History

lavfi: add an audio split filter

Based on current version of the asplit filter in FFmpeg written by Stefano Sabatini and others.

Justin Ruggles committed 14 years ago

Commit afeb3591 parent cc300806 files · +45 −3Browse files

Showing the changes to libavfilter (4 of 6 files). Show all

Unified · Split

4 files
  1. libavfilter/Makefile +1 −0
  2. libavfilter/allfilters.c +1 −0
  3. libavfilter/split.c +28 −2
  4. libavfilter/version.h +1 −1
libavfilter/Makefile+1−0
@@ -27,6 +27,7 @@ OBJS = allfilters.o \ · 26 unmodified lines
2727
2828 OBJS-$(CONFIG_AFORMAT_FILTER) += af_aformat.o
2929 OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o
30+OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
3031 OBJS-$(CONFIG_ASYNCTS_FILTER) += af_asyncts.o
3132 OBJS-$(CONFIG_RESAMPLE_FILTER) += af_resample.o
3233
libavfilter/allfilters.c+1−0
@@ -36,6 +36,7 @@ void avfilter_register_all(void) · 35 unmodified lines
3636
3737 REGISTER_FILTER (AFORMAT, aformat, af);
3838 REGISTER_FILTER (ANULL, anull, af);
39+ REGISTER_FILTER (ASPLIT, asplit, af);
3940 REGISTER_FILTER (ASYNCTS, asyncts, af);
4041 REGISTER_FILTER (RESAMPLE, resample, af);
4142
libavfilter/split.c+28−2
@@ -20,10 +20,11 @@ · 19 unmodified lines
2020
2121 /**
2222 * @file
23− * Video splitter
23+ * audio and video splitter
2424 */
2525
2626 #include "avfilter.h"
27+#include "audio.h"
2728
2829 static int split_init(AVFilterContext *ctx, const char *args, void *opaque)
2930 {
@@ -43,7 +44,7 @@ static int split_init(AVFilterContext *ctx, const char *args, void *opaque) · 13 unmodified lines
4344 AVFilterPad pad = { 0 };
4445
4546 snprintf(name, sizeof(name), "output%d", i);
46− pad.type = AVMEDIA_TYPE_VIDEO;
47+ pad.type = ctx->filter->inputs[0].type;
4748 pad.name = av_strdup(name);
4849
4950 avfilter_insert_outpad(ctx, i, &pad);
@@ -106,3 +107,28 @@ AVFilter avfilter_vf_split = { · 56 unmodified lines
106107 { .name = NULL}},
107108 .outputs = (AVFilterPad[]) {{ .name = NULL}},
108109 };
110+
111+static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
112+{
113+ AVFilterContext *ctx = inlink->dst;
114+ int i;
115+
116+ for (i = 0; i < ctx->output_count; i++)
117+ ff_filter_samples(inlink->dst->outputs[i],
118+ avfilter_ref_buffer(samplesref, ~AV_PERM_WRITE));
119+}
120+
121+AVFilter avfilter_af_asplit = {
122+ .name = "asplit",
123+ .description = NULL_IF_CONFIG_SMALL("Pass on the audio input to N audio outputs."),
124+
125+ .init = split_init,
126+ .uninit = split_uninit,
127+
128+ .inputs = (const AVFilterPad[]) {{ .name = "default",
129+ .type = AVMEDIA_TYPE_AUDIO,
130+ .get_audio_buffer = ff_null_get_audio_buffer,
131+ .filter_samples = filter_samples },
132+ { .name = NULL }},
133+ .outputs = (const AVFilterPad[]) {{ .name = NULL }},
134+};
libavfilter/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 #include "libavutil/avutil.h"
3030
3131 #define LIBAVFILTER_VERSION_MAJOR 2
32−#define LIBAVFILTER_VERSION_MINOR 18
32+#define LIBAVFILTER_VERSION_MINOR 19
3333 #define LIBAVFILTER_VERSION_MICRO 0
3434
3535 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t