Example #1
0
        public Model()
        {
            // Construct the conversion table for number statistics.  Initially it will contain the following values.
            //
            // 0 2 4 4 4 4 4 4 4 4 4 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6

            numberStatisticsToBinarySummaryIndex[0] = 2*0;
            numberStatisticsToBinarySummaryIndex[1] = 2*1;
            for (int index = 2; index < 11; index++)
                numberStatisticsToBinarySummaryIndex[index] = 2*2;
            for (int index = 11; index < 256; index++)
                numberStatisticsToBinarySummaryIndex[index] = 2*3;

            // Construct the probability table.  Initially it will contain the following values (depending on the value of
            // the upper frequency).
            //
            // 00 01 02 03 04 05 06 06 07 07 07 08 08 08 08 09 09 09 09 09 10 10 10 10 10 10 11 11 11 11 11 11
            // 11 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 14 14 14 14 14 14 14 14 14 14 15 15 15 15
            // 15 15 15 15 15 15 15 16 16 16 16 16 16 16 16 16 16 16 16 17 17 17 17 17 17 17 17 17 17 17 17 17
            // 18 18 18 18 18 18 18 18 18 18 18 18 18 18 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 20 20 20
            // 20 20 20 20 20 20 20 20 20 20 20 20 20 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 22 22
            // 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23
            // 23 23 23 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 25 25 25 25 25 25 25 25 25
            // 25 25 25 25 25 25 25 25 25 25 25 25 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26
            // 26 26 27 27

            uint count = 1;
            uint step = 1;
            uint probability = UpperFrequency;

            for (int index = 0; index < UpperFrequency; index++)
                probabilities[index] = (byte) index;

            for (int index = UpperFrequency; index < 260; index++)
            {
                probabilities[index] = (byte) probability;
                count--;
                if (count == 0)
                {
                    step++;
                    count = step;
                    probability++;
                }
            }

            // Create the context array.

            see2Contexts = new See2Context[24,32];
            for (int index1 = 0; index1 < 24; index1++)
                for (int index2 = 0; index2 < 32; index2++)
                    see2Contexts[index1, index2] = new See2Context();

            // Set the signature (identifying the algorithm).

            emptySee2Context = new See2Context();
            emptySee2Context.Summary = (ushort) (Signature & 0x0000ffff);
            emptySee2Context.Shift = (byte) ((Signature >> 16) & 0x000000ff);
            emptySee2Context.Count = (byte) (Signature >> 24);
        }
Example #2
0
        public Model()
        {
            // Construct the conversion table for number statistics.  Initially it will contain the following values.
            //
            // 0 2 4 4 4 4 4 4 4 4 4 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
            // 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6

            numberStatisticsToBinarySummaryIndex[0] = 2 * 0;
            numberStatisticsToBinarySummaryIndex[1] = 2 * 1;
            for (int index = 2; index < 11; index++)
            {
                numberStatisticsToBinarySummaryIndex[index] = 2 * 2;
            }
            for (int index = 11; index < 256; index++)
            {
                numberStatisticsToBinarySummaryIndex[index] = 2 * 3;
            }

            // Construct the probability table.  Initially it will contain the following values (depending on the value of
            // the upper frequency).
            //
            // 00 01 02 03 04 05 06 06 07 07 07 08 08 08 08 09 09 09 09 09 10 10 10 10 10 10 11 11 11 11 11 11
            // 11 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 14 14 14 14 14 14 14 14 14 14 15 15 15 15
            // 15 15 15 15 15 15 15 16 16 16 16 16 16 16 16 16 16 16 16 17 17 17 17 17 17 17 17 17 17 17 17 17
            // 18 18 18 18 18 18 18 18 18 18 18 18 18 18 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 20 20 20
            // 20 20 20 20 20 20 20 20 20 20 20 20 20 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21 22 22
            // 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23
            // 23 23 23 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 25 25 25 25 25 25 25 25 25
            // 25 25 25 25 25 25 25 25 25 25 25 25 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26
            // 26 26 27 27

            uint count       = 1;
            uint step        = 1;
            uint probability = UpperFrequency;

            for (int index = 0; index < UpperFrequency; index++)
            {
                probabilities[index] = (byte)index;
            }

            for (int index = UpperFrequency; index < 260; index++)
            {
                probabilities[index] = (byte)probability;
                count--;
                if (count == 0)
                {
                    step++;
                    count = step;
                    probability++;
                }
            }

            // Create the context array.

            see2Contexts = new See2Context[24, 32];
            for (int index1 = 0; index1 < 24; index1++)
            {
                for (int index2 = 0; index2 < 32; index2++)
                {
                    see2Contexts[index1, index2] = new See2Context();
                }
            }

            // Set the signature (identifying the algorithm).

            emptySee2Context         = new See2Context();
            emptySee2Context.Summary = (ushort)(Signature & 0x0000ffff);
            emptySee2Context.Shift   = (byte)((Signature >> 16) & 0x000000ff);
            emptySee2Context.Count   = (byte)(Signature >> 24);
        }