ATI VCR1
This page is based on the document 'Simple YUV Coding Formats' by Mike Melanson found here: http://multimedia.cx/simple-yuv.txt.
- FourCCs: VCR1
- Company: ATI
- Samples: http://samples.mplayerhq.hu/V-codecs/ATI-VCR12/
The ATI VCR1 codec, identified by the fourcc VCR1, uses differential coding to pack Y samples. C samples are left alone. VCR1 is based on a YUV 4:1:0 colorspace. This means that each pixel in a 4x4 block has a unique Y sample while the entire block shares a Cb and a Cr sample.
Data Format
The format of a VCR1-encoded video chunk is as follows:
bytes 0-31 16 16-bit, signed, little-endian deltas used in this frame bytes 32.. encoded YUV data
The deltas are apparently 16 bits in width which is somewhat irrelevant since the Y samples to which they are applied are only 8-bit numbers.
The YUV data is coded after the initial deltas. The data is coded as:
luminance/chrominance line luminance line luminance line luminance line [...]
Every fourth line, starting with line 0, contains both luminance (Y) and chrominance (C) data. The other lines only contain Y data.
Each Y/C line begins with 4 offsets to be used when decoding the Y data for the next 4 lines:
byte 0 offset for this line's Y data byte 1 offset for second line's Y data byte 2 offset for third line's Y data byte 3 offset for fourth line's Y data bytes 4.. Y/C data
For the remainder of the data on a Y/C line, these 6 pieces of data:
Y0 Y1 Y2 Y3 U V
are encoded within groups of 4 bytes of the bytestream. Y0..Y3 are the next 4 Y samples in the line while U and V are the C samples for the 4 Y samples as well as the 4 Y samples on each of the next 3 lines (since this is a YUV 4:1:0 colorspace). The 4 bytes in the group have the following meaning:
byte0 byte1 byte2 byte3 Y3i Y2i V Y1i Y0i U
Bytes 1 and 3 correspond to the V and U samples, respectively. Bytes 0 and 2 break down into 4 4-bit nibbles which do not actually represent the Y samples. Instead, they index into the delta table from the start of the frame. The indexed signed delta is applied to this line's Y offset. For example,
Y0 = offset + delta_table [ byte2 & 0x0F ] Y3 = offset + delta_table [ byte0 >> 4 ]
For the other lines that only contain Y data, each group of 4 bytes decodes to 8 Y samples in a similar manner as on the Y/C lines:
byte0 byte1 byte2 byte3 Y5i Y4i Y7i Y6i Y1i Y0i Y3i Y2i