It's more convenient to have them all in one file.
Anton Khirnov authored on 2012/05/10 14:41:16... | ... |
@@ -55,67 +55,3 @@ int avfilter_default_config_output_link(AVFilterLink *link) |
55 | 55 |
|
56 | 56 |
return 0; |
57 | 57 |
} |
58 |
- |
|
59 |
-#define SET_COMMON_FORMATS(ctx, fmts, in_fmts, out_fmts, ref, list) \ |
|
60 |
-{ \ |
|
61 |
- int count = 0, i; \ |
|
62 |
- \ |
|
63 |
- for (i = 0; i < ctx->input_count; i++) { \ |
|
64 |
- if (ctx->inputs[i]) { \ |
|
65 |
- ref(fmts, &ctx->inputs[i]->out_fmts); \ |
|
66 |
- count++; \ |
|
67 |
- } \ |
|
68 |
- } \ |
|
69 |
- for (i = 0; i < ctx->output_count; i++) { \ |
|
70 |
- if (ctx->outputs[i]) { \ |
|
71 |
- ref(fmts, &ctx->outputs[i]->in_fmts); \ |
|
72 |
- count++; \ |
|
73 |
- } \ |
|
74 |
- } \ |
|
75 |
- \ |
|
76 |
- if (!count) { \ |
|
77 |
- av_freep(&fmts->list); \ |
|
78 |
- av_freep(&fmts->refs); \ |
|
79 |
- av_freep(&fmts); \ |
|
80 |
- } \ |
|
81 |
-} |
|
82 |
- |
|
83 |
-void ff_set_common_channel_layouts(AVFilterContext *ctx, |
|
84 |
- AVFilterChannelLayouts *layouts) |
|
85 |
-{ |
|
86 |
- SET_COMMON_FORMATS(ctx, layouts, in_channel_layouts, out_channel_layouts, |
|
87 |
- ff_channel_layouts_ref, channel_layouts); |
|
88 |
-} |
|
89 |
- |
|
90 |
-void ff_set_common_samplerates(AVFilterContext *ctx, |
|
91 |
- AVFilterFormats *samplerates) |
|
92 |
-{ |
|
93 |
- SET_COMMON_FORMATS(ctx, samplerates, in_samplerates, out_samplerates, |
|
94 |
- avfilter_formats_ref, formats); |
|
95 |
-} |
|
96 |
- |
|
97 |
-/** |
|
98 |
- * A helper for query_formats() which sets all links to the same list of |
|
99 |
- * formats. If there are no links hooked to this filter, the list of formats is |
|
100 |
- * freed. |
|
101 |
- */ |
|
102 |
-void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) |
|
103 |
-{ |
|
104 |
- SET_COMMON_FORMATS(ctx, formats, in_formats, out_formats, |
|
105 |
- avfilter_formats_ref, formats); |
|
106 |
-} |
|
107 |
- |
|
108 |
-int avfilter_default_query_formats(AVFilterContext *ctx) |
|
109 |
-{ |
|
110 |
- enum AVMediaType type = ctx->inputs && ctx->inputs [0] ? ctx->inputs [0]->type : |
|
111 |
- ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type : |
|
112 |
- AVMEDIA_TYPE_VIDEO; |
|
113 |
- |
|
114 |
- avfilter_set_common_formats(ctx, avfilter_all_formats(type)); |
|
115 |
- if (type == AVMEDIA_TYPE_AUDIO) { |
|
116 |
- ff_set_common_channel_layouts(ctx, ff_all_channel_layouts()); |
|
117 |
- ff_set_common_samplerates(ctx, ff_all_samplerates()); |
|
118 |
- } |
|
119 |
- |
|
120 |
- return 0; |
|
121 |
-} |
... | ... |
@@ -314,3 +314,67 @@ void avfilter_formats_changeref(AVFilterFormats **oldref, |
314 | 314 |
{ |
315 | 315 |
FORMATS_CHANGEREF(oldref, newref); |
316 | 316 |
} |
317 |
+ |
|
318 |
+#define SET_COMMON_FORMATS(ctx, fmts, in_fmts, out_fmts, ref, list) \ |
|
319 |
+{ \ |
|
320 |
+ int count = 0, i; \ |
|
321 |
+ \ |
|
322 |
+ for (i = 0; i < ctx->input_count; i++) { \ |
|
323 |
+ if (ctx->inputs[i]) { \ |
|
324 |
+ ref(fmts, &ctx->inputs[i]->out_fmts); \ |
|
325 |
+ count++; \ |
|
326 |
+ } \ |
|
327 |
+ } \ |
|
328 |
+ for (i = 0; i < ctx->output_count; i++) { \ |
|
329 |
+ if (ctx->outputs[i]) { \ |
|
330 |
+ ref(fmts, &ctx->outputs[i]->in_fmts); \ |
|
331 |
+ count++; \ |
|
332 |
+ } \ |
|
333 |
+ } \ |
|
334 |
+ \ |
|
335 |
+ if (!count) { \ |
|
336 |
+ av_freep(&fmts->list); \ |
|
337 |
+ av_freep(&fmts->refs); \ |
|
338 |
+ av_freep(&fmts); \ |
|
339 |
+ } \ |
|
340 |
+} |
|
341 |
+ |
|
342 |
+void ff_set_common_channel_layouts(AVFilterContext *ctx, |
|
343 |
+ AVFilterChannelLayouts *layouts) |
|
344 |
+{ |
|
345 |
+ SET_COMMON_FORMATS(ctx, layouts, in_channel_layouts, out_channel_layouts, |
|
346 |
+ ff_channel_layouts_ref, channel_layouts); |
|
347 |
+} |
|
348 |
+ |
|
349 |
+void ff_set_common_samplerates(AVFilterContext *ctx, |
|
350 |
+ AVFilterFormats *samplerates) |
|
351 |
+{ |
|
352 |
+ SET_COMMON_FORMATS(ctx, samplerates, in_samplerates, out_samplerates, |
|
353 |
+ avfilter_formats_ref, formats); |
|
354 |
+} |
|
355 |
+ |
|
356 |
+/** |
|
357 |
+ * A helper for query_formats() which sets all links to the same list of |
|
358 |
+ * formats. If there are no links hooked to this filter, the list of formats is |
|
359 |
+ * freed. |
|
360 |
+ */ |
|
361 |
+void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) |
|
362 |
+{ |
|
363 |
+ SET_COMMON_FORMATS(ctx, formats, in_formats, out_formats, |
|
364 |
+ avfilter_formats_ref, formats); |
|
365 |
+} |
|
366 |
+ |
|
367 |
+int avfilter_default_query_formats(AVFilterContext *ctx) |
|
368 |
+{ |
|
369 |
+ enum AVMediaType type = ctx->inputs && ctx->inputs [0] ? ctx->inputs [0]->type : |
|
370 |
+ ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type : |
|
371 |
+ AVMEDIA_TYPE_VIDEO; |
|
372 |
+ |
|
373 |
+ avfilter_set_common_formats(ctx, avfilter_all_formats(type)); |
|
374 |
+ if (type == AVMEDIA_TYPE_AUDIO) { |
|
375 |
+ ff_set_common_channel_layouts(ctx, ff_all_channel_layouts()); |
|
376 |
+ ff_set_common_samplerates(ctx, ff_all_samplerates()); |
|
377 |
+ } |
|
378 |
+ |
|
379 |
+ return 0; |
|
380 |
+} |