MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / UpdateModel

Method UpdateModel

Libraries/unrar/model.cpp:246–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244
245
246inline void ModelPPM::UpdateModel()
247{
248 RARPPM_STATE fs = *FoundState, *p = NULL;
249 RARPPM_CONTEXT *pc, *Successor;
250 uint ns1, ns, cf, sf, s0;
251 if (fs.Freq < MAX_FREQ/4 && (pc=MinContext->Suffix) != NULL)
252 {
253 if (pc->NumStats != 1)
254 {
255 if ((p=pc->U.Stats)->Symbol != fs.Symbol)
256 {
257 do
258 {
259 p++;
260 } while (p->Symbol != fs.Symbol);
261 if (p[0].Freq >= p[-1].Freq)
262 {
263 _PPMD_SWAP(p[0],p[-1]);
264 p--;
265 }
266 }
267 if (p->Freq < MAX_FREQ-9)
268 {
269 p->Freq += 2;
270 pc->U.SummFreq += 2;
271 }
272 }
273 else
274 {
275 p=&(pc->OneState);
276 p->Freq += (p->Freq < 32);
277 }
278 }
279 if ( !OrderFall )
280 {
281 MinContext=MaxContext=FoundState->Successor=CreateSuccessors(TRUE,p);
282 if ( !MinContext )
283 goto RESTART_MODEL;
284 return;
285 }
286 *SubAlloc.pText++ = fs.Symbol;
287 Successor = (RARPPM_CONTEXT*) SubAlloc.pText;
288 if (SubAlloc.pText >= SubAlloc.FakeUnitsStart)
289 goto RESTART_MODEL;
290 if ( fs.Successor )
291 {
292 if ((byte*) fs.Successor <= SubAlloc.pText &&
293 (fs.Successor=CreateSuccessors(FALSE,p)) == NULL)
294 goto RESTART_MODEL;
295 if ( !--OrderFall )
296 {
297 Successor=fs.Successor;
298 SubAlloc.pText -= (MaxContext != MinContext);
299 }
300 }
301 else
302 {
303 FoundState->Successor=Successor;

Callers

nothing calls this directly

Calls 3

_PPMD_SWAPFunction · 0.85
ExpandUnitsMethod · 0.80
AllocUnitsMethod · 0.80

Tested by

no test coverage detected