Blame doc/03-codebook.tex

Packit 06404a
% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*-
Packit 06404a
%!TEX root = Vorbis_I_spec.tex
Packit 06404a
% $Id$
Packit 06404a
\section{Probability Model and Codebooks} \label{vorbis:spec:codebook}
Packit 06404a
Packit 06404a
\subsection{Overview}
Packit 06404a
Packit 06404a
Unlike practically every other mainstream audio codec, Vorbis has no
Packit 06404a
statically configured probability model, instead packing all entropy
Packit 06404a
decoding configuration, VQ and Huffman, into the bitstream itself in
Packit 06404a
the third header, the codec setup header.  This packed configuration
Packit 06404a
consists of multiple 'codebooks', each containing a specific
Packit 06404a
Huffman-equivalent representation for decoding compressed codewords as
Packit 06404a
well as an optional lookup table of output vector values to which a
Packit 06404a
decoded Huffman value is applied as an offset, generating the final
Packit 06404a
decoded output corresponding to a given compressed codeword.
Packit 06404a
Packit 06404a
\subsubsection{Bitwise operation}
Packit 06404a
The codebook mechanism is built on top of the vorbis bitpacker. Both
Packit 06404a
the codebooks themselves and the codewords they decode are unrolled
Packit 06404a
from a packet as a series of arbitrary-width values read from the
Packit 06404a
stream according to \xref{vorbis:spec:bitpacking}.
Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a
\subsection{Packed codebook format}
Packit 06404a
Packit 06404a
For purposes of the examples below, we assume that the storage
Packit 06404a
system's native byte width is eight bits.  This is not universally
Packit 06404a
true; see \xref{vorbis:spec:bitpacking} for discussion
Packit 06404a
relating to non-eight-bit bytes.
Packit 06404a
Packit 06404a
\subsubsection{codebook decode}
Packit 06404a
Packit 06404a
A codebook begins with a 24 bit sync pattern, 0x564342:
Packit 06404a
Packit 06404a
\begin{Verbatim}[commandchars=\\\{\}]
Packit 06404a
byte 0: [ 0 1 0 0 0 0 1 0 ] (0x42)
Packit 06404a
byte 1: [ 0 1 0 0 0 0 1 1 ] (0x43)
Packit 06404a
byte 2: [ 0 1 0 1 0 1 1 0 ] (0x56)
Packit 06404a
\end{Verbatim}
Packit 06404a
Packit 06404a
16 bit \varname{[codebook\_dimensions]} and 24 bit \varname{[codebook\_entries]} fields:
Packit 06404a
Packit 06404a
\begin{Verbatim}[commandchars=\\\{\}]
Packit 06404a
Packit 06404a
byte 3: [ X X X X X X X X ]
Packit 06404a
byte 4: [ X X X X X X X X ] [codebook\_dimensions] (16 bit unsigned)
Packit 06404a
Packit 06404a
byte 5: [ X X X X X X X X ]
Packit 06404a
byte 6: [ X X X X X X X X ]
Packit 06404a
byte 7: [ X X X X X X X X ] [codebook\_entries] (24 bit unsigned)
Packit 06404a
Packit 06404a
\end{Verbatim}
Packit 06404a
Packit 06404a
Next is the \varname{[ordered]} bit flag:
Packit 06404a
Packit 06404a
\begin{Verbatim}[commandchars=\\\{\}]
Packit 06404a
Packit 06404a
byte 8: [               X ] [ordered] (1 bit)
Packit 06404a
Packit 06404a
\end{Verbatim}
Packit 06404a
Packit 06404a
Each entry, numbering a
Packit 06404a
total of \varname{[codebook\_entries]}, is assigned a codeword length.
Packit 06404a
We now read the list of codeword lengths and store these lengths in
Packit 06404a
the array \varname{[codebook\_codeword\_lengths]}. Decode of lengths is
Packit 06404a
according to whether the \varname{[ordered]} flag is set or unset.
Packit 06404a
Packit 06404a
\begin{itemize}
Packit 06404a
\item
Packit 06404a
  If the \varname{[ordered]} flag is unset, the codeword list is not
Packit 06404a
  length ordered and the decoder needs to read each codeword length
Packit 06404a
  one-by-one.
Packit 06404a
Packit 06404a
  The decoder first reads one additional bit flag, the
