diff mbox series

[FFmpeg-devel] avcodec/h274: slightly fix comments

Message ID 20210829233721.58127-1-ffmpeg@haasn.xyz
State New
Headers show
Series [FFmpeg-devel] avcodec/h274: slightly fix comments | expand


Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Niklas Haas Aug. 29, 2021, 11:37 p.m. UTC
From: Niklas Haas <git@haasn.dev>

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

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 mbox series


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])