From patchwork Wed Apr 19 19:48:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41253 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp741704pzb; Wed, 19 Apr 2023 12:49:19 -0700 (PDT) X-Google-Smtp-Source: AKy350Z1S66p3NtJXKAN5/3mm19rhvwDeSsRgYvr9qJso4rARGmez7Tvc+WDvE7ejG4YR0W6xxgU X-Received: by 2002:aa7:cb84:0:b0:504:8c1a:70db with SMTP id r4-20020aa7cb84000000b005048c1a70dbmr6796600edt.32.1681933759279; Wed, 19 Apr 2023 12:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681933759; cv=none; d=google.com; s=arc-20160816; b=q11b0xjT0zlVBeG3kSFjxibnBjOy6KUeBilYCdKclVwWq01UpbuhpNWmXeM+QraOx5 6qLOwhMwdNjL4t0pAS37akxqxvNVcJETSTUD6O87JaZ3YdI9uBxAwsJgG9PJS/bOE7l9 FpBBN9TlRW+SFlYr9nmuwNpz0EVi4oaVWQtCgc0T9u3qivpfioAKBONPN/flJzVe1zWu azf2bppZute4331+YgEL0spJ3iUu1l1+DtIRNHcGHbTekQK9mQ/L4rAUIkx60rJScIXb fXImiDcbFyKGp2yrFkwfN6Pspp17I/mLspLML3lC0m69td1AToB0DiHsNo6802DBZON0 Jphg== 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:message-id:date:to:from :delivered-to; bh=jrrB4x9zxTQ07wZXCxz4Zn+O1za3Whd1m1O/g7j7OlY=; b=0EKJl7Ww1CAtHqUJWaxYzlgeMoJsYvDT8YKNQ13THcBHEBtNLx82XDrJQmdakyrjrX 7mdAz3cEBmvCdu163srqNP75tdH2/zopkaRzjh0w2UgsLjFLhI/mLEHVgXWnWL4m/xFK kgpQ7Zgjef619YpE8L9qidpPRukCUYWfgvdeqH420pmoVnauxt7QY6LQNfqVBSwyNQSF RcT9EkBNu4fpVg0shM147yJ2Ew4cUpzQ7/LvZcxRA0XTqCuiOXyIRUMdaNNwRIrbvIMZ fRnq9HH/g3vjCNzRMkLxQjXexrfVA+URDsbF1bUQmAnh7Rg8x4iF+856iWB4xVdBCbvK 8tHw== 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 n12-20020aa7c68c000000b0050480d8a036si14643779edq.248.2023.04.19.12.49.18; Wed, 19 Apr 2023 12:49:19 -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 8242368BE34; Wed, 19 Apr 2023 22:49:15 +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 CAC73680C8F for ; Wed, 19 Apr 2023 22:49:08 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B4AC12404EE for ; Wed, 19 Apr 2023 21:49:07 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id NtKCBiRYermQ for ; Wed, 19 Apr 2023 21:49:07 +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 174452404EC for ; Wed, 19 Apr 2023 21:49:07 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3589E3A037D for ; Wed, 19 Apr 2023 21:48:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Apr 2023 21:48:32 +0200 Message-Id: <20230419194832.757-1-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [RFC/PATCH] fftools/ffmpeg: stop printing PSNR information in status report 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: yJoT/D0RXRC2 When an encoder exports sum-of-squared-differences information in encoded packets, print_report() will print PSNR information in the status line. However, * the code computing PSNR assumes 8bit 420 video and prints incorrect values otherwise; there are no issues on trac about this * only a few encoders (namely aom, vpx, mpegvideo, snow) export this information; other often-used encoders such as libx26[45] do not export this, even though they could This suggests that this feature is not useful and it is better to remove it rather than spend effort on fixing it. --- I needed to resolve this code's interaction with encoders as a part of my multithreading work and spent a few hours on it. Making it work correctly in all cases seems nontrivial and duplicates a lot of the logic from vf_psnr. Given that nobody ever noticed that it's broken for everything other than YUV420P, or bothered adding support in libx264 strongly suggests to me that nobody cares about this and it can be safely dropped. Anyone against? --- fftools/ffmpeg.c | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index a7e856e9e2..c73064af9a 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -767,36 +767,6 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti if (is_last_report) av_bprintf(&buf, "L"); - if (enc && (enc->flags & AV_CODEC_FLAG_PSNR) && - (ost->pict_type != AV_PICTURE_TYPE_NONE || is_last_report)) { - int j; - double error, error_sum = 0; - double scale, scale_sum = 0; - double p; - char type[3] = { 'Y','U','V' }; - av_bprintf(&buf, "PSNR="); - for (j = 0; j < 3; j++) { - if (is_last_report) { - error = enc->error[j]; - scale = enc->width * enc->height * 255.0 * 255.0 * frame_number; - } else { - error = ost->error[j]; - scale = enc->width * enc->height * 255.0 * 255.0; - } - if (j) - scale /= 4; - error_sum += error; - scale_sum += scale; - p = psnr(error / scale); - av_bprintf(&buf, "%c:%2.2f ", type[j], p); - av_bprintf(&buf_script, "stream_%d_%d_psnr_%c=%2.2f\n", - ost->file_index, ost->index, type[j] | 32, p); - } - p = psnr(error_sum / scale_sum); - av_bprintf(&buf, "*:%2.2f ", psnr(error_sum / scale_sum)); - av_bprintf(&buf_script, "stream_%d_%d_psnr_all=%2.2f\n", - ost->file_index, ost->index, p); - } vid = 1; } /* compute min output value */