MP3 decoding principle

Source: Internet
Author: User

Address: http://www.eefocus.com/jjbearustc/blog/07-09/3525_b7189.html#articletop

When the PCM signal is compressed to MP3, It is encapsulated into an MP3 data frame with a fixed length in units of 1152 PCM sample values. The frame is the minimum unit of composition of the MP3 file. During decoding, the information in the data frame can be used to restore 1152 PCM sampling values. These 1152 sample values are dividedTwo granularity groupsEach granularity group contains 576 sample values. An mp3 data frame is divided into five parts:Frame header, CRC value, edge information, primary data, and additional data.

1. Synchronization of data streams and reading of frame header information. The synchronization of MP3 data streams is in frame units. The frame header of each frame contains synchronization information. This synchronization information is composed of 12 consecutive bits of '1. The first step in MP3 audio decoding is to synchronize the decoder with the input data stream. After the decoder is enabled, you can search for 12-bit long synchronization characters in the data stream. The data that follows the synchronization is the frame header information, including the sampling rate, fill bit, bit rate and other information.

2. Read master data. The bit pool technology is used in the MP3 encoding process. Therefore, the master data of the current frame may not all be in the current frame. During decoding, the start position of the master data must be determined based on the value of the Start pointer of the master data. The data contained in the primary data includes the scaling factor, user-initiated data, and additional data. These fields have a fixed format in the primary data.

3. Harman decoding and anti-quantization. In the MP3 coding process, according to the output of the psychological acoustic model, the output samples of the discrete cosine transform are quantified and allocated in units of granularity, and then the quantization results are encoded by the Harman. Quantization and encoding are mainly completed through loop iteration. The loop module is described in three layers. The highest layer is frame loop, which calls the outer iteration loop, while the outer iteration loop calls the inner iteration loop. However, in the decoding process, the process of Harman decoding and anti-quantization is implemented separately. The frequency lines of each grain-level group are encoded using different Harman tables. Therefore, different decoding methods are required in the decoding process. The back-quantization spectrum process is based on the obtained Harman decoded data, and based on the full-scaling formula and frame edge information of the reverse quantization, use different formulas for different window types to restore the true values of the 576 frequency lines.

4. Stereo Processing

5. Re-sorting and anti-mixing. The spectrum values obtained during the reverse quantization process are not arranged in the same order. During the mdct process, the spectrum values generated by long windows are first sorted by sub-band and then by frequency. For short windows, the generated spectrum values are arranged in the subband, window, and frequency order. To improve the coding efficiency, data in the short window is rearranged and arranged in the order of sub-band, frequency, and window. During decoding, the spectrum values in the short window are re-sorted in a timely manner. In the same way, in the mdct process of coding, in order to obtain better characteristics in the frequency domain, each sub-band corresponding to the long window is de-overlapped, in order to obtain the correct audio signal, during decoding, the Child bands corresponding to the long window must be overlapped and reconstructed.

6. Inverse discrete cosine transformation. The inverse Discrete Cosine transformation uses the inverse Discrete Cosine transformation formula to transform the signal obtained by inverse quantization. The Calculation of inverse Discrete Cosine transformation is very complex. To improve efficiency, we can optimize the calculation.

7. Frequency Inversion and sub-band synthesis. Frequency Inversion is an odd number of child bands in the output value of the inverse Discrete Cosine Transformation (1, 3, 5 ,..., 31) the odd number of sample values (1, 3, 5 ,..., 17 Sample value) is used to compensate for the frequency inversion to improve the discrete cosine transformation efficiency. The sub-band synthetic filter converts the frequency-domain signals in 32 sub-bands with the same bandwidth into time-domain signals. Sub-band synthesis is the sample value of 32 sub-bands in a channel after inverse Discrete Cosine transformation. After a series of calculations, 32 PCM Digital audio signals are restored. During the sub-band merging process, 32 sub-band sample values are converted to the inverse Discrete Cosine Transform to generate 64 median values, transfer the 64 median values to a 1024-point cache similar to FIFO, and then extract half of the 1024 values to form a vector of 512 values, then, the window addition operation is performed, and the result of the window addition is superimposed to generate 32 Time Domain outputs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.