summaryrefslogtreecommitdiff
path: root/tests/checkasm
diff options
context:
space:
mode:
authorHenrik Gramner <henrik@gramner.com>2021-12-20 23:52:44 +0100
committerHenrik Gramner <henrik@gramner.com>2021-12-20 23:58:05 +0100
commit15cfb4eee316a1d6a0764f4460409f0258fd94cb (patch)
treedc05bfdb8926225305b0a4d05926adbf7e3c19b2 /tests/checkasm
parentcde2efb5dac2358c919229015d18629ca739b602 (diff)
checkasm: Use the correct AVTXContext in av_tx tests
Keep a reference to the correct associated context of the reference function and use that context when calling the reference function.
Diffstat (limited to 'tests/checkasm')
-rw-r--r--tests/checkasm/av_tx.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/tests/checkasm/av_tx.c b/tests/checkasm/av_tx.c
index 178fb61972..9d3823e8ed 100644
--- a/tests/checkasm/av_tx.c
+++ b/tests/checkasm/av_tx.c
@@ -22,6 +22,8 @@
#include "checkasm.h"
+#include <stdlib.h>
+
#define EPS 0.00005
#define SCALE_NOOP(x) (x)
@@ -41,6 +43,16 @@ static const int check_lens[] = {
2, 4, 8, 16, 32, 64, 1024, 16384,
};
+static AVTXContext *tx_refs[6 /*AVTXType*/][FF_ARRAY_ELEMS(check_lens)];
+static int init = 0;
+
+static void free_tx_refs(void)
+{
+ for (int i = 0; i < FF_ARRAY_ELEMS(tx_refs); i++)
+ for (int j = 0; j < FF_ARRAY_ELEMS(*tx_refs); j++)
+ av_tx_uninit(&tx_refs[i][j]);
+}
+
#define CHECK_TEMPLATE(PREFIX, TYPE, DATA_TYPE, SCALE, LENGTHS, CHECK_EXPRESSION) \
do { \
int err; \
@@ -59,24 +71,26 @@ static const int check_lens[] = {
} \
\
if (check_func(fn, PREFIX "_%i", len)) { \
+ AVTXContext *tx_ref = tx_refs[TYPE][i]; \
+ if (!tx_ref) \
+ tx_ref = tx; \
num_checks++; \
last_check = len; \
- call_ref(tx, out_ref, in, sizeof(DATA_TYPE)); \
- call_new(tx, out_new, in, sizeof(DATA_TYPE)); \
+ call_ref(tx_ref, out_ref, in, sizeof(DATA_TYPE)); \
+ call_new(tx, out_new, in, sizeof(DATA_TYPE)); \
if (CHECK_EXPRESSION) { \
fail(); \
+ av_tx_uninit(&tx); \
break; \
} \
bench_new(tx, out_new, in, sizeof(DATA_TYPE)); \
+ av_tx_uninit(&tx_refs[TYPE][i]); \
+ tx_refs[TYPE][i] = tx; \
+ } else { \
+ av_tx_uninit(&tx); \
} \
- \
- 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) \
@@ -105,4 +119,9 @@ void checkasm_check_av_tx(void)
av_free(in);
av_free(out_ref);
av_free(out_new);
+
+ if (!init) {
+ init = 1;
+ atexit(free_tx_refs);
+ }
}