public jvirt_array<JBLOCK>[] jpeg_read_coefficients()
{
if (m_global_state == JpegState.DSTATE_READY)
{
/* First call: initialize active modules */
transdecode_master_selection();
m_global_state = JpegState.DSTATE_RDCOEFS;
}
if (m_global_state == JpegState.DSTATE_RDCOEFS)
{
/* Absorb whole file into the coef buffer */
for ( ; ; )
{
ReadResult retcode;
/* Call progress monitor hook if present */
if (m_progress != null)
m_progress.Updated();
/* Absorb some more input */
retcode = m_inputctl.consume_input();
if (retcode == ReadResult.JPEG_SUSPENDED)
return null;
if (retcode == ReadResult.JPEG_REACHED_EOI)
break;
/* Advance progress counter if appropriate */
if (m_progress != null && (retcode == ReadResult.JPEG_ROW_COMPLETED || retcode == ReadResult.JPEG_REACHED_SOS))
{
m_progress.Pass_counter++;
if (m_progress.Pass_counter >= m_progress.Pass_limit)
{
/* startup underestimated number of scans; ratchet up one scan */
m_progress.Pass_limit += m_total_iMCU_rows;
}
}
}
/* Set state so that jpeg_finish_decompress does the right thing */
m_global_state = JpegState.DSTATE_STOPPING;
}
/* At this point we should be in state DSTATE_STOPPING if being used
* standalone, or in state DSTATE_BUFIMAGE if being invoked to get access
* to the coefficients during a full buffered-image-mode decompression.
*/
if ((m_global_state == JpegState.DSTATE_STOPPING || m_global_state == JpegState.DSTATE_BUFIMAGE) && m_buffered_image)
return m_coef.GetCoefArrays();
/* Oops, improper usage */
ERREXIT(J_MESSAGE_CODE.JERR_BAD_STATE, (int)m_global_state);
/* keep compiler happy */
return null;
}