[FFmpeg-devel] [PATCH] avcodec/libmp3lame: add ABR support
Timothy Gu
timothygu99 at gmail.com
Thu Oct 31 04:37:17 CET 2013
On Oct 30, 2013 8:49 AM, "Michael Niedermayer" <michaelni at gmx.at> wrote:
>
> On Thu, Oct 24, 2013 at 08:19:48PM -0700, Timothy Gu wrote:
> > Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
> > ---
> > doc/encoders.texi | 7 ++++++-
> > libavcodec/libmp3lame.c | 11 +++++++++--
> > 2 files changed, 15 insertions(+), 3 deletions(-)
> >
> > diff --git a/doc/encoders.texi b/doc/encoders.texi
> > index 0c01364..2c7d9cb 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..ac40674 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;
> > @@ -119,8 +120,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(gfp, vbr_abr);
> > + lame_set_VBR_mean_bitrate_kbps(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 */
>
> doesnt build:
> In file included from libavcodec/libmp3lame.c:1:
> libavcodec/libmp3lame.c:125:30: error: use of undeclared identifier 'gfp'
> lame_set_VBR(gfp, vbr_abr);
> ^
> libavcodec/libmp3lame.c:126:48: error: use of undeclared identifier 'gfp'
> lame_set_VBR_mean_bitrate_kbps(gfp, avctx->bit_rate /
1000);
Oops forgot to add s->
[...]
Timothy
More information about the ffmpeg-devel
mailing list