rev |
line source |
nuclear@0
|
1 /*
|
nuclear@0
|
2 * jdcoefct.c
|
nuclear@0
|
3 *
|
nuclear@0
|
4 * Copyright (C) 1994-1997, Thomas G. Lane.
|
nuclear@0
|
5 * This file is part of the Independent JPEG Group's software.
|
nuclear@0
|
6 * For conditions of distribution and use, see the accompanying README file.
|
nuclear@0
|
7 *
|
nuclear@0
|
8 * This file contains the coefficient buffer controller for decompression.
|
nuclear@0
|
9 * This controller is the top level of the JPEG decompressor proper.
|
nuclear@0
|
10 * The coefficient buffer lies between entropy decoding and inverse-DCT steps.
|
nuclear@0
|
11 *
|
nuclear@0
|
12 * In buffered-image mode, this controller is the interface between
|
nuclear@0
|
13 * input-oriented processing and output-oriented processing.
|
nuclear@0
|
14 * Also, the input side (only) is used when reading a file for transcoding.
|
nuclear@0
|
15 */
|
nuclear@0
|
16
|
nuclear@0
|
17 #define JPEG_INTERNALS
|
nuclear@0
|
18 #include "jinclude.h"
|
nuclear@0
|
19 #include "jpeglib.h"
|
nuclear@0
|
20
|
nuclear@0
|
21 /* Block smoothing is only applicable for progressive JPEG, so: */
|
nuclear@0
|
22 #ifndef D_PROGRESSIVE_SUPPORTED
|
nuclear@0
|
23 #undef BLOCK_SMOOTHING_SUPPORTED
|
nuclear@0
|
24 #endif
|
nuclear@0
|
25
|
nuclear@0
|
26 /* Private buffer controller object */
|
nuclear@0
|
27
|
nuclear@0
|
28 typedef struct {
|
nuclear@0
|
29 struct jpeg_d_coef_controller pub; /* public fields */
|
nuclear@0
|
30
|
nuclear@0
|
31 /* These variables keep track of the current location of the input side. */
|
nuclear@0
|
32 /* cinfo->input_iMCU_row is also used for this. */
|
nuclear@0
|
33 JDIMENSION MCU_ctr; /* counts MCUs processed in current row */
|
nuclear@0
|
34 int MCU_vert_offset; /* counts MCU rows within iMCU row */
|
nuclear@0
|
35 int MCU_rows_per_iMCU_row; /* number of such rows needed */
|
nuclear@0
|
36
|
nuclear@0
|
37 /* The output side's location is represented by cinfo->output_iMCU_row. */
|
nuclear@0
|
38
|
nuclear@0
|
39 /* In single-pass modes, it's sufficient to buffer just one MCU.
|
nuclear@0
|
40 * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,
|
nuclear@0
|
41 * and let the entropy decoder write into that workspace each time.
|
nuclear@0
|
42 * (On 80x86, the workspace is FAR even though it's not really very big;
|
nuclear@0
|
43 * this is to keep the module interfaces unchanged when a large coefficient
|
nuclear@0
|
44 * buffer is necessary.)
|
nuclear@0
|
45 * In multi-pass modes, this array points to the current MCU's blocks
|
nuclear@0
|
46 * within the virtual arrays; it is used only by the input side.
|
nuclear@0
|
47 */
|
nuclear@0
|
48 JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU];
|
nuclear@0
|
49
|
nuclear@0
|
50 #ifdef D_MULTISCAN_FILES_SUPPORTED
|
nuclear@0
|
51 /* In multi-pass modes, we need a virtual block array for each component. */
|
nuclear@0
|
52 jvirt_barray_ptr whole_image[MAX_COMPONENTS];
|
nuclear@0
|
53 #endif
|
nuclear@0
|
54
|
nuclear@0
|
55 #ifdef BLOCK_SMOOTHING_SUPPORTED
|
nuclear@0
|
56 /* When doing block smoothing, we latch coefficient Al values here */
|
nuclear@0
|
57 int * coef_bits_latch;
|
nuclear@0
|
58 #define SAVED_COEFS 6 /* we save coef_bits[0..5] */
|
nuclear@0
|
59 #endif
|
nuclear@0
|
60 } my_coef_controller;
|
nuclear@0
|
61
|
nuclear@0
|
62 typedef my_coef_controller * my_coef_ptr;
|
nuclear@0
|
63
|
nuclear@0
|
64 /* Forward declarations */
|
nuclear@0
|
65 METHODDEF(int) decompress_onepass
|
nuclear@0
|
66 JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
|
nuclear@0
|
67 #ifdef D_MULTISCAN_FILES_SUPPORTED
|
nuclear@0
|
68 METHODDEF(int) decompress_data
|
nuclear@0
|
69 JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
|
nuclear@0
|
70 #endif
|
nuclear@0
|
71 #ifdef BLOCK_SMOOTHING_SUPPORTED
|
nuclear@0
|
72 LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo));
|
nuclear@0
|
73 METHODDEF(int) decompress_smooth_data
|
nuclear@0
|
74 JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
|
nuclear@0
|
75 #endif
|
nuclear@0
|
76
|
nuclear@0
|
77
|
nuclear@0
|
78 LOCAL(void)
|
nuclear@0
|
79 start_iMCU_row (j_decompress_ptr cinfo)
|
nuclear@0
|
80 /* Reset within-iMCU-row counters for a new row (input side) */
|
nuclear@0
|
81 {
|
nuclear@0
|
82 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
nuclear@0
|
83
|
nuclear@0
|
84 /* In an interleaved scan, an MCU row is the same as an iMCU row.
|
nuclear@0
|
85 * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
|
nuclear@0
|
86 * But at the bottom of the image, process only what's left.
|
nuclear@0
|
87 */
|
nuclear@0
|
88 if (cinfo->comps_in_scan > 1) {
|
nuclear@0
|
89 coef->MCU_rows_per_iMCU_row = 1;
|
nuclear@0
|
90 } else {
|
nuclear@0
|
91 if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1))
|
nuclear@0
|
92 coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
|
nuclear@0
|
93 else
|
nuclear@0
|
94 coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
nuclear@0
|
95 }
|
nuclear@0
|
96
|
nuclear@0
|
97 coef->MCU_ctr = 0;
|
nuclear@0
|
98 coef->MCU_vert_offset = 0;
|
nuclear@0
|
99 }
|
nuclear@0
|
100
|
nuclear@0
|
101
|
nuclear@0
|
102 /*
|
nuclear@0
|
103 * Initialize for an input processing pass.
|
nuclear@0
|
104 */
|
nuclear@0
|
105
|
nuclear@0
|
106 METHODDEF(void)
|
nuclear@0
|
107 start_input_pass (j_decompress_ptr cinfo)
|
nuclear@0
|
108 {
|
nuclear@0
|
109 cinfo->input_iMCU_row = 0;
|
nuclear@0
|
110 start_iMCU_row(cinfo);
|
nuclear@0
|
111 }
|
nuclear@0
|
112
|
nuclear@0
|
113
|
nuclear@0
|
114 /*
|
nuclear@0
|
115 * Initialize for an output processing pass.
|
nuclear@0
|
116 */
|
nuclear@0
|
117
|
nuclear@0
|
118 METHODDEF(void)
|
nuclear@0
|
119 start_output_pass (j_decompress_ptr cinfo)
|
nuclear@0
|
120 {
|
nuclear@0
|
121 #ifdef BLOCK_SMOOTHING_SUPPORTED
|
nuclear@0
|
122 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
nuclear@0
|
123
|
nuclear@0
|
124 /* If multipass, check to see whether to use block smoothing on this pass */
|
nuclear@0
|
125 if (coef->pub.coef_arrays != NULL) {
|
nuclear@0
|
126 if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
|
nuclear@0
|
127 coef->pub.decompress_data = decompress_smooth_data;
|
nuclear@0
|
128 else
|
nuclear@0
|
129 coef->pub.decompress_data = decompress_data;
|
nuclear@0
|
130 }
|
nuclear@0
|
131 #endif
|
nuclear@0
|
132 cinfo->output_iMCU_row = 0;
|
nuclear@0
|
133 }
|
nuclear@0
|
134
|
nuclear@0
|
135
|
nuclear@0
|
136 /*
|
nuclear@0
|
137 * Decompress and return some data in the single-pass case.
|
nuclear@0
|
138 * Always attempts to emit one fully interleaved MCU row ("iMCU" row).
|
nuclear@0
|
139 * Input and output must run in lockstep since we have only a one-MCU buffer.
|
nuclear@0
|
140 * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
|
nuclear@0
|
141 *
|
nuclear@0
|
142 * NB: output_buf contains a plane for each component in image,
|
nuclear@0
|
143 * which we index according to the component's SOF position.
|
nuclear@0
|
144 */
|
nuclear@0
|
145
|
nuclear@0
|
146 METHODDEF(int)
|
nuclear@0
|
147 decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
nuclear@0
|
148 {
|
nuclear@0
|
149 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
nuclear@0
|
150 JDIMENSION MCU_col_num; /* index of current MCU within row */
|
nuclear@0
|
151 JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
nuclear@0
|
152 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
nuclear@0
|
153 int blkn, ci, xindex, yindex, yoffset, useful_width;
|
nuclear@0
|
154 JSAMPARRAY output_ptr;
|
nuclear@0
|
155 JDIMENSION start_col, output_col;
|
nuclear@0
|
156 jpeg_component_info *compptr;
|
nuclear@0
|
157 inverse_DCT_method_ptr inverse_DCT;
|
nuclear@0
|
158
|
nuclear@0
|
159 /* Loop to process as much as one whole iMCU row */
|
nuclear@0
|
160 for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
|
nuclear@0
|
161 yoffset++) {
|
nuclear@0
|
162 for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
|
nuclear@0
|
163 MCU_col_num++) {
|
nuclear@0
|
164 /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
|
nuclear@0
|
165 jzero_far((void FAR *) coef->MCU_buffer[0],
|
nuclear@0
|
166 (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));
|
nuclear@0
|
167 if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
nuclear@0
|
168 /* Suspension forced; update state counters and exit */
|
nuclear@0
|
169 coef->MCU_vert_offset = yoffset;
|
nuclear@0
|
170 coef->MCU_ctr = MCU_col_num;
|
nuclear@0
|
171 return JPEG_SUSPENDED;
|
nuclear@0
|
172 }
|
nuclear@0
|
173 /* Determine where data should go in output_buf and do the IDCT thing.
|
nuclear@0
|
174 * We skip dummy blocks at the right and bottom edges (but blkn gets
|
nuclear@0
|
175 * incremented past them!). Note the inner loop relies on having
|
nuclear@0
|
176 * allocated the MCU_buffer[] blocks sequentially.
|
nuclear@0
|
177 */
|
nuclear@0
|
178 blkn = 0; /* index of current DCT block within MCU */
|
nuclear@0
|
179 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
nuclear@0
|
180 compptr = cinfo->cur_comp_info[ci];
|
nuclear@0
|
181 /* Don't bother to IDCT an uninteresting component. */
|
nuclear@0
|
182 if (! compptr->component_needed) {
|
nuclear@0
|
183 blkn += compptr->MCU_blocks;
|
nuclear@0
|
184 continue;
|
nuclear@0
|
185 }
|
nuclear@0
|
186 inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
|
nuclear@0
|
187 useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
nuclear@0
|
188 : compptr->last_col_width;
|
nuclear@0
|
189 output_ptr = output_buf[compptr->component_index] +
|
nuclear@0
|
190 yoffset * compptr->DCT_scaled_size;
|
nuclear@0
|
191 start_col = MCU_col_num * compptr->MCU_sample_width;
|
nuclear@0
|
192 for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
nuclear@0
|
193 if (cinfo->input_iMCU_row < last_iMCU_row ||
|
nuclear@0
|
194 yoffset+yindex < compptr->last_row_height) {
|
nuclear@0
|
195 output_col = start_col;
|
nuclear@0
|
196 for (xindex = 0; xindex < useful_width; xindex++) {
|
nuclear@0
|
197 (*inverse_DCT) (cinfo, compptr,
|
nuclear@0
|
198 (JCOEFPTR) coef->MCU_buffer[blkn+xindex],
|
nuclear@0
|
199 output_ptr, output_col);
|
nuclear@0
|
200 output_col += compptr->DCT_scaled_size;
|
nuclear@0
|
201 }
|
nuclear@0
|
202 }
|
nuclear@0
|
203 blkn += compptr->MCU_width;
|
nuclear@0
|
204 output_ptr += compptr->DCT_scaled_size;
|
nuclear@0
|
205 }
|
nuclear@0
|
206 }
|
nuclear@0
|
207 }
|
nuclear@0
|
208 /* Completed an MCU row, but perhaps not an iMCU row */
|
nuclear@0
|
209 coef->MCU_ctr = 0;
|
nuclear@0
|
210 }
|
nuclear@0
|
211 /* Completed the iMCU row, advance counters for next one */
|
nuclear@0
|
212 cinfo->output_iMCU_row++;
|
nuclear@0
|
213 if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
|
nuclear@0
|
214 start_iMCU_row(cinfo);
|
nuclear@0
|
215 return JPEG_ROW_COMPLETED;
|
nuclear@0
|
216 }
|
nuclear@0
|
217 /* Completed the scan */
|
nuclear@0
|
218 (*cinfo->inputctl->finish_input_pass) (cinfo);
|
nuclear@0
|
219 return JPEG_SCAN_COMPLETED;
|
nuclear@0
|
220 }
|
nuclear@0
|
221
|
nuclear@0
|
222
|
nuclear@0
|
223 /*
|
nuclear@0
|
224 * Dummy consume-input routine for single-pass operation.
|
nuclear@0
|
225 */
|
nuclear@0
|
226
|
nuclear@0
|
227 METHODDEF(int)
|
nuclear@0
|
228 dummy_consume_data (j_decompress_ptr cinfo)
|
nuclear@0
|
229 {
|
nuclear@0
|
230 return JPEG_SUSPENDED; /* Always indicate nothing was done */
|
nuclear@0
|
231 }
|
nuclear@0
|
232
|
nuclear@0
|
233
|
nuclear@0
|
234 #ifdef D_MULTISCAN_FILES_SUPPORTED
|
nuclear@0
|
235
|
nuclear@0
|
236 /*
|
nuclear@0
|
237 * Consume input data and store it in the full-image coefficient buffer.
|
nuclear@0
|
238 * We read as much as one fully interleaved MCU row ("iMCU" row) per call,
|
nuclear@0
|
239 * ie, v_samp_factor block rows for each component in the scan.
|
nuclear@0
|
240 * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
|
nuclear@0
|
241 */
|
nuclear@0
|
242
|
nuclear@0
|
243 METHODDEF(int)
|
nuclear@0
|
244 consume_data (j_decompress_ptr cinfo)
|
nuclear@0
|
245 {
|
nuclear@0
|
246 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
nuclear@0
|
247 JDIMENSION MCU_col_num; /* index of current MCU within row */
|
nuclear@0
|
248 int blkn, ci, xindex, yindex, yoffset;
|
nuclear@0
|
249 JDIMENSION start_col;
|
nuclear@0
|
250 JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
|
nuclear@0
|
251 JBLOCKROW buffer_ptr;
|
nuclear@0
|
252 jpeg_component_info *compptr;
|
nuclear@0
|
253
|
nuclear@0
|
254 /* Align the virtual buffers for the components used in this scan. */
|
nuclear@0
|
255 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
nuclear@0
|
256 compptr = cinfo->cur_comp_info[ci];
|
nuclear@0
|
257 buffer[ci] = (*cinfo->mem->access_virt_barray)
|
nuclear@0
|
258 ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
|
nuclear@0
|
259 cinfo->input_iMCU_row * compptr->v_samp_factor,
|
nuclear@0
|
260 (JDIMENSION) compptr->v_samp_factor, TRUE);
|
nuclear@0
|
261 /* Note: entropy decoder expects buffer to be zeroed,
|
nuclear@0
|
262 * but this is handled automatically by the memory manager
|
nuclear@0
|
263 * because we requested a pre-zeroed array.
|
nuclear@0
|
264 */
|
nuclear@0
|
265 }
|
nuclear@0
|
266
|
nuclear@0
|
267 /* Loop to process one whole iMCU row */
|
nuclear@0
|
268 for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
|
nuclear@0
|
269 yoffset++) {
|
nuclear@0
|
270 for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
|
nuclear@0
|
271 MCU_col_num++) {
|
nuclear@0
|
272 /* Construct list of pointers to DCT blocks belonging to this MCU */
|
nuclear@0
|
273 blkn = 0; /* index of current DCT block within MCU */
|
nuclear@0
|
274 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
nuclear@0
|
275 compptr = cinfo->cur_comp_info[ci];
|
nuclear@0
|
276 start_col = MCU_col_num * compptr->MCU_width;
|
nuclear@0
|
277 for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
nuclear@0
|
278 buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
nuclear@0
|
279 for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
|
nuclear@0
|
280 coef->MCU_buffer[blkn++] = buffer_ptr++;
|
nuclear@0
|
281 }
|
nuclear@0
|
282 }
|
nuclear@0
|
283 }
|
nuclear@0
|
284 /* Try to fetch the MCU. */
|
nuclear@0
|
285 if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
nuclear@0
|
286 /* Suspension forced; update state counters and exit */
|
nuclear@0
|
287 coef->MCU_vert_offset = yoffset;
|
nuclear@0
|
288 coef->MCU_ctr = MCU_col_num;
|
nuclear@0
|
289 return JPEG_SUSPENDED;
|
nuclear@0
|
290 }
|
nuclear@0
|
291 }
|
nuclear@0
|
292 /* Completed an MCU row, but perhaps not an iMCU row */
|
nuclear@0
|
293 coef->MCU_ctr = 0;
|
nuclear@0
|
294 }
|
nuclear@0
|
295 /* Completed the iMCU row, advance counters for next one */
|
nuclear@0
|
296 if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
|
nuclear@0
|
297 start_iMCU_row(cinfo);
|
nuclear@0
|
298 return JPEG_ROW_COMPLETED;
|
nuclear@0
|
299 }
|
nuclear@0
|
300 /* Completed the scan */
|
nuclear@0
|
301 (*cinfo->inputctl->finish_input_pass) (cinfo);
|
nuclear@0
|
302 return JPEG_SCAN_COMPLETED;
|
nuclear@0
|
303 }
|
nuclear@0
|
304
|
nuclear@0
|
305
|
nuclear@0
|
306 /*
|
nuclear@0
|
307 * Decompress and return some data in the multi-pass case.
|
nuclear@0
|
308 * Always attempts to emit one fully interleaved MCU row ("iMCU" row).
|
nuclear@0
|
309 * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
|
nuclear@0
|
310 *
|
nuclear@0
|
311 * NB: output_buf contains a plane for each component in image.
|
nuclear@0
|
312 */
|
nuclear@0
|
313
|
nuclear@0
|
314 METHODDEF(int)
|
nuclear@0
|
315 decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
nuclear@0
|
316 {
|
nuclear@0
|
317 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
nuclear@0
|
318 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
nuclear@0
|
319 JDIMENSION block_num;
|
nuclear@0
|
320 int ci, block_row, block_rows;
|
nuclear@0
|
321 JBLOCKARRAY buffer;
|
nuclear@0
|
322 JBLOCKROW buffer_ptr;
|
nuclear@0
|
323 JSAMPARRAY output_ptr;
|
nuclear@0
|
324 JDIMENSION output_col;
|
nuclear@0
|
325 jpeg_component_info *compptr;
|
nuclear@0
|
326 inverse_DCT_method_ptr inverse_DCT;
|
nuclear@0
|
327
|
nuclear@0
|
328 /* Force some input to be done if we are getting ahead of the input. */
|
nuclear@0
|
329 while (cinfo->input_scan_number < cinfo->output_scan_number ||
|
nuclear@0
|
330 (cinfo->input_scan_number == cinfo->output_scan_number &&
|
nuclear@0
|
331 cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
|
nuclear@0
|
332 if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
|
nuclear@0
|
333 return JPEG_SUSPENDED;
|
nuclear@0
|
334 }
|
nuclear@0
|
335
|
nuclear@0
|
336 /* OK, output from the virtual arrays. */
|
nuclear@0
|
337 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
nuclear@0
|
338 ci++, compptr++) {
|
nuclear@0
|
339 /* Don't bother to IDCT an uninteresting component. */
|
nuclear@0
|
340 if (! compptr->component_needed)
|
nuclear@0
|
341 continue;
|
nuclear@0
|
342 /* Align the virtual buffer for this component. */
|
nuclear@0
|
343 buffer = (*cinfo->mem->access_virt_barray)
|
nuclear@0
|
344 ((j_common_ptr) cinfo, coef->whole_image[ci],
|
nuclear@0
|
345 cinfo->output_iMCU_row * compptr->v_samp_factor,
|
nuclear@0
|
346 (JDIMENSION) compptr->v_samp_factor, FALSE);
|
nuclear@0
|
347 /* Count non-dummy DCT block rows in this iMCU row. */
|
nuclear@0
|
348 if (cinfo->output_iMCU_row < last_iMCU_row)
|
nuclear@0
|
349 block_rows = compptr->v_samp_factor;
|
nuclear@0
|
350 else {
|
nuclear@0
|
351 /* NB: can't use last_row_height here; it is input-side-dependent! */
|
nuclear@0
|
352 block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
nuclear@0
|
353 if (block_rows == 0) block_rows = compptr->v_samp_factor;
|
nuclear@0
|
354 }
|
nuclear@0
|
355 inverse_DCT = cinfo->idct->inverse_DCT[ci];
|
nuclear@0
|
356 output_ptr = output_buf[ci];
|
nuclear@0
|
357 /* Loop over all DCT blocks to be processed. */
|
nuclear@0
|
358 for (block_row = 0; block_row < block_rows; block_row++) {
|
nuclear@0
|
359 buffer_ptr = buffer[block_row];
|
nuclear@0
|
360 output_col = 0;
|
nuclear@0
|
361 for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) {
|
nuclear@0
|
362 (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,
|
nuclear@0
|
363 output_ptr, output_col);
|
nuclear@0
|
364 buffer_ptr++;
|
nuclear@0
|
365 output_col += compptr->DCT_scaled_size;
|
nuclear@0
|
366 }
|
nuclear@0
|
367 output_ptr += compptr->DCT_scaled_size;
|
nuclear@0
|
368 }
|
nuclear@0
|
369 }
|
nuclear@0
|
370
|
nuclear@0
|
371 if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
|
nuclear@0
|
372 return JPEG_ROW_COMPLETED;
|
nuclear@0
|
373 return JPEG_SCAN_COMPLETED;
|
nuclear@0
|
374 }
|
nuclear@0
|
375
|
nuclear@0
|
376 #endif /* D_MULTISCAN_FILES_SUPPORTED */
|
nuclear@0
|
377
|
nuclear@0
|
378
|
nuclear@0
|
379 #ifdef BLOCK_SMOOTHING_SUPPORTED
|
nuclear@0
|
380
|
nuclear@0
|
381 /*
|
nuclear@0
|
382 * This code applies interblock smoothing as described by section K.8
|
nuclear@0
|
383 * of the JPEG standard: the first 5 AC coefficients are estimated from
|
nuclear@0
|
384 * the DC values of a DCT block and its 8 neighboring blocks.
|
nuclear@0
|
385 * We apply smoothing only for progressive JPEG decoding, and only if
|
nuclear@0
|
386 * the coefficients it can estimate are not yet known to full precision.
|
nuclear@0
|
387 */
|
nuclear@0
|
388
|
nuclear@0
|
389 /* Natural-order array positions of the first 5 zigzag-order coefficients */
|
nuclear@0
|
390 #define Q01_POS 1
|
nuclear@0
|
391 #define Q10_POS 8
|
nuclear@0
|
392 #define Q20_POS 16
|
nuclear@0
|
393 #define Q11_POS 9
|
nuclear@0
|
394 #define Q02_POS 2
|
nuclear@0
|
395
|
nuclear@0
|
396 /*
|
nuclear@0
|
397 * Determine whether block smoothing is applicable and safe.
|
nuclear@0
|
398 * We also latch the current states of the coef_bits[] entries for the
|
nuclear@0
|
399 * AC coefficients; otherwise, if the input side of the decompressor
|
nuclear@0
|
400 * advances into a new scan, we might think the coefficients are known
|
nuclear@0
|
401 * more accurately than they really are.
|
nuclear@0
|
402 */
|
nuclear@0
|
403
|
nuclear@0
|
404 LOCAL(boolean)
|
nuclear@0
|
405 smoothing_ok (j_decompress_ptr cinfo)
|
nuclear@0
|
406 {
|
nuclear@0
|
407 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
nuclear@0
|
408 boolean smoothing_useful = FALSE;
|
nuclear@0
|
409 int ci, coefi;
|
nuclear@0
|
410 jpeg_component_info *compptr;
|
nuclear@0
|
411 JQUANT_TBL * qtable;
|
nuclear@0
|
412 int * coef_bits;
|
nuclear@0
|
413 int * coef_bits_latch;
|
nuclear@0
|
414
|
nuclear@0
|
415 if (! cinfo->progressive_mode || cinfo->coef_bits == NULL)
|
nuclear@0
|
416 return FALSE;
|
nuclear@0
|
417
|
nuclear@0
|
418 /* Allocate latch area if not already done */
|
nuclear@0
|
419 if (coef->coef_bits_latch == NULL)
|
nuclear@0
|
420 coef->coef_bits_latch = (int *)
|
nuclear@0
|
421 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
nuclear@0
|
422 cinfo->num_components *
|
nuclear@0
|
423 (SAVED_COEFS * SIZEOF(int)));
|
nuclear@0
|
424 coef_bits_latch = coef->coef_bits_latch;
|
nuclear@0
|
425
|
nuclear@0
|
426 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
nuclear@0
|
427 ci++, compptr++) {
|
nuclear@0
|
428 /* All components' quantization values must already be latched. */
|
nuclear@0
|
429 if ((qtable = compptr->quant_table) == NULL)
|
nuclear@0
|
430 return FALSE;
|
nuclear@0
|
431 /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */
|
nuclear@0
|
432 if (qtable->quantval[0] == 0 ||
|
nuclear@0
|
433 qtable->quantval[Q01_POS] == 0 ||
|
nuclear@0
|
434 qtable->quantval[Q10_POS] == 0 ||
|
nuclear@0
|
435 qtable->quantval[Q20_POS] == 0 ||
|
nuclear@0
|
436 qtable->quantval[Q11_POS] == 0 ||
|
nuclear@0
|
437 qtable->quantval[Q02_POS] == 0)
|
nuclear@0
|
438 return FALSE;
|
nuclear@0
|
439 /* DC values must be at least partly known for all components. */
|
nuclear@0
|
440 coef_bits = cinfo->coef_bits[ci];
|
nuclear@0
|
441 if (coef_bits[0] < 0)
|
nuclear@0
|
442 return FALSE;
|
nuclear@0
|
443 /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
|
nuclear@0
|
444 for (coefi = 1; coefi <= 5; coefi++) {
|
nuclear@0
|
445 coef_bits_latch[coefi] = coef_bits[coefi];
|
nuclear@0
|
446 if (coef_bits[coefi] != 0)
|
nuclear@0
|
447 smoothing_useful = TRUE;
|
nuclear@0
|
448 }
|
nuclear@0
|
449 coef_bits_latch += SAVED_COEFS;
|
nuclear@0
|
450 }
|
nuclear@0
|
451
|
nuclear@0
|
452 return smoothing_useful;
|
nuclear@0
|
453 }
|
nuclear@0
|
454
|
nuclear@0
|
455
|
nuclear@0
|
456 /*
|
nuclear@0
|
457 * Variant of decompress_data for use when doing block smoothing.
|
nuclear@0
|
458 */
|
nuclear@0
|
459
|
nuclear@0
|
460 METHODDEF(int)
|
nuclear@0
|
461 decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
nuclear@0
|
462 {
|
nuclear@0
|
463 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
nuclear@0
|
464 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
nuclear@0
|
465 JDIMENSION block_num, last_block_column;
|
nuclear@0
|
466 int ci, block_row, block_rows, access_rows;
|
nuclear@0
|
467 JBLOCKARRAY buffer;
|
nuclear@0
|
468 JBLOCKROW buffer_ptr, prev_block_row, next_block_row;
|
nuclear@0
|
469 JSAMPARRAY output_ptr;
|
nuclear@0
|
470 JDIMENSION output_col;
|
nuclear@0
|
471 jpeg_component_info *compptr;
|
nuclear@0
|
472 inverse_DCT_method_ptr inverse_DCT;
|
nuclear@0
|
473 boolean first_row, last_row;
|
nuclear@0
|
474 JBLOCK workspace;
|
nuclear@0
|
475 int *coef_bits;
|
nuclear@0
|
476 JQUANT_TBL *quanttbl;
|
nuclear@0
|
477 INT32 Q00,Q01,Q02,Q10,Q11,Q20, num;
|
nuclear@0
|
478 int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;
|
nuclear@0
|
479 int Al, pred;
|
nuclear@0
|
480
|
nuclear@0
|
481 /* Force some input to be done if we are getting ahead of the input. */
|
nuclear@0
|
482 while (cinfo->input_scan_number <= cinfo->output_scan_number &&
|
nuclear@0
|
483 ! cinfo->inputctl->eoi_reached) {
|
nuclear@0
|
484 if (cinfo->input_scan_number == cinfo->output_scan_number) {
|
nuclear@0
|
485 /* If input is working on current scan, we ordinarily want it to
|
nuclear@0
|
486 * have completed the current row. But if input scan is DC,
|
nuclear@0
|
487 * we want it to keep one row ahead so that next block row's DC
|
nuclear@0
|
488 * values are up to date.
|
nuclear@0
|
489 */
|
nuclear@0
|
490 JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0;
|
nuclear@0
|
491 if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta)
|
nuclear@0
|
492 break;
|
nuclear@0
|
493 }
|
nuclear@0
|
494 if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
|
nuclear@0
|
495 return JPEG_SUSPENDED;
|
nuclear@0
|
496 }
|
nuclear@0
|
497
|
nuclear@0
|
498 /* OK, output from the virtual arrays. */
|
nuclear@0
|
499 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
nuclear@0
|
500 ci++, compptr++) {
|
nuclear@0
|
501 /* Don't bother to IDCT an uninteresting component. */
|
nuclear@0
|
502 if (! compptr->component_needed)
|
nuclear@0
|
503 continue;
|
nuclear@0
|
504 /* Count non-dummy DCT block rows in this iMCU row. */
|
nuclear@0
|
505 if (cinfo->output_iMCU_row < last_iMCU_row) {
|
nuclear@0
|
506 block_rows = compptr->v_samp_factor;
|
nuclear@0
|
507 access_rows = block_rows * 2; /* this and next iMCU row */
|
nuclear@0
|
508 last_row = FALSE;
|
nuclear@0
|
509 } else {
|
nuclear@0
|
510 /* NB: can't use last_row_height here; it is input-side-dependent! */
|
nuclear@0
|
511 block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
nuclear@0
|
512 if (block_rows == 0) block_rows = compptr->v_samp_factor;
|
nuclear@0
|
513 access_rows = block_rows; /* this iMCU row only */
|
nuclear@0
|
514 last_row = TRUE;
|
nuclear@0
|
515 }
|
nuclear@0
|
516 /* Align the virtual buffer for this component. */
|
nuclear@0
|
517 if (cinfo->output_iMCU_row > 0) {
|
nuclear@0
|
518 access_rows += compptr->v_samp_factor; /* prior iMCU row too */
|
nuclear@0
|
519 buffer = (*cinfo->mem->access_virt_barray)
|
nuclear@0
|
520 ((j_common_ptr) cinfo, coef->whole_image[ci],
|
nuclear@0
|
521 (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
|
nuclear@0
|
522 (JDIMENSION) access_rows, FALSE);
|
nuclear@0
|
523 buffer += compptr->v_samp_factor; /* point to current iMCU row */
|
nuclear@0
|
524 first_row = FALSE;
|
nuclear@0
|
525 } else {
|
nuclear@0
|
526 buffer = (*cinfo->mem->access_virt_barray)
|
nuclear@0
|
527 ((j_common_ptr) cinfo, coef->whole_image[ci],
|
nuclear@0
|
528 (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE);
|
nuclear@0
|
529 first_row = TRUE;
|
nuclear@0
|
530 }
|
nuclear@0
|
531 /* Fetch component-dependent info */
|
nuclear@0
|
532 coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
|
nuclear@0
|
533 quanttbl = compptr->quant_table;
|
nuclear@0
|
534 Q00 = quanttbl->quantval[0];
|
nuclear@0
|
535 Q01 = quanttbl->quantval[Q01_POS];
|
nuclear@0
|
536 Q10 = quanttbl->quantval[Q10_POS];
|
nuclear@0
|
537 Q20 = quanttbl->quantval[Q20_POS];
|
nuclear@0
|
538 Q11 = quanttbl->quantval[Q11_POS];
|
nuclear@0
|
539 Q02 = quanttbl->quantval[Q02_POS];
|
nuclear@0
|
540 inverse_DCT = cinfo->idct->inverse_DCT[ci];
|
nuclear@0
|
541 output_ptr = output_buf[ci];
|
nuclear@0
|
542 /* Loop over all DCT blocks to be processed. */
|
nuclear@0
|
543 for (block_row = 0; block_row < block_rows; block_row++) {
|
nuclear@0
|
544 buffer_ptr = buffer[block_row];
|
nuclear@0
|
545 if (first_row && block_row == 0)
|
nuclear@0
|
546 prev_block_row = buffer_ptr;
|
nuclear@0
|
547 else
|
nuclear@0
|
548 prev_block_row = buffer[block_row-1];
|
nuclear@0
|
549 if (last_row && block_row == block_rows-1)
|
nuclear@0
|
550 next_block_row = buffer_ptr;
|
nuclear@0
|
551 else
|
nuclear@0
|
552 next_block_row = buffer[block_row+1];
|
nuclear@0
|
553 /* We fetch the surrounding DC values using a sliding-register approach.
|
nuclear@0
|
554 * Initialize all nine here so as to do the right thing on narrow pics.
|
nuclear@0
|
555 */
|
nuclear@0
|
556 DC1 = DC2 = DC3 = (int) prev_block_row[0][0];
|
nuclear@0
|
557 DC4 = DC5 = DC6 = (int) buffer_ptr[0][0];
|
nuclear@0
|
558 DC7 = DC8 = DC9 = (int) next_block_row[0][0];
|
nuclear@0
|
559 output_col = 0;
|
nuclear@0
|
560 last_block_column = compptr->width_in_blocks - 1;
|
nuclear@0
|
561 for (block_num = 0; block_num <= last_block_column; block_num++) {
|
nuclear@0
|
562 /* Fetch current DCT block into workspace so we can modify it. */
|
nuclear@0
|
563 jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1);
|
nuclear@0
|
564 /* Update DC values */
|
nuclear@0
|
565 if (block_num < last_block_column) {
|
nuclear@0
|
566 DC3 = (int) prev_block_row[1][0];
|
nuclear@0
|
567 DC6 = (int) buffer_ptr[1][0];
|
nuclear@0
|
568 DC9 = (int) next_block_row[1][0];
|
nuclear@0
|
569 }
|
nuclear@0
|
570 /* Compute coefficient estimates per K.8.
|
nuclear@0
|
571 * An estimate is applied only if coefficient is still zero,
|
nuclear@0
|
572 * and is not known to be fully accurate.
|
nuclear@0
|
573 */
|
nuclear@0
|
574 /* AC01 */
|
nuclear@0
|
575 if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {
|
nuclear@0
|
576 num = 36 * Q00 * (DC4 - DC6);
|
nuclear@0
|
577 if (num >= 0) {
|
nuclear@0
|
578 pred = (int) (((Q01<<7) + num) / (Q01<<8));
|
nuclear@0
|
579 if (Al > 0 && pred >= (1<<Al))
|
nuclear@0
|
580 pred = (1<<Al)-1;
|
nuclear@0
|
581 } else {
|
nuclear@0
|
582 pred = (int) (((Q01<<7) - num) / (Q01<<8));
|
nuclear@0
|
583 if (Al > 0 && pred >= (1<<Al))
|
nuclear@0
|
584 pred = (1<<Al)-1;
|
nuclear@0
|
585 pred = -pred;
|
nuclear@0
|
586 }
|
nuclear@0
|
587 workspace[1] = (JCOEF) pred;
|
nuclear@0
|
588 }
|
nuclear@0
|
589 /* AC10 */
|
nuclear@0
|
590 if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {
|
nuclear@0
|
591 num = 36 * Q00 * (DC2 - DC8);
|
nuclear@0
|
592 if (num >= 0) {
|
nuclear@0
|
593 pred = (int) (((Q10<<7) + num) / (Q10<<8));
|
nuclear@0
|
594 if (Al > 0 && pred >= (1<<Al))
|
nuclear@0
|
595 pred = (1<<Al)-1;
|
nuclear@0
|
596 } else {
|
nuclear@0
|
597 pred = (int) (((Q10<<7) - num) / (Q10<<8));
|
nuclear@0
|
598 if (Al > 0 && pred >= (1<<Al))
|
nuclear@0
|
599 pred = (1<<Al)-1;
|
nuclear@0
|
600 pred = -pred;
|
nuclear@0
|
601 }
|
nuclear@0
|
602 workspace[8] = (JCOEF) pred;
|
nuclear@0
|
603 }
|
nuclear@0
|
604 /* AC20 */
|
nuclear@0
|
605 if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {
|
nuclear@0
|
606 num = 9 * Q00 * (DC2 + DC8 - 2*DC5);
|
nuclear@0
|
607 if (num >= 0) {
|
nuclear@0
|
608 pred = (int) (((Q20<<7) + num) / (Q20<<8));
|
nuclear@0
|
609 if (Al > 0 && pred >= (1<<Al))
|
nuclear@0
|
610 pred = (1<<Al)-1;
|
nuclear@0
|
611 } else {
|
nuclear@0
|
612 pred = (int) (((Q20<<7) - num) / (Q20<<8));
|
nuclear@0
|
613 if (Al > 0 && pred >= (1<<Al))
|
nuclear@0
|
614 pred = (1<<Al)-1;
|
nuclear@0
|
615 pred = -pred;
|
nuclear@0
|
616 }
|
nuclear@0
|
617 workspace[16] = (JCOEF) pred;
|
nuclear@0
|
618 }
|
nuclear@0
|
619 /* AC11 */
|
nuclear@0
|
620 if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {
|
nuclear@0
|
621 num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
|
nuclear@0
|
622 if (num >= 0) {
|
nuclear@0
|
623 pred = (int) (((Q11<<7) + num) / (Q11<<8));
|
nuclear@0
|
624 if (Al > 0 && pred >= (1<<Al))
|
nuclear@0
|
625 pred = (1<<Al)-1;
|
nuclear@0
|
626 } else {
|
nuclear@0
|
627 pred = (int) (((Q11<<7) - num) / (Q11<<8));
|
nuclear@0
|
628 if (Al > 0 && pred >= (1<<Al))
|
nuclear@0
|
629 pred = (1<<Al)-1;
|
nuclear@0
|
630 pred = -pred;
|
nuclear@0
|
631 }
|
nuclear@0
|
632 workspace[9] = (JCOEF) pred;
|
nuclear@0
|
633 }
|
nuclear@0
|
634 /* AC02 */
|
nuclear@0
|
635 if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {
|
nuclear@0
|
636 num = 9 * Q00 * (DC4 + DC6 - 2*DC5);
|
nuclear@0
|
637 if (num >= 0) {
|
nuclear@0
|
638 pred = (int) (((Q02<<7) + num) / (Q02<<8));
|
nuclear@0
|
639 if (Al > 0 && pred >= (1<<Al))
|
nuclear@0
|
640 pred = (1<<Al)-1;
|
nuclear@0
|
641 } else {
|
nuclear@0
|
642 pred = (int) (((Q02<<7) - num) / (Q02<<8));
|
nuclear@0
|
643 if (Al > 0 && pred >= (1<<Al))
|
nuclear@0
|
644 pred = (1<<Al)-1;
|
nuclear@0
|
645 pred = -pred;
|
nuclear@0
|
646 }
|
nuclear@0
|
647 workspace[2] = (JCOEF) pred;
|
nuclear@0
|
648 }
|
nuclear@0
|
649 /* OK, do the IDCT */
|
nuclear@0
|
650 (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace,
|
nuclear@0
|
651 output_ptr, output_col);
|
nuclear@0
|
652 /* Advance for next column */
|
nuclear@0
|
653 DC1 = DC2; DC2 = DC3;
|
nuclear@0
|
654 DC4 = DC5; DC5 = DC6;
|
nuclear@0
|
655 DC7 = DC8; DC8 = DC9;
|
nuclear@0
|
656 buffer_ptr++, prev_block_row++, next_block_row++;
|
nuclear@0
|
657 output_col += compptr->DCT_scaled_size;
|
nuclear@0
|
658 }
|
nuclear@0
|
659 output_ptr += compptr->DCT_scaled_size;
|
nuclear@0
|
660 }
|
nuclear@0
|
661 }
|
nuclear@0
|
662
|
nuclear@0
|
663 if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
|
nuclear@0
|
664 return JPEG_ROW_COMPLETED;
|
nuclear@0
|
665 return JPEG_SCAN_COMPLETED;
|
nuclear@0
|
666 }
|
nuclear@0
|
667
|
nuclear@0
|
668 #endif /* BLOCK_SMOOTHING_SUPPORTED */
|
nuclear@0
|
669
|
nuclear@0
|
670
|
nuclear@0
|
671 /*
|
nuclear@0
|
672 * Initialize coefficient buffer controller.
|
nuclear@0
|
673 */
|
nuclear@0
|
674
|
nuclear@0
|
675 GLOBAL(void)
|
nuclear@0
|
676 jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
nuclear@0
|
677 {
|
nuclear@0
|
678 my_coef_ptr coef;
|
nuclear@0
|
679
|
nuclear@0
|
680 coef = (my_coef_ptr)
|
nuclear@0
|
681 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
nuclear@0
|
682 SIZEOF(my_coef_controller));
|
nuclear@0
|
683 cinfo->coef = (struct jpeg_d_coef_controller *) coef;
|
nuclear@0
|
684 coef->pub.start_input_pass = start_input_pass;
|
nuclear@0
|
685 coef->pub.start_output_pass = start_output_pass;
|
nuclear@0
|
686 #ifdef BLOCK_SMOOTHING_SUPPORTED
|
nuclear@0
|
687 coef->coef_bits_latch = NULL;
|
nuclear@0
|
688 #endif
|
nuclear@0
|
689
|
nuclear@0
|
690 /* Create the coefficient buffer. */
|
nuclear@0
|
691 if (need_full_buffer) {
|
nuclear@0
|
692 #ifdef D_MULTISCAN_FILES_SUPPORTED
|
nuclear@0
|
693 /* Allocate a full-image virtual array for each component, */
|
nuclear@0
|
694 /* padded to a multiple of samp_factor DCT blocks in each direction. */
|
nuclear@0
|
695 /* Note we ask for a pre-zeroed array. */
|
nuclear@0
|
696 int ci, access_rows;
|
nuclear@0
|
697 jpeg_component_info *compptr;
|
nuclear@0
|
698
|
nuclear@0
|
699 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
nuclear@0
|
700 ci++, compptr++) {
|
nuclear@0
|
701 access_rows = compptr->v_samp_factor;
|
nuclear@0
|
702 #ifdef BLOCK_SMOOTHING_SUPPORTED
|
nuclear@0
|
703 /* If block smoothing could be used, need a bigger window */
|
nuclear@0
|
704 if (cinfo->progressive_mode)
|
nuclear@0
|
705 access_rows *= 3;
|
nuclear@0
|
706 #endif
|
nuclear@0
|
707 coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
|
nuclear@0
|
708 ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE,
|
nuclear@0
|
709 (JDIMENSION) jround_up((long) compptr->width_in_blocks,
|
nuclear@0
|
710 (long) compptr->h_samp_factor),
|
nuclear@0
|
711 (JDIMENSION) jround_up((long) compptr->height_in_blocks,
|
nuclear@0
|
712 (long) compptr->v_samp_factor),
|
nuclear@0
|
713 (JDIMENSION) access_rows);
|
nuclear@0
|
714 }
|
nuclear@0
|
715 coef->pub.consume_data = consume_data;
|
nuclear@0
|
716 coef->pub.decompress_data = decompress_data;
|
nuclear@0
|
717 coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
|
nuclear@0
|
718 #else
|
nuclear@0
|
719 ERREXIT(cinfo, JERR_NOT_COMPILED);
|
nuclear@0
|
720 #endif
|
nuclear@0
|
721 } else {
|
nuclear@0
|
722 /* We only need a single-MCU buffer. */
|
nuclear@0
|
723 JBLOCKROW buffer;
|
nuclear@0
|
724 int i;
|
nuclear@0
|
725
|
nuclear@0
|
726 buffer = (JBLOCKROW)
|
nuclear@0
|
727 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
nuclear@0
|
728 D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
nuclear@0
|
729 for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
|
nuclear@0
|
730 coef->MCU_buffer[i] = buffer + i;
|
nuclear@0
|
731 }
|
nuclear@0
|
732 coef->pub.consume_data = dummy_consume_data;
|
nuclear@0
|
733 coef->pub.decompress_data = decompress_onepass;
|
nuclear@0
|
734 coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
|
nuclear@0
|
735 }
|
nuclear@0
|
736 }
|