TurboJPEG: 8-bit lossless JPEG support
This commit is contained in:
58
turbojpeg.h
58
turbojpeg.h
@@ -370,7 +370,7 @@ enum TJCS {
|
||||
* The uncompressed source/destination image is stored in bottom-up (Windows,
|
||||
* OpenGL) order, not top-down (X11) order.
|
||||
*/
|
||||
#define TJFLAG_BOTTOMUP 2
|
||||
#define TJFLAG_BOTTOMUP (1 << 1)
|
||||
/**
|
||||
* When decompressing an image that was compressed using chrominance
|
||||
* subsampling, use the fastest chrominance upsampling algorithm available in
|
||||
@@ -378,7 +378,7 @@ enum TJCS {
|
||||
* creates a smooth transition between neighboring chrominance components in
|
||||
* order to reduce upsampling artifacts in the decompressed image.
|
||||
*/
|
||||
#define TJFLAG_FASTUPSAMPLE 256
|
||||
#define TJFLAG_FASTUPSAMPLE (1 << 8)
|
||||
/**
|
||||
* Disable buffer (re)allocation. If passed to one of the JPEG compression or
|
||||
* transform functions, this flag will cause those functions to generate an
|
||||
@@ -386,7 +386,7 @@ enum TJCS {
|
||||
* attempting to allocate or reallocate that buffer. This reproduces the
|
||||
* behavior of earlier versions of TurboJPEG.
|
||||
*/
|
||||
#define TJFLAG_NOREALLOC 1024
|
||||
#define TJFLAG_NOREALLOC (1 << 10)
|
||||
/**
|
||||
* 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 @@ enum TJCS {
|
||||
* 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.
|
||||
*/
|
||||
#define TJFLAG_FASTDCT 2048
|
||||
#define TJFLAG_FASTDCT (1 << 11)
|
||||
/**
|
||||
* Use the most accurate DCT/IDCT algorithm available in the underlying codec.
|
||||
* The default if this flag is not specified is implementation-specific. For
|
||||
@@ -404,14 +404,14 @@ enum TJCS {
|
||||
* 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.
|
||||
*/
|
||||
#define TJFLAG_ACCURATEDCT 4096
|
||||
#define TJFLAG_ACCURATEDCT (1 << 12)
|
||||
/**
|
||||
* Immediately discontinue the current compression/decompression/transform
|
||||
* operation if the underlying codec throws a warning (non-fatal error). The
|
||||
* default behavior is to allow the operation to complete unless a fatal error
|
||||
* is encountered.
|
||||
*/
|
||||
#define TJFLAG_STOPONWARNING 8192
|
||||
#define TJFLAG_STOPONWARNING (1 << 13)
|
||||
/**
|
||||
* Use progressive entropy coding in JPEG images generated by the compression
|
||||
* and transform functions. Progressive entropy coding will generally improve
|
||||
@@ -419,7 +419,7 @@ enum TJCS {
|
||||
* reduce compression and decompression performance considerably. Can be
|
||||
* combined with #TJFLAG_ARITHMETIC.
|
||||
*/
|
||||
#define TJFLAG_PROGRESSIVE 16384
|
||||
#define TJFLAG_PROGRESSIVE (1 << 14)
|
||||
/**
|
||||
* Limit the number of progressive JPEG scans that the decompression and
|
||||
* transform functions will process. If a progressive JPEG image contains an
|
||||
@@ -429,7 +429,7 @@ enum TJCS {
|
||||
* 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>.
|
||||
*/
|
||||
#define TJFLAG_LIMITSCANS 32768
|
||||
#define TJFLAG_LIMITSCANS (1 << 15)
|
||||
/**
|
||||
* Use arithmetic entropy coding in JPEG images generated by the compression
|
||||
* and transform functions. Arithmetic entropy coding will generally improve
|
||||
@@ -437,7 +437,23 @@ enum TJCS {
|
||||
* reduce compression and decompression performance considerably. Can be
|
||||
* combined with #TJFLAG_PROGRESSIVE.
|
||||
*/
|
||||
#define TJFLAG_ARITHMETIC 65536
|
||||
#define TJFLAG_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:
|
||||
* - Colorspace conversion
|
||||
* - Chrominance subsampling
|
||||
* - JPEG quality selection
|
||||
* - DCT/IDCT algorithm selection
|
||||
* - Progressive entropy coding
|
||||
* - Arithmetic entropy coding
|
||||
* - Compression from/decompression to YUV planar images
|
||||
* - Decompression scaling
|
||||
* - Lossless transformations
|
||||
*/
|
||||
#define TJFLAG_LOSSLESS (1 << 17)
|
||||
|
||||
|
||||
/**
|
||||
@@ -527,29 +543,29 @@ enum TJXOP {
|
||||
* that cannot be transformed will be left in place, which will create
|
||||
* odd-looking strips on the right or bottom edge of the image.
|
||||
*/
|
||||
#define TJXOPT_PERFECT 1
|
||||
#define TJXOPT_PERFECT (1 << 0)
|
||||
/**
|
||||
* This option will cause #tjTransform() to discard any partial MCU blocks that
|
||||
* cannot be transformed.
|
||||
*/
|
||||
#define TJXOPT_TRIM 2
|
||||
#define TJXOPT_TRIM (1 << 1)
|
||||
/**
|
||||
* This option will enable lossless cropping. See #tjTransform() for more
|
||||
* information.
|
||||
*/
|
||||
#define TJXOPT_CROP 4
|
||||
#define TJXOPT_CROP (1 << 2)
|
||||
/**
|
||||
* This option will discard the color data in the input image and produce
|
||||
* a grayscale output image.
|
||||
*/
|
||||
#define TJXOPT_GRAY 8
|
||||
#define TJXOPT_GRAY (1 << 3)
|
||||
/**
|
||||
* This option will prevent #tjTransform() from outputting a JPEG image for
|
||||
* this particular transform (this can be used in conjunction with a custom
|
||||
* filter to capture the transformed DCT coefficients without transcoding
|
||||
* them.)
|
||||
*/
|
||||
#define TJXOPT_NOOUTPUT 16
|
||||
#define TJXOPT_NOOUTPUT (1 << 4)
|
||||
/**
|
||||
* This option will enable progressive entropy coding in the output image
|
||||
* generated by this particular transform. Progressive entropy coding will
|
||||
@@ -557,13 +573,13 @@ enum TJXOP {
|
||||
* default), but it will reduce compression and decompression performance
|
||||
* considerably. Can be combined with #TJXOPT_ARITHMETIC.
|
||||
*/
|
||||
#define TJXOPT_PROGRESSIVE 32
|
||||
#define TJXOPT_PROGRESSIVE (1 << 5)
|
||||
/**
|
||||
* This option will prevent #tjTransform() from copying any extra markers
|
||||
* (including EXIF and ICC profile data) from the source image to the output
|
||||
* image.
|
||||
*/
|
||||
#define TJXOPT_COPYNONE 64
|
||||
#define TJXOPT_COPYNONE (1 << 6)
|
||||
/**
|
||||
* This option will enable arithmetic entropy coding in the output image
|
||||
* generated by this particular transform. Arithmetic entropy coding will
|
||||
@@ -571,7 +587,7 @@ enum TJXOP {
|
||||
* default), but it will reduce compression and decompression performance
|
||||
* considerably. Can be combined with #TJXOPT_PROGRESSIVE.
|
||||
*/
|
||||
#define TJXOPT_ARITHMETIC 128
|
||||
#define TJXOPT_ARITHMETIC (1 << 7)
|
||||
|
||||
|
||||
/**
|
||||
@@ -760,7 +776,13 @@ DLLEXPORT tjhandle tjInitCompress(void);
|
||||
* "Chrominance subsampling options".)
|
||||
*
|
||||
* @param jpegQual the image quality of the generated JPEG image (1 = worst,
|
||||
* 100 = best)
|
||||
* 100 = best.) When generating a lossless JPEG image (see #TJFLAG_LOSSLESS),
|
||||
* <tt>jpegQual</tt> is <tt>psv * 10 + Pt</tt>, where <tt>psv</tt> is the
|
||||
* predictor selection value (1-7) and <tt>Pt</tt> is the point transform
|
||||
* (0-7). A point transform value of 0 is necessary in order to create a fully
|
||||
* lossless JPEG image. (A non-zero point transform value right-shifts the
|
||||
* input samples by the specified number of bits, which is effectively a form
|
||||
* of lossy color quantization.)
|
||||
*
|
||||
* @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT
|
||||
* "flags"
|
||||
|
||||
Reference in New Issue
Block a user