Appendix C. Pixel Packings and Color Spaces

This appendix explains

Packings

This section presents each packing used by the OCTANE Personal Video option, giving a diagram and its tokens in the pertinent libraries. It explains

Packings and Color Spaces

A packing

  • determines which of the four components are sampled, either RGBA or VYUA (more correctly, CrYCbA)

  • determines the sampling pattern (for example, 4:4:4 or 4:2:2), 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.

A color space

  • determines the color in each component by specifying the color set

  • specifies a canonical minimum and maximum value for each component, either full-range or headroom-range

    See “Color Spaces” in Chapter 3 for an explanation.

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. In the VL of the OCTANE Personal Video option and other advanced 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_BGR_8_P and VL_PACKING_UYV_8_P, indicates 3-byte quantities packed together in memory. The values are not padded out to 32-bit boundaries; see Figure C-1.

Figure C-1. VL_PACKING_BGR_8_P and VL_PACKING_UYV_8_P

Figure C-1 VL_PACKING_BGR_8_P and VL_PACKING_UYV_8_P

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

  • Readers may get any garbage in the bit.

  • Writers may leave the bit as garbage.

A 0 means

  • Readers may assume the bit is zero.

  • Writers must zero out the bit.


    Note: Writers in a memory-to-video VL path may leave the bit as garbage.


The packing defines a bit layout, but for convenience, as shown in Figure C-1, the component slots are filled with the RGBA or VYUA color set where appropriate. See “Color Spaces” in Chapter 3 for an explanation.


Note: For chroma components, Cr and Cb are more accurate terms than V and U, because the analog NTSC video specification ANSI/SMPTE 170M uses V and U with a slightly different meaning. 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.

The OCTANE Personal Video device can natively transfer data of all the packings shown in this appendix in real time except VL_PACKING_Y_8_P and VL_PACKING_RGB_332_P.

Packings and Library Tokens

Accompanying each packing diagram are comments and library tokens for that packing. For most packings, two indications are given for VL:

  • The main reference uses the old-style token, for example, VL_PACKING_Y_8_P. These packings encode both the bit layout (packing) and color space.

  • New-style VL tokens are included for reference. The indication includes the new-style packing control value and a color-space control value; for example, VL_PACKING_4_8 + VL_COLORSPACE_{CCIR,YUV}.

For the OCTANE Personal Video option, you set packing and color space separately for memory nodes. The new definitions provide a more flexible way to specify memory layout of pixels and their color spaces.

DM refers to the tokens in /usr/lib/dmedia/dm_image.h, which are used by several libraries (libdmedia (dmParams, dmIC, dmColor), libmoviefile, libmovieplay, and others). See “Color Spaces” in Chapter 3 for an explanation.

Packing Naming Conventions (New-Style Tokens)

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.

  • 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 the 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 OCTANE Personal Video packings in the order of the 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. OCTANE Personal Video Packings

Old-Style Packing and Color-Space Token

Bits

Color Space

New-Style Packing Name

VL_PACKING_Y_8_P

8

VYUA monochrome/luma only

VL_PACKING_4_8

VL_PACKING_RGB_332_P

8

RGBA

VL_PACKING_R444_332

VL_PACKING_YVYU_422_8

16

VYUA

VL_PACKING_R242_8

VL_PACKING_BGR_8_P

24

RGBA

VL_PACKING_444_8

VL_PACKING_UYV_8_P

24

VYUA

VL_PACKING_444_8

VL_PACKING_ABGR_8

32

RGBA

VL_PACKING_4444_8

VL_PACKING_AUYV_8 or
VL_PACKING_AUYV_4444_8

32

VYUA

VL_PACKING_4444_8

VL_PACKING_RGBA_8

32

RGBA

VL_PACKING_R4444_8

VL_PACKING_YUVA_4444_8

32

VYUA

VL_PACKING_R4444_8

VL_PACKING_RGB_8

32

RGBA

VL_PACKING_R0444_8

VL_PACKING_YVYU_422_10

32

VYUA

VL_PACKING_R242_10_in_16_L


8-Bit Pixel Packings

Figure C-2 shows the VL_PACKING_Y_8_P, an 8-bit packing useful for VYUA monochrome (luma) only.

Figure C-2. VL_PACKING_Y_8_P

Figure C-2 VL_PACKING_Y_8_P

This packing is

  • VL_PACKING_4_8 + VL_COLORSPACE_{CCIR,YUV} in the VL, new style

  • GL_LUMINANCE GL_UNSIGNED_BYTE in OpenGL

  • DM_IMAGE_PACKING_LUMINANCE in DM

This packing is not native to the OCTANE Personal Video option, but is implemented in software.

Figure C-3 shows VL_PACKING_RGB_332_P, an 8-bit packing in the RGBA color space.

Figure C-3. VL_PACKING_RGB_332_P

Figure C-3 VL_PACKING_RGB_332_P

