From patchwork Wed May 11 08:16:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 35725 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp3781104pzb; Wed, 11 May 2022 01:18:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXHPXIkIIk1eWX57WnJVYX8+c2RHesBdmH6iRCpxS4wILG6cglHo1dxIGC/D0AY5ft650y X-Received: by 2002:a17:907:7e8f:b0:6f5:fc1:e8af with SMTP id qb15-20020a1709077e8f00b006f50fc1e8afmr22708761ejc.20.1652257081405; Wed, 11 May 2022 01:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652257081; cv=none; d=google.com; s=arc-20160816; b=zdoBZfpjXbRej5myG5JUB2c1HpTJvnn8ruLGYbWyVwsSbBC94XYcaK8Yk3Wa+i5nMw 9x1uZkKqtx0Ty9bVVpyQZlc0ebVZq9ycXgzymNhkaif62p/J6SlmBipjlmj80YtFOjcI AlB9yK3opEhbLZuYXIpYEdDTy/c4ZLhdYSo9Oy60APUSpcbe5YBqn+eD+a8ng1Gn0VCx G9vxry57nEoAsqtiZLePAjjzvAZQb1a3l9GrFeNKZLaUlOg1iBbpVV4ycWd7IjRSIekV i+6LM3SPPi3T2eGuYeAHmnWdImNF8DekzLoLN2KIICMG76l3T/otJrJFMtzL/yizYWqs 6ArQ== 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=8XxP3fqvoQ6gwTrUkArqXIiL+UQyBT0x0wKxjhmy+Uo=; b=p+XTdqeH8qBitYJ52nZ4jNDsCLiQFDJp0MmzeInZNoHE517J23bUo4eA1XmIQhDN90 X/IEK4ynv+PoPDYbk7VuN0ZhLEFYNLKsTwv/zxQM664YWHpmjSbxaV48mt4+hOJlgjkF YlsbGUN8q1K0bIfvVZiFQFQx3CUVFZMkjOuudtYqLdruGfrjZ78sXU20JmAXP90wE46h 81iqYeeWqXZJUNsFJz/EvcCSyr/jRfZjTfsu9HWuOH4sIalenG7jI8TppG0lqHxfYdRK q0PdLHlMHlsSHNhvaaLpY86yK8A3sD+LEjXc/h6F8lO4w+P7SdidtS2tELF3pkdoUtdl RSQw== 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 c69-20020a509fcb000000b0041d81347011si1479564edf.382.2022.05.11.01.18.00; Wed, 11 May 2022 01:18:01 -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 D033F68B38D; Wed, 11 May 2022 11:17:20 +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 7935068B3BB for ; Wed, 11 May 2022 11:17:11 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id DC57D24017E for ; Wed, 11 May 2022 10:17:10 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id A5WsNwki04jK for ; Wed, 11 May 2022 10:17:10 +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 B1330240506 for ; Wed, 11 May 2022 10:17:07 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id B2E0C3A0836; Wed, 11 May 2022 10:17:02 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 May 2022 10:16:52 +0200 Message-Id: <20220511081654.15127-7-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220511081654.15127-1-anton@khirnov.net> References: <20220511081654.15127-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/9] fftools/ffmpeg: stop using av_stream_get_end_pts() in do_video_stats() 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: mYbZB86NRh/K It retrieves libavformat's internal dts value (contrary to the function's name), which is not only incorrect in general, but also unnecessary because we can access the packet directly. --- fftools/ffmpeg.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index c15d1486dd..5983c57410 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -835,7 +835,7 @@ static double psnr(double d) return -10.0 * log10(d); } -static void do_video_stats(OutputStream *ost, int frame_size) +static void do_video_stats(OutputStream *ost, const AVPacket *pkt) { AVCodecContext *enc; int frame_number; @@ -863,13 +863,13 @@ static void do_video_stats(OutputStream *ost, int frame_size) if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR)) fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width * enc->height * 255.0 * 255.0))); - fprintf(vstats_file,"f_size= %6d ", frame_size); + fprintf(vstats_file,"f_size= %6d ", pkt->size); /* compute pts value */ - ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base); + ti1 = pkt->dts * av_q2d(ost->mux_timebase); if (ti1 < 0.01) ti1 = 0.01; - bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0; + bitrate = (pkt->size * 8) / av_q2d(enc->time_base) / 1000.0; avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0; fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate); @@ -943,7 +943,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) } if (enc->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename) - do_video_stats(ost, pkt->size); + do_video_stats(ost, pkt); ost->packets_encoded++;