summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/checkasm/Makefile1
-rw-r--r--tests/checkasm/av_tx.c108
-rw-r--r--tests/checkasm/checkasm.c1
-rw-r--r--tests/checkasm/checkasm.h1
-rw-r--r--tests/fate/checkasm.mak1
5 files changed, 112 insertions, 0 deletions
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 1827a4e134..4ef5fa87da 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -50,6 +50,7 @@ SWSCALEOBJS += sw_rgb.o sw_scale.o
CHECKASMOBJS-$(CONFIG_SWSCALE) += $(SWSCALEOBJS)
# libavutil tests
+AVUTILOBJS += av_tx.o
AVUTILOBJS += fixed_dsp.o
AVUTILOBJS += float_dsp.o
diff --git a/tests/checkasm/av_tx.c b/tests/checkasm/av_tx.c
new file mode 100644
index 0000000000..178fb61972
--- /dev/null
+++ b/tests/checkasm/av_tx.c
@@ -0,0 +1,108 @@
+/*
+ * 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 "libavutil/mem_internal.h"
+#include "libavutil/tx.h"
+#include "libavutil/error.h"
+
+#include "checkasm.h"
+
+#define EPS 0.00005
+
+#define SCALE_NOOP(x) (x)
+#define SCALE_INT20(x) (av_clip64(lrintf((x) * 2147483648.0), INT32_MIN, INT32_MAX) >> 12)
+
+#define randomize_complex(BUF, LEN, TYPE, SCALE) \
+ do { \
+ TYPE *buf = (TYPE *)BUF; \
+ for (int i = 0; i < LEN; i++) { \
+ double fre = (double)rnd() / UINT_MAX; \
+ double fim = (double)rnd() / UINT_MAX; \
+ buf[i] = (TYPE){ SCALE(fre), SCALE(fim) }; \
+ } \
+ } while (0)
+
+static const int check_lens[] = {
+ 2, 4, 8, 16, 32, 64, 1024, 16384,
+};
+
+#define CHECK_TEMPLATE(PREFIX, TYPE, DATA_TYPE, SCALE, LENGTHS, CHECK_EXPRESSION) \
+ do { \
+ int err; \
+ AVTXContext *tx; \
+ av_tx_fn fn; \
+ int num_checks = 0; \
+ int last_check = 0; \
+ const void *scale = &SCALE; \
+ \
+ for (int i = 0; i < FF_ARRAY_ELEMS(LENGTHS); i++) { \
+ int len = LENGTHS[i]; \
+ \
+ if ((err = av_tx_init(&tx, &fn, TYPE, 0, len, &scale, 0x0)) < 0) { \
+ fprintf(stderr, "av_tx: %s\n", av_err2str(err)); \
+ return; \
+ } \
+ \
+ if (check_func(fn, PREFIX "_%i", len)) { \
+ num_checks++; \
+ last_check = len; \
+ call_ref(tx, out_ref, in, sizeof(DATA_TYPE)); \
+ call_new(tx, out_new, in, sizeof(DATA_TYPE)); \
+ if (CHECK_EXPRESSION) { \
+ fail(); \
+ break; \
+ } \
+ bench_new(tx, out_new, in, sizeof(DATA_TYPE)); \
+ } \
+ \
+ av_tx_uninit(&tx); \
+ fn = NULL; \
+ } \
+ \
+ av_tx_uninit(&tx); \
+ fn = NULL; \
+ \
+ if (num_checks == 1) \
+ report(PREFIX "_%i", last_check); \
+ else if (num_checks) \
+ report(PREFIX); \
+ } while (0)
+
+void checkasm_check_av_tx(void)
+{
+ const float scale_float = 1.0f;
+ const double scale_double = 1.0f;
+
+ declare_func(void, AVTXContext *tx, void *out, void *in, ptrdiff_t stride);
+
+ void *in = av_malloc(16384*2*8);
+ void *out_ref = av_malloc(16384*2*8);
+ void *out_new = av_malloc(16384*2*8);
+
+ randomize_complex(in, 16384, AVComplexFloat, SCALE_NOOP);
+ CHECK_TEMPLATE("float_fft", AV_TX_FLOAT_FFT, AVComplexFloat, scale_float, check_lens,
+ !float_near_abs_eps_array(out_ref, out_new, EPS, len*2));
+
+ randomize_complex(in, 16384, AVComplexDouble, SCALE_NOOP);
+ CHECK_TEMPLATE("double_fft", AV_TX_DOUBLE_FFT, AVComplexDouble, scale_double, check_lens,
+ !double_near_abs_eps_array(out_ref, out_new, EPS, len*2));
+
+ av_free(in);
+ av_free(out_ref);
+ av_free(out_new);
+}
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 8338e8ff58..e2e17d2b11 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -198,6 +198,7 @@ static const struct {
#if CONFIG_AVUTIL
{ "fixed_dsp", checkasm_check_fixed_dsp },
{ "float_dsp", checkasm_check_float_dsp },
+ { "av_tx", checkasm_check_av_tx },
#endif
{ NULL }
};
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index ef6645e3a2..0593d0edac 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -43,6 +43,7 @@ void checkasm_check_aacpsdsp(void);
void checkasm_check_afir(void);
void checkasm_check_alacdsp(void);
void checkasm_check_audiodsp(void);
+void checkasm_check_av_tx(void);
void checkasm_check_blend(void);
void checkasm_check_blockdsp(void);
void checkasm_check_bswapdsp(void);
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index 07f1d8238e..3108fcd510 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -2,6 +2,7 @@ FATE_CHECKASM = fate-checkasm-aacpsdsp \
fate-checkasm-af_afir \
fate-checkasm-alacdsp \
fate-checkasm-audiodsp \
+ fate-checkasm-av_tx \
fate-checkasm-blockdsp \
fate-checkasm-bswapdsp \
fate-checkasm-exrdsp \