pixfmt-007.rst 19.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
.. -*- coding: utf-8; mode: rst -*-

********************************
Detailed Colorspace Descriptions
********************************


.. _col-smpte-170m:

Colorspace SMPTE 170M (V4L2_COLORSPACE_SMPTE170M)
=================================================

The :ref:`smpte170m` standard defines the colorspace used by NTSC and
PAL and by SDTV in general. The default transfer function is
``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
range. The chromaticities of the primary colors and the white reference
are:



22 23
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
.. flat-table:: SMPTE 170M Chromaticities
    :header-rows:  1
    :stub-columns: 0
    :widths:       1 1 2


    -  .. row 1

       -  Color

       -  x

       -  y

    -  .. row 2

       -  Red

       -  0.630

       -  0.340

    -  .. row 3

       -  Green

       -  0.310

       -  0.595

    -  .. row 4

       -  Blue

       -  0.155

       -  0.070

    -  .. row 5

       -  White Reference (D65)

       -  0.3127

       -  0.3290


The red, green and blue chromaticities are also often referred to as the
SMPTE C set, so this colorspace is sometimes called SMPTE C as well.

The transfer function defined for SMPTE 170M is the same as the one
defined in Rec. 709.
76

77
.. math::
78

79
    L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le-0.018
80

81 82 83
    L' = 4.5L \text{, for } -0.018 < L < 0.018

    L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
84 85

Inverse Transfer function:
86

