Commit c49680e6 authored by Janne Grunau's avatar Janne Grunau

checkasm: replace rand() with xorshift xor128

Reduces the aarch64 checkasm run time from 22s to 2.4s.
parent c82cf102
Pipeline #3414 passed with stages
in 4 minutes and 41 seconds
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
static void init_tmp(pixel *buf, int n, const int bitdepth_max) { static void init_tmp(pixel *buf, int n, const int bitdepth_max) {
while (n--) while (n--)
*buf++ = rand() & bitdepth_max; *buf++ = rnd() & bitdepth_max;
} }
static void check_cdef_filter(const cdef_fn fn, const int w, const int h, static void check_cdef_filter(const cdef_fn fn, const int w, const int h,
...@@ -57,7 +57,7 @@ static void check_cdef_filter(const cdef_fn fn, const int w, const int h, ...@@ -57,7 +57,7 @@ static void check_cdef_filter(const cdef_fn fn, const int w, const int h,
memcpy(c_src, src, (10 * 16 + 8) * sizeof(pixel)); memcpy(c_src, src, (10 * 16 + 8) * sizeof(pixel));
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
...@@ -66,8 +66,8 @@ static void check_cdef_filter(const cdef_fn fn, const int w, const int h, ...@@ -66,8 +66,8 @@ static void check_cdef_filter(const cdef_fn fn, const int w, const int h,
init_tmp(top, 16 * 2 + 8, bitdepth_max); init_tmp(top, 16 * 2 + 8, bitdepth_max);
init_tmp((pixel *) left,8 * 2, bitdepth_max); init_tmp((pixel *) left,8 * 2, bitdepth_max);
const int lvl = 1 + (rand() % 62); const int lvl = 1 + (rnd() % 62);
const int damping = 3 + (rand() & 3) + bitdepth_min_8; const int damping = 3 + (rnd() & 3) + bitdepth_min_8;
const int pri_strength = (lvl >> 2) << bitdepth_min_8; const int pri_strength = (lvl >> 2) << bitdepth_min_8;
int sec_strength = lvl & 3; int sec_strength = lvl & 3;
sec_strength += sec_strength == 3; sec_strength += sec_strength == 3;
...@@ -100,7 +100,7 @@ static void check_cdef_direction(const cdef_dir_fn fn) { ...@@ -100,7 +100,7 @@ static void check_cdef_direction(const cdef_dir_fn fn) {
if (check_func(fn, "cdef_dir_%dbpc", BITDEPTH)) { if (check_func(fn, "cdef_dir_%dbpc", BITDEPTH)) {
unsigned c_var, a_var; unsigned c_var, a_var;
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
......
...@@ -143,6 +143,33 @@ typedef union { ...@@ -143,6 +143,33 @@ typedef union {
uint32_t i; uint32_t i;
} intfloat; } intfloat;
static uint32_t xs_state[4];
static void xor128_srand(unsigned int seed) {
xs_state[0] = seed;
xs_state[1] = ( seed & 0xffff0000) | (~seed & 0x0000ffff);
xs_state[2] = (~seed & 0xffff0000) | ( seed & 0x0000ffff);
xs_state[3] = ~seed;
}
// xor128 from Marsaglia, George (July 2003). "Xorshift RNGs".
// Journal of Statistical Software. 8 (14).
// doi:10.18637/jss.v008.i14.
int xor128_rand(void) {
const uint32_t x = xs_state[0];
const uint32_t t = x ^ (x << 11);
xs_state[0] = xs_state[1];
xs_state[1] = xs_state[2];
xs_state[2] = xs_state[3];
uint32_t w = xs_state[3];
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
xs_state[3] = w;
return w >> 1;
}
static int is_negative(const intfloat u) { static int is_negative(const intfloat u) {
return u.i >> 31; return u.i >> 31;
} }
...@@ -453,7 +480,7 @@ static void check_cpu_flag(const char *const name, unsigned flag) { ...@@ -453,7 +480,7 @@ static void check_cpu_flag(const char *const name, unsigned flag) {
for (int i = 0; tests[i].func; i++) { for (int i = 0; tests[i].func; i++) {
if (state.test_name && strcmp(tests[i].name, state.test_name)) if (state.test_name && strcmp(tests[i].name, state.test_name))
continue; continue;
srand(state.seed); xor128_srand(state.seed);
state.current_test_name = tests[i].name; state.current_test_name = tests[i].name;
tests[i].func(); tests[i].func();
} }
...@@ -567,7 +594,7 @@ void *checkasm_check_func(void *const func, const char *const name, ...) { ...@@ -567,7 +594,7 @@ void *checkasm_check_func(void *const func, const char *const name, ...) {
v->ok = 1; v->ok = 1;
v->cpu = state.cpu_flag; v->cpu = state.cpu_flag;
state.current_func_ver = v; state.current_func_ver = v;
srand(state.seed); xor128_srand(state.seed);
if (state.cpu_flag) if (state.cpu_flag)
state.num_checked++; state.num_checked++;
......
...@@ -50,6 +50,9 @@ ...@@ -50,6 +50,9 @@
#include "include/common/attributes.h" #include "include/common/attributes.h"
#include "include/common/intops.h" #include "include/common/intops.h"
int xor128_rand(void);
#define rnd xor128_rand
#define decl_check_bitfns(name) \ #define decl_check_bitfns(name) \
name##_8bpc(void); \ name##_8bpc(void); \
name##_16bpc(void) name##_16bpc(void)
......
...@@ -85,21 +85,21 @@ static void check_intra_pred(Dav1dIntraPredDSPContext *const c) { ...@@ -85,21 +85,21 @@ static void check_intra_pred(Dav1dIntraPredDSPContext *const c) {
int a = 0; int a = 0;
if (mode >= Z1_PRED && mode <= Z3_PRED) /* angle */ if (mode >= Z1_PRED && mode <= Z3_PRED) /* angle */
a = (90 * (mode - Z1_PRED) + z_angles[rand() % 27]) | a = (90 * (mode - Z1_PRED) + z_angles[rnd() % 27]) |
(rand() & 0x600); (rnd() & 0x600);
else if (mode == FILTER_PRED) /* filter_idx */ else if (mode == FILTER_PRED) /* filter_idx */
a = (rand() % 5) | (rand() & ~511); a = (rnd() % 5) | (rnd() & ~511);
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
for (int i = -h * 2; i <= w * 2; i++) for (int i = -h * 2; i <= w * 2; i++)
topleft[i] = rand() & bitdepth_max; topleft[i] = rnd() & bitdepth_max;
const int maxw = 1 + (rand() % 128), maxh = 1 + (rand() % 128); const int maxw = 1 + (rnd() % 128), maxh = 1 + (rnd() % 128);
call_ref(c_dst, stride, topleft, w, h, a, maxw, maxh call_ref(c_dst, stride, topleft, w, h, a, maxw, maxh
HIGHBD_TAIL_SUFFIX); HIGHBD_TAIL_SUFFIX);
call_new(a_dst, stride, topleft, w, h, a, maxw, maxh call_new(a_dst, stride, topleft, w, h, a, maxw, maxh
...@@ -134,13 +134,13 @@ static void check_cfl_ac(Dav1dIntraPredDSPContext *const c) { ...@@ -134,13 +134,13 @@ static void check_cfl_ac(Dav1dIntraPredDSPContext *const c) {
for (int w_pad = (w >> 2) - 1; w_pad >= 0; w_pad--) { for (int w_pad = (w >> 2) - 1; w_pad >= 0; w_pad--) {
for (int h_pad = (h >> 2) - 1; h_pad >= 0; h_pad--) { for (int h_pad = (h >> 2) - 1; h_pad >= 0; h_pad--) {
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
for (int y = 0; y < (h << ss_ver); y++) for (int y = 0; y < (h << ss_ver); y++)
for (int x = 0; x < (w << ss_hor); x++) for (int x = 0; x < (w << ss_hor); x++)
luma[y * 32 + x] = rand() & bitdepth_max; luma[y * 32 + x] = rnd() & bitdepth_max;
call_ref(c_dst, luma, stride, w_pad, h_pad, w, h); call_ref(c_dst, luma, stride, w_pad, h_pad, w, h);
call_new(a_dst, luma, stride, w_pad, h_pad, w, h); call_new(a_dst, luma, stride, w_pad, h_pad, w, h);
...@@ -175,21 +175,21 @@ static void check_cfl_pred(Dav1dIntraPredDSPContext *const c) { ...@@ -175,21 +175,21 @@ static void check_cfl_pred(Dav1dIntraPredDSPContext *const c) {
for (int h = imax(w / 4, 4); h <= imin(w * 4, 32); h <<= 1) for (int h = imax(w / 4, 4); h <= imin(w * 4, 32); h <<= 1)
{ {
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
const ptrdiff_t stride = w * sizeof(pixel); const ptrdiff_t stride = w * sizeof(pixel);
int alpha = ((rand() & 15) + 1) * (1 - (rand() & 2)); int alpha = ((rnd() & 15) + 1) * (1 - (rnd() & 2));
for (int i = -h * 2; i <= w * 2; i++) for (int i = -h * 2; i <= w * 2; i++)
topleft[i] = rand() & bitdepth_max; topleft[i] = rnd() & bitdepth_max;
int luma_avg = w * h >> 1; int luma_avg = w * h >> 1;
for (int i = 0; i < w * h; i++) for (int i = 0; i < w * h; i++)
luma_avg += ac[i] = rand() & (bitdepth_max << 3); luma_avg += ac[i] = rnd() & (bitdepth_max << 3);
luma_avg /= w * h; luma_avg /= w * h;
for (int i = 0; i < w * h; i++) for (int i = 0; i < w * h; i++)
ac[i] -= luma_avg; ac[i] -= luma_avg;
...@@ -222,17 +222,17 @@ static void check_pal_pred(Dav1dIntraPredDSPContext *const c) { ...@@ -222,17 +222,17 @@ static void check_pal_pred(Dav1dIntraPredDSPContext *const c) {
for (int h = imax(w / 4, 4); h <= imin(w * 4, 64); h <<= 1) for (int h = imax(w / 4, 4); h <= imin(w * 4, 64); h <<= 1)
{ {
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
const ptrdiff_t stride = w * sizeof(pixel); const ptrdiff_t stride = w * sizeof(pixel);
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
pal[i] = rand() & bitdepth_max; pal[i] = rnd() & bitdepth_max;
for (int i = 0; i < w * h; i++) for (int i = 0; i < w * h; i++)
idx[i] = rand() & 7; idx[i] = rnd() & 7;
call_ref(c_dst, stride, pal, idx, w, h); call_ref(c_dst, stride, pal, idx, w, h);
call_new(a_dst, stride, pal, idx, w, h); call_new(a_dst, stride, pal, idx, w, h);
......
...@@ -155,7 +155,7 @@ static int copy_subcoefs(coef *coeff, ...@@ -155,7 +155,7 @@ static int copy_subcoefs(coef *coeff,
} }
if (eob) if (eob)
eob += rand() % (n - eob - 1); eob += rnd() % (n - eob - 1);
for (n = eob + 1; n < sw * sh; n++) for (n = eob + 1; n < sw * sh; n++)
coeff[scan[n]] = 0; coeff[scan[n]] = 0;
return eob; return eob;
...@@ -173,7 +173,7 @@ static int ftx(coef *const buf, const enum RectTxfmSize tx, ...@@ -173,7 +173,7 @@ static int ftx(coef *const buf, const enum RectTxfmSize tx,
double in[64], temp_out[64]; double in[64], temp_out[64];
for (int i = 0; i < w; i++) for (int i = 0; i < w; i++)
in[i] = (rand() & (2 * bitdepth_max + 1)) - bitdepth_max; in[i] = (rnd() & (2 * bitdepth_max + 1)) - bitdepth_max;
switch (itx_1d_types[txtp][0]) { switch (itx_1d_types[txtp][0]) {
case DCT: case DCT:
...@@ -258,14 +258,14 @@ void bitfn(checkasm_check_itx)(void) { ...@@ -258,14 +258,14 @@ void bitfn(checkasm_check_itx)(void) {
BITDEPTH)) BITDEPTH))
{ {
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
const int eob = ftx(coeff[0], tx, txtp, w, h, subsh, bitdepth_max); const int eob = ftx(coeff[0], tx, txtp, w, h, subsh, bitdepth_max);
for (int j = 0; j < w * h; j++) for (int j = 0; j < w * h; j++)
c_dst[j] = a_dst[j] = rand() & bitdepth_max; c_dst[j] = a_dst[j] = rnd() & bitdepth_max;
memcpy(coeff[1], coeff[0], sw * sh * sizeof(**coeff)); memcpy(coeff[1], coeff[0], sw * sh * sizeof(**coeff));
memcpy(coeff[2], coeff[0], sw * sh * sizeof(**coeff)); memcpy(coeff[2], coeff[0], sw * sh * sizeof(**coeff));
......
...@@ -41,51 +41,51 @@ static void init_lpf_border(pixel *const dst, const ptrdiff_t stride, ...@@ -41,51 +41,51 @@ static void init_lpf_border(pixel *const dst, const ptrdiff_t stride,
I <<= bitdepth_min_8; I <<= bitdepth_min_8;
H <<= bitdepth_min_8; H <<= bitdepth_min_8;
const int filter_type = rand() % 4; const int filter_type = rnd() % 4;
const int edge_diff = rand() % ((E + 2) * 4) - 2 * (E + 2); const int edge_diff = rnd() % ((E + 2) * 4) - 2 * (E + 2);
switch (filter_type) { switch (filter_type) {
case 0: // random, unfiltered case 0: // random, unfiltered
for (int i = -8; i < 8; i++) for (int i = -8; i < 8; i++)
dst[i * stride] = rand() & bitdepth_max; dst[i * stride] = rnd() & bitdepth_max;
break; break;
case 1: // long flat case 1: // long flat
dst[-8 * stride] = rand() & bitdepth_max; dst[-8 * stride] = rnd() & bitdepth_max;
dst[+7 * stride] = rand() & bitdepth_max; dst[+7 * stride] = rnd() & bitdepth_max;
dst[+0 * stride] = rand() & bitdepth_max; dst[+0 * stride] = rnd() & bitdepth_max;
dst[-1 * stride] = iclip_pixel(dst[+0 * stride] + edge_diff); dst[-1 * stride] = iclip_pixel(dst[+0 * stride] + edge_diff);
for (int i = 1; i < 7; i++) { for (int i = 1; i < 7; i++) {
dst[-(1 + i) * stride] = iclip_pixel(dst[-1 * stride] + dst[-(1 + i) * stride] = iclip_pixel(dst[-1 * stride] +
rand() % (2 * (F + 1)) - (F + 1)); rnd() % (2 * (F + 1)) - (F + 1));
dst[+(0 + i) * stride] = iclip_pixel(dst[+0 * stride] + dst[+(0 + i) * stride] = iclip_pixel(dst[+0 * stride] +
rand() % (2 * (F + 1)) - (F + 1)); rnd() % (2 * (F + 1)) - (F + 1));
} }
break; break;
case 2: // short flat case 2: // short flat
for (int i = 4; i < 8; i++) { for (int i = 4; i < 8; i++) {
dst[-(1 + i) * stride] = rand() & bitdepth_max; dst[-(1 + i) * stride] = rnd() & bitdepth_max;
dst[+(0 + i) * stride] = rand() & bitdepth_max; dst[+(0 + i) * stride] = rnd() & bitdepth_max;
} }
dst[+0 * stride] = rand() & bitdepth_max; dst[+0 * stride] = rnd() & bitdepth_max;
dst[-1 * stride] = iclip_pixel(dst[+0 * stride] + edge_diff); dst[-1 * stride] = iclip_pixel(dst[+0 * stride] + edge_diff);
for (int i = 1; i < 4; i++) { for (int i = 1; i < 4; i++) {
dst[-(1 + i) * stride] = iclip_pixel(dst[-1 * stride] + dst[-(1 + i) * stride] = iclip_pixel(dst[-1 * stride] +
rand() % (2 * (F + 1)) - (F + 1)); rnd() % (2 * (F + 1)) - (F + 1));
dst[+(0 + i) * stride] = iclip_pixel(dst[+0 * stride] + dst[+(0 + i) * stride] = iclip_pixel(dst[+0 * stride] +
rand() % (2 * (F + 1)) - (F + 1)); rnd() % (2 * (F + 1)) - (F + 1));
} }
break; break;
case 3: // normal or hev case 3: // normal or hev
for (int i = 4; i < 8; i++) { for (int i = 4; i < 8; i++) {
dst[-(1 + i) * stride] = rand() & bitdepth_max; dst[-(1 + i) * stride] = rnd() & bitdepth_max;
dst[+(0 + i) * stride] = rand() & bitdepth_max; dst[+(0 + i) * stride] = rnd() & bitdepth_max;
} }
dst[+0 * stride] = rand() & bitdepth_max; dst[+0 * stride] = rnd() & bitdepth_max;
dst[-1 * stride] = iclip_pixel(dst[+0 * stride] + edge_diff); dst[-1 * stride] = iclip_pixel(dst[+0 * stride] + edge_diff);
for (int i = 1; i < 4; i++) { for (int i = 1; i < 4; i++) {
dst[-(1 + i) * stride] = iclip_pixel(dst[-(0 + i) * stride] + dst[-(1 + i) * stride] = iclip_pixel(dst[-(0 + i) * stride] +
rand() % (2 * (I + 1)) - (I + 1)); rnd() % (2 * (I + 1)) - (I + 1));
dst[+(0 + i) * stride] = iclip_pixel(dst[+(i - 1) * stride] + dst[+(0 + i) * stride] = iclip_pixel(dst[+(i - 1) * stride] +
rand() % (2 * (I + 1)) - (I + 1)); rnd() % (2 * (I + 1)) - (I + 1));
} }
break; break;
} }
...@@ -117,7 +117,7 @@ static void check_lpf_sb(loopfilter_sb_fn fn, const char *const name, ...@@ -117,7 +117,7 @@ static void check_lpf_sb(loopfilter_sb_fn fn, const char *const name,
} }
Av1FilterLUT lut; Av1FilterLUT lut;
const int sharp = rand() & 7; const int sharp = rnd() & 7;
for (int level = 0; level < 64; level++) { for (int level = 0; level < 64; level++) {
int limit = level; int limit = level;
...@@ -142,18 +142,18 @@ static void check_lpf_sb(loopfilter_sb_fn fn, const char *const name, ...@@ -142,18 +142,18 @@ static void check_lpf_sb(loopfilter_sb_fn fn, const char *const name,
uint8_t l[32 * 2][4]; uint8_t l[32 * 2][4];
for (int j = 0; j < n_blks; j++) { for (int j = 0; j < n_blks; j++) {
const int idx = rand() % (i + 2); const int idx = rnd() % (i + 2);
if (idx) vmask[idx - 1] |= 1U << j; if (idx) vmask[idx - 1] |= 1U << j;
if (dir) { if (dir) {
l[j][lf_idx] = rand() & 63; l[j][lf_idx] = rnd() & 63;
l[j + 32][lf_idx] = rand() & 63; l[j + 32][lf_idx] = rnd() & 63;
} else { } else {
l[j * 2][lf_idx] = rand() & 63; l[j * 2][lf_idx] = rnd() & 63;
l[j * 2 + 1][lf_idx] = rand() & 63; l[j * 2 + 1][lf_idx] = rnd() & 63;
} }
} }
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
......
...@@ -38,7 +38,7 @@ static void init_tmp(pixel *buf, const ptrdiff_t stride, ...@@ -38,7 +38,7 @@ static void init_tmp(pixel *buf, const ptrdiff_t stride,
{ {
for (int y = 0; y < h; y++) { for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) for (int x = 0; x < w; x++)
buf[x] = rand() & bitdepth_max; buf[x] = rnd() & bitdepth_max;
buf += PXSTRIDE(stride); buf += PXSTRIDE(stride);
} }
} }
...@@ -74,12 +74,12 @@ static void check_wiener(Dav1dLoopRestorationDSPContext *const c) { ...@@ -74,12 +74,12 @@ static void check_wiener(Dav1dLoopRestorationDSPContext *const c) {
{ {
int16_t filter[2][3], filter_v[7], filter_h[7]; int16_t filter[2][3], filter_v[7], filter_h[7];
filter[0][0] = pl ? 0 : (rand() & 15) - 5; filter[0][0] = pl ? 0 : (rnd() & 15) - 5;
filter[0][1] = (rand() & 31) - 23; filter[0][1] = (rnd() & 31) - 23;
filter[0][2] = (rand() & 63) - 17; filter[0][2] = (rnd() & 63) - 17;
filter[1][0] = pl ? 0 : (rand() & 15) - 5; filter[1][0] = pl ? 0 : (rnd() & 15) - 5;
filter[1][1] = (rand() & 31) - 23; filter[1][1] = (rnd() & 31) - 23;
filter[1][2] = (rand() & 63) - 17; filter[1][2] = (rnd() & 63) - 17;
filter_h[0] = filter_h[6] = filter[0][0]; filter_h[0] = filter_h[6] = filter[0][0];
filter_h[1] = filter_h[5] = filter[0][1]; filter_h[1] = filter_h[5] = filter[0][1];
...@@ -91,10 +91,10 @@ static void check_wiener(Dav1dLoopRestorationDSPContext *const c) { ...@@ -91,10 +91,10 @@ static void check_wiener(Dav1dLoopRestorationDSPContext *const c) {
filter_v[2] = filter_v[4] = filter[1][2]; filter_v[2] = filter_v[4] = filter[1][2];
filter_v[3] = -((filter_v[0] + filter_v[1] + filter_v[2]) * 2); filter_v[3] = -((filter_v[0] + filter_v[1] + filter_v[2]) * 2);
const int base_w = 1 + (rand() % 384); const int base_w = 1 + (rnd() % 384);
const int base_h = 1 + (rand() & 63); const int base_h = 1 + (rnd() & 63);
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
...@@ -145,14 +145,14 @@ static void check_sgr(Dav1dLoopRestorationDSPContext *const c) { ...@@ -145,14 +145,14 @@ static void check_sgr(Dav1dLoopRestorationDSPContext *const c) {
{ {
int16_t sgr_wt[2]; int16_t sgr_wt[2];
sgr_wt[0] = dav1d_sgr_params[sgr_idx][0] ? (rand() & 127) - 96 : 0; sgr_wt[0] = dav1d_sgr_params[sgr_idx][0] ? (rnd() & 127) - 96 : 0;
sgr_wt[1] = dav1d_sgr_params[sgr_idx][1] ? (rand() & 127) - 32 : sgr_wt[1] = dav1d_sgr_params[sgr_idx][1] ? (rnd() & 127) - 32 :
iclip(128 - sgr_wt[0], -32, 95); iclip(128 - sgr_wt[0], -32, 95);
const int base_w = 1 + (rand() % 384); const int base_w = 1 + (rnd() % 384);
const int base_h = 1 + (rand() & 63); const int base_h = 1 + (rnd() & 63);
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
......
...@@ -60,16 +60,16 @@ static void check_mc(Dav1dMCDSPContext *const c) { ...@@ -60,16 +60,16 @@ static void check_mc(Dav1dMCDSPContext *const c) {
const int min = w <= 32 ? 2 : w / 4; const int min = w <= 32 ? 2 : w / 4;
const int max = imax(imin(w * 4, 128), 32); const int max = imax(imin(w * 4, 128), 32);
for (int h = min; h <= max; h <<= 1) { for (int h = min; h <= max; h <<= 1) {
const int mx = (mxy & 1) ? rand() % 15 + 1 : 0; const int mx = (mxy & 1) ? rnd() % 15 + 1 : 0;
const int my = (mxy & 2) ? rand() % 15 + 1 : 0; const int my = (mxy & 2) ? rnd() % 15 + 1 : 0;
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
for (int i = 0; i < 135 * 135; i++) for (int i = 0; i < 135 * 135; i++)
src_buf[i] = rand() & bitdepth_max; src_buf[i] = rnd() & bitdepth_max;
call_ref(c_dst, w, src, w, w, h, mx, my HIGHBD_TAIL_SUFFIX); call_ref(c_dst, w, src, w, w, h, mx, my HIGHBD_TAIL_SUFFIX);
call_new(a_dst, w, src, w, w, h, mx, my HIGHBD_TAIL_SUFFIX); call_new(a_dst, w, src, w, w, h, mx, my HIGHBD_TAIL_SUFFIX);
...@@ -100,16 +100,16 @@ static void check_mct(Dav1dMCDSPContext *const c) { ...@@ -100,16 +100,16 @@ static void check_mct(Dav1dMCDSPContext *const c) {
filter_names[filter], w, mxy_names[mxy], BITDEPTH)) filter_names[filter], w, mxy_names[mxy], BITDEPTH))
for (int h = imax(w / 4, 4); h <= imin(w * 4, 128); h <<= 1) for (int h = imax(w / 4, 4); h <= imin(w * 4, 128); h <<= 1)
{ {
const int mx = (mxy & 1) ? rand() % 15 + 1 : 0; const int mx = (mxy & 1) ? rnd() % 15 + 1 : 0;
const int my = (mxy & 2) ? rand() % 15 + 1 : 0; const int my = (mxy & 2) ? rnd() % 15 + 1 : 0;
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
for (int i = 0; i < 135 * 135; i++) for (int i = 0; i < 135 * 135; i++)
src_buf[i] = rand() & bitdepth_max; src_buf[i] = rnd() & bitdepth_max;
call_ref(c_tmp, src, w, w, h, mx, my HIGHBD_TAIL_SUFFIX); call_ref(c_tmp, src, w, w, h, mx, my HIGHBD_TAIL_SUFFIX);
call_new(a_tmp, src, w, w, h, mx, my HIGHBD_TAIL_SUFFIX); call_new(a_tmp, src, w, w, h, mx, my HIGHBD_TAIL_SUFFIX);
...@@ -128,10 +128,10 @@ static void init_tmp(Dav1dMCDSPContext *const c, pixel *const buf, ...@@ -128,10 +128,10 @@ static void init_tmp(Dav1dMCDSPContext *const c, pixel *const buf,
{ {
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
for (int j = 0; j < 135 * 135; j++) for (int j = 0; j < 135 * 135; j++)
buf[j] = rand() & bitdepth_max; buf[j] = rnd() & bitdepth_max;
c->mct[rand() % N_2D_FILTERS](tmp[i], buf + 135 * 3 + 3, c->mct[rnd() % N_2D_FILTERS](tmp[i], buf + 135 * 3 + 3,
128 * sizeof(pixel), 128, 128, 128 * sizeof(pixel), 128, 128,
rand() & 15, rand() & 15 rnd() & 15, rnd() & 15
HIGHBD_TAIL_SUFFIX); HIGHBD_TAIL_SUFFIX);
} }
} }
...@@ -149,7 +149,7 @@ static void check_avg(Dav1dMCDSPContext *const c) { ...@@ -149,7 +149,7 @@ static void check_avg(Dav1dMCDSPContext *const c) {
for (int h = imax(w / 4, 4); h <= imin(w * 4, 128); h <<= 1) for (int h = imax(w / 4, 4); h <= imin(w * 4, 128); h <<= 1)
{ {
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
...@@ -176,9 +176,9 @@ static void check_w_avg(Dav1dMCDSPContext *const c) { ...@@ -176,9 +176,9 @@ static void check_w_avg(Dav1dMCDSPContext *const c) {
if (check_func(c->w_avg, "w_avg_w%d_%dbpc", w, BITDEPTH)) if (check_func(c->w_avg, "w_avg_w%d_%dbpc", w, BITDEPTH))
for (int h = imax(w / 4, 4); h <= imin(w * 4, 128); h <<= 1) for (int h = imax(w / 4, 4); h <= imin(w * 4, 128); h <<= 1)
{ {
int weight = rand() % 15 + 1; int weight = rnd() % 15 + 1;
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
...@@ -201,7 +201,7 @@ static void check_mask(Dav1dMCDSPContext *const c) { ...@@ -201,7 +201,7 @@ static void check_mask(Dav1dMCDSPContext *const c) {
ALIGN_STK_32(uint8_t, mask, 128 * 128,); ALIGN_STK_32(uint8_t, mask, 128 * 128,);
for (int i = 0; i < 128 * 128; i++) for (int i = 0; i < 128 * 128; i++)
mask[i] = rand() % 65; mask[i] = rnd() % 65;
declare_func(void, pixel *dst, ptrdiff_t dst_stride, const int16_t *tmp1, declare_func(void, pixel *dst, ptrdiff_t dst_stride, const int16_t *tmp1,
const int16_t *tmp2, int w, int h, const uint8_t *mask const int16_t *tmp2, int w, int h, const uint8_t *mask
...@@ -212,7 +212,7 @@ static void check_mask(Dav1dMCDSPContext *const c) { ...@@ -212,7 +212,7 @@ static void check_mask(Dav1dMCDSPContext *const c) {
for (int h = imax(w / 4, 4); h <= imin(w * 4, 128); h <<= 1) for (int h = imax(w / 4, 4); h <= imin(w * 4, 128); h <<= 1)
{ {
#if BITDEPTH == 16 #if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff; const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else #else
const int bitdepth_max = 0xff; const int bitdepth_max = 0xff;
#endif #endif
...@@ -246,9 +246,9 @@ static void check_w_mask(Dav1dMCDSPContext *const c) { ...@@ -246,9 +246,9 @@ static void check_w_mask(Dav1dMCDSPContext *const c) {
BITDEPTH)) BITDEPTH))
for (int h = imax(w / 4, 4); h <= imin(w * 4, 128); h <<= 1)