From e78360db52b727be41e9fb6e7f3bfe0253cee14a Mon Sep 17 00:00:00 2001 From: Stone Chen Date: Wed, 12 Feb 2025 14:56:56 -0500 Subject: [PATCH] vvc_deblock.c: fix RANDCLIP Previously RANDCLIP(x, diff) was computing the difference x - diff and then clipping it between (0, max_pixel_val + rnd() % 2 * diff). This means we're not really generating a random value in the range. Instead compute (x - diff) + rnd() % 2 * diff. This returns a value such that abs(value - x) < diff. This greatly improves the generation of strong deblocking data. --- tests/checkasm/vvc_deblock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/checkasm/vvc_deblock.c b/tests/checkasm/vvc_deblock.c index 577dde0cef..22087cdbae 100644 --- a/tests/checkasm/vvc_deblock.c +++ b/tests/checkasm/vvc_deblock.c @@ -67,8 +67,8 @@ static const uint32_t pixel_mask[3] = {0xffffffff, 0x03ff03ff, 0x0fff0fff}; else \ *(uint16_t*)(&x) = z; \ } while (0) -#define RANDCLIP(x, diff) av_clip(GET(x) - (diff), 0, \ - (1 << (bit_depth)) - 1) + rnd() % FFMAX(2 * (diff), 1) +#define RANDCLIP(x, diff) av_clip(GET(x) - (diff) + rnd() % FFMAX(2 * (diff), 1), \ +0, (1 << (bit_depth)) - 1) static void randomize_params(int32_t *beta, int32_t *tc, const int is_luma, const int bit_depth, const int size) {