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

@@ -2728,8 +2728,10 @@ DLLEXPORT int tj3Transform(tjhandle handle, const unsigned char *jpegBuf,
if (this->progressive || t[i].options & TJXOPT_PROGRESSIVE)
jpeg_simple_progression(cinfo);
#endif
if (this->arithmetic || t[i].options & TJXOPT_ARITHMETIC)
if (this->arithmetic || t[i].options & TJXOPT_ARITHMETIC) {
cinfo->arith_code = TRUE;
cinfo->optimize_coding = FALSE;
}
if (!(t[i].options & TJXOPT_NOOUTPUT)) {
jpeg_write_coefficients(cinfo, dstcoefs);
jcopy_markers_execute(dinfo, cinfo, t[i].options & TJXOPT_COPYNONE ?