[FFmpeg-devel] [PATCH] vf_overlay: add support to RGBA packed input and output
Mark Himsley
mark at mdsh.com
Sat Oct 29 18:27:16 CEST 2011
On 29/10/2011 16:26, Michael Niedermayer wrote:
> On Sat, Oct 29, 2011 at 04:47:41PM +0200, Stefano Sabatini wrote:
>> Regarding the second patch, I kept Mark's code but after some time
>> spent tinkering on it I couldn't figure out the meaning of the
>> equation:
>
>> d[da] = ( (d[da]<< 8) + (256 - d[da]) * s[sa] )>> 8;
>
> correcter:
> d += ((255 - d) * s + 128) / 255;
>
> and /255 can be done by multiplication and shift
Sure, Michael is right.
I tried to optimise out the /255, and my code was within 1 of the
correct result and never altered the main alpha if the overlay alpha was 0.
In the intervening months between writing that code and Stefano moulding
it into something workable, I have learnt that GCC is better at
optimising maths than I am :)
--
Mark
More information about the ffmpeg-devel
mailing list