[FFmpeg-devel] [PATCH 1/2] libavcodec/dvbsubdec.c: set color to black if fully transparent

Scott Theisen scott.the.elm at gmail.com
Thu Nov 14 08:56:02 EET 2024


From: Isaac Richards <irichards at mythtv.org>

from:
If a dvbsub palette is transparent, force it to be black. Fixes color creep on the one DVB sample I have.
https://github.com/MythTV/mythtv/commit/e7fdb7a3a7f1bcf2fb54a1fc186243ee07db509b
---
 libavcodec/dvbsubdec.c |  5 +++
 tests/ref/fate/sub-dvb | 72 +++++++++++++++++++++---------------------
 2 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index 4553c45b3d..36596e0064 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1127,6 +1127,11 @@ static int dvbsub_parse_clut_segment(AVCodecContext *avctx,
                     return AVERROR_INVALIDDATA;
             }
 
+            if (alpha == 255)
+            {
+                r = g = b = 0;
+            }
+
             if (depth & 0x80 && entry_id < 4)
                 clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha);
             else if (depth & 0x40 && entry_id < 16)
diff --git a/tests/ref/fate/sub-dvb b/tests/ref/fate/sub-dvb
index cbd1801d64..2e221884d2 100644
--- a/tests/ref/fate/sub-dvb
+++ b/tests/ref/fate/sub-dvb
@@ -1,75 +1,75 @@
 #tb 0: 1/1000000
 #media_type 0: subtitle
 #codec_id 0: dvb_subtitle
-0,   15600000,   15600000,   159000,     1168, 0xd0f89d82
+0,   15600000,   15600000,   159000,     1168, 0x2e5d9d97
 0,   15759000,   15759000,   159000,       14, 0x064900eb
-0,   15760000,   15760000,   239000,     1544, 0xe60f1751
+0,   15760000,   15760000,   239000,     1544, 0x624c1766
 0,   15999000,   15999000,   239000,       14, 0x0729010b
-0,   16000000,   16000000,   339000,     1658, 0xbe343093
+0,   16000000,   16000000,   339000,     1658, 0x43cb30a8
 0,   16339000,   16339000,   339000,       14, 0x0809012b
-0,   16340000,   16340000,   599000,     2343, 0xc68f07ef
+0,   16340000,   16340000,   599000,     2343, 0x84570804
 0,   16939000,   16939000,   599000,       14, 0x08e9014b
-0,   16940000,   16940000,   459000,     2568, 0x0ee657b1
+0,   16940000,   16940000,   459000,     2568, 0xdf1457c6
 0,   17399000,   17399000,   459000,       14, 0x09c9016b
-0,   17400000,   17400000,   359000,     3422, 0xba5b63ce
+0,   17400000,   17400000,   359000,     3422, 0xd0a663e3
 0,   17759000,   17759000,   359000,       14, 0x0aa9018b
-0,   17760000,   17760000,   219000,     5078, 0x95b19902
+0,   17760000,   17760000,   219000,     5078, 0xc882992c
 0,   17979000,   17979000,   219000,       14, 0x0b8901ab
-0,   17980000,   17980000,   959000,     5808, 0xc9717b89
+0,   17980000,   17980000,   959000,     5808, 0x74157bb3
 0,   18939000,   18939000,   959000,       14, 0x0c6901cb
-0,   18940000,   18940000,   219000,     6015, 0x0becbfac
+0,   18940000,   18940000,   219000,     6015, 0xd877bfd6
 0,   19159000,   19159000,   219000,       14, 0x064900eb
-0,   19160000,   19160000,   259000,     6519, 0xfcd24d26
+0,   19160000,   19160000,   259000,     6519, 0x1c2b4d50
 0,   19419000,   19419000,   259000,       14, 0x0729010b
-0,   19420000,   19420000,    99000,     7061, 0xf0320408
+0,   19420000,   19420000,    99000,     7061, 0x68770432
 0,   19519000,   19519000,    99000,       14, 0x0809012b
-0,   19520000,   19520000,   219000,     4773, 0x66c93074
+0,   19520000,   19520000,   219000,     4773, 0x6790309e
 0,   19739000,   19739000,   219000,       14, 0x08e9014b
-0,   19740000,   19740000,   219000,     5546, 0x06052c81
+0,   19740000,   19740000,   219000,     5546, 0x859e2cab
 0,   19959000,   19959000,   219000,       14, 0x09c9016b
-0,   19960000,   19960000,   239000,     5754, 0x904f7325
+0,   19960000,   19960000,   239000,     5754, 0x3217734f
 0,   20199000,   20199000,   239000,       14, 0x0aa9018b
-0,   20200000,   20200000,   139000,     6099, 0xe30cde07
+0,   20200000,   20200000,   139000,     6099, 0xbd6ede31
 0,   20339000,   20339000,   139000,       14, 0x0b8901ab
