GNOME Bugzilla – Bug 639763
[dvbsuboverlay] Green borders around subtitles
Last modified: 2011-03-18 08:34:55 UTC
Created attachment 178532 [details] Subtitle screen shot DVB subtitle overlay draws green, transparent borders around subtitles, see the attached screen shot for an example. I don't see similar borders in other software, e.g. VLC, when I play the same streams. Here's some transport stream files that produce the problem: https://bugs.launchpad.net/me-tv/+bug/624781
Interestingly commit 994156c1b - "dvbsuboverlay: remove unnecessary RGB -> YUV conversion by using YUV palettes" seemingly made the green borders even thicker than before in initial code and also changed the tones of the white fill. The sample media does not seem to use alpha values other than 0 or 255. When observing the look of it before commit 994156c1b, it seems as if it has a green tint next to subtitle overlayed pixels at places where no transparency changes to full transparency in the middle of a 2x2 subsampled block. E.g, the top side of both lines are nicely aligned to the 2x2 blocks, and I can't observe any green tinting above, while it doesn't align with the bottom of a 2x2 block at the bottom of the text, and there's one pixel of green shade. Same with various places on the right and left edges. Looked at it in magnification of a screenshot in gimp. So there it smells like there's some issue with alpha change handling in the I420 blending code, but the shading seemingly being strengthened to go across the 2x2 blocks after change to YUV CLUT palette is weird.
Apparently this is caused by using the average alpha value for all pixels in the 2x2 block, instead of using each pixel's own alpha value. Background color is transparent green, hence the green tint if there are both transparent and opaque pixels in the block.
Created attachment 183582 [details] [review] Fix using alpha values in blitting.
Review of attachment 183582 [details] [review]: Nice work! I was debugging this today as well, and got to alpha values being the problem, but after a break fortunately noticed bugmail from you instead of continuing :) Got around to looking through it, thinking about it and testing some, and indeed this is the issue and the obvious fix. Now I also remember (and re-confirmed) that Finnish DVB Subtitle streams tend to contain green YUV values for the parts where full transparency is declared in the alpha channel, back from the decoding work when I spit those out in raw PNGs. I see you already work inside GIT - maybe you could also commit it with a nice commit message and send that (after possibly tweaking something per this or other comments), so it's easily applied with proper authorship information? ::: gst/dvbsuboverlay/gstdvbsuboverlay.c @@ +657,1 @@ I see you simplify the logic of dealing with this by pre-multiplying U and V channels above. Maybe the same premultiplying logic would be nice for the last block too (for odd height and width), where there's no alpha issue concerns, just for consistencies sake?
Created attachment 183667 [details] [review] Updated patch
Yes this change absolutely makes sense. I wonder why I thought that averaging the alpha was a good idea at all :) commit 9e7d1ba888af466a2625484d3091f701c70e9906 Author: Raimo Järvi <raimo.jarvi@gmail.com> Date: Thu Mar 17 20:19:27 2011 +0200 dvbsuboverlay: Fix using alpha values in blitting. Use each pixel's own alpha value instead of average alpha value when calculating color components. Fixes bug #639763.