xref: /aosp_15_r20/external/zstd/lib/common/fse_decompress.c (revision 01826a4963a0d8a59bc3812d29bdf0fb76416722)
1*01826a49SYabin Cui /* ******************************************************************
2*01826a49SYabin Cui  * FSE : Finite State Entropy decoder
3*01826a49SYabin Cui  * Copyright (c) Meta Platforms, Inc. and affiliates.
4*01826a49SYabin Cui  *
5*01826a49SYabin Cui  *  You can contact the author at :
6*01826a49SYabin Cui  *  - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
7*01826a49SYabin Cui  *  - Public forum : https://groups.google.com/forum/#!forum/lz4c
8*01826a49SYabin Cui  *
9*01826a49SYabin Cui  * This source code is licensed under both the BSD-style license (found in the
10*01826a49SYabin Cui  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
11*01826a49SYabin Cui  * in the COPYING file in the root directory of this source tree).
12*01826a49SYabin Cui  * You may select, at your option, one of the above-listed licenses.
13*01826a49SYabin Cui ****************************************************************** */
14*01826a49SYabin Cui 
15*01826a49SYabin Cui 
16*01826a49SYabin Cui /* **************************************************************
17*01826a49SYabin Cui *  Includes
18*01826a49SYabin Cui ****************************************************************/
19*01826a49SYabin Cui #include "debug.h"      /* assert */
20*01826a49SYabin Cui #include "bitstream.h"
21*01826a49SYabin Cui #include "compiler.h"
22*01826a49SYabin Cui #define FSE_STATIC_LINKING_ONLY
23*01826a49SYabin Cui #include "fse.h"
24*01826a49SYabin Cui #include "error_private.h"
25*01826a49SYabin Cui #include "zstd_deps.h"  /* ZSTD_memcpy */
26*01826a49SYabin Cui #include "bits.h"       /* ZSTD_highbit32 */
27*01826a49SYabin Cui 
28*01826a49SYabin Cui 
29*01826a49SYabin Cui /* **************************************************************
30*01826a49SYabin Cui *  Error Management
31*01826a49SYabin Cui ****************************************************************/
32*01826a49SYabin Cui #define FSE_isError ERR_isError
33*01826a49SYabin Cui #define FSE_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c)   /* use only *after* variable declarations */
34*01826a49SYabin Cui 
35*01826a49SYabin Cui 
36*01826a49SYabin Cui /* **************************************************************
37*01826a49SYabin Cui *  Templates
38*01826a49SYabin Cui ****************************************************************/
39*01826a49SYabin Cui /*
40*01826a49SYabin Cui   designed to be included
41*01826a49SYabin Cui   for type-specific functions (template emulation in C)
42*01826a49SYabin Cui   Objective is to write these functions only once, for improved maintenance
43*01826a49SYabin Cui */
44*01826a49SYabin Cui 
45*01826a49SYabin Cui /* safety checks */
46*01826a49SYabin Cui #ifndef FSE_FUNCTION_EXTENSION
47*01826a49SYabin Cui #  error "FSE_FUNCTION_EXTENSION must be defined"
48*01826a49SYabin Cui #endif
49*01826a49SYabin Cui #ifndef FSE_FUNCTION_TYPE
50*01826a49SYabin Cui #  error "FSE_FUNCTION_TYPE must be defined"
51*01826a49SYabin Cui #endif
52*01826a49SYabin Cui 
53*01826a49SYabin Cui /* Function names */
54*01826a49SYabin Cui #define FSE_CAT(X,Y) X##Y
55*01826a49SYabin Cui #define FSE_FUNCTION_NAME(X,Y) FSE_CAT(X,Y)
56*01826a49SYabin Cui #define FSE_TYPE_NAME(X,Y) FSE_CAT(X,Y)
57*01826a49SYabin Cui 
FSE_buildDTable_internal(FSE_DTable * dt,const short * normalizedCounter,unsigned maxSymbolValue,unsigned tableLog,void * workSpace,size_t wkspSize)58*01826a49SYabin Cui static size_t FSE_buildDTable_internal(FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize)
59*01826a49SYabin Cui {
60*01826a49SYabin Cui     void* const tdPtr = dt+1;   /* because *dt is unsigned, 32-bits aligned on 32-bits */
61*01826a49SYabin Cui     FSE_DECODE_TYPE* const tableDecode = (FSE_DECODE_TYPE*) (tdPtr);
62*01826a49SYabin Cui     U16* symbolNext = (U16*)workSpace;
63*01826a49SYabin Cui     BYTE* spread = (BYTE*)(symbolNext + maxSymbolValue + 1);
64*01826a49SYabin Cui 
65*01826a49SYabin Cui     U32 const maxSV1 = maxSymbolValue + 1;
66*01826a49SYabin Cui     U32 const tableSize = 1 << tableLog;
67*01826a49SYabin Cui     U32 highThreshold = tableSize-1;
68*01826a49SYabin Cui 
69*01826a49SYabin Cui     /* Sanity Checks */
70*01826a49SYabin Cui     if (FSE_BUILD_DTABLE_WKSP_SIZE(tableLog, maxSymbolValue) > wkspSize) return ERROR(maxSymbolValue_tooLarge);
71*01826a49SYabin Cui     if (maxSymbolValue > FSE_MAX_SYMBOL_VALUE) return ERROR(maxSymbolValue_tooLarge);
72*01826a49SYabin Cui     if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge);
73*01826a49SYabin Cui 
74*01826a49SYabin Cui     /* Init, lay down lowprob symbols */
75*01826a49SYabin Cui     {   FSE_DTableHeader DTableH;
76*01826a49SYabin Cui         DTableH.tableLog = (U16)tableLog;
77*01826a49SYabin Cui         DTableH.fastMode = 1;
78*01826a49SYabin Cui         {   S16 const largeLimit= (S16)(1 << (tableLog-1));
79*01826a49SYabin Cui             U32 s;
80*01826a49SYabin Cui             for (s=0; s<maxSV1; s++) {
81*01826a49SYabin Cui                 if (normalizedCounter[s]==-1) {
82*01826a49SYabin Cui                     tableDecode[highThreshold--].symbol = (FSE_FUNCTION_TYPE)s;
83*01826a49SYabin Cui                     symbolNext[s] = 1;
84*01826a49SYabin Cui                 } else {
85*01826a49SYabin Cui                     if (normalizedCounter[s] >= largeLimit) DTableH.fastMode=0;
86*01826a49SYabin Cui                     symbolNext[s] = (U16)normalizedCounter[s];
87*01826a49SYabin Cui         }   }   }
88*01826a49SYabin Cui         ZSTD_memcpy(dt, &DTableH, sizeof(DTableH));
89*01826a49SYabin Cui     }
90*01826a49SYabin Cui 
91*01826a49SYabin Cui     /* Spread symbols */
92*01826a49SYabin Cui     if (highThreshold == tableSize - 1) {
93*01826a49SYabin Cui         size_t const tableMask = tableSize-1;
94*01826a49SYabin Cui         size_t const step = FSE_TABLESTEP(tableSize);
95*01826a49SYabin Cui         /* First lay down the symbols in order.
96*01826a49SYabin Cui          * We use a uint64_t to lay down 8 bytes at a time. This reduces branch
97*01826a49SYabin Cui          * misses since small blocks generally have small table logs, so nearly
98*01826a49SYabin Cui          * all symbols have counts <= 8. We ensure we have 8 bytes at the end of
99*01826a49SYabin Cui          * our buffer to handle the over-write.
100*01826a49SYabin Cui          */
101*01826a49SYabin Cui         {   U64 const add = 0x0101010101010101ull;
102*01826a49SYabin Cui             size_t pos = 0;
103*01826a49SYabin Cui             U64 sv = 0;
104*01826a49SYabin Cui             U32 s;
105*01826a49SYabin Cui             for (s=0; s<maxSV1; ++s, sv += add) {
106*01826a49SYabin Cui                 int i;
107*01826a49SYabin Cui                 int const n = normalizedCounter[s];
108*01826a49SYabin Cui                 MEM_write64(spread + pos, sv);
109*01826a49SYabin Cui                 for (i = 8; i < n; i += 8) {
110*01826a49SYabin Cui                     MEM_write64(spread + pos + i, sv);
111*01826a49SYabin Cui                 }
112*01826a49SYabin Cui                 pos += (size_t)n;
113*01826a49SYabin Cui         }   }
114*01826a49SYabin Cui         /* Now we spread those positions across the table.
115*01826a49SYabin Cui          * The benefit of doing it in two stages is that we avoid the
116*01826a49SYabin Cui          * variable size inner loop, which caused lots of branch misses.
117*01826a49SYabin Cui          * Now we can run through all the positions without any branch misses.
118*01826a49SYabin Cui          * We unroll the loop twice, since that is what empirically worked best.
119*01826a49SYabin Cui          */
120*01826a49SYabin Cui         {
121*01826a49SYabin Cui             size_t position = 0;
122*01826a49SYabin Cui             size_t s;
123*01826a49SYabin Cui             size_t const unroll = 2;
124*01826a49SYabin Cui             assert(tableSize % unroll == 0); /* FSE_MIN_TABLELOG is 5 */
125*01826a49SYabin Cui             for (s = 0; s < (size_t)tableSize; s += unroll) {
126*01826a49SYabin Cui                 size_t u;
127*01826a49SYabin Cui                 for (u = 0; u < unroll; ++u) {
128*01826a49SYabin Cui                     size_t const uPosition = (position + (u * step)) & tableMask;
129*01826a49SYabin Cui                     tableDecode[uPosition].symbol = spread[s + u];
130*01826a49SYabin Cui                 }
131*01826a49SYabin Cui                 position = (position + (unroll * step)) & tableMask;
132*01826a49SYabin Cui             }
133*01826a49SYabin Cui             assert(position == 0);
134*01826a49SYabin Cui         }
135*01826a49SYabin Cui     } else {
136*01826a49SYabin Cui         U32 const tableMask = tableSize-1;
137*01826a49SYabin Cui         U32 const step = FSE_TABLESTEP(tableSize);
138*01826a49SYabin Cui         U32 s, position = 0;
139*01826a49SYabin Cui         for (s=0; s<maxSV1; s++) {
140*01826a49SYabin Cui             int i;
141*01826a49SYabin Cui             for (i=0; i<normalizedCounter[s]; i++) {
142*01826a49SYabin Cui                 tableDecode[position].symbol = (FSE_FUNCTION_TYPE)s;
143*01826a49SYabin Cui                 position = (position + step) & tableMask;
144*01826a49SYabin Cui                 while (position > highThreshold) position = (position + step) & tableMask;   /* lowprob area */
145*01826a49SYabin Cui         }   }
146*01826a49SYabin Cui         if (position!=0) return ERROR(GENERIC);   /* position must reach all cells once, otherwise normalizedCounter is incorrect */
147*01826a49SYabin Cui     }
148*01826a49SYabin Cui 
149*01826a49SYabin Cui     /* Build Decoding table */
150*01826a49SYabin Cui     {   U32 u;
151*01826a49SYabin Cui         for (u=0; u<tableSize; u++) {
152*01826a49SYabin Cui             FSE_FUNCTION_TYPE const symbol = (FSE_FUNCTION_TYPE)(tableDecode[u].symbol);
153*01826a49SYabin Cui             U32 const nextState = symbolNext[symbol]++;
154*01826a49SYabin Cui             tableDecode[u].nbBits = (BYTE) (tableLog - ZSTD_highbit32(nextState) );
155*01826a49SYabin Cui             tableDecode[u].newState = (U16) ( (nextState << tableDecode[u].nbBits) - tableSize);
156*01826a49SYabin Cui     }   }
157*01826a49SYabin Cui 
158*01826a49SYabin Cui     return 0;
159*01826a49SYabin Cui }
160*01826a49SYabin Cui 
FSE_buildDTable_wksp(FSE_DTable * dt,const short * normalizedCounter,unsigned maxSymbolValue,unsigned tableLog,void * workSpace,size_t wkspSize)161*01826a49SYabin Cui size_t FSE_buildDTable_wksp(FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize)
162*01826a49SYabin Cui {
163*01826a49SYabin Cui     return FSE_buildDTable_internal(dt, normalizedCounter, maxSymbolValue, tableLog, workSpace, wkspSize);
164*01826a49SYabin Cui }
165*01826a49SYabin Cui 
166*01826a49SYabin Cui 
167*01826a49SYabin Cui #ifndef FSE_COMMONDEFS_ONLY
168*01826a49SYabin Cui 
169*01826a49SYabin Cui /*-*******************************************************
170*01826a49SYabin Cui *  Decompression (Byte symbols)
171*01826a49SYabin Cui *********************************************************/
172*01826a49SYabin Cui 
FSE_decompress_usingDTable_generic(void * dst,size_t maxDstSize,const void * cSrc,size_t cSrcSize,const FSE_DTable * dt,const unsigned fast)173*01826a49SYabin Cui FORCE_INLINE_TEMPLATE size_t FSE_decompress_usingDTable_generic(
174*01826a49SYabin Cui           void* dst, size_t maxDstSize,
175*01826a49SYabin Cui     const void* cSrc, size_t cSrcSize,
176*01826a49SYabin Cui     const FSE_DTable* dt, const unsigned fast)
177*01826a49SYabin Cui {
178*01826a49SYabin Cui     BYTE* const ostart = (BYTE*) dst;
179*01826a49SYabin Cui     BYTE* op = ostart;
180*01826a49SYabin Cui     BYTE* const omax = op + maxDstSize;
181*01826a49SYabin Cui     BYTE* const olimit = omax-3;
182*01826a49SYabin Cui 
183*01826a49SYabin Cui     BIT_DStream_t bitD;
184*01826a49SYabin Cui     FSE_DState_t state1;
185*01826a49SYabin Cui     FSE_DState_t state2;
186*01826a49SYabin Cui 
187*01826a49SYabin Cui     /* Init */
188*01826a49SYabin Cui     CHECK_F(BIT_initDStream(&bitD, cSrc, cSrcSize));
189*01826a49SYabin Cui 
190*01826a49SYabin Cui     FSE_initDState(&state1, &bitD, dt);
191*01826a49SYabin Cui     FSE_initDState(&state2, &bitD, dt);
192*01826a49SYabin Cui 
193*01826a49SYabin Cui #define FSE_GETSYMBOL(statePtr) fast ? FSE_decodeSymbolFast(statePtr, &bitD) : FSE_decodeSymbol(statePtr, &bitD)
194*01826a49SYabin Cui 
195*01826a49SYabin Cui     /* 4 symbols per loop */
196*01826a49SYabin Cui     for ( ; (BIT_reloadDStream(&bitD)==BIT_DStream_unfinished) & (op<olimit) ; op+=4) {
197*01826a49SYabin Cui         op[0] = FSE_GETSYMBOL(&state1);
198*01826a49SYabin Cui 
199*01826a49SYabin Cui         if (FSE_MAX_TABLELOG*2+7 > sizeof(bitD.bitContainer)*8)    /* This test must be static */
200*01826a49SYabin Cui             BIT_reloadDStream(&bitD);
201*01826a49SYabin Cui 
202*01826a49SYabin Cui         op[1] = FSE_GETSYMBOL(&state2);
203*01826a49SYabin Cui 
204*01826a49SYabin Cui         if (FSE_MAX_TABLELOG*4+7 > sizeof(bitD.bitContainer)*8)    /* This test must be static */
205*01826a49SYabin Cui             { if (BIT_reloadDStream(&bitD) > BIT_DStream_unfinished) { op+=2; break; } }
206*01826a49SYabin Cui 
207*01826a49SYabin Cui         op[2] = FSE_GETSYMBOL(&state1);
208*01826a49SYabin Cui 
209*01826a49SYabin Cui         if (FSE_MAX_TABLELOG*2+7 > sizeof(bitD.bitContainer)*8)    /* This test must be static */
210*01826a49SYabin Cui             BIT_reloadDStream(&bitD);
211*01826a49SYabin Cui 
212*01826a49SYabin Cui         op[3] = FSE_GETSYMBOL(&state2);
213*01826a49SYabin Cui     }
214*01826a49SYabin Cui 
215*01826a49SYabin Cui     /* tail */
216*01826a49SYabin Cui     /* note : BIT_reloadDStream(&bitD) >= FSE_DStream_partiallyFilled; Ends at exactly BIT_DStream_completed */
217*01826a49SYabin Cui     while (1) {
218*01826a49SYabin Cui         if (op>(omax-2)) return ERROR(dstSize_tooSmall);
219*01826a49SYabin Cui         *op++ = FSE_GETSYMBOL(&state1);
220*01826a49SYabin Cui         if (BIT_reloadDStream(&bitD)==BIT_DStream_overflow) {
221*01826a49SYabin Cui             *op++ = FSE_GETSYMBOL(&state2);
222*01826a49SYabin Cui             break;
223*01826a49SYabin Cui         }
224*01826a49SYabin Cui 
225*01826a49SYabin Cui         if (op>(omax-2)) return ERROR(dstSize_tooSmall);
226*01826a49SYabin Cui         *op++ = FSE_GETSYMBOL(&state2);
227*01826a49SYabin Cui         if (BIT_reloadDStream(&bitD)==BIT_DStream_overflow) {
228*01826a49SYabin Cui             *op++ = FSE_GETSYMBOL(&state1);
229*01826a49SYabin Cui             break;
230*01826a49SYabin Cui     }   }
231*01826a49SYabin Cui 
232*01826a49SYabin Cui     assert(op >= ostart);
233*01826a49SYabin Cui     return (size_t)(op-ostart);
234*01826a49SYabin Cui }
235*01826a49SYabin Cui 
236*01826a49SYabin Cui typedef struct {
237*01826a49SYabin Cui     short ncount[FSE_MAX_SYMBOL_VALUE + 1];
238*01826a49SYabin Cui } FSE_DecompressWksp;
239*01826a49SYabin Cui 
240*01826a49SYabin Cui 
FSE_decompress_wksp_body(void * dst,size_t dstCapacity,const void * cSrc,size_t cSrcSize,unsigned maxLog,void * workSpace,size_t wkspSize,int bmi2)241*01826a49SYabin Cui FORCE_INLINE_TEMPLATE size_t FSE_decompress_wksp_body(
242*01826a49SYabin Cui         void* dst, size_t dstCapacity,
243*01826a49SYabin Cui         const void* cSrc, size_t cSrcSize,
244*01826a49SYabin Cui         unsigned maxLog, void* workSpace, size_t wkspSize,
245*01826a49SYabin Cui         int bmi2)
246*01826a49SYabin Cui {
247*01826a49SYabin Cui     const BYTE* const istart = (const BYTE*)cSrc;
248*01826a49SYabin Cui     const BYTE* ip = istart;
249*01826a49SYabin Cui     unsigned tableLog;
250*01826a49SYabin Cui     unsigned maxSymbolValue = FSE_MAX_SYMBOL_VALUE;
251*01826a49SYabin Cui     FSE_DecompressWksp* const wksp = (FSE_DecompressWksp*)workSpace;
252*01826a49SYabin Cui     size_t const dtablePos = sizeof(FSE_DecompressWksp) / sizeof(FSE_DTable);
253*01826a49SYabin Cui     FSE_DTable* const dtable = (FSE_DTable*)workSpace + dtablePos;
254*01826a49SYabin Cui 
255*01826a49SYabin Cui     FSE_STATIC_ASSERT((FSE_MAX_SYMBOL_VALUE + 1) % 2 == 0);
256*01826a49SYabin Cui     if (wkspSize < sizeof(*wksp)) return ERROR(GENERIC);
257*01826a49SYabin Cui 
258*01826a49SYabin Cui     /* correct offset to dtable depends on this property */
259*01826a49SYabin Cui     FSE_STATIC_ASSERT(sizeof(FSE_DecompressWksp) % sizeof(FSE_DTable) == 0);
260*01826a49SYabin Cui 
261*01826a49SYabin Cui     /* normal FSE decoding mode */
262*01826a49SYabin Cui     {   size_t const NCountLength =
263*01826a49SYabin Cui             FSE_readNCount_bmi2(wksp->ncount, &maxSymbolValue, &tableLog, istart, cSrcSize, bmi2);
264*01826a49SYabin Cui         if (FSE_isError(NCountLength)) return NCountLength;
265*01826a49SYabin Cui         if (tableLog > maxLog) return ERROR(tableLog_tooLarge);
266*01826a49SYabin Cui         assert(NCountLength <= cSrcSize);
267*01826a49SYabin Cui         ip += NCountLength;
268*01826a49SYabin Cui         cSrcSize -= NCountLength;
269*01826a49SYabin Cui     }
270*01826a49SYabin Cui 
271*01826a49SYabin Cui     if (FSE_DECOMPRESS_WKSP_SIZE(tableLog, maxSymbolValue) > wkspSize) return ERROR(tableLog_tooLarge);
272*01826a49SYabin Cui     assert(sizeof(*wksp) + FSE_DTABLE_SIZE(tableLog) <= wkspSize);
273*01826a49SYabin Cui     workSpace = (BYTE*)workSpace + sizeof(*wksp) + FSE_DTABLE_SIZE(tableLog);
274*01826a49SYabin Cui     wkspSize -= sizeof(*wksp) + FSE_DTABLE_SIZE(tableLog);
275*01826a49SYabin Cui 
276*01826a49SYabin Cui     CHECK_F( FSE_buildDTable_internal(dtable, wksp->ncount, maxSymbolValue, tableLog, workSpace, wkspSize) );
277*01826a49SYabin Cui 
278*01826a49SYabin Cui     {
279*01826a49SYabin Cui         const void* ptr = dtable;
280*01826a49SYabin Cui         const FSE_DTableHeader* DTableH = (const FSE_DTableHeader*)ptr;
281*01826a49SYabin Cui         const U32 fastMode = DTableH->fastMode;
282*01826a49SYabin Cui 
283*01826a49SYabin Cui         /* select fast mode (static) */
284*01826a49SYabin Cui         if (fastMode) return FSE_decompress_usingDTable_generic(dst, dstCapacity, ip, cSrcSize, dtable, 1);
285*01826a49SYabin Cui         return FSE_decompress_usingDTable_generic(dst, dstCapacity, ip, cSrcSize, dtable, 0);
286*01826a49SYabin Cui     }
287*01826a49SYabin Cui }
288*01826a49SYabin Cui 
289*01826a49SYabin Cui /* Avoids the FORCE_INLINE of the _body() function. */
FSE_decompress_wksp_body_default(void * dst,size_t dstCapacity,const void * cSrc,size_t cSrcSize,unsigned maxLog,void * workSpace,size_t wkspSize)290*01826a49SYabin Cui static size_t FSE_decompress_wksp_body_default(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, unsigned maxLog, void* workSpace, size_t wkspSize)
291*01826a49SYabin Cui {
292*01826a49SYabin Cui     return FSE_decompress_wksp_body(dst, dstCapacity, cSrc, cSrcSize, maxLog, workSpace, wkspSize, 0);
293*01826a49SYabin Cui }
294*01826a49SYabin Cui 
295*01826a49SYabin Cui #if DYNAMIC_BMI2
FSE_decompress_wksp_body_bmi2(void * dst,size_t dstCapacity,const void * cSrc,size_t cSrcSize,unsigned maxLog,void * workSpace,size_t wkspSize)296*01826a49SYabin Cui BMI2_TARGET_ATTRIBUTE static size_t FSE_decompress_wksp_body_bmi2(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, unsigned maxLog, void* workSpace, size_t wkspSize)
297*01826a49SYabin Cui {
298*01826a49SYabin Cui     return FSE_decompress_wksp_body(dst, dstCapacity, cSrc, cSrcSize, maxLog, workSpace, wkspSize, 1);
299*01826a49SYabin Cui }
300*01826a49SYabin Cui #endif
301*01826a49SYabin Cui 
FSE_decompress_wksp_bmi2(void * dst,size_t dstCapacity,const void * cSrc,size_t cSrcSize,unsigned maxLog,void * workSpace,size_t wkspSize,int bmi2)302*01826a49SYabin Cui size_t FSE_decompress_wksp_bmi2(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, unsigned maxLog, void* workSpace, size_t wkspSize, int bmi2)
303*01826a49SYabin Cui {
304*01826a49SYabin Cui #if DYNAMIC_BMI2
305*01826a49SYabin Cui     if (bmi2) {
306*01826a49SYabin Cui         return FSE_decompress_wksp_body_bmi2(dst, dstCapacity, cSrc, cSrcSize, maxLog, workSpace, wkspSize);
307*01826a49SYabin Cui     }
308*01826a49SYabin Cui #endif
309*01826a49SYabin Cui     (void)bmi2;
310*01826a49SYabin Cui     return FSE_decompress_wksp_body_default(dst, dstCapacity, cSrc, cSrcSize, maxLog, workSpace, wkspSize);
311*01826a49SYabin Cui }
312*01826a49SYabin Cui 
313*01826a49SYabin Cui #endif   /* FSE_COMMONDEFS_ONLY */
314