-0,   20340000,   20340000,   799000,     6839, 0x770fcb6c
+0,   20340000,   20340000,   799000,     6839, 0xcad9cb96
 0,   21139000,   21139000,   799000,       14, 0x0c6901cb
-0,   21140000,   21140000,   239000,     4744, 0xa91e1b41
+0,   21140000,   21140000,   239000,     4744, 0xa5231b6b
 0,   21379000,   21379000,   239000,       14, 0x064900eb
-0,   21380000,   21380000,   339000,     5824, 0xcf6d782b
+0,   21380000,   21380000,   339000,     5824, 0x7cb17855
 0,   21719000,   21719000,   339000,       14, 0x0729010b
-0,   21720000,   21720000,  1439000,     6212, 0xabf8f7cf
+0,   21720000,   21720000,  1439000,     6212, 0x98e4f7f9
 0,   23159000,   23159000,  1439000,       14, 0x0809012b
-0,   23160000,   23160000,  1319000,     7082, 0xd7ca10f2
+0,   23160000,   23160000,  1319000,     7082, 0x5381111c
 0,   24479000,   24479000,  1319000,       14, 0x08e9014b
-0,   24480000,   24480000,   219000,     5345, 0x12b2cae0
+0,   24480000,   24480000,   219000,     5345, 0x7151cb0a
 0,   24699000,   24699000,   219000,       14, 0x09c9016b
-0,   24700000,   24700000,   219000,     5765, 0xc7d46192
+0,   24700000,   24700000,   219000,     5765, 0x6b6a61bc
 0,   24919000,   24919000,   219000,       14, 0x0aa9018b
-0,   24920000,   24920000,   599000,     6557, 0xcb995d30
+0,   24920000,   24920000,   599000,     6557, 0xf11f5d5a
 0,   25519000,   25519000,   599000,       14, 0x0b8901ab
-0,   25520000,   25520000,   219000,     7091, 0xe6ea0559
+0,   25520000,   25520000,   219000,     7091, 0x641b0583
 0,   25739000,   25739000,   219000,       14, 0x0c6901cb
-0,   25740000,   25740000,   239000,     7305, 0xb66c404e
+0,   25740000,   25740000,   239000,     7305, 0x56b94078
 0,   25979000,   25979000,   239000,       14, 0x064900eb
-0,   25980000,   25980000,   359000,     7590, 0x0cc2a481
+0,   25980000,   25980000,   359000,     7590, 0xdbc2a4ab
 0,   26339000,   26339000,   359000,       14, 0x0729010b
-0,   26340000,   26340000,   219000,     4629, 0xe18cfea8
+0,   26340000,   26340000,   219000,     4629, 0xcab3fed2
 0,   26559000,   26559000,   219000,       14, 0x0809012b
-0,   26560000,   26560000,   719000,     4785, 0x82043fc0
+0,   26560000,   26560000,   719000,     4785, 0x84c33fea
 0,   27279000,   27279000,   719000,       14, 0x08e9014b
-0,   27280000,   27280000,   459000,     6061, 0xbde7d245
+0,   27280000,   27280000,   459000,     6061, 0x920dd26f
 0,   27739000,   27739000,   459000,       14, 0x09c9016b
-0,   27740000,   27740000,   239000,     6301, 0x92d01a51
+0,   27740000,   27740000,   239000,     6301, 0x8e561a7b
 0,   27979000,   27979000,   239000,       14, 0x0aa9018b
-0,   27980000,   27980000,    99000,     6736, 0xbd25a134
+0,   27980000,   27980000,    99000,     6736, 0x0018a15e
 0,   28079000,   28079000,    99000,       14, 0x0b8901ab
-0,   28080000,   28080000,   219000,     7214, 0x7ef93c13
+0,   28080000,   28080000,   219000,     7214, 0x10583c3d
 0,   28299000,   28299000,   219000,       14, 0x0c6901cb
-0,   28300000,   28300000,   239000,     7366, 0x5bed7fcd
+0,   28300000,   28300000,   239000,     7366, 0x063c7ff7
 0,   28539000,   28539000,   239000,       14, 0x064900eb
-0,   28540000,   28540000,   599000,     4564, 0x7f4c014b
+0,   28540000,   28540000,   599000,     4564, 0x5dc90175
 0,   29139000,   29139000,   599000,       14, 0x0729010b
-0,   29140000,   29140000,   219000,     4637, 0x682626b7
+0,   29140000,   29140000,   219000,     4637, 0x529d26e1
 0,   29359000,   29359000,   219000,       14, 0x0809012b
-0,   29360000,   29360000,  1679000,     5358, 0x29e30c48
+0,   29360000,   29360000,  1679000,     5358, 0x8aa40c72
 0,   31039000,   31039000,  1679000,       14, 0x08e9014b
-- 
2.43.0



More information about the ffmpeg-devel mailing list