Defining Colorspaces in V4L2

In V4L2 colorspaces are defined by four values. The first is the colorspace identifier (enum v4l2_colorspace) which defines the chromaticities, the default transfer function, the default Y'CbCr encoding and the default quantization method. The second is the transfer function identifier (enum v4l2_xfer_func) to specify non-standard transfer functions. The third is the Y'CbCr encoding identifier (enum v4l2_ycbcr_encoding) to specify non-standard Y'CbCr encodings and the fourth is the quantization identifier (enum v4l2_quantization) to specify non-standard quantization methods. Most of the time only the colorspace field of struct v4l2_pix_format or struct v4l2_pix_format_mplane needs to be filled in. Note that the default R'G'B' quantization is full range for all colorspaces except for BT.2020 which uses limited range R'G'B' quantization.

Table 2.4. V4L2 Colorspaces

IdentifierDetails
V4L2_COLORSPACE_DEFAULTThe default colorspace. This can be used by applications to let the driver fill in the colorspace.
V4L2_COLORSPACE_SMPTE170MSee the section called “Colorspace SMPTE 170M (V4L2_COLORSPACE_SMPTE170M)”.
V4L2_COLORSPACE_REC709See the section called “Colorspace Rec. 709 (V4L2_COLORSPACE_REC709)”.
V4L2_COLORSPACE_SRGBSee the section called “Colorspace sRGB (V4L2_COLORSPACE_SRGB)”.
V4L2_COLORSPACE_ADOBERGBSee the section called “Colorspace Adobe RGB (V4L2_COLORSPACE_ADOBERGB)”.
V4L2_COLORSPACE_BT2020See the section called “Colorspace BT.2020 (V4L2_COLORSPACE_BT2020)”.
V4L2_COLORSPACE_DCI_P3See the section called “Colorspace DCI-P3 (V4L2_COLORSPACE_DCI_P3)”.
V4L2_COLORSPACE_SMPTE240MSee the section called “Colorspace SMPTE 240M (V4L2_COLORSPACE_SMPTE240M)”.
V4L2_COLORSPACE_470_SYSTEM_MSee the section called “Colorspace NTSC 1953 (V4L2_COLORSPACE_470_SYSTEM_M)”.
V4L2_COLORSPACE_470_SYSTEM_BGSee the section called “Colorspace EBU Tech. 3213 (V4L2_COLORSPACE_470_SYSTEM_BG)”.
V4L2_COLORSPACE_JPEGSee the section called “Colorspace JPEG (V4L2_COLORSPACE_JPEG)”.
V4L2_COLORSPACE_RAWThe raw colorspace. This is used for raw image capture where the image is minimally processed and is using the internal colorspace of the device. The software that processes an image using this 'colorspace' will have to know the internals of the capture device.

Table 2.5. V4L2 Transfer Function

IdentifierDetails
V4L2_XFER_FUNC_DEFAULTUse the default transfer function as defined by the colorspace.
V4L2_XFER_FUNC_709Use the Rec. 709 transfer function.
V4L2_XFER_FUNC_SRGBUse the sRGB transfer function.
V4L2_XFER_FUNC_ADOBERGBUse the AdobeRGB transfer function.
V4L2_XFER_FUNC_SMPTE240MUse the SMPTE 240M transfer function.
V4L2_XFER_FUNC_NONEDo not use a transfer function (i.e. use linear RGB values).
V4L2_XFER_FUNC_DCI_P3Use the DCI-P3 transfer function.
V4L2_XFER_FUNC_SMPTE2084Use the SMPTE 2084 transfer function.

Table 2.6. V4L2 Y'CbCr Encodings

IdentifierDetails
V4L2_YCBCR_ENC_DEFAULTUse the default Y'CbCr encoding as defined by the colorspace.
V4L2_YCBCR_ENC_601Use the BT.601 Y'CbCr encoding.
V4L2_YCBCR_ENC_709Use the Rec. 709 Y'CbCr encoding.
V4L2_YCBCR_ENC_XV601Use the extended gamut xvYCC BT.601 encoding.
V4L2_YCBCR_ENC_XV709Use the extended gamut xvYCC Rec. 709 encoding.
V4L2_YCBCR_ENC_SYCCUse the extended gamut sYCC encoding.
V4L2_YCBCR_ENC_BT2020Use the default non-constant luminance BT.2020 Y'CbCr encoding.
V4L2_YCBCR_ENC_BT2020_CONST_LUMUse the constant luminance BT.2020 Yc'CbcCrc encoding.

Table 2.7. V4L2 Quantization Methods

IdentifierDetails
V4L2_QUANTIZATION_DEFAULTUse the default quantization encoding as defined by the colorspace. This is always full range for R'G'B' (except for the BT.2020 colorspace) and usually limited range for Y'CbCr.
V4L2_QUANTIZATION_FULL_RANGEUse the full range quantization encoding. I.e. the range [0…1] is mapped to [0…255] (with possible clipping to [1…254] to avoid the 0x00 and 0xff values). Cb and Cr are mapped from [-0.5…0.5] to [0…255] (with possible clipping to [1…254] to avoid the 0x00 and 0xff values).
V4L2_QUANTIZATION_LIM_RANGEUse the limited range quantization encoding. I.e. the range [0…1] is mapped to [16…235]. Cb and Cr are mapped from [-0.5…0.5] to [16…240].