This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 4a2c02a993856576bf2852e2d3482b13f6d9012a Author: Andreas Rheinhardt <[email protected]> AuthorDate: Tue Jul 28 12:12:47 2026 +0200 Commit: Andreas Rheinhardt <[email protected]> CommitDate: Sun Aug 9 16:30:34 2026 +0200 tests/checkasm/crc: Avoid static variables This is possible because the state of the PRNG at the beginning of every test function is the same for every cpu flag (since the switch to libcheckasm). It also has the advantage that random sizes are checked when using --repeat. Signed-off-by: Andreas Rheinhardt <[email protected]> --- tests/checkasm/crc.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/tests/checkasm/crc.c b/tests/checkasm/crc.c index 8c133e1730..d35126ed06 100644 --- a/tests/checkasm/crc.c +++ b/tests/checkasm/crc.c @@ -34,6 +34,10 @@ #include "libavutil/mem.h" #include "libavutil/mem_internal.h" +enum { + BUF_SIZE = 16384, +}; + typedef struct CustomTest { struct CustomTest *prev; AVCRC ctx[1024]; @@ -51,7 +55,8 @@ void checkasm_uninit_crc(void) ctx_list = NULL; } -static void check_crc(const AVCRC *table_new, const char *name, unsigned idx) +static void check_crc(const AVCRC *table_new, const char *name, + size_t size, size_t offset) { declare_func(uint32_t, const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length); @@ -60,21 +65,9 @@ static void check_crc(const AVCRC *table_new, const char *name, unsigned idx) if (!table_ref) return; - DECLARE_ALIGNED(4, uint8_t, buf)[16384]; - static size_t offsets[AV_CRC_MAX + 1]; - static size_t sizes[AV_CRC_MAX + 1]; - static unsigned sizes_initialized = 0; + DECLARE_ALIGNED(4, uint8_t, buf)[BUF_SIZE]; uint32_t prev_crc = rnd(); - if (!(sizes_initialized & (1 << idx))) { - sizes_initialized |= 1 << idx; - offsets[idx] = rnd() & 31; - sizes[idx] = rnd() % (sizeof(buf) - 1 - offsets[idx]); - } - - size_t size = sizes[idx]; - size_t offset = offsets[idx]; - for (size_t j = 0; j < sizeof(buf); j += 4) AV_WN32A(buf + j, rnd()); @@ -97,21 +90,29 @@ void checkasm_check_crc(void) }; static_assert(FF_ARRAY_ELEMS(tests) == AV_CRC_MAX, "test needs to be added"); + size_t offsets[AV_CRC_MAX + 1]; + size_t sizes[AV_CRC_MAX + 1]; + uint32_t poly; + int le, bits; + + // Initialize parameters before any test so that different instruction sets + // use the same values. + for (size_t i = 0; i < FF_ARRAY_ELEMS(offsets); ++i) { + offsets[i] = rnd() & 31; + sizes[i] = rnd() % (BUF_SIZE - 1 - offsets[i]); + } + le = rnd() & 1; + bits = 8 + rnd() % 25; // av_crc_init() accepts between 8 and 32 bits + poly = rnd() >> (32 - bits); + for (unsigned i = 0; i < AV_CRC_MAX; ++i) - check_crc(av_crc_get_table(i), tests[i], i); + check_crc(av_crc_get_table(i), tests[i], sizes[i], offsets[i]); struct CustomTest *new = av_mallocz(sizeof(*new)); - static int le, bits; - static uint32_t poly; if (!new) fail(); - if (!ctx_list) { - le = rnd() & 1; - bits = 8 + rnd() % 25; // av_crc_init() accepts between 8 and 32 bits - poly = rnd() >> (32 - bits); - } av_assert0(av_crc_init(new->ctx, le, bits, poly, sizeof(new->ctx)) >= 0); if (ctx_list && !memcmp(ctx_list->ctx, new->ctx, sizeof(new->ctx))) { av_free(new); @@ -120,6 +121,7 @@ void checkasm_check_crc(void) ctx_list = new; } - check_crc(ctx_list->ctx, "custom_polynomial", AV_CRC_MAX); + check_crc(ctx_list->ctx, "custom_polynomial", + sizes[AV_CRC_MAX], offsets[AV_CRC_MAX]); report("crc"); } _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
