예제 #1
0
        public virtual int decodeChar()
        {
            // Debug
            //subAlloc.dumpHeap();

            if (minContext.Address <= subAlloc.PText || minContext.Address > subAlloc.HeapEnd)
            {
                return(-1);
            }

            if (minContext.NumStats != 1)
            {
                if (minContext.FreqData.GetStats() <= subAlloc.PText || minContext.FreqData.GetStats() > subAlloc.HeapEnd)
                {
                    return(-1);
                }
                if (!minContext.decodeSymbol1(this))
                {
                    return(-1);
                }
            }
            else
            {
                minContext.decodeBinSymbol(this);
            }
            coder.Decode();
            while (foundState.Address == 0)
            {
                coder.AriDecNormalize();
                do
                {
                    orderFall++;
                    minContext.Address = minContext.getSuffix(); // =MinContext->Suffix;
                    if (minContext.Address <= subAlloc.PText || minContext.Address > subAlloc.HeapEnd)
                    {
                        return(-1);
                    }
                }while (minContext.NumStats == numMasked);
                if (!minContext.decodeSymbol2(this))
                {
                    return(-1);
                }
                coder.Decode();
            }
            int Symbol = foundState.Symbol;

            if ((orderFall == 0) && foundState.GetSuccessor() > subAlloc.PText)
            {
                // MinContext=MaxContext=FoundState->Successor;
                int addr = foundState.GetSuccessor();
                minContext.Address = addr;
                maxContext.Address = addr;
            }
            else
            {
                updateModel();
                //this.foundState.Address=foundState.Address);//TODO just 4 debugging
                if (escCount == 0)
                {
                    clearMask();
                }
            }
            coder.AriDecNormalize(); // ARI_DEC_NORMALIZE(Coder.code,Coder.low,Coder.range,Coder.UnpackRead);
            return(Symbol);
        }