Пример #1
0
        internal int createChild(ModelPPM model, State pStats, StateRef firstState)
        {
            PPMContext pc = getTempPPMContext(model.SubAlloc.Heap);

            pc.Address = model.SubAlloc.allocContext();
            if (pc != null)
            {
                pc.NumStats = 1;
                pc.setOneState(firstState);
                pc.setSuffix(this);
                pStats.SetSuccessor(pc);
            }
            return(pc.Address);
        }
Пример #2
0
        private void updateModel()
        {
            //System.out.println("ModelPPM.updateModel()");
            // STATE fs = *FoundState, *p = NULL;
            StateRef fs = tempStateRef1;

            fs.Values = foundState;
            State p         = tempState3.Initialize(Heap);
            State tempState = tempState4.Initialize(Heap);

            PPMContext pc        = tempPPMContext3.Initialize(Heap);
            PPMContext successor = tempPPMContext4.Initialize(Heap);

            int ns1, ns, cf, sf, s0;

            pc.Address = minContext.getSuffix();
            if (fs.Freq < MAX_FREQ / 4 && pc.Address != 0)
            {
                if (pc.NumStats != 1)
                {
                    p.Address = pc.FreqData.GetStats();
                    if (p.Symbol != fs.Symbol)
                    {
                        do
                        {
                            p.IncrementAddress();
                        } while (p.Symbol != fs.Symbol);
                        tempState.Address = p.Address - State.Size;
                        if (p.Freq >= tempState.Freq)
                        {
                            State.PPMDSwap(p, tempState);
                            p.DecrementAddress();
                        }
                    }
                    if (p.Freq < MAX_FREQ - 9)
                    {
                        p.IncrementFreq(2);
                        pc.FreqData.IncrementSummFreq(2);
                    }
                }
                else
                {
                    p.Address = pc.getOneState().Address;
                    if (p.Freq < 32)
                    {
                        p.IncrementFreq(1);
                    }
                }
            }
            if (orderFall == 0)
            {
                foundState.SetSuccessor(createSuccessors(true, p));
                minContext.Address = foundState.GetSuccessor();
                maxContext.Address = foundState.GetSuccessor();
                if (minContext.Address == 0)
                {
                    updateModelRestart();
                    return;
                }
                return;
            }
            subAlloc.Heap[subAlloc.PText] = (byte)fs.Symbol;
            subAlloc.incPText();
            successor.Address = subAlloc.PText;
            if (subAlloc.PText >= subAlloc.FakeUnitsStart)
            {
                updateModelRestart();
                return;
            }
            //        // Debug
            //        subAlloc.dumpHeap();
            if (fs.GetSuccessor() != 0)
            {
                if (fs.GetSuccessor() <= subAlloc.PText)
                {
                    fs.SetSuccessor(createSuccessors(false, p));
                    if (fs.GetSuccessor() == 0)
                    {
                        updateModelRestart();
                        return;
                    }
                }
                if (--orderFall == 0)
                {
                    successor.Address = fs.GetSuccessor();
                    if (maxContext.Address != minContext.Address)
                    {
                        subAlloc.decPText(1);
                    }
                }
            }
            else
            {
                foundState.SetSuccessor(successor.Address);
                fs.SetSuccessor(minContext);
            }
            //        // Debug
            //        subAlloc.dumpHeap();
            ns = minContext.NumStats;
            s0 = minContext.FreqData.SummFreq - (ns) - (fs.Freq - 1);
            for (pc.Address = maxContext.Address; pc.Address != minContext.Address; pc.Address = pc.getSuffix())
            {
                if ((ns1 = pc.NumStats) != 1)
                {
                    if ((ns1 & 1) == 0)
                    {
                        //System.out.println(ns1);
                        pc.FreqData.SetStats(subAlloc.expandUnits(pc.FreqData.GetStats(), Utility.URShift(ns1, 1)));
                        if (pc.FreqData.GetStats() == 0)
                        {
                            updateModelRestart();
                            return;
                        }
                    }
                    // bug fixed
                    //				int sum = ((2 * ns1 < ns) ? 1 : 0) +
                    //                        2 * ((4 * ((ns1 <= ns) ? 1 : 0)) & ((pc.getFreqData()
                    //								.getSummFreq() <= 8 * ns1) ? 1 : 0));
                    int sum = ((2 * ns1 < ns) ? 1 : 0) +
                              2 * (((4 * ns1 <= ns) ? 1 : 0) & ((pc.FreqData.SummFreq <= 8 * ns1) ? 1 : 0));
                    pc.FreqData.IncrementSummFreq(sum);
                }
                else
                {
                    p.Address = subAlloc.allocUnits(1);
                    if (p.Address == 0)
                    {
                        updateModelRestart();
                        return;
                    }
                    p.SetValues(pc.getOneState());
                    pc.FreqData.SetStats(p);
                    if (p.Freq < MAX_FREQ / 4 - 1)
                    {
                        p.IncrementFreq(p.Freq);
                    }
                    else
                    {
                        p.Freq = MAX_FREQ - 4;
                    }
                    pc.FreqData.SummFreq = (p.Freq + initEsc + (ns > 3 ? 1 : 0));
                }
                cf = 2 * fs.Freq * (pc.FreqData.SummFreq + 6);
                sf = s0 + pc.FreqData.SummFreq;
                if (cf < 6 * sf)
                {
                    cf = 1 + (cf > sf ? 1 : 0) + (cf >= 4 * sf ? 1 : 0);
                    pc.FreqData.IncrementSummFreq(3);
                }
                else
                {
                    cf = 4 + (cf >= 9 * sf ? 1 : 0) + (cf >= 12 * sf ? 1 : 0) + (cf >= 15 * sf ? 1 : 0);
                    pc.FreqData.IncrementSummFreq(cf);
                }
                p.Address = pc.FreqData.GetStats() + ns1 * State.Size;
                p.SetSuccessor(successor);
                p.Symbol    = fs.Symbol;
                p.Freq      = cf;
                pc.NumStats = ++ns1;
            }

            int address = fs.GetSuccessor();

            maxContext.Address = address;
            minContext.Address = address;
            //TODO-----debug
            //		int pos = minContext.getFreqData().getStats();
            //		State a = new State(getHeap());
            //		a.Address=pos);
            //		pos+=State.size;
            //		a.Address=pos);
            //--dbg end
            return;
        }
