]> git.sesse.net Git - movit/blob - overlay_effect.frag
Add input support for packed 10-bit Y'CbCr.
[movit] / overlay_effect.frag
1 // It's actually (but surprisingly) not correct to do a mix() here;
2 // it would be if we had postmultiplied alpha and didn't have to worry
3 // about alpha in the bottom layer, but given that we use premultiplied
4 // alpha all over, top shouldn't actually be multiplied by anything.
5 //
6 // These formulas come from Wikipedia:
7 //
8 //   http://en.wikipedia.org/wiki/Alpha_compositing
9 //
10 // We use the associative version given. However, note that since we want
11 // _output_ to be premultiplied, C_o from Wikipedia is not what we want,
12 // but rather c_o (which is not explicitly given, but obviously is just
13 // C_o without the division by alpha_o).
14
15 vec4 FUNCNAME(vec2 tc) {
16 // SWAP_INPUTS will be #defined to 1 if we want to swap the two inputs,
17 #if SWAP_INPUTS
18         vec4 bottom = INPUT2(tc);
19         vec4 top = INPUT1(tc);
20 #else
21         vec4 bottom = INPUT1(tc);
22         vec4 top = INPUT2(tc);
23 #endif
24         return top + (1.0 - top.a) * bottom;
25 }
26
27 #undef SWAP_INPUTS