Commit e3f2e92f14 for ffmpeg

commit e3f2e92f14449ea500462a4acf35da7ab5ca7511
Author: Rainbaby <r@bgr.jp>
Date:   Fri Aug 28 16:18:07 2026 +0900

    avcodec/cavsdec: clear the residual after a failed dequant

    dequant() writes each coefficient as it goes and only then rejects a
    position past the end, so a failed block left its coefficients in
    h->block for the next block to add through the inverse transform.

    Signed-off-by: Rainbaby <r@bgr.jp>

diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c
index 73212305c0..9b236f519d 100644
--- a/libavcodec/cavsdec.c
+++ b/libavcodec/cavsdec.c
@@ -587,12 +587,13 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb,
         level_buf[i] = level;
         run_buf[i]   = run;
     }
-    if ((ret = dequant(h, level_buf, run_buf, block, dequant_mul[qp],
-                      dequant_shift[qp], i)) < 0)
-        return ret;
-    h->cdsp.cavs_idct8_add(dst, block, stride);
+    ret = dequant(h, level_buf, run_buf, block, dequant_mul[qp],
+                  dequant_shift[qp], i);
+    if (ret >= 0)
+        h->cdsp.cavs_idct8_add(dst, block, stride);
+    /* dequant() can write before it fails, so always clear the block */
     h->bdsp.clear_block(block);
-    return 0;
+    return ret;
 }