Пример #3
0
        private int createSuccessors(bool Skip, State p1)
        {
            //State upState = tempState1.Initialize(null);
            StateRef upState   = tempStateRef2;
            State    tempState = tempState1.Initialize(Heap);

            // PPM_CONTEXT* pc=MinContext, * UpBranch=FoundState->Successor;
            PPMContext pc = tempPPMContext1.Initialize(Heap);

            pc.Address = minContext.Address;
            PPMContext upBranch = tempPPMContext2.Initialize(Heap);

            upBranch.Address = foundState.GetSuccessor();

            // STATE * p, * ps[MAX_O], ** pps=ps;
            State p   = tempState2.Initialize(Heap);
            int   pps = 0;

            bool noLoop = false;

            if (!Skip)
            {
                ps[pps++] = foundState.Address; // *pps++ = FoundState;
                if (pc.getSuffix() == 0)
                {
                    noLoop = true;
                }
            }
            if (!noLoop)
            {
                bool loopEntry = false;
                if (p1.Address != 0)
                {
                    p.Address  = p1.Address;
                    pc.Address = pc.getSuffix(); // =pc->Suffix;
                    loopEntry  = true;
                }
                do
                {
                    if (!loopEntry)
                    {
                        pc.Address = pc.getSuffix(); // pc=pc->Suffix;
                        if (pc.NumStats != 1)
                        {
                            p.Address = pc.FreqData.GetStats(); // p=pc->U.Stats
                            if (p.Symbol != foundState.Symbol)
                            {
                                do
                                {
                                    p.IncrementAddress();
                                } while (p.Symbol != foundState.Symbol);
                            }
                        }
                        else
                        {
                            p.Address = pc.getOneState().Address; // p=&(pc->OneState);
                        }
                    } // LOOP_ENTRY:
                    loopEntry = false;
                    if (p.GetSuccessor() != upBranch.Address)
                    {
                        pc.Address = p.GetSuccessor(); // =p->Successor;
                        break;
                    }
                    ps[pps++] = p.Address;
                } while (pc.getSuffix() != 0);
            } // NO_LOOP:
            if (pps == 0)
            {
                return(pc.Address);
            }
            upState.Symbol = Heap[upBranch.Address]; // UpState.Symbol=*(byte*)
            // UpBranch;
            // UpState.Successor=(PPM_CONTEXT*) (((byte*) UpBranch)+1);
            upState.SetSuccessor(upBranch.Address + 1); //TODO check if +1 necessary
            if (pc.NumStats != 1)
            {
                if (pc.Address <= subAlloc.PText)
                {
                    return(0);
                }
                p.Address = pc.FreqData.GetStats();
                if (p.Symbol != upState.Symbol)
                {
                    do
                    {
                        p.IncrementAddress();
                    } while (p.Symbol != upState.Symbol);
                }
                int cf = p.Freq - 1;
                int s0 = pc.FreqData.SummFreq - pc.NumStats - cf;
                // UpState.Freq=1+((2*cf <= s0)?(5*cf > s0):((2*cf+3*s0-1)/(2*s0)));
                upState.Freq = 1 + ((2 * cf <= s0) ? (5 * cf > s0 ? 1 : 0) : ((2 * cf + 3 * s0 - 1) / (2 * s0)));
            }
            else
            {
                upState.Freq = pc.getOneState().Freq; // UpState.Freq=pc->OneState.Freq;
            }
            do
            {
                // pc = pc->createChild(this,*--pps,UpState);
                tempState.Address = ps[--pps];
                pc.Address        = pc.createChild(this, tempState, upState);
                if (pc.Address == 0)
                {
                    return(0);
                }
            } while (pps != 0);
            return(pc.Address);
        }
