Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avfillter/buffersrc: activate and EOF fix
@ 2023-10-27 12:38 Paul B Mahol
  2023-10-27 12:53 ` Nicolas George
  0 siblings, 1 reply; 30+ messages in thread
From: Paul B Mahol @ 2023-10-27 12:38 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- Attachment #1: Type: text/plain, Size: 18 bytes --]

Patches attached.

[-- Attachment #2: 0001-avfilter-buffersrc-switch-to-activate.patch --]
[-- Type: text/x-patch, Size: 2555 bytes --]

From 8cbfb1beddcdede7c50a0879ac21654cba02f6b5 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Fri, 27 Oct 2023 14:26:50 +0200
Subject: [PATCH 1/2] avfilter/buffersrc: switch to activate

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/buffersrc.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 453fc0fd5c..1216904721 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -36,6 +36,7 @@
 #include "audio.h"
 #include "avfilter.h"
 #include "buffersrc.h"
+#include "filters.h"
 #include "formats.h"
 #include "internal.h"
 #include "video.h"
@@ -484,21 +485,28 @@ static int config_props(AVFilterLink *link)
     return 0;
 }
 
-static int request_frame(AVFilterLink *link)
+static int activate(AVFilterContext *ctx)
 {
-    BufferSourceContext *c = link->src->priv;
+    AVFilterLink *outlink = ctx->outputs[0];
+    BufferSourceContext *c = ctx->priv;
+
+    if (!c->eof && ff_outlink_get_status(outlink)) {
+        c->eof = 1;
+        return 0;
+    }
 
-    if (c->eof)
-        return AVERROR_EOF;
+    if (c->eof) {
+        ff_outlink_set_status(outlink, AVERROR_EOF, c->last_pts);
+        return 0;
+    }
     c->nb_failed_requests++;
-    return AVERROR(EAGAIN);
+    return FFERROR_NOT_READY;
 }
 
 static const AVFilterPad avfilter_vsrc_buffer_outputs[] = {
     {
         .name          = "default",
         .type          = AVMEDIA_TYPE_VIDEO,
-        .request_frame = request_frame,
         .config_props  = config_props,
     },
 };
@@ -507,7 +515,7 @@ const AVFilter ff_vsrc_buffer = {
     .name      = "buffer",
     .description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them accessible to the filterchain."),
     .priv_size = sizeof(BufferSourceContext),
-
+    .activate  = activate,
     .init      = init_video,
     .uninit    = uninit,
 
@@ -521,7 +529,6 @@ static const AVFilterPad avfilter_asrc_abuffer_outputs[] = {
     {
         .name          = "default",
         .type          = AVMEDIA_TYPE_AUDIO,
-        .request_frame = request_frame,
         .config_props  = config_props,
     },
 };
@@ -530,7 +537,7 @@ const AVFilter ff_asrc_abuffer = {
     .name          = "abuffer",
     .description   = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them accessible to the filterchain."),
     .priv_size     = sizeof(BufferSourceContext),
-
+    .activate  = activate,
     .init      = init_audio,
     .uninit    = uninit,
 
-- 
2.42.0


[-- Attachment #3: 0002-avfilter-buffersrc-return-AVERROR_EOF-on-EOF.patch --]
[-- Type: text/x-patch, Size: 949 bytes --]

From 6bb41a6d27800825610d6dc77c8c0d7cf5c3a8e8 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Fri, 27 Oct 2023 14:33:00 +0200
Subject: [PATCH 2/2] avfilter/buffersrc: return AVERROR_EOF on EOF

Fixes error when user keeps adding frames into filtergraph
that reached EOF by other means, for example EOF is signalled
by other filter in filtergraph or by buffersink.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/buffersrc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 1216904721..b0a905d455 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -195,7 +195,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
     if (!frame)
         return av_buffersrc_close(ctx, s->last_pts, flags);
     if (s->eof)
-        return AVERROR(EINVAL);
+        return AVERROR_EOF;
 
     s->last_pts = frame->pts + frame->duration;
 
-- 
2.42.0


[-- Attachment #4: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2023-11-04 19:05 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-27 12:38 [FFmpeg-devel] [PATCH] avfillter/buffersrc: activate and EOF fix Paul B Mahol
2023-10-27 12:53 ` Nicolas George
2023-10-27 13:07   ` Paul B Mahol
2023-10-27 13:02     ` Nicolas George
2023-10-27 13:18       ` Paul B Mahol
2023-10-27 17:51         ` Paul B Mahol
2023-10-27 17:54           ` Nicolas George
2023-10-27 22:48             ` Paul B Mahol
2023-10-29  9:38               ` Nicolas George
2023-10-29 21:46                 ` Paul B Mahol
2023-10-31 10:55     ` Nicolas George
2023-10-31 20:13       ` Paul B Mahol
2023-10-31 20:14         ` Paul B Mahol
2023-11-01 13:58         ` Nicolas George
2023-11-01 14:15           ` Paul B Mahol
2023-11-01 14:13             ` Nicolas George
2023-11-02  9:56               ` Paul B Mahol
2023-11-02  9:50                 ` Nicolas George
2023-11-02 10:00                   ` Paul B Mahol
2023-11-02 10:03                     ` Nicolas George
2023-11-02 10:18                       ` Paul B Mahol
2023-11-02 10:15                         ` Nicolas George
2023-11-02 20:05                         ` Tristan Matthews
2023-11-03 19:04                           ` Nicolas George
2023-11-03 20:47                             ` Paul B Mahol
2023-11-04 19:05                               ` Nicolas George
2023-11-01 13:48       ` Jan Ekström
2023-11-01 13:56         ` Nicolas George
2023-11-01 14:23           ` James Almer
2023-11-01 14:28             ` Nicolas George

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