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

Stefano Sabatini stefano.sabatini-lala
Mon Aug 23 21:48:12 CEST 2010


On date Monday 2010-08-23 20:24:10 +0200, Michael Niedermayer encoded:
> On Sat, Aug 21, 2010 at 12:25:24AM +0200, Stefano Sabatini wrote:
> > 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.
> 
> yes
> but not only that, x channels is ambigous, there can be several layouts
> with x channels

OK now I see, channel_layout contains flags, these the values:
#define CH_FRONT_LEFT             0x00000001
#define CH_FRONT_RIGHT            0x00000002
#define CH_FRONT_CENTER           0x00000004
#define CH_LOW_FREQUENCY          0x00000008
#define CH_BACK_LEFT              0x00000010
#define CH_BACK_RIGHT             0x00000020
#define CH_FRONT_LEFT_OF_CENTER   0x00000040
#define CH_FRONT_RIGHT_OF_CENTER  0x00000080
#define CH_BACK_CENTER            0x00000100
#define CH_SIDE_LEFT              0x00000200
#define CH_SIDE_RIGHT             0x00000400
#define CH_TOP_CENTER             0x00000800
#define CH_TOP_FRONT_LEFT         0x00001000
#define CH_TOP_FRONT_CENTER       0x00002000
#define CH_TOP_FRONT_RIGHT        0x00004000
#define CH_TOP_BACK_LEFT          0x00008000
#define CH_TOP_BACK_CENTER        0x00010000
#define CH_TOP_BACK_RIGHT         0x00020000
#define CH_STEREO_LEFT            0x20000000  ///< Stereo downmix.
#define CH_STEREO_RIGHT           0x40000000  ///< See CH_STEREO_LEFT.

Since they are so much, I'd prefer to keep it as an integer, then when
we will have an options API for doing flags <-> string conversion that
may be used instead.

> 
> [...]
> 
> > > > > 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).
> 
> you surely can use a functional filter to test the filterchain setup.
> So this filter as is is unneeded

1) for testing a functional source and an ff* tool we need an audio
mixer filter, which currently we don't have.

2) even if we'd have the mixer filter, it may be useful to test the
setup of a source with a particular channel layout / sample rate /
sample format which is not necessarily reproducible with a random
source.

For example the ffplay.c source is not registered, having a nullsrc
filter can be useful for testing the setup of an ffplay filterchain
(btw this is also the reason for which I implemented the null video
source).

3) the code is pedagogically useful as example and template

Regards.
-- 
FFmpeg = Faithful and Foolish Multimedia Pacific Efficient Genius



More information about the ffmpeg-devel mailing list