removed new huffman depth heuristic

results are now identical to before this PR
This commit is contained in:
Yann Collet
2022-01-26 15:22:06 -08:00
parent a66e8bb437
commit 8b46895588
2 changed files with 15 additions and 34 deletions
+4 -23
View File
@@ -143,7 +143,10 @@ typedef struct {
S16 norm[HUF_TABLELOG_MAX+1];
} HUF_CompressWeightsWksp;
static size_t HUF_compressWeights(void* dst, size_t dstSize, const void* weightTable, size_t wtSize, void* workspace, size_t workspaceSize)
static size_t
HUF_compressWeights(void* dst, size_t dstSize,
const void* weightTable, size_t wtSize,
void* workspace, size_t workspaceSize)
{
BYTE* const ostart = (BYTE*) dst;
BYTE* op = ostart;
@@ -731,18 +734,6 @@ static void HUF_buildCTableFromTree(HUF_CElt* CTable, nodeElt const* huffNode, i
CTable[0] = maxNbBits;
}
static size_t
HUF_nbSymbolsTooLarge(const nodeElt* hnodes, U32 maxSymbolValue, U32 maxNbBits)
{
size_t nbSTL = 0;
int s = (int)maxSymbolValue;
for ( ; s > 0; s-- ) {
if (hnodes[s].nbBits > maxNbBits) nbSTL++;
else break;
}
return nbSTL;
}
size_t
HUF_buildCTable_wksp(HUF_CElt* CTable, const unsigned* count, U32 maxSymbolValue, U32 maxNbBits,
void* workSpace, size_t wkspSize)
@@ -771,16 +762,6 @@ HUF_buildCTable_wksp(HUF_CElt* CTable, const unsigned* count, U32 maxSymbolValue
nonNullRank = HUF_buildTree(huffNode, maxSymbolValue);
/* determine and enforce maxTableLog */
/* Loosen target when maxNbBits is already within limits.
* A harsh rebalancing can be bad for compression ratio
* while a mild one tends to be better */
while (maxNbBits < HUF_TABLELOG_DEFAULT) {
size_t const nbSTL = HUF_nbSymbolsTooLarge(huffNode, maxSymbolValue, maxNbBits);
#define HUF_NB_NODES_TO_FIX_MAX 32
if (nbSTL < HUF_NB_NODES_TO_FIX_MAX) /* heuristic */
break;
maxNbBits++;
}
maxNbBits = HUF_setMaxHeight(huffNode, (U32)nonNullRank, maxNbBits);
if (maxNbBits > HUF_TABLELOG_MAX) return ERROR(GENERIC); /* check fit into table */