mirror of
https://github.com/libjpeg-turbo/libjpeg-turbo.git
synced 2026-01-18 21:41:20 +01:00
TJBench: Test end-to-end grayscale comp./decomp.
Because the TurboJPEG API originated in VirtualGL and TurboVNC as a means of compressing from/decompressing to extended RGB framebuffers, its earliest incarnations did not handle grayscale packed-pixel images. Thus, TJBench has always converted the input image (even if it is grayscale) to an extended RGB source buffer prior to compression, and it has always decompressed JPEG images (even if they are grayscale) into an extended RGB destination buffer. That allows TJBench to benchmark the RGB-to-grayscale and grayscale-to-RGB color conversion paths used by VirtualGL and TurboVNC when grayscale subsampling (AKA the grayscale JPEG colorspace) is selected. However, more recent versions of the TurboJPEG API handle grayscale packed-pixel images, so it is beneficial to allow TJBench to benchmark the end-to-end grayscale compression and decompression paths. This commit accomplishes that by adding a new command-line option (-gray) that causes TJBench to use a grayscale source buffer (which only works if the input image is PGM or grayscale BMP), to decompress JPEG images (even if they are full-color) into a grayscale destination buffer, and to save output images in PGM or grayscale BMP format.
This commit is contained in:
@@ -9,6 +9,10 @@ documentation for the libjpeg API library and associated programs has been
|
||||
moved into the **doc/** subdirectory, and all C source code and headers have
|
||||
been moved into a new **src/** 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.0.4
|
||||
=====
|
||||
|
||||
@@ -44,8 +44,8 @@ final class TJBench {
|
||||
private static int maxMemory = 0, maxPixels = 0, precision = 8, quiet = 0,
|
||||
pf = TJ.PF_BGR, yuvAlign = 1, restartIntervalBlocks,
|
||||
restartIntervalRows = 0;
|
||||
private static boolean compOnly, decompOnly, doTile, doYUV, write = true,
|
||||
bmp = false;
|
||||
private static boolean compOnly, decompOnly, doTile, doYUV, write = true;
|
||||
private static String ext = null;
|
||||
|
||||
static final String[] PIXFORMATSTR = {
|
||||
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY", "", "", "", "",
|
||||
@@ -319,11 +319,11 @@ final class TJBench {
|
||||
else
|
||||
sizeStr = new String("full");
|
||||
if (decompOnly)
|
||||
tempStr = new String(fileName + "_" + sizeStr + (bmp ? ".bmp" : ".ppm"));
|
||||
tempStr = new String(fileName + "_" + sizeStr + "." + ext);
|
||||
else
|
||||
tempStr = new String(fileName + "_" +
|
||||
(lossless ? "LOSSLS" : SUBNAME[subsamp]) + qualStr +
|
||||
"_" + sizeStr + (bmp ? ".bmp" : ".ppm"));
|
||||
"_" + sizeStr + "." + ext);
|
||||
|
||||
tjd.saveImage(precision, tempStr, dstBuf, scaledw, 0, scaledh, pf);
|
||||
}
|
||||
@@ -768,14 +768,14 @@ final class TJBench {
|
||||
String className = new TJBench().getClass().getName();
|
||||
|
||||
System.out.println("\nUSAGE: java " + className);
|
||||
System.out.println(" <Inputimage (BMP|PPM)> <Quality or PSV> [options]\n");
|
||||
System.out.println(" <Inputimage (BMP|PPM|PGM)> <Quality or PSV> [options]\n");
|
||||
System.out.println(" java " + className);
|
||||
System.out.println(" <Inputimage (JPG)> [options]");
|
||||
|
||||
System.out.println("\nGENERAL OPTIONS");
|
||||
System.out.println("---------------");
|
||||
System.out.println("-benchtime T = Run each benchmark for at least T seconds [default = 5.0]");
|
||||
System.out.println("-bmp = Use Windows Bitmap format for output images [default = PPM]");
|
||||
System.out.println("-bmp = Use Windows Bitmap format for output images [default = PPM or PGM]");
|
||||
System.out.println(" ** 8-bit data precision only **");
|
||||
System.out.println("-bottomup = Use bottom-up row order for packed-pixel source/destination buffers");
|
||||
System.out.println("-componly = Stop after running compression tests. Do not test decompression.");
|
||||
@@ -788,7 +788,7 @@ final class TJBench {
|
||||
System.out.println("-maxpixels = Input image size limit (in pixels) [default = no limit]");
|
||||
System.out.println("-nowrite = Do not write reference or output images (improves consistency of");
|
||||
System.out.println(" benchmark results)");
|
||||
System.out.println("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb =");
|
||||
System.out.println("-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 = Indirectly test YCCK JPEG compression/decompression");
|
||||
@@ -883,7 +883,7 @@ final class TJBench {
|
||||
if (tempStr.endsWith(".jpg") || tempStr.endsWith(".jpeg"))
|
||||
decompOnly = true;
|
||||
if (tempStr.endsWith(".bmp"))
|
||||
bmp = true;
|
||||
ext = new String("bmp");
|
||||
|
||||
System.out.println("");
|
||||
|
||||
@@ -951,6 +951,8 @@ final class TJBench {
|
||||
pf = TJ.PF_XBGR;
|
||||
else if (argv[i].equalsIgnoreCase("-xrgb"))
|
||||
pf = TJ.PF_XRGB;
|
||||
else if (argv[i].equalsIgnoreCase("-gray"))
|
||||
pf = TJ.PF_GRAY;
|
||||
else if (argv[i].equalsIgnoreCase("-cmyk"))
|
||||
pf = TJ.PF_CMYK;
|
||||
else if (argv[i].equalsIgnoreCase("-bottomup"))
|
||||
@@ -1043,9 +1045,10 @@ final class TJBench {
|
||||
System.out.format("Warmup time = %.1f seconds\n\n", warmup);
|
||||
} else
|
||||
usage();
|
||||
} else if (argv[i].equalsIgnoreCase("-bmp"))
|
||||
bmp = true;
|
||||
else if (argv[i].equalsIgnoreCase("-yuv")) {
|
||||
} else if (argv[i].equalsIgnoreCase("-bmp")) {
|
||||
if (ext == null)
|
||||
ext = new String("bmp");
|
||||
} else if (argv[i].equalsIgnoreCase("-yuv")) {
|
||||
System.out.println("Testing planar YUV encoding/decoding\n");
|
||||
doYUV = true;
|
||||
} else if (argv[i].equalsIgnoreCase("-yuvpad") &&
|
||||
@@ -1130,6 +1133,15 @@ final class TJBench {
|
||||
precision != 12)
|
||||
System.out.println("Using optimized baseline entropy coding\n");
|
||||
|
||||
if (pf == TJ.PF_GRAY) {
|
||||
if (ext == null)
|
||||
ext = new String("pgm");
|
||||
subsamp = TJ.SAMP_GRAY;
|
||||
}
|
||||
|
||||
if (ext == null)
|
||||
ext = new String("ppm");
|
||||
|
||||
if (precision == 16 && !lossless)
|
||||
throw new Exception("-lossless must be specified along with -precision 16");
|
||||
if (precision != 8 && doYUV)
|
||||
|
||||
@@ -904,7 +904,7 @@ static void usage(char *progName)
|
||||
int i;
|
||||
|
||||
printf("USAGE: %s\n", progName);
|
||||
printf(" <Inputimage (BMP|PPM)> <Quality or PSV> [options]\n\n");
|
||||
printf(" <Inputimage (BMP|PPM|PGM)> <Quality or PSV> [options]\n\n");
|
||||
printf(" %s\n", progName);
|
||||
printf(" <Inputimage (JPG)> [options]\n");
|
||||
|
||||
@@ -912,7 +912,7 @@ static void usage(char *progName)
|
||||
printf("---------------\n");
|
||||
printf("-alloc = Dynamically allocate JPEG buffers\n");
|
||||
printf("-benchtime T = Run each benchmark for at least T seconds [default = 5.0]\n");
|
||||
printf("-bmp = Use Windows Bitmap format for output images [default = PPM]\n");
|
||||
printf("-bmp = Use Windows Bitmap format for output images [default = PPM or PGM]\n");
|
||||
printf(" ** 8-bit data precision only **\n");
|
||||
printf("-bottomup = Use bottom-up row order for packed-pixel source/destination buffers\n");
|
||||
printf("-componly = Stop after running compression tests. Do not test decompression.\n");
|
||||
@@ -925,7 +925,7 @@ static void usage(char *progName)
|
||||
printf("-maxpixels = Input image size limit (in pixels) [default = no limit]\n");
|
||||
printf("-nowrite = Do not write reference or output images (improves consistency of\n");
|
||||
printf(" benchmark results)\n");
|
||||
printf("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb =\n");
|
||||
printf("-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 = Indirectly test YCCK JPEG compression/decompression\n");
|
||||
@@ -1072,6 +1072,8 @@ int main(int argc, char *argv[])
|
||||
pf = TJPF_XBGR;
|
||||
else if (!strcasecmp(argv[i], "-xrgb"))
|
||||
pf = TJPF_XRGB;
|
||||
else if (!strcasecmp(argv[i], "-gray"))
|
||||
pf = TJPF_GRAY;
|
||||
else if (!strcasecmp(argv[i], "-cmyk"))
|
||||
pf = TJPF_CMYK;
|
||||
else if (!strcasecmp(argv[i], "-bottomup"))
|
||||
@@ -1199,6 +1201,11 @@ int main(int argc, char *argv[])
|
||||
if (optimize && !progressive && !arithmetic && !lossless && precision != 12)
|
||||
printf("Using optimized baseline entropy coding\n\n");
|
||||
|
||||
if (pf == TJPF_GRAY) {
|
||||
if (!strcmp(ext, "ppm")) ext = "pgm";
|
||||
subsamp = TJSAMP_GRAY;
|
||||
}
|
||||
|
||||
if (precision == 16 && !lossless) {
|
||||
printf("ERROR: -lossless must be specified along with -precision 16\n");
|
||||
retval = -1; goto bailout;
|
||||
|
||||
Reference in New Issue
Block a user