tsdecrypt reads and decrypts CSA encrypted incoming mpeg transport stream over UDP/RTP using code words obtained from OSCAM or similar CAM server. tsdecrypt communicates with CAM server using cs378x (camd35 over tcp) protocol or newcamd protocol. https://georgi.unixsol.org/programs/tsdecrypt/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

parallel_064_8char.h 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /* FFdecsa -- fast decsa algorithm
  2. *
  3. * Copyright (C) 2003-2004 fatih89r
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19. struct group_t{
  20. unsigned char s1,s2,s3,s4,s5,s6,s7,s8;
  21. };
  22. typedef struct group_t group;
  23. #define GROUP_PARALLELISM 64
  24. group static inline FF0(){
  25. group res;
  26. res.s1=0x0;
  27. res.s2=0x0;
  28. res.s3=0x0;
  29. res.s4=0x0;
  30. res.s5=0x0;
  31. res.s6=0x0;
  32. res.s7=0x0;
  33. res.s8=0x0;
  34. return res;
  35. }
  36. group static inline FF1(){
  37. group res;
  38. res.s1=0xff;
  39. res.s2=0xff;
  40. res.s3=0xff;
  41. res.s4=0xff;
  42. res.s5=0xff;
  43. res.s6=0xff;
  44. res.s7=0xff;
  45. res.s8=0xff;
  46. return res;
  47. }
  48. group static inline FFAND(group a,group b){
  49. group res;
  50. res.s1=a.s1&b.s1;
  51. res.s2=a.s2&b.s2;
  52. res.s3=a.s3&b.s3;
  53. res.s4=a.s4&b.s4;
  54. res.s5=a.s5&b.s5;
  55. res.s6=a.s6&b.s6;
  56. res.s7=a.s7&b.s7;
  57. res.s8=a.s8&b.s8;
  58. return res;
  59. }
  60. group static inline FFOR(group a,group b){
  61. group res;
  62. res.s1=a.s1|b.s1;
  63. res.s2=a.s2|b.s2;
  64. res.s3=a.s3|b.s3;
  65. res.s4=a.s4|b.s4;
  66. res.s5=a.s5|b.s5;
  67. res.s6=a.s6|b.s6;
  68. res.s7=a.s7|b.s7;
  69. res.s8=a.s8|b.s8;
  70. return res;
  71. }
  72. group static inline FFXOR(group a,group b){
  73. group res;
  74. res.s1=a.s1^b.s1;
  75. res.s2=a.s2^b.s2;
  76. res.s3=a.s3^b.s3;
  77. res.s4=a.s4^b.s4;
  78. res.s5=a.s5^b.s5;
  79. res.s6=a.s6^b.s6;
  80. res.s7=a.s7^b.s7;
  81. res.s8=a.s8^b.s8;
  82. return res;
  83. }
  84. group static inline FFNOT(group a){
  85. group res;
  86. res.s1=~a.s1;
  87. res.s2=~a.s2;
  88. res.s3=~a.s3;
  89. res.s4=~a.s4;
  90. res.s5=~a.s5;
  91. res.s6=~a.s6;
  92. res.s7=~a.s7;
  93. res.s8=~a.s8;
  94. return res;
  95. }
  96. /* 64 rows of 64 bits */
  97. void static inline FFTABLEIN(unsigned char *tab, int g, unsigned char *data){
  98. *(((int *)tab)+2*g)=*((int *)data);
  99. *(((int *)tab)+2*g+1)=*(((int *)data)+1);
  100. }
  101. void static inline FFTABLEOUT(unsigned char *data, unsigned char *tab, int g){
  102. *((int *)data)=*(((int *)tab)+2*g);
  103. *(((int *)data)+1)=*(((int *)tab)+2*g+1);
  104. }
  105. void static inline FFTABLEOUTXORNBY(int n, unsigned char *data, unsigned char *tab, int g){
  106. int j;
  107. for(j=0;j<n;j++){
  108. *(data+j)^=*(tab+8*g+j);
  109. }
  110. }
  111. struct batch_t{
  112. unsigned char s1,s2,s3,s4,s5,s6,s7,s8;
  113. };
  114. typedef struct batch_t batch;
  115. #define BYTES_PER_BATCH 8
  116. batch static inline B_FFAND(batch a,batch b){
  117. batch res;
  118. res.s1=a.s1&b.s1;
  119. res.s2=a.s2&b.s2;
  120. res.s3=a.s3&b.s3;
  121. res.s4=a.s4&b.s4;
  122. res.s5=a.s5&b.s5;
  123. res.s6=a.s6&b.s6;
  124. res.s7=a.s7&b.s7;
  125. res.s8=a.s8&b.s8;
  126. return res;
  127. }
  128. batch static inline B_FFOR(batch a,batch b){
  129. batch res;
  130. res.s1=a.s1|b.s1;
  131. res.s2=a.s2|b.s2;
  132. res.s3=a.s3|b.s3;
  133. res.s4=a.s4|b.s4;
  134. res.s5=a.s5|b.s5;
  135. res.s6=a.s6|b.s6;
  136. res.s7=a.s7|b.s7;
  137. res.s8=a.s8|b.s8;
  138. return res;
  139. }
  140. batch static inline B_FFXOR(batch a,batch b){
  141. batch res;
  142. res.s1=a.s1^b.s1;
  143. res.s2=a.s2^b.s2;
  144. res.s3=a.s3^b.s3;
  145. res.s4=a.s4^b.s4;
  146. res.s5=a.s5^b.s5;
  147. res.s6=a.s6^b.s6;
  148. res.s7=a.s7^b.s7;
  149. res.s8=a.s8^b.s8;
  150. return res;
  151. }
  152. batch static inline B_FFN_ALL_29(){
  153. batch res;
  154. res.s1=0x29;
  155. res.s2=0x29;
  156. res.s3=0x29;
  157. res.s4=0x29;
  158. res.s5=0x29;
  159. res.s6=0x29;
  160. res.s7=0x29;
  161. res.s8=0x29;
  162. return res;
  163. }
  164. batch static inline B_FFN_ALL_02(){
  165. batch res;
  166. res.s1=0x02;
  167. res.s2=0x02;
  168. res.s3=0x02;
  169. res.s4=0x02;
  170. res.s5=0x02;
  171. res.s6=0x02;
  172. res.s7=0x02;
  173. res.s8=0x02;
  174. return res;
  175. }
  176. batch static inline B_FFN_ALL_04(){
  177. batch res;
  178. res.s1=0x04;
  179. res.s2=0x04;
  180. res.s3=0x04;
  181. res.s4=0x04;
  182. res.s5=0x04;
  183. res.s6=0x04;
  184. res.s7=0x04;
  185. res.s8=0x04;
  186. return res;
  187. }
  188. batch static inline B_FFN_ALL_10(){
  189. batch res;
  190. res.s1=0x10;
  191. res.s2=0x10;
  192. res.s3=0x10;
  193. res.s4=0x10;
  194. res.s5=0x10;
  195. res.s6=0x10;
  196. res.s7=0x10;
  197. res.s8=0x10;
  198. return res;
  199. }
  200. batch static inline B_FFN_ALL_40(){
  201. batch res;
  202. res.s1=0x40;
  203. res.s2=0x40;
  204. res.s3=0x40;
  205. res.s4=0x40;
  206. res.s5=0x40;
  207. res.s6=0x40;
  208. res.s7=0x40;
  209. res.s8=0x40;
  210. return res;
  211. }
  212. batch static inline B_FFN_ALL_80(){
  213. batch res;
  214. res.s1=0x80;
  215. res.s2=0x80;
  216. res.s3=0x80;
  217. res.s4=0x80;
  218. res.s5=0x80;
  219. res.s6=0x80;
  220. res.s7=0x80;
  221. res.s8=0x80;
  222. return res;
  223. }
  224. batch static inline B_FFSH8L(batch a,int n){
  225. batch res;
  226. res.s1=a.s1<<n;
  227. res.s2=a.s2<<n;
  228. res.s3=a.s3<<n;
  229. res.s4=a.s4<<n;
  230. res.s5=a.s5<<n;
  231. res.s6=a.s6<<n;
  232. res.s7=a.s7<<n;
  233. res.s8=a.s8<<n;
  234. return res;
  235. }
  236. batch static inline B_FFSH8R(batch a,int n){
  237. batch res;
  238. res.s1=a.s1>>n;
  239. res.s2=a.s2>>n;
  240. res.s3=a.s3>>n;
  241. res.s4=a.s4>>n;
  242. res.s5=a.s5>>n;
  243. res.s6=a.s6>>n;
  244. res.s7=a.s7>>n;
  245. res.s8=a.s8>>n;
  246. return res;
  247. }
  248. void static inline M_EMPTY(void){
  249. }