mirror of
				https://github.com/facebook/zstd.git
				synced 2025-10-31 08:37:43 +02:00 
			
		
		
		
	no longer supported starting C++17
This commit is contained in:
		| @@ -141,7 +141,7 @@ static LDM_hashEntry *getBucket(const LDM_hashTable *table, const hash_t hash) { | ||||
|   return table->entries + (hash << HASH_BUCKET_SIZE_LOG); | ||||
| } | ||||
|  | ||||
| static unsigned ZSTD_NbCommonBytes (register size_t val) { | ||||
| static unsigned ZSTD_NbCommonBytes (size_t val) { | ||||
|   if (MEM_isLittleEndian()) { | ||||
|     if (MEM_64bits()) { | ||||
| #    if defined(_MSC_VER) && defined(_WIN64) | ||||
| @@ -854,4 +854,3 @@ void LDM_outputConfiguration(void) { | ||||
|   printf("HASH_CHAR_OFFSET: %d\n", HASH_CHAR_OFFSET); | ||||
|   printf("=====================\n"); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -167,7 +167,7 @@ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits); | ||||
| /*-************************************************************** | ||||
| *  Internal functions | ||||
| ****************************************************************/ | ||||
| MEM_STATIC unsigned BIT_highbit32 (register U32 val) | ||||
| MEM_STATIC unsigned BIT_highbit32 (U32 val) | ||||
| { | ||||
|     assert(val != 0); | ||||
|     { | ||||
|   | ||||
| @@ -268,7 +268,7 @@ MEM_STATIC void ZSTD_storeSeq(seqStore_t* seqStorePtr, size_t litLength, const v | ||||
| /*-************************************* | ||||
| *  Match length counter | ||||
| ***************************************/ | ||||
| static unsigned ZSTD_NbCommonBytes (register size_t val) | ||||
| static unsigned ZSTD_NbCommonBytes (size_t val) | ||||
| { | ||||
|     if (MEM_isLittleEndian()) { | ||||
|         if (MEM_64bits()) { | ||||
|   | ||||
| @@ -103,7 +103,7 @@ unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize) | ||||
| /*-******************************************************** | ||||
| *  Dictionary training functions | ||||
| **********************************************************/ | ||||
| static unsigned ZDICT_NbCommonBytes (register size_t val) | ||||
| static unsigned ZDICT_NbCommonBytes (size_t val) | ||||
| { | ||||
|     if (MEM_isLittleEndian()) { | ||||
|         if (MEM_64bits()) { | ||||
|   | ||||
| @@ -339,7 +339,7 @@ typedef U32 DTable_max_t[FSE_DTABLE_SIZE_U32(FSE_MAX_TABLELOG)]; | ||||
| /**************************************************************** | ||||
| *  Internal functions | ||||
| ****************************************************************/ | ||||
| FORCE_INLINE unsigned FSE_highbit32 (register U32 val) | ||||
| FORCE_INLINE unsigned FSE_highbit32 (U32 val) | ||||
| { | ||||
| #   if defined(_MSC_VER)   /* Visual */ | ||||
|     unsigned long r; | ||||
|   | ||||
| @@ -330,18 +330,6 @@ MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD); | ||||
| MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD); | ||||
|  | ||||
|  | ||||
| /* | ||||
| * Start by invoking BIT_initDStream(). | ||||
| * A chunk of the bitStream is then stored into a local register. | ||||
| * Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t). | ||||
| * You can then retrieve bitFields stored into the local register, **in reverse order**. | ||||
| * Local register is manually filled from memory by the BIT_reloadDStream() method. | ||||
| * A reload guarantee a minimum of ((8*sizeof(size_t))-7) bits when its result is BIT_DStream_unfinished. | ||||
| * Otherwise, it can be less than that, so proceed accordingly. | ||||
| * Checking if DStream has reached its end can be performed with BIT_endOfDStream() | ||||
| */ | ||||
|  | ||||
|  | ||||
| /****************************************** | ||||
| *  unsafe API | ||||
| ******************************************/ | ||||
| @@ -353,7 +341,7 @@ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits); | ||||
| /**************************************************************** | ||||
| *  Helper functions | ||||
| ****************************************************************/ | ||||
| MEM_STATIC unsigned BIT_highbit32 (register U32 val) | ||||
| MEM_STATIC unsigned BIT_highbit32 (U32 val) | ||||
| { | ||||
| #   if defined(_MSC_VER)   /* Visual */ | ||||
|     unsigned long r=0; | ||||
| @@ -427,13 +415,6 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si | ||||
|     return srcSize; | ||||
| } | ||||
|  | ||||
| /*!BIT_lookBits | ||||
|  * Provides next n bits from local register | ||||
|  * local register is not modified (bits are still present for next read/look) | ||||
|  * On 32-bits, maxNbBits==25 | ||||
|  * On 64-bits, maxNbBits==57 | ||||
|  * @return : value extracted | ||||
|  */ | ||||
| MEM_STATIC size_t BIT_lookBits(BIT_DStream_t* bitD, U32 nbBits) | ||||
| { | ||||
|     const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1; | ||||
| @@ -453,11 +434,6 @@ MEM_STATIC void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits) | ||||
|     bitD->bitsConsumed += nbBits; | ||||
| } | ||||
|  | ||||
| /*!BIT_readBits | ||||
|  * Read next n bits from local register. | ||||
|  * pay attention to not read more than nbBits contained into local register. | ||||
|  * @return : extracted value. | ||||
|  */ | ||||
| MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits) | ||||
| { | ||||
|     size_t value = BIT_lookBits(bitD, nbBits); | ||||
| @@ -695,55 +671,6 @@ static unsigned char FSE_decodeSymbol(FSE_DState_t* DStatePtr, BIT_DStream_t* bi | ||||
|  | ||||
| static unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr); | ||||
|  | ||||
| /* | ||||
| Let's now decompose FSE_decompress_usingDTable() into its unitary components. | ||||
| You will decode FSE-encoded symbols from the bitStream, | ||||
| and also any other bitFields you put in, **in reverse order**. | ||||
|  | ||||
| You will need a few variables to track your bitStream. They are : | ||||
|  | ||||
| BIT_DStream_t DStream;    // Stream context | ||||
| FSE_DState_t  DState;     // State context. Multiple ones are possible | ||||
| FSE_DTable*   DTablePtr;  // Decoding table, provided by FSE_buildDTable() | ||||
|  | ||||
| The first thing to do is to init the bitStream. | ||||
|     errorCode = BIT_initDStream(&DStream, srcBuffer, srcSize); | ||||
|  | ||||
| You should then retrieve your initial state(s) | ||||
| (in reverse flushing order if you have several ones) : | ||||
|     errorCode = FSE_initDState(&DState, &DStream, DTablePtr); | ||||
|  | ||||
| You can then decode your data, symbol after symbol. | ||||
| For information the maximum number of bits read by FSE_decodeSymbol() is 'tableLog'. | ||||
| Keep in mind that symbols are decoded in reverse order, like a LIFO stack (last in, first out). | ||||
|     unsigned char symbol = FSE_decodeSymbol(&DState, &DStream); | ||||
|  | ||||
| You can retrieve any bitfield you eventually stored into the bitStream (in reverse order) | ||||
| Note : maximum allowed nbBits is 25, for 32-bits compatibility | ||||
|     size_t bitField = BIT_readBits(&DStream, nbBits); | ||||
|  | ||||
| All above operations only read from local register (which size depends on size_t). | ||||
| Refueling the register from memory is manually performed by the reload method. | ||||
|     endSignal = FSE_reloadDStream(&DStream); | ||||
|  | ||||
| BIT_reloadDStream() result tells if there is still some more data to read from DStream. | ||||
| BIT_DStream_unfinished : there is still some data left into the DStream. | ||||
| BIT_DStream_endOfBuffer : Dstream reached end of buffer. Its container may no longer be completely filled. | ||||
| BIT_DStream_completed : Dstream reached its exact end, corresponding in general to decompression completed. | ||||
| BIT_DStream_tooFar : Dstream went too far. Decompression result is corrupted. | ||||
|  | ||||
| When reaching end of buffer (BIT_DStream_endOfBuffer), progress slowly, notably if you decode multiple symbols per loop, | ||||
| to properly detect the exact end of stream. | ||||
| After each decoded symbol, check if DStream is fully consumed using this simple test : | ||||
|     BIT_reloadDStream(&DStream) >= BIT_DStream_completed | ||||
|  | ||||
| When it's done, verify decompression is fully completed, by checking both DStream and the relevant states. | ||||
| Checking if DStream has reached its end is performed by : | ||||
|     BIT_endOfDStream(&DStream); | ||||
| Check also the states. There might be some symbols left there, if some high probability ones (>50%) are possible. | ||||
|     FSE_endOfDState(&DState); | ||||
| */ | ||||
|  | ||||
|  | ||||
| /****************************************** | ||||
| *  FSE unsafe API | ||||
|   | ||||
| @@ -332,17 +332,6 @@ MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD); | ||||
| MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD); | ||||
|  | ||||
|  | ||||
| /* | ||||
| * Start by invoking BIT_initDStream(). | ||||
| * A chunk of the bitStream is then stored into a local register. | ||||
| * Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t). | ||||
| * You can then retrieve bitFields stored into the local register, **in reverse order**. | ||||
| * Local register is manually filled from memory by the BIT_reloadDStream() method. | ||||
| * A reload guarantee a minimum of ((8*sizeof(size_t))-7) bits when its result is BIT_DStream_unfinished. | ||||
| * Otherwise, it can be less than that, so proceed accordingly. | ||||
| * Checking if DStream has reached its end can be performed with BIT_endOfDStream() | ||||
| */ | ||||
|  | ||||
|  | ||||
| /****************************************** | ||||
| *  unsafe API | ||||
| @@ -355,7 +344,7 @@ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits); | ||||
| /**************************************************************** | ||||
| *  Helper functions | ||||
| ****************************************************************/ | ||||
| MEM_STATIC unsigned BIT_highbit32 (register U32 val) | ||||
| MEM_STATIC unsigned BIT_highbit32 (U32 val) | ||||
| { | ||||
| #   if defined(_MSC_VER)   /* Visual */ | ||||
|     unsigned long r=0; | ||||
| @@ -428,14 +417,6 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si | ||||
|  | ||||
|     return srcSize; | ||||
| } | ||||
|  | ||||
| /*!BIT_lookBits | ||||
|  * Provides next n bits from local register | ||||
|  * local register is not modified (bits are still present for next read/look) | ||||
|  * On 32-bits, maxNbBits==25 | ||||
|  * On 64-bits, maxNbBits==57 | ||||
|  * @return : value extracted | ||||
|  */ | ||||
| MEM_STATIC size_t BIT_lookBits(BIT_DStream_t* bitD, U32 nbBits) | ||||
| { | ||||
|     const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1; | ||||
| @@ -455,11 +436,6 @@ MEM_STATIC void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits) | ||||
|     bitD->bitsConsumed += nbBits; | ||||
| } | ||||
|  | ||||
| /*!BIT_readBits | ||||
|  * Read next n bits from local register. | ||||
|  * pay attention to not read more than nbBits contained into local register. | ||||
|  * @return : extracted value. | ||||
|  */ | ||||
| MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits) | ||||
| { | ||||
|     size_t value = BIT_lookBits(bitD, nbBits); | ||||
| @@ -697,55 +673,6 @@ static unsigned char FSE_decodeSymbol(FSE_DState_t* DStatePtr, BIT_DStream_t* bi | ||||
|  | ||||
| static unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr); | ||||
|  | ||||
| /* | ||||
| Let's now decompose FSE_decompress_usingDTable() into its unitary components. | ||||
| You will decode FSE-encoded symbols from the bitStream, | ||||
| and also any other bitFields you put in, **in reverse order**. | ||||
|  | ||||
| You will need a few variables to track your bitStream. They are : | ||||
|  | ||||
| BIT_DStream_t DStream;    // Stream context | ||||
| FSE_DState_t  DState;     // State context. Multiple ones are possible | ||||
| FSE_DTable*   DTablePtr;  // Decoding table, provided by FSE_buildDTable() | ||||
|  | ||||
| The first thing to do is to init the bitStream. | ||||
|     errorCode = BIT_initDStream(&DStream, srcBuffer, srcSize); | ||||
|  | ||||
| You should then retrieve your initial state(s) | ||||
| (in reverse flushing order if you have several ones) : | ||||
|     errorCode = FSE_initDState(&DState, &DStream, DTablePtr); | ||||
|  | ||||
| You can then decode your data, symbol after symbol. | ||||
| For information the maximum number of bits read by FSE_decodeSymbol() is 'tableLog'. | ||||
| Keep in mind that symbols are decoded in reverse order, like a LIFO stack (last in, first out). | ||||
|     unsigned char symbol = FSE_decodeSymbol(&DState, &DStream); | ||||
|  | ||||
| You can retrieve any bitfield you eventually stored into the bitStream (in reverse order) | ||||
| Note : maximum allowed nbBits is 25, for 32-bits compatibility | ||||
|     size_t bitField = BIT_readBits(&DStream, nbBits); | ||||
|  | ||||
| All above operations only read from local register (which size depends on size_t). | ||||
| Refueling the register from memory is manually performed by the reload method. | ||||
|     endSignal = FSE_reloadDStream(&DStream); | ||||
|  | ||||
| BIT_reloadDStream() result tells if there is still some more data to read from DStream. | ||||
| BIT_DStream_unfinished : there is still some data left into the DStream. | ||||
| BIT_DStream_endOfBuffer : Dstream reached end of buffer. Its container may no longer be completely filled. | ||||
| BIT_DStream_completed : Dstream reached its exact end, corresponding in general to decompression completed. | ||||
| BIT_DStream_tooFar : Dstream went too far. Decompression result is corrupted. | ||||
|  | ||||
| When reaching end of buffer (BIT_DStream_endOfBuffer), progress slowly, notably if you decode multiple symbols per loop, | ||||
| to properly detect the exact end of stream. | ||||
| After each decoded symbol, check if DStream is fully consumed using this simple test : | ||||
|     BIT_reloadDStream(&DStream) >= BIT_DStream_completed | ||||
|  | ||||
| When it's done, verify decompression is fully completed, by checking both DStream and the relevant states. | ||||
| Checking if DStream has reached its end is performed by : | ||||
|     BIT_endOfDStream(&DStream); | ||||
| Check also the states. There might be some symbols left there, if some high probability ones (>50%) are possible. | ||||
|     FSE_endOfDState(&DState); | ||||
| */ | ||||
|  | ||||
|  | ||||
| /****************************************** | ||||
| *  FSE unsafe API | ||||
|   | ||||
| @@ -738,16 +738,6 @@ MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD); | ||||
| MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD); | ||||
|  | ||||
|  | ||||
| /* | ||||
| * Start by invoking BIT_initDStream(). | ||||
| * A chunk of the bitStream is then stored into a local register. | ||||
| * Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t). | ||||
| * You can then retrieve bitFields stored into the local register, **in reverse order**. | ||||
| * Local register is manually filled from memory by the BIT_reloadDStream() method. | ||||
| * A reload guarantee a minimum of ((8*sizeof(size_t))-7) bits when its result is BIT_DStream_unfinished. | ||||
| * Otherwise, it can be less than that, so proceed accordingly. | ||||
| * Checking if DStream has reached its end can be performed with BIT_endOfDStream() | ||||
| */ | ||||
|  | ||||
|  | ||||
| /****************************************** | ||||
| @@ -761,7 +751,7 @@ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits); | ||||
| /**************************************************************** | ||||
| *  Helper functions | ||||
| ****************************************************************/ | ||||
| MEM_STATIC unsigned BIT_highbit32 (register U32 val) | ||||
| MEM_STATIC unsigned BIT_highbit32 (U32 val) | ||||
| { | ||||
| #   if defined(_MSC_VER)   /* Visual */ | ||||
|     unsigned long r=0; | ||||
| @@ -834,13 +824,6 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si | ||||
|     return srcSize; | ||||
| } | ||||
|  | ||||
| /*!BIT_lookBits | ||||
|  * Provides next n bits from local register | ||||
|  * local register is not modified (bits are still present for next read/look) | ||||
|  * On 32-bits, maxNbBits==25 | ||||
|  * On 64-bits, maxNbBits==57 | ||||
|  * @return : value extracted | ||||
|  */ | ||||
| MEM_STATIC size_t BIT_lookBits(BIT_DStream_t* bitD, U32 nbBits) | ||||
| { | ||||
|     const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1; | ||||
| @@ -860,11 +843,6 @@ MEM_STATIC void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits) | ||||
|     bitD->bitsConsumed += nbBits; | ||||
| } | ||||
|  | ||||
| /*!BIT_readBits | ||||
|  * Read next n bits from local register. | ||||
|  * pay attention to not read more than nbBits contained into local register. | ||||
|  * @return : extracted value. | ||||
|  */ | ||||
| MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits) | ||||
| { | ||||
|     size_t value = BIT_lookBits(bitD, nbBits); | ||||
| @@ -1011,55 +989,6 @@ static unsigned char FSE_decodeSymbol(FSE_DState_t* DStatePtr, BIT_DStream_t* bi | ||||
|  | ||||
| static unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr); | ||||
|  | ||||
| /*! | ||||
| Let's now decompose FSE_decompress_usingDTable() into its unitary components. | ||||
| You will decode FSE-encoded symbols from the bitStream, | ||||
| and also any other bitFields you put in, **in reverse order**. | ||||
|  | ||||
| You will need a few variables to track your bitStream. They are : | ||||
|  | ||||
| BIT_DStream_t DStream;    // Stream context | ||||
| FSE_DState_t  DState;     // State context. Multiple ones are possible | ||||
| FSE_DTable*   DTablePtr;  // Decoding table, provided by FSE_buildDTable() | ||||
|  | ||||
| The first thing to do is to init the bitStream. | ||||
|     errorCode = BIT_initDStream(&DStream, srcBuffer, srcSize); | ||||
|  | ||||
| You should then retrieve your initial state(s) | ||||
| (in reverse flushing order if you have several ones) : | ||||
|     errorCode = FSE_initDState(&DState, &DStream, DTablePtr); | ||||
|  | ||||
| You can then decode your data, symbol after symbol. | ||||
| For information the maximum number of bits read by FSE_decodeSymbol() is 'tableLog'. | ||||
| Keep in mind that symbols are decoded in reverse order, like a LIFO stack (last in, first out). | ||||
|     unsigned char symbol = FSE_decodeSymbol(&DState, &DStream); | ||||
|  | ||||
| You can retrieve any bitfield you eventually stored into the bitStream (in reverse order) | ||||
| Note : maximum allowed nbBits is 25, for 32-bits compatibility | ||||
|     size_t bitField = BIT_readBits(&DStream, nbBits); | ||||
|  | ||||
| All above operations only read from local register (which size depends on size_t). | ||||
| Refueling the register from memory is manually performed by the reload method. | ||||
|     endSignal = FSE_reloadDStream(&DStream); | ||||
|  | ||||
| BIT_reloadDStream() result tells if there is still some more data to read from DStream. | ||||
| BIT_DStream_unfinished : there is still some data left into the DStream. | ||||
| BIT_DStream_endOfBuffer : Dstream reached end of buffer. Its container may no longer be completely filled. | ||||
| BIT_DStream_completed : Dstream reached its exact end, corresponding in general to decompression completed. | ||||
| BIT_DStream_tooFar : Dstream went too far. Decompression result is corrupted. | ||||
|  | ||||
| When reaching end of buffer (BIT_DStream_endOfBuffer), progress slowly, notably if you decode multiple symbols per loop, | ||||
| to properly detect the exact end of stream. | ||||
| After each decoded symbol, check if DStream is fully consumed using this simple test : | ||||
|     BIT_reloadDStream(&DStream) >= BIT_DStream_completed | ||||
|  | ||||
| When it's done, verify decompression is fully completed, by checking both DStream and the relevant states. | ||||
| Checking if DStream has reached its end is performed by : | ||||
|     BIT_endOfDStream(&DStream); | ||||
| Check also the states. There might be some symbols left there, if some high probability ones (>50%) are possible. | ||||
|     FSE_endOfDState(&DState); | ||||
| */ | ||||
|  | ||||
|  | ||||
| /* ***************************************** | ||||
| *  FSE unsafe API | ||||
|   | ||||
| @@ -736,18 +736,6 @@ MEM_STATIC BITv05_DStream_status BITv05_reloadDStream(BITv05_DStream_t* bitD); | ||||
| MEM_STATIC unsigned BITv05_endOfDStream(const BITv05_DStream_t* bitD); | ||||
|  | ||||
|  | ||||
| /*! | ||||
| * Start by invoking BITv05_initDStream(). | ||||
| * A chunk of the bitStream is then stored into a local register. | ||||
| * Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t). | ||||
| * You can then retrieve bitFields stored into the local register, **in reverse order**. | ||||
| * Local register is explicitly reloaded from memory by the BITv05_reloadDStream() method. | ||||
| * A reload guarantee a minimum of ((8*sizeof(size_t))-7) bits when its result is BITv05_DStream_unfinished. | ||||
| * Otherwise, it can be less than that, so proceed accordingly. | ||||
| * Checking if DStream has reached its end can be performed with BITv05_endOfDStream() | ||||
| */ | ||||
|  | ||||
|  | ||||
| /*-**************************************** | ||||
| *  unsafe API | ||||
| ******************************************/ | ||||
| @@ -759,7 +747,7 @@ MEM_STATIC size_t BITv05_readBitsFast(BITv05_DStream_t* bitD, unsigned nbBits); | ||||
| /*-************************************************************** | ||||
| *  Helper functions | ||||
| ****************************************************************/ | ||||
| MEM_STATIC unsigned BITv05_highbit32 (register U32 val) | ||||
| MEM_STATIC unsigned BITv05_highbit32 (U32 val) | ||||
| { | ||||
| #   if defined(_MSC_VER)   /* Visual */ | ||||
|     unsigned long r=0; | ||||
| @@ -829,13 +817,6 @@ MEM_STATIC size_t BITv05_initDStream(BITv05_DStream_t* bitD, const void* srcBuff | ||||
|     return srcSize; | ||||
| } | ||||
|  | ||||
| /*!BITv05_lookBits | ||||
|  * Provides next n bits from local register | ||||
|  * local register is not modified (bits are still present for next read/look) | ||||
|  * On 32-bits, maxNbBits==25 | ||||
|  * On 64-bits, maxNbBits==57 | ||||
|  * @return : value extracted | ||||
|  */ | ||||
| MEM_STATIC size_t BITv05_lookBits(BITv05_DStream_t* bitD, U32 nbBits) | ||||
| { | ||||
|     const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1; | ||||
| @@ -855,11 +836,6 @@ MEM_STATIC void BITv05_skipBits(BITv05_DStream_t* bitD, U32 nbBits) | ||||
|     bitD->bitsConsumed += nbBits; | ||||
| } | ||||
|  | ||||
| /*!BITv05_readBits | ||||
|  * Read next n bits from local register. | ||||
|  * pay attention to not read more than nbBits contained into local register. | ||||
|  * @return : extracted value. | ||||
|  */ | ||||
| MEM_STATIC size_t BITv05_readBits(BITv05_DStream_t* bitD, U32 nbBits) | ||||
| { | ||||
|     size_t value = BITv05_lookBits(bitD, nbBits); | ||||
| @@ -995,54 +971,6 @@ static unsigned char FSEv05_decodeSymbol(FSEv05_DState_t* DStatePtr, BITv05_DStr | ||||
|  | ||||
| static unsigned FSEv05_endOfDState(const FSEv05_DState_t* DStatePtr); | ||||
|  | ||||
| /*! | ||||
| Let's now decompose FSEv05_decompress_usingDTable() into its unitary components. | ||||
| You will decode FSEv05-encoded symbols from the bitStream, | ||||
| and also any other bitFields you put in, **in reverse order**. | ||||
|  | ||||
| You will need a few variables to track your bitStream. They are : | ||||
|  | ||||
| BITv05_DStream_t DStream;    // Stream context | ||||
| FSEv05_DState_t  DState;     // State context. Multiple ones are possible | ||||
| FSEv05_DTable*   DTablePtr;  // Decoding table, provided by FSEv05_buildDTable() | ||||
|  | ||||
| The first thing to do is to init the bitStream. | ||||
|     errorCode = BITv05_initDStream(&DStream, srcBuffer, srcSize); | ||||
|  | ||||
| You should then retrieve your initial state(s) | ||||
| (in reverse flushing order if you have several ones) : | ||||
|     errorCode = FSEv05_initDState(&DState, &DStream, DTablePtr); | ||||
|  | ||||
| You can then decode your data, symbol after symbol. | ||||
| For information the maximum number of bits read by FSEv05_decodeSymbol() is 'tableLog'. | ||||
| Keep in mind that symbols are decoded in reverse order, like a LIFO stack (last in, first out). | ||||
|     unsigned char symbol = FSEv05_decodeSymbol(&DState, &DStream); | ||||
|  | ||||
| You can retrieve any bitfield you eventually stored into the bitStream (in reverse order) | ||||
| Note : maximum allowed nbBits is 25, for 32-bits compatibility | ||||
|     size_t bitField = BITv05_readBits(&DStream, nbBits); | ||||
|  | ||||
| All above operations only read from local register (which size depends on size_t). | ||||
| Refueling the register from memory is manually performed by the reload method. | ||||
|     endSignal = FSEv05_reloadDStream(&DStream); | ||||
|  | ||||
| BITv05_reloadDStream() result tells if there is still some more data to read from DStream. | ||||
| BITv05_DStream_unfinished : there is still some data left into the DStream. | ||||
| BITv05_DStream_endOfBuffer : Dstream reached end of buffer. Its container may no longer be completely filled. | ||||
| BITv05_DStream_completed : Dstream reached its exact end, corresponding in general to decompression completed. | ||||
| BITv05_DStream_tooFar : Dstream went too far. Decompression result is corrupted. | ||||
|  | ||||
| When reaching end of buffer (BITv05_DStream_endOfBuffer), progress slowly, notably if you decode multiple symbols per loop, | ||||
| to properly detect the exact end of stream. | ||||
| After each decoded symbol, check if DStream is fully consumed using this simple test : | ||||
|     BITv05_reloadDStream(&DStream) >= BITv05_DStream_completed | ||||
|  | ||||
| When it's done, verify decompression is fully completed, by checking both DStream and the relevant states. | ||||
| Checking if DStream has reached its end is performed by : | ||||
|     BITv05_endOfDStream(&DStream); | ||||
| Check also the states. There might be some symbols left there, if some high probability ones (>50%) are possible. | ||||
|     FSEv05_endOfDState(&DState); | ||||
| */ | ||||
|  | ||||
|  | ||||
| /* ***************************************** | ||||
|   | ||||
| @@ -839,16 +839,6 @@ MEM_STATIC BITv06_DStream_status BITv06_reloadDStream(BITv06_DStream_t* bitD); | ||||
| MEM_STATIC unsigned BITv06_endOfDStream(const BITv06_DStream_t* bitD); | ||||
|  | ||||
|  | ||||
| /* Start by invoking BITv06_initDStream(). | ||||
| *  A chunk of the bitStream is then stored into a local register. | ||||
| *  Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t). | ||||
| *  You can then retrieve bitFields stored into the local register, **in reverse order**. | ||||
| *  Local register is explicitly reloaded from memory by the BITv06_reloadDStream() method. | ||||
| *  A reload guarantee a minimum of ((8*sizeof(bitD->bitContainer))-7) bits when its result is BITv06_DStream_unfinished. | ||||
| *  Otherwise, it can be less than that, so proceed accordingly. | ||||
| *  Checking if DStream has reached its end can be performed with BITv06_endOfDStream(). | ||||
| */ | ||||
|  | ||||
|  | ||||
| /*-**************************************** | ||||
| *  unsafe API | ||||
| @@ -861,7 +851,7 @@ MEM_STATIC size_t BITv06_readBitsFast(BITv06_DStream_t* bitD, unsigned nbBits); | ||||
| /*-************************************************************** | ||||
| *  Internal functions | ||||
| ****************************************************************/ | ||||
| MEM_STATIC unsigned BITv06_highbit32 (register U32 val) | ||||
| MEM_STATIC unsigned BITv06_highbit32 ( U32 val) | ||||
| { | ||||
| #   if defined(_MSC_VER)   /* Visual */ | ||||
|     unsigned long r=0; | ||||
| @@ -929,13 +919,6 @@ MEM_STATIC size_t BITv06_initDStream(BITv06_DStream_t* bitD, const void* srcBuff | ||||
| } | ||||
|  | ||||
|  | ||||
| /*! BITv06_lookBits() : | ||||
|  *  Provides next n bits from local register. | ||||
|  *  local register is not modified. | ||||
|  *  On 32-bits, maxNbBits==24. | ||||
|  *  On 64-bits, maxNbBits==56. | ||||
|  *  @return : value extracted | ||||
|  */ | ||||
|  MEM_STATIC size_t BITv06_lookBits(const BITv06_DStream_t* bitD, U32 nbBits) | ||||
| { | ||||
|     U32 const bitMask = sizeof(bitD->bitContainer)*8 - 1; | ||||
| @@ -955,11 +938,6 @@ MEM_STATIC void BITv06_skipBits(BITv06_DStream_t* bitD, U32 nbBits) | ||||
|     bitD->bitsConsumed += nbBits; | ||||
| } | ||||
|  | ||||
| /*! BITv06_readBits() : | ||||
|  *  Read (consume) next n bits from local register and update. | ||||
|  *  Pay attention to not read more than nbBits contained into local register. | ||||
|  *  @return : extracted value. | ||||
|  */ | ||||
| MEM_STATIC size_t BITv06_readBits(BITv06_DStream_t* bitD, U32 nbBits) | ||||
| { | ||||
|     size_t const value = BITv06_lookBits(bitD, nbBits); | ||||
| @@ -976,11 +954,6 @@ MEM_STATIC size_t BITv06_readBitsFast(BITv06_DStream_t* bitD, U32 nbBits) | ||||
|     return value; | ||||
| } | ||||
|  | ||||
| /*! BITv06_reloadDStream() : | ||||
| *   Refill `BITv06_DStream_t` from src buffer previously defined (see BITv06_initDStream() ). | ||||
| *   This function is safe, it guarantees it will not read beyond src buffer. | ||||
| *   @return : status of `BITv06_DStream_t` internal register. | ||||
|               if status == unfinished, internal register is filled with >= (sizeof(bitD->bitContainer)*8 - 7) bits */ | ||||
| MEM_STATIC BITv06_DStream_status BITv06_reloadDStream(BITv06_DStream_t* bitD) | ||||
| { | ||||
|     if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8))  /* should never happen */ | ||||
| @@ -1103,55 +1076,6 @@ static void     FSEv06_initDState(FSEv06_DState_t* DStatePtr, BITv06_DStream_t* | ||||
|  | ||||
| static unsigned char FSEv06_decodeSymbol(FSEv06_DState_t* DStatePtr, BITv06_DStream_t* bitD); | ||||
|  | ||||
| /*! | ||||
| Let's now decompose FSEv06_decompress_usingDTable() into its unitary components. | ||||
| You will decode FSE-encoded symbols from the bitStream, | ||||
| and also any other bitFields you put in, **in reverse order**. | ||||
|  | ||||
| You will need a few variables to track your bitStream. They are : | ||||
|  | ||||
| BITv06_DStream_t DStream;    // Stream context | ||||
| FSEv06_DState_t  DState;     // State context. Multiple ones are possible | ||||
| FSEv06_DTable*   DTablePtr;  // Decoding table, provided by FSEv06_buildDTable() | ||||
|  | ||||
| The first thing to do is to init the bitStream. | ||||
|     errorCode = BITv06_initDStream(&DStream, srcBuffer, srcSize); | ||||
|  | ||||
| You should then retrieve your initial state(s) | ||||
| (in reverse flushing order if you have several ones) : | ||||
|     errorCode = FSEv06_initDState(&DState, &DStream, DTablePtr); | ||||
|  | ||||
| You can then decode your data, symbol after symbol. | ||||
| For information the maximum number of bits read by FSEv06_decodeSymbol() is 'tableLog'. | ||||
| Keep in mind that symbols are decoded in reverse order, like a LIFO stack (last in, first out). | ||||
|     unsigned char symbol = FSEv06_decodeSymbol(&DState, &DStream); | ||||
|  | ||||
| You can retrieve any bitfield you eventually stored into the bitStream (in reverse order) | ||||
| Note : maximum allowed nbBits is 25, for 32-bits compatibility | ||||
|     size_t bitField = BITv06_readBits(&DStream, nbBits); | ||||
|  | ||||
| All above operations only read from local register (which size depends on size_t). | ||||
| Refueling the register from memory is manually performed by the reload method. | ||||
|     endSignal = FSEv06_reloadDStream(&DStream); | ||||
|  | ||||
| BITv06_reloadDStream() result tells if there is still some more data to read from DStream. | ||||
| BITv06_DStream_unfinished : there is still some data left into the DStream. | ||||
| BITv06_DStream_endOfBuffer : Dstream reached end of buffer. Its container may no longer be completely filled. | ||||
| BITv06_DStream_completed : Dstream reached its exact end, corresponding in general to decompression completed. | ||||
| BITv06_DStream_tooFar : Dstream went too far. Decompression result is corrupted. | ||||
|  | ||||
| When reaching end of buffer (BITv06_DStream_endOfBuffer), progress slowly, notably if you decode multiple symbols per loop, | ||||
| to properly detect the exact end of stream. | ||||
| After each decoded symbol, check if DStream is fully consumed using this simple test : | ||||
|     BITv06_reloadDStream(&DStream) >= BITv06_DStream_completed | ||||
|  | ||||
| When it's done, verify decompression is fully completed, by checking both DStream and the relevant states. | ||||
| Checking if DStream has reached its end is performed by : | ||||
|     BITv06_endOfDStream(&DStream); | ||||
| Check also the states. There might be some symbols left there, if some high probability ones (>50%) are possible. | ||||
|     FSEv06_endOfDState(&DState); | ||||
| */ | ||||
|  | ||||
|  | ||||
| /* ***************************************** | ||||
| *  FSE unsafe API | ||||
|   | ||||
| @@ -511,16 +511,6 @@ MEM_STATIC BITv07_DStream_status BITv07_reloadDStream(BITv07_DStream_t* bitD); | ||||
| MEM_STATIC unsigned BITv07_endOfDStream(const BITv07_DStream_t* bitD); | ||||
|  | ||||
|  | ||||
| /* Start by invoking BITv07_initDStream(). | ||||
| *  A chunk of the bitStream is then stored into a local register. | ||||
| *  Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t). | ||||
| *  You can then retrieve bitFields stored into the local register, **in reverse order**. | ||||
| *  Local register is explicitly reloaded from memory by the BITv07_reloadDStream() method. | ||||
| *  A reload guarantee a minimum of ((8*sizeof(bitD->bitContainer))-7) bits when its result is BITv07_DStream_unfinished. | ||||
| *  Otherwise, it can be less than that, so proceed accordingly. | ||||
| *  Checking if DStream has reached its end can be performed with BITv07_endOfDStream(). | ||||
| */ | ||||
|  | ||||
|  | ||||
| /*-**************************************** | ||||
| *  unsafe API | ||||
| @@ -533,7 +523,7 @@ MEM_STATIC size_t BITv07_readBitsFast(BITv07_DStream_t* bitD, unsigned nbBits); | ||||
| /*-************************************************************** | ||||
| *  Internal functions | ||||
| ****************************************************************/ | ||||
| MEM_STATIC unsigned BITv07_highbit32 (register U32 val) | ||||
| MEM_STATIC unsigned BITv07_highbit32 (U32 val) | ||||
| { | ||||
| #   if defined(_MSC_VER)   /* Visual */ | ||||
|     unsigned long r=0; | ||||
| @@ -599,13 +589,6 @@ MEM_STATIC size_t BITv07_initDStream(BITv07_DStream_t* bitD, const void* srcBuff | ||||
| } | ||||
|  | ||||
|  | ||||
| /*! BITv07_lookBits() : | ||||
|  *  Provides next n bits from local register. | ||||
|  *  local register is not modified. | ||||
|  *  On 32-bits, maxNbBits==24. | ||||
|  *  On 64-bits, maxNbBits==56. | ||||
|  *  @return : value extracted | ||||
|  */ | ||||
|  MEM_STATIC size_t BITv07_lookBits(const BITv07_DStream_t* bitD, U32 nbBits) | ||||
| { | ||||
|     U32 const bitMask = sizeof(bitD->bitContainer)*8 - 1; | ||||
| @@ -625,11 +608,6 @@ MEM_STATIC void BITv07_skipBits(BITv07_DStream_t* bitD, U32 nbBits) | ||||
|     bitD->bitsConsumed += nbBits; | ||||
| } | ||||
|  | ||||
| /*! BITv07_readBits() : | ||||
|  *  Read (consume) next n bits from local register and update. | ||||
|  *  Pay attention to not read more than nbBits contained into local register. | ||||
|  *  @return : extracted value. | ||||
|  */ | ||||
| MEM_STATIC size_t BITv07_readBits(BITv07_DStream_t* bitD, U32 nbBits) | ||||
| { | ||||
|     size_t const value = BITv07_lookBits(bitD, nbBits); | ||||
| @@ -646,11 +624,6 @@ MEM_STATIC size_t BITv07_readBitsFast(BITv07_DStream_t* bitD, U32 nbBits) | ||||
|     return value; | ||||
| } | ||||
|  | ||||
| /*! BITv07_reloadDStream() : | ||||
| *   Refill `BITv07_DStream_t` from src buffer previously defined (see BITv07_initDStream() ). | ||||
| *   This function is safe, it guarantees it will not read beyond src buffer. | ||||
| *   @return : status of `BITv07_DStream_t` internal register. | ||||
|               if status == unfinished, internal register is filled with >= (sizeof(bitD->bitContainer)*8 - 7) bits */ | ||||
| MEM_STATIC BITv07_DStream_status BITv07_reloadDStream(BITv07_DStream_t* bitD) | ||||
| { | ||||
|     if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8))  /* should not happen => corruption detected */ | ||||
| @@ -874,55 +847,6 @@ static void     FSEv07_initDState(FSEv07_DState_t* DStatePtr, BITv07_DStream_t* | ||||
| static unsigned char FSEv07_decodeSymbol(FSEv07_DState_t* DStatePtr, BITv07_DStream_t* bitD); | ||||
|  | ||||
|  | ||||
| /**< | ||||
| Let's now decompose FSEv07_decompress_usingDTable() into its unitary components. | ||||
| You will decode FSE-encoded symbols from the bitStream, | ||||
| and also any other bitFields you put in, **in reverse order**. | ||||
|  | ||||
| You will need a few variables to track your bitStream. They are : | ||||
|  | ||||
| BITv07_DStream_t DStream;    // Stream context | ||||
| FSEv07_DState_t  DState;     // State context. Multiple ones are possible | ||||
| FSEv07_DTable*   DTablePtr;  // Decoding table, provided by FSEv07_buildDTable() | ||||
|  | ||||
| The first thing to do is to init the bitStream. | ||||
|     errorCode = BITv07_initDStream(&DStream, srcBuffer, srcSize); | ||||
|  | ||||
| You should then retrieve your initial state(s) | ||||
| (in reverse flushing order if you have several ones) : | ||||
|     errorCode = FSEv07_initDState(&DState, &DStream, DTablePtr); | ||||
|  | ||||
| You can then decode your data, symbol after symbol. | ||||
| For information the maximum number of bits read by FSEv07_decodeSymbol() is 'tableLog'. | ||||
| Keep in mind that symbols are decoded in reverse order, like a LIFO stack (last in, first out). | ||||
|     unsigned char symbol = FSEv07_decodeSymbol(&DState, &DStream); | ||||
|  | ||||
| You can retrieve any bitfield you eventually stored into the bitStream (in reverse order) | ||||
| Note : maximum allowed nbBits is 25, for 32-bits compatibility | ||||
|     size_t bitField = BITv07_readBits(&DStream, nbBits); | ||||
|  | ||||
| All above operations only read from local register (which size depends on size_t). | ||||
| Refueling the register from memory is manually performed by the reload method. | ||||
|     endSignal = FSEv07_reloadDStream(&DStream); | ||||
|  | ||||
| BITv07_reloadDStream() result tells if there is still some more data to read from DStream. | ||||
| BITv07_DStream_unfinished : there is still some data left into the DStream. | ||||
| BITv07_DStream_endOfBuffer : Dstream reached end of buffer. Its container may no longer be completely filled. | ||||
| BITv07_DStream_completed : Dstream reached its exact end, corresponding in general to decompression completed. | ||||
| BITv07_DStream_tooFar : Dstream went too far. Decompression result is corrupted. | ||||
|  | ||||
| When reaching end of buffer (BITv07_DStream_endOfBuffer), progress slowly, notably if you decode multiple symbols per loop, | ||||
| to properly detect the exact end of stream. | ||||
| After each decoded symbol, check if DStream is fully consumed using this simple test : | ||||
|     BITv07_reloadDStream(&DStream) >= BITv07_DStream_completed | ||||
|  | ||||
| When it's done, verify decompression is fully completed, by checking both DStream and the relevant states. | ||||
| Checking if DStream has reached its end is performed by : | ||||
|     BITv07_endOfDStream(&DStream); | ||||
| Check also the states. There might be some symbols left there, if some high probability ones (>50%) are possible. | ||||
|     FSEv07_endOfDState(&DState); | ||||
| */ | ||||
|  | ||||
|  | ||||
| /* ***************************************** | ||||
| *  FSE unsafe API | ||||
|   | ||||
		Reference in New Issue
	
	Block a user