diff options
author | Henrik Gramner <gramner@twoorioles.com> | 2022-05-20 14:49:15 +0300 |
---|---|---|
committer | Henrik Gramner <henrik@gramner.com> | 2022-05-20 14:59:34 +0300 |
commit | 3d9e848cd23d2833e86961f7b282279d985b7df9 (patch) | |
tree | 3c7fa120ec966a84de9e807015b33c676d6d5cde | |
parent | 297682250fd77b014d7b0fc63e61782025426a1a (diff) |
checkasm: Split cdef test into separate pri/sec/pri+sec parts
Makes it possible to benchmark the different code paths individually.
-rw-r--r-- | tests/checkasm/cdef.c | 67 |
1 files changed, 29 insertions, 38 deletions
diff --git a/tests/checkasm/cdef.c b/tests/checkasm/cdef.c index 6f9f0cd..9a90e31 100644 --- a/tests/checkasm/cdef.c +++ b/tests/checkasm/cdef.c @@ -65,47 +65,38 @@ static void check_cdef_filter(const cdef_fn fn, const int w, const int h) { int sec_strength, int dir, int damping, enum CdefEdgeFlags edges HIGHBD_DECL_SUFFIX); - if (check_func(fn, "cdef_filter_%dx%d_%dbpc", w, h, BITDEPTH)) { - for (int dir = 0; dir < 8; dir++) { - for (enum CdefEdgeFlags edges = 0x0; edges <= 0xf; edges++) { + for (int s = 0x1; s <= 0x3; s++) { + if (check_func(fn, "cdef_filter_%dx%d_%02d_%dbpc", w, h, to_binary(s), BITDEPTH)) { + for (int dir = 0; dir < 8; dir++) { + for (enum CdefEdgeFlags edges = 0x0; edges <= 0xf; edges++) { #if BITDEPTH == 16 - const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff; + const int bitdepth_max = rnd() & 1 ? 0x3ff : 0xfff; #else - const int bitdepth_max = 0xff; + const int bitdepth_max = 0xff; #endif - const int bitdepth_min_8 = bitdepth_from_max(bitdepth_max) - 8; - - init_tmp(c_src, 16 * 10 + 16, bitdepth_max); - init_tmp(top_buf, 16 * 2 + 16, bitdepth_max); - init_tmp(bot_buf, 16 * 2 + 16, bitdepth_max); - init_tmp((pixel *) left, 8 * 2, bitdepth_max); - memcpy(a_src, c_src, (16 * 10 + 16) * sizeof(pixel)); - - const int lvl = 1 + (rnd() % 62); - const int damping = 3 + (rnd() & 3) + bitdepth_min_8 - (w == 4 || (rnd() & 1)); - int pri_strength = (lvl >> 2) << bitdepth_min_8; - int sec_strength = lvl & 3; - sec_strength += sec_strength == 3; - sec_strength <<= bitdepth_min_8; - call_ref(c_dst, stride, left, top, bot, pri_strength, sec_strength, - dir, damping, edges HIGHBD_TAIL_SUFFIX); - call_new(a_dst, stride, left, top, bot, pri_strength, sec_strength, - dir, damping, edges HIGHBD_TAIL_SUFFIX); - if (checkasm_check_pixel(c_dst, stride, a_dst, stride, w, h, "dst")) { - fprintf(stderr, "strength = %d:%d, dir = %d, damping = %d, edges = %04d\n", - pri_strength, sec_strength, dir, damping, to_binary(edges)); - return; - } - if (dir == 7 && (edges == 0x5 || edges == 0xa || edges == 0xf)) { - /* Benchmark a fixed set of cases to get consistent results: - * 1) top/left edges and pri_strength only - * 2) bottom/right edges and sec_strength only - * 3) all edges and both pri_strength and sec_strength - */ - pri_strength = (edges & 1) << bitdepth_min_8; - sec_strength = (edges & 2) << bitdepth_min_8; - bench_new(alternate(c_dst, a_dst), stride, left, top, bot, pri_strength, - sec_strength, dir, damping, edges HIGHBD_TAIL_SUFFIX); + const int bitdepth_min_8 = bitdepth_from_max(bitdepth_max) - 8; + + init_tmp(c_src, 16 * 10 + 16, bitdepth_max); + init_tmp(top_buf, 16 * 2 + 16, bitdepth_max); + init_tmp(bot_buf, 16 * 2 + 16, bitdepth_max); + init_tmp((pixel *) left, 8 * 2, bitdepth_max); + memcpy(a_src, c_src, (16 * 10 + 16) * sizeof(pixel)); + + const int pri_strength = s & 2 ? (1 + (rnd() % 15)) << bitdepth_min_8 : 0; + const int sec_strength = s & 1 ? 1 << ((rnd() % 3) + bitdepth_min_8) : 0; + const int damping = 3 + (rnd() & 3) + bitdepth_min_8 - (w == 4 || (rnd() & 1)); + call_ref(c_dst, stride, left, top, bot, pri_strength, sec_strength, + dir, damping, edges HIGHBD_TAIL_SUFFIX); + call_new(a_dst, stride, left, top, bot, pri_strength, sec_strength, + dir, damping, edges HIGHBD_TAIL_SUFFIX); + if (checkasm_check_pixel(c_dst, stride, a_dst, stride, w, h, "dst")) { + fprintf(stderr, "strength = %d:%d, dir = %d, damping = %d, edges = %04d\n", + pri_strength, sec_strength, dir, damping, to_binary(edges)); + return; + } + if (dir == 7 && (edges == 0x5 || edges == 0xa || edges == 0xf)) + bench_new(alternate(c_dst, a_dst), stride, left, top, bot, pri_strength, + sec_strength, dir, damping, edges HIGHBD_TAIL_SUFFIX); } } } |