[FFmpeg-devel] [PATCH 2/2] fic: Support rendering cursors

Michael Niedermayer michaelni at gmx.at
Wed Apr 23 00:11:41 CEST 2014


On Tue, Apr 22, 2014 at 09:30:13PM +0100, Derek Buitenhuis wrote:
> On 4/21/2014 9:48 PM, Michael Niedermayer wrote:
> >> +    for (i = 0; i < size; i++)
> >> +        dst[i] = (dst[i] * (256 - alpha[i]) + src[i] * alpha[i]) >> 8;
> > 
> > this would be simpler:
> > dst[i] +=  ((src[i] - dst[i]) * alpha[i]) >> 8;
> 
> Done.

> 
> >> +        planes[0][i] = av_clip_uint8((( 25 * ptr[0] + 129 * ptr[1] +  66 * ptr[2]) / 255) + 16);
> >> +        planes[1][i] = av_clip_uint8(((-38 * ptr[0] + 112 * ptr[1] + -74 * ptr[2]) / 255) + 128);
> >> +        planes[2][i] = av_clip_uint8(((-18 * ptr[0] + 112 * ptr[1] + -94 * ptr[2]) / 255) + 128);
> > 
> > the clipping seems redundant
> 
> I'm not entirely sure if it can over/underflow with these equations (I got them from the binary decoder).

*ptr is uint8 so its value is something from 0 to 255

25 * ptr[0] + 129 * ptr[1] +  66 * ptr[2]
can at lowest be 0 and at highest be (25+129+66)*255
(25+129+66)*255 / 255 = 220
and 220 + 16 is 236
so i dont see how this could overflow or underflow

similar with the other 2 equations

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140423/86b3d545/attachment.asc>


More information about the ffmpeg-devel mailing list