From patchwork Sun Jun 18 11:17:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42204 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp57527pzb; Sun, 18 Jun 2023 04:23:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7zAQJ2u4ndi5dWVSdKHKGJAKJFEpVU78TjrVPdmy3/m4dBbji8ARKwEvBZTj+FVe2vprUf X-Received: by 2002:aa7:de12:0:b0:514:7f36:7092 with SMTP id h18-20020aa7de12000000b005147f367092mr4555863edv.12.1687087422576; Sun, 18 Jun 2023 04:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687087422; cv=none; d=google.com; s=arc-20160816; b=cbPsaN/YCQdwr4soxnho6TD109sZX10JzZZgDJMeOm3C9UMps18x5XFQHe18+/F5Ir AfBQZKZb2VS7SghegXiIYB/RalxJETJjumB9ynf/cWbPB27nn3Yf2bc7fnSBmO8wj2Ss XkPyghJcKtiFt/EjE4KC+uXGXoam8tG3KCTwol4WhxU+ClgCZUKTCD522cr6S884HqKY k7Z5gZhemHTsr6WOq2InwbvPOI79L+sgVsjcBGl1G4mYh8oXzUXUZZ7t1jh3mtdBzmwN fE7OqUO6TN5EqOhzBuVFk1sgAaPNmyfN8B9MDmbu1JtjWFP89CeTVCP+6Ai8bfzL4PAJ cwiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=LPOUOlWaKsVVVXIkUzZ4bkyvRxY+2a0fEtNwd4+QgK8=; b=F3sqdeaamwBSmxmjQu1bRSzeW8h0KlkjDJmhNN/a2mCnQ3t8AWSeAONZphl8WmtHbg ctiEeCAwbez4VzG7BukvbdcBpeqGifhh5DlUCfGohtUTuU4oNDY5nRvCJXB6JfPg3dQ9 wlUqwYIcq02tG44x4vu+WpRC8WACcNkUcfk2l6dEpTMCD2zlElumdSHbe0GiWK/M/XyQ FOcJh2pblyl/qzym4fYTGb/Xe7DZP7EvQlO7lc6iarz1K+H8cnHija+Cz6FcQ3eknIyu bVJG1ZOTCWFVfFA1OgMSDAeVsdn+LNhb7o/gG4Bwelk8N/gxIOXnqhKe2Fw2di2sqTDM ICVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=Pr1VuJw2; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e15-20020a056402088f00b0051892a12c03si4213740edy.99.2023.06.18.04.23.42; Sun, 18 Jun 2023 04:23:42 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=Pr1VuJw2; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B69F268C2A3; Sun, 18 Jun 2023 14:20:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B6DFA68C08B for ; Sun, 18 Jun 2023 14:20:14 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id C7AF74B7B8; Sun, 18 Jun 2023 13:20:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1687087211; bh=x0Sm4xroF6fRUm84bad2pPXnhLifHL14/V1/zve7OCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pr1VuJw2jk36Fa7ZVazR35rNcj8A7iCi+XXarmdP4H9IhBTSpZPozuBcD0FzMtEvH 5mBFTNIIeYz8NxTVElZqK9sekX6ro3G4J2FJGCGPtaIcxUR6PMAldMcFu1VPGDR8SX teAP6Rn7zJ3bmtamj74nP4gN8MJE7H86vIHW9LrM= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2023 13:17:06 +0200 Message-ID: <20230618111955.40994-16-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230618111955.40994-2-ffmpeg@haasn.xyz> References: <20230618111955.40994-2-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 14/22] lavfi/vf_libplacebo: only drain actually used PTS 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: uTeutouziNB9 From: Niklas Haas When combining multiple inputs, the output PTS may be less than the PTS of the input. In this case, the current's code assumption of always draining one value from the FIFO is incorrect. Replace by a smarter function which drains only those PTS values that were actually consumed. --- libavfilter/vf_libplacebo.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 47f019fa192..753d6f3cc79 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -971,6 +971,13 @@ static int handle_input(AVFilterContext *ctx, LibplaceboInput *input) return 0; } +static void drain_input_pts(LibplaceboInput *in, int64_t until) +{ + int64_t pts; + while (av_fifo_peek(in->out_pts, &pts, 1, 0) >= 0 && pts <= until) + av_fifo_drain2(in->out_pts, 1); +} + static int libplacebo_activate(AVFilterContext *ctx) { int ret, retry = 0; @@ -1023,8 +1030,7 @@ static int libplacebo_activate(AVFilterContext *ctx) ff_inlink_request_frame(in->link); return 0; case PL_QUEUE_OK: - if (!s->fps.num) - av_fifo_drain2(in->out_pts, 1); + drain_input_pts(in, out_pts); return output_frame(ctx, out_pts); case PL_QUEUE_ERR: return AVERROR_EXTERNAL;