[Bug 797169] compositor: Remove crossfade property and implement a more extensible interface like in glvideomixer

GStreamer (GNOME Bugzilla) bugzilla at gnome.org
Mon Sep 24 10:44:39 UTC 2018


https://bugzilla.gnome.org/show_bug.cgi?id=797169

--- Comment #15 from Sebastian Dröge (slomo) <slomo at coaxion.net> ---
(In reply to Thibault Saunier from comment #14)
>
> > Especially it's not clear to me what exact blending behaviour you need (both
> > with only two pads, but also with >2 and what should happen with the
> > background), and why maybe the "weird" behaviours (see what I wrote above
> > but also Matthew) in the current crossfade mode are actually required.
> 
> We require the current crossfade behaviour with 2 pads, our plans was to
> rely on the > 2 pads behavior but we can live without it without much
> trouble, we do not care about the background issue.

Do you know why you need the current behaviour though, with regards to
background handling? Why do you blend both pads, and then blend them with the
background (instead of just overwriting the background)?

The GitLab issue / former phab issue mentions that what you need is
alpha-additive blending between the two pads in question.

That is (note that dst is the background, so the first pad with its own alpha
property applied already!):
>   out[alpha] = min(1, src[alpha] * alpha + dst[alpha])
>   out[color] = (src[color] + dst[color]) / out[alpha]

Which without pre-multiplied alpha is
>   out[alpha] = min(1, src[alpha] * alpha + dst[alpha])
>   out[color] = src[color] * src[alpha] * alpha + dst[color] * dst[alpha]

The "additive" code however currently calculates (according to its comments):

>   out[alpha] = src[alpha] * alpha + dst[alpha] * (1 - src[alpha] * alpha) ** 2
>   out[color] = src[color] * src[alpha] * alpha + dst[color] * (1 - src[alpha] * alpha) ** 2
>   (note the ** 2 here !)

I'm not sure what the idea behind that calculation is.

-------

>From what I understand what you want overall is that the alpha is the sum of
both alphas with crossfading ratio built-in:

>   out[alpha] = min(1, src[alpha] * alpha_src * crossfade + dst[alpha] * alpha_dst * (1 - crossfade), where alpha_X are the alpha properties of the relevant pads
>   out[color] = src[color] * src[alpha] * alpha_src * crossfade + dst[color] * dst[alpha] * alpha_dst * (1 - crossfade)

Which is what you get from what I proposed above:

1) first pad on background with operator=SRC, alpha=alpha_dst * (1 - crossfade)

>  out[alpha] = src[alpha] * alpha_dst * (1 - crossfade)
>  out[color] = src[color]

2) second pad with operator=ADD, alpha=alpha_src * crossfade

>  out[alpha] = min(1, src[alpha] * alpha_src * crossfade + dst[alpha]) = {inserting step 1 to do it all in one go} min(1, src[alpha] * alpha_src * crossfade + dst[alpha] * alpha_dst * (1 - crossfade))
>  out[color] = src[color] * src[alpha] * alpha_src * crossfade + dst[color] * dst[alpha] = {inserting step 1 to do it all in one go} src[color] * src[alpha] * alpha_src * crossfade + dst[color] * dst[alpha] * alpha_dst * (1 - crossfade)


Also Bugzilla is kind of annoying for writing comments like this.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list