Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 02/10] lavfi: add a new struct for private link properties
Date: Sun, 11 Aug 2024 16:42:03 +0200
Message-ID: <20240811144211.5712-2-anton@khirnov.net> (raw)
In-Reply-To: <20240811144211.5712-1-anton@khirnov.net>

Specifically those that should be visible to filters, but hidden from
API callers. Such properties are currently located at the end of the
public AVFilterLink struct, demarcated by a comment marking them as
private. However it is generally better to hide them explicitly, using
the same pattern already employed in avformat or avcodec.

The new struct is currently trivial, but will become more useful in
following commits.
---
 libavfilter/avfilter.c          | 10 +++++-----
 libavfilter/avfilter_internal.h |  3 ++-
 libavfilter/avfiltergraph.c     | 10 +++++-----
 libavfilter/filters.h           | 10 ++++++++++
 4 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index c4bd134fb2..80c9cf7b51 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -176,7 +176,7 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
     li = av_mallocz(sizeof(*li));
     if (!li)
         return AVERROR(ENOMEM);
-    link = &li->l;
+    link = &li->l.pub;
 
     src->outputs[srcpad] = dst->inputs[dstpad] = link;
 
@@ -222,7 +222,7 @@ int avfilter_config_links(AVFilterContext *filter)
 
 static void update_link_current_pts(FilterLinkInternal *li, int64_t pts)
 {
-    AVFilterLink *const link = &li->l;
+    AVFilterLink *const link = &li->l.pub;
 
     if (pts == AV_NOPTS_VALUE)
         return;
@@ -1077,7 +1077,7 @@ static int samples_ready(FilterLinkInternal *link, unsigned min)
 static int take_samples(FilterLinkInternal *li, unsigned min, unsigned max,
                         AVFrame **rframe)
 {
-    AVFilterLink *link = &li->l;
+    AVFilterLink *link = &li->l.pub;
     AVFrame *frame0, *frame, *buf;
     unsigned nb_samples, nb_frames, i, p;
     int ret;
@@ -1169,7 +1169,7 @@ static int ff_filter_frame_to_filter(AVFilterLink *link)
 
 static int forward_status_change(AVFilterContext *filter, FilterLinkInternal *li_in)
 {
-    AVFilterLink *in = &li_in->l;
+    AVFilterLink *in = &li_in->l.pub;
     unsigned out = 0, progress = 0;
     int ret;
 
@@ -1431,7 +1431,7 @@ int ff_inlink_check_available_samples(AVFilterLink *link, unsigned min)
 
 static void consume_update(FilterLinkInternal *li, const AVFrame *frame)
 {
-    AVFilterLink *const link = &li->l;
+    AVFilterLink *const link = &li->l.pub;
     update_link_current_pts(li, frame->pts);
     ff_inlink_process_commands(link, frame);
     if (link == link->dst->inputs[0])
diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h
index 2c31c3e7de..7084411d68 100644
--- a/libavfilter/avfilter_internal.h
+++ b/libavfilter/avfilter_internal.h
@@ -28,10 +28,11 @@
 #include <stdint.h>
 
 #include "avfilter.h"
+#include "filters.h"
 #include "framequeue.h"
 
 typedef struct FilterLinkInternal {
-    AVFilterLink l;
+    FilterLink l;
 
     struct FFFramePool *frame_pool;
 
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 2791ffa64a..47655703cd 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -1326,7 +1326,7 @@ static void heap_bubble_up(FFFilterGraph *graph,
 
     while (index) {
         int parent = (index - 1) >> 1;
-        if (links[parent]->l.current_pts_us >= li->l.current_pts_us)
+        if (links[parent]->l.pub.current_pts_us >= li->l.pub.current_pts_us)
             break;
         links[index] = links[parent];
         links[index]->age_index = index;
@@ -1348,9 +1348,9 @@ static void heap_bubble_down(FFFilterGraph *graph,
         if (child >= graph->sink_links_count)
             break;
         if (child + 1 < graph->sink_links_count &&
-            links[child + 1]->l.current_pts_us < links[child]->l.current_pts_us)
+            links[child + 1]->l.pub.current_pts_us < links[child]->l.pub.current_pts_us)
             child++;
-        if (li->l.current_pts_us < links[child]->l.current_pts_us)
+        if (li->l.pub.current_pts_us < links[child]->l.pub.current_pts_us)
             break;
         links[index] = links[child];
         links[index]->age_index = index;
@@ -1372,13 +1372,13 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph)
 {
     FFFilterGraph *graphi = fffiltergraph(graph);
     FilterLinkInternal *oldesti = graphi->sink_links[0];
-    AVFilterLink *oldest = &oldesti->l;
+    AVFilterLink *oldest = &oldesti->l.pub;
     int64_t frame_count;
     int r;
 
     while (graphi->sink_links_count) {
         oldesti = graphi->sink_links[0];
-        oldest  = &oldesti->l;
+        oldest  = &oldesti->l.pub;
         if (oldest->dst->filter->activate) {
             r = av_buffersink_get_frame_flags(oldest->dst, NULL,
                                               AV_BUFFERSINK_FLAG_PEEK);
diff --git a/libavfilter/filters.h b/libavfilter/filters.h
index 86bc49d459..2c856fead7 100644
--- a/libavfilter/filters.h
+++ b/libavfilter/filters.h
@@ -33,6 +33,16 @@
  */
 #define FFERROR_NOT_READY FFERRTAG('N','R','D','Y')
 
+/**
+ * Link properties exposed to filter code, but not external callers.
+ *
+ * Cf. AVFilterLink for public properties, FilterLinkInternal for
+ * properties private to the generic layer.
+ */
+typedef struct FilterLink {
+    AVFilterLink pub;
+} FilterLink;
+
 /**
  * Mark a filter ready and schedule it for activation.
  *
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2024-08-11 14:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-11 14:42 [FFmpeg-devel] [PATCH 01/10] lavfi: set AVFilterLink.graph on link creation Anton Khirnov
2024-08-11 14:42 ` Anton Khirnov [this message]
2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 03/10] lavfi: move AVFilterLink.m{ax, in}_samples to FilterLink Anton Khirnov
2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 04/10] lavfi/vf_*_cuda: do not access hw contexts before checking they exist Anton Khirnov
2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 05/10] lavfi: move AVFilterLink.hw_frames_ctx to FilterLink Anton Khirnov
2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 06/10] lavfi: move AVFilterLink.current_pts(_us) " Anton Khirnov
2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 07/10] lavfi: move AVFilterLink.frame_rate " Anton Khirnov
2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 08/10] lavfi: move AVFilterLink.{frame, sample}_count_{in, out} " Anton Khirnov
2024-08-12 20:19   ` Michael Niedermayer
2024-08-13  8:28     ` Anton Khirnov
2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 09/10] lavfi: move AVFilterLink.frame_wanted_out to FilterLinkInternal Anton Khirnov
2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 10/10] lavfi: move AVFilterLink.graph to FilterLink Anton Khirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240811144211.5712-2-anton@khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git