research/brotlidump.py
def value(self, dcode, dextra):
        """Decode value of symbol together with the extra bits.
        >>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
        >>> d[34].value(2)
        (0, 35)
        """
        if dcode<16:
            return [(1,0),(2,0),(3,0),(4,0),
                    (1,-1),(1,+1),(1,-2),(1,+2),(1,-3),(1,+3),
                    (2,-1),(2,+1),(2,-2),(2,+2),(2,-3),(2,+3)
                ][dcode]
        if dcode<16+self.NDIRECT:
            return (0,dcode-16)
        #we use the original formulas, instead of my clear explanation
        POSTFIX_MASK = (1 << self.NPOSTFIX) - 1
        ndistbits = 1 + ((dcode - self.NDIRECT - 16) >> (self.NPOSTFIX + 1))
        hcode = (dcode - self.NDIRECT - 16) >> self.NPOSTFIX
        lcode = (dcode - self.NDIRECT - 16) & POSTFIX_MASK
        offset = ((2 + (hcode & 1)) << ndistbits) - 4
        distance = ((offset + dextra) << self.NPOSTFIX) + lcode + self.NDIRECT + 1
        return (0,distance)
def value(self, dcode, dextra):
        """Decode value of symbol together with the extra bits.
        >>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
        >>> d[34].value(2)
        (0, 35)
        """
        if dcode<16:
            return [(1,0),(2,0),(3,0),(4,0),
                    (1,-1),(1,+1),(1,-2),(1,+2),(1,-3),(1,+3),
                    (2,-1),(2,+1),(2,-2),(2,+2),(2,-3),(2,+3)
                ][dcode]
        if dcode<16+self.NDIRECT:
            return (0,dcode-16)
        #we use the original formulas, instead of my clear explanation
        POSTFIX_MASK = (1 << self.NPOSTFIX) - 1
        ndistbits = 1 + ((dcode - self.NDIRECT - 16) >> (self.NPOSTFIX + 1))
        hcode = (dcode - self.NDIRECT - 16) >> self.NPOSTFIX
        lcode = (dcode - self.NDIRECT - 16) & POSTFIX_MASK
        offset = ((2 + (hcode & 1)) << ndistbits) - 4
        distance = ((offset + dextra) << self.NPOSTFIX) + lcode + self.NDIRECT + 1
        return (0,distance)
def value ( self , dcode , dextra ) : if dcode < 16 : return [ ( 1 , 0 ) , ( 2 , 0 ) , ( 3 , 0 ) , ( 4 , 0 ) , ( 1 , - 1 ) , ( 1 , + 1 ) , ( 1 , - 2 ) , ( 1 , + 2 ) , ( 1 , - 3 ) , ( 1 , + 3 ) , ( 2 , - 1 ) , ( 2 , + 1 ) , ( 2 , - 2 ) , ( 2 , + 2 ) , ( 2 , - 3 ) , ( 2 , + 3 ) ] [ dcode ] if dcode < 16 + self . NDIRECT : return ( 0 , dcode - 16 ) #we use the original formulas, instead of my clear explanation POSTFIX_MASK = ( 1 << self . NPOSTFIX ) - 1 ndistbits = 1 + ( ( dcode - self . NDIRECT - 16 ) >> ( self . NPOSTFIX + 1 ) ) hcode = ( dcode - self . NDIRECT - 16 ) >> self . NPOSTFIX lcode = ( dcode - self . NDIRECT - 16 ) & POSTFIX_MASK offset = ( ( 2 + ( hcode & 1 ) ) << ndistbits ) - 4 distance = ( ( offset + dextra ) << self . NPOSTFIX ) + lcode + self . NDIRECT + 1 return ( 0 , distance )
Decode value of symbol together with the extra bits.
        >>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
        >>> d[34].value(2)
        (0, 35)
Decode value of symbol together with the extra bits . >>> d = DistanceAlphabet ( D NPOSTFIX = 2 NDIRECT = 10 ) >>> d [ 34 ] . value ( 2 ) ( 0 35 )