예제 #1
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);
     }
 }
예제 #2
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             = EXP_ESCAPE[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
        }
예제 #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);
            }
            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);
        }