Packit 06404a
  \varname{[sparse]} flag.  This flag determines whether or not the
Packit 06404a
  codebook contains unused entries that are not to be included in the
Packit 06404a
  codeword decode tree:
Packit 06404a
Packit 06404a
\begin{Verbatim}[commandchars=\\\{\}]
Packit 06404a
byte 8: [             X 1 ] [sparse] flag (1 bit)
Packit 06404a
\end{Verbatim}
Packit 06404a
Packit 06404a
  The decoder now performs for each of the \varname{[codebook\_entries]}
Packit 06404a
  codebook entries:
Packit 06404a
Packit 06404a
\begin{Verbatim}[commandchars=\\\{\}]
Packit 06404a
Packit 06404a
  1) if([sparse] is set) \{
Packit 06404a
Packit 06404a
         2) [flag] = read one bit;
Packit 06404a
         3) if([flag] is set) \{
Packit 06404a
Packit 06404a
              4) [length] = read a five bit unsigned integer;
Packit 06404a
              5) codeword length for this entry is [length]+1;
Packit 06404a
Packit 06404a
            \} else \{
Packit 06404a
Packit 06404a
              6) this entry is unused.  mark it as such.
Packit 06404a
Packit 06404a
            \}
Packit 06404a
Packit 06404a
     \} else the sparse flag is not set \{
Packit 06404a
Packit 06404a
        7) [length] = read a five bit unsigned integer;
Packit 06404a
        8) the codeword length for this entry is [length]+1;
Packit 06404a
Packit 06404a
     \}
Packit 06404a
Packit 06404a
\end{Verbatim}
Packit 06404a
Packit 06404a
\item
Packit 06404a
  If the \varname{[ordered]} flag is set, the codeword list for this
Packit 06404a
  codebook is encoded in ascending length order.  Rather than reading
Packit 06404a
  a length for every codeword, the encoder reads the number of
Packit 06404a
  codewords per length.  That is, beginning at entry zero:
Packit 06404a
Packit 06404a
\begin{Verbatim}[commandchars=\\\{\}]
Packit 06404a
  1) [current\_entry] = 0;
Packit 06404a
  2) [current\_length] = read a five bit unsigned integer and add 1;
Packit 06404a
  3) [number] = read \link{vorbis:spec:ilog}{ilog}([codebook\_entries] - [current\_entry]) bits as an unsigned integer
Packit 06404a
  4) set the entries [current\_entry] through [current\_entry]+[number]-1, inclusive,
Packit 06404a
    of the [codebook\_codeword\_lengths] array to [current\_length]
Packit 06404a
  5) set [current\_entry] to [number] + [current\_entry]
Packit 06404a
  6) increment [current\_length] by 1
Packit 06404a
  7) if [current\_entry] is greater than [codebook\_entries] ERROR CONDITION;
Packit 06404a
    the decoder will not be able to read this stream.
Packit 06404a
  8) if [current\_entry] is less than [codebook\_entries], repeat process starting at 3)
Packit 06404a
  9) done.
Packit 06404a
\end{Verbatim}
Packit 06404a
Packit 06404a
\end{itemize}
Packit 06404a
Packit 06404a
After all codeword lengths have been decoded, the decoder reads the
Packit 06404a
vector lookup table.  Vorbis I supports three lookup types:
Packit 06404a
\begin{enumerate}
Packit 06404a
\item
Packit 06404a
No lookup
Packit 06404a
\item
Packit 06404a
Implicitly populated value mapping (lattice VQ)
Packit 06404a
\item
Packit 06404a
Explicitly populated value mapping (tessellated or 'foam'
Packit 06404a
VQ)
Packit 06404a
\end{enumerate}
Packit 06404a
Packit 06404a
Packit 06404a
The lookup table type is read as a four bit unsigned integer:
Packit 06404a
\begin{Verbatim}[commandchars=\\\{\}]
Packit 06404a
  1) [codebook\_lookup\_type] = read four bits as an unsigned integer
