Commit 176438577a for ffmpeg
commit 176438577affcc4d35b100a6b1139eb018c3964d
Author: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Date: Wed Nov 18 15:03:30 2026 -0800
avcodec/rpza: use QuickTime's 4-colour blend weights
Matches QuickTime 7.7.9 on all 146 frames of FATE rpza2.mov: its 32-bit
ARGB decode >> 3 equals the rgb555le output.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c
index 81886deb02..1ae0536b7d 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 3ad7e4cce1..5c37639bcf 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