OLD | NEW |
1 /* | 1 /* |
2 * jdapistd.c | 2 * jdapistd.c |
3 * | 3 * |
4 * This file was part of the Independent JPEG Group's software: | 4 * This file was part of the Independent JPEG Group's software: |
5 * Copyright (C) 1994-1996, Thomas G. Lane. | 5 * Copyright (C) 1994-1996, Thomas G. Lane. |
6 * libjpeg-turbo Modifications: | 6 * libjpeg-turbo Modifications: |
7 * Copyright (C) 2010, 2015, D. R. Commander. | 7 * Copyright (C) 2010, 2015-2016, D. R. Commander. |
8 * Copyright (C) 2015, Google, Inc. | 8 * Copyright (C) 2015, Google, Inc. |
9 * For conditions of distribution and use, see the accompanying README file. | 9 * For conditions of distribution and use, see the accompanying README.ijg |
| 10 * file. |
10 * | 11 * |
11 * This file contains application interface code for the decompression half | 12 * This file contains application interface code for the decompression half |
12 * of the JPEG library. These are the "standard" API routines that are | 13 * of the JPEG library. These are the "standard" API routines that are |
13 * used in the normal full-decompression case. They are not used by a | 14 * used in the normal full-decompression case. They are not used by a |
14 * transcoding-only application. Note that if an application links in | 15 * transcoding-only application. Note that if an application links in |
15 * jpeg_start_decompress, it will end up linking in the entire decompressor. | 16 * jpeg_start_decompress, it will end up linking in the entire decompressor. |
16 * We thus must separate this file from jdapimin.c to avoid linking the | 17 * We thus must separate this file from jdapimin.c to avoid linking the |
17 * whole decompression library into a transcoder. | 18 * whole decompression library into a transcoder. |
18 */ | 19 */ |
19 | 20 |
| 21 #include "jinclude.h" |
20 #include "jdmainct.h" | 22 #include "jdmainct.h" |
21 #include "jdcoefct.h" | 23 #include "jdcoefct.h" |
22 #include "jdsample.h" | 24 #include "jdsample.h" |
23 #include "jmemsys.h" | 25 #include "jmemsys.h" |
24 | 26 |
25 | |
26 /* Forward declarations */ | 27 /* Forward declarations */ |
27 LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo)); | 28 LOCAL(boolean) output_pass_setup (j_decompress_ptr cinfo); |
28 | 29 |
29 | 30 |
30 /* | 31 /* |
31 * Decompression initialization. | 32 * Decompression initialization. |
32 * jpeg_read_header must be completed before calling this. | 33 * jpeg_read_header must be completed before calling this. |
33 * | 34 * |
34 * If a multipass operating mode was selected, this will do all but the | 35 * If a multipass operating mode was selected, this will do all but the |
35 * last pass, and thus may take a great deal of time. | 36 * last pass, and thus may take a great deal of time. |
36 * | 37 * |
37 * Returns FALSE if suspended. The return value need be inspected only if | 38 * Returns FALSE if suspended. The return value need be inspected only if |
(...skipping 11 matching lines...) Expand all Loading... |
49 cinfo->global_state = DSTATE_BUFIMAGE; | 50 cinfo->global_state = DSTATE_BUFIMAGE; |
50 return TRUE; | 51 return TRUE; |
51 } | 52 } |
52 cinfo->global_state = DSTATE_PRELOAD; | 53 cinfo->global_state = DSTATE_PRELOAD; |
53 } | 54 } |
54 if (cinfo->global_state == DSTATE_PRELOAD) { | 55 if (cinfo->global_state == DSTATE_PRELOAD) { |
55 /* If file has multiple scans, absorb them all into the coef buffer */ | 56 /* If file has multiple scans, absorb them all into the coef buffer */ |
56 if (cinfo->inputctl->has_multiple_scans) { | 57 if (cinfo->inputctl->has_multiple_scans) { |
57 #ifdef D_MULTISCAN_FILES_SUPPORTED | 58 #ifdef D_MULTISCAN_FILES_SUPPORTED |
58 for (;;) { | 59 for (;;) { |
59 » int retcode; | 60 int retcode; |
60 » /* Call progress monitor hook if present */ | 61 /* Call progress monitor hook if present */ |
61 » if (cinfo->progress != NULL) | 62 if (cinfo->progress != NULL) |
62 » (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); | 63 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); |
63 » /* Absorb some more input */ | 64 /* Absorb some more input */ |
64 » retcode = (*cinfo->inputctl->consume_input) (cinfo); | 65 retcode = (*cinfo->inputctl->consume_input) (cinfo); |
65 » if (retcode == JPEG_SUSPENDED) | 66 if (retcode == JPEG_SUSPENDED) |
66 » return FALSE; | 67 return FALSE; |
67 » if (retcode == JPEG_REACHED_EOI) | 68 if (retcode == JPEG_REACHED_EOI) |
68 » break; | 69 break; |
69 » /* Advance progress counter if appropriate */ | 70 /* Advance progress counter if appropriate */ |
70 » if (cinfo->progress != NULL && | 71 if (cinfo->progress != NULL && |
71 » (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { | 72 (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { |
72 » if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { | 73 if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { |
73 » /* jdmaster underestimated number of scans; ratchet up one scan */ | 74 /* jdmaster underestimated number of scans; ratchet up one scan */ |
74 » cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; | 75 cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; |
75 » } | 76 } |
76 » } | 77 } |
77 } | 78 } |
78 #else | 79 #else |
79 ERREXIT(cinfo, JERR_NOT_COMPILED); | 80 ERREXIT(cinfo, JERR_NOT_COMPILED); |
80 #endif /* D_MULTISCAN_FILES_SUPPORTED */ | 81 #endif /* D_MULTISCAN_FILES_SUPPORTED */ |
81 } | 82 } |
82 cinfo->output_scan_number = cinfo->input_scan_number; | 83 cinfo->output_scan_number = cinfo->input_scan_number; |
83 } else if (cinfo->global_state != DSTATE_PRESCAN) | 84 } else if (cinfo->global_state != DSTATE_PRESCAN) |
84 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); | 85 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
85 /* Perform any dummy output passes, and set up for the final pass */ | 86 /* Perform any dummy output passes, and set up for the final pass */ |
86 return output_pass_setup(cinfo); | 87 return output_pass_setup(cinfo); |
(...skipping 18 matching lines...) Expand all Loading... |
105 cinfo->global_state = DSTATE_PRESCAN; | 106 cinfo->global_state = DSTATE_PRESCAN; |
106 } | 107 } |
107 /* Loop over any required dummy passes */ | 108 /* Loop over any required dummy passes */ |
108 while (cinfo->master->is_dummy_pass) { | 109 while (cinfo->master->is_dummy_pass) { |
109 #ifdef QUANT_2PASS_SUPPORTED | 110 #ifdef QUANT_2PASS_SUPPORTED |
110 /* Crank through the dummy pass */ | 111 /* Crank through the dummy pass */ |
111 while (cinfo->output_scanline < cinfo->output_height) { | 112 while (cinfo->output_scanline < cinfo->output_height) { |
112 JDIMENSION last_scanline; | 113 JDIMENSION last_scanline; |
113 /* Call progress monitor hook if present */ | 114 /* Call progress monitor hook if present */ |
114 if (cinfo->progress != NULL) { | 115 if (cinfo->progress != NULL) { |
115 » cinfo->progress->pass_counter = (long) cinfo->output_scanline; | 116 cinfo->progress->pass_counter = (long) cinfo->output_scanline; |
116 » cinfo->progress->pass_limit = (long) cinfo->output_height; | 117 cinfo->progress->pass_limit = (long) cinfo->output_height; |
117 » (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); | 118 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); |
118 } | 119 } |
119 /* Process some data */ | 120 /* Process some data */ |
120 last_scanline = cinfo->output_scanline; | 121 last_scanline = cinfo->output_scanline; |
121 (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL, | 122 (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL, |
122 » » » » &cinfo->output_scanline, (JDIMENSION) 0); | 123 &cinfo->output_scanline, (JDIMENSION) 0); |
123 if (cinfo->output_scanline == last_scanline) | 124 if (cinfo->output_scanline == last_scanline) |
124 » return FALSE;» » /* No progress made, must suspend */ | 125 return FALSE; /* No progress made, must suspend */ |
125 } | 126 } |
126 /* Finish up dummy pass, and set up for another one */ | 127 /* Finish up dummy pass, and set up for another one */ |
127 (*cinfo->master->finish_output_pass) (cinfo); | 128 (*cinfo->master->finish_output_pass) (cinfo); |
128 (*cinfo->master->prepare_for_output_pass) (cinfo); | 129 (*cinfo->master->prepare_for_output_pass) (cinfo); |
129 cinfo->output_scanline = 0; | 130 cinfo->output_scanline = 0; |
130 #else | 131 #else |
131 ERREXIT(cinfo, JERR_NOT_COMPILED); | 132 ERREXIT(cinfo, JERR_NOT_COMPILED); |
132 #endif /* QUANT_2PASS_SUPPORTED */ | 133 #endif /* QUANT_2PASS_SUPPORTED */ |
133 } | 134 } |
134 /* Ready for application to drive output pass through | 135 /* Ready for application to drive output pass through |
135 * jpeg_read_scanlines or jpeg_read_raw_data. | 136 * jpeg_read_scanlines or jpeg_read_raw_data. |
136 */ | 137 */ |
137 cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING; | 138 cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING; |
138 return TRUE; | 139 return TRUE; |
139 } | 140 } |
140 | 141 |
141 | 142 |
142 /* | 143 /* |
| 144 * Enable partial scanline decompression |
| 145 * |
| 146 * Must be called after jpeg_start_decompress() and before any calls to |
| 147 * jpeg_read_scanlines() or jpeg_skip_scanlines(). |
| 148 * |
| 149 * Refer to libjpeg.txt for more information. |
| 150 */ |
| 151 |
| 152 GLOBAL(void) |
| 153 jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset, |
| 154 JDIMENSION *width) |
| 155 { |
| 156 int ci, align, orig_downsampled_width; |
| 157 JDIMENSION input_xoffset; |
| 158 boolean reinit_upsampler = FALSE; |
| 159 jpeg_component_info *compptr; |
| 160 |
| 161 if (cinfo->global_state != DSTATE_SCANNING || cinfo->output_scanline != 0) |
| 162 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
| 163 |
| 164 if (!xoffset || !width) |
| 165 ERREXIT(cinfo, JERR_BAD_CROP_SPEC); |
| 166 |
| 167 /* xoffset and width must fall within the output image dimensions. */ |
| 168 if (*width == 0 || *xoffset + *width > cinfo->output_width) |
| 169 ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); |
| 170 |
| 171 /* No need to do anything if the caller wants the entire width. */ |
| 172 if (*width == cinfo->output_width) |
| 173 return; |
| 174 |
| 175 /* Ensuring the proper alignment of xoffset is tricky. At minimum, it |
| 176 * must align with an MCU boundary, because: |
| 177 * |
| 178 * (1) The IDCT is performed in blocks, and it is not feasible to modify |
| 179 * the algorithm so that it can transform partial blocks. |
| 180 * (2) Because of the SIMD extensions, any input buffer passed to the |
| 181 * upsampling and color conversion routines must be aligned to the |
| 182 * SIMD word size (for instance, 128-bit in the case of SSE2.) The |
| 183 * easiest way to accomplish this without copying data is to ensure |
| 184 * that upsampling and color conversion begin at the start of the |
| 185 * first MCU column that will be inverse transformed. |
| 186 * |
| 187 * In practice, we actually impose a stricter alignment requirement. We |
| 188 * require that xoffset be a multiple of the maximum MCU column width of all |
| 189 * of the components (the "iMCU column width.") This is to simplify the |
| 190 * single-pass decompression case, allowing us to use the same MCU column |
| 191 * width for all of the components. |
| 192 */ |
| 193 align = cinfo->_min_DCT_scaled_size * cinfo->max_h_samp_factor; |
| 194 |
| 195 /* Adjust xoffset to the nearest iMCU boundary <= the requested value */ |
| 196 input_xoffset = *xoffset; |
| 197 *xoffset = (input_xoffset / align) * align; |
| 198 |
| 199 /* Adjust the width so that the right edge of the output image is as |
| 200 * requested (only the left edge is altered.) It is important that calling |
| 201 * programs check this value after this function returns, so that they can |
| 202 * allocate an output buffer with the appropriate size. |
| 203 */ |
| 204 *width = *width + input_xoffset - *xoffset; |
| 205 cinfo->output_width = *width; |
| 206 |
| 207 /* Set the first and last iMCU columns that we must decompress. These values |
| 208 * will be used in single-scan decompressions. |
| 209 */ |
| 210 cinfo->master->first_iMCU_col = |
| 211 (JDIMENSION) (long) (*xoffset) / (long) align; |
| 212 cinfo->master->last_iMCU_col = |
| 213 (JDIMENSION) jdiv_round_up((long) (*xoffset + cinfo->output_width), |
| 214 (long) align) - 1; |
| 215 |
| 216 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
| 217 ci++, compptr++) { |
| 218 /* Set downsampled_width to the new output width. */ |
| 219 orig_downsampled_width = compptr->downsampled_width; |
| 220 compptr->downsampled_width = |
| 221 (JDIMENSION) jdiv_round_up((long) (cinfo->output_width * |
| 222 compptr->h_samp_factor), |
| 223 (long) cinfo->max_h_samp_factor); |
| 224 if (compptr->downsampled_width < 2 && orig_downsampled_width >= 2) |
| 225 reinit_upsampler = TRUE; |
| 226 |
| 227 /* Set the first and last iMCU columns that we must decompress. These |
| 228 * values will be used in multi-scan decompressions. |
| 229 */ |
| 230 cinfo->master->first_MCU_col[ci] = |
| 231 (JDIMENSION) (long) (*xoffset * compptr->h_samp_factor) / |
| 232 (long) align; |
| 233 cinfo->master->last_MCU_col[ci] = |
| 234 (JDIMENSION) jdiv_round_up((long) ((*xoffset + cinfo->output_width) * |
| 235 compptr->h_samp_factor), |
| 236 (long) align) - 1; |
| 237 } |
| 238 |
| 239 if (reinit_upsampler) { |
| 240 cinfo->master->jinit_upsampler_no_alloc = TRUE; |
| 241 jinit_upsampler(cinfo); |
| 242 cinfo->master->jinit_upsampler_no_alloc = FALSE; |
| 243 } |
| 244 } |
| 245 |
| 246 |
| 247 /* |
143 * Read some scanlines of data from the JPEG decompressor. | 248 * Read some scanlines of data from the JPEG decompressor. |
144 * | 249 * |
145 * The return value will be the number of lines actually read. | 250 * The return value will be the number of lines actually read. |
146 * This may be less than the number requested in several cases, | 251 * This may be less than the number requested in several cases, |
147 * including bottom of image, data source suspension, and operating | 252 * including bottom of image, data source suspension, and operating |
148 * modes that emit multiple scanlines at a time. | 253 * modes that emit multiple scanlines at a time. |
149 * | 254 * |
150 * Note: we warn about excess calls to jpeg_read_scanlines() since | 255 * Note: we warn about excess calls to jpeg_read_scanlines() since |
151 * this likely signals an application programmer error. However, | 256 * this likely signals an application programmer error. However, |
152 * an oversize buffer (max_lines > scanlines remaining) is not an error. | 257 * an oversize buffer (max_lines > scanlines remaining) is not an error. |
153 */ | 258 */ |
154 | 259 |
155 GLOBAL(JDIMENSION) | 260 GLOBAL(JDIMENSION) |
156 jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, | 261 jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, |
157 » » JDIMENSION max_lines) | 262 JDIMENSION max_lines) |
158 { | 263 { |
159 JDIMENSION row_ctr; | 264 JDIMENSION row_ctr; |
160 | 265 |
161 if (cinfo->global_state != DSTATE_SCANNING) | 266 if (cinfo->global_state != DSTATE_SCANNING) |
162 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); | 267 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
163 if (cinfo->output_scanline >= cinfo->output_height) { | 268 if (cinfo->output_scanline >= cinfo->output_height) { |
164 WARNMS(cinfo, JWRN_TOO_MUCH_DATA); | 269 WARNMS(cinfo, JWRN_TOO_MUCH_DATA); |
165 return 0; | 270 return 0; |
166 } | 271 } |
167 | 272 |
168 /* Call progress monitor hook if present */ | 273 /* Call progress monitor hook if present */ |
169 if (cinfo->progress != NULL) { | 274 if (cinfo->progress != NULL) { |
170 cinfo->progress->pass_counter = (long) cinfo->output_scanline; | 275 cinfo->progress->pass_counter = (long) cinfo->output_scanline; |
171 cinfo->progress->pass_limit = (long) cinfo->output_height; | 276 cinfo->progress->pass_limit = (long) cinfo->output_height; |
172 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); | 277 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); |
173 } | 278 } |
174 | 279 |
175 /* Process some data */ | 280 /* Process some data */ |
176 row_ctr = 0; | 281 row_ctr = 0; |
177 (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines); | 282 (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines); |
178 cinfo->output_scanline += row_ctr; | 283 cinfo->output_scanline += row_ctr; |
179 return row_ctr; | 284 return row_ctr; |
180 } | 285 } |
181 | 286 |
182 | 287 |
183 | |
184 /* Dummy color convert function used by jpeg_skip_scanlines() */ | 288 /* Dummy color convert function used by jpeg_skip_scanlines() */ |
185 LOCAL(void) | 289 LOCAL(void) |
186 noop_convert (j_decompress_ptr cinfo, JSAMPIMAGE input_buf, | 290 noop_convert (j_decompress_ptr cinfo, JSAMPIMAGE input_buf, |
187 JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows) | 291 JDIMENSION input_row, JSAMPARRAY output_buf, int num_rows) |
188 { | 292 { |
189 } | 293 } |
190 | 294 |
191 | 295 |
192 /* | 296 /* |
193 * In some cases, it is best to call jpeg_read_scanlines() and discard the | 297 * In some cases, it is best to call jpeg_read_scanlines() and discard the |
194 * output, rather than skipping the scanlines, because this allows us to | 298 * output, rather than skipping the scanlines, because this allows us to |
195 * maintain the internal state of the context-based upsampler. In these cases, | 299 * maintain the internal state of the context-based upsampler. In these cases, |
196 * we set up and tear down a dummy color converter in order to avoid valgrind | 300 * we set up and tear down a dummy color converter in order to avoid valgrind |
197 * errors and to achieve the best possible performance. | 301 * errors and to achieve the best possible performance. |
198 */ | 302 */ |
| 303 |
199 LOCAL(void) | 304 LOCAL(void) |
200 read_and_discard_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines) | 305 read_and_discard_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines) |
201 { | 306 { |
202 JDIMENSION n; | 307 JDIMENSION n; |
203 void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf, | 308 void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf, |
204 JDIMENSION input_row, JSAMPARRAY output_buf, | 309 JDIMENSION input_row, JSAMPARRAY output_buf, |
205 int num_rows); | 310 int num_rows); |
206 | 311 |
207 color_convert = cinfo->cconvert->color_convert; | 312 color_convert = cinfo->cconvert->color_convert; |
208 cinfo->cconvert->color_convert = noop_convert; | 313 cinfo->cconvert->color_convert = noop_convert; |
209 | 314 |
210 for (n = 0; n < num_lines; n++) | 315 for (n = 0; n < num_lines; n++) |
211 jpeg_read_scanlines(cinfo, NULL, 1); | 316 jpeg_read_scanlines(cinfo, NULL, 1); |
212 | 317 |
213 cinfo->cconvert->color_convert = color_convert; | 318 cinfo->cconvert->color_convert = color_convert; |
214 } | 319 } |
215 | 320 |
| 321 |
216 /* | 322 /* |
217 * Called by jpeg_skip_scanlines(). This partially skips a decompress block by | 323 * Called by jpeg_skip_scanlines(). This partially skips a decompress block by |
218 * incrementing the rowgroup counter. | 324 * incrementing the rowgroup counter. |
219 */ | 325 */ |
220 | 326 |
221 LOCAL(void) | 327 LOCAL(void) |
222 increment_simple_rowgroup_ctr (j_decompress_ptr cinfo, JDIMENSION rows) | 328 increment_simple_rowgroup_ctr (j_decompress_ptr cinfo, JDIMENSION rows) |
223 { | 329 { |
224 JDIMENSION rows_left; | 330 JDIMENSION rows_left; |
225 my_main_ptr main_ptr = (my_main_ptr) cinfo->main; | 331 my_main_ptr main_ptr = (my_main_ptr) cinfo->main; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 return num_lines; | 515 return num_lines; |
410 } | 516 } |
411 | 517 |
412 /* | 518 /* |
413 * Alternate entry point to read raw data. | 519 * Alternate entry point to read raw data. |
414 * Processes exactly one iMCU row per call, unless suspended. | 520 * Processes exactly one iMCU row per call, unless suspended. |
415 */ | 521 */ |
416 | 522 |
417 GLOBAL(JDIMENSION) | 523 GLOBAL(JDIMENSION) |
418 jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, | 524 jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, |
419 » » JDIMENSION max_lines) | 525 JDIMENSION max_lines) |
420 { | 526 { |
421 JDIMENSION lines_per_iMCU_row; | 527 JDIMENSION lines_per_iMCU_row; |
422 | 528 |
423 if (cinfo->global_state != DSTATE_RAW_OK) | 529 if (cinfo->global_state != DSTATE_RAW_OK) |
424 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); | 530 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
425 if (cinfo->output_scanline >= cinfo->output_height) { | 531 if (cinfo->output_scanline >= cinfo->output_height) { |
426 WARNMS(cinfo, JWRN_TOO_MUCH_DATA); | 532 WARNMS(cinfo, JWRN_TOO_MUCH_DATA); |
427 return 0; | 533 return 0; |
428 } | 534 } |
429 | 535 |
430 /* Call progress monitor hook if present */ | 536 /* Call progress monitor hook if present */ |
431 if (cinfo->progress != NULL) { | 537 if (cinfo->progress != NULL) { |
432 cinfo->progress->pass_counter = (long) cinfo->output_scanline; | 538 cinfo->progress->pass_counter = (long) cinfo->output_scanline; |
433 cinfo->progress->pass_limit = (long) cinfo->output_height; | 539 cinfo->progress->pass_limit = (long) cinfo->output_height; |
434 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); | 540 (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); |
435 } | 541 } |
436 | 542 |
437 /* Verify that at least one iMCU row can be returned. */ | 543 /* Verify that at least one iMCU row can be returned. */ |
438 lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size; | 544 lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->_min_DCT_scaled_size; |
439 if (max_lines < lines_per_iMCU_row) | 545 if (max_lines < lines_per_iMCU_row) |
440 ERREXIT(cinfo, JERR_BUFFER_SIZE); | 546 ERREXIT(cinfo, JERR_BUFFER_SIZE); |
441 | 547 |
442 /* Decompress directly into user's buffer. */ | 548 /* Decompress directly into user's buffer. */ |
443 if (! (*cinfo->coef->decompress_data) (cinfo, data)) | 549 if (! (*cinfo->coef->decompress_data) (cinfo, data)) |
444 return 0;» » » /* suspension forced, can do nothing more */ | 550 return 0; /* suspension forced, can do nothing more */ |
445 | 551 |
446 /* OK, we processed one iMCU row. */ | 552 /* OK, we processed one iMCU row. */ |
447 cinfo->output_scanline += lines_per_iMCU_row; | 553 cinfo->output_scanline += lines_per_iMCU_row; |
448 return lines_per_iMCU_row; | 554 return lines_per_iMCU_row; |
449 } | 555 } |
450 | 556 |
451 | 557 |
452 /* Additional entry points for buffered-image mode. */ | 558 /* Additional entry points for buffered-image mode. */ |
453 | 559 |
454 #ifdef D_MULTISCAN_FILES_SUPPORTED | 560 #ifdef D_MULTISCAN_FILES_SUPPORTED |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 /* Terminate this pass. */ | 596 /* Terminate this pass. */ |
491 /* We do not require the whole pass to have been completed. */ | 597 /* We do not require the whole pass to have been completed. */ |
492 (*cinfo->master->finish_output_pass) (cinfo); | 598 (*cinfo->master->finish_output_pass) (cinfo); |
493 cinfo->global_state = DSTATE_BUFPOST; | 599 cinfo->global_state = DSTATE_BUFPOST; |
494 } else if (cinfo->global_state != DSTATE_BUFPOST) { | 600 } else if (cinfo->global_state != DSTATE_BUFPOST) { |
495 /* BUFPOST = repeat call after a suspension, anything else is error */ | 601 /* BUFPOST = repeat call after a suspension, anything else is error */ |
496 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); | 602 ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); |
497 } | 603 } |
498 /* Read markers looking for SOS or EOI */ | 604 /* Read markers looking for SOS or EOI */ |
499 while (cinfo->input_scan_number <= cinfo->output_scan_number && | 605 while (cinfo->input_scan_number <= cinfo->output_scan_number && |
500 » ! cinfo->inputctl->eoi_reached) { | 606 ! cinfo->inputctl->eoi_reached) { |
501 if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) | 607 if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) |
502 return FALSE;» » /* Suspend, come back later */ | 608 return FALSE; /* Suspend, come back later */ |
503 } | 609 } |
504 cinfo->global_state = DSTATE_BUFIMAGE; | 610 cinfo->global_state = DSTATE_BUFIMAGE; |
505 return TRUE; | 611 return TRUE; |
506 } | 612 } |
507 | 613 |
508 #endif /* D_MULTISCAN_FILES_SUPPORTED */ | 614 #endif /* D_MULTISCAN_FILES_SUPPORTED */ |
OLD | NEW |