Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
0002 
0003 ********************************
0004 Detailed Colorspace Descriptions
0005 ********************************
0006 
0007 
0008 .. _col-smpte-170m:
0009 
0010 Colorspace SMPTE 170M (V4L2_COLORSPACE_SMPTE170M)
0011 =================================================
0012 
0013 The :ref:`smpte170m` standard defines the colorspace used by NTSC and
0014 PAL and by SDTV in general. The default transfer function is
0015 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
0016 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
0017 range. The chromaticities of the primary colors and the white reference
0018 are:
0019 
0020 .. flat-table:: SMPTE 170M Chromaticities
0021     :header-rows:  1
0022     :stub-columns: 0
0023     :widths:       1 1 2
0024 
0025     * - Color
0026       - x
0027       - y
0028     * - Red
0029       - 0.630
0030       - 0.340
0031     * - Green
0032       - 0.310
0033       - 0.595
0034     * - Blue
0035       - 0.155
0036       - 0.070
0037     * - White Reference (D65)
0038       - 0.3127
0039       - 0.3290
0040 
0041 
0042 The red, green and blue chromaticities are also often referred to as the
0043 SMPTE C set, so this colorspace is sometimes called SMPTE C as well.
0044 
0045 The transfer function defined for SMPTE 170M is the same as the one
0046 defined in Rec. 709.
0047 
0048 .. math::
0049 
0050     L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le-0.018
0051 
0052     L' = 4.5L \text{, for } -0.018 < L < 0.018
0053 
0054     L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
0055 
0056 Inverse Transfer function:
0057 
0058 .. math::
0059 
0060     L = -\left( \frac{L' - 0.099}{-1.099} \right) ^{\frac{1}{0.45}} \text{, for } L' \le -0.081
0061 
0062     L = \frac{L'}{4.5} \text{, for } -0.081 < L' < 0.081
0063 
0064     L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
0065 
0066 The luminance (Y') and color difference (Cb and Cr) are obtained with
0067 the following ``V4L2_YCBCR_ENC_601`` encoding:
0068 
0069 .. math::
0070 
0071     Y' = 0.2990R' + 0.5870G' + 0.1140B'
0072 
0073     Cb = -0.1687R' - 0.3313G' + 0.5B'
0074 
0075     Cr = 0.5R' - 0.4187G' - 0.0813B'
0076 
0077 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
0078 [-0.5…0.5]. This conversion to Y'CbCr is identical to the one defined in
0079 the :ref:`itu601` standard and this colorspace is sometimes called
0080 BT.601 as well, even though BT.601 does not mention any color primaries.
0081 
0082 The default quantization is limited range, but full range is possible
0083 although rarely seen.
0084 
0085 
0086 .. _col-rec709:
0087 
0088 Colorspace Rec. 709 (V4L2_COLORSPACE_REC709)
0089 ============================================
0090 
0091 The :ref:`itu709` standard defines the colorspace used by HDTV in
0092 general. The default transfer function is ``V4L2_XFER_FUNC_709``. The
0093 default Y'CbCr encoding is ``V4L2_YCBCR_ENC_709``. The default Y'CbCr
0094 quantization is limited range. The chromaticities of the primary colors
0095 and the white reference are:
0096 
0097 .. flat-table:: Rec. 709 Chromaticities
0098     :header-rows:  1
0099     :stub-columns: 0
0100     :widths:       1 1 2
0101 
0102     * - Color
0103       - x
0104       - y
0105     * - Red
0106       - 0.640
0107       - 0.330
0108     * - Green
0109       - 0.300
0110       - 0.600
0111     * - Blue
0112       - 0.150
0113       - 0.060
0114     * - White Reference (D65)
0115       - 0.3127
0116       - 0.3290
0117 
0118 
0119 The full name of this standard is Rec. ITU-R BT.709-5.
0120 
0121 Transfer function. Normally L is in the range [0…1], but for the
0122 extended gamut xvYCC encoding values outside that range are allowed.
0123 
0124 .. math::
0125 
0126     L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le -0.018
0127 
0128     L' = 4.5L \text{, for } -0.018 < L < 0.018
0129 
0130     L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
0131 
0132 Inverse Transfer function:
0133 
0134 .. math::
0135 
0136     L = -\left( \frac{L' - 0.099}{-1.099} \right)^\frac{1}{0.45} \text{, for } L' \le -0.081
0137 
0138     L = \frac{L'}{4.5}\text{, for } -0.081 < L' < 0.081
0139 
0140     L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
0141 
0142 The luminance (Y') and color difference (Cb and Cr) are obtained with
0143 the following ``V4L2_YCBCR_ENC_709`` encoding:
0144 
0145 .. math::
0146 
0147     Y' = 0.2126R' + 0.7152G' + 0.0722B'
0148 
0149     Cb = -0.1146R' - 0.3854G' + 0.5B'
0150 
0151     Cr = 0.5R' - 0.4542G' - 0.0458B'
0152 
0153 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
0154 [-0.5…0.5].
0155 
0156 The default quantization is limited range, but full range is possible
0157 although rarely seen.
0158 
0159 The ``V4L2_YCBCR_ENC_709`` encoding described above is the default for
0160 this colorspace, but it can be overridden with ``V4L2_YCBCR_ENC_601``,
0161 in which case the BT.601 Y'CbCr encoding is used.
0162 
0163 Two additional extended gamut Y'CbCr encodings are also possible with
0164 this colorspace:
0165 
0166 The xvYCC 709 encoding (``V4L2_YCBCR_ENC_XV709``, :ref:`xvycc`) is
0167 similar to the Rec. 709 encoding, but it allows for R', G' and B' values
0168 that are outside the range [0…1]. The resulting Y', Cb and Cr values are
0169 scaled and offset according to the limited range formula:
0170 
0171 .. math::
0172 
0173     Y' = \frac{219}{256} * (0.2126R' + 0.7152G' + 0.0722B') + \frac{16}{256}
0174 
0175     Cb = \frac{224}{256} * (-0.1146R' - 0.3854G' + 0.5B')
0176 
0177     Cr = \frac{224}{256} * (0.5R' - 0.4542G' - 0.0458B')
0178 
0179 The xvYCC 601 encoding (``V4L2_YCBCR_ENC_XV601``, :ref:`xvycc`) is
0180 similar to the BT.601 encoding, but it allows for R', G' and B' values
0181 that are outside the range [0…1]. The resulting Y', Cb and Cr values are
0182 scaled and offset according to the limited range formula:
0183 
0184 .. math::
0185 
0186     Y' = \frac{219}{256} * (0.2990R' + 0.5870G' + 0.1140B') + \frac{16}{256}
0187 
0188     Cb = \frac{224}{256} * (-0.1687R' - 0.3313G' + 0.5B')
0189 
0190     Cr = \frac{224}{256} * (0.5R' - 0.4187G' - 0.0813B')
0191 
0192 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
0193 [-0.5…0.5] and quantized without further scaling or offsets.
0194 The non-standard xvYCC 709 or xvYCC 601 encodings can be
0195 used by selecting ``V4L2_YCBCR_ENC_XV709`` or ``V4L2_YCBCR_ENC_XV601``.
0196 As seen by the xvYCC formulas these encodings always use limited range quantization,
0197 there is no full range variant. The whole point of these extended gamut encodings
0198 is that values outside the limited range are still valid, although they
0199 map to R', G' and B' values outside the [0…1] range and are therefore outside
0200 the Rec. 709 colorspace gamut.
0201 
0202 
0203 .. _col-srgb:
0204 
0205 Colorspace sRGB (V4L2_COLORSPACE_SRGB)
0206 ======================================
0207 
0208 The :ref:`srgb` standard defines the colorspace used by most webcams
0209 and computer graphics. The default transfer function is
0210 ``V4L2_XFER_FUNC_SRGB``. The default Y'CbCr encoding is
0211 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited range.
0212 
0213 Note that the :ref:`sycc` standard specifies full range quantization,
0214 however all current capture hardware supported by the kernel convert
0215 R'G'B' to limited range Y'CbCr. So choosing full range as the default
0216 would break how applications interpret the quantization range.
0217 
0218 The chromaticities of the primary colors and the white reference are:
0219 
0220 .. flat-table:: sRGB Chromaticities
0221     :header-rows:  1
0222     :stub-columns: 0
0223     :widths:       1 1 2
0224 
0225     * - Color
0226       - x
0227       - y
0228     * - Red
0229       - 0.640
0230       - 0.330
0231     * - Green
0232       - 0.300
0233       - 0.600
0234     * - Blue
0235       - 0.150
0236       - 0.060
0237     * - White Reference (D65)
0238       - 0.3127
0239       - 0.3290
0240 
0241 
0242 These chromaticities are identical to the Rec. 709 colorspace.
0243 
0244 Transfer function. Note that negative values for L are only used by the
0245 Y'CbCr conversion.
0246 
0247 .. math::
0248 
0249     L' = -1.055(-L)^{\frac{1}{2.4} } + 0.055\text{, for }L < -0.0031308
0250 
0251     L' = 12.92L\text{, for }-0.0031308 \le L \le 0.0031308
0252 
0253     L' = 1.055L ^{\frac{1}{2.4} } - 0.055\text{, for }0.0031308 < L \le 1
0254 
0255 Inverse Transfer function:
0256 
0257 .. math::
0258 
0259     L = -((-L' + 0.055) / 1.055) ^{2.4}\text{, for }L' < -0.04045
0260 
0261     L = L' / 12.92\text{, for }-0.04045 \le L' \le 0.04045
0262 
0263     L = ((L' + 0.055) / 1.055) ^{2.4}\text{, for }L' > 0.04045
0264 
0265 The luminance (Y') and color difference (Cb and Cr) are obtained with
0266 the following ``V4L2_YCBCR_ENC_601`` encoding as defined by :ref:`sycc`:
0267 
0268 .. math::
0269 
0270     Y' = 0.2990R' + 0.5870G' + 0.1140B'
0271 
0272     Cb = -0.1687R' - 0.3313G' + 0.5B'
0273 
0274     Cr = 0.5R' - 0.4187G' - 0.0813B'
0275 
0276 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
0277 [-0.5…0.5]. This transform is identical to one defined in SMPTE
0278 170M/BT.601. The Y'CbCr quantization is limited range.
0279 
0280 
0281 .. _col-oprgb:
0282 
0283 Colorspace opRGB (V4L2_COLORSPACE_OPRGB)
0284 ===============================================
0285 
0286 The :ref:`oprgb` standard defines the colorspace used by computer
0287 graphics that use the opRGB colorspace. The default transfer function is
0288 ``V4L2_XFER_FUNC_OPRGB``. The default Y'CbCr encoding is
0289 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
0290 range.
0291 
0292 Note that the :ref:`oprgb` standard specifies full range quantization,
0293 however all current capture hardware supported by the kernel convert
0294 R'G'B' to limited range Y'CbCr. So choosing full range as the default
0295 would break how applications interpret the quantization range.
0296 
0297 The chromaticities of the primary colors and the white reference are:
0298 
0299 .. flat-table:: opRGB Chromaticities
0300     :header-rows:  1
0301     :stub-columns: 0
0302     :widths:       1 1 2
0303 
0304     * - Color
0305       - x
0306       - y
0307     * - Red
0308       - 0.6400
0309       - 0.3300
0310     * - Green
0311       - 0.2100
0312       - 0.7100
0313     * - Blue
0314       - 0.1500
0315       - 0.0600
0316     * - White Reference (D65)
0317       - 0.3127
0318       - 0.3290
0319 
0320 
0321 
0322 Transfer function:
0323 
0324 .. math::
0325 
0326     L' = L ^{\frac{1}{2.19921875}}
0327 
0328 Inverse Transfer function:
0329 
0330 .. math::
0331 
0332     L = L'^{(2.19921875)}
0333 
0334 The luminance (Y') and color difference (Cb and Cr) are obtained with
0335 the following ``V4L2_YCBCR_ENC_601`` encoding:
0336 
0337 .. math::
0338 
0339     Y' = 0.2990R' + 0.5870G' + 0.1140B'
0340 
0341     Cb = -0.1687R' - 0.3313G' + 0.5B'
0342 
0343     Cr = 0.5R' - 0.4187G' - 0.0813B'
0344 
0345 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
0346 [-0.5…0.5]. This transform is identical to one defined in SMPTE
0347 170M/BT.601. The Y'CbCr quantization is limited range.
0348 
0349 
0350 .. _col-bt2020:
0351 
0352 Colorspace BT.2020 (V4L2_COLORSPACE_BT2020)
0353 ===========================================
0354 
0355 The :ref:`itu2020` standard defines the colorspace used by Ultra-high
0356 definition television (UHDTV). The default transfer function is
0357 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
0358 ``V4L2_YCBCR_ENC_BT2020``. The default Y'CbCr quantization is limited range.
0359 The chromaticities of the primary colors and the white reference are:
0360 
0361 .. flat-table:: BT.2020 Chromaticities
0362     :header-rows:  1
0363     :stub-columns: 0
0364     :widths:       1 1 2
0365 
0366     * - Color
0367       - x
0368       - y
0369     * - Red
0370       - 0.708
0371       - 0.292
0372     * - Green
0373       - 0.170
0374       - 0.797
0375     * - Blue
0376       - 0.131
0377       - 0.046
0378     * - White Reference (D65)
0379       - 0.3127
0380       - 0.3290
0381 
0382 
0383 
0384 Transfer function (same as Rec. 709):
0385 
0386 .. math::
0387 
0388     L' = 4.5L\text{, for }0 \le L < 0.018
0389 
0390     L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
0391 
0392 Inverse Transfer function:
0393 
0394 .. math::
0395 
0396     L = L' / 4.5\text{, for } L' < 0.081
0397 
0398     L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
0399 
0400 Please note that while Rec. 709 is defined as the default transfer function
0401 by the :ref:`itu2020` standard, in practice this colorspace is often used
0402 with the :ref:`xf-smpte-2084`. In particular Ultra HD Blu-ray discs use
0403 this combination.
0404 
0405 The luminance (Y') and color difference (Cb and Cr) are obtained with
0406 the following ``V4L2_YCBCR_ENC_BT2020`` encoding:
0407 
0408 .. math::
0409 
0410     Y' = 0.2627R' + 0.6780G' + 0.0593B'
0411 
0412     Cb = -0.1396R' - 0.3604G' + 0.5B'
0413 
0414     Cr = 0.5R' - 0.4598G' - 0.0402B'
0415 
0416 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
0417 [-0.5…0.5]. The Y'CbCr quantization is limited range.
0418 
0419 There is also an alternate constant luminance R'G'B' to Yc'CbcCrc
0420 (``V4L2_YCBCR_ENC_BT2020_CONST_LUM``) encoding:
0421 
0422 Luma:
0423 
0424 .. math::
0425     :nowrap:
0426 
0427     \begin{align*}
0428     Yc' = (0.2627R + 0.6780G + 0.0593B)'& \\
0429     B' - Yc' \le 0:& \\
0430         &Cbc = (B' - Yc') / 1.9404 \\
0431     B' - Yc' > 0: & \\
0432         &Cbc = (B' - Yc') / 1.5816 \\
0433     R' - Yc' \le 0:& \\
0434         &Crc = (R' - Y') / 1.7184 \\
0435     R' - Yc' > 0:& \\
0436         &Crc = (R' - Y') / 0.9936
0437     \end{align*}
0438 
0439 Yc' is clamped to the range [0…1] and Cbc and Crc are clamped to the
0440 range [-0.5…0.5]. The Yc'CbcCrc quantization is limited range.
0441 
0442 
0443 .. _col-dcip3:
0444 
0445 Colorspace DCI-P3 (V4L2_COLORSPACE_DCI_P3)
0446 ==========================================
0447 
0448 The :ref:`smpte431` standard defines the colorspace used by cinema
0449 projectors that use the DCI-P3 colorspace. The default transfer function
0450 is ``V4L2_XFER_FUNC_DCI_P3``. The default Y'CbCr encoding is
0451 ``V4L2_YCBCR_ENC_709``. The default Y'CbCr quantization is limited range.
0452 
0453 .. note::
0454 
0455    Note that this colorspace standard does not specify a
0456    Y'CbCr encoding since it is not meant to be encoded to Y'CbCr. So this
0457    default Y'CbCr encoding was picked because it is the HDTV encoding.
0458 
0459 The chromaticities of the primary colors and the white reference are:
0460 
0461 
0462 .. flat-table:: DCI-P3 Chromaticities
0463     :header-rows:  1
0464     :stub-columns: 0
0465     :widths:       1 1 2
0466 
0467     * - Color
0468       - x
0469       - y
0470     * - Red
0471       - 0.6800
0472       - 0.3200
0473     * - Green
0474       - 0.2650
0475       - 0.6900
0476     * - Blue
0477       - 0.1500
0478       - 0.0600
0479     * - White Reference
0480       - 0.3140
0481       - 0.3510
0482 
0483 
0484 
0485 Transfer function:
0486 
0487 .. math::
0488 
0489     L' = L^{\frac{1}{2.6}}
0490 
0491 Inverse Transfer function:
0492 
0493 .. math::
0494 
0495     L = L'^{(2.6)}
0496 
0497 Y'CbCr encoding is not specified. V4L2 defaults to Rec. 709.
0498 
0499 
0500 .. _col-smpte-240m:
0501 
0502 Colorspace SMPTE 240M (V4L2_COLORSPACE_SMPTE240M)
0503 =================================================
0504 
0505 The :ref:`smpte240m` standard was an interim standard used during the
0506 early days of HDTV (1988-1998). It has been superseded by Rec. 709. The
0507 default transfer function is ``V4L2_XFER_FUNC_SMPTE240M``. The default
0508 Y'CbCr encoding is ``V4L2_YCBCR_ENC_SMPTE240M``. The default Y'CbCr
0509 quantization is limited range. The chromaticities of the primary colors
0510 and the white reference are:
0511 
0512 
0513 .. flat-table:: SMPTE 240M Chromaticities
0514     :header-rows:  1
0515     :stub-columns: 0
0516     :widths:       1 1 2
0517 
0518     * - Color
0519       - x
0520       - y
0521     * - Red
0522       - 0.630
0523       - 0.340
0524     * - Green
0525       - 0.310
0526       - 0.595
0527     * - Blue
0528       - 0.155
0529       - 0.070
0530     * - White Reference (D65)
0531       - 0.3127
0532       - 0.3290
0533 
0534 
0535 These chromaticities are identical to the SMPTE 170M colorspace.
0536 
0537 Transfer function:
0538 
0539 .. math::
0540 
0541     L' = 4L\text{, for } 0 \le L < 0.0228
0542 
0543     L' = 1.1115L ^{0.45} - 0.1115\text{, for } 0.0228 \le L \le 1
0544 
0545 Inverse Transfer function:
0546 
0547 .. math::
0548 
0549     L = \frac{L'}{4}\text{, for } 0 \le L' < 0.0913
0550 
0551     L = \left( \frac{L' + 0.1115}{1.1115}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.0913
0552 
0553 The luminance (Y') and color difference (Cb and Cr) are obtained with
0554 the following ``V4L2_YCBCR_ENC_SMPTE240M`` encoding:
0555 
0556 .. math::
0557 
0558     Y' = 0.2122R' + 0.7013G' + 0.0865B'
0559 
0560     Cb = -0.1161R' - 0.3839G' + 0.5B'
0561 
0562     Cr = 0.5R' - 0.4451G' - 0.0549B'
0563 
0564 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the
0565 range [-0.5…0.5]. The Y'CbCr quantization is limited range.
0566 
0567 
0568 .. _col-sysm:
0569 
0570 Colorspace NTSC 1953 (V4L2_COLORSPACE_470_SYSTEM_M)
0571 ===================================================
0572 
0573 This standard defines the colorspace used by NTSC in 1953. In practice
0574 this colorspace is obsolete and SMPTE 170M should be used instead. The
0575 default transfer function is ``V4L2_XFER_FUNC_709``. The default Y'CbCr
0576 encoding is ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is
0577 limited range. The chromaticities of the primary colors and the white
0578 reference are:
0579 
0580 
0581 .. flat-table:: NTSC 1953 Chromaticities
0582     :header-rows:  1
0583     :stub-columns: 0
0584     :widths:       1 1 2
0585 
0586     * - Color
0587       - x
0588       - y
0589     * - Red
0590       - 0.67
0591       - 0.33
0592     * - Green
0593       - 0.21
0594       - 0.71
0595     * - Blue
0596       - 0.14
0597       - 0.08
0598     * - White Reference (C)
0599       - 0.310
0600       - 0.316
0601 
0602 
0603 .. note::
0604 
0605    This colorspace uses Illuminant C instead of D65 as the white
0606    reference. To correctly convert an image in this colorspace to another
0607    that uses D65 you need to apply a chromatic adaptation algorithm such as
0608    the Bradford method.
0609 
0610 The transfer function was never properly defined for NTSC 1953. The Rec.
0611 709 transfer function is recommended in the literature:
0612 
0613 .. math::
0614 
0615     L' = 4.5L\text{, for } 0 \le L < 0.018
0616 
0617     L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
0618 
0619 Inverse Transfer function:
0620 
0621 .. math::
0622 
0623     L = \frac{L'}{4.5} \text{, for } L' < 0.081
0624 
0625     L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
0626 
0627 The luminance (Y') and color difference (Cb and Cr) are obtained with
0628 the following ``V4L2_YCBCR_ENC_601`` encoding:
0629 
0630 .. math::
0631 
0632     Y' = 0.2990R' + 0.5870G' + 0.1140B'
0633 
0634     Cb = -0.1687R' - 0.3313G' + 0.5B'
0635 
0636     Cr = 0.5R' - 0.4187G' - 0.0813B'
0637 
0638 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
0639 [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
0640 identical to one defined in SMPTE 170M/BT.601.
0641 
0642 
0643 .. _col-sysbg:
0644 
0645 Colorspace EBU Tech. 3213 (V4L2_COLORSPACE_470_SYSTEM_BG)
0646 =========================================================
0647 
0648 The :ref:`tech3213` standard defines the colorspace used by PAL/SECAM
0649 in 1975. Note that this colorspace is not supported by the HDMI interface.
0650 Instead :ref:`tech3321` recommends that Rec. 709 is used instead for HDMI.
0651 The default transfer function is
0652 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
0653 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
0654 range. The chromaticities of the primary colors and the white reference
0655 are:
0656 
0657 
0658 .. flat-table:: EBU Tech. 3213 Chromaticities
0659     :header-rows:  1
0660     :stub-columns: 0
0661     :widths:       1 1 2
0662 
0663     * - Color
0664       - x
0665       - y
0666     * - Red
0667       - 0.64
0668       - 0.33
0669     * - Green
0670       - 0.29
0671       - 0.60
0672     * - Blue
0673       - 0.15
0674       - 0.06
0675     * - White Reference (D65)
0676       - 0.3127
0677       - 0.3290
0678 
0679 
0680 
0681 The transfer function was never properly defined for this colorspace.
0682 The Rec. 709 transfer function is recommended in the literature:
0683 
0684 .. math::
0685 
0686     L' = 4.5L\text{, for } 0 \le L < 0.018
0687 
0688     L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
0689 
0690 Inverse Transfer function:
0691 
0692 .. math::
0693 
0694     L = \frac{L'}{4.5} \text{, for } L' < 0.081
0695 
0696     L = \left(\frac{L' + 0.099}{1.099} \right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
0697 
0698 The luminance (Y') and color difference (Cb and Cr) are obtained with
0699 the following ``V4L2_YCBCR_ENC_601`` encoding:
0700 
0701 .. math::
0702 
0703     Y' = 0.2990R' + 0.5870G' + 0.1140B'
0704 
0705     Cb = -0.1687R' - 0.3313G' + 0.5B'
0706 
0707     Cr = 0.5R' - 0.4187G' - 0.0813B'
0708 
0709 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
0710 [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
0711 identical to one defined in SMPTE 170M/BT.601.
0712 
0713 
0714 .. _col-jpeg:
0715 
0716 Colorspace JPEG (V4L2_COLORSPACE_JPEG)
0717 ======================================
0718 
0719 This colorspace defines the colorspace used by most (Motion-)JPEG
0720 formats. The chromaticities of the primary colors and the white
0721 reference are identical to sRGB. The transfer function use is
0722 ``V4L2_XFER_FUNC_SRGB``. The Y'CbCr encoding is ``V4L2_YCBCR_ENC_601``
0723 with full range quantization where Y' is scaled to [0…255] and Cb/Cr are
0724 scaled to [-128…128] and then clipped to [-128…127].
0725 
0726 .. note::
0727 
0728    The JPEG standard does not actually store colorspace
0729    information. So if something other than sRGB is used, then the driver
0730    will have to set that information explicitly. Effectively
0731    ``V4L2_COLORSPACE_JPEG`` can be considered to be an abbreviation for
0732    ``V4L2_COLORSPACE_SRGB``, ``V4L2_XFER_FUNC_SRGB``, ``V4L2_YCBCR_ENC_601``
0733    and ``V4L2_QUANTIZATION_FULL_RANGE``.
0734 
0735 ***************************************
0736 Detailed Transfer Function Descriptions
0737 ***************************************
0738 
0739 .. _xf-smpte-2084:
0740 
0741 Transfer Function SMPTE 2084 (V4L2_XFER_FUNC_SMPTE2084)
0742 =======================================================
0743 
0744 The :ref:`smpte2084` standard defines the transfer function used by
0745 High Dynamic Range content.
0746 
0747 Constants:
0748     m1 = (2610 / 4096) / 4
0749 
0750     m2 = (2523 / 4096) * 128
0751 
0752     c1 = 3424 / 4096
0753 
0754     c2 = (2413 / 4096) * 32
0755 
0756     c3 = (2392 / 4096) * 32
0757 
0758 Transfer function:
0759     L' = ((c1 + c2 * L\ :sup:`m1`) / (1 + c3 * L\ :sup:`m1`))\ :sup:`m2`
0760 
0761 Inverse Transfer function:
0762     L = (max(L':sup:`1/m2` - c1, 0) / (c2 - c3 *
0763     L'\ :sup:`1/m2`))\ :sup:`1/m1`
0764 
0765 Take care when converting between this transfer function and non-HDR transfer
0766 functions: the linear RGB values [0…1] of HDR content map to a luminance range
0767 of 0 to 10000 cd/m\ :sup:`2` whereas the linear RGB values of non-HDR (aka
0768 Standard Dynamic Range or SDR) map to a luminance range of 0 to 100 cd/m\ :sup:`2`.
0769 
0770 To go from SDR to HDR you will have to divide L by 100 first. To go in the other
0771 direction you will have to multiply L by 100. Of course, this clamps all
0772 luminance values over 100 cd/m\ :sup:`2` to 100 cd/m\ :sup:`2`.
0773 
0774 There are better methods, see e.g. :ref:`colimg` for more in-depth information
0775 about this.