[pulseaudio-discuss] [PATCH v11 08/11] bluetooth: Add more variants of SBC codec

ValdikSS iam at valdikss.org.ru
Tue Jun 11 21:09:56 UTC 2019


On 10.06.2019 23:20, Pali Rohár wrote:
> On Monday 10 June 2019 20:37:43 ValdikSS wrote:
>> On 10.06.2019 17:53, Pali Rohár wrote:
>>> On Wednesday 05 June 2019 22:42:49 ValdikSS wrote:
>>>> On 02.06.2019 18:25, Pali Rohár wrote:
>>>>> Specify configuration for Low, Middle, High and Ultra High Quality of SBC
>>>>> codec. SBC codec in Ultra High Quality has higher quality than aptX.
>>>>>
>>>>> Automatic Quality mode matches configuration of SBC codec which was used
>>>>> before this change. Which means that it accept configuration between Low
>>>>> and High quality.
>>>>>
>>>>> Current SBC code was extended to allow definitions of arbitrary
>>>>> configuration variants of SBC codec parameters.
>>>>> ---
>>>> ...
>>>>> +
>>>>> +/* SBC Ultra High Quality, calculated to minimize wasted bytes and to be below max possible 512 kbps */
>>>>> +static const a2dp_sbc_t sbc_uhq1_caps_table[] = {
>>>>> +    FIXED_SBC_CAPS(SBC_CHANNEL_MODE_JOINT_STEREO, SBC_SAMPLING_FREQ_44100, 76), /* 454.8 kbps */
>>>>> +    FIXED_SBC_CAPS(SBC_CHANNEL_MODE_JOINT_STEREO, SBC_SAMPLING_FREQ_48000, 76), /* 495   kbps */
>>>>> +    FIXED_SBC_CAPS(SBC_CHANNEL_MODE_STEREO,       SBC_SAMPLING_FREQ_44100, 76), /* 452   kbps */
>>>>> +    FIXED_SBC_CAPS(SBC_CHANNEL_MODE_STEREO,       SBC_SAMPLING_FREQ_48000, 76), /* 492   kbps */
>>>>> +};
>>>>> +static const a2dp_sbc_t sbc_uhq2_caps_table[] = {
>>>>> +    FIXED_SBC_CAPS(SBC_CHANNEL_MODE_DUAL_CHANNEL, SBC_SAMPLING_FREQ_44100, 38), /* 452   kbps */
>>>>> +    FIXED_SBC_CAPS(SBC_CHANNEL_MODE_DUAL_CHANNEL, SBC_SAMPLING_FREQ_48000, 38), /* 492   kbps */
>>>>> +    FIXED_SBC_CAPS(SBC_CHANNEL_MODE_MONO,         SBC_SAMPLING_FREQ_44100, 37), /* 226   kbps */
>>>>> +    FIXED_SBC_CAPS(SBC_CHANNEL_MODE_MONO,         SBC_SAMPLING_FREQ_48000, 37), /* 246   kbps */
>>>>> +};
>>>> ...
>>>>
>>>> While working on Android SBC HD patch, allowing bitpools higher than 53 unfortunately introduced problems with some headphones. All major OS have maximum bitpool locked to 53, and it seems there's a reason for that: compatibility with broken devices. I had to revert bitpool increasing patch in the final release and implement only Dual Channel patch.
>>> It is a problem if pulseaudio/bluez exports one SEP with fixed SBC
>>> bitpool 76 (min = max = 76) and another SEP with dynamic SBC bitpool
>>> range 2-53?
>> Probably not a problem, I'm not sure.
> Do you have test devices which have those "compatibility" problems?


Unfortunately not, but it breaks at least Denon AVR-X2100W receiver

https://review.lineageos.org/c/LineageOS/android_packages_apps_Bluetooth/+/229310#message-32480b69e039db9dd0fffdc68216ac1bdb70704e


>
>>>> Some notes regarding UHQ profiles:
>>>> 1. It would be great to use bitpool 38 for Dual Channel 2-DH5 (EDR 2 mbit/s) and bitpool 47 for Dual Channel 3-DH5 (edr 3 mbit/s), automatically detecting link speed. It pushes bitrate even further for 3-DH5 compatible devices (551 kbit/s for 44.1 kHz, 5 audio frames) and makes SBC on par with aptX HD. That's what I did for Android patch.
>>> How can be detect link speed? Is there some kernel API for it? Or deduce
>>> it from socket send buffer size?
>> Android exports EDR speed into media encoder, I don't know of Linux BlueZ stack much. Can you determine link MTU from inside the PulseAudio?
> Yes, in pulseaudio we have access to socket and MTU can be determined...
> Pulseaudio A2DP codecs already use it for configuring send buffer size.
>
>> If you can, you can use that: if MTU is more than 679, than it's most probably 3-DH5 mode (EDR 3mbit/s with 5 slots).
>>>> 2. It's possible to introduce another "extreme quality" profile for 2-DH5 (EDR 2 mbit/s) Dual Channel, with 648 kbps @ 48 khz, 595.4 kbps @ 44.1 khz (Up to 3 frames for 2DH5).
>>>>
>>>> By the way, SBC HD patch has been merged into LineageOS 15.1 (Android 8) and LineageOS 16.0 (Android 9). If you use LineageOS, you can now enable Dual Channel in Bluetooth device settings (it's called HD Audio: SBC HD).
>>>>
>>>> Besides my old SBC HD bitrate calculator (https://btcodecs.valdikss.org.ru/sbc-bitrate-calculator/), I made in-browser realtime SBC and aptX/HD encoder, with frequency spectrum analyzer. You can now easily experiment with Bluetooth codecs quality:
>>>> https://btcodecs.valdikss.org.ru/sbc-encoder/
>>>>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 868 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20190612/f57d3cf7/attachment.sig>


More information about the pulseaudio-discuss mailing list