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:
DRC
2023-01-26 13:11:58 -06:00
parent fc01f4673b
commit 96bc40c1b3
19 changed files with 68 additions and 52 deletions

View File

@@ -490,7 +490,8 @@ enum TJPARAM {
* **Value**
* - `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,
/**
@@ -566,8 +567,8 @@ enum TJPARAM {
*
* Progressive entropy coding will generally improve compression relative to
* baseline entropy coding, but it will reduce compression and decompression
* performance considerably. Implies #TJPARAM_OPTIMIZE. Can be combined
* with #TJPARAM_ARITHMETIC.
* performance considerably. Can be combined with #TJPARAM_ARITHMETIC.
* Implies #TJPARAM_OPTIMIZE unless #TJPARAM_ARITHMETIC is also set.
*/
TJPARAM_PROGRESSIVE,
/**
@@ -602,7 +603,6 @@ enum TJPARAM {
* 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 #TJPARAM_PROGRESSIVE.
* Arithmetic entropy coding is currently only implemented for 8-bit samples.
*/
TJPARAM_ARITHMETIC,
/**
@@ -863,7 +863,8 @@ enum TJXOP {
* generated by this particular transform. Progressive entropy coding will
* generally improve compression relative to baseline entropy coding (the
* 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)
/**
@@ -877,8 +878,7 @@ enum TJXOP {
* generated by this particular transform. 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 #TJXOPT_PROGRESSIVE. Arithmetic entropy coding is currently
* only implemented for 8-bit samples.
* combined with #TJXOPT_PROGRESSIVE.
*/
#define TJXOPT_ARITHMETIC (1 << 7)
/**