From b74a1da49db5ebed51aceae6cacc2329288a92c1 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 30 May 2012 10:12:55 +0200 Subject: lavfi: make formats API private on next bump. It is only useful inside filters and we don't allow user filters for now. --- libavfilter/af_aformat.c | 8 +-- libavfilter/af_amix.c | 4 +- libavfilter/af_resample.c | 12 ++-- libavfilter/avfilter.c | 20 +++---- libavfilter/avfilter.h | 140 +++++++------------------------------------- libavfilter/avfiltergraph.c | 18 +++--- libavfilter/buffersrc.c | 10 ++-- libavfilter/formats.c | 58 ++++++++++++++---- libavfilter/formats.h | 138 +++++++++++++++++++++++++++++++++++++++++++ libavfilter/vf_blackframe.c | 3 +- libavfilter/vf_boxblur.c | 3 +- libavfilter/vf_crop.c | 3 +- libavfilter/vf_cropdetect.c | 3 +- libavfilter/vf_delogo.c | 3 +- libavfilter/vf_drawbox.c | 3 +- libavfilter/vf_drawtext.c | 3 +- libavfilter/vf_fade.c | 3 +- libavfilter/vf_fieldorder.c | 9 +-- libavfilter/vf_format.c | 5 +- libavfilter/vf_frei0r.c | 9 +-- libavfilter/vf_gradfun.c | 3 +- libavfilter/vf_hflip.c | 3 +- libavfilter/vf_hqdn3d.c | 3 +- libavfilter/vf_libopencv.c | 2 +- libavfilter/vf_lut.c | 3 +- libavfilter/vf_overlay.c | 11 ++-- libavfilter/vf_pad.c | 3 +- libavfilter/vf_scale.c | 13 ++-- libavfilter/vf_transpose.c | 3 +- libavfilter/vf_unsharp.c | 3 +- libavfilter/vf_yadif.c | 3 +- libavfilter/vsrc_color.c | 3 +- libavfilter/vsrc_movie.c | 3 +- libavfilter/vsrc_nullsrc.c | 1 + libavfilter/vsrc_testsrc.c | 5 +- 35 files changed, 307 insertions(+), 210 deletions(-) (limited to 'libavfilter') diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c index 84442d379e..3a75b925dd 100644 --- a/libavfilter/af_aformat.c +++ b/libavfilter/af_aformat.c @@ -105,8 +105,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) } PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats, - avfilter_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format"); - PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, avfilter_add_format, + ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format"); + PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format, get_sample_rate, 0, "sample rate"); PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts, ff_add_channel_layout, av_get_channel_layout, 0, @@ -121,8 +121,8 @@ static int query_formats(AVFilterContext *ctx) { AFormatContext *s = ctx->priv; - avfilter_set_common_formats(ctx, s->formats ? s->formats : - avfilter_all_formats(AVMEDIA_TYPE_AUDIO)); + ff_set_common_formats(ctx, s->formats ? s->formats : + ff_all_formats(AVMEDIA_TYPE_AUDIO)); ff_set_common_samplerates(ctx, s->sample_rates ? s->sample_rates : ff_all_samplerates()); ff_set_common_channel_layouts(ctx, s->channel_layouts ? s->channel_layouts : diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c index d4af9a4234..d33d96ba6e 100644 --- a/libavfilter/af_amix.c +++ b/libavfilter/af_amix.c @@ -525,8 +525,8 @@ static void uninit(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - avfilter_add_format(&formats, AV_SAMPLE_FMT_FLT); - avfilter_set_common_formats(ctx, formats); + ff_add_format(&formats, AV_SAMPLE_FMT_FLT); + ff_set_common_formats(ctx, formats); ff_set_common_channel_layouts(ctx, ff_all_channel_layouts()); ff_set_common_samplerates(ctx, ff_all_samplerates()); return 0; diff --git a/libavfilter/af_resample.c b/libavfilter/af_resample.c index 1fc8c04b4a..6b1dfbc085 100644 --- a/libavfilter/af_resample.c +++ b/libavfilter/af_resample.c @@ -55,18 +55,18 @@ static int query_formats(AVFilterContext *ctx) AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; - AVFilterFormats *in_formats = avfilter_all_formats(AVMEDIA_TYPE_AUDIO); - AVFilterFormats *out_formats = avfilter_all_formats(AVMEDIA_TYPE_AUDIO); + AVFilterFormats *in_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO); + AVFilterFormats *out_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO); AVFilterFormats *in_samplerates = ff_all_samplerates(); AVFilterFormats *out_samplerates = ff_all_samplerates(); AVFilterChannelLayouts *in_layouts = ff_all_channel_layouts(); AVFilterChannelLayouts *out_layouts = ff_all_channel_layouts(); - avfilter_formats_ref(in_formats, &inlink->out_formats); - avfilter_formats_ref(out_formats, &outlink->in_formats); + ff_formats_ref(in_formats, &inlink->out_formats); + ff_formats_ref(out_formats, &outlink->in_formats); - avfilter_formats_ref(in_samplerates, &inlink->out_samplerates); - avfilter_formats_ref(out_samplerates, &outlink->in_samplerates); + ff_formats_ref(in_samplerates, &inlink->out_samplerates); + ff_formats_ref(out_samplerates, &outlink->in_samplerates); ff_channel_layouts_ref(in_layouts, &inlink->out_channel_layouts); ff_channel_layouts_ref(out_layouts, &outlink->in_channel_layouts); diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 2f5c37d3af..8594b8365c 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -120,10 +120,10 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, /* if any information on supported media formats already exists on the * link, we need to preserve that */ if (link->out_formats) - avfilter_formats_changeref(&link->out_formats, + ff_formats_changeref(&link->out_formats, &filt->outputs[filt_dstpad_idx]->out_formats); if (link->out_samplerates) - avfilter_formats_changeref(&link->out_samplerates, + ff_formats_changeref(&link->out_samplerates, &filt->outputs[filt_dstpad_idx]->out_samplerates); if (link->out_channel_layouts) ff_channel_layouts_changeref(&link->out_channel_layouts, @@ -380,10 +380,10 @@ void avfilter_free(AVFilterContext *filter) if ((link = filter->inputs[i])) { if (link->src) link->src->outputs[link->srcpad - link->src->output_pads] = NULL; - avfilter_formats_unref(&link->in_formats); - avfilter_formats_unref(&link->out_formats); - avfilter_formats_unref(&link->in_samplerates); - avfilter_formats_unref(&link->out_samplerates); + ff_formats_unref(&link->in_formats); + ff_formats_unref(&link->out_formats); + ff_formats_unref(&link->in_samplerates); + ff_formats_unref(&link->out_samplerates); ff_channel_layouts_unref(&link->in_channel_layouts); ff_channel_layouts_unref(&link->out_channel_layouts); } @@ -393,10 +393,10 @@ void avfilter_free(AVFilterContext *filter) if ((link = filter->outputs[i])) { if (link->dst) link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL; - avfilter_formats_unref(&link->in_formats); - avfilter_formats_unref(&link->out_formats); - avfilter_formats_unref(&link->in_samplerates); - avfilter_formats_unref(&link->out_samplerates); + ff_formats_unref(&link->in_formats); + ff_formats_unref(&link->out_formats); + ff_formats_unref(&link->in_samplerates); + ff_formats_unref(&link->out_samplerates); ff_channel_layouts_unref(&link->in_channel_layouts); ff_channel_layouts_unref(&link->out_channel_layouts); } diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 289c06c331..37e783e41e 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -52,6 +52,7 @@ const char *avfilter_license(void); typedef struct AVFilterContext AVFilterContext; typedef struct AVFilterLink AVFilterLink; typedef struct AVFilterPad AVFilterPad; +typedef struct AVFilterFormats AVFilterFormats; /** * A reference-counted buffer data type used by the filter system. Filters @@ -197,134 +198,42 @@ AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask); */ void avfilter_unref_buffer(AVFilterBufferRef *ref); +#if FF_API_FILTERS_PUBLIC /** - * A list of supported formats for one end of a filter link. This is used - * during the format negotiation process to try to pick the best format to - * use to minimize the number of necessary conversions. Each filter gives a - * list of the formats supported by each input and output pad. The list - * given for each pad need not be distinct - they may be references to the - * same list of formats, as is often the case when a filter supports multiple - * formats, but will always output the same format as it is given in input. - * - * In this way, a list of possible input formats and a list of possible - * output formats are associated with each link. When a set of formats is - * negotiated over a link, the input and output lists are merged to form a - * new list containing only the common elements of each list. In the case - * that there were no common elements, a format conversion is necessary. - * Otherwise, the lists are merged, and all other links which reference - * either of the format lists involved in the merge are also affected. - * - * For example, consider the filter chain: - * filter (a) --> (b) filter (b) --> (c) filter - * - * where the letters in parenthesis indicate a list of formats supported on - * the input or output of the link. Suppose the lists are as follows: - * (a) = {A, B} - * (b) = {A, B, C} - * (c) = {B, C} - * - * First, the first link's lists are merged, yielding: - * filter (a) --> (a) filter (a) --> (c) filter - * - * Notice that format list (b) now refers to the same list as filter list (a). - * Next, the lists for the second link are merged, yielding: - * filter (a) --> (a) filter (a) --> (a) filter - * - * where (a) = {B}. - * - * Unfortunately, when the format lists at the two ends of a link are merged, - * we must ensure that all links which reference either pre-merge format list - * get updated as well. Therefore, we have the format list structure store a - * pointer to each of the pointers to itself. + * @addtogroup lavfi_deprecated + * @deprecated Those functions are only useful inside filters and + * user filters are not supported at this point. + * @{ */ -typedef struct AVFilterFormats { +struct AVFilterFormats { unsigned format_count; ///< number of formats int *formats; ///< list of media formats unsigned refcount; ///< number of references to this list struct AVFilterFormats ***refs; ///< references to this list -} AVFilterFormats; +}; -/** - * Create a list of supported formats. This is intended for use in - * AVFilter->query_formats(). - * - * @param fmts list of media formats, terminated by -1 - * @return the format list, with no existing references - */ +attribute_deprecated AVFilterFormats *avfilter_make_format_list(const int *fmts); - -/** - * Add fmt to the list of media formats contained in *avff. - * If *avff is NULL the function allocates the filter formats struct - * and puts its pointer in *avff. - * - * @return a non negative value in case of success, or a negative - * value corresponding to an AVERROR code in case of error - */ +attribute_deprecated int avfilter_add_format(AVFilterFormats **avff, int fmt); - -/** - * Return a list of all formats supported by Libav for the given media type. - */ +attribute_deprecated AVFilterFormats *avfilter_all_formats(enum AVMediaType type); - -/** - * Return a format list which contains the intersection of the formats of - * a and b. Also, all the references of a, all the references of b, and - * a and b themselves will be deallocated. - * - * If a and b do not share any common formats, neither is modified, and NULL - * is returned. - */ +attribute_deprecated AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b); - -/** - * Add *ref as a new reference to formats. - * That is the pointers will point like in the ascii art below: - * ________ - * |formats |<--------. - * | ____ | ____|___________________ - * | |refs| | | __|_ - * | |* * | | | | | | AVFilterLink - * | |* *--------->|*ref| - * | |____| | | |____| - * |________| |________________________ - */ +attribute_deprecated void avfilter_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref); - -/** - * If *ref is non-NULL, remove *ref as a reference to the format list - * it currently points to, deallocates that list if this was the last - * reference, and sets *ref to NULL. - * - * Before After - * ________ ________ NULL - * |formats |<--------. |formats | ^ - * | ____ | ____|________________ | ____ | ____|________________ - * | |refs| | | __|_ | |refs| | | __|_ - * | |* * | | | | | | AVFilterLink | |* * | | | | | | AVFilterLink - * | |* *--------->|*ref| | |* | | | |*ref| - * | |____| | | |____| | |____| | | |____| - * |________| |_____________________ |________| |_____________________ - */ +attribute_deprecated void avfilter_formats_unref(AVFilterFormats **ref); - -/** - * - * Before After - * ________ ________ - * |formats |<---------. |formats |<---------. - * | ____ | ___|___ | ____ | ___|___ - * | |refs| | | | | | |refs| | | | | NULL - * | |* *--------->|*oldref| | |* *--------->|*newref| ^ - * | |* * | | |_______| | |* * | | |_______| ___|___ - * | |____| | | |____| | | | | - * |________| |________| |*oldref| - * |_______| - */ +attribute_deprecated void avfilter_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref); +attribute_deprecated +void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats); +/** + * @} + */ +#endif /** * A filter pad used for either input or output. @@ -479,13 +388,6 @@ 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 - * freed. - */ -void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats); - #if FF_API_FILTERS_PUBLIC /** start_frame() handler for filters which simply pass video along */ attribute_deprecated diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index bc275142d2..42bf1f7547 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -189,7 +189,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) continue; if (link->in_formats != link->out_formats && - !avfilter_merge_formats(link->in_formats, + !ff_merge_formats(link->in_formats, link->out_formats)) convert_needed = 1; if (link->type == AVMEDIA_TYPE_AUDIO) { @@ -246,8 +246,8 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) convert->filter->query_formats(convert); inlink = convert->inputs[0]; outlink = convert->outputs[0]; - if (!avfilter_merge_formats( inlink->in_formats, inlink->out_formats) || - !avfilter_merge_formats(outlink->in_formats, outlink->out_formats)) + if (!ff_merge_formats( inlink->in_formats, inlink->out_formats) || + !ff_merge_formats(outlink->in_formats, outlink->out_formats)) ret |= AVERROR(ENOSYS); if (inlink->type == AVMEDIA_TYPE_AUDIO && (!ff_merge_samplerates(inlink->in_samplerates, @@ -303,10 +303,10 @@ static int pick_format(AVFilterLink *link) link->channel_layout = link->in_channel_layouts->channel_layouts[0]; } - avfilter_formats_unref(&link->in_formats); - avfilter_formats_unref(&link->out_formats); - avfilter_formats_unref(&link->in_samplerates); - avfilter_formats_unref(&link->out_samplerates); + ff_formats_unref(&link->in_formats); + ff_formats_unref(&link->out_formats); + ff_formats_unref(&link->in_samplerates); + ff_formats_unref(&link->out_samplerates); ff_channel_layouts_unref(&link->in_channel_layouts); ff_channel_layouts_unref(&link->out_channel_layouts); @@ -353,9 +353,9 @@ static int reduce_formats_on_filter(AVFilterContext *filter) int i, j, k, ret = 0; REDUCE_FORMATS(int, AVFilterFormats, formats, formats, - format_count, avfilter_add_format); + format_count, ff_add_format); REDUCE_FORMATS(int, AVFilterFormats, samplerates, formats, - format_count, avfilter_add_format); + format_count, ff_add_format); REDUCE_FORMATS(uint64_t, AVFilterChannelLayouts, channel_layouts, channel_layouts, nb_channel_layouts, ff_add_channel_layout); diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index ca9390aa5a..f78b8f6eff 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -284,14 +284,14 @@ static int query_formats(AVFilterContext *ctx) switch (ctx->outputs[0]->type) { case AVMEDIA_TYPE_VIDEO: - avfilter_add_format(&formats, c->pix_fmt); - avfilter_set_common_formats(ctx, formats); + ff_add_format(&formats, c->pix_fmt); + ff_set_common_formats(ctx, formats); break; case AVMEDIA_TYPE_AUDIO: - avfilter_add_format(&formats, c->sample_fmt); - avfilter_set_common_formats(ctx, formats); + ff_add_format(&formats, c->sample_fmt); + ff_set_common_formats(ctx, formats); - avfilter_add_format(&samplerates, c->sample_rate); + ff_add_format(&samplerates, c->sample_rate); ff_set_common_samplerates(ctx, samplerates); ff_add_channel_layout(&channel_layouts, c->channel_layout); diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 63c63e32b4..83bdcd7a7a 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -76,7 +76,7 @@ do { MERGE_REF(ret, b, fmts, type, fail); \ } while (0) -AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) +AVFilterFormats *ff_merge_formats(AVFilterFormats *a, AVFilterFormats *b) { AVFilterFormats *ret = NULL; @@ -161,7 +161,7 @@ int ff_fmt_is_in(int fmt, const int *fmts) return 0; } -AVFilterFormats *avfilter_make_format_list(const int *fmts) +AVFilterFormats *ff_make_format_list(const int *fmts) { AVFilterFormats *formats; int count; @@ -195,7 +195,7 @@ do { \ return 0; \ } while (0) -int avfilter_add_format(AVFilterFormats **avff, int fmt) +int ff_add_format(AVFilterFormats **avff, int fmt) { ADD_FORMAT(avff, fmt, int, formats, format_count); } @@ -205,7 +205,7 @@ int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout) ADD_FORMAT(l, channel_layout, uint64_t, channel_layouts, nb_channel_layouts); } -AVFilterFormats *avfilter_all_formats(enum AVMediaType type) +AVFilterFormats *ff_all_formats(enum AVMediaType type) { AVFilterFormats *ret = NULL; int fmt; @@ -215,7 +215,7 @@ AVFilterFormats *avfilter_all_formats(enum AVMediaType type) for (fmt = 0; fmt < num_formats; fmt++) if ((type != AVMEDIA_TYPE_VIDEO) || (type == AVMEDIA_TYPE_VIDEO && !(av_pix_fmt_descriptors[fmt].flags & PIX_FMT_HWACCEL))) - avfilter_add_format(&ret, fmt); + ff_add_format(&ret, fmt); return ret; } @@ -244,7 +244,7 @@ void ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts ** FORMATS_REF(f, ref); } -void avfilter_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) +void ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) { FORMATS_REF(f, ref); } @@ -280,7 +280,7 @@ do { \ *ref = NULL; \ } while (0) -void avfilter_formats_unref(AVFilterFormats **ref) +void ff_formats_unref(AVFilterFormats **ref) { FORMATS_UNREF(ref, formats); } @@ -309,8 +309,7 @@ void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, FORMATS_CHANGEREF(oldref, newref); } -void avfilter_formats_changeref(AVFilterFormats **oldref, - AVFilterFormats **newref) +void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) { FORMATS_CHANGEREF(oldref, newref); } @@ -350,7 +349,7 @@ void ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates) { SET_COMMON_FORMATS(ctx, samplerates, in_samplerates, out_samplerates, - avfilter_formats_ref, formats); + ff_formats_ref, formats); } /** @@ -358,10 +357,10 @@ void ff_set_common_samplerates(AVFilterContext *ctx, * formats. If there are no links hooked to this filter, the list of formats is * freed. */ -void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) +void ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) { SET_COMMON_FORMATS(ctx, formats, in_formats, out_formats, - avfilter_formats_ref, formats); + ff_formats_ref, formats); } int ff_default_query_formats(AVFilterContext *ctx) @@ -370,7 +369,7 @@ int ff_default_query_formats(AVFilterContext *ctx) ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type : AVMEDIA_TYPE_VIDEO; - avfilter_set_common_formats(ctx, avfilter_all_formats(type)); + ff_set_common_formats(ctx, ff_all_formats(type)); if (type == AVMEDIA_TYPE_AUDIO) { ff_set_common_channel_layouts(ctx, ff_all_channel_layouts()); ff_set_common_samplerates(ctx, ff_all_samplerates()); @@ -384,4 +383,37 @@ int avfilter_default_query_formats(AVFilterContext *ctx) { return ff_default_query_formats(ctx); } +void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) +{ + ff_set_common_formats(ctx, formats); +} +AVFilterFormats *avfilter_make_format_list(const int *fmts) +{ + return ff_make_format_list(fmts); +} +int avfilter_add_format(AVFilterFormats **avff, int fmt) +{ + return ff_add_format(avff, fmt); +} +AVFilterFormats *avfilter_all_formats(enum AVMediaType type) +{ + return ff_all_formats(type); +} +AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b) +{ + return ff_merge_formats(a, b); +} +void avfilter_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) +{ + ff_formats_ref(f, ref); +} +void avfilter_formats_unref(AVFilterFormats **ref) +{ + ff_formats_unref(ref); +} +void avfilter_formats_changeref(AVFilterFormats **oldref, + AVFilterFormats **newref) +{ + ff_formats_changeref(oldref, newref); +} #endif diff --git a/libavfilter/formats.h b/libavfilter/formats.h index 9acd31f38a..8961cb1a65 100644 --- a/libavfilter/formats.h +++ b/libavfilter/formats.h @@ -21,6 +21,56 @@ #include "avfilter.h" +/** + * A list of supported formats for one end of a filter link. This is used + * during the format negotiation process to try to pick the best format to + * use to minimize the number of necessary conversions. Each filter gives a + * list of the formats supported by each input and output pad. The list + * given for each pad need not be distinct - they may be references to the + * same list of formats, as is often the case when a filter supports multiple + * formats, but will always output the same format as it is given in input. + * + * In this way, a list of possible input formats and a list of possible + * output formats are associated with each link. When a set of formats is + * negotiated over a link, the input and output lists are merged to form a + * new list containing only the common elements of each list. In the case + * that there were no common elements, a format conversion is necessary. + * Otherwise, the lists are merged, and all other links which reference + * either of the format lists involved in the merge are also affected. + * + * For example, consider the filter chain: + * filter (a) --> (b) filter (b) --> (c) filter + * + * where the letters in parenthesis indicate a list of formats supported on + * the input or output of the link. Suppose the lists are as follows: + * (a) = {A, B} + * (b) = {A, B, C} + * (c) = {B, C} + * + * First, the first link's lists are merged, yielding: + * filter (a) --> (a) filter (a) --> (c) filter + * + * Notice that format list (b) now refers to the same list as filter list (a). + * Next, the lists for the second link are merged, yielding: + * filter (a) --> (a) filter (a) --> (a) filter + * + * where (a) = {B}. + * + * Unfortunately, when the format lists at the two ends of a link are merged, + * we must ensure that all links which reference either pre-merge format list + * get updated as well. Therefore, we have the format list structure store a + * pointer to each of the pointers to itself. + */ +#if !FF_API_FILTERS_PUBLIC +struct AVFilterFormats { + unsigned format_count; ///< number of formats + int *formats; ///< list of media formats + + unsigned refcount; ///< number of references to this list + struct AVFilterFormats ***refs; ///< references to this list +}; +#endif + typedef struct AVFilterChannelLayouts { uint64_t *channel_layouts; ///< list of channel layouts int nb_channel_layouts; ///< number of channel layouts @@ -59,6 +109,13 @@ void ff_set_common_channel_layouts(AVFilterContext *ctx, void ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates); +/** + * 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. + */ +void ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats); + int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout); /** @@ -77,4 +134,85 @@ void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, int ff_default_query_formats(AVFilterContext *ctx); + +/** + * Create a list of supported formats. This is intended for use in + * AVFilter->query_formats(). + * + * @param fmts list of media formats, terminated by -1 + * @return the format list, with no existing references + */ +AVFilterFormats *ff_make_format_list(const int *fmts); + +/** + * Add fmt to the list of media formats contained in *avff. + * If *avff is NULL the function allocates the filter formats struct + * and puts its pointer in *avff. + * + * @return a non negative value in case of success, or a negative + * value corresponding to an AVERROR code in case of error + */ +int ff_add_format(AVFilterFormats **avff, int fmt); + +/** + * Return a list of all formats supported by Libav for the given media type. + */ +AVFilterFormats *ff_all_formats(enum AVMediaType type); + +/** + * Return a format list which contains the intersection of the formats of + * a and b. Also, all the references of a, all the references of b, and + * a and b themselves will be deallocated. + * + * If a and b do not share any common formats, neither is modified, and NULL + * is returned. + */ +AVFilterFormats *ff_merge_formats(AVFilterFormats *a, AVFilterFormats *b); + +/** + * Add *ref as a new reference to formats. + * That is the pointers will point like in the ascii art below: + * ________ + * |formats |<--------. + * | ____ | ____|___________________ + * | |refs| | | __|_ + * | |* * | | | | | | AVFilterLink + * | |* *--------->|*ref| + * | |____| | | |____| + * |________| |________________________ + */ +void ff_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref); + +/** + * If *ref is non-NULL, remove *ref as a reference to the format list + * it currently points to, deallocates that list if this was the last + * reference, and sets *ref to NULL. + * + * Before After + * ________ ________ NULL + * |formats |<--------. |formats | ^ + * | ____ | ____|________________ | ____ | ____|________________ + * | |refs| | | __|_ | |refs| | | __|_ + * | |* * | | | | | | AVFilterLink | |* * | | | | | | AVFilterLink + * | |* *--------->|*ref| | |* | | | |*ref| + * | |____| | | |____| | |____| | | |____| + * |________| |_____________________ |________| |_____________________ + */ +void ff_formats_unref(AVFilterFormats **ref); + +/** + * + * Before After + * ________ ________ + * |formats |<---------. |formats |<---------. + * | ____ | ___|___ | ____ | ___|___ + * | |refs| | | | | | |refs| | | | | NULL + * | |* *--------->|*oldref| | |* *--------->|*newref| ^ + * | |* * | | |_______| | |* * | | |_______| ___|___ + * | |____| | | |____| | | | | + * |________| |________| |*oldref| + * |_______| + */ +void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref); + #endif // AVFILTER_FORMATS_H diff --git a/libavfilter/vf_blackframe.c b/libavfilter/vf_blackframe.c index 7e69ccb1f6..bdc132285e 100644 --- a/libavfilter/vf_blackframe.c +++ b/libavfilter/vf_blackframe.c @@ -28,6 +28,7 @@ */ #include "avfilter.h" +#include "formats.h" #include "video.h" typedef struct { @@ -45,7 +46,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_boxblur.c b/libavfilter/vf_boxblur.c index fa739de48d..04486ce1a8 100644 --- a/libavfilter/vf_boxblur.c +++ b/libavfilter/vf_boxblur.c @@ -29,6 +29,7 @@ #include "libavutil/eval.h" #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "formats.h" static const char *const var_names[] = { "w", @@ -129,7 +130,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index 5452601068..cb8b94ef7e 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -26,6 +26,7 @@ /* #define DEBUG */ #include "avfilter.h" +#include "formats.h" #include "video.h" #include "libavutil/eval.h" #include "libavutil/avstring.h" @@ -106,7 +107,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c index d321afdd40..20bc219d81 100644 --- a/libavfilter/vf_cropdetect.c +++ b/libavfilter/vf_cropdetect.c @@ -25,6 +25,7 @@ #include "libavutil/imgutils.h" #include "avfilter.h" +#include "formats.h" #include "video.h" typedef struct { @@ -47,7 +48,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index a54abe1a79..3410982b63 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -29,6 +29,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "formats.h" #include "video.h" /** @@ -165,7 +166,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c index fc80402f60..46ce6979a0 100644 --- a/libavfilter/vf_drawbox.c +++ b/libavfilter/vf_drawbox.c @@ -28,6 +28,7 @@ #include "libavutil/pixdesc.h" #include "libavutil/parseutils.h" #include "avfilter.h" +#include "formats.h" #include "video.h" enum { Y, U, V, A }; @@ -71,7 +72,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 5ef0d8c1ca..92f14a7ba8 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -41,6 +41,7 @@ #include "libavutil/lfg.h" #include "avfilter.h" #include "drawutils.h" +#include "formats.h" #include "video.h" #undef time @@ -396,7 +397,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c index a0f37d2ad5..8bd4074592 100644 --- a/libavfilter/vf_fade.c +++ b/libavfilter/vf_fade.c @@ -27,6 +27,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "formats.h" #include "video.h" typedef struct { @@ -79,7 +80,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c index 444dffb52c..d975aab974 100644 --- a/libavfilter/vf_fieldorder.c +++ b/libavfilter/vf_fieldorder.c @@ -28,6 +28,7 @@ #include "libavutil/imgutils.h" #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "formats.h" typedef struct { @@ -76,12 +77,12 @@ static int query_formats(AVFilterContext *ctx) || av_pix_fmt_descriptors[pix_fmt].flags & PIX_FMT_BITSTREAM) && av_pix_fmt_descriptors[pix_fmt].nb_components && !av_pix_fmt_descriptors[pix_fmt].log2_chroma_h - && (ret = avfilter_add_format(&formats, pix_fmt)) < 0) { - avfilter_formats_unref(&formats); + && (ret = ff_add_format(&formats, pix_fmt)) < 0) { + ff_formats_unref(&formats); return ret; } - avfilter_formats_ref(formats, &ctx->inputs[0]->out_formats); - avfilter_formats_ref(formats, &ctx->outputs[0]->in_formats); + ff_formats_ref(formats, &ctx->inputs[0]->out_formats); + ff_formats_ref(formats, &ctx->outputs[0]->in_formats); } return 0; diff --git a/libavfilter/vf_format.c b/libavfilter/vf_format.c index aaaca277df..fff616b06a 100644 --- a/libavfilter/vf_format.c +++ b/libavfilter/vf_format.c @@ -25,6 +25,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "formats.h" #include "video.h" typedef struct { @@ -89,7 +90,7 @@ static AVFilterFormats *make_format_list(FormatContext *format, int flag) #if CONFIG_FORMAT_FILTER static int query_formats_format(AVFilterContext *ctx) { - avfilter_set_common_formats(ctx, make_format_list(ctx->priv, 1)); + ff_set_common_formats(ctx, make_format_list(ctx->priv, 1)); return 0; } @@ -119,7 +120,7 @@ AVFilter avfilter_vf_format = { #if CONFIG_NOFORMAT_FILTER static int query_formats_noformat(AVFilterContext *ctx) { - avfilter_set_common_formats(ctx, make_format_list(ctx->priv, 0)); + ff_set_common_formats(ctx, make_format_list(ctx->priv, 0)); return 0; } diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c index 455e24a7f1..4dd6fbef09 100644 --- a/libavfilter/vf_frei0r.c +++ b/libavfilter/vf_frei0r.c @@ -31,6 +31,7 @@ #include "libavutil/mathematics.h" #include "libavutil/parseutils.h" #include "avfilter.h" +#include "formats.h" typedef f0r_instance_t (*f0r_construct_f)(unsigned int width, unsigned int height); typedef void (*f0r_destruct_f)(f0r_instance_t instance); @@ -320,20 +321,20 @@ static int query_formats(AVFilterContext *ctx) AVFilterFormats *formats = NULL; if (frei0r->plugin_info.color_model == F0R_COLOR_MODEL_BGRA8888) { - avfilter_add_format(&formats, PIX_FMT_BGRA); + ff_add_format(&formats, PIX_FMT_BGRA); } else if (frei0r->plugin_info.color_model == F0R_COLOR_MODEL_RGBA8888) { - avfilter_add_format(&formats, PIX_FMT_RGBA); + ff_add_format(&formats, PIX_FMT_RGBA); } else { /* F0R_COLOR_MODEL_PACKED32 */ static const enum PixelFormat pix_fmts[] = { PIX_FMT_BGRA, PIX_FMT_ARGB, PIX_FMT_ABGR, PIX_FMT_ARGB, PIX_FMT_NONE }; - formats = avfilter_make_format_list(pix_fmts); + formats = ff_make_format_list(pix_fmts); } if (!formats) return AVERROR(ENOMEM); - avfilter_set_common_formats(ctx, formats); + ff_set_common_formats(ctx, formats); return 0; } diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c index 9da9b20a70..b61c06317c 100644 --- a/libavfilter/vf_gradfun.c +++ b/libavfilter/vf_gradfun.c @@ -36,6 +36,7 @@ #include "libavutil/cpu.h" #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "formats.h" #include "gradfun.h" DECLARE_ALIGNED(16, static const uint16_t, dither)[8][8] = { @@ -160,7 +161,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c index c92296e61a..5e87a7dc13 100644 --- a/libavfilter/vf_hflip.c +++ b/libavfilter/vf_hflip.c @@ -25,6 +25,7 @@ */ #include "avfilter.h" +#include "formats.h" #include "libavutil/pixdesc.h" #include "libavutil/intreadwrite.h" #include "libavutil/imgutils.h" @@ -62,7 +63,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c index 2e9a89510b..51de0d8de6 100644 --- a/libavfilter/vf_hqdn3d.c +++ b/libavfilter/vf_hqdn3d.c @@ -27,6 +27,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "formats.h" typedef struct { int Coefs[4][512*16]; @@ -268,7 +269,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c index 6e343af7ef..2bbbb6a373 100644 --- a/libavfilter/vf_libopencv.c +++ b/libavfilter/vf_libopencv.c @@ -61,7 +61,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_BGR24, PIX_FMT_BGRA, PIX_FMT_GRAY8, PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index b4950f4e36..29f8b3ce78 100644 --- a/libavfilter/vf_lut.c +++ b/libavfilter/vf_lut.c @@ -29,6 +29,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "formats.h" #include "internal.h" static const char *const var_names[] = { @@ -163,7 +164,7 @@ static int query_formats(AVFilterContext *ctx) enum PixelFormat *pix_fmts = lut->is_rgb ? rgb_pix_fmts : lut->is_yuv ? yuv_pix_fmts : all_pix_fmts; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index e8171e0069..571d48dfad 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -26,6 +26,7 @@ */ #include "avfilter.h" +#include "formats.h" #include "libavutil/eval.h" #include "libavutil/avstring.h" #include "libavutil/pixdesc.h" @@ -94,12 +95,12 @@ static int query_formats(AVFilterContext *ctx) { const enum PixelFormat inout_pix_fmts[] = { PIX_FMT_YUV420P, PIX_FMT_NONE }; const enum PixelFormat blend_pix_fmts[] = { PIX_FMT_YUVA420P, PIX_FMT_NONE }; - AVFilterFormats *inout_formats = avfilter_make_format_list(inout_pix_fmts); - AVFilterFormats *blend_formats = avfilter_make_format_list(blend_pix_fmts); + AVFilterFormats *inout_formats = ff_make_format_list(inout_pix_fmts); + AVFilterFormats *blend_formats = ff_make_format_list(blend_pix_fmts); - avfilter_formats_ref(inout_formats, &ctx->inputs [MAIN ]->out_formats); - avfilter_formats_ref(blend_formats, &ctx->inputs [OVERLAY]->out_formats); - avfilter_formats_ref(inout_formats, &ctx->outputs[MAIN ]->in_formats ); + ff_formats_ref(inout_formats, &ctx->inputs [MAIN ]->out_formats); + ff_formats_ref(blend_formats, &ctx->inputs [OVERLAY]->out_formats); + ff_formats_ref(inout_formats, &ctx->outputs[MAIN ]->in_formats ); return 0; } diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index fdadb1a7c7..1091a212d0 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -25,6 +25,7 @@ */ #include "avfilter.h" +#include "formats.h" #include "libavutil/avstring.h" #include "libavutil/eval.h" #include "libavutil/pixdesc.h" @@ -84,7 +85,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 85095b78d7..82a3181cb5 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -24,6 +24,7 @@ */ #include "avfilter.h" +#include "formats.h" #include "libavutil/avstring.h" #include "libavutil/eval.h" #include "libavutil/mathematics.h" @@ -123,21 +124,21 @@ static int query_formats(AVFilterContext *ctx) formats = NULL; for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) if ( sws_isSupportedInput(pix_fmt) - && (ret = avfilter_add_format(&formats, pix_fmt)) < 0) { - avfilter_formats_unref(&formats); + && (ret = ff_add_format(&formats, pix_fmt)) < 0) { + ff_formats_unref(&formats); return ret; } - avfilter_formats_ref(formats, &ctx->inputs[0]->out_formats); + ff_formats_ref(formats, &ctx->inputs[0]->out_formats); } if (ctx->outputs[0]) { formats = NULL; for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++) if ( sws_isSupportedOutput(pix_fmt) - && (ret = avfilter_add_format(&formats, pix_fmt)) < 0) { - avfilter_formats_unref(&formats); + && (ret = ff_add_format(&formats, pix_fmt)) < 0) { + ff_formats_unref(&formats); return ret; } - avfilter_formats_ref(formats, &ctx->outputs[0]->in_formats); + ff_formats_ref(formats, &ctx->outputs[0]->in_formats); } return 0; diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c index a0ec67c426..7801066824 100644 --- a/libavfilter/vf_transpose.c +++ b/libavfilter/vf_transpose.c @@ -29,6 +29,7 @@ #include "libavutil/pixdesc.h" #include "libavutil/imgutils.h" #include "avfilter.h" +#include "formats.h" typedef struct { int hsub, vsub; @@ -83,7 +84,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c index 7aca2cf32f..9c0809f331 100644 --- a/libavfilter/vf_unsharp.c +++ b/libavfilter/vf_unsharp.c @@ -37,6 +37,7 @@ */ #include "avfilter.h" +#include "formats.h" #include "libavutil/common.h" #include "libavutil/mem.h" #include "libavutil/pixdesc.h" @@ -162,7 +163,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_YUVJ444P, PIX_FMT_YUVJ440P, PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 0c72444bee..694b984764 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 "formats.h" #include "video.h" #include "yadif.h" @@ -387,7 +388,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vsrc_color.c b/libavfilter/vsrc_color.c index 94b5a29719..803196ebf7 100644 --- a/libavfilter/vsrc_color.c +++ b/libavfilter/vsrc_color.c @@ -24,6 +24,7 @@ */ #include "avfilter.h" +#include "formats.h" #include "libavutil/pixdesc.h" #include "libavutil/colorspace.h" #include "libavutil/imgutils.h" @@ -100,7 +101,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c index 4ac079c5a2..45772319c6 100644 --- a/libavfilter/vsrc_movie.c +++ b/libavfilter/vsrc_movie.c @@ -36,6 +36,7 @@ #include "libavutil/imgutils.h" #include "libavformat/avformat.h" #include "avfilter.h" +#include "formats.h" typedef struct { const AVClass *class; @@ -202,7 +203,7 @@ static int query_formats(AVFilterContext *ctx) MovieContext *movie = ctx->priv; enum PixelFormat pix_fmts[] = { movie->codec_ctx->pix_fmt, PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } diff --git a/libavfilter/vsrc_nullsrc.c b/libavfilter/vsrc_nullsrc.c index 4f9dd79346..d145b0b277 100644 --- a/libavfilter/vsrc_nullsrc.c +++ b/libavfilter/vsrc_nullsrc.c @@ -26,6 +26,7 @@ #include "libavutil/mathematics.h" #include "libavutil/parseutils.h" #include "avfilter.h" +#include "formats.h" static const char *const var_names[] = { "E", diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c index 0f5596b715..43495d6fd4 100644 --- a/libavfilter/vsrc_testsrc.c +++ b/libavfilter/vsrc_testsrc.c @@ -37,6 +37,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/parseutils.h" #include "avfilter.h" +#include "formats.h" typedef struct { const AVClass *class; @@ -348,7 +349,7 @@ static int test_query_formats(AVFilterContext *ctx) static const enum PixelFormat pix_fmts[] = { PIX_FMT_RGB24, PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } @@ -459,7 +460,7 @@ static int rgbtest_query_formats(AVFilterContext *ctx) PIX_FMT_RGB555, PIX_FMT_BGR555, PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; } -- cgit v1.2.3 From fa417fcd278a003530fe6bf851f8194177a5e71f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 30 May 2012 10:31:48 +0200 Subject: lavfi: make avfilter_insert_pad and pals private on next bump. They are only useful inside filters and we don't allow user filters for now. --- libavfilter/af_amix.c | 2 +- libavfilter/avfilter.c | 24 +++++++++++++++++++++--- libavfilter/avfilter.h | 37 +++++++++---------------------------- libavfilter/internal.h | 33 +++++++++++++++++++++++++++++++++ libavfilter/split.c | 3 ++- 5 files changed, 66 insertions(+), 33 deletions(-) (limited to 'libavfilter') diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c index d33d96ba6e..8f8ae3e340 100644 --- a/libavfilter/af_amix.c +++ b/libavfilter/af_amix.c @@ -497,7 +497,7 @@ static int init(AVFilterContext *ctx, const char *args, void *opaque) pad.name = av_strdup(name); pad.filter_samples = filter_samples; - avfilter_insert_inpad(ctx, i, &pad); + ff_insert_inpad(ctx, i, &pad); } return 0; diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 8594b8365c..6b73e48d81 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -44,9 +44,9 @@ const char *avfilter_license(void) return LICENSE_PREFIX LIBAV_LICENSE + sizeof(LICENSE_PREFIX) - 1; } -void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, - AVFilterPad **pads, AVFilterLink ***links, - AVFilterPad *newpad) +void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, + AVFilterPad **pads, AVFilterLink ***links, + AVFilterPad *newpad) { unsigned i; @@ -426,4 +426,22 @@ int avfilter_default_config_output_link(AVFilterLink *link) { return 0; } +void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, + AVFilterPad **pads, AVFilterLink ***links, + AVFilterPad *newpad) +{ + ff_insert_pad(idx, count, padidx_off, pads, links, newpad); +} +void avfilter_insert_inpad(AVFilterContext *f, unsigned index, + AVFilterPad *p) +{ + ff_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad), + &f->input_pads, &f->inputs, p); +} +void avfilter_insert_outpad(AVFilterContext *f, unsigned index, + AVFilterPad *p) +{ + ff_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad), + &f->output_pads, &f->outputs, p); +} #endif diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 37e783e41e..0f5a35fc73 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -749,38 +749,19 @@ void avfilter_free(AVFilterContext *filter); int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, unsigned filt_srcpad_idx, unsigned filt_dstpad_idx); -/** - * Insert a new pad. - * - * @param idx Insertion point. Pad is inserted at the end if this point - * is beyond the end of the list of pads. - * @param count Pointer to the number of pads in the list - * @param padidx_off Offset within an AVFilterLink structure to the element - * to increment when inserting a new pad causes link - * numbering to change - * @param pads Pointer to the pointer to the beginning of the list of pads - * @param links Pointer to the pointer to the beginning of the list of links - * @param newpad The new pad to add. A copy is made when adding. - */ +#if FF_API_FILTERS_PUBLIC +attribute_deprecated void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, AVFilterPad **pads, AVFilterLink ***links, AVFilterPad *newpad); -/** Insert a new input pad for the filter. */ -static inline void avfilter_insert_inpad(AVFilterContext *f, unsigned index, - AVFilterPad *p) -{ - avfilter_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad), - &f->input_pads, &f->inputs, p); -} - -/** Insert a new output pad for the filter. */ -static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index, - AVFilterPad *p) -{ - avfilter_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad), - &f->output_pads, &f->outputs, p); -} +attribute_deprecated +void avfilter_insert_inpad(AVFilterContext *f, unsigned index, + AVFilterPad *p); +attribute_deprecated +void avfilter_insert_outpad(AVFilterContext *f, unsigned index, + AVFilterPad *p); +#endif /** * Copy the frame properties of src to dst, without copying the actual diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 4eb65305f9..7f7cf45771 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -36,4 +36,37 @@ int ff_fmt_is_in(int fmt, const int *fmts); void ff_dlog_link(void *ctx, AVFilterLink *link, int end); +/** + * Insert a new pad. + * + * @param idx Insertion point. Pad is inserted at the end if this point + * is beyond the end of the list of pads. + * @param count Pointer to the number of pads in the list + * @param padidx_off Offset within an AVFilterLink structure to the element + * to increment when inserting a new pad causes link + * numbering to change + * @param pads Pointer to the pointer to the beginning of the list of pads + * @param links Pointer to the pointer to the beginning of the list of links + * @param newpad The new pad to add. A copy is made when adding. + */ +void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, + AVFilterPad **pads, AVFilterLink ***links, + AVFilterPad *newpad); + +/** Insert a new input pad for the filter. */ +static inline void ff_insert_inpad(AVFilterContext *f, unsigned index, + AVFilterPad *p) +{ + ff_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad), + &f->input_pads, &f->inputs, p); +} + +/** Insert a new output pad for the filter. */ +static inline void ff_insert_outpad(AVFilterContext *f, unsigned index, + AVFilterPad *p) +{ + ff_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad), + &f->output_pads, &f->outputs, p); +} + #endif /* AVFILTER_INTERNAL_H */ diff --git a/libavfilter/split.c b/libavfilter/split.c index da33b7d183..9f7890cde6 100644 --- a/libavfilter/split.c +++ b/libavfilter/split.c @@ -25,6 +25,7 @@ #include "avfilter.h" #include "audio.h" +#include "internal.h" #include "video.h" static int split_init(AVFilterContext *ctx, const char *args, void *opaque) @@ -48,7 +49,7 @@ static int split_init(AVFilterContext *ctx, const char *args, void *opaque) pad.type = ctx->filter->inputs[0].type; pad.name = av_strdup(name); - avfilter_insert_outpad(ctx, i, &pad); + ff_insert_outpad(ctx, i, &pad); } return 0; -- cgit v1.2.3 From 803391f7195ba37a553026009ff989d6e2625d8f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 30 May 2012 11:20:32 +0200 Subject: lavfi: remove request/poll and drawing functions from public API on next bump They are only useful inside filters and we don't allow user filters for now. --- libavfilter/af_amix.c | 4 ++-- libavfilter/af_asyncts.c | 3 ++- libavfilter/af_resample.c | 2 +- libavfilter/avfilter.c | 16 ++++++++++---- libavfilter/avfilter.h | 51 ++++++-------------------------------------- libavfilter/buffersink.c | 5 +++-- libavfilter/buffersrc.c | 7 +++--- libavfilter/internal.h | 17 +++++++++++++++ libavfilter/split.c | 8 +++---- libavfilter/vf_aspect.c | 2 +- libavfilter/vf_blackframe.c | 4 ++-- libavfilter/vf_boxblur.c | 3 ++- libavfilter/vf_crop.c | 6 +++--- libavfilter/vf_cropdetect.c | 2 +- libavfilter/vf_delogo.c | 6 +++--- libavfilter/vf_drawbox.c | 2 +- libavfilter/vf_drawtext.c | 6 +++--- libavfilter/vf_fade.c | 4 ++-- libavfilter/vf_fieldorder.c | 9 ++++---- libavfilter/vf_fifo.c | 9 ++++---- libavfilter/vf_fps.c | 16 ++++++++------ libavfilter/vf_frei0r.c | 11 +++++----- libavfilter/vf_gradfun.c | 7 +++--- libavfilter/vf_hflip.c | 3 ++- libavfilter/vf_hqdn3d.c | 5 +++-- libavfilter/vf_libopencv.c | 4 ++-- libavfilter/vf_lut.c | 3 ++- libavfilter/vf_overlay.c | 13 +++++------ libavfilter/vf_pad.c | 9 ++++---- libavfilter/vf_pixdesctest.c | 5 +++-- libavfilter/vf_scale.c | 9 ++++---- libavfilter/vf_select.c | 19 +++++++++-------- libavfilter/vf_setpts.c | 2 +- libavfilter/vf_settb.c | 2 +- libavfilter/vf_showinfo.c | 2 +- libavfilter/vf_slicify.c | 10 ++++----- libavfilter/vf_transpose.c | 7 +++--- libavfilter/vf_unsharp.c | 5 +++-- libavfilter/vf_vflip.c | 4 ++-- libavfilter/vf_yadif.c | 23 ++++++++++---------- libavfilter/video.c | 30 ++++++++++++++++++-------- libavfilter/video.h | 35 ++++++++++++++++++++++++++++++ libavfilter/vsrc_color.c | 7 +++--- libavfilter/vsrc_movie.c | 7 +++--- libavfilter/vsrc_testsrc.c | 7 +++--- 45 files changed, 235 insertions(+), 176 deletions(-) (limited to 'libavfilter') diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c index 8f8ae3e340..3fc2e8499a 100644 --- a/libavfilter/af_amix.c +++ b/libavfilter/af_amix.c @@ -349,7 +349,7 @@ static int request_samples(AVFilterContext *ctx, int min_samples) if (s->input_state[i] == INPUT_OFF) continue; while (!ret && av_audio_fifo_size(s->fifos[i]) < min_samples) - ret = avfilter_request_frame(ctx->inputs[i]); + ret = ff_request_frame(ctx->inputs[i]); if (ret == AVERROR_EOF) { if (av_audio_fifo_size(s->fifos[i]) == 0) { s->input_state[i] = INPUT_OFF; @@ -410,7 +410,7 @@ static int request_frame(AVFilterLink *outlink) } if (s->frame_list->nb_frames == 0) { - ret = avfilter_request_frame(ctx->inputs[0]); + ret = ff_request_frame(ctx->inputs[0]); if (ret == AVERROR_EOF) { s->input_state[0] = INPUT_OFF; if (s->nb_inputs == 1) diff --git a/libavfilter/af_asyncts.c b/libavfilter/af_asyncts.c index adb5347a80..252b32278d 100644 --- a/libavfilter/af_asyncts.c +++ b/libavfilter/af_asyncts.c @@ -24,6 +24,7 @@ #include "audio.h" #include "avfilter.h" +#include "internal.h" typedef struct ASyncContext { const AVClass *class; @@ -116,7 +117,7 @@ static int request_frame(AVFilterLink *link) { AVFilterContext *ctx = link->src; ASyncContext *s = ctx->priv; - int ret = avfilter_request_frame(ctx->inputs[0]); + int ret = ff_request_frame(ctx->inputs[0]); int nb_samples; /* flush the fifo */ diff --git a/libavfilter/af_resample.c b/libavfilter/af_resample.c index 6b1dfbc085..8a02cfe976 100644 --- a/libavfilter/af_resample.c +++ b/libavfilter/af_resample.c @@ -130,7 +130,7 @@ static int request_frame(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; ResampleContext *s = ctx->priv; - int ret = avfilter_request_frame(ctx->inputs[0]); + int ret = ff_request_frame(ctx->inputs[0]); /* flush the lavr delay buffer */ if (ret == AVERROR_EOF && s->avr) { diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 6b73e48d81..3dbb6920ee 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -223,18 +223,18 @@ void ff_dlog_link(void *ctx, AVFilterLink *link, int end) } } -int avfilter_request_frame(AVFilterLink *link) +int ff_request_frame(AVFilterLink *link) { FF_DPRINTF_START(NULL, request_frame); ff_dlog_link(NULL, link, 1); if (link->srcpad->request_frame) return link->srcpad->request_frame(link); else if (link->src->inputs[0]) - return avfilter_request_frame(link->src->inputs[0]); + return ff_request_frame(link->src->inputs[0]); else return -1; } -int avfilter_poll_frame(AVFilterLink *link) +int ff_poll_frame(AVFilterLink *link) { int i, min = INT_MAX; @@ -245,7 +245,7 @@ int avfilter_poll_frame(AVFilterLink *link) int val; if (!link->src->inputs[i]) return -1; - val = avfilter_poll_frame(link->src->inputs[i]); + val = ff_poll_frame(link->src->inputs[i]); min = FFMIN(min, val); } @@ -444,4 +444,12 @@ void avfilter_insert_outpad(AVFilterContext *f, unsigned index, ff_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad), &f->output_pads, &f->outputs, p); } +int avfilter_poll_frame(AVFilterLink *link) +{ + return ff_poll_frame(link); +} +int avfilter_request_frame(AVFilterLink *link) +{ + return ff_request_frame(link); +} #endif diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 0f5a35fc73..c592372ced 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -620,57 +620,20 @@ AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, enum AVSampleFormat sample_fmt, uint64_t channel_layout); -/** - * Request an input frame from the filter at the other end of the link. - * - * @param link the input link - * @return zero on success - */ +#if FF_API_FILTERS_PUBLIC +attribute_deprecated int avfilter_request_frame(AVFilterLink *link); -/** - * Poll a frame from the filter chain. - * - * @param link the input link - * @return the number of immediately available frames, a negative - * number in case of error - */ +attribute_deprecated int avfilter_poll_frame(AVFilterLink *link); -/** - * Notify the next filter of the start of a frame. - * - * @param link the output link the frame will be sent over - * @param picref A reference to the frame about to be sent. The data for this - * frame need only be valid once draw_slice() is called for that - * portion. The receiving filter will free this reference when - * it no longer needs it. - */ +attribute_deprecated void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); - -/** - * Notifie the next filter that the current frame has finished. - * - * @param link the output link the frame was sent over - */ +attribute_deprecated void avfilter_end_frame(AVFilterLink *link); - -/** - * Send a slice to the next filter. - * - * Slices have to be provided in sequential order, either in - * top-bottom or bottom-top order. If slices are provided in - * non-sequential order the behavior of the function is undefined. - * - * @param link the output link over which the frame is being sent - * @param y offset in pixels from the top of the image for this slice - * @param h height of this slice in pixels - * @param slice_dir the assumed direction for sending slices, - * from the top slice to the bottom slice if the value is 1, - * from the bottom slice to the top slice if the value is -1, - * for other values the behavior of the function is undefined. - */ +attribute_deprecated void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); +#endif /** Initialize the filter system. Register all builtin filters. */ void avfilter_register_all(void); diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index 8787268f4c..13fb2558c1 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -31,6 +31,7 @@ #include "audio.h" #include "avfilter.h" #include "buffersink.h" +#include "internal.h" typedef struct { AVFifoBuffer *fifo; ///< FIFO buffer of frame references @@ -102,11 +103,11 @@ int av_buffersink_read(AVFilterContext *ctx, AVFilterBufferRef **buf) if (av_fifo_size(sink->fifo)) return av_fifo_size(sink->fifo)/sizeof(*buf); else - return avfilter_poll_frame(ctx->inputs[0]); + return ff_poll_frame(ctx->inputs[0]); } if (!av_fifo_size(sink->fifo) && - (ret = avfilter_request_frame(link)) < 0) + (ret = ff_request_frame(link)) < 0) return ret; if (!av_fifo_size(sink->fifo)) diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index f78b8f6eff..7af9f6c571 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -27,6 +27,7 @@ #include "avfilter.h" #include "buffersrc.h" #include "formats.h" +#include "video.h" #include "vsrc_buffer.h" #include "libavutil/audioconvert.h" @@ -340,9 +341,9 @@ static int request_frame(AVFilterLink *link) switch (link->type) { case AVMEDIA_TYPE_VIDEO: - avfilter_start_frame(link, avfilter_ref_buffer(buf, ~0)); - avfilter_draw_slice(link, 0, link->h, 1); - avfilter_end_frame(link); + ff_start_frame(link, avfilter_ref_buffer(buf, ~0)); + ff_draw_slice(link, 0, link->h, 1); + ff_end_frame(link); break; case AVMEDIA_TYPE_AUDIO: ff_filter_samples(link, avfilter_ref_buffer(buf, ~0)); diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 7f7cf45771..4b53831063 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -69,4 +69,21 @@ static inline void ff_insert_outpad(AVFilterContext *f, unsigned index, &f->output_pads, &f->outputs, p); } +/** + * Poll a frame from the filter chain. + * + * @param link the input link + * @return the number of immediately available frames, a negative + * number in case of error + */ +int ff_poll_frame(AVFilterLink *link); + +/** + * Request an input frame from the filter at the other end of the link. + * + * @param link the input link + * @return zero on success + */ +int ff_request_frame(AVFilterLink *link); + #endif /* AVFILTER_INTERNAL_H */ diff --git a/libavfilter/split.c b/libavfilter/split.c index 9f7890cde6..95c1b9aa1f 100644 --- a/libavfilter/split.c +++ b/libavfilter/split.c @@ -69,8 +69,8 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) int i; for (i = 0; i < ctx->output_count; i++) - avfilter_start_frame(ctx->outputs[i], - avfilter_ref_buffer(picref, ~AV_PERM_WRITE)); + ff_start_frame(ctx->outputs[i], + avfilter_ref_buffer(picref, ~AV_PERM_WRITE)); } static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) @@ -79,7 +79,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) int i; for (i = 0; i < ctx->output_count; i++) - avfilter_draw_slice(ctx->outputs[i], y, h, slice_dir); + ff_draw_slice(ctx->outputs[i], y, h, slice_dir); } static void end_frame(AVFilterLink *inlink) @@ -88,7 +88,7 @@ static void end_frame(AVFilterLink *inlink) int i; for (i = 0; i < ctx->output_count; i++) - avfilter_end_frame(ctx->outputs[i]); + ff_end_frame(ctx->outputs[i]); avfilter_unref_buffer(inlink->cur_buf); } diff --git a/libavfilter/vf_aspect.c b/libavfilter/vf_aspect.c index 4e1fdac90e..0555afe4c0 100644 --- a/libavfilter/vf_aspect.c +++ b/libavfilter/vf_aspect.c @@ -68,7 +68,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) AspectContext *aspect = link->dst->priv; picref->video->pixel_aspect = aspect->aspect; - avfilter_start_frame(link->dst->outputs[0], picref); + ff_start_frame(link->dst->outputs[0], picref); } #if CONFIG_SETDAR_FILTER diff --git a/libavfilter/vf_blackframe.c b/libavfilter/vf_blackframe.c index bdc132285e..1d9a75d502 100644 --- a/libavfilter/vf_blackframe.c +++ b/libavfilter/vf_blackframe.c @@ -87,7 +87,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) p += picref->linesize[0]; } - avfilter_draw_slice(ctx->outputs[0], y, h, slice_dir); + ff_draw_slice(ctx->outputs[0], y, h, slice_dir); } static void end_frame(AVFilterLink *inlink) @@ -105,7 +105,7 @@ static void end_frame(AVFilterLink *inlink) blackframe->frame++; blackframe->nblack = 0; - avfilter_end_frame(inlink->dst->outputs[0]); + ff_end_frame(inlink->dst->outputs[0]); } AVFilter avfilter_vf_blackframe = { diff --git a/libavfilter/vf_boxblur.c b/libavfilter/vf_boxblur.c index 04486ce1a8..21a0173ccb 100644 --- a/libavfilter/vf_boxblur.c +++ b/libavfilter/vf_boxblur.c @@ -30,6 +30,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" #include "formats.h" +#include "video.h" static const char *const var_names[] = { "w", @@ -328,7 +329,7 @@ static void draw_slice(AVFilterLink *inlink, int y0, int h0, int slice_dir) w[plane], h[plane], boxblur->radius[plane], boxblur->power[plane], boxblur->temp); - avfilter_draw_slice(outlink, y0, h0, slice_dir); + ff_draw_slice(outlink, y0, h0, slice_dir); } AVFilter avfilter_vf_boxblur = { diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index cb8b94ef7e..f25278e79e 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -290,7 +290,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) ref2->data[3] += crop->x * crop->max_step[3]; } - avfilter_start_frame(link->dst->outputs[0], ref2); + ff_start_frame(link->dst->outputs[0], ref2); } static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) @@ -308,7 +308,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) if (y + h > crop->y + crop->h) h = crop->y + crop->h - y; - avfilter_draw_slice(ctx->outputs[0], y - crop->y, h, slice_dir); + ff_draw_slice(ctx->outputs[0], y - crop->y, h, slice_dir); } static void end_frame(AVFilterLink *link) @@ -317,7 +317,7 @@ static void end_frame(AVFilterLink *link) crop->var_values[VAR_N] += 1.0; avfilter_unref_buffer(link->cur_buf); - avfilter_end_frame(link->dst->outputs[0]); + ff_end_frame(link->dst->outputs[0]); } AVFilter avfilter_vf_crop = { diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c index 20bc219d81..38fd5c1355 100644 --- a/libavfilter/vf_cropdetect.c +++ b/libavfilter/vf_cropdetect.c @@ -190,7 +190,7 @@ static void end_frame(AVFilterLink *inlink) w, h, x, y); } - avfilter_end_frame(inlink->dst->outputs[0]); + ff_end_frame(inlink->dst->outputs[0]); } AVFilter avfilter_vf_cropdetect = { diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index 3410982b63..6fe47306ea 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -228,7 +228,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) outpicref = inpicref; outlink->out_buf = outpicref; - avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); + ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); } static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } @@ -257,8 +257,8 @@ static void end_frame(AVFilterLink *inlink) delogo->show, direct); } - avfilter_draw_slice(outlink, 0, inlink->h, 1); - avfilter_end_frame(outlink); + ff_draw_slice(outlink, 0, inlink->h, 1); + ff_end_frame(outlink); avfilter_unref_buffer(inpicref); if (!direct) avfilter_unref_buffer(outpicref); diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c index 46ce6979a0..47db0490a7 100644 --- a/libavfilter/vf_drawbox.c +++ b/libavfilter/vf_drawbox.c @@ -119,7 +119,7 @@ static void draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir) } } - avfilter_draw_slice(inlink->dst->outputs[0], y0, h, 1); + ff_draw_slice(inlink->dst->outputs[0], y0, h, 1); } AVFilter avfilter_vf_drawbox = { diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 92f14a7ba8..411bcbc781 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -849,7 +849,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) (int)dtext->var_values[VAR_N], dtext->var_values[VAR_T], dtext->x, dtext->y, dtext->x+dtext->w, dtext->y+dtext->h); - avfilter_start_frame(inlink->dst->outputs[0], inpicref); + ff_start_frame(inlink->dst->outputs[0], inpicref); } static void end_frame(AVFilterLink *inlink) @@ -863,8 +863,8 @@ static void end_frame(AVFilterLink *inlink) dtext->var_values[VAR_N] += 1.0; - avfilter_draw_slice(outlink, 0, picref->video->h, 1); - avfilter_end_frame(outlink); + ff_draw_slice(outlink, 0, picref->video->h, 1); + ff_end_frame(outlink); } AVFilter avfilter_vf_drawtext = { diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c index 8bd4074592..6b9cb66fe6 100644 --- a/libavfilter/vf_fade.c +++ b/libavfilter/vf_fade.c @@ -133,14 +133,14 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) } } - avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); + ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); } static void end_frame(AVFilterLink *inlink) { FadeContext *fade = inlink->dst->priv; - avfilter_end_frame(inlink->dst->outputs[0]); + ff_end_frame(inlink->dst->outputs[0]); if (fade->frame_index >= fade->start_frame && fade->frame_index <= fade->stop_frame) diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c index d975aab974..ff1e332572 100644 --- a/libavfilter/vf_fieldorder.c +++ b/libavfilter/vf_fieldorder.c @@ -29,6 +29,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" #include "formats.h" +#include "video.h" typedef struct { @@ -124,7 +125,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) outpicref = avfilter_ref_buffer(inpicref, ~0); outlink->out_buf = outpicref; - avfilter_start_frame(outlink, outpicref); + ff_start_frame(outlink, outpicref); } static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) @@ -141,7 +142,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) * and that complexity will be added later */ if ( !inpicref->video->interlaced || inpicref->video->top_field_first == fieldorder->dst_tff) { - avfilter_draw_slice(outlink, y, h, slice_dir); + ff_draw_slice(outlink, y, h, slice_dir); } } @@ -203,13 +204,13 @@ static void end_frame(AVFilterLink *inlink) } } outpicref->video->top_field_first = fieldorder->dst_tff; - avfilter_draw_slice(outlink, 0, h, 1); + ff_draw_slice(outlink, 0, h, 1); } else { av_dlog(ctx, "not interlaced or field order already correct\n"); } - avfilter_end_frame(outlink); + ff_end_frame(outlink); avfilter_unref_buffer(inpicref); } diff --git a/libavfilter/vf_fifo.c b/libavfilter/vf_fifo.c index b99cec38dc..1785946a4f 100644 --- a/libavfilter/vf_fifo.c +++ b/libavfilter/vf_fifo.c @@ -24,6 +24,7 @@ */ #include "avfilter.h" +#include "internal.h" #include "video.h" typedef struct BufPic { @@ -77,15 +78,15 @@ static int request_frame(AVFilterLink *outlink) int ret; if (!fifo->root.next) { - if ((ret = avfilter_request_frame(outlink->src->inputs[0]) < 0)) + if ((ret = ff_request_frame(outlink->src->inputs[0]) < 0)) return ret; } /* by doing this, we give ownership of the reference to the next filter, * so we don't have to worry about dereferencing it ourselves. */ - avfilter_start_frame(outlink, fifo->root.next->picref); - avfilter_draw_slice (outlink, 0, outlink->h, 1); - avfilter_end_frame (outlink); + ff_start_frame(outlink, fifo->root.next->picref); + ff_draw_slice (outlink, 0, outlink->h, 1); + ff_end_frame (outlink); if (fifo->last == fifo->root.next) fifo->last = &fifo->root; diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c index da38af299b..18cd51a9a8 100644 --- a/libavfilter/vf_fps.c +++ b/libavfilter/vf_fps.c @@ -27,6 +27,8 @@ #include "libavutil/parseutils.h" #include "avfilter.h" +#include "internal.h" +#include "video.h" typedef struct FPSContext { const AVClass *class; @@ -129,7 +131,7 @@ static int request_frame(AVFilterLink *outlink) int ret = 0; while (ret >= 0 && s->frames_out == frames_out) - ret = avfilter_request_frame(ctx->inputs[0]); + ret = ff_request_frame(ctx->inputs[0]); /* flush the fifo */ if (ret == AVERROR_EOF && av_fifo_size(s->fifo)) { @@ -141,9 +143,9 @@ static int request_frame(AVFilterLink *outlink) buf->pts = av_rescale_q(s->first_pts, ctx->inputs[0]->time_base, outlink->time_base) + s->frames_out; - avfilter_start_frame(outlink, buf); - avfilter_draw_slice(outlink, 0, outlink->h, 1); - avfilter_end_frame(outlink); + ff_start_frame(outlink, buf); + ff_draw_slice(outlink, 0, outlink->h, 1); + ff_end_frame(outlink); s->frames_out++; } return 0; @@ -229,9 +231,9 @@ static void end_frame(AVFilterLink *inlink) buf_out->pts = av_rescale_q(s->first_pts, inlink->time_base, outlink->time_base) + s->frames_out; - avfilter_start_frame(outlink, buf_out); - avfilter_draw_slice(outlink, 0, outlink->h, 1); - avfilter_end_frame(outlink); + ff_start_frame(outlink, buf_out); + ff_draw_slice(outlink, 0, outlink->h, 1); + ff_end_frame(outlink); s->frames_out++; } flush_fifo(s->fifo); diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c index 4dd6fbef09..85b4205559 100644 --- a/libavfilter/vf_frei0r.c +++ b/libavfilter/vf_frei0r.c @@ -32,6 +32,7 @@ #include "libavutil/parseutils.h" #include "avfilter.h" #include "formats.h" +#include "video.h" typedef f0r_instance_t (*f0r_construct_f)(unsigned int width, unsigned int height); typedef void (*f0r_destruct_f)(f0r_instance_t instance); @@ -351,8 +352,8 @@ static void end_frame(AVFilterLink *inlink) (const uint32_t *)inpicref->data[0], (uint32_t *)outpicref->data[0]); avfilter_unref_buffer(inpicref); - avfilter_draw_slice(outlink, 0, outlink->h, 1); - avfilter_end_frame(outlink); + ff_draw_slice(outlink, 0, outlink->h, 1); + ff_end_frame(outlink); avfilter_unref_buffer(outpicref); } @@ -436,11 +437,11 @@ static int source_request_frame(AVFilterLink *outlink) picref->pts = frei0r->pts++; picref->pos = -1; - avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); + ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); frei0r->update(frei0r->instance, av_rescale_q(picref->pts, frei0r->time_base, (AVRational){1,1000}), NULL, (uint32_t *)picref->data[0]); - avfilter_draw_slice(outlink, 0, outlink->h, 1); - avfilter_end_frame(outlink); + ff_draw_slice(outlink, 0, outlink->h, 1); + ff_end_frame(outlink); avfilter_unref_buffer(picref); return 0; diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c index b61c06317c..7fde16d41b 100644 --- a/libavfilter/vf_gradfun.c +++ b/libavfilter/vf_gradfun.c @@ -38,6 +38,7 @@ #include "avfilter.h" #include "formats.h" #include "gradfun.h" +#include "video.h" DECLARE_ALIGNED(16, static const uint16_t, dither)[8][8] = { {0x00,0x60,0x18,0x78,0x06,0x66,0x1E,0x7E}, @@ -197,7 +198,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) outpicref = inpicref; outlink->out_buf = outpicref; - avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); + ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); } static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } @@ -226,8 +227,8 @@ static void end_frame(AVFilterLink *inlink) av_image_copy_plane(outpic->data[p], outpic->linesize[p], inpic->data[p], inpic->linesize[p], w, h); } - avfilter_draw_slice(outlink, 0, inlink->h, 1); - avfilter_end_frame(outlink); + ff_draw_slice(outlink, 0, inlink->h, 1); + ff_end_frame(outlink); avfilter_unref_buffer(inpic); if (outpic != inpic) avfilter_unref_buffer(outpic); diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c index 5e87a7dc13..aff0f8c5d3 100644 --- a/libavfilter/vf_hflip.c +++ b/libavfilter/vf_hflip.c @@ -26,6 +26,7 @@ #include "avfilter.h" #include "formats.h" +#include "video.h" #include "libavutil/pixdesc.h" #include "libavutil/intreadwrite.h" #include "libavutil/imgutils.h" @@ -140,7 +141,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) } } - avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); + ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); } AVFilter avfilter_vf_hflip = { diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c index 51de0d8de6..0a26dd0017 100644 --- a/libavfilter/vf_hqdn3d.c +++ b/libavfilter/vf_hqdn3d.c @@ -28,6 +28,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" #include "formats.h" +#include "video.h" typedef struct { int Coefs[4][512*16]; @@ -318,8 +319,8 @@ static void end_frame(AVFilterLink *inlink) hqdn3d->Coefs[2], hqdn3d->Coefs[3]); - avfilter_draw_slice(outlink, 0, inpic->video->h, 1); - avfilter_end_frame(outlink); + ff_draw_slice(outlink, 0, inpic->video->h, 1); + ff_end_frame(outlink); avfilter_unref_buffer(inpic); avfilter_unref_buffer(outpic); } diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c index 2bbbb6a373..b6dcd191ae 100644 --- a/libavfilter/vf_libopencv.c +++ b/libavfilter/vf_libopencv.c @@ -364,8 +364,8 @@ static void end_frame(AVFilterLink *inlink) fill_picref_from_iplimage(outpicref, &outimg, inlink->format); avfilter_unref_buffer(inpicref); - avfilter_draw_slice(outlink, 0, outlink->h, 1); - avfilter_end_frame(outlink); + ff_draw_slice(outlink, 0, outlink->h, 1); + ff_end_frame(outlink); avfilter_unref_buffer(outpicref); } diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index 29f8b3ce78..3817228960 100644 --- a/libavfilter/vf_lut.c +++ b/libavfilter/vf_lut.c @@ -31,6 +31,7 @@ #include "avfilter.h" #include "formats.h" #include "internal.h" +#include "video.h" static const char *const var_names[] = { "E", @@ -338,7 +339,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) } } - avfilter_draw_slice(outlink, y, h, slice_dir); + ff_draw_slice(outlink, y, h, slice_dir); } #define DEFINE_LUT_FILTER(name_, description_, init_) \ diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index 571d48dfad..55f1cc3a14 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -33,6 +33,7 @@ #include "libavutil/imgutils.h" #include "libavutil/mathematics.h" #include "internal.h" +#include "video.h" static const char *const var_names[] = { "E", @@ -220,7 +221,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) if (!over->overpicref || over->overpicref->pts < outpicref->pts) { AVFilterBufferRef *old = over->overpicref; over->overpicref = NULL; - avfilter_request_frame(ctx->inputs[OVERLAY]); + ff_request_frame(ctx->inputs[OVERLAY]); if (over->overpicref) { if (old) avfilter_unref_buffer(old); @@ -228,7 +229,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) over->overpicref = old; } - avfilter_start_frame(inlink->dst->outputs[0], outpicref); + ff_start_frame(inlink->dst->outputs[0], outpicref); } static void start_frame_overlay(AVFilterLink *inlink, AVFilterBufferRef *inpicref) @@ -333,12 +334,12 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) over->overpicref->video->w, over->overpicref->video->h, y, outpicref->video->w, h); } - avfilter_draw_slice(outlink, y, h, slice_dir); + ff_draw_slice(outlink, y, h, slice_dir); } static void end_frame(AVFilterLink *inlink) { - avfilter_end_frame(inlink->dst->outputs[0]); + ff_end_frame(inlink->dst->outputs[0]); avfilter_unref_buffer(inlink->cur_buf); } @@ -350,12 +351,12 @@ static int poll_frame(AVFilterLink *link) { AVFilterContext *s = link->src; OverlayContext *over = s->priv; - int ret = avfilter_poll_frame(s->inputs[OVERLAY]); + int ret = ff_poll_frame(s->inputs[OVERLAY]); if (ret == AVERROR_EOF) ret = !!over->overpicref; - return ret && avfilter_poll_frame(s->inputs[MAIN]); + return ret && ff_poll_frame(s->inputs[MAIN]); } AVFilter avfilter_vf_overlay = { diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index 1091a212d0..2e98aea028 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -26,6 +26,7 @@ #include "avfilter.h" #include "formats.h" +#include "video.h" #include "libavutil/avstring.h" #include "libavutil/eval.h" #include "libavutil/pixdesc.h" @@ -337,12 +338,12 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) outpicref->video->w = pad->w; outpicref->video->h = pad->h; - avfilter_start_frame(inlink->dst->outputs[0], outpicref); + ff_start_frame(inlink->dst->outputs[0], outpicref); } static void end_frame(AVFilterLink *link) { - avfilter_end_frame(link->dst->outputs[0]); + ff_end_frame(link->dst->outputs[0]); avfilter_unref_buffer(link->cur_buf); } @@ -366,7 +367,7 @@ static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, link->dst->outputs[0]->out_buf->linesize, pad->line, pad->line_step, pad->hsub, pad->vsub, 0, bar_y, pad->w, bar_h); - avfilter_draw_slice(link->dst->outputs[0], bar_y, bar_h, slice_dir); + ff_draw_slice(link->dst->outputs[0], bar_y, bar_h, slice_dir); } } @@ -400,7 +401,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) ff_draw_rectangle(outpic->data, outpic->linesize, pad->line, pad->line_step, pad->hsub, pad->vsub, pad->x + pad->in_w, y, pad->w - pad->x - pad->in_w, h); - avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir); + ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); draw_send_bar_slice(link, y, h, slice_dir, -1); } diff --git a/libavfilter/vf_pixdesctest.c b/libavfilter/vf_pixdesctest.c index cf7dfeda3e..7eecdc0bb1 100644 --- a/libavfilter/vf_pixdesctest.c +++ b/libavfilter/vf_pixdesctest.c @@ -25,6 +25,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "video.h" typedef struct { const AVPixFmtDescriptor *pix_desc; @@ -76,7 +77,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) priv->pix_desc->flags & PIX_FMT_PSEUDOPAL) memcpy(outpicref->data[1], outpicref->data[1], 256*4); - avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); + ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); } static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) @@ -106,7 +107,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) } } - avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); + ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); } AVFilter avfilter_vf_pixdesctest = { diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 82a3181cb5..6f33848f20 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -25,6 +25,7 @@ #include "avfilter.h" #include "formats.h" +#include "video.h" #include "libavutil/avstring.h" #include "libavutil/eval.h" #include "libavutil/mathematics.h" @@ -257,7 +258,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) AVFilterBufferRef *outpicref; if (!scale->sws) { - avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); + ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); return; } @@ -277,7 +278,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) INT_MAX); scale->slice_y = 0; - avfilter_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); + ff_start_frame(outlink, avfilter_ref_buffer(outpicref, ~0)); } static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) @@ -288,7 +289,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) const uint8_t *data[4]; if (!scale->sws) { - avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir); + ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); return; } @@ -308,7 +309,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) if (slice_dir == -1) scale->slice_y -= out_h; - avfilter_draw_slice(link->dst->outputs[0], scale->slice_y, out_h, slice_dir); + ff_draw_slice(link->dst->outputs[0], scale->slice_y, out_h, slice_dir); if (slice_dir == 1) scale->slice_y += out_h; } diff --git a/libavfilter/vf_select.c b/libavfilter/vf_select.c index 2b6b49c153..dab47ced85 100644 --- a/libavfilter/vf_select.c +++ b/libavfilter/vf_select.c @@ -27,6 +27,7 @@ #include "libavutil/fifo.h" #include "libavutil/mathematics.h" #include "avfilter.h" +#include "internal.h" #include "video.h" static const char *const var_names[] = { @@ -242,7 +243,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) sizeof(picref), NULL); return; } - avfilter_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0)); + ff_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0)); } } @@ -251,7 +252,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) SelectContext *select = inlink->dst->priv; if (select->select && !select->cache_frames) - avfilter_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); + ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir); } static void end_frame(AVFilterLink *inlink) @@ -262,7 +263,7 @@ static void end_frame(AVFilterLink *inlink) if (select->select) { if (select->cache_frames) return; - avfilter_end_frame(inlink->dst->outputs[0]); + ff_end_frame(inlink->dst->outputs[0]); } avfilter_unref_buffer(picref); } @@ -277,15 +278,15 @@ static int request_frame(AVFilterLink *outlink) if (av_fifo_size(select->pending_frames)) { AVFilterBufferRef *picref; av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL); - avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); - avfilter_draw_slice(outlink, 0, outlink->h, 1); - avfilter_end_frame(outlink); + ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); + ff_draw_slice(outlink, 0, outlink->h, 1); + ff_end_frame(outlink); avfilter_unref_buffer(picref); return 0; } while (!select->select) { - int ret = avfilter_request_frame(inlink); + int ret = ff_request_frame(inlink); if (ret < 0) return ret; } @@ -300,12 +301,12 @@ static int poll_frame(AVFilterLink *outlink) int count, ret; if (!av_fifo_size(select->pending_frames)) { - if ((count = avfilter_poll_frame(inlink)) <= 0) + if ((count = ff_poll_frame(inlink)) <= 0) return count; /* request frame from input, and apply select condition to it */ select->cache_frames = 1; while (count-- && av_fifo_space(select->pending_frames)) { - ret = avfilter_request_frame(inlink); + ret = ff_request_frame(inlink); if (ret < 0) break; } diff --git a/libavfilter/vf_setpts.c b/libavfilter/vf_setpts.c index 103f265782..d303851686 100644 --- a/libavfilter/vf_setpts.c +++ b/libavfilter/vf_setpts.c @@ -129,7 +129,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) setpts->var_values[VAR_N] += 1.0; setpts->var_values[VAR_PREV_INPTS ] = TS2D(inpicref ->pts); setpts->var_values[VAR_PREV_OUTPTS] = TS2D(outpicref->pts); - avfilter_start_frame(inlink->dst->outputs[0], outpicref); + ff_start_frame(inlink->dst->outputs[0], outpicref); } static av_cold void uninit(AVFilterContext *ctx) diff --git a/libavfilter/vf_settb.c b/libavfilter/vf_settb.c index b40ede87cb..78d4617526 100644 --- a/libavfilter/vf_settb.c +++ b/libavfilter/vf_settb.c @@ -119,7 +119,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) avfilter_unref_buffer(picref); } - avfilter_start_frame(outlink, picref2); + ff_start_frame(outlink, picref2); } AVFilter avfilter_vf_settb = { diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index 0475f9bf90..1a8f16e2c3 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -75,7 +75,7 @@ static void end_frame(AVFilterLink *inlink) checksum, plane_checksum[0], plane_checksum[1], plane_checksum[2], plane_checksum[3]); showinfo->frame++; - avfilter_end_frame(inlink->dst->outputs[0]); + ff_end_frame(inlink->dst->outputs[0]); } AVFilter avfilter_vf_showinfo = { diff --git a/libavfilter/vf_slicify.c b/libavfilter/vf_slicify.c index 31d74979af..fdc10bea9d 100644 --- a/libavfilter/vf_slicify.c +++ b/libavfilter/vf_slicify.c @@ -73,7 +73,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) av_log(link->dst, AV_LOG_DEBUG, "h:%d\n", slice->h); - avfilter_start_frame(link->dst->outputs[0], picref); + ff_start_frame(link->dst->outputs[0], picref); } static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) @@ -83,16 +83,16 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) if (slice_dir == 1) { for (y2 = y; y2 + slice->h <= y + h; y2 += slice->h) - avfilter_draw_slice(link->dst->outputs[0], y2, slice->h, slice_dir); + ff_draw_slice(link->dst->outputs[0], y2, slice->h, slice_dir); if (y2 < y + h) - avfilter_draw_slice(link->dst->outputs[0], y2, y + h - y2, slice_dir); + ff_draw_slice(link->dst->outputs[0], y2, y + h - y2, slice_dir); } else if (slice_dir == -1) { for (y2 = y + h; y2 - slice->h >= y; y2 -= slice->h) - avfilter_draw_slice(link->dst->outputs[0], y2 - slice->h, slice->h, slice_dir); + ff_draw_slice(link->dst->outputs[0], y2 - slice->h, slice->h, slice_dir); if (y2 > y) - avfilter_draw_slice(link->dst->outputs[0], y, y2 - y, slice_dir); + ff_draw_slice(link->dst->outputs[0], y, y2 - y, slice_dir); } } diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c index 7801066824..5e5feda85f 100644 --- a/libavfilter/vf_transpose.c +++ b/libavfilter/vf_transpose.c @@ -30,6 +30,7 @@ #include "libavutil/imgutils.h" #include "avfilter.h" #include "formats.h" +#include "video.h" typedef struct { int hsub, vsub; @@ -130,7 +131,7 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) outlink->out_buf->video->pixel_aspect.den = picref->video->pixel_aspect.num; } - avfilter_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); + ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); } static void end_frame(AVFilterLink *inlink) @@ -191,8 +192,8 @@ static void end_frame(AVFilterLink *inlink) } avfilter_unref_buffer(inpic); - avfilter_draw_slice(outlink, 0, outpic->video->h, 1); - avfilter_end_frame(outlink); + ff_draw_slice(outlink, 0, outpic->video->h, 1); + ff_end_frame(outlink); avfilter_unref_buffer(outpic); } diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c index 9c0809f331..a5d301cd72 100644 --- a/libavfilter/vf_unsharp.c +++ b/libavfilter/vf_unsharp.c @@ -38,6 +38,7 @@ #include "avfilter.h" #include "formats.h" +#include "video.h" #include "libavutil/common.h" #include "libavutil/mem.h" #include "libavutil/pixdesc.h" @@ -224,8 +225,8 @@ static void end_frame(AVFilterLink *link) apply_unsharp(out->data[2], out->linesize[2], in->data[2], in->linesize[2], cw, ch, &unsharp->chroma); avfilter_unref_buffer(in); - avfilter_draw_slice(link->dst->outputs[0], 0, link->h, 1); - avfilter_end_frame(link->dst->outputs[0]); + ff_draw_slice(link->dst->outputs[0], 0, link->h, 1); + ff_end_frame(link->dst->outputs[0]); avfilter_unref_buffer(out); } diff --git a/libavfilter/vf_vflip.c b/libavfilter/vf_vflip.c index a7f14c0775..6d2f42ed5d 100644 --- a/libavfilter/vf_vflip.c +++ b/libavfilter/vf_vflip.c @@ -78,14 +78,14 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref) } } - avfilter_start_frame(link->dst->outputs[0], outpicref); + ff_start_frame(link->dst->outputs[0], outpicref); } static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { AVFilterContext *ctx = link->dst; - avfilter_draw_slice(ctx->outputs[0], link->h - (y+h), h, -1 * slice_dir); + ff_draw_slice(ctx->outputs[0], link->h - (y+h), h, -1 * slice_dir); } AVFilter avfilter_vf_vflip = { diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 694b984764..b498ab9d39 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -24,6 +24,7 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" #include "formats.h" +#include "internal.h" #include "video.h" #include "yadif.h" @@ -229,10 +230,10 @@ static void return_frame(AVFilterContext *ctx, int is_second) } else { yadif->out->pts = AV_NOPTS_VALUE; } - avfilter_start_frame(ctx->outputs[0], yadif->out); + ff_start_frame(ctx->outputs[0], yadif->out); } - avfilter_draw_slice(ctx->outputs[0], 0, link->h, 1); - avfilter_end_frame(ctx->outputs[0]); + ff_draw_slice(ctx->outputs[0], 0, link->h, 1); + ff_end_frame(ctx->outputs[0]); yadif->frame_pending = (yadif->mode&1) && !is_second; } @@ -260,7 +261,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) yadif->prev = NULL; if (yadif->out->pts != AV_NOPTS_VALUE) yadif->out->pts *= 2; - avfilter_start_frame(ctx->outputs[0], yadif->out); + ff_start_frame(ctx->outputs[0], yadif->out); return; } @@ -274,7 +275,7 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) yadif->out->video->interlaced = 0; if (yadif->out->pts != AV_NOPTS_VALUE) yadif->out->pts *= 2; - avfilter_start_frame(ctx->outputs[0], yadif->out); + ff_start_frame(ctx->outputs[0], yadif->out); } static void end_frame(AVFilterLink *link) @@ -286,8 +287,8 @@ static void end_frame(AVFilterLink *link) return; if (yadif->auto_enable && !yadif->cur->video->interlaced) { - avfilter_draw_slice(ctx->outputs[0], 0, link->h, 1); - avfilter_end_frame(ctx->outputs[0]); + ff_draw_slice(ctx->outputs[0], 0, link->h, 1); + ff_end_frame(ctx->outputs[0]); return; } @@ -310,7 +311,7 @@ static int request_frame(AVFilterLink *link) if (yadif->eof) return AVERROR_EOF; - ret = avfilter_request_frame(link->src->inputs[0]); + ret = ff_request_frame(link->src->inputs[0]); if (ret == AVERROR_EOF && yadif->next) { AVFilterBufferRef *next = avfilter_ref_buffer(yadif->next, AV_PERM_READ); @@ -335,14 +336,14 @@ static int poll_frame(AVFilterLink *link) if (yadif->frame_pending) return 1; - val = avfilter_poll_frame(link->src->inputs[0]); + val = ff_poll_frame(link->src->inputs[0]); if (val <= 0) return val; if (val==1 && !yadif->next) { //FIXME change API to not requre this red tape - if ((ret = avfilter_request_frame(link->src->inputs[0])) < 0) + if ((ret = ff_request_frame(link->src->inputs[0])) < 0) return ret; - val = avfilter_poll_frame(link->src->inputs[0]); + val = ff_poll_frame(link->src->inputs[0]); if (val <= 0) return val; } diff --git a/libavfilter/video.c b/libavfilter/video.c index 6a19388f6e..33082a1482 100644 --- a/libavfilter/video.c +++ b/libavfilter/video.c @@ -162,7 +162,7 @@ AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) { - avfilter_start_frame(link->dst->outputs[0], picref); + ff_start_frame(link->dst->outputs[0], picref); } static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) @@ -175,13 +175,13 @@ static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) if (outlink) { outlink->out_buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); avfilter_copy_buffer_ref_props(outlink->out_buf, picref); - avfilter_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); + ff_start_frame(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); } } /* XXX: should we do the duplicating of the picture ref here, instead of * forcing the source filter to do it? */ -void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) +void ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) { void (*start_frame)(AVFilterLink *, AVFilterBufferRef *); AVFilterPad *dst = link->dstpad; @@ -213,7 +213,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) void ff_null_end_frame(AVFilterLink *link) { - avfilter_end_frame(link->dst->outputs[0]); + ff_end_frame(link->dst->outputs[0]); } static void default_end_frame(AVFilterLink *inlink) @@ -231,11 +231,11 @@ static void default_end_frame(AVFilterLink *inlink) avfilter_unref_buffer(outlink->out_buf); outlink->out_buf = NULL; } - avfilter_end_frame(outlink); + ff_end_frame(outlink); } } -void avfilter_end_frame(AVFilterLink *link) +void ff_end_frame(AVFilterLink *link) { void (*end_frame)(AVFilterLink *); @@ -254,7 +254,7 @@ void avfilter_end_frame(AVFilterLink *link) void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { - avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir); + ff_draw_slice(link->dst->outputs[0], y, h, slice_dir); } static void default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) @@ -265,10 +265,10 @@ static void default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir outlink = inlink->dst->outputs[0]; if (outlink) - avfilter_draw_slice(outlink, y, h, slice_dir); + ff_draw_slice(outlink, y, h, slice_dir); } -void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) +void ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { uint8_t *src[4], *dst[4]; int i, j, vsub; @@ -342,4 +342,16 @@ void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { ff_null_draw_slice(link, y, h, slice_dir); } +void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) +{ + ff_start_frame(link, picref); +} +void avfilter_end_frame(AVFilterLink *link) +{ + ff_end_frame(link); +} +void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) +{ + ff_draw_slice(link, y, h, slice_dir); +} #endif diff --git a/libavfilter/video.h b/libavfilter/video.h index 2256482eee..7c9f9a0d28 100644 --- a/libavfilter/video.h +++ b/libavfilter/video.h @@ -29,4 +29,39 @@ void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); void ff_null_end_frame(AVFilterLink *link); +/** + * Notify the next filter of the start of a frame. + * + * @param link the output link the frame will be sent over + * @param picref A reference to the frame about to be sent. The data for this + * frame need only be valid once draw_slice() is called for that + * portion. The receiving filter will free this reference when + * it no longer needs it. + */ +void ff_start_frame(AVFilterLink *link, AVFilterBufferRef *picref); + +/** + * Notify the next filter that the current frame has finished. + * + * @param link the output link the frame was sent over + */ +void ff_end_frame(AVFilterLink *link); + +/** + * Send a slice to the next filter. + * + * Slices have to be provided in sequential order, either in + * top-bottom or bottom-top order. If slices are provided in + * non-sequential order the behavior of the function is undefined. + * + * @param link the output link over which the frame is being sent + * @param y offset in pixels from the top of the image for this slice + * @param h height of this slice in pixels + * @param slice_dir the assumed direction for sending slices, + * from the top slice to the bottom slice if the value is 1, + * from the bottom slice to the top slice if the value is -1, + * for other values the behavior of the function is undefined. + */ +void ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); + #endif /* AVFILTER_VIDEO_H */ diff --git a/libavfilter/vsrc_color.c b/libavfilter/vsrc_color.c index 803196ebf7..99ea0ad5c1 100644 --- a/libavfilter/vsrc_color.c +++ b/libavfilter/vsrc_color.c @@ -25,6 +25,7 @@ #include "avfilter.h" #include "formats.h" +#include "video.h" #include "libavutil/pixdesc.h" #include "libavutil/colorspace.h" #include "libavutil/imgutils.h" @@ -144,12 +145,12 @@ static int color_request_frame(AVFilterLink *link) picref->pts = color->pts++; picref->pos = -1; - avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0)); + ff_start_frame(link, avfilter_ref_buffer(picref, ~0)); ff_draw_rectangle(picref->data, picref->linesize, color->line, color->line_step, color->hsub, color->vsub, 0, 0, color->w, color->h); - avfilter_draw_slice(link, 0, color->h, 1); - avfilter_end_frame(link); + ff_draw_slice(link, 0, color->h, 1); + ff_end_frame(link); avfilter_unref_buffer(picref); return 0; diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c index 45772319c6..ff3022cdd6 100644 --- a/libavfilter/vsrc_movie.c +++ b/libavfilter/vsrc_movie.c @@ -37,6 +37,7 @@ #include "libavformat/avformat.h" #include "avfilter.h" #include "formats.h" +#include "video.h" typedef struct { const AVClass *class; @@ -287,9 +288,9 @@ static int request_frame(AVFilterLink *outlink) return ret; outpicref = avfilter_ref_buffer(movie->picref, ~0); - avfilter_start_frame(outlink, outpicref); - avfilter_draw_slice(outlink, 0, outlink->h, 1); - avfilter_end_frame(outlink); + ff_start_frame(outlink, outpicref); + ff_draw_slice(outlink, 0, outlink->h, 1); + ff_end_frame(outlink); avfilter_unref_buffer(movie->picref); movie->picref = NULL; diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c index 43495d6fd4..7187241136 100644 --- a/libavfilter/vsrc_testsrc.c +++ b/libavfilter/vsrc_testsrc.c @@ -38,6 +38,7 @@ #include "libavutil/parseutils.h" #include "avfilter.h" #include "formats.h" +#include "video.h" typedef struct { const AVClass *class; @@ -142,9 +143,9 @@ static int request_frame(AVFilterLink *outlink) test->nb_frame++; test->fill_picture_fn(outlink->src, picref); - avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); - avfilter_draw_slice(outlink, 0, picref->video->h, 1); - avfilter_end_frame(outlink); + ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); + ff_draw_slice(outlink, 0, picref->video->h, 1); + ff_end_frame(outlink); avfilter_unref_buffer(picref); return 0; -- cgit v1.2.3