From: Ralph Giles Date: Mon, 28 Nov 2005 00:44:24 +0000 (+0000) Subject: Update documentation builds for recent fixes. The pdf version still X-Git-Tag: v1.3.3~440 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=db0da1066d5500769ecd1b9c3363354071e717da;p=platform%2Fupstream%2Flibvorbis.git Update documentation builds for recent fixes. The pdf version still suffers some formatting problems and doesn't build cleanly; I've forced a manual update for now since the text looks reasonably correct. The size difference from the previous build is from not including the in-flux RTP draft. svn path=/trunk/vorbis/; revision=10467 --- diff --git a/doc/Vorbis_I_spec.html b/doc/Vorbis_I_spec.html index da8c73b..4345624 100644 --- a/doc/Vorbis_I_spec.html +++ b/doc/Vorbis_I_spec.html @@ -1,12 +1,12 @@ -Vorbis I specification

Vorbis I specification

Xiph.org Foundation


1. Introduction and Description

+Vorbis I specification

Vorbis I specification

Xiph.org Foundation


1. Introduction and Description

$Id: 01-introduction.xml 7186 2004-07-20 07:19:25Z xiphmont $ -

1.1. Overview

+

1.1. Overview

This document provides a high level description of the Vorbis codec's construction. A bit-by-bit specification appears beginning in Section 4, “Codec Setup and Packet Decode”. The later sections assume a high-level understanding of the Vorbis decode process, which is -provided here.

1.1.1. Application

+provided here.

1.1.1. Application

Vorbis is a general purpose perceptual audio CODEC intended to allow maximum encoder flexibility, thus allowing it to scale competitively over an exceptionally wide range of bitrates. At the high @@ -18,13 +18,13 @@ lower and higher sample rates (from 8kHz telephony to 192kHz digital masters) and a range of channel representations (monaural, polyphonic, stereo, quadraphonic, 5.1, ambisonic, or up to 255 discrete channels). -

1.1.2. Classification

+

1.1.2. Classification

Vorbis I is a forward-adaptive monolithic transform CODEC based on the Modified Discrete Cosine Transform. The codec is structured to allow addition of a hybrid wavelet filterbank in Vorbis II to offer better transient response and reproduction using a transform better suited to localized time events. -

1.1.3. Assumptions

+

1.1.3. Assumptions

The Vorbis CODEC design assumes a complex, psychoacoustically-aware encoder and simple, low-complexity decoder. Vorbis decode is computationally simpler than mp3, although it does require more @@ -56,8 +56,8 @@ examples in this document, we will assume that Vorbis is to be embedded in an Ogg stream specifically, although this is by no means a requirement or fundamental assumption in the Vorbis design.

The specification for embedding Vorbis into -an Ogg transport stream is in Appendix 1, Embedding Vorbis into an Ogg stream. -

1.1.4. Codec Setup and Probability Model

+an Ogg transport stream is in Appendix A, Embedding Vorbis into an Ogg stream. +

1.1.4. Codec Setup and Probability Model

Vorbis' heritage is as a research CODEC and its current design reflects a desire to allow multiple decades of continuous encoder improvement before running out of room within the codec specification. @@ -85,29 +85,29 @@ causes some amount of complaint among engineers as this runs against current design trends (and also points out limitations in some existing software/interface designs, such as Windows' ACM codec framework). However, we find that it does not fundamentally limit -Vorbis' suitable application space.

1.1.5. Format Specification

+Vorbis' suitable application space.

1.1.5. Format Specification

The Vorbis format is well-defined by its decode specification; any encoder that produces packets that are correctly decoded by the reference Vorbis decoder described below may be considered a proper Vorbis encoder. A decoder must faithfully and completely implement the specification defined below (except where noted) to be considered -a proper Vorbis decoder.

1.1.6. Hardware Profile

+a proper Vorbis decoder.

1.1.6. Hardware Profile

Although Vorbis decode is computationally simple, it may still run into specific limitations of an embedded design. For this reason, embedded designs are allowed to deviate in limited ways from the 'full' decode specification yet still be certified compliant. These -optional omissions are labelled in the spec where relevant.

1.2. Decoder Configuration

+optional omissions are labelled in the spec where relevant.

1.2. Decoder Configuration

Decoder setup consists of configuration of multiple, self-contained component abstractions that perform specific functions in the decode pipeline. Each different component instance of a specific type is semantically interchangeable; decoder configuration consists both of internal component configuration, as well as arrangement of specific instances into a decode pipeline. Componentry arrangement is roughly -as follows:

decoder pipeline configuration

1.2.1. Global Config

+as follows:

decoder pipeline configuration

1.2.1. Global Config

Global codec configuration consists of a few audio related fields (sample rate, channels), Vorbis version (always '0' in Vorbis I), bitrate hints, and the lists of component instances. All other -configuration is in the context of specific components.

1.2.2. Mode

+configuration is in the context of specific components.

1.2.2. Mode

Each Vorbis frame is coded according to a master 'mode'. A bitstream may use one or many modes.

The mode mechanism is used to encode a frame according to one of @@ -120,7 +120,7 @@ A 'mode' configuration consists of a frame size setting, window type (always 0, the Vorbis window, in Vorbis I), transform type (always type 0, the MDCT, in Vorbis I) and a mapping number. The mapping number specifies which mapping configuration instance to use for -low-level packet decode and synthesis.

1.2.3. Mapping

+low-level packet decode and synthesis.

1.2.3. Mapping

A mapping contains a channel coupling description and a list of 'submaps' that bundle sets of channel vectors together for grouped encoding and decoding. These submaps are not references to external @@ -141,7 +141,7 @@ apply a full range floor and residue encoding to channels 0 through 4, and a bass-only representation to the bass channel, thus saving space. In this example, channels 0-4 belong to submap 0 (which indicates use of a full-range floor) and channel 5 belongs to submap 1, which uses a -bass-only representation.

1.2.4. Floor

+bass-only representation.

1.2.4. Floor

Vorbis encodes a spectral 'floor' vector for each PCM channel. This vector is a low-resolution representation of the audio spectrum for the given channel in the current frame, generally used akin to a @@ -165,7 +165,7 @@ make use of entropy coding to save space. For this reason, a floor configuration generally refers to multiple codebooks in the codebook component list. Entropy coding is thus provided as an abstraction, and each floor instance may choose from any and all available -codebooks when coding/decoding.

1.2.5. Residue

+codebooks when coding/decoding.

1.2.5. Residue

The spectral residue is the fine structure of the audio spectrum once the floor curve has been subtracted out. In simplest terms, it is coded in the bitstream using cascaded (multi-pass) vector @@ -174,7 +174,7 @@ algorithms numbered 0 through 2. The packing algorithm details are configured by residue instance. As with the floor components, the final VQ/entropy encoding is provided by external codebook instances and each residue instance may choose from any and all available -codebooks.

1.2.6. Codebooks

+codebooks.

1.2.6. Codebooks

Codebooks are a self-contained abstraction that perform entropy decoding and, optionally, use the entropy-decoded integer value as an offset into an index of output value vectors, returning the indicated @@ -186,7 +186,7 @@ ordered or unordered, or the tree is sparse.

The codebook vector index is similarly packed according to index characteristic. Most commonly, the vector index is encoded as a single list of values of possible values that are then permuted into -a list of n-dimensional rows (lattice VQ).

1.3. High-level Decode Process

1.3.1. Decode Setup

+a list of n-dimensional rows (lattice VQ).

1.3. High-level Decode Process

1.3.1. Decode Setup

Before decoding can begin, a decoder must initialize using the bitstream headers matching the stream to be decoded. Vorbis uses three header packets; all are required, in-order, by this @@ -194,16 +194,16 @@ specification. Once set up, decode may begin at any audio packet belonging to the Vorbis stream. In Vorbis I, all packets after the three initial headers are audio packets.

