/src/tdengine/contrib/TSZ/zstd/common/bitstream.h
Line | Count | Source |
1 | | /* ****************************************************************** |
2 | | bitstream |
3 | | Part of FSE library |
4 | | Copyright (C) 2013-present, Yann Collet. |
5 | | |
6 | | BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) |
7 | | |
8 | | Redistribution and use in source and binary forms, with or without |
9 | | modification, are permitted provided that the following conditions are |
10 | | met: |
11 | | |
12 | | * Redistributions of source code must retain the above copyright |
13 | | notice, this list of conditions and the following disclaimer. |
14 | | * Redistributions in binary form must reproduce the above |
15 | | copyright notice, this list of conditions and the following disclaimer |
16 | | in the documentation and/or other materials provided with the |
17 | | distribution. |
18 | | |
19 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
20 | | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
21 | | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
22 | | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
23 | | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
24 | | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
25 | | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26 | | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 | | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 | | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | | |
31 | | You can contact the author at : |
32 | | - Source repository : https://github.com/Cyan4973/FiniteStateEntropy |
33 | | ****************************************************************** */ |
34 | | #ifndef BITSTREAM_H_MODULE |
35 | | #define BITSTREAM_H_MODULE |
36 | | |
37 | | #if defined (__cplusplus) |
38 | | extern "C" { |
39 | | #endif |
40 | | |
41 | | /* |
42 | | * This API consists of small unitary functions, which must be inlined for best performance. |
43 | | * Since link-time-optimization is not available for all compilers, |
44 | | * these functions are defined into a .h to be included. |
45 | | */ |
46 | | |
47 | | /*-**************************************** |
48 | | * Dependencies |
49 | | ******************************************/ |
50 | | #include "mem.h" /* unaligned access routines */ |
51 | | #include "debug.h" /* assert(), DEBUGLOG(), RAWLOG() */ |
52 | | #include "error_private.h" /* error codes and messages */ |
53 | | |
54 | | |
55 | | /*========================================= |
56 | | * Target specific |
57 | | =========================================*/ |
58 | | #if defined(__BMI__) && defined(__GNUC__) |
59 | | # include <immintrin.h> /* support for bextr (experimental) */ |
60 | | #endif |
61 | | |
62 | 0 | #define STREAM_ACCUMULATOR_MIN_32 25 |
63 | 0 | #define STREAM_ACCUMULATOR_MIN_64 57 |
64 | 0 | #define STREAM_ACCUMULATOR_MIN ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64)) |
65 | | |
66 | | |
67 | | /*-****************************************** |
68 | | * bitStream encoding API (write forward) |
69 | | ********************************************/ |
70 | | /* bitStream can mix input from multiple sources. |
71 | | * A critical property of these streams is that they encode and decode in **reverse** direction. |
72 | | * So the first bit sequence you add will be the last to be read, like a LIFO stack. |
73 | | */ |
74 | | typedef struct { |
75 | | size_t bitContainer; |
76 | | unsigned bitPos; |
77 | | char* startPtr; |
78 | | char* ptr; |
79 | | char* endPtr; |
80 | | } BIT_CStream_t; |
81 | | |
82 | | MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, void* dstBuffer, size_t dstCapacity); |
83 | | MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, size_t value, unsigned nbBits); |
84 | | MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC); |
85 | | MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC); |
86 | | |
87 | | /* Start with initCStream, providing the size of buffer to write into. |
88 | | * bitStream will never write outside of this buffer. |
89 | | * `dstCapacity` must be >= sizeof(bitD->bitContainer), otherwise @return will be an error code. |
90 | | * |
91 | | * bits are first added to a local register. |
92 | | * Local register is size_t, hence 64-bits on 64-bits systems, or 32-bits on 32-bits systems. |
93 | | * Writing data into memory is an explicit operation, performed by the flushBits function. |
94 | | * Hence keep track how many bits are potentially stored into local register to avoid register overflow. |
95 | | * After a flushBits, a maximum of 7 bits might still be stored into local register. |
96 | | * |
97 | | * Avoid storing elements of more than 24 bits if you want compatibility with 32-bits bitstream readers. |
98 | | * |
99 | | * Last operation is to close the bitStream. |
100 | | * The function returns the final size of CStream in bytes. |
101 | | * If data couldn't fit into `dstBuffer`, it will return a 0 ( == not storable) |
102 | | */ |
103 | | |
104 | | |
105 | | /*-******************************************** |
106 | | * bitStream decoding API (read backward) |
107 | | **********************************************/ |
108 | | typedef struct { |
109 | | size_t bitContainer; |
110 | | unsigned bitsConsumed; |
111 | | const char* ptr; |
112 | | const char* start; |
113 | | const char* limitPtr; |
114 | | } BIT_DStream_t; |
115 | | |
116 | | typedef enum { BIT_DStream_unfinished = 0, |
117 | | BIT_DStream_endOfBuffer = 1, |
118 | | BIT_DStream_completed = 2, |
119 | | BIT_DStream_overflow = 3 } BIT_DStream_status; /* result of BIT_reloadDStream() */ |
120 | | /* 1,2,4,8 would be better for bitmap combinations, but slows down performance a bit ... :( */ |
121 | | |
122 | | MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize); |
123 | | MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits); |
124 | | MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD); |
125 | | MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD); |
126 | | |
127 | | |
128 | | /* Start by invoking BIT_initDStream(). |
129 | | * A chunk of the bitStream is then stored into a local register. |
130 | | * Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t). |
131 | | * You can then retrieve bitFields stored into the local register, **in reverse order**. |
132 | | * Local register is explicitly reloaded from memory by the BIT_reloadDStream() method. |
133 | | * A reload guarantee a minimum of ((8*sizeof(bitD->bitContainer))-7) bits when its result is BIT_DStream_unfinished. |
134 | | * Otherwise, it can be less than that, so proceed accordingly. |
135 | | * Checking if DStream has reached its end can be performed with BIT_endOfDStream(). |
136 | | */ |
137 | | |
138 | | |
139 | | /*-**************************************** |
140 | | * unsafe API |
141 | | ******************************************/ |
142 | | MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, size_t value, unsigned nbBits); |
143 | | /* faster, but works only if value is "clean", meaning all high bits above nbBits are 0 */ |
144 | | |
145 | | MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC); |
146 | | /* unsafe version; does not check buffer overflow */ |
147 | | |
148 | | MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits); |
149 | | /* faster, but works only if nbBits >= 1 */ |
150 | | |
151 | | |
152 | | |
153 | | /*-************************************************************** |
154 | | * Internal functions |
155 | | ****************************************************************/ |
156 | | MEM_STATIC unsigned BIT_highbit32 (U32 val) |
157 | 0 | { |
158 | 0 | assert(val != 0); |
159 | 0 | { |
160 | | # if defined(_MSC_VER) /* Visual */ |
161 | | unsigned long r=0; |
162 | | _BitScanReverse ( &r, val ); |
163 | | return (unsigned) r; |
164 | | # elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */ |
165 | | return 31 - __builtin_clz (val); |
166 | | # else /* Software version */ |
167 | | static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, |
168 | | 11, 14, 16, 18, 22, 25, 3, 30, |
169 | | 8, 12, 20, 28, 15, 17, 24, 7, |
170 | | 19, 27, 23, 6, 26, 5, 4, 31 }; |
171 | | U32 v = val; |
172 | | v |= v >> 1; |
173 | | v |= v >> 2; |
174 | | v |= v >> 4; |
175 | | v |= v >> 8; |
176 | | v |= v >> 16; |
177 | | return DeBruijnClz[ (U32) (v * 0x07C4ACDDU) >> 27]; |
178 | | # endif |
179 | 0 | } |
180 | 0 | } Unexecuted instantiation: td_sz.c:BIT_highbit32 Unexecuted instantiation: zstd_common.c:BIT_highbit32 Unexecuted instantiation: zstd_compress.c:BIT_highbit32 Unexecuted instantiation: zstd_double_fast.c:BIT_highbit32 Unexecuted instantiation: zstd_fast.c:BIT_highbit32 Unexecuted instantiation: zstd_lazy.c:BIT_highbit32 Unexecuted instantiation: zstd_ldm.c:BIT_highbit32 Unexecuted instantiation: zstd_opt.c:BIT_highbit32 Unexecuted instantiation: zstd_decompress.c:BIT_highbit32 Unexecuted instantiation: conf.c:BIT_highbit32 Unexecuted instantiation: sz.c:BIT_highbit32 Unexecuted instantiation: sz_double.c:BIT_highbit32 Unexecuted instantiation: sz_float.c:BIT_highbit32 Unexecuted instantiation: szd_double.c:BIT_highbit32 Unexecuted instantiation: szd_float.c:BIT_highbit32 Unexecuted instantiation: transcode.c:BIT_highbit32 Unexecuted instantiation: utility.c:BIT_highbit32 Unexecuted instantiation: entropy_common.c:BIT_highbit32 Unexecuted instantiation: fse_decompress.c:BIT_highbit32 Unexecuted instantiation: fse_compress.c:BIT_highbit32 Unexecuted instantiation: huf_compress.c:BIT_highbit32 Unexecuted instantiation: huf_decompress.c:BIT_highbit32 Unexecuted instantiation: ByteToolkit.c:BIT_highbit32 Unexecuted instantiation: CompressElement.c:BIT_highbit32 Unexecuted instantiation: DynamicByteArray.c:BIT_highbit32 Unexecuted instantiation: DynamicIntArray.c:BIT_highbit32 Unexecuted instantiation: Huffman.c:BIT_highbit32 Unexecuted instantiation: TightDataPointStorageD.c:BIT_highbit32 Unexecuted instantiation: TightDataPointStorageF.c:BIT_highbit32 Unexecuted instantiation: TypeManager.c:BIT_highbit32 Unexecuted instantiation: dataCompression.c:BIT_highbit32 |
181 | | |
182 | | /*===== Local Constants =====*/ |
183 | | static const unsigned BIT_mask[] = { |
184 | | 0, 1, 3, 7, 0xF, 0x1F, |
185 | | 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF, |
186 | | 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, 0x1FFFF, |
187 | | 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, 0x7FFFFF, |
188 | | 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF, 0x1FFFFFFF, |
189 | | 0x3FFFFFFF, 0x7FFFFFFF}; /* up to 31 bits */ |
190 | | #define BIT_MASK_SIZE (sizeof(BIT_mask) / sizeof(BIT_mask[0])) |
191 | | |
192 | | /*-************************************************************** |
193 | | * bitStream encoding |
194 | | ****************************************************************/ |
195 | | /*! BIT_initCStream() : |
196 | | * `dstCapacity` must be > sizeof(size_t) |
197 | | * @return : 0 if success, |
198 | | * otherwise an error code (can be tested using ERR_isError()) */ |
199 | | MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, |
200 | | void* startPtr, size_t dstCapacity) |
201 | 0 | { |
202 | 0 | bitC->bitContainer = 0; |
203 | 0 | bitC->bitPos = 0; |
204 | 0 | bitC->startPtr = (char*)startPtr; |
205 | 0 | bitC->ptr = bitC->startPtr; |
206 | 0 | bitC->endPtr = bitC->startPtr + dstCapacity - sizeof(bitC->bitContainer); |
207 | 0 | if (dstCapacity <= sizeof(bitC->bitContainer)) return ERROR(dstSize_tooSmall); |
208 | 0 | return 0; |
209 | 0 | } Unexecuted instantiation: td_sz.c:BIT_initCStream Unexecuted instantiation: zstd_common.c:BIT_initCStream Unexecuted instantiation: zstd_compress.c:BIT_initCStream Unexecuted instantiation: zstd_double_fast.c:BIT_initCStream Unexecuted instantiation: zstd_fast.c:BIT_initCStream Unexecuted instantiation: zstd_lazy.c:BIT_initCStream Unexecuted instantiation: zstd_ldm.c:BIT_initCStream Unexecuted instantiation: zstd_opt.c:BIT_initCStream Unexecuted instantiation: zstd_decompress.c:BIT_initCStream Unexecuted instantiation: conf.c:BIT_initCStream Unexecuted instantiation: sz.c:BIT_initCStream Unexecuted instantiation: sz_double.c:BIT_initCStream Unexecuted instantiation: sz_float.c:BIT_initCStream Unexecuted instantiation: szd_double.c:BIT_initCStream Unexecuted instantiation: szd_float.c:BIT_initCStream Unexecuted instantiation: transcode.c:BIT_initCStream Unexecuted instantiation: utility.c:BIT_initCStream Unexecuted instantiation: entropy_common.c:BIT_initCStream Unexecuted instantiation: fse_decompress.c:BIT_initCStream Unexecuted instantiation: fse_compress.c:BIT_initCStream Unexecuted instantiation: huf_compress.c:BIT_initCStream Unexecuted instantiation: huf_decompress.c:BIT_initCStream Unexecuted instantiation: ByteToolkit.c:BIT_initCStream Unexecuted instantiation: CompressElement.c:BIT_initCStream Unexecuted instantiation: DynamicByteArray.c:BIT_initCStream Unexecuted instantiation: DynamicIntArray.c:BIT_initCStream Unexecuted instantiation: Huffman.c:BIT_initCStream Unexecuted instantiation: TightDataPointStorageD.c:BIT_initCStream Unexecuted instantiation: TightDataPointStorageF.c:BIT_initCStream Unexecuted instantiation: TypeManager.c:BIT_initCStream Unexecuted instantiation: dataCompression.c:BIT_initCStream |
210 | | |
211 | | /*! BIT_addBits() : |
212 | | * can add up to 31 bits into `bitC`. |
213 | | * Note : does not check for register overflow ! */ |
214 | | MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, |
215 | | size_t value, unsigned nbBits) |
216 | 0 | { |
217 | 0 | MEM_STATIC_ASSERT(BIT_MASK_SIZE == 32); |
218 | 0 | assert(nbBits < BIT_MASK_SIZE); |
219 | 0 | assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8); |
220 | 0 | bitC->bitContainer |= (value & BIT_mask[nbBits]) << bitC->bitPos; |
221 | 0 | bitC->bitPos += nbBits; |
222 | 0 | } Unexecuted instantiation: td_sz.c:BIT_addBits Unexecuted instantiation: zstd_common.c:BIT_addBits Unexecuted instantiation: zstd_compress.c:BIT_addBits Unexecuted instantiation: zstd_double_fast.c:BIT_addBits Unexecuted instantiation: zstd_fast.c:BIT_addBits Unexecuted instantiation: zstd_lazy.c:BIT_addBits Unexecuted instantiation: zstd_ldm.c:BIT_addBits Unexecuted instantiation: zstd_opt.c:BIT_addBits Unexecuted instantiation: zstd_decompress.c:BIT_addBits Unexecuted instantiation: conf.c:BIT_addBits Unexecuted instantiation: sz.c:BIT_addBits Unexecuted instantiation: sz_double.c:BIT_addBits Unexecuted instantiation: sz_float.c:BIT_addBits Unexecuted instantiation: szd_double.c:BIT_addBits Unexecuted instantiation: szd_float.c:BIT_addBits Unexecuted instantiation: transcode.c:BIT_addBits Unexecuted instantiation: utility.c:BIT_addBits Unexecuted instantiation: entropy_common.c:BIT_addBits Unexecuted instantiation: fse_decompress.c:BIT_addBits Unexecuted instantiation: fse_compress.c:BIT_addBits Unexecuted instantiation: huf_compress.c:BIT_addBits Unexecuted instantiation: huf_decompress.c:BIT_addBits Unexecuted instantiation: ByteToolkit.c:BIT_addBits Unexecuted instantiation: CompressElement.c:BIT_addBits Unexecuted instantiation: DynamicByteArray.c:BIT_addBits Unexecuted instantiation: DynamicIntArray.c:BIT_addBits Unexecuted instantiation: Huffman.c:BIT_addBits Unexecuted instantiation: TightDataPointStorageD.c:BIT_addBits Unexecuted instantiation: TightDataPointStorageF.c:BIT_addBits Unexecuted instantiation: TypeManager.c:BIT_addBits Unexecuted instantiation: dataCompression.c:BIT_addBits |
223 | | |
224 | | /*! BIT_addBitsFast() : |
225 | | * works only if `value` is _clean_, |
226 | | * meaning all high bits above nbBits are 0 */ |
227 | | MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, |
228 | | size_t value, unsigned nbBits) |
229 | 0 | { |
230 | 0 | assert((value>>nbBits) == 0); |
231 | 0 | assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8); |
232 | 0 | bitC->bitContainer |= value << bitC->bitPos; |
233 | 0 | bitC->bitPos += nbBits; |
234 | 0 | } Unexecuted instantiation: td_sz.c:BIT_addBitsFast Unexecuted instantiation: zstd_common.c:BIT_addBitsFast Unexecuted instantiation: zstd_compress.c:BIT_addBitsFast Unexecuted instantiation: zstd_double_fast.c:BIT_addBitsFast Unexecuted instantiation: zstd_fast.c:BIT_addBitsFast Unexecuted instantiation: zstd_lazy.c:BIT_addBitsFast Unexecuted instantiation: zstd_ldm.c:BIT_addBitsFast Unexecuted instantiation: zstd_opt.c:BIT_addBitsFast Unexecuted instantiation: zstd_decompress.c:BIT_addBitsFast Unexecuted instantiation: conf.c:BIT_addBitsFast Unexecuted instantiation: sz.c:BIT_addBitsFast Unexecuted instantiation: sz_double.c:BIT_addBitsFast Unexecuted instantiation: sz_float.c:BIT_addBitsFast Unexecuted instantiation: szd_double.c:BIT_addBitsFast Unexecuted instantiation: szd_float.c:BIT_addBitsFast Unexecuted instantiation: transcode.c:BIT_addBitsFast Unexecuted instantiation: utility.c:BIT_addBitsFast Unexecuted instantiation: entropy_common.c:BIT_addBitsFast Unexecuted instantiation: fse_decompress.c:BIT_addBitsFast Unexecuted instantiation: fse_compress.c:BIT_addBitsFast Unexecuted instantiation: huf_compress.c:BIT_addBitsFast Unexecuted instantiation: huf_decompress.c:BIT_addBitsFast Unexecuted instantiation: ByteToolkit.c:BIT_addBitsFast Unexecuted instantiation: CompressElement.c:BIT_addBitsFast Unexecuted instantiation: DynamicByteArray.c:BIT_addBitsFast Unexecuted instantiation: DynamicIntArray.c:BIT_addBitsFast Unexecuted instantiation: Huffman.c:BIT_addBitsFast Unexecuted instantiation: TightDataPointStorageD.c:BIT_addBitsFast Unexecuted instantiation: TightDataPointStorageF.c:BIT_addBitsFast Unexecuted instantiation: TypeManager.c:BIT_addBitsFast Unexecuted instantiation: dataCompression.c:BIT_addBitsFast |
235 | | |
236 | | /*! BIT_flushBitsFast() : |
237 | | * assumption : bitContainer has not overflowed |
238 | | * unsafe version; does not check buffer overflow */ |
239 | | MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC) |
240 | 0 | { |
241 | 0 | size_t const nbBytes = bitC->bitPos >> 3; |
242 | 0 | assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8); |
243 | 0 | MEM_writeLEST(bitC->ptr, bitC->bitContainer); |
244 | 0 | bitC->ptr += nbBytes; |
245 | 0 | assert(bitC->ptr <= bitC->endPtr); |
246 | 0 | bitC->bitPos &= 7; |
247 | 0 | bitC->bitContainer >>= nbBytes*8; |
248 | 0 | } Unexecuted instantiation: td_sz.c:BIT_flushBitsFast Unexecuted instantiation: zstd_common.c:BIT_flushBitsFast Unexecuted instantiation: zstd_compress.c:BIT_flushBitsFast Unexecuted instantiation: zstd_double_fast.c:BIT_flushBitsFast Unexecuted instantiation: zstd_fast.c:BIT_flushBitsFast Unexecuted instantiation: zstd_lazy.c:BIT_flushBitsFast Unexecuted instantiation: zstd_ldm.c:BIT_flushBitsFast Unexecuted instantiation: zstd_opt.c:BIT_flushBitsFast Unexecuted instantiation: zstd_decompress.c:BIT_flushBitsFast Unexecuted instantiation: conf.c:BIT_flushBitsFast Unexecuted instantiation: sz.c:BIT_flushBitsFast Unexecuted instantiation: sz_double.c:BIT_flushBitsFast Unexecuted instantiation: sz_float.c:BIT_flushBitsFast Unexecuted instantiation: szd_double.c:BIT_flushBitsFast Unexecuted instantiation: szd_float.c:BIT_flushBitsFast Unexecuted instantiation: transcode.c:BIT_flushBitsFast Unexecuted instantiation: utility.c:BIT_flushBitsFast Unexecuted instantiation: entropy_common.c:BIT_flushBitsFast Unexecuted instantiation: fse_decompress.c:BIT_flushBitsFast Unexecuted instantiation: fse_compress.c:BIT_flushBitsFast Unexecuted instantiation: huf_compress.c:BIT_flushBitsFast Unexecuted instantiation: huf_decompress.c:BIT_flushBitsFast Unexecuted instantiation: ByteToolkit.c:BIT_flushBitsFast Unexecuted instantiation: CompressElement.c:BIT_flushBitsFast Unexecuted instantiation: DynamicByteArray.c:BIT_flushBitsFast Unexecuted instantiation: DynamicIntArray.c:BIT_flushBitsFast Unexecuted instantiation: Huffman.c:BIT_flushBitsFast Unexecuted instantiation: TightDataPointStorageD.c:BIT_flushBitsFast Unexecuted instantiation: TightDataPointStorageF.c:BIT_flushBitsFast Unexecuted instantiation: TypeManager.c:BIT_flushBitsFast Unexecuted instantiation: dataCompression.c:BIT_flushBitsFast |
249 | | |
250 | | /*! BIT_flushBits() : |
251 | | * assumption : bitContainer has not overflowed |
252 | | * safe version; check for buffer overflow, and prevents it. |
253 | | * note : does not signal buffer overflow. |
254 | | * overflow will be revealed later on using BIT_closeCStream() */ |
255 | | MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC) |
256 | 0 | { |
257 | 0 | size_t const nbBytes = bitC->bitPos >> 3; |
258 | 0 | assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8); |
259 | 0 | MEM_writeLEST(bitC->ptr, bitC->bitContainer); |
260 | 0 | bitC->ptr += nbBytes; |
261 | 0 | if (bitC->ptr > bitC->endPtr) bitC->ptr = bitC->endPtr; |
262 | 0 | bitC->bitPos &= 7; |
263 | 0 | bitC->bitContainer >>= nbBytes*8; |
264 | 0 | } Unexecuted instantiation: td_sz.c:BIT_flushBits Unexecuted instantiation: zstd_common.c:BIT_flushBits Unexecuted instantiation: zstd_compress.c:BIT_flushBits Unexecuted instantiation: zstd_double_fast.c:BIT_flushBits Unexecuted instantiation: zstd_fast.c:BIT_flushBits Unexecuted instantiation: zstd_lazy.c:BIT_flushBits Unexecuted instantiation: zstd_ldm.c:BIT_flushBits Unexecuted instantiation: zstd_opt.c:BIT_flushBits Unexecuted instantiation: zstd_decompress.c:BIT_flushBits Unexecuted instantiation: conf.c:BIT_flushBits Unexecuted instantiation: sz.c:BIT_flushBits Unexecuted instantiation: sz_double.c:BIT_flushBits Unexecuted instantiation: sz_float.c:BIT_flushBits Unexecuted instantiation: szd_double.c:BIT_flushBits Unexecuted instantiation: szd_float.c:BIT_flushBits Unexecuted instantiation: transcode.c:BIT_flushBits Unexecuted instantiation: utility.c:BIT_flushBits Unexecuted instantiation: entropy_common.c:BIT_flushBits Unexecuted instantiation: fse_decompress.c:BIT_flushBits Unexecuted instantiation: fse_compress.c:BIT_flushBits Unexecuted instantiation: huf_compress.c:BIT_flushBits Unexecuted instantiation: huf_decompress.c:BIT_flushBits Unexecuted instantiation: ByteToolkit.c:BIT_flushBits Unexecuted instantiation: CompressElement.c:BIT_flushBits Unexecuted instantiation: DynamicByteArray.c:BIT_flushBits Unexecuted instantiation: DynamicIntArray.c:BIT_flushBits Unexecuted instantiation: Huffman.c:BIT_flushBits Unexecuted instantiation: TightDataPointStorageD.c:BIT_flushBits Unexecuted instantiation: TightDataPointStorageF.c:BIT_flushBits Unexecuted instantiation: TypeManager.c:BIT_flushBits Unexecuted instantiation: dataCompression.c:BIT_flushBits |
265 | | |
266 | | /*! BIT_closeCStream() : |
267 | | * @return : size of CStream, in bytes, |
268 | | * or 0 if it could not fit into dstBuffer */ |
269 | | MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC) |
270 | 0 | { |
271 | 0 | BIT_addBitsFast(bitC, 1, 1); /* endMark */ |
272 | 0 | BIT_flushBits(bitC); |
273 | 0 | if (bitC->ptr >= bitC->endPtr) return 0; /* overflow detected */ |
274 | 0 | return (bitC->ptr - bitC->startPtr) + (bitC->bitPos > 0); |
275 | 0 | } Unexecuted instantiation: td_sz.c:BIT_closeCStream Unexecuted instantiation: zstd_common.c:BIT_closeCStream Unexecuted instantiation: zstd_compress.c:BIT_closeCStream Unexecuted instantiation: zstd_double_fast.c:BIT_closeCStream Unexecuted instantiation: zstd_fast.c:BIT_closeCStream Unexecuted instantiation: zstd_lazy.c:BIT_closeCStream Unexecuted instantiation: zstd_ldm.c:BIT_closeCStream Unexecuted instantiation: zstd_opt.c:BIT_closeCStream Unexecuted instantiation: zstd_decompress.c:BIT_closeCStream Unexecuted instantiation: conf.c:BIT_closeCStream Unexecuted instantiation: sz.c:BIT_closeCStream Unexecuted instantiation: sz_double.c:BIT_closeCStream Unexecuted instantiation: sz_float.c:BIT_closeCStream Unexecuted instantiation: szd_double.c:BIT_closeCStream Unexecuted instantiation: szd_float.c:BIT_closeCStream Unexecuted instantiation: transcode.c:BIT_closeCStream Unexecuted instantiation: utility.c:BIT_closeCStream Unexecuted instantiation: entropy_common.c:BIT_closeCStream Unexecuted instantiation: fse_decompress.c:BIT_closeCStream Unexecuted instantiation: fse_compress.c:BIT_closeCStream Unexecuted instantiation: huf_compress.c:BIT_closeCStream Unexecuted instantiation: huf_decompress.c:BIT_closeCStream Unexecuted instantiation: ByteToolkit.c:BIT_closeCStream Unexecuted instantiation: CompressElement.c:BIT_closeCStream Unexecuted instantiation: DynamicByteArray.c:BIT_closeCStream Unexecuted instantiation: DynamicIntArray.c:BIT_closeCStream Unexecuted instantiation: Huffman.c:BIT_closeCStream Unexecuted instantiation: TightDataPointStorageD.c:BIT_closeCStream Unexecuted instantiation: TightDataPointStorageF.c:BIT_closeCStream Unexecuted instantiation: TypeManager.c:BIT_closeCStream Unexecuted instantiation: dataCompression.c:BIT_closeCStream |
276 | | |
277 | | |
278 | | /*-******************************************************** |
279 | | * bitStream decoding |
280 | | **********************************************************/ |
281 | | /*! BIT_initDStream() : |
282 | | * Initialize a BIT_DStream_t. |
283 | | * `bitD` : a pointer to an already allocated BIT_DStream_t structure. |
284 | | * `srcSize` must be the *exact* size of the bitStream, in bytes. |
285 | | * @return : size of stream (== srcSize), or an errorCode if a problem is detected |
286 | | */ |
287 | | MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize) |
288 | 0 | { |
289 | 0 | if (srcSize < 1) { (void)memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); } |
290 | | |
291 | 0 | bitD->start = (const char*)srcBuffer; |
292 | 0 | bitD->limitPtr = bitD->start + sizeof(bitD->bitContainer); |
293 | |
|
294 | 0 | if (srcSize >= sizeof(bitD->bitContainer)) { /* normal case */ |
295 | 0 | bitD->ptr = (const char*)srcBuffer + srcSize - sizeof(bitD->bitContainer); |
296 | 0 | bitD->bitContainer = MEM_readLEST(bitD->ptr); |
297 | 0 | { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1]; |
298 | 0 | bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; /* ensures bitsConsumed is always set */ |
299 | 0 | if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ } |
300 | 0 | } else { |
301 | 0 | bitD->ptr = bitD->start; |
302 | 0 | bitD->bitContainer = *(const BYTE*)(bitD->start); |
303 | 0 | switch(srcSize) |
304 | 0 | { |
305 | 0 | case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16); |
306 | | /* fall-through */ |
307 | |
|
308 | 0 | case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24); |
309 | | /* fall-through */ |
310 | |
|
311 | 0 | case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32); |
312 | | /* fall-through */ |
313 | |
|
314 | 0 | case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24; |
315 | | /* fall-through */ |
316 | |
|
317 | 0 | case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16; |
318 | | /* fall-through */ |
319 | |
|
320 | 0 | case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8; |
321 | | /* fall-through */ |
322 | |
|
323 | 0 | default: break; |
324 | 0 | } |
325 | 0 | { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1]; |
326 | 0 | bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; |
327 | 0 | if (lastByte == 0) return ERROR(corruption_detected); /* endMark not present */ |
328 | 0 | } |
329 | 0 | bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8; |
330 | 0 | } |
331 | | |
332 | 0 | return srcSize; |
333 | 0 | } Unexecuted instantiation: td_sz.c:BIT_initDStream Unexecuted instantiation: zstd_common.c:BIT_initDStream Unexecuted instantiation: zstd_compress.c:BIT_initDStream Unexecuted instantiation: zstd_double_fast.c:BIT_initDStream Unexecuted instantiation: zstd_fast.c:BIT_initDStream Unexecuted instantiation: zstd_lazy.c:BIT_initDStream Unexecuted instantiation: zstd_ldm.c:BIT_initDStream Unexecuted instantiation: zstd_opt.c:BIT_initDStream Unexecuted instantiation: zstd_decompress.c:BIT_initDStream Unexecuted instantiation: conf.c:BIT_initDStream Unexecuted instantiation: sz.c:BIT_initDStream Unexecuted instantiation: sz_double.c:BIT_initDStream Unexecuted instantiation: sz_float.c:BIT_initDStream Unexecuted instantiation: szd_double.c:BIT_initDStream Unexecuted instantiation: szd_float.c:BIT_initDStream Unexecuted instantiation: transcode.c:BIT_initDStream Unexecuted instantiation: utility.c:BIT_initDStream Unexecuted instantiation: entropy_common.c:BIT_initDStream Unexecuted instantiation: fse_decompress.c:BIT_initDStream Unexecuted instantiation: fse_compress.c:BIT_initDStream Unexecuted instantiation: huf_compress.c:BIT_initDStream Unexecuted instantiation: huf_decompress.c:BIT_initDStream Unexecuted instantiation: ByteToolkit.c:BIT_initDStream Unexecuted instantiation: CompressElement.c:BIT_initDStream Unexecuted instantiation: DynamicByteArray.c:BIT_initDStream Unexecuted instantiation: DynamicIntArray.c:BIT_initDStream Unexecuted instantiation: Huffman.c:BIT_initDStream Unexecuted instantiation: TightDataPointStorageD.c:BIT_initDStream Unexecuted instantiation: TightDataPointStorageF.c:BIT_initDStream Unexecuted instantiation: TypeManager.c:BIT_initDStream Unexecuted instantiation: dataCompression.c:BIT_initDStream |
334 | | |
335 | | MEM_STATIC size_t BIT_getUpperBits(size_t bitContainer, U32 const start) |
336 | 0 | { |
337 | 0 | return bitContainer >> start; |
338 | 0 | } Unexecuted instantiation: td_sz.c:BIT_getUpperBits Unexecuted instantiation: zstd_common.c:BIT_getUpperBits Unexecuted instantiation: zstd_compress.c:BIT_getUpperBits Unexecuted instantiation: zstd_double_fast.c:BIT_getUpperBits Unexecuted instantiation: zstd_fast.c:BIT_getUpperBits Unexecuted instantiation: zstd_lazy.c:BIT_getUpperBits Unexecuted instantiation: zstd_ldm.c:BIT_getUpperBits Unexecuted instantiation: zstd_opt.c:BIT_getUpperBits Unexecuted instantiation: zstd_decompress.c:BIT_getUpperBits Unexecuted instantiation: conf.c:BIT_getUpperBits Unexecuted instantiation: sz.c:BIT_getUpperBits Unexecuted instantiation: sz_double.c:BIT_getUpperBits Unexecuted instantiation: sz_float.c:BIT_getUpperBits Unexecuted instantiation: szd_double.c:BIT_getUpperBits Unexecuted instantiation: szd_float.c:BIT_getUpperBits Unexecuted instantiation: transcode.c:BIT_getUpperBits Unexecuted instantiation: utility.c:BIT_getUpperBits Unexecuted instantiation: entropy_common.c:BIT_getUpperBits Unexecuted instantiation: fse_decompress.c:BIT_getUpperBits Unexecuted instantiation: fse_compress.c:BIT_getUpperBits Unexecuted instantiation: huf_compress.c:BIT_getUpperBits Unexecuted instantiation: huf_decompress.c:BIT_getUpperBits Unexecuted instantiation: ByteToolkit.c:BIT_getUpperBits Unexecuted instantiation: CompressElement.c:BIT_getUpperBits Unexecuted instantiation: DynamicByteArray.c:BIT_getUpperBits Unexecuted instantiation: DynamicIntArray.c:BIT_getUpperBits Unexecuted instantiation: Huffman.c:BIT_getUpperBits Unexecuted instantiation: TightDataPointStorageD.c:BIT_getUpperBits Unexecuted instantiation: TightDataPointStorageF.c:BIT_getUpperBits Unexecuted instantiation: TypeManager.c:BIT_getUpperBits Unexecuted instantiation: dataCompression.c:BIT_getUpperBits |
339 | | |
340 | | MEM_STATIC size_t BIT_getMiddleBits(size_t bitContainer, U32 const start, U32 const nbBits) |
341 | 0 | { |
342 | 0 | #if defined(__BMI__) && defined(__GNUC__) && __GNUC__*1000+__GNUC_MINOR__ >= 4008 /* experimental */ |
343 | 0 | # if defined(__x86_64__) |
344 | 0 | if (sizeof(bitContainer)==8) |
345 | 0 | return _bextr_u64(bitContainer, start, nbBits); |
346 | 0 | else |
347 | 0 | # endif |
348 | 0 | return _bextr_u32(bitContainer, start, nbBits); |
349 | 0 | #else |
350 | 0 | assert(nbBits < BIT_MASK_SIZE); |
351 | 0 | return (bitContainer >> start) & BIT_mask[nbBits]; |
352 | 0 | #endif |
353 | 0 | } Unexecuted instantiation: td_sz.c:BIT_getMiddleBits Unexecuted instantiation: zstd_common.c:BIT_getMiddleBits Unexecuted instantiation: zstd_compress.c:BIT_getMiddleBits Unexecuted instantiation: zstd_double_fast.c:BIT_getMiddleBits Unexecuted instantiation: zstd_fast.c:BIT_getMiddleBits Unexecuted instantiation: zstd_lazy.c:BIT_getMiddleBits Unexecuted instantiation: zstd_ldm.c:BIT_getMiddleBits Unexecuted instantiation: zstd_opt.c:BIT_getMiddleBits Unexecuted instantiation: zstd_decompress.c:BIT_getMiddleBits Unexecuted instantiation: conf.c:BIT_getMiddleBits Unexecuted instantiation: sz.c:BIT_getMiddleBits Unexecuted instantiation: sz_double.c:BIT_getMiddleBits Unexecuted instantiation: sz_float.c:BIT_getMiddleBits Unexecuted instantiation: szd_double.c:BIT_getMiddleBits Unexecuted instantiation: szd_float.c:BIT_getMiddleBits Unexecuted instantiation: transcode.c:BIT_getMiddleBits Unexecuted instantiation: utility.c:BIT_getMiddleBits Unexecuted instantiation: entropy_common.c:BIT_getMiddleBits Unexecuted instantiation: fse_decompress.c:BIT_getMiddleBits Unexecuted instantiation: fse_compress.c:BIT_getMiddleBits Unexecuted instantiation: huf_compress.c:BIT_getMiddleBits Unexecuted instantiation: huf_decompress.c:BIT_getMiddleBits Unexecuted instantiation: ByteToolkit.c:BIT_getMiddleBits Unexecuted instantiation: CompressElement.c:BIT_getMiddleBits Unexecuted instantiation: DynamicByteArray.c:BIT_getMiddleBits Unexecuted instantiation: DynamicIntArray.c:BIT_getMiddleBits Unexecuted instantiation: Huffman.c:BIT_getMiddleBits Unexecuted instantiation: TightDataPointStorageD.c:BIT_getMiddleBits Unexecuted instantiation: TightDataPointStorageF.c:BIT_getMiddleBits Unexecuted instantiation: TypeManager.c:BIT_getMiddleBits Unexecuted instantiation: dataCompression.c:BIT_getMiddleBits |
354 | | |
355 | | MEM_STATIC size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits) |
356 | 0 | { |
357 | 0 | assert(nbBits < BIT_MASK_SIZE); |
358 | 0 | return bitContainer & BIT_mask[nbBits]; |
359 | 0 | } Unexecuted instantiation: td_sz.c:BIT_getLowerBits Unexecuted instantiation: zstd_common.c:BIT_getLowerBits Unexecuted instantiation: zstd_compress.c:BIT_getLowerBits Unexecuted instantiation: zstd_double_fast.c:BIT_getLowerBits Unexecuted instantiation: zstd_fast.c:BIT_getLowerBits Unexecuted instantiation: zstd_lazy.c:BIT_getLowerBits Unexecuted instantiation: zstd_ldm.c:BIT_getLowerBits Unexecuted instantiation: zstd_opt.c:BIT_getLowerBits Unexecuted instantiation: zstd_decompress.c:BIT_getLowerBits Unexecuted instantiation: conf.c:BIT_getLowerBits Unexecuted instantiation: sz.c:BIT_getLowerBits Unexecuted instantiation: sz_double.c:BIT_getLowerBits Unexecuted instantiation: sz_float.c:BIT_getLowerBits Unexecuted instantiation: szd_double.c:BIT_getLowerBits Unexecuted instantiation: szd_float.c:BIT_getLowerBits Unexecuted instantiation: transcode.c:BIT_getLowerBits Unexecuted instantiation: utility.c:BIT_getLowerBits Unexecuted instantiation: entropy_common.c:BIT_getLowerBits Unexecuted instantiation: fse_decompress.c:BIT_getLowerBits Unexecuted instantiation: fse_compress.c:BIT_getLowerBits Unexecuted instantiation: huf_compress.c:BIT_getLowerBits Unexecuted instantiation: huf_decompress.c:BIT_getLowerBits Unexecuted instantiation: ByteToolkit.c:BIT_getLowerBits Unexecuted instantiation: CompressElement.c:BIT_getLowerBits Unexecuted instantiation: DynamicByteArray.c:BIT_getLowerBits Unexecuted instantiation: DynamicIntArray.c:BIT_getLowerBits Unexecuted instantiation: Huffman.c:BIT_getLowerBits Unexecuted instantiation: TightDataPointStorageD.c:BIT_getLowerBits Unexecuted instantiation: TightDataPointStorageF.c:BIT_getLowerBits Unexecuted instantiation: TypeManager.c:BIT_getLowerBits Unexecuted instantiation: dataCompression.c:BIT_getLowerBits |
360 | | |
361 | | /*! BIT_lookBits() : |
362 | | * Provides next n bits from local register. |
363 | | * local register is not modified. |
364 | | * On 32-bits, maxNbBits==24. |
365 | | * On 64-bits, maxNbBits==56. |
366 | | * @return : value extracted */ |
367 | | MEM_STATIC size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits) |
368 | 0 | { |
369 | | #if defined(__BMI__) && defined(__GNUC__) /* experimental; fails if bitD->bitsConsumed + nbBits > sizeof(bitD->bitContainer)*8 */ |
370 | | return BIT_getMiddleBits(bitD->bitContainer, (sizeof(bitD->bitContainer)*8) - bitD->bitsConsumed - nbBits, nbBits); |
371 | | #else |
372 | 0 | U32 const regMask = sizeof(bitD->bitContainer)*8 - 1; |
373 | 0 | return ((bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> 1) >> ((regMask-nbBits) & regMask); |
374 | 0 | #endif |
375 | 0 | } Unexecuted instantiation: td_sz.c:BIT_lookBits Unexecuted instantiation: zstd_common.c:BIT_lookBits Unexecuted instantiation: zstd_compress.c:BIT_lookBits Unexecuted instantiation: zstd_double_fast.c:BIT_lookBits Unexecuted instantiation: zstd_fast.c:BIT_lookBits Unexecuted instantiation: zstd_lazy.c:BIT_lookBits Unexecuted instantiation: zstd_ldm.c:BIT_lookBits Unexecuted instantiation: zstd_opt.c:BIT_lookBits Unexecuted instantiation: zstd_decompress.c:BIT_lookBits Unexecuted instantiation: conf.c:BIT_lookBits Unexecuted instantiation: sz.c:BIT_lookBits Unexecuted instantiation: sz_double.c:BIT_lookBits Unexecuted instantiation: sz_float.c:BIT_lookBits Unexecuted instantiation: szd_double.c:BIT_lookBits Unexecuted instantiation: szd_float.c:BIT_lookBits Unexecuted instantiation: transcode.c:BIT_lookBits Unexecuted instantiation: utility.c:BIT_lookBits Unexecuted instantiation: entropy_common.c:BIT_lookBits Unexecuted instantiation: fse_decompress.c:BIT_lookBits Unexecuted instantiation: fse_compress.c:BIT_lookBits Unexecuted instantiation: huf_compress.c:BIT_lookBits Unexecuted instantiation: huf_decompress.c:BIT_lookBits Unexecuted instantiation: ByteToolkit.c:BIT_lookBits Unexecuted instantiation: CompressElement.c:BIT_lookBits Unexecuted instantiation: DynamicByteArray.c:BIT_lookBits Unexecuted instantiation: DynamicIntArray.c:BIT_lookBits Unexecuted instantiation: Huffman.c:BIT_lookBits Unexecuted instantiation: TightDataPointStorageD.c:BIT_lookBits Unexecuted instantiation: TightDataPointStorageF.c:BIT_lookBits Unexecuted instantiation: TypeManager.c:BIT_lookBits Unexecuted instantiation: dataCompression.c:BIT_lookBits |
376 | | |
377 | | /*! BIT_lookBitsFast() : |
378 | | * unsafe version; only works if nbBits >= 1 */ |
379 | | MEM_STATIC size_t BIT_lookBitsFast(const BIT_DStream_t* bitD, U32 nbBits) |
380 | 0 | { |
381 | 0 | U32 const regMask = sizeof(bitD->bitContainer)*8 - 1; |
382 | 0 | assert(nbBits >= 1); |
383 | 0 | return (bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> (((regMask+1)-nbBits) & regMask); |
384 | 0 | } Unexecuted instantiation: td_sz.c:BIT_lookBitsFast Unexecuted instantiation: zstd_common.c:BIT_lookBitsFast Unexecuted instantiation: zstd_compress.c:BIT_lookBitsFast Unexecuted instantiation: zstd_double_fast.c:BIT_lookBitsFast Unexecuted instantiation: zstd_fast.c:BIT_lookBitsFast Unexecuted instantiation: zstd_lazy.c:BIT_lookBitsFast Unexecuted instantiation: zstd_ldm.c:BIT_lookBitsFast Unexecuted instantiation: zstd_opt.c:BIT_lookBitsFast Unexecuted instantiation: zstd_decompress.c:BIT_lookBitsFast Unexecuted instantiation: conf.c:BIT_lookBitsFast Unexecuted instantiation: sz.c:BIT_lookBitsFast Unexecuted instantiation: sz_double.c:BIT_lookBitsFast Unexecuted instantiation: sz_float.c:BIT_lookBitsFast Unexecuted instantiation: szd_double.c:BIT_lookBitsFast Unexecuted instantiation: szd_float.c:BIT_lookBitsFast Unexecuted instantiation: transcode.c:BIT_lookBitsFast Unexecuted instantiation: utility.c:BIT_lookBitsFast Unexecuted instantiation: entropy_common.c:BIT_lookBitsFast Unexecuted instantiation: fse_decompress.c:BIT_lookBitsFast Unexecuted instantiation: fse_compress.c:BIT_lookBitsFast Unexecuted instantiation: huf_compress.c:BIT_lookBitsFast Unexecuted instantiation: huf_decompress.c:BIT_lookBitsFast Unexecuted instantiation: ByteToolkit.c:BIT_lookBitsFast Unexecuted instantiation: CompressElement.c:BIT_lookBitsFast Unexecuted instantiation: DynamicByteArray.c:BIT_lookBitsFast Unexecuted instantiation: DynamicIntArray.c:BIT_lookBitsFast Unexecuted instantiation: Huffman.c:BIT_lookBitsFast Unexecuted instantiation: TightDataPointStorageD.c:BIT_lookBitsFast Unexecuted instantiation: TightDataPointStorageF.c:BIT_lookBitsFast Unexecuted instantiation: TypeManager.c:BIT_lookBitsFast Unexecuted instantiation: dataCompression.c:BIT_lookBitsFast |
385 | | |
386 | | MEM_STATIC void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits) |
387 | 0 | { |
388 | 0 | bitD->bitsConsumed += nbBits; |
389 | 0 | } Unexecuted instantiation: td_sz.c:BIT_skipBits Unexecuted instantiation: zstd_common.c:BIT_skipBits Unexecuted instantiation: zstd_compress.c:BIT_skipBits Unexecuted instantiation: zstd_double_fast.c:BIT_skipBits Unexecuted instantiation: zstd_fast.c:BIT_skipBits Unexecuted instantiation: zstd_lazy.c:BIT_skipBits Unexecuted instantiation: zstd_ldm.c:BIT_skipBits Unexecuted instantiation: zstd_opt.c:BIT_skipBits Unexecuted instantiation: zstd_decompress.c:BIT_skipBits Unexecuted instantiation: conf.c:BIT_skipBits Unexecuted instantiation: sz.c:BIT_skipBits Unexecuted instantiation: sz_double.c:BIT_skipBits Unexecuted instantiation: sz_float.c:BIT_skipBits Unexecuted instantiation: szd_double.c:BIT_skipBits Unexecuted instantiation: szd_float.c:BIT_skipBits Unexecuted instantiation: transcode.c:BIT_skipBits Unexecuted instantiation: utility.c:BIT_skipBits Unexecuted instantiation: entropy_common.c:BIT_skipBits Unexecuted instantiation: fse_decompress.c:BIT_skipBits Unexecuted instantiation: fse_compress.c:BIT_skipBits Unexecuted instantiation: huf_compress.c:BIT_skipBits Unexecuted instantiation: huf_decompress.c:BIT_skipBits Unexecuted instantiation: ByteToolkit.c:BIT_skipBits Unexecuted instantiation: CompressElement.c:BIT_skipBits Unexecuted instantiation: DynamicByteArray.c:BIT_skipBits Unexecuted instantiation: DynamicIntArray.c:BIT_skipBits Unexecuted instantiation: Huffman.c:BIT_skipBits Unexecuted instantiation: TightDataPointStorageD.c:BIT_skipBits Unexecuted instantiation: TightDataPointStorageF.c:BIT_skipBits Unexecuted instantiation: TypeManager.c:BIT_skipBits Unexecuted instantiation: dataCompression.c:BIT_skipBits |
390 | | |
391 | | /*! BIT_readBits() : |
392 | | * Read (consume) next n bits from local register and update. |
393 | | * Pay attention to not read more than nbBits contained into local register. |
394 | | * @return : extracted value. */ |
395 | | MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits) |
396 | 0 | { |
397 | 0 | size_t const value = BIT_lookBits(bitD, nbBits); |
398 | 0 | BIT_skipBits(bitD, nbBits); |
399 | 0 | return value; |
400 | 0 | } Unexecuted instantiation: td_sz.c:BIT_readBits Unexecuted instantiation: zstd_common.c:BIT_readBits Unexecuted instantiation: zstd_compress.c:BIT_readBits Unexecuted instantiation: zstd_double_fast.c:BIT_readBits Unexecuted instantiation: zstd_fast.c:BIT_readBits Unexecuted instantiation: zstd_lazy.c:BIT_readBits Unexecuted instantiation: zstd_ldm.c:BIT_readBits Unexecuted instantiation: zstd_opt.c:BIT_readBits Unexecuted instantiation: zstd_decompress.c:BIT_readBits Unexecuted instantiation: conf.c:BIT_readBits Unexecuted instantiation: sz.c:BIT_readBits Unexecuted instantiation: sz_double.c:BIT_readBits Unexecuted instantiation: sz_float.c:BIT_readBits Unexecuted instantiation: szd_double.c:BIT_readBits Unexecuted instantiation: szd_float.c:BIT_readBits Unexecuted instantiation: transcode.c:BIT_readBits Unexecuted instantiation: utility.c:BIT_readBits Unexecuted instantiation: entropy_common.c:BIT_readBits Unexecuted instantiation: fse_decompress.c:BIT_readBits Unexecuted instantiation: fse_compress.c:BIT_readBits Unexecuted instantiation: huf_compress.c:BIT_readBits Unexecuted instantiation: huf_decompress.c:BIT_readBits Unexecuted instantiation: ByteToolkit.c:BIT_readBits Unexecuted instantiation: CompressElement.c:BIT_readBits Unexecuted instantiation: DynamicByteArray.c:BIT_readBits Unexecuted instantiation: DynamicIntArray.c:BIT_readBits Unexecuted instantiation: Huffman.c:BIT_readBits Unexecuted instantiation: TightDataPointStorageD.c:BIT_readBits Unexecuted instantiation: TightDataPointStorageF.c:BIT_readBits Unexecuted instantiation: TypeManager.c:BIT_readBits Unexecuted instantiation: dataCompression.c:BIT_readBits |
401 | | |
402 | | /*! BIT_readBitsFast() : |
403 | | * unsafe version; only works only if nbBits >= 1 */ |
404 | | MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits) |
405 | 0 | { |
406 | 0 | size_t const value = BIT_lookBitsFast(bitD, nbBits); |
407 | 0 | assert(nbBits >= 1); |
408 | 0 | BIT_skipBits(bitD, nbBits); |
409 | 0 | return value; |
410 | 0 | } Unexecuted instantiation: td_sz.c:BIT_readBitsFast Unexecuted instantiation: zstd_common.c:BIT_readBitsFast Unexecuted instantiation: zstd_compress.c:BIT_readBitsFast Unexecuted instantiation: zstd_double_fast.c:BIT_readBitsFast Unexecuted instantiation: zstd_fast.c:BIT_readBitsFast Unexecuted instantiation: zstd_lazy.c:BIT_readBitsFast Unexecuted instantiation: zstd_ldm.c:BIT_readBitsFast Unexecuted instantiation: zstd_opt.c:BIT_readBitsFast Unexecuted instantiation: zstd_decompress.c:BIT_readBitsFast Unexecuted instantiation: conf.c:BIT_readBitsFast Unexecuted instantiation: sz.c:BIT_readBitsFast Unexecuted instantiation: sz_double.c:BIT_readBitsFast Unexecuted instantiation: sz_float.c:BIT_readBitsFast Unexecuted instantiation: szd_double.c:BIT_readBitsFast Unexecuted instantiation: szd_float.c:BIT_readBitsFast Unexecuted instantiation: transcode.c:BIT_readBitsFast Unexecuted instantiation: utility.c:BIT_readBitsFast Unexecuted instantiation: entropy_common.c:BIT_readBitsFast Unexecuted instantiation: fse_decompress.c:BIT_readBitsFast Unexecuted instantiation: fse_compress.c:BIT_readBitsFast Unexecuted instantiation: huf_compress.c:BIT_readBitsFast Unexecuted instantiation: huf_decompress.c:BIT_readBitsFast Unexecuted instantiation: ByteToolkit.c:BIT_readBitsFast Unexecuted instantiation: CompressElement.c:BIT_readBitsFast Unexecuted instantiation: DynamicByteArray.c:BIT_readBitsFast Unexecuted instantiation: DynamicIntArray.c:BIT_readBitsFast Unexecuted instantiation: Huffman.c:BIT_readBitsFast Unexecuted instantiation: TightDataPointStorageD.c:BIT_readBitsFast Unexecuted instantiation: TightDataPointStorageF.c:BIT_readBitsFast Unexecuted instantiation: TypeManager.c:BIT_readBitsFast Unexecuted instantiation: dataCompression.c:BIT_readBitsFast |
411 | | |
412 | | /*! BIT_reloadDStream() : |
413 | | * Refill `bitD` from buffer previously set in BIT_initDStream() . |
414 | | * This function is safe, it guarantees it will not read beyond src buffer. |
415 | | * @return : status of `BIT_DStream_t` internal register. |
416 | | * when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */ |
417 | | MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD) |
418 | 0 | { |
419 | 0 | if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* overflow detected, like end of stream */ |
420 | 0 | return BIT_DStream_overflow; |
421 | | |
422 | 0 | if (bitD->ptr >= bitD->limitPtr) { |
423 | 0 | bitD->ptr -= bitD->bitsConsumed >> 3; |
424 | 0 | bitD->bitsConsumed &= 7; |
425 | 0 | bitD->bitContainer = MEM_readLEST(bitD->ptr); |
426 | 0 | return BIT_DStream_unfinished; |
427 | 0 | } |
428 | 0 | if (bitD->ptr == bitD->start) { |
429 | 0 | if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer; |
430 | 0 | return BIT_DStream_completed; |
431 | 0 | } |
432 | | /* start < ptr < limitPtr */ |
433 | 0 | { U32 nbBytes = bitD->bitsConsumed >> 3; |
434 | 0 | BIT_DStream_status result = BIT_DStream_unfinished; |
435 | 0 | if (bitD->ptr - nbBytes < bitD->start) { |
436 | 0 | nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */ |
437 | 0 | result = BIT_DStream_endOfBuffer; |
438 | 0 | } |
439 | 0 | bitD->ptr -= nbBytes; |
440 | 0 | bitD->bitsConsumed -= nbBytes*8; |
441 | 0 | bitD->bitContainer = MEM_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD->bitContainer), otherwise bitD->ptr == bitD->start */ |
442 | 0 | return result; |
443 | 0 | } |
444 | 0 | } Unexecuted instantiation: td_sz.c:BIT_reloadDStream Unexecuted instantiation: zstd_common.c:BIT_reloadDStream Unexecuted instantiation: zstd_compress.c:BIT_reloadDStream Unexecuted instantiation: zstd_double_fast.c:BIT_reloadDStream Unexecuted instantiation: zstd_fast.c:BIT_reloadDStream Unexecuted instantiation: zstd_lazy.c:BIT_reloadDStream Unexecuted instantiation: zstd_ldm.c:BIT_reloadDStream Unexecuted instantiation: zstd_opt.c:BIT_reloadDStream Unexecuted instantiation: zstd_decompress.c:BIT_reloadDStream Unexecuted instantiation: conf.c:BIT_reloadDStream Unexecuted instantiation: sz.c:BIT_reloadDStream Unexecuted instantiation: sz_double.c:BIT_reloadDStream Unexecuted instantiation: sz_float.c:BIT_reloadDStream Unexecuted instantiation: szd_double.c:BIT_reloadDStream Unexecuted instantiation: szd_float.c:BIT_reloadDStream Unexecuted instantiation: transcode.c:BIT_reloadDStream Unexecuted instantiation: utility.c:BIT_reloadDStream Unexecuted instantiation: entropy_common.c:BIT_reloadDStream Unexecuted instantiation: fse_decompress.c:BIT_reloadDStream Unexecuted instantiation: fse_compress.c:BIT_reloadDStream Unexecuted instantiation: huf_compress.c:BIT_reloadDStream Unexecuted instantiation: huf_decompress.c:BIT_reloadDStream Unexecuted instantiation: ByteToolkit.c:BIT_reloadDStream Unexecuted instantiation: CompressElement.c:BIT_reloadDStream Unexecuted instantiation: DynamicByteArray.c:BIT_reloadDStream Unexecuted instantiation: DynamicIntArray.c:BIT_reloadDStream Unexecuted instantiation: Huffman.c:BIT_reloadDStream Unexecuted instantiation: TightDataPointStorageD.c:BIT_reloadDStream Unexecuted instantiation: TightDataPointStorageF.c:BIT_reloadDStream Unexecuted instantiation: TypeManager.c:BIT_reloadDStream Unexecuted instantiation: dataCompression.c:BIT_reloadDStream |
445 | | |
446 | | /*! BIT_endOfDStream() : |
447 | | * @return : 1 if DStream has _exactly_ reached its end (all bits consumed). |
448 | | */ |
449 | | MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream) |
450 | 0 | { |
451 | 0 | return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8)); |
452 | 0 | } Unexecuted instantiation: td_sz.c:BIT_endOfDStream Unexecuted instantiation: zstd_common.c:BIT_endOfDStream Unexecuted instantiation: zstd_compress.c:BIT_endOfDStream Unexecuted instantiation: zstd_double_fast.c:BIT_endOfDStream Unexecuted instantiation: zstd_fast.c:BIT_endOfDStream Unexecuted instantiation: zstd_lazy.c:BIT_endOfDStream Unexecuted instantiation: zstd_ldm.c:BIT_endOfDStream Unexecuted instantiation: zstd_opt.c:BIT_endOfDStream Unexecuted instantiation: zstd_decompress.c:BIT_endOfDStream Unexecuted instantiation: conf.c:BIT_endOfDStream Unexecuted instantiation: sz.c:BIT_endOfDStream Unexecuted instantiation: sz_double.c:BIT_endOfDStream Unexecuted instantiation: sz_float.c:BIT_endOfDStream Unexecuted instantiation: szd_double.c:BIT_endOfDStream Unexecuted instantiation: szd_float.c:BIT_endOfDStream Unexecuted instantiation: transcode.c:BIT_endOfDStream Unexecuted instantiation: utility.c:BIT_endOfDStream Unexecuted instantiation: entropy_common.c:BIT_endOfDStream Unexecuted instantiation: fse_decompress.c:BIT_endOfDStream Unexecuted instantiation: fse_compress.c:BIT_endOfDStream Unexecuted instantiation: huf_compress.c:BIT_endOfDStream Unexecuted instantiation: huf_decompress.c:BIT_endOfDStream Unexecuted instantiation: ByteToolkit.c:BIT_endOfDStream Unexecuted instantiation: CompressElement.c:BIT_endOfDStream Unexecuted instantiation: DynamicByteArray.c:BIT_endOfDStream Unexecuted instantiation: DynamicIntArray.c:BIT_endOfDStream Unexecuted instantiation: Huffman.c:BIT_endOfDStream Unexecuted instantiation: TightDataPointStorageD.c:BIT_endOfDStream Unexecuted instantiation: TightDataPointStorageF.c:BIT_endOfDStream Unexecuted instantiation: TypeManager.c:BIT_endOfDStream Unexecuted instantiation: dataCompression.c:BIT_endOfDStream |
453 | | |
454 | | #if defined (__cplusplus) |
455 | | } |
456 | | #endif |
457 | | |
458 | | #endif /* BITSTREAM_H_MODULE */ |