Appendix C. Pixel Packings and Color Spaces

This appendix explains

HD I/O Pixel Packings

This section presents each packing used by the HD I/O hardware, providing a diagram and its tokens in the pertinent libraries.

The following topics are covered:

Packings and Color Spaces

A packing

  • Determines which of the four components are sampled, either RGBA or CrYCb (sometimes called VYUA)

  • Determines the sampling pattern (for example, 4:4:4:4 or 4:2:2:4), which specifies where and how often each component of the image is sampled.

  • Allocates a certain number of bits to represent the component samples, and positions those samples along with possible padding in memory; each sample is an unsigned number, unless specified otherwise in the description of the packing

A color space

In most Silicon Graphics libraries, a single token encodes both color space and packing. For example, VL_PACKING_RGBA_8 is a 32-bit packing in the RGBA color space. For the VL of SGI advanced video products, the two parameters are specified separately with different controls: VL_PACKING and VL_COLORSPACE. The color space must be defined with the VL_COLORSPACE control.

Packing Diagram Conventions

In all illustrations, as you move from left to right:

  • Each byte goes from the most significant bit to the least significant bit

  • The bytes increase in memory address by 1

  • Component samples go from most significant bit to least significant bit

Each illustration shows the smallest repeating spatial pattern of component samples that is a multiple of 8 bits wide. No additional padding or alignment is to be inferred. For example, a 24-bit-per-pixel diagram, such as that for VL_PACKING_444_8 (Figure C-1), indicates 3-byte quantities packed together in memory; the values are not padded out to 32-bit boundaries.

Figure C-1. VL_PACKING_444_8

VL_PACKING_444_8

The packing defines a bit layout, but for convenience, as shown in Figure C-1, the component slots are filled with the RGBA or CrYCb color set as appropriate. (See “VL_COLORSPACE ” in Chapter 2 in Chapter 2, “Programming the HD I/O Board” for more information.) For chroma components, Cr and Cb are more accurate terms than V and U; however, this chapter uses the letters V and U in the illustrations of packings for typographical convenience.

Packings that use 4:2:2 sampling also show the location of each component sample: left and right for 4:2:2. The diagrams assume row-major, left-to-right ordering of pixels in memory.

An x (“don't care”) in a bit means the following:

  • Readers may get any garbage in this bit.

  • Writers can leave this bit as garbage.

A 0 means the following:

  • Readers may assume this bit is zero.

  • Writers can leave this bit as garbage.

An s indicates a padding bit that is a sign extension bit. For the HD I/O Board, this convention applies only to the more significant bits in 12-bit and 13-bit packings with rightward orientation; that is, VL_PACKING_4444_12_in_16_R and VL_PACKING_4444_13_in_16_R.

A p indicates a padding bit in the least significant bits of a left-justified 10-, 12-, or 13-bit word, such as VL_PACKING_R242_10_in_16_L or VL_PACKING_4444_13_in_16_L:

  • Readers can assume that the bits are replicated from the component found in the same word: With bits numbered starting with 0 for the least significant, there are n contiguous p bits to the right of the component. The p bits contain a copy of bits [9,9-n+1] of the component.

  • Writers can leave the p bits as garbage.

The HD I/O device natively transfers data of all packings in this appendix in real time.

Packings and Library Tokens

Following each packing diagram are comments and library tokens for that packing, listing, where applicable, the color set (RGBA or CrYCb) and the library (VL, OpenGL, and DM) for each library token.

  • DM refers to the tokens in /usr/lib/dmedia/dm_image.h, which are used by several libraries (libdmedia (dmParams, dmIC, dmColor), libmoviefile, and others). See “VL_COLORSPACE ” in Chapter 2 in Chapter 2, “Programming the HD I/O Board” for more information.

  • The VL includes the packing control value and a color-space control value; for example, VL_PACKING_4_8 + VL_COLORSPACE_{CCIR,YUV}. For the HD I/O Board, you set packing and color space separately for memory nodes. These definitions provide a more flexible way to specify memory layout of pixels and their color spaces.


    Note: Because of HDTV's multiple color spaces, “old style” packings, such as VL_PACKING_Y_8_P, are ambiguous and therefore not supported for the HD I/O Board. You must specify the packing and color space explicitly.


All HD I/O packings are also supported by the DIVO and DIVO-DVC boards.

Packing Naming Conventions

In packing tokens, the following applies:

  • _L and _R appended to the end of tokens with padding (0 bits) indicate that the 0 bits are at the left end or the right end of the pattern, respectively; for example, VL_PACKING_4444_10_in_16_L and VL_PACKING_4444_10_in_16_R).

  • X before the numerical part of the token at the end of a token indicates a component order other than the standard (RGBA or ABGR, CrYCbA or ACbYCr); for example, DM_IMAGE_PACKING_XBGR.

  • R before the numerical part of the token indicates reverse order of the components; for example, VL_PACKING_242_8 and VL_PACKING_R242_8 have the same pattern of component bits, but their order is reversed in VL_PACKING_R242_8.

  • Z at the end of the token name means that the packing is padded to the word boundary; for example, the packing in VL_PACKING_2424_10_10_10_2Z is 30 bits per pixel, but it is padded to 32 bits per pixel.

