[FFmpeg-devel] [PATCH 2/5] lavfi: add aformat filter
Stefano Sabatini
stefano.sabatini-lala at poste.it
Mon Aug 8 11:39:05 CEST 2011
On date Monday 2011-08-08 11:11:46 +0300, Mina Nagy Zaki encoded:
> ---
> doc/filters.texi | 21 +++++++++
> libavfilter/Makefile | 1 +
> libavfilter/af_aformat.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++
> libavfilter/allfilters.c | 1 +
> 4 files changed, 136 insertions(+), 0 deletions(-)
> create mode 100644 libavfilter/af_aformat.c
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 33d6496..8dc1c15 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -99,6 +99,27 @@ build.
>
> Below is a description of the currently available audio filters.
>
> + at section aformat
> +
> +Convert the input audio to one of the specified formats. The framework will
> +negotiate the most appropriate format to minimize conversions.
> +
> +The filter accepts three lists of formats, separated by ":",
> +"sample_formats:channel_layouts:packing"
> +
> +Elements in each list are separated by "," which has to be escaped in the
> +filtergraph specification.
> +
> +The special parameter "all", in place of a list of elements, signifies all
> +supported formats.
> +
> +Some examples follow:
> + at example
> +aformat=u8\\,s16:mono:packed
> +
> +aformat=s16:mono\\,stereo:all
> + at end example
> +
> @section anull
>
> Pass the audio source unchanged to the output.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 6007fed..865ba1e 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -18,6 +18,7 @@ OBJS = allfilters.o \
>
> OBJS-$(CONFIG_AVCODEC) += avcodec.o
>
> +OBJS-$(CONFIG_AFORMAT_FILTER) += af_aformat.o
> OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o
>
> OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o
> diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
> new file mode 100644
> index 0000000..d3bf96c
> --- /dev/null
> +++ b/libavfilter/af_aformat.c
> @@ -0,0 +1,113 @@
> +/*
> + * Copyright (c) 2011 Mina Nagy Zaki
> + *
> + * 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
> + * format and noformat audio filters
> + */
> +
> +#include "libavutil/audioconvert.h"
> +#include "avfilter.h"
> +#include "internal.h"
> +
> +typedef struct {
> + AVFilterFormats *formats, *chlayouts, *packing;
> +} AFormatContext;
> +
> +static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
> +{
> + AFormatContext * const aformat = ctx->priv;
> + char *arg, *fmt_str;
> + int64_t fmt;
> +
> + arg = strsep(&args, ":");
> + if (!arg) goto arg_fail;
> + if (!strcmp(arg, "all")) {
> + aformat->formats = avfilter_all_formats(AVMEDIA_TYPE_AUDIO);
> + } else {
> + while (fmt_str = strsep(&arg, ",")) {
> + fmt = ff_parse_sample_format(fmt_str, ctx);
> + if (fmt == -1) return AVERROR(EINVAL);
if ((fmt = ff_parse_sample_format(fmt_str, ctx)) < 0)
return ret;
better to avoid custom error code values
Same below, looks fine otherwise.
[...]
--
FFmpeg = Fabulous and Frightening Majestic Proud Egregious Generator
More information about the ffmpeg-devel
mailing list