alpha handled improperly by ffmpegcolorspace

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

alpha handled improperly by ffmpegcolorspace

Bert Douglas
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?

Thanks much,
Bert Douglas



------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: alpha handled improperly by ffmpegcolorspace

Sebastian Dröge-7
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.

------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users
worldwide. Take advantage of special opportunities to increase revenue and
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

signature.asc (205 bytes) Download Attachment