Skip to content

Commit

Permalink
checkasm: Use the correct AVTXContext in av_tx tests
Browse files Browse the repository at this point in the history
Keep a reference to the correct associated context of the reference
function and use that context when calling the reference function.
  • Loading branch information
Gramner committed Dec 20, 2021
1 parent cde2efb commit 15cfb4e
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions tests/checkasm/av_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include "checkasm.h"

#include <stdlib.h>

#define EPS 0.00005

#define SCALE_NOOP(x) (x)
Expand All @@ -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; \
Expand All @@ -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) \
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 15cfb4e

Please sign in to comment.