UYVY(3)
NAME
UYVY − UYVY compressor/decompressor for compressed image sequences
DESCRIPTION
The UYVY compression type provides access to the raw 4:2:2 data produced by the SunVideo card. This compression type is useful if you want to pass the raw data through the SunVideo card and use your own software compression on the raw data.
The UYVY compression type is supplied as part of the SunVideo packages and is not part of the normal XIL delivery. Therefore, even though the SunVideo card is not used in decompressing UYVY data, you must have the SunVideo software (SUNWrtvcu package) installed to decompress a CIS created with the UYVY compressor. The SUNWrtvcu package includes accelerated XIL molecules to decompress and display UYVY CIS’s. See the SunVideo User’s Guide for details.
The Layout of UYVY Data
There are two pixels stored in each UYVY word. Each of the data values (U, Y0, V, and Y1) are 8-bit values.
+-------+-------+-------+-------+
| U | Y0 | V | Y1 |
+-------+-------+-------+-------+
8 bits 8 bits 8 bits 8 bits
\______________ _____________/
\/
UYVY word
The values for U and V are the same for each pixel in a UYVY word. The Y value of a pixel depends upon whether the x-location of the pixel is even or odd. If the x-location of the pixel is even (x=0), the Y value is Y0. If the x-location of the pixel is odd (x=1), the Y value is Y1.
Accessing UYVY Data
To access UYVY data, use the xil_cis_get_bits_ptr(3) function. This function returns a pointer to the beginning of the data. The following example illustrates accessing UYVY data.
void
UYVY_get_pixel(XilCis cis, int x, int y)
/∗ Example routine to print the YUV values of a single pixel from
∗ a UYVY CIS. ∗/
{
Xil_unsigned32 ∗data;
int nframes;
int nbytes;
int width;
Xil_unsigned32 uyvy;
Xil_unsigned8 uval, yval, vval;
/∗ get a 32 bit pointer to the raw 4:2:2 data ∗/
data = (Xil_unsigned32 ∗) xil_cis_get_bits_ptr(cis, &nbytes, &nframes);
/∗ figure out the width of the images in the CIS ∗/
width = xil_imagetype_get_width(xil_cis_get_output_type(cis));
/∗ There are two pixels stored in each UYVY word ∗/
/∗ Note that the UYVY data is guaranteed to be word aligned so it is not
∗ necessary to read it a byte at a time ∗/
uyvy = data[(y ∗ width + x) / 2];
uval = uyvy >> 24;
vval = (uyvy >> 8) & 0xff;
/∗ if the x-location of the pixel is odd, use the second y value;
∗ otherwise, use the first y value ∗/
yval = (x & 0x1) ? (uyvy & 0xff) : ((uyvy >> 16) & 0xff);
printf("YUV = (%x,%x,%x)\n", yval, uval, vval);
/∗ return the read frame to where it was at the beginning of this
∗ routine ∗/
xil_cis_seek(cis, -nframes, 1);
}
Creating a CIS
To compress a compressed image sequence (CIS) with the XIL UYVY compressor, specify "UYVY" for the compressorname argument in xil_cis_create(3).
UYVY Attributes
There are only two UYVY attributes: WIDTH and HEIGHT. Both are "set-only" attributes. Use xil_cis_set_attribute(3) to set these attributes. It is only necessary to set them when decompressing a bitstream that has been input via a call to xil_cis_put_bits(3) or xil_cis_put_bits_ptr(3) since the width and height are not encoded in the bitstream, as is the case for certain other compressors, such as Jpeg(3).
EXAMPLES
The following example opens and closes a UYVY CIS using the XIL library:
XilSystemState State;
XilCis cis;
State = xil_open();
cis = xil_cis_create(State, "UYVY");
-- calls to UYVY-specific compression routines --
xil_cis_destroy(cis);
xil_close(State);
The following example sets the WIDTH and HEIGHT attributes of a UYVY CIS.
XilCis cis;
int width, height;
xil_cis_set_attribute(cis, "WIDTH", (void ∗) width);
xil_cis_set_attribute(cis, "HEIGHT", (void ∗) height);
NOTES
The xil_cis_set_attribute(3) and xil_cis_get_attribute(3) calls are used to modify the default behavior of a specific compressor. Generic attributes of compressors are set by individual function calls.
SEE ALSO
xil_cis_create(3), xil_cis_set_attribute(3), xil_cis_get_bits_ptr(3), xil_compress(3), xil_decompress(3).
SunOS 5.4 — Last change: 29 April 1994