[MPlayer-dev-eng] [PATCH] vf_ass: avoid a division

Nicolas George nicolas.george at normalesup.org
Fri Sep 17 21:36:24 CEST 2010


Le jour de la Vertu, an CCXVIII, Reimar Döffinger a écrit :
> > Why aren't you using the method from the original patch anymore?
> > It would still remove one shift and one add and should reduce
> > the rounding errors that appear with above code for small k.

Because the trivial equivalent to (x+255)>>8 for 255² does not work.

> Actually I think you should try something like
> opacity += opacity << 8; // *258, approximates 256*256/255/255

I hadn't thought of tweaking k that way to make it work. I will try various
methods to see which one is fastest and accurate enough. I'll keep in touch.

In the meantime...

> if (!k)
>     continue;

... is there any objection for me to commit this one?

> Note that the constant add possibly should be tweaked a bit.
> You could also use *129 instead of *258 in case the above
> can overflow or you'd like to be able to use signed ints.

I think I will start with *129, since the one you wrote above was *257
rather than *258; *258 would require one more shift for no useful reason.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20100917/56e4b7cf/attachment.pgp>


More information about the MPlayer-dev-eng mailing list