[FFmpeg-cvslog] libmp3lame: add ABR support

Timothy Gu git at videolan.org
Mon Mar 31 02:55:42 CEST 2014


ffmpeg | branch: master | Timothy Gu <timothygu99 at gmail.com> | Fri Nov  1 19:43:24 2013 -0700| [09fda6bb503dd9ac6ca963e308bdb86114df1294] | committer: Vittorio Giovara

libmp3lame: add ABR support

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=09fda6bb503dd9ac6ca963e308bdb86114df1294
---

 libavcodec/libmp3lame.c |   11 +++++++++--
 libavcodec/version.h    |    2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c
index fbb4032..eebc65c 100644
--- a/libavcodec/libmp3lame.c
+++ b/libavcodec/libmp3lame.c
@@ -49,6 +49,7 @@ typedef struct LAMEContext {
     int buffer_size;
     int reservoir;
     int joint_stereo;
+    int abr;
     float *samples_flt[2];
     AudioFrameQueue afq;
     AVFloatDSPContext fdsp;
@@ -114,8 +115,13 @@ static av_cold int mp3lame_encode_init(AVCodecContext *avctx)
         lame_set_VBR(s->gfp, vbr_default);
         lame_set_VBR_quality(s->gfp, avctx->global_quality / (float)FF_QP2LAMBDA);
     } else {
-        if (avctx->bit_rate)                // CBR
-            lame_set_brate(s->gfp, avctx->bit_rate / 1000);
+        if (avctx->bit_rate) {
+            if (s->abr) {                   // ABR
+                lame_set_VBR(s->gfp, vbr_abr);
+                lame_set_VBR_mean_bitrate_kbps(s->gfp, avctx->bit_rate / 1000);
+            } else                          // CBR
+                lame_set_brate(s->gfp, avctx->bit_rate / 1000);
+        }
     }
 
     /* do not get a Xing VBR header frame from LAME */
@@ -262,6 +268,7 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
 static const AVOption options[] = {
     { "reservoir", "Use bit reservoir.", OFFSET(reservoir), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, AE },
     { "joint_stereo", "Use joint stereo.", OFFSET(joint_stereo), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, AE },
+    { "abr", "Use ABR", OFFSET(abr), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AE },
     { NULL },
 };
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index faf85b3..99e4303 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 55
 #define LIBAVCODEC_VERSION_MINOR 41
-#define LIBAVCODEC_VERSION_MICRO  1
+#define LIBAVCODEC_VERSION_MICRO  2
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list