Example #1
0
 private int decodeNumber(Decode RD)
 {
     return UnpackUtility.decodeNumber(this,RD);
 }
Example #2
0
 internal static int decodeNumber(this BitInput input, Decode dec)
 {
     int bits;
     long bitField = input.GetBits() & 0xfffe;
     //        if (bitField < dec.getDecodeLen()[8]) {
     //			if (bitField < dec.getDecodeLen()[4]) {
     //				if (bitField < dec.getDecodeLen()[2]) {
     //					if (bitField < dec.getDecodeLen()[1]) {
     //						bits = 1;
     //					} else {
     //						bits = 2;
     //					}
     //				} else {
     //					if (bitField < dec.getDecodeLen()[3]) {
     //						bits = 3;
     //					} else {
     //						bits = 4;
     //					}
     //				}
     //			} else {
     //				if (bitField < dec.getDecodeLen()[6]) {
     //					if (bitField < dec.getDecodeLen()[5])
     //						bits = 5;
     //					else
     //						bits = 6;
     //				} else {
     //					if (bitField < dec.getDecodeLen()[7]) {
     //						bits = 7;
     //					} else {
     //						bits = 8;
     //					}
     //				}
     //			}
     //		} else {
     //			if (bitField < dec.getDecodeLen()[12]) {
     //				if (bitField < dec.getDecodeLen()[10])
     //					if (bitField < dec.getDecodeLen()[9])
     //						bits = 9;
     //					else
     //						bits = 10;
     //				else if (bitField < dec.getDecodeLen()[11])
     //					bits = 11;
     //				else
     //					bits = 12;
     //			} else {
     //				if (bitField < dec.getDecodeLen()[14]) {
     //					if (bitField < dec.getDecodeLen()[13]) {
     //						bits = 13;
     //					} else {
     //						bits = 14;
     //					}
     //				} else {
     //					bits = 15;
     //				}
     //			}
     //		}
     //		addbits(bits);
     //		int N = dec.getDecodePos()[bits]
     //				+ (((int) bitField - dec.getDecodeLen()[bits - 1]) >>> (16 - bits));
     //		if (N >= dec.getMaxNum()) {
     //			N = 0;
     //		}
     //		return (dec.getDecodeNum()[N]);
     int[] decodeLen = dec.DecodeLen;
     if (bitField < decodeLen[8])
     {
         if (bitField < decodeLen[4])
         {
             if (bitField < decodeLen[2])
             {
                 if (bitField < decodeLen[1])
                 {
                     bits = 1;
                 }
                 else
                 {
                     bits = 2;
                 }
             }
             else
             {
                 if (bitField < decodeLen[3])
                 {
                     bits = 3;
                 }
                 else
                 {
                     bits = 4;
                 }
             }
         }
         else
         {
             if (bitField < decodeLen[6])
             {
                 if (bitField < decodeLen[5])
                     bits = 5;
                 else
                     bits = 6;
             }
             else
             {
                 if (bitField < decodeLen[7])
                 {
                     bits = 7;
                 }
                 else
                 {
                     bits = 8;
                 }
             }
         }
     }
     else
     {
         if (bitField < decodeLen[12])
         {
             if (bitField < decodeLen[10])
                 if (bitField < decodeLen[9])
                     bits = 9;
                 else
                     bits = 10;
             else if (bitField < decodeLen[11])
                 bits = 11;
             else
                 bits = 12;
         }
         else
         {
             if (bitField < decodeLen[14])
             {
                 if (bitField < decodeLen[13])
                 {
                     bits = 13;
                 }
                 else
                 {
                     bits = 14;
                 }
             }
             else
             {
                 bits = 15;
             }
         }
     }
     input.AddBits(bits);
     int N = dec.DecodePos[bits] + (Utility.URShift(((int)bitField - decodeLen[bits - 1]), (16 - bits)));
     if (N >= dec.MaxNum)
     {
         N = 0;
     }
     return (dec.DecodeNum[N]);
 }
