and should now be much more intuitive.
-- The Java API now supports encoding a YUV image from an arbitrary position in
a large image buffer.
+-- All of the YUV functions now have a corresponding function that operates on
+separate image planes instead of a unified image buffer. This allows for
+compressing/decoding a YUV image from or decompressing/encoding a YUV image to
+an arbitrary position in a larger YUV image. It also allows for handling YUV
+formats that swap the order of the U and V planes.
[2] Added SIMD acceleration for DSPr2-capable MIPS platforms. This speeds up
the compression of full-color JPEGs by 70-80% on such platforms and
<tr class="memitem:ga0b931126c7a615ddc3bbd0cca6698d67"><td class="memItemLeft" align="right" valign="top">DLLEXPORT int DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga0b931126c7a615ddc3bbd0cca6698d67">tjCompressFromYUV</a> (<a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> handle, unsigned char *srcBuf, int width, int pad, int height, int subsamp, unsigned char **jpegBuf, unsigned long *jpegSize, int jpegQual, int flags)</td></tr>
<tr class="memdesc:ga0b931126c7a615ddc3bbd0cca6698d67"><td class="mdescLeft"> </td><td class="mdescRight">Compress a YUV planar image into a JPEG image. <a href="#ga0b931126c7a615ddc3bbd0cca6698d67">More...</a><br/></td></tr>
<tr class="separator:ga0b931126c7a615ddc3bbd0cca6698d67"><td class="memSeparator" colspan="2"> </td></tr>
+<tr class="memitem:gab87b2b19ee8bdd8dba395b74d66a4835"><td class="memItemLeft" align="right" valign="top">DLLEXPORT int DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#gab87b2b19ee8bdd8dba395b74d66a4835">tjCompressFromYUVPlanes</a> (<a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> handle, unsigned char **srcBufs, int width, int *strides, int height, int subsamp, unsigned char **jpegBuf, unsigned long *jpegSize, int jpegQual, int flags)</td></tr>
+<tr class="memdesc:gab87b2b19ee8bdd8dba395b74d66a4835"><td class="mdescLeft"> </td><td class="mdescRight">Compress a set of Y, U (Cb), and V (Cr) image planes into a JPEG image. <a href="#gab87b2b19ee8bdd8dba395b74d66a4835">More...</a><br/></td></tr>
+<tr class="separator:gab87b2b19ee8bdd8dba395b74d66a4835"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gaccc5bca7f12fcdcc302e6e1c6d4b311b"><td class="memItemLeft" align="right" valign="top">DLLEXPORT unsigned long DLLCALL </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 class="memdesc:gaccc5bca7f12fcdcc302e6e1c6d4b311b"><td class="mdescLeft"> </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">More...</a><br/></td></tr>
<tr class="separator:gaccc5bca7f12fcdcc302e6e1c6d4b311b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga0a5ffbf7cb58a5b6a8201114fe889360"><td class="memItemLeft" align="right" valign="top">DLLEXPORT int DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga0a5ffbf7cb58a5b6a8201114fe889360">tjEncodeYUV3</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 pad, int subsamp, int flags)</td></tr>
<tr class="memdesc:ga0a5ffbf7cb58a5b6a8201114fe889360"><td class="mdescLeft"> </td><td class="mdescRight">Encode an RGB or grayscale image into a YUV planar image. <a href="#ga0a5ffbf7cb58a5b6a8201114fe889360">More...</a><br/></td></tr>
<tr class="separator:ga0a5ffbf7cb58a5b6a8201114fe889360"><td class="memSeparator" colspan="2"> </td></tr>
+<tr class="memitem:gaa791db8598853ddcad24e42897ef1269"><td class="memItemLeft" align="right" valign="top">DLLEXPORT int DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#gaa791db8598853ddcad24e42897ef1269">tjEncodeYUVPlanes</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 **dstPlanes, int *strides, int subsamp, int flags)</td></tr>
+<tr class="memdesc:gaa791db8598853ddcad24e42897ef1269"><td class="mdescLeft"> </td><td class="mdescRight">Encode an RGB or grayscale image into separate Y, U (Cb), and V (Cr) image planes. <a href="#gaa791db8598853ddcad24e42897ef1269">More...</a><br/></td></tr>
+<tr class="separator:gaa791db8598853ddcad24e42897ef1269"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:gae5408179d041e2a2f7199c8283cf649e"><td class="memItemLeft" align="right" valign="top">DLLEXPORT <a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#gae5408179d041e2a2f7199c8283cf649e">tjInitDecompress</a> (void)</td></tr>
<tr class="memdesc:gae5408179d041e2a2f7199c8283cf649e"><td class="mdescLeft"> </td><td class="mdescRight">Create a TurboJPEG decompressor instance. <a href="#gae5408179d041e2a2f7199c8283cf649e">More...</a><br/></td></tr>
<tr class="separator:gae5408179d041e2a2f7199c8283cf649e"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga7c08b340ad7f8e85d407bd9e81d44d07"><td class="memItemLeft" align="right" valign="top">DLLEXPORT int DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga7c08b340ad7f8e85d407bd9e81d44d07">tjDecompressToYUV2</a> (<a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> handle, unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf, int width, int pad, int height, int flags)</td></tr>
<tr class="memdesc:ga7c08b340ad7f8e85d407bd9e81d44d07"><td class="mdescLeft"> </td><td class="mdescRight">Decompress a JPEG image to a YUV planar image. <a href="#ga7c08b340ad7f8e85d407bd9e81d44d07">More...</a><br/></td></tr>
<tr class="separator:ga7c08b340ad7f8e85d407bd9e81d44d07"><td class="memSeparator" colspan="2"> </td></tr>
+<tr class="memitem:ga0828a38ae29631ac28b6857cefb0eebf"><td class="memItemLeft" align="right" valign="top">DLLEXPORT int DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga0828a38ae29631ac28b6857cefb0eebf">tjDecompressToYUVPlanes</a> (<a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> handle, unsigned char *jpegBuf, unsigned long jpegSize, unsigned char **dstPlanes, int width, int *strides, int height, int flags)</td></tr>
+<tr class="memdesc:ga0828a38ae29631ac28b6857cefb0eebf"><td class="mdescLeft"> </td><td class="mdescRight">Decompress a JPEG image into separate Y, U (Cb), and V (Cr) image planes. <a href="#ga0828a38ae29631ac28b6857cefb0eebf">More...</a><br/></td></tr>
+<tr class="separator:ga0828a38ae29631ac28b6857cefb0eebf"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga132ae2c2cadcf64c8bb0f3bdf69da3ed"><td class="memItemLeft" align="right" valign="top">DLLEXPORT int DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga132ae2c2cadcf64c8bb0f3bdf69da3ed">tjDecodeYUV</a> (<a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> handle, unsigned char *srcBuf, int pad, int subsamp, unsigned char *dstBuf, int width, int pitch, int height, int pixelFormat, int flags)</td></tr>
<tr class="memdesc:ga132ae2c2cadcf64c8bb0f3bdf69da3ed"><td class="mdescLeft"> </td><td class="mdescRight">Decode a YUV planar image into an RGB or grayscale image. <a href="#ga132ae2c2cadcf64c8bb0f3bdf69da3ed">More...</a><br/></td></tr>
<tr class="separator:ga132ae2c2cadcf64c8bb0f3bdf69da3ed"><td class="memSeparator" colspan="2"> </td></tr>
+<tr class="memitem:ga6cb5b0e1101a2b20edea576e11faf93d"><td class="memItemLeft" align="right" valign="top">DLLEXPORT int DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga6cb5b0e1101a2b20edea576e11faf93d">tjDecodeYUVPlanes</a> (<a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> handle, unsigned char **srcPlanes, int *strides, int subsamp, unsigned char *dstBuf, int width, int pitch, int height, int pixelFormat, int flags)</td></tr>
+<tr class="memdesc:ga6cb5b0e1101a2b20edea576e11faf93d"><td class="mdescLeft"> </td><td class="mdescRight">Decode a set of Y, U (Cb), and V (Cr) image planes into an RGB or grayscale image. <a href="#ga6cb5b0e1101a2b20edea576e11faf93d">More...</a><br/></td></tr>
+<tr class="separator:ga6cb5b0e1101a2b20edea576e11faf93d"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ga3155b775bfbac9dbba869b95a0367902"><td class="memItemLeft" align="right" valign="top">DLLEXPORT <a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> DLLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga3155b775bfbac9dbba869b95a0367902">tjInitTransform</a> (void)</td></tr>
<tr class="memdesc:ga3155b775bfbac9dbba869b95a0367902"><td class="mdescLeft"> </td><td class="mdescRight">Create a new TurboJPEG transformer instance. <a href="#ga3155b775bfbac9dbba869b95a0367902">More...</a><br/></td></tr>
<tr class="separator:ga3155b775bfbac9dbba869b95a0367902"><td class="memSeparator" colspan="2"> </td></tr>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+</div>
+</div>
+<a class="anchor" id="gab87b2b19ee8bdd8dba395b74d66a4835"></a>
+<div class="memitem">
+<div class="memproto">
+ <table class="memname">
+ <tr>
+ <td class="memname">DLLEXPORT int DLLCALL tjCompressFromYUVPlanes </td>
+ <td>(</td>
+ <td class="paramtype"><a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> </td>
+ <td class="paramname"><em>handle</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">unsigned char ** </td>
+ <td class="paramname"><em>srcBufs</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>width</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int * </td>
+ <td class="paramname"><em>strides</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>height</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>subsamp</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">unsigned char ** </td>
+ <td class="paramname"><em>jpegBuf</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">unsigned long * </td>
+ <td class="paramname"><em>jpegSize</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>jpegQual</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>flags</em> </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>)</td>
+ <td></td><td></td>
+ </tr>
+ </table>
+</div><div class="memdoc">
+
+<p>Compress a set of Y, U (Cb), and V (Cr) image planes into a JPEG image. </p>
+<dl class="params"><dt>Parameters</dt><dd>
+ <table class="params">
+ <tr><td class="paramname">handle</td><td>a handle to a TurboJPEG compressor or transformer instance </td></tr>
+ <tr><td class="paramname">srcPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if compressing a grayscale image) that contain a YUV image to be compressed. These planes can be contiguous or non-contiguous in memory. Each plane should be at least <b><em>{component stride} * {component height}</em></b> bytes in size. (See below for a description of stride, and refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for a description of component height.) </td></tr>
+ <tr><td class="paramname">width</td><td>width (in pixels) of the source image. If the width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG. </td></tr>
+ <tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the YUV source image. Setting the stride for any plane to 0 is the same as setting it to the component width for the plane. If <code>stride</code> is NULL, then the strides for all planes will be set to their respective component widths. You can adjust the strides in order to specify an arbitrary amount of line padding in each plane or to create a JPEG image from a subregion of a larger YUV planar image. </td></tr>
+ <tr><td class="paramname">height</td><td>height (in pixels) of the source image. If the height is not an even multiple of the MCU block height (see <a class="el" href="group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf" title="MCU block height (in pixels) for a given level of chrominance subsampling.">tjMCUHeight</a>), then an intermediate buffer copy will be performed within TurboJPEG. </td></tr>
+ <tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling used in the source image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.) </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#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 that 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>
+ <tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best) </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>
+</dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+
</div>
</div>
<a class="anchor" id="ga132ae2c2cadcf64c8bb0f3bdf69da3ed"></a>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+</div>
+</div>
+<a class="anchor" id="ga6cb5b0e1101a2b20edea576e11faf93d"></a>
+<div class="memitem">
+<div class="memproto">
+ <table class="memname">
+ <tr>
+ <td class="memname">DLLEXPORT int DLLCALL tjDecodeYUVPlanes </td>
+ <td>(</td>
+ <td class="paramtype"><a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> </td>
+ <td class="paramname"><em>handle</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">unsigned char ** </td>
+ <td class="paramname"><em>srcPlanes</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int * </td>
+ <td class="paramname"><em>strides</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>subsamp</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">unsigned char * </td>
+ <td class="paramname"><em>dstBuf</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>width</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>pitch</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>height</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>pixelFormat</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>flags</em> </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>)</td>
+ <td></td><td></td>
+ </tr>
+ </table>
+</div><div class="memdoc">
+
+<p>Decode a set of Y, U (Cb), and V (Cr) image planes into an RGB or grayscale image. </p>
+<p>This function uses the accelerated color conversion routines in the underlying codec but does not execute any of the other steps in the JPEG decompression process.</p>
+<dl class="params"><dt>Parameters</dt><dd>
+ <table class="params">
+ <tr><td class="paramname">handle</td><td>a handle to a TurboJPEG decompressor or transformer instance </td></tr>
+ <tr><td class="paramname">srcPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if decoding a grayscale image) that contain a YUV image to be decoded. These planes can be contiguous or non-contiguous in memory. Each plane should be at least <b><em>{component stride} * {component height}</em></b> bytes in size. (See below for a description of stride, and refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for a description of component height.) </td></tr>
+ <tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the YUV source image. Setting the stride for any plane to 0 is the same as setting it to the component width for the plane. If <code>stride</code> is NULL, then the strides for all planes will be set to their respective component widths. You can adjust the strides in order to specify an arbitrary amount of line padding in each plane or to decode a subregion of a larger YUV planar image. </td></tr>
+ <tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling used in the YUV source image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.) </td></tr>
+ <tr><td class="paramname">dstBuf</td><td>pointer to an image buffer that will receive the decoded image. This buffer should normally be <code>pitch * height</code> bytes in size, but the <code>dstBuf</code> pointer can also be used to decode into a specific region of a larger buffer. </td></tr>
+ <tr><td class="paramname">width</td><td>width (in pixels) of the source and destination images </td></tr>
+ <tr><td class="paramname">pitch</td><td>bytes per line of the destination 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 destination 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 destination image should be padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use the pitch 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 and destination images </td></tr>
+ <tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</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>
+ </dd>
+</dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+
</div>
</div>
<a class="anchor" id="gada69cc6443d1bb493b40f1626259e5e9"></a>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+</div>
+</div>
+<a class="anchor" id="ga0828a38ae29631ac28b6857cefb0eebf"></a>
+<div class="memitem">
+<div class="memproto">
+ <table class="memname">
+ <tr>
+ <td class="memname">DLLEXPORT int DLLCALL tjDecompressToYUVPlanes </td>
+ <td>(</td>
+ <td class="paramtype"><a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> </td>
+ <td class="paramname"><em>handle</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">unsigned char * </td>
+ <td class="paramname"><em>jpegBuf</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">unsigned long </td>
+ <td class="paramname"><em>jpegSize</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">unsigned char ** </td>
+ <td class="paramname"><em>dstPlanes</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>width</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int * </td>
+ <td class="paramname"><em>strides</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>height</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>flags</em> </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>)</td>
+ <td></td><td></td>
+ </tr>
+ </table>
+</div><div class="memdoc">
+
+<p>Decompress a JPEG image into separate Y, U (Cb), and V (Cr) image planes. </p>
+<p>This function performs JPEG decompression but leaves out the color conversion step, so a planar YUV image is generated instead of an RGB image.</p>
+<dl class="params"><dt>Parameters</dt><dd>
+ <table class="params">
+ <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">dstPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if decompressing a grayscale image) that will receive the YUV image. These planes can be contiguous or non-contiguous in memory. Each plane should be at least <b><em>{component stride} * {scaled component height}</em></b> bytes in size. (See below for a description of stride, and refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for a description of component height.) </td></tr>
+ <tr><td class="paramname">width</td><td>desired width (in pixels) of the YUV image. If this is different than the width 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 width. If <code>width</code> is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG. </td></tr>
+ <tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the output image. Setting the stride for any plane to 0 is the same as setting it to the scaled component width for the plane. If <code>stride</code> is NULL, then the strides for all planes will be set to their respective scaled component widths. You can adjust the strides in order to add an arbitrary amount of line padding to each plane or to decompress the JPEG image into a subregion of a larger YUV planar image. </td></tr>
+ <tr><td class="paramname">height</td><td>desired height (in pixels) of the YUV image. If this is different than the height 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 height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see <a class="el" href="group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf" title="MCU block height (in pixels) for a given level of chrominance subsampling.">tjMCUHeight</a>), then an intermediate buffer copy will be performed within TurboJPEG. </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>
+</dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+
</div>
</div>
<a class="anchor" id="ga674adee917b95ad4a896f1ba39e12540"></a>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+</div>
+</div>
+<a class="anchor" id="gaa791db8598853ddcad24e42897ef1269"></a>
+<div class="memitem">
+<div class="memproto">
+ <table class="memname">
+ <tr>
+ <td class="memname">DLLEXPORT int DLLCALL tjEncodeYUVPlanes </td>
+ <td>(</td>
+ <td class="paramtype"><a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> </td>
+ <td class="paramname"><em>handle</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">unsigned char * </td>
+ <td class="paramname"><em>srcBuf</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>width</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>pitch</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>height</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>pixelFormat</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">unsigned char ** </td>
+ <td class="paramname"><em>dstPlanes</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int * </td>
+ <td class="paramname"><em>strides</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>subsamp</em>, </td>
+ </tr>
+ <tr>
+ <td class="paramkey"></td>
+ <td></td>
+ <td class="paramtype">int </td>
+ <td class="paramname"><em>flags</em> </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>)</td>
+ <td></td><td></td>
+ </tr>
+ </table>
+</div><div class="memdoc">
+
+<p>Encode an RGB or grayscale image into separate Y, U (Cb), and V (Cr) image planes. </p>
+<p>This function uses the accelerated color conversion routines in the underlying codec but does not execute any of the other steps in the JPEG compression process.</p>
+<dl class="params"><dt>Parameters</dt><dd>
+ <table class="params">
+ <tr><td class="paramname">handle</td><td>a handle to a TurboJPEG compressor or transformer instance </td></tr>
+ <tr><td class="paramname">srcBuf</td><td>pointer to an image buffer containing RGB or grayscale pixels to be encoded </td></tr>
+ <tr><td class="paramname">width</td><td>width (in pixels) of the source image </td></tr>
+ <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">dstPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if generating a grayscale image) that will receive the encoded image. These planes can be contiguous or non-contiguous in memory. Each plane should be at least <b><em>{component stride} * {component height}</em></b> bytes in size. (See below for a description of stride, and refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for a description of component height.) </td></tr>
+ <tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the output image. Setting the stride for any plane to 0 is the same as setting it to the component width for the plane. If <code>stride</code> is NULL, then the strides for all planes will be set to their respective component widths. You can adjust the strides in order to add an arbitrary amount of line padding to each plane or to encode an RGB or grayscale image into a subregion of a larger YUV planar image. </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>.) To generate images suitable for X Video, <code>subsamp</code> should be set to <a class="el" href="group___turbo_j_p_e_g.html#gga1d047060ea80bb9820d540bb928e9074a63085dbf683cfe39e513cdb6343e3737">TJSAMP_420</a>. This produces an image compatible with the I420 (AKA "YUV420P") format. </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>
+</dl>
+<dl class="section return"><dt>Returns</dt><dd>0 if successful, or -1 if an error occurred (see <a class="el" href="group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf" title="Returns a descriptive error message explaining why the last command failed.">tjGetErrorStr()</a>.) </dd></dl>
+
</div>
</div>
<a class="anchor" id="ga8c4a1231dc06a450514c835f6471f137"></a>
['tjbufsizeyuv2',['tjBufSizeYUV2',['../group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9',1,'turbojpeg.h']]],
['tjcompress2',['tjCompress2',['../group___turbo_j_p_e_g.html#gaba62b7a98f960839b588579898495cf2',1,'turbojpeg.h']]],
['tjcompressfromyuv',['tjCompressFromYUV',['../group___turbo_j_p_e_g.html#ga0b931126c7a615ddc3bbd0cca6698d67',1,'turbojpeg.h']]],
+ ['tjcompressfromyuvplanes',['tjCompressFromYUVPlanes',['../group___turbo_j_p_e_g.html#gab87b2b19ee8bdd8dba395b74d66a4835',1,'turbojpeg.h']]],
['tjcs',['TJCS',['../group___turbo_j_p_e_g.html#ga4f83ad3368e0e29d1957be0efa7c3720',1,'turbojpeg.h']]],
['tjcs_5fcmyk',['TJCS_CMYK',['../group___turbo_j_p_e_g.html#gga4f83ad3368e0e29d1957be0efa7c3720a6c8b636152ac8195b869587db315ee53',1,'turbojpeg.h']]],
['tjcs_5fgray',['TJCS_GRAY',['../group___turbo_j_p_e_g.html#gga4f83ad3368e0e29d1957be0efa7c3720ab3e7d6a87f695e45b81c1b5262b5a50a',1,'turbojpeg.h']]],
['tjcs_5fycbcr',['TJCS_YCbCr',['../group___turbo_j_p_e_g.html#gga4f83ad3368e0e29d1957be0efa7c3720a7389b8f65bb387ffedce3efd0d78ec75',1,'turbojpeg.h']]],
['tjcs_5fycck',['TJCS_YCCK',['../group___turbo_j_p_e_g.html#gga4f83ad3368e0e29d1957be0efa7c3720a53839e0fe867b76b58d16b0a1a7c598e',1,'turbojpeg.h']]],
['tjdecodeyuv',['tjDecodeYUV',['../group___turbo_j_p_e_g.html#ga132ae2c2cadcf64c8bb0f3bdf69da3ed',1,'turbojpeg.h']]],
+ ['tjdecodeyuvplanes',['tjDecodeYUVPlanes',['../group___turbo_j_p_e_g.html#ga6cb5b0e1101a2b20edea576e11faf93d',1,'turbojpeg.h']]],
['tjdecompress2',['tjDecompress2',['../group___turbo_j_p_e_g.html#gada69cc6443d1bb493b40f1626259e5e9',1,'turbojpeg.h']]],
['tjdecompressheader3',['tjDecompressHeader3',['../group___turbo_j_p_e_g.html#gacd0fac3af74b3511d39b4781b7103086',1,'turbojpeg.h']]],
['tjdecompresstoyuv2',['tjDecompressToYUV2',['../group___turbo_j_p_e_g.html#ga7c08b340ad7f8e85d407bd9e81d44d07',1,'turbojpeg.h']]],
+ ['tjdecompresstoyuvplanes',['tjDecompressToYUVPlanes',['../group___turbo_j_p_e_g.html#ga0828a38ae29631ac28b6857cefb0eebf',1,'turbojpeg.h']]],
['tjdestroy',['tjDestroy',['../group___turbo_j_p_e_g.html#ga674adee917b95ad4a896f1ba39e12540',1,'turbojpeg.h']]],
['tjencodeyuv3',['tjEncodeYUV3',['../group___turbo_j_p_e_g.html#ga0a5ffbf7cb58a5b6a8201114fe889360',1,'turbojpeg.h']]],
+ ['tjencodeyuvplanes',['tjEncodeYUVPlanes',['../group___turbo_j_p_e_g.html#gaa791db8598853ddcad24e42897ef1269',1,'turbojpeg.h']]],
['tjflag_5faccuratedct',['TJFLAG_ACCURATEDCT',['../group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0',1,'turbojpeg.h']]],
['tjflag_5fbottomup',['TJFLAG_BOTTOMUP',['../group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec',1,'turbojpeg.h']]],
['tjflag_5ffastdct',['TJFLAG_FASTDCT',['../group___turbo_j_p_e_g.html#gaabce235db80d3f698b27f36cbd453da2',1,'turbojpeg.h']]],
['tjsamp_5fgray',['TJSAMP_GRAY',['../group___turbo_j_p_e_g.html#gga1d047060ea80bb9820d540bb928e9074a3f1c9504842ddc7a48d0f690754b6248',1,'turbojpeg.h']]],
['tjscaled',['TJSCALED',['../group___turbo_j_p_e_g.html#ga84878bb65404204743aa18cac02781df',1,'turbojpeg.h']]],
['tjscalingfactor',['tjscalingfactor',['../structtjscalingfactor.html',1,'']]],
- ['tjtransform',['tjtransform',['../structtjtransform.html',1,'tjtransform'],['../group___turbo_j_p_e_g.html#gae403193ceb4aafb7e0f56ab587b48616',1,'tjTransform(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int n, unsigned char **dstBufs, unsigned long *dstSizes, tjtransform *transforms, int flags): turbojpeg.h'],['../group___turbo_j_p_e_g.html#gaa29f3189c41be12ec5dee7caec318a31',1,'tjtransform(): turbojpeg.h']]],
+ ['tjtransform',['tjtransform',['../structtjtransform.html',1,'tjtransform'],['../group___turbo_j_p_e_g.html#gaa29f3189c41be12ec5dee7caec318a31',1,'tjtransform(): turbojpeg.h'],['../group___turbo_j_p_e_g.html#gae403193ceb4aafb7e0f56ab587b48616',1,'tjTransform(tjhandle handle, unsigned char *jpegBuf, unsigned long jpegSize, int n, unsigned char **dstBufs, unsigned long *dstSizes, tjtransform *transforms, int flags): turbojpeg.h']]],
['tjxop',['TJXOP',['../group___turbo_j_p_e_g.html#ga2de531af4e7e6c4f124908376b354866',1,'turbojpeg.h']]],
['tjxop_5fhflip',['TJXOP_HFLIP',['../group___turbo_j_p_e_g.html#gga2de531af4e7e6c4f124908376b354866aa0df69776caa30f0fa28e26332d311ce',1,'turbojpeg.h']]],
['tjxop_5fnone',['TJXOP_NONE',['../group___turbo_j_p_e_g.html#gga2de531af4e7e6c4f124908376b354866aad88c0366cd3f7d0eac9d7a3fa1c2c27',1,'turbojpeg.h']]],
['tjbufsizeyuv2',['tjBufSizeYUV2',['../group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9',1,'turbojpeg.h']]],
['tjcompress2',['tjCompress2',['../group___turbo_j_p_e_g.html#gaba62b7a98f960839b588579898495cf2',1,'turbojpeg.h']]],
['tjcompressfromyuv',['tjCompressFromYUV',['../group___turbo_j_p_e_g.html#ga0b931126c7a615ddc3bbd0cca6698d67',1,'turbojpeg.h']]],
+ ['tjcompressfromyuvplanes',['tjCompressFromYUVPlanes',['../group___turbo_j_p_e_g.html#gab87b2b19ee8bdd8dba395b74d66a4835',1,'turbojpeg.h']]],
['tjdecodeyuv',['tjDecodeYUV',['../group___turbo_j_p_e_g.html#ga132ae2c2cadcf64c8bb0f3bdf69da3ed',1,'turbojpeg.h']]],
+ ['tjdecodeyuvplanes',['tjDecodeYUVPlanes',['../group___turbo_j_p_e_g.html#ga6cb5b0e1101a2b20edea576e11faf93d',1,'turbojpeg.h']]],
['tjdecompress2',['tjDecompress2',['../group___turbo_j_p_e_g.html#gada69cc6443d1bb493b40f1626259e5e9',1,'turbojpeg.h']]],
['tjdecompressheader3',['tjDecompressHeader3',['../group___turbo_j_p_e_g.html#gacd0fac3af74b3511d39b4781b7103086',1,'turbojpeg.h']]],
['tjdecompresstoyuv2',['tjDecompressToYUV2',['../group___turbo_j_p_e_g.html#ga7c08b340ad7f8e85d407bd9e81d44d07',1,'turbojpeg.h']]],
+ ['tjdecompresstoyuvplanes',['tjDecompressToYUVPlanes',['../group___turbo_j_p_e_g.html#ga0828a38ae29631ac28b6857cefb0eebf',1,'turbojpeg.h']]],
['tjdestroy',['tjDestroy',['../group___turbo_j_p_e_g.html#ga674adee917b95ad4a896f1ba39e12540',1,'turbojpeg.h']]],
['tjencodeyuv3',['tjEncodeYUV3',['../group___turbo_j_p_e_g.html#ga0a5ffbf7cb58a5b6a8201114fe889360',1,'turbojpeg.h']]],
+ ['tjencodeyuvplanes',['tjEncodeYUVPlanes',['../group___turbo_j_p_e_g.html#gaa791db8598853ddcad24e42897ef1269',1,'turbojpeg.h']]],
['tjfree',['tjFree',['../group___turbo_j_p_e_g.html#ga8c4a1231dc06a450514c835f6471f137',1,'turbojpeg.h']]],
['tjgeterrorstr',['tjGetErrorStr',['../group___turbo_j_p_e_g.html#ga9af79c908ec131b1ae8d52fe40375abf',1,'turbojpeg.h']]],
['tjgetscalingfactors',['tjGetScalingFactors',['../group___turbo_j_p_e_g.html#ga6449044b9af402999ccf52f401333be8',1,'turbojpeg.h']]],
global:
tjBufSizeYUV2;
tjCompressFromYUV;
+ tjCompressFromYUVPlanes;
tjDecodeYUV;
+ tjDecodeYUVPlanes;
tjDecompressHeader3;
tjDecompressToYUV2;
+ tjDecompressToYUVPlanes;
tjEncodeYUV3;
+ tjEncodeYUVPlanes;
} TURBOJPEG_1.2;
global:
tjBufSizeYUV2;
tjCompressFromYUV;
+ tjCompressFromYUVPlanes;
tjDecodeYUV;
+ tjDecodeYUVPlanes;
tjDecompressHeader3;
tjDecompressToYUV2;
+ tjDecompressToYUVPlanes;
tjEncodeYUV3;
+ tjEncodeYUVPlanes;
Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV__IIII;
Java_org_libjpegturbo_turbojpeg_TJCompressor_compressFromYUV___3BIIII_3BII;
Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIIIII_3BIII;
struct jpeg_compress_struct cinfo;
struct jpeg_decompress_struct dinfo;
struct my_error_mgr jerr;
- int init;
+ int init, headerRead;
} tjinstance;
static const int pixelsize[TJ_NUMSAMP]={3, 3, 3, 1, 3, 3};
}
-DLLEXPORT int DLLCALL tjEncodeYUV3(tjhandle handle, unsigned char *srcBuf,
- int width, int pitch, int height, int pixelFormat, unsigned char *dstBuf,
- int pad, int subsamp, int flags)
+DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle, unsigned char *srcBuf,
+ int width, int pitch, int height, int pixelFormat, unsigned char **dstPlanes,
+ int *strides, int subsamp, int flags)
{
int i, retval=0; JSAMPROW *row_pointer=NULL;
JSAMPLE *_tmpbuf[MAX_COMPONENTS], *_tmpbuf2[MAX_COMPONENTS];
JSAMPROW *tmpbuf[MAX_COMPONENTS], *tmpbuf2[MAX_COMPONENTS];
JSAMPROW *outbuf[MAX_COMPONENTS];
int row, pw, ph, cw[MAX_COMPONENTS], ch[MAX_COMPONENTS];
- JSAMPLE *ptr=dstBuf;
- unsigned long yuvsize=0;
+ JSAMPLE *ptr;
jpeg_component_info *compptr;
#ifndef JCS_EXTENSIONS
unsigned char *rgbBuf=NULL;
}
if((this->init&COMPRESS)==0)
- _throw("tjEncodeYUV3(): Instance has not been initialized for compression");
+ _throw("tjEncodeYUVPlanes(): Instance has not been initialized for compression");
if(srcBuf==NULL || width<=0 || pitch<0 || height<=0 || pixelFormat<0
- || pixelFormat>=TJ_NUMPF || dstBuf==NULL || pad<0 || !isPow2(pad)
- || subsamp<0 || subsamp>=NUMSUBOPT)
- _throw("tjEncodeYUV3(): Invalid argument");
+ || pixelFormat>=TJ_NUMPF || !dstPlanes || !dstPlanes[0] || subsamp<0
+ || subsamp>=NUMSUBOPT)
+ _throw("tjEncodeYUVPlanes(): Invalid argument");
+ if(subsamp!=TJSAMP_GRAY && (!dstPlanes[1] || !dstPlanes[2]))
+ _throw("tjEncodeYUVPlanes(): Invalid argument");
if(setjmp(this->jerr.setjmp_buffer))
{
}
if(pixelFormat==TJPF_CMYK)
- _throw("tjEncodeYUV3(): Cannot generate YUV images from CMYK pixels");
+ _throw("tjEncodeYUVPlanes(): Cannot generate YUV images from CMYK pixels");
if(pitch==0) pitch=width*tjPixelSize[pixelFormat];
if(pixelFormat!=TJPF_GRAY && pixelFormat!=TJPF_CMYK)
{
rgbBuf=(unsigned char *)malloc(width*height*RGB_PIXELSIZE);
- if(!rgbBuf) _throw("tjEncodeYUV3(): Memory allocation failure");
+ if(!rgbBuf) _throw("tjEncodeYUVPlanes(): Memory allocation failure");
srcBuf=toRGB(srcBuf, width, pitch, height, pixelFormat, rgbBuf);
pitch=width*RGB_PIXELSIZE;
}
else if(flags&TJFLAG_FORCESSE) putenv("JSIMD_FORCESSE=1");
else if(flags&TJFLAG_FORCESSE2) putenv("JSIMD_FORCESSE2=1");
- yuvsize=tjBufSizeYUV2(width, pad, height, subsamp);
if(setCompDefaults(cinfo, pixelFormat, subsamp, -1, flags)==-1) return -1;
/* Execute only the parts of jpeg_start_compress() that we need. If we
to write the file headers, which could overflow the output buffer if the
YUV image were very small. */
if(cinfo->global_state!=CSTATE_START)
- _throw("tjEncodeYUV3(): libjpeg API is in the wrong state");
+ _throw("tjEncodeYUVPlanes(): libjpeg API is in the wrong state");
(*cinfo->err->reset_error_mgr)((j_common_ptr)cinfo);
jinit_c_master_control(cinfo, FALSE);
jinit_color_converter(cinfo);
ph=PAD(height, cinfo->max_v_samp_factor);
if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)*ph))==NULL)
- _throw("tjEncodeYUV3(): Memory allocation failure");
+ _throw("tjEncodeYUVPlanes(): Memory allocation failure");
for(i=0; i<height; i++)
{
if(flags&TJFLAG_BOTTOMUP) row_pointer[i]=&srcBuf[(height-i-1)*pitch];
_tmpbuf[i]=(JSAMPLE *)malloc(
PAD((compptr->width_in_blocks*cinfo->max_h_samp_factor*DCTSIZE)
/compptr->h_samp_factor, 16) * cinfo->max_v_samp_factor + 16);
- if(!_tmpbuf[i]) _throw("tjEncodeYUV3(): Memory allocation failure");
+ if(!_tmpbuf[i]) _throw("tjEncodeYUVPlanes(): Memory allocation failure");
tmpbuf[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*cinfo->max_v_samp_factor);
- if(!tmpbuf[i]) _throw("tjEncodeYUV3(): Memory allocation failure");
+ if(!tmpbuf[i]) _throw("tjEncodeYUVPlanes(): Memory allocation failure");
for(row=0; row<cinfo->max_v_samp_factor; row++)
{
unsigned char *_tmpbuf_aligned=
}
_tmpbuf2[i]=(JSAMPLE *)malloc(PAD(compptr->width_in_blocks*DCTSIZE, 16)
* compptr->v_samp_factor + 16);
- if(!_tmpbuf2[i]) _throw("tjEncodeYUV3(): Memory allocation failure");
+ if(!_tmpbuf2[i]) _throw("tjEncodeYUVPlanes(): Memory allocation failure");
tmpbuf2[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*compptr->v_samp_factor);
- if(!tmpbuf2[i]) _throw("tjEncodeYUV3(): Memory allocation failure");
+ if(!tmpbuf2[i]) _throw("tjEncodeYUVPlanes(): Memory allocation failure");
for(row=0; row<compptr->v_samp_factor; row++)
{
unsigned char *_tmpbuf2_aligned=
cw[i]=pw*compptr->h_samp_factor/cinfo->max_h_samp_factor;
ch[i]=ph*compptr->v_samp_factor/cinfo->max_v_samp_factor;
outbuf[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*ch[i]);
- if(!outbuf[i]) _throw("tjEncodeYUV3(): Memory allocation failure");
+ if(!outbuf[i]) _throw("tjEncodeYUVPlanes(): Memory allocation failure");
+ ptr=dstPlanes[i];
for(row=0; row<ch[i]; row++)
{
outbuf[i][row]=ptr;
- ptr+=PAD(cw[i], pad);
+ ptr+=(strides && strides[i]>0)? strides[i]:cw[i];
}
}
- if(yuvsize!=(unsigned long)(ptr-dstBuf))
- _throw("tjEncodeYUV3(): Generated image is not the correct size");
for(row=0; row<ph; row+=cinfo->max_v_samp_factor)
{
return retval;
}
+DLLEXPORT int DLLCALL tjEncodeYUV3(tjhandle handle, unsigned char *srcBuf,
+ int width, int pitch, int height, int pixelFormat, unsigned char *dstBuf,
+ int pad, int subsamp, int flags)
+{
+ unsigned char *dstPlanes[3];
+ int pw, ph, cw, ch, strides[3], retval=-1;
+
+ if(width<=0 || height<=0 || dstBuf==NULL || pad<0 || !isPow2(pad)
+ || subsamp<0 || subsamp>=NUMSUBOPT)
+ _throw("tjEncodeYUV3(): Invalid argument");
+
+ pw=PAD(width, tjMCUWidth[subsamp]/8);
+ ph=PAD(height, tjMCUHeight[subsamp]/8);
+ cw=pw*8/tjMCUWidth[subsamp]; ch=ph*8/tjMCUHeight[subsamp];
+
+ strides[0]=PAD(pw, pad);
+ strides[1]=strides[2]=(subsamp==TJSAMP_GRAY? 0:PAD(cw, pad));
+ dstPlanes[0]=dstBuf;
+ dstPlanes[1]=(subsamp==TJSAMP_GRAY? NULL:dstPlanes[0]+strides[0]*ph);
+ dstPlanes[2]=(subsamp==TJSAMP_GRAY? NULL:dstPlanes[1]+strides[1]*ch);
+
+ return tjEncodeYUVPlanes(handle, srcBuf, width, pitch, height, pixelFormat,
+ dstPlanes, strides, subsamp, flags);
+
+ bailout:
+ return retval;
+}
+
DLLEXPORT int DLLCALL tjEncodeYUV2(tjhandle handle, unsigned char *srcBuf,
int width, int pitch, int height, int pixelFormat, unsigned char *dstBuf,
int subsamp, int flags)
}
-DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle, unsigned char *srcBuf,
- int width, int pad, int height, int subsamp, unsigned char **jpegBuf,
- unsigned long *jpegSize, int jpegQual, int flags)
+DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle,
+ unsigned char **srcPlanes, int width, int *strides, int height, int subsamp,
+ unsigned char **jpegBuf, unsigned long *jpegSize, int jpegQual, int flags)
{
int i, row, retval=0, alloc=1; JSAMPROW *inbuf[MAX_COMPONENTS];
int cw[MAX_COMPONENTS], ch[MAX_COMPONENTS], iw[MAX_COMPONENTS],
tmpbufsize=0, usetmpbuf=0, th[MAX_COMPONENTS];
- JSAMPLE *_tmpbuf=NULL, *ptr=srcBuf; JSAMPROW *tmpbuf[MAX_COMPONENTS];
+ JSAMPLE *_tmpbuf=NULL, *ptr; JSAMPROW *tmpbuf[MAX_COMPONENTS];
getcinstance(handle)
}
if((this->init&COMPRESS)==0)
- _throw("tjCompressFromYUV(): Instance has not been initialized for compression");
+ _throw("tjCompressFromYUVPlanes(): Instance has not been initialized for compression");
- if(srcBuf==NULL || width<=0 || pad<1 || height<=0 || subsamp<0
+ if(!srcPlanes || !srcPlanes[0] || width<=0 || height<=0 || subsamp<0
|| subsamp>=NUMSUBOPT || jpegBuf==NULL || jpegSize==NULL || jpegQual<0
|| jpegQual>100)
- _throw("tjCompressFromYUV(): Invalid argument");
+ _throw("tjCompressFromYUVPlanes(): Invalid argument");
+ if(subsamp!=TJSAMP_GRAY && (!srcPlanes[1] || !srcPlanes[2]))
+ _throw("tjCompressFromYUVPlanes(): Invalid argument");
if(setjmp(this->jerr.setjmp_buffer))
{
th[i]=compptr->v_samp_factor*DCTSIZE;
tmpbufsize+=iw[i]*th[i];
if((inbuf[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*ch[i]))==NULL)
- _throw("tjCompressFromYUV(): Memory allocation failure");
+ _throw("tjCompressFromYUVPlanes(): Memory allocation failure");
+ ptr=srcPlanes[i];
for(row=0; row<ch[i]; row++)
{
inbuf[i][row]=ptr;
- ptr+=PAD(cw[i], pad);
+ ptr+=(strides && strides[i]>0)? strides[i]:cw[i];
}
}
if(usetmpbuf)
{
if((_tmpbuf=(JSAMPLE *)malloc(sizeof(JSAMPLE)*tmpbufsize))==NULL)
- _throw("tjCompressFromYUV(): Memory allocation failure");
+ _throw("tjCompressFromYUVPlanes(): Memory allocation failure");
ptr=_tmpbuf;
for(i=0; i<cinfo->num_components; i++)
{
if((tmpbuf[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*th[i]))==NULL)
- _throw("tjCompressFromYUV(): Memory allocation failure");
+ _throw("tjCompressFromYUVPlanes(): Memory allocation failure");
for(row=0; row<th[i]; row++)
{
tmpbuf[i][row]=ptr;
return retval;
}
+DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle, unsigned char *srcBuf,
+ int width, int pad, int height, int subsamp, unsigned char **jpegBuf,
+ unsigned long *jpegSize, int jpegQual, int flags)
+{
+ unsigned char *srcPlanes[3];
+ int pw, ph, cw, ch, strides[3], retval=-1;
+
+ if(srcBuf==NULL || width<=0 || pad<1 || height<=0 || subsamp<0
+ || subsamp>=NUMSUBOPT)
+ _throw("tjCompressFromYUV(): Invalid argument");
+
+ pw=PAD(width, tjMCUWidth[subsamp]/8);
+ ph=PAD(height, tjMCUHeight[subsamp]/8);
+ cw=pw*8/tjMCUWidth[subsamp]; ch=ph*8/tjMCUHeight[subsamp];
+
+ strides[0]=PAD(pw, pad);
+ strides[1]=strides[2]=(subsamp==TJSAMP_GRAY? 0:PAD(cw, pad));
+ srcPlanes[0]=srcBuf;
+ srcPlanes[1]=(subsamp==TJSAMP_GRAY? NULL:srcPlanes[0]+strides[0]*ph);
+ srcPlanes[2]=(subsamp==TJSAMP_GRAY? NULL:srcPlanes[1]+strides[1]*ch);
+
+ return tjCompressFromYUVPlanes(handle, srcPlanes, width, strides, height,
+ subsamp, jpegBuf, jpegSize, jpegQual, flags);
+
+ bailout:
+ return retval;
+}
+
/* Decompressor */
{
}
-DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, unsigned char *srcBuf,
- int pad, int subsamp, unsigned char *dstBuf, int width, int pitch,
- int height, int pixelFormat, int flags)
+DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle,
+ unsigned char **srcPlanes, int *strides, int subsamp, unsigned char *dstBuf,
+ int width, int pitch, int height, int pixelFormat, int flags)
{
int i, retval=0; JSAMPROW *row_pointer=NULL;
JSAMPLE *_tmpbuf[MAX_COMPONENTS];
JSAMPROW *tmpbuf[MAX_COMPONENTS], *inbuf[MAX_COMPONENTS];
int row, pw, ph, cw[MAX_COMPONENTS], ch[MAX_COMPONENTS];
- JSAMPLE *ptr=srcBuf;
- unsigned long yuvsize=0;
+ JSAMPLE *ptr;
jpeg_component_info *compptr;
#ifndef JCS_EXTENSIONS
unsigned char *rgbBuf=NULL;
}
if((this->init&DECOMPRESS)==0)
- _throw("tjDecodeYUV(): Instance has not been initialized for decompression");
+ _throw("tjDecodeYUVPlanes(): Instance has not been initialized for decompression");
- if(srcBuf==NULL || pad<0 || !isPow2(pad) || subsamp<0 || subsamp>=NUMSUBOPT
+ if(!srcPlanes || !srcPlanes[0] || subsamp<0 || subsamp>=NUMSUBOPT
|| dstBuf==NULL || width<=0 || pitch<0 || height<=0 || pixelFormat<0
|| pixelFormat>=TJ_NUMPF)
- _throw("tjDecodeYUV(): Invalid argument");
+ _throw("tjDecodeYUVPlanes(): Invalid argument");
+ if(subsamp!=TJSAMP_GRAY && (!srcPlanes[1] || !srcPlanes[2]))
+ _throw("tjDecodeYUVPlanes(): Invalid argument");
if(setjmp(this->jerr.setjmp_buffer))
{
}
if(pixelFormat==TJPF_CMYK)
- _throw("tjDecodeYUV(): Cannot decode YUV images into CMYK pixels.");
+ _throw("tjDecodeYUVPlanes(): Cannot decode YUV images into CMYK pixels.");
if(pitch==0) pitch=width*tjPixelSize[pixelFormat];
dinfo->image_width=width;
else if(flags&TJFLAG_FORCESSE) putenv("JSIMD_FORCESSE=1");
else if(flags&TJFLAG_FORCESSE2) putenv("JSIMD_FORCESSE2=1");
- yuvsize=tjBufSizeYUV2(width, pad, height, subsamp);
if(setDecodeDefaults(dinfo, pixelFormat, subsamp, flags)==-1)
{
retval=-1; goto bailout;
RGB_PIXELSIZE!=tjPixelSize[pixelFormat]))
{
rgbBuf=(unsigned char *)malloc(width*height*3);
- if(!rgbBuf) _throw("tjDecodeYUV(): Memory allocation failure");
+ if(!rgbBuf) _throw("tjDecodeYUVPlanes(): Memory allocation failure");
_pitch=pitch; pitch=width*3;
_dstBuf=dstBuf; dstBuf=rgbBuf;
}
#endif
if((row_pointer=(JSAMPROW *)malloc(sizeof(JSAMPROW)*ph))==NULL)
- _throw("tjDecodeYUV(): Memory allocation failure");
+ _throw("tjDecodeYUVPlanes(): Memory allocation failure");
for(i=0; i<height; i++)
{
if(flags&TJFLAG_BOTTOMUP) row_pointer[i]=&dstBuf[(height-i-1)*pitch];
compptr=&dinfo->comp_info[i];
_tmpbuf[i]=(JSAMPLE *)malloc(PAD(compptr->width_in_blocks*DCTSIZE, 16)
* compptr->v_samp_factor + 16);
- if(!_tmpbuf[i]) _throw("tjDecodeYUV(): Memory allocation failure");
+ if(!_tmpbuf[i]) _throw("tjDecodeYUVPlanes(): Memory allocation failure");
tmpbuf[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*compptr->v_samp_factor);
- if(!tmpbuf[i]) _throw("tjDecodeYUV(): Memory allocation failure");
+ if(!tmpbuf[i]) _throw("tjDecodeYUVPlanes(): Memory allocation failure");
for(row=0; row<compptr->v_samp_factor; row++)
{
unsigned char *_tmpbuf_aligned=
cw[i]=pw*compptr->h_samp_factor/dinfo->max_h_samp_factor;
ch[i]=ph*compptr->v_samp_factor/dinfo->max_v_samp_factor;
inbuf[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*ch[i]);
- if(!inbuf[i]) _throw("tjDecodeYUV(): Memory allocation failure");
+ if(!inbuf[i]) _throw("tjDecodeYUVPlanes(): Memory allocation failure");
+ ptr=srcPlanes[i];
for(row=0; row<ch[i]; row++)
{
inbuf[i][row]=ptr;
- ptr+=PAD(cw[i], pad);
+ ptr+=(strides && strides[i]>0)? strides[i]:cw[i];
}
}
- if(yuvsize!=(unsigned long)(ptr-srcBuf))
- _throw("tjDecodeYUV(): YUV image is not the correct size");
-
for(row=0; row<ph; row+=dinfo->max_v_samp_factor)
{
JDIMENSION inrow=0, outrow=0;
return retval;
}
+DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, unsigned char *srcBuf,
+ int pad, int subsamp, unsigned char *dstBuf, int width, int pitch,
+ int height, int pixelFormat, int flags)
+{
+ unsigned char *srcPlanes[3];
+ int pw, ph, cw, ch, strides[3], retval=-1;
-DLLEXPORT int DLLCALL tjDecompressToYUV2(tjhandle handle,
- unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf,
- int width, int pad, int height, int flags)
+ if(srcBuf==NULL || pad<0 || !isPow2(pad) || subsamp<0 || subsamp>=NUMSUBOPT
+ || width<=0 || height<=0)
+ _throw("tjDecodeYUV(): Invalid argument");
+
+ pw=PAD(width, tjMCUWidth[subsamp]/8);
+ ph=PAD(height, tjMCUHeight[subsamp]/8);
+ cw=pw*8/tjMCUWidth[subsamp]; ch=ph*8/tjMCUHeight[subsamp];
+
+ strides[0]=PAD(pw, pad);
+ strides[1]=strides[2]=(subsamp==TJSAMP_GRAY? 0:PAD(cw, pad));
+ srcPlanes[0]=srcBuf;
+ srcPlanes[1]=(subsamp==TJSAMP_GRAY? NULL:srcPlanes[0]+strides[0]*ph);
+ srcPlanes[2]=(subsamp==TJSAMP_GRAY? NULL:srcPlanes[1]+strides[1]*ch);
+
+ return tjDecodeYUVPlanes(handle, srcPlanes, strides, subsamp, dstBuf, width,
+ pitch, height, pixelFormat, flags);
+
+ bailout:
+ return retval;
+}
+
+DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
+ unsigned char *jpegBuf, unsigned long jpegSize, unsigned char **dstPlanes,
+ int width, int *strides, int height, int flags)
{
int i, sfi, row, retval=0; JSAMPROW *outbuf[MAX_COMPONENTS];
int jpegwidth, jpegheight, jpegSubsamp, scaledw, scaledh;
int cw[MAX_COMPONENTS], ch[MAX_COMPONENTS], iw[MAX_COMPONENTS],
tmpbufsize=0, usetmpbuf=0, th[MAX_COMPONENTS];
- JSAMPLE *_tmpbuf=NULL, *ptr=dstBuf; JSAMPROW *tmpbuf[MAX_COMPONENTS];
+ JSAMPLE *_tmpbuf=NULL, *ptr; JSAMPROW *tmpbuf[MAX_COMPONENTS];
int dctsize;
getdinstance(handle);
}
if((this->init&DECOMPRESS)==0)
- _throw("tjDecompressToYUV2(): Instance has not been initialized for decompression");
+ _throw("tjDecompressToYUVPlanes(): Instance has not been initialized for decompression");
- if(jpegBuf==NULL || jpegSize<=0 || dstBuf==NULL || width<0 || pad<1
- || !isPow2(pad) || height<0)
- _throw("tjDecompressToYUV2(): Invalid argument");
+ if(jpegBuf==NULL || jpegSize<=0 || !dstPlanes || !dstPlanes[0] || width<0
+ || height<0)
+ _throw("tjDecompressToYUVPlanes(): Invalid argument");
if(flags&TJFLAG_FORCEMMX) putenv("JSIMD_FORCEMMX=1");
else if(flags&TJFLAG_FORCESSE) putenv("JSIMD_FORCESSE=1");
goto bailout;
}
- jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
- jpeg_read_header(dinfo, TRUE);
+ if(!this->headerRead)
+ {
+ jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
+ jpeg_read_header(dinfo, TRUE);
+ }
+ this->headerRead=0;
jpegSubsamp=getSubsamp(dinfo);
if(jpegSubsamp<0)
- _throw("tjDecompressToYUV2(): Could not determine subsampling type for JPEG image");
+ _throw("tjDecompressToYUVPlanes(): Could not determine subsampling type for JPEG image");
+
+ if(jpegSubsamp!=TJSAMP_GRAY && (!dstPlanes[1] || !dstPlanes[2]))
+ _throw("tjDecompressToYUVPlanes(): Invalid argument");
jpegwidth=dinfo->image_width; jpegheight=dinfo->image_height;
if(width==0) width=jpegwidth;
break;
}
if(scaledw>width || scaledh>height)
- _throw("tjDecompressToYUV2(): Could not scale down to desired image dimensions");
+ _throw("tjDecompressToYUVPlanes(): Could not scale down to desired image dimensions");
if(dinfo->num_components>3)
- _throw("tjDecompressToYUV2(): JPEG image must have 3 or fewer components");
+ _throw("tjDecompressToYUVPlanes(): JPEG image must have 3 or fewer components");
width=scaledw; height=scaledh;
dinfo->scale_num=sf[i].num;
th[i]=compptr->v_samp_factor*dctsize;
tmpbufsize+=iw[i]*th[i];
if((outbuf[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*ch[i]))==NULL)
- _throw("tjDecompressToYUV2(): Memory allocation failure");
+ _throw("tjDecompressToYUVPlanes(): Memory allocation failure");
+ ptr=dstPlanes[i];
for(row=0; row<ch[i]; row++)
{
outbuf[i][row]=ptr;
- ptr+=PAD(cw[i], pad);
+ ptr+=(strides && strides[i]>0)? strides[i]:cw[i];
}
}
if(usetmpbuf)
{
if((_tmpbuf=(JSAMPLE *)malloc(sizeof(JSAMPLE)*tmpbufsize))==NULL)
- _throw("tjDecompressToYUV2(): Memory allocation failure");
+ _throw("tjDecompressToYUVPlanes(): Memory allocation failure");
ptr=_tmpbuf;
for(i=0; i<dinfo->num_components; i++)
{
if((tmpbuf[i]=(JSAMPROW *)malloc(sizeof(JSAMPROW)*th[i]))==NULL)
- _throw("tjDecompressToYUV2(): Memory allocation failure");
+ _throw("tjDecompressToYUVPlanes(): Memory allocation failure");
for(row=0; row<th[i]; row++)
{
tmpbuf[i][row]=ptr;
return retval;
}
+DLLEXPORT int DLLCALL tjDecompressToYUV2(tjhandle handle,
+ unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf,
+ int width, int pad, int height, int flags)
+{
+ unsigned char *dstPlanes[3];
+ int pw, ph, cw, ch, strides[3], retval=-1, jpegSubsamp=-1;
+ int i, jpegwidth, jpegheight, scaledw, scaledh;
+
+ getdinstance(handle);
+
+ if(jpegBuf==NULL || jpegSize<=0 || dstBuf==NULL || width<0 || pad<1
+ || !isPow2(pad) || height<0)
+ _throw("tjDecompressToYUV2(): Invalid argument");
+
+ jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
+ jpeg_read_header(dinfo, TRUE);
+ jpegSubsamp=getSubsamp(dinfo);
+ if(jpegSubsamp<0)
+ _throw("tjDecompressToYUV2(): Could not determine subsampling type for JPEG image");
+
+ jpegwidth=dinfo->image_width; jpegheight=dinfo->image_height;
+ if(width==0) width=jpegwidth;
+ if(height==0) height=jpegheight;
+
+ for(i=0; i<NUMSF; i++)
+ {
+ scaledw=TJSCALED(jpegwidth, sf[i]);
+ scaledh=TJSCALED(jpegheight, sf[i]);
+ if(scaledw<=width && scaledh<=height)
+ break;
+ }
+ if(scaledw>width || scaledh>height)
+ _throw("tjDecompressToYUV2(): Could not scale down to desired image dimensions");
+
+ pw=PAD(scaledw, tjMCUWidth[jpegSubsamp]/8);
+ ph=PAD(scaledh, tjMCUHeight[jpegSubsamp]/8);
+ cw=pw*8/tjMCUWidth[jpegSubsamp]; ch=ph*8/tjMCUHeight[jpegSubsamp];
+
+ strides[0]=PAD(pw, pad);
+ strides[1]=strides[2]=(jpegSubsamp==TJSAMP_GRAY? 0:PAD(cw, pad));
+ dstPlanes[0]=dstBuf;
+ dstPlanes[1]=(jpegSubsamp==TJSAMP_GRAY? NULL:dstPlanes[0]+strides[0]*ph);
+ dstPlanes[2]=(jpegSubsamp==TJSAMP_GRAY? NULL:dstPlanes[1]+strides[1]*ch);
+
+ this->headerRead=1;
+ return tjDecompressToYUVPlanes(handle, jpegBuf, jpegSize, dstPlanes, width,
+ strides, height, flags);
+
+ bailout:
+ return retval;
+
+}
+
DLLEXPORT int DLLCALL tjDecompressToYUV(tjhandle handle,
unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf,
int flags)
unsigned long *jpegSize, int jpegQual, int flags);
+/**
+ * Compress a set of Y, U (Cb), and V (Cr) image planes into a JPEG image.
+ *
+ * @param handle a handle to a TurboJPEG compressor or transformer instance
+ * @param srcPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
+ * (or just a Y plane, if compressing a grayscale image) that contain a
+ * YUV image to be compressed. These planes can be contiguous or
+ * non-contiguous in memory. Each plane should be at least
+ * <b><i>{component stride} * {component height}</i></b> bytes in size.
+ * (See below for a description of stride, and refer to @ref YUVnotes
+ * "YUV Image Format Notes" for a description of component height.)
+ * @param width width (in pixels) of the source image. If the width is not an
+ * even multiple of the MCU block width (see #tjMCUWidth), then an
+ * intermediate buffer copy will be performed within TurboJPEG.
+ * @param strides an array of integers, each specifying the number of bytes per
+ * line in the corresponding plane of the YUV source image. Setting the
+ * stride for any plane to 0 is the same as setting it to the component
+ * width for the plane. If <tt>stride</tt> is NULL, then the strides
+ * for all planes will be set to their respective component widths. You
+ * can adjust the strides in order to specify an arbitrary amount of
+ * line padding in each plane or to create a JPEG image from a subregion
+ * of a larger YUV planar image.
+ * @param height height (in pixels) of the source image. If the height is not
+ * an even multiple of the MCU block height (see #tjMCUHeight), then an
+ * intermediate buffer copy will be performed within TurboJPEG.
+ * @param subsamp the level of chrominance subsampling used in the source
+ * image (see @ref TJSAMP "Chrominance subsampling options".)
+ * @param jpegBuf 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:
+ * -# pre-allocate the JPEG buffer with an arbitrary size using
+ * #tjAlloc() and let TurboJPEG grow the buffer as needed,
+ * -# 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
+ * to be re-allocated (setting #TJFLAG_NOREALLOC guarantees this.)
+ * .
+ * If you choose option 1, <tt>*jpegSize</tt> should be set to the
+ * size of your pre-allocated buffer. In any case, unless you have
+ * set #TJFLAG_NOREALLOC, you should always check <tt>*jpegBuf</tt> upon
+ * return from this function, as it may have changed.
+ * @param jpegSize pointer to an unsigned long variable that holds the size of
+ * the JPEG image buffer. If <tt>*jpegBuf</tt> points to a
+ * pre-allocated buffer, then <tt>*jpegSize</tt> should be set to the
+ * size of the buffer. Upon return, <tt>*jpegSize</tt> will contain the
+ * size of the JPEG image (in bytes.)
+ * @param jpegQual the image quality of the generated JPEG image (1 = worst,
+ 100 = best)
+ * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
+ * "flags".
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+*/
+DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle,
+ unsigned char **srcBufs, int width, int *strides, int height, int subsamp,
+ unsigned char **jpegBuf, unsigned long *jpegSize, int jpegQual, int flags);
+
+
/**
* The maximum size of the buffer (in bytes) required to hold a JPEG image with
* the given parameters. The number of bytes returned by this function is
unsigned char *dstBuf, int pad, int subsamp, int flags);
+/**
+ * Encode an RGB or grayscale image into separate Y, U (Cb), and V (Cr) image
+ * planes. This function uses the accelerated color conversion routines in the
+ * underlying codec but does not execute any of the other steps in the JPEG
+ * compression process.
+ *
+ * @param handle a handle to a TurboJPEG compressor or transformer instance
+ * @param srcBuf pointer to an image buffer containing RGB or grayscale pixels
+ * to be encoded
+ * @param width width (in pixels) of the source image
+ * @param pitch bytes per line of the source image. Normally, this should be
+ * <tt>width * #tjPixelSize[pixelFormat]</tt> if the image is unpadded,
+ * or <tt>#TJPAD(width * #tjPixelSize[pixelFormat])</tt> 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 <tt>width * #tjPixelSize[pixelFormat]</tt>.
+ * @param height height (in pixels) of the source image
+ * @param pixelFormat pixel format of the source image (see @ref TJPF
+ * "Pixel formats".)
+ * @param dstPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
+ * (or just a Y plane, if generating a grayscale image) that will
+ * receive the encoded image. These planes can be contiguous or
+ * non-contiguous in memory. Each plane should be at least
+ * <b><i>{component stride} * {component height}</i></b> bytes in size.
+ * (See below for a description of stride, and refer to @ref YUVnotes
+ * "YUV Image Format Notes" for a description of component height.)
+ * @param strides an array of integers, each specifying the number of bytes per
+ * line in the corresponding plane of the output image. Setting the
+ * stride for any plane to 0 is the same as setting it to the component
+ * width for the plane. If <tt>stride</tt> is NULL, then the strides
+ * for all planes will be set to their respective component widths. You
+ * can adjust the strides in order to add an arbitrary amount of line
+ * padding to each plane or to encode an RGB or grayscale image into a
+ * subregion of a larger YUV planar image.
+ * @param subsamp the level of chrominance subsampling to be used when
+ * generating the YUV image (see @ref TJSAMP
+ * "Chrominance subsampling options".) To generate images suitable for
+ * X Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This
+ * produces an image compatible with the I420 (AKA "YUV420P") format.
+ * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
+ * "flags".
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+*/
+DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle,
+ unsigned char *srcBuf, int width, int pitch, int height, int pixelFormat,
+ unsigned char **dstPlanes, int *strides, int subsamp, int flags);
+
+
/**
* Create a TurboJPEG decompressor instance.
*
int width, int pad, int height, int flags);
+/**
+ * Decompress a JPEG image into separate Y, U (Cb), and V (Cr) image
+ * planes. This function performs JPEG decompression but leaves out the color
+ * conversion step, so a planar YUV image is generated instead of an RGB image.
+ *
+ * @param handle a handle to a TurboJPEG decompressor or transformer instance
+ * @param jpegBuf pointer to a buffer containing the JPEG image to decompress
+ * @param jpegSize size of the JPEG image (in bytes)
+ * @param dstPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
+ * (or just a Y plane, if decompressing a grayscale image) that will
+ * receive the YUV image. These planes can be contiguous or
+ * non-contiguous in memory. Each plane should be at least
+ * <b><i>{component stride} * {scaled component height}</i></b> bytes in
+ * size. (See below for a description of stride, and refer to @ref
+ * YUVnotes "YUV Image Format Notes" for a description of component
+ * height.)
+ * @param width desired width (in pixels) of the YUV image. If this is
+ * different than the width 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 width. If
+ * <tt>width</tt> is set to 0, then only the height will be considered
+ * when determining the scaled image size. If the scaled width is not
+ * an even multiple of the MCU block width (see #tjMCUWidth), then an
+ * intermediate buffer copy will be performed within TurboJPEG.
+ * @param strides an array of integers, each specifying the number of bytes per
+ * line in the corresponding plane of the output image. Setting the
+ * stride for any plane to 0 is the same as setting it to the scaled
+ * component width for the plane. If <tt>stride</tt> is NULL, then the
+ * strides for all planes will be set to their respective scaled
+ * component widths. You can adjust the strides in order to add an
+ * arbitrary amount of line padding to each plane or to decompress the
+ * JPEG image into a subregion of a larger YUV planar image.
+ * @param height desired height (in pixels) of the YUV image. If this is
+ * different than the height 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 height. If
+ * <tt>height</tt> is set to 0, then only the width will be considered
+ * when determining the scaled image size. If the scaled height is not
+ * an even multiple of the MCU block height (see #tjMCUHeight), then an
+ * intermediate buffer copy will be performed within TurboJPEG.
+ * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
+ * "flags".
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ */
+DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
+ unsigned char *jpegBuf, unsigned long jpegSize, unsigned char **dstPlanes,
+ int width, int *strides, int height, int flags);
+
+
/**
* Decode a YUV planar image into an RGB or grayscale image. This function
* uses the accelerated color conversion routines in the underlying
int height, int pixelFormat, int flags);
+/**
+ * Decode a set of Y, U (Cb), and V (Cr) image planes into an RGB or grayscale
+ * image. This function uses the accelerated color conversion routines in the
+ * underlying codec but does not execute any of the other steps in the JPEG
+ * decompression process.
+ *
+ * @param handle a handle to a TurboJPEG decompressor or transformer instance
+ * @param srcPlanes an array of pointers to Y, U (Cb), and V (Cr) image planes
+ * (or just a Y plane, if decoding a grayscale image) that contain a
+ * YUV image to be decoded. These planes can be contiguous or
+ * non-contiguous in memory. Each plane should be at least
+ * <b><i>{component stride} * {component height}</i></b> bytes in size.
+ * (See below for a description of stride, and refer to @ref YUVnotes
+ * "YUV Image Format Notes" for a description of component height.)
+ * @param strides an array of integers, each specifying the number of bytes per
+ * line in the corresponding plane of the YUV source image. Setting the
+ * stride for any plane to 0 is the same as setting it to the component
+ * width for the plane. If <tt>stride</tt> is NULL, then the strides
+ * for all planes will be set to their respective component widths. You
+ * can adjust the strides in order to specify an arbitrary amount of
+ * line padding in each plane or to decode a subregion of a larger YUV
+ * planar image.
+ * @param subsamp the level of chrominance subsampling used in the YUV source
+ * image (see @ref TJSAMP "Chrominance subsampling options".)
+ * @param dstBuf pointer to an image buffer that will receive the decoded
+ * image. This buffer should normally be <tt>pitch * height</tt>
+ * bytes in size, but the <tt>dstBuf</tt> pointer can also be used to
+ * decode into a specific region of a larger buffer.
+ * @param width width (in pixels) of the source and destination images
+ * @param pitch bytes per line of the destination image. Normally, this should
+ * be <tt>width * #tjPixelSize[pixelFormat]</tt> if the destination
+ * image is unpadded, or <tt>#TJPAD(width *
+ * #tjPixelSize[pixelFormat])</tt> if each line of the destination
+ * image should be padded to the nearest 32-bit boundary, as is the case
+ * for Windows bitmaps. You can also be clever and use the pitch
+ * parameter to skip lines, etc. Setting this parameter to 0 is the
+ * equivalent of setting it to <tt>width *
+ * #tjPixelSize[pixelFormat]</tt>.
+ * @param height height (in pixels) of the source and destination images
+ * @param pixelFormat pixel format of the destination image (see @ref TJPF
+ * "Pixel formats".)
+ * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP
+ * "flags".
+ *
+ * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().)
+ */
+DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle,
+ unsigned char **srcPlanes, int *strides, int subsamp, unsigned char *dstBuf,
+ int width, int pitch, int height, int pixelFormat, int flags);
+
+
/**
* Create a new TurboJPEG transformer instance.
*