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

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

Issue 7554002: Updates libjpeg-turbo to 1.1.90 (r677) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: '' Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « third_party/libjpeg_turbo/jcmarker.c ('k') | third_party/libjpeg_turbo/jconfig.h » ('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 * jcmaster.c 2 * jcmaster.c
3 * 3 *
4 * Copyright (C) 1991-1997, Thomas G. Lane. 4 * Copyright (C) 1991-1997, Thomas G. Lane.
5 * Modified 2003-2010 by Guido Vollbeding.
6 * Copyright (C) 2010, D. R. Commander.
5 * This file is part of the Independent JPEG Group's software. 7 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file. 8 * For conditions of distribution and use, see the accompanying README file.
7 * 9 *
8 * This file contains master control logic for the JPEG compressor. 10 * This file contains master control logic for the JPEG compressor.
9 * These routines are concerned with parameter validation, initial setup, 11 * These routines are concerned with parameter validation, initial setup,
10 * and inter-pass control (determining the number of passes and the work 12 * and inter-pass control (determining the number of passes and the work
11 * to be done in each pass). 13 * to be done in each pass).
12 */ 14 */
13 15
14 #define JPEG_INTERNALS 16 #define JPEG_INTERNALS
15 #include "jinclude.h" 17 #include "jinclude.h"
16 #include "jpeglib.h" 18 #include "jpeglib.h"
19 #include "jpegcomp.h"
17 20
18 21
19 /* Private state */ 22 /* Private state */
20 23
21 typedef enum { 24 typedef enum {
22 main_pass, /* input data, also do first output step */ 25 main_pass, /* input data, also do first output step */
23 huff_opt_pass, /* Huffman code optimization pass */ 26 huff_opt_pass, /* Huffman code optimization pass */
24 output_pass /* data output pass */ 27 output_pass /* data output pass */
25 } c_pass_type; 28 } c_pass_type;
26 29
27 typedef struct { 30 typedef struct {
28 struct jpeg_comp_master pub; /* public fields */ 31 struct jpeg_comp_master pub; /* public fields */
29 32
30 c_pass_type pass_type; /* the type of the current pass */ 33 c_pass_type pass_type; /* the type of the current pass */
31 34
32 int pass_number; /* # of passes completed */ 35 int pass_number; /* # of passes completed */
33 int total_passes; /* total # of passes needed */ 36 int total_passes; /* total # of passes needed */
34 37
35 int scan_number; /* current index in scan_info[] */ 38 int scan_number; /* current index in scan_info[] */
36 } my_comp_master; 39 } my_comp_master;
37 40
38 typedef my_comp_master * my_master_ptr; 41 typedef my_comp_master * my_master_ptr;
39 42
40 43
41 /* 44 /*
42 * Support routines that do various essential calculations. 45 * Support routines that do various essential calculations.
43 */ 46 */
44 47
48 #if JPEG_LIB_VERSION >= 70
49 /*
50 * Compute JPEG image dimensions and related values.
51 * NOTE: this is exported for possible use by application.
52 * Hence it mustn't do anything that can't be done twice.
53 */
54
55 GLOBAL(void)
56 jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo)
57 /* Do computations that are needed before master selection phase */
58 {
59 /* Hardwire it to "no scaling" */
60 cinfo->jpeg_width = cinfo->image_width;
61 cinfo->jpeg_height = cinfo->image_height;
62 cinfo->min_DCT_h_scaled_size = DCTSIZE;
63 cinfo->min_DCT_v_scaled_size = DCTSIZE;
64 }
65 #endif
66
67
45 LOCAL(void) 68 LOCAL(void)
46 initial_setup (j_compress_ptr cinfo) 69 initial_setup (j_compress_ptr cinfo, boolean transcode_only)
47 /* Do computations that are needed before master selection phase */ 70 /* Do computations that are needed before master selection phase */
48 { 71 {
49 int ci; 72 int ci;
50 jpeg_component_info *compptr; 73 jpeg_component_info *compptr;
51 long samplesperrow; 74 long samplesperrow;
52 JDIMENSION jd_samplesperrow; 75 JDIMENSION jd_samplesperrow;
53 76
77 #if JPEG_LIB_VERSION >= 70
78 #if JPEG_LIB_VERSION >= 80
79 if (!transcode_only)
80 #endif
81 jpeg_calc_jpeg_dimensions(cinfo);
82 #endif
83
54 /* Sanity check on image dimensions */ 84 /* Sanity check on image dimensions */
55 if (cinfo->image_height <= 0 || cinfo->image_width <= 0 85 if (cinfo->_jpeg_height <= 0 || cinfo->_jpeg_width <= 0
56 || cinfo->num_components <= 0 || cinfo->input_components <= 0) 86 || cinfo->num_components <= 0 || cinfo->input_components <= 0)
57 ERREXIT(cinfo, JERR_EMPTY_IMAGE); 87 ERREXIT(cinfo, JERR_EMPTY_IMAGE);
58 88
59 /* Make sure image isn't bigger than I can handle */ 89 /* Make sure image isn't bigger than I can handle */
60 if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || 90 if ((long) cinfo->_jpeg_height > (long) JPEG_MAX_DIMENSION ||
61 (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) 91 (long) cinfo->_jpeg_width > (long) JPEG_MAX_DIMENSION)
62 ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); 92 ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
63 93
64 /* Width of an input scanline must be representable as JDIMENSION. */ 94 /* Width of an input scanline must be representable as JDIMENSION. */
65 samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; 95 samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components;
66 jd_samplesperrow = (JDIMENSION) samplesperrow; 96 jd_samplesperrow = (JDIMENSION) samplesperrow;
67 if ((long) jd_samplesperrow != samplesperrow) 97 if ((long) jd_samplesperrow != samplesperrow)
68 ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); 98 ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
69 99
70 /* For now, precision must match compiled-in value... */ 100 /* For now, precision must match compiled-in value... */
71 if (cinfo->data_precision != BITS_IN_JSAMPLE) 101 if (cinfo->data_precision != BITS_IN_JSAMPLE)
(...skipping 17 matching lines...) Expand all
89 cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, 119 cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
90 compptr->v_samp_factor); 120 compptr->v_samp_factor);
91 } 121 }
92 122
93 /* Compute dimensions of components */ 123 /* Compute dimensions of components */
94 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 124 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
95 ci++, compptr++) { 125 ci++, compptr++) {
96 /* Fill in the correct component_index value; don't rely on application */ 126 /* Fill in the correct component_index value; don't rely on application */
97 compptr->component_index = ci; 127 compptr->component_index = ci;
98 /* For compression, we never do DCT scaling. */ 128 /* For compression, we never do DCT scaling. */
129 #if JPEG_LIB_VERSION >= 70
130 compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size = DCTSIZE;
131 #else
99 compptr->DCT_scaled_size = DCTSIZE; 132 compptr->DCT_scaled_size = DCTSIZE;
133 #endif
100 /* Size in DCT blocks */ 134 /* Size in DCT blocks */
101 compptr->width_in_blocks = (JDIMENSION) 135 compptr->width_in_blocks = (JDIMENSION)
102 jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, 136 jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
103 (long) (cinfo->max_h_samp_factor * DCTSIZE)); 137 (long) (cinfo->max_h_samp_factor * DCTSIZE));
104 compptr->height_in_blocks = (JDIMENSION) 138 compptr->height_in_blocks = (JDIMENSION)
105 jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, 139 jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
106 (long) (cinfo->max_v_samp_factor * DCTSIZE)); 140 (long) (cinfo->max_v_samp_factor * DCTSIZE));
107 /* Size in samples */ 141 /* Size in samples */
108 compptr->downsampled_width = (JDIMENSION) 142 compptr->downsampled_width = (JDIMENSION)
109 jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, 143 jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
110 (long) cinfo->max_h_samp_factor); 144 (long) cinfo->max_h_samp_factor);
111 compptr->downsampled_height = (JDIMENSION) 145 compptr->downsampled_height = (JDIMENSION)
112 jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, 146 jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
113 (long) cinfo->max_v_samp_factor); 147 (long) cinfo->max_v_samp_factor);
114 /* Mark component needed (this flag isn't actually used for compression) */ 148 /* Mark component needed (this flag isn't actually used for compression) */
115 compptr->component_needed = TRUE; 149 compptr->component_needed = TRUE;
116 } 150 }
117 151
118 /* Compute number of fully interleaved MCU rows (number of times that 152 /* Compute number of fully interleaved MCU rows (number of times that
119 * main controller will call coefficient controller). 153 * main controller will call coefficient controller).
120 */ 154 */
121 cinfo->total_iMCU_rows = (JDIMENSION) 155 cinfo->total_iMCU_rows = (JDIMENSION)
122 jdiv_round_up((long) cinfo->image_height, 156 jdiv_round_up((long) cinfo->_jpeg_height,
123 (long) (cinfo->max_v_samp_factor*DCTSIZE)); 157 (long) (cinfo->max_v_samp_factor*DCTSIZE));
124 } 158 }
125 159
126 160
127 #ifdef C_MULTISCAN_FILES_SUPPORTED 161 #ifdef C_MULTISCAN_FILES_SUPPORTED
128 162
129 LOCAL(void) 163 LOCAL(void)
130 validate_script (j_compress_ptr cinfo) 164 validate_script (j_compress_ptr cinfo)
131 /* Verify that the scan script in cinfo->scan_info[] is valid; also 165 /* Verify that the scan script in cinfo->scan_info[] is valid; also
132 * determine whether it uses progressive JPEG, and set cinfo->progressive_mode. 166 * determine whether it uses progressive JPEG, and set cinfo->progressive_mode.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 374
341 } else { 375 } else {
342 376
343 /* Interleaved (multi-component) scan */ 377 /* Interleaved (multi-component) scan */
344 if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) 378 if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
345 ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, 379 ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
346 MAX_COMPS_IN_SCAN); 380 MAX_COMPS_IN_SCAN);
347 381
348 /* Overall image size in MCUs */ 382 /* Overall image size in MCUs */
349 cinfo->MCUs_per_row = (JDIMENSION) 383 cinfo->MCUs_per_row = (JDIMENSION)
350 jdiv_round_up((long) cinfo->image_width, 384 jdiv_round_up((long) cinfo->_jpeg_width,
351 (long) (cinfo->max_h_samp_factor*DCTSIZE)); 385 (long) (cinfo->max_h_samp_factor*DCTSIZE));
352 cinfo->MCU_rows_in_scan = (JDIMENSION) 386 cinfo->MCU_rows_in_scan = (JDIMENSION)
353 jdiv_round_up((long) cinfo->image_height, 387 jdiv_round_up((long) cinfo->_jpeg_height,
354 (long) (cinfo->max_v_samp_factor*DCTSIZE)); 388 (long) (cinfo->max_v_samp_factor*DCTSIZE));
355 389
356 cinfo->blocks_in_MCU = 0; 390 cinfo->blocks_in_MCU = 0;
357 391
358 for (ci = 0; ci < cinfo->comps_in_scan; ci++) { 392 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
359 compptr = cinfo->cur_comp_info[ci]; 393 compptr = cinfo->cur_comp_info[ci];
360 /* Sampling factors give # of blocks of component in each MCU */ 394 /* Sampling factors give # of blocks of component in each MCU */
361 compptr->MCU_width = compptr->h_samp_factor; 395 compptr->MCU_width = compptr->h_samp_factor;
362 compptr->MCU_height = compptr->v_samp_factor; 396 compptr->MCU_height = compptr->v_samp_factor;
363 compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; 397 compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 master = (my_master_ptr) 581 master = (my_master_ptr)
548 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 582 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
549 SIZEOF(my_comp_master)); 583 SIZEOF(my_comp_master));
550 cinfo->master = (struct jpeg_comp_master *) master; 584 cinfo->master = (struct jpeg_comp_master *) master;
551 master->pub.prepare_for_pass = prepare_for_pass; 585 master->pub.prepare_for_pass = prepare_for_pass;
552 master->pub.pass_startup = pass_startup; 586 master->pub.pass_startup = pass_startup;
553 master->pub.finish_pass = finish_pass_master; 587 master->pub.finish_pass = finish_pass_master;
554 master->pub.is_last_pass = FALSE; 588 master->pub.is_last_pass = FALSE;
555 589
556 /* Validate parameters, determine derived values */ 590 /* Validate parameters, determine derived values */
557 initial_setup(cinfo); 591 initial_setup(cinfo, transcode_only);
558 592
559 if (cinfo->scan_info != NULL) { 593 if (cinfo->scan_info != NULL) {
560 #ifdef C_MULTISCAN_FILES_SUPPORTED 594 #ifdef C_MULTISCAN_FILES_SUPPORTED
561 validate_script(cinfo); 595 validate_script(cinfo);
562 #else 596 #else
563 ERREXIT(cinfo, JERR_NOT_COMPILED); 597 ERREXIT(cinfo, JERR_NOT_COMPILED);
564 #endif 598 #endif
565 } else { 599 } else {
566 cinfo->progressive_mode = FALSE; 600 cinfo->progressive_mode = FALSE;
567 cinfo->num_scans = 1; 601 cinfo->num_scans = 1;
(...skipping 13 matching lines...) Expand all
581 /* for normal compression, first pass is always this type: */ 615 /* for normal compression, first pass is always this type: */
582 master->pass_type = main_pass; 616 master->pass_type = main_pass;
583 } 617 }
584 master->scan_number = 0; 618 master->scan_number = 0;
585 master->pass_number = 0; 619 master->pass_number = 0;
586 if (cinfo->optimize_coding) 620 if (cinfo->optimize_coding)
587 master->total_passes = cinfo->num_scans * 2; 621 master->total_passes = cinfo->num_scans * 2;
588 else 622 else
589 master->total_passes = cinfo->num_scans; 623 master->total_passes = cinfo->num_scans;
590 } 624 }
OLDNEW
« no previous file with comments | « third_party/libjpeg_turbo/jcmarker.c ('k') | third_party/libjpeg_turbo/jconfig.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698