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
64 - White Reference (D65)
71 The red, green and blue chromaticities are also often referred to as the
72 SMPTE C set, so this colorspace is sometimes called SMPTE C as well.
74 The transfer function defined for SMPTE 170M is the same as the one
79 L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le-0.018
81 L' = 4.5L \text{, for } -0.018 < L < 0.018
83 L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
85 Inverse Transfer function:
89 L = -\left( \frac{L' - 0.099}{-1.099} \right) ^{\frac{1}{0.45}} \text{, for } L' \le -0.081
91 L = \frac{L'}{4.5} \text{, for } -0.081 < L' < 0.081
93 L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
95 The luminance (Y') and color difference (Cb and Cr) are obtained with
96 the following ``V4L2_YCBCR_ENC_601`` encoding:
100 Y' = 0.299R' + 0.587G' + 0.114B'
102 Cb = -0.169R' - 0.331G' + 0.5B'
104 Cr = 0.5R' - 0.419G' - 0.081B'
106 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
107 [-0.5…0.5]. This conversion to Y'CbCr is identical to the one defined in
108 the :ref:`itu601` standard and this colorspace is sometimes called
109 BT.601 as well, even though BT.601 does not mention any color primaries.
111 The default quantization is limited range, but full range is possible
112 although rarely seen.
117 Colorspace Rec. 709 (V4L2_COLORSPACE_REC709)
118 ============================================
120 The :ref:`itu709` standard defines the colorspace used by HDTV in
121 general. The default transfer function is ``V4L2_XFER_FUNC_709``. The
122 default Y'CbCr encoding is ``V4L2_YCBCR_ENC_709``. The default Y'CbCr
123 quantization is limited range. The chromaticities of the primary colors
124 and the white reference are:
128 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
130 .. flat-table:: Rec. 709 Chromaticities
170 - White Reference (D65)
177 The full name of this standard is Rec. ITU-R BT.709-5.
179 Transfer function. Normally L is in the range [0…1], but for the
180 extended gamut xvYCC encoding values outside that range are allowed.
184 L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le -0.018
186 L' = 4.5L \text{, for } -0.018 < L < 0.018
188 L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
190 Inverse Transfer function:
194 L = -\left( \frac{L' - 0.099}{-1.099} \right)^\frac{1}{0.45} \text{, for } L' \le -0.081
196 L = \frac{L'}{4.5}\text{, for } -0.081 < L' < 0.081
198 L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
200 The luminance (Y') and color difference (Cb and Cr) are obtained with
201 the following ``V4L2_YCBCR_ENC_709`` encoding:
205 Y' = 0.2126R' + 0.7152G' + 0.0722B'
207 Cb = -0.1146R' - 0.3854G' + 0.5B'
209 Cr = 0.5R' - 0.4542G' - 0.0458B'
211 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
214 The default quantization is limited range, but full range is possible
215 although rarely seen.
217 The ``V4L2_YCBCR_ENC_709`` encoding described above is the default for
218 this colorspace, but it can be overridden with ``V4L2_YCBCR_ENC_601``,
219 in which case the BT.601 Y'CbCr encoding is used.
221 Two additional extended gamut Y'CbCr encodings are also possible with
224 The xvYCC 709 encoding (``V4L2_YCBCR_ENC_XV709``, :ref:`xvycc`) is
225 similar to the Rec. 709 encoding, but it allows for R', G' and B' values
226 that are outside the range [0…1]. The resulting Y', Cb and Cr values are
231 Y' = \frac{219}{256} * (0.2126R' + 0.7152G' + 0.0722B') + \frac{16}{256}
233 Cb = \frac{224}{256} * (-0.1146R' - 0.3854G' + 0.5B')
235 Cr = \frac{224}{256} * (0.5R' - 0.4542G' - 0.0458B')
237 The xvYCC 601 encoding (``V4L2_YCBCR_ENC_XV601``, :ref:`xvycc`) is
238 similar to the BT.601 encoding, but it allows for R', G' and B' values
239 that are outside the range [0…1]. The resulting Y', Cb and Cr values are
244 Y' = \frac{219}{256} * (0.299R' + 0.587G' + 0.114B') + \frac{16}{256}
246 Cb = \frac{224}{256} * (-0.169R' - 0.331G' + 0.5B')
248 Cr = \frac{224}{256} * (0.5R' - 0.419G' - 0.081B')
250 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
251 [-0.5…0.5]. The non-standard xvYCC 709 or xvYCC 601 encodings can be
252 used by selecting ``V4L2_YCBCR_ENC_XV709`` or ``V4L2_YCBCR_ENC_XV601``.
253 The xvYCC encodings always use full range quantization.
258 Colorspace sRGB (V4L2_COLORSPACE_SRGB)
259 ======================================
261 The :ref:`srgb` standard defines the colorspace used by most webcams
262 and computer graphics. The default transfer function is
263 ``V4L2_XFER_FUNC_SRGB``. The default Y'CbCr encoding is
264 ``V4L2_YCBCR_ENC_SYCC``. The default Y'CbCr quantization is full range.
265 The chromaticities of the primary colors and the white reference are:
269 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
271 .. flat-table:: sRGB Chromaticities
311 - White Reference (D65)
318 These chromaticities are identical to the Rec. 709 colorspace.
320 Transfer function. Note that negative values for L are only used by the
325 L' = -1.055(-L)^{\frac{1}{2.4} } + 0.055\text{, for }L < -0.0031308
327 L' = 12.92L\text{, for }-0.0031308 \le L \le 0.0031308
329 L' = 1.055L ^{\frac{1}{2.4} } - 0.055\text{, for }0.0031308 < L \le 1
331 Inverse Transfer function:
335 L = -((-L' + 0.055) / 1.055) ^{2.4}\text{, for }L' < -0.04045
337 L = L' / 12.92\text{, for }-0.04045 \le L' \le 0.04045
339 L = ((L' + 0.055) / 1.055) ^{2.4}\text{, for }L' > 0.04045
341 The luminance (Y') and color difference (Cb and Cr) are obtained with
342 the following ``V4L2_YCBCR_ENC_SYCC`` encoding as defined by
347 Y' = 0.2990R' + 0.5870G' + 0.1140B'
349 Cb = -0.1687R' - 0.3313G' + 0.5B'
351 Cr = 0.5R' - 0.4187G' - 0.0813B'
353 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
354 [-0.5…0.5]. The ``V4L2_YCBCR_ENC_SYCC`` quantization is always full
355 range. Although this Y'CbCr encoding looks very similar to the
356 ``V4L2_YCBCR_ENC_XV601`` encoding, it is not. The
357 ``V4L2_YCBCR_ENC_XV601`` scales and offsets the Y'CbCr values before
358 quantization, but this encoding does not do that.
363 Colorspace Adobe RGB (V4L2_COLORSPACE_ADOBERGB)
364 ===============================================
366 The :ref:`adobergb` standard defines the colorspace used by computer
367 graphics that use the AdobeRGB colorspace. This is also known as the
368 :ref:`oprgb` standard. The default transfer function is
369 ``V4L2_XFER_FUNC_ADOBERGB``. The default Y'CbCr encoding is
370 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is full
371 range. The chromaticities of the primary colors and the white reference
376 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
378 .. flat-table:: Adobe RGB Chromaticities
418 - White Reference (D65)
430 L' = L ^{\frac{1}{2.19921875}}
432 Inverse Transfer function:
436 L = L'^{(2.19921875)}
438 The luminance (Y') and color difference (Cb and Cr) are obtained with
439 the following ``V4L2_YCBCR_ENC_601`` encoding:
443 Y' = 0.299R' + 0.587G' + 0.114B'
445 Cb = -0.169R' - 0.331G' + 0.5B'
447 Cr = 0.5R' - 0.419G' - 0.081B'
449 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
450 [-0.5…0.5]. This transform is identical to one defined in SMPTE
451 170M/BT.601. The Y'CbCr quantization is full range.
456 Colorspace BT.2020 (V4L2_COLORSPACE_BT2020)
457 ===========================================
459 The :ref:`itu2020` standard defines the colorspace used by Ultra-high
460 definition television (UHDTV). The default transfer function is
461 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
462 ``V4L2_YCBCR_ENC_BT2020``. The default R'G'B' quantization is limited
463 range (!), and so is the default Y'CbCr quantization. The chromaticities
464 of the primary colors and the white reference are:
468 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
470 .. flat-table:: BT.2020 Chromaticities
510 - White Reference (D65)
518 Transfer function (same as Rec. 709):
522 L' = 4.5L\text{, for }0 \le L < 0.018
524 L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
526 Inverse Transfer function:
530 L = L' / 4.5\text{, for } L' < 0.081
532 L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
534 The luminance (Y') and color difference (Cb and Cr) are obtained with
535 the following ``V4L2_YCBCR_ENC_BT2020`` encoding:
539 Y' = 0.2627R' + 0.6780G' + 0.0593B'
541 Cb = -0.1396R' - 0.3604G' + 0.5B'
543 Cr = 0.5R' - 0.4598G' - 0.0402B'
545 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
546 [-0.5…0.5]. The Y'CbCr quantization is limited range.
548 There is also an alternate constant luminance R'G'B' to Yc'CbcCrc
549 (``V4L2_YCBCR_ENC_BT2020_CONST_LUM``) encoding:
557 Yc' = (0.2627R + 0.6780G + 0.0593B)'& \\
559 &Cbc = (B' - Yc') / 1.9404 \\
561 &Cbc = (B' - Yc') / 1.5816 \\
563 &Crc = (R' - Y') / 1.7184 \\
565 &Crc = (R' - Y') / 0.9936
568 Yc' is clamped to the range [0…1] and Cbc and Crc are clamped to the
569 range [-0.5…0.5]. The Yc'CbcCrc quantization is limited range.
574 Colorspace DCI-P3 (V4L2_COLORSPACE_DCI_P3)
575 ==========================================
577 The :ref:`smpte431` standard defines the colorspace used by cinema
578 projectors that use the DCI-P3 colorspace. The default transfer function
579 is ``V4L2_XFER_FUNC_DCI_P3``. The default Y'CbCr encoding is
580 ``V4L2_YCBCR_ENC_709``.
584 Note that this colorspace does not specify a
585 Y'CbCr encoding since it is not meant to be encoded to Y'CbCr. So this
586 default Y'CbCr encoding was picked because it is the HDTV encoding. The
587 default Y'CbCr quantization is limited range. The chromaticities of the
588 primary colors and the white reference are:
592 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
594 .. flat-table:: DCI-P3 Chromaticities
646 L' = L^{\frac{1}{2.6}}
648 Inverse Transfer function:
654 Y'CbCr encoding is not specified. V4L2 defaults to Rec. 709.
659 Colorspace SMPTE 240M (V4L2_COLORSPACE_SMPTE240M)
660 =================================================
662 The :ref:`smpte240m` standard was an interim standard used during the
663 early days of HDTV (1988-1998). It has been superseded by Rec. 709. The
664 default transfer function is ``V4L2_XFER_FUNC_SMPTE240M``. The default
665 Y'CbCr encoding is ``V4L2_YCBCR_ENC_SMPTE240M``. The default Y'CbCr
666 quantization is limited range. The chromaticities of the primary colors
667 and the white reference are:
671 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
673 .. flat-table:: SMPTE 240M Chromaticities
713 - White Reference (D65)
720 These chromaticities are identical to the SMPTE 170M colorspace.
726 L' = 4L\text{, for } 0 \le L < 0.0228
728 L' = 1.1115L ^{0.45} - 0.1115\text{, for } 0.0228 \le L \le 1
730 Inverse Transfer function:
734 L = \frac{L'}{4}\text{, for } 0 \le L' < 0.0913
736 L = \left( \frac{L' + 0.1115}{1.1115}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.0913
738 The luminance (Y') and color difference (Cb and Cr) are obtained with
739 the following ``V4L2_YCBCR_ENC_SMPTE240M`` encoding:
743 Y' = 0.2122R' + 0.7013G' + 0.0865B'
745 Cb = -0.1161R' - 0.3839G' + 0.5B'
747 Cr = 0.5R' - 0.4451G' - 0.0549B'
749 Yc' is clamped to the range [0…1] and Cbc and Crc are clamped to the
750 range [-0.5…0.5]. The Y'CbCr quantization is limited range.
755 Colorspace NTSC 1953 (V4L2_COLORSPACE_470_SYSTEM_M)
756 ===================================================
758 This standard defines the colorspace used by NTSC in 1953. In practice
759 this colorspace is obsolete and SMPTE 170M should be used instead. The
760 default transfer function is ``V4L2_XFER_FUNC_709``. The default Y'CbCr
761 encoding is ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is
762 limited range. The chromaticities of the primary colors and the white
767 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
769 .. flat-table:: NTSC 1953 Chromaticities
809 - White Reference (C)
818 This colorspace uses Illuminant C instead of D65 as the white
819 reference. To correctly convert an image in this colorspace to another
820 that uses D65 you need to apply a chromatic adaptation algorithm such as
823 The transfer function was never properly defined for NTSC 1953. The Rec.
824 709 transfer function is recommended in the literature:
828 L' = 4.5L\text{, for } 0 \le L < 0.018
830 L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
832 Inverse Transfer function:
836 L = \frac{L'}{4.5} \text{, for } L' < 0.081
838 L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
840 The luminance (Y') and color difference (Cb and Cr) are obtained with
841 the following ``V4L2_YCBCR_ENC_601`` encoding:
845 Y' = 0.299R' + 0.587G' + 0.114B'
847 Cb = -0.169R' - 0.331G' + 0.5B'
849 Cr = 0.5R' - 0.419G' - 0.081B'
851 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
852 [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
853 identical to one defined in SMPTE 170M/BT.601.
858 Colorspace EBU Tech. 3213 (V4L2_COLORSPACE_470_SYSTEM_BG)
859 =========================================================
861 The :ref:`tech3213` standard defines the colorspace used by PAL/SECAM
862 in 1975. In practice this colorspace is obsolete and SMPTE 170M should
863 be used instead. The default transfer function is
864 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
865 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
866 range. The chromaticities of the primary colors and the white reference
871 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
873 .. flat-table:: EBU Tech. 3213 Chromaticities
913 - White Reference (D65)
921 The transfer function was never properly defined for this colorspace.
922 The Rec. 709 transfer function is recommended in the literature:
926 L' = 4.5L\text{, for } 0 \le L < 0.018
928 L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
930 Inverse Transfer function:
934 L = \frac{L'}{4.5} \text{, for } L' < 0.081
936 L = \left(\frac{L' + 0.099}{1.099} \right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
938 The luminance (Y') and color difference (Cb and Cr) are obtained with
939 the following ``V4L2_YCBCR_ENC_601`` encoding:
943 Y' = 0.299R' + 0.587G' + 0.114B'
945 Cb = -0.169R' - 0.331G' + 0.5B'
947 Cr = 0.5R' - 0.419G' - 0.081B'
949 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
950 [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
951 identical to one defined in SMPTE 170M/BT.601.
956 Colorspace JPEG (V4L2_COLORSPACE_JPEG)
957 ======================================
959 This colorspace defines the colorspace used by most (Motion-)JPEG
960 formats. The chromaticities of the primary colors and the white
961 reference are identical to sRGB. The transfer function use is
962 ``V4L2_XFER_FUNC_SRGB``. The Y'CbCr encoding is ``V4L2_YCBCR_ENC_601``
963 with full range quantization where Y' is scaled to [0…255] and Cb/Cr are
964 scaled to [-128…128] and then clipped to [-128…127].
968 The JPEG standard does not actually store colorspace
969 information. So if something other than sRGB is used, then the driver
970 will have to set that information explicitly. Effectively
971 ``V4L2_COLORSPACE_JPEG`` can be considered to be an abbreviation for
972 ``V4L2_COLORSPACE_SRGB``, ``V4L2_YCBCR_ENC_601`` and
973 ``V4L2_QUANTIZATION_FULL_RANGE``.