Packit 06404a
\end{Verbatim}
Packit 06404a
Packit 06404a
Codebook decode precedes according to \varname{[codebook\_lookup\_type]}:
Packit 06404a
\begin{itemize}
Packit 06404a
\item
Packit 06404a
Lookup type zero indicates no lookup to be read.  Proceed past
Packit 06404a
lookup decode.
Packit 06404a
\item
Packit 06404a
Lookup types one and two are similar, differing only in the
Packit 06404a
number of lookup values to be read.  Lookup type one reads a list of
Packit 06404a
values that are permuted in a set pattern to build a list of vectors,
Packit 06404a
each vector of order \varname{[codebook\_dimensions]} scalars.  Lookup
Packit 06404a
type two builds the same vector list, but reads each scalar for each
Packit 06404a
vector explicitly, rather than building vectors from a smaller list of
Packit 06404a
possible scalar values.  Lookup decode proceeds as follows:
Packit 06404a
Packit 06404a
\begin{Verbatim}[commandchars=\\\{\}]
Packit 06404a
  1) [codebook\_minimum\_value] = \link{vorbis:spec:float32:unpack}{float32\_unpack}( read 32 bits as an unsigned integer)
Packit 06404a
  2) [codebook\_delta\_value] = \link{vorbis:spec:float32:unpack}{float32\_unpack}( read 32 bits as an unsigned integer)
Packit 06404a
  3) [codebook\_value\_bits] = read 4 bits as an unsigned integer and add 1
Packit 06404a
  4) [codebook\_sequence\_p] = read 1 bit as a boolean flag
Packit 06404a
Packit 06404a
  if ( [codebook\_lookup\_type] is 1 ) \{
Packit 06404a
Packit 06404a
     5) [codebook\_lookup\_values] = \link{vorbis:spec:lookup1:values}{lookup1\_values}(\varname{[codebook\_entries]}, \varname{[codebook\_dimensions]} )
Packit 06404a
Packit 06404a
  \} else \{
Packit 06404a
Packit 06404a
     6) [codebook\_lookup\_values] = \varname{[codebook\_entries]} * \varname{[codebook\_dimensions]}
Packit 06404a
Packit 06404a
  \}
Packit 06404a
Packit 06404a
  7) read a total of [codebook\_lookup\_values] unsigned integers of [codebook\_value\_bits] each;
Packit 06404a
     store these in order in the array [codebook\_multiplicands]