Example #3
0
 internal static int decodeNumber(BitInput input, Decode dec)
 {
     int num;
     long num2 = input.GetBits() & 0xfffe;
     int[] decodeLen = dec.DecodeLen;
     if (num2 < decodeLen[8])
     {
         if (num2 < decodeLen[4])
         {
             if (num2 < decodeLen[2])
             {
                 if (num2 < decodeLen[1])
                 {
                     num = 1;
                 }
                 else
                 {
                     num = 2;
                 }
             }
             else if (num2 < decodeLen[3])
             {
                 num = 3;
             }
             else
             {
                 num = 4;
             }
         }
         else if (num2 < decodeLen[6])
         {
             if (num2 < decodeLen[5])
             {
                 num = 5;
             }
             else
             {
                 num = 6;
             }
         }
         else if (num2 < decodeLen[7])
         {
             num = 7;
         }
         else
         {
             num = 8;
         }
     }
     else if (num2 < decodeLen[12])
     {
         if (num2 < decodeLen[10])
         {
             if (num2 < decodeLen[9])
             {
                 num = 9;
             }
             else
             {
                 num = 10;
             }
         }
         else if (num2 < decodeLen[11])
         {
             num = 11;
         }
         else
         {
             num = 12;
         }
     }
     else if (num2 < decodeLen[14])
     {
         if (num2 < decodeLen[13])
         {
             num = 13;
         }
         else
         {
             num = 14;
         }
     }
     else
     {
         num = 15;
     }
     input.AddBits(num);
     int index = dec.DecodePos[num] + Utility.URShift((int) (((int) num2) - decodeLen[num - 1]), (int) (0x10 - num));
     if (index >= dec.MaxNum)
     {
         index = 0;
     }
     return dec.DecodeNum[index];
 }
Example #4
0
        internal static void makeDecodeTables(byte[] lenTab, int offset, Decode dec, int size)
        {
            int[] lenCount = new int[16];
            int[] tmpPos = new int[16];
            int i;
            long M, N;

            Utility.Fill(lenCount, 0); // memset(LenCount,0,sizeof(LenCount));

            Utility.Fill(dec.DecodeNum, 0); // memset(Dec->DecodeNum,0,Size*sizeof(*Dec->DecodeNum));

            for (i = 0; i < size; i++)
            {
                lenCount[(int)(lenTab[offset + i] & 0xF)]++;
            }
            lenCount[0] = 0;
            for (tmpPos[0] = 0, dec.DecodePos[0] = 0, dec.DecodeLen[0] = 0, N = 0, i = 1; i < 16; i++)
            {
                N = 2 * (N + lenCount[i]);
                M = N << (15 - i);
                if (M > 0xFFFF)
                {
                    M = 0xFFFF;
                }
                dec.DecodeLen[i] = (int)M;
                tmpPos[i] = dec.DecodePos[i] = dec.DecodePos[i - 1] + lenCount[i - 1];
            }

            for (i = 0; i < size; i++)
            {
                if (lenTab[offset + i] != 0)
                {
                    dec.DecodeNum[tmpPos[lenTab[offset + i] & 0xF]++] = i;
                }
            }
            dec.MaxNum = size;
        }
Example #5
0
 internal static void makeDecodeTables(byte[] lenTab, int offset, Decode dec, int size)
 {
     int num;
     int[] array = new int[0x10];
     int[] numArray2 = new int[0x10];
     Utility.Fill<int>(array, 0);
     Utility.Fill<int>(dec.DecodeNum, 0);
     for (num = 0; num < size; num++)
     {
         array[lenTab[offset + num] & 15]++;
     }
     array[0] = 0;
     numArray2[0] = 0;
     dec.DecodePos[0] = 0;
     dec.DecodeLen[0] = 0;
     long num3 = 0L;
     for (num = 1; num < 0x10; num++)
     {
         num3 = 2L * (num3 + array[num]);
         long num2 = num3 << (15 - num);
         if (num2 > 0xffffL)
         {
             num2 = 0xffffL;
         }
         dec.DecodeLen[num] = (int) num2;
         numArray2[num] = dec.DecodePos[num] = dec.DecodePos[num - 1] + array[num - 1];
     }
     for (num = 0; num < size; num++)
     {
         if (lenTab[offset + num] != 0)
         {
             dec.DecodeNum[numArray2[lenTab[offset + num] & 15]++] = num;
         }
     }
     dec.MaxNum = size;
 }