@@ -1646,32 +1674,12 @@ codebook and the implementors MAY use any other search methods.

<t>

The best PVQ codeword is encoded as a uniformly-distributed integer value

by encode_pulses() (cwrs.c).

The codeword is converted to a unique index in the same way as specified in

<xreftarget="PVQ"></xref>. The indexing is based on the calculation of V(N,K) (denoted N(L,K) in <xreftarget="PVQ"></xref>), which is the number of possible combinations of K pulses

in N samples. The number of combinations can be computed recursively as

V(N,K) = V(N+1,K) + V(N,K+1) + V(N+1,K+1), with V(N,0) = 1 and V(0,K) = 0, K != 0.

There are many different ways to compute V(N,K), including pre-computed tables and direct

use of the recursive formulation. The reference implementation applies the recursive

formulation one line (or column) at a time to save on memory use,

along with an alternate,

univariate recurrence to initialise an arbitrary line, and direct

polynomial solutions for small N. All of these methods are

equivalent, and have different trade-offs in speed, memory usage, and

code size. Implementations MAY use any methods they like, as long as

they are equivalent to the mathematical definition.

The codeword is converted from a unique index in the same way as specified in

<xreftarget="PVQ"></xref>. The indexing is based on the calculation of V(N,K)

(denoted N(L,K) in <xreftarget="PVQ"></xref>), which is the number of possible

combinations of K pulses in N samples.

</t>

<t>

The indexing computations are performed using 32-bit unsigned integers. For large codebooks,

32-bit integers are not sufficient. Instead of using 64-bit integers (or more), the encoding

is for these cases is handled by splitting each band into two equal vectors of

size N/2 prior to quantization. A quantized gain parameter with precision

derived from the current allocation is entropy coded to represent the relative gains of each side of

the split and the entire quantization process is recursively applied.

Multiple levels of splitting may be applied upto a frame size dependent limit.

The same recursive mechanism is applied for the joint coding of stereo