diff mbox series

[FFmpeg-devel,09/10] lavfi: move AVFilterLink.frame_wanted_out to FilterLinkInternal

Message ID 20240811144211.5712-9-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/10] lavfi: set AVFilterLink.graph on link creation | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Anton Khirnov Aug. 11, 2024, 2:42 p.m. UTC
---
 libavfilter/avfilter.c          | 22 ++++++++++++++--------
 libavfilter/avfilter.h          |  7 -------
 libavfilter/avfilter_internal.h |  7 +++++++
 libavfilter/avfiltergraph.c     |  2 +-
 libavfilter/buffersink.c        |  3 ++-
 libavfilter/filters.h           |  5 +----
 6 files changed, 25 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 9a01bc1c4e..055db01e02 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -264,7 +264,7 @@  void ff_avfilter_link_set_in_status(AVFilterLink *link, int status, int64_t pts)
     av_assert0(!li->status_in);
     li->status_in = status;
     li->status_in_pts = pts;
-    link->frame_wanted_out = 0;
+    li->frame_wanted_out = 0;
     li->frame_blocked_in = 0;
     filter_unblock(link->dst);
     ff_filter_set_ready(link->dst, 200);
@@ -278,7 +278,7 @@  static void link_set_out_status(AVFilterLink *link, int status, int64_t pts)
 {
     FilterLinkInternal * const li = ff_link_internal(link);
 
-    av_assert0(!link->frame_wanted_out);
+    av_assert0(!li->frame_wanted_out);
     av_assert0(!li->status_out);
     li->status_out = status;
     if (pts != AV_NOPTS_VALUE)
@@ -481,7 +481,7 @@  int ff_request_frame(AVFilterLink *link)
         return li->status_out;
     if (li->status_in) {
         if (ff_framequeue_queued_frames(&li->fifo)) {
-            av_assert1(!link->frame_wanted_out);
+            av_assert1(!li->frame_wanted_out);
             av_assert1(link->dst->ready >= 300);
             return 0;
         } else {
@@ -492,7 +492,7 @@  int ff_request_frame(AVFilterLink *link)
             return li->status_out;
         }
     }
-    link->frame_wanted_out = 1;
+    li->frame_wanted_out = 1;
     ff_filter_set_ready(link->src, 100);
     return 0;
 }
@@ -1058,7 +1058,7 @@  int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
                                        link->time_base);
     }
 
-    li->frame_blocked_in = link->frame_wanted_out = 0;
+    li->frame_blocked_in = li->frame_wanted_out = 0;
     li->l.frame_count_in++;
     li->l.sample_count_in += frame->nb_samples;
     filter_unblock(link->dst);
@@ -1241,7 +1241,7 @@  static int ff_filter_activate_default(AVFilterContext *filter)
     }
     for (i = 0; i < filter->nb_outputs; i++) {
         FilterLinkInternal * const li = ff_link_internal(filter->outputs[i]);
-        if (filter->outputs[i]->frame_wanted_out &&
+        if (li->frame_wanted_out &&
             !li->frame_blocked_in) {
             return ff_request_frame_to_filter(filter->outputs[i]);
         }
@@ -1581,7 +1581,7 @@  void ff_inlink_request_frame(AVFilterLink *link)
     av_unused FilterLinkInternal *li = ff_link_internal(link);
     av_assert1(!li->status_in);
     av_assert1(!li->status_out);
-    link->frame_wanted_out = 1;
+    li->frame_wanted_out = 1;
     ff_filter_set_ready(link->src, 100);
 }
 
@@ -1590,7 +1590,7 @@  void ff_inlink_set_status(AVFilterLink *link, int status)
     FilterLinkInternal * const li = ff_link_internal(link);
     if (li->status_out)
         return;
-    link->frame_wanted_out = 0;
+    li->frame_wanted_out = 0;
     li->frame_blocked_in = 0;
     link_set_out_status(link, status, AV_NOPTS_VALUE);
     while (ff_framequeue_queued_frames(&li->fifo)) {
@@ -1642,3 +1642,9 @@  int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link,
 
     return 0;
 }
+
+int ff_outlink_frame_wanted(AVFilterLink *link)
+{
+    FilterLinkInternal * const li = ff_link_internal(link);
+    return li->frame_wanted_out;
+}
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 176498cdb4..a91b543f5e 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -599,13 +599,6 @@  struct AVFilterLink {
      * Graph the filter belongs to.
      */
     struct AVFilterGraph *graph;
-
-    /**
-     * True if a frame is currently wanted on the output of this filter.
-     * Set when ff_request_frame() is called by the output,
-     * cleared when a frame is filtered.
-     */
-    int frame_wanted_out;
 };
 
 /**
diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h
index 7084411d68..974024254f 100644
--- a/libavfilter/avfilter_internal.h
+++ b/libavfilter/avfilter_internal.h
@@ -67,6 +67,13 @@  typedef struct FilterLinkInternal {
      */
     int status_out;
 
+    /**
+     * True if a frame is currently wanted on the output of this filter.
+     * Set when ff_request_frame() is called by the output,
+     * cleared when a frame is filtered.
+     */
+    int frame_wanted_out;
+
     /**
      * Index in the age array.
      */
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 18a3f54759..2d46dd7637 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -1406,7 +1406,7 @@  int avfilter_graph_request_oldest(AVFilterGraph *graph)
     while (frame_count == oldesti->l.frame_count_out) {
         r = ff_filter_graph_run_once(graph);
         if (r == AVERROR(EAGAIN) &&
-            !oldest->frame_wanted_out && !oldesti->frame_blocked_in &&
+            !oldesti->frame_wanted_out && !oldesti->frame_blocked_in &&
             !oldesti->status_in)
             (void)ff_request_frame(oldest);
         else if (r < 0)
diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index f76d0af7ff..bc4c4ebd43 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -88,6 +88,7 @@  static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, i
 {
     BufferSinkContext *buf = ctx->priv;
     AVFilterLink *inlink = ctx->inputs[0];
+    FilterLinkInternal *li = ff_link_internal(inlink);
     int status, ret;
     AVFrame *cur_frame;
     int64_t pts;
@@ -107,7 +108,7 @@  static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, i
             return status;
         } else if ((flags & AV_BUFFERSINK_FLAG_NO_REQUEST)) {
             return AVERROR(EAGAIN);
-        } else if (inlink->frame_wanted_out) {
+        } else if (li->frame_wanted_out) {
             ret = ff_filter_graph_run_once(ctx->graph);
             if (ret < 0)
                 return ret;
diff --git a/libavfilter/filters.h b/libavfilter/filters.h
index 3f591e6f9d..36164c171e 100644
--- a/libavfilter/filters.h
+++ b/libavfilter/filters.h
@@ -245,10 +245,7 @@  void ff_inlink_set_status(AVFilterLink *link, int status);
 /**
  * Test if a frame is wanted on an output link.
  */
-static inline int ff_outlink_frame_wanted(AVFilterLink *link)
-{
-    return link->frame_wanted_out;
-}
+int ff_outlink_frame_wanted(AVFilterLink *link);
 
 /**
  * Get the status on an output link.