Merge branch 'main' into dev

This commit is contained in:
DRC
2023-01-20 14:09:25 -06:00
13 changed files with 144 additions and 137 deletions

View File

@@ -17,7 +17,7 @@ jobs:
run: | run: |
echo "BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" >$GITHUB_ENV echo "BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" >$GITHUB_ENV
- name: Check out code - name: Check out code
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Set up build - name: Set up build
run: | run: |
mkdir -p $HOME/src/ljt.nightly mkdir -p $HOME/src/ljt.nightly
@@ -57,7 +57,7 @@ jobs:
run: | run: |
echo "BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" >$GITHUB_ENV echo "BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" >$GITHUB_ENV
- name: Check out code - name: Check out code
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Set up build - name: Set up build
run: | run: |
brew install yasm md5sha1sum brew install yasm md5sha1sum
@@ -90,7 +90,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out code - name: Check out code
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Set up build - name: Set up build
run: | run: |
sudo apt install -y nasm sudo apt install -y nasm
@@ -113,7 +113,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out code - name: Check out code
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Set up build - name: Set up build
run: | run: |
sudo apt update sudo apt update
@@ -138,7 +138,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out code - name: Check out code
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Set up build - name: Set up build
run: | run: |
sudo apt -y install nasm sudo apt -y install nasm
@@ -162,7 +162,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out code - name: Check out code
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Build - name: Build
env: env:
CTEST_OUTPUT_ON_FAILURE: 1 CTEST_OUTPUT_ON_FAILURE: 1

View File

@@ -105,6 +105,13 @@ image dimensions.
(`-DWITH_12BIT=1`) using an alpha-enabled output color space such as (`-DWITH_12BIT=1`) using an alpha-enabled output color space such as
`JCS_EXT_RGBA`, the alpha channel was set to 255 rather than 4095. `JCS_EXT_RGBA`, the alpha channel was set to 255 rather than 4095.
8. Fixed an issue whereby the Java version of TJBench did not accept a range of
quality values.
9. Fixed an issue whereby, when `-progressive` was passed to TJBench, the JPEG
input image was not transformed into a progressive JPEG image prior to
decompression.
2.1.4 2.1.4
===== =====

View File

@@ -687,7 +687,7 @@ YUV Image Format Notes</h2>
</div><div class="memdoc"> </div><div class="memdoc">
<p>This option will enable arithmetic entropy coding in the JPEG image generated by this particular transform. </p> <p>This option will enable arithmetic entropy coding in the JPEG image generated by this particular transform. </p>
<p>Arithmetic entropy coding will generally improve compression relative to Huffman entropy coding (the default), but it will reduce compression and decompression performance considerably. Can be combined with <a class="el" href="group___turbo_j_p_e_g.html#gad2371c80674584ecc1a7d75e564cf026" title="This option will enable progressive entropy coding in the JPEG image generated by this particular tra...">TJXOPT_PROGRESSIVE</a>. </p> <p>Arithmetic entropy coding will generally improve compression relative to Huffman entropy coding (the default), but it will reduce decompression performance considerably. Can be combined with <a class="el" href="group___turbo_j_p_e_g.html#gad2371c80674584ecc1a7d75e564cf026" title="This option will enable progressive entropy coding in the JPEG image generated by this particular tra...">TJXOPT_PROGRESSIVE</a>. </p>
</div> </div>
</div> </div>
@@ -787,7 +787,7 @@ YUV Image Format Notes</h2>
</div><div class="memdoc"> </div><div class="memdoc">
<p>This option will enable progressive entropy coding in the JPEG image generated by this particular transform. </p> <p>This option will enable progressive entropy coding in the JPEG image generated by this particular transform. </p>
<p>Progressive entropy coding will generally improve compression relative to baseline entropy coding (the default), but it will reduce compression and decompression performance considerably. Can be combined with <a class="el" href="group___turbo_j_p_e_g.html#gaecaaa3b7e2af812592c015d83207f010" title="This option will enable arithmetic entropy coding in the JPEG image generated by this particular tran...">TJXOPT_ARITHMETIC</a>. </p> <p>Progressive entropy coding will generally improve compression relative to baseline entropy coding (the default), but it will reduce decompression performance considerably. Can be combined with <a class="el" href="group___turbo_j_p_e_g.html#gaecaaa3b7e2af812592c015d83207f010" title="This option will enable arithmetic entropy coding in the JPEG image generated by this particular tran...">TJXOPT_ARITHMETIC</a>. </p>
</div> </div>
</div> </div>

View File

