// Debug // public void dumpHeap() { // subAlloc.dumpHeap(); // } internal bool DecodeInit(Stream stream, int maxOrder, int maxMemory) { if (stream != null) { Coder = new RangeCoder(stream); } if (maxOrder == 1) { SubAlloc.StopSubAllocator(); return(false); } SubAlloc.StartSubAllocator(maxMemory); _minContext = new PpmContext(Heap); //medContext = new PPMContext(Heap); _maxContext = new PpmContext(Heap); FoundState = new State(Heap); _dummySee2Cont = new See2Context(); for (int i = 0; i < 25; i++) { for (int j = 0; j < 16; j++) { _see2Cont[i][j] = new See2Context(); } } StartModelRare(maxOrder); return(_minContext.Address != 0); }
private void InitBlock() { for (int i = 0; i < 25; i++) { _see2Cont[i] = new See2Context[16]; } for (int i2 = 0; i2 < 128; i2++) { _binSumm[i2] = new int[64]; } }
internal bool DecodeInit(IRarUnpack unpackRead, int escChar) { int maxOrder = unpackRead.Char & 0xff; bool reset = ((maxOrder & 0x20) != 0); int maxMb = 0; if (reset) { maxMb = unpackRead.Char; } else { if (SubAlloc.GetAllocatedMemory() == 0) { return(false); } } if ((maxOrder & 0x40) != 0) { escChar = unpackRead.Char; unpackRead.PpmEscChar = escChar; } Coder = new RangeCoder(unpackRead); if (reset) { maxOrder = (maxOrder & 0x1f) + 1; if (maxOrder > 16) { maxOrder = 16 + (maxOrder - 16) * 3; } if (maxOrder == 1) { SubAlloc.StopSubAllocator(); return(false); } SubAlloc.StartSubAllocator((maxMb + 1) << 20); _minContext = new PpmContext(Heap); //medContext = new PPMContext(Heap); _maxContext = new PpmContext(Heap); FoundState = new State(Heap); _dummySee2Cont = new See2Context(); for (int i = 0; i < 25; i++) { for (int j = 0; j < 16; j++) { _see2Cont[i][j] = new See2Context(); } } StartModelRare(maxOrder); } return(_minContext.Address != 0); }
internal bool DecodeSymbol2(ModelPpm model) { long count; int hiCnt, i = NumStats - model.NumMasked; See2Context psee2C = MakeEscFreq2(model, i); RangeCoder coder = model.Coder; // STATE* ps[256], ** pps=ps, * p=U.Stats-1; State p = _tempState1.Initialize(model.Heap); State temp = _tempState2.Initialize(model.Heap); p.Address = _freqData.GetStats() - State.SIZE; int pps = 0; hiCnt = 0; do { do { p.IncrementAddress(); // p++; }while (model.CharMask[p.Symbol] == model.EscCount); hiCnt += p.Freq; _ps[pps++] = p.Address; }while (--i != 0); coder.SubRange.IncScale(hiCnt); count = coder.CurrentCount; if (count >= coder.SubRange.Scale) { return(false); } pps = 0; p.Address = _ps[pps]; if (count < hiCnt) { hiCnt = 0; while ((hiCnt += p.Freq) <= count) { p.Address = _ps[++pps]; // p=*++pps; } coder.SubRange.HighCount = hiCnt; coder.SubRange.LowCount = hiCnt - p.Freq; psee2C.Update(); Update2(model, p.Address); } else { coder.SubRange.LowCount = hiCnt; coder.SubRange.HighCount = coder.SubRange.Scale; i = NumStats - model.NumMasked; // ->NumMasked; pps--; do { temp.Address = _ps[++pps]; // (*++pps) model.CharMask[temp.Symbol] = model.EscCount; }while (--i != 0); psee2C.IncSumm((int)coder.SubRange.Scale); model.NumMasked = NumStats; } return(true); }