The SMPTE 170M standard defines the colorspace used by NTSC and
PAL and by SDTV in general. The default transfer function is
V4L2_XFER_FUNC_709. The default Y’CbCr encoding is
V4L2_YCBCR_ENC_601. The default Y’CbCr quantization is limited
range. The chromaticities of the primary colors and the white reference
are:
The red, green and blue chromaticities are also often referred to as the
SMPTE C set, so this colorspace is sometimes called SMPTE C as well.
The transfer function defined for SMPTE 170M is the same as the one
defined in Rec. 709.
Inverse Transfer function:
The luminance (Y’) and color difference (Cb and Cr) are obtained with
the following V4L2_YCBCR_ENC_601 encoding:
Y’ is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5]. This conversion to Y’CbCr is identical to the one defined in
the ITU BT.601 standard and this colorspace is sometimes called
BT.601 as well, even though BT.601 does not mention any color primaries.
The default quantization is limited range, but full range is possible
although rarely seen.
The ITU BT.709 standard defines the colorspace used by HDTV in
general. The default transfer function is V4L2_XFER_FUNC_709. The
default Y’CbCr encoding is V4L2_YCBCR_ENC_709. The default Y’CbCr
quantization is limited range. The chromaticities of the primary colors
and the white reference are:
The full name of this standard is Rec. ITU-R BT.709-5.
Transfer function. Normally L is in the range [0…1], but for the
extended gamut xvYCC encoding values outside that range are allowed.
Inverse Transfer function:
The luminance (Y’) and color difference (Cb and Cr) are obtained with
the following V4L2_YCBCR_ENC_709 encoding:
Y’ is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5].
The default quantization is limited range, but full range is possible
although rarely seen.
The V4L2_YCBCR_ENC_709 encoding described above is the default for
this colorspace, but it can be overridden with V4L2_YCBCR_ENC_601,
in which case the BT.601 Y’CbCr encoding is used.
Two additional extended gamut Y’CbCr encodings are also possible with
this colorspace:
The xvYCC 709 encoding (V4L2_YCBCR_ENC_XV709, xvYCC) is
similar to the Rec. 709 encoding, but it allows for R’, G’ and B’ values
that are outside the range [0…1]. The resulting Y’, Cb and Cr values are
scaled and offset according to the limited range formula:
The xvYCC 601 encoding (V4L2_YCBCR_ENC_XV601, xvYCC) is
similar to the BT.601 encoding, but it allows for R’, G’ and B’ values
that are outside the range [0…1]. The resulting Y’, Cb and Cr values are
scaled and offset according to the limited range formula:
Y’ is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5] and quantized without further scaling or offsets.
The non-standard xvYCC 709 or xvYCC 601 encodings can be
used by selecting V4L2_YCBCR_ENC_XV709 or V4L2_YCBCR_ENC_XV601.
As seen by the xvYCC formulas these encodings always use limited range quantization,
there is no full range variant. The whole point of these extended gamut encodings
is that values outside the limited range are still valid, although they
map to R’, G’ and B’ values outside the [0…1] range and are therefore outside
the Rec. 709 colorspace gamut.
The sRGB standard defines the colorspace used by most webcams
and computer graphics. The default transfer function is
V4L2_XFER_FUNC_SRGB. The default Y’CbCr encoding is
V4L2_YCBCR_ENC_601. The default Y’CbCr quantization is limited range.
Note that the sYCC standard specifies full range quantization,
however all current capture hardware supported by the kernel convert
R’G’B’ to limited range Y’CbCr. So choosing full range as the default
would break how applications interpret the quantization range.
The chromaticities of the primary colors and the white reference are:
These chromaticities are identical to the Rec. 709 colorspace.
Transfer function. Note that negative values for L are only used by the
Y’CbCr conversion.
Inverse Transfer function:
The luminance (Y’) and color difference (Cb and Cr) are obtained with
the following V4L2_YCBCR_ENC_601 encoding as defined by sYCC:
Y’ is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5]. This transform is identical to one defined in SMPTE
170M/BT.601. The Y’CbCr quantization is limited range.
The opRGB standard defines the colorspace used by computer
graphics that use the opRGB colorspace. The default transfer function is
V4L2_XFER_FUNC_OPRGB. The default Y’CbCr encoding is
V4L2_YCBCR_ENC_601. The default Y’CbCr quantization is limited
range.
Note that the opRGB standard specifies full range quantization,
however all current capture hardware supported by the kernel convert
R’G’B’ to limited range Y’CbCr. So choosing full range as the default
would break how applications interpret the quantization range.
The chromaticities of the primary colors and the white reference are:
The luminance (Y’) and color difference (Cb and Cr) are obtained with
the following V4L2_YCBCR_ENC_601 encoding:
Y’ is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5]. This transform is identical to one defined in SMPTE
170M/BT.601. The Y’CbCr quantization is limited range.
The ITU BT.2020 standard defines the colorspace used by Ultra-high
definition television (UHDTV). The default transfer function is
V4L2_XFER_FUNC_709. The default Y’CbCr encoding is
V4L2_YCBCR_ENC_BT2020. The default Y’CbCr quantization is limited range.
The chromaticities of the primary colors and the white reference are:
Please note that while Rec. 709 is defined as the default transfer function
by the ITU BT.2020 standard, in practice this colorspace is often used
with the Transfer Function SMPTE 2084 (V4L2_XFER_FUNC_SMPTE2084). In particular Ultra HD Blu-ray discs use
this combination.
The luminance (Y’) and color difference (Cb and Cr) are obtained with
the following V4L2_YCBCR_ENC_BT2020 encoding:
Y’ is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5]. The Y’CbCr quantization is limited range.
There is also an alternate constant luminance R’G’B’ to Yc’CbcCrc
(V4L2_YCBCR_ENC_BT2020_CONST_LUM) encoding:
Luma:
Yc’ is clamped to the range [0…1] and Cbc and Crc are clamped to the
range [-0.5…0.5]. The Yc’CbcCrc quantization is limited range.
The SMPTE RP 431-2 standard defines the colorspace used by cinema
projectors that use the DCI-P3 colorspace. The default transfer function
is V4L2_XFER_FUNC_DCI_P3. The default Y’CbCr encoding is
V4L2_YCBCR_ENC_709. The default Y’CbCr quantization is limited range.
Note
Note that this colorspace standard does not specify a
Y’CbCr encoding since it is not meant to be encoded to Y’CbCr. So this
default Y’CbCr encoding was picked because it is the HDTV encoding.
The chromaticities of the primary colors and the white reference are:
The SMPTE 240M standard was an interim standard used during the
early days of HDTV (1988-1998). It has been superseded by Rec. 709. The
default transfer function is V4L2_XFER_FUNC_SMPTE240M. The default
Y’CbCr encoding is V4L2_YCBCR_ENC_SMPTE240M. The default Y’CbCr
quantization is limited range. The chromaticities of the primary colors
and the white reference are:
This standard defines the colorspace used by NTSC in 1953. In practice
this colorspace is obsolete and SMPTE 170M should be used instead. The
default transfer function is V4L2_XFER_FUNC_709. The default Y’CbCr
encoding is V4L2_YCBCR_ENC_601. The default Y’CbCr quantization is
limited range. The chromaticities of the primary colors and the white
reference are:
This colorspace uses Illuminant C instead of D65 as the white
reference. To correctly convert an image in this colorspace to another
that uses D65 you need to apply a chromatic adaptation algorithm such as
the Bradford method.
The transfer function was never properly defined for NTSC 1953. The Rec.
709 transfer function is recommended in the literature:
Inverse Transfer function:
The luminance (Y’) and color difference (Cb and Cr) are obtained with
the following V4L2_YCBCR_ENC_601 encoding:
Y’ is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5]. The Y’CbCr quantization is limited range. This transform is
identical to one defined in SMPTE 170M/BT.601.
2.17.9. Colorspace EBU Tech. 3213 (V4L2_COLORSPACE_470_SYSTEM_BG)¶
The EBU Tech 3213 standard defines the colorspace used by PAL/SECAM
in 1975. Note that this colorspace is not supported by the HDMI interface.
Instead EBU Tech 3321 recommends that Rec. 709 is used instead for HDMI.
The default transfer function is
V4L2_XFER_FUNC_709. The default Y’CbCr encoding is
V4L2_YCBCR_ENC_601. The default Y’CbCr quantization is limited
range. The chromaticities of the primary colors and the white reference
are:
The transfer function was never properly defined for this colorspace.
The Rec. 709 transfer function is recommended in the literature:
Inverse Transfer function:
The luminance (Y’) and color difference (Cb and Cr) are obtained with
the following V4L2_YCBCR_ENC_601 encoding:
Y’ is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5]. The Y’CbCr quantization is limited range. This transform is
identical to one defined in SMPTE 170M/BT.601.
This colorspace defines the colorspace used by most (Motion-)JPEG
formats. The chromaticities of the primary colors and the white
reference are identical to sRGB. The transfer function use is
V4L2_XFER_FUNC_SRGB. The Y’CbCr encoding is V4L2_YCBCR_ENC_601
with full range quantization where Y’ is scaled to [0…255] and Cb/Cr are
scaled to [-128…128] and then clipped to [-128…127].
Note
The JPEG standard does not actually store colorspace
information. So if something other than sRGB is used, then the driver
will have to set that information explicitly. Effectively
V4L2_COLORSPACE_JPEG can be considered to be an abbreviation for
V4L2_COLORSPACE_SRGB, V4L2_XFER_FUNC_SRGB, V4L2_YCBCR_ENC_601
and V4L2_QUANTIZATION_FULL_RANGE.
Take care when converting between this transfer function and non-HDR transfer
functions: the linear RGB values [0…1] of HDR content map to a luminance range
of 0 to 10000 cd/m2 whereas the linear RGB values of non-HDR (aka
Standard Dynamic Range or SDR) map to a luminance range of 0 to 100 cd/m2.
To go from SDR to HDR you will have to divide L by 100 first. To go in the other
direction you will have to multiply L by 100. Of course, this clamps all
luminance values over 100 cd/m2 to 100 cd/m2.
There are better methods, see e.g. colimg for more in-depth information
about this.