The present invention relates in general to audio compression techniques, and in particular, to methods for selecting an initial quantization step size in audio encoders and systems using the same.
The popularity of small portable audio appliances and the ability to exchange audio information across the Internet have driven recent efforts to develop compression standards for storing, transferring, and playing back high fidelity audio information. Two of the more advanced of these audio compression standards are the Moving Pictures Expert Group Layer 3 (MP3) and the Advanced Audio Coding (AAC) standards.
Generally, the MP3 and AAC standards define audio decoding techniques that reduce the sampling rate and sample resolution of a stream of digitized audio data for storage and transmission. While these standards define a number of stream parameters, such as the input sampling rates and stream format, they otherwise allow significant flexibility in the implementation of the actual encoders and decoders.
In designing MP3 and AAC audio encoders and decoders, efficient encoding and decoding techniques are required for compressing high-fidelity audio into the smallest possible compressed digital files and subsequently reconstructing that high-fidelity audio from the compressed digital files without significant noise and distortion. Further, these audio techniques should minimize the overall complexity of the hardware and software designs, while at the same time being sufficiently flexible for utilization in a range of possible applications.
The principles of the present invention are embodied in methods for efficiently selecting the initial quantization value during audio encoding operations. According to a particular representative embodiment, a method is disclosed for performing quantization in an audio encoder and includes determining a number of bits available in a frame of encoded audio data. Determinations are also made for the maximum transform coefficient value and a distribution of transform coefficient values across a transform coefficient spectrum being encoded. A quantization step value is determined from the number of available bits in the frame, the maximum transfer coefficient value, and the distribution of coefficient values across the transform spectrum.
Embodiments of the present principles advantageously increase the efficiency of audio encoding processes, by reducing the amount of time required for a quantization process to converge. These principles are applicable to both single-loop and dual-loop encoding processes utilized, for example, in MP3 and AAC audio encoding, in which the number of loop iterations is reduced thereby increasing the efficiency of the encoding process. Additionally, the principles of the present invention also account for the distribution of MDCT coefficient levels and the dynamic range of the input signal, which increases the efficiency of the associated Huffman encoding scheme.
For a more complete understanding of the present invention, and the advantages thereof, reference is now made to the following descriptions taken in conjunction with the accompanying drawings, in which:
The principles of the present invention and their advantages are best understood by referring to the illustrated embodiment depicted in
At the same time, a psycho-acoustic model 103 is applied to the input audio data stream
Psycho-acoustic model 103 also controls MDCT filters 103. Generally, each of the thirty-two (32) streams of data samples from the corresponding sub-band filter 101 is operated on in overlapping blocks defined by temporal windows or a transient detection algorithm controlled by psycho-acoustic model 103 through window control block 110.
The MDCT coefficients output from MDCT filters 103 are scaled in scale factor block 104 with scale factors based on the masking thresholds determined by psycho-acoustic model 103. In particular, the scale factors are applied to scale-factor bands covering multiple MDCT coefficients, and which approximate the critical auditory bands. After scaling, the MDCT coefficients are companded by a factor of X3/4 to balance the signal-to-noise ratio and then quantized in quantizer 105. The integer parts of the resulting quantized values index Huffman code tables 106 to produce the encoded audio output stream. A formatter 107 formats the encoded data into output frames, including headers, the scale factors, other side information generated by side information block 108, and the actual encoded audio samples. A cyclic redundancy check (CRC) is also performed on the compressed output stream.
In typical MP3 encoders, a dual-loop process is often utilized during quantizing and encoding of the MDCT coefficients. In this process, an inner loop adjusts the quantization step size and selects the Huffman code tables. Huffman encoding assigns shorter code words for smaller quantized MDCT coefficients. Hence, if the number of Huffman-encoded bits generated for a corresponding output data frame is above or below the number of bits allocated for that frame, the inner loop iteratively adjusts the quantization steps to best fit the encoded bits into that output frame. The outer loop observes the noise in each scale-factor band and adjusts the corresponding scale-factor until the quantization noise is below the masking threshold generated by the psycho-acoustic model. The inner loop re-adjusts the quantization step size with each iteration of the outer loop in nested-loop operations.
The controlling inputs to the rate/distortion control module include the number of bits available for encoding a given MDCT spectrum, as governed by the desired bit rate of the encoded stream, and the masking threshold calculated by the psycho-acoustic model. Given these two inputs, the rate control/distortion module attempts to shape the quantization noise below the masking curve by adjusting the scale-factors. At the same time, the rate/distortion control module utilizes the global quantization step-size such that the number of bits utilized for encoding is very close to the number of available bits for encoding the given MDCT spectrum.
Current implementations of the inner loop typically do not minimize the number of iterations required to converge to the optimal quantization step value. This deficiency directly and adversely impacts the speed and efficiency of the over all audio encoding process. This problem is advantageously addressed by the principles of the present invention in distortion and rate Loops control block 109, as discussed in detail below.
A similar two-loop iterative quantization and coding procedure is utilized in typical AAC encoders, such as the ACC encoder 200 shown in
Intensity/coupling block 205 performs intensity stereo processing and coupling operations, which generally allow two channels of stereo audio data to be jointly encoded to increase compression efficiency. Prediction block 206 performs backward prediction, on a line-by-line basis, for encoding tone-like signals. Mid/side encoding block 207 coding generally generates an average between two channels of stereo audio data, to further increase the efficiency of the encoding process.
Exemplary AAC encoder 200 includes a scale factors block 208, which applies scale factors to scale bands, as determined by the psycho-acoustic model, a quantizer 209, and a noiseless encoding block 210, which performs Huffman encoding on the data stream. In the illustrated embodiment, a dual-loop process, similar to the MP3 example discussed above, utilized by rate/distortion control block 211 for quantization and coding. Bitstream multiplexer (MUX) 212 generates the formatted compressed output data stream.
According to the principles of the present invention, rate/distortion loop control block 109 of
At block 301, a set of initial scale factors is set for the scale factor sub-bands. These scale factors are applied at block 302 and an initial quantization step size if set at block 303.
At blocks 304 and 305, the scaled MDCT coefficients are quantized and Huffman decoded. If the number of bits resulting from Huffman encoding exceeds the number of bits available in the current output frame, then the quantization step size is increased at block 307 to decrease the quantization bit rate. Procedure 300 then loops back to quantization block 304 and the process repeats.
On the other hand, if the number of bits generated during Huffman decoding is less than the number allocated to the output frame, then at block 308 a determination is made as to whether the quantization noise is below the masking threshold for each sub-band. If the quantization noise is below the corresponding masking threshold, procedure 300 ends at block 312 with the output of the generated Huffman codes for the current output frame.
If, at block 308, the quantization noise is not below the masking threshold for each sub-band, the scale factors for all sub-bands are adjusted at block 309 and applied to the corresponding MDCT coefficients at block 310. At block 311, the quantization step size is reset and procedure 300 loops-back to quantization block 304 and repeats.
A set of equations, described in detail below, provides a “best guess” for the initial quantization-step-size based on statistically and empirically observed behavior of various audio test vectors in response to different quantization step initialization step-sizes. Generally, these equations are based on the following observations. First, quantization step-size is directly proportional to available number of bits in the current output frame. Second, quantization step-size is related to the maximum value of the current MDCT output coefficient spectrum. Third, quantization step-size depends on the distribution of each MDCT coefficient value with respect to the maximum MDCT coefficient value. This third factor is important since it reflects the compression efficiency of the Huffman encoding operation and the corresponding improvement in compression gain over linear encoding.
Specifically, if the maximum MDCT coefficient value is high, then the dynamic range of all the MDCT coefficient values to be encoded is large and hence the number of bits required during encoding is large. The choice of optimal step size must therefore be varied accordingly. Further, the number of bits used during encoding also depends on the distribution of MDCT coefficient values between MDCT lines 0 to MDCT max (575 for MP3 and 1023 for AAC). Again, a similar correction must be applied to the optimal quantization step-size. For example, if the MDCT coefficients are densely distributed near the low amplitude region, excellent Huffman coding gain is achieved and the number of bits required during encoding is reduced. On the other hand, if the MDCT coefficients are more or less evenly distributed in all amplitude regions, the Huffman coding gain is reduced, and the number of bits required during encoding substantially increases.
Generally, the optimal quantization step size is the one for which the number of bits required during encoding is slightly less than available bits in the current output frame. In sum, the equations embodying the principles of the present inventive principles are based on the following considerations: (1) the number of bits available in the current output frame; (2) the maximum absolute MDCT coefficient value in the current MDCT coefficient spectrum; and (3) the distribution of the MDCT coefficient values across the MDCT spectrum.
According to the principles of the present invention, the best guess initial quantization step-size for the dual-loop MP3 encoding process is given by Equation (1):
Optimal_quant_step_size=C+(16/3*log2Max_Abs_MDCT)+(bits available/(108*f) (1)
in which, C depends upon the distribution of absolute values of companded MDCT coefficients, Max_Abs_MDCT is the maximum MDCT coefficient value in the companded spectrum, and f represents Huffman compression coding gain with fixed length encoding.
Code in the C programming language for implementing Equation (1) is provided in Appendix A for reference.
According to the principles of the present invention, the best guess initial quantization step-size for the dual-loop AAC encoding process is given by Equation (2):
Optimal_quant_step_size=C+(16/3*log2Max_Abs_MDCT)−(bits available/(192*f) (2)
in which, C depends upon the distribution of absolute values of companded MDCT coefficients, Max_Abs_MDCT is the maximum MDCT coefficient value in the companded spectrum, and f represents Huffman compression coding gain with fixed length encoding.
Code in the C programming language for implementing Equation (2) is provided in Appendix B for reference.
Equations (1) and (2) are general form equations embodying the principles of the present invention derived based on the following analysis and empirical observation. For MP3 encoding, due to the definitions in the standard, increasing the quantization step-size quant_step_size increases the number of bits required during encoding, while for AAC encoding decreasing the step-size quant_step_size increases the number of bits required during encoding.
In linear quantization, the number of bits required is given by Equation (3) in which the value max (mdct levels[i]) is the maximum MDCT coefficient value in the MDCT coefficient after psycho-acoustic scaling, companding, and applying the global quantization step. For MP3, N=576, and for AAC, N=1024.
Bits_used=log2|max_(mdct_levels[i])| (3)
MP3 and AAC encoders both utilize Huffman coding for variable length encoding. If the Huffman coding gain is “f1”, and the MDCT coefficient values fall in the range of Huffman code-book tables, in the illustrated embodiment, for max_mdct<16, then:
Bits_used=(f1*N*log2max(abs_mdct[i]))+min_audio_data_bits, (4)
in which min_audio_data_bits frame is the number of bits required to encode an all zero (0) output frame.
For max_mdct>16, the escape codes, described below, are applied and the number of bit required becomes:
Bits_used==Nlarge*f2*log2max(abs_mdct[i])+f1*(N−Nlarge)*log216+min_audio_data_bits, (5)
in which the value Nlarge is the number of the MDCT values that have absolute values larger than sixteen (16) and f2 refers to the coding gain for encoding MDCT values beyond sixteen (16).
If N>>Nlarge, then:
Bits_used≈Nlarge*f2*log2max(abs_mdct[i])+audio_data_bits_used—16, (6)
in which the value audio_bits_used—16 is the number of audio bits required for encoding the MDCT coefficient spectrum after scaling such that maximum of the MDCT coefficients is sixteen (16).
An observation of the variation of Bits_used based on changes in the quantization step size provides for estimation of a best guess optimal step size. For example, one estimate for the value of Bits_used if the quantization step size is varied by small Δq change in the MDCT coefficient spectrum is:
abs(mdct_spectrum_new(i))=abs(m(i))*2(−3/16*Δq) (7)
in which m[i] is the value of the MDCT coefficients of the original MDCT coefficient spectrum. The scaled MDCT coefficient spectrum from quant_step is thus:
abs(mdct(i))=abs(mdct_orig(i))*2(−3/16*quant
An estimate the number of bits is then estimated from the bilinear equation forms:
Bits_used=c1+Nf1*(−3/16*quant_step+log 2(max_abs_mdct))(for max scaled mdct<16); and (9)
Bits_used=c2+Nf2*(−3/16*quant_step+log 2(max_abs_mdct))(for max of scaled mdct>=16) (10)
The parameter pairs (C1, Nf1) and (C2, Nf2) depend on the overall scaling factor of the original MDCT coefficient spectrum specific to implementation of the MDCT module. One of the parameter pairs (C1, Nf1) and (C2, Nf2) is selected depending on whether the maximum of the MDCT coefficients scaled using quant_step is below or above sixteen (16) (i.e. the knee point). The distribution of the MDCT coefficient values determines the encoding efficiency and hence also decides the values for intercept and slope for (C1, Nf1) pair. The analysis is simplified by setting:
max_step=16/3*log2max_abs_mdct. (11)
For an audio encoder, the reverse analysis is performed. In other words, given the number of bits available for encoding one output frame, an optimal quantization step size is estimated. In particular, the optimal quantization step size for the given MDCT coefficient spectrum is estimated when the actual bits used, after scaling the MDCT coefficients by the value quant_step and Huffman encoding, is approximately equal to the number of bits available in the output frame.
Approximations for the number of bits used are defined by Equations (12) and (13):
Bits_Available≈Bits_used for max scaled mdct<16=C+Nf1·(−3/16*optimal_quant_step+log 2(max_mdct))=C1+3/16*Nf1*(−optimal_quant_step+max_step) (12)
Bits_Available≈Bits_used for max scaled mdct>16=C2+3/16·Nf2*(−optimal_quant_step+max_step) (13)
Again, the values of (C and Nf) are dependent on the distribution of MDCT coefficient values. Therefore, an optimal_quant_step_size estimation from Bits_available is:
Optimal_quant_step_size=max_step−Kf1−Bits_Available/f1(for max scaled MDCT<16) (14)
Optimal_quant_step_size=max_step−Kf2−Bits_Available/f2(for max scaled MDCT>=16) (15)
Both MP3 and AAC encoders utilize separate Huffman tables designed for maximum quantized values in the range of 0 to 15. Separate Huffman tables and an escape code mechanism are provided for maximum quantized values beyond 15. Specifically, if the quantized value is above 15, that value is linearly encoded. Once a maximum quantized value in the scaled MDCT coefficient spectrum goes beyond 16, the Huffman encoding gain is generally less. Therefore, the value of “f” correspondingly changes and introduces a knee point in the linear approximation equations.
Different values of c1 and f differ before and after the knee point. The knee point is the point where the maximum quantized values just start falling into the escape Huffman coding region (i.e. max_MDCT=16). A first approximation of the knee point is:
Available_bits_knee=(no_of_bins)·Avg number of bits per bin for max_MDCT=(no_of_bins)·log2(16)·(1/Huffman coding gain) (16)
For MP3, the observed Huffman coding gain for music files is 1/0.34 and no_of_bins is 576, resulting in a value of available_bits_knee of 800. For AAC, the observed Huffman coding gain for music files is 1/0.24 and no_of_bins is 1024, resulting in a value of available_bits_knee of 1000.
If bits_used at the knee point is Usedbits_knee. Then Equations (14) and (15) can be written as:
Optimal_quant step_size=max_step−Kf1−Bits_Available/Gf1(Bits_available<Usedbits_knee) (17)
Optimal_quant_step_size=max_step−Kf2−Bits_Available/Gf2(Bits available>=Usedbits knee) (18)
Plotting the value of max_step_optimal_quant_step versus bits_available, reveals that for a given value of bits_available, the mean value of max_step-optimal_quant_size demonstrates distinct bilinear behavior with a knee point. Different audio signals show completely bilinear behavior with completely different intercepts and slopes; however, the knee point remains the same. The procedures provided as Appendices A and B empirically provide the best convergence properties (i.e. best estimate of optimal_quant_step_size for the number available bits). In Appendices A and B the value meanbymax of the MDCT coefficient set is a first order parameter to describe the distribution of MDCT values, which determines the set of values (Kf1, Gf1) and (Kf2, Gf2) need in the above equations.
The value meanbymax is a first order approximation providing an objective measure of the distribution of the MDCT coefficients:
meanbymax=mean_abs_MDCT_values/max_abs_MDCT_values (19)
Generally the value meanbymax is a very effective for partitioning the above equations into separate regions having different c1 and f1 values.
Although the invention has been described with reference to specific embodiments, these descriptions are not meant to be construed in a limiting sense. Various modifications of the disclosed embodiments, as well as alternative embodiments of the invention, will become apparent to persons skilled in the art upon reference to the description of the invention. It should be appreciated by those skilled in the art that the conception and the specific embodiment disclosed might be readily utilized as a basis for modifying or designing other structures for carrying out the same purposes of the present invention. It should also be realized by those skilled in the art that such equivalent constructions do not depart from the spirit and scope of the invention as set forth in the appended claims.
It is therefore contemplated that the claims will cover any such modifications or embodiments that fall within the true scope of the invention.
Number | Name | Date | Kind |
---|---|---|---|
4191858 | Araseki | Mar 1980 | A |
5054073 | Yazu | Oct 1991 | A |
5303346 | Fesseler et al. | Apr 1994 | A |
5913186 | Byrnes et al. | Jun 1999 | A |
5930750 | Tsutsui | Jul 1999 | A |
6011554 | Grunbock et al. | Jan 2000 | A |
6029126 | Malvar | Feb 2000 | A |
6058362 | Malvar | May 2000 | A |
6115689 | Malvar | Sep 2000 | A |
6138090 | Inoue | Oct 2000 | A |
6182034 | Malvar | Jan 2001 | B1 |
6240380 | Malvar | May 2001 | B1 |
6253165 | Malvar | Jun 2001 | B1 |
6256608 | Malvar | Jul 2001 | B1 |
6307549 | Grunbock et al. | Oct 2001 | B1 |
6342349 | Virtanen | Jan 2002 | B1 |
6477370 | Siegler et al. | Nov 2002 | B1 |
6604069 | Tsutsui | Aug 2003 | B1 |
6675148 | Hardwick | Jan 2004 | B2 |
6704705 | Azghandi et al. | Mar 2004 | B1 |
6748363 | Rowlands et al. | Jun 2004 | B1 |
6785815 | Bocon-Gibod | Aug 2004 | B1 |
6792542 | Atrero et al. | Sep 2004 | B1 |
7395211 | Watson et al. | Jul 2008 | B2 |