Changeset 846 for trunk/src/3rdparty/libjpeg/jdmaster.c
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/3rdparty/libjpeg/jdmaster.c
r2 r846 3 3 * 4 4 * Copyright (C) 1991-1997, Thomas G. Lane. 5 * Modified 2002-2009 by Guido Vollbeding. 5 6 * This file is part of the Independent JPEG Group's software. 6 7 * For conditions of distribution and use, see the accompanying README file. … … 62 63 return FALSE; 63 64 /* furthermore, it doesn't work if we've scaled the IDCTs differently */ 64 if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size || 65 cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size || 66 cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size) 65 if (cinfo->comp_info[0].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size || 66 cinfo->comp_info[1].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size || 67 cinfo->comp_info[2].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size || 68 cinfo->comp_info[0].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size || 69 cinfo->comp_info[1].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size || 70 cinfo->comp_info[2].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size) 67 71 return FALSE; 68 72 /* ??? also need to test for upsample-time rescaling, when & if supported */ … … 83 87 GLOBAL(void) 84 88 jpeg_calc_output_dimensions (j_decompress_ptr cinfo) 85 /* Do computations that are needed before master selection phase */ 89 /* Do computations that are needed before master selection phase. 90 * This function is used for full decompression. 91 */ 86 92 { 87 93 #ifdef IDCT_SCALING_SUPPORTED … … 94 100 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 95 101 102 /* Compute core output image dimensions and DCT scaling choices. */ 103 jpeg_core_output_dimensions(cinfo); 104 96 105 #ifdef IDCT_SCALING_SUPPORTED 97 106 98 /* Compute actual output image dimensions and DCT scaling choices. */99 if (cinfo->scale_num * 8 <= cinfo->scale_denom) {100 /* Provide 1/8 scaling */101 cinfo->output_width = (JDIMENSION)102 jdiv_round_up((long) cinfo->image_width, 8L);103 cinfo->output_height = (JDIMENSION)104 jdiv_round_up((long) cinfo->image_height, 8L);105 cinfo->min_DCT_scaled_size = 1;106 } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {107 /* Provide 1/4 scaling */108 cinfo->output_width = (JDIMENSION)109 jdiv_round_up((long) cinfo->image_width, 4L);110 cinfo->output_height = (JDIMENSION)111 jdiv_round_up((long) cinfo->image_height, 4L);112 cinfo->min_DCT_scaled_size = 2;113 } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {114 /* Provide 1/2 scaling */115 cinfo->output_width = (JDIMENSION)116 jdiv_round_up((long) cinfo->image_width, 2L);117 cinfo->output_height = (JDIMENSION)118 jdiv_round_up((long) cinfo->image_height, 2L);119 cinfo->min_DCT_scaled_size = 4;120 } else {121 /* Provide 1/1 scaling */122 cinfo->output_width = cinfo->image_width;123 cinfo->output_height = cinfo->image_height;124 cinfo->min_DCT_scaled_size = DCTSIZE;125 }126 107 /* In selecting the actual DCT scaling for each component, we try to 127 108 * scale up the chroma components via IDCT scaling rather than upsampling. 128 109 * This saves time if the upsampler gets to use 1:1 scaling. 129 * Note this code a ssumes that the supported DCT scalingsare powers of 2.110 * Note this code adapts subsampling ratios which are powers of 2. 130 111 */ 131 112 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 132 113 ci++, compptr++) { 133 int ssize = cinfo->min_DCT_scaled_size; 134 while (ssize < DCTSIZE && 135 (compptr->h_samp_factor * ssize * 2 <= 136 cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) && 137 (compptr->v_samp_factor * ssize * 2 <= 138 cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) { 114 int ssize = 1; 115 while (cinfo->min_DCT_h_scaled_size * ssize <= 116 (cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) && 117 (cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == 0) { 139 118 ssize = ssize * 2; 140 119 } 141 compptr->DCT_scaled_size = ssize; 120 compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize; 121 ssize = 1; 122 while (cinfo->min_DCT_v_scaled_size * ssize <= 123 (cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) && 124 (cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == 0) { 125 ssize = ssize * 2; 126 } 127 compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize; 128 129 /* We don't support IDCT ratios larger than 2. */ 130 if (compptr->DCT_h_scaled_size > compptr->DCT_v_scaled_size * 2) 131 compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size * 2; 132 else if (compptr->DCT_v_scaled_size > compptr->DCT_h_scaled_size * 2) 133 compptr->DCT_v_scaled_size = compptr->DCT_h_scaled_size * 2; 142 134 } 143 135 … … 150 142 compptr->downsampled_width = (JDIMENSION) 151 143 jdiv_round_up((long) cinfo->image_width * 152 (long) (compptr->h_samp_factor * compptr->DCT_ scaled_size),153 (long) (cinfo->max_h_samp_factor * DCTSIZE));144 (long) (compptr->h_samp_factor * compptr->DCT_h_scaled_size), 145 (long) (cinfo->max_h_samp_factor * cinfo->block_size)); 154 146 compptr->downsampled_height = (JDIMENSION) 155 147 jdiv_round_up((long) cinfo->image_height * 156 (long) (compptr->v_samp_factor * compptr->DCT_scaled_size), 157 (long) (cinfo->max_v_samp_factor * DCTSIZE)); 158 } 159 160 #else /* !IDCT_SCALING_SUPPORTED */ 161 162 /* Hardwire it to "no scaling" */ 163 cinfo->output_width = cinfo->image_width; 164 cinfo->output_height = cinfo->image_height; 165 /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE, 166 * and has computed unscaled downsampled_width and downsampled_height. 167 */ 148 (long) (compptr->v_samp_factor * compptr->DCT_v_scaled_size), 149 (long) (cinfo->max_v_samp_factor * cinfo->block_size)); 150 } 168 151 169 152 #endif /* IDCT_SCALING_SUPPORTED */ … … 373 356 jinit_inverse_dct(cinfo); 374 357 /* Entropy decoding: either Huffman or arithmetic coding. */ 375 if (cinfo->arith_code) { 376 ERREXIT(cinfo, JERR_ARITH_NOTIMPL); 377 } else { 378 if (cinfo->progressive_mode) { 379 #ifdef D_PROGRESSIVE_SUPPORTED 380 jinit_phuff_decoder(cinfo); 381 #else 382 ERREXIT(cinfo, JERR_NOT_COMPILED); 383 #endif 384 } else 385 jinit_huff_decoder(cinfo); 358 if (cinfo->arith_code) 359 jinit_arith_decoder(cinfo); 360 else { 361 jinit_huff_decoder(cinfo); 386 362 } 387 363
Note:
See TracChangeset
for help on using the changeset viewer.