diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2012-05-21 14:03:42 -0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2012-05-21 14:49:52 -0400 |
commit | afeb3590fc5ff01d43b1a1be9df8fac64431ff9e (patch) | |
tree | 35ad32f8b80d374a83bc2601a1da2fc7e0892bc6 /libavfilter/split.c | |
parent | cc30080b3fb44bebea97533f7dfd5ee7700e4665 (diff) | |
download | ffmpeg-afeb3590fc5ff01d43b1a1be9df8fac64431ff9e.tar.gz |
lavfi: add an audio split filter
Based on current version of the asplit filter in FFmpeg written by
Stefano Sabatini and others.
Diffstat (limited to 'libavfilter/split.c')
-rw-r--r-- | libavfilter/split.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/libavfilter/split.c b/libavfilter/split.c index da6b3ff320..83ad765081 100644 --- a/libavfilter/split.c +++ b/libavfilter/split.c @@ -20,10 +20,11 @@ /** * @file - * Video splitter + * audio and video splitter */ #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 = ctx->filter->inputs[0].type; pad.name = av_strdup(name); avfilter_insert_outpad(ctx, i, &pad); @@ -106,3 +107,28 @@ 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 }}, +}; |