diff mbox

[FFmpeg-devel] checkasm: add a g722dsp test

Message ID 20170705194447.9352-1-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer July 5, 2017, 7:44 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 tests/checkasm/Makefile   |  1 +
 tests/checkasm/checkasm.c |  3 +++
 tests/checkasm/checkasm.h |  1 +
 tests/checkasm/g722dsp.c  | 66 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/fate/checkasm.mak   |  1 +
 5 files changed, 72 insertions(+)
 create mode 100644 tests/checkasm/g722dsp.c

Comments

James Almer July 10, 2017, 7:09 p.m. UTC | #1
On 7/5/2017 4:44 PM, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  tests/checkasm/Makefile   |  1 +
>  tests/checkasm/checkasm.c |  3 +++
>  tests/checkasm/checkasm.h |  1 +
>  tests/checkasm/g722dsp.c  | 66 +++++++++++++++++++++++++++++++++++++++++++++++
>  tests/fate/checkasm.mak   |  1 +
>  5 files changed, 72 insertions(+)
>  create mode 100644 tests/checkasm/g722dsp.c
> 
> diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
> index 60e80ab738..184e981754 100644
> --- a/tests/checkasm/Makefile
> +++ b/tests/checkasm/Makefile
> @@ -5,6 +5,7 @@ AVCODECOBJS-$(CONFIG_BLOCKDSP)          += blockdsp.o
>  AVCODECOBJS-$(CONFIG_BSWAPDSP)          += bswapdsp.o
>  AVCODECOBJS-$(CONFIG_FLACDSP)           += flacdsp.o
>  AVCODECOBJS-$(CONFIG_FMTCONVERT)        += fmtconvert.o
> +AVCODECOBJS-$(CONFIG_G722DSP)           += g722dsp.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 29f201b1b3..9173ed19d9 100644
> --- a/tests/checkasm/checkasm.c
> +++ b/tests/checkasm/checkasm.c
> @@ -90,6 +90,9 @@ static const struct {
>      #if CONFIG_FMTCONVERT
>          { "fmtconvert", checkasm_check_fmtconvert },
>      #endif
> +    #if CONFIG_G722DSP
> +        { "g722dsp", checkasm_check_g722dsp },
> +    #endif
>      #if CONFIG_H264DSP
>          { "h264dsp", checkasm_check_h264dsp },
>      #endif
> diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
> index fa51e71e4b..3165b21086 100644
> --- a/tests/checkasm/checkasm.h
> +++ b/tests/checkasm/checkasm.h
> @@ -42,6 +42,7 @@ void checkasm_check_fixed_dsp(void);
>  void checkasm_check_flacdsp(void);
>  void checkasm_check_float_dsp(void);
>  void checkasm_check_fmtconvert(void);
> +void checkasm_check_g722dsp(void);
>  void checkasm_check_h264dsp(void);
>  void checkasm_check_h264pred(void);
>  void checkasm_check_h264qpel(void);
> diff --git a/tests/checkasm/g722dsp.c b/tests/checkasm/g722dsp.c
> new file mode 100644
> index 0000000000..2120c5fd58
> --- /dev/null
> +++ b/tests/checkasm/g722dsp.c
> @@ -0,0 +1,66 @@
> +/*
> + * 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 <string.h>
> +#include "checkasm.h"
> +#include "libavcodec/g722.h"
> +#include "libavcodec/g722dsp.h"
> +#include "libavcodec/mathops.h"
> +
> +#define randomize_buffers()                           \
> +    do {                                              \
> +        int i;                                        \
> +        for (i = 0; i < PREV_SAMPLES_BUF_SIZE; i++) { \
> +            int16_t r = sign_extend(rnd(), 16);       \
> +            src0[i] = r;                              \
> +            src1[i] = r;                              \
> +        }                                             \
> +    } while (0)
> +
> +static void check_qmf(int16_t *src0, int16_t *src1, int dst0[2], int dst1[2]) {
> +    const int16_t *tmp0 = src0;
> +    const int16_t *tmp1 = src1;
> +    int i;
> +
> +    declare_func(void, const int16_t *prev_samples, int xout[2]);
> +
> +    randomize_buffers();
> +    for (i = 0; i < PREV_SAMPLES_BUF_SIZE - 24; i++) {
> +        call_ref(tmp0++, dst0);
> +        call_new(tmp1++, dst1);
> +        if (memcmp(src0, src1, PREV_SAMPLES_BUF_SIZE * sizeof(int16_t)) ||
> +            memcmp(dst0, dst1, sizeof(dst0)))
> +            fail();
> +    }
> +    bench_new(src1, dst1);
> +}
> +
> +void checkasm_check_g722dsp(void)
> +{
> +    int16_t src0[PREV_SAMPLES_BUF_SIZE];
> +    int16_t src1[PREV_SAMPLES_BUF_SIZE];
> +    int dst0[2], dst1[2];
> +    G722DSPContext h;
> +
> +    ff_g722dsp_init(&h);
> +
> +    if (check_func(h.apply_qmf, "g722_apply_qmf"))
> +        check_qmf(src0, src1, dst0, dst1);
> +
> +    report("apply_qmf");
> +}
> diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
> index 61ce6cd74f..e473b3ec0c 100644
> --- a/tests/fate/checkasm.mak
> +++ b/tests/fate/checkasm.mak
> @@ -7,6 +7,7 @@ FATE_CHECKASM = fate-checkasm-aacpsdsp                                  \
>                  fate-checkasm-flacdsp                                   \
>                  fate-checkasm-float_dsp                                 \
>                  fate-checkasm-fmtconvert                                \
> +                fate-checkasm-g722dsp                                   \
>                  fate-checkasm-h264dsp                                   \
>                  fate-checkasm-h264pred                                  \
>                  fate-checkasm-h264qpel                                  \
> 

Ping for this and other checkasm test patches.
James Almer July 13, 2017, 9:33 p.m. UTC | #2
On 7/10/2017 4:09 PM, James Almer wrote:
> On 7/5/2017 4:44 PM, James Almer wrote:
> 
> Ping for this and other checkasm test patches.
> 

Pushed.
diff mbox

Patch

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 60e80ab738..184e981754 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -5,6 +5,7 @@  AVCODECOBJS-$(CONFIG_BLOCKDSP)          += blockdsp.o
 AVCODECOBJS-$(CONFIG_BSWAPDSP)          += bswapdsp.o
 AVCODECOBJS-$(CONFIG_FLACDSP)           += flacdsp.o
 AVCODECOBJS-$(CONFIG_FMTCONVERT)        += fmtconvert.o
+AVCODECOBJS-$(CONFIG_G722DSP)           += g722dsp.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 29f201b1b3..9173ed19d9 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -90,6 +90,9 @@  static const struct {
     #if CONFIG_FMTCONVERT
         { "fmtconvert", checkasm_check_fmtconvert },
     #endif
+    #if CONFIG_G722DSP
+        { "g722dsp", checkasm_check_g722dsp },
+    #endif
     #if CONFIG_H264DSP
         { "h264dsp", checkasm_check_h264dsp },
     #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index fa51e71e4b..3165b21086 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -42,6 +42,7 @@  void checkasm_check_fixed_dsp(void);
 void checkasm_check_flacdsp(void);
 void checkasm_check_float_dsp(void);
 void checkasm_check_fmtconvert(void);
+void checkasm_check_g722dsp(void);
 void checkasm_check_h264dsp(void);
 void checkasm_check_h264pred(void);
 void checkasm_check_h264qpel(void);
diff --git a/tests/checkasm/g722dsp.c b/tests/checkasm/g722dsp.c
new file mode 100644
index 0000000000..2120c5fd58
--- /dev/null
+++ b/tests/checkasm/g722dsp.c
@@ -0,0 +1,66 @@ 
+/*
+ * 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 <string.h>
+#include "checkasm.h"
+#include "libavcodec/g722.h"
+#include "libavcodec/g722dsp.h"
+#include "libavcodec/mathops.h"
+
+#define randomize_buffers()                           \
+    do {                                              \
+        int i;                                        \
+        for (i = 0; i < PREV_SAMPLES_BUF_SIZE; i++) { \
+            int16_t r = sign_extend(rnd(), 16);       \
+            src0[i] = r;                              \
+            src1[i] = r;                              \
+        }                                             \
+    } while (0)
+
+static void check_qmf(int16_t *src0, int16_t *src1, int dst0[2], int dst1[2]) {
+    const int16_t *tmp0 = src0;
+    const int16_t *tmp1 = src1;
+    int i;
+
+    declare_func(void, const int16_t *prev_samples, int xout[2]);
+
+    randomize_buffers();
+    for (i = 0; i < PREV_SAMPLES_BUF_SIZE - 24; i++) {
+        call_ref(tmp0++, dst0);
+        call_new(tmp1++, dst1);
+        if (memcmp(src0, src1, PREV_SAMPLES_BUF_SIZE * sizeof(int16_t)) ||
+            memcmp(dst0, dst1, sizeof(dst0)))
+            fail();
+    }
+    bench_new(src1, dst1);
+}
+
+void checkasm_check_g722dsp(void)
+{
+    int16_t src0[PREV_SAMPLES_BUF_SIZE];
+    int16_t src1[PREV_SAMPLES_BUF_SIZE];
+    int dst0[2], dst1[2];
+    G722DSPContext h;
+
+    ff_g722dsp_init(&h);
+
+    if (check_func(h.apply_qmf, "g722_apply_qmf"))
+        check_qmf(src0, src1, dst0, dst1);
+
+    report("apply_qmf");
+}
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index 61ce6cd74f..e473b3ec0c 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -7,6 +7,7 @@  FATE_CHECKASM = fate-checkasm-aacpsdsp                                  \
                 fate-checkasm-flacdsp                                   \
                 fate-checkasm-float_dsp                                 \
                 fate-checkasm-fmtconvert                                \
+                fate-checkasm-g722dsp                                   \
                 fate-checkasm-h264dsp                                   \
                 fate-checkasm-h264pred                                  \
                 fate-checkasm-h264qpel                                  \