summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/docs/native-code/rtp-hdrext/color-space/README.md
blob: 3f9485681fba1dc7faf97cafc5b66eabba5f6b17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
76
77
78
79
80
81
82
83
84
85
86
87
88
# Color Space

The color space extension is used to communicate color space information and
optionally also metadata that is needed in order to properly render a high
dynamic range (HDR) video stream. Contact <kron@google.com> for more info.

**Name:** "Color space" ; "RTP Header Extension for color space"

**Formal name:** <http://www.webrtc.org/experiments/rtp-hdrext/color-space>

**Status:** This extension is defined here to allow for experimentation. Once experience
has shown that it is useful, we intend to make a proposal based on it for standardization
in the IETF.

## RTP header extension format

### Data layout overview
Data layout without HDR metadata (one-byte RTP header extension)
     1-byte header + 4 bytes of data:

      0                   1                   2                   3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |  ID   | L = 3 |   primaries   |   transfer    |    matrix     |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |range+chr.sit. |
     +-+-+-+-+-+-+-+-+

Data layout of color space with HDR metadata (two-byte RTP header extension)
     2-byte header + 28 bytes of data:

      0                   1                   2                   3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |      ID       |   length=28   |   primaries   |   transfer    |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |    matrix     |range+chr.sit. |         luminance_max         |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |         luminance_min         |            mastering_metadata.|
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |primary_r.x and .y             |            mastering_metadata.|
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |primary_g.x and .y             |            mastering_metadata.|
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |primary_b.x and .y             |            mastering_metadata.|
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     |white.x and .y                 |    max_content_light_level    |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
     | max_frame_average_light_level |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

### Data layout details
The data is written in the following order,
Color space information (4 bytes):
  * Color primaries value according to ITU-T H.273 Table 2.
  * Transfer characteristic value according to ITU-T H.273 Table 3.
  * Matrix coefficients value according to ITU-T H.273 Table 4.
  * Range and chroma siting as specified at
    https://www.webmproject.org/docs/container/#colour. Range (range), horizontal (horz)
    and vertical (vert) siting are merged to one byte by the operation: (range << 4) +
    (horz << 2) + vert.

The extension may optionally include HDR metadata written in the following order,
Mastering metadata (20 bytes):
  * Luminance max, specified in nits, where 1 nit = 1 cd/m<sup>2</sup>.
    (16-bit unsigned integer)
  * Luminance min, scaled by a factor of 10000 and specified in the unit 1/10000
    nits. (16-bit unsigned integer)
  * CIE 1931 xy chromaticity coordinates of the primary red, scaled by a factor of 50000.
    (2x 16-bit unsigned integers)
  * CIE 1931 xy chromaticity coordinates of the primary green, scaled by a factor of 50000.
    (2x 16-bit unsigned integers)
  * CIE 1931 xy chromaticity coordinates of the primary blue, scaled by a factor of 50000.
    (2x 16-bit unsigned integers)
  * CIE 1931 xy chromaticity coordinates of the white point, scaled by a factor of 50000.
    (2x 16-bit unsigned integers)

Followed by max light levels (4 bytes):
  * Max content light level, specified in nits. (16-bit unsigned integer)
  * Max frame average light level, specified in nits. (16-bit unsigned integer)

Note, the byte order for all integers is big endian.

See the standard SMPTE ST 2086 for more information about these entities.

Notes: Extension should be present only in the last packet of video frames. If attached
to other packets it should be ignored.