diff options
31 files changed, 512 insertions, 151 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ffffebb..495ac2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/Makefile.am b/Makefile.am index dab99b4..de6c307 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/java/TJUnitTest.java b/java/TJUnitTest.java index d0a609a..4b1a52d 100644 --- a/java/TJUnitTest.java +++ b/java/TJUnitTest.java @@ -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(); diff --git a/java/doc/allclasses-frame.html b/java/doc/allclasses-frame.html index c02463d..3ee3e6f 100644 --- a/java/doc/allclasses-frame.html +++ b/java/doc/allclasses-frame.html @@ -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"> diff --git a/java/doc/allclasses-noframe.html b/java/doc/allclasses-noframe.html index 1f134aa..249acfb 100644 --- a/java/doc/allclasses-noframe.html +++ b/java/doc/allclasses-noframe.html @@ -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"> diff --git a/java/doc/constant-values.html b/java/doc/constant-values.html index 5c6ab69..3978d19 100644 --- a/java/doc/constant-values.html +++ b/java/doc/constant-values.html @@ -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"> diff --git a/java/doc/deprecated-list.html b/java/doc/deprecated-list.html index a19b026..9a73159 100644 --- a/java/doc/deprecated-list.html +++ b/java/doc/deprecated-list.html @@ -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> + <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> </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> <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> </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> + <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> </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> + <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> </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> <I>Use diff --git a/java/doc/help-doc.html b/java/doc/help-doc.html index 7fb7c44..ebffee0 100644 --- a/java/doc/help-doc.html +++ b/java/doc/help-doc.html @@ -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"> diff --git a/java/doc/index-all.html b/java/doc/index-all.html index 36435a7..820876f 100644 --- a/java/doc/index-all.html +++ b/java/doc/index-all.html @@ -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> <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> <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> <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> diff --git a/java/doc/index.html b/java/doc/index.html index f187a87..d555848 100644 --- a/java/doc/index.html +++ b/java/doc/index.html @@ -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> diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJ.html b/java/doc/org/libjpegturbo/turbojpeg/TJ.html index 2a11b78..3103cd4 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJ.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJ.html @@ -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"> @@ -375,6 +375,17 @@ TurboJPEG utility class (cannot be instantiated) int subsamp)</CODE> <BR> + <B>Deprecated.</B> <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 int</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSizeYUV(int, int, int, int)">bufSizeYUV</A></B>(int width, + int pad, + int height, + int subsamp)</CODE> + +<BR> 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> </TR> @@ -992,10 +1003,11 @@ public static int <B>bufSize</B>(int 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 width, + int pad, int height, int subsamp) throws java.lang.Exception</PRE> @@ -1004,7 +1016,9 @@ public static int <B>bufSizeYUV</B>(int 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 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 width, + int height, + int subsamp) + throws java.lang.Exception</PRE> +<DL> +<DD><B>Deprecated.</B> <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> diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html index 871d9bc..ee829c8 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html @@ -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 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> void</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJCompressor.html#setYUVPad(int)">setYUVPad</A></B>(int pad)</CODE> + +<BR> + Set the plane padding for subsequent YUV encode operations.</TD> +</TR> </TABLE> <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[] srcImage, <A NAME="setSourceImage(byte[], int, int, int, int)"><!-- --></A><H3> setSourceImage</H3> <PRE> -public void <B>setSourceImage</B>(byte[] srcImage, - int width, - int pitch, - int height, - int pixelFormat) +<FONT SIZE="-1">@Deprecated +</FONT>public void <B>setSourceImage</B>(byte[] srcImage, + int width, + int pitch, + int height, + int pixelFormat) throws java.lang.Exception</PRE> <DL> <DD><B>Deprecated.</B> <I>Use @@ -572,6 +581,25 @@ public byte[] <B>compress</B>(java.awt.image.BufferedImage srcImage, </DL> <HR> +<A NAME="setYUVPad(int)"><!-- --></A><H3> +setYUVPad</H3> +<PRE> +public void <B>setYUVPad</B>(int 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[] 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 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> diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html b/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html index c91978d..350d636 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html @@ -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"> diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html index d7c6495..013c054 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html @@ -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"> @@ -305,6 +305,19 @@ TurboJPEG decompressor int flags)</CODE> <BR> + <B>Deprecated.</B> <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> void</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(byte[], int, int, int, int)">decompressToYUV</A></B>(byte[] dstBuf, + int desiredWidth, + int pad, + int desiredHeight, + int flags)</CODE> + +<BR> Decompress the JPEG source image associated with this decompressor instance and output a YUV planar image to the given destination buffer.</TD> </TR> @@ -314,6 +327,17 @@ TurboJPEG decompressor <TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int)">decompressToYUV</A></B>(int flags)</CODE> <BR> + <B>Deprecated.</B> <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> byte[]</CODE></FONT></TD> +<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#decompressToYUV(int, int, int, int)">decompressToYUV</A></B>(int desiredWidth, + int pad, + int desiredHeight, + int flags)</CODE> + +<BR> Decompress the JPEG source image associated with this decompressor instance and return a buffer containing a YUV planar image.</TD> </TR> @@ -779,12 +803,13 @@ public void <B>decompress</B>(byte[] dstBuf, <A NAME="decompress(byte[], int, int, int, int, int)"><!-- --></A><H3> decompress</H3> <PRE> -public void <B>decompress</B>(byte[] dstBuf, - int desiredWidth, - int pitch, - int desiredHeight, - int pixelFormat, - int flags) +<FONT SIZE="-1">@Deprecated +</FONT>public void <B>decompress</B>(byte[] dstBuf, + int desiredWidth, + int pitch, + int desiredHeight, + int pixelFormat, + int flags) throws java.lang.Exception</PRE> <DL> <DD><B>Deprecated.</B> <I>Use @@ -827,10 +852,13 @@ public byte[] <B>decompress</B>(int 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[] dstBuf, + int desiredWidth, + int pad, + int desiredHeight, int flags) throws java.lang.Exception</PRE> <DL> @@ -846,25 +874,63 @@ public void <B>decompressToYUV</B>(byte[] 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 flags) +<FONT SIZE="-1">@Deprecated +</FONT>public void <B>decompressToYUV</B>(byte[] dstBuf, + int flags) + throws java.lang.Exception</PRE> +<DL> +<DD><B>Deprecated.</B> <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 desiredWidth, + int pad, + int desiredHeight, + int 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 flags) </DL> <HR> +<A NAME="decompressToYUV(int)"><!-- --></A><H3> +decompressToYUV</H3> +<PRE> +<FONT SIZE="-1">@Deprecated +</FONT>public byte[] <B>decompressToYUV</B>(int flags) + throws java.lang.Exception</PRE> +<DL> +<DD><B>Deprecated.</B> <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> diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html b/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html index 9262c49..8badc52 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html @@ -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"> diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html b/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html index 5a31980..7e9f660 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html @@ -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"> diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html b/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html index dfef713..c597fa7 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html +++ b/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html @@ -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> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-frame.html b/java/doc/org/libjpegturbo/turbojpeg/package-frame.html index 7286078..035d330 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/package-frame.html +++ b/java/doc/org/libjpegturbo/turbojpeg/package-frame.html @@ -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"> diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-summary.html b/java/doc/org/libjpegturbo/turbojpeg/package-summary.html index bafbf52..7a16142 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/package-summary.html +++ b/java/doc/org/libjpegturbo/turbojpeg/package-summary.html @@ -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"> diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-tree.html b/java/doc/org/libjpegturbo/turbojpeg/package-tree.html index 40eb910..9066835 100644 --- a/java/doc/org/libjpegturbo/turbojpeg/package-tree.html +++ b/java/doc/org/libjpegturbo/turbojpeg/package-tree.html @@ -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"> diff --git a/java/doc/overview-tree.html b/java/doc/overview-tree.html index 93c07d3..dd01dd9 100644 --- a/java/doc/overview-tree.html +++ b/java/doc/overview-tree.html @@ -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"> diff --git a/java/doc/serialized-form.html b/java/doc/serialized-form.html index d6162a9..bc8b1bb 100644 --- a/java/doc/serialized-form.html +++ b/java/doc/serialized-form.html @@ -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"> diff --git a/java/org/libjpegturbo/turbojpeg/TJ.java b/java/org/libjpegturbo/turbojpeg/TJ.java index 9f7c682..eb9f027 100644 --- a/java/org/libjpegturbo/turbojpeg/TJ.java +++ b/java/org/libjpegturbo/turbojpeg/TJ.java @@ -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; diff --git a/java/org/libjpegturbo/turbojpeg/TJCompressor.java b/java/org/libjpegturbo/turbojpeg/TJCompressor.java index f8f82ac..18fa192 100644 --- a/java/org/libjpegturbo/turbojpeg/TJCompressor.java +++ b/java/org/libjpegturbo/turbojpeg/TJCompressor.java @@ -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; }; diff --git a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java index c2d361e..eb8d31c 100644 --- a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java +++ b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java @@ -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,39 +374,91 @@ 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(); diff --git a/java/org_libjpegturbo_turbojpeg_TJ.h b/java/org_libjpegturbo_turbojpeg_TJ.h index d7b032a..cec69e4 100644 --- a/java/org_libjpegturbo_turbojpeg_TJ.h +++ b/java/org_libjpegturbo_turbojpeg_TJ.h @@ -70,9 +70,17 @@ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSize /* * 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); /* diff --git a/java/org_libjpegturbo_turbojpeg_TJCompressor.h b/java/org_libjpegturbo_turbojpeg_TJCompressor.h index 2fc9136..afec077 100644 --- a/java/org_libjpegturbo_turbojpeg_TJCompressor.h +++ b/java/org_libjpegturbo_turbojpeg_TJCompressor.h @@ -66,11 +66,27 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___ /* * 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 * Signature: ([IIIII[BII)V */ 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 diff --git a/java/org_libjpegturbo_turbojpeg_TJDecompressor.h b/java/org_libjpegturbo_turbojpeg_TJDecompressor.h index f798a77..203f004 100644 --- a/java/org_libjpegturbo_turbojpeg_TJDecompressor.h +++ b/java/org_libjpegturbo_turbojpeg_TJDecompressor.h @@ -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 diff --git a/tjunittest.c b/tjunittest.c index a1e6f33..7a44b94 100644 --- a/tjunittest.c +++ b/tjunittest.c @@ -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); } diff --git a/turbojpeg-jni.c b/turbojpeg-jni.c index 634bedf..174558e 100644 --- a/turbojpeg-jni.c +++ b/turbojpeg-jni.c @@ -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) { diff --git a/turbojpeg-mapfile.jni b/turbojpeg-mapfile.jni index ca39c9e..5ca59b4 100755 --- a/turbojpeg-mapfile.jni +++ b/turbojpeg-mapfile.jni @@ -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; |