summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-05-10 07:41:16 +0200
committerAnton Khirnov <anton@khirnov.net>2012-05-15 06:52:01 +0200
commit4c64fed37ce0964c45d3699ccf5ac55b077a8291 (patch)
tree365fa00bf5dade8c3115c0b11679de76b21019e1
parentc5432d3ca4af629cea713c7613d22f5c451d41ab (diff)
lavfi: move formats-related functions from default.c to formats.c
It's more convenient to have them all in one file.
-rw-r--r--libavfilter/defaults.c64
-rw-r--r--libavfilter/formats.c64
2 files changed, 64 insertions, 64 deletions
diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
index 9829cdcff4..7230da0ba2 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 06567c4d2f..36b4d6d682 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;
+}