^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * FSE : Finite State Entropy codec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Public Prototypes declaration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2013-2016, Yann Collet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * modification, are permitted provided that the following conditions are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * * Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * * Redistributions in binary form must reproduce the above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * copyright notice, this list of conditions and the following disclaimer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * in the documentation and/or other materials provided with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * This program is free software; you can redistribute it and/or modify it under
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * the terms of the GNU General Public License version 2 as published by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * Free Software Foundation. This program is dual-licensed; you may select
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * either version 2 of the GNU General Public License ("GPL") or BSD license
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * ("BSD").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * You can contact the author at :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #ifndef FSE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define FSE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /*-*****************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * Dependencies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) ******************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include <linux/types.h> /* size_t, ptrdiff_t */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /*-*****************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * FSE_PUBLIC_API : control library symbols visibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) ******************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define FSE_PUBLIC_API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /*------ Version ------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define FSE_VERSION_MAJOR 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define FSE_VERSION_MINOR 9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define FSE_VERSION_RELEASE 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define FSE_LIB_VERSION FSE_VERSION_MAJOR.FSE_VERSION_MINOR.FSE_VERSION_RELEASE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define FSE_QUOTE(str) #str
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define FSE_EXPAND_AND_QUOTE(str) FSE_QUOTE(str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define FSE_VERSION_STRING FSE_EXPAND_AND_QUOTE(FSE_LIB_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define FSE_VERSION_NUMBER (FSE_VERSION_MAJOR * 100 * 100 + FSE_VERSION_MINOR * 100 + FSE_VERSION_RELEASE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) FSE_PUBLIC_API unsigned FSE_versionNumber(void); /**< library version number; to be used when checking dll version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /*-*****************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * Tool functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) ******************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) FSE_PUBLIC_API size_t FSE_compressBound(size_t size); /* maximum compressed size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /* Error Management */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) FSE_PUBLIC_API unsigned FSE_isError(size_t code); /* tells if a return value is an error code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /*-*****************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * FSE detailed API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) ******************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /*!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) FSE_compress() does the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 1. count symbol occurrence from source[] into table count[]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 2. normalize counters so that sum(count[]) == Power_of_2 (2^tableLog)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 3. save normalized counters to memory buffer using writeNCount()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 4. build encoding table 'CTable' from normalized counters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 5. encode the data stream using encoding table 'CTable'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) FSE_decompress() does the following:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 1. read normalized counters with readNCount()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 2. build decoding table 'DTable' from normalized counters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 3. decode the data stream using decoding table 'DTable'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) The following API allows targeting specific sub-functions for advanced tasks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) For example, it's possible to compress several blocks using the same 'CTable',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) or to save and provide normalized distribution using external method.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /* *** COMPRESSION *** */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /*! FSE_optimalTableLog():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) dynamically downsize 'tableLog' when conditions are met.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) It saves CPU time, by using smaller tables, while preserving or even improving compression ratio.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) @return : recommended tableLog (necessarily <= 'maxTableLog') */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) FSE_PUBLIC_API unsigned FSE_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*! FSE_normalizeCount():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) normalize counts so that sum(count[]) == Power_of_2 (2^tableLog)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 'normalizedCounter' is a table of short, of minimum size (maxSymbolValue+1).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) @return : tableLog,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) or an errorCode, which can be tested using FSE_isError() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) FSE_PUBLIC_API size_t FSE_normalizeCount(short *normalizedCounter, unsigned tableLog, const unsigned *count, size_t srcSize, unsigned maxSymbolValue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /*! FSE_NCountWriteBound():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) Provides the maximum possible size of an FSE normalized table, given 'maxSymbolValue' and 'tableLog'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) Typically useful for allocation purpose. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) FSE_PUBLIC_API size_t FSE_NCountWriteBound(unsigned maxSymbolValue, unsigned tableLog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /*! FSE_writeNCount():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) Compactly save 'normalizedCounter' into 'buffer'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) @return : size of the compressed table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) or an errorCode, which can be tested using FSE_isError(). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) FSE_PUBLIC_API size_t FSE_writeNCount(void *buffer, size_t bufferSize, const short *normalizedCounter, unsigned maxSymbolValue, unsigned tableLog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /*! Constructor and Destructor of FSE_CTable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) Note that FSE_CTable size depends on 'tableLog' and 'maxSymbolValue' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) typedef unsigned FSE_CTable; /* don't allocate that. It's only meant to be more restrictive than void* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) /*! FSE_compress_usingCTable():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) Compress `src` using `ct` into `dst` which must be already allocated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) @return : size of compressed data (<= `dstCapacity`),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) or 0 if compressed data could not fit into `dst`,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) or an errorCode, which can be tested using FSE_isError() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) FSE_PUBLIC_API size_t FSE_compress_usingCTable(void *dst, size_t dstCapacity, const void *src, size_t srcSize, const FSE_CTable *ct);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /*!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) Tutorial :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) ----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) The first step is to count all symbols. FSE_count() does this job very fast.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) Result will be saved into 'count', a table of unsigned int, which must be already allocated, and have 'maxSymbolValuePtr[0]+1' cells.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 'src' is a table of bytes of size 'srcSize'. All values within 'src' MUST be <= maxSymbolValuePtr[0]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) maxSymbolValuePtr[0] will be updated, with its real value (necessarily <= original value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) FSE_count() will return the number of occurrence of the most frequent symbol.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) This can be used to know if there is a single symbol within 'src', and to quickly evaluate its compressibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) If there is an error, the function will return an ErrorCode (which can be tested using FSE_isError()).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) The next step is to normalize the frequencies.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) FSE_normalizeCount() will ensure that sum of frequencies is == 2 ^'tableLog'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) It also guarantees a minimum of 1 to any Symbol with frequency >= 1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) You can use 'tableLog'==0 to mean "use default tableLog value".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) If you are unsure of which tableLog value to use, you can ask FSE_optimalTableLog(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) which will provide the optimal valid tableLog given sourceSize, maxSymbolValue, and a user-defined maximum (0 means "default").
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) The result of FSE_normalizeCount() will be saved into a table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) called 'normalizedCounter', which is a table of signed short.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 'normalizedCounter' must be already allocated, and have at least 'maxSymbolValue+1' cells.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) The return value is tableLog if everything proceeded as expected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) It is 0 if there is a single symbol within distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) If there is an error (ex: invalid tableLog value), the function will return an ErrorCode (which can be tested using FSE_isError()).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 'normalizedCounter' can be saved in a compact manner to a memory area using FSE_writeNCount().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 'buffer' must be already allocated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) For guaranteed success, buffer size must be at least FSE_headerBound().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) The result of the function is the number of bytes written into 'buffer'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) If there is an error, the function will return an ErrorCode (which can be tested using FSE_isError(); ex : buffer size too small).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 'normalizedCounter' can then be used to create the compression table 'CTable'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) The space required by 'CTable' must be already allocated, using FSE_createCTable().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) You can then use FSE_buildCTable() to fill 'CTable'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) If there is an error, both functions will return an ErrorCode (which can be tested using FSE_isError()).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 'CTable' can then be used to compress 'src', with FSE_compress_usingCTable().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) Similar to FSE_count(), the convention is that 'src' is assumed to be a table of char of size 'srcSize'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) The function returns the size of compressed data (without header), necessarily <= `dstCapacity`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) If it returns '0', compressed data could not fit into 'dst'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) If there is an error, the function will return an ErrorCode (which can be tested using FSE_isError()).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* *** DECOMPRESSION *** */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /*! FSE_readNCount():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) Read compactly saved 'normalizedCounter' from 'rBuffer'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) @return : size read from 'rBuffer',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) or an errorCode, which can be tested using FSE_isError().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) maxSymbolValuePtr[0] and tableLogPtr[0] will also be updated with their respective values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) FSE_PUBLIC_API size_t FSE_readNCount(short *normalizedCounter, unsigned *maxSymbolValuePtr, unsigned *tableLogPtr, const void *rBuffer, size_t rBuffSize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) /*! Constructor and Destructor of FSE_DTable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) Note that its size depends on 'tableLog' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) typedef unsigned FSE_DTable; /* don't allocate that. It's just a way to be more restrictive than void* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /*! FSE_buildDTable():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) Builds 'dt', which must be already allocated, using FSE_createDTable().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return : 0, or an errorCode, which can be tested using FSE_isError() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) FSE_PUBLIC_API size_t FSE_buildDTable_wksp(FSE_DTable *dt, const short *normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void *workspace, size_t workspaceSize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) /*! FSE_decompress_usingDTable():
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) Decompress compressed source `cSrc` of size `cSrcSize` using `dt`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) into `dst` which must be already allocated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) @return : size of regenerated data (necessarily <= `dstCapacity`),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) or an errorCode, which can be tested using FSE_isError() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) FSE_PUBLIC_API size_t FSE_decompress_usingDTable(void *dst, size_t dstCapacity, const void *cSrc, size_t cSrcSize, const FSE_DTable *dt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) /*!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) Tutorial :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) ----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) (Note : these functions only decompress FSE-compressed blocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) If block is uncompressed, use memcpy() instead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) If block is a single repeated byte, use memset() instead )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) The first step is to obtain the normalized frequencies of symbols.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) This can be performed by FSE_readNCount() if it was saved using FSE_writeNCount().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 'normalizedCounter' must be already allocated, and have at least 'maxSymbolValuePtr[0]+1' cells of signed short.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) In practice, that means it's necessary to know 'maxSymbolValue' beforehand,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) or size the table to handle worst case situations (typically 256).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) FSE_readNCount() will provide 'tableLog' and 'maxSymbolValue'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) The result of FSE_readNCount() is the number of bytes read from 'rBuffer'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) Note that 'rBufferSize' must be at least 4 bytes, even if useful information is less than that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) If there is an error, the function will return an error code, which can be tested using FSE_isError().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) The next step is to build the decompression tables 'FSE_DTable' from 'normalizedCounter'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) This is performed by the function FSE_buildDTable().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) The space required by 'FSE_DTable' must be already allocated using FSE_createDTable().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) If there is an error, the function will return an error code, which can be tested using FSE_isError().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) `FSE_DTable` can then be used to decompress `cSrc`, with FSE_decompress_usingDTable().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) `cSrcSize` must be strictly correct, otherwise decompression will fail.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) FSE_decompress_usingDTable() result will tell how many bytes were regenerated (<=`dstCapacity`).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) If there is an error, the function will return an error code, which can be tested using FSE_isError(). (ex: dst buffer too small)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) /* *** Dependency *** */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) #include "bitstream.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /* *****************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * Static allocation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) *******************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) /* FSE buffer bounds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) #define FSE_NCOUNTBOUND 512
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) #define FSE_BLOCKBOUND(size) (size + (size >> 7))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) #define FSE_COMPRESSBOUND(size) (FSE_NCOUNTBOUND + FSE_BLOCKBOUND(size)) /* Macro version, useful for static allocation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) /* It is possible to statically allocate FSE CTable/DTable as a table of FSE_CTable/FSE_DTable using below macros */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) #define FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) (1 + (1 << (maxTableLog - 1)) + ((maxSymbolValue + 1) * 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) #define FSE_DTABLE_SIZE_U32(maxTableLog) (1 + (1 << maxTableLog))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /* *****************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * FSE advanced API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) *******************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) /* FSE_count_wksp() :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * Same as FSE_count(), but using an externally provided scratch buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * `workSpace` size must be table of >= `1024` unsigned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) size_t FSE_count_wksp(unsigned *count, unsigned *maxSymbolValuePtr, const void *source, size_t sourceSize, unsigned *workSpace);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) /* FSE_countFast_wksp() :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * Same as FSE_countFast(), but using an externally provided scratch buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * `workSpace` must be a table of minimum `1024` unsigned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) size_t FSE_countFast_wksp(unsigned *count, unsigned *maxSymbolValuePtr, const void *src, size_t srcSize, unsigned *workSpace);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) /*! FSE_count_simple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * Same as FSE_countFast(), but does not use any additional memory (not even on stack).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * This function is unsafe, and will segfault if any value within `src` is `> *maxSymbolValuePtr` (presuming it's also the size of `count`).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) size_t FSE_count_simple(unsigned *count, unsigned *maxSymbolValuePtr, const void *src, size_t srcSize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) unsigned FSE_optimalTableLog_internal(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue, unsigned minus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) /**< same as FSE_optimalTableLog(), which used `minus==2` */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) size_t FSE_buildCTable_raw(FSE_CTable *ct, unsigned nbBits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) /**< build a fake FSE_CTable, designed for a flat distribution, where each symbol uses nbBits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) size_t FSE_buildCTable_rle(FSE_CTable *ct, unsigned char symbolValue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) /**< build a fake FSE_CTable, designed to compress always the same symbolValue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) /* FSE_buildCTable_wksp() :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) * Same as FSE_buildCTable(), but using an externally allocated scratch buffer (`workSpace`).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * `wkspSize` must be >= `(1<<tableLog)`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) size_t FSE_buildCTable_wksp(FSE_CTable *ct, const short *normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void *workSpace, size_t wkspSize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) size_t FSE_buildDTable_raw(FSE_DTable *dt, unsigned nbBits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) /**< build a fake FSE_DTable, designed to read a flat distribution where each symbol uses nbBits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) size_t FSE_buildDTable_rle(FSE_DTable *dt, unsigned char symbolValue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) /**< build a fake FSE_DTable, designed to always generate the same symbolValue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) size_t FSE_decompress_wksp(void *dst, size_t dstCapacity, const void *cSrc, size_t cSrcSize, unsigned maxLog, void *workspace, size_t workspaceSize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) /**< same as FSE_decompress(), using an externally allocated `workSpace` produced with `FSE_DTABLE_SIZE_U32(maxLog)` */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) /* *****************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * FSE symbol compression API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) *******************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) /*!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) This API consists of small unitary functions, which highly benefit from being inlined.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) Hence their body are included in next section.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) ptrdiff_t value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) const void *stateTable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) const void *symbolTT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) unsigned stateLog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) } FSE_CState_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) static void FSE_initCState(FSE_CState_t *CStatePtr, const FSE_CTable *ct);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) static void FSE_encodeSymbol(BIT_CStream_t *bitC, FSE_CState_t *CStatePtr, unsigned symbol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) static void FSE_flushCState(BIT_CStream_t *bitC, const FSE_CState_t *CStatePtr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) /**<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) These functions are inner components of FSE_compress_usingCTable().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) They allow the creation of custom streams, mixing multiple tables and bit sources.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) A key property to keep in mind is that encoding and decoding are done **in reverse direction**.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) So the first symbol you will encode is the last you will decode, like a LIFO stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) You will need a few variables to track your CStream. They are :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) FSE_CTable ct; // Provided by FSE_buildCTable()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) BIT_CStream_t bitStream; // bitStream tracking structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) FSE_CState_t state; // State tracking structure (can have several)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) The first thing to do is to init bitStream and state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) size_t errorCode = BIT_initCStream(&bitStream, dstBuffer, maxDstSize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) FSE_initCState(&state, ct);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) Note that BIT_initCStream() can produce an error code, so its result should be tested, using FSE_isError();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) You can then encode your input data, byte after byte.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) FSE_encodeSymbol() outputs a maximum of 'tableLog' bits at a time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) Remember decoding will be done in reverse direction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) FSE_encodeByte(&bitStream, &state, symbol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) At any time, you can also add any bit sequence.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) Note : maximum allowed nbBits is 25, for compatibility with 32-bits decoders
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) BIT_addBits(&bitStream, bitField, nbBits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) The above methods don't commit data to memory, they just store it into local register, for speed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) Writing data to memory is a manual operation, performed by the flushBits function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) BIT_flushBits(&bitStream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) Your last FSE encoding operation shall be to flush your last state value(s).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) FSE_flushState(&bitStream, &state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) Finally, you must close the bitStream.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) The function returns the size of CStream in bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) If data couldn't fit into dstBuffer, it will return a 0 ( == not compressible)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) If there is an error, it returns an errorCode (which can be tested using FSE_isError()).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) size_t size = BIT_closeCStream(&bitStream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) /* *****************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) * FSE symbol decompression API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) *******************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) size_t state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) const void *table; /* precise table may vary, depending on U16 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) } FSE_DState_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) static void FSE_initDState(FSE_DState_t *DStatePtr, BIT_DStream_t *bitD, const FSE_DTable *dt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) static unsigned char FSE_decodeSymbol(FSE_DState_t *DStatePtr, BIT_DStream_t *bitD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) static unsigned FSE_endOfDState(const FSE_DState_t *DStatePtr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) /**<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) Let's now decompose FSE_decompress_usingDTable() into its unitary components.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) You will decode FSE-encoded symbols from the bitStream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) and also any other bitFields you put in, **in reverse order**.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) You will need a few variables to track your bitStream. They are :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) BIT_DStream_t DStream; // Stream context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) FSE_DState_t DState; // State context. Multiple ones are possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) FSE_DTable* DTablePtr; // Decoding table, provided by FSE_buildDTable()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) The first thing to do is to init the bitStream.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) errorCode = BIT_initDStream(&DStream, srcBuffer, srcSize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) You should then retrieve your initial state(s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) (in reverse flushing order if you have several ones) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) errorCode = FSE_initDState(&DState, &DStream, DTablePtr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) You can then decode your data, symbol after symbol.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) For information the maximum number of bits read by FSE_decodeSymbol() is 'tableLog'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) Keep in mind that symbols are decoded in reverse order, like a LIFO stack (last in, first out).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) unsigned char symbol = FSE_decodeSymbol(&DState, &DStream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) You can retrieve any bitfield you eventually stored into the bitStream (in reverse order)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) Note : maximum allowed nbBits is 25, for 32-bits compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) size_t bitField = BIT_readBits(&DStream, nbBits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) All above operations only read from local register (which size depends on size_t).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) Refueling the register from memory is manually performed by the reload method.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) endSignal = FSE_reloadDStream(&DStream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) BIT_reloadDStream() result tells if there is still some more data to read from DStream.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) BIT_DStream_unfinished : there is still some data left into the DStream.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) BIT_DStream_endOfBuffer : Dstream reached end of buffer. Its container may no longer be completely filled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) BIT_DStream_completed : Dstream reached its exact end, corresponding in general to decompression completed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) BIT_DStream_tooFar : Dstream went too far. Decompression result is corrupted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) When reaching end of buffer (BIT_DStream_endOfBuffer), progress slowly, notably if you decode multiple symbols per loop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) to properly detect the exact end of stream.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) After each decoded symbol, check if DStream is fully consumed using this simple test :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) BIT_reloadDStream(&DStream) >= BIT_DStream_completed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) When it's done, verify decompression is fully completed, by checking both DStream and the relevant states.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) Checking if DStream has reached its end is performed by :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) BIT_endOfDStream(&DStream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) Check also the states. There might be some symbols left there, if some high probability ones (>50%) are possible.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) FSE_endOfDState(&DState);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) /* *****************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) * FSE unsafe API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) *******************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) static unsigned char FSE_decodeSymbolFast(FSE_DState_t *DStatePtr, BIT_DStream_t *bitD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) /* faster, but works only if nbBits is always >= 1 (otherwise, result will be corrupted) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) /* *****************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) * Implementation of inlined functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) *******************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) int deltaFindState;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) U32 deltaNbBits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) } FSE_symbolCompressionTransform; /* total 8 bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) ZSTD_STATIC void FSE_initCState(FSE_CState_t *statePtr, const FSE_CTable *ct)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) const void *ptr = ct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) const U16 *u16ptr = (const U16 *)ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) const U32 tableLog = ZSTD_read16(ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) statePtr->value = (ptrdiff_t)1 << tableLog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) statePtr->stateTable = u16ptr + 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) statePtr->symbolTT = ((const U32 *)ct + 1 + (tableLog ? (1 << (tableLog - 1)) : 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) statePtr->stateLog = tableLog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) /*! FSE_initCState2() :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) * Same as FSE_initCState(), but the first symbol to include (which will be the last to be read)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) * uses the smallest state value possible, saving the cost of this symbol */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) ZSTD_STATIC void FSE_initCState2(FSE_CState_t *statePtr, const FSE_CTable *ct, U32 symbol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) FSE_initCState(statePtr, ct);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) const FSE_symbolCompressionTransform symbolTT = ((const FSE_symbolCompressionTransform *)(statePtr->symbolTT))[symbol];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) const U16 *stateTable = (const U16 *)(statePtr->stateTable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) U32 nbBitsOut = (U32)((symbolTT.deltaNbBits + (1 << 15)) >> 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) statePtr->value = (nbBitsOut << 16) - symbolTT.deltaNbBits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) statePtr->value = stateTable[(statePtr->value >> nbBitsOut) + symbolTT.deltaFindState];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) ZSTD_STATIC void FSE_encodeSymbol(BIT_CStream_t *bitC, FSE_CState_t *statePtr, U32 symbol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) const FSE_symbolCompressionTransform symbolTT = ((const FSE_symbolCompressionTransform *)(statePtr->symbolTT))[symbol];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) const U16 *const stateTable = (const U16 *)(statePtr->stateTable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) U32 nbBitsOut = (U32)((statePtr->value + symbolTT.deltaNbBits) >> 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) BIT_addBits(bitC, statePtr->value, nbBitsOut);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) statePtr->value = stateTable[(statePtr->value >> nbBitsOut) + symbolTT.deltaFindState];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) ZSTD_STATIC void FSE_flushCState(BIT_CStream_t *bitC, const FSE_CState_t *statePtr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) BIT_addBits(bitC, statePtr->value, statePtr->stateLog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) BIT_flushBits(bitC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) /* ====== Decompression ====== */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) U16 tableLog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) U16 fastMode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) } FSE_DTableHeader; /* sizeof U32 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) unsigned short newState;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) unsigned char symbol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) unsigned char nbBits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) } FSE_decode_t; /* size == U32 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) ZSTD_STATIC void FSE_initDState(FSE_DState_t *DStatePtr, BIT_DStream_t *bitD, const FSE_DTable *dt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) const void *ptr = dt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) const FSE_DTableHeader *const DTableH = (const FSE_DTableHeader *)ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) DStatePtr->state = BIT_readBits(bitD, DTableH->tableLog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) BIT_reloadDStream(bitD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) DStatePtr->table = dt + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) ZSTD_STATIC BYTE FSE_peekSymbol(const FSE_DState_t *DStatePtr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) FSE_decode_t const DInfo = ((const FSE_decode_t *)(DStatePtr->table))[DStatePtr->state];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) return DInfo.symbol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) ZSTD_STATIC void FSE_updateState(FSE_DState_t *DStatePtr, BIT_DStream_t *bitD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) FSE_decode_t const DInfo = ((const FSE_decode_t *)(DStatePtr->table))[DStatePtr->state];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) U32 const nbBits = DInfo.nbBits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) size_t const lowBits = BIT_readBits(bitD, nbBits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) DStatePtr->state = DInfo.newState + lowBits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) ZSTD_STATIC BYTE FSE_decodeSymbol(FSE_DState_t *DStatePtr, BIT_DStream_t *bitD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) FSE_decode_t const DInfo = ((const FSE_decode_t *)(DStatePtr->table))[DStatePtr->state];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) U32 const nbBits = DInfo.nbBits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) BYTE const symbol = DInfo.symbol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) size_t const lowBits = BIT_readBits(bitD, nbBits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) DStatePtr->state = DInfo.newState + lowBits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) return symbol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) /*! FSE_decodeSymbolFast() :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) unsafe, only works if no symbol has a probability > 50% */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) ZSTD_STATIC BYTE FSE_decodeSymbolFast(FSE_DState_t *DStatePtr, BIT_DStream_t *bitD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) FSE_decode_t const DInfo = ((const FSE_decode_t *)(DStatePtr->table))[DStatePtr->state];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) U32 const nbBits = DInfo.nbBits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) BYTE const symbol = DInfo.symbol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) size_t const lowBits = BIT_readBitsFast(bitD, nbBits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) DStatePtr->state = DInfo.newState + lowBits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) return symbol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) ZSTD_STATIC unsigned FSE_endOfDState(const FSE_DState_t *DStatePtr) { return DStatePtr->state == 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) /* **************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) * Tuning parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) ****************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) /*!MEMORY_USAGE :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) * Increasing memory usage improves compression ratio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) * Reduced memory usage can improve speed, due to cache effect
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) * Recommended max value is 14, for 16KB, which nicely fits into Intel x86 L1 cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) #ifndef FSE_MAX_MEMORY_USAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) #define FSE_MAX_MEMORY_USAGE 14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) #ifndef FSE_DEFAULT_MEMORY_USAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) #define FSE_DEFAULT_MEMORY_USAGE 13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) /*!FSE_MAX_SYMBOL_VALUE :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * Maximum symbol value authorized.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) * Required for proper stack allocation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) #ifndef FSE_MAX_SYMBOL_VALUE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) #define FSE_MAX_SYMBOL_VALUE 255
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) /* **************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) * template functions type & suffix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) ****************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) #define FSE_FUNCTION_TYPE BYTE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) #define FSE_FUNCTION_EXTENSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) #define FSE_DECODE_TYPE FSE_decode_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) /* ***************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) * Constants
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) *****************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) #define FSE_MAX_TABLELOG (FSE_MAX_MEMORY_USAGE - 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) #define FSE_MAX_TABLESIZE (1U << FSE_MAX_TABLELOG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) #define FSE_MAXTABLESIZE_MASK (FSE_MAX_TABLESIZE - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) #define FSE_DEFAULT_TABLELOG (FSE_DEFAULT_MEMORY_USAGE - 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) #define FSE_MIN_TABLELOG 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) #define FSE_TABLELOG_ABSOLUTE_MAX 15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) #if FSE_MAX_TABLELOG > FSE_TABLELOG_ABSOLUTE_MAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) #error "FSE_MAX_TABLELOG > FSE_TABLELOG_ABSOLUTE_MAX is not supported"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) #define FSE_TABLESTEP(tableSize) ((tableSize >> 1) + (tableSize >> 3) + 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) #endif /* FSE_H */