The header packets are, in order, the identification -header, the comments header, and the setup header.

1.3.1.1. Identification Header

+header, the comments header, and the setup header.

1.3.1.1. Identification Header

The identification header identifies the bitstream as Vorbis, Vorbis version, and the simple audio characteristics of the stream such as -sample rate and number of channels.

1.3.1.2. Comment Header

+sample rate and number of channels.

1.3.1.2. Comment Header

The comment header includes user text comments ("tags") and a vendor string for the application/library that produced the bitstream. The encoding and proper use of the comment header is described in -Section 5, “comment field and header specification”.

1.3.1.3. Setup Header

The setup header includes extensive CODEC setup information as well as -the complete VQ and Huffman codebooks needed for decode.

1.3.2. Decode Procedure

+the complete VQ and Huffman codebooks needed for decode.

1.3.2. Decode Procedure

The decoding and synthesis procedure for all audio packets is fundamentally the same.

  1. decode packet type flag
  2. decode mode number
  3. decode window shape (long windows only)
  4. decode floor
  5. decode residue into residue vectors
  6. inverse channel coupling of residue vectors
  7. generate floor curve from decoded floor data
  8. compute dot product of floor and residue, producing audio spectrum vector
  9. inverse monolithic transform of audio spectrum vector, always an MDCT in Vorbis I
  10. overlap/add left-hand output of transform with right-hand output of previous frame
  11. store right hand-data from transform of current frame for future lapping
  12. if not first frame, return results of overlap/add as audio result of current frame

@@ -215,7 +215,7 @@ MDCT to store the right-hand transform data of a partial MDCT for a later before overlap/add with the next frame. This optimization produces entirely equivalent output and is naturally perfectly legal. The decoder must be entirely mathematically equivalent to the -specification, it need not be a literal semantic implementation.

1.3.2.1. Packet type decode

+specification, it need not be a literal semantic implementation.

1.3.2.1. Packet type decode

Vorbis I uses four packet types. The first three packet types mark each of the three Vorbis headers described above. The fourth packet type marks an audio packet. All other packet types are reserved; packets @@ -225,7 +225,7 @@ are audio. The first step of audio packet decode is to read and verify the packet type; a non-audio packet when audio is expected indicates stream corruption or a non-compliant stream. The decoder must ignore the packet and not attempt decoding it to -audio.

1.3.2.2. Mode decode

+audio.

1.3.2.2. Mode decode

Vorbis allows an encoder to set up multiple, numbered packet 'modes', as described earlier, all of which may be used in a given Vorbis stream. The mode is encoded as an integer used as a direct offset into @@ -262,10 +262,10 @@ The use of multirate filter banks for coding of high quality digital audio”, by T. Sporer, K. Brandenburg and B. Edler. Vorbis windows all use the slope function . -

1.3.2.4. floor decode

+

1.3.2.4. floor decode

Each floor is encoded/decoded in channel order, however each floor belongs to a 'submap' that specifies which floor configuration to -use. All floors are decoded before residue decode begins.

1.3.2.5. residue decode

+use. All floors are decoded before residue decode begins.

1.3.2.5. residue decode

Although the number of residue vectors equals the number of channels, channel coupling may mean that the raw residue vectors extracted during decode do not map directly to specific channels. When channel @@ -275,7 +275,7 @@ and may differ from frame to frame, due to different mode numbers.

Vorbis codes residue vectors in groups by submap; the coding is done in submap order from submap 0 through n-1. This differs from floors which are coded using a configuration provided by submap number, but -are coded individually in channel order.

1.3.2.6. inverse channel coupling

+are coded individually in channel order.

1.3.2.6. inverse channel coupling

A detailed discussion of stereo in the Vorbis codec can be found in the document Stereo Channel Coupling in the Vorbis CODEC. Vorbis is not limited to only stereo coupling, but @@ -289,7 +289,7 @@ polar representation (where one vector is magnitude and the second angle) back to Cartesian representation.

After decoupling, in order, each pair of vectors on the coupling list, the resulting residue vectors represent the fine spectral detail -of each output channel.

1.3.2.7. generate floor curve

+of each output channel.

1.3.2.7. generate floor curve

The decoder may choose to generate the floor curve at any appropriate time. It is reasonable to generate the output curve when the floor data is decoded from the raw packet, or it can be generated after @@ -298,7 +298,7 @@ combining generation and the dot product into one step and eliminating some working space.

Both floor 0 and floor 1 generate a linear-range, linear-domain output vector to be multiplied (dot product) by the linear-range, -linear-domain spectral residue.

1.3.2.8. compute floor/residue dot product

+linear-domain spectral residue.

1.3.2.8. compute floor/residue dot product

This step is straightforward; for each output channel, the decoder multiplies the floor curve and residue vectors element by element, producing the finished audio spectrum of each channel.

@@ -321,7 +321,7 @@ residue vector must be able to represent a 48 bit range and the dot product must be able to handle an effective 48 bit times 24 bit multiplication. This range may be achieved using large (64 bit or larger) integers, or implementing a movable binary point -representation.

1.3.2.9. inverse monolithic transform (MDCT)

+representation.

1.3.2.9. inverse monolithic transform (MDCT)

The audio spectrum is converted back into time domain PCM audio via an inverse Modified Discrete Cosine Transform (MDCT). A detailed description of the MDCT is available in the paper The use of multirate filter banks for coding of high quality digital @@ -329,16 +329,16 @@ audio, by T. Sporer, K. Brandenburg and B. Edler.

Note that the PCM produced directly from the MDCT is not yet finished audio; it must be lapped with surrounding frames using an appropriate window (such as the Vorbis window) before the MDCT can be considered -orthogonal.

1.3.2.10. overlap/add data

+orthogonal.

1.3.2.10. overlap/add data

Windowed MDCT output is overlapped and added with the right hand data of the previous window such that the 3/4 point of the previous window is aligned with the 1/4 point of the current window (as illustrated in the window overlap diagram). At this point, the audio data between the center of the previous frame and the center of the current frame is -now finished and ready to be returned.

1.3.2.11. cache right hand data

+now finished and ready to be returned.

1.3.2.11. cache right hand data

The decoder must cache the right hand portion of the current frame to be lapped with the left hand portion of the next frame. -

1.3.2.12. return finished audio data

+

1.3.2.12. return finished audio data

The overlapped portion produced from overlapping the previous and current frame data is finished data to be returned by the decoder. This data spans from the center of the previous window to the center @@ -360,7 +360,7 @@ the decode engine. The encoder accounts for this priming when calculating PCM offsets; after the first frame, the proper PCM output offset is '0' (as no data has been returned yet).

2. Bitpacking Convention

$Id: 02-bitpacking.xml 7186 2004-07-20 07:19:25Z xiphmont $ -

2.1. Overview

+

2.1. Overview

The Vorbis codec uses relatively unstructured raw packets containing arbitrary-width binary integer fields. Logically, these packets are a bitstream in which bits are coded one-by-one by the encoder and then @@ -370,7 +370,7 @@ native word size of eight bits (octets), sixteen bits, thirty-two bits or, less commonly other fixed word sizes. The Vorbis bitpacking convention specifies the correct mapping of the logical packet bitstream into an actual representation in fixed-width words. -

2.1.1. octets, bytes and words

+

2.1.1. octets, bytes and words

In most contemporary architectures, a 'byte' is synonymous with an 'octet', that is, eight bits. This has not always been the case; seven, ten, eleven and sixteen bit 'bytes' have been used. For @@ -386,13 +386,13 @@ octet (eight bits) and a word to be a group of two, four or eight bytes (16, 32 or 64 bits). Note however that the Vorbis bitpacking convention is still well defined for any native byte size; Vorbis uses the native bit-width of a given storage system. This document assumes -that a byte is one octet for purposes of example.

