On 05/09/2012 03:13 AM, Anton Khirnov wrote:
> ---
> configure | 2 +-
> doc/filters.texi | 6 ++
> libavfilter/Makefile | 5 +-
> libavfilter/af_resample.c | 220
> +++++++++++++++++++++++++++++++++++++++++++++
> libavfilter/allfilters.c | 4 +
> 5 files changed, 234 insertions(+), 3 deletions(-)
> create mode 100644 libavfilter/af_resample.c
>
> diff --git a/configure b/configure
> index 4b1e551..b132bff 100755
> --- a/configure
> +++ b/configure
> @@ -1536,7 +1536,7 @@ yadif_filter_deps="gpl"
>
> # libraries
> avdevice_deps="avcodec avformat"
> -avfilter_deps="swscale"
> +avfilter_deps="avresample swscale"
> avformat_deps="avcodec"
>
> # programs
> diff --git a/doc/filters.texi b/doc/filters.texi
> index dbcc86a..8eff84a 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -111,6 +111,12 @@ Below is a description of the currently available audio
> filters.
>
> Pass the audio source unchanged to the output.
>
> +@section resample
> +Convert the audio sample format, sample rate and channel layout. This filter
> is
> +not meant to be used directly, it is inserted automatically by libavfilter
> +whenever conversion is needed. Use the @var{aformat} filter to force a
> specific
> +conversion.
> +
> @c man end AUDIO FILTERS
>
> @chapter Audio Sources
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 49a47d3..342f4a9 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -1,5 +1,5 @@
> NAME = avfilter
> -FFLIBS = avutil swscale
> +FFLIBS = avresample avutil swscale
> FFLIBS-$(CONFIG_MOVIE_FILTER) += avformat avcodec
>
> HEADERS = avfilter.h \
> @@ -9,7 +9,8 @@ HEADERS = avfilter.h
> \
> version.h \
> vsrc_buffer.h \
>
> -OBJS = allfilters.o \
> +OBJS = af_resample.o \
> + allfilters.o \
> audio.o \
> avfilter.o \
> avfiltergraph.o \
> diff --git a/libavfilter/af_resample.c b/libavfilter/af_resample.c
> new file mode 100644
> index 0000000..0d6591d
> --- /dev/null
> +++ b/libavfilter/af_resample.c
> @@ -0,0 +1,220 @@
> +/*
> + *
> + * This file is part of Libav.
> + *
> + * Libav 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.
> + *
> + * Libav 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 Libav; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> + */
> +
> +/**
> + * @file
> + * sample format and channel layout conversion audio filter
> + */
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/avstring.h"
> +#include "libavutil/mathematics.h"
> +#include "libavutil/opt.h"
> +
> +#include "libavresample/avresample.h"
> +
> +#include "audio.h"
> +#include "avfilter.h"
> +#include "internal.h"
> +
> +typedef struct ResampleContext {
> + AVAudioResampleContext *avr;
> +
> + int64_t next_pts;
> +} ResampleContext;
> +
> +static av_cold void uninit(AVFilterContext *ctx)
> +{
> + ResampleContext *s = ctx->priv;
> +
> + if (s->avr) {
> + avresample_close(s->avr);
> + avresample_free(&s->avr);
> + }
> +}
> +
> +static int query_formats(AVFilterContext *ctx)
> +{
> + AVFilterLink *inlink = ctx->inputs[0];
> + AVFilterLink *outlink = ctx->outputs[0];
> +
> + AVFilterFormats *in_formats =
> avfilter_all_formats(AVMEDIA_TYPE_AUDIO);
> + AVFilterFormats *out_formats =
> avfilter_all_formats(AVMEDIA_TYPE_AUDIO);
weird spacing
[...]
> + /* flush the lavr delay buffer */
> + if (ret == AVERROR_EOF && s->avr) {
> + AVFilterBufferRef *buf;
> + int nb_samples = avresample_get_delay(s->avr);
as previously discussed on IRC, this needs to be rescaled to the output
sample format.
[...]
> + if (ret > 0) {
> + buf_out->audio->nb_samples = ret;
weird spacing
The rest of the patch LGTM!
Thanks,
Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel