lavfi: move formats-related functions from default.c to formats.c
authorAnton Khirnov <anton@khirnov.net>
Thu, 10 May 2012 05:41:16 +0000 (07:41 +0200)
committerAnton Khirnov <anton@khirnov.net>
Tue, 15 May 2012 04:52:01 +0000 (06:52 +0200)
It's more convenient to have them all in one file.

libavfilter/defaults.c
libavfilter/formats.c

index 9829cdc..7230da0 100644 (file)
@@ -55,67 +55,3 @@ int avfilter_default_config_output_link(AVFilterLink *link)
 
     return 0;
 }
-
-#define SET_COMMON_FORMATS(ctx, fmts, in_fmts, out_fmts, ref, list) \
-{                                                                   \
-    int count = 0, i;                                               \
-                                                                    \
-    for (i = 0; i < ctx->input_count; i++) {                        \
-        if (ctx->inputs[i]) {                                       \
-            ref(fmts, &ctx->inputs[i]->out_fmts);                   \
-            count++;                                                \
-        }                                                           \
-    }                                                               \
-    for (i = 0; i < ctx->output_count; i++) {                       \
-        if (ctx->outputs[i]) {                                      \
-            ref(fmts, &ctx->outputs[i]->in_fmts);                   \
-            count++;                                                \
-        }                                                           \
-    }                                                               \
-                                                                    \
-    if (!count) {                                                   \
-        av_freep(&fmts->list);                                      \
-        av_freep(&fmts->refs);                                      \
-        av_freep(&fmts);                                            \
-    }                                                               \
-}
-
-void ff_set_common_channel_layouts(AVFilterContext *ctx,
-                                   AVFilterChannelLayouts *layouts)
-{
-    SET_COMMON_FORMATS(ctx, layouts, in_channel_layouts, out_channel_layouts,
-                       ff_channel_layouts_ref, channel_layouts);
-}
-
-void ff_set_common_samplerates(AVFilterContext *ctx,
-                               AVFilterFormats *samplerates)
-{
-    SET_COMMON_FORMATS(ctx, samplerates, in_samplerates, out_samplerates,
-                       avfilter_formats_ref, formats);
-}
-
-/**
- * A helper for query_formats() which sets all links to the same list of
- * formats. If there are no links hooked to this filter, the list of formats is
- * freed.
- */
-void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
-{
-    SET_COMMON_FORMATS(ctx, formats, in_formats, out_formats,
-                       avfilter_formats_ref, formats);
-}
-
-int avfilter_default_query_formats(AVFilterContext *ctx)
-{
-    enum AVMediaType type = ctx->inputs  && ctx->inputs [0] ? ctx->inputs [0]->type :
-                            ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type :
-                            AVMEDIA_TYPE_VIDEO;
-
-    avfilter_set_common_formats(ctx, avfilter_all_formats(type));
-    if (type == AVMEDIA_TYPE_AUDIO) {
-        ff_set_common_channel_layouts(ctx, ff_all_channel_layouts());
-        ff_set_common_samplerates(ctx, ff_all_samplerates());
-    }
-
-    return 0;
-}
index 06567c4..36b4d6d 100644 (file)
@@ -314,3 +314,67 @@ void avfilter_formats_changeref(AVFilterFormats **oldref,
 {
     FORMATS_CHANGEREF(oldref, newref);
 }
+
+#define SET_COMMON_FORMATS(ctx, fmts, in_fmts, out_fmts, ref, list) \
+{                                                                   \
+    int count = 0, i;                                               \
+                                                                    \
+    for (i = 0; i < ctx->input_count; i++) {                        \
+        if (ctx->inputs[i]) {                                       \
+            ref(fmts, &ctx->inputs[i]->out_fmts);                   \
+            count++;                                                \
+        }                                                           \
+    }                                                               \
+    for (i = 0; i < ctx->output_count; i++) {                       \
+        if (ctx->outputs[i]) {                                      \
+            ref(fmts, &ctx->outputs[i]->in_fmts);                   \
+            count++;                                                \
+        }                                                           \
+    }                                                               \
+                                                                    \
+    if (!count) {                                                   \
+        av_freep(&fmts->list);                                      \
+        av_freep(&fmts->refs);                                      \
+        av_freep(&fmts);                                            \
+    }                                                               \
+}
+
+void ff_set_common_channel_layouts(AVFilterContext *ctx,
+                                   AVFilterChannelLayouts *layouts)
+{
+    SET_COMMON_FORMATS(ctx, layouts, in_channel_layouts, out_channel_layouts,
+                       ff_channel_layouts_ref, channel_layouts);
+}
+
+void ff_set_common_samplerates(AVFilterContext *ctx,
+                               AVFilterFormats *samplerates)
+{
+    SET_COMMON_FORMATS(ctx, samplerates, in_samplerates, out_samplerates,
+                       avfilter_formats_ref, formats);
+}
+
+/**
+ * A helper for query_formats() which sets all links to the same list of
+ * formats. If there are no links hooked to this filter, the list of formats is
+ * freed.
+ */
+void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
+{
+    SET_COMMON_FORMATS(ctx, formats, in_formats, out_formats,
+                       avfilter_formats_ref, formats);
+}
+
+int avfilter_default_query_formats(AVFilterContext *ctx)
+{
+    enum AVMediaType type = ctx->inputs  && ctx->inputs [0] ? ctx->inputs [0]->type :
+                            ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type :
+                            AVMEDIA_TYPE_VIDEO;
+
+    avfilter_set_common_formats(ctx, avfilter_all_formats(type));
+    if (type == AVMEDIA_TYPE_AUDIO) {
+        ff_set_common_channel_layouts(ctx, ff_all_channel_layouts());
+        ff_set_common_samplerates(ctx, ff_all_samplerates());
+    }
+
+    return 0;
+}