diff options
author | Dr.Smile <vabnick@gmail.com> | 2022-12-04 23:38:39 +0300 |
---|---|---|
committer | Dr.Smile <vabnick@gmail.com> | 2023-04-02 06:06:19 +0300 |
commit | c9992e024d7a502c1b1499e0918be3b7a0834fed (patch) | |
tree | c268423824e18292c7f125ee4390b69225aa3b8e | |
parent | 588781e6d75aa98dee8d66dd58f14fea04c77f54 (diff) | |
download | libass-c9992e024d7a502c1b1499e0918be3b7a0834fed.tar.bz2 libass-c9992e024d7a502c1b1499e0918be3b7a0834fed.tar.xz |
checkasm: adapt to libass and add simple tests
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile.am | 6 | ||||
-rw-r--r-- | Makefile_util.am | 32 | ||||
-rw-r--r-- | checkasm/arm/checkasm_64.S | 3 | ||||
-rw-r--r-- | checkasm/be_blur.c | 67 | ||||
-rw-r--r-- | checkasm/blend_bitmaps.c | 104 | ||||
-rw-r--r-- | checkasm/checkasm.c | 149 | ||||
-rw-r--r-- | checkasm/checkasm.h | 79 | ||||
-rw-r--r-- | checkasm/x86/checkasm.asm | 4 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | libass/Makefile_library.am | 4 |
11 files changed, 250 insertions, 205 deletions
@@ -22,6 +22,7 @@ Makefile.in /compare/compare /profile/profile /fuzz/fuzz +/checkasm/checkasm # pkgconfig /libass.pc @@ -38,3 +39,4 @@ Makefile.in /ltmain.sh /missing /m4 +/test-driver diff --git a/Makefile.am b/Makefile.am index 1bac0a2..52f99f1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,8 +10,14 @@ EXTRA_DIST = libass.pc.in Changelog MAINTAINERS ltnasm.sh pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libass.pc +nasm_verbose = $(nasm_verbose_$(V)) +nasm_verbose_ = $(nasm_verbose_$(AM_DEFAULT_VERBOSITY)) +nasm_verbose_0 = @echo " NASM " $@; + lib_LTLIBRARIES = noinst_PROGRAMS = +check_PROGRAMS = +TESTS = include libass/Makefile_library.am include Makefile_util.am diff --git a/Makefile_util.am b/Makefile_util.am index 5c900c6..97dce66 100644 --- a/Makefile_util.am +++ b/Makefile_util.am @@ -38,3 +38,35 @@ fuzz/fuzz_ossfuzz: fuzz/fuzz-fuzz.o libass/libass.la $(srcdir)/libass.pc $$(pkg-config --static --libs $(srcdir)/libass.pc | sed -e 's/-lm //g' -e 's/-lass //g') \ -Wl,-Bdynamic endif + + +if ENABLE_CHECKASM +check_PROGRAMS += checkasm/checkasm +TESTS += checkasm/checkasm$(EXEEXT) +bench: run-checkasm-bench +endif + +.asm.o: + $(nasm_verbose)$(AS) $(ASFLAGS) -I$(top_srcdir)/libass/ -o $@ $< + +checkasm_checkasm_SOURCES = \ + checkasm/blend_bitmaps.c \ + checkasm/be_blur.c \ + checkasm/checkasm.h checkasm/checkasm.c + +checkasm_checkasm_CPPFLAGS = -I$(top_srcdir)/libass +checkasm_checkasm_LDADD = libass/libass.la +checkasm_checkasm_LDFLAGS = $(AM_LDFLAGS) -static + +if X86 +checkasm_checkasm_SOURCES += checkasm/x86/checkasm.asm +endif +if AARCH64 +checkasm_checkasm_SOURCES += checkasm/arm/checkasm_64.S +endif + +run-checkasm: checkasm/checkasm$(EXEEXT) + checkasm/checkasm$(EXEEXT) + +run-checkasm-bench: checkasm/checkasm$(EXEEXT) + checkasm/checkasm$(EXEEXT) --bench diff --git a/checkasm/arm/checkasm_64.S b/checkasm/arm/checkasm_64.S index 5feb2cb..fc54b40 100644 --- a/checkasm/arm/checkasm_64.S +++ b/checkasm/arm/checkasm_64.S @@ -28,8 +28,7 @@ #define PRIVATE_PREFIX checkasm_ -#include "src/arm/asm.S" -#include "src/arm/64/util.S" +#include "aarch64/asm.S" const register_init, align=4 .quad 0x21f86d66c8ca00ce diff --git a/checkasm/be_blur.c b/checkasm/be_blur.c new file mode 100644 index 0000000..affba7b --- /dev/null +++ b/checkasm/be_blur.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2020-2022 libass contributors + * + * This file is part of libass. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "checkasm.h" + +#define HEIGHT 8 +#define STRIDE 64 +#define MIN_WIDTH 2 + +static void check_be_blur(BeBlurFunc func) +{ + ALIGN(uint8_t buf_ref[STRIDE * HEIGHT], 32); + ALIGN(uint8_t buf_new[STRIDE * HEIGHT], 32); + ALIGN(uint16_t tmp[STRIDE * 2], 32); + declare_func(void, + uint8_t *buf, ptrdiff_t stride, + size_t width, size_t height, uint16_t *tmp); + + if (check_func(func, "be_blur")) { + for (int w = MIN_WIDTH; w <= STRIDE; w++) { + memset(buf_ref, 0, sizeof(buf_ref)); + memset(buf_new, 0, sizeof(buf_new)); + for (int y = 0; y < HEIGHT; y++) { + for (int x = 0; x < w - 1; x++) + buf_ref[y * STRIDE + x] = buf_new[y * STRIDE + x] = rnd(); + } + + for (int i = 0; i < 2 * STRIDE; i++) + tmp[i] = rnd(); + call_ref(buf_ref, STRIDE, w, HEIGHT, tmp); + + for (int i = 0; i < 2 * STRIDE; i++) + tmp[i] = rnd(); + call_new(buf_new, STRIDE, w, HEIGHT, tmp); + + if (memcmp(buf_ref, buf_new, sizeof(buf_ref))) { + fail(); + break; + } + } + + bench_new(buf_new, STRIDE, STRIDE, HEIGHT, tmp); + } + + report("be_blur"); +} + +void checkasm_check_be_blur(unsigned cpu_flag) +{ + BitmapEngine engine = ass_bitmap_engine_init(cpu_flag); + check_be_blur(engine.be_blur); +} diff --git a/checkasm/blend_bitmaps.c b/checkasm/blend_bitmaps.c new file mode 100644 index 0000000..02cf008 --- /dev/null +++ b/checkasm/blend_bitmaps.c @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2020-2022 libass contributors + * + * This file is part of libass. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "checkasm.h" + +#define HEIGHT 8 +#define DST_STRIDE 64 +#define MIN_WIDTH 1 +#define SRC1_STRIDE 96 +#define SRC2_STRIDE 128 + +static void check_blend_bitmaps(BitmapBlendFunc func, const char *name) +{ + ALIGN(uint8_t src[SRC1_STRIDE * HEIGHT], 32); + ALIGN(uint8_t dst_ref[DST_STRIDE * HEIGHT], 32); + ALIGN(uint8_t dst_new[DST_STRIDE * HEIGHT], 32); + declare_func(void, + uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + size_t width, size_t height); + + if (check_func(func, name)) { + for (int w = MIN_WIDTH; w <= DST_STRIDE; w++) { + for (int i = 0; i < sizeof(src); i++) + src[i] = rnd(); + + for (int i = 0; i < sizeof(dst_ref); i++) + dst_ref[i] = dst_new[i] = rnd(); + + call_ref(dst_ref, DST_STRIDE, src, SRC1_STRIDE, w, HEIGHT); + call_new(dst_new, DST_STRIDE, src, SRC1_STRIDE, w, HEIGHT); + + if (memcmp(dst_ref, dst_new, sizeof(dst_ref))) { + fail(); + break; + } + } + + bench_new(dst_new, DST_STRIDE, src, SRC1_STRIDE, DST_STRIDE, HEIGHT); + } + + report(name); +} + +static void check_mul_bitmaps(BitmapMulFunc func) +{ + ALIGN(uint8_t src1[SRC1_STRIDE * HEIGHT], 32); + ALIGN(uint8_t src2[SRC2_STRIDE * HEIGHT], 32); + ALIGN(uint8_t dst_ref[DST_STRIDE * HEIGHT], 32); + ALIGN(uint8_t dst_new[DST_STRIDE * HEIGHT], 32); + declare_func(void, + uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src1, ptrdiff_t src1_stride, + const uint8_t *src2, ptrdiff_t src2_stride, + size_t width, size_t height); + + if (check_func(func, "mul_bitmaps")) { + for (int w = MIN_WIDTH; w < DST_STRIDE; w++) { + for (int i = 0; i < sizeof(src1); i++) + src1[i] = rnd(); + + for (int i = 0; i < sizeof(src2); i++) + src2[i] = rnd(); + + memset(dst_ref, 0, sizeof(dst_ref)); + memset(dst_new, 0, sizeof(dst_new)); + + call_ref(dst_ref, DST_STRIDE, src1, SRC1_STRIDE, src2, SRC2_STRIDE, w, HEIGHT); + call_new(dst_new, DST_STRIDE, src1, SRC1_STRIDE, src2, SRC2_STRIDE, w, HEIGHT); + + if (memcmp(dst_ref, dst_new, sizeof(dst_ref))) { + fail(); + break; + } + } + + bench_new(dst_new, DST_STRIDE, src1, SRC1_STRIDE, src2, SRC2_STRIDE, DST_STRIDE, HEIGHT); + } + + report("mul_bitmaps"); +} + +void checkasm_check_blend_bitmaps(unsigned cpu_flag) +{ + BitmapEngine engine = ass_bitmap_engine_init(cpu_flag); + check_blend_bitmaps(engine.add_bitmaps, "add_bitmaps"); + check_blend_bitmaps(engine.imul_bitmaps, "imul_bitmaps"); + check_mul_bitmaps(engine.mul_bitmaps); +} diff --git a/checkasm/checkasm.c b/checkasm/checkasm.c index 0539bfb..85398e0 100644 --- a/checkasm/checkasm.c +++ b/checkasm/checkasm.c @@ -24,15 +24,14 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "tests/checkasm/checkasm.h" + +#include "checkasm.h" #include <math.h> #include <stdarg.h> #include <stdio.h> #include <string.h> -#include "src/cpu.h" - #ifdef _WIN32 #include <windows.h> #define COLOR_RED FOREGROUND_RED @@ -53,28 +52,10 @@ /* List of tests to invoke */ static const struct { const char *name; - void (*func)(void); + void (*func)(unsigned cpu_flag); } tests[] = { - { "msac", checkasm_check_msac }, - { "refmvs", checkasm_check_refmvs }, -#if CONFIG_8BPC - { "cdef_8bpc", checkasm_check_cdef_8bpc }, - { "filmgrain_8bpc", checkasm_check_filmgrain_8bpc }, - { "ipred_8bpc", checkasm_check_ipred_8bpc }, - { "itx_8bpc", checkasm_check_itx_8bpc }, - { "loopfilter_8bpc", checkasm_check_loopfilter_8bpc }, - { "looprestoration_8bpc", checkasm_check_looprestoration_8bpc }, - { "mc_8bpc", checkasm_check_mc_8bpc }, -#endif -#if CONFIG_16BPC - { "cdef_16bpc", checkasm_check_cdef_16bpc }, - { "filmgrain_16bpc", checkasm_check_filmgrain_16bpc }, - { "ipred_16bpc", checkasm_check_ipred_16bpc }, - { "itx_16bpc", checkasm_check_itx_16bpc }, - { "loopfilter_16bpc", checkasm_check_loopfilter_16bpc }, - { "looprestoration_16bpc", checkasm_check_looprestoration_16bpc }, - { "mc_16bpc", checkasm_check_mc_16bpc }, -#endif + { "blend_bitmaps", checkasm_check_blend_bitmaps }, + { "be_blur", checkasm_check_be_blur }, { 0 } }; @@ -85,15 +66,11 @@ static const struct { unsigned flag; } cpus[] = { #if ARCH_X86 - { "SSE2", "sse2", DAV1D_X86_CPU_FLAG_SSE2 }, - { "SSSE3", "ssse3", DAV1D_X86_CPU_FLAG_SSSE3 }, - { "SSE4.1", "sse4", DAV1D_X86_CPU_FLAG_SSE41 }, - { "AVX2", "avx2", DAV1D_X86_CPU_FLAG_AVX2 }, - { "AVX-512 (Ice Lake)", "avx512icl", DAV1D_X86_CPU_FLAG_AVX512ICL }, -#elif ARCH_AARCH64 || ARCH_ARM - { "NEON", "neon", DAV1D_ARM_CPU_FLAG_NEON }, -#elif ARCH_PPC64LE - { "VSX", "vsx", DAV1D_PPC_CPU_FLAG_VSX }, + { "SSE2", "sse2", ASS_CPU_FLAG_X86_SSE2 }, + { "SSSE3", "ssse3", ASS_CPU_FLAG_X86_SSSE3 }, + { "AVX2", "avx2", ASS_CPU_FLAG_X86_AVX2 }, +#elif ARCH_AARCH64 + { "NEON", "neon", ASS_CPU_FLAG_ARM_NEON }, #endif { 0 } }; @@ -516,8 +493,7 @@ static void check_cpu_flag(const char *const name, unsigned flag) { const unsigned old_cpu_flag = state.cpu_flag; flag |= old_cpu_flag; - dav1d_set_cpu_flags_mask(flag); - state.cpu_flag = dav1d_get_cpu_flags(); + state.cpu_flag = ass_get_cpu_flags(flag); if (!flag || state.cpu_flag != old_cpu_flag) { state.cpu_flag_name = name; @@ -526,7 +502,7 @@ static void check_cpu_flag(const char *const name, unsigned flag) { continue; xor128_srand(state.seed); state.current_test_name = tests[i].name; - tests[i].func(); + tests[i].func(state.cpu_flag); } } } @@ -612,8 +588,6 @@ int main(int argc, char *argv[]) { return 0; #endif - dav1d_init_cpu(); - #ifdef _WIN32 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) AddVectoredExceptionHandler(0, signal_handler); @@ -651,10 +625,10 @@ int main(int argc, char *argv[]) { #if ARCH_X86_64 void checkasm_warmup_avx2(void); void checkasm_warmup_avx512(void); - const unsigned cpu_flags = dav1d_get_cpu_flags(); - if (cpu_flags & DAV1D_X86_CPU_FLAG_AVX512ICL) + const unsigned cpu_flags = ass_get_cpu_flags(ASS_CPU_FLAG_ALL); + if (cpu_flags & /*ASS_CPU_FLAG_X86_AVX512ICL*/0) state.simd_warmup = checkasm_warmup_avx512; - else if (cpu_flags & DAV1D_X86_CPU_FLAG_AVX2) + else if (cpu_flags & ASS_CPU_FLAG_X86_AVX2) state.simd_warmup = checkasm_warmup_avx2; checkasm_simd_warmup(); #endif @@ -801,7 +775,7 @@ void checkasm_report(const char *const name, ...) { va_start(arg, name); pad_length -= vfprintf(stderr, name, arg); va_end(arg); - fprintf(stderr, "%*c", imax(pad_length, 0) + 2, '['); + fprintf(stderr, "%*c", FFMAX(pad_length, 0) + 2, '['); if (state.num_failed == prev_failed) color_printf(COLOR_GREEN, "OK"); @@ -830,97 +804,6 @@ void checkasm_set_signal_handler_state(const int enabled) { state.catch_signals = enabled; } -static int check_err(const char *const file, const int line, - const char *const name, const int w, const int h, - int *const err) -{ - if (*err) - return 0; - if (!checkasm_fail_func("%s:%d", file, line)) - return 1; - *err = 1; - fprintf(stderr, "%s (%dx%d):\n", name, w, h); - return 0; -} - -#define DEF_CHECKASM_CHECK_FUNC(type, fmt) \ -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 align_w, const int align_h, \ - const int padding) \ -{ \ - int aligned_w = (w + align_w - 1) & ~(align_w - 1); \ - int aligned_h = (h + align_h - 1) & ~(align_h - 1); \ - int err = 0; \ - 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))) \ - break; \ - if (y != h) { \ - if (check_err(file, line, name, w, h, &err)) \ - return 1; \ - 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))) { \ - if (check_err(file, line, name, w, h, &err)) \ - return 1; \ - fprintf(stderr, " overwrite above\n"); \ - break; \ - } \ - for (y = aligned_h; y < aligned_h + padding; y++) \ - if (memcmp(&buf1[y*stride1 - padding], &buf2[y*stride2 - padding], \ - (w + 2*padding)*sizeof(*buf1))) { \ - if (check_err(file, line, name, w, h, &err)) \ - return 1; \ - 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))) { \ - if (check_err(file, line, name, w, h, &err)) \ - return 1; \ - fprintf(stderr, " overwrite left\n"); \ - break; \ - } \ - for (y = 0; y < h; y++) \ - if (memcmp(&buf1[y*stride1 + aligned_w], &buf2[y*stride2 + aligned_w], \ - padding*sizeof(*buf1))) { \ - if (check_err(file, line, name, w, h, &err)) \ - return 1; \ - fprintf(stderr, " overwrite right\n"); \ - break; \ - } \ - return err; \ -} - -DEF_CHECKASM_CHECK_FUNC(int8_t, "%4d") -DEF_CHECKASM_CHECK_FUNC(int16_t, "%6d") -DEF_CHECKASM_CHECK_FUNC(int32_t, "%9d") -DEF_CHECKASM_CHECK_FUNC(uint8_t, "%02x") -DEF_CHECKASM_CHECK_FUNC(uint16_t, "%04x") -DEF_CHECKASM_CHECK_FUNC(uint32_t, "%08x") - #if ARCH_X86_64 void checkasm_simd_warmup(void) { diff --git a/checkasm/checkasm.h b/checkasm/checkasm.h index 26ae045..996fb53 100644 --- a/checkasm/checkasm.h +++ b/checkasm/checkasm.h @@ -25,11 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef DAV1D_TESTS_CHECKASM_CHECKASM_H -#define DAV1D_TESTS_CHECKASM_CHECKASM_H +#ifndef CHECKASM_CHECKASM_H +#define CHECKASM_CHECKASM_H #include "config.h" +#include "ass_bitmap.h" + #include <stdint.h> #include <stdlib.h> @@ -51,26 +53,11 @@ #define checkasm_load_context() #endif -#include "include/common/attributes.h" -#include "include/common/bitdepth.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) - -void checkasm_check_msac(void); -void checkasm_check_refmvs(void); -decl_check_bitfns(void checkasm_check_cdef); -decl_check_bitfns(void checkasm_check_filmgrain); -decl_check_bitfns(void checkasm_check_ipred); -decl_check_bitfns(void checkasm_check_itx); -decl_check_bitfns(void checkasm_check_loopfilter); -decl_check_bitfns(void checkasm_check_looprestoration); -decl_check_bitfns(void checkasm_check_mc); +void checkasm_check_blend_bitmaps(unsigned cpu_flag); +void checkasm_check_be_blur(unsigned cpu_flag); void *checkasm_check_func(void *func, const char *name, ...); int checkasm_bench_func(void); @@ -118,7 +105,7 @@ int float_near_abs_eps_array_ulp(const float *a, const float *b, float eps, ((func_type *)func_ref)(__VA_ARGS__));\ checkasm_set_signal_handler_state(0) -#if HAVE_ASM +#if CONFIG_ASM #if ARCH_X86 #if defined(_MSC_VER) && !defined(__clang__) #include <intrin.h> @@ -293,14 +280,14 @@ void checkasm_stack_clobber(uint64_t clobber, ...); ((func_type *)func_new)(__VA_ARGS__));\ checkasm_set_signal_handler_state(0) #endif -#else /* HAVE_ASM */ +#else /* CONFIG_ASM */ #define declare_new(ret, ...) /* Call the function */ #define call_new(...)\ (checkasm_set_signal_handler_state(1),\ ((func_type *)func_new)(__VA_ARGS__));\ checkasm_set_signal_handler_state(0) -#endif /* HAVE_ASM */ +#endif /* CONFIG_ASM */ /* Benchmark the function */ #ifdef readtime @@ -338,46 +325,12 @@ void checkasm_stack_clobber(uint64_t clobber, ...); #define bench_new(...) do {} while (0) #endif -/* Alternates between two pointers. Intended to be used within bench_new() - * calls for functions which modifies their input buffer(s) to ensure that - * throughput, and not latency, is measured. */ -#define alternate(a, b) (talt ? (b) : (a)) - -#define ROUND_UP(x,a) (((x)+((a)-1)) & ~((a)-1)) -#define PIXEL_RECT(name, w, h) \ - ALIGN_STK_64(pixel, name##_buf, ((h)+32)*(ROUND_UP(w,64)+64) + 64,); \ - ptrdiff_t name##_stride = sizeof(pixel)*(ROUND_UP(w,64)+64); \ - (void)name##_stride; \ - pixel *name = name##_buf + (ROUND_UP(w,64)+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 align_w, const int align_h, \ - const int padding) - -DECL_CHECKASM_CHECK_FUNC(int8_t); -DECL_CHECKASM_CHECK_FUNC(int16_t); -DECL_CHECKASM_CHECK_FUNC(int32_t); -DECL_CHECKASM_CHECK_FUNC(uint8_t); -DECL_CHECKASM_CHECK_FUNC(uint16_t); -DECL_CHECKASM_CHECK_FUNC(uint32_t); - -#define CONCAT(a,b) a ## b - -#define checkasm_check2(prefix, ...) CONCAT(checkasm_check_, prefix)(__FILE__, __LINE__, __VA_ARGS__) -#define checkasm_check(prefix, ...) checkasm_check2(prefix, __VA_ARGS__, 0, 0, 0) - -#ifdef BITDEPTH -#define checkasm_check_pixel(...) checkasm_check(PIXEL_TYPE, __VA_ARGS__) -#define checkasm_check_pixel_padded(...) checkasm_check2(PIXEL_TYPE, __VA_ARGS__, 1, 1, 8) -#define checkasm_check_pixel_padded_align(...) checkasm_check2(PIXEL_TYPE, __VA_ARGS__, 8) -#define checkasm_check_coef(...) checkasm_check(COEF_TYPE, __VA_ARGS__) +#ifdef _MSC_VER +#define ALIGN(ll, a) \ + __declspec(align(a)) ll +#else +#define ALIGN(line, align) \ + line __attribute__((aligned(align))) #endif -#endif /* DAV1D_TESTS_CHECKASM_CHECKASM_H */ +#endif /* CHECKASM_CHECKASM_H */ diff --git a/checkasm/x86/checkasm.asm b/checkasm/x86/checkasm.asm index 8f19ef9..4ad1946 100644 --- a/checkasm/x86/checkasm.asm +++ b/checkasm/x86/checkasm.asm @@ -23,10 +23,8 @@ ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -%include "config.asm" -%undef private_prefix %define private_prefix checkasm -%include "ext/x86/x86inc.asm" +%include "x86/x86inc.asm" SECTION_RODATA 16 diff --git a/configure.ac b/configure.ac index b210d0c..012478a 100644 --- a/configure.ac +++ b/configure.ac @@ -364,6 +364,8 @@ AM_CONDITIONAL([ENABLE_COMPARE], [test "x$enable_compare" = xyes && test "x$libp AM_CONDITIONAL([ENABLE_TEST], [test "x$enable_test" = xyes && test "x$libpng" = xtrue]) AM_CONDITIONAL([ENABLE_PROFILE], [test "x$enable_profile" = xyes]) AM_CONDITIONAL([ENABLE_FUZZ], [test "x$enable_fuzz" = xyes]) +# tcc doesn't have the full support of __attribute__((aligned(32))) +AM_CONDITIONAL([ENABLE_CHECKASM], [test "x$can_asm" = xtrue && test "x$GCC" = xyes]) AM_CONDITIONAL([FONTCONFIG], [test "x$fontconfig" = xtrue]) AM_CONDITIONAL([CORETEXT], [test "x$coretext" = xtrue]) @@ -375,6 +377,9 @@ AM_COND_IF([ASM], [ AM_COND_IF([X86], [ AC_DEFINE(ARCH_X86, 1, [targeting a 32- or 64-bit x86 host architecture]) ]) + AM_COND_IF([X86_64], [ + AC_DEFINE(ARCH_X86_64, 1, [targeting a 64-bit x86 host architecture]) + ]) AM_COND_IF([AARCH64], [ AC_DEFINE(ARCH_AARCH64, 1, [targeting a 64-bit arm host architecture]) ]) diff --git a/libass/Makefile_library.am b/libass/Makefile_library.am index 8d0ac3a..536d775 100644 --- a/libass/Makefile_library.am +++ b/libass/Makefile_library.am @@ -2,10 +2,6 @@ LIBASS_LT_CURRENT = 11 LIBASS_LT_REVISION = 1 LIBASS_LT_AGE = 2 -nasm_verbose = $(nasm_verbose_$(V)) -nasm_verbose_ = $(nasm_verbose_$(AM_DEFAULT_VERBOSITY)) -nasm_verbose_0 = @echo " NASM " $@; - .asm.lo: $(nasm_verbose)$(LIBTOOL) $(AM_V_lt) --tag=CC --mode=compile $(top_srcdir)/ltnasm.sh $(AS) $(ASFLAGS) -I$(top_srcdir)/libass/ -Dprivate_prefix=ass -o $@ $< |