Implement arithmetic coding with 12-bit precision
This actually works and apparently always has worked. It only failed because the libjpeg code, which did not originally support arithmetic coding, assumed that optimize_coding should always be TRUE for 12-bit data precision.
This commit is contained in:
@@ -35,7 +35,12 @@ if(NOT PRECISION EQUAL 16)
|
|||||||
endif()
|
endif()
|
||||||
if(PRECISION EQUAL 8)
|
if(PRECISION EQUAL 8)
|
||||||
run_test(tjbenchtest "-precision;${PRECISION};-progressive;-yuv")
|
run_test(tjbenchtest "-precision;${PRECISION};-progressive;-yuv")
|
||||||
|
endif()
|
||||||
|
if(NOT PRECISION EQUAL 16)
|
||||||
run_test(tjbenchtest "-precision;${PRECISION};-arithmetic")
|
run_test(tjbenchtest "-precision;${PRECISION};-arithmetic")
|
||||||
|
run_test(tjbenchtest "-precision;${PRECISION};-progressive;-arithmetic")
|
||||||
|
endif()
|
||||||
|
if(PRECISION EQUAL 8)
|
||||||
run_test(tjbenchtest "-precision;${PRECISION};-arithmetic;-yuv")
|
run_test(tjbenchtest "-precision;${PRECISION};-arithmetic;-yuv")
|
||||||
endif()
|
endif()
|
||||||
run_test(tjbenchtest "-precision;${PRECISION};-lossless")
|
run_test(tjbenchtest "-precision;${PRECISION};-lossless")
|
||||||
@@ -57,7 +62,12 @@ if(WITH_JAVA)
|
|||||||
endif()
|
endif()
|
||||||
if(PRECISION EQUAL 8)
|
if(PRECISION EQUAL 8)
|
||||||
run_test(tjbenchtest "-java;-precision;${PRECISION};-progressive;-yuv")
|
run_test(tjbenchtest "-java;-precision;${PRECISION};-progressive;-yuv")
|
||||||
|
endif()
|
||||||
|
if(NOT PRECISION EQUAL 16)
|
||||||
run_test(tjbenchtest "-java;-precision;${PRECISION};-arithmetic")
|
run_test(tjbenchtest "-java;-precision;${PRECISION};-arithmetic")
|
||||||
|
run_test(tjbenchtest "-java;-precision;${PRECISION};-progressive;-arithmetic")
|
||||||
|
endif()
|
||||||
|
if(PRECISION EQUAL 8)
|
||||||
run_test(tjbenchtest "-java;-precision;${PRECISION};-arithmetic;-yuv")
|
run_test(tjbenchtest "-java;-precision;${PRECISION};-arithmetic;-yuv")
|
||||||
endif()
|
endif()
|
||||||
run_test(tjbenchtest "-java;-precision;${PRECISION};-lossless")
|
run_test(tjbenchtest "-java;-precision;${PRECISION};-lossless")
|
||||||
|
|||||||
@@ -572,7 +572,7 @@ YUV Image Format Notes</h2>
|
|||||||
</div><div class="memdoc">
|
</div><div class="memdoc">
|
||||||
|
|
||||||
<p>This option will enable arithmetic entropy coding in the JPEG image generated by this particular transform. </p>
|
<p>This option will enable arithmetic entropy coding in the JPEG image generated by this particular transform. </p>
|
||||||
<p>Arithmetic entropy coding will generally improve compression relative to Huffman entropy coding (the default), but it will reduce decompression performance considerably. Can be combined with <a class="el" href="group___turbo_j_p_e_g.html#gad2371c80674584ecc1a7d75e564cf026" title="This option will enable progressive entropy coding in the JPEG image generated by this particular tra...">TJXOPT_PROGRESSIVE</a>. Arithmetic entropy coding is currently only implemented for 8-bit samples. </p>
|
<p>Arithmetic entropy coding will generally improve compression relative to Huffman entropy coding (the default), but it will reduce decompression performance considerably. Can be combined with <a class="el" href="group___turbo_j_p_e_g.html#gad2371c80674584ecc1a7d75e564cf026" title="This option will enable progressive entropy coding in the JPEG image generated by this particular tra...">TJXOPT_PROGRESSIVE</a>. </p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -689,7 +689,7 @@ YUV Image Format Notes</h2>
|
|||||||
</div><div class="memdoc">
|
</div><div class="memdoc">
|
||||||
|
|
||||||
<p>This option will enable progressive entropy coding in the JPEG image generated by this particular transform. </p>
|
<p>This option will enable progressive entropy coding in the JPEG image generated by this particular transform. </p>
|
||||||
<p>Progressive entropy coding will generally improve compression relative to baseline entropy coding (the default), but it will reduce decompression performance considerably. Implies <a class="el" href="group___turbo_j_p_e_g.html#ga6bedf37aa9e1122f3ec9f7302ca59117" title="This option will enable optimized baseline entropy coding in the JPEG image generated by this particu...">TJXOPT_OPTIMIZE</a>. Can be combined with <a class="el" href="group___turbo_j_p_e_g.html#gaecaaa3b7e2af812592c015d83207f010" title="This option will enable arithmetic entropy coding in the JPEG image generated by this particular tran...">TJXOPT_ARITHMETIC</a>. </p>
|
<p>Progressive entropy coding will generally improve compression relative to baseline entropy coding (the default), but it will reduce decompression performance considerably. Can be combined with <a class="el" href="group___turbo_j_p_e_g.html#gaecaaa3b7e2af812592c015d83207f010" title="This option will enable arithmetic entropy coding in the JPEG image generated by this particular tran...">TJXOPT_ARITHMETIC</a>. Implies <a class="el" href="group___turbo_j_p_e_g.html#ga6bedf37aa9e1122f3ec9f7302ca59117" title="This option will enable optimized baseline entropy coding in the JPEG image generated by this particu...">TJXOPT_OPTIMIZE</a> unless <a class="el" href="group___turbo_j_p_e_g.html#gaecaaa3b7e2af812592c015d83207f010" title="This option will enable arithmetic entropy coding in the JPEG image generated by this particular tran...">TJXOPT_ARITHMETIC</a> is also specified. </p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -874,7 +874,7 @@ YUV Image Format Notes</h2>
|
|||||||
<p><b>Value</b></p><ul>
|
<p><b>Value</b></p><ul>
|
||||||
<li><code>8</code>, <code>12</code>, or <code>16</code></li>
|
<li><code>8</code>, <code>12</code>, or <code>16</code></li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>12-bit data precision implies <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82a8f0af9afc0b36443751f9ee82b760aa6" title="Optimized baseline entropy coding [lossy compression only].">TJPARAM_OPTIMIZE</a>. </p>
|
<p>12-bit data precision implies <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82a8f0af9afc0b36443751f9ee82b760aa6" title="Optimized baseline entropy coding [lossy compression only].">TJPARAM_OPTIMIZE</a> unless <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82a1c756757384308145602c040524aebf7" title="Arithmetic entropy coding.">TJPARAM_ARITHMETIC</a> is set. </p>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td class="fieldname"><a id="ggaa0f6be63ba78278299c9f5c12031fe82a46a10d46309514907d0c39fcd86c324c"></a>TJPARAM_COLORSPACE </td><td class="fielddoc"><p>JPEG colorspace. </p>
|
<tr><td class="fieldname"><a id="ggaa0f6be63ba78278299c9f5c12031fe82a46a10d46309514907d0c39fcd86c324c"></a>TJPARAM_COLORSPACE </td><td class="fielddoc"><p>JPEG colorspace. </p>
|
||||||
<p>The JPEG image uses (decompression) or will use (lossy compression) the specified colorspace.</p>
|
<p>The JPEG image uses (decompression) or will use (lossy compression) the specified colorspace.</p>
|
||||||
@@ -912,7 +912,7 @@ YUV Image Format Notes</h2>
|
|||||||
<li><code>0</code> <em>[default for compression, lossless transformation]</em> The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) baseline entropy coding.</li>
|
<li><code>0</code> <em>[default for compression, lossless transformation]</em> The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) baseline entropy coding.</li>
|
||||||
<li><code>1</code> The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) progressive entropy coding. For lossless transformation, this can also be specified using <a class="el" href="group___turbo_j_p_e_g.html#gad2371c80674584ecc1a7d75e564cf026" title="This option will enable progressive entropy coding in the JPEG image generated by this particular tra...">TJXOPT_PROGRESSIVE</a>.</li>
|
<li><code>1</code> The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) progressive entropy coding. For lossless transformation, this can also be specified using <a class="el" href="group___turbo_j_p_e_g.html#gad2371c80674584ecc1a7d75e564cf026" title="This option will enable progressive entropy coding in the JPEG image generated by this particular tra...">TJXOPT_PROGRESSIVE</a>.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Progressive entropy coding will generally improve compression relative to baseline entropy coding, but it will reduce compression and decompression performance considerably. Implies <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82a8f0af9afc0b36443751f9ee82b760aa6" title="Optimized baseline entropy coding [lossy compression only].">TJPARAM_OPTIMIZE</a>. Can be combined with <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82a1c756757384308145602c040524aebf7" title="Arithmetic entropy coding.">TJPARAM_ARITHMETIC</a>. </p>
|
<p>Progressive entropy coding will generally improve compression relative to baseline entropy coding, but it will reduce compression and decompression performance considerably. Can be combined with <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82a1c756757384308145602c040524aebf7" title="Arithmetic entropy coding.">TJPARAM_ARITHMETIC</a>. Implies <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82a8f0af9afc0b36443751f9ee82b760aa6" title="Optimized baseline entropy coding [lossy compression only].">TJPARAM_OPTIMIZE</a> unless <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82a1c756757384308145602c040524aebf7" title="Arithmetic entropy coding.">TJPARAM_ARITHMETIC</a> is also set. </p>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td class="fieldname"><a id="ggaa0f6be63ba78278299c9f5c12031fe82ac478910e20ecf61b914f9824d80f8167"></a>TJPARAM_SCANLIMIT </td><td class="fielddoc"><p>Progressive JPEG scan limit for lossy JPEG images [decompression, lossless transformation]. </p>
|
<tr><td class="fieldname"><a id="ggaa0f6be63ba78278299c9f5c12031fe82ac478910e20ecf61b914f9824d80f8167"></a>TJPARAM_SCANLIMIT </td><td class="fielddoc"><p>Progressive JPEG scan limit for lossy JPEG images [decompression, lossless transformation]. </p>
|
||||||
<p>Setting this parameter will cause the decompression and transform functions to return an error if the number of scans in a progressive JPEG image exceeds the specified limit. The primary purpose of this is to allow security-critical applications to guard against an exploit of the progressive JPEG format described in <a href="https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf" target="_blank">this report</a>.</p>
|
<p>Setting this parameter will cause the decompression and transform functions to return an error if the number of scans in a progressive JPEG image exceeds the specified limit. The primary purpose of this is to allow security-critical applications to guard against an exploit of the progressive JPEG format described in <a href="https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf" target="_blank">this report</a>.</p>
|
||||||
@@ -926,7 +926,7 @@ YUV Image Format Notes</h2>
|
|||||||
<li><code>0</code> <em>[default for compression, lossless transformation]</em> The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) Huffman entropy coding.</li>
|
<li><code>0</code> <em>[default for compression, lossless transformation]</em> The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) Huffman entropy coding.</li>
|
||||||
<li><code>1</code> The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) arithmetic entropy coding. For lossless transformation, this can also be specified using <a class="el" href="group___turbo_j_p_e_g.html#gaecaaa3b7e2af812592c015d83207f010" title="This option will enable arithmetic entropy coding in the JPEG image generated by this particular tran...">TJXOPT_ARITHMETIC</a>.</li>
|
<li><code>1</code> The lossy JPEG image uses (decompression) or will use (compression, lossless transformation) arithmetic entropy coding. For lossless transformation, this can also be specified using <a class="el" href="group___turbo_j_p_e_g.html#gaecaaa3b7e2af812592c015d83207f010" title="This option will enable arithmetic entropy coding in the JPEG image generated by this particular tran...">TJXOPT_ARITHMETIC</a>.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Arithmetic entropy coding will generally improve compression relative to Huffman entropy coding, but it will reduce compression and decompression performance considerably. Can be combined with <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82a1716f242b3859905b4a317dae8cfb75f" title="Progressive entropy coding.">TJPARAM_PROGRESSIVE</a>. Arithmetic entropy coding is currently only implemented for 8-bit samples. </p>
|
<p>Arithmetic entropy coding will generally improve compression relative to Huffman entropy coding, but it will reduce compression and decompression performance considerably. Can be combined with <a class="el" href="group___turbo_j_p_e_g.html#ggaa0f6be63ba78278299c9f5c12031fe82a1716f242b3859905b4a317dae8cfb75f" title="Progressive entropy coding.">TJPARAM_PROGRESSIVE</a>. </p>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td class="fieldname"><a id="ggaa0f6be63ba78278299c9f5c12031fe82a249f35f0770792b19f995e603bb17c6f"></a>TJPARAM_LOSSLESS </td><td class="fielddoc"><p>Lossless JPEG. </p>
|
<tr><td class="fieldname"><a id="ggaa0f6be63ba78278299c9f5c12031fe82a249f35f0770792b19f995e603bb17c6f"></a>TJPARAM_LOSSLESS </td><td class="fielddoc"><p>Lossless JPEG. </p>
|
||||||
<p><b>Value</b></p><ul>
|
<p><b>Value</b></p><ul>
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|||||||
tj3Set(handle, TJPARAM_BOTTOMUP, ti == 0);
|
tj3Set(handle, TJPARAM_BOTTOMUP, ti == 0);
|
||||||
tj3Set(handle, TJPARAM_FASTDCT, ti == 0);
|
tj3Set(handle, TJPARAM_FASTDCT, ti == 0);
|
||||||
tj3Set(handle, TJPARAM_PROGRESSIVE, ti == 1 || ti == 3);
|
tj3Set(handle, TJPARAM_PROGRESSIVE, ti == 1 || ti == 3);
|
||||||
|
tj3Set(handle, TJPARAM_ARITHMETIC, ti == 2 || ti == 3);
|
||||||
tj3Set(handle, TJPARAM_NOREALLOC, ti != 2);
|
tj3Set(handle, TJPARAM_NOREALLOC, ti != 2);
|
||||||
tj3Set(handle, TJPARAM_RESTARTROWS, ti == 1 || ti == 2 ? 2 : 0);
|
tj3Set(handle, TJPARAM_RESTARTROWS, ti == 1 || ti == 2 ? 2 : 0);
|
||||||
|
|
||||||
|
|||||||
@@ -775,6 +775,7 @@ final class TJBench {
|
|||||||
System.out.println(" (use the CMYK pixel format for packed-pixel source/destination buffers)");
|
System.out.println(" (use the CMYK pixel format for packed-pixel source/destination buffers)");
|
||||||
System.out.println("-precision N = Use N-bit data precision when compressing [N is 8, 12, or 16;");
|
System.out.println("-precision N = Use N-bit data precision when compressing [N is 8, 12, or 16;");
|
||||||
System.out.println(" default = 8; if N is 16, then -lossless must also be specified]");
|
System.out.println(" default = 8; if N is 16, then -lossless must also be specified]");
|
||||||
|
System.out.println(" (-precision 12 implies -optimize unless -arithmetic is also specified)");
|
||||||
System.out.println("-quiet = Output results in tabular rather than verbose format");
|
System.out.println("-quiet = Output results in tabular rather than verbose format");
|
||||||
System.out.println("-restart N = When compressing, add a restart marker every N MCU rows (lossy) or");
|
System.out.println("-restart N = When compressing, add a restart marker every N MCU rows (lossy) or");
|
||||||
System.out.println(" N sample rows (lossless) [default = 0 (no restart markers)]. Append 'B'");
|
System.out.println(" N sample rows (lossless) [default = 0 (no restart markers)]. Append 'B'");
|
||||||
@@ -793,7 +794,6 @@ final class TJBench {
|
|||||||
System.out.println("------------------");
|
System.out.println("------------------");
|
||||||
System.out.println("-arithmetic = Use arithmetic entropy coding in JPEG images generated by");
|
System.out.println("-arithmetic = Use arithmetic entropy coding in JPEG images generated by");
|
||||||
System.out.println(" compression and transform operations (can be combined with -progressive)");
|
System.out.println(" compression and transform operations (can be combined with -progressive)");
|
||||||
System.out.println(" ** 8-bit data precision only **");
|
|
||||||
System.out.println("-crop WxH+X+Y = Decompress only the specified region of the JPEG image, where W");
|
System.out.println("-crop WxH+X+Y = Decompress only the specified region of the JPEG image, where W");
|
||||||
System.out.println(" and H are the width and height of the region (0 = maximum possible width");
|
System.out.println(" and H are the width and height of the region (0 = maximum possible width");
|
||||||
System.out.println(" or height) and X and Y are the left and upper boundary of the region, all");
|
System.out.println(" or height) and X and Y are the left and upper boundary of the region, all");
|
||||||
@@ -804,8 +804,8 @@ final class TJBench {
|
|||||||
System.out.println("-optimize = Use optimized baseline entropy coding in JPEG images generated by");
|
System.out.println("-optimize = Use optimized baseline entropy coding in JPEG images generated by");
|
||||||
System.out.println(" compession and transform operations");
|
System.out.println(" compession and transform operations");
|
||||||
System.out.println("-progressive = Use progressive entropy coding in JPEG images generated by");
|
System.out.println("-progressive = Use progressive entropy coding in JPEG images generated by");
|
||||||
System.out.println(" compression and transform operations (implies -optimize; can be combined");
|
System.out.println(" compression and transform operations (can be combined with -arithmetic;");
|
||||||
System.out.println(" with -arithmetic)");
|
System.out.println(" implies -optimize unless -arithmetic is also specified)");
|
||||||
System.out.println("-limitscans = Refuse to decompress or transform progressive JPEG images that");
|
System.out.println("-limitscans = Refuse to decompress or transform progressive JPEG images that");
|
||||||
System.out.println(" have an unreasonably large number of scans");
|
System.out.println(" have an unreasonably large number of scans");
|
||||||
System.out.println("-scale M/N = When decompressing, scale the width/height of the JPEG image by a");
|
System.out.println("-scale M/N = When decompressing, scale the width/height of the JPEG image by a");
|
||||||
@@ -1087,8 +1087,6 @@ final class TJBench {
|
|||||||
|
|
||||||
if (precision == 16 && !lossless)
|
if (precision == 16 && !lossless)
|
||||||
throw new Exception("-lossless must be specified along with -precision 16");
|
throw new Exception("-lossless must be specified along with -precision 16");
|
||||||
if (precision != 8 && arithmetic)
|
|
||||||
throw new Exception("-arithmetic requires 8-bit data precision");
|
|
||||||
if (precision != 8 && doYUV)
|
if (precision != 8 && doYUV)
|
||||||
throw new Exception("-yuv requires 8-bit data precision");
|
throw new Exception("-yuv requires 8-bit data precision");
|
||||||
if (lossless && doYUV)
|
if (lossless && doYUV)
|
||||||
|
|||||||
Binary file not shown.
@@ -1367,7 +1367,8 @@ extends java.lang.Object</pre>
|
|||||||
<li> <code>8</code>, <code>12</code>, or <code>16</code>
|
<li> <code>8</code>, <code>12</code>, or <code>16</code>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>12-bit data precision implies <a href="#PARAM_OPTIMIZE"><code>PARAM_OPTIMIZE</code></a>.</div>
|
<p>12-bit data precision implies <a href="#PARAM_OPTIMIZE"><code>PARAM_OPTIMIZE</code></a> unless
|
||||||
|
<a href="#PARAM_ARITHMETIC"><code>PARAM_ARITHMETIC</code></a> is set.</div>
|
||||||
<dl>
|
<dl>
|
||||||
<dt><span class="seeLabel">See Also:</span></dt>
|
<dt><span class="seeLabel">See Also:</span></dt>
|
||||||
<dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.PARAM_PRECISION">Constant Field Values</a></dd>
|
<dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.PARAM_PRECISION">Constant Field Values</a></dd>
|
||||||
@@ -1511,8 +1512,9 @@ extends java.lang.Object</pre>
|
|||||||
|
|
||||||
<p>Progressive entropy coding will generally improve compression relative
|
<p>Progressive entropy coding will generally improve compression relative
|
||||||
to baseline entropy coding, but it will reduce compression and
|
to baseline entropy coding, but it will reduce compression and
|
||||||
decompression performance considerably. Implies <a href="#PARAM_OPTIMIZE"><code>PARAM_OPTIMIZE</code></a>.
|
decompression performance considerably. Can be combined with
|
||||||
Can be combined with <a href="#PARAM_ARITHMETIC"><code>PARAM_ARITHMETIC</code></a>.</div>
|
<a href="#PARAM_ARITHMETIC"><code>PARAM_ARITHMETIC</code></a>. Implies <a href="#PARAM_OPTIMIZE"><code>PARAM_OPTIMIZE</code></a> unless
|
||||||
|
<a href="#PARAM_ARITHMETIC"><code>PARAM_ARITHMETIC</code></a> is also set.</div>
|
||||||
<dl>
|
<dl>
|
||||||
<dt><span class="seeLabel">See Also:</span></dt>
|
<dt><span class="seeLabel">See Also:</span></dt>
|
||||||
<dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.PARAM_PROGRESSIVE">Constant Field Values</a></dd>
|
<dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.PARAM_PROGRESSIVE">Constant Field Values</a></dd>
|
||||||
@@ -1572,8 +1574,7 @@ extends java.lang.Object</pre>
|
|||||||
<p>Arithmetic entropy coding will generally improve compression relative
|
<p>Arithmetic entropy coding will generally improve compression relative
|
||||||
to Huffman entropy coding, but it will reduce compression and
|
to Huffman entropy coding, but it will reduce compression and
|
||||||
decompression performance considerably. Can be combined with
|
decompression performance considerably. Can be combined with
|
||||||
<a href="#PARAM_PROGRESSIVE"><code>PARAM_PROGRESSIVE</code></a>. Arithmetic entropy coding is currently only
|
<a href="#PARAM_PROGRESSIVE"><code>PARAM_PROGRESSIVE</code></a>.</div>
|
||||||
implemented for 8-bit samples.</div>
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt><span class="seeLabel">See Also:</span></dt>
|
<dt><span class="seeLabel">See Also:</span></dt>
|
||||||
<dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.PARAM_ARITHMETIC">Constant Field Values</a></dd>
|
<dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJ.PARAM_ARITHMETIC">Constant Field Values</a></dd>
|
||||||
|
|||||||
@@ -700,8 +700,8 @@ extends java.awt.Rectangle</pre>
|
|||||||
generated by this particular transform. Progressive entropy coding will
|
generated by this particular transform. Progressive entropy coding will
|
||||||
generally improve compression relative to baseline entropy coding (the
|
generally improve compression relative to baseline entropy coding (the
|
||||||
default), but it will reduce decompression performance considerably.
|
default), but it will reduce decompression performance considerably.
|
||||||
Implies <a href="#OPT_OPTIMIZE"><code>OPT_OPTIMIZE</code></a>. Can be combined with
|
Can be combined with <a href="#OPT_ARITHMETIC"><code>OPT_ARITHMETIC</code></a>. Implies
|
||||||
<a href="#OPT_ARITHMETIC"><code>OPT_ARITHMETIC</code></a>.</div>
|
<a href="#OPT_OPTIMIZE"><code>OPT_OPTIMIZE</code></a> unless <a href="#OPT_ARITHMETIC"><code>OPT_ARITHMETIC</code></a> is also specified.</div>
|
||||||
<dl>
|
<dl>
|
||||||
<dt><span class="seeLabel">See Also:</span></dt>
|
<dt><span class="seeLabel">See Also:</span></dt>
|
||||||
<dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJTransform.OPT_PROGRESSIVE">Constant Field Values</a></dd>
|
<dd><a href="../../../constant-values.html#org.libjpegturbo.turbojpeg.TJTransform.OPT_PROGRESSIVE">Constant Field Values</a></dd>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -465,7 +465,8 @@ public final class TJ {
|
|||||||
* <li> <code>8</code>, <code>12</code>, or <code>16</code>
|
* <li> <code>8</code>, <code>12</code>, or <code>16</code>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* <p>12-bit data precision implies {@link #PARAM_OPTIMIZE}.
|
* <p>12-bit data precision implies {@link #PARAM_OPTIMIZE} unless
|
||||||
|
* {@link #PARAM_ARITHMETIC} is set.
|
||||||
*/
|
*/
|
||||||
public static final int PARAM_PRECISION = 7;
|
public static final int PARAM_PRECISION = 7;
|
||||||
/**
|
/**
|
||||||
@@ -559,8 +560,9 @@ public final class TJ {
|
|||||||
*
|
*
|
||||||
* <p>Progressive entropy coding will generally improve compression relative
|
* <p>Progressive entropy coding will generally improve compression relative
|
||||||
* to baseline entropy coding, but it will reduce compression and
|
* to baseline entropy coding, but it will reduce compression and
|
||||||
* decompression performance considerably. Implies {@link #PARAM_OPTIMIZE}.
|
* decompression performance considerably. Can be combined with
|
||||||
* Can be combined with {@link #PARAM_ARITHMETIC}.
|
* {@link #PARAM_ARITHMETIC}. Implies {@link #PARAM_OPTIMIZE} unless
|
||||||
|
* {@link #PARAM_ARITHMETIC} is also set.
|
||||||
*/
|
*/
|
||||||
public static final int PARAM_PROGRESSIVE = 12;
|
public static final int PARAM_PROGRESSIVE = 12;
|
||||||
/**
|
/**
|
||||||
@@ -601,8 +603,7 @@ public final class TJ {
|
|||||||
* <p>Arithmetic entropy coding will generally improve compression relative
|
* <p>Arithmetic entropy coding will generally improve compression relative
|
||||||
* to Huffman entropy coding, but it will reduce compression and
|
* to Huffman entropy coding, but it will reduce compression and
|
||||||
* decompression performance considerably. Can be combined with
|
* decompression performance considerably. Can be combined with
|
||||||
* {@link #PARAM_PROGRESSIVE}. Arithmetic entropy coding is currently only
|
* {@link #PARAM_PROGRESSIVE}.
|
||||||
* implemented for 8-bit samples.
|
|
||||||
*/
|
*/
|
||||||
public static final int PARAM_ARITHMETIC = 14;
|
public static final int PARAM_ARITHMETIC = 14;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -133,8 +133,8 @@ public class TJTransform extends Rectangle {
|
|||||||
* generated by this particular transform. Progressive entropy coding will
|
* generated by this particular transform. Progressive entropy coding will
|
||||||
* generally improve compression relative to baseline entropy coding (the
|
* generally improve compression relative to baseline entropy coding (the
|
||||||
* default), but it will reduce decompression performance considerably.
|
* default), but it will reduce decompression performance considerably.
|
||||||
* Implies {@link #OPT_OPTIMIZE}. Can be combined with
|
* Can be combined with {@link #OPT_ARITHMETIC}. Implies
|
||||||
* {@link #OPT_ARITHMETIC}.
|
* {@link #OPT_OPTIMIZE} unless {@link #OPT_ARITHMETIC} is also specified.
|
||||||
*/
|
*/
|
||||||
public static final int OPT_PROGRESSIVE = (1 << 5);
|
public static final int OPT_PROGRESSIVE = (1 << 5);
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -914,9 +914,6 @@ jinit_arith_encoder(j_compress_ptr cinfo)
|
|||||||
arith_entropy_ptr entropy;
|
arith_entropy_ptr entropy;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (cinfo->data_precision != 8)
|
|
||||||
ERREXIT(cinfo, JERR_NOTIMPL);
|
|
||||||
|
|
||||||
entropy = (arith_entropy_ptr)
|
entropy = (arith_entropy_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||||
sizeof(arith_entropy_encoder));
|
sizeof(arith_entropy_encoder));
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* Lossless JPEG Modifications:
|
* Lossless JPEG Modifications:
|
||||||
* Copyright (C) 1999, Ken Murchison.
|
* Copyright (C) 1999, Ken Murchison.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2010, 2016, 2018, 2022, D. R. Commander.
|
* Copyright (C) 2010, 2016, 2018, 2022-2023, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -646,7 +646,7 @@ jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
(cinfo->progressive_mode && !cinfo->arith_code))
|
(cinfo->progressive_mode && !cinfo->arith_code))
|
||||||
cinfo->optimize_coding = TRUE; /* assume default tables no good for
|
cinfo->optimize_coding = TRUE; /* assume default tables no good for
|
||||||
progressive mode or lossless mode */
|
progressive mode or lossless mode */
|
||||||
if (cinfo->data_precision == 12)
|
if (cinfo->data_precision == 12 && !cinfo->arith_code)
|
||||||
cinfo->optimize_coding = TRUE; /* assume default tables no good for 12-bit
|
cinfo->optimize_coding = TRUE; /* assume default tables no good for 12-bit
|
||||||
data precision */
|
data precision */
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* Lossless JPEG Modifications:
|
* Lossless JPEG Modifications:
|
||||||
* Copyright (C) 1999, Ken Murchison.
|
* Copyright (C) 1999, Ken Murchison.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2009-2011, 2018, D. R. Commander.
|
* Copyright (C) 2009-2011, 2018, 2023, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -233,7 +233,7 @@ jpeg_set_defaults(j_compress_ptr cinfo)
|
|||||||
* tables will be computed. This test can be removed if default tables
|
* tables will be computed. This test can be removed if default tables
|
||||||
* are supplied that are valid for the desired precision.
|
* are supplied that are valid for the desired precision.
|
||||||
*/
|
*/
|
||||||
if (cinfo->data_precision > 8)
|
if (cinfo->data_precision == 12 && !cinfo->arith_code)
|
||||||
cinfo->optimize_coding = TRUE;
|
cinfo->optimize_coding = TRUE;
|
||||||
|
|
||||||
/* By default, use the simpler non-cosited sampling alignment */
|
/* By default, use the simpler non-cosited sampling alignment */
|
||||||
|
|||||||
@@ -752,9 +752,6 @@ jinit_arith_decoder(j_decompress_ptr cinfo)
|
|||||||
arith_entropy_ptr entropy;
|
arith_entropy_ptr entropy;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (cinfo->data_precision != 8)
|
|
||||||
ERREXIT(cinfo, JERR_NOTIMPL);
|
|
||||||
|
|
||||||
entropy = (arith_entropy_ptr)
|
entropy = (arith_entropy_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||||
sizeof(arith_entropy_decoder));
|
sizeof(arith_entropy_decoder));
|
||||||
|
|||||||
10
tjbench.c
10
tjbench.c
@@ -901,6 +901,7 @@ static void usage(char *progName)
|
|||||||
printf(" (use the CMYK pixel format for packed-pixel source/destination buffers)\n");
|
printf(" (use the CMYK pixel format for packed-pixel source/destination buffers)\n");
|
||||||
printf("-precision N = Use N-bit data precision when compressing [N is 8, 12, or 16;\n");
|
printf("-precision N = Use N-bit data precision when compressing [N is 8, 12, or 16;\n");
|
||||||
printf(" default = 8; if N is 16, then -lossless must also be specified]\n");
|
printf(" default = 8; if N is 16, then -lossless must also be specified]\n");
|
||||||
|
printf(" (-precision 12 implies -optimize unless -arithmetic is also specified)\n");
|
||||||
printf("-quiet = Output results in tabular rather than verbose format\n");
|
printf("-quiet = Output results in tabular rather than verbose format\n");
|
||||||
printf("-restart N = When compressing, add a restart marker every N MCU rows (lossy) or\n");
|
printf("-restart N = When compressing, add a restart marker every N MCU rows (lossy) or\n");
|
||||||
printf(" N sample rows (lossless) [default = 0 (no restart markers)]. Append 'B'\n");
|
printf(" N sample rows (lossless) [default = 0 (no restart markers)]. Append 'B'\n");
|
||||||
@@ -919,7 +920,6 @@ static void usage(char *progName)
|
|||||||
printf("------------------\n");
|
printf("------------------\n");
|
||||||
printf("-arithmetic = Use arithmetic entropy coding in JPEG images generated by\n");
|
printf("-arithmetic = Use arithmetic entropy coding in JPEG images generated by\n");
|
||||||
printf(" compression and transform operations (can be combined with -progressive)\n");
|
printf(" compression and transform operations (can be combined with -progressive)\n");
|
||||||
printf(" ** 8-bit data precision only **\n");
|
|
||||||
printf("-crop WxH+X+Y = Decompress only the specified region of the JPEG image, where W\n");
|
printf("-crop WxH+X+Y = Decompress only the specified region of the JPEG image, where W\n");
|
||||||
printf(" and H are the width and height of the region (0 = maximum possible width\n");
|
printf(" and H are the width and height of the region (0 = maximum possible width\n");
|
||||||
printf(" or height) and X and Y are the left and upper boundary of the region, all\n");
|
printf(" or height) and X and Y are the left and upper boundary of the region, all\n");
|
||||||
@@ -930,8 +930,8 @@ static void usage(char *progName)
|
|||||||
printf("-optimize = Use optimized baseline entropy coding in JPEG images generated by\n");
|
printf("-optimize = Use optimized baseline entropy coding in JPEG images generated by\n");
|
||||||
printf(" compession and transform operations\n");
|
printf(" compession and transform operations\n");
|
||||||
printf("-progressive = Use progressive entropy coding in JPEG images generated by\n");
|
printf("-progressive = Use progressive entropy coding in JPEG images generated by\n");
|
||||||
printf(" compression and transform operations (implies -optimize; can be combined\n");
|
printf(" compression and transform operations (can be combined with -arithmetic;\n");
|
||||||
printf(" with -arithmetic)\n");
|
printf(" implies -optimize unless -arithmetic is also specified)\n");
|
||||||
printf("-limitscans = Refuse to decompress or transform progressive JPEG images that\n");
|
printf("-limitscans = Refuse to decompress or transform progressive JPEG images that\n");
|
||||||
printf(" have an unreasonably large number of scans\n");
|
printf(" have an unreasonably large number of scans\n");
|
||||||
printf("-scale M/N = When decompressing, scale the width/height of the JPEG image by a\n");
|
printf("-scale M/N = When decompressing, scale the width/height of the JPEG image by a\n");
|
||||||
@@ -1159,10 +1159,6 @@ int main(int argc, char *argv[])
|
|||||||
printf("ERROR: -lossless must be specified along with -precision 16\n");
|
printf("ERROR: -lossless must be specified along with -precision 16\n");
|
||||||
retval = -1; goto bailout;
|
retval = -1; goto bailout;
|
||||||
}
|
}
|
||||||
if (precision != 8 && arithmetic) {
|
|
||||||
printf("ERROR: -arithmetic requires 8-bit data precision\n");
|
|
||||||
retval = -1; goto bailout;
|
|
||||||
}
|
|
||||||
if (precision != 8 && doYUV) {
|
if (precision != 8 && doYUV) {
|
||||||
printf("ERROR: -yuv requires 8-bit data precision\n");
|
printf("ERROR: -yuv requires 8-bit data precision\n");
|
||||||
retval = -1; goto bailout;
|
retval = -1; goto bailout;
|
||||||
|
|||||||
@@ -84,10 +84,18 @@ while [ $# -gt 0 ]; do
|
|||||||
ENTROPYARG=-optimize
|
ENTROPYARG=-optimize
|
||||||
;;
|
;;
|
||||||
-progressive)
|
-progressive)
|
||||||
ENTROPYARG=-progressive
|
if [ "$ENTROPYARG" = "-arithmetic" ]; then
|
||||||
|
ENTROPYARG=-progressive-arithmetic
|
||||||
|
else
|
||||||
|
ENTROPYARG=-progressive
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
-arithmetic)
|
-arithmetic)
|
||||||
ENTROPYARG=-arithmetic
|
if [ "$ENTROPYARG" = "-progressive" ]; then
|
||||||
|
ENTROPYARG=-progressive-arithmetic
|
||||||
|
else
|
||||||
|
ENTROPYARG=-arithmetic
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
-lossless)
|
-lossless)
|
||||||
LOSSLSARG="-lossless"
|
LOSSLSARG="-lossless"
|
||||||
@@ -115,13 +123,18 @@ if [ $PRECISION = 8 -a "$YUVARG" = "" ]; then
|
|||||||
IMAGES="vgl_6434_0018a.${EXT}"
|
IMAGES="vgl_6434_0018a.${EXT}"
|
||||||
elif [ "$ENTROPYARG" = "-progressive" ]; then
|
elif [ "$ENTROPYARG" = "-progressive" ]; then
|
||||||
IMAGES="vgl_6548_0026a.${EXT}"
|
IMAGES="vgl_6548_0026a.${EXT}"
|
||||||
elif [ "$ENTROPYARG" = "-arithmetic" ]; then
|
elif [ "$ENTROPYARG" = "-arithmetic" -o \
|
||||||
|
"$ENTROPYARG" = "-progressive-arithmetic" ]; then
|
||||||
IMAGES="big_tree8.${EXT}"
|
IMAGES="big_tree8.${EXT}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec >$EXEDIR/tjbenchtest$JAVAARG$YUVARG$ALLOCARG$ENTROPYARG$LOSSLSARG-$PRECISION.log
|
exec >$EXEDIR/tjbenchtest$JAVAARG$YUVARG$ALLOCARG$ENTROPYARG$LOSSLSARG-$PRECISION.log
|
||||||
|
|
||||||
|
if [ "$ENTROPYARG" = "-progressive-arithmetic" ]; then
|
||||||
|
ENTROPYARG="-progressive -arithmetic"
|
||||||
|
fi
|
||||||
|
|
||||||
# Standard tests
|
# Standard tests
|
||||||
for image in $IMAGES; do
|
for image in $IMAGES; do
|
||||||
|
|
||||||
|
|||||||
@@ -2728,8 +2728,10 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
|
|||||||
if (this->progressive || t[i].options & TJXOPT_PROGRESSIVE)
|
if (this->progressive || t[i].options & TJXOPT_PROGRESSIVE)
|
||||||
jpeg_simple_progression(cinfo);
|
jpeg_simple_progression(cinfo);
|
||||||
#endif
|
#endif
|
||||||
if (this->arithmetic || t[i].options & TJXOPT_ARITHMETIC)
|
if (this->arithmetic || t[i].options & TJXOPT_ARITHMETIC) {
|
||||||
cinfo->arith_code = TRUE;
|
cinfo->arith_code = TRUE;
|
||||||
|
cinfo->optimize_coding = FALSE;
|
||||||
|
}
|
||||||
if (!(t[i].options & TJXOPT_NOOUTPUT)) {
|
if (!(t[i].options & TJXOPT_NOOUTPUT)) {
|
||||||
jpeg_write_coefficients(cinfo, dstcoefs);
|
jpeg_write_coefficients(cinfo, dstcoefs);
|
||||||
jcopy_markers_execute(dinfo, cinfo, t[i].options & TJXOPT_COPYNONE ?
|
jcopy_markers_execute(dinfo, cinfo, t[i].options & TJXOPT_COPYNONE ?
|
||||||
|
|||||||
14
turbojpeg.h
14
turbojpeg.h
@@ -490,7 +490,8 @@ enum TJPARAM {
|
|||||||
* **Value**
|
* **Value**
|
||||||
* - `8`, `12`, or `16`
|
* - `8`, `12`, or `16`
|
||||||
*
|
*
|
||||||
* 12-bit data precision implies #TJPARAM_OPTIMIZE.
|
* 12-bit data precision implies #TJPARAM_OPTIMIZE unless #TJPARAM_ARITHMETIC
|
||||||
|
* is set.
|
||||||
*/
|
*/
|
||||||
TJPARAM_PRECISION,
|
TJPARAM_PRECISION,
|
||||||
/**
|
/**
|
||||||
@@ -566,8 +567,8 @@ enum TJPARAM {
|
|||||||
*
|
*
|
||||||
* Progressive entropy coding will generally improve compression relative to
|
* Progressive entropy coding will generally improve compression relative to
|
||||||
* baseline entropy coding, but it will reduce compression and decompression
|
* baseline entropy coding, but it will reduce compression and decompression
|
||||||
* performance considerably. Implies #TJPARAM_OPTIMIZE. Can be combined
|
* performance considerably. Can be combined with #TJPARAM_ARITHMETIC.
|
||||||
* with #TJPARAM_ARITHMETIC.
|
* Implies #TJPARAM_OPTIMIZE unless #TJPARAM_ARITHMETIC is also set.
|
||||||
*/
|
*/
|
||||||
TJPARAM_PROGRESSIVE,
|
TJPARAM_PROGRESSIVE,
|
||||||
/**
|
/**
|
||||||
@@ -602,7 +603,6 @@ enum TJPARAM {
|
|||||||
* Arithmetic entropy coding will generally improve compression relative to
|
* Arithmetic entropy coding will generally improve compression relative to
|
||||||
* Huffman entropy coding, but it will reduce compression and decompression
|
* Huffman entropy coding, but it will reduce compression and decompression
|
||||||
* performance considerably. Can be combined with #TJPARAM_PROGRESSIVE.
|
* performance considerably. Can be combined with #TJPARAM_PROGRESSIVE.
|
||||||
* Arithmetic entropy coding is currently only implemented for 8-bit samples.
|
|
||||||
*/
|
*/
|
||||||
TJPARAM_ARITHMETIC,
|
TJPARAM_ARITHMETIC,
|
||||||
/**
|
/**
|
||||||
@@ -863,7 +863,8 @@ enum TJXOP {
|
|||||||
* generated by this particular transform. Progressive entropy coding will
|
* generated by this particular transform. Progressive entropy coding will
|
||||||
* generally improve compression relative to baseline entropy coding (the
|
* generally improve compression relative to baseline entropy coding (the
|
||||||
* default), but it will reduce decompression performance considerably.
|
* default), but it will reduce decompression performance considerably.
|
||||||
* Implies #TJXOPT_OPTIMIZE. Can be combined with #TJXOPT_ARITHMETIC.
|
* Can be combined with #TJXOPT_ARITHMETIC. Implies #TJXOPT_OPTIMIZE unless
|
||||||
|
* #TJXOPT_ARITHMETIC is also specified.
|
||||||
*/
|
*/
|
||||||
#define TJXOPT_PROGRESSIVE (1 << 5)
|
#define TJXOPT_PROGRESSIVE (1 << 5)
|
||||||
/**
|
/**
|
||||||
@@ -877,8 +878,7 @@ enum TJXOP {
|
|||||||
* generated by this particular transform. Arithmetic entropy coding will
|
* generated by this particular transform. Arithmetic entropy coding will
|
||||||
* generally improve compression relative to Huffman entropy coding (the
|
* generally improve compression relative to Huffman entropy coding (the
|
||||||
* default), but it will reduce decompression performance considerably. Can be
|
* default), but it will reduce decompression performance considerably. Can be
|
||||||
* combined with #TJXOPT_PROGRESSIVE. Arithmetic entropy coding is currently
|
* combined with #TJXOPT_PROGRESSIVE.
|
||||||
* only implemented for 8-bit samples.
|
|
||||||
*/
|
*/
|
||||||
#define TJXOPT_ARITHMETIC (1 << 7)
|
#define TJXOPT_ARITHMETIC (1 << 7)
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user