Signed-off-by: Stefano Sabatini <stefano.sabatini-lala@poste.it>
Mina Nagy Zaki authored on 2011/07/14 20:18:13... | ... |
@@ -99,6 +99,27 @@ build. |
99 | 99 |
|
100 | 100 |
Below is a description of the currently available audio filters. |
101 | 101 |
|
102 |
+@section aformat |
|
103 |
+ |
|
104 |
+Convert the input audio to one of the specified formats. The framework will |
|
105 |
+negotiate the most appropriate format to minimize conversions. |
|
106 |
+ |
|
107 |
+The filter accepts three lists of formats, separated by ":", in the form: |
|
108 |
+"@var{sample_formats}:@var{channel_layouts}:@var{packing_formats}". |
|
109 |
+ |
|
110 |
+Elements in each list are separated by "," which has to be escaped in the |
|
111 |
+filtergraph specification. |
|
112 |
+ |
|
113 |
+The special parameter "all", in place of a list of elements, signifies all |
|
114 |
+supported formats. |
|
115 |
+ |
|
116 |
+Some examples follow: |
|
117 |
+@example |
|
118 |
+aformat=u8\\,s16:mono:packed |
|
119 |
+ |
|
120 |
+aformat=s16:mono\\,stereo:all |
|
121 |
+@end example |
|
122 |
+ |
|
102 | 123 |
@section anull |
103 | 124 |
|
104 | 125 |
Pass the audio source unchanged to the output. |
24 | 25 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,114 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2011 Mina Nagy Zaki |
|
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 |
+ * format audio filter |
|
23 |
+ */ |
|
24 |
+ |
|
25 |
+#include "libavutil/audioconvert.h" |
|
26 |
+#include "avfilter.h" |
|
27 |
+#include "internal.h" |
|
28 |
+ |
|
29 |
+typedef struct { |
|
30 |
+ AVFilterFormats *formats, *chlayouts, *packing; |
|
31 |
+} AFormatContext; |
|
32 |
+ |
|
33 |
+static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) |
|
34 |
+{ |
|
35 |
+ AFormatContext * const aformat = ctx->priv; |
|
36 |
+ char *arg, *fmt_str; |
|
37 |
+ int64_t fmt; |
|
38 |
+ int ret; |
|
39 |
+ |
|
40 |
+ arg = strsep(&args, ":"); |
|
41 |
+ if (!arg) goto arg_fail; |
|
42 |
+ if (!strcmp(arg, "all")) { |
|
43 |
+ aformat->formats = avfilter_all_formats(AVMEDIA_TYPE_AUDIO); |
|
44 |
+ } else { |
|
45 |
+ while (fmt_str = strsep(&arg, ",")) { |
|
46 |
+ if ((ret = ff_parse_sample_format((int*)&fmt, fmt_str, ctx)) < 0) |
|
47 |
+ return ret; |
|
48 |
+ avfilter_add_format(&aformat->formats, fmt); |
|
49 |
+ } |
|
50 |
+ } |
|
51 |
+ |
|
52 |
+ arg = strsep(&args, ":"); |
|
53 |
+ if (!arg) goto arg_fail; |
|
54 |
+ if (!strcmp(arg, "all")) { |
|
55 |
+ aformat->chlayouts = avfilter_all_channel_layouts(); |
|
56 |
+ } else { |
|
57 |
+ while (fmt_str = strsep(&arg, ",")) { |
|
58 |
+ if ((ret = ff_parse_channel_layout(&fmt, fmt_str, ctx)) < 0) |
|
59 |
+ return ret; |
|
60 |
+ avfilter_add_format(&aformat->chlayouts, fmt); |
|
61 |
+ } |
|
62 |
+ } |
|
63 |
+ |
|
64 |
+ arg = strsep(&args, ":"); |
|
65 |
+ if (!arg) goto arg_fail; |
|
66 |
+ if (!strcmp(arg, "all")) { |
|
67 |
+ aformat->packing = avfilter_all_packing_formats(); |
|
68 |
+ } else { |
|
69 |
+ while (fmt_str = strsep(&arg, ",")) { |
|
70 |
+ if ((ret = ff_parse_packing_format((int*)&fmt, fmt_str, ctx)) < 0) |
|
71 |
+ return ret; |
|
72 |
+ avfilter_add_format(&aformat->packing, fmt); |
|
73 |
+ } |
|
74 |
+ } |
|
75 |
+ |
|
76 |
+ return 0; |
|
77 |
+ |
|
78 |
+arg_fail: |
|
79 |
+ av_log(ctx, AV_LOG_ERROR, "Invalid arguments, they must be of the form " |
|
80 |
+ "sample_fmts:channel_layouts:packing_fmts\n"); |
|
81 |
+ return AVERROR(EINVAL); |
|
82 |
+} |
|
83 |
+ |
|
84 |
+static int query_formats(AVFilterContext *ctx) |
|
85 |
+{ |
|
86 |
+ AFormatContext * const aformat = ctx->priv; |
|
87 |
+ |
|
88 |
+ avfilter_set_common_sample_formats (ctx, aformat->formats); |
|
89 |
+ avfilter_set_common_channel_layouts(ctx, aformat->chlayouts); |
|
90 |
+ avfilter_set_common_packing_formats(ctx, aformat->packing); |
|
91 |
+ return 0; |
|
92 |
+} |
|
93 |
+ |
|
94 |
+static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref) |
|
95 |
+{ |
|
96 |
+ avfilter_filter_samples(inlink->dst->outputs[0], insamplesref); |
|
97 |
+} |
|
98 |
+ |
|
99 |
+AVFilter avfilter_af_aformat = { |
|
100 |
+ .name = "aformat", |
|
101 |
+ .description = NULL_IF_CONFIG_SMALL("Convert the input audio to one of the specified formats."), |
|
102 |
+ .init = init, |
|
103 |
+ .query_formats = query_formats, |
|
104 |
+ .priv_size = sizeof(AFormatContext), |
|
105 |
+ |
|
106 |
+ .inputs = (AVFilterPad[]) {{ .name = "default", |
|
107 |
+ .type = AVMEDIA_TYPE_AUDIO, |
|
108 |
+ .filter_samples = filter_samples}, |
|
109 |
+ { .name = NULL}}, |
|
110 |
+ .outputs = (AVFilterPad[]) {{ .name = "default", |
|
111 |
+ .type = AVMEDIA_TYPE_AUDIO}, |
|
112 |
+ { .name = NULL}}, |
|
113 |
+}; |
... | ... |
@@ -29,8 +29,8 @@ |
29 | 29 |
#include "libavutil/rational.h" |
30 | 30 |
|
31 | 31 |
#define LIBAVFILTER_VERSION_MAJOR 2 |
32 |
-#define LIBAVFILTER_VERSION_MINOR 29 |
|
33 |
-#define LIBAVFILTER_VERSION_MICRO 2 |
|
32 |
+#define LIBAVFILTER_VERSION_MINOR 30 |
|
33 |
+#define LIBAVFILTER_VERSION_MICRO 0 |
|
34 | 34 |
|
35 | 35 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
36 | 36 |
LIBAVFILTER_VERSION_MINOR, \ |