TurboJPEG: 8-bit lossless JPEG support

This commit is contained in:
DRC
2022-11-16 15:57:25 -06:00
parent 3fb10c35d8
commit 25ccad99a0
36 changed files with 541 additions and 304 deletions

View File

@@ -377,7 +377,7 @@ public final class TJ {
* The uncompressed source/destination image is stored in bottom-up (Windows,
* OpenGL) order, not top-down (X11) order.
*/
public static final int FLAG_BOTTOMUP = 2;
public static final int FLAG_BOTTOMUP = (1 << 1);
/**
* When decompressing an image that was compressed using chrominance
@@ -386,7 +386,7 @@ public final class TJ {
* creates a smooth transition between neighboring chrominance components in
* order to reduce upsampling artifacts in the decompressed image.
*/
public static final int FLAG_FASTUPSAMPLE = 256;
public static final int FLAG_FASTUPSAMPLE = (1 << 8);
/**
* Use the fastest DCT/IDCT algorithm available in the underlying codec. The
* default if this flag is not specified is implementation-specific. For
@@ -395,7 +395,7 @@ public final class TJ {
* only a very slight effect on accuracy, but it uses the accurate algorithm
* when decompressing, because this has been shown to have a larger effect.
*/
public static final int FLAG_FASTDCT = 2048;
public static final int FLAG_FASTDCT = (1 << 11);
/**
* Use the most accurate DCT/IDCT algorithm available in the underlying
* codec. The default if this flag is not specified is
@@ -405,7 +405,7 @@ public final class TJ {
* but it uses the accurate algorithm when decompressing, because this has
* been shown to have a larger effect.
*/
public static final int FLAG_ACCURATEDCT = 4096;
public static final int FLAG_ACCURATEDCT = (1 << 12);
/**
* Immediately discontinue the current compression/decompression/transform
* operation if the underlying codec throws a warning (non-fatal error). The
@@ -417,7 +417,7 @@ public final class TJ {
* with a void return type) will complete and leave the output image in a
* fully recoverable state after a non-fatal error occurs.
*/
public static final int FLAG_STOPONWARNING = 8192;
public static final int FLAG_STOPONWARNING = (1 << 13);
/**
* Use progressive entropy coding in JPEG images generated by compression and
* transform operations. Progressive entropy coding will generally improve
@@ -425,7 +425,7 @@ public final class TJ {
* reduce compression and decompression performance considerably. Can be
* combined with {@link #FLAG_ARITHMETIC}.
*/
public static final int FLAG_PROGRESSIVE = 16384;
public static final int FLAG_PROGRESSIVE = (1 << 14);
/**
* Limit the number of progressive JPEG scans that the decompression and
* transform operations will process. If a progressive JPEG image contains
@@ -435,7 +435,7 @@ public final class TJ {
* 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>.
*/
public static final int FLAG_LIMITSCANS = 32768;
public static final int FLAG_LIMITSCANS = (1 << 15);
/**
* Use arithmetic entropy coding in JPEG images generated by compression and
* transform operations. Arithmetic entropy coding will generally improve
@@ -443,7 +443,25 @@ public final class TJ {
* reduce compression and decompression performance considerably. Can be
* combined with {@link #FLAG_PROGRESSIVE}.
*/
public static final int FLAG_ARITHMETIC = 65536;
public static final int FLAG_ARITHMETIC = (1 << 16);
/**
* Generate a lossless JPEG image when compressing. In most cases,
* compressing and decompressing lossless JPEG images is considerably slower
* than compressing and decompressing lossy JPEG images. Also note that the
* following features are not available with lossless JPEG images:
* <ul>
* <li> Colorspace conversion
* <li> Chrominance subsampling
* <li> JPEG quality selection
* <li> DCT/IDCT algorithm selection
* <li> Progressive entropy coding
* <li> Arithmetic entropy coding
* <li> Compression from/decompression to YUV planar images
* <li> Decompression scaling
* <li> Lossless transformations
* </ul>
*/
public static final int FLAG_LOSSLESS = (1 << 17);
/**
* The number of error codes