private void emit_dht(int index, bool is_ac)
{
JHUFF_TBL htbl = m_cinfo.m_dc_huff_tbl_ptrs[index];
if (is_ac)
{
htbl = m_cinfo.m_ac_huff_tbl_ptrs[index];
index += 0x10; /* output index has AC bit set */
}
if (htbl == null)
m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_NO_HUFF_TABLE, index);
if (!htbl.Sent_table)
{
emit_marker(JPEG_MARKER.DHT);
int length = 0;
for (int i = 1; i <= 16; i++)
length += htbl.Bits[i];
emit_2bytes(length + 2 + 1 + 16);
emit_byte(index);
for (int i = 1; i <= 16; i++)
emit_byte(htbl.Bits[i]);
for (int i = 0; i < length; i++)
emit_byte(htbl.Huffval[i]);
htbl.Sent_table = true;
}
}