From aba7ceda4f519f1ac1d5b5ec7bfc7627a812348e Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 23 Aug 2013 07:13:59 +0000 Subject: [PATCH] Oops. Forgot to implement access method for the colorspace & extend TJBench git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@1022 632fc199-4ca6-4c93-a231-07263d6284db --- java/TJBench.java | 35 ++++++++++++++----- java/doc/index-all.html | 4 +++ .../turbojpeg/TJDecompressor.html | 30 +++++++++++++++- .../libjpegturbo/turbojpeg/TJTransformer.html | 2 +- .../turbojpeg/TJDecompressor.java | 17 ++++++++- 5 files changed, 77 insertions(+), 11 deletions(-) diff --git a/java/TJBench.java b/java/TJBench.java index e5ca2f4..c4055f2 100644 --- a/java/TJBench.java +++ b/java/TJBench.java @@ -52,6 +52,10 @@ class TJBench { "444", "422", "420", "GRAY", "440", "411" }; + static final String[] csName = { + "RGB", "YCbCr", "GRAY", "CMYK", "YCCK" + }; + static TJScalingFactor sf; static int xformOp = TJTransform.OP_NONE, xformOpt = 0; static double benchTime = 5.0; @@ -62,6 +66,16 @@ class TJBench { } + static String formatName(int subsamp, int cs) { + if (cs == TJ.CS_YCbCr) + return subNameLong[subsamp]; + else if (cs == TJ.CS_YCCK) + return csName[cs] + " " + subNameLong[subsamp]; + else + return csName[cs]; + } + + static String sigFig(double val, int figs) { String format; int digitsAfterDecimal = figs - (int)Math.ceil(Math.log10(Math.abs(val))); @@ -417,7 +431,7 @@ class TJBench { byte[] srcBuf; int[] jpegSize; int totalJpegSize; - int w = 0, h = 0, subsamp = -1, _w, _h, _tilew, _tileh, + int w = 0, h = 0, subsamp = -1, cs = -1, _w, _h, _tilew, _tileh, _ntilesw, _ntilesh, _subsamp, x, y; int ntilesw = 1, ntilesh = 1; double start, elapsed; @@ -439,17 +453,22 @@ class TJBench { w = tjt.getWidth(); h = tjt.getHeight(); subsamp = tjt.getSubsamp(); + cs = tjt.getColorspace(); if (quiet == 1) { System.out.println("All performance values in Mpixels/sec\n"); - System.out.format("Bitmap\tBitmap\tJPEG\t%s %s \tXform\tComp\tDecomp\n", + System.out.format("Bitmap\tBitmap\tJPEG\tJPEG\t%s %s \tXform\tComp\tDecomp\n", (doTile ? "Tile " : "Image"), (doTile ? "Tile " : "Image")); - System.out.println("Format\tOrder\tSubsamp\tWidth Height\tPerf \tRatio\tPerf\n"); + System.out.println("Format\tOrder\tCS\tSubsamp\tWidth Height\tPerf \tRatio\tPerf\n"); } else if (quiet == 0) { - System.out.format(">>>>> JPEG %s --> %s (%s) <<<<<", - subNameLong[subsamp], pixFormatStr[pf], - (flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-up" : "Top-down"); + if (yuv == YUVDECODE) + System.out.format(">>>>> JPEG %s --> YUV <<<<<", + formatName(subsamp, cs)); + else + System.out.format(">>>>> JPEG %s --> %s (%s) <<<<<", + formatName(subsamp, cs), pixFormatStr[pf], + (flags & TJ.FLAG_BOTTOMUP) != 0 ? "Bottom-up" : "Top-down"); } for (int tilew = doTile ? 16 : w, tileh = doTile ? 16 : h; ; @@ -470,9 +489,9 @@ class TJBench { sf.getScaled(_h)); System.out.println(""); } else if (quiet == 1) { - System.out.format("%s\t%s\t%s\t", pixFormatStr[pf], + System.out.format("%s\t%s\t%s\t%s\t", pixFormatStr[pf], (flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD", - subNameLong[subsamp]); + csName[cs], subNameLong[subsamp]); System.out.format("%-4d %-4d\t", tilew, tileh); } diff --git a/java/doc/index-all.html b/java/doc/index-all.html index 876410e..4555379 100644 --- a/java/doc/index-all.html +++ b/java/doc/index-all.html @@ -262,6 +262,10 @@ Static variable in class org.libjpegturbo.turbojpeg.TJ
For the given pixel format, returns the number of bytes that the blue component is offset from the start of the pixel. +
getColorspace() - +Method in class org.libjpegturbo.turbojpeg.TJDecompressor +
Returns the colorspace used in the JPEG image associated with this + decompressor instance.
getCompressedSize() - Method in class org.libjpegturbo.turbojpeg.TJCompressor
Returns the size of the image (in bytes) generated by the most recent diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html index a3d3db5..2dc3cc6 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html @@ -358,6 +358,15 @@ TurboJPEG decompressor  int +getColorspace() + +
+          Returns the colorspace used in the JPEG image associated with this + decompressor instance. + + + + int getHeight()
@@ -656,7 +665,7 @@ public int getSubsamp() throws java.lang.Exception
Returns the level of chrominance subsampling used in the JPEG image - associated with this decompressor instance. + associated with this decompressor instance. See TJ.SAMP_*.

@@ -668,6 +677,25 @@ public int getSubsamp()

+

+getColorspace

+
+public int getColorspace()
+                  throws java.lang.Exception
+
+
Returns the colorspace used in the JPEG image associated with this + decompressor instance. See TJ.CS_*. +

+

+ +
Returns:
the colorspace used in the JPEG image associated with this + decompressor instance +
Throws: +
java.lang.Exception
+
+
+
+

getJPEGBuf

diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html b/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html
index 823fe0f..0811b51 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html
@@ -203,7 +203,7 @@ TurboJPEG lossless transformer
 Methods inherited from class org.libjpegturbo.turbojpeg.TJDecompressor
 
 
-close, decompress, decompress, decompress, decompress, decompress, decompress, decompressToYUV, decompressToYUV, decompressToYUV, decompressToYUV, finalize, getHeight, getJPEGBuf, getJPEGSize, getScaledHeight, getScaledWidth, getSubsamp, getWidth, setJPEGImage
+close, decompress, decompress, decompress, decompress, decompress, decompress, decompressToYUV, decompressToYUV, decompressToYUV, decompressToYUV, finalize, getColorspace, getHeight, getJPEGBuf, getJPEGSize, getScaledHeight, getScaledWidth, getSubsamp, getWidth, setJPEGImage
 
 
  
diff --git a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
index ad61975..d14a989 100644
--- a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
+++ b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
@@ -117,7 +117,7 @@ public class TJDecompressor {
 
   /**
    * Returns the level of chrominance subsampling used in the JPEG image
-   * associated with this decompressor instance.
+   * associated with this decompressor instance.  See {@link TJ TJ.SAMP_*}.
    *
    * @return the level of chrominance subsampling used in the JPEG image
    * associated with this decompressor instance
@@ -130,6 +130,21 @@ public class TJDecompressor {
     return jpegSubsamp;
   }
 
+  /**
+   * Returns the colorspace used in the JPEG image associated with this
+   * decompressor instance.  See {@link TJ TJ.CS_*}.
+   *
+   * @return the colorspace used in the JPEG image associated with this
+   * decompressor instance
+   */
+  public int getColorspace() throws Exception {
+    if (jpegColorspace < 0)
+      throw new Exception(NO_ASSOC_ERROR);
+    if (jpegColorspace >= TJ.NUMCS)
+      throw new Exception("JPEG header information is invalid");
+    return jpegColorspace;
+  }
+
   /**
    * Returns the JPEG image buffer associated with this decompressor instance.
    *
-- 
2.40.0