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

Side by Side Diff: jdmaster.c

Issue 1939823002: Update to libjpeg_turbo 1.4.90 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@master
Patch Set: Response to comments Created 4 years, 7 months 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
« jdhuff.c ('K') | « jdmaster.h ('k') | 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
1 /* 1 /*
2 * jdmaster.c 2 * jdmaster.c
3 * 3 *
4 * This file was part of the Independent JPEG Group's software: 4 * This file was part of the Independent JPEG Group's software:
5 * Copyright (C) 1991-1997, Thomas G. Lane. 5 * Copyright (C) 1991-1997, Thomas G. Lane.
6 * Modified 2002-2009 by Guido Vollbeding. 6 * Modified 2002-2009 by Guido Vollbeding.
7 * libjpeg-turbo Modifications: 7 * libjpeg-turbo Modifications:
8 * Copyright (C) 2009-2011, D. R. Commander. 8 * Copyright (C) 2009-2011, 2016, D. R. Commander.
9 * Copyright (C) 2013, Linaro Limited. 9 * Copyright (C) 2013, Linaro Limited.
10 10 * Copyright (C) 2015, Google, Inc.
11 * For conditions of distribution and use, see the accompanying README file. 11 * For conditions of distribution and use, see the accompanying README.ijg
12 * file.
12 * 13 *
13 * This file contains master control logic for the JPEG decompressor. 14 * This file contains master control logic for the JPEG decompressor.
14 * These routines are concerned with selecting the modules to be executed 15 * These routines are concerned with selecting the modules to be executed
15 * and with determining the number of passes and the work to be done in each 16 * and with determining the number of passes and the work to be done in each
16 * pass. 17 * pass.
17 */ 18 */
18 19
19 #define JPEG_INTERNALS 20 #define JPEG_INTERNALS
20 #include "jinclude.h" 21 #include "jinclude.h"
21 #include "jpeglib.h" 22 #include "jpeglib.h"
22 #include "jpegcomp.h" 23 #include "jpegcomp.h"
23 24 #include "jdmaster.h"
24
25 /* Private state */
26
27 typedef struct {
28 struct jpeg_decomp_master pub; /* public fields */
29
30 int pass_number;» » /* # of passes completed */
31
32 boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */
33
34 /* Saved references to initialized quantizer modules,
35 * in case we need to switch modes.
36 */
37 struct jpeg_color_quantizer * quantizer_1pass;
38 struct jpeg_color_quantizer * quantizer_2pass;
39 } my_decomp_master;
40
41 typedef my_decomp_master * my_master_ptr;
42 25
43 26
44 /* 27 /*
45 * Determine whether merged upsample/color conversion should be used. 28 * Determine whether merged upsample/color conversion should be used.
46 * CRUCIAL: this must match the actual capabilities of jdmerge.c! 29 * CRUCIAL: this must match the actual capabilities of jdmerge.c!
47 */ 30 */
48 31
49 LOCAL(boolean) 32 LOCAL(boolean)
50 use_merged_upsample (j_decompress_ptr cinfo) 33 use_merged_upsample (j_decompress_ptr cinfo)
51 { 34 {
(...skipping 28 matching lines...) Expand all
80 cinfo->comp_info[0].v_samp_factor > 2 || 63 cinfo->comp_info[0].v_samp_factor > 2 ||
81 cinfo->comp_info[1].v_samp_factor != 1 || 64 cinfo->comp_info[1].v_samp_factor != 1 ||
82 cinfo->comp_info[2].v_samp_factor != 1) 65 cinfo->comp_info[2].v_samp_factor != 1)
83 return FALSE; 66 return FALSE;
84 /* furthermore, it doesn't work if we've scaled the IDCTs differently */ 67 /* furthermore, it doesn't work if we've scaled the IDCTs differently */
85 if (cinfo->comp_info[0]._DCT_scaled_size != cinfo->_min_DCT_scaled_size || 68 if (cinfo->comp_info[0]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
86 cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size || 69 cinfo->comp_info[1]._DCT_scaled_size != cinfo->_min_DCT_scaled_size ||
87 cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size) 70 cinfo->comp_info[2]._DCT_scaled_size != cinfo->_min_DCT_scaled_size)
88 return FALSE; 71 return FALSE;
89 /* ??? also need to test for upsample-time rescaling, when & if supported */ 72 /* ??? also need to test for upsample-time rescaling, when & if supported */
90 return TRUE;» » » /* by golly, it'll work... */ 73 return TRUE; /* by golly, it'll work... */
91 #else 74 #else
92 return FALSE; 75 return FALSE;
93 #endif 76 #endif
94 } 77 }
95 78
96 79
97 /* 80 /*
98 * Compute output image dimensions and related values. 81 * Compute output image dimensions and related values.
99 * NOTE: this is exported for possible use by application. 82 * NOTE: this is exported for possible use by application.
100 * Hence it mustn't do anything that can't be done twice. 83 * Hence it mustn't do anything that can't be done twice.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 275
293 /* In selecting the actual DCT scaling for each component, we try to 276 /* In selecting the actual DCT scaling for each component, we try to
294 * scale up the chroma components via IDCT scaling rather than upsampling. 277 * scale up the chroma components via IDCT scaling rather than upsampling.
295 * This saves time if the upsampler gets to use 1:1 scaling. 278 * This saves time if the upsampler gets to use 1:1 scaling.
296 * Note this code adapts subsampling ratios which are powers of 2. 279 * Note this code adapts subsampling ratios which are powers of 2.
297 */ 280 */
298 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 281 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
299 ci++, compptr++) { 282 ci++, compptr++) {
300 int ssize = cinfo->_min_DCT_scaled_size; 283 int ssize = cinfo->_min_DCT_scaled_size;
301 while (ssize < DCTSIZE && 284 while (ssize < DCTSIZE &&
302 » ((cinfo->max_h_samp_factor * cinfo->_min_DCT_scaled_size) % 285 ((cinfo->max_h_samp_factor * cinfo->_min_DCT_scaled_size) %
303 » (compptr->h_samp_factor * ssize * 2) == 0) && 286 (compptr->h_samp_factor * ssize * 2) == 0) &&
304 » ((cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size) % 287 ((cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size) %
305 » (compptr->v_samp_factor * ssize * 2) == 0)) { 288 (compptr->v_samp_factor * ssize * 2) == 0)) {
306 ssize = ssize * 2; 289 ssize = ssize * 2;
307 } 290 }
308 #if JPEG_LIB_VERSION >= 70 291 #if JPEG_LIB_VERSION >= 70
309 compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = ssize; 292 compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = ssize;
310 #else 293 #else
311 compptr->DCT_scaled_size = ssize; 294 compptr->DCT_scaled_size = ssize;
312 #endif 295 #endif
313 } 296 }
314 297
315 /* Recompute downsampled dimensions of components; 298 /* Recompute downsampled dimensions of components;
316 * application needs to know these if using raw downsampled data. 299 * application needs to know these if using raw downsampled data.
317 */ 300 */
318 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 301 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
319 ci++, compptr++) { 302 ci++, compptr++) {
320 /* Size in samples, after IDCT scaling */ 303 /* Size in samples, after IDCT scaling */
321 compptr->downsampled_width = (JDIMENSION) 304 compptr->downsampled_width = (JDIMENSION)
322 jdiv_round_up((long) cinfo->image_width * 305 jdiv_round_up((long) cinfo->image_width *
323 » » (long) (compptr->h_samp_factor * compptr->_DCT_scaled_size), 306 (long) (compptr->h_samp_factor * compptr->_DCT_scaled_size),
324 » » (long) (cinfo->max_h_samp_factor * DCTSIZE)); 307 (long) (cinfo->max_h_samp_factor * DCTSIZE));
325 compptr->downsampled_height = (JDIMENSION) 308 compptr->downsampled_height = (JDIMENSION)
326 jdiv_round_up((long) cinfo->image_height * 309 jdiv_round_up((long) cinfo->image_height *
327 » » (long) (compptr->v_samp_factor * compptr->_DCT_scaled_size), 310 (long) (compptr->v_samp_factor * compptr->_DCT_scaled_size),
328 » » (long) (cinfo->max_v_samp_factor * DCTSIZE)); 311 (long) (cinfo->max_v_samp_factor * DCTSIZE));
329 } 312 }
330 313
331 #else /* !IDCT_SCALING_SUPPORTED */ 314 #else /* !IDCT_SCALING_SUPPORTED */
332 315
333 /* Hardwire it to "no scaling" */ 316 /* Hardwire it to "no scaling" */
334 cinfo->output_width = cinfo->image_width; 317 cinfo->output_width = cinfo->image_width;
335 cinfo->output_height = cinfo->image_height; 318 cinfo->output_height = cinfo->image_height;
336 /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE, 319 /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
337 * and has computed unscaled downsampled_width and downsampled_height. 320 * and has computed unscaled downsampled_width and downsampled_height.
338 */ 321 */
(...skipping 20 matching lines...) Expand all
359 cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space]; 342 cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
360 break; 343 break;
361 case JCS_YCbCr: 344 case JCS_YCbCr:
362 case JCS_RGB565: 345 case JCS_RGB565:
363 cinfo->out_color_components = 3; 346 cinfo->out_color_components = 3;
364 break; 347 break;
365 case JCS_CMYK: 348 case JCS_CMYK:
366 case JCS_YCCK: 349 case JCS_YCCK:
367 cinfo->out_color_components = 4; 350 cinfo->out_color_components = 4;
368 break; 351 break;
369 default:» » » /* else must be same colorspace as in file */ 352 default: /* else must be same colorspace as in file */
370 cinfo->out_color_components = cinfo->num_components; 353 cinfo->out_color_components = cinfo->num_components;
371 break; 354 break;
372 } 355 }
373 cinfo->output_components = (cinfo->quantize_colors ? 1 : 356 cinfo->output_components = (cinfo->quantize_colors ? 1 :
374 » » » cinfo->out_color_components); 357 cinfo->out_color_components);
375 358
376 /* See if upsampler will want to emit more than one row at a time */ 359 /* See if upsampler will want to emit more than one row at a time */
377 if (use_merged_upsample(cinfo)) 360 if (use_merged_upsample(cinfo))
378 cinfo->rec_outbuf_height = cinfo->max_v_samp_factor; 361 cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
379 else 362 else
380 cinfo->rec_outbuf_height = 1; 363 cinfo->rec_outbuf_height = 1;
381 } 364 }
382 365
383 366
384 /* 367 /*
385 * Several decompression processes need to range-limit values to the range 368 * Several decompression processes need to range-limit values to the range
386 * 0..MAXJSAMPLE; the input value may fall somewhat outside this range 369 * 0..MAXJSAMPLE; the input value may fall somewhat outside this range
387 * due to noise introduced by quantization, roundoff error, etc. These 370 * due to noise introduced by quantization, roundoff error, etc. These
388 * processes are inner loops and need to be as fast as possible. On most 371 * processes are inner loops and need to be as fast as possible. On most
389 * machines, particularly CPUs with pipelines or instruction prefetch, 372 * machines, particularly CPUs with pipelines or instruction prefetch,
390 * a (subscript-check-less) C table lookup 373 * a (subscript-check-less) C table lookup
391 *» » x = sample_range_limit[x]; 374 * x = sample_range_limit[x];
392 * is faster than explicit tests 375 * is faster than explicit tests
393 *» » if (x < 0) x = 0; 376 * if (x < 0) x = 0;
394 *» » else if (x > MAXJSAMPLE) x = MAXJSAMPLE; 377 * else if (x > MAXJSAMPLE) x = MAXJSAMPLE;
395 * These processes all use a common table prepared by the routine below. 378 * These processes all use a common table prepared by the routine below.
396 * 379 *
397 * For most steps we can mathematically guarantee that the initial value 380 * For most steps we can mathematically guarantee that the initial value
398 * of x is within MAXJSAMPLE+1 of the legal range, so a table running from 381 * of x is within MAXJSAMPLE+1 of the legal range, so a table running from
399 * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial 382 * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial
400 * limiting step (just after the IDCT), a wildly out-of-range value is 383 * limiting step (just after the IDCT), a wildly out-of-range value is
401 * possible if the input data is corrupt. To avoid any chance of indexing 384 * possible if the input data is corrupt. To avoid any chance of indexing
402 * off the end of memory and getting a bad-pointer trap, we perform the 385 * off the end of memory and getting a bad-pointer trap, we perform the
403 * post-IDCT limiting thus: 386 * post-IDCT limiting thus:
404 *» » x = range_limit[x & MASK]; 387 * x = range_limit[x & MASK];
405 * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit 388 * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
406 * samples. Under normal circumstances this is more than enough range and 389 * samples. Under normal circumstances this is more than enough range and
407 * a correct output will be generated; with bogus input data the mask will 390 * a correct output will be generated; with bogus input data the mask will
408 * cause wraparound, and we will safely generate a bogus-but-in-range output. 391 * cause wraparound, and we will safely generate a bogus-but-in-range output.
409 * For the post-IDCT step, we want to convert the data from signed to unsigned 392 * For the post-IDCT step, we want to convert the data from signed to unsigned
410 * representation by adding CENTERJSAMPLE at the same time that we limit it. 393 * representation by adding CENTERJSAMPLE at the same time that we limit it.
411 * So the post-IDCT limiting table ends up looking like this: 394 * So the post-IDCT limiting table ends up looking like this:
412 * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE, 395 * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,
413 * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), 396 * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
414 * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), 397 * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
415 * 0,1,...,CENTERJSAMPLE-1 398 * 0,1,...,CENTERJSAMPLE-1
416 * Negative inputs select values from the upper half of the table after 399 * Negative inputs select values from the upper half of the table after
417 * masking. 400 * masking.
418 * 401 *
419 * We can save some space by overlapping the start of the post-IDCT table 402 * We can save some space by overlapping the start of the post-IDCT table
420 * with the simpler range limiting table. The post-IDCT table begins at 403 * with the simpler range limiting table. The post-IDCT table begins at
421 * sample_range_limit + CENTERJSAMPLE. 404 * sample_range_limit + CENTERJSAMPLE.
422 *
423 * Note that the table is allocated in near data space on PCs; it's small
424 * enough and used often enough to justify this.
425 */ 405 */
426 406
427 LOCAL(void) 407 LOCAL(void)
428 prepare_range_limit_table (j_decompress_ptr cinfo) 408 prepare_range_limit_table (j_decompress_ptr cinfo)
429 /* Allocate and fill in the sample_range_limit table */ 409 /* Allocate and fill in the sample_range_limit table */
430 { 410 {
431 JSAMPLE * table; 411 JSAMPLE *table;
432 int i; 412 int i;
433 413
434 table = (JSAMPLE *) 414 table = (JSAMPLE *)
435 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 415 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
436 » » (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); 416 (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
437 table += (MAXJSAMPLE+1);» /* allow negative subscripts of simple table */ 417 table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
438 cinfo->sample_range_limit = table; 418 cinfo->sample_range_limit = table;
439 /* First segment of "simple" table: limit[x] = 0 for x < 0 */ 419 /* First segment of "simple" table: limit[x] = 0 for x < 0 */
440 MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE)); 420 MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * sizeof(JSAMPLE));
441 /* Main part of "simple" table: limit[x] = x */ 421 /* Main part of "simple" table: limit[x] = x */
442 for (i = 0; i <= MAXJSAMPLE; i++) 422 for (i = 0; i <= MAXJSAMPLE; i++)
443 table[i] = (JSAMPLE) i; 423 table[i] = (JSAMPLE) i;
444 table += CENTERJSAMPLE;» /* Point to where post-IDCT table starts */ 424 table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
445 /* End of simple table, rest of first half of post-IDCT table */ 425 /* End of simple table, rest of first half of post-IDCT table */
446 for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++) 426 for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
447 table[i] = MAXJSAMPLE; 427 table[i] = MAXJSAMPLE;
448 /* Second half of post-IDCT table */ 428 /* Second half of post-IDCT table */
449 MEMZERO(table + (2 * (MAXJSAMPLE+1)), 429 MEMZERO(table + (2 * (MAXJSAMPLE+1)),
450 » (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE)); 430 (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
451 MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), 431 MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
452 » cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE)); 432 cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
453 } 433 }
454 434
455 435
456 /* 436 /*
457 * Master selection of decompression modules. 437 * Master selection of decompression modules.
458 * This is done once at jpeg_start_decompress time. We determine 438 * This is done once at jpeg_start_decompress time. We determine
459 * which modules will be used and give them appropriate initialization calls. 439 * which modules will be used and give them appropriate initialization calls.
460 * We also initialize the decompressor input side to begin consuming data. 440 * We also initialize the decompressor input side to begin consuming data.
461 * 441 *
462 * Since jpeg_read_header has finished, we know what is in the SOF 442 * Since jpeg_read_header has finished, we know what is in the SOF
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 555
576 if (! cinfo->raw_data_out) 556 if (! cinfo->raw_data_out)
577 jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */); 557 jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
578 558
579 /* We can now tell the memory manager to allocate virtual arrays. */ 559 /* We can now tell the memory manager to allocate virtual arrays. */
580 (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); 560 (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
581 561
582 /* Initialize input side of decompressor to consume first scan. */ 562 /* Initialize input side of decompressor to consume first scan. */
583 (*cinfo->inputctl->start_input_pass) (cinfo); 563 (*cinfo->inputctl->start_input_pass) (cinfo);
584 564
565 /* Set the first and last iMCU columns to decompress from single-scan images.
566 * By default, decompress all of the iMCU columns.
567 */
568 cinfo->master->first_iMCU_col = 0;
569 cinfo->master->last_iMCU_col = cinfo->MCUs_per_row - 1;
570
585 #ifdef D_MULTISCAN_FILES_SUPPORTED 571 #ifdef D_MULTISCAN_FILES_SUPPORTED
586 /* If jpeg_start_decompress will read the whole file, initialize 572 /* If jpeg_start_decompress will read the whole file, initialize
587 * progress monitoring appropriately. The input step is counted 573 * progress monitoring appropriately. The input step is counted
588 * as one pass. 574 * as one pass.
589 */ 575 */
590 if (cinfo->progress != NULL && ! cinfo->buffered_image && 576 if (cinfo->progress != NULL && ! cinfo->buffered_image &&
591 cinfo->inputctl->has_multiple_scans) { 577 cinfo->inputctl->has_multiple_scans) {
592 int nscans; 578 int nscans;
593 /* Estimate number of scans to set pass_limit. */ 579 /* Estimate number of scans to set pass_limit. */
594 if (cinfo->progressive_mode) { 580 if (cinfo->progressive_mode) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 (*cinfo->cquantize->start_pass) (cinfo, FALSE); 616 (*cinfo->cquantize->start_pass) (cinfo, FALSE);
631 (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST); 617 (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);
632 (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST); 618 (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);
633 #else 619 #else
634 ERREXIT(cinfo, JERR_NOT_COMPILED); 620 ERREXIT(cinfo, JERR_NOT_COMPILED);
635 #endif /* QUANT_2PASS_SUPPORTED */ 621 #endif /* QUANT_2PASS_SUPPORTED */
636 } else { 622 } else {
637 if (cinfo->quantize_colors && cinfo->colormap == NULL) { 623 if (cinfo->quantize_colors && cinfo->colormap == NULL) {
638 /* Select new quantization method */ 624 /* Select new quantization method */
639 if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) { 625 if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
640 » cinfo->cquantize = master->quantizer_2pass; 626 cinfo->cquantize = master->quantizer_2pass;
641 » master->pub.is_dummy_pass = TRUE; 627 master->pub.is_dummy_pass = TRUE;
642 } else if (cinfo->enable_1pass_quant) { 628 } else if (cinfo->enable_1pass_quant) {
643 » cinfo->cquantize = master->quantizer_1pass; 629 cinfo->cquantize = master->quantizer_1pass;
644 } else { 630 } else {
645 » ERREXIT(cinfo, JERR_MODE_CHANGE); 631 ERREXIT(cinfo, JERR_MODE_CHANGE);
646 } 632 }
647 } 633 }
648 (*cinfo->idct->start_pass) (cinfo); 634 (*cinfo->idct->start_pass) (cinfo);
649 (*cinfo->coef->start_output_pass) (cinfo); 635 (*cinfo->coef->start_output_pass) (cinfo);
650 if (! cinfo->raw_data_out) { 636 if (! cinfo->raw_data_out) {
651 if (! master->using_merged_upsample) 637 if (! master->using_merged_upsample)
652 » (*cinfo->cconvert->start_pass) (cinfo); 638 (*cinfo->cconvert->start_pass) (cinfo);
653 (*cinfo->upsample->start_pass) (cinfo); 639 (*cinfo->upsample->start_pass) (cinfo);
654 if (cinfo->quantize_colors) 640 if (cinfo->quantize_colors)
655 » (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass); 641 (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
656 (*cinfo->post->start_pass) (cinfo, 642 (*cinfo->post->start_pass) (cinfo,
657 » (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); 643 (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
658 (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); 644 (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
659 } 645 }
660 } 646 }
661 647
662 /* Set up progress monitor's pass info if present */ 648 /* Set up progress monitor's pass info if present */
663 if (cinfo->progress != NULL) { 649 if (cinfo->progress != NULL) {
664 cinfo->progress->completed_passes = master->pass_number; 650 cinfo->progress->completed_passes = master->pass_number;
665 cinfo->progress->total_passes = master->pass_number + 651 cinfo->progress->total_passes = master->pass_number +
666 » » » » (master->pub.is_dummy_pass ? 2 : 1); 652 (master->pub.is_dummy_pass ? 2 : 1);
667 /* In buffered-image mode, we assume one more output pass if EOI not 653 /* In buffered-image mode, we assume one more output pass if EOI not
668 * yet reached, but no more passes if EOI has been reached. 654 * yet reached, but no more passes if EOI has been reached.
669 */ 655 */
670 if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) { 656 if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {
671 cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1); 657 cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
672 } 658 }
673 } 659 }
674 } 660 }
675 661
676 662
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 705
720 706
721 /* 707 /*
722 * Initialize master decompression control and select active modules. 708 * Initialize master decompression control and select active modules.
723 * This is performed at the start of jpeg_start_decompress. 709 * This is performed at the start of jpeg_start_decompress.
724 */ 710 */
725 711
726 GLOBAL(void) 712 GLOBAL(void)
727 jinit_master_decompress (j_decompress_ptr cinfo) 713 jinit_master_decompress (j_decompress_ptr cinfo)
728 { 714 {
729 my_master_ptr master; 715 my_master_ptr master = (my_master_ptr) cinfo->master;
730 716
731 master = (my_master_ptr)
732 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
733 SIZEOF(my_decomp_master));
734 cinfo->master = (struct jpeg_decomp_master *) master;
735 master->pub.prepare_for_output_pass = prepare_for_output_pass; 717 master->pub.prepare_for_output_pass = prepare_for_output_pass;
736 master->pub.finish_output_pass = finish_output_pass; 718 master->pub.finish_output_pass = finish_output_pass;
737 719
738 master->pub.is_dummy_pass = FALSE; 720 master->pub.is_dummy_pass = FALSE;
721 master->pub.jinit_upsampler_no_alloc = FALSE;
739 722
740 master_selection(cinfo); 723 master_selection(cinfo);
741 } 724 }
OLDNEW
« jdhuff.c ('K') | « jdmaster.h ('k') | jdmerge.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698