bluez5: improve LHDC v5 codec handling

Tighten LHDC v5 config validation and keep the codec encoder-only: do not add unsupported decode, delay query, or PipeWire-side ABR behavior.

Advertise the LHDC v5 sample rates and S16/S24 formats supported by liblhdcv5, parse the P7 bitrate range from peer capabilities, and initialize liblhdcv5 with the selected min/max bitrate indices. Keep fixed quality choices limited to the currently negotiable local max.
This commit is contained in:
DBeidachazi 2026-07-02 14:01:24 +08:00
parent 4ced2a0ea4
commit 276167a82b
2 changed files with 558 additions and 82 deletions

View file

@ -197,10 +197,26 @@
#define LHDC_V5_VENDOR_ID 0x0000053a
#define LHDC_V5_CODEC_ID 0x4c35
#define LHDC_V5_SAMPLING_FREQ_44100 0x20
#define LHDC_V5_SAMPLING_FREQ_48000 0x10
#define LHDC_V5_SAMPLING_FREQ_96000 0x04
#define LHDC_V5_SAMPLING_FREQ_192000 0x01
#define LHDC_V5_BIT_FMT_24 0x02
#define LHDC_V5_BIT_FMT_16 0x04
/* LHDC v5 P7 bitrate_and_depth byte: bit[7:6] min bitrate,
* bit[5:4] max bitrate, bit[2:0] bit depth.
*/
#define LHDC_V5_MIN_BITRATE_MASK 0xc0
#define LHDC_V5_MIN_BITRATE_64K 0x00
#define LHDC_V5_MIN_BITRATE_160K 0x40
#define LHDC_V5_MIN_BITRATE_256K 0x80
#define LHDC_V5_MIN_BITRATE_400K 0xc0
#define LHDC_V5_MAX_BITRATE_MASK 0x30
#define LHDC_V5_MAX_BITRATE_1000K 0x00
#define LHDC_V5_MAX_BITRATE_400K 0x10
#define LHDC_V5_MAX_BITRATE_500K 0x20
#define LHDC_V5_MAX_BITRATE_900K 0x30
#define LHDC_V5_VERSION_1 0x01
#define LHDC_V5_FRAME_LEN_5MS 0x10
#define LHDC_V5_FEATURE_LL 0x40