Table C-1 lists the HD I/O packings by number of bits in the pattern of component samples—the order in which they are described in the rest of this section.

Table C-1. HD I/O Packings

Packing

Bits

Color Space

VL_PACKING_ 242_8

16

CrYCb

VL_PACKING_R242_8

16

CrYCb

VL_PACKING_242_10

20

CrYCb

VL_PACKING_R242_10

20

CrYCb

VL_PACKING_444_8

24

RGB/CrYCb

VL_PACKING_R444_8

24

RGB/CrYCb

VL_PACKING_4444_8

32

RGBA/CrYCb

VL_PACKING_R4444_8

32

RGBA/CrYCb

VL_PACKING_R0444_8

32

RGBA/CrYCb

VL_PACKING_0444_8

32

RGBA/CrYCb

VL_PACKING_4444_10_10_10_2 

32

RGBA/CrYCb

VL_PACKING_R4444_10_10_10_2 

32

RGBA/CrYCb

VL_PACKING_2424_10_10_10_2Z

32

CrYCb

VL_PACKING_R2424_10_10_10_2Z

32

CrYCb

VL_PACKING_242_10_in_16_L

32

CrYCb

VL_PACKING_242_10_in_16_R

32

CrYCb

VL_PACKING_R242_10_in_16_L

32

CrYCb

VL_PACKING_R242_10_in_16_R

32

CrYCb

VL_PACKING_444_12_in_16_L

48

RGB

VL_PACKING_444_12_in_16_R

48

RGB

The packings are explained in these categories:

16-Bit Pixel Packings

Figure C-2 shows VL_PACKING_242_8, a 16-bit CrYCb packing.

Figure C-2. VL_PACKING_242_8

VL_PACKING_242_8


Note: Cr and Cb are more accurate terms than V and U; however, this appendix uses the letters V and U in the illustrations of packings for typographical convenience.


This rarely used packing is VL_PACKING_242_8 + VL_COLORSPACE_{CCIR,YUV} in the VL. It samples chroma and luma in a 4:2:2 pattern. See “Sampling Patterns”.

Figure C-3 shows VL_PACKING_R242_8, a 16-bit 4:2:2 CrYCb packing. The most commonly used 4:2:2 packing, it is used by other Silicon Graphics video hardware.

Figure C-3. VL_PACKING_R242_8

VL_PACKING_R242_8

This packing is

  • VL_PACKING_R242_8 + VL_COLORSPACE_{CCIR,YUV}

  • GL_YCRCB_422_SGIX GL_UNSIGNED_BYTE in OpenGL

  • DM_IMAGE_PACKING_CbYCrY in DM

20-Bit Pixel Packings

Figure C-4 shows VL_PACKING_242_10, a 20-bit CrYCb packing.

Figure C-4. VL_PACKING_242_10

