[FFmpeg-devel] [PATCH 3/3] avcodec/libmp3lame: add ABR support
Hendrik Leppkes
h.leppkes at gmail.com
Thu Oct 24 08:58:58 CEST 2013
On Thu, Oct 24, 2013 at 6:01 AM, Timothy Gu <timothygu99 at gmail.com> wrote:
> Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
> ---
> doc/encoders.texi | 7 ++++++-
> libavcodec/libmp3lame.c | 6 ++++++
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index a96c1fc..fc44f3a 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -509,7 +509,7 @@ The following options are supported by the libmp3lame wrapper. The
>
> @table @option
> @item b (@emph{-b})
> -Set bitrate expressed in bits/s for CBR. LAME @code{bitrate} is
> +Set bitrate expressed in bits/s for CBR or ABR. LAME @code{bitrate} is
> expressed in kilobits/s.
>
> @item q (@emph{-V})
> @@ -531,6 +531,11 @@ has this enabled by default, but can be overriden by use
> Enable the encoder to use (on a frame by frame basis) either L/R
> stereo or mid/side stereo. Default value is 1.
>
> + at item abr (@emph{--abr})
> +Enable the encoder to use ABR when set to 1. The @command{lame}
> + at option{--abr} sets the target bitrate, while this options only
> +tells FFmpeg to use ABR still relies on @option{b} to set bitrate.
> +
> @end table
>
> @section libopencore-amrnb
> diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c
> index 0fb9c6a..9c46044 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;
> @@ -121,6 +122,10 @@ static av_cold int mp3lame_encode_init(AVCodecContext *avctx)
> } else {
> if (avctx->bit_rate) // CBR
> lame_set_brate(s->gfp, avctx->bit_rate / 1000);
> + else if (s->abr) { // ABR
> + lame_set_VBR(gfp, vbr_abr);
> + lame_set_VBR_mean_bitrate_kbps(gfp, avctx->bit_rate / 1000);
> + }
> }
How would it ever reach the ABR case?
bit_rate will be set for ABR as well, so it'll always enter the CBR
case - the ABR check should probably be on top of the pure bit_rate
check.
>
> /* do not get a Xing VBR header frame from LAME */
> @@ -265,6 +270,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 },
> };
>
> --
> 1.8.1.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list