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

Side by Side Diff: jctrans.c

Issue 1934113002: Update libjpeg_turbo to 1.4.90 from https://github.com/libjpeg-turbo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@master
Patch Set: 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
OLDNEW
1 /* 1 /*
2 * jctrans.c 2 * jctrans.c
3 * 3 *
4 * This file was part of the Independent JPEG Group's software:
4 * Copyright (C) 1995-1998, Thomas G. Lane. 5 * Copyright (C) 1995-1998, Thomas G. Lane.
5 * Modified 2000-2009 by Guido Vollbeding. 6 * Modified 2000-2009 by Guido Vollbeding.
6 * This file is part of the Independent JPEG Group's software. 7 * It was modified by The libjpeg-turbo Project to include only code relevant
7 * For conditions of distribution and use, see the accompanying README file. 8 * to libjpeg-turbo.
9 * For conditions of distribution and use, see the accompanying README.ijg
10 * file.
8 * 11 *
9 * This file contains library routines for transcoding compression, 12 * This file contains library routines for transcoding compression,
10 * that is, writing raw DCT coefficient arrays to an output JPEG file. 13 * that is, writing raw DCT coefficient arrays to an output JPEG file.
11 * The routines in jcapimin.c will also be needed by a transcoder. 14 * The routines in jcapimin.c will also be needed by a transcoder.
12 */ 15 */
13 16
14 #define JPEG_INTERNALS 17 #define JPEG_INTERNALS
15 #include "jinclude.h" 18 #include "jinclude.h"
16 #include "jpeglib.h" 19 #include "jpeglib.h"
17 20
18 21
19 /* Forward declarations */ 22 /* Forward declarations */
20 LOCAL(void) transencode_master_selection 23 LOCAL(void) transencode_master_selection
21 » JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); 24 (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays);
22 LOCAL(void) transencode_coef_controller 25 LOCAL(void) transencode_coef_controller
23 » JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); 26 (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays);
24 27
25 28
26 /* 29 /*
27 * Compression initialization for writing raw-coefficient data. 30 * Compression initialization for writing raw-coefficient data.
28 * Before calling this, all parameters and a data destination must be set up. 31 * Before calling this, all parameters and a data destination must be set up.
29 * Call jpeg_finish_compress() to actually write the data. 32 * Call jpeg_finish_compress() to actually write the data.
30 * 33 *
31 * The number of passed virtual arrays must match cinfo->num_components. 34 * The number of passed virtual arrays must match cinfo->num_components.
32 * Note that the virtual arrays need not be filled or even realized at 35 * Note that the virtual arrays need not be filled or even realized at
33 * the time write_coefficients is called; indeed, if the virtual arrays 36 * the time write_coefficients is called; indeed, if the virtual arrays
34 * were requested from this compression object's memory manager, they 37 * were requested from this compression object's memory manager, they
35 * typically will be realized during this routine and filled afterwards. 38 * typically will be realized during this routine and filled afterwards.
36 */ 39 */
37 40
38 GLOBAL(void) 41 GLOBAL(void)
39 jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) 42 jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
40 { 43 {
41 if (cinfo->global_state != CSTATE_START) 44 if (cinfo->global_state != CSTATE_START)
42 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 45 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
43 /* Mark all tables to be written */ 46 /* Mark all tables to be written */
44 jpeg_suppress_tables(cinfo, FALSE); 47 jpeg_suppress_tables(cinfo, FALSE);
45 /* (Re)initialize error mgr and destination modules */ 48 /* (Re)initialize error mgr and destination modules */
46 (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); 49 (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
47 (*cinfo->dest->init_destination) (cinfo); 50 (*cinfo->dest->init_destination) (cinfo);
48 /* Perform master selection of active modules */ 51 /* Perform master selection of active modules */
49 transencode_master_selection(cinfo, coef_arrays); 52 transencode_master_selection(cinfo, coef_arrays);
50 /* Wait for jpeg_finish_compress() call */ 53 /* Wait for jpeg_finish_compress() call */
51 cinfo->next_scanline = 0;» /* so jpeg_write_marker works */ 54 cinfo->next_scanline = 0; /* so jpeg_write_marker works */
52 cinfo->global_state = CSTATE_WRCOEFS; 55 cinfo->global_state = CSTATE_WRCOEFS;
53 } 56 }
54 57
55 58
56 /* 59 /*
57 * Initialize the compression object with default parameters, 60 * Initialize the compression object with default parameters,
58 * then copy from the source object all parameters needed for lossless 61 * then copy from the source object all parameters needed for lossless
59 * transcoding. Parameters that can be varied without loss (such as 62 * transcoding. Parameters that can be varied without loss (such as
60 * scan script and Huffman optimization) are left in their default states. 63 * scan script and Huffman optimization) are left in their default states.
61 */ 64 */
62 65
63 GLOBAL(void) 66 GLOBAL(void)
64 jpeg_copy_critical_parameters (j_decompress_ptr srcinfo, 67 jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
65 » » » j_compress_ptr dstinfo) 68 j_compress_ptr dstinfo)
66 { 69 {
67 JQUANT_TBL ** qtblptr; 70 JQUANT_TBL **qtblptr;
68 jpeg_component_info *incomp, *outcomp; 71 jpeg_component_info *incomp, *outcomp;
69 JQUANT_TBL *c_quant, *slot_quant; 72 JQUANT_TBL *c_quant, *slot_quant;
70 int tblno, ci, coefi; 73 int tblno, ci, coefi;
71 74
72 /* Safety check to ensure start_compress not called yet. */ 75 /* Safety check to ensure start_compress not called yet. */
73 if (dstinfo->global_state != CSTATE_START) 76 if (dstinfo->global_state != CSTATE_START)
74 ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); 77 ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state);
75 /* Copy fundamental image dimensions */ 78 /* Copy fundamental image dimensions */
76 dstinfo->image_width = srcinfo->image_width; 79 dstinfo->image_width = srcinfo->image_width;
77 dstinfo->image_height = srcinfo->image_height; 80 dstinfo->image_height = srcinfo->image_height;
(...skipping 11 matching lines...) Expand all
89 * Fix it to get the right header markers for the image colorspace. 92 * Fix it to get the right header markers for the image colorspace.
90 */ 93 */
91 jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); 94 jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space);
92 dstinfo->data_precision = srcinfo->data_precision; 95 dstinfo->data_precision = srcinfo->data_precision;
93 dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; 96 dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling;
94 /* Copy the source's quantization tables. */ 97 /* Copy the source's quantization tables. */
95 for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { 98 for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
96 if (srcinfo->quant_tbl_ptrs[tblno] != NULL) { 99 if (srcinfo->quant_tbl_ptrs[tblno] != NULL) {
97 qtblptr = & dstinfo->quant_tbl_ptrs[tblno]; 100 qtblptr = & dstinfo->quant_tbl_ptrs[tblno];
98 if (*qtblptr == NULL) 101 if (*qtblptr == NULL)
99 » *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo); 102 *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo);
100 MEMCOPY((*qtblptr)->quantval, 103 MEMCOPY((*qtblptr)->quantval,
101 » srcinfo->quant_tbl_ptrs[tblno]->quantval, 104 srcinfo->quant_tbl_ptrs[tblno]->quantval,
102 » SIZEOF((*qtblptr)->quantval)); 105 sizeof((*qtblptr)->quantval));
103 (*qtblptr)->sent_table = FALSE; 106 (*qtblptr)->sent_table = FALSE;
104 } 107 }
105 } 108 }
106 /* Copy the source's per-component info. 109 /* Copy the source's per-component info.
107 * Note we assume jpeg_set_defaults has allocated the dest comp_info array. 110 * Note we assume jpeg_set_defaults has allocated the dest comp_info array.
108 */ 111 */
109 dstinfo->num_components = srcinfo->num_components; 112 dstinfo->num_components = srcinfo->num_components;
110 if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS) 113 if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS)
111 ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components, 114 ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components,
112 » MAX_COMPONENTS); 115 MAX_COMPONENTS);
113 for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info; 116 for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info;
114 ci < dstinfo->num_components; ci++, incomp++, outcomp++) { 117 ci < dstinfo->num_components; ci++, incomp++, outcomp++) {
115 outcomp->component_id = incomp->component_id; 118 outcomp->component_id = incomp->component_id;
116 outcomp->h_samp_factor = incomp->h_samp_factor; 119 outcomp->h_samp_factor = incomp->h_samp_factor;
117 outcomp->v_samp_factor = incomp->v_samp_factor; 120 outcomp->v_samp_factor = incomp->v_samp_factor;
118 outcomp->quant_tbl_no = incomp->quant_tbl_no; 121 outcomp->quant_tbl_no = incomp->quant_tbl_no;
119 /* Make sure saved quantization table for component matches the qtable 122 /* Make sure saved quantization table for component matches the qtable
120 * slot. If not, the input file re-used this qtable slot. 123 * slot. If not, the input file re-used this qtable slot.
121 * IJG encoder currently cannot duplicate this. 124 * IJG encoder currently cannot duplicate this.
122 */ 125 */
123 tblno = outcomp->quant_tbl_no; 126 tblno = outcomp->quant_tbl_no;
124 if (tblno < 0 || tblno >= NUM_QUANT_TBLS || 127 if (tblno < 0 || tblno >= NUM_QUANT_TBLS ||
125 » srcinfo->quant_tbl_ptrs[tblno] == NULL) 128 srcinfo->quant_tbl_ptrs[tblno] == NULL)
126 ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno); 129 ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno);
127 slot_quant = srcinfo->quant_tbl_ptrs[tblno]; 130 slot_quant = srcinfo->quant_tbl_ptrs[tblno];
128 c_quant = incomp->quant_table; 131 c_quant = incomp->quant_table;
129 if (c_quant != NULL) { 132 if (c_quant != NULL) {
130 for (coefi = 0; coefi < DCTSIZE2; coefi++) { 133 for (coefi = 0; coefi < DCTSIZE2; coefi++) {
131 » if (c_quant->quantval[coefi] != slot_quant->quantval[coefi]) 134 if (c_quant->quantval[coefi] != slot_quant->quantval[coefi])
132 » ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno); 135 ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno);
133 } 136 }
134 } 137 }
135 /* Note: we do not copy the source's Huffman table assignments; 138 /* Note: we do not copy the source's Huffman table assignments;
136 * instead we rely on jpeg_set_colorspace to have made a suitable choice. 139 * instead we rely on jpeg_set_colorspace to have made a suitable choice.
137 */ 140 */
138 } 141 }
139 /* Also copy JFIF version and resolution information, if available. 142 /* Also copy JFIF version and resolution information, if available.
140 * Strictly speaking this isn't "critical" info, but it's nearly 143 * Strictly speaking this isn't "critical" info, but it's nearly
141 * always appropriate to copy it if available. In particular, 144 * always appropriate to copy it if available. In particular,
142 * if the application chooses to copy JFIF 1.02 extension markers from 145 * if the application chooses to copy JFIF 1.02 extension markers from
(...skipping 13 matching lines...) Expand all
156 } 159 }
157 160
158 161
159 /* 162 /*
160 * Master selection of compression modules for transcoding. 163 * Master selection of compression modules for transcoding.
161 * This substitutes for jcinit.c's initialization of the full compressor. 164 * This substitutes for jcinit.c's initialization of the full compressor.
162 */ 165 */
163 166
164 LOCAL(void) 167 LOCAL(void)
165 transencode_master_selection (j_compress_ptr cinfo, 168 transencode_master_selection (j_compress_ptr cinfo,
166 » » » jvirt_barray_ptr * coef_arrays) 169 jvirt_barray_ptr *coef_arrays)
167 { 170 {
168 /* Although we don't actually use input_components for transcoding, 171 /* Although we don't actually use input_components for transcoding,
169 * jcmaster.c's initial_setup will complain if input_components is 0. 172 * jcmaster.c's initial_setup will complain if input_components is 0.
170 */ 173 */
171 cinfo->input_components = 1; 174 cinfo->input_components = 1;
172 /* Initialize master control (includes parameter checking/processing) */ 175 /* Initialize master control (includes parameter checking/processing) */
173 jinit_c_master_control(cinfo, TRUE /* transcode only */); 176 jinit_c_master_control(cinfo, TRUE /* transcode only */);
174 177
175 /* Entropy encoding: either Huffman or arithmetic coding. */ 178 /* Entropy encoding: either Huffman or arithmetic coding. */
176 if (cinfo->arith_code) { 179 if (cinfo->arith_code) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 * output from presupplied virtual arrays. Furthermore, we generate any 215 * output from presupplied virtual arrays. Furthermore, we generate any
213 * dummy padding blocks on-the-fly rather than expecting them to be present 216 * dummy padding blocks on-the-fly rather than expecting them to be present
214 * in the arrays. 217 * in the arrays.
215 */ 218 */
216 219
217 /* Private buffer controller object */ 220 /* Private buffer controller object */
218 221
219 typedef struct { 222 typedef struct {
220 struct jpeg_c_coef_controller pub; /* public fields */ 223 struct jpeg_c_coef_controller pub; /* public fields */
221 224
222 JDIMENSION iMCU_row_num;» /* iMCU row # within image */ 225 JDIMENSION iMCU_row_num; /* iMCU row # within image */
223 JDIMENSION mcu_ctr;» » /* counts MCUs processed in current row */ 226 JDIMENSION mcu_ctr; /* counts MCUs processed in current row */
224 int MCU_vert_offset;» » /* counts MCU rows within iMCU row */ 227 int MCU_vert_offset; /* counts MCU rows within iMCU row */
225 int MCU_rows_per_iMCU_row;» /* number of such rows needed */ 228 int MCU_rows_per_iMCU_row; /* number of such rows needed */
226 229
227 /* Virtual block array for each component. */ 230 /* Virtual block array for each component. */
228 jvirt_barray_ptr * whole_image; 231 jvirt_barray_ptr *whole_image;
229 232
230 /* Workspace for constructing dummy blocks at right/bottom edges. */ 233 /* Workspace for constructing dummy blocks at right/bottom edges. */
231 JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU]; 234 JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU];
232 } my_coef_controller; 235 } my_coef_controller;
233 236
234 typedef my_coef_controller * my_coef_ptr; 237 typedef my_coef_controller *my_coef_ptr;
235 238
236 239
237 LOCAL(void) 240 LOCAL(void)
238 start_iMCU_row (j_compress_ptr cinfo) 241 start_iMCU_row (j_compress_ptr cinfo)
239 /* Reset within-iMCU-row counters for a new row */ 242 /* Reset within-iMCU-row counters for a new row */
240 { 243 {
241 my_coef_ptr coef = (my_coef_ptr) cinfo->coef; 244 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
242 245
243 /* In an interleaved scan, an MCU row is the same as an iMCU row. 246 /* In an interleaved scan, an MCU row is the same as an iMCU row.
244 * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. 247 * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 * The data is obtained from the virtual arrays and fed to the entropy coder. 285 * The data is obtained from the virtual arrays and fed to the entropy coder.
283 * Returns TRUE if the iMCU row is completed, FALSE if suspended. 286 * Returns TRUE if the iMCU row is completed, FALSE if suspended.
284 * 287 *
285 * NB: input_buf is ignored; it is likely to be a NULL pointer. 288 * NB: input_buf is ignored; it is likely to be a NULL pointer.
286 */ 289 */
287 290
288 METHODDEF(boolean) 291 METHODDEF(boolean)
289 compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) 292 compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
290 { 293 {
291 my_coef_ptr coef = (my_coef_ptr) cinfo->coef; 294 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
292 JDIMENSION MCU_col_num;» /* index of current MCU within row */ 295 JDIMENSION MCU_col_num; /* index of current MCU within row */
293 JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; 296 JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
294 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; 297 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
295 int blkn, ci, xindex, yindex, yoffset, blockcnt; 298 int blkn, ci, xindex, yindex, yoffset, blockcnt;
296 JDIMENSION start_col; 299 JDIMENSION start_col;
297 JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; 300 JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
298 JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; 301 JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU];
299 JBLOCKROW buffer_ptr; 302 JBLOCKROW buffer_ptr;
300 jpeg_component_info *compptr; 303 jpeg_component_info *compptr;
301 304
302 /* Align the virtual buffers for the components used in this scan. */ 305 /* Align the virtual buffers for the components used in this scan. */
303 for (ci = 0; ci < cinfo->comps_in_scan; ci++) { 306 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
304 compptr = cinfo->cur_comp_info[ci]; 307 compptr = cinfo->cur_comp_info[ci];
305 buffer[ci] = (*cinfo->mem->access_virt_barray) 308 buffer[ci] = (*cinfo->mem->access_virt_barray)
306 ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], 309 ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
307 coef->iMCU_row_num * compptr->v_samp_factor, 310 coef->iMCU_row_num * compptr->v_samp_factor,
308 (JDIMENSION) compptr->v_samp_factor, FALSE); 311 (JDIMENSION) compptr->v_samp_factor, FALSE);
309 } 312 }
310 313
311 /* Loop to process one whole iMCU row */ 314 /* Loop to process one whole iMCU row */
312 for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; 315 for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
313 yoffset++) { 316 yoffset++) {
314 for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; 317 for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;
315 » MCU_col_num++) { 318 MCU_col_num++) {
316 /* Construct list of pointers to DCT blocks belonging to this MCU */ 319 /* Construct list of pointers to DCT blocks belonging to this MCU */
317 blkn = 0;»» » /* index of current DCT block within MCU */ 320 blkn = 0; /* index of current DCT block within MCU */
318 for (ci = 0; ci < cinfo->comps_in_scan; ci++) { 321 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
319 » compptr = cinfo->cur_comp_info[ci]; 322 compptr = cinfo->cur_comp_info[ci];
320 » start_col = MCU_col_num * compptr->MCU_width; 323 start_col = MCU_col_num * compptr->MCU_width;
321 » blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width 324 blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
322 » » » » » » : compptr->last_col_width; 325 : compptr->last_col_width;
323 » for (yindex = 0; yindex < compptr->MCU_height; yindex++) { 326 for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
324 » if (coef->iMCU_row_num < last_iMCU_row || 327 if (coef->iMCU_row_num < last_iMCU_row ||
325 » yindex+yoffset < compptr->last_row_height) { 328 yindex+yoffset < compptr->last_row_height) {
326 » /* Fill in pointers to real blocks in this row */ 329 /* Fill in pointers to real blocks in this row */
327 » buffer_ptr = buffer[ci][yindex+yoffset] + start_col; 330 buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
328 » for (xindex = 0; xindex < blockcnt; xindex++) 331 for (xindex = 0; xindex < blockcnt; xindex++)
329 » MCU_buffer[blkn++] = buffer_ptr++; 332 MCU_buffer[blkn++] = buffer_ptr++;
330 » } else { 333 } else {
331 » /* At bottom of image, need a whole row of dummy blocks */ 334 /* At bottom of image, need a whole row of dummy blocks */
332 » xindex = 0; 335 xindex = 0;
333 » } 336 }
334 » /* Fill in any dummy blocks needed in this row. 337 /* Fill in any dummy blocks needed in this row.
335 » * Dummy blocks are filled in the same way as in jccoefct.c: 338 * Dummy blocks are filled in the same way as in jccoefct.c:
336 » * all zeroes in the AC entries, DC entries equal to previous 339 * all zeroes in the AC entries, DC entries equal to previous
337 » * block's DC value. The init routine has already zeroed the 340 * block's DC value. The init routine has already zeroed the
338 » * AC entries, so we need only set the DC entries correctly. 341 * AC entries, so we need only set the DC entries correctly.
339 » */ 342 */
340 » for (; xindex < compptr->MCU_width; xindex++) { 343 for (; xindex < compptr->MCU_width; xindex++) {
341 » MCU_buffer[blkn] = coef->dummy_buffer[blkn]; 344 MCU_buffer[blkn] = coef->dummy_buffer[blkn];
342 » MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0]; 345 MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0];
343 » blkn++; 346 blkn++;
344 » } 347 }
345 » } 348 }
346 } 349 }
347 /* Try to write the MCU. */ 350 /* Try to write the MCU. */
348 if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) { 351 if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
349 » /* Suspension forced; update state counters and exit */ 352 /* Suspension forced; update state counters and exit */
350 » coef->MCU_vert_offset = yoffset; 353 coef->MCU_vert_offset = yoffset;
351 » coef->mcu_ctr = MCU_col_num; 354 coef->mcu_ctr = MCU_col_num;
352 » return FALSE; 355 return FALSE;
353 } 356 }
354 } 357 }
355 /* Completed an MCU row, but perhaps not an iMCU row */ 358 /* Completed an MCU row, but perhaps not an iMCU row */
356 coef->mcu_ctr = 0; 359 coef->mcu_ctr = 0;
357 } 360 }
358 /* Completed the iMCU row, advance counters for next one */ 361 /* Completed the iMCU row, advance counters for next one */
359 coef->iMCU_row_num++; 362 coef->iMCU_row_num++;
360 start_iMCU_row(cinfo); 363 start_iMCU_row(cinfo);
361 return TRUE; 364 return TRUE;
362 } 365 }
363 366
364 367
365 /* 368 /*
366 * Initialize coefficient buffer controller. 369 * Initialize coefficient buffer controller.
367 * 370 *
368 * Each passed coefficient array must be the right size for that 371 * Each passed coefficient array must be the right size for that
369 * coefficient: width_in_blocks wide and height_in_blocks high, 372 * coefficient: width_in_blocks wide and height_in_blocks high,
370 * with unitheight at least v_samp_factor. 373 * with unitheight at least v_samp_factor.
371 */ 374 */
372 375
373 LOCAL(void) 376 LOCAL(void)
374 transencode_coef_controller (j_compress_ptr cinfo, 377 transencode_coef_controller (j_compress_ptr cinfo,
375 » » » jvirt_barray_ptr * coef_arrays) 378 jvirt_barray_ptr *coef_arrays)
376 { 379 {
377 my_coef_ptr coef; 380 my_coef_ptr coef;
378 JBLOCKROW buffer; 381 JBLOCKROW buffer;
379 int i; 382 int i;
380 383
381 coef = (my_coef_ptr) 384 coef = (my_coef_ptr)
382 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 385 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
383 » » » » SIZEOF(my_coef_controller)); 386 sizeof(my_coef_controller));
384 cinfo->coef = (struct jpeg_c_coef_controller *) coef; 387 cinfo->coef = (struct jpeg_c_coef_controller *) coef;
385 coef->pub.start_pass = start_pass_coef; 388 coef->pub.start_pass = start_pass_coef;
386 coef->pub.compress_data = compress_output; 389 coef->pub.compress_data = compress_output;
387 390
388 /* Save pointer to virtual arrays */ 391 /* Save pointer to virtual arrays */
389 coef->whole_image = coef_arrays; 392 coef->whole_image = coef_arrays;
390 393
391 /* Allocate and pre-zero space for dummy DCT blocks. */ 394 /* Allocate and pre-zero space for dummy DCT blocks. */
392 buffer = (JBLOCKROW) 395 buffer = (JBLOCKROW)
393 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, 396 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
394 » » » » C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); 397 C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
395 jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); 398 jzero_far((void *) buffer, C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
396 for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { 399 for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
397 coef->dummy_buffer[i] = buffer + i; 400 coef->dummy_buffer[i] = buffer + i;
398 } 401 }
399 } 402 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698