Add rails for huffman table log calculation (#3047)

This commit is contained in:
binhdvo 2022-02-02 15:12:48 -05:00 committed by GitHub
parent 529a5879bf
commit b9566fc558
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -1224,7 +1224,10 @@ static size_t HUF_compressCTable_internal(
unsigned HUF_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue) unsigned HUF_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue)
{ {
return FSE_optimalTableLog_internal(maxTableLog, srcSize, maxSymbolValue, 1); unsigned tableLog = FSE_optimalTableLog_internal(maxTableLog, srcSize, maxSymbolValue, 1);
assert(tableLog <= HUF_TABLELOG_MAX);
return tableLog;
} }
typedef struct { typedef struct {

View File

@ -3112,6 +3112,7 @@ static size_t ZSTD_buildBlockEntropyStats_literals(void* const src, size_t srcSi
/* Build Huffman Tree */ /* Build Huffman Tree */
ZSTD_memset(nextHuf->CTable, 0, sizeof(nextHuf->CTable)); ZSTD_memset(nextHuf->CTable, 0, sizeof(nextHuf->CTable));
huffLog = HUF_optimalTableLog(huffLog, srcSize, maxSymbolValue); huffLog = HUF_optimalTableLog(huffLog, srcSize, maxSymbolValue);
assert(huffLog <= LitHufLog);
{ size_t const maxBits = HUF_buildCTable_wksp((HUF_CElt*)nextHuf->CTable, countWksp, { size_t const maxBits = HUF_buildCTable_wksp((HUF_CElt*)nextHuf->CTable, countWksp,
maxSymbolValue, huffLog, maxSymbolValue, huffLog,
nodeWksp, nodeWkspSize); nodeWksp, nodeWkspSize);