Ogg Vorbis I format specification: helper equations
</font></h1>
-<em>Last update to this document: July 18, 2002</em><p>
+<em>Last update to this document: August 8, 2002</em><p>
<h1>Overview</h1>
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 linked int he main documents
+documents, they are defined here and linked in the main documents
where appropriate.<p>
<a name=log><h2>ilog</h2></a>
-The "ilog(x)" function returns the highest set bit in the two's complement integer value
+The "ilog(x)" function returns the position number (1 through n) of the highest set bit in the two's complement integer value
<tt>[x]</tt>. Values of <tt>[x]</tt> less than zero are defined to return zero.
<pre>
1) [return_value] = 0;
- 2) if ( [x] is greater than nonzero ){
+ 2) if ( [x] is greater than zero ){
3) increment [return_value];
4) logical shift [x] one bit to the right, padding the MSb with zero
<pre>
1) [mantissa] = [x] bitwise AND 0x1fffff (unsigned result)
2) [sign] = [x] bitwise AND 0x80000000 (unsigned result)
- 3) [exponent] = ( [x] bitwise AND 0x7fe00000) shifted left 21 bits (unsigned result)
- 4) if ( [mantissa] is nonzero ) then negate [mantissa]
+ 3) [exponent] = ( [x] bitwise AND 0x7fe00000) shifted right 21 bits (unsigned result)
+ 4) if ( [sign] is nonzero ) then negate [mantissa]
5) return [mantissa] * ( 2 ^ ( [exponent] - 788 ) )
</pre>
Ogg Vorbis I format specification: probability model and codebooks
</font></h1>
-<em>Last update to this document: July 16, 2002</em><br>
+<em>Last update to this document: August 8, 2002</em><br>
<h1>Overview</h1>
</pre>
-We now read the list of codeword lengths; each entry (numbering a
-total of <tt>[codebook_entries]</tt>) is assigned a codeword length. However,
-decode of lengths is according to whether the <tt>[ordered]</tt> flag is
-set or unset.
+Each entry, numbering a
+total of <tt>[codebook_entries]</tt>, is assigned a codeword length.
+We now read the list of codeword lengths and store these lengths in
+the array <tt>[codebook_codeword_lengths]</tt>. Decode of lengths is
+according to whether the <tt>[ordered]</tt> flag is set or unset.
<ul>
<pre>
1) [current_entry] = 0;
- 2) [current_length] = read a five bit unsigned integer and add one;
+ 2) [current_length] = read a five bit unsigned integer and add 1;
3) [number] = read <a
href="helper.html#ilog">ilog</a>([codebook_entries] - [current_entry]) bits as an unsigned integer
- 4) set the entries [current_entry] through [current_entry]+[n]-1
- inclusive of the [codebook_codeword_lengths] array to [current_length]
+ 4) set the entries [current_entry] through [current_entry]+[number]-1, inclusive,
+ of the [codebook_codeword_lengths] array to [current_length]
5) set [current_entry] to [number] + [current_entry]
- 6) increment [current_length]
+ 6) increment [current_length] by 1
7) if [current_entry] is greater than [codebook_entries] ERROR CONDITION; the decoder will
not be able to read this stream.
8) if [current_entry] is less than [codebook_entries], repeat process starting at 3)
<pre>
1) [codebook_minimum_value] = <a href="helper.html#float32_unpack">float32_unpack</a>( read 32 bits as an unsigned integer)
2) [codebook_delta_value] = <a href="helper.html#float32_unpack">float32_unpack</a>( read 32 bits as an unsigned integer)
- 3) [codebook_value_bits] = read 4 bits as an unsigned integer and add one
+ 3) [codebook_value_bits] = read 4 bits as an unsigned integer and add 1
4) [codebook_sequence_p] = read 1 bit as a boolean flag
if ( [codebook_lookup_type] is 1 ) {
<h2>VQ lookup table vector representation</h2>
-Decoding the VQ lookup table vectors relies on the following values:
+Unpacking the VQ lookup table vectors relies on the following values:
<ul>
<li> the <tt>[codebook_multiplicands]</tt> array
<li> <tt>[codebook_minimum_value]</tt>
</tt>
</ul>
-Decoding a specific vector in the vector lookup table proceeds
-according to <tt>[codebook_lookup_type]</tt>.<p>
+Decoding [unpacking] a specific vector in the vector lookup table
+proceeds according to <tt>[codebook_lookup_type]</tt>. The unpacked
+vector values are what a codebook would return during audio packet
+decode in a VQ context.<p>
<h3>Vector value decode: Lookup type 1</h3>
Lookup type one specifies a lattice VQ lookup table built
-algorithmically from a list of scalar values. The scalar values of a
-specific vector entry are calculated as follows, assuming
-<tt>[lookup_offset]</tt> specifies the vector to be
-calculated:<p>
+algorithmically from a list of scalar values. Calculate [unpack] the
+final values of a codebook entry vector from the entries in
+<tt>[codebook_multiplicands]</tt> as follows (<tt>[value_vector]</tt>
+is the output vector representing the vctor of values for entry number
+<tt>[lookup_offset]</tt> in this codebook):<p>
<pre>
- 1) [last] = zero;
- 2) [index_divisor] = one;
- 3) iterate [codebook_dimensions] times, once for each scalar value in the vector {
+ 1) [last] = 0;
+ 2) [index_divisor] = 1;
+ 3) iterate [i] over the range 0 ... [codebook_dimensions]-1 (once for each scalar value in the value vector) {
4) [multiplicand_offset] = ( [lookup_offset] divided by [index_divisor] using integer
division ) integer modulo [codebook_lookup_values]
- 5) set this iteration's scalar value =
+ 5) vector [value_vector] element [i] =
( [codebook_multiplicands] array element number [multiplicand_offset] ) *
[codebook_delta_value] + [codebook_minimum_value] + [last];
- 6) if ( [codebook_sequence_p] is set ) then set [last] = this iteration's scalar value
+ 6) if ( [codebook_sequence_p] is set ) then set [last] = vector [value_vector] element [i]
7) [index_divisor] = [index_divisor] * [codebook_lookup_values]
Lookup type two specifies a VQ lookup table in which each scalar in
each vector is explicitly set by the <tt>[codebook_multiplicands]</tt>
-array in a one-to-one mapping. The scalar values of a specific vector
-entry in the lookup table are calculated as follows, assuming
-<tt>[lookup_offset]</tt> specifies the vector to be calculated:<p>
+array in a one-to-one mapping. Calculate [unpack] the
+final values of a codebook entry vector from the entries in
+<tt>[codebook_multiplicands]</tt> as follows (<tt>[value_vector]</tt>
+is the output vector representing the vctor of values for entry number
+<tt>[lookup_offset]</tt> in this codebook):<p>
<pre>
- 1) [last] = zero;
+ 1) [last] = 0;
2) [multiplicand_offset] = [lookup_offset] * [codebook_dimensions]
- 3) iterate [codebook_dimensions] times, once for each scalar value in the vector {
+ 3) iterate [i] over the range 0 ... [codebook_dimensions]-1 (once for each scalar value in the value vector) {
- 4) set this iteration's scalar value =
+ 4) vector [value_vector] element [i] =
( [codebook_multiplicands] array element number [multiplicand_offset] ) *
[codebook_delta_value] + [codebook_minimum_value] + [last];
- 5) if ( [codebook_sequence_p] is set ) then set [last] = this iteration's scalar value
+ 5) if ( [codebook_sequence_p] is set ) then set [last] = vector [value_vector] element [i]
6) increment [multiplicand_offset]
Ogg Vorbis I format specification: floor type 1 setup and decode
</font></h1>
-<em>Last update to this document: July 19, 2002</em><br>
+<em>Last update to this document: August 8, 2002</em><br>
<h1>Overview</h1>
<pre>
1) [floor1_partitions] = read 5 bits as unsigned integer
- 2) [maximum_class] = 0
+ 2) [maximum_class] = -1
3) iterate [i] over the range 0 ... [floor1_partitions]-1 {
4) vector [floor1_partition_class_list] element [i] = read 4 bits as unsigned integer
14) [rangebits] = read 4 bits as unsigned integer
15) vector [floor1_X_list] element [0] = 0
16) vector [floor1_X_list] element [1] = 2 exponent [rangebits];
- 17) [floor1_values] = 1
+ 17) [floor1_values] = 2
18) iterate [i] over the range 0 ... [floor1_partitions]-1 {
19) iterate [j] over the range 0 ... ([floor1_class_dimensions] element [i])-1 {
21) [floor1_values] = [floor1_values] + [floor1_class_dimensions] element [i]
}
- 19) done
+ 22) done
</pre>
An end-of-packet condition while reading any aspect of a floor 1
the stereo document also gives a good overview of the generic coupling
mechanism.<p>
-Vorbis coupling applies to pairs of reside vectors at a time;
+Vorbis coupling applies to pairs of residue vectors at a time;
decoupling is done in-place a pair at a time in the order and using
the vectors specified in the current mapping configuration. The
decoupling operation is the same for all pairs, converting square
Ogg Vorbis I format specification: codec setup and packet decode
</font></h1>
-<em>Last update to this document: July 18, 2002</em><br>
+<em>Last update to this document: August 8, 2002</em><br>
<h1>Overview</h1>
3) [audio_sample_rate] = read 32 bits as unsigned integer
4) [bitrate_maximum] = read 32 bits as signed integer
5) [bitrate_nominal] = read 32 bits as signed integer
- 6) [bitrate_lower] = read 32 bits as signed integer
+ 6) [bitrate_minimum] = read 32 bits as signed integer
7) [blocksize_0] = 2 exponent (read 4 bits as unsigned integer)
8) [blocksize_1] = 2 exponent (read 4 bits as unsigned integer)
9) [framing_flag] = read one bit
<tt>[vorbis_version]</tt> is to read '0' in order to be compatible
with this document. Both <tt>[audio_channels]</tt> and
-<tt>[audio_rate]</tt> must read greater than zero. Allowed final
+<tt>[audio_sample_rate]</tt> must read greater than zero. Allowed final
blocksize values are 64, 128, 256, 512, 1024, 2048, 4096 and 8192 in
Vorbis I. <tt>[blocksize_0]</tt> must be less than or equal to
<tt>[blocksize_1]</tt>. The framing bit must be nonzero. Failure to
fields are meaningful only when greater than zero.<p>
<ul><li>All three fields set to the same value implies a fixed rate, or tightly bounded, nearly fixed-rate bitstream
<li>Only nominal set implies a VBR or ABR stream that averages the nominal bitrate
- <li>Upper and or lower set implies a VBR bitstream that obeys the bitrate limits
+ <li>Maximum and or minimum set implies a VBR bitstream that obeys the bitrate limits
<li>None set indicates the encoder does not care to speculate.
</ul>
<ol>
<li><tt>[vorbis_time_count]</tt> = read 6 bits as unsigned integer and add one
-<li>read <tt>[vorbis_time_count]</tt> 16 bit values; each value should be zero. If any other values is nonzero, this is an error condition and the stream is undecodable.
+<li>read <tt>[vorbis_time_count]</tt> 16 bit values; each value should be zero. If any value is nonzero, this is an error condition and the stream is undecodable.
</ol>
<h3>floors</h3>
<ol>
<li><tt>[vorbis_floor_count]</tt> = read 6 bits as unsigned integer and add one
-<li>For each of <tt>[vorbis_floor_count]</tt> floor numbers:
+<li>For each <tt>[i]</tt> of <tt>[vorbis_floor_count]</tt> floor numbers:
<ol>
- <li>read the floor type; vector <tt>[vorbis_floor_types]</tt> element <tt>[i]</tt> = read 16 bits as unsigned integer
+ <li>read the floor type: vector <tt>[vorbis_floor_types]</tt> element <tt>[i]</tt> = read 16 bits as unsigned integer
<li>If the floor type is zero, decode the floor configuration as defined in <a href="vorbis-spec-floor0.html">the floor type 0 specification document</a>; save this configuration in slot <tt>[i]</tt> of the floor configuration array <tt>[vorbis_floor_configurations]</tt>.
<li>If the floor type is one, decode the floor configuration as defined in <a href="vorbis-spec-floor1.html">the floor type 1 specification document</a>; save this configuration in slot <tt>[i]</tt> of the floor configuration array <tt>[vorbis_floor_configurations]</tt>.
<li>If the the floor type is greater than one, this stream is undecodable; ERROR CONDITION
<ol>
<li>vector <tt>[vorbis_mapping_magnitude]</tt> element <tt>[j]</tt>= read <a href="helper.html#ilog">ilog</a>([audio_channels]) bits as unsigned integer<p>
<li>vector <tt>[vorbis_mapping_angle]</tt> element <tt>[j]</tt>= read <a href="helper.html#ilog">ilog</a>([audio_channels]) bits as unsigned integer<p>
- <li>the numbers read in the above two steps are channel numbers representing the channel to treat as magnitude and the channel to treat as angle, respectively. If any of angle channel equals magnitude channel, magnitude channel is greater than <tt>[audio_channels]</tt>-1, or angle channel is greater than <tt>[audio_channels]</tt>-1, the stream is undecodable.<p>
+ <li>the numbers read in the above two steps are channel numbers representing the channel to treat as magnitude and the channel to treat as angle, respectively. If for any coupling step the angle channel number equals the magnitude channel number, the magnitude channel number is greater than <tt>[audio_channels]</tt>-1, or the angle channel is greater than <tt>[audio_channels]</tt>-1, the stream is undecodable.<p>
</ol>
</ol>
<li>read 2 bits (reserved field); if the value is nonzero, the stream is undecodable<p>
<li>if <tt>[vorbis_mapping_submaps]</tt> is greater than one, we read channel multiplex settings. For each <tt>[j]</tt> of <tt>[audio_channels]</tt> channels:<p>
<ol><li>vector <tt>[vorbis_mapping_mux]</tt> element <tt>[j]</tt> = read 4 bits as unsigned integer<p>
- <li>if the value is greater than the highest numbered submap, this in an error condition rendering the stream undecodable<p>
+ <li>if the value is greater than the highest numbered submap (<tt>[vorbis_mapping_submaps]</tt> - 1), this in an error condition rendering the stream undecodable<p>
</ol>
<li>for each submap <tt>[j]</tt> of <tt>[vorbis_mapping_submaps]</tt> submaps, read the floor and residue numbers for use in decoding that submap:
<ol><li>read and discard 8 bits (the unused time configuration placeholder)<p>
<h3>modes</h3>
<ol>
-<li><tt>[vorbis_mode_count]</tt> = read 6 bits as unsigned integer and add one<p.
+<li><tt>[vorbis_mode_count]</tt> = read 6 bits as unsigned integer and add one<p>
<li>For each of <tt>[vorbis_mode_count]</tt> mode numbers:<p>
<ol>
<li><tt>[vorbis_mode_blockflag]</tt> = read 1 bit<p>