mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 12:50:49 +08:00
tests/checkasm/vp3dsp: Add test for put_no_rnd_pixels_l2
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -25,15 +25,6 @@
|
||||
#include "libavutil/mem_internal.h"
|
||||
#include "libavcodec/vp3dsp.h"
|
||||
|
||||
enum {
|
||||
MAX_STRIDE = 64,
|
||||
MIN_STRIDE = 8,
|
||||
/// Horizontal tests operate on 4x8 blocks
|
||||
HORIZONTAL_BUF_SIZE = ((8 /* lines */ - 1) * MAX_STRIDE + 4 /* width */ + 7 /* misalignment */),
|
||||
/// Vertical tests operate on 8x4 blocks
|
||||
VERTICAL_BUF_SIZE = ((4 /* lines */ - 1) * MAX_STRIDE + 8 /* width */ + 7 /* misalignment */),
|
||||
};
|
||||
|
||||
#define randomize_buffers(buf0, buf1, size) \
|
||||
do { \
|
||||
static_assert(sizeof(buf0[0]) == 1 && sizeof(buf1[0]) == 1, \
|
||||
@@ -47,16 +38,68 @@ enum {
|
||||
buf0[k] = buf1[k] = rnd(); \
|
||||
} while (0)
|
||||
|
||||
|
||||
static void vp3_check_loop_filter(void)
|
||||
static void vp3_check_put_no_rnd_pixels_l2(const VP3DSPContext *const vp3dsp)
|
||||
{
|
||||
enum {
|
||||
MAX_STRIDE = 64,
|
||||
HEIGHT = 8, ///< only used height, so only tested height
|
||||
WIDTH = 8,
|
||||
BUF_SIZE = MAX_STRIDE * (HEIGHT - 1) + WIDTH,
|
||||
SRC_BUF_SIZE = BUF_SIZE + (WIDTH - 1), ///< WIDTH-1 to use misaligned input
|
||||
};
|
||||
declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst,
|
||||
const uint8_t *a, const uint8_t *b,
|
||||
ptrdiff_t stride, int h);
|
||||
|
||||
if (!check_func(vp3dsp->put_no_rnd_pixels_l2, "put_no_rnd_pixels_l2"))
|
||||
return;
|
||||
|
||||
DECLARE_ALIGNED(8, uint8_t, dstbuf_new)[BUF_SIZE];
|
||||
DECLARE_ALIGNED(8, uint8_t, dstbuf_ref)[BUF_SIZE];
|
||||
DECLARE_ALIGNED(4, uint8_t, src0_buf)[SRC_BUF_SIZE];
|
||||
DECLARE_ALIGNED(4, uint8_t, src1_buf)[SRC_BUF_SIZE];
|
||||
|
||||
size_t src0_offset = rnd() % WIDTH, src1_offset = rnd() % WIDTH;
|
||||
ptrdiff_t stride = (rnd() % (MAX_STRIDE / WIDTH) + 1) * WIDTH;
|
||||
const uint8_t *src0 = src0_buf + src0_offset, *src1 = src1_buf + src1_offset;
|
||||
uint8_t *dst_new = dstbuf_new, *dst_ref = dstbuf_ref;
|
||||
const int h = HEIGHT;
|
||||
|
||||
if (rnd() & 1) {
|
||||
// Flip stride.
|
||||
dst_new += (h - 1) * stride;
|
||||
dst_ref += (h - 1) * stride;
|
||||
src0 += (h - 1) * stride;
|
||||
src1 += (h - 1) * stride;
|
||||
stride = -stride;
|
||||
}
|
||||
|
||||
randomize_buffers(src0_buf, src1_buf, sizeof(src0_buf));
|
||||
randomize_buffers(dstbuf_new, dstbuf_ref, sizeof(dstbuf_new));
|
||||
call_ref(dst_ref, src0, src1, stride, h);
|
||||
call_new(dst_new, src0, src1, stride, h);
|
||||
if (memcmp(dstbuf_new, dstbuf_ref, sizeof(dstbuf_new)))
|
||||
fail();
|
||||
bench_new(dst_new, src1, src1, stride, h);
|
||||
}
|
||||
|
||||
|
||||
static void vp3_check_loop_filter(const VP3DSPContext *const vp3dsp)
|
||||
{
|
||||
enum {
|
||||
MAX_STRIDE = 64,
|
||||
MIN_STRIDE = 8,
|
||||
/// Horizontal tests operate on 4x8 blocks
|
||||
HORIZONTAL_BUF_SIZE = ((8 /* lines */ - 1) * MAX_STRIDE + 4 /* width */ + 7 /* misalignment */),
|
||||
/// Vertical tests operate on 8x4 blocks
|
||||
VERTICAL_BUF_SIZE = ((4 /* lines */ - 1) * MAX_STRIDE + 8 /* width */ + 7 /* misalignment */),
|
||||
};
|
||||
DECLARE_ALIGNED(8, uint8_t, hor_buf0)[HORIZONTAL_BUF_SIZE];
|
||||
DECLARE_ALIGNED(8, uint8_t, hor_buf1)[HORIZONTAL_BUF_SIZE];
|
||||
DECLARE_ALIGNED(8, uint8_t, ver_buf0)[VERTICAL_BUF_SIZE];
|
||||
DECLARE_ALIGNED(8, uint8_t, ver_buf1)[VERTICAL_BUF_SIZE];
|
||||
DECLARE_ALIGNED(16, int, bounding_values_array)[256 + 4];
|
||||
int *const bounding_values = bounding_values_array + 127;
|
||||
VP3DSPContext vp3dsp;
|
||||
static const struct {
|
||||
const char *name;
|
||||
size_t offset;
|
||||
@@ -73,14 +116,12 @@ static void vp3_check_loop_filter(void)
|
||||
};
|
||||
declare_func(void, uint8_t *src, ptrdiff_t stride, int *bounding_values);
|
||||
|
||||
ff_vp3dsp_init(&vp3dsp);
|
||||
|
||||
int filter_limit = rnd() % 128;
|
||||
|
||||
ff_vp3dsp_set_bounding_values(bounding_values_array, filter_limit);
|
||||
|
||||
for (size_t i = 0; i < FF_ARRAY_ELEMS(tests); ++i) {
|
||||
void (*loop_filter)(uint8_t *, ptrdiff_t, int*) = *(void(**)(uint8_t *, ptrdiff_t, int*))((char*)&vp3dsp + tests[i].offset);
|
||||
void (*loop_filter)(uint8_t *, ptrdiff_t, int*) = *(void(**)(uint8_t *, ptrdiff_t, int*))((const char*)vp3dsp + tests[i].offset);
|
||||
|
||||
if (check_func(loop_filter, "%s", tests[i].name)) {
|
||||
uint8_t *buf0 = tests[i].horizontal ? hor_buf0 : ver_buf0;
|
||||
@@ -112,6 +153,13 @@ static void vp3_check_loop_filter(void)
|
||||
|
||||
void checkasm_check_vp3dsp(void)
|
||||
{
|
||||
vp3_check_loop_filter();
|
||||
VP3DSPContext vp3dsp;
|
||||
|
||||
ff_vp3dsp_init(&vp3dsp);
|
||||
|
||||
vp3_check_put_no_rnd_pixels_l2(&vp3dsp);
|
||||
report("put_no_rnd_pixels_l2");
|
||||
|
||||
vp3_check_loop_filter(&vp3dsp);
|
||||
report("loop_filter");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user