@@ -17,6 +17,8 @@ similar fix, but it did not cover all cases.
|
||||
- `jpeg_skip_scanlines()` now throws an error if two-pass color
|
||||
quantization is enabled. Two-pass color quantization never worked properly
|
||||
with `jpeg_skip_scanlines()`, and the issues could not readily be fixed.
|
||||
- Fixed an issue whereby `jpeg_skip_scanlines()` always returned 0 when
|
||||
skipping past the end of an image.
|
||||
|
||||
|
||||
2.0.5
|
||||
|
||||
24
djpeg.c
24
djpeg.c
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2013 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010-2011, 2013-2017, D. R. Commander.
|
||||
* Copyright (C) 2010-2011, 2013-2017, 2020, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@@ -708,7 +708,12 @@ main(int argc, char **argv)
|
||||
dest_mgr->buffer_height);
|
||||
(*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
|
||||
}
|
||||
jpeg_skip_scanlines(&cinfo, skip_end - skip_start + 1);
|
||||
if ((tmp = jpeg_skip_scanlines(&cinfo, skip_end - skip_start + 1)) !=
|
||||
skip_end - skip_start + 1) {
|
||||
fprintf(stderr, "%s: jpeg_skip_scanlines() returned %d rather than %d\n",
|
||||
progname, tmp, skip_end - skip_start + 1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
while (cinfo.output_scanline < cinfo.output_height) {
|
||||
num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
|
||||
dest_mgr->buffer_height);
|
||||
@@ -744,13 +749,24 @@ main(int argc, char **argv)
|
||||
cinfo.output_height = tmp;
|
||||
|
||||
/* Process data */
|
||||
jpeg_skip_scanlines(&cinfo, crop_y);
|
||||
if ((tmp = jpeg_skip_scanlines(&cinfo, crop_y)) != crop_y) {
|
||||
fprintf(stderr, "%s: jpeg_skip_scanlines() returned %d rather than %d\n",
|
||||
progname, tmp, crop_y);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
while (cinfo.output_scanline < crop_y + crop_height) {
|
||||
num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
|
||||
dest_mgr->buffer_height);
|
||||
(*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
|
||||
}
|
||||
jpeg_skip_scanlines(&cinfo, cinfo.output_height - crop_y - crop_height);
|
||||
if ((tmp =
|
||||
jpeg_skip_scanlines(&cinfo,
|
||||
cinfo.output_height - crop_y - crop_height)) !=
|
||||
cinfo.output_height - crop_y - crop_height) {
|
||||
fprintf(stderr, "%s: jpeg_skip_scanlines() returned %d rather than %d\n",
|
||||
progname, tmp, cinfo.output_height - crop_y - crop_height);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Normal full-image decompress */
|
||||
} else {
|
||||
|
||||
@@ -413,10 +413,11 @@ 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) {
|
||||
num_lines = cinfo->output_height - cinfo->output_scanline;
|
||||
cinfo->output_scanline = cinfo->output_height;
|
||||
(*cinfo->inputctl->finish_input_pass) (cinfo);
|
||||
cinfo->inputctl->eoi_reached = TRUE;
|
||||
return cinfo->output_height - cinfo->output_scanline;
|
||||
return num_lines;
|
||||
}
|
||||
|
||||
if (num_lines == 0)
|
||||
|
||||
Reference in New Issue
Block a user