[FFmpeg-devel] [PATCH] Add asrc_anullsrc - null audio source

Stefano Sabatini stefano.sabatini-lala
Sat Aug 21 00:25:24 CEST 2010


On date Friday 2010-08-20 01:06:04 +0200, Michael Niedermayer encoded:
> On Fri, Aug 20, 2010 at 01:03:27AM +0200, Stefano Sabatini wrote:
[...]
> > > > +/**
> > > > + * @file
> > > > + * null audio source
> > > > + */
> > > > +
> > > > +#include "avfilter.h"
> > > > +
> > > > +typedef struct {
> > > > +    int64_t channel_layout;
> > > > +    int64_t sample_rate;
> > > > +} ANullContext;
> > > > +
> > > > +static int init(AVFilterContext *ctx, const char *args, void *opaque)
> > > > +{
> > > > +    ANullContext *priv = ctx->priv;
> > > > +
> > > > +    priv->sample_rate = 44100;
> > > > +    priv->channel_layout = CH_LAYOUT_STEREO;
> > > > +
> > > > +    if (args)
> > > > +        sscanf(args, "%ld:%ld", &priv->sample_rate, &priv->channel_layout);
> > > 
> > > reading channel layout like this is maybe not ideal
> > 
> > Please elaborate.
> 
> 7
> 
> you want an english awnser instead of a number?
> the user also wants to specify his speaker configuration be listing
> speakers and not just their number

I suppose this means that the user should be able to specify a string
rather than a number? I had the same concern, but I'm not sure we have
an API right now for doing the string <-> number mapping.
 
> > > > +
> > > > +    if (priv->sample_rate < 0 || priv->channel_layout < 3) {
> > > > +        av_log(ctx, AV_LOG_ERROR,
> > > > +               "Invalid value for sample format or channel layout .\n");
> > > > +        return AVERROR(EINVAL);
> > > > +    }
> > > > +
> > > > +    return 0;
> > > > +}
> > > > +
> > > > +static int config_props(AVFilterLink *outlink)
> > > > +{
> > > > +    ANullContext *priv = outlink->src->priv;
> > > > +
> > > > +    outlink->sample_rate = priv->sample_rate;
> > > > +    outlink->channel_layout = priv->channel_layout;
> > > > +
> > > > +    av_log(outlink->src, AV_LOG_INFO, "sample_rate:%ld channel_layout:%ld\n",
> > > > +           priv->sample_rate, priv->channel_layout);
> > > > +
> > > > +    return 0;
> > > > +}
> > > > +
> > > 
> > > > +static int request_frame(AVFilterLink *link)
> > > > +{
> > > > +    return -1;
> > > > +}
> > > 
> > > this appears a little pointless whats the point of this filter then if it
> > > generates no output
> > 
> > To test the setup of a filterchain, e.g. with graph2dot.
> 
> and why does the filter only that and not work like a real one?

Because it is supposed to be used only for testing the filterchain
setup, and so the simpler it is the better it is (note that this is
the corresponding of the nullsrc video source).

Regards.
-- 
FFmpeg = Fierce and Formidable Moronic Plastic Explosive Goblin



More information about the ffmpeg-devel mailing list