/src/libjpeg-turbo/src/jdcoefct.c
Line | Count | Source |
1 | | /* |
2 | | * jdcoefct.c |
3 | | * |
4 | | * This file was part of the Independent JPEG Group's software: |
5 | | * Copyright (C) 1994-1997, Thomas G. Lane. |
6 | | * libjpeg-turbo Modifications: |
7 | | * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
8 | | * Copyright (C) 2010, 2015-2016, 2019-2020, 2022-2026, D. R. Commander. |
9 | | * Copyright (C) 2015, 2020, Google, Inc. |
10 | | * For conditions of distribution and use, see the accompanying README.ijg |
11 | | * file. |
12 | | * |
13 | | * This file contains the coefficient buffer controller for decompression. |
14 | | * This controller is the top level of the lossy JPEG decompressor proper. |
15 | | * The coefficient buffer lies between entropy decoding and inverse-DCT steps. |
16 | | * |
17 | | * In buffered-image mode, this controller is the interface between |
18 | | * input-oriented processing and output-oriented processing. |
19 | | * Also, the input side (only) is used when reading a file for transcoding. |
20 | | */ |
21 | | |
22 | | #include "jinclude.h" |
23 | | #include "jdcoefct.h" |
24 | | #include "jpegapicomp.h" |
25 | | #include "jsamplecomp.h" |
26 | | #ifdef WITH_PROFILE |
27 | | #include "tjutil.h" |
28 | | #endif |
29 | | |
30 | | |
31 | | /* Forward declarations */ |
32 | | METHODDEF(int) decompress_onepass(j_decompress_ptr cinfo, |
33 | | _JSAMPIMAGE output_buf); |
34 | | #ifdef D_MULTISCAN_FILES_SUPPORTED |
35 | | METHODDEF(int) decompress_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf); |
36 | | #endif |
37 | | #ifdef BLOCK_SMOOTHING_SUPPORTED |
38 | | LOCAL(boolean) smoothing_ok(j_decompress_ptr cinfo); |
39 | | METHODDEF(int) decompress_smooth_data(j_decompress_ptr cinfo, |
40 | | _JSAMPIMAGE output_buf); |
41 | | #endif |
42 | | |
43 | | |
44 | | /* |
45 | | * Initialize for an input processing pass. |
46 | | */ |
47 | | |
48 | | METHODDEF(void) |
49 | | start_input_pass(j_decompress_ptr cinfo) |
50 | 88.4k | { |
51 | 88.4k | cinfo->input_iMCU_row = 0; |
52 | 88.4k | start_iMCU_row(cinfo); |
53 | 88.4k | } jdcoefct-8.c:start_input_pass Line | Count | Source | 50 | 77.5k | { | 51 | 77.5k | cinfo->input_iMCU_row = 0; | 52 | 77.5k | start_iMCU_row(cinfo); | 53 | 77.5k | } |
jdcoefct-12.c:start_input_pass Line | Count | Source | 50 | 10.8k | { | 51 | 10.8k | cinfo->input_iMCU_row = 0; | 52 | 10.8k | start_iMCU_row(cinfo); | 53 | 10.8k | } |
|
54 | | |
55 | | |
56 | | /* |
57 | | * Initialize for an output processing pass. |
58 | | */ |
59 | | |
60 | | METHODDEF(void) |
61 | | start_output_pass(j_decompress_ptr cinfo) |
62 | 25.0k | { |
63 | 25.0k | #ifdef BLOCK_SMOOTHING_SUPPORTED |
64 | 25.0k | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; |
65 | | |
66 | | /* If multipass, check to see whether to use block smoothing on this pass */ |
67 | 25.0k | if (coef->pub.coef_arrays != NULL) { |
68 | 11.8k | if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) |
69 | 6.68k | coef->pub._decompress_data = decompress_smooth_data; |
70 | 5.16k | else |
71 | 5.16k | coef->pub._decompress_data = decompress_data; |
72 | 11.8k | } |
73 | 25.0k | #endif |
74 | 25.0k | cinfo->output_iMCU_row = 0; |
75 | 25.0k | } jdcoefct-8.c:start_output_pass Line | Count | Source | 62 | 23.7k | { | 63 | 23.7k | #ifdef BLOCK_SMOOTHING_SUPPORTED | 64 | 23.7k | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; | 65 | | | 66 | | /* If multipass, check to see whether to use block smoothing on this pass */ | 67 | 23.7k | if (coef->pub.coef_arrays != NULL) { | 68 | 10.6k | if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) | 69 | 6.35k | coef->pub._decompress_data = decompress_smooth_data; | 70 | 4.32k | else | 71 | 4.32k | coef->pub._decompress_data = decompress_data; | 72 | 10.6k | } | 73 | 23.7k | #endif | 74 | 23.7k | cinfo->output_iMCU_row = 0; | 75 | 23.7k | } |
jdcoefct-12.c:start_output_pass Line | Count | Source | 62 | 1.26k | { | 63 | 1.26k | #ifdef BLOCK_SMOOTHING_SUPPORTED | 64 | 1.26k | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; | 65 | | | 66 | | /* If multipass, check to see whether to use block smoothing on this pass */ | 67 | 1.26k | if (coef->pub.coef_arrays != NULL) { | 68 | 1.16k | if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) | 69 | 325 | coef->pub._decompress_data = decompress_smooth_data; | 70 | 841 | else | 71 | 841 | coef->pub._decompress_data = decompress_data; | 72 | 1.16k | } | 73 | 1.26k | #endif | 74 | 1.26k | cinfo->output_iMCU_row = 0; | 75 | 1.26k | } |
|
76 | | |
77 | | |
78 | | /* |
79 | | * Decompress and return some data in the single-pass case. |
80 | | * Always attempts to emit one fully interleaved MCU row ("iMCU" row). |
81 | | * Input and output must run in lockstep since we have only a one-MCU buffer. |
82 | | * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. |
83 | | * |
84 | | * NB: output_buf contains a plane for each component in image, |
85 | | * which we index according to the component's SOF position. |
86 | | */ |
87 | | |
88 | | METHODDEF(int) |
89 | | decompress_onepass(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf) |
90 | 2.25M | { |
91 | 2.25M | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; |
92 | 2.25M | JDIMENSION MCU_col_num; /* index of current MCU within row */ |
93 | 2.25M | JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; |
94 | 2.25M | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
95 | 2.25M | int blkn, ci, xindex, yindex, yoffset, useful_width; |
96 | 2.25M | _JSAMPARRAY output_ptr; |
97 | 2.25M | JDIMENSION start_col, output_col; |
98 | 2.25M | jpeg_component_info *compptr; |
99 | 2.25M | _inverse_DCT_method_ptr inverse_DCT; |
100 | | |
101 | | /* Loop to process as much as one whole iMCU row */ |
102 | 4.84M | for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; |
103 | 2.59M | yoffset++) { |
104 | 33.7M | for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; |
105 | 31.1M | MCU_col_num++) { |
106 | | /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ |
107 | 31.1M | jzero_far((void *)coef->MCU_buffer[0], |
108 | 31.1M | (size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK))); |
109 | 31.1M | if (!cinfo->entropy->insufficient_data) |
110 | 31.1M | cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row; |
111 | | #ifdef WITH_PROFILE |
112 | | cinfo->master->start = getTime(); |
113 | | #endif |
114 | 31.1M | if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { |
115 | | /* Suspension forced; update state counters and exit */ |
116 | 0 | coef->MCU_vert_offset = yoffset; |
117 | 0 | coef->MCU_ctr = MCU_col_num; |
118 | | #ifdef WITH_PROFILE |
119 | | cinfo->master->entropy_elapsed += getTime() - cinfo->master->start; |
120 | | cinfo->master->entropy_mcoeffs += |
121 | | (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.; |
122 | | #endif |
123 | 0 | return JPEG_SUSPENDED; |
124 | 0 | } |
125 | | #ifdef WITH_PROFILE |
126 | | cinfo->master->entropy_elapsed += getTime() - cinfo->master->start; |
127 | | cinfo->master->entropy_mcoeffs += |
128 | | (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.; |
129 | | #endif |
130 | | |
131 | | /* Only perform the IDCT on blocks that are contained within the desired |
132 | | * cropping region. |
133 | | */ |
134 | 31.1M | if (MCU_col_num >= cinfo->master->first_iMCU_col && |
135 | 31.1M | MCU_col_num <= cinfo->master->last_iMCU_col) { |
136 | | /* Determine where data should go in output_buf and do the IDCT thing. |
137 | | * We skip dummy blocks at the right and bottom edges (but blkn gets |
138 | | * incremented past them!). Note the inner loop relies on having |
139 | | * allocated the MCU_buffer[] blocks sequentially. |
140 | | */ |
141 | 31.1M | blkn = 0; /* index of current DCT block within MCU */ |
142 | 85.3M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
143 | 54.2M | compptr = cinfo->cur_comp_info[ci]; |
144 | | /* Don't bother to IDCT an uninteresting component. */ |
145 | 54.2M | if (!compptr->component_needed) { |
146 | 0 | blkn += compptr->MCU_blocks; |
147 | 0 | continue; |
148 | 0 | } |
149 | 54.2M | inverse_DCT = cinfo->idct->_inverse_DCT[compptr->component_index]; |
150 | 54.2M | useful_width = (MCU_col_num < last_MCU_col) ? |
151 | 48.3M | compptr->MCU_width : compptr->last_col_width; |
152 | 54.2M | output_ptr = output_buf[compptr->component_index] + |
153 | 54.2M | yoffset * compptr->_DCT_scaled_size; |
154 | 54.2M | start_col = (MCU_col_num - cinfo->master->first_iMCU_col) * |
155 | 54.2M | compptr->MCU_sample_width; |
156 | 118M | for (yindex = 0; yindex < compptr->MCU_height; yindex++) { |
157 | 64.7M | if (cinfo->input_iMCU_row < last_iMCU_row || |
158 | 62.6M | yoffset + yindex < compptr->last_row_height) { |
159 | 62.6M | output_col = start_col; |
160 | 134M | for (xindex = 0; xindex < useful_width; xindex++) { |
161 | | #ifdef WITH_PROFILE |
162 | | cinfo->master->start = getTime(); |
163 | | #endif |
164 | 71.3M | (*inverse_DCT) (cinfo, compptr, |
165 | 71.3M | (JCOEFPTR)coef->MCU_buffer[blkn + xindex], |
166 | 71.3M | output_ptr, output_col); |
167 | | #ifdef WITH_PROFILE |
168 | | cinfo->master->idct_elapsed += |
169 | | getTime() - cinfo->master->start; |
170 | | cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.; |
171 | | #endif |
172 | 71.3M | output_col += compptr->_DCT_scaled_size; |
173 | 71.3M | } |
174 | 62.6M | } |
175 | 64.7M | blkn += compptr->MCU_width; |
176 | 64.7M | output_ptr += compptr->_DCT_scaled_size; |
177 | 64.7M | } |
178 | 54.2M | } |
179 | 31.1M | } |
180 | 31.1M | } |
181 | | /* Completed an MCU row, but perhaps not an iMCU row */ |
182 | 2.59M | coef->MCU_ctr = 0; |
183 | 2.59M | } |
184 | | /* Completed the iMCU row, advance counters for next one */ |
185 | 2.25M | cinfo->output_iMCU_row++; |
186 | 2.25M | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { |
187 | 2.24M | start_iMCU_row(cinfo); |
188 | 2.24M | return JPEG_ROW_COMPLETED; |
189 | 2.24M | } |
190 | | /* Completed the scan */ |
191 | 13.0k | (*cinfo->inputctl->finish_input_pass) (cinfo); |
192 | 13.0k | return JPEG_SCAN_COMPLETED; |
193 | 2.25M | } jdcoefct-8.c:decompress_onepass Line | Count | Source | 90 | 2.25M | { | 91 | 2.25M | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; | 92 | 2.25M | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 93 | 2.25M | JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; | 94 | 2.25M | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 95 | 2.25M | int blkn, ci, xindex, yindex, yoffset, useful_width; | 96 | 2.25M | _JSAMPARRAY output_ptr; | 97 | 2.25M | JDIMENSION start_col, output_col; | 98 | 2.25M | jpeg_component_info *compptr; | 99 | 2.25M | _inverse_DCT_method_ptr inverse_DCT; | 100 | | | 101 | | /* Loop to process as much as one whole iMCU row */ | 102 | 4.84M | for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; | 103 | 2.59M | yoffset++) { | 104 | 33.7M | for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; | 105 | 31.1M | MCU_col_num++) { | 106 | | /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ | 107 | 31.1M | jzero_far((void *)coef->MCU_buffer[0], | 108 | 31.1M | (size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK))); | 109 | 31.1M | if (!cinfo->entropy->insufficient_data) | 110 | 31.1M | cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row; | 111 | | #ifdef WITH_PROFILE | 112 | | cinfo->master->start = getTime(); | 113 | | #endif | 114 | 31.1M | if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { | 115 | | /* Suspension forced; update state counters and exit */ | 116 | 0 | coef->MCU_vert_offset = yoffset; | 117 | 0 | coef->MCU_ctr = MCU_col_num; | 118 | | #ifdef WITH_PROFILE | 119 | | cinfo->master->entropy_elapsed += getTime() - cinfo->master->start; | 120 | | cinfo->master->entropy_mcoeffs += | 121 | | (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.; | 122 | | #endif | 123 | 0 | return JPEG_SUSPENDED; | 124 | 0 | } | 125 | | #ifdef WITH_PROFILE | 126 | | cinfo->master->entropy_elapsed += getTime() - cinfo->master->start; | 127 | | cinfo->master->entropy_mcoeffs += | 128 | | (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.; | 129 | | #endif | 130 | | | 131 | | /* Only perform the IDCT on blocks that are contained within the desired | 132 | | * cropping region. | 133 | | */ | 134 | 31.1M | if (MCU_col_num >= cinfo->master->first_iMCU_col && | 135 | 31.1M | MCU_col_num <= cinfo->master->last_iMCU_col) { | 136 | | /* Determine where data should go in output_buf and do the IDCT thing. | 137 | | * We skip dummy blocks at the right and bottom edges (but blkn gets | 138 | | * incremented past them!). Note the inner loop relies on having | 139 | | * allocated the MCU_buffer[] blocks sequentially. | 140 | | */ | 141 | 31.1M | blkn = 0; /* index of current DCT block within MCU */ | 142 | 85.3M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 143 | 54.2M | compptr = cinfo->cur_comp_info[ci]; | 144 | | /* Don't bother to IDCT an uninteresting component. */ | 145 | 54.2M | if (!compptr->component_needed) { | 146 | 0 | blkn += compptr->MCU_blocks; | 147 | 0 | continue; | 148 | 0 | } | 149 | 54.2M | inverse_DCT = cinfo->idct->_inverse_DCT[compptr->component_index]; | 150 | 54.2M | useful_width = (MCU_col_num < last_MCU_col) ? | 151 | 48.3M | compptr->MCU_width : compptr->last_col_width; | 152 | 54.2M | output_ptr = output_buf[compptr->component_index] + | 153 | 54.2M | yoffset * compptr->_DCT_scaled_size; | 154 | 54.2M | start_col = (MCU_col_num - cinfo->master->first_iMCU_col) * | 155 | 54.2M | compptr->MCU_sample_width; | 156 | 118M | for (yindex = 0; yindex < compptr->MCU_height; yindex++) { | 157 | 64.7M | if (cinfo->input_iMCU_row < last_iMCU_row || | 158 | 62.6M | yoffset + yindex < compptr->last_row_height) { | 159 | 62.6M | output_col = start_col; | 160 | 134M | for (xindex = 0; xindex < useful_width; xindex++) { | 161 | | #ifdef WITH_PROFILE | 162 | | cinfo->master->start = getTime(); | 163 | | #endif | 164 | 71.3M | (*inverse_DCT) (cinfo, compptr, | 165 | 71.3M | (JCOEFPTR)coef->MCU_buffer[blkn + xindex], | 166 | 71.3M | output_ptr, output_col); | 167 | | #ifdef WITH_PROFILE | 168 | | cinfo->master->idct_elapsed += | 169 | | getTime() - cinfo->master->start; | 170 | | cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.; | 171 | | #endif | 172 | 71.3M | output_col += compptr->_DCT_scaled_size; | 173 | 71.3M | } | 174 | 62.6M | } | 175 | 64.7M | blkn += compptr->MCU_width; | 176 | 64.7M | output_ptr += compptr->_DCT_scaled_size; | 177 | 64.7M | } | 178 | 54.2M | } | 179 | 31.1M | } | 180 | 31.1M | } | 181 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 182 | 2.59M | coef->MCU_ctr = 0; | 183 | 2.59M | } | 184 | | /* Completed the iMCU row, advance counters for next one */ | 185 | 2.25M | cinfo->output_iMCU_row++; | 186 | 2.25M | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 187 | 2.24M | start_iMCU_row(cinfo); | 188 | 2.24M | return JPEG_ROW_COMPLETED; | 189 | 2.24M | } | 190 | | /* Completed the scan */ | 191 | 13.0k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 192 | 13.0k | return JPEG_SCAN_COMPLETED; | 193 | 2.25M | } |
Unexecuted instantiation: jdcoefct-12.c:decompress_onepass |
194 | | |
195 | | |
196 | | /* |
197 | | * Dummy consume-input routine for single-pass operation. |
198 | | */ |
199 | | |
200 | | METHODDEF(int) |
201 | | dummy_consume_data(j_decompress_ptr cinfo) |
202 | 0 | { |
203 | 0 | return JPEG_SUSPENDED; /* Always indicate nothing was done */ |
204 | 0 | } Unexecuted instantiation: jdcoefct-8.c:dummy_consume_data Unexecuted instantiation: jdcoefct-12.c:dummy_consume_data |
205 | | |
206 | | |
207 | | #ifdef D_MULTISCAN_FILES_SUPPORTED |
208 | | |
209 | | /* |
210 | | * Consume input data and store it in the full-image coefficient buffer. |
211 | | * We read as much as one fully interleaved MCU row ("iMCU" row) per call, |
212 | | * ie, v_samp_factor block rows for each component in the scan. |
213 | | * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. |
214 | | */ |
215 | | |
216 | | METHODDEF(int) |
217 | | consume_data(j_decompress_ptr cinfo) |
218 | 10.6M | { |
219 | 10.6M | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; |
220 | 10.6M | JDIMENSION MCU_col_num; /* index of current MCU within row */ |
221 | 10.6M | int blkn, ci, xindex, yindex, yoffset; |
222 | 10.6M | JDIMENSION start_col; |
223 | 10.6M | JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; |
224 | 10.6M | JBLOCKROW buffer_ptr; |
225 | 10.6M | jpeg_component_info *compptr; |
226 | | |
227 | | /* Align the virtual buffers for the components used in this scan. */ |
228 | 35.3M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
229 | 24.6M | compptr = cinfo->cur_comp_info[ci]; |
230 | 24.6M | buffer[ci] = (*cinfo->mem->access_virt_barray) |
231 | 24.6M | ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index], |
232 | 24.6M | cinfo->input_iMCU_row * compptr->v_samp_factor, |
233 | 24.6M | (JDIMENSION)compptr->v_samp_factor, TRUE); |
234 | | /* Note: entropy decoder expects buffer to be zeroed, |
235 | | * but this is handled automatically by the memory manager |
236 | | * because we requested a pre-zeroed array. |
237 | | */ |
238 | 24.6M | } |
239 | | |
240 | | /* Loop to process one whole iMCU row */ |
241 | 24.8M | for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; |
242 | 14.1M | yoffset++) { |
243 | 320M | for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; |
244 | 306M | MCU_col_num++) { |
245 | | /* Construct list of pointers to DCT blocks belonging to this MCU */ |
246 | 306M | blkn = 0; /* index of current DCT block within MCU */ |
247 | 745M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
248 | 438M | compptr = cinfo->cur_comp_info[ci]; |
249 | 438M | start_col = MCU_col_num * compptr->MCU_width; |
250 | 959M | for (yindex = 0; yindex < compptr->MCU_height; yindex++) { |
251 | 520M | buffer_ptr = buffer[ci][yindex + yoffset] + start_col; |
252 | 1.10G | for (xindex = 0; xindex < compptr->MCU_width; xindex++) { |
253 | 581M | coef->MCU_buffer[blkn++] = buffer_ptr++; |
254 | 581M | } |
255 | 520M | } |
256 | 438M | } |
257 | 306M | if (!cinfo->entropy->insufficient_data) |
258 | 306M | cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row; |
259 | | /* Try to fetch the MCU. */ |
260 | | #ifdef WITH_PROFILE |
261 | | cinfo->master->start = getTime(); |
262 | | #endif |
263 | 306M | if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { |
264 | | /* Suspension forced; update state counters and exit */ |
265 | 0 | coef->MCU_vert_offset = yoffset; |
266 | 0 | coef->MCU_ctr = MCU_col_num; |
267 | | #ifdef WITH_PROFILE |
268 | | cinfo->master->entropy_elapsed += getTime() - cinfo->master->start; |
269 | | cinfo->master->entropy_mcoeffs += |
270 | | (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.; |
271 | | #endif |
272 | 0 | return JPEG_SUSPENDED; |
273 | 0 | } |
274 | | #ifdef WITH_PROFILE |
275 | | cinfo->master->entropy_elapsed += getTime() - cinfo->master->start; |
276 | | cinfo->master->entropy_mcoeffs += |
277 | | (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.; |
278 | | #endif |
279 | 306M | } |
280 | | /* Completed an MCU row, but perhaps not an iMCU row */ |
281 | 14.1M | coef->MCU_ctr = 0; |
282 | 14.1M | } |
283 | | /* Completed the iMCU row, advance counters for next one */ |
284 | 10.6M | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { |
285 | 10.6M | start_iMCU_row(cinfo); |
286 | 10.6M | return JPEG_ROW_COMPLETED; |
287 | 10.6M | } |
288 | | /* Completed the scan */ |
289 | 75.2k | (*cinfo->inputctl->finish_input_pass) (cinfo); |
290 | 75.2k | return JPEG_SCAN_COMPLETED; |
291 | 10.6M | } jdcoefct-8.c:consume_data Line | Count | Source | 218 | 7.01M | { | 219 | 7.01M | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; | 220 | 7.01M | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 221 | 7.01M | int blkn, ci, xindex, yindex, yoffset; | 222 | 7.01M | JDIMENSION start_col; | 223 | 7.01M | JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; | 224 | 7.01M | JBLOCKROW buffer_ptr; | 225 | 7.01M | jpeg_component_info *compptr; | 226 | | | 227 | | /* Align the virtual buffers for the components used in this scan. */ | 228 | 20.6M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 229 | 13.5M | compptr = cinfo->cur_comp_info[ci]; | 230 | 13.5M | buffer[ci] = (*cinfo->mem->access_virt_barray) | 231 | 13.5M | ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index], | 232 | 13.5M | cinfo->input_iMCU_row * compptr->v_samp_factor, | 233 | 13.5M | (JDIMENSION)compptr->v_samp_factor, TRUE); | 234 | | /* Note: entropy decoder expects buffer to be zeroed, | 235 | | * but this is handled automatically by the memory manager | 236 | | * because we requested a pre-zeroed array. | 237 | | */ | 238 | 13.5M | } | 239 | | | 240 | | /* Loop to process one whole iMCU row */ | 241 | 17.0M | for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; | 242 | 10.0M | yoffset++) { | 243 | 263M | for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; | 244 | 253M | MCU_col_num++) { | 245 | | /* Construct list of pointers to DCT blocks belonging to this MCU */ | 246 | 253M | blkn = 0; /* index of current DCT block within MCU */ | 247 | 595M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 248 | 342M | compptr = cinfo->cur_comp_info[ci]; | 249 | 342M | start_col = MCU_col_num * compptr->MCU_width; | 250 | 740M | for (yindex = 0; yindex < compptr->MCU_height; yindex++) { | 251 | 398M | buffer_ptr = buffer[ci][yindex + yoffset] + start_col; | 252 | 841M | for (xindex = 0; xindex < compptr->MCU_width; xindex++) { | 253 | 443M | coef->MCU_buffer[blkn++] = buffer_ptr++; | 254 | 443M | } | 255 | 398M | } | 256 | 342M | } | 257 | 253M | if (!cinfo->entropy->insufficient_data) | 258 | 253M | cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row; | 259 | | /* Try to fetch the MCU. */ | 260 | | #ifdef WITH_PROFILE | 261 | | cinfo->master->start = getTime(); | 262 | | #endif | 263 | 253M | if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { | 264 | | /* Suspension forced; update state counters and exit */ | 265 | 0 | coef->MCU_vert_offset = yoffset; | 266 | 0 | coef->MCU_ctr = MCU_col_num; | 267 | | #ifdef WITH_PROFILE | 268 | | cinfo->master->entropy_elapsed += getTime() - cinfo->master->start; | 269 | | cinfo->master->entropy_mcoeffs += | 270 | | (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.; | 271 | | #endif | 272 | 0 | return JPEG_SUSPENDED; | 273 | 0 | } | 274 | | #ifdef WITH_PROFILE | 275 | | cinfo->master->entropy_elapsed += getTime() - cinfo->master->start; | 276 | | cinfo->master->entropy_mcoeffs += | 277 | | (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.; | 278 | | #endif | 279 | 253M | } | 280 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 281 | 10.0M | coef->MCU_ctr = 0; | 282 | 10.0M | } | 283 | | /* Completed the iMCU row, advance counters for next one */ | 284 | 7.01M | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 285 | 6.94M | start_iMCU_row(cinfo); | 286 | 6.94M | return JPEG_ROW_COMPLETED; | 287 | 6.94M | } | 288 | | /* Completed the scan */ | 289 | 64.4k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 290 | 64.4k | return JPEG_SCAN_COMPLETED; | 291 | 7.01M | } |
jdcoefct-12.c:consume_data Line | Count | Source | 218 | 3.67M | { | 219 | 3.67M | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; | 220 | 3.67M | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 221 | 3.67M | int blkn, ci, xindex, yindex, yoffset; | 222 | 3.67M | JDIMENSION start_col; | 223 | 3.67M | JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; | 224 | 3.67M | JBLOCKROW buffer_ptr; | 225 | 3.67M | jpeg_component_info *compptr; | 226 | | | 227 | | /* Align the virtual buffers for the components used in this scan. */ | 228 | 14.7M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 229 | 11.0M | compptr = cinfo->cur_comp_info[ci]; | 230 | 11.0M | buffer[ci] = (*cinfo->mem->access_virt_barray) | 231 | 11.0M | ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index], | 232 | 11.0M | cinfo->input_iMCU_row * compptr->v_samp_factor, | 233 | 11.0M | (JDIMENSION)compptr->v_samp_factor, TRUE); | 234 | | /* Note: entropy decoder expects buffer to be zeroed, | 235 | | * but this is handled automatically by the memory manager | 236 | | * because we requested a pre-zeroed array. | 237 | | */ | 238 | 11.0M | } | 239 | | | 240 | | /* Loop to process one whole iMCU row */ | 241 | 7.80M | for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; | 242 | 4.12M | yoffset++) { | 243 | 57.2M | for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; | 244 | 53.1M | MCU_col_num++) { | 245 | | /* Construct list of pointers to DCT blocks belonging to this MCU */ | 246 | 53.1M | blkn = 0; /* index of current DCT block within MCU */ | 247 | 149M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 248 | 96.8M | compptr = cinfo->cur_comp_info[ci]; | 249 | 96.8M | start_col = MCU_col_num * compptr->MCU_width; | 250 | 219M | for (yindex = 0; yindex < compptr->MCU_height; yindex++) { | 251 | 122M | buffer_ptr = buffer[ci][yindex + yoffset] + start_col; | 252 | 260M | for (xindex = 0; xindex < compptr->MCU_width; xindex++) { | 253 | 138M | coef->MCU_buffer[blkn++] = buffer_ptr++; | 254 | 138M | } | 255 | 122M | } | 256 | 96.8M | } | 257 | 53.1M | if (!cinfo->entropy->insufficient_data) | 258 | 53.1M | cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row; | 259 | | /* Try to fetch the MCU. */ | 260 | | #ifdef WITH_PROFILE | 261 | | cinfo->master->start = getTime(); | 262 | | #endif | 263 | 53.1M | if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { | 264 | | /* Suspension forced; update state counters and exit */ | 265 | 0 | coef->MCU_vert_offset = yoffset; | 266 | 0 | coef->MCU_ctr = MCU_col_num; | 267 | | #ifdef WITH_PROFILE | 268 | | cinfo->master->entropy_elapsed += getTime() - cinfo->master->start; | 269 | | cinfo->master->entropy_mcoeffs += | 270 | | (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.; | 271 | | #endif | 272 | 0 | return JPEG_SUSPENDED; | 273 | 0 | } | 274 | | #ifdef WITH_PROFILE | 275 | | cinfo->master->entropy_elapsed += getTime() - cinfo->master->start; | 276 | | cinfo->master->entropy_mcoeffs += | 277 | | (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.; | 278 | | #endif | 279 | 53.1M | } | 280 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 281 | 4.12M | coef->MCU_ctr = 0; | 282 | 4.12M | } | 283 | | /* Completed the iMCU row, advance counters for next one */ | 284 | 3.67M | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 285 | 3.66M | start_iMCU_row(cinfo); | 286 | 3.66M | return JPEG_ROW_COMPLETED; | 287 | 3.66M | } | 288 | | /* Completed the scan */ | 289 | 10.7k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 290 | 10.7k | return JPEG_SCAN_COMPLETED; | 291 | 3.67M | } |
|
292 | | |
293 | | |
294 | | /* |
295 | | * Decompress and return some data in the multi-pass case. |
296 | | * Always attempts to emit one fully interleaved MCU row ("iMCU" row). |
297 | | * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. |
298 | | * |
299 | | * NB: output_buf contains a plane for each component in image. |
300 | | */ |
301 | | |
302 | | METHODDEF(int) |
303 | | decompress_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf) |
304 | 1.01M | { |
305 | 1.01M | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; |
306 | 1.01M | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
307 | 1.01M | JDIMENSION block_num; |
308 | 1.01M | int ci, block_row, block_rows; |
309 | 1.01M | JBLOCKARRAY buffer; |
310 | 1.01M | JBLOCKROW buffer_ptr; |
311 | 1.01M | _JSAMPARRAY output_ptr; |
312 | 1.01M | JDIMENSION output_col; |
313 | 1.01M | jpeg_component_info *compptr; |
314 | 1.01M | _inverse_DCT_method_ptr inverse_DCT; |
315 | | |
316 | | /* Force some input to be done if we are getting ahead of the input. */ |
317 | 1.01M | while (cinfo->input_scan_number < cinfo->output_scan_number || |
318 | 1.01M | (cinfo->input_scan_number == cinfo->output_scan_number && |
319 | 1.01M | cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { |
320 | 0 | if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) |
321 | 0 | return JPEG_SUSPENDED; |
322 | 0 | } |
323 | | |
324 | | /* OK, output from the virtual arrays. */ |
325 | 3.37M | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
326 | 2.35M | ci++, compptr++) { |
327 | | /* Don't bother to IDCT an uninteresting component. */ |
328 | 2.35M | if (!compptr->component_needed) |
329 | 0 | continue; |
330 | | /* Align the virtual buffer for this component. */ |
331 | 2.35M | buffer = (*cinfo->mem->access_virt_barray) |
332 | 2.35M | ((j_common_ptr)cinfo, coef->whole_image[ci], |
333 | 2.35M | cinfo->output_iMCU_row * compptr->v_samp_factor, |
334 | 2.35M | (JDIMENSION)compptr->v_samp_factor, FALSE); |
335 | | /* Count non-dummy DCT block rows in this iMCU row. */ |
336 | 2.35M | if (cinfo->output_iMCU_row < last_iMCU_row) |
337 | 2.34M | block_rows = compptr->v_samp_factor; |
338 | 12.2k | else { |
339 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ |
340 | 12.2k | block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); |
341 | 12.2k | if (block_rows == 0) block_rows = compptr->v_samp_factor; |
342 | 12.2k | } |
343 | 2.35M | inverse_DCT = cinfo->idct->_inverse_DCT[ci]; |
344 | 2.35M | output_ptr = output_buf[ci]; |
345 | | /* Loop over all DCT blocks to be processed. */ |
346 | 5.93M | for (block_row = 0; block_row < block_rows; block_row++) { |
347 | 3.58M | buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci]; |
348 | 3.58M | output_col = 0; |
349 | 3.58M | for (block_num = cinfo->master->first_MCU_col[ci]; |
350 | 47.2M | block_num <= cinfo->master->last_MCU_col[ci]; block_num++) { |
351 | | #ifdef WITH_PROFILE |
352 | | cinfo->master->start = getTime(); |
353 | | #endif |
354 | 43.6M | (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)buffer_ptr, output_ptr, |
355 | 43.6M | output_col); |
356 | | #ifdef WITH_PROFILE |
357 | | cinfo->master->idct_elapsed += getTime() - cinfo->master->start; |
358 | | cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.; |
359 | | #endif |
360 | 43.6M | buffer_ptr++; |
361 | 43.6M | output_col += compptr->_DCT_scaled_size; |
362 | 43.6M | } |
363 | 3.58M | output_ptr += compptr->_DCT_scaled_size; |
364 | 3.58M | } |
365 | 2.35M | } |
366 | | |
367 | 1.01M | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) |
368 | 1.01M | return JPEG_ROW_COMPLETED; |
369 | 4.32k | return JPEG_SCAN_COMPLETED; |
370 | 1.01M | } jdcoefct-8.c:decompress_data Line | Count | Source | 304 | 1.01M | { | 305 | 1.01M | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; | 306 | 1.01M | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 307 | 1.01M | JDIMENSION block_num; | 308 | 1.01M | int ci, block_row, block_rows; | 309 | 1.01M | JBLOCKARRAY buffer; | 310 | 1.01M | JBLOCKROW buffer_ptr; | 311 | 1.01M | _JSAMPARRAY output_ptr; | 312 | 1.01M | JDIMENSION output_col; | 313 | 1.01M | jpeg_component_info *compptr; | 314 | 1.01M | _inverse_DCT_method_ptr inverse_DCT; | 315 | | | 316 | | /* Force some input to be done if we are getting ahead of the input. */ | 317 | 1.01M | while (cinfo->input_scan_number < cinfo->output_scan_number || | 318 | 1.01M | (cinfo->input_scan_number == cinfo->output_scan_number && | 319 | 1.01M | cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { | 320 | 0 | if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) | 321 | 0 | return JPEG_SUSPENDED; | 322 | 0 | } | 323 | | | 324 | | /* OK, output from the virtual arrays. */ | 325 | 3.37M | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 326 | 2.35M | ci++, compptr++) { | 327 | | /* Don't bother to IDCT an uninteresting component. */ | 328 | 2.35M | if (!compptr->component_needed) | 329 | 0 | continue; | 330 | | /* Align the virtual buffer for this component. */ | 331 | 2.35M | buffer = (*cinfo->mem->access_virt_barray) | 332 | 2.35M | ((j_common_ptr)cinfo, coef->whole_image[ci], | 333 | 2.35M | cinfo->output_iMCU_row * compptr->v_samp_factor, | 334 | 2.35M | (JDIMENSION)compptr->v_samp_factor, FALSE); | 335 | | /* Count non-dummy DCT block rows in this iMCU row. */ | 336 | 2.35M | if (cinfo->output_iMCU_row < last_iMCU_row) | 337 | 2.34M | block_rows = compptr->v_samp_factor; | 338 | 12.2k | else { | 339 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ | 340 | 12.2k | block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); | 341 | 12.2k | if (block_rows == 0) block_rows = compptr->v_samp_factor; | 342 | 12.2k | } | 343 | 2.35M | inverse_DCT = cinfo->idct->_inverse_DCT[ci]; | 344 | 2.35M | output_ptr = output_buf[ci]; | 345 | | /* Loop over all DCT blocks to be processed. */ | 346 | 5.93M | for (block_row = 0; block_row < block_rows; block_row++) { | 347 | 3.58M | buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci]; | 348 | 3.58M | output_col = 0; | 349 | 3.58M | for (block_num = cinfo->master->first_MCU_col[ci]; | 350 | 47.2M | block_num <= cinfo->master->last_MCU_col[ci]; block_num++) { | 351 | | #ifdef WITH_PROFILE | 352 | | cinfo->master->start = getTime(); | 353 | | #endif | 354 | 43.6M | (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)buffer_ptr, output_ptr, | 355 | 43.6M | output_col); | 356 | | #ifdef WITH_PROFILE | 357 | | cinfo->master->idct_elapsed += getTime() - cinfo->master->start; | 358 | | cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.; | 359 | | #endif | 360 | 43.6M | buffer_ptr++; | 361 | 43.6M | output_col += compptr->_DCT_scaled_size; | 362 | 43.6M | } | 363 | 3.58M | output_ptr += compptr->_DCT_scaled_size; | 364 | 3.58M | } | 365 | 2.35M | } | 366 | | | 367 | 1.01M | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) | 368 | 1.01M | return JPEG_ROW_COMPLETED; | 369 | 4.32k | return JPEG_SCAN_COMPLETED; | 370 | 1.01M | } |
Unexecuted instantiation: jdcoefct-12.c:decompress_data |
371 | | |
372 | | #endif /* D_MULTISCAN_FILES_SUPPORTED */ |
373 | | |
374 | | |
375 | | #ifdef BLOCK_SMOOTHING_SUPPORTED |
376 | | |
377 | | /* |
378 | | * This code applies interblock smoothing; the first 9 AC coefficients are |
379 | | * estimated from the DC values of a DCT block and its 24 neighboring blocks. |
380 | | * We apply smoothing only for progressive JPEG decoding, and only if |
381 | | * the coefficients it can estimate are not yet known to full precision. |
382 | | */ |
383 | | |
384 | | /* Natural-order array positions of the first 9 zigzag-order coefficients */ |
385 | 3.00M | #define Q01_POS 1 |
386 | 3.00M | #define Q10_POS 8 |
387 | 3.00M | #define Q20_POS 16 |
388 | 3.00M | #define Q11_POS 9 |
389 | 3.00M | #define Q02_POS 2 |
390 | 2.43M | #define Q03_POS 3 |
391 | 2.43M | #define Q12_POS 10 |
392 | 2.42M | #define Q21_POS 17 |
393 | 2.42M | #define Q30_POS 24 |
394 | | |
395 | | /* |
396 | | * Determine whether block smoothing is applicable and safe. |
397 | | * We also latch the current states of the coef_bits[] entries for the |
398 | | * AC coefficients; otherwise, if the input side of the decompressor |
399 | | * advances into a new scan, we might think the coefficients are known |
400 | | * more accurately than they really are. |
401 | | */ |
402 | | |
403 | | LOCAL(boolean) |
404 | | smoothing_ok(j_decompress_ptr cinfo) |
405 | 11.8k | { |
406 | 11.8k | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; |
407 | 11.8k | boolean smoothing_useful = FALSE; |
408 | 11.8k | int ci, coefi; |
409 | 11.8k | jpeg_component_info *compptr; |
410 | 11.8k | JQUANT_TBL *qtable; |
411 | 11.8k | int *coef_bits, *prev_coef_bits; |
412 | 11.8k | int *coef_bits_latch, *prev_coef_bits_latch; |
413 | | |
414 | 11.8k | if (!cinfo->progressive_mode || cinfo->coef_bits == NULL) |
415 | 150 | return FALSE; |
416 | | |
417 | | /* Allocate latch area if not already done */ |
418 | 11.6k | if (coef->coef_bits_latch == NULL) |
419 | 11.6k | coef->coef_bits_latch = (int *) |
420 | 11.6k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
421 | 11.6k | cinfo->num_components * 2 * |
422 | 11.6k | (SAVED_COEFS * sizeof(int))); |
423 | 11.6k | coef_bits_latch = coef->coef_bits_latch; |
424 | 11.6k | prev_coef_bits_latch = |
425 | 11.6k | &coef->coef_bits_latch[cinfo->num_components * SAVED_COEFS]; |
426 | | |
427 | 35.6k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
428 | 26.8k | ci++, compptr++) { |
429 | | /* All components' quantization values must already be latched. */ |
430 | 26.8k | if ((qtable = compptr->quant_table) == NULL) |
431 | 329 | return FALSE; |
432 | | /* Verify DC & first 9 AC quantizers are nonzero to avoid zero-divide. */ |
433 | 26.5k | if (qtable->quantval[0] == 0 || |
434 | 26.2k | qtable->quantval[Q01_POS] == 0 || |
435 | 25.9k | qtable->quantval[Q10_POS] == 0 || |
436 | 25.6k | qtable->quantval[Q20_POS] == 0 || |
437 | 25.4k | qtable->quantval[Q11_POS] == 0 || |
438 | 25.0k | qtable->quantval[Q02_POS] == 0 || |
439 | 24.9k | qtable->quantval[Q03_POS] == 0 || |
440 | 24.5k | qtable->quantval[Q12_POS] == 0 || |
441 | 24.3k | qtable->quantval[Q21_POS] == 0 || |
442 | 24.1k | qtable->quantval[Q30_POS] == 0) |
443 | 2.60k | return FALSE; |
444 | | /* DC values must be at least partly known for all components. */ |
445 | 23.9k | coef_bits = cinfo->coef_bits[ci]; |
446 | 23.9k | prev_coef_bits = cinfo->coef_bits[ci + cinfo->num_components]; |
447 | 23.9k | if (coef_bits[0] < 0) |
448 | 0 | return FALSE; |
449 | 23.9k | coef_bits_latch[0] = coef_bits[0]; |
450 | | /* Block smoothing is helpful if some AC coefficients remain inaccurate. */ |
451 | 239k | for (coefi = 1; coefi < SAVED_COEFS; coefi++) { |
452 | 215k | if (cinfo->input_scan_number > 1) |
453 | 137k | prev_coef_bits_latch[coefi] = prev_coef_bits[coefi]; |
454 | 77.9k | else |
455 | 77.9k | prev_coef_bits_latch[coefi] = -1; |
456 | 215k | coef_bits_latch[coefi] = coef_bits[coefi]; |
457 | 215k | if (coef_bits[coefi] != 0) |
458 | 154k | smoothing_useful = TRUE; |
459 | 215k | } |
460 | 23.9k | coef_bits_latch += SAVED_COEFS; |
461 | 23.9k | prev_coef_bits_latch += SAVED_COEFS; |
462 | 23.9k | } |
463 | | |
464 | 8.76k | return smoothing_useful; |
465 | 11.6k | } jdcoefct-8.c:smoothing_ok Line | Count | Source | 405 | 10.6k | { | 406 | 10.6k | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; | 407 | 10.6k | boolean smoothing_useful = FALSE; | 408 | 10.6k | int ci, coefi; | 409 | 10.6k | jpeg_component_info *compptr; | 410 | 10.6k | JQUANT_TBL *qtable; | 411 | 10.6k | int *coef_bits, *prev_coef_bits; | 412 | 10.6k | int *coef_bits_latch, *prev_coef_bits_latch; | 413 | | | 414 | 10.6k | if (!cinfo->progressive_mode || cinfo->coef_bits == NULL) | 415 | 101 | return FALSE; | 416 | | | 417 | | /* Allocate latch area if not already done */ | 418 | 10.5k | if (coef->coef_bits_latch == NULL) | 419 | 10.5k | coef->coef_bits_latch = (int *) | 420 | 10.5k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 421 | 10.5k | cinfo->num_components * 2 * | 422 | 10.5k | (SAVED_COEFS * sizeof(int))); | 423 | 10.5k | coef_bits_latch = coef->coef_bits_latch; | 424 | 10.5k | prev_coef_bits_latch = | 425 | 10.5k | &coef->coef_bits_latch[cinfo->num_components * SAVED_COEFS]; | 426 | | | 427 | 33.3k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 428 | 24.9k | ci++, compptr++) { | 429 | | /* All components' quantization values must already be latched. */ | 430 | 24.9k | if ((qtable = compptr->quant_table) == NULL) | 431 | 266 | return FALSE; | 432 | | /* Verify DC & first 9 AC quantizers are nonzero to avoid zero-divide. */ | 433 | 24.6k | if (qtable->quantval[0] == 0 || | 434 | 24.4k | qtable->quantval[Q01_POS] == 0 || | 435 | 24.2k | qtable->quantval[Q10_POS] == 0 || | 436 | 24.0k | qtable->quantval[Q20_POS] == 0 || | 437 | 23.9k | qtable->quantval[Q11_POS] == 0 || | 438 | 23.6k | qtable->quantval[Q02_POS] == 0 || | 439 | 23.5k | qtable->quantval[Q03_POS] == 0 || | 440 | 23.1k | qtable->quantval[Q12_POS] == 0 || | 441 | 23.0k | qtable->quantval[Q21_POS] == 0 || | 442 | 22.9k | qtable->quantval[Q30_POS] == 0) | 443 | 1.89k | return FALSE; | 444 | | /* DC values must be at least partly known for all components. */ | 445 | 22.7k | coef_bits = cinfo->coef_bits[ci]; | 446 | 22.7k | prev_coef_bits = cinfo->coef_bits[ci + cinfo->num_components]; | 447 | 22.7k | if (coef_bits[0] < 0) | 448 | 0 | return FALSE; | 449 | 22.7k | coef_bits_latch[0] = coef_bits[0]; | 450 | | /* Block smoothing is helpful if some AC coefficients remain inaccurate. */ | 451 | 227k | for (coefi = 1; coefi < SAVED_COEFS; coefi++) { | 452 | 205k | if (cinfo->input_scan_number > 1) | 453 | 133k | prev_coef_bits_latch[coefi] = prev_coef_bits[coefi]; | 454 | 71.9k | else | 455 | 71.9k | prev_coef_bits_latch[coefi] = -1; | 456 | 205k | coef_bits_latch[coefi] = coef_bits[coefi]; | 457 | 205k | if (coef_bits[coefi] != 0) | 458 | 145k | smoothing_useful = TRUE; | 459 | 205k | } | 460 | 22.7k | coef_bits_latch += SAVED_COEFS; | 461 | 22.7k | prev_coef_bits_latch += SAVED_COEFS; | 462 | 22.7k | } | 463 | | | 464 | 8.41k | return smoothing_useful; | 465 | 10.5k | } |
jdcoefct-12.c:smoothing_ok Line | Count | Source | 405 | 1.16k | { | 406 | 1.16k | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; | 407 | 1.16k | boolean smoothing_useful = FALSE; | 408 | 1.16k | int ci, coefi; | 409 | 1.16k | jpeg_component_info *compptr; | 410 | 1.16k | JQUANT_TBL *qtable; | 411 | 1.16k | int *coef_bits, *prev_coef_bits; | 412 | 1.16k | int *coef_bits_latch, *prev_coef_bits_latch; | 413 | | | 414 | 1.16k | if (!cinfo->progressive_mode || cinfo->coef_bits == NULL) | 415 | 49 | return FALSE; | 416 | | | 417 | | /* Allocate latch area if not already done */ | 418 | 1.11k | if (coef->coef_bits_latch == NULL) | 419 | 1.11k | coef->coef_bits_latch = (int *) | 420 | 1.11k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 421 | 1.11k | cinfo->num_components * 2 * | 422 | 1.11k | (SAVED_COEFS * sizeof(int))); | 423 | 1.11k | coef_bits_latch = coef->coef_bits_latch; | 424 | 1.11k | prev_coef_bits_latch = | 425 | 1.11k | &coef->coef_bits_latch[cinfo->num_components * SAVED_COEFS]; | 426 | | | 427 | 2.23k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 428 | 1.88k | ci++, compptr++) { | 429 | | /* All components' quantization values must already be latched. */ | 430 | 1.88k | if ((qtable = compptr->quant_table) == NULL) | 431 | 63 | return FALSE; | 432 | | /* Verify DC & first 9 AC quantizers are nonzero to avoid zero-divide. */ | 433 | 1.82k | if (qtable->quantval[0] == 0 || | 434 | 1.77k | qtable->quantval[Q01_POS] == 0 || | 435 | 1.73k | qtable->quantval[Q10_POS] == 0 || | 436 | 1.60k | qtable->quantval[Q20_POS] == 0 || | 437 | 1.55k | qtable->quantval[Q11_POS] == 0 || | 438 | 1.45k | qtable->quantval[Q02_POS] == 0 || | 439 | 1.39k | qtable->quantval[Q03_POS] == 0 || | 440 | 1.32k | qtable->quantval[Q12_POS] == 0 || | 441 | 1.26k | qtable->quantval[Q21_POS] == 0 || | 442 | 1.19k | qtable->quantval[Q30_POS] == 0) | 443 | 706 | return FALSE; | 444 | | /* DC values must be at least partly known for all components. */ | 445 | 1.11k | coef_bits = cinfo->coef_bits[ci]; | 446 | 1.11k | prev_coef_bits = cinfo->coef_bits[ci + cinfo->num_components]; | 447 | 1.11k | if (coef_bits[0] < 0) | 448 | 0 | return FALSE; | 449 | 1.11k | coef_bits_latch[0] = coef_bits[0]; | 450 | | /* Block smoothing is helpful if some AC coefficients remain inaccurate. */ | 451 | 11.1k | for (coefi = 1; coefi < SAVED_COEFS; coefi++) { | 452 | 10.0k | if (cinfo->input_scan_number > 1) | 453 | 4.03k | prev_coef_bits_latch[coefi] = prev_coef_bits[coefi]; | 454 | 5.99k | else | 455 | 5.99k | prev_coef_bits_latch[coefi] = -1; | 456 | 10.0k | coef_bits_latch[coefi] = coef_bits[coefi]; | 457 | 10.0k | if (coef_bits[coefi] != 0) | 458 | 8.91k | smoothing_useful = TRUE; | 459 | 10.0k | } | 460 | 1.11k | coef_bits_latch += SAVED_COEFS; | 461 | 1.11k | prev_coef_bits_latch += SAVED_COEFS; | 462 | 1.11k | } | 463 | | | 464 | 348 | return smoothing_useful; | 465 | 1.11k | } |
|
466 | | |
467 | | |
468 | | /* |
469 | | * Variant of decompress_data for use when doing block smoothing. |
470 | | */ |
471 | | |
472 | | METHODDEF(int) |
473 | | decompress_smooth_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf) |
474 | 1.51M | { |
475 | 1.51M | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; |
476 | 1.51M | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
477 | 1.51M | JDIMENSION block_num, last_block_column; |
478 | 1.51M | int ci, block_row, block_rows, access_rows, image_block_row, |
479 | 1.51M | image_block_rows; |
480 | 1.51M | JBLOCKARRAY buffer; |
481 | 1.51M | JBLOCKROW buffer_ptr, prev_prev_block_row, prev_block_row; |
482 | 1.51M | JBLOCKROW next_block_row, next_next_block_row; |
483 | 1.51M | _JSAMPARRAY output_ptr; |
484 | 1.51M | JDIMENSION output_col; |
485 | 1.51M | jpeg_component_info *compptr; |
486 | 1.51M | _inverse_DCT_method_ptr inverse_DCT; |
487 | 1.51M | boolean change_dc; |
488 | 1.51M | JCOEF *workspace; |
489 | 1.51M | int *coef_bits; |
490 | 1.51M | JQUANT_TBL *quanttbl; |
491 | 1.51M | JLONG Q00, Q01, Q02, Q03 = 0, Q10, Q11, Q12 = 0, Q20, Q21 = 0, Q30 = 0, num; |
492 | 1.51M | int DC01, DC02, DC03, DC04, DC05, DC06, DC07, DC08, DC09, DC10, DC11, DC12, |
493 | 1.51M | DC13, DC14, DC15, DC16, DC17, DC18, DC19, DC20, DC21, DC22, DC23, DC24, |
494 | 1.51M | DC25; |
495 | 1.51M | int Al, pred; |
496 | | |
497 | | /* Keep a local variable to avoid looking it up more than once */ |
498 | 1.51M | workspace = coef->workspace; |
499 | | |
500 | | /* Force some input to be done if we are getting ahead of the input. */ |
501 | 1.51M | while (cinfo->input_scan_number <= cinfo->output_scan_number && |
502 | 1.51M | !cinfo->inputctl->eoi_reached) { |
503 | 0 | if (cinfo->input_scan_number == cinfo->output_scan_number) { |
504 | | /* If input is working on current scan, we ordinarily want it to |
505 | | * have completed the current row. But if input scan is DC, |
506 | | * we want it to keep two rows ahead so that next two block rows' DC |
507 | | * values are up to date. |
508 | | */ |
509 | 0 | JDIMENSION delta = (cinfo->Ss == 0) ? 2 : 0; |
510 | 0 | if (cinfo->input_iMCU_row > cinfo->output_iMCU_row + delta) |
511 | 0 | break; |
512 | 0 | } |
513 | 0 | if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) |
514 | 0 | return JPEG_SUSPENDED; |
515 | 0 | } |
516 | | |
517 | | /* OK, output from the virtual arrays. */ |
518 | 4.49M | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
519 | 2.98M | ci++, compptr++) { |
520 | | /* Don't bother to IDCT an uninteresting component. */ |
521 | 2.98M | if (!compptr->component_needed) |
522 | 0 | continue; |
523 | | /* Count non-dummy DCT block rows in this iMCU row. */ |
524 | 2.98M | if (cinfo->output_iMCU_row + 1 < last_iMCU_row) { |
525 | 2.95M | block_rows = compptr->v_samp_factor; |
526 | 2.95M | access_rows = block_rows * 3; /* this and next two iMCU rows */ |
527 | 2.95M | } else if (cinfo->output_iMCU_row < last_iMCU_row) { |
528 | 13.8k | block_rows = compptr->v_samp_factor; |
529 | 13.8k | access_rows = block_rows * 2; /* this and next iMCU row */ |
530 | 16.2k | } else { |
531 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ |
532 | 16.2k | block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); |
533 | 16.2k | if (block_rows == 0) block_rows = compptr->v_samp_factor; |
534 | 16.2k | access_rows = block_rows; /* this iMCU row only */ |
535 | 16.2k | } |
536 | | /* Align the virtual buffer for this component. */ |
537 | 2.98M | if (cinfo->output_iMCU_row > 1) { |
538 | 2.95M | access_rows += 2 * compptr->v_samp_factor; /* prior two iMCU rows too */ |
539 | 2.95M | buffer = (*cinfo->mem->access_virt_barray) |
540 | 2.95M | ((j_common_ptr)cinfo, coef->whole_image[ci], |
541 | 2.95M | (cinfo->output_iMCU_row - 2) * compptr->v_samp_factor, |
542 | 2.95M | (JDIMENSION)access_rows, FALSE); |
543 | 2.95M | buffer += 2 * compptr->v_samp_factor; /* point to current iMCU row */ |
544 | 2.95M | } else if (cinfo->output_iMCU_row > 0) { |
545 | 13.8k | access_rows += compptr->v_samp_factor; /* prior iMCU row too */ |
546 | 13.8k | buffer = (*cinfo->mem->access_virt_barray) |
547 | 13.8k | ((j_common_ptr)cinfo, coef->whole_image[ci], |
548 | 13.8k | (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor, |
549 | 13.8k | (JDIMENSION)access_rows, FALSE); |
550 | 13.8k | buffer += compptr->v_samp_factor; /* point to current iMCU row */ |
551 | 16.2k | } else { |
552 | 16.2k | buffer = (*cinfo->mem->access_virt_barray) |
553 | 16.2k | ((j_common_ptr)cinfo, coef->whole_image[ci], |
554 | 16.2k | (JDIMENSION)0, (JDIMENSION)access_rows, FALSE); |
555 | 16.2k | } |
556 | | /* Fetch component-dependent info. |
557 | | * If the current scan is incomplete, then we use the component-dependent |
558 | | * info from the previous scan. |
559 | | */ |
560 | 2.98M | if (cinfo->output_iMCU_row > cinfo->master->last_good_iMCU_row) |
561 | 0 | coef_bits = |
562 | 0 | coef->coef_bits_latch + ((ci + cinfo->num_components) * SAVED_COEFS); |
563 | 2.98M | else |
564 | 2.98M | coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS); |
565 | | |
566 | | /* We only do DC interpolation if no AC coefficient data is available. */ |
567 | 2.98M | change_dc = |
568 | 2.98M | coef_bits[1] == -1 && coef_bits[2] == -1 && coef_bits[3] == -1 && |
569 | 2.57M | coef_bits[4] == -1 && coef_bits[5] == -1 && coef_bits[6] == -1 && |
570 | 2.45M | coef_bits[7] == -1 && coef_bits[8] == -1 && coef_bits[9] == -1; |
571 | | |
572 | 2.98M | quanttbl = compptr->quant_table; |
573 | 2.98M | Q00 = quanttbl->quantval[0]; |
574 | 2.98M | Q01 = quanttbl->quantval[Q01_POS]; |
575 | 2.98M | Q10 = quanttbl->quantval[Q10_POS]; |
576 | 2.98M | Q20 = quanttbl->quantval[Q20_POS]; |
577 | 2.98M | Q11 = quanttbl->quantval[Q11_POS]; |
578 | 2.98M | Q02 = quanttbl->quantval[Q02_POS]; |
579 | 2.98M | if (change_dc) { |
580 | 2.40M | Q03 = quanttbl->quantval[Q03_POS]; |
581 | 2.40M | Q12 = quanttbl->quantval[Q12_POS]; |
582 | 2.40M | Q21 = quanttbl->quantval[Q21_POS]; |
583 | 2.40M | Q30 = quanttbl->quantval[Q30_POS]; |
584 | 2.40M | } |
585 | 2.98M | inverse_DCT = cinfo->idct->_inverse_DCT[ci]; |
586 | 2.98M | output_ptr = output_buf[ci]; |
587 | | /* Loop over all DCT blocks to be processed. */ |
588 | 2.98M | image_block_rows = block_rows * cinfo->total_iMCU_rows; |
589 | 7.92M | for (block_row = 0; block_row < block_rows; block_row++) { |
590 | 4.94M | image_block_row = cinfo->output_iMCU_row * block_rows + block_row; |
591 | 4.94M | buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci]; |
592 | | |
593 | 4.94M | if (image_block_row > 0) |
594 | 4.92M | prev_block_row = |
595 | 4.92M | buffer[block_row - 1] + cinfo->master->first_MCU_col[ci]; |
596 | 16.2k | else |
597 | 16.2k | prev_block_row = buffer_ptr; |
598 | | |
599 | 4.94M | if (image_block_row > 1) |
600 | 4.91M | prev_prev_block_row = |
601 | 4.91M | buffer[block_row - 2] + cinfo->master->first_MCU_col[ci]; |
602 | 30.6k | else |
603 | 30.6k | prev_prev_block_row = prev_block_row; |
604 | | |
605 | 4.94M | if (image_block_row < image_block_rows - 1) |
606 | 4.92M | next_block_row = |
607 | 4.92M | buffer[block_row + 1] + cinfo->master->first_MCU_col[ci]; |
608 | 16.2k | else |
609 | 16.2k | next_block_row = buffer_ptr; |
610 | | |
611 | 4.94M | if (image_block_row < image_block_rows - 2) |
612 | 4.91M | next_next_block_row = |
613 | 4.91M | buffer[block_row + 2] + cinfo->master->first_MCU_col[ci]; |
614 | 26.7k | else |
615 | 26.7k | next_next_block_row = next_block_row; |
616 | | |
617 | | /* We fetch the surrounding DC values using a sliding-register approach. |
618 | | * Initialize all 25 here so as to do the right thing on narrow pics. |
619 | | */ |
620 | 4.94M | DC01 = DC02 = DC03 = DC04 = DC05 = (int)prev_prev_block_row[0][0]; |
621 | 4.94M | DC06 = DC07 = DC08 = DC09 = DC10 = (int)prev_block_row[0][0]; |
622 | 4.94M | DC11 = DC12 = DC13 = DC14 = DC15 = (int)buffer_ptr[0][0]; |
623 | 4.94M | DC16 = DC17 = DC18 = DC19 = DC20 = (int)next_block_row[0][0]; |
624 | 4.94M | DC21 = DC22 = DC23 = DC24 = DC25 = (int)next_next_block_row[0][0]; |
625 | 4.94M | output_col = 0; |
626 | 4.94M | last_block_column = compptr->width_in_blocks - 1; |
627 | 4.94M | for (block_num = cinfo->master->first_MCU_col[ci]; |
628 | 128M | block_num <= cinfo->master->last_MCU_col[ci]; block_num++) { |
629 | | /* Fetch current DCT block into workspace so we can modify it. */ |
630 | 123M | jcopy_block_row(buffer_ptr, (JBLOCKROW)workspace, (JDIMENSION)1); |
631 | | /* Update DC values */ |
632 | 123M | if (block_num == cinfo->master->first_MCU_col[ci] && |
633 | 4.94M | block_num < last_block_column) { |
634 | 3.80M | DC04 = DC05 = (int)prev_prev_block_row[1][0]; |
635 | 3.80M | DC09 = DC10 = (int)prev_block_row[1][0]; |
636 | 3.80M | DC14 = DC15 = (int)buffer_ptr[1][0]; |
637 | 3.80M | DC19 = DC20 = (int)next_block_row[1][0]; |
638 | 3.80M | DC24 = DC25 = (int)next_next_block_row[1][0]; |
639 | 3.80M | } |
640 | 123M | if (block_num + 1 < last_block_column) { |
641 | 115M | DC05 = (int)prev_prev_block_row[2][0]; |
642 | 115M | DC10 = (int)prev_block_row[2][0]; |
643 | 115M | DC15 = (int)buffer_ptr[2][0]; |
644 | 115M | DC20 = (int)next_block_row[2][0]; |
645 | 115M | DC25 = (int)next_next_block_row[2][0]; |
646 | 115M | } |
647 | | /* If DC interpolation is enabled, compute coefficient estimates using |
648 | | * a Gaussian-like kernel, keeping the averages of the DC values. |
649 | | * |
650 | | * If DC interpolation is disabled, compute coefficient estimates using |
651 | | * an algorithm similar to the one described in Section K.8 of the JPEG |
652 | | * standard, except applied to a 5x5 window rather than a 3x3 window. |
653 | | * |
654 | | * An estimate is applied only if the coefficient is still zero and is |
655 | | * not known to be fully accurate. |
656 | | */ |
657 | | /* AC01 */ |
658 | 123M | if ((Al = coef_bits[1]) != 0 && workspace[1] == 0) { |
659 | 118M | num = Q00 * (change_dc ? |
660 | 95.9M | (-DC01 - DC02 + DC04 + DC05 - 3 * DC06 + 13 * DC07 - |
661 | 95.9M | 13 * DC09 + 3 * DC10 - 3 * DC11 + 38 * DC12 - 38 * DC14 + |
662 | 95.9M | 3 * DC15 - 3 * DC16 + 13 * DC17 - 13 * DC19 + 3 * DC20 - |
663 | 95.9M | DC21 - DC22 + DC24 + DC25) : |
664 | 118M | (-7 * DC11 + 50 * DC12 - 50 * DC14 + 7 * DC15)); |
665 | 118M | if (num >= 0) { |
666 | 74.7M | pred = (int)(((Q01 << 7) + num) / (Q01 << 8)); |
667 | 74.7M | if (Al > 0 && pred >= (1 << Al)) |
668 | 1.74M | pred = (1 << Al) - 1; |
669 | 74.7M | } else { |
670 | 43.9M | pred = (int)(((Q01 << 7) - num) / (Q01 << 8)); |
671 | 43.9M | if (Al > 0 && pred >= (1 << Al)) |
672 | 2.11M | pred = (1 << Al) - 1; |
673 | 43.9M | pred = -pred; |
674 | 43.9M | } |
675 | 118M | workspace[1] = (JCOEF)pred; |
676 | 118M | } |
677 | | /* AC10 */ |
678 | 123M | if ((Al = coef_bits[2]) != 0 && workspace[8] == 0) { |
679 | 119M | num = Q00 * (change_dc ? |
680 | 95.9M | (-DC01 - 3 * DC02 - 3 * DC03 - 3 * DC04 - DC05 - DC06 + |
681 | 95.9M | 13 * DC07 + 38 * DC08 + 13 * DC09 - DC10 + DC16 - |
682 | 95.9M | 13 * DC17 - 38 * DC18 - 13 * DC19 + DC20 + DC21 + |
683 | 95.9M | 3 * DC22 + 3 * DC23 + 3 * DC24 + DC25) : |
684 | 119M | (-7 * DC03 + 50 * DC08 - 50 * DC18 + 7 * DC23)); |
685 | 119M | if (num >= 0) { |
686 | 74.8M | pred = (int)(((Q10 << 7) + num) / (Q10 << 8)); |
687 | 74.8M | if (Al > 0 && pred >= (1 << Al)) |
688 | 5.84M | pred = (1 << Al) - 1; |
689 | 74.8M | } else { |
690 | 44.6M | pred = (int)(((Q10 << 7) - num) / (Q10 << 8)); |
691 | 44.6M | if (Al > 0 && pred >= (1 << Al)) |
692 | 4.63M | pred = (1 << Al) - 1; |
693 | 44.6M | pred = -pred; |
694 | 44.6M | } |
695 | 119M | workspace[8] = (JCOEF)pred; |
696 | 119M | } |
697 | | /* AC20 */ |
698 | 123M | if ((Al = coef_bits[3]) != 0 && workspace[16] == 0) { |
699 | 119M | num = Q00 * (change_dc ? |
700 | 95.9M | (DC03 + 2 * DC07 + 7 * DC08 + 2 * DC09 - 5 * DC12 - 14 * DC13 - |
701 | 95.9M | 5 * DC14 + 2 * DC17 + 7 * DC18 + 2 * DC19 + DC23) : |
702 | 119M | (-DC03 + 13 * DC08 - 24 * DC13 + 13 * DC18 - DC23)); |
703 | 119M | if (num >= 0) { |
704 | 70.9M | pred = (int)(((Q20 << 7) + num) / (Q20 << 8)); |
705 | 70.9M | if (Al > 0 && pred >= (1 << Al)) |
706 | 3.74M | pred = (1 << Al) - 1; |
707 | 70.9M | } else { |
708 | 48.1M | pred = (int)(((Q20 << 7) - num) / (Q20 << 8)); |
709 | 48.1M | if (Al > 0 && pred >= (1 << Al)) |
710 | 3.80M | pred = (1 << Al) - 1; |
711 | 48.1M | pred = -pred; |
712 | 48.1M | } |
713 | 119M | workspace[16] = (JCOEF)pred; |
714 | 119M | } |
715 | | /* AC11 */ |
716 | 123M | if ((Al = coef_bits[4]) != 0 && workspace[9] == 0) { |
717 | 119M | num = Q00 * (change_dc ? |
718 | 95.9M | (-DC01 + DC05 + 9 * DC07 - 9 * DC09 - 9 * DC17 + |
719 | 95.9M | 9 * DC19 + DC21 - DC25) : |
720 | 119M | (DC10 + DC16 - 10 * DC17 + 10 * DC19 - DC02 - DC20 + DC22 - |
721 | 23.3M | DC24 + DC04 - DC06 + 10 * DC07 - 10 * DC09)); |
722 | 119M | if (num >= 0) { |
723 | 92.3M | pred = (int)(((Q11 << 7) + num) / (Q11 << 8)); |
724 | 92.3M | if (Al > 0 && pred >= (1 << Al)) |
725 | 1.04M | pred = (1 << Al) - 1; |
726 | 92.3M | } else { |
727 | 26.9M | pred = (int)(((Q11 << 7) - num) / (Q11 << 8)); |
728 | 26.9M | if (Al > 0 && pred >= (1 << Al)) |
729 | 1.04M | pred = (1 << Al) - 1; |
730 | 26.9M | pred = -pred; |
731 | 26.9M | } |
732 | 119M | workspace[9] = (JCOEF)pred; |
733 | 119M | } |
734 | | /* AC02 */ |
735 | 123M | if ((Al = coef_bits[5]) != 0 && workspace[2] == 0) { |
736 | 119M | num = Q00 * (change_dc ? |
737 | 95.9M | (2 * DC07 - 5 * DC08 + 2 * DC09 + DC11 + 7 * DC12 - 14 * DC13 + |
738 | 95.9M | 7 * DC14 + DC15 + 2 * DC17 - 5 * DC18 + 2 * DC19) : |
739 | 119M | (-DC11 + 13 * DC12 - 24 * DC13 + 13 * DC14 - DC15)); |
740 | 119M | if (num >= 0) { |
741 | 71.7M | pred = (int)(((Q02 << 7) + num) / (Q02 << 8)); |
742 | 71.7M | if (Al > 0 && pred >= (1 << Al)) |
743 | 2.27M | pred = (1 << Al) - 1; |
744 | 71.7M | } else { |
745 | 47.5M | pred = (int)(((Q02 << 7) - num) / (Q02 << 8)); |
746 | 47.5M | if (Al > 0 && pred >= (1 << Al)) |
747 | 2.32M | pred = (1 << Al) - 1; |
748 | 47.5M | pred = -pred; |
749 | 47.5M | } |
750 | 119M | workspace[2] = (JCOEF)pred; |
751 | 119M | } |
752 | 123M | if (change_dc) { |
753 | | /* AC03 */ |
754 | 95.9M | if ((Al = coef_bits[6]) != 0 && workspace[3] == 0) { |
755 | 95.9M | num = Q00 * (DC07 - DC09 + 2 * DC12 - 2 * DC14 + DC17 - DC19); |
756 | 95.9M | if (num >= 0) { |
757 | 61.2M | pred = (int)(((Q03 << 7) + num) / (Q03 << 8)); |
758 | 61.2M | if (Al > 0 && pred >= (1 << Al)) |
759 | 0 | pred = (1 << Al) - 1; |
760 | 61.2M | } else { |
761 | 34.7M | pred = (int)(((Q03 << 7) - num) / (Q03 << 8)); |
762 | 34.7M | if (Al > 0 && pred >= (1 << Al)) |
763 | 0 | pred = (1 << Al) - 1; |
764 | 34.7M | pred = -pred; |
765 | 34.7M | } |
766 | 95.9M | workspace[3] = (JCOEF)pred; |
767 | 95.9M | } |
768 | | /* AC12 */ |
769 | 95.9M | if ((Al = coef_bits[7]) != 0 && workspace[10] == 0) { |
770 | 95.9M | num = Q00 * (DC07 - 3 * DC08 + DC09 - DC17 + 3 * DC18 - DC19); |
771 | 95.9M | if (num >= 0) { |
772 | 57.4M | pred = (int)(((Q12 << 7) + num) / (Q12 << 8)); |
773 | 57.4M | if (Al > 0 && pred >= (1 << Al)) |
774 | 0 | pred = (1 << Al) - 1; |
775 | 57.4M | } else { |
776 | 38.5M | pred = (int)(((Q12 << 7) - num) / (Q12 << 8)); |
777 | 38.5M | if (Al > 0 && pred >= (1 << Al)) |
778 | 0 | pred = (1 << Al) - 1; |
779 | 38.5M | pred = -pred; |
780 | 38.5M | } |
781 | 95.9M | workspace[10] = (JCOEF)pred; |
782 | 95.9M | } |
783 | | /* AC21 */ |
784 | 95.9M | if ((Al = coef_bits[8]) != 0 && workspace[17] == 0) { |
785 | 95.9M | num = Q00 * (DC07 - DC09 - 3 * DC12 + 3 * DC14 + DC17 - DC19); |
786 | 95.9M | if (num >= 0) { |
787 | 55.1M | pred = (int)(((Q21 << 7) + num) / (Q21 << 8)); |
788 | 55.1M | if (Al > 0 && pred >= (1 << Al)) |
789 | 0 | pred = (1 << Al) - 1; |
790 | 55.1M | } else { |
791 | 40.8M | pred = (int)(((Q21 << 7) - num) / (Q21 << 8)); |
792 | 40.8M | if (Al > 0 && pred >= (1 << Al)) |
793 | 0 | pred = (1 << Al) - 1; |
794 | 40.8M | pred = -pred; |
795 | 40.8M | } |
796 | 95.9M | workspace[17] = (JCOEF)pred; |
797 | 95.9M | } |
798 | | /* AC30 */ |
799 | 95.9M | if ((Al = coef_bits[9]) != 0 && workspace[24] == 0) { |
800 | 95.9M | num = Q00 * (DC07 + 2 * DC08 + DC09 - DC17 - 2 * DC18 - DC19); |
801 | 95.9M | if (num >= 0) { |
802 | 61.9M | pred = (int)(((Q30 << 7) + num) / (Q30 << 8)); |
803 | 61.9M | if (Al > 0 && pred >= (1 << Al)) |
804 | 0 | pred = (1 << Al) - 1; |
805 | 61.9M | } else { |
806 | 34.0M | pred = (int)(((Q30 << 7) - num) / (Q30 << 8)); |
807 | 34.0M | if (Al > 0 && pred >= (1 << Al)) |
808 | 0 | pred = (1 << Al) - 1; |
809 | 34.0M | pred = -pred; |
810 | 34.0M | } |
811 | 95.9M | workspace[24] = (JCOEF)pred; |
812 | 95.9M | } |
813 | | /* coef_bits[0] is non-negative. Otherwise this function would not |
814 | | * be called. |
815 | | */ |
816 | 95.9M | num = Q00 * |
817 | 95.9M | (-2 * DC01 - 6 * DC02 - 8 * DC03 - 6 * DC04 - 2 * DC05 - |
818 | 95.9M | 6 * DC06 + 6 * DC07 + 42 * DC08 + 6 * DC09 - 6 * DC10 - |
819 | 95.9M | 8 * DC11 + 42 * DC12 + 152 * DC13 + 42 * DC14 - 8 * DC15 - |
820 | 95.9M | 6 * DC16 + 6 * DC17 + 42 * DC18 + 6 * DC19 - 6 * DC20 - |
821 | 95.9M | 2 * DC21 - 6 * DC22 - 8 * DC23 - 6 * DC24 - 2 * DC25); |
822 | 95.9M | if (num >= 0) { |
823 | 47.6M | pred = (int)(((Q00 << 7) + num) / (Q00 << 8)); |
824 | 48.3M | } else { |
825 | 48.3M | pred = (int)(((Q00 << 7) - num) / (Q00 << 8)); |
826 | 48.3M | pred = -pred; |
827 | 48.3M | } |
828 | 95.9M | workspace[0] = (JCOEF)pred; |
829 | 95.9M | } /* change_dc */ |
830 | | |
831 | | /* OK, do the IDCT */ |
832 | | #ifdef WITH_PROFILE |
833 | | cinfo->master->start = getTime(); |
834 | | #endif |
835 | 123M | (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)workspace, output_ptr, |
836 | 123M | output_col); |
837 | | #ifdef WITH_PROFILE |
838 | | cinfo->master->idct_elapsed += getTime() - cinfo->master->start; |
839 | | cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.; |
840 | | #endif |
841 | | /* Advance for next column */ |
842 | 123M | DC01 = DC02; DC02 = DC03; DC03 = DC04; DC04 = DC05; |
843 | 123M | DC06 = DC07; DC07 = DC08; DC08 = DC09; DC09 = DC10; |
844 | 123M | DC11 = DC12; DC12 = DC13; DC13 = DC14; DC14 = DC15; |
845 | 123M | DC16 = DC17; DC17 = DC18; DC18 = DC19; DC19 = DC20; |
846 | 123M | DC21 = DC22; DC22 = DC23; DC23 = DC24; DC24 = DC25; |
847 | 123M | buffer_ptr++, prev_block_row++, next_block_row++, |
848 | 123M | prev_prev_block_row++, next_next_block_row++; |
849 | 123M | output_col += compptr->_DCT_scaled_size; |
850 | 123M | } |
851 | 4.94M | output_ptr += compptr->_DCT_scaled_size; |
852 | 4.94M | } |
853 | 2.98M | } |
854 | | |
855 | 1.51M | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) |
856 | 1.50M | return JPEG_ROW_COMPLETED; |
857 | 6.35k | return JPEG_SCAN_COMPLETED; |
858 | 1.51M | } jdcoefct-8.c:decompress_smooth_data Line | Count | Source | 474 | 1.51M | { | 475 | 1.51M | my_coef_ptr coef = (my_coef_ptr)cinfo->coef; | 476 | 1.51M | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 477 | 1.51M | JDIMENSION block_num, last_block_column; | 478 | 1.51M | int ci, block_row, block_rows, access_rows, image_block_row, | 479 | 1.51M | image_block_rows; | 480 | 1.51M | JBLOCKARRAY buffer; | 481 | 1.51M | JBLOCKROW buffer_ptr, prev_prev_block_row, prev_block_row; | 482 | 1.51M | JBLOCKROW next_block_row, next_next_block_row; | 483 | 1.51M | _JSAMPARRAY output_ptr; | 484 | 1.51M | JDIMENSION output_col; | 485 | 1.51M | jpeg_component_info *compptr; | 486 | 1.51M | _inverse_DCT_method_ptr inverse_DCT; | 487 | 1.51M | boolean change_dc; | 488 | 1.51M | JCOEF *workspace; | 489 | 1.51M | int *coef_bits; | 490 | 1.51M | JQUANT_TBL *quanttbl; | 491 | 1.51M | JLONG Q00, Q01, Q02, Q03 = 0, Q10, Q11, Q12 = 0, Q20, Q21 = 0, Q30 = 0, num; | 492 | 1.51M | int DC01, DC02, DC03, DC04, DC05, DC06, DC07, DC08, DC09, DC10, DC11, DC12, | 493 | 1.51M | DC13, DC14, DC15, DC16, DC17, DC18, DC19, DC20, DC21, DC22, DC23, DC24, | 494 | 1.51M | DC25; | 495 | 1.51M | int Al, pred; | 496 | | | 497 | | /* Keep a local variable to avoid looking it up more than once */ | 498 | 1.51M | workspace = coef->workspace; | 499 | | | 500 | | /* Force some input to be done if we are getting ahead of the input. */ | 501 | 1.51M | while (cinfo->input_scan_number <= cinfo->output_scan_number && | 502 | 1.51M | !cinfo->inputctl->eoi_reached) { | 503 | 0 | if (cinfo->input_scan_number == cinfo->output_scan_number) { | 504 | | /* If input is working on current scan, we ordinarily want it to | 505 | | * have completed the current row. But if input scan is DC, | 506 | | * we want it to keep two rows ahead so that next two block rows' DC | 507 | | * values are up to date. | 508 | | */ | 509 | 0 | JDIMENSION delta = (cinfo->Ss == 0) ? 2 : 0; | 510 | 0 | if (cinfo->input_iMCU_row > cinfo->output_iMCU_row + delta) | 511 | 0 | break; | 512 | 0 | } | 513 | 0 | if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) | 514 | 0 | return JPEG_SUSPENDED; | 515 | 0 | } | 516 | | | 517 | | /* OK, output from the virtual arrays. */ | 518 | 4.49M | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 519 | 2.98M | ci++, compptr++) { | 520 | | /* Don't bother to IDCT an uninteresting component. */ | 521 | 2.98M | if (!compptr->component_needed) | 522 | 0 | continue; | 523 | | /* Count non-dummy DCT block rows in this iMCU row. */ | 524 | 2.98M | if (cinfo->output_iMCU_row + 1 < last_iMCU_row) { | 525 | 2.95M | block_rows = compptr->v_samp_factor; | 526 | 2.95M | access_rows = block_rows * 3; /* this and next two iMCU rows */ | 527 | 2.95M | } else if (cinfo->output_iMCU_row < last_iMCU_row) { | 528 | 13.8k | block_rows = compptr->v_samp_factor; | 529 | 13.8k | access_rows = block_rows * 2; /* this and next iMCU row */ | 530 | 16.2k | } else { | 531 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ | 532 | 16.2k | block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); | 533 | 16.2k | if (block_rows == 0) block_rows = compptr->v_samp_factor; | 534 | 16.2k | access_rows = block_rows; /* this iMCU row only */ | 535 | 16.2k | } | 536 | | /* Align the virtual buffer for this component. */ | 537 | 2.98M | if (cinfo->output_iMCU_row > 1) { | 538 | 2.95M | access_rows += 2 * compptr->v_samp_factor; /* prior two iMCU rows too */ | 539 | 2.95M | buffer = (*cinfo->mem->access_virt_barray) | 540 | 2.95M | ((j_common_ptr)cinfo, coef->whole_image[ci], | 541 | 2.95M | (cinfo->output_iMCU_row - 2) * compptr->v_samp_factor, | 542 | 2.95M | (JDIMENSION)access_rows, FALSE); | 543 | 2.95M | buffer += 2 * compptr->v_samp_factor; /* point to current iMCU row */ | 544 | 2.95M | } else if (cinfo->output_iMCU_row > 0) { | 545 | 13.8k | access_rows += compptr->v_samp_factor; /* prior iMCU row too */ | 546 | 13.8k | buffer = (*cinfo->mem->access_virt_barray) | 547 | 13.8k | ((j_common_ptr)cinfo, coef->whole_image[ci], | 548 | 13.8k | (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor, | 549 | 13.8k | (JDIMENSION)access_rows, FALSE); | 550 | 13.8k | buffer += compptr->v_samp_factor; /* point to current iMCU row */ | 551 | 16.2k | } else { | 552 | 16.2k | buffer = (*cinfo->mem->access_virt_barray) | 553 | 16.2k | ((j_common_ptr)cinfo, coef->whole_image[ci], | 554 | 16.2k | (JDIMENSION)0, (JDIMENSION)access_rows, FALSE); | 555 | 16.2k | } | 556 | | /* Fetch component-dependent info. | 557 | | * If the current scan is incomplete, then we use the component-dependent | 558 | | * info from the previous scan. | 559 | | */ | 560 | 2.98M | if (cinfo->output_iMCU_row > cinfo->master->last_good_iMCU_row) | 561 | 0 | coef_bits = | 562 | 0 | coef->coef_bits_latch + ((ci + cinfo->num_components) * SAVED_COEFS); | 563 | 2.98M | else | 564 | 2.98M | coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS); | 565 | | | 566 | | /* We only do DC interpolation if no AC coefficient data is available. */ | 567 | 2.98M | change_dc = | 568 | 2.98M | coef_bits[1] == -1 && coef_bits[2] == -1 && coef_bits[3] == -1 && | 569 | 2.57M | coef_bits[4] == -1 && coef_bits[5] == -1 && coef_bits[6] == -1 && | 570 | 2.45M | coef_bits[7] == -1 && coef_bits[8] == -1 && coef_bits[9] == -1; | 571 | | | 572 | 2.98M | quanttbl = compptr->quant_table; | 573 | 2.98M | Q00 = quanttbl->quantval[0]; | 574 | 2.98M | Q01 = quanttbl->quantval[Q01_POS]; | 575 | 2.98M | Q10 = quanttbl->quantval[Q10_POS]; | 576 | 2.98M | Q20 = quanttbl->quantval[Q20_POS]; | 577 | 2.98M | Q11 = quanttbl->quantval[Q11_POS]; | 578 | 2.98M | Q02 = quanttbl->quantval[Q02_POS]; | 579 | 2.98M | if (change_dc) { | 580 | 2.40M | Q03 = quanttbl->quantval[Q03_POS]; | 581 | 2.40M | Q12 = quanttbl->quantval[Q12_POS]; | 582 | 2.40M | Q21 = quanttbl->quantval[Q21_POS]; | 583 | 2.40M | Q30 = quanttbl->quantval[Q30_POS]; | 584 | 2.40M | } | 585 | 2.98M | inverse_DCT = cinfo->idct->_inverse_DCT[ci]; | 586 | 2.98M | output_ptr = output_buf[ci]; | 587 | | /* Loop over all DCT blocks to be processed. */ | 588 | 2.98M | image_block_rows = block_rows * cinfo->total_iMCU_rows; | 589 | 7.92M | for (block_row = 0; block_row < block_rows; block_row++) { | 590 | 4.94M | image_block_row = cinfo->output_iMCU_row * block_rows + block_row; | 591 | 4.94M | buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci]; | 592 | | | 593 | 4.94M | if (image_block_row > 0) | 594 | 4.92M | prev_block_row = | 595 | 4.92M | buffer[block_row - 1] + cinfo->master->first_MCU_col[ci]; | 596 | 16.2k | else | 597 | 16.2k | prev_block_row = buffer_ptr; | 598 | | | 599 | 4.94M | if (image_block_row > 1) | 600 | 4.91M | prev_prev_block_row = | 601 | 4.91M | buffer[block_row - 2] + cinfo->master->first_MCU_col[ci]; | 602 | 30.6k | else | 603 | 30.6k | prev_prev_block_row = prev_block_row; | 604 | | | 605 | 4.94M | if (image_block_row < image_block_rows - 1) | 606 | 4.92M | next_block_row = | 607 | 4.92M | buffer[block_row + 1] + cinfo->master->first_MCU_col[ci]; | 608 | 16.2k | else | 609 | 16.2k | next_block_row = buffer_ptr; | 610 | | | 611 | 4.94M | if (image_block_row < image_block_rows - 2) | 612 | 4.91M | next_next_block_row = | 613 | 4.91M | buffer[block_row + 2] + cinfo->master->first_MCU_col[ci]; | 614 | 26.7k | else | 615 | 26.7k | next_next_block_row = next_block_row; | 616 | | | 617 | | /* We fetch the surrounding DC values using a sliding-register approach. | 618 | | * Initialize all 25 here so as to do the right thing on narrow pics. | 619 | | */ | 620 | 4.94M | DC01 = DC02 = DC03 = DC04 = DC05 = (int)prev_prev_block_row[0][0]; | 621 | 4.94M | DC06 = DC07 = DC08 = DC09 = DC10 = (int)prev_block_row[0][0]; | 622 | 4.94M | DC11 = DC12 = DC13 = DC14 = DC15 = (int)buffer_ptr[0][0]; | 623 | 4.94M | DC16 = DC17 = DC18 = DC19 = DC20 = (int)next_block_row[0][0]; | 624 | 4.94M | DC21 = DC22 = DC23 = DC24 = DC25 = (int)next_next_block_row[0][0]; | 625 | 4.94M | output_col = 0; | 626 | 4.94M | last_block_column = compptr->width_in_blocks - 1; | 627 | 4.94M | for (block_num = cinfo->master->first_MCU_col[ci]; | 628 | 128M | block_num <= cinfo->master->last_MCU_col[ci]; block_num++) { | 629 | | /* Fetch current DCT block into workspace so we can modify it. */ | 630 | 123M | jcopy_block_row(buffer_ptr, (JBLOCKROW)workspace, (JDIMENSION)1); | 631 | | /* Update DC values */ | 632 | 123M | if (block_num == cinfo->master->first_MCU_col[ci] && | 633 | 4.94M | block_num < last_block_column) { | 634 | 3.80M | DC04 = DC05 = (int)prev_prev_block_row[1][0]; | 635 | 3.80M | DC09 = DC10 = (int)prev_block_row[1][0]; | 636 | 3.80M | DC14 = DC15 = (int)buffer_ptr[1][0]; | 637 | 3.80M | DC19 = DC20 = (int)next_block_row[1][0]; | 638 | 3.80M | DC24 = DC25 = (int)next_next_block_row[1][0]; | 639 | 3.80M | } | 640 | 123M | if (block_num + 1 < last_block_column) { | 641 | 115M | DC05 = (int)prev_prev_block_row[2][0]; | 642 | 115M | DC10 = (int)prev_block_row[2][0]; | 643 | 115M | DC15 = (int)buffer_ptr[2][0]; | 644 | 115M | DC20 = (int)next_block_row[2][0]; | 645 | 115M | DC25 = (int)next_next_block_row[2][0]; | 646 | 115M | } | 647 | | /* If DC interpolation is enabled, compute coefficient estimates using | 648 | | * a Gaussian-like kernel, keeping the averages of the DC values. | 649 | | * | 650 | | * If DC interpolation is disabled, compute coefficient estimates using | 651 | | * an algorithm similar to the one described in Section K.8 of the JPEG | 652 | | * standard, except applied to a 5x5 window rather than a 3x3 window. | 653 | | * | 654 | | * An estimate is applied only if the coefficient is still zero and is | 655 | | * not known to be fully accurate. | 656 | | */ | 657 | | /* AC01 */ | 658 | 123M | if ((Al = coef_bits[1]) != 0 && workspace[1] == 0) { | 659 | 118M | num = Q00 * (change_dc ? | 660 | 95.9M | (-DC01 - DC02 + DC04 + DC05 - 3 * DC06 + 13 * DC07 - | 661 | 95.9M | 13 * DC09 + 3 * DC10 - 3 * DC11 + 38 * DC12 - 38 * DC14 + | 662 | 95.9M | 3 * DC15 - 3 * DC16 + 13 * DC17 - 13 * DC19 + 3 * DC20 - | 663 | 95.9M | DC21 - DC22 + DC24 + DC25) : | 664 | 118M | (-7 * DC11 + 50 * DC12 - 50 * DC14 + 7 * DC15)); | 665 | 118M | if (num >= 0) { | 666 | 74.7M | pred = (int)(((Q01 << 7) + num) / (Q01 << 8)); | 667 | 74.7M | if (Al > 0 && pred >= (1 << Al)) | 668 | 1.74M | pred = (1 << Al) - 1; | 669 | 74.7M | } else { | 670 | 43.9M | pred = (int)(((Q01 << 7) - num) / (Q01 << 8)); | 671 | 43.9M | if (Al > 0 && pred >= (1 << Al)) | 672 | 2.11M | pred = (1 << Al) - 1; | 673 | 43.9M | pred = -pred; | 674 | 43.9M | } | 675 | 118M | workspace[1] = (JCOEF)pred; | 676 | 118M | } | 677 | | /* AC10 */ | 678 | 123M | if ((Al = coef_bits[2]) != 0 && workspace[8] == 0) { | 679 | 119M | num = Q00 * (change_dc ? | 680 | 95.9M | (-DC01 - 3 * DC02 - 3 * DC03 - 3 * DC04 - DC05 - DC06 + | 681 | 95.9M | 13 * DC07 + 38 * DC08 + 13 * DC09 - DC10 + DC16 - | 682 | 95.9M | 13 * DC17 - 38 * DC18 - 13 * DC19 + DC20 + DC21 + | 683 | 95.9M | 3 * DC22 + 3 * DC23 + 3 * DC24 + DC25) : | 684 | 119M | (-7 * DC03 + 50 * DC08 - 50 * DC18 + 7 * DC23)); | 685 | 119M | if (num >= 0) { | 686 | 74.8M | pred = (int)(((Q10 << 7) + num) / (Q10 << 8)); | 687 | 74.8M | if (Al > 0 && pred >= (1 << Al)) | 688 | 5.84M | pred = (1 << Al) - 1; | 689 | 74.8M | } else { | 690 | 44.6M | pred = (int)(((Q10 << 7) - num) / (Q10 << 8)); | 691 | 44.6M | if (Al > 0 && pred >= (1 << Al)) | 692 | 4.63M | pred = (1 << Al) - 1; | 693 | 44.6M | pred = -pred; | 694 | 44.6M | } | 695 | 119M | workspace[8] = (JCOEF)pred; | 696 | 119M | } | 697 | | /* AC20 */ | 698 | 123M | if ((Al = coef_bits[3]) != 0 && workspace[16] == 0) { | 699 | 119M | num = Q00 * (change_dc ? | 700 | 95.9M | (DC03 + 2 * DC07 + 7 * DC08 + 2 * DC09 - 5 * DC12 - 14 * DC13 - | 701 | 95.9M | 5 * DC14 + 2 * DC17 + 7 * DC18 + 2 * DC19 + DC23) : | 702 | 119M | (-DC03 + 13 * DC08 - 24 * DC13 + 13 * DC18 - DC23)); | 703 | 119M | if (num >= 0) { | 704 | 70.9M | pred = (int)(((Q20 << 7) + num) / (Q20 << 8)); | 705 | 70.9M | if (Al > 0 && pred >= (1 << Al)) | 706 | 3.74M | pred = (1 << Al) - 1; | 707 | 70.9M | } else { | 708 | 48.1M | pred = (int)(((Q20 << 7) - num) / (Q20 << 8)); | 709 | 48.1M | if (Al > 0 && pred >= (1 << Al)) | 710 | 3.80M | pred = (1 << Al) - 1; | 711 | 48.1M | pred = -pred; | 712 | 48.1M | } | 713 | 119M | workspace[16] = (JCOEF)pred; | 714 | 119M | } | 715 | | /* AC11 */ | 716 | 123M | if ((Al = coef_bits[4]) != 0 && workspace[9] == 0) { | 717 | 119M | num = Q00 * (change_dc ? | 718 | 95.9M | (-DC01 + DC05 + 9 * DC07 - 9 * DC09 - 9 * DC17 + | 719 | 95.9M | 9 * DC19 + DC21 - DC25) : | 720 | 119M | (DC10 + DC16 - 10 * DC17 + 10 * DC19 - DC02 - DC20 + DC22 - | 721 | 23.3M | DC24 + DC04 - DC06 + 10 * DC07 - 10 * DC09)); | 722 | 119M | if (num >= 0) { | 723 | 92.3M | pred = (int)(((Q11 << 7) + num) / (Q11 << 8)); | 724 | 92.3M | if (Al > 0 && pred >= (1 << Al)) | 725 | 1.04M | pred = (1 << Al) - 1; | 726 | 92.3M | } else { | 727 | 26.9M | pred = (int)(((Q11 << 7) - num) / (Q11 << 8)); | 728 | 26.9M | if (Al > 0 && pred >= (1 << Al)) | 729 | 1.04M | pred = (1 << Al) - 1; | 730 | 26.9M | pred = -pred; | 731 | 26.9M | } | 732 | 119M | workspace[9] = (JCOEF)pred; | 733 | 119M | } | 734 | | /* AC02 */ | 735 | 123M | if ((Al = coef_bits[5]) != 0 && workspace[2] == 0) { | 736 | 119M | num = Q00 * (change_dc ? | 737 | 95.9M | (2 * DC07 - 5 * DC08 + 2 * DC09 + DC11 + 7 * DC12 - 14 * DC13 + | 738 | 95.9M | 7 * DC14 + DC15 + 2 * DC17 - 5 * DC18 + 2 * DC19) : | 739 | 119M | (-DC11 + 13 * DC12 - 24 * DC13 + 13 * DC14 - DC15)); | 740 | 119M | if (num >= 0) { | 741 | 71.7M | pred = (int)(((Q02 << 7) + num) / (Q02 << 8)); | 742 | 71.7M | if (Al > 0 && pred >= (1 << Al)) | 743 | 2.27M | pred = (1 << Al) - 1; | 744 | 71.7M | } else { | 745 | 47.5M | pred = (int)(((Q02 << 7) - num) / (Q02 << 8)); | 746 | 47.5M | if (Al > 0 && pred >= (1 << Al)) | 747 | 2.32M | pred = (1 << Al) - 1; | 748 | 47.5M | pred = -pred; | 749 | 47.5M | } | 750 | 119M | workspace[2] = (JCOEF)pred; | 751 | 119M | } | 752 | 123M | if (change_dc) { | 753 | | /* AC03 */ | 754 | 95.9M | if ((Al = coef_bits[6]) != 0 && workspace[3] == 0) { | 755 | 95.9M | num = Q00 * (DC07 - DC09 + 2 * DC12 - 2 * DC14 + DC17 - DC19); | 756 | 95.9M | if (num >= 0) { | 757 | 61.2M | pred = (int)(((Q03 << 7) + num) / (Q03 << 8)); | 758 | 61.2M | if (Al > 0 && pred >= (1 << Al)) | 759 | 0 | pred = (1 << Al) - 1; | 760 | 61.2M | } else { | 761 | 34.7M | pred = (int)(((Q03 << 7) - num) / (Q03 << 8)); | 762 | 34.7M | if (Al > 0 && pred >= (1 << Al)) | 763 | 0 | pred = (1 << Al) - 1; | 764 | 34.7M | pred = -pred; | 765 | 34.7M | } | 766 | 95.9M | workspace[3] = (JCOEF)pred; | 767 | 95.9M | } | 768 | | /* AC12 */ | 769 | 95.9M | if ((Al = coef_bits[7]) != 0 && workspace[10] == 0) { | 770 | 95.9M | num = Q00 * (DC07 - 3 * DC08 + DC09 - DC17 + 3 * DC18 - DC19); | 771 | 95.9M | if (num >= 0) { | 772 | 57.4M | pred = (int)(((Q12 << 7) + num) / (Q12 << 8)); | 773 | 57.4M | if (Al > 0 && pred >= (1 << Al)) | 774 | 0 | pred = (1 << Al) - 1; | 775 | 57.4M | } else { | 776 | 38.5M | pred = (int)(((Q12 << 7) - num) / (Q12 << 8)); | 777 | 38.5M | if (Al > 0 && pred >= (1 << Al)) | 778 | 0 | pred = (1 << Al) - 1; | 779 | 38.5M | pred = -pred; | 780 | 38.5M | } | 781 | 95.9M | workspace[10] = (JCOEF)pred; | 782 | 95.9M | } | 783 | | /* AC21 */ | 784 | 95.9M | if ((Al = coef_bits[8]) != 0 && workspace[17] == 0) { | 785 | 95.9M | num = Q00 * (DC07 - DC09 - 3 * DC12 + 3 * DC14 + DC17 - DC19); | 786 | 95.9M | if (num >= 0) { | 787 | 55.1M | pred = (int)(((Q21 << 7) + num) / (Q21 << 8)); | 788 | 55.1M | if (Al > 0 && pred >= (1 << Al)) | 789 | 0 | pred = (1 << Al) - 1; | 790 | 55.1M | } else { | 791 | 40.8M | pred = (int)(((Q21 << 7) - num) / (Q21 << 8)); | 792 | 40.8M | if (Al > 0 && pred >= (1 << Al)) | 793 | 0 | pred = (1 << Al) - 1; | 794 | 40.8M | pred = -pred; | 795 | 40.8M | } | 796 | 95.9M | workspace[17] = (JCOEF)pred; | 797 | 95.9M | } | 798 | | /* AC30 */ | 799 | 95.9M | if ((Al = coef_bits[9]) != 0 && workspace[24] == 0) { | 800 | 95.9M | num = Q00 * (DC07 + 2 * DC08 + DC09 - DC17 - 2 * DC18 - DC19); | 801 | 95.9M | if (num >= 0) { | 802 | 61.9M | pred = (int)(((Q30 << 7) + num) / (Q30 << 8)); | 803 | 61.9M | if (Al > 0 && pred >= (1 << Al)) | 804 | 0 | pred = (1 << Al) - 1; | 805 | 61.9M | } else { | 806 | 34.0M | pred = (int)(((Q30 << 7) - num) / (Q30 << 8)); | 807 | 34.0M | if (Al > 0 && pred >= (1 << Al)) | 808 | 0 | pred = (1 << Al) - 1; | 809 | 34.0M | pred = -pred; | 810 | 34.0M | } | 811 | 95.9M | workspace[24] = (JCOEF)pred; | 812 | 95.9M | } | 813 | | /* coef_bits[0] is non-negative. Otherwise this function would not | 814 | | * be called. | 815 | | */ | 816 | 95.9M | num = Q00 * | 817 | 95.9M | (-2 * DC01 - 6 * DC02 - 8 * DC03 - 6 * DC04 - 2 * DC05 - | 818 | 95.9M | 6 * DC06 + 6 * DC07 + 42 * DC08 + 6 * DC09 - 6 * DC10 - | 819 | 95.9M | 8 * DC11 + 42 * DC12 + 152 * DC13 + 42 * DC14 - 8 * DC15 - | 820 | 95.9M | 6 * DC16 + 6 * DC17 + 42 * DC18 + 6 * DC19 - 6 * DC20 - | 821 | 95.9M | 2 * DC21 - 6 * DC22 - 8 * DC23 - 6 * DC24 - 2 * DC25); | 822 | 95.9M | if (num >= 0) { | 823 | 47.6M | pred = (int)(((Q00 << 7) + num) / (Q00 << 8)); | 824 | 48.3M | } else { | 825 | 48.3M | pred = (int)(((Q00 << 7) - num) / (Q00 << 8)); | 826 | 48.3M | pred = -pred; | 827 | 48.3M | } | 828 | 95.9M | workspace[0] = (JCOEF)pred; | 829 | 95.9M | } /* change_dc */ | 830 | | | 831 | | /* OK, do the IDCT */ | 832 | | #ifdef WITH_PROFILE | 833 | | cinfo->master->start = getTime(); | 834 | | #endif | 835 | 123M | (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)workspace, output_ptr, | 836 | 123M | output_col); | 837 | | #ifdef WITH_PROFILE | 838 | | cinfo->master->idct_elapsed += getTime() - cinfo->master->start; | 839 | | cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.; | 840 | | #endif | 841 | | /* Advance for next column */ | 842 | 123M | DC01 = DC02; DC02 = DC03; DC03 = DC04; DC04 = DC05; | 843 | 123M | DC06 = DC07; DC07 = DC08; DC08 = DC09; DC09 = DC10; | 844 | 123M | DC11 = DC12; DC12 = DC13; DC13 = DC14; DC14 = DC15; | 845 | 123M | DC16 = DC17; DC17 = DC18; DC18 = DC19; DC19 = DC20; | 846 | 123M | DC21 = DC22; DC22 = DC23; DC23 = DC24; DC24 = DC25; | 847 | 123M | buffer_ptr++, prev_block_row++, next_block_row++, | 848 | 123M | prev_prev_block_row++, next_next_block_row++; | 849 | 123M | output_col += compptr->_DCT_scaled_size; | 850 | 123M | } | 851 | 4.94M | output_ptr += compptr->_DCT_scaled_size; | 852 | 4.94M | } | 853 | 2.98M | } | 854 | | | 855 | 1.51M | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) | 856 | 1.50M | return JPEG_ROW_COMPLETED; | 857 | 6.35k | return JPEG_SCAN_COMPLETED; | 858 | 1.51M | } |
Unexecuted instantiation: jdcoefct-12.c:decompress_smooth_data |
859 | | |
860 | | #endif /* BLOCK_SMOOTHING_SUPPORTED */ |
861 | | |
862 | | |
863 | | /* |
864 | | * Initialize coefficient buffer controller. |
865 | | */ |
866 | | |
867 | | GLOBAL(void) |
868 | | _jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer) |
869 | 36.3k | { |
870 | 36.3k | my_coef_ptr coef; |
871 | | |
872 | 36.3k | if (cinfo->data_precision != BITS_IN_JSAMPLE) |
873 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
874 | | |
875 | 36.3k | coef = (my_coef_ptr) |
876 | 36.3k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
877 | 36.3k | sizeof(my_coef_controller)); |
878 | 36.3k | memset(coef, 0, sizeof(my_coef_controller)); |
879 | 36.3k | cinfo->coef = (struct jpeg_d_coef_controller *)coef; |
880 | 36.3k | coef->pub.start_input_pass = start_input_pass; |
881 | 36.3k | coef->pub.start_output_pass = start_output_pass; |
882 | 36.3k | #ifdef BLOCK_SMOOTHING_SUPPORTED |
883 | 36.3k | coef->coef_bits_latch = NULL; |
884 | 36.3k | #endif |
885 | | |
886 | | /* Create the coefficient buffer. */ |
887 | 36.3k | if (need_full_buffer) { |
888 | 22.2k | #ifdef D_MULTISCAN_FILES_SUPPORTED |
889 | | /* Allocate a full-image virtual array for each component, */ |
890 | | /* padded to a multiple of samp_factor DCT blocks in each direction. */ |
891 | | /* Note we ask for a pre-zeroed array. */ |
892 | 22.2k | int ci, access_rows; |
893 | 22.2k | jpeg_component_info *compptr; |
894 | | |
895 | 82.1k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
896 | 59.9k | ci++, compptr++) { |
897 | 59.9k | access_rows = compptr->v_samp_factor; |
898 | 59.9k | #ifdef BLOCK_SMOOTHING_SUPPORTED |
899 | | /* If block smoothing could be used, need a bigger window */ |
900 | 59.9k | if (cinfo->progressive_mode) |
901 | 57.7k | access_rows *= 5; |
902 | 59.9k | #endif |
903 | 59.9k | coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) |
904 | 59.9k | ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE, |
905 | 59.9k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
906 | 59.9k | (long)compptr->h_samp_factor), |
907 | 59.9k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, |
908 | 59.9k | (long)compptr->v_samp_factor), |
909 | 59.9k | (JDIMENSION)access_rows); |
910 | 59.9k | } |
911 | 22.2k | coef->pub.consume_data = consume_data; |
912 | 22.2k | coef->pub._decompress_data = decompress_data; |
913 | 22.2k | coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */ |
914 | | #else |
915 | | ERREXIT(cinfo, JERR_NOT_COMPILED); |
916 | | #endif |
917 | 22.2k | } else { |
918 | | /* We only need a single-MCU buffer. */ |
919 | 14.1k | JBLOCKROW buffer; |
920 | 14.1k | int i; |
921 | | |
922 | 14.1k | buffer = (JBLOCKROW) |
923 | 14.1k | (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
924 | 14.1k | D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK)); |
925 | 155k | for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { |
926 | 141k | coef->MCU_buffer[i] = buffer + i; |
927 | 141k | } |
928 | 14.1k | coef->pub.consume_data = dummy_consume_data; |
929 | 14.1k | coef->pub._decompress_data = decompress_onepass; |
930 | 14.1k | coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ |
931 | 14.1k | } |
932 | | |
933 | | /* Allocate the workspace buffer */ |
934 | 36.3k | coef->workspace = (JCOEF *) |
935 | 36.3k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
936 | 36.3k | sizeof(JCOEF) * DCTSIZE2); |
937 | 36.3k | } Line | Count | Source | 869 | 32.1k | { | 870 | 32.1k | my_coef_ptr coef; | 871 | | | 872 | 32.1k | if (cinfo->data_precision != BITS_IN_JSAMPLE) | 873 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 874 | | | 875 | 32.1k | coef = (my_coef_ptr) | 876 | 32.1k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 877 | 32.1k | sizeof(my_coef_controller)); | 878 | 32.1k | memset(coef, 0, sizeof(my_coef_controller)); | 879 | 32.1k | cinfo->coef = (struct jpeg_d_coef_controller *)coef; | 880 | 32.1k | coef->pub.start_input_pass = start_input_pass; | 881 | 32.1k | coef->pub.start_output_pass = start_output_pass; | 882 | 32.1k | #ifdef BLOCK_SMOOTHING_SUPPORTED | 883 | 32.1k | coef->coef_bits_latch = NULL; | 884 | 32.1k | #endif | 885 | | | 886 | | /* Create the coefficient buffer. */ | 887 | 32.1k | if (need_full_buffer) { | 888 | 18.2k | #ifdef D_MULTISCAN_FILES_SUPPORTED | 889 | | /* Allocate a full-image virtual array for each component, */ | 890 | | /* padded to a multiple of samp_factor DCT blocks in each direction. */ | 891 | | /* Note we ask for a pre-zeroed array. */ | 892 | 18.2k | int ci, access_rows; | 893 | 18.2k | jpeg_component_info *compptr; | 894 | | | 895 | 66.9k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 896 | 48.6k | ci++, compptr++) { | 897 | 48.6k | access_rows = compptr->v_samp_factor; | 898 | 48.6k | #ifdef BLOCK_SMOOTHING_SUPPORTED | 899 | | /* If block smoothing could be used, need a bigger window */ | 900 | 48.6k | if (cinfo->progressive_mode) | 901 | 47.1k | access_rows *= 5; | 902 | 48.6k | #endif | 903 | 48.6k | coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) | 904 | 48.6k | ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE, | 905 | 48.6k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 906 | 48.6k | (long)compptr->h_samp_factor), | 907 | 48.6k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 908 | 48.6k | (long)compptr->v_samp_factor), | 909 | 48.6k | (JDIMENSION)access_rows); | 910 | 48.6k | } | 911 | 18.2k | coef->pub.consume_data = consume_data; | 912 | 18.2k | coef->pub._decompress_data = decompress_data; | 913 | 18.2k | coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */ | 914 | | #else | 915 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 916 | | #endif | 917 | 18.2k | } else { | 918 | | /* We only need a single-MCU buffer. */ | 919 | 13.8k | JBLOCKROW buffer; | 920 | 13.8k | int i; | 921 | | | 922 | 13.8k | buffer = (JBLOCKROW) | 923 | 13.8k | (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 924 | 13.8k | D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK)); | 925 | 152k | for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { | 926 | 138k | coef->MCU_buffer[i] = buffer + i; | 927 | 138k | } | 928 | 13.8k | coef->pub.consume_data = dummy_consume_data; | 929 | 13.8k | coef->pub._decompress_data = decompress_onepass; | 930 | 13.8k | coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ | 931 | 13.8k | } | 932 | | | 933 | | /* Allocate the workspace buffer */ | 934 | 32.1k | coef->workspace = (JCOEF *) | 935 | 32.1k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 936 | 32.1k | sizeof(JCOEF) * DCTSIZE2); | 937 | 32.1k | } |
j12init_d_coef_controller Line | Count | Source | 869 | 4.21k | { | 870 | 4.21k | my_coef_ptr coef; | 871 | | | 872 | 4.21k | if (cinfo->data_precision != BITS_IN_JSAMPLE) | 873 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 874 | | | 875 | 4.21k | coef = (my_coef_ptr) | 876 | 4.21k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 877 | 4.21k | sizeof(my_coef_controller)); | 878 | 4.21k | memset(coef, 0, sizeof(my_coef_controller)); | 879 | 4.21k | cinfo->coef = (struct jpeg_d_coef_controller *)coef; | 880 | 4.21k | coef->pub.start_input_pass = start_input_pass; | 881 | 4.21k | coef->pub.start_output_pass = start_output_pass; | 882 | 4.21k | #ifdef BLOCK_SMOOTHING_SUPPORTED | 883 | 4.21k | coef->coef_bits_latch = NULL; | 884 | 4.21k | #endif | 885 | | | 886 | | /* Create the coefficient buffer. */ | 887 | 4.21k | if (need_full_buffer) { | 888 | 3.95k | #ifdef D_MULTISCAN_FILES_SUPPORTED | 889 | | /* Allocate a full-image virtual array for each component, */ | 890 | | /* padded to a multiple of samp_factor DCT blocks in each direction. */ | 891 | | /* Note we ask for a pre-zeroed array. */ | 892 | 3.95k | int ci, access_rows; | 893 | 3.95k | jpeg_component_info *compptr; | 894 | | | 895 | 15.2k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 896 | 11.2k | ci++, compptr++) { | 897 | 11.2k | access_rows = compptr->v_samp_factor; | 898 | 11.2k | #ifdef BLOCK_SMOOTHING_SUPPORTED | 899 | | /* If block smoothing could be used, need a bigger window */ | 900 | 11.2k | if (cinfo->progressive_mode) | 901 | 10.6k | access_rows *= 5; | 902 | 11.2k | #endif | 903 | 11.2k | coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) | 904 | 11.2k | ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE, | 905 | 11.2k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 906 | 11.2k | (long)compptr->h_samp_factor), | 907 | 11.2k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 908 | 11.2k | (long)compptr->v_samp_factor), | 909 | 11.2k | (JDIMENSION)access_rows); | 910 | 11.2k | } | 911 | 3.95k | coef->pub.consume_data = consume_data; | 912 | 3.95k | coef->pub._decompress_data = decompress_data; | 913 | 3.95k | coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */ | 914 | | #else | 915 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 916 | | #endif | 917 | 3.95k | } else { | 918 | | /* We only need a single-MCU buffer. */ | 919 | 259 | JBLOCKROW buffer; | 920 | 259 | int i; | 921 | | | 922 | 259 | buffer = (JBLOCKROW) | 923 | 259 | (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 924 | 259 | D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK)); | 925 | 2.84k | for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { | 926 | 2.59k | coef->MCU_buffer[i] = buffer + i; | 927 | 2.59k | } | 928 | 259 | coef->pub.consume_data = dummy_consume_data; | 929 | 259 | coef->pub._decompress_data = decompress_onepass; | 930 | 259 | coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ | 931 | 259 | } | 932 | | | 933 | | /* Allocate the workspace buffer */ | 934 | 4.21k | coef->workspace = (JCOEF *) | 935 | 4.21k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 936 | 4.21k | sizeof(JCOEF) * DCTSIZE2); | 937 | 4.21k | } |
|