2008-02-15 21:58:25 +00:00
|
|
|
/*
|
|
|
|
* Filter layer - default implementations
|
2010-11-28 10:22:58 +00:00
|
|
|
* Copyright (c) 2007 Bobby Bingham
|
2008-02-15 21:58:25 +00:00
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2011-12-25 22:35:06 +00:00
|
|
|
#include "libavutil/avassert.h"
|
2011-02-07 13:37:08 +00:00
|
|
|
#include "libavutil/audioconvert.h"
|
|
|
|
#include "libavutil/imgutils.h"
|
|
|
|
#include "libavutil/samplefmt.h"
|
2012-05-07 08:51:23 +00:00
|
|
|
|
2008-02-15 21:58:25 +00:00
|
|
|
#include "avfilter.h"
|
2010-11-25 20:50:23 +00:00
|
|
|
#include "internal.h"
|
2012-05-06 05:00:22 +00:00
|
|
|
#include "formats.h"
|
2008-02-15 21:58:25 +00:00
|
|
|
|
2011-06-19 18:31:24 +00:00
|
|
|
static void set_common_formats(AVFilterContext *ctx, AVFilterFormats *fmts,
|
|
|
|
enum AVMediaType type, int offin, int offout)
|
2008-02-15 21:58:25 +00:00
|
|
|
{
|
2011-06-19 18:31:24 +00:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < ctx->input_count; i++)
|
|
|
|
if (ctx->inputs[i] && ctx->inputs[i]->type == type)
|
|
|
|
avfilter_formats_ref(fmts,
|
2011-08-06 10:42:02 +00:00
|
|
|
(AVFilterFormats **)((uint8_t *)ctx->inputs[i]+offout));
|
2011-06-19 18:31:24 +00:00
|
|
|
|
|
|
|
for (i = 0; i < ctx->output_count; i++)
|
|
|
|
if (ctx->outputs[i] && ctx->outputs[i]->type == type)
|
|
|
|
avfilter_formats_ref(fmts,
|
2011-08-06 10:42:02 +00:00
|
|
|
(AVFilterFormats **)((uint8_t *)ctx->outputs[i]+offin));
|
2011-06-19 18:31:24 +00:00
|
|
|
|
|
|
|
if (!fmts->refcount) {
|
|
|
|
av_free(fmts->formats);
|
|
|
|
av_free(fmts->refs);
|
|
|
|
av_free(fmts);
|
2008-02-15 22:00:03 +00:00
|
|
|
}
|
2011-06-19 18:31:24 +00:00
|
|
|
}
|
2008-02-15 22:00:03 +00:00
|
|
|
|
2011-06-19 18:31:24 +00:00
|
|
|
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,
|
2012-05-16 00:27:31 +00:00
|
|
|
offsetof(AVFilterLink, in_channel_layouts),
|
|
|
|
offsetof(AVFilterLink, out_channel_layouts));
|
2008-02-15 22:00:03 +00:00
|
|
|
}
|
|
|
|
|
2012-05-12 15:38:47 +00:00
|
|
|
#if FF_API_PACKING
|
2011-06-28 05:56:19 +00:00
|
|
|
void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats)
|
|
|
|
{
|
|
|
|
set_common_formats(ctx, formats, AVMEDIA_TYPE_AUDIO,
|
|
|
|
offsetof(AVFilterLink, in_packing),
|
|
|
|
offsetof(AVFilterLink, out_packing));
|
|
|
|
}
|
2012-05-12 15:38:47 +00:00
|
|
|
#endif
|