[FFmpeg-devel] [PATCH] libmp3lame: set noise shaping & psycho acoustic algorithms quality

Nicolas George nicolas.george
Thu Jul 31 15:53:38 CEST 2008


The attached patch allow to set the quality parameter for noise shaping and
psycho acoustic algorithms (the lame_set_quality function and -q option to
the lame command line tool).

This patch does not change the default behaviour, and does not break the
regression tests.

I think this option is very similar to the LOW / MAIN / LTP selection for
AAC encoding, so I used the same option: -profile. -aq is not the correct
option, since it is mapped, as it should be, to lame_set_VBR_q (-V option to

Since the documentation for lame uses numeric values, I did not add symbolic
constants to the option system.

I considered adding a warning about the crash with lame 3.91, but as lame
3.91 is more than six years old, I thought it was not worth the additional


  Nicolas George
-------------- next part --------------
Index: libavcodec/libmp3lame.c
--- libavcodec/libmp3lame.c	(revision 14485)
+++ libavcodec/libmp3lame.c	(working copy)
@@ -50,8 +50,11 @@
     lame_set_in_samplerate(s->gfp, avctx->sample_rate);
     lame_set_out_samplerate(s->gfp, avctx->sample_rate);
     lame_set_num_channels(s->gfp, avctx->channels);
-    /* lame 3.91 dies on quality != 5 */
-    lame_set_quality(s->gfp, 5);
+    if(avctx->profile == FF_PROFILE_UNKNOWN) {
+	lame_set_quality(s->gfp, 5);
+    } else {
+	lame_set_quality(s->gfp, avctx->profile);
+    }
     /* lame 3.91 doesn't work in mono */
     lame_set_mode(s->gfp, JOINT_STEREO);
     lame_set_brate(s->gfp, avctx->bit_rate/1000);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080731/66de1537/attachment.pgp>

More information about the ffmpeg-devel mailing list