Пример #4
0
 internal void setOneState(StateRef oneState)
 {
     this.oneState.SetValues(oneState);
 }
Пример #5
0
        internal void rescale(ModelPPM model)
        {
            int OldNS = NumStats, i = NumStats - 1, Adder, EscFreq;
            // STATE* p1, * p;
            State p1   = new State(model.Heap);
            State p    = new State(model.Heap);
            State temp = new State(model.Heap);

            for (p.Address = model.FoundState.Address; p.Address != freqData.GetStats(); p.DecrementAddress())
            {
                temp.Address = p.Address - State.Size;
                State.PPMDSwap(p, temp);
            }
            temp.Address = freqData.GetStats();
            temp.IncrementFreq(4);
            freqData.IncrementSummFreq(4);
            EscFreq           = freqData.SummFreq - p.Freq;
            Adder             = (model.OrderFall != 0) ? 1 : 0;
            p.Freq            = Utility.URShift((p.Freq + Adder), 1);
            freqData.SummFreq = p.Freq;
            do
            {
                p.IncrementAddress();
                EscFreq -= p.Freq;
                p.Freq   = Utility.URShift((p.Freq + Adder), 1);
                freqData.IncrementSummFreq(p.Freq);
                temp.Address = p.Address - State.Size;
                if (p.Freq > temp.Freq)
                {
                    p1.Address = p.Address;
                    StateRef tmp = new StateRef();
                    tmp.Values = p1;
                    State temp2 = new State(model.Heap);
                    State temp3 = new State(model.Heap);
                    do
                    {
                        // p1[0]=p1[-1];
                        temp2.Address = p1.Address - State.Size;
                        p1.SetValues(temp2);
                        p1.DecrementAddress();
                        temp3.Address = p1.Address - State.Size;
                    } while (p1.Address != freqData.GetStats() && tmp.Freq > temp3.Freq);
                    p1.SetValues(tmp);
                }
            } while (--i != 0);
            if (p.Freq == 0)
            {
                do
                {
                    i++;
                    p.DecrementAddress();
                } while (p.Freq == 0);
                EscFreq += i;
                NumStats = NumStats - i;
                if (NumStats == 1)
                {
                    StateRef tmp = new StateRef();
                    temp.Address = freqData.GetStats();
                    tmp.Values   = temp;
                    // STATE tmp=*U.Stats;
                    do
                    {
                        // tmp.Freq-=(tmp.Freq >> 1)
                        tmp.DecrementFreq(Utility.URShift(tmp.Freq, 1));
                        EscFreq = Utility.URShift(EscFreq, 1);
                    } while (EscFreq > 1);
                    model.SubAlloc.freeUnits(freqData.GetStats(), Utility.URShift((OldNS + 1), 1));
                    oneState.SetValues(tmp);
                    model.FoundState.Address = oneState.Address;
                    return;
                }
            }
            EscFreq -= Utility.URShift(EscFreq, 1);
            freqData.IncrementSummFreq(EscFreq);
            int n0 = Utility.URShift((OldNS + 1), 1), n1 = Utility.URShift((NumStats + 1), 1);

            if (n0 != n1)
            {
                freqData.SetStats(model.SubAlloc.shrinkUnits(freqData.GetStats(), n0, n1));
            }
            model.FoundState.Address = freqData.GetStats();
        }
Пример #6
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;
                }
            }
        }
Пример #7
0
        private int createSuccessors(bool Skip, SharpCompress.Compressor.PPMd.H.State p1)
        {
            StateRef firstState = this.tempStateRef2;

            SharpCompress.Compressor.PPMd.H.State pStats = this.tempState1.Initialize(this.Heap);
            PPMContext context = this.tempPPMContext1.Initialize(this.Heap);

            context.Address = this.minContext.Address;
            PPMContext context2 = this.tempPPMContext2.Initialize(this.Heap);

            context2.Address = this.foundState.GetSuccessor();
            SharpCompress.Compressor.PPMd.H.State state2 = this.tempState2.Initialize(this.Heap);
            int  num  = 0;
            bool flag = false;

            if (!Skip)
            {
                this.ps[num++] = this.foundState.Address;
                if (context.getSuffix() == 0)
                {
                    flag = true;
                }
            }
            if (flag)
            {
                goto Label_01E0;
            }
            bool flag2 = false;

            if (p1.Address != 0)
            {
                state2.Address  = p1.Address;
                context.Address = context.getSuffix();
                flag2           = true;
            }
Label_00F2:
            if (!flag2)
            {
                context.Address = context.getSuffix();
                if (context.NumStats != 1)
                {
                    state2.Address = context.FreqData.GetStats();
                    if (state2.Symbol != this.foundState.Symbol)
                    {
                        do
                        {
                            state2.IncrementAddress();
                        }while (state2.Symbol != this.foundState.Symbol);
                    }
                }
                else
                {
                    state2.Address = context.getOneState().Address;
                }
            }
            flag2 = false;
            if (state2.GetSuccessor() != context2.Address)
            {
                context.Address = state2.GetSuccessor();
            }
            else
            {
                this.ps[num++] = state2.Address;
                if (context.getSuffix() != 0)
                {
                    goto Label_00F2;
                }
            }
Label_01E0:
            if (num != 0)
            {
                firstState.Symbol = this.Heap[context2.Address];
                firstState.SetSuccessor((int)(context2.Address + 1));
                if (context.NumStats != 1)
                {
                    if (context.Address <= this.subAlloc.PText)
                    {
                        return(0);
                    }
                    state2.Address = context.FreqData.GetStats();
                    if (state2.Symbol != firstState.Symbol)
                    {
                        do
                        {
                            state2.IncrementAddress();
                        }while (state2.Symbol != firstState.Symbol);
                    }
                    int num2 = state2.Freq - 1;
                    int num3 = (context.FreqData.SummFreq - context.NumStats) - num2;
                    firstState.Freq = 1 + (((2 * num2) <= num3) ? (((5 * num2) > num3) ? 1 : 0) : ((((2 * num2) + (3 * num3)) - 1) / (2 * num3)));
                }
                else
                {
                    firstState.Freq = context.getOneState().Freq;
                }
                do
                {
                    pStats.Address  = this.ps[--num];
                    context.Address = context.createChild(this, pStats, firstState);
                    if (context.Address == 0)
                    {
                        return(0);
                    }
                }while (num != 0);
            }
            return(context.Address);
        }
Пример #8
0
 internal void SetValues(StateRef state)
 {
     Symbol = state.Symbol;
     Freq = state.Freq;
     SetSuccessor(state.GetSuccessor());
 }
Пример #9
0
 internal void SetValues(StateRef state)
 {
     Symbol = state.Symbol;
     Freq   = state.Freq;
     SetSuccessor(state.GetSuccessor());
 }
Пример #10
0
        internal void rescale(ModelPPM model)
        {
            int OldNS = NumStats, i = NumStats - 1, Adder, EscFreq;
            // STATE* p1, * p;
            State p1 = new State(model.Heap);
            State p = new State(model.Heap);
            State temp = new State(model.Heap);

            for (p.Address = model.FoundState.Address; p.Address != freqData.GetStats(); p.DecrementAddress())
            {
                temp.Address = p.Address - State.Size;
                State.PPMDSwap(p, temp);
            }
            temp.Address = freqData.GetStats();
            temp.IncrementFreq(4);
            freqData.IncrementSummFreq(4);
            EscFreq = freqData.SummFreq - p.Freq;
            Adder = (model.OrderFall != 0) ? 1 : 0;
            p.Freq = Utility.URShift((p.Freq + Adder), 1);
            freqData.SummFreq = p.Freq;
            do
            {
                p.IncrementAddress();
                EscFreq -= p.Freq;
                p.Freq = Utility.URShift((p.Freq + Adder), 1);
                freqData.IncrementSummFreq(p.Freq);
                temp.Address = p.Address - State.Size;
                if (p.Freq > temp.Freq)
                {
                    p1.Address = p.Address;
                    StateRef tmp = new StateRef();
                    tmp.Values = p1;
                    State temp2 = new State(model.Heap);
                    State temp3 = new State(model.Heap);
                    do
                    {
                        // p1[0]=p1[-1];
                        temp2.Address = p1.Address - State.Size;
                        p1.SetValues(temp2);
                        p1.DecrementAddress();
                        temp3.Address = p1.Address - State.Size;
                    }
                    while (p1.Address != freqData.GetStats() && tmp.Freq > temp3.Freq);
                    p1.SetValues(tmp);
                }
            }
            while (--i != 0);
            if (p.Freq == 0)
            {
                do
                {
                    i++;
                    p.DecrementAddress();
                }
                while (p.Freq == 0);
                EscFreq += i;
                NumStats = NumStats - i;
                if (NumStats == 1)
                {
                    StateRef tmp = new StateRef();
                    temp.Address = freqData.GetStats();
                    tmp.Values = temp;
                    // STATE tmp=*U.Stats;
                    do
                    {
                        // tmp.Freq-=(tmp.Freq >> 1)
                        tmp.DecrementFreq(Utility.URShift(tmp.Freq, 1));
                        EscFreq = Utility.URShift(EscFreq, 1);
                    }
                    while (EscFreq > 1);
                    model.SubAlloc.freeUnits(freqData.GetStats(), Utility.URShift((OldNS + 1), 1));
                    oneState.SetValues(tmp);
                    model.FoundState.Address = oneState.Address;
                    return;
                }
            }
            EscFreq -= Utility.URShift(EscFreq, 1);
            freqData.IncrementSummFreq(EscFreq);
            int n0 = Utility.URShift((OldNS + 1), 1), n1 = Utility.URShift((NumStats + 1), 1);
            if (n0 != n1)
            {
                freqData.SetStats(model.SubAlloc.shrinkUnits(freqData.GetStats(), n0, n1));
            }
            model.FoundState.Address = freqData.GetStats();
        }
Пример #11
0
 internal void setOneState(StateRef oneState)
 {
     this.oneState.SetValues(oneState);
 }
Пример #12
0
 internal int createChild(ModelPPM model, State pStats, StateRef firstState)
 {
     PPMContext pc = getTempPPMContext(model.SubAlloc.Heap);
     pc.Address = model.SubAlloc.allocContext();
     if (pc != null)
     {
         pc.NumStats = 1;
         pc.setOneState(firstState);
         pc.setSuffix(this);
         pStats.SetSuccessor(pc);
     }
     return pc.Address;
 }
Пример #13
0
 internal void rescale(ModelPPM model)
 {
     StateRef ref2;
     int numStats = this.NumStats;
     int num2 = this.NumStats - 1;
     SharpCompress.Compressor.PPMd.H.State state = new SharpCompress.Compressor.PPMd.H.State(model.Heap);
     SharpCompress.Compressor.PPMd.H.State state2 = new SharpCompress.Compressor.PPMd.H.State(model.Heap);
     SharpCompress.Compressor.PPMd.H.State state3 = new SharpCompress.Compressor.PPMd.H.State(model.Heap);
     state2.Address = model.FoundState.Address;
     while (state2.Address != this.freqData.GetStats())
     {
         state3.Address = state2.Address - 6;
         SharpCompress.Compressor.PPMd.H.State.PPMDSwap(state2, state3);
         state2.DecrementAddress();
     }
     state3.Address = this.freqData.GetStats();
     state3.IncrementFreq(4);
     this.freqData.IncrementSummFreq(4);
     int number = this.freqData.SummFreq - state2.Freq;
     int num3 = (model.OrderFall != 0) ? 1 : 0;
     state2.Freq = Utility.URShift((int) (state2.Freq + num3), 1);
     this.freqData.SummFreq = state2.Freq;
     do
     {
         state2.IncrementAddress();
         number -= state2.Freq;
         state2.Freq = Utility.URShift((int) (state2.Freq + num3), 1);
         this.freqData.IncrementSummFreq(state2.Freq);
         state3.Address = state2.Address - 6;
         if (state2.Freq > state3.Freq)
         {
             state.Address = state2.Address;
             ref2 = new StateRef();
             ref2.Values = state;
             SharpCompress.Compressor.PPMd.H.State ptr = new SharpCompress.Compressor.PPMd.H.State(model.Heap);
             SharpCompress.Compressor.PPMd.H.State state5 = new SharpCompress.Compressor.PPMd.H.State(model.Heap);
             do
             {
                 ptr.Address = state.Address - 6;
                 state.SetValues(ptr);
                 state.DecrementAddress();
                 state5.Address = state.Address - 6;
             }
             while ((state.Address != this.freqData.GetStats()) && (ref2.Freq > state5.Freq));
             state.SetValues(ref2);
         }
     }
     while (--num2 != 0);
     if (state2.Freq == 0)
     {
         do
         {
             num2++;
             state2.DecrementAddress();
         }
         while (state2.Freq == 0);
         number += num2;
         this.NumStats -= num2;
         if (this.NumStats == 1)
         {
             ref2 = new StateRef();
             state3.Address = this.freqData.GetStats();
             ref2.Values = state3;
             do
             {
                 ref2.DecrementFreq(Utility.URShift(ref2.Freq, 1));
                 number = Utility.URShift(number, 1);
             }
             while (number > 1);
             model.SubAlloc.freeUnits(this.freqData.GetStats(), Utility.URShift((int) (numStats + 1), 1));
             this.oneState.SetValues(ref2);
             model.FoundState.Address = this.oneState.Address;
             return;
         }
     }
     number -= Utility.URShift(number, 1);
     this.freqData.IncrementSummFreq(number);
     int oldNU = Utility.URShift((int) (numStats + 1), 1);
     int newNU = Utility.URShift((int) (this.NumStats + 1), 1);
     if (oldNU != newNU)
     {
         this.freqData.SetStats(model.SubAlloc.shrinkUnits(this.freqData.GetStats(), oldNU, newNU));
     }
     model.FoundState.Address = this.freqData.GetStats();
 }
