clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name jdcoefct.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mthread-model posix -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base/linux -I /home/daniel/Projects/java/jdk/src/java.base/share/native/libjava -I /home/daniel/Projects/java/jdk/src/java.base/unix/native/libjava -I /home/daniel/Projects/java/jdk/src/hotspot/share/include -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix/include -D LIBC=gnu -D _GNU_SOURCE -D _REENTRANT -D _LARGEFILE64_SOURCE -D LINUX -D DEBUG -D _LITTLE_ENDIAN -D ARCH="amd64" -D amd64 -D _LP64=1 -D SPLASHSCREEN -D PNG_NO_MMX_CODE -D PNG_ARM_NEON_OPT=0 -D PNG_ARM_NEON_IMPLEMENTATION=0 -D WITH_X11 -I /home/daniel/Projects/java/jdk/src/java.desktop/unix/native/libsplashscreen -I /home/daniel/Projects/java/jdk/src/java.desktop/share/native/libsplashscreen -I /home/daniel/Projects/java/jdk/src/java.desktop/unix/native/common/awt/systemscale -I /home/daniel/Projects/java/jdk/src/java.desktop/share/native/libjavajpeg -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/headers/java.desktop -I /home/daniel/Projects/java/jdk/src/java.desktop/share/native/libsplashscreen/giflib -I /home/daniel/Projects/java/jdk/src/java.desktop/share/native/libsplashscreen/libpng -I /home/daniel/Projects/java/jdk/src/java.base/unix/native/include -I /home/daniel/Projects/java/jdk/src/java.base/share/native/include -I /home/daniel/Projects/java/jdk/src/java.base/linux/native/libjava -I /home/daniel/Projects/java/jdk/src/java.base/unix/native/libjava -I /home/daniel/Projects/java/jdk/src/java.base/share/native/libjava -D _FORTIFY_SOURCE=2 -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-unused -Wno-sign-compare -Wno-type-limits -Wno-unused-result -Wno-maybe-uninitialized -Wno-shift-negative-value -Wno-implicit-fallthrough -Wno-unused-function -std=c99 -fdebug-compilation-dir /home/daniel/Projects/java/jdk/make -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -stack-protector 1 -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /home/daniel/Projects/java/scan/2021-12-21-193737-8510-1 -x c /home/daniel/Projects/java/jdk/src/java.desktop/share/native/libjavajpeg/jdcoefct.c
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | #define JPEG_INTERNALS |
22 | #include "jinclude.h" |
23 | #include "jpeglib.h" |
24 | |
25 | |
26 | #ifndef D_PROGRESSIVE_SUPPORTED |
27 | #undef BLOCK_SMOOTHING_SUPPORTED |
28 | #endif |
29 | |
30 | |
31 | |
32 | typedef struct { |
33 | struct jpeg_d_coef_controller pub; |
34 | |
35 | |
36 | |
37 | JDIMENSION MCU_ctr; |
38 | int MCU_vert_offset; |
39 | int MCU_rows_per_iMCU_row; |
40 | |
41 | |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU]; |
53 | |
54 | #ifdef D_MULTISCAN_FILES_SUPPORTED |
55 | |
56 | jvirt_barray_ptr whole_image[MAX_COMPONENTS]; |
57 | #endif |
58 | |
59 | #ifdef BLOCK_SMOOTHING_SUPPORTED |
60 | |
61 | int * coef_bits_latch; |
62 | #define SAVED_COEFS 6 /* we save coef_bits[0..5] */ |
63 | #endif |
64 | } my_coef_controller; |
65 | |
66 | typedef my_coef_controller * my_coef_ptr; |
67 | |
68 | |
69 | METHODDEF(int) decompress_onepass |
70 | JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); |
71 | #ifdef D_MULTISCAN_FILES_SUPPORTED |
72 | METHODDEF(int) decompress_data |
73 | JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); |
74 | #endif |
75 | #ifdef BLOCK_SMOOTHING_SUPPORTED |
76 | LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo)); |
77 | METHODDEF(int) decompress_smooth_data |
78 | JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); |
79 | #endif |
80 | |
81 | |
82 | LOCAL(void) |
83 | start_iMCU_row (j_decompress_ptr cinfo) |
84 | |
85 | { |
86 | my_coef_ptr coef = (my_coef_ptr) cinfo->coef; |
87 | |
88 | |
89 | |
90 | |
91 | |
92 | if (cinfo->comps_in_scan > 1) { |
93 | coef->MCU_rows_per_iMCU_row = 1; |
94 | } else { |
95 | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) |
96 | coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; |
97 | else |
98 | coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; |
99 | } |
100 | |
101 | coef->MCU_ctr = 0; |
102 | coef->MCU_vert_offset = 0; |
103 | } |
104 | |
105 | |
106 | |
107 | |
108 | |
109 | |
110 | METHODDEF(void) |
111 | start_input_pass (j_decompress_ptr cinfo) |
112 | { |
113 | cinfo->input_iMCU_row = 0; |
114 | start_iMCU_row(cinfo); |
115 | } |
116 | |
117 | |
118 | |
119 | |
120 | |
121 | |
122 | METHODDEF(void) |
123 | start_output_pass (j_decompress_ptr cinfo) |
124 | { |
125 | #ifdef BLOCK_SMOOTHING_SUPPORTED |
126 | my_coef_ptr coef = (my_coef_ptr) cinfo->coef; |
127 | |
128 | |
129 | if (coef->pub.coef_arrays != NULL) { |
130 | if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) |
131 | coef->pub.decompress_data = decompress_smooth_data; |
132 | else |
133 | coef->pub.decompress_data = decompress_data; |
134 | } |
135 | #endif |
136 | cinfo->output_iMCU_row = 0; |
137 | } |
138 | |
139 | |
140 | |
141 | |
142 | |
143 | |
144 | |
145 | |
146 | |
147 | |
148 | |
149 | |
150 | METHODDEF(int) |
151 | decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) |
152 | { |
153 | my_coef_ptr coef = (my_coef_ptr) cinfo->coef; |
154 | JDIMENSION MCU_col_num; |
155 | JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; |
156 | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
157 | int blkn, ci, xindex, yindex, yoffset, useful_width; |
158 | JSAMPARRAY output_ptr; |
159 | JDIMENSION start_col, output_col; |
160 | jpeg_component_info *compptr; |
161 | inverse_DCT_method_ptr inverse_DCT; |
162 | |
163 | |
164 | for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; |
165 | yoffset++) { |
166 | for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; |
167 | MCU_col_num++) { |
168 | |
169 | jzero_far((void FAR *) coef->MCU_buffer[0], |
170 | (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK))); |
171 | if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { |
172 | |
173 | coef->MCU_vert_offset = yoffset; |
174 | coef->MCU_ctr = MCU_col_num; |
175 | return JPEG_SUSPENDED; |
176 | } |
177 | |
178 | |
179 | |
180 | |
181 | |
182 | blkn = 0; |
183 | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
184 | compptr = cinfo->cur_comp_info[ci]; |
185 | |
186 | if (! compptr->component_needed) { |
187 | blkn += compptr->MCU_blocks; |
188 | continue; |
189 | } |
190 | inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index]; |
191 | useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width |
192 | : compptr->last_col_width; |
193 | output_ptr = output_buf[compptr->component_index] + |
194 | yoffset * compptr->DCT_scaled_size; |
195 | start_col = MCU_col_num * compptr->MCU_sample_width; |
196 | for (yindex = 0; yindex < compptr->MCU_height; yindex++) { |
197 | if (cinfo->input_iMCU_row < last_iMCU_row || |
198 | yoffset+yindex < compptr->last_row_height) { |
199 | output_col = start_col; |
200 | for (xindex = 0; xindex < useful_width; xindex++) { |
201 | (*inverse_DCT) (cinfo, compptr, |
202 | (JCOEFPTR) coef->MCU_buffer[blkn+xindex], |
203 | output_ptr, output_col); |
204 | output_col += compptr->DCT_scaled_size; |
205 | } |
206 | } |
207 | blkn += compptr->MCU_width; |
208 | output_ptr += compptr->DCT_scaled_size; |
209 | } |
210 | } |
211 | } |
212 | |
213 | coef->MCU_ctr = 0; |
214 | } |
215 | |
216 | cinfo->output_iMCU_row++; |
217 | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { |
218 | start_iMCU_row(cinfo); |
219 | return JPEG_ROW_COMPLETED; |
220 | } |
221 | |
222 | (*cinfo->inputctl->finish_input_pass) (cinfo); |
223 | return JPEG_SCAN_COMPLETED; |
224 | } |
225 | |
226 | |
227 | |
228 | |
229 | |
230 | |
231 | METHODDEF(int) |
232 | dummy_consume_data (j_decompress_ptr cinfo) |
233 | { |
234 | return JPEG_SUSPENDED; |
235 | } |
236 | |
237 | |
238 | #ifdef D_MULTISCAN_FILES_SUPPORTED |
239 | |
240 | |
241 | |
242 | |
243 | |
244 | |
245 | |
246 | |
247 | METHODDEF(int) |
248 | consume_data (j_decompress_ptr cinfo) |
249 | { |
250 | my_coef_ptr coef = (my_coef_ptr) cinfo->coef; |
251 | JDIMENSION MCU_col_num; |
252 | int blkn, ci, xindex, yindex, yoffset; |
253 | JDIMENSION start_col; |
254 | JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; |
255 | JBLOCKROW buffer_ptr; |
256 | jpeg_component_info *compptr; |
257 | |
258 | |
259 | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
| 1 | Assuming 'ci' is >= field 'comps_in_scan' | |
|
| 2 | | Loop condition is false. Execution continues on line 272 | |
|
260 | compptr = cinfo->cur_comp_info[ci]; |
261 | buffer[ci] = (*cinfo->mem->access_virt_barray) |
262 | ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], |
263 | cinfo->input_iMCU_row * compptr->v_samp_factor, |
264 | (JDIMENSION) compptr->v_samp_factor, TRUE); |
265 | |
266 | |
267 | |
268 | |
269 | } |
270 | |
271 | |
272 | for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; |
| 3 | | Assuming 'yoffset' is < field 'MCU_rows_per_iMCU_row' | |
|
| 4 | | Loop condition is true. Entering loop body | |
|
273 | yoffset++) { |
274 | for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; |
| 5 | | Assuming 'MCU_col_num' is < field 'MCUs_per_row' | |
|
| 6 | | Loop condition is true. Entering loop body | |
|
| 10 | | Assuming 'MCU_col_num' is < field 'MCUs_per_row' | |
|
| 11 | | Loop condition is true. Entering loop body | |
|
275 | MCU_col_num++) { |
276 | |
277 | blkn = 0; |
278 | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
| 7 | | Loop condition is false. Execution continues on line 289 | |
|
| 12 | | Assuming 'ci' is < field 'comps_in_scan' | |
|
| 13 | | Loop condition is true. Entering loop body | |
|
279 | compptr = cinfo->cur_comp_info[ci]; |
280 | start_col = MCU_col_num * compptr->MCU_width; |
281 | for (yindex = 0; yindex < compptr->MCU_height; yindex++) { |
| 14 | | Assuming 'yindex' is < field 'MCU_height' | |
|
| 15 | | Loop condition is true. Entering loop body | |
|
282 | buffer_ptr = buffer[ci][yindex+yoffset] + start_col; |
| 16 | | Dereference of undefined pointer value |
|
283 | for (xindex = 0; xindex < compptr->MCU_width; xindex++) { |
284 | coef->MCU_buffer[blkn++] = buffer_ptr++; |
285 | } |
286 | } |
287 | } |
288 | |
289 | if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { |
| 8 | | Assuming the condition is false | |
|
| |
290 | |
291 | coef->MCU_vert_offset = yoffset; |
292 | coef->MCU_ctr = MCU_col_num; |
293 | return JPEG_SUSPENDED; |
294 | } |
295 | } |
296 | |
297 | coef->MCU_ctr = 0; |
298 | } |
299 | |
300 | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { |
301 | start_iMCU_row(cinfo); |
302 | return JPEG_ROW_COMPLETED; |
303 | } |
304 | |
305 | (*cinfo->inputctl->finish_input_pass) (cinfo); |
306 | return JPEG_SCAN_COMPLETED; |
307 | } |
308 | |
309 | |
310 | |
311 | |
312 | |
313 | |
314 | |
315 | |
316 | |
317 | |
318 | METHODDEF(int) |
319 | decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) |
320 | { |
321 | my_coef_ptr coef = (my_coef_ptr) cinfo->coef; |
322 | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
323 | JDIMENSION block_num; |
324 | int ci, block_row, block_rows; |
325 | JBLOCKARRAY buffer; |
326 | JBLOCKROW buffer_ptr; |
327 | JSAMPARRAY output_ptr; |
328 | JDIMENSION output_col; |
329 | jpeg_component_info *compptr; |
330 | inverse_DCT_method_ptr inverse_DCT; |
331 | |
332 | |
333 | while (cinfo->input_scan_number < cinfo->output_scan_number || |
334 | (cinfo->input_scan_number == cinfo->output_scan_number && |
335 | cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { |
336 | if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) |
337 | return JPEG_SUSPENDED; |
338 | } |
339 | |
340 | |
341 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
342 | ci++, compptr++) { |
343 | |
344 | if (! compptr->component_needed) |
345 | continue; |
346 | |
347 | buffer = (*cinfo->mem->access_virt_barray) |
348 | ((j_common_ptr) cinfo, coef->whole_image[ci], |
349 | cinfo->output_iMCU_row * compptr->v_samp_factor, |
350 | (JDIMENSION) compptr->v_samp_factor, FALSE); |
351 | |
352 | if (cinfo->output_iMCU_row < last_iMCU_row) |
353 | block_rows = compptr->v_samp_factor; |
354 | else { |
355 | |
356 | block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); |
357 | if (block_rows == 0) block_rows = compptr->v_samp_factor; |
358 | } |
359 | inverse_DCT = cinfo->idct->inverse_DCT[ci]; |
360 | output_ptr = output_buf[ci]; |
361 | |
362 | for (block_row = 0; block_row < block_rows; block_row++) { |
363 | buffer_ptr = buffer[block_row]; |
364 | output_col = 0; |
365 | for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) { |
366 | (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr, |
367 | output_ptr, output_col); |
368 | buffer_ptr++; |
369 | output_col += compptr->DCT_scaled_size; |
370 | } |
371 | output_ptr += compptr->DCT_scaled_size; |
372 | } |
373 | } |
374 | |
375 | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) |
376 | return JPEG_ROW_COMPLETED; |
377 | return JPEG_SCAN_COMPLETED; |
378 | } |
379 | |
380 | #endif /* D_MULTISCAN_FILES_SUPPORTED */ |
381 | |
382 | |
383 | #ifdef BLOCK_SMOOTHING_SUPPORTED |
384 | |
385 | |
386 | |
387 | |
388 | |
389 | |
390 | |
391 | |
392 | |
393 | |
394 | #define Q01_POS 1 |
395 | #define Q10_POS 8 |
396 | #define Q20_POS 16 |
397 | #define Q11_POS 9 |
398 | #define Q02_POS 2 |
399 | |
400 | |
401 | |
402 | |
403 | |
404 | |
405 | |
406 | |
407 | |
408 | LOCAL(boolean) |
409 | smoothing_ok (j_decompress_ptr cinfo) |
410 | { |
411 | my_coef_ptr coef = (my_coef_ptr) cinfo->coef; |
412 | boolean smoothing_useful = FALSE; |
413 | int ci, coefi; |
414 | jpeg_component_info *compptr; |
415 | JQUANT_TBL * qtable; |
416 | int * coef_bits; |
417 | int * coef_bits_latch; |
418 | |
419 | if (! cinfo->progressive_mode || cinfo->coef_bits == NULL) |
420 | return FALSE; |
421 | |
422 | |
423 | if (coef->coef_bits_latch == NULL) |
424 | coef->coef_bits_latch = (int *) |
425 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
426 | cinfo->num_components * |
427 | (SAVED_COEFS * SIZEOF(int))); |
428 | coef_bits_latch = coef->coef_bits_latch; |
429 | |
430 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
431 | ci++, compptr++) { |
432 | |
433 | if ((qtable = compptr->quant_table) == NULL) |
434 | return FALSE; |
435 | |
436 | if (qtable->quantval[0] == 0 || |
437 | qtable->quantval[Q01_POS] == 0 || |
438 | qtable->quantval[Q10_POS] == 0 || |
439 | qtable->quantval[Q20_POS] == 0 || |
440 | qtable->quantval[Q11_POS] == 0 || |
441 | qtable->quantval[Q02_POS] == 0) |
442 | return FALSE; |
443 | |
444 | coef_bits = cinfo->coef_bits[ci]; |
445 | if (coef_bits[0] < 0) |
446 | return FALSE; |
447 | |
448 | for (coefi = 1; coefi <= 5; coefi++) { |
449 | coef_bits_latch[coefi] = coef_bits[coefi]; |
450 | if (coef_bits[coefi] != 0) |
451 | smoothing_useful = TRUE; |
452 | } |
453 | coef_bits_latch += SAVED_COEFS; |
454 | } |
455 | |
456 | return smoothing_useful; |
457 | } |
458 | |
459 | |
460 | |
461 | |
462 | |
463 | |
464 | METHODDEF(int) |
465 | decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) |
466 | { |
467 | my_coef_ptr coef = (my_coef_ptr) cinfo->coef; |
468 | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
469 | JDIMENSION block_num, last_block_column; |
470 | int ci, block_row, block_rows, access_rows; |
471 | JBLOCKARRAY buffer; |
472 | JBLOCKROW buffer_ptr, prev_block_row, next_block_row; |
473 | JSAMPARRAY output_ptr; |
474 | JDIMENSION output_col; |
475 | jpeg_component_info *compptr; |
476 | inverse_DCT_method_ptr inverse_DCT; |
477 | boolean first_row, last_row; |
478 | JBLOCK workspace; |
479 | int *coef_bits; |
480 | JQUANT_TBL *quanttbl; |
481 | INT32 Q00,Q01,Q02,Q10,Q11,Q20, num; |
482 | int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9; |
483 | int Al, pred; |
484 | |
485 | |
486 | while (cinfo->input_scan_number <= cinfo->output_scan_number && |
487 | ! cinfo->inputctl->eoi_reached) { |
488 | if (cinfo->input_scan_number == cinfo->output_scan_number) { |
489 | |
490 | |
491 | |
492 | |
493 | |
494 | JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0; |
495 | if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta) |
496 | break; |
497 | } |
498 | if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) |
499 | return JPEG_SUSPENDED; |
500 | } |
501 | |
502 | |
503 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
504 | ci++, compptr++) { |
505 | |
506 | if (! compptr->component_needed) |
507 | continue; |
508 | |
509 | if (cinfo->output_iMCU_row < last_iMCU_row) { |
510 | block_rows = compptr->v_samp_factor; |
511 | access_rows = block_rows * 2; |
512 | last_row = FALSE; |
513 | } else { |
514 | |
515 | block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); |
516 | if (block_rows == 0) block_rows = compptr->v_samp_factor; |
517 | access_rows = block_rows; |
518 | last_row = TRUE; |
519 | } |
520 | |
521 | if (cinfo->output_iMCU_row > 0) { |
522 | access_rows += compptr->v_samp_factor; |
523 | buffer = (*cinfo->mem->access_virt_barray) |
524 | ((j_common_ptr) cinfo, coef->whole_image[ci], |
525 | (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor, |
526 | (JDIMENSION) access_rows, FALSE); |
527 | buffer += compptr->v_samp_factor; |
528 | first_row = FALSE; |
529 | } else { |
530 | buffer = (*cinfo->mem->access_virt_barray) |
531 | ((j_common_ptr) cinfo, coef->whole_image[ci], |
532 | (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE); |
533 | first_row = TRUE; |
534 | } |
535 | |
536 | coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS); |
537 | quanttbl = compptr->quant_table; |
538 | Q00 = quanttbl->quantval[0]; |
539 | Q01 = quanttbl->quantval[Q01_POS]; |
540 | Q10 = quanttbl->quantval[Q10_POS]; |
541 | Q20 = quanttbl->quantval[Q20_POS]; |
542 | Q11 = quanttbl->quantval[Q11_POS]; |
543 | Q02 = quanttbl->quantval[Q02_POS]; |
544 | inverse_DCT = cinfo->idct->inverse_DCT[ci]; |
545 | output_ptr = output_buf[ci]; |
546 | |
547 | for (block_row = 0; block_row < block_rows; block_row++) { |
548 | buffer_ptr = buffer[block_row]; |
549 | if (first_row && block_row == 0) |
550 | prev_block_row = buffer_ptr; |
551 | else |
552 | prev_block_row = buffer[block_row-1]; |
553 | if (last_row && block_row == block_rows-1) |
554 | next_block_row = buffer_ptr; |
555 | else |
556 | next_block_row = buffer[block_row+1]; |
557 | |
558 | |
559 | |
560 | DC1 = DC2 = DC3 = (int) prev_block_row[0][0]; |
561 | DC4 = DC5 = DC6 = (int) buffer_ptr[0][0]; |
562 | DC7 = DC8 = DC9 = (int) next_block_row[0][0]; |
563 | output_col = 0; |
564 | last_block_column = compptr->width_in_blocks - 1; |
565 | for (block_num = 0; block_num <= last_block_column; block_num++) { |
566 | |
567 | jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1); |
568 | |
569 | if (block_num < last_block_column) { |
570 | DC3 = (int) prev_block_row[1][0]; |
571 | DC6 = (int) buffer_ptr[1][0]; |
572 | DC9 = (int) next_block_row[1][0]; |
573 | } |
574 | |
575 | |
576 | |
577 | |
578 | |
579 | if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) { |
580 | num = 36 * Q00 * (DC4 - DC6); |
581 | if (num >= 0) { |
582 | pred = (int) (((Q01<<7) + num) / (Q01<<8)); |
583 | if (Al > 0 && pred >= (1<<Al)) |
584 | pred = (1<<Al)-1; |
585 | } else { |
586 | pred = (int) (((Q01<<7) - num) / (Q01<<8)); |
587 | if (Al > 0 && pred >= (1<<Al)) |
588 | pred = (1<<Al)-1; |
589 | pred = -pred; |
590 | } |
591 | workspace[1] = (JCOEF) pred; |
592 | } |
593 | |
594 | if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) { |
595 | num = 36 * Q00 * (DC2 - DC8); |
596 | if (num >= 0) { |
597 | pred = (int) (((Q10<<7) + num) / (Q10<<8)); |
598 | if (Al > 0 && pred >= (1<<Al)) |
599 | pred = (1<<Al)-1; |
600 | } else { |
601 | pred = (int) (((Q10<<7) - num) / (Q10<<8)); |
602 | if (Al > 0 && pred >= (1<<Al)) |
603 | pred = (1<<Al)-1; |
604 | pred = -pred; |
605 | } |
606 | workspace[8] = (JCOEF) pred; |
607 | } |
608 | |
609 | if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) { |
610 | num = 9 * Q00 * (DC2 + DC8 - 2*DC5); |
611 | if (num >= 0) { |
612 | pred = (int) (((Q20<<7) + num) / (Q20<<8)); |
613 | if (Al > 0 && pred >= (1<<Al)) |
614 | pred = (1<<Al)-1; |
615 | } else { |
616 | pred = (int) (((Q20<<7) - num) / (Q20<<8)); |
617 | if (Al > 0 && pred >= (1<<Al)) |
618 | pred = (1<<Al)-1; |
619 | pred = -pred; |
620 | } |
621 | workspace[16] = (JCOEF) pred; |
622 | } |
623 | |
624 | if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) { |
625 | num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9); |
626 | if (num >= 0) { |
627 | pred = (int) (((Q11<<7) + num) / (Q11<<8)); |
628 | if (Al > 0 && pred >= (1<<Al)) |
629 | pred = (1<<Al)-1; |
630 | } else { |
631 | pred = (int) (((Q11<<7) - num) / (Q11<<8)); |
632 | if (Al > 0 && pred >= (1<<Al)) |
633 | pred = (1<<Al)-1; |
634 | pred = -pred; |
635 | } |
636 | workspace[9] = (JCOEF) pred; |
637 | } |
638 | |
639 | if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) { |
640 | num = 9 * Q00 * (DC4 + DC6 - 2*DC5); |
641 | if (num >= 0) { |
642 | pred = (int) (((Q02<<7) + num) / (Q02<<8)); |
643 | if (Al > 0 && pred >= (1<<Al)) |
644 | pred = (1<<Al)-1; |
645 | } else { |
646 | pred = (int) (((Q02<<7) - num) / (Q02<<8)); |
647 | if (Al > 0 && pred >= (1<<Al)) |
648 | pred = (1<<Al)-1; |
649 | pred = -pred; |
650 | } |
651 | workspace[2] = (JCOEF) pred; |
652 | } |
653 | |
654 | (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace, |
655 | output_ptr, output_col); |
656 | |
657 | DC1 = DC2; DC2 = DC3; |
658 | DC4 = DC5; DC5 = DC6; |
659 | DC7 = DC8; DC8 = DC9; |
660 | buffer_ptr++, prev_block_row++, next_block_row++; |
661 | output_col += compptr->DCT_scaled_size; |
662 | } |
663 | output_ptr += compptr->DCT_scaled_size; |
664 | } |
665 | } |
666 | |
667 | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) |
668 | return JPEG_ROW_COMPLETED; |
669 | return JPEG_SCAN_COMPLETED; |
670 | } |
671 | |
672 | #endif /* BLOCK_SMOOTHING_SUPPORTED */ |
673 | |
674 | |
675 | |
676 | |
677 | |
678 | |
679 | GLOBAL(void) |
680 | jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer) |
681 | { |
682 | my_coef_ptr coef; |
683 | |
684 | coef = (my_coef_ptr) |
685 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
686 | SIZEOF(my_coef_controller)); |
687 | cinfo->coef = (struct jpeg_d_coef_controller *) coef; |
688 | coef->pub.start_input_pass = start_input_pass; |
689 | coef->pub.start_output_pass = start_output_pass; |
690 | #ifdef BLOCK_SMOOTHING_SUPPORTED |
691 | coef->coef_bits_latch = NULL; |
692 | #endif |
693 | |
694 | |
695 | if (need_full_buffer) { |
696 | #ifdef D_MULTISCAN_FILES_SUPPORTED |
697 | |
698 | |
699 | |
700 | int ci, access_rows; |
701 | jpeg_component_info *compptr; |
702 | |
703 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
704 | ci++, compptr++) { |
705 | access_rows = compptr->v_samp_factor; |
706 | #ifdef BLOCK_SMOOTHING_SUPPORTED |
707 | |
708 | if (cinfo->progressive_mode) |
709 | access_rows *= 3; |
710 | #endif |
711 | coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) |
712 | ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE, |
713 | (JDIMENSION) jround_up((long) compptr->width_in_blocks, |
714 | (long) compptr->h_samp_factor), |
715 | (JDIMENSION) jround_up((long) compptr->height_in_blocks, |
716 | (long) compptr->v_samp_factor), |
717 | (JDIMENSION) access_rows); |
718 | } |
719 | coef->pub.consume_data = consume_data; |
720 | coef->pub.decompress_data = decompress_data; |
721 | coef->pub.coef_arrays = coef->whole_image; |
722 | #else |
723 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
724 | #endif |
725 | } else { |
726 | |
727 | JBLOCKROW buffer; |
728 | int i; |
729 | |
730 | buffer = (JBLOCKROW) |
731 | (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
732 | D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); |
733 | for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { |
734 | coef->MCU_buffer[i] = buffer + i; |
735 | } |
736 | coef->pub.consume_data = dummy_consume_data; |
737 | coef->pub.decompress_data = decompress_onepass; |
738 | coef->pub.coef_arrays = NULL; |
739 | } |
740 | } |