<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.xiph.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mvrable</id>
	<title>XiphWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.xiph.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mvrable"/>
	<link rel="alternate" type="text/html" href="https://wiki.xiph.org/Special:Contributions/Mvrable"/>
	<updated>2026-05-04T13:22:23Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=TransOgg_Page&amp;diff=12295</id>
		<title>TransOgg Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=TransOgg_Page&amp;diff=12295"/>
		<updated>2010-09-02T20:40:14Z</updated>

		<summary type="html">&lt;p&gt;Mvrable: /* Lacing codewords */ bugfix in the lacing specification&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= transOgg Page Primitive =&lt;br /&gt;
&lt;br /&gt;
transOgg transport consists of a single encapsulation primitive, based&lt;br /&gt;
on the original Ogg page.  Pages are byte aligned; in the diagram&lt;br /&gt;
below, bytes are encoded left to right, top to bottom.&lt;br /&gt;
Greater-than-byte quantities are encoded in little-endian byteorder.&lt;br /&gt;
&lt;br /&gt;
           01234567 01234567 01234567 01234567&lt;br /&gt;
              0        1        2        3&lt;br /&gt;
    --    |-------- -------- -------- --------|&lt;br /&gt;
         0|          capture pattern          |3&lt;br /&gt;
          |--------|-------- -------- --------|&lt;br /&gt;
         4| sgmnts |   stream identification  |7&lt;br /&gt;
          |------|-|--------|-------- --------|&lt;br /&gt;
    20   8| flag |  hbytes  |      dbytes     |11&lt;br /&gt;
          |------|- --------|-------- --------|&lt;br /&gt;
        12|          32 bit checksum          |15&lt;br /&gt;
          |-------- -------- -------- --------|&lt;br /&gt;
        16|          DTS [low] word           |19&lt;br /&gt;
    --    |-------- -------- -------- --------|&lt;br /&gt;
        20?           DTS high word           |&lt;br /&gt;
          |-------- -------- -------- --------&lt;br /&gt;
          ? sequence...&lt;br /&gt;
          |--------&lt;br /&gt;
  hbytes  ? distance...&lt;br /&gt;
          |--------&lt;br /&gt;
          ? segment table...&lt;br /&gt;
          |--------&lt;br /&gt;
          ? delay... duration... ppflags...&lt;br /&gt;
    --    |--------&lt;br /&gt;
  dbytes  ? data payloads...&lt;br /&gt;
    --    |--------                   &lt;br /&gt;
&lt;br /&gt;
== capture pattern ==&lt;br /&gt;
the capture pattern consists of four ASCII 7-bit clean bytes: &#039;tOgS&#039;&lt;br /&gt;
(0x74, 0x4F, 0x47, 0x53 in order)&lt;br /&gt;
&lt;br /&gt;
== segment count ==&lt;br /&gt;
&#039;sgmnts&#039; (8 bits, 0-255) indicates the number of packet segments&lt;br /&gt;
encoded in this page.  The first and/or last packets may be partial&lt;br /&gt;
as specified by the FROM/TO flags (below).&lt;br /&gt;
&lt;br /&gt;
== stream identification ==&lt;br /&gt;
the stream identification ID is a 24-bit pseudo-random number that&lt;br /&gt;
uniquely identifies this media stream within the larger multiplexed&lt;br /&gt;
stream.  It must be unique both in the current multiplexed section,&lt;br /&gt;
as well as globally unique within a chained stream.  The large size&lt;br /&gt;
of the 24 bit ID is intended to be used like a weak hash such that&lt;br /&gt;
it will be highly unlikely to need to rewrite a stream&#039;s ID number&lt;br /&gt;
(and thus rechecksum all the pages as well) when multiplexing or&lt;br /&gt;
concatenating.&lt;br /&gt;
&lt;br /&gt;
== flags ==&lt;br /&gt;
&#039;flags&#039; defines seven bit flags (bits 0-6 of byte 8) as follows:&lt;br /&gt;
   0 FROM:   set == initial packet continued from previous page&lt;br /&gt;
                    note: unset if page contains no packets&lt;br /&gt;
   1 TO  :   set == final packet continued on next page&lt;br /&gt;
                    note: unset if page contains no packets&lt;br /&gt;
   2 CRC :   set == checksum applies to header and data&lt;br /&gt;
           unset == checksum applies to header fields only&lt;br /&gt;
   3 SYNC:   set == payload data begins with a syncpoint/keyframe&lt;br /&gt;
                    note: always set for keyframeless codecs&lt;br /&gt;
                    note: set if a keyframe/syncpoint packet is continued&lt;br /&gt;
                          onto the current page&lt;br /&gt;
   4 SEQ :   set == sequence field is present&lt;br /&gt;
   5 DURA:   set == full raw duration encoding present &lt;br /&gt;
   6 EVIL:          as specified in RFC 3514&lt;br /&gt;
