diff options
author | Henrik Gramner <gramner@twoorioles.com> | 2021-01-21 17:31:13 +0300 |
---|---|---|
committer | Henrik Gramner <henrik@gramner.com> | 2021-01-21 17:56:04 +0300 |
commit | f539111b2430ac7c50a6c6c0047bc073e61de5d0 (patch) | |
tree | bc7c5c3c24e9b046f380113915afd7a069069530 /tests | |
parent | 5686e8355c7da3851c5e0d997150b97b85cbdad9 (diff) |
checkasm: Improve looprestoration input randomization
SGR uses edge detection to decide which pixels to modify, but if the
input is pure random noise there isn't going to be many (if any) edges.
As a result the entire function call often ends up doing nothing,
which isn't ideal when we want test code for correctness.
Change the input randomization algorithm to generate a checkerboard
pattern with limited noise applied to the flat areas.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/checkasm/looprestoration.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/checkasm/looprestoration.c b/tests/checkasm/looprestoration.c index 5f6dba8..cef9efe 100644 --- a/tests/checkasm/looprestoration.c +++ b/tests/checkasm/looprestoration.c @@ -41,9 +41,14 @@ static int to_binary(int x) { /* 0-15 -> 0000-1111 */ static void init_tmp(pixel *buf, const ptrdiff_t stride, const int w, const int h, const int bitdepth_max) { + const int noise_mask = bitdepth_max >> 4; + const int x_off = rnd() & 7, y_off = rnd() & 7; + for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) - buf[x] = rnd() & bitdepth_max; + for (int x = 0; x < w; x++) { + buf[x] = (((x + x_off) ^ (y + y_off)) & 8 ? bitdepth_max : 0) ^ + (rnd() & noise_mask); + } buf += PXSTRIDE(stride); } } |