summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-05-18 19:38:38 +0200
committerStefano Sabatini <stefasab@gmail.com>2012-05-19 13:24:53 +0200
commit150227e8edfcbd5ee30d9236a4d3618937447ed3 (patch)
tree86b6d73de4662bd893c976176857af075c70e6be
parente5fcf3646acd633bfad1806fc778bc33748e6f5f (diff)
lavfi/asplit: move asplit code to vf_split.c, and make it support N outputs
The move allows to share the init code already used by split.
-rw-r--r--doc/filters.texi17
-rw-r--r--libavfilter/Makefile2
-rw-r--r--libavfilter/af_asplit.c56
-rw-r--r--libavfilter/version.h2
-rw-r--r--libavfilter/vf_split.c32
5 files changed, 45 insertions, 64 deletions
diff --git a/doc/filters.texi b/doc/filters.texi
index 06374fc5d5..08e1647966 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -304,16 +304,23 @@ expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3} @var{c4} @var{c5}
@section asplit
-Pass on the input audio to two outputs. Both outputs are identical to
-the input audio.
+Split input audio into several identical outputs.
+
+The filter accepts a single parameter which specifies the number of outputs. If
+unspecified, it defaults to 2.
For example:
@example
-[in] asplit[out0], showaudio[out1]
+[in] asplit [out0][out1]
@end example
-will create two separate outputs from the same input, one cropped and
-one padded.
+will create two separate outputs from the same input.
+
+To create 3 or more outputs, you need to specify the number of
+outputs, like in:
+@example
+[in] asplit=3 [out0][out1][out2]
+@end example
@section astreamsync
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 56c931a17d..2841759243 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -50,7 +50,7 @@ OBJS-$(CONFIG_AMERGE_FILTER) += af_amerge.o
OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o
OBJS-$(CONFIG_ARESAMPLE_FILTER) += af_aresample.o
OBJS-$(CONFIG_ASHOWINFO_FILTER) += af_ashowinfo.o
-OBJS-$(CONFIG_ASPLIT_FILTER) += af_asplit.o
+OBJS-$(CONFIG_ASPLIT_FILTER) += vf_split.o
OBJS-$(CONFIG_ASTREAMSYNC_FILTER) += af_astreamsync.o
OBJS-$(CONFIG_ASYNCTS_FILTER) += af_asyncts.o
OBJS-$(CONFIG_EARWAX_FILTER) += af_earwax.o
diff --git a/libavfilter/af_asplit.c b/libavfilter/af_asplit.c
deleted file mode 100644
index f63a29e1d3..0000000000
--- a/libavfilter/af_asplit.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2011 Stefano Sabatini
- *
- * 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
- * audio splitter
- */
-
-#include "avfilter.h"
-#include "audio.h"
-
-static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
-{
- ff_filter_samples(inlink->dst->outputs[0],
- avfilter_ref_buffer(insamples, ~AV_PERM_WRITE));
- ff_filter_samples(inlink->dst->outputs[1],
- avfilter_ref_buffer(insamples, ~AV_PERM_WRITE));
- avfilter_unref_buffer(insamples);
-}
-
-AVFilter avfilter_af_asplit = {
- .name = "asplit",
- .description = NULL_IF_CONFIG_SMALL("Pass on the audio input to two outputs."),
-
- .inputs = (const AVFilterPad[]) {
- { .name = "default",
- .type = AVMEDIA_TYPE_AUDIO,
- .get_audio_buffer = ff_null_get_audio_buffer,
- .filter_samples = filter_samples, },
- { .name = NULL}
- },
- .outputs = (const AVFilterPad[]) {
- { .name = "output1",
- .type = AVMEDIA_TYPE_AUDIO, },
- { .name = "output2",
- .type = AVMEDIA_TYPE_AUDIO, },
- { .name = NULL}
- },
-};
diff --git a/libavfilter/version.h b/libavfilter/version.h
index c536baba4a..9fd3819008 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MINOR 74
-#define LIBAVFILTER_VERSION_MICRO 101
+#define LIBAVFILTER_VERSION_MICRO 102
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
diff --git a/libavfilter/vf_split.c b/libavfilter/vf_split.c
index e7e2dee90d..172781d7e1 100644
--- a/libavfilter/vf_split.c
+++ b/libavfilter/vf_split.c
@@ -24,6 +24,7 @@
*/
#include "avfilter.h"
+#include "audio.h"
static int split_init(AVFilterContext *ctx, const char *args, void *opaque)
{
@@ -43,7 +44,7 @@ static int split_init(AVFilterContext *ctx, const char *args, void *opaque)
AVFilterPad pad = { 0 };
snprintf(name, sizeof(name), "output%d", i);
- pad.type = AVMEDIA_TYPE_VIDEO;
+ pad.type = !strcmp(ctx->name, "split") ? AVMEDIA_TYPE_VIDEO : AVMEDIA_TYPE_AUDIO;
pad.name = av_strdup(name);
avfilter_insert_outpad(ctx, i, &pad);
@@ -106,3 +107,32 @@ AVFilter avfilter_vf_split = {
{ .name = NULL}},
.outputs = (AVFilterPad[]) {{ .name = NULL}},
};
+
+static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
+{
+ AVFilterContext *ctx = inlink->dst;
+ int i;
+
+ for (i = 0; i < ctx->output_count; i++)
+ ff_filter_samples(inlink->dst->outputs[i],
+ avfilter_ref_buffer(samplesref, ~AV_PERM_WRITE));
+}
+
+AVFilter avfilter_af_asplit = {
+ .name = "asplit",
+ .description = NULL_IF_CONFIG_SMALL("Pass on the audio input to N audio outputs."),
+
+ .init = split_init,
+ .uninit = split_uninit,
+
+ .inputs = (const AVFilterPad[]) {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_AUDIO,
+ .get_audio_buffer = ff_null_get_audio_buffer,
+ .filter_samples = filter_samples,
+ },
+ { .name = NULL }
+ },
+ .outputs = (const AVFilterPad[]) {{ .name = NULL }},
+};