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_128_2mmx.h 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. #include <mmintrin.h>
  20. #define MEMALIGN __attribute__((aligned(16)))
  21. struct group_t{
  22. __m64 s1,s2;
  23. };
  24. typedef struct group_t group;
  25. #define GROUP_PARALLELISM 128
  26. group static inline FF0(){
  27. group res;
  28. res.s1=(__m64)0x0ULL;
  29. res.s2=(__m64)0x0ULL;
  30. return res;
  31. }
  32. group static inline FF1(){
  33. group res;
  34. res.s1=(__m64)0xffffffffffffffffULL;
  35. res.s2=(__m64)0xffffffffffffffffULL;
  36. return res;
  37. }
  38. group static inline FFAND(group a,group b){
  39. group res;
  40. res.s1=_m_pand(a.s1,b.s1);
  41. res.s2=_m_pand(a.s2,b.s2);
  42. return res;
  43. }
  44. group static inline FFOR(group a,group b){
  45. group res;
  46. res.s1=_m_por(a.s1,b.s1);
  47. res.s2=_m_por(a.s2,b.s2);
  48. return res;
  49. }
  50. group static inline FFXOR(group a,group b){
  51. group res;
  52. res.s1=_m_pxor(a.s1,b.s1);
  53. res.s2=_m_pxor(a.s2,b.s2);
  54. return res;
  55. }
  56. group static inline FFNOT(group a){
  57. group res;
  58. res.s1=_m_pxor(a.s1,FF1().s1);
  59. res.s2=_m_pxor(a.s2,FF1().s2);
  60. return res;
  61. }
  62. /* 64 rows of 128 bits */
  63. void static inline FFTABLEIN(unsigned char *tab, int g, unsigned char *data){
  64. *(((int *)tab)+2*g)=*((int *)data);
  65. *(((int *)tab)+2*g+1)=*(((int *)data)+1);
  66. }
  67. void static inline FFTABLEOUT(unsigned char *data, unsigned char *tab, int g){
  68. *((int *)data)=*(((int *)tab)+2*g);
  69. *(((int *)data)+1)=*(((int *)tab)+2*g+1);
  70. }
  71. void static inline FFTABLEOUTXORNBY(int n, unsigned char *data, unsigned char *tab, int g){
  72. int j;
  73. for(j=0;j<n;j++){
  74. *(data+j)^=*(tab+8*g+j);
  75. }
  76. }
  77. struct batch_t{
  78. __m64 s1,s2;
  79. };
  80. typedef struct batch_t batch;
  81. #define BYTES_PER_BATCH 16
  82. batch static inline B_FFAND(batch a,batch b){
  83. batch res;
  84. res.s1=_m_pand(a.s1,b.s1);
  85. res.s2=_m_pand(a.s2,b.s2);
  86. return res;
  87. }
  88. batch static inline B_FFOR(batch a,batch b){
  89. batch res;
  90. res.s1=_m_por(a.s1,b.s1);
  91. res.s2=_m_por(a.s2,b.s2);
  92. return res;
  93. }
  94. batch static inline B_FFXOR(batch a,batch b){
  95. batch res;
  96. res.s1=_m_pxor(a.s1,b.s1);
  97. res.s2=_m_pxor(a.s2,b.s2);
  98. return res;
  99. }
  100. batch static inline B_FFN_ALL_29(){
  101. batch res;
  102. res.s1=(__m64)0x2929292929292929ULL;
  103. res.s2=(__m64)0x2929292929292929ULL;
  104. return res;
  105. }
  106. batch static inline B_FFN_ALL_02(){
  107. batch res;
  108. res.s1=(__m64)0x0202020202020202ULL;
  109. res.s2=(__m64)0x0202020202020202ULL;
  110. return res;
  111. }
  112. batch static inline B_FFN_ALL_04(){
  113. batch res;
  114. res.s1=(__m64)0x0404040404040404ULL;
  115. res.s2=(__m64)0x0404040404040404ULL;
  116. return res;
  117. }
  118. batch static inline B_FFN_ALL_10(){
  119. batch res;
  120. res.s1=(__m64)0x1010101010101010ULL;
  121. res.s2=(__m64)0x1010101010101010ULL;
  122. return res;
  123. }
  124. batch static inline B_FFN_ALL_40(){
  125. batch res;
  126. res.s1=(__m64)0x4040404040404040ULL;
  127. res.s2=(__m64)0x4040404040404040ULL;
  128. return res;
  129. }
  130. batch static inline B_FFN_ALL_80(){
  131. batch res;
  132. res.s1=(__m64)0x8080808080808080ULL;
  133. res.s2=(__m64)0x8080808080808080ULL;
  134. return res;
  135. }
  136. batch static inline B_FFSH8L(batch a,int n){
  137. batch res;
  138. res.s1=_m_psllqi(a.s1,n);
  139. res.s2=_m_psllqi(a.s2,n);
  140. return res;
  141. }
  142. batch static inline B_FFSH8R(batch a,int n){
  143. batch res;
  144. res.s1=_m_psrlqi(a.s1,n);
  145. res.s2=_m_psrlqi(a.s2,n);
  146. return res;
  147. }
  148. void static inline M_EMPTY(void){
  149. _m_empty();
  150. }
  151. #undef XOR_8_BY
  152. #define XOR_8_BY(d,s1,s2) do{ __m64 *pd=(__m64 *)(d), *ps1=(__m64 *)(s1), *ps2=(__m64 *)(s2); \
  153. *pd = _m_pxor( *ps1 , *ps2 ); }while(0)
  154. #undef XOREQ_8_BY
  155. #define XOREQ_8_BY(d,s) do{ __m64 *pd=(__m64 *)(d), *ps=(__m64 *)(s); \
  156. *pd = _m_pxor( *ps, *pd ); }while(0)
  157. #undef COPY_8_BY
  158. #define COPY_8_BY(d,s) do{ __m64 *pd=(__m64 *)(d), *ps=(__m64 *)(s); \
  159. *pd = *ps; }while(0)
  160. #undef BEST_SPAN
  161. #define BEST_SPAN 8
  162. #undef XOR_BEST_BY
  163. #define XOR_BEST_BY(d,s1,s2) do{ XOR_8_BY(d,s1,s2); }while(0);
  164. #undef XOREQ_BEST_BY
  165. #define XOREQ_BEST_BY(d,s) do{ XOREQ_8_BY(d,s); }while(0);
  166. #undef COPY_BEST_BY
  167. #define COPY_BEST_BY(d,s) do{ COPY_8_BY(d,s); }while(0);