Packit 06404a
\end{Verbatim}
Packit 06404a
\item
Packit 06404a
A \varname{[codebook\_lookup\_type]} of greater than two is reserved
Packit 06404a
and indicates a stream that is not decodable by the specification in this
Packit 06404a
document.
Packit 06404a
Packit 06404a
\end{itemize}
Packit 06404a
Packit 06404a
Packit 06404a
An 'end of packet' during any read operation in the above steps is
Packit 06404a
considered an error condition rendering the stream undecodable.
Packit 06404a
Packit 06404a
\paragraph{Huffman decision tree representation}
Packit 06404a
Packit 06404a
The \varname{[codebook\_codeword\_lengths]} array and
Packit 06404a
\varname{[codebook\_entries]} value uniquely define the Huffman decision
Packit 06404a
tree used for entropy decoding.
Packit 06404a
Packit 06404a
Briefly, each used codebook entry (recall that length-unordered
Packit 06404a
codebooks support unused codeword entries) is assigned, in order, the
Packit 06404a
lowest valued unused binary Huffman codeword possible.  Assume the
Packit 06404a
following codeword length list:
Packit 06404a
Packit 06404a
\begin{Verbatim}[commandchars=\\\{\}]
Packit 06404a
entry 0: length 2
Packit 06404a
entry 1: length 4
Packit 06404a
entry 2: length 4
Packit 06404a
entry 3: length 4
Packit 06404a
entry 4: length 4
Packit 06404a
entry 5: length 2
Packit 06404a
entry 6: length 3
Packit 06404a
entry 7: length 3
Packit 06404a
\end{Verbatim}
Packit 06404a
Packit 06404a
Assigning codewords in order (lowest possible value of the appropriate
Packit 06404a
length to highest) results in the following codeword list:
Packit 06404a
Packit 06404a
\begin{Verbatim}[commandchars=\\\{\}]
Packit 06404a
entry 0: length 2 codeword 00
Packit 06404a
entry 1: length 4 codeword 0100
Packit 06404a
entry 2: length 4 codeword 0101
Packit 06404a
entry 3: length 4 codeword 0110
Packit 06404a
entry 4: length 4 codeword 0111
Packit 06404a
entry 5: length 2 codeword 10
Packit 06404a
entry 6: length 3 codeword 110
Packit 06404a
entry 7: length 3 codeword 111
Packit 06404a
\end{Verbatim}
Packit 06404a
Packit 06404a
Packit 06404a
\begin{note}
Packit 06404a
Unlike most binary numerical values in this document, we
Packit 06404a
intend the above codewords to be read and used bit by bit from left to
Packit 06404a
right, thus the codeword '001' is the bit string 'zero, zero, one'.
Packit 06404a
When determining 'lowest possible value' in the assignment definition
Packit 06404a
above, the leftmost bit is the MSb.
Packit 06404a
\end{note}
Packit 06404a
Packit 06404a
It is clear that the codeword length list represents a Huffman
Packit 06404a
decision tree with the entry numbers equivalent to the leaves numbered
Packit 06404a
left-to-right:
Packit 06404a
Packit 06404a
\begin{center}
Packit 06404a
\includegraphics[width=10cm]{hufftree}
Packit 06404a
\captionof{figure}{huffman tree illustration}
Packit 06404a
\end{center}
Packit 06404a
Packit 06404a
Packit 06404a
As we assign codewords in order, we see that each choice constructs a
Packit 06404a
new leaf in the leftmost possible position.
Packit 06404a
Packit 06404a
Note that it's possible to underspecify or overspecify a Huffman tree
Packit 06404a
via the length list.  In the above example, if codeword seven were
Packit 06404a
eliminated, it's clear that the tree is unfinished:
Packit 06404a
Packit 06404a
\begin{center}
Packit 06404a
\includegraphics[width=10cm]{hufftree-under}
Packit 06404a
\captionof{figure}{underspecified huffman tree illustration}
Packit 06404a
\end{center}
Packit 06404a
Packit 06404a
Packit 06404a
Similarly, in the original codebook, it's clear that the tree is fully
Packit 06404a
populated and a ninth codeword is impossible.  Both underspecified and
Packit 06404a
overspecified trees are an error condition rendering the stream
Packit 06404a
undecodable.
Packit 06404a
Packit 06404a
Codebook entries marked 'unused' are simply skipped in the assigning
Packit 06404a
process.  They have no codeword and do not appear in the decision
Packit 06404a
tree, thus it's impossible for any bit pattern read from the stream to
Packit 06404a
decode to that entry number.
Packit 06404a
Packit 06404a
\paragraph{Errata 20150226: Single entry codebooks}
Packit 06404a
Packit 06404a
A 'single-entry codebook' is a codebook with one active codeword
Packit 06404a
entry. A single-entry codebook may be either a fully populated
Packit 06404a
codebook with only one declared entry, or a sparse codebook with only
Packit 06404a
one entry marked used. The Vorbis I spec provides no means to specify
Packit 06404a
a codeword length of zero, and as a result, a single-entry codebook is
Packit 06404a
inherently malformed because it is underpopulated.  The original
Packit 06404a
specification did not address directly the matter of single-entry
Packit 06404a
codebooks; they were implicitly illegal as it was not possible to
Packit 06404a
write such a codebook with a valid tree structure.
Packit 06404a
Packit 06404a
In r14811 of the libvorbis reference implementation, Xiph added an
Packit 06404a
additional check to the codebook implementation to reject
Packit 06404a
underpopulated Huffman trees. This change led to the discovery of
Packit 06404a
single-entry books used 'in the wild' when the new, stricter checks
Packit 06404a
rejected a number of apparently working streams.
Packit 06404a
Packit 06404a
In order to minimize breakage of deployed (if technically erroneous)
Packit 06404a
streams, r16073 of the reference implementation explicitly
Packit 06404a
special-cased single-entry codebooks to tolerate the single-entry
Packit 06404a
case.  Commit r16073 also added the following to the specification:
Packit 06404a
Packit 06404a
\blockquote{\sout{Take special care that a codebook with a single used
Packit 06404a
    entry is handled properly; it consists of a single codework of
Packit 06404a
    zero bits and ’reading’ a value out of such a codebook always
Packit 06404a
    returns the single used value and sinks zero bits.
Packit 06404a
}} 
Packit 06404a
Packit 06404a
The intent was to clarify the spec and codify current practice.
Packit 06404a
However, this addition is erroneously at odds with the intent of preserving
Packit 06404a
usability of existing streams using single-entry codebooks, disagrees
Packit 06404a
with the code changes that reinstated decoding, and does not address how
Packit 06404a
single-entry codebooks should be encoded.
Packit 06404a
Packit 06404a
As such, the above addition made in r16037 is struck from the
Packit 06404a
specification and replaced by the following:
Packit 06404a
Packit 06404a
\blockquote{It is possible to declare a Vorbis codebook containing a
Packit 06404a
  single codework entry.  A single-entry codebook may be either a
Packit 06404a
  fully populated codebook with \varname{[codebook\_entries]} set to
Packit 06404a
  1, or a sparse codebook marking only one entry used.  Note that it
Packit 06404a
  is not possible to also encode a \varname{[codeword\_length]} of
Packit 06404a
  zero for the single used codeword, as the unsigned value written to
Packit 06404a
  the stream is \varname{[codeword\_length]-1}.  Instead, encoder
Packit 06404a
  implementations should indicate a \varname{[codeword\_length]} of 1
Packit 06404a
  and 'write' the codeword to a stream during audio encoding by
Packit 06404a
  writing a single zero bit.
Packit 06404a
Packit 06404a
  Decoder implementations shall reject a codebook if it contains only
Packit 06404a
  one used entry and the encoded \varname{[codeword\_length]} of that
Packit 06404a
  entry is not 1.  'Reading' a value from single-entry codebook always
Packit 06404a
  returns the single used codeword value and sinks one bit.  Decoders
Packit 06404a
  should tolerate that the bit read from the stream be '1' instead of
Packit 06404a
  '0'; both values shall return the single used codeword.}
