2 <HEAD><TITLE>xiph.org: Ogg Theora documentation</TITLE></HEAD>
3 <BODY BGCOLOR="#FFFFFF" TEXT="#202020" LINK="#006666" VLINK="#000000">
4 <H1><FONT COLOR="#000070">
5 Ogg Theora I specification: color space conventions
9 There are a large number of different color standards used in digital video.
10 Since Theora is a lossy codec, it restricts itself to only a few of them to
12 Unlike the alternate method of describing all the parameters of the color
13 model, this allows a few dedicated routines for color conversion to be written
14 and heavily optimized in a decoder.
15 More flexible conversion functions should instead be specified in an encoder,
16 where additional computational complexity is more easily tolerated.
17 The color spaces were selected to give a fair representation of color standards
18 in use around the world today.
19 Most of the standards that do not exactly match one of these can be converted
23 The Theora codec identification header contains an 8-bit value that describes
25 This merely selects one of the color spaces available from an enumerated list.
26 Currently, only two color spaces are defined, with a third possibility that
27 indicates the color space is "unknown".
28 All of them are Y'C<SUB>b</SUB>C<SUB>r</SUB> color spaces with one luma channel
29 and two chroma channels.
30 Each channel contains 8-bit discrete values in the range 0-255, which represent
31 non-linear gamma pre-corrected signals.
33 <H2>color space parameters</H2>
35 The parameters which describe each color space are listed below.
36 These are the parameters needed to map colors from the encoded
37 Y'C<SUB>b</SUB>C<SUB>r</SUB> representation to the device-independent color
41 <DT>Y'C<SUB>b</SUB>C<SUB>r</SUB> to Y'P<SUB>b</SUB>P<SUB>r</SUB></DT>
44 This conversion takes 8-bit discrete values in the range 0-255 and maps them to
45 real values in the range [0,1] for Y and [-1/2,1/2] for P<SUB>b</SUB>
47 Because some values may fall outside the offset and excursion defined for each
48 channel in the Y'C<SUB>b</SUB>C<SUB>r</SUB> space, the results may fall
49 outside these ranges in Y'P<SUB>b</SUB>P<SUB>r</SUB> space.
50 No clamping should be done at this stage.
53 Parameters: <EM>Offset<SUB>Y,C<SUB>b</SUB>,C<SUB>r</SUB></SUB></EM>,
54 <EM>Excursion<SUB>Y,C<SUB>b</SUB>,C<SUB>r</SUB>,</SUB></EM>
58 <TD ALIGN="RIGHT">Y'<SUB>out</SUB></TD>
61 (Y'<SUB>in</SUB>-<EM>Offset<SUB>Y</SUB></EM>)/
62 <EM>Excursion<SUB>Y</SUB></EM>
66 <TD ALIGN="RIGHT">P<SUB>b</SUB></TD>
69 (C<SUB>b</SUB>-<EM>Offset<SUB>C<SUB>b</SUB></SUB></EM>)/
70 <EM>Excursion<SUB>C<SUB>b</SUB></SUB></EM>
74 <TD ALIGN="RIGHT">P<SUB>r</SUB></TD>
77 (C<SUB>r</SUB>-<EM>Offset<SUB>C<SUB>r</SUB></SUB></EM>)/
78 <EM>Excursion<SUB>C<SUB>r</SUB></SUB></EM>
83 <DT>Y'P<SUB>b</SUB>P<SUB>r</SUB> to R'G'B'</DT>
86 This conversion takes the one luma and two chroma channel representation and
87 maps it to the non-linear R'G'B' space used to drive actual output devices.
88 Values should be clamped into the range [0,1] after this stage.
90 Parameters: <EM>K<SUB>b</SUB></EM>, <EM>K<SUB>r</SUB></EM>
94 <TD ALIGN="RIGHT">R'</TD>
96 <TD ALIGN="LEFT">Y' + 2(1-<EM>K<SUB>r</SUB></EM>)P<SUB>r</SUB></TD>
99 <TD ALIGN="RIGHT">G'</TD>
103 2((<EM>K<SUB>b</SUB></EM>-1)<EM>K<SUB>b</SUB></EM>/
104 (1-<EM>K<SUB>b</SUB></EM>-<EM>K<SUB>r</SUB></EM>))P<SUB>b</SUB> +
105 2((<EM>K<SUB>r</SUB></EM>-1)<EM>K<SUB>r</SUB></EM>/
106 (1-<EM>K<SUB>b</SUB></EM>-<EM>K<SUB>r</SUB></EM>))P<SUB>r</SUB>
110 <TD ALIGN="RIGHT">B'</TD>
112 <TD ALIGN="LEFT">Y' + 2(1-<EM>K<SUB>b</SUB></EM>)P<SUB>b</SUB></TD>
116 <DT>R'G'B' to RGB (Output device gamma correction)</DT>
119 This conversion takes the non-linear R'G'B' voltage levels and maps it to the
120 linear light levels produced by the actual output device.
121 Note that this conversion is only that of the output device, and its inverse is
122 <EM>not</EM> that used by the input device.
123 Because a dim viewing environment is assumed in most television standards, the
124 overall gamma between the input and output devices is usually around 1.1 to
125 1.2, and not a strict 1.0.
128 For calibration with actual output devices, the model
131 <TD ALIGN="RIGHT">L</TD>
133 <TD ALIGN="LEFT">(E'+Δ)<SUP><EM>γ</EM></SUP></TD>
136 should be used, with Δ the free parameter and <EM>γ</EM> held
137 fixed to the value specified in this document.
138 The conversion function presented here is an idealized version with Δ=0.
141 Parameters: <EM>γ</EM>
145 <TD ALIGN="RIGHT">R</TD>
147 <TD ALIGN="LEFT">R'<SUP><EM>γ</EM></SUP></TD>
150 <TD ALIGN="RIGHT">G</TD>
152 <TD ALIGN="LEFT">G'<SUP><EM>γ</EM></SUP></TD>
155 <TD ALIGN="RIGHT">B</TD>
157 <TD ALIGN="LEFT">B'<SUP><EM>γ</EM></SUP></TD>
161 <DT>RGB to R'G'B' (Input device gamma correction)</DT>
164 This conversion takes linear light levels and maps them to the non-linear
165 voltage levels used to drive the actual output device.
166 This information is merely informative.
167 It is not required for building a decoder or for converting between the various
168 formats and the actual output capabilities of a particular device.
171 A linear segment is introduced on the low end to reduce noise in dark areas of
173 The rest of the scale is adjusted so that the power segment of the curve
174 intersects the linear segment with the proper slope, and so that it still maps
178 Parameters: <EM>β</EM>, <EM>α</EM>, <EM>δ</EM>,
183 <TD ALIGN="RIGHT">R'</TD>
186 (1+<EM>ε</EM>)R<SUP>β</SUP>-<EM>ε</EM>
188 <TD>for <EM>δ</EM> ≤ R ≤ 1</TD>
191 <TD ALIGN="RIGHT">R'</TD>
193 <TD ALIGN="LEFT"><EM>α</EM>R</TD>
194 <TD>for 0 ≤ R < <EM>δ</EM></TD>
197 <TD ALIGN="RIGHT">G'</TD>
200 (1+<EM>ε</EM>)G<SUP>β</SUP>-<EM>ε</EM>
202 <TD>for <EM>δ</EM> ≤ G ≤ 1</TD>
205 <TD ALIGN="RIGHT">G'</TD>
207 <TD ALIGN="LEFT"><EM>α</EM>G</TD>
208 <TD>for 0 ≤ G < <EM>δ</EM></TD>
211 <TD ALIGN="RIGHT">B'</TD>
214 (1+<EM>ε</EM>)B<SUP>β</SUP>-<EM>ε</EM>
216 <TD>for <EM>δ</EM> ≤ B ≤ 1</TD>
219 <TD ALIGN="RIGHT">B'</TD>
221 <TD ALIGN="LEFT"><EM>α</EM>B</TD>
222 <TD>for 0 ≤ B < <EM>δ</EM></TD>
226 <DT>RGB to CIE XYZ (1931)</DT>
229 This conversion maps a device-dependent linear RGB space to the
230 device-independent linear CIE XYZ space.
231 The parameters are the CIE chromaticity coordinates of the three primaries,
232 red, green, and blue, as well as the chromaticity coordinates of the white
234 This is how hardware manufacturers and standards typically describe a
235 particular RGB space.
236 The math required to convert these parameters into a useful transformation
237 matrix is reproduced below.
240 Parameters: <EM>x<SUB>r,g,b,w</SUB></EM>, <EM>y<SUB>r,g,b,w</SUB></EM>
244 <TD ALIGN="RIGHT">F</TD>
246 <TD ALIGN="LEFT"><TABLE><TR>
247 <TD><FONT SIZE="300%">(</FONT></TD>
250 <TD ALIGN="CENTER"><EM>x<SUB>r</SUB></EM>/<EM>y<SUB>r</SUB></EM></TD>
251 <TD ALIGN="CENTER"><EM>x<SUB>g</SUB></EM>/<EM>y<SUB>g</SUB></EM></TD>
252 <TD ALIGN="CENTER"><EM>x<SUB>b</SUB></EM>/<EM>y<SUB>b</SUB></EM></TD>
255 <TD ALIGN="CENTER">1</TD>
256 <TD ALIGN="CENTER">1</TD>
257 <TD ALIGN="CENTER">1</TD>
261 (1-<EM>x<SUB>r</SUB></EM>-<EM>y<SUB>r</SUB></EM>)/<EM>y<SUB>r</SUB></EM>
264 (1-<EM>x<SUB>g</SUB></EM>-<EM>y<SUB>g</SUB></EM>)/<EM>y<SUB>g</SUB></EM>
267 (1-<EM>x<SUB>b</SUB></EM>-<EM>y<SUB>b</SUB></EM>)/<EM>y<SUB>b</SUB></EM>
271 <TD<FONT SIZE="300%">)</FONT></TD>
275 <TD ALIGN="RIGHT"><TABLE><TR>
276 <TD><FONT SIZE="300%">(</FONT></TD>
278 <TR><TD ALIGN="CENTER">s<SUB>r</SUB></TD></TR>
279 <TR><TD ALIGN="CENTER">s<SUB>g</SUB></TD></TR>
280 <TR><TD ALIGN="CENTER">s<SUB>b</SUB></TD></TR>
282 <TD><FONT SIZE="300%">)</FONT></TD>
285 <TD ALIGN="LEFT"><TABLE><TR>
286 <TD>F<SUP>-1</SUP><FONT SIZE="300%">(</FONT></TD>
288 <TR><TD ALIGN="CENTER"><EM>x<SUB>w</SUB></EM>/<EM>y<SUB>w</SUB></EM></TD></TR>
289 <TR><TD ALIGN="CENTER">1</TD></TR>
290 <TR><TD ALIGN="CENTER">
291 (1-<EM>x<SUB>w</SUB></EM>-<EM>y<SUB>w</SUB></EM>)/<EM>y<SUB>w</SUB></EM>
294 <TD><FONT SIZE="300%">)</FONT></TD>
298 <TD ALIGN="RIGHT"><TABLE><TR>
299 <TD><FONT SIZE="300%">(</FONT></TD>
301 <TR><TD ALIGN="CENTER">X</TD></TR>
302 <TR><TD ALIGN="CENTER">Y</TD></TR>
303 <TR><TD ALIGN="CENTER">Z</TD></TR>
305 <TD><FONT SIZE="300%">)</FONT></TD>
308 <TD ALIGN="LEFT"><TABLE><TR>
309 <TD>F<FONT SIZE="300%">(</FONT></TD>
311 <TR><TD ALIGN="CENTER">s<SUB>r</SUB>R</TD></TR>
312 <TR><TD ALIGN="CENTER">s<SUB>g</SUB>G</TD></TR>
313 <TR><TD ALIGN="CENTER">s<SUB>b</SUB>B</TD></TR>
315 <TD><FONT SIZE="300%">)</FONT></TD>
321 <H2>available color spaces</H2>
323 These are the color spaces currently defined for use by Ogg Theora video.
324 Each one has a short name, with which it is referred to in this document, and
325 a more detailed specification of the standards from which its parameters are
327 Some standards do not specify all the parameters necessary.
328 For these unspecified parameters, this document serves as the definition of
329 what should be used when encoding or decoding Ogg Theora video.
330 <H3>Rec 470M (Rec. ITU-R BT.470-6 System M/NTSC with Rec. ITU-R BT.601-5)</H3>
332 This color space is used by broadcast television and DVDs in much of the
333 Americas, Japan, Korea, and the Union of Myanmar
334 [<A HREF="#Rec470">Rec470</A>].
335 This color space may also be used for System M/PAL (Brazil), with an
336 appropriate conversion supplied by the encoder to compensate for the
337 different gamma value.
338 See the Rec 470BG section for an appropriate gamma value to assume for M/PAL
342 In the US, studio monitors are adjusted to a D65 white point
343 (<EM>x<SUB>w</SUB></EM>,<EM>y<SUB>w</SUB></EM>=0.313,0.329).
344 In Japan, studio monitors are adjusted to a D white of 9300K
345 (<EM>x<SUB>w</SUB></EM>,<EM>y<SUB>w</SUB></EM>=0.285,0.293).
348 Rec 470 does not specify a digital encoding of the color signals.
349 For Ogg Theora, Rec. ITU-R BT.601-5 is used, starting from the R'G'B' signals
350 specified by Rec 470 [<A HREF="#Rec601">Rec601</A>].
354 Rec 470 does not specify an input gamma function.
355 For Ogg Theora, the Rec 709 input function is used.
356 This is the same as that specified by SMPTE 170M, which claims to reflect
357 modern practice in the creation of NTSC signals (c. 1994)
358 [<A HREF="#SMPTE170M">SMPTE170M</A>].
363 <TD ALIGN="RIGHT"><EM>Offset<SUB>Y,C<SUB>b</SUB>,C<SUB>r</SUB></SUB></EM></TD>
365 <TD ALIGN="LEFT" COLSPAN="2">(16,128,128)</TD>
369 <EM>Excursion<SUB>Y,C<SUB>b</SUB>,C<SUB>r</SUB></SUB></EM>
372 <TD ALIGN="LEFT" COLSPAN="2">(219,224,224)</TD>
375 <TD ALIGN="RIGHT"><EM>K<SUB>b</SUB></EM></TD>
377 <TD ALIGN="LEFT" COLSPAN="2">0.114</TD>
380 <TD ALIGN="RIGHT"><EM>K<SUB>r</SUB></EM></TD>
382 <TD ALIGN="LEFT" COLSPAN="2">0.299</TD>
385 <TD ALIGN="RIGHT"><EM>γ</EM></TD>
387 <TD ALIGN="LEFT">2.2</TD>
390 <TD ALIGN="RIGHT"><EM>β</EM></TD>
392 <TD ALIGN="LEFT">0.45</TD>
395 <TD ALIGN="RIGHT"><EM>α</EM></TD>
397 <TD ALIGN="LEFT">4.5</TD>
400 <TD ALIGN="RIGHT"><EM>δ</EM></TD>
402 <TD ALIGN="LEFT">0.018</TD>
405 <TD ALIGN="RIGHT"><EM>ε</EM></TD>
407 <TD ALIGN="LEFT">0.099</TD>
410 <TD ALIGN="RIGHT"><EM>x<SUB>r</SUB></EM>,<EM>y<SUB>r</SUB></EM></TD>
416 <TD ALIGN="RIGHT"><EM>x<SUB>g</SUB></EM>,<EM>y<SUB>g</SUB></EM></TD>
422 <TD ALIGN="RIGHT"><EM>x<SUB>b</SUB></EM>,<EM>y<SUB>b</SUB></EM></TD>
429 (Illuminant C) <EM>x<SUB>w</SUB></EM>,<EM>y<SUB>w</SUB></EM>
437 Rec 470BG (Rec. ITU-R BT.470-6 Systems B and G with Rec. ITU-R BT.601-5)
440 This color space is used by the PAL and SECAM systems in much of the rest of
441 the world [<A HREF="#Rec470">Rec470</A>].
442 This can be used directly by systems (B, B1, D, D1, G, H, I, K, N)/PAL and (B,
443 D, G, H, K, K1, L)/SECAM.
446 Note that the Rec 470BG chromaticity values are different from those specified
448 When PAL and SECAM systems were first designed, they were based upon the same
450 However, as methods of making color picture tubes have changed, the primaries
451 used have changed as well.
452 The US recommends using correction circuitry to approximate the existing,
453 standard NTSC primaries.
454 Current PAL and SECAM systems have standardized on primaries in accord with
455 more recent technology.
458 Rec 470 provisionally permits the use of the NTSC chromaticity values (given
459 above) with legacy PAL and SECAM equipment.
460 In Ogg Theora, material must be decoded assuming the new PAL and SECAM
462 Material intended for display on old legacy devices should be converted by the
466 The official Rec 470BG specifies a gamma value of <EM>γ</EM>=2.8.
467 However, in practice this value is unrealistically high
468 [<A HREF="#RefPoy97">Poy97</A>].
469 Rec 470BG states that the overall system gamma should be approximately
470 <EM>γ</EM>/<EM>β</EM>=1.2.
471 However, most cameras pre-correct with a gamma value of <EM>β</EM>=0.45,
472 which suggests an output device gamma of approximately <EM>γ</EM>=2.67.
473 This is the value recommended for use with PAL systems in Ogg Theora.
476 Rec 470 does not specify a digital encoding of the color signals.
477 For Ogg Theora, Rec. ITU-R BT.601-5 is used, starting from the R'G'B' signals
478 specified by Rec 470 [<A HREF="#Rec601">Rec601</A>].
481 Rec 470 does not specify an input gamma function.
482 For Ogg Theora, the Rec 709 input function is used.
487 <TD ALIGN="RIGHT"><EM>Offset<SUB>Y,C<SUB>b</SUB>,C<SUB>r</SUB></SUB></EM></TD>
489 <TD ALIGN="LEFT" COLSPAN="2">(16,128,128)</TD>
493 <EM>Excursion<SUB>Y,C<SUB>b</SUB>,C<SUB>r</SUB></SUB></EM>
496 <TD ALIGN="LEFT" COLSPAN="2">(219,224,224)</TD>
499 <TD ALIGN="RIGHT"><EM>K<SUB>b</SUB></EM></TD>
501 <TD ALIGN="LEFT" COLSPAN="2">0.114</TD>
504 <TD ALIGN="RIGHT"><EM>K<SUB>r</SUB></EM></TD>
506 <TD ALIGN="LEFT" COLSPAN="2">0.299</TD>
509 <TD ALIGN="RIGHT"><EM>γ</EM></TD>
511 <TD ALIGN="LEFT">2.67</TD>
514 <TD ALIGN="RIGHT"><EM>β</EM></TD>
516 <TD ALIGN="LEFT">0.45</TD>
519 <TD ALIGN="RIGHT"><EM>α</EM></TD>
521 <TD ALIGN="LEFT">4.5</TD>
524 <TD ALIGN="RIGHT"><EM>δ</EM></TD>
526 <TD ALIGN="LEFT">0.018</TD>
529 <TD ALIGN="RIGHT"><EM>ε</EM></TD>
531 <TD ALIGN="LEFT">0.099</TD>
534 <TD ALIGN="RIGHT"><EM>x<SUB>r</SUB></EM>,<EM>y<SUB>r</SUB></EM></TD>
540 <TD ALIGN="RIGHT"><EM>x<SUB>g</SUB></EM>,<EM>y<SUB>g</SUB></EM></TD>
546 <TD ALIGN="RIGHT"><EM>x<SUB>b</SUB></EM>,<EM>y<SUB>b</SUB></EM></TD>
553 (D65) <EM>x<SUB>w</SUB></EM>,<EM>y<SUB>w</SUB></EM>
562 <DT>[<A NAME="Poy97">Poy97</A>]</DT>
564 Poynton, Charles, <I>Frequently-Asked Questions about Gamma</I>.
565 <A HREF="http://www.poynton.com/GammaFAQ.html">http://www.poynton.com/GammaFAQ/html</A>,
568 <DT>[<A NAME="Rec470">Rec470</A>]</DT>
570 Recommendation ITU-R BT.470-6, <I>Conventional Television Systems</I>
571 (1970, revised 1998). International Telecommunications Union, 1211 Geneva 20,
574 <DT>[<A NAME="Rec601">Rec601</A>]</DT>
576 Recommendation ITU-R BT.601-5, <I>Studio Encoding Parameters of
577 Digital Television for Standard 4:3 and Wide-Screen 16:9 Aspect Ratios</I>
578 (1982, revised 1995). International Telecommunications Union, 1211 Geneva 20,
581 <DT>[<A NAME="Rec709">Rec709</A>]</DT>
583 Recommendation ITU-R BT.709-5, <I>Parameter values for the
584 HDTV standards for production and international programme exchange</I>
585 (1990, revised 2002). International Telecommunications Union, 1211 Geneva 20,
588 <DT>[<A NAME="SMPTE170M">SMPTE170M</A>]</DT>
590 Society of Motion Picture and Television Engineers, <I>Television —
591 Composite Analog Video Signal — NTSC for Studio Applications</I>.
594 <DT>[<A NAME="SMPTE240M">SMPTE240M</A>]</DT>
596 Society of Motion Picture and Television Engineers, <I>Television —
597 Signal Parameters — 1125-Line High-Definition Production</I>.