[FFmpeg-devel] [PATCH] DES en-/decryption

Reimar Döffinger Reimar.Doeffinger
Thu Oct 18 12:55:38 CEST 2007


Hello,
On Sun, Oct 14, 2007 at 11:40:43PM +0200, Michael Niedermayer wrote:
> > +        in = (in << 32) | (in >> 32);
> > +        in ^= f_res;
> > +    }
> 
> maybe
> 
> for (i = 0; i < 8; i++) {
>     in ^= f_func(in    , K[decrypt ? 15 - i : i]) << 32;
>     in ^= f_func(in>>32, K[decrypt ? 15 - i : i]);
> }
> 
> would be faster/smaller? maybe not ...

I tried with
>     for (i = 0; i < 16; i++) {
>         in ^= (uint64_t)f_func(in      , K[decrypt ^ i]) << 32;
>         i++;
>         in ^=           f_func(in >> 32, K[decrypt ^ i]);
> }

And it is almost 1% slower.

> > +    in = (in << 32) | (in >> 32);
> > +    // reverse shuffle used to ease hardware implementations
> > +    in = shuffle_inv(in, IP_shuffle, sizeof(IP_shuffle));
> 
> if the inv table is split off and shuffle is used than the 32bit swap can
> be mergeed into the table

That saves one single instruction per 8 bytes of data, that seems an
(effort + obfuscation) / speedup ratio is not worth it by far...
Actually, I'm almost sure it saves nothing at all on x86_32 when
shuffle_inv is inlined.

Greetings,
Reimar D?ffinger




More information about the ffmpeg-devel mailing list