[FFmpeg-devel] [PATCH] Add asrc_anullsrc - null audio source
Michael Niedermayer
michaelni
Fri Aug 20 01:06:04 CEST 2010
On Fri, Aug 20, 2010 at 01:03:27AM +0200, Stefano Sabatini wrote:
> On date Friday 2010-08-20 00:41:57 +0200, Michael Niedermayer encoded:
> > On Thu, Aug 19, 2010 at 06:08:21AM -0700, S.N. Hemanth Meenakshisundaram wrote:
> > > Null audio source and doc
> > >
> > > ---
> > > doc/filters.texi | 19 ++++++++++
> > > libavfilter/Makefile | 1 +
> > > libavfilter/allfilters.c | 1 +
> > > libavfilter/asrc_anullsrc.c | 82 +++++++++++++++++++++++++++++++++++++++++++
> > > 4 files changed, 103 insertions(+), 0 deletions(-)
> > > create mode 100644 libavfilter/asrc_anullsrc.c
> > >
> > >
> > >
> >
> > > doc/filters.texi | 19 ++++++++++
> > > libavfilter/Makefile | 1
> > > libavfilter/allfilters.c | 1
> > > libavfilter/asrc_anullsrc.c | 82 ++++++++++++++++++++++++++++++++++++++++++++
> > > 4 files changed, 103 insertions(+)
> > > 6ef0b890e7e28a23fb16be68cec03423aa1c688c 0001-Add-asrc_anullsrc-null-audio-source.patch
> > > diff --git a/doc/filters.texi b/doc/filters.texi
> > > index 92d8814..7dd3120 100644
> > > --- a/doc/filters.texi
> > > +++ b/doc/filters.texi
> > > @@ -303,6 +303,25 @@ Since the sample format with name "s16" corresponds to the number
> > > abuffer=1
> > > @end example
> > >
> > > + at section anullsrc
> > > +
> > > +Null audio source, never return audio frames. It is mainly useful as a
> > > +template and to be employed in analysis / debugging tools.
> > > +
> > > +It accepts as optional parameter a string of the form
> > > + at var{sample_rate}:@var{channel_layout}, where @var{sample_rate} and
> > > + at var{channel_layout} specify the properties of the configured audio source.
> > > +
> > > +The default values of @var{sample_rate} and @var{channel_layout} are
> > > +respectively 44100 and 3 respectively. A channel layout value of 3
> > > +corresponds to CH_LAYOUT_STEREO (check the channel_layout_map definition in
> > > + at file{libavcodec/audioconvert.h}).
> > > +
> > > + at example
> > > +anullsrc=48000:4
> > > + at end example
> > > +will set the sample rate to 48000 Hz and the channel layout to CH_LAYOUT_MONO.
> > > +
> > > @c man end AUDIO SOURCES
> > >
> > > @chapter Video Sources
> > > diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> > > index 5396434..beb8be8 100644
> > > --- a/libavfilter/Makefile
> > > +++ b/libavfilter/Makefile
> > > @@ -34,6 +34,7 @@ OBJS-$(CONFIG_UNSHARP_FILTER) += vf_unsharp.o
> > > OBJS-$(CONFIG_VFLIP_FILTER) += vf_vflip.o
> > >
> > > OBJS-$(CONFIG_ABUFFER_FILTER) += asrc_abuffer.o
> > > +OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o
> > >
> > > OBJS-$(CONFIG_BUFFER_FILTER) += vsrc_buffer.o
> > > OBJS-$(CONFIG_COLOR_FILTER) += vf_pad.o
> > > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> > > index 8f4124c..3460c29 100644
> > > --- a/libavfilter/allfilters.c
> > > +++ b/libavfilter/allfilters.c
> > > @@ -54,6 +54,7 @@ void avfilter_register_all(void)
> > > REGISTER_FILTER (VFLIP, vflip, vf);
> > >
> > > REGISTER_FILTER (ABUFFER, abuffer, asrc);
> > > + REGISTER_FILTER (ANULLSRC, anullsrc, asrc);
> > >
> > > REGISTER_FILTER (BUFFER, buffer, vsrc);
> > > REGISTER_FILTER (COLOR, color, vsrc);
> > > diff --git a/libavfilter/asrc_anullsrc.c b/libavfilter/asrc_anullsrc.c
> > > new file mode 100644
> > > index 0000000..9b2096f
> > > --- /dev/null
> > > +++ b/libavfilter/asrc_anullsrc.c
> > > @@ -0,0 +1,82 @@
> > > +/*
> > > + * This file is part of FFmpeg.
> > > + *
> > > + * FFmpeg is free software; you can redistribute it and/or
> > > + * modify it under the terms of the GNU Lesser General Public
> > > + * License as published by the Free Software Foundation; either
> > > + * version 2.1 of the License, or (at your option) any later version.
> > > + *
> > > + * FFmpeg is distributed in the hope that it will be useful,
> > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > > + * Lesser General Public License for more details.
> > > + *
> > > + * You should have received a copy of the GNU Lesser General Public
> > > + * License along with FFmpeg; if not, write to the Free Software
> > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> > > + */
> > > +
> > > +/**
> > > + * @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
>
> > > +
> > > + 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?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100820/dd1865b5/attachment.pgp>
More information about the ffmpeg-devel
mailing list