Browse code

lavfi: add asplit filter

Stefano Sabatini authored on 2011/12/26 07:04:44
Showing 6 changed files
... ...
@@ -10,6 +10,7 @@ version next:
10 10
 - dv: add timecode to metadata
11 11
 - thumbnail video filter
12 12
 - XML output in ffprobe
13
+- asplit audio filter
13 14
 
14 15
 
15 16
 version 0.9:
... ...
@@ -224,6 +224,19 @@ expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3} @var{c4} @var{c5}
224 224
 @var{c6} @var{c7}]"
225 225
 @end table
226 226
 
227
+@section asplit
228
+
229
+Pass on the input audio to two outputs. Both outputs are identical to
230
+the input audio.
231
+
232
+For example:
233
+@example
234
+[in] asplit[out0], showaudio[out1]
235
+@end example
236
+
237
+will create two separate outputs from the same input, one cropped and
238
+one padded.
239
+
227 240
 @section earwax
228 241
 
229 242
 Make audio easier to listen to on headphones.
... ...
@@ -29,6 +29,7 @@ OBJS-$(CONFIG_AFORMAT_FILTER)                += af_aformat.o
29 29
 OBJS-$(CONFIG_ANULL_FILTER)                  += af_anull.o
30 30
 OBJS-$(CONFIG_ARESAMPLE_FILTER)              += af_aresample.o
31 31
 OBJS-$(CONFIG_ASHOWINFO_FILTER)              += af_ashowinfo.o
32
+OBJS-$(CONFIG_ASPLIT_FILTER)                 += af_asplit.o
32 33
 OBJS-$(CONFIG_EARWAX_FILTER)                 += af_earwax.o
33 34
 OBJS-$(CONFIG_PAN_FILTER)                    += af_pan.o
34 35
 OBJS-$(CONFIG_VOLUME_FILTER)                 += af_volume.o
35 36
new file mode 100644
... ...
@@ -0,0 +1,55 @@
0
+/*
1
+ * Copyright (c) 2011 Stefano Sabatini
2
+ *
3
+ * This file is part of FFmpeg.
4
+ *
5
+ * FFmpeg is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * FFmpeg is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with FFmpeg; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+/**
21
+ * @file
22
+ * audio splitter
23
+ */
24
+
25
+#include "avfilter.h"
26
+
27
+static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples)
28
+{
29
+    avfilter_filter_samples(inlink->dst->outputs[0],
30
+                            avfilter_ref_buffer(insamples, ~AV_PERM_WRITE));
31
+    avfilter_filter_samples(inlink->dst->outputs[1],
32
+                            avfilter_ref_buffer(insamples, ~AV_PERM_WRITE));
33
+    avfilter_unref_buffer(insamples);
34
+}
35
+
36
+AVFilter avfilter_af_asplit = {
37
+    .name        = "asplit",
38
+    .description = NULL_IF_CONFIG_SMALL("Pass on the audio input to two outputs."),
39
+
40
+    .inputs = (const AVFilterPad[]) {
41
+        { .name             = "default",
42
+          .type             = AVMEDIA_TYPE_AUDIO,
43
+          .get_audio_buffer = avfilter_null_get_audio_buffer,
44
+          .filter_samples   = filter_samples, },
45
+        { .name = NULL}
46
+    },
47
+    .outputs = (const AVFilterPad[]) {
48
+        { .name             = "output1",
49
+          .type             = AVMEDIA_TYPE_AUDIO, },
50
+        { .name             = "output2",
51
+          .type             = AVMEDIA_TYPE_AUDIO, },
52
+        { .name = NULL}
53
+    },
54
+};
... ...
@@ -39,6 +39,7 @@ void avfilter_register_all(void)
39 39
     REGISTER_FILTER (ANULL,       anull,       af);
40 40
     REGISTER_FILTER (ARESAMPLE,   aresample,   af);
41 41
     REGISTER_FILTER (ASHOWINFO,   ashowinfo,   af);
42
+    REGISTER_FILTER (ASPLIT,      asplit,      af);
42 43
     REGISTER_FILTER (EARWAX,      earwax,      af);
43 44
     REGISTER_FILTER (PAN,         pan,         af);
44 45
     REGISTER_FILTER (VOLUME,      volume,      af);
... ...
@@ -30,7 +30,7 @@
30 30
 #include "libavcodec/avcodec.h"
31 31
 
32 32
 #define LIBAVFILTER_VERSION_MAJOR  2
33
-#define LIBAVFILTER_VERSION_MINOR 54
33
+#define LIBAVFILTER_VERSION_MINOR 55
34 34
 #define LIBAVFILTER_VERSION_MICRO 100
35 35
 
36 36
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \