|
SASC-NG
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 00022 #include <xmmintrin.h> 00023 00024 #define MEMALIGN_VAL 16 00025 00026 union __u128 { 00027 unsigned int u[4]; 00028 __m128 v; 00029 }; 00030 00031 static const union __u128 ff0 = {{0x00000000U, 0x00000000U, 0x00000000U, 0x00000000U}}; 00032 static const union __u128 ff1 = {{0xffffffffU, 0xffffffffU, 0xffffffffU, 0xffffffffU}}; 00033 00034 typedef __m128 group; 00035 #define GROUP_PARALLELISM 128 00036 #define FF0() ff0.v 00037 #define FF1() ff1.v 00038 #define FFAND(a,b) _mm_and_ps((a),(b)) 00039 #define FFOR(a,b) _mm_or_ps((a),(b)) 00040 #define FFXOR(a,b) _mm_xor_ps((a),(b)) 00041 #define FFNOT(a) _mm_xor_ps((a),FF1()) 00042 #define MALLOC(X) _mm_malloc(X,16) 00043 #define FREE(X) _mm_free(X) 00044 00045 union __u64 { 00046 unsigned int u[2]; 00047 __m64 v; 00048 }; 00049 00050 static const union __u64 ff29 = {{0x29292929U, 0x29292929U}}; 00051 static const union __u64 ff02 = {{0x02020202U, 0x02020202U}}; 00052 static const union __u64 ff04 = {{0x04040404U, 0x04040404U}}; 00053 static const union __u64 ff10 = {{0x10101010U, 0x10101010U}}; 00054 static const union __u64 ff40 = {{0x40404040U, 0x40404040U}}; 00055 static const union __u64 ff80 = {{0x80808080U, 0x80808080U}}; 00056 00057 typedef __m64 batch; 00058 #define BYTES_PER_BATCH 8 00059 #define B_FFN_ALL_29() ff29.v 00060 #define B_FFN_ALL_02() ff02.v 00061 #define B_FFN_ALL_04() ff04.v 00062 #define B_FFN_ALL_10() ff10.v 00063 #define B_FFN_ALL_40() ff40.v 00064 #define B_FFN_ALL_80() ff80.v 00065 #define B_FFAND(a,b) _mm_and_si64((a),(b)) 00066 #define B_FFOR(a,b) _mm_or_si64((a),(b)) 00067 #define B_FFXOR(a,b) _mm_xor_si64((a),(b)) 00068 #define B_FFSH8L(a,n) _mm_slli_si64((a),(n)) 00069 #define B_FFSH8R(a,n) _mm_srli_si64((a),(n)) 00070 00071 #define M_EMPTY() _mm_empty() 00072 00073 00074 #undef XOR_8_BY 00075 #define XOR_8_BY(d,s1,s2) do { *(__m64*)d = _mm_xor_si64(*(__m64*)(s1), *(__m64*)(s2)); } while(0) 00076 00077 #undef XOREQ_8_BY 00078 #define XOREQ_8_BY(d,s) XOR_8_BY(d, d, s) 00079 00080 #undef COPY_8_BY 00081 #define COPY_8_BY(d,s) do { *(__m64 *)(d) = *(__m64 *)(s); } while(0) 00082 00083 #undef BEST_SPAN 00084 #define BEST_SPAN 16 00085 00086 #undef XOR_BEST_BY 00087 static inline void XOR_BEST_BY(unsigned char *d, unsigned char *s1, unsigned char *s2) 00088 { 00089 __m128 vs1 = _mm_load_ps((float*)s1); 00090 __m128 vs2 = _mm_load_ps((float*)s2); 00091 vs1 = _mm_xor_ps(vs1, vs2); 00092 _mm_store_ps((float*)d, vs1); 00093 } 00094 00095 #include "fftable.h"