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

Git pushed a commit to branch master
in repository ffmpeg.

commit 277dd7dbe5b37b4bcbab470e51b06aa80cf3e271
Author:     Rainbaby <[email protected]>
AuthorDate: Tue Nov 10 08:26:16 2026 +0900
Commit:     Zhao Zhili <[email protected]>
CommitDate: Wed Nov 11 09:37:47 2026 +0000

    avcodec/cavsdsp: clip the inverse transform as specified
    
    GB/T 20090.2-2013 9.8.2 and GY/T 257.1-2012 9.7 clip both passes to
    16 bits; the C code clipped neither, so some conformant blocks came
    out wrong. The rounding bias moves into the second pass so the first
    pass clips what the standard clips.
    
    Signed-off-by: Rainbaby <[email protected]>
---
 libavcodec/cavsdsp.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavcodec/cavsdsp.c b/libavcodec/cavsdsp.c
index 8b2fa2dde9..684ce290ea 100644
--- a/libavcodec/cavsdsp.c
+++ b/libavcodec/cavsdsp.c
@@ -196,8 +196,6 @@ static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, 
ptrdiff_t stride)
     int i;
     int16_t (*src)[8] = (int16_t(*)[8])block;
 
-    src[0][0] += 8;
-
     for( i = 0; i < 8; i++ ) {
         const int a0 = 3 * src[i][1] - 2 * src[i][7];
         const int a1 = 3 * src[i][3] + 2 * src[i][5];
@@ -219,15 +217,16 @@ static void cavs_idct8_add_c(uint8_t *dst, int16_t 
*block, ptrdiff_t stride)
         const int b2 = a5 - a7;
         const int b3 = a4 - a6;
 
-        src[i][0] = (b0 + b4) >> 3;
-        src[i][1] = (b1 + b5) >> 3;
-        src[i][2] = (b2 + b6) >> 3;
-        src[i][3] = (b3 + b7) >> 3;
-        src[i][4] = (b3 - b7) >> 3;
-        src[i][5] = (b2 - b6) >> 3;
-        src[i][6] = (b1 - b5) >> 3;
-        src[i][7] = (b0 - b4) >> 3;
+        src[i][0] = av_clip_int16(b0 + b4) >> 3;
+        src[i][1] = av_clip_int16(b1 + b5) >> 3;
+        src[i][2] = av_clip_int16(b2 + b6) >> 3;
+        src[i][3] = av_clip_int16(b3 + b7) >> 3;
+        src[i][4] = av_clip_int16(b3 - b7) >> 3;
+        src[i][5] = av_clip_int16(b2 - b6) >> 3;
+        src[i][6] = av_clip_int16(b1 - b5) >> 3;
+        src[i][7] = av_clip_int16(b0 - b4) >> 3;
     }
+    /* the second pass clip is covered by av_clip_uint8() */
     for( i = 0; i < 8; i++ ) {
         const int a0 = 3 * src[1][i] - 2 * src[7][i];
         const int a1 = 3 * src[3][i] + 2 * src[5][i];
@@ -241,8 +240,8 @@ static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, 
ptrdiff_t stride)
 
         const int a7 = 4 * src[2][i] - 10 * src[6][i];
         const int a6 = 4 * src[6][i] + 10 * src[2][i];
-        const int a5 = 8 * (src[0][i] - src[4][i]);
-        const int a4 = 8 * (src[0][i] + src[4][i]);
+        const int a5 = 8 * (src[0][i] - src[4][i]) + 64;
+        const int a4 = 8 * (src[0][i] + src[4][i]) + 64;
 
         const int b0 = a4 + a6;
         const int b1 = a5 + a7;

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to