From patchwork Wed May 17 10:19:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41656 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:ba91:b0:105:feb:71f2 with SMTP id fb17csp1077743pzb; Wed, 17 May 2023 03:20:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fUNwcx72eizu3lnXj45lxlqY5nZ0B8CU1qMzAglEXhE41nyvnRNNOIkrX+tSAAT+b8drL X-Received: by 2002:a17:907:6090:b0:96a:4ea0:a1e7 with SMTP id ht16-20020a170907609000b0096a4ea0a1e7mr24700567ejc.50.1684318856949; Wed, 17 May 2023 03:20:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684318856; cv=none; d=google.com; s=arc-20160816; b=POviAZOIlX1oHGSRzRlX+wHMdiNlZEzZB1ymcoYihVxcJJLPcDLBoDCNKOY14m6XX+ J4JQjMMom/6pKWVkuxGu+vcIlKoNCn0qZ0aINoezfpZwRVHUmg15SOxr38x6gh+pjYxW yVLq1X8vDXtbxKuAc58p2nr2EU2M04qhMyXpR/tYxbIdYGoxUCE2Zk6yQ9+7PjsSLnHh X/LMwQNKARLCye1OCn+M89FcODXRSr0+LT+BPLDtg74WNK9X7dkkOo7TcBKc/RauTwd9 i8amW8JGIRjUDwkjQhJXX1akbovpZCrdj8vhFBMZcJPGanNIEajXhKfwclrgeufoABeQ 553A== 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=5wioa3mLzjAp6VUfsdvoM2uW5pRCcPQhTwVQqSOIS+g=; b=esqWD7BJzUge3+uJ6pa98XuC3L2HAyGfotz8H3TCcg90vTs4U62SZHnvIe/Tf4KG5M Q6cfQx4KMKd6VmUw2wxA194KnTp8xLRGl+5xlIQy6seKwpwrXaJbrbua5BNwSv4t8XaK C8fue/PNrcYV/1hs14wcsxrhAJg5WD2hqhJJFy/qnGhtLe/cadA7cuIx4q8XVCwOndCS qrap45bptMjf2yY054x6YGnLx/oZQAhtrnCTF6f5sfxTVpFNw8FCXGdg35KHcy8msh5q 4ndId33NTzVw0sydVKc0e/t3ytnR9AnWIxwGDpgoY9jl3iqsrCGdtn0Zt/UbJEOExHzh AP2Q== 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 k21-20020a170906579500b0096647f97dc8si15534847ejq.82.2023.05.17.03.20.56; Wed, 17 May 2023 03:20:56 -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; 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 078C968C10E; Wed, 17 May 2023 13:20:53 +0300 (EEST) 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 E35DD68BF17 for ; Wed, 17 May 2023 13:20:46 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6D930240D28 for ; Wed, 17 May 2023 12:20:46 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id MV2vcecAjXGw for ; Wed, 17 May 2023 12:20:45 +0200 (CEST) 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 D394C2404EC for ; Wed, 17 May 2023 12:20:45 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 7025F3A048F for ; Wed, 17 May 2023 12:20:39 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 17 May 2023 12:19:55 +0200 Message-Id: <20230517102029.541-2-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230517102029.541-1-anton@khirnov.net> References: <20230517102029.541-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/36] fftools/ffmpeg: drop a useless local variable 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: zIIPinDx1rkS Store decoded frame timestamp directly in AVFrame.pts, there is no advantage to using a separate local variable for it. --- fftools/ffmpeg.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 084192f270..60f0ff3b12 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1029,7 +1029,6 @@ static int decode_video(InputStream *ist, const AVPacket *pkt, int *got_output, { AVFrame *frame = ist->decoded_frame; int ret = 0, err = 0; - int64_t best_effort_timestamp; // With fate-indeo3-2, we're getting 0-sized packets before EOF for some // reason. This seems like a semi-critical bug. Don't trigger EOF, and @@ -1089,19 +1088,15 @@ static int decode_video(InputStream *ist, const AVPacket *pkt, int *got_output, goto fail; } - best_effort_timestamp = frame->best_effort_timestamp; + frame->pts = frame->best_effort_timestamp; if (ist->framerate.num) - best_effort_timestamp = ist->cfr_next_pts++; + frame->pts = ist->cfr_next_pts++; // no timestamp available - extrapolate from previous frame duration - if (best_effort_timestamp == AV_NOPTS_VALUE) - best_effort_timestamp = ist->last_frame_pts == AV_NOPTS_VALUE ? 0 : - ist->last_frame_pts + ist->last_frame_duration_est; - - if(best_effort_timestamp != AV_NOPTS_VALUE) { - frame->pts = best_effort_timestamp; - } + if (frame->pts == AV_NOPTS_VALUE) + frame->pts = ist->last_frame_pts == AV_NOPTS_VALUE ? 0 : + ist->last_frame_pts + ist->last_frame_duration_est; // update timestamp history ist->last_frame_duration_est = video_duration_estimate(ist, frame); @@ -1112,15 +1107,12 @@ static int decode_video(InputStream *ist, const AVPacket *pkt, int *got_output, av_log(ist, AV_LOG_INFO, "decoder -> pts:%s pts_time:%s " "pkt_dts:%s pkt_dts_time:%s " - "best_effort_ts:%"PRId64" best_effort_ts_time:%s " "duration:%s duration_time:%s " "keyframe:%d frame_type:%d time_base:%d/%d\n", av_ts2str(frame->pts), av_ts2timestr(frame->pts, &ist->st->time_base), av_ts2str(frame->pkt_dts), av_ts2timestr(frame->pkt_dts, &ist->st->time_base), - best_effort_timestamp, - av_ts2timestr(best_effort_timestamp, &ist->st->time_base), av_ts2str(frame->duration), av_ts2timestr(frame->duration, &ist->st->time_base), !!(frame->flags & AV_FRAME_FLAG_KEY), frame->pict_type,