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

Thierry Foucu tfoucu
Fri Aug 13 07:33:02 CEST 2010


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);
+        }
+    }
     lame_set_brate(s->gfp, avctx->bit_rate/1000);
     if(avctx->flags & CODEC_FLAG_QSCALE) {
         lame_set_brate(s->gfp, 0);
-------------- next part --------------
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);
+        }
+    }
     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