BitMiracle.LibJpeg.Classic.Internal.huff_entropy_encoder.encode_mcu_DC_refine C# (CSharp) Method

encode_mcu_DC_refine() private method

MCU encoding for DC successive approximation refinement scan. Note: we assume such scans can be multi-component, although the spec is not very clear on the point.
private encode_mcu_DC_refine ( JBLOCK MCU_data ) : bool
MCU_data JBLOCK
return bool
        private bool encode_mcu_DC_refine(JBLOCK[][] MCU_data)
        {
            /* Emit restart marker if needed */
            if (m_cinfo.m_restart_interval != 0)
            {
                if (m_restarts_to_go == 0)
                    emit_restart_e(m_next_restart_num);
            }

            /* Encode the MCU data blocks */
            for (int blkn = 0; blkn < m_cinfo.m_blocks_in_MCU; blkn++)
            {
                /* We simply emit the Al'th bit of the DC coefficient value. */
                int temp = MCU_data[blkn][0][0];
                emit_bits_e(temp >> m_cinfo.m_Al, 1);
            }

            /* Update restart-interval state too */
            if (m_cinfo.m_restart_interval != 0)
            {
                if (m_restarts_to_go == 0)
                {
                    m_restarts_to_go = m_cinfo.m_restart_interval;
                    m_next_restart_num++;
                    m_next_restart_num &= 7;
                }
                m_restarts_to_go--;
            }

            return true;
        }