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

Nicolas George nicolas.george at normalesup.org
Thu Sep 16 21:50:45 CEST 2010


Le decadi 30 fructidor, an CCXVIII, Reimar Döffinger a écrit :
> Changing the formula as part of an optimization is suboptimal.
> You can calculate / 255 with identical values within the range like this:
> 
> (x + (x >> 8) + 1) >> 8
> 
> (gives the same value as x / 255 for x in [0; 256*256-2])

Unfortunately, this version seems to be as slow as the original version with
the division.

The problem is probably that since x appears twice in the formula, it
requires an additional register.

Therefore, I still think that "(x + 255) >> 8" is the best option, since it
is the fastest, and acceptably accurate.

The fact that it is actually more accurate than the original code is just a
bonus.

> I think the
> if (!k)
>     continue;
> suggestion someone made was a good one, I usually consider it
> good for readability to avoid extra indentation levels.

I am not fond of continue statements for just a few lines, but all right.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mplayer-vfasstestzero-20100916b.diff
Type: text/x-diff
Size: 711 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20100916/6bc5b859/attachment.diff>
-------------- 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/20100916/6bc5b859/attachment.pgp>


More information about the MPlayer-dev-eng mailing list