doc-rst: linux_tv DocBook to reST migration (docs-next)
[deliverable/linux.git] / Documentation / linux_tv / media / v4l / pixfmt-007.rst
CommitLineData
5377d91f
MH
1.. -*- coding: utf-8; mode: rst -*-
2
3********************************
4Detailed Colorspace Descriptions
5********************************
6
7
8.. _col-smpte-170m:
9
10Colorspace SMPTE 170M (V4L2_COLORSPACE_SMPTE170M)
11=================================================
12
13The :ref:`smpte170m` standard defines the colorspace used by NTSC and
14PAL 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
17range. The chromaticities of the primary colors and the white reference
18are:
19
20
21
22.. flat-table:: SMPTE 170M Chromaticities
23 :header-rows: 1
24 :stub-columns: 0
25 :widths: 1 1 2
26
27
28 - .. row 1
29
30 - Color
31
32 - x
33
34 - y
35
36 - .. row 2
37
38 - Red
39
40 - 0.630
41
42 - 0.340
43
44 - .. row 3
45
46 - Green
47
48 - 0.310
49
50 - 0.595
51
52 - .. row 4
53
54 - Blue
55
56 - 0.155
57
58 - 0.070
59
60 - .. row 5
61
62 - White Reference (D65)
63
64 - 0.3127
65
66 - 0.3290
67
68
69The red, green and blue chromaticities are also often referred to as the
70SMPTE C set, so this colorspace is sometimes called SMPTE C as well.
71
72The transfer function defined for SMPTE 170M is the same as the one
73defined in Rec. 709.
74 L' = -1.099(-L):sup:`0.45` + 0.099 for L ≤ -0.018
75
76 L' = 4.5L for -0.018 < L < 0.018
77
78 L' = 1.099L\ :sup:`0.45` - 0.099 for L ≥ 0.018
79
80Inverse Transfer function:
81 L = -((L' - 0.099) / -1.099):sup:`1/0.45` for L' ≤ -0.081
82
83 L = L' / 4.5 for -0.081 < L' < 0.081
84
85 L = ((L' + 0.099) / 1.099)\ :sup:`1/0.45` for L' ≥ 0.081
86
87The luminance (Y') and color difference (Cb and Cr) are obtained with
88the following ``V4L2_YCBCR_ENC_601`` encoding:
89 Y' = 0.299R' + 0.587G' + 0.114B'
90
91 Cb = -0.169R' - 0.331G' + 0.5B'
92
93 Cr = 0.5R' - 0.419G' - 0.081B'
94
95Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
96[-0.5…0.5]. This conversion to Y'CbCr is identical to the one defined in
97the :ref:`itu601` standard and this colorspace is sometimes called
98BT.601 as well, even though BT.601 does not mention any color primaries.
99
100The default quantization is limited range, but full range is possible
101although rarely seen.
102
103
104.. _col-rec709:
105
106Colorspace Rec. 709 (V4L2_COLORSPACE_REC709)
107============================================
108
109The :ref:`itu709` standard defines the colorspace used by HDTV in
110general. The default transfer function is ``V4L2_XFER_FUNC_709``. The
111default Y'CbCr encoding is ``V4L2_YCBCR_ENC_709``. The default Y'CbCr
112quantization is limited range. The chromaticities of the primary colors
113and the white reference are:
114
115
116
117.. flat-table:: Rec. 709 Chromaticities
118 :header-rows: 1
119 :stub-columns: 0
120 :widths: 1 1 2
121
122
123 - .. row 1
124
125 - Color
126
127 - x
128
129 - y
130
131 - .. row 2
132
133 - Red
134
135 - 0.640
136
137 - 0.330
138
139 - .. row 3
140
141 - Green
142
143 - 0.300
144
145 - 0.600
146
147 - .. row 4
148
149 - Blue
150
151 - 0.150
152
153 - 0.060
154
155 - .. row 5
156
157 - White Reference (D65)
158
159 - 0.3127
160
161 - 0.3290
162
163
164The full name of this standard is Rec. ITU-R BT.709-5.
165
166Transfer function. Normally L is in the range [0…1], but for the
167extended gamut xvYCC encoding values outside that range are allowed.
168 L' = -1.099(-L):sup:`0.45` + 0.099 for L ≤ -0.018
169
170 L' = 4.5L for -0.018 < L < 0.018
171
172 L' = 1.099L\ :sup:`0.45` - 0.099 for L ≥ 0.018
173
174Inverse Transfer function:
175 L = -((L' - 0.099) / -1.099):sup:`1/0.45` for L' ≤ -0.081
176
177 L = L' / 4.5 for -0.081 < L' < 0.081
178
179 L = ((L' + 0.099) / 1.099)\ :sup:`1/0.45` for L' ≥ 0.081
180
181The luminance (Y') and color difference (Cb and Cr) are obtained with
182the following ``V4L2_YCBCR_ENC_709`` encoding:
183 Y' = 0.2126R' + 0.7152G' + 0.0722B'
184
185 Cb = -0.1146R' - 0.3854G' + 0.5B'
186
187 Cr = 0.5R' - 0.4542G' - 0.0458B'
188
189Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
190[-0.5…0.5].
191
192The default quantization is limited range, but full range is possible
193although rarely seen.
194
195The ``V4L2_YCBCR_ENC_709`` encoding described above is the default for
196this colorspace, but it can be overridden with ``V4L2_YCBCR_ENC_601``,
197in which case the BT.601 Y'CbCr encoding is used.
198
199Two additional extended gamut Y'CbCr encodings are also possible with
200this colorspace:
201
202The xvYCC 709 encoding (``V4L2_YCBCR_ENC_XV709``, :ref:`xvycc`) is
203similar to the Rec. 709 encoding, but it allows for R', G' and B' values
204that are outside the range [0…1]. The resulting Y', Cb and Cr values are
205scaled and offset:
206 Y' = (219 / 256) * (0.2126R' + 0.7152G' + 0.0722B') + (16 / 256)
207
208 Cb = (224 / 256) * (-0.1146R' - 0.3854G' + 0.5B')
209
210 Cr = (224 / 256) * (0.5R' - 0.4542G' - 0.0458B')
211
212The xvYCC 601 encoding (``V4L2_YCBCR_ENC_XV601``, :ref:`xvycc`) is
213similar to the BT.601 encoding, but it allows for R', G' and B' values
214that are outside the range [0…1]. The resulting Y', Cb and Cr values are
215scaled and offset:
216 Y' = (219 / 256) * (0.299R' + 0.587G' + 0.114B') + (16 / 256)
217
218 Cb = (224 / 256) * (-0.169R' - 0.331G' + 0.5B')
219
220 Cr = (224 / 256) * (0.5R' - 0.419G' - 0.081B')
221
222Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
223[-0.5…0.5]. The non-standard xvYCC 709 or xvYCC 601 encodings can be
224used by selecting ``V4L2_YCBCR_ENC_XV709`` or ``V4L2_YCBCR_ENC_XV601``.
225The xvYCC encodings always use full range quantization.
226
227
228.. _col-srgb:
229
230Colorspace sRGB (V4L2_COLORSPACE_SRGB)
231======================================
232
233The :ref:`srgb` standard defines the colorspace used by most webcams
234and computer graphics. The default transfer function is
235``V4L2_XFER_FUNC_SRGB``. The default Y'CbCr encoding is
236``V4L2_YCBCR_ENC_SYCC``. The default Y'CbCr quantization is full range.
237The chromaticities of the primary colors and the white reference are:
238
239
240
241.. flat-table:: sRGB Chromaticities
242 :header-rows: 1
243 :stub-columns: 0
244 :widths: 1 1 2
245
246
247 - .. row 1
248
249 - Color
250
251 - x
252
253 - y
254
255 - .. row 2
256
257 - Red
258
259 - 0.640
260
261 - 0.330
262
263 - .. row 3
264
265 - Green
266
267 - 0.300
268
269 - 0.600
270
271 - .. row 4
272
273 - Blue
274
275 - 0.150
276
277 - 0.060
278
279 - .. row 5
280
281 - White Reference (D65)
282
283 - 0.3127
284
285 - 0.3290
286
287
288These chromaticities are identical to the Rec. 709 colorspace.
289
290Transfer function. Note that negative values for L are only used by the
291Y'CbCr conversion.
292 L' = -1.055(-L):sup:`1/2.4` + 0.055 for L < -0.0031308
293
294 L' = 12.92L for -0.0031308 ≤ L ≤ 0.0031308
295
296 L' = 1.055L\ :sup:`1/2.4` - 0.055 for 0.0031308 < L ≤ 1
297
298Inverse Transfer function:
299 L = -((-L' + 0.055) / 1.055)\ :sup:`2.4` for L' < -0.04045
300
301 L = L' / 12.92 for -0.04045 ≤ L' ≤ 0.04045
302
303 L = ((L' + 0.055) / 1.055)\ :sup:`2.4` for L' > 0.04045
304
305The luminance (Y') and color difference (Cb and Cr) are obtained with
306the following ``V4L2_YCBCR_ENC_SYCC`` encoding as defined by
307:ref:`sycc`:
308 Y' = 0.2990R' + 0.5870G' + 0.1140B'
309
310 Cb = -0.1687R' - 0.3313G' + 0.5B'
311
312 Cr = 0.5R' - 0.4187G' - 0.0813B'
313
314Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
315[-0.5…0.5]. The ``V4L2_YCBCR_ENC_SYCC`` quantization is always full
316range. Although this Y'CbCr encoding looks very similar to the
317``V4L2_YCBCR_ENC_XV601`` encoding, it is not. The
318``V4L2_YCBCR_ENC_XV601`` scales and offsets the Y'CbCr values before
319quantization, but this encoding does not do that.
320
321
322.. _col-adobergb:
323
324Colorspace Adobe RGB (V4L2_COLORSPACE_ADOBERGB)
325===============================================
326
327The :ref:`adobergb` standard defines the colorspace used by computer
328graphics that use the AdobeRGB colorspace. This is also known as the
329:ref:`oprgb` standard. The default transfer function is
330``V4L2_XFER_FUNC_ADOBERGB``. The default Y'CbCr encoding is
331``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
332range. The chromaticities of the primary colors and the white reference
333are:
334
335
336
337.. flat-table:: Adobe RGB Chromaticities
338 :header-rows: 1
339 :stub-columns: 0
340 :widths: 1 1 2
341
342
343 - .. row 1
344
345 - Color
346
347 - x
348
349 - y
350
351 - .. row 2
352
353 - Red
354
355 - 0.6400
356
357 - 0.3300
358
359 - .. row 3
360
361 - Green
362
363 - 0.2100
364
365 - 0.7100
366
367 - .. row 4
368
369 - Blue
370
371 - 0.1500
372
373 - 0.0600
374
375 - .. row 5
376
377 - White Reference (D65)
378
379 - 0.3127
380
381 - 0.3290
382
383
384
385Transfer function:
386 L' = L\ :sup:`1/2.19921875`
387
388Inverse Transfer function:
389 L = L'\ :sup:`2.19921875`
390
391The luminance (Y') and color difference (Cb and Cr) are obtained with
392the following ``V4L2_YCBCR_ENC_601`` encoding:
393 Y' = 0.299R' + 0.587G' + 0.114B'
394
395 Cb = -0.169R' - 0.331G' + 0.5B'
396
397 Cr = 0.5R' - 0.419G' - 0.081B'
398
399Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
400[-0.5…0.5]. This transform is identical to one defined in SMPTE
401170M/BT.601. The Y'CbCr quantization is limited range.
402
403
404.. _col-bt2020:
405
406Colorspace BT.2020 (V4L2_COLORSPACE_BT2020)
407===========================================
408
409The :ref:`itu2020` standard defines the colorspace used by Ultra-high
410definition television (UHDTV). The default transfer function is
411``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
412``V4L2_YCBCR_ENC_BT2020``. The default R'G'B' quantization is limited
413range (!), and so is the default Y'CbCr quantization. The chromaticities
414of the primary colors and the white reference are:
415
416
417
418.. flat-table:: BT.2020 Chromaticities
419 :header-rows: 1
420 :stub-columns: 0
421 :widths: 1 1 2
422
423
424 - .. row 1
425
426 - Color
427
428 - x
429
430 - y
431
432 - .. row 2
433
434 - Red
435
436 - 0.708
437
438 - 0.292
439
440 - .. row 3
441
442 - Green
443
444 - 0.170
445
446 - 0.797
447
448 - .. row 4
449
450 - Blue
451
452 - 0.131
453
454 - 0.046
455
456 - .. row 5
457
458 - White Reference (D65)
459
460 - 0.3127
461
462 - 0.3290
463
464
465
466Transfer function (same as Rec. 709):
467 L' = 4.5L for 0 ≤ L < 0.018
468
469 L' = 1.099L\ :sup:`0.45` - 0.099 for 0.018 ≤ L ≤ 1
470
471Inverse Transfer function:
472 L = L' / 4.5 for L' < 0.081
473
474 L = ((L' + 0.099) / 1.099)\ :sup:`1/0.45` for L' ≥ 0.081
475
476The luminance (Y') and color difference (Cb and Cr) are obtained with
477the following ``V4L2_YCBCR_ENC_BT2020`` encoding:
478 Y' = 0.2627R' + 0.6780G' + 0.0593B'
479
480 Cb = -0.1396R' - 0.3604G' + 0.5B'
481
482 Cr = 0.5R' - 0.4598G' - 0.0402B'
483
484Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
485[-0.5…0.5]. The Y'CbCr quantization is limited range.
486
487There is also an alternate constant luminance R'G'B' to Yc'CbcCrc
488(``V4L2_YCBCR_ENC_BT2020_CONST_LUM``) encoding:
489
490Luma:
491 Yc' = (0.2627R + 0.6780G + 0.0593B)'
492
493B' - Yc' ≤ 0:
494 Cbc = (B' - Yc') / 1.9404
495
496B' - Yc' > 0:
497 Cbc = (B' - Yc') / 1.5816
498
499R' - Yc' ≤ 0:
500 Crc = (R' - Y') / 1.7184
501
502R' - Yc' > 0:
503 Crc = (R' - Y') / 0.9936
504
505Yc' is clamped to the range [0…1] and Cbc and Crc are clamped to the
506range [-0.5…0.5]. The Yc'CbcCrc quantization is limited range.
507
508
509.. _col-dcip3:
510
511Colorspace DCI-P3 (V4L2_COLORSPACE_DCI_P3)
512==========================================
513
514The :ref:`smpte431` standard defines the colorspace used by cinema
515projectors that use the DCI-P3 colorspace. The default transfer function
516is ``V4L2_XFER_FUNC_DCI_P3``. The default Y'CbCr encoding is
517``V4L2_YCBCR_ENC_709``. Note that this colorspace does not specify a
518Y'CbCr encoding since it is not meant to be encoded to Y'CbCr. So this
519default Y'CbCr encoding was picked because it is the HDTV encoding. The
520default Y'CbCr quantization is limited range. The chromaticities of the
521primary colors and the white reference are:
522
523
524
525.. flat-table:: DCI-P3 Chromaticities
526 :header-rows: 1
527 :stub-columns: 0
528 :widths: 1 1 2
529
530
531 - .. row 1
532
533 - Color
534
535 - x
536
537 - y
538
539 - .. row 2
540
541 - Red
542
543 - 0.6800
544
545 - 0.3200
546
547 - .. row 3
548
549 - Green
550
551 - 0.2650
552
553 - 0.6900
554
555 - .. row 4
556
557 - Blue
558
559 - 0.1500
560
561 - 0.0600
562
563 - .. row 5
564
565 - White Reference
566
567 - 0.3140
568
569 - 0.3510
570
571
572
573Transfer function:
574 L' = L\ :sup:`1/2.6`
575
576Inverse Transfer function:
577 L = L'\ :sup:`2.6`
578
579Y'CbCr encoding is not specified. V4L2 defaults to Rec. 709.
580
581
582.. _col-smpte-240m:
583
584Colorspace SMPTE 240M (V4L2_COLORSPACE_SMPTE240M)
585=================================================
586
587The :ref:`smpte240m` standard was an interim standard used during the
588early days of HDTV (1988-1998). It has been superseded by Rec. 709. The
589default transfer function is ``V4L2_XFER_FUNC_SMPTE240M``. The default
590Y'CbCr encoding is ``V4L2_YCBCR_ENC_SMPTE240M``. The default Y'CbCr
591quantization is limited range. The chromaticities of the primary colors
592and the white reference are:
593
594
595
596.. flat-table:: SMPTE 240M Chromaticities
597 :header-rows: 1
598 :stub-columns: 0
599 :widths: 1 1 2
600
601
602 - .. row 1
603
604 - Color
605
606 - x
607
608 - y
609
610 - .. row 2
611
612 - Red
613
614 - 0.630
615
616 - 0.340
617
618 - .. row 3
619
620 - Green
621
622 - 0.310
623
624 - 0.595
625
626 - .. row 4
627
628 - Blue
629
630 - 0.155
631
632 - 0.070
633
634 - .. row 5
635
636 - White Reference (D65)
637
638 - 0.3127
639
640 - 0.3290
641
642
643These chromaticities are identical to the SMPTE 170M colorspace.
644
645Transfer function:
646 L' = 4L for 0 ≤ L < 0.0228
647
648 L' = 1.1115L\ :sup:`0.45` - 0.1115 for 0.0228 ≤ L ≤ 1
649
650Inverse Transfer function:
651 L = L' / 4 for 0 ≤ L' < 0.0913
652
653 L = ((L' + 0.1115) / 1.1115)\ :sup:`1/0.45` for L' ≥ 0.0913
654
655The luminance (Y') and color difference (Cb and Cr) are obtained with
656the following ``V4L2_YCBCR_ENC_SMPTE240M`` encoding:
657 Y' = 0.2122R' + 0.7013G' + 0.0865B'
658
659 Cb = -0.1161R' - 0.3839G' + 0.5B'
660
661 Cr = 0.5R' - 0.4451G' - 0.0549B'
662
663Yc' is clamped to the range [0…1] and Cbc and Crc are clamped to the
664range [-0.5…0.5]. The Y'CbCr quantization is limited range.
665
666
667.. _col-sysm:
668
669Colorspace NTSC 1953 (V4L2_COLORSPACE_470_SYSTEM_M)
670===================================================
671
672This standard defines the colorspace used by NTSC in 1953. In practice
673this colorspace is obsolete and SMPTE 170M should be used instead. The
674default transfer function is ``V4L2_XFER_FUNC_709``. The default Y'CbCr
675encoding is ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is
676limited range. The chromaticities of the primary colors and the white
677reference are:
678
679
680
681.. flat-table:: NTSC 1953 Chromaticities
682 :header-rows: 1
683 :stub-columns: 0
684 :widths: 1 1 2
685
686
687 - .. row 1
688
689 - Color
690
691 - x
692
693 - y
694
695 - .. row 2
696
697 - Red
698
699 - 0.67
700
701 - 0.33
702
703 - .. row 3
704
705 - Green
706
707 - 0.21
708
709 - 0.71
710
711 - .. row 4
712
713 - Blue
714
715 - 0.14
716
717 - 0.08
718
719 - .. row 5
720
721 - White Reference (C)
722
723 - 0.310
724
725 - 0.316
726
727
728Note that this colorspace uses Illuminant C instead of D65 as the white
729reference. To correctly convert an image in this colorspace to another
730that uses D65 you need to apply a chromatic adaptation algorithm such as
731the Bradford method.
732
733The transfer function was never properly defined for NTSC 1953. The Rec.
734709 transfer function is recommended in the literature:
735 L' = 4.5L for 0 ≤ L < 0.018
736
737 L' = 1.099L\ :sup:`0.45` - 0.099 for 0.018 ≤ L ≤ 1
738
739Inverse Transfer function:
740 L = L' / 4.5 for L' < 0.081
741
742 L = ((L' + 0.099) / 1.099)\ :sup:`1/0.45` for L' ≥ 0.081
743
744The luminance (Y') and color difference (Cb and Cr) are obtained with
745the following ``V4L2_YCBCR_ENC_601`` encoding:
746 Y' = 0.299R' + 0.587G' + 0.114B'
747
748 Cb = -0.169R' - 0.331G' + 0.5B'
749
750 Cr = 0.5R' - 0.419G' - 0.081B'
751
752Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
753[-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
754identical to one defined in SMPTE 170M/BT.601.
755
756
757.. _col-sysbg:
758
759Colorspace EBU Tech. 3213 (V4L2_COLORSPACE_470_SYSTEM_BG)
760=========================================================
761
762The :ref:`tech3213` standard defines the colorspace used by PAL/SECAM
763in 1975. In practice this colorspace is obsolete and SMPTE 170M should
764be used instead. The default transfer function is
765``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
766``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
767range. The chromaticities of the primary colors and the white reference
768are:
769
770
771
772.. flat-table:: EBU Tech. 3213 Chromaticities
773 :header-rows: 1
774 :stub-columns: 0
775 :widths: 1 1 2
776
777
778 - .. row 1
779
780 - Color
781
782 - x
783
784 - y
785
786 - .. row 2
787
788 - Red
789
790 - 0.64
791
792 - 0.33
793
794 - .. row 3
795
796 - Green
797
798 - 0.29
799
800 - 0.60
801
802 - .. row 4
803
804 - Blue
805
806 - 0.15
807
808 - 0.06
809
810 - .. row 5
811
812 - White Reference (D65)
813
814 - 0.3127
815
816 - 0.3290
817
818
819
820The transfer function was never properly defined for this colorspace.
821The Rec. 709 transfer function is recommended in the literature:
822 L' = 4.5L for 0 ≤ L < 0.018
823
824 L' = 1.099L\ :sup:`0.45` - 0.099 for 0.018 ≤ L ≤ 1
825
826Inverse Transfer function:
827 L = L' / 4.5 for L' < 0.081
828
829 L = ((L' + 0.099) / 1.099)\ :sup:`1/0.45` for L' ≥ 0.081
830
831The luminance (Y') and color difference (Cb and Cr) are obtained with
832the following ``V4L2_YCBCR_ENC_601`` encoding:
833 Y' = 0.299R' + 0.587G' + 0.114B'
834
835 Cb = -0.169R' - 0.331G' + 0.5B'
836
837 Cr = 0.5R' - 0.419G' - 0.081B'
838
839Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
840[-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
841identical to one defined in SMPTE 170M/BT.601.
842
843
844.. _col-jpeg:
845
846Colorspace JPEG (V4L2_COLORSPACE_JPEG)
847======================================
848
849This colorspace defines the colorspace used by most (Motion-)JPEG
850formats. The chromaticities of the primary colors and the white
851reference are identical to sRGB. The transfer function use is
852``V4L2_XFER_FUNC_SRGB``. The Y'CbCr encoding is ``V4L2_YCBCR_ENC_601``
853with full range quantization where Y' is scaled to [0…255] and Cb/Cr are
854scaled to [-128…128] and then clipped to [-128…127].
855
856Note that the JPEG standard does not actually store colorspace
857information. So if something other than sRGB is used, then the driver
858will have to set that information explicitly. Effectively
859``V4L2_COLORSPACE_JPEG`` can be considered to be an abbreviation for
860``V4L2_COLORSPACE_SRGB``, ``V4L2_YCBCR_ENC_601`` and
861``V4L2_QUANTIZATION_FULL_RANGE``.
862
863
864.. ------------------------------------------------------------------------------
865.. This file was automatically converted from DocBook-XML with the dbxml
866.. library (https://github.com/return42/sphkerneldoc). The origin XML comes
867.. from the linux kernel, refer to:
868..
869.. * https://github.com/torvalds/linux/tree/master/Documentation/DocBook
870.. ------------------------------------------------------------------------------
This page took 0.060083 seconds and 5 git commands to generate.