TJBench: More argument consistification

-copynone --> -copy none

Add '-copy all', even though it's the default.

-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb, -gray, -cmyk -->
-pixelformat {rgb|bgr|rgbx|bgrx|xbgr|xrgb|gray|cmyk}
(This is mainly so -gray won't interfere with -grayscale.)

Fix an ArrayIndexOutOfBoundsException that occurred when passing -dct
to the Java version without specifying the DCT algorithm (oversight from
24fbf64d31a0758c63bcc27cf5d92fc5611717d0.)
This commit is contained in:
DRC
2024-09-04 12:06:42 -04:00
parent d43ed7a1ff
commit e4c67aff50
4 changed files with 101 additions and 45 deletions

View File

@@ -10,16 +10,12 @@ moved into the **doc/** subdirectory, all C source code and headers have been
moved into a new **src/** subdirectory, and test scripts have been moved into a
new **test/** subdirectory.
2. Added a new TJBench option (`-gray`) that can be used to test the
performance of compressing/decompressing a grayscale JPEG image from/to a
packed-pixel grayscale image.
3. cjpeg no longer allows GIF input files to be converted into
2. cjpeg no longer allows GIF input files to be converted into
12-bit-per-sample JPEG files. That was never a useful feature, since GIF
images have at most 256 colors referenced from a palette of 8-bit-per-component
RGB values.
4. Added support for lossless JPEG images with 2 to 15 bits per sample to the
3. Added support for lossless JPEG images with 2 to 15 bits per sample to the
libjpeg and TurboJPEG APIs. When creating or decompressing a lossless JPEG
image and when loading or saving a PBMPLUS image, functions/methods specific to
8-bit samples now handle 8-bit samples with 2 to 8 bits of data precision
@@ -31,20 +27,23 @@ now handle 16-bit samples with 13 to 16 bits of data precision. Refer to
[libjpeg.txt](doc/libjpeg.txt), [usage.txt](doc/usage.txt), and the TurboJPEG
API documentation for more details.
5. All deprecated constants and methods in the TurboJPEG Java API have been
4. All deprecated constants and methods in the TurboJPEG Java API have been
removed.
6. TJBench command-line arguments are now more consistent with those of cjpeg,
5. TJBench command-line arguments are now more consistent with those of cjpeg,
djpeg, and jpegtran. More specifically:
- `-copynone` has been replaced with `-copy none`.
- `-fastdct` has been replaced with `-dct fast`.
- `-fastupsample` has been replaced with `-nosmooth`.
- `-hflip` and `-vflip` have been replaced with `-flip horizontal` and
`-flip vertical`.
- `-hflip` and `-vflip` have been replaced with
`-flip {horizontal|vertical}`.
- `-limitscans` has been replaced with `-maxscans`, which allows the scan
limit to be specified.
- `-rgb`, `-bgr`, `-rgbx`, `-bgrx`, `-xbgr`, `-xrgb`, and `-cmyk` have
been replaced with `-pixelformat {rgb|bgr|rgbx|bgrx|xbgr|xrgb|cmyk}`.
- `-rot90`, `-rot180`, and `-rot270` have been replaced with
`-rotate 90`, `-rotate 180`, and `-rotate 270`.
`-rotate {90|180|270}`.
- `-stoponwarning` has been replaced with `-strict`.
- British spellings for `gray` (`grey`) and `optimize` (`optimise`) are
now allowed.
@@ -54,6 +53,10 @@ future release. TJBench command-line arguments can now be abbreviated as well.
(Where possible, the abbreviations are the same as those supported by cjpeg,
djpeg, and jpegtran.)
6. Added a new TJBench option (`-pixelformat gray`) that can be used to test
the performance of compressing/decompressing a grayscale JPEG image from/to a
packed-pixel grayscale image.
7. The TurboJPEG C and Java APIs have been improved in the following ways:
- New image I/O methods (`TJCompressor.loadSourceImage()` and

View File

@@ -797,10 +797,10 @@ final class TJBench {
System.out.println("-nowrite");
System.out.println(" Do not write reference or output images (improves consistency of benchmark");
System.out.println(" results)");
System.out.println("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb, -gray");
System.out.println("-pixelformat {rgb|bgr|rgbx|bgrx|xbgr|xrgb|gray}");
System.out.println(" Use the specified pixel format for packed-pixel source/destination buffers");
System.out.println(" [default = BGR]");
System.out.println("-cmyk");
System.out.println("-pixelformat cmyk");
System.out.println(" Indirectly test YCCK JPEG compression/decompression (use the CMYK pixel");
System.out.println(" format for packed-pixel source/destination buffers)");
System.out.println("-precision N");
@@ -829,9 +829,11 @@ final class TJBench {
System.out.println("-arithmetic");
System.out.println(" Use arithmetic entropy coding in JPEG images generated by compression and");
System.out.println(" transform operations (can be combined with -progressive)");
System.out.println("-copynone");
System.out.println(" Do not copy any extra markers (including Exif and ICC profile data) when");
System.out.println(" transforming the input image");
System.out.println("-copy all");
System.out.println(" Copy all extra markers (including comments, JFIF thumbnails, Exif data, and");
System.out.println(" ICC profile data) when transforming the input image [default]");
System.out.println("-copy none");
System.out.println(" Do not copy any extra markers when transforming the input image");
System.out.println("-crop WxH+X+Y");
System.out.println(" Decompress only the specified region of the JPEG image, where W and H are");
System.out.println(" the width and height of the region (0 = maximum possible width or height)");
@@ -973,7 +975,7 @@ final class TJBench {
pf = TJ.PF_CMYK;
else if (matchArg(argv[i], "-componly", 4))
compOnly = true;
else if (matchArg(argv[i], "-copynone", 4))
else if (matchArg(argv[i], "-copynone", 6))
xformOpt |= TJTransform.OPT_COPYNONE;
else if (matchArg(argv[i], "-crop", 3) && i < argv.length - 1) {
int temp1 = -1, temp2 = -1, temp3 = -1, temp4 = -1;
@@ -991,7 +993,13 @@ final class TJBench {
cr.width = temp1; cr.height = temp2; cr.x = temp3; cr.y = temp4;
} else if (matchArg(argv[i], "-custom", 3))
customFilter = new DummyDCTFilter();
else if (matchArg(argv[i], "-dct", 2)) {
else if (matchArg(argv[i], "-copy", 2)) {
i++;
if (matchArg(argv[i], "none", 1))
xformOpt |= TJTransform.OPT_COPYNONE;
else if (!matchArg(argv[i], "all", 1))
usage();
} else if (matchArg(argv[i], "-dct", 2) && i < argv.length - 1) {
i++;
if (matchArg(argv[i], "fast", 1)) {
System.out.println("Using less accurate DCT/IDCT algorithm\n");
@@ -1012,11 +1020,8 @@ final class TJBench {
xformOp = TJTransform.OP_VFLIP;
else
usage();
} else if (argv[i].equalsIgnoreCase("-gray") ||
argv[i].equalsIgnoreCase("-grey"))
pf = TJ.PF_GRAY;
else if (matchArg(argv[i], "-grayscale", 2) ||
matchArg(argv[i], "-greyscale", 2))
} else if (matchArg(argv[i], "-grayscale", 2) ||
matchArg(argv[i], "-greyscale", 2))
xformOpt |= TJTransform.OPT_GRAY;
else if (matchArg(argv[i], "-hflip", 2))
xformOp = TJTransform.OP_HFLIP;
@@ -1064,6 +1069,28 @@ final class TJBench {
matchArg(argv[i], "-optimise", 2)) {
optimize = true;
xformOpt |= TJTransform.OPT_OPTIMIZE;
} else if (matchArg(argv[i], "-pixelformat", 3) &&
i < argv.length - 1) {
i++;
if (argv[i].equalsIgnoreCase("bgr"))
pf = TJ.PF_BGR;
else if (argv[i].equalsIgnoreCase("bgrx"))
pf = TJ.PF_BGRX;
else if (matchArg(argv[i], "cmyk", 1))
pf = TJ.PF_CMYK;
else if (matchArg(argv[i], "gray", 1) ||
matchArg(argv[i], "grey", 1))
pf = TJ.PF_GRAY;
else if (argv[i].equalsIgnoreCase("rgb"))
pf = TJ.PF_RGB;
else if (argv[i].equalsIgnoreCase("rgbx"))
pf = TJ.PF_RGBX;
else if (argv[i].equalsIgnoreCase("xbgr"))
pf = TJ.PF_XBGR;
else if (argv[i].equalsIgnoreCase("xrgb"))
pf = TJ.PF_XRGB;
else
usage();
} else if (matchArg(argv[i], "-precision", 4) &&
i < argv.length - 1) {
int temp = 0;

View File

@@ -940,10 +940,10 @@ static void usage(char *progName)
printf("-nowrite\n");
printf(" Do not write reference or output images (improves consistency of benchmark\n");
printf(" results)\n");
printf("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb, -gray\n");
printf("-pixelformat {rgb|bgr|rgbx|bgrx|xbgr|xrgb|gray}\n");
printf(" Use the specified pixel format for packed-pixel source/destination buffers\n");
printf(" [default = BGR]\n");
printf("-cmyk\n");
printf("-pixelformat cmyk\n");
printf(" Indirectly test YCCK JPEG compression/decompression (use the CMYK pixel\n");
printf(" format for packed-pixel source/destination buffers)\n");
printf("-precision N\n");
@@ -972,9 +972,11 @@ static void usage(char *progName)
printf("-arithmetic\n");
printf(" Use arithmetic entropy coding in JPEG images generated by compression and\n");
printf(" transform operations (can be combined with -progressive)\n");
printf("-copynone\n");
printf(" Do not copy any extra markers (including Exif and ICC profile data) when\n");
printf(" transforming the input image\n");
printf("-copy all\n");
printf(" Copy all extra markers (including comments, JFIF thumbnails, Exif data, and\n");
printf(" ICC profile data) when transforming the input image [default]\n");
printf("-copy none\n");
printf(" Do not copy any extra markers when transforming the input image\n");
printf("-crop WxH+X+Y\n");
printf(" Decompress only the specified region of the JPEG image, where W and H are\n");
printf(" the width and height of the region (0 = maximum possible width or height)\n");
@@ -1089,7 +1091,7 @@ int main(int argc, char *argv[])
pf = TJPF_CMYK;
else if (MATCH_ARG(argv[i], "-componly", 4))
compOnly = 1;
else if (MATCH_ARG(argv[i], "-copynone", 4))
else if (MATCH_ARG(argv[i], "-copynone", 6))
xformOpt |= TJXOPT_COPYNONE;
else if (MATCH_ARG(argv[i], "-crop", 3) && i < argc - 1) {
int temp1 = -1, temp2 = -1, temp3 = -1, temp4 = -1;
@@ -1103,7 +1105,13 @@ int main(int argc, char *argv[])
} else usage(argv[0]);
} else if (MATCH_ARG(argv[i], "-custom", 3))
customFilter = dummyDCTFilter;
else if (MATCH_ARG(argv[i], "-dct", 2) && i < argc - 1) {
else if (MATCH_ARG(argv[i], "-copy", 2)) {
i++;
if (MATCH_ARG(argv[i], "none", 1))
xformOpt |= TJXOPT_COPYNONE;
else if (!MATCH_ARG(argv[i], "all", 1))
usage(argv[0]);
} else if (MATCH_ARG(argv[i], "-dct", 2) && i < argc - 1) {
i++;
if (MATCH_ARG(argv[i], "fast", 1)) {
printf("Using less accurate DCT/IDCT algorithm\n\n");
@@ -1124,11 +1132,8 @@ int main(int argc, char *argv[])
xformOp = TJXOP_VFLIP;
else
usage(argv[0]);
} else if (!strcasecmp(argv[i], "-gray") ||
!strcasecmp(argv[i], "-grey"))
pf = TJPF_GRAY;
else if (MATCH_ARG(argv[i], "-grayscale", 2) ||
MATCH_ARG(argv[i], "-greyscale", 2))
} else if (MATCH_ARG(argv[i], "-grayscale", 2) ||
MATCH_ARG(argv[i], "-greyscale", 2))
xformOpt |= TJXOPT_GRAY;
else if (MATCH_ARG(argv[i], "-hflip", 2))
xformOp = TJXOP_HFLIP;
@@ -1162,6 +1167,27 @@ int main(int argc, char *argv[])
MATCH_ARG(argv[i], "-optimise", 2)) {
optimize = 1;
xformOpt |= TJXOPT_OPTIMIZE;
} else if (MATCH_ARG(argv[i], "-pixelformat", 3) && i < argc - 1) {
i++;
if (!strcasecmp(argv[i], "bgr"))
pf = TJPF_BGR;
else if (!strcasecmp(argv[i], "bgrx"))
pf = TJPF_BGRX;
else if (MATCH_ARG(argv[i], "cmyk", 1))
pf = TJPF_CMYK;
else if (MATCH_ARG(argv[i], "gray", 1) ||
MATCH_ARG(argv[i], "grey", 1))
pf = TJPF_GRAY;
else if (!strcasecmp(argv[i], "rgb"))
pf = TJPF_RGB;
else if (!strcasecmp(argv[i], "rgbx"))
pf = TJPF_RGBX;
else if (!strcasecmp(argv[i], "xbgr"))
pf = TJPF_XBGR;
else if (!strcasecmp(argv[i], "xrgb"))
pf = TJPF_XRGB;
else
usage(argv[0]);
} else if (MATCH_ARG(argv[i], "-precision", 4) && i < argc - 1) {
int tempi = atoi(argv[++i]);

View File

@@ -179,11 +179,11 @@ for image in $IMAGES; do
if [ "${dct}" = "fast" ]; then
dctarg="-d f"
fi
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -rgb -q -be 0.01 -w 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -pi rgb -q -be 0.01 -w 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
if [ "$LOSSLSARG" != "-l" ]; then
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -su 440 -r 1b -rgb -q -be 0.01 -w 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -su 411 -r 1 -rgb -q -be 0.01 -w 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -su 441 -r 2 -rgb -q -be 0.01 -w 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -su 440 -r 1b -pi rgb -q -be 0.01 -w 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -su 411 -r 1 -pi rgb -q -be 0.01 -w 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -su 441 -r 2 -pi rgb -q -be 0.01 -w 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
fi
for samp in $ALLSUBSAMP; do
if [ "$LOSSLSARG" = "-l" ]; then
@@ -201,7 +201,7 @@ for image in $IMAGES; do
fi
# Tiled compression & decompression
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -rgb -ti -q -be 0.01 -w 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -pi rgb -ti -q -be 0.01 -w 0 ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
for samp in $x1SUBSAMP; do
if [ $ALLOC = 1 ]; then
if [ "$LOSSLSARG" = "-l" ]; then
@@ -227,11 +227,11 @@ for image in $IMAGES; do
fi
fi
done
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -rgb -ti -q -be 0.01 -w 0 -nos ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -pi rgb -ti -q -be 0.01 -w 0 -nos ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
if [ "$LOSSLSARG" != "-l" ]; then
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -su 440 -rgb -ti -q -be 0.01 -w 0 -nos ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -su 411 -rgb -ti -q -be 0.01 -w 0 -nos ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -su 441 -rgb -ti -q -be 0.01 -w 0 -nos ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -su 440 -pi rgb -ti -q -be 0.01 -w 0 -nos ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -su 411 -pi rgb -ti -q -be 0.01 -w 0 -nos ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
runme $TJBENCH $OUTDIR/$image $TJQUAL -pre $PRECISION -su 441 -pi rgb -ti -q -be 0.01 -w 0 -nos ${dctarg} $YUVARG $ALLOCARG $ENTROPYARG $LOSSLSARG
fi
for samp in $x24SUBSAMP; do
if [ $ALLOC = 1 ]; then
@@ -409,7 +409,7 @@ for image in $IMAGES; do
# Grayscale transform
for xform in {0..6}; do
for samp in $ALLSUBSAMP; do
runme $TJBENCH $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG ${XFORMARGS[$xform]} -ti -q -be 0.01 -w 0 -grays $YUVARG $ALLOCARG $ENTROPYARG
runme $TJBENCH $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG ${XFORMARGS[$xform]} -ti -q -be 0.01 -w 0 -g $YUVARG $ALLOCARG $ENTROPYARG
if [ $ALLOC = 1 ]; then
runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_GRAY_${XFORMNAME[$xform]}_jpegtran.${EXT}
rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}