From patchwork Sat Nov 26 08:19:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 39454 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp6013260pzb; Sat, 26 Nov 2022 00:20:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf6lPrL9eUAFVvno/Yf/wX9PPqw5PBJNQ7xteP9rxvu+ttXXBbVNqJjkIhpkA9fsNDiyOSFM X-Received: by 2002:a17:906:7f07:b0:7ad:b216:f1ce with SMTP id d7-20020a1709067f0700b007adb216f1cemr35170131ejr.419.1669450813505; Sat, 26 Nov 2022 00:20:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669450813; cv=none; d=google.com; s=arc-20160816; b=aRW/1cTjZ+UM7BM++oEwQpA24NQQb8q+51TZdhnq/yIF5ZQvzS5SajKH+4N9M9MGZM P7RtYQTuhpqBoRxGz6kYmU7ka1IXYEAFMYvCxDgayS7jVh4/WcFreiE+YIB93dEyQYVv f0TQ65wuj9y9blkCKgVv07Svs5+UNpUyGjMaPrzpZGd3QFmoNIsc7EWiTu1WhD6myoqh cWw/w3EFhCY8AHS+fqvyK+bt5F1xyAFy4s3IQxLxcypLn+/hDED2nbPN4Pf7T66a5C3k I1BuIP0xUqUK7ZCXLk2d86Z+v9WOFFfJAEFPuP+60JLPSIEKAis9nFbjxDsbinOm3izN R5yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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:delivered-to; bh=xpcnScGF6LN5/W0aHzegNTGZutsRYym61FIciw6vap4=; b=h8/3fea+NulOIBgx53UWnZ6UbgYZB4b7ZSNDJLXCyazwmc5lSNVzc+Y/pbr1OD0i3G fVB226kOHPJWRqQjYGSVHYxGBeqyO7dvclF/bM7IkZbNKFipUjVspyUAlXVqO9j9Tcsn FZSpV/ElQtnknvbsuT2AmpiCRuWLUdNq6cgdoexD++h2qfwaKWCod4UuEzBUHj69N2G2 v5jWxAPbP9utpd5UIvYhTx5xyPJloa+gf3rSKD6iZ7QtfX5msapUW15KRASAo13RZNZt t4a+I9yW60H4WdoBYApKZTNc9I8pmSoJ7TdV3QWNUBIWb3CsNNXM5fih5aiHCkAmkIUE TgRA== ARC-Authentication-Results: i=1; mx.google.com; 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 gs12-20020a1709072d0c00b0078d78fbb88dsi3277649ejc.967.2022.11.26.00.20.13; Sat, 26 Nov 2022 00:20:13 -0800 (PST) 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; 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 66E0368B8BE; Sat, 26 Nov 2022 10:19:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 884F568B48E for ; Sat, 26 Nov 2022 10:19:25 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 47DC12404F8 for ; Sat, 26 Nov 2022 09:19:25 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6-EFpQSABrbp for ; Sat, 26 Nov 2022 09:19:24 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id A0B1C2405EC for ; Sat, 26 Nov 2022 09:19:23 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 9084F3A0CD6 for ; Sat, 26 Nov 2022 09:19:23 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 26 Nov 2022 09:19:05 +0100 Message-Id: <20221126081911.31275-7-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221126081911.31275-1-anton@khirnov.net> References: <20221126081911.31275-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/13] fftools/ffmpeg: set AVFrame.time_base after filtering 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 45AFbYjOg9mm Makes it easier to track what timebase are the frame timestamps in and allows to stop accessing filters in code that shouldn't deal with filtering. --- fftools/ffmpeg.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 263670d3f5..2ee40890a9 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -678,17 +678,14 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost, double float_pts = AV_NOPTS_VALUE; // this is identical to frame.pts but with higher precision AVCodecContext *enc = ost->enc_ctx; AVRational filter_tb = (AVRational){ -1, -1 }; - if (!frame || frame->pts == AV_NOPTS_VALUE || - !enc || !ost->filter || !ost->filter->graph->graph) + if (!frame || frame->pts == AV_NOPTS_VALUE || !enc) goto early_exit; { - AVFilterContext *filter = ost->filter->filter; - int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; AVRational tb = enc->time_base; int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16); - filter_tb = av_buffersink_get_time_base(filter); + filter_tb = frame->time_base; tb.den <<= extra_bits; float_pts = @@ -701,6 +698,7 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost, frame->pts = av_rescale_q(frame->pts, filter_tb, enc->time_base) - av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base); + frame->time_base = enc->time_base; } early_exit: @@ -1295,6 +1293,7 @@ static int reap_filters(int flush) AVRational tb = av_buffersink_get_time_base(filter); ost->last_filter_pts = av_rescale_q(filtered_frame->pts, tb, AV_TIME_BASE_Q); + filtered_frame->time_base = tb; if (debug_ts) av_log(NULL, AV_LOG_INFO, "filter_raw -> pts:%s pts_time:%s time_base:%d/%d\n",