annotate src/libogg-1.3.0/doc/rfc3533.txt @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 98c1576536ae
children
rev   line source
cannam@86 1
cannam@86 2
cannam@86 3
cannam@86 4
cannam@86 5
cannam@86 6
cannam@86 7 Network Working Group S. Pfeiffer
cannam@86 8 Request for Comments: 3533 CSIRO
cannam@86 9 Category: Informational May 2003
cannam@86 10
cannam@86 11
cannam@86 12 The Ogg Encapsulation Format Version 0
cannam@86 13
cannam@86 14 Status of this Memo
cannam@86 15
cannam@86 16 This memo provides information for the Internet community. It does
cannam@86 17 not specify an Internet standard of any kind. Distribution of this
cannam@86 18 memo is unlimited.
cannam@86 19
cannam@86 20 Copyright Notice
cannam@86 21
cannam@86 22 Copyright (C) The Internet Society (2003). All Rights Reserved.
cannam@86 23
cannam@86 24 Abstract
cannam@86 25
cannam@86 26 This document describes the Ogg bitstream format version 0, which is
cannam@86 27 a general, freely-available encapsulation format for media streams.
cannam@86 28 It is able to encapsulate any kind and number of video and audio
cannam@86 29 encoding formats as well as other data streams in a single bitstream.
cannam@86 30
cannam@86 31 Terminology
cannam@86 32
cannam@86 33 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
cannam@86 34 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
cannam@86 35 document are to be interpreted as described in BCP 14, RFC 2119 [2].
cannam@86 36
cannam@86 37 Table of Contents
cannam@86 38
cannam@86 39 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 2
cannam@86 40 2. Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 2
cannam@86 41 3. Requirements for a generic encapsulation format . . . . . . . 3
cannam@86 42 4. The Ogg bitstream format . . . . . . . . . . . . . . . . . . . 3
cannam@86 43 5. The encapsulation process . . . . . . . . . . . . . . . . . . 6
cannam@86 44 6. The Ogg page format . . . . . . . . . . . . . . . . . . . . . 9
cannam@86 45 7. Security Considerations . . . . . . . . . . . . . . . . . . . 11
cannam@86 46 8. References . . . . . . . . . . . . . . . . . . . . . . . . . . 12
cannam@86 47 A. Glossary of terms and abbreviations . . . . . . . . . . . . . 13
cannam@86 48 B. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 14
cannam@86 49 Author's Address . . . . . . . . . . . . . . . . . . . . . . . 14
cannam@86 50 Full Copyright Statement . . . . . . . . . . . . . . . . . . . 15
cannam@86 51
cannam@86 52
cannam@86 53
cannam@86 54
cannam@86 55
cannam@86 56
cannam@86 57
cannam@86 58 Pfeiffer Informational [Page 1]
cannam@86 59
cannam@86 60 RFC 3533 OGG May 2003
cannam@86 61
cannam@86 62
cannam@86 63 1. Introduction
cannam@86 64
cannam@86 65 The Ogg bitstream format has been developed as a part of a larger
cannam@86 66 project aimed at creating a set of components for the coding and
cannam@86 67 decoding of multimedia content (codecs) which are to be freely
cannam@86 68 available and freely re-implementable, both in software and in
cannam@86 69 hardware for the computing community at large, including the Internet
cannam@86 70 community. It is the intention of the Ogg developers represented by
cannam@86 71 Xiph.Org that it be usable without intellectual property concerns.
cannam@86 72
cannam@86 73 This document describes the Ogg bitstream format and how to use it to
cannam@86 74 encapsulate one or several media bitstreams created by one or several
cannam@86 75 encoders. The Ogg transport bitstream is designed to provide
cannam@86 76 framing, error protection and seeking structure for higher-level
cannam@86 77 codec streams that consist of raw, unencapsulated data packets, such
cannam@86 78 as the Vorbis audio codec or the upcoming Tarkin and Theora video
cannam@86 79 codecs. It is capable of interleaving different binary media and
cannam@86 80 other time-continuous data streams that are prepared by an encoder as
cannam@86 81 a sequence of data packets. Ogg provides enough information to
cannam@86 82 properly separate data back into such encoder created data packets at
cannam@86 83 the original packet boundaries without relying on decoding to find
cannam@86 84 packet boundaries.
cannam@86 85
cannam@86 86 Please note that the MIME type application/ogg has been registered
cannam@86 87 with the IANA [1].
cannam@86 88
cannam@86 89 2. Definitions
cannam@86 90
cannam@86 91 For describing the Ogg encapsulation process, a set of terms will be
cannam@86 92 used whose meaning needs to be well understood. Therefore, some of
cannam@86 93 the most fundamental terms are defined now before we start with the
cannam@86 94 description of the requirements for a generic media stream
cannam@86 95 encapsulation format, the process of encapsulation, and the concrete
cannam@86 96 format of the Ogg bitstream. See the Appendix for a more complete
cannam@86 97 glossary.
cannam@86 98
cannam@86 99 The result of an Ogg encapsulation is called the "Physical (Ogg)
cannam@86 100 Bitstream". It encapsulates one or several encoder-created
cannam@86 101 bitstreams, which are called "Logical Bitstreams". A logical
cannam@86 102 bitstream, provided to the Ogg encapsulation process, has a
cannam@86 103 structure, i.e., it is split up into a sequence of so-called
cannam@86 104 "Packets". The packets are created by the encoder of that logical
cannam@86 105 bitstream and represent meaningful entities for that encoder only
cannam@86 106 (e.g., an uncompressed stream may use video frames as packets). They
cannam@86 107 do not contain boundary information - strung together they appear to
cannam@86 108 be streams of random bytes with no landmarks.
cannam@86 109
cannam@86 110
cannam@86 111
cannam@86 112
cannam@86 113
cannam@86 114 Pfeiffer Informational [Page 2]
cannam@86 115
cannam@86 116 RFC 3533 OGG May 2003
cannam@86 117
cannam@86 118
cannam@86 119 Please note that the term "packet" is not used in this document to
cannam@86 120 signify entities for transport over a network.
cannam@86 121
cannam@86 122 3. Requirements for a generic encapsulation format
cannam@86 123
cannam@86 124 The design idea behind Ogg was to provide a generic, linear media
cannam@86 125 transport format to enable both file-based storage and stream-based
cannam@86 126 transmission of one or several interleaved media streams independent
cannam@86 127 of the encoding format of the media data. Such an encapsulation
cannam@86 128 format needs to provide:
cannam@86 129
cannam@86 130 o framing for logical bitstreams.
cannam@86 131
cannam@86 132 o interleaving of different logical bitstreams.
cannam@86 133
cannam@86 134 o detection of corruption.
cannam@86 135
cannam@86 136 o recapture after a parsing error.
cannam@86 137
cannam@86 138 o position landmarks for direct random access of arbitrary positions
cannam@86 139 in the bitstream.
cannam@86 140
cannam@86 141 o streaming capability (i.e., no seeking is needed to build a 100%
cannam@86 142 complete bitstream).
cannam@86 143
cannam@86 144 o small overhead (i.e., use no more than approximately 1-2% of
cannam@86 145 bitstream bandwidth for packet boundary marking, high-level
cannam@86 146 framing, sync and seeking).
cannam@86 147
cannam@86 148 o simplicity to enable fast parsing.
cannam@86 149
cannam@86 150 o simple concatenation mechanism of several physical bitstreams.
cannam@86 151
cannam@86 152 All of these design considerations have been taken into consideration
cannam@86 153 for Ogg. Ogg supports framing and interleaving of logical
cannam@86 154 bitstreams, seeking landmarks, detection of corruption, and stream
cannam@86 155 resynchronisation after a parsing error with no more than
cannam@86 156 approximately 1-2% overhead. It is a generic framework to perform
cannam@86 157 encapsulation of time-continuous bitstreams. It does not know any
cannam@86 158 specifics about the codec data that it encapsulates and is thus
cannam@86 159 independent of any media codec.
cannam@86 160
cannam@86 161 4. The Ogg bitstream format
cannam@86 162
cannam@86 163 A physical Ogg bitstream consists of multiple logical bitstreams
cannam@86 164 interleaved in so-called "Pages". Whole pages are taken in order
cannam@86 165 from multiple logical bitstreams multiplexed at the page level. The
cannam@86 166 logical bitstreams are identified by a unique serial number in the
cannam@86 167
cannam@86 168
cannam@86 169
cannam@86 170 Pfeiffer Informational [Page 3]
cannam@86 171
cannam@86 172 RFC 3533 OGG May 2003
cannam@86 173
cannam@86 174
cannam@86 175 header of each page of the physical bitstream. This unique serial
cannam@86 176 number is created randomly and does not have any connection to the
cannam@86 177 content or encoder of the logical bitstream it represents. Pages of
cannam@86 178 all logical bitstreams are concurrently interleaved, but they need
cannam@86 179 not be in a regular order - they are only required to be consecutive
cannam@86 180 within the logical bitstream. Ogg demultiplexing reconstructs the
cannam@86 181 original logical bitstreams from the physical bitstream by taking the
cannam@86 182 pages in order from the physical bitstream and redirecting them into
cannam@86 183 the appropriate logical decoding entity.
cannam@86 184
cannam@86 185 Each Ogg page contains only one type of data as it belongs to one
cannam@86 186 logical bitstream only. Pages are of variable size and have a page
cannam@86 187 header containing encapsulation and error recovery information. Each
cannam@86 188 logical bitstream in a physical Ogg bitstream starts with a special
cannam@86 189 start page (bos=beginning of stream) and ends with a special page
cannam@86 190 (eos=end of stream).
cannam@86 191
cannam@86 192 The bos page contains information to uniquely identify the codec type
cannam@86 193 and MAY contain information to set up the decoding process. The bos
cannam@86 194 page SHOULD also contain information about the encoded media - for
cannam@86 195 example, for audio, it should contain the sample rate and number of
cannam@86 196 channels. By convention, the first bytes of the bos page contain
cannam@86 197 magic data that uniquely identifies the required codec. It is the
cannam@86 198 responsibility of anyone fielding a new codec to make sure it is
cannam@86 199 possible to reliably distinguish his/her codec from all other codecs
cannam@86 200 in use. There is no fixed way to detect the end of the codec-
cannam@86 201 identifying marker. The format of the bos page is dependent on the
cannam@86 202 codec and therefore MUST be given in the encapsulation specification
cannam@86 203 of that logical bitstream type. Ogg also allows but does not require
cannam@86 204 secondary header packets after the bos page for logical bitstreams
cannam@86 205 and these must also precede any data packets in any logical
cannam@86 206 bitstream. These subsequent header packets are framed into an
cannam@86 207 integral number of pages, which will not contain any data packets.
cannam@86 208 So, a physical bitstream begins with the bos pages of all logical
cannam@86 209 bitstreams containing one initial header packet per page, followed by
cannam@86 210 the subsidiary header packets of all streams, followed by pages
cannam@86 211 containing data packets.
cannam@86 212
cannam@86 213 The encapsulation specification for one or more logical bitstreams is
cannam@86 214 called a "media mapping". An example for a media mapping is "Ogg
cannam@86 215 Vorbis", which uses the Ogg framework to encapsulate Vorbis-encoded
cannam@86 216 audio data for stream-based storage (such as files) and transport
cannam@86 217 (such as TCP streams or pipes). Ogg Vorbis provides the name and
cannam@86 218 revision of the Vorbis codec, the audio rate and the audio quality on
cannam@86 219 the Ogg Vorbis bos page. It also uses two additional header pages
cannam@86 220 per logical bitstream. The Ogg Vorbis bos page starts with the byte
cannam@86 221 0x01, followed by "vorbis" (a total of 7 bytes of identifier).
cannam@86 222
cannam@86 223
cannam@86 224
cannam@86 225
cannam@86 226 Pfeiffer Informational [Page 4]
cannam@86 227
cannam@86 228 RFC 3533 OGG May 2003
cannam@86 229
cannam@86 230
cannam@86 231 Ogg knows two types of multiplexing: concurrent multiplexing (so-
cannam@86 232 called "Grouping") and sequential multiplexing (so-called
cannam@86 233 "Chaining"). Grouping defines how to interleave several logical
cannam@86 234 bitstreams page-wise in the same physical bitstream. Grouping is for
cannam@86 235 example needed for interleaving a video stream with several
cannam@86 236 synchronised audio tracks using different codecs in different logical
cannam@86 237 bitstreams. Chaining on the other hand, is defined to provide a
cannam@86 238 simple mechanism to concatenate physical Ogg bitstreams, as is often
cannam@86 239 needed for streaming applications.
cannam@86 240
cannam@86 241 In grouping, all bos pages of all logical bitstreams MUST appear
cannam@86 242 together at the beginning of the Ogg bitstream. The media mapping
cannam@86 243 specifies the order of the initial pages. For example, the grouping
cannam@86 244 of a specific Ogg video and Ogg audio bitstream may specify that the
cannam@86 245 physical bitstream MUST begin with the bos page of the logical video
cannam@86 246 bitstream, followed by the bos page of the audio bitstream. Unlike
cannam@86 247 bos pages, eos pages for the logical bitstreams need not all occur
cannam@86 248 contiguously. Eos pages may be 'nil' pages, that is, pages
cannam@86 249 containing no content but simply a page header with position
cannam@86 250 information and the eos flag set in the page header. Each grouped
cannam@86 251 logical bitstream MUST have a unique serial number within the scope
cannam@86 252 of the physical bitstream.
cannam@86 253
cannam@86 254 In chaining, complete logical bitstreams are concatenated. The
cannam@86 255 bitstreams do not overlap, i.e., the eos page of a given logical
cannam@86 256 bitstream is immediately followed by the bos page of the next. Each
cannam@86 257 chained logical bitstream MUST have a unique serial number within the
cannam@86 258 scope of the physical bitstream.
cannam@86 259
cannam@86 260 It is possible to consecutively chain groups of concurrently
cannam@86 261 multiplexed bitstreams. The groups, when unchained, MUST stand on
cannam@86 262 their own as a valid concurrently multiplexed bitstream. The
cannam@86 263 following diagram shows a schematic example of such a physical
cannam@86 264 bitstream that obeys all the rules of both grouped and chained
cannam@86 265 multiplexed bitstreams.
cannam@86 266
cannam@86 267 physical bitstream with pages of
cannam@86 268 different logical bitstreams grouped and chained
cannam@86 269 -------------------------------------------------------------
cannam@86 270 |*A*|*B*|*C*|A|A|C|B|A|B|#A#|C|...|B|C|#B#|#C#|*D*|D|...|#D#|
cannam@86 271 -------------------------------------------------------------
cannam@86 272 bos bos bos eos eos eos bos eos
cannam@86 273
cannam@86 274 In this example, there are two chained physical bitstreams, the first
cannam@86 275 of which is a grouped stream of three logical bitstreams A, B, and C.
cannam@86 276 The second physical bitstream is chained after the end of the grouped
cannam@86 277 bitstream, which ends after the last eos page of all its grouped
cannam@86 278 logical bitstreams. As can be seen, grouped bitstreams begin
cannam@86 279
cannam@86 280
cannam@86 281
cannam@86 282 Pfeiffer Informational [Page 5]
cannam@86 283
cannam@86 284 RFC 3533 OGG May 2003
cannam@86 285
cannam@86 286
cannam@86 287 together - all of the bos pages MUST appear before any data pages.
cannam@86 288 It can also be seen that pages of concurrently multiplexed bitstreams
cannam@86 289 need not conform to a regular order. And it can be seen that a
cannam@86 290 grouped bitstream can end long before the other bitstreams in the
cannam@86 291 group end.
cannam@86 292
cannam@86 293 Ogg does not know any specifics about the codec data except that each
cannam@86 294 logical bitstream belongs to a different codec, the data from the
cannam@86 295 codec comes in order and has position markers (so-called "Granule
cannam@86 296 positions"). Ogg does not have a concept of 'time': it only knows
cannam@86 297 about sequentially increasing, unitless position markers. An
cannam@86 298 application can only get temporal information through higher layers
cannam@86 299 which have access to the codec APIs to assign and convert granule
cannam@86 300 positions or time.
cannam@86 301
cannam@86 302 A specific definition of a media mapping using Ogg may put further
cannam@86 303 constraints on its specific use of the Ogg bitstream format. For
cannam@86 304 example, a specific media mapping may require that all the eos pages
cannam@86 305 for all grouped bitstreams need to appear in direct sequence. An
cannam@86 306 example for a media mapping is the specification of "Ogg Vorbis".
cannam@86 307 Another example is the upcoming "Ogg Theora" specification which
cannam@86 308 encapsulates Theora-encoded video data and usually comes multiplexed
cannam@86 309 with a Vorbis stream for an Ogg containing synchronised audio and
cannam@86 310 video. As Ogg does not specify temporal relationships between the
cannam@86 311 encapsulated concurrently multiplexed bitstreams, the temporal
cannam@86 312 synchronisation between the audio and video stream will be specified
cannam@86 313 in this media mapping. To enable streaming, pages from various
cannam@86 314 logical bitstreams will typically be interleaved in chronological
cannam@86 315 order.
cannam@86 316
cannam@86 317 5. The encapsulation process
cannam@86 318
cannam@86 319 The process of multiplexing different logical bitstreams happens at
cannam@86 320 the level of pages as described above. The bitstreams provided by
cannam@86 321 encoders are however handed over to Ogg as so-called "Packets" with
cannam@86 322 packet boundaries dependent on the encoding format. The process of
cannam@86 323 encapsulating packets into pages will be described now.
cannam@86 324
cannam@86 325 From Ogg's perspective, packets can be of any arbitrary size. A
cannam@86 326 specific media mapping will define how to group or break up packets
cannam@86 327 from a specific media encoder. As Ogg pages have a maximum size of
cannam@86 328 about 64 kBytes, sometimes a packet has to be distributed over
cannam@86 329 several pages. To simplify that process, Ogg divides each packet
cannam@86 330 into 255 byte long chunks plus a final shorter chunk. These chunks
cannam@86 331 are called "Ogg Segments". They are only a logical construct and do
cannam@86 332 not have a header for themselves.
cannam@86 333
cannam@86 334
cannam@86 335
cannam@86 336
cannam@86 337
cannam@86 338 Pfeiffer Informational [Page 6]
cannam@86 339
cannam@86 340 RFC 3533 OGG May 2003
cannam@86 341
cannam@86 342
cannam@86 343 A group of contiguous segments is wrapped into a variable length page
cannam@86 344 preceded by a header. A segment table in the page header tells about
cannam@86 345 the "Lacing values" (sizes) of the segments included in the page. A
cannam@86 346 flag in the page header tells whether a page contains a packet
cannam@86 347 continued from a previous page. Note that a lacing value of 255
cannam@86 348 implies that a second lacing value follows in the packet, and a value
cannam@86 349 of less than 255 marks the end of the packet after that many
cannam@86 350 additional bytes. A packet of 255 bytes (or a multiple of 255 bytes)
cannam@86 351 is terminated by a lacing value of 0. Note also that a 'nil' (zero
cannam@86 352 length) packet is not an error; it consists of nothing more than a
cannam@86 353 lacing value of zero in the header.
cannam@86 354
cannam@86 355 The encoding is optimized for speed and the expected case of the
cannam@86 356 majority of packets being between 50 and 200 bytes large. This is a
cannam@86 357 design justification rather than a recommendation. This encoding
cannam@86 358 both avoids imposing a maximum packet size as well as imposing
cannam@86 359 minimum overhead on small packets. In contrast, e.g., simply using
cannam@86 360 two bytes at the head of every packet and having a max packet size of
cannam@86 361 32 kBytes would always penalize small packets (< 255 bytes, the
cannam@86 362 typical case) with twice the segmentation overhead. Using the lacing
cannam@86 363 values as suggested, small packets see the minimum possible byte-
cannam@86 364 aligned overhead (1 byte) and large packets (>512 bytes) see a fairly
cannam@86 365 constant ~0.5% overhead on encoding space.
cannam@86 366
cannam@86 367
cannam@86 368
cannam@86 369
cannam@86 370
cannam@86 371
cannam@86 372
cannam@86 373
cannam@86 374
cannam@86 375
cannam@86 376
cannam@86 377
cannam@86 378
cannam@86 379
cannam@86 380
cannam@86 381
cannam@86 382
cannam@86 383
cannam@86 384
cannam@86 385
cannam@86 386
cannam@86 387
cannam@86 388
cannam@86 389
cannam@86 390
cannam@86 391
cannam@86 392
cannam@86 393
cannam@86 394 Pfeiffer Informational [Page 7]
cannam@86 395
cannam@86 396 RFC 3533 OGG May 2003
cannam@86 397
cannam@86 398
cannam@86 399 The following diagram shows a schematic example of a media mapping
cannam@86 400 using Ogg and grouped logical bitstreams:
cannam@86 401
cannam@86 402 logical bitstream with packet boundaries
cannam@86 403 -----------------------------------------------------------------
cannam@86 404 > | packet_1 | packet_2 | packet_3 | <
cannam@86 405 -----------------------------------------------------------------
cannam@86 406
cannam@86 407 |segmentation (logically only)
cannam@86 408 v
cannam@86 409
cannam@86 410 packet_1 (5 segments) packet_2 (4 segs) p_3 (2 segs)
cannam@86 411 ------------------------------ -------------------- ------------
cannam@86 412 .. |seg_1|seg_2|seg_3|seg_4|s_5 | |seg_1|seg_2|seg_3|| |seg_1|s_2 | ..
cannam@86 413 ------------------------------ -------------------- ------------
cannam@86 414
cannam@86 415 | page encapsulation
cannam@86 416 v
cannam@86 417
cannam@86 418 page_1 (packet_1 data) page_2 (pket_1 data) page_3 (packet_2 data)
cannam@86 419 ------------------------ ---------------- ------------------------
cannam@86 420 |H|------------------- | |H|----------- | |H|------------------- |
cannam@86 421 |D||seg_1|seg_2|seg_3| | |D|seg_4|s_5 | | |D||seg_1|seg_2|seg_3| | ...
cannam@86 422 |R|------------------- | |R|----------- | |R|------------------- |
cannam@86 423 ------------------------ ---------------- ------------------------
cannam@86 424
cannam@86 425 |
cannam@86 426 pages of |
cannam@86 427 other --------| |
cannam@86 428 logical -------
cannam@86 429 bitstreams | MUX |
cannam@86 430 -------
cannam@86 431 |
cannam@86 432 v
cannam@86 433
cannam@86 434 page_1 page_2 page_3
cannam@86 435 ------ ------ ------- ----- -------
cannam@86 436 ... || | || | || | || | || | ...
cannam@86 437 ------ ------ ------- ----- -------
cannam@86 438 physical Ogg bitstream
cannam@86 439
cannam@86 440 In this example we take a snapshot of the encapsulation process of
cannam@86 441 one logical bitstream. We can see part of that bitstream's
cannam@86 442 subdivision into packets as provided by the codec. The Ogg
cannam@86 443 encapsulation process chops up the packets into segments. The
cannam@86 444 packets in this example are rather large such that packet_1 is split
cannam@86 445 into 5 segments - 4 segments with 255 bytes and a final smaller one.
cannam@86 446 Packet_2 is split into 4 segments - 3 segments with 255 bytes and a
cannam@86 447
cannam@86 448
cannam@86 449
cannam@86 450 Pfeiffer Informational [Page 8]
cannam@86 451
cannam@86 452 RFC 3533 OGG May 2003
cannam@86 453
cannam@86 454
cannam@86 455 final very small one - and packet_3 is split into two segments. The
cannam@86 456 encapsulation process then creates pages, which are quite small in
cannam@86 457 this example. Page_1 consists of the first three segments of
cannam@86 458 packet_1, page_2 contains the remaining 2 segments from packet_1, and
cannam@86 459 page_3 contains the first three pages of packet_2. Finally, this
cannam@86 460 logical bitstream is multiplexed into a physical Ogg bitstream with
cannam@86 461 pages of other logical bitstreams.
cannam@86 462
cannam@86 463 6. The Ogg page format
cannam@86 464
cannam@86 465 A physical Ogg bitstream consists of a sequence of concatenated
cannam@86 466 pages. Pages are of variable size, usually 4-8 kB, maximum 65307
cannam@86 467 bytes. A page header contains all the information needed to
cannam@86 468 demultiplex the logical bitstreams out of the physical bitstream and
cannam@86 469 to perform basic error recovery and landmarks for seeking. Each page
cannam@86 470 is a self-contained entity such that the page decode mechanism can
cannam@86 471 recognize, verify, and handle single pages at a time without
cannam@86 472 requiring the overall bitstream.
cannam@86 473
cannam@86 474 The Ogg page header has the following format:
cannam@86 475
cannam@86 476 0 1 2 3
cannam@86 477 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| Byte
cannam@86 478 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
cannam@86 479 | capture_pattern: Magic number for page start "OggS" | 0-3
cannam@86 480 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
cannam@86 481 | version | header_type | granule_position | 4-7
cannam@86 482 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
cannam@86 483 | | 8-11
cannam@86 484 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
cannam@86 485 | | bitstream_serial_number | 12-15
cannam@86 486 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
cannam@86 487 | | page_sequence_number | 16-19
cannam@86 488 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
cannam@86 489 | | CRC_checksum | 20-23
cannam@86 490 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
cannam@86 491 | |page_segments | segment_table | 24-27
cannam@86 492 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
cannam@86 493 | ... | 28-
cannam@86 494 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
cannam@86 495
cannam@86 496 The LSb (least significant bit) comes first in the Bytes. Fields
cannam@86 497 with more than one byte length are encoded LSB (least significant
cannam@86 498 byte) first.
cannam@86 499
cannam@86 500
cannam@86 501
cannam@86 502
cannam@86 503
cannam@86 504
cannam@86 505
cannam@86 506 Pfeiffer Informational [Page 9]
cannam@86 507
cannam@86 508 RFC 3533 OGG May 2003
cannam@86 509
cannam@86 510
cannam@86 511 The fields in the page header have the following meaning:
cannam@86 512
cannam@86 513 1. capture_pattern: a 4 Byte field that signifies the beginning of a
cannam@86 514 page. It contains the magic numbers:
cannam@86 515
cannam@86 516 0x4f 'O'
cannam@86 517
cannam@86 518 0x67 'g'
cannam@86 519
cannam@86 520 0x67 'g'
cannam@86 521
cannam@86 522 0x53 'S'
cannam@86 523
cannam@86 524 It helps a decoder to find the page boundaries and regain
cannam@86 525 synchronisation after parsing a corrupted stream. Once the
cannam@86 526 capture pattern is found, the decoder verifies page sync and
cannam@86 527 integrity by computing and comparing the checksum.
cannam@86 528
cannam@86 529 2. stream_structure_version: 1 Byte signifying the version number of
cannam@86 530 the Ogg file format used in this stream (this document specifies
cannam@86 531 version 0).
cannam@86 532
cannam@86 533 3. header_type_flag: the bits in this 1 Byte field identify the
cannam@86 534 specific type of this page.
cannam@86 535
cannam@86 536 * bit 0x01
cannam@86 537
cannam@86 538 set: page contains data of a packet continued from the previous
cannam@86 539 page
cannam@86 540
cannam@86 541 unset: page contains a fresh packet
cannam@86 542
cannam@86 543 * bit 0x02
cannam@86 544
cannam@86 545 set: this is the first page of a logical bitstream (bos)
cannam@86 546
cannam@86 547 unset: this page is not a first page
cannam@86 548
cannam@86 549 * bit 0x04
cannam@86 550
cannam@86 551 set: this is the last page of a logical bitstream (eos)
cannam@86 552
cannam@86 553 unset: this page is not a last page
cannam@86 554
cannam@86 555 4. granule_position: an 8 Byte field containing position information.
cannam@86 556 For example, for an audio stream, it MAY contain the total number
cannam@86 557 of PCM samples encoded after including all frames finished on this
cannam@86 558 page. For a video stream it MAY contain the total number of video
cannam@86 559
cannam@86 560
cannam@86 561
cannam@86 562 Pfeiffer Informational [Page 10]
cannam@86 563
cannam@86 564 RFC 3533 OGG May 2003
cannam@86 565
cannam@86 566
cannam@86 567 frames encoded after this page. This is a hint for the decoder
cannam@86 568 and gives it some timing and position information. Its meaning is
cannam@86 569 dependent on the codec for that logical bitstream and specified in
cannam@86 570 a specific media mapping. A special value of -1 (in two's
cannam@86 571 complement) indicates that no packets finish on this page.
cannam@86 572
cannam@86 573 5. bitstream_serial_number: a 4 Byte field containing the unique
cannam@86 574 serial number by which the logical bitstream is identified.
cannam@86 575
cannam@86 576 6. page_sequence_number: a 4 Byte field containing the sequence
cannam@86 577 number of the page so the decoder can identify page loss. This
cannam@86 578 sequence number is increasing on each logical bitstream
cannam@86 579 separately.
cannam@86 580
cannam@86 581 7. CRC_checksum: a 4 Byte field containing a 32 bit CRC checksum of
cannam@86 582 the page (including header with zero CRC field and page content).
cannam@86 583 The generator polynomial is 0x04c11db7.
cannam@86 584
cannam@86 585 8. number_page_segments: 1 Byte giving the number of segment entries
cannam@86 586 encoded in the segment table.
cannam@86 587
cannam@86 588 9. segment_table: number_page_segments Bytes containing the lacing
cannam@86 589 values of all segments in this page. Each Byte contains one
cannam@86 590 lacing value.
cannam@86 591
cannam@86 592 The total header size in bytes is given by:
cannam@86 593 header_size = number_page_segments + 27 [Byte]
cannam@86 594
cannam@86 595 The total page size in Bytes is given by:
cannam@86 596 page_size = header_size + sum(lacing_values: 1..number_page_segments)
cannam@86 597 [Byte]
cannam@86 598
cannam@86 599 7. Security Considerations
cannam@86 600
cannam@86 601 The Ogg encapsulation format is a container format and only
cannam@86 602 encapsulates content (such as Vorbis-encoded audio). It does not
cannam@86 603 provide for any generic encryption or signing of itself or its
cannam@86 604 contained content bitstreams. However, it encapsulates any kind of
cannam@86 605 content bitstream as long as there is a codec for it, and is thus
cannam@86 606 able to contain encrypted and signed content data. It is also
cannam@86 607 possible to add an external security mechanism that encrypts or signs
cannam@86 608 an Ogg physical bitstream and thus provides content confidentiality
cannam@86 609 and authenticity.
cannam@86 610
cannam@86 611 As Ogg encapsulates binary data, it is possible to include executable
cannam@86 612 content in an Ogg bitstream. This can be an issue with applications
cannam@86 613 that are implemented using the Ogg format, especially when Ogg is
cannam@86 614 used for streaming or file transfer in a networking scenario. As
cannam@86 615
cannam@86 616
cannam@86 617
cannam@86 618 Pfeiffer Informational [Page 11]
cannam@86 619
cannam@86 620 RFC 3533 OGG May 2003
cannam@86 621
cannam@86 622
cannam@86 623 such, Ogg does not pose a threat there. However, an application
cannam@86 624 decoding Ogg and its encapsulated content bitstreams has to ensure
cannam@86 625 correct handling of manipulated bitstreams, of buffer overflows and
cannam@86 626 the like.
cannam@86 627
cannam@86 628 8. References
cannam@86 629
cannam@86 630 [1] Walleij, L., "The application/ogg Media Type", RFC 3534, May
cannam@86 631 2003.
cannam@86 632
cannam@86 633 [2] Bradner, S., "Key words for use in RFCs to Indicate Requirement
cannam@86 634 Levels", BCP 14, RFC 2119, March 1997.
cannam@86 635
cannam@86 636
cannam@86 637
cannam@86 638
cannam@86 639
cannam@86 640
cannam@86 641
cannam@86 642
cannam@86 643
cannam@86 644
cannam@86 645
cannam@86 646
cannam@86 647
cannam@86 648
cannam@86 649
cannam@86 650
cannam@86 651
cannam@86 652
cannam@86 653
cannam@86 654
cannam@86 655
cannam@86 656
cannam@86 657
cannam@86 658
cannam@86 659
cannam@86 660
cannam@86 661
cannam@86 662
cannam@86 663
cannam@86 664
cannam@86 665
cannam@86 666
cannam@86 667
cannam@86 668
cannam@86 669
cannam@86 670
cannam@86 671
cannam@86 672
cannam@86 673
cannam@86 674 Pfeiffer Informational [Page 12]
cannam@86 675
cannam@86 676 RFC 3533 OGG May 2003
cannam@86 677
cannam@86 678
cannam@86 679 Appendix A. Glossary of terms and abbreviations
cannam@86 680
cannam@86 681 bos page: The initial page (beginning of stream) of a logical
cannam@86 682 bitstream which contains information to identify the codec type
cannam@86 683 and other decoding-relevant information.
cannam@86 684
cannam@86 685 chaining (or sequential multiplexing): Concatenation of two or more
cannam@86 686 complete physical Ogg bitstreams.
cannam@86 687
cannam@86 688 eos page: The final page (end of stream) of a logical bitstream.
cannam@86 689
cannam@86 690 granule position: An increasing position number for a specific
cannam@86 691 logical bitstream stored in the page header. Its meaning is
cannam@86 692 dependent on the codec for that logical bitstream and specified in
cannam@86 693 a specific media mapping.
cannam@86 694
cannam@86 695 grouping (or concurrent multiplexing): Interleaving of pages of
cannam@86 696 several logical bitstreams into one complete physical Ogg
cannam@86 697 bitstream under the restriction that all bos pages of all grouped
cannam@86 698 logical bitstreams MUST appear before any data pages.
cannam@86 699
cannam@86 700 lacing value: An entry in the segment table of a page header
cannam@86 701 representing the size of the related segment.
cannam@86 702
cannam@86 703 logical bitstream: A sequence of bits being the result of an encoded
cannam@86 704 media stream.
cannam@86 705
cannam@86 706 media mapping: A specific use of the Ogg encapsulation format
cannam@86 707 together with a specific (set of) codec(s).
cannam@86 708
cannam@86 709 (Ogg) packet: A subpart of a logical bitstream that is created by the
cannam@86 710 encoder for that bitstream and represents a meaningful entity for
cannam@86 711 the encoder, but only a sequence of bits to the Ogg encapsulation.
cannam@86 712
cannam@86 713 (Ogg) page: A physical bitstream consists of a sequence of Ogg pages
cannam@86 714 containing data of one logical bitstream only. It usually
cannam@86 715 contains a group of contiguous segments of one packet only, but
cannam@86 716 sometimes packets are too large and need to be split over several
cannam@86 717 pages.
cannam@86 718
cannam@86 719 physical (Ogg) bitstream: The sequence of bits resulting from an Ogg
cannam@86 720 encapsulation of one or several logical bitstreams. It consists
cannam@86 721 of a sequence of pages from the logical bitstreams with the
cannam@86 722 restriction that the pages of one logical bitstream MUST come in
cannam@86 723 their correct temporal order.
cannam@86 724
cannam@86 725
cannam@86 726
cannam@86 727
cannam@86 728
cannam@86 729
cannam@86 730 Pfeiffer Informational [Page 13]
cannam@86 731
cannam@86 732 RFC 3533 OGG May 2003
cannam@86 733
cannam@86 734
cannam@86 735 (Ogg) segment: The Ogg encapsulation process splits each packet into
cannam@86 736 chunks of 255 bytes plus a last fractional chunk of less than 255
cannam@86 737 bytes. These chunks are called segments.
cannam@86 738
cannam@86 739 Appendix B. Acknowledgements
cannam@86 740
cannam@86 741 The author gratefully acknowledges the work that Christopher
cannam@86 742 Montgomery and the Xiph.Org foundation have done in defining the Ogg
cannam@86 743 multimedia project and as part of it the open file format described
cannam@86 744 in this document. The author hopes that providing this document to
cannam@86 745 the Internet community will help in promoting the Ogg multimedia
cannam@86 746 project at http://www.xiph.org/. Many thanks also for the many
cannam@86 747 technical and typo corrections that C. Montgomery and the Ogg
cannam@86 748 community provided as feedback to this RFC.
cannam@86 749
cannam@86 750 Author's Address
cannam@86 751
cannam@86 752 Silvia Pfeiffer
cannam@86 753 CSIRO, Australia
cannam@86 754 Locked Bag 17
cannam@86 755 North Ryde, NSW 2113
cannam@86 756 Australia
cannam@86 757
cannam@86 758 Phone: +61 2 9325 3141
cannam@86 759 EMail: Silvia.Pfeiffer@csiro.au
cannam@86 760 URI: http://www.cmis.csiro.au/Silvia.Pfeiffer/
cannam@86 761
cannam@86 762
cannam@86 763
cannam@86 764
cannam@86 765
cannam@86 766
cannam@86 767
cannam@86 768
cannam@86 769
cannam@86 770
cannam@86 771
cannam@86 772
cannam@86 773
cannam@86 774
cannam@86 775
cannam@86 776
cannam@86 777
cannam@86 778
cannam@86 779
cannam@86 780
cannam@86 781
cannam@86 782
cannam@86 783
cannam@86 784
cannam@86 785
cannam@86 786 Pfeiffer Informational [Page 14]
cannam@86 787
cannam@86 788 RFC 3533 OGG May 2003
cannam@86 789
cannam@86 790
cannam@86 791 Full Copyright Statement
cannam@86 792
cannam@86 793 Copyright (C) The Internet Society (2003). All Rights Reserved.
cannam@86 794
cannam@86 795 This document and translations of it may be copied and furnished to
cannam@86 796 others, and derivative works that comment on or otherwise explain it
cannam@86 797 or assist in its implementation may be prepared, copied, published
cannam@86 798 and distributed, in whole or in part, without restriction of any
cannam@86 799 kind, provided that the above copyright notice and this paragraph are
cannam@86 800 included on all such copies and derivative works. However, this
cannam@86 801 document itself may not be modified in any way, such as by removing
cannam@86 802 the copyright notice or references to the Internet Society or other
cannam@86 803 Internet organizations, except as needed for the purpose of
cannam@86 804 developing Internet standards in which case the procedures for
cannam@86 805 copyrights defined in the Internet Standards process must be
cannam@86 806 followed, or as required to translate it into languages other than
cannam@86 807 English.
cannam@86 808
cannam@86 809 The limited permissions granted above are perpetual and will not be
cannam@86 810 revoked by the Internet Society or its successors or assigns.
cannam@86 811
cannam@86 812 This document and the information contained herein is provided on an
cannam@86 813 "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
cannam@86 814 TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
cannam@86 815 BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
cannam@86 816 HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
cannam@86 817 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
cannam@86 818
cannam@86 819 Acknowledgement
cannam@86 820
cannam@86 821 Funding for the RFC Editor function is currently provided by the
cannam@86 822 Internet Society.
cannam@86 823
cannam@86 824
cannam@86 825
cannam@86 826
cannam@86 827
cannam@86 828
cannam@86 829
cannam@86 830
cannam@86 831
cannam@86 832
cannam@86 833
cannam@86 834
cannam@86 835
cannam@86 836
cannam@86 837
cannam@86 838
cannam@86 839
cannam@86 840
cannam@86 841
cannam@86 842 Pfeiffer Informational [Page 15]
cannam@86 843