Class AbstractAVIStream.VideoTrack

java.lang.Object
org.monte.media.avi.AbstractAVIStream.Track
org.monte.media.avi.AbstractAVIStream.VideoTrack
Enclosing class:
AbstractAVIStream

protected class AbstractAVIStream.VideoTrack extends AbstractAVIStream.Track
Represents a video track in an AVI file.

The format of a video track is defined in a "strf" chunk, which contains a BITMAPINFOHEADER struct.

 //----------------------
 // AVI Bitmap Info Header
 // ----------------------
 typedef struct {
      BYTE blue;
      BYTE green;
      BYTE red;
      BYTE reserved;
 } RGBQUAD;

 // Values for this enum taken from:
 // http://www.fourcc.org/index.php?http%3A//www.fourcc.org/rgb.php
 enum {
      BI_RGB = 0x00000000,
      RGB = 0x32424752, // Alias for BI_RGB
      BI_RLE8 =0x01000000,
      RLE8 = 0x38454C52, // Alias for BI_RLE8
      BI_RLE4 = 0x00000002,
      RLE4 = 0x34454C52, // Alias for BI_RLE4
      BI_BITFIELDS = 0x00000003,
      raw = 0x32776173,
      RGBA = 0x41424752,
      RGBT = 0x54424752,
      cvid = "cvid"
  } bitmapCompression;

 typedef struct {
      DWORD structSize;
                      // Specifies the number of bytes required by the structure.
      LONG width;
                      // Specifies the width of the bitmap.
                      // - For RGB formats, the width is specified in pixels.
                      // - The same is true for YUV formats if the bitdepth is an even power
                      // of 2.
                      // - For YUV formats where the bitdepth is not an even power of 2,
                      // however, the width is specified in bytes.
                      // Decoders and video sources should propose formats where "width" is
                      // the width of the image. If the video renderer is using DirectDraw, it
                      // modifies the format so that "width" equals the stride of the surface,
                      // and the "target" member of the VIDEOINFOHEADER or VIDEOINFOHEADER2
                      // structure specifies the image width. Then it proposes the modified
                      // format using IPin::QueryAccept.
                      // For RGB and even-power-of-2 YUV formats, if the video renderer does
                      // not specify the stride, then round the width up to the nearst DWORD
                      // boundary to find the stride.
      LONG height;
                      // Specifies the height of the bitmap, in pixels.
                      // - For uncompressed RGB bitmaps, if "height" is positive, the bitmap
                      // is a bottom-up DIB with the origin at the lower left corner. If
                      // "height" is negative, the bitmap is a top-down DIB with the origin
                      // at the upper left corner.
                      // - For YUV bitmaps, the bitmap is always top-down, regardless of the
                      // sign of "height". Decoders should offer YUV formats with positive
                      // "height", but for backward compatibility they should accept YUV
                      // formats with either positive or negative "height".
                      // - For compressed formats, height must be positive, regardless of
                      // image orientation.
      WORD planes;
                      // Specifies the number of planes for the target device. This value must
                      // be set to 1.
      WORD bitCount;
                      // Specifies the number of bits per pixel.
      FOURCC enum bitmapCompression compression;
                      // If the bitmap is compressed, this member is a FOURCC that specifies
                      // the compression.
                      // Value     Description
                      // BI_RLE8  A run-length encoded (RLE) format for bitmaps with 8
                      //              bpp. The compression format is a 2-byte format
                      //              consisting of a count byte followed by a byte containing a color index.
                      //              For more information, see Bitmap Compression.
                      // BI_RLE4  An RLE format for bitmaps with 4 bpp. The compression
                      //              format is a 2-byte format consisting of a count byte
                      //              followed by two word-length color indexes. For more
                      //              information, see Bitmap Compression.
                      // BI_JPEG  Windows 98/Me, Windows 2000/XP: Indicates that the
                      //              image is a JPEG image.
                      // BI_PNG  Windows 98/Me, Windows 2000/XP: Indicates that the
                      //              image is a PNG image.
                      // For uncompressed formats, the following values are possible:
                      // Value     Description
                      // BI_RGB  Uncompressed RGB.
                      // BI_BITFIELDS Specifies that the bitmap is not compressed and that
                      //              the color table consists of three DWORD color masks
                      //              that specify the red, green, and blue components,
                      //              respectively, of each pixel. This is valid when used
                      //              with 16- and 32-bpp bitmaps.
      DWORD imageSizeInBytes;
                      // Specifies the size, in bytes, of the image. This can be set to 0 for
                      // uncompressed RGB bitmaps.
      LONG xPelsPerMeter;
                      // Specifies the horizontal resolution, in pixels per meter, of the
                      // target device for the bitmap.
      LONG yPelsPerMeter;
                      // Specifies the vertical resolution, in pixels per meter, of the target
                      // device for the bitmap.
      DWORD numberOfColorsUsed;
                      // Specifies the number of color indices in the color table that are
                      // actually used by the bitmap
      DWORD numberOfColorsImportant;
                      // Specifies the number of color indices that are considered important
                      // for displaying the bitmap. If this value is zero, all colors are
                      // important.
      RGBQUAD colors[];
                      // If the bitmap is 8-bpp or less, the bitmap uses a color table, which
                      // immediately follows the BITMAPINFOHEADER. The color table consists of
                      // an array of RGBQUAD values. The size of the array is given by the
                      // "clrUsed" member. If "clrUsed" is zero, the array contains the
                      // maximum number of colors for the given bitdepth; that is,
                      // 2^"bitCount" colors.
 } BITMAPINFOHEADER;
 
Author:
Werner Randelshofer
  • Field Details

    • palette

      public IndexColorModel palette
      Index color model for RAW_RGB4 and RAW_RGB8 formats.
    • previousPalette

      public IndexColorModel previousPalette
    • previousData

      protected Object previousData
      Previous frame for delta compression.
    • bitCount

      public int bitCount
      Specifies the number of bits per pixel (bpp). For uncompressed formats, this value is the average number of bits per pixel. For compressed formats, this value is the implied bit depth of the uncompressed image, after the image has been decoded.
  • Constructor Details

    • VideoTrack

      public VideoTrack(int trackIndex, int fourCC, Format videoFormat)
  • Method Details