/src/libjpeg-turbo/src/jddiffct.c
Line | Count | Source |
1 | | /* |
2 | | * jddiffct.c |
3 | | * |
4 | | * This file was part of the Independent JPEG Group's software: |
5 | | * Copyright (C) 1994-1997, Thomas G. Lane. |
6 | | * Lossless JPEG Modifications: |
7 | | * Copyright (C) 1999, Ken Murchison. |
8 | | * libjpeg-turbo Modifications: |
9 | | * Copyright (C) 2022, 2024, D. R. Commander. |
10 | | * For conditions of distribution and use, see the accompanying README.ijg |
11 | | * file. |
12 | | * |
13 | | * This file contains the [un]difference buffer controller for decompression. |
14 | | * This controller is the top level of the lossless JPEG decompressor proper. |
15 | | * The difference buffer lies between the entropy decoding and |
16 | | * prediction/undifferencing steps. The undifference buffer lies between the |
17 | | * prediction/undifferencing and scaling steps. |
18 | | * |
19 | | * In buffered-image mode, this controller is the interface between |
20 | | * input-oriented processing and output-oriented processing. |
21 | | */ |
22 | | |
23 | | #define JPEG_INTERNALS |
24 | | #include "jinclude.h" |
25 | | #include "jpeglib.h" |
26 | | #include "jlossls.h" /* Private declarations for lossless codec */ |
27 | | |
28 | | |
29 | | #ifdef D_LOSSLESS_SUPPORTED |
30 | | |
31 | | /* Private buffer controller object */ |
32 | | |
33 | | typedef struct { |
34 | | struct jpeg_d_coef_controller pub; /* public fields */ |
35 | | |
36 | | /* These variables keep track of the current location of the input side. */ |
37 | | /* cinfo->input_iMCU_row is also used for this. */ |
38 | | JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ |
39 | | unsigned int restart_rows_to_go; /* MCU rows left in this restart |
40 | | interval */ |
41 | | unsigned int MCU_vert_offset; /* counts MCU rows within iMCU row */ |
42 | | unsigned int MCU_rows_per_iMCU_row; /* number of such rows needed */ |
43 | | |
44 | | /* The output side's location is represented by cinfo->output_iMCU_row. */ |
45 | | |
46 | | JDIFFARRAY diff_buf[MAX_COMPONENTS]; /* iMCU row of differences */ |
47 | | JDIFFARRAY undiff_buf[MAX_COMPONENTS]; /* iMCU row of undiff'd samples */ |
48 | | |
49 | | #ifdef D_MULTISCAN_FILES_SUPPORTED |
50 | | /* In multi-pass modes, we need a virtual sample array for each component. */ |
51 | | jvirt_sarray_ptr whole_image[MAX_COMPONENTS]; |
52 | | #endif |
53 | | } my_diff_controller; |
54 | | |
55 | | typedef my_diff_controller *my_diff_ptr; |
56 | | |
57 | | /* Forward declarations */ |
58 | | METHODDEF(int) decompress_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf); |
59 | | #ifdef D_MULTISCAN_FILES_SUPPORTED |
60 | | METHODDEF(int) output_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf); |
61 | | #endif |
62 | | |
63 | | |
64 | | LOCAL(void) |
65 | | start_iMCU_row(j_decompress_ptr cinfo) |
66 | | /* Reset within-iMCU-row counters for a new row (input side) */ |
67 | 901k | { |
68 | 901k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
69 | | |
70 | | /* In an interleaved scan, an MCU row is the same as an iMCU row. |
71 | | * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. |
72 | | * But at the bottom of the image, process only what's left. |
73 | | */ |
74 | 901k | if (cinfo->comps_in_scan > 1) { |
75 | 102k | diff->MCU_rows_per_iMCU_row = 1; |
76 | 798k | } else { |
77 | 798k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) |
78 | 765k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; |
79 | 32.7k | else |
80 | 32.7k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; |
81 | 798k | } |
82 | | |
83 | 901k | diff->MCU_ctr = 0; |
84 | 901k | diff->MCU_vert_offset = 0; |
85 | 901k | } jddiffct-8.c:start_iMCU_row Line | Count | Source | 67 | 328k | { | 68 | 328k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 69 | | | 70 | | /* In an interleaved scan, an MCU row is the same as an iMCU row. | 71 | | * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. | 72 | | * But at the bottom of the image, process only what's left. | 73 | | */ | 74 | 328k | if (cinfo->comps_in_scan > 1) { | 75 | 95.8k | diff->MCU_rows_per_iMCU_row = 1; | 76 | 232k | } else { | 77 | 232k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 221k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 11.0k | else | 80 | 11.0k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 232k | } | 82 | | | 83 | 328k | diff->MCU_ctr = 0; | 84 | 328k | diff->MCU_vert_offset = 0; | 85 | 328k | } |
jddiffct-12.c:start_iMCU_row Line | Count | Source | 67 | 313k | { | 68 | 313k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 69 | | | 70 | | /* In an interleaved scan, an MCU row is the same as an iMCU row. | 71 | | * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. | 72 | | * But at the bottom of the image, process only what's left. | 73 | | */ | 74 | 313k | if (cinfo->comps_in_scan > 1) { | 75 | 3.46k | diff->MCU_rows_per_iMCU_row = 1; | 76 | 310k | } else { | 77 | 310k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 298k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 11.3k | else | 80 | 11.3k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 310k | } | 82 | | | 83 | 313k | diff->MCU_ctr = 0; | 84 | 313k | diff->MCU_vert_offset = 0; | 85 | 313k | } |
jddiffct-16.c:start_iMCU_row Line | Count | Source | 67 | 259k | { | 68 | 259k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 69 | | | 70 | | /* In an interleaved scan, an MCU row is the same as an iMCU row. | 71 | | * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. | 72 | | * But at the bottom of the image, process only what's left. | 73 | | */ | 74 | 259k | if (cinfo->comps_in_scan > 1) { | 75 | 3.55k | diff->MCU_rows_per_iMCU_row = 1; | 76 | 255k | } else { | 77 | 255k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 245k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 10.4k | else | 80 | 10.4k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 255k | } | 82 | | | 83 | 259k | diff->MCU_ctr = 0; | 84 | 259k | diff->MCU_vert_offset = 0; | 85 | 259k | } |
|
86 | | |
87 | | |
88 | | /* |
89 | | * Initialize for an input processing pass. |
90 | | */ |
91 | | |
92 | | METHODDEF(void) |
93 | | start_input_pass(j_decompress_ptr cinfo) |
94 | 55.9k | { |
95 | 55.9k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
96 | | |
97 | | /* Because it is hitching a ride on the jpeg_inverse_dct struct, |
98 | | * start_pass_lossless() will be called at the start of the output pass. |
99 | | * This ensures that it will be called at the start of the input pass as |
100 | | * well. |
101 | | */ |
102 | 55.9k | (*cinfo->idct->start_pass) (cinfo); |
103 | | |
104 | | /* Check that the restart interval is an integer multiple of the number |
105 | | * of MCUs in an MCU row. |
106 | | */ |
107 | 55.9k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) |
108 | 128 | ERREXIT2(cinfo, JERR_BAD_RESTART, |
109 | 55.9k | cinfo->restart_interval, cinfo->MCUs_per_row); |
110 | | |
111 | | /* Initialize restart counter */ |
112 | 55.9k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; |
113 | | |
114 | 55.9k | cinfo->input_iMCU_row = 0; |
115 | 55.9k | start_iMCU_row(cinfo); |
116 | 55.9k | } jddiffct-8.c:start_input_pass Line | Count | Source | 94 | 20.5k | { | 95 | 20.5k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 96 | | | 97 | | /* Because it is hitching a ride on the jpeg_inverse_dct struct, | 98 | | * start_pass_lossless() will be called at the start of the output pass. | 99 | | * This ensures that it will be called at the start of the input pass as | 100 | | * well. | 101 | | */ | 102 | 20.5k | (*cinfo->idct->start_pass) (cinfo); | 103 | | | 104 | | /* Check that the restart interval is an integer multiple of the number | 105 | | * of MCUs in an MCU row. | 106 | | */ | 107 | 20.5k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 40 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 20.5k | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 20.5k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 20.5k | cinfo->input_iMCU_row = 0; | 115 | 20.5k | start_iMCU_row(cinfo); | 116 | 20.5k | } |
jddiffct-12.c:start_input_pass Line | Count | Source | 94 | 17.8k | { | 95 | 17.8k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 96 | | | 97 | | /* Because it is hitching a ride on the jpeg_inverse_dct struct, | 98 | | * start_pass_lossless() will be called at the start of the output pass. | 99 | | * This ensures that it will be called at the start of the input pass as | 100 | | * well. | 101 | | */ | 102 | 17.8k | (*cinfo->idct->start_pass) (cinfo); | 103 | | | 104 | | /* Check that the restart interval is an integer multiple of the number | 105 | | * of MCUs in an MCU row. | 106 | | */ | 107 | 17.8k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 50 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 17.8k | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 17.8k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 17.8k | cinfo->input_iMCU_row = 0; | 115 | 17.8k | start_iMCU_row(cinfo); | 116 | 17.8k | } |
jddiffct-16.c:start_input_pass Line | Count | Source | 94 | 17.5k | { | 95 | 17.5k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 96 | | | 97 | | /* Because it is hitching a ride on the jpeg_inverse_dct struct, | 98 | | * start_pass_lossless() will be called at the start of the output pass. | 99 | | * This ensures that it will be called at the start of the input pass as | 100 | | * well. | 101 | | */ | 102 | 17.5k | (*cinfo->idct->start_pass) (cinfo); | 103 | | | 104 | | /* Check that the restart interval is an integer multiple of the number | 105 | | * of MCUs in an MCU row. | 106 | | */ | 107 | 17.5k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 38 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 17.5k | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 17.5k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 17.5k | cinfo->input_iMCU_row = 0; | 115 | 17.5k | start_iMCU_row(cinfo); | 116 | 17.5k | } |
|
117 | | |
118 | | |
119 | | /* |
120 | | * Check for a restart marker & resynchronize decoder, undifferencer. |
121 | | * Returns FALSE if must suspend. |
122 | | */ |
123 | | |
124 | | METHODDEF(boolean) |
125 | | process_restart(j_decompress_ptr cinfo) |
126 | 374 | { |
127 | 374 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
128 | | |
129 | 374 | if (!(*cinfo->entropy->process_restart) (cinfo)) |
130 | 0 | return FALSE; |
131 | | |
132 | 374 | (*cinfo->idct->start_pass) (cinfo); |
133 | | |
134 | | /* Reset restart counter */ |
135 | 374 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; |
136 | | |
137 | 374 | return TRUE; |
138 | 374 | } jddiffct-8.c:process_restart Line | Count | Source | 126 | 127 | { | 127 | 127 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 128 | | | 129 | 127 | if (!(*cinfo->entropy->process_restart) (cinfo)) | 130 | 0 | return FALSE; | 131 | | | 132 | 127 | (*cinfo->idct->start_pass) (cinfo); | 133 | | | 134 | | /* Reset restart counter */ | 135 | 127 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 136 | | | 137 | 127 | return TRUE; | 138 | 127 | } |
jddiffct-12.c:process_restart Line | Count | Source | 126 | 122 | { | 127 | 122 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 128 | | | 129 | 122 | if (!(*cinfo->entropy->process_restart) (cinfo)) | 130 | 0 | return FALSE; | 131 | | | 132 | 122 | (*cinfo->idct->start_pass) (cinfo); | 133 | | | 134 | | /* Reset restart counter */ | 135 | 122 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 136 | | | 137 | 122 | return TRUE; | 138 | 122 | } |
jddiffct-16.c:process_restart Line | Count | Source | 126 | 125 | { | 127 | 125 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 128 | | | 129 | 125 | if (!(*cinfo->entropy->process_restart) (cinfo)) | 130 | 0 | return FALSE; | 131 | | | 132 | 125 | (*cinfo->idct->start_pass) (cinfo); | 133 | | | 134 | | /* Reset restart counter */ | 135 | 125 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 136 | | | 137 | 125 | return TRUE; | 138 | 125 | } |
|
139 | | |
140 | | |
141 | | /* |
142 | | * Initialize for an output processing pass. |
143 | | */ |
144 | | |
145 | | METHODDEF(void) |
146 | | start_output_pass(j_decompress_ptr cinfo) |
147 | 6.27k | { |
148 | 6.27k | cinfo->output_iMCU_row = 0; |
149 | 6.27k | } jddiffct-8.c:start_output_pass Line | Count | Source | 147 | 5.81k | { | 148 | 5.81k | cinfo->output_iMCU_row = 0; | 149 | 5.81k | } |
jddiffct-12.c:start_output_pass Line | Count | Source | 147 | 227 | { | 148 | 227 | cinfo->output_iMCU_row = 0; | 149 | 227 | } |
jddiffct-16.c:start_output_pass Line | Count | Source | 147 | 227 | { | 148 | 227 | cinfo->output_iMCU_row = 0; | 149 | 227 | } |
|
150 | | |
151 | | |
152 | | /* |
153 | | * Decompress and return some data in the supplied buffer. |
154 | | * Always attempts to emit one fully interleaved MCU row ("iMCU" row). |
155 | | * Input and output must run in lockstep since we have only a one-MCU buffer. |
156 | | * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. |
157 | | * |
158 | | * NB: output_buf contains a plane for each component in image, |
159 | | * which we index according to the component's SOF position. |
160 | | */ |
161 | | |
162 | | METHODDEF(int) |
163 | | decompress_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf) |
164 | 900k | { |
165 | 900k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
166 | 900k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; |
167 | 900k | JDIMENSION MCU_col_num; /* index of current MCU within row */ |
168 | 900k | JDIMENSION MCU_count; /* number of MCUs decoded */ |
169 | 900k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
170 | 900k | int ci, compi, row, prev_row; |
171 | 900k | unsigned int yoffset; |
172 | 900k | jpeg_component_info *compptr; |
173 | | |
174 | | /* Loop to process as much as one whole iMCU row */ |
175 | 2.36M | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; |
176 | 1.46M | yoffset++) { |
177 | | |
178 | | /* Process restart marker if needed; may have to suspend */ |
179 | 1.46M | if (cinfo->restart_interval) { |
180 | 31.0k | if (diff->restart_rows_to_go == 0) |
181 | 374 | if (!process_restart(cinfo)) |
182 | 0 | return JPEG_SUSPENDED; |
183 | 31.0k | } |
184 | | |
185 | 1.46M | MCU_col_num = diff->MCU_ctr; |
186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ |
187 | 1.46M | MCU_count = |
188 | 1.46M | (*cinfo->entropy->decode_mcus) (cinfo, |
189 | 1.46M | diff->diff_buf, yoffset, MCU_col_num, |
190 | 1.46M | cinfo->MCUs_per_row - MCU_col_num); |
191 | 1.46M | if (MCU_count != cinfo->MCUs_per_row - MCU_col_num) { |
192 | | /* Suspension forced; update state counters and exit */ |
193 | 0 | diff->MCU_vert_offset = yoffset; |
194 | 0 | diff->MCU_ctr += MCU_count; |
195 | 0 | return JPEG_SUSPENDED; |
196 | 0 | } |
197 | | |
198 | | /* Account for restart interval (no-op if not using restarts) */ |
199 | 1.46M | if (cinfo->restart_interval) |
200 | 30.5k | diff->restart_rows_to_go--; |
201 | | |
202 | | /* Completed an MCU row, but perhaps not an iMCU row */ |
203 | 1.46M | diff->MCU_ctr = 0; |
204 | 1.46M | } |
205 | | |
206 | | /* |
207 | | * Undifference and scale each scanline of the disassembled MCU row |
208 | | * separately. We do not process dummy samples at the end of a scanline |
209 | | * or dummy rows at the end of the image. |
210 | | */ |
211 | 1.99M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
212 | 1.09M | compptr = cinfo->cur_comp_info[ci]; |
213 | 1.09M | compi = compptr->component_index; |
214 | 1.09M | for (row = 0, prev_row = compptr->v_samp_factor - 1; |
215 | 2.84M | row < (cinfo->input_iMCU_row == last_iMCU_row ? |
216 | 2.72M | compptr->last_row_height : compptr->v_samp_factor); |
217 | 1.74M | prev_row = row, row++) { |
218 | 1.74M | (*losslessd->predict_undifference[compi]) |
219 | 1.74M | (cinfo, compi, diff->diff_buf[compi][row], |
220 | 1.74M | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], |
221 | 1.74M | compptr->width_in_blocks); |
222 | 1.74M | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], |
223 | 1.74M | output_buf[compi][row], |
224 | 1.74M | compptr->width_in_blocks); |
225 | 1.74M | } |
226 | 1.09M | } |
227 | | |
228 | | /* Completed the iMCU row, advance counters for next one. |
229 | | * |
230 | | * NB: output_data will increment output_iMCU_row. |
231 | | * This counter is not needed for the single-pass case |
232 | | * or the input side of the multi-pass case. |
233 | | */ |
234 | 900k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { |
235 | 846k | start_iMCU_row(cinfo); |
236 | 846k | return JPEG_ROW_COMPLETED; |
237 | 846k | } |
238 | | /* Completed the scan */ |
239 | 53.9k | (*cinfo->inputctl->finish_input_pass) (cinfo); |
240 | 53.9k | return JPEG_SCAN_COMPLETED; |
241 | 900k | } jddiffct-8.c:decompress_data Line | Count | Source | 164 | 328k | { | 165 | 328k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 328k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 328k | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 328k | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 328k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 328k | int ci, compi, row, prev_row; | 171 | 328k | unsigned int yoffset; | 172 | 328k | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 898k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 570k | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 570k | if (cinfo->restart_interval) { | 180 | 3.84k | if (diff->restart_rows_to_go == 0) | 181 | 127 | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 3.84k | } | 184 | | | 185 | 570k | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 570k | MCU_count = | 188 | 570k | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 570k | diff->diff_buf, yoffset, MCU_col_num, | 190 | 570k | cinfo->MCUs_per_row - MCU_col_num); | 191 | 570k | if (MCU_count != cinfo->MCUs_per_row - MCU_col_num) { | 192 | | /* Suspension forced; update state counters and exit */ | 193 | 0 | diff->MCU_vert_offset = yoffset; | 194 | 0 | diff->MCU_ctr += MCU_count; | 195 | 0 | return JPEG_SUSPENDED; | 196 | 0 | } | 197 | | | 198 | | /* Account for restart interval (no-op if not using restarts) */ | 199 | 570k | if (cinfo->restart_interval) | 200 | 3.68k | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 570k | diff->MCU_ctr = 0; | 204 | 570k | } | 205 | | | 206 | | /* | 207 | | * Undifference and scale each scanline of the disassembled MCU row | 208 | | * separately. We do not process dummy samples at the end of a scanline | 209 | | * or dummy rows at the end of the image. | 210 | | */ | 211 | 852k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 523k | compptr = cinfo->cur_comp_info[ci]; | 213 | 523k | compi = compptr->component_index; | 214 | 523k | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 1.37M | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 1.33M | compptr->last_row_height : compptr->v_samp_factor); | 217 | 847k | prev_row = row, row++) { | 218 | 847k | (*losslessd->predict_undifference[compi]) | 219 | 847k | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 847k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 847k | compptr->width_in_blocks); | 222 | 847k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 847k | output_buf[compi][row], | 224 | 847k | compptr->width_in_blocks); | 225 | 847k | } | 226 | 523k | } | 227 | | | 228 | | /* Completed the iMCU row, advance counters for next one. | 229 | | * | 230 | | * NB: output_data will increment output_iMCU_row. | 231 | | * This counter is not needed for the single-pass case | 232 | | * or the input side of the multi-pass case. | 233 | | */ | 234 | 328k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 308k | start_iMCU_row(cinfo); | 236 | 308k | return JPEG_ROW_COMPLETED; | 237 | 308k | } | 238 | | /* Completed the scan */ | 239 | 19.8k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 19.8k | return JPEG_SCAN_COMPLETED; | 241 | 328k | } |
jddiffct-12.c:decompress_data Line | Count | Source | 164 | 313k | { | 165 | 313k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 313k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 313k | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 313k | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 313k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 313k | int ci, compi, row, prev_row; | 171 | 313k | unsigned int yoffset; | 172 | 313k | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 778k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 465k | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 465k | if (cinfo->restart_interval) { | 180 | 20.4k | if (diff->restart_rows_to_go == 0) | 181 | 122 | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 20.4k | } | 184 | | | 185 | 465k | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 465k | MCU_count = | 188 | 465k | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 465k | diff->diff_buf, yoffset, MCU_col_num, | 190 | 465k | cinfo->MCUs_per_row - MCU_col_num); | 191 | 465k | if (MCU_count != cinfo->MCUs_per_row - MCU_col_num) { | 192 | | /* Suspension forced; update state counters and exit */ | 193 | 0 | diff->MCU_vert_offset = yoffset; | 194 | 0 | diff->MCU_ctr += MCU_count; | 195 | 0 | return JPEG_SUSPENDED; | 196 | 0 | } | 197 | | | 198 | | /* Account for restart interval (no-op if not using restarts) */ | 199 | 465k | if (cinfo->restart_interval) | 200 | 20.2k | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 465k | diff->MCU_ctr = 0; | 204 | 465k | } | 205 | | | 206 | | /* | 207 | | * Undifference and scale each scanline of the disassembled MCU row | 208 | | * separately. We do not process dummy samples at the end of a scanline | 209 | | * or dummy rows at the end of the image. | 210 | | */ | 211 | 628k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 314k | compptr = cinfo->cur_comp_info[ci]; | 213 | 314k | compi = compptr->component_index; | 214 | 314k | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 783k | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 744k | compptr->last_row_height : compptr->v_samp_factor); | 217 | 468k | prev_row = row, row++) { | 218 | 468k | (*losslessd->predict_undifference[compi]) | 219 | 468k | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 468k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 468k | compptr->width_in_blocks); | 222 | 468k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 468k | output_buf[compi][row], | 224 | 468k | compptr->width_in_blocks); | 225 | 468k | } | 226 | 314k | } | 227 | | | 228 | | /* Completed the iMCU row, advance counters for next one. | 229 | | * | 230 | | * NB: output_data will increment output_iMCU_row. | 231 | | * This counter is not needed for the single-pass case | 232 | | * or the input side of the multi-pass case. | 233 | | */ | 234 | 313k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 296k | start_iMCU_row(cinfo); | 236 | 296k | return JPEG_ROW_COMPLETED; | 237 | 296k | } | 238 | | /* Completed the scan */ | 239 | 17.1k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 17.1k | return JPEG_SCAN_COMPLETED; | 241 | 313k | } |
jddiffct-16.c:decompress_data Line | Count | Source | 164 | 258k | { | 165 | 258k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 258k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 258k | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 258k | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 258k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 258k | int ci, compi, row, prev_row; | 171 | 258k | unsigned int yoffset; | 172 | 258k | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 685k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 426k | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 426k | if (cinfo->restart_interval) { | 180 | 6.80k | if (diff->restart_rows_to_go == 0) | 181 | 125 | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 6.80k | } | 184 | | | 185 | 426k | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 426k | MCU_count = | 188 | 426k | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 426k | diff->diff_buf, yoffset, MCU_col_num, | 190 | 426k | cinfo->MCUs_per_row - MCU_col_num); | 191 | 426k | if (MCU_count != cinfo->MCUs_per_row - MCU_col_num) { | 192 | | /* Suspension forced; update state counters and exit */ | 193 | 0 | diff->MCU_vert_offset = yoffset; | 194 | 0 | diff->MCU_ctr += MCU_count; | 195 | 0 | return JPEG_SUSPENDED; | 196 | 0 | } | 197 | | | 198 | | /* Account for restart interval (no-op if not using restarts) */ | 199 | 426k | if (cinfo->restart_interval) | 200 | 6.63k | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 426k | diff->MCU_ctr = 0; | 204 | 426k | } | 205 | | | 206 | | /* | 207 | | * Undifference and scale each scanline of the disassembled MCU row | 208 | | * separately. We do not process dummy samples at the end of a scanline | 209 | | * or dummy rows at the end of the image. | 210 | | */ | 211 | 518k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 260k | compptr = cinfo->cur_comp_info[ci]; | 213 | 260k | compi = compptr->component_index; | 214 | 260k | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 689k | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 649k | compptr->last_row_height : compptr->v_samp_factor); | 217 | 429k | prev_row = row, row++) { | 218 | 429k | (*losslessd->predict_undifference[compi]) | 219 | 429k | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 429k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 429k | compptr->width_in_blocks); | 222 | 429k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 429k | output_buf[compi][row], | 224 | 429k | compptr->width_in_blocks); | 225 | 429k | } | 226 | 260k | } | 227 | | | 228 | | /* Completed the iMCU row, advance counters for next one. | 229 | | * | 230 | | * NB: output_data will increment output_iMCU_row. | 231 | | * This counter is not needed for the single-pass case | 232 | | * or the input side of the multi-pass case. | 233 | | */ | 234 | 258k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 242k | start_iMCU_row(cinfo); | 236 | 242k | return JPEG_ROW_COMPLETED; | 237 | 242k | } | 238 | | /* Completed the scan */ | 239 | 16.8k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 16.8k | return JPEG_SCAN_COMPLETED; | 241 | 258k | } |
|
242 | | |
243 | | |
244 | | /* |
245 | | * Dummy consume-input routine for single-pass operation. |
246 | | */ |
247 | | |
248 | | METHODDEF(int) |
249 | | dummy_consume_data(j_decompress_ptr cinfo) |
250 | 0 | { |
251 | 0 | return JPEG_SUSPENDED; /* Always indicate nothing was done */ |
252 | 0 | } Unexecuted instantiation: jddiffct-8.c:dummy_consume_data Unexecuted instantiation: jddiffct-12.c:dummy_consume_data Unexecuted instantiation: jddiffct-16.c:dummy_consume_data |
253 | | |
254 | | |
255 | | #ifdef D_MULTISCAN_FILES_SUPPORTED |
256 | | |
257 | | /* |
258 | | * Consume input data and store it in the full-image sample buffer. |
259 | | * We read as much as one fully interleaved MCU row ("iMCU" row) per call, |
260 | | * ie, v_samp_factor rows for each component in the scan. |
261 | | * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. |
262 | | */ |
263 | | |
264 | | METHODDEF(int) |
265 | | consume_data(j_decompress_ptr cinfo) |
266 | 780k | { |
267 | 780k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
268 | 780k | int ci, compi; |
269 | 780k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; |
270 | 780k | jpeg_component_info *compptr; |
271 | | |
272 | | /* Align the virtual buffers for the components used in this scan. */ |
273 | 1.63M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
274 | 854k | compptr = cinfo->cur_comp_info[ci]; |
275 | 854k | compi = compptr->component_index; |
276 | 854k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) |
277 | 854k | ((j_common_ptr)cinfo, diff->whole_image[compi], |
278 | 854k | cinfo->input_iMCU_row * compptr->v_samp_factor, |
279 | 854k | (JDIMENSION)compptr->v_samp_factor, TRUE); |
280 | 854k | } |
281 | | |
282 | 780k | return decompress_data(cinfo, buffer); |
283 | 780k | } jddiffct-8.c:consume_data Line | Count | Source | 266 | 208k | { | 267 | 208k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 208k | int ci, compi; | 269 | 208k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 208k | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 479k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 271k | compptr = cinfo->cur_comp_info[ci]; | 275 | 271k | compi = compptr->component_index; | 276 | 271k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 271k | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 271k | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 271k | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 271k | } | 281 | | | 282 | 208k | return decompress_data(cinfo, buffer); | 283 | 208k | } |
jddiffct-12.c:consume_data Line | Count | Source | 266 | 313k | { | 267 | 313k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 313k | int ci, compi; | 269 | 313k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 313k | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 632k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 318k | compptr = cinfo->cur_comp_info[ci]; | 275 | 318k | compi = compptr->component_index; | 276 | 318k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 318k | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 318k | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 318k | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 318k | } | 281 | | | 282 | 313k | return decompress_data(cinfo, buffer); | 283 | 313k | } |
jddiffct-16.c:consume_data Line | Count | Source | 266 | 258k | { | 267 | 258k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 258k | int ci, compi; | 269 | 258k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 258k | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 523k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 264k | compptr = cinfo->cur_comp_info[ci]; | 275 | 264k | compi = compptr->component_index; | 276 | 264k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 264k | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 264k | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 264k | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 264k | } | 281 | | | 282 | 258k | return decompress_data(cinfo, buffer); | 283 | 258k | } |
|
284 | | |
285 | | |
286 | | /* |
287 | | * Output some data from the full-image sample buffer in the multi-pass case. |
288 | | * Always attempts to emit one fully interleaved MCU row ("iMCU" row). |
289 | | * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. |
290 | | * |
291 | | * NB: output_buf contains a plane for each component in image. |
292 | | */ |
293 | | |
294 | | METHODDEF(int) |
295 | | output_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf) |
296 | 1.43k | { |
297 | 1.43k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
298 | 1.43k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
299 | 1.43k | int ci, samp_rows, row; |
300 | 1.43k | _JSAMPARRAY buffer; |
301 | 1.43k | jpeg_component_info *compptr; |
302 | | |
303 | | /* Force some input to be done if we are getting ahead of the input. */ |
304 | 1.43k | while (cinfo->input_scan_number < cinfo->output_scan_number || |
305 | 1.43k | (cinfo->input_scan_number == cinfo->output_scan_number && |
306 | 1.43k | cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { |
307 | 0 | if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) |
308 | 0 | return JPEG_SUSPENDED; |
309 | 0 | } |
310 | | |
311 | | /* OK, output from the virtual arrays. */ |
312 | 4.58k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
313 | 3.14k | ci++, compptr++) { |
314 | | /* Align the virtual buffer for this component. */ |
315 | 3.14k | buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) |
316 | 3.14k | ((j_common_ptr)cinfo, diff->whole_image[ci], |
317 | 3.14k | cinfo->output_iMCU_row * compptr->v_samp_factor, |
318 | 3.14k | (JDIMENSION)compptr->v_samp_factor, FALSE); |
319 | | |
320 | 3.14k | if (cinfo->output_iMCU_row < last_iMCU_row) |
321 | 2.69k | samp_rows = compptr->v_samp_factor; |
322 | 450 | else { |
323 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ |
324 | 450 | samp_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); |
325 | 450 | if (samp_rows == 0) samp_rows = compptr->v_samp_factor; |
326 | 450 | } |
327 | | |
328 | 7.61k | for (row = 0; row < samp_rows; row++) { |
329 | 4.46k | memcpy(output_buf[ci][row], buffer[row], |
330 | 4.46k | compptr->width_in_blocks * sizeof(_JSAMPLE)); |
331 | 4.46k | } |
332 | 3.14k | } |
333 | | |
334 | 1.43k | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) |
335 | 1.16k | return JPEG_ROW_COMPLETED; |
336 | 263 | return JPEG_SCAN_COMPLETED; |
337 | 1.43k | } Line | Count | Source | 296 | 1.43k | { | 297 | 1.43k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 298 | 1.43k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 299 | 1.43k | int ci, samp_rows, row; | 300 | 1.43k | _JSAMPARRAY buffer; | 301 | 1.43k | jpeg_component_info *compptr; | 302 | | | 303 | | /* Force some input to be done if we are getting ahead of the input. */ | 304 | 1.43k | while (cinfo->input_scan_number < cinfo->output_scan_number || | 305 | 1.43k | (cinfo->input_scan_number == cinfo->output_scan_number && | 306 | 1.43k | cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { | 307 | 0 | if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) | 308 | 0 | return JPEG_SUSPENDED; | 309 | 0 | } | 310 | | | 311 | | /* OK, output from the virtual arrays. */ | 312 | 4.58k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 313 | 3.14k | ci++, compptr++) { | 314 | | /* Align the virtual buffer for this component. */ | 315 | 3.14k | buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 316 | 3.14k | ((j_common_ptr)cinfo, diff->whole_image[ci], | 317 | 3.14k | cinfo->output_iMCU_row * compptr->v_samp_factor, | 318 | 3.14k | (JDIMENSION)compptr->v_samp_factor, FALSE); | 319 | | | 320 | 3.14k | if (cinfo->output_iMCU_row < last_iMCU_row) | 321 | 2.69k | samp_rows = compptr->v_samp_factor; | 322 | 450 | else { | 323 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ | 324 | 450 | samp_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); | 325 | 450 | if (samp_rows == 0) samp_rows = compptr->v_samp_factor; | 326 | 450 | } | 327 | | | 328 | 7.61k | for (row = 0; row < samp_rows; row++) { | 329 | 4.46k | memcpy(output_buf[ci][row], buffer[row], | 330 | 4.46k | compptr->width_in_blocks * sizeof(_JSAMPLE)); | 331 | 4.46k | } | 332 | 3.14k | } | 333 | | | 334 | 1.43k | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) | 335 | 1.16k | return JPEG_ROW_COMPLETED; | 336 | 263 | return JPEG_SCAN_COMPLETED; | 337 | 1.43k | } |
Unexecuted instantiation: jddiffct-12.c:output_data Unexecuted instantiation: jddiffct-16.c:output_data |
338 | | |
339 | | #endif /* D_MULTISCAN_FILES_SUPPORTED */ |
340 | | |
341 | | |
342 | | /* |
343 | | * Initialize difference buffer controller. |
344 | | */ |
345 | | |
346 | | GLOBAL(void) |
347 | | _jinit_d_diff_controller(j_decompress_ptr cinfo, boolean need_full_buffer) |
348 | 21.3k | { |
349 | 21.3k | my_diff_ptr diff; |
350 | 21.3k | int ci; |
351 | 21.3k | jpeg_component_info *compptr; |
352 | | |
353 | | #if BITS_IN_JSAMPLE == 8 |
354 | 9.12k | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) |
355 | | #else |
356 | 12.2k | if (cinfo->data_precision > BITS_IN_JSAMPLE || |
357 | 12.2k | cinfo->data_precision < BITS_IN_JSAMPLE - 3) |
358 | 0 | #endif |
359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
360 | | |
361 | 21.3k | diff = (my_diff_ptr) |
362 | 21.3k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
363 | 21.3k | sizeof(my_diff_controller)); |
364 | 21.3k | cinfo->coef = (struct jpeg_d_coef_controller *)diff; |
365 | 21.3k | diff->pub.start_input_pass = start_input_pass; |
366 | 21.3k | diff->pub.start_output_pass = start_output_pass; |
367 | | |
368 | | /* Create the [un]difference buffers. */ |
369 | 79.4k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
370 | 58.0k | ci++, compptr++) { |
371 | 58.0k | diff->diff_buf[ci] = |
372 | 58.0k | ALLOC_DARRAY(JPOOL_IMAGE, |
373 | 58.0k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
374 | 58.0k | (long)compptr->h_samp_factor), |
375 | 58.0k | (JDIMENSION)compptr->v_samp_factor); |
376 | 58.0k | diff->undiff_buf[ci] = |
377 | 58.0k | ALLOC_DARRAY(JPOOL_IMAGE, |
378 | 58.0k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
379 | 58.0k | (long)compptr->h_samp_factor), |
380 | 58.0k | (JDIMENSION)compptr->v_samp_factor); |
381 | 58.0k | } |
382 | | |
383 | 21.3k | if (need_full_buffer) { |
384 | 14.2k | #ifdef D_MULTISCAN_FILES_SUPPORTED |
385 | | /* Allocate a full-image virtual array for each component. */ |
386 | 14.2k | int access_rows; |
387 | | |
388 | 55.4k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
389 | 41.1k | ci++, compptr++) { |
390 | 41.1k | access_rows = compptr->v_samp_factor; |
391 | 41.1k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) |
392 | 41.1k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, |
393 | 41.1k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
394 | 41.1k | (long)compptr->h_samp_factor), |
395 | 41.1k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, |
396 | 41.1k | (long)compptr->v_samp_factor), |
397 | 41.1k | (JDIMENSION)access_rows); |
398 | 41.1k | } |
399 | 14.2k | diff->pub.consume_data = consume_data; |
400 | 14.2k | diff->pub._decompress_data = output_data; |
401 | | #else |
402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); |
403 | | #endif |
404 | 14.2k | } else { |
405 | 7.09k | diff->pub.consume_data = dummy_consume_data; |
406 | 7.09k | diff->pub._decompress_data = decompress_data; |
407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ |
408 | 7.09k | } |
409 | 21.3k | } Line | Count | Source | 348 | 9.12k | { | 349 | 9.12k | my_diff_ptr diff; | 350 | 9.12k | int ci; | 351 | 9.12k | jpeg_component_info *compptr; | 352 | | | 353 | 9.12k | #if BITS_IN_JSAMPLE == 8 | 354 | 9.12k | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) | 355 | | #else | 356 | | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 357 | | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 358 | | #endif | 359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 360 | | | 361 | 9.12k | diff = (my_diff_ptr) | 362 | 9.12k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 9.12k | sizeof(my_diff_controller)); | 364 | 9.12k | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 9.12k | diff->pub.start_input_pass = start_input_pass; | 366 | 9.12k | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 32.3k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 23.2k | ci++, compptr++) { | 371 | 23.2k | diff->diff_buf[ci] = | 372 | 23.2k | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 23.2k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 23.2k | (long)compptr->h_samp_factor), | 375 | 23.2k | (JDIMENSION)compptr->v_samp_factor); | 376 | 23.2k | diff->undiff_buf[ci] = | 377 | 23.2k | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 23.2k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 23.2k | (long)compptr->h_samp_factor), | 380 | 23.2k | (JDIMENSION)compptr->v_samp_factor); | 381 | 23.2k | } | 382 | | | 383 | 9.12k | if (need_full_buffer) { | 384 | 2.92k | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 2.92k | int access_rows; | 387 | | | 388 | 11.6k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 8.77k | ci++, compptr++) { | 390 | 8.77k | access_rows = compptr->v_samp_factor; | 391 | 8.77k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 8.77k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 8.77k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 8.77k | (long)compptr->h_samp_factor), | 395 | 8.77k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 8.77k | (long)compptr->v_samp_factor), | 397 | 8.77k | (JDIMENSION)access_rows); | 398 | 8.77k | } | 399 | 2.92k | diff->pub.consume_data = consume_data; | 400 | 2.92k | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 6.20k | } else { | 405 | 6.20k | diff->pub.consume_data = dummy_consume_data; | 406 | 6.20k | diff->pub._decompress_data = decompress_data; | 407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 6.20k | } | 409 | 9.12k | } |
j12init_d_diff_controller Line | Count | Source | 348 | 5.95k | { | 349 | 5.95k | my_diff_ptr diff; | 350 | 5.95k | int ci; | 351 | 5.95k | jpeg_component_info *compptr; | 352 | | | 353 | | #if BITS_IN_JSAMPLE == 8 | 354 | | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) | 355 | | #else | 356 | 5.95k | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 357 | 5.95k | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 358 | 0 | #endif | 359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 360 | | | 361 | 5.95k | diff = (my_diff_ptr) | 362 | 5.95k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 5.95k | sizeof(my_diff_controller)); | 364 | 5.95k | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 5.95k | diff->pub.start_input_pass = start_input_pass; | 366 | 5.95k | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 22.8k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 16.8k | ci++, compptr++) { | 371 | 16.8k | diff->diff_buf[ci] = | 372 | 16.8k | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 16.8k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 16.8k | (long)compptr->h_samp_factor), | 375 | 16.8k | (JDIMENSION)compptr->v_samp_factor); | 376 | 16.8k | diff->undiff_buf[ci] = | 377 | 16.8k | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 16.8k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 16.8k | (long)compptr->h_samp_factor), | 380 | 16.8k | (JDIMENSION)compptr->v_samp_factor); | 381 | 16.8k | } | 382 | | | 383 | 5.95k | if (need_full_buffer) { | 384 | 5.53k | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 5.53k | int access_rows; | 387 | | | 388 | 21.2k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 15.7k | ci++, compptr++) { | 390 | 15.7k | access_rows = compptr->v_samp_factor; | 391 | 15.7k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 15.7k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 15.7k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 15.7k | (long)compptr->h_samp_factor), | 395 | 15.7k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 15.7k | (long)compptr->v_samp_factor), | 397 | 15.7k | (JDIMENSION)access_rows); | 398 | 15.7k | } | 399 | 5.53k | diff->pub.consume_data = consume_data; | 400 | 5.53k | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 5.53k | } else { | 405 | 425 | diff->pub.consume_data = dummy_consume_data; | 406 | 425 | diff->pub._decompress_data = decompress_data; | 407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 425 | } | 409 | 5.95k | } |
j16init_d_diff_controller Line | Count | Source | 348 | 6.28k | { | 349 | 6.28k | my_diff_ptr diff; | 350 | 6.28k | int ci; | 351 | 6.28k | jpeg_component_info *compptr; | 352 | | | 353 | | #if BITS_IN_JSAMPLE == 8 | 354 | | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) | 355 | | #else | 356 | 6.28k | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 357 | 6.28k | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 358 | 0 | #endif | 359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 360 | | | 361 | 6.28k | diff = (my_diff_ptr) | 362 | 6.28k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 6.28k | sizeof(my_diff_controller)); | 364 | 6.28k | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 6.28k | diff->pub.start_input_pass = start_input_pass; | 366 | 6.28k | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 24.1k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 17.9k | ci++, compptr++) { | 371 | 17.9k | diff->diff_buf[ci] = | 372 | 17.9k | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 17.9k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 17.9k | (long)compptr->h_samp_factor), | 375 | 17.9k | (JDIMENSION)compptr->v_samp_factor); | 376 | 17.9k | diff->undiff_buf[ci] = | 377 | 17.9k | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 17.9k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 17.9k | (long)compptr->h_samp_factor), | 380 | 17.9k | (JDIMENSION)compptr->v_samp_factor); | 381 | 17.9k | } | 382 | | | 383 | 6.28k | if (need_full_buffer) { | 384 | 5.81k | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 5.81k | int access_rows; | 387 | | | 388 | 22.4k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 16.6k | ci++, compptr++) { | 390 | 16.6k | access_rows = compptr->v_samp_factor; | 391 | 16.6k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 16.6k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 16.6k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 16.6k | (long)compptr->h_samp_factor), | 395 | 16.6k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 16.6k | (long)compptr->v_samp_factor), | 397 | 16.6k | (JDIMENSION)access_rows); | 398 | 16.6k | } | 399 | 5.81k | diff->pub.consume_data = consume_data; | 400 | 5.81k | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 5.81k | } else { | 405 | 466 | diff->pub.consume_data = dummy_consume_data; | 406 | 466 | diff->pub._decompress_data = decompress_data; | 407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 466 | } | 409 | 6.28k | } |
|
410 | | |
411 | | #endif /* D_LOSSLESS_SUPPORTED */ |