diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2012-05-18 19:38:38 +0200 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2012-05-19 13:24:53 +0200 |
commit | 150227e8edfcbd5ee30d9236a4d3618937447ed3 (patch) | |
tree | 86b6d73de4662bd893c976176857af075c70e6be /libavfilter/vf_split.c | |
parent | e5fcf3646acd633bfad1806fc778bc33748e6f5f (diff) | |
download | ffmpeg-150227e8edfcbd5ee30d9236a4d3618937447ed3.tar.gz |
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.
Diffstat (limited to 'libavfilter/vf_split.c')
-rw-r--r-- | libavfilter/vf_split.c | 32 |
1 files changed, 31 insertions, 1 deletions
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 }}, +}; |