VL_PACKING_242_10

This packing is VL_PACKING_242_10 + VL_COLORSPACE {CCIR,YUV}. It uses 4:2:2 sampling.

Figure C-5 shows VL_PACKING_R242_10, a 20-bit CrYCb packing.

Figure C-5. VL_PACKING_R242_10

VL_PACKING_R242_10

This packing is VL_PACKING_R242_10 + VL_COLORSPACE {CCIR,YUV}. It uses 4:2:2 sampling.


Note: Cr and Cb are more accurate terms than V and U; however, this appendix uses the letters V and U in the illustrations of packings for typographical convenience.


24-Bit Pixel Packings

Figure C-6 shows VL_PACKING_444_8, a 24-bit RGB/CrYCb packing.

Figure C-6. VL_PACKING_444_8

VL_PACKING_444_8

This packing is

  • RGB:

    • GL_RGB GL_UNSIGNED_BYTE in OpenGL

    • VL_PACKING_444_8 + VL_COLORSPACE_{RGB,RP175}

    • PM_RGB GL_UNSIGNED_BYTE on RealityEngine (IRIS GL)

    • DM_IMAGE_PACKING_RGB in DM

  • CrYCb: VL_PACKING_444_8 + VL_COLORSPACE_{YUV/YCRCB}

Figure C-7 shows VL_PACKING_R444_8, a 24-bit RGB/CrYCb packing.

Figure C-7. VL_PACKING_R444_8

VL_PACKING_R444_8

This packing is

  • RGB:

    • VL_PACKING_R444_8 + VL_COLORSPACE_{RGB,RP175}

    • DM_IMAGE_PACKING_BGR in DM

    • PM_BGR PM_UNSIGNED_BYTE on RealityEngine (IRIS GL)

  • CrYCb:

    • VL_PACKING_R444_8 + VL_COLORSPACE_{CCIR,YUV}

    • DM_IMAGE_PACKING_CbYCr in DM

32-Bit Pixel Packings

This section explains

OpenGL-Like 32-Bit Pixel Packing

Figure C-8 shows VL_PACKING_4444_8, an OpenGL-like 32-bit packing. This packing, supported by many Silicon Graphics video products, is the most commonly used OpenGL packing.

Figure C-8. VL_PACKING_4444_8

VL_PACKING_4444_8

This packing is

  • RGBA:

    • VL_PACKING_4444_8 + VL_COLORSPACE_{RGB,RP175}

    • GL_RGBA GL_UNSIGNED_BYTE in OpenGL (the default)

    • DM_IMAGE_PACKING_RGBA in DM

    • PM_RGBA PM_UNSIGNED_BYTE on RealityEngine (IRIS GL)

  • CrYCbA: VL_PACKING_4444_8 + VL_COLORSPACE_{CCIR,YUV}


    Note: Cr and Cb are more accurate terms than V and U; however, this appendix uses the letters V and U in the illustrations of packings for typographical convenience.


IRIS GL-Like 32-Bit Pixel Packings

Figure C-9 shows VL_PACKING_R4444_8, an IRIS GL-like 32-bit packing. This packing, supported by many Silicon Graphics video products, is the default IRIS GL packing.

Figure C-9. VL_PACKING_R4444_8

VL_PACKING_R4444_8

This packing is

  • RGBA:

    • VL_PACKING_R4444_8 + VL_COLORSPACE_{RGB,RP175}

    • GL_ABGR_EXT GL_UNSIGNED_BYTE in OpenGL

    • DM_IMAGE_PACKING_ABGR in DM

    • PM_ABGR PM_UNSIGNED_BYTE (default IRIS GL packing)

  • CrYCbA: VL_PACKING_R4444_8 + VL_COLORSPACE_{CCIR,YUV}

Figure C-10 shows VL_PACKING_R0444_8, an IRIS GL-like 32-bit packing. This packing is supported by many Silicon Graphics video products.

Figure C-10. VL_PACKING_R0444_8

