GNOME Bugzilla – Bug 739695
assrender poorly handles transparency
Last modified: 2014-11-09 14:13:00 UTC
Created attachment 290061 [details] this is how the ass images look like (BGRA) before blending i'm trying to render ass subtitles on top of "empty" frames so that i can blit them afterwards, expecting that the pixels that actually have subtitles rendered become visible, and the rest ("the background") stays transparent. currently, the output frames keep the input alpha everywhere in the image, so i can either blit nothing, or mask my video with the background color. the problem may be that the assrender blitting function tries to create a premultiplied bitmap. i did some funny ascii art output though ^_^ it looks like in case of a fully transparent input pixel (alpha = 0x00), it doesn't do premultiplication but instead keeps the alpha. that's visible in the log (i'm simply doing a printf("%02x%02x%02x%02x ",dst[0],dst[1],dst[2],dst[3]); in the blit function) however, the transparency byte of the ass images seems to get overwritten somewhere later on during the composition process, maybe the gst_video_overlay_composition_blend operation
so i went through and wrote the raw data into files at different spots and it turns out that the bitmaps get rendered correctly and the alpha channels breaks once gst_video_overlay_composition_blend is called in gst_ass_render_chain_video() it doesn't make a difference whether the overlay rectangle was created with GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA or GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE
There are some patches in Bugzilla about improving the handling of src alpha and using the proper blending operation. I can't find them right now, but they should solve your problem.
Arnaud's patch https://bugzilla.gnome.org/attachment.cgi?id=263194 from https://bugzilla.gnome.org/show_bug.cgi?id=681447 actually does what I need!
Great. Perhaps you could contribute a unit test for the issue then :) *** This bug has been marked as a duplicate of bug 681447 ***