[FFmpeg-devel] [PATCH] Allow setting mode MONO in libmp3lame if the library is greater than 3.97

Thierry Foucu tfoucu
Fri Aug 13 19:00:39 CEST 2010


On Fri, Aug 13, 2010 at 6:07 AM, Aurelien Jacobs <aurel at gnuage.org> wrote:

> On Thu, Aug 12, 2010 at 10:33:02PM -0700, Thierry Foucu wrote:
> > Hi,
> >
> > for a while we are using lame 3.97+ in mono and stereo mode in mencoder,
> and
> > I noticed that ffmpeg sets always the mode to JOINT_STEREO.
> >
> > The patch will check lame version and if greater then 3.97, it will set
> the
> > mode to MONO or JOINT_STEREO
> >
> > Index: libavcodec/libmp3lame.c
> > ===================================================================
> > --- libavcodec/libmp3lame.c (revision 24791)
> > +++ libavcodec/libmp3lame.c (working copy)
> > @@ -55,8 +55,18 @@
> >      } else {
> >          lame_set_quality(s->gfp, avctx->compression_level);
> >      }
> > -    /* lame 3.91 doesn't work in mono */
> > -    lame_set_mode(s->gfp, JOINT_STEREO);
> > +    lame_version_t lame_version;
> > +    get_lame_version_numerical(&lame_version);
> > +    if (lame_version.major <= 3 && lame_version.minor < 97) {
> > +        /* lame 3.91 doesn't work in mono */
> > +        lame_set_mode(s->gfp, JOINT_STEREO);
> > +    } else {
>
> > +        if (s->stereo) {
> > +          lame_set_mode(s->gfp, JOINT_STEREO);
> > +        } else {
> > +          lame_set_mode(s->gfp, MONO);
> > +        }
>
> Inconsistent indentation, and it would be simpler this way:
>  lame_set_mode(s->gfp, s->stereo ? JOINT_STEREO : MONO);
>
>
Patch updated. Make test passed as well.
If patch applied, I will send another patch with the indentation corrected.

Index: libavcodec/libmp3lame.c
===================================================================
--- libavcodec/libmp3lame.c (revision 24791)
+++ libavcodec/libmp3lame.c (working copy)
@@ -39,6 +39,7 @@
 static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
 {
     Mp3AudioContext *s = avctx->priv_data;
+    lame_version_t lame_version;

     if (avctx->channels > 2)
         return -1;
@@ -55,8 +56,13 @@
     } else {
         lame_set_quality(s->gfp, avctx->compression_level);
     }
+    get_lame_version_numerical(&lame_version);
+    if (lame_version.major <= 3 && lame_version.minor < 97) {
     /* lame 3.91 doesn't work in mono */
     lame_set_mode(s->gfp, JOINT_STEREO);
+    } else {
+        lame_set_mode(s->gfp, s->stereo? JOINT_STEREO : MONO);
+    }
     lame_set_brate(s->gfp, avctx->bit_rate/1000);
     if(avctx->flags & CODEC_FLAG_QSCALE) {
         lame_set_brate(s->gfp, 0);




> Aurel
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
>
-------------- next part --------------
Index: libavcodec/libmp3lame.c
===================================================================
--- libavcodec/libmp3lame.c	(revision 24791)
+++ libavcodec/libmp3lame.c	(working copy)
@@ -39,6 +39,7 @@
 static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
 {
     Mp3AudioContext *s = avctx->priv_data;
+    lame_version_t lame_version;
 
     if (avctx->channels > 2)
         return -1;
@@ -55,8 +56,13 @@
     } else {
         lame_set_quality(s->gfp, avctx->compression_level);
     }
+    get_lame_version_numerical(&lame_version);
+    if (lame_version.major <= 3 && lame_version.minor < 97) {
     /* lame 3.91 doesn't work in mono */
     lame_set_mode(s->gfp, JOINT_STEREO);
+    } else {
+        lame_set_mode(s->gfp, s->stereo? JOINT_STEREO : MONO);
+    }
     lame_set_brate(s->gfp, avctx->bit_rate/1000);
     if(avctx->flags & CODEC_FLAG_QSCALE) {
         lame_set_brate(s->gfp, 0);



More information about the ffmpeg-devel mailing list