Audio codec description and optimization method

The codecs of audio are mainly formulated by several major technical organizations according to different application scenarios, namely, ITU-T, 3GPP, and MPEG. Of course, there are also some companies or companies such as the formation of a joint venture, such as Microsoft's WMA. They not only defined the codec specification, but also provided the reference code for software implementation, which facilitates the use of the popular codec. This article first talk about these codec, and then how to optimize the codec according to the reference code (mainly to reduce the CPU load).

1, codec specification

1) ITU-T

The ITU-T developed the codec standard for cable voice, namely the G series, which mainly includes G.711, G.722, G.726, G.728, and G.729. The sampling rate is 8KHz in the narrow band and 16KHz in the wide band. The code rate varies from 64kbps to 8kbps.

The following table lists the specific sampling rates and bit rates.

Audio codec description and optimization method

2) 3GPP

The 3GPP specifies the codec standard for mobile voice, mainly AMR (adapTIve mulTI-rate, adaptive multi-rate) series, and can adjust the code rate adaptively according to the network conditions. The sampling rate is 8KHz in the narrow band and 16KHz in the wide band. In response to the competition of the Internet in recent years (Internet companies have proposed the OPUS codec covering voice and music), 3GPP introduced the EVS (enhanced voice service) audio codec specification. EVS also covers voice and music, and can be flexibly switched between the two, supporting multiple sample rates and bit rates. The specific table below.

Audio codec description and optimization method

3)MPEG

MPEG is mainly made up of music codec specifications, mainly MP3, AAC and so on. MP3 everyone is familiar with, is the most important format of listening to music in the past two decades, AAC is the successor of MP3, the next generation of the most important music codec specification. The sampling rate in music is generally 44100HZ, and some use 48000HZ. The code rate is within a range. The higher the code rate, the better the sound quality.

4) Company or company association

Some companies or company associations develop audio codec specifications as required, such as Microsoft's WMA, Skype's SILK, GIPS (GIPS was acquired by Google in 2011, Google's GIPS-based audio and video solution introduced webRTC and open source, affecting Huge) ILBC and so on. One other thing that I have to mention is OPUS, which was jointly developed by the non-profit Xiph.org Foundation, Skype and Mozilla, etc., with full-band (8kHZ to 48kHZ), voice and music support (SILK for voice, music CELT) has been accepted by the IETF as a voice codec standard on the Internet (RFC6716).

I have used codec from voice to music respectively G.711/G.722/G.726/G.728/G.729/AMR-NB/AMR-WB/ILBC/OPUS/MP3/AAC/WMA/APE /Vorbis/ALAC/FLAC, etc.

2, codec optimization

The optimization mentioned here mainly refers to the optimization of the CPU load, that is, running the codec after optimization takes up less CPU and runs more smoothly on the specific hardware platform. The extent to which optimization is done depends on the demand. If you optimize the project to use, it depends on how long the project gives you to optimize and the project can accept the optimized CPU load, under normal circumstances the project after the optimized codec in the most complex scenarios can run smoothly It does not affect other functions, because the project needs to free up staff to do other things. After all, the progress and quality of the project are the most important. If the optimization is used as a library to sell to customers, we must try our best to optimize it to the extreme. This is an important indicator of which company library the user chooses to use. It is a selling point. In this case, there will be more optimization methods and techniques. The optimizations I have made are for projects, not as libraries for customers, so the skills are not particularly high.

(1) Preparation before optimization

a) Read through the codec code that you want to optimize, try to understand it. If you don't understand it, you need to figure out what the function is. This will help optimize the code later.

b) The profiling tool is ready. The profiling tool measures how many clocks a function runs. There are ready-made profiling tools that are best. If not, do your own tools based on the specific OS and hardware platform (ARM/MIPS, etc.).

c) Prepare the test vector, which is the source of the test. The official codec will provide the official, usually multiple vectors, corresponding to different scenarios. The principle of optimization is to reduce the CPU load at the same time the algorithm operation results are not changed, so every optimization in the optimization should use the test vector to run to see if the results have changed, if you change, we must return to the previous version . When I do optimization, I keep at least one version, sometimes two or three, every day, so that I can find out where the problem is.

(2) Optimization steps and methods

a) Change the compiler's optimization options from -o0 to -o3

b) Add inline to the short functions that are often called in the code

Usually, after a and b are completed, the load will come down a large amount, and like squeeze bubbles, it will squeeze out a large part.

c) In the ITU-T or 3GPP codec reference code, there are a lot of basic operations (addition, subtraction, multiplication and division) functions. These functions are written particularly rigorously. At the same time, the frequency of invocation is very high, thus increasing the computational complexity. Some of these functions can be simplified on the premise of ensuring correctness (for example, some anti-saturation can be avoided), so that the load will be reduced after processing.

d) Use the profiling tool to step by step to see which function has spent more load, understand what the function is doing, and then analyze the specific issues to see how to optimize.

e) Some functions are a small algorithm. The reference code is more complex and the frequency of the call is higher. To find whether there is a simple implementation can be replaced, if there is a substitute for the load will come down. For example, in codec, there are often calculations to find the square root, and the reference code is usually more complex. We know that we can also use the Newton iteration method to find the square root. We can use Newton's iterative method to replace the load.

f) Optimize with assembly. If you can solve the problem at the C level, do not use assembly. Each processor has its own set of assembly instructions and needs to learn and master the ideas and techniques therein. Usually used higher frequency and more load function to write with assembly, that is mixed programming with C and assembly. Assembly compilation takes a relatively long time.

Of course, there are some small tricks such as expanding the for loop, using pointers instead of arrays, and so on, not one by one.

Dash Cam Car DVR

Product Name: Car DVR

Type: DASH CAM

Angle: 145°

Resolution: 1080P

Function : G-Sensor, Voice Interaction,Build-in Battery

Warranty: 1 Months

Certification: CE

Place of Origin: Guangdong, China

Video resolution: 1920*1080P

View Angle: 145 Degree

CPU: Novatek 99672

Lens: 4-Glass Lens

Max External Memory: TF memory card(8-128G)

Product size:90*33*43mm

Packing box size:158*158*59

PRODUCT ADVANTAGES

We attach great importance to product design

material selection and optimization

INTELLIGENT ANTI-SHAKE

You can get usable images even on mountain roads,and DNR noise reduction makes the images clearer.

CLEAR NIGHT IMAGE

LED`s automatically fill light, The front and rear dual-kons and combine professional technology to process composite images.

driving recorder player, dash cam for car,dash cameras, rear view camera for car, rear view camera and monitor

Jiangmen soundrace electronics and technology co.,ltd. , https://www.soundracegroup.com