From patchwork Sun Aug 29 23:37:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 29864 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp3469634iov; Sun, 29 Aug 2021 16:37:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPVRAIf7tXaFIZbmwlFnxRcnhmP7Shj70jeAfT9G2WAgyesKV8aqF5XEwJy2+lzj4eiIh6 X-Received: by 2002:a50:cb83:: with SMTP id k3mr21848316edi.102.1630280259391; Sun, 29 Aug 2021 16:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630280259; cv=none; d=google.com; s=arc-20160816; b=0MiNhkzTSpQMee4CQkwjQIT6zW0nb77smzp3jGtWub9sraCZ8gmUGwjhMZzf8HSlIE wCUaxxdI9Xc758PMYis2sDIch4gaMAw5NKDWjlIXjgUtHXK1ShKC3M3b8Z5hNV2kyxnu iXmj5G0+7ysn0C3F/063MFtKfrLiOmLnqj8I8vsXzS+Q/pppaKs4eSMrOG8ljCA5se6S HfOLtqDV2wOnnRsGo1BHTk0PDJabxP8Wv3f7+GucYwitRSiCwCkk5qcZ+yBhKMQd1ts9 unt1JyOXvqRUE0qEyODRPJMB/zGgFYmaN3mXMkU3F7s7S8F0MB/8aHTGKVSmX+CLkGSe e39w== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=BwHWqqPPorQisEqdBhTOaTh2rMb7qr3IUDjIQWaLjio=; b=GIImpZfHWw15zS5QqQwR33xZC1QrJZ4gm1OQz3w/WC/cM2/l9WM/n1g1EE0IKgAK0y C0D7AbCsODjMyXgsgAq/XFl8Nn3SBUTfPSTWG4511bDQVkZGwTngLTa4KwyUoq0q2CqJ FiO8p4iywWW3aUJVv2t4329xkdGDjbWzwrX/xZydOrYFWN0bDmuZbvlkTp5cXgVrS7On vDOQcOcbpqxO7St+q3z0r+i/kGD5rIlGnUmfWbahXbzocWS8hOzxz0kbb4G5EXkfwGMB vVEpzNtRyJuVFpK3asdOH39yCeRmJBD+na7cqlLRWIl2Bx6JuPZ2EFaiOnTqOdRFLWZP LiDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=EuoKyS2Q; 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 k24si13399607edr.79.2021.08.29.16.37.38; Sun, 29 Aug 2021 16:37:39 -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=EuoKyS2Q; 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 62E046899DA; Mon, 30 Aug 2021 02:37:34 +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 E6EFD6806F9 for ; Mon, 30 Aug 2021 02:37:27 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id D003747710; Mon, 30 Aug 2021 01:37:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1630280246; bh=RNcngEVrpPYuwTs5Wb28SJaNjWyr+WVGgS/kwAWCGy8=; h=From:To:Cc:Subject:Date:From; b=EuoKyS2Q4P/+AZgmDjGMzVTzSgla586kusuxWxHlvcKA2dq4urpNtISJ6aBuDJ4ss AcMa4zgwiSXBLYfFZVdkWR/O0hzLx05aRktxL5+81w/Ps+SLxVb0y8KA1PXYjA6Iqv IzOm5N1lY/sr80X3YT9jmHxk9kmLY7SDTxNMJsCE= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Mon, 30 Aug 2021 01:37:21 +0200 Message-Id: <20210829233721.58127-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/h274: slightly fix comments 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: 9DWQ4jRRHEJu From: Niklas Haas This comment was wrong. It does not require an FFT, a straight sum is enough. (An FFT is only required for high-passed grain, not generational grain) Also fix a misleading/redundant comment on avg_8x8_c - the right shift is just part of the averaging logic. --- libavcodec/h274.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libavcodec/h274.c b/libavcodec/h274.c index 5e2cf150ea..7ace1829b4 100644 --- a/libavcodec/h274.c +++ b/libavcodec/h274.c @@ -110,7 +110,7 @@ static void init_slice(H274FilmGrainDatabase *database, uint8_t h, uint8_t v) init_slice_c(database->db[h][v], h, v, database->slice_tmp); } -// Computes the average of an 8x8 block, right-shifted by 6 +// Computes the average of an 8x8 block static uint16_t avg_8x8_c(const uint8_t *in, int in_stride) { uint16_t avg[8] = {0}; // summing over an array vectorizes better @@ -166,15 +166,9 @@ static av_always_inline void generate(int8_t *out, int out_stride, uint8_t h, v; int8_t s = -1; - // FIXME: This logic only generates grain with a single - // intensity interval. Strictly speaking, the H.274 specification allows - // for overlapping intensity intervals, however SMPTE RDD 5-2006 (which - // concerns the implementation of H.274 for H.264) forbids this as it - // requires a nontrivial grain synthesis process (FFT). - // - // In principle, we should detect this possibility ahead of time and warn - // the user that the output is unlikely to be correct, or alternatively - // return an AVERROR_PATCHWELCOME. + // TODO: Multi-generational grain, adding together multiple synthesized + // grain blocks where needed. This is allowed by H.274 but forbidden by + // SMPTE RDD 5-2006 (which concerns the implementation of H.274 for H.264) for (int i = 0; i < h274->num_intensity_intervals[c]; i++) { if (avg >= h274->intensity_interval_lower_bound[c][i] && avg <= h274->intensity_interval_upper_bound[c][i])