private bool get_dac()
{
int length;
if (!m_cinfo.m_src.GetTwoBytes(out length))
return false;
length -= 2;
while (length > 0)
{
int index;
if (!m_cinfo.m_src.GetByte(out index))
return false;
int val;
if (!m_cinfo.m_src.GetByte(out val))
return false;
length -= 2;
m_cinfo.TRACEMS(1, J_MESSAGE_CODE.JTRC_DAC, index, val);
if (index < 0 || index >= (2 * JpegConstants.NUM_ARITH_TBLS))
m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_DAC_INDEX, index);
if (index >= JpegConstants.NUM_ARITH_TBLS)
{ /* define AC table */
m_cinfo.arith_ac_K[index - JpegConstants.NUM_ARITH_TBLS] = (byte)val;
}
else { /* define DC table */
m_cinfo.arith_dc_L[index] = (byte)(val & 0x0F);
m_cinfo.arith_dc_U[index] = (byte)(val >> 4);
if (m_cinfo.arith_dc_L[index] > m_cinfo.arith_dc_U[index])
m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_DAC_VALUE, val);
}
}
if (length != 0)
m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_BAD_LENGTH);
return true;
}