PR #26189 opened by Baptiste Coudurier (bcoudurier)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26189
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26189.patch

The two middle colours of a 4-colour block are now blended with quarter 
weights, (A + 3B) / 4 and (3A + B) / 4, instead of 11/32 and 21/32. With this 
change the decoder matches QuickTime 7 at 5 bits on every frame of FATE 
rpza2.mov (146/146) and of an Apple Video file encoded by QuickTime 7 (90/90).

🤖 Generated with [Claude Code](https://claude.com/claude-code)



From 3c210c3b59343ed3d4326717ce07c0dc66399cfe Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Wed, 18 Nov 2026 15:03:30 -0800
Subject: [PATCH] avcodec/rpza: use QuickTime's 4-colour blend weights

Matches QuickTime 7 on every frame of FATE rpza2.mov.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Baptiste Coudurier <[email protected]>
---
 libavcodec/rpza.c   | 12 ++++-----
 tests/ref/fate/rpza | 60 ++++++++++++++++++++++-----------------------
 2 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c
index 81886deb02e..1ae0536b7de 100644
--- a/libavcodec/rpza.c
+++ b/libavcodec/rpza.c
@@ -177,20 +177,20 @@ static int rpza_decode_stream(RpzaContext *s)
             /* red components */
             ta = (colorA >> 10) & 0x1F;
             tb = (colorB >> 10) & 0x1F;
-            color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10;
-            color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10;
+            color4[1] |= ((ta + 3 * tb) >> 2) << 10;
+            color4[2] |= ((3 * ta + tb) >> 2) << 10;
 
             /* green components */
             ta = (colorA >> 5) & 0x1F;
             tb = (colorB >> 5) & 0x1F;
-            color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5;
-            color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5;
+            color4[1] |= ((ta + 3 * tb) >> 2) << 5;
+            color4[2] |= ((3 * ta + tb) >> 2) << 5;
 
             /* blue components */
             ta = colorA & 0x1F;
             tb = colorB & 0x1F;
-            color4[1] |= ((11 * ta + 21 * tb) >> 5);
-            color4[2] |= ((21 * ta + 11 * tb) >> 5);
+            color4[1] |= ((ta + 3 * tb) >> 2);
+            color4[2] |= ((3 * ta + tb) >> 2);
 
             if (bytestream2_get_bytes_left(&s->gb) < n_blocks * 4)
                 return AVERROR_INVALIDDATA;
diff --git a/tests/ref/fate/rpza b/tests/ref/fate/rpza
index 3ad7e4cce15..5c37639bcf3 100644
--- a/tests/ref/fate/rpza
+++ b/tests/ref/fate/rpza
@@ -3,33 +3,33 @@
 #codec_id 0: rawvideo
 #dimensions 0: 320x240
 #sar 0: 0/1
-0,          0,          0,        1,   230400, 0x26a4728c
-0,          1,          1,        1,   230400, 0xa5ff0a21
-0,          2,          2,        1,   230400, 0x479d767d
-0,          3,          3,        1,   230400, 0xc619cd01
-0,          4,          4,        1,   230400, 0x1d377157
-0,          5,          5,        1,   230400, 0x1d377157
-0,          6,          6,        1,   230400, 0x0941c629
-0,          7,          7,        1,   230400, 0xe64b3a93
-0,          8,          8,        1,   230400, 0x28493fd7
-0,          9,          9,        1,   230400, 0x18c77af2
-0,         10,         10,        1,   230400, 0x18c77af2
-0,         11,         11,        1,   230400, 0x5a542008
-0,         12,         12,        1,   230400, 0x5a542008
-0,         13,         13,        1,   230400, 0x3b1a34fd
-0,         14,         14,        1,   230400, 0x77d34944
-0,         15,         15,        1,   230400, 0x50ac218c
-0,         16,         16,        1,   230400, 0xcb999f16
-0,         17,         17,        1,   230400, 0xe1ce9f19
-0,         18,         18,        1,   230400, 0xb10b4264
-0,         19,         19,        1,   230400, 0x61207031
-0,         20,         20,        1,   230400, 0x81626d5b
-0,         21,         21,        1,   230400, 0x81626d5b
-0,         22,         22,        1,   230400, 0x1cb59751
-0,         23,         23,        1,   230400, 0x316e6962
-0,         24,         24,        1,   230400, 0x4c01b829
-0,         25,         25,        1,   230400, 0x276e32bc
-0,         26,         26,        1,   230400, 0x276e32bc
-0,         27,         27,        1,   230400, 0xe251117a
-0,         28,         28,        1,   230400, 0xe251117a
-0,         29,         29,        1,   230400, 0x41b7f098
+0,          0,          0,        1,   230400, 0xc0b9c412
+0,          1,          1,        1,   230400, 0x7f236481
+0,          2,          2,        1,   230400, 0xce07c2b8
+0,          3,          3,        1,   230400, 0x4a6d31c2
+0,          4,          4,        1,   230400, 0x90e1c5ce
+0,          5,          5,        1,   230400, 0x90e1c5ce
+0,          6,          6,        1,   230400, 0x83bd17a4
+0,          7,          7,        1,   230400, 0x43cb9c39
+0,          8,          8,        1,   230400, 0xa006a677
+0,          9,          9,        1,   230400, 0x904cdcbc
+0,         10,         10,        1,   230400, 0x904cdcbc
+0,         11,         11,        1,   230400, 0x4a7e86cf
+0,         12,         12,        1,   230400, 0x4a7e86cf
+0,         13,         13,        1,   230400, 0xb21f9a20
+0,         14,         14,        1,   230400, 0xdd66a4bd
+0,         15,         15,        1,   230400, 0x24e78656
+0,         16,         16,        1,   230400, 0xd2bef9ba
+0,         17,         17,        1,   230400, 0x56900218
+0,         18,         18,        1,   230400, 0x782193b1
+0,         19,         19,        1,   230400, 0xd38cc2a2
+0,         20,         20,        1,   230400, 0xea94c863
+0,         21,         21,        1,   230400, 0xea94c863
+0,         22,         22,        1,   230400, 0xcaa3f8b8
+0,         23,         23,        1,   230400, 0x5c27cbe8
+0,         24,         24,        1,   230400, 0x3a021c5c
+0,         25,         25,        1,   230400, 0x77aa9ce0
+0,         26,         26,        1,   230400, 0x77aa9ce0
+0,         27,         27,        1,   230400, 0xd62479f1
+0,         28,         28,        1,   230400, 0xd62479f1
+0,         29,         29,        1,   230400, 0x9e19641e
-- 
2.54.1

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

Reply via email to