VL_PACKING_R0444_8

  • RGB:

    • VL_PACKING_R0444_8 + VL_COLORSPACE_{RGB,RP175}

    • DM_IMAGE_PACKING_XBGR

      Use DM_IMAGE_PACKING_ABGR instead of this packing unless you specifically want to inform a piece of software (such as dmColor) not to spend processing time on the alpha channel.

  • CrYCb: VL_PACKING_R0444_8 + VL_COLORSPACE_{CCIR,YUV}


    Note: Cr and Cb are more accurate terms than V and U; however, this appendix uses the letters V and U in the illustrations of packings for typographical convenience.


32-Bit Pixel Packing for QuickTime

Figure C-11 shows VL_PACKING_0444_8, a 32-bit packing used for QuickTime files (uncompressed format without alpha).

Figure C-11. VL_PACKING_0444_8

VL_PACKING_0444_8

This packing is

  • RGB:

    • VL_PACKING_0444_8 + VL_COLORSPACE_{RGB,RP175}

    • DM_IMAGE_PACKING_XRGB in DM

  • CrYCb: VL_PACKING_0444_8 + VL_COLORSPACE_{CCIR,YUV}

4:4:4:4 10_10_10_2 32-Bit Pixel Packings

Figure C-12 shows VL_PACKING_4444_10_10_10_2, a 32-bit 4:4:4:4 10_10_10_2 packing.

Figure C-12. VL_PACKING_4444_10_10_10_2

VL_PACKING_4444_10_10_10_2

This packing is

  • RGBA:

    • VL_PACKING_4444_10_10_10_2 + VL_COLORSPACE_{RGB,RP175}

    • GL_RGBA GL_UNSIGNED_INT_10_10_10_2_EXT in OpenGL

  • CrYCbA: VL_PACKING_4444_10_10_10_2 + VL_COLORSPACE_{CCIR,YUV}

Figure C-13 shows VL_PACKING_R4444_10_10_10_2, an alternate 32-bit 4:4:4:4 10_10_10_2 packing.

Figure C-13. VL_PACKING_R4444_10_10_10_2

VL_PACKING_R4444_10_10_10_2

This packing is

  • RGBA:

    • VL_PACKING_R4444_10_10_10_2 + VL_COLORSPACE_{RGB,RP175}

    • GL_ABGR GL_UNSIGNED_INT_10_10_10_2_EXT in OpenGL

  • CrYCbA: VL_PACKING_R4444_10_10_10_2 + VL_COLORSPACE_{CCIR,YUV}

4:2:2:4 10_10_10_2 32-Bit Pixel Packings

Figure C-14 shows VL_PACKING_2424_10_10_10_2Z, the 4:2:2:4 10_10_10_2 32-bit CrYCbA packing.

Figure C-14. VL_PACKING_2424_10_10_10_2Z

VL_PACKING_2424_10_10_10_2Z

This packing is VL_PACKING_2424_10_10_10_2Z + VL_COLORSPACE_{CCIR,YUV} in the VL.

Figure C-15 shows VL_PACKING_R2424_10_10_10_2Z, an alternate 4:2:2:4 10_10_10_2 32-bit packing.

Figure C-15. VL_PACKING_R2424_10_10_10_2Z

VL_PACKING_R2424_10_10_10_2Z

This packing is VL_PACKING_R2424_10_10_10_2Z + VL_COLORSPACE_{CCIR,YUV} in the VL.


Note: Cr and Cb are more accurate terms than V and U; however, this appendix uses the letters V and U in the illustrations of packings for typographical convenience.


4:2:2 10_in_16 32-Bit Pixel Packings

The diagrams of packings that use 4:2:2 sampling show the location (left and right) of each component sample. Only DIVO and DIVO-DVC use this packing.

Figure C-16 shows VL_PACKING_242_10_in_16_L, a 4:2:2 10_in_16 32-bit CrYCb packing. This packing is supported by several Silicon Graphics video products. For an explanation of the p bit, see “Packing Diagram Conventions”.

Figure C-16. VL_PACKING_242_10_in_16_L

VL_PACKING_242_10_in_16_L

