From 43c7a01e9879640859d32b062ac01700e1333c7a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 19 May 2012 10:37:56 +0200 Subject: [PATCH] lavfi: remove avfilter_default_* from public API on next bump. Those functions are only useful inside filters. It is better to not support user filters until the API is more stable. --- libavfilter/avfilter.h | 13 ++++++++++--- libavfilter/avfiltergraph.c | 2 +- libavfilter/formats.c | 9 ++++++++- libavfilter/formats.h | 2 ++ libavfilter/version.h | 3 +++ libavfilter/vf_vflip.c | 3 ++- libavfilter/vf_yadif.c | 3 ++- libavfilter/video.c | 35 +++++++++++++++++++++++++++-------- libavfilter/video.h | 24 ++++++++++++++++++++++++ tools/lavfi-showfiltfmts.c | 3 ++- 10 files changed, 81 insertions(+), 16 deletions(-) create mode 100644 libavfilter/video.h diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 711feca9e1..0d40b7664c 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -451,13 +451,17 @@ struct AVFilterPad { int (*config_props)(AVFilterLink *link); }; +#if FF_API_FILTERS_PUBLIC /** default handler for start_frame() for video inputs */ +attribute_deprecated void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); /** default handler for draw_slice() for video inputs */ +attribute_deprecated void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); /** default handler for end_frame() for video inputs */ +attribute_deprecated void avfilter_default_end_frame(AVFilterLink *link); #if FF_API_DEFAULT_CONFIG_OUTPUT_LINK @@ -467,9 +471,15 @@ int avfilter_default_config_output_link(AVFilterLink *link); #endif /** default handler for get_video_buffer() for video inputs */ +attribute_deprecated AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h); +/** Default handler for query_formats() */ +attribute_deprecated +int avfilter_default_query_formats(AVFilterContext *ctx); +#endif + /** * 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 @@ -477,9 +487,6 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, */ void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats); -/** Default handler for query_formats() */ -int avfilter_default_query_formats(AVFilterContext *ctx); - /** start_frame() handler for filters which simply pass video along */ void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 91a5f3233f..b2db5dcf97 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -161,7 +161,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) if (graph->filters[i]->filter->query_formats) graph->filters[i]->filter->query_formats(graph->filters[i]); else - avfilter_default_query_formats(graph->filters[i]); + ff_default_query_formats(graph->filters[i]); } /* go through and merge as many format lists as possible */ diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 36b4d6d682..63c63e32b4 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -364,7 +364,7 @@ void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) avfilter_formats_ref, formats); } -int avfilter_default_query_formats(AVFilterContext *ctx) +int ff_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 : @@ -378,3 +378,10 @@ int avfilter_default_query_formats(AVFilterContext *ctx) return 0; } + +#if FF_API_FILTERS_PUBLIC +int avfilter_default_query_formats(AVFilterContext *ctx) +{ + return ff_default_query_formats(ctx); +} +#endif diff --git a/libavfilter/formats.h b/libavfilter/formats.h index 7e0a60114c..9acd31f38a 100644 --- a/libavfilter/formats.h +++ b/libavfilter/formats.h @@ -75,4 +75,6 @@ void ff_channel_layouts_unref(AVFilterChannelLayouts **ref); void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, AVFilterChannelLayouts **newref); +int ff_default_query_formats(AVFilterContext *ctx); + #endif // AVFILTER_FORMATS_H diff --git a/libavfilter/version.h b/libavfilter/version.h index 5dd81c1dcd..6194876d25 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -56,5 +56,8 @@ #ifndef FF_API_DEFAULT_CONFIG_OUTPUT_LINK #define FF_API_DEFAULT_CONFIG_OUTPUT_LINK (LIBAVFILTER_VERSION_MAJOR < 3) #endif +#ifndef FF_API_FILTERS_PUBLIC +#define FF_API_FILTERS_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 3) +#endif #endif // AVFILTER_VERSION_H diff --git a/libavfilter/vf_vflip.c b/libavfilter/vf_vflip.c index 09ba303bb9..a7f14c0775 100644 --- a/libavfilter/vf_vflip.c +++ b/libavfilter/vf_vflip.c @@ -25,6 +25,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "video.h" typedef struct { int vsub; ///< vertical chroma subsampling @@ -47,7 +48,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, int i; if (!(perms & AV_PERM_NEG_LINESIZES)) - return avfilter_default_get_video_buffer(link, perms, w, h); + return ff_default_get_video_buffer(link, perms, w, h); picref = avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h); for (i = 0; i < 4; i ++) { diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 1cecdd98cb..0c72444bee 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -23,6 +23,7 @@ #include "libavutil/common.h" #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "video.h" #include "yadif.h" #undef NDEBUG @@ -180,7 +181,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, int w, int height= FFALIGN(h+2, 32); int i; - picref = avfilter_default_get_video_buffer(link, perms, width, height); + picref = ff_default_get_video_buffer(link, perms, width, height); picref->video->w = w; picref->video->h = h; diff --git a/libavfilter/video.c b/libavfilter/video.c index ad033f3b8f..74b08379bf 100644 --- a/libavfilter/video.c +++ b/libavfilter/video.c @@ -20,6 +20,7 @@ #include "avfilter.h" #include "internal.h" +#include "video.h" #ifdef DEBUG static char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms) @@ -72,7 +73,7 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, /* TODO: set the buffer's priv member to a context structure for the whole * filter chain. This will allow for a buffer pool instead of the constant * alloc & free cycle currently implemented. */ -AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h) +AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h) { int linesize[4]; uint8_t *data[4]; @@ -149,7 +150,7 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int ret = link->dstpad->get_video_buffer(link, perms, w, h); if (!ret) - ret = avfilter_default_get_video_buffer(link, perms, w, h); + ret = ff_default_get_video_buffer(link, perms, w, h); if (ret) ret->type = AVMEDIA_TYPE_VIDEO; @@ -164,7 +165,7 @@ void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) avfilter_start_frame(link->dst->outputs[0], picref); } -void avfilter_default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) +static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) { AVFilterLink *outlink = NULL; @@ -189,7 +190,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) FF_DPRINTF_START(NULL, start_frame); ff_dlog_link(NULL, link, 0); av_dlog(NULL, " "); ff_dlog_ref(NULL, picref, 1); if (!(start_frame = dst->start_frame)) - start_frame = avfilter_default_start_frame; + start_frame = default_start_frame; if (picref->linesize[0] < 0) perms |= AV_PERM_NEG_LINESIZES; @@ -215,7 +216,7 @@ void avfilter_null_end_frame(AVFilterLink *link) avfilter_end_frame(link->dst->outputs[0]); } -void avfilter_default_end_frame(AVFilterLink *inlink) +static void default_end_frame(AVFilterLink *inlink) { AVFilterLink *outlink = NULL; @@ -239,7 +240,7 @@ void avfilter_end_frame(AVFilterLink *link) void (*end_frame)(AVFilterLink *); if (!(end_frame = link->dstpad->end_frame)) - end_frame = avfilter_default_end_frame; + end_frame = default_end_frame; end_frame(link); @@ -256,7 +257,7 @@ void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir); } -void avfilter_default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) +static void default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { AVFilterLink *outlink = NULL; @@ -304,7 +305,25 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) } if (!(draw_slice = link->dstpad->draw_slice)) - draw_slice = avfilter_default_draw_slice; + draw_slice = default_draw_slice; draw_slice(link, y, h, slice_dir); } +#if FF_API_FILTERS_PUBLIC +AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h) +{ + return ff_default_get_video_buffer(link, perms, w, h); +} +void avfilter_default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) +{ + default_start_frame(inlink, picref); +} +void avfilter_default_end_frame(AVFilterLink *inlink) +{ + default_end_frame(inlink); +} +void avfilter_default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) +{ + default_draw_slice(inlink, y, h, slice_dir); +} +#endif diff --git a/libavfilter/video.h b/libavfilter/video.h new file mode 100644 index 0000000000..99f84ecde8 --- /dev/null +++ b/libavfilter/video.h @@ -0,0 +1,24 @@ +/* + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_VIDEO_H +#define AVFILTER_VIDEO_H + +AVFilterBufferRef *ff_default_get_video_buffer(AVFilterLink *link, + int perms, int w, int h); +#endif /* AVFILTER_VIDEO_H */ diff --git a/tools/lavfi-showfiltfmts.c b/tools/lavfi-showfiltfmts.c index d25cf3e138..146f0cd081 100644 --- a/tools/lavfi-showfiltfmts.c +++ b/tools/lavfi-showfiltfmts.c @@ -21,6 +21,7 @@ #include "libavformat/avformat.h" #include "libavutil/pixdesc.h" #include "libavfilter/avfilter.h" +#include "libavfilter/formats.h" int main(int argc, char **argv) { @@ -75,7 +76,7 @@ int main(int argc, char **argv) if (filter->query_formats) filter->query_formats(filter_ctx); else - avfilter_default_query_formats(filter_ctx); + ff_default_query_formats(filter_ctx); /* print the supported formats in input */ for (i = 0; i < filter_ctx->input_count; i++) {