diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index f6b380672d..06b22f3764 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -1,5 +1,6 @@ # libavcodec tests # subsystems +AVCODECOBJS-$(CONFIG_BLOCKDSP) += blockdsp.o AVCODECOBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o AVCODECOBJS-$(CONFIG_FLACDSP) += flacdsp.o AVCODECOBJS-$(CONFIG_FMTCONVERT) += fmtconvert.o diff --git a/tests/checkasm/blockdsp.c b/tests/checkasm/blockdsp.c new file mode 100644 index 0000000000..153699b632 --- /dev/null +++ b/tests/checkasm/blockdsp.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2015 Henrik Gramner + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include "checkasm.h" + +#include "libavcodec/blockdsp.h" + +#include "libavutil/common.h" +#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" + +#define randomize_buffers(size) \ + do { \ + int i; \ + for (i = 0; i < size; i++) { \ + uint16_t r = rnd(); \ + AV_WN16A(buf0 + i, r); \ + AV_WN16A(buf1 + i, r); \ + } \ + } while (0) + +#define check_clear(func, size) \ +do { \ + if (check_func(h.func, "blockdsp." #func)) { \ + declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t *block); \ + randomize_buffers(size); \ + call_ref(buf0); \ + call_new(buf1); \ + if (memcmp(buf0, buf1, sizeof(*buf0) * size)) \ + fail(); \ + bench_new(buf0); \ + } \ +} while (0) + +void checkasm_check_blockdsp(void) +{ + LOCAL_ALIGNED_16(uint16_t, buf0, [6 * 8 * 8]); + LOCAL_ALIGNED_16(uint16_t, buf1, [6 * 8 * 8]); + + AVCodecContext avctx = { 0 }; + BlockDSPContext h; + + ff_blockdsp_init(&h, &avctx); + + check_clear(clear_block, 8 * 8); + check_clear(clear_blocks, 8 * 8 * 6); + + report("blockdsp"); +} diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index efbce3250b..abaaec716f 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -68,6 +68,9 @@ static const struct { #if CONFIG_ALAC_DECODER { "alacdsp", checkasm_check_alacdsp }, #endif + #if CONFIG_BLOCKDSP + { "blockdsp", checkasm_check_blockdsp }, + #endif #if CONFIG_BSWAPDSP { "bswapdsp", checkasm_check_bswapdsp }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index a3db2a91b9..6a5c514945 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -33,6 +33,7 @@ void checkasm_check_alacdsp(void); void checkasm_check_blend(void); +void checkasm_check_blockdsp(void); void checkasm_check_bswapdsp(void); void checkasm_check_colorspace(void); void checkasm_check_flacdsp(void);