[FFmpeg-devel] [PATCH 3/5] lavfi: add asrc_abuffer - audio source buffer filter
Stefano Sabatini
stefano.sabatini-lala at poste.it
Sun Aug 14 11:03:43 CEST 2011
On date Monday 2011-08-08 18:38:57 +0300, Mina Nagy Zaki encoded:
> 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.
[...]
> +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 < 0) return AVERROR(EINVAL);
> +
> + arg = strsep(&args, ":");
> + if (!arg) goto arg_fail;
> + abuffer->sample_fmt = ff_parse_sample_format(arg, ctx);
> + if (abuffer->sample_fmt < 0) return AVERROR(EINVAL);
> +
> + arg = strsep(&args, ":");
> + if (!arg) goto arg_fail;
> + abuffer->channel_layout = ff_parse_channel_layout(arg, ctx);
> + if (abuffer->channel_layout < 0) return AVERROR(EINVAL);
> +
> + arg = strsep(&args, ":");
> + if (!arg) goto arg_fail;
> + abuffer->planar = ff_parse_packing_format(arg, ctx);
> + if (abuffer->planar < 0) return AVERROR(EINVAL);
Wrong patch?
--
FFmpeg = Fabulous and Fostering Mystic Prodigious Elitarian Guru
More information about the ffmpeg-devel
mailing list