Exemplo n.º 1
0
        internal void decodeBinSymbol(ModelPPM model)
        {
            State rs = tempState1.Initialize(model.Heap);

            rs.Address       = oneState.Address; // State&
            model.HiBitsFlag = model.getHB2Flag()[model.FoundState.Symbol];
            int off1 = rs.Freq - 1;
            int off2 = getArrayIndex(model, rs);
            int bs   = model.BinSumm[off1][off2];

            if (model.Coder.GetCurrentShiftCount(ModelPPM.TOT_BITS) < bs)
            {
                model.FoundState.Address = rs.Address;
                rs.IncrementFreq((rs.Freq < 128) ? 1 : 0);
                model.Coder.SubRange.LowCount  = 0;
                model.Coder.SubRange.HighCount = bs;
                bs = ((bs + ModelPPM.INTERVAL - getMean(bs, ModelPPM.PERIOD_BITS, 2)) & 0xffff);
                model.BinSumm[off1][off2] = bs;
                model.PrevSuccess         = 1;
                model.incRunLength(1);
            }
            else
            {
                model.Coder.SubRange.LowCount = bs;
                bs = (bs - getMean(bs, ModelPPM.PERIOD_BITS, 2)) & 0xFFFF;
                model.BinSumm[off1][off2]      = bs;
                model.Coder.SubRange.HighCount = ModelPPM.BIN_SCALE;
                model.InitEsc             = ExpEscape[Utility.URShift(bs, 10)];
                model.NumMasked           = 1;
                model.CharMask[rs.Symbol] = model.EscCount;
                model.PrevSuccess         = 0;
                model.FoundState.Address  = 0;
            }
            //int a = 0;//TODO just 4 debugging
        }
Exemplo n.º 2
0
 internal void update1_0(ModelPPM model, int p)
 {
     model.FoundState.Address = p;
     model.PrevSuccess        = 2 * model.FoundState.Freq > freqData.SummFreq ? 1 : 0;
     model.incRunLength(model.PrevSuccess);
     freqData.IncrementSummFreq(4);
     model.FoundState.IncrementFreq(4);
     if (model.FoundState.Freq > ModelPPM.MAX_FREQ)
     {
         rescale(model);
     }
 }
Exemplo n.º 3
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);
        }