1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
3 ********************************
4 Detailed Colorspace Descriptions
5 ********************************
10 Colorspace SMPTE 170M (V4L2_COLORSPACE_SMPTE170M)
11 =================================================
13 The :ref:`smpte170m` standard defines the colorspace used by NTSC and
14 PAL and by SDTV in general. The default transfer function is
15 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
16 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
17 range. The chromaticities of the primary colors and the white reference
20 .. flat-table:: SMPTE 170M Chromaticities
37 * - White Reference (D65)
42 The red, green and blue chromaticities are also often referred to as the
43 SMPTE C set, so this colorspace is sometimes called SMPTE C as well.
45 The transfer function defined for SMPTE 170M is the same as the one
50 L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le-0.018
52 L' = 4.5L \text{, for } -0.018 < L < 0.018
54 L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
56 Inverse Transfer function:
60 L = -\left( \frac{L' - 0.099}{-1.099} \right) ^{\frac{1}{0.45}} \text{, for } L' \le -0.081
62 L = \frac{L'}{4.5} \text{, for } -0.081 < L' < 0.081
64 L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
66 The luminance (Y') and color difference (Cb and Cr) are obtained with
67 the following ``V4L2_YCBCR_ENC_601`` encoding:
71 Y' = 0.2990R' + 0.5870G' + 0.1140B'
73 Cb = -0.1687R' - 0.3313G' + 0.5B'
75 Cr = 0.5R' - 0.4187G' - 0.0813B'
77 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
78 [-0.5…0.5]. This conversion to Y'CbCr is identical to the one defined in
79 the :ref:`itu601` standard and this colorspace is sometimes called
80 BT.601 as well, even though BT.601 does not mention any color primaries.
82 The default quantization is limited range, but full range is possible
88 Colorspace Rec. 709 (V4L2_COLORSPACE_REC709)
89 ============================================
91 The :ref:`itu709` standard defines the colorspace used by HDTV in
92 general. The default transfer function is ``V4L2_XFER_FUNC_709``. The
93 default Y'CbCr encoding is ``V4L2_YCBCR_ENC_709``. The default Y'CbCr
94 quantization is limited range. The chromaticities of the primary colors
95 and the white reference are:
97 .. flat-table:: Rec. 709 Chromaticities
114 * - White Reference (D65)
119 The full name of this standard is Rec. ITU-R BT.709-5.
121 Transfer function. Normally L is in the range [0…1], but for the
122 extended gamut xvYCC encoding values outside that range are allowed.
126 L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le -0.018
128 L' = 4.5L \text{, for } -0.018 < L < 0.018
130 L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
132 Inverse Transfer function:
136 L = -\left( \frac{L' - 0.099}{-1.099} \right)^\frac{1}{0.45} \text{, for } L' \le -0.081
138 L = \frac{L'}{4.5}\text{, for } -0.081 < L' < 0.081
140 L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
142 The luminance (Y') and color difference (Cb and Cr) are obtained with
143 the following ``V4L2_YCBCR_ENC_709`` encoding:
147 Y' = 0.2126R' + 0.7152G' + 0.0722B'
149 Cb = -0.1146R' - 0.3854G' + 0.5B'
151 Cr = 0.5R' - 0.4542G' - 0.0458B'
153 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
156 The default quantization is limited range, but full range is possible
157 although rarely seen.
159 The ``V4L2_YCBCR_ENC_709`` encoding described above is the default for
160 this colorspace, but it can be overridden with ``V4L2_YCBCR_ENC_601``,
161 in which case the BT.601 Y'CbCr encoding is used.
163 Two additional extended gamut Y'CbCr encodings are also possible with
166 The xvYCC 709 encoding (``V4L2_YCBCR_ENC_XV709``, :ref:`xvycc`) is
167 similar to the Rec. 709 encoding, but it allows for R', G' and B' values
168 that are outside the range [0…1]. The resulting Y', Cb and Cr values are
169 scaled and offset according to the limited range formula:
173 Y' = \frac{219}{256} * (0.2126R' + 0.7152G' + 0.0722B') + \frac{16}{256}
175 Cb = \frac{224}{256} * (-0.1146R' - 0.3854G' + 0.5B')
177 Cr = \frac{224}{256} * (0.5R' - 0.4542G' - 0.0458B')
179 The xvYCC 601 encoding (``V4L2_YCBCR_ENC_XV601``, :ref:`xvycc`) is
180 similar to the BT.601 encoding, but it allows for R', G' and B' values
181 that are outside the range [0…1]. The resulting Y', Cb and Cr values are
182 scaled and offset according to the limited range formula:
186 Y' = \frac{219}{256} * (0.2990R' + 0.5870G' + 0.1140B') + \frac{16}{256}
188 Cb = \frac{224}{256} * (-0.1687R' - 0.3313G' + 0.5B')
190 Cr = \frac{224}{256} * (0.5R' - 0.4187G' - 0.0813B')
192 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
193 [-0.5…0.5] and quantized without further scaling or offsets.
194 The non-standard xvYCC 709 or xvYCC 601 encodings can be
195 used by selecting ``V4L2_YCBCR_ENC_XV709`` or ``V4L2_YCBCR_ENC_XV601``.
196 As seen by the xvYCC formulas these encodings always use limited range quantization,
197 there is no full range variant. The whole point of these extended gamut encodings
198 is that values outside the limited range are still valid, although they
199 map to R', G' and B' values outside the [0…1] range and are therefore outside
200 the Rec. 709 colorspace gamut.
205 Colorspace sRGB (V4L2_COLORSPACE_SRGB)
206 ======================================
208 The :ref:`srgb` standard defines the colorspace used by most webcams
209 and computer graphics. The default transfer function is
210 ``V4L2_XFER_FUNC_SRGB``. The default Y'CbCr encoding is
211 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited range.
213 Note that the :ref:`sycc` standard specifies full range quantization,
214 however all current capture hardware supported by the kernel convert
215 R'G'B' to limited range Y'CbCr. So choosing full range as the default
216 would break how applications interpret the quantization range.
218 The chromaticities of the primary colors and the white reference are:
220 .. flat-table:: sRGB Chromaticities
237 * - White Reference (D65)
242 These chromaticities are identical to the Rec. 709 colorspace.
244 Transfer function. Note that negative values for L are only used by the
249 L' = -1.055(-L)^{\frac{1}{2.4} } + 0.055\text{, for }L < -0.0031308
251 L' = 12.92L\text{, for }-0.0031308 \le L \le 0.0031308
253 L' = 1.055L ^{\frac{1}{2.4} } - 0.055\text{, for }0.0031308 < L \le 1
255 Inverse Transfer function:
259 L = -((-L' + 0.055) / 1.055) ^{2.4}\text{, for }L' < -0.04045
261 L = L' / 12.92\text{, for }-0.04045 \le L' \le 0.04045
263 L = ((L' + 0.055) / 1.055) ^{2.4}\text{, for }L' > 0.04045
265 The luminance (Y') and color difference (Cb and Cr) are obtained with
266 the following ``V4L2_YCBCR_ENC_601`` encoding as defined by :ref:`sycc`:
270 Y' = 0.2990R' + 0.5870G' + 0.1140B'
272 Cb = -0.1687R' - 0.3313G' + 0.5B'
274 Cr = 0.5R' - 0.4187G' - 0.0813B'
276 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
277 [-0.5…0.5]. This transform is identical to one defined in SMPTE
278 170M/BT.601. The Y'CbCr quantization is limited range.
283 Colorspace opRGB (V4L2_COLORSPACE_OPRGB)
284 ===============================================
286 The :ref:`oprgb` standard defines the colorspace used by computer
287 graphics that use the opRGB colorspace. The default transfer function is
288 ``V4L2_XFER_FUNC_OPRGB``. The default Y'CbCr encoding is
289 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
292 Note that the :ref:`oprgb` standard specifies full range quantization,
293 however all current capture hardware supported by the kernel convert
294 R'G'B' to limited range Y'CbCr. So choosing full range as the default
295 would break how applications interpret the quantization range.
297 The chromaticities of the primary colors and the white reference are:
299 .. flat-table:: opRGB Chromaticities
316 * - White Reference (D65)
326 L' = L ^{\frac{1}{2.19921875}}
328 Inverse Transfer function:
332 L = L'^{(2.19921875)}
334 The luminance (Y') and color difference (Cb and Cr) are obtained with
335 the following ``V4L2_YCBCR_ENC_601`` encoding:
339 Y' = 0.2990R' + 0.5870G' + 0.1140B'
341 Cb = -0.1687R' - 0.3313G' + 0.5B'
343 Cr = 0.5R' - 0.4187G' - 0.0813B'
345 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
346 [-0.5…0.5]. This transform is identical to one defined in SMPTE
347 170M/BT.601. The Y'CbCr quantization is limited range.
352 Colorspace BT.2020 (V4L2_COLORSPACE_BT2020)
353 ===========================================
355 The :ref:`itu2020` standard defines the colorspace used by Ultra-high
356 definition television (UHDTV). The default transfer function is
357 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
358 ``V4L2_YCBCR_ENC_BT2020``. The default Y'CbCr quantization is limited range.
359 The chromaticities of the primary colors and the white reference are:
361 .. flat-table:: BT.2020 Chromaticities
378 * - White Reference (D65)
384 Transfer function (same as Rec. 709):
388 L' = 4.5L\text{, for }0 \le L < 0.018
390 L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
392 Inverse Transfer function:
396 L = L' / 4.5\text{, for } L' < 0.081
398 L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
400 Please note that while Rec. 709 is defined as the default transfer function
401 by the :ref:`itu2020` standard, in practice this colorspace is often used
402 with the :ref:`xf-smpte-2084`. In particular Ultra HD Blu-ray discs use
405 The luminance (Y') and color difference (Cb and Cr) are obtained with
406 the following ``V4L2_YCBCR_ENC_BT2020`` encoding:
410 Y' = 0.2627R' + 0.6780G' + 0.0593B'
412 Cb = -0.1396R' - 0.3604G' + 0.5B'
414 Cr = 0.5R' - 0.4598G' - 0.0402B'
416 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
417 [-0.5…0.5]. The Y'CbCr quantization is limited range.
419 There is also an alternate constant luminance R'G'B' to Yc'CbcCrc
420 (``V4L2_YCBCR_ENC_BT2020_CONST_LUM``) encoding:
428 Yc' = (0.2627R + 0.6780G + 0.0593B)'& \\
430 &Cbc = (B' - Yc') / 1.9404 \\
432 &Cbc = (B' - Yc') / 1.5816 \\
434 &Crc = (R' - Y') / 1.7184 \\
436 &Crc = (R' - Y') / 0.9936
439 Yc' is clamped to the range [0…1] and Cbc and Crc are clamped to the
440 range [-0.5…0.5]. The Yc'CbcCrc quantization is limited range.
445 Colorspace DCI-P3 (V4L2_COLORSPACE_DCI_P3)
446 ==========================================
448 The :ref:`smpte431` standard defines the colorspace used by cinema
449 projectors that use the DCI-P3 colorspace. The default transfer function
450 is ``V4L2_XFER_FUNC_DCI_P3``. The default Y'CbCr encoding is
451 ``V4L2_YCBCR_ENC_709``. The default Y'CbCr quantization is limited range.
455 Note that this colorspace standard does not specify a
456 Y'CbCr encoding since it is not meant to be encoded to Y'CbCr. So this
457 default Y'CbCr encoding was picked because it is the HDTV encoding.
459 The chromaticities of the primary colors and the white reference are:
462 .. flat-table:: DCI-P3 Chromaticities
489 L' = L^{\frac{1}{2.6}}
491 Inverse Transfer function:
497 Y'CbCr encoding is not specified. V4L2 defaults to Rec. 709.
502 Colorspace SMPTE 240M (V4L2_COLORSPACE_SMPTE240M)
503 =================================================
505 The :ref:`smpte240m` standard was an interim standard used during the
506 early days of HDTV (1988-1998). It has been superseded by Rec. 709. The
507 default transfer function is ``V4L2_XFER_FUNC_SMPTE240M``. The default
508 Y'CbCr encoding is ``V4L2_YCBCR_ENC_SMPTE240M``. The default Y'CbCr
509 quantization is limited range. The chromaticities of the primary colors
510 and the white reference are:
513 .. flat-table:: SMPTE 240M Chromaticities
530 * - White Reference (D65)
535 These chromaticities are identical to the SMPTE 170M colorspace.
541 L' = 4L\text{, for } 0 \le L < 0.0228
543 L' = 1.1115L ^{0.45} - 0.1115\text{, for } 0.0228 \le L \le 1
545 Inverse Transfer function:
549 L = \frac{L'}{4}\text{, for } 0 \le L' < 0.0913
551 L = \left( \frac{L' + 0.1115}{1.1115}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.0913
553 The luminance (Y') and color difference (Cb and Cr) are obtained with
554 the following ``V4L2_YCBCR_ENC_SMPTE240M`` encoding:
558 Y' = 0.2122R' + 0.7013G' + 0.0865B'
560 Cb = -0.1161R' - 0.3839G' + 0.5B'
562 Cr = 0.5R' - 0.4451G' - 0.0549B'
564 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the
565 range [-0.5…0.5]. The Y'CbCr quantization is limited range.
570 Colorspace NTSC 1953 (V4L2_COLORSPACE_470_SYSTEM_M)
571 ===================================================
573 This standard defines the colorspace used by NTSC in 1953. In practice
574 this colorspace is obsolete and SMPTE 170M should be used instead. The
575 default transfer function is ``V4L2_XFER_FUNC_709``. The default Y'CbCr
576 encoding is ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is
577 limited range. The chromaticities of the primary colors and the white
581 .. flat-table:: NTSC 1953 Chromaticities
598 * - White Reference (C)
605 This colorspace uses Illuminant C instead of D65 as the white
606 reference. To correctly convert an image in this colorspace to another
607 that uses D65 you need to apply a chromatic adaptation algorithm such as
610 The transfer function was never properly defined for NTSC 1953. The Rec.
611 709 transfer function is recommended in the literature:
615 L' = 4.5L\text{, for } 0 \le L < 0.018
617 L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
619 Inverse Transfer function:
623 L = \frac{L'}{4.5} \text{, for } L' < 0.081
625 L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
627 The luminance (Y') and color difference (Cb and Cr) are obtained with
628 the following ``V4L2_YCBCR_ENC_601`` encoding:
632 Y' = 0.2990R' + 0.5870G' + 0.1140B'
634 Cb = -0.1687R' - 0.3313G' + 0.5B'
636 Cr = 0.5R' - 0.4187G' - 0.0813B'
638 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
639 [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
640 identical to one defined in SMPTE 170M/BT.601.
645 Colorspace EBU Tech. 3213 (V4L2_COLORSPACE_470_SYSTEM_BG)
646 =========================================================
648 The :ref:`tech3213` standard defines the colorspace used by PAL/SECAM
649 in 1975. Note that this colorspace is not supported by the HDMI interface.
650 Instead :ref:`tech3321` recommends that Rec. 709 is used instead for HDMI.
651 The default transfer function is
652 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
653 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
654 range. The chromaticities of the primary colors and the white reference
658 .. flat-table:: EBU Tech. 3213 Chromaticities
675 * - White Reference (D65)
681 The transfer function was never properly defined for this colorspace.
682 The Rec. 709 transfer function is recommended in the literature:
686 L' = 4.5L\text{, for } 0 \le L < 0.018
688 L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
690 Inverse Transfer function:
694 L = \frac{L'}{4.5} \text{, for } L' < 0.081
696 L = \left(\frac{L' + 0.099}{1.099} \right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
698 The luminance (Y') and color difference (Cb and Cr) are obtained with
699 the following ``V4L2_YCBCR_ENC_601`` encoding:
703 Y' = 0.2990R' + 0.5870G' + 0.1140B'
705 Cb = -0.1687R' - 0.3313G' + 0.5B'
707 Cr = 0.5R' - 0.4187G' - 0.0813B'
709 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
710 [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
711 identical to one defined in SMPTE 170M/BT.601.
716 Colorspace JPEG (V4L2_COLORSPACE_JPEG)
717 ======================================
719 This colorspace defines the colorspace used by most (Motion-)JPEG
720 formats. The chromaticities of the primary colors and the white
721 reference are identical to sRGB. The transfer function use is
722 ``V4L2_XFER_FUNC_SRGB``. The Y'CbCr encoding is ``V4L2_YCBCR_ENC_601``
723 with full range quantization where Y' is scaled to [0…255] and Cb/Cr are
724 scaled to [-128…128] and then clipped to [-128…127].
728 The JPEG standard does not actually store colorspace
729 information. So if something other than sRGB is used, then the driver
730 will have to set that information explicitly. Effectively
731 ``V4L2_COLORSPACE_JPEG`` can be considered to be an abbreviation for
732 ``V4L2_COLORSPACE_SRGB``, ``V4L2_XFER_FUNC_SRGB``, ``V4L2_YCBCR_ENC_601``
733 and ``V4L2_QUANTIZATION_FULL_RANGE``.
735 ***************************************
736 Detailed Transfer Function Descriptions
737 ***************************************
741 Transfer Function SMPTE 2084 (V4L2_XFER_FUNC_SMPTE2084)
742 =======================================================
744 The :ref:`smpte2084` standard defines the transfer function used by
745 High Dynamic Range content.
748 m1 = (2610 / 4096) / 4
750 m2 = (2523 / 4096) * 128
754 c2 = (2413 / 4096) * 32
756 c3 = (2392 / 4096) * 32
759 L' = ((c1 + c2 * L\ :sup:`m1`) / (1 + c3 * L\ :sup:`m1`))\ :sup:`m2`
761 Inverse Transfer function:
762 L = (max(L':sup:`1/m2` - c1, 0) / (c2 - c3 *
763 L'\ :sup:`1/m2`))\ :sup:`1/m1`
765 Take care when converting between this transfer function and non-HDR transfer
766 functions: the linear RGB values [0…1] of HDR content map to a luminance range
767 of 0 to 10000 cd/m\ :sup:`2` whereas the linear RGB values of non-HDR (aka
768 Standard Dynamic Range or SDR) map to a luminance range of 0 to 100 cd/m\ :sup:`2`.
770 To go from SDR to HDR you will have to divide L by 100 first. To go in the other
771 direction you will have to multiply L by 100. Of course, this clamps all
772 luminance values over 100 cd/m\ :sup:`2` to 100 cd/m\ :sup:`2`.
774 There are better methods, see e.g. :ref:`colimg` for more in-depth information