dimension using the given scaling factor. More...Technically, the JPEG format uses the YCbCr colorspace (which is technically not a colorspace but a color transform), but per the convention of the digital video community, the TurboJPEG API uses "YUV" to refer to an image format consisting of Y, Cb, and Cr image planes.
-Each plane is simply a 2D array of bytes, each byte representing the value of one of the components (Y, Cb, or Cr) at a particular location in the image. The width and height of each plane are determined by the image width, height, and level of chrominance subsampling. The luminance plane width is the image width padded to the nearest multiple of the horizontal subsampling factor (2 in the case of 4:2:0 and 4:2:2, 4 in the case of 4:1:1, 1 in the case of 4:4:4 or grayscale.) Similarly, the luminance plane height is the image height padded to the nearest multiple of the vertical subsampling factor (2 in the case of 4:2:0 or 4:4:0, 1 in the case of 4:4:4 or grayscale.) This is irrespective of any additional padding that may be specified as an argument to the various YUV functions. The chrominance plane width is equal to the luminance plane width divided by the horizontal subsampling factor, and the chrominance plane height is equal to the luminance plane height divided by the vertical subsampling factor.
-For example, if the source image is 35 x 35 pixels and 4:2:2 subsampling is used, then the luminance plane would be 36 x 35 bytes, and each of the chrominance planes would be 18 x 35 bytes. If you specify a line padding of 4 bytes on top of this, then the luminance plane would be 36 x 35 bytes, and each of the chrominance planes would be 20 x 35 bytes.
+Each plane is simply a 2D array of bytes, each byte representing the value of one of the components (Y, Cb, or Cr) at a particular location in the image. The width and height of each plane are determined by the image width, height, and level of chrominance subsampling. The luminance plane width is the image width padded to the nearest multiple of the horizontal subsampling factor (1 in the case of 4:4:4, grayscale, or 4:4:0; 2 in the case of 4:2:2 or 4:2:0; 4 in the case of 4:1:1.) Similarly, the luminance plane height is the image height padded to the nearest multiple of the vertical subsampling factor (1 in the case of 4:4:4, 4:2:2, grayscale, or 4:1:1; 2 in the case of 4:2:0 or 4:4:0.) This is irrespective of any additional padding that may be specified as an argument to the various YUV functions. The chrominance plane width is equal to the luminance plane width divided by the horizontal subsampling factor, and the chrominance plane height is equal to the luminance plane height divided by the vertical subsampling factor.
+For example, if the source image is 35 x 35 pixels and 4:2:2 subsampling is used, then the luminance plane would be 36 x 35 bytes, and each of the chrominance planes would be 18 x 35 bytes. If you specify a row alignment of 4 bytes on top of this, then the luminance plane would be 36 x 35 bytes, and each of the chrominance planes would be 20 x 35 bytes.
Use the most accurate DCT/IDCT algorithm available in the underlying codec.
-The default if this flag is not specified is implementation-specific. For example, the implementation of TurboJPEG for libjpeg[-turbo] uses the fast algorithm by default when compressing, because this has been shown to have 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.
+Use the most accurate DCT/IDCT algorithm available.
+The default if this flag is not specified is implementation-specific. For example, the implementation of the TurboJPEG API in libjpeg-turbo uses the fast algorithm by default when compressing, because this has been shown to have 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.
The uncompressed source/destination image is stored in bottom-up (Windows, OpenGL) order, not top-down (X11) order.
+Rows in the packed-pixel source/destination image are stored in bottom-up (Windows, OpenGL) order rather than in top-down (X11) order.
Use the fastest DCT/IDCT algorithm available in the underlying codec.
-The default if this flag is not specified is implementation-specific. For example, the implementation of TurboJPEG for libjpeg[-turbo] uses the fast algorithm by default when compressing, because this has been shown to have 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.
+Use the fastest DCT/IDCT algorithm available.
+The default if this flag is not specified is implementation-specific. For example, the implementation of the TurboJPEG API in libjpeg-turbo uses the fast algorithm by default when compressing, because this has been shown to have 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.
When decompressing an image that was compressed using chrominance subsampling, use the fastest chrominance upsampling algorithm available in the underlying codec.
+When decompressing an image that was compressed using chrominance subsampling, use the fastest chrominance upsampling algorithm available.
The default is to use smooth upsampling, which creates a smooth transition between neighboring chrominance components in order to reduce upsampling artifacts in the decompressed image.
Disable buffer (re)allocation.
-If passed to one of the JPEG compression or transform functions, this flag will cause those functions to generate an error if the JPEG image buffer is invalid or too small rather than attempting to allocate or reallocate that buffer. This reproduces the behavior of earlier versions of TurboJPEG.
+Disable JPEG buffer (re)allocation.
+If passed to one of the JPEG compression or transform functions, this flag will cause those functions to generate an error if the JPEG destination buffer is invalid or too small, rather than attempt to allocate or reallocate that buffer.
Immediately discontinue the current compression/decompression/transform operation if the underlying codec throws a warning (non-fatal error).
+Immediately discontinue the current compression/decompression/transform operation if a warning (non-fatal error) occurs.
The default behavior is to allow the operation to complete unless a fatal error is encountered.
Pad the given width to the nearest 32-bit boundary.
+Pad the given width to the nearest multiple of 4.
This option will prevent tjTransform() from copying any extra markers (including EXIF and ICC profile data) from the source image to the output image.
+This option will prevent tjTransform() from copying any extra markers (including EXIF and ICC profile data) from the source image to the destination image.
This option will discard the color data in the input image and produce a grayscale output image.
+This option will discard the color data in the source image and produce a grayscale destination image.
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.)
+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.)
This option will enable progressive entropy coding in the output image generated by this particular transform.
-Progressive entropy coding will generally improve compression relative to baseline entropy coding (the default), but it will reduce compression and decompression performance considerably.
+This option will enable progressive entropy coding in the JPEG image 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.
JPEG colorspaces.
Error codes.
| Enumerator | |
|---|---|
| TJERR_WARNING | The error was non-fatal and recoverable, but the image may still be corrupt. + |
| Enumerator | |
| TJERR_WARNING | The error was non-fatal and recoverable, but the destination image may still be corrupt. |
| TJERR_FATAL | The error was fatal and non-recoverable. |
| TJPF_CMYK | CMYK pixel format. -Unlike RGB, which is an additive color model used primarily for display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive color model used primarily for printing. In the CMYK color model, the value of each color component typically corresponds to an amount of cyan, magenta, yellow, or black ink that is applied to a white background. In order to convert between CMYK and RGB, it is necessary to use a color management system (CMS.) A CMS will attempt to map colors within the printer's gamut to perceptually similar colors in the display's gamut and vice versa, but the mapping is typically not 1:1 or reversible, nor can it be defined with a simple formula. Thus, such a conversion is out of scope for a codec library. However, the TurboJPEG API allows for compressing CMYK pixels into a YCCK JPEG image (see TJCS_YCCK) and decompressing YCCK JPEG images into CMYK pixels. +Unlike RGB, which is an additive color model used primarily for display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive color model used primarily for printing. In the CMYK color model, the value of each color component typically corresponds to an amount of cyan, magenta, yellow, or black ink that is applied to a white background. In order to convert between CMYK and RGB, it is necessary to use a color management system (CMS.) A CMS will attempt to map colors within the printer's gamut to perceptually similar colors in the display's gamut and vice versa, but the mapping is typically not 1:1 or reversible, nor can it be defined with a simple formula. Thus, such a conversion is out of scope for a codec library. However, the TurboJPEG API allows for compressing packed-pixel CMYK images into YCCK JPEG images (see TJCS_YCCK) and decompressing YCCK JPEG images into packed-pixel CMYK images. |
| TJPF_UNKNOWN | Unknown pixel format. -Currently this is only used by tjLoadImage(). +Currently this is only used by tjLoadImage(). |
Chrominance subsampling options.
-When pixels are converted from RGB to YCbCr (see TJCS_YCbCr) or from CMYK to YCCK (see TJCS_YCCK) as part of the JPEG compression process, some of the Cb and Cr (chrominance) components can be discarded or averaged together to produce a smaller image with little perceptible loss of image clarity (the human eye is more sensitive to small changes in brightness than to small changes in color.) This is called "chrominance subsampling".
+When pixels are converted from RGB to YCbCr (see TJCS_YCbCr) or from CMYK to YCCK (see TJCS_YCCK) as part of the JPEG compression process, some of the Cb and Cr (chrominance) components can be discarded or averaged together to produce a smaller image with little perceptible loss of image clarity. (The human eye is more sensitive to small changes in brightness than to small changes in color.) This is called "chrominance subsampling".
Allocate an image buffer for use with TurboJPEG.
-You should always use this function to allocate the JPEG destination buffer(s) for the compression and transform functions unless you are disabling automatic buffer (re)allocation (by setting TJFLAG_NOREALLOC.)
+Allocate a byte buffer for use with TurboJPEG.
+You should always use this function to allocate the JPEG destination buffer(s) for the compression and transform functions unless you are disabling automatic buffer (re)allocation (by setting TJFLAG_NOREALLOC.)
| bytes | the number of bytes to allocate |
| width | width (in pixels) of the image |
| pad | the width of each line in each plane of the image is padded to the nearest multiple of this number of bytes (must be a power of 2.) |
| align | row alignment (in bytes) of the image (must be a power of 2.) Setting this parameter to n specifies that each row in each plane of the image will be padded to the nearest multiple of n bytes (1 = unpadded.) |
| height | height (in pixels) of the image |
| subsamp | level of chrominance subsampling in the image (see Chrominance subsampling options.) |
Compress an RGB, grayscale, or CMYK image into a JPEG image.
+Compress a packed-pixel RGB, grayscale, or CMYK image into a JPEG image.
| handle | a handle to a TurboJPEG compressor or transformer instance | ||||
| srcBuf | pointer to an image buffer containing RGB, grayscale, or CMYK pixels to be compressed | ||||
| srcBuf | pointer to a buffer containing a packed-pixel RGB, grayscale, or CMYK source image to be compressed | ||||
| width | width (in pixels) of the source image | ||||
| pitch | bytes per line in the source image. Normally, this should be width * tjPixelSize[pixelFormat] if the image is unpadded, or TJPAD(width * tjPixelSize[pixelFormat]) if each line of the image is padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use this parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat]. | ||||
| pitch | bytes per row in the source image. Normally this should be width * tjPixelSize[pixelFormat], if the image is unpadded, or TJPAD(width * tjPixelSize[pixelFormat]) if each row of the image is padded to the nearest multiple of 4 bytes, as is the case for Windows bitmaps. You can also be clever and use this parameter to skip rows, etc. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat]. | ||||
| height | height (in pixels) of the source image | ||||
| pixelFormat | pixel format of the source image (see Pixel formats.) | ||||
| jpegBuf | address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:
jpegBuf | address of a pointer to a byte buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to: |
*jpegSize should be set to the size of your pre-allocated buffer. In any case, unless you have set TJFLAG_NOREALLOC, you should always check *jpegBuf upon return from this function, as it may have changed.jpegSize | pointer to an unsigned long variable that holds the size of the JPEG image buffer. If | *jpegBuf points to a pre-allocated buffer, then *jpegSize should be set to the size of the buffer. Upon return, *jpegSize will contain the size of the JPEG image (in bytes.) If *jpegBuf points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then *jpegSize is ignored.*jpegSize should be set to the size of your pre-allocated buffer. In any case, unless you have set TJFLAG_NOREALLOC, you should always check *jpegBuf upon return from this function, as it may have changed. |
| jpegSize | pointer to an unsigned long variable that holds the size of the JPEG buffer. If *jpegBuf points to a pre-allocated buffer, then *jpegSize should be set to the size of the buffer. Upon return, *jpegSize will contain the size of the JPEG image (in bytes.) If *jpegBuf points to a JPEG buffer that is being reused from a previous call to one of the JPEG compression functions, then *jpegSize is ignored. | ||||
| jpegSubsamp | the level of chrominance subsampling to be used when generating the JPEG image (see Chrominance subsampling options.) | ||||
| jpegQual | the image quality of the generated JPEG image (1 = worst, 100 = best) | ||||
| flags | the bitwise OR of one or more of the flags | int | -pad, | +align, | |
| @@ -1268,22 +1269,22 @@ If you choose option 1, |
Compress a YUV planar image into a JPEG image.
+Compress a unified planar YUV image into a JPEG image.
| handle | a handle to a TurboJPEG compressor or transformer instance | ||||
| srcBuf | pointer to an image buffer containing a YUV planar image to be compressed. The size of this buffer should match the value returned by tjBufSizeYUV2() for the given image width, height, padding, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be stored sequentially in the source buffer (refer to YUV Image Format Notes.) | ||||
| width | width (in pixels) of the source image. If the width is not an even multiple of the MCU block width (see tjMCUWidth), then an intermediate buffer copy will be performed within TurboJPEG. | ||||
| pad | the line padding used in the source image. For instance, if each line in each plane of the YUV image is padded to the nearest multiple of 4 bytes, then pad should be set to 4. | ||||
| height | height (in pixels) of the source image. If the height is not an even multiple of the MCU block height (see tjMCUHeight), then an intermediate buffer copy will be performed within TurboJPEG. | ||||
| srcBuf | pointer to a buffer containing a unified planar YUV source image to be compressed. The size of this buffer should match the value returned by tjBufSizeYUV2() for the given image width, height, row alignment, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be stored sequentially in the buffer. (Refer to YUV Image Format Notes.) | ||||
| width | width (in pixels) of the source image. If the width is not an even multiple of the MCU block width (see tjMCUWidth), then an intermediate buffer copy will be performed. | ||||
| align | row alignment (in bytes) of the source image (must be a power of 2.) Setting this parameter to n indicates that each row in each plane of the source image is padded to the nearest multiple of n bytes (1 = unpadded.) | ||||
| height | height (in pixels) of the source image. If the height is not an even multiple of the MCU block height (see tjMCUHeight), then an intermediate buffer copy will be performed. | ||||
| subsamp | the level of chrominance subsampling used in the source image (see Chrominance subsampling options.) | ||||
| jpegBuf | address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:
jpegBuf | address of a pointer to a byte buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to: |
*jpegSize should be set to the size of your pre-allocated buffer. In any case, unless you have set TJFLAG_NOREALLOC, you should always check *jpegBuf upon return from this function, as it may have changed.jpegSize | pointer to an unsigned long variable that holds the size of the JPEG image buffer. If | *jpegBuf points to a pre-allocated buffer, then *jpegSize should be set to the size of the buffer. Upon return, *jpegSize will contain the size of the JPEG image (in bytes.) If *jpegBuf points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then *jpegSize is ignored.*jpegSize should be set to the size of your pre-allocated buffer. In any case, unless you have set TJFLAG_NOREALLOC, you should always check *jpegBuf upon return from this function, as it may have changed. |
| jpegSize | pointer to an unsigned long variable that holds the size of the JPEG buffer. If *jpegBuf points to a pre-allocated buffer, then *jpegSize should be set to the size of the buffer. Upon return, *jpegSize will contain the size of the JPEG image (in bytes.) If *jpegBuf points to a JPEG buffer that is being reused from a previous call to one of the JPEG compression functions, then *jpegSize is ignored. | ||||
| jpegQual | the image quality of the generated JPEG image (1 = worst, 100 = best) | ||||
| flags | the bitwise OR of one or more of the flags |
*jpegSize should be set to the size of your
| handle | a handle to a TurboJPEG compressor or transformer instance | ||||
| srcPlanes | an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if compressing a grayscale image) that contain a YUV image to be compressed. These planes can be contiguous or non-contiguous in memory. The size of each plane should match the value returned by tjPlaneSizeYUV() for the given image width, height, strides, and level of chrominance subsampling. Refer to YUV Image Format Notes for more details. | ||||
| width | width (in pixels) of the source image. If the width is not an even multiple of the MCU block width (see tjMCUWidth), then an intermediate buffer copy will be performed within TurboJPEG. | ||||
| strides | an array of integers, each specifying the number of bytes per line in the corresponding plane of the YUV source image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see YUV Image Format Notes.) If strides is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to specify an arbitrary amount of line padding in each plane or to create a JPEG image from a subregion of a larger YUV planar image. | ||||
| height | height (in pixels) of the source image. If the height is not an even multiple of the MCU block height (see tjMCUHeight), then an intermediate buffer copy will be performed within TurboJPEG. | ||||
| srcPlanes | an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if compressing a grayscale image) that contain a YUV source image to be compressed. These planes can be contiguous or non-contiguous in memory. The size of each plane should match the value returned by tjPlaneSizeYUV() for the given image width, height, strides, and level of chrominance subsampling. Refer to YUV Image Format Notes for more details. | ||||
| width | width (in pixels) of the source image. If the width is not an even multiple of the MCU block width (see tjMCUWidth), then an intermediate buffer copy will be performed. | ||||
| strides | an array of integers, each specifying the number of bytes per row in the corresponding plane of the YUV source image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see YUV Image Format Notes.) If strides is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to specify an arbitrary amount of row padding in each plane or to create a JPEG image from a subregion of a larger planar YUV image. | ||||
| height | height (in pixels) of the source image. If the height is not an even multiple of the MCU block height (see tjMCUHeight), then an intermediate buffer copy will be performed. | ||||
| subsamp | the level of chrominance subsampling used in the source image (see Chrominance subsampling options.) | ||||
| jpegBuf | address of a pointer to an image buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:
jpegBuf | address of a pointer to a byte buffer that will receive the JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to: |
*jpegSize should be set to the size of your pre-allocated buffer. In any case, unless you have set TJFLAG_NOREALLOC, you should always check *jpegBuf upon return from this function, as it may have changed.jpegSize | pointer to an unsigned long variable that holds the size of the JPEG image buffer. If | *jpegBuf points to a pre-allocated buffer, then *jpegSize should be set to the size of the buffer. Upon return, *jpegSize will contain the size of the JPEG image (in bytes.) If *jpegBuf points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then *jpegSize is ignored.*jpegSize should be set to the size of your pre-allocated buffer. In any case, unless you have set TJFLAG_NOREALLOC, you should always check *jpegBuf upon return from this function, as it may have changed. |
| jpegSize | pointer to an unsigned long variable that holds the size of the JPEG buffer. If *jpegBuf points to a pre-allocated buffer, then *jpegSize should be set to the size of the buffer. Upon return, *jpegSize will contain the size of the JPEG image (in bytes.) If *jpegBuf points to a JPEG buffer that is being reused from a previous call to one of the JPEG compression functions, then *jpegSize is ignored. | ||||
| jpegQual | the image quality of the generated JPEG image (1 = worst, 100 = best) | ||||
| flags | the bitwise OR of one or more of the flags |
*jpegSize should be set to the size of your
*jpegSize should be set to the size of your
*jpegSize should be set to the size of your
Decode a YUV planar image into an RGB or grayscale image.
-This function uses the accelerated color conversion routines in the underlying codec but does not execute any of the other steps in the JPEG decompression process.
+Decode a unified planar YUV image into a packed-pixel RGB or grayscale image.
+This function performs color conversion (which is accelerated in the libjpeg-turbo implementation) but does not execute any of the other steps in the JPEG decompression process.
| handle | a handle to a TurboJPEG decompressor or transformer instance |
| srcBuf | pointer to an image buffer containing a YUV planar image to be decoded. The size of this buffer should match the value returned by tjBufSizeYUV2() for the given image width, height, padding, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be stored sequentially in the source buffer (refer to YUV Image Format Notes.) |
| pad | Use this parameter to specify that the width of each line in each plane of the YUV source image is padded to the nearest multiple of this number of bytes (must be a power of 2.) |
| srcBuf | pointer to a buffer containing a unified planar YUV source image to be decoded. The size of this buffer should match the value returned by tjBufSizeYUV2() for the given image width, height, row alignment, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes should be stored sequentially in the source buffer. (Refer to YUV Image Format Notes.) |
| align | row alignment (in bytes) of the YUV source image (must be a power of 2.) Setting this parameter to n indicates that each row in each plane of the YUV source image is padded to the nearest multiple of n bytes (1 = unpadded.) |
| subsamp | the level of chrominance subsampling used in the YUV source image (see Chrominance subsampling options.) |
| dstBuf | pointer to an image buffer that will receive the decoded image. This buffer should normally be pitch * height bytes in size, but the dstBuf pointer can also be used to decode into a specific region of a larger buffer. |
| dstBuf | pointer to a buffer that will receive the packed-pixel decoded image. This buffer should normally be pitch * height bytes in size, but the dstBuf pointer can also be used to decode into a specific region of a larger buffer. |
| width | width (in pixels) of the source and destination images |
| pitch | bytes per line in the destination image. Normally, this should be width * tjPixelSize[pixelFormat] if the destination image is unpadded, or TJPAD(width * tjPixelSize[pixelFormat]) if each line of the destination image should be padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat]. |
| pitch | bytes per row in the destination image. Normally this should be set to width * tjPixelSize[pixelFormat], if the destination image should be unpadded, or TJPAD(width * tjPixelSize[pixelFormat]) if each row of the destination image should be padded to the nearest multiple of 4 bytes, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip rows, etc. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat]. |
| height | height (in pixels) of the source and destination images |
| pixelFormat | pixel format of the destination image (see Pixel formats.) |
| flags | the bitwise OR of one or more of the flags |
Decode a set of Y, U (Cb), and V (Cr) image planes into an RGB or grayscale image.
-This function uses the accelerated color conversion routines in the underlying codec but does not execute any of the other steps in the JPEG decompression process.
+Decode a set of Y, U (Cb), and V (Cr) image planes into a packed-pixel RGB or grayscale image.
+This function performs color conversion (which is accelerated in the libjpeg-turbo implementation) but does not execute any of the other steps in the JPEG decompression process.
| handle | a handle to a TurboJPEG decompressor or transformer instance |
| srcPlanes | an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if decoding a grayscale image) that contain a YUV image to be decoded. These planes can be contiguous or non-contiguous in memory. The size of each plane should match the value returned by tjPlaneSizeYUV() for the given image width, height, strides, and level of chrominance subsampling. Refer to YUV Image Format Notes for more details. |
| strides | an array of integers, each specifying the number of bytes per line in the corresponding plane of the YUV source image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see YUV Image Format Notes.) If strides is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to specify an arbitrary amount of line padding in each plane or to decode a subregion of a larger YUV planar image. |
| strides | an array of integers, each specifying the number of bytes per row in the corresponding plane of the YUV source image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see YUV Image Format Notes.) If strides is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to specify an arbitrary amount of row padding in each plane or to decode a subregion of a larger planar YUV image. |
| subsamp | the level of chrominance subsampling used in the YUV source image (see Chrominance subsampling options.) |
| dstBuf | pointer to an image buffer that will receive the decoded image. This buffer should normally be pitch * height bytes in size, but the dstBuf pointer can also be used to decode into a specific region of a larger buffer. |
| dstBuf | pointer to a buffer that will receive the packed-pixel decoded image. This buffer should normally be pitch * height bytes in size, but the dstBuf pointer can also be used to decode into a specific region of a larger buffer. |
| width | width (in pixels) of the source and destination images |
| pitch | bytes per line in the destination image. Normally, this should be width * tjPixelSize[pixelFormat] if the destination image is unpadded, or TJPAD(width * tjPixelSize[pixelFormat]) if each line of the destination image should be padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat]. |
| pitch | bytes per row in the destination image. Normally this should be set to width * tjPixelSize[pixelFormat], if the destination image should be unpadded, or TJPAD(width * tjPixelSize[pixelFormat]) if each row of the destination image should be padded to the nearest multiple of 4 bytes, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip rows, etc. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat]. |
| height | height (in pixels) of the source and destination images |
| pixelFormat | pixel format of the destination image (see Pixel formats.) |
| flags | the bitwise OR of one or more of the flags |
Decompress a JPEG image to an RGB, grayscale, or CMYK image.
+Decompress a JPEG image into a packed-pixel RGB, grayscale, or CMYK image.
| handle | a handle to a TurboJPEG decompressor or transformer instance |
| jpegBuf | pointer to a buffer containing the JPEG image to decompress |
| jpegBuf | pointer to a byte buffer containing the JPEG image to decompress |
| jpegSize | size of the JPEG image (in bytes) |
| dstBuf | pointer to an image buffer that will receive the decompressed image. This buffer should normally be pitch * scaledHeight bytes in size, where scaledHeight can be determined by calling TJSCALED() with the JPEG image height and one of the scaling factors returned by tjGetScalingFactors(). The dstBuf pointer may also be used to decompress into a specific region of a larger buffer. |
| dstBuf | pointer to a buffer that will receive the packed-pixel decompressed image. This buffer should normally be pitch * scaledHeight bytes in size, where scaledHeight can be determined by calling TJSCALED() with the JPEG image height and one of the scaling factors returned by tjGetScalingFactors(). The dstBuf pointer may also be used to decompress into a specific region of a larger buffer. |
| width | desired width (in pixels) of the destination image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If width is set to 0, then only the height will be considered when determining the scaled image size. |
| pitch | bytes per line in the destination image. Normally, this is scaledWidth * tjPixelSize[pixelFormat] if the decompressed image is unpadded, else TJPAD(scaledWidth * tjPixelSize[pixelFormat]) if each line of the decompressed image is padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. (NOTE: scaledWidth can be determined by calling TJSCALED() with the JPEG image width and one of the scaling factors returned by tjGetScalingFactors().) You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to scaledWidth * tjPixelSize[pixelFormat]. |
| pitch | bytes per row in the destination image. Normally this should be set to scaledWidth * tjPixelSize[pixelFormat], if the destination image should be unpadded, or TJPAD(scaledWidth * tjPixelSize[pixelFormat]) if each row of the destination image should be padded to the nearest multiple of 4 bytes, as is the case for Windows bitmaps. (NOTE: scaledWidth can be determined by calling TJSCALED() with the JPEG image width and one of the scaling factors returned by tjGetScalingFactors().) You can also be clever and use the pitch parameter to skip rows, etc. Setting this parameter to 0 is the equivalent of setting it to scaledWidth * tjPixelSize[pixelFormat]. |
| height | desired height (in pixels) of the destination image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If height is set to 0, then only the width will be considered when determining the scaled image size. |
| pixelFormat | pixel format of the destination image (see Pixel formats.) |
| flags | the bitwise OR of one or more of the flags |
| handle | a handle to a TurboJPEG decompressor or transformer instance |
| jpegBuf | pointer to a buffer containing a JPEG image or an "abbreviated table specification" (AKA "tables-only") datastream. Passing a tables-only datastream to this function primes the decompressor with quantization and Huffman tables that can be used when decompressing subsequent "abbreviated image" datastreams. This is useful, for instance, when decompressing video streams in which all frames share the same quantization and Huffman tables. |
| jpegBuf | pointer to a byte buffer containing a JPEG image or an "abbreviated table specification" (AKA "tables-only") datastream. Passing a tables-only datastream to this function primes the decompressor with quantization and Huffman tables that can be used when decompressing subsequent "abbreviated image" datastreams. This is useful, for instance, when decompressing video streams in which all frames share the same quantization and Huffman tables. |
| jpegSize | size of the JPEG image or tables-only datastream (in bytes) |
| width | pointer to an integer variable that will receive the width (in pixels) of the JPEG image. If jpegBuf points to a tables-only datastream, then width is ignored. |
| height | pointer to an integer variable that will receive the height (in pixels) of the JPEG image. If jpegBuf points to a tables-only datastream, then height is ignored. | int | -pad, | +align, |
| @@ -1804,17 +1805,17 @@ If you choose option 1, |
Decompress a JPEG image to a YUV planar image.
-This function performs JPEG decompression but leaves out the color conversion step, so a planar YUV image is generated instead of an RGB image.
+Decompress a JPEG image into a unified planar YUV image.
+This function performs JPEG decompression but leaves out the color conversion step, so a planar YUV image is generated instead of a packed-pixel image.
| handle | a handle to a TurboJPEG decompressor or transformer instance |
| jpegBuf | pointer to a buffer containing the JPEG image to decompress |
| jpegBuf | pointer to a byte buffer containing the JPEG image to decompress |
| jpegSize | size of the JPEG image (in bytes) |
| dstBuf | pointer to an image buffer that will receive the YUV image. Use tjBufSizeYUV2() to determine the appropriate size for this buffer based on the image width, height, padding, and level of subsampling. The Y, U (Cb), and V (Cr) image planes will be stored sequentially in the buffer (refer to YUV Image Format Notes.) |
| width | desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If width is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see tjMCUWidth), then an intermediate buffer copy will be performed within TurboJPEG. |
| pad | the width of each line in each plane of the YUV image will be padded to the nearest multiple of this number of bytes (must be a power of 2.) To generate images suitable for X Video, pad should be set to 4. |
| height | desired height (in pixels) of the YUV image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If height is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see tjMCUHeight), then an intermediate buffer copy will be performed within TurboJPEG. |
| dstBuf | pointer to a buffer that will receive the unified planar YUV decompressed image. Use tjBufSizeYUV2() to determine the appropriate size for this buffer based on the scaled image width, scaled image height, row alignment, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes will be stored sequentially in the buffer. (Refer to YUV Image Format Notes.) |
| width | desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If width is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see tjMCUWidth), then an intermediate buffer copy will be performed. |
| align | row alignment (in bytes) of the YUV image (must be a power of 2.) Setting this parameter to n will cause each row in each plane of the YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.) To generate images suitable for X Video, align should be set to 4. |
| height | desired height (in pixels) of the YUV image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If height is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see tjMCUHeight), then an intermediate buffer copy will be performed. |
| flags | the bitwise OR of one or more of the flags |
*jpegSize should be set to the size of your
Decompress a JPEG image into separate Y, U (Cb), and V (Cr) image planes.
-This function performs JPEG decompression but leaves out the color conversion step, so a planar YUV image is generated instead of an RGB image.
+This function performs JPEG decompression but leaves out the color conversion step, so a planar YUV image is generated instead of a packed-pixel image.
| handle | a handle to a TurboJPEG decompressor or transformer instance |
| jpegBuf | pointer to a buffer containing the JPEG image to decompress |
| jpegBuf | pointer to a byte buffer containing the JPEG image to decompress |
| jpegSize | size of the JPEG image (in bytes) |
| dstPlanes | an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if decompressing a grayscale image) that will receive the YUV image. These planes can be contiguous or non-contiguous in memory. Use tjPlaneSizeYUV() to determine the appropriate size for each plane based on the scaled image width, scaled image height, strides, and level of chrominance subsampling. Refer to YUV Image Format Notes for more details. |
| width | desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If width is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see tjMCUWidth), then an intermediate buffer copy will be performed within TurboJPEG. |
| strides | an array of integers, each specifying the number of bytes per line in the corresponding plane of the output image. Setting the stride for any plane to 0 is the same as setting it to the scaled plane width (see YUV Image Format Notes.) If strides is NULL, then the strides for all planes will be set to their respective scaled plane widths. You can adjust the strides in order to add an arbitrary amount of line padding to each plane or to decompress the JPEG image into a subregion of a larger YUV planar image. |
| height | desired height (in pixels) of the YUV image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If height is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see tjMCUHeight), then an intermediate buffer copy will be performed within TurboJPEG. |
| dstPlanes | an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if decompressing a grayscale image) that will receive the decompressed image. These planes can be contiguous or non-contiguous in memory. Use tjPlaneSizeYUV() to determine the appropriate size for each plane based on the scaled image width, scaled image height, strides, and level of chrominance subsampling. Refer to YUV Image Format Notes for more details. |
| width | desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If width is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see tjMCUWidth), then an intermediate buffer copy will be performed. |
| strides | an array of integers, each specifying the number of bytes per row in the corresponding plane of the YUV image. Setting the stride for any plane to 0 is the same as setting it to the scaled plane width (see YUV Image Format Notes.) If strides is NULL, then the strides for all planes will be set to their respective scaled plane widths. You can adjust the strides in order to add an arbitrary amount of row padding to each plane or to decompress the JPEG image into a subregion of a larger planar YUV image. |
| height | desired height (in pixels) of the YUV image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If height is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see tjMCUHeight), then an intermediate buffer copy will be performed. |
| flags | the bitwise OR of one or more of the flags |
*jpegSize should be set to the size of your
*jpegSize should be set to the size of your
*jpegSize should be set to the size of your
Encode an RGB or grayscale image into a YUV planar image.
-This function uses the accelerated color conversion routines in the underlying codec but does not execute any of the other steps in the JPEG compression process.
+Encode a packed-pixel RGB or grayscale image into a unified planar YUV image.
+This function performs color conversion (which is accelerated in the libjpeg-turbo implementation) but does not execute any of the other steps in the JPEG compression process.
| handle | a handle to a TurboJPEG compressor or transformer instance |
| srcBuf | pointer to an image buffer containing RGB or grayscale pixels to be encoded |
| srcBuf | pointer to a buffer containing a packed-pixel RGB or grayscale source image to be encoded |
| width | width (in pixels) of the source image |
| pitch | bytes per line in the source image. Normally, this should be width * tjPixelSize[pixelFormat] if the image is unpadded, or TJPAD(width * tjPixelSize[pixelFormat]) if each line of the image is padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use this parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat]. |
| pitch | bytes per row in the source image. Normally this should be width * tjPixelSize[pixelFormat], if the image is unpadded, or TJPAD(width * tjPixelSize[pixelFormat]) if each row of the image is padded to the nearest multiple of 4 bytes, as is the case for Windows bitmaps. You can also be clever and use this parameter to skip rows, etc. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat]. |
| height | height (in pixels) of the source image |
| pixelFormat | pixel format of the source image (see Pixel formats.) |
| dstBuf | pointer to an image buffer that will receive the YUV image. Use tjBufSizeYUV2() to determine the appropriate size for this buffer based on the image width, height, padding, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes will be stored sequentially in the buffer (refer to YUV Image Format Notes.) |
| pad | the width of each line in each plane of the YUV image will be padded to the nearest multiple of this number of bytes (must be a power of 2.) To generate images suitable for X Video, pad should be set to 4. |
| dstBuf | pointer to a buffer that will receive the unified planar YUV image. Use tjBufSizeYUV2() to determine the appropriate size for this buffer based on the image width, height, row alignment, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes will be stored sequentially in the buffer. (Refer to YUV Image Format Notes.) |
| align | row alignment (in bytes) of the YUV image (must be a power of 2.) Setting this parameter to n will cause each row in each plane of the YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.) To generate images suitable for X Video, align should be set to 4. |
| subsamp | the level of chrominance subsampling to be used when generating the YUV image (see Chrominance subsampling options.) To generate images suitable for X Video, subsamp should be set to TJSAMP_420. This produces an image compatible with the I420 (AKA "YUV420P") format. |
| flags | the bitwise OR of one or more of the flags |
*jpegSize should be set to the size of your
Encode an RGB or grayscale image into separate Y, U (Cb), and V (Cr) image planes.
-This function uses the accelerated color conversion routines in the underlying codec but does not execute any of the other steps in the JPEG compression process.
+Encode a packed-pixel RGB or grayscale image into separate Y, U (Cb), and V (Cr) image planes.
+This function performs color conversion (which is accelerated in the libjpeg-turbo implementation) but does not execute any of the other steps in the JPEG compression process.
| handle | a handle to a TurboJPEG compressor or transformer instance |
| srcBuf | pointer to an image buffer containing RGB or grayscale pixels to be encoded |
| srcBuf | pointer to a buffer containing a packed-pixel RGB or grayscale source image to be encoded |
| width | width (in pixels) of the source image |
| pitch | bytes per line in the source image. Normally, this should be width * tjPixelSize[pixelFormat] if the image is unpadded, or TJPAD(width * tjPixelSize[pixelFormat]) if each line of the image is padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use this parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat]. |
| pitch | bytes per row in the source image. Normally this should be width * tjPixelSize[pixelFormat], if the image is unpadded, or TJPAD(width * tjPixelSize[pixelFormat]) if each row of the image is padded to the nearest multiple of 4 bytes, as is the case for Windows bitmaps. You can also be clever and use this parameter to skip rows, etc. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat]. |
| height | height (in pixels) of the source image |
| pixelFormat | pixel format of the source image (see Pixel formats.) |
| dstPlanes | an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if generating a grayscale image) that will receive the encoded image. These planes can be contiguous or non-contiguous in memory. Use tjPlaneSizeYUV() to determine the appropriate size for each plane based on the image width, height, strides, and level of chrominance subsampling. Refer to YUV Image Format Notes for more details. |
| strides | an array of integers, each specifying the number of bytes per line in the corresponding plane of the output image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see YUV Image Format Notes.) If strides is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to add an arbitrary amount of line padding to each plane or to encode an RGB or grayscale image into a subregion of a larger YUV planar image. |
| strides | an array of integers, each specifying the number of bytes per row in the corresponding plane of the YUV image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see YUV Image Format Notes.) If strides is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to add an arbitrary amount of row padding to each plane or to encode an RGB or grayscale image into a subregion of a larger planar YUV image. |
| subsamp | the level of chrominance subsampling to be used when generating the YUV image (see Chrominance subsampling options.) To generate images suitable for X Video, subsamp should be set to TJSAMP_420. This produces an image compatible with the I420 (AKA "YUV420P") format. |
| flags | the bitwise OR of one or more of the flags |
*jpegSize should be set to the size of your
Free an image buffer previously allocated by TurboJPEG.
-You should always use this function to free JPEG destination buffer(s) that were automatically (re)allocated by the compression and transform functions or that were manually allocated using tjAlloc().
+Free a byte buffer previously allocated by TurboJPEG.
+You should always use this function to free JPEG destination buffer(s) that were automatically (re)allocated by the compression and transform functions or that were manually allocated using tjAlloc().
| buffer | address of the buffer to free. If the address is NULL, then this function has no effect. |
*jpegSize should be set to the size of your
-
-*jpegSize should be set to the size of your
Returns a list of fractional scaling factors that the JPEG decompressor in this implementation of TurboJPEG supports.
+Returns a list of fractional scaling factors that the JPEG decompressor supports.
| numscalingfactors | pointer to an integer variable that will receive the number of elements in the list |
| numScalingFactors | pointer to an integer variable that will receive the number of elements in the list |
*jpegSize should be set to the size of your
Load an uncompressed image from disk into memory.
+Load a packed-pixel image from disk into memory.
| filename | name of a file containing an uncompressed image in Windows BMP or PBMPLUS (PPM/PGM) format | ||||||||||||
| width | pointer to an integer variable that will receive the width (in pixels) of the uncompressed image | ||||||||||||
| align | row alignment of the image buffer to be returned (must be a power of 2.) For instance, setting this parameter to 4 will cause all rows in the image buffer to be padded to the nearest 32-bit boundary, and setting this parameter to 1 will cause all rows in the image buffer to be unpadded. | ||||||||||||
| height | pointer to an integer variable that will receive the height (in pixels) of the uncompressed image | ||||||||||||
| pixelFormat | pointer to an integer variable that specifies or will receive the pixel format of the uncompressed image buffer. The behavior of tjLoadImage() will vary depending on the value of *pixelFormat passed to the function:
filename | name of a file containing a packed-pixel image in Windows BMP or PBMPLUS (PPM/PGM) format | width | pointer to an integer variable that will receive the width (in pixels) of the packed-pixel image | align | row alignment of the packed-pixel buffer to be returned (must be a power of 2.) Setting this parameter to n will cause all rows in the buffer to be padded to the nearest multiple of n bytes (1 = unpadded.) | height | pointer to an integer variable that will receive the height (in pixels) of the packed-pixel image | pixelFormat | pointer to an integer variable that specifies or will receive the pixel format of the packed-pixel buffer. The behavior of tjLoadImage() will vary depending on the value of | *pixelFormat passed to the function:
flags | the bitwise OR of one or more of the flags. | |
*jpegSize should be set to the size of your
| componentID | ID number of the image plane (0 = Y, 1 = U/Cb, 2 = V/Cr) |
| width | width (in pixels) of the YUV image. NOTE: this is the width of the whole image, not the plane width. |
| stride | bytes per line in the image plane. Setting this to 0 is the equivalent of setting it to the plane width. |
| stride | bytes per row in the image plane. Setting this to 0 is the equivalent of setting it to the plane width. |
| height | height (in pixels) of the YUV image. NOTE: this is the height of the whole image, not the plane height. |
| subsamp | level of chrominance subsampling in the image (see Chrominance subsampling options.) |
*jpegSize should be set to the size of your
Save an uncompressed image from memory to disk.
+Save a packed-pixel image from memory to disk.
| filename | name of a file to which to save the uncompressed image. The image will be stored in Windows BMP or PBMPLUS (PPM/PGM) format, depending on the file extension. |
| buffer | pointer to an image buffer containing RGB, grayscale, or CMYK pixels to be saved |
| width | width (in pixels) of the uncompressed image |
| pitch | bytes per line in the image buffer. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat]. |
| height | height (in pixels) of the uncompressed image |
| pixelFormat | pixel format of the image buffer (see Pixel formats.) If this parameter is set to TJPF_GRAY, then the image will be stored in PGM or 8-bit (indexed color) BMP format. Otherwise, the image will be stored in PPM or 24-bit BMP format. If this parameter is set to TJPF_CMYK, then the CMYK pixels will be converted to RGB using a quick & dirty algorithm that is suitable only for testing (proper conversion between CMYK and other formats requires a color management system.) |
| filename | name of a file to which to save the packed-pixel image. The image will be stored in Windows BMP or PBMPLUS (PPM/PGM) format, depending on the file extension. |
| buffer | pointer to a buffer containing a packed-pixel RGB, grayscale, or CMYK image to be saved |
| width | width (in pixels) of the packed-pixel image |
| pitch | bytes per row in the packed-pixel image. Setting this parameter to 0 is the equivalent of setting it to width * tjPixelSize[pixelFormat]. |
| height | height (in pixels) of the packed-pixel image |
| pixelFormat | pixel format of the packed-pixel image (see Pixel formats.) If this parameter is set to TJPF_GRAY, then the image will be stored in PGM or 8-bit-per-pixel (indexed color) BMP format. Otherwise, the image will be stored in PPM or 24-bit-per-pixel BMP format. If this parameter is set to TJPF_CMYK, then the CMYK pixels will be converted to RGB using a quick & dirty algorithm that is suitable only for testing purposes. (Proper conversion between CMYK and other formats requires a color management system.) |
| flags | the bitwise OR of one or more of the flags. |
*jpegSize should be set to the size of your
| handle | a handle to a TurboJPEG transformer instance | ||||||
| jpegBuf | pointer to a buffer containing the JPEG source image to transform | ||||||
| jpegBuf | pointer to a byte buffer containing the JPEG source image to transform | ||||||
| jpegSize | size of the JPEG source image (in bytes) | ||||||
| n | the number of transformed JPEG images to generate | ||||||
| dstBufs | pointer to an array of n image buffers. dstBufs[i] will receive a JPEG image that has been transformed using the parameters in transforms[i]. TurboJPEG has the ability to reallocate the JPEG buffer to accommodate the size of the JPEG image. Thus, you can choose to:
dstBufs | pointer to an array of n byte buffers. | dstBufs[i] will receive a JPEG image that has been transformed using the parameters in transforms[i]. TurboJPEG has the ability to reallocate the JPEG destination buffer to accommodate the size of the transformed JPEG image. Thus, you can choose to:
dstSizes[i] should be set to the size of your pre-allocated buffer. In any case, unless you have set TJFLAG_NOREALLOC, you should always check dstBufs[i] upon return from this function, as it may have changed.dstSizes | pointer to an array of n unsigned long variables that will receive the actual sizes (in bytes) of each transformed JPEG image. If | dstBufs[i] points to a pre-allocated buffer, then dstSizes[i] should be set to the size of the buffer. Upon return, dstSizes[i] will contain the size of the JPEG image (in bytes.)transforms | pointer to an array of n tjtransform structures, each of which specifies the transform parameters and/or cropping region for the corresponding transformed output image. | dstSizes[i] should be set to the size of your pre-allocated buffer. In any case, unless you have set TJFLAG_NOREALLOC, you should always check dstBufs[i] upon return from this function, as it may have changed. |
| dstSizes | pointer to an array of n unsigned long variables that will receive the actual sizes (in bytes) of each transformed JPEG image. If dstBufs[i] points to a pre-allocated buffer, then dstSizes[i] should be set to the size of the buffer. Upon return, dstSizes[i] will contain the size of the transformed JPEG image (in bytes.) | ||||||
| transforms | pointer to an array of n tjtransform structures, each of which specifies the transform parameters and/or cropping region for the corresponding transformed JPEG image. | ||||||
| flags | the bitwise OR of one or more of the flags |
dstSizes[i] should be set to the size of yo
Alpha offset (in bytes) for a given pixel format.
-This specifies the number of bytes that the Alpha component is offset from the start of the pixel. For instance, if a pixel of format TJ_BGRA is stored in char pixel[], then the alpha component will be pixel[tjAlphaOffset[TJ_BGRA]]. This will be -1 if the pixel format does not have an alpha component.
This specifies the number of bytes that the alpha component is offset from the start of the pixel. For instance, if a pixel of format TJPF_BGRA is stored in unsigned char pixel[], then the alpha component will be pixel[tjAlphaOffset[TJPF_BGRA]]. This will be -1 if the pixel format does not have an alpha component.
dstSizes[i] should be set to the size of yo
Blue offset (in bytes) for a given pixel format.
-This specifies the number of bytes that the Blue component is offset from the start of the pixel. For instance, if a pixel of format TJ_BGRX is stored in char pixel[], then the blue component will be pixel[tjBlueOffset[TJ_BGRX]]. This will be -1 if the pixel format does not have a blue component.
This specifies the number of bytes that the blue component is offset from the start of the pixel. For instance, if a pixel of format TJPF_BGRX is stored in unsigned char pixel[], then the blue component will be pixel[tjBlueOffset[TJPF_BGRX]]. This will be -1 if the pixel format does not have a blue component.
dstSizes[i] should be set to the size of yo
Green offset (in bytes) for a given pixel format.
-This specifies the number of bytes that the green component is offset from the start of the pixel. For instance, if a pixel of format TJ_BGRX is stored in char pixel[], then the green component will be pixel[tjGreenOffset[TJ_BGRX]]. This will be -1 if the pixel format does not have a green component.
This specifies the number of bytes that the green component is offset from the start of the pixel. For instance, if a pixel of format TJPF_BGRX is stored in unsigned char pixel[], then the green component will be pixel[tjGreenOffset[TJPF_BGRX]]. This will be -1 if the pixel format does not have a green component.
dstSizes[i] should be set to the size of yo
Red offset (in bytes) for a given pixel format.
-This specifies the number of bytes that the red component is offset from the start of the pixel. For instance, if a pixel of format TJ_BGRX is stored in char pixel[], then the red component will be pixel[tjRedOffset[TJ_BGRX]]. This will be -1 if the pixel format does not have a red component.
This specifies the number of bytes that the red component is offset from the start of the pixel. For instance, if a pixel of format TJPF_BGRX is stored in unsigned char pixel[], then the red component will be pixel[tjRedOffset[TJPF_BGRX]]. This will be -1 if the pixel format does not have a red component.
coeffs as well as its offset relative to the component plane. TurboJPEG implementations may choose to split each component plane into multiple DCT coefficient arrays and call the callback function once for each array.coeffs belongscoeffs belongs (Y, Cb, and Cr have, respectively, ID's of 0, 1, and 2 in typical JPEG images.)coeffs belongs. (Y, Cb, and Cr have, respectively, ID's of 0, 1, and 2 in typical JPEG images.)coeffs belongs. This is the same as the index of the transform in the transforms array that was passed to tjTransform().The bitwise OR of one of more of the transform options.
+The bitwise OR of one of more of the transform options.
= If testing YUV encoding/decoding, this specifies the number of"); - System.out.println(" bytes to which each row of each plane in the intermediate YUV image is"); - System.out.println(" padded (default = 1)"); - System.out.println("-scale M/N = Scale down the width/height of the decompressed JPEG image by a"); + System.out.println("-yuv = Compress from/decompress to intermediate planar YUV images"); + System.out.println("-yuvpad
= The number of bytes by which each row in each plane of an");
+ System.out.println(" intermediate YUV image is evenly divisible (must be a power of 2)");
+ System.out.println(" [default = 1]");
+ System.out.println("-scale M/N = When decompressing, scale the width/height of the JPEG image by a");
System.out.print(" factor of M/N (M/N = ");
for (i = 0; i < nsf; i++) {
System.out.format("%d/%d", scalingFactors[i].getNum(),
@@ -740,24 +737,24 @@ final class TJBench {
}
System.out.println(")");
System.out.println("-hflip, -vflip, -transpose, -transverse, -rot90, -rot180, -rot270 =");
- System.out.println(" Perform the corresponding lossless transform prior to");
- System.out.println(" decompression (these options are mutually exclusive)");
- System.out.println("-grayscale = Perform lossless grayscale conversion prior to decompression");
- System.out.println(" test (can be combined with the other transforms above)");
+ System.out.println(" Perform the specified lossless transform operation on the input image");
+ System.out.println(" prior to decompression (these operations are mutually exclusive)");
+ System.out.println("-grayscale = Transform the input image into a grayscale JPEG image prior to");
+ System.out.println(" decompression (can be combined with the other transform operations above)");
System.out.println("-copynone = Do not copy any extra markers (including EXIF and ICC profile data)");
- System.out.println(" when transforming the image.");
- System.out.println("-benchtime
NOTE: due to the design of the TurboJPEG Java API, only certain methods
(specifically,
NOTE: due to the design of the TurboJPEG Java API, only certain methods
(specifically,
- NOTE: This method has no effect when compressing a JPEG image from a YUV
- planar source. In that case, the level of chrominance subsampling in
- the JPEG image is determined by the source. Furthermore, this method has
- no effect when encoding to a pre-allocated
- NOTE: The output image is fully recoverable if this method throws a
+ NOTE: The destination image is fully recoverable if this method throws a
non-fatal
- NOTE: The YUV planar output image is fully recoverable if this method
+ NOTE: The planar YUV destination image is fully recoverable if this method
throws a non-fatal
- NOTE: The output image is fully recoverable if this method throws a
+ NOTE: The destination image is fully recoverable if this method throws a
non-fatal
- NOTE: The output image is fully recoverable if this method throws a
+ NOTE: The destination image is fully recoverable if this method throws a
non-fatal
- Technically, the JPEG format uses the YCbCr colorspace (which technically is
- not a "colorspace" but rather a "color transform"), but per the convention
- of the digital video community, the TurboJPEG API uses "YUV" to refer to an
- image format consisting of Y, Cb, and Cr image planes.
+ Technically, the JPEG format uses the YCbCr colorspace (which is technically
+ not a colorspace but a color transform), but per the convention of the
+ digital video community, the TurboJPEG API uses "YUV" to refer to an image
+ format consisting of Y, Cb, and Cr image planes.
Each plane is simply a 2D array of bytes, each byte representing the value
of one of the components (Y, Cb, or Cr) at a particular location in the
image. The width and height of each plane are determined by the image
width, height, and level of chrominance subsampling. The luminance plane
width is the image width padded to the nearest multiple of the horizontal
- subsampling factor (2 in the case of 4:2:0 and 4:2:2, 4 in the case of
- 4:1:1, 1 in the case of 4:4:4 or grayscale.) Similarly, the luminance plane
- height is the image height padded to the nearest multiple of the vertical
- subsampling factor (2 in the case of 4:2:0 or 4:4:0, 1 in the case of 4:4:4
- or grayscale.) The chrominance plane width is equal to the luminance plane
- width divided by the horizontal subsampling factor, and the chrominance
- plane height is equal to the luminance plane height divided by the vertical
- subsampling factor.
+ subsampling factor (1 in the case of 4:4:4, grayscale, or 4:4:0; 2 in the
+ case of 4:2:2 or 4:2:0; 4 in the case of 4:1:1.) Similarly, the luminance
+ plane height is the image height padded to the nearest multiple of the
+ vertical subsampling factor (1 in the case of 4:4:4, 4:2:2, grayscale, or
+ 4:1:1; 2 in the case of 4:2:0 or 4:4:0.) This is irrespective of any
+ additional padding that may be specified as an argument to the various
+ YUVImage methods. The chrominance plane width is equal to the luminance
+ plane width divided by the horizontal subsampling factor, and the
+ chrominance plane height is equal to the luminance plane height divided by
+ the vertical subsampling factor.
For example, if the source image is 35 x 35 pixels and 4:2:2 subsampling is
used, then the luminance plane would be 36 x 35 bytes, and each of the
- chrominance planes would be 18 x 35 bytes. If you specify a line padding of
- 4 bytes on top of this, then the luminance plane would be 36 x 35 bytes, and
- each of the chrominance planes would be 20 x 35 bytes.
* NOTE: due to the design of the TurboJPEG Java API, only certain methods
* (specifically, {@link TJDecompressor TJDecompressor.decompress*()} methods
- * with a void return type) will complete and leave the output image in a
- * fully recoverable state after a non-fatal error occurs.
+ * with a void return type) will complete and leave the destination image in
+ * a fully recoverable state after a non-fatal error occurs.
*/
public static final int FLAG_STOPONWARNING = 8192;
/**
@@ -455,13 +456,13 @@ public final class TJ {
*/
public static final int NUMERR = 2;
/**
- * The error was non-fatal and recoverable, but the image may still be
- * corrupt.
+ * The error was non-fatal and recoverable, but the destination image may
+ * still be corrupt.
*
* NOTE: due to the design of the TurboJPEG Java API, only certain methods
* (specifically, {@link TJDecompressor TJDecompressor.decompress*()} methods
- * with a void return type) will complete and leave the output image in a
- * fully recoverable state after a non-fatal error occurs.
+ * with a void return type) will complete and leave the destination image in
+ * a fully recoverable state after a non-fatal error occurs.
*/
public static final int ERR_WARNING = 0;
/**
@@ -479,7 +480,7 @@ public final class TJ {
* @param height the height (in pixels) of the JPEG image
*
* @param jpegSubsamp the level of chrominance subsampling to be used when
- * generating the JPEG image (one of {@link TJ TJ.SAMP_*})
+ * generating the JPEG image (one of {@link #SAMP_444 TJ.SAMP_*})
*
* @return the maximum size of the buffer (in bytes) required to hold a JPEG
* image with the given width, height, and level of chrominance subsampling.
@@ -487,23 +488,27 @@ public final class TJ {
public static native int bufSize(int width, int height, int jpegSubsamp);
/**
- * Returns the size of the buffer (in bytes) required to hold a YUV planar
- * image with the given width, height, and level of chrominance subsampling.
+ * Returns the size of the buffer (in bytes) required to hold a unified
+ * planar YUV image with the given width, height, and level of chrominance
+ * subsampling.
*
* @param width the width (in pixels) of the YUV image
*
- * @param pad the width of each line in each plane of the image is padded to
- * the nearest multiple of this number of bytes (must be a power of 2.)
+ * @param align row alignment (in bytes) of the YUV image (must be a power of
+ * 2.) Setting this parameter to n specifies that each row in each plane of
+ * the YUV image will be padded to the nearest multiple of n bytes
+ * (1 = unpadded.)
*
* @param height the height (in pixels) of the YUV image
*
* @param subsamp the level of chrominance subsampling used in the YUV
- * image (one of {@link TJ TJ.SAMP_*})
+ * image (one of {@link #SAMP_444 TJ.SAMP_*})
*
- * @return the size of the buffer (in bytes) required to hold a YUV planar
- * image with the given width, height, and level of chrominance subsampling.
+ * @return the size of the buffer (in bytes) required to hold a unified
+ * planar YUV image with the given width, height, and level of chrominance
+ * subsampling.
*/
- public static native int bufSizeYUV(int width, int pad, int height,
+ public static native int bufSizeYUV(int width, int align, int height,
int subsamp);
/**
@@ -523,16 +528,16 @@ public final class TJ {
* @param width width (in pixels) of the YUV image. NOTE: this is the width
* of the whole image, not the plane width.
*
- * @param stride bytes per line in the image plane.
+ * @param stride bytes per row in the image plane.
*
* @param height height (in pixels) of the YUV image. NOTE: this is the
* height of the whole image, not the plane height.
*
* @param subsamp the level of chrominance subsampling used in the YUV
- * image (one of {@link TJ TJ.SAMP_*})
+ * image (one of {@link #SAMP_444 TJ.SAMP_*})
*
- * @return the size of the buffer (in bytes) required to hold a YUV planar
- * image with the given parameters.
+ * @return the size of the buffer (in bytes) required to hold a YUV image
+ * plane with the given parameters.
*/
public static native int planeSizeYUV(int componentID, int width, int stride,
int height, int subsamp);
@@ -547,7 +552,7 @@ public final class TJ {
* @param width width (in pixels) of the YUV image
*
* @param subsamp the level of chrominance subsampling used in the YUV image
- * (one of {@link TJ TJ.SAMP_*})
+ * (one of {@link #SAMP_444 TJ.SAMP_*})
*
* @return the plane width of a YUV image plane with the given parameters.
*/
@@ -563,7 +568,7 @@ public final class TJ {
* @param height height (in pixels) of the YUV image
*
* @param subsamp the level of chrominance subsampling used in the YUV image
- * (one of {@link TJ TJ.SAMP_*})
+ * (one of {@link #SAMP_444 TJ.SAMP_*})
*
* @return the plane height of a YUV image plane with the given parameters.
*/
@@ -571,11 +576,11 @@ public final class TJ {
int subsamp);
/**
- * Returns a list of fractional scaling factors that the JPEG decompressor in
- * this implementation of TurboJPEG supports.
+ * Returns a list of fractional scaling factors that the JPEG decompressor
+ * supports.
*
- * @return a list of fractional scaling factors that the JPEG decompressor in
- * this implementation of TurboJPEG supports.
+ * @return a list of fractional scaling factors that the JPEG decompressor
+ * supports.
*/
public static native TJScalingFactor[] getScalingFactors();
diff --git a/java/org/libjpegturbo/turbojpeg/TJCompressor.java b/java/org/libjpegturbo/turbojpeg/TJCompressor.java
index 6d4830f5..d5bbd826 100644
--- a/java/org/libjpegturbo/turbojpeg/TJCompressor.java
+++ b/java/org/libjpegturbo/turbojpeg/TJCompressor.java
@@ -1,5 +1,6 @@
/*
- * Copyright (C)2011-2015, 2018, 2020 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011-2015, 2018, 2020, 2023 D. R. Commander.
+ * All Rights Reserved.
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,7 +50,7 @@ public class TJCompressor implements Closeable {
}
/**
- * Create a TurboJPEG compressor instance and associate the uncompressed
+ * Create a TurboJPEG compressor instance and associate the packed-pixel
* source image stored in
- * NOTE: This method has no effect when compressing a JPEG image from a YUV
- * planar source. In that case, the level of chrominance subsampling in
- * the JPEG image is determined by the source. Furthermore, this method has
- * no effect when encoding to a pre-allocated {@link YUVImage} instance. In
- * that case, the level of chrominance subsampling is determined by the
- * destination.
+ * NOTE: This method has no effect when compressing a JPEG image from a
+ * planar YUV source image. In that case, the level of chrominance
+ * subsampling in the JPEG image is determined by the source image.
+ * Furthermore, this method has no effect when encoding to a pre-allocated
+ * {@link YUVImage} instance. In that case, the level of chrominance
+ * subsampling is determined by the destination image.
*
* @param newSubsamp the level of chrominance subsampling to use in
* subsequent compress/encode oeprations (one of
@@ -315,8 +318,9 @@ public class TJCompressor implements Closeable {
}
/**
- * Compress the uncompressed source image associated with this compressor
- * instance and output a JPEG image to the given destination buffer.
+ * Compress the packed-pixel or planar YUV source image associated with this
+ * compressor instance and output a JPEG image to the given destination
+ * buffer.
*
* @param dstBuf buffer that will receive the JPEG image. Use
* {@link TJ#bufSize} to determine the maximum size for this buffer based on
@@ -366,8 +370,8 @@ public class TJCompressor implements Closeable {
}
/**
- * Compress the uncompressed source image associated with this compressor
- * instance and return a buffer containing a JPEG image.
+ * Compress the packed-pixel or planar YUV source image associated with this
+ * compressor instance and return a buffer containing a JPEG image.
*
* @param flags the bitwise OR of one or more of
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
@@ -417,14 +421,14 @@ public class TJCompressor implements Closeable {
}
/**
- * Encode the uncompressed source image associated with this compressor
- * instance into a YUV planar image and store it in the given
- *
- * NOTE: The output image is fully recoverable if this method throws a
+ * NOTE: The destination image is fully recoverable if this method throws a
* non-fatal {@link TJException} (unless
* {@link TJ#FLAG_STOPONWARNING TJ.FLAG_STOPONWARNING} is specified.)
*
- * @param dstBuf buffer that will receive the decompressed/decoded image.
- * If the source image is a JPEG image, then this buffer should normally be
- *
- * NOTE: The YUV planar output image is fully recoverable if this method
+ * NOTE: The planar YUV destination image is fully recoverable if this method
* throws a non-fatal {@link TJException} (unless
* {@link TJ#FLAG_STOPONWARNING TJ.FLAG_STOPONWARNING} is specified.)
*
- * @param dstImage {@link YUVImage} instance that will receive the YUV planar
- * image. The level of subsampling specified in this
- * NOTE: The output image is fully recoverable if this method throws a
+ * NOTE: The destination image is fully recoverable if this method throws a
* non-fatal {@link TJException} (unless
* {@link TJ#FLAG_STOPONWARNING TJ.FLAG_STOPONWARNING} is specified.)
*
- * @param dstBuf buffer that will receive the decompressed/decoded image.
- * If the source image is a JPEG image, then this buffer should normally be
- *
- * NOTE: The output image is fully recoverable if this method throws a
+ * NOTE: The destination image is fully recoverable if this method throws a
* non-fatal {@link TJException} (unless
* {@link TJ#FLAG_STOPONWARNING TJ.FLAG_STOPONWARNING} is specified.)
*
* @param dstImage a
- * Technically, the JPEG format uses the YCbCr colorspace (which technically is
- * not a "colorspace" but rather a "color transform"), but per the convention
- * of the digital video community, the TurboJPEG API uses "YUV" to refer to an
- * image format consisting of Y, Cb, and Cr image planes.
+ * Technically, the JPEG format uses the YCbCr colorspace (which is technically
+ * not a colorspace but a color transform), but per the convention of the
+ * digital video community, the TurboJPEG API uses "YUV" to refer to an image
+ * format consisting of Y, Cb, and Cr image planes.
*
* Each plane is simply a 2D array of bytes, each byte representing the value
* of one of the components (Y, Cb, or Cr) at a particular location in the
* image. The width and height of each plane are determined by the image
* width, height, and level of chrominance subsampling. The luminance plane
* width is the image width padded to the nearest multiple of the horizontal
- * subsampling factor (2 in the case of 4:2:0 and 4:2:2, 4 in the case of
- * 4:1:1, 1 in the case of 4:4:4 or grayscale.) Similarly, the luminance plane
- * height is the image height padded to the nearest multiple of the vertical
- * subsampling factor (2 in the case of 4:2:0 or 4:4:0, 1 in the case of 4:4:4
- * or grayscale.) The chrominance plane width is equal to the luminance plane
- * width divided by the horizontal subsampling factor, and the chrominance
- * plane height is equal to the luminance plane height divided by the vertical
- * subsampling factor.
+ * subsampling factor (1 in the case of 4:4:4, grayscale, or 4:4:0; 2 in the
+ * case of 4:2:2 or 4:2:0; 4 in the case of 4:1:1.) Similarly, the luminance
+ * plane height is the image height padded to the nearest multiple of the
+ * vertical subsampling factor (1 in the case of 4:4:4, 4:2:2, grayscale, or
+ * 4:1:1; 2 in the case of 4:2:0 or 4:4:0.) This is irrespective of any
+ * additional padding that may be specified as an argument to the various
+ * YUVImage methods. The chrominance plane width is equal to the luminance
+ * plane width divided by the horizontal subsampling factor, and the
+ * chrominance plane height is equal to the luminance plane height divided by
+ * the vertical subsampling factor.
*
* For example, if the source image is 35 x 35 pixels and 4:2:2 subsampling is
* used, then the luminance plane would be 36 x 35 bytes, and each of the
- * chrominance planes would be 18 x 35 bytes. If you specify a line padding of
- * 4 bytes on top of this, then the luminance plane would be 36 x 35 bytes, and
- * each of the chrominance planes would be 20 x 35 bytes.
+ * chrominance planes would be 18 x 35 bytes. If you specify a row alignment
+ * of 4 bytes on top of this, then the luminance plane would be 36 x 35 bytes,
+ * and each of the chrominance planes would be 20 x 35 bytes.
*/
public class YUVImage {
@@ -75,7 +77,7 @@ public class YUVImage {
* @param width width (in pixels) of the YUV image
*
* @param strides an array of integers, each specifying the number of bytes
- * per line in the corresponding plane of the YUV image. Setting the stride
+ * per row in the corresponding plane of the YUV image. Setting the stride
* for any plane to 0 is the same as setting it to the plane width (see
* {@link YUVImage above}.) If = If testing YUV encoding/decoding, this specifies the number of\n");
- printf(" bytes to which each row of each plane in the intermediate YUV image is\n");
- printf(" padded (default = 1)\n");
- printf("-scale M/N = Scale down the width/height of the decompressed JPEG image by a\n");
+ printf("-yuv = Compress from/decompress to intermediate planar YUV images\n");
+ printf("-yuvpad = The number of bytes by which each row in each plane of an\n");
+ printf(" intermediate YUV image is evenly divisible (must be a power of 2)\n");
+ printf(" [default = 1]\n");
+ printf("-scale M/N = When decompressing, scale the width/height of the JPEG image by a\n");
printf(" factor of M/N (M/N = ");
for (i = 0; i < nsf; i++) {
printf("%d/%d", scalingFactors[i].num, scalingFactors[i].denom);
@@ -794,24 +790,24 @@ static void usage(char *progName)
}
printf(")\n");
printf("-hflip, -vflip, -transpose, -transverse, -rot90, -rot180, -rot270 =\n");
- printf(" Perform the corresponding lossless transform prior to\n");
- printf(" decompression (these options are mutually exclusive)\n");
- printf("-grayscale = Perform lossless grayscale conversion prior to decompression\n");
- printf(" test (can be combined with the other transforms above)\n");
+ printf(" Perform the specified lossless transform operation on the input image\n");
+ printf(" prior to decompression (these operations are mutually exclusive)\n");
+ printf("-grayscale = Transform the input image into a grayscale JPEG image prior to\n");
+ printf(" decompression (can be combined with the other transform operations above)\n");
printf("-copynone = Do not copy any extra markers (including EXIF and ICC profile data)\n");
- printf(" when transforming the image.\n");
- printf("-benchtime
@@ -370,8 +373,8 @@
BufferedImage instance.BufferedImage
+ instance.BufferedImage
- instance containing the decompressed/decoded image.BufferedImage instance containing the packed-pixel
+ decompressed/decoded image.YUVImage instance.YUVImage instance.
YUVImage instance containing the decompressed image planes.YUVImage instance containing the decompressed image planes.
YUVImage instance containing the decompressed image.YUVImage
+ instance containing the decompressed image.
@@ -303,23 +308,21 @@
YUVImage instance.YUVImage instance.YUVImage instance containing the encoded image.YUVImage
+ instance containing the encoded image.YUVImage instance containing the encoded image planes.YUVImage instance containing the encoded image planes.
OP_*)OP_*)TJTransformer.transform() from copying any extra markers (including EXIF
- and ICC profile data) from the source image to the output image.OPT_*)OPT_*)YUVImage instance.YUVImage instance.srcImage with the newly created
instance.srcImage with the newly created
instance.jpegImage with the newly created instance.jpegImage with the newly created instance.imageSize bytes stored in
- jpegImage with the newly created instance.imageSize bytes stored in jpegImage
+ with the newly created instance.yuvImage with the newly created
instance.jpegImage with the newly created instance.jpegImage with the newly created
+ instance.imageSize bytes stored in
+ source image of length imageSize bytes stored in
jpegImage with the newly created instance.TJDecompressor instances, each of
- which has a transformed JPEG image associated with it.TJDecompressor
+ instances, each of which has a transformed JPEG image associated with it.Y
+
YUVImage instance backed by a unified image
- buffer, and allocate memory for the image buffer.YUVImage instance backed by a unified buffer,
+ and allocate memory for the buffer.YUVImage instance from an existing unified image
+YUVImage instance from an existing unified
buffer.
static intERR_WARNING
-
static intFLAG_ACCURATEDCT
-
static intFLAG_BOTTOMUP
-
static intFLAG_FASTDCT
-
static intFLAG_FASTUPSAMPLE
@@ -230,7 +228,7 @@ extends java.lang.Object
static intFLAG_STOPONWARNING
@@ -402,11 +400,12 @@ extends java.lang.Object
static intbufSizeYUV(int width,
- int pad,
+ int align,
int height,
int subsamp)
-
@@ -460,8 +459,8 @@ extends java.lang.Object
static TJScalingFactor[]getScalingFactors()
-
@@ -778,8 +777,8 @@ extends java.lang.Object
vice versa, but the mapping is typically not 1:1 or reversible, nor can it
be defined with a simple formula. Thus, such a conversion is out of scope
for a codec library. However, the TurboJPEG API allows for compressing
- CMYK pixels into a YCCK JPEG image (see
CS_YCCK) and
- decompressing YCCK JPEG images into CMYK pixels.
+ packed-pixel CMYK images into YCCK JPEG images (see CS_YCCK) and
+ decompressing YCCK JPEG images into packed-pixel CMYK images.
@@ -804,8 +803,9 @@ extends java.lang.Object
@@ -826,10 +826,11 @@ extends java.lang.Object
transformation allowed the same signal to drive both black & white and
color televisions, but JPEG images use YCbCr primarily because it allows
the color data to be optionally subsampled for the purposes of reducing
- bandwidth or disk space. YCbCr is the most common JPEG colorspace, and
- YCbCr JPEG images can be compressed from and decompressed to any of the
- extended RGB pixel formats or grayscale, or they can be decompressed to
- YUV planar images.
+ network or disk usage. YCbCr is the most common JPEG colorspace, and
+ YCbCr JPEG images can be compressed from and decompressed to packed-pixel
+ images with any of the extended RGB or grayscale pixel formats. YCbCr
+ JPEG images can also be compressed from and decompressed to planar YUV
+ images.
@@ -842,9 +843,10 @@ extends java.lang.Object
public static final int CS_GRAY
@@ -858,7 +860,7 @@ extends java.lang.Object
@@ -875,7 +877,7 @@ extends java.lang.Object
reversibly transformed into YCCK, and as with YCbCr, the chrominance
components in the YCCK pixels can be subsampled without incurring major
perceptual loss. YCCK JPEG images can only be compressed from and
- decompressed to CMYK pixels.
+ decompressed to packed-pixel images with the CMYK pixel format.
@@ -886,8 +888,8 @@ extends java.lang.Object
FLAG_BOTTOMUP
public static final int FLAG_BOTTOMUP
-FLAG_FASTUPSAMPLE
public static final int FLAG_FASTUPSAMPLE
@@ -961,12 +963,12 @@ public static final int FLAG_FORCESSE3
FLAG_FASTDCT
public static final int FLAG_FASTDCT
-FLAG_ACCURATEDCT
public static final int FLAG_ACCURATEDCT
-FLAG_STOPONWARNING
public static final int FLAG_STOPONWARNING
TJDecompressor.decompress*() methods
- with a void return type) will complete and leave the output image in a
- fully recoverable state after a non-fatal error occurs.
@@ -1055,13 +1055,13 @@ public static final int FLAG_FORCESSE3
ERR_WARNING
public static final int ERR_WARNING
-TJDecompressor.decompress*() methods
- with a void return type) will complete and leave the output image in a
- fully recoverable state after a non-fatal error occurs.
@@ -1109,7 +1109,7 @@ public static final int FLAG_FORCESSE3
subsamp - the level of chrominance subsampling (one of
- SAMP_*)SAMP_*)
@@ -1122,7 +1122,7 @@ public static final int FLAG_FORCESSE3
subsamp - the level of chrominance subsampling (one of
- SAMP_*)SAMP_*)
getPixelSize
public static int getPixelSize(int pixelFormat)
pixelFormat - the pixel format (one of PF_*)
@@ -1138,7 +1138,7 @@ public static final int FLAG_FORCESSE3
of format pixelFormat - the pixel format (one of PF_*)TJ.PF_BGRX is stored in char pixel[],
then the red component will be
pixel[TJ.getRedOffset(TJ.PF_BGRX)].
-pixelFormat - the pixel format (one of PF_*)
@@ -1155,7 +1155,7 @@ public static final int FLAG_FORCESSE3
of format pixelFormat - the pixel format (one of PF_*)TJ.PF_BGRX is stored in char pixel[],
then the green component will be
pixel[TJ.getGreenOffset(TJ.PF_BGRX)].
-pixelFormat - the pixel format (one of PF_*)
@@ -1172,7 +1172,7 @@ public static final int FLAG_FORCESSE3
of format pixelFormat - the pixel format (one of PF_*)TJ.PF_BGRX is stored in char pixel[],
then the blue component will be
pixel[TJ.getBlueOffset(TJ.PF_BGRX)].
-pixelFormat - the pixel format (one of PF_*)
@@ -1189,7 +1189,7 @@ public static final int FLAG_FORCESSE3
of format pixelFormat - the pixel format (one of PF_*)TJ.PF_BGRA is stored in char pixel[],
then the alpha component will be
pixel[TJ.getAlphaOffset(TJ.PF_BGRA)].
-pixelFormat - the pixel format (one of PF_*)
@@ -1206,7 +1206,7 @@ public static final int FLAG_FORCESSE3
pixelFormat - the pixel format (one of PF_*)
@@ -1218,16 +1218,20 @@ public static final int FLAG_FORCESSE3
width - the width (in pixels) of the JPEG imageheight - the height (in pixels) of the JPEG imagejpegSubsamp - the level of chrominance subsampling to be used when
- generating the JPEG image (one of TJ.SAMP_*)TJ.SAMP_*)
bufSizeYUV
public static int bufSizeYUV(int width,
- int pad,
+ int align,
int height,
int subsamp)
-
+width - the width (in pixels) of the YUV imagepad - the width of each line in each plane of the image is padded to
- the nearest multiple of this number of bytes (must be a power of 2.)height - the height (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling used in the YUV
- image (one of TJ.SAMP_*)width - the width (in pixels) of the YUV imagealign - row alignment (in bytes) of the YUV image (must be a power of
+ 2.) Setting this parameter to n specifies that each row in each plane of
+ the YUV image will be padded to the nearest multiple of n bytes
+ (1 = unpadded.)height - the height (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling used in the YUV
+ image (one of TJ.SAMP_*)
+ image (one of componentID - ID number of the image plane (0 = Y, 1 = U/Cb,
2 = V/Cr)width - width (in pixels) of the YUV image. NOTE: this is the width
- of the whole image, not the plane width.stride - bytes per line in the image plane.height - height (in pixels) of the YUV image. NOTE: this is the
+ of the whole image, not the plane width.stride - bytes per row in the image plane.height - height (in pixels) of the YUV image. NOTE: this is the
height of the whole image, not the plane height.subsamp - the level of chrominance subsampling used in the YUV
- image (one of TJ.SAMP_*)TJ.SAMP_*)
+YUVImage for a description of plane width.
@@ -1295,7 +1299,7 @@ public static int bufSizeYUV(int width,
Refer to componentID - ID number of the image plane (0 = Y, 1 = U/Cb,
2 = V/Cr)width - width (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling used in the YUV image
- (one of TJ.SAMP_*)TJ.SAMP_*)
YUVImage for a description of plane height.
@@ -1306,10 +1310,10 @@ public static int bufSizeYUV(int width,
componentID - ID number of the image plane (0 = Y, 1 = U/Cb,
2 = V/Cr)height - height (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling used in the YUV image
- (one of TJ.SAMP_*)TJ.SAMP_*)
getScalingFactors
public static TJScalingFactor[] getScalingFactors()
-
+srcImage with the newly created
instance.srcImage with the newly created
instance.voidcompress(byte[] dstBuf,
int flags)
-
byte[]compress(int flags)
-
@@ -265,27 +266,27 @@ implements java.io.Closeable
YUVImageencodeYUV(int[] strides,
int flags)
-YUVImage instance containing the encoded image planes.YUVImage instance containing the encoded image planes.
-YUVImageencodeYUV(int pad,
+encodeYUV(int align,
int flags)
-YUVImage instance containing the encoded image.YUVImage
+ instance containing the encoded image.
voidencodeYUV(YUVImage dstImage,
int flags)
-YUVImage instance.YUVImage instance.
@@ -312,7 +313,7 @@ implements java.io.Closeable
int y,
int width,
int height)
-
@@ -338,15 +339,14 @@ implements java.io.Closeable
int pitch,
int height,
int pixelFormat)
-
voidsetSourceImage(YUVImage srcImage)
-
@@ -405,7 +405,7 @@ implements java.io.Closeable
int height,
int pixelFormat)
throws TJException
-
srcImage with the newly created
instance.srcImage - see setSourceImage(byte[], int, int, int, int, int, int) for descriptionx - see setSourceImage(byte[], int, int, int, int, int, int) for descriptiony - see setSourceImage(byte[], int, int, int, int, int, int) for descriptionwidth - see setSourceImage(byte[], int, int, int, int, int, int) for descriptionpitch - see setSourceImage(byte[], int, int, int, int, int, int) for descriptionheight - see setSourceImage(byte[], int, int, int, int, int, int) for descriptionpixelFormat - pixel format of the source image (one of
@@ -445,7 +445,7 @@ public TJCompressor(byte[] srcImage,
int width,
int height)
throws TJException
-srcImage with the newly created
instance.srcImage - see
@@ -480,20 +480,22 @@ public TJCompressor(byte[] srcImage,
int height,
int pixelFormat)
throws TJException
-srcImage - image buffer containing RGB, grayscale, or CMYK pixels to
- be compressed or encoded. This buffer is not modified.x - x offset (in pixels) of the region in the source image from which
+srcImage - buffer containing a packed-pixel RGB, grayscale, or CMYK
+ source image to be compressed or encoded. This buffer is not modified.x - x offset (in pixels) of the region in the source image from which
the JPEG or YUV image should be compressed/encodedy - y offset (in pixels) of the region in the source image from which
the JPEG or YUV image should be compressed/encodedwidth - width (in pixels) of the region in the source image from
- which the JPEG or YUV image should be compressed/encodedpitch - bytes per line of the source image. Normally, this should be
- width * TJ.pixelSize(pixelFormat) if the source image is
- unpadded, but you can use this parameter to, for instance, specify that
- the scanlines in the source image are padded to a 4-byte boundary or to
- compress/encode a JPEG or YUV image from a region of a larger source
- image. You can also be clever and use this parameter to skip lines, etc.
- Setting this parameter to 0 is the equivalent of setting it to
- width * TJ.pixelSize(pixelFormat).height - height (in pixels) of the region in the source image from
+ which the JPEG or YUV image should be compressed/encodedpitch - bytes per row in the source image. Normally this should be
+ width *
+ TJ.getPixelSize(pixelFormat),
+ if the source image is unpadded. However, you can use this parameter to,
+ for instance, specify that the rows in the source image are padded to the
+ nearest multiple of 4 bytes or to compress/encode a JPEG or YUV image from
+ a region of a larger source image. You can also be clever and use this
+ parameter to skip rows, etc. Setting this parameter to 0 is the
+ equivalent of setting it to width *
+ TJ.getPixelSize(pixelFormat).height - height (in pixels) of the region in the source image from
which the JPEG or YUV image should be compressed/encodedpixelFormat - pixel format of the source image (one of
TJ.PF_*)srcImage - a BufferedImage instance containing RGB or
- grayscale pixels to be compressed or encoded. This image is not modified.x - x offset (in pixels) of the region in the source image from which
+srcImage - a BufferedImage instance containing a
+ packed-pixel RGB or grayscale source image to be compressed or encoded.
+ This image is not modified.x - x offset (in pixels) of the region in the source image from which
the JPEG or YUV image should be compressed/encodedy - y offset (in pixels) of the region in the source image from which
the JPEG or YUV image should be compressed/encodedwidth - width (in pixels) of the region in the source image from
which the JPEG or YUV image should be compressed/encoded (0 = use the
@@ -553,10 +556,9 @@ public void setSourceImage(byte[] srcImage,
setSourceImage
public void setSourceImage(YUVImage srcImage)
throws TJException
-srcImage - YUV planar image to be compressed. This image is not
- modified.
@@ -573,16 +575,16 @@ public void setSourceImage(byte[] srcImage,
srcImage - planar YUV source image to be compressed. This image is
+ not modified.TJExceptionTJ.CS_YCbCr) or from CMYK to YCCK (see TJ.CS_YCCK) as part
of the JPEG compression process, some of the Cb and Cr (chrominance)
components can be discarded or averaged together to produce a smaller
- image with little perceptible loss of image clarity (the human eye is more
- sensitive to small changes in brightness than to small changes in color.)
- This is called "chrominance subsampling".
+ image with little perceptible loss of image clarity. (The human eye is
+ more sensitive to small changes in brightness than to small changes in
+ color.) This is called "chrominance subsampling".
YUVImage instance. In
- that case, the level of chrominance subsampling is determined by the
- destination.YUVImage instance. In that case, the level of chrominance
+ subsampling is determined by the destination image.
@@ -609,8 +611,9 @@ public void setSourceImage(byte[] srcImage,
newSubsamp - the level of chrominance subsampling to use in
subsequent compress/encode oeprations (one of
TJ.SAMP_*)public void compress(byte[] dstBuf,
int flags)
throws TJException
-dstBuf - buffer that will receive the JPEG image. Use
TJ.bufSize(int, int, int) to determine the maximum size for this buffer based on
the source image's width and height and the desired level of chrominance
@@ -628,8 +631,8 @@ public void setSourceImage(byte[] srcImage,
compress
public byte[] compress(int flags)
throws TJException
-flags - the bitwise OR of one or more of
TJ.FLAG_*public void encodeYUV(YUVImage dstImage,
int flags)
throws TJException
-YUVImage instance. This method uses the accelerated color
- conversion routines in TurboJPEG's underlying codec but does not execute
- any of the other steps in the JPEG compression process. Encoding
- CMYK source images to YUV is not supported.dstImage - YUVImage instance that will receive the YUV planar
+YUVImage instance. This method performs color conversion (which
+ is accelerated in the libjpeg-turbo implementation) but does not execute
+ any of the other steps in the JPEG compression process. Encoding CMYK
+ source images into YUV images is not supported.dstImage - YUVImage instance that will receive the planar YUV
imageflags - the bitwise OR of one or more of
TJ.FLAG_*
encodeYUV
-public YUVImage encodeYUV(int pad,
+
public YUVImage encodeYUV(int align,
int flags)
throws TJException
-YUVImage instance containing the encoded image. This method
- uses the accelerated color conversion routines in TurboJPEG's underlying
- codec but does not execute any of the other steps in the JPEG compression
- process. Encoding CMYK source images to YUV is not supported.pad - the width of each line in each plane of the YUV image will be
- padded to the nearest multiple of this number of bytes (must be a power of
- 2.)flags - the bitwise OR of one or more of
+YUVImage
+ instance containing the encoded image. This method performs color
+ conversion (which is accelerated in the libjpeg-turbo implementation) but
+ does not execute any of the other steps in the JPEG compression process.
+ Encoding CMYK source images into YUV images is not supported.align - row alignment (in bytes) of the YUV image (must be a power of
+ 2.) Setting this parameter to n will cause each row in each plane of the
+ YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.)flags - the bitwise OR of one or more of
TJ.FLAG_*YUVImage instance containing the unified planar YUV
+ encoded imageTJExceptionpublic YUVImage encodeYUV(int[] strides,
int flags)
throws TJException
-YUVImage instance containing the encoded image planes. This
- method uses the accelerated color conversion routines in TurboJPEG's
- underlying codec but does not execute any of the other steps in the JPEG
- compression process. Encoding CMYK source images to YUV is not supported.YUVImage instance containing the encoded image planes. This
+ method performs color conversion (which is accelerated in the
+ libjpeg-turbo implementation) but does not execute any of the other steps
+ in the JPEG compression process. Encoding CMYK source images into YUV
+ images is not supported.
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html b/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html
index 412dcd46..982079c4 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html
@@ -163,7 +163,7 @@
into multiple DCT coefficient buffers and call the callback function once
for each buffer.strides - an array of integers, each specifying the number of bytes
- per line in the corresponding plane of the output image. Setting the
- stride for any plane to 0 is the same as setting it to the component width
- of the plane. If strides is null, then the strides for all
- planes will be set to their respective component widths. You can adjust
- the strides in order to add an arbitrary amount of line padding to each
- plane.flags - the bitwise OR of one or more of
+ per row in the corresponding plane of the YUV source image. Setting the
+ stride for any plane to 0 is the same as setting it to the plane width
+ (see YUVImage.) If strides is null, then the strides
+ for all planes will be set to their respective plane widths. You can
+ adjust the strides in order to add an arbitrary amount of row padding to
+ each plane.flags - the bitwise OR of one or more of
TJ.FLAG_*YUVImage instance containing the encoded image planesTJExceptionplaneRegion - rectangle containing the width and height of the
component plane to which coeffBuffer belongscomponentID - ID number of the component plane to which
- coeffBuffer belongs (Y, Cb, and Cr have, respectively, ID's
+ coeffBuffer belongs. (Y, Cb, and Cr have, respectively, ID's
of 0, 1, and 2 in typical JPEG images.)transformID - ID number of the transformed image to which
coeffBuffer belongs. This is the same as the index of the
transform in the transforms array that was passed to TJTransformer.transform().transform - a TJTransform instance that specifies the
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
index 6666e4e1..77a7ab69 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html
@@ -180,20 +180,22 @@ implements java.io.Closeable
TJDecompressor(byte[] jpegImage)
jpegImage with the newly created instance.jpegImage with the newly created instance.
TJDecompressor(byte[] jpegImage,
int imageSize)
imageSize bytes stored in
- jpegImage with the newly created instance.imageSize bytes stored in jpegImage
+ with the newly created instance.
@@ -223,9 +225,10 @@ implements java.io.Closeable
TJDecompressor(YUVImage yuvImage)
-yuvImage with the newly created
instance.voiddecompress(java.awt.image.BufferedImage dstImage,
int flags)
-BufferedImage instance.BufferedImage
+ instance.
@@ -252,9 +255,9 @@ implements java.io.Closeable
int desiredHeight,
int pixelFormat,
int flags)
-
@@ -267,9 +270,9 @@ implements java.io.Closeable
int desiredHeight,
int pixelFormat,
int flags)
-
@@ -278,9 +281,10 @@ implements java.io.Closeable
int desiredHeight,
int bufferedImageType,
int flags)
-
BufferedImage
- instance containing the decompressed/decoded image.BufferedImage instance containing the packed-pixel
+ decompressed/decoded image.
@@ -290,8 +294,9 @@ implements java.io.Closeable
int desiredHeight,
int pixelFormat,
int flags)
-
@@ -319,18 +324,18 @@ implements java.io.Closeable
int flags)
YUVImage instance containing the decompressed image planes.YUVImage instance containing the decompressed image planes.
YUVImagedecompressToYUV(int desiredWidth,
- int pad,
+ int align,
int desiredHeight,
int flags)
YUVImage instance containing the decompressed image.YUVImage
+ instance containing the decompressed image.
@@ -338,8 +343,8 @@ implements java.io.Closeable
decompressToYUV(YUVImage dstImage,
int flags)
YUVImage instance.YUVImage instance.
@@ -363,7 +368,7 @@ implements java.io.Closeable
byte[]getJPEGBuf()
-
@@ -426,7 +431,7 @@ implements java.io.Closeable
@@ -554,9 +559,11 @@ implements java.io.Closeable
voidsetSourceImage(YUVImage srcImage)
-public TJDecompressor(byte[] jpegImage)
throws TJException
jpegImage with the newly created instance.jpegImage - JPEG image buffer (size of the JPEG image is assumed to
- be the length of the array.) This buffer is not modified.jpegImage with the newly created instance.
@@ -571,9 +578,12 @@ implements java.io.Closeable
int imageSize)
throws TJException
jpegImage - buffer containing a JPEG source image or tables-only
+ datastream. (The size of the JPEG image or datastream is assumed to be
+ the length of the array.) This buffer is not modified.TJExceptionimageSize bytes stored in
- jpegImage with the newly created instance.jpegImage - JPEG image buffer. This buffer is not modified.imageSize - size of the JPEG image (in bytes)imageSize bytes stored in jpegImage
+ with the newly created instance.
@@ -586,10 +596,10 @@ implements java.io.Closeable
jpegImage - buffer containing a JPEG source image or tables-only
+ datastream. This buffer is not modified.imageSize - size of the JPEG source image or tables-only datastream
+ (in bytes)TJExceptionTJDecompressor
public TJDecompressor(YUVImage yuvImage)
throws TJException
-yuvImage with the newly created
instance.yuvImage - YUVImage instance containing a YUV planar
+
@@ -616,15 +626,15 @@ implements java.io.Closeable
"tables-only") datastream of length yuvImage - YUVImage instance containing a planar YUV source
image to be decoded. This image is not modified.TJExceptionimageSize bytes stored in
jpegImage with this decompressor instance. If
jpegImage contains a JPEG image, then this image will be used
- as the source image for subsequent decompress operations. Passing a
+ as the source image for subsequent decompression operations. Passing a
tables-only datastream to this method primes the decompressor with
quantization and Huffman tables that can be used when decompressing
subsequent "abbreviated image" datastreams. This is useful, for instance,
when decompressing video streams in which all frames share the same
quantization and Huffman tables.jpegImage - buffer containing a JPEG image or an "abbreviated table
- specification" (AKA "tables-only") datastream. This buffer is not
- modified.imageSize - size of the JPEG image (in bytes)
@@ -651,11 +661,11 @@ public void setJPEGImage(byte[] jpegImage,
jpegImage - buffer containing a JPEG source image or tables-only
+ datastream. This buffer is not modified.imageSize - size of the JPEG source image or tables-only datastream
+ (in bytes)TJExceptionsetSourceImage
public void setSourceImage(YUVImage srcImage)
-
+srcImage - YUVImage instance containing a YUV planar image to
- be decoded. This image is not modified.srcImage - YUVImage instance containing a planar YUV source
+ image to be decoded. This image is not modified.getJPEGBuf
public byte[] getJPEGBuf()
-
+
@@ -771,12 +781,12 @@ public void setJPEGImage(byte[] jpegImage,
decompressor can generate without exceeding the desired image width and
height.
desiredWidth - desired width (in pixels) of the decompressed image.
- Setting this to 0 is the same as setting it to the width of the JPEG image
- (in other words, the width will not be considered when determining the
- scaled image size.)desiredHeight - desired height (in pixels) of the decompressed image.
+ Setting this to 0 is the same as setting it to the width of the JPEG
+ image. (In other words, the width will not be considered when determining
+ the scaled image size.)desiredHeight - desired height (in pixels) of the decompressed image.
Setting this to 0 is the same as setting it to the height of the JPEG
- image (in other words, the height will not be considered when determining
- the scaled image size.)
@@ -797,25 +807,26 @@ public void setJPEGImage(byte[] jpegImage,
int pixelFormat,
int flags)
throws TJException
-desiredWidth - desired width (in pixels) of the decompressed image.
- Setting this to 0 is the same as setting it to the width of the JPEG image
- (in other words, the width will not be considered when determining the
- scaled image size.)desiredHeight - desired height (in pixels) of the decompressed image.
+ Setting this to 0 is the same as setting it to the width of the JPEG
+ image. (In other words, the width will not be considered when determining
+ the scaled image size.)desiredHeight - desired height (in pixels) of the decompressed image.
Setting this to 0 is the same as setting it to the height of the JPEG
- image (in other words, the height will not be considered when determining
- the scaled image size.)TJException (unless
TJ.FLAG_STOPONWARNING is specified.)dstBuf - buffer that will receive the decompressed/decoded image.
- If the source image is a JPEG image, then this buffer should normally be
- pitch * scaledHeight bytes in size, where
- scaledHeight can be determined by calling
- scalingFactor. with one of the scaling factors returned from getScaled(jpegHeight)
- TJ.getScalingFactors() or by calling getScaledHeight(int, int). If the
- source image is a YUV image, then this buffer should normally be
- pitch * height bytes in size, where height is
- the height of the YUV image. However, the buffer may also be larger than
- the dimensions of the source image, in which case the x,
- y, and pitch parameters can be used to specify
- the region into which the source image should be decompressed/decoded.x - x offset (in pixels) of the region in the destination image into
+dstBuf - buffer that will receive the packed-pixel
+ decompressed/decoded image. If the source image is a JPEG image, then
+ this buffer should normally be pitch * scaledHeight bytes in
+ size, where scaledHeight can be determined by calling
+ scalingFactor.getScaled(jpegHeight)
+ with one of the scaling factors returned from TJ.getScalingFactors()
+ or by calling getScaledHeight(int, int). If the source image is a YUV
+ image, then this buffer should normally be pitch * height
+ bytes in size, where height is the height of the YUV image.
+ However, the buffer may also be larger than the dimensions of the source
+ image, in which case the x, y, and
+ pitch parameters can be used to specify the region into which
+ the source image should be decompressed/decoded.x - x offset (in pixels) of the region in the destination image into
which the source image should be decompressed/decodedy - y offset (in pixels) of the region in the destination image into
which the source image should be decompressed/decodeddesiredWidth - If the source image is a JPEG image, then this
specifies the desired width (in pixels) of the decompressed image (or
@@ -823,27 +834,29 @@ public void setJPEGImage(byte[] jpegImage,
than the source image dimensions, then TurboJPEG will use scaling in the
JPEG decompressor to generate the largest possible image that will fit
within the desired dimensions. Setting this to 0 is the same as setting
- it to the width of the JPEG image (in other words, the width will not be
+ it to the width of the JPEG image. (In other words, the width will not be
considered when determining the scaled image size.) This parameter is
- ignored if the source image is a YUV image.pitch - bytes per line of the destination image. Normally, this
- should be set to scaledWidth * TJ.pixelSize(pixelFormat) if
- the destination image is unpadded, but you can use this to, for instance,
- pad each line of the destination image to a 4-byte boundary or to
- decompress/decode the source image into a region of a larger image. NOTE:
- if the source image is a JPEG image, then scaledWidth can be
- determined by calling
- scalingFactor. or by calling getScaled(jpegWidth)
- getScaledWidth(int, int). If the source image is a
- YUV image, then scaledWidth is the width of the YUV image.
+ ignored if the source image is a YUV image.pitch - bytes per row in the destination image. Normally this should
+ be set to scaledWidth *
+ TJ.getPixelSize(pixelFormat),
+ if the destination image will be unpadded. However, you can use this to,
+ for instance, pad each row of the destination image to the nearest
+ multiple of 4 bytes or to decompress/decode the source image into a region
+ of a larger image. NOTE: if the source image is a JPEG image, then
+ scaledWidth can be determined by calling
+ scalingFactor.getScaled(jpegWidth)
+ or by calling getScaledWidth(int, int). If the source image is a YUV
+ image, then scaledWidth is the width of the YUV image.
Setting this parameter to 0 is the equivalent of setting it to
- scaledWidth * TJ.pixelSize(pixelFormat).desiredHeight - If the source image is a JPEG image, then this
+ scaledWidth *
+ TJ.getPixelSize(pixelFormat).desiredHeight - If the source image is a JPEG image, then this
specifies the desired height (in pixels) of the decompressed image (or
image region.) If the desired destination image dimensions are different
than the source image dimensions, then TurboJPEG will use scaling in the
JPEG decompressor to generate the largest possible image that will fit
within the desired dimensions. Setting this to 0 is the same as setting
- it to the height of the JPEG image (in other words, the height will not be
- considered when determining the scaled image size.) This parameter is
+ it to the height of the JPEG image. (In other words, the height will not
+ be considered when determining the scaled image size.) This parameter is
ignored if the source image is a YUV image.pixelFormat - pixel format of the decompressed/decoded image (one of
TJ.PF_*)flags - the bitwise OR of one or more of
TJ.FLAG_*
@@ -909,21 +923,21 @@ public void decompress(byte[] dstBuf,
int flags)
throws TJException
desiredWidth - see
decompress(byte[], int, int, int, int, int, int, int)
for descriptionpitch - see
@@ -894,7 +908,7 @@ public void decompress(byte[] dstBuf,
for descriptionpixelFormat - pixel format of the decompressed image (one of
TJ.PF_*)flags - the bitwise OR of one or more of
TJ.FLAG_*TJExceptionYUVImage instance. This method performs JPEG decompression
- but leaves out the color conversion step, so a planar YUV image is
- generated instead of an RGB or grayscale image. This method cannot be
- used to decompress JPEG source images with the CMYK or YCCK colorspace.
+ instance into a planar YUV image and store it in the given
+ YUVImage instance. This method performs JPEG decompression but
+ leaves out the color conversion step, so a planar YUV image is generated
+ instead of a packed-pixel image. This method cannot be used to decompress
+ JPEG source images with the CMYK or YCCK colorspace.
TJException (unless
TJ.FLAG_STOPONWARNING is specified.)dstImage - YUVImage instance that will receive the YUV planar
- image. The level of subsampling specified in this YUVImage
- instance must match that of the JPEG image, and the width and height
- specified in the YUVImage instance must match one of the
- scaled image sizes that TurboJPEG is capable of generating from the JPEG
- source image.flags - the bitwise OR of one or more of
+
@@ -957,32 +971,33 @@ public void decompressToYUV(byte[] dstBuf,
throws TJException
dstImage - YUVImage instance that will receive the planar YUV
+ decompressed image. The level of subsampling specified in this
+ YUVImage instance must match that of the JPEG image, and the width
+ and height specified in the YUVImage instance must match one of
+ the scaled image sizes that the decompressor is capable of generating from
+ the JPEG source image.flags - the bitwise OR of one or more of
TJ.FLAG_*TJExceptionYUVImage instance containing the decompressed image planes.
- This method performs JPEG decompression but leaves out the color
- conversion step, so a planar YUV image is generated instead of an RGB or
- grayscale image. This method cannot be used to decompress JPEG source
- images with the CMYK or YCCK colorspace.YUVImage instance containing the decompressed image planes. This
+ method performs JPEG decompression but leaves out the color conversion
+ step, so a planar YUV image is generated instead of a packed-pixel image.
+ This method cannot be used to decompress JPEG source images with the CMYK
+ or YCCK colorspace.
@@ -994,34 +1009,34 @@ public void decompressToYUV(byte[] dstBuf,
desiredWidth - desired width (in pixels) of the YUV image. If the
desired image dimensions are different than the dimensions of the JPEG
image being decompressed, then TurboJPEG will use scaling in the JPEG
decompressor to generate the largest possible image that will fit within
the desired dimensions. Setting this to 0 is the same as setting it to
- the width of the JPEG image (in other words, the width will not be
+ the width of the JPEG image. (In other words, the width will not be
considered when determining the scaled image size.)strides - an array of integers, each specifying the number of bytes
- per line in the corresponding plane of the output image. Setting the
- stride for any plane to 0 is the same as setting it to the scaled
- component width of the plane. If strides is NULL, then the
- strides for all planes will be set to their respective scaled component
- widths. You can adjust the strides in order to add an arbitrary amount of
- line padding to each plane.desiredHeight - desired height (in pixels) of the YUV image. If the
+ per row in the corresponding plane of the YUV image. Setting the stride
+ for any plane to 0 is the same as setting it to the scaled plane width
+ (see YUVImage.) If strides is null, then the strides
+ for all planes will be set to their respective scaled plane widths. You
+ can adjust the strides in order to add an arbitrary amount of row padding
+ to each plane.desiredHeight - desired height (in pixels) of the YUV image. If the
desired image dimensions are different than the dimensions of the JPEG
image being decompressed, then TurboJPEG will use scaling in the JPEG
decompressor to generate the largest possible image that will fit within
the desired dimensions. Setting this to 0 is the same as setting it to
- the height of the JPEG image (in other words, the height will not be
+ the height of the JPEG image. (In other words, the height will not be
considered when determining the scaled image size.)flags - the bitwise OR of one or more of
TJ.FLAG_*YUVImage instance containing the decompressed image
+ planesTJExceptiondecompressToYUV
public YUVImage decompressToYUV(int desiredWidth,
- int pad,
+ int align,
int desiredHeight,
int flags)
throws TJException
YUVImage instance containing the decompressed image. This
- method performs JPEG decompression but leaves out the color conversion
- step, so a planar YUV image is generated instead of an RGB or grayscale
- image. This method cannot be used to decompress JPEG source images with
- the CMYK or YCCK colorspace.YUVImage
+ instance containing the decompressed image. This method performs JPEG
+ decompression but leaves out the color conversion step, so a planar YUV
+ image is generated instead of a packed-pixel image. This method cannot be
+ used to decompress JPEG source images with the CMYK or YCCK colorspace.
desiredWidth - desired width (in pixels) of the YUV image. If the
desired image dimensions are different than the dimensions of the JPEG
image being decompressed, then TurboJPEG will use scaling in the JPEG
decompressor to generate the largest possible image that will fit within
the desired dimensions. Setting this to 0 is the same as setting it to
- the width of the JPEG image (in other words, the width will not be
- considered when determining the scaled image size.)pad - the width of each line in each plane of the YUV image will be
- padded to the nearest multiple of this number of bytes (must be a power of
- 2.)desiredHeight - desired height (in pixels) of the YUV image. If the
+ the width of the JPEG image. (In other words, the width will not be
+ considered when determining the scaled image size.)align - row alignment (in bytes) of the YUV image (must be a power of
+ 2.) Setting this parameter to n will cause each row in each plane of the
+ YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.)desiredHeight - desired height (in pixels) of the YUV image. If the
desired image dimensions are different than the dimensions of the JPEG
image being decompressed, then TurboJPEG will use scaling in the JPEG
decompressor to generate the largest possible image that will fit within
the desired dimensions. Setting this to 0 is the same as setting it to
- the height of the JPEG image (in other words, the height will not be
+ the height of the JPEG image. (In other words, the height will not be
considered when determining the scaled image size.)flags - the bitwise OR of one or more of
TJ.FLAG_*YUVImage instance containing the unified planar YUV
+ decompressed imageTJExceptionTJException (unless
TJ.FLAG_STOPONWARNING is specified.)
+ dstBuf - buffer that will receive the decompressed/decoded image.
- If the source image is a JPEG image, then this buffer should normally be
- stride * scaledHeight pixels in size, where
- scaledHeight can be determined by calling
- scalingFactor. with one of the scaling factors returned from getScaled(jpegHeight)
- TJ.getScalingFactors() or by calling getScaledHeight(int, int). If the
- source image is a YUV image, then this buffer should normally be
- stride * height pixels in size, where height is
- the height of the YUV image. However, the buffer may also be larger than
- the dimensions of the JPEG image, in which case the x,
- y, and stride parameters can be used to specify
- the region into which the source image should be decompressed.x - x offset (in pixels) of the region in the destination image into
+dstBuf - buffer that will receive the packed-pixel
+ decompressed/decoded image. If the source image is a JPEG image, then
+ this buffer should normally be stride * scaledHeight pixels
+ in size, where scaledHeight can be determined by calling
+ scalingFactor.getScaled(jpegHeight)
+ with one of the scaling factors returned from TJ.getScalingFactors()
+ or by calling getScaledHeight(int, int). If the source image is a YUV
+ image, then this buffer should normally be stride * height
+ pixels in size, where height is the height of the YUV image.
+ However, the buffer may also be larger than the dimensions of the JPEG
+ image, in which case the x, y, and
+ stride parameters can be used to specify the region into
+ which the source image should be decompressed.x - x offset (in pixels) of the region in the destination image into
which the source image should be decompressed/decodedy - y offset (in pixels) of the region in the destination image into
which the source image should be decompressed/decodeddesiredWidth - If the source image is a JPEG image, then this
specifies the desired width (in pixels) of the decompressed image (or
@@ -1081,16 +1097,16 @@ public byte[] decompressToYUV(int flags)
than the source image dimensions, then TurboJPEG will use scaling in the
JPEG decompressor to generate the largest possible image that will fit
within the desired dimensions. Setting this to 0 is the same as setting
- it to the width of the JPEG image (in other words, the width will not be
+ it to the width of the JPEG image. (In other words, the width will not be
considered when determining the scaled image size.) This parameter is
- ignored if the source image is a YUV image.stride - pixels per line of the destination image. Normally, this
+ ignored if the source image is a YUV image.stride - pixels per row in the destination image. Normally this
should be set to scaledWidth, but you can use this to, for
instance, decompress the JPEG image into a region of a larger image.
NOTE: if the source image is a JPEG image, then scaledWidth
- can be determined by calling
- scalingFactor. or by calling getScaled(jpegWidth)
- getScaledWidth(int, int). If the source image is a
- YUV image, then scaledWidth is the width of the YUV image.
+ can be determined by calling
+ scalingFactor.getScaled(jpegWidth)
+ or by calling getScaledWidth(int, int). If the source image is a YUV
+ image, then scaledWidth is the width of the YUV image.
Setting this parameter to 0 is the equivalent of setting it to
scaledWidth.desiredHeight - If the source image is a JPEG image, then this
specifies the desired height (in pixels) of the decompressed image (or
@@ -1098,8 +1114,8 @@ public byte[] decompressToYUV(int flags)
than the source image dimensions, then TurboJPEG will use scaling in the
JPEG decompressor to generate the largest possible image that will fit
within the desired dimensions. Setting this to 0 is the same as setting
- it to the height of the JPEG image (in other words, the height will not be
- considered when determining the scaled image size.) This parameter is
+ it to the height of the JPEG image. (In other words, the height will not
+ be considered when determining the scaled image size.) This parameter is
ignored if the source image is a YUV image.pixelFormat - pixel format of the decompressed image (one of
TJ.PF_*)flags - the bitwise OR of one or more of
TJ.FLAG_*public void decompress(java.awt.image.BufferedImage dstImage,
int flags)
throws TJException
-BufferedImage instance.
+BufferedImage
+ instance.
TJException (unless
TJ.FLAG_STOPONWARNING is specified.)
@@ -1146,9 +1163,10 @@ public byte[] decompressToYUV(int flags)
int bufferedImageType,
int flags)
throws TJException
-dstImage - a BufferedImage instance that will receive
- the decompressed/decoded image. If the source image is a JPEG image, then
- the width and height of the BufferedImage instance must match
- one of the scaled image sizes that TurboJPEG is capable of generating from
- the JPEG image. If the source image is a YUV image, then the width and
- height of the BufferedImage instance must match the width and
- height of the YUV image.flags - the bitwise OR of one or more of
+ the packed-pixel decompressed/decoded image. If the source image is a
+ JPEG image, then the width and height of the BufferedImage
+ instance must match one of the scaled image sizes that the decompressor is
+ capable of generating from the JPEG image. If the source image is a YUV
+ image, then the width and height of the BufferedImage
+ instance must match the width and height of the YUV image.flags - the bitwise OR of one or more of
TJ.FLAG_*TJExceptionBufferedImage
- instance containing the decompressed/decoded image.BufferedImage instance containing the packed-pixel
+ decompressed/decoded image.
diff --git a/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html b/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html
index 5f22691e..e528d791 100644
--- a/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html
+++ b/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html
@@ -167,7 +167,7 @@ extends java.awt.Rectangle
desiredWidth - see
decompress(byte[], int, int, int, int, int, int, int) for
descriptiondesiredHeight - see
@@ -1157,7 +1175,7 @@ public byte[] decompressToYUV(int flags)
instance that will be created (for instance,
BufferedImage.TYPE_INT_RGB)flags - the bitwise OR of one or more of
TJ.FLAG_*BufferedImage instance containing the
+BufferedImage instance containing the packed-pixel
decompressed/decoded image.TJException
intop
-OP_*)OP_*)
@@ -223,7 +223,7 @@ extends java.awt.Rectangle
static intOPT_COPYNONE
TJTransformer.transform() from copying any extra markers (including EXIF
- and ICC profile data) from the source image to the output image.
@@ -235,8 +235,8 @@ extends java.awt.Rectangle
static intOPT_GRAY
-
@@ -256,7 +256,7 @@ extends java.awt.Rectangle
@@ -270,7 +270,8 @@ extends java.awt.Rectangle
static intOPT_PROGRESSIVE
-
@@ -509,7 +510,7 @@ extends java.awt.Rectangle
the level of chrominance subsampling used. If the image's width or height
is not evenly divisible by the MCU block size (see intoptions
-OPT_*)OPT_*)TJ.getMCUWidth(int)
and TJ.getMCUHeight(int)), then there will be partial MCU blocks on the
- right and/or bottom edges. It is not possible to move these partial MCU
+ right and/or bottom edges. It is not possible to move these partial MCU
blocks to the top or left of the image, so any transform that would
require that is "imperfect." If this option is not specified, then any
partial MCU blocks that cannot be transformed will be left in place, which
@@ -547,8 +548,8 @@ extends java.awt.Rectangle
OPT_GRAY
public static final int OPT_GRAY
-OPT_PROGRESSIVE
public static final int OPT_PROGRESSIVE
-OPT_COPYNONE
public static final int OPT_COPYNONE
TJTransformer.transform() from copying any extra markers (including EXIF
- and ICC profile data) from the source image to the output image.
@@ -600,7 +600,7 @@ extends java.awt.Rectangle
op
public int op
-OP_*)OP_*)options
public int options
-OPT_*)OPT_*)x).h - the height of the cropping region. Setting this to 0 is the
equivalent of setting it to (height of the source JPEG image -
- y).op - one of the transform operations (OP_*)options - the bitwise OR of one or more of the transform options
- (OPT_*)cf - an instance of an object that implements the TJCustomFilter interface, or null if no custom filter is neededy).op - one of the transform operations (OP_*)options - the bitwise OR of one or more of the transform options
+ (OPT_*)cf - an instance of an object that implements the TJCustomFilter interface, or null if no custom filter is needed
+ detail.r - a Rectangle instance that specifies the cropping
region. See TJTransform(int, int, int, int, int, int, TJCustomFilter) for more
- detail.op - one of the transform operations (OP_*)options - the bitwise OR of one or more of the transform options
- (OPT_*)cf - an instance of an object that implements the TJCustomFilter interface, or null if no custom filter is neededop - one of the transform operations (OP_*)options - the bitwise OR of one or more of the transform options
+ (OPT_*)cf - an instance of an object that implements the TJCustomFilter interface, or null if no custom filter is neededTJTransformer(byte[] jpegImage)
jpegImage with the newly created instance.jpegImage with the newly created
+ instance.
@@ -178,7 +179,7 @@ extends TJTransformer(byte[] jpegImage,
int imageSize)
imageSize bytes stored in
+ source image of length imageSize bytes stored in
jpegImage with the newly created instance.int[]
getTransformedSizes()
@@ -186,18 +187,18 @@ extends
transform(byte[][] dstBufs,
TJTransform[] transforms,
int flags)
-
@@ -251,9 +252,11 @@ extends public TJTransformer(byte[] jpegImage)
throws TJException
TJDecompressor[]transform(TJTransform[] transforms,
int flags)
-TJDecompressor instances, each of
- which has a transformed JPEG image associated with it.TJDecompressor
+ instances, each of which has a transformed JPEG image associated with it.jpegImage with the newly created instance.jpegImage - JPEG image buffer (size of the JPEG image is assumed to
- be the length of the array.) This buffer is not modified.jpegImage with the newly created
+ instance.
@@ -268,9 +271,10 @@ extends TJException
jpegImage - buffer containing the JPEG source image to transform.
+ (The size of the JPEG image is assumed to be the length of the array.)
+ This buffer is not modified.TJExceptionimageSize bytes stored in
+ source image of length imageSize bytes stored in
jpegImage with the newly created instance.jpegImage - JPEG image buffer. This buffer is not modified.imageSize - size of the JPEG image (in bytes)
@@ -293,25 +297,26 @@ extends TJTransform[] transforms,
int flags)
throws TJException
-jpegImage - buffer containing the JPEG source image to transform.
+ This buffer is not modified.imageSize - size of the JPEG source image (in bytes)TJExceptiondstBufs - an array of image buffers. dstbufs[i] will
- receive a JPEG image that has been transformed using the parameters in
- transforms[i]. Use TJ.bufSize(int, int, int) to determine the
- maximum size for each buffer based on the transformed or cropped width and
- height and the level of subsampling used in the source image.transforms - an array of TJTransform instances, each of
+
@@ -326,12 +331,12 @@ extends public TJDecompressor[] transform(TJTransform[] transforms,
int flags)
throws TJException
-dstBufs - an array of JPEG destination buffers.
+ dstbufs[i] will receive a JPEG image that has been
+ transformed using the parameters in transforms[i]. Use
+ TJ.bufSize(int, int, int) to determine the maximum size for each buffer based on
+ the transformed or cropped width and height and the level of subsampling
+ used in the source image.transforms - an array of TJTransform instances, each of
which specifies the transform parameters and/or cropping region for the
- corresponding transformed output imageflags - the bitwise OR of one or more of
+ corresponding transformed JPEG imageflags - the bitwise OR of one or more of
TJ.FLAG_*TJExceptionTJDecompressor instances, each of
- which has a transformed JPEG image associated with it.TJDecompressor
+ instances, each of which has a transformed JPEG image associated with it.transforms - an array of TJTransform instances, each of
which specifies the transform parameters and/or cropping region for the
- corresponding transformed output imageflags - the bitwise OR of one or more of
+ corresponding transformed JPEG imageflags - the bitwise OR of one or more of
TJ.FLAG_*TJDecompressor instances, each of
which has a transformed JPEG image associated with it.public int[] getTransformedSizes()
+ (in bytes) generated by the most recent transform operation.
public class YUVImage
extends java.lang.Object
-YUVImage instance
@@ -106,30 +106,32 @@ extends java.lang.Object
operations and as the source image for compress-from-YUV and YUV decode
operations.
-protected int
+yuvHeight yuvAlign
-
-protected int[]
+yuvOffsets
+protected intyuvHeight
-
-protected int
+yuvPad
+protected int[]yuvOffsets
@@ -208,10 +210,10 @@ extends java.lang.Object
protected byte[][]
@@ -226,11 +228,11 @@ extends java.lang.Object
YUVImage(byte[] yuvImage,
int width,
- int pad,
+ int align,
int height,
int subsamp)
-YUVImage instance from an existing unified image
+YUVImage instance from an existing unified
buffer.
@@ -251,8 +253,8 @@ extends java.lang.Object
YUVImage(int width,
- int pad,
+ int align,
int height,
int subsamp)
-YUVImage instance backed by a unified image
- buffer, and allocate memory for the image buffer.YUVImage instance backed by a unified buffer,
+ and allocate memory for the buffer.
byte[]getBuf()
-
@@ -271,7 +273,7 @@ extends java.lang.Object
@@ -284,14 +286,14 @@ extends java.lang.Object
intgetPad()
-
intgetSize()
-
int[]getStrides()
-
@@ -321,10 +323,10 @@ extends java.lang.Object
@@ -385,13 +387,13 @@ extends java.lang.Object
voidsetBuf(byte[] yuvImage,
int width,
- int pad,
+ int align,
int height,
int subsamp)
-YUVImage instance.YUVImage instance.protected int[] yuvStrides
-
+
@@ -442,7 +444,7 @@ extends java.lang.Object
yuvPad
-protected int yuvPad
+yuvAlign
+protected int yuvAlign
YUVImage instance backed by separate image
planes, and allocate memory for the image planes.width - width (in pixels) of the YUV imagestrides - an array of integers, each specifying the number of bytes
- per line in the corresponding plane of the YUV image. Setting the stride
+ per row in the corresponding plane of the YUV image. Setting the stride
for any plane to 0 is the same as setting it to the plane width (see
above.) If strides is null, then the
strides for all planes will be set to their respective plane widths. When
@@ -458,13 +460,15 @@ extends java.lang.Object
YUVImage
public YUVImage(int width,
- int pad,
+ int align,
int height,
int subsamp)
-YUVImage instance backed by a unified image
- buffer, and allocate memory for the image buffer.width - width (in pixels) of the YUV imagepad - Each line of each plane in the YUV image buffer will be padded
- to this number of bytes (must be a power of 2.)height - height (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling to be used in the YUV
+YUVImage instance backed by a unified buffer,
+ and allocate memory for the buffer.width - width (in pixels) of the YUV imagealign - row alignment (in bytes) of the YUV image (must be a power of
+ 2.) Setting this parameter to n specifies that each row in each plane of
+ the YUV image will be padded to the nearest multiple of n bytes
+ (1 = unpadded.)height - height (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling to be used in the YUV
image (one of TJ.SAMP_*)planes - an array of buffers representing the Y, U (Cb), and V (Cr)
image planes (or just the Y plane, if the image is grayscale.) These
planes can be contiguous or non-contiguous in memory. Plane
- i should be at least offsets[i] +
-
+ TJ.planeSizeYUV(i, width, strides[i], height, subsamp)i should be at least offsets[i] +
+ TJ.planeSizeYUV(i, width, strides[i], height, subsamp)
bytes in size.offsets - If this YUVImage instance represents a
subregion of a larger image, then offsets[i] specifies the
offset (in bytes) of the subregion within plane i of the
larger image. Setting this to null is the same as setting the offsets for
all planes to 0.width - width (in pixels) of the new YUV image (or subregion)strides - an array of integers, each specifying the number of bytes
- per line in the corresponding plane of the YUV image. Setting the stride
+ per row in the corresponding plane of the YUV image. Setting the stride
for any plane to 0 is the same as setting it to the plane width (see
above.) If strides is null, then the
strides for all planes will be set to their respective plane widths. You
- can adjust the strides in order to add an arbitrary amount of line padding
+ can adjust the strides in order to add an arbitrary amount of row padding
to each plane or to specify that this YUVImage instance is a
subregion of a larger image (in which case, strides[i] should
be set to the plane width of plane i in the larger image.)height - height (in pixels) of the new YUV image (or subregion)subsamp - the level of chrominance subsampling used in the YUV
@@ -511,18 +515,19 @@ extends java.lang.Object
YUVImage
public YUVImage(byte[] yuvImage,
int width,
- int pad,
+ int align,
int height,
int subsamp)
-YUVImage instance from an existing unified image
+YUVImage instance from an existing unified
buffer.yuvImage - image buffer that contains or will contain YUV planar
- image data. Use TJ.bufSizeYUV(int, int, int, int) to determine the minimum size for
- this buffer. The Y, U (Cb), and V (Cr) image planes are stored
- sequentially in the buffer (see above for a description
- of the image format.)width - width (in pixels) of the YUV imagepad - the line padding used in the YUV image buffer. For
- instance, if each line in each plane of the buffer is padded to the
- nearest multiple of 4 bytes, then pad should be set to 4.height - height (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling used in the YUV
+
@@ -550,19 +555,19 @@ extends java.lang.Object
yuvImage - buffer that contains or will receive a unified planar YUV
+ image. Use TJ.bufSizeYUV(int, int, int, int) to determine the minimum size for this
+ buffer. The Y, U (Cb), and V (Cr) image planes are stored sequentially in
+ the buffer. (See above for a description of the image
+ format.)width - width (in pixels) of the YUV imagealign - row alignment (in bytes) of the YUV image (must be a power of
+ 2.) Setting this parameter to n specifies that each row in each plane of
+ the YUV image will be padded to the nearest multiple of n bytes
+ (1 = unpadded.)height - height (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling used in the YUV
image (one of TJ.SAMP_*)
@@ -576,17 +581,18 @@ extends java.lang.Object
planes - an array of buffers representing the Y, U (Cb), and V (Cr)
image planes (or just the Y plane, if the image is grayscale.) These
planes can be contiguous or non-contiguous in memory. Plane
- i should be at least offsets[i] +
-
+ TJ.planeSizeYUV(i, width, strides[i], height, subsamp)i should be at least offsets[i] +
+ TJ.planeSizeYUV(i, width, strides[i], height, subsamp)
bytes in size.offsets - If this YUVImage instance represents a
subregion of a larger image, then offsets[i] specifies the
offset (in bytes) of the subregion within plane i of the
larger image. Setting this to null is the same as setting the offsets for
all planes to 0.width - width (in pixels) of the YUV image (or subregion)strides - an array of integers, each specifying the number of bytes
- per line in the corresponding plane of the YUV image. Setting the stride
+ per row in the corresponding plane of the YUV image. Setting the stride
for any plane to 0 is the same as setting it to the plane width (see
above.) If strides is null, then the
strides for all planes will be set to their respective plane widths. You
- can adjust the strides in order to add an arbitrary amount of line padding
- to each plane or to specify that this YUVImage image is a
+ can adjust the strides in order to add an arbitrary amount of row padding
+ to each plane or to specify that this YUVImage instance is a
subregion of a larger image (in which case, strides[i] should
be set to the plane width of plane i in the larger image.)height - height (in pixels) of the YUV image (or subregion)subsamp - the level of chrominance subsampling used in the YUV
image (one of TJ.SAMP_*)setBuf
public void setBuf(byte[] yuvImage,
int width,
- int pad,
+ int align,
int height,
int subsamp)
-YUVImage instance.yuvImage - image buffer that contains or will contain YUV planar
- image data. Use TJ.bufSizeYUV(int, int, int, int) to determine the minimum size for
- this buffer. The Y, U (Cb), and V (Cr) image planes are stored
- sequentially in the buffer (see above for a description
- of the image format.)width - width (in pixels) of the YUV imagepad - the line padding used in the YUV image buffer. For
- instance, if each line in each plane of the buffer is padded to the
- nearest multiple of 4 bytes, then pad should be set to 4.height - height (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling used in the YUV
+YUVImage instance.
@@ -619,9 +625,9 @@ extends java.lang.Object
yuvImage - buffer that contains or will receive a unified planar YUV
+ image. Use TJ.bufSizeYUV(int, int, int, int) to determine the minimum size for this
+ buffer. The Y, U (Cb), and V (Cr) image planes are stored sequentially in
+ the buffer. (See above for a description of the image
+ format.)width - width (in pixels) of the YUV imagealign - row alignment (in bytes) of the YUV image (must be a power of
+ 2.) Setting this parameter to n specifies that each row in each plane of
+ the YUV image will be padded to the nearest multiple of n bytes
+ (1 = unpadded.)height - height (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling used in the YUV
image (one of TJ.SAMP_*)getPad
public int getPad()
-
+
@@ -631,8 +637,8 @@ extends java.lang.Object
getStrides
public int[] getStrides()
-
+getBuf
public byte[] getBuf()
-
+getSize
public int getSize()
-
+
diff --git a/java/doc/serialized-form.html b/java/doc/serialized-form.html
index 45bbc862..e123f318 100644
--- a/java/doc/serialized-form.html
+++ b/java/doc/serialized-form.html
@@ -109,12 +109,13 @@
YUVImage
-
op
int op
-OP_*)OP_*)options
int options
-OPT_*)OPT_*)cf
diff --git a/java/org/libjpegturbo/turbojpeg/TJ.java b/java/org/libjpegturbo/turbojpeg/TJ.java
index d791e001..3857087e 100644
--- a/java/org/libjpegturbo/turbojpeg/TJ.java
+++ b/java/org/libjpegturbo/turbojpeg/TJ.java
@@ -1,6 +1,6 @@
/*
- * Copyright (C)2011-2013, 2017-2018, 2020-2021 D. R. Commander.
- * All Rights Reserved.
+ * Copyright (C)2011-2013, 2017-2018, 2020-2021, 2023 D. R. Commander.
+ * All Rights Reserved.
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -85,7 +85,7 @@ public final class TJ {
* subsampling.
*
* @param subsamp the level of chrominance subsampling (one of
- * SAMP_*)
+ * {@link #SAMP_444 SAMP_*})
*
* @return the MCU block width for the given level of chrominance
* subsampling.
@@ -105,7 +105,7 @@ public final class TJ {
* subsampling.
*
* @param subsamp the level of chrominance subsampling (one of
- * SAMP_*)
+ * {@link #SAMP_444 SAMP_*})
*
* @return the MCU block height for the given level of chrominance
* subsampling.
@@ -205,8 +205,8 @@ public final class TJ {
* vice versa, but the mapping is typically not 1:1 or reversible, nor can it
* be defined with a simple formula. Thus, such a conversion is out of scope
* for a codec library. However, the TurboJPEG API allows for compressing
- * CMYK pixels into a YCCK JPEG image (see {@link #CS_YCCK}) and
- * decompressing YCCK JPEG images into CMYK pixels.
+ * packed-pixel CMYK images into YCCK JPEG images (see {@link #CS_YCCK}) and
+ * decompressing YCCK JPEG images into packed-pixel CMYK images.
*/
public static final int PF_CMYK = 11;
@@ -214,7 +214,7 @@ public final class TJ {
/**
* Returns the pixel size (in bytes) for the given pixel format.
*
- * @param pixelFormat the pixel format (one of PF_*)
+ * @param pixelFormat the pixel format (one of {@link #PF_RGB PF_*})
*
* @return the pixel size (in bytes) for the given pixel format.
*/
@@ -235,7 +235,7 @@ public final class TJ {
* then the red component will be
* pixel[TJ.getRedOffset(TJ.PF_BGRX)].
*
- * @param pixelFormat the pixel format (one of PF_*)
+ * @param pixelFormat the pixel format (one of {@link #PF_RGB PF_*})
*
* @return the red offset for the given pixel format, or -1 if the pixel
* format does not have a red component.
@@ -257,7 +257,7 @@ public final class TJ {
* then the green component will be
* pixel[TJ.getGreenOffset(TJ.PF_BGRX)].
*
- * @param pixelFormat the pixel format (one of PF_*)
+ * @param pixelFormat the pixel format (one of {@link #PF_RGB PF_*})
*
* @return the green offset for the given pixel format, or -1 if the pixel
* format does not have a green component.
@@ -279,7 +279,7 @@ public final class TJ {
* then the blue component will be
* pixel[TJ.getBlueOffset(TJ.PF_BGRX)].
*
- * @param pixelFormat the pixel format (one of PF_*)
+ * @param pixelFormat the pixel format (one of {@link #PF_RGB PF_*})
*
* @return the blue offset for the given pixel format, or -1 if the pixel
* format does not have a blue component.
@@ -301,7 +301,7 @@ public final class TJ {
* then the alpha component will be
* pixel[TJ.getAlphaOffset(TJ.PF_BGRA)].
*
- * @param pixelFormat the pixel format (one of PF_*)
+ * @param pixelFormat the pixel format (one of {@link #PF_RGB PF_*})
*
* @return the alpha offset for the given pixel format, or -1 if the pixel
* format does not have a alpha component.
@@ -324,8 +324,9 @@ public final class TJ {
* RGB colorspace. When compressing the JPEG image, the R, G, and B
* components in the source image are reordered into image planes, but no
* colorspace conversion or subsampling is performed. RGB JPEG images can be
- * decompressed to any of the extended RGB pixel formats or grayscale, but
- * they cannot be decompressed to YUV images.
+ * decompressed to packed-pixel images with any of the extended RGB or
+ * grayscale pixel formats, but they cannot be decompressed to planar YUV
+ * images.
*/
public static final int CS_RGB = 0;
/**
@@ -339,26 +340,28 @@ public final class TJ {
* transformation allowed the same signal to drive both black & white and
* color televisions, but JPEG images use YCbCr primarily because it allows
* the color data to be optionally subsampled for the purposes of reducing
- * bandwidth or disk space. YCbCr is the most common JPEG colorspace, and
- * YCbCr JPEG images can be compressed from and decompressed to any of the
- * extended RGB pixel formats or grayscale, or they can be decompressed to
- * YUV planar images.
+ * network or disk usage. YCbCr is the most common JPEG colorspace, and
+ * YCbCr JPEG images can be compressed from and decompressed to packed-pixel
+ * images with any of the extended RGB or grayscale pixel formats. YCbCr
+ * JPEG images can also be compressed from and decompressed to planar YUV
+ * images.
*/
@SuppressWarnings("checkstyle:ConstantName")
public static final int CS_YCbCr = 1;
/**
* Grayscale colorspace. The JPEG image retains only the luminance data (Y
* component), and any color data from the source image is discarded.
- * Grayscale JPEG images can be compressed from and decompressed to any of
- * the extended RGB pixel formats or grayscale, or they can be decompressed
- * to YUV planar images.
+ * Grayscale JPEG images can be compressed from and decompressed to
+ * packed-pixel images with any of the extended RGB or grayscale pixel
+ * formats, or they can be compressed from and decompressed to planar YUV
+ * images.
*/
public static final int CS_GRAY = 2;
/**
* CMYK colorspace. When compressing the JPEG image, the C, M, Y, and K
* components in the source image are reordered into image planes, but no
* colorspace conversion or subsampling is performed. CMYK JPEG images can
- * only be decompressed to CMYK pixels.
+ * only be decompressed to packed-pixel images with the CMYK pixel format.
*/
public static final int CS_CMYK = 3;
/**
@@ -368,14 +371,14 @@ public final class TJ {
* reversibly transformed into YCCK, and as with YCbCr, the chrominance
* components in the YCCK pixels can be subsampled without incurring major
* perceptual loss. YCCK JPEG images can only be compressed from and
- * decompressed to CMYK pixels.
+ * decompressed to packed-pixel images with the CMYK pixel format.
*/
public static final int CS_YCCK = 4;
/**
- * The uncompressed source/destination image is stored in bottom-up (Windows,
- * OpenGL) order, not top-down (X11) order.
+ * Rows in the packed-pixel source/destination image are stored in bottom-up
+ * (Windows, OpenGL) order rather than in top-down (X11) order.
*/
public static final int FLAG_BOTTOMUP = 2;
@@ -394,41 +397,39 @@ public final class TJ {
/**
* When decompressing an image that was compressed using chrominance
- * subsampling, use the fastest chrominance upsampling algorithm available in
- * the underlying codec. The default is to use smooth upsampling, which
- * creates a smooth transition between neighboring chrominance components in
- * order to reduce upsampling artifacts in the decompressed image.
+ * subsampling, use the fastest chrominance upsampling algorithm available.
+ * The default is to use smooth upsampling, which 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;
/**
- * Use the fastest DCT/IDCT algorithm available in the underlying codec. The
- * default if this flag is not specified is implementation-specific. For
- * example, the implementation of TurboJPEG for libjpeg[-turbo] uses the fast
+ * Use the fastest DCT/IDCT algorithm available. The default if this flag is
+ * not specified is implementation-specific. For example, the implementation
+ * of the TurboJPEG API in libjpeg-turbo uses the fast algorithm by default
+ * when compressing, because this has been shown to have 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;
+ /**
+ * Use the most accurate DCT/IDCT algorithm available. The default if this
+ * flag is not specified is implementation-specific. For example, the
+ * implementation of the TurboJPEG API in libjpeg-turbo uses the fast
* algorithm by default when compressing, because this has been shown to have
* 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;
- /**
- * Use the most accurate DCT/IDCT algorithm available in the underlying
- * codec. The default if this flag is not specified is
- * implementation-specific. For example, the implementation of TurboJPEG for
- * libjpeg[-turbo] uses the fast algorithm by default when compressing,
- * because this has been shown to have 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_ACCURATEDCT = 4096;
/**
* 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.
+ * operation if a warning (non-fatal error) occurs. The default behavior is
+ * to allow the operation to complete unless a fatal error is encountered.
* srcImage with the newly created
* instance.
*
@@ -85,7 +86,7 @@ public class TJCompressor implements Closeable {
}
/**
- * Create a TurboJPEG compressor instance and associate the uncompressed
+ * Create a TurboJPEG compressor instance and associate the packed-pixel
* source image stored in srcImage with the newly created
* instance.
*
@@ -110,11 +111,11 @@ public class TJCompressor implements Closeable {
}
/**
- * Associate an uncompressed RGB, grayscale, or CMYK source image with this
+ * Associate a packed-pixel RGB, grayscale, or CMYK source image with this
* compressor instance.
*
- * @param srcImage image buffer containing RGB, grayscale, or CMYK pixels to
- * be compressed or encoded. This buffer is not modified.
+ * @param srcImage buffer containing a packed-pixel RGB, grayscale, or CMYK
+ * source image to be compressed or encoded. This buffer is not modified.
*
* @param x x offset (in pixels) of the region in the source image from which
* the JPEG or YUV image should be compressed/encoded
@@ -125,14 +126,16 @@ public class TJCompressor implements Closeable {
* @param width width (in pixels) of the region in the source image from
* which the JPEG or YUV image should be compressed/encoded
*
- * @param pitch bytes per line of the source image. Normally, this should be
- * width * TJ.pixelSize(pixelFormat) if the source image is
- * unpadded, but you can use this parameter to, for instance, specify that
- * the scanlines in the source image are padded to a 4-byte boundary or to
- * compress/encode a JPEG or YUV image from a region of a larger source
- * image. You can also be clever and use this parameter to skip lines, etc.
- * Setting this parameter to 0 is the equivalent of setting it to
- * width * TJ.pixelSize(pixelFormat).
+ * @param pitch bytes per row in the source image. Normally this should be
+ * width *
+ * {@link TJ#getPixelSize TJ.getPixelSize}(pixelFormat),
+ * if the source image is unpadded. However, you can use this parameter to,
+ * for instance, specify that the rows in the source image are padded to the
+ * nearest multiple of 4 bytes or to compress/encode a JPEG or YUV image from
+ * a region of a larger source image. You can also be clever and use this
+ * parameter to skip rows, etc. Setting this parameter to 0 is the
+ * equivalent of setting it to width *
+ * {@link TJ#getPixelSize TJ.getPixelSize}(pixelFormat).
*
* @param height height (in pixels) of the region in the source image from
* which the JPEG or YUV image should be compressed/encoded
@@ -174,11 +177,12 @@ public class TJCompressor implements Closeable {
}
/**
- * Associate an uncompressed RGB or grayscale source image with this
+ * Associate a packed-pixel RGB or grayscale source image with this
* compressor instance.
*
- * @param srcImage a BufferedImage instance containing RGB or
- * grayscale pixels to be compressed or encoded. This image is not modified.
+ * @param srcImage a BufferedImage instance containing a
+ * packed-pixel RGB or grayscale source image to be compressed or encoded.
+ * This image is not modified.
*
* @param x x offset (in pixels) of the region in the source image from which
* the JPEG or YUV image should be compressed/encoded
@@ -260,11 +264,10 @@ public class TJCompressor implements Closeable {
}
/**
- * Associate an uncompressed YUV planar source image with this compressor
- * instance.
+ * Associate a planar YUV source image with this compressor instance.
*
- * @param srcImage YUV planar image to be compressed. This image is not
- * modified.
+ * @param srcImage planar YUV source image to be compressed. This image is
+ * not modified.
*/
public void setSourceImage(YUVImage srcImage) throws TJException {
if (handle == 0) init();
@@ -281,16 +284,16 @@ public class TJCompressor implements Closeable {
* {@link TJ#CS_YCbCr}) or from CMYK to YCCK (see {@link TJ#CS_YCCK}) as part
* of the JPEG compression process, some of the Cb and Cr (chrominance)
* components can be discarded or averaged together to produce a smaller
- * image with little perceptible loss of image clarity (the human eye is more
- * sensitive to small changes in brightness than to small changes in color.)
- * This is called "chrominance subsampling".
+ * image with little perceptible loss of image clarity. (The human eye is
+ * more sensitive to small changes in brightness than to small changes in
+ * color.) This is called "chrominance subsampling".
* YUVImage instance. This method uses the accelerated color
- * conversion routines in TurboJPEG's underlying codec but does not execute
- * any of the other steps in the JPEG compression process. Encoding
- * CMYK source images to YUV is not supported.
+ * Encode the packed-pixel source image associated with this compressor
+ * instance into a planar YUV image and store it in the given
+ * {@link YUVImage} instance. This method performs color conversion (which
+ * is accelerated in the libjpeg-turbo implementation) but does not execute
+ * any of the other steps in the JPEG compression process. Encoding CMYK
+ * source images into YUV images is not supported.
*
- * @param dstImage {@link YUVImage} instance that will receive the YUV planar
+ * @param dstImage {@link YUVImage} instance that will receive the planar YUV
* image
*
* @param flags the bitwise OR of one or more of
@@ -469,52 +473,54 @@ public class TJCompressor implements Closeable {
}
/**
- * Encode the uncompressed source image associated with this compressor
- * instance into a unified YUV planar image buffer and return a
- * YUVImage instance containing the encoded image. This method
- * uses the accelerated color conversion routines in TurboJPEG's underlying
- * codec but does not execute any of the other steps in the JPEG compression
- * process. Encoding CMYK source images to YUV is not supported.
+ * Encode the packed-pixel source image associated with this compressor
+ * instance into a unified planar YUV image and return a {@link YUVImage}
+ * instance containing the encoded image. This method performs color
+ * conversion (which is accelerated in the libjpeg-turbo implementation) but
+ * does not execute any of the other steps in the JPEG compression process.
+ * Encoding CMYK source images into YUV images is not supported.
*
- * @param pad the width of each line in each plane of the YUV image will be
- * padded to the nearest multiple of this number of bytes (must be a power of
- * 2.)
+ * @param align row alignment (in bytes) of the YUV image (must be a power of
+ * 2.) Setting this parameter to n will cause each row in each plane of the
+ * YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.)
*
* @param flags the bitwise OR of one or more of
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
*
- * @return a YUV planar image.
+ * @return a {@link YUVImage} instance containing the unified planar YUV
+ * encoded image
*/
- public YUVImage encodeYUV(int pad, int flags) throws TJException {
+ public YUVImage encodeYUV(int align, int flags) throws TJException {
checkSourceImage();
checkSubsampling();
- if (pad < 1 || ((pad & (pad - 1)) != 0))
+ if (align < 1 || ((align & (align - 1)) != 0))
throw new IllegalStateException("Invalid argument in encodeYUV()");
- YUVImage dstYUVImage = new YUVImage(srcWidth, pad, srcHeight, subsamp);
+ YUVImage dstYUVImage = new YUVImage(srcWidth, align, srcHeight, subsamp);
encodeYUV(dstYUVImage, flags);
return dstYUVImage;
}
/**
- * Encode the uncompressed source image associated with this compressor
+ * Encode the packed-pixel source image associated with this compressor
* instance into separate Y, U (Cb), and V (Cr) image planes and return a
- * YUVImage instance containing the encoded image planes. This
- * method uses the accelerated color conversion routines in TurboJPEG's
- * underlying codec but does not execute any of the other steps in the JPEG
- * compression process. Encoding CMYK source images to YUV is not supported.
+ * {@link YUVImage} instance containing the encoded image planes. This
+ * method performs color conversion (which is accelerated in the
+ * libjpeg-turbo implementation) but does not execute any of the other steps
+ * in the JPEG compression process. Encoding CMYK source images into YUV
+ * images is not supported.
*
* @param strides an array of integers, each specifying the number of bytes
- * per line in the corresponding plane of the output image. Setting the
- * stride for any plane to 0 is the same as setting it to the component width
- * of the plane. If strides is null, then the strides for all
- * planes will be set to their respective component widths. You can adjust
- * the strides in order to add an arbitrary amount of line padding to each
- * plane.
+ * per row in the corresponding plane of the YUV source image. Setting the
+ * stride for any plane to 0 is the same as setting it to the plane width
+ * (see {@link YUVImage}.) If strides is null, then the strides
+ * for all planes will be set to their respective plane widths. You can
+ * adjust the strides in order to add an arbitrary amount of row padding to
+ * each plane.
*
* @param flags the bitwise OR of one or more of
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
*
- * @return a YUV planar image.
+ * @return a {@link YUVImage} instance containing the encoded image planes
*/
public YUVImage encodeYUV(int[] strides, int flags) throws TJException {
checkSourceImage();
@@ -679,6 +685,5 @@ public class TJCompressor implements Closeable {
private int subsamp = -1;
private int jpegQuality = -1;
private int compressedSize = 0;
- private int yuvPad = 4;
private ByteOrder byteOrder = null;
}
diff --git a/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java b/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java
index 9a34587a..3a66fd9e 100644
--- a/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java
+++ b/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011, 2013 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011, 2013, 2023 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -58,7 +58,7 @@ public interface TJCustomFilter {
* component plane to which coeffBuffer belongs
*
* @param componentID ID number of the component plane to which
- * coeffBuffer belongs (Y, Cb, and Cr have, respectively, ID's
+ * coeffBuffer belongs. (Y, Cb, and Cr have, respectively, ID's
* of 0, 1, and 2 in typical JPEG images.)
*
* @param transformID ID number of the transformed image to which
diff --git a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
index aba390b1..e35f80a9 100644
--- a/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
+++ b/java/org/libjpegturbo/turbojpeg/TJDecompressor.java
@@ -1,5 +1,6 @@
/*
- * Copyright (C)2011-2015, 2018, 2022 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011-2015, 2018, 2022-2023 D. R. Commander.
+ * All Rights Reserved.
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -50,10 +51,12 @@ public class TJDecompressor implements Closeable {
/**
* Create a TurboJPEG decompressor instance and associate the JPEG source
- * image stored in jpegImage with the newly created instance.
+ * image or "abbreviated table specification" (AKA "tables-only") datastream
+ * stored in jpegImage with the newly created instance.
*
- * @param jpegImage JPEG image buffer (size of the JPEG image is assumed to
- * be the length of the array.) This buffer is not modified.
+ * @param jpegImage buffer containing a JPEG source image or tables-only
+ * datastream. (The size of the JPEG image or datastream is assumed to be
+ * the length of the array.) This buffer is not modified.
*/
public TJDecompressor(byte[] jpegImage) throws TJException {
init();
@@ -62,12 +65,15 @@ public class TJDecompressor implements Closeable {
/**
* Create a TurboJPEG decompressor instance and associate the JPEG source
- * image of length imageSize bytes stored in
- * jpegImage with the newly created instance.
+ * image or "abbreviated table specification" (AKA "tables-only") datastream
+ * of length imageSize bytes stored in jpegImage
+ * with the newly created instance.
*
- * @param jpegImage JPEG image buffer. This buffer is not modified.
+ * @param jpegImage buffer containing a JPEG source image or tables-only
+ * datastream. This buffer is not modified.
*
- * @param imageSize size of the JPEG image (in bytes)
+ * @param imageSize size of the JPEG source image or tables-only datastream
+ * (in bytes)
*/
public TJDecompressor(byte[] jpegImage, int imageSize) throws TJException {
init();
@@ -75,11 +81,11 @@ public class TJDecompressor implements Closeable {
}
/**
- * Create a TurboJPEG decompressor instance and associate the YUV planar
+ * Create a TurboJPEG decompressor instance and associate the planar YUV
* source image stored in yuvImage with the newly created
* instance.
*
- * @param yuvImage {@link YUVImage} instance containing a YUV planar
+ * @param yuvImage {@link YUVImage} instance containing a planar YUV source
* image to be decoded. This image is not modified.
*/
@SuppressWarnings("checkstyle:HiddenField")
@@ -93,18 +99,18 @@ public class TJDecompressor implements Closeable {
* "tables-only") datastream of length imageSize bytes stored in
* jpegImage with this decompressor instance. If
* jpegImage contains a JPEG image, then this image will be used
- * as the source image for subsequent decompress operations. Passing a
+ * as the source image for subsequent decompression operations. Passing a
* tables-only datastream to this method primes the decompressor with
* quantization and Huffman tables that can be used when decompressing
* subsequent "abbreviated image" datastreams. This is useful, for instance,
* when decompressing video streams in which all frames share the same
* quantization and Huffman tables.
*
- * @param jpegImage buffer containing a JPEG image or an "abbreviated table
- * specification" (AKA "tables-only") datastream. This buffer is not
- * modified.
+ * @param jpegImage buffer containing a JPEG source image or tables-only
+ * datastream. This buffer is not modified.
*
- * @param imageSize size of the JPEG image (in bytes)
+ * @param imageSize size of the JPEG source image or tables-only datastream
+ * (in bytes)
*/
public void setSourceImage(byte[] jpegImage, int imageSize)
throws TJException {
@@ -127,12 +133,12 @@ public class TJDecompressor implements Closeable {
}
/**
- * Associate the specified YUV planar source image with this decompressor
- * instance. Subsequent decompress operations will decode this image into an
- * RGB or grayscale destination image.
+ * Associate the specified planar YUV source image with this decompressor
+ * instance. Subsequent decompression operations will decode this image into
+ * a packed-pixel RGB or grayscale destination image.
*
- * @param srcImage {@link YUVImage} instance containing a YUV planar image to
- * be decoded. This image is not modified.
+ * @param srcImage {@link YUVImage} instance containing a planar YUV source
+ * image to be decoded. This image is not modified.
*/
public void setSourceImage(YUVImage srcImage) {
if (srcImage == null)
@@ -210,9 +216,9 @@ public class TJDecompressor implements Closeable {
}
/**
- * Returns the JPEG image buffer associated with this decompressor instance.
+ * Returns the JPEG buffer associated with this decompressor instance.
*
- * @return the JPEG image buffer associated with this decompressor instance.
+ * @return the JPEG buffer associated with this decompressor instance.
*/
public byte[] getJPEGBuf() {
if (jpegBuf == null)
@@ -239,14 +245,14 @@ public class TJDecompressor implements Closeable {
* height.
*
* @param desiredWidth desired width (in pixels) of the decompressed image.
- * Setting this to 0 is the same as setting it to the width of the JPEG image
- * (in other words, the width will not be considered when determining the
- * scaled image size.)
+ * Setting this to 0 is the same as setting it to the width of the JPEG
+ * image. (In other words, the width will not be considered when determining
+ * the scaled image size.)
*
* @param desiredHeight desired height (in pixels) of the decompressed image.
* Setting this to 0 is the same as setting it to the height of the JPEG
- * image (in other words, the height will not be considered when determining
- * the scaled image size.)
+ * image. (In other words, the height will not be considered when
+ * determining the scaled image size.)
*
* @return the width of the largest scaled-down image that the TurboJPEG
* decompressor can generate without exceeding the desired image width and
@@ -280,14 +286,14 @@ public class TJDecompressor implements Closeable {
* height.
*
* @param desiredWidth desired width (in pixels) of the decompressed image.
- * Setting this to 0 is the same as setting it to the width of the JPEG image
- * (in other words, the width will not be considered when determining the
- * scaled image size.)
+ * Setting this to 0 is the same as setting it to the width of the JPEG
+ * image. (In other words, the width will not be considered when determining
+ * the scaled image size.)
*
* @param desiredHeight desired height (in pixels) of the decompressed image.
* Setting this to 0 is the same as setting it to the height of the JPEG
- * image (in other words, the height will not be considered when determining
- * the scaled image size.)
+ * image. (In other words, the height will not be considered when
+ * determining the scaled image size.)
*
* @return the height of the largest scaled-down image that the TurboJPEG
* decompressor can generate without exceeding the desired image width and
@@ -316,27 +322,27 @@ public class TJDecompressor implements Closeable {
}
/**
- * Decompress the JPEG source image or decode the YUV source image associated
- * with this decompressor instance and output a grayscale, RGB, or CMYK image
- * to the given destination buffer.
+ * Decompress the JPEG source image or decode the planar YUV source image
+ * associated with this decompressor instance and output a packed-pixel
+ * grayscale, RGB, or CMYK image to the given destination buffer.
* pitch * scaledHeight bytes in size, where
- * scaledHeight can be determined by calling
- * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegHeight)
- * with one of the scaling factors returned from {@link
- * TJ#getScalingFactors} or by calling {@link #getScaledHeight}. If the
- * source image is a YUV image, then this buffer should normally be
- * pitch * height bytes in size, where height is
- * the height of the YUV image. However, the buffer may also be larger than
- * the dimensions of the source image, in which case the x,
- * y, and pitch parameters can be used to specify
- * the region into which the source image should be decompressed/decoded.
+ * @param dstBuf buffer that will receive the packed-pixel
+ * decompressed/decoded image. If the source image is a JPEG image, then
+ * this buffer should normally be pitch * scaledHeight bytes in
+ * size, where scaledHeight can be determined by calling
+ * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegHeight)
+ * with one of the scaling factors returned from {@link TJ#getScalingFactors}
+ * or by calling {@link #getScaledHeight}. If the source image is a YUV
+ * image, then this buffer should normally be pitch * height
+ * bytes in size, where height is the height of the YUV image.
+ * However, the buffer may also be larger than the dimensions of the source
+ * image, in which case the x, y, and
+ * pitch parameters can be used to specify the region into which
+ * the source image should be decompressed/decoded.
*
* @param x x offset (in pixels) of the region in the destination image into
* which the source image should be decompressed/decoded
@@ -350,22 +356,24 @@ public class TJDecompressor implements Closeable {
* than the source image dimensions, then TurboJPEG will use scaling in the
* JPEG decompressor to generate the largest possible image that will fit
* within the desired dimensions. Setting this to 0 is the same as setting
- * it to the width of the JPEG image (in other words, the width will not be
+ * it to the width of the JPEG image. (In other words, the width will not be
* considered when determining the scaled image size.) This parameter is
* ignored if the source image is a YUV image.
*
- * @param pitch bytes per line of the destination image. Normally, this
- * should be set to scaledWidth * TJ.pixelSize(pixelFormat) if
- * the destination image is unpadded, but you can use this to, for instance,
- * pad each line of the destination image to a 4-byte boundary or to
- * decompress/decode the source image into a region of a larger image. NOTE:
- * if the source image is a JPEG image, then scaledWidth can be
- * determined by calling
- * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegWidth)
- * or by calling {@link #getScaledWidth}. If the source image is a
- * YUV image, then scaledWidth is the width of the YUV image.
+ * @param pitch bytes per row in the destination image. Normally this should
+ * be set to scaledWidth *
+ * {@link TJ#getPixelSize TJ.getPixelSize}(pixelFormat),
+ * if the destination image will be unpadded. However, you can use this to,
+ * for instance, pad each row of the destination image to the nearest
+ * multiple of 4 bytes or to decompress/decode the source image into a region
+ * of a larger image. NOTE: if the source image is a JPEG image, then
+ * scaledWidth can be determined by calling
+ * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegWidth)
+ * or by calling {@link #getScaledWidth}. If the source image is a YUV
+ * image, then scaledWidth is the width of the YUV image.
* Setting this parameter to 0 is the equivalent of setting it to
- * scaledWidth * TJ.pixelSize(pixelFormat).
+ * scaledWidth *
+ * {@link TJ#getPixelSize TJ.getPixelSize}(pixelFormat).
*
* @param desiredHeight If the source image is a JPEG image, then this
* specifies the desired height (in pixels) of the decompressed image (or
@@ -373,8 +381,8 @@ public class TJDecompressor implements Closeable {
* than the source image dimensions, then TurboJPEG will use scaling in the
* JPEG decompressor to generate the largest possible image that will fit
* within the desired dimensions. Setting this to 0 is the same as setting
- * it to the height of the JPEG image (in other words, the height will not be
- * considered when determining the scaled image size.) This parameter is
+ * it to the height of the JPEG image. (In other words, the height will not
+ * be considered when determining the scaled image size.) This parameter is
* ignored if the source image is a YUV image.
*
* @param pixelFormat pixel format of the decompressed/decoded image (one of
@@ -387,7 +395,7 @@ public class TJDecompressor implements Closeable {
int pitch, int desiredHeight, int pixelFormat,
int flags) throws TJException {
if (jpegBuf == null && yuvImage == null)
- throw new IllegalStateException(NO_ASSOC_ERROR);
+ throw new IllegalStateException("No source image is associated with this instance");
if (dstBuf == null || x < 0 || y < 0 || pitch < 0 ||
(yuvImage != null && (desiredWidth < 0 || desiredHeight < 0)) ||
pixelFormat < 0 || pixelFormat >= TJ.NUMPF || flags < 0)
@@ -421,8 +429,9 @@ public class TJDecompressor implements Closeable {
}
/**
- * Decompress the JPEG source image associated with this decompressor
- * instance and return a buffer containing the decompressed image.
+ * Decompress the JPEG source image or decode the planar YUV source image
+ * associated with this decompressor instance and return a buffer containing
+ * the packed-pixel decompressed image.
*
* @param desiredWidth see
* {@link #decompress(byte[], int, int, int, int, int, int, int)}
@@ -442,7 +451,7 @@ public class TJDecompressor implements Closeable {
* @param flags the bitwise OR of one or more of
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
*
- * @return a buffer containing the decompressed image.
+ * @return a buffer containing the packed-pixel decompressed image.
*/
public byte[] decompress(int desiredWidth, int pitch, int desiredHeight,
int pixelFormat, int flags) throws TJException {
@@ -462,22 +471,22 @@ public class TJDecompressor implements Closeable {
/**
* Decompress the JPEG source image associated with this decompressor
- * instance into a YUV planar image and store it in the given
- * YUVImage instance. This method performs JPEG decompression
- * but leaves out the color conversion step, so a planar YUV image is
- * generated instead of an RGB or grayscale image. This method cannot be
- * used to decompress JPEG source images with the CMYK or YCCK colorspace.
+ * instance into a planar YUV image and store it in the given
+ * {@link YUVImage} instance. This method performs JPEG decompression but
+ * leaves out the color conversion step, so a planar YUV image is generated
+ * instead of a packed-pixel image. This method cannot be used to decompress
+ * JPEG source images with the CMYK or YCCK colorspace.
* YUVImage
- * instance must match that of the JPEG image, and the width and height
- * specified in the YUVImage instance must match one of the
- * scaled image sizes that TurboJPEG is capable of generating from the JPEG
- * source image.
+ * @param dstImage {@link YUVImage} instance that will receive the planar YUV
+ * decompressed image. The level of subsampling specified in this
+ * {@link YUVImage} instance must match that of the JPEG image, and the width
+ * and height specified in the {@link YUVImage} instance must match one of
+ * the scaled image sizes that the decompressor is capable of generating from
+ * the JPEG source image.
*
* @param flags the bitwise OR of one or more of
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
@@ -494,7 +503,7 @@ public class TJDecompressor implements Closeable {
dstImage.getHeight());
if (scaledWidth != dstImage.getWidth() ||
scaledHeight != dstImage.getHeight())
- throw new IllegalArgumentException("YUVImage dimensions do not match one of the scaled image sizes that TurboJPEG is capable of generating.");
+ throw new IllegalArgumentException("YUVImage dimensions do not match one of the scaled image sizes that the decompressor is capable of generating.");
if (jpegSubsamp != dstImage.getSubsamp())
throw new IllegalArgumentException("YUVImage subsampling level does not match that of the JPEG image");
@@ -517,40 +526,41 @@ public class TJDecompressor implements Closeable {
/**
* Decompress the JPEG source image associated with this decompressor
* instance into a set of Y, U (Cb), and V (Cr) image planes and return a
- * YUVImage instance containing the decompressed image planes.
- * This method performs JPEG decompression but leaves out the color
- * conversion step, so a planar YUV image is generated instead of an RGB or
- * grayscale image. This method cannot be used to decompress JPEG source
- * images with the CMYK or YCCK colorspace.
+ * {@link YUVImage} instance containing the decompressed image planes. This
+ * method performs JPEG decompression but leaves out the color conversion
+ * step, so a planar YUV image is generated instead of a packed-pixel image.
+ * This method cannot be used to decompress JPEG source images with the CMYK
+ * or YCCK colorspace.
*
* @param desiredWidth desired width (in pixels) of the YUV image. If the
* desired image dimensions are different than the dimensions of the JPEG
* image being decompressed, then TurboJPEG will use scaling in the JPEG
* decompressor to generate the largest possible image that will fit within
* the desired dimensions. Setting this to 0 is the same as setting it to
- * the width of the JPEG image (in other words, the width will not be
+ * the width of the JPEG image. (In other words, the width will not be
* considered when determining the scaled image size.)
*
* @param strides an array of integers, each specifying the number of bytes
- * per line in the corresponding plane of the output image. Setting the
- * stride for any plane to 0 is the same as setting it to the scaled
- * component width of the plane. If strides is NULL, then the
- * strides for all planes will be set to their respective scaled component
- * widths. You can adjust the strides in order to add an arbitrary amount of
- * line padding to each plane.
+ * per row in the corresponding plane of the YUV image. Setting the stride
+ * for any plane to 0 is the same as setting it to the scaled plane width
+ * (see {@link YUVImage}.) If strides is null, then the strides
+ * for all planes will be set to their respective scaled plane widths. You
+ * can adjust the strides in order to add an arbitrary amount of row padding
+ * to each plane.
*
* @param desiredHeight desired height (in pixels) of the YUV image. If the
* desired image dimensions are different than the dimensions of the JPEG
* image being decompressed, then TurboJPEG will use scaling in the JPEG
* decompressor to generate the largest possible image that will fit within
* the desired dimensions. Setting this to 0 is the same as setting it to
- * the height of the JPEG image (in other words, the height will not be
+ * the height of the JPEG image. (In other words, the height will not be
* considered when determining the scaled image size.)
*
* @param flags the bitwise OR of one or more of
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
*
- * @return a YUV planar image.
+ * @return a {@link YUVImage} instance containing the decompressed image
+ * planes
*/
public YUVImage decompressToYUV(int desiredWidth, int[] strides,
int desiredHeight,
@@ -574,40 +584,41 @@ public class TJDecompressor implements Closeable {
/**
* Decompress the JPEG source image associated with this decompressor
- * instance into a unified YUV planar image buffer and return a
- * YUVImage instance containing the decompressed image. This
- * method performs JPEG decompression but leaves out the color conversion
- * step, so a planar YUV image is generated instead of an RGB or grayscale
- * image. This method cannot be used to decompress JPEG source images with
- * the CMYK or YCCK colorspace.
+ * instance into a unified planar YUV image and return a {@link YUVImage}
+ * instance containing the decompressed image. This method performs JPEG
+ * decompression but leaves out the color conversion step, so a planar YUV
+ * image is generated instead of a packed-pixel image. This method cannot be
+ * used to decompress JPEG source images with the CMYK or YCCK colorspace.
*
* @param desiredWidth desired width (in pixels) of the YUV image. If the
* desired image dimensions are different than the dimensions of the JPEG
* image being decompressed, then TurboJPEG will use scaling in the JPEG
* decompressor to generate the largest possible image that will fit within
* the desired dimensions. Setting this to 0 is the same as setting it to
- * the width of the JPEG image (in other words, the width will not be
+ * the width of the JPEG image. (In other words, the width will not be
* considered when determining the scaled image size.)
*
- * @param pad the width of each line in each plane of the YUV image will be
- * padded to the nearest multiple of this number of bytes (must be a power of
- * 2.)
+ * @param align row alignment (in bytes) of the YUV image (must be a power of
+ * 2.) Setting this parameter to n will cause each row in each plane of the
+ * YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.)
*
* @param desiredHeight desired height (in pixels) of the YUV image. If the
* desired image dimensions are different than the dimensions of the JPEG
* image being decompressed, then TurboJPEG will use scaling in the JPEG
* decompressor to generate the largest possible image that will fit within
* the desired dimensions. Setting this to 0 is the same as setting it to
- * the height of the JPEG image (in other words, the height will not be
+ * the height of the JPEG image. (In other words, the height will not be
* considered when determining the scaled image size.)
*
* @param flags the bitwise OR of one or more of
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
*
- * @return a YUV planar image.
+ * @return a {@link YUVImage} instance containing the unified planar YUV
+ * decompressed image
*/
- public YUVImage decompressToYUV(int desiredWidth, int pad, int desiredHeight,
- int flags) throws TJException {
+ public YUVImage decompressToYUV(int desiredWidth, int align,
+ int desiredHeight, int flags)
+ throws TJException {
if (flags < 0)
throw new IllegalArgumentException("Invalid argument in decompressToYUV()");
if (jpegWidth < 1 || jpegHeight < 1 || jpegSubsamp < 0)
@@ -619,7 +630,7 @@ public class TJDecompressor implements Closeable {
int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
- YUVImage dstYUVImage = new YUVImage(scaledWidth, pad, scaledHeight,
+ YUVImage dstYUVImage = new YUVImage(scaledWidth, align, scaledHeight,
jpegSubsamp);
decompressToYUV(dstYUVImage, flags);
return dstYUVImage;
@@ -637,27 +648,27 @@ public class TJDecompressor implements Closeable {
}
/**
- * Decompress the JPEG source image or decode the YUV source image associated
- * with this decompressor instance and output a grayscale, RGB, or CMYK image
- * to the given destination buffer.
+ * Decompress the JPEG source image or decode the planar YUV source image
+ * associated with this decompressor instance and output a packed-pixel
+ * grayscale, RGB, or CMYK image to the given destination buffer.
* stride * scaledHeight pixels in size, where
- * scaledHeight can be determined by calling
- * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegHeight)
- * with one of the scaling factors returned from {@link
- * TJ#getScalingFactors} or by calling {@link #getScaledHeight}. If the
- * source image is a YUV image, then this buffer should normally be
- * stride * height pixels in size, where height is
- * the height of the YUV image. However, the buffer may also be larger than
- * the dimensions of the JPEG image, in which case the x,
- * y, and stride parameters can be used to specify
- * the region into which the source image should be decompressed.
+ * @param dstBuf buffer that will receive the packed-pixel
+ * decompressed/decoded image. If the source image is a JPEG image, then
+ * this buffer should normally be stride * scaledHeight pixels
+ * in size, where scaledHeight can be determined by calling
+ * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegHeight)
+ * with one of the scaling factors returned from {@link TJ#getScalingFactors}
+ * or by calling {@link #getScaledHeight}. If the source image is a YUV
+ * image, then this buffer should normally be stride * height
+ * pixels in size, where height is the height of the YUV image.
+ * However, the buffer may also be larger than the dimensions of the JPEG
+ * image, in which case the x, y, and
+ * stride parameters can be used to specify the region into
+ * which the source image should be decompressed.
*
* @param x x offset (in pixels) of the region in the destination image into
* which the source image should be decompressed/decoded
@@ -671,18 +682,18 @@ public class TJDecompressor implements Closeable {
* than the source image dimensions, then TurboJPEG will use scaling in the
* JPEG decompressor to generate the largest possible image that will fit
* within the desired dimensions. Setting this to 0 is the same as setting
- * it to the width of the JPEG image (in other words, the width will not be
+ * it to the width of the JPEG image. (In other words, the width will not be
* considered when determining the scaled image size.) This parameter is
* ignored if the source image is a YUV image.
*
- * @param stride pixels per line of the destination image. Normally, this
+ * @param stride pixels per row in the destination image. Normally this
* should be set to scaledWidth, but you can use this to, for
* instance, decompress the JPEG image into a region of a larger image.
* NOTE: if the source image is a JPEG image, then scaledWidth
- * can be determined by calling
- * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegWidth)
- * or by calling {@link #getScaledWidth}. If the source image is a
- * YUV image, then scaledWidth is the width of the YUV image.
+ * can be determined by calling
+ * scalingFactor.{@link TJScalingFactor#getScaled getScaled}(jpegWidth)
+ * or by calling {@link #getScaledWidth}. If the source image is a YUV
+ * image, then scaledWidth is the width of the YUV image.
* Setting this parameter to 0 is the equivalent of setting it to
* scaledWidth.
*
@@ -692,8 +703,8 @@ public class TJDecompressor implements Closeable {
* than the source image dimensions, then TurboJPEG will use scaling in the
* JPEG decompressor to generate the largest possible image that will fit
* within the desired dimensions. Setting this to 0 is the same as setting
- * it to the height of the JPEG image (in other words, the height will not be
- * considered when determining the scaled image size.) This parameter is
+ * it to the height of the JPEG image. (In other words, the height will not
+ * be considered when determining the scaled image size.) This parameter is
* ignored if the source image is a YUV image.
*
* @param pixelFormat pixel format of the decompressed image (one of
@@ -706,7 +717,7 @@ public class TJDecompressor implements Closeable {
int stride, int desiredHeight, int pixelFormat,
int flags) throws TJException {
if (jpegBuf == null && yuvImage == null)
- throw new IllegalStateException(NO_ASSOC_ERROR);
+ throw new IllegalStateException("No source image is associated with this instance");
if (dstBuf == null || x < 0 || y < 0 || stride < 0 ||
(yuvImage != null && (desiredWidth < 0 || desiredHeight < 0)) ||
pixelFormat < 0 || pixelFormat >= TJ.NUMPF || flags < 0)
@@ -722,21 +733,22 @@ public class TJDecompressor implements Closeable {
}
/**
- * Decompress the JPEG source image or decode the YUV source image associated
- * with this decompressor instance and output a decompressed/decoded image to
- * the given BufferedImage instance.
+ * Decompress the JPEG source image or decode the planar YUV source image
+ * associated with this decompressor instance and output a packed-pixel
+ * decompressed/decoded image to the given BufferedImage
+ * instance.
* BufferedImage instance that will receive
- * the decompressed/decoded image. If the source image is a JPEG image, then
- * the width and height of the BufferedImage instance must match
- * one of the scaled image sizes that TurboJPEG is capable of generating from
- * the JPEG image. If the source image is a YUV image, then the width and
- * height of the BufferedImage instance must match the width and
- * height of the YUV image.
+ * the packed-pixel decompressed/decoded image. If the source image is a
+ * JPEG image, then the width and height of the BufferedImage
+ * instance must match one of the scaled image sizes that the decompressor is
+ * capable of generating from the JPEG image. If the source image is a YUV
+ * image, then the width and height of the BufferedImage
+ * instance must match the width and height of the YUV image.
*
* @param flags the bitwise OR of one or more of
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
@@ -759,7 +771,7 @@ public class TJDecompressor implements Closeable {
scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
if (scaledWidth != desiredWidth || scaledHeight != desiredHeight)
- throw new IllegalArgumentException("BufferedImage dimensions do not match one of the scaled image sizes that TurboJPEG is capable of generating.");
+ throw new IllegalArgumentException("BufferedImage dimensions do not match one of the scaled image sizes that the decompressor is capable of generating.");
}
int pixelFormat; boolean intPixels = false;
if (byteOrder == null)
@@ -827,9 +839,10 @@ public class TJDecompressor implements Closeable {
}
/**
- * Decompress the JPEG source image or decode the YUV source image associated
- * with this decompressor instance and return a BufferedImage
- * instance containing the decompressed/decoded image.
+ * Decompress the JPEG source image or decode the planar YUV source image
+ * associated with this decompressor instance and return a
+ * BufferedImage instance containing the packed-pixel
+ * decompressed/decoded image.
*
* @param desiredWidth see
* {@link #decompress(byte[], int, int, int, int, int, int, int)} for
@@ -846,7 +859,7 @@ public class TJDecompressor implements Closeable {
* @param flags the bitwise OR of one or more of
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
*
- * @return a BufferedImage instance containing the
+ * @return a BufferedImage instance containing the packed-pixel
* decompressed/decoded image.
*/
public BufferedImage decompress(int desiredWidth, int desiredHeight,
diff --git a/java/org/libjpegturbo/turbojpeg/TJTransform.java b/java/org/libjpegturbo/turbojpeg/TJTransform.java
index 41c4b45e..91bcc6bd 100644
--- a/java/org/libjpegturbo/turbojpeg/TJTransform.java
+++ b/java/org/libjpegturbo/turbojpeg/TJTransform.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011, 2013, 2018 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011, 2013, 2018, 2023 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -97,7 +97,7 @@ public class TJTransform extends Rectangle {
* the level of chrominance subsampling used. If the image's width or height
* is not evenly divisible by the MCU block size (see {@link TJ#getMCUWidth}
* and {@link TJ#getMCUHeight}), then there will be partial MCU blocks on the
- * right and/or bottom edges. It is not possible to move these partial MCU
+ * right and/or bottom edges. It is not possible to move these partial MCU
* blocks to the top or left of the image, so any transform that would
* require that is "imperfect." If this option is not specified, then any
* partial MCU blocks that cannot be transformed will be left in place, which
@@ -114,8 +114,8 @@ public class TJTransform extends Rectangle {
*/
public static final int OPT_CROP = 4;
/**
- * This option will discard the color data in the input image and produce
- * a grayscale output image.
+ * This option will discard the color data in the source image and produce a
+ * grayscale destination image.
*/
public static final int OPT_GRAY = 8;
/**
@@ -127,17 +127,16 @@ public class TJTransform extends Rectangle {
*/
public static final int OPT_NOOUTPUT = 16;
/**
- * This option will enable progressive entropy coding in the output image
+ * This option will enable progressive entropy coding in the JPEG image
* generated by this particular transform. Progressive entropy coding will
* generally improve compression relative to baseline entropy coding (the
- * default), but it will reduce compression and decompression performance
- * considerably.
+ * default), but it will reduce decompression performance considerably.
*/
public static final int OPT_PROGRESSIVE = 32;
/**
* This option will prevent {@link TJTransformer#transform
* TJTransformer.transform()} from copying any extra markers (including EXIF
- * and ICC profile data) from the source image to the output image.
+ * and ICC profile data) from the source image to the destination image.
*/
public static final int OPT_COPYNONE = 64;
@@ -165,10 +164,10 @@ public class TJTransform extends Rectangle {
* equivalent of setting it to (height of the source JPEG image -
* y).
*
- * @param op one of the transform operations (OP_*)
+ * @param op one of the transform operations ({@link #OP_NONE OP_*})
*
* @param options the bitwise OR of one or more of the transform options
- * (OPT_*)
+ * ({@link #OPT_PERFECT OPT_*})
*
* @param cf an instance of an object that implements the {@link
* TJCustomFilter} interface, or null if no custom filter is needed
@@ -190,10 +189,10 @@ public class TJTransform extends Rectangle {
* #TJTransform(int, int, int, int, int, int, TJCustomFilter)} for more
* detail.
*
- * @param op one of the transform operations (OP_*)
+ * @param op one of the transform operations ({@link #OP_NONE OP_*})
*
* @param options the bitwise OR of one or more of the transform options
- * (OPT_*)
+ * ({@link #OPT_PERFECT OPT_*})
*
* @param cf an instance of an object that implements the {@link
* TJCustomFilter} interface, or null if no custom filter is needed
@@ -208,13 +207,14 @@ public class TJTransform extends Rectangle {
}
/**
- * Transform operation (one of OP_*)
+ * Transform operation (one of {@link #OP_NONE OP_*})
*/
@SuppressWarnings("checkstyle:VisibilityModifier")
public int op = 0;
/**
- * Transform options (bitwise OR of one or more of OPT_*)
+ * Transform options (bitwise OR of one or more of
+ * {@link #OPT_PERFECT OPT_*})
*/
@SuppressWarnings("checkstyle:VisibilityModifier")
public int options = 0;
diff --git a/java/org/libjpegturbo/turbojpeg/TJTransformer.java b/java/org/libjpegturbo/turbojpeg/TJTransformer.java
index d7a56f35..2cbf0bfb 100644
--- a/java/org/libjpegturbo/turbojpeg/TJTransformer.java
+++ b/java/org/libjpegturbo/turbojpeg/TJTransformer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2011, 2013-2015 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2011, 2013-2015, 2023 D. R. Commander. All Rights Reserved.
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,10 +43,12 @@ public class TJTransformer extends TJDecompressor {
/**
* Create a TurboJPEG lossless transformer instance and associate the JPEG
- * image stored in jpegImage with the newly created instance.
+ * source image stored in jpegImage with the newly created
+ * instance.
*
- * @param jpegImage JPEG image buffer (size of the JPEG image is assumed to
- * be the length of the array.) This buffer is not modified.
+ * @param jpegImage buffer containing the JPEG source image to transform.
+ * (The size of the JPEG image is assumed to be the length of the array.)
+ * This buffer is not modified.
*/
public TJTransformer(byte[] jpegImage) throws TJException {
init();
@@ -55,12 +57,13 @@ public class TJTransformer extends TJDecompressor {
/**
* Create a TurboJPEG lossless transformer instance and associate the JPEG
- * image of length imageSize bytes stored in
+ * source image of length imageSize bytes stored in
* jpegImage with the newly created instance.
*
- * @param jpegImage JPEG image buffer. This buffer is not modified.
+ * @param jpegImage buffer containing the JPEG source image to transform.
+ * This buffer is not modified.
*
- * @param imageSize size of the JPEG image (in bytes)
+ * @param imageSize size of the JPEG source image (in bytes)
*/
public TJTransformer(byte[] jpegImage, int imageSize) throws TJException {
init();
@@ -68,28 +71,29 @@ public class TJTransformer extends TJDecompressor {
}
/**
- * Losslessly transform the JPEG image associated with this transformer
- * instance into one or more JPEG images stored in the given destination
- * buffers. Lossless transforms work by moving the raw coefficients from one
- * JPEG image structure to another without altering the values of the
- * coefficients. While this is typically faster than decompressing the
- * image, transforming it, and re-compressing it, lossless transforms are not
- * free. Each lossless transform requires reading and performing Huffman
- * decoding on all of the coefficients in the source image, regardless of the
- * size of the destination image. Thus, this method provides a means of
- * generating multiple transformed images from the same source or of applying
- * multiple transformations simultaneously, in order to eliminate the need to
- * read the source coefficients multiple times.
+ * Losslessly transform the JPEG source image associated with this
+ * transformer instance into one or more JPEG images stored in the given
+ * destination buffers. Lossless transforms work by moving the raw
+ * coefficients from one JPEG image structure to another without altering the
+ * values of the coefficients. While this is typically faster than
+ * decompressing the image, transforming it, and re-compressing it, lossless
+ * transforms are not free. Each lossless transform requires reading and
+ * performing Huffman decoding on all of the coefficients in the source
+ * image, regardless of the size of the destination image. Thus, this method
+ * provides a means of generating multiple transformed images from the same
+ * source or of applying multiple transformations simultaneously, in order to
+ * eliminate the need to read the source coefficients multiple times.
*
- * @param dstBufs an array of image buffers. dstbufs[i] will
- * receive a JPEG image that has been transformed using the parameters in
- * transforms[i]. Use {@link TJ#bufSize} to determine the
- * maximum size for each buffer based on the transformed or cropped width and
- * height and the level of subsampling used in the source image.
+ * @param dstBufs an array of JPEG destination buffers.
+ * dstbufs[i] will receive a JPEG image that has been
+ * transformed using the parameters in transforms[i]. Use
+ * {@link TJ#bufSize} to determine the maximum size for each buffer based on
+ * the transformed or cropped width and height and the level of subsampling
+ * used in the source image.
*
* @param transforms an array of {@link TJTransform} instances, each of
* which specifies the transform parameters and/or cropping region for the
- * corresponding transformed output image
+ * corresponding transformed JPEG image
*
* @param flags the bitwise OR of one or more of
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
@@ -103,13 +107,13 @@ public class TJTransformer extends TJDecompressor {
}
/**
- * Losslessly transform the JPEG image associated with this transformer
- * instance and return an array of {@link TJDecompressor} instances, each of
- * which has a transformed JPEG image associated with it.
+ * Losslessly transform the JPEG source image associated with this
+ * transformer instance and return an array of {@link TJDecompressor}
+ * instances, each of which has a transformed JPEG image associated with it.
*
* @param transforms an array of {@link TJTransform} instances, each of
* which specifies the transform parameters and/or cropping region for the
- * corresponding transformed output image
+ * corresponding transformed JPEG image
*
* @param flags the bitwise OR of one or more of
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
@@ -139,10 +143,10 @@ public class TJTransformer extends TJDecompressor {
/**
* Returns an array containing the sizes of the transformed JPEG images
- * generated by the most recent transform operation.
+ * (in bytes) generated by the most recent transform operation.
*
* @return an array containing the sizes of the transformed JPEG images
- * generated by the most recent transform operation.
+ * (in bytes) generated by the most recent transform operation.
*/
public int[] getTransformedSizes() {
if (transformedSizes == null)
diff --git a/java/org/libjpegturbo/turbojpeg/YUVImage.java b/java/org/libjpegturbo/turbojpeg/YUVImage.java
index 4da9843a..94830464 100644
--- a/java/org/libjpegturbo/turbojpeg/YUVImage.java
+++ b/java/org/libjpegturbo/turbojpeg/YUVImage.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C)2014, 2017 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2014, 2017, 2023 D. R. Commander. All Rights Reserved.
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,7 +30,7 @@
package org.libjpegturbo.turbojpeg;
/**
- * This class encapsulates a YUV planar image and the metadata
+ * This class encapsulates a planar YUV image and the metadata
* associated with it. The TurboJPEG API allows both the JPEG compression and
* decompression pipelines to be split into stages: YUV encode, compress from
* YUV, decompress to YUV, and YUV decode. A YUVImage instance
@@ -38,30 +38,32 @@ package org.libjpegturbo.turbojpeg;
* operations and as the source image for compress-from-YUV and YUV decode
* operations.
* strides is null, then the
* strides for all planes will be set to their respective plane widths. When
@@ -92,22 +94,24 @@ public class YUVImage {
}
/**
- * Create a new YUVImage instance backed by a unified image
- * buffer, and allocate memory for the image buffer.
+ * Create a new YUVImage instance backed by a unified buffer,
+ * and allocate memory for the buffer.
*
* @param width width (in pixels) of the YUV image
*
- * @param pad Each line of each plane in the YUV image buffer will be padded
- * to this number of bytes (must be a power of 2.)
+ * @param align row alignment (in bytes) of the YUV image (must be a power of
+ * 2.) Setting this parameter to n specifies that each row in each plane of
+ * the YUV image will be padded to the nearest multiple of n bytes
+ * (1 = unpadded.)
*
* @param height height (in pixels) of the YUV image
*
* @param subsamp the level of chrominance subsampling to be used in the YUV
* image (one of {@link TJ#SAMP_444 TJ.SAMP_*})
*/
- public YUVImage(int width, int pad, int height, int subsamp) {
- setBuf(new byte[TJ.bufSizeYUV(width, pad, height, subsamp)], width, pad,
- height, subsamp);
+ public YUVImage(int width, int align, int height, int subsamp) {
+ setBuf(new byte[TJ.bufSizeYUV(width, align, height, subsamp)], width,
+ align, height, subsamp);
}
/**
@@ -117,8 +121,8 @@ public class YUVImage {
* @param planes an array of buffers representing the Y, U (Cb), and V (Cr)
* image planes (or just the Y plane, if the image is grayscale.) These
* planes can be contiguous or non-contiguous in memory. Plane
- * i should be at least offsets[i] +
- * {@link TJ#planeSizeYUV TJ.planeSizeYUV}(i, width, strides[i], height, subsamp)
+ * i should be at least offsets[i] +
+ * {@link TJ#planeSizeYUV TJ.planeSizeYUV}(i, width, strides[i], height, subsamp)
* bytes in size.
*
* @param offsets If this YUVImage instance represents a
@@ -130,11 +134,11 @@ public class YUVImage {
* @param width width (in pixels) of the new YUV image (or subregion)
*
* @param strides an array of integers, each specifying the number of bytes
- * per line in the corresponding plane of the YUV image. Setting the stride
+ * per row in the corresponding plane of the YUV image. Setting the stride
* for any plane to 0 is the same as setting it to the plane width (see
* {@link YUVImage above}.) If strides is null, then the
* strides for all planes will be set to their respective plane widths. You
- * can adjust the strides in order to add an arbitrary amount of line padding
+ * can adjust the strides in order to add an arbitrary amount of row padding
* to each plane or to specify that this YUVImage instance is a
* subregion of a larger image (in which case, strides[i] should
* be set to the plane width of plane i in the larger image.)
@@ -150,29 +154,30 @@ public class YUVImage {
}
/**
- * Create a new YUVImage instance from an existing unified image
+ * Create a new YUVImage instance from an existing unified
* buffer.
*
- * @param yuvImage image buffer that contains or will contain YUV planar
- * image data. Use {@link TJ#bufSizeYUV} to determine the minimum size for
- * this buffer. The Y, U (Cb), and V (Cr) image planes are stored
- * sequentially in the buffer (see {@link YUVImage above} for a description
- * of the image format.)
+ * @param yuvImage buffer that contains or will receive a unified planar YUV
+ * image. Use {@link TJ#bufSizeYUV} to determine the minimum size for this
+ * buffer. The Y, U (Cb), and V (Cr) image planes are stored sequentially in
+ * the buffer. (See {@link YUVImage above} for a description of the image
+ * format.)
*
* @param width width (in pixels) of the YUV image
*
- * @param pad the line padding used in the YUV image buffer. For
- * instance, if each line in each plane of the buffer is padded to the
- * nearest multiple of 4 bytes, then pad should be set to 4.
+ * @param align row alignment (in bytes) of the YUV image (must be a power of
+ * 2.) Setting this parameter to n specifies that each row in each plane of
+ * the YUV image will be padded to the nearest multiple of n bytes
+ * (1 = unpadded.)
*
* @param height height (in pixels) of the YUV image
*
* @param subsamp the level of chrominance subsampling used in the YUV
* image (one of {@link TJ#SAMP_444 TJ.SAMP_*})
*/
- public YUVImage(byte[] yuvImage, int width, int pad, int height,
+ public YUVImage(byte[] yuvImage, int width, int align, int height,
int subsamp) {
- setBuf(yuvImage, width, pad, height, subsamp);
+ setBuf(yuvImage, width, align, height, subsamp);
}
/**
@@ -181,8 +186,8 @@ public class YUVImage {
* @param planes an array of buffers representing the Y, U (Cb), and V (Cr)
* image planes (or just the Y plane, if the image is grayscale.) These
* planes can be contiguous or non-contiguous in memory. Plane
- * i should be at least offsets[i] +
- * {@link TJ#planeSizeYUV TJ.planeSizeYUV}(i, width, strides[i], height, subsamp)
+ * i should be at least offsets[i] +
+ * {@link TJ#planeSizeYUV TJ.planeSizeYUV}(i, width, strides[i], height, subsamp)
* bytes in size.
*
* @param offsets If this YUVImage instance represents a
@@ -194,12 +199,12 @@ public class YUVImage {
* @param width width (in pixels) of the YUV image (or subregion)
*
* @param strides an array of integers, each specifying the number of bytes
- * per line in the corresponding plane of the YUV image. Setting the stride
+ * per row in the corresponding plane of the YUV image. Setting the stride
* for any plane to 0 is the same as setting it to the plane width (see
* {@link YUVImage above}.) If strides is null, then the
* strides for all planes will be set to their respective plane widths. You
- * can adjust the strides in order to add an arbitrary amount of line padding
- * to each plane or to specify that this YUVImage image is a
+ * can adjust the strides in order to add an arbitrary amount of row padding
+ * to each plane or to specify that this YUVImage instance is a
* subregion of a larger image (in which case, strides[i] should
* be set to the plane width of plane i in the larger image.)
*
@@ -263,32 +268,34 @@ public class YUVImage {
}
/**
- * Assign a unified image buffer to this YUVImage instance.
+ * Assign a unified buffer to this YUVImage instance.
*
- * @param yuvImage image buffer that contains or will contain YUV planar
- * image data. Use {@link TJ#bufSizeYUV} to determine the minimum size for
- * this buffer. The Y, U (Cb), and V (Cr) image planes are stored
- * sequentially in the buffer (see {@link YUVImage above} for a description
- * of the image format.)
+ * @param yuvImage buffer that contains or will receive a unified planar YUV
+ * image. Use {@link TJ#bufSizeYUV} to determine the minimum size for this
+ * buffer. The Y, U (Cb), and V (Cr) image planes are stored sequentially in
+ * the buffer. (See {@link YUVImage above} for a description of the image
+ * format.)
*
* @param width width (in pixels) of the YUV image
*
- * @param pad the line padding used in the YUV image buffer. For
- * instance, if each line in each plane of the buffer is padded to the
- * nearest multiple of 4 bytes, then pad should be set to 4.
+ * @param align row alignment (in bytes) of the YUV image (must be a power of
+ * 2.) Setting this parameter to n specifies that each row in each plane of
+ * the YUV image will be padded to the nearest multiple of n bytes
+ * (1 = unpadded.)
*
* @param height height (in pixels) of the YUV image
*
* @param subsamp the level of chrominance subsampling used in the YUV
* image (one of {@link TJ#SAMP_444 TJ.SAMP_*})
*/
- public void setBuf(byte[] yuvImage, int width, int pad, int height,
+ public void setBuf(byte[] yuvImage, int width, int align, int height,
int subsamp) {
- if (yuvImage == null || width < 1 || pad < 1 || ((pad & (pad - 1)) != 0) ||
- height < 1 || subsamp < 0 || subsamp >= TJ.NUMSAMP)
+ if (yuvImage == null || width < 1 || align < 1 ||
+ ((align & (align - 1)) != 0) || height < 1 || subsamp < 0 ||
+ subsamp >= TJ.NUMSAMP)
throw new IllegalArgumentException("Invalid argument in YUVImage::setBuf()");
- if (yuvImage.length < TJ.bufSizeYUV(width, pad, height, subsamp))
- throw new IllegalArgumentException("YUV image buffer is not large enough");
+ if (yuvImage.length < TJ.bufSizeYUV(width, align, height, subsamp))
+ throw new IllegalArgumentException("YUV buffer is not large enough");
int nc = (subsamp == TJ.SAMP_GRAY ? 1 : 3);
byte[][] planes = new byte[nc][];
@@ -296,9 +303,9 @@ public class YUVImage {
int[] offsets = new int[nc];
planes[0] = yuvImage;
- strides[0] = pad(TJ.planeWidth(0, width, subsamp), pad);
+ strides[0] = pad(TJ.planeWidth(0, width, subsamp), align);
if (subsamp != TJ.SAMP_GRAY) {
- strides[1] = strides[2] = pad(TJ.planeWidth(1, width, subsamp), pad);
+ strides[1] = strides[2] = pad(TJ.planeWidth(1, width, subsamp), align);
planes[1] = planes[2] = yuvImage;
offsets[1] = offsets[0] +
strides[0] * TJ.planeHeight(0, height, subsamp);
@@ -306,7 +313,7 @@ public class YUVImage {
strides[1] * TJ.planeHeight(1, height, subsamp);
}
- yuvPad = pad;
+ yuvAlign = align;
setBuf(planes, offsets, width, strides, height, subsamp);
}
@@ -333,23 +340,23 @@ public class YUVImage {
}
/**
- * Returns the line padding used in the YUV image buffer (if this image is
+ * Returns the row alignment (in bytes) of the YUV buffer (if this image is
* stored in a unified buffer rather than separate image planes.)
*
- * @return the line padding used in the YUV image buffer
+ * @return the row alignment of the YUV buffer
*/
public int getPad() {
if (yuvPlanes == null)
throw new IllegalStateException(NO_ASSOC_ERROR);
- if (yuvPad < 1 || ((yuvPad & (yuvPad - 1)) != 0))
+ if (yuvAlign < 1 || ((yuvAlign & (yuvAlign - 1)) != 0))
throw new IllegalStateException("Image is not stored in a unified buffer");
- return yuvPad;
+ return yuvAlign;
}
/**
- * Returns the number of bytes per line of each plane in the YUV image.
+ * Returns the number of bytes per row of each plane in the YUV image.
*
- * @return the number of bytes per line of each plane in the YUV image
+ * @return the number of bytes per row of each plane in the YUV image
*/
public int[] getStrides() {
if (yuvStrides == null)
@@ -395,10 +402,10 @@ public class YUVImage {
}
/**
- * Returns the YUV image buffer (if this image is stored in a unified
- * buffer rather than separate image planes.)
+ * Returns the YUV buffer (if this image is stored in a unified buffer rather
+ * than separate image planes.)
*
- * @return the YUV image buffer
+ * @return the YUV buffer
*/
public byte[] getBuf() {
if (yuvPlanes == null || yuvSubsamp < 0 || yuvSubsamp >= TJ.NUMSAMP)
@@ -412,22 +419,22 @@ public class YUVImage {
}
/**
- * Returns the size (in bytes) of the YUV image buffer (if this image is
- * stored in a unified buffer rather than separate image planes.)
+ * Returns the size (in bytes) of the YUV buffer (if this image is stored in
+ * a unified buffer rather than separate image planes.)
*
- * @return the size (in bytes) of the YUV image buffer
+ * @return the size (in bytes) of the YUV buffer
*/
public int getSize() {
if (yuvPlanes == null || yuvSubsamp < 0 || yuvSubsamp >= TJ.NUMSAMP)
throw new IllegalStateException(NO_ASSOC_ERROR);
int nc = (yuvSubsamp == TJ.SAMP_GRAY ? 1 : 3);
- if (yuvPad < 1)
+ if (yuvAlign < 1)
throw new IllegalStateException("Image is not stored in a unified buffer");
for (int i = 1; i < nc; i++) {
if (yuvPlanes[i] != yuvPlanes[0])
throw new IllegalStateException("Image is not stored in a unified buffer");
}
- return TJ.bufSizeYUV(yuvWidth, yuvPad, yuvHeight, yuvSubsamp);
+ return TJ.bufSizeYUV(yuvWidth, yuvAlign, yuvHeight, yuvSubsamp);
}
private static int pad(int v, int p) {
@@ -438,7 +445,7 @@ public class YUVImage {
protected byte[][] yuvPlanes = null;
protected int[] yuvOffsets = null;
protected int[] yuvStrides = null;
- protected int yuvPad = 0;
+ protected int yuvAlign = 1;
protected int yuvWidth = 0;
protected int yuvHeight = 0;
protected int yuvSubsamp = -1;
diff --git a/jccolext.c b/jccolext.c
index 303b322c..20f891a6 100644
--- a/jccolext.c
+++ b/jccolext.c
@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
- * Copyright (C) 2009-2012, 2015, D. R. Commander.
+ * Copyright (C) 2009-2012, 2015, 2022, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -48,9 +48,9 @@ rgb_ycc_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
outptr2 = output_buf[2][output_row];
output_row++;
for (col = 0; col < num_cols; col++) {
- r = inptr[RGB_RED];
- g = inptr[RGB_GREEN];
- b = inptr[RGB_BLUE];
+ r = RANGE_LIMIT(inptr[RGB_RED]);
+ g = RANGE_LIMIT(inptr[RGB_GREEN]);
+ b = RANGE_LIMIT(inptr[RGB_BLUE]);
inptr += RGB_PIXELSIZE;
/* If the inputs are 0..MAXJSAMPLE, the outputs of these equations
* must be too; we do not need an explicit range-limiting operation.
@@ -100,9 +100,9 @@ rgb_gray_convert_internal(j_compress_ptr cinfo, JSAMPARRAY input_buf,
outptr = output_buf[0][output_row];
output_row++;
for (col = 0; col < num_cols; col++) {
- r = inptr[RGB_RED];
- g = inptr[RGB_GREEN];
- b = inptr[RGB_BLUE];
+ r = RANGE_LIMIT(inptr[RGB_RED]);
+ g = RANGE_LIMIT(inptr[RGB_GREEN]);
+ b = RANGE_LIMIT(inptr[RGB_BLUE]);
inptr += RGB_PIXELSIZE;
/* Y */
outptr[col] = (JSAMPLE)((ctab[r + R_Y_OFF] + ctab[g + G_Y_OFF] +
diff --git a/jccolor.c b/jccolor.c
index bdc563c7..fb9f1cc1 100644
--- a/jccolor.c
+++ b/jccolor.c
@@ -5,7 +5,7 @@
* Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman = When testing JPEG compression, this option specifies the level\n");
- printf(" of chrominance subsampling to use ( = 444, 422, 440, 420, 411, or\n");
- printf(" GRAY). The default is to test Grayscale, 4:2:0, 4:2:2, and 4:4:4 in\n");
- printf(" sequence.\n");
+ printf(" compression and transform operations\n");
+ printf("-subsamp = When compressing, use the specified level of chrominance\n");
+ printf(" subsampling ( = 444, 422, 440, 420, 411, or GRAY) [default = test\n");
+ printf(" Grayscale, 4:2:0, 4:2:2, and 4:4:4 in sequence]\n");
printf("-quiet = Output results in tabular rather than verbose format\n");
- printf("-yuv = Test YUV encoding/decoding functions\n");
- printf("-yuvpad