[FFmpeg-cvslog] Merge commit 'e9ef6171396dc4106526aaa86b620c61ca3d1017'

Clément Bœsch git at videolan.org
Mon Mar 20 20:11:27 EET 2017


ffmpeg | branch: master | Clément Bœsch <u at pkh.me> | Mon Mar 20 19:10:56 2017 +0100| [84147554865b5e34b8e81d4e9a1a238817e5d81e] | committer: Clément Bœsch

Merge commit 'e9ef6171396dc4106526aaa86b620c61ca3d1017'

* commit 'e9ef6171396dc4106526aaa86b620c61ca3d1017':
  checkasm: add tests for audiodsp

Merged-by: Clément Bœsch <u at pkh.me>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=84147554865b5e34b8e81d4e9a1a238817e5d81e
---

 tests/checkasm/Makefile   |   1 +
 tests/checkasm/audiodsp.c | 146 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/checkasm/checkasm.c |   3 +
 tests/checkasm/checkasm.h |   1 +
 4 files changed, 151 insertions(+)

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 06b22f3..5cd92c4 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -1,5 +1,6 @@
 # libavcodec tests
 # subsystems
+AVCODECOBJS-$(CONFIG_AUDIODSP)          += audiodsp.o
 AVCODECOBJS-$(CONFIG_BLOCKDSP)          += blockdsp.o
 AVCODECOBJS-$(CONFIG_BSWAPDSP)          += bswapdsp.o
 AVCODECOBJS-$(CONFIG_FLACDSP)           += flacdsp.o
