00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "libavutil/avassert.h"
00023 #include "libavutil/audioconvert.h"
00024 #include "libavutil/imgutils.h"
00025 #include "libavutil/samplefmt.h"
00026
00027 #include "avfilter.h"
00028 #include "internal.h"
00029 #include "formats.h"
00030
00031 static void set_common_formats(AVFilterContext *ctx, AVFilterFormats *fmts,
00032 enum AVMediaType type, int offin, int offout)
00033 {
00034 int i;
00035 for (i = 0; i < ctx->input_count; i++)
00036 if (ctx->inputs[i] && ctx->inputs[i]->type == type)
00037 avfilter_formats_ref(fmts,
00038 (AVFilterFormats **)((uint8_t *)ctx->inputs[i]+offout));
00039
00040 for (i = 0; i < ctx->output_count; i++)
00041 if (ctx->outputs[i] && ctx->outputs[i]->type == type)
00042 avfilter_formats_ref(fmts,
00043 (AVFilterFormats **)((uint8_t *)ctx->outputs[i]+offin));
00044
00045 if (!fmts->refcount) {
00046 av_free(fmts->formats);
00047 av_free(fmts->refs);
00048 av_free(fmts);
00049 }
00050 }
00051
00052 void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats)
00053 {
00054 set_common_formats(ctx, formats, AVMEDIA_TYPE_VIDEO,
00055 offsetof(AVFilterLink, in_formats),
00056 offsetof(AVFilterLink, out_formats));
00057 }
00058
00059 void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats)
00060 {
00061 set_common_formats(ctx, formats, AVMEDIA_TYPE_AUDIO,
00062 offsetof(AVFilterLink, in_formats),
00063 offsetof(AVFilterLink, out_formats));
00064 }
00065
00066 void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats)
00067 {
00068 set_common_formats(ctx, formats, AVMEDIA_TYPE_AUDIO,
00069 offsetof(AVFilterLink, in_channel_layouts),
00070 offsetof(AVFilterLink, out_channel_layouts));
00071 }
00072
00073 #if FF_API_PACKING
00074 void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats)
00075 {
00076 set_common_formats(ctx, formats, AVMEDIA_TYPE_AUDIO,
00077 offsetof(AVFilterLink, in_packing),
00078 offsetof(AVFilterLink, out_packing));
00079 }
00080 #endif