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 F29A446736 for ; Fri, 16 Jun 2023 09:32:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 03A7F68C607; Fri, 16 Jun 2023 12:30:41 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 79EAB68C5C1 for ; Fri, 16 Jun 2023 12:30:31 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 55301436B4; Fri, 16 Jun 2023 11:30:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907831; bh=Bu6cXQFW7flVz2N+p3SkLuhVfsVN4MBHUxoCNHn6ysQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DvY1td4/OyFChzBX8YYN+/lcHFc59GxuaPOdfw/fM2SmgOTM/rIZspUwy5vYdQCpX PfP3WBqUHHZ4E4GI4f9Tdh33rSqOX3+BCX/yAj8UqfJEprMiJBxcAxG5yNBSmy3Pgy wEI0rhGGCW2lQfLgyG208KfZgbK1fLpLJqTL5cTs= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:58 +0200 Message-ID: <20230616092959.5247-21-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/22] lavfi/vf_libplacebo: set time_base/frame_rate dynamically 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: From: Niklas Haas Use the gcd of all input timebases to ensure PTS accuracy. For the framerate, just pick the highest of all the inputs, under the assumption that we will render frames with approximately this frequency. Of course, this is not 100% accurate, in particular if the input frames are badly misaligned. But this field is informational to begin with. Importantly, it covers the "common" case of combining high FPS and low FPS streams with aligned frames. --- libavfilter/vf_libplacebo.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 9b1526f19e..7840677b06 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -1156,6 +1156,11 @@ static int libplacebo_config_input(AVFilterLink *inlink) return 0; } +static inline AVRational max_q(AVRational a, AVRational b) +{ + return av_cmp_q(a, b) < 0 ? b : a; +} + static int libplacebo_config_output(AVFilterLink *outlink) { int err; @@ -1196,6 +1201,16 @@ static int libplacebo_config_output(AVFilterLink *outlink) if (s->fps.num) { outlink->frame_rate = s->fps; outlink->time_base = av_inv_q(s->fps); + } else { + outlink->frame_rate = avctx->inputs[0]->frame_rate; + outlink->time_base = avctx->inputs[0]->time_base; + for (int i = 1; i < s->nb_inputs; i++) { + outlink->frame_rate = max_q(outlink->frame_rate, + avctx->inputs[i]->frame_rate); + outlink->time_base = av_gcd_q(outlink->time_base, + avctx->inputs[i]->time_base, + AV_TIME_BASE / 2, AV_TIME_BASE_Q); + } } /* Static variables */ -- 2.41.0 _______________________________________________ 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".