/src/libjpeg-turbo.main/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 | 5.32M | { |
68 | 5.32M | 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 | 5.32M | if (cinfo->comps_in_scan > 1) { |
75 | 884k | diff->MCU_rows_per_iMCU_row = 1; |
76 | 4.43M | } else { |
77 | 4.43M | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) |
78 | 4.43M | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; |
79 | 1.68k | else |
80 | 1.68k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; |
81 | 4.43M | } |
82 | | |
83 | 5.32M | diff->MCU_ctr = 0; |
84 | 5.32M | diff->MCU_vert_offset = 0; |
85 | 5.32M | } jddiffct-8.c:start_iMCU_row Line | Count | Source | 67 | 2.95M | { | 68 | 2.95M | 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 | 2.95M | if (cinfo->comps_in_scan > 1) { | 75 | 881k | diff->MCU_rows_per_iMCU_row = 1; | 76 | 2.07M | } else { | 77 | 2.07M | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 2.07M | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 1.12k | else | 80 | 1.12k | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 2.07M | } | 82 | | | 83 | 2.95M | diff->MCU_ctr = 0; | 84 | 2.95M | diff->MCU_vert_offset = 0; | 85 | 2.95M | } |
jddiffct-12.c:start_iMCU_row Line | Count | Source | 67 | 1.06M | { | 68 | 1.06M | 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 | 1.06M | if (cinfo->comps_in_scan > 1) { | 75 | 1.24k | diff->MCU_rows_per_iMCU_row = 1; | 76 | 1.06M | } else { | 77 | 1.06M | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 1.06M | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 282 | else | 80 | 282 | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 1.06M | } | 82 | | | 83 | 1.06M | diff->MCU_ctr = 0; | 84 | 1.06M | diff->MCU_vert_offset = 0; | 85 | 1.06M | } |
jddiffct-16.c:start_iMCU_row Line | Count | Source | 67 | 1.30M | { | 68 | 1.30M | 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 | 1.30M | if (cinfo->comps_in_scan > 1) { | 75 | 1.09k | diff->MCU_rows_per_iMCU_row = 1; | 76 | 1.29M | } else { | 77 | 1.29M | if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) | 78 | 1.29M | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; | 79 | 279 | else | 80 | 279 | diff->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; | 81 | 1.29M | } | 82 | | | 83 | 1.30M | diff->MCU_ctr = 0; | 84 | 1.30M | diff->MCU_vert_offset = 0; | 85 | 1.30M | } |
|
86 | | |
87 | | |
88 | | /* |
89 | | * Initialize for an input processing pass. |
90 | | */ |
91 | | |
92 | | METHODDEF(void) |
93 | | start_input_pass(j_decompress_ptr cinfo) |
94 | 2.78k | { |
95 | 2.78k | 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 | 2.78k | (*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 | 2.78k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) |
108 | 23 | ERREXIT2(cinfo, JERR_BAD_RESTART, |
109 | 2.78k | cinfo->restart_interval, cinfo->MCUs_per_row); |
110 | | |
111 | | /* Initialize restart counter */ |
112 | 2.78k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; |
113 | | |
114 | 2.78k | cinfo->input_iMCU_row = 0; |
115 | 2.78k | start_iMCU_row(cinfo); |
116 | 2.78k | } jddiffct-8.c:start_input_pass Line | Count | Source | 94 | 2.13k | { | 95 | 2.13k | 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 | 2.13k | (*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 | 2.13k | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 13 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 2.13k | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 2.13k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 2.13k | cinfo->input_iMCU_row = 0; | 115 | 2.13k | start_iMCU_row(cinfo); | 116 | 2.13k | } |
jddiffct-12.c:start_input_pass Line | Count | Source | 94 | 318 | { | 95 | 318 | 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 | 318 | (*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 | 318 | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 1 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 318 | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 318 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 318 | cinfo->input_iMCU_row = 0; | 115 | 318 | start_iMCU_row(cinfo); | 116 | 318 | } |
jddiffct-16.c:start_input_pass Line | Count | Source | 94 | 336 | { | 95 | 336 | 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 | 336 | (*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 | 336 | if (cinfo->restart_interval % cinfo->MCUs_per_row != 0) | 108 | 9 | ERREXIT2(cinfo, JERR_BAD_RESTART, | 109 | 336 | cinfo->restart_interval, cinfo->MCUs_per_row); | 110 | | | 111 | | /* Initialize restart counter */ | 112 | 336 | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 113 | | | 114 | 336 | cinfo->input_iMCU_row = 0; | 115 | 336 | start_iMCU_row(cinfo); | 116 | 336 | } |
|
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 | 63.8k | { |
127 | 63.8k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
128 | | |
129 | 63.8k | if (!(*cinfo->entropy->process_restart) (cinfo)) |
130 | 0 | return FALSE; |
131 | | |
132 | 63.8k | (*cinfo->idct->start_pass) (cinfo); |
133 | | |
134 | | /* Reset restart counter */ |
135 | 63.8k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; |
136 | | |
137 | 63.8k | return TRUE; |
138 | 63.8k | } jddiffct-8.c:process_restart Line | Count | Source | 126 | 39.6k | { | 127 | 39.6k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 128 | | | 129 | 39.6k | if (!(*cinfo->entropy->process_restart) (cinfo)) | 130 | 0 | return FALSE; | 131 | | | 132 | 39.6k | (*cinfo->idct->start_pass) (cinfo); | 133 | | | 134 | | /* Reset restart counter */ | 135 | 39.6k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 136 | | | 137 | 39.6k | return TRUE; | 138 | 39.6k | } |
jddiffct-12.c:process_restart Line | Count | Source | 126 | 3.65k | { | 127 | 3.65k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 128 | | | 129 | 3.65k | if (!(*cinfo->entropy->process_restart) (cinfo)) | 130 | 0 | return FALSE; | 131 | | | 132 | 3.65k | (*cinfo->idct->start_pass) (cinfo); | 133 | | | 134 | | /* Reset restart counter */ | 135 | 3.65k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 136 | | | 137 | 3.65k | return TRUE; | 138 | 3.65k | } |
jddiffct-16.c:process_restart Line | Count | Source | 126 | 20.5k | { | 127 | 20.5k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 128 | | | 129 | 20.5k | if (!(*cinfo->entropy->process_restart) (cinfo)) | 130 | 0 | return FALSE; | 131 | | | 132 | 20.5k | (*cinfo->idct->start_pass) (cinfo); | 133 | | | 134 | | /* Reset restart counter */ | 135 | 20.5k | diff->restart_rows_to_go = cinfo->restart_interval / cinfo->MCUs_per_row; | 136 | | | 137 | 20.5k | return TRUE; | 138 | 20.5k | } |
|
139 | | |
140 | | |
141 | | /* |
142 | | * Initialize for an output processing pass. |
143 | | */ |
144 | | |
145 | | METHODDEF(void) |
146 | | start_output_pass(j_decompress_ptr cinfo) |
147 | 933 | { |
148 | 933 | cinfo->output_iMCU_row = 0; |
149 | 933 | } jddiffct-8.c:start_output_pass Line | Count | Source | 147 | 918 | { | 148 | 918 | cinfo->output_iMCU_row = 0; | 149 | 918 | } |
jddiffct-12.c:start_output_pass Line | Count | Source | 147 | 5 | { | 148 | 5 | cinfo->output_iMCU_row = 0; | 149 | 5 | } |
jddiffct-16.c:start_output_pass Line | Count | Source | 147 | 10 | { | 148 | 10 | cinfo->output_iMCU_row = 0; | 149 | 10 | } |
|
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 | 5.32M | { |
165 | 5.32M | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
166 | 5.32M | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; |
167 | 5.32M | JDIMENSION MCU_col_num; /* index of current MCU within row */ |
168 | 5.32M | JDIMENSION MCU_count; /* number of MCUs decoded */ |
169 | 5.32M | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
170 | 5.32M | int ci, compi, row, prev_row; |
171 | 5.32M | unsigned int yoffset; |
172 | 5.32M | jpeg_component_info *compptr; |
173 | | |
174 | | /* Loop to process as much as one whole iMCU row */ |
175 | 16.3M | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; |
176 | 10.9M | yoffset++) { |
177 | | |
178 | | /* Process restart marker if needed; may have to suspend */ |
179 | 10.9M | if (cinfo->restart_interval) { |
180 | 2.29M | if (diff->restart_rows_to_go == 0) |
181 | 63.8k | if (!process_restart(cinfo)) |
182 | 0 | return JPEG_SUSPENDED; |
183 | 2.29M | } |
184 | | |
185 | 10.9M | MCU_col_num = diff->MCU_ctr; |
186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ |
187 | 10.9M | MCU_count = |
188 | 10.9M | (*cinfo->entropy->decode_mcus) (cinfo, |
189 | 10.9M | diff->diff_buf, yoffset, MCU_col_num, |
190 | 10.9M | cinfo->MCUs_per_row - MCU_col_num); |
191 | 10.9M | 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 | 10.9M | if (cinfo->restart_interval) |
200 | 2.29M | diff->restart_rows_to_go--; |
201 | | |
202 | | /* Completed an MCU row, but perhaps not an iMCU row */ |
203 | 10.9M | diff->MCU_ctr = 0; |
204 | 10.9M | } |
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 | 11.5M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
212 | 6.27M | compptr = cinfo->cur_comp_info[ci]; |
213 | 6.27M | compi = compptr->component_index; |
214 | 6.27M | for (row = 0, prev_row = compptr->v_samp_factor - 1; |
215 | 20.2M | row < (cinfo->input_iMCU_row == last_iMCU_row ? |
216 | 20.2M | compptr->last_row_height : compptr->v_samp_factor); |
217 | 13.9M | prev_row = row, row++) { |
218 | 13.9M | (*losslessd->predict_undifference[compi]) |
219 | 13.9M | (cinfo, compi, diff->diff_buf[compi][row], |
220 | 13.9M | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], |
221 | 13.9M | compptr->width_in_blocks); |
222 | 13.9M | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], |
223 | 13.9M | output_buf[compi][row], |
224 | 13.9M | compptr->width_in_blocks); |
225 | 13.9M | } |
226 | 6.27M | } |
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 | 5.32M | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { |
235 | 5.31M | start_iMCU_row(cinfo); |
236 | 5.31M | return JPEG_ROW_COMPLETED; |
237 | 5.31M | } |
238 | | /* Completed the scan */ |
239 | 2.65k | (*cinfo->inputctl->finish_input_pass) (cinfo); |
240 | 2.65k | return JPEG_SCAN_COMPLETED; |
241 | 5.32M | } jddiffct-8.c:decompress_data Line | Count | Source | 164 | 2.95M | { | 165 | 2.95M | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 2.95M | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 2.95M | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 2.95M | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 2.95M | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 2.95M | int ci, compi, row, prev_row; | 171 | 2.95M | unsigned int yoffset; | 172 | 2.95M | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 8.80M | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 5.84M | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 5.84M | if (cinfo->restart_interval) { | 180 | 800k | if (diff->restart_rows_to_go == 0) | 181 | 39.6k | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 800k | } | 184 | | | 185 | 5.84M | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 5.84M | MCU_count = | 188 | 5.84M | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 5.84M | diff->diff_buf, yoffset, MCU_col_num, | 190 | 5.84M | cinfo->MCUs_per_row - MCU_col_num); | 191 | 5.84M | 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 | 5.84M | if (cinfo->restart_interval) | 200 | 800k | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 5.84M | diff->MCU_ctr = 0; | 204 | 5.84M | } | 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 | 6.86M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 3.90M | compptr = cinfo->cur_comp_info[ci]; | 213 | 3.90M | compi = compptr->component_index; | 214 | 3.90M | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 12.7M | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 12.7M | compptr->last_row_height : compptr->v_samp_factor); | 217 | 8.82M | prev_row = row, row++) { | 218 | 8.82M | (*losslessd->predict_undifference[compi]) | 219 | 8.82M | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 8.82M | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 8.82M | compptr->width_in_blocks); | 222 | 8.82M | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 8.82M | output_buf[compi][row], | 224 | 8.82M | compptr->width_in_blocks); | 225 | 8.82M | } | 226 | 3.90M | } | 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 | 2.95M | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 2.95M | start_iMCU_row(cinfo); | 236 | 2.95M | return JPEG_ROW_COMPLETED; | 237 | 2.95M | } | 238 | | /* Completed the scan */ | 239 | 2.06k | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 2.06k | return JPEG_SCAN_COMPLETED; | 241 | 2.95M | } |
jddiffct-12.c:decompress_data Line | Count | Source | 164 | 1.06M | { | 165 | 1.06M | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 1.06M | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 1.06M | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 1.06M | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 1.06M | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 1.06M | int ci, compi, row, prev_row; | 171 | 1.06M | unsigned int yoffset; | 172 | 1.06M | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 3.53M | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 2.47M | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 2.47M | if (cinfo->restart_interval) { | 180 | 712k | if (diff->restart_rows_to_go == 0) | 181 | 3.65k | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 712k | } | 184 | | | 185 | 2.47M | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 2.47M | MCU_count = | 188 | 2.47M | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 2.47M | diff->diff_buf, yoffset, MCU_col_num, | 190 | 2.47M | cinfo->MCUs_per_row - MCU_col_num); | 191 | 2.47M | 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 | 2.47M | if (cinfo->restart_interval) | 200 | 712k | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 2.47M | diff->MCU_ctr = 0; | 204 | 2.47M | } | 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 | 2.13M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 1.06M | compptr = cinfo->cur_comp_info[ci]; | 213 | 1.06M | compi = compptr->component_index; | 214 | 1.06M | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 3.54M | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 3.54M | compptr->last_row_height : compptr->v_samp_factor); | 217 | 2.48M | prev_row = row, row++) { | 218 | 2.48M | (*losslessd->predict_undifference[compi]) | 219 | 2.48M | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 2.48M | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 2.48M | compptr->width_in_blocks); | 222 | 2.48M | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 2.48M | output_buf[compi][row], | 224 | 2.48M | compptr->width_in_blocks); | 225 | 2.48M | } | 226 | 1.06M | } | 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 | 1.06M | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 1.06M | start_iMCU_row(cinfo); | 236 | 1.06M | return JPEG_ROW_COMPLETED; | 237 | 1.06M | } | 238 | | /* Completed the scan */ | 239 | 293 | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 293 | return JPEG_SCAN_COMPLETED; | 241 | 1.06M | } |
jddiffct-16.c:decompress_data Line | Count | Source | 164 | 1.30M | { | 165 | 1.30M | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 166 | 1.30M | lossless_decomp_ptr losslessd = (lossless_decomp_ptr)cinfo->idct; | 167 | 1.30M | JDIMENSION MCU_col_num; /* index of current MCU within row */ | 168 | 1.30M | JDIMENSION MCU_count; /* number of MCUs decoded */ | 169 | 1.30M | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 170 | 1.30M | int ci, compi, row, prev_row; | 171 | 1.30M | unsigned int yoffset; | 172 | 1.30M | jpeg_component_info *compptr; | 173 | | | 174 | | /* Loop to process as much as one whole iMCU row */ | 175 | 3.96M | for (yoffset = diff->MCU_vert_offset; yoffset < diff->MCU_rows_per_iMCU_row; | 176 | 2.66M | yoffset++) { | 177 | | | 178 | | /* Process restart marker if needed; may have to suspend */ | 179 | 2.66M | if (cinfo->restart_interval) { | 180 | 785k | if (diff->restart_rows_to_go == 0) | 181 | 20.5k | if (!process_restart(cinfo)) | 182 | 0 | return JPEG_SUSPENDED; | 183 | 785k | } | 184 | | | 185 | 2.66M | MCU_col_num = diff->MCU_ctr; | 186 | | /* Try to fetch an MCU row (or remaining portion of suspended MCU row). */ | 187 | 2.66M | MCU_count = | 188 | 2.66M | (*cinfo->entropy->decode_mcus) (cinfo, | 189 | 2.66M | diff->diff_buf, yoffset, MCU_col_num, | 190 | 2.66M | cinfo->MCUs_per_row - MCU_col_num); | 191 | 2.66M | 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 | 2.66M | if (cinfo->restart_interval) | 200 | 785k | diff->restart_rows_to_go--; | 201 | | | 202 | | /* Completed an MCU row, but perhaps not an iMCU row */ | 203 | 2.66M | diff->MCU_ctr = 0; | 204 | 2.66M | } | 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 | 2.60M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 212 | 1.30M | compptr = cinfo->cur_comp_info[ci]; | 213 | 1.30M | compi = compptr->component_index; | 214 | 1.30M | for (row = 0, prev_row = compptr->v_samp_factor - 1; | 215 | 3.97M | row < (cinfo->input_iMCU_row == last_iMCU_row ? | 216 | 3.97M | compptr->last_row_height : compptr->v_samp_factor); | 217 | 2.67M | prev_row = row, row++) { | 218 | 2.67M | (*losslessd->predict_undifference[compi]) | 219 | 2.67M | (cinfo, compi, diff->diff_buf[compi][row], | 220 | 2.67M | diff->undiff_buf[compi][prev_row], diff->undiff_buf[compi][row], | 221 | 2.67M | compptr->width_in_blocks); | 222 | 2.67M | (*losslessd->scaler_scale) (cinfo, diff->undiff_buf[compi][row], | 223 | 2.67M | output_buf[compi][row], | 224 | 2.67M | compptr->width_in_blocks); | 225 | 2.67M | } | 226 | 1.30M | } | 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 | 1.30M | if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { | 235 | 1.30M | start_iMCU_row(cinfo); | 236 | 1.30M | return JPEG_ROW_COMPLETED; | 237 | 1.30M | } | 238 | | /* Completed the scan */ | 239 | 293 | (*cinfo->inputctl->finish_input_pass) (cinfo); | 240 | 293 | return JPEG_SCAN_COMPLETED; | 241 | 1.30M | } |
|
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 | 5.08M | { |
267 | 5.08M | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
268 | 5.08M | int ci, compi; |
269 | 5.08M | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; |
270 | 5.08M | jpeg_component_info *compptr; |
271 | | |
272 | | /* Align the virtual buffers for the components used in this scan. */ |
273 | 10.8M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { |
274 | 5.80M | compptr = cinfo->cur_comp_info[ci]; |
275 | 5.80M | compi = compptr->component_index; |
276 | 5.80M | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) |
277 | 5.80M | ((j_common_ptr)cinfo, diff->whole_image[compi], |
278 | 5.80M | cinfo->input_iMCU_row * compptr->v_samp_factor, |
279 | 5.80M | (JDIMENSION)compptr->v_samp_factor, TRUE); |
280 | 5.80M | } |
281 | | |
282 | 5.08M | return decompress_data(cinfo, buffer); |
283 | 5.08M | } jddiffct-8.c:consume_data Line | Count | Source | 266 | 2.72M | { | 267 | 2.72M | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 2.72M | int ci, compi; | 269 | 2.72M | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 2.72M | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 6.16M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 3.43M | compptr = cinfo->cur_comp_info[ci]; | 275 | 3.43M | compi = compptr->component_index; | 276 | 3.43M | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 3.43M | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 3.43M | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 3.43M | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 3.43M | } | 281 | | | 282 | 2.72M | return decompress_data(cinfo, buffer); | 283 | 2.72M | } |
jddiffct-12.c:consume_data Line | Count | Source | 266 | 1.06M | { | 267 | 1.06M | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 1.06M | int ci, compi; | 269 | 1.06M | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 1.06M | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 2.13M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 1.06M | compptr = cinfo->cur_comp_info[ci]; | 275 | 1.06M | compi = compptr->component_index; | 276 | 1.06M | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 1.06M | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 1.06M | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 1.06M | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 1.06M | } | 281 | | | 282 | 1.06M | return decompress_data(cinfo, buffer); | 283 | 1.06M | } |
jddiffct-16.c:consume_data Line | Count | Source | 266 | 1.30M | { | 267 | 1.30M | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 268 | 1.30M | int ci, compi; | 269 | 1.30M | _JSAMPARRAY buffer[MAX_COMPS_IN_SCAN]; | 270 | 1.30M | jpeg_component_info *compptr; | 271 | | | 272 | | /* Align the virtual buffers for the components used in this scan. */ | 273 | 2.60M | for (ci = 0; ci < cinfo->comps_in_scan; ci++) { | 274 | 1.30M | compptr = cinfo->cur_comp_info[ci]; | 275 | 1.30M | compi = compptr->component_index; | 276 | 1.30M | buffer[compi] = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 277 | 1.30M | ((j_common_ptr)cinfo, diff->whole_image[compi], | 278 | 1.30M | cinfo->input_iMCU_row * compptr->v_samp_factor, | 279 | 1.30M | (JDIMENSION)compptr->v_samp_factor, TRUE); | 280 | 1.30M | } | 281 | | | 282 | 1.30M | return decompress_data(cinfo, buffer); | 283 | 1.30M | } |
|
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 | 656k | { |
297 | 656k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; |
298 | 656k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; |
299 | 656k | int ci, samp_rows, row; |
300 | 656k | _JSAMPARRAY buffer; |
301 | 656k | jpeg_component_info *compptr; |
302 | | |
303 | | /* Force some input to be done if we are getting ahead of the input. */ |
304 | 1.31M | while (cinfo->input_scan_number < cinfo->output_scan_number || |
305 | 1.31M | (cinfo->input_scan_number == cinfo->output_scan_number && |
306 | 1.31M | cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { |
307 | 656k | if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) |
308 | 0 | return JPEG_SUSPENDED; |
309 | 656k | } |
310 | | |
311 | | /* OK, output from the virtual arrays. */ |
312 | 2.01M | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
313 | 1.35M | ci++, compptr++) { |
314 | | /* Align the virtual buffer for this component. */ |
315 | 1.35M | buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) |
316 | 1.35M | ((j_common_ptr)cinfo, diff->whole_image[ci], |
317 | 1.35M | cinfo->output_iMCU_row * compptr->v_samp_factor, |
318 | 1.35M | (JDIMENSION)compptr->v_samp_factor, FALSE); |
319 | | |
320 | 1.35M | if (cinfo->output_iMCU_row < last_iMCU_row) |
321 | 1.35M | samp_rows = compptr->v_samp_factor; |
322 | 1.74k | else { |
323 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ |
324 | 1.74k | samp_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); |
325 | 1.74k | if (samp_rows == 0) samp_rows = compptr->v_samp_factor; |
326 | 1.74k | } |
327 | | |
328 | 4.53M | for (row = 0; row < samp_rows; row++) { |
329 | 3.17M | memcpy(output_buf[ci][row], buffer[row], |
330 | 3.17M | compptr->width_in_blocks * sizeof(_JSAMPLE)); |
331 | 3.17M | } |
332 | 1.35M | } |
333 | | |
334 | 656k | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) |
335 | 655k | return JPEG_ROW_COMPLETED; |
336 | 846 | return JPEG_SCAN_COMPLETED; |
337 | 656k | } Line | Count | Source | 296 | 656k | { | 297 | 656k | my_diff_ptr diff = (my_diff_ptr)cinfo->coef; | 298 | 656k | JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; | 299 | 656k | int ci, samp_rows, row; | 300 | 656k | _JSAMPARRAY buffer; | 301 | 656k | jpeg_component_info *compptr; | 302 | | | 303 | | /* Force some input to be done if we are getting ahead of the input. */ | 304 | 1.31M | while (cinfo->input_scan_number < cinfo->output_scan_number || | 305 | 1.31M | (cinfo->input_scan_number == cinfo->output_scan_number && | 306 | 1.31M | cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { | 307 | 656k | if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) | 308 | 0 | return JPEG_SUSPENDED; | 309 | 656k | } | 310 | | | 311 | | /* OK, output from the virtual arrays. */ | 312 | 2.01M | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 313 | 1.35M | ci++, compptr++) { | 314 | | /* Align the virtual buffer for this component. */ | 315 | 1.35M | buffer = (_JSAMPARRAY)(*cinfo->mem->access_virt_sarray) | 316 | 1.35M | ((j_common_ptr)cinfo, diff->whole_image[ci], | 317 | 1.35M | cinfo->output_iMCU_row * compptr->v_samp_factor, | 318 | 1.35M | (JDIMENSION)compptr->v_samp_factor, FALSE); | 319 | | | 320 | 1.35M | if (cinfo->output_iMCU_row < last_iMCU_row) | 321 | 1.35M | samp_rows = compptr->v_samp_factor; | 322 | 1.74k | else { | 323 | | /* NB: can't use last_row_height here; it is input-side-dependent! */ | 324 | 1.74k | samp_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor); | 325 | 1.74k | if (samp_rows == 0) samp_rows = compptr->v_samp_factor; | 326 | 1.74k | } | 327 | | | 328 | 4.53M | for (row = 0; row < samp_rows; row++) { | 329 | 3.17M | memcpy(output_buf[ci][row], buffer[row], | 330 | 3.17M | compptr->width_in_blocks * sizeof(_JSAMPLE)); | 331 | 3.17M | } | 332 | 1.35M | } | 333 | | | 334 | 656k | if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) | 335 | 655k | return JPEG_ROW_COMPLETED; | 336 | 846 | return JPEG_SCAN_COMPLETED; | 337 | 656k | } |
Unexecuted instantiation: jddiffct-12.c:output_data Unexecuted instantiation: jddiffct-16.c:output_data |
338 | | |
339 | | #endif /* D_MULTISCAN_FILES_SUPPORTED */ |
340 | | |
341 | | |
342 | | /* |
343 | | * Initialize difference buffer controller. |
344 | | */ |
345 | | |
346 | | GLOBAL(void) |
347 | | _jinit_d_diff_controller(j_decompress_ptr cinfo, boolean need_full_buffer) |
348 | 1.32k | { |
349 | 1.32k | my_diff_ptr diff; |
350 | 1.32k | int ci; |
351 | 1.32k | jpeg_component_info *compptr; |
352 | | |
353 | | #if BITS_IN_JSAMPLE == 8 |
354 | 602 | if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2) |
355 | | #else |
356 | 724 | if (cinfo->data_precision > BITS_IN_JSAMPLE || |
357 | 724 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) |
358 | 0 | #endif |
359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
360 | | |
361 | 1.32k | diff = (my_diff_ptr) |
362 | 1.32k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
363 | 1.32k | sizeof(my_diff_controller)); |
364 | 1.32k | cinfo->coef = (struct jpeg_d_coef_controller *)diff; |
365 | 1.32k | diff->pub.start_input_pass = start_input_pass; |
366 | 1.32k | diff->pub.start_output_pass = start_output_pass; |
367 | | |
368 | | /* Create the [un]difference buffers. */ |
369 | 4.36k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
370 | 3.03k | ci++, compptr++) { |
371 | 3.03k | diff->diff_buf[ci] = |
372 | 3.03k | ALLOC_DARRAY(JPOOL_IMAGE, |
373 | 3.03k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
374 | 3.03k | (long)compptr->h_samp_factor), |
375 | 3.03k | (JDIMENSION)compptr->v_samp_factor); |
376 | 3.03k | diff->undiff_buf[ci] = |
377 | 3.03k | ALLOC_DARRAY(JPOOL_IMAGE, |
378 | 3.03k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
379 | 3.03k | (long)compptr->h_samp_factor), |
380 | 3.03k | (JDIMENSION)compptr->v_samp_factor); |
381 | 3.03k | } |
382 | | |
383 | 1.32k | if (need_full_buffer) { |
384 | 1.23k | #ifdef D_MULTISCAN_FILES_SUPPORTED |
385 | | /* Allocate a full-image virtual array for each component. */ |
386 | 1.23k | int access_rows; |
387 | | |
388 | 4.09k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
389 | 2.85k | ci++, compptr++) { |
390 | 2.85k | access_rows = compptr->v_samp_factor; |
391 | 2.85k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) |
392 | 2.85k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, |
393 | 2.85k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, |
394 | 2.85k | (long)compptr->h_samp_factor), |
395 | 2.85k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, |
396 | 2.85k | (long)compptr->v_samp_factor), |
397 | 2.85k | (JDIMENSION)access_rows); |
398 | 2.85k | } |
399 | 1.23k | diff->pub.consume_data = consume_data; |
400 | 1.23k | diff->pub._decompress_data = output_data; |
401 | | #else |
402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); |
403 | | #endif |
404 | 1.23k | } else { |
405 | 89 | diff->pub.consume_data = dummy_consume_data; |
406 | 89 | diff->pub._decompress_data = decompress_data; |
407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ |
408 | 89 | } |
409 | 1.32k | } Line | Count | Source | 348 | 602 | { | 349 | 602 | my_diff_ptr diff; | 350 | 602 | int ci; | 351 | 602 | jpeg_component_info *compptr; | 352 | | | 353 | 602 | #if BITS_IN_JSAMPLE == 8 | 354 | 602 | 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 | 602 | diff = (my_diff_ptr) | 362 | 602 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 602 | sizeof(my_diff_controller)); | 364 | 602 | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 602 | diff->pub.start_input_pass = start_input_pass; | 366 | 602 | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 1.94k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 1.34k | ci++, compptr++) { | 371 | 1.34k | diff->diff_buf[ci] = | 372 | 1.34k | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 1.34k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 1.34k | (long)compptr->h_samp_factor), | 375 | 1.34k | (JDIMENSION)compptr->v_samp_factor); | 376 | 1.34k | diff->undiff_buf[ci] = | 377 | 1.34k | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 1.34k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 1.34k | (long)compptr->h_samp_factor), | 380 | 1.34k | (JDIMENSION)compptr->v_samp_factor); | 381 | 1.34k | } | 382 | | | 383 | 602 | if (need_full_buffer) { | 384 | 520 | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 520 | int access_rows; | 387 | | | 388 | 1.70k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 1.18k | ci++, compptr++) { | 390 | 1.18k | access_rows = compptr->v_samp_factor; | 391 | 1.18k | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 1.18k | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 1.18k | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 1.18k | (long)compptr->h_samp_factor), | 395 | 1.18k | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 1.18k | (long)compptr->v_samp_factor), | 397 | 1.18k | (JDIMENSION)access_rows); | 398 | 1.18k | } | 399 | 520 | diff->pub.consume_data = consume_data; | 400 | 520 | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 520 | } else { | 405 | 82 | diff->pub.consume_data = dummy_consume_data; | 406 | 82 | diff->pub._decompress_data = decompress_data; | 407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 82 | } | 409 | 602 | } |
j12init_d_diff_controller Line | Count | Source | 348 | 353 | { | 349 | 353 | my_diff_ptr diff; | 350 | 353 | int ci; | 351 | 353 | 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 | 353 | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 357 | 353 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 358 | 0 | #endif | 359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 360 | | | 361 | 353 | diff = (my_diff_ptr) | 362 | 353 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 353 | sizeof(my_diff_controller)); | 364 | 353 | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 353 | diff->pub.start_input_pass = start_input_pass; | 366 | 353 | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 1.17k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 823 | ci++, compptr++) { | 371 | 823 | diff->diff_buf[ci] = | 372 | 823 | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 823 | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 823 | (long)compptr->h_samp_factor), | 375 | 823 | (JDIMENSION)compptr->v_samp_factor); | 376 | 823 | diff->undiff_buf[ci] = | 377 | 823 | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 823 | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 823 | (long)compptr->h_samp_factor), | 380 | 823 | (JDIMENSION)compptr->v_samp_factor); | 381 | 823 | } | 382 | | | 383 | 353 | if (need_full_buffer) { | 384 | 350 | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 350 | int access_rows; | 387 | | | 388 | 1.16k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 817 | ci++, compptr++) { | 390 | 817 | access_rows = compptr->v_samp_factor; | 391 | 817 | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 817 | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 817 | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 817 | (long)compptr->h_samp_factor), | 395 | 817 | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 817 | (long)compptr->v_samp_factor), | 397 | 817 | (JDIMENSION)access_rows); | 398 | 817 | } | 399 | 350 | diff->pub.consume_data = consume_data; | 400 | 350 | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 350 | } else { | 405 | 3 | diff->pub.consume_data = dummy_consume_data; | 406 | 3 | diff->pub._decompress_data = decompress_data; | 407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 3 | } | 409 | 353 | } |
j16init_d_diff_controller Line | Count | Source | 348 | 371 | { | 349 | 371 | my_diff_ptr diff; | 350 | 371 | int ci; | 351 | 371 | 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 | 371 | if (cinfo->data_precision > BITS_IN_JSAMPLE || | 357 | 371 | cinfo->data_precision < BITS_IN_JSAMPLE - 3) | 358 | 0 | #endif | 359 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 360 | | | 361 | 371 | diff = (my_diff_ptr) | 362 | 371 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 363 | 371 | sizeof(my_diff_controller)); | 364 | 371 | cinfo->coef = (struct jpeg_d_coef_controller *)diff; | 365 | 371 | diff->pub.start_input_pass = start_input_pass; | 366 | 371 | diff->pub.start_output_pass = start_output_pass; | 367 | | | 368 | | /* Create the [un]difference buffers. */ | 369 | 1.23k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 370 | 865 | ci++, compptr++) { | 371 | 865 | diff->diff_buf[ci] = | 372 | 865 | ALLOC_DARRAY(JPOOL_IMAGE, | 373 | 865 | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 374 | 865 | (long)compptr->h_samp_factor), | 375 | 865 | (JDIMENSION)compptr->v_samp_factor); | 376 | 865 | diff->undiff_buf[ci] = | 377 | 865 | ALLOC_DARRAY(JPOOL_IMAGE, | 378 | 865 | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 379 | 865 | (long)compptr->h_samp_factor), | 380 | 865 | (JDIMENSION)compptr->v_samp_factor); | 381 | 865 | } | 382 | | | 383 | 371 | if (need_full_buffer) { | 384 | 367 | #ifdef D_MULTISCAN_FILES_SUPPORTED | 385 | | /* Allocate a full-image virtual array for each component. */ | 386 | 367 | int access_rows; | 387 | | | 388 | 1.22k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 389 | 857 | ci++, compptr++) { | 390 | 857 | access_rows = compptr->v_samp_factor; | 391 | 857 | diff->whole_image[ci] = (*cinfo->mem->request_virt_sarray) | 392 | 857 | ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE, | 393 | 857 | (JDIMENSION)jround_up((long)compptr->width_in_blocks, | 394 | 857 | (long)compptr->h_samp_factor), | 395 | 857 | (JDIMENSION)jround_up((long)compptr->height_in_blocks, | 396 | 857 | (long)compptr->v_samp_factor), | 397 | 857 | (JDIMENSION)access_rows); | 398 | 857 | } | 399 | 367 | diff->pub.consume_data = consume_data; | 400 | 367 | diff->pub._decompress_data = output_data; | 401 | | #else | 402 | | ERREXIT(cinfo, JERR_NOT_COMPILED); | 403 | | #endif | 404 | 367 | } else { | 405 | 4 | diff->pub.consume_data = dummy_consume_data; | 406 | 4 | diff->pub._decompress_data = decompress_data; | 407 | | diff->whole_image[0] = NULL; /* flag for no virtual arrays */ | 408 | 4 | } | 409 | 371 | } |
|
410 | | |
411 | | #endif /* D_LOSSLESS_SUPPORTED */ |