This packing is VL_PACKING_242_10_in_16_L + VL_COLORSPACE_{CCIR,YUV} in the VL.

Figure C-17 shows VL_PACKING_242_10_in_16_R, a 4:2:2 10_in_16 32-bit CrYCb packing.

Figure C-17. VL_PACKING_242_10_in_16_R

VL_PACKING_242_10_in_16_R

This packing is CrYCb VL_PACKING_242_10_in_16_R + VL_COLORSPACE_{CCIR,YUV} in the VL.

Figure C-18 shows VL_PACKING_R242_10_in_16_L, a 4:2:2 10_in_16 32-bit CrYCb packing. This packing is supported by several Silicon Graphics video products. For an explanation of the p bit, see “Packing Diagram Conventions”.

Figure C-18. VL_PACKING_R242_10_in_16_L

VL_PACKING_R242_10_in_16_L

This packing is VL_PACKING_R242_10_in_16_L + VL_COLORSPACE_{CCIR,YUV} in the VL.

Figure C-19 shows VL_PACKING_R242_10_in_16_R, a 4:2:2 10_in_16 32-bit CrYCb packing.

Figure C-19. VL_PACKING_R242_10_in_16_R

VL_PACKING_R242_10_in_16_R

This packing is CrYCb VL_PACKING_R242_10_in_16_R + VL_COLORSPACE_{CCIR,YUV} in the VL.


Note: Cr and Cb are more accurate terms than V and U; however, this appendix uses the letters V and U in the illustrations of packings for typographical convenience.


48-Bit Pixel Packings

Figure C-20 shows VL_PACKING_444_12_in_16_L, a 48-bit RGB packing. For an explanation of the p bit, see “Packing Diagram Conventions”.

Figure C-20. VL_PACKING_444_12_in_16_L

VL_PACKING_444_12_in_16_L

This packing is VL_PACKING_444_12_in_16_L + VL_COLORSPACE_{RGB,RP175} in the VL, new style.

Figure C-21 shows VL_PACKING_444_12_in_16_R, a 64-bit RGBA packing for use with extended RGB components.

Figure C-21. VL_PACKING_444_12_in_16_R

VL_PACKING_444_12_in_16_R

This packing is VL_PACKING_444_12_in_16_R + VL_COLORSPACE_{RGB,RP175} in the VL, new style.


Note: The components in this packing are signed, with positive and negative values varying by color space. The s in the more significant bits in Figure C-21 indicates a sign extension padding bit.


Sampling Patterns

Sampling patterns are

4:4:4 and 4:4:4:4 Sampling

Some of the diagrams in the “HD I/O Pixel Packings” section indicate 4:4:4 or 4:4:4:4 sampling. This video industry terminology means that each of the three or four components is sampled at every pixel. Figure C-22 diagrams this sampling pattern.

Figure C-22. 4:4:4 Sampling

4:4:4 Sampling

4:2:2 and 4:2:2:4 Sampling

The packings shown in diagrams that indicate 4:2:2 sampling make sense only in the CrYCbA color spaces. For every two pixels, there are two luma samples (two Ys) but only one chroma sample (one sample of Cr and Cb, which together determine the chroma), as shown in Figure C-23.

Figure C-23. 4:2:2 Sampling

4:2:2 Sampling

The chroma samples belong at the same instant in space as the left Y sample (the chrominance samples and the left Y are co-sited). The diagrams for 4:2:2 packings in the “HD I/O Pixel Packings” section of this appendix show the location of each Y, Cr, or Cb component as left or right. The first pixel of each line is a left pixel.

Converting 4:4:4 video to 4:2:2 video is like converting 44.1 kHz audio into 22.05 kHz audio: just dropping every other Cr,Cb sample yields extremely poor results. Video devices that need to convert between 4:4:4 and 4:2:2 use carefully designed filters. The characteristics of the required filter are specified in ITU-R BT.601 (Rec. 601).

4:2:2 sampled packings that also include alpha are called 4:2:2:4. This method has one alpha value per pixel, like the Y value.