[FFmpeg-devel] [PATCH 3/5] lavfi: add asrc_abuffer - audio source buffer filter

Mina Nagy Zaki mnzaki at gmail.com
Mon Aug 8 17:38:57 CEST 2011


On Mon, Aug 08, 2011 at 05:18:52PM +0200, Stefano Sabatini wrote:
> On date Monday 2011-08-08 11:11:47 +0300, Mina Nagy Zaki encoded:
> > Originally based on code by Stefano Sabatini and S. N. Hemanth
> > ---
> >  doc/filters.texi           |   44 ++++++
> >  libavfilter/Makefile       |    2 +
> >  libavfilter/allfilters.c   |    1 +
> >  libavfilter/asrc_abuffer.c |  368 ++++++++++++++++++++++++++++++++++++++++++++
> >  libavfilter/asrc_abuffer.h |   81 ++++++++++
> >  5 files changed, 496 insertions(+), 0 deletions(-)
> >  create mode 100644 libavfilter/asrc_abuffer.c
> >  create mode 100644 libavfilter/asrc_abuffer.h
> > 
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index 8dc1c15..53017b2 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> [...]
> > +static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
> > +{
> > +    ABufferSourceContext *abuffer = ctx->priv;
> > +    char *arg, chlayout_str[16];
> > +
> > +    arg = strsep(&args, ":");
> > +    if (!arg) goto arg_fail;
> > +    abuffer->sample_rate = ff_parse_sample_rate(arg, ctx);
> > +    if (abuffer->sample_rate == -1) return AVERROR(EINVAL);
> > +
> > +    arg = strsep(&args, ":");
> > +    if (!arg) goto arg_fail;
> > +    abuffer->sample_fmt = ff_parse_sample_format(arg, ctx);
> > +    if (abuffer->sample_fmt == -1) return AVERROR(EINVAL);
> > +
> > +    arg = strsep(&args, ":");
> > +    if (!arg) goto arg_fail;
> > +    abuffer->channel_layout = ff_parse_channel_layout(arg, ctx);
> > +    if (abuffer->channel_layout == -1) return AVERROR(EINVAL);
> > +
> > +    arg = strsep(&args, ":");
> > +    if (!arg) goto arg_fail;
> > +    abuffer->planar = ff_parse_packing_format(arg, ctx);
> > +    if (abuffer->planar == -1) return AVERROR(EINVAL);
> 
> as already told in another mail, returning -1 is ugly, just return
> AVERROR(EINVAL) and check on <0.
> Alternatively:
> int ff_parse_sample_rate(int &sample_rate, arg, log_ctx);
> 
> i.e.: you return an error code and put the resulting thing in the
> passed pointer (easier in case you don't have to return an int,
> e.g. if you return an unsigned, more generic).

Fixed.

> [...]
> 
> Sounds fine otherwise, I assume it has been tested with
> mid-stream-format-changing streams.

Yeah, I did a decent amount of testing and it works as expected.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-lavfi-add-asrc_abuffer-audio-source-buffer-filter.patch
Type: text/x-diff
Size: 19829 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110808/a3b98ec0/attachment.bin>


More information about the ffmpeg-devel mailing list