87 88 89
.. math::

    L = -\left( \frac{L' - 0.099}{-1.099} \right) ^{\frac{1}{0.45}} \text{, for } L' \le -0.081
90

91
    L = \frac{L'}{4.5} \text{, for } -0.081 < L' < 0.081
92

93
    L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
94 95 96

The luminance (Y') and color difference (Cb and Cr) are obtained with
the following ``V4L2_YCBCR_ENC_601`` encoding:
97

98 99
.. math::

100
    Y' = 0.2990R' + 0.5870G' + 0.1140B'
101

102
    Cb = -0.1687R' - 0.3313G' + 0.5B'
103

104
    Cr = 0.5R' - 0.4187G' - 0.0813B'
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5]. This conversion to Y'CbCr is identical to the one defined in
the :ref:`itu601` standard and this colorspace is sometimes called
BT.601 as well, even though BT.601 does not mention any color primaries.

The default quantization is limited range, but full range is possible
although rarely seen.


.. _col-rec709:

Colorspace Rec. 709 (V4L2_COLORSPACE_REC709)
============================================

The :ref:`itu709` standard defines the colorspace used by HDTV in
general. The default transfer function is ``V4L2_XFER_FUNC_709``. The
default Y'CbCr encoding is ``V4L2_YCBCR_ENC_709``. The default Y'CbCr
quantization is limited range. The chromaticities of the primary colors
and the white reference are:



128 129
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
.. flat-table:: Rec. 709 Chromaticities
    :header-rows:  1
    :stub-columns: 0
    :widths:       1 1 2


    -  .. row 1

       -  Color

       -  x

       -  y

    -  .. row 2

       -  Red

       -  0.640

       -  0.330

    -  .. row 3

       -  Green

       -  0.300

       -  0.600

    -  .. row 4

       -  Blue

       -  0.150

       -  0.060

    -  .. row 5

       -  White Reference (D65)

       -  0.3127

       -  0.3290


The full name of this standard is Rec. ITU-R BT.709-5.

Transfer function. Normally L is in the range [0…1], but for the
extended gamut xvYCC encoding values outside that range are allowed.
181

182
.. math::
183

184
    L' = -1.099(-L)^{0.45} + 0.099 \text{, for } L \le -0.018
185

186 187 188
    L' = 4.5L \text{, for } -0.018 < L < 0.018

    L' = 1.099L^{0.45} - 0.099 \text{, for } L \ge 0.018
189 190

Inverse Transfer function:
191

192 193 194
.. math::

    L = -\left( \frac{L' - 0.099}{-1.099} \right)^\frac{1}{0.45} \text{, for } L' \le -0.081
195

196
    L = \frac{L'}{4.5}\text{, for } -0.081 < L' < 0.081
197

198
    L = \left(\frac{L' + 0.099}{1.099}\right)^{\frac{1}{0.45} } \text{, for } L' \ge 0.081
199 200 201

The luminance (Y') and color difference (Cb and Cr) are obtained with
the following ``V4L2_YCBCR_ENC_709`` encoding:
202

203 204
.. math::

205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
    Y' = 0.2126R' + 0.7152G' + 0.0722B'

    Cb = -0.1146R' - 0.3854G' + 0.5B'

    Cr = 0.5R' - 0.4542G' - 0.0458B'

Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5].

The default quantization is limited range, but full range is possible
although rarely seen.

The ``V4L2_YCBCR_ENC_709`` encoding described above is the default for
this colorspace, but it can be overridden with ``V4L2_YCBCR_ENC_601``,
in which case the BT.601 Y'CbCr encoding is used.

Two additional extended gamut Y'CbCr encodings are also possible with
this colorspace:

The xvYCC 709 encoding (``V4L2_YCBCR_ENC_XV709``, :ref:`xvycc`) is
similar to the Rec. 709 encoding, but it allows for R', G' and B' values
that are outside the range [0…1]. The resulting Y', Cb and Cr values are
scaled and offset:
228

229 230 231
.. math::

    Y' = \frac{219}{256} * (0.2126R' + 0.7152G' + 0.0722B') + \frac{16}{256}
232

233
    Cb = \frac{224}{256} * (-0.1146R' - 0.3854G' + 0.5B')
234

235
    Cr = \frac{224}{256} * (0.5R' - 0.4542G' - 0.0458B')
236 237 238 239 240

The xvYCC 601 encoding (``V4L2_YCBCR_ENC_XV601``, :ref:`xvycc`) is
similar to the BT.601 encoding, but it allows for R', G' and B' values
that are outside the range [0…1]. The resulting Y', Cb and Cr values are
scaled and offset:
241

242
.. math::
243

244
    Y' = \frac{219}{256} * (0.2990R' + 0.5870G' + 0.1140B') + \frac{16}{256}
245

246
    Cb = \frac{224}{256} * (-0.1687R' - 0.3313G' + 0.5B')
247

248
    Cr = \frac{224}{256} * (0.5R' - 0.4187G' - 0.0813B')
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263

Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5]. The non-standard xvYCC 709 or xvYCC 601 encodings can be
used by selecting ``V4L2_YCBCR_ENC_XV709`` or ``V4L2_YCBCR_ENC_XV601``.
The xvYCC encodings always use full range quantization.


.. _col-srgb:

Colorspace sRGB (V4L2_COLORSPACE_SRGB)
======================================

The :ref:`srgb` standard defines the colorspace used by most webcams
and computer graphics. The default transfer function is
``V4L2_XFER_FUNC_SRGB``. The default Y'CbCr encoding is
264
``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is full range.
265 266 267 268
The chromaticities of the primary colors and the white reference are:



269 270
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
.. flat-table:: sRGB Chromaticities
    :header-rows:  1
    :stub-columns: 0
    :widths:       1 1 2


    -  .. row 1

       -  Color

       -  x

       -  y

    -  .. row 2

       -  Red

       -  0.640

       -  0.330

    -  .. row 3

       -  Green

       -  0.300

       -  0.600

    -  .. row 4

       -  Blue

       -  0.150

       -  0.060

    -  .. row 5

       -  White Reference (D65)

       -  0.3127

       -  0.3290


These chromaticities are identical to the Rec. 709 colorspace.

Transfer function. Note that negative values for L are only used by the
Y'CbCr conversion.
322

323 324 325
.. math::

    L' = -1.055(-L)^{\frac{1}{2.4} } + 0.055\text{, for }L < -0.0031308
326

327
    L' = 12.92L\text{, for }-0.0031308 \le L \le 0.0031308
328

329
    L' = 1.055L ^{\frac{1}{2.4} } - 0.055\text{, for }0.0031308 < L \le 1
330 331

Inverse Transfer function:
332

333
.. math::
334

335
    L = -((-L' + 0.055) / 1.055) ^{2.4}\text{, for }L' < -0.04045
336

337 338 339
    L = L' / 12.92\text{, for }-0.04045 \le L' \le 0.04045

    L = ((L' + 0.055) / 1.055) ^{2.4}\text{, for }L' > 0.04045
340 341

The luminance (Y') and color difference (Cb and Cr) are obtained with
342
the following ``V4L2_YCBCR_ENC_601`` encoding as defined by :ref:`sycc`:
343

344 345
.. math::

346 347 348 349 350 351 352
    Y' = 0.2990R' + 0.5870G' + 0.1140B'

    Cb = -0.1687R' - 0.3313G' + 0.5B'

    Cr = 0.5R' - 0.4187G' - 0.0813B'

Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
353 354
[-0.5…0.5]. This transform is identical to one defined in SMPTE
170M/BT.601. The Y'CbCr quantization is full range.
355 356 357 358 359 360 361 362 363 364 365


.. _col-adobergb:

Colorspace Adobe RGB (V4L2_COLORSPACE_ADOBERGB)
===============================================

The :ref:`adobergb` standard defines the colorspace used by computer
graphics that use the AdobeRGB colorspace. This is also known as the
:ref:`oprgb` standard. The default transfer function is
``V4L2_XFER_FUNC_ADOBERGB``. The default Y'CbCr encoding is
366
``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is full
367 368 369 370 371
range. The chromaticities of the primary colors and the white reference
are:



372 373
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
.. flat-table:: Adobe RGB Chromaticities
    :header-rows:  1
    :stub-columns: 0
    :widths:       1 1 2


    -  .. row 1

       -  Color

       -  x

       -  y

    -  .. row 2

       -  Red

       -  0.6400

       -  0.3300

    -  .. row 3

       -  Green

       -  0.2100

       -  0.7100

    -  .. row 4

       -  Blue

       -  0.1500

       -  0.0600

    -  .. row 5

       -  White Reference (D65)

       -  0.3127

       -  0.3290



Transfer function:
423

424 425 426
.. math::

    L' = L ^{\frac{1}{2.19921875}}
427 428

Inverse Transfer function:
429

430 431 432
.. math::

    L = L'^{(2.19921875)}
433 434 435

The luminance (Y') and color difference (Cb and Cr) are obtained with
the following ``V4L2_YCBCR_ENC_601`` encoding:
436

437 438
.. math::

439
    Y' = 0.2990R' + 0.5870G' + 0.1140B'
440

441
    Cb = -0.1687R' - 0.3313G' + 0.5B'
442

443
    Cr = 0.5R' - 0.4187G' - 0.0813B'
444 445 446

Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5]. This transform is identical to one defined in SMPTE
447
170M/BT.601. The Y'CbCr quantization is full range.
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463


.. _col-bt2020:

Colorspace BT.2020 (V4L2_COLORSPACE_BT2020)
===========================================

The :ref:`itu2020` standard defines the colorspace used by Ultra-high
definition television (UHDTV). The default transfer function is
``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
``V4L2_YCBCR_ENC_BT2020``. The default R'G'B' quantization is limited
range (!), and so is the default Y'CbCr quantization. The chromaticities
of the primary colors and the white reference are:



464 465
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
.. flat-table:: BT.2020 Chromaticities
    :header-rows:  1
    :stub-columns: 0
    :widths:       1 1 2


    -  .. row 1

       -  Color

       -  x

       -  y

    -  .. row 2

       -  Red

       -  0.708

       -  0.292

    -  .. row 3

       -  Green

       -  0.170

       -  0.797

    -  .. row 4

       -  Blue

       -  0.131

       -  0.046

    -  .. row 5

       -  White Reference (D65)

       -  0.3127

       -  0.3290



Transfer function (same as Rec. 709):
515

516
.. math::
517

518 519 520
    L' = 4.5L\text{, for }0 \le L < 0.018

    L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
521 522

Inverse Transfer function:
523

524 525 526
.. math::

    L = L' / 4.5\text{, for } L' < 0.081
527

528
    L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
529 530 531

The luminance (Y') and color difference (Cb and Cr) are obtained with
the following ``V4L2_YCBCR_ENC_BT2020`` encoding:
532

533 534
.. math::

535 536 537 538 539 540 541 542 543 544 545 546 547
    Y' = 0.2627R' + 0.6780G' + 0.0593B'

    Cb = -0.1396R' - 0.3604G' + 0.5B'

    Cr = 0.5R' - 0.4598G' - 0.0402B'

Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5]. The Y'CbCr quantization is limited range.

There is also an alternate constant luminance R'G'B' to Yc'CbcCrc
(``V4L2_YCBCR_ENC_BT2020_CONST_LUM``) encoding:

Luma:
548

549 550 551 552 553 554 555 556 557 558 559 560 561 562
.. math::
    :nowrap:

    \begin{align*}
    Yc' = (0.2627R + 0.6780G + 0.0593B)'& \\
    B' - Yc' \le 0:& \\
        &Cbc = (B' - Yc') / 1.9404 \\
    B' - Yc' > 0: & \\
        &Cbc = (B' - Yc') / 1.5816 \\
    R' - Yc' \le 0:& \\
        &Crc = (R' - Y') / 1.7184 \\
    R' - Yc' > 0:& \\
        &Crc = (R' - Y') / 0.9936
    \end{align*}
563 564 565 566 567 568 569 570 571 572 573 574 575

Yc' is clamped to the range [0…1] and Cbc and Crc are clamped to the
range [-0.5…0.5]. The Yc'CbcCrc quantization is limited range.


.. _col-dcip3:

Colorspace DCI-P3 (V4L2_COLORSPACE_DCI_P3)
==========================================

The :ref:`smpte431` standard defines the colorspace used by cinema
projectors that use the DCI-P3 colorspace. The default transfer function
is ``V4L2_XFER_FUNC_DCI_P3``. The default Y'CbCr encoding is
576
``V4L2_YCBCR_ENC_709``. The default Y'CbCr quantization is limited range.
577

578 579
.. note::

580
   Note that this colorspace standard does not specify a
581
   Y'CbCr encoding since it is not meant to be encoded to Y'CbCr. So this
582 583 584
   default Y'CbCr encoding was picked because it is the HDTV encoding.

The chromaticities of the primary colors and the white reference are:
585 586 587



588 589
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
.. flat-table:: DCI-P3 Chromaticities
    :header-rows:  1
    :stub-columns: 0
    :widths:       1 1 2


    -  .. row 1

       -  Color

       -  x

       -  y

    -  .. row 2

       -  Red

       -  0.6800

       -  0.3200

    -  .. row 3

       -  Green

       -  0.2650

       -  0.6900

    -  .. row 4

       -  Blue

       -  0.1500

       -  0.0600

    -  .. row 5

       -  White Reference

       -  0.3140

       -  0.3510



Transfer function:
639

640 641 642
.. math::

    L' = L^{\frac{1}{2.6}}
643 644

Inverse Transfer function:
645

646 647 648
.. math::

    L = L'^{(2.6)}
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666

Y'CbCr encoding is not specified. V4L2 defaults to Rec. 709.


.. _col-smpte-240m:

Colorspace SMPTE 240M (V4L2_COLORSPACE_SMPTE240M)
=================================================

The :ref:`smpte240m` standard was an interim standard used during the
early days of HDTV (1988-1998). It has been superseded by Rec. 709. The
default transfer function is ``V4L2_XFER_FUNC_SMPTE240M``. The default
Y'CbCr encoding is ``V4L2_YCBCR_ENC_SMPTE240M``. The default Y'CbCr
quantization is limited range. The chromaticities of the primary colors
and the white reference are:



667 668
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
.. flat-table:: SMPTE 240M Chromaticities
    :header-rows:  1
    :stub-columns: 0
    :widths:       1 1 2


    -  .. row 1

       -  Color

       -  x

       -  y

    -  .. row 2

       -  Red

       -  0.630

       -  0.340

    -  .. row 3

       -  Green

       -  0.310

       -  0.595

    -  .. row 4

       -  Blue

       -  0.155

       -  0.070

    -  .. row 5

       -  White Reference (D65)

       -  0.3127

       -  0.3290


These chromaticities are identical to the SMPTE 170M colorspace.

Transfer function:
719

720
.. math::
721

722 723 724
    L' = 4L\text{, for } 0 \le L < 0.0228

    L' = 1.1115L ^{0.45} - 0.1115\text{, for } 0.0228 \le L \le 1
725 726

Inverse Transfer function:
727

728 729 730
.. math::

    L = \frac{L'}{4}\text{, for } 0 \le L' < 0.0913
731

732
    L = \left( \frac{L' + 0.1115}{1.1115}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.0913
733 734 735

The luminance (Y') and color difference (Cb and Cr) are obtained with
the following ``V4L2_YCBCR_ENC_SMPTE240M`` encoding:
736

737 738
.. math::

739 740 741 742 743 744
    Y' = 0.2122R' + 0.7013G' + 0.0865B'

    Cb = -0.1161R' - 0.3839G' + 0.5B'

    Cr = 0.5R' - 0.4451G' - 0.0549B'

745
Y' is clamped to the range [0…1] and Cb and Cr are clamped to the
746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762
range [-0.5…0.5]. The Y'CbCr quantization is limited range.


.. _col-sysm:

Colorspace NTSC 1953 (V4L2_COLORSPACE_470_SYSTEM_M)
===================================================

This standard defines the colorspace used by NTSC in 1953. In practice
this colorspace is obsolete and SMPTE 170M should be used instead. The
default transfer function is ``V4L2_XFER_FUNC_709``. The default Y'CbCr
encoding is ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is
limited range. The chromaticities of the primary colors and the white
reference are:



763 764
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811
.. flat-table:: NTSC 1953 Chromaticities
    :header-rows:  1
    :stub-columns: 0
    :widths:       1 1 2


    -  .. row 1

       -  Color

       -  x

       -  y

    -  .. row 2

       -  Red

       -  0.67

       -  0.33

    -  .. row 3

       -  Green

       -  0.21

       -  0.71

    -  .. row 4

       -  Blue

       -  0.14

       -  0.08

    -  .. row 5

       -  White Reference (C)

       -  0.310

       -  0.316


812 813 814
.. note::

   This colorspace uses Illuminant C instead of D65 as the white
815 816 817
   reference. To correctly convert an image in this colorspace to another
   that uses D65 you need to apply a chromatic adaptation algorithm such as
   the Bradford method.
818 819 820

The transfer function was never properly defined for NTSC 1953. The Rec.
709 transfer function is recommended in the literature:
821

822
.. math::
823

824 825 826
    L' = 4.5L\text{, for } 0 \le L < 0.018

    L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
827 828

Inverse Transfer function:
829

830 831 832
.. math::

    L = \frac{L'}{4.5} \text{, for } L' < 0.081
833

834
    L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
835 836 837

The luminance (Y') and color difference (Cb and Cr) are obtained with
the following ``V4L2_YCBCR_ENC_601`` encoding:
838

839 840
.. math::

841
    Y' = 0.2990R' + 0.5870G' + 0.1140B'
842

843
    Cb = -0.1687R' - 0.3313G' + 0.5B'
844

845
    Cr = 0.5R' - 0.4187G' - 0.0813B'
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866

Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
identical to one defined in SMPTE 170M/BT.601.


.. _col-sysbg:

Colorspace EBU Tech. 3213 (V4L2_COLORSPACE_470_SYSTEM_BG)
=========================================================

The :ref:`tech3213` standard defines the colorspace used by PAL/SECAM
in 1975. In practice this colorspace is obsolete and SMPTE 170M should
be used instead. The default transfer function is
``V4L2_XFER_FUNC_709``. The default Y'CbCr encoding is
``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited
range. The chromaticities of the primary colors and the white reference
are:



867 868
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|

869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918
.. flat-table:: EBU Tech. 3213 Chromaticities
    :header-rows:  1
    :stub-columns: 0
    :widths:       1 1 2


    -  .. row 1

       -  Color

       -  x

       -  y

    -  .. row 2

       -  Red

       -  0.64

       -  0.33

    -  .. row 3

       -  Green

       -  0.29

       -  0.60

    -  .. row 4

       -  Blue

       -  0.15

       -  0.06

    -  .. row 5

       -  White Reference (D65)

       -  0.3127

       -  0.3290



The transfer function was never properly defined for this colorspace.
The Rec. 709 transfer function is recommended in the literature:
919

920 921 922
.. math::

    L' = 4.5L\text{, for } 0 \le L < 0.018
923

924
    L' = 1.099L ^{0.45} - 0.099\text{, for } 0.018 \le L \le 1
925 926

Inverse Transfer function:
927

928
.. math::
929

930 931 932
    L = \frac{L'}{4.5} \text{, for } L' < 0.081

    L = \left(\frac{L' + 0.099}{1.099} \right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
933 934 935

The luminance (Y') and color difference (Cb and Cr) are obtained with
the following ``V4L2_YCBCR_ENC_601`` encoding:
936

937 938
.. math::

939
    Y' = 0.2990R' + 0.5870G' + 0.1140B'
940

941
    Cb = -0.1687R' - 0.3313G' + 0.5B'
942

943
    Cr = 0.5R' - 0.4187G' - 0.0813B'
944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961

Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range
[-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is
identical to one defined in SMPTE 170M/BT.601.


.. _col-jpeg:

Colorspace JPEG (V4L2_COLORSPACE_JPEG)
======================================

This colorspace defines the colorspace used by most (Motion-)JPEG
formats. The chromaticities of the primary colors and the white
reference are identical to sRGB. The transfer function use is
``V4L2_XFER_FUNC_SRGB``. The Y'CbCr encoding is ``V4L2_YCBCR_ENC_601``
with full range quantization where Y' is scaled to [0…255] and Cb/Cr are
scaled to [-128…128] and then clipped to [-128…127].

962 963 964
.. note::

   The JPEG standard does not actually store colorspace
965 966 967 968 969
   information. So if something other than sRGB is used, then the driver
   will have to set that information explicitly. Effectively
   ``V4L2_COLORSPACE_JPEG`` can be considered to be an abbreviation for
   ``V4L2_COLORSPACE_SRGB``, ``V4L2_YCBCR_ENC_601`` and
   ``V4L2_QUANTIZATION_FULL_RANGE``.