Bluetooth A2DP Codec
Since the birth of Bluetooth technology in 1998, Bluetooth has entered our lives step by step, including Bluetooth headphones, Bluetooth speakers, and various low-power Bluetooth devices of the Internet of Things, etc. The size of Bluetooth users is increasing, and Bluetooth technology is also improving. Among them, Bluetooth headphones are also constantly improving on the basis of the advancement of Bluetooth technology.
With the release and popularization of Bluetooth A2DP (Advanced Audio Distribution Profile Bluetooth Stereo Audio Transmission Specification), the sound quality of Bluetooth headphones has been further improved and the audience is becoming more and more widespread. Major mobile phone manufacturers have canceled the 3.5mm headphone interface, and have further pursued the sound quality of Bluetooth headphones. However, Apple's release of AirPods completely ignited the TWS (True Wireless Stereo) market, although it opened up the Bluetooth market from another perspective.
Since we talk about the sound quality of Bluetooth headphones, this article will talk about the most common Bluetooth audio decoding technology in various Bluetooth headphones promotions. Of course, sound quality is not just influenced by a certain point, but by a complete system. This article is only a part of the content that is easier to quantify.
Introduction to Bluetooth encoding
SBC
Introduction SBC's full name is Subband Coding. It is an audio encoding system specially designed for Bluetooth audio and video applications. It can obtain high-quality audio using medium bitrates and has low computing complexity. Therefore, SBC can also run well on relatively low-performance hardware.
SBC is the Bluetooth decoding method that must be implemented in the A2DP protocol. It is an encoder required by the Bluetooth protocol to ensure A2DP compatibility. For the requirements for SBC in A2DP, please refer to the table below, and refer to [1] for specific documents.
The maximum bit rate supported by SBC encoding is 320kbps mono and 345kbps stereo. But according to its recommendation, the most used stereo transmission is actually 44.1KHz@328kbps.
principle:
The principle of SBC is to use a bandpass filter to divide the input audio data into 4 or 8 subbands, then specify a scaling factor and sampling depth for each subband, and perform adaptive PCM encoding on the data of this subband (Adaptive Plus Code Modulation), and finally package the encoded data into a binary bitstream and output according to the requirements of A2DP.
You can refer to the following flowchart, source [1].
-
Polyphase analysis The purpose is to transform the input PCM audio sequence into the frequency domain, using a defined multiphase filter bank (bandpass filter). The number of subbands can be 4 or 8, and they correspond to different multiphase filter banks. After processing, the output is multiple subband samples.
-
Derive allocation Convert subband sequences to levels according to different scaling factors (Scale Samples). The range of amplitudes of each subband is different, and the maximum value of each subband amplitude is taken as the Scale Factors of this subband. For example, if the amplitude of the subband is distributed in the interval (0, 128), then the Scale Factors of the self-defined subband are 128, and then convert them into Levels.
-
APCM The process of encoding subband samples and levels generated by each subband is adaptive PCM encoding. After adaptive PCM encoding processing, the quantized subband data (Quantized Subband samples) is output.
-
Bitstream packing The quantized subband sequence is packaged in a bitstream, and finally output into a bitstream, and then sent out as A2DP data.
The advantage of this is to discard or reduce the frequency part of the human ear that is insensitive to hearing, use finer quantization at sensitive frequencies, and achieve better auditory effects under low bit rate conditions.
AAC
Introduction AAC's full name Advanced Audio Coding, was born in 1997. It is a patented audio encoding standard for lossy digital audio compression based on MPEG-2. In 2000, MPEG-4 added some characteristics on the basis of MPEG-2, which are generally called MPEG-2 AAC and MPEG-4 AAC respectively. It is also a codec defined in A2DP, but it is an optional implementation, so not all Bluetooth devices include AAC codec implementations.
However, current Bluetooth devices basically support AAC. For example, the current iPhone (iOS system) contains two codecs: SBC and AAC, while AOSP (the standard open source Android system released by Google) has AAC codec support in the default system. However, the Android system also has a whitelist mechanism for AAC. This may be used by some mobile phone manufacturers to modify the whitelist mechanism. In addition, some mobile phone manufacturers may directly remove AAC codec support, because Android 8.0 has already included LDAC codecs.
The maximum bit rate supported by AAC encoding is stereo 576kbps, with a range of 8576kbps, and a sampling rate range of 8k96k. But according to its recommendation, the most commonly used stereo transmission is actually 44.1/48KHz@256~320 kbps.
principle:
AAC current standards include MPEG-2 AAC and MPEG-4 AAC, and they respectively include different levels of applications. A2DP supports the following four levels of applications, namely MPEG-2 AAC LC, MPEG-4 AAC LC, MPEG-4 LTP and MPEG-4 AAC scalcable, as shown in the figure below.
The overall principle flowchart of MPEG-2 AAC is shown in the figure below, but we can see that the scenarios used by Bluetooth are generally limited, so it is only LC-level applications that must be implemented.
In the LC description of MPEG-2 AAC, prediction and gain control are required to not use, and TNS is also limited. At the same time, any mono or stereo mixing elements should not be included in the bit stream of the LC.
For more information about AAC, please refer to another article introducing the principles of AAC, or you can directly view the more detailed official documents of MPEG-2 (ISO/IEC 13818-7) and MPEG-4 (ISO/IEC 14496-3).
aptX\aptX LL\aptX HD\aptX Adaptive
Introduction: Bluetooth audio codecs, developed by Qualcomm, are not codecs defined in A2DP, but are codecs defined by third-party manufacturers themselves. Due to Qualcomm chips' strong position in the mobile phone market, they have become popular.
Currently, the transmitting end (Source) devices on the market are basically mobile phone manufacturers that use Qualcomm chip solutions. Of course, some HiFi music manufacturers do not use Qualcomm chip solutions, and also provide aptX transmitting function. Most of the receiver (Sink) devices also use Bluetooth headsets using Qualcomm chips. Here is another thing that Bluetooth third-party codec currently uses the transmitter (Source) for free use, while the receiver (Sink) requires a fee.
aptX was first developed by Audio Processing Technology and named apt-X, which was originally used in the professional audio and broadcasting field. apt should be the abbreviation of the first letter of Audio Processing Technology company name. X I guess it means extension (eXtended), but I can only guess it a long time ago. Later, British Bluetooth chip manufacturer CSR acquired Audio Processing Technology and promoted the use of aptX technology in their Bluetooth chip solutions. During this period, aptX began to be widely used due to its low latency, good fault tolerance, and high sound quality. In 2015, Qualcomm acquired CSR, and also acquired aptX technology, and built aptX into Qualcomm's mobile phone solution. A series of Bluetooth chips launched by Qualcomm later included aptX.
The maximum bit rate supported by aptX encoding is stereo 576kbps, with a range of 56576kbps, and a sampling rate range of 8k96k. But according to its recommendation, the most commonly used stereo transmission is actually 44.1/48KHz@352~384 kbps.
principle:
Unlike SBC/AAC, these encoding methods based on psychoacoustic models, aptX uses a digital audio compression algorithm based on SubBand-ADPCM (subband adaptive differential pulse code modulation) technology. For information about SubBand-ADPCM, please refer to the article "Introduction to Lossy Compression Technology".
Source: http://www.aptx.com/which-aptx
From the above table, we can see that the four versions of aptX each have their own strengths. aptX is the most basic version and can be used as a benchmark for the atpX series.
aptX Low Latency is abbreviated as aptX LL, and its features are low latency. When doing Bluetooth development, I did some basic analysis of the code other than codec of aptX LL. I saw that all the places involving aptX LL will reduce the size of the intermediate buffer (buffer), so that the latency of each link can be reduced to achieve the purpose of low latency. Research shows that the delay limit that the human ear can sense is 70ms, and reaching 40ms means we don't feel the delay. But unfortunately, there are few Source devices that support aptX LL. This also involves one of the largest launch devices, smartphones. Taking Android as an example, it needs to be processed by the Android system in the middle and then transmitted through Bluetooth. The processing of each link will increase the delay, so the delay promoted by aptX LL itself is actually more difficult to achieve on mobile phones.
aptX HD focuses on high-definition audio, which is mainly due to the significant increase in transmission rates. When encoding, you can choose processing parameters and processing methods that lose less, and ultimately achieve higher signal-to-noise ratio and smaller distortion. By analyzing the aptX source in FFMPEG, it can be seen that the difference between aptX HD and aptX is mainly: 1. Block size (block_size), aptX is 4, and aptX HD is 6; 2. Parameter tables processed by different subbands ADPCM;
aptX Adaptive, translated as aptX adaptive, this encoding can automatically adjust the transmission bit rate as needed, just like its name. No information was found to confirm whether the transmission bit rate is adjusted according to the signal quality or the audio content is adjusted. It is also explained here that the adaptive mode of LDAC adjusts the transmission bit rate according to the signal quality. aptX Adaptive is backward compatible with aptX and aptX HD.
LDAC
Introduction: Bluetooth audio codec, audio codec developed by Sony, supports up to 96k sampling rate output and can reach a transmission bit rate of up to 990kbps. (After Android 8.0, Sony released LDAC as part of the Android open source plan, so all the systems have preset the encoder after Android 8.0. If your system is after Android 8.0 but does not include LDAC encoding, then the manufacturer should have restricted this part)
principle: LDAC is a lossy codec that uses a hybrid encoding scheme based on improved discrete cosine transform (MDCT) to provide more efficient data compression.
Regarding the characteristics of LDAC, we can find the following information on the official website of LDAC: LDAC Features
-
Unparalleled sound quality LDAC supports the transmission of audio content over Bluetooth at a maximum bit rate of 990kbps, including high resolution (Hi-Res) audio. LDAC is the certified codec for "Hi-Res Audio Wireless" (*1) (*1) LDAC meets the requirements of the "Hi-Res Audio Wireless" logo at a transmission rate of 990 kbps
-
High reliability The "Work to the best" mode automatically controls the bit rate according to network conditions, ensuring stable connections even in harsh environments.
-
Compatible with multiple devices LDAC is compatible with a variety of devices because LDAC is a software codec.
-
LDAC is implemented for Android operating system LDAC source code is contributed to the Android open source project, allowing SRC (smartphone) manufacturers to install LDAC software for free (*1) LDAC is implemented as the first connection priority for the Android operating system. (*1) Sony's license is required to implement LDAC software (SNK).
The above picture is a comparison of the transmission rate between SBC and LDAC provided by the official website of LDAC: However, this comparison does not make much sense, because SBC can also improve audio quality by increasing the transmission rate. For LDAC, in order to be compatible with the impact of different environments, the adaptive transmission rate is used by default, that is, the transmission rate will be adjusted according to the specific Bluetooth signal environment.
The above picture is a comparison of audio quality after SBC and LDAC codecs provided by the official LDAC website:
From the above figure, we can see that when SBC encounters 96k@24bit audio, it needs to downsample to 44.1k@16bit first, then SBC encoding, and then transmit to the receiver at a rate of 328kbps, and finally decode it into 44.1k@16bit audio. Since SBC does not support 96k@24bit audio, it requires one more downsampling before SBC encoding.
At the same time, it can also be seen that LDAC can realize 96k@24bit audio, which is encoded by LDAC, and then transmitted to the receiver at a rate of 990kbps, and then restored to 96k@24bit through LDAC decoding. Compared with SBC, LDAC lacks the process of downsampling to 44.1k@16bit, and can also eventually recover to 96k@24bit.
Although the official LDAC diagram is beautiful, Android mobile phone users, the largest user group of LDAC, did not experience this process, because many Android audio systems only support the input of 44.1k\48k audio, resulting in an additional 96k to 44.1k in the middle of the audio playback of 96k@24bit through Android phones, which may be an extra 96k to 44.1k in the middle of the audio that plays 96k@24bit through Android phones, and converts to 96k output. As shown in the figure above (a).
Since Android phone Bluetooth currently only supports fixed sampling rate output, when you play 44.1k audio, it will resample to 96k and then output through LDAC encoding. As shown in the figure above (b).
However, some devices implement the direct output method of LDAC official diagrams, such as Sony's NW35 and Seaweather's R3PRO, which are non-smart audio players.
The standard implementation of LDAC includes four transmission rates: adaptive transmission rate, connection priority, connection sound quality balanced, and sound quality priority. The adaptive transmission rate method should be said to be a very core advantage of LDAC. In different Bluetooth connection environments, the purpose of adjusting the transmission rate can be achieved.
There are more and more wireless devices nowadays, and Bluetooth signal quality is also increasingly interfering with in different situations. Adaptive transmission of LDAC can be achieved: when the Bluetooth environment is good, the LDAC will automatically switch to 990kbps to transmit high-quality audio content, while when the Bluetooth environment is poor, the transmission rate will automatically drop back to 330kbps in order to ensure the stability of Bluetooth transmission. At this time, although the transmitted audio quality becomes lower, the stability of Bluetooth audio is guaranteed.
LHDC
Introduction: LHDC's full name Low-Latency Hi-Definition Audio Codec is a low-latency high-sound quality Bluetooth codec developed by Taiwanese manufacturer SAVITECH Shengwei Advanced Technology. This technology allows high-quality audio transmission of up to 96k@24bit at speeds up to 900kbps.
LHDC is also the second Bluetooth high-quality codec to reach the Japanese Audio Association certification after Sony's LDAC. Of course, LHDC is also an encoder certified by HWA standards.
Recently, the Japan Audio Association has updated the new version of the Hi-Res Wireless specification, which puts forward the following requirements for high-sounding true wireless Bluetooth headsets:
- True wireless Bluetooth headsets must meet the balance of left and right channels;
- Use LDAC Bluetooth coding technology proposed by Sony, or LHDC Bluetooth coding technology proposed by Taiwan Shengwei Advanced Technology (Savitech);
Compared with LDAC, the original audio will first raise/download to 96kHz@24bit mode, the LHDC can be output according to the original sampling rate to reduce the delay of the SRC process. The above part is excerpted from Wikipedia, but this sentence is actually wrong. LDAC does not have to raise/download the original audio to 96kHz@24bit, but because the LDAC implementation in Android only supports fixed sampling rate output, but some other non-Android devices can normally implement the original sampling rate output. For example, Sony's NW35 and SeaWay's R3PRO are non-smart audio players.
In the above documents, a Hi-Res Audio Wireless certification frequently appears. This is the same as the Hi-Res Audio certification, which is also a set of certification standards proposed by the Japanese Audio Association, namely the small gold standard.
principle: From the related websites of LHDC, we found the following features about LHDC:
- The amount of data transmitted by the LHDC codec is from other technologies (here it should refer to SBC according to the context) is more than 3 times;
- The excellent sound quality that LHDC codecs can provide;
- The increase in transmission data allows users to experience more details and better sound field and immerse themselves in the emotions of music;
Judging from the current relevant information about LHDC, we can only know that LHDC, like LDAC, further improves the sound quality of the transmitted audio by increasing the transmission speed. There is no effective information about the compression algorithm of the audio itself. However, judging from the information of other different types of decoders, LHDC should also be compressed based on psychoacoustics.
Codec | Sampling Rate | Word | Bit Rate | THD+N(Digital) | SNR@1kHz | Frequency respnose |
---|---|---|---|---|---|---|
SBC | 16k-48k | 16bit | 127-345kbps | >-80dB | - | |
AAC | 8k-48k | 16bit | 128-392kbps | >-80dB | - | |
aptX | 16k-48k | 16bit | 384kbps@48k | -85dB | 93dB | 20Hz-22.7kHz |
aptX LL | 16k-48k | 16bit | 352kbps | -85dB | 93dB | 20Hz-22.7kHz |
aptX HD | 16k-48k | 24bit | 570kbps | -90dB | 129dB | 20Hz-22.7kHz |
aptX Adaptive | 16k-48k | 24bit | 276-420kbps | -100dB@420kbps -90db@276kbps | 130dB@276kbps 135dB@420kbps | 20Hz-22.7kHz |
LDAC | 16k-96k | 24bit | 330-990kbps | -125dB | - | |
LHDC | 16k-96k | 24bit | 256-900kbps | -141dB | - |
References
https://www.bluetooth.com/specifications/specs/advanced-audi%e2%80%8b%e2%80%8bo-distribution-profile-1-3-2 http://www.aptx.com/which-aptx https://zh.wikipedia.org/wiki/AptX https://en.wikipedia.org/wiki/Advanced_Audio_Coding http://www.caianet.org.cn/custom/index/24 https://zhuanlan.zhihu.com/p/298347871 https://zhuanlan.zhihu.com/p/56880153 https://www.cnblogs.com/huahuahu/p/lan-ya-xie-yi-zhong-deSBC-bian-ma.html https://www.sony.net/Products/LDAC/ https://zh.wikipedia.org/wiki/LDAC https://zh.wikipedia.org/wiki/LHDC https://www.hwa-lhdc.org/how-it-works https://habr.com/en/post/456182/
ADPCM https://blog.csdn.net/houxiaoni01/article/details/104702570