Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Paul B Mahol <onemda@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avfilter/buffersrc: switch to activate
Date: Sat, 4 Nov 2023 20:07:38 +0100
Message-ID: <CAPYw7P7syZhb98oDAV53KGANqcZODxVNiEX+objtObTH-zG6ww@mail.gmail.com> (raw)

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

Attached.

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

From 31a6a78ebc3a3f8785ec7c8e5ffd4257c7eadec3 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] avfilter/buffersrc: switch to activate

Fixes error when caller 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 | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 453fc0fd5c..b0a905d455 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"
@@ -194,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;
 
@@ -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)
-        return AVERROR_EOF;
+    if (!c->eof && ff_outlink_get_status(outlink)) {
+        c->eof = 1;
+        return 0;
+    }
+
+    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: 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".

             reply	other threads:[~2023-11-04 18:59 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-04 19:07 Paul B Mahol [this message]
2023-11-04 19:06 ` Nicolas George
2023-11-04 20:05   ` Paul B Mahol
2023-11-06 18:54     ` Paul B Mahol
2023-11-06 18:50       ` Nicolas George
2023-11-06 19:59         ` Vittorio Giovara
2023-11-06 20:07           ` Nicolas George
2023-11-06 20:21             ` Vittorio Giovara
2023-11-06 20:28               ` Nicolas George
2023-11-06 20:45                 ` Vittorio Giovara
2023-11-06 20:50                   ` Nicolas George
2023-11-06 21:22                     ` Vittorio Giovara
2023-11-06 21:46                       ` Nicolas George
2023-11-06 22:26                         ` Vittorio Giovara
2023-11-06 22:48                           ` Nicolas George
2023-11-06 23:03                             ` Vittorio Giovara
2023-11-06 23:05                               ` Nicolas George
2023-11-06 23:20                                 ` Vittorio Giovara
2023-11-07  7:44                                   ` Nicolas George
2023-11-07  9:20                                     ` Vittorio Giovara
2023-11-07  9:35                                       ` Nicolas George
2023-11-07 20:05                                         ` Paul B Mahol
2023-11-07 21:50                                           ` Nicolas George
2023-11-07 22:40                                             ` Sean McGovern
2023-11-07 22:50                                               ` Nicolas George
2023-11-08 13:53                                                 ` Nicolas George
2023-11-08 18:28                                                   ` Paul B Mahol
2023-11-08 18:22                                                     ` Nicolas George
2023-11-11 18:03                                                       ` Paul B Mahol
2023-11-11 18:27                                                         ` Nicolas George
2023-11-11 18:38                                                           ` Vittorio Giovara
2023-11-11 18:42                                                             ` Nicolas George
2023-11-11 18:55                                                               ` Vittorio Giovara
2023-11-11 19:03                                                                 ` Nicolas George
2023-11-11 19:31                                                                   ` Vittorio Giovara
2023-11-12 10:02                                                                     ` Nicolas George
2023-11-12 16:36                                                                       ` Michael Niedermayer
2023-11-12 20:19                                                                         ` Paul B Mahol
2023-11-13 16:59                                                                           ` Michael Niedermayer
2023-11-13 17:45                                                                             ` Sean McGovern
2023-11-13 18:42                                                                               ` Zhao Zhili
2023-11-13 19:03                                                                             ` Paul B Mahol
2023-11-13 21:32                                                                             ` Nicolas George
2023-11-13 23:59                                                                               ` Paul B Mahol
2023-11-12  1:46                                                           ` Paul B Mahol
2023-11-12 10:00                                                             ` Nicolas George

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=CAPYw7P7syZhb98oDAV53KGANqcZODxVNiEX+objtObTH-zG6ww@mail.gmail.com \
    --to=onemda@gmail.com \
    --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