SASC-NG
DVBSoftCAM

parallel_128_4int.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 int s1,s2,s3,s4;
00023 };
00024 typedef struct group_t group;
00025 
00026 #define GROUP_PARALLELISM 128
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   return res;
00035 }
00036 
00037 group static inline FF1(){
00038   group res;
00039   res.s1=0xffffffff;
00040   res.s2=0xffffffff;
00041   res.s3=0xffffffff;
00042   res.s4=0xffffffff;
00043   return res;
00044 }
00045 
00046 group static inline FFAND(group a,group b){
00047   group res;
00048   res.s1=a.s1&b.s1;
00049   res.s2=a.s2&b.s2;
00050   res.s3=a.s3&b.s3;
00051   res.s4=a.s4&b.s4;
00052   return res;
00053 }
00054 
00055 group static inline FFOR(group a,group b){
00056   group res;
00057   res.s1=a.s1|b.s1;
00058   res.s2=a.s2|b.s2;
00059   res.s3=a.s3|b.s3;
00060   res.s4=a.s4|b.s4;
00061   return res;
00062 }
00063 
00064 group static inline FFXOR(group a,group b){
00065   group res;
00066   res.s1=a.s1^b.s1;
00067   res.s2=a.s2^b.s2;
00068   res.s3=a.s3^b.s3;
00069   res.s4=a.s4^b.s4;
00070   return res;
00071 }
00072 
00073 group static inline FFNOT(group a){
00074   group res;
00075   res.s1=~a.s1;
00076   res.s2=~a.s2;
00077   res.s3=~a.s3;
00078   res.s4=~a.s4;
00079   return res;
00080 }
00081 
00082 
00083 /* 64 rows of 128 bits */
00084 
00085 void static inline FFTABLEIN(unsigned char *tab, int g, unsigned char *data){
00086   *(((int *)tab)+2*g)=*((int *)data);
00087   *(((int *)tab)+2*g+1)=*(((int *)data)+1);
00088 }
00089 
00090 void static inline FFTABLEOUT(unsigned char *data, unsigned char *tab, int g){
00091   *((int *)data)=*(((int *)tab)+2*g);
00092   *(((int *)data)+1)=*(((int *)tab)+2*g+1);
00093 }
00094 
00095 void static inline FFTABLEOUTXORNBY(int n, unsigned char *data, unsigned char *tab, int g){
00096   int j;
00097   for(j=0;j<n;j++){
00098     *(data+j)^=*(tab+8*g+j);
00099   }
00100 }
00101 
00102 
00103 struct batch_t{
00104   unsigned int s1,s2,s3,s4;
00105 };
00106 typedef struct batch_t batch;
00107 
00108 #define BYTES_PER_BATCH 16
00109 
00110 batch static inline B_FFAND(batch a,batch b){
00111   batch res;
00112   res.s1=a.s1&b.s1;
00113   res.s2=a.s2&b.s2;
00114   res.s3=a.s3&b.s3;
00115   res.s4=a.s4&b.s4;
00116   return res;
00117 }
00118 
00119 batch static inline B_FFOR(batch a,batch b){
00120   batch res;
00121   res.s1=a.s1|b.s1;
00122   res.s2=a.s2|b.s2;
00123   res.s3=a.s3|b.s3;
00124   res.s4=a.s4|b.s4;
00125   return res;
00126 }
00127 
00128 batch static inline B_FFXOR(batch a,batch b){
00129   batch res;
00130   res.s1=a.s1^b.s1;
00131   res.s2=a.s2^b.s2;
00132   res.s3=a.s3^b.s3;
00133   res.s4=a.s4^b.s4;
00134   return res;
00135 }
00136 
00137 
00138 batch static inline B_FFN_ALL_29(){
00139   batch res;
00140   res.s1=0x29292929;
00141   res.s2=0x29292929;
00142   res.s3=0x29292929;
00143   res.s4=0x29292929;
00144   return res;
00145 }
00146 batch static inline B_FFN_ALL_02(){
00147   batch res;
00148   res.s1=0x02020202;
00149   res.s2=0x02020202;
00150   res.s3=0x02020202;
00151   res.s4=0x02020202;
00152   return res;
00153 }
00154 batch static inline B_FFN_ALL_04(){
00155   batch res;
00156   res.s1=0x04040404;
00157   res.s2=0x04040404;
00158   res.s3=0x04040404;
00159   res.s4=0x04040404;
00160   return res;
00161 }
00162 batch static inline B_FFN_ALL_10(){
00163   batch res;
00164   res.s1=0x10101010;
00165   res.s2=0x10101010;
00166   res.s3=0x10101010;
00167   res.s4=0x10101010;
00168   return res;
00169 }
00170 batch static inline B_FFN_ALL_40(){
00171   batch res;
00172   res.s1=0x40404040;
00173   res.s2=0x40404040;
00174   res.s3=0x40404040;
00175   res.s4=0x40404040;
00176   return res;
00177 }
00178 batch static inline B_FFN_ALL_80(){
00179   batch res;
00180   res.s1=0x80808080;
00181   res.s2=0x80808080;
00182   res.s3=0x80808080;
00183   res.s4=0x80808080;
00184   return res;
00185 }
00186 
00187 batch static inline B_FFSH8L(batch a,int n){
00188   batch res;
00189   res.s1=a.s1<<n;
00190   res.s2=a.s2<<n;
00191   res.s3=a.s3<<n;
00192   res.s4=a.s4<<n;
00193   return res;
00194 }
00195 
00196 batch static inline B_FFSH8R(batch a,int n){
00197   batch res;
00198   res.s1=a.s1>>n;
00199   res.s2=a.s2>>n;
00200   res.s3=a.s3>>n;
00201   res.s4=a.s4>>n;
00202   return res;
00203 }
00204 
00205 
00206 void static inline M_EMPTY(void){
00207 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines