Ogg Theora I specification: color space conventions

Overview

There are a large number of different color standards used in digital video. Since Theora is a lossy codec, it restricts itself to only a few of them to simplify playback. Unlike the alternate method of describing all the parameters of the color model, this allows a few dedicated routines for color conversion to be written and heavily optimized in a decoder. More flexible conversion functions should instead be specified in an encoder, where additional computational complexity is more easily tolerated. The color spaces were selected to give a fair representation of color standards in use around the world today. Most of the standards that do not exactly match one of these can be converted to one fairly easily.

The Theora codec identification header contains an 8-bit value that describes the color space. This merely selects one of the color spaces available from an enumerated list. Currently, only two color spaces are defined, with a third possibility that indicates the color space is "unknown". All of them are Y'CbCr color spaces with one luma channel and two chroma channels. Each channel contains 8-bit discrete values in the range 0-255, which represent non-linear gamma pre-corrected signals.

color space parameters

The parameters which describe each color space are listed below. These are the parameters needed to map colors from the encoded Y'CbCr representation to the device-independent color space CIE XYZ (1931).

Y'CbCr to Y'PbPr

This conversion takes 8-bit discrete values in the range 0-255 and maps them to real values in the range [0,1] for Y and [-1/2,1/2] for Pb and Pr. Because some values may fall outside the offset and excursion defined for each channel in the Y'CbCr space, the results may fall outside these ranges in Y'PbPr space. No clamping should be done at this stage.

Parameters: OffsetY,Cb,Cr, ExcursionY,Cb,Cr,

Y'out = (Y'in-OffsetY)/ ExcursionY
Pb = (Cb-OffsetCb)/ ExcursionCb
Pr = (Cr-OffsetCr)/ ExcursionCr
Y'PbPr to R'G'B'

This conversion takes the one luma and two chroma channel representation and maps it to the non-linear R'G'B' space used to drive actual output devices. Values should be clamped into the range [0,1] after this stage.

Parameters: Kb, Kr

R' = Y' + 2(1-Kr)Pr
G' = Y' + 2((Kb-1)Kb/ (1-Kb-Kr))Pb + 2((Kr-1)Kr/ (1-Kb-Kr))Pr
B' = Y' + 2(1-Kb)Pb
R'G'B' to RGB (Output device gamma correction)

This conversion takes the non-linear R'G'B' voltage levels and maps it to the linear light levels produced by the actual output device. Note that this conversion is only that of the output device, and its inverse is not that used by the input device. Because a dim viewing environment is assumed in most television standards, the overall gamma between the input and output devices is usually around 1.1 to 1.2, and not a strict 1.0.