Packit 06404a
Packit 06404a
\paragraph{VQ lookup table vector representation}
Packit 06404a
Packit 06404a
Unpacking the VQ lookup table vectors relies on the following values:
Packit 06404a
\begin{programlisting}
Packit 06404a
the [codebook\_multiplicands] array
Packit 06404a
[codebook\_minimum\_value]
Packit 06404a
[codebook\_delta\_value]
Packit 06404a
[codebook\_sequence\_p]
Packit 06404a
[codebook\_lookup\_type]
Packit 06404a
[codebook\_entries]
Packit 06404a
[codebook\_dimensions]
Packit 06404a
[codebook\_lookup\_values]
Packit 06404a
\end{programlisting}
Packit 06404a
Packit 06404a
\bigskip
Packit 06404a
Packit 06404a
Decoding (unpacking) a specific vector in the vector lookup table
Packit 06404a
proceeds according to \varname{[codebook\_lookup\_type]}.  The unpacked
Packit 06404a
vector values are what a codebook would return during audio packet
Packit 06404a
decode in a VQ context.
Packit 06404a
Packit 06404a
\paragraph{Vector value decode: Lookup type 1}
Packit 06404a
Packit 06404a
Lookup type one specifies a lattice VQ lookup table built
Packit 06404a
algorithmically from a list of scalar values.  Calculate (unpack) the
Packit 06404a
final values of a codebook entry vector from the entries in
Packit 06404a
\varname{[codebook\_multiplicands]} as follows (\varname{[value\_vector]}
Packit 06404a
is the output vector representing the vector of values for entry number
Packit 06404a
\varname{[lookup\_offset]} in this codebook):
Packit 06404a
Packit 06404a
\begin{Verbatim}[commandchars=\\\{\}]
Packit 06404a
  1) [last] = 0;
Packit 06404a
  2) [index\_divisor] = 1;
Packit 06404a
  3) iterate [i] over the range 0 ... [codebook\_dimensions]-1 (once for each scalar value in the value vector) \{
Packit 06404a
Packit 06404a
       4) [multiplicand\_offset] = ( [lookup\_offset] divided by [index\_divisor] using integer
Packit 06404a
          division ) integer modulo [codebook\_lookup\_values]
Packit 06404a
Packit 06404a
       5) vector [value\_vector] element [i] =
Packit 06404a
            ( [codebook\_multiplicands] array element number [multiplicand\_offset] ) *
Packit 06404a
            [codebook\_delta\_value] + [codebook\_minimum\_value] + [last];
Packit 06404a
Packit 06404a
       6) if ( [codebook\_sequence\_p] is set ) then set [last] = vector [value\_vector] element [i]
