tjDecompressHeader3(): Accept tables-only streams
Inspired by:
b3b15cfe74
Closes #604
Closes #605
This commit is contained in:
@@ -6,6 +6,12 @@
|
||||
1. Fixed a regression introduced in 2.1.3 that caused build failures with
|
||||
Visual Studio 2010.
|
||||
|
||||
2. The `tjDecompressHeader3()` function in the TurboJPEG C API and the
|
||||
`TJDecompressor.setSourceImage()` method in the TurboJPEG Java API now accept
|
||||
"abbreviated table specification" (AKA "tables-only") datastreams, which can be
|
||||
used to prime the decompressor with quantization and Huffman tables that can be
|
||||
used when decompressing subsequent "abbreviated image" datastreams.
|
||||
|
||||
|
||||
2.1.3
|
||||
=====
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">TurboJPEG
|
||||
 <span id="projectnumber">2.1</span>
|
||||
 <span id="projectnumber">2.1.4</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">TurboJPEG
|
||||
 <span id="projectnumber">2.1</span>
|
||||
 <span id="projectnumber">2.1.4</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">TurboJPEG
|
||||
 <span id="projectnumber">2.1</span>
|
||||
 <span id="projectnumber">2.1.4</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">TurboJPEG
|
||||
 <span id="projectnumber">2.1</span>
|
||||
 <span id="projectnumber">2.1.4</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">TurboJPEG
|
||||
 <span id="projectnumber">2.1</span>
|
||||
 <span id="projectnumber">2.1.4</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -273,7 +273,7 @@ Functions</h2></td></tr>
