aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDRC <dcommander@users.sourceforge.net>2015-06-25 03:44:37 +0000
committerMatt Sarett <msarett@google.com>2015-11-23 17:19:46 -0500
commit15884f48eb1a4acd9c6c24291db974c596e71934 (patch)
tree10d391627cdcdb0092cd3cde67ec5ab0101484b1
parentac30a1bf12751bd82e56158eb9456a28d9c086f3 (diff)
downloadlibjpeg-turbo-15884f48eb1a4acd9c6c24291db974c596e71934.tar.gz
Add a -skip option to djpeg, which opens up further regression testing options.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@1583 632fc199-4ca6-4c93-a231-07263d6284db
-rw-r--r--djpeg.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/djpeg.c b/djpeg.c
index 20821cec..6e3a0b99 100644
--- a/djpeg.c
+++ b/djpeg.c
@@ -89,7 +89,7 @@ static IMAGE_FORMATS requested_fmt;
static const char * progname; /* program name for error messages */
static char * outfilename; /* for -outfile switch */
boolean memsrc; /* for -memsrc switch */
-boolean stripe;
+boolean stripe, skip;
JDIMENSION startY, endY;
#define INPUT_BUF_SIZE 4096
@@ -167,7 +167,8 @@ usage (void)
fprintf(stderr, " -memsrc Load input file into memory before decompressing\n");
#endif
- fprintf(stderr, " -stripe Y0,Y1 Decode a horizontal stripe of the image [Y0, Y1)\n");
+ fprintf(stderr, " -skip Y0,Y1 Skip decoding a horizontal stripe of the image [Y0, Y1)\n");
+ fprintf(stderr, " -stripe Y0,Y1 Decode only a horizontal stripe of the image [Y0, Y1)\n");
fprintf(stderr, " -verbose or -debug Emit debug output\n");
fprintf(stderr, " -version Print version information and exit\n");
exit(EXIT_FAILURE);
@@ -194,6 +195,7 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
outfilename = NULL;
memsrc = FALSE;
stripe = FALSE;
+ skip = FALSE;
cinfo->err->trace_level = 0;
/* Scan command line options, adjust parameters */
@@ -381,6 +383,14 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
usage();
stripe = TRUE;
+
+ } else if (keymatch(arg, "skip", 2)) {
+ if (++argn >= argc)
+ usage();
+ if (sscanf(argv[argn], "%d,%d", &startY, &endY) != 2 || startY > endY)
+ usage();
+ skip = TRUE;
+
} else if (keymatch(arg, "targa", 1)) {
/* Targa output format. */
requested_fmt = FMT_TARGA;
@@ -647,7 +657,7 @@ main (int argc, char **argv)
(void) jpeg_start_decompress(&cinfo);
/* Stripe decode */
- if (stripe) {
+ if (stripe || skip) {
JDIMENSION tmp;
/* Check for valid endY. We cannot check this value until after
@@ -665,17 +675,33 @@ main (int argc, char **argv)
*/
tmp = cinfo.output_height;
cinfo.output_height = endY - startY;
+ if (skip)
+ cinfo.output_height = tmp - cinfo.output_height;
(*dest_mgr->start_output) (&cinfo, dest_mgr);
cinfo.output_height = tmp;
/* Process data */
- (void) jpeg_skip_scanlines(&cinfo, startY);
- while (cinfo.output_scanline < endY) {
- num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
- dest_mgr->buffer_height);
- (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
+ if (skip) {
+ while (cinfo.output_scanline < startY) {
+ 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, endY - startY);
+ while (cinfo.output_scanline < cinfo.output_height) {
+ num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
+ dest_mgr->buffer_height);
+ (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
+ }
+ } else {
+ jpeg_skip_scanlines(&cinfo, startY);
+ while (cinfo.output_scanline < endY) {
+ 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 - endY);
}
- (void) jpeg_skip_scanlines(&cinfo, cinfo.output_height - endY);
/* Normal full image decode */
} else {