lavfi/avfilter: move AVFilterContext.ready to FFFilterContext

This field is private to the generic filtering code.
pull/153/merge
Anton Khirnov 3 months ago
parent e0eec71a13
commit b1247e7c1f
  1. 9
      libavfilter/avfilter.c
  2. 7
      libavfilter/avfilter.h
  3. 7
      libavfilter/avfilter_internal.h
  4. 18
      libavfilter/avfiltergraph.c
  5. 1
      libavfilter/version_major.h

@ -237,7 +237,8 @@ static void update_link_current_pts(FilterLinkInternal *li, int64_t pts)
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
{
filter->ready = FFMAX(filter->ready, priority);
FFFilterContext *ctxi = fffilterctx(filter);
ctxi->ready = FFMAX(ctxi->ready, priority);
}
/**
@ -473,6 +474,7 @@ void ff_tlog_link(void *ctx, AVFilterLink *link, int end)
int ff_request_frame(AVFilterLink *link)
{
FilterLinkInternal * const li = ff_link_internal(link);
FFFilterContext * const ctxi_dst = fffilterctx(link->dst);
FF_TPRINTF_START(NULL, request_frame); ff_tlog_link(NULL, link, 1);
@ -482,7 +484,7 @@ int ff_request_frame(AVFilterLink *link)
if (li->status_in) {
if (ff_framequeue_queued_frames(&li->fifo)) {
av_assert1(!li->frame_wanted_out);
av_assert1(link->dst->ready >= 300);
av_assert1(ctxi_dst->ready >= 300);
return 0;
} else {
/* Acknowledge status change. Filters using ff_request_frame() will
@ -1384,12 +1386,13 @@ static int ff_filter_activate_default(AVFilterContext *filter)
int ff_filter_activate(AVFilterContext *filter)
{
FFFilterContext *ctxi = fffilterctx(filter);
int ret;
/* Generic timeline support is not yet implemented but should be easy */
av_assert1(!(filter->filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC &&
filter->filter->activate));
filter->ready = 0;
ctxi->ready = 0;
ret = filter->filter->activate ? filter->filter->activate(filter) :
ff_filter_activate_default(filter);
if (ret == FFERROR_NOT_READY)

@ -518,12 +518,13 @@ struct AVFilterContext {
*/
AVBufferRef *hw_device_ctx;
#if FF_API_CONTEXT_PUBLIC
/**
* Ready status of the filter.
* A non-0 value means that the filter needs activating;
* a higher value suggests a more urgent activation.
* @deprecated this field should never have been accessed by callers
*/
attribute_deprecated
unsigned ready;
#endif
/**
* Sets the number of extra hardware frames which the filter will

@ -102,6 +102,13 @@ typedef struct FFFilterContext {
// AV_CLASS_STATE_FLAG_*
unsigned state_flags;
/**
* Ready status of the filter.
* A non-0 value means that the filter needs activating;
* a higher value suggests a more urgent activation.
*/
unsigned ready;
} FFFilterContext;
static inline FFFilterContext *fffilterctx(AVFilterContext *ctx)

@ -1470,15 +1470,19 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph)
int ff_filter_graph_run_once(AVFilterGraph *graph)
{
AVFilterContext *filter;
FFFilterContext *ctxi;
unsigned i;
av_assert0(graph->nb_filters);
filter = graph->filters[0];
for (i = 1; i < graph->nb_filters; i++)
if (graph->filters[i]->ready > filter->ready)
filter = graph->filters[i];
if (!filter->ready)
ctxi = fffilterctx(graph->filters[0]);
for (i = 1; i < graph->nb_filters; i++) {
FFFilterContext *ctxi_other = fffilterctx(graph->filters[i]);
if (ctxi_other->ready > ctxi->ready)
ctxi = ctxi_other;
}
if (!ctxi->ready)
return AVERROR(EAGAIN);
return ff_filter_activate(filter);
return ff_filter_activate(&ctxi->p);
}

@ -37,5 +37,6 @@
#define FF_API_LINK_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 11)
#define FF_API_BUFFERSINK_OPTS (LIBAVFILTER_VERSION_MAJOR < 11)
#define FF_API_CONTEXT_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 11)
#endif /* AVFILTER_VERSION_MAJOR_H */

Loading…
Cancel
Save