aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.txt3
-rw-r--r--doc/html/annotated.html2
-rw-r--r--doc/html/classes.html2
-rw-r--r--doc/html/functions.html2
-rw-r--r--doc/html/functions_vars.html2
-rw-r--r--doc/html/group___turbo_j_p_e_g.html42
-rw-r--r--doc/html/index.html2
-rw-r--r--doc/html/modules.html2
-rw-r--r--doc/html/structtjregion.html2
-rw-r--r--doc/html/structtjscalingfactor.html2
-rw-r--r--doc/html/structtjtransform.html2
-rw-r--r--java/TJUnitTest.java6
-rw-r--r--java/doc/allclasses-frame.html4
-rw-r--r--java/doc/allclasses-noframe.html4
-rw-r--r--java/doc/constant-values.html4
-rw-r--r--java/doc/deprecated-list.html4
-rw-r--r--java/doc/help-doc.html4
-rw-r--r--java/doc/index-all.html9
-rw-r--r--java/doc/index.html2
-rw-r--r--java/doc/org/libjpegturbo/turbojpeg/TJ.html28
-rw-r--r--java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html8
-rw-r--r--java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html4
-rw-r--r--java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html4
-rw-r--r--java/doc/org/libjpegturbo/turbojpeg/TJTransform.html4
-rw-r--r--java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html6
-rw-r--r--java/doc/org/libjpegturbo/turbojpeg/package-frame.html4
-rw-r--r--java/doc/org/libjpegturbo/turbojpeg/package-summary.html4
-rw-r--r--java/doc/org/libjpegturbo/turbojpeg/package-tree.html4
-rw-r--r--java/doc/overview-tree.html4
-rw-r--r--java/doc/serialized-form.html4
-rw-r--r--java/org/libjpegturbo/turbojpeg/TJ.java13
-rw-r--r--java/org/libjpegturbo/turbojpeg/TJCompressor.java4
-rw-r--r--java/org/libjpegturbo/turbojpeg/TJTransformer.java2
-rw-r--r--java/org_libjpegturbo_turbojpeg_TJ.h6
-rw-r--r--tjbench.c10
-rw-r--r--tjunittest.c18
-rw-r--r--turbojpeg-jni.c22
-rwxr-xr-xturbojpeg-mapfile2
-rwxr-xr-xturbojpeg-mapfile.jni2
-rw-r--r--turbojpeg.c97
-rw-r--r--turbojpeg.h34
41 files changed, 236 insertions, 148 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 0a8e8b1..99cb505 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -55,6 +55,9 @@ based on whether libjpeg v7 or v8 emulation was enabled.
fail to compile if the Windows system headers were included before jpeglib.h.
This issue was caused by a conflict in the definition of the INT32 type.
+[15] Implemented a more efficient version of TJBUFSIZE() which computes a
+worst-case JPEG size based on the level of chrominance subsampling.
+
1.1.1
=====
diff --git a/doc/html/annotated.html b/doc/html/annotated.html
index 3c6e903..1598f0b 100644
--- a/doc/html/annotated.html
+++ b/doc/html/annotated.html
@@ -81,7 +81,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe>
</div>
-<hr class="footer"/><address class="footer"><small>Generated on Tue May 24 2011 11:59:01 for TurboJPEG by&#160;
+<hr class="footer"/><address class="footer"><small>Generated on Mon Jul 11 2011 22:02:02 for TurboJPEG by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
diff --git a/doc/html/classes.html b/doc/html/classes.html
index 5af9a2a..c33212b 100644
--- a/doc/html/classes.html
+++ b/doc/html/classes.html
@@ -80,7 +80,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe>
</div>
-<hr class="footer"/><address class="footer"><small>Generated on Tue May 24 2011 11:59:01 for TurboJPEG by&#160;
+<hr class="footer"/><address class="footer"><small>Generated on Mon Jul 11 2011 22:02:02 for TurboJPEG by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
diff --git a/doc/html/functions.html b/doc/html/functions.html
index 867a59f..62aab11 100644
--- a/doc/html/functions.html
+++ b/doc/html/functions.html
@@ -107,7 +107,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe>
</div>
-<hr class="footer"/><address class="footer"><small>Generated on Tue May 24 2011 11:59:01 for TurboJPEG by&#160;
+<hr class="footer"/><address class="footer"><small>Generated on Mon Jul 11 2011 22:02:02 for TurboJPEG by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
diff --git a/doc/html/functions_vars.html b/doc/html/functions_vars.html
index 64a9c0d..da04855 100644
--- a/doc/html/functions_vars.html
+++ b/doc/html/functions_vars.html
@@ -107,7 +107,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe>
</div>
-<hr class="footer"/><address class="footer"><small>Generated on Tue May 24 2011 11:59:01 for TurboJPEG by&#160;
+<hr class="footer"/><address class="footer"><small>Generated on Mon Jul 11 2011 22:02:02 for TurboJPEG by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
diff --git a/doc/html/group___turbo_j_p_e_g.html b/doc/html/group___turbo_j_p_e_g.html
index d217944..efcecac 100644
--- a/doc/html/group___turbo_j_p_e_g.html
+++ b/doc/html/group___turbo_j_p_e_g.html
@@ -154,10 +154,10 @@ Functions</h2></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a TurboJPEG compressor instance. <a href="#ga3d10c47fbe4a2489a2b30c931551d01a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">DLLEXPORT int DLLCALL&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#gaba62b7a98f960839b588579898495cf2">tjCompress2</a> (<a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> handle, unsigned char *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf, unsigned long *jpegSize, int jpegSubsamp, int jpegQual, int flags)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Compress an RGB or grayscale image into a JPEG image. <a href="#gaba62b7a98f960839b588579898495cf2"></a><br/></td></tr>
-<tr><td class="memItemLeft" align="right" valign="top">DLLEXPORT unsigned long DLLCALL&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga68f4761dc5213cb9653a2f6ce236716e">TJBUFSIZE</a> (int width, int height)</td></tr>
-<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters. <a href="#ga68f4761dc5213cb9653a2f6ce236716e"></a><br/></td></tr>
-<tr><td class="memItemLeft" align="right" valign="top">DLLEXPORT unsigned long DLLCALL&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga8e624b291053bf850b7409af9b2d7ac8">TJBUFSIZEYUV</a> (int width, int height, int jpegSubsamp)</td></tr>
-<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters. <a href="#ga8e624b291053bf850b7409af9b2d7ac8"></a><br/></td></tr>
+<tr><td class="memItemLeft" align="right" valign="top">DLLEXPORT unsigned long DLLCALL&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b">tjBufSize</a> (int width, int height, int jpegSubsamp)</td></tr>
+<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters. <a href="#gaccc5bca7f12fcdcc302e6e1c6d4b311b"></a><br/></td></tr>
+<tr><td class="memItemLeft" align="right" valign="top">DLLEXPORT unsigned long DLLCALL&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga9d0cb06fd5052d21b6f2b382db8b219c">tjBufSizeYUV</a> (int width, int height, int subsamp)</td></tr>
+<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters. <a href="#ga9d0cb06fd5052d21b6f2b382db8b219c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">DLLEXPORT int DLLCALL&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga0fa4e7b1943687c6a0c0304529c55d35">tjEncodeYUV2</a> (<a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> handle, unsigned char *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char *dstBuf, int subsamp, int flags)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Encode an RGB or grayscale image into a YUV planar image. <a href="#ga0fa4e7b1943687c6a0c0304529c55d35"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">DLLEXPORT <a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> DLLCALL&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#gae5408179d041e2a2f7199c8283cf649e">tjInitDecompress</a> (void)</td></tr>
@@ -644,12 +644,12 @@ Variables</h2></td></tr>
</div>
</div>
-<a class="anchor" id="ga68f4761dc5213cb9653a2f6ce236716e"></a><!-- doxytag: member="turbojpeg.h::TJBUFSIZE" ref="ga68f4761dc5213cb9653a2f6ce236716e" args="(int width, int height)" -->
+<a class="anchor" id="gaccc5bca7f12fcdcc302e6e1c6d4b311b"></a><!-- doxytag: member="turbojpeg.h::tjBufSize" ref="gaccc5bca7f12fcdcc302e6e1c6d4b311b" args="(int width, int height, int jpegSubsamp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
- <td class="memname">DLLEXPORT unsigned long DLLCALL TJBUFSIZE </td>
+ <td class="memname">DLLEXPORT unsigned long DLLCALL tjBufSize </td>
<td>(</td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>width</em>, </td>
@@ -658,7 +658,13 @@ Variables</h2></td></tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
- <td class="paramname"><em>height</em>&#160;</td>
+ <td class="paramname"><em>height</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int&#160;</td>
+ <td class="paramname"><em>jpegSubsamp</em>&#160;</td>
</tr>
<tr>
<td></td>
@@ -670,10 +676,12 @@ Variables</h2></td></tr>
<div class="memdoc">
<p>The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters. </p>
+<p>The number of bytes returned by this function is larger than the size of the uncompressed source image. The reason for this is that the JPEG format uses 16-bit coefficients, and it is thus possible for a very high-quality JPEG image with very high frequency content to expand rather than compress when converted to the JPEG format. Such images represent a very rare corner case, but since there is no way to predict the size of a JPEG image prior to compression, the corner case has to be handled.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<table class="params">
<tr><td class="paramname">width</td><td>width of the image (in pixels) </td></tr>
- <tr><td class="paramname">height</td><td>height of the image (in pixels)</td></tr>
+ <tr><td class="paramname">height</td><td>height of the image (in pixels) </td></tr>
+ <tr><td class="paramname">jpegSubsamp</td><td>the level of chrominance subsampling to be used when generating the JPEG image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.)</td></tr>
</table>
</dd>
</dl>
@@ -681,12 +689,12 @@ Variables</h2></td></tr>
</div>
</div>
-<a class="anchor" id="ga8e624b291053bf850b7409af9b2d7ac8"></a><!-- doxytag: member="turbojpeg.h::TJBUFSIZEYUV" ref="ga8e624b291053bf850b7409af9b2d7ac8" args="(int width, int height, int jpegSubsamp)" -->
+<a class="anchor" id="ga9d0cb06fd5052d21b6f2b382db8b219c"></a><!-- doxytag: member="turbojpeg.h::tjBufSizeYUV" ref="ga9d0cb06fd5052d21b6f2b382db8b219c" args="(int width, int height, int subsamp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
- <td class="memname">DLLEXPORT unsigned long DLLCALL TJBUFSIZEYUV </td>
+ <td class="memname">DLLEXPORT unsigned long DLLCALL tjBufSizeYUV </td>
<td>(</td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>width</em>, </td>
@@ -701,7 +709,7 @@ Variables</h2></td></tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
- <td class="paramname"><em>jpegSubsamp</em>&#160;</td>
+ <td class="paramname"><em>subsamp</em>&#160;</td>
</tr>
<tr>
<td></td>
@@ -717,7 +725,7 @@ Variables</h2></td></tr>
<table class="params">
<tr><td class="paramname">width</td><td>width of the image (in pixels) </td></tr>
<tr><td class="paramname">height</td><td>height of the image (in pixels) </td></tr>
- <tr><td class="paramname">jpegSubsamp</td><td>level of chrominance subsampling in the image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.)</td></tr>
+ <tr><td class="paramname">subsamp</td><td>level of chrominance subsampling in the image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.)</td></tr>
</table>
</dd>
</dl>
@@ -816,7 +824,7 @@ Variables</h2></td></tr>
<tr><td class="paramname">jpegBuf</td><td>address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
<li>set <code>*jpegBuf</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
-<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#ga68f4761dc5213cb9653a2f6ce236716e" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">TJBUFSIZE()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees this.)</li>
+<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a>. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees this.)</li>
</ol>
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed. </td></tr>
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable which holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) </td></tr>
@@ -1031,7 +1039,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG decompressor or transformer instance </td></tr>
<tr><td class="paramname">jpegBuf</td><td>pointer to a buffer containing the JPEG image to decompress </td></tr>
<tr><td class="paramname">jpegSize</td><td>size of the JPEG image (in bytes) </td></tr>
- <tr><td class="paramname">dstBuf</td><td>pointer to an image buffer which will receive the YUV image. Use <a class="el" href="group___turbo_j_p_e_g.html#ga8e624b291053bf850b7409af9b2d7ac8" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">TJBUFSIZEYUV</a> to determine the appropriate size for this buffer based on the image width, height, and level of subsampling. </td></tr>
+ <tr><td class="paramname">dstBuf</td><td>pointer to an image buffer which will receive the YUV image. Use <a class="el" href="group___turbo_j_p_e_g.html#ga9d0cb06fd5052d21b6f2b382db8b219c" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">tjBufSizeYUV</a> to determine the appropriate size for this buffer based on the image width, height, and level of subsampling. </td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a>.</td></tr>
</table>
</dd>
@@ -1143,7 +1151,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">pitch</td><td>bytes per line of the source image. Normally, this should be <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the image is unpadded, or <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the image is padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use this parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>. </td></tr>
<tr><td class="paramname">height</td><td>height (in pixels) of the source image </td></tr>
<tr><td class="paramname">pixelFormat</td><td>pixel format of the source image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.) </td></tr>
- <tr><td class="paramname">dstBuf</td><td>pointer to an image buffer which will receive the YUV image. Use <a class="el" href="group___turbo_j_p_e_g.html#ga8e624b291053bf850b7409af9b2d7ac8" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">TJBUFSIZEYUV()</a> to determine the appropriate size for this buffer based on the image width, height, and level of chrominance subsampling. </td></tr>
+ <tr><td class="paramname">dstBuf</td><td>pointer to an image buffer which will receive the YUV image. Use <a class="el" href="group___turbo_j_p_e_g.html#ga9d0cb06fd5052d21b6f2b382db8b219c" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">tjBufSizeYUV()</a> to determine the appropriate size for this buffer based on the image width, height, and level of chrominance subsampling. </td></tr>
<tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling to be used when generating the YUV image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.) </td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a>.</td></tr>
</table>
@@ -1358,7 +1366,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">dstBufs</td><td>pointer to an array of n image buffers. <code>dstBufs[i]</code> will receive a JPEG image that has been transformed using the parameters in <code>transforms[i]</code>. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:<ol type="1">
<li>pre-allocate the JPEG buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga5c9234bda6d993cdaffdd89bf81a00ff" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a> and let TurboJPEG grow the buffer as needed,</li>
<li>set <code>dstBufs[i]</code> to NULL to tell TurboJPEG to allocate the buffer for you, or</li>
-<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#ga68f4761dc5213cb9653a2f6ce236716e" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">TJBUFSIZE()</a> with the cropped width and height. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees this.)</li>
+<li>pre-allocate the buffer to a "worst case" size determined by calling <a class="el" href="group___turbo_j_p_e_g.html#gaccc5bca7f12fcdcc302e6e1c6d4b311b" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters...">tjBufSize()</a> with the cropped width and height. This should ensure that the buffer never has to be re-allocated (setting <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a> guarantees this.)</li>
</ol>
If you choose option 1, <code>dstSizes[i]</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>dstBufs[i]</code> upon return from this function, as it may have changed. </td></tr>
<tr><td class="paramname">dstSizes</td><td>pointer to an array of n unsigned long variables which will receive the actual sizes (in bytes) of each transformed JPEG image. If <code>dstBufs[i]</code> points to a pre-allocated buffer, then <code>dstSizes[i]</code> should be set to the size of the buffer. Upon return, <code>dstSizes[i]</code> will contain the size of the JPEG image (in bytes.) </td></tr>
@@ -1494,7 +1502,7 @@ If you choose option 1, <code>dstSizes[i]</code> should be set to the size of yo
</iframe>
</div>
-<hr class="footer"/><address class="footer"><small>Generated on Tue May 24 2011 11:59:01 for TurboJPEG by&#160;
+<hr class="footer"/><address class="footer"><small>Generated on Mon Jul 11 2011 22:02:02 for TurboJPEG by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
diff --git a/doc/html/index.html b/doc/html/index.html
index 9f751d4..2f24f32 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -69,7 +69,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe>
</div>
-<hr class="footer"/><address class="footer"><small>Generated on Tue May 24 2011 11:59:01 for TurboJPEG by&#160;
+<hr class="footer"/><address class="footer"><small>Generated on Mon Jul 11 2011 22:02:02 for TurboJPEG by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
diff --git a/doc/html/modules.html b/doc/html/modules.html
index 175581c..a9dd19e 100644
--- a/doc/html/modules.html
+++ b/doc/html/modules.html
@@ -72,7 +72,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
</iframe>
</div>
-<hr class="footer"/><address class="footer"><small>Generated on Tue May 24 2011 11:59:01 for TurboJPEG by&#160;
+<hr class="footer"/><address class="footer"><small>Generated on Mon Jul 11 2011 22:02:02 for TurboJPEG by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
diff --git a/doc/html/structtjregion.html b/doc/html/structtjregion.html
index 2b1df74..0f1762f 100644
--- a/doc/html/structtjregion.html
+++ b/doc/html/structtjregion.html
@@ -165,7 +165,7 @@ Data Fields</h2></td></tr>
</iframe>
</div>
-<hr class="footer"/><address class="footer"><small>Generated on Tue May 24 2011 11:59:01 for TurboJPEG by&#160;
+<hr class="footer"/><address class="footer"><small>Generated on Mon Jul 11 2011 22:02:02 for TurboJPEG by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
diff --git a/doc/html/structtjscalingfactor.html b/doc/html/structtjscalingfactor.html
index 51661e4..f0d23c6 100644
--- a/doc/html/structtjscalingfactor.html
+++ b/doc/html/structtjscalingfactor.html
@@ -127,7 +127,7 @@ Data Fields</h2></td></tr>
</iframe>
</div>
-<hr class="footer"/><address class="footer"><small>Generated on Tue May 24 2011 11:59:01 for TurboJPEG by&#160;
+<hr class="footer"/><address class="footer"><small>Generated on Mon Jul 11 2011 22:02:02 for TurboJPEG by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
diff --git a/doc/html/structtjtransform.html b/doc/html/structtjtransform.html
index 2c57025..61e8787 100644
--- a/doc/html/structtjtransform.html
+++ b/doc/html/structtjtransform.html
@@ -144,7 +144,7 @@ Data Fields</h2></td></tr>
</iframe>
</div>
-<hr class="footer"/><address class="footer"><small>Generated on Tue May 24 2011 11:59:01 for TurboJPEG by&#160;
+<hr class="footer"/><address class="footer"><small>Generated on Mon Jul 11 2011 22:02:02 for TurboJPEG by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
diff --git a/java/TJUnitTest.java b/java/TJUnitTest.java
index 80e6dbf..b0c44ad 100644
--- a/java/TJUnitTest.java
+++ b/java/TJUnitTest.java
@@ -682,7 +682,7 @@ public class TJUnitTest {
byte[] dstBuf;
if(yuv == YUVENCODE) dstBuf = new byte[TJ.bufSizeYUV(w, h, subsamp)];
- else dstBuf = new byte[TJ.bufSize(w, h)];
+ else dstBuf = new byte[TJ.bufSize(w, h, subsamp)];
try {
tjc = new TJCompressor();
@@ -726,7 +726,7 @@ public class TJUnitTest {
if(h % 100 == 0)
System.out.format("%04d x %04d\b\b\b\b\b\b\b\b\b\b\b", w, h);
srcBuf = new byte[w * h * 4];
- jpegBuf = new byte[TJ.bufSize(w, h)];
+ jpegBuf = new byte[TJ.bufSize(w, h, TJ.SAMP_444)];
Arrays.fill(srcBuf, (byte)0);
for(i = 0; i < w * h; i++) {
srcBuf[i * 4] = pixels[i % 9][0];
@@ -739,7 +739,7 @@ public class TJUnitTest {
tjc.compress(jpegBuf, 0);
srcBuf = new byte[h * w * 4];
- jpegBuf = new byte[TJ.bufSize(h, w)];
+ jpegBuf = new byte[TJ.bufSize(h, w, TJ.SAMP_444)];
for(i = 0; i < h * w; i++) {
if(i % 2 == 0) srcBuf[i * 4] =
srcBuf[i * 4 + 1] = srcBuf[i * 4 + 2] = (byte)0xFF;
diff --git a/java/doc/allclasses-frame.html b/java/doc/allclasses-frame.html
index 038f9ad..1ed402a 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
All Classes
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<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 964f111..dd2f4f1 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
All Classes
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<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 17936ea..abfbf15 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
Constant Field Values
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<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 ac6d82c..f8ea290 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
Deprecated List
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
diff --git a/java/doc/help-doc.html b/java/doc/help-doc.html
index 27fbb7f..1733e1f 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
API Help
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<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 af5f275..8940402 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
Index
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<LINK REL ="stylesheet" TYPE="text/css" HREF="./stylesheet.css" TITLE="Style">
@@ -80,10 +80,11 @@ function windowTitle()
<A NAME="_B_"><!-- --></A><H2>
<B>B</B></H2>
<DL>
-<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#bufSize(int, int)"><B>bufSize(int, int)</B></A> -
+<DT><A HREF="./org/libjpegturbo/turbojpeg/TJ.html#bufSize(int, int, int)"><B>bufSize(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 maximum size of the buffer (in bytes) required to hold a JPEG
- image with the given width and height.
+ image with the given width and 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>Returns the size of the buffer (in bytes) required to hold a YUV planar
diff --git a/java/doc/index.html b/java/doc/index.html
index abf4dd4..64965ea 100644
--- a/java/doc/index.html
+++ b/java/doc/index.html
@@ -2,7 +2,7 @@
<!--NewPage-->
<HTML>
<HEAD>
-<!-- Generated by javadoc on Fri Apr 01 20:49:05 CDT 2011-->
+<!-- Generated by javadoc on Mon Jul 11 21:40:35 CDT 2011-->
<TITLE>
Generated Documentation (Untitled)
</TITLE>
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJ.html b/java/doc/org/libjpegturbo/turbojpeg/TJ.html
index 86e33d6..6c07d32 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_24) on Fri Apr 01 20:49:04 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
TJ
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
@@ -309,12 +309,14 @@ TurboJPEG utility class (cannot be instantiated)
<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#bufSize(int, int)">bufSize</A></B>(int&nbsp;width,
- int&nbsp;height)</CODE>
+<TD><CODE><B><A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSize(int, int, int)">bufSize</A></B>(int&nbsp;width,
+ int&nbsp;height,
+ int&nbsp;jpegSubsamp)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the maximum size of the buffer (in bytes) required to hold a JPEG
- image with the given width and height.</TD>
+ image with the given width and height, and level of chrominance
+ subsampling.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
@@ -821,20 +823,24 @@ public static int <B>getBlueOffset</B>(int&nbsp;pixelFormat)
</DL>
<HR>
-<A NAME="bufSize(int, int)"><!-- --></A><H3>
+<A NAME="bufSize(int, int, int)"><!-- --></A><H3>
bufSize</H3>
<PRE>
public static int <B>bufSize</B>(int&nbsp;width,
- int&nbsp;height)
+ int&nbsp;height,
+ int&nbsp;jpegSubsamp)
throws java.lang.Exception</PRE>
<DL>
<DD>Returns the maximum size of the buffer (in bytes) required to hold a JPEG
- image with the given width and height.
+ image with the given width and height, and level of chrominance
+ subsampling.
<P>
<DD><DL>
-<DT><B>Parameters:</B><DD><CODE>width</CODE> - the width (in pixels) of the JPEG image<DD><CODE>height</CODE> - the height (in pixels) of the JPEG image
+<DT><B>Parameters:</B><DD><CODE>width</CODE> - the width (in pixels) of the JPEG image<DD><CODE>height</CODE> - the height (in pixels) of the JPEG image<DD><CODE>jpegSubsamp</CODE> - the level of chrominance subsampling to be used when
+ generating the JPEG 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 maximum size of the buffer (in bytes) required to hold a JPEG
- image with the given width and height
+ image with the given width and height, and level of chrominance
+ subsampling
<DT><B>Throws:</B>
<DD><CODE>java.lang.Exception</CODE></DL>
</DD>
@@ -854,7 +860,7 @@ public static int <B>bufSizeYUV</B>(int&nbsp;width,
<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
- image
+ 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
<DT><B>Throws:</B>
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html
index b9a8fc4..566c877 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
TJCompressor
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
@@ -421,7 +421,7 @@ public void <B>compress</B>(byte[]&nbsp;dstBuf,
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>dstBuf</CODE> - buffer which will receive the JPEG image. Use
- <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSize(int, int)"><CODE>TJ.bufSize(int, int)</CODE></A> to determine the maximum size for this buffer based on
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSize(int, int, int)"><CODE>TJ.bufSize(int, int, int)</CODE></A> to determine the maximum size for this buffer based on
the image width and height.<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>
@@ -462,7 +462,7 @@ public void <B>compress</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 compressed<DD><CODE>dstBuf</CODE> - buffer which will receive the JPEG image. Use
- <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSize(int, int)"><CODE>TJ.bufSize(int, int)</CODE></A> to determine the maximum size for this buffer based on
+ <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSize(int, int, int)"><CODE>TJ.bufSize(int, int, int)</CODE></A> to determine the maximum size for this buffer based on
the image width and height.<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/TJDecompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
index f610afe..4d37d71 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
TJDecompressor
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html b/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html
index 867f418..166acfb 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
TJScalingFactor
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<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 fecccea..bb64cc3 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
TJTransform
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<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 d3da485..280b82f 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
TJTransformer
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
@@ -313,7 +313,7 @@ public void <B>transform</B>(byte[][]&nbsp;dstBufs,
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>dstBufs</CODE> - an array of image buffers. <code>dstbufs[i]</code> will
receive a JPEG image that has been transformed using the parameters in
- <code>transforms[i]</code>. Use <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSize(int, int)"><CODE>TJ.bufSize(int, int)</CODE></A> to determine the
+ <code>transforms[i]</code>. Use <A HREF="../../../org/libjpegturbo/turbojpeg/TJ.html#bufSize(int, int, int)"><CODE>TJ.bufSize(int, int, int)</CODE></A> to determine the
maximum size for each buffer based on the cropped width and height.<DD><CODE>transforms</CODE> - an array of <A HREF="../../../org/libjpegturbo/turbojpeg/TJTransform.html" title="class in org.libjpegturbo.turbojpeg"><CODE>TJTransform</CODE></A> instances, each of
which specifies the transform parameters and/or cropping region for the
corresponding transformed output image<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>
diff --git a/java/doc/org/libjpegturbo/turbojpeg/package-frame.html b/java/doc/org/libjpegturbo/turbojpeg/package-frame.html
index 4338f9b..cb1e2b8 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
org.libjpegturbo.turbojpeg
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<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 733d88d..caf1b95 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
org.libjpegturbo.turbojpeg
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<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 ee04a10..58d8672 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
org.libjpegturbo.turbojpeg Class Hierarchy
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<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 8a19a88..6ba3d6d 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
Class Hierarchy
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<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 90d6ff8..3f08701 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_24) on Fri Apr 01 20:49:05 CDT 2011 -->
+<!-- Generated by javadoc (build 1.6.0_26) on Mon Jul 11 21:40:35 CDT 2011 -->
<TITLE>
Serialized Form
</TITLE>
-<META NAME="date" CONTENT="2011-04-01">
+<META NAME="date" CONTENT="2011-07-11">
<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 3941b53..cd22ee0 100644
--- a/java/org/libjpegturbo/turbojpeg/TJ.java
+++ b/java/org/libjpegturbo/turbojpeg/TJ.java
@@ -271,16 +271,21 @@ final public class TJ {
/**
* Returns the maximum size of the buffer (in bytes) required to hold a JPEG
- * image with the given width and height.
+ * image with the given width and height, and level of chrominance
+ * subsampling.
*
* @param width the width (in pixels) of the JPEG image
*
* @param height the height (in pixels) of the JPEG image
*
+ * @param jpegSubsamp the level of chrominance subsampling to be used when
+ * generating the JPEG image (one of {@link TJ TJ.SAMP_*})
+ *
* @return the maximum size of the buffer (in bytes) required to hold a JPEG
- * image with the given width and height
+ * image with the given width and height, and level of chrominance
+ * subsampling
*/
- public native static int bufSize(int width, int height)
+ public native static int bufSize(int width, int height, int jpegSubsamp)
throws Exception;
/**
@@ -292,7 +297,7 @@ final public class TJ {
* @param height the height (in pixels) of the YUV image
*
* @param subsamp the level of chrominance subsampling used in the YUV
- * image
+ * image (one of {@link TJ TJ.SAMP_*})
*
* @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
diff --git a/java/org/libjpegturbo/turbojpeg/TJCompressor.java b/java/org/libjpegturbo/turbojpeg/TJCompressor.java
index de32227..1029139 100644
--- a/java/org/libjpegturbo/turbojpeg/TJCompressor.java
+++ b/java/org/libjpegturbo/turbojpeg/TJCompressor.java
@@ -160,7 +160,7 @@ public class TJCompressor {
public byte[] compress(int flags) throws Exception {
if(srcWidth < 1 || srcHeight < 1)
throw new Exception(NO_ASSOC_ERROR);
- byte[] buf = new byte[TJ.bufSize(srcWidth, srcHeight)];
+ byte[] buf = new byte[TJ.bufSize(srcWidth, srcHeight, subsamp)];
compress(buf, flags);
return buf;
}
@@ -249,7 +249,7 @@ public class TJCompressor {
public byte[] compress(BufferedImage srcImage, int flags) throws Exception {
int width = srcImage.getWidth();
int height = srcImage.getHeight();
- byte[] buf = new byte[TJ.bufSize(width, height)];
+ byte[] buf = new byte[TJ.bufSize(width, height, subsamp)];
compress(srcImage, buf, flags);
return buf;
}
diff --git a/java/org/libjpegturbo/turbojpeg/TJTransformer.java b/java/org/libjpegturbo/turbojpeg/TJTransformer.java
index 78c4c9d..6c07483 100644
--- a/java/org/libjpegturbo/turbojpeg/TJTransformer.java
+++ b/java/org/libjpegturbo/turbojpeg/TJTransformer.java
@@ -123,7 +123,7 @@ public class TJTransformer extends TJDecompressor {
if(transforms[i].width != 0) w = transforms[i].width;
if(transforms[i].height != 0) h = transforms[i].height;
}
- dstBufs[i] = new byte[TJ.bufSize(w, h)];
+ dstBufs[i] = new byte[TJ.bufSize(w, h, jpegSubsamp)];
}
TJDecompressor[] tjd = new TJDecompressor[transforms.length];
transform(dstBufs, transforms, flags);
diff --git a/java/org_libjpegturbo_turbojpeg_TJ.h b/java/org_libjpegturbo_turbojpeg_TJ.h
index ab68bd5..54479be 100644
--- a/java/org_libjpegturbo_turbojpeg_TJ.h
+++ b/java/org_libjpegturbo_turbojpeg_TJ.h
@@ -50,10 +50,10 @@ extern "C" {
/*
* Class: org_libjpegturbo_turbojpeg_TJ
* Method: bufSize
- * Signature: (II)I
+ * Signature: (III)I
*/
JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSize
- (JNIEnv *, jclass, jint, jint);
+ (JNIEnv *, jclass, jint, jint, jint);
/*
* Class: org_libjpegturbo_turbojpeg_TJ
@@ -66,7 +66,7 @@ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV
/*
* Class: org_libjpegturbo_turbojpeg_TJ
* Method: getScalingFactors
- * Signature: ()[Lorg/libjpegturbo/turbojpeg/TJ/ScalingFactor;
+ * Signature: ()[Lorg/libjpegturbo/turbojpeg/TJScalingFactor;
*/
JNIEXPORT jobjectArray JNICALL Java_org_libjpegturbo_turbojpeg_TJ_getScalingFactors
(JNIEnv *, jclass);
diff --git a/tjbench.c b/tjbench.c
index ed48bc4..48332ec 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -83,7 +83,7 @@ int decomptest(unsigned char *srcbuf, unsigned char **jpegbuf,
int row, col, i, dstbufalloc=0, retval=0;
double start, elapsed;
int ps=tjPixelSize[pf];
- int yuvsize=TJBUFSIZEYUV(w, h, subsamp), bufsize;
+ int yuvsize=tjBufSizeYUV(w, h, subsamp), bufsize;
int scaledw=(yuv==YUVDECODE)? w : TJSCALED(w, sf);
int scaledh=(yuv==YUVDECODE)? h : TJSCALED(h, sf);
int pitch=scaledw*ps;
@@ -237,7 +237,7 @@ void dotestyuv(unsigned char *srcbuf, int w, int h, int subsamp,
int i, retval=0, ps=tjPixelSize[pf];
int yuvsize=0;
- yuvsize=TJBUFSIZEYUV(w, h, subsamp);
+ yuvsize=tjBufSizeYUV(w, h, subsamp);
if((dstbuf=(unsigned char *)malloc(yuvsize)) == NULL)
_throwunix("allocating image buffer");
@@ -341,7 +341,8 @@ void dotest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
if((flags&TJFLAG_NOREALLOC)!=0)
for(i=0; i<ntilesw*ntilesh; i++)
{
- if((jpegbuf[i]=(unsigned char *)malloc(TJBUFSIZE(tilew, tileh)))==NULL)
+ if((jpegbuf[i]=(unsigned char *)malloc(tjBufSize(tilew, tileh,
+ subsamp)))==NULL)
_throwunix("allocating JPEG tiles");
}
@@ -511,7 +512,8 @@ void dodecomptest(char *filename)
if((flags&TJFLAG_NOREALLOC)!=0)
for(i=0; i<ntilesw*ntilesh; i++)
{
- if((jpegbuf[i]=(unsigned char *)malloc(TJBUFSIZE(tilew, tileh)))==NULL)
+ if((jpegbuf[i]=(unsigned char *)malloc(tjBufSize(tilew, tileh,
+ subsamp)))==NULL)
_throwunix("allocating JPEG tiles");
}
diff --git a/tjunittest.c b/tjunittest.c
index 3fd7948..9acab0a 100644
--- a/tjunittest.c
+++ b/tjunittest.c
@@ -366,7 +366,8 @@ void compTest(tjhandle handle, unsigned char **dstBuf,
if(!alloc)
{
flags|=TJFLAG_NOREALLOC;
- *dstSize=(yuv==YUVENCODE? TJBUFSIZEYUV(w, h, subsamp):TJBUFSIZE(w, h));
+ *dstSize=(yuv==YUVENCODE? tjBufSizeYUV(w, h, subsamp)
+ : tjBufSize(w, h, subsamp));
}
_tj(tjCompress2(handle, srcBuf, w, 0, h, pf, dstBuf, dstSize, subsamp,
jpegQual, flags));
@@ -422,7 +423,7 @@ void _decompTest(tjhandle handle, unsigned char *jpegBuf,
if(_hdrw!=w || _hdrh!=h || _hdrsubsamp!=subsamp)
_throw("Incorrect JPEG header");
- if(yuv==YUVDECODE) dstSize=TJBUFSIZEYUV(w, h, subsamp);
+ if(yuv==YUVDECODE) dstSize=tjBufSizeYUV(w, h, subsamp);
else dstSize=scaledWidth*scaledHeight*tjPixelSize[pf];
if((dstBuf=(unsigned char *)malloc(dstSize))==NULL)
_throw("Memory allocation failure");
@@ -490,7 +491,8 @@ void doTest(int w, int h, const int *formats, int nformats, int subsamp,
if(!alloc)
{
- size=(yuv==YUVENCODE? TJBUFSIZEYUV(w, h, subsamp):TJBUFSIZE(w, h));
+ size=(yuv==YUVENCODE? tjBufSizeYUV(w, h, subsamp)
+ : tjBufSize(w, h, subsamp));
if((dstBuf=(unsigned char *)tjAlloc(size))==NULL)
_throw("Memory allocation failure.");
}
@@ -544,9 +546,10 @@ void doTest1(void)
_throw("Memory allocation failure");
if(!alloc)
{
- if((jpegBuf=(unsigned char *)tjAlloc(TJBUFSIZE(w, h)))==NULL)
+ if((jpegBuf=(unsigned char *)tjAlloc(tjBufSize(w, h, TJSAMP_444)))
+ ==NULL)
_throw("Memory allocation failure");
- jpegSize=TJBUFSIZE(w, h);
+ jpegSize=tjBufSize(w, h, TJSAMP_444);
}
memset(srcBuf, 0, w*h*4);
@@ -561,9 +564,10 @@ void doTest1(void)
_throw("Memory allocation failure");
if(!alloc)
{
- if((jpegBuf=(unsigned char *)tjAlloc(TJBUFSIZE(h, w)))==NULL)
+ if((jpegBuf=(unsigned char *)tjAlloc(tjBufSize(h, w, TJSAMP_444)))
+ ==NULL)
_throw("Memory allocation failure");
- jpegSize=TJBUFSIZE(h, w);
+ jpegSize=tjBufSize(h, w, TJSAMP_444);
}
for(i=0; i<h*w; i++)
diff --git a/turbojpeg-jni.c b/turbojpeg-jni.c
index 3c98880..75123b5 100644
--- a/turbojpeg-jni.c
+++ b/turbojpeg-jni.c
@@ -51,9 +51,9 @@
handle=(tjhandle)(jlong)(*env)->GetLongField(env, obj, _fid); \
JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSize
- (JNIEnv *env, jclass cls, jint width, jint height)
+ (JNIEnv *env, jclass cls, jint width, jint height, jint jpegSubsamp)
{
- jint retval=(jint)TJBUFSIZE(width, height);
+ jint retval=(jint)tjBufSize(width, height, jpegSubsamp);
if(retval==-1) _throw(tjGetErrorStr());
bailout:
@@ -63,7 +63,7 @@ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSize
JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV
(JNIEnv *env, jclass cls, jint width, jint height, jint subsamp)
{
- jint retval=(jint)TJBUFSIZEYUV(width, height, subsamp);
+ jint retval=(jint)tjBufSizeYUV(width, height, subsamp);
if(retval==-1) _throw(tjGetErrorStr());
bailout:
@@ -108,7 +108,7 @@ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compress___3
arraySize=(pitch==0)? width*tjPixelSize[pf]*height:pitch*height;
if((*env)->GetArrayLength(env, src)<arraySize)
_throw("Source buffer is not large enough");
- jpegSize=TJBUFSIZE(width, height);
+ jpegSize=tjBufSize(width, height, jpegSubsamp);
if((*env)->GetArrayLength(env, dst)<(jsize)jpegSize)
_throw("Destination buffer is not large enough");
@@ -152,7 +152,7 @@ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compress___3
arraySize=(pitch==0)? width*height:pitch*height;
if((*env)->GetArrayLength(env, src)<arraySize)
_throw("Source buffer is not large enough");
- jpegSize=TJBUFSIZE(width, height);
+ jpegSize=tjBufSize(width, height, jpegSubsamp);
if((*env)->GetArrayLength(env, dst)<(jsize)jpegSize)
_throw("Destination buffer is not large enough");
@@ -194,7 +194,7 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___
if((*env)->GetArrayLength(env, src)<arraySize)
_throw("Source buffer is not large enough");
if((*env)->GetArrayLength(env, dst)
- <(jsize)TJBUFSIZEYUV(width, height, subsamp))
+ <(jsize)tjBufSizeYUV(width, height, subsamp))
_throw("Destination buffer is not large enough");
bailif0(srcBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
@@ -237,7 +237,7 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___
if((*env)->GetArrayLength(env, src)<arraySize)
_throw("Source buffer is not large enough");
if((*env)->GetArrayLength(env, dst)
- <(jsize)TJBUFSIZEYUV(width, height, subsamp))
+ <(jsize)tjBufSizeYUV(width, height, subsamp))
_throw("Destination buffer is not large enough");
bailif0(srcBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
@@ -449,7 +449,7 @@ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress
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))
+ <(jsize)tjBufSizeYUV(jpegWidth, jpegHeight, jpegSubsamp))
_throw("Destination buffer is not large enough");
bailif0(jpegBuf=(*env)->GetPrimitiveArrayCritical(env, src, 0));
@@ -495,7 +495,7 @@ JNIEXPORT jintArray JNICALL Java_org_libjpegturbo_turbojpeg_TJTransformer_transf
unsigned char *jpegBuf=NULL, **dstBufs=NULL; jsize n=0;
unsigned long *dstSizes=NULL; tjtransform *t=NULL;
jbyteArray *jdstBufs=NULL;
- int jpegWidth=0, jpegHeight=0;
+ int jpegWidth=0, jpegHeight=0, jpegSubsamp;
jintArray jdstSizes=0; jint *dstSizesi=NULL;
gethandle();
@@ -506,6 +506,8 @@ JNIEXPORT jintArray JNICALL Java_org_libjpegturbo_turbojpeg_TJTransformer_transf
jpegWidth=(int)(*env)->GetIntField(env, obj, _fid);
bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegHeight", "I"));
jpegHeight=(int)(*env)->GetIntField(env, obj, _fid);
+ bailif0(_fid=(*env)->GetFieldID(env, _cls, "jpegSubsamp", "I"));
+ jpegSubsamp=(int)(*env)->GetIntField(env, obj, _fid);
n=(*env)->GetArrayLength(env, dstobjs);
if(n!=(*env)->GetArrayLength(env, tobjs))
@@ -552,7 +554,7 @@ JNIEXPORT jintArray JNICALL Java_org_libjpegturbo_turbojpeg_TJTransformer_transf
if(t[i].r.w!=0) w=t[i].r.w;
if(t[i].r.h!=0) h=t[i].r.h;
bailif0(jdstBufs[i]=(*env)->GetObjectArrayElement(env, dstobjs, i));
- if((*env)->GetArrayLength(env, jdstBufs[i])<TJBUFSIZE(w, h))
+ if((*env)->GetArrayLength(env, jdstBufs[i])<tjBufSize(w, h, jpegSubsamp))
_throw("Destination buffer is not large enough");
bailif0(dstBufs[i]=(*env)->GetPrimitiveArrayCritical(env, jdstBufs[i], 0));
}
diff --git a/turbojpeg-mapfile b/turbojpeg-mapfile
index 0e704ec..bd1ac71 100755
--- a/turbojpeg-mapfile
+++ b/turbojpeg-mapfile
@@ -26,6 +26,8 @@ TURBOJPEG_1.2
{
global:
tjAlloc;
+ tjBufSize;
+ tjBufSizeYUV;
tjCompress2;
tjDecompress2;
tjEncodeYUV2;
diff --git a/turbojpeg-mapfile.jni b/turbojpeg-mapfile.jni
index 1465ad2..9c046ce 100755
--- a/turbojpeg-mapfile.jni
+++ b/turbojpeg-mapfile.jni
@@ -26,6 +26,8 @@ TURBOJPEG_1.2
{
global:
tjAlloc;
+ tjBufSize;
+ tjBufSizeYUV;
tjCompress2;
tjDecompress2;
tjEncodeYUV2;
diff --git a/turbojpeg.c b/turbojpeg.c
index c890bc0..5f097a9 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -217,6 +217,34 @@ static void setDecompDefaults(struct jpeg_decompress_struct *dinfo,
}
+static int getSubsamp(j_decompress_ptr dinfo)
+{
+ int retval=-1, i, k;
+ for(i=0; i<NUMSUBOPT; i++)
+ {
+ if(dinfo->num_components==pixelsize[i])
+ {
+ if(dinfo->comp_info[0].h_samp_factor==tjMCUWidth[i]/8
+ && dinfo->comp_info[0].v_samp_factor==tjMCUHeight[i]/8)
+ {
+ int match=0;
+ for(k=1; k<dinfo->num_components; k++)
+ {
+ if(dinfo->comp_info[k].h_samp_factor==1
+ && dinfo->comp_info[k].v_samp_factor==1)
+ match++;
+ }
+ if(match==dinfo->num_components-1)
+ {
+ retval=i; break;
+ }
+ }
+ }
+ }
+ return retval;
+}
+
+
/* General API functions */
DLLEXPORT char* DLLCALL tjGetErrorStr(void)
@@ -292,6 +320,26 @@ DLLEXPORT tjhandle DLLCALL tjInitCompress(void)
}
+DLLEXPORT unsigned long DLLCALL tjBufSize(int width, int height,
+ int jpegSubsamp)
+{
+ unsigned long retval=0; int mcuw, mcuh, chromasf;
+ if(width<1 || height<1 || jpegSubsamp<0 || jpegSubsamp>=NUMSUBOPT)
+ _throw("tjBufSize(): Invalid argument");
+
+ // This allows for rare corner cases in which a JPEG image can actually be
+ // larger than the uncompressed input (we wouldn't mention it if it hadn't
+ // happened before.)
+ mcuw=tjMCUWidth[jpegSubsamp];
+ mcuh=tjMCUHeight[jpegSubsamp];
+ chromasf=jpegSubsamp==TJSAMP_GRAY? 0: 4*64/(mcuw*mcuh);
+ retval=PAD(width, mcuw) * PAD(height, mcuh) * (2 + chromasf) + 2048;
+
+ bailout:
+ return retval;
+}
+
+
DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height)
{
unsigned long retval=0;
@@ -308,13 +356,13 @@ DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height)
}
-DLLEXPORT unsigned long DLLCALL TJBUFSIZEYUV(int width, int height,
+DLLEXPORT unsigned long DLLCALL tjBufSizeYUV(int width, int height,
int subsamp)
{
unsigned long retval=0;
int pw, ph, cw, ch;
if(width<1 || height<1 || subsamp<0 || subsamp>=NUMSUBOPT)
- _throw("TJBUFSIZEYUV(): Invalid argument");
+ _throw("tjBufSizeYUV(): Invalid argument");
pw=PAD(width, tjMCUWidth[subsamp]/8);
ph=PAD(height, tjMCUHeight[subsamp]/8);
cw=pw*8/tjMCUWidth[subsamp]; ch=ph*8/tjMCUHeight[subsamp];
@@ -325,6 +373,13 @@ DLLEXPORT unsigned long DLLCALL TJBUFSIZEYUV(int width, int height,
}
+DLLEXPORT unsigned long DLLCALL TJBUFSIZEYUV(int width, int height,
+ int subsamp)
+{
+ return tjBufSizeYUV(width, height, subsamp);
+}
+
+
DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, unsigned char *srcBuf,
int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf,
unsigned long *jpegSize, int jpegSubsamp, int jpegQual, int flags)
@@ -358,7 +413,7 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, unsigned char *srcBuf,
if(flags&TJFLAG_NOREALLOC)
{
- alloc=0; *jpegSize=TJBUFSIZE(width, height);
+ alloc=0; *jpegSize=tjBufSize(width, height, jpegSubsamp);
}
jpeg_mem_dest_tj(cinfo, jpegBuf, jpegSize, alloc);
setCompDefaults(cinfo, pixelFormat, jpegSubsamp, jpegQual);
@@ -391,7 +446,7 @@ DLLEXPORT int DLLCALL tjCompress(tjhandle handle, unsigned char *srcBuf,
int retval=0; unsigned long size;
if(flags&TJ_YUV)
{
- size=TJBUFSIZEYUV(width, height, jpegSubsamp);
+ size=tjBufSizeYUV(width, height, jpegSubsamp);
retval=tjEncodeYUV2(handle, srcBuf, width, pitch, height,
getPixelFormat(pixelSize, flags), jpegBuf, jpegSubsamp, flags);
}
@@ -450,7 +505,7 @@ DLLEXPORT int DLLCALL tjEncodeYUV2(tjhandle handle, unsigned char *srcBuf,
else if(flags&TJFLAG_FORCESSE) putenv("JSIMD_FORCESSE=1");
else if(flags&TJFLAG_FORCESSE2) putenv("JSIMD_FORCESSE2=1");
- yuvsize=TJBUFSIZEYUV(width, height, subsamp);
+ yuvsize=tjBufSizeYUV(width, height, subsamp);
jpeg_mem_dest_tj(cinfo, &dstBuf, &yuvsize, 0);
setCompDefaults(cinfo, pixelFormat, subsamp, -1);
@@ -589,7 +644,7 @@ DLLEXPORT int DLLCALL tjDecompressHeader2(tjhandle handle,
unsigned char *jpegBuf, unsigned long jpegSize, int *width, int *height,
int *jpegSubsamp)
{
- int i, k, retval=0;
+ int retval=0;
getinstance(handle);
if((this->init&DECOMPRESS)==0)
@@ -610,28 +665,7 @@ DLLEXPORT int DLLCALL tjDecompressHeader2(tjhandle handle,
*width=dinfo->image_width;
*height=dinfo->image_height;
- *jpegSubsamp=-1;
- for(i=0; i<NUMSUBOPT; i++)
- {
- if(dinfo->num_components==pixelsize[i])
- {
- if(dinfo->comp_info[0].h_samp_factor==tjMCUWidth[i]/8
- && dinfo->comp_info[0].v_samp_factor==tjMCUHeight[i]/8)
- {
- int match=0;
- for(k=1; k<dinfo->num_components; k++)
- {
- if(dinfo->comp_info[k].h_samp_factor==1
- && dinfo->comp_info[k].v_samp_factor==1)
- match++;
- }
- if(match==dinfo->num_components-1)
- {
- *jpegSubsamp=i; break;
- }
- }
- }
- }
+ *jpegSubsamp=getSubsamp(dinfo);
jpeg_abort_decompress(dinfo);
@@ -892,7 +926,7 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle handle, unsigned char *jpegBuf,
{
jpeg_transform_info *xinfo=NULL;
jvirt_barray_ptr *srccoefs, *dstcoefs;
- int retval=0, i;
+ int retval=0, i, jpegSubsamp;
getinstance(handle);
if((this->init&COMPRESS)==0 || (this->init&DECOMPRESS)==0)
@@ -949,6 +983,9 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle handle, unsigned char *jpegBuf,
jcopy_markers_setup(dinfo, JCOPYOPT_ALL);
jpeg_read_header(dinfo, TRUE);
+ jpegSubsamp=getSubsamp(dinfo);
+ if(jpegSubsamp<0)
+ _throw("tjTransform(): Could not determine subsampling type for JPEG image");
for(i=0; i<n; i++)
{
@@ -984,7 +1021,7 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle handle, unsigned char *jpegBuf,
}
if(flags&TJFLAG_NOREALLOC)
{
- alloc=0; dstSizes[i]=TJBUFSIZE(w, h);
+ alloc=0; dstSizes[i]=tjBufSize(w, h, jpegSubsamp);
}
jpeg_mem_dest_tj(cinfo, &dstBufs[i], &dstSizes[i], alloc);
jpeg_copy_critical_parameters(dinfo, cinfo);
diff --git a/turbojpeg.h b/turbojpeg.h
index cf85793..e4c5779 100644
--- a/turbojpeg.h
+++ b/turbojpeg.h
@@ -437,7 +437,7 @@ DLLEXPORT tjhandle DLLCALL tjInitCompress(void);
* -# set <tt>*jpegBuf</tt> to NULL to tell TurboJPEG to allocate the
* buffer for you, or
* -# pre-allocate the buffer to a "worst case" size determined by
- * calling #TJBUFSIZE(). This should ensure that the buffer never has
+ * calling #tjBufSize(). This should ensure that the buffer never has
* to be re-allocated (setting #TJFLAG_NOREALLOC guarantees this.)
* .
* If you choose option 1, <tt>*jpegSize</tt> should be set to the
@@ -466,15 +466,26 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, unsigned char *srcBuf,
/**
* The maximum size of the buffer (in bytes) required to hold a JPEG image with
- * the given parameters.
+ * the given parameters. The number of bytes returned by this function is
+ * larger than the size of the uncompressed source image. The reason for this
+ * is that the JPEG format uses 16-bit coefficients, and it is thus possible
+ * for a very high-quality JPEG image with very high frequency content to
+ * expand rather than compress when converted to the JPEG format. Such images
+ * represent a very rare corner case, but since there is no way to predict the
+ * size of a JPEG image prior to compression, the corner case has to be
+ * handled.
*
* @param width width of the image (in pixels)
* @param height height of the image (in pixels)
+ * @param jpegSubsamp the level of chrominance subsampling to be used when
+ * generating the JPEG image (see @ref TJSAMP
+ * "Chrominance subsampling options".)
*
* @return the maximum size of the buffer (in bytes) required to hold the
* image, or -1 if the arguments are out of bounds.
*/
-DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height);
+DLLEXPORT unsigned long DLLCALL tjBufSize(int width, int height,
+ int jpegSubsamp);
/**
@@ -483,14 +494,14 @@ DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height);
*
* @param width width of the image (in pixels)
* @param height height of the image (in pixels)
- * @param jpegSubsamp level of chrominance subsampling in the image (see
+ * @param subsamp level of chrominance subsampling in the image (see
* @ref TJSAMP "Chrominance subsampling options".)
*
* @return the size of the buffer (in bytes) required to hold the image, or
* -1 if the arguments are out of bounds.
*/
-DLLEXPORT unsigned long DLLCALL TJBUFSIZEYUV(int width, int height,
- int jpegSubsamp);
+DLLEXPORT unsigned long DLLCALL tjBufSizeYUV(int width, int height,
+ int subsamp);
/**
@@ -521,7 +532,7 @@ DLLEXPORT unsigned long DLLCALL TJBUFSIZEYUV(int width, int height,
* @param pixelFormat pixel format of the source image (see @ref TJPF
* "Pixel formats".)
* @param dstBuf pointer to an image buffer which will receive the YUV image.
- * Use #TJBUFSIZEYUV() to determine the appropriate size for this buffer
+ * Use #tjBufSizeYUV() to determine the appropriate size for this buffer
* based on the image width, height, and level of chrominance
* subsampling.
* @param subsamp the level of chrominance subsampling to be used when
@@ -640,7 +651,7 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
* @param jpegBuf pointer to a buffer containing the JPEG image to decompress
* @param jpegSize size of the JPEG image (in bytes)
* @param dstBuf pointer to an image buffer which will receive the YUV image.
- * Use #TJBUFSIZEYUV to determine the appropriate size for this buffer
+ * Use #tjBufSizeYUV to determine the appropriate size for this buffer
* based on the image width, height, and level of subsampling.
* @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
* "flags".
@@ -688,7 +699,7 @@ DLLEXPORT tjhandle DLLCALL tjInitTransform(void);
* -# set <tt>dstBufs[i]</tt> to NULL to tell TurboJPEG to allocate the
* buffer for you, or
* -# pre-allocate the buffer to a "worst case" size determined by
- * calling #TJBUFSIZE() with the cropped width and height. This should
+ * calling #tjBufSize() with the cropped width and height. This should
* ensure that the buffer never has to be re-allocated (setting
* #TJFLAG_NOREALLOC guarantees this.)
* .
@@ -781,6 +792,11 @@ DLLEXPORT char* DLLCALL tjGetErrorStr(void);
#define TJ_FASTUPSAMPLE TJFLAG_FASTUPSAMPLE
#define TJ_YUV 512
+DLLEXPORT unsigned long DLLCALL TJBUFSIZE(int width, int height);
+
+DLLEXPORT unsigned long DLLCALL TJBUFSIZEYUV(int width, int height,
+ int jpegSubsamp);
+
DLLEXPORT int DLLCALL tjCompress(tjhandle handle, unsigned char *srcBuf,
int width, int pitch, int height, int pixelSize, unsigned char *dstBuf,
unsigned long *compressedSize, int jpegSubsamp, int jpegQual, int flags);