[FFmpeg-devel] [RFC] support encrypted asf

Uoti Urpala uoti.urpala
Tue Oct 9 00:03:57 CEST 2007


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;
}






More information about the ffmpeg-devel mailing list