diff --git a/tests/checkasm/audiodsp.c b/tests/checkasm/audiodsp.c
new file mode 100644
index 0000000..1da1d1e
--- /dev/null
+++ b/tests/checkasm/audiodsp.c
@@ -0,0 +1,146 @@
+/*
+ * 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 <math.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "libavcodec/audiodsp.h"
+
+#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
+
+#include "checkasm.h"
+
+#define MAX_SIZE (32 * 128)
+
+#define randomize_float(buf, len)                               \
+    do {                                                        \
+        int i;                                                  \
+        for (i = 0; i < len; i++) {                             \
+            float f = (float)rnd() / (UINT_MAX >> 5) - 16.0f;   \
+            buf[i] = f;                                         \
+        }                                                       \
+    } while (0)
+
+#define randomize_int(buf, len, size, bits)                         \
+    do {                                                            \
+        int i;                                                      \
+        for (i = 0; i < len; i++) {                                 \
+            uint ## size ## _t r = rnd() & ((1LL << bits) - 1);     \
+            AV_WN ## size ## A(buf + i, -(1LL << (bits - 1)) + r);  \
+        }                                                           \
+    } while (0)
+
+void checkasm_check_audiodsp(void)
+{
+    AudioDSPContext adsp;
+
+    ff_audiodsp_init(&adsp);
+
+    if (check_func(adsp.scalarproduct_int16, "audiodsp.scalarproduct_int16")) {
+        LOCAL_ALIGNED(32, int16_t, v1, [MAX_SIZE]);
+        LOCAL_ALIGNED(32, int16_t, v2, [MAX_SIZE]);
+        unsigned int len_bits_minus4, v1_bits, v2_bits, len;
+        int32_t res0, res1;
+
+        declare_func_emms(AV_CPU_FLAG_MMX, int32_t, const int16_t *v1, const int16_t *v2, int len);
+
+        // generate random 5-12bit vector length
+        len_bits_minus4 = rnd() % 8;
+        len = rnd() & ((1 << len_bits_minus4) - 1);
+        len = 16 * FFMAX(len, 1);
+
+        // generate the bit counts for each of the vectors such that the result
+        // fits into int32
+        v1_bits = 1 + rnd() % 15;
+        v2_bits = FFMIN(32 - (len_bits_minus4 + 4) - v1_bits - 1, 15);
+
+        randomize_int(v1, MAX_SIZE, 16, v1_bits + 1);
+        randomize_int(v2, MAX_SIZE, 16, v2_bits + 1);
+
+        res0 = call_ref(v1, v2, len);
+        res1 = call_new(v1, v2, len);
+        if (res0 != res1)
+            fail();
+        bench_new(v1, v2, MAX_SIZE);
+    }
+
+    if (check_func(adsp.vector_clip_int32, "audiodsp.vector_clip_int32")) {
+        LOCAL_ALIGNED(32, int32_t, src,  [MAX_SIZE]);
+        LOCAL_ALIGNED(32, int32_t, dst0, [MAX_SIZE]);
+        LOCAL_ALIGNED(32, int32_t, dst1, [MAX_SIZE]);
+        int32_t val1, val2, min, max;
+        int len;
+
+        declare_func_emms(AV_CPU_FLAG_MMX, void, int32_t *dst, const int32_t *src,
+                          int32_t min, int32_t max, unsigned int len);
+
+        val1 = ((int32_t)rnd());
+        val1 = FFSIGN(val1) * (val1 & ((1 << 24) - 1));
+        val2 = ((int32_t)rnd());
+        val2 = FFSIGN(val2) * (val2 & ((1 << 24) - 1));
+
+        min = FFMIN(val1, val2);
+        max = FFMAX(val1, val2);
+
+        randomize_int(src, MAX_SIZE, 32, 32);
+
+        len = rnd() % 128;
+        len = 32 * FFMAX(len, 1);
+
+        call_ref(dst0, src, min, max, len);
+        call_new(dst1, src, min, max, len);
+        if (memcmp(dst0, dst1, len * sizeof(*dst0)))
+            fail();
+        bench_new(dst1, src, min, max, MAX_SIZE);
+    }
+
+    if (check_func(adsp.vector_clipf, "audiodsp.vector_clipf")) {
+        LOCAL_ALIGNED(32, float, src, [MAX_SIZE]);
+        LOCAL_ALIGNED(32, float, dst0, [MAX_SIZE]);
+        LOCAL_ALIGNED(32, float, dst1, [MAX_SIZE]);
+        float val1, val2, min, max;
+        int i, len;
+
+        declare_func_emms(AV_CPU_FLAG_MMX, void, float *dst, const float *src,
+                          float min, float max, unsigned int len);
+
+        val1 = (float)rnd() / (UINT_MAX >> 1) - 1.0f;
+        val2 = (float)rnd() / (UINT_MAX >> 1) - 1.0f;
+
+        min = FFMIN(val1, val2);
+        max = FFMAX(val1, val2);
+
+        randomize_float(src, MAX_SIZE);
+
+        len = rnd() % 128;
+        len = 16 * FFMAX(len, 1);
+
+        call_ref(dst0, src, min, max, len);
+        call_new(dst1, src, min, max, len);
+        for (i = 0; i < len; i++) {
+            if (!float_near_ulp_array(dst0, dst1, 3, len))
+                fail();
+        }
+        bench_new(dst1, src, min, max, MAX_SIZE);
+    }
+
+    report("audiodsp");
+}
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index abaaec7..95e2ea3 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_AUDIODSP
+        { "audiodsp", checkasm_check_audiodsp },
+    #endif
     #if CONFIG_BLOCKDSP
         { "blockdsp", checkasm_check_blockdsp },
     #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 6a5c514..e3dcf2c 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -32,6 +32,7 @@
 #include "libavutil/timer.h"
 
 void checkasm_check_alacdsp(void);
+void checkasm_check_audiodsp(void);
 void checkasm_check_blend(void);
 void checkasm_check_blockdsp(void);
 void checkasm_check_bswapdsp(void);


======================================================================

diff --cc tests/checkasm/Makefile
index 06b22f3,f66c8b9..5cd92c4
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@@ -1,8 -1,8 +1,9 @@@
  # libavcodec tests
  # subsystems
+ AVCODECOBJS-$(CONFIG_AUDIODSP)          += audiodsp.o
  AVCODECOBJS-$(CONFIG_BLOCKDSP)          += blockdsp.o
  AVCODECOBJS-$(CONFIG_BSWAPDSP)          += bswapdsp.o
 +AVCODECOBJS-$(CONFIG_FLACDSP)           += flacdsp.o
  AVCODECOBJS-$(CONFIG_FMTCONVERT)        += fmtconvert.o
  AVCODECOBJS-$(CONFIG_H264DSP)           += h264dsp.o
  AVCODECOBJS-$(CONFIG_H264PRED)          += h264pred.o
diff --cc tests/checkasm/audiodsp.c
index 0000000,456b90b..1da1d1e
mode 000000,100644..100644
--- a/tests/checkasm/audiodsp.c
+++ b/tests/checkasm/audiodsp.c
@@@ -1,0 -1,146 +1,146 @@@
+ /*
 - * This file is part of Libav.
++ * This file is part of FFmpeg.
+  *
 - * Libav is free software; you can redistribute it and/or modify
++ * 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.
+  *
 - * Libav is distributed in the hope that it will be useful,
++ * 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 Libav; if not, write to the Free Software Foundation, Inc.,
++ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+  */
+ 
+ #include <math.h>
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ 
+ #include "libavcodec/audiodsp.h"
+ 
+ #include "libavutil/common.h"
+ #include "libavutil/intreadwrite.h"
+ 
+ #include "checkasm.h"
+ 
+ #define MAX_SIZE (32 * 128)
+ 
+ #define randomize_float(buf, len)                               \
+     do {                                                        \
+         int i;                                                  \
+         for (i = 0; i < len; i++) {                             \
+             float f = (float)rnd() / (UINT_MAX >> 5) - 16.0f;   \
+             buf[i] = f;                                         \
+         }                                                       \
+     } while (0)
+ 
+ #define randomize_int(buf, len, size, bits)                         \
+     do {                                                            \
+         int i;                                                      \
+         for (i = 0; i < len; i++) {                                 \
+             uint ## size ## _t r = rnd() & ((1LL << bits) - 1);     \
+             AV_WN ## size ## A(buf + i, -(1LL << (bits - 1)) + r);  \
+         }                                                           \
+     } while (0)
+ 
+ void checkasm_check_audiodsp(void)
+ {
+     AudioDSPContext adsp;
+ 
+     ff_audiodsp_init(&adsp);
+ 
+     if (check_func(adsp.scalarproduct_int16, "audiodsp.scalarproduct_int16")) {
+         LOCAL_ALIGNED(32, int16_t, v1, [MAX_SIZE]);
+         LOCAL_ALIGNED(32, int16_t, v2, [MAX_SIZE]);
+         unsigned int len_bits_minus4, v1_bits, v2_bits, len;
+         int32_t res0, res1;
+ 
+         declare_func_emms(AV_CPU_FLAG_MMX, int32_t, const int16_t *v1, const int16_t *v2, int len);
+ 
+         // generate random 5-12bit vector length
+         len_bits_minus4 = rnd() % 8;
+         len = rnd() & ((1 << len_bits_minus4) - 1);
+         len = 16 * FFMAX(len, 1);
+ 
+         // generate the bit counts for each of the vectors such that the result
+         // fits into int32
+         v1_bits = 1 + rnd() % 15;
+         v2_bits = FFMIN(32 - (len_bits_minus4 + 4) - v1_bits - 1, 15);
+ 
+         randomize_int(v1, MAX_SIZE, 16, v1_bits + 1);
+         randomize_int(v2, MAX_SIZE, 16, v2_bits + 1);
+ 
+         res0 = call_ref(v1, v2, len);
+         res1 = call_new(v1, v2, len);
+         if (res0 != res1)
+             fail();
+         bench_new(v1, v2, MAX_SIZE);
+     }
+ 
+     if (check_func(adsp.vector_clip_int32, "audiodsp.vector_clip_int32")) {
+         LOCAL_ALIGNED(32, int32_t, src,  [MAX_SIZE]);
+         LOCAL_ALIGNED(32, int32_t, dst0, [MAX_SIZE]);
+         LOCAL_ALIGNED(32, int32_t, dst1, [MAX_SIZE]);
+         int32_t val1, val2, min, max;
+         int len;
+ 
+         declare_func_emms(AV_CPU_FLAG_MMX, void, int32_t *dst, const int32_t *src,
+                           int32_t min, int32_t max, unsigned int len);
+ 
+         val1 = ((int32_t)rnd());
+         val1 = FFSIGN(val1) * (val1 & ((1 << 24) - 1));
+         val2 = ((int32_t)rnd());
+         val2 = FFSIGN(val2) * (val2 & ((1 << 24) - 1));
+ 
+         min = FFMIN(val1, val2);
+         max = FFMAX(val1, val2);
+ 
+         randomize_int(src, MAX_SIZE, 32, 32);
+ 
+         len = rnd() % 128;
+         len = 32 * FFMAX(len, 1);
+ 
+         call_ref(dst0, src, min, max, len);
+         call_new(dst1, src, min, max, len);
+         if (memcmp(dst0, dst1, len * sizeof(*dst0)))
+             fail();
+         bench_new(dst1, src, min, max, MAX_SIZE);
+     }
+ 
+     if (check_func(adsp.vector_clipf, "audiodsp.vector_clipf")) {
+         LOCAL_ALIGNED(32, float, src, [MAX_SIZE]);
+         LOCAL_ALIGNED(32, float, dst0, [MAX_SIZE]);
+         LOCAL_ALIGNED(32, float, dst1, [MAX_SIZE]);
+         float val1, val2, min, max;
+         int i, len;
+ 
+         declare_func_emms(AV_CPU_FLAG_MMX, void, float *dst, const float *src,
+                           float min, float max, unsigned int len);
+ 
+         val1 = (float)rnd() / (UINT_MAX >> 1) - 1.0f;
+         val2 = (float)rnd() / (UINT_MAX >> 1) - 1.0f;
+ 
+         min = FFMIN(val1, val2);
+         max = FFMAX(val1, val2);
+ 
+         randomize_float(src, MAX_SIZE);
+ 
+         len = rnd() % 128;
+         len = 16 * FFMAX(len, 1);
+ 
+         call_ref(dst0, src, min, max, len);
+         call_new(dst1, src, min, max, len);
+         for (i = 0; i < len; i++) {
+             if (!float_near_ulp_array(dst0, dst1, 3, len))
+                 fail();
+         }
+         bench_new(dst1, src, min, max, MAX_SIZE);
+     }
+ 
+     report("audiodsp");
+ }
diff --cc tests/checkasm/checkasm.c
index abaaec7,c279ed1..95e2ea3
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@@ -64,63 -64,43 +64,66 @@@ static const struct 
      const char *name;
      void (*func)(void);
  } tests[] = {
 -#if CONFIG_AUDIODSP
 -    { "audiodsp", checkasm_check_audiodsp },
 +#if CONFIG_AVCODEC
 +    #if CONFIG_ALAC_DECODER
 +        { "alacdsp", checkasm_check_alacdsp },
 +    #endif
++    #if CONFIG_AUDIODSP
++        { "audiodsp", checkasm_check_audiodsp },
++    #endif
 +    #if CONFIG_BLOCKDSP
 +        { "blockdsp", checkasm_check_blockdsp },
 +    #endif
 +    #if CONFIG_BSWAPDSP
 +        { "bswapdsp", checkasm_check_bswapdsp },
 +    #endif
 +    #if CONFIG_DCA_DECODER
 +        { "synth_filter", checkasm_check_synth_filter },
 +    #endif
 +    #if CONFIG_FLACDSP
 +        { "flacdsp", checkasm_check_flacdsp },
 +    #endif
 +    #if CONFIG_FMTCONVERT
 +        { "fmtconvert", checkasm_check_fmtconvert },
 +    #endif
 +    #if CONFIG_H264DSP
 +        { "h264dsp", checkasm_check_h264dsp },
 +    #endif
 +    #if CONFIG_H264PRED
 +        { "h264pred", checkasm_check_h264pred },
 +    #endif
 +    #if CONFIG_H264QPEL
 +        { "h264qpel", checkasm_check_h264qpel },
 +    #endif
 +    #if CONFIG_HEVC_DECODER
 +        { "hevc_idct", checkasm_check_hevc_idct },
 +    #endif
 +    #if CONFIG_JPEG2000_DECODER
 +        { "jpeg2000dsp", checkasm_check_jpeg2000dsp },
 +    #endif
 +    #if CONFIG_PIXBLOCKDSP
 +        { "pixblockdsp", checkasm_check_pixblockdsp },
 +    #endif
 +    #if CONFIG_V210_ENCODER
 +        { "v210enc", checkasm_check_v210enc },
 +    #endif
 +    #if CONFIG_VP8DSP
 +        { "vp8dsp", checkasm_check_vp8dsp },
 +    #endif
 +    #if CONFIG_VP9_DECODER
 +        { "vp9dsp", checkasm_check_vp9dsp },
 +    #endif
 +    #if CONFIG_VIDEODSP
 +        { "videodsp", checkasm_check_videodsp },
 +    #endif
  #endif
 -#if CONFIG_BLOCKDSP
 -    { "blockdsp", checkasm_check_blockdsp },
 -#endif
 -#if CONFIG_BSWAPDSP
 -    { "bswapdsp", checkasm_check_bswapdsp },
 -#endif
 -#if CONFIG_DCA_DECODER
 -    { "dcadsp", checkasm_check_dcadsp },
 -    { "synth_filter", checkasm_check_synth_filter },
 -#endif
 -#if CONFIG_FMTCONVERT
 -    { "fmtconvert", checkasm_check_fmtconvert },
 -#endif
 -#if CONFIG_H264DSP
 -    { "h264dsp", checkasm_check_h264dsp },
 -#endif
 -#if CONFIG_H264PRED
 -    { "h264pred", checkasm_check_h264pred },
 -#endif
 -#if CONFIG_H264QPEL
 -    { "h264qpel", checkasm_check_h264qpel },
 -#endif
 -#if CONFIG_HEVC_DECODER
 -    { "hevc_mc", checkasm_check_hevc_mc },
 -    { "hevc_idct", checkasm_check_hevc_idct },
 -#endif
 -#if CONFIG_V210_ENCODER
 -    { "v210enc", checkasm_check_v210enc },
 -#endif
 -#if CONFIG_VP8DSP
 -    { "vp8dsp", checkasm_check_vp8dsp },
 -#endif
 -#if CONFIG_VP9_DECODER
 -    { "vp9dsp", checkasm_check_vp9dsp },
 +#if CONFIG_AVFILTER
 +    #if CONFIG_BLEND_FILTER
 +        { "vf_blend", checkasm_check_blend },
 +    #endif
 +    #if CONFIG_COLORSPACE_FILTER
 +        { "vf_colorspace", checkasm_check_colorspace },
 +    #endif
  #endif
      { NULL }
  };
diff --cc tests/checkasm/checkasm.h
index 6a5c514,169aa2a..e3dcf2c
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@@ -31,12 -31,10 +31,13 @@@
  #include "libavutil/lfg.h"
  #include "libavutil/timer.h"
  
 +void checkasm_check_alacdsp(void);
+ void checkasm_check_audiodsp(void);
 +void checkasm_check_blend(void);
  void checkasm_check_blockdsp(void);
  void checkasm_check_bswapdsp(void);
 -void checkasm_check_dcadsp(void);
 +void checkasm_check_colorspace(void);
 +void checkasm_check_flacdsp(void);
  void checkasm_check_fmtconvert(void);
  void checkasm_check_h264dsp(void);
  void checkasm_check_h264pred(void);



More information about the ffmpeg-cvslog mailing list