Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: third_party/libjpeg_turbo/jdmaster.c

Issue 4134011: Adds libjpeg-turbo to deps... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/libjpeg_turbo/jdmarker.c ('k') | third_party/libjpeg_turbo/jdmerge.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * jdmaster.c
3 *
4 * Copyright (C) 1991-1997, Thomas G. Lane.
5 * Copyright (C) 2009, D. R. Commander.
6 * This file is part of the Independent JPEG Group's software.
7 * For conditions of distribution and use, see the accompanying README file.
8 *
9 * This file contains master control logic for the JPEG decompressor.
10 * These routines are concerned with selecting the modules to be executed
11 * and with determining the number of passes and the work to be done in each
12 * pass.
13 */
14
15 #define JPEG_INTERNALS
16 #include "jinclude.h"
17 #include "jpeglib.h"
18
19
20 /* Private state */
21
22 typedef struct {
23 struct jpeg_decomp_master pub; /* public fields */
24
25 int pass_number; /* # of passes completed */
26
27 boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */
28
29 /* Saved references to initialized quantizer modules,
30 * in case we need to switch modes.
31 */
32 struct jpeg_color_quantizer * quantizer_1pass;
33 struct jpeg_color_quantizer * quantizer_2pass;
34 } my_decomp_master;
35
36 typedef my_decomp_master * my_master_ptr;
37
38
39 /*
40 * Determine whether merged upsample/color conversion should be used.
41 * CRUCIAL: this must match the actual capabilities of jdmerge.c!
42 */
43
44 LOCAL(boolean)
45 use_merged_upsample (j_decompress_ptr cinfo)
46 {
47 #ifdef UPSAMPLE_MERGING_SUPPORTED
48 /* Merging is the equivalent of plain box-filter upsampling */
49 if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
50 return FALSE;
51 /* jdmerge.c only supports YCC=>RGB color conversion */
52 if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
53 (cinfo->out_color_space != JCS_RGB &&
54 cinfo->out_color_space != JCS_EXT_RGB &&
55 cinfo->out_color_space != JCS_EXT_RGBX &&
56 cinfo->out_color_space != JCS_EXT_BGR &&
57 cinfo->out_color_space != JCS_EXT_BGRX &&
58 cinfo->out_color_space != JCS_EXT_XBGR &&
59 cinfo->out_color_space != JCS_EXT_XRGB) ||
60 cinfo->out_color_components != rgb_pixelsize[cinfo->out_color_space])
61 return FALSE;
62 /* and it only handles 2h1v or 2h2v sampling ratios */
63 if (cinfo->comp_info[0].h_samp_factor != 2 ||
64 cinfo->comp_info[1].h_samp_factor != 1 ||
65 cinfo->comp_info[2].h_samp_factor != 1 ||
66 cinfo->comp_info[0].v_samp_factor > 2 ||
67 cinfo->comp_info[1].v_samp_factor != 1 ||
68 cinfo->comp_info[2].v_samp_factor != 1)
69 return FALSE;
70 /* furthermore, it doesn't work if we've scaled the IDCTs differently */
71 if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
72 cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
73 cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size)
74 return FALSE;
75 /* ??? also need to test for upsample-time rescaling, when & if supported */
76 return TRUE; /* by golly, it'll work... */
77 #else
78 return FALSE;
79 #endif
80 }
81
82
83 /*
84 * Compute output image dimensions and related values.
85 * NOTE: this is exported for possible use by application.
86 * Hence it mustn't do anything that can't be done twice.
87 * Also note that it may be called before the master module is initialized!
88 */
89
90 GLOBAL(void)
91 jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
92 /* Do computations that are needed before master selection phase */
93 {
94 #ifdef IDCT_SCALING_SUPPORTED
95 int ci;
96 jpeg_component_info *compptr;
97 #endif
98
99 /* Prevent application from calling me at wrong times */
100 if (cinfo->global_state != DSTATE_READY)
101 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
102
103 #ifdef IDCT_SCALING_SUPPORTED
104
105 /* Compute actual output image dimensions and DCT scaling choices. */
106 if (cinfo->scale_num * 8 <= cinfo->scale_denom) {
107 /* Provide 1/8 scaling */
108 cinfo->output_width = (JDIMENSION)
109 jdiv_round_up((long) cinfo->image_width, 8L);
110 cinfo->output_height = (JDIMENSION)
111 jdiv_round_up((long) cinfo->image_height, 8L);
112 cinfo->min_DCT_scaled_size = 1;
113 } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {
114 /* Provide 1/4 scaling */
115 cinfo->output_width = (JDIMENSION)
116 jdiv_round_up((long) cinfo->image_width, 4L);
117 cinfo->output_height = (JDIMENSION)
118 jdiv_round_up((long) cinfo->image_height, 4L);
119 cinfo->min_DCT_scaled_size = 2;
120 } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {
121 /* Provide 1/2 scaling */
122 cinfo->output_width = (JDIMENSION)
123 jdiv_round_up((long) cinfo->image_width, 2L);
124 cinfo->output_height = (JDIMENSION)
125 jdiv_round_up((long) cinfo->image_height, 2L);
126 cinfo->min_DCT_scaled_size = 4;
127 } else {
128 /* Provide 1/1 scaling */
129 cinfo->output_width = cinfo->image_width;
130 cinfo->output_height = cinfo->image_height;
131 cinfo->min_DCT_scaled_size = DCTSIZE;
132 }
133 /* In selecting the actual DCT scaling for each component, we try to
134 * scale up the chroma components via IDCT scaling rather than upsampling.
135 * This saves time if the upsampler gets to use 1:1 scaling.
136 * Note this code assumes that the supported DCT scalings are powers of 2.
137 */
138 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
139 ci++, compptr++) {
140 int ssize = cinfo->min_DCT_scaled_size;
141 while (ssize < DCTSIZE &&
142 (compptr->h_samp_factor * ssize * 2 <=
143 cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) &&
144 (compptr->v_samp_factor * ssize * 2 <=
145 cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) {
146 ssize = ssize * 2;
147 }
148 compptr->DCT_scaled_size = ssize;
149 }
150
151 /* Recompute downsampled dimensions of components;
152 * application needs to know these if using raw downsampled data.
153 */
154 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
155 ci++, compptr++) {
156 /* Size in samples, after IDCT scaling */
157 compptr->downsampled_width = (JDIMENSION)
158 jdiv_round_up((long) cinfo->image_width *
159 (long) (compptr->h_samp_factor * compptr->DCT_scaled_size),
160 (long) (cinfo->max_h_samp_factor * DCTSIZE));
161 compptr->downsampled_height = (JDIMENSION)
162 jdiv_round_up((long) cinfo->image_height *
163 (long) (compptr->v_samp_factor * compptr->DCT_scaled_size),
164 (long) (cinfo->max_v_samp_factor * DCTSIZE));
165 }
166
167 #else /* !IDCT_SCALING_SUPPORTED */
168
169 /* Hardwire it to "no scaling" */
170 cinfo->output_width = cinfo->image_width;
171 cinfo->output_height = cinfo->image_height;
172 /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
173 * and has computed unscaled downsampled_width and downsampled_height.
174 */
175
176 #endif /* IDCT_SCALING_SUPPORTED */
177
178 /* Report number of components in selected colorspace. */
179 /* Probably this should be in the color conversion module... */
180 switch (cinfo->out_color_space) {
181 case JCS_GRAYSCALE:
182 cinfo->out_color_components = 1;
183 break;
184 case JCS_RGB:
185 case JCS_EXT_RGB:
186 case JCS_EXT_RGBX:
187 case JCS_EXT_BGR:
188 case JCS_EXT_BGRX:
189 case JCS_EXT_XBGR:
190 case JCS_EXT_XRGB:
191 cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
192 break;
193 case JCS_YCbCr:
194 cinfo->out_color_components = 3;
195 break;
196 case JCS_CMYK:
197 case JCS_YCCK:
198 cinfo->out_color_components = 4;
199 break;
200 default: /* else must be same colorspace as in file */
201 cinfo->out_color_components = cinfo->num_components;
202 break;
203 }
204 cinfo->output_components = (cinfo->quantize_colors ? 1 :
205 cinfo->out_color_components);
206
207 /* See if upsampler will want to emit more than one row at a time */
208 if (use_merged_upsample(cinfo))
209 cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
210 else
211 cinfo->rec_outbuf_height = 1;
212 }
213
214
215 /*
216 * Several decompression processes need to range-limit values to the range
217 * 0..MAXJSAMPLE; the input value may fall somewhat outside this range
218 * due to noise introduced by quantization, roundoff error, etc. These
219 * processes are inner loops and need to be as fast as possible. On most
220 * machines, particularly CPUs with pipelines or instruction prefetch,
221 * a (subscript-check-less) C table lookup
222 * x = sample_range_limit[x];
223 * is faster than explicit tests
224 * if (x < 0) x = 0;
225 * else if (x > MAXJSAMPLE) x = MAXJSAMPLE;
226 * These processes all use a common table prepared by the routine below.
227 *
228 * For most steps we can mathematically guarantee that the initial value
229 * of x is within MAXJSAMPLE+1 of the legal range, so a table running from
230 * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial
231 * limiting step (just after the IDCT), a wildly out-of-range value is
232 * possible if the input data is corrupt. To avoid any chance of indexing
233 * off the end of memory and getting a bad-pointer trap, we perform the
234 * post-IDCT limiting thus:
235 * x = range_limit[x & MASK];
236 * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
237 * samples. Under normal circumstances this is more than enough range and
238 * a correct output will be generated; with bogus input data the mask will
239 * cause wraparound, and we will safely generate a bogus-but-in-range output.
240 * For the post-IDCT step, we want to convert the data from signed to unsigned
241 * representation by adding CENTERJSAMPLE at the same time that we limit it.
242 * So the post-IDCT limiting table ends up looking like this:
243 * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,
244 * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
245 * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
246 * 0,1,...,CENTERJSAMPLE-1
247 * Negative inputs select values from the upper half of the table after
248 * masking.
249 *
250 * We can save some space by overlapping the start of the post-IDCT table
251 * with the simpler range limiting table. The post-IDCT table begins at
252 * sample_range_limit + CENTERJSAMPLE.
253 *
254 * Note that the table is allocated in near data space on PCs; it's small
255 * enough and used often enough to justify this.
256 */
257
258 LOCAL(void)
259 prepare_range_limit_table (j_decompress_ptr cinfo)
260 /* Allocate and fill in the sample_range_limit table */
261 {
262 JSAMPLE * table;
263 int i;
264
265 table = (JSAMPLE *)
266 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
267 (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));
268 table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
269 cinfo->sample_range_limit = table;
270 /* First segment of "simple" table: limit[x] = 0 for x < 0 */
271 MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
272 /* Main part of "simple" table: limit[x] = x */
273 for (i = 0; i <= MAXJSAMPLE; i++)
274 table[i] = (JSAMPLE) i;
275 table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
276 /* End of simple table, rest of first half of post-IDCT table */
277 for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
278 table[i] = MAXJSAMPLE;
279 /* Second half of post-IDCT table */
280 MEMZERO(table + (2 * (MAXJSAMPLE+1)),
281 (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
282 MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
283 cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));
284 }
285
286
287 /*
288 * Master selection of decompression modules.
289 * This is done once at jpeg_start_decompress time. We determine
290 * which modules will be used and give them appropriate initialization calls.
291 * We also initialize the decompressor input side to begin consuming data.
292 *
293 * Since jpeg_read_header has finished, we know what is in the SOF
294 * and (first) SOS markers. We also have all the application parameter
295 * settings.
296 */
297
298 LOCAL(void)
299 master_selection (j_decompress_ptr cinfo)
300 {
301 my_master_ptr master = (my_master_ptr) cinfo->master;
302 boolean use_c_buffer;
303 long samplesperrow;
304 JDIMENSION jd_samplesperrow;
305
306 /* Initialize dimensions and other stuff */
307 jpeg_calc_output_dimensions(cinfo);
308 prepare_range_limit_table(cinfo);
309
310 /* Width of an output scanline must be representable as JDIMENSION. */
311 samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_component s;
312 jd_samplesperrow = (JDIMENSION) samplesperrow;
313 if ((long) jd_samplesperrow != samplesperrow)
314 ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
315
316 /* Initialize my private state */
317 master->pass_number = 0;
318 master->using_merged_upsample = use_merged_upsample(cinfo);
319
320 /* Color quantizer selection */
321 master->quantizer_1pass = NULL;
322 master->quantizer_2pass = NULL;
323 /* No mode changes if not using buffered-image mode. */
324 if (! cinfo->quantize_colors || ! cinfo->buffered_image) {
325 cinfo->enable_1pass_quant = FALSE;
326 cinfo->enable_external_quant = FALSE;
327 cinfo->enable_2pass_quant = FALSE;
328 }
329 if (cinfo->quantize_colors) {
330 if (cinfo->raw_data_out)
331 ERREXIT(cinfo, JERR_NOTIMPL);
332 /* 2-pass quantizer only works in 3-component color space. */
333 if (cinfo->out_color_components != 3) {
334 cinfo->enable_1pass_quant = TRUE;
335 cinfo->enable_external_quant = FALSE;
336 cinfo->enable_2pass_quant = FALSE;
337 cinfo->colormap = NULL;
338 } else if (cinfo->colormap != NULL) {
339 cinfo->enable_external_quant = TRUE;
340 } else if (cinfo->two_pass_quantize) {
341 cinfo->enable_2pass_quant = TRUE;
342 } else {
343 cinfo->enable_1pass_quant = TRUE;
344 }
345
346 if (cinfo->enable_1pass_quant) {
347 #ifdef QUANT_1PASS_SUPPORTED
348 jinit_1pass_quantizer(cinfo);
349 master->quantizer_1pass = cinfo->cquantize;
350 #else
351 ERREXIT(cinfo, JERR_NOT_COMPILED);
352 #endif
353 }
354
355 /* We use the 2-pass code to map to external colormaps. */
356 if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
357 #ifdef QUANT_2PASS_SUPPORTED
358 jinit_2pass_quantizer(cinfo);
359 master->quantizer_2pass = cinfo->cquantize;
360 #else
361 ERREXIT(cinfo, JERR_NOT_COMPILED);
362 #endif
363 }
364 /* If both quantizers are initialized, the 2-pass one is left active;
365 * this is necessary for starting with quantization to an external map.
366 */
367 }
368
369 /* Post-processing: in particular, color conversion first */
370 if (! cinfo->raw_data_out) {
371 if (master->using_merged_upsample) {
372 #ifdef UPSAMPLE_MERGING_SUPPORTED
373 jinit_merged_upsampler(cinfo); /* does color conversion too */
374 #else
375 ERREXIT(cinfo, JERR_NOT_COMPILED);
376 #endif
377 } else {
378 jinit_color_deconverter(cinfo);
379 jinit_upsampler(cinfo);
380 }
381 jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);
382 }
383 /* Inverse DCT */
384 jinit_inverse_dct(cinfo);
385 /* Entropy decoding: either Huffman or arithmetic coding. */
386 if (cinfo->arith_code) {
387 ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
388 } else {
389 if (cinfo->progressive_mode) {
390 #ifdef D_PROGRESSIVE_SUPPORTED
391 jinit_phuff_decoder(cinfo);
392 #else
393 ERREXIT(cinfo, JERR_NOT_COMPILED);
394 #endif
395 } else
396 jinit_huff_decoder(cinfo);
397 }
398
399 /* Initialize principal buffer controllers. */
400 use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
401 jinit_d_coef_controller(cinfo, use_c_buffer);
402
403 if (! cinfo->raw_data_out)
404 jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
405
406 /* We can now tell the memory manager to allocate virtual arrays. */
407 (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
408
409 /* Initialize input side of decompressor to consume first scan. */
410 (*cinfo->inputctl->start_input_pass) (cinfo);
411
412 #ifdef D_MULTISCAN_FILES_SUPPORTED
413 /* If jpeg_start_decompress will read the whole file, initialize
414 * progress monitoring appropriately. The input step is counted
415 * as one pass.
416 */
417 if (cinfo->progress != NULL && ! cinfo->buffered_image &&
418 cinfo->inputctl->has_multiple_scans) {
419 int nscans;
420 /* Estimate number of scans to set pass_limit. */
421 if (cinfo->progressive_mode) {
422 /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
423 nscans = 2 + 3 * cinfo->num_components;
424 } else {
425 /* For a nonprogressive multiscan file, estimate 1 scan per component. */
426 nscans = cinfo->num_components;
427 }
428 cinfo->progress->pass_counter = 0L;
429 cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
430 cinfo->progress->completed_passes = 0;
431 cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
432 /* Count the input pass as done */
433 master->pass_number++;
434 }
435 #endif /* D_MULTISCAN_FILES_SUPPORTED */
436 }
437
438
439 /*
440 * Per-pass setup.
441 * This is called at the beginning of each output pass. We determine which
442 * modules will be active during this pass and give them appropriate
443 * start_pass calls. We also set is_dummy_pass to indicate whether this
444 * is a "real" output pass or a dummy pass for color quantization.
445 * (In the latter case, jdapistd.c will crank the pass to completion.)
446 */
447
448 METHODDEF(void)
449 prepare_for_output_pass (j_decompress_ptr cinfo)
450 {
451 my_master_ptr master = (my_master_ptr) cinfo->master;
452
453 if (master->pub.is_dummy_pass) {
454 #ifdef QUANT_2PASS_SUPPORTED
455 /* Final pass of 2-pass quantization */
456 master->pub.is_dummy_pass = FALSE;
457 (*cinfo->cquantize->start_pass) (cinfo, FALSE);
458 (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);
459 (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);
460 #else
461 ERREXIT(cinfo, JERR_NOT_COMPILED);
462 #endif /* QUANT_2PASS_SUPPORTED */
463 } else {
464 if (cinfo->quantize_colors && cinfo->colormap == NULL) {
465 /* Select new quantization method */
466 if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
467 cinfo->cquantize = master->quantizer_2pass;
468 master->pub.is_dummy_pass = TRUE;
469 } else if (cinfo->enable_1pass_quant) {
470 cinfo->cquantize = master->quantizer_1pass;
471 } else {
472 ERREXIT(cinfo, JERR_MODE_CHANGE);
473 }
474 }
475 (*cinfo->idct->start_pass) (cinfo);
476 (*cinfo->coef->start_output_pass) (cinfo);
477 if (! cinfo->raw_data_out) {
478 if (! master->using_merged_upsample)
479 (*cinfo->cconvert->start_pass) (cinfo);
480 (*cinfo->upsample->start_pass) (cinfo);
481 if (cinfo->quantize_colors)
482 (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
483 (*cinfo->post->start_pass) (cinfo,
484 (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
485 (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
486 }
487 }
488
489 /* Set up progress monitor's pass info if present */
490 if (cinfo->progress != NULL) {
491 cinfo->progress->completed_passes = master->pass_number;
492 cinfo->progress->total_passes = master->pass_number +
493 (master->pub.is_dummy_pass ? 2 : 1);
494 /* In buffered-image mode, we assume one more output pass if EOI not
495 * yet reached, but no more passes if EOI has been reached.
496 */
497 if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {
498 cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
499 }
500 }
501 }
502
503
504 /*
505 * Finish up at end of an output pass.
506 */
507
508 METHODDEF(void)
509 finish_output_pass (j_decompress_ptr cinfo)
510 {
511 my_master_ptr master = (my_master_ptr) cinfo->master;
512
513 if (cinfo->quantize_colors)
514 (*cinfo->cquantize->finish_pass) (cinfo);
515 master->pass_number++;
516 }
517
518
519 #ifdef D_MULTISCAN_FILES_SUPPORTED
520
521 /*
522 * Switch to a new external colormap between output passes.
523 */
524
525 GLOBAL(void)
526 jpeg_new_colormap (j_decompress_ptr cinfo)
527 {
528 my_master_ptr master = (my_master_ptr) cinfo->master;
529
530 /* Prevent application from calling me at wrong times */
531 if (cinfo->global_state != DSTATE_BUFIMAGE)
532 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
533
534 if (cinfo->quantize_colors && cinfo->enable_external_quant &&
535 cinfo->colormap != NULL) {
536 /* Select 2-pass quantizer for external colormap use */
537 cinfo->cquantize = master->quantizer_2pass;
538 /* Notify quantizer of colormap change */
539 (*cinfo->cquantize->new_color_map) (cinfo);
540 master->pub.is_dummy_pass = FALSE; /* just in case */
541 } else
542 ERREXIT(cinfo, JERR_MODE_CHANGE);
543 }
544
545 #endif /* D_MULTISCAN_FILES_SUPPORTED */
546
547
548 /*
549 * Initialize master decompression control and select active modules.
550 * This is performed at the start of jpeg_start_decompress.
551 */
552
553 GLOBAL(void)
554 jinit_master_decompress (j_decompress_ptr cinfo)
555 {
556 my_master_ptr master;
557
558 master = (my_master_ptr)
559 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
560 SIZEOF(my_decomp_master));
561 cinfo->master = (struct jpeg_decomp_master *) master;
562 master->pub.prepare_for_output_pass = prepare_for_output_pass;
563 master->pub.finish_output_pass = finish_output_pass;
564
565 master->pub.is_dummy_pass = FALSE;
566
567 master_selection(cinfo);
568 }
OLDNEW
« no previous file with comments | « third_party/libjpeg_turbo/jdmarker.c ('k') | third_party/libjpeg_turbo/jdmerge.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698