From patchwork Fri Nov 1 08:51:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Cowgill X-Patchwork-Id: 16057 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E661B448432 for ; Fri, 1 Nov 2019 10:51:50 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BDFF568AA83; Fri, 1 Nov 2019 10:51:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C038A68AA46 for ; Fri, 1 Nov 2019 10:51:44 +0200 (EET) Received: from dummy (unknown [31.205.32.145]) (Authenticated sender: jcowgill@jcowgill.uk) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 48235240009; Fri, 1 Nov 2019 08:51:43 +0000 (UTC) From: James Cowgill To: ffmpeg-devel@ffmpeg.org Date: Fri, 1 Nov 2019 08:51:07 +0000 Message-Id: <20191101085107.20891-1-jcowgill@debian.org> X-Mailer: git-send-email 2.24.0.rc1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/libtwolame: fix mono default bitrate X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: James Cowgill Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 --- libavcodec/libtwolame.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/libtwolame.c b/libavcodec/libtwolame.c index 030f88868f..5ceb3d9f3f 100644 --- a/libavcodec/libtwolame.c +++ b/libavcodec/libtwolame.c @@ -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);