|
SASC
DVBSoftCAM
|
00001 /* FFdecsa -- fast decsa algorithm 00002 * 00003 * Copyright (C) 2007 Dark Avenger 00004 * 2003-2004 fatih89r 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 */ 00020 00021 #include <emmintrin.h> 00022 00023 #define MEMALIGN_VAL 16 00024 00025 union __u128i { 00026 unsigned int u[4]; 00027 __m128i v; 00028 }; 00029 00030 static const union __u128i ff0 = {{0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U}}; 00031 static const union __u128i ff1 = {{0xffffffffU, 0xffffffffU, 0xffffffffU, 0xffffffffU}}; 00032 00033 typedef __m128i group; 00034 #define GROUP_PARALLELISM 128 00035 #define FF0() ff0.v 00036 #define FF1() ff1.v 00037 #define FFAND(a,b) _mm_and_si128((a),(b)) 00038 #define FFOR(a,b) _mm_or_si128((a),(b)) 00039 #define FFXOR(a,b) _mm_xor_si128((a),(b)) 00040 #define FFNOT(a) _mm_xor_si128((a),FF1()) 00041 #define MALLOC(X) _mm_malloc(X,16) 00042 #define FREE(X) _mm_free(X) 00043 00044 /* BATCH */ 00045 00046 static const union __u128i ff29 = {{0x29292929U, 0x29292929U, 0x29292929U, 0x29292929U}}; 00047 static const union __u128i ff02 = {{0x02020202U, 0x02020202U, 0x02020202U, 0x02020202U}}; 00048 static const union __u128i ff04 = {{0x04040404U, 0x04040404U, 0x04040404U, 0x04040404U}}; 00049 static const union __u128i ff10 = {{0x10101010U, 0x10101010U, 0x10101010U, 0x10101010U}}; 00050 static const union __u128i ff40 = {{0x40404040U, 0x40404040U, 0x40404040U, 0x40404040U}}; 00051 static const union __u128i ff80 = {{0x80808080U, 0x80808080U, 0x80808080U, 0x80808080U}}; 00052 00053 typedef __m128i batch; 00054 #define BYTES_PER_BATCH 16 00055 #define B_FFN_ALL_29() ff29.v 00056 #define B_FFN_ALL_02() ff02.v 00057 #define B_FFN_ALL_04() ff04.v 00058 #define B_FFN_ALL_10() ff10.v 00059 #define B_FFN_ALL_40() ff40.v 00060 #define B_FFN_ALL_80() ff80.v 00061 00062 #define B_FFAND(a,b) FFAND(a,b) 00063 #define B_FFOR(a,b) FFOR(a,b) 00064 #define B_FFXOR(a,b) FFXOR(a,b) 00065 #define B_FFSH8L(a,n) _mm_slli_epi64((a),(n)) 00066 #define B_FFSH8R(a,n) _mm_srli_epi64((a),(n)) 00067 00068 #define M_EMPTY() 00069 00070 #undef BEST_SPAN 00071 #define BEST_SPAN 16 00072 00073 #undef XOR_BEST_BY 00074 static inline void XOR_BEST_BY(unsigned char *d, unsigned char *s1, unsigned char *s2) 00075 { 00076 __m128i vs1 = _mm_load_si128((__m128i*)s1); 00077 __m128i vs2 = _mm_load_si128((__m128i*)s2); 00078 vs1 = _mm_xor_si128(vs1, vs2); 00079 _mm_store_si128((__m128i*)d, vs1); 00080 } 00081 00082 #include "fftable.h"