METHODS AND SYSTEMS FOR BIT ALLOCATION AND PARTITIONING IN GAIN-SHAPE VECTOR QUANTIZATION FOR AUDIO CODING
Embodiments are generally directed to systems and methods for bit allocation and band partitioning for gain-shape vector quantization in an audio codec. An audio codec implements a method that uses an implicit, dynamic scheme to allow an encoder and decoder to recreate a series of bit allocation decisions for gain and shape without transmitting additional side information for each decision, based on the number of bits that are left remaining and available in a given packet. For implementation in practical codecs, the band comprising the allocation of bits for the shape is recursively split into equal partitions until the number of bits allocated to each partition is less than the maximum codebook size.
This application claims priority to provisional U.S. Provisional Patent Application No. 61/450,053, filed on Mar. 7, 2011 and entitled “Method and System for Bit Allocation and Partitioning in Gain-Shape Vector Quantization for Audio Coding,” which is incorporated herein in its entirety.
COPYRIGHT NOTICEA portion of the disclosure of this patent document including any priority documents contains material that is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.
FIELD OF THE INVENTIONOne or more implementations relate generally to digital communications, and more specifically to eliminating quantization distortion in audio codecs.
INCORPORATION BY REFERENCEThe present application incorporates by reference U.S. Patent Application No. 61/384,154, which is assigned to the assignees of the present application.
BACKGROUNDThe subject matter discussed in the background section should not be assumed to be prior art merely as a result of its mention in the background section. Similarly, a problem mentioned in the background section or associated with the subject matter of the background section should not be assumed to have been previously recognized in the prior art. The subject matter in the background section merely represents different approaches.
The transmission and storage of computer data increasingly relies on the use of codecs (coder-decoders) to compress/decompress digital media files to reduce the file sizes to manageable sizes to optimize transmission bandwidth and memory use. Vector quantization is used in many signal compression applications. In general, a vector quantizer maps k-dimensional vectors in a vector space into a finite set of vectors Y={yi:i=1, 2, . . . , N}. Each vector is called a code vector or a codeword and the set of all the codewords is called a codebook. In a codec, the encoder takes an input vector and outputs the index of the codeword that offers the lowest distortion. The lowest distortion is typically found by evaluating the Euclidean distance between the input vector and each codeword in the codebook. Once the closest codeword is found, the index of that codeword is sent through a channel, and is then replaced with the associated codeword. Gain shape vector quantization is a type of vector quantization method that has become widely used in high quality speech coding systems, and is generally used when it is important to preserve the energy of the vector.
Many existing low-delay audio codecs only support a limited number of frame sizes and bitrates, often hard-coding the dimensions and rates of the codebooks they use. This allows careful tuning of the rate allocation to various pieces of the codec, but is not very flexible. This lack of flexibility limits the ability of the codec to adapt to the variable capacity of modern network channels, and to trade off latency for quality and loss robustness. Moreover, with regard to gain shape vector quantization, present methods of determining bit rate allocations for the gain and shape quantizations require the solution of processor-intensive calculations that are not appropriate for use with low-power or fixed-point digital signal processors (DSPs).
What is needed, therefore, is an efficient system for bit allocation and band partitioning for use in an audio codec for gain-shape vector quantization operations.
In the following drawings like reference numbers are used to refer to like elements. Although the following figures depict various examples, the one or more implementations are not limited to the examples depicted in the figures.
Embodiments are generally directed to systems and methods for bit allocation and band partitioning for gain-shape vector quantization in an audio codec. The method uses an implicit, dynamic scheme to allow an encoder and decoder to recreate a series of bit allocation decisions without transmitting additional side information for each decision, based on the number of bits that are left remaining and available in a given packet. Since packet-switched networks for real-time communication must already convey the size of the packet, this side channel reduces the amount of explicit side information that must be transmitted, thus improving compression of the audio signal. For implementation in practical codecs, the band comprising the allocation of bits for the shape is recursively split into equal partitions until the size of each partition is less than the maximum codebook size.
Any of the embodiments described herein may be used alone or together with one another in any combination. The one or more implementations encompassed within this specification may also include embodiments that are only partially mentioned or alluded to or are not mentioned or alluded to at all in this brief summary or in the abstract. Although various embodiments may have been motivated by various deficiencies with the prior art, which may be discussed or alluded to in one or more places in the specification, the embodiments do not necessarily address any of these deficiencies. In other words, different embodiments may address different deficiencies that may be discussed in the specification. Some embodiments may only partially address some deficiencies or just one deficiency that may be discussed in the specification, and some embodiments may not address any of these deficiencies.
Aspects of the one or more embodiments described herein may be implemented on one or more computers or processor-based devices executing software instructions. The computers may be networked in a peer-to-peer or other distributed computer network arrangement (e.g., client-server), and may be included as part of an audio and/or video processing and playback system.
Embodiments are directed to an audio coding scheme implemented in a codec (coder-decoder) system.
In an embodiment, and in connection with the PVQ function 112, the encoder 100 uses a technique known as band folding, which delivers a similar effect to the spectral band replication by reusing coefficients of lower bands for higher bands, while also reducing algorithmic delay and computational complexity.
In an embodiment, the codec represented by
For the embodiment of
Embodiments of the codec circuits of
Embodiments of the signal processing systems and methods described herein implement methods for bit allocation and band partitioning for use in an audio codec based on gain-shape vector quantization. In certain audio applications, these methods allow for the practical adaptation of bit rates from 32 kbps to 255 kbps per channel and latencies of 5 ms or less up to more than 20 ms. The system uses an implicit-dynamic scheme to allow an encoder and decoder both to recreate a series of bit allocation decisions without requiring the transmission of additional side information. Each of the encoder 100 and decoder 200 stages executes a respective bit allocation and partitioning process 120 and 220 to determine appropriate bit allocations for the gain and shape values of the audio signal.
In an embodiment of the audio codec system, as shown in
The codec system under an embodiment includes a gain-shape allocation function that determines the number of bits to allocate to coding the gain versus the number of bits to code the shape. Essentially the system determines the size of the codebook to be used for the gain (bit rate) and then uses the remaining bits to code the shape. After coding an initial set of parameters, such as flags to set the operating mode, transform sizes, filtering parameters, a coarse representation of the gains, or other side information, any remaining bits in the packet are distributed to the individual bands. The exact method of distributing bits to bands is usually based on psychoacoustic principles, which are well-known in the art, and depend on the specific representation of audio content being used, and may additionally benefit from a small amount of side information to adapt to the signal being coded.
Once bits have been allocated to a particular band, they must be partitioned between the scalar gain quantizer and the vector shape quantizer of dimension N−1. It is assumed that N≧2, since if N=1, the “shape” consists of, at most, a single sign bit, and all the remaining bits should go to the gain. Given the number of dimensions N and the target bitrate b, one can find the allocation that minimizes the mean squared error (MSE) introduced by the quantization, using known methods. For example, one known method derives this allocation under the assumptions that the gain is quantized using an A-law quantizer and the shape is quantized using an optimal spherical quantizer (for which there is no known construction for arbitrary dimension) and that the bitrate b is large. The result for the size of the codebook to use for the gain, Ng, is given in Eq. 1 as follows:
where Cg is a constant that depends on the A-law quantizer parameter, but not N or b. The value of Csvq is:
As can be seen, the expression based on Ng and Csvq is quite complicated, and requires several processor-intensive division operations, as well as the evaluation of several transcendental functions. In addition, the result that is desired is log2Ng, which is the number of bits to use, and not Ng, itself, further complicating the situation. As such, these calculations are not particularly well suited for implementation on low-powered DSP processors, such as may be found in many commercial audio compression systems. In addition, the assumption that b is large gives suboptimal results when b is in fact small, as is often the case for low-bitrate audio coding.
In an embodiment, a gain-shape allocation method utilizes an approximation method to simplify the gain shape bit allocation calculations in order to simplify the processing operations. The process applies an approximation function for large factorials (e.g., Stirling's approximation) to Eq. (2) above to produce the following expression:
In above Eq. 3, the value, Csvq rapidly approaches 1 as N becomes large. Substituting the value 1 into Eq. 1 for Csvq and replacing (N−1) with N (which compensates for undershooting Csvq for small N) produces the following:
Ng≈√{square root over (CgN)}2b/N, (4)
which is moderately accurate for N>2. This gives the bit allocation for the gain, bg, (in bits) as:
In an embodiment, the bit allocation for the gain is actually computed via the expression:
In the above Eq. 6, the values G and G2 are experimentally chosen constants (selected to be close to ½ log2Cg and G+N/2, respectively), and a is a low-rate correction factor determined as follows:
Given suitably chosen values of G2 and G, this comes quite close to minimizing the mean square error (MSE) over a large range of values of N and b, but is much simpler to compute than Eq. 1. In a practical codec, one cannot use negative bits, and the codebook size may be limited to various sizes (such as a whole number of bits), subject to some maximum, bgmax. Thus in a preferred embodiment, the actual size of the codebook is determined as given in Eq. 8, as follows:
The above Eq. 8 rounds the calculated number of bits for gain to an integer number of bits, as well as imposes bounds on the possible value and prevents the possibility of negative bits.
In an embodiment, the constants G and G2 can be chosen experimentally by an offline training procedure. This procedure first collects a large number of training vectors to be quantized, and measures the average MSE after quantizing at every supported combination of gain quantizer bitrate and shape quantizer bitrate. For a given target bitrate and for each supported gain quantizer bitrate, the process finds the largest shape quantizer bitrate that yields a total less than the target, and the smallest shape quantizer bitrate that yields a total greater than the target, and uses these to interpolate an average MSE value at the target bitrate. Finally, the process selects the gain quantizer bitrate that minimizes this interpolated MSE for the target bitrate. The process is repeated with N=2 for all desired bitrate targets and picks the value of G2 that minimizes the mismatch between the decisions made by this process and those made by Eq. 8. The process then repeats with all supported N>2 for all desired bitrate targets, and picks the value of G that minimizes the mismatch between the decisions made by this process and those made by Eq. 8. The roles of gain and shape can be reversed in this process, but there are typically fewer supported gain bitrates than shape bitrates, which can make this option less efficient.
Once the number of bits bg for the gain is determined, a simple subtraction step is used to determine the number of bits to allocate to the shape bs. In this case, the remaining bs=b−bg bits are allocated to the shape. In practice, Eq. 8 may be approximated using fixed-point integer arithmetic. The equation requires only a single division and a single logarithm calculation, both of which can be accelerated through the use of a small lookup table.
Once the number of bits to be allocated respectively to the gain (bg) and shape (bs) have been determined, the normalized coefficients of an entire band that comprise the “shape,” are quantized. Ideally, the normalized coefficients of an entire band, which compose the shape would be quantized with a single vector quantizer, but in practice efficient vector quantizers with codewords larger than the size of a typical microprocessor word, e.g., 32 bits, are difficult to implement. That is, the number of bits allocated for the shape may be on the order of hundreds of bits, but such a codebook would be too big for practical purposes. To address this issue, the process undertakes a band partitioning and allocation procedure. Algebraic codebooks such as the Pyramid Vector Quantizer are an ideal choice for a vector quantizer when a large number of band sizes, N, and bit rates bs, must be supported. They can be implemented for sizes larger than 32 bits using multiple-precision arithmetic, but this has a large cost in terms of computation time, code size, and data size. The following described method of band partitioning and allocation generally works with any suitable vector quantizer, but the Pyramid Vector Quantizer is used in a preferred embodiment.
To maintain processing efficiency, when a band is allocated more than a certain number of bits for the shape, it is recursively split into halves (partitioned) until the allocation for each partition becomes small enough to code with a single vector quantization codeword, or until the maximum partition depth is reached. The exact number of bits required to trigger a split may vary from band to band, or even among the partitions within a band. In a preferred embodiment, a threshold is set a constant amount above the largest codebook size for the current partition (usually close to 32 bits, but sometimes significantly smaller), and it is only split into two more partitions if the target allocation exceeds this amount. Because splitting reduces the VQ (vector quantization) dimension of the codebooks used, it adds some small amount of coding inefficiency, and the constant amount added to the threshold helps compensate for this overhead by avoiding splitting when the increased bit allocation would not result in lower distortion. Alternative embodiments may utilize other splitting rules, like splitting when the allocation exceeds a fixed threshold (such as 32 bits), which is simpler to implement and reduces compression performance only by a very tiny amount.
If x is the input to the splitting process (either a whole band, or a single partition that has already been split at least once), then it is split into two pieces y1 and y2, such that x is the concatenation of y1 and y2. These are again separated into gains, g1 and g2, and shapes, x1 and x2, such that y1=g1x1 and y2=g2x2 and ∥x1∥=∥x2∥=1. The relative magnitude of the two partitions is coded using a scalar parameter θ=arctan(g2/g1), in the range [0, π/2]. Given these parameters, the codec must determine the optimal bit allocations for θ, x1, and x2, denoted bθ, b1, and b2, respectively. The value θ represents the ratio of the gains, and x1, and x2 are the normalized shapes that are generated after factoring out the gains from y1 and y2.
The normalized coefficients in a band may be further grouped into one or more tiles (after possible deinterleaving or other reordering), where each tile contains coefficients from distinct periods of time. Thus, as shown with reference to
In an embodiment, a bit allocation process is used to determine the optimal bit allocations for θ, x1, and x2. In this process, bp is denoted as the current allocation for the band, e.g., either bs if the entire band is being partitioned, or b1 or b2 from a previous round of partitioning. Following a process similar to that used for Eq. 8, above, the target allocation for θ in terms of the total allocation for the current partition, bp, and the size of each partition after splitting, Np, is determined by the following Eq. 9:
In the above Eq. 9, S is an experimentally determined constant. As before, a practical implementation will need to map this allocation to a real codebook for θ. It is possible to derive a number of alternatives for this procedure, and use it to produce a quantized θ value, {circumflex over (θ)}. For example, in the preferred embodiment, the allocation is capped at a maximum value, bθmax, and the codebook size is computed from an integer approximation of Eq. 9 using ⅛th bit precision. A preferred embodiment actually codes {circumflex over (θ)} using a range coder, which allows codebooks that do not use a whole number of bits. For partitions that contain data from more than one tile, the process uses a uniform probability distribution function (PDF) to drive the range coder, while for partitions that contain data only from a single tile, it uses a triangular PDF. Many other coding schemes of varying complexity and compression performance are also possible. Because these coding schemes can use a variable number of bits, a fixed-point estimate of the actual number of bits used, b{circumflex over (θ)} is subtracted from the total allocation bp, instead of the original target allocation.
The allocation for the two partitions x1 and x2 is determined, in turn, as given in Eqs. 10 and 11:
In the above Eq. 12, Tδ is a temporal masking offset, computed according to psychoacoustic principals. In a preferred embodiment, when the total number of tiles on both sides of the partition, t, is greater than 1, then
Otherwise Tδ=0. Different values depending on the sampling rates, tile sizes, and other factors may also be used as appropriate, depending on the constraints and requirements of the system.
In the decoder 200, dequantized versions of the original gains may be recovered as shown in Eq. 14:
When the L2 norm is used, the denominators are 1. A practical implementation will use an integer approximation to cos {circumflex over (θ)} and sin {circumflex over (θ)}, in order to use them for computing log2tan {circumflex over (θ)} in Eq. 12 (also using an integer approximation), which must produce exactly the same value in the encoder and the decoder.
As shown in
Because of the practical restrictions on the size of various codebooks, a partition 402, as shown in
Although embodiments have been described in relation to processing audio signals using an audio codec, it should be understood that the methods and systems described herein can also be implemented to process video signals to using a video codec. In this case, the input signal may be a digitized video signal that is organized such that the frequency coefficients are grouped into a number of bands, whose size may vary to match properties of the human eye to account for the psycho visual effects associated with video signal processing. Appropriate changes may be made to the values of certain variables in the equations shown above, depending on the characteristics of the video signal and the requirements of the video codec components.
Embodiments are directed to a method and system of coding an audio signal using gain-shape vector quantization, comprising: organizing coefficients representing audio content into one or more bands; dividing each band into a gain and a shape; determining, in processor-based device processing the audio content, a size of a codebook to use for the shape using an approximation method, wherein the size of the codebook dictates a number of bits to allocate to the size; subtracting, in the processor-based device, the number of bits allocated to the size from a total number of bits to determine a number of bits to allocate to the shape; determining if the number of bits allocated to the shape is less than a defined number of bits used in the codebook; and recursively dividing the band into equal size partitions until the number of bits allocated to the shape in each partition is less than the defined number.
Embodiments are further directed to a method and system of coding an audio signal using gain-shape vector quantization, comprising: organizing coefficients representing audio content into one or more bands; dividing each band into a gain and a shape; quantizing the gain using an A-law quantizer, and quantizing the shape using an optimal spherical quantizer; determining, in processor-based device processing the audio content, a size of a codebook to use for the shape using an approximation method for large factorials that approximates the size of the codebook to use for the gain, wherein the size of the codebook dictates a number of bits to allocate to the size; and subtracting, in the processor-based device, the number bits allocated to the size from a total number of bits to determine a number of bits to allocate to the shape.
For purposes of the present description, the terms “component,” “module,” and “process,” may be used interchangeably to refer to a processing unit that performs a particular function and that may be implemented through computer program code (software), digital or analog circuitry, computer firmware, or any combination thereof.
It should be noted that the various functions disclosed herein may be described using any number of combinations of hardware, firmware, and/or as data and/or instructions embodied in various machine-readable or computer-readable media, in terms of their behavioral, register transfer, logic component, and/or other characteristics. Computer-readable media in which such formatted data and/or instructions may be embodied include, but are not limited to, physical (non-transitory), non-volatile storage media in various forms, such as optical, magnetic or semiconductor storage media.
Unless the context clearly requires otherwise, throughout the description and the claims, the words “comprise,” “comprising,” and the like are to be construed in an inclusive sense as opposed to an exclusive or exhaustive sense; that is to say, in a sense of “including, but not limited to.” Words using the singular or plural number also include the plural or singular number respectively. Additionally, the words “herein,” “hereunder,” “above,” “below,” and words of similar import refer to this application as a whole and not to any particular portions of this application. When the word “or” is used in reference to a list of two or more items, that word covers all of the following interpretations of the word: any of the items in the list, all of the items in the list and any combination of the items in the list.
While one or more implementations have been described by way of example and in terms of the specific embodiments, it is to be understood that one or more implementations are not limited to the disclosed embodiments. To the contrary, it is intended to cover various modifications and similar arrangements as would be apparent to those skilled in the art. Therefore, the scope of the appended claims should be accorded the broadest interpretation so as to encompass all such modifications and similar arrangements.
Claims
1. A computer-implemented method of coding an audio signal using gain-shape vector quantization, comprising:
- organizing coefficients representing audio content into one or more bands;
- dividing each band into a gain and a shape;
- determining, in processor-based device processing the audio content, a size of a codebook to use for the shape using an approximation method, wherein the size of the codebook dictates a number of bits to allocate to the size;
- subtracting, in the processor-based device, the number bits allocated to the size from a total number of bits to determine a number of bits to allocate to the shape;
- determining if the number of bits allocated to the shape is less than a defined number of bits used in the codebook; and
- recursively dividing the band into equal size partitions until the number of bits allocated to the shape in each partition is less than the defined number.
2. The method of claim 1 wherein the coefficients are generated by a process selected from the group consisting of: time-domain filtering, excitation of a Linear Predictive Coding (LPC) model, a subband filter process, and a modified discrete cosine transform function.
3. The method of claim 2 wherein the one or more bands are selected to be of a size that matches one or more properties of human hearing.
4. The method of claim 1 wherein the codebook comprises an algebraic codebook, and wherein the defined number of bits comprises 32 bits.
5. The method of claim 4 wherein the processor-based device comprises an audio codec having an encoder circuit and a decoder circuit.
6. The method of claim 5 wherein the encoder circuit executes an encoder process that makes a series of bit allocation decisions for the gain and the shape of the audio content, and wherein the decoder circuit executes a decoder process that recreates the series of bit allocation decisions for gain and shape, without requiring transmission of additional side information for each decision in any data packet transmitted between the encoder circuit and the decoder circuit.
7. The method of claim 1 wherein the gain is quantized using an A-law quantizer, and the shape is quantized using an optimal spherical quantizer, and wherein the approximation comprises an approximation for large factorials that approximates the size of the codebook to use for the gain, denoted Ng, as: Ng≈√{square root over (CgN)}2b/N, wherein N is a number of dimensions, b is a target bitrate, and Cg is a defined constant that depends on the A-law quantizer parameter.
8. The method of claim 7 wherein the number of bits allocated for the gain is denoted bg, and is calculated using the formula: bg=log2 Ng.
9. The method of claim 8 further comprising determining the number of bits allocated for the gain using a low bitrate correction factor.
10. A computer-implemented method of coding an audio signal using gain-shape vector quantization, comprising:
- organizing coefficients representing audio content into one or more bands;
- dividing each band into a gain and a shape;
- quantizing the gain using an A-law quantizer, and quantizing the shape using an optimal spherical quantizer;
- determining, in processor-based device processing the audio content, a size of a codebook to use for the shape using an approximation method for large factorials that approximates the size of the codebook to use for the gain, wherein the size of the codebook dictates a number of bits to allocate to the size; and
- subtracting, in the processor-based device, the number bits allocated to the size from a total number of bits to determine a number of bits to allocate to the shape.
11. The method of claim 10 further comprising:
- determining if the number of bits allocated to the shape is less than a defined number of bits used in the codebook; and
- recursively dividing the band into equal size partitions until the number of bits allocated to the shape in each partition is less than the defined number.
12. The method of claim 11 wherein each partition is separated into gains denoted g1 and g2 and shapes denoted x1 and x2.
13. The method of claim 12 further comprising coding a relative magnitude of two partitions comprising a divided band using a scalar parameter denoted θ, wherein a value of the scalar parameter is calculated by: θ=arctan(g1/g2).
14. The method of claim 13 wherein the codebook comprises an algebraic codebook, and wherein the defined number of bits comprises 32 bits.
15. The method of claim 14 wherein the processor-based device comprises an audio codec having an encoder circuit and a decoder circuit.
16. The method of claim 15 wherein the encoder circuit executes an encoder process that makes a series of bit allocation decisions for the gain and the shape of the audio content, and wherein the decoder circuit executes a decoder process that recreates the series of bit allocation decisions for gain and shape, without requiring transmission of additional side information for each decision in any data packet transmitted between the encoder circuit and the decoder circuit.
17. A system for coding an audio signal in an audio codec utilizing gain-shape vector quantization, comprising:
- a first component organizing coefficients representing audio content into one or more bands and dividing each band into a gain and a shape;
- a gain shape allocation component determining a size of a codebook to use for the shape using an approximation method, wherein the size of the codebook dictates a number of bits to allocate to the size and subtracting, in the processor-based device, the number bits allocated to the size from a total number of bits to determine a number of bits to allocate to the shape; and
- a band partitioning and allocation component determining if the number of bits allocated to the shape is less than a defined number of bits used in the codebook, and recursively dividing the band into equal size partitions until the number of bits allocated to the shape in each partition is less than the defined number.
18. The system of claim 17 wherein the coefficients are generated by a process selected from the group consisting of: time-domain filtering, excitation of a Linear Predictive Coding (LPC) model, a subband filter process, and a modified discrete cosine transform function.
19. The system of claim 18 wherein the codebook comprises an algebraic codebook, and wherein the defined number of bits comprises 32 bits.
20. The system of claim 19 wherein the system includes an audio codec having an encoder circuit and a decoder circuit, wherein the encoder circuit executes an encoder process that makes a series of bit allocation decisions for the gain and the shape of the audio content, and wherein the decoder circuit executes a decoder process that recreates the series of bit allocation decisions for gain and shape, without requiring transmission of additional side information for each decision in any data packet transmitted between the encoder circuit and the decoder circuit.
21. The system of claim 17 wherein the gain is quantized using an A-law quantizer, and the shape is quantized using an optimal spherical quantizer, and wherein the approximation comprises an approximation for large factorials that approximates the size of the codebook to use for the gain.
Type: Application
Filed: Mar 7, 2012
Publication Date: Sep 13, 2012
Patent Grant number: 9009036
Inventors: Timothy B. Terriberry (Mountain View, CA), Jean-Marc Valin (Montreal)
Application Number: 13/414,490
International Classification: G10L 21/00 (20060101);