aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/defaults.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-06-21 05:22:40 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-06-21 05:27:44 +0200
commit779d7610c71d267a88c787affd91000b826e812e (patch)
tree197be42d44c8fdf16b3f4fbdf12ad1e5e0f6de18 /libavfilter/defaults.c
parent56629aa0127e7f8f2f5dad3ebe794424b51afd64 (diff)
parentd39b33c63bc080231d8d6e79c6301a60b86150de (diff)
downloadffmpeg-779d7610c71d267a88c787affd91000b826e812e.tar.gz
Merge branch 'master' into oldabi
* master: (109 commits) libx264: fix open gop default. Please use -x264opts to force open gop This fixes Ticket268 avfilter picture pool: double free hotfix mpegaudio_parser: be less picky on the start position ppc32: Fix movrel Replace usages of av_get_bits_per_sample_fmt() with av_get_bytes_per_sample(). x86: cabac: fix register constraints for 32-bit mode cabac: move x86 asm to libavcodec/x86/cabac.h x86: h264: cast pointers to intptr_t rather than int x86: h264: remove hardcoded edi in decode_significance_8x8_x86() x86: h264: remove hardcoded esi in decode_significance[_8x8]_x86() x86: h264: remove hardcoded edx in decode_significance[_8x8]_x86() x86: h264: remove hardcoded eax in decode_significance[_8x8]_x86() x86: cabac: change 'a' constraint to 'r' in get_cabac_inline() x86: cabac: remove hardcoded esi in get_cabac_inline() x86: cabac: remove hardcoded edx in get_cabac_inline() x86: cabac: remove unused macro parameter x86: cabac: remove hardcoded ebx in inline asm x86: cabac: remove hardcoded struct offsets from inline asm cabac: remove inline asm under #if 0 cabac: remove BRANCHLESS_CABAC_DECODER switch ... Conflicts: cmdutils.c ffserver.c libavfilter/avfilter.h libavformat/avformat.h libavformat/utils.c libavformat/version.h libavutil/avutil.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
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;
}