Class TJ

java.lang.Object
org.libjpegturbo.turbojpeg.TJ

public final class TJ extends Object
TurboJPEG utility class (cannot be instantiated)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int[]
     
    static final int
    Use the most accurate DCT/IDCT algorithm available in the underlying codec.
    static final int
    The uncompressed source/destination image is stored in bottom-up (Windows, OpenGL) order, not top-down (X11) order.
    static final int
    Use the fastest DCT/IDCT algorithm available in the underlying codec.
    static final int
    When decompressing, use the fastest chrominance upsampling algorithm available in the underlying codec.
    static final int
    Turn off CPU auto-detection and force TurboJPEG to use MMX code (if the underlying codec supports it.)
    static final int
    Turn off CPU auto-detection and force TurboJPEG to use SSE code (if the underlying codec supports it.)
    static final int
    Turn off CPU auto-detection and force TurboJPEG to use SSE2 code (if the underlying codec supports it.)
    static final int
    Turn off CPU auto-detection and force TurboJPEG to use SSE3 code (if the underlying codec supports it.)
    private static final int[]
     
    private static final int[]
     
    private static final int[]
     
    static final int
    The number of pixel formats
    static final int
    The number of chrominance subsampling options
    static final int
    ABGR pixel format.
    static final int
    ARGB pixel format.
    static final int
    BGR pixel format.
    static final int
    BGRA pixel format.
    static final int
    BGRX pixel format.
    static final int
    Grayscale pixel format.
    static final int
    RGB pixel format.
    static final int
    RGBA pixel format.
    static final int
    RGBX pixel format.
    static final int
    XBGR pixel format.
    static final int
    XRGB pixel format.
    private static final int[]
     
    private static final int[]
     
    static final int
    4:2:0 chrominance subsampling.
    static final int
    4:2:2 chrominance subsampling.
    static final int
    4:4:0 chrominance subsampling.
    static final int
    4:4:4 chrominance subsampling (no chrominance subsampling).
    static final int
    Grayscale.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TJ()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    bufSize(int width, int height, int jpegSubsamp)
    Returns the maximum size of the buffer (in bytes) required to hold a JPEG image with the given width and height, and level of chrominance subsampling.
    static int
    bufSizeYUV(int width, int height, int subsamp)
    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.
    static int
    getBlueOffset(int pixelFormat)
    For the given pixel format, returns the number of bytes that the blue component is offset from the start of the pixel.
    static int
    getGreenOffset(int pixelFormat)
    For the given pixel format, returns the number of bytes that the green component is offset from the start of the pixel.
    static int
    getMCUHeight(int subsamp)
    Returns the MCU block height for the given level of chrominance subsampling.
    static int
    getMCUWidth(int subsamp)
    Returns the MCU block width for the given level of chrominance subsampling.
    static int
    getPixelSize(int pixelFormat)
    Returns the pixel size (in bytes) of the given pixel format.
    static int
    getRedOffset(int pixelFormat)
    For the given pixel format, returns the number of bytes that the red component is offset from the start of the pixel.
    Returns a list of fractional scaling factors that the JPEG decompressor in this implementation of TurboJPEG supports.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NUMSAMP

      public static final int NUMSAMP
      The number of chrominance subsampling options
      See Also:
    • SAMP_444

      public static final int SAMP_444
      4:4:4 chrominance subsampling (no chrominance subsampling). The JPEG or YUV image will contain one chrominance component for every pixel in the source image.
      See Also:
    • SAMP_422

      public static final int SAMP_422
      4:2:2 chrominance subsampling. The JPEG or YUV image will contain one chrominance component for every 2x1 block of pixels in the source image.
      See Also:
    • SAMP_420

      public static final int SAMP_420
      4:2:0 chrominance subsampling. The JPEG or YUV image will contain one chrominance component for every 2x2 block of pixels in the source image.
      See Also:
    • SAMP_GRAY

      public static final int SAMP_GRAY
      Grayscale. The JPEG or YUV image will contain no chrominance components.
      See Also:
    • SAMP_440

      public static final int SAMP_440
      4:4:0 chrominance subsampling. The JPEG or YUV image will contain one chrominance component for every 1x2 block of pixels in the source image.
      See Also:
    • mcuWidth

      private static final int[] mcuWidth
    • mcuHeight

      private static final int[] mcuHeight
    • NUMPF

      public static final int NUMPF
      The number of pixel formats
      See Also:
    • PF_RGB

      public static final int PF_RGB
      RGB pixel format. The red, green, and blue components in the image are stored in 3-byte pixels in the order R, G, B from lowest to highest byte address within each pixel.
      See Also:
    • PF_BGR

      public static final int PF_BGR
      BGR pixel format. The red, green, and blue components in the image are stored in 3-byte pixels in the order B, G, R from lowest to highest byte address within each pixel.
      See Also:
    • PF_RGBX

      public static final int PF_RGBX
      RGBX pixel format. The red, green, and blue components in the image are stored in 4-byte pixels in the order R, G, B from lowest to highest byte address within each pixel. The X component is ignored when compressing and undefined when decompressing.
      See Also:
    • PF_BGRX

      public static final int PF_BGRX
      BGRX pixel format. The red, green, and blue components in the image are stored in 4-byte pixels in the order B, G, R from lowest to highest byte address within each pixel. The X component is ignored when compressing and undefined when decompressing.
      See Also:
    • PF_XBGR

      public static final int PF_XBGR
      XBGR pixel format. The red, green, and blue components in the image are stored in 4-byte pixels in the order R, G, B from highest to lowest byte address within each pixel. The X component is ignored when compressing and undefined when decompressing.
      See Also:
    • PF_XRGB

      public static final int PF_XRGB
      XRGB pixel format. The red, green, and blue components in the image are stored in 4-byte pixels in the order B, G, R from highest to lowest byte address within each pixel. The X component is ignored when compressing and undefined when decompressing.
      See Also:
    • PF_GRAY

      public static final int PF_GRAY
      Grayscale pixel format. Each 1-byte pixel represents a luminance (brightness) level from 0 to 255.
      See Also:
    • PF_RGBA

      public static final int PF_RGBA
      RGBA pixel format. This is the same as PF_RGBX, except that when decompressing, the X byte is guaranteed to be 0xFF, which can be interpreted as an opaque alpha channel.
      See Also:
    • PF_BGRA

      public static final int PF_BGRA
      BGRA pixel format. This is the same as PF_BGRX, except that when decompressing, the X byte is guaranteed to be 0xFF, which can be interpreted as an opaque alpha channel.
      See Also:
    • PF_ABGR

      public static final int PF_ABGR
      ABGR pixel format. This is the same as PF_XBGR, except that when decompressing, the X byte is guaranteed to be 0xFF, which can be interpreted as an opaque alpha channel.
      See Also:
    • PF_ARGB

      public static final int PF_ARGB
      ARGB pixel format. This is the same as PF_XRGB, except that when decompressing, the X byte is guaranteed to be 0xFF, which can be interpreted as an opaque alpha channel.
      See Also:
    • pixelSize

      private static final int[] pixelSize
    • redOffset

      private static final int[] redOffset
    • greenOffset

      private static final int[] greenOffset
    • blueOffset

      private static final int[] blueOffset
    • FLAG_BOTTOMUP

      public static final int FLAG_BOTTOMUP
      The uncompressed source/destination image is stored in bottom-up (Windows, OpenGL) order, not top-down (X11) order.
      See Also:
    • FLAG_FORCEMMX

      public static final int FLAG_FORCEMMX
      Turn off CPU auto-detection and force TurboJPEG to use MMX code (if the underlying codec supports it.)
      See Also:
    • FLAG_FORCESSE

      public static final int FLAG_FORCESSE
      Turn off CPU auto-detection and force TurboJPEG to use SSE code (if the underlying codec supports it.)
      See Also:
    • FLAG_FORCESSE2

      public static final int FLAG_FORCESSE2
      Turn off CPU auto-detection and force TurboJPEG to use SSE2 code (if the underlying codec supports it.)
      See Also:
    • FLAG_FORCESSE3

      public static final int FLAG_FORCESSE3
      Turn off CPU auto-detection and force TurboJPEG to use SSE3 code (if the underlying codec supports it.)
      See Also:
    • FLAG_FASTUPSAMPLE

      public static final int FLAG_FASTUPSAMPLE
      When decompressing, 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.
      See Also:
    • FLAG_FASTDCT

      public static final int FLAG_FASTDCT
      Use the fastest DCT/IDCT algorithm available in the underlying codec. The default if this flag is not specified is implementation-specific. The libjpeg implementation, for example, 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.
      See Also:
    • FLAG_ACCURATEDCT

      public static final int FLAG_ACCURATEDCT
      Use the most accurate DCT/IDCT algorithm available in the underlying codec. The default if this flag is not specified is implementation-specific. The libjpeg implementation, for example, 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.
      See Also:
  • Constructor Details

    • TJ

      public TJ()
  • Method Details

    • getMCUWidth

      public static int getMCUWidth(int subsamp) throws Exception
      Returns the MCU block width for the given level of chrominance subsampling.
      Parameters:
      subsamp - the level of chrominance subsampling (one of SAMP_*)
      Returns:
      the MCU block width for the given level of chrominance subsampling
      Throws:
      Exception
    • getMCUHeight

      public static int getMCUHeight(int subsamp) throws Exception
      Returns the MCU block height for the given level of chrominance subsampling.
      Parameters:
      subsamp - the level of chrominance subsampling (one of SAMP_*)
      Returns:
      the MCU block height for the given level of chrominance subsampling
      Throws:
      Exception
    • getPixelSize

      public static int getPixelSize(int pixelFormat) throws Exception
      Returns the pixel size (in bytes) of the given pixel format.
      Parameters:
      pixelFormat - the pixel format (one of PF_*)
      Returns:
      the pixel size (in bytes) of the given pixel format
      Throws:
      Exception
    • getRedOffset

      public static int getRedOffset(int pixelFormat) throws Exception
      For the given pixel format, returns the number of bytes that the red component is offset from the start of the pixel. For instance, if a pixel of format TJ.PF_BGRX is stored in char pixel[], then the red component will be pixel[TJ.getRedOffset(TJ.PF_BGRX)].
      Parameters:
      pixelFormat - the pixel format (one of PF_*)
      Returns:
      the red offset for the given pixel format
      Throws:
      Exception
    • getGreenOffset

      public static int getGreenOffset(int pixelFormat) throws Exception
      For the given pixel format, returns the number of bytes that the green component is offset from the start of the pixel. For instance, if a pixel of format TJ.PF_BGRX is stored in char pixel[], then the green component will be pixel[TJ.getGreenOffset(TJ.PF_BGRX)].
      Parameters:
      pixelFormat - the pixel format (one of PF_*)
      Returns:
      the green offset for the given pixel format
      Throws:
      Exception
    • getBlueOffset

      public static int getBlueOffset(int pixelFormat) throws Exception
      For the given pixel format, returns the number of bytes that the blue component is offset from the start of the pixel. For instance, if a pixel of format TJ.PF_BGRX is stored in char pixel[], then the blue component will be pixel[TJ.getBlueOffset(TJ.PF_BGRX)].
      Parameters:
      pixelFormat - the pixel format (one of PF_*)
      Returns:
      the blue offset for the given pixel format
      Throws:
      Exception
    • bufSize

      public static int bufSize(int width, int height, int jpegSubsamp) throws Exception
      Returns the maximum size of the buffer (in bytes) required to hold a JPEG image with the given width and height, and level of chrominance subsampling.
      Parameters:
      width - the width (in pixels) of the JPEG image
      height - the height (in pixels) of the JPEG image
      jpegSubsamp - the level of chrominance subsampling to be used when generating the JPEG image (one of TJ.SAMP_*)
      Returns:
      the maximum size of the buffer (in bytes) required to hold a JPEG image with the given width and height, and level of chrominance subsampling
      Throws:
      Exception
    • bufSizeYUV

      public static int bufSizeYUV(int width, int height, int subsamp) throws Exception
      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.
      Parameters:
      width - the width (in pixels) of the YUV image
      height - the height (in pixels) of the YUV image
      subsamp - the level of chrominance subsampling used in the YUV image (one of TJ.SAMP_*)
      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
      Throws:
      Exception
    • getScalingFactors

      public static TJScalingFactor[] getScalingFactors() throws Exception
      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 in this implementation of TurboJPEG supports
      Throws:
      Exception