2.1.2. bit order

+that a byte is one octet for purposes of example.

2.1.2. bit order

A byte has a well-defined 'least significant' bit (LSb), which is the only bit set when the byte is storing the two's complement integer value +1. A byte's 'most significant' bit (MSb) is at the opposite end of the byte. Bits in a byte are numbered from zero at the LSb to n (n=7 in an octet) for the -MSb.

2.1.3. byte order

+MSb.

2.1.3. byte order

Words are native groupings of multiple bytes. Several byte orderings are possible in a word; the common ones are 3-2-1-0 ('big endian' or 'most significant byte first' in which the highest-valued byte comes @@ -404,7 +404,7 @@ manipulation at the byte, not word, level, thus host word ordering is of a concern only during optimization when writing high performance code that operates on a word of storage at a time rather than by byte. Logically, bytes are always coded and decoded in order from byte zero -through byte n.

2.1.4. coding bits into byte sequences

+through byte n.

2.1.4. coding bits into byte sequences

The Vorbis codec has need to code arbitrary bit-width integers, from zero to 32 bits wide, into packets. These integer fields are not aligned to the boundaries of the byte representation; the next field @@ -420,13 +420,13 @@ the requested number of bits. When all bits of the destination byte have been filled, encoding continues by zeroing all bits of the next byte and writing the next bit into the bit position 0 of that byte. Decoding follows the same process as encoding, but by reading bits -from the byte stream and reassembling them into integers.

2.1.5. signedness

+from the byte stream and reassembling them into integers.

2.1.5. signedness

The signedness of a specific number resulting from decode is to be interpreted by the decoder given decode context. That is, the three bit binary pattern 'b111' can be taken to represent either 'seven' as an unsigned integer, or '-1' as a signed, two's complement integer. The encoder and decoder are responsible for knowing if fields are to -be treated as signed or unsigned.

2.1.6. coding example

+be treated as signed or unsigned.

2.1.6. coding example

Code the 4 bit integer value '12' [b1100] into an empty bytestream. Bytestream result: @@ -490,7 +490,7 @@ byte 3 [0 0 0 0 0 1 1 0] <- byte n [ ] bytestream length == 4 bytes

-

2.1.7. decoding example

+

2.1.7. decoding example

Reading from the beginning of the bytestream encoded in the above example:

@@ -515,7 +515,7 @@ boundaries maintained in the bitstream.

  • The second value is the two-bit-wide integer 'b11'. This value may be interpreted either as the unsigned value '3', or the signed value '-1'. Signedness is dependent on decode context.

  • -

    2.1.8. end-of-packet alignment

    +

    2.1.8. end-of-packet alignment

    The typical use of bitpacking is to produce many independent byte-aligned packets which are embedded into a larger byte-aligned container structure, such as an Ogg transport bitstream. Externally, @@ -533,7 +533,7 @@ remaining data to fulfill the desired read size. Vorbis uses truncated packets as a normal mode of operation, and as such, decoders must handle reading past the end of a packet as a typical mode of operation. Any further read operations after an 'end-of-packet' -condition shall also return 'end-of-packet'.

    2.1.9.  reading zero bits

    +condition shall also return 'end-of-packet'.

    2.1.9.  reading zero bits

    Reading a zero-bit-wide integer returns the value '0' and does not increment the stream cursor. Reading to the end of the packet (but not past, such that an 'end-of-packet' condition has not triggered) @@ -542,7 +542,7 @@ not trigger an end-of-packet condition. Reading a zero-bit-wide integer after a previous read sets 'end-of-packet' shall also fail with 'end-of-packet'.

    3. Probability Model and Codebooks

    $Id: 03-codebook.xml 7186 2004-07-20 07:19:25Z xiphmont $ -

    3.1. Overview

    +

    3.1. Overview

    Unlike practically every other mainstream audio codec, Vorbis has no statically configured probability model, instead packing all entropy decoding configuration, VQ and Huffman, into the bitstream itself in @@ -551,15 +551,15 @@ consists of multiple 'codebooks', each containing a specific Huffman-equivalent representation for decoding compressed codewords as well as an optional lookup table of output vector values to which a decoded Huffman value is applied as an offset, generating the final -decoded output corresponding to a given compressed codeword.

    3.1.1. Bitwise operation

    +decoded output corresponding to a given compressed codeword.

    3.1.1. Bitwise operation

    The codebook mechanism is built on top of the vorbis bitpacker. Both the codebooks themselves and the codewords they decode are unrolled from a packet as a series of arbitrary-width values read from the -stream according to Section 2, “Bitpacking Convention”.

    3.2. Packed codebook format

    +stream according to Section 2, “Bitpacking Convention”.

    3.2. Packed codebook format

    For purposes of the examples below, we assume that the storage system's native byte width is eight bits. This is not universally true; see Section 2, “Bitpacking Convention” for discussion -relating to non-eight-bit bytes.

    3.2.1. codebook decode

    +relating to non-eight-bit bytes.

    3.2.1. codebook decode

    A codebook begins with a 24 bit sync pattern, 0x564342:

    @@ -689,7 +689,7 @@ and indicates a stream that is not decodable by the specification in this
     document.

    An 'end of packet' during any read operation in the above steps is -considered an error condition rendering the stream undecodable.

    3.2.1.1. Huffman decision tree representation

    +considered an error condition rendering the stream undecodable.

    3.2.1.1. Huffman decision tree representation

    The [codebook_codeword_lengths] array and [codebook_entries] value uniquely define the Huffman decision tree used for entropy decoding.

    @@ -747,7 +747,7 @@ undecodable.

    Codebook entries marked 'unused' are simply skipped in the assigning process. They have no codeword and do not appear in the decision tree, thus it's impossible for any bit pattern read from the stream to -decode to that entry number.

    3.2.1.2. VQ lookup table vector representation

    +decode to that entry number.

    3.2.1.2. VQ lookup table vector representation

    Unpacking the VQ lookup table vectors relies on the following values:

     the [codebook_multiplicands] array
    @@ -763,7 +763,7 @@ the [codebook_multiplicands] array
     Decoding (unpacking) a specific vector in the vector lookup table
     proceeds according to [codebook_lookup_type].  The unpacked
     vector values are what a codebook would return during audio packet
    -decode in a VQ context.

    3.2.1.2.1. Vector value decode: Lookup type 1

    +decode in a VQ context.

    3.2.1.2.1. Vector value decode: Lookup type 1

    Lookup type one specifies a lattice VQ lookup table built algorithmically from a list of scalar values. Calculate (unpack) the final values of a codebook entry vector from the entries in @@ -790,7 +790,7 @@ is the output vector representing the vector of values for entry number } 8) vector calculation completed. -

    3.2.1.2.2. Vector value decode: Lookup type 2

    +

    3.2.1.2.2. Vector value decode: Lookup type 2

    Lookup type two specifies a VQ lookup table in which each scalar in each vector is explicitly set by the [codebook_multiplicands] array in a one-to-one mapping. Calculate [unpack] the @@ -815,7 +815,7 @@ is the output vector representing the vector of values for entry number } 7) vector calculation completed. -

    3.3. Use of the codebook abstraction

    +

    3.3. Use of the codebook abstraction

    The decoder uses the codebook abstraction much as it does the bit-unpacking convention; a specific codebook reads a codeword from the bitstream, decoding it into an entry number, and then @@ -847,19 +847,19 @@ desired return value.

    When used in a VQ context, the codeword entry number is used as an offset into the VQ lookup table. The value returned to the decoder is the vector of scalars corresponding to this offset.

    4. Codec Setup and Packet Decode

    - $Id: 04-codec.xml 7186 2004-07-20 07:19:25Z xiphmont $ -

    4.1. Overview

    + $Id: 04-codec.xml 10466 2005-11-28 00:34:44Z giles $ +

    4.1. Overview

    This document serves as the top-level reference document for the bit-by-bit decode specification of Vorbis I. This document assumes a high-level understanding of the Vorbis decode process, which is provided in Section 1, “Introduction and Description”. Section 2, “Bitpacking Convention” covers reading and writing bit fields from -and to bitstream packets.

    4.2. Header decode and decode setup

    +and to bitstream packets.

    4.2. Header decode and decode setup

    A Vorbis bitstream begins with three header packets. The header packets are, in order, the identification header, the comments header, and the setup header. All are required for decode compliance. An end-of-packet condition during decoding the first or third header packet renders the stream undecodable. End-of-packet decoding the -comment header is a non-fatal error condition.

    4.2.1. Common header decode

    +comment header is a non-fatal error condition.

    4.2.1. Common header decode

    Each header packet begins with the same header fields.

       1) [packet_type] : 8 bit value
    @@ -869,7 +869,7 @@ Decode continues according to packet type; the identification header
     is type 1, the comment header type 3 and the setup header type 5
     (these types are all odd as a packet with a leading single bit of '0'
     is an audio packet).  The packets must occur in the order of
    -identification, comment, setup.

    4.2.2. Identification header

    +identification, comment, setup.

    4.2.2. Identification header

    The identification header is a short header of only a few fields used to declare the stream definitively as Vorbis, and provide a few externally relevant pieces of information about the audio stream. The @@ -893,9 +893,11 @@ Vorbis I. [blocksize_0] must be less than or equal meet any of these conditions renders a stream undecodable.

    The bitrate fields above are used only as hints. The nominal bitrate field especially may be considerably off in purely VBR streams. The -fields are meaningful only when greater than zero.

    • All three fields set to the same value implies a fixed rate, or tightly bounded, nearly fixed-rate bitstream
    • Only nominal set implies a VBR or ABR stream that averages the nominal bitrate
    • Maximum and or minimum set implies a VBR bitstream that obeys the bitrate limits
    • None set indicates the encoder does not care to speculate.

    4.2.3. Comment header

    +fields are meaningful only when greater than zero.

    +

    • All three fields set to the same value implies a fixed rate, or tightly bounded, nearly fixed-rate bitstream
    • Only nominal set implies a VBR or ABR stream that averages the nominal bitrate
    • Maximum and or minimum set implies a VBR bitstream that obeys the bitrate limits
    • None set indicates the encoder does not care to speculate.

    +

    4.2.3. Comment header

    Comment header decode and data specification is covered in -Section 5, “comment field and header specification”.

    4.2.4. Setup header

    Vorbis codec setup is configurable to an extreme degree:

    [decoder pipeline configuration]

    @@ -906,13 +908,13 @@ codebook configurations, time-domain transform configurations (placeholders in Vorbis I), floor configurations, residue configurations, channel mapping configurations and mode configurations. It finishes with a framing bit of '1'. Header decode -proceeds in the following order:

    4.2.4.1. Codebooks
    1. [vorbis_codebook_count] = read eight bits as unsigned integer and add one
    2. Decode [vorbis_codebook_count] codebooks in order as defined +proceeds in the following order:

      4.2.4.1. Codebooks
      1. [vorbis_codebook_count] = read eight bits as unsigned integer and add one
      2. Decode [vorbis_codebook_count] codebooks in order as defined in Section 3, “Probability Model and Codebooks”. Save each configuration, in order, in an array of -codebook configurations [vorbis_codebook_configurations].
      4.2.4.2. Time domain transforms

      +codebook configurations [vorbis_codebook_configurations].

    4.2.4.2. Time domain transforms

    These hooks are placeholders in Vorbis I. Nevertheless, the configuration placeholder values must be read to maintain bitstream -sync.

    1. [vorbis_time_count] = read 6 bits as unsigned integer and add one
    2. read [vorbis_time_count] 16 bit values; each value should be zero. If any value is nonzero, this is an error condition and the stream is undecodable.
    4.2.4.3. Floors

    +sync.

    1. [vorbis_time_count] = read 6 bits as unsigned integer and add one
    2. read [vorbis_time_count] 16 bit values; each value should be zero. If any value is nonzero, this is an error condition and the stream is undecodable.
    4.2.4.3. Floors

    Vorbis uses two floor types; header decode is handed to the decode abstraction of the appropriate type.

    1. [vorbis_floor_count] = read 6 bits as unsigned integer and add one
    2. For each [i] of [vorbis_floor_count] floor numbers:

      1. read the floor type: vector [vorbis_floor_types] element [i] = @@ -921,13 +923,13 @@ configuration as defined in [i] of the floor configuration array [vorbis_floor_configurations].
      2. If the floor type is one, decode the floor configuration as defined in Section 7, “Floor type 1 setup and decode”; save this configuration in slot [i] of the floor configuration array [vorbis_floor_configurations].
      3. If the the floor type is greater than one, this stream is undecodable; ERROR CONDITION

      -

    4.2.4.4. Residues

    +

    4.2.4.4. Residues

    Vorbis uses three residue types; header decode of each type is identical.

    1. [vorbis_residue_count] = read 6 bits as unsigned integer and add one
    2. For each of [vorbis_residue_count] residue numbers:

      1. read the residue type; vector [vorbis_residue_types] element [i] = read 16 bits as unsigned integer
      2. If the residue type is zero, one or two, decode the residue configuration as defined in Section 8, “Residue setup and decode”; save this configuration in slot [i] of the residue configuration array [vorbis_residue_configurations].
      3. If the the residue type is greater than two, this stream is undecodable; ERROR CONDITION

      -

    4.2.4.5. Mappings

    +

    4.2.4.5. Mappings

    Mappings are used to set up specific pipelines for encoding multichannel audio with varying channel mapping applications. Vorbis I uses a single mapping type (0), with implicit PCM channel mappings.

    1. [vorbis_mapping_count] = read 6 bits as unsigned integer and add one
    2. For each [i] of [vorbis_mapping_count] mapping numbers: @@ -941,19 +943,19 @@ uses a single mapping type (0), with implicit PCM channel mappings.

  • if unset, [vorbis_mapping_coupling_steps] = 0
  • read 2 bits (reserved field); if the value is nonzero, the stream is undecodable
  • if [vorbis_mapping_submaps] is greater than one, we read channel multiplex settings. For each [j] of [audio_channels] channels:

    1. vector [vorbis_mapping_mux] element [j] = read 4 bits as unsigned integer
    2. if the value is greater than the highest numbered submap ([vorbis_mapping_submaps] - 1), this in an error condition rendering the stream undecodable
  • for each submap [j] of [vorbis_mapping_submaps] submaps, read the floor and residue numbers for use in decoding that submap:

    1. read and discard 8 bits (the unused time configuration placeholder)
    2. read 8 bits as unsigned integer for the floor number; save in vector [vorbis_mapping_submap_floor] element [j]
    3. verify the floor number is not greater than the highest number floor configured for the bitstream. If it is, the bitstream is undecodable
    4. read 8 bits as unsigned integer for the residue number; save in vector [vorbis_mapping_submap_residue] element [j]
    5. verify the residue number is not greater than the highest number residue configured for the bitstream. If it is, the bitstream is undecodable
  • save this mapping configuration in slot [i] of the mapping configuration array [vorbis_mapping_configurations].
  • -

    4.2.4.6. Modes
    1. [vorbis_mode_count] = read 6 bits as unsigned integer and add one
    2. For each of [vorbis_mode_count] mode numbers:

      1. [vorbis_mode_blockflag] = read 1 bit
      2. [vorbis_mode_windowtype] = read 16 bits as unsigned integer
      3. [vorbis_mode_transformtype] = read 16 bits as unsigned integer
      4. [vorbis_mode_mapping] = read 8 bits as unsigned integer
      5. verify ranges; zero is the only legal value in Vorbis I for +

    4.2.4.6. Modes
    1. [vorbis_mode_count] = read 6 bits as unsigned integer and add one
    2. For each of [vorbis_mode_count] mode numbers:

      1. [vorbis_mode_blockflag] = read 1 bit
      2. [vorbis_mode_windowtype] = read 16 bits as unsigned integer
      3. [vorbis_mode_transformtype] = read 16 bits as unsigned integer
      4. [vorbis_mode_mapping] = read 8 bits as unsigned integer
      5. verify ranges; zero is the only legal value in Vorbis I for [vorbis_mode_windowtype] and [vorbis_mode_transformtype]. [vorbis_mode_mapping] must not be greater than the highest number mapping in use. Any illegal values render the stream undecodable.
      6. save this mode configuration in slot [i] of the mode configuration array [vorbis_mode_configurations].
    3. read 1 bit as a framing flag. If unset, a framing error occurred and the stream is not decodable.

    After reading mode descriptions, setup header decode is complete. -

    4.3. Audio packet decode and synthesis

    +

    4.3. Audio packet decode and synthesis

    Following the three header packets, all packets in a Vorbis I stream are audio. The first step of audio packet decode is to read and verify the packet type. A non-audio packet when audio is expected indicates stream corruption or a non-compliant stream. The decoder must ignore the packet and not attempt decoding it to audio. -

    4.3.1. packet type, mode and window decode

    1. read 1 bit [packet_type]; check that packet type is 0 (audio)
    2. read ilog([vorbis_mode_count]-1) bits +

      4.3.1. packet type, mode and window decode

      1. read 1 bit [packet_type]; check that packet type is 0 (audio)
      2. read ilog([vorbis_mode_count]-1) bits [mode_number]
      3. decode blocksize [n] is equal to [blocksize_0] if [vorbis_mode_blockflag] is 0, else [n] is equal to [blocksize_1].
      4. perform window selection and setup; this window is used later by the inverse MDCT:

        1. if this is a long window (the [vorbis_mode_blockflag] flag of this mode is set):

          1. read 1 bit for [previous_window_flag]
          2. read 1 bit for [next_window_flag]
          3. if [previous_window_flag] is not set, the left half @@ -989,7 +991,7 @@ zero

          An end-of-packet condition up to this point should be considered an error that discards this packet from the stream. An end of packet condition past this point is to be considered a possible nominal -occurrence.

        4.3.2. floor curve decode

        +occurrence.

        4.3.2. floor curve decode

        From this point on, we assume out decode context is using mode number [mode_number] from configuration array [vorbis_mode_configurations] and the map number @@ -1011,7 +1013,7 @@ false

      An end-of-packet condition during floor decode shall result in packet decode zeroing all channel output vectors and skipping to the -add/overlap output stage.

      4.3.3. nonzero vector propagate

      +add/overlap output stage.

      4.3.3. nonzero vector propagate

      A possible result of floor decode is that a specific vector is marked 'unused' which indicates that that final output vector is all-zero values (and the floor is zero). The residue for that vector is not @@ -1027,13 +1029,13 @@ or channel are set to false, then both must be set to false. Note that an 'unused' floor has no decoded floor information; it is important that this is remembered at floor curve synthesis time.

    -

    4.3.4. residue decode

    +

    4.3.4. residue decode

    Unlike floors, which are decoded in channel order, the residue vectors are decoded in submap order.

    for each submap [i] in order from 0 ... [vorbis_mapping_submaps]-1

    1. [ch] = 0
    2. for each channel [j] in order from 0 ... [audio_channels] - 1

      1. if channel [j] in submap [i] (vector [vorbis_mapping_mux] element [j] is equal to [i])

        1. if vector [no_residue] element [j] is true

          1. vector [do_not_decode_flag] element [ch] is set

          else -

          1. vector [do_not_decode_flag] element [ch] is unset
        2. increment [ch]
    3. [residue_number] = vector [vorbis_mapping_submap_residue] element [i]
    4. [residue_type] = vector [vorbis_residue_types] element [residue_number]
    5. decode [ch] vectors using residue [residue_number], according to type [residue_type], also passing vector [do_not_decode_flag] to indicate which vectors in the bundle should not be decoded. Correct per-vector decode length is [n]/2.
    6. [ch] = 0
    7. for each channel [j] in order from 0 ... [audio_channels]

      1. if channel [j] is in submap [i] (vector [vorbis_mapping_mux] element [j] is equal to [i])

        1. residue vector for channel [j] is set to decoded residue vector [ch]
        2. increment [ch]

    4.3.5. inverse coupling

    +

    1. vector [do_not_decode_flag] element [ch] is unset
  • increment [ch]
  • [residue_number] = vector [vorbis_mapping_submap_residue] element [i]
  • [residue_type] = vector [vorbis_residue_types] element [residue_number]
  • decode [ch] vectors using residue [residue_number], according to type [residue_type], also passing vector [do_not_decode_flag] to indicate which vectors in the bundle should not be decoded. Correct per-vector decode length is [n]/2.
  • [ch] = 0
  • for each channel [j] in order from 0 ... [audio_channels]

    1. if channel [j] is in submap [i] (vector [vorbis_mapping_mux] element [j] is equal to [i])

      1. residue vector for channel [j] is set to decoded residue vector [ch]
      2. increment [ch]
  • 4.3.5. inverse coupling

    for each [i] from [vorbis_mapping_coupling_steps]-1 descending to 0

    1. [magnitude_vector] = the residue vector for channel @@ -1051,7 +1053,7 @@ for each [i] from [vorbis_map

      1. [new_A] = [M]
      2. [new_M] = [M]-[A]

  • set scalar value [M] in vector [magnitude_vector] to [new_M]
  • set scalar value [A] in vector [angle_vector] to [new_A]
  • -

    4.3.6. dot product

    +

    4.3.6. dot product

    For each channel, synthesize the floor curve from the decoded floor information, according to packet type. Note that the vector synthesis length for floor computation is [n]/2.

    @@ -1079,14 +1081,14 @@ residue vector must be able to represent a 48 bit range and the dot product must be able to handle an effective 48 bit times 24 bit multiplication. This range may be achieved using large (64 bit or larger) integers, or implementing a movable binary point -representation.

    4.3.7. inverse MDCT

    +representation.

    4.3.7. inverse MDCT

    Convert the audio spectrum vector of each channel back into time domain PCM audio via an inverse Modified Discrete Cosine Transform (MDCT). A detailed description of the MDCT is available in the paper The use of multirate filter banks for coding of high quality digital audio, by T. Sporer, K. Brandenburg and B. Edler. The window -function used for the MDCT is the function described earlier.

    4.3.8. overlap_add

    +function used for the MDCT is the function described earlier.

    4.3.8. overlap_add

    Windowed MDCT output is overlapped and added with the right hand data of the previous window such that the 3/4 point of the previous window is aligned with the 1/4 point of the current window (as illustrated in @@ -1110,7 +1112,7 @@ center (element windowsize/2-1, inclusive) of the current window.

    Data is not returned from the first frame; it must be used to 'prime' the decode engine. The encoder accounts for this priming when calculating PCM offsets; after the first frame, the proper PCM output -offset is '0' (as no data has been returned yet).

    4.3.9. output channel order

    +offset is '0' (as no data has been returned yet).

    4.3.9. output channel order

    Vorbis I specifies only a channel mapping type 0. In mapping type 0, channel mapping is implicitly defined as follows for standard audio applications:

    one channel
    the stream is monophonic
    two channels
    the stream is stereo. channel order: left, right
    three channels
    the stream is a 1d-surround encoding. channel order: left, @@ -1122,8 +1124,8 @@ Applications using Vorbis for dedicated purposes may define channel mapping as seen fit. Future channel mappings (such as three and four channel Ambisonics) will make use of channel mappings other than mapping 0.

    5. comment field and header specification

    - $Id: 05-comment.xml 7186 2004-07-20 07:19:25Z xiphmont $ -

    5.1. Overview

    The Vorbis text comment header is the second (of three) header + $Id: 05-comment.xml 10465 2005-11-28 00:33:05Z giles $ +

    5.1. Overview

    The Vorbis text comment header is the second (of three) header packets that begin a Vorbis bitstream. It is meant for short text comments, not arbitrary metadata; arbitrary metadata belongs in a separate logical bitstream (usually an XML stream type) that provides @@ -1136,14 +1138,14 @@ they turn out to be, eg:

    Honest Bob and the Factory-to-Dealer-Incentives, I'm Still Around, opening for Moxy Früvous, 1997.

    -

    5.2. Comment encoding

    5.2.1. Structure

    +

    5.2. Comment encoding

    5.2.1. Structure

    The comment header is logically a list of eight-bit-clean vectors; the number of vectors is bounded to 2^32-1 and the length of each vector is limited to 2^32-1 bytes. The vector length is encoded; the vector contents themselves are not null terminated. In addition to the vector list, there is a single vector for vendor name (also 8 bit clean, -length encoded in 32 bits). The 1.0 release of libvorbis sets the -vendor string to "Xiph.Org libVorbis I 20020717".

    The comment header is decoded as follows: +length encoded in 32 bits). For example, the 1.0 release of libvorbis +set the vendor string to "Xiph.Org libVorbis I 20020717".

    The comment header is decoded as follows:

       1) [vendor_length] = read an unsigned integer of 32 bits
    @@ -1157,7 +1159,7 @@ vendor string to "Xiph.Org libVorbis I 20020717".

    The comment header is de 8) if ( [framing_bit] unset or end-of-packet ) then ERROR 9) done.

    -

    5.2.2. Content vector format

    +

    5.2.2. Content vector format

    The comment vectors are structured similarly to a UNIX environment variable. That is, comment fields consist of a field name and a corresponding value and look like:

    @@ -1174,7 +1176,7 @@ this equals sign is used to terminate the field name.
     

    0x3D is followed by 8 bit clean UTF-8 encoded value of the field contents to the end of the field. -

    5.2.2.1. Field names

    Below is a proposed, minimal list of standard field names with a +

    5.2.2.1. Field names

    Below is a proposed, minimal list of standard field names with a description of intended use. No single or group of field names is mandatory; a comment header may contain one, all or none of the names in this list.

    TITLE
    Track/Work name
    VERSION
    The version field may be used to @@ -1202,7 +1204,7 @@ the 'record label')
    ISRC
    International Standard Recording Code for the track; see the ISRC intro page for more information on ISRC numbers. -
    5.2.2.2. Implications

    Field names should not be 'internationalized'; this is a +

    5.2.2.2. Implications

    Field names should not be 'internationalized'; this is a concession to simplicity not an attempt to exclude the majority of the world that doesn't speak English. Field contents however, use the UTF-8 character encoding to allow easy representation of any @@ -1223,7 +1225,7 @@ ARTIST=Sonny Rollins ARTIST=Sonny Stitt

    -

    5.2.3. Encoding

    +

    5.2.3. Encoding

    The comment header comprises the entirety of the second bitstream header packet. Unlike the first bitstream header packet, it is not generally the only packet on the second page and may not be restricted @@ -1252,18 +1254,18 @@ bitstream octet first):

    This is actually somewhat easier to describe in code; implementation of the above can be found in vorbis/lib/info.c, _vorbis_pack_comment() and _vorbis_unpack_comment().

    6. Floor type 0 setup and decode

    - $Id: 06-floor0.xml 8547 2004-12-29 03:33:51Z giles $ -

    6.1. Overview

    + $Id: 06-floor0.xml 10424 2005-11-23 08:44:18Z xiphmont $ +

    6.1. Overview

    Vorbis floor type zero uses Line Spectral Pair (LSP, also alternately known as Line Spectral Frequency or LSF) representation to encode a smooth spectral envelope curve as the frequency response of the LSP filter. This representation is equivalent to a traditional all-pole infinite impulse response filter as would be used in linear predictive coding; LSP representation may be converted to LPC representation and -vice-versa.

    6.2. Floor 0 format

    +vice-versa.

    6.2. Floor 0 format

    Floor zero configuration consists of six integer fields and a list of VQ codebooks for use in coding/decoding the LSP filter coefficient -values used by each frame.

    6.2.1. header decode

    +values used by each frame.

    6.2.1. header decode

    Configuration information for instances of floor zero decodes from the codec setup header (third packet). configuration decode proceeds as follows:

    @@ -1291,11 +1293,10 @@ Packet decode proceeds as follows:

       1) [amplitude] = read an unsigned integer of [floor0_amplitude_bits] bits
       2) if ( [amplitude] is greater than zero ) {
            3) [coefficients] is an empty, zero length vector
    -
            4) [booknumber] = read an unsigned integer of ilog( [floor0_number_of_books] ) bits
            5) if ( [booknumber] is greater than the highest number decode codebook ) then packet is undecodable
            6) [last] = zero;
    -       7) vector [temp_vector] = read vector from bitstream using codebook number [booknumber] in VQ context.
    +       7) vector [temp_vector] = read vector from bitstream using codebook number [floor0_book_list] element [booknumber] in VQ context.
            8) add the scalar value [last] to each scalar in vector [temp_vector]
            9) [last] = the value of the last scalar in vector [temp_vector]
           10) concatenate [temp_vector] onto the end of the [coefficients] vector
    @@ -1349,17 +1350,18 @@ Similarly, the below calculation synthesizes the output LSP curve [linear_floor_value] according to:
          

    [expression for floorval]

  • [iteration_condition] = map element [i]
  • [output] element [i] = [linear_floor_value]
  • increment [i]
  • if ( map element [i] is equal to [iteration_condition] ) continue at step 5
  • if ( [i] is less than [n] ) continue at step 2
  • done
  • 7. Floor type 1 setup and decode

    - $Id: 07-floor1.xml 7186 2004-07-20 07:19:25Z xiphmont $ -

    7.1. Overview

    + $Id: 07-floor1.xml 10466 2005-11-28 00:34:44Z giles $ +

    7.1. Overview

    Vorbis floor type one uses a piecewise straight-line representation to encode a spectral envelope curve. The representation plots this curve mechanically on a linear frequency axis and a logarithmic (dB) amplitude axis. The integer plotting algorithm used is similar to -Bresenham's algorithm.

    7.2. Floor 1 format

    7.2.1. model

    +Bresenham's algorithm.

    7.2. Floor 1 format

    7.2.1. model

    Floor type one represents a spectral curve as a series of line segments. Synthesis constructs a floor curve using iterative prediction in a process roughly equivalent to the following simplified -description:

    • the first line segment (base case) is a logical line spanning +description:

      +

      • the first line segment (base case) is a logical line spanning from x_0,y_0 to x_1,y_1 where in the base case x_0=0 and x_1=[n], the full range of the spectral floor to be computed.
      • the induction step chooses a point x_new within an existing logical line segment and produces a y_new value at that point computed @@ -1371,6 +1373,7 @@ amplitude value at x_new so that later refinement is additionally bounded at x_new.
      • the induction step repeats, using a list of x values specified in the codec setup header at floor 1 initialization time. Computation is completed at the end of the x value list.

      +

      Consider the following example, with values chosen for ease of understanding rather than representing typical configuration:

      For the below example, we assume a floor setup with an [n] of 128. @@ -1389,7 +1392,7 @@ A more efficient algorithm with carefully defined integer rounding behavior is used for actual decode, as described later. The actual algorithm splits Y value computation and line plotting into two steps with modifications to the above algorithm to eliminate noise -accumulation through integer roundoff/truncation.

    7.2.2. header decode

    +accumulation through integer roundoff/truncation.

    7.2.2. header decode

    A list of floor X values is stored in the packet header in interleaved format (used in list order during packet decode and synthesis). This list is split into partitions, and each partition is assigned to a @@ -1440,7 +1443,7 @@ context.

     
            19) [current_class_number] = vector [floor1_partition_class_list] element [i]
            20) iterate [j] over the range 0 ... ([floor1_class_dimensions] element [current_class_number])-1 {
    -             21) vector [floor1_X_list] element ([j] + [floor1_values]) = 
    +             21) vector [floor1_X_list] element ([floor1_values]) = 
                      read [rangebits] bits as unsigned integer
                  22) increment [floor1_values] by one
                }
    @@ -1521,7 +1524,7 @@ Skipping zero-difference values allows a smoother line fit.  

    Although some aspects of the below algorithm look like inconsequential optimizations, implementors are warned to follow the details closely. Deviation from implementing a strictly equivalent algorithm can result -in serious decoding errors.

    7.2.2.2.1. step 1: amplitude value synthesis

    +in serious decoding errors.

    7.2.2.2.1. step 1: amplitude value synthesis

    Unwrap the always-positive-or-zero values read from the packet into +/- difference values, then apply to line prediction.

       1) [range] = vector { 256, 128, 86, 64 } element ([floor1_multiplier]-1)
    @@ -1549,7 +1552,7 @@ Unwrap the always-positive-or-zero values read from the packet into
              
               } else [highroom] is not less than [lowroom] {
     		      
    -            15) [root] = [lowroom] * 2
    +            15) [room] = [lowroom] * 2
             
               }
     
    @@ -1597,7 +1600,7 @@ Unwrap the always-positive-or-zero values read from the packet into
     
      29) done
     
    -
    7.2.2.2.2. step 2: curve synthesis

    +

    7.2.2.2.2. step 2: curve synthesis

    Curve synthesis generates a return vector [floor] of length [n] (where [n] is provided by the decode process calling to floor decode). Floor 1 curve synthesis makes use of the @@ -1619,7 +1622,7 @@ Then compute the final curve in one pass:

       3) [ly] = vector [floor1_final_Y]' element [0] * [floor1_multiplier]
       4) iterate [i] over the range 1 ... [floor1_values]-1 {
     
    -       5) if ( [floor1_step2_flag]' is set ) {
    +       5) if ( [floor1_step2_flag]' element [i] is set ) {
     
                  6) [hy] = [floor1_final_Y]' element [i] * [floor1_multiplier]
      	     7) [hx] = [floor1_X_list]' element [i]
    @@ -1647,8 +1650,8 @@ Then compute the final curve in one pass:

      16) done
     
     

    8. Residue setup and decode

    - $Id: 08-residue.xml 7186 2004-07-20 07:19:25Z xiphmont $ -

    8.1. Overview

    + $Id: 08-residue.xml 10466 2005-11-28 00:34:44Z giles $ +

    8.1. Overview

    A residue vector represents the fine detail of the audio spectrum of one channel in an audio frame after the encoder subtracts the floor curve and performs any channel coupling. A residue vector may @@ -1659,7 +1662,7 @@ Whatever the exact qualities, the Vorbis residue abstraction codes the residue vectors into the bitstream packet, and then reconstructs the vectors during decode. Vorbis makes use of three different encoding variants (numbered 0, 1 and 2) of the same basic vector encoding -abstraction.

    8.2. Residue format

    +abstraction.

    8.2. Residue format

    Residue format partitions each vector in the vector bundle into chunks, classifies each chunk, encodes the chunk classifications and finally encodes the chunks themselves using the the specific VQ arrangement @@ -1669,7 +1672,8 @@ however the high-level process used to classify and encode the residue vector is the same in all three variants.

    A set of coded residue vectors are all of the same length. High level coding structure, ignoring for the moment exactly how a partition is -encoded and simply trusting that it is, is as follows:

    • Each vector is partitioned into multiple equal sized chunks +encoded and simply trusting that it is, is as follows:

      +

      • Each vector is partitioned into multiple equal sized chunks according to configuration specified. If we have a vector size of n, a partition size residue_partition_size, and a total of ch residue vectors, the total number of partitioned chunks @@ -1692,7 +1696,8 @@ sum of several passes through the residue vector using more than one VQ codebook. Thus, each residue value potentially accumulates values from multiple decode passes. The classification value associated with a partition is the same in each pass, thus the classification codeword -is coded only in the first pass.

      [illustration of residue vector format]

    8.3. residue 0

    +is coded only in the first pass.

    +

    [illustration of residue vector format]

    8.3. residue 0

    Residue 0 and 1 differ only in the way the values within a residue partition are interleaved during partition encoding (visually treated as a black box--or cyan box or brown box--in the above figure).

    @@ -1716,7 +1721,7 @@ codebook dimensions = 1 encoded as: [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [

    It is worth mentioning at this point that no configurable value in the -residue coding setup is restricted to a power of two.

    8.4. residue 1

    +residue coding setup is restricted to a power of two.

    8.4. residue 1

    Residue 1 does not interleave VQ encoding. It represents partition vector scalars in order. As with residue 0, however, partition length must be an integer multiple of the codebook dimension, although @@ -1734,14 +1739,14 @@ codebook dimensions = 2 encoded as: [ 0 1 ], [ 2 3 ], [ 4 5 ], [ 6 7 ] codebook dimensions = 1 encoded as: [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ] -

    8.5. residue 2

    +

    8.5. residue 2

    Residue type two can be thought of as a variant of residue type 1. Rather than encoding multiple passed-in vectors as in residue type 1, the ch passed in vectors of length n are first interleaved and flattened into a single vector of length ch*n. Encoding then proceeds as in type 1. Decoding is as in type 1 with decode interleave reversed. If operating on a single -vector to begin with, residue type 1 and type 2 are equivalent.

    [illustration of residue type 2]

    8.6. Residue decode

    8.6.1. header decode

    +vector to begin with, residue type 1 and type 2 are equivalent.

    [illustration of residue type 2]

    8.6. Residue decode

    8.6.1. header decode

    Header decode for all three residue types is identical.

       1) [residue_begin] = read 24 bits as unsigned integer
       2) [residue_end] = read 24 bits as unsigned integer
    @@ -1802,7 +1807,7 @@ bitmap being eight bits):

     An end-of-packet condition at any point in header decode renders the
     stream undecodable.  In addition, any codebook number greater than the
     maximum numbered codebook set up in this stream also renders the
    -stream undecodable.

    8.6.2. packet decode

    +stream undecodable.

    8.6.2. packet decode

    Format 0 and 1 packet decode is identical except for specific partition interleave. Format 2 packet decode can be built out of the format 1 decode process. Thus we describe first the decode @@ -1825,58 +1830,63 @@ Packet decode proceeds as follows, matching the description offered earlier in t 3) [partition_count] = 0 - 4) if ([pass] is zero) { + 4) while [partition_count] is less than [partitions_to_read] + + 5) if ([pass] is zero) { - 5) iterate [j] over the range 0 .. [ch]-1 { + 6) iterate [j] over the range 0 .. [ch]-1 { - 6) if vector [j] is not marked 'do not decode' { + 7) if vector [j] is not marked 'do not decode' { - 7) [temp] = read from packet using codebook [residue_classbook] in scalar context - 8) iterate [i] descending over the range [classwords_per_codeword]-1 ... 0 { + 8) [temp] = read from packet using codebook [residue_classbook] in scalar context + 9) iterate [i] descending over the range [classwords_per_codeword]-1 ... 0 { - 9) array [classifications] element [j],([i]+[partition_count]) = - [temp] integer modulo [residue_classifications] - 10) [temp] = [temp] / [residue_classifications] using integer division + 10) array [classifications] element [j],([i]+[partition_count]) = + [temp] integer modulo [residue_classifications] + 11) [temp] = [temp] / [residue_classifications] using integer division - } + } - } + } + } + } - - } - 11) iterate [i] over the range 0 .. ([classwords_per_codeword] - 1) while [partition_count] - is also less than [partitions_to_read] { + 12) iterate [i] over the range 0 .. ([classwords_per_codeword] - 1) while [partition_count] + is also less than [partitions_to_read] { - 12) iterate [j] over the range 0 .. [ch]-1 { + 13) iterate [j] over the range 0 .. [ch]-1 { - 13) if vector [j] is not marked 'do not decode' { + 14) if vector [j] is not marked 'do not decode' { - 14) [vqclass] = array [classifications] element [j],[partition_count] - 15) [vqbook] = array [residue_books] element [vqclass],[pass] - 16) if ([vqbook] is not 'unused') { + 15) [vqclass] = array [classifications] element [j],[partition_count] + 16) [vqbook] = array [residue_books] element [vqclass],[pass] + 17) if ([vqbook] is not 'unused') { - 17) decode partition into output vector number [j], starting at scalar - offset [residue_begin]+[partition_count]*[residue_partition_size] using - codebook number [vqbook] in VQ context + 18) decode partition into output vector number [j], starting at scalar + offset [residue_begin]+[partition_count]*[residue_partition_size] using + codebook number [vqbook] in VQ context + } } - } - 18) increment [partition_count] by one + 19) increment [partition_count] by one + } } } - 19) done + 20) done

    An end-of-packet condition during packet decode is to be considered a nominal occurrence. Decode returns the result of vector decode up to -that point.

    8.6.3. format 0 specifics

    +that point.

    8.6.3. format 0 specifics

    Format zero decodes partitions exactly as described earlier in the 'Residue Format: residue 0' section. The following pseudocode -presents the same algorithm. Assume:

    • [n] is the value in [residue_partition_size]
    • [v] is the residue vector
    • [offset] is the beginning read offset in [v]
    +presents the same algorithm. Assume:

    +

    • [n] is the value in [residue_partition_size]
    • [v] is the residue vector
    • [offset] is the beginning read offset in [v]

    +

      1) [step] = [n] / [codebook_dimensions]
      2) iterate [i] over the range 0 ... [step]-1 {
     
    @@ -1893,11 +1903,13 @@ presents the same algorithm. Assume:

      8.6.4. format 1 specifics

      +

    8.6.4. format 1 specifics

    Format 1 decodes partitions exactly as described earlier in the 'Residue Format: residue 1' section. The following pseudocode -presents the same algorithm. Assume:

    • [n] is the value in -[residue_partition_size]
    • [v] is the residue vector
    • [offset] is the beginning read offset in [v]
    +presents the same algorithm. Assume:

    +

    • [n] is the value in +[residue_partition_size]
    • [v] is the residue vector
    • [offset] is the beginning read offset in [v]

    +

      1) [i] = 0
      2) vector [entry_temp] = read vector from packet using current codebook in VQ context
      3) iterate [j] over the range 0 ... [codebook_dimensions]-1 {
    @@ -1911,7 +1923,7 @@ presents the same algorithm. Assume:

      8.6.5. format 2 specifics

      +

    8.6.5. format 2 specifics

    Format 2 is reducible to format 1. It may be implemented as an additional step prior to and an additional post-decode step after a normal format 1 decode.

    Format 2 handles 'do not decode' vectors differently than residue 0 or @@ -1934,11 +1946,11 @@ channel. After decode, deinterleave the vector into independent vectors, one fo

    9. Helper equations

    $Id: 09-helper.xml 7186 2004-07-20 07:19:25Z xiphmont $ -

    9.1. Overview

    +

    9.1. Overview

    The equations below are used in multiple places by the Vorbis codec specification. Rather than cluttering up the main specification documents, they are defined here and referenced where appropriate. -

    9.2. Functions

    9.2.1. ilog

    +

    9.2. Functions

    9.2.1. ilog

    The "ilog(x)" function returns the position number (1 through n) of the highest set bit in the two's complement integer value [x]. Values of [x] less than zero are defined to return zero.

       1) [return_value] = 0;
    @@ -2119,7 +2131,7 @@ then top to bottom):

       0.50028648,    0.53279791,    0.56742212,    0.60429640, 
       0.64356699,    0.68538959,    0.72993007,    0.77736504, 
       0.82788260,    0.88168307,    0.9389798,     1.
    -

    1. Embedding Vorbis into an Ogg stream

    1.1. Overview

    +

    A. Embedding Vorbis into an Ogg stream

    A.1. Overview

    This document describes using Ogg logical and physical transport streams to encapsulate Vorbis compressed audio packet data into file form.

    @@ -2130,7 +2142,7 @@ bitstream overview and Ogg logical bitstream and framing spec provide detailed descriptions of Ogg transport streams. This specification document assumes a working knowledge of the concepts covered in these named backround -documents. Please read them first.

    1.1.1. Restrictions

    +documents. Please read them first.

    A.1.1. Restrictions

    The Ogg/Vorbis I specification currently dictates that Ogg/Vorbis streams use Ogg transport streams in degenerate, unmultiplexed form only. That is: @@ -2153,11 +2165,11 @@ audio player' is not required to implement Ogg support beyond the specific support of Vorbis within a degenrate ogg stream (naturally, application authors are encouraged to support full multiplexed Ogg handling). -

    1.1.2. MIME type

    +

    A.1.2. MIME type

    The correct MIME type of any Ogg file is application/ogg. However, if a file is a Vorbis I audio file (which implies a degenerate Ogg stream including only unmultiplexed Vorbis audio), the -mime type audio/x-vorbis is also allowed.

    1.2. Encapsulation

    +mime type audio/x-vorbis is also allowed.

    A.2. Encapsulation

    Ogg encapsulation of a Vorbis packet stream is straightforward.

    • The first Vorbis packet (the identification header), which uniquely identifies a stream as Vorbis audio, is placed alone in the @@ -2229,14 +2241,14 @@ Ogg encapsulation of a Vorbis packet stream is straightforward.

      2. Vorbis encapsulation in RTP

      + 

    B. Vorbis encapsulation in RTP

     
     
     
         

    Please consult the internet draft RTP Payload Format for Vorbis Encoded Audio for description of how to embed Vorbis audio in an RTP stream.

    -

    3. Colophon

    [Xiph.org logo]

    +

    C. Colophon

    [Xiph.org logo]

    Ogg is a Xiph.org Foundation effort to protect essential tenets of Internet multimedia from corporate hostage-taking; Open Source is the net's greatest tool to keep diff --git a/doc/Vorbis_I_spec.pdf b/doc/Vorbis_I_spec.pdf index b83530c..b25d3aa 100644 Binary files a/doc/Vorbis_I_spec.pdf and b/doc/Vorbis_I_spec.pdf differ