From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C4DF9465AD for ; Mon, 22 May 2023 08:35:24 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4318768C135; Mon, 22 May 2023 11:35:22 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 20E2968AFD7 for ; Mon, 22 May 2023 11:35:16 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id DA79B42DED; Mon, 22 May 2023 10:35:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1684744515; bh=jYrRAR+lHoayAigMFAWped6/2liM5x74VPvzzu5AmHQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=H9GG15cgOGDYpxlVSsyCmWGBKFHJS0pb/B7nXzk6cPMRXDTwsHunoVtvvY0aSVXfF alOkipAYrLyqVRRaaXNODpVygTkmPG+bm3JCFS2P+eIFs7pLiQAT105wCHPAqGWzJx j9HXgPxPlVq/ppdKDpBLrvmxC0IYGu2jRxXJCHzk= Date: Mon, 22 May 2023 10:35:15 +0200 Message-ID: <20230522103515.GB56755@haasn.xyz> From: Niklas Haas To: ffmpeg-devel@ffmpeg.org In-Reply-To: <20230521111352.102281-1-ffmpeg@haasn.xyz> References: <20230521111352.102281-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Content-Disposition: inline Subject: Re: [FFmpeg-devel] [PATCH] lavfi/libplacebo: properly handle EOF X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Niklas Haas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sun, 21 May 2023 13:13:52 +0200 Niklas Haas wrote: > From: Niklas Haas > > 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 > Merged as c00fd025587fc8f028cda2c36f0061070fe91a35 _______________________________________________ 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".