From patchwork Sun Sep 8 22:24:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 51464 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9c4f:0:b0:48e:c0f8:d0de with SMTP id w15csp1464652vqu; Mon, 9 Sep 2024 00:34:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVZ7UJqL8rG/1OATkqSqVIn8Nd266+1WQROD1jgdNBqnMwHYrGSPiK68q8gZz+A1v2xzapVspXlWc/DmAS3xR7j@gmail.com X-Google-Smtp-Source: AGHT+IF2mfrgevqKVWkVwDE49DoU2+tBTCiAj7NRZb2/q21w0arawpZ8l/L/9hQUu1lipd0xtmdt X-Received: by 2002:a05:651c:150f:b0:2f7:59b8:7e9a with SMTP id 38308e7fff4ca-2f759b87f2amr21335561fa.9.1725867253661; Mon, 09 Sep 2024 00:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725867253; cv=none; d=google.com; s=arc-20240605; b=AR8ldZPFOhJbL7/Uvur4pwRWGdg+8lB+xRd8z6dIhDbmYMj/4+P7WUegpkby8d2m5S aS1uEv/EUtSc2OT0gsmj5KLs+Mu1HywABUSskUhy0VVeBUbFoIh9D23J9Lhi0fRsrlhC 5AeBOcZIcpRZvYD9U2orimy4CJFIY6nxKPm9MfYch6eSqaPikGv+eZpJ7RDjLQxD+sQq x3vyFT3AvwTP56L8fMyobzrVR7vOaSFIJo9fweStmCiZUXNft8ENo7lMeTxa3eL+YqYS 7ieEhhgjJAfUJnGlCnw4cI8x65JE94ow2d6OaNvfmAIBNC1Awox8KyOanycgxE+3pJ8k b4sg== 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=AvtZULHnOxOshVD+eXNtvg7AvtlzLdL5jRno+DC6y1k=; fh=5IeVwzS1vbVKjIV8MP3mnmnRtZGb8uteQ9r4QD2keV0=; b=BFX65E03RWtGr0GTKzEh0Bjirvbm0odtCaS3dyb2p47T60Z2WlFO/MpKpujyQXiVc8 zDE/6rQ6ZzL8CLej17+XVCgkC0Fcv3tv7wnAyC/63+2vmWgOeOs6r7i2Ie1bNjPHpX8X Yqf3zPWd+crkSRiQpRiilZMqqkQMUGeN0qrqLBtNXNR/Zz9xA/gGFHCY3z5h7VTfoAPv YNxtQO18HybbTgyjqO5Bwo4HBMKj6KCY2Ak0bkGMvjcEftHGe67+S/Bmuoie4TwP0jg5 VMRhTKQEuIK2HY2qfPI/RJdsQiME3QWehmBV1zeSan4Gcgpe0OPmoVEPSUKOzkkn7Raj FdhQ==; 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=fdiaupXX; 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-2f75c087638si14296381fa.429.2024.09.09.00.34.13; Mon, 09 Sep 2024 00:34:13 -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=fdiaupXX; 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 A5D7368DD4F; Mon, 9 Sep 2024 03:55:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3BC2F68DC68 for ; Mon, 9 Sep 2024 03:55:31 +0300 (EEST) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-374c3400367so3115115f8f.2 for ; Sun, 08 Sep 2024 17:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725843330; x=1726448130; darn=ffmpeg.org; h=subject:date:from:to:message-id:in-reply-to:from:to:cc:subject:date :message-id:reply-to; bh=RxehWZzxIfcZymGyfRv91zpTyt+rENq9vd9AJshIhfk=; b=fdiaupXX3Ujt7i8wkS4e/EEQigmF1YGFZec2B/LdCSnTMp/TppEaNnujj7+PhCbaio m/59denm02WsNhI1YC/Z6LnhKhNzHldbMtfn+tp9MdsJ5poX3ZbBIIOuGrzyCkV9S8bS eIzkedtNVfjno5qfiv/CtIuUH/0JjUlibat+GTIFnb5auhd+SWfN0Nu59w/wWziQgBuK 1YL98ya4WYxLSJ97ATR8RNmBJ5XGty8153rnMD+Pd4IiugVqiGhx/FmV3M3/Kq77YYuc CHweX12syJs3IosxGjxbtFTGLsQzgHkm7SsAgaKOQDMyosniLWz9SV0F4AY8ZXbH+pzr nzxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725843330; x=1726448130; h=subject:date:from:to:message-id:in-reply-to:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=RxehWZzxIfcZymGyfRv91zpTyt+rENq9vd9AJshIhfk=; b=hgWqvnN21f70Z2HiPU5Zeqbod9HJn9Tn/Ko1nC4Jt4N87quuPjnXh5zsHv740sCRXk 8zwAK1in1S7RPFKIsAYsuYypRa5jVs1fT760WfBJL4iq890s5vh0zQQXsvFAgsj3tblV oWmcsmJzgaZOUFRBNHnTGPTf5znIKjr2UJme+KKhOULp7Ub5l3V0J4qpEZJ3OaC9a1Cs CNocqrwRFfd6MmJQtOfoMSlxje/CM6wdmNj+1DjS3WI3gCH50o0V5LdbhJlUJ/63jA1O 5HJPZu0RPgGviEX2qTclagiEDW+m8GWg+XpjbsCt7repuDf4TspuTMWRwA5pBqvM8DoG Qc4A== X-Gm-Message-State: AOJu0Yx/yzFWgXaECacpJpZ4J2KdmbPa/2BSE3t228WXXiJSbU2k2rMX NKJhxMgDa7f6oObAor6rt9w7zCHy0TiU22eJemRvogtYSP0u0kOjY6T2WQ== X-Received: by 2002:a5d:5cc5:0:b0:374:bcdc:6257 with SMTP id ffacd0b85a97d-37892466eecmr3963872f8f.54.1725843330546; Sun, 08 Sep 2024 17:55:30 -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.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Sep 2024 17:55:30 -0700 (PDT) In-Reply-To: Message-Id: To: From: "Marvin Scholz" Date: Mon, 9 Sep 2024 00:24:34 +0200 Subject: [FFmpeg-devel] [PATCH 31/60] avcodec/exr: narrow variable scope and fix shadowing 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: 8i5nGyVjEz8q --- libavcodec/exr.c | 103 ++++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 4bac0be89b..0f7c7b8546 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -989,7 +989,7 @@ static int dwa_uncompress(const EXRContext *s, const uint8_t *src, int compresse int64_t ac_count, dc_count, ac_compression; const int dc_w = td->xsize >> 3; const int dc_h = td->ysize >> 3; - GetByteContext gb, agb; + GetByteContext gb; int skip, ret; if (compressed_size <= 88) @@ -1103,51 +1103,54 @@ static int dwa_uncompress(const EXRContext *s, const uint8_t *src, int compresse bytestream2_skip(&gb, rle_csize); } - bytestream2_init(&agb, td->ac_data, ac_count * 2); + { + GetByteContext agb; + bytestream2_init(&agb, td->ac_data, ac_count * 2); - for (int y = 0; y < td->ysize; y += 8) { - for (int x = 0; x < td->xsize; x += 8) { - memset(td->block, 0, sizeof(td->block)); + for (int y = 0; y < td->ysize; y += 8) { + for (int x = 0; x < td->xsize; x += 8) { + memset(td->block, 0, sizeof(td->block)); - for (int j = 0; j < 3; j++) { - float *block = td->block[j]; - const int idx = (x >> 3) + (y >> 3) * dc_w + dc_w * dc_h * j; - uint16_t *dc = (uint16_t *)td->dc_data; - union av_intfloat32 dc_val; + for (int j = 0; j < 3; j++) { + float *block = td->block[j]; + const int idx = (x >> 3) + (y >> 3) * dc_w + dc_w * dc_h * j; + uint16_t *dc = (uint16_t *)td->dc_data; + union av_intfloat32 dc_val; - dc_val.i = half2float(dc[idx], &s->h2f_tables); + dc_val.i = half2float(dc[idx], &s->h2f_tables); - block[0] = dc_val.f; - ac_uncompress(s, &agb, block); - dct_inverse(block); - } + block[0] = dc_val.f; + ac_uncompress(s, &agb, block); + dct_inverse(block); + } - { - const int o = s->nb_channels == 4; - float *bo = ((float *)td->uncompressed_data) + - y * td->xsize * s->nb_channels + td->xsize * (o + 0) + x; - float *go = ((float *)td->uncompressed_data) + - y * td->xsize * s->nb_channels + td->xsize * (o + 1) + x; - float *ro = ((float *)td->uncompressed_data) + - y * td->xsize * s->nb_channels + td->xsize * (o + 2) + x; - float *yb = td->block[0]; - float *ub = td->block[1]; - float *vb = td->block[2]; - - for (int yy = 0; yy < 8; yy++) { - for (int xx = 0; xx < 8; xx++) { - const int idx = xx + yy * 8; - - convert(yb[idx], ub[idx], vb[idx], &bo[xx], &go[xx], &ro[xx]); - - bo[xx] = to_linear(bo[xx], 1.f); - go[xx] = to_linear(go[xx], 1.f); - ro[xx] = to_linear(ro[xx], 1.f); - } + { + const int o = s->nb_channels == 4; + float *bo = ((float *)td->uncompressed_data) + + y * td->xsize * s->nb_channels + td->xsize * (o + 0) + x; + float *go = ((float *)td->uncompressed_data) + + y * td->xsize * s->nb_channels + td->xsize * (o + 1) + x; + float *ro = ((float *)td->uncompressed_data) + + y * td->xsize * s->nb_channels + td->xsize * (o + 2) + x; + float *yb = td->block[0]; + float *ub = td->block[1]; + float *vb = td->block[2]; + + for (int yy = 0; yy < 8; yy++) { + for (int xx = 0; xx < 8; xx++) { + const int idx = xx + yy * 8; + + convert(yb[idx], ub[idx], vb[idx], &bo[xx], &go[xx], &ro[xx]); + + bo[xx] = to_linear(bo[xx], 1.f); + go[xx] = to_linear(go[xx], 1.f); + ro[xx] = to_linear(ro[xx], 1.f); + } - bo += td->xsize * s->nb_channels; - go += td->xsize * s->nb_channels; - ro += td->xsize * s->nb_channels; + bo += td->xsize * s->nb_channels; + go += td->xsize * s->nb_channels; + ro += td->xsize * s->nb_channels; + } } } } @@ -1378,10 +1381,10 @@ static int decode_block(AVCodecContext *avctx, void *tdata, ptr = p->data[plane] + window_ymin * p->linesize[plane] + (window_xmin * 4); for (i = 0; i < ysize; i++, ptr += p->linesize[plane]) { - const uint8_t *src; + const uint8_t *tmp_src; union av_intfloat32 *ptr_x; - src = channel_buffer[c]; + tmp_src = channel_buffer[c]; ptr_x = (union av_intfloat32 *)ptr; // Zero out the start if xmin is not 0 @@ -1395,20 +1398,20 @@ static int decode_block(AVCodecContext *avctx, void *tdata, union av_intfloat32 t; if (trc_func && c < 3) { for (x = 0; x < xsize; x++) { - t.i = bytestream_get_le32(&src); + t.i = bytestream_get_le32(&tmp_src); t.f = trc_func(t.f); *ptr_x++ = t; } } else if (one_gamma != 1.f) { for (x = 0; x < xsize; x++) { - t.i = bytestream_get_le32(&src); + t.i = bytestream_get_le32(&tmp_src); if (t.f > 0.0f && c < 3) /* avoid negative values */ t.f = powf(t.f, one_gamma); *ptr_x++ = t; } } else { for (x = 0; x < xsize; x++) { - t.i = bytestream_get_le32(&src); + t.i = bytestream_get_le32(&tmp_src); *ptr_x++ = t; } } @@ -1416,11 +1419,11 @@ static int decode_block(AVCodecContext *avctx, void *tdata, // 16-bit if (c < 3 || !trc_func) { for (x = 0; x < xsize; x++) { - *ptr_x++ = s->gamma_table[bytestream_get_le16(&src)]; + *ptr_x++ = s->gamma_table[bytestream_get_le16(&tmp_src)]; } } else { for (x = 0; x < xsize; x++) { - ptr_x[0].i = half2float(bytestream_get_le16(&src), &s->h2f_tables); + ptr_x[0].i = half2float(bytestream_get_le16(&tmp_src), &s->h2f_tables); ptr_x++; } } @@ -2033,7 +2036,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, GetByteContext *gb = &s->gb; uint8_t *ptr; - int i, y, ret, ymax; + int y, ret, ymax; int planes; int out_line_size; int nb_blocks; /* nb scanline or nb tile */ @@ -2191,7 +2194,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, s->buf_size = avpkt->size; // Zero out the start if ymin is not 0 - for (i = 0; i < planes; i++) { + for (int i = 0; i < planes; i++) { ptr = picture->data[i]; for (y = 0; y < FFMIN(s->ymin, s->h); y++) { memset(ptr, 0, out_line_size); @@ -2206,7 +2209,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture, ymax = FFMAX(0, s->ymax + 1); // Zero out the end if ymax+1 is not h if (ymax < avctx->height) - for (i = 0; i < planes; i++) { + for (int i = 0; i < planes; i++) { ptr = picture->data[i] + (ymax * picture->linesize[i]); for (y = ymax; y < avctx->height; y++) { memset(ptr, 0, out_line_size);