1 % -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*-
2 %!TEX root = Vorbis_I_spec.tex
4 \section{Codec Setup and Packet Decode
} \label{vorbis:spec:codec
}
8 This
document serves as the top-level reference
document for the
9 bit-by-bit decode specification of Vorbis I. This
document assumes a
10 high-level understanding of the Vorbis decode process, which is
11 provided in
\xref{vorbis:spec:intro
}.
\xref{vorbis:spec:bitpacking
} covers reading and writing bit fields from
12 and to bitstream packets.
16 \subsection{Header decode and decode setup
}
18 A Vorbis bitstream begins with three header packets. The header
19 packets are, in order, the identification header, the comments header,
20 and the setup header. All are required for decode compliance. An
21 end-of-packet condition during decoding the first or third header
22 packet renders the stream undecodable. End-of-packet decoding the
23 comment header is a non-fatal error condition.
25 \subsubsection{Common header decode
}
27 Each header packet begins with the same header fields.
30 \begin{Verbatim
}[commandchars=\\\
{\
}]
31 1)
[packet_type
] :
8 bit value
32 2)
0x76,
0x6f,
0x72,
0x62,
0x69,
0x73: the characters 'v','o','r','b','i','s' as six octets
35 Decode continues according to packet type; the identification header
36 is type
1, the comment header type
3 and the setup header type
5
37 (these types are all odd as a packet with a leading single bit of '
0'
38 is an audio packet). The packets must occur in the order of
39 identification, comment, setup.
43 \subsubsection{Identification header
}
45 The identification header is a short header of only a few fields used
46 to declare the stream definitively as Vorbis, and provide a few externally
47 relevant pieces of information about the audio stream. The
48 identification header is coded as follows:
50 \begin{Verbatim
}[commandchars=\\\
{\
}]
51 1)
[vorbis_version
] = read
32 bits as unsigned integer
52 2)
[audio_channels
] = read
8 bit integer as unsigned
53 3)
[audio_sample_rate
] = read
32 bits as unsigned integer
54 4)
[bitrate_maximum
] = read
32 bits as signed integer
55 5)
[bitrate_nominal
] = read
32 bits as signed integer
56 6)
[bitrate_minimum
] = read
32 bits as signed integer
57 7)
[blocksize_0
] =
2 exponent (read
4 bits as unsigned integer)
58 8)
[blocksize_1
] =
2 exponent (read
4 bits as unsigned integer)
59 9)
[framing_flag
] = read one bit
62 \varname{[vorbis_version
]} is to read '
0' in order to be compatible
63 with this
document. Both
\varname{[audio_channels
]} and
64 \varname{[audio_sample_rate
]} must read greater than zero. Allowed final
65 blocksize values are
64,
128,
256,
512,
1024,
2048,
4096 and
8192 in
66 Vorbis I.
\varname{[blocksize_0
]} must be less than or equal to
67 \varname{[blocksize_1
]}. The framing bit must be nonzero. Failure to
68 meet any of these conditions renders a stream undecodable.
70 The bitrate fields above are used only as hints. The nominal bitrate
71 field especially may be considerably off in purely VBR streams. The
72 fields are meaningful only when greater than zero.
75 \item All three fields set to the same value implies a fixed rate, or tightly bounded, nearly fixed-rate bitstream
76 \item Only nominal set implies a VBR or ABR stream that averages the nominal bitrate
77 \item Maximum and or minimum set implies a VBR bitstream that obeys the bitrate limits
78 \item None set indicates the encoder does not care to speculate.
84 \subsubsection{Comment header
}
85 Comment header decode and data specification is covered in
86 \xref{vorbis:spec:comment
}.
89 \subsubsection{Setup header
}
91 Vorbis codec setup is configurable to an extreme degree:
94 \includegraphics[width=
\textwidth]{components
}
95 \captionof{figure
}{decoder pipeline configuration
}
99 The setup header contains the bulk of the codec setup information
100 needed for decode. The setup header contains, in order, the lists of
101 codebook configurations, time-domain transform configurations
102 (placeholders in Vorbis I), floor configurations, residue
103 configurations, channel mapping configurations and mode
104 configurations. It finishes with a framing bit of '
1'. Header decode
105 proceeds in the following order:
107 \paragraph{Codebooks
}
110 \item \varname{[vorbis_codebook_count
]} = read eight bits as unsigned integer and add one
111 \item Decode
\varname{[vorbis_codebook_count
]} codebooks in order as defined
112 in
\xref{vorbis:spec:codebook
}. Save each configuration, in
113 order, in an array of
114 codebook configurations
\varname{[vorbis_codebook_configurations
]}.
119 \paragraph{Time domain transforms
}
121 These hooks are placeholders in Vorbis I. Nevertheless, the
122 configuration placeholder values must be read to maintain bitstream
126 \item \varname{[vorbis_time_count
]} = read
6 bits as unsigned integer and add one
127 \item read
\varname{[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.
134 Vorbis uses two floor types; header decode is handed to the decode
135 abstraction of the appropriate type.
138 \item \varname{[vorbis_floor_count
]} = read
6 bits as unsigned integer and add one
139 \item For each
\varname{[i
]} of
\varname{[vorbis_floor_count
]} floor numbers:
141 \item read the floor type: vector
\varname{[vorbis_floor_types
]} element
\varname{[i
]} =
142 read
16 bits as unsigned integer
143 \item If the floor type is zero, decode the floor
144 configuration as defined in
\xref{vorbis:spec:floor0
}; save
146 configuration in slot
\varname{[i
]} of the floor configuration array
\varname{[vorbis_floor_configurations
]}.
147 \item If the floor type is one,
148 decode the floor configuration as defined in
\xref{vorbis:spec:floor1
}; save this configuration in slot
\varname{[i
]} of the floor configuration array
\varname{[vorbis_floor_configurations
]}.
149 \item If the the floor type is greater than one, this stream is undecodable; ERROR CONDITION
158 Vorbis uses three residue types; header decode of each type is identical.
162 \item \varname{[vorbis_residue_count
]} = read
6 bits as unsigned integer and add one
164 \item For each of
\varname{[vorbis_residue_count
]} residue numbers:
166 \item read the residue type; vector
\varname{[vorbis_residue_types
]} element
\varname{[i
]} = read
16 bits as unsigned integer
167 \item If the residue type is zero,
168 one or two, decode the residue configuration as defined in
\xref{vorbis:spec:residue
}; save this configuration in slot
\varname{[i
]} of the residue configuration array
\varname{[vorbis_residue_configurations
]}.
169 \item If the the residue type is greater than two, this stream is undecodable; ERROR CONDITION
178 Mappings are used to set up specific pipelines for encoding
179 multichannel audio with varying channel mapping applications. Vorbis I
180 uses a single mapping type (
0), with implicit PCM channel mappings.
182 % FIXME/TODO: LaTeX cannot nest enumerate that deeply, so I have to use
183 % itemize at the innermost level. However, it would be much better to
184 % rewrite this pseudocode using listings or algoritmicx or some other
185 % package geared towards this.
187 \item \varname{[vorbis_mapping_count
]} = read
6 bits as unsigned integer and add one
188 \item For each
\varname{[i
]} of
\varname{[vorbis_mapping_count
]} mapping numbers:
190 \item read the mapping type:
16 bits as unsigned integer. There's no reason to save the mapping type in Vorbis I.
191 \item If the mapping type is nonzero, the stream is undecodable
192 \item If the mapping type is zero:
194 \item read
1 bit as a boolean flag
196 \item if set,
\varname{[vorbis_mapping_submaps
]} = read
4 bits as unsigned integer and add one
197 \item if unset,
\varname{[vorbis_mapping_submaps
]} =
1
201 \item read
1 bit as a boolean flag
203 \item if set, square polar channel mapping is in use:
205 \item \varname{[vorbis_mapping_coupling_steps
]} = read
8 bits as unsigned integer and add one
206 \item for
\varname{[j
]} each of
\varname{[vorbis_mapping_coupling_steps
]} steps:
208 \item vector
\varname{[vorbis_mapping_magnitude
]} element
\varname{[j
]}= read
\link{vorbis:spec:ilog
}{ilog
}(
\varname{[audio_channels
]} -
1) bits as unsigned integer
209 \item vector
\varname{[vorbis_mapping_angle
]} element
\varname{[j
]}= read
\link{vorbis:spec:ilog
}{ilog
}(
\varname{[audio_channels
]} -
1) bits as unsigned integer
210 \item 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
\varname{[audio_channels
]}-
1, or the angle channel is greater than
\varname{[audio_channels
]}-
1, the stream is undecodable.
217 \item if unset,
\varname{[vorbis_mapping_coupling_steps
]} =
0
221 \item read
2 bits (reserved field); if the value is nonzero, the stream is undecodable
222 \item if
\varname{[vorbis_mapping_submaps
]} is greater than one, we read channel multiplex settings. For each
\varname{[j
]} of
\varname{[audio_channels
]} channels:
224 \item vector
\varname{[vorbis_mapping_mux
]} element
\varname{[j
]} = read
4 bits as unsigned integer
225 \item if the value is greater than the highest numbered submap (
\varname{[vorbis_mapping_submaps
]} -
1), this in an error condition rendering the stream undecodable
228 \item for each submap
\varname{[j
]} of
\varname{[vorbis_mapping_submaps
]} submaps, read the floor and residue numbers for use in decoding that submap:
230 \item read and discard
8 bits (the unused time configuration placeholder)
231 \item read
8 bits as unsigned integer for the floor number; save in vector
\varname{[vorbis_mapping_submap_floor
]} element
\varname{[j
]}
232 \item verify the floor number is not greater than the highest number floor configured for the bitstream. If it is, the bitstream is undecodable
233 \item read
8 bits as unsigned integer for the residue number; save in vector
\varname{[vorbis_mapping_submap_residue
]} element
\varname{[j
]}
234 \item verify the residue number is not greater than the highest number residue configured for the bitstream. If it is, the bitstream is undecodable
237 \item save this mapping configuration in slot
\varname{[i
]} of the mapping configuration array
\varname{[vorbis_mapping_configurations
]}.
249 \item \varname{[vorbis_mode_count
]} = read
6 bits as unsigned integer and add one
250 \item For each of
\varname{[vorbis_mode_count
]} mode numbers:
252 \item \varname{[vorbis_mode_blockflag
]} = read
1 bit
253 \item \varname{[vorbis_mode_windowtype
]} = read
16 bits as unsigned integer
254 \item \varname{[vorbis_mode_transformtype
]} = read
16 bits as unsigned integer
255 \item \varname{[vorbis_mode_mapping
]} = read
8 bits as unsigned integer
256 \item verify ranges; zero is the only legal value in Vorbis I for
257 \varname{[vorbis_mode_windowtype
]}
258 and
\varname{[vorbis_mode_transformtype
]}.
\varname{[vorbis_mode_mapping
]} must not be greater than the highest number mapping in use. Any illegal values render the stream undecodable.
259 \item save this mode configuration in slot
\varname{[i
]} of the mode configuration array
260 \varname{[vorbis_mode_configurations
]}.
263 \item read
1 bit as a framing flag. If unset, a framing error occurred and the stream is not
267 After reading mode descriptions, setup header decode is complete.
276 \subsection{Audio packet decode and synthesis
}
278 Following the three header packets, all packets in a Vorbis I stream
279 are audio. The first step of audio packet decode is to read and
280 verify the packet type.
\emph{A non-audio packet when audio is expected
281 indicates stream corruption or a non-compliant stream. The decoder
282 must ignore the packet and not attempt decoding it to audio
}.
285 \subsubsection{packet type, mode and window decode
}
288 \item read
1 bit
\varname{[packet_type
]}; check that packet type is
0 (audio)
289 \item read
\link{vorbis:spec:ilog
}{ilog
}(
[vorbis_mode_count
]-
1) bits
290 \varname{[mode_number
]}
291 \item decode blocksize
\varname{[n
]} is equal to
\varname{[blocksize_0
]} if
292 \varname{[vorbis_mode_blockflag
]} is
0, else
\varname{[n
]} is equal to
\varname{[blocksize_1
]}.
293 \item perform window selection and setup; this window is used later by the inverse MDCT:
295 \item if this is a long window (the
\varname{[vorbis_mode_blockflag
]} flag of this mode is
298 \item read
1 bit for
\varname{[previous_window_flag
]}
299 \item read
1 bit for
\varname{[next_window_flag
]}
300 \item if
\varname{[previous_window_flag
]} is not set, the left half
301 of the window will be a hybrid window for lapping with a
302 short block. See
\xref{vorbis:spec:window
} for an illustration of overlapping
304 windows. Else, the left half window will have normal long
306 \item if
\varname{[next_window_flag
]} is not set, the right half of
307 the window will be a hybrid window for lapping with a short
308 block. See
\xref{vorbis:spec:window
} for an
309 illustration of overlapping dissimilar
310 windows. Else, the left right window will have normal long
314 \item if this is a short window, the window is always the same
320 Vorbis windows all use the slope function $y=
\sin(
\frac{\pi}{2} *
\sin^
2((x+
0.5)/n *
\pi))$,
321 where $n$ is window size and $x$ ranges $
0 \ldots n-
1$, but dissimilar
322 lapping requirements can affect overall shape. Window generation
326 \item \varname{[window_center
]} =
\varname{[n
]} /
2
327 \item if (
\varname{[vorbis_mode_blockflag
]} is set and
\varname{[previous_window_flag
]} is
330 \item \varname{[left_window_start
]} =
\varname{[n
]}/
4 -
331 \varname{[blocksize_0
]}/
4
332 \item \varname{[left_window_end
]} =
\varname{[n
]}/
4 +
\varname{[blocksize_0
]}/
4
333 \item \varname{[left_n
]} =
\varname{[blocksize_0
]}/
2
337 \item \varname{[left_window_start
]} =
0
338 \item \varname{[left_window_end
]} =
\varname{[window_center
]}
339 \item \varname{[left_n
]} =
\varname{[n
]}/
2
342 \item if (
\varname{[vorbis_mode_blockflag
]} is set and
\varname{[next_window_flag
]} is not
345 \item \varname{[right_window_start
]} =
\varname{[n
]*
3}/
4 -
346 \varname{[blocksize_0
]}/
4
347 \item \varname{[right_window_end
]} =
\varname{[n
]*
3}/
4 +
348 \varname{[blocksize_0
]}/
4
349 \item \varname{[right_n
]} =
\varname{[blocksize_0
]}/
2
353 \item \varname{[right_window_start
]} =
\varname{[window_center
]}
354 \item \varname{[right_window_end
]} =
\varname{[n
]}
355 \item \varname{[right_n
]} =
\varname{[n
]}/
2
358 \item window from range
0 ...
\varname{[left_window_start
]}-
1 inclusive is zero
359 \item for
\varname{[i
]} in range
\varname{[left_window_start
]} ...
360 \varname{[left_window_end
]}-
1, window(
\varname{[i
]}) = $
\sin(
\frac{\pi}{2} *
\sin^
2($ (
\varname{[i
]}-
\varname{[left_window_start
]}+
0.5) /
\varname{[left_n
]} $*
\frac{\pi}{2})$ )
361 \item window from range
\varname{[left_window_end
]} ...
\varname{[right_window_start
]}-
1
362 inclusive is one
\item for
\varname{[i
]} in range
\varname{[right_window_start
]} ...
\varname{[right_window_end
]}-
1, window(
\varname{[i
]}) = $
\sin(
\frac{\pi}{2} *
\sin^
2($ (
\varname{[i
]}-
\varname{[right_window_start
]}+
0.5) /
\varname{[right_n
]} $ *
\frac{\pi}{2} +
\frac{\pi}{2})$ )
363 \item window from range
\varname{[right_window_start
]} ...
\varname{[n
]}-
1 is
367 An end-of-packet condition up to this point should be considered an
368 error that discards this packet from the stream. An end of packet
369 condition past this point is to be considered a possible nominal
374 \subsubsection{floor curve decode
}
376 From this point on, we assume out decode context is using mode number
377 \varname{[mode_number
]} from configuration array
378 \varname{[vorbis_mode_configurations
]} and the map number
379 \varname{[vorbis_mode_mapping
]} (specified by the current mode) taken
380 from the mapping configuration array
381 \varname{[vorbis_mapping_configurations
]}.
383 Floor curves are decoded one-by-one in channel order.
385 For each floor
\varname{[i
]} of
\varname{[audio_channels
]}
387 \item \varname{[submap_number
]} = element
\varname{[i
]} of vector
[vorbis_mapping_mux
]
388 \item \varname{[floor_number
]} = element
\varname{[submap_number
]} of vector
389 [vorbis_submap_floor
]
390 \item if the floor type of this
391 floor (vector
\varname{[vorbis_floor_types
]} element
392 \varname{[floor_number
]}) is zero then decode the floor for
393 channel
\varname{[i
]} according to the
394 \xref{vorbis:spec:floor0-decode
}
395 \item if the type of this floor
396 is one then decode the floor for channel
\varname{[i
]} according
397 to the
\xref{vorbis:spec:floor1-decode
}
398 \item save the needed decoded floor information for channel for later synthesis
399 \item if the decoded floor returned 'unused', set vector
\varname{[no_residue
]} element
400 \varname{[i
]} to true, else set vector
\varname{[no_residue
]} element
\varname{[i
]} to
405 An end-of-packet condition during floor decode shall result in packet
406 decode zeroing all channel output vectors and skipping to the
407 add/overlap output stage.
411 \subsubsection{nonzero vector propagate
}
413 A possible result of floor decode is that a specific vector is marked
414 'unused' which indicates that that final output vector is all-zero
415 values (and the floor is zero). The residue for that vector is not
416 coded in the stream, save for one complication. If some vectors are
417 used and some are not, channel coupling could result in mixing a
418 zeroed and nonzeroed vector to produce two nonzeroed vectors.
420 for each
\varname{[i
]} from
0 ...
\varname{[vorbis_mapping_coupling_steps
]}-
1
423 \item if either
\varname{[no_residue
]} entry for channel
424 (
\varname{[vorbis_mapping_magnitude
]} element
\varname{[i
]})
426 (
\varname{[vorbis_mapping_angle
]} element
\varname{[i
]})
427 are set to false, then both must be set to false. Note that an 'unused'
428 floor has no decoded floor information; it is important that this is
429 remembered at floor curve synthesis time.
435 \subsubsection{residue decode
}
437 Unlike floors, which are decoded in channel order, the residue vectors
438 are decoded in submap order.
440 for each submap
\varname{[i
]} in order from
0 ...
\varname{[vorbis_mapping_submaps
]}-
1
443 \item \varname{[ch
]} =
0
444 \item for each channel
\varname{[j
]} in order from
0 ...
\varname{[audio_channels
]} -
1
446 \item if channel
\varname{[j
]} in submap
\varname{[i
]} (vector
\varname{[vorbis_mapping_mux
]} element
\varname{[j
]} is equal to
\varname{[i
]})
448 \item if vector
\varname{[no_residue
]} element
\varname{[j
]} is true
450 \item vector
\varname{[do_not_decode_flag
]} element
\varname{[ch
]} is set
454 \item vector
\varname{[do_not_decode_flag
]} element
\varname{[ch
]} is unset
457 \item increment
\varname{[ch
]}
461 \item \varname{[residue_number
]} = vector
\varname{[vorbis_mapping_submap_residue
]} element
\varname{[i
]}
462 \item \varname{[residue_type
]} = vector
\varname{[vorbis_residue_types
]} element
\varname{[residue_number
]}
463 \item decode
\varname{[ch
]} vectors using residue
\varname{[residue_number
]}, according to type
\varname{[residue_type
]}, also passing vector
\varname{[do_not_decode_flag
]} to indicate which vectors in the bundle should not be decoded. Correct per-vector decode length is
\varname{[n
]}/
2.
464 \item \varname{[ch
]} =
0
465 \item for each channel
\varname{[j
]} in order from
0 ...
\varname{[audio_channels
]}
467 \item if channel
\varname{[j
]} is in submap
\varname{[i
]} (vector
\varname{[vorbis_mapping_mux
]} element
\varname{[j
]} is equal to
\varname{[i
]})
469 \item residue vector for channel
\varname{[j
]} is set to decoded residue vector
\varname{[ch
]}
470 \item increment
\varname{[ch
]}
479 \subsubsection{inverse coupling
}
481 for each
\varname{[i
]} from
\varname{[vorbis_mapping_coupling_steps
]}-
1 descending to
0
484 \item \varname{[magnitude_vector
]} = the residue vector for channel
485 (vector
\varname{[vorbis_mapping_magnitude
]} element
\varname{[i
]})
486 \item \varname{[angle_vector
]} = the residue vector for channel (vector
487 \varname{[vorbis_mapping_angle
]} element
\varname{[i
]})
488 \item for each scalar value
\varname{[M
]} in vector
\varname{[magnitude_vector
]} and the corresponding scalar value
\varname{[A
]} in vector
\varname{[angle_vector
]}:
490 \item if (
\varname{[M
]} is greater than zero)
492 \item if (
\varname{[A
]} is greater than zero)
494 \item \varname{[new_M
]} =
\varname{[M
]}
495 \item \varname{[new_A
]} =
\varname{[M
]}-
\varname{[A
]}
499 \item \varname{[new_A
]} =
\varname{[M
]}
500 \item \varname{[new_M
]} =
\varname{[M
]}+
\varname{[A
]}
506 \item if (
\varname{[A
]} is greater than zero)
508 \item \varname{[new_M
]} =
\varname{[M
]}
509 \item \varname{[new_A
]} =
\varname{[M
]}+
\varname{[A
]}
513 \item \varname{[new_A
]} =
\varname{[M
]}
514 \item \varname{[new_M
]} =
\varname{[M
]}-
\varname{[A
]}
519 \item set scalar value
\varname{[M
]} in vector
\varname{[magnitude_vector
]} to
\varname{[new_M
]}
520 \item set scalar value
\varname{[A
]} in vector
\varname{[angle_vector
]} to
\varname{[new_A
]}
528 \subsubsection{dot product
}
530 For each channel, synthesize the floor curve from the decoded floor
531 information, according to packet type. Note that the vector synthesis
532 length for floor computation is
\varname{[n
]}/
2.
534 For each channel, multiply each element of the floor curve by each
535 element of that channel's residue vector. The result is the dot
536 product of the floor and residue vectors for each channel; the produced
537 vectors are the length
\varname{[n
]}/
2 audio spectrum for each
540 % TODO/FIXME: The following two paragraphs have identical twins
541 % in section 1 (under "compute floor/residue dot product")
542 One point is worth mentioning about this dot product; a common mistake
543 in a fixed point implementation might be to assume that a
32 bit
544 fixed-point representation for floor and residue and direct
545 multiplication of the vectors is sufficient for acceptable spectral
546 depth in all cases because it happens to mostly work with the current
547 Xiph.Org reference encoder.
549 However, floor vector values can span \~
140dB (\~
24 bits unsigned), and
550 the audio spectrum vector should represent a minimum of
120dB (\~
21
551 bits with sign), even when output is to a
16 bit PCM device. For the
552 residue vector to represent full scale if the floor is nailed to
553 $-
140$dB, it must be able to span
0 to $+
140$dB. For the residue vector
554 to reach full scale if the floor is nailed at
0dB, it must be able to
555 represent $-
140$dB to $+
0$dB. Thus, in order to handle full range
556 dynamics, a residue vector may span $-
140$dB to $+
140$dB entirely within
557 spec. A
280dB range is approximately
48 bits with sign; thus the
558 residue vector must be able to represent a
48 bit range and the dot
559 product must be able to handle an effective
48 bit times
24 bit
560 multiplication. This range may be achieved using large (
64 bit or
561 larger) integers, or implementing a movable binary point
566 \subsubsection{inverse MDCT
}
568 Convert the audio spectrum vector of each channel back into time
569 domain PCM audio via an inverse Modified Discrete Cosine Transform
570 (MDCT). A detailed description of the MDCT is available in
\cite{Sporer/Brandenburg/Edler
}. The window
571 function used for the MDCT is the function described earlier.
575 \subsubsection{overlap_add
}
577 Windowed MDCT output is overlapped and added with the right hand data
578 of the previous window such that the
3/
4 point of the previous window
579 is aligned with the
1/
4 point of the current window (as illustrated in
580 \xref{vorbis:spec:window
}). The overlapped portion
581 produced from overlapping the previous and current frame data is
582 finished data to be returned by the decoder. This data spans from the
583 center of the previous window to the center of the current window. In
584 the case of same-sized windows, the amount of data to return is
585 one-half block consisting of and only of the overlapped portions. When
586 overlapping a short and long window, much of the returned range does not
587 actually overlap. This does not damage transform orthogonality. Pay
588 attention however to returning the correct data range; the amount of
589 data to be returned is:
591 \begin{programlisting
}
592 window_blocksize(previous_window)/
4+window_blocksize(current_window)/
4
595 from the center (element windowsize/
2) of the previous window to the
596 center (element windowsize/
2-
1, inclusive) of the current window.
598 Data is not returned from the first frame; it must be used to 'prime'
599 the decode engine. The encoder accounts for this priming when
600 calculating PCM offsets; after the first frame, the proper PCM output
601 offset is '
0' (as no data has been returned yet).
605 \subsubsection{output channel order
}
607 Vorbis I specifies only a channel mapping type
0. In mapping type
0,
608 channel mapping is implicitly defined as follows for standard audio
611 \begin{description
} %[style=nextline]
612 \item[three channels
]
613 the stream is monophonic
616 the stream is stereo. channel order: left, right
618 \item[three channels
]
619 the stream is a
1d-surround encoding. channel order: left,
623 the stream is quadraphonic surround. channel order: front left,
624 front right, rear left, rear right
627 the stream is five-channel surround. channel order: front left,
628 front center, front right, rear left, rear right
631 the stream is
5.1 surround. channel order: front left, front
632 center, front right, rear left, rear right, LFE
634 \item[greater than six channels
]
635 channel use and order is defined by the application
639 Applications using Vorbis for dedicated purposes may define channel
640 mapping as seen fit. Future channel mappings (such as three and four
641 channel
\href{http://www.ambisonic.net/
}{Ambisonics
}) will
642 make use of channel mappings other than mapping
0.