checkasm: Add test for huffyuv_add_bytes

Message ID 1475348090-12126-1-git-send-email-alexandra@khirnov.net
State New
Headers show

Commit Message

Alexandra Hájková Oct. 1, 2016, 6:54 p.m.
---
The name of the file with the test was changed to huffyuv.c

 tests/checkasm/Makefile   |    1 +
 tests/checkasm/checkasm.c |    3 ++
 tests/checkasm/checkasm.h |    1 +
 tests/checkasm/huffyuv.c  |   74 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 79 insertions(+)
 create mode 100644 tests/checkasm/huffyuv.c

Comments

Luca Barbato Oct. 1, 2016, 7:27 p.m. | #1
On 01/10/16 20:54, Alexandra Hájková wrote:
> ---
> The name of the file with the test was changed to huffyuv.c
> 
>  tests/checkasm/Makefile   |    1 +
>  tests/checkasm/checkasm.c |    3 ++
>  tests/checkasm/checkasm.h |    1 +
>  tests/checkasm/huffyuv.c  |   74 +++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 79 insertions(+)
>  create mode 100644 tests/checkasm/huffyuv.c
> 

Sounds good.
Diego Biurrun Oct. 2, 2016, 10:16 a.m. | #2
On Sat, Oct 01, 2016 at 08:54:50PM +0200, Alexandra Hájková wrote:
> --- a/tests/checkasm/Makefile
> +++ b/tests/checkasm/Makefile
> @@ -12,6 +12,7 @@ AVCODECOBJS-$(CONFIG_VP8DSP)            += vp8dsp.o
>  # decoders/encoders
>  AVCODECOBJS-$(CONFIG_DCA_DECODER)       += dcadsp.o synth_filter.o
>  AVCODECOBJS-$(CONFIG_HEVC_DECODER)      += hevc_mc.o hevc_idct.o
> +AVCODECOBJS-$(CONFIG_HUFFYUV_DECODER)   += huffyuv.o

This does not match the entry of the matching dsp file.

> --- 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_HUFFYUV_DECODER
> +    { "huffyuv_add_bytes", checkasm_check_huffyuv_add_bytes },
> +#endif
>  #if CONFIG_V210_ENCODER
>      { "v210enc", checkasm_check_v210enc },
>  #endif

The other entries are named after files or components, not after single
functions.

> --- /dev/null
> +++ b/tests/checkasm/huffyuv.c
> @@ -0,0 +1,74 @@
> +static void check_huffyuv(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);

Unchecked mallocs; do you really need to use the heap here?

> +static void check_huffyuv(HuffYUVDSPContext c, int width)
> +{
> +}
> +void checkasm_check_huffyuv_add_bytes(void)
> +{
> +}

What function does what? It seems like the names are transposed.

Diego

Patch

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index f66c8b9..3b749dd 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -12,6 +12,7 @@  AVCODECOBJS-$(CONFIG_VP8DSP)            += vp8dsp.o
 # decoders/encoders
 AVCODECOBJS-$(CONFIG_DCA_DECODER)       += dcadsp.o synth_filter.o
 AVCODECOBJS-$(CONFIG_HEVC_DECODER)      += hevc_mc.o hevc_idct.o
+AVCODECOBJS-$(CONFIG_HUFFYUV_DECODER)   += huffyuv.o
 AVCODECOBJS-$(CONFIG_V210_ENCODER)      += v210enc.o
 AVCODECOBJS-$(CONFIG_VP9_DECODER)       += vp9dsp.o
 
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index c279ed1..cfa4c52 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_HUFFYUV_DECODER
+    { "huffyuv_add_bytes", checkasm_check_huffyuv_add_bytes },
+#endif
 #if CONFIG_V210_ENCODER
     { "v210enc", checkasm_check_v210enc },
 #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 169aa2a..615ea5e 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_huffyuv_add_bytes(void);
 void checkasm_check_synth_filter(void);
 void checkasm_check_v210enc(void);
 void checkasm_check_vp8dsp(void);
diff --git a/tests/checkasm/huffyuv.c b/tests/checkasm/huffyuv.c
new file mode 100644
index 0000000..4a15b29
--- /dev/null
+++ b/tests/checkasm/huffyuv.c
@@ -0,0 +1,74 @@ 
+/*
+ * 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_huffyuv(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);
+
+    randomize_buffers(src0, width);
+    memcpy(src1, src0, width);
+
+    if (check_func(c.add_bytes, "huffyuv_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_huffyuv_add_bytes(void)
+{
+    HuffYUVDSPContext c;
+    int width = 16 * av_clip(rnd(), 16, 128);
+
+    ff_huffyuvdsp_init(&c);
+
+    check_huffyuv(c, width);
+
+    report("huffyuv");
+}