Skip to content

Commit 8162edd

Browse files
committed
Fix issues w/ partial img decompr + buf img mode
Fixes #611
1 parent 2e136a7 commit 8162edd

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

ChangeLog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ iMCU (8 * the vertical sampling factor) using buffered-image mode with
2323
interblock smoothing enabled. This was a regression introduced by
2424
2.1 beta1[6(b)].
2525

26+
5. Fixed two issues that prevented partial image decompression from working
27+
properly with buffered-image mode:
28+
29+
- Attempting to call `jpeg_crop_scanline()` after
30+
`jpeg_start_decompress()` but before `jpeg_start_output()` resulted in an error
31+
("Improper call to JPEG library in state 207".)
32+
- Attempting to use `jpeg_skip_scanlines()` resulted in an error ("Bogus
33+
virtual array access") under certain circumstances.
34+
2635

2736
2.1.3
2837
=====

jdapistd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
163163
my_master_ptr master = (my_master_ptr)cinfo->master;
164164
#endif
165165

166-
if (cinfo->global_state != DSTATE_SCANNING || cinfo->output_scanline != 0)
166+
if ((cinfo->global_state != DSTATE_SCANNING &&
167+
cinfo->global_state != DSTATE_BUFIMAGE) || cinfo->output_scanline != 0)
167168
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
168169

169170
if (!xoffset || !width)
@@ -525,7 +526,7 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
525526
* all of the entropy decoding occurs in jpeg_start_decompress(), assuming
526527
* that the input data source is non-suspending. This makes skipping easy.
527528
*/
528-
if (cinfo->inputctl->has_multiple_scans) {
529+
if (cinfo->inputctl->has_multiple_scans || cinfo->buffered_image) {
529530
if (cinfo->upsample->need_context_rows) {
530531
cinfo->output_scanline += lines_to_skip;
531532
cinfo->output_iMCU_row += lines_to_skip / lines_per_iMCU_row;

0 commit comments

Comments
 (0)