From patchwork Sun Sep 8 18:51:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 51411 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9c4f:0:b0:48e:c0f8:d0de with SMTP id w15csp1363766vqu; Sun, 8 Sep 2024 18:19:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUyxZ3wy0bcz/QrzXlUqx1yoASlFN7krpCXrPwxcqtLUdbcUXgmRR0n0OjqFT3TBrx0dRNbesL8S8T6HpbjaMjk@gmail.com X-Google-Smtp-Source: AGHT+IGo9PXJOuEUGKa4TdBjb+e2kQRRQ+GJ4zJXtfKI0/TdzBQ/vtDz+JufCb6PKJbC42+HgCfB X-Received: by 2002:a05:651c:1987:b0:2f7:5c24:97a with SMTP id 38308e7fff4ca-2f75c241996mr15713371fa.11.1725844755178; Sun, 08 Sep 2024 18:19:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725844755; cv=none; d=google.com; s=arc-20240605; b=WEVoDuvvjlF2Mcsw7uStPQdl4J/UFi9gfRtrtFHI0hQEPtMflZepfh3GeHw0+oKOKR SxyGa/gJvC+uHP1ipYAe9eC46m8LatZKDM413RHyYgxIrrrfJ+iMbKiqJDHX4bsyYruq jnzRY29FJdoxpNIk/rqtBvb+Lb4EkjQH7EY/jhDpWQH66pwsjV7k/yEdsd7NZ93o8BUo fmzyAZqdtUbrpMN2XYx6X23JBRzEbhlTzjkG4fs6cQisSmDVdlRUBRkz8re1AoiFptTx 56ZOIUX9dCoeoBf6Y2hYe8wCfSt2QVS3emwHp8Pz/tQMoDkQCulF9WbWAiUDDcGhXiXG D5ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:date:from:to:message-id:in-reply-to :dkim-signature:delivered-to; bh=dx8/uee2rHyK4KXwuPuSylZhSf4XnbyMT9AeJRQDmlE=; fh=5IeVwzS1vbVKjIV8MP3mnmnRtZGb8uteQ9r4QD2keV0=; b=jHC2LfrDFTh7ELlZY1BoZagrSXSI9dbfppmwr2H3dggJWGmPO0NzYaQwWf3e82hvpQ d7nLDezYU3AQZsOVzPbxyEhpqNHL6MgRAYwEgTTdhD98T6/2ZdVoC9tCXcexm1fEHZBV 1ykJxO+JQv9PpVpSMa8xQH5bl80KYkbq9eKcdJhAJAYbuZbbfZPgNxahPYujH6itcLfZ 94wFPkn2vozieXdR33Jm7FhgfBR1zdzagndvdadFRubDEExylUpFzj1moquQlDV/km6/ rrbAy2Ik5pYMDIZF4gHPoHBi08jEBegxoMP/wWBR1ddnbaRLcUFloIQOy8bPTD3j22OO 5ghA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=TvcUfIm2; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2f75bfd2d90si11433651fa.55.2024.09.08.18.19.14; Sun, 08 Sep 2024 18:19:15 -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=@gmail.com header.s=20230601 header.b=TvcUfIm2; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1DD7D68DB02; Mon, 9 Sep 2024 03:55:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BCC0368DA9B for ; Mon, 9 Sep 2024 03:55:12 +0300 (EEST) Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-374c5bab490so2944981f8f.1 for ; Sun, 08 Sep 2024 17:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725843312; x=1726448112; darn=ffmpeg.org; h=subject:date:from:to:message-id:in-reply-to:from:to:cc:subject:date :message-id:reply-to; bh=sbWVPa6SxJPzujpfy4gHjNwfx4jl8SVJtB4vZS1+Zl8=; b=TvcUfIm26YZkQm/JUZ3uYkZLHhHnQy4GNnIDRecUX+BT9Xx9C6XLdW0q5VaD5kcVIZ SjIxG8tEzbHpb3uLyiUYZ4kJksFJjDhoPi8ltM3BIF+7J0XmQG/ERltCeizbmWcqlb+8 9pcX5gkvwvlOMrd5mKvaWzH02MFnEHtSKtXvDhIbtnVWCvD05dtFvAfnO719iWZNNPd7 Va0kXah8xyKRF20/1WS+YLUHUWdPjiXvqd+TxsC23jaUSkpZW2EVUE0qm+eYIoG8A+LF 2M34igMNdIuWEHzXDekuWpK3Nforb2G6OOHXGZyrRhXiHEEHUKxhg1FwF0KePxJUYAlM k97Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725843312; x=1726448112; h=subject:date:from:to:message-id:in-reply-to:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=sbWVPa6SxJPzujpfy4gHjNwfx4jl8SVJtB4vZS1+Zl8=; b=IHin/2VRotcmU6t/2+Zvu63NmWgLX61jx/eTvz9Mb51wTL9rUyTuUTs1UNe1xP3ANL K4JxTOw4ZZyO//Ms0QNJWX6fDCXw7meXhCU4C1ERl3A0w7qLi6D9XasG89ZoH/TdhCTB ma61mMtDj4osnDz0R5SMihn3zbwRshvf1aLsBR1WE5AVQb1U3LvDUFS8mpPrTsSkFBwZ OFtjL0jmTCMlWhjbgkmMsAFQ89rb2U+zR08As7MeTzQPt8f6MACnQL/JeUktqfNZgVvg vnFrH2K5WBZ0a4/N3ZptYT3sKr7guyFlr+EtohlEEdk4Uopjz4K0NFXgPkGyUu5yOWH3 7JJQ== X-Gm-Message-State: AOJu0Yy/f/q1QMSkcLdCpRmsdVoLtDX2gRQZO4ywtAFBgenx5zrl2Iy+ /E1XAY/pko5lTnerTUMq7uYDJb1M4k5Hvtb8TDxHJfbAFPZoDy2JYZg9sg== X-Received: by 2002:adf:f547:0:b0:374:bfd8:eeee with SMTP id ffacd0b85a97d-378885cfcd4mr6383147f8f.10.1725843311947; Sun, 08 Sep 2024 17:55:11 -0700 (PDT) Received: from localhost (p200300cccf1178009d94fda8472792f7.dip0.t-ipconnect.de. [2003:cc:cf11:7800:9d94:fda8:4727:92f7]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895649728sm4583399f8f.16.2024.09.08.17.55.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Sep 2024 17:55:11 -0700 (PDT) In-Reply-To: Message-Id: To: From: "Marvin Scholz" Date: Sun, 8 Sep 2024 20:51:47 +0200 Subject: [FFmpeg-devel] [PATCH 12/60] lavfi/vf_ssim: narrow variable scopes 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: rEKig+oi+fJf --- libavfilter/vf_ssim.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c index 54e28d43bd..52b22a6870 100644 --- a/libavfilter/vf_ssim.c +++ b/libavfilter/vf_ssim.c @@ -194,9 +194,8 @@ static float ssim_end1(int s1, int s2, int ss, int s12) static float ssim_endn_16bit(const int64_t (*sum0)[4], const int64_t (*sum1)[4], int width, int max) { float ssim = 0.0; - int i; - for (i = 0; i < width; i++) + for (int i = 0; i < width; i++) ssim += ssim_end1x(sum0[i][0] + sum0[i + 1][0] + sum1[i][0] + sum1[i + 1][0], sum0[i][1] + sum0[i + 1][1] + sum1[i][1] + sum1[i + 1][1], sum0[i][2] + sum0[i + 1][2] + sum1[i][2] + sum1[i + 1][2], @@ -208,9 +207,8 @@ static float ssim_endn_16bit(const int64_t (*sum0)[4], const int64_t (*sum1)[4], static double ssim_endn_8bit(const int (*sum0)[4], const int (*sum1)[4], int width) { double ssim = 0.0; - int i; - for (i = 0; i < width; i++) + for (int i = 0; i < width; i++) ssim += ssim_end1(sum0[i][0] + sum0[i + 1][0] + sum1[i][0] + sum1[i + 1][0], sum0[i][1] + sum0[i + 1][1] + sum1[i][1] + sum1[i + 1][1], sum0[i][2] + sum0[i + 1][2] + sum1[i][2] + sum1[i + 1][2], @@ -443,7 +441,7 @@ static int config_input_ref(AVFilterLink *inlink) const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); AVFilterContext *ctx = inlink->dst; SSIMContext *s = ctx->priv; - int sum = 0, i; + int sum = 0; s->nb_threads = ff_filter_get_nb_threads(ctx); s->nb_components = desc->nb_components; @@ -464,9 +462,9 @@ static int config_input_ref(AVFilterLink *inlink) s->planeheight[0] = s->planeheight[3] = inlink->h; s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w); s->planewidth[0] = s->planewidth[3] = inlink->w; - for (i = 0; i < s->nb_components; i++) + for (int i = 0; i < s->nb_components; i++) sum += s->planeheight[i] * s->planewidth[i]; - for (i = 0; i < s->nb_components; i++) + for (int i = 0; i < s->nb_components; i++) s->coefs[i] = (double) s->planeheight[i] * s->planewidth[i] / sum; s->temp = av_calloc(s->nb_threads, sizeof(*s->temp)); @@ -544,9 +542,8 @@ static av_cold void uninit(AVFilterContext *ctx) if (s->nb_frames > 0) { char buf[256]; - int i; buf[0] = 0; - for (i = 0; i < s->nb_components; i++) { + for (int i = 0; i < s->nb_components; i++) { int c = s->is_rgb ? s->rgba_map[i] : i; av_strlcatf(buf, sizeof(buf), " %c:%f (%f)", s->comps[i], s->ssim[c] / s->nb_frames, ssim_db(s->ssim[c], s->nb_frames));