Based on a patch by "S.N. Hemanth Meenakshisundaram" smeenaks!ucsd!edu.
Originally committed as revision 25188 to svn://svn.ffmpeg.org/ffmpeg/trunk
... | ... |
@@ -14,6 +14,40 @@ Pass the audio source unchanged to the output. |
14 | 14 |
|
15 | 15 |
@c man end AUDIO FILTERS |
16 | 16 |
|
17 |
+@chapter Audio Sources |
|
18 |
+@c man begin AUDIO SOURCES |
|
19 |
+ |
|
20 |
+Below is a description of the currently available audio sources. |
|
21 |
+ |
|
22 |
+@section anullsrc |
|
23 |
+ |
|
24 |
+Null audio source, never return audio frames. It is mainly useful as a |
|
25 |
+template and to be employed in analysis / debugging tools. |
|
26 |
+ |
|
27 |
+It accepts as optional parameter a string of the form |
|
28 |
+@var{sample_rate}:@var{channel_layout}. |
|
29 |
+ |
|
30 |
+@var{sample_rate} specify the sample rate, and defaults to 44100. |
|
31 |
+ |
|
32 |
+@var{channel_layout} specify the channel layout, and can be either an |
|
33 |
+integer or a string representing a channel layout. The default value |
|
34 |
+of @var{channel_layout} is 3, which corresponds to CH_LAYOUT_STEREO. |
|
35 |
+ |
|
36 |
+Check the channel_layout_map definition in |
|
37 |
+@file{libavcodec/audioconvert.c} for the correspondance between string |
|
38 |
+and channel layout values. |
|
39 |
+ |
|
40 |
+Follow some examples: |
|
41 |
+@example |
|
42 |
+# set the sample rate to 48000 Hz and the channel layout to CH_LAYOUT_MONO. |
|
43 |
+anullsrc=48000:4 |
|
44 |
+ |
|
45 |
+# same as |
|
46 |
+anullsrc=48000:mono |
|
47 |
+@end example |
|
48 |
+ |
|
49 |
+@c man end AUDIO SOURCES |
|
50 |
+ |
|
17 | 51 |
@chapter Video Filters |
18 | 52 |
@c man begin VIDEO FILTERS |
19 | 53 |
|
... | ... |
@@ -16,6 +16,8 @@ OBJS = allfilters.o \ |
16 | 16 |
|
17 | 17 |
OBJS-$(CONFIG_ANULL_FILTER) += af_anull.o |
18 | 18 |
|
19 |
+OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o |
|
20 |
+ |
|
19 | 21 |
OBJS-$(CONFIG_ASPECT_FILTER) += vf_aspect.o |
20 | 22 |
OBJS-$(CONFIG_CROP_FILTER) += vf_crop.o |
21 | 23 |
OBJS-$(CONFIG_FIFO_FILTER) += vf_fifo.o |
42 | 44 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,96 @@ |
0 |
+/* |
|
1 |
+ * This file is part of FFmpeg. |
|
2 |
+ * |
|
3 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
4 |
+ * modify it under the terms of the GNU Lesser General Public |
|
5 |
+ * License as published by the Free Software Foundation; either |
|
6 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
7 |
+ * |
|
8 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
11 |
+ * Lesser General Public License for more details. |
|
12 |
+ * |
|
13 |
+ * You should have received a copy of the GNU Lesser General Public |
|
14 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
15 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 |
+ */ |
|
17 |
+ |
|
18 |
+/** |
|
19 |
+ * @file |
|
20 |
+ * null audio source |
|
21 |
+ */ |
|
22 |
+ |
|
23 |
+#include "avfilter.h" |
|
24 |
+#include "libavcodec/audioconvert.h" |
|
25 |
+ |
|
26 |
+typedef struct { |
|
27 |
+ int64_t channel_layout; |
|
28 |
+ int64_t sample_rate; |
|
29 |
+} ANullContext; |
|
30 |
+ |
|
31 |
+static int init(AVFilterContext *ctx, const char *args, void *opaque) |
|
32 |
+{ |
|
33 |
+ ANullContext *priv = ctx->priv; |
|
34 |
+ char channel_layout_str[128] = ""; |
|
35 |
+ |
|
36 |
+ priv->sample_rate = 44100; |
|
37 |
+ priv->channel_layout = CH_LAYOUT_STEREO; |
|
38 |
+ |
|
39 |
+ if (args) |
|
40 |
+ sscanf(args, "%"PRId64":%s", &priv->sample_rate, channel_layout_str); |
|
41 |
+ |
|
42 |
+ if (priv->sample_rate < 0) { |
|
43 |
+ av_log(ctx, AV_LOG_ERROR, "Invalid negative sample rate: %"PRId64"\n", priv->sample_rate); |
|
44 |
+ return AVERROR(EINVAL); |
|
45 |
+ } |
|
46 |
+ |
|
47 |
+ if (*channel_layout_str) |
|
48 |
+ if (!(priv->channel_layout = avcodec_get_channel_layout(channel_layout_str)) |
|
49 |
+ && sscanf(channel_layout_str, "%"PRId64, &priv->channel_layout) != 1) { |
|
50 |
+ av_log(ctx, AV_LOG_ERROR, "Invalid value '%s' for channel layout\n", |
|
51 |
+ channel_layout_str); |
|
52 |
+ return AVERROR(EINVAL); |
|
53 |
+ } |
|
54 |
+ |
|
55 |
+ return 0; |
|
56 |
+} |
|
57 |
+ |
|
58 |
+static int config_props(AVFilterLink *outlink) |
|
59 |
+{ |
|
60 |
+ ANullContext *priv = outlink->src->priv; |
|
61 |
+ char buf[128]; |
|
62 |
+ int chans_nb; |
|
63 |
+ |
|
64 |
+ outlink->sample_rate = priv->sample_rate; |
|
65 |
+ outlink->channel_layout = priv->channel_layout; |
|
66 |
+ |
|
67 |
+ chans_nb = avcodec_channel_layout_num_channels(priv->channel_layout); |
|
68 |
+ avcodec_get_channel_layout_string(buf, sizeof(buf), chans_nb, priv->channel_layout); |
|
69 |
+ av_log(outlink->src, AV_LOG_INFO, |
|
70 |
+ "sample_rate:%"PRId64 " channel_layout:%"PRId64 " channel_layout_description:'%s'\n", |
|
71 |
+ priv->sample_rate, priv->channel_layout, buf); |
|
72 |
+ |
|
73 |
+ return 0; |
|
74 |
+} |
|
75 |
+ |
|
76 |
+static int request_frame(AVFilterLink *link) |
|
77 |
+{ |
|
78 |
+ return -1; |
|
79 |
+} |
|
80 |
+ |
|
81 |
+AVFilter avfilter_asrc_anullsrc = { |
|
82 |
+ .name = "anullsrc", |
|
83 |
+ .description = NULL_IF_CONFIG_SMALL("Null audio source, never return audio frames."), |
|
84 |
+ |
|
85 |
+ .init = init, |
|
86 |
+ .priv_size = sizeof(ANullContext), |
|
87 |
+ |
|
88 |
+ .inputs = (AVFilterPad[]) {{ .name = NULL}}, |
|
89 |
+ |
|
90 |
+ .outputs = (AVFilterPad[]) {{ .name = "default", |
|
91 |
+ .type = AVMEDIA_TYPE_AUDIO, |
|
92 |
+ .config_props = config_props, |
|
93 |
+ .request_frame = request_frame, }, |
|
94 |
+ { .name = NULL}}, |
|
95 |
+}; |
... | ... |
@@ -25,7 +25,7 @@ |
25 | 25 |
#include "libavutil/avutil.h" |
26 | 26 |
|
27 | 27 |
#define LIBAVFILTER_VERSION_MAJOR 1 |
28 |
-#define LIBAVFILTER_VERSION_MINOR 42 |
|
28 |
+#define LIBAVFILTER_VERSION_MINOR 43 |
|
29 | 29 |
#define LIBAVFILTER_VERSION_MICRO 0 |
30 | 30 |
|
31 | 31 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |