Пример #1
0
        private void restartModelRare()
        {
            int num2;
            int num3;

            Utility.Fill <int>(this.charMask, 0);
            this.subAlloc.initSubAllocator();
            this.initRL = -((this.maxOrder < 12) ? this.maxOrder : 12) - 1;
            int stats = this.subAlloc.allocContext();

            this.minContext.Address = stats;
            this.maxContext.Address = stats;
            this.minContext.setSuffix(0);
            this.orderFall                    = this.maxOrder;
            this.minContext.NumStats          = 0x100;
            this.minContext.FreqData.SummFreq = this.minContext.NumStats + 1;
            stats = this.subAlloc.allocUnits(0x80);
            this.foundState.Address = stats;
            this.minContext.FreqData.SetStats(stats);
            SharpCompress.Compressor.PPMd.H.State state = new SharpCompress.Compressor.PPMd.H.State(this.subAlloc.Heap);
            stats            = this.minContext.FreqData.GetStats();
            this.runLength   = this.initRL;
            this.prevSuccess = 0;
            for (num2 = 0; num2 < 0x100; num2++)
            {
                state.Address = stats + (num2 * 6);
                state.Symbol  = num2;
                state.Freq    = 1;
                state.SetSuccessor(0);
            }
            for (num2 = 0; num2 < 0x80; num2++)
            {
                num3 = 0;
                while (num3 < 8)
                {
                    for (int i = 0; i < 0x40; i += 8)
                    {
                        this.binSumm[num2][num3 + i] = BIN_SCALE - (InitBinEsc[num3] / (num2 + 2));
                    }
                    num3++;
                }
            }
            for (num2 = 0; num2 < 0x19; num2++)
            {
                for (num3 = 0; num3 < 0x10; num3++)
                {
                    this.SEE2Cont[num2][num3].Initialize((5 * num2) + 10);
                }
            }
        }
Пример #2
0
        internal int createChild(ModelPPM model, SharpCompress.Compressor.PPMd.H.State pStats, StateRef firstState)
        {
            PPMContext successor = this.getTempPPMContext(model.SubAlloc.Heap);

            successor.Address = model.SubAlloc.allocContext();
            if (successor != null)
            {
                successor.NumStats = 1;
                successor.setOneState(firstState);
                successor.setSuffix(this);
                pStats.SetSuccessor(successor);
            }
            return(successor.Address);
        }
