]> granicus.if.org Git - libjpeg-turbo/commitdiff
Extend the TurboJPEG Java API to support generating YUV images with arbitrary padding...
authorDRC <dcommander@users.sourceforge.net>
Sun, 28 Apr 2013 01:32:52 +0000 (01:32 +0000)
committerDRC <dcommander@users.sourceforge.net>
Sun, 28 Apr 2013 01:32:52 +0000 (01:32 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@975 632fc199-4ca6-4c93-a231-07263d6284db

31 files changed:
CMakeLists.txt
Makefile.am
java/TJUnitTest.java
java/doc/allclasses-frame.html
java/doc/allclasses-noframe.html
java/doc/constant-values.html
java/doc/deprecated-list.html
java/doc/help-doc.html
java/doc/index-all.html
java/doc/index.html
java/doc/org/libjpegturbo/turbojpeg/TJ.html
java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html
java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html
java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html
java/doc/org/libjpegturbo/turbojpeg/TJTransform.html
java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html
java/doc/org/libjpegturbo/turbojpeg/package-frame.html
java/doc/org/libjpegturbo/turbojpeg/package-summary.html
java/doc/org/libjpegturbo/turbojpeg/package-tree.html
java/doc/overview-tree.html
java/doc/serialized-form.html
java/org/libjpegturbo/turbojpeg/TJ.java
java/org/libjpegturbo/turbojpeg/TJCompressor.java
java/org/libjpegturbo/turbojpeg/TJDecompressor.java
java/org_libjpegturbo_turbojpeg_TJ.h
java/org_libjpegturbo_turbojpeg_TJCompressor.h
java/org_libjpegturbo_turbojpeg_TJDecompressor.h
tjunittest.c
turbojpeg-jni.c
turbojpeg-mapfile.jni

index ffffebb21f2c0d7e63d1f9460fea28dca08f6e60..495ac2d8bc1afb37a104d1d9c1ee87ec904f6f2b 100644 (file)
@@ -314,8 +314,10 @@ set(MD5_JPEG_CROP b4197f377e621c4e9b1d20471432610d)
 if(WITH_JAVA)
 add_test(TJUnitTest ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest)
 add_test(TJUnitTest-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -yuv)
+add_test(TJUnitTest-yuv-nopad ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -yuv -noyuvpad)
 add_test(TJUnitTest-bi ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi)
 add_test(TJUnitTest-bi-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi -yuv)
+add_test(TJUnitTest-bi-yuv-nopad ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi -yuv -noyuvpad)
 endif()
 add_test(tjunittest tjunittest)
 add_test(tjunittest-alloc tjunittest -alloc)
index dab99b405bedf07ea03a63a073854d72b9ae49c6..de6c3073654b164fd0a85300c88e73fdf646cb5e 100644 (file)
@@ -200,7 +200,9 @@ if WITH_JAVA
        $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest
        $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -bi
        $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -yuv
+       $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -yuv -noyuvpad
        $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -yuv -bi
+       $(JAVA) -cp java/turbojpeg.jar -Djava.library.path=.libs TJUnitTest -yuv -bi -noyuvpad
 endif
        ./tjunittest
        ./tjunittest -alloc
index d0a609a937477197ffc8376fbac57b435e372099..4b1a52d903cfa1211c293e23b8fb29874387c161 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C)2011-2012 D. R. Commander.  All Rights Reserved.
+ * Copyright (C)2011-2013 D. R. Commander.  All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -46,6 +46,8 @@ public class TJUnitTest {
     System.out.println("\nUSAGE: java " + classname + " [options]\n");
     System.out.println("Options:\n");
     System.out.println("-yuv = test YUV encoding/decoding support\n");
+    System.out.println("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest\n");
+    System.out.println("            4-byte boundary\n");
     System.out.println("-bi = test BufferedImage support\n");
     System.exit(1);
   }
