ffmpeg | branch: master | Henrik Gramner <hen...@gramner.com> | Mon Dec 20 23:52:44 2021 +0100| [15cfb4eee316a1d6a0764f4460409f0258fd94cb] | committer: Henrik Gramner
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. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=15cfb4eee316a1d6a0764f4460409f0258fd94cb --- tests/checkasm/av_tx.c | 35 +++++++++++++++++++++++++++-------- 1 file 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); + } } _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".