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
......@@ -34,7 +34,7 @@
static void init_tmp(pixel *buf, int n, const int bitdepth_max) {
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,
......@@ -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));
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
......@@ -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((pixel *) left,8 * 2, bitdepth_max);
const int lvl = 1 + (rand() % 62);
const int damping = 3 + (rand() & 3) + bitdepth_min_8;
const int lvl = 1 + (rnd() % 62);
const int damping = 3 + (rnd() & 3) + bitdepth_min_8;
const int pri_strength = (lvl >> 2) << bitdepth_min_8;
int sec_strength = lvl & 3;
sec_strength += sec_strength == 3;
......@@ -100,7 +100,7 @@ static void check_cdef_direction(const cdef_dir_fn fn) {
if (check_func(fn, "cdef_dir_%dbpc", BITDEPTH)) {
unsigned c_var, a_var;
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
......
......@@ -143,6 +143,33 @@ typedef union {
uint32_t i;
} 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) {
return u.i >> 31;
}
......@@ -453,7 +480,7 @@ static void check_cpu_flag(const char *const name, unsigned flag) {
for (int i = 0; tests[i].func; i++) {
if (state.test_name && strcmp(tests[i].name, state.test_name))
continue;
srand(state.seed);
xor128_srand(state.seed);
state.current_test_name = tests[i].name;
tests[i].func();
}
......@@ -567,7 +594,7 @@ void *checkasm_check_func(void *const func, const char *const name, ...) {
v->ok = 1;
v->cpu = state.cpu_flag;
state.current_func_ver = v;
srand(state.seed);
xor128_srand(state.seed);
if (state.cpu_flag)
state.num_checked++;
......
......@@ -50,6 +50,9 @@
#include "include/common/attributes.h"
#include "include/common/intops.h"
int xor128_rand(void);
#define rnd xor128_rand
#define decl_check_bitfns(name) \
name##_8bpc(void); \
name##_16bpc(void)
......
......@@ -85,21 +85,21 @@ static void check_intra_pred(Dav1dIntraPredDSPContext *const c) {
int a = 0;
if (mode >= Z1_PRED && mode <= Z3_PRED) /* angle */
a = (90 * (mode - Z1_PRED) + z_angles[rand() % 27]) |
(rand() & 0x600);
a = (90 * (mode - Z1_PRED) + z_angles[rnd() % 27]) |
(rnd() & 0x600);
else if (mode == FILTER_PRED) /* filter_idx */
a = (rand() % 5) | (rand() & ~511);
a = (rnd() % 5) | (rnd() & ~511);
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
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
HIGHBD_TAIL_SUFFIX);
call_new(a_dst, stride, topleft, w, h, a, maxw, maxh
......@@ -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 h_pad = (h >> 2) - 1; h_pad >= 0; h_pad--) {
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
for (int y = 0; y < (h << ss_ver); y++)
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_new(a_dst, luma, stride, w_pad, h_pad, w, h);
......@@ -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)
{
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
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++)
topleft[i] = rand() & bitdepth_max;
topleft[i] = rnd() & bitdepth_max;
int luma_avg = w * h >> 1;
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;
for (int i = 0; i < w * h; i++)
ac[i] -= luma_avg;
......@@ -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)
{
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
const ptrdiff_t stride = w * sizeof(pixel);
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++)
idx[i] = rand() & 7;
idx[i] = rnd() & 7;
call_ref(c_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,
}
if (eob)
eob += rand() % (n - eob - 1);
eob += rnd() % (n - eob - 1);
for (n = eob + 1; n < sw * sh; n++)
coeff[scan[n]] = 0;
return eob;
......@@ -173,7 +173,7 @@ static int ftx(coef *const buf, const enum RectTxfmSize tx,
double in[64], temp_out[64];
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]) {
case DCT:
......@@ -258,14 +258,14 @@ void bitfn(checkasm_check_itx)(void) {
BITDEPTH))
{
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
const int eob = ftx(coeff[0], tx, txtp, w, h, subsh, bitdepth_max);
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[2], coeff[0], sw * sh * sizeof(**coeff));
......
......@@ -41,51 +41,51 @@ static void init_lpf_border(pixel *const dst, const ptrdiff_t stride,
I <<= bitdepth_min_8;
H <<= bitdepth_min_8;
const int filter_type = rand() % 4;
const int edge_diff = rand() % ((E + 2) * 4) - 2 * (E + 2);
const int filter_type = rnd() % 4;
const int edge_diff = rnd() % ((E + 2) * 4) - 2 * (E + 2);
switch (filter_type) {
case 0: // random, unfiltered
for (int i = -8; i < 8; i++)
dst[i * stride] = rand() & bitdepth_max;
dst[i * stride] = rnd() & bitdepth_max;
break;
case 1: // long flat
dst[-8 * stride] = rand() & bitdepth_max;
dst[+7 * stride] = rand() & bitdepth_max;
dst[+0 * stride] = rand() & bitdepth_max;
dst[-8 * stride] = rnd() & bitdepth_max;
dst[+7 * stride] = rnd() & bitdepth_max;
dst[+0 * stride] = rnd() & bitdepth_max;
dst[-1 * stride] = iclip_pixel(dst[+0 * stride] + edge_diff);
for (int i = 1; i < 7; i++) {
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] +
rand() % (2 * (F + 1)) - (F + 1));
rnd() % (2 * (F + 1)) - (F + 1));
}
break;
case 2: // short flat
for (int i = 4; i < 8; i++) {
dst[-(1 + i) * stride] = rand() & bitdepth_max;
dst[+(0 + i) * stride] = rand() & bitdepth_max;
dst[-(1 + i) * stride] = rnd() & 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);
for (int i = 1; i < 4; i++) {
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] +
rand() % (2 * (F + 1)) - (F + 1));
rnd() % (2 * (F + 1)) - (F + 1));
}
break;
case 3: // normal or hev
for (int i = 4; i < 8; i++) {
dst[-(1 + i) * stride] = rand() & bitdepth_max;
dst[+(0 + i) * stride] = rand() & bitdepth_max;
dst[-(1 + i) * stride] = rnd() & 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);
for (int i = 1; i < 4; i++) {
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] +
rand() % (2 * (I + 1)) - (I + 1));
rnd() % (2 * (I + 1)) - (I + 1));
}
break;
}
......@@ -117,7 +117,7 @@ static void check_lpf_sb(loopfilter_sb_fn fn, const char *const name,
}
Av1FilterLUT lut;
const int sharp = rand() & 7;
const int sharp = rnd() & 7;
for (int level = 0; level < 64; level++) {
int limit = level;
......@@ -142,18 +142,18 @@ static void check_lpf_sb(loopfilter_sb_fn fn, const char *const name,
uint8_t l[32 * 2][4];
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 (dir) {
l[j][lf_idx] = rand() & 63;
l[j + 32][lf_idx] = rand() & 63;
l[j][lf_idx] = rnd() & 63;
l[j + 32][lf_idx] = rnd() & 63;
} else {
l[j * 2][lf_idx] = rand() & 63;
l[j * 2 + 1][lf_idx] = rand() & 63;
l[j * 2][lf_idx] = rnd() & 63;
l[j * 2 + 1][lf_idx] = rnd() & 63;
}
}
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
......
......@@ -38,7 +38,7 @@ static void init_tmp(pixel *buf, const ptrdiff_t stride,
{
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++)
buf[x] = rand() & bitdepth_max;
buf[x] = rnd() & bitdepth_max;
buf += PXSTRIDE(stride);
}
}
......@@ -74,12 +74,12 @@ static void check_wiener(Dav1dLoopRestorationDSPContext *const c) {
{
int16_t filter[2][3], filter_v[7], filter_h[7];
filter[0][0] = pl ? 0 : (rand() & 15) - 5;
filter[0][1] = (rand() & 31) - 23;
filter[0][2] = (rand() & 63) - 17;
filter[1][0] = pl ? 0 : (rand() & 15) - 5;
filter[1][1] = (rand() & 31) - 23;
filter[1][2] = (rand() & 63) - 17;
filter[0][0] = pl ? 0 : (rnd() & 15) - 5;
filter[0][1] = (rnd() & 31) - 23;
filter[0][2] = (rnd() & 63) - 17;
filter[1][0] = pl ? 0 : (rnd() & 15) - 5;
filter[1][1] = (rnd() & 31) - 23;
filter[1][2] = (rnd() & 63) - 17;
filter_h[0] = filter_h[6] = filter[0][0];
filter_h[1] = filter_h[5] = filter[0][1];
......@@ -91,10 +91,10 @@ static void check_wiener(Dav1dLoopRestorationDSPContext *const c) {
filter_v[2] = filter_v[4] = filter[1][2];
filter_v[3] = -((filter_v[0] + filter_v[1] + filter_v[2]) * 2);
const int base_w = 1 + (rand() % 384);
const int base_h = 1 + (rand() & 63);
const int base_w = 1 + (rnd() % 384);
const int base_h = 1 + (rnd() & 63);
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
......@@ -145,14 +145,14 @@ static void check_sgr(Dav1dLoopRestorationDSPContext *const c) {
{
int16_t sgr_wt[2];
sgr_wt[0] = dav1d_sgr_params[sgr_idx][0] ? (rand() & 127) - 96 : 0;
sgr_wt[1] = dav1d_sgr_params[sgr_idx][1] ? (rand() & 127) - 32 :
sgr_wt[0] = dav1d_sgr_params[sgr_idx][0] ? (rnd() & 127) - 96 : 0;
sgr_wt[1] = dav1d_sgr_params[sgr_idx][1] ? (rnd() & 127) - 32 :
iclip(128 - sgr_wt[0], -32, 95);
const int base_w = 1 + (rand() % 384);
const int base_h = 1 + (rand() & 63);
const int base_w = 1 + (rnd() % 384);
const int base_h = 1 + (rnd() & 63);
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
......
......@@ -60,16 +60,16 @@ static void check_mc(Dav1dMCDSPContext *const c) {
const int min = w <= 32 ? 2 : w / 4;
const int max = imax(imin(w * 4, 128), 32);
for (int h = min; h <= max; h <<= 1) {
const int mx = (mxy & 1) ? rand() % 15 + 1 : 0;
const int my = (mxy & 2) ? rand() % 15 + 1 : 0;
const int mx = (mxy & 1) ? rnd() % 15 + 1 : 0;
const int my = (mxy & 2) ? rnd() % 15 + 1 : 0;
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
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_new(a_dst, w, src, w, w, h, mx, my HIGHBD_TAIL_SUFFIX);
......@@ -100,16 +100,16 @@ static void check_mct(Dav1dMCDSPContext *const c) {
filter_names[filter], w, mxy_names[mxy], BITDEPTH))
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 my = (mxy & 2) ? rand() % 15 + 1 : 0;
const int mx = (mxy & 1) ? rnd() % 15 + 1 : 0;
const int my = (mxy & 2) ? rnd() % 15 + 1 : 0;
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
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_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,
{
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 135 * 135; j++)
buf[j] = rand() & bitdepth_max;
c->mct[rand() % N_2D_FILTERS](tmp[i], buf + 135 * 3 + 3,
buf[j] = rnd() & bitdepth_max;
c->mct[rnd() % N_2D_FILTERS](tmp[i], buf + 135 * 3 + 3,
128 * sizeof(pixel), 128, 128,
rand() & 15, rand() & 15
rnd() & 15, rnd() & 15
HIGHBD_TAIL_SUFFIX);
}
}
......@@ -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)
{
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
......@@ -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))
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
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
......@@ -201,7 +201,7 @@ static void check_mask(Dav1dMCDSPContext *const c) {
ALIGN_STK_32(uint8_t, mask, 128 * 128,);
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,
const int16_t *tmp2, int w, int h, const uint8_t *mask
......@@ -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)
{
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
......@@ -246,9 +246,9 @@ static void check_w_mask(Dav1dMCDSPContext *const c) {
BITDEPTH))
for (int h = imax(w / 4, 4); h <= imin(w * 4, 128); h <<= 1)
{
int sign = rand() & 1;
int sign = rnd() & 1;
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
......@@ -284,16 +284,16 @@ static void check_blend(Dav1dMCDSPContext *const c) {
if (check_func(c->blend, "blend_w%d_%dbpc", w, BITDEPTH))
for (int h = imax(w / 2, 4); h <= imin(w * 2, 32); h <<= 1) {
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
for (int i = 0; i < 32 * 32; i++) {
tmp[i] = rand() & bitdepth_max;
mask[i] = rand() % 65;
tmp[i] = rnd() & bitdepth_max;
mask[i] = rnd() % 65;
}
for (int i = 0; i < w * h; i++)
c_dst[i] = a_dst[i] = rand() & bitdepth_max;
c_dst[i] = a_dst[i] = rnd() & bitdepth_max;
call_ref(c_dst, dst_stride, tmp, w, h, mask);
call_new(a_dst, dst_stride, tmp, w, h, mask);
......@@ -319,15 +319,15 @@ static void check_blend_v(Dav1dMCDSPContext *const c) {
if (check_func(c->blend_v, "blend_v_w%d_%dbpc", w, BITDEPTH))
for (int h = 2; h <= (w == 2 ? 64 : 128); h <<= 1) {
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
for (int i = 0; i < w * h; i++)
c_dst[i] = a_dst[i] = rand() & bitdepth_max;
c_dst[i] = a_dst[i] = rnd() & bitdepth_max;
for (int i = 0; i < 32 * 128; i++)
tmp[i] = rand() & bitdepth_max;
tmp[i] = rnd() & bitdepth_max;
call_ref(c_dst, dst_stride, tmp, w, h);
call_new(a_dst, dst_stride, tmp, w, h);
......@@ -353,14 +353,14 @@ static void check_blend_h(Dav1dMCDSPContext *const c) {
if (check_func(c->blend_h, "blend_h_w%d_%dbpc", w, BITDEPTH))
for (int h = (w == 128 ? 4 : 2); h <= 32; h <<= 1) {
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
for (int i = 0; i < w * h; i++)
c_dst[i] = a_dst[i] = rand() & bitdepth_max;
c_dst[i] = a_dst[i] = rnd() & bitdepth_max;
for (int i = 0; i < 128 * 32; i++)
tmp[i] = rand() & bitdepth_max;
tmp[i] = rnd() & bitdepth_max;
call_ref(c_dst, dst_stride, tmp, w, h);
call_new(a_dst, dst_stride, tmp, w, h);
......@@ -387,19 +387,19 @@ static void check_warp8x8(Dav1dMCDSPContext *const c) {
HIGHBD_DECL_SUFFIX);
if (check_func(c->warp8x8, "warp_8x8_%dbpc", BITDEPTH)) {
const int mx = (rand() & 0x1fff) - 0x800;
const int my = (rand() & 0x1fff) - 0x800;
const int mx = (rnd() & 0x1fff) - 0x800;
const int my = (rnd() & 0x1fff) - 0x800;
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
for (int i = 0; i < 4; i++)
abcd[i] = (rand() & 0x1fff) - 0x800;
abcd[i] = (rnd() & 0x1fff) - 0x800;
for (int i = 0; i < 15 * 15; i++)
src_buf[i] = rand() & bitdepth_max;
src_buf[i] = rnd() & bitdepth_max;
call_ref(c_dst, dst_stride, src, src_stride, abcd, mx, my HIGHBD_TAIL_SUFFIX);
call_new(a_dst, dst_stride, src, src_stride, abcd, mx, my HIGHBD_TAIL_SUFFIX);
......@@ -424,19 +424,19 @@ static void check_warp8x8t(Dav1dMCDSPContext *const c) {
HIGHBD_DECL_SUFFIX);
if (check_func(c->warp8x8t, "warp_8x8t_%dbpc", BITDEPTH)) {
const int mx = (rand() & 0x1fff) - 0x800;
const int my = (rand() & 0x1fff) - 0x800;
const int mx = (rnd() & 0x1fff) - 0x800;
const int my = (rnd() & 0x1fff) - 0x800;
#if BITDEPTH == 16
const int bitdepth_max = rand() & 1 ? 0x3ff : 0xfff;
const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff;
#else
const int bitdepth_max = 0xff;
#endif
for (int i = 0; i < 4; i++)
abcd[i] = (rand() & 0x1fff) - 0x800;
abcd[i] = (rnd() & 0x1fff) - 0x800;
for (int i = 0; i < 15 * 15; i++)
src_buf[i] = rand() & bitdepth_max;
src_buf[i] = rnd() & bitdepth_max;
call_ref(c_tmp, 8, src, src_stride, abcd, mx, my HIGHBD_TAIL_SUFFIX);
call_new(a_tmp, 8, src, src_stride, abcd, mx, my HIGHBD_TAIL_SUFFIX);
......@@ -473,21 +473,21 @@ static void random_offset_for_edge(int *const x, int *const y,
const enum EdgeFlags edge)
{
#define set_off(edge1, edge2, pos, dim) \
*i##dim = edge & (HAVE_##edge1 | HAVE_##edge2) ? 160 : 1 + (rand() % (b##dim - 2)); \
*i##dim = edge & (HAVE_##edge1 | HAVE_##edge2) ? 160 : 1 + (rnd() % (b##dim - 2)); \
switch (edge & (HAVE_##edge1 | HAVE_##edge2)) { \
case HAVE_##edge1 | HAVE_##edge2: \
assert(b##dim <= *i##dim); \
*pos = rand() % (*i##dim - b##dim + 1); \
*pos = rnd() % (*i##dim - b##dim + 1); \
break; \
case HAVE_##edge1: \
*pos = (*i##dim - b##dim) + 1 + (rand() % (b##dim - 1)); \
*pos = (*i##dim - b##dim) + 1 + (rnd() % (b##dim - 1)); \
break; \
case HAVE_##edge2: \
*pos = -(1 + (rand() % (b##dim - 1))); \
*pos = -(1 + (rnd() % (b##dim - 1))); \
break; \
case 0: \
assert(b##dim - 1 > *i##dim); \
*pos = -(1 + (rand() % (b##dim - *i##dim - 1))); \
*pos = -(1 + (rnd() % (b##dim - *i##dim - 1))); \
break; \
}
set_off(LEFT, RIGHT, x, w);
......@@ -500,7 +500,7 @@ static void check_emuedge(Dav1dMCDSPContext *const c) {
ALIGN_STK_32(pixel, src, 160 * 160,);
for (int i = 0; i < 160 * 160; i++)
src[i] = rand() & ((1U << BITDEPTH) - 1);
src[i] = rnd() & ((1U << BITDEPTH) - 1);
declare_func(void, intptr_t bw, intptr_t bh, intptr_t iw, intptr_t ih,
intptr_t x, intptr_t y,
......@@ -513,8 +513,8 @@ static void check_emuedge(Dav1dMCDSPContext *const c) {
for (int h = imax(w / 4, 4); h <= imin(w * 4, 128); h <<= 1) {
// we skip 0xf, since it implies that we don't need emu_edge
for (enum EdgeFlags edge = 0; edge < 0xf; edge++) {
const int bw = w + (rand() & 7);
const int bh = h + (rand() & 7);
const int bw = w + (rnd() & 7);
const int bh = h + (rnd() & 7);
random_offset_for_edge(&x, &y, bw, bh, &iw, &ih, edge);
call_ref(bw, bh, iw, ih, x, y,
c_dst, 192 * sizeof(pixel), src, 160 * sizeof(pixel));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment