public static nuint FSE_buildDTable_raw(uint *dt, uint nbBits) { void * ptr = (void *)dt; FSE_DTableHeader *DTableH = (FSE_DTableHeader *)(ptr); void * dPtr = (void *)(dt + 1); FSE_decode_t * dinfo = (FSE_decode_t *)(dPtr); uint tableSize = (uint)(1 << (int)nbBits); uint tableMask = tableSize - 1; uint maxSV1 = tableMask + 1; uint s; if (nbBits < 1) { return(unchecked ((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_GENERIC))); } DTableH->tableLog = (ushort)(nbBits); DTableH->fastMode = 1; for (s = 0; s < maxSV1; s++) { dinfo[s].newState = 0; dinfo[s].symbol = (byte)(s); dinfo[s].nbBits = (byte)(nbBits); } return(0); }
} /* size == U32 */ public static void InitDState(FSE_DState_t DStatePtr, BIT_DStream_t bitD, FSE_DTable *dt) { void * ptr = dt; FSE_DTableHeader *DTableH = (FSE_DTableHeader *)ptr; DStatePtr.state = ReadBits(bitD, DTableH->tableLog); ReloadDStream(bitD); DStatePtr.table = dt + 1; }
private static void FSE_initDState(FSE_DState_t *DStatePtr, BIT_DStream_t *bitD, uint *dt) { void * ptr = (void *)dt; FSE_DTableHeader *DTableH = (FSE_DTableHeader *)(ptr); DStatePtr->state = BIT_readBits(bitD, DTableH->tableLog); BIT_reloadDStream(bitD); DStatePtr->table = dt + 1; }
private static nuint FSE_decompress_wksp_body(void *dst, nuint dstCapacity, void *cSrc, nuint cSrcSize, uint maxLog, void *workSpace, nuint wkspSize, int bmi2) { byte * istart = (byte *)(cSrc); byte * ip = istart; short *counting = stackalloc short[256]; uint tableLog; uint maxSymbolValue = 255; uint * dtable = (uint *)(workSpace); nuint NCountLength = FSE_readNCount_bmi2((short *)counting, &maxSymbolValue, &tableLog, (void *)istart, cSrcSize, bmi2); if ((ERR_isError(NCountLength)) != 0) { return(NCountLength); } if (tableLog > maxLog) { return(unchecked ((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_tableLog_tooLarge))); } assert(NCountLength <= cSrcSize); ip += NCountLength; cSrcSize -= NCountLength; if ((((uint)((1 + (1 << (int)(tableLog)))) + ((((nuint)(sizeof(short)) * (maxSymbolValue + 1) + (1UL << (int)tableLog) + 8) + (nuint)(sizeof(uint)) - 1) / (nuint)(sizeof(uint)))) * (nuint)(sizeof(uint))) > wkspSize) { return(unchecked ((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_tableLog_tooLarge))); } workSpace = dtable + (1 + (1 << (int)(tableLog))); wkspSize -= ((uint)((1 + (1 << (int)(tableLog)))) * (nuint)(sizeof(uint))); { nuint _var_err__ = FSE_buildDTable_internal(dtable, (short *)counting, maxSymbolValue, tableLog, workSpace, wkspSize); if ((ERR_isError(_var_err__)) != 0) { return(_var_err__); } } { void * ptr = (void *)dtable; FSE_DTableHeader *DTableH = (FSE_DTableHeader *)(ptr); uint fastMode = DTableH->fastMode; if (fastMode != 0) { return(FSE_decompress_usingDTable_generic(dst, dstCapacity, (void *)ip, cSrcSize, dtable, 1)); } return(FSE_decompress_usingDTable_generic(dst, dstCapacity, (void *)ip, cSrcSize, dtable, 0)); } }
public static size_t FSE_decompress_usingDTable(void *dst, size_t originalSize, void *cSrc, size_t cSrcSize, FSE_DTable *dt) { void * ptr = dt; FSE_DTableHeader *DTableH = (FSE_DTableHeader *)ptr; U32 fastMode = DTableH->fastMode; /* select fast mode (static) */ if (fastMode != 0) { return(FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 1)); } return(FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 0)); }
/*! FSE_decompress_usingDTable(): * Decompress compressed source `cSrc` of size `cSrcSize` using `dt` * into `dst` which must be already allocated. * @return : size of regenerated data (necessarily <= `dstCapacity`), * or an errorCode, which can be tested using FSE_isError() */ public static nuint FSE_decompress_usingDTable(void *dst, nuint originalSize, void *cSrc, nuint cSrcSize, uint *dt) { void * ptr = (void *)dt; FSE_DTableHeader *DTableH = (FSE_DTableHeader *)(ptr); uint fastMode = DTableH->fastMode; if (fastMode != 0) { return(FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 1)); } return(FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 0)); }
/*-******************************************************* * Decompression (Byte symbols) *********************************************************/ public static nuint FSE_buildDTable_rle(uint *dt, byte symbolValue) { void * ptr = (void *)dt; FSE_DTableHeader *DTableH = (FSE_DTableHeader *)(ptr); void * dPtr = (void *)(dt + 1); FSE_decode_t * cell = (FSE_decode_t *)(dPtr); DTableH->tableLog = 0; DTableH->fastMode = 0; cell->newState = 0; cell->symbol = symbolValue; cell->nbBits = 0; return(0); }