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) 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) int ff_request_frame(AVFilterLink *link)
{ {
FilterLinkInternal * const li = ff_link_internal(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); 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 (li->status_in) {
if (ff_framequeue_queued_frames(&li->fifo)) { if (ff_framequeue_queued_frames(&li->fifo)) {
av_assert1(!li->frame_wanted_out); av_assert1(!li->frame_wanted_out);
av_assert1(link->dst->ready >= 300); av_assert1(ctxi_dst->ready >= 300);
return 0; return 0;
} else { } else {
/* Acknowledge status change. Filters using ff_request_frame() will /* 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) int ff_filter_activate(AVFilterContext *filter)
{ {
FFFilterContext *ctxi = fffilterctx(filter);
int ret; int ret;
/* Generic timeline support is not yet implemented but should be easy */ /* Generic timeline support is not yet implemented but should be easy */
av_assert1(!(filter->filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC && av_assert1(!(filter->filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC &&
filter->filter->activate)); filter->filter->activate));
filter->ready = 0; ctxi->ready = 0;
ret = filter->filter->activate ? filter->filter->activate(filter) : ret = filter->filter->activate ? filter->filter->activate(filter) :
ff_filter_activate_default(filter); ff_filter_activate_default(filter);
if (ret == FFERROR_NOT_READY) if (ret == FFERROR_NOT_READY)

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

@ -102,6 +102,13 @@ typedef struct FFFilterContext {
// AV_CLASS_STATE_FLAG_* // AV_CLASS_STATE_FLAG_*
unsigned state_flags; 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; } FFFilterContext;
static inline FFFilterContext *fffilterctx(AVFilterContext *ctx) 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) int ff_filter_graph_run_once(AVFilterGraph *graph)
{ {
AVFilterContext *filter; FFFilterContext *ctxi;
unsigned i; unsigned i;
av_assert0(graph->nb_filters); av_assert0(graph->nb_filters);
filter = graph->filters[0]; ctxi = fffilterctx(graph->filters[0]);
for (i = 1; i < graph->nb_filters; i++) for (i = 1; i < graph->nb_filters; i++) {
if (graph->filters[i]->ready > filter->ready) FFFilterContext *ctxi_other = fffilterctx(graph->filters[i]);
filter = graph->filters[i];
if (!filter->ready) if (ctxi_other->ready > ctxi->ready)
ctxi = ctxi_other;
}
if (!ctxi->ready)
return AVERROR(EAGAIN); 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_LINK_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 11)
#define FF_API_BUFFERSINK_OPTS (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 */ #endif /* AVFILTER_VERSION_MAJOR_H */

Loading…
Cancel
Save