This packing is

  • VL_PACKING_R444_332 + VL_COLORSPACE_{RGB,RP175} in the VL, new style

  • VL_PACKING_RGB_332_P in the VL, old style

  • DM_IMAGE_PACKING_BGR233 in DM

This packing is not native to the OCTANE Personal Video option, but is implemented in software.

16-Bit Pixel Packing

Figure C-4 shows VL_PACKING_YVYU_422_8, a 16-bit 4:2:2 VYUA packing. The most commonly used 4:2:2 packing, it is used by other Silicon Graphics video hardware as well as the OCTANE Personal Video option.

Figure C-4. VL_PACKING_YVYU_422_8

Figure C-4 VL_PACKING_YVYU_422_8

This packing is

  • VL_PACKING_R242_8 + VL_COLORSPACE_{CCIR,YUV} in the VL, new style

  • GL_YCRCB_422_SGIX GL_UNSIGNED_BYTE in OpenGL

  • DM_IMAGE_PACKING_CbYCrY in DM

24-Bit Pixel Packings

Figure C-5 shows VL_PACKING_BGR_8_P and VL_PACKING_UYV_8_P, which are 24-bit RGBA/VYUA packings.

Figure C-5. VL_PACKING_BGR_8_P and VL_PACKING_UYV_8_P

Figure C-5 VL_PACKING_BGR_8_P and VL_PACKING_UYV_8_P

VL_PACKING_BGR_8_P is

  • GL_RGB GL_UNSIGNED_BYTE in OpenGL

  • VL_PACKING_444_8 + VL_COLORSPACE_{RGB,RP175} in the VL, new style

  • DM_IMAGE_PACKING_RGB in DM

VL_PACKING_UYV_8_P is VL_PACKING_444_8 + VL_COLORSPACE_{RGB,RP175} in the VL, new style.

32-Bit Pixel Packings

Figure C-6 shows VL_PACKING_ABGR_8 andVL_PACKING_AUYV_8. These packings are supported by many Silicon Graphics video products.

Figure C-6. VL_PACKING_ABGR_8 andVL_PACKING_AUYV_8

Figure C-6 VL_PACKING_ABGR_8 andVL_PACKING_AUYV_8

VL_PACKING_ABGR_8 is

  • VL_PACKING_4444_8 + VL_COLORSPACE_{RGB,RP175} in the VL, new style

  • GL_RGBA GL_UNSIGNED_BYTE in OpenGL (most commonly used OpenGL packing)

  • DM_IMAGE_PACKING_RGBA in DM

VL_PACKING_AUYV_8 is

  • VL_PACKING_4444_8 + VL_COLORSPACE_{CCIR,YUV} in the VL, new style

  • also VL_PACKING_AUYV_4444_8 in the VL, old style

Figure C-7 shows VL_PACKING_RGBA_8 and VL_PACKING_YUVA_4444_8, which are supported by many Silicon Graphics video products. VL_PACKING_RGBA_8 is the default IRIS GL packing.

Figure C-7. VL_PACKING_RGBA_8 and VL_PACKING_YUVA_4444_8

Figure C-7 VL_PACKING_RGBA_8 and VL_PACKING_YUVA_4444_8

VL_PACKING_RGBA_8 is

  • VL_PACKING_R4444_8 + VL_COLORSPACE_{RGB,RP175} in the VL, new style

  • PM_ABGR PM_UNSIGNED_BYTE in IRIS GL (the default)

  • GL_ABGR_EXT GL_UNSIGNED_BYTE in OpenGL

  • DM_IMAGE_PACKING_ABGR in DM

VL_PACKING_YUVA_4444_8 is VL_PACKING_R4444_8 + VL_COLORSPACE_{CCIR,YUV} in the VL, new style.

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

Figure C-8. VL_PACKING_RGB_8

Figure C-8 VL_PACKING_RGB_8

VL_PACKING_RGB_8 is

  • VL_PACKING_R0444_8 + VL_COLORSPACE_{RGB,RP175} in the VL, new style

  • 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.

Figure C-9 shows VL_PACKING_YVYU_422_10, a 4:2:2 10_in_16 32-bit VYUA packing. This packing is supported by several recent Silicon Graphics video products.

Figure C-9. VL_PACKING_YVYU_422_10

Figure C-9 VL_PACKING_YVYU_422_10

This packing is

  • 4:2:2 sampling (2 bits of A); see “Sampling Patterns,” later in this appendix

  • VL_PACKING_R242_10_in_16_L + VL_COLORSPACE_{CCIR,YUV} in the VL, new style

Sampling Patterns

Sampling patterns are

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

Some of the packing diagrams earlier in this appendix 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-11 diagrams this sampling pattern.

Figure C-10. 4:4:4 Sampling

Figure C-10 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 VYUA color spaces. For every two pixels, there are two luma samples (two Y's) but only one chroma sample (one sample of Cr and Cb, which together determine the chroma), as shown in Figure C-11.

Figure C-11. 4:2:2 Sampling

Figure C-11 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 “Packings” section of this appendix show the spatial 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-4 (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.