Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMina Nagy Zaki <mnzaki@gmail.com>2011-06-19 22:31:24 +0400
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2011-06-20 00:58:32 +0400
commitfd2c0a5db242a3c89a89f1dd2ae9e3155e48f9e2 (patch)
tree304f7ccb5772ff319728ba6cc99ada72bd579c9e /libavfilter/defaults.c
parent527ca3985c736ffe077a82fdf3616f0fd571b923 (diff)
lavfi: add layout negotiation fields and helper functions.
Diffstat (limited to 'libavfilter/defaults.c')
-rw-r--r--libavfilter/defaults.c71
1 files changed, 40 insertions, 31 deletions
diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
index c39ed64048..b03816dd24 100644
--- a/libavfilter/defaults.c
+++ b/libavfilter/defaults.c
@@ -197,45 +197,54 @@ int avfilter_default_config_output_link(AVFilterLink *link)
return 0;
}
-/**
- * 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.
- *
- * FIXME: this will need changed for filters with a mix of pad types
- * (video + audio, etc)
- */
-void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
+static void set_common_formats(AVFilterContext *ctx, AVFilterFormats *fmts,
+ enum AVMediaType type, int offin, int offout)
{
- int count = 0, i;
-
- for (i = 0; i < ctx->input_count; i++) {
- if (ctx->inputs[i]) {
- avfilter_formats_ref(formats, &ctx->inputs[i]->out_formats);
- count++;
- }
- }
- for (i = 0; i < ctx->output_count; i++) {
- if (ctx->outputs[i]) {
- avfilter_formats_ref(formats, &ctx->outputs[i]->in_formats);
- count++;
- }
+ int i;
+ for (i = 0; i < ctx->input_count; i++)
+ if (ctx->inputs[i] && ctx->inputs[i]->type == type)
+ avfilter_formats_ref(fmts,
+ (AVFilterFormats**)((void*)ctx->inputs[i]+offout));
+
+ for (i = 0; i < ctx->output_count; i++)
+ if (ctx->outputs[i] && ctx->outputs[i]->type == type)
+ avfilter_formats_ref(fmts,
+ (AVFilterFormats**)((void*)ctx->outputs[i]+offin));
+
+ if (!fmts->refcount) {
+ av_free(fmts->formats);
+ av_free(fmts->refs);
+ av_free(fmts);
}
+}
- if (!count) {
- av_free(formats->formats);
- av_free(formats->refs);
- av_free(formats);
- }
+void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats)
+{
+ set_common_formats(ctx, formats, AVMEDIA_TYPE_VIDEO,
+ offsetof(AVFilterLink, in_formats),
+ offsetof(AVFilterLink, out_formats));
+}
+
+void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats)
+{
+ set_common_formats(ctx, formats, AVMEDIA_TYPE_AUDIO,
+ offsetof(AVFilterLink, in_formats),
+ offsetof(AVFilterLink, out_formats));
+}
+
+void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats)
+{
+ set_common_formats(ctx, formats, AVMEDIA_TYPE_AUDIO,
+ offsetof(AVFilterLink, in_chlayouts),
+ offsetof(AVFilterLink, out_chlayouts));
}
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_pixel_formats(ctx, avfilter_all_formats(AVMEDIA_TYPE_VIDEO));
+ avfilter_set_common_sample_formats(ctx, avfilter_all_formats(AVMEDIA_TYPE_AUDIO));
+ avfilter_set_common_channel_layouts(ctx, avfilter_all_channel_layouts());
- avfilter_set_common_formats(ctx, avfilter_all_formats(type));
return 0;
}