/src/libjpeg-turbo/src/jddiffct.c
Line | Count | Source (jump to first uncovered line) |
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 | 46.9k | { |
68 | 46.9k | 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 | 46.9k | if (cinfo->comps_in_scan > 1) { |
75 | 4.23k | diff->MCU_rows_per_iMCU_row = 1; |
76 | 42.6k | } else { |
77 | 42.6k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) |
78 | 42.4k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; |
79 | 267 | else |
80 | 267 | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; |
81 | 42.6k | } |
82 | | |
83 | 46.9k | diff->MCU_ctr = 0; |
84 | 46.9k | diff->MCU_vert_offset = 0; |
85 | 46.9k | } jddiffct-8.c:start_iMCU_row Line | Count | Source | 67 | 8.33k | { | 68 | 8.33k | 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 | 8.33k | if (cinfo->comps_in_scan > 1) { | 75 | 4.23k | diff->MCU_rows_per_iMCU_row = 1; | 76 | 4.23k | } else { | 77 | 4.10k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 3.99k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 102 | else | 80 | 102 | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 4.10k | } | 82 | | | 83 | 8.33k | diff->MCU_ctr = 0; | 84 | 8.33k | diff->MCU_vert_offset = 0; | 85 | 8.33k | } |
jddiffct-12.c:start_iMCU_row Line | Count | Source | 67 | 8.26k | { | 68 | 8.26k | 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 | 8.26k | if (cinfo->comps_in_scan > 1) { | 75 | 2 | diff->MCU_rows_per_iMCU_row = 1; | 76 | 8.26k | } else { | 77 | 8.26k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 8.18k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 77 | else | 80 | 77 | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 8.26k | } | 82 | | | 83 | 8.26k | diff->MCU_ctr = 0; | 84 | 8.26k | diff->MCU_vert_offset = 0; | 85 | 8.26k | } |
jddiffct-16.c:start_iMCU_row Line | Count | Source | 67 | 30.3k | { | 68 | 30.3k | 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 | 30.3k | if (cinfo->comps_in_scan > 1) { | 75 | 1 | diff->MCU_rows_per_iMCU_row = 1; | 76 | 30.3k | } else { | 77 | 30.3k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 30.2k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 88 | else | 80 | 88 | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 30.3k | } | 82 | | | 83 | 30.3k | diff->MCU_ctr = 0; | 84 | 30.3k | diff->MCU_vert_offset = 0; | 85 | 30.3k | } |
|
86 | | |
87 | | |
88 | | /* |
89 | | * Initialize for an input processing pass. |
90 | | */ |
91 | | |
92 | | METHODDEF(void) |
93 | | start_input_pass(j_decompress_ptr cinfo) |
94 | 1.18k | { |
95 | 1.18k | 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 | 1.18k | (*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 | 1.18k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) |
108 | 0 | ERREXIT2(cinfo, JERR_BAD_RESTART, |
109 | 1.18k | cinfo->restart_interval, cinfo->MCUs_per_row); |
110 | | |
111 | | /* Initialize restart counter */ |
112 | 1.18k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; |
113 | | |
114 | 1.18k | cinfo->input_iMCU_row = 0; |
115 | 1.18k | start_iMCU_row(cinfo); |
116 | 1.18k | } jddiffct-8.c:start_input_pass Line | Count | Source | 94 | 443 | { | 95 | 443 | 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 | 443 | (*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 | 443 | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 0 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 443 | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 443 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 443 | cinfo->input_iMCU_row = 0; | 115 | 443 | start_iMCU_row(cinfo); | 116 | 443 | } |
jddiffct-12.c:start_input_pass Line | Count | Source | 94 | 370 | { | 95 | 370 | 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 | 370 | (*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 | 370 | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 0 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 370 | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 370 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 370 | cinfo->input_iMCU_row = 0; | 115 | 370 | start_iMCU_row(cinfo); | 116 | 370 | } |
jddiffct-16.c:start_input_pass Line | Count | Source | 94 | 368 | { | 95 | 368 | 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 | 368 | (*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 | 368 | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 0 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 368 | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 368 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 368 | cinfo->input_iMCU_row = 0; | 115 | 368 | start_iMCU_row(cinfo); | 116 | 368 | } |
|
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 | 0 | { |
127 | 0 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
128 | |
|
129 | 0 | if (!(*cinfo->entropy->process_restart) (cinfo)) |
130 | 0 | return FALSE; |
131 | | |
132 | 0 | (*cinfo->idct->start_pass) (cinfo); |
133 | | |
134 | | /* Reset restart counter */ |
135 | 0 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; |
136 | |
|
137 | 0 | return TRUE; |
138 | 0 | } Unexecuted instantiation: jddiffct-8.c:process_restart Unexecuted instantiation: jddiffct-12.c:process_restart Unexecuted instantiation: jddiffct-16.c:process_restart |
139 | | |
140 | | |
141 | | /* |
142 | | * Initialize for an output processing pass. |
143 | | */ |
144 | | |
145 | | METHODDEF(void) |
146 | | start_output_pass(j_decompress_ptr cinfo) |
147 | 177 | { |
148 | 177 | cinfo->output_iMCU_row = 0; |
149 | 177 | } jddiffct-8.c:start_output_pass Line | Count | Source | 147 | 166 | { | 148 | 166 | cinfo->output_iMCU_row = 0; | 149 | 166 | } |
jddiffct-12.c:start_output_pass Line | Count | Source | 147 | 3 | { | 148 | 3 | cinfo->output_iMCU_row = 0; | 149 | 3 | } |
jddiffct-16.c:start_output_pass Line | Count | Source | 147 | 8 | { | 148 | 8 | cinfo->output_iMCU_row = 0; | 149 | 8 | } |
|
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 | 46.9k | { |
165 | 46.9k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
166 | 46.9k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; |
167 | 46.9k | JDIMENSION MCU_col_num; /* index of current MCU within row */ |
168 | 46.9k | JDIMENSION MCU_count; /* number of MCUs decoded */ |
169 | 46.9k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
170 | 46.9k | int ci, compi, row, prev_row; |
171 | 46.9k | unsigned int yoffset; |
172 | 46.9k | jpeg_component_info *compptr; |
173 | | |
174 | | /* Loop to process as much as one whole iMCU row */ |
175 | 162k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; |
176 | 115k | yoffset++) { |
177 | | |
178 | | /* Process restart marker if needed; may have to suspend */ |
179 | 115k | if (cinfo->restart_interval) { |
180 | 0 | if (diff->restart_rows_to_go == 0) |
181 | 0 | if (!process_restart(cinfo)) |
182 | 0 | return JPEG_SUSPENDED; |
183 | 0 | } |
184 | | |
185 | 115k | MCU_col_num = diff->MCU_ctr; |
186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ |
187 | 115k | MCU_count = |
188 | 115k | (*cinfo->entropy->decode_mcus) (cinfo, |
189 | 115k | diff->diff_buf, yoffset, MCU_col_num, |
190 | 115k | cinfo->MCUs_per_row - MCU_col_num); |
191 | 115k | 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 | 115k | if (cinfo->restart_interval) |
200 | 0 | diff->restart_rows_to_go--; |
201 | | |
202 | | /* Completed an MCU row, but perhaps not an iMCU row */ |
203 | 115k | diff->MCU_ctr = 0; |
204 | 115k | } |
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 | 101k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
212 | 54.1k | compptr = cinfo->cur_comp_info[ci]; |
213 | 54.1k | compi = compptr->component_index; |
214 | 54.1k | for (row = 0, prev_row = compptr->v_samp_factor - 1; |
215 | 181k | row < (cinfo->input_iMCU_row == last_iMCU_row ? |
216 | 180k | compptr->last_row_height : compptr->v_samp_factor); |
217 | 126k | prev_row = row, row++) { |
218 | 126k | (*losslessd->predict_undifference[compi]) |
219 | 126k | (cinfo, compi, diff->diff_buf[compi][row], |
220 | 126k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], |
221 | 126k | compptr->width_in_blocks); |
222 | 126k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], |
223 | 126k | output_buf[compi][row], |
224 | 126k | compptr->width_in_blocks); |
225 | 126k | } |
226 | 54.1k | } |
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 | 46.9k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { |
235 | 45.7k | start_iMCU_row(cinfo); |
236 | 45.7k | return JPEG_ROW_COMPLETED; |
237 | 45.7k | } |
238 | | /* Completed the scan */ |
239 | 1.12k | (*cinfo->inputctl->finish_input_pass) (cinfo); |
240 | 1.12k | return JPEG_SCAN_COMPLETED; |
241 | 46.9k | } jddiffct-8.c:decompress_data Line | Count | Source | 164 | 8.33k | { | 165 | 8.33k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 8.33k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 8.33k | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 8.33k | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 8.33k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 8.33k | int ci, compi, row, prev_row; | 171 | 8.33k | unsigned int yoffset; | 172 | 8.33k | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 23.7k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 15.3k | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 15.3k | if (cinfo->restart_interval) { | 180 | 0 | if (diff->restart_rows_to_go == 0) | 181 | 0 | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 0 | } | 184 | | | 185 | 15.3k | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 15.3k | MCU_count = | 188 | 15.3k | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 15.3k | diff->diff_buf, yoffset, MCU_col_num, | 190 | 15.3k | cinfo->MCUs_per_row - MCU_col_num); | 191 | 15.3k | 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 | 15.3k | if (cinfo->restart_interval) | 200 | 0 | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 15.3k | diff->MCU_ctr = 0; | 204 | 15.3k | } | 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 | 24.4k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 16.1k | compptr = cinfo->cur_comp_info[ci]; | 213 | 16.1k | compi = compptr->component_index; | 214 | 16.1k | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 43.4k | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 43.2k | compptr->last_row_height : compptr->v_samp_factor); | 217 | 27.3k | prev_row = row, row++) { | 218 | 27.3k | (*losslessd->predict_undifference[compi]) | 219 | 27.3k | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 27.3k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 27.3k | compptr->width_in_blocks); | 222 | 27.3k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 27.3k | output_buf[compi][row], | 224 | 27.3k | compptr->width_in_blocks); | 225 | 27.3k | } | 226 | 16.1k | } | 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 | 8.33k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 7.90k | start_iMCU_row(cinfo); | 236 | 7.90k | return JPEG_ROW_COMPLETED; | 237 | 7.90k | } | 238 | | /* Completed the scan */ | 239 | 428 | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 428 | return JPEG_SCAN_COMPLETED; | 241 | 8.33k | } |
jddiffct-12.c:decompress_data Line | Count | Source | 164 | 8.26k | { | 165 | 8.26k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 8.26k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 8.26k | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 8.26k | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 8.26k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 8.26k | int ci, compi, row, prev_row; | 171 | 8.26k | unsigned int yoffset; | 172 | 8.26k | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 26.0k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 17.7k | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 17.7k | if (cinfo->restart_interval) { | 180 | 0 | if (diff->restart_rows_to_go == 0) | 181 | 0 | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 0 | } | 184 | | | 185 | 17.7k | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 17.7k | MCU_count = | 188 | 17.7k | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 17.7k | diff->diff_buf, yoffset, MCU_col_num, | 190 | 17.7k | cinfo->MCUs_per_row - MCU_col_num); | 191 | 17.7k | 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 | 17.7k | if (cinfo->restart_interval) | 200 | 0 | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 17.7k | diff->MCU_ctr = 0; | 204 | 17.7k | } | 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 | 16.2k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 7.98k | compptr = cinfo->cur_comp_info[ci]; | 213 | 7.98k | compi = compptr->component_index; | 214 | 7.98k | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 25.3k | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 25.0k | compptr->last_row_height : compptr->v_samp_factor); | 217 | 17.3k | prev_row = row, row++) { | 218 | 17.3k | (*losslessd->predict_undifference[compi]) | 219 | 17.3k | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 17.3k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 17.3k | compptr->width_in_blocks); | 222 | 17.3k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 17.3k | output_buf[compi][row], | 224 | 17.3k | compptr->width_in_blocks); | 225 | 17.3k | } | 226 | 7.98k | } | 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 | 8.26k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 7.90k | start_iMCU_row(cinfo); | 236 | 7.90k | return JPEG_ROW_COMPLETED; | 237 | 7.90k | } | 238 | | /* Completed the scan */ | 239 | 355 | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 355 | return JPEG_SCAN_COMPLETED; | 241 | 8.26k | } |
jddiffct-16.c:decompress_data Line | Count | Source | 164 | 30.3k | { | 165 | 30.3k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 30.3k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 30.3k | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 30.3k | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 30.3k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 30.3k | int ci, compi, row, prev_row; | 171 | 30.3k | unsigned int yoffset; | 172 | 30.3k | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 112k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 82.6k | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 82.6k | if (cinfo->restart_interval) { | 180 | 0 | if (diff->restart_rows_to_go == 0) | 181 | 0 | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 0 | } | 184 | | | 185 | 82.6k | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 82.6k | MCU_count = | 188 | 82.6k | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 82.6k | diff->diff_buf, yoffset, MCU_col_num, | 190 | 82.6k | cinfo->MCUs_per_row - MCU_col_num); | 191 | 82.6k | 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 | 82.6k | if (cinfo->restart_interval) | 200 | 0 | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 82.6k | diff->MCU_ctr = 0; | 204 | 82.6k | } | 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 | 60.3k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 30.0k | compptr = cinfo->cur_comp_info[ci]; | 213 | 30.0k | compi = compptr->component_index; | 214 | 30.0k | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 112k | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 112k | compptr->last_row_height : compptr->v_samp_factor); | 217 | 82.2k | prev_row = row, row++) { | 218 | 82.2k | (*losslessd->predict_undifference[compi]) | 219 | 82.2k | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 82.2k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 82.2k | compptr->width_in_blocks); | 222 | 82.2k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 82.2k | output_buf[compi][row], | 224 | 82.2k | compptr->width_in_blocks); | 225 | 82.2k | } | 226 | 30.0k | } | 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 | 30.3k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 29.9k | start_iMCU_row(cinfo); | 236 | 29.9k | return JPEG_ROW_COMPLETED; | 237 | 29.9k | } | 238 | | /* Completed the scan */ | 239 | 346 | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 346 | return JPEG_SCAN_COMPLETED; | 241 | 30.3k | } |
|
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 | 42.6k | { |
267 | 42.6k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
268 | 42.6k | int ci, compi; |
269 | 42.6k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; |
270 | 42.6k | jpeg_component_info *compptr; |
271 | | |
272 | | /* Align the virtual buffers for the components used in this scan. */ |
273 | 85.3k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
274 | 42.6k | compptr = cinfo->cur_comp_info[ci]; |
275 | 42.6k | compi = compptr->component_index; |
276 | 42.6k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) |
277 | 42.6k | ((j_common_ptr)cinfo, diff->whole_image[compi], |
278 | 42.6k | cinfo->input_iMCU_row * compptr->v_samp_factor, |
279 | 42.6k | (JDIMENSION)compptr->v_samp_factor, TRUE); |
280 | 42.6k | } |
281 | | |
282 | 42.6k | return decompress_data(cinfo, buffer); |
283 | 42.6k | } jddiffct-8.c:consume_data Line | Count | Source | 266 | 4.10k | { | 267 | 4.10k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 4.10k | int ci, compi; | 269 | 4.10k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 4.10k | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 8.20k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 4.10k | compptr = cinfo->cur_comp_info[ci]; | 275 | 4.10k | compi = compptr->component_index; | 276 | 4.10k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 4.10k | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 4.10k | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 4.10k | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 4.10k | } | 281 | | | 282 | 4.10k | return decompress_data(cinfo, buffer); | 283 | 4.10k | } |
jddiffct-12.c:consume_data Line | Count | Source | 266 | 8.26k | { | 267 | 8.26k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 8.26k | int ci, compi; | 269 | 8.26k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 8.26k | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 16.5k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 8.26k | compptr = cinfo->cur_comp_info[ci]; | 275 | 8.26k | compi = compptr->component_index; | 276 | 8.26k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 8.26k | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 8.26k | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 8.26k | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 8.26k | } | 281 | | | 282 | 8.26k | return decompress_data(cinfo, buffer); | 283 | 8.26k | } |
jddiffct-16.c:consume_data Line | Count | Source | 266 | 30.3k | { | 267 | 30.3k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 30.3k | int ci, compi; | 269 | 30.3k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 30.3k | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 60.6k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 30.3k | compptr = cinfo->cur_comp_info[ci]; | 275 | 30.3k | compi = compptr->component_index; | 276 | 30.3k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 30.3k | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 30.3k | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 30.3k | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 30.3k | } | 281 | | | 282 | 30.3k | return decompress_data(cinfo, buffer); | 283 | 30.3k | } |
|
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 | 6 | { |
297 | 6 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
298 | 6 | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
299 | 6 | int ci, samp_rows, row; |
300 | 6 | _JSAMPARRAY buffer; |
301 | 6 | jpeg_component_info *compptr; |
302 | | |
303 | | /* Force some input to be done if we are getting ahead of the input. */ |
304 | 6 | while (cinfo->input_scan_number < cinfo->output_scan_number || |
305 | 6 | (cinfo->input_scan_number == cinfo->output_scan_number && |
306 | 6 | 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 | 18 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
313 | 12 | ci++, compptr++) { |
314 | | /* Align the virtual buffer for this component. */ |
315 | 12 | buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) |
316 | 12 | ((j_common_ptr)cinfo, diff->whole_image[ci], |
317 | 12 | cinfo->output_iMCU_row * compptr->v_samp_factor, |
318 | 12 | (JDIMENSION)compptr->v_samp_factor, FALSE); |
319 | | |
320 | 12 | if (cinfo->output_iMCU_row < last_iMCU_row) |
321 | 1 | samp_rows = compptr->v_samp_factor; |
322 | 11 | else { |
323 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ |
324 | 11 | samp_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); |
325 | 11 | if (samp_rows == 0) samp_rows = compptr->v_samp_factor; |
326 | 11 | } |
327 | | |
328 | 28 | for (row = 0; row < samp_rows; row++) { |
329 | 16 | memcpy(output_buf[ci][row], buffer[row], |
330 | 16 | compptr->width_in_blocks * sizeof(_JSAMPLE)); |
331 | 16 | } |
332 | 12 | } |
333 | | |
334 | 6 | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) |
335 | 0 | return JPEG_ROW_COMPLETED; |
336 | 6 | return JPEG_SCAN_COMPLETED; |
337 | 6 | } Line | Count | Source | 296 | 6 | { | 297 | 6 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 298 | 6 | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 299 | 6 | int ci, samp_rows, row; | 300 | 6 | _JSAMPARRAY buffer; | 301 | 6 | jpeg_component_info *compptr; | 302 | | | 303 | | /* Force some input to be done if we are getting ahead of the input. */ | 304 | 6 | while (cinfo->input_scan_number < cinfo->output_scan_number || | 305 | 6 | (cinfo->input_scan_number == cinfo->output_scan_number && | 306 | 6 | 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 | 18 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 313 | 12 | ci++, compptr++) { | 314 | | /* Align the virtual buffer for this component. */ | 315 | 12 | buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 316 | 12 | ((j_common_ptr)cinfo, diff->whole_image[ci], | 317 | 12 | cinfo->output_iMCU_row * compptr->v_samp_factor, | 318 | 12 | (JDIMENSION)compptr->v_samp_factor, FALSE); | 319 | | | 320 | 12 | if (cinfo->output_iMCU_row < last_iMCU_row) | 321 | 1 | samp_rows = compptr->v_samp_factor; | 322 | 11 | else { | 323 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ | 324 | 11 | samp_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); | 325 | 11 | if (samp_rows == 0) samp_rows = compptr->v_samp_factor; | 326 | 11 | } | 327 | | | 328 | 28 | for (row = 0; row < samp_rows; row++) { | 329 | 16 | memcpy(output_buf[ci][row], buffer[row], | 330 | 16 | compptr->width_in_blocks * sizeof(_JSAMPLE)); | 331 | 16 | } | 332 | 12 | } | 333 | | | 334 | 6 | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) | 335 | 0 | return JPEG_ROW_COMPLETED; | 336 | 6 | return JPEG_SCAN_COMPLETED; | 337 | 6 | } |
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 | 1.09k | { |
349 | 1.09k | my_diff_ptr diff; |
350 | 1.09k | int ci; |
351 | 1.09k | jpeg_component_info *compptr; |
352 | | |
353 | | #if BITS_IN_JSAMPLE == 8 |
354 | 417 | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) |
355 | | #else |
356 | 679 | if (cinfo->data_precision > BITS_IN_JSAMPLE || |
357 | 679 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) |
358 | 0 | #endif |
359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
360 | | |
361 | 1.09k | diff = (my_diff_ptr) |
362 | 1.09k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
363 | 1.09k | sizeof(my_diff_controller)); |
364 | 1.09k | cinfo->coef = (struct jpeg_d_coef_controller *)diff; |
365 | 1.09k | diff->pub.start_input_pass = start_input_pass; |
366 | 1.09k | diff->pub.start_output_pass = start_output_pass; |
367 | | |
368 | | /* Create the [un]difference buffers. */ |
369 | 4.38k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
370 | 3.29k | ci++, compptr++) { |
371 | 3.29k | diff->diff_buf[ci] = |
372 | 3.29k | ALLOC_DARRAY(JPOOL_IMAGE, |
373 | 3.29k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
374 | 3.29k | (long)compptr->h_samp_factor), |
375 | 3.29k | (JDIMENSION)compptr->v_samp_factor); |
376 | 3.29k | diff->undiff_buf[ci] = |
377 | 3.29k | ALLOC_DARRAY(JPOOL_IMAGE, |
378 | 3.29k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
379 | 3.29k | (long)compptr->h_samp_factor), |
380 | 3.29k | (JDIMENSION)compptr->v_samp_factor); |
381 | 3.29k | } |
382 | | |
383 | 1.09k | if (need_full_buffer) { |
384 | 919 | #ifdef D_MULTISCAN_FILES_SUPPORTED |
385 | | /* Allocate a full-image virtual array for each component. */ |
386 | 919 | int access_rows; |
387 | | |
388 | 3.67k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
389 | 2.75k | ci++, compptr++) { |
390 | 2.75k | access_rows = compptr->v_samp_factor; |
391 | 2.75k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) |
392 | 2.75k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, |
393 | 2.75k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
394 | 2.75k | (long)compptr->h_samp_factor), |
395 | 2.75k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, |
396 | 2.75k | (long)compptr->v_samp_factor), |
397 | 2.75k | (JDIMENSION)access_rows); |
398 | 2.75k | } |
399 | 919 | diff->pub.consume_data = consume_data; |
400 | 919 | diff->pub._decompress_data = output_data; |
401 | | #else |
402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); |
403 | | #endif |
404 | 919 | } else { |
405 | 177 | diff->pub.consume_data = dummy_consume_data; |
406 | 177 | diff->pub._decompress_data = decompress_data; |
407 | 177 | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ |
408 | 177 | } |
409 | 1.09k | } Line | Count | Source | 348 | 417 | { | 349 | 417 | my_diff_ptr diff; | 350 | 417 | int ci; | 351 | 417 | jpeg_component_info *compptr; | 352 | | | 353 | 417 | #if BITS_IN_JSAMPLE == 8 | 354 | 417 | 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 | 417 | diff = (my_diff_ptr) | 362 | 417 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 417 | sizeof(my_diff_controller)); | 364 | 417 | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 417 | diff->pub.start_input_pass = start_input_pass; | 366 | 417 | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 1.66k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 1.25k | ci++, compptr++) { | 371 | 1.25k | diff->diff_buf[ci] = | 372 | 1.25k | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 1.25k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 1.25k | (long)compptr->h_samp_factor), | 375 | 1.25k | (JDIMENSION)compptr->v_samp_factor); | 376 | 1.25k | diff->undiff_buf[ci] = | 377 | 1.25k | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 1.25k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 1.25k | (long)compptr->h_samp_factor), | 380 | 1.25k | (JDIMENSION)compptr->v_samp_factor); | 381 | 1.25k | } | 382 | | | 383 | 417 | if (need_full_buffer) { | 384 | 249 | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 249 | int access_rows; | 387 | | | 388 | 996 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 747 | ci++, compptr++) { | 390 | 747 | access_rows = compptr->v_samp_factor; | 391 | 747 | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 747 | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 747 | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 747 | (long)compptr->h_samp_factor), | 395 | 747 | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 747 | (long)compptr->v_samp_factor), | 397 | 747 | (JDIMENSION)access_rows); | 398 | 747 | } | 399 | 249 | diff->pub.consume_data = consume_data; | 400 | 249 | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 249 | } else { | 405 | 168 | diff->pub.consume_data = dummy_consume_data; | 406 | 168 | diff->pub._decompress_data = decompress_data; | 407 | 168 | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 168 | } | 409 | 417 | } |
j12init_d_diff_controller Line | Count | Source | 348 | 335 | { | 349 | 335 | my_diff_ptr diff; | 350 | 335 | int ci; | 351 | 335 | 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 | 335 | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 357 | 335 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 358 | 0 | #endif | 359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 360 | | | 361 | 335 | diff = (my_diff_ptr) | 362 | 335 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 335 | sizeof(my_diff_controller)); | 364 | 335 | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 335 | diff->pub.start_input_pass = start_input_pass; | 366 | 335 | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 1.34k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 1.00k | ci++, compptr++) { | 371 | 1.00k | diff->diff_buf[ci] = | 372 | 1.00k | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 1.00k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 1.00k | (long)compptr->h_samp_factor), | 375 | 1.00k | (JDIMENSION)compptr->v_samp_factor); | 376 | 1.00k | diff->undiff_buf[ci] = | 377 | 1.00k | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 1.00k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 1.00k | (long)compptr->h_samp_factor), | 380 | 1.00k | (JDIMENSION)compptr->v_samp_factor); | 381 | 1.00k | } | 382 | | | 383 | 335 | if (need_full_buffer) { | 384 | 330 | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 330 | int access_rows; | 387 | | | 388 | 1.32k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 990 | ci++, compptr++) { | 390 | 990 | access_rows = compptr->v_samp_factor; | 391 | 990 | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 990 | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 990 | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 990 | (long)compptr->h_samp_factor), | 395 | 990 | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 990 | (long)compptr->v_samp_factor), | 397 | 990 | (JDIMENSION)access_rows); | 398 | 990 | } | 399 | 330 | diff->pub.consume_data = consume_data; | 400 | 330 | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 330 | } else { | 405 | 5 | diff->pub.consume_data = dummy_consume_data; | 406 | 5 | diff->pub._decompress_data = decompress_data; | 407 | 5 | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 5 | } | 409 | 335 | } |
j16init_d_diff_controller Line | Count | Source | 348 | 344 | { | 349 | 344 | my_diff_ptr diff; | 350 | 344 | int ci; | 351 | 344 | 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 | 344 | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 357 | 344 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 358 | 0 | #endif | 359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 360 | | | 361 | 344 | diff = (my_diff_ptr) | 362 | 344 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 344 | sizeof(my_diff_controller)); | 364 | 344 | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 344 | diff->pub.start_input_pass = start_input_pass; | 366 | 344 | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 1.37k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 1.03k | ci++, compptr++) { | 371 | 1.03k | diff->diff_buf[ci] = | 372 | 1.03k | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 1.03k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 1.03k | (long)compptr->h_samp_factor), | 375 | 1.03k | (JDIMENSION)compptr->v_samp_factor); | 376 | 1.03k | diff->undiff_buf[ci] = | 377 | 1.03k | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 1.03k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 1.03k | (long)compptr->h_samp_factor), | 380 | 1.03k | (JDIMENSION)compptr->v_samp_factor); | 381 | 1.03k | } | 382 | | | 383 | 344 | if (need_full_buffer) { | 384 | 340 | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 340 | int access_rows; | 387 | | | 388 | 1.36k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 1.02k | ci++, compptr++) { | 390 | 1.02k | access_rows = compptr->v_samp_factor; | 391 | 1.02k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 1.02k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 1.02k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 1.02k | (long)compptr->h_samp_factor), | 395 | 1.02k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 1.02k | (long)compptr->v_samp_factor), | 397 | 1.02k | (JDIMENSION)access_rows); | 398 | 1.02k | } | 399 | 340 | diff->pub.consume_data = consume_data; | 400 | 340 | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 340 | } else { | 405 | 4 | diff->pub.consume_data = dummy_consume_data; | 406 | 4 | diff->pub._decompress_data = decompress_data; | 407 | 4 | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 4 | } | 409 | 344 | } |
|
410 | | |
411 | | #endif /* D_LOSSLESS_SUPPORTED */ |