public void write_scan_header()
{
if (m_cinfo.arith_code)
{
/* Emit arith conditioning info. We may have some duplication
* if the file has multiple scans, but it's so small it's hardly
* worth worrying about.
*/
emit_dac();
}
else
{
/* Emit Huffman tables.
* Note that emit_dht() suppresses any duplicate tables.
*/
for (int i = 0; i < m_cinfo.m_comps_in_scan; i++)
{
jpeg_component_info compptr = m_cinfo.Component_info[m_cinfo.m_cur_comp_info[i]];
/* DC needs no table for refinement scan */
if (m_cinfo.m_Ss == 0 && m_cinfo.m_Ah == 0)
emit_dht(compptr.Dc_tbl_no, false);
/* AC needs no table when not present */
if (m_cinfo.m_Se != 0)
emit_dht(compptr.Ac_tbl_no, true);
}
/* Emit DRI if required --- note that DRI value could change for each scan.
* We avoid wasting space with unnecessary DRIs, however.
*/
if (m_cinfo.m_restart_interval != m_last_restart_interval)
{
emit_dri();
m_last_restart_interval = m_cinfo.m_restart_interval;
}
emit_sos();
}
}