@@ -93,6 +95,7 @@ public class TJUnitTest {
   private static final int YUVENCODE = 1;
   private static final int YUVDECODE = 2;
   private static int yuv = 0;
+  private static int pad = 4;
   private static boolean bi = false;
 
   private static int exitStatus = 0;
@@ -472,16 +475,18 @@ public class TJUnitTest {
   }
 
   private static int checkBufYUV(byte[] buf, int size, int w, int h,
-                                 int subsamp) throws Exception {
+                                 int subsamp, TJScalingFactor sf)
+                                 throws Exception {
     int row, col;
     int hsf = TJ.getMCUWidth(subsamp) / 8, vsf = TJ.getMCUHeight(subsamp) / 8;
     int pw = PAD(w, hsf), ph = PAD(h, vsf);
     int cw = pw / hsf, ch = ph / vsf;
-    int ypitch = PAD(pw, 4), uvpitch = PAD(cw, 4);
+    int ypitch = PAD(pw, pad), uvpitch = PAD(cw, pad);
     int retval = 1;
     int correctsize = ypitch * ph +
                       (subsamp == TJ.SAMP_GRAY ? 0 : uvpitch * ch * 2);
-    int halfway = 16;
+    int halfway = 16 * sf.getNum() / sf.getDenom();
+    int blockSize = 8 * sf.getNum() / sf.getDenom();
 
     try {
       if (size != correctsize)
@@ -491,7 +496,7 @@ public class TJUnitTest {
       for (row = 0; row < ph; row++) {
         for (col = 0; col < pw; col++) {
           byte y = buf[ypitch * row + col];
-          if (((row / 8) + (col / 8)) % 2 == 0) {
+          if (((row / blockSize) + (col / blockSize)) % 2 == 0) {
             if (row < halfway)
               checkVal255(row, col, y, "Y");
             else
@@ -505,12 +510,12 @@ public class TJUnitTest {
         }
       }
       if (subsamp != TJ.SAMP_GRAY) {
-        halfway = 16 / vsf;
+        halfway = 16 / vsf * sf.getNum() / sf.getDenom();
         for (row = 0; row < ch; row++) {
           for (col = 0; col < cw; col++) {
             byte u = buf[ypitch * ph + (uvpitch * row + col)],
                  v = buf[ypitch * ph + uvpitch * ch + (uvpitch * row + col)];
-            if (((row * vsf / 8) + (col * hsf / 8)) % 2 == 0) {
+            if (((row * vsf / blockSize) + (col * hsf / blockSize)) % 2 == 0) {
               checkVal(row, col, u, "U", 128);
               checkVal(row, col, v, "V", 128);
             } else {
@@ -618,6 +623,7 @@ public class TJUnitTest {
     t = getTime();
     tjc.setSubsamp(subsamp);
     tjc.setJPEGQuality(jpegQual);
+    tjc.setYUVPad(pad);
     if (bi) {
       if (yuv == YUVENCODE)
         tjc.encodeYUV(img, dstBuf, flags);
@@ -644,7 +650,8 @@ public class TJUnitTest {
     writeJPEG(dstBuf, size, tempstr);
 
     if (yuv == YUVENCODE) {
-      if (checkBufYUV(dstBuf, size, w, h, subsamp) == 1)
+      if (checkBufYUV(dstBuf, size, w, h, subsamp,
+                      new TJScalingFactor(1, 1)) == 1)
         System.out.print("Passed.");
       else {
         System.out.print("FAILED!");
@@ -680,7 +687,7 @@ public class TJUnitTest {
 
     System.out.print("JPEG -> ");
     if (yuv == YUVDECODE)
-      System.out.print("YUV " + subName[subsamp] + " ... ");
+      System.out.print("YUV " + subNameLong[subsamp] + " ");
     else {
       System.out.print(pfStr + " ");
       if (bi)
@@ -689,11 +696,11 @@ public class TJUnitTest {
         System.out.print("Bottom-Up ");
       else
         System.out.print("Top-Down  ");
-      if (!sf.isOne())
-        System.out.print(sf.getNum() + "/" + sf.getDenom() + " ... ");
-      else
-        System.out.print("... ");
     }
+    if (!sf.isOne())
+      System.out.print(sf.getNum() + "/" + sf.getDenom() + " ... ");
+    else
+      System.out.print("... ");
 
     t = getTime();
     tjd.setJPEGImage(jpegBuf, jpegSize);
@@ -709,7 +716,7 @@ public class TJUnitTest {
       throw new Exception("Scaled size mismatch");
 
     if (yuv == YUVDECODE)
-      dstBuf = tjd.decompressToYUV(flags);
+      dstBuf = tjd.decompressToYUV(scaledWidth, pad, scaledHeight, flags);
     else {
       if (bi)
         img = tjd.decompress(scaledWidth, scaledHeight, imgType, flags);
@@ -728,7 +735,8 @@ public class TJUnitTest {
     }
 
     if (yuv == YUVDECODE) {
-      if (checkBufYUV(dstBuf, dstBuf.length, w, h, subsamp) == 1)
+      if (checkBufYUV(dstBuf, dstBuf.length, scaledWidth, scaledHeight,
+                      subsamp, sf) == 1)
         System.out.print("Passed.");
       else {
         System.out.print("FAILED!");  exitStatus = -1;
@@ -752,7 +760,7 @@ public class TJUnitTest {
                                  String baseName, int subsamp,
                                  int flags) throws Exception {
     int i;
-    if ((subsamp == TJ.SAMP_444 || subsamp == TJ.SAMP_GRAY) && yuv == 0) {
+    if (subsamp == TJ.SAMP_444 || subsamp == TJ.SAMP_GRAY) {
       TJScalingFactor[] sf = TJ.getScalingFactors();
       for (i = 0; i < sf.length; i++)
         decompTest(tjd, jpegBuf, jpegSize, w, h, pf, baseName, subsamp,
@@ -771,7 +779,7 @@ public class TJUnitTest {
     byte[] dstBuf;
 
     if (yuv == YUVENCODE)
-      dstBuf = new byte[TJ.bufSizeYUV(w, h, subsamp)];
+      dstBuf = new byte[TJ.bufSizeYUV(w, pad, h, subsamp)];
     else
       dstBuf = new byte[TJ.bufSize(w, h, subsamp)];
 
@@ -860,6 +868,8 @@ public class TJUnitTest {
       for (int i = 0; i < argv.length; i++) {
         if (argv[i].equalsIgnoreCase("-yuv"))
           doyuv = true;
+        if (argv[i].equalsIgnoreCase("-noyuvpad"))
+          pad = 1;
         if (argv[i].substring(0, 1).equalsIgnoreCase("-h") ||
             argv[i].equalsIgnoreCase("-?"))
           usage();
index c02463d0227779b5e0309bf593db84df793f0321..3ee3e6fd2cfe01900debcd4872a559e9659d0ef1 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 All Classes
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
index 1f134aa67cc9b27400a772ba85970485d2a75a08..249acfb530b76b09f649fec56ff80d81ef4cf7ae 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 All Classes
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
index 5c6ab692de0fb7c66da02366f0cd5f0b750db992..3978d1994def17fd767d693fb6924c5ed41922dc 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 Constant Field Values
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
index a19b0267139d15c908b1c2492b60393d07dddb5f..9a7315942548b10ac38764c75dd3c0413965e0da 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 Deprecated List
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
@@ -93,12 +93,28 @@ function windowTitle()
 <B>Deprecated Methods</B></FONT></TH>
 </TR>
 <TR BGCOLOR="white" CLASS="TableRowColor">
+<TD><A HREF="org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int)">org.libjpegturbo.turbojpeg.TJ.bufSizeYUV(int, int, int)</A>
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I>Use <A HREF="org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int, int)"><CODE>TJ.bufSizeYUV(int, int, int, int)</CODE></A> instead.</I>&nbsp;</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
 <TD><A HREF="org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int)">org.libjpegturbo.turbojpeg.TJDecompressor.decompress(byte[], int, int, int, int, int)</A>
 <BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I>Use
  <A HREF="org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)"><CODE>TJDecompressor.decompress(byte[], int, int, int, int, int, int, int)</CODE></A> instead.</I>&nbsp;</TD>
 </TR>
 <TR BGCOLOR="white" CLASS="TableRowColor">
+<TD><A HREF="org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int)">org.libjpegturbo.turbojpeg.TJDecompressor.decompressToYUV(byte[], int)</A>
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I>Use <A HREF="org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int, int, int, int)"><CODE>TJDecompressor.decompressToYUV(byte[], int, int, int, int)</CODE></A>
+ instead.</I>&nbsp;</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD><A HREF="org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int)">org.libjpegturbo.turbojpeg.TJDecompressor.decompressToYUV(int)</A>
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I>Use <A HREF="org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int, int, int, int)"><CODE>TJDecompressor.decompressToYUV(int, int, int, int)</CODE></A> instead.</I>&nbsp;</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
 <TD><A HREF="org/libjpegturbo/turbojpeg/TJCompressor.html#setSourceImage(byte[], int, int, int, int)">org.libjpegturbo.turbojpeg.TJCompressor.setSourceImage(byte[], int, int, int, int)</A>
 <BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<I>Use
index 7fb7c4414f88bebd3cc92266e31e7066cd8f98f7..ebffee078d9b70ffd19f1dd44ff51c924b00d115 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:35 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 API Help
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
index 36435a71a80d0edbe7a3854952f31a41671492f8..820876fa2afff43f8b8d2ecbc65b0f1d515e4207 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 Index
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="./stylesheet.css" TITLE="Style">
 
@@ -84,10 +84,13 @@ function windowTitle()
 Static method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A>
 <DD>Returns the maximum size of the buffer (in bytes) required to hold a JPEG
  image with the given width, height, and level of chrominance subsampling.
-<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int)"><B>bufSizeYUV(int, int, int)</B></A> - 
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int, int)"><B>bufSizeYUV(int, int, int, int)</B></A> - 
 Static method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A>
 <DD>Returns the size of the buffer (in bytes) required to hold a YUV planar
  image with the given width, height, and level of chrominance subsampling.
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int)"><B>bufSizeYUV(int, int, int)</B></A> - 
+Static method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</A>
+<DD><B>Deprecated.</B>&nbsp;<I>Use <A HREF="./org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int, int)"><CODE>TJ.bufSizeYUV(int, int, int, int)</CODE></A> instead.</I>
 </DL>
 <HR>
 <A NAME="_C_"><!-- --></A><H2>
@@ -154,14 +157,21 @@ Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg
 <DD>Decompress the JPEG source image associated with this decompressor
  instance and return a <code>BufferedImage</code> instance containing the
  decompressed image.
-<DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int)"><B>decompressToYUV(byte[], int)</B></A> - 
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int, int, int, int)"><B>decompressToYUV(byte[], int, int, int, int)</B></A> - 
 Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A>
 <DD>Decompress the JPEG source image associated with this decompressor
  instance and output a YUV planar image to the given destination buffer.
-<DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int)"><B>decompressToYUV(int)</B></A> - 
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int)"><B>decompressToYUV(byte[], int)</B></A> - 
+Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A>
+<DD><B>Deprecated.</B>&nbsp;<I>Use <A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int, int, int, int)"><CODE>TJDecompressor.decompressToYUV(byte[], int, int, int, int)</CODE></A>
+ instead.</I>
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int, int, int, int)"><B>decompressToYUV(int, int, int, int)</B></A> - 
 Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A>
 <DD>Decompress the JPEG source image associated with this decompressor
  instance and return a buffer containing a YUV planar image.
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int)"><B>decompressToYUV(int)</B></A> - 
+Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A>
+<DD><B>Deprecated.</B>&nbsp;<I>Use <A HREF="./org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int, int, int, int)"><CODE>TJDecompressor.decompressToYUV(int, int, int, int)</CODE></A> instead.</I>
 </DL>
 <HR>
 <A NAME="_E_"><!-- --></A><H2>
@@ -490,6 +500,9 @@ Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg
 Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg">TJCompressor</A>
 <DD>Set the level of chrominance subsampling for subsequent compress/encode
  operations.
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJCompressor.html#setYUVPad(int)"><B>setYUVPad(int)</B></A> - 
+Method in class org.libjpegturbo.turbojpeg.<A HREF="./org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg">TJCompressor</A>
+<DD>Set the plane padding for subsequent YUV encode operations.
 </DL>
 <HR>
 <A NAME="_T_"><!-- --></A><H2>
index f187a87e13377caf93a9d51ef5097ba456f3ed68..d55584876009b278018301413095bee5d509581f 100644 (file)
@@ -2,7 +2,7 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc on Fri Apr 26 20:05:34 CDT 2013-->
+<!-- Generated by javadoc on Sat Apr 27 20:13:12 CDT 2013-->
 <TITLE>
 Generated Documentation (Untitled)
 </TITLE>
index 2a11b78f0acb8651528582f9f9a73a0ab8f6330d..3103cd4152438a10985409edbd7e527487ad5b25 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:33 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:11 CDT 2013 -->
 <TITLE>
 TJ
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
@@ -374,6 +374,17 @@ TurboJPEG utility class (cannot be instantiated)
            int&nbsp;height,
            int&nbsp;subsamp)</CODE>
 
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Deprecated.</B>&nbsp;<I>Use <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int, int)"><CODE>bufSizeYUV(int, int, int, int)</CODE></A> instead.</I></TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>static&nbsp;int</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int, int)">bufSizeYUV</A></B>(int&nbsp;width,
+           int&nbsp;pad,
+           int&nbsp;height,
+           int&nbsp;subsamp)</CODE>
+
 <BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the size of the buffer (in bytes) required to hold a YUV planar
  image with the given width, height, and level of chrominance subsampling.</TD>
@@ -992,10 +1003,11 @@ public static int <B>bufSize</B>(int&nbsp;width,
 </DL>
 <HR>
 
-<A NAME="bufSizeYUV(int, int, int)"><!-- --></A><H3>
+<A NAME="bufSizeYUV(int, int, int, int)"><!-- --></A><H3>
 bufSizeYUV</H3>
 <PRE>
 public static int <B>bufSizeYUV</B>(int&nbsp;width,
+                             int&nbsp;pad,
                              int&nbsp;height,
                              int&nbsp;subsamp)
                       throws java.lang.Exception</PRE>
@@ -1004,7 +1016,9 @@ public static int <B>bufSizeYUV</B>(int&nbsp;width,
  image with the given width, height, and level of chrominance subsampling.
 <P>
 <DD><DL>
-<DT><B>Parameters:</B><DD><CODE>width</CODE> - the width (in pixels) of the YUV image<DD><CODE>height</CODE> - the height (in pixels) of the YUV image<DD><CODE>subsamp</CODE> - the level of chrominance subsampling used in the YUV
+<DT><B>Parameters:</B><DD><CODE>width</CODE> - the width (in pixels) of the YUV image<DD><CODE>pad</CODE> - the width of each line in each plane of the image is padded to
+        the nearest multiple of this number of bytes (must be a power of
+        2.)<DD><CODE>height</CODE> - the height (in pixels) of the YUV image<DD><CODE>subsamp</CODE> - the level of chrominance subsampling used in the YUV
  image (one of <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.SAMP_*</CODE></A>)
 <DT><B>Returns:</B><DD>the size of the buffer (in bytes) required to hold a YUV planar
  image with the given width, height, and level of chrominance subsampling
@@ -1014,6 +1028,25 @@ public static int <B>bufSizeYUV</B>(int&nbsp;width,
 </DL>
 <HR>
 
+<A NAME="bufSizeYUV(int, int, int)"><!-- --></A><H3>
+bufSizeYUV</H3>
+<PRE>
+<FONT SIZE="-1">@Deprecated
+</FONT>public static int <B>bufSizeYUV</B>(int&nbsp;width,
+                                        int&nbsp;height,
+                                        int&nbsp;subsamp)
+                      throws java.lang.Exception</PRE>
+<DL>
+<DD><B>Deprecated.</B>&nbsp;<I>Use <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int, int)"><CODE>bufSizeYUV(int, int, int, int)</CODE></A> instead.</I>
+<P>
+<DD><DL>
+
+<DT><B>Throws:</B>
+<DD><CODE>java.lang.Exception</CODE></DL>
+</DD>
+</DL>
+<HR>
+
 <A NAME="getScalingFactors()"><!-- --></A><H3>
 getScalingFactors</H3>
 <PRE>
index 871d9bc534f4f2b5ea4bd0f1201d55a305a92eb9..ee829c8890f0ce1e0a31f81cbaab5421b1bfd7f5 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 TJCompressor
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
@@ -306,6 +306,14 @@ TurboJPEG compressor
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set the level of chrominance subsampling for subsequent compress/encode
  operations.</TD>
 </TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;void</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJCompressor.html#setYUVPad(int)">setYUVPad</A></B>(int&nbsp;pad)</CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set the plane padding for subsequent YUV encode operations.</TD>
+</TR>
 </TABLE>
 &nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
@@ -437,11 +445,12 @@ public void <B>setSourceImage</B>(byte[]&nbsp;srcImage,
 <A NAME="setSourceImage(byte[], int, int, int, int)"><!-- --></A><H3>
 setSourceImage</H3>
 <PRE>
-public void <B>setSourceImage</B>(byte[]&nbsp;srcImage,
-                           int&nbsp;width,
-                           int&nbsp;pitch,
-                           int&nbsp;height,
-                           int&nbsp;pixelFormat)
+<FONT SIZE="-1">@Deprecated
+</FONT>public void <B>setSourceImage</B>(byte[]&nbsp;srcImage,
+                                      int&nbsp;width,
+                                      int&nbsp;pitch,
+                                      int&nbsp;height,
+                                      int&nbsp;pixelFormat)
                     throws java.lang.Exception</PRE>
 <DL>
 <DD><B>Deprecated.</B>&nbsp;<I>Use
@@ -572,6 +581,25 @@ public byte[] <B>compress</B>(java.awt.image.BufferedImage&nbsp;srcImage,
 </DL>
 <HR>
 
+<A NAME="setYUVPad(int)"><!-- --></A><H3>
+setYUVPad</H3>
+<PRE>
+public void <B>setYUVPad</B>(int&nbsp;pad)
+               throws java.lang.Exception</PRE>
+<DL>
+<DD>Set the plane padding for subsequent YUV encode operations.
+<P>
+<DD><DL>
+<DT><B>Parameters:</B><DD><CODE>pad</CODE> - the width of each line in each plane of the YUV image will be
+        padded to the nearest multiple of this number of bytes (must be a
+        power of 2.)  The default padding is 4 bytes, which generates
+        images suitable for direct video display.
+<DT><B>Throws:</B>
+<DD><CODE>java.lang.Exception</CODE></DL>
+</DD>
+</DL>
+<HR>
+
 <A NAME="encodeYUV(byte[], int)"><!-- --></A><H3>
 encodeYUV</H3>
 <PRE>
@@ -581,21 +609,20 @@ public void <B>encodeYUV</B>(byte[]&nbsp;dstBuf,
 <DL>
 <DD>Encode the uncompressed source image associated with this compressor
  instance and output a YUV planar image to the given destination buffer.
- This method uses the accelerated color conversion routines in
- TurboJPEG's underlying codec to produce a planar YUV image that is
- suitable for direct video display.  Specifically, if the chrominance
- components are subsampled along the horizontal dimension, then the width
- of the luminance plane is padded to the nearest multiple of 2 in the
- output image (same goes for the height of the luminance plane, if the
- chrominance components are subsampled along the vertical dimension.)
- Also, each line of each plane in the output image is padded to 4 bytes.
- Although this will work with any subsampling option, it is really only
- useful in combination with <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#SAMP_420"><CODE>TJ.SAMP_420</CODE></A>, which produces an image
- compatible with the I420 (AKA "YUV420P") format.
+ This method uses the accelerated color conversion routines in TurboJPEG's
+ underlying codec but does not execute any of the other steps in the JPEG
+ compression process.  The Y, U, and V image planes are stored sequentially
+ into the destination buffer, and the size of each plane is determined by
+ the width and height of the source image, as well as the specified padding
+ and level of chrominance subsampling.  If the chrominance components are
+ subsampled along the horizontal dimension, then the width of the luminance
+ plane is padded to the nearest multiple of 2 in the output image (same
+ goes for the height of the luminance plane, if the chrominance components
+ are subsampled along the vertical dimension.)
 <P>
 <DD><DL>
 <DT><B>Parameters:</B><DD><CODE>dstBuf</CODE> - buffer that will receive the YUV planar image.  Use
- <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int)"><CODE>TJ.bufSizeYUV(int, int, int)</CODE></A> to determine the appropriate size for this buffer
+ <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 size for this buffer
  based on the image width, height, and level of chrominance subsampling.<DD><CODE>flags</CODE> - the bitwise OR of one or more of <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.FLAG_*</CODE></A>
 <DT><B>Throws:</B>
 <DD><CODE>java.lang.Exception</CODE></DL>
@@ -637,7 +664,7 @@ public void <B>encodeYUV</B>(java.awt.image.BufferedImage&nbsp;srcImage,
 <DD><DL>
 <DT><B>Parameters:</B><DD><CODE>srcImage</CODE> - a <code>BufferedImage</code> instance containing RGB or
  grayscale pixels to be encoded<DD><CODE>dstBuf</CODE> - buffer that will receive the YUV planar image.  Use
- <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int)"><CODE>TJ.bufSizeYUV(int, int, int)</CODE></A> to determine the appropriate size for this buffer
+ <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 size for this buffer
  based on the image width, height, and level of chrominance subsampling.<DD><CODE>flags</CODE> - the bitwise OR of one or more of <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.FLAG_*</CODE></A>
 <DT><B>Throws:</B>
 <DD><CODE>java.lang.Exception</CODE></DL>
index c91978d56903b89aaa64afa1b7cfe69bc5098643..350d63659d03023286dd61c6259afd45db78a6cb 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 TJCustomFilter
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
index d7c6495e2513b9be6216fcaf2273ede4aba197e1..013c05423c95cf3b8f5eadcec9fa6c2a4938ff42 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 TJDecompressor
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
@@ -304,6 +304,19 @@ TurboJPEG decompressor
 <TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int)">decompressToYUV</A></B>(byte[]&nbsp;dstBuf,
                 int&nbsp;flags)</CODE>
 
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Deprecated.</B>&nbsp;<I>Use <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int, int, int, int)"><CODE>decompressToYUV(byte[], int, int, int, int)</CODE></A>
+ instead.</I></TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;void</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int, int, int, int)">decompressToYUV</A></B>(byte[]&nbsp;dstBuf,
+                int&nbsp;desiredWidth,
+                int&nbsp;pad,
+                int&nbsp;desiredHeight,
+                int&nbsp;flags)</CODE>
+
 <BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Decompress the JPEG source image associated with this decompressor
  instance and output a YUV planar image to the given destination buffer.</TD>
@@ -313,6 +326,17 @@ TurboJPEG decompressor
 <CODE>&nbsp;byte[]</CODE></FONT></TD>
 <TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int)">decompressToYUV</A></B>(int&nbsp;flags)</CODE>
 
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Deprecated.</B>&nbsp;<I>Use <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int, int, int, int)"><CODE>decompressToYUV(int, int, int, int)</CODE></A> instead.</I></TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;byte[]</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int, int, int, int)">decompressToYUV</A></B>(int&nbsp;desiredWidth,
+                int&nbsp;pad,
+                int&nbsp;desiredHeight,
+                int&nbsp;flags)</CODE>
+
 <BR>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Decompress the JPEG source image associated with this decompressor
  instance and return a buffer containing a YUV planar image.</TD>
@@ -779,12 +803,13 @@ public void <B>decompress</B>(byte[]&nbsp;dstBuf,
 <A NAME="decompress(byte[], int, int, int, int, int)"><!-- --></A><H3>
 decompress</H3>
 <PRE>
-public void <B>decompress</B>(byte[]&nbsp;dstBuf,
-                       int&nbsp;desiredWidth,
-                       int&nbsp;pitch,
-                       int&nbsp;desiredHeight,
-                       int&nbsp;pixelFormat,
-                       int&nbsp;flags)
+<FONT SIZE="-1">@Deprecated
+</FONT>public void <B>decompress</B>(byte[]&nbsp;dstBuf,
+                                  int&nbsp;desiredWidth,
+                                  int&nbsp;pitch,
+                                  int&nbsp;desiredHeight,
+                                  int&nbsp;pixelFormat,
+                                  int&nbsp;flags)
                 throws java.lang.Exception</PRE>
 <DL>
 <DD><B>Deprecated.</B>&nbsp;<I>Use
@@ -827,10 +852,13 @@ public byte[] <B>decompress</B>(int&nbsp;desiredWidth,
 </DL>
 <HR>
 
-<A NAME="decompressToYUV(byte[], int)"><!-- --></A><H3>
+<A NAME="decompressToYUV(byte[], int, int, int, int)"><!-- --></A><H3>
 decompressToYUV</H3>
 <PRE>
 public void <B>decompressToYUV</B>(byte[]&nbsp;dstBuf,
+                            int&nbsp;desiredWidth,
+                            int&nbsp;pad,
+                            int&nbsp;desiredHeight,
                             int&nbsp;flags)
                      throws java.lang.Exception</PRE>
 <DL>
@@ -846,25 +874,63 @@ public void <B>decompressToYUV</B>(byte[]&nbsp;dstBuf,
 <P>
 <DD><DL>
 <DT><B>Parameters:</B><DD><CODE>dstBuf</CODE> - buffer that will receive the YUV planar image.  Use
- <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int)"><CODE>TJ.bufSizeYUV(int, int, int)</CODE></A> to determine the appropriate size for this buffer
- based on the image width, height, and level of chrominance subsampling.<DD><CODE>flags</CODE> - the bitwise OR of one or more of <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.FLAG_*</CODE></A>
+ <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 size for this buffer
+ based on the image width, height, and level of chrominance subsampling.<DD><CODE>desiredWidth</CODE> - desired width (in pixels) of the YUV image.  If the
+ desired image dimensions are different than the dimensions of the JPEG
+ image being decompressed, then TurboJPEG will use scaling in the JPEG
+ decompressor to generate the largest possible image that will fit within
+ the desired dimensions.  Setting this to 0 is the same as setting it to
+ the width of the JPEG image (in other words, the width will not be
+ considered when determining the scaled image size.)<DD><CODE>pad</CODE> - the width of each line in each plane of the YUV image will be
+ padded to the nearest multiple of this number of bytes (must be a power of
+ 2.)<DD><CODE>desiredHeight</CODE> - desired height (in pixels) of the YUV image.  If the
+ desired image dimensions are different than the dimensions of the JPEG
+ image being decompressed, then TurboJPEG will use scaling in the JPEG
+ decompressor to generate the largest possible image that will fit within
+ the desired dimensions.  Setting this to 0 is the same as setting it to
+ the height of the JPEG image (in other words, the height will not be
+ considered when determining the scaled image size.)<DD><CODE>flags</CODE> - the bitwise OR of one or more of <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.FLAG_*</CODE></A>
 <DT><B>Throws:</B>
 <DD><CODE>java.lang.Exception</CODE></DL>
 </DD>
 </DL>
 <HR>
 
-<A NAME="decompressToYUV(int)"><!-- --></A><H3>
+<A NAME="decompressToYUV(byte[], int)"><!-- --></A><H3>
 decompressToYUV</H3>
 <PRE>
-public byte[] <B>decompressToYUV</B>(int&nbsp;flags)
+<FONT SIZE="-1">@Deprecated
+</FONT>public void <B>decompressToYUV</B>(byte[]&nbsp;dstBuf,
+                                       int&nbsp;flags)
+                     throws java.lang.Exception</PRE>
+<DL>
+<DD><B>Deprecated.</B>&nbsp;<I>Use <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int, int, int, int)"><CODE>decompressToYUV(byte[], int, int, int, int)</CODE></A>
+ instead.</I>
+<P>
+<DD><DL>
+
+<DT><B>Throws:</B>
+<DD><CODE>java.lang.Exception</CODE></DL>
+</DD>
+</DL>
+<HR>
+
+<A NAME="decompressToYUV(int, int, int, int)"><!-- --></A><H3>
+decompressToYUV</H3>
+<PRE>
+public byte[] <B>decompressToYUV</B>(int&nbsp;desiredWidth,
+                              int&nbsp;pad,
+                              int&nbsp;desiredHeight,
+                              int&nbsp;flags)
                        throws java.lang.Exception</PRE>
 <DL>
 <DD>Decompress the JPEG source image associated with this decompressor
- instance and return a buffer containing a YUV planar image.  See <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int)"><CODE>decompressToYUV(byte[], int)</CODE></A> for more detail.
+ instance and return a buffer containing a YUV planar image.  See <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int, int, int, int)"><CODE>decompressToYUV(byte[], int, int, int, int)</CODE></A> for more detail.
 <P>
 <DD><DL>
-<DT><B>Parameters:</B><DD><CODE>flags</CODE> - the bitwise OR of one or more of <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.FLAG_*</CODE></A>
+<DT><B>Parameters:</B><DD><CODE>desiredWidth</CODE> - see
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int, int, int, int)"><CODE>decompressToYUV(byte[], int, int, int, int)</CODE></A> for description<DD><CODE>pad</CODE> - see <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int, int, int, int)"><CODE>decompressToYUV(byte[], int, int, int, int)</CODE></A> for
+ description<DD><CODE>desiredHeight</CODE> - see <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int, int, int, int)"><CODE>decompressToYUV(byte[], int, int, int, int)</CODE></A> for description<DD><CODE>flags</CODE> - the bitwise OR of one or more of <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJ.FLAG_*</CODE></A>
 <DT><B>Returns:</B><DD>a buffer containing a YUV planar image
 <DT><B>Throws:</B>
 <DD><CODE>java.lang.Exception</CODE></DL>
@@ -872,6 +938,23 @@ public byte[] <B>decompressToYUV</B>(int&nbsp;flags)
 </DL>
 <HR>
 
+<A NAME="decompressToYUV(int)"><!-- --></A><H3>
+decompressToYUV</H3>
+<PRE>
+<FONT SIZE="-1">@Deprecated
+</FONT>public byte[] <B>decompressToYUV</B>(int&nbsp;flags)
+                       throws java.lang.Exception</PRE>
+<DL>
+<DD><B>Deprecated.</B>&nbsp;<I>Use <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int, int, int, int)"><CODE>decompressToYUV(int, int, int, int)</CODE></A> instead.</I>
+<P>
+<DD><DL>
+
+<DT><B>Throws:</B>
+<DD><CODE>java.lang.Exception</CODE></DL>
+</DD>
+</DL>
+<HR>
+
 <A NAME="decompress(int[], int, int, int, int, int, int, int)"><!-- --></A><H3>
 decompress</H3>
 <PRE>
index 9262c49faa7461abadefd95dc0b1f62625f95e3d..8badc52dc11734caae5ad7169891957b68db2e54 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 TJScalingFactor
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
index 5a319807d35e0ab0a181ec72f3fd613abf5f2593..7e9f660ed32414677e1654d43d823066abd9d0b6 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 TJTransform
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
index dfef713ce6277b569a5a2b159934e3b4e94a844b..c597fa7fbf2ee7527c2b005ade0df11227c0ed8b 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 TJTransformer
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
@@ -205,7 +205,7 @@ TurboJPEG lossless transformer
 <TH ALIGN="left"><B>Methods inherited from class org.libjpegturbo.turbojpeg.<A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</A></B></TH>
 </TR>
 <TR BGCOLOR="white" CLASS="TableRowColor">
-<TD><CODE><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#close()">close</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(java.awt.image.BufferedImage, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int[], int, int, int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int)">decompressToYUV</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int)">decompressToYUV</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#finalize()">finalize</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getHeight()">getHeight</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getJPEGBuf()">getJPEGBuf</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getJPEGSize()">getJPEGSize</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledHeight(int, int)">getScaledHeight</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledWidth(int, int)">getScaledWidth</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getSubsamp()">getSubsamp</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getWidth()">getWidth</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#setJPEGImage(byte[], int)">setJPEGImage</A></CODE></TD>
+<TD><CODE><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#close()">close</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(java.awt.image.BufferedImage, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(byte[], int, int, int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int[], int, int, int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompress(int, int, int, int, int)">decompress</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int)">decompressToYUV</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int, int, int, int)">decompressToYUV</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int)">decompressToYUV</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int, int, int, int)">decompressToYUV</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#finalize()">finalize</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getHeight()">getHeight</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getJPEGBuf()">getJPEGBuf</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getJPEGSize()">getJPEGSize</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledHeight(int, int)">getScaledHeight</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getScaledWidth(int, int)">getScaledWidth</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getSubsamp()">getSubsamp</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#getWidth()">getWidth</A>, <A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#setJPEGImage(byte[], int)">setJPEGImage</A></CODE></TD>
 </TR>
 </TABLE>
 &nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
index 72860782947dfe6f24d591fbbcdb4fe30e3de2b0..035d330b75544da8f2e3ebdc6bf3469d1af97da3 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 org.libjpegturbo.turbojpeg
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
index bafbf528ac243379b1dc1c524fe88bc33f8ab9d8..7a161426cf8713163586bd96f2731bfea91f8207 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 org.libjpegturbo.turbojpeg
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
index 40eb9100e9344fa4ccb0b6739e61f44252d2e721..90668357323b8741b043659216347db5daca7d42 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 org.libjpegturbo.turbojpeg Class Hierarchy
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
 
index 93c07d3f92bd8f636fd27cc380f58bf1c96a0efa..dd01dd97c8e8bbb9d3d99919ee1286ba464bda73 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 Class Hierarchy
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
index d6162a94c7f1c0478322e9d79c49b56442555580..bc8b1bb5a984cf031dea2da1ad0e3b10958ecd66 100644 (file)
@@ -2,12 +2,12 @@
 <!--NewPage-->
 <HTML>
 <HEAD>
-<!-- Generated by javadoc (build 1.6.0_43) on Fri Apr 26 20:05:34 CDT 2013 -->
+<!-- Generated by javadoc (build 1.6.0_43) on Sat Apr 27 20:13:12 CDT 2013 -->
 <TITLE>
 Serialized Form
 </TITLE>
 
-<META NAME="date" CONTENT="2013-04-26">
+<META NAME="date" CONTENT="2013-04-27">
 
 <LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
 
index 9f7c68221acfd50876b0534eddcfe2ab3af6a5c5..eb9f0275d3ca111e0b2500d4aea044919f3c3c0c 100644 (file)
@@ -342,6 +342,10 @@ public final class TJ {
    *
    * @param width the width (in pixels) of the YUV image
    *
+   * @param pad the width of each line in each plane of the image is padded to
+   *        the nearest multiple of this number of bytes (must be a power of
+   *        2.)
+   *
    * @param height the height (in pixels) of the YUV image
    *
    * @param subsamp the level of chrominance subsampling used in the YUV
@@ -350,6 +354,14 @@ public final class TJ {
    * @return the size of the buffer (in bytes) required to hold a YUV planar
    * image with the given width, height, and level of chrominance subsampling
    */
+  public static native int bufSizeYUV(int width, int pad, int height,
+                                      int subsamp)
+    throws Exception;
+
+  /**
+   * @deprecated Use {@link #bufSizeYUV(int, int, int, int)} instead.
+   */
+  @Deprecated
   public static native int bufSizeYUV(int width, int height, int subsamp)
     throws Exception;
 
index f8f82acc01dc963148ae1ab4ea1c35b87f94f275..18fa192dff2984e9550fc92fb4a46e6bb44da1af 100644 (file)
@@ -145,6 +145,7 @@ public class TJCompressor {
    * @deprecated Use
    * {@link #setSourceImage(byte[], int, int, int, int, int, int)} instead.
    */
+  @Deprecated
   public void setSourceImage(byte[] srcImage, int width, int pitch,
                              int height, int pixelFormat) throws Exception {
     setSourceImage(srcImage, 0, 0, width, pitch, height, pixelFormat);
@@ -330,20 +331,34 @@ public class TJCompressor {
     return buf;
   }
 
+
+  /**
+   * Set the plane padding for subsequent YUV encode operations.
+   *
+   * @param pad the width of each line in each plane of the YUV image will be
+   *        padded to the nearest multiple of this number of bytes (must be a
+   *        power of 2.)  The default padding is 4 bytes, which generates
+   *        images suitable for direct video display.
+   */
+  public void setYUVPad(int pad) throws Exception {
+    if(pad < 1 || ((pad & (pad - 1)) != 0))
+      throw new Exception("Invalid argument in setYUVPad()");
+    yuvPad = pad;
+  }
+
   /**
    * Encode the uncompressed source image associated with this compressor
    * instance and output a YUV planar image to the given destination buffer.
-   * This method uses the accelerated color conversion routines in
-   * TurboJPEG's underlying codec to produce a planar YUV image that is
-   * suitable for direct video display.  Specifically, if the chrominance
-   * components are subsampled along the horizontal dimension, then the width
-   * of the luminance plane is padded to the nearest multiple of 2 in the
-   * output image (same goes for the height of the luminance plane, if the
-   * chrominance components are subsampled along the vertical dimension.)
-   * Also, each line of each plane in the output image is padded to 4 bytes.
-   * Although this will work with any subsampling option, it is really only
-   * useful in combination with {@link TJ#SAMP_420}, which produces an image
-   * compatible with the I420 (AKA "YUV420P") format.
+   * This method uses the accelerated color conversion routines in TurboJPEG's
+   * underlying codec but does not execute any of the other steps in the JPEG
+   * compression process.  The Y, U, and V image planes are stored sequentially
+   * into the destination buffer, and the size of each plane is determined by
+   * the width and height of the source image, as well as the specified padding
+   * and level of chrominance subsampling.  If the chrominance components are
+   * subsampled along the horizontal dimension, then the width of the luminance
+   * plane is padded to the nearest multiple of 2 in the output image (same
+   * goes for the height of the luminance plane, if the chrominance components
+   * are subsampled along the vertical dimension.)
    *
    * @param dstBuf buffer that will receive the YUV planar image.  Use
    * {@link TJ#bufSizeYUV} to determine the appropriate size for this buffer
@@ -358,9 +373,9 @@ public class TJCompressor {
       throw new Exception(NO_ASSOC_ERROR);
     if (subsamp < 0)
       throw new Exception("Subsampling level not set");
-    encodeYUV(srcBuf, srcWidth, srcPitch, srcHeight,
-              srcPixelFormat, dstBuf, subsamp, flags);
-    compressedSize = TJ.bufSizeYUV(srcWidth, srcHeight, subsamp);
+    encodeYUV(srcBuf, srcWidth, srcPitch, srcHeight, srcPixelFormat, dstBuf,
+              yuvPad, subsamp, flags);
+    compressedSize = TJ.bufSizeYUV(srcWidth, yuvPad, srcHeight, subsamp);
   }
 
   /**
@@ -377,7 +392,7 @@ public class TJCompressor {
       throw new Exception(NO_ASSOC_ERROR);
     if (subsamp < 0)
       throw new Exception("Subsampling level not set");
-    byte[] buf = new byte[TJ.bufSizeYUV(srcWidth, srcHeight, subsamp)];
+    byte[] buf = new byte[TJ.bufSizeYUV(srcWidth, yuvPad, srcHeight, subsamp)];
     encodeYUV(buf, flags);
     return buf;
   }
@@ -438,8 +453,8 @@ public class TJCompressor {
       int stride = sm.getScanlineStride();
       DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
       int[] buf = db.getData();
-      encodeYUV(buf, width, stride, height, pixelFormat, dstBuf, subsamp,
-                flags);
+      encodeYUV(buf, width, stride, height, pixelFormat, dstBuf, yuvPad,
+                subsamp, flags);
     } else {
       ComponentSampleModel sm =
         (ComponentSampleModel)srcImage.getSampleModel();
@@ -449,10 +464,10 @@ public class TJCompressor {
       int pitch = sm.getScanlineStride();
       DataBufferByte db = (DataBufferByte)wr.getDataBuffer();
       byte[] buf = db.getData();
-      encodeYUV(buf, width, pitch, height, pixelFormat, dstBuf, subsamp,
-                flags);
+      encodeYUV(buf, width, pitch, height, pixelFormat, dstBuf, yuvPad,
+                subsamp, flags);
     }
-    compressedSize = TJ.bufSizeYUV(width, height, subsamp);
+    compressedSize = TJ.bufSizeYUV(width, yuvPad, height, subsamp);
   }
 
   /**
@@ -472,7 +487,7 @@ public class TJCompressor {
       throw new Exception("Subsampling level not set");
     int width = srcImage.getWidth();
     int height = srcImage.getHeight();
-    byte[] buf = new byte[TJ.bufSizeYUV(width, height, subsamp)];
+    byte[] buf = new byte[TJ.bufSizeYUV(width, yuvPad, height, subsamp)];
     encodeYUV(srcImage, buf, flags);
     return buf;
   }
@@ -527,11 +542,19 @@ public class TJCompressor {
 
   private native void encodeYUV(byte[] srcBuf, int width, int pitch,
     int height, int pixelFormat, byte[] dstBuf, int subsamp, int flags)
-    throws Exception;
+    throws Exception; // deprecated
+
+  private native void encodeYUV(byte[] srcBuf, int width, int pitch,
+    int height, int pixelFormat, byte[] dstBuf, int pad, int subsamp,
+    int flags) throws Exception;
 
   private native void encodeYUV(int[] srcBuf, int width, int stride,
     int height, int pixelFormat, byte[] dstBuf, int subsamp, int flags)
-    throws Exception;
+    throws Exception; // deprecated
+
+  private native void encodeYUV(int[] srcBuf, int width, int pitch,
+    int height, int pixelFormat, byte[] dstBuf, int pad, int subsamp,
+    int flags) throws Exception;
 
   static {
     TJLoader.load();
@@ -548,5 +571,6 @@ public class TJCompressor {
   private int subsamp = -1;
   private int jpegQuality = -1;
   private int compressedSize = 0;
+  private int yuvPad = 4;
   private ByteOrder byteOrder = null;
 };
index c2d361e14429e23f8ac6b91d2092b852b784acd9..eb8d31cce064c89fb46b60f257d5f4a73359360d 100644 (file)
@@ -313,6 +313,7 @@ public class TJDecompressor {
    * @deprecated Use
    * {@link #decompress(byte[], int, int, int, int, int, int, int)} instead.
    */
+  @Deprecated
   public void decompress(byte[] dstBuf, int desiredWidth, int pitch,
                          int desiredHeight, int pixelFormat, int flags)
                          throws Exception {
@@ -373,38 +374,90 @@ public class TJDecompressor {
    * {@link TJ#bufSizeYUV} to determine the appropriate size for this buffer
    * based on the image width, height, and level of chrominance subsampling.
    *
+   * @param desiredWidth desired width (in pixels) of the YUV image.  If the
+   * desired image dimensions are different than the dimensions of the JPEG
+   * image being decompressed, then TurboJPEG will use scaling in the JPEG
+   * decompressor to generate the largest possible image that will fit within
+   * the desired dimensions.  Setting this to 0 is the same as setting it to
+   * the width of the JPEG image (in other words, the width will not be
+   * considered when determining the scaled image size.)
+   *
+   * @param pad the width of each line in each plane of the YUV image will be
+   * padded to the nearest multiple of this number of bytes (must be a power of
+   * 2.)
+   *
+   * @param desiredHeight desired height (in pixels) of the YUV image.  If the
+   * desired image dimensions are different than the dimensions of the JPEG
+   * image being decompressed, then TurboJPEG will use scaling in the JPEG
+   * decompressor to generate the largest possible image that will fit within
+   * the desired dimensions.  Setting this to 0 is the same as setting it to
+   * the height of the JPEG image (in other words, the height will not be
+   * considered when determining the scaled image size.)
+   *
    * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
    */
-  public void decompressToYUV(byte[] dstBuf, int flags) throws Exception {
+  public void decompressToYUV(byte[] dstBuf, int desiredWidth, int pad,
+                              int desiredHeight, int flags) throws Exception {
     if (jpegBuf == null)
       throw new Exception(NO_ASSOC_ERROR);
-    if (dstBuf == null || flags < 0)
+    if (dstBuf == null || desiredWidth < 0 || pad < 1 ||
+        ((pad & (pad - 1)) != 0) || desiredHeight < 0 || flags < 0)
       throw new Exception("Invalid argument in decompressToYUV()");
-    decompressToYUV(jpegBuf, jpegBufSize, dstBuf, flags);
+    decompressToYUV(jpegBuf, jpegBufSize, dstBuf, desiredWidth, pad,
+                    desiredHeight, flags);
   }
 
+  /**
+   * @deprecated Use {@link #decompressToYUV(byte[], int, int, int, int)}
+   * instead.
+   */
+  @Deprecated
+  public void decompressToYUV(byte[] dstBuf, int flags) throws Exception {
+    decompressToYUV(dstBuf, 0, 4, 0, flags);
+  }
 
   /**
    * Decompress the JPEG source image associated with this decompressor
    * instance and return a buffer containing a YUV planar image.  See {@link
-   * #decompressToYUV(byte[], int)} for more detail.
+   * #decompressToYUV(byte[], int, int, int, int)} for more detail.
+   *
+   * @param desiredWidth see
+   * {@link #decompressToYUV(byte[], int, int, int, int)} for description
+   *
+   * @param pad see {@link #decompressToYUV(byte[], int, int, int, int)} for
+   * description
+   *
+   * @param desiredHeight see {@link
+   * #decompressToYUV(byte[], int, int, int, int)} for description
    *
    * @param flags the bitwise OR of one or more of {@link TJ TJ.FLAG_*}
    *
    * @return a buffer containing a YUV planar image
    */
-  public byte[] decompressToYUV(int flags) throws Exception {
+  public byte[] decompressToYUV(int desiredWidth, int pad, int desiredHeight,
+                                int flags) throws Exception {
     if (flags < 0)
       throw new Exception("Invalid argument in decompressToYUV()");
     if (jpegWidth < 1 || jpegHeight < 1 || jpegSubsamp < 0)
       throw new Exception(NO_ASSOC_ERROR);
     if (jpegSubsamp >= TJ.NUMSAMP)
       throw new Exception("JPEG header information is invalid");
-    byte[] buf = new byte[TJ.bufSizeYUV(jpegWidth, jpegHeight, jpegSubsamp)];
-    decompressToYUV(buf, flags);
+    int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
+    int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
+    byte[] buf = new byte[TJ.bufSizeYUV(scaledWidth, pad, scaledHeight,
+                                        jpegSubsamp)];
+    decompressToYUV(buf, desiredWidth, pad, desiredHeight, flags);
     return buf;
   }
 
+  /**
+   * @deprecated Use {@link #decompressToYUV(int, int, int, int)} instead.
+   */
+  @Deprecated
+  public byte[] decompressToYUV(int flags) throws Exception {
+    return decompressToYUV(0, 4, 0, flags);
+  }
+
   /**
    * Decompress the JPEG source image associated with this decompressor
    * instance and output a decompressed image to the given destination buffer.
@@ -619,7 +672,10 @@ public class TJDecompressor {
     int flags) throws Exception;
 
   private native void decompressToYUV(byte[] srcBuf, int size, byte[] dstBuf,
-    int flags) throws Exception;
+    int flags) throws Exception; // deprecated
+
+  private native void decompressToYUV(byte[] srcBuf, int size, byte[] dstBuf,
+    int desiredWidth, int pad, int desiredheight, int flags) throws Exception;
 
   static {
     TJLoader.load();
index d7b032aec98a38a89b7c84cfca0db4d96bbcef5a..cec69e4c20b3dd4f440c3c8e0f7272e5bab605fe 100644 (file)
@@ -67,12 +67,20 @@ extern "C" {
 JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSize
   (JNIEnv *, jclass, jint, jint, jint);
 
+/*
+ * Class:     org_libjpegturbo_turbojpeg_TJ
+ * Method:    bufSizeYUV
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV__IIII
+  (JNIEnv *, jclass, jint, jint, jint, jint);
+
 /*
  * Class:     org_libjpegturbo_turbojpeg_TJ
  * Method:    bufSizeYUV
  * Signature: (III)I
  */
-JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV
+JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV__III
   (JNIEnv *, jclass, jint, jint, jint);
 
 /*
index 2fc9136964627a5c9d4bb6ab762b13598aca0999..afec0772327ef6a19c6f06de4d1c0cb38ffdd814 100644 (file)
@@ -63,6 +63,14 @@ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compress___3
 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIII_3BII
   (JNIEnv *, jobject, jbyteArray, jint, jint, jint, jint, jbyteArray, jint, jint);
 
+/*
+ * Class:     org_libjpegturbo_turbojpeg_TJCompressor
+ * Method:    encodeYUV
+ * Signature: ([BIIII[BIII)V
+ */
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIII_3BIII
+  (JNIEnv *, jobject, jbyteArray, jint, jint, jint, jint, jbyteArray, jint, jint, jint);
+
 /*
  * Class:     org_libjpegturbo_turbojpeg_TJCompressor
  * Method:    encodeYUV
@@ -71,6 +79,14 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___
 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BII
   (JNIEnv *, jobject, jintArray, jint, jint, jint, jint, jbyteArray, jint, jint);
 
+/*
+ * Class:     org_libjpegturbo_turbojpeg_TJCompressor
+ * Method:    encodeYUV
+ * Signature: ([IIIII[BIII)V
+ */
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BIII
+  (JNIEnv *, jobject, jintArray, jint, jint, jint, jint, jbyteArray, jint, jint, jint);
+
 #ifdef __cplusplus
 }
 #endif
index f798a77f253ac0ee9e62da9d49f013839c1f64e1..203f00489856ef8c3b27e624f8a1d7a2db092777 100644 (file)
@@ -68,9 +68,17 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
  * Method:    decompressToYUV
  * Signature: ([BI[BI)V
  */
-JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV___3BI_3BI
   (JNIEnv *, jobject, jbyteArray, jint, jbyteArray, jint);
 
+/*
+ * Class:     org_libjpegturbo_turbojpeg_TJDecompressor
+ * Method:    decompressToYUV
+ * Signature: ([BI[BIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV___3BI_3BIIII
+  (JNIEnv *, jobject, jbyteArray, jint, jbyteArray, jint, jint, jint, jint);
+
 #ifdef __cplusplus
 }
 #endif
index a1e6f33476954b8572245d87cc5252beaab638a7..7a44b9405c6e3de56d4c373b04f092c0d5460db2 100644 (file)
@@ -48,7 +48,7 @@ void usage(char *progName)
        printf("Options:\n");
        printf("-yuv = test YUV encoding/decoding support\n");
        printf("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest\n");
-       printf("            4-byte boundary.\n");
+       printf("            4-byte boundary\n");
        printf("-alloc = test automatic buffer allocation\n");
        exit(1);
 }
index 634bedf605b37f85cfe3a1055053f0b1aaa3073e..174558e912988f4b96c40a335fea597eb4e5151c 100644 (file)
@@ -67,16 +67,23 @@ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSize
        return retval;
 }
 
-JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV
-       (JNIEnv *env, jclass cls, jint width, jint height, jint subsamp)
+JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV__IIII
+       (JNIEnv *env, jclass cls, jint width, jint pad, jint height, jint subsamp)
 {
-       jint retval=(jint)tjBufSizeYUV(width, height, subsamp);
+       jint retval=(jint)tjBufSizeYUV2(width, pad, height, subsamp);
        if(retval==-1) _throw(tjGetErrorStr());
 
        bailout:
        return retval;
 }
 
+JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV__III
+       (JNIEnv *env, jclass cls, jint width, jint height, jint subsamp)
+{
+       return Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV__IIII(env, cls, width,
+               4, height, subsamp);
+}
+
 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_init
        (JNIEnv *env, jobject obj)
 {
@@ -207,12 +214,12 @@ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compress___3
                flags);
 }
 
-JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIII_3BII
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIII_3BIII
        (JNIEnv *env, jobject obj, jbyteArray src, jint width, jint pitch,
-               jint height, jint pf, jbyteArray dst, jint subsamp, jint flags)
+               jint height, jint pf, jbyteArray dst, jint pad, jint subsamp, jint flags)
 {
        tjhandle handle=0;
-       jsize arraySize=0;
+       jsize arraySize=0, yuvSize;
        unsigned char *srcBuf=NULL, *dstBuf=NULL;
 
        gethandle();
@@ -226,15 +233,17 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___
        arraySize=(pitch==0)? width*tjPixelSize[pf]*height:pitch*height;
        if((*env)->GetArrayLength(env, src)<arraySize)
                _throw("Source buffer is not large enough");
-       if((*env)->GetArrayLength(env, dst)
-               <(jsize)tjBufSizeYUV(width, height, subsamp))
+       yuvSize=(jsize)tjBufSizeYUV2(width, pad, height, subsamp);
+       if(yuvSize==(unsigned long)-1)
+               _throw(tjGetErrorStr());
+       if((*env)->GetArrayLength(env, dst)<yuvSize)
                _throw("Destination buffer is not large enough");
 
        bailif0(srcBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
        bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0));
 
-       if(tjEncodeYUV2(handle, srcBuf, width, pitch, height, pf, dstBuf, subsamp,
-               flags)==-1)
+       if(tjEncodeYUV3(handle, srcBuf, width, pitch, height, pf, dstBuf, pad,
+               subsamp, flags)==-1)
        {
                (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
                (*env)->ReleasePrimitiveArrayCritical(env, src, srcBuf, 0);
@@ -248,12 +257,20 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___
        return;
 }
 
-JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BII
-       (JNIEnv *env, jobject obj, jintArray src, jint width, jint stride,
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIII_3BII
+       (JNIEnv *env, jobject obj, jbyteArray src, jint width, jint pitch,
                jint height, jint pf, jbyteArray dst, jint subsamp, jint flags)
+{
+       Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIII_3BIII(
+               env, obj, src, width, pitch, height, pf, dst, 4, subsamp, flags);
+}
+
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BIII
+       (JNIEnv *env, jobject obj, jintArray src, jint width, jint stride,
+               jint height, jint pf, jbyteArray dst, jint pad, jint subsamp, jint flags)
 {
        tjhandle handle=0;
-       jsize arraySize=0;
+       jsize arraySize=0, yuvSize;
        unsigned char *srcBuf=NULL, *dstBuf=NULL;
 
        gethandle();
@@ -269,15 +286,17 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___
        arraySize=(stride==0)? width*height:stride*height;
        if((*env)->GetArrayLength(env, src)<arraySize)
                _throw("Source buffer is not large enough");
-       if((*env)->GetArrayLength(env, dst)
-               <(jsize)tjBufSizeYUV(width, height, subsamp))
+       yuvSize=(jsize)tjBufSizeYUV2(width, pad, height, subsamp);
+       if(yuvSize==(unsigned long)-1)
+               _throw(tjGetErrorStr());
+       if((*env)->GetArrayLength(env, dst)<yuvSize)
                _throw("Destination buffer is not large enough");
 
        bailif0(srcBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
        bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0));
 
-       if(tjEncodeYUV2(handle, srcBuf, width, stride*sizeof(jint), height, pf,
-               dstBuf, subsamp, flags)==-1)
+       if(tjEncodeYUV3(handle, srcBuf, width, stride*sizeof(jint), height, pf,
+               dstBuf, pad, subsamp, flags)==-1)
        {
                (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
                (*env)->ReleasePrimitiveArrayCritical(env, src, srcBuf, 0);
@@ -291,6 +310,14 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___
        return;
 }
 
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BII
+       (JNIEnv *env, jobject obj, jintArray src, jint width, jint pitch,
+               jint height, jint pf, jbyteArray dst, jint subsamp, jint flags)
+{
+       Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BIII(
+               env, obj, src, width, pitch, height, pf, dst, 4, subsamp, flags);
+}
+
 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_destroy
        (JNIEnv *env, jobject obj)
 {
@@ -484,13 +511,14 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
        
 }
 
-JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV___3BI_3BIIII
        (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst,
-               jint flags)
+               jint desiredWidth, jint pad, jint desiredHeight, jint flags)
 {
        tjhandle handle=0;
        unsigned char *jpegBuf=NULL, *dstBuf=NULL;
        int jpegSubsamp=-1, jpegWidth=0, jpegHeight=0;
+       jsize yuvSize;
 
        gethandle();
 
@@ -502,15 +530,18 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
        jpegWidth=(int)(*env)->GetIntField(env, obj, _fid);
        bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegHeight", "I"));
        jpegHeight=(int)(*env)->GetIntField(env, obj, _fid);
-       if((*env)->GetArrayLength(env, dst)
-               <(jsize)tjBufSizeYUV(jpegWidth, jpegHeight, jpegSubsamp))
-               _throw("Destination buffer is not large enough");
 
+       yuvSize=(jsize)tjBufSizeYUV2(desiredWidth==0? jpegWidth:desiredWidth,
+               pad, desiredHeight==0? jpegHeight:desiredHeight, jpegSubsamp);
+       if(yuvSize==(unsigned long)-1)
+               _throw(tjGetErrorStr());
+       if((*env)->GetArrayLength(env, dst)<yuvSize)
+               _throw("Destination buffer is not large enough");
        bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
        bailif0(dstBuf=(*env)->GetPrimitiveArrayCritical(env, dst, 0));
 
-       if(tjDecompressToYUV(handle, jpegBuf, (unsigned long)jpegSize, dstBuf,
-               flags)==-1)
+       if(tjDecompressToYUV2(handle, jpegBuf, (unsigned long)jpegSize, dstBuf,
+               desiredWidth, pad, desiredHeight, flags)==-1)
        {
                (*env)->ReleasePrimitiveArrayCritical(env, dst, dstBuf, 0);
                (*env)->ReleasePrimitiveArrayCritical(env, src, jpegBuf, 0);
@@ -524,6 +555,14 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
        return;
 }
 
+JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV___3BI_3BI
+       (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst,
+               jint flags)
+{
+       Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV___3BI_3BIIII(
+               env, obj, src, jpegSize, dst, 0, 4, 0, flags);
+}
+
 JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJTransformer_init
        (JNIEnv *env, jobject obj)
 {
index ca39c9e31223a4bc61784c2a59870e433247ab3d..5ca59b47fd47588e26c121af6fc39aa5648af9c1 100755 (executable)
@@ -36,7 +36,7 @@ TURBOJPEG_1.2
                tjInitTransform;
                tjTransform;
                Java_org_libjpegturbo_turbojpeg_TJ_bufSize;
-               Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV;
+               Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV__III;
                Java_org_libjpegturbo_turbojpeg_TJ_getScalingFactors;
                Java_org_libjpegturbo_turbojpeg_TJCompressor_init;
                Java_org_libjpegturbo_turbojpeg_TJCompressor_compress___3BIIII_3BIII;
@@ -48,7 +48,7 @@ TURBOJPEG_1.2
                Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressHeader;
                Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIII;
                Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIII;
-               Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV;
+               Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV___3BI_3BI;
                Java_org_libjpegturbo_turbojpeg_TJDecompressor_destroy;         
                Java_org_libjpegturbo_turbojpeg_TJTransformer_init;
                Java_org_libjpegturbo_turbojpeg_TJTransformer_transform;
@@ -62,3 +62,15 @@ TURBOJPEG_1.3
                Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIIIII;
                Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIIIII;
 } TURBOJPEG_1.2;
+
+TURBOJPEG_1.4
+{
+       global:
+               tjBufSizeYUV2;
+               tjDecompressToYUV2;
+               tjEncodeYUV3;
+               Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV__IIII;
+               Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIII_3BIII;
+               Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BIII;
+               Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV___3BI_3BIIII;
+} TURBOJPEG_1.3;