• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/sys/contrib/zstd/lib/compress/

Lines Matching defs:maxNbBits

210  * Enforces maxNbBits on the Huffman tree described in huffNode.
212 * It sets all nodes with nbBits > maxNbBits to be maxNbBits. Then it adjusts
218 * where largestBits is the return value <= maxNbBits.
220 * @param huffNode The Huffman tree modified in place to enforce maxNbBits.
222 * @param maxNbBits The maximum allowed number of bits, which the Huffman tree
224 * respect maxNbBits.
226 * necessarily no more than maxNbBits.
228 static U32 HUF_setMaxHeight(nodeElt* huffNode, U32 lastNonNull, U32 maxNbBits)
231 /* early exit : no elt > maxNbBits, so the tree is already valid. */
232 if (largestBits <= maxNbBits) return largestBits;
236 const U32 baseCost = 1 << (largestBits - maxNbBits);
239 /* Adjust any ranks > maxNbBits to maxNbBits.
243 while (huffNode[n].nbBits > maxNbBits) {
245 huffNode[n].nbBits = (BYTE)maxNbBits;
248 /* n stops at huffNode[n].nbBits <= maxNbBits */
249 assert(huffNode[n].nbBits <= maxNbBits);
250 /* n end at index of smallest symbol using < maxNbBits */
251 while (huffNode[n].nbBits == maxNbBits) --n;
253 /* renorm totalCost from 2^largestBits to 2^maxNbBits
256 totalCost >>= (largestBits - maxNbBits);
265 { U32 currentNbBits = maxNbBits;
269 currentNbBits = huffNode[pos].nbBits; /* < maxNbBits */
270 rankLast[maxNbBits-currentNbBits] = (U32)pos;
317 if (huffNode[rankLast[nBitsToDecrease]].nbBits != maxNbBits-nBitsToDecrease)
329 /* special case : no rank 1 symbol (using maxNbBits-1);
330 * let's create one from largest rank 0 (using maxNbBits).
333 while (huffNode[n].nbBits == maxNbBits) n--;
347 return maxNbBits;
470 * @param maxNbBits The exact maximum number of bits used in the Huffman tree.
472 static void HUF_buildCTableFromTree(HUF_CElt* CTable, nodeElt const* huffNode, int nonNullRank, U32 maxSymbolValue, U32 maxNbBits)
483 for (n=(int)maxNbBits; n>0; n--) {
494 size_t HUF_buildCTable_wksp (HUF_CElt* tree, const unsigned* count, U32 maxSymbolValue, U32 maxNbBits, void* workSpace, size_t wkspSize)
505 if (maxNbBits == 0) maxNbBits = HUF_TABLELOG_DEFAULT;
517 maxNbBits = HUF_setMaxHeight(huffNode, (U32)nonNullRank, maxNbBits);
518 if (maxNbBits > HUF_TABLELOG_MAX) return ERROR(GENERIC); /* check fit into table */
520 HUF_buildCTableFromTree(tree, huffNode, nonNullRank, maxSymbolValue, maxNbBits);
522 return maxNbBits;
885 * @return : maxNbBits
888 size_t HUF_buildCTable (HUF_CElt* tree, const unsigned* count, unsigned maxSymbolValue, unsigned maxNbBits)
891 return HUF_buildCTable_wksp(tree, count, maxSymbolValue, maxNbBits, &workspace, sizeof(workspace));