contrib/python-zstandard/zstd/common/fse.h
changeset 37495 b1fb341d8a61
parent 30822 b54a2984cdd4
child 40121 73fef626dae3
equal deleted inserted replaced
37494:1ce7a55b09d1 37495:b1fb341d8a61
    29    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    29    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    30 
    30 
    31    You can contact the author at :
    31    You can contact the author at :
    32    - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
    32    - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
    33 ****************************************************************** */
    33 ****************************************************************** */
    34 #ifndef FSE_H
       
    35 #define FSE_H
       
    36 
    34 
    37 #if defined (__cplusplus)
    35 #if defined (__cplusplus)
    38 extern "C" {
    36 extern "C" {
    39 #endif
    37 #endif
       
    38 
       
    39 #ifndef FSE_H
       
    40 #define FSE_H
    40 
    41 
    41 
    42 
    42 /*-*****************************************
    43 /*-*****************************************
    43 *  Dependencies
    44 *  Dependencies
    44 ******************************************/
    45 ******************************************/
    45 #include <stddef.h>    /* size_t, ptrdiff_t */
    46 #include <stddef.h>    /* size_t, ptrdiff_t */
    46 
    47 
       
    48 
       
    49 /*-*****************************************
       
    50 *  FSE_PUBLIC_API : control library symbols visibility
       
    51 ******************************************/
       
    52 #if defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) && defined(__GNUC__) && (__GNUC__ >= 4)
       
    53 #  define FSE_PUBLIC_API __attribute__ ((visibility ("default")))
       
    54 #elif defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1)   /* Visual expected */
       
    55 #  define FSE_PUBLIC_API __declspec(dllexport)
       
    56 #elif defined(FSE_DLL_IMPORT) && (FSE_DLL_IMPORT==1)
       
    57 #  define FSE_PUBLIC_API __declspec(dllimport) /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
       
    58 #else
       
    59 #  define FSE_PUBLIC_API
       
    60 #endif
       
    61 
       
    62 /*------   Version   ------*/
       
    63 #define FSE_VERSION_MAJOR    0
       
    64 #define FSE_VERSION_MINOR    9
       
    65 #define FSE_VERSION_RELEASE  0
       
    66 
       
    67 #define FSE_LIB_VERSION FSE_VERSION_MAJOR.FSE_VERSION_MINOR.FSE_VERSION_RELEASE
       
    68 #define FSE_QUOTE(str) #str
       
    69 #define FSE_EXPAND_AND_QUOTE(str) FSE_QUOTE(str)
       
    70 #define FSE_VERSION_STRING FSE_EXPAND_AND_QUOTE(FSE_LIB_VERSION)
       
    71 
       
    72 #define FSE_VERSION_NUMBER  (FSE_VERSION_MAJOR *100*100 + FSE_VERSION_MINOR *100 + FSE_VERSION_RELEASE)
       
    73 FSE_PUBLIC_API unsigned FSE_versionNumber(void);   /**< library version number; to be used when checking dll version */
    47 
    74 
    48 /*-****************************************
    75 /*-****************************************
    49 *  FSE simple functions
    76 *  FSE simple functions
    50 ******************************************/
    77 ******************************************/
    51 /*! FSE_compress() :
    78 /*! FSE_compress() :
    54     @return : size of compressed data (<= dstCapacity).
    81     @return : size of compressed data (<= dstCapacity).
    55     Special values : if return == 0, srcData is not compressible => Nothing is stored within dst !!!
    82     Special values : if return == 0, srcData is not compressible => Nothing is stored within dst !!!
    56                      if return == 1, srcData is a single byte symbol * srcSize times. Use RLE compression instead.
    83                      if return == 1, srcData is a single byte symbol * srcSize times. Use RLE compression instead.
    57                      if FSE_isError(return), compression failed (more details using FSE_getErrorName())
    84                      if FSE_isError(return), compression failed (more details using FSE_getErrorName())
    58 */
    85 */
    59 size_t FSE_compress(void* dst, size_t dstCapacity,
    86 FSE_PUBLIC_API size_t FSE_compress(void* dst, size_t dstCapacity,
    60               const void* src, size_t srcSize);
    87                              const void* src, size_t srcSize);
    61 
    88 
    62 /*! FSE_decompress():
    89 /*! FSE_decompress():
    63     Decompress FSE data from buffer 'cSrc', of size 'cSrcSize',
    90     Decompress FSE data from buffer 'cSrc', of size 'cSrcSize',
    64     into already allocated destination buffer 'dst', of size 'dstCapacity'.
    91     into already allocated destination buffer 'dst', of size 'dstCapacity'.
    65     @return : size of regenerated data (<= maxDstSize),
    92     @return : size of regenerated data (<= maxDstSize),
    67 
    94 
    68     ** Important ** : FSE_decompress() does not decompress non-compressible nor RLE data !!!
    95     ** Important ** : FSE_decompress() does not decompress non-compressible nor RLE data !!!
    69     Why ? : making this distinction requires a header.
    96     Why ? : making this distinction requires a header.
    70     Header management is intentionally delegated to the user layer, which can better manage special cases.
    97     Header management is intentionally delegated to the user layer, which can better manage special cases.
    71 */
    98 */
    72 size_t FSE_decompress(void* dst,  size_t dstCapacity,
    99 FSE_PUBLIC_API size_t FSE_decompress(void* dst,  size_t dstCapacity,
    73                 const void* cSrc, size_t cSrcSize);
   100                                const void* cSrc, size_t cSrcSize);
    74 
   101 
    75 
   102 
    76 /*-*****************************************
   103 /*-*****************************************
    77 *  Tool functions
   104 *  Tool functions
    78 ******************************************/
   105 ******************************************/
    79 size_t FSE_compressBound(size_t size);       /* maximum compressed size */
   106 FSE_PUBLIC_API size_t FSE_compressBound(size_t size);       /* maximum compressed size */
    80 
   107 
    81 /* Error Management */
   108 /* Error Management */
    82 unsigned    FSE_isError(size_t code);        /* tells if a return value is an error code */
   109 FSE_PUBLIC_API unsigned    FSE_isError(size_t code);        /* tells if a return value is an error code */
    83 const char* FSE_getErrorName(size_t code);   /* provides error code string (useful for debugging) */
   110 FSE_PUBLIC_API const char* FSE_getErrorName(size_t code);   /* provides error code string (useful for debugging) */
    84 
   111 
    85 
   112 
    86 /*-*****************************************
   113 /*-*****************************************
    87 *  FSE advanced functions
   114 *  FSE advanced functions
    88 ******************************************/
   115 ******************************************/
    92     @return : size of compressed data
   119     @return : size of compressed data
    93     Special values : if return == 0, srcData is not compressible => Nothing is stored within cSrc !!!
   120     Special values : if return == 0, srcData is not compressible => Nothing is stored within cSrc !!!
    94                      if return == 1, srcData is a single byte symbol * srcSize times. Use RLE compression.
   121                      if return == 1, srcData is a single byte symbol * srcSize times. Use RLE compression.
    95                      if FSE_isError(return), it's an error code.
   122                      if FSE_isError(return), it's an error code.
    96 */
   123 */
    97 size_t FSE_compress2 (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog);
   124 FSE_PUBLIC_API size_t FSE_compress2 (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog);
    98 
   125 
    99 
   126 
   100 /*-*****************************************
   127 /*-*****************************************
   101 *  FSE detailed API
   128 *  FSE detailed API
   102 ******************************************/
   129 ******************************************/
   125     'count' is a table of unsigned int, of minimum size (*maxSymbolValuePtr+1).
   152     'count' is a table of unsigned int, of minimum size (*maxSymbolValuePtr+1).
   126     *maxSymbolValuePtr will be updated if detected smaller than initial value.
   153     *maxSymbolValuePtr will be updated if detected smaller than initial value.
   127     @return : the count of the most frequent symbol (which is not identified).
   154     @return : the count of the most frequent symbol (which is not identified).
   128               if return == srcSize, there is only one symbol.
   155               if return == srcSize, there is only one symbol.
   129               Can also return an error code, which can be tested with FSE_isError(). */
   156               Can also return an error code, which can be tested with FSE_isError(). */
   130 size_t FSE_count(unsigned* count, unsigned* maxSymbolValuePtr, const void* src, size_t srcSize);
   157 FSE_PUBLIC_API size_t FSE_count(unsigned* count, unsigned* maxSymbolValuePtr, const void* src, size_t srcSize);
   131 
   158 
   132 /*! FSE_optimalTableLog():
   159 /*! FSE_optimalTableLog():
   133     dynamically downsize 'tableLog' when conditions are met.
   160     dynamically downsize 'tableLog' when conditions are met.
   134     It saves CPU time, by using smaller tables, while preserving or even improving compression ratio.
   161     It saves CPU time, by using smaller tables, while preserving or even improving compression ratio.
   135     @return : recommended tableLog (necessarily <= 'maxTableLog') */
   162     @return : recommended tableLog (necessarily <= 'maxTableLog') */
   136 unsigned FSE_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue);
   163 FSE_PUBLIC_API unsigned FSE_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue);
   137 
   164 
   138 /*! FSE_normalizeCount():
   165 /*! FSE_normalizeCount():
   139     normalize counts so that sum(count[]) == Power_of_2 (2^tableLog)
   166     normalize counts so that sum(count[]) == Power_of_2 (2^tableLog)
   140     'normalizedCounter' is a table of short, of minimum size (maxSymbolValue+1).
   167     'normalizedCounter' is a table of short, of minimum size (maxSymbolValue+1).
   141     @return : tableLog,
   168     @return : tableLog,
   142               or an errorCode, which can be tested using FSE_isError() */
   169               or an errorCode, which can be tested using FSE_isError() */
   143 size_t FSE_normalizeCount(short* normalizedCounter, unsigned tableLog, const unsigned* count, size_t srcSize, unsigned maxSymbolValue);
   170 FSE_PUBLIC_API size_t FSE_normalizeCount(short* normalizedCounter, unsigned tableLog, const unsigned* count, size_t srcSize, unsigned maxSymbolValue);
   144 
   171 
   145 /*! FSE_NCountWriteBound():
   172 /*! FSE_NCountWriteBound():
   146     Provides the maximum possible size of an FSE normalized table, given 'maxSymbolValue' and 'tableLog'.
   173     Provides the maximum possible size of an FSE normalized table, given 'maxSymbolValue' and 'tableLog'.
   147     Typically useful for allocation purpose. */
   174     Typically useful for allocation purpose. */
   148 size_t FSE_NCountWriteBound(unsigned maxSymbolValue, unsigned tableLog);
   175 FSE_PUBLIC_API size_t FSE_NCountWriteBound(unsigned maxSymbolValue, unsigned tableLog);
   149 
   176 
   150 /*! FSE_writeNCount():
   177 /*! FSE_writeNCount():
   151     Compactly save 'normalizedCounter' into 'buffer'.
   178     Compactly save 'normalizedCounter' into 'buffer'.
   152     @return : size of the compressed table,
   179     @return : size of the compressed table,
   153               or an errorCode, which can be tested using FSE_isError(). */
   180               or an errorCode, which can be tested using FSE_isError(). */
   154 size_t FSE_writeNCount (void* buffer, size_t bufferSize, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog);
   181 FSE_PUBLIC_API size_t FSE_writeNCount (void* buffer, size_t bufferSize, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog);
   155 
   182 
   156 
   183 
   157 /*! Constructor and Destructor of FSE_CTable.
   184 /*! Constructor and Destructor of FSE_CTable.
   158     Note that FSE_CTable size depends on 'tableLog' and 'maxSymbolValue' */
   185     Note that FSE_CTable size depends on 'tableLog' and 'maxSymbolValue' */
   159 typedef unsigned FSE_CTable;   /* don't allocate that. It's only meant to be more restrictive than void* */
   186 typedef unsigned FSE_CTable;   /* don't allocate that. It's only meant to be more restrictive than void* */
   160 FSE_CTable* FSE_createCTable (unsigned tableLog, unsigned maxSymbolValue);
   187 FSE_PUBLIC_API FSE_CTable* FSE_createCTable (unsigned maxSymbolValue, unsigned tableLog);
   161 void        FSE_freeCTable (FSE_CTable* ct);
   188 FSE_PUBLIC_API void        FSE_freeCTable (FSE_CTable* ct);
   162 
   189 
   163 /*! FSE_buildCTable():
   190 /*! FSE_buildCTable():
   164     Builds `ct`, which must be already allocated, using FSE_createCTable().
   191     Builds `ct`, which must be already allocated, using FSE_createCTable().
   165     @return : 0, or an errorCode, which can be tested using FSE_isError() */
   192     @return : 0, or an errorCode, which can be tested using FSE_isError() */
   166 size_t FSE_buildCTable(FSE_CTable* ct, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog);
   193 FSE_PUBLIC_API size_t FSE_buildCTable(FSE_CTable* ct, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog);
   167 
   194 
   168 /*! FSE_compress_usingCTable():
   195 /*! FSE_compress_usingCTable():
   169     Compress `src` using `ct` into `dst` which must be already allocated.
   196     Compress `src` using `ct` into `dst` which must be already allocated.
   170     @return : size of compressed data (<= `dstCapacity`),
   197     @return : size of compressed data (<= `dstCapacity`),
   171               or 0 if compressed data could not fit into `dst`,
   198               or 0 if compressed data could not fit into `dst`,
   172               or an errorCode, which can be tested using FSE_isError() */
   199               or an errorCode, which can be tested using FSE_isError() */
   173 size_t FSE_compress_usingCTable (void* dst, size_t dstCapacity, const void* src, size_t srcSize, const FSE_CTable* ct);
   200 FSE_PUBLIC_API size_t FSE_compress_usingCTable (void* dst, size_t dstCapacity, const void* src, size_t srcSize, const FSE_CTable* ct);
   174 
   201 
   175 /*!
   202 /*!
   176 Tutorial :
   203 Tutorial :
   177 ----------
   204 ----------
   178 The first step is to count all symbols. FSE_count() does this job very fast.
   205 The first step is to count all symbols. FSE_count() does this job very fast.
   221 /*! FSE_readNCount():
   248 /*! FSE_readNCount():
   222     Read compactly saved 'normalizedCounter' from 'rBuffer'.
   249     Read compactly saved 'normalizedCounter' from 'rBuffer'.
   223     @return : size read from 'rBuffer',
   250     @return : size read from 'rBuffer',
   224               or an errorCode, which can be tested using FSE_isError().
   251               or an errorCode, which can be tested using FSE_isError().
   225               maxSymbolValuePtr[0] and tableLogPtr[0] will also be updated with their respective values */
   252               maxSymbolValuePtr[0] and tableLogPtr[0] will also be updated with their respective values */
   226 size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSymbolValuePtr, unsigned* tableLogPtr, const void* rBuffer, size_t rBuffSize);
   253 FSE_PUBLIC_API size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSymbolValuePtr, unsigned* tableLogPtr, const void* rBuffer, size_t rBuffSize);
   227 
   254 
   228 /*! Constructor and Destructor of FSE_DTable.
   255 /*! Constructor and Destructor of FSE_DTable.
   229     Note that its size depends on 'tableLog' */
   256     Note that its size depends on 'tableLog' */
   230 typedef unsigned FSE_DTable;   /* don't allocate that. It's just a way to be more restrictive than void* */
   257 typedef unsigned FSE_DTable;   /* don't allocate that. It's just a way to be more restrictive than void* */
   231 FSE_DTable* FSE_createDTable(unsigned tableLog);
   258 FSE_PUBLIC_API FSE_DTable* FSE_createDTable(unsigned tableLog);
   232 void        FSE_freeDTable(FSE_DTable* dt);
   259 FSE_PUBLIC_API void        FSE_freeDTable(FSE_DTable* dt);
   233 
   260 
   234 /*! FSE_buildDTable():
   261 /*! FSE_buildDTable():
   235     Builds 'dt', which must be already allocated, using FSE_createDTable().
   262     Builds 'dt', which must be already allocated, using FSE_createDTable().
   236     return : 0, or an errorCode, which can be tested using FSE_isError() */
   263     return : 0, or an errorCode, which can be tested using FSE_isError() */
   237 size_t FSE_buildDTable (FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog);
   264 FSE_PUBLIC_API size_t FSE_buildDTable (FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog);
   238 
   265 
   239 /*! FSE_decompress_usingDTable():
   266 /*! FSE_decompress_usingDTable():
   240     Decompress compressed source `cSrc` of size `cSrcSize` using `dt`
   267     Decompress compressed source `cSrc` of size `cSrcSize` using `dt`
   241     into `dst` which must be already allocated.
   268     into `dst` which must be already allocated.
   242     @return : size of regenerated data (necessarily <= `dstCapacity`),
   269     @return : size of regenerated data (necessarily <= `dstCapacity`),
   243               or an errorCode, which can be tested using FSE_isError() */
   270               or an errorCode, which can be tested using FSE_isError() */
   244 size_t FSE_decompress_usingDTable(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, const FSE_DTable* dt);
   271 FSE_PUBLIC_API size_t FSE_decompress_usingDTable(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, const FSE_DTable* dt);
   245 
   272 
   246 /*!
   273 /*!
   247 Tutorial :
   274 Tutorial :
   248 ----------
   275 ----------
   249 (Note : these functions only decompress FSE-compressed blocks.
   276 (Note : these functions only decompress FSE-compressed blocks.
   269 `cSrcSize` must be strictly correct, otherwise decompression will fail.
   296 `cSrcSize` must be strictly correct, otherwise decompression will fail.
   270 FSE_decompress_usingDTable() result will tell how many bytes were regenerated (<=`dstCapacity`).
   297 FSE_decompress_usingDTable() result will tell how many bytes were regenerated (<=`dstCapacity`).
   271 If there is an error, the function will return an error code, which can be tested using FSE_isError(). (ex: dst buffer too small)
   298 If there is an error, the function will return an error code, which can be tested using FSE_isError(). (ex: dst buffer too small)
   272 */
   299 */
   273 
   300 
   274 
   301 #endif  /* FSE_H */
   275 #ifdef FSE_STATIC_LINKING_ONLY
   302 
       
   303 #if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY)
       
   304 #define FSE_H_FSE_STATIC_LINKING_ONLY
   276 
   305 
   277 /* *** Dependency *** */
   306 /* *** Dependency *** */
   278 #include "bitstream.h"
   307 #include "bitstream.h"
   279 
   308 
   280 
   309 
   287 #define FSE_COMPRESSBOUND(size) (FSE_NCOUNTBOUND + FSE_BLOCKBOUND(size))   /* Macro version, useful for static allocation */
   316 #define FSE_COMPRESSBOUND(size) (FSE_NCOUNTBOUND + FSE_BLOCKBOUND(size))   /* Macro version, useful for static allocation */
   288 
   317 
   289 /* It is possible to statically allocate FSE CTable/DTable as a table of FSE_CTable/FSE_DTable using below macros */
   318 /* It is possible to statically allocate FSE CTable/DTable as a table of FSE_CTable/FSE_DTable using below macros */
   290 #define FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue)   (1 + (1<<(maxTableLog-1)) + ((maxSymbolValue+1)*2))
   319 #define FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue)   (1 + (1<<(maxTableLog-1)) + ((maxSymbolValue+1)*2))
   291 #define FSE_DTABLE_SIZE_U32(maxTableLog)                   (1 + (1<<maxTableLog))
   320 #define FSE_DTABLE_SIZE_U32(maxTableLog)                   (1 + (1<<maxTableLog))
       
   321 
       
   322 /* or use the size to malloc() space directly. Pay attention to alignment restrictions though */
       
   323 #define FSE_CTABLE_SIZE(maxTableLog, maxSymbolValue)   (FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) * sizeof(FSE_CTable))
       
   324 #define FSE_DTABLE_SIZE(maxTableLog)                   (FSE_DTABLE_SIZE_U32(maxTableLog) * sizeof(FSE_DTable))
   292 
   325 
   293 
   326 
   294 /* *****************************************
   327 /* *****************************************
   295 *  FSE advanced API
   328 *  FSE advanced API
   296 *******************************************/
   329 *******************************************/
   310  * Same as FSE_countFast(), but using an externally provided scratch buffer.
   343  * Same as FSE_countFast(), but using an externally provided scratch buffer.
   311  * `workSpace` must be a table of minimum `1024` unsigned
   344  * `workSpace` must be a table of minimum `1024` unsigned
   312  */
   345  */
   313 size_t FSE_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr, const void* src, size_t srcSize, unsigned* workSpace);
   346 size_t FSE_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr, const void* src, size_t srcSize, unsigned* workSpace);
   314 
   347 
   315 /*! FSE_count_simple
   348 /*! FSE_count_simple() :
   316  * Same as FSE_countFast(), but does not use any additional memory (not even on stack).
   349  * Same as FSE_countFast(), but does not use any additional memory (not even on stack).
   317  * This function is unsafe, and will segfault if any value within `src` is `> *maxSymbolValuePtr` (presuming it's also the size of `count`).
   350  * This function is unsafe, and will segfault if any value within `src` is `> *maxSymbolValuePtr` (presuming it's also the size of `count`).
   318 */
   351 */
   319 size_t FSE_count_simple(unsigned* count, unsigned* maxSymbolValuePtr, const void* src, size_t srcSize);
   352 size_t FSE_count_simple(unsigned* count, unsigned* maxSymbolValuePtr, const void* src, size_t srcSize);
   320 
   353 
   325 
   358 
   326 /* FSE_compress_wksp() :
   359 /* FSE_compress_wksp() :
   327  * Same as FSE_compress2(), but using an externally allocated scratch buffer (`workSpace`).
   360  * Same as FSE_compress2(), but using an externally allocated scratch buffer (`workSpace`).
   328  * FSE_WKSP_SIZE_U32() provides the minimum size required for `workSpace` as a table of FSE_CTable.
   361  * FSE_WKSP_SIZE_U32() provides the minimum size required for `workSpace` as a table of FSE_CTable.
   329  */
   362  */
   330 #define FSE_WKSP_SIZE_U32(maxTableLog, maxSymbolValue)   ( FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) + (1<<((maxTableLog>2)?(maxTableLog-2):0)) )
   363 #define FSE_WKSP_SIZE_U32(maxTableLog, maxSymbolValue)   ( FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) + ((maxTableLog > 12) ? (1 << (maxTableLog - 2)) : 1024) )
   331 size_t FSE_compress_wksp (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize);
   364 size_t FSE_compress_wksp (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize);
   332 
   365 
   333 size_t FSE_buildCTable_raw (FSE_CTable* ct, unsigned nbBits);
   366 size_t FSE_buildCTable_raw (FSE_CTable* ct, unsigned nbBits);
   334 /**< build a fake FSE_CTable, designed for a flat distribution, where each symbol uses nbBits */
   367 /**< build a fake FSE_CTable, designed for a flat distribution, where each symbol uses nbBits */
   335 
   368 
   349 /**< build a fake FSE_DTable, designed to always generate the same symbolValue */
   382 /**< build a fake FSE_DTable, designed to always generate the same symbolValue */
   350 
   383 
   351 size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, FSE_DTable* workSpace, unsigned maxLog);
   384 size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, FSE_DTable* workSpace, unsigned maxLog);
   352 /**< same as FSE_decompress(), using an externally allocated `workSpace` produced with `FSE_DTABLE_SIZE_U32(maxLog)` */
   385 /**< same as FSE_decompress(), using an externally allocated `workSpace` produced with `FSE_DTABLE_SIZE_U32(maxLog)` */
   353 
   386 
       
   387 typedef enum {
       
   388    FSE_repeat_none,  /**< Cannot use the previous table */
       
   389    FSE_repeat_check, /**< Can use the previous table but it must be checked */
       
   390    FSE_repeat_valid  /**< Can use the previous table and it is asumed to be valid */
       
   391  } FSE_repeat;
   354 
   392 
   355 /* *****************************************
   393 /* *****************************************
   356 *  FSE symbol compression API
   394 *  FSE symbol compression API
   357 *******************************************/
   395 *******************************************/
   358 /*!
   396 /*!
   522     }
   560     }
   523 }
   561 }
   524 
   562 
   525 MEM_STATIC void FSE_encodeSymbol(BIT_CStream_t* bitC, FSE_CState_t* statePtr, U32 symbol)
   563 MEM_STATIC void FSE_encodeSymbol(BIT_CStream_t* bitC, FSE_CState_t* statePtr, U32 symbol)
   526 {
   564 {
   527     const FSE_symbolCompressionTransform symbolTT = ((const FSE_symbolCompressionTransform*)(statePtr->symbolTT))[symbol];
   565     FSE_symbolCompressionTransform const symbolTT = ((const FSE_symbolCompressionTransform*)(statePtr->symbolTT))[symbol];
   528     const U16* const stateTable = (const U16*)(statePtr->stateTable);
   566     const U16* const stateTable = (const U16*)(statePtr->stateTable);
   529     U32 nbBitsOut  = (U32)((statePtr->value + symbolTT.deltaNbBits) >> 16);
   567     U32 const nbBitsOut  = (U32)((statePtr->value + symbolTT.deltaNbBits) >> 16);
   530     BIT_addBits(bitC, statePtr->value, nbBitsOut);
   568     BIT_addBits(bitC, statePtr->value, nbBitsOut);
   531     statePtr->value = stateTable[ (statePtr->value >> nbBitsOut) + symbolTT.deltaFindState];
   569     statePtr->value = stateTable[ (statePtr->value >> nbBitsOut) + symbolTT.deltaFindState];
   532 }
   570 }
   533 
   571 
   534 MEM_STATIC void FSE_flushCState(BIT_CStream_t* bitC, const FSE_CState_t* statePtr)
   572 MEM_STATIC void FSE_flushCState(BIT_CStream_t* bitC, const FSE_CState_t* statePtr)
   662 
   700 
   663 
   701 
   664 #if defined (__cplusplus)
   702 #if defined (__cplusplus)
   665 }
   703 }
   666 #endif
   704 #endif
   667 
       
   668 #endif  /* FSE_H */