[FFmpeg-cvslog] lavfi: move formats-related functions from default.c to formats.c

Anton Khirnov git at videolan.org
Wed May 16 02:30:46 CEST 2012


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Thu May 10 07:41:16 2012 +0200| [4c64fed37ce0964c45d3699ccf5ac55b077a8291] | committer: Anton Khirnov

lavfi: move formats-related functions from default.c to formats.c

It's more convenient to have them all in one file.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4c64fed37ce0964c45d3699ccf5ac55b077a8291
---

 libavfilter/defaults.c |   64 ------------------------------------------------
 libavfilter/formats.c  |   64 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
index 9829cdc..7230da0 100644
--- a/libavfilter/defaults.c
+++ b/libavfilter/defaults.c
@@ -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;
-}
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 06567c4..36b4d6d 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -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;
+}



More information about the ffmpeg-cvslog mailing list