[FFmpeg-cvslog] lavfi/asplit: move asplit code to vf_split.c, and make it support N outputs

Stefano Sabatini git at videolan.org
Sat May 19 13:28:48 CEST 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Fri May 18 19:38:38 2012 +0200| [150227e8edfcbd5ee30d9236a4d3618937447ed3] | committer: Stefano Sabatini

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.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=150227e8edfcbd5ee30d9236a4d3618937447ed3
---

 doc/filters.texi        |   17 +++++++++-----
 libavfilter/Makefile    |    2 +-
 libavfilter/af_asplit.c |   56 -----------------------------------------------
 libavfilter/version.h   |    2 +-
 libavfilter/vf_split.c  |   32 ++++++++++++++++++++++++++-
 5 files changed, 45 insertions(+), 64 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 06374fc..08e1647 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:
+ at example
+[in] asplit=3 [out0][out1][out2]
+ at end example
 
 @section astreamsync
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 56c931a..2841759 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 f63a29e..0000000
--- 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 c536bab..9fd3819 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 e7e2dee..172781d 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 }},
+};



More information about the ffmpeg-cvslog mailing list