Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2021-02-19 12:30:45 +0300
committerMartin Storsjö <martin@martin.st>2021-04-22 15:31:04 +0300
commit35d1d011fda4a92bcaf42d30ed137583b27d7f6d (patch)
treea48cc0a57b09055dc8e3cab1e4c8c92190541f21 /tests
parent685a73bc8b2efc948c39dcb72dfd24a5d9646811 (diff)
checkasm: Add macros for allocating and checking padded pixel buffers
Diffstat (limited to 'tests')
-rw-r--r--tests/checkasm/checkasm.c67
-rw-r--r--tests/checkasm/checkasm.h17
2 files changed, 65 insertions, 19 deletions
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index b6a21b7..69cb9d9 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -772,32 +772,65 @@ void checkasm_set_signal_handler_state(const int enabled) {
int checkasm_check_##type(const char *const file, const int line, \
const type *buf1, ptrdiff_t stride1, \
const type *buf2, ptrdiff_t stride2, \
- const int w, int h, const char *const name) \
+ const int w, int h, const char *const name, \
+ const int padding) \
{ \
stride1 /= sizeof(*buf1); \
stride2 /= sizeof(*buf2); \
int y = 0; \
- for (y = 0; y < h; y++) \
- if (memcmp(&buf1[y*stride1], &buf2[y*stride2], w*sizeof(*buf1))) \
+ for (y = -padding; y < h + padding; y++) \
+ if (memcmp(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \
+ (w + 2*padding)*sizeof(*buf1))) \
break; \
- if (y == h) \
+ if (y == h + padding) \
return 0; \
if (!checkasm_fail_func("%s:%d", file, line)) \
return 1; \
- fprintf(stderr, "%s:\n", name); \
- while (h--) { \
- for (int x = 0; x < w; x++) \
- fprintf(stderr, " " fmt, buf1[x]); \
- fprintf(stderr, " "); \
- for (int x = 0; x < w; x++) \
- fprintf(stderr, " " fmt, buf2[x]); \
- fprintf(stderr, " "); \
- for (int x = 0; x < w; x++) \
- fprintf(stderr, "%c", buf1[x] != buf2[x] ? 'x' : '.'); \
- buf1 += stride1; \
- buf2 += stride2; \
- fprintf(stderr, "\n"); \
+ fprintf(stderr, "%s (%dx%d):\n", name, w, h); \
+ for (y = 0; y < h; y++) \
+ if (memcmp(&buf1[y*stride1], &buf2[y*stride2], w*sizeof(*buf1))) \
+ break; \
+ if (y != h) { \
+ for (y = 0; y < h; y++) { \
+ for (int x = 0; x < w; x++) \
+ fprintf(stderr, " " fmt, buf1[x]); \
+ fprintf(stderr, " "); \
+ for (int x = 0; x < w; x++) \
+ fprintf(stderr, " " fmt, buf2[x]); \
+ fprintf(stderr, " "); \
+ for (int x = 0; x < w; x++) \
+ fprintf(stderr, "%c", buf1[x] != buf2[x] ? 'x' : '.'); \
+ buf1 += stride1; \
+ buf2 += stride2; \
+ fprintf(stderr, "\n"); \
+ } \
+ buf1 -= h*stride1; \
+ buf2 -= h*stride2; \
} \
+ for (y = -padding; y < 0; y++) \
+ if (memcmp(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \
+ (w + 2*padding)*sizeof(*buf1))) { \
+ fprintf(stderr, " overwrite above\n"); \
+ break; \
+ } \
+ for (y = h; y < h + padding; y++) \
+ if (memcmp(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \
+ (w + 2*padding)*sizeof(*buf1))) { \
+ fprintf(stderr, " overwrite below\n"); \
+ break; \
+ } \
+ for (y = 0; y < h; y++) \
+ if (memcmp(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \
+ padding*sizeof(*buf1))) { \
+ fprintf(stderr, " overwrite left\n"); \
+ break; \
+ } \
+ for (y = 0; y < h; y++) \
+ if (memcmp(&buf1[y*stride1 + w], &buf2[y*stride2 + w], \
+ padding*sizeof(*buf1))) { \
+ fprintf(stderr, " overwrite right\n"); \
+ break; \
+ } \
return 1; \
}
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index e077c50..b22a9f0 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -307,11 +307,22 @@ void checkasm_stack_clobber(uint64_t clobber, ...);
#define bench_new(...) do {} while (0)
#endif
+
+#define PIXEL_RECT(name, w, h) \
+ ALIGN_STK_64(pixel, name##_buf, ((h)+32)*((w)+64) + 64,); \
+ ptrdiff_t name##_stride = sizeof(pixel)*((w)+64); \
+ (void)name##_stride; \
+ pixel *name = name##_buf + ((w)+64)*16 + 64
+
+#define CLEAR_PIXEL_RECT(name) \
+ memset(name##_buf, 0x99, sizeof(name##_buf)) \
+
#define DECL_CHECKASM_CHECK_FUNC(type) \
int checkasm_check_##type(const char *const file, const int line, \
const type *const buf1, const ptrdiff_t stride1, \
const type *const buf2, const ptrdiff_t stride2, \
- const int w, const int h, const char *const name)
+ const int w, const int h, const char *const name, \
+ const int padding)
DECL_CHECKASM_CHECK_FUNC(uint8_t);
DECL_CHECKASM_CHECK_FUNC(uint16_t);
@@ -321,10 +332,12 @@ DECL_CHECKASM_CHECK_FUNC(int32_t);
#define CONCAT(a,b) a ## b
-#define checkasm_check(prefix, ...) CONCAT(checkasm_check_, prefix)(__FILE__, __LINE__, __VA_ARGS__)
+#define checkasm_check2(prefix, ...) CONCAT(checkasm_check_, prefix)(__FILE__, __LINE__, __VA_ARGS__)
+#define checkasm_check(prefix, ...) checkasm_check2(prefix, __VA_ARGS__, 0)
#ifdef BITDEPTH
#define checkasm_check_pixel(...) checkasm_check(PIXEL_TYPE, __VA_ARGS__)
+#define checkasm_check_pixel_padded(...) checkasm_check2(PIXEL_TYPE, __VA_ARGS__, 8)
#define checkasm_check_coef(...) checkasm_check(COEF_TYPE, __VA_ARGS__)
#endif