Пример #14
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;
 }
Пример #15
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);
        }
Пример #16
0
        internal void rescale(ModelPPM model)
        {
            StateRef ref2;
            int      numStats = this.NumStats;
            int      num2     = this.NumStats - 1;

            SharpCompress.Compressor.PPMd.H.State state  = new SharpCompress.Compressor.PPMd.H.State(model.Heap);
            SharpCompress.Compressor.PPMd.H.State state2 = new SharpCompress.Compressor.PPMd.H.State(model.Heap);
            SharpCompress.Compressor.PPMd.H.State state3 = new SharpCompress.Compressor.PPMd.H.State(model.Heap);
            state2.Address = model.FoundState.Address;
            while (state2.Address != this.freqData.GetStats())
            {
                state3.Address = state2.Address - 6;
                SharpCompress.Compressor.PPMd.H.State.PPMDSwap(state2, state3);
                state2.DecrementAddress();
            }
            state3.Address = this.freqData.GetStats();
            state3.IncrementFreq(4);
            this.freqData.IncrementSummFreq(4);
            int number = this.freqData.SummFreq - state2.Freq;
            int num3   = (model.OrderFall != 0) ? 1 : 0;

            state2.Freq            = Utility.URShift((int)(state2.Freq + num3), 1);
            this.freqData.SummFreq = state2.Freq;
            do
            {
                state2.IncrementAddress();
                number     -= state2.Freq;
                state2.Freq = Utility.URShift((int)(state2.Freq + num3), 1);
                this.freqData.IncrementSummFreq(state2.Freq);
                state3.Address = state2.Address - 6;
                if (state2.Freq > state3.Freq)
                {
                    state.Address = state2.Address;
                    ref2          = new StateRef();
                    ref2.Values   = state;
                    SharpCompress.Compressor.PPMd.H.State ptr    = new SharpCompress.Compressor.PPMd.H.State(model.Heap);
                    SharpCompress.Compressor.PPMd.H.State state5 = new SharpCompress.Compressor.PPMd.H.State(model.Heap);
                    do
                    {
                        ptr.Address = state.Address - 6;
                        state.SetValues(ptr);
                        state.DecrementAddress();
                        state5.Address = state.Address - 6;
                    }while ((state.Address != this.freqData.GetStats()) && (ref2.Freq > state5.Freq));
                    state.SetValues(ref2);
                }
            }while (--num2 != 0);
            if (state2.Freq == 0)
            {
                do
                {
                    num2++;
                    state2.DecrementAddress();
                }while (state2.Freq == 0);
                number        += num2;
                this.NumStats -= num2;
                if (this.NumStats == 1)
                {
                    ref2           = new StateRef();
                    state3.Address = this.freqData.GetStats();
                    ref2.Values    = state3;
                    do
                    {
                        ref2.DecrementFreq(Utility.URShift(ref2.Freq, 1));
                        number = Utility.URShift(number, 1);
                    }while (number > 1);
                    model.SubAlloc.freeUnits(this.freqData.GetStats(), Utility.URShift((int)(numStats + 1), 1));
                    this.oneState.SetValues(ref2);
                    model.FoundState.Address = this.oneState.Address;
                    return;
                }
            }
            number -= Utility.URShift(number, 1);
            this.freqData.IncrementSummFreq(number);
            int oldNU = Utility.URShift((int)(numStats + 1), 1);
            int newNU = Utility.URShift((int)(this.NumStats + 1), 1);

            if (oldNU != newNU)
            {
                this.freqData.SetStats(model.SubAlloc.shrinkUnits(this.freqData.GetStats(), oldNU, newNU));
            }
            model.FoundState.Address = this.freqData.GetStats();
        }