From patchwork Wed Sep 27 13:56:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 43989 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:2a18:b0:15d:8365:d4b8 with SMTP id e24csp2621102pzh; Wed, 27 Sep 2023 06:56:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEq0wK9Is9hWS3zaehpp+G2qUA01GyBCnf9tdEg6a2tr2eLHHHPQ8ilgdz0ZrJkM5EVh9qE X-Received: by 2002:a17:907:6a13:b0:9b2:b37d:17ff with SMTP id rf19-20020a1709076a1300b009b2b37d17ffmr2418317ejc.19.1695822998980; Wed, 27 Sep 2023 06:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695822998; cv=none; d=google.com; s=arc-20160816; b=LW5IZ6qEOnXvOY3pq4L8lLgwp8g4TNP6L3Wf6STQbfFNWZ2c9RAY55DJxKqNdpzzrN vdz5c1WLsWqKURRR69oePGl7B2OZ4kD9QdELjJq2Nuke5gqVexv8gcyyeEwscw/vrEFB 7ri6kZggzYnYJttFP5hdNxXrDSzM8nwetch6htJZRg2LUpDqt0tLPCCEuT1enBBxjhAA /AZkIuSlvUvoXgoEF1F8mRjHFpgyIJZRB5hbBpr1T08NlVul83o9prk7Gjw3Pe2Yf5I0 G5slT9EA1HZcPyoXZ2sdaVSqwNiDYJ3OUEBzvpXIFEyzzWC4G8DKskNyMrIAbbPW4Jyg ft7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=QthTCvkKgJOtmawlp+60KoKaoDk+/wb0m0kvX4MVE5c=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=V4IJeeI6AIkeMp7+iOlykN1sFGWa76vmNtUa3lqEvQ1yruHiVrNQlXluenYpFaZtnt LA/lS2alxsbBBlIlmESC8Y0qZDNVPZUmCCnVqMKJc+mNZNeEeRq+ucG+QkIvfvGmaDOp r2Vpbgs7/5Imc3xDJJ2xq+xvWG7I4ZuAtDQ1x6luP2aTTFV29z3SZ0VYORzNarSaCRTV VvToMqA57SFkJsowgTorekuXx1uyjqak7RYkExVle0dkx7OuLfxHzRIgP2xgcWg9b3wg ve4nR9yMD2eeWRplJD/yuyqgC9Ko0CzRmfnJ/e5eHFOxyBK9OQinoDMKEa31VCkGdPcp dU5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=re3c2b2Q; 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 h6-20020a1709060f4600b0099de8722195si13127439ejj.747.2023.09.27.06.56.38; Wed, 27 Sep 2023 06:56:38 -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=@haasn.xyz header.s=mail header.b=re3c2b2Q; 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 EA06168CB00; Wed, 27 Sep 2023 16:56:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B58D668CA4B for ; Wed, 27 Sep 2023 16:56:21 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 713EE43600; Wed, 27 Sep 2023 15:56:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1695822981; bh=x8ay4TMU12Yi2xmt/RH2vIkVO+AtJIJXWEXKWszY0OE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=re3c2b2QQlx0ivYbkwHv5iYjP3aEKN2vd5cLLO1dS5gSPHLUkoKUH3HfmOyCgMQdr piUIXODYNb26cUYwvFEs173NJTc4IJGANynMQF1YSmWG8gOl7xHo+LHojXMIiYIqqM CzcgHUsMNUvQRmxREKvL0G9MMVG6ledJjnvW3NAo= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 27 Sep 2023 15:56:16 +0200 Message-ID: <20230927135617.33952-2-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230927135617.33952-1-ffmpeg@haasn.xyz> References: <20230927135617.33952-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] lavc/h274: correct grain DB indices 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 Cc: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: tLtK77SMq33/ From: Niklas Haas The spec specified indices in the order [x][y], but our code follows the traditional C convention of [y][x]. This was not correctly account for when calculating the base index of the grain database access. --- libavcodec/h274.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/h274.c b/libavcodec/h274.c index fc111cdb50d..2388826d547 100644 --- a/libavcodec/h274.c +++ b/libavcodec/h274.c @@ -259,11 +259,11 @@ int ff_h274_apply_film_grain(AVFrame *out_frame, const AVFrame *in_frame, // only advanced in 16x16 blocks, so use a nested loop for (int y = 0; y < height; y += 16) { for (int x = 0; x < width; x += 16) { - uint16_t y_offset = (seed >> 16) % 52; - uint16_t x_offset = (seed & 0xFFFF) % 56; + uint16_t x_offset = (seed >> 16) % 52; + uint16_t y_offset = (seed & 0xFFFF) % 56; const int invert = (seed & 0x1); - y_offset &= 0xFFFC; - x_offset &= 0xFFF8; + x_offset &= 0xFFFC; + y_offset &= 0xFFF8; prng_shift(&seed); for (int yy = 0; yy < 16 && y+yy < height; yy += 8) {