Пример #3
0
        private void updateModel()
        {
            StateRef ref2 = this.tempStateRef1;

            ref2.Values = this.foundState;
            SharpCompress.Compressor.PPMd.H.State state  = this.tempState3.Initialize(this.Heap);
            SharpCompress.Compressor.PPMd.H.State state2 = this.tempState4.Initialize(this.Heap);
            PPMContext context   = this.tempPPMContext3.Initialize(this.Heap);
            PPMContext successor = this.tempPPMContext4.Initialize(this.Heap);

            context.Address = this.minContext.getSuffix();
            if ((ref2.Freq < 0x1f) && (context.Address != 0))
            {
                if (context.NumStats != 1)
                {
                    state.Address = context.FreqData.GetStats();
                    if (state.Symbol != ref2.Symbol)
                    {
                        do
                        {
                            state.IncrementAddress();
                        }while (state.Symbol != ref2.Symbol);
                        state2.Address = state.Address - 6;
                        if (state.Freq >= state2.Freq)
                        {
                            SharpCompress.Compressor.PPMd.H.State.PPMDSwap(state, state2);
                            state.DecrementAddress();
                        }
                    }
                    if (state.Freq < 0x73)
                    {
                        state.IncrementFreq(2);
                        context.FreqData.IncrementSummFreq(2);
                    }
                }
                else
                {
                    state.Address = context.getOneState().Address;
                    if (state.Freq < 0x20)
                    {
                        state.IncrementFreq(1);
                    }
                }
            }
            if (this.orderFall == 0)
            {
                this.foundState.SetSuccessor(this.createSuccessors(true, state));
                this.minContext.Address = this.foundState.GetSuccessor();
                this.maxContext.Address = this.foundState.GetSuccessor();
                if (this.minContext.Address == 0)
                {
                    this.updateModelRestart();
                }
            }
            else
            {
                this.subAlloc.Heap[this.subAlloc.PText] = (byte)ref2.Symbol;
                this.subAlloc.incPText();
                successor.Address = this.subAlloc.PText;
                if (this.subAlloc.PText >= this.subAlloc.FakeUnitsStart)
                {
                    this.updateModelRestart();
                }
                else
                {
                    if (ref2.GetSuccessor() != 0)
                    {
                        if (ref2.GetSuccessor() <= this.subAlloc.PText)
                        {
                            ref2.SetSuccessor(this.createSuccessors(false, state));
                            if (ref2.GetSuccessor() == 0)
                            {
                                this.updateModelRestart();
                                return;
                            }
                        }
                        if (--this.orderFall == 0)
                        {
                            successor.Address = ref2.GetSuccessor();
                            if (this.maxContext.Address != this.minContext.Address)
                            {
                                this.subAlloc.decPText(1);
                            }
                        }
                    }
                    else
                    {
                        this.foundState.SetSuccessor(successor.Address);
                        ref2.SetSuccessor(this.minContext);
                    }
                    int numStats = this.minContext.NumStats;
                    int num5     = (this.minContext.FreqData.SummFreq - numStats) - (ref2.Freq - 1);
                    context.Address = this.maxContext.Address;
                    while (context.Address != this.minContext.Address)
                    {
                        int number = context.NumStats;
                        if (number != 1)
                        {
                            if ((number & 1) == 0)
                            {
                                context.FreqData.SetStats(this.subAlloc.expandUnits(context.FreqData.GetStats(), Utility.URShift(number, 1)));
                                if (context.FreqData.GetStats() == 0)
                                {
                                    this.updateModelRestart();
                                    return;
                                }
                            }
                            int num6 = (((2 * number) < numStats) ? 1 : 0) + (2 * ((((4 * number) <= numStats) ? 1 : 0) & ((context.FreqData.SummFreq <= (8 * number)) ? 1 : 0)));
                            context.FreqData.IncrementSummFreq(num6);
                        }
                        else
                        {
                            state.Address = this.subAlloc.allocUnits(1);
                            if (state.Address == 0)
                            {
                                this.updateModelRestart();
                                return;
                            }
                            state.SetValues(context.getOneState());
                            context.FreqData.SetStats(state);
                            if (state.Freq < 30)
                            {
                                state.IncrementFreq(state.Freq);
                            }
                            else
                            {
                                state.Freq = 120;
                            }
                            context.FreqData.SummFreq = (state.Freq + this.initEsc) + ((numStats > 3) ? 1 : 0);
                        }
                        int dSummFreq = (2 * ref2.Freq) * (context.FreqData.SummFreq + 6);
                        int num4      = num5 + context.FreqData.SummFreq;
                        if (dSummFreq < (6 * num4))
                        {
                            dSummFreq = (1 + ((dSummFreq > num4) ? 1 : 0)) + ((dSummFreq >= (4 * num4)) ? 1 : 0);
                            context.FreqData.IncrementSummFreq(3);
                        }
                        else
                        {
                            dSummFreq = ((4 + ((dSummFreq >= (9 * num4)) ? 1 : 0)) + ((dSummFreq >= (12 * num4)) ? 1 : 0)) + ((dSummFreq >= (15 * num4)) ? 1 : 0);
                            context.FreqData.IncrementSummFreq(dSummFreq);
                        }
                        state.Address = context.FreqData.GetStats() + (number * 6);
                        state.SetSuccessor(successor);
                        state.Symbol     = ref2.Symbol;
                        state.Freq       = dSummFreq;
                        context.NumStats = ++number;
                        context.Address  = context.getSuffix();
                    }
                    int num7 = ref2.GetSuccessor();
                    this.maxContext.Address = num7;
                    this.minContext.Address = num7;
                }
            }
        }
Пример #4
0
 private void restartModelRare()
 {
     int num2;
     int num3;
     Utility.Fill<int>(this.charMask, 0);
     this.subAlloc.initSubAllocator();
     this.initRL = -((this.maxOrder < 12) ? this.maxOrder : 12) - 1;
     int stats = this.subAlloc.allocContext();
     this.minContext.Address = stats;
     this.maxContext.Address = stats;
     this.minContext.setSuffix(0);
     this.orderFall = this.maxOrder;
     this.minContext.NumStats = 0x100;
     this.minContext.FreqData.SummFreq = this.minContext.NumStats + 1;
     stats = this.subAlloc.allocUnits(0x80);
     this.foundState.Address = stats;
     this.minContext.FreqData.SetStats(stats);
     SharpCompress.Compressor.PPMd.H.State state = new SharpCompress.Compressor.PPMd.H.State(this.subAlloc.Heap);
     stats = this.minContext.FreqData.GetStats();
     this.runLength = this.initRL;
     this.prevSuccess = 0;
     for (num2 = 0; num2 < 0x100; num2++)
     {
         state.Address = stats + (num2 * 6);
         state.Symbol = num2;
         state.Freq = 1;
         state.SetSuccessor(0);
     }
     for (num2 = 0; num2 < 0x80; num2++)
     {
         num3 = 0;
         while (num3 < 8)
         {
             for (int i = 0; i < 0x40; i += 8)
             {
                 this.binSumm[num2][num3 + i] = BIN_SCALE - (InitBinEsc[num3] / (num2 + 2));
             }
             num3++;
         }
     }
     for (num2 = 0; num2 < 0x19; num2++)
     {
         for (num3 = 0; num3 < 0x10; num3++)
         {
             this.SEE2Cont[num2][num3].Initialize((5 * num2) + 10);
         }
     }
 }