Merge tag 'pstore-v4.20-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees...
[sfrench/cifs-2.6.git] / Documentation / media / uapi / v4l / colorspaces-details.rst
1 .. -*- coding: utf-8; mode: rst -*-
2
3 ********************************
4 Detailed Colorspace Descriptions
5 ********************************
6
7
8 .. _col-smpte-170m:
9
10 Colorspace SMPTE 170M (V4L2_COLORSPACE_SMPTE170M)
11 =================================================
12
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
18 are:
19
20
21
22 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
23
24 .. flat-table:: SMPTE 170M Chromaticities
25     :header-rows:  1
26     :stub-columns: 0
27     :widths:       1 1 2
28
29     * - Color
30       - x
31       - y
32     * - Red
33       - 0.630
34       - 0.340
35     * - Green
36       - 0.310
37       - 0.595
38     * - Blue
39       - 0.155
40       - 0.070
41     * - White Reference (D65)
42       - 0.3127
43       - 0.3290
44
45
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.
48
49 The transfer function defined for SMPTE 170M is the same as the one
50 defined in Rec. 709.
51
52 .. math::
53
54     L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le-0.018
55
56     L' = 4.5L \text{, for } -0.018 < L < 0.018
57
58     L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
59
60 Inverse Transfer function:
61
62 .. math::
63
64     L = -\left( \frac{L' - 0.099}{-1.099} \right) ^{\frac{1}{0.45}} \text{, for } L' \le -0.081
65
66     L = \frac{L'}{4.5} \text{, for } -0.081 < L' < 0.081
67
68     L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
69
70 The luminance (Y') and color difference (Cb and Cr) are obtained with
71 the following ``V4L2_YCBCR_ENC_601`` encoding:
72
73 .. math::
74
75     Y' = 0.2990R' + 0.5870G' + 0.1140B'
76
77     Cb = -0.1687R' - 0.3313G' + 0.5B'
78
79     Cr = 0.5R' - 0.4187G' - 0.0813B'
80
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.
85
86 The default quantization is limited range, but full range is possible
87 although rarely seen.
88
89
90 .. _col-rec709:
91
92 Colorspace Rec. 709 (V4L2_COLORSPACE_REC709)
93 ============================================
94
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:
100
101
102
103 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
104
105 .. flat-table:: Rec. 709 Chromaticities
106     :header-rows:  1
107     :stub-columns: 0
108     :widths:       1 1 2
109
110     * - Color
111       - x
112       - y
113     * - Red
114       - 0.640
115       - 0.330
116     * - Green
117       - 0.300
118       - 0.600
119     * - Blue
120       - 0.150
121       - 0.060
122     * - White Reference (D65)
123       - 0.3127
124       - 0.3290
125
126
127 The full name of this standard is Rec. ITU-R BT.709-5.
128
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.
131
132 .. math::
133
134     L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le -0.018
135
136     L' = 4.5L \text{, for } -0.018 < L < 0.018
137
138     L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
139
140 Inverse Transfer function:
141
142 .. math::
143
144     L = -\left( \frac{L' - 0.099}{-1.099} \right)^\frac{1}{0.45} \text{, for } L' \le -0.081
145
146     L = \frac{L'}{4.5}\text{, for } -0.081 < L' < 0.081
147
148     L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
149
150 The luminance (Y') and color difference (Cb and Cr) are obtained with
151 the following ``V4L2_YCBCR_ENC_709`` encoding:
152
153 .. math::
154
155     Y' = 0.2126R' + 0.7152G' + 0.0722B'
156
157     Cb = -0.1146R' - 0.3854G' + 0.5B'
158
159     Cr = 0.5R' - 0.4542G' - 0.0458B'
160
161 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
162 [-0.5…0.5].
163
164 The default quantization is limited range, but full range is possible
165 although rarely seen.
166
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.
170
171 Two additional extended gamut Y'CbCr encodings are also possible with
172 this colorspace:
173
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:
178
179 .. math::
180
181     Y' = \frac{219}{256} * (0.2126R' + 0.7152G' + 0.0722B') + \frac{16}{256}
182
183     Cb = \frac{224}{256} * (-0.1146R' - 0.3854G' + 0.5B')
184
185     Cr = \frac{224}{256} * (0.5R' - 0.4542G' - 0.0458B')
186
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:
191
192 .. math::
193
194     Y' = \frac{219}{256} * (0.2990R' + 0.5870G' + 0.1140B') + \frac{16}{256}
195
196     Cb = \frac{224}{256} * (-0.1687R' - 0.3313G' + 0.5B')
197
198     Cr = \frac{224}{256} * (0.5R' - 0.4187G' - 0.0813B')
199
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.
209
210
211 .. _col-srgb:
212
213 Colorspace sRGB (V4L2_COLORSPACE_SRGB)
214 ======================================
215
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.
220
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.
225
226 The chromaticities of the primary colors and the white reference are:
227
228
229
230 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
231
232 .. flat-table:: sRGB Chromaticities
233     :header-rows:  1
234     :stub-columns: 0
235     :widths:       1 1 2
236
237     * - Color
238       - x
239       - y
240     * - Red
241       - 0.640
242       - 0.330
243     * - Green
244       - 0.300
245       - 0.600
246     * - Blue
247       - 0.150
248       - 0.060
249     * - White Reference (D65)
250       - 0.3127
251       - 0.3290
252
253
254 These chromaticities are identical to the Rec. 709 colorspace.
255
256 Transfer function. Note that negative values for L are only used by the
257 Y'CbCr conversion.
258
259 .. math::
260
261     L' = -1.055(-L)^{\frac{1}{2.4} } + 0.055\text{, for }L < -0.0031308
262
263     L' = 12.92L\text{, for }-0.0031308 \le L \le 0.0031308
264
265     L' = 1.055L ^{\frac{1}{2.4} } - 0.055\text{, for }0.0031308 < L \le 1
266
267 Inverse Transfer function:
268
269 .. math::
270
271     L = -((-L' + 0.055) / 1.055) ^{2.4}\text{, for }L' < -0.04045
272
273     L = L' / 12.92\text{, for }-0.04045 \le L' \le 0.04045
274
275     L = ((L' + 0.055) / 1.055) ^{2.4}\text{, for }L' > 0.04045
276
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`:
279
280 .. math::
281
282     Y' = 0.2990R' + 0.5870G' + 0.1140B'
283
284     Cb = -0.1687R' - 0.3313G' + 0.5B'
285
286     Cr = 0.5R' - 0.4187G' - 0.0813B'
287
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.
291
292
293 .. _col-oprgb:
294
295 Colorspace opRGB (V4L2_COLORSPACE_OPRGB)
296 ===============================================
297
298 The :ref:`oprgb` standard defines the colorspace used by computer
299 graphics that use the opRGB colorspace. The default transfer function is
300 ``V4L2_XFER_FUNC_OPRGB``. The default Y'CbCr encoding is
301 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
302 range.
303
304 Note that the :ref:`oprgb` standard specifies full range quantization,
305 however all current capture hardware supported by the kernel convert
306 R'G'B' to limited range Y'CbCr. So choosing full range as the default
307 would break how applications interpret the quantization range.
308
309 The chromaticities of the primary colors and the white reference are:
310
311
312 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
313
314 .. flat-table:: opRGB Chromaticities
315     :header-rows:  1
316     :stub-columns: 0
317     :widths:       1 1 2
318
319     * - Color
320       - x
321       - y
322     * - Red
323       - 0.6400
324       - 0.3300
325     * - Green
326       - 0.2100
327       - 0.7100
328     * - Blue
329       - 0.1500
330       - 0.0600
331     * - White Reference (D65)
332       - 0.3127
333       - 0.3290
334
335
336
337 Transfer function:
338
339 .. math::
340
341     L' = L ^{\frac{1}{2.19921875}}
342
343 Inverse Transfer function:
344
345 .. math::
346
347     L = L'^{(2.19921875)}
348
349 The luminance (Y') and color difference (Cb and Cr) are obtained with
350 the following ``V4L2_YCBCR_ENC_601`` encoding:
351
352 .. math::
353
354     Y' = 0.2990R' + 0.5870G' + 0.1140B'
355
356     Cb = -0.1687R' - 0.3313G' + 0.5B'
357
358     Cr = 0.5R' - 0.4187G' - 0.0813B'
359
360 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
361 [-0.5…0.5]. This transform is identical to one defined in SMPTE
362 170M/BT.601. The Y'CbCr quantization is limited range.
363
364
365 .. _col-bt2020:
366
367 Colorspace BT.2020 (V4L2_COLORSPACE_BT2020)
368 ===========================================
369
370 The :ref:`itu2020` standard defines the colorspace used by Ultra-high
371 definition television (UHDTV). The default transfer function is
372 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
373 ``V4L2_YCBCR_ENC_BT2020``. The default R'G'B' quantization is limited
374 range (!), and so is the default Y'CbCr quantization. The chromaticities
375 of the primary colors and the white reference are:
376
377
378
379 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
380
381 .. flat-table:: BT.2020 Chromaticities
382     :header-rows:  1
383     :stub-columns: 0
384     :widths:       1 1 2
385
386     * - Color
387       - x
388       - y
389     * - Red
390       - 0.708
391       - 0.292
392     * - Green
393       - 0.170
394       - 0.797
395     * - Blue
396       - 0.131
397       - 0.046
398     * - White Reference (D65)
399       - 0.3127
400       - 0.3290
401
402
403
404 Transfer function (same as Rec. 709):
405
406 .. math::
407
408     L' = 4.5L\text{, for }0 \le L < 0.018
409
410     L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
411
412 Inverse Transfer function:
413
414 .. math::
415
416     L = L' / 4.5\text{, for } L' < 0.081
417
418     L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
419
420 Please note that while Rec. 709 is defined as the default transfer function
421 by the :ref:`itu2020` standard, in practice this colorspace is often used
422 with the :ref:`xf-smpte-2084`. In particular Ultra HD Blu-ray discs use
423 this combination.
424
425 The luminance (Y') and color difference (Cb and Cr) are obtained with
426 the following ``V4L2_YCBCR_ENC_BT2020`` encoding:
427
428 .. math::
429
430     Y' = 0.2627R' + 0.6780G' + 0.0593B'
431
432     Cb = -0.1396R' - 0.3604G' + 0.5B'
433
434     Cr = 0.5R' - 0.4598G' - 0.0402B'
435
436 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
437 [-0.5…0.5]. The Y'CbCr quantization is limited range.
438
439 There is also an alternate constant luminance R'G'B' to Yc'CbcCrc
440 (``V4L2_YCBCR_ENC_BT2020_CONST_LUM``) encoding:
441
442 Luma:
443
444 .. math::
445     :nowrap:
446
447     \begin{align*}
448     Yc' = (0.2627R + 0.6780G + 0.0593B)'& \\
449     B' - Yc' \le 0:& \\
450         &Cbc = (B' - Yc') / 1.9404 \\
451     B' - Yc' > 0: & \\
452         &Cbc = (B' - Yc') / 1.5816 \\
453     R' - Yc' \le 0:& \\
454         &Crc = (R' - Y') / 1.7184 \\
455     R' - Yc' > 0:& \\
456         &Crc = (R' - Y') / 0.9936
457     \end{align*}
458
459 Yc' is clamped to the range [0…1] and Cbc and Crc are clamped to the
460 range [-0.5…0.5]. The Yc'CbcCrc quantization is limited range.
461
462
463 .. _col-dcip3:
464
465 Colorspace DCI-P3 (V4L2_COLORSPACE_DCI_P3)
466 ==========================================
467
468 The :ref:`smpte431` standard defines the colorspace used by cinema
469 projectors that use the DCI-P3 colorspace. The default transfer function
470 is ``V4L2_XFER_FUNC_DCI_P3``. The default Y'CbCr encoding is
471 ``V4L2_YCBCR_ENC_709``. The default Y'CbCr quantization is limited range.
472
473 .. note::
474
475    Note that this colorspace standard does not specify a
476    Y'CbCr encoding since it is not meant to be encoded to Y'CbCr. So this
477    default Y'CbCr encoding was picked because it is the HDTV encoding.
478
479 The chromaticities of the primary colors and the white reference are:
480
481
482
483 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
484
485 .. flat-table:: DCI-P3 Chromaticities
486     :header-rows:  1
487     :stub-columns: 0
488     :widths:       1 1 2
489
490     * - Color
491       - x
492       - y
493     * - Red
494       - 0.6800
495       - 0.3200
496     * - Green
497       - 0.2650
498       - 0.6900
499     * - Blue
500       - 0.1500
501       - 0.0600
502     * - White Reference
503       - 0.3140
504       - 0.3510
505
506
507
508 Transfer function:
509
510 .. math::
511
512     L' = L^{\frac{1}{2.6}}
513
514 Inverse Transfer function:
515
516 .. math::
517
518     L = L'^{(2.6)}
519
520 Y'CbCr encoding is not specified. V4L2 defaults to Rec. 709.
521
522
523 .. _col-smpte-240m:
524
525 Colorspace SMPTE 240M (V4L2_COLORSPACE_SMPTE240M)
526 =================================================
527
528 The :ref:`smpte240m` standard was an interim standard used during the
529 early days of HDTV (1988-1998). It has been superseded by Rec. 709. The
530 default transfer function is ``V4L2_XFER_FUNC_SMPTE240M``. The default
531 Y'CbCr encoding is ``V4L2_YCBCR_ENC_SMPTE240M``. The default Y'CbCr
532 quantization is limited range. The chromaticities of the primary colors
533 and the white reference are:
534
535
536
537 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
538
539 .. flat-table:: SMPTE 240M Chromaticities
540     :header-rows:  1
541     :stub-columns: 0
542     :widths:       1 1 2
543
544     * - Color
545       - x
546       - y
547     * - Red
548       - 0.630
549       - 0.340
550     * - Green
551       - 0.310
552       - 0.595
553     * - Blue
554       - 0.155
555       - 0.070
556     * - White Reference (D65)
557       - 0.3127
558       - 0.3290
559
560
561 These chromaticities are identical to the SMPTE 170M colorspace.
562
563 Transfer function:
564
565 .. math::
566
567     L' = 4L\text{, for } 0 \le L < 0.0228
568
569     L' = 1.1115L ^{0.45} - 0.1115\text{, for } 0.0228 \le L \le 1
570
571 Inverse Transfer function:
572
573 .. math::
574
575     L = \frac{L'}{4}\text{, for } 0 \le L' < 0.0913
576
577     L = \left( \frac{L' + 0.1115}{1.1115}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.0913
578
579 The luminance (Y') and color difference (Cb and Cr) are obtained with
580 the following ``V4L2_YCBCR_ENC_SMPTE240M`` encoding:
581
582 .. math::
583
584     Y' = 0.2122R' + 0.7013G' + 0.0865B'
585
586     Cb = -0.1161R' - 0.3839G' + 0.5B'
587
588     Cr = 0.5R' - 0.4451G' - 0.0549B'
589
590 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the
591 range [-0.5…0.5]. The Y'CbCr quantization is limited range.
592
593
594 .. _col-sysm:
595
596 Colorspace NTSC 1953 (V4L2_COLORSPACE_470_SYSTEM_M)
597 ===================================================
598
599 This standard defines the colorspace used by NTSC in 1953. In practice
600 this colorspace is obsolete and SMPTE 170M should be used instead. The
601 default transfer function is ``V4L2_XFER_FUNC_709``. The default Y'CbCr
602 encoding is ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is
603 limited range. The chromaticities of the primary colors and the white
604 reference are:
605
606
607
608 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
609
610 .. flat-table:: NTSC 1953 Chromaticities
611     :header-rows:  1
612     :stub-columns: 0
613     :widths:       1 1 2
614
615     * - Color
616       - x
617       - y
618     * - Red
619       - 0.67
620       - 0.33
621     * - Green
622       - 0.21
623       - 0.71
624     * - Blue
625       - 0.14
626       - 0.08
627     * - White Reference (C)
628       - 0.310
629       - 0.316
630
631
632 .. note::
633
634    This colorspace uses Illuminant C instead of D65 as the white
635    reference. To correctly convert an image in this colorspace to another
636    that uses D65 you need to apply a chromatic adaptation algorithm such as
637    the Bradford method.
638
639 The transfer function was never properly defined for NTSC 1953. The Rec.
640 709 transfer function is recommended in the literature:
641
642 .. math::
643
644     L' = 4.5L\text{, for } 0 \le L < 0.018
645
646     L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
647
648 Inverse Transfer function:
649
650 .. math::
651
652     L = \frac{L'}{4.5} \text{, for } L' < 0.081
653
654     L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
655
656 The luminance (Y') and color difference (Cb and Cr) are obtained with
657 the following ``V4L2_YCBCR_ENC_601`` encoding:
658
659 .. math::
660
661     Y' = 0.2990R' + 0.5870G' + 0.1140B'
662
663     Cb = -0.1687R' - 0.3313G' + 0.5B'
664
665     Cr = 0.5R' - 0.4187G' - 0.0813B'
666
667 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
668 [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
669 identical to one defined in SMPTE 170M/BT.601.
670
671
672 .. _col-sysbg:
673
674 Colorspace EBU Tech. 3213 (V4L2_COLORSPACE_470_SYSTEM_BG)
675 =========================================================
676
677 The :ref:`tech3213` standard defines the colorspace used by PAL/SECAM
678 in 1975. In practice this colorspace is obsolete and SMPTE 170M should
679 be used instead. The default transfer function is
680 ``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
681 ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
682 range. The chromaticities of the primary colors and the white reference
683 are:
684
685
686
687 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
688
689 .. flat-table:: EBU Tech. 3213 Chromaticities
690     :header-rows:  1
691     :stub-columns: 0
692     :widths:       1 1 2
693
694     * - Color
695       - x
696       - y
697     * - Red
698       - 0.64
699       - 0.33
700     * - Green
701       - 0.29
702       - 0.60
703     * - Blue
704       - 0.15
705       - 0.06
706     * - White Reference (D65)
707       - 0.3127
708       - 0.3290
709
710
711
712 The transfer function was never properly defined for this colorspace.
713 The Rec. 709 transfer function is recommended in the literature:
714
715 .. math::
716
717     L' = 4.5L\text{, for } 0 \le L < 0.018
718
719     L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
720
721 Inverse Transfer function:
722
723 .. math::
724
725     L = \frac{L'}{4.5} \text{, for } L' < 0.081
726
727     L = \left(\frac{L' + 0.099}{1.099} \right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
728
729 The luminance (Y') and color difference (Cb and Cr) are obtained with
730 the following ``V4L2_YCBCR_ENC_601`` encoding:
731
732 .. math::
733
734     Y' = 0.2990R' + 0.5870G' + 0.1140B'
735
736     Cb = -0.1687R' - 0.3313G' + 0.5B'
737
738     Cr = 0.5R' - 0.4187G' - 0.0813B'
739
740 Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
741 [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
742 identical to one defined in SMPTE 170M/BT.601.
743
744
745 .. _col-jpeg:
746
747 Colorspace JPEG (V4L2_COLORSPACE_JPEG)
748 ======================================
749
750 This colorspace defines the colorspace used by most (Motion-)JPEG
751 formats. The chromaticities of the primary colors and the white
752 reference are identical to sRGB. The transfer function use is
753 ``V4L2_XFER_FUNC_SRGB``. The Y'CbCr encoding is ``V4L2_YCBCR_ENC_601``
754 with full range quantization where Y' is scaled to [0…255] and Cb/Cr are
755 scaled to [-128…128] and then clipped to [-128…127].
756
757 .. note::
758
759    The JPEG standard does not actually store colorspace
760    information. So if something other than sRGB is used, then the driver
761    will have to set that information explicitly. Effectively
762    ``V4L2_COLORSPACE_JPEG`` can be considered to be an abbreviation for
763    ``V4L2_COLORSPACE_SRGB``, ``V4L2_YCBCR_ENC_601`` and
764    ``V4L2_QUANTIZATION_FULL_RANGE``.
765
766 ***************************************
767 Detailed Transfer Function Descriptions
768 ***************************************
769
770 .. _xf-smpte-2084:
771
772 Transfer Function SMPTE 2084 (V4L2_XFER_FUNC_SMPTE2084)
773 =======================================================
774
775 The :ref:`smpte2084` standard defines the transfer function used by
776 High Dynamic Range content.
777
778 Constants:
779     m1 = (2610 / 4096) / 4
780
781     m2 = (2523 / 4096) * 128
782
783     c1 = 3424 / 4096
784
785     c2 = (2413 / 4096) * 32
786
787     c3 = (2392 / 4096) * 32
788
789 Transfer function:
790     L' = ((c1 + c2 * L\ :sup:`m1`) / (1 + c3 * L\ :sup:`m1`))\ :sup:`m2`
791
792 Inverse Transfer function:
793     L = (max(L':sup:`1/m2` - c1, 0) / (c2 - c3 *
794     L'\ :sup:`1/m2`))\ :sup:`1/m1`
795
796 Take care when converting between this transfer function and non-HDR transfer
797 functions: the linear RGB values [0…1] of HDR content map to a luminance range
798 of 0 to 10000 cd/m\ :sup:`2` whereas the linear RGB values of non-HDR (aka
799 Standard Dynamic Range or SDR) map to a luminance range of 0 to 100 cd/m\ :sup:`2`.
800
801 To go from SDR to HDR you will have to divide L by 100 first. To go in the other
802 direction you will have to multiply L by 100. Of course, this clamps all
803 luminance values over 100 cd/m\ :sup:`2` to 100 cd/m\ :sup:`2`.
804
805 There are better methods, see e.g. :ref:`colimg` for more in-depth information
806 about this.