[pulseaudio-discuss] [PATCH v8 07/12] bluetooth: Add A2DP aptX and aptX HD codecs support

Tanu Kaskinen tanuk at iki.fi
Fri Apr 19 08:41:22 UTC 2019


On Sat, 2019-04-06 at 11:16 +0200, Pali Rohár wrote:
> This patch provides support for aptX and aptX HD codecs in bluetooth A2DP
> profile. It uses open source LGPLv2.1+ licensed libopenaptx library which
> can be found at https://github.com/pali/libopenaptx.
> 
> aptX for s24 stereo samples provides fixed 6:1 compression ratio and
> bitrate 352.8 kbit/s, aptX HD provides fixed 4:1 compression ratio and
> bitrate 529.2 kbit/s.
> 
> According to soundexpert research, aptX codec used in bluetooth A2DP is no
> better than SBC High Quality settings. And you cannot hear difference
> between aptX and SBC High Quality, aptX is just a copper-less overpriced
> audio cable.
> 
> aptX HD is high-bitrate version of aptX. It has clearly noticeable increase
> in sound quality (not dramatic though taking into account the increase in
> bitrate).
> 
> http://soundexpert.org/news/-/blogs/audio-quality-of-bluetooth-aptx
> ---
>  configure.ac                            |  36 +++
>  src/Makefile.am                         |   6 +
>  src/modules/bluetooth/a2dp-codec-aptx.c | 445 ++++++++++++++++++++++++++++++++
>  src/modules/bluetooth/a2dp-codec-util.c |   8 +
>  4 files changed, 495 insertions(+)
>  create mode 100644 src/modules/bluetooth/a2dp-codec-aptx.c

> +static bool can_accept_capabilities_common(const a2dp_aptx_t *capabilities, uint32_t vendor_id, uint16_t codec_id) {
> +    if (!(capabilities->frequency & (APTX_SAMPLING_FREQ_16000 | APTX_SAMPLING_FREQ_32000 |
> +                                     APTX_SAMPLING_FREQ_44100 | APTX_SAMPLING_FREQ_48000)))
> +        return false;
> +
> +    if (A2DP_GET_VENDOR_ID(capabilities->info) != vendor_id || A2DP_GET_CODEC_ID(capabilities->info) != codec_id)
> +        return false;
> +
> +    if (!(capabilities->channel_mode & APTX_CHANNEL_MODE_STEREO))

Why is mono support not implemented? Is it a limitation of libopenaptx?
It's not a big shortcoming, but it would be nice to support mono too.

> +static size_t decode_buffer(void *codec_info, const uint8_t *input_buffer, size_t input_size, uint8_t *output_buffer, size_t output_size, size_t *processed) {
> +    struct aptx_context *aptx_c = (struct aptx_context *) codec_info;
> +
> +    const uint8_t *p;
> +    uint8_t *d;
> +    size_t to_write, to_decode;
> +
> +    p = input_buffer;
> +    to_decode = input_size;
> +
> +    d = output_buffer;
> +    to_write = output_size;
> +
> +    while (PA_LIKELY(to_decode > 0)) {

Is it intentional that encode_buffer() checks both to_encode and
to_write in the while loop condition, but decode_buffer() only checks
to_decode? If so, why does encode_buffer() need to be extra careful but
decode_buffer() doesn't?

-- 
Tanu

https://www.patreon.com/tanuk
https://liberapay.com/tanuk



More information about the pulseaudio-discuss mailing list