Esempio n. 1
0
        public DecodeIntResult decodeInt(long[,] table)
        {
            int length = 0, prefix = 0;

            for (int i = 0; table[i, 2] != jbig2HuffmanEOT; i++)
            {
                for (; length < table[i, 1]; length++)
                {
                    int bit = reader.readBit();
                    prefix = (prefix << 1) | bit;
                }

                if (prefix == table[i, 3])
                {
                    if (table[i, 2] == jbig2HuffmanOOB)
                    {
                        return(new DecodeIntResult(-1, false));
                    }
                    long decodedInt;
                    if (table[i, 2] == jbig2HuffmanLOW)
                    {
                        int readBits = reader.readBits(32);
                        decodedInt = table[i, 0] - readBits;
                    }
                    else if (table[i, 2] > 0)
                    {
                        int readBits = reader.readBits(table[i, 2]);
                        decodedInt = table[i, 0] + readBits;
                    }
                    else
                    {
                        decodedInt = table[i, 0];
                    }
                    return(new DecodeIntResult(decodedInt, true));
                }
            }

            return(new DecodeIntResult(-1, false));
        }
 public int readBits(long num)
 {
     return(reader.readBits(num));
 }