Lines Matching refs:optPtr
66 static int ZSTD_compressedLiterals(optState_t const* const optPtr) in ZSTD_compressedLiterals() argument
68 return optPtr->literalCompressionMode != ZSTD_ps_disable; in ZSTD_compressedLiterals()
71 static void ZSTD_setBasePrices(optState_t* optPtr, int optLevel) in ZSTD_setBasePrices() argument
73 if (ZSTD_compressedLiterals(optPtr)) in ZSTD_setBasePrices()
74 optPtr->litSumBasePrice = WEIGHT(optPtr->litSum, optLevel); in ZSTD_setBasePrices()
75 optPtr->litLengthSumBasePrice = WEIGHT(optPtr->litLengthSum, optLevel); in ZSTD_setBasePrices()
76 optPtr->matchLengthSumBasePrice = WEIGHT(optPtr->matchLengthSum, optLevel); in ZSTD_setBasePrices()
77 optPtr->offCodeSumBasePrice = WEIGHT(optPtr->offCodeSum, optLevel); in ZSTD_setBasePrices()
124 ZSTD_rescaleFreqs(optState_t* const optPtr, in ZSTD_rescaleFreqs() argument
128 int const compressedLiterals = ZSTD_compressedLiterals(optPtr); in ZSTD_rescaleFreqs()
130 optPtr->priceType = zop_dynamic; in ZSTD_rescaleFreqs()
132 if (optPtr->litLengthSum == 0) { /* first block : init */ in ZSTD_rescaleFreqs()
135 optPtr->priceType = zop_predef; in ZSTD_rescaleFreqs()
138 assert(optPtr->symbolCosts != NULL); in ZSTD_rescaleFreqs()
139 if (optPtr->symbolCosts->huf.repeatMode == HUF_repeat_valid) { in ZSTD_rescaleFreqs()
141 optPtr->priceType = zop_dynamic; in ZSTD_rescaleFreqs()
145 assert(optPtr->litFreq != NULL); in ZSTD_rescaleFreqs()
146 optPtr->litSum = 0; in ZSTD_rescaleFreqs()
149 … U32 const bitCost = HUF_getNbBitsFromCTable(optPtr->symbolCosts->huf.CTable, lit); in ZSTD_rescaleFreqs()
151 … optPtr->litFreq[lit] = bitCost ? 1 << (scaleLog-bitCost) : 1 /*minimum to calculate cost*/; in ZSTD_rescaleFreqs()
152 optPtr->litSum += optPtr->litFreq[lit]; in ZSTD_rescaleFreqs()
157 FSE_initCState(&llstate, optPtr->symbolCosts->fse.litlengthCTable); in ZSTD_rescaleFreqs()
158 optPtr->litLengthSum = 0; in ZSTD_rescaleFreqs()
163 … optPtr->litLengthFreq[ll] = bitCost ? 1 << (scaleLog-bitCost) : 1 /*minimum to calculate cost*/; in ZSTD_rescaleFreqs()
164 optPtr->litLengthSum += optPtr->litLengthFreq[ll]; in ZSTD_rescaleFreqs()
169 FSE_initCState(&mlstate, optPtr->symbolCosts->fse.matchlengthCTable); in ZSTD_rescaleFreqs()
170 optPtr->matchLengthSum = 0; in ZSTD_rescaleFreqs()
175 … optPtr->matchLengthFreq[ml] = bitCost ? 1 << (scaleLog-bitCost) : 1 /*minimum to calculate cost*/; in ZSTD_rescaleFreqs()
176 optPtr->matchLengthSum += optPtr->matchLengthFreq[ml]; in ZSTD_rescaleFreqs()
181 FSE_initCState(&ofstate, optPtr->symbolCosts->fse.offcodeCTable); in ZSTD_rescaleFreqs()
182 optPtr->offCodeSum = 0; in ZSTD_rescaleFreqs()
187 … optPtr->offCodeFreq[of] = bitCost ? 1 << (scaleLog-bitCost) : 1 /*minimum to calculate cost*/; in ZSTD_rescaleFreqs()
188 optPtr->offCodeSum += optPtr->offCodeFreq[of]; in ZSTD_rescaleFreqs()
193 assert(optPtr->litFreq != NULL); in ZSTD_rescaleFreqs()
196 …HIST_count_simple(optPtr->litFreq, &lit, src, srcSize); /* use raw first block to init statistic… in ZSTD_rescaleFreqs()
197 optPtr->litSum = ZSTD_downscaleStats(optPtr->litFreq, MaxLit, 8); in ZSTD_rescaleFreqs()
207 ZSTD_memcpy(optPtr->litLengthFreq, baseLLfreqs, sizeof(baseLLfreqs)); in ZSTD_rescaleFreqs()
208 optPtr->litLengthSum = sum_u32(baseLLfreqs, MaxLL+1); in ZSTD_rescaleFreqs()
213 optPtr->matchLengthFreq[ml] = 1; in ZSTD_rescaleFreqs()
215 optPtr->matchLengthSum = MaxML+1; in ZSTD_rescaleFreqs()
223 ZSTD_memcpy(optPtr->offCodeFreq, baseOFCfreqs, sizeof(baseOFCfreqs)); in ZSTD_rescaleFreqs()
224 optPtr->offCodeSum = sum_u32(baseOFCfreqs, MaxOff+1); in ZSTD_rescaleFreqs()
233 optPtr->litSum = ZSTD_scaleStats(optPtr->litFreq, MaxLit, 12); in ZSTD_rescaleFreqs()
234 optPtr->litLengthSum = ZSTD_scaleStats(optPtr->litLengthFreq, MaxLL, 11); in ZSTD_rescaleFreqs()
235 optPtr->matchLengthSum = ZSTD_scaleStats(optPtr->matchLengthFreq, MaxML, 11); in ZSTD_rescaleFreqs()
236 optPtr->offCodeSum = ZSTD_scaleStats(optPtr->offCodeFreq, MaxOff, 11); in ZSTD_rescaleFreqs()
239 ZSTD_setBasePrices(optPtr, optLevel); in ZSTD_rescaleFreqs()
246 const optState_t* const optPtr, in ZSTD_rawLiteralsCost() argument
251 if (!ZSTD_compressedLiterals(optPtr)) in ZSTD_rawLiteralsCost()
254 if (optPtr->priceType == zop_predef) in ZSTD_rawLiteralsCost()
258 { U32 price = litLength * optPtr->litSumBasePrice; in ZSTD_rawLiteralsCost()
261 …assert(WEIGHT(optPtr->litFreq[literals[u]], optLevel) <= optPtr->litSumBasePrice); /* literal co… in ZSTD_rawLiteralsCost()
262 price -= WEIGHT(optPtr->litFreq[literals[u]], optLevel); in ZSTD_rawLiteralsCost()
270 static U32 ZSTD_litLengthPrice(U32 const litLength, const optState_t* const optPtr, int optLevel) in ZSTD_litLengthPrice() argument
273 if (optPtr->priceType == zop_predef) in ZSTD_litLengthPrice()
281 return BITCOST_MULTIPLIER + ZSTD_litLengthPrice(ZSTD_BLOCKSIZE_MAX - 1, optPtr, optLevel); in ZSTD_litLengthPrice()
286 + optPtr->litLengthSumBasePrice in ZSTD_litLengthPrice()
287 - WEIGHT(optPtr->litLengthFreq[llCode], optLevel); in ZSTD_litLengthPrice()
300 const optState_t* const optPtr, in ZSTD_getMatchPrice() argument
308 if (optPtr->priceType == zop_predef) /* fixed scheme, do not use statistics */ in ZSTD_getMatchPrice()
312 …price = (offCode * BITCOST_MULTIPLIER) + (optPtr->offCodeSumBasePrice - WEIGHT(optPtr->offCodeFreq… in ZSTD_getMatchPrice()
318 …price += (ML_bits[mlCode] * BITCOST_MULTIPLIER) + (optPtr->matchLengthSumBasePrice - WEIGHT(optPtr… in ZSTD_getMatchPrice()
329 static void ZSTD_updateStats(optState_t* const optPtr, in ZSTD_updateStats() argument
334 if (ZSTD_compressedLiterals(optPtr)) { in ZSTD_updateStats()
337 optPtr->litFreq[literals[u]] += ZSTD_LITFREQ_ADD; in ZSTD_updateStats()
338 optPtr->litSum += litLength*ZSTD_LITFREQ_ADD; in ZSTD_updateStats()
343 optPtr->litLengthFreq[llCode]++; in ZSTD_updateStats()
344 optPtr->litLengthSum++; in ZSTD_updateStats()
350 optPtr->offCodeFreq[offCode]++; in ZSTD_updateStats()
351 optPtr->offCodeSum++; in ZSTD_updateStats()
357 optPtr->matchLengthFreq[mlCode]++; in ZSTD_updateStats()
358 optPtr->matchLengthSum++; in ZSTD_updateStats()