From: Niklas Haas <ffmpeg@haasn.xyz> To: ffmpeg-devel@ffmpeg.org Cc: Niklas Haas <git@haasn.dev> Subject: [FFmpeg-devel] [PATCH] lavfi/libplacebo: properly handle EOF Date: Sun, 21 May 2023 13:13:52 +0200 Message-ID: <20230521111352.102281-1-ffmpeg@haasn.xyz> (raw) From: Niklas Haas <git@haasn.dev> The current code relied on pl_queue eventually returning EOF back to the caller, which didn't work in all situations (e.g. single frame input). Also, the current code assumed that ff_inlink_acknowledge_status only fired once, which was patently not true, as the above edge cases demonstrated. Solve both issues by keeping track of the acknowledged link status and forwarding it (instead of trying to probe the pl_queue again) in the event that we run out of queued input frames, as well as (in CFR mode) when we pass the indicated status PTS. --- libavfilter/vf_libplacebo.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 94e49aa4652..6ce0f6263e4 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -131,6 +131,8 @@ typedef struct LibplaceboContext { /* filter state */ AVFifo *out_pts; ///< timestamps of wanted output frames + int64_t status_pts; + int status; /* settings */ char *out_format_string; @@ -805,19 +807,12 @@ static int libplacebo_activate(AVFilterContext *ctx) if (ret < 0) return ret; - if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { + if (!s->status && ff_inlink_acknowledge_status(inlink, &status, &pts)) { pts = av_rescale_q_rnd(pts, inlink->time_base, outlink->time_base, AV_ROUND_UP); - if (status == AVERROR_EOF) { - /* Signal EOF to pl_queue, and enqueue this output frame to - * make sure we see PL_QUEUE_EOF returned eventually */ - pl_queue_push(s->queue, NULL); - if (!s->fps.num) - av_fifo_write(s->out_pts, &pts, 1); - } else { - ff_outlink_set_status(outlink, status, pts); - return 0; - } + pl_queue_push(s->queue, NULL); /* Signal EOF to pl_queue */ + s->status = status; + s->status_pts = pts; } if (ff_outlink_frame_wanted(outlink)) { @@ -827,7 +822,17 @@ static int libplacebo_activate(AVFilterContext *ctx) if (s->fps.num) { pts = outlink->frame_count_out; } else if (av_fifo_peek(s->out_pts, &pts, 1, 0) < 0) { - ff_inlink_request_frame(inlink); + /* No frames queued */ + if (s->status) { + pts = s->status_pts; + } else { + ff_inlink_request_frame(inlink); + return 0; + } + } + + if (s->status && pts >= s->status_pts) { + ff_outlink_set_status(outlink, s->status, s->status_pts); return 0; } -- 2.40.1 _______________________________________________ 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".
next reply other threads:[~2023-05-21 11:14 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-21 11:13 Niklas Haas [this message] 2023-05-22 8:35 ` Niklas Haas
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=20230521111352.102281-1-ffmpeg@haasn.xyz \ --to=ffmpeg@haasn.xyz \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=git@haasn.dev \ /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