From patchwork Sun Sep 8 21:38:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 51422 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9c4f:0:b0:48e:c0f8:d0de with SMTP id w15csp1376103vqu; Sun, 8 Sep 2024 19:04:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVYIezneZVo7t/Vfg6hHPlFtI05z35c5klbot/vBhhy62xCMJ0HueLJQamyXATfygbQM+x1dIKvLAOyqeJFHK/3@gmail.com X-Google-Smtp-Source: AGHT+IEjY5Ril09kMmzbBBIyptxfyk33kjA9UlOcQSFNiEs9xoY/VcpsR81NJZRfSNtx+flaBGHE X-Received: by 2002:a05:6402:5207:b0:5c2:4e5b:d0cc with SMTP id 4fb4d7f45d1cf-5c3dc77ff69mr2764304a12.1.1725847448624; Sun, 08 Sep 2024 19:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725847448; cv=none; d=google.com; s=arc-20240605; b=caXXHBsFWP2d5rGPFj7Dru0IsMMy1Kg7t2f6hqqhMCDhaeY2si003xC3eQUVq0JUDH q2SFng7UIRXNJGw9KXpMFLzOsxYDn56GC1QX8eW5Lcitq2cZmrUV6sXLIxUvT18f38XS 0ltyz4FJ5zFXwlFfAufYSnKwObZPwhHGZmK3ek3ErLY0fg39axlLPETIMCgCjBDgrHwU ZpaHGt3Zo4BLQSq2dv3fdk2SDSDzWG1NNrdOeLzeCMpn9wdaSBFhpBFfXhvvRVvUO7wA YK4Zrje9PnbOom3pkgYw3dmgGbwqmkdV98WFROAU1Dy+I2AR2eul+Ijb6OujLJAtmObU 6Opw== 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=DsTeeLv52MCysYmpLOHCHnr1UAn2BuBGkTDt6hqIP9k=; fh=5IeVwzS1vbVKjIV8MP3mnmnRtZGb8uteQ9r4QD2keV0=; b=UmYWaNyLNZ+2CvdcJaKAR5iVo0i9DanFuusF9iuoSJ5BPzOy2OhbFDFvH9L5UJCNHF 5UQCCkOmJYeUMk1c0hbRojdg5sSZSlHGnANryeSd1WxzFyJxuM8aDq9SLT+dxNe+kbc8 wTY0UpV7INTYydxItLPN6ofsJ4fJxFmqwrYralR5JeaOYD0o9CK1hBTFsIIqeupPFi8U 2qc0yjXwc7dIHHTJL6BRJ+lXzJQyk9ux8rLcNlxhE5nKOm/kGjxmaS7LsWwTLxEQhdsl acT8+LaA68ij0ncYyGdHywhghMZYZyqPP/ul2xeGKJQVUylEPITCg4IpIzvOpYDRfkGh 5y4w==; 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=CRJW24e6; 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 4fb4d7f45d1cf-5c3ebdaa5d8si3100200a12.550.2024.09.08.19.04.08; Sun, 08 Sep 2024 19:04:08 -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=CRJW24e6; 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 65E4168DD37; Mon, 9 Sep 2024 03:55:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 46B4368DC45 for ; Mon, 9 Sep 2024 03:55:29 +0300 (EEST) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-42cae102702so15072205e9.0 for ; Sun, 08 Sep 2024 17:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725843328; x=1726448128; darn=ffmpeg.org; h=subject:date:from:to:message-id:in-reply-to:from:to:cc:subject:date :message-id:reply-to; bh=4K6kA5C58SWi2iBywTcfEDhNj7t2CA1kQBeHDhtZ34g=; b=CRJW24e66mm9OZ8ZEJIozTyk/AX/mDZ/DLYOyb+I8xjLZdKc0qKHZ1xYOMYME/KXGG cAWEUYRzucF5dA373JLg7qkA4TY6qkYzQKXWPB166VbmuDdf4H6nNQPc38XOHrcuUta5 hnxg99peDgoxP6ohycjbc1Yu9xBKWHXVmL8jgh61fEhfBRETo3/k0MRsO7JKOqtomGm6 l5TmQbcI5YSYe6Uix9rNoq5HPhQ2ts6Sbe4+IIs44VwEaf7TlsDA9AR6sOv1EIv0NyFk ped8UDPGOc/za48sIkRmsmScsCfgmSDsJH2+YRDNO3ebiuxiIyD+62qvjBFfTFuB0wsa ugOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725843328; x=1726448128; h=subject:date:from:to:message-id:in-reply-to:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=4K6kA5C58SWi2iBywTcfEDhNj7t2CA1kQBeHDhtZ34g=; b=kxh4uUaNDT/W9dlhGVffcktk5HQndEFxwIGaIioNtFxCYAQsd/gX1xAH3I7wY0aP82 +VaIu0qVbW8R0BgJ08NnfLcDUUBiNaNDW6IH7BE72n++/t8i258xNxRtXOXd8/aEd/+i k8ntcZxCcpFciyP8KmJZ+sykh7KDlFPsCW14jBaANAQ6tPkYTB5lS4bQJKGQNLkXVj6y PNMOjA/xo6bUcZSkOPLtC50acvFIPHKKZmSOjX1+zKaKzzHQCK/gROGhy9jPF5dcIYnQ FZTem3y+yOCh1UNGXmnykVchznE8oB4X75nwgnfZdSs9+din6d/Xrxz72I7HSoqDV8V4 Xexg== X-Gm-Message-State: AOJu0YzOl5KefT2zAMb6HumNw5krR2QEqkXP8w6xCZXVvELA7YuPa9bk 7OI0zLobuY9t9/lQhBqYuNK8kEgxbnHrKzIPJ35w93MZdGtx+O4eagkaSw== X-Received: by 2002:adf:f147:0:b0:374:c35a:7335 with SMTP id ffacd0b85a97d-378949f7ccbmr3379314f8f.18.1725843328493; Sun, 08 Sep 2024 17:55:28 -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.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Sep 2024 17:55:27 -0700 (PDT) In-Reply-To: Message-Id: To: From: "Marvin Scholz" Date: Sun, 8 Sep 2024 23:38:26 +0200 Subject: [FFmpeg-devel] [PATCH 29/60] avcodec/fix: 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: 8NpV8N2D5Ul6 --- libavcodec/fic.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/libavcodec/fic.c b/libavcodec/fic.c index 4763fab689..8f4277b4e1 100644 --- a/libavcodec/fic.c +++ b/libavcodec/fic.c @@ -113,25 +113,24 @@ static av_always_inline void fic_idct(int16_t *blk, int step, int shift, int rnd static void fic_idct_put(uint8_t *dst, int stride, int16_t *block) { - int i, j; int16_t *ptr; ptr = block; fic_idct(ptr++, 8, 13, (1 << 12) + (1 << 17)); - for (i = 1; i < 8; i++) { + for (int i = 1; i < 8; i++) { fic_idct(ptr, 8, 13, 1 << 12); ptr++; } ptr = block; - for (i = 0; i < 8; i++) { + for (int i = 0; i < 8; i++) { fic_idct(ptr, 1, 20, 0); ptr += 8; } ptr = block; - for (j = 0; j < 8; j++) { - for (i = 0; i < 8; i++) + for (int j = 0; j < 8; j++) { + for (int i = 0; i < 8; i++) dst[i] = av_clip_uint8(ptr[i]); dst += stride; ptr += 8; @@ -140,7 +139,7 @@ static void fic_idct_put(uint8_t *dst, int stride, int16_t *block) static int fic_decode_block(FICContext *ctx, GetBitContext *gb, uint8_t *dst, int stride, int16_t *block, int *is_p) { - int i, num_coeff; + int num_coeff; if (get_bits_left(gb) < 8) return AVERROR_INVALIDDATA; @@ -157,7 +156,7 @@ static int fic_decode_block(FICContext *ctx, GetBitContext *gb, if (num_coeff > 64) return AVERROR_INVALIDDATA; - for (i = 0; i < num_coeff; i++) { + for (int i = 0; i < num_coeff; i++) { int v = get_se_golomb(gb); if (v < -2048 || v > 2048) return AVERROR_INVALIDDATA; @@ -179,18 +178,18 @@ static int fic_decode_slice(AVCodecContext *avctx, void *tdata) int slice_h = tctx->slice_h; int src_size = tctx->src_size; int y_off = tctx->y_off; - int x, y, p, ret; + int ret; ret = init_get_bits8(&gb, src, src_size); if (ret < 0) return ret; - for (p = 0; p < 3; p++) { + for (int p = 0; p < 3; p++) { int stride = ctx->frame->linesize[p]; uint8_t* dst = ctx->frame->data[p] + (y_off >> !!p) * stride; - for (y = 0; y < (slice_h >> !!p); y += 8) { - for (x = 0; x < (ctx->aligned_width >> !!p); x += 8) { + for (int y = 0; y < (slice_h >> !!p); y += 8) { + for (int x = 0; x < (ctx->aligned_width >> !!p); x += 8) { if ((ret = fic_decode_block(ctx, &gb, dst + x, stride, tctx->block, &tctx->p_frame)) != 0) return ret; @@ -206,9 +205,7 @@ static int fic_decode_slice(AVCodecContext *avctx, void *tdata) static av_always_inline void fic_alpha_blend(uint8_t *dst, uint8_t *src, int size, uint8_t *alpha) { - int i; - - for (i = 0; i < size; i++) + for (int i = 0; i < size; i++) dst[i] += ((src[i] - dst[i]) * alpha[i]) >> 8; } @@ -219,10 +216,9 @@ static void fic_draw_cursor(AVCodecContext *avctx, int cur_x, int cur_y) uint8_t *dstptr[3]; uint8_t planes[4][1024]; uint8_t chroma[3][256]; - int i, j, p; /* Convert to YUVA444. */ - for (i = 0; i < 1024; i++) { + for (int i = 0; i < 1024; i++) { planes[0][i] = (( 25 * ptr[0] + 129 * ptr[1] + 66 * ptr[2]) / 255) + 16; planes[1][i] = ((-38 * ptr[0] + 112 * ptr[1] + -74 * ptr[2]) / 255) + 128; planes[2][i] = ((-18 * ptr[0] + 112 * ptr[1] + -94 * ptr[2]) / 255) + 128; @@ -232,22 +228,22 @@ static void fic_draw_cursor(AVCodecContext *avctx, int cur_x, int cur_y) } /* Subsample chroma. */ - for (i = 0; i < 32; i += 2) - for (j = 0; j < 32; j += 2) - for (p = 0; p < 3; p++) + for (int i = 0; i < 32; i += 2) + for (int j = 0; j < 32; j += 2) + for (int p = 0; p < 3; p++) chroma[p][16 * (i / 2) + j / 2] = (planes[p + 1][32 * i + j ] + planes[p + 1][32 * i + j + 1] + planes[p + 1][32 * (i + 1) + j ] + planes[p + 1][32 * (i + 1) + j + 1]) / 4; /* Seek to x/y pos of cursor. */ - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) dstptr[i] = ctx->final_frame->data[i] + (ctx->final_frame->linesize[i] * (cur_y >> !!i)) + (cur_x >> !!i) + !!i; /* Copy. */ - for (i = 0; i < FFMIN(32, avctx->height - cur_y) - 1; i += 2) { + for (int i = 0; i < FFMIN(32, avctx->height - cur_y) - 1; i += 2) { int lsize = FFMIN(32, avctx->width - cur_x); int csize = lsize / 2; @@ -272,7 +268,7 @@ static int fic_decode_frame(AVCodecContext *avctx, AVFrame *rframe, FICContext *ctx = avctx->priv_data; const uint8_t *src = avpkt->data; int ret; - int slice, nslices; + int nslices; int msize; int tsize; int cur_x, cur_y; @@ -371,7 +367,7 @@ static int fic_decode_frame(AVCodecContext *avctx, AVFrame *rframe, } memset(ctx->slice_data, 0, nslices * sizeof(ctx->slice_data[0])); - for (slice = 0; slice < nslices; slice++) { + for (int slice = 0; slice < nslices; slice++) { unsigned slice_off = AV_RB32(src + tsize + FIC_HEADER_SIZE + slice * 4); unsigned slice_size; int y_off = ctx->slice_h * slice; @@ -407,7 +403,7 @@ static int fic_decode_frame(AVCodecContext *avctx, AVFrame *rframe, ctx->frame->flags |= AV_FRAME_FLAG_KEY; ctx->frame->pict_type = AV_PICTURE_TYPE_I; - for (slice = 0; slice < nslices; slice++) { + for (int slice = 0; slice < nslices; slice++) { if (ctx->slice_data[slice].p_frame) { ctx->frame->flags &= ~AV_FRAME_FLAG_KEY; ctx->frame->pict_type = AV_PICTURE_TYPE_P;