|
||||
<tr class="memdesc:ga52300eac3f3d9ef4bab303bc244f62d3"><td class="mdescLeft"> </td><td class="mdescRight">Create a TurboJPEG decompressor instance. <a href="group___turbo_j_p_e_g.html#ga52300eac3f3d9ef4bab303bc244f62d3">More...</a><br /></td></tr>
|
||||
<tr class="separator:ga52300eac3f3d9ef4bab303bc244f62d3"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ga0595681096bba7199cc6f3533cb25f77"><td class="memItemLeft" align="right" valign="top">DLLEXPORT int </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#ga0595681096bba7199cc6f3533cb25f77">tjDecompressHeader3</a> (<a class="el" href="group___turbo_j_p_e_g.html#ga758d2634ecb4949de7815cba621f5763">tjhandle</a> handle, const unsigned char *jpegBuf, unsigned long jpegSize, int *width, int *height, int *jpegSubsamp, int *jpegColorspace)</td></tr>
|
||||
<tr class="memdesc:ga0595681096bba7199cc6f3533cb25f77"><td class="mdescLeft"> </td><td class="mdescRight">Retrieve information about a JPEG image without decompressing it. <a href="group___turbo_j_p_e_g.html#ga0595681096bba7199cc6f3533cb25f77">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:ga0595681096bba7199cc6f3533cb25f77"><td class="mdescLeft"> </td><td class="mdescRight">Retrieve information about a JPEG image without decompressing it, or prime the decompressor with quantization and Huffman tables. <a href="group___turbo_j_p_e_g.html#ga0595681096bba7199cc6f3533cb25f77">More...</a><br /></td></tr>
|
||||
<tr class="separator:ga0595681096bba7199cc6f3533cb25f77"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:gac3854476006b10787bd128f7ede48057"><td class="memItemLeft" align="right" valign="top">DLLEXPORT <a class="el" href="structtjscalingfactor.html">tjscalingfactor</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="group___turbo_j_p_e_g.html#gac3854476006b10787bd128f7ede48057">tjGetScalingFactors</a> (int *numscalingfactors)</td></tr>
|
||||
<tr class="memdesc:gac3854476006b10787bd128f7ede48057"><td class="mdescLeft"> </td><td class="mdescRight">Returns a list of fractional scaling factors that the JPEG decompressor in this implementation of TurboJPEG supports. <a href="group___turbo_j_p_e_g.html#gac3854476006b10787bd128f7ede48057">More...</a><br /></td></tr>
|
||||
@@ -1725,16 +1725,16 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Retrieve information about a JPEG image without decompressing it. </p>
|
||||
<p>Retrieve information about a JPEG image without decompressing it, or prime the decompressor with quantization and Huffman tables. </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 a JPEG image</td></tr>
|
||||
<tr><td class="paramname">jpegSize</td><td>size of the JPEG image (in bytes)</td></tr>
|
||||
<tr><td class="paramname">width</td><td>pointer to an integer variable that will receive the width (in pixels) of the JPEG image</td></tr>
|
||||
<tr><td class="paramname">height</td><td>pointer to an integer variable that will receive the height (in pixels) of the JPEG image</td></tr>
|
||||
<tr><td class="paramname">jpegSubsamp</td><td>pointer to an integer variable that will receive the level of chrominance subsampling used when the JPEG image was compressed (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.)</td></tr>
|
||||
<tr><td class="paramname">jpegColorspace</td><td>pointer to an integer variable that will receive one of the JPEG colorspace constants, indicating the colorspace of the JPEG image (see <a class="el" href="group___turbo_j_p_e_g.html#ga4f83ad3368e0e29d1957be0efa7c3720">JPEG colorspaces</a>.)</td></tr>
|
||||
<tr><td class="paramname">jpegBuf</td><td>pointer to a buffer containing a JPEG image or an "abbreviated table specification" (AKA "tables-only") datastream. Passing a tables-only datastream to this function primes the decompressor with quantization and Huffman tables that can be used when decompressing subsequent "abbreviated image" datastreams. This is useful, for instance, when decompressing video streams in which all frames share the same quantization and Huffman tables.</td></tr>
|
||||
<tr><td class="paramname">jpegSize</td><td>size of the JPEG image or tables-only datastream (in bytes)</td></tr>
|
||||
<tr><td class="paramname">width</td><td>pointer to an integer variable that will receive the width (in pixels) of the JPEG image. If <code>jpegBuf</code> points to a tables-only datastream, then <code>width</code> is ignored.</td></tr>
|
||||
<tr><td class="paramname">height</td><td>pointer to an integer variable that will receive the height (in pixels) of the JPEG image. If <code>jpegBuf</code> points to a tables-only datastream, then <code>height</code> is ignored.</td></tr>
|
||||
<tr><td class="paramname">jpegSubsamp</td><td>pointer to an integer variable that will receive the level of chrominance subsampling used when the JPEG image was compressed (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.) If <code>jpegBuf</code> points to a tables-only datastream, then <code>jpegSubsamp</code> is ignored.</td></tr>
|
||||
<tr><td class="paramname">jpegColorspace</td><td>pointer to an integer variable that will receive one of the JPEG colorspace constants, indicating the colorspace of the JPEG image (see <a class="el" href="group___turbo_j_p_e_g.html#ga4f83ad3368e0e29d1957be0efa7c3720">JPEG colorspaces</a>.) If <code>jpegBuf</code> points to a tables-only datastream, then <code>jpegColorspace</code> is ignored.</td></tr>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">TurboJPEG
|
||||
 <span id="projectnumber">2.1</span>
|
||||
 <span id="projectnumber">2.1.4</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">TurboJPEG
|
||||
 <span id="projectnumber">2.1</span>
|
||||
 <span id="projectnumber">2.1.4</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">TurboJPEG
|
||||
 <span id="projectnumber">2.1</span>
|
||||
 <span id="projectnumber">2.1.4</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">TurboJPEG
|
||||
 <span id="projectnumber">2.1</span>
|
||||
 <span id="projectnumber">2.1.4</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">TurboJPEG
|
||||
 <span id="projectnumber">2.1</span>
|
||||
 <span id="projectnumber">2.1.4</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
