consume_data_multi_scan(j_decompress_ptr cinfo) { huffman_index *index = cinfo->entropy->index; int i, retcode, ci; int mcu = cinfo->input_iMCU_row; jinit_phuff_decoder(cinfo); for (i = 0; i < index->scan_count; i++) { (*cinfo->inputctl->finish_input_pass)(cinfo); jset_input_stream_position(cinfo, index->scan[i].bitstream_offset); cinfo->output_iMCU_row = mcu; cinfo->unread_marker = 0; // Consume SOS and DHT headers retcode = (*cinfo->inputctl->consume_markers)(cinfo, index, i); cinfo->input_iMCU_row = mcu; cinfo->input_scan_number = i; cinfo->entropy->index = index; // Consume scan block data consume_data(cinfo); } cinfo->input_iMCU_row = mcu + 1; cinfo->input_scan_number = 0; cinfo->output_scan_number = 0; return JPEG_ROW_COMPLETED; }
jpeg_build_huffman_index_progressive(j_decompress_ptr cinfo, huffman_index *index) { if (cinfo->global_state == DSTATE_READY) { JPEG_TRACE("Progressive Mode\n"); /* First call: initialize active modules */ transdecode_master_selection(cinfo); cinfo->global_state = DSTATE_RDCOEFS; } if (cinfo->global_state == DSTATE_RDCOEFS) { int mcu, i; cinfo->marker->get_sos_marker_position(cinfo, index); /* Absorb whole file into the coef buffer */ for (mcu = 0; (unsigned int)mcu < cinfo->total_iMCU_rows; mcu++) { int retcode = 0; /* Call progress monitor hook if present */ if (cinfo->progress != NULL) (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); /* Absorb some more input */ jinit_phuff_decoder(cinfo); for (i = 0; i < index->scan_count; i++) { (*cinfo->inputctl->finish_input_pass) (cinfo); jset_input_stream_position(cinfo, index->scan[i].bitstream_offset); cinfo->unread_marker = 0; retcode = (*cinfo->inputctl->consume_input_build_huffman_index) (cinfo, index, i); if (retcode == JPEG_REACHED_EOI) break; cinfo->input_iMCU_row = mcu; if (mcu != 0) (*cinfo->entropy->configure_huffman_decoder) (cinfo, index->scan[i].prev_MCU_offset); cinfo->input_scan_number = i; retcode = (*cinfo->inputctl->consume_input_build_huffman_index) (cinfo, index, i); } if (retcode == JPEG_SUSPENDED) return FALSE; if (retcode == JPEG_REACHED_EOI) break; /* Advance progress counter if appropriate */ if (cinfo->progress != NULL && (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { /* startup underestimated number of scans; ratchet up one scan */ cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; } } } cinfo->global_state = 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 ((cinfo->global_state == DSTATE_STOPPING || cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) { return TRUE; } /* Oops, improper usage */ ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); return FALSE; /* keep compiler happy */ }