1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/libtwolame: fix mono default bitrate

As of libtwolame 0.4.0, 384 kbps is not accepted as a valid bitrate
for encoding mono audio and the maximum bitrate is now halved to 192
kbps to comply with the MP2 standard. Example error:

    twolame_init_params(): 384kbps is an invalid bitrate for mono encoding.

Adjust the default bitrate calculation to take this into account.

Signed-off-by: James Cowgill <jcowgill@debian.org>
This commit is contained in:
James Cowgill 2019-11-01 08:51:07 +00:00 committed by Paul B Mahol
parent 2dd71bf95e
commit bb718d11ed

View File

@ -78,8 +78,12 @@ static av_cold int twolame_encode_init(AVCodecContext *avctx)
twolame_set_in_samplerate(s->glopts, avctx->sample_rate);
twolame_set_out_samplerate(s->glopts, avctx->sample_rate);
if (!avctx->bit_rate)
avctx->bit_rate = avctx->sample_rate < 28000 ? 160000 : 384000;
if (!avctx->bit_rate) {
if ((s->mode == TWOLAME_AUTO_MODE && avctx->channels == 1) || s->mode == TWOLAME_MONO)
avctx->bit_rate = avctx->sample_rate < 28000 ? 80000 : 192000;
else
avctx->bit_rate = avctx->sample_rate < 28000 ? 160000 : 384000;
}
if (avctx->flags & AV_CODEC_FLAG_QSCALE || !avctx->bit_rate) {
twolame_set_VBR(s->glopts, TRUE);