1 .. -*- coding: utf-8; mode: rst -*-
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
22 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
24 .. flat-table:: SMPTE 170M Chromaticities
41 * - White Reference (D65)
46 The red, green and blue chromaticities are also often referred to as the
47 SMPTE C set, so this colorspace is sometimes called SMPTE C as well.
49 The transfer function defined for SMPTE 170M is the same as the one
54 L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le-0.018
56 L' = 4.5L \text{, for } -0.018 < L < 0.018
58 L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
60 Inverse Transfer function:
64 L = -\left( \frac{L' - 0.099}{-1.099} \right) ^{\frac{1}{0.45}} \text{, for } L' \le -0.081
66 L = \frac{L'}{4.5} \text{, for } -0.081 < L' < 0.081
68 L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
70 The luminance (Y') and color difference (Cb and Cr) are obtained with
71 the following ``V4L2_YCBCR_ENC_601`` encoding:
75 Y' = 0.2990R' + 0.5870G' + 0.1140B'
77 Cb = -0.1687R' - 0.3313G' + 0.5B'
79 Cr = 0.5R' - 0.4187G' - 0.0813B'
81 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
82 [-0.5…0.5]. This conversion to Y'CbCr is identical to the one defined in
83 the :ref:`itu601` standard and this colorspace is sometimes called
84 BT.601 as well, even though BT.601 does not mention any color primaries.
86 The default quantization is limited range, but full range is possible
92 Colorspace Rec. 709 (V4L2_COLORSPACE_REC709)
93 ============================================
95 The :ref:`itu709` standard defines the colorspace used by HDTV in
96 general. The default transfer function is ``V4L2_XFER_FUNC_709``. The
97 default Y'CbCr encoding is ``V4L2_YCBCR_ENC_709``. The default Y'CbCr
98 quantization is limited range. The chromaticities of the primary colors
99 and the white reference are:
103 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
105 .. flat-table:: Rec. 709 Chromaticities
122 * - White Reference (D65)
127 The full name of this standard is Rec. ITU-R BT.709-5.
129 Transfer function. Normally L is in the range [0…1], but for the
130 extended gamut xvYCC encoding values outside that range are allowed.
134 L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le -0.018
136 L' = 4.5L \text{, for } -0.018 < L < 0.018
138 L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
140 Inverse Transfer function:
144 L = -\left( \frac{L' - 0.099}{-1.099} \right)^\frac{1}{0.45} \text{, for } L' \le -0.081
146 L = \frac{L'}{4.5}\text{, for } -0.081 < L' < 0.081
148 L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
150 The luminance (Y') and color difference (Cb and Cr) are obtained with
151 the following ``V4L2_YCBCR_ENC_709`` encoding:
155 Y' = 0.2126R' + 0.7152G' + 0.0722B'
157 Cb = -0.1146R' - 0.3854G' + 0.5B'
159 Cr = 0.5R' - 0.4542G' - 0.0458B'
161 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
164 The default quantization is limited range, but full range is possible
165 although rarely seen.
167 The ``V4L2_YCBCR_ENC_709`` encoding described above is the default for
168 this colorspace, but it can be overridden with ``V4L2_YCBCR_ENC_601``,
169 in which case the BT.601 Y'CbCr encoding is used.
171 Two additional extended gamut Y'CbCr encodings are also possible with
174 The xvYCC 709 encoding (``V4L2_YCBCR_ENC_XV709``, :ref:`xvycc`) is
175 similar to the Rec. 709 encoding, but it allows for R', G' and B' values
176 that are outside the range [0…1]. The resulting Y', Cb and Cr values are
177 scaled and offset according to the limited range formula:
181 Y' = \frac{219}{256} * (0.2126R' + 0.7152G' + 0.0722B') + \frac{16}{256}
183 Cb = \frac{224}{256} * (-0.1146R' - 0.3854G' + 0.5B')
185 Cr = \frac{224}{256} * (0.5R' - 0.4542G' - 0.0458B')
187 The xvYCC 601 encoding (``V4L2_YCBCR_ENC_XV601``, :ref:`xvycc`) is
188 similar to the BT.601 encoding, but it allows for R', G' and B' values
189 that are outside the range [0…1]. The resulting Y', Cb and Cr values are
190 scaled and offset according to the limited range formula:
194 Y' = \frac{219}{256} * (0.2990R' + 0.5870G' + 0.1140B') + \frac{16}{256}
196 Cb = \frac{224}{256} * (-0.1687R' - 0.3313G' + 0.5B')
198 Cr = \frac{224}{256} * (0.5R' - 0.4187G' - 0.0813B')
200 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
201 [-0.5…0.5] and quantized without further scaling or offsets.
202 The non-standard xvYCC 709 or xvYCC 601 encodings can be
203 used by selecting ``V4L2_YCBCR_ENC_XV709`` or ``V4L2_YCBCR_ENC_XV601``.
204 As seen by the xvYCC formulas these encodings always use limited range quantization,
205 there is no full range variant. The whole point of these extended gamut encodings
206 is that values outside the limited range are still valid, although they
207 map to R', G' and B' values outside the [0…1] range and are therefore outside
208 the Rec. 709 colorspace gamut.
213 Colorspace sRGB (V4L2_COLORSPACE_SRGB)
214 ======================================
216 The :ref:`srgb` standard defines the colorspace used by most webcams
217 and computer graphics. The default transfer function is
218 ``V4L2_XFER_FUNC_SRGB``. The default Y'CbCr encoding is
219 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited range.
221 Note that the :ref:`sycc` standard specifies full range quantization,
222 however all current capture hardware supported by the kernel convert
223 R'G'B' to limited range Y'CbCr. So choosing full range as the default
224 would break how applications interpret the quantization range.
226 The chromaticities of the primary colors and the white reference are:
230 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
232 .. flat-table:: sRGB Chromaticities
249 * - White Reference (D65)
254 These chromaticities are identical to the Rec. 709 colorspace.
256 Transfer function. Note that negative values for L are only used by the
261 L' = -1.055(-L)^{\frac{1}{2.4} } + 0.055\text{, for }L < -0.0031308
263 L' = 12.92L\text{, for }-0.0031308 \le L \le 0.0031308
265 L' = 1.055L ^{\frac{1}{2.4} } - 0.055\text{, for }0.0031308 < L \le 1
267 Inverse Transfer function:
271 L = -((-L' + 0.055) / 1.055) ^{2.4}\text{, for }L' < -0.04045
273 L = L' / 12.92\text{, for }-0.04045 \le L' \le 0.04045
275 L = ((L' + 0.055) / 1.055) ^{2.4}\text{, for }L' > 0.04045
277 The luminance (Y') and color difference (Cb and Cr) are obtained with
278 the following ``V4L2_YCBCR_ENC_601`` encoding as defined by :ref:`sycc`:
282 Y' = 0.2990R' + 0.5870G' + 0.1140B'
284 Cb = -0.1687R' - 0.3313G' + 0.5B'
286 Cr = 0.5R' - 0.4187G' - 0.0813B'
288 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
289 [-0.5…0.5]. This transform is identical to one defined in SMPTE
290 170M/BT.601. The Y'CbCr quantization is limited range.
295 Colorspace Adobe RGB (V4L2_COLORSPACE_ADOBERGB)
296 ===============================================
298 The :ref:`adobergb` standard defines the colorspace used by computer
299 graphics that use the AdobeRGB colorspace. This is also known as the
300 :ref:`oprgb` standard. The default transfer function is
301 ``V4L2_XFER_FUNC_ADOBERGB``. The default Y'CbCr encoding is
302 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
305 Note that the :ref:`oprgb` standard specifies full range quantization,
306 however all current capture hardware supported by the kernel convert
307 R'G'B' to limited range Y'CbCr. So choosing full range as the default
308 would break how applications interpret the quantization range.
310 The chromaticities of the primary colors and the white reference are:
313 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
315 .. flat-table:: Adobe RGB Chromaticities
332 * - White Reference (D65)
342 L' = L ^{\frac{1}{2.19921875}}
344 Inverse Transfer function:
348 L = L'^{(2.19921875)}
350 The luminance (Y') and color difference (Cb and Cr) are obtained with
351 the following ``V4L2_YCBCR_ENC_601`` encoding:
355 Y' = 0.2990R' + 0.5870G' + 0.1140B'
357 Cb = -0.1687R' - 0.3313G' + 0.5B'
359 Cr = 0.5R' - 0.4187G' - 0.0813B'
361 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
362 [-0.5…0.5]. This transform is identical to one defined in SMPTE
363 170M/BT.601. The Y'CbCr quantization is limited range.
368 Colorspace BT.2020 (V4L2_COLORSPACE_BT2020)
369 ===========================================
371 The :ref:`itu2020` standard defines the colorspace used by Ultra-high
372 definition television (UHDTV). The default transfer function is
373 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
374 ``V4L2_YCBCR_ENC_BT2020``. The default R'G'B' quantization is limited
375 range (!), and so is the default Y'CbCr quantization. The chromaticities
376 of the primary colors and the white reference are:
380 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
382 .. flat-table:: BT.2020 Chromaticities
399 * - White Reference (D65)
405 Transfer function (same as Rec. 709):
409 L' = 4.5L\text{, for }0 \le L < 0.018
411 L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
413 Inverse Transfer function:
417 L = L' / 4.5\text{, for } L' < 0.081
419 L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
421 Please note that while Rec. 709 is defined as the default transfer function
422 by the :ref:`itu2020` standard, in practice this colorspace is often used
423 with the :ref:`xf-smpte-2084`. In particular Ultra HD Blu-ray discs use
426 The luminance (Y') and color difference (Cb and Cr) are obtained with
427 the following ``V4L2_YCBCR_ENC_BT2020`` encoding:
431 Y' = 0.2627R' + 0.6780G' + 0.0593B'
433 Cb = -0.1396R' - 0.3604G' + 0.5B'
435 Cr = 0.5R' - 0.4598G' - 0.0402B'
437 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
438 [-0.5…0.5]. The Y'CbCr quantization is limited range.
440 There is also an alternate constant luminance R'G'B' to Yc'CbcCrc
441 (``V4L2_YCBCR_ENC_BT2020_CONST_LUM``) encoding:
449 Yc' = (0.2627R + 0.6780G + 0.0593B)'& \\
451 &Cbc = (B' - Yc') / 1.9404 \\
453 &Cbc = (B' - Yc') / 1.5816 \\
455 &Crc = (R' - Y') / 1.7184 \\
457 &Crc = (R' - Y') / 0.9936
460 Yc' is clamped to the range [0…1] and Cbc and Crc are clamped to the
461 range [-0.5…0.5]. The Yc'CbcCrc quantization is limited range.
466 Colorspace DCI-P3 (V4L2_COLORSPACE_DCI_P3)
467 ==========================================
469 The :ref:`smpte431` standard defines the colorspace used by cinema
470 projectors that use the DCI-P3 colorspace. The default transfer function
471 is ``V4L2_XFER_FUNC_DCI_P3``. The default Y'CbCr encoding is
472 ``V4L2_YCBCR_ENC_709``. The default Y'CbCr quantization is limited range.
476 Note that this colorspace standard does not specify a
477 Y'CbCr encoding since it is not meant to be encoded to Y'CbCr. So this
478 default Y'CbCr encoding was picked because it is the HDTV encoding.
480 The chromaticities of the primary colors and the white reference are:
484 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
486 .. flat-table:: DCI-P3 Chromaticities
513 L' = L^{\frac{1}{2.6}}
515 Inverse Transfer function:
521 Y'CbCr encoding is not specified. V4L2 defaults to Rec. 709.
526 Colorspace SMPTE 240M (V4L2_COLORSPACE_SMPTE240M)
527 =================================================
529 The :ref:`smpte240m` standard was an interim standard used during the
530 early days of HDTV (1988-1998). It has been superseded by Rec. 709. The
531 default transfer function is ``V4L2_XFER_FUNC_SMPTE240M``. The default
532 Y'CbCr encoding is ``V4L2_YCBCR_ENC_SMPTE240M``. The default Y'CbCr
533 quantization is limited range. The chromaticities of the primary colors
534 and the white reference are:
538 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
540 .. flat-table:: SMPTE 240M Chromaticities
557 * - White Reference (D65)
562 These chromaticities are identical to the SMPTE 170M colorspace.
568 L' = 4L\text{, for } 0 \le L < 0.0228
570 L' = 1.1115L ^{0.45} - 0.1115\text{, for } 0.0228 \le L \le 1
572 Inverse Transfer function:
576 L = \frac{L'}{4}\text{, for } 0 \le L' < 0.0913
578 L = \left( \frac{L' + 0.1115}{1.1115}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.0913
580 The luminance (Y') and color difference (Cb and Cr) are obtained with
581 the following ``V4L2_YCBCR_ENC_SMPTE240M`` encoding:
585 Y' = 0.2122R' + 0.7013G' + 0.0865B'
587 Cb = -0.1161R' - 0.3839G' + 0.5B'
589 Cr = 0.5R' - 0.4451G' - 0.0549B'
591 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the
592 range [-0.5…0.5]. The Y'CbCr quantization is limited range.
597 Colorspace NTSC 1953 (V4L2_COLORSPACE_470_SYSTEM_M)
598 ===================================================
600 This standard defines the colorspace used by NTSC in 1953. In practice
601 this colorspace is obsolete and SMPTE 170M should be used instead. The
602 default transfer function is ``V4L2_XFER_FUNC_709``. The default Y'CbCr
603 encoding is ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is
604 limited range. The chromaticities of the primary colors and the white
609 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
611 .. flat-table:: NTSC 1953 Chromaticities
628 * - White Reference (C)
635 This colorspace uses Illuminant C instead of D65 as the white
636 reference. To correctly convert an image in this colorspace to another
637 that uses D65 you need to apply a chromatic adaptation algorithm such as
640 The transfer function was never properly defined for NTSC 1953. The Rec.
641 709 transfer function is recommended in the literature:
645 L' = 4.5L\text{, for } 0 \le L < 0.018
647 L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
649 Inverse Transfer function:
653 L = \frac{L'}{4.5} \text{, for } L' < 0.081
655 L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
657 The luminance (Y') and color difference (Cb and Cr) are obtained with
658 the following ``V4L2_YCBCR_ENC_601`` encoding:
662 Y' = 0.2990R' + 0.5870G' + 0.1140B'
664 Cb = -0.1687R' - 0.3313G' + 0.5B'
666 Cr = 0.5R' - 0.4187G' - 0.0813B'
668 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
669 [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
670 identical to one defined in SMPTE 170M/BT.601.
675 Colorspace EBU Tech. 3213 (V4L2_COLORSPACE_470_SYSTEM_BG)
676 =========================================================
678 The :ref:`tech3213` standard defines the colorspace used by PAL/SECAM
679 in 1975. In practice this colorspace is obsolete and SMPTE 170M should
680 be used instead. The default transfer function is
681 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
682 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
683 range. The chromaticities of the primary colors and the white reference
688 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
690 .. flat-table:: EBU Tech. 3213 Chromaticities
707 * - White Reference (D65)
713 The transfer function was never properly defined for this colorspace.
714 The Rec. 709 transfer function is recommended in the literature:
718 L' = 4.5L\text{, for } 0 \le L < 0.018
720 L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
722 Inverse Transfer function:
726 L = \frac{L'}{4.5} \text{, for } L' < 0.081
728 L = \left(\frac{L' + 0.099}{1.099} \right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
730 The luminance (Y') and color difference (Cb and Cr) are obtained with
731 the following ``V4L2_YCBCR_ENC_601`` encoding:
735 Y' = 0.2990R' + 0.5870G' + 0.1140B'
737 Cb = -0.1687R' - 0.3313G' + 0.5B'
739 Cr = 0.5R' - 0.4187G' - 0.0813B'
741 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
742 [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
743 identical to one defined in SMPTE 170M/BT.601.
748 Colorspace JPEG (V4L2_COLORSPACE_JPEG)
749 ======================================
751 This colorspace defines the colorspace used by most (Motion-)JPEG
752 formats. The chromaticities of the primary colors and the white
753 reference are identical to sRGB. The transfer function use is
754 ``V4L2_XFER_FUNC_SRGB``. The Y'CbCr encoding is ``V4L2_YCBCR_ENC_601``
755 with full range quantization where Y' is scaled to [0…255] and Cb/Cr are
756 scaled to [-128…128] and then clipped to [-128…127].
760 The JPEG standard does not actually store colorspace
761 information. So if something other than sRGB is used, then the driver
762 will have to set that information explicitly. Effectively
763 ``V4L2_COLORSPACE_JPEG`` can be considered to be an abbreviation for
764 ``V4L2_COLORSPACE_SRGB``, ``V4L2_YCBCR_ENC_601`` and
765 ``V4L2_QUANTIZATION_FULL_RANGE``.
767 ***************************************
768 Detailed Transfer Function Descriptions
769 ***************************************
773 Transfer Function SMPTE 2084 (V4L2_XFER_FUNC_SMPTE2084)
774 =======================================================
776 The :ref:`smpte2084` standard defines the transfer function used by
777 High Dynamic Range content.
780 m1 = (2610 / 4096) / 4
782 m2 = (2523 / 4096) * 128
786 c2 = (2413 / 4096) * 32
788 c3 = (2392 / 4096) * 32
791 L' = ((c1 + c2 * L\ :sup:`m1`) / (1 + c3 * L\ :sup:`m1`))\ :sup:`m2`
793 Inverse Transfer function:
794 L = (max(L':sup:`1/m2` - c1, 0) / (c2 - c3 *
795 L'\ :sup:`1/m2`))\ :sup:`1/m1`
797 Take care when converting between this transfer function and non-HDR transfer
798 functions: the linear RGB values [0…1] of HDR content map to a luminance range
799 of 0 to 10000 cd/m\ :sup:`2` whereas the linear RGB values of non-HDR (aka
800 Standard Dynamic Range or SDR) map to a luminance range of 0 to 100 cd/m\ :sup:`2`.
802 To go from SDR to HDR you will have to divide L by 100 first. To go in the other
803 direction you will have to multiply L by 100. Of course, this clamps all
804 luminance values over 100 cd/m\ :sup:`2` to 100 cd/m\ :sup:`2`.
806 There are better methods, see e.g. :ref:`colimg` for more in-depth information