Minor TurboJPEG doc tweaks
- When transforming, the worst-case JPEG buffer size depends on the subsampling level used in the destination image, since a grayscale transform might have been applied. - Parentheses Police
This commit is contained in:
@@ -3173,7 +3173,7 @@ If you choose option 1, then <code>*jpegSize</code> should be set to the size of
|
||||
<tr><td class="paramname">dstBufs</td><td>pointer to an array of n byte 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 destination buffer to accommodate the size of the transformed JPEG image. Thus, you can choose to:<ol type="1">
|
||||
<li>pre-allocate the JPEG destination buffer with an arbitrary size using <a class="el" href="group___turbo_j_p_e_g.html#ga1a2c96d8b47530b6e6050ba6f10b7c57" title="Allocate a byte buffer for use with TurboJPEG.">tj3Alloc()</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#gac6285e58e35a35d871d7162ec5a929c4" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters.">tj3JPEGBufSize()</a> with the transformed or cropped width and height and the level of subsampling used in the source image. Under normal circumstances, this should ensure that the buffer never has to be re-allocated. (Setting <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82ae64ffb358bc7b194fd48e0f27750b29b" title="JPEG destination buffer (re)allocation [compression, lossless transformation].">TJPARAM_NOREALLOC</a> guarantees that it won't be.) Note, however, that there are some rare cases (such as transforming images with a large amount of embedded Exif or ICC profile data) in which the transformed JPEG image will be larger than the worst-case size, and <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82ae64ffb358bc7b194fd48e0f27750b29b" title="JPEG destination buffer (re)allocation [compression, lossless transformation].">TJPARAM_NOREALLOC</a> cannot be used in those cases.</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#gac6285e58e35a35d871d7162ec5a929c4" title="The maximum size of the buffer (in bytes) required to hold a JPEG image with the given parameters.">tj3JPEGBufSize()</a> with the transformed or cropped width and height and the level of subsampling used in the destination image. Under normal circumstances, this should ensure that the buffer never has to be re-allocated. (Setting <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82ae64ffb358bc7b194fd48e0f27750b29b" title="JPEG destination buffer (re)allocation [compression, lossless transformation].">TJPARAM_NOREALLOC</a> guarantees that it won't be.) Note, however, that there are some rare cases (such as transforming images with a large amount of embedded Exif or ICC profile data) in which the transformed JPEG image will be larger than the worst-case size, and <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82ae64ffb358bc7b194fd48e0f27750b29b" title="JPEG destination buffer (re)allocation [compression, lossless transformation].">TJPARAM_NOREALLOC</a> cannot be used in those cases.</li>
|
||||
</ol>
|
||||
If you choose option 1, then <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#ggaa0f6be63ba78278299c9f5c12031fe82ae64ffb358bc7b194fd48e0f27750b29b" title="JPEG destination buffer (re)allocation [compression, lossless transformation].">TJPARAM_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 size_t variables that 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 transformed JPEG image (in bytes.)</td></tr>
|
||||
|
||||
Binary file not shown.
@@ -869,7 +869,7 @@ implements java.io.Closeable</pre>
|
||||
subsampling in the JPEG image (see <a href="TJ.html#PARAM_SUBSAMP"><code>TJ.PARAM_SUBSAMP</code></a>.) The
|
||||
cropping region should be specified relative to the scaled image
|
||||
dimensions. Unless <code>croppingRegion</code> is <a href="TJ.html#UNCROPPED"><code>TJ.UNCROPPED</code></a>,
|
||||
the JPEG header must be read (see <a href="#setSourceImage(byte%5B%5D,int)"><code>setSourceImage(byte[], int)</code></a>
|
||||
the JPEG header must be read (see <a href="#setSourceImage(byte%5B%5D,int)"><code>setSourceImage(byte[], int)</code></a>)
|
||||
prior to calling this method.</dd>
|
||||
<dt><span class="throwsLabel">Throws:</span></dt>
|
||||
<dd><code><a href="TJException.html" title="class in org.libjpegturbo.turbojpeg">TJException</a></code></dd>
|
||||
|
||||
@@ -379,7 +379,7 @@ extends <a href="TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg
|
||||
transformed using the parameters in <code>transforms[i]</code>. Use
|
||||
<a href="TJ.html#bufSize(int,int,int)"><code>TJ.bufSize()</code></a> to determine the maximum size for each
|
||||
buffer based on the transformed or cropped width and height and the level
|
||||
of subsampling used in the source image.</dd>
|
||||
of subsampling used in the destination image.</dd>
|
||||
<dd><code>transforms</code> - an array of <a href="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 JPEG image</dd>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -263,7 +263,7 @@ public class TJDecompressor implements Closeable {
|
||||
* subsampling in the JPEG image (see {@link TJ#PARAM_SUBSAMP}.) The
|
||||
* cropping region should be specified relative to the scaled image
|
||||
* dimensions. Unless <code>croppingRegion</code> is {@link TJ#UNCROPPED},
|
||||
* the JPEG header must be read (see {@link #setSourceImage(byte[], int)}
|
||||
* the JPEG header must be read (see {@link #setSourceImage(byte[], int)})
|
||||
* prior to calling this method.
|
||||
*/
|
||||
@SuppressWarnings("checkstyle:HiddenField")
|
||||
|
||||
@@ -89,7 +89,7 @@ public class TJTransformer extends TJDecompressor {
|
||||
* transformed using the parameters in <code>transforms[i]</code>. Use
|
||||
* {@link TJ#bufSize TJ.bufSize()} to determine the maximum size for each
|
||||
* buffer based on the transformed or cropped width and height and the level
|
||||
* of subsampling used in the source image.
|
||||
* of subsampling used in the destination image.
|
||||
*
|
||||
* @param transforms an array of {@link TJTransform} instances, each of
|
||||
* which specifies the transform parameters and/or cropping region for the
|
||||
|
||||
14
turbojpeg.h
14
turbojpeg.h
@@ -2065,13 +2065,13 @@ DLLEXPORT int tj3DecodeYUV8(tjhandle handle, const unsigned char *srcBuf,
|
||||
* you, or
|
||||
* -# pre-allocate the buffer to a "worst case" size determined by calling
|
||||
* #tj3JPEGBufSize() with the transformed or cropped width and height and the
|
||||
* level of subsampling used in the source image. Under normal circumstances,
|
||||
* this should ensure that the buffer never has to be re-allocated. (Setting
|
||||
* #TJPARAM_NOREALLOC guarantees that it won't be.) Note, however, that there
|
||||
* are some rare cases (such as transforming images with a large amount of
|
||||
* embedded Exif or ICC profile data) in which the transformed JPEG image will
|
||||
* be larger than the worst-case size, and #TJPARAM_NOREALLOC cannot be used in
|
||||
* those cases.
|
||||
* level of subsampling used in the destination image. Under normal
|
||||
* circumstances, this should ensure that the buffer never has to be
|
||||
* re-allocated. (Setting #TJPARAM_NOREALLOC guarantees that it won't be.)
|
||||
* Note, however, that there are some rare cases (such as transforming images
|
||||
* with a large amount of embedded Exif or ICC profile data) in which the
|
||||
* transformed JPEG image will be larger than the worst-case size, and
|
||||
* #TJPARAM_NOREALLOC cannot be used in those cases.
|
||||
* .
|
||||
* If you choose option 1, then `dstSizes[i]` should be set to the size of your
|
||||
* pre-allocated buffer. In any case, unless you have set #TJPARAM_NOREALLOC,
|
||||
|
||||
Reference in New Issue
Block a user