Extend YUVImage class to allow reuse of the same buffer with different metadata; port TJBench changes that treat YUV encoding/decoding as an intermediate step of the JPEG compression/decompression pipeline rather than a separate test case; add YUV encode/decode tests to the Java version of tjbenchtest

git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@1184 632fc199-4ca6-4c93-a231-07263d6284db
This commit is contained in:
DRC
2014-03-17 11:14:52 +00:00
parent dd5fcdd007
commit 7a6ed075ea
7 changed files with 404 additions and 344 deletions

View File

@@ -330,6 +330,7 @@ tjtest:
sh ./tjbenchtest -yuv sh ./tjbenchtest -yuv
if WITH_JAVA if WITH_JAVA
sh ./tjbenchtest.java sh ./tjbenchtest.java
sh ./tjbenchtest.java -yuv
endif endif

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C)2009-2013 D. R. Commander. All Rights Reserved. * Copyright (C)2009-2014 D. R. Commander. All Rights Reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@@ -34,12 +34,8 @@ import org.libjpegturbo.turbojpeg.*;
class TJBench { class TJBench {
static final int YUVENCODE = 1; static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvpad = 1, warmup = 1;
static final int YUVDECODE = 2; static boolean compOnly, decompOnly, doTile, doYUV;
static final int YUVCOMPRESS = 3;
static int flags = 0, yuv = 0, quiet = 0, pf = TJ.PF_BGR, yuvpad = 1;
static boolean compOnly, decompOnly, doTile;
static final String[] pixFormatStr = { static final String[] pixFormatStr = {
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY" "RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY"
@@ -134,17 +130,15 @@ class TJBench {
/* Decompression test */ /* Decompression test */
static void decompTest(byte[] srcBuf, byte[][] jpegBuf, int[] jpegSize, static void decomp(byte[] srcBuf, byte[][] jpegBuf, int[] jpegSize,
byte[] dstBuf, int w, int h, int subsamp, byte[] dstBuf, int w, int h, int subsamp, int jpegQual,
int jpegQual, String fileName, int tilew, int tileh) String fileName, int tilew, int tileh) throws Exception {
throws Exception {
String qualStr = new String(""), sizeStr, tempStr; String qualStr = new String(""), sizeStr, tempStr;
TJDecompressor tjd; TJDecompressor tjd;
double start, elapsed; double elapsed, elapsedDecode;
int ps = TJ.getPixelSize(pf), i; int ps = TJ.getPixelSize(pf), i, iter = 0;
int scaledw = sf.getScaled(w); int scaledw = sf.getScaled(w);
int scaledh = sf.getScaled(h); int scaledh = sf.getScaled(h);
int yuvSize = TJ.bufSizeYUV(scaledw, yuvpad, scaledh, subsamp), bufsize;
int pitch = scaledw * ps; int pitch = scaledw * ps;
YUVImage yuvImage = null; YUVImage yuvImage = null;
@@ -153,40 +147,52 @@ class TJBench {
tjd = new TJDecompressor(); tjd = new TJDecompressor();
int bufSize = (yuv == YUVDECODE ? yuvSize : pitch * scaledh);
if (dstBuf == null) if (dstBuf == null)
dstBuf = new byte[bufSize]; dstBuf = new byte[pitch * scaledh];
/* Set the destination buffer to gray so we know whether the decompressor /* Set the destination buffer to gray so we know whether the decompressor
attempted to write to it */ attempted to write to it */
Arrays.fill(dstBuf, (byte)127); Arrays.fill(dstBuf, (byte)127);
/* Execute once to preload cache */ if (doYUV) {
tjd.setSourceImage(jpegBuf[0], jpegSize[0]); int width = doTile ? tilew : scaledw;
if (yuv == YUVDECODE) { int height = doTile ? tileh : scaledh;
yuvImage = new YUVImage(dstBuf, scaledw, yuvpad, scaledh, subsamp); yuvImage = new YUVImage(width, yuvpad, height, subsamp);
tjd.decompressToYUV(yuvImage, flags); Arrays.fill(yuvImage.getBuf(), (byte)127);
} }
else
tjd.decompress(dstBuf, 0, 0, scaledw, pitch, scaledh, pf, flags);
/* Benchmark */ /* Benchmark */
for (i = 0, start = getTime(); (elapsed = getTime() - start) < benchTime; iter -= warmup;
i++) { elapsed = elapsedDecode = 0.0;
while (true) {
int tile = 0; int tile = 0;
if (yuv == YUVDECODE) double start = getTime();
tjd.decompressToYUV(yuvImage, flags); for (int y = 0; y < h; y += tileh) {
else { for (int x = 0; x < w; x += tilew, tile++) {
for (int y = 0; y < h; y += tileh) { int width = doTile ? Math.min(tilew, w - x) : scaledw;
for (int x = 0; x < w; x += tilew, tile++) { int height = doTile ? Math.min(tileh, h - y) : scaledh;
int width = doTile ? Math.min(tilew, w - x) : scaledw; tjd.setSourceImage(jpegBuf[tile], jpegSize[tile]);
int height = doTile ? Math.min(tileh, h - y) : scaledh; if (doYUV) {
tjd.setSourceImage(jpegBuf[tile], jpegSize[tile]); yuvImage.setBuf(yuvImage.getBuf(), width, yuvpad, height, subsamp);
tjd.decompressToYUV(yuvImage, flags);
double startDecode = getTime();
tjd.setSourceImage(yuvImage);
tjd.decompress(dstBuf, x, y, width, pitch, height, pf, flags);
if (iter >= 0)
elapsedDecode += getTime() - startDecode;
} else
tjd.decompress(dstBuf, x, y, width, pitch, height, pf, flags); tjd.decompress(dstBuf, x, y, width, pitch, height, pf, flags);
}
} }
} }
iter++;
if (iter >= 1) {
elapsed += getTime() - start;
if (elapsed >= benchTime)
break;
}
} }
if(doYUV)
elapsed -= elapsedDecode;
tjd = null; tjd = null;
for (i = 0; i < jpegBuf.length; i++) for (i = 0; i < jpegBuf.length; i++)
@@ -194,14 +200,27 @@ class TJBench {
jpegBuf = null; jpegSize = null; jpegBuf = null; jpegSize = null;
System.gc(); System.gc();
if (quiet != 0) if (quiet != 0) {
System.out.println( System.out.format("%-6s%s",
sigFig((double)(w * h) / 1000000. * (double)i / elapsed, 4)); sigFig((double)(w * h) / 1000000. * (double)iter / elapsed, 4),
else { quiet == 2 ? "\n" : " ");
System.out.format("D--> Frame rate: %f fps\n", if (doYUV)
(double)i / elapsed); System.out.format("%s\n",
System.out.format(" Dest. throughput: %f Megapixels/sec\n", sigFig((double)(w * h) / 1000000. * (double)iter / elapsedDecode, 4));
(double)(w * h) / 1000000. * (double)i / elapsed); else if (quiet != 2)
System.out.print("\n");
} else {
System.out.format("%s --> Frame rate: %f fps\n",
(doYUV ? "Decomp to YUV":"Decompress "),
(double)iter / elapsed);
System.out.format(" Throughput: %f Megapixels/sec\n",
(double)(w * h) / 1000000. * (double)iter / elapsed);
if (doYUV) {
System.out.format("YUV Decode --> Frame rate: %f fps\n",
(double)iter / elapsedDecode);
System.out.format(" Throughput: %f Megapixels/sec\n",
(double)(w * h) / 1000000. * (double)iter / elapsedDecode);
}
} }
if (sf.getNum() != 1 || sf.getDenom() != 1) if (sf.getNum() != 1 || sf.getDenom() != 1)
@@ -211,132 +230,57 @@ class TJBench {
else else
sizeStr = new String("full"); sizeStr = new String("full");
if (decompOnly) if (decompOnly)
tempStr = new String(fileName + "_" + sizeStr + tempStr = new String(fileName + "_" + sizeStr + ".bmp");
(yuv != 0 ? ".yuv" : ".bmp"));
else else
tempStr = new String(fileName + "_" + subName[subsamp] + qualStr + tempStr = new String(fileName + "_" + subName[subsamp] + qualStr +
"_" + sizeStr + (yuv != 0 ? ".yuv" : ".bmp")); "_" + sizeStr + ".bmp");
if (yuv == YUVDECODE) { saveImage(tempStr, dstBuf, scaledw, scaledh, pf);
FileOutputStream fos = new FileOutputStream(tempStr); int ndx = tempStr.indexOf('.');
fos.write(dstBuf, 0, yuvSize); tempStr = new String(tempStr.substring(0, ndx) + "-err.bmp");
fos.close(); if (srcBuf != null && sf.getNum() == 1 && sf.getDenom() == 1) {
} else { if (quiet == 0)
saveImage(tempStr, dstBuf, scaledw, scaledh, pf); System.out.println("Compression error written to " + tempStr + ".");
int ndx = tempStr.indexOf('.'); if (subsamp == TJ.SAMP_GRAY) {
tempStr = new String(tempStr.substring(0, ndx) + "-err.bmp"); for (int y = 0, index = 0; y < h; y++, index += pitch) {
if (srcBuf != null && sf.getNum() == 1 && sf.getDenom() == 1) { for (int x = 0, index2 = index; x < w; x++, index2 += ps) {
if (quiet == 0) int rindex = index2 + TJ.getRedOffset(pf);
System.out.println("Compression error written to " + tempStr + "."); int gindex = index2 + TJ.getGreenOffset(pf);
if (subsamp == TJ.SAMP_GRAY) { int bindex = index2 + TJ.getBlueOffset(pf);
for (int y = 0, index = 0; y < h; y++, index += pitch) { int lum = (int)((double)(srcBuf[rindex] & 0xff) * 0.299 +
for (int x = 0, index2 = index; x < w; x++, index2 += ps) { (double)(srcBuf[gindex] & 0xff) * 0.587 +
int rindex = index2 + TJ.getRedOffset(pf); (double)(srcBuf[bindex] & 0xff) * 0.114 + 0.5);
int gindex = index2 + TJ.getGreenOffset(pf); if (lum > 255) lum = 255;
int bindex = index2 + TJ.getBlueOffset(pf); if (lum < 0) lum = 0;
int lum = (int)((double)(srcBuf[rindex] & 0xff) * 0.299 + dstBuf[rindex] = (byte)Math.abs((dstBuf[rindex] & 0xff) - lum);
(double)(srcBuf[gindex] & 0xff) * 0.587 + dstBuf[gindex] = (byte)Math.abs((dstBuf[gindex] & 0xff) - lum);
(double)(srcBuf[bindex] & 0xff) * 0.114 + 0.5); dstBuf[bindex] = (byte)Math.abs((dstBuf[bindex] & 0xff) - lum);
if (lum > 255) lum = 255;
if (lum < 0) lum = 0;
dstBuf[rindex] = (byte)Math.abs((dstBuf[rindex] & 0xff) - lum);
dstBuf[gindex] = (byte)Math.abs((dstBuf[gindex] & 0xff) - lum);
dstBuf[bindex] = (byte)Math.abs((dstBuf[bindex] & 0xff) - lum);
}
} }
} else {
for (int y = 0; y < h; y++)
for (int x = 0; x < w * ps; x++)
dstBuf[pitch * y + x] =
(byte)Math.abs((dstBuf[pitch * y + x] & 0xff) -
(srcBuf[pitch * y + x] & 0xff));
} }
saveImage(tempStr, dstBuf, w, h, pf); } else {
for (int y = 0; y < h; y++)
for (int x = 0; x < w * ps; x++)
dstBuf[pitch * y + x] =
(byte)Math.abs((dstBuf[pitch * y + x] & 0xff) -
(srcBuf[pitch * y + x] & 0xff));
} }
saveImage(tempStr, dstBuf, w, h, pf);
} }
} }
static void doTestYUV(byte[] srcBuf, int w, int h, int subsamp, static void fullTest(byte[] srcBuf, int w, int h, int subsamp, int jpegQual,
String fileName) throws Exception { String fileName) throws Exception {
TJCompressor tjc;
byte[] dstBuf;
double start, elapsed;
int ps = TJ.getPixelSize(pf), i;
int yuvSize = 0;
YUVImage yuvImage;
yuvSize = TJ.bufSizeYUV(w, yuvpad, h, subsamp);
dstBuf = new byte[yuvSize];
if (quiet == 0)
System.out.format(">>>>> %s (%s) <--> YUV %s <<<<<\n",
pixFormatStr[pf],
(flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-up" : "Top-down",
subNameLong[subsamp]);
if (quiet == 1)
System.out.format("%s\t%s\t%s\tN/A\t", pixFormatStr[pf],
(flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD",
subNameLong[subsamp]);
tjc = new TJCompressor(srcBuf, 0, 0, w, 0, h, pf);
tjc.setSubsamp(subsamp);
/* Execute once to preload cache */
yuvImage = new YUVImage(dstBuf, w, yuvpad, h, subsamp);
tjc.encodeYUV(yuvImage, flags);
/* Benchmark */
for (i = 0, start = getTime();
(elapsed = getTime() - start) < benchTime; i++)
tjc.encodeYUV(yuvImage, flags);
if (quiet == 1)
System.out.format("%-4d %-4d\t", w, h);
if (quiet != 0) {
System.out.format("%s%c%s%c",
sigFig((double)(w * h) / 1000000. * (double) i / elapsed, 4),
quiet == 2 ? '\n' : '\t',
sigFig((double)(w * h * ps) / (double)yuvSize, 4),
quiet == 2 ? '\n' : '\t');
} else {
System.out.format("\n%s size: %d x %d\n", "Image", w, h);
System.out.format("C--> Frame rate: %f fps\n",
(double)i / elapsed);
System.out.format(" Output image size: %d bytes\n", yuvSize);
System.out.format(" Compression ratio: %f:1\n",
(double)(w * h * ps) / (double)yuvSize);
System.out.format(" Source throughput: %f Megapixels/sec\n",
(double)(w * h) / 1000000. * (double)i / elapsed);
System.out.format(" Output bit stream: %f Megabits/sec\n",
(double)yuvSize * 8. / 1000000. * (double)i / elapsed);
}
String tempStr = fileName + "_" + subName[subsamp] + ".yuv";
FileOutputStream fos = new FileOutputStream(tempStr);
fos.write(dstBuf, 0, yuvSize);
fos.close();
if (quiet == 0)
System.out.println("Reference image written to " + tempStr);
}
static void doTest(byte[] srcBuf, int w, int h, int subsamp, int jpegQual,
String fileName) throws Exception {
TJCompressor tjc; TJCompressor tjc;
byte[] tmpBuf; byte[] tmpBuf;
byte[][] jpegBuf; byte[][] jpegBuf;
int[] jpegSize; int[] jpegSize;
double start, elapsed; double start, elapsed, elapsedEncode;
int totalJpegSize = 0, tilew, tileh, i; int totalJpegSize = 0, tilew, tileh, i, iter;
int ps = (yuv == YUVCOMPRESS ? 3 : TJ.getPixelSize(pf)); int ps = TJ.getPixelSize(pf);
int ntilesw = 1, ntilesh = 1, pitch = w * ps; int ntilesw = 1, ntilesh = 1, pitch = w * ps;
String pfStr = (yuv == YUVCOMPRESS ? "YUV" : pixFormatStr[pf]); String pfStr = pixFormatStr[pf];
YUVImage yuvImage = null;
if (yuv == YUVENCODE) {
doTestYUV(srcBuf, w, h, subsamp, fileName);
return;
}
tmpBuf = new byte[pitch * h]; tmpBuf = new byte[pitch * h];
@@ -361,62 +305,94 @@ class TJBench {
/* Compression test */ /* Compression test */
if (quiet == 1) if (quiet == 1)
System.out.format("%s\t%s\t%s\t%d\t", pfStr, System.out.format("%-4s (%s) %-5s %-3d ", pfStr,
(flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD", (flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD",
subNameLong[subsamp], jpegQual); subNameLong[subsamp], jpegQual);
if (yuv != YUVCOMPRESS) for (i = 0; i < h; i++)
for (i = 0; i < h; i++) System.arraycopy(srcBuf, w * ps * i, tmpBuf, pitch * i, w * ps);
System.arraycopy(srcBuf, w * ps * i, tmpBuf, pitch * i, w * ps);
if (yuv == YUVCOMPRESS)
tjc.setSourceImage(new YUVImage(srcBuf, tilew, yuvpad, tileh,
subsamp));
else
tjc.setSourceImage(srcBuf, 0, 0, tilew, pitch, tileh, pf);
tjc.setJPEGQuality(jpegQual); tjc.setJPEGQuality(jpegQual);
tjc.setSubsamp(subsamp); tjc.setSubsamp(subsamp);
/* Execute once to preload cache */ if (doYUV) {
tjc.compress(jpegBuf[0], flags); yuvImage = new YUVImage(tilew, yuvpad, tileh, subsamp);
Arrays.fill(yuvImage.getBuf(), (byte)127);
}
/* Benchmark */ /* Benchmark */
for (i = 0, start = getTime(); iter = -warmup;
(elapsed = getTime() - start) < benchTime; i++) { elapsed = elapsedEncode = 0.0;
while (true) {
int tile = 0; int tile = 0;
totalJpegSize = 0; totalJpegSize = 0;
start = getTime();
for (int y = 0; y < h; y += tileh) { for (int y = 0; y < h; y += tileh) {
for (int x = 0; x < w; x += tilew, tile++) { for (int x = 0; x < w; x += tilew, tile++) {
int width = Math.min(tilew, w - x); int width = Math.min(tilew, w - x);
int height = Math.min(tileh, h - y); int height = Math.min(tileh, h - y);
if (yuv != YUVCOMPRESS) tjc.setSourceImage(srcBuf, x, y, width, pitch, height, pf);
tjc.setSourceImage(srcBuf, x, y, width, pitch, height, pf); if (doYUV) {
double startEncode = getTime();
yuvImage.setBuf(yuvImage.getBuf(), width, yuvpad, height,
subsamp);
tjc.encodeYUV(yuvImage, flags);
if (iter >= 0)
elapsedEncode += getTime() - startEncode;
tjc.setSourceImage(yuvImage);
}
tjc.compress(jpegBuf[tile], flags); tjc.compress(jpegBuf[tile], flags);
jpegSize[tile] = tjc.getCompressedSize(); jpegSize[tile] = tjc.getCompressedSize();
totalJpegSize += jpegSize[tile]; totalJpegSize += jpegSize[tile];
} }
} }
iter++;
if (iter >= 1) {
elapsed += getTime() - start;
if (elapsed >= benchTime)
break;
}
} }
if (doYUV)
elapsed -= elapsedEncode;
if (quiet == 1) if (quiet == 1)
System.out.format("%-4d %-4d\t", tilew, tileh); System.out.format("%-5d %-5d ", tilew, tileh);
if (quiet != 0) { if (quiet != 0) {
System.out.format("%s%c%s%c", if (doYUV)
sigFig((double)(w * h) / 1000000. * (double) i / elapsed, 4), System.out.format("%-6s%s",
quiet == 2 ? '\n' : '\t', sigFig((double)(w * h) / 1000000. * (double)iter / elapsedEncode, 4),
quiet == 2 ? "\n" : " ");
System.out.format("%-6s%s",
sigFig((double)(w * h) / 1000000. * (double)iter / elapsed, 4),
quiet == 2 ? "\n" : " ");
System.out.format("%-6s%s",
sigFig((double)(w * h * ps) / (double)totalJpegSize, 4), sigFig((double)(w * h * ps) / (double)totalJpegSize, 4),
quiet == 2 ? '\n' : '\t'); quiet == 2 ? "\n" : " ");
} else { } else {
System.out.format("\n%s size: %d x %d\n", doTile ? "Tile" : "Image", System.out.format("\n%s size: %d x %d\n", doTile ? "Tile" : "Image",
tilew, tileh); tilew, tileh);
System.out.format("C--> Frame rate: %f fps\n", if (doYUV) {
(double)i / elapsed); System.out.format("Encode YUV --> Frame rate: %f fps\n",
System.out.format(" Output image size: %d bytes\n", (double)iter / elapsedEncode);
System.out.format(" Output image size: %d bytes\n",
yuvImage.getSize());
System.out.format(" Compression ratio: %f:1\n",
(double)(w * h * ps) / (double)yuvImage.getSize());
System.out.format(" Throughput: %f Megapixels/sec\n",
(double)(w * h) / 1000000. * (double)iter / elapsedEncode);
System.out.format(" Output bit stream: %f Megabits/sec\n",
(double)yuvImage.getSize() * 8. / 1000000. * (double)iter / elapsedEncode);
}
System.out.format("%s --> Frame rate: %f fps\n",
doYUV ? "Comp from YUV" : "Compress ",
(double)iter / elapsed);
System.out.format(" Output image size: %d bytes\n",
totalJpegSize); totalJpegSize);
System.out.format(" Compression ratio: %f:1\n", System.out.format(" Compression ratio: %f:1\n",
(double)(w * h * ps) / (double)totalJpegSize); (double)(w * h * ps) / (double)totalJpegSize);
System.out.format(" Source throughput: %f Megapixels/sec\n", System.out.format(" Throughput: %f Megapixels/sec\n",
(double)(w * h) / 1000000. * (double)i / elapsed); (double)(w * h) / 1000000. * (double)iter / elapsed);
System.out.format(" Output bit stream: %f Megabits/sec\n", System.out.format(" Output bit stream: %f Megabits/sec\n",
(double)totalJpegSize * 8. / 1000000. * (double)i / elapsed); (double)totalJpegSize * 8. / 1000000. * (double)iter / elapsed);
} }
if (tilew == w && tileh == h) { if (tilew == w && tileh == h) {
String tempStr = fileName + "_" + subName[subsamp] + "_" + "Q" + String tempStr = fileName + "_" + subName[subsamp] + "_" + "Q" +
@@ -430,22 +406,22 @@ class TJBench {
/* Decompression test */ /* Decompression test */
if (!compOnly) if (!compOnly)
decompTest(srcBuf, jpegBuf, jpegSize, tmpBuf, w, h, subsamp, jpegQual, decomp(srcBuf, jpegBuf, jpegSize, tmpBuf, w, h, subsamp, jpegQual,
fileName, tilew, tileh); fileName, tilew, tileh);
if (tilew == w && tileh == h) break; if (tilew == w && tileh == h) break;
} }
} }
static void doDecompTest(String fileName) throws Exception { static void decompTest(String fileName) throws Exception {
TJTransformer tjt; TJTransformer tjt;
byte[][] jpegBuf; byte[][] jpegBuf = null;
byte[] srcBuf; byte[] srcBuf;
int[] jpegSize; int[] jpegSize = null;
int totalJpegSize; int totalJpegSize;
int w = 0, h = 0, subsamp = -1, cs = -1, _w, _h, _tilew, _tileh, int w = 0, h = 0, subsamp = -1, cs = -1, _w, _h, _tilew, _tileh,
_ntilesw, _ntilesh, _subsamp, x, y; _ntilesw, _ntilesh, _subsamp, x, y, iter;
int ntilesw = 1, ntilesh = 1; int ntilesw = 1, ntilesh = 1;
double start, elapsed; double start, elapsed;
int ps = TJ.getPixelSize(pf), tile; int ps = TJ.getPixelSize(pf), tile;
@@ -470,19 +446,20 @@ class TJBench {
if (quiet == 1) { if (quiet == 1) {
System.out.println("All performance values in Mpixels/sec\n"); System.out.println("All performance values in Mpixels/sec\n");
System.out.format("Bitmap\tBitmap\tJPEG\tJPEG\t%s %s \tXform\tComp\tDecomp\n", System.out.format("Bitmap JPEG JPEG %s %s Xform Comp Decomp ",
(doTile ? "Tile " : "Image"), (doTile ? "Tile " : "Image"),
(doTile ? "Tile " : "Image")); (doTile ? "Tile " : "Image"));
System.out.println("Format\tOrder\tCS\tSubsamp\tWidth Height\tPerf \tRatio\tPerf\n"); if (doYUV)
} else if (quiet == 0) { System.out.print("Decode");
if (yuv == YUVDECODE) System.out.print("\n");
System.out.format(">>>>> JPEG %s --> YUV <<<<<\n", System.out.print("Format CS Subsamp Width Height Perf Ratio Perf ");
formatName(subsamp, cs)); if (doYUV)
else System.out.print("Perf");
System.out.format(">>>>> JPEG %s --> %s (%s) <<<<<\n", System.out.println("\n");
formatName(subsamp, cs), pixFormatStr[pf], } else if (quiet == 0)
(flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-up" : "Top-down"); System.out.format(">>>>> JPEG %s --> %s (%s) <<<<<\n",
} formatName(subsamp, cs), pixFormatStr[pf],
(flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-up" : "Top-down");
for (int tilew = doTile ? 16 : w, tileh = doTile ? 16 : h; ; for (int tilew = doTile ? 16 : w, tileh = doTile ? 16 : h; ;
tilew *= 2, tileh *= 2) { tilew *= 2, tileh *= 2) {
@@ -502,10 +479,10 @@ class TJBench {
sf.getScaled(_h)); sf.getScaled(_h));
System.out.println(""); System.out.println("");
} else if (quiet == 1) { } else if (quiet == 1) {
System.out.format("%s\t%s\t%s\t%s\t", pixFormatStr[pf], System.out.format("%-4s (%s) %-5s %-5s ", pixFormatStr[pf],
(flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD", (flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD",
csName[cs], subNameLong[subsamp]); csName[cs], subNameLong[subsamp]);
System.out.format("%-4d %-4d\t", tilew, tileh); System.out.format("%-5d %-5d ", tilew, tileh);
} }
_subsamp = subsamp; _subsamp = subsamp;
@@ -534,6 +511,16 @@ class TJBench {
_ntilesw = (_w + _tilew - 1) / _tilew; _ntilesw = (_w + _tilew - 1) / _tilew;
_ntilesh = (_h + _tileh - 1) / _tileh; _ntilesh = (_h + _tileh - 1) / _tileh;
if (xformOp == TJTransform.OP_TRANSPOSE ||
xformOp == TJTransform.OP_TRANSVERSE ||
xformOp == TJTransform.OP_ROT90 ||
xformOp == TJTransform.OP_ROT270) {
if (_subsamp == TJ.SAMP_422)
_subsamp = TJ.SAMP_440;
else if (_subsamp == TJ.SAMP_440)
_subsamp = TJ.SAMP_422;
}
TJTransform[] t = new TJTransform[_ntilesw * _ntilesh]; TJTransform[] t = new TJTransform[_ntilesw * _ntilesh];
jpegBuf = new byte[_ntilesw * _ntilesh][TJ.bufSize(_tilew, _tileh, subsamp)]; jpegBuf = new byte[_ntilesw * _ntilesh][TJ.bufSize(_tilew, _tileh, subsamp)];
@@ -552,37 +539,45 @@ class TJBench {
} }
} }
start = getTime(); iter = -warmup;
tjt.transform(jpegBuf, t, flags); elapsed = 0.;
jpegSize = tjt.getTransformedSizes(); while (true) {
elapsed = getTime() - start; start = getTime();
tjt.transform(jpegBuf, t, flags);
jpegSize = tjt.getTransformedSizes();
iter++;
if (iter >= 1) {
elapsed += getTime() - start;
if (elapsed >= benchTime)
break;
}
}
t = null; t = null;
for (tile = 0, totalJpegSize = 0; tile < _ntilesw * _ntilesh; tile++) for (tile = 0, totalJpegSize = 0; tile < _ntilesw * _ntilesh; tile++)
totalJpegSize += jpegSize[tile]; totalJpegSize += jpegSize[tile];
if (quiet != 0) { if (quiet != 0) {
System.out.format("%s%c%s%c", System.out.format("%-6s%s%-6s%s",
sigFig((double)(w * h) / 1000000. / elapsed, 4), sigFig((double)(w * h) / 1000000. / elapsed, 4),
quiet == 2 ? '\n' : '\t', quiet == 2 ? "\n" : " ",
sigFig((double)(w * h * ps) / (double)totalJpegSize, 4), sigFig((double)(w * h * ps) / (double)totalJpegSize, 4),
quiet == 2 ? '\n' : '\t'); quiet == 2 ? "\n" : " ");
} else if (quiet == 0) { } else if (quiet == 0) {
System.out.format("X--> Frame rate: %f fps\n", System.out.format("Transform --> Frame rate: %f fps\n",
1.0 / elapsed); 1.0 / elapsed);
System.out.format(" Output image size: %d bytes\n", System.out.format(" Output image size: %d bytes\n",
totalJpegSize); totalJpegSize);
System.out.format(" Compression ratio: %f:1\n", System.out.format(" Compression ratio: %f:1\n",
(double)(w * h * ps) / (double)totalJpegSize); (double)(w * h * ps) / (double)totalJpegSize);
System.out.format(" Source throughput: %f Megapixels/sec\n", System.out.format(" Throughput: %f Megapixels/sec\n",
(double)(w * h) / 1000000. / elapsed); (double)(w * h) / 1000000. / elapsed);
System.out.format(" Output bit stream: %f Megabits/sec\n", System.out.format(" Output bit stream: %f Megabits/sec\n",
(double)totalJpegSize * 8. / 1000000. / elapsed); (double)totalJpegSize * 8. / 1000000. / elapsed);
} }
} else { } else {
if (quiet == 1) if (quiet == 1)
System.out.print("N/A\tN/A\t"); System.out.print("N/A N/A ");
jpegBuf = new byte[1][TJ.bufSize(_tilew, _tileh, subsamp)]; jpegBuf = new byte[1][TJ.bufSize(_tilew, _tileh, subsamp)];
jpegSize = new int[1]; jpegSize = new int[1];
jpegSize[0] = srcSize; jpegSize[0] = srcSize;
@@ -594,8 +589,8 @@ class TJBench {
if (h == tileh) if (h == tileh)
_tileh = _h; _tileh = _h;
if ((xformOpt & TJTransform.OPT_NOOUTPUT) == 0) if ((xformOpt & TJTransform.OPT_NOOUTPUT) == 0)
decompTest(null, jpegBuf, jpegSize, null, _w, _h, _subsamp, 0, decomp(null, jpegBuf, jpegSize, null, _w, _h, _subsamp, 0,
fileName, _tilew, _tileh); fileName, _tilew, _tileh);
else if (quiet == 1) else if (quiet == 1)
System.out.println("N/A"); System.out.println("N/A");
@@ -614,7 +609,7 @@ class TJBench {
String className = new TJBench().getClass().getName(); String className = new TJBench().getClass().getName();
System.out.println("\nUSAGE: java " + className); System.out.println("\nUSAGE: java " + className);
System.out.println(" <Inputfile (BMP|YUV)> <Quality> [options]\n"); System.out.println(" <Inputfile (BMP)> <Quality> [options]\n");
System.out.println(" java " + className); System.out.println(" java " + className);
System.out.println(" <Inputfile (JPG)> [options]\n"); System.out.println(" <Inputfile (JPG)> [options]\n");
System.out.println("Options:\n"); System.out.println("Options:\n");
@@ -623,29 +618,23 @@ class TJBench {
System.out.println("-tile = Test performance of the codec when the image is encoded as separate"); System.out.println("-tile = Test performance of the codec when the image is encoded as separate");
System.out.println(" tiles of varying sizes."); System.out.println(" tiles of varying sizes.");
System.out.println("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb ="); System.out.println("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb =");
System.out.println(" Test the specified color conversion path in the codec (default: BGR)"); System.out.println(" Test the specified color conversion path in the codec (default = BGR)");
System.out.println("-fastupsample = Use the fastest chrominance upsampling algorithm available in"); System.out.println("-fastupsample = Use the fastest chrominance upsampling algorithm available in");
System.out.println(" the underlying codec"); System.out.println(" the underlying codec");
System.out.println("-fastdct = Use the fastest DCT/IDCT algorithms available in the underlying"); System.out.println("-fastdct = Use the fastest DCT/IDCT algorithms available in the underlying");
System.out.println(" codec"); System.out.println(" codec");
System.out.println("-accuratedct = Use the most accurate DCT/IDCT algorithms available in the"); System.out.println("-accuratedct = Use the most accurate DCT/IDCT algorithms available in the");
System.out.println(" underlying codec"); System.out.println(" underlying codec");
System.out.println("-subsamp <s> = if compressing a JPEG image from a YUV planar source image,"); System.out.println("-subsamp <s> = When testing JPEG compression, this option specifies the level");
System.out.println(" this specifies the level of chrominance subsampling used in the source"); System.out.println(" of chrominance subsampling to use (<s> = 444, 422, 440, 420, 411, or");
System.out.println(" image. Otherwise, this specifies the level of chrominance subsampling"); System.out.println(" GRAY). The default is to test Grayscale, 4:2:0, 4:2:2, and 4:4:4 in");
System.out.println(" to use in the JPEG destination image. <s> = 444, 422, 440, 420, 411,"); System.out.println(" sequence.");
System.out.println(" or GRAY");
System.out.println("-quiet = Output results in tabular rather than verbose format"); System.out.println("-quiet = Output results in tabular rather than verbose format");
System.out.println("-yuvencode = Encode RGB input as planar YUV rather than compressing as JPEG"); System.out.println("-yuv = Test YUV encoding/decoding functions");
System.out.println("-yuvdecode = Decode JPEG image to planar YUV rather than RGB"); System.out.println("-yuvpad <p> = If testing YUV encoding/decoding, this specifies the number of");
System.out.println("-yuvsize WxH = if compressing a JPEG image from a YUV planar source image, this"); System.out.println(" bytes to which each row of each plane in the intermediate YUV image is");
System.out.println(" specifies the width and height of the source image."); System.out.println(" padded (default = 1)");
System.out.println("-yuvpad <p> = if compressing a JPEG image from a YUV planar source image, this"); System.out.println("-scale M/N = Scale down the width/height of the decompressed JPEG image by a");
System.out.println(" specifies the number of bytes to which each row of each plane in the");
System.out.println(" source image is padded. If decompressing a JPEG image to a YUV planar");
System.out.println(" destination image, this specifies the row padding for each plane of the");
System.out.println(" destination image. (default=1)");
System.out.println("-scale M/N = scale down the width/height of the decompressed JPEG image by a");
System.out.print (" factor of M/N (M/N = "); System.out.print (" factor of M/N (M/N = ");
for (i = 0; i < nsf; i++) { for (i = 0; i < nsf; i++) {
System.out.format("%d/%d", scalingFactors[i].getNum(), System.out.format("%d/%d", scalingFactors[i].getNum(),
@@ -668,7 +657,9 @@ class TJBench {
System.out.println("-grayscale = Perform lossless grayscale conversion prior to decompression"); System.out.println("-grayscale = Perform lossless grayscale conversion prior to decompression");
System.out.println(" test (can be combined with the other transforms above)"); System.out.println(" test (can be combined with the other transforms above)");
System.out.println("-benchtime <t> = Run each benchmark for at least <t> seconds (default = 5.0)"); System.out.println("-benchtime <t> = Run each benchmark for at least <t> seconds (default = 5.0)");
System.out.println("-componly = Stop after running compression tests. Do not test decompression.\n"); System.out.println("-warmup <w> = Execute each benchmark <w> times to prime the cache before");
System.out.println(" taking performance measurements (default = 1)");
System.out.println("-componly = Stop after running compression tests. Do not test decompression.\n");
System.out.println("NOTE: If the quality is specified as a range (e.g. 90-100), a separate"); System.out.println("NOTE: If the quality is specified as a range (e.g. 90-100), a separate");
System.out.println("test will be performed for all quality values in the range.\n"); System.out.println("test will be performed for all quality values in the range.\n");
System.exit(1); System.exit(1);
@@ -689,25 +680,10 @@ class TJBench {
String tempStr = argv[0].toLowerCase(); String tempStr = argv[0].toLowerCase();
if (tempStr.endsWith(".jpg") || tempStr.endsWith(".jpeg")) if (tempStr.endsWith(".jpg") || tempStr.endsWith(".jpeg"))
decompOnly = true; decompOnly = true;
if (tempStr.endsWith(".yuv"))
yuv = YUVCOMPRESS;
System.out.println(""); System.out.println("");
if (argv.length > minArg) { if (!decompOnly) {
for (int i = minArg; i < argv.length; i++) {
if (argv[i].equalsIgnoreCase("-yuvencode")) {
System.out.println("Testing YUV planar encoding\n");
yuv = YUVENCODE; maxQual = minQual = 100;
}
if (argv[i].equalsIgnoreCase("-yuvdecode")) {
System.out.println("Testing YUV planar decoding\n");
yuv = YUVDECODE;
}
}
}
if (!decompOnly && yuv != YUVENCODE) {
minArg = 2; minArg = 2;
if (argv.length < minArg) if (argv.length < minArg)
usage(); usage();
@@ -812,18 +788,9 @@ class TJBench {
else else
usage(); usage();
} }
if (argv[i].equalsIgnoreCase("-yuvsize") && i < argv.length - 1) { if (argv[i].equalsIgnoreCase("-yuv")) {
int temp1 = 0, temp2 = 0; System.out.println("Testing YUV planar encoding/decoding\n");
Scanner scanner = new Scanner(argv[++i]).useDelimiter("x"); doYUV = true;
try {
temp1 = scanner.nextInt();
temp2 = scanner.nextInt();
} catch(Exception e) {}
if (temp1 >= 1 && temp2 >= 1) {
w = temp1;
h = temp2;
} else
usage();
} }
if (argv[i].equalsIgnoreCase("-yuvpad") && i < argv.length - 1) { if (argv[i].equalsIgnoreCase("-yuvpad") && i < argv.length - 1) {
int temp = 0; int temp = 0;
@@ -850,6 +817,16 @@ class TJBench {
} }
if (argv[i].equalsIgnoreCase("-componly")) if (argv[i].equalsIgnoreCase("-componly"))
compOnly = true; compOnly = true;
if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) {
int temp = -1;
try {
temp = Integer.parseInt(argv[++i]);
} catch (NumberFormatException e) {}
if (temp >= 0) {
warmup = temp;
System.out.format("Warmup runs = %d\n\n", warmup);
}
}
if (argv[i].equalsIgnoreCase("-?")) if (argv[i].equalsIgnoreCase("-?"))
usage(); usage();
} }
@@ -864,67 +841,60 @@ class TJBench {
doTile = false; doTile = false;
} }
if (yuv != 0 && doTile) {
System.out.println("Disabling tiled compression/decompression tests, because those tests do not");
System.out.println("work when YUV encoding, compression, or decoding is enabled.\n");
doTile = false;
}
if (!decompOnly) { if (!decompOnly) {
if(yuv == YUVCOMPRESS) { int[] width = new int[1], height = new int[1];
if (w < 1 || h < 1 || subsamp < 0 || subsamp >= TJ.NUMSAMP) srcBuf = loadImage(argv[0], width, height, pf);
throw new Exception("YUV image size and/or subsampling not specified"); w = width[0]; h = height[0];
FileInputStream fis = new FileInputStream(argv[0]); int index = -1;
int srcSize = (int)fis.getChannel().size(); if ((index = argv[0].indexOf('.')) >= 0)
if (srcSize != TJ.bufSizeYUV(w, yuvpad, h, subsamp)) argv[0] = argv[0].substring(0, index);
throw new Exception("YUV image file is the wrong size");
srcBuf = new byte[srcSize];
fis.read(srcBuf, 0, srcSize);
fis.close();
}
else {
int[] width = new int[1], height = new int[1];
srcBuf = loadImage(argv[0], width, height, pf);
w = width[0]; h = height[0];
int index = -1;
if ((index = argv[0].indexOf('.')) >= 0)
argv[0] = argv[0].substring(0, index);
}
} }
if (quiet == 1 && !decompOnly) { if (quiet == 1 && !decompOnly) {
System.out.println("All performance values in Mpixels/sec\n"); System.out.println("All performance values in Mpixels/sec\n");
System.out.format("Bitmap\tBitmap\tJPEG\tJPEG\t%s %s \tComp\tComp\tDecomp\n", System.out.format("Bitmap JPEG JPEG %s %s ",
(doTile ? "Tile " : "Image"), (doTile ? "Tile " : "Image")); (doTile ? "Tile " : "Image"), (doTile ? "Tile " : "Image"));
System.out.println("Format\tOrder\tSubsamp\tQual\tWidth Height\tPerf \tRatio\tPerf\n"); if (doYUV)
System.out.print("Encode ");
System.out.print("Comp Comp Decomp ");
if (doYUV)
System.out.print("Decode");
System.out.print("\n");
System.out.print("Format Subsamp Qual Width Height ");
if (doYUV)
System.out.print("Perf ");
System.out.print("Perf Ratio Perf ");
if (doYUV)
System.out.print("Perf");
System.out.println("\n");
} }
if (decompOnly) { if (decompOnly) {
doDecompTest(argv[0]); decompTest(argv[0]);
System.out.println(""); System.out.println("");
System.exit(retval); System.exit(retval);
} }
System.gc(); System.gc();
if (yuv == YUVCOMPRESS || (subsamp >= 0 && subsamp < TJ.NUMSAMP)) { if (subsamp >= 0 && subsamp < TJ.NUMSAMP) {
for (int i = maxQual; i >= minQual; i--) for (int i = maxQual; i >= minQual; i--)
doTest(srcBuf, w, h, subsamp, i, argv[0]); fullTest(srcBuf, w, h, subsamp, i, argv[0]);
System.out.println(""); System.out.println("");
} else { } else {
for (int i = maxQual; i >= minQual; i--) for (int i = maxQual; i >= minQual; i--)
doTest(srcBuf, w, h, TJ.SAMP_GRAY, i, argv[0]); fullTest(srcBuf, w, h, TJ.SAMP_GRAY, i, argv[0]);
System.out.println(""); System.out.println("");
System.gc(); System.gc();
for (int i = maxQual; i >= minQual; i--) for (int i = maxQual; i >= minQual; i--)
doTest(srcBuf, w, h, TJ.SAMP_420, i, argv[0]); fullTest(srcBuf, w, h, TJ.SAMP_420, i, argv[0]);
System.out.println(""); System.out.println("");
System.gc(); System.gc();
for (int i = maxQual; i >= minQual; i--) for (int i = maxQual; i >= minQual; i--)
doTest(srcBuf, w, h, TJ.SAMP_422, i, argv[0]); fullTest(srcBuf, w, h, TJ.SAMP_422, i, argv[0]);
System.out.println(""); System.out.println("");
System.gc(); System.gc();
for (int i = maxQual; i >= minQual; i--) for (int i = maxQual; i >= minQual; i--)
doTest(srcBuf, w, h, TJ.SAMP_444, i, argv[0]); fullTest(srcBuf, w, h, TJ.SAMP_444, i, argv[0]);
System.out.println(""); System.out.println("");
} }

View File

@@ -662,6 +662,11 @@
<dd> <dd>
<div class="block">Grayscale.</div> <div class="block">Grayscale.</div>
</dd> </dd>
<dt><span class="strong"><a href="./org/libjpegturbo/turbojpeg/YUVImage.html#setBuf(byte[], int, int, int, int)">setBuf(byte[], int, int, int, int)</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="./org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg">YUVImage</a></dt>
<dd>
<div class="block">Assign an existing YUV planar image buffer to this <code>YUVImage</code>
instance.</div>
</dd>
<dt><span class="strong"><a href="./org/libjpegturbo/turbojpeg/TJDecompressor.html#setJPEGImage(byte[], int)">setJPEGImage(byte[], int)</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</a></dt> <dt><span class="strong"><a href="./org/libjpegturbo/turbojpeg/TJDecompressor.html#setJPEGImage(byte[], int)">setJPEGImage(byte[], int)</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</a></dt>
<dd> <dd>
<div class="block"><span class="strong">Deprecated.</span> <div class="block"><span class="strong">Deprecated.</span>

View File

@@ -243,6 +243,17 @@ extends java.lang.Object</pre>
<div class="block">Returns the width of the YUV image.</div> <div class="block">Returns the width of the YUV image.</div>
</td> </td>
</tr> </tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/YUVImage.html#setBuf(byte[], int, int, int, int)">setBuf</a></strong>(byte[]&nbsp;yuvImage,
int&nbsp;width,
int&nbsp;pad,
int&nbsp;height,
int&nbsp;subsamp)</code>
<div class="block">Assign an existing YUV planar image buffer to this <code>YUVImage</code>
instance.</div>
</td>
</tr>
</table> </table>
<ul class="blockList"> <ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object"> <li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
@@ -362,8 +373,8 @@ extends java.lang.Object</pre>
buffer.</div> buffer.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>yuvImage</code> - image buffer that contains or will contain YUV planar <dl><dt><span class="strong">Parameters:</span></dt><dd><code>yuvImage</code> - image buffer that contains or will contain YUV planar
image data. See <a href="../../../org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg"><code>above</code></a> for a description of the image image data. See <a href="../../../org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg"><code>above</code></a> for a description of the image
format. You can use <a href="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int, int)"><code>TJ.bufSizeYUV(int, int, int, int)</code></a> to determine the appropriate format. Use <a href="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int, int)"><code>TJ.bufSizeYUV(int, int, int, int)</code></a> to determine the minimum size for this
size for this buffer.</dd><dd><code>width</code> - width (in pixels) of the YUV image</dd><dd><code>pad</code> - the line padding used in the YUV image buffer. For buffer.</dd><dd><code>width</code> - width (in pixels) of the YUV image</dd><dd><code>pad</code> - the line padding used in the YUV image buffer. For
instance, if each line in each plane of the buffer is padded to the instance, if each line in each plane of the buffer is padded to the
nearest multiple of 4 bytes, then <code>pad</code> should be set to 4.</dd><dd><code>height</code> - height (in pixels) of the YUV image</dd><dd><code>subsamp</code> - the level of chrominance subsampling used in the YUV nearest multiple of 4 bytes, then <code>pad</code> should be set to 4.</dd><dd><code>height</code> - height (in pixels) of the YUV image</dd><dd><code>subsamp</code> - the level of chrominance subsampling used in the YUV
image (one of <a href="../../../org/libjpegturbo/turbojpeg/TJ.html#SAMP_444"><code>TJ.SAMP_*</code></a>)</dd> image (one of <a href="../../../org/libjpegturbo/turbojpeg/TJ.html#SAMP_444"><code>TJ.SAMP_*</code></a>)</dd>
@@ -379,6 +390,31 @@ extends java.lang.Object</pre>
<!-- --> <!-- -->
</a> </a>
<h3>Method Detail</h3> <h3>Method Detail</h3>
<a name="setBuf(byte[], int, int, int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setBuf</h4>
<pre>public&nbsp;void&nbsp;setBuf(byte[]&nbsp;yuvImage,
int&nbsp;width,
int&nbsp;pad,
int&nbsp;height,
int&nbsp;subsamp)
throws java.lang.Exception</pre>
<div class="block">Assign an existing YUV planar image buffer to this <code>YUVImage</code>
instance.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>yuvImage</code> - image buffer that contains or will contain YUV planar
image data. See <a href="../../../org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg"><code>above</code></a> for a description of the image
format. Use <a href="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int, int)"><code>TJ.bufSizeYUV(int, int, int, int)</code></a> to determine the minimum size for this
buffer.</dd><dd><code>width</code> - width (in pixels) of the YUV image</dd><dd><code>pad</code> - the line padding used in the YUV image buffer. For
instance, if each line in each plane of the buffer is padded to the
nearest multiple of 4 bytes, then <code>pad</code> should be set to 4.</dd><dd><code>height</code> - height (in pixels) of the YUV image</dd><dd><code>subsamp</code> - the level of chrominance subsampling used in the YUV
image (one of <a href="../../../org/libjpegturbo/turbojpeg/TJ.html#SAMP_444"><code>TJ.SAMP_*</code></a>)</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.lang.Exception</code></dd></dl>
</li>
</ul>
<a name="getWidth()"> <a name="getWidth()">
<!-- --> <!-- -->
</a> </a>

View File

@@ -74,8 +74,8 @@ public class YUVImage {
*/ */
public YUVImage(int width, int pad, int height, int subsamp) public YUVImage(int width, int pad, int height, int subsamp)
throws Exception { throws Exception {
setBuffer(new byte[TJ.bufSizeYUV(width, pad, height, subsamp)], width, pad, setBuf(new byte[TJ.bufSizeYUV(width, pad, height, subsamp)], width, pad,
height, subsamp); height, subsamp);
} }
/** /**
@@ -84,8 +84,8 @@ public class YUVImage {
* *
* @param yuvImage image buffer that contains or will contain YUV planar * @param yuvImage image buffer that contains or will contain YUV planar
* image data. See {@link YUVImage above} for a description of the image * image data. See {@link YUVImage above} for a description of the image
* format. You can use {@link TJ#bufSizeYUV} to determine the appropriate * format. Use {@link TJ#bufSizeYUV} to determine the minimum size for this
* size for this buffer. * buffer.
* *
* @param width width (in pixels) of the YUV image * @param width width (in pixels) of the YUV image
* *
@@ -100,16 +100,36 @@ public class YUVImage {
*/ */
public YUVImage(byte[] yuvImage, int width, int pad, int height, public YUVImage(byte[] yuvImage, int width, int pad, int height,
int subsamp) throws Exception { int subsamp) throws Exception {
setBuffer(yuvImage, width, pad, height, subsamp); setBuf(yuvImage, width, pad, height, subsamp);
} }
private void setBuffer(byte[] yuvImage, int width, int pad, int height, /**
int subsamp) throws Exception { * Assign an existing YUV planar image buffer to this <code>YUVImage</code>
* instance.
*
* @param yuvImage image buffer that contains or will contain YUV planar
* image data. See {@link YUVImage above} for a description of the image
* format. Use {@link TJ#bufSizeYUV} to determine the minimum size for this
* buffer.
*
* @param width width (in pixels) of the YUV image
*
* @param pad the line padding used in the YUV image buffer. For
* instance, if each line in each plane of the buffer is padded to the
* nearest multiple of 4 bytes, then <code>pad</code> should be set to 4.
*
* @param height height (in pixels) of the YUV image
*
* @param subsamp the level of chrominance subsampling used in the YUV
* image (one of {@link TJ#SAMP_444 TJ.SAMP_*})
*/
public void setBuf(byte[] yuvImage, int width, int pad, int height,
int subsamp) throws Exception {
if (yuvImage == null || width < 1 || pad < 1 || ((pad & (pad - 1)) != 0) || if (yuvImage == null || width < 1 || pad < 1 || ((pad & (pad - 1)) != 0) ||
height < 1 || subsamp < 0 || subsamp >= TJ.NUMSAMP) height < 1 || subsamp < 0 || subsamp >= TJ.NUMSAMP)
throw new Exception("Invalid argument in YUVImage()"); throw new Exception("Invalid argument in YUVImage()");
if (yuvImage.length != TJ.bufSizeYUV(width, pad, height, subsamp)) if (yuvImage.length < TJ.bufSizeYUV(width, pad, height, subsamp))
throw new Exception("YUV image buffer is the wrong size"); throw new Exception("YUV image buffer is not large enough");
yuvBuf = yuvImage; yuvBuf = yuvImage;
yuvWidth = width; yuvWidth = width;
yuvPad = pad; yuvPad = pad;
@@ -181,7 +201,7 @@ public class YUVImage {
public int getSize() throws Exception { public int getSize() throws Exception {
if (yuvBuf == null) if (yuvBuf == null)
throw new Exception(NO_ASSOC_ERROR); throw new Exception(NO_ASSOC_ERROR);
return yuvBuf.length; return TJ.bufSizeYUV(yuvWidth, yuvPad, yuvHeight, yuvSubsamp);
} }
protected long handle = 0; protected long handle = 0;

View File

@@ -159,7 +159,7 @@ for image in $IMAGES; do
done done
for xform in hflip vflip transpose transverse rot90 rot180 rot270; do for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
for samp in GRAY 444; do for samp in GRAY 444; do
runme $EXEDIR/djpeg -rgb $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg runme $EXEDIR/djpeg -rgb $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 $YUVARG runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 $YUVARG
for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
$OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do

View File

@@ -24,6 +24,9 @@ IMGDIR=@srcdir@/testimages
OUTDIR=__tjbenchtest_java_output OUTDIR=__tjbenchtest_java_output
EXEDIR=. EXEDIR=.
JAVA="@JAVA@ -cp java/turbojpeg.jar -Djava.library.path=.libs" JAVA="@JAVA@ -cp java/turbojpeg.jar -Djava.library.path=.libs"
BMPARG=
NSARG=
YUVARG=
if [ -d $OUTDIR ]; then if [ -d $OUTDIR ]; then
rm -rf $OUTDIR rm -rf $OUTDIR
@@ -32,33 +35,58 @@ mkdir -p $OUTDIR
exec >$EXEDIR/tjbenchtest-java.log exec >$EXEDIR/tjbenchtest-java.log
if [ $# -gt 0 ]; then
if [ "$1" = "-yuv" ]; then
NSARG=-nosmooth
YUVARG=-yuv
# NOTE: The combination of tjEncodeYUV*() and tjCompressFromYUV*() does not
# always produce bitwise-identical results to tjCompress*() if subsampling is
# enabled. In both cases, if the image width or height are not evenly
# divisible by the MCU width/height, then the bottom and/or right edge are
# expanded. However, the libjpeg code performs this expansion prior to
# downsampling, and TurboJPEG performs it in tjCompressFromYUV*(), which is
# after downsampling. Thus, the two will agree only if the width/height along
# each downsampled dimension is an odd number or is evenly divisible by the MCU
# width/height. This disagreement basically amounts to a round-off error, but
# there is no easy way around it, so for now, we just test the only image that
# works. (NOTE: nightshot_iso_100 does not suffer from the above issue, but
# it suffers from an unrelated problem whereby the combination of
# tjDecompressToYUV*() and tjDecodeYUV*() do not produce bitwise-identical
# results to tjDecompress*() if decompression scaling is enabled. This latter
# phenomenon is not yet fully understood but is also believed to be some sort
# of round-off error.)
IMAGES="vgl_6548_0026a.bmp"
fi
fi
# Standard tests # Standard tests
for image in $IMAGES; do for image in $IMAGES; do
cp $IMGDIR/$image $OUTDIR cp $IMGDIR/$image $OUTDIR
basename=`basename $image .bmp` basename=`basename $image .bmp`
$EXEDIR/cjpeg -quality 95 -dct fast -grayscale $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_GRAY_fast_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_420_fast_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_422_fast_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_444_fast_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct int -grayscale $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_420_accurate_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_422_accurate_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_444_accurate_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
for samp in GRAY 420 422 444; do for samp in GRAY 420 422 444; do
$EXEDIR/djpeg -rgb -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_djpeg.bmp runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_default_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
$EXEDIR/djpeg -dct fast -rgb -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_djpeg.bmp runme $EXEDIR/djpeg -dct fast -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_fast_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
$EXEDIR/djpeg -dct int -rgb -bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_djpeg.bmp runme $EXEDIR/djpeg -dct int -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
done done
for samp in 420 422; do for samp in 420 422; do
$EXEDIR/djpeg -nosmooth -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.bmp runme $EXEDIR/djpeg -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
$EXEDIR/djpeg -dct fast -nosmooth -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp runme $EXEDIR/djpeg -dct fast -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
$EXEDIR/djpeg -dct int -nosmooth -bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp runme $EXEDIR/djpeg -dct int -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
done done
# Compression # Compression
for dct in accurate fast; do for dct in accurate fast; do
runme $JAVA TJBench $OUTDIR/$image 95 -rgb -quiet -benchtime 0.01 -${dct}dct runme $JAVA TJBench $OUTDIR/$image 95 -rgb -quiet -benchtime 0.01 -warmup 0 -${dct}dct $YUVARG
for samp in GRAY 420 422 444; do for samp in GRAY 420 422 444; do
runme cmp $OUTDIR/${basename}_${samp}_Q95.jpg $OUTDIR/${basename}_${samp}_${dct}_cjpeg.jpg runme cmp $OUTDIR/${basename}_${samp}_Q95.jpg $OUTDIR/${basename}_${samp}_${dct}_cjpeg.jpg
done done
@@ -71,7 +99,7 @@ for image in $IMAGES; do
fi fi
# Tiled compression & decompression # Tiled compression & decompression
runme $JAVA TJBench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 ${dctarg} runme $JAVA TJBench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG
for samp in GRAY 444; do for samp in GRAY 444; do
for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
$OUTDIR/${basename}_${samp}_Q95_full.bmp; do $OUTDIR/${basename}_${samp}_Q95_full.bmp; do
@@ -79,7 +107,7 @@ for image in $IMAGES; do
rm $i rm $i
done done
done done
runme $JAVA TJBench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -fastupsample ${dctarg} runme $JAVA TJBench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG
for samp in 420 422; do for samp in 420 422; do
for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
$OUTDIR/${basename}_${samp}_Q95_full.bmp; do $OUTDIR/${basename}_${samp}_Q95_full.bmp; do
@@ -90,7 +118,7 @@ for image in $IMAGES; do
# Tiled decompression # Tiled decompression
for samp in GRAY 444; do for samp in GRAY 444; do
runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -tile -quiet -benchtime 0.01 ${dctarg} runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG
for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
$OUTDIR/${basename}_${samp}_Q95_full.bmp; do $OUTDIR/${basename}_${samp}_Q95_full.bmp; do
runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${dct}_djpeg.bmp runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${dct}_djpeg.bmp
@@ -98,7 +126,7 @@ for image in $IMAGES; do
done done
done done
for samp in 420 422; do for samp in 420 422; do
runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -tile -quiet -benchtime 0.01 -fastupsample ${dctarg} runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG
for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
$OUTDIR/${basename}_${samp}_Q95_full.bmp; do $OUTDIR/${basename}_${samp}_Q95_full.bmp; do
runme cmp $i -i 54:54 $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.bmp runme cmp $i -i 54:54 $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.bmp
@@ -111,8 +139,8 @@ for image in $IMAGES; do
for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do
scalearg=`echo $scale | sed s@_@/@g` scalearg=`echo $scale | sed s@_@/@g`
for samp in GRAY 420 422 444; do for samp in GRAY 420 422 444; do
$EXEDIR/djpeg -rgb -scale ${scalearg} -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG -bmp -outfile $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -scale ${scalearg} -quiet -benchtime 0.01 runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp
rm $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp rm $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp
done done
@@ -120,18 +148,18 @@ for image in $IMAGES; do
# Transforms # Transforms
for samp in GRAY 420 422 444; do for samp in GRAY 420 422 444; do
$EXEDIR/jpegtran -flip horizontal -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg runme $EXEDIR/jpegtran -flip horizontal -trim -outfile $OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
$EXEDIR/jpegtran -flip vertical -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg runme $EXEDIR/jpegtran -flip vertical -trim -outfile $OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
$EXEDIR/jpegtran -transpose -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg runme $EXEDIR/jpegtran -transpose -trim -outfile $OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
$EXEDIR/jpegtran -transverse -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg runme $EXEDIR/jpegtran -transverse -trim -outfile $OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
$EXEDIR/jpegtran -rotate 90 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg runme $EXEDIR/jpegtran -rotate 90 -trim -outfile $OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
$EXEDIR/jpegtran -rotate 180 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg runme $EXEDIR/jpegtran -rotate 180 -trim -outfile $OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
$EXEDIR/jpegtran -rotate 270 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg runme $EXEDIR/jpegtran -rotate 270 -trim -outfile $OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
done done
for xform in hflip vflip transpose transverse rot90 rot180 rot270; do for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
for samp in GRAY 444; do for samp in GRAY 444; do
$EXEDIR/djpeg -rgb -bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -warmup 0 $YUVARG
for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
$OUTDIR/${basename}_${samp}_Q95_full.bmp; do $OUTDIR/${basename}_${samp}_Q95_full.bmp; do
runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
@@ -139,8 +167,8 @@ for image in $IMAGES; do
done done
done done
for samp in 420 422; do for samp in 420 422; do
$EXEDIR/djpeg -nosmooth -rgb -bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp runme $EXEDIR/djpeg -nosmooth -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -fastupsample runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample $YUVARG
for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
$OUTDIR/${basename}_${samp}_Q95_full.bmp; do $OUTDIR/${basename}_${samp}_Q95_full.bmp; do
runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
@@ -152,7 +180,7 @@ for image in $IMAGES; do
# Grayscale transform # Grayscale transform
for xform in hflip vflip transpose transverse rot90 rot180 rot270; do for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
for samp in GRAY 444 422 420; do for samp in GRAY 444 422 420; do
runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -grayscale runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -warmup 0 -grayscale $YUVARG
for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
$OUTDIR/${basename}_${samp}_Q95_full.bmp; do $OUTDIR/${basename}_${samp}_Q95_full.bmp; do
runme cmp -i 54:54 $i $OUTDIR/${basename}_GRAY_${xform}_jpegtran.bmp runme cmp -i 54:54 $i $OUTDIR/${basename}_GRAY_${xform}_jpegtran.bmp
@@ -166,8 +194,8 @@ for image in $IMAGES; do
for samp in GRAY 444 422 420; do for samp in GRAY 444 422 420; do
for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do
scalearg=`echo $scale | sed s@_@/@g` scalearg=`echo $scale | sed s@_@/@g`
$EXEDIR/djpeg -rgb -scale ${scalearg} -bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -scale ${scalearg} -quiet -benchtime 0.01 runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp
rm $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp rm $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp
done done