This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 8984d7c239095f5fdaf2c55665386fdb0aa42183
Author:     Andreas Rheinhardt <[email protected]>
AuthorDate: Thu Jul 30 13:41:56 2026 +0200
Commit:     Andreas Rheinhardt <[email protected]>
CommitDate: Mon Aug 3 09:20:39 2026 +0200

    tests/checkasm/sbcdsp: Avoid using static variable
    
    This has been done in order to use the same number of blocks
    for benchmarks of different instruction sets to
    make the benchmarks comparable. Yet it has a downside:
    Only one number would ever be executed when using --repeat.
    Luckily libcheckasm makes it easy to fix this:
    At the start of every test function, the internal state
    of rnd() is reset, so that it produces the same sequence
    of random values. So just removing the static variable works.
    
    This would also makes this test trivially parallelizable.
    
    Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/sbcdsp.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tests/checkasm/sbcdsp.c b/tests/checkasm/sbcdsp.c
index 802eb430ed..b6170ca04f 100644
--- a/tests/checkasm/sbcdsp.c
+++ b/tests/checkasm/sbcdsp.c
@@ -69,7 +69,7 @@ static void check_sbc_analyze(SBCDSPContext *sbcdsp)
     report("sbc_analyze");
 }
 
-static void check_sbc_calc_scalefactors(const SBCDSPContext *const sbcdsp)
+static void check_sbc_calc_scalefactors(const SBCDSPContext *const sbcdsp, int 
blocks)
 {
     DECLARE_ALIGNED(SBC_ALIGN,  int32_t, sb_sample_f)[16][2][8];
     DECLARE_ALIGNED(SBC_ALIGN, uint32_t, scale_factor_ref)[2][8];
@@ -79,9 +79,6 @@ static void check_sbc_calc_scalefactors(const SBCDSPContext 
*const sbcdsp)
                        uint32_t scale_factor[2][8],
                        int blocks, int channels, int subbands);
 
-    static int blocks = 0;
-    if (!blocks)
-        blocks = ((const int[]){4, 8, 12, 15, 16})[rnd() % 5];
     int inited = 0;
 
     for (int ch = 1; ch <= 2; ++ch) {
@@ -111,11 +108,12 @@ static void check_sbc_calc_scalefactors(const 
SBCDSPContext *const sbcdsp)
 void checkasm_check_sbcdsp(void)
 {
     SBCDSPContext sbcdsp;
+    int blocks = ((const int[]){4, 8, 12, 15, 16})[rnd() % 5];
 
     ff_sbcdsp_init(&sbcdsp);
 
     check_sbc_analyze(&sbcdsp);
 
-    check_sbc_calc_scalefactors(&sbcdsp);
+    check_sbc_calc_scalefactors(&sbcdsp, blocks);
     report("calc_scalefactors");
 }

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to