private int emit_dqt(int index)
{
JQUANT_TBL qtbl = m_cinfo.m_quant_tbl_ptrs[index];
if (qtbl == null)
m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_NO_QUANT_TABLE, index);
int prec = 0;
for (int i = 0; i <= m_cinfo.lim_Se; i++)
{
if (qtbl.quantval[m_cinfo.natural_order[i]] > 255)
prec = 1;
}
if (!qtbl.Sent_table)
{
emit_marker(JPEG_MARKER.DQT);
emit_2bytes(prec != 0 ?
m_cinfo.lim_Se * 2 + 2 + 1 + 2 : m_cinfo.lim_Se + 1 + 1 + 2);
emit_byte(index + (prec << 4));
for (int i = 0; i <= m_cinfo.lim_Se; i++)
{
/* The table entries must be emitted in zigzag order. */
int qval = qtbl.quantval[m_cinfo.natural_order[i]];
if (prec != 0)
emit_byte(qval >> 8);
emit_byte(qval & 0xFF);
}
qtbl.Sent_table = true;
}
return prec;
}