TurboJPEG: Fix 12-bit-per-sample arith-coded compr
(Regression introduced by7bb958b732) Because of7bb958b732, the TurboJPEG compression and encoding functions no longer transfer the value of TJPARAM_OPTIMIZE into cinfo->data_precision unless the data precision is 8. The intent of that was to prevent using_std_huff_tables() from being called more than once when reusing the same compressor object to generate multiple 12-bit-per-sample JPEG images. However, because cinfo->optimize_coding is always set to TRUE by jpeg_set_defaults() if the data precision is 12, calling applications that use 12-bit data precision had to unset cinfo->optimize_coding if they set cinfo->arith_code after calling jpeg_set_defaults(). Because of7bb958b732, the TurboJPEG API stopped doing that except with 8-bit data precision. Thus, attempting to generate a 12-bit-per-sample arithmetic-coded lossy JPEG image using the TurboJPEG API failed with "Requested features are incompatible." Since the compressor will always fail if cinfo->arith_code and cinfo->optimize_coding are both set, and since cinfo->optimize_coding has no relevance for arithmetic coding, the most robust and user-proof solution is for jinit_c_master_control() to set cinfo->optimize_coding to FALSE if cinfo->arith_code is TRUE. This commit also: - modifies TJBench so that it no longer reports that it is using optimized baseline entropy coding in modes where that setting is irrelevant, - amends the cjpeg documentation to clarify that -optimize is implied when specifying -progressive or '-precision 12' without -arithmetic, and - prevents jpeg_set_defaults() from uselessly checking the value of cinfo->arith_code immediately after it has been set to FALSE.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C)2009-2014, 2016-2019, 2021-2023 D. R. Commander.
|
||||
* Copyright (C)2009-2014, 2016-2019, 2021-2024 D. R. Commander.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -926,7 +926,6 @@ final class TJBench {
|
||||
System.out.println("Using fastest DCT/IDCT algorithm\n");
|
||||
fastDCT = true;
|
||||
} else if (argv[i].equalsIgnoreCase("-optimize")) {
|
||||
System.out.println("Using optimized baseline entropy coding\n");
|
||||
optimize = true;
|
||||
xformOpt |= TJTransform.OPT_OPTIMIZE;
|
||||
} else if (argv[i].equalsIgnoreCase("-progressive")) {
|
||||
@@ -1127,6 +1126,10 @@ final class TJBench {
|
||||
}
|
||||
}
|
||||
|
||||
if (optimize && !progressive && !arithmetic && !lossless &&
|
||||
precision != 12)
|
||||
System.out.println("Using optimized baseline entropy coding\n");
|
||||
|
||||
if (precision == 16 && !lossless)
|
||||
throw new Exception("-lossless must be specified along with -precision 16");
|
||||
if (precision != 8 && doYUV)
|
||||
|
||||
Reference in New Issue
Block a user