Packed RGB formats — Packed RGB formats


These formats are designed to match the pixel formats of typical PC graphics frame buffers. They occupy 8, 16, 24 or 32 bits per pixel. These are all packed-pixel formats, meaning all the data for a pixel lie next to each other in memory.

Table 2.18. Packed RGB Image Formats

IdentifierCode Byte 0 in memory Byte 1 Byte 2 Byte 3
  Bit76543210 76543210 76543210 76543210
V4L2_PIX_FMT_RGB332'RGB1' r2r1r0g2g1g0b1b0                          
V4L2_PIX_FMT_ARGB444'AR12' g3g2g1g0b3b2b1b0 a3a2a1a0r3r2r1r0                 
V4L2_PIX_FMT_XRGB444'XR12' g3g2g1g0b3b2b1b0 ----r3r2r1r0                 
V4L2_PIX_FMT_ARGB555'AR15' g2g1g0b4b3b2b1b0 ar4r3r2r1r0g4g3                 
V4L2_PIX_FMT_XRGB555'XR15' g2g1g0b4b3b2b1b0 -r4r3r2r1r0g4g3                 
V4L2_PIX_FMT_RGB565'RGBP' g2g1g0b4b3b2b1b0 r4r3r2r1r0g5g4g3                 
V4L2_PIX_FMT_ARGB555X'AR15' | (1 << 31) ar4r3r2r1r0g4g3 g2g1g0b4b3b2b1b0                 
V4L2_PIX_FMT_XRGB555X'XR15' | (1 << 31) -r4r3r2r1r0g4g3 g2g1g0b4b3b2b1b0                 
V4L2_PIX_FMT_RGB565X'RGBR' r4r3r2r1r0g5g4g3 g2g1g0b4b3b2b1b0                 
V4L2_PIX_FMT_BGR24'BGR3' b7b6b5b4b3b2b1b0 g7g6g5g4g3g2g1g0 r7r6r5r4r3r2r1r0        
V4L2_PIX_FMT_RGB24'RGB3' r7r6r5r4r3r2r1r0 g7g6g5g4g3g2g1g0 b7b6b5b4b3b2b1b0        
V4L2_PIX_FMT_BGR666'BGRH' b5b4b3b2b1b0g5g4 g3g2g1g0r5r4r3r2 r1r0------ --------
V4L2_PIX_FMT_ABGR32'AR24' b7b6b5b4b3b2b1b0 g7g6g5g4g3g2g1g0 r7r6r5r4r3r2r1r0 a7a6a5a4a3a2a1a0
V4L2_PIX_FMT_XBGR32'XR24' b7b6b5b4b3b2b1b0 g7g6g5g4g3g2g1g0 r7r6r5r4r3r2r1r0 --------
V4L2_PIX_FMT_ARGB32'BA24' a7a6a5a4a3a2a1a0 r7r6r5r4r3r2r1r0 g7g6g5g4g3g2g1g0 b7b6b5b4b3b2b1b0
V4L2_PIX_FMT_XRGB32'BX24' -------- r7r6r5r4r3r2r1r0 g7g6g5g4g3g2g1g0 b7b6b5b4b3b2b1b0

Bit 7 is the most significant bit.

The usage and value of the alpha bits (a) in the ARGB and ABGR formats (collectively referred to as alpha formats) depend on the device type and hardware operation. Capture devices (including capture queues of mem-to-mem devices) fill the alpha component in memory. When the device outputs an alpha channel the alpha component will have a meaningful value. Otherwise, when the device doesn't output an alpha channel but can set the alpha bit to a user-configurable value, the V4L2_CID_ALPHA_COMPONENT control is used to specify that alpha value, and the alpha component of all pixels will be set to the value specified by that control. Otherwise a corresponding format without an alpha component (XRGB or XBGR) must be used instead of an alpha format.

Output devices (including output queues of mem-to-mem devices and video output overlay devices) read the alpha component from memory. When the device processes the alpha channel the alpha component must be filled with meaningful values by applications. Otherwise a corresponding format without an alpha component (XRGB or XBGR) must be used instead of an alpha format.

The XRGB and XBGR formats contain undefined bits (-). Applications, devices and drivers must ignore those bits, for both capture and output devices.

Example 2.1. V4L2_PIX_FMT_BGR24 4 × 4 pixel image

Byte Order. Each cell is one byte.

start + 0:B00G00R00B01G01R01B02G02R02B03G03R03
start + 12:B10G10R10B11G11R11B12G12R12B13G13R13
start + 24:B20G20R20B21G21R21B22G22R22B23G23R23
start + 36:B30G30R30B31G31R31B32G32R32B33G33R33

Formats defined in Table 2.19, “Deprecated Packed RGB Image Formats” are deprecated and must not be used by new drivers. They are documented here for reference. The meaning of their alpha bits (a) is ill-defined and interpreted as in either the corresponding ARGB or XRGB format, depending on the driver.

Table 2.19. Deprecated Packed RGB Image Formats

IdentifierCode Byte 0 in memory Byte 1 Byte 2 Byte 3
  Bit76543210 76543210 76543210 76543210
V4L2_PIX_FMT_RGB444'R444' g3g2g1g0b3b2b1b0 a3a2a1a0r3r2r1r0                 
V4L2_PIX_FMT_RGB555'RGBO' g2g1g0b4b3b2b1b0 ar4r3r2r1r0g4g3                 
V4L2_PIX_FMT_RGB555X'RGBQ' ar4r3r2r1r0g4g3 g2g1g0b4b3b2b1b0                 
V4L2_PIX_FMT_BGR32'BGR4' b7b6b5b4b3b2b1b0 g7g6g5g4g3g2g1g0 r7r6r5r4r3r2r1r0 a7a6a5a4a3a2a1a0
V4L2_PIX_FMT_RGB32'RGB4' a7a6a5a4a3a2a1a0 r7r6r5r4r3r2r1r0 g7g6g5g4g3g2g1g0 b7b6b5b4b3b2b1b0

A test utility to determine which RGB formats a driver actually supports is available from the LinuxTV v4l-dvb repository. See for access instructions.