Doxygen Source Code Documentation
jdinput.c File Reference
#include "jinclude.h"#include "jpeglib.h"Go to the source code of this file.
Data Structures | |
| struct | my_input_controller |
Defines | |
| #define | JPEG_INTERNALS |
Typedefs | |
| typedef my_input_controller * | my_inputctl_ptr |
Functions | |
| METHODDEF (int) consume_markers JPP((j_decompress_ptr cinfo)) | |
| initial_setup (j_decompress_ptr cinfo) | |
| per_scan_setup (j_decompress_ptr cinfo) | |
| latch_quant_tables (j_decompress_ptr cinfo) | |
| start_input_pass (j_decompress_ptr cinfo) | |
| finish_input_pass (j_decompress_ptr cinfo) | |
| consume_markers (j_decompress_ptr cinfo) | |
| reset_input_controller (j_decompress_ptr cinfo) | |
| jinit_input_controller (j_decompress_ptr cinfo) | |
Define Documentation
|
|
|
Typedef Documentation
|
|
|
Function Documentation
|
|
Definition at line 288 of file jdinput.c. References jpeg_input_controller::eoi_reached, ERREXIT, jpeg_input_controller::has_multiple_scans, my_input_controller::inheaders, initial_setup(), jpeg_decompress_struct::input_scan_number, jpeg_decompress_struct::inputctl, JPEG_REACHED_EOI, JPEG_REACHED_SOS, JPEG_SUSPENDED, jpeg_decompress_struct::marker, jpeg_decompress_struct::output_scan_number, my_input_controller::pub, jpeg_marker_reader::saw_SOF, and start_input_pass(). Referenced by finish_input_pass(), jinit_input_controller(), and reset_input_controller().
00289 {
00290 my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;
00291 int val;
00292
00293 if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */
00294 return JPEG_REACHED_EOI;
00295
00296 val = (*cinfo->marker->read_markers) (cinfo);
00297
00298 switch (val) {
00299 case JPEG_REACHED_SOS: /* Found SOS */
00300 if (inputctl->inheaders) { /* 1st SOS */
00301 initial_setup(cinfo);
00302 inputctl->inheaders = FALSE;
00303 /* Note: start_input_pass must be called by jdmaster.c
00304 * before any more input can be consumed. jdapimin.c is
00305 * responsible for enforcing this sequencing.
00306 */
00307 } else { /* 2nd or later SOS marker */
00308 if (! inputctl->pub.has_multiple_scans)
00309 ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */
00310 start_input_pass(cinfo);
00311 }
00312 break;
00313 case JPEG_REACHED_EOI: /* Found EOI */
00314 inputctl->pub.eoi_reached = TRUE;
00315 if (inputctl->inheaders) { /* Tables-only datastream, apparently */
00316 if (cinfo->marker->saw_SOF)
00317 ERREXIT(cinfo, JERR_SOF_NO_SOS);
00318 } else {
00319 /* Prevent infinite loop in coef ctlr's decompress_data routine
00320 * if user set output_scan_number larger than number of scans.
00321 */
00322 if (cinfo->output_scan_number > cinfo->input_scan_number)
00323 cinfo->output_scan_number = cinfo->input_scan_number;
00324 }
00325 break;
00326 case JPEG_SUSPENDED:
00327 break;
00328 }
00329
00330 return val;
00331 }
|
|
|
Definition at line 271 of file jdinput.c. References consume_markers(), and jpeg_decompress_struct::inputctl. Referenced by jinit_input_controller().
00272 {
00273 cinfo->inputctl->consume_input = consume_markers;
00274 }
|
|
|
Definition at line 39 of file jdinput.c. References BITS_IN_JSAMPLE, jpeg_decompress_struct::comp_info, jpeg_component_info::component_needed, compptr, jpeg_decompress_struct::comps_in_scan, jpeg_decompress_struct::data_precision, jpeg_component_info::DCT_scaled_size, jpeg_component_info::downsampled_height, jpeg_component_info::downsampled_width, ERREXIT, ERREXIT1, ERREXIT2, jpeg_component_info::h_samp_factor, jpeg_input_controller::has_multiple_scans, jpeg_component_info::height_in_blocks, jpeg_decompress_struct::image_height, jpeg_decompress_struct::image_width, jpeg_decompress_struct::inputctl, jdiv_round_up(), JPEG_MAX_DIMENSION, MAX, MAX_COMPONENTS, jpeg_decompress_struct::max_h_samp_factor, MAX_SAMP_FACTOR, jpeg_decompress_struct::max_v_samp_factor, jpeg_decompress_struct::min_DCT_scaled_size, jpeg_decompress_struct::num_components, jpeg_decompress_struct::progressive_mode, jpeg_component_info::quant_table, jpeg_decompress_struct::total_iMCU_rows, jpeg_component_info::v_samp_factor, and jpeg_component_info::width_in_blocks. Referenced by consume_markers(), and jinit_c_master_control().
00041 {
00042 int ci;
00043 jpeg_component_info *compptr;
00044
00045 /* Make sure image isn't bigger than I can handle */
00046 if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION ||
00047 (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)
00048 ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
00049
00050 /* For now, precision must match compiled-in value... */
00051 if (cinfo->data_precision != BITS_IN_JSAMPLE)
00052 ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
00053
00054 /* Check that number of components won't exceed internal array sizes */
00055 if (cinfo->num_components > MAX_COMPONENTS)
00056 ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
00057 MAX_COMPONENTS);
00058
00059 /* Compute maximum sampling factors; check factor validity */
00060 cinfo->max_h_samp_factor = 1;
00061 cinfo->max_v_samp_factor = 1;
00062 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00063 ci++, compptr++) {
00064 if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||
00065 compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)
00066 ERREXIT(cinfo, JERR_BAD_SAMPLING);
00067 cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
00068 compptr->h_samp_factor);
00069 cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
00070 compptr->v_samp_factor);
00071 }
00072
00073 /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.
00074 * In the full decompressor, this will be overridden by jdmaster.c;
00075 * but in the transcoder, jdmaster.c is not used, so we must do it here.
00076 */
00077 cinfo->min_DCT_scaled_size = DCTSIZE;
00078
00079 /* Compute dimensions of components */
00080 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00081 ci++, compptr++) {
00082 compptr->DCT_scaled_size = DCTSIZE;
00083 /* Size in DCT blocks */
00084 compptr->width_in_blocks = (JDIMENSION)
00085 jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
00086 (long) (cinfo->max_h_samp_factor * DCTSIZE));
00087 compptr->height_in_blocks = (JDIMENSION)
00088 jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
00089 (long) (cinfo->max_v_samp_factor * DCTSIZE));
00090 /* downsampled_width and downsampled_height will also be overridden by
00091 * jdmaster.c if we are doing full decompression. The transcoder library
00092 * doesn't use these values, but the calling application might.
00093 */
00094 /* Size in samples */
00095 compptr->downsampled_width = (JDIMENSION)
00096 jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
00097 (long) cinfo->max_h_samp_factor);
00098 compptr->downsampled_height = (JDIMENSION)
00099 jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
00100 (long) cinfo->max_v_samp_factor);
00101 /* Mark component needed, until color conversion says otherwise */
00102 compptr->component_needed = TRUE;
00103 /* Mark no quantization table yet saved for component */
00104 compptr->quant_table = NULL;
00105 }
00106
00107 /* Compute number of fully interleaved MCU rows. */
00108 cinfo->total_iMCU_rows = (JDIMENSION)
00109 jdiv_round_up((long) cinfo->image_height,
00110 (long) (cinfo->max_v_samp_factor*DCTSIZE));
00111
00112 /* Decide whether file contains multiple scans */
00113 if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)
00114 cinfo->inputctl->has_multiple_scans = TRUE;
00115 else
00116 cinfo->inputctl->has_multiple_scans = FALSE;
00117 }
|
|
|
Definition at line 361 of file jdinput.c. References consume_markers(), jpeg_input_controller::eoi_reached, finish_input_pass(), jpeg_input_controller::has_multiple_scans, JPOOL_PERMANENT, reset_input_controller(), SIZEOF, and start_input_pass(). Referenced by jpeg_CreateDecompress().
00362 {
00363 my_inputctl_ptr inputctl;
00364
00365 /* Create subobject in permanent pool */
00366 inputctl = (my_inputctl_ptr)
00367 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
00368 SIZEOF(my_input_controller));
00369 cinfo->inputctl = (struct jpeg_input_controller *) inputctl;
00370 /* Initialize method pointers */
00371 inputctl->pub.consume_input = consume_markers;
00372 inputctl->pub.reset_input_controller = reset_input_controller;
00373 inputctl->pub.start_input_pass = start_input_pass;
00374 inputctl->pub.finish_input_pass = finish_input_pass;
00375 /* Initialize state: can't use reset_input_controller since we don't
00376 * want to try to reset other modules yet.
00377 */
00378 inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
00379 inputctl->pub.eoi_reached = FALSE;
00380 inputctl->inheaders = TRUE;
00381 }
|
|
|
Definition at line 220 of file jdinput.c. References compptr, jpeg_decompress_struct::comps_in_scan, jpeg_decompress_struct::cur_comp_info, ERREXIT1, JPOOL_IMAGE, MEMCOPY, NUM_QUANT_TBLS, jpeg_component_info::quant_table, jpeg_component_info::quant_tbl_no, jpeg_decompress_struct::quant_tbl_ptrs, and SIZEOF. Referenced by start_input_pass().
00221 {
00222 int ci, qtblno;
00223 jpeg_component_info *compptr;
00224 JQUANT_TBL * qtbl;
00225
00226 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
00227 compptr = cinfo->cur_comp_info[ci];
00228 /* No work if we already saved Q-table for this component */
00229 if (compptr->quant_table != NULL)
00230 continue;
00231 /* Make sure specified quantization table is present */
00232 qtblno = compptr->quant_tbl_no;
00233 if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
00234 cinfo->quant_tbl_ptrs[qtblno] == NULL)
00235 ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
00236 /* OK, save away the quantization table */
00237 qtbl = (JQUANT_TBL *)
00238 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00239 SIZEOF(JQUANT_TBL));
00240 MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL));
00241 compptr->quant_table = qtbl;
00242 }
00243 }
|
|
|
|
|
|
Definition at line 121 of file jdinput.c. References jpeg_decompress_struct::blocks_in_MCU, compptr, jpeg_decompress_struct::comps_in_scan, jpeg_decompress_struct::cur_comp_info, D_MAX_BLOCKS_IN_MCU, jpeg_component_info::DCT_scaled_size, ERREXIT, ERREXIT2, jpeg_component_info::h_samp_factor, jpeg_component_info::height_in_blocks, jpeg_decompress_struct::image_height, jpeg_decompress_struct::image_width, jdiv_round_up(), jpeg_component_info::last_col_width, jpeg_component_info::last_row_height, MAX_COMPS_IN_SCAN, jpeg_decompress_struct::max_h_samp_factor, jpeg_decompress_struct::max_v_samp_factor, jpeg_component_info::MCU_blocks, jpeg_component_info::MCU_height, jpeg_decompress_struct::MCU_membership, jpeg_decompress_struct::MCU_rows_in_scan, jpeg_component_info::MCU_sample_width, jpeg_component_info::MCU_width, jpeg_decompress_struct::MCUs_per_row, jpeg_component_info::v_samp_factor, and jpeg_component_info::width_in_blocks. Referenced by prepare_for_pass(), and start_input_pass().
00124 {
00125 int ci, mcublks, tmp;
00126 jpeg_component_info *compptr;
00127
00128 if (cinfo->comps_in_scan == 1) {
00129
00130 /* Noninterleaved (single-component) scan */
00131 compptr = cinfo->cur_comp_info[0];
00132
00133 /* Overall image size in MCUs */
00134 cinfo->MCUs_per_row = compptr->width_in_blocks;
00135 cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
00136
00137 /* For noninterleaved scan, always one block per MCU */
00138 compptr->MCU_width = 1;
00139 compptr->MCU_height = 1;
00140 compptr->MCU_blocks = 1;
00141 compptr->MCU_sample_width = compptr->DCT_scaled_size;
00142 compptr->last_col_width = 1;
00143 /* For noninterleaved scans, it is convenient to define last_row_height
00144 * as the number of block rows present in the last iMCU row.
00145 */
00146 tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
00147 if (tmp == 0) tmp = compptr->v_samp_factor;
00148 compptr->last_row_height = tmp;
00149
00150 /* Prepare array describing MCU composition */
00151 cinfo->blocks_in_MCU = 1;
00152 cinfo->MCU_membership[0] = 0;
00153
00154 } else {
00155
00156 /* Interleaved (multi-component) scan */
00157 if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
00158 ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
00159 MAX_COMPS_IN_SCAN);
00160
00161 /* Overall image size in MCUs */
00162 cinfo->MCUs_per_row = (JDIMENSION)
00163 jdiv_round_up((long) cinfo->image_width,
00164 (long) (cinfo->max_h_samp_factor*DCTSIZE));
00165 cinfo->MCU_rows_in_scan = (JDIMENSION)
00166 jdiv_round_up((long) cinfo->image_height,
00167 (long) (cinfo->max_v_samp_factor*DCTSIZE));
00168
00169 cinfo->blocks_in_MCU = 0;
00170
00171 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
00172 compptr = cinfo->cur_comp_info[ci];
00173 /* Sampling factors give # of blocks of component in each MCU */
00174 compptr->MCU_width = compptr->h_samp_factor;
00175 compptr->MCU_height = compptr->v_samp_factor;
00176 compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
00177 compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size;
00178 /* Figure number of non-dummy blocks in last MCU column & row */
00179 tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
00180 if (tmp == 0) tmp = compptr->MCU_width;
00181 compptr->last_col_width = tmp;
00182 tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);
00183 if (tmp == 0) tmp = compptr->MCU_height;
00184 compptr->last_row_height = tmp;
00185 /* Prepare array describing MCU composition */
00186 mcublks = compptr->MCU_blocks;
00187 if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU)
00188 ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
00189 while (mcublks-- > 0) {
00190 cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
00191 }
00192 }
00193
00194 }
00195 }
|
|
|
Definition at line 339 of file jdinput.c. References jpeg_decompress_struct::coef_bits, consume_markers(), jpeg_input_controller::eoi_reached, jpeg_input_controller::has_multiple_scans, my_input_controller::inheaders, jpeg_decompress_struct::inputctl, jpeg_decompress_struct::marker, and my_input_controller::pub. Referenced by jinit_input_controller().
00340 {
00341 my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;
00342
00343 inputctl->pub.consume_input = consume_markers;
00344 inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
00345 inputctl->pub.eoi_reached = FALSE;
00346 inputctl->inheaders = TRUE;
00347 /* Reset other modules */
00348 (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
00349 (*cinfo->marker->reset_marker_reader) (cinfo);
00350 /* Reset progression state -- would be cleaner if entropy decoder did this */
00351 cinfo->coef_bits = NULL;
00352 }
|
|
|
Definition at line 254 of file jdinput.c. References jpeg_decompress_struct::coef, jpeg_decompress_struct::entropy, jpeg_decompress_struct::inputctl, latch_quant_tables(), and per_scan_setup(). Referenced by consume_markers(), and jinit_input_controller().
00255 {
00256 per_scan_setup(cinfo);
00257 latch_quant_tables(cinfo);
00258 (*cinfo->entropy->start_pass) (cinfo);
00259 (*cinfo->coef->start_input_pass) (cinfo);
00260 cinfo->inputctl->consume_input = cinfo->coef->consume_data;
00261 }
|