Packit 06404a
Packit 06404a
       7) [index\_divisor] = [index\_divisor] * [codebook\_lookup\_values]
Packit 06404a
Packit 06404a
     \}
Packit 06404a
Packit 06404a
  8) vector calculation completed.
Packit 06404a
\end{Verbatim}
Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a
\paragraph{Vector value decode: Lookup type 2}
Packit 06404a
Packit 06404a
Lookup type two specifies a VQ lookup table in which each scalar in
Packit 06404a
each vector is explicitly set by the \varname{[codebook\_multiplicands]}
Packit 06404a
array in a one-to-one mapping.  Calculate [unpack] the
Packit 06404a
final values of a codebook entry vector from the entries in
Packit 06404a
\varname{[codebook\_multiplicands]} as follows (\varname{[value\_vector]}
Packit 06404a
is the output vector representing the vector of values for entry number
Packit 06404a
\varname{[lookup\_offset]} in this codebook):
Packit 06404a
Packit 06404a
\begin{Verbatim}[commandchars=\\\{\}]
Packit 06404a
  1) [last] = 0;
Packit 06404a
  2) [multiplicand\_offset] = [lookup\_offset] * [codebook\_dimensions]
Packit 06404a
  3) iterate [i] over the range 0 ... [codebook\_dimensions]-1 (once for each scalar value in the value vector) \{
Packit 06404a
Packit 06404a
       4) vector [value\_vector] element [i] =
Packit 06404a
            ( [codebook\_multiplicands] array element number [multiplicand\_offset] ) *
Packit 06404a
            [codebook\_delta\_value] + [codebook\_minimum\_value] + [last];
Packit 06404a
Packit 06404a
       5) if ( [codebook\_sequence\_p] is set ) then set [last] = vector [value\_vector] element [i]
Packit 06404a
Packit 06404a
       6) increment [multiplicand\_offset]
Packit 06404a
Packit 06404a
     \}
Packit 06404a
Packit 06404a
  7) vector calculation completed.
Packit 06404a
\end{Verbatim}
Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a
\subsection{Use of the codebook abstraction}
Packit 06404a
Packit 06404a
The decoder uses the codebook abstraction much as it does the
Packit 06404a
bit-unpacking convention; a specific codebook reads a
Packit 06404a
codeword from the bitstream, decoding it into an entry number, and then
Packit 06404a
returns that entry number to the decoder (when used in a scalar
Packit 06404a
entropy coding context), or uses that entry number as an offset into
Packit 06404a
the VQ lookup table, returning a vector of values (when used in a context
Packit 06404a
desiring a VQ value). Scalar or VQ context is always explicit; any call
Packit 06404a
to the codebook mechanism requests either a scalar entry number or a
Packit 06404a
lookup vector.
Packit 06404a
Packit 06404a
Note that VQ lookup type zero indicates that there is no lookup table;
Packit 06404a
requesting decode using a codebook of lookup type 0 in any context
Packit 06404a
expecting a vector return value (even in a case where a vector of
Packit 06404a
dimension one) is forbidden.  If decoder setup or decode requests such
Packit 06404a
an action, that is an error condition rendering the packet
Packit 06404a
undecodable.
Packit 06404a
Packit 06404a
Using a codebook to read from the packet bitstream consists first of
Packit 06404a
reading and decoding the next codeword in the bitstream. The decoder
Packit 06404a
reads bits until the accumulated bits match a codeword in the
Packit 06404a
codebook.  This process can be though of as logically walking the
Packit 06404a
Huffman decode tree by reading one bit at a time from the bitstream,
Packit 06404a
and using the bit as a decision boolean to take the 0 branch (left in
Packit 06404a
the above examples) or the 1 branch (right in the above examples).
Packit 06404a
Walking the tree finishes when the decode process hits a leaf in the
Packit 06404a
decision tree; the result is the entry number corresponding to that
Packit 06404a
leaf.  Reading past the end of a packet propagates the 'end-of-stream'
Packit 06404a
condition to the decoder.
Packit 06404a
Packit 06404a
When used in a scalar context, the resulting codeword entry is the
Packit 06404a
desired return value.
Packit 06404a
Packit 06404a
When used in a VQ context, the codeword entry number is used as an
Packit 06404a
offset into the VQ lookup table.  The value returned to the decoder is
Packit 06404a
the vector of scalars corresponding to this offset.