Пример #1
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);
        }
Пример #2
0
        // 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);
        }
Пример #3
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];
     }
 }