1 .. Permission is granted to copy, distribute and/or modify this
2 .. document under the terms of the GNU Free Documentation License,
3 .. Version 1.1 or any later version published by the Free Software
4 .. Foundation, with no Invariant Sections, no Front-Cover Texts
5 .. and no Back-Cover Texts. A copy of the license is included at
6 .. Documentation/userspace-api/media/fdl-appendix.rst.
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
10 ********************************
11 Detailed Colorspace Descriptions
12 ********************************
17 Colorspace SMPTE 170M (V4L2_COLORSPACE_SMPTE170M)
18 =================================================
20 The :ref:`smpte170m` standard defines the colorspace used by NTSC and
21 PAL and by SDTV in general. The default transfer function is
22 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
23 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
24 range. The chromaticities of the primary colors and the white reference
29 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
31 .. flat-table:: SMPTE 170M Chromaticities
48 * - White Reference (D65)
53 The red, green and blue chromaticities are also often referred to as the
54 SMPTE C set, so this colorspace is sometimes called SMPTE C as well.
56 The transfer function defined for SMPTE 170M is the same as the one
61 L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le-0.018
63 L' = 4.5L \text{, for } -0.018 < L < 0.018
65 L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
67 Inverse Transfer function:
71 L = -\left( \frac{L' - 0.099}{-1.099} \right) ^{\frac{1}{0.45}} \text{, for } L' \le -0.081
73 L = \frac{L'}{4.5} \text{, for } -0.081 < L' < 0.081
75 L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
77 The luminance (Y') and color difference (Cb and Cr) are obtained with
78 the following ``V4L2_YCBCR_ENC_601`` encoding:
82 Y' = 0.2990R' + 0.5870G' + 0.1140B'
84 Cb = -0.1687R' - 0.3313G' + 0.5B'
86 Cr = 0.5R' - 0.4187G' - 0.0813B'
88 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
89 [-0.5…0.5]. This conversion to Y'CbCr is identical to the one defined in
90 the :ref:`itu601` standard and this colorspace is sometimes called
91 BT.601 as well, even though BT.601 does not mention any color primaries.
93 The default quantization is limited range, but full range is possible
99 Colorspace Rec. 709 (V4L2_COLORSPACE_REC709)
100 ============================================
102 The :ref:`itu709` standard defines the colorspace used by HDTV in
103 general. The default transfer function is ``V4L2_XFER_FUNC_709``. The
104 default Y'CbCr encoding is ``V4L2_YCBCR_ENC_709``. The default Y'CbCr
105 quantization is limited range. The chromaticities of the primary colors
106 and the white reference are:
110 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
112 .. flat-table:: Rec. 709 Chromaticities
129 * - White Reference (D65)
134 The full name of this standard is Rec. ITU-R BT.709-5.
136 Transfer function. Normally L is in the range [0…1], but for the
137 extended gamut xvYCC encoding values outside that range are allowed.
141 L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le -0.018
143 L' = 4.5L \text{, for } -0.018 < L < 0.018
145 L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
147 Inverse Transfer function:
151 L = -\left( \frac{L' - 0.099}{-1.099} \right)^\frac{1}{0.45} \text{, for } L' \le -0.081
153 L = \frac{L'}{4.5}\text{, for } -0.081 < L' < 0.081
155 L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
157 The luminance (Y') and color difference (Cb and Cr) are obtained with
158 the following ``V4L2_YCBCR_ENC_709`` encoding:
162 Y' = 0.2126R' + 0.7152G' + 0.0722B'
164 Cb = -0.1146R' - 0.3854G' + 0.5B'
166 Cr = 0.5R' - 0.4542G' - 0.0458B'
168 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
171 The default quantization is limited range, but full range is possible
172 although rarely seen.
174 The ``V4L2_YCBCR_ENC_709`` encoding described above is the default for
175 this colorspace, but it can be overridden with ``V4L2_YCBCR_ENC_601``,
176 in which case the BT.601 Y'CbCr encoding is used.
178 Two additional extended gamut Y'CbCr encodings are also possible with
181 The xvYCC 709 encoding (``V4L2_YCBCR_ENC_XV709``, :ref:`xvycc`) is
182 similar to the Rec. 709 encoding, but it allows for R', G' and B' values
183 that are outside the range [0…1]. The resulting Y', Cb and Cr values are
184 scaled and offset according to the limited range formula:
188 Y' = \frac{219}{256} * (0.2126R' + 0.7152G' + 0.0722B') + \frac{16}{256}
190 Cb = \frac{224}{256} * (-0.1146R' - 0.3854G' + 0.5B')
192 Cr = \frac{224}{256} * (0.5R' - 0.4542G' - 0.0458B')
194 The xvYCC 601 encoding (``V4L2_YCBCR_ENC_XV601``, :ref:`xvycc`) is
195 similar to the BT.601 encoding, but it allows for R', G' and B' values
196 that are outside the range [0…1]. The resulting Y', Cb and Cr values are
197 scaled and offset according to the limited range formula:
201 Y' = \frac{219}{256} * (0.2990R' + 0.5870G' + 0.1140B') + \frac{16}{256}
203 Cb = \frac{224}{256} * (-0.1687R' - 0.3313G' + 0.5B')
205 Cr = \frac{224}{256} * (0.5R' - 0.4187G' - 0.0813B')
207 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
208 [-0.5…0.5] and quantized without further scaling or offsets.
209 The non-standard xvYCC 709 or xvYCC 601 encodings can be
210 used by selecting ``V4L2_YCBCR_ENC_XV709`` or ``V4L2_YCBCR_ENC_XV601``.
211 As seen by the xvYCC formulas these encodings always use limited range quantization,
212 there is no full range variant. The whole point of these extended gamut encodings
213 is that values outside the limited range are still valid, although they
214 map to R', G' and B' values outside the [0…1] range and are therefore outside
215 the Rec. 709 colorspace gamut.
220 Colorspace sRGB (V4L2_COLORSPACE_SRGB)
221 ======================================
223 The :ref:`srgb` standard defines the colorspace used by most webcams
224 and computer graphics. The default transfer function is
225 ``V4L2_XFER_FUNC_SRGB``. The default Y'CbCr encoding is
226 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited range.
228 Note that the :ref:`sycc` standard specifies full range quantization,
229 however all current capture hardware supported by the kernel convert
230 R'G'B' to limited range Y'CbCr. So choosing full range as the default
231 would break how applications interpret the quantization range.
233 The chromaticities of the primary colors and the white reference are:
237 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
239 .. flat-table:: sRGB Chromaticities
256 * - White Reference (D65)
261 These chromaticities are identical to the Rec. 709 colorspace.
263 Transfer function. Note that negative values for L are only used by the
268 L' = -1.055(-L)^{\frac{1}{2.4} } + 0.055\text{, for }L < -0.0031308
270 L' = 12.92L\text{, for }-0.0031308 \le L \le 0.0031308
272 L' = 1.055L ^{\frac{1}{2.4} } - 0.055\text{, for }0.0031308 < L \le 1
274 Inverse Transfer function:
278 L = -((-L' + 0.055) / 1.055) ^{2.4}\text{, for }L' < -0.04045
280 L = L' / 12.92\text{, for }-0.04045 \le L' \le 0.04045
282 L = ((L' + 0.055) / 1.055) ^{2.4}\text{, for }L' > 0.04045
284 The luminance (Y') and color difference (Cb and Cr) are obtained with
285 the following ``V4L2_YCBCR_ENC_601`` encoding as defined by :ref:`sycc`:
289 Y' = 0.2990R' + 0.5870G' + 0.1140B'
291 Cb = -0.1687R' - 0.3313G' + 0.5B'
293 Cr = 0.5R' - 0.4187G' - 0.0813B'
295 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
296 [-0.5…0.5]. This transform is identical to one defined in SMPTE
297 170M/BT.601. The Y'CbCr quantization is limited range.
302 Colorspace opRGB (V4L2_COLORSPACE_OPRGB)
303 ===============================================
305 The :ref:`oprgb` standard defines the colorspace used by computer
306 graphics that use the opRGB colorspace. The default transfer function is
307 ``V4L2_XFER_FUNC_OPRGB``. The default Y'CbCr encoding is
308 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
311 Note that the :ref:`oprgb` standard specifies full range quantization,
312 however all current capture hardware supported by the kernel convert
313 R'G'B' to limited range Y'CbCr. So choosing full range as the default
314 would break how applications interpret the quantization range.
316 The chromaticities of the primary colors and the white reference are:
319 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
321 .. flat-table:: opRGB Chromaticities
338 * - White Reference (D65)
348 L' = L ^{\frac{1}{2.19921875}}
350 Inverse Transfer function:
354 L = L'^{(2.19921875)}
356 The luminance (Y') and color difference (Cb and Cr) are obtained with
357 the following ``V4L2_YCBCR_ENC_601`` encoding:
361 Y' = 0.2990R' + 0.5870G' + 0.1140B'
363 Cb = -0.1687R' - 0.3313G' + 0.5B'
365 Cr = 0.5R' - 0.4187G' - 0.0813B'
367 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
368 [-0.5…0.5]. This transform is identical to one defined in SMPTE
369 170M/BT.601. The Y'CbCr quantization is limited range.
374 Colorspace BT.2020 (V4L2_COLORSPACE_BT2020)
375 ===========================================
377 The :ref:`itu2020` standard defines the colorspace used by Ultra-high
378 definition television (UHDTV). The default transfer function is
379 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
380 ``V4L2_YCBCR_ENC_BT2020``. The default R'G'B' quantization is limited
381 range (!), and so is the default Y'CbCr quantization. The chromaticities
382 of the primary colors and the white reference are:
386 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
388 .. flat-table:: BT.2020 Chromaticities
405 * - White Reference (D65)
411 Transfer function (same as Rec. 709):
415 L' = 4.5L\text{, for }0 \le L < 0.018
417 L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
419 Inverse Transfer function:
423 L = L' / 4.5\text{, for } L' < 0.081
425 L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
427 Please note that while Rec. 709 is defined as the default transfer function
428 by the :ref:`itu2020` standard, in practice this colorspace is often used
429 with the :ref:`xf-smpte-2084`. In particular Ultra HD Blu-ray discs use
432 The luminance (Y') and color difference (Cb and Cr) are obtained with
433 the following ``V4L2_YCBCR_ENC_BT2020`` encoding:
437 Y' = 0.2627R' + 0.6780G' + 0.0593B'
439 Cb = -0.1396R' - 0.3604G' + 0.5B'
441 Cr = 0.5R' - 0.4598G' - 0.0402B'
443 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
444 [-0.5…0.5]. The Y'CbCr quantization is limited range.
446 There is also an alternate constant luminance R'G'B' to Yc'CbcCrc
447 (``V4L2_YCBCR_ENC_BT2020_CONST_LUM``) encoding:
455 Yc' = (0.2627R + 0.6780G + 0.0593B)'& \\
457 &Cbc = (B' - Yc') / 1.9404 \\
459 &Cbc = (B' - Yc') / 1.5816 \\
461 &Crc = (R' - Y') / 1.7184 \\
463 &Crc = (R' - Y') / 0.9936
466 Yc' is clamped to the range [0…1] and Cbc and Crc are clamped to the
467 range [-0.5…0.5]. The Yc'CbcCrc quantization is limited range.
472 Colorspace DCI-P3 (V4L2_COLORSPACE_DCI_P3)
473 ==========================================
475 The :ref:`smpte431` standard defines the colorspace used by cinema
476 projectors that use the DCI-P3 colorspace. The default transfer function
477 is ``V4L2_XFER_FUNC_DCI_P3``. The default Y'CbCr encoding is
478 ``V4L2_YCBCR_ENC_709``. The default Y'CbCr quantization is limited range.
482 Note that this colorspace standard does not specify a
483 Y'CbCr encoding since it is not meant to be encoded to Y'CbCr. So this
484 default Y'CbCr encoding was picked because it is the HDTV encoding.
486 The chromaticities of the primary colors and the white reference are:
490 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
492 .. flat-table:: DCI-P3 Chromaticities
519 L' = L^{\frac{1}{2.6}}
521 Inverse Transfer function:
527 Y'CbCr encoding is not specified. V4L2 defaults to Rec. 709.
532 Colorspace SMPTE 240M (V4L2_COLORSPACE_SMPTE240M)
533 =================================================
535 The :ref:`smpte240m` standard was an interim standard used during the
536 early days of HDTV (1988-1998). It has been superseded by Rec. 709. The
537 default transfer function is ``V4L2_XFER_FUNC_SMPTE240M``. The default
538 Y'CbCr encoding is ``V4L2_YCBCR_ENC_SMPTE240M``. The default Y'CbCr
539 quantization is limited range. The chromaticities of the primary colors
540 and the white reference are:
544 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
546 .. flat-table:: SMPTE 240M Chromaticities
563 * - White Reference (D65)
568 These chromaticities are identical to the SMPTE 170M colorspace.
574 L' = 4L\text{, for } 0 \le L < 0.0228
576 L' = 1.1115L ^{0.45} - 0.1115\text{, for } 0.0228 \le L \le 1
578 Inverse Transfer function:
582 L = \frac{L'}{4}\text{, for } 0 \le L' < 0.0913
584 L = \left( \frac{L' + 0.1115}{1.1115}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.0913
586 The luminance (Y') and color difference (Cb and Cr) are obtained with
587 the following ``V4L2_YCBCR_ENC_SMPTE240M`` encoding:
591 Y' = 0.2122R' + 0.7013G' + 0.0865B'
593 Cb = -0.1161R' - 0.3839G' + 0.5B'
595 Cr = 0.5R' - 0.4451G' - 0.0549B'
597 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the
598 range [-0.5…0.5]. The Y'CbCr quantization is limited range.
603 Colorspace NTSC 1953 (V4L2_COLORSPACE_470_SYSTEM_M)
604 ===================================================
606 This standard defines the colorspace used by NTSC in 1953. In practice
607 this colorspace is obsolete and SMPTE 170M should be used instead. The
608 default transfer function is ``V4L2_XFER_FUNC_709``. The default Y'CbCr
609 encoding is ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is
610 limited range. The chromaticities of the primary colors and the white
615 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
617 .. flat-table:: NTSC 1953 Chromaticities
634 * - White Reference (C)
641 This colorspace uses Illuminant C instead of D65 as the white
642 reference. To correctly convert an image in this colorspace to another
643 that uses D65 you need to apply a chromatic adaptation algorithm such as
646 The transfer function was never properly defined for NTSC 1953. The Rec.
647 709 transfer function is recommended in the literature:
651 L' = 4.5L\text{, for } 0 \le L < 0.018
653 L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
655 Inverse Transfer function:
659 L = \frac{L'}{4.5} \text{, for } L' < 0.081
661 L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
663 The luminance (Y') and color difference (Cb and Cr) are obtained with
664 the following ``V4L2_YCBCR_ENC_601`` encoding:
668 Y' = 0.2990R' + 0.5870G' + 0.1140B'
670 Cb = -0.1687R' - 0.3313G' + 0.5B'
672 Cr = 0.5R' - 0.4187G' - 0.0813B'
674 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
675 [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
676 identical to one defined in SMPTE 170M/BT.601.
681 Colorspace EBU Tech. 3213 (V4L2_COLORSPACE_470_SYSTEM_BG)
682 =========================================================
684 The :ref:`tech3213` standard defines the colorspace used by PAL/SECAM
685 in 1975. In practice this colorspace is obsolete and SMPTE 170M should
686 be used instead. The default transfer function is
687 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
688 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
689 range. The chromaticities of the primary colors and the white reference
694 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
696 .. flat-table:: EBU Tech. 3213 Chromaticities
713 * - White Reference (D65)
719 The transfer function was never properly defined for this colorspace.
720 The Rec. 709 transfer function is recommended in the literature:
724 L' = 4.5L\text{, for } 0 \le L < 0.018
726 L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
728 Inverse Transfer function:
732 L = \frac{L'}{4.5} \text{, for } L' < 0.081
734 L = \left(\frac{L' + 0.099}{1.099} \right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
736 The luminance (Y') and color difference (Cb and Cr) are obtained with
737 the following ``V4L2_YCBCR_ENC_601`` encoding:
741 Y' = 0.2990R' + 0.5870G' + 0.1140B'
743 Cb = -0.1687R' - 0.3313G' + 0.5B'
745 Cr = 0.5R' - 0.4187G' - 0.0813B'
747 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
748 [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
749 identical to one defined in SMPTE 170M/BT.601.
754 Colorspace JPEG (V4L2_COLORSPACE_JPEG)
755 ======================================
757 This colorspace defines the colorspace used by most (Motion-)JPEG
758 formats. The chromaticities of the primary colors and the white
759 reference are identical to sRGB. The transfer function use is
760 ``V4L2_XFER_FUNC_SRGB``. The Y'CbCr encoding is ``V4L2_YCBCR_ENC_601``
761 with full range quantization where Y' is scaled to [0…255] and Cb/Cr are
762 scaled to [-128…128] and then clipped to [-128…127].
766 The JPEG standard does not actually store colorspace
767 information. So if something other than sRGB is used, then the driver
768 will have to set that information explicitly. Effectively
769 ``V4L2_COLORSPACE_JPEG`` can be considered to be an abbreviation for
770 ``V4L2_COLORSPACE_SRGB``, ``V4L2_YCBCR_ENC_601`` and
771 ``V4L2_QUANTIZATION_FULL_RANGE``.
773 ***************************************
774 Detailed Transfer Function Descriptions
775 ***************************************
779 Transfer Function SMPTE 2084 (V4L2_XFER_FUNC_SMPTE2084)
780 =======================================================
782 The :ref:`smpte2084` standard defines the transfer function used by
783 High Dynamic Range content.
786 m1 = (2610 / 4096) / 4
788 m2 = (2523 / 4096) * 128
792 c2 = (2413 / 4096) * 32
794 c3 = (2392 / 4096) * 32
797 L' = ((c1 + c2 * L\ :sup:`m1`) / (1 + c3 * L\ :sup:`m1`))\ :sup:`m2`
799 Inverse Transfer function:
800 L = (max(L':sup:`1/m2` - c1, 0) / (c2 - c3 *
801 L'\ :sup:`1/m2`))\ :sup:`1/m1`
803 Take care when converting between this transfer function and non-HDR transfer
804 functions: the linear RGB values [0…1] of HDR content map to a luminance range
805 of 0 to 10000 cd/m\ :sup:`2` whereas the linear RGB values of non-HDR (aka
806 Standard Dynamic Range or SDR) map to a luminance range of 0 to 100 cd/m\ :sup:`2`.
808 To go from SDR to HDR you will have to divide L by 100 first. To go in the other
809 direction you will have to multiply L by 100. Of course, this clamps all
810 luminance values over 100 cd/m\ :sup:`2` to 100 cd/m\ :sup:`2`.
812 There are better methods, see e.g. :ref:`colimg` for more in-depth information