PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio
Commits: 7e9e9e27 by Igor V. Kovalenko at 2021-01-21T15:16:19+00:00 bluetooth: allow increasing SBC output bitrate SBC codec decrements bitpool value by fixed amount each time it is asked to reduce output bitrate. This results in reduced audio quality with SBC codec. Implement increase_encoder_bitrate for SBC codec by adding 1 to bitpool value each time encoder bitrate needs to be increased to restore SBC audio quality. While at it, remove bitpool decrement limit to use connection agreed value instead as we will be able to restore quality later. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/474> - - - - - 1 changed file: - src/modules/bluetooth/a2dp-codec-sbc.c Changes: ===================================== src/modules/bluetooth/a2dp-codec-sbc.c ===================================== @@ -36,8 +36,8 @@ #include "a2dp-codec-api.h" #include "rtp.h" -#define SBC_BITPOOL_DEC_LIMIT 32 #define SBC_BITPOOL_DEC_STEP 5 +#define SBC_BITPOOL_INC_STEP 1 struct sbc_info { sbc_t sbc; /* Codec data */ @@ -503,14 +503,20 @@ static size_t reduce_encoder_bitrate(void *codec_info, size_t write_link_mtu) { struct sbc_info *sbc_info = (struct sbc_info *) codec_info; uint8_t bitpool; - /* Check if bitpool is already at its limit */ - if (sbc_info->sbc.bitpool <= SBC_BITPOOL_DEC_LIMIT) + bitpool = PA_MAX(sbc_info->sbc.bitpool - SBC_BITPOOL_DEC_STEP, sbc_info->min_bitpool); + + if (sbc_info->sbc.bitpool == bitpool) return 0; - bitpool = sbc_info->sbc.bitpool - SBC_BITPOOL_DEC_STEP; + set_bitpool(sbc_info, bitpool); + return get_block_size(codec_info, write_link_mtu); +} + +static size_t increase_encoder_bitrate(void *codec_info, size_t write_link_mtu) { + struct sbc_info *sbc_info = (struct sbc_info *) codec_info; + uint8_t bitpool; - if (bitpool < SBC_BITPOOL_DEC_LIMIT) - bitpool = SBC_BITPOOL_DEC_LIMIT; + bitpool = PA_MIN(sbc_info->sbc.bitpool + SBC_BITPOOL_INC_STEP, sbc_info->max_bitpool); if (sbc_info->sbc.bitpool == bitpool) return 0; @@ -682,6 +688,7 @@ const pa_a2dp_codec pa_a2dp_codec_sbc = { .get_read_block_size = get_block_size, .get_write_block_size = get_block_size, .reduce_encoder_bitrate = reduce_encoder_bitrate, + .increase_encoder_bitrate = increase_encoder_bitrate, .encode_buffer = encode_buffer, .decode_buffer = decode_buffer, }; View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/7e9e9e271aebb801a9fd8abe2489f95604c35bc5 -- View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/7e9e9e271aebb801a9fd8abe2489f95604c35bc5 You're receiving this email because of your account on gitlab.freedesktop.org.
_______________________________________________ pulseaudio-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/pulseaudio-commits
