[FFmpeg-devel] [RFC] support encrypted asf
Michael Niedermayer
michaelni
Tue Oct 9 14:06:26 CEST 2007
Hi
On Tue, Oct 09, 2007 at 01:31:54PM +0200, Michael Niedermayer wrote:
> 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 ...
actually the following would in theory be better
static uint_fast32_t inverse4(uint_fast32_t v) {
uint_fast32_t i = v * v * v;
i *= 2 - v * i;
i *= 2 - v * i;
i *= 2 - v * i;
return i;
}
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- 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/9969d4a7/attachment.pgp>
More information about the ffmpeg-devel
mailing list