private void emit_bits_e(int code, int size)
{
/* This routine is heavily used, so it's worth coding tightly. */
/* if size is 0, caller used an invalid Huffman table entry */
if (size == 0)
m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_HUFF_MISSING_CODE);
if (m_gather_statistics)
{
/* do nothing if we're only getting stats */
return;
}
int local_put_buffer = code & ((1 << size) - 1); /* mask off any extra bits in code */
int put_bits = size + m_saved.put_bits; /* new number of bits in buffer */
local_put_buffer <<= 24 - put_bits; /* align incoming bits */
local_put_buffer |= m_saved.put_buffer; /* and merge with old buffer contents */
while (put_bits >= 8)
{
int c = (local_put_buffer >> 16) & 0xFF;
emit_byte_e(c);
if (c == 0xFF)
{
/* need to stuff a zero byte? */
emit_byte_e(0);
}
local_put_buffer <<= 8;
put_bits -= 8;
}
m_saved.put_buffer = local_put_buffer; /* update variables */
m_saved.put_bits = put_bits;
}