summaryrefslogtreecommitdiff
path: root/tests/checkasm
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2016-01-02 12:50:13 +0100
committerHendrik Leppkes <h.leppkes@gmail.com>2016-01-02 12:50:13 +0100
commitf299d8d9f283453cd7671bd174cfdc81503d5e5f (patch)
tree3a4de52630bec836f632dcf74923069a5c83335e /tests/checkasm
parenteb50a3d4409d23429e7576429647d43dce09e69d (diff)
parent489e6add4478b0f5717dbf644234c6f3a3baf02c (diff)
Merge commit '489e6add4478b0f5717dbf644234c6f3a3baf02c'
* commit '489e6add4478b0f5717dbf644234c6f3a3baf02c': checkasm: add fmtconvert tests Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
Diffstat (limited to 'tests/checkasm')
-rw-r--r--tests/checkasm/Makefile1
-rw-r--r--tests/checkasm/checkasm.c3
-rw-r--r--tests/checkasm/checkasm.h1
-rw-r--r--tests/checkasm/fmtconvert.c105
4 files changed, 110 insertions, 0 deletions
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index db5e18638e..e38d15b880 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -3,6 +3,7 @@ AVCODECOBJS-$(CONFIG_ALAC_DECODER) += alacdsp.o
AVCODECOBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o
AVCODECOBJS-$(CONFIG_DCA_DECODER) += dcadsp.o synth_filter.o
AVCODECOBJS-$(CONFIG_FLACDSP) += flacdsp.o
+AVCODECOBJS-$(CONFIG_FMTCONVERT) += fmtconvert.o
AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o
AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o
AVCODECOBJS-$(CONFIG_JPEG2000_DECODER) += jpeg2000dsp.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 372c36677c..7f2cf8ef30 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -72,6 +72,9 @@ static const struct {
#if CONFIG_FLACDSP
{ "flacdsp", checkasm_check_flacdsp },
#endif
+ #if CONFIG_FMTCONVERT
+ { "fmtconvert", checkasm_check_fmtconvert },
+ #endif
#if CONFIG_H264PRED
{ "h264pred", checkasm_check_h264pred },
#endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 0c94f2f3d1..69416e954b 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -34,6 +34,7 @@ void checkasm_check_alacdsp(void);
void checkasm_check_bswapdsp(void);
void checkasm_check_dcadsp(void);
void checkasm_check_flacdsp(void);
+void checkasm_check_fmtconvert(void);
void checkasm_check_h264pred(void);
void checkasm_check_h264qpel(void);
void checkasm_check_jpeg2000dsp(void);
diff --git a/tests/checkasm/fmtconvert.c b/tests/checkasm/fmtconvert.c
new file mode 100644
index 0000000000..50ad3ca2ea
--- /dev/null
+++ b/tests/checkasm/fmtconvert.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2015 Janne Grunau
+ *
+ * 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 <stdint.h>
+#include <string.h>
+
+#include "libavutil/internal.h"
+#include "libavutil/common.h"
+#include "libavcodec/fmtconvert.h"
+
+#include "checkasm.h"
+
+#define BUF_SIZE 1024
+
+#define randomize_input(len) \
+ do { \
+ int k; \
+ for (k = 0; k < len; k++) { \
+ in[k] = rnd() - INT32_MAX; \
+ } \
+ for ( ; k < BUF_SIZE; k++) { \
+ in[k] = INT32_MAX; \
+ } \
+ } while (0)
+
+void checkasm_check_fmtconvert(void)
+{
+ FmtConvertContext c;
+ LOCAL_ALIGNED(32, float, dst0, [BUF_SIZE]);
+ LOCAL_ALIGNED(32, float, dst1, [BUF_SIZE]);
+ LOCAL_ALIGNED(32, int32_t, in, [BUF_SIZE]);
+ float scale_arr[128];
+ int length[] = {8, 16, 24, 56, 72, 128, 512, 520, 656, 768, 992};
+ int i, j;
+
+ for (i = 0; i < FF_ARRAY_ELEMS(scale_arr); i++)
+ scale_arr[i] = (FF_ARRAY_ELEMS(scale_arr) - FF_ARRAY_ELEMS(scale_arr) / 2) / 13;
+
+ ff_fmt_convert_init(&c, NULL);
+
+ memset(dst0, 0, sizeof(*dst0) * BUF_SIZE);
+ memset(dst1, 0, sizeof(*dst1) * BUF_SIZE);
+
+ if (check_func(c.int32_to_float_fmul_scalar, "int32_to_float_fmul_scalar")) {
+ declare_func(void, float *, const int32_t *, float, int);
+
+ for (i = 0; i < FF_ARRAY_ELEMS(scale_arr); i++) {
+ for (j = 0; j < FF_ARRAY_ELEMS(length); j++) {
+
+ randomize_input(length[j]);
+
+ call_ref(dst0, in, scale_arr[i], length[j]);
+ call_new(dst1, in, scale_arr[i], length[j]);
+
+ if (!float_near_ulp_array(dst0, dst1, 3, length[j])) {
+ fail();
+ break;
+ }
+
+ bench_new(dst1, in, scale_arr[i], length[j]);
+ }
+ }
+ }
+ if (check_func(c.int32_to_float_fmul_array8, "int32_to_float_fmul_array8")) {
+ declare_func(void, FmtConvertContext *, float *, const int32_t *,
+ const float *, int);
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < FF_ARRAY_ELEMS(length); j++) {
+
+ randomize_input(length[j]);
+
+ call_ref(&c, dst0, in, scale_arr, length[j]);
+ call_new(&c, dst1, in, scale_arr, length[j]);
+
+ if (!float_near_ulp_array(dst0, dst1, 3, length[j])) {
+ fail();
+ fprintf(stderr, "int32_to_float_fmul_array8: len: %d\n", length[j]);
+ break;
+ }
+
+ bench_new(&c, dst1, in, scale_arr, length[j]);
+ }
+ }
+ }
+ report("fmtconvert");
+}