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); }
internal bool decodeInit(Unpack 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); 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 decodeSymbol1(ModelPPM model) { RangeCoder coder = model.Coder; coder.SubRange.Scale = freqData.SummFreq; State p = new State(model.Heap); p.Address = freqData.GetStats(); int i, HiCnt; long count = coder.CurrentCount; if (count >= coder.SubRange.Scale) { return(false); } if (count < (HiCnt = p.Freq)) { coder.SubRange.HighCount = HiCnt; model.PrevSuccess = (2 * HiCnt > coder.SubRange.Scale) ? 1 : 0; model.incRunLength(model.PrevSuccess); HiCnt += 4; model.FoundState.Address = p.Address; model.FoundState.Freq = HiCnt; freqData.IncrementSummFreq(4); if (HiCnt > ModelPPM.MAX_FREQ) { rescale(model); } coder.SubRange.LowCount = 0; return(true); } else { if (model.FoundState.Address == 0) { return(false); } } model.PrevSuccess = 0; int numStats = NumStats; i = numStats - 1; while ((HiCnt += p.IncrementAddress().Freq) <= count) { if (--i == 0) { model.HiBitsFlag = model.getHB2Flag()[model.FoundState.Symbol]; coder.SubRange.LowCount = HiCnt; model.CharMask[p.Symbol] = model.EscCount; model.NumMasked = numStats; i = numStats - 1; model.FoundState.Address = 0; do { model.CharMask[p.DecrementAddress().Symbol] = model.EscCount; }while (--i != 0); coder.SubRange.HighCount = coder.SubRange.Scale; return(true); } } coder.SubRange.LowCount = HiCnt - p.Freq; coder.SubRange.HighCount = HiCnt; update1(model, p.Address); return(true); }
internal bool decodeInit(Unpack 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); 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); }