The test is over. I'm no longer accepting libraries to patch.



SBC XQ Feature is available in LineageOS 15.1 build created on or after the 31st of March 2019, or a 16.0 build created on or after the 13th of May 2019.





Short technical information about SBC codec

Audio channel type and number: Joint Stereo, Stereo, Dual Channel, Mono;

Number of frequency bands: 4 or 8;

Number of audio blocks in one packet: 4, 8, 12, 16;

Quantization bit allocation algorithm: Loudness, SNR;

Maximum and minimum bit pool used in quantization process: usually 2-53.

The decoder is required to support any combination of these parameters. Encoder may implement only a part of them.

Existing Bluetooth stacks usually negotiate the following profile: Joint Stereo, 8 bands, 16 blocks, Loudness, bitpool 2..53. This profile encodes 44.1 kHz audio with a bitrate of 328 kbps.

Bitpool parameter directly affects the bitrate within the same profile: the higher it is, the higher the bitrate, and hence the quality.

However, the bitpool parameter is not bound to a specific profile. The bitrate is also significantly affected by other parameters: audio channel type, number of frequency bands, number of audio blocks. You can increase the bitrate indirectly by negotiating non-standard profiles, without changing the bitpool.





For example, Dual Channel encodes channels separately, using the entire bitpool for each channel. Forcing the device to use Dual Channel instead of Joint Stereo will get us almost doubled bitrate at the same maximum bitpool, 617 kbps.

To me it feels that bitpool should be an internal variable. It is an A2DP specification design fault that bitpool value is not bound to other codec parameters and only defined as a global value.

These fixed Bitpool and Bitrate values originate from recommended values for high-quality audio. But the recommendation is not an excuse to limit the profile to these values.

SBC has lots of different parameters that are negotiated during the connection setup phase:The decoder is required to support any combination of these parameters. Encoder may implement only a part of them.Existing Bluetooth stacks usually negotiate the following profile: Joint Stereo, 8 bands, 16 blocks, Loudness, bitpool 2..53. This profile encodes 44.1 kHz audio with a bitrate of 328 kbps.Bitpool parameter directly affects the bitrate within the same profile: the higher it is, the higher the bitrate, and hence the quality.However, the bitpool parameter is not bound to a specific profile. The bitrate is also significantly affected by other parameters: audio channel type, number of frequency bands, number of audio blocks. You can increase the bitrate indirectly by negotiating non-standard profiles, without changing the bitpool.For example, Dual Channel encodes channels separately, using the entire bitpool for each channel. Forcing the device to use Dual Channel instead of Joint Stereo will get us almost doubled bitrate at the same maximum bitpool, 617 kbps.To me it feels that bitpool should be an internal variable. It is an A2DP specification design fault that bitpool value is not bound to other codec parameters and only defined as a global value.These fixed Bitpool and Bitrate values originate from recommended values for high-quality audio. But the recommendation is not an excuse to limit the profile to these values.

Quote: The decoder of the SNK shall support all possible bitpool values ​​that do not result in the excess of the maximum bit rate. This profile limits the available maximum bit rate to 320kb/s for mono, and 512kb/s for two-channel modes.

How to test on a PC

Download Virtualbox and Virtualbox Extension Pack: https://www.virtualbox.org/wiki/Downloads; Install Virtualbox, start it; Install Extension Pack using File → Preferences → Extensions; Create new virtual machine: Linux, Ubuntu (64-bit), 1024 RAM. Do not create a HDD. Navigate to virtual machine settings, in Storage choose Controller: IDE, Empty, press CD icon → Choose virtual optical disk file; Select downloaded bluetooth-dualchannel-test-ubuntu-18.04.1-desktop-amd64.iso; Save and close settings window, start virtual machine; Right-click USB cable icon in the bottom right, select your Bluetooth adapter;

Burn the image to a USB flash drive using Etcher: https://etcher.io/. This operation will delete all existing files on a USB drive. Turn off the PC; Insert USB flash drive, turn on the PC and press boot order button (usually Esc or F12); Select your USB flash drive.

(optional but recommended) Double click on "Btsnoop Dump" script on the desktop. It will start Bluetooth data capture for later analysis. Do not close terminal window. Switch the headphones to pairing mode; Click to the arrow in top right corner, select Bluetooth icon → Bluetooth Settings; Choose your headphones, wait until pairing is complete and close the window; Set Ubuntu volume to about 2/3. Also decrease volume using headset buttons as it could be very loud after pairing. Open "music" folder, play "testrecord1.flac"; (optional but recommended) Close player, close terminal window. This will stop data capture. (optional but recommended) Open Firefox browser, upload data dump (btsnoop_hci.btsnoop on the desktop) to https://btcodecs.valdikss.org.ru/ You can listen to other music in the music folder, or upload your own; Post in this topic your headphone model and test results.

Many note low sound quality and lack of high frequencies when using the standard SBC Bluetooth codec, which is supported by all headphones and other Bluetooth devices. A common recommendation to get better sound quality is to buy devices and headphones with aptX or LDAC codecs supported. These codecs require licensing fees, so devices with them are more expensive.A2DP specification v1.2, which was active from 2007 to 2015, requires all decoders to work correctly with bitrates up to 512 kbps:In the new version of the specification there is no bitrate limitation. It is assumed that modern headphones released after 2015 with EDR can support bitrates up to 730 kbps.For some reason, all currently tested Bluetooth stacks (Linux (PulseAudio), Android, Blackberry and macOS) have artificial restrictions of maximum bitpool parameter, which directly affects the maximum bitrate. But this is not the biggest problem, almost all headphones also limit the maximum bitpool value to 53.As I've already seen in my tests, most devices work fine on a modified Bluetooth stack with a bitrate of 507 kbps, without interrupts and crackling. But such a bitrate will never be negotiated under normal conditions, with stock Bluetooth stacks.High bitrate SBC headphone compatibility test is the easiest to perform on the PC with a Bluetooth adapter. I've prepared Ubuntu image with a modified Bluetooth stack, which can be run as in a virtual machine (by connecting Bluetooth adapter as a USB device inside the virtual machine, it also works with the adapters built into the laptops) or by booting from the USB flash drive. This image uses the following profile: Dual Channel, 8 bands, 16 blocks, Loudness, bitpool 2..41, 44.1 kHz, which provides 485 kbps bitrate.The image supports BIOS/CSM and UEFI booting.There should be no cracklings, audio interruption or other sound distortion in the headphones. If you hear a good high-quality sound, that means your headphones support audio with a bit rate of 485 kbps.If you upload data to the server, please carefully follow the algorithm above. Especially, if you power off the headphones or disconnect after pairing, it's important to connect to the headphones manually from the bluetooth settings, do not allow auto connection!