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

Git pushed a commit to branch master
in repository ffmpeg.

commit b3fb13e8dd6ef2451acaffbe84f178d859f50f68
Author:     Thomas Guilbert <[email protected]>
AuthorDate: Thu May 21 01:22:37 2026 +0000
Commit:     michaelni <[email protected]>
CommitDate: Thu Jul 2 02:49:06 2026 +0000

    Guard lpc methods in flacdsp and add tests
    
    This commit adds additional guards for the RISC-V lpc variants.
    
    It also adds tests to exercise the guarded paths in checkasm/flacdsp.c.
---
 libavcodec/riscv/flacdsp_rvv.S | 11 ++++++----
 tests/checkasm/flacdsp.c       | 50 ++++++++++++++++++++++++++++++++----------
 2 files changed, 45 insertions(+), 16 deletions(-)

diff --git a/libavcodec/riscv/flacdsp_rvv.S b/libavcodec/riscv/flacdsp_rvv.S
index 0db81726f1..b04e7c7d98 100644
--- a/libavcodec/riscv/flacdsp_rvv.S
+++ b/libavcodec/riscv/flacdsp_rvv.S
@@ -22,11 +22,11 @@
 
 func ff_flac_lpc16_rvv, zve32x, b
         lpad    0
+        ble     a4, a2, 2f
         vtype_vli t0, a2, t2, e32, ta, ma
         vsetvl  zero, a2, t0
         vle32.v v8, (a1)
         sub     a4, a4, a2
-        blez    a4, 2f
         vle32.v v16, (a0)
         sh2add  a0, a2, a0
         vmv.s.x v0, zero
@@ -49,6 +49,7 @@ endfunc
 #if (__riscv_xlen == 64)
 func ff_flac_lpc32_rvv, zve64x, zba
         lpad    0
+        ble     a4, a2, 2f
         addi    t2, a2, -16
         ble     t2, zero, ff_flac_lpc32_rvv_simple
         vsetivli zero, 1, e64, m1, ta, ma
@@ -75,12 +76,13 @@ func ff_flac_lpc32_rvv, zve64x, zba
         sw      t0, (a0)
         addi    a0, a0, 4
         bnez    a4, 1b
-
+2:
         ret
 endfunc
 
 func ff_flac_lpc32_rvv_simple, zve64x, b
         lpad    0
+        ble     a4, a2, 2f
         vtype_vli t3, a2, t1, e64, ta, ma
         vntypei t2, t3
         vsetvl  zero, a2, t3 // e64
@@ -104,12 +106,13 @@ func ff_flac_lpc32_rvv_simple, zve64x, b
         sw      t0, (a0)
         addi    a0, a0, 4
         bnez    a4, 1b
-
+2:
         ret
 endfunc
 
 func ff_flac_lpc33_rvv, zve64x, b
         lpad    0
+        ble     a5, a3, 2f
         vtype_vli t0, a3, t1, e64, ta, ma
         vsetvl  zero, a3, t0
         vmv.s.x v0, zero
@@ -132,7 +135,7 @@ func ff_flac_lpc33_rvv, zve64x, b
         sd      t0, (a0)
         addi    a0, a0, 8
         bnez    a5, 1b
-
+2:
         ret
 endfunc
 #endif
diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c
index 6f8e8817b5..d8a10a6b57 100644
--- a/tests/checkasm/flacdsp.c
+++ b/tests/checkasm/flacdsp.c
@@ -74,12 +74,25 @@ static void check_lpc(int pred_order, int bps)
     for (int i = 0; i < BUF_SIZE; i++)
         dst[i] = sign_extend(rnd(), bps);
 
-    memcpy(dst0, dst, BUF_SIZE * sizeof (int32_t));
-    memcpy(dst1, dst, BUF_SIZE * sizeof (int32_t));
-    call_ref(dst0, coeffs, pred_order, qlevel, BUF_SIZE);
-    call_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE);
-    if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int32_t)) != 0)
-       fail();
+    const int test_lens[] = {
+        0,
+        pred_order - 1,
+        pred_order,
+        pred_order + 1,
+        BUF_SIZE,
+    };
+
+    for (int k = 0; k < FF_ARRAY_ELEMS(test_lens); k++) {
+        int len = test_lens[k];
+        if (len < 0 || len > BUF_SIZE) continue;
+
+        memcpy(dst0, dst, BUF_SIZE * sizeof (int32_t));
+        memcpy(dst1, dst, BUF_SIZE * sizeof (int32_t));
+        call_ref(dst0, coeffs, pred_order, qlevel, len);
+        call_new(dst1, coeffs, pred_order, qlevel, len);
+        if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int32_t)) != 0)
+           fail();
+    }
     bench_new(dst, coeffs, pred_order, qlevel, BUF_SIZE);
 }
 
@@ -103,12 +116,25 @@ static void check_lpc33(int pred_order)
         dst[i] = sign_extend64(((int64_t)rnd() << 1) | (rnd() & 1), 33);
     }
 
-    memcpy(dst0, dst, BUF_SIZE * sizeof (int64_t));
-    memcpy(dst1, dst, BUF_SIZE * sizeof (int64_t));
-    call_ref(dst0, residuals, coeffs, pred_order, qlevel, BUF_SIZE);
-    call_new(dst1, residuals, coeffs, pred_order, qlevel, BUF_SIZE);
-    if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int64_t)) != 0)
-       fail();
+    const int test_lens[] = {
+        0,
+        pred_order - 1,
+        pred_order,
+        pred_order + 1,
+        BUF_SIZE,
+    };
+
+    for (int k = 0; k < FF_ARRAY_ELEMS(test_lens); k++) {
+        int len = test_lens[k];
+        if (len < 0 || len > BUF_SIZE) continue;
+
+        memcpy(dst0, dst, BUF_SIZE * sizeof (int64_t));
+        memcpy(dst1, dst, BUF_SIZE * sizeof (int64_t));
+        call_ref(dst0, residuals, coeffs, pred_order, qlevel, len);
+        call_new(dst1, residuals, coeffs, pred_order, qlevel, len);
+        if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int64_t)) != 0)
+           fail();
+    }
     bench_new(dst, residuals, coeffs, pred_order, qlevel, BUF_SIZE);
 }
 

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

Reply via email to