&lt;br /&gt;
== header variable fields bytes ==&lt;br /&gt;
&#039;hbytes&#039; (bit 7 of byte 8 and bits 0-7 of byte 9 for 9 bits total, 0-511) indicates the number of bytes spanned by&lt;br /&gt;
the variable-length header fields (DTS high word, sequence,&lt;br /&gt;
distance, lacing, and delay/duration/ppflags fields)&lt;br /&gt;
&lt;br /&gt;
== data payload bytes ==&lt;br /&gt;
&#039;dbytes&#039; (16 bits, 0-65535) indicates the number of bytes of data payload.&lt;br /&gt;
&lt;br /&gt;
== checksum ==&lt;br /&gt;
the checksum is 32 bit CRC value (direct algorithm, initial val and&lt;br /&gt;
final XOR = 0, generator polynomial=0x04c11db7) encoded in the page&lt;br /&gt;
header in little-endian format.  The checksum is computed over the&lt;br /&gt;
20+hbytes header bytes, skipping the CRC bytes. When the CRC flag&lt;br /&gt;
is set, the CRC continues over the entire page body (dbytes).&lt;br /&gt;
&lt;br /&gt;
== delivery/decode-time stamp ==&lt;br /&gt;
The DTS field is a variable-length encoded delivery time stamp value,&lt;br /&gt;
equivalent to the high bits of the granule position in the original&lt;br /&gt;
Ogg container.  The DTS value is encoded in [[#V32/64 format|V32/64 format]] and is either 4 or 8 bytes in total.&lt;br /&gt;
&lt;br /&gt;
== sequence field ==&lt;br /&gt;
The sequence field is present when the SEQ flag is set; this field&lt;br /&gt;
orders any sequence of pages that have the same DTS, such as pages&lt;br /&gt;
without complete packets, or pages containing only packets with&lt;br /&gt;
zero duration. The sequence value is encoded in [[#V8/16/32 format|V8/16/32 format]].  The first page in a sequence of pages with identical&lt;br /&gt;
DTS does not set the SEQ flag.  The second page in a sequence sets&lt;br /&gt;
the SEQ flag and the sequence value to zero.  The third page in a&lt;br /&gt;
sequence sets the SEQ flag and the sequence value to one, etc.&lt;br /&gt;
&lt;br /&gt;
== distance field ==&lt;br /&gt;
The distance field is conditionally present only if the SYNC flag&lt;br /&gt;
is unset.  It is equal to the DTS of the current page minus the DTS&lt;br /&gt;
of the previous syncpoint packet (not page) minus one.  The value&lt;br /&gt;
is encoded in [[#V8/16/32 format|V8/16/32 format]].&lt;br /&gt;
&lt;br /&gt;
== segment table ==&lt;br /&gt;
Lacing values encode the length of each payload segment in the&lt;br /&gt;
page into the segment table.  [[#Lacing codewords|Lacing values are coded in one, two or three bytes]]. Lacing&lt;br /&gt;
values are coded until the total number of coded segment&lt;br /&gt;
lengths == &#039;sgmnts-1&#039;. Length of the last segment is implicit,&lt;br /&gt;
equalling the unencoded remainder of &#039;dbytes&#039;, which may be zero.&lt;br /&gt;
   &lt;br /&gt;
Overrunning the number of declared segments (ie, a zero run encodes&lt;br /&gt;
past the &#039;sgmnts&#039;-1 limit), or underruning the expected number of&lt;br /&gt;
segments (ie, reading to the end of hbytes before seeing the&lt;br /&gt;
expected number of segments) shall be considered an error condition&lt;br /&gt;
rendering the page undecodable.  Lacing values may encode no more&lt;br /&gt;
than 255 segments total (including the implicit last segment), null&lt;br /&gt;
or otherwise, in a single page.&lt;br /&gt;
   &lt;br /&gt;
If &#039;sgmnts&#039; is zero, the page is a null-page containing no&lt;br /&gt;
data. &#039;dbytes&#039; must also be zero.  &lt;br /&gt;
[[TransOgg_NULL|More on proper encoding and use of null pages]]&lt;br /&gt;
&lt;br /&gt;
== per-packet fields ==&lt;br /&gt;
the delay, duration and per-packet flags are collectively&lt;br /&gt;
byte-aligned and fill out the remainder of the &#039;hbytes&#039; span not&lt;br /&gt;
filled by the DTS, sequence, distance and lacing fields. Within&lt;br /&gt;
this span, the individual delay, duration and flag fields are&lt;br /&gt;
bit-aligned using a big-endian byte-packer.&lt;br /&gt;
&lt;br /&gt;
=== delay values ===&lt;br /&gt;
Delay values are written first.  A field of N bits is written&lt;br /&gt;
for every packet completed on the page. N is set in the&lt;br /&gt;
stream metaheader; N may be zero in which case no delay&lt;br /&gt;
values are written.  The value encoded is the PTS minus the&lt;br /&gt;
DTS of the packet.  The value in unsigned (positive).&lt;br /&gt;
&lt;br /&gt;
=== duration values ===&lt;br /&gt;
Duration values are written next, bit aligned to the end of&lt;br /&gt;
the delay values. A duration value is written for each packet&lt;br /&gt;
completed on the page.&lt;br /&gt;
&lt;br /&gt;
If the DURA flag is unset, each duration value is written as&lt;br /&gt;
an N bit quantity, where N is set in the metadata header.  N&lt;br /&gt;
may be zero.  The value as written is interpreted according&lt;br /&gt;
to the duration base, duration multiplier and duration table&lt;br /&gt;
declared in the metadata header.&lt;br /&gt;
&lt;br /&gt;
If the DURA flag is set, each duration value is instead&lt;br /&gt;
encoded as an [[#V8/16/32 format|V8/16/32 value]] and interpreted&lt;br /&gt;
directly against the stream&#039;s master PTS/DTS timebase.&lt;br /&gt;
&lt;br /&gt;
=== per-packet &#039;private&#039; flags ===&lt;br /&gt;
Codec-private &#039;per packet&#039; flags are encoded next. A field of&lt;br /&gt;
N bits is written for every packet completed on the page.  N&lt;br /&gt;
is set in the stream metadata; N may be zero in which case no&lt;br /&gt;
packet flags are written.&lt;br /&gt;
&lt;br /&gt;
=== padding ===&lt;br /&gt;
Any unused bits needed to fill the last byte out such that&lt;br /&gt;
the lags are written into an integral number of bytes are set&lt;br /&gt;
to zero. The hbytes field may not be used to &#039;pad&#039; the flags&lt;br /&gt;
fields with extra space; more than seven &#039;left over&#039; bits&lt;br /&gt;
(hbytes + 4 - DTS bytes - sequence field bytes - distance&lt;br /&gt;
field bytes - segment tabel bytes) * 8 - flag bits &amp;gt; 7) shall be considered&lt;br /&gt;
an error rendering the page undecodable.&lt;br /&gt;
&lt;br /&gt;
== data payload ==&lt;br /&gt;
Data payload is byte-aligned and immediately follows the last flag&lt;br /&gt;
byte. The size of the data payload is equal to dbytes.&lt;br /&gt;
&lt;br /&gt;
= Value encodings =&lt;br /&gt;
&lt;br /&gt;
== Lacing codewords ==&lt;br /&gt;
Lacing codewords are as follows:&lt;br /&gt;
&lt;br /&gt;
   first byte == 0 through &lt;br /&gt;
                 251 : stop reading, use unsigned value as sizeof packet.  &lt;br /&gt;
   	      	       Note that zero is a valid packet size.&lt;br /&gt;
              == 252 : read a second byte; packet size is the unsigned value&lt;br /&gt;
                       of the second byte + 252.&lt;br /&gt;
              == 253 : read a second byte; packet size is the unsigned value&lt;br /&gt;
                       of the second byte + 508.&lt;br /&gt;
              == 254 : read a second byte; packet size is the unsigned value&lt;br /&gt;
                       of the second byte + 764.&lt;br /&gt;
              == 255 : read a second and third unsigned byte;&lt;br /&gt;
                       If the second byte is &amp;lt;= 251, packet size is&lt;br /&gt;
       	                  (second byte &amp;lt;&amp;lt; 8) + third byte + 1020.&lt;br /&gt;
                       If the second byte == 252, read a third byte.&lt;br /&gt;
                          If the third byte is &amp;lt; 4, packet size is&lt;br /&gt;
                             (second byte &amp;lt;&amp;lt; 8) + third byte + 1020.&lt;br /&gt;
                          If the third byte is &amp;gt;= 4, this indicates the &lt;br /&gt;
                             presence of (third byte) zero-length packets &lt;br /&gt;
                             in sequence.  It is always more efficient to &lt;br /&gt;
                             code more than three zero-length packets in &lt;br /&gt;
                             sequence using the this three-byte signalling, &lt;br /&gt;
                             however muxers MAY use either encoding.  &lt;br /&gt;
                             Demuxers MUST handle both cases.&lt;br /&gt;
                       If the second byte &amp;gt; 252, this indicates a case reserved&lt;br /&gt;
                       for future use; this shall render the page not &lt;br /&gt;
                       decodable.&lt;br /&gt;
&lt;br /&gt;
== V32/64 format ==&lt;br /&gt;
&lt;br /&gt;
V32/64 is a bit-extension format that signals the codeword length using the leading bit (LSbit of the codeword) to indicate if the codeword is 32 or 64 bits. &lt;br /&gt;
&lt;br /&gt;
 inital [low] bit: 0 -&amp;gt; codeword is 32 bits total; &lt;br /&gt;
                        upper 31 bits encode an unsigned value between 0 and 2^31-1&lt;br /&gt;
                   1 -&amp;gt; codeword is 64 bits total; &lt;br /&gt;
                        upper 63 bits encode an unsigned value between 2^31 and 2^63 + 2^31 -1&lt;br /&gt;
&lt;br /&gt;
== V8/16/32 format ==&lt;br /&gt;
&lt;br /&gt;
V8/16/32 is a bit-extension format that signals the codeword length using the leading bit[s] (LSbit[s] of the codeword) to indicate if the codeword is 8, 16 or 32 bits. &lt;br /&gt;
&lt;br /&gt;
 inital [low] bit[s]: 0  -&amp;gt; codeword is 8 bits total; &lt;br /&gt;
                            upper 7 bits encode an unsigned value between 0 and 127 (2^7 - 1)&lt;br /&gt;
                      10 -&amp;gt; codeword is 16 bits total; &lt;br /&gt;
                            upper 15 bits encode an unsigned value between 128 (2^7) and 32895 (2^15 + 2^7 - 1)&lt;br /&gt;
                      11 -&amp;gt; codeword is 32 bits total; &lt;br /&gt;
                            upper 31 bits encode an unsigned value between 32896 (2^15 + 2^7) and 2147516543 (2^31 + 2^15 + 2^7 - 1)&lt;br /&gt;
&lt;br /&gt;
= Syncpoints / Keyframes =&lt;br /&gt;
&lt;br /&gt;
Streams in which not every frame serves as a syncpoint may place only&lt;br /&gt;
one syncpoint (keyframe) packet per page.  The syncpoint packet must&lt;br /&gt;
be the first packet completed on the page (if any).&lt;br /&gt;
&lt;br /&gt;
= More Information =&lt;br /&gt;
&lt;br /&gt;
* [[TransOgg]]: Toplevel transOgg page&lt;/div&gt;</summary>
		<author><name>Mvrable</name></author>
	</entry>
</feed>