/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 | 119k | { |
68 | 119k | 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 | 119k | if (cinfo->comps_in_scan > 1) { |
75 | 4.67k | diff->MCU_rows_per_iMCU_row = 1; |
76 | 114k | } else { |
77 | 114k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) |
78 | 113k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; |
79 | 1.37k | else |
80 | 1.37k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; |
81 | 114k | } |
82 | | |
83 | 119k | diff->MCU_ctr = 0; |
84 | 119k | diff->MCU_vert_offset = 0; |
85 | 119k | } jddiffct-8.c:start_iMCU_row Line | Count | Source | 67 | 66.5k | { | 68 | 66.5k | 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 | 66.5k | if (cinfo->comps_in_scan > 1) { | 75 | 3.10k | diff->MCU_rows_per_iMCU_row = 1; | 76 | 63.4k | } else { | 77 | 63.4k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 62.9k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 423 | else | 80 | 423 | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 63.4k | } | 82 | | | 83 | 66.5k | diff->MCU_ctr = 0; | 84 | 66.5k | diff->MCU_vert_offset = 0; | 85 | 66.5k | } |
jddiffct-12.c:start_iMCU_row Line | Count | Source | 67 | 27.2k | { | 68 | 27.2k | 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 | 27.2k | if (cinfo->comps_in_scan > 1) { | 75 | 678 | diff->MCU_rows_per_iMCU_row = 1; | 76 | 26.5k | } else { | 77 | 26.5k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 26.0k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 545 | else | 80 | 545 | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 26.5k | } | 82 | | | 83 | 27.2k | diff->MCU_ctr = 0; | 84 | 27.2k | diff->MCU_vert_offset = 0; | 85 | 27.2k | } |
jddiffct-16.c:start_iMCU_row Line | Count | Source | 67 | 25.5k | { | 68 | 25.5k | 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 | 25.5k | if (cinfo->comps_in_scan > 1) { | 75 | 896 | diff->MCU_rows_per_iMCU_row = 1; | 76 | 24.6k | } else { | 77 | 24.6k | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 24.1k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 411 | else | 80 | 411 | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 24.6k | } | 82 | | | 83 | 25.5k | diff->MCU_ctr = 0; | 84 | 25.5k | diff->MCU_vert_offset = 0; | 85 | 25.5k | } |
|
86 | | |
87 | | |
88 | | /* |
89 | | * Initialize for an input processing pass. |
90 | | */ |
91 | | |
92 | | METHODDEF(void) |
93 | | start_input_pass(j_decompress_ptr cinfo) |
94 | 5.03k | { |
95 | 5.03k | 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 | 5.03k | (*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 | 5.03k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) |
108 | 23 | ERREXIT2(cinfo, JERR_BAD_RESTART, |
109 | 5.03k | cinfo->restart_interval, cinfo->MCUs_per_row); |
110 | | |
111 | | /* Initialize restart counter */ |
112 | 5.03k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; |
113 | | |
114 | 5.03k | cinfo->input_iMCU_row = 0; |
115 | 5.03k | start_iMCU_row(cinfo); |
116 | 5.03k | } jddiffct-8.c:start_input_pass Line | Count | Source | 94 | 1.84k | { | 95 | 1.84k | 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.84k | (*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.84k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 8 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 1.84k | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 1.84k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 1.84k | cinfo->input_iMCU_row = 0; | 115 | 1.84k | start_iMCU_row(cinfo); | 116 | 1.84k | } |
jddiffct-12.c:start_input_pass Line | Count | Source | 94 | 1.56k | { | 95 | 1.56k | 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.56k | (*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.56k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 6 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 1.56k | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 1.56k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 1.56k | cinfo->input_iMCU_row = 0; | 115 | 1.56k | start_iMCU_row(cinfo); | 116 | 1.56k | } |
jddiffct-16.c:start_input_pass Line | Count | Source | 94 | 1.61k | { | 95 | 1.61k | 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.61k | (*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.61k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 9 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 1.61k | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 1.61k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 1.61k | cinfo->input_iMCU_row = 0; | 115 | 1.61k | start_iMCU_row(cinfo); | 116 | 1.61k | } |
|
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 | 66 | { |
127 | 66 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
128 | | |
129 | 66 | if (!(*cinfo->entropy->process_restart) (cinfo)) |
130 | 0 | return FALSE; |
131 | | |
132 | 66 | (*cinfo->idct->start_pass) (cinfo); |
133 | | |
134 | | /* Reset restart counter */ |
135 | 66 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; |
136 | | |
137 | 66 | return TRUE; |
138 | 66 | } jddiffct-8.c:process_restart Line | Count | Source | 126 | 20 | { | 127 | 20 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 128 | | | 129 | 20 | if (!(*cinfo->entropy->process_restart) (cinfo)) | 130 | 0 | return FALSE; | 131 | | | 132 | 20 | (*cinfo->idct->start_pass) (cinfo); | 133 | | | 134 | | /* Reset restart counter */ | 135 | 20 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 136 | | | 137 | 20 | return TRUE; | 138 | 20 | } |
jddiffct-12.c:process_restart Line | Count | Source | 126 | 24 | { | 127 | 24 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 128 | | | 129 | 24 | if (!(*cinfo->entropy->process_restart) (cinfo)) | 130 | 0 | return FALSE; | 131 | | | 132 | 24 | (*cinfo->idct->start_pass) (cinfo); | 133 | | | 134 | | /* Reset restart counter */ | 135 | 24 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 136 | | | 137 | 24 | return TRUE; | 138 | 24 | } |
jddiffct-16.c:process_restart Line | Count | Source | 126 | 22 | { | 127 | 22 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 128 | | | 129 | 22 | if (!(*cinfo->entropy->process_restart) (cinfo)) | 130 | 0 | return FALSE; | 131 | | | 132 | 22 | (*cinfo->idct->start_pass) (cinfo); | 133 | | | 134 | | /* Reset restart counter */ | 135 | 22 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 136 | | | 137 | 22 | return TRUE; | 138 | 22 | } |
|
139 | | |
140 | | |
141 | | /* |
142 | | * Initialize for an output processing pass. |
143 | | */ |
144 | | |
145 | | METHODDEF(void) |
146 | | start_output_pass(j_decompress_ptr cinfo) |
147 | 868 | { |
148 | 868 | cinfo->output_iMCU_row = 0; |
149 | 868 | } jddiffct-8.c:start_output_pass Line | Count | Source | 147 | 823 | { | 148 | 823 | cinfo->output_iMCU_row = 0; | 149 | 823 | } |
jddiffct-12.c:start_output_pass Line | Count | Source | 147 | 29 | { | 148 | 29 | cinfo->output_iMCU_row = 0; | 149 | 29 | } |
jddiffct-16.c:start_output_pass Line | Count | Source | 147 | 16 | { | 148 | 16 | cinfo->output_iMCU_row = 0; | 149 | 16 | } |
|
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 | 119k | { |
165 | 119k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
166 | 119k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; |
167 | 119k | JDIMENSION MCU_col_num; /* index of current MCU within row */ |
168 | 119k | JDIMENSION MCU_count; /* number of MCUs decoded */ |
169 | 119k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
170 | 119k | int ci, compi, row, prev_row; |
171 | 119k | unsigned int yoffset; |
172 | 119k | jpeg_component_info *compptr; |
173 | | |
174 | | /* Loop to process as much as one whole iMCU row */ |
175 | 352k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; |
176 | 233k | yoffset++) { |
177 | | |
178 | | /* Process restart marker if needed; may have to suspend */ |
179 | 233k | if (cinfo->restart_interval) { |
180 | 1.08k | if (diff->restart_rows_to_go == 0) |
181 | 66 | if (!process_restart(cinfo)) |
182 | 0 | return JPEG_SUSPENDED; |
183 | 1.08k | } |
184 | | |
185 | 233k | MCU_col_num = diff->MCU_ctr; |
186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ |
187 | 233k | MCU_count = |
188 | 233k | (*cinfo->entropy->decode_mcus) (cinfo, |
189 | 233k | diff->diff_buf, yoffset, MCU_col_num, |
190 | 233k | cinfo->MCUs_per_row - MCU_col_num); |
191 | 233k | 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 | 233k | if (cinfo->restart_interval) |
200 | 984 | diff->restart_rows_to_go--; |
201 | | |
202 | | /* Completed an MCU row, but perhaps not an iMCU row */ |
203 | 233k | diff->MCU_ctr = 0; |
204 | 233k | } |
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 | 242k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
212 | 123k | compptr = cinfo->cur_comp_info[ci]; |
213 | 123k | compi = compptr->component_index; |
214 | 123k | for (row = 0, prev_row = compptr->v_samp_factor - 1; |
215 | 366k | row < (cinfo->input_iMCU_row == last_iMCU_row ? |
216 | 353k | compptr->last_row_height : compptr->v_samp_factor); |
217 | 243k | prev_row = row, row++) { |
218 | 243k | (*losslessd->predict_undifference[compi]) |
219 | 243k | (cinfo, compi, diff->diff_buf[compi][row], |
220 | 243k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], |
221 | 243k | compptr->width_in_blocks); |
222 | 243k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], |
223 | 243k | output_buf[compi][row], |
224 | 243k | compptr->width_in_blocks); |
225 | 243k | } |
226 | 123k | } |
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 | 119k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { |
235 | 114k | start_iMCU_row(cinfo); |
236 | 114k | return JPEG_ROW_COMPLETED; |
237 | 114k | } |
238 | | /* Completed the scan */ |
239 | 4.85k | (*cinfo->inputctl->finish_input_pass) (cinfo); |
240 | 4.85k | return JPEG_SCAN_COMPLETED; |
241 | 119k | } jddiffct-8.c:decompress_data Line | Count | Source | 164 | 66.5k | { | 165 | 66.5k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 66.5k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 66.5k | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 66.5k | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 66.5k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 66.5k | int ci, compi, row, prev_row; | 171 | 66.5k | unsigned int yoffset; | 172 | 66.5k | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 239k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 172k | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 172k | if (cinfo->restart_interval) { | 180 | 395 | if (diff->restart_rows_to_go == 0) | 181 | 20 | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 395 | } | 184 | | | 185 | 172k | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 172k | MCU_count = | 188 | 172k | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 172k | diff->diff_buf, yoffset, MCU_col_num, | 190 | 172k | cinfo->MCUs_per_row - MCU_col_num); | 191 | 172k | 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 | 172k | if (cinfo->restart_interval) | 200 | 358 | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 172k | diff->MCU_ctr = 0; | 204 | 172k | } | 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 | 136k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 69.8k | compptr = cinfo->cur_comp_info[ci]; | 213 | 69.8k | compi = compptr->component_index; | 214 | 69.8k | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 250k | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 246k | compptr->last_row_height : compptr->v_samp_factor); | 217 | 180k | prev_row = row, row++) { | 218 | 180k | (*losslessd->predict_undifference[compi]) | 219 | 180k | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 180k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 180k | compptr->width_in_blocks); | 222 | 180k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 180k | output_buf[compi][row], | 224 | 180k | compptr->width_in_blocks); | 225 | 180k | } | 226 | 69.8k | } | 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 | 66.5k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 64.7k | start_iMCU_row(cinfo); | 236 | 64.7k | return JPEG_ROW_COMPLETED; | 237 | 64.7k | } | 238 | | /* Completed the scan */ | 239 | 1.76k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 1.76k | return JPEG_SCAN_COMPLETED; | 241 | 66.5k | } |
jddiffct-12.c:decompress_data Line | Count | Source | 164 | 27.2k | { | 165 | 27.2k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 27.2k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 27.2k | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 27.2k | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 27.2k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 27.2k | int ci, compi, row, prev_row; | 171 | 27.2k | unsigned int yoffset; | 172 | 27.2k | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 57.4k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 30.1k | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 30.1k | if (cinfo->restart_interval) { | 180 | 297 | if (diff->restart_rows_to_go == 0) | 181 | 24 | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 297 | } | 184 | | | 185 | 30.1k | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 30.1k | MCU_count = | 188 | 30.1k | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 30.1k | diff->diff_buf, yoffset, MCU_col_num, | 190 | 30.1k | cinfo->MCUs_per_row - MCU_col_num); | 191 | 30.1k | 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 | 30.1k | if (cinfo->restart_interval) | 200 | 267 | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 30.1k | diff->MCU_ctr = 0; | 204 | 30.1k | } | 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 | 54.8k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 27.5k | compptr = cinfo->cur_comp_info[ci]; | 213 | 27.5k | compi = compptr->component_index; | 214 | 27.5k | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 58.7k | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 54.3k | compptr->last_row_height : compptr->v_samp_factor); | 217 | 31.1k | prev_row = row, row++) { | 218 | 31.1k | (*losslessd->predict_undifference[compi]) | 219 | 31.1k | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 31.1k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 31.1k | compptr->width_in_blocks); | 222 | 31.1k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 31.1k | output_buf[compi][row], | 224 | 31.1k | compptr->width_in_blocks); | 225 | 31.1k | } | 226 | 27.5k | } | 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 | 27.2k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 25.7k | start_iMCU_row(cinfo); | 236 | 25.7k | return JPEG_ROW_COMPLETED; | 237 | 25.7k | } | 238 | | /* Completed the scan */ | 239 | 1.51k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 1.51k | return JPEG_SCAN_COMPLETED; | 241 | 27.2k | } |
jddiffct-16.c:decompress_data Line | Count | Source | 164 | 25.4k | { | 165 | 25.4k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 25.4k | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 25.4k | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 25.4k | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 25.4k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 25.4k | int ci, compi, row, prev_row; | 171 | 25.4k | unsigned int yoffset; | 172 | 25.4k | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 55.8k | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 30.3k | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 30.3k | if (cinfo->restart_interval) { | 180 | 394 | if (diff->restart_rows_to_go == 0) | 181 | 22 | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 394 | } | 184 | | | 185 | 30.3k | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 30.3k | MCU_count = | 188 | 30.3k | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 30.3k | diff->diff_buf, yoffset, MCU_col_num, | 190 | 30.3k | cinfo->MCUs_per_row - MCU_col_num); | 191 | 30.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 | 30.3k | if (cinfo->restart_interval) | 200 | 359 | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 30.3k | diff->MCU_ctr = 0; | 204 | 30.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 | 51.5k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 26.0k | compptr = cinfo->cur_comp_info[ci]; | 213 | 26.0k | compi = compptr->component_index; | 214 | 26.0k | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 57.7k | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 53.1k | compptr->last_row_height : compptr->v_samp_factor); | 217 | 31.6k | prev_row = row, row++) { | 218 | 31.6k | (*losslessd->predict_undifference[compi]) | 219 | 31.6k | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 31.6k | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 31.6k | compptr->width_in_blocks); | 222 | 31.6k | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 31.6k | output_buf[compi][row], | 224 | 31.6k | compptr->width_in_blocks); | 225 | 31.6k | } | 226 | 26.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 | 25.4k | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 23.9k | start_iMCU_row(cinfo); | 236 | 23.9k | return JPEG_ROW_COMPLETED; | 237 | 23.9k | } | 238 | | /* Completed the scan */ | 239 | 1.57k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 1.57k | return JPEG_SCAN_COMPLETED; | 241 | 25.4k | } |
|
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 | 109k | { |
267 | 109k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
268 | 109k | int ci, compi; |
269 | 109k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; |
270 | 109k | jpeg_component_info *compptr; |
271 | | |
272 | | /* Align the virtual buffers for the components used in this scan. */ |
273 | 221k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
274 | 112k | compptr = cinfo->cur_comp_info[ci]; |
275 | 112k | compi = compptr->component_index; |
276 | 112k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) |
277 | 112k | ((j_common_ptr)cinfo, diff->whole_image[compi], |
278 | 112k | cinfo->input_iMCU_row * compptr->v_samp_factor, |
279 | 112k | (JDIMENSION)compptr->v_samp_factor, TRUE); |
280 | 112k | } |
281 | | |
282 | 109k | return decompress_data(cinfo, buffer); |
283 | 109k | } jddiffct-8.c:consume_data Line | Count | Source | 266 | 56.5k | { | 267 | 56.5k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 56.5k | int ci, compi; | 269 | 56.5k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 56.5k | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 114k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 57.7k | compptr = cinfo->cur_comp_info[ci]; | 275 | 57.7k | compi = compptr->component_index; | 276 | 57.7k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 57.7k | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 57.7k | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 57.7k | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 57.7k | } | 281 | | | 282 | 56.5k | return decompress_data(cinfo, buffer); | 283 | 56.5k | } |
jddiffct-12.c:consume_data Line | Count | Source | 266 | 27.2k | { | 267 | 27.2k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 27.2k | int ci, compi; | 269 | 27.2k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 27.2k | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 55.3k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 28.1k | compptr = cinfo->cur_comp_info[ci]; | 275 | 28.1k | compi = compptr->component_index; | 276 | 28.1k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 28.1k | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 28.1k | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 28.1k | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 28.1k | } | 281 | | | 282 | 27.2k | return decompress_data(cinfo, buffer); | 283 | 27.2k | } |
jddiffct-16.c:consume_data Line | Count | Source | 266 | 25.4k | { | 267 | 25.4k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 25.4k | int ci, compi; | 269 | 25.4k | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 25.4k | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 52.2k | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 26.7k | compptr = cinfo->cur_comp_info[ci]; | 275 | 26.7k | compi = compptr->component_index; | 276 | 26.7k | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 26.7k | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 26.7k | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 26.7k | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 26.7k | } | 281 | | | 282 | 25.4k | return decompress_data(cinfo, buffer); | 283 | 25.4k | } |
|
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 | 228 | { |
297 | 228 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
298 | 228 | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
299 | 228 | int ci, samp_rows, row; |
300 | 228 | _JSAMPARRAY buffer; |
301 | 228 | jpeg_component_info *compptr; |
302 | | |
303 | | /* Force some input to be done if we are getting ahead of the input. */ |
304 | 228 | while (cinfo->input_scan_number < cinfo->output_scan_number || |
305 | 228 | (cinfo->input_scan_number == cinfo->output_scan_number && |
306 | 228 | 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 | 816 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
313 | 588 | ci++, compptr++) { |
314 | | /* Align the virtual buffer for this component. */ |
315 | 588 | buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) |
316 | 588 | ((j_common_ptr)cinfo, diff->whole_image[ci], |
317 | 588 | cinfo->output_iMCU_row * compptr->v_samp_factor, |
318 | 588 | (JDIMENSION)compptr->v_samp_factor, FALSE); |
319 | | |
320 | 588 | if (cinfo->output_iMCU_row < last_iMCU_row) |
321 | 517 | samp_rows = compptr->v_samp_factor; |
322 | 71 | else { |
323 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ |
324 | 71 | samp_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); |
325 | 71 | if (samp_rows == 0) samp_rows = compptr->v_samp_factor; |
326 | 71 | } |
327 | | |
328 | 1.45k | for (row = 0; row < samp_rows; row++) { |
329 | 869 | memcpy(output_buf[ci][row], buffer[row], |
330 | 869 | compptr->width_in_blocks * sizeof(_JSAMPLE)); |
331 | 869 | } |
332 | 588 | } |
333 | | |
334 | 228 | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) |
335 | 193 | return JPEG_ROW_COMPLETED; |
336 | 35 | return JPEG_SCAN_COMPLETED; |
337 | 228 | } Line | Count | Source | 296 | 228 | { | 297 | 228 | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 298 | 228 | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 299 | 228 | int ci, samp_rows, row; | 300 | 228 | _JSAMPARRAY buffer; | 301 | 228 | jpeg_component_info *compptr; | 302 | | | 303 | | /* Force some input to be done if we are getting ahead of the input. */ | 304 | 228 | while (cinfo->input_scan_number < cinfo->output_scan_number || | 305 | 228 | (cinfo->input_scan_number == cinfo->output_scan_number && | 306 | 228 | 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 | 816 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 313 | 588 | ci++, compptr++) { | 314 | | /* Align the virtual buffer for this component. */ | 315 | 588 | buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 316 | 588 | ((j_common_ptr)cinfo, diff->whole_image[ci], | 317 | 588 | cinfo->output_iMCU_row * compptr->v_samp_factor, | 318 | 588 | (JDIMENSION)compptr->v_samp_factor, FALSE); | 319 | | | 320 | 588 | if (cinfo->output_iMCU_row < last_iMCU_row) | 321 | 517 | samp_rows = compptr->v_samp_factor; | 322 | 71 | else { | 323 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ | 324 | 71 | samp_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); | 325 | 71 | if (samp_rows == 0) samp_rows = compptr->v_samp_factor; | 326 | 71 | } | 327 | | | 328 | 1.45k | for (row = 0; row < samp_rows; row++) { | 329 | 869 | memcpy(output_buf[ci][row], buffer[row], | 330 | 869 | compptr->width_in_blocks * sizeof(_JSAMPLE)); | 331 | 869 | } | 332 | 588 | } | 333 | | | 334 | 228 | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) | 335 | 193 | return JPEG_ROW_COMPLETED; | 336 | 35 | return JPEG_SCAN_COMPLETED; | 337 | 228 | } |
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.62k | { |
349 | 2.62k | my_diff_ptr diff; |
350 | 2.62k | int ci; |
351 | 2.62k | jpeg_component_info *compptr; |
352 | | |
353 | | #if BITS_IN_JSAMPLE == 8 |
354 | 1.13k | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) |
355 | | #else |
356 | 1.48k | if (cinfo->data_precision > BITS_IN_JSAMPLE || |
357 | 1.48k | cinfo->data_precision < BITS_IN_JSAMPLE - 3) |
358 | 0 | #endif |
359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
360 | | |
361 | 2.62k | diff = (my_diff_ptr) |
362 | 2.62k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
363 | 2.62k | sizeof(my_diff_controller)); |
364 | 2.62k | cinfo->coef = (struct jpeg_d_coef_controller *)diff; |
365 | 2.62k | diff->pub.start_input_pass = start_input_pass; |
366 | 2.62k | diff->pub.start_output_pass = start_output_pass; |
367 | | |
368 | | /* Create the [un]difference buffers. */ |
369 | 8.52k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
370 | 5.90k | ci++, compptr++) { |
371 | 5.90k | diff->diff_buf[ci] = |
372 | 5.90k | ALLOC_DARRAY(JPOOL_IMAGE, |
373 | 5.90k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
374 | 5.90k | (long)compptr->h_samp_factor), |
375 | 5.90k | (JDIMENSION)compptr->v_samp_factor); |
376 | 5.90k | diff->undiff_buf[ci] = |
377 | 5.90k | ALLOC_DARRAY(JPOOL_IMAGE, |
378 | 5.90k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
379 | 5.90k | (long)compptr->h_samp_factor), |
380 | 5.90k | (JDIMENSION)compptr->v_samp_factor); |
381 | 5.90k | } |
382 | | |
383 | 2.62k | if (need_full_buffer) { |
384 | 1.67k | #ifdef D_MULTISCAN_FILES_SUPPORTED |
385 | | /* Allocate a full-image virtual array for each component. */ |
386 | 1.67k | int access_rows; |
387 | | |
388 | 6.16k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
389 | 4.48k | ci++, compptr++) { |
390 | 4.48k | access_rows = compptr->v_samp_factor; |
391 | 4.48k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) |
392 | 4.48k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, |
393 | 4.48k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
394 | 4.48k | (long)compptr->h_samp_factor), |
395 | 4.48k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, |
396 | 4.48k | (long)compptr->v_samp_factor), |
397 | 4.48k | (JDIMENSION)access_rows); |
398 | 4.48k | } |
399 | 1.67k | diff->pub.consume_data = consume_data; |
400 | 1.67k | diff->pub._decompress_data = output_data; |
401 | | #else |
402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); |
403 | | #endif |
404 | 1.67k | } else { |
405 | 950 | diff->pub.consume_data = dummy_consume_data; |
406 | 950 | diff->pub._decompress_data = decompress_data; |
407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ |
408 | 950 | } |
409 | 2.62k | } Line | Count | Source | 348 | 1.13k | { | 349 | 1.13k | my_diff_ptr diff; | 350 | 1.13k | int ci; | 351 | 1.13k | jpeg_component_info *compptr; | 352 | | | 353 | 1.13k | #if BITS_IN_JSAMPLE == 8 | 354 | 1.13k | 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 | 1.13k | diff = (my_diff_ptr) | 362 | 1.13k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 1.13k | sizeof(my_diff_controller)); | 364 | 1.13k | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 1.13k | diff->pub.start_input_pass = start_input_pass; | 366 | 1.13k | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 3.25k | 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 | 1.13k | if (need_full_buffer) { | 384 | 258 | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 258 | int access_rows; | 387 | | | 388 | 1.05k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 800 | ci++, compptr++) { | 390 | 800 | access_rows = compptr->v_samp_factor; | 391 | 800 | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 800 | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 800 | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 800 | (long)compptr->h_samp_factor), | 395 | 800 | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 800 | (long)compptr->v_samp_factor), | 397 | 800 | (JDIMENSION)access_rows); | 398 | 800 | } | 399 | 258 | diff->pub.consume_data = consume_data; | 400 | 258 | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 880 | } else { | 405 | 880 | diff->pub.consume_data = dummy_consume_data; | 406 | 880 | diff->pub._decompress_data = decompress_data; | 407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 880 | } | 409 | 1.13k | } |
j12init_d_diff_controller Line | Count | Source | 348 | 733 | { | 349 | 733 | my_diff_ptr diff; | 350 | 733 | int ci; | 351 | 733 | 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 | 733 | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 357 | 733 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 358 | 0 | #endif | 359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 360 | | | 361 | 733 | diff = (my_diff_ptr) | 362 | 733 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 733 | sizeof(my_diff_controller)); | 364 | 733 | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 733 | diff->pub.start_input_pass = start_input_pass; | 366 | 733 | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 2.60k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 1.87k | ci++, compptr++) { | 371 | 1.87k | diff->diff_buf[ci] = | 372 | 1.87k | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 1.87k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 1.87k | (long)compptr->h_samp_factor), | 375 | 1.87k | (JDIMENSION)compptr->v_samp_factor); | 376 | 1.87k | diff->undiff_buf[ci] = | 377 | 1.87k | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 1.87k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 1.87k | (long)compptr->h_samp_factor), | 380 | 1.87k | (JDIMENSION)compptr->v_samp_factor); | 381 | 1.87k | } | 382 | | | 383 | 733 | if (need_full_buffer) { | 384 | 700 | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 700 | int access_rows; | 387 | | | 388 | 2.52k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 1.82k | ci++, compptr++) { | 390 | 1.82k | access_rows = compptr->v_samp_factor; | 391 | 1.82k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 1.82k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 1.82k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 1.82k | (long)compptr->h_samp_factor), | 395 | 1.82k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 1.82k | (long)compptr->v_samp_factor), | 397 | 1.82k | (JDIMENSION)access_rows); | 398 | 1.82k | } | 399 | 700 | diff->pub.consume_data = consume_data; | 400 | 700 | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 700 | } else { | 405 | 33 | diff->pub.consume_data = dummy_consume_data; | 406 | 33 | diff->pub._decompress_data = decompress_data; | 407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 33 | } | 409 | 733 | } |
j16init_d_diff_controller Line | Count | Source | 348 | 753 | { | 349 | 753 | my_diff_ptr diff; | 350 | 753 | int ci; | 351 | 753 | 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 | 753 | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 357 | 753 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 358 | 0 | #endif | 359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 360 | | | 361 | 753 | diff = (my_diff_ptr) | 362 | 753 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 753 | sizeof(my_diff_controller)); | 364 | 753 | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 753 | diff->pub.start_input_pass = start_input_pass; | 366 | 753 | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 2.66k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 1.90k | ci++, compptr++) { | 371 | 1.90k | diff->diff_buf[ci] = | 372 | 1.90k | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 1.90k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 1.90k | (long)compptr->h_samp_factor), | 375 | 1.90k | (JDIMENSION)compptr->v_samp_factor); | 376 | 1.90k | diff->undiff_buf[ci] = | 377 | 1.90k | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 1.90k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 1.90k | (long)compptr->h_samp_factor), | 380 | 1.90k | (JDIMENSION)compptr->v_samp_factor); | 381 | 1.90k | } | 382 | | | 383 | 753 | if (need_full_buffer) { | 384 | 716 | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 716 | int access_rows; | 387 | | | 388 | 2.57k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 1.86k | ci++, compptr++) { | 390 | 1.86k | access_rows = compptr->v_samp_factor; | 391 | 1.86k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 1.86k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 1.86k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 1.86k | (long)compptr->h_samp_factor), | 395 | 1.86k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 1.86k | (long)compptr->v_samp_factor), | 397 | 1.86k | (JDIMENSION)access_rows); | 398 | 1.86k | } | 399 | 716 | diff->pub.consume_data = consume_data; | 400 | 716 | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 716 | } else { | 405 | 37 | diff->pub.consume_data = dummy_consume_data; | 406 | 37 | diff->pub._decompress_data = decompress_data; | 407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 37 | } | 409 | 753 | } |
|
410 | | |
411 | | #endif /* D_LOSSLESS_SUPPORTED */ |