Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #define JPEG_INTERNALS
00014 #include "jinclude.h"
00015 #include "jpeglib.h"
00016
00017
00018
00019 LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo));
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 GLOBAL(jvirt_barray_ptr *)
00045 jpeg_read_coefficients (j_decompress_ptr cinfo)
00046 {
00047 if (cinfo->global_state == DSTATE_READY) {
00048
00049 transdecode_master_selection(cinfo);
00050 cinfo->global_state = DSTATE_RDCOEFS;
00051 }
00052 if (cinfo->global_state == DSTATE_RDCOEFS) {
00053
00054 for (;;) {
00055 int retcode;
00056
00057 if (cinfo->progress != NULL)
00058 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
00059
00060 retcode = (*cinfo->inputctl->consume_input) (cinfo);
00061 if (retcode == JPEG_SUSPENDED)
00062 return NULL;
00063 if (retcode == JPEG_REACHED_EOI)
00064 break;
00065
00066 if (cinfo->progress != NULL &&
00067 (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
00068 if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
00069
00070 cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
00071 }
00072 }
00073 }
00074
00075 cinfo->global_state = DSTATE_STOPPING;
00076 }
00077
00078
00079
00080
00081 if ((cinfo->global_state == DSTATE_STOPPING ||
00082 cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) {
00083 return cinfo->coef->coef_arrays;
00084 }
00085
00086 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
00087 return NULL;
00088 }
00089
00090
00091
00092
00093
00094
00095
00096 LOCAL(void)
00097 transdecode_master_selection (j_decompress_ptr cinfo)
00098 {
00099
00100 cinfo->buffered_image = TRUE;
00101
00102
00103 if (cinfo->arith_code) {
00104 ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
00105 } else {
00106 if (cinfo->progressive_mode) {
00107 #ifdef D_PROGRESSIVE_SUPPORTED
00108 jinit_phuff_decoder(cinfo);
00109 #else
00110 ERREXIT(cinfo, JERR_NOT_COMPILED);
00111 #endif
00112 } else
00113 jinit_huff_decoder(cinfo);
00114 }
00115
00116
00117 jinit_d_coef_controller(cinfo, TRUE);
00118
00119
00120 (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
00121
00122
00123 (*cinfo->inputctl->start_input_pass) (cinfo);
00124
00125
00126 if (cinfo->progress != NULL) {
00127 int nscans;
00128
00129 if (cinfo->progressive_mode) {
00130
00131 nscans = 2 + 3 * cinfo->num_components;
00132 } else if (cinfo->inputctl->has_multiple_scans) {
00133
00134 nscans = cinfo->num_components;
00135 } else {
00136 nscans = 1;
00137 }
00138 cinfo->progress->pass_counter = 0L;
00139 cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
00140 cinfo->progress->completed_passes = 0;
00141 cinfo->progress->total_passes = 1;
00142 }
00143 }