[gst-devel] alpha handled improperly by ffmpegcolorspace

Sebastian Dröge sebastian.droege at collabora.co.uk
Sun Aug 29 10:35:23 CEST 2010


On Sat, 2010-08-28 at 11:05 -0500, Bert Douglas wrote:
> When converting from RGBA to RGB, ffmpegcolorspace simply throws away
> alpha.
> 
> This is not compatible with videomixer, which uses "premultiplied"
> alpha.
> In other words, the color components have been multiplied by alpha.
> 
> When using pre-multiplied alpha it is necessary to divide color values
> by alpha when converting back to regular rgb.
> 
> This is correct:
>     in:  RGBA
>     out: rgb
>     action:
>          r = R/A
>          g = G/A
>          b = B/A
> 
> But instead what actually happens is:
>     r = R
>     g = G
>     b = B
> 
> This problem is not specific to rgb but also happens in yuv.
> 
> I am willing to write some code to fix this.  But ffmpegcolorspace has
> so many layers of macros that I am afraid to touch it.
> 
> Can someone advise me on an easy way to fix this?

That's not really a bug. What you're proposing is to blend the input
over a black, opaque frame. That's one way to transform frames with
alpha channel to frames without, yes. But it's not the best or only way
to do it.

It might make sense to write an element that transforms ARGB/AYUV by
multiplying the other components with the alpha and then passing this
through ffmpegcolorspace will give the results you want.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20100829/3e8d6ac4/attachment.pgp>


More information about the gstreamer-devel mailing list