diff options
author | Alexandra Hájková <alexandra.khirnova@gmail.com> | 2016-10-02 15:20:13 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2016-10-02 17:13:26 +0200 |
commit | 22c3ab18646924ce24dc6017a9e882ff69689e40 (patch) | |
tree | b9625af956310af10588c35bbf1a73994ea2253d | |
parent | 27085d1b47c3741cc0fac284c916127c4066d049 (diff) | |
download | ffmpeg-streaming-22c3ab18646924ce24dc6017a9e882ff69689e40.zip ffmpeg-streaming-22c3ab18646924ce24dc6017a9e882ff69689e40.tar.gz |
checkasm: Add test for huffyuvdsp add_bytes
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r-- | tests/checkasm/Makefile | 1 | ||||
-rw-r--r-- | tests/checkasm/checkasm.c | 3 | ||||
-rw-r--r-- | tests/checkasm/checkasm.h | 1 | ||||
-rw-r--r-- | tests/checkasm/huffyuvdsp.c | 76 |
4 files changed, 81 insertions, 0 deletions
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index f66c8b9..9b3df55 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -4,6 +4,7 @@ AVCODECOBJS-$(CONFIG_AUDIODSP) += audiodsp.o AVCODECOBJS-$(CONFIG_BLOCKDSP) += blockdsp.o AVCODECOBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o AVCODECOBJS-$(CONFIG_FMTCONVERT) += fmtconvert.o +AVCODECOBJS-$(CONFIG_HUFFYUVDSP) += huffyuvdsp.o AVCODECOBJS-$(CONFIG_H264DSP) += h264dsp.o AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index c279ed1..040c4eb 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -93,6 +93,9 @@ static const struct { { "hevc_mc", checkasm_check_hevc_mc }, { "hevc_idct", checkasm_check_hevc_idct }, #endif +#if CONFIG_HUFFYUVDSP + { "huffyuvdsp", checkasm_check_huffyuvdsp }, +#endif #if CONFIG_V210_ENCODER { "v210enc", checkasm_check_v210enc }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 169aa2a..5a4c056 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -41,6 +41,7 @@ void checkasm_check_h264pred(void); void checkasm_check_h264qpel(void); void checkasm_check_hevc_idct(void); void checkasm_check_hevc_mc(void); +void checkasm_check_huffyuvdsp(void); void checkasm_check_synth_filter(void); void checkasm_check_v210enc(void); void checkasm_check_vp8dsp(void); diff --git a/tests/checkasm/huffyuvdsp.c b/tests/checkasm/huffyuvdsp.c new file mode 100644 index 0000000..59e0f6a --- /dev/null +++ b/tests/checkasm/huffyuvdsp.c @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016 Alexandra Hájková + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <string.h> + +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" + +#include "libavcodec/huffyuvdsp.h" + +#include "checkasm.h" + +#define randomize_buffers(buf, size) \ + do { \ + int j; \ + for (j = 0; j < size; j++) \ + buf[j] = rnd() & 0xFF; \ + } while (0) + +static void check_add_bytes(HuffYUVDSPContext c, int width) +{ + uint8_t *src0 = av_mallocz(width); + uint8_t *src1 = av_mallocz(width); + uint8_t *dst0 = av_mallocz(width); + uint8_t *dst1 = av_mallocz(width); + declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, int w); + + if (!src0 || !src1 || !dst0 || !dst1) + fail(); + + randomize_buffers(src0, width); + memcpy(src1, src0, width); + + if (check_func(c.add_bytes, "add_bytes")) { + call_ref(dst0, src0, width); + call_new(dst1, src1, width); + if (memcmp(dst0, dst1, width)) + fail(); + bench_new(dst1, src1, width); + } + + av_free(src0); + av_free(src1); + av_free(dst0); + av_free(dst1); +} + +void checkasm_check_huffyuvdsp(void) +{ + HuffYUVDSPContext c; + int width = 16 * av_clip(rnd(), 16, 128); + + ff_huffyuvdsp_init(&c); + + check_add_bytes(c, width); + + report("add_bytes"); +} |