/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 | 94.8k | { |
68 | 94.8k | 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 | 94.8k | if (cinfo->comps_in_scan > 1) { |
75 | 3.79k | diff->MCU_rows_per_iMCU_row = 1; |
76 | 91.0k | } else { |
77 | 91.0k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) |
78 | 88.2k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; |
79 | 2.87k | else |
80 | 2.87k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; |
81 | 91.0k | } |
82 | | |
83 | 94.8k | diff->MCU_ctr = 0; |
84 | 94.8k | diff->MCU_vert_offset = 0; |
85 | 94.8k | } jddiffct-8.c:start_iMCU_row Line | Count | Source | 67 | 9.31k | { | 68 | 9.31k | 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 | 9.31k | if (cinfo->comps_in_scan > 1) { | 75 | 3.74k | diff->MCU_rows_per_iMCU_row = 1; | 76 | 5.57k | } else { | 77 | 5.57k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 5.17k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 398 | else | 80 | 398 | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 5.57k | } | 82 | | | 83 | 9.31k | diff->MCU_ctr = 0; | 84 | 9.31k | diff->MCU_vert_offset = 0; | 85 | 9.31k | } |
jddiffct-12.c:start_iMCU_row Line | Count | Source | 67 | 69.4k | { | 68 | 69.4k | 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 | 69.4k | if (cinfo->comps_in_scan > 1) { | 75 | 28 | diff->MCU_rows_per_iMCU_row = 1; | 76 | 69.4k | } else { | 77 | 69.4k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 67.8k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 1.50k | else | 80 | 1.50k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 69.4k | } | 82 | | | 83 | 69.4k | diff->MCU_ctr = 0; | 84 | 69.4k | diff->MCU_vert_offset = 0; | 85 | 69.4k | } |
jddiffct-16.c:start_iMCU_row Line | Count | Source | 67 | 16.1k | { | 68 | 16.1k | 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 | 16.1k | if (cinfo->comps_in_scan > 1) { | 75 | 17 | diff->MCU_rows_per_iMCU_row = 1; | 76 | 16.1k | } else { | 77 | 16.1k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 15.1k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 970 | else | 80 | 970 | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 16.1k | } | 82 | | | 83 | 16.1k | diff->MCU_ctr = 0; | 84 | 16.1k | diff->MCU_vert_offset = 0; | 85 | 16.1k | } |
|
86 | | |
87 | | |
88 | | /* |
89 | | * Initialize for an input processing pass. |
90 | | */ |
91 | | |
92 | | METHODDEF(void) |
93 | | start_input_pass(j_decompress_ptr cinfo) |
94 | 4.59k | { |
95 | 4.59k | 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 | 4.59k | (*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 | 4.59k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) |
108 | 21 | ERREXIT2(cinfo, JERR_BAD_RESTART, |
109 | 4.59k | cinfo->restart_interval, cinfo->MCUs_per_row); |
110 | | |
111 | | /* Initialize restart counter */ |
112 | 4.59k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; |
113 | | |
114 | 4.59k | cinfo->input_iMCU_row = 0; |
115 | 4.59k | start_iMCU_row(cinfo); |
116 | 4.59k | } jddiffct-8.c:start_input_pass Line | Count | Source | 94 | 1.14k | { | 95 | 1.14k | 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.14k | (*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.14k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 5 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 1.14k | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 1.14k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 1.14k | cinfo->input_iMCU_row = 0; | 115 | 1.14k | start_iMCU_row(cinfo); | 116 | 1.14k | } |
jddiffct-12.c:start_input_pass Line | Count | Source | 94 | 1.97k | { | 95 | 1.97k | 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.97k | (*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.97k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 10 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 1.97k | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 1.97k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 1.97k | cinfo->input_iMCU_row = 0; | 115 | 1.97k | start_iMCU_row(cinfo); | 116 | 1.97k | } |
jddiffct-16.c:start_input_pass Line | Count | Source | 94 | 1.47k | { | 95 | 1.47k | 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.47k | (*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.47k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 6 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 1.47k | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 1.47k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 1.47k | cinfo->input_iMCU_row = 0; | 115 | 1.47k | start_iMCU_row(cinfo); | 116 | 1.47k | } |
|
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 | 9 | { |
127 | 9 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
128 | | |
129 | 9 | if (!(*cinfo->entropy->process_restart) (cinfo)) |
130 | 0 | return FALSE; |
131 | | |
132 | 9 | (*cinfo->idct->start_pass) (cinfo); |
133 | | |
134 | | /* Reset restart counter */ |
135 | 9 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; |
136 | | |
137 | 9 | return TRUE; |
138 | 9 | } jddiffct-8.c:process_restart Line | Count | Source | 126 | 4 | { | 127 | 4 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 128 | | | 129 | 4 | if (!(*cinfo->entropy->process_restart) (cinfo)) | 130 | 0 | return FALSE; | 131 | | | 132 | 4 | (*cinfo->idct->start_pass) (cinfo); | 133 | | | 134 | | /* Reset restart counter */ | 135 | 4 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 136 | | | 137 | 4 | return TRUE; | 138 | 4 | } |
jddiffct-12.c:process_restart Line | Count | Source | 126 | 3 | { | 127 | 3 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 128 | | | 129 | 3 | if (!(*cinfo->entropy->process_restart) (cinfo)) | 130 | 0 | return FALSE; | 131 | | | 132 | 3 | (*cinfo->idct->start_pass) (cinfo); | 133 | | | 134 | | /* Reset restart counter */ | 135 | 3 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 136 | | | 137 | 3 | return TRUE; | 138 | 3 | } |
jddiffct-16.c:process_restart Line | Count | Source | 126 | 2 | { | 127 | 2 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 128 | | | 129 | 2 | if (!(*cinfo->entropy->process_restart) (cinfo)) | 130 | 0 | return FALSE; | 131 | | | 132 | 2 | (*cinfo->idct->start_pass) (cinfo); | 133 | | | 134 | | /* Reset restart counter */ | 135 | 2 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 136 | | | 137 | 2 | return TRUE; | 138 | 2 | } |
|
139 | | |
140 | | |
141 | | /* |
142 | | * Initialize for an output processing pass. |
143 | | */ |
144 | | |
145 | | METHODDEF(void) |
146 | | start_output_pass(j_decompress_ptr cinfo) |
147 | 605 | { |
148 | 605 | cinfo->output_iMCU_row = 0; |
149 | 605 | } jddiffct-8.c:start_output_pass Line | Count | Source | 147 | 548 | { | 148 | 548 | cinfo->output_iMCU_row = 0; | 149 | 548 | } |
jddiffct-12.c:start_output_pass Line | Count | Source | 147 | 30 | { | 148 | 30 | cinfo->output_iMCU_row = 0; | 149 | 30 | } |
jddiffct-16.c:start_output_pass Line | Count | Source | 147 | 27 | { | 148 | 27 | cinfo->output_iMCU_row = 0; | 149 | 27 | } |
|
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 | 94.8k | { |
165 | 94.8k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
166 | 94.8k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; |
167 | 94.8k | JDIMENSION MCU_col_num; /* index of current MCU within row */ |
168 | 94.8k | JDIMENSION MCU_count; /* number of MCUs decoded */ |
169 | 94.8k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
170 | 94.8k | int ci, compi, row, prev_row; |
171 | 94.8k | unsigned int yoffset; |
172 | 94.8k | jpeg_component_info *compptr; |
173 | | |
174 | | /* Loop to process as much as one whole iMCU row */ |
175 | 273k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; |
176 | 178k | yoffset++) { |
177 | | |
178 | | /* Process restart marker if needed; may have to suspend */ |
179 | 178k | if (cinfo->restart_interval) { |
180 | 36.9k | if (diff->restart_rows_to_go == 0) |
181 | 9 | if (!process_restart(cinfo)) |
182 | 0 | return JPEG_SUSPENDED; |
183 | 36.9k | } |
184 | | |
185 | 178k | MCU_col_num = diff->MCU_ctr; |
186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ |
187 | 178k | MCU_count = |
188 | 178k | (*cinfo->entropy->decode_mcus) (cinfo, |
189 | 178k | diff->diff_buf, yoffset, MCU_col_num, |
190 | 178k | cinfo->MCUs_per_row - MCU_col_num); |
191 | 178k | 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 | 178k | if (cinfo->restart_interval) |
200 | 36.8k | diff->restart_rows_to_go--; |
201 | | |
202 | | /* Completed an MCU row, but perhaps not an iMCU row */ |
203 | 178k | diff->MCU_ctr = 0; |
204 | 178k | } |
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 | 197k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
212 | 103k | compptr = cinfo->cur_comp_info[ci]; |
213 | 103k | compi = compptr->component_index; |
214 | 103k | for (row = 0, prev_row = compptr->v_samp_factor - 1; |
215 | 293k | row < (cinfo->input_iMCU_row == last_iMCU_row ? |
216 | 287k | compptr->last_row_height : compptr->v_samp_factor); |
217 | 190k | prev_row = row, row++) { |
218 | 190k | (*losslessd->predict_undifference[compi]) |
219 | 190k | (cinfo, compi, diff->diff_buf[compi][row], |
220 | 190k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], |
221 | 190k | compptr->width_in_blocks); |
222 | 190k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], |
223 | 190k | output_buf[compi][row], |
224 | 190k | compptr->width_in_blocks); |
225 | 190k | } |
226 | 103k | } |
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 | 94.8k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { |
235 | 90.4k | start_iMCU_row(cinfo); |
236 | 90.4k | return JPEG_ROW_COMPLETED; |
237 | 90.4k | } |
238 | | /* Completed the scan */ |
239 | 4.35k | (*cinfo->inputctl->finish_input_pass) (cinfo); |
240 | 4.35k | return JPEG_SCAN_COMPLETED; |
241 | 94.8k | } jddiffct-8.c:decompress_data Line | Count | Source | 164 | 9.31k | { | 165 | 9.31k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 9.31k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 9.31k | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 9.31k | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 9.31k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 9.31k | int ci, compi, row, prev_row; | 171 | 9.31k | unsigned int yoffset; | 172 | 9.31k | 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 | 14.4k | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 14.4k | if (cinfo->restart_interval) { | 180 | 244 | if (diff->restart_rows_to_go == 0) | 181 | 4 | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 244 | } | 184 | | | 185 | 14.4k | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 14.4k | MCU_count = | 188 | 14.4k | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 14.4k | diff->diff_buf, yoffset, MCU_col_num, | 190 | 14.4k | cinfo->MCUs_per_row - MCU_col_num); | 191 | 14.4k | 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 | 14.4k | if (cinfo->restart_interval) | 200 | 235 | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 14.4k | diff->MCU_ctr = 0; | 204 | 14.4k | } | 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 | 27.6k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 18.3k | compptr = cinfo->cur_comp_info[ci]; | 213 | 18.3k | compi = compptr->component_index; | 214 | 18.3k | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 46.0k | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 45.0k | compptr->last_row_height : compptr->v_samp_factor); | 217 | 27.7k | prev_row = row, row++) { | 218 | 27.7k | (*losslessd->predict_undifference[compi]) | 219 | 27.7k | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 27.7k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 27.7k | compptr->width_in_blocks); | 222 | 27.7k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 27.7k | output_buf[compi][row], | 224 | 27.7k | compptr->width_in_blocks); | 225 | 27.7k | } | 226 | 18.3k | } | 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 | 9.31k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 8.25k | start_iMCU_row(cinfo); | 236 | 8.25k | return JPEG_ROW_COMPLETED; | 237 | 8.25k | } | 238 | | /* Completed the scan */ | 239 | 1.06k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 1.06k | return JPEG_SCAN_COMPLETED; | 241 | 9.31k | } |
jddiffct-12.c:decompress_data Line | Count | Source | 164 | 69.4k | { | 165 | 69.4k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 69.4k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 69.4k | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 69.4k | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 69.4k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 69.4k | int ci, compi, row, prev_row; | 171 | 69.4k | unsigned int yoffset; | 172 | 69.4k | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 203k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 134k | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 134k | if (cinfo->restart_interval) { | 180 | 25.8k | if (diff->restart_rows_to_go == 0) | 181 | 3 | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 25.8k | } | 184 | | | 185 | 134k | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 134k | MCU_count = | 188 | 134k | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 134k | diff->diff_buf, yoffset, MCU_col_num, | 190 | 134k | cinfo->MCUs_per_row - MCU_col_num); | 191 | 134k | 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 | 134k | if (cinfo->restart_interval) | 200 | 25.8k | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 134k | diff->MCU_ctr = 0; | 204 | 134k | } | 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 | 138k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 68.9k | compptr = cinfo->cur_comp_info[ci]; | 213 | 68.9k | compi = compptr->component_index; | 214 | 68.9k | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 202k | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 199k | compptr->last_row_height : compptr->v_samp_factor); | 217 | 133k | prev_row = row, row++) { | 218 | 133k | (*losslessd->predict_undifference[compi]) | 219 | 133k | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 133k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 133k | compptr->width_in_blocks); | 222 | 133k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 133k | output_buf[compi][row], | 224 | 133k | compptr->width_in_blocks); | 225 | 133k | } | 226 | 68.9k | } | 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 | 69.4k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 67.5k | start_iMCU_row(cinfo); | 236 | 67.5k | return JPEG_ROW_COMPLETED; | 237 | 67.5k | } | 238 | | /* Completed the scan */ | 239 | 1.90k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 1.90k | return JPEG_SCAN_COMPLETED; | 241 | 69.4k | } |
jddiffct-16.c:decompress_data Line | Count | Source | 164 | 16.1k | { | 165 | 16.1k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 16.1k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 16.1k | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 16.1k | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 16.1k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 16.1k | int ci, compi, row, prev_row; | 171 | 16.1k | unsigned int yoffset; | 172 | 16.1k | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 45.9k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 29.8k | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 29.8k | if (cinfo->restart_interval) { | 180 | 10.7k | if (diff->restart_rows_to_go == 0) | 181 | 2 | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 10.7k | } | 184 | | | 185 | 29.8k | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 29.8k | MCU_count = | 188 | 29.8k | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 29.8k | diff->diff_buf, yoffset, MCU_col_num, | 190 | 29.8k | cinfo->MCUs_per_row - MCU_col_num); | 191 | 29.8k | 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 | 29.8k | if (cinfo->restart_interval) | 200 | 10.7k | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 29.8k | diff->MCU_ctr = 0; | 204 | 29.8k | } | 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 | 31.7k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 15.6k | compptr = cinfo->cur_comp_info[ci]; | 213 | 15.6k | compi = compptr->component_index; | 214 | 15.6k | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 44.9k | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 42.6k | compptr->last_row_height : compptr->v_samp_factor); | 217 | 29.2k | prev_row = row, row++) { | 218 | 29.2k | (*losslessd->predict_undifference[compi]) | 219 | 29.2k | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 29.2k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 29.2k | compptr->width_in_blocks); | 222 | 29.2k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 29.2k | output_buf[compi][row], | 224 | 29.2k | compptr->width_in_blocks); | 225 | 29.2k | } | 226 | 15.6k | } | 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 | 16.1k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 14.7k | start_iMCU_row(cinfo); | 236 | 14.7k | return JPEG_ROW_COMPLETED; | 237 | 14.7k | } | 238 | | /* Completed the scan */ | 239 | 1.39k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 1.39k | return JPEG_SCAN_COMPLETED; | 241 | 16.1k | } |
|
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 | 91.0k | { |
267 | 91.0k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
268 | 91.0k | int ci, compi; |
269 | 91.0k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; |
270 | 91.0k | jpeg_component_info *compptr; |
271 | | |
272 | | /* Align the virtual buffers for the components used in this scan. */ |
273 | 182k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
274 | 91.0k | compptr = cinfo->cur_comp_info[ci]; |
275 | 91.0k | compi = compptr->component_index; |
276 | 91.0k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) |
277 | 91.0k | ((j_common_ptr)cinfo, diff->whole_image[compi], |
278 | 91.0k | cinfo->input_iMCU_row * compptr->v_samp_factor, |
279 | 91.0k | (JDIMENSION)compptr->v_samp_factor, TRUE); |
280 | 91.0k | } |
281 | | |
282 | 91.0k | return decompress_data(cinfo, buffer); |
283 | 91.0k | } jddiffct-8.c:consume_data Line | Count | Source | 266 | 5.57k | { | 267 | 5.57k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 5.57k | int ci, compi; | 269 | 5.57k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 5.57k | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 11.1k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 5.57k | compptr = cinfo->cur_comp_info[ci]; | 275 | 5.57k | compi = compptr->component_index; | 276 | 5.57k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 5.57k | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 5.57k | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 5.57k | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 5.57k | } | 281 | | | 282 | 5.57k | return decompress_data(cinfo, buffer); | 283 | 5.57k | } |
jddiffct-12.c:consume_data Line | Count | Source | 266 | 69.4k | { | 267 | 69.4k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 69.4k | int ci, compi; | 269 | 69.4k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 69.4k | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 138k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 69.4k | compptr = cinfo->cur_comp_info[ci]; | 275 | 69.4k | compi = compptr->component_index; | 276 | 69.4k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 69.4k | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 69.4k | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 69.4k | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 69.4k | } | 281 | | | 282 | 69.4k | return decompress_data(cinfo, buffer); | 283 | 69.4k | } |
jddiffct-16.c:consume_data Line | Count | Source | 266 | 16.1k | { | 267 | 16.1k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 16.1k | int ci, compi; | 269 | 16.1k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 16.1k | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 32.2k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 16.1k | compptr = cinfo->cur_comp_info[ci]; | 275 | 16.1k | compi = compptr->component_index; | 276 | 16.1k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 16.1k | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 16.1k | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 16.1k | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 16.1k | } | 281 | | | 282 | 16.1k | return decompress_data(cinfo, buffer); | 283 | 16.1k | } |
|
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 | 21 | { |
297 | 21 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
298 | 21 | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
299 | 21 | int ci, samp_rows, row; |
300 | 21 | _JSAMPARRAY buffer; |
301 | 21 | jpeg_component_info *compptr; |
302 | | |
303 | | /* Force some input to be done if we are getting ahead of the input. */ |
304 | 21 | while (cinfo->input_scan_number < cinfo->output_scan_number || |
305 | 21 | (cinfo->input_scan_number == cinfo->output_scan_number && |
306 | 21 | 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 | 67 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
313 | 46 | ci++, compptr++) { |
314 | | /* Align the virtual buffer for this component. */ |
315 | 46 | buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) |
316 | 46 | ((j_common_ptr)cinfo, diff->whole_image[ci], |
317 | 46 | cinfo->output_iMCU_row * compptr->v_samp_factor, |
318 | 46 | (JDIMENSION)compptr->v_samp_factor, FALSE); |
319 | | |
320 | 46 | if (cinfo->output_iMCU_row < last_iMCU_row) |
321 | 9 | samp_rows = compptr->v_samp_factor; |
322 | 37 | else { |
323 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ |
324 | 37 | samp_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); |
325 | 37 | if (samp_rows == 0) samp_rows = compptr->v_samp_factor; |
326 | 37 | } |
327 | | |
328 | 92 | for (row = 0; row < samp_rows; row++) { |
329 | 46 | memcpy(output_buf[ci][row], buffer[row], |
330 | 46 | compptr->width_in_blocks * sizeof(_JSAMPLE)); |
331 | 46 | } |
332 | 46 | } |
333 | | |
334 | 21 | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) |
335 | 0 | return JPEG_ROW_COMPLETED; |
336 | 21 | return JPEG_SCAN_COMPLETED; |
337 | 21 | } Line | Count | Source | 296 | 21 | { | 297 | 21 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 298 | 21 | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 299 | 21 | int ci, samp_rows, row; | 300 | 21 | _JSAMPARRAY buffer; | 301 | 21 | jpeg_component_info *compptr; | 302 | | | 303 | | /* Force some input to be done if we are getting ahead of the input. */ | 304 | 21 | while (cinfo->input_scan_number < cinfo->output_scan_number || | 305 | 21 | (cinfo->input_scan_number == cinfo->output_scan_number && | 306 | 21 | 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 | 67 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 313 | 46 | ci++, compptr++) { | 314 | | /* Align the virtual buffer for this component. */ | 315 | 46 | buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 316 | 46 | ((j_common_ptr)cinfo, diff->whole_image[ci], | 317 | 46 | cinfo->output_iMCU_row * compptr->v_samp_factor, | 318 | 46 | (JDIMENSION)compptr->v_samp_factor, FALSE); | 319 | | | 320 | 46 | if (cinfo->output_iMCU_row < last_iMCU_row) | 321 | 9 | samp_rows = compptr->v_samp_factor; | 322 | 37 | else { | 323 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ | 324 | 37 | samp_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); | 325 | 37 | if (samp_rows == 0) samp_rows = compptr->v_samp_factor; | 326 | 37 | } | 327 | | | 328 | 92 | for (row = 0; row < samp_rows; row++) { | 329 | 46 | memcpy(output_buf[ci][row], buffer[row], | 330 | 46 | compptr->width_in_blocks * sizeof(_JSAMPLE)); | 331 | 46 | } | 332 | 46 | } | 333 | | | 334 | 21 | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) | 335 | 0 | return JPEG_ROW_COMPLETED; | 336 | 21 | return JPEG_SCAN_COMPLETED; | 337 | 21 | } |
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 | 2.20k | { |
349 | 2.20k | my_diff_ptr diff; |
350 | 2.20k | int ci; |
351 | 2.20k | jpeg_component_info *compptr; |
352 | | |
353 | | #if BITS_IN_JSAMPLE == 8 |
354 | 854 | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) |
355 | | #else |
356 | 1.35k | if (cinfo->data_precision > BITS_IN_JSAMPLE || |
357 | 1.35k | cinfo->data_precision < BITS_IN_JSAMPLE - 3) |
358 | 0 | #endif |
359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
360 | | |
361 | 2.20k | diff = (my_diff_ptr) |
362 | 2.20k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
363 | 2.20k | sizeof(my_diff_controller)); |
364 | 2.20k | cinfo->coef = (struct jpeg_d_coef_controller *)diff; |
365 | 2.20k | diff->pub.start_input_pass = start_input_pass; |
366 | 2.20k | diff->pub.start_output_pass = start_output_pass; |
367 | | |
368 | | /* Create the [un]difference buffers. */ |
369 | 9.49k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
370 | 7.28k | ci++, compptr++) { |
371 | 7.28k | diff->diff_buf[ci] = |
372 | 7.28k | ALLOC_DARRAY(JPOOL_IMAGE, |
373 | 7.28k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
374 | 7.28k | (long)compptr->h_samp_factor), |
375 | 7.28k | (JDIMENSION)compptr->v_samp_factor); |
376 | 7.28k | diff->undiff_buf[ci] = |
377 | 7.28k | ALLOC_DARRAY(JPOOL_IMAGE, |
378 | 7.28k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
379 | 7.28k | (long)compptr->h_samp_factor), |
380 | 7.28k | (JDIMENSION)compptr->v_samp_factor); |
381 | 7.28k | } |
382 | | |
383 | 2.20k | if (need_full_buffer) { |
384 | 1.45k | #ifdef D_MULTISCAN_FILES_SUPPORTED |
385 | | /* Allocate a full-image virtual array for each component. */ |
386 | 1.45k | int access_rows; |
387 | | |
388 | 5.83k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
389 | 4.37k | ci++, compptr++) { |
390 | 4.37k | access_rows = compptr->v_samp_factor; |
391 | 4.37k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) |
392 | 4.37k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, |
393 | 4.37k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
394 | 4.37k | (long)compptr->h_samp_factor), |
395 | 4.37k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, |
396 | 4.37k | (long)compptr->v_samp_factor), |
397 | 4.37k | (JDIMENSION)access_rows); |
398 | 4.37k | } |
399 | 1.45k | diff->pub.consume_data = consume_data; |
400 | 1.45k | diff->pub._decompress_data = output_data; |
401 | | #else |
402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); |
403 | | #endif |
404 | 1.45k | } else { |
405 | 750 | diff->pub.consume_data = dummy_consume_data; |
406 | 750 | diff->pub._decompress_data = decompress_data; |
407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ |
408 | 750 | } |
409 | 2.20k | } Line | Count | Source | 348 | 854 | { | 349 | 854 | my_diff_ptr diff; | 350 | 854 | int ci; | 351 | 854 | jpeg_component_info *compptr; | 352 | | | 353 | 854 | #if BITS_IN_JSAMPLE == 8 | 354 | 854 | 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 | 854 | diff = (my_diff_ptr) | 362 | 854 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 854 | sizeof(my_diff_controller)); | 364 | 854 | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 854 | diff->pub.start_input_pass = start_input_pass; | 366 | 854 | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 3.99k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 3.14k | ci++, compptr++) { | 371 | 3.14k | diff->diff_buf[ci] = | 372 | 3.14k | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 3.14k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 3.14k | (long)compptr->h_samp_factor), | 375 | 3.14k | (JDIMENSION)compptr->v_samp_factor); | 376 | 3.14k | diff->undiff_buf[ci] = | 377 | 3.14k | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 3.14k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 3.14k | (long)compptr->h_samp_factor), | 380 | 3.14k | (JDIMENSION)compptr->v_samp_factor); | 381 | 3.14k | } | 382 | | | 383 | 854 | if (need_full_buffer) { | 384 | 244 | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 244 | int access_rows; | 387 | | | 388 | 977 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 733 | ci++, compptr++) { | 390 | 733 | access_rows = compptr->v_samp_factor; | 391 | 733 | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 733 | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 733 | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 733 | (long)compptr->h_samp_factor), | 395 | 733 | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 733 | (long)compptr->v_samp_factor), | 397 | 733 | (JDIMENSION)access_rows); | 398 | 733 | } | 399 | 244 | diff->pub.consume_data = consume_data; | 400 | 244 | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 610 | } else { | 405 | 610 | diff->pub.consume_data = dummy_consume_data; | 406 | 610 | diff->pub._decompress_data = decompress_data; | 407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 610 | } | 409 | 854 | } |
j12init_d_diff_controller Line | Count | Source | 348 | 695 | { | 349 | 695 | my_diff_ptr diff; | 350 | 695 | int ci; | 351 | 695 | 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 | 695 | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 357 | 695 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 358 | 0 | #endif | 359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 360 | | | 361 | 695 | diff = (my_diff_ptr) | 362 | 695 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 695 | sizeof(my_diff_controller)); | 364 | 695 | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 695 | diff->pub.start_input_pass = start_input_pass; | 366 | 695 | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 2.82k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 2.12k | ci++, compptr++) { | 371 | 2.12k | diff->diff_buf[ci] = | 372 | 2.12k | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 2.12k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 2.12k | (long)compptr->h_samp_factor), | 375 | 2.12k | (JDIMENSION)compptr->v_samp_factor); | 376 | 2.12k | diff->undiff_buf[ci] = | 377 | 2.12k | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 2.12k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 2.12k | (long)compptr->h_samp_factor), | 380 | 2.12k | (JDIMENSION)compptr->v_samp_factor); | 381 | 2.12k | } | 382 | | | 383 | 695 | if (need_full_buffer) { | 384 | 615 | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 615 | int access_rows; | 387 | | | 388 | 2.46k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 1.84k | ci++, compptr++) { | 390 | 1.84k | access_rows = compptr->v_samp_factor; | 391 | 1.84k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 1.84k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 1.84k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 1.84k | (long)compptr->h_samp_factor), | 395 | 1.84k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 1.84k | (long)compptr->v_samp_factor), | 397 | 1.84k | (JDIMENSION)access_rows); | 398 | 1.84k | } | 399 | 615 | diff->pub.consume_data = consume_data; | 400 | 615 | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 615 | } else { | 405 | 80 | diff->pub.consume_data = dummy_consume_data; | 406 | 80 | diff->pub._decompress_data = decompress_data; | 407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 80 | } | 409 | 695 | } |
j16init_d_diff_controller Line | Count | Source | 348 | 659 | { | 349 | 659 | my_diff_ptr diff; | 350 | 659 | int ci; | 351 | 659 | 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 | 659 | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 357 | 659 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 358 | 0 | #endif | 359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 360 | | | 361 | 659 | diff = (my_diff_ptr) | 362 | 659 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 659 | sizeof(my_diff_controller)); | 364 | 659 | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 659 | diff->pub.start_input_pass = start_input_pass; | 366 | 659 | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 2.67k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 2.01k | ci++, compptr++) { | 371 | 2.01k | diff->diff_buf[ci] = | 372 | 2.01k | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 2.01k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 2.01k | (long)compptr->h_samp_factor), | 375 | 2.01k | (JDIMENSION)compptr->v_samp_factor); | 376 | 2.01k | diff->undiff_buf[ci] = | 377 | 2.01k | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 2.01k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 2.01k | (long)compptr->h_samp_factor), | 380 | 2.01k | (JDIMENSION)compptr->v_samp_factor); | 381 | 2.01k | } | 382 | | | 383 | 659 | if (need_full_buffer) { | 384 | 599 | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 599 | int access_rows; | 387 | | | 388 | 2.39k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 1.79k | ci++, compptr++) { | 390 | 1.79k | access_rows = compptr->v_samp_factor; | 391 | 1.79k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 1.79k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 1.79k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 1.79k | (long)compptr->h_samp_factor), | 395 | 1.79k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 1.79k | (long)compptr->v_samp_factor), | 397 | 1.79k | (JDIMENSION)access_rows); | 398 | 1.79k | } | 399 | 599 | diff->pub.consume_data = consume_data; | 400 | 599 | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 599 | } else { | 405 | 60 | diff->pub.consume_data = dummy_consume_data; | 406 | 60 | diff->pub._decompress_data = decompress_data; | 407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 60 | } | 409 | 659 | } |
|
410 | | |
411 | | #endif /* D_LOSSLESS_SUPPORTED */ |