def get_bits need
    val = @bit_bucket
    while @bit_count < need
      val |= (@input_buffer[@in_pos+=1] << @bit_count)
      @bit_count += 8
    end

    @bit_bucket = val >> need
    @bit_count -= need
    val & ((1 << need) - 1)
  end
def get_bits need
    val = @bit_bucket
    while @bit_count < need
      val |= (@input_buffer[@in_pos+=1] << @bit_count)
      @bit_count += 8
    end

    @bit_bucket = val >> need
    @bit_count -= need
    val & ((1 << need) - 1)
  end
returns need bits from the input buffer
 == Format Notes
 bits are stored LSB to MSB