private bool output_pass_setup()
{
if (m_global_state != JpegState.DSTATE_PRESCAN)
{
/* First call: do pass setup */
m_master.prepare_for_output_pass();
m_output_scanline = 0;
m_global_state = JpegState.DSTATE_PRESCAN;
}
/* Loop over any required dummy passes */
while (m_master.IsDummyPass())
{
/* Crank through the dummy pass */
while (m_output_scanline < m_output_height)
{
int last_scanline;
/* Call progress monitor hook if present */
if (m_progress != null)
{
m_progress.Pass_counter = m_output_scanline;
m_progress.Pass_limit = m_output_height;
m_progress.Updated();
}
/* Process some data */
last_scanline = m_output_scanline;
m_main.process_data(null, ref m_output_scanline, 0);
if (m_output_scanline == last_scanline)
{
/* No progress made, must suspend */
return false;
}
}
/* Finish up dummy pass, and set up for another one */
m_master.finish_output_pass();
m_master.prepare_for_output_pass();
m_output_scanline = 0;
}
/* Ready for application to drive output pass through
* jpeg_read_scanlines or jpeg_read_raw_data.
*/
m_global_state = m_raw_data_out ? JpegState.DSTATE_RAW_OK : JpegState.DSTATE_SCANNING;
return true;
}