[FFmpeg-devel] [RFC] support encrypted asf

Michael Niedermayer michaelni
Tue Oct 9 13:31:54 CEST 2007


Hi

On Tue, Oct 09, 2007 at 01:03:57AM +0300, Uoti Urpala wrote:
> 
> On Mon, 2007-10-08 at 21:29 +0200, Michael Niedermayer wrote:
> > or a LUT based variant
> > 
> > static uint32_t inverse2(uint32_t v) {
> >     uint32_t a,b;
> >     a= inv[v&255];
> > 
> >     b= (a*v)>>8;
> >     b*= a;
> >     a-= b<<8;
> >     b= (a*v)>>16;
> >     b*= a;
> > 
> >     return a - (b<<16);
> > }
> > 
> > for(i=1; i<256; i+=2)
> >     inv[i]= inverse(i);
> 
> In my test the following was about twice as fast (though minimizing the
> multiply sizes through shifts could help on some architecture):
> 
> static uint32_t inverse2(uint32_t v) {
>     uint32_t i = inv[v & 255];
>     i *= 2 - v * i;
>     i *= 2 - v * i;
>     return i;
> }
> 
> Which also gives the following tableless variant:
> 
> static uint32_t inverse3(uint32_t v) {
>     uint32_t i;
>     i =  2 - v;
>     i *= 2 - v * i;
>     i *= 2 - v * i;
>     i *= 2 - v * i;
>     i *= 2 - v * i;
>     return i;
> }

or even faster:

static uint32_t inverse4(uint32_t v) {
    int i = v * v * v;
    i *= 2 - v * i;
    i *= 2 - v * i;
    i *= 2 - v * i;
    return i;
}

and i would not be surprised if that can be simplified further ...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071009/0e5e42ce/attachment.pgp>



More information about the ffmpeg-devel mailing list