def decode_extra_length(bits, length):
    """Decode extra bits for a match length symbol."""
    if length == 285:
        return 258
    extra = (length - 257) / 4 - 1
    length = length - 254
    if extra > 0:
        ebits = bits.read(extra)
        length = 2**(extra+2) + 3 + (((length + 1) % 4) * (2**extra)) + ebits
    return length