private bool decode_mcu_DC_refine(JBLOCK[] MCU_data)
{
/* Process restart marker if needed; may have to suspend */
if (m_cinfo.m_restart_interval != 0)
{
if (m_restarts_to_go == 0)
{
if (!process_restart())
return false;
}
}
/* Not worth the cycles to check insufficient_data here,
* since we will not change the data anyway if we read zeroes.
*/
/* Load up working state */
int get_buffer;
int bits_left;
bitread_working_state br_state = new bitread_working_state();
BITREAD_LOAD_STATE(m_bitstate, out get_buffer, out bits_left, ref br_state);
int p1 = 1 << m_cinfo.m_Al;
/* Outer loop handles each block in the MCU */
for (int blkn = 0; blkn < m_cinfo.m_blocks_in_MCU; blkn++)
{
/* Encoded data is simply the next bit of the two's-complement DC value */
if (!CHECK_BIT_BUFFER(ref br_state, 1, ref get_buffer, ref bits_left))
return false;
if (GET_BITS(1, get_buffer, ref bits_left) != 0)
{
/* 1 in the bit position being coded */
MCU_data[blkn][0] = (short)((ushort)MCU_data[blkn][0] | p1);
}
/* Note: since we use |=, repeating the assignment later is safe */
}
/* Completed MCU, so update state */
BITREAD_SAVE_STATE(ref m_bitstate, get_buffer, bits_left);
/* Account for restart interval (no-op if not using restarts) */
m_restarts_to_go--;
return true;
}