32 - Public forum : https://groups.google.com/forum/#!forum/lz4c |
32 - Public forum : https://groups.google.com/forum/#!forum/lz4c |
33 ****************************************************************** */ |
33 ****************************************************************** */ |
34 |
34 |
35 |
35 |
36 /* ************************************************************** |
36 /* ************************************************************** |
37 * Compiler specifics |
|
38 ****************************************************************/ |
|
39 #ifdef _MSC_VER /* Visual Studio */ |
|
40 # define FORCE_INLINE static __forceinline |
|
41 # include <intrin.h> /* For Visual 2005 */ |
|
42 # pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ |
|
43 # pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */ |
|
44 #else |
|
45 # if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ |
|
46 # ifdef __GNUC__ |
|
47 # define FORCE_INLINE static inline __attribute__((always_inline)) |
|
48 # else |
|
49 # define FORCE_INLINE static inline |
|
50 # endif |
|
51 # else |
|
52 # define FORCE_INLINE static |
|
53 # endif /* __STDC_VERSION__ */ |
|
54 #endif |
|
55 |
|
56 |
|
57 /* ************************************************************** |
|
58 * Includes |
37 * Includes |
59 ****************************************************************/ |
38 ****************************************************************/ |
60 #include <stdlib.h> /* malloc, free, qsort */ |
39 #include <stdlib.h> /* malloc, free, qsort */ |
61 #include <string.h> /* memcpy, memset */ |
40 #include <string.h> /* memcpy, memset */ |
62 #include <stdio.h> /* printf (debug) */ |
|
63 #include "bitstream.h" |
41 #include "bitstream.h" |
|
42 #include "compiler.h" |
64 #define FSE_STATIC_LINKING_ONLY |
43 #define FSE_STATIC_LINKING_ONLY |
65 #include "fse.h" |
44 #include "fse.h" |
|
45 #include "error_private.h" |
66 |
46 |
67 |
47 |
68 /* ************************************************************** |
48 /* ************************************************************** |
69 * Error Management |
49 * Error Management |
70 ****************************************************************/ |
50 ****************************************************************/ |
157 |
137 |
158 /* Build Decoding table */ |
138 /* Build Decoding table */ |
159 { U32 u; |
139 { U32 u; |
160 for (u=0; u<tableSize; u++) { |
140 for (u=0; u<tableSize; u++) { |
161 FSE_FUNCTION_TYPE const symbol = (FSE_FUNCTION_TYPE)(tableDecode[u].symbol); |
141 FSE_FUNCTION_TYPE const symbol = (FSE_FUNCTION_TYPE)(tableDecode[u].symbol); |
162 U16 nextState = symbolNext[symbol]++; |
142 U32 const nextState = symbolNext[symbol]++; |
163 tableDecode[u].nbBits = (BYTE) (tableLog - BIT_highbit32 ((U32)nextState) ); |
143 tableDecode[u].nbBits = (BYTE) (tableLog - BIT_highbit32(nextState) ); |
164 tableDecode[u].newState = (U16) ( (nextState << tableDecode[u].nbBits) - tableSize); |
144 tableDecode[u].newState = (U16) ( (nextState << tableDecode[u].nbBits) - tableSize); |
165 } } |
145 } } |
166 |
146 |
167 return 0; |
147 return 0; |
168 } |
148 } |
215 } |
195 } |
216 |
196 |
217 return 0; |
197 return 0; |
218 } |
198 } |
219 |
199 |
220 FORCE_INLINE size_t FSE_decompress_usingDTable_generic( |
200 FORCE_INLINE_TEMPLATE size_t FSE_decompress_usingDTable_generic( |
221 void* dst, size_t maxDstSize, |
201 void* dst, size_t maxDstSize, |
222 const void* cSrc, size_t cSrcSize, |
202 const void* cSrc, size_t cSrcSize, |
223 const FSE_DTable* dt, const unsigned fast) |
203 const FSE_DTable* dt, const unsigned fast) |
224 { |
204 { |
225 BYTE* const ostart = (BYTE*) dst; |
205 BYTE* const ostart = (BYTE*) dst; |