SASC
DVBSoftCAM

parallel_064_8char.h

Go to the documentation of this file.
00001 /* FFdecsa -- fast decsa algorithm
00002  *
00003  * Copyright (C) 2003-2004  fatih89r
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  */
00019 
00020 
00021 struct group_t{
00022   unsigned char s1,s2,s3,s4,s5,s6,s7,s8;
00023 };
00024 typedef struct group_t group;
00025 
00026 #define GROUP_PARALLELISM 64
00027 
00028 group static inline FF0(){
00029   group res;
00030   res.s1=0x0;
00031   res.s2=0x0;
00032   res.s3=0x0;
00033   res.s4=0x0;
00034   res.s5=0x0;
00035   res.s6=0x0;
00036   res.s7=0x0;
00037   res.s8=0x0;
00038   return res;
00039 }
00040 
00041 group static inline FF1(){
00042   group res;
00043   res.s1=0xff;
00044   res.s2=0xff;
00045   res.s3=0xff;
00046   res.s4=0xff;
00047   res.s5=0xff;
00048   res.s6=0xff;
00049   res.s7=0xff;
00050   res.s8=0xff;
00051   return res;
00052 }
00053 
00054 group static inline FFAND(group a,group b){
00055   group res;
00056   res.s1=a.s1&b.s1;
00057   res.s2=a.s2&b.s2;
00058   res.s3=a.s3&b.s3;
00059   res.s4=a.s4&b.s4;
00060   res.s5=a.s5&b.s5;
00061   res.s6=a.s6&b.s6;
00062   res.s7=a.s7&b.s7;
00063   res.s8=a.s8&b.s8;
00064   return res;
00065 }
00066 
00067 group static inline FFOR(group a,group b){
00068   group res;
00069   res.s1=a.s1|b.s1;
00070   res.s2=a.s2|b.s2;
00071   res.s3=a.s3|b.s3;
00072   res.s4=a.s4|b.s4;
00073   res.s5=a.s5|b.s5;
00074   res.s6=a.s6|b.s6;
00075   res.s7=a.s7|b.s7;
00076   res.s8=a.s8|b.s8;
00077   return res;
00078 }
00079 
00080 group static inline FFXOR(group a,group b){
00081   group res;
00082   res.s1=a.s1^b.s1;
00083   res.s2=a.s2^b.s2;
00084   res.s3=a.s3^b.s3;
00085   res.s4=a.s4^b.s4;
00086   res.s5=a.s5^b.s5;
00087   res.s6=a.s6^b.s6;
00088   res.s7=a.s7^b.s7;
00089   res.s8=a.s8^b.s8;
00090   return res;
00091 }
00092 
00093 group static inline FFNOT(group a){
00094   group res;
00095   res.s1=~a.s1;
00096   res.s2=~a.s2;
00097   res.s3=~a.s3;
00098   res.s4=~a.s4;
00099   res.s5=~a.s5;
00100   res.s6=~a.s6;
00101   res.s7=~a.s7;
00102   res.s8=~a.s8;
00103   return res;
00104 }
00105 
00106 
00107 /* 64 rows of 64 bits */
00108 
00109 void static inline FFTABLEIN(unsigned char *tab, int g, unsigned char *data){
00110   *(((int *)tab)+2*g)=*((int *)data);
00111   *(((int *)tab)+2*g+1)=*(((int *)data)+1);
00112 }
00113 
00114 void static inline FFTABLEOUT(unsigned char *data, unsigned char *tab, int g){
00115   *((int *)data)=*(((int *)tab)+2*g);
00116   *(((int *)data)+1)=*(((int *)tab)+2*g+1);
00117 }
00118 
00119 void static inline FFTABLEOUTXORNBY(int n, unsigned char *data, unsigned char *tab, int g){
00120   int j;
00121   for(j=0;j<n;j++){
00122     *(data+j)^=*(tab+8*g+j);
00123   }
00124 }
00125 
00126 struct batch_t{
00127   unsigned char s1,s2,s3,s4,s5,s6,s7,s8;
00128 };
00129 typedef struct batch_t batch;
00130 
00131 #define BYTES_PER_BATCH 8
00132 
00133 batch static inline B_FFAND(batch a,batch b){
00134   batch res;
00135   res.s1=a.s1&b.s1;
00136   res.s2=a.s2&b.s2;
00137   res.s3=a.s3&b.s3;
00138   res.s4=a.s4&b.s4;
00139   res.s5=a.s5&b.s5;
00140   res.s6=a.s6&b.s6;
00141   res.s7=a.s7&b.s7;
00142   res.s8=a.s8&b.s8;
00143   return res;
00144 }
00145 
00146 batch static inline B_FFOR(batch a,batch b){
00147   batch res;
00148   res.s1=a.s1|b.s1;
00149   res.s2=a.s2|b.s2;
00150   res.s3=a.s3|b.s3;
00151   res.s4=a.s4|b.s4;
00152   res.s5=a.s5|b.s5;
00153   res.s6=a.s6|b.s6;
00154   res.s7=a.s7|b.s7;
00155   res.s8=a.s8|b.s8;
00156   return res;
00157 }
00158 
00159 batch static inline B_FFXOR(batch a,batch b){
00160   batch res;
00161   res.s1=a.s1^b.s1;
00162   res.s2=a.s2^b.s2;
00163   res.s3=a.s3^b.s3;
00164   res.s4=a.s4^b.s4;
00165   res.s5=a.s5^b.s5;
00166   res.s6=a.s6^b.s6;
00167   res.s7=a.s7^b.s7;
00168   res.s8=a.s8^b.s8;
00169   return res;
00170 }
00171 
00172 
00173 batch static inline B_FFN_ALL_29(){
00174   batch res;
00175   res.s1=0x29;
00176   res.s2=0x29;
00177   res.s3=0x29;
00178   res.s4=0x29;
00179   res.s5=0x29;
00180   res.s6=0x29;
00181   res.s7=0x29;
00182   res.s8=0x29;
00183   return res;
00184 }
00185 batch static inline B_FFN_ALL_02(){
00186   batch res;
00187   res.s1=0x02;
00188   res.s2=0x02;
00189   res.s3=0x02;
00190   res.s4=0x02;
00191   res.s5=0x02;
00192   res.s6=0x02;
00193   res.s7=0x02;
00194   res.s8=0x02;
00195   return res;
00196 }
00197 batch static inline B_FFN_ALL_04(){
00198   batch res;
00199   res.s1=0x04;
00200   res.s2=0x04;
00201   res.s3=0x04;
00202   res.s4=0x04;
00203   res.s5=0x04;
00204   res.s6=0x04;
00205   res.s7=0x04;
00206   res.s8=0x04;
00207   return res;
00208 }
00209 batch static inline B_FFN_ALL_10(){
00210   batch res;
00211   res.s1=0x10;
00212   res.s2=0x10;
00213   res.s3=0x10;
00214   res.s4=0x10;
00215   res.s5=0x10;
00216   res.s6=0x10;
00217   res.s7=0x10;
00218   res.s8=0x10;
00219   return res;
00220 }
00221 batch static inline B_FFN_ALL_40(){
00222   batch res;
00223   res.s1=0x40;
00224   res.s2=0x40;
00225   res.s3=0x40;
00226   res.s4=0x40;
00227   res.s5=0x40;
00228   res.s6=0x40;
00229   res.s7=0x40;
00230   res.s8=0x40;
00231   return res;
00232 }
00233 batch static inline B_FFN_ALL_80(){
00234   batch res;
00235   res.s1=0x80;
00236   res.s2=0x80;
00237   res.s3=0x80;
00238   res.s4=0x80;
00239   res.s5=0x80;
00240   res.s6=0x80;
00241   res.s7=0x80;
00242   res.s8=0x80;
00243   return res;
00244 }
00245 
00246 batch static inline B_FFSH8L(batch a,int n){
00247   batch res;
00248   res.s1=a.s1<<n;
00249   res.s2=a.s2<<n;
00250   res.s3=a.s3<<n;
00251   res.s4=a.s4<<n;
00252   res.s5=a.s5<<n;
00253   res.s6=a.s6<<n;
00254   res.s7=a.s7<<n;
00255   res.s8=a.s8<<n;
00256   return res;
00257 }
00258 
00259 batch static inline B_FFSH8R(batch a,int n){
00260   batch res;
00261   res.s1=a.s1>>n;
00262   res.s2=a.s2>>n;
00263   res.s3=a.s3>>n;
00264   res.s4=a.s4>>n;
00265   res.s5=a.s5>>n;
00266   res.s6=a.s6>>n;
00267   res.s7=a.s7>>n;
00268   res.s8=a.s8>>n;
00269   return res;
00270 }
00271 
00272 
00273 void static inline M_EMPTY(void){
00274 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines