diff options
author | DRC <dcommander@users.sourceforge.net> | 2015-06-27 08:10:31 +0000 |
---|---|---|
committer | Matt Sarett <msarett@google.com> | 2015-11-23 17:20:23 -0500 |
commit | e67a7e37deb26db5ac7da420560d22e1ca7ea4b4 (patch) | |
tree | 33e5c877b300fb2e3aeb60ef90b4dee10bd6c2e2 | |
parent | f8a1775eab51fb0a83e82343d2eae8cf52b16124 (diff) | |
download | libjpeg-turbo-e67a7e37deb26db5ac7da420560d22e1ca7ea4b4.tar.gz |
Add regression tests for jpeg_skip_scanlines(); change "stripe" to "strip" in djpeg; document -strip and -skip parameters in djpeg
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@1587 632fc199-4ca6-4c93-a231-07263d6284db
-rw-r--r-- | CMakeLists.txt | 100 | ||||
-rw-r--r-- | Makefile.am | 58 | ||||
-rw-r--r-- | djpeg.1 | 12 | ||||
-rw-r--r-- | djpeg.c | 28 |
4 files changed, 181 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bd914933..0be768e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -356,6 +356,10 @@ if(WITH_12BIT) set(MD5_PPM_420M_ISLOW_3_8 343d19015531b7bbe746124127244fa8) set(MD5_PPM_420M_ISLOW_1_4 35fd59d866e44659edfa3c18db2a3edb) set(MD5_PPM_420M_ISLOW_1_8 ccaed48ac0aedefda5d4abe4013f4ad7) + set(MD5_PPM_420_ISLOW_SKIP15_31 86664cd9dc956536409e44e244d20a97) + set(MD5_PPM_420_ISLOW_PROG_STRIP71_132 a5c3706bb2e59bd01786b1181f67f97c) + set(MD5_PPM_444_ISLOW_SKIP1_6 ef63901f71ef7a75cd78253fc0914f84) + set(MD5_PPM_444_ISLOW_PROG_STRIP13_110 6d228f8d05381d8639f3d078b91b2ee0) set(MD5_JPEG_CROP cdb35ff4b4519392690ea040c56ea99c) else() set(TESTORIG testorig.jpg) @@ -405,6 +409,13 @@ else() set(MD5_BMP_420_ISLOW_565D 6bde71526acc44bcff76f696df8638d2) set(MD5_BMP_420M_ISLOW_565 8dc0185245353cfa32ad97027342216f) set(MD5_BMP_420M_ISLOW_565D d1be3a3339166255e76fa50a0d70d73e) + set(MD5_PPM_420_ISLOW_SKIP15_31 c4c65c1e43d7275cd50328a61e6534f0) + set(MD5_PPM_420_ISLOW_ARI_SKIP16_139 087c6b123db16ac00cb88c5b590bb74a) + set(MD5_PPM_420_ISLOW_PROG_STRIP71_132 a7f2ba6ea335f03549888bed66a89fae) + set(MD5_PPM_420_ISLOW_ARI_STRIP4_56 0e5e44a39b94817917a1bac72903246b) + set(MD5_PPM_444_ISLOW_SKIP1_6 5606f86874cf26b8fcee1117a0a436a6) + set(MD5_PPM_444_ISLOW_PROG_STRIP13_110 40b5d9742558dca6229d7332fc2dda07) + set(MD5_PPM_444_ISLOW_ARI_STRIP0_36 9aceb5b9449c900b892a1d2fe39351b4) set(MD5_JPEG_CROP b4197f377e621c4e9b1d20471432610d) endif() @@ -653,7 +664,7 @@ foreach(libtype ${TEST_LIBTYPES}) -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake) # CC: YCC->RGB SAMP: fullsize FDCT: islow ENT: prog arith add_test(cjpeg${suffix}-444-islow-progari - ${dir}cjpeg${suffix} -sample 1x1 -dct int -progressive -arithmetic + ${dir}cjpeg${suffix} -sample 1x1 -dct int -prog -arithmetic -outfile testout_444_islow_progari.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm) add_test(cjpeg${suffix}-444-islow-progari-cmp @@ -757,6 +768,93 @@ foreach(libtype ${TEST_LIBTYPES}) -DFILE=testout_420m_islow_565D.bmp -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake) endif() + + # Partial decode tests. These tests are designed to cover all of the + # possible code paths in jpeg_skip_scanlines(). + + # Context rows: Yes Intra-iMCU row: Yes iMCU row prefetch: No ENT: huff + add_test(djpeg${suffix}-420-islow-skip15_31 + ${dir}djpeg${suffix} -dct int -skip 15,31 -ppm + -outfile testout_420_islow_skip15,31.ppm + ${CMAKE_SOURCE_DIR}/testimages/${TESTORIG}) + add_test(djpeg${suffix}-420-islow-skip15_31-cmp + ${CMAKE_COMMAND} -DMD5=${MD5_PPM_420_ISLOW_SKIP15_31} + -DFILE=testout_420_islow_skip15,31.ppm + -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake) + # Context rows: Yes Intra-iMCU row: No iMCU row prefetch: Yes ENT: arith + if(WITH_ARITH_DEC) + add_test(djpeg${suffix}-420-islow-ari-skip16_139 + ${dir}djpeg${suffix} -dct int -skip 16,139 -ppm + -outfile testout_420_islow_ari_skip16,139.ppm + ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg) + add_test(djpeg${suffix}-420-islow-ari_skip16_139-cmp + ${CMAKE_COMMAND} -DMD5=${MD5_PPM_420_ISLOW_ARI_SKIP16_139} + -DFILE=testout_420_islow_ari_skip16,139.ppm + -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake) + endif() + # Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: prog huff + add_test(cjpeg${suffix}-420-islow-prog + ${dir}cjpeg${suffix} -dct int -prog -outfile testout_420_islow_prog.jpg + ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm) + add_test(djpeg${suffix}-420-islow-prog-strip71_132 + ${dir}djpeg${suffix} -dct int -strip 71,132 -ppm + -outfile testout_420_islow_strip71,132.ppm testout_420_islow_prog.jpg) + add_test(djpeg${suffix}-420-islow-prog-strip71_132-cmp + ${CMAKE_COMMAND} -DMD5=${MD5_PPM_420_ISLOW_PROG_STRIP71_132} + -DFILE=testout_420_islow_strip71,132.ppm + -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake) + # Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: arith + if(WITH_ARITH_DEC) + add_test(djpeg${suffix}-420-islow-ari-strip4_56 + ${dir}djpeg${suffix} -dct int -strip 4,56 -ppm + -outfile testout_420_islow_ari_strip4,56.ppm + ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg) + add_test(djpeg${suffix}-420-islow-ari-strip4_56-cmp + ${CMAKE_COMMAND} -DMD5=${MD5_PPM_420_ISLOW_ARI_STRIP4_56} + -DFILE=testout_420_islow_ari_strip4,56.ppm + -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake) + endif() + # Context rows: No Intra-iMCU row: Yes ENT: huff + add_test(cjpeg${suffix}-444-islow + ${dir}cjpeg${suffix} -dct int -sample 1x1 -outfile testout_444_islow.jpg + ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm) + add_test(djpeg${suffix}-444-islow-skip1_6 + ${dir}djpeg${suffix} -dct int -skip 1,6 -ppm + -outfile testout_444_islow_skip1,6.ppm testout_444_islow.jpg) + add_test(djpeg${suffix}-444-islow-skip1_6-cmp + ${CMAKE_COMMAND} -DMD5=${MD5_PPM_444_ISLOW_SKIP1_6} + -DFILE=testout_444_islow_skip1,6.ppm + -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake) + # Context rows: No Intra-iMCU row: No ENT: prog huff + add_test(cjpeg${suffix}-444-islow-prog + ${dir}cjpeg${suffix} -dct int -prog -sample 1x1 + -outfile testout_444_islow_prog.jpg + ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm) + add_test(djpeg${suffix}-444-islow-prog-strip13_110 + ${dir}djpeg${suffix} -dct int -strip 13,110 -ppm + -outfile testout_444_islow_prog_strip13,110.ppm testout_444_islow_prog.jpg) + add_test(djpeg${suffix}-444-islow-prog_strip13_110-cmp + ${CMAKE_COMMAND} -DMD5=${MD5_PPM_444_ISLOW_PROG_STRIP13_110} + -DFILE=testout_444_islow_prog_strip13,110.ppm + -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake) + # Context rows: No Intra-iMCU row: No ENT: arith + if(WITH_ARITH_ENC) + add_test(cjpeg${suffix}-444-islow-ari + ${dir}cjpeg${suffix} -dct int -arithmetic -sample 1x1 + -outfile testout_444_islow_ari.jpg + ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm) + if(WITH_ARITH_DEC) + add_test(djpeg${suffix}-444-islow-ari-strip0_36 + ${dir}djpeg${suffix} -dct int -strip 0,36 -ppm + -outfile testout_444_islow_ari_strip0,36.ppm + testout_444_islow_ari.jpg) + add_test(djpeg${suffix}-444-islow-ari-strip0_36-cmp + ${CMAKE_COMMAND} -DMD5=${MD5_PPM_444_ISLOW_ARI_STRIP0_36} + -DFILE=testout_444_islow_ari_strip0,36.ppm + -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake) + endif() + endif() + add_test(jpegtran${suffix}-crop ${dir}jpegtran${suffix} -crop 120x90+20+50 -transpose -perfect -outfile testout_crop.jpg ${CMAKE_SOURCE_DIR}/testimages/${TESTORIG}) diff --git a/Makefile.am b/Makefile.am index 3a12fde2..17cda345 100644 --- a/Makefile.am +++ b/Makefile.am @@ -210,6 +210,10 @@ MD5_PPM_420M_ISLOW_1_2 = b419124dd5568b085787234866102866 MD5_PPM_420M_ISLOW_3_8 = 343d19015531b7bbe746124127244fa8 MD5_PPM_420M_ISLOW_1_4 = 35fd59d866e44659edfa3c18db2a3edb MD5_PPM_420M_ISLOW_1_8 = ccaed48ac0aedefda5d4abe4013f4ad7 +MD5_PPM_420_ISLOW_SKIP15_31 = 86664cd9dc956536409e44e244d20a97 +MD5_PPM_420_ISLOW_PROG_STRIP71_132 = a5c3706bb2e59bd01786b1181f67f97c +MD5_PPM_444_ISLOW_SKIP1_6 = ef63901f71ef7a75cd78253fc0914f84 +MD5_PPM_444_ISLOW_PROG_STRIP13_110 = 6d228f8d05381d8639f3d078b91b2ee0 MD5_JPEG_CROP = cdb35ff4b4519392690ea040c56ea99c else @@ -262,6 +266,13 @@ MD5_BMP_420_ISLOW_565 = bf9d13e16c4923b92e1faa604d7922cb MD5_BMP_420_ISLOW_565D = 6bde71526acc44bcff76f696df8638d2 MD5_BMP_420M_ISLOW_565 = 8dc0185245353cfa32ad97027342216f MD5_BMP_420M_ISLOW_565D =d1be3a3339166255e76fa50a0d70d73e +MD5_PPM_420_ISLOW_SKIP15_31 = c4c65c1e43d7275cd50328a61e6534f0 +MD5_PPM_420_ISLOW_ARI_SKIP16_139 = 087c6b123db16ac00cb88c5b590bb74a +MD5_PPM_420_ISLOW_PROG_STRIP71_132 = a7f2ba6ea335f03549888bed66a89fae +MD5_PPM_420_ISLOW_ARI_STRIP4_56 = 0e5e44a39b94817917a1bac72903246b +MD5_PPM_444_ISLOW_SKIP1_6 = 5606f86874cf26b8fcee1117a0a436a6 +MD5_PPM_444_ISLOW_PROG_STRIP13_110 = 40b5d9742558dca6229d7332fc2dda07 +MD5_PPM_444_ISLOW_ARI_STRIP0_36 = 9aceb5b9449c900b892a1d2fe39351b4 MD5_JPEG_CROP = b4197f377e621c4e9b1d20471432610d endif @@ -487,7 +498,7 @@ if WITH_ARITH_ENC md5/md5cmp $(MD5_JPEG_420_ISLOW_ARI) testout_420_islow_ari.jpg rm testout_420_islow_ari.jpg # CC: YCC->RGB SAMP: fullsize FDCT: islow ENT: prog arith - ./cjpeg -sample 1x1 -dct int -progressive -arithmetic -outfile testout_444_islow_progari.jpg $(srcdir)/testimages/testorig.ppm + ./cjpeg -sample 1x1 -dct int -prog -arithmetic -outfile testout_444_islow_progari.jpg $(srcdir)/testimages/testorig.ppm md5/md5cmp $(MD5_JPEG_444_ISLOW_PROGARI) testout_444_islow_progari.jpg rm testout_444_islow_progari.jpg endif @@ -573,6 +584,51 @@ else rm testout_420m_islow_565D.bmp endif +# Partial decode tests. These tests are designed to cover all of the possible +# code paths in jpeg_skip_scanlines(). + +# Context rows: Yes Intra-iMCU row: Yes iMCU row prefetch: No ENT: huff + ./djpeg -dct int -skip 15,31 -ppm -outfile testout_420_islow_skip15,31.ppm $(srcdir)/testimages/$(TESTORIG) + md5/md5cmp $(MD5_PPM_420_ISLOW_SKIP15_31) testout_420_islow_skip15,31.ppm + rm testout_420_islow_skip15,31.ppm +# Context rows: Yes Intra-iMCU row: No iMCU row prefetch: Yes ENT: arith +if WITH_ARITH_DEC + ./djpeg -dct int -skip 16,139 -ppm -outfile testout_420_islow_ari_skip16,139.ppm $(srcdir)/testimages/testimgari.jpg + md5/md5cmp $(MD5_PPM_420_ISLOW_ARI_SKIP16_139) testout_420_islow_ari_skip16,139.ppm + rm testout_420_islow_ari_skip16,139.ppm +endif +# Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: prog huff + ./cjpeg -dct int -prog -outfile testout_420_islow_prog.jpg $(srcdir)/testimages/testorig.ppm + ./djpeg -dct int -strip 71,132 -ppm -outfile testout_420_islow_prog_strip71,132.ppm testout_420_islow_prog.jpg + md5/md5cmp $(MD5_PPM_420_ISLOW_PROG_STRIP71_132) testout_420_islow_prog_strip71,132.ppm + rm testout_420_islow_prog_strip71,132.ppm testout_420_islow_prog.jpg +# Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: arith +if WITH_ARITH_DEC + ./djpeg -dct int -strip 4,56 -ppm -outfile testout_420_islow_ari_strip4,56.ppm $(srcdir)/testimages/testimgari.jpg + md5/md5cmp $(MD5_PPM_420_ISLOW_ARI_STRIP4_56) testout_420_islow_ari_strip4,56.ppm + rm testout_420_islow_ari_strip4,56.ppm +endif +# Context rows: No Intra-iMCU row: Yes ENT: huff + ./cjpeg -dct int -sample 1x1 -outfile testout_444_islow.jpg $(srcdir)/testimages/testorig.ppm + ./djpeg -dct int -skip 1,6 -ppm -outfile testout_444_islow_skip1,6.ppm testout_444_islow.jpg + md5/md5cmp $(MD5_PPM_444_ISLOW_SKIP1_6) testout_444_islow_skip1,6.ppm + rm testout_444_islow_skip1,6.ppm testout_444_islow.jpg +# Context rows: No Intra-iMCU row: No ENT: prog huff + ./cjpeg -dct int -prog -sample 1x1 -outfile testout_444_islow_prog.jpg $(srcdir)/testimages/testorig.ppm + ./djpeg -dct int -strip 13,110 -ppm -outfile testout_444_islow_prog_strip13,110.ppm testout_444_islow_prog.jpg + md5/md5cmp $(MD5_PPM_444_ISLOW_PROG_STRIP13_110) testout_444_islow_prog_strip13,110.ppm + rm testout_444_islow_prog_strip13,110.ppm testout_444_islow_prog.jpg +# Context rows: No Intra-iMCU row: No ENT: arith +if WITH_ARITH_ENC + ./cjpeg -dct int -arithmetic -sample 1x1 -outfile testout_444_islow_ari.jpg $(srcdir)/testimages/testorig.ppm +if WITH_ARITH_DEC + ./djpeg -dct int -strip 0,36 -ppm -outfile testout_444_islow_ari_strip0,36.ppm testout_444_islow_ari.jpg + md5/md5cmp $(MD5_PPM_444_ISLOW_ARI_STRIP0_36) testout_444_islow_ari_strip0,36.ppm + rm testout_444_islow_ari_strip0,36.ppm +endif + rm testout_444_islow_ari.jpg +endif + ./jpegtran -crop 120x90+20+50 -transpose -perfect -outfile testout_crop.jpg $(srcdir)/testimages/$(TESTORIG) md5/md5cmp $(MD5_JPEG_CROP) testout_crop.jpg rm testout_crop.jpg @@ -1,4 +1,4 @@ -.TH DJPEG 1 "21 November 2014" +.TH DJPEG 1 "26 June 2015" .SH NAME djpeg \- decompress a JPEG file to an image file .SH SYNOPSIS @@ -194,6 +194,16 @@ Send output image to the named file, not to standard output. Load input file into memory before decompressing. This feature was implemented mainly as a way of testing the in-memory source manager (jpeg_mem_src().) .TP +.BI \-skip " Y0,Y1" +Decode all rows of the JPEG image except those between Y0 and Y1 (inclusive.) +Note that if decompression scaling is being used, Y0 and Y1 are relative to the +scaled image dimensions. +.TP +.BI \-strip " Y0,Y1" +Decode only the rows of the JPEG image between Y0 and Y1 (inclusive.) Note +that if decompression scaling is being used, Y0 and Y1 are relative to the +scaled image dimensions. +.TP .B \-verbose Enable debug printout. More .BR \-v 's @@ -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, skip; +boolean strip, skip; JDIMENSION startY, endY; #define INPUT_BUF_SIZE 4096 @@ -167,8 +167,8 @@ usage (void) fprintf(stderr, " -memsrc Load input file into memory before decompressing\n"); #endif - 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, " -skip Y0,Y1 Decode all rows except those between Y0 and Y1 (inclusive)\n"); + fprintf(stderr, " -strip Y0,Y1 Decode only rows between Y0 and Y1 (inclusive)\n"); fprintf(stderr, " -verbose or -debug Emit debug output\n"); fprintf(stderr, " -version Print version information and exit\n"); exit(EXIT_FAILURE); @@ -194,7 +194,7 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv, requested_fmt = DEFAULT_FMT; /* set default output file format */ outfilename = NULL; memsrc = FALSE; - stripe = FALSE; + strip = FALSE; skip = FALSE; cinfo->err->trace_level = 0; @@ -376,12 +376,12 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv, &cinfo->scale_num, &cinfo->scale_denom) != 2) usage(); - } else if (keymatch(arg, "stripe", 2)) { + } else if (keymatch(arg, "strip", 2)) { if (++argn >= argc) usage(); if (sscanf(argv[argn], "%d,%d", &startY, &endY) != 2 || startY > endY) usage(); - stripe = TRUE; + strip = TRUE; } else if (keymatch(arg, "skip", 2)) { @@ -656,16 +656,16 @@ main (int argc, char **argv) /* Start decompressor */ (void) jpeg_start_decompress(&cinfo); - /* Stripe decode */ - if (stripe || skip) { + /* Strip decode */ + if (strip || skip) { JDIMENSION tmp; /* Check for valid endY. We cannot check this value until after * jpeg_start_decompress() is called. Note that we have already verified * that startY <= endY. */ - if (endY > cinfo.output_height) { - fprintf(stderr, "%s: stripe %d-%d exceeds image height %d\n", progname, + if (endY > cinfo.output_height - 1) { + fprintf(stderr, "%s: strip %d-%d exceeds image height %d\n", progname, startY, endY, cinfo.output_height); exit(EXIT_FAILURE); } @@ -674,7 +674,7 @@ main (int argc, char **argv) * manager creates an image of the proper size for the partial decode. */ tmp = cinfo.output_height; - cinfo.output_height = endY - startY; + cinfo.output_height = endY - startY + 1; if (skip) cinfo.output_height = tmp - cinfo.output_height; (*dest_mgr->start_output) (&cinfo, dest_mgr); @@ -687,7 +687,7 @@ main (int argc, char **argv) dest_mgr->buffer_height); (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines); } - jpeg_skip_scanlines(&cinfo, endY - startY); + jpeg_skip_scanlines(&cinfo, endY - startY + 1); while (cinfo.output_scanline < cinfo.output_height) { num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer, dest_mgr->buffer_height); @@ -695,12 +695,12 @@ main (int argc, char **argv) } } else { jpeg_skip_scanlines(&cinfo, startY); - while (cinfo.output_scanline < endY) { + 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); + jpeg_skip_scanlines(&cinfo, cinfo.output_height - endY + 1); } /* Normal full image decode */ |