Re: [FFmpeg-devel] [PATCH] avcodec/libtwolame: fix mono default bitrate

2019-11-01 Thread Moritz Barsnick
On Fri, Nov 01, 2019 at 08:51:07 +, James Cowgill wrote:
> 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:

I also just noticed this, after update to twolame-0.4.0.

Does this imply that the native mp2 encoder is creating invalid mono
streams? (It too apparently defaults to 384k, even in mono mode, and
allows setting it.)

Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/libtwolame: fix mono default bitrate

2019-11-01 Thread Paul B Mahol
applied

On 11/1/19, James Cowgill  wrote:
> 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 ? 16 : 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 ? 8 : 192000;
> +else
> +avctx->bit_rate = avctx->sample_rate < 28000 ? 16 : 384000;
> +}
>
>  if (avctx->flags & AV_CODEC_FLAG_QSCALE || !avctx->bit_rate) {
>  twolame_set_VBR(s->glopts, TRUE);
> --
> 2.24.0.rc1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avcodec/libtwolame: fix mono default bitrate

2019-11-01 Thread James Cowgill
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 ? 16 : 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 ? 8 : 192000;
+else
+avctx->bit_rate = avctx->sample_rate < 28000 ? 16 : 384000;
+}
 
 if (avctx->flags & AV_CODEC_FLAG_QSCALE || !avctx->bit_rate) {
 twolame_set_VBR(s->glopts, TRUE);
-- 
2.24.0.rc1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".