public bool read_restart_marker()
{
/* Obtain a marker unless we already did. */
/* Note that next_marker will complain if it skips any data. */
if (m_cinfo.m_unread_marker == 0)
{
if (!next_marker())
return false;
}
if (m_cinfo.m_unread_marker == ((int)JPEG_MARKER.RST0 + m_cinfo.m_marker.m_next_restart_num))
{
/* Normal case --- swallow the marker and let entropy decoder continue */
m_cinfo.TRACEMS(3, J_MESSAGE_CODE.JTRC_RST, m_cinfo.m_marker.m_next_restart_num);
m_cinfo.m_unread_marker = 0;
}
else
{
/* Uh-oh, the restart markers have been messed up. */
/* Let the data source manager determine how to resync. */
if (!m_cinfo.m_src.resync_to_restart(m_cinfo, m_cinfo.m_marker.m_next_restart_num))
return false;
}
/* Update next-restart state */
m_cinfo.m_marker.m_next_restart_num = (m_cinfo.m_marker.m_next_restart_num + 1) & 7;
return true;
}