1 /* FFdecsa -- fast decsa algorithm
2  *
3  * Copyright (C) 2007 Dark Avenger
4  *               2003-2004  fatih89r
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef FFTABLE_H
22 #define FFTABLE_H
23 
FFTABLEIN(unsigned char * tab,int g,unsigned char * data)24 void static inline FFTABLEIN(unsigned char *tab, int g, unsigned char *data)
25 {
26 #if 0
27   *(((int *)tab)+2*g)=*((int *)data);
28   *(((int *)tab)+2*g+1)=*(((int *)data)+1);
29 #else
30   *(((long long *)tab)+g)=*((long long *)data);
31 #endif
32 }
33 
FFTABLEOUT(unsigned char * data,unsigned char * tab,int g)34 void static inline FFTABLEOUT(unsigned char *data, unsigned char *tab, int g)
35 {
36 #if 1
37   *((int *)data)=*(((int *)tab)+2*g);
38   *(((int *)data)+1)=*(((int *)tab)+2*g+1);
39 #else
40   *((long long *)data)=*(((long long *)tab)+g);
41 #endif
42 }
43 
FFTABLEOUTXORNBY(int n,unsigned char * data,unsigned char * tab,int g)44 void static inline FFTABLEOUTXORNBY(int n, unsigned char *data, unsigned char *tab, int g)
45 {
46   int j;
47   for(j=0;j<n;j++) *(data+j)^=*(tab+8*g+j);
48 }
49 
50 #undef XOREQ_BEST_BY
XOREQ_BEST_BY(unsigned char * d,unsigned char * s)51 static inline void XOREQ_BEST_BY(unsigned char *d, unsigned char *s)
52 {
53 	XOR_BEST_BY(d, d, s);
54 }
55 
56 #endif //FFTABLE_H
57