org.libjpegturbo.turbojpeg
Class YUVImage

java.lang.Object
  extended by org.libjpegturbo.turbojpeg.YUVImage

public class YUVImage
extends java.lang.Object

This class encapsulates a YUV planar image buffer 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 serves as the destination image for YUV encode and decompress-to-YUV operations and as the source image for compress-from-YUV and YUV decode operations.

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. In this image format, the Y, Cb (U), and Cr (V) planes are stored sequentially in the same image buffer, and the size of each plane is determined by the image width, height, line padding, and level of chrominance subsampling. If the chrominance components are subsampled along the horizontal dimension, then the width of the luminance plane would be padded to the nearest multiple of 2 (same goes for the height of the luminance plane, if the chrominance components are subsampled along the vertical dimension.) For instance, 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, for instance, 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.


Field Summary
protected  long handle
           
protected  byte[] yuvBuf
           
protected  int yuvHeight
           
protected  int yuvPad
           
protected  int yuvSubsamp
           
protected  int yuvWidth
           
 
Constructor Summary
YUVImage(byte[] yuvImage, int width, int pad, int height, int subsamp)
          Create a YUVImage instance from an existing YUV planar image buffer.
YUVImage(int width, int pad, int height, int subsamp)
          Create a YUVImage instance with a new image buffer.
 
Method Summary
 byte[] getBuf()
          Returns the YUV image buffer
 int getHeight()
          Returns the height of the YUV image.
 int getPad()
          Returns the line padding used in the YUV image buffer.
 int getSize()
          Returns the size (in bytes) of the YUV image buffer
 int getSubsamp()
          Returns the level of chrominance subsampling used in the YUV image.
 int getWidth()
          Returns the width of the YUV image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

handle

protected long handle

yuvBuf

protected byte[] yuvBuf

yuvPad

protected int yuvPad

yuvWidth

protected int yuvWidth

yuvHeight

protected int yuvHeight

yuvSubsamp

protected int yuvSubsamp
Constructor Detail

YUVImage

public YUVImage(int width,
                int pad,
                int height,
                int subsamp)
         throws java.lang.Exception
Create a YUVImage instance with a new image buffer.

Parameters:
width - width (in pixels) of the YUV image
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.)
height - height (in pixels) of the YUV image
subsamp - the level of chrominance subsampling to be used in the YUV image (one of TJ.SAMP_*)
Throws:
java.lang.Exception

YUVImage

public YUVImage(byte[] yuvImage,
                int width,
                int pad,
                int height,
                int subsamp)
         throws java.lang.Exception
Create a YUVImage instance from an existing YUV planar image buffer.

Parameters:
yuvImage - image buffer that contains or will contain YUV planar image data. See above for a description of the image format. You can use TJ.bufSizeYUV(int, int, int, int) to determine the appropriate size for this buffer.
width - width (in pixels) of the YUV image
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.
height - height (in pixels) of the YUV image
subsamp - the level of chrominance subsampling used in the YUV image (one of TJ.SAMP_*)
Throws:
java.lang.Exception
Method Detail

getWidth

public int getWidth()
             throws java.lang.Exception
Returns the width of the YUV image.

Returns:
the width of the YUV image
Throws:
java.lang.Exception

getHeight

public int getHeight()
              throws java.lang.Exception
Returns the height of the YUV image.

Returns:
the height of the YUV image
Throws:
java.lang.Exception

getPad

public int getPad()
           throws java.lang.Exception
Returns the line padding used in the YUV image buffer.

Returns:
the line padding used in the YUV image buffer
Throws:
java.lang.Exception

getSubsamp

public int getSubsamp()
               throws java.lang.Exception
Returns the level of chrominance subsampling used in the YUV image. See TJ.SAMP_*.

Returns:
the level of chrominance subsampling used in the YUV image
Throws:
java.lang.Exception

getBuf

public byte[] getBuf()
              throws java.lang.Exception
Returns the YUV image buffer

Returns:
the YUV image buffer
Throws:
java.lang.Exception

getSize

public int getSize()
            throws java.lang.Exception
Returns the size (in bytes) of the YUV image buffer

Returns:
the size (in bytes) of the YUV image buffer
Throws:
java.lang.Exception