summaryrefslogtreecommitdiff
path: root/libavcodec/libmp3lame.c
diff options
context:
space:
mode:
authorTimothy Gu <timothygu99@gmail.com>2013-11-01 19:43:24 -0700
committerVittorio Giovara <vittorio.giovara@gmail.com>2014-03-31 01:11:16 +0200
commit09fda6bb503dd9ac6ca963e308bdb86114df1294 (patch)
tree764e63aee5405ce50415aed52f231cb5e4a5f9b2 /libavcodec/libmp3lame.c
parent292dbe5e8a95d38c1324b0432fbaca67f8fe4b73 (diff)
downloadffmpeg-09fda6bb503dd9ac6ca963e308bdb86114df1294.tar.gz
libmp3lame: add ABR support
Diffstat (limited to 'libavcodec/libmp3lame.c')
-rw-r--r--libavcodec/libmp3lame.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c
index fbb40321b9..eebc65c44d 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 },
};