jdmaster.c
Go to the documentation of this file.
00001 /*
00002  * jdmaster.c
00003  *
00004  * Copyright (C) 1991-1997, Thomas G. Lane.
00005  * This file is part of the Independent JPEG Group's software.
00006  * For conditions of distribution and use, see the accompanying README file.
00007  *
00008  * This file contains master control logic for the JPEG decompressor.
00009  * These routines are concerned with selecting the modules to be executed
00010  * and with determining the number of passes and the work to be done in each
00011  * pass.
00012  */
00013 
00014 #define JPEG_INTERNALS
00015 #include "jinclude.h"
00016 #include "jpeglib.h"
00017 
00018 
00019 /* Private state */
00020 
00021 typedef struct {
00022   struct jpeg_decomp_master pub; /* public fields */
00023 
00024   int pass_number;              /* # of passes completed */
00025 
00026   boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */
00027 
00028   /* Saved references to initialized quantizer modules,
00029    * in case we need to switch modes.
00030    */
00031   struct jpeg_color_quantizer * quantizer_1pass;
00032   struct jpeg_color_quantizer * quantizer_2pass;
00033 } my_decomp_master;
00034 
00035 typedef my_decomp_master * my_master_ptr;
00036 
00037 
00038 /*
00039  * Determine whether merged upsample/color conversion should be used.
00040  * CRUCIAL: this must match the actual capabilities of jdmerge.c!
00041  */
00042 
00043 LOCAL(boolean)
00044 use_merged_upsample (j_decompress_ptr cinfo)
00045 {
00046 #ifdef UPSAMPLE_MERGING_SUPPORTED
00047   /* Merging is the equivalent of plain box-filter upsampling */
00048   if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
00049     return FALSE;
00050   /* jdmerge.c only supports YCC=>RGB color conversion */
00051   if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
00052       cinfo->out_color_space != JCS_RGB ||
00053       cinfo->out_color_components != RGB_PIXELSIZE)
00054     return FALSE;
00055   /* and it only handles 2h1v or 2h2v sampling ratios */
00056   if (cinfo->comp_info[0].h_samp_factor != 2 ||
00057       cinfo->comp_info[1].h_samp_factor != 1 ||
00058       cinfo->comp_info[2].h_samp_factor != 1 ||
00059       cinfo->comp_info[0].v_samp_factor >  2 ||
00060       cinfo->comp_info[1].v_samp_factor != 1 ||
00061       cinfo->comp_info[2].v_samp_factor != 1)
00062     return FALSE;
00063   /* furthermore, it doesn't work if we've scaled the IDCTs differently */
00064   if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
00065       cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
00066       cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size)
00067     return FALSE;
00068   /* ??? also need to test for upsample-time rescaling, when & if supported */
00069   return TRUE;                  /* by golly, it'll work... */
00070 #else
00071   return FALSE;
00072 #endif
00073 }
00074 
00075 
00076 /*
00077  * Compute output image dimensions and related values.
00078  * NOTE: this is exported for possible use by application.
00079  * Hence it mustn't do anything that can't be done twice.
00080  * Also note that it may be called before the master module is initialized!
00081  */
00082 
00083 GLOBAL(void)
00084 jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
00085 /* Do computations that are needed before master selection phase */
00086 {
00087 #ifdef IDCT_SCALING_SUPPORTED
00088   int ci;
00089   jpeg_component_info *compptr;
00090 #endif
00091 
00092   /* Prevent application from calling me at wrong times */
00093   if (cinfo->global_state != DSTATE_READY)
00094     ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
00095 
00096 #ifdef IDCT_SCALING_SUPPORTED
00097 
00098   /* Compute actual output image dimensions and DCT scaling choices. */
00099   if (cinfo->scale_num * 8 <= cinfo->scale_denom) {
00100     /* Provide 1/8 scaling */
00101     cinfo->output_width = (JDIMENSION)
00102       jdiv_round_up((long) cinfo->image_width, 8L);
00103     cinfo->output_height = (JDIMENSION)
00104       jdiv_round_up((long) cinfo->image_height, 8L);
00105     cinfo->min_DCT_scaled_size = 1;
00106   } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {
00107     /* Provide 1/4 scaling */
00108     cinfo->output_width = (JDIMENSION)
00109       jdiv_round_up((long) cinfo->image_width, 4L);
00110     cinfo->output_height = (JDIMENSION)
00111       jdiv_round_up((long) cinfo->image_height, 4L);
00112     cinfo->min_DCT_scaled_size = 2;
00113   } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {
00114     /* Provide 1/2 scaling */
00115     cinfo->output_width = (JDIMENSION)
00116       jdiv_round_up((long) cinfo->image_width, 2L);
00117     cinfo->output_height = (JDIMENSION)
00118       jdiv_round_up((long) cinfo->image_height, 2L);
00119     cinfo->min_DCT_scaled_size = 4;
00120   } else {
00121     /* Provide 1/1 scaling */
00122     cinfo->output_width = cinfo->image_width;
00123     cinfo->output_height = cinfo->image_height;
00124     cinfo->min_DCT_scaled_size = DCTSIZE;
00125   }
00126   /* In selecting the actual DCT scaling for each component, we try to
00127    * scale up the chroma components via IDCT scaling rather than upsampling.
00128    * This saves time if the upsampler gets to use 1:1 scaling.
00129    * Note this code assumes that the supported DCT scalings are powers of 2.
00130    */
00131   for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00132        ci++, compptr++) {
00133     int ssize = cinfo->min_DCT_scaled_size;
00134     while (ssize < DCTSIZE &&
00135            (compptr->h_samp_factor * ssize * 2 <=
00136             cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) &&
00137            (compptr->v_samp_factor * ssize * 2 <=
00138             cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) {
00139       ssize = ssize * 2;
00140     }
00141     compptr->DCT_scaled_size = ssize;
00142   }
00143 
00144   /* Recompute downsampled dimensions of components;
00145    * application needs to know these if using raw downsampled data.
00146    */
00147   for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00148        ci++, compptr++) {
00149     /* Size in samples, after IDCT scaling */
00150     compptr->downsampled_width = (JDIMENSION)
00151       jdiv_round_up((long) cinfo->image_width *
00152                     (long) (compptr->h_samp_factor * compptr->DCT_scaled_size),
00153                     (long) (cinfo->max_h_samp_factor * DCTSIZE));
00154     compptr->downsampled_height = (JDIMENSION)
00155       jdiv_round_up((long) cinfo->image_height *
00156                     (long) (compptr->v_samp_factor * compptr->DCT_scaled_size),
00157                     (long) (cinfo->max_v_samp_factor * DCTSIZE));
00158   }
00159 
00160 #else /* !IDCT_SCALING_SUPPORTED */
00161 
00162   /* Hardwire it to "no scaling" */
00163   cinfo->output_width = cinfo->image_width;
00164   cinfo->output_height = cinfo->image_height;
00165   /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
00166    * and has computed unscaled downsampled_width and downsampled_height.
00167    */
00168 
00169 #endif /* IDCT_SCALING_SUPPORTED */
00170 
00171   /* Report number of components in selected colorspace. */
00172   /* Probably this should be in the color conversion module... */
00173   switch (cinfo->out_color_space) {
00174   case JCS_GRAYSCALE:
00175     cinfo->out_color_components = 1;
00176     break;
00177   case JCS_RGB:
00178 #if RGB_PIXELSIZE != 3
00179     cinfo->out_color_components = RGB_PIXELSIZE;
00180     break;
00181 #endif /* else share code with YCbCr */
00182   case JCS_YCbCr:
00183     cinfo->out_color_components = 3;
00184     break;
00185   case JCS_CMYK:
00186   case JCS_YCCK:
00187     cinfo->out_color_components = 4;
00188     break;
00189   default:                      /* else must be same colorspace as in file */
00190     cinfo->out_color_components = cinfo->num_components;
00191     break;
00192   }
00193   cinfo->output_components = (cinfo->quantize_colors ? 1 :
00194                               cinfo->out_color_components);
00195 
00196   /* See if upsampler will want to emit more than one row at a time */
00197   if (use_merged_upsample(cinfo))
00198     cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
00199   else
00200     cinfo->rec_outbuf_height = 1;
00201 }
00202 
00203 
00204 /*
00205  * Several decompression processes need to range-limit values to the range
00206  * 0..MAXJSAMPLE; the input value may fall somewhat outside this range
00207  * due to noise introduced by quantization, roundoff error, etc.  These
00208  * processes are inner loops and need to be as fast as possible.  On most
00209  * machines, particularly CPUs with pipelines or instruction prefetch,
00210  * a (subscript-check-less) C table lookup
00211  *              x = sample_range_limit[x];
00212  * is faster than explicit tests
00213  *              if (x < 0)  x = 0;
00214  *              else if (x > MAXJSAMPLE)  x = MAXJSAMPLE;
00215  * These processes all use a common table prepared by the routine below.
00216  *
00217  * For most steps we can mathematically guarantee that the initial value
00218  * of x is within MAXJSAMPLE+1 of the legal range, so a table running from
00219  * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient.  But for the initial
00220  * limiting step (just after the IDCT), a wildly out-of-range value is 
00221  * possible if the input data is corrupt.  To avoid any chance of indexing
00222  * off the end of memory and getting a bad-pointer trap, we perform the
00223  * post-IDCT limiting thus:
00224  *              x = range_limit[x & MASK];
00225  * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
00226  * samples.  Under normal circumstances this is more than enough range and
00227  * a correct output will be generated; with bogus input data the mask will
00228  * cause wraparound, and we will safely generate a bogus-but-in-range output.
00229  * For the post-IDCT step, we want to convert the data from signed to unsigned
00230  * representation by adding CENTERJSAMPLE at the same time that we limit it.
00231  * So the post-IDCT limiting table ends up looking like this:
00232  *   CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,
00233  *   MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
00234  *   0          (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
00235  *   0,1,...,CENTERJSAMPLE-1
00236  * Negative inputs select values from the upper half of the table after
00237  * masking.
00238  *
00239  * We can save some space by overlapping the start of the post-IDCT table
00240  * with the simpler range limiting table.  The post-IDCT table begins at
00241  * sample_range_limit + CENTERJSAMPLE.
00242  *
00243  * Note that the table is allocated in near data space on PCs; it's small
00244  * enough and used often enough to justify this.
00245  */
00246 
00247 LOCAL(void)
00248 prepare_range_limit_table (j_decompress_ptr cinfo)
00249 /* Allocate and fill in the sample_range_limit table */
00250 {
00251   JSAMPLE * table;
00252   int i;
00253 
00254   table = (JSAMPLE *)
00255     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00256                 (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));
00257   table += (MAXJSAMPLE+1);      /* allow negative subscripts of simple table */
00258   cinfo->sample_range_limit = table;
00259   /* First segment of "simple" table: limit[x] = 0 for x < 0 */
00260   MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
00261   /* Main part of "simple" table: limit[x] = x */
00262   for (i = 0; i <= MAXJSAMPLE; i++)
00263     table[i] = (JSAMPLE) i;
00264   table += CENTERJSAMPLE;       /* Point to where post-IDCT table starts */
00265   /* End of simple table, rest of first half of post-IDCT table */
00266   for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
00267     table[i] = MAXJSAMPLE;
00268   /* Second half of post-IDCT table */
00269   MEMZERO(table + (2 * (MAXJSAMPLE+1)),
00270           (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
00271   MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
00272           cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));
00273 }
00274 
00275 
00276 /*
00277  * Master selection of decompression modules.
00278  * This is done once at jpeg_start_decompress time.  We determine
00279  * which modules will be used and give them appropriate initialization calls.
00280  * We also initialize the decompressor input side to begin consuming data.
00281  *
00282  * Since jpeg_read_header has finished, we know what is in the SOF
00283  * and (first) SOS markers.  We also have all the application parameter
00284  * settings.
00285  */
00286 
00287 LOCAL(void)
00288 master_selection (j_decompress_ptr cinfo)
00289 {
00290   my_master_ptr master = (my_master_ptr) cinfo->master;
00291   boolean use_c_buffer;
00292   long samplesperrow;
00293   JDIMENSION jd_samplesperrow;
00294 
00295   /* Initialize dimensions and other stuff */
00296   jpeg_calc_output_dimensions(cinfo);
00297   prepare_range_limit_table(cinfo);
00298 
00299   /* Width of an output scanline must be representable as JDIMENSION. */
00300   samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;
00301   jd_samplesperrow = (JDIMENSION) samplesperrow;
00302   if ((long) jd_samplesperrow != samplesperrow)
00303     ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
00304 
00305   /* Initialize my private state */
00306   master->pass_number = 0;
00307   master->using_merged_upsample = use_merged_upsample(cinfo);
00308 
00309   /* Color quantizer selection */
00310   master->quantizer_1pass = NULL;
00311   master->quantizer_2pass = NULL;
00312   /* No mode changes if not using buffered-image mode. */
00313   if (! cinfo->quantize_colors || ! cinfo->buffered_image) {
00314     cinfo->enable_1pass_quant = FALSE;
00315     cinfo->enable_external_quant = FALSE;
00316     cinfo->enable_2pass_quant = FALSE;
00317   }
00318   if (cinfo->quantize_colors) {
00319     if (cinfo->raw_data_out)
00320       ERREXIT(cinfo, JERR_NOTIMPL);
00321     /* 2-pass quantizer only works in 3-component color space. */
00322     if (cinfo->out_color_components != 3) {
00323       cinfo->enable_1pass_quant = TRUE;
00324       cinfo->enable_external_quant = FALSE;
00325       cinfo->enable_2pass_quant = FALSE;
00326       cinfo->colormap = NULL;
00327     } else if (cinfo->colormap != NULL) {
00328       cinfo->enable_external_quant = TRUE;
00329     } else if (cinfo->two_pass_quantize) {
00330       cinfo->enable_2pass_quant = TRUE;
00331     } else {
00332       cinfo->enable_1pass_quant = TRUE;
00333     }
00334 
00335     if (cinfo->enable_1pass_quant) {
00336 #ifdef QUANT_1PASS_SUPPORTED
00337       jinit_1pass_quantizer(cinfo);
00338       master->quantizer_1pass = cinfo->cquantize;
00339 #else
00340       ERREXIT(cinfo, JERR_NOT_COMPILED);
00341 #endif
00342     }
00343 
00344     /* We use the 2-pass code to map to external colormaps. */
00345     if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
00346 #ifdef QUANT_2PASS_SUPPORTED
00347       jinit_2pass_quantizer(cinfo);
00348       master->quantizer_2pass = cinfo->cquantize;
00349 #else
00350       ERREXIT(cinfo, JERR_NOT_COMPILED);
00351 #endif
00352     }
00353     /* If both quantizers are initialized, the 2-pass one is left active;
00354      * this is necessary for starting with quantization to an external map.
00355      */
00356   }
00357 
00358   /* Post-processing: in particular, color conversion first */
00359   if (! cinfo->raw_data_out) {
00360     if (master->using_merged_upsample) {
00361 #ifdef UPSAMPLE_MERGING_SUPPORTED
00362       jinit_merged_upsampler(cinfo); /* does color conversion too */
00363 #else
00364       ERREXIT(cinfo, JERR_NOT_COMPILED);
00365 #endif
00366     } else {
00367       jinit_color_deconverter(cinfo);
00368       jinit_upsampler(cinfo);
00369     }
00370     jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);
00371   }
00372   /* Inverse DCT */
00373   jinit_inverse_dct(cinfo);
00374   /* Entropy decoding: either Huffman or arithmetic coding. */
00375   if (cinfo->arith_code) {
00376     ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
00377   } else {
00378     if (cinfo->progressive_mode) {
00379 #ifdef D_PROGRESSIVE_SUPPORTED
00380       jinit_phuff_decoder(cinfo);
00381 #else
00382       ERREXIT(cinfo, JERR_NOT_COMPILED);
00383 #endif
00384     } else
00385       jinit_huff_decoder(cinfo);
00386   }
00387 
00388   /* Initialize principal buffer controllers. */
00389   use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
00390   jinit_d_coef_controller(cinfo, use_c_buffer);
00391 
00392   if (! cinfo->raw_data_out)
00393     jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
00394 
00395   /* We can now tell the memory manager to allocate virtual arrays. */
00396   (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
00397 
00398   /* Initialize input side of decompressor to consume first scan. */
00399   (*cinfo->inputctl->start_input_pass) (cinfo);
00400 
00401 #ifdef D_MULTISCAN_FILES_SUPPORTED
00402   /* If jpeg_start_decompress will read the whole file, initialize
00403    * progress monitoring appropriately.  The input step is counted
00404    * as one pass.
00405    */
00406   if (cinfo->progress != NULL && ! cinfo->buffered_image &&
00407       cinfo->inputctl->has_multiple_scans) {
00408     int nscans;
00409     /* Estimate number of scans to set pass_limit. */
00410     if (cinfo->progressive_mode) {
00411       /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
00412       nscans = 2 + 3 * cinfo->num_components;
00413     } else {
00414       /* For a nonprogressive multiscan file, estimate 1 scan per component. */
00415       nscans = cinfo->num_components;
00416     }
00417     cinfo->progress->pass_counter = 0L;
00418     cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
00419     cinfo->progress->completed_passes = 0;
00420     cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
00421     /* Count the input pass as done */
00422     master->pass_number++;
00423   }
00424 #endif /* D_MULTISCAN_FILES_SUPPORTED */
00425 }
00426 
00427 
00428 /*
00429  * Per-pass setup.
00430  * This is called at the beginning of each output pass.  We determine which
00431  * modules will be active during this pass and give them appropriate
00432  * start_pass calls.  We also set is_dummy_pass to indicate whether this
00433  * is a "real" output pass or a dummy pass for color quantization.
00434  * (In the latter case, jdapistd.c will crank the pass to completion.)
00435  */
00436 
00437 METHODDEF(void)
00438 prepare_for_output_pass (j_decompress_ptr cinfo)
00439 {
00440   my_master_ptr master = (my_master_ptr) cinfo->master;
00441 
00442   if (master->pub.is_dummy_pass) {
00443 #ifdef QUANT_2PASS_SUPPORTED
00444     /* Final pass of 2-pass quantization */
00445     master->pub.is_dummy_pass = FALSE;
00446     (*cinfo->cquantize->start_pass) (cinfo, FALSE);
00447     (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);
00448     (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);
00449 #else
00450     ERREXIT(cinfo, JERR_NOT_COMPILED);
00451 #endif /* QUANT_2PASS_SUPPORTED */
00452   } else {
00453     if (cinfo->quantize_colors && cinfo->colormap == NULL) {
00454       /* Select new quantization method */
00455       if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
00456         cinfo->cquantize = master->quantizer_2pass;
00457         master->pub.is_dummy_pass = TRUE;
00458       } else if (cinfo->enable_1pass_quant) {
00459         cinfo->cquantize = master->quantizer_1pass;
00460       } else {
00461         ERREXIT(cinfo, JERR_MODE_CHANGE);
00462       }
00463     }
00464     (*cinfo->idct->start_pass) (cinfo);
00465     (*cinfo->coef->start_output_pass) (cinfo);
00466     if (! cinfo->raw_data_out) {
00467       if (! master->using_merged_upsample)
00468         (*cinfo->cconvert->start_pass) (cinfo);
00469       (*cinfo->upsample->start_pass) (cinfo);
00470       if (cinfo->quantize_colors)
00471         (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
00472       (*cinfo->post->start_pass) (cinfo,
00473             (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
00474       (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
00475     }
00476   }
00477 
00478   /* Set up progress monitor's pass info if present */
00479   if (cinfo->progress != NULL) {
00480     cinfo->progress->completed_passes = master->pass_number;
00481     cinfo->progress->total_passes = master->pass_number +
00482                                     (master->pub.is_dummy_pass ? 2 : 1);
00483     /* In buffered-image mode, we assume one more output pass if EOI not
00484      * yet reached, but no more passes if EOI has been reached.
00485      */
00486     if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {
00487       cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
00488     }
00489   }
00490 }
00491 
00492 
00493 /*
00494  * Finish up at end of an output pass.
00495  */
00496 
00497 METHODDEF(void)
00498 finish_output_pass (j_decompress_ptr cinfo)
00499 {
00500   my_master_ptr master = (my_master_ptr) cinfo->master;
00501 
00502   if (cinfo->quantize_colors)
00503     (*cinfo->cquantize->finish_pass) (cinfo);
00504   master->pass_number++;
00505 }
00506 
00507 
00508 #ifdef D_MULTISCAN_FILES_SUPPORTED
00509 
00510 /*
00511  * Switch to a new external colormap between output passes.
00512  */
00513 
00514 GLOBAL(void)
00515 jpeg_new_colormap (j_decompress_ptr cinfo)
00516 {
00517   my_master_ptr master = (my_master_ptr) cinfo->master;
00518 
00519   /* Prevent application from calling me at wrong times */
00520   if (cinfo->global_state != DSTATE_BUFIMAGE)
00521     ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
00522 
00523   if (cinfo->quantize_colors && cinfo->enable_external_quant &&
00524       cinfo->colormap != NULL) {
00525     /* Select 2-pass quantizer for external colormap use */
00526     cinfo->cquantize = master->quantizer_2pass;
00527     /* Notify quantizer of colormap change */
00528     (*cinfo->cquantize->new_color_map) (cinfo);
00529     master->pub.is_dummy_pass = FALSE; /* just in case */
00530   } else
00531     ERREXIT(cinfo, JERR_MODE_CHANGE);
00532 }
00533 
00534 #endif /* D_MULTISCAN_FILES_SUPPORTED */
00535 
00536 
00537 /*
00538  * Initialize master decompression control and select active modules.
00539  * This is performed at the start of jpeg_start_decompress.
00540  */
00541 
00542 GLOBAL(void)
00543 jinit_master_decompress (j_decompress_ptr cinfo)
00544 {
00545   my_master_ptr master;
00546 
00547   master = (my_master_ptr)
00548       (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00549                                   SIZEOF(my_decomp_master));
00550   cinfo->master = (struct jpeg_decomp_master *) master;
00551   master->pub.prepare_for_output_pass = prepare_for_output_pass;
00552   master->pub.finish_output_pass = finish_output_pass;
00553 
00554   master->pub.is_dummy_pass = FALSE;
00555 
00556   master_selection(cinfo);
00557 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:55