From patchwork Thu Aug 11 17:44:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Cooper X-Patchwork-Id: 157 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp183063vsd; Thu, 11 Aug 2016 10:44:43 -0700 (PDT) X-Received: by 10.194.72.226 with SMTP id g2mr12243286wjv.70.1470937483907; Thu, 11 Aug 2016 10:44:43 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bb3si3410550wjb.243.2016.08.11.10.44.43; Thu, 11 Aug 2016 10:44:43 -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; dkim=neutral (body hash did not verify) header.i=@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 58B9F68A475; Thu, 11 Aug 2016 20:44:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0676568A17C for ; Thu, 11 Aug 2016 20:44:21 +0300 (EEST) Received: by mail-pa0-f52.google.com with SMTP id pp5so653055pac.3 for ; Thu, 11 Aug 2016 10:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=ZUeYE6H4L+hZ18f9/M+zzGEgt6TxD0GxAmBU3+vK8lE=; b=cPy3H5LVTKoW9Xag4tHz+UY81Iw58s2anKEW2mP+kNhdVtUdJJYJzb5Rd7TQZkd8MC zCro3sQmDAQzWtqk2lDjyA1/E4yd2ebfQOVtzCkW0CX3n7Hkbd4eosBLaQHabuTPue4a X1SZGFq5dfBma8UFC7cc6B7pIYqGT1zz1Rtqz8X5CFUR5v622VE9lpVPCCiyYT2F1FBR D2069ywkGn+A6mqvVUiFR/Bgwx0v8OH4ddb5QgZGVtvTvhCApJbcE+uoSaQ4m35bu7Au towO4Od9FHBhuOMNQpBgQVs+Q4+j5V4K6wM3jsRmHln/aDR0Cke+Ugr/cV8SPgRF8372 m8ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZUeYE6H4L+hZ18f9/M+zzGEgt6TxD0GxAmBU3+vK8lE=; b=Y0D4ynd55VozGT5s2/ENJoXo4/2i9f2E6iLesoOf5SJSZbFB5k1ONIQzzc1flfgmk7 BuYWkpbBVs8zn+YG2FbtIDLf6w9n1D1bZ+fOkAVeIKOtxJep0u1A4hiLC0q+ScVkzykE plNYW3HjpYky79KcKmQIcyCXf6UGDnBsmr6HoockZ0fatBe9Kkkf2OKTTKm3jcFZyvn+ mU7hxXbRFDgezmSkBTnORfBzoFDPeRZshyTzpF3AqsmYCo+TtC2jR9QBnOGWlsqfzpRO yySfB8WtQf0w+LhwowyWLzyrjvp5g+qaZS6YmrRFON+0eNHYbrZxCJfI6vqd8L0CySGt ++eg== X-Gm-Message-State: AEkoousJyzGDA9WVQbQam45kvIIIVQ1iTAvgYFYJpGFW1AuVAj+4F55DYam/yQHS7SUlhQE0 X-Received: by 10.66.132.105 with SMTP id ot9mr19565243pab.88.1470937460649; Thu, 11 Aug 2016 10:44:20 -0700 (PDT) Received: from pinkiepie.mtv.corp.google.com ([172.27.82.120]) by smtp.gmail.com with ESMTPSA id 9sm6816154pfo.74.2016.08.11.10.44.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Aug 2016 10:44:20 -0700 (PDT) From: Lucas Cooper To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Aug 2016 10:44:12 -0700 Message-Id: <1470937452-14164-1-git-send-email-bobobo@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 Subject: [FFmpeg-devel] [PATCH] Add max value output option to psnr stats log. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Lucas Cooper MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This allows retroactive calculation/aggregation of PSNR from the stats log. --- libavfilter/vf_psnr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c index 3bec747..de5cc8f 100644 --- a/libavfilter/vf_psnr.c +++ b/libavfilter/vf_psnr.c @@ -45,6 +45,7 @@ typedef struct PSNRContext { char *stats_file_str; int stats_version; int stats_header_written; + int stats_add_max; int max[4], average_max; int is_rgb; uint8_t rgba_map[4]; @@ -63,6 +64,7 @@ static const AVOption psnr_options[] = { {"stats_file", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, {"f", "Set file where to store per-frame difference information", OFFSET(stats_file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, {"stats_version", "Set the format version for the stats file.", OFFSET(stats_version), AV_OPT_TYPE_INT, {.i64=1}, 1, 2, FLAGS }, + {"output_max", "Add raw stats (max values) to the output log.", OFFSET(stats_add_max), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS}, { NULL } }; @@ -182,6 +184,12 @@ static AVFrame *do_psnr(AVFilterContext *ctx, AVFrame *main, for (j = 0; j < s->nb_components; j++) { fprintf(s->stats_file, ",psnr_%c", s->comps[j]); } + if (s->stats_add_max) { + fprintf(s->stats_file, ",max_avg"); + for (j = 0; j < s->nb_components; j++) { + fprintf(s->stats_file, ",max_%c", s->comps[j]); + } + } fprintf(s->stats_file, "\n"); s->stats_header_written = 1; } @@ -196,6 +204,13 @@ static AVFrame *do_psnr(AVFilterContext *ctx, AVFrame *main, fprintf(s->stats_file, "psnr_%c:%0.2f ", s->comps[j], get_psnr(comp_mse[c], 1, s->max[c])); } + if (s->stats_version == 2 && s->stats_add_max) { + fprintf(s->stats_file, "max_avg:%d ", s->average_max); + for (j = 0; j < s->nb_components; j++) { + c = s->is_rgb ? s->rgba_map[j] : j; + fprintf(s->stats_file, "max_%c:%d ", s->comps[j], s->max[c]); + } + } fprintf(s->stats_file, "\n"); }