For calibration with actual output devices, the model
L = (E'+Δ)γ
should be used, with Δ the free parameter and γ held fixed to the value specified in this document. The conversion function presented here is an idealized version with Δ=0.

Parameters: γ

R = R'γ
G = G'γ
B = B'γ
RGB to R'G'B' (Input device gamma correction)

This conversion takes linear light levels and maps them to the non-linear voltage levels used to drive the actual output device. This information is merely informative. It is not required for building a decoder or for converting between the various formats and the actual output capabilities of a particular device.

A linear segment is introduced on the low end to reduce noise in dark areas of the image. The rest of the scale is adjusted so that the power segment of the curve intersects the linear segment with the proper slope, and so that it still maps 0 to 0 and 1 to 1.

Parameters: β, α, δ, ε

R' = (1+ε)Rβ-ε for δ ≤ R ≤ 1
R' = αR for 0 ≤ R < δ
G' = (1+ε)Gβ-ε for δ ≤ G ≤ 1
G' = αG for 0 ≤ G < δ
B' = (1+ε)Bβ-ε for δ ≤ B ≤ 1
B' = αB for 0 ≤ B < δ
RGB to CIE XYZ (1931)

This conversion maps a device-dependent linear RGB space to the device-independent linear CIE XYZ space. The parameters are the CIE chromaticity coordinates of the three primaries, red, green, and blue, as well as the chromaticity coordinates of the white point of the device. This is how hardware manufacturers and standards typically describe a particular RGB space. The math required to convert these parameters into a useful transformation matrix is reproduced below.

Parameters: xr,g,b,w, yr,g,b,w

F = )
(
xr/yr xg/yg xb/yb
1 1 1
(1-xr-yr)/yr (1-xg-yg)/yg (1-xb-yb)/yb
(
sr
sg
sb
)
=
F-1(
xw/yw
1
(1-xw-yw)/yw
)
(
X
Y
Z
)
=
F(
srR
sgG
sbB
)

available color spaces

These are the color spaces currently defined for use by Ogg Theora video. Each one has a short name, with which it is referred to in this document, and a more detailed specification of the standards from which its parameters are derived. Some standards do not specify all the parameters necessary. For these unspecified parameters, this document serves as the definition of what should be used when encoding or decoding Ogg Theora video.

Rec 470M (Rec. ITU-R BT.470-6 System M/NTSC with Rec. ITU-R BT.601-5)

This color space is used by broadcast television and DVDs in much of the Americas, Japan, Korea, and the Union of Myanmar [Rec470]. This color space may also be used for System M/PAL (Brazil), with an appropriate conversion supplied by the encoder to compensate for the different gamma value. See the Rec 470BG section for an appropriate gamma value to assume for M/PAL input.

In the US, studio monitors are adjusted to a D65 white point (xw,yw=0.313,0.329). In Japan, studio monitors are adjusted to a D white of 9300K (xw,yw=0.285,0.293).

Rec 470 does not specify a digital encoding of the color signals. For Ogg Theora, Rec. ITU-R BT.601-5 is used, starting from the R'G'B' signals specified by Rec 470 [Rec601].

Rec 470 does not specify an input gamma function. For Ogg Theora, the Rec 709 input function is used. This is the same as that specified by SMPTE 170M, which claims to reflect modern practice in the creation of NTSC signals (c. 1994) [SMPTE170M].

parameters

OffsetY,Cb,Cr = (16,128,128)
ExcursionY,Cb,Cr = (219,224,224)
Kb = 0.114
Kr = 0.299
γ = 2.2
β = 0.45
α = 4.5
δ = 0.018
ε = 0.099
xr,yr = 0.67, 0.33
xg,yg = 0.21, 0.71
xb,yb = 0.14, 0.08
(Illuminant C) xw,yw = 0.310, 0.316

Rec 470BG (Rec. ITU-R BT.470-6 Systems B and G with Rec. ITU-R BT.601-5)

This color space is used by the PAL and SECAM systems in much of the rest of the world [Rec470]. This can be used directly by systems (B, B1, D, D1, G, H, I, K, N)/PAL and (B, D, G, H, K, K1, L)/SECAM.

Note that the Rec 470BG chromaticity values are different from those specified in Rec 470M. When PAL and SECAM systems were first designed, they were based upon the same primaries as NTSC. However, as methods of making color picture tubes have changed, the primaries used have changed as well. The US recommends using correction circuitry to approximate the existing, standard NTSC primaries. Current PAL and SECAM systems have standardized on primaries in accord with more recent technology.

Rec 470 provisionally permits the use of the NTSC chromaticity values (given above) with legacy PAL and SECAM equipment. In Ogg Theora, material must be decoded assuming the new PAL and SECAM primaries. Material intended for display on old legacy devices should be converted by the decoder.

The official Rec 470BG specifies a gamma value of γ=2.8. However, in practice this value is unrealistically high [Poy97]. Rec 470BG states that the overall system gamma should be approximately γ/β=1.2. However, most cameras pre-correct with a gamma value of β=0.45, which suggests an output device gamma of approximately γ=2.67. This is the value recommended for use with PAL systems in Ogg Theora.

Rec 470 does not specify a digital encoding of the color signals. For Ogg Theora, Rec. ITU-R BT.601-5 is used, starting from the R'G'B' signals specified by Rec 470 [Rec601].

Rec 470 does not specify an input gamma function. For Ogg Theora, the Rec 709 input function is used.

parameters

OffsetY,Cb,Cr = (16,128,128)
ExcursionY,Cb,Cr = (219,224,224)
Kb = 0.114
Kr = 0.299
γ = 2.67
β = 0.45
α = 4.5
δ = 0.018
ε = 0.099
xr,yr = 0.64, 0.33
xg,yg = 0.29, 0.60
xb,yb = 0.15, 0.06
(D65) xw,yw = 0.313, 0.329

references

[Poy97]
Poynton, Charles, Frequently-Asked Questions about Gamma. http://www.poynton.com/GammaFAQ/html, Feb. 1997.
[Rec470]
Recommendation ITU-R BT.470-6, Conventional Television Systems (1970, revised 1998). International Telecommunications Union, 1211 Geneva 20, Switzerland.
[Rec601]
Recommendation ITU-R BT.601-5, Studio Encoding Parameters of Digital Television for Standard 4:3 and Wide-Screen 16:9 Aspect Ratios (1982, revised 1995). International Telecommunications Union, 1211 Geneva 20, Switzerland.
[Rec709]
Recommendation ITU-R BT.709-5, Parameter values for the HDTV standards for production and international programme exchange (1990, revised 2002). International Telecommunications Union, 1211 Geneva 20, Switzerland.
[SMPTE170M]
Society of Motion Picture and Television Engineers, Television — Composite Analog Video Signal — NTSC for Studio Applications. SMPTE-170M, 1994
[SMPTE240M]
Society of Motion Picture and Television Engineers, Television — Signal Parameters — 1125-Line High-Definition Production. SMPTE-240M, 1999.