]> granicus.if.org Git - libjpeg-turbo/commitdiff
Fix lib state when skipping to end of 1-scan image
authorDRC <information@libjpeg-turbo.org>
Tue, 5 Dec 2017 21:27:34 +0000 (15:27 -0600)
committerDRC <information@libjpeg-turbo.org>
Tue, 5 Dec 2017 22:08:01 +0000 (16:08 -0600)
If jpeg_skip_scanlines() is used to skip to the end of a single-scan
image, then we need to change the library state such that subsequent
calls to jpeg_consume_input() will return JPEG_REACHED_EOI rather than
JPEG_SUSPENDED.  (NOTE: not necessary for multi-scan images, since the
scans are processed prior to any call to jpeg_skip_scanlines().)

Unless I miss my guess, using jpeg_skip_scanlines() in this manner
will prevent any markers at the end of the JPEG image from being
read, but I don't think there is any way around that without actually
reading the data, which would defeat the purpose of
jpeg_skip_scanlines().

Fixes #194

ChangeLog.md
jdapistd.c

index d6299f119118e0ae1ae8ec32b5583e49f917b52b..d7d31ca8f4d70dcc5e21b6d9fe9cb256820572d9 100644 (file)
@@ -32,6 +32,11 @@ program was used to decompress an existing JPEG image.
 occurred when attempting to decompress a JPEG image that had been compressed
 with 4:1:1 chrominance subsampling.
 
+8. Fixed an issue whereby, when using `jpeg_skip_scanlines()` to skip to the
+end of a single-scan (non-progressive) image, subsequent calls to
+`jpeg_consume_input()` would return `JPEG_SUSPENDED` rather than
+`JPEG_REACHED_EOI`.
+
 
 1.5.2
 =====
index 6755dbb0dfc6ff6390aabb1bf4639e96f6f4dfdd..14fc6e31a6c8eb964d036dd803894fe8c85b79d9 100644 (file)
@@ -386,6 +386,8 @@ jpeg_skip_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
   /* Do not skip past the bottom of the image. */
   if (cinfo->output_scanline + num_lines >= cinfo->output_height) {
     cinfo->output_scanline = cinfo->output_height;
+    (*cinfo->inputctl->finish_input_pass) (cinfo);
+    cinfo->inputctl->eoi_reached = TRUE;
     return cinfo->output_height - cinfo->output_scanline;
   }