@@ -534,7 +534,7 @@ final 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 JPEG JPEG %s %s Xform Comp Decomp ", System.out.format("Pixel JPEG JPEG %s %s Xform Comp Decomp ",
(doTile ? "Tile " : "Image"), (doTile ? "Tile " : "Image"),
(doTile ? "Tile " : "Image")); (doTile ? "Tile " : "Image"));
if (doYUV) if (doYUV)
@@ -705,42 +705,37 @@ final 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)> <Quality> [options]\n"); System.out.println(" <Inputimage (BMP)> <Quality> [options]\n");
System.out.println(" java " + className); System.out.println(" java " + className);
System.out.println(" <Inputfile (JPG)> [options]\n"); System.out.println(" <Inputimage (JPG)> [options]\n");
System.out.println("Options:\n"); System.out.println("Options:\n");
System.out.println("-alloc = Dynamically allocate JPEG image buffers"); System.out.println("-bottomup = Use bottom-up row order for packed-pixel source/destination buffers");
System.out.println("-bottomup = Test bottom-up compression/decompression"); System.out.println("-tile = Compress/transform the input image into separate JPEG tiles of varying");
System.out.println("-tile = Test performance of the codec when the image is encoded as separate"); System.out.println(" sizes (useful for measuring JPEG overhead)");
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(" Use the specified pixel format for packed-pixel source/destination buffers");
System.out.println("-fastupsample = Use the fastest chrominance upsampling algorithm available in"); System.out.println(" [default = BGR]");
System.out.println(" the underlying codec"); System.out.println("-fastupsample = Use the fastest chrominance upsampling algorithm available");
System.out.println("-fastdct = Use the fastest DCT/IDCT algorithms available in the underlying"); System.out.println("-fastdct = Use the fastest DCT/IDCT algorithm available");
System.out.println(" codec"); System.out.println("-accuratedct = Use the most accurate DCT/IDCT algorithm available");
System.out.println("-accuratedct = Use the most accurate DCT/IDCT algorithms available in the");
System.out.println(" underlying codec");
System.out.println("-progressive = Use progressive entropy coding in JPEG images generated by"); System.out.println("-progressive = Use progressive entropy coding in JPEG images generated by");
System.out.println(" compression and transform operations. (Can be combined with -arithmetic.)"); System.out.println(" compression and transform operations (can be combined with -arithmetic)");
System.out.println("-arithmetic = Use arithmetic entropy coding in JPEG images generated by"); System.out.println("-arithmetic = Use arithmetic entropy coding in JPEG images generated by");
System.out.println(" compression and transform operations. (Can be combined with"); System.out.println(" compression and transform operations (can be combined with -progressive)");
System.out.println(" -progressive.)"); System.out.println("-lossless = Generate lossless JPEG images when compressing (implies");
System.out.println("-lossless = Generate lossless JPEG images (implies -subsamp 444). When"); System.out.println(" -subsamp 444). When generating lossless JPEG images, Quality is");
System.out.println(" generating lossless JPEG images, Quality is psv * 10 + Pt, where psv is"); System.out.println(" psv * 10 + Pt, where psv is the predictor selection value (1-7) and Pt is");
System.out.println(" the predictor selection value (1-7) and Pt is the point transform (0-7)."); System.out.println(" the point transform (0-7). A point transform value of 0 is necessary in");
System.out.println(" A point transform value of 0 is necessary in order to create a fully"); System.out.println(" order to create a fully lossless JPEG image.");
System.out.println(" lossless JPEG image."); System.out.println("-subsamp <s> = When compressing, use the specified level of chrominance");
System.out.println("-subsamp <s> = When testing JPEG compression, this option specifies the level"); System.out.println(" subsampling (<s> = 444, 422, 440, 420, 411, or GRAY) [default = test");
System.out.println(" of chrominance subsampling to use (<s> = 444, 422, 440, 420, 411, or"); System.out.println(" Grayscale, 4:2:0, 4:2:2, and 4:4:4 in sequence]");
System.out.println(" GRAY). The default is to test Grayscale, 4:2:0, 4:2:2, and 4:4:4 in");
System.out.println(" sequence.");
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("-yuv = Test YUV encoding/decoding functions"); System.out.println("-yuv = Compress from/decompress to intermediate planar YUV images");
System.out.println("-yuvpad <p> = If testing YUV encoding/decoding, this specifies the number of"); System.out.println("-yuvpad <p> = The number of bytes by which each row in each plane of an");
System.out.println(" bytes by which each row of each plane in the intermediate YUV image is"); System.out.println(" intermediate YUV image is evenly divisible (must be a power of 2)");
System.out.println(" evenly divisible (default = 1)"); System.out.println(" [default = 1]");
System.out.println("-scale M/N = Scale down the width/height of the decompressed JPEG image by a"); System.out.println("-scale M/N = When decompressing, scale the width/height of the 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(),
@@ -758,24 +753,24 @@ final class TJBench {
} }
System.out.println(")"); System.out.println(")");
System.out.println("-hflip, -vflip, -transpose, -transverse, -rot90, -rot180, -rot270 ="); System.out.println("-hflip, -vflip, -transpose, -transverse, -rot90, -rot180, -rot270 =");
System.out.println(" Perform the corresponding lossless transform prior to"); System.out.println(" Perform the specified lossless transform operation on the input image");
System.out.println(" decompression (these options are mutually exclusive)"); System.out.println(" prior to decompression (these operations are mutually exclusive)");
System.out.println("-grayscale = Perform lossless grayscale conversion prior to decompression"); System.out.println("-grayscale = Transform the input image into a grayscale JPEG image prior to");
System.out.println(" test (can be combined with the other transforms above)"); System.out.println(" decompression (can be combined with the other transform operations above)");
System.out.println("-copynone = Do not copy any extra markers (including EXIF and ICC profile data)"); System.out.println("-copynone = Do not copy any extra markers (including EXIF and ICC profile data)");
System.out.println(" when transforming the image."); System.out.println(" when transforming the input image");
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("-warmup <t> = Run each benchmark for <t> seconds (default = 1.0) prior to"); System.out.println("-warmup <t> = Run each benchmark for <t> seconds [default = 1.0] prior to");
System.out.println(" starting the timer, in order to prime the caches and thus improve the"); System.out.println(" starting the timer, in order to prime the caches and thus improve the");
System.out.println(" consistency of the results."); System.out.println(" consistency of the benchmark results");
System.out.println("-componly = Stop after running compression tests. Do not test decompression."); System.out.println("-componly = Stop after running compression tests. Do not test decompression.");
System.out.println("-nowrite = Do not write reference or output images (improves consistency"); System.out.println("-nowrite = Do not write reference or output images (improves consistency of");
System.out.println(" of performance measurements.)"); System.out.println(" benchmark results)");
System.out.println("-limitscans = Refuse to decompress or transform progressive JPEG images that"); System.out.println("-limitscans = Refuse to decompress or transform progressive JPEG images that");
System.out.println(" have an unreasonably large number of scans"); System.out.println(" have an unreasonably large number of scans");
System.out.println("-stoponwarning = Immediately discontinue the current"); System.out.println("-stoponwarning = Immediately discontinue the current");
System.out.println(" compression/decompression/transform operation if the underlying codec"); System.out.println(" compression/decompression/transform operation if a warning (non-fatal");
System.out.println(" throws a warning (non-fatal error)\n"); System.out.println(" error) occurs\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);
@@ -803,18 +798,18 @@ final class TJBench {
minArg = 2; minArg = 2;
if (argv.length < minArg) if (argv.length < minArg)
usage(); usage();
String[] quals = argv[1].split("-", 2);
try { try {
minQual = Integer.parseInt(argv[1]); minQual = Integer.parseInt(quals[0]);
} catch (NumberFormatException e) {} } catch (NumberFormatException e) {}
if (minQual < 1 || minQual > 100) if (minQual < 1 || minQual > 100)
throw new Exception("Quality must be between 1 and 100."); throw new Exception("Quality must be between 1 and 100.");
int dashIndex = argv[1].indexOf('-'); if (quals.length > 1) {
if (dashIndex > 0 && argv[1].length() > dashIndex + 1) {
try { try {
maxQual = Integer.parseInt(argv[1].substring(dashIndex + 1)); maxQual = Integer.parseInt(quals[1]);
} catch (NumberFormatException e) {} } catch (NumberFormatException e) {}
} }
if (maxQual < 1 || maxQual > 100) if (maxQual < 1 || maxQual > 100 || maxQual < minQual)
maxQual = minQual; maxQual = minQual;
} }
@@ -823,7 +818,7 @@ final class TJBench {
if (argv[i].equalsIgnoreCase("-tile")) { if (argv[i].equalsIgnoreCase("-tile")) {
doTile = true; xformOpt |= TJTransform.OPT_CROP; doTile = true; xformOpt |= TJTransform.OPT_CROP;
} else if (argv[i].equalsIgnoreCase("-fastupsample")) { } else if (argv[i].equalsIgnoreCase("-fastupsample")) {
System.out.println("Using fast upsampling code\n"); System.out.println("Using fastest upsampling algorithm\n");
flags |= TJ.FLAG_FASTUPSAMPLE; flags |= TJ.FLAG_FASTUPSAMPLE;
} else if (argv[i].equalsIgnoreCase("-fastdct")) { } else if (argv[i].equalsIgnoreCase("-fastdct")) {
System.out.println("Using fastest DCT/IDCT algorithm\n"); System.out.println("Using fastest DCT/IDCT algorithm\n");
@@ -834,9 +829,11 @@ final class TJBench {
} else if (argv[i].equalsIgnoreCase("-progressive")) { } else if (argv[i].equalsIgnoreCase("-progressive")) {
System.out.println("Using progressive entropy coding\n"); System.out.println("Using progressive entropy coding\n");
flags |= TJ.FLAG_PROGRESSIVE; flags |= TJ.FLAG_PROGRESSIVE;
xformOpt |= TJTransform.OPT_PROGRESSIVE;
} else if (argv[i].equalsIgnoreCase("-arithmetic")) { } else if (argv[i].equalsIgnoreCase("-arithmetic")) {
System.out.println("Using arithmetic entropy coding\n"); System.out.println("Using arithmetic entropy coding\n");
flags |= TJ.FLAG_ARITHMETIC; flags |= TJ.FLAG_ARITHMETIC;
xformOpt |= TJTransform.OPT_ARITHMETIC;
} else if (argv[i].equalsIgnoreCase("-lossless")) { } else if (argv[i].equalsIgnoreCase("-lossless")) {
System.out.println("Using lossless JPEG\n\n"); System.out.println("Using lossless JPEG\n\n");
flags |= TJ.FLAG_LOSSLESS; flags |= TJ.FLAG_LOSSLESS;
@@ -936,8 +933,10 @@ final class TJBench {
try { try {
temp = Integer.parseInt(argv[++i]); temp = Integer.parseInt(argv[++i]);
} catch (NumberFormatException e) {} } catch (NumberFormatException e) {}
if (temp >= 1) if (temp >= 1 && (temp & (temp - 1)) == 0)
yuvAlign = temp; yuvAlign = temp;
else
usage();
} else if (argv[i].equalsIgnoreCase("-subsamp") && } else if (argv[i].equalsIgnoreCase("-subsamp") &&
i < argv.length - 1) { i < argv.length - 1) {
i++; i++;
@@ -953,6 +952,8 @@ final class TJBench {
subsamp = TJ.SAMP_420; subsamp = TJ.SAMP_420;
else if (argv[i].equals("411")) else if (argv[i].equals("411"))
subsamp = TJ.SAMP_411; subsamp = TJ.SAMP_411;
else
usage();
} else if (argv[i].equalsIgnoreCase("-componly")) } else if (argv[i].equalsIgnoreCase("-componly"))
compOnly = true; compOnly = true;
else if (argv[i].equalsIgnoreCase("-nowrite")) else if (argv[i].equalsIgnoreCase("-nowrite"))
@@ -986,7 +987,7 @@ final class TJBench {
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 JPEG JPEG %s %s ", System.out.format("Pixel JPEG JPEG %s %s ",
(doTile ? "Tile " : "Image"), (doTile ? "Tile " : "Image"),
(doTile ? "Tile " : "Image")); (doTile ? "Tile " : "Image"));
if (doYUV) if (doYUV)

View File

@@ -48,11 +48,11 @@ final class TJUnitTest {
static void usage() { static void usage() {
System.out.println("\nUSAGE: java " + CLASS_NAME + " [options]\n"); System.out.println("\nUSAGE: java " + CLASS_NAME + " [options]\n");
System.out.println("Options:"); System.out.println("Options:");
System.out.println("-yuv = test YUV encoding/decoding support"); System.out.println("-yuv = test YUV encoding/compression/decompression/decoding");
System.out.println("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest"); System.out.println("-noyuvpad = do not pad each row in each Y, U, and V plane to the nearest");
System.out.println(" multiple of 4 bytes"); System.out.println(" multiple of 4 bytes");
System.out.println("-lossless = test lossless JPEG compression/decompression"); System.out.println("-lossless = test lossless JPEG compression/decompression");
System.out.println("-bi = test BufferedImage support\n"); System.out.println("-bi = test BufferedImage I/O\n");
System.exit(1); System.exit(1);
} }

View File

@@ -608,7 +608,7 @@ implements java.io.Closeable</pre>
"tables-only") datastream of length <code>imageSize</code> bytes stored in "tables-only") datastream of length <code>imageSize</code> bytes stored in
<code>jpegImage</code> with this decompressor instance. If <code>jpegImage</code> with this decompressor instance. If
<code>jpegImage</code> contains a JPEG image, then this image will be used <code>jpegImage</code> contains a JPEG image, then this image will be used
as the source image for subsequent decompress operations. Passing a as the source image for subsequent decompression operations. Passing a
tables-only datastream to this method primes the decompressor with tables-only datastream to this method primes the decompressor with
quantization and Huffman tables that can be used when decompressing quantization and Huffman tables that can be used when decompressing
subsequent "abbreviated image" datastreams. This is useful, for instance, subsequent "abbreviated image" datastreams. This is useful, for instance,
@@ -629,8 +629,8 @@ implements java.io.Closeable</pre>
<h4>setSourceImage</h4> <h4>setSourceImage</h4>
<pre>public&nbsp;void&nbsp;setSourceImage(<a href="../../../org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg">YUVImage</a>&nbsp;srcImage)</pre> <pre>public&nbsp;void&nbsp;setSourceImage(<a href="../../../org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg">YUVImage</a>&nbsp;srcImage)</pre>
<div class="block">Associate the specified planar YUV source image with this decompressor <div class="block">Associate the specified planar YUV source image with this decompressor
instance. Subsequent decompress operations will decode this image into a instance. Subsequent decompression operations will decode this image into
packed-pixel RGB or grayscale destination image.</div> a packed-pixel RGB or grayscale destination image.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>srcImage</code> - <a href="../../../org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg"><code>YUVImage</code></a> instance containing a planar YUV source <dl><dt><span class="strong">Parameters:</span></dt><dd><code>srcImage</code> - <a href="../../../org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg"><code>YUVImage</code></a> instance containing a planar YUV source
image to be decoded. This image is not modified.</dd></dl> image to be decoded. This image is not modified.</dd></dl>
</li> </li>

View File

@@ -584,8 +584,8 @@ extends java.awt.Rectangle</pre>
<div class="block">This option will enable progressive entropy coding in the JPEG image <div class="block">This option will enable progressive entropy coding in the JPEG image
generated by this particular transform. Progressive entropy coding will generated by this particular transform. Progressive entropy coding will
generally improve compression relative to baseline entropy coding (the generally improve compression relative to baseline entropy coding (the
default), but it will reduce compression and decompression performance default), but it will reduce decompression performance considerably. Can
considerably. Can be combined with <a href="../../../org/libjpegturbo/turbojpeg/TJTransform.html#OPT_ARITHMETIC"><code>OPT_ARITHMETIC</code></a>.</div> be combined with <a href="../../../org/libjpegturbo/turbojpeg/TJTransform.html#OPT_ARITHMETIC"><code>OPT_ARITHMETIC</code></a>.</div>
<dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJTransform.OPT_PROGRESSIVE">Constant Field Values</a></dd></dl> <dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJTransform.OPT_PROGRESSIVE">Constant Field Values</a></dd></dl>
</li> </li>
</ul> </ul>
@@ -611,8 +611,8 @@ extends java.awt.Rectangle</pre>
<div class="block">This option will enable arithmetic entropy coding in the JPEG image <div class="block">This option will enable arithmetic entropy coding in the JPEG image
generated by this particular transform. Arithmetic entropy coding will generated by this particular transform. Arithmetic entropy coding will
generally improve compression relative to Huffman entropy coding (the generally improve compression relative to Huffman entropy coding (the
default), but it will reduce compression and decompression performance default), but it will reduce decompression performance considerably. Can
considerably. Can be combined with <a href="../../../org/libjpegturbo/turbojpeg/TJTransform.html#OPT_PROGRESSIVE"><code>OPT_PROGRESSIVE</code></a>.</div> be combined with <a href="../../../org/libjpegturbo/turbojpeg/TJTransform.html#OPT_PROGRESSIVE"><code>OPT_PROGRESSIVE</code></a>.</div>
<dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJTransform.OPT_ARITHMETIC">Constant Field Values</a></dd></dl> <dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJTransform.OPT_ARITHMETIC">Constant Field Values</a></dd></dl>
</li> </li>
</ul> </ul>

View File

@@ -99,7 +99,7 @@ public class TJDecompressor implements Closeable {
* "tables-only") datastream of length <code>imageSize</code> bytes stored in * "tables-only") datastream of length <code>imageSize</code> bytes stored in
* <code>jpegImage</code> with this decompressor instance. If * <code>jpegImage</code> with this decompressor instance. If
* <code>jpegImage</code> contains a JPEG image, then this image will be used * <code>jpegImage</code> contains a JPEG image, then this image will be used
* as the source image for subsequent decompress operations. Passing a * as the source image for subsequent decompression operations. Passing a
* tables-only datastream to this method primes the decompressor with * tables-only datastream to this method primes the decompressor with
* quantization and Huffman tables that can be used when decompressing * quantization and Huffman tables that can be used when decompressing
* subsequent "abbreviated image" datastreams. This is useful, for instance, * subsequent "abbreviated image" datastreams. This is useful, for instance,
@@ -124,8 +124,8 @@ public class TJDecompressor implements Closeable {
/** /**
* Associate the specified planar YUV source image with this decompressor * Associate the specified planar YUV source image with this decompressor
* instance. Subsequent decompress operations will decode this image into a * instance. Subsequent decompression operations will decode this image into
* packed-pixel RGB or grayscale destination image. * a packed-pixel RGB or grayscale destination image.
* *
* @param srcImage {@link YUVImage} instance containing a planar YUV source * @param srcImage {@link YUVImage} instance containing a planar YUV source
* image to be decoded. This image is not modified. * image to be decoded. This image is not modified.

View File

@@ -131,8 +131,8 @@ public class TJTransform extends Rectangle {
* This option will enable progressive entropy coding in the JPEG image * This option will enable progressive entropy coding in the JPEG image
* generated by this particular transform. Progressive entropy coding will * generated by this particular transform. Progressive entropy coding will
* generally improve compression relative to baseline entropy coding (the * generally improve compression relative to baseline entropy coding (the
* default), but it will reduce compression and decompression performance * default), but it will reduce decompression performance considerably. Can
* considerably. Can be combined with {@link #OPT_ARITHMETIC}. * be combined with {@link #OPT_ARITHMETIC}.
*/ */
public static final int OPT_PROGRESSIVE = (1 << 5); public static final int OPT_PROGRESSIVE = (1 << 5);
/** /**
@@ -145,8 +145,8 @@ public class TJTransform extends Rectangle {
* This option will enable arithmetic entropy coding in the JPEG image * This option will enable arithmetic entropy coding in the JPEG image
* generated by this particular transform. Arithmetic entropy coding will * generated by this particular transform. Arithmetic entropy coding will
* generally improve compression relative to Huffman entropy coding (the * generally improve compression relative to Huffman entropy coding (the
* default), but it will reduce compression and decompression performance * default), but it will reduce decompression performance considerably. Can
* considerably. Can be combined with {@link #OPT_PROGRESSIVE}. * be combined with {@link #OPT_PROGRESSIVE}.
*/ */
public static final int OPT_ARITHMETIC = (1 << 7); public static final int OPT_ARITHMETIC = (1 << 7);

103
tjbench.c
View File

@@ -278,7 +278,7 @@ static int decomp(unsigned char *srcBuf, unsigned char **jpegBuf,
qualStr, sizeStr, ext); qualStr, sizeStr, ext);
if (tjSaveImage(tempStr, dstBuf, scaledw, 0, scaledh, pf, flags) == -1) if (tjSaveImage(tempStr, dstBuf, scaledw, 0, scaledh, pf, flags) == -1)
THROW_TJG("saving bitmap"); THROW_TJG("saving output image");
ptr = strrchr(tempStr, '.'); ptr = strrchr(tempStr, '.');
SNPRINTF(ptr, 1024 - (ptr - tempStr), "-err.%s", ext); SNPRINTF(ptr, 1024 - (ptr - tempStr), "-err.%s", ext);
if (srcBuf && sf.num == 1 && sf.denom == 1) { if (srcBuf && sf.num == 1 && sf.denom == 1) {
@@ -310,7 +310,7 @@ static int decomp(unsigned char *srcBuf, unsigned char **jpegBuf,
srcBuf[pitch * row + col]); srcBuf[pitch * row + col]);
} }
if (tjSaveImage(tempStr, dstBuf, w, 0, h, pf, flags) == -1) if (tjSaveImage(tempStr, dstBuf, w, 0, h, pf, flags) == -1)
THROW_TJG("saving bitmap"); THROW_TJG("saving output image");
} }
bailout: bailout:
@@ -575,7 +575,7 @@ static int decompTest(char *fileName)
if (quiet == 1) { if (quiet == 1) {
printf("All performance values in Mpixels/sec\n\n"); printf("All performance values in Mpixels/sec\n\n");
printf("Bitmap JPEG JPEG %s %s Xform Comp Decomp ", printf("Pixel JPEG JPEG %s %s Xform Comp Decomp ",
doTile ? "Tile " : "Image", doTile ? "Tile " : "Image"); doTile ? "Tile " : "Image", doTile ? "Tile " : "Image");
if (doYUV) printf("Decode"); if (doYUV) printf("Decode");
printf("\n"); printf("\n");
@@ -757,46 +757,41 @@ static void usage(char *progName)
int i; int i;
printf("USAGE: %s\n", progName); printf("USAGE: %s\n", progName);
printf(" <Inputfile (BMP|PPM)> <Quality> [options]\n\n"); printf(" <Inputimage (BMP|PPM)> <Quality> [options]\n\n");
printf(" %s\n", progName); printf(" %s\n", progName);
printf(" <Inputfile (JPG)> [options]\n\n"); printf(" <Inputimage (JPG)> [options]\n\n");
printf("Options:\n\n"); printf("Options:\n\n");
printf("-alloc = Dynamically allocate JPEG image buffers\n"); printf("-alloc = Dynamically allocate JPEG buffers\n");
printf("-bmp = Generate output images in Windows Bitmap format (default = PPM)\n"); printf("-bmp = Use Windows Bitmap format for output images [default = PPM]\n");
printf("-bottomup = Test bottom-up compression/decompression\n"); printf("-bottomup = Use bottom-up row order for packed-pixel source/destination buffers\n");
printf("-tile = Test performance of the codec when the image is encoded as separate\n"); printf("-tile = Compress/transform the input image into separate JPEG tiles of varying\n");
printf(" tiles of varying sizes.\n"); printf(" sizes (useful for measuring JPEG overhead)\n");
printf("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb =\n"); printf("-rgb, -bgr, -rgbx, -bgrx, -xbgr, -xrgb =\n");
printf(" Test the specified color conversion path in the codec (default = BGR)\n"); printf(" Use the specified pixel format for packed-pixel source/destination buffers\n");
printf("-cmyk = Indirectly test YCCK JPEG compression/decompression (the source\n"); printf(" [default = BGR]\n");
printf(" and destination bitmaps are still RGB. The conversion is done\n"); printf("-cmyk = Indirectly test YCCK JPEG compression/decompression\n");
printf(" internally prior to compression or after decompression.)\n"); printf(" (use the CMYK pixel format for packed-pixel source/destination buffers)\n");
printf("-fastupsample = Use the fastest chrominance upsampling algorithm available in\n"); printf("-fastupsample = Use the fastest chrominance upsampling algorithm available\n");
printf(" the underlying codec\n"); printf("-fastdct = Use the fastest DCT/IDCT algorithm available\n");
printf("-fastdct = Use the fastest DCT/IDCT algorithms available in the underlying\n"); printf("-accuratedct = Use the most accurate DCT/IDCT algorithm available\n");
printf(" codec\n");
printf("-accuratedct = Use the most accurate DCT/IDCT algorithms available in the\n");
printf(" underlying codec\n");
printf("-progressive = Use progressive entropy coding in JPEG images generated by\n"); printf("-progressive = Use progressive entropy coding in JPEG images generated by\n");
printf(" compression and transform operations. (Can be combined with -arithmetic.)\n"); printf(" compression and transform operations (can be combined with -arithmetic)\n");
printf("-arithmetic = Use arithmetic entropy coding in JPEG images generated by\n"); printf("-arithmetic = Use arithmetic entropy coding in JPEG images generated by\n");
printf(" compression and transform operations. (Can be combined with\n"); printf(" compression and transform operations (can be combined with -progressive)\n");
printf(" -progressive.)\n"); printf("-lossless = Generate lossless JPEG images when compressing (implies\n");
printf("-lossless = Generate lossless JPEG images (implies -subsamp 444). When\n"); printf(" -subsamp 444). When generating lossless JPEG images, Quality is\n");
printf(" generating lossless JPEG images, Quality is psv * 10 + Pt, where psv is\n"); printf(" psv * 10 + Pt, where psv is the predictor selection value (1-7) and Pt is\n");
printf(" the predictor selection value (1-7) and Pt is the point transform (0-7).\n"); printf(" the point transform (0-7). A point transform value of 0 is necessary in\n");
printf(" A point transform value of 0 is necessary in order to create a fully\n"); printf(" order to create a fully lossless JPEG image.\n");
printf(" lossless JPEG image.\n"); printf("-subsamp <s> = When compressing, use the specified level of chrominance\n");
printf("-subsamp <s> = When testing JPEG compression, this option specifies the level\n"); printf(" subsampling (<s> = 444, 422, 440, 420, 411, or GRAY) [default = test\n");
printf(" of chrominance subsampling to use (<s> = 444, 422, 440, 420, 411, or\n"); printf(" Grayscale, 4:2:0, 4:2:2, and 4:4:4 in sequence]\n");
printf(" GRAY). The default is to test Grayscale, 4:2:0, 4:2:2, and 4:4:4 in\n");
printf(" sequence.\n");
printf("-quiet = Output results in tabular rather than verbose format\n"); printf("-quiet = Output results in tabular rather than verbose format\n");
printf("-yuv = Test YUV encoding/decoding functions\n"); printf("-yuv = Compress from/decompress to intermediate planar YUV images\n");
printf("-yuvpad <p> = If testing YUV encoding/decoding, this specifies the number of\n"); printf("-yuvpad <p> = The number of bytes by which each row in each plane of an\n");
printf(" bytes by which each row of each plane in the intermediate YUV image is\n"); printf(" intermediate YUV image is evenly divisible (must be a power of 2)\n");
printf(" evenly divisible (default = 1)\n"); printf(" [default = 1]\n");
printf("-scale M/N = Scale down the width/height of the decompressed JPEG image by a\n"); printf("-scale M/N = When decompressing, scale the width/height of the JPEG image by a\n");
printf(" factor of M/N (M/N = "); printf(" factor of M/N (M/N = ");
for (i = 0; i < nsf; i++) { for (i = 0; i < nsf; i++) {
printf("%d/%d", scalingFactors[i].num, scalingFactors[i].denom); printf("%d/%d", scalingFactors[i].num, scalingFactors[i].denom);
@@ -809,24 +804,24 @@ static void usage(char *progName)
} }
printf(")\n"); printf(")\n");
printf("-hflip, -vflip, -transpose, -transverse, -rot90, -rot180, -rot270 =\n"); printf("-hflip, -vflip, -transpose, -transverse, -rot90, -rot180, -rot270 =\n");
printf(" Perform the corresponding lossless transform prior to\n"); printf(" Perform the specified lossless transform operation on the input image\n");
printf(" decompression (these options are mutually exclusive)\n"); printf(" prior to decompression (these operations are mutually exclusive)\n");
printf("-grayscale = Perform lossless grayscale conversion prior to decompression\n"); printf("-grayscale = Transform the input image into a grayscale JPEG image prior to\n");
printf(" test (can be combined with the other transforms above)\n"); printf(" decompression (can be combined with the other transform operations above)\n");
printf("-copynone = Do not copy any extra markers (including EXIF and ICC profile data)\n"); printf("-copynone = Do not copy any extra markers (including EXIF and ICC profile data)\n");
printf(" when transforming the image.\n"); printf(" when transforming the input image\n");
printf("-benchtime <t> = Run each benchmark for at least <t> seconds (default = 5.0)\n"); printf("-benchtime <t> = Run each benchmark for at least <t> seconds [default = 5.0]\n");
printf("-warmup <t> = Run each benchmark for <t> seconds (default = 1.0) prior to\n"); printf("-warmup <t> = Run each benchmark for <t> seconds [default = 1.0] prior to\n");
printf(" starting the timer, in order to prime the caches and thus improve the\n"); printf(" starting the timer, in order to prime the caches and thus improve the\n");
printf(" consistency of the results.\n"); printf(" consistency of the benchmark results\n");
printf("-componly = Stop after running compression tests. Do not test decompression.\n"); printf("-componly = Stop after running compression tests. Do not test decompression.\n");
printf("-nowrite = Do not write reference or output images (improves consistency of\n"); printf("-nowrite = Do not write reference or output images (improves consistency of\n");
printf(" performance measurements.)\n"); printf(" benchmark results)\n");
printf("-limitscans = Refuse to decompress or transform progressive JPEG images that\n"); printf("-limitscans = Refuse to decompress or transform progressive JPEG images that\n");
printf(" have an unreasonably large number of scans\n"); printf(" have an unreasonably large number of scans\n");
printf("-stoponwarning = Immediately discontinue the current\n"); printf("-stoponwarning = Immediately discontinue the current\n");
printf(" compression/decompression/transform operation if the underlying codec\n"); printf(" compression/decompression/transform operation if a warning (non-fatal\n");
printf(" throws a warning (non-fatal error)\n\n"); printf(" error) occurs\n\n");
printf("NOTE: If the quality is specified as a range (e.g. 90-100), a separate\n"); printf("NOTE: If the quality is specified as a range (e.g. 90-100), a separate\n");
printf("test will be performed for all quality values in the range.\n\n"); printf("test will be performed for all quality values in the range.\n\n");
exit(1); exit(1);
@@ -872,7 +867,7 @@ int main(int argc, char *argv[])
if (!strcasecmp(argv[i], "-tile")) { if (!strcasecmp(argv[i], "-tile")) {
doTile = 1; xformOpt |= TJXOPT_CROP; doTile = 1; xformOpt |= TJXOPT_CROP;
} else if (!strcasecmp(argv[i], "-fastupsample")) { } else if (!strcasecmp(argv[i], "-fastupsample")) {
printf("Using fast upsampling code\n\n"); printf("Using fastest upsampling algorithm\n\n");
flags |= TJFLAG_FASTUPSAMPLE; flags |= TJFLAG_FASTUPSAMPLE;
} else if (!strcasecmp(argv[i], "-fastdct")) { } else if (!strcasecmp(argv[i], "-fastdct")) {
printf("Using fastest DCT/IDCT algorithm\n\n"); printf("Using fastest DCT/IDCT algorithm\n\n");
@@ -883,9 +878,11 @@ int main(int argc, char *argv[])
} else if (!strcasecmp(argv[i], "-progressive")) { } else if (!strcasecmp(argv[i], "-progressive")) {
printf("Using progressive entropy coding\n\n"); printf("Using progressive entropy coding\n\n");
flags |= TJFLAG_PROGRESSIVE; flags |= TJFLAG_PROGRESSIVE;
xformOpt |= TJXOPT_PROGRESSIVE;
} else if (!strcasecmp(argv[i], "-arithmetic")) { } else if (!strcasecmp(argv[i], "-arithmetic")) {
printf("Using arithmetic entropy coding\n\n"); printf("Using arithmetic entropy coding\n\n");
flags |= TJFLAG_ARITHMETIC; flags |= TJFLAG_ARITHMETIC;
xformOpt |= TJXOPT_ARITHMETIC;
} else if (!strcasecmp(argv[i], "-lossless")) { } else if (!strcasecmp(argv[i], "-lossless")) {
printf("Using lossless JPEG\n\n"); printf("Using lossless JPEG\n\n");
flags |= TJFLAG_LOSSLESS; flags |= TJFLAG_LOSSLESS;
@@ -967,7 +964,8 @@ int main(int argc, char *argv[])
} else if (!strcasecmp(argv[i], "-yuvpad") && i < argc - 1) { } else if (!strcasecmp(argv[i], "-yuvpad") && i < argc - 1) {
int tempi = atoi(argv[++i]); int tempi = atoi(argv[++i]);
if (tempi >= 1) yuvAlign = tempi; if (tempi >= 1 && (tempi & (tempi - 1)) == 0) yuvAlign = tempi;
else usage(argv[0]);
} else if (!strcasecmp(argv[i], "-subsamp") && i < argc - 1) { } else if (!strcasecmp(argv[i], "-subsamp") && i < argc - 1) {
i++; i++;
if (toupper(argv[i][0]) == 'G') subsamp = TJSAMP_GRAY; if (toupper(argv[i][0]) == 'G') subsamp = TJSAMP_GRAY;
@@ -980,6 +978,7 @@ int main(int argc, char *argv[])
case 440: subsamp = TJSAMP_440; break; case 440: subsamp = TJSAMP_440; break;
case 420: subsamp = TJSAMP_420; break; case 420: subsamp = TJSAMP_420; break;
case 411: subsamp = TJSAMP_411; break; case 411: subsamp = TJSAMP_411; break;
default: usage(argv[0]);
} }
} }
} else if (!strcasecmp(argv[i], "-componly")) } else if (!strcasecmp(argv[i], "-componly"))
@@ -1008,14 +1007,14 @@ int main(int argc, char *argv[])
if (!decompOnly) { if (!decompOnly) {
if ((srcBuf = tjLoadImage(argv[1], &w, 1, &h, &pf, flags)) == NULL) if ((srcBuf = tjLoadImage(argv[1], &w, 1, &h, &pf, flags)) == NULL)
THROW_TJG("loading bitmap"); THROW_TJG("loading input image");
temp = strrchr(argv[1], '.'); temp = strrchr(argv[1], '.');
if (temp != NULL) *temp = '\0'; if (temp != NULL) *temp = '\0';
} }
if (quiet == 1 && !decompOnly) { if (quiet == 1 && !decompOnly) {
printf("All performance values in Mpixels/sec\n\n"); printf("All performance values in Mpixels/sec\n\n");
printf("Bitmap JPEG JPEG %s %s ", printf("Pixel JPEG JPEG %s %s ",
doTile ? "Tile " : "Image", doTile ? "Tile " : "Image"); doTile ? "Tile " : "Image", doTile ? "Tile " : "Image");
if (doYUV) printf("Encode "); if (doYUV) printf("Encode ");
printf("Comp Comp Decomp "); printf("Comp Comp Decomp ");

View File

@@ -55,12 +55,12 @@ static void usage(char *progName)
{ {
printf("\nUSAGE: %s [options]\n\n", progName); printf("\nUSAGE: %s [options]\n\n", progName);
printf("Options:\n"); printf("Options:\n");
printf("-yuv = test YUV encoding/decoding support\n"); printf("-yuv = test YUV encoding/compression/decompression/decoding\n");
printf("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest\n"); printf("-noyuvpad = do not pad each row in each Y, U, and V plane to the nearest\n");
printf(" multiple of 4 bytes\n"); printf(" multiple of 4 bytes\n");
printf("-lossless = test lossless JPEG compression/decompression\n"); printf("-lossless = test lossless JPEG compression/decompression\n");
printf("-alloc = test automatic buffer allocation\n"); printf("-alloc = test automatic JPEG buffer allocation\n");
printf("-bmp = tjLoadImage()/tjSaveImage() unit test\n\n"); printf("-bmp = test packed-pixel image I/O\n");
exit(1); exit(1);
} }

View File

@@ -2204,7 +2204,7 @@ DLLEXPORT unsigned char *tjLoadImage(const char *filename, int *width,
invert = (flags & TJFLAG_BOTTOMUP) == 0; invert = (flags & TJFLAG_BOTTOMUP) == 0;
} else if (tempc == 'P') { } else if (tempc == 'P') {
if ((src = jinit_read_ppm(cinfo)) == NULL) if ((src = jinit_read_ppm(cinfo)) == NULL)
THROWG("tjLoadImage(): Could not initialize bitmap loader"); THROWG("tjLoadImage(): Could not initialize PPM loader");
invert = (flags & TJFLAG_BOTTOMUP) != 0; invert = (flags & TJFLAG_BOTTOMUP) != 0;
} else } else
THROWG("tjLoadImage(): Unsupported file type"); THROWG("tjLoadImage(): Unsupported file type");

View File

@@ -574,8 +574,8 @@ enum TJXOP {
* This option will enable progressive entropy coding in the JPEG image * This option will enable progressive entropy coding in the JPEG image
* generated by this particular transform. Progressive entropy coding will * generated by this particular transform. Progressive entropy coding will
* generally improve compression relative to baseline entropy coding (the * generally improve compression relative to baseline entropy coding (the
* default), but it will reduce compression and decompression performance * default), but it will reduce decompression performance considerably. Can be
* considerably. Can be combined with #TJXOPT_ARITHMETIC. * combined with #TJXOPT_ARITHMETIC.
*/ */
#define TJXOPT_PROGRESSIVE (1 << 5) #define TJXOPT_PROGRESSIVE (1 << 5)
/** /**
@@ -588,8 +588,8 @@ enum TJXOP {
* This option will enable arithmetic entropy coding in the JPEG image * This option will enable arithmetic entropy coding in the JPEG image
* generated by this particular transform. Arithmetic entropy coding will * generated by this particular transform. Arithmetic entropy coding will
* generally improve compression relative to Huffman entropy coding (the * generally improve compression relative to Huffman entropy coding (the
* default), but it will reduce compression and decompression performance * default), but it will reduce decompression performance considerably. Can be
* considerably. Can be combined with #TJXOPT_PROGRESSIVE. * combined with #TJXOPT_PROGRESSIVE.
*/ */
#define TJXOPT_ARITHMETIC (1 << 7) #define TJXOPT_ARITHMETIC (1 << 7)