The move allows to share the init code already used by split.tags/n0.11
@@ -304,16 +304,23 @@ expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3} @var{c4} @var{c5} | |||||
@section asplit | @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: | For example: | ||||
@example | @example | ||||
[in] asplit[out0], showaudio[out1] | |||||
[in] asplit [out0][out1] | |||||
@end example | @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 | @section astreamsync | ||||
@@ -50,7 +50,7 @@ OBJS-$(CONFIG_AMERGE_FILTER) += af_amerge.o | |||||
OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o | OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o | ||||
OBJS-$(CONFIG_ARESAMPLE_FILTER) += af_aresample.o | OBJS-$(CONFIG_ARESAMPLE_FILTER) += af_aresample.o | ||||
OBJS-$(CONFIG_ASHOWINFO_FILTER) += af_ashowinfo.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_ASTREAMSYNC_FILTER) += af_astreamsync.o | ||||
OBJS-$(CONFIG_ASYNCTS_FILTER) += af_asyncts.o | OBJS-$(CONFIG_ASYNCTS_FILTER) += af_asyncts.o | ||||
OBJS-$(CONFIG_EARWAX_FILTER) += af_earwax.o | OBJS-$(CONFIG_EARWAX_FILTER) += af_earwax.o | ||||
@@ -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} | |||||
}, | |||||
}; |
@@ -30,7 +30,7 @@ | |||||
#define LIBAVFILTER_VERSION_MAJOR 2 | #define LIBAVFILTER_VERSION_MAJOR 2 | ||||
#define LIBAVFILTER_VERSION_MINOR 74 | #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, \ | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ | ||||
LIBAVFILTER_VERSION_MINOR, \ | LIBAVFILTER_VERSION_MINOR, \ | ||||
@@ -24,6 +24,7 @@ | |||||
*/ | */ | ||||
#include "avfilter.h" | #include "avfilter.h" | ||||
#include "audio.h" | |||||
static int split_init(AVFilterContext *ctx, const char *args, void *opaque) | 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 }; | AVFilterPad pad = { 0 }; | ||||
snprintf(name, sizeof(name), "output%d", i); | 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); | pad.name = av_strdup(name); | ||||
avfilter_insert_outpad(ctx, i, &pad); | avfilter_insert_outpad(ctx, i, &pad); | ||||
@@ -106,3 +107,32 @@ AVFilter avfilter_vf_split = { | |||||
{ .name = NULL}}, | { .name = NULL}}, | ||||
.outputs = (AVFilterPad[]) {{ .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 }}, | |||||
}; |