Skip to content

Commit

Permalink
Add rails for huffman table log calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
binhdvo committed Feb 2, 2022
1 parent c9072dd commit 8d0ba68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/compress/huf_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,11 @@ static size_t HUF_compressCTable_internal(

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 <= maxTableLog);
assert(tableLog <= HUF_TABLELOG_MAX);

return tableLog;
}

typedef struct {
Expand Down
1 change: 1 addition & 0 deletions lib/compress/zstd_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -3110,6 +3110,7 @@ static size_t ZSTD_buildBlockEntropyStats_literals(void* const src, size_t srcSi
/* Build Huffman Tree */
ZSTD_memset(nextHuf->CTable, 0, sizeof(nextHuf->CTable));
huffLog = HUF_optimalTableLog(huffLog, srcSize, maxSymbolValue);
assert(huffLog <= LitHufLog);
{ size_t const maxBits = HUF_buildCTable_wksp((HUF_CElt*)nextHuf->CTable, countWksp,
maxSymbolValue, huffLog,
nodeWksp, nodeWkspSize);
Expand Down

0 comments on commit 8d0ba68

Please sign in to comment.