PROJECT_NAME = TurboJPEG
|
||||
PROJECT_NUMBER = 2.1
|
||||
PROJECT_NUMBER = 2.1.4
|
||||
OUTPUT_DIRECTORY = doc/
|
||||
USE_WINDOWS_ENCODING = NO
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
|
||||
@@ -792,7 +792,8 @@
|
||||
</dd>
|
||||
<dt><span class="strong"><a href="./org/libjpegturbo/turbojpeg/TJDecompressor.html#setSourceImage(byte[],%20int)">setSourceImage(byte[], int)</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</a></dt>
|
||||
<dd>
|
||||
<div class="block">Associate the JPEG image of length <code>imageSize</code> bytes stored in
|
||||
<div class="block">Associate the JPEG image or "abbreviated table specification" (AKA
|
||||
"tables-only") datastream of length <code>imageSize</code> bytes stored in
|
||||
<code>jpegImage</code> with this decompressor instance.</div>
|
||||
</dd>
|
||||
<dt><span class="strong"><a href="./org/libjpegturbo/turbojpeg/TJDecompressor.html#setSourceImage(org.libjpegturbo.turbojpeg.YUVImage)">setSourceImage(YUVImage)</a></span> - Method in class org.libjpegturbo.turbojpeg.<a href="./org/libjpegturbo/turbojpeg/TJDecompressor.html" title="class in org.libjpegturbo.turbojpeg">TJDecompressor</a></dt>
|
||||
|
||||
@@ -418,7 +418,8 @@ implements java.io.Closeable</pre>
|
||||
<td class="colFirst"><code>void</code></td>
|
||||
<td class="colLast"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJDecompressor.html#setSourceImage(byte[],%20int)">setSourceImage</a></strong>(byte[] jpegImage,
|
||||
int imageSize)</code>
|
||||
<div class="block">Associate the JPEG image of length <code>imageSize</code> bytes stored in
|
||||
<div class="block">Associate the JPEG image or "abbreviated table specification" (AKA
|
||||
"tables-only") datastream of length <code>imageSize</code> bytes stored in
|
||||
<code>jpegImage</code> with this decompressor instance.</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -611,10 +612,19 @@ implements java.io.Closeable</pre>
|
||||
<pre>public void setSourceImage(byte[] jpegImage,
|
||||
int imageSize)
|
||||
throws <a href="../../../org/libjpegturbo/turbojpeg/TJException.html" title="class in org.libjpegturbo.turbojpeg">TJException</a></pre>
|
||||
<div class="block">Associate the JPEG image of length <code>imageSize</code> bytes stored in
|
||||
<code>jpegImage</code> with this decompressor instance. This image will
|
||||
be used as the source image for subsequent decompress operations.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>jpegImage</code> - JPEG image buffer. This buffer is not modified.</dd><dd><code>imageSize</code> - size of the JPEG image (in bytes)</dd>
|
||||
<div class="block">Associate the JPEG image or "abbreviated table specification" (AKA
|
||||
"tables-only") datastream of length <code>imageSize</code> bytes stored in
|
||||
<code>jpegImage</code> with this decompressor instance. If
|
||||
<code>jpegImage</code> contains a JPEG image, then this image will be used
|
||||
as the source image for subsequent decompress operations. Passing a
|
||||
tables-only datastream to this method primes the decompressor with
|
||||
quantization and Huffman tables that can be used when decompressing
|
||||
subsequent "abbreviated image" datastreams. This is useful, for instance,
|
||||
when decompressing video streams in which all frames share the same
|
||||
quantization and Huffman tables.</div>
|
||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>jpegImage</code> - buffer containing a JPEG image or an "abbreviated table
|
||||
specification" (AKA "tables-only") datastream. This buffer is not
|
||||
modified.</dd><dd><code>imageSize</code> - size of the JPEG image (in bytes)</dd>
|
||||
<dt><span class="strong">Throws:</span></dt>
|
||||
<dd><code><a href="../../../org/libjpegturbo/turbojpeg/TJException.html" title="class in org.libjpegturbo.turbojpeg">TJException</a></code></dd></dl>
|
||||
</li>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2011-2015, 2018 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2011-2015, 2018, 2022 D. R. Commander. All Rights Reserved.
|
||||
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -89,11 +89,20 @@ public class TJDecompressor implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate the JPEG image of length <code>imageSize</code> bytes stored in
|
||||
* <code>jpegImage</code> with this decompressor instance. This image will
|
||||
* be used as the source image for subsequent decompress operations.
|
||||
* Associate the JPEG image or "abbreviated table specification" (AKA
|
||||
* "tables-only") datastream of length <code>imageSize</code> bytes stored in
|
||||
* <code>jpegImage</code> with this decompressor instance. If
|
||||
* <code>jpegImage</code> contains a JPEG image, then this image will be used
|
||||
* as the source image for subsequent decompress operations. Passing a
|
||||
* tables-only datastream to this method primes the decompressor with
|
||||
* quantization and Huffman tables that can be used when decompressing
|
||||
* subsequent "abbreviated image" datastreams. This is useful, for instance,
|
||||
* when decompressing video streams in which all frames share the same
|
||||
* quantization and Huffman tables.
|
||||
*
|
||||
* @param jpegImage JPEG image buffer. This buffer is not modified.
|
||||
* @param jpegImage buffer containing a JPEG image or an "abbreviated table
|
||||
* specification" (AKA "tables-only") datastream. This buffer is not
|
||||
* modified.
|
||||
*
|
||||
* @param imageSize size of the JPEG image (in bytes)
|
||||
*/
|
||||
|
||||
@@ -1225,7 +1225,13 @@ DLLEXPORT int tjDecompressHeader3(tjhandle handle,
|
||||
}
|
||||
|
||||
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
|
||||
jpeg_read_header(dinfo, TRUE);
|
||||
|
||||
/* jpeg_read_header() calls jpeg_abort() and returns JPEG_HEADER_TABLES_ONLY
|
||||
if the datastream is a tables-only datastream. Since we aren't using a
|
||||
suspending data source, the only other value it can return is
|
||||
JPEG_HEADER_OK. */
|
||||
if (jpeg_read_header(dinfo, FALSE) == JPEG_HEADER_TABLES_ONLY)
|
||||
return 0;
|
||||
|
||||
*width = dinfo->image_width;
|
||||
*height = dinfo->image_height;
|
||||
|
||||
25
turbojpeg.h
25
turbojpeg.h
@@ -1129,27 +1129,38 @@ DLLEXPORT tjhandle tjInitDecompress(void);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve information about a JPEG image without decompressing it.
|
||||
* Retrieve information about a JPEG image without decompressing it, or prime
|
||||
* the decompressor with quantization and Huffman tables.
|
||||
*
|
||||
* @param handle a handle to a TurboJPEG decompressor or transformer instance
|
||||
*
|
||||
* @param jpegBuf pointer to a buffer containing a JPEG image
|
||||
* @param jpegBuf pointer to a buffer containing a JPEG image or an
|
||||
* "abbreviated table specification" (AKA "tables-only") datastream. Passing a
|
||||
* tables-only datastream to this function primes the decompressor with
|
||||
* quantization and Huffman tables that can be used when decompressing
|
||||
* subsequent "abbreviated image" datastreams. This is useful, for instance,
|
||||
* when decompressing video streams in which all frames share the same
|
||||
* quantization and Huffman tables.
|
||||
*
|
||||
* @param jpegSize size of the JPEG image (in bytes)
|
||||
* @param jpegSize size of the JPEG image or tables-only datastream (in bytes)
|
||||
*
|
||||
* @param width pointer to an integer variable that will receive the width (in
|
||||
* pixels) of the JPEG image
|
||||
* pixels) of the JPEG image. If <tt>jpegBuf</tt> points to a tables-only
|
||||
* datastream, then <tt>width</tt> is ignored.
|
||||
*
|
||||
* @param height pointer to an integer variable that will receive the height
|
||||
* (in pixels) of the JPEG image
|
||||
* (in pixels) of the JPEG image. If <tt>jpegBuf</tt> points to a tables-only
|
||||
* datastream, then <tt>height</tt> is ignored.
|
||||
*
|
||||
* @param jpegSubsamp pointer to an integer variable that will receive the
|
||||
* level of chrominance subsampling used when the JPEG image was compressed
|
||||
* (see @ref TJSAMP "Chrominance subsampling options".)
|
||||
* (see @ref TJSAMP "Chrominance subsampling options".) If <tt>jpegBuf</tt>
|
||||
* points to a tables-only datastream, then <tt>jpegSubsamp</tt> is ignored.
|
||||
*
|
||||
* @param jpegColorspace pointer to an integer variable that will receive one
|
||||
* of the JPEG colorspace constants, indicating the colorspace of the JPEG
|
||||
* image (see @ref TJCS "JPEG colorspaces".)
|
||||
* image (see @ref TJCS "JPEG colorspaces".) If <tt>jpegBuf</tt>
|
||||
* points to a tables-only datastream, then <tt>jpegColorspace</tt> is ignored.
|
||||
*
|
||||
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
|
||||
* and #tjGetErrorCode().)
|
||||
|
||||
Reference in New Issue
Block a user