code: def read_bitpacked(file_obj, header, width, debug_logging):
      
      num_groups = header >> 1
      count = num_groups * 8
      byte_count = (width * count) // 8
      if debug_logging:
          logger.debug("Reading a bit-packed run with: %s groups, count %s, bytes %s",
                       num_groups, count, byte_count)
      if width == 0:
          return [0 for _ in range(count)]
      raw_bytes = array.array(ARRAY_BYTE_STR, file_obj.read(byte_count)).tolist()
      current_byte = 0
      data = raw_bytes[current_byte]
      mask = _mask_for_bits(width)
      bits_wnd_l = 8
      bits_wnd_r = 0
      res = []
      total = len(raw_bytes) * 8
      while total >= width:
          # NOTE zero-padding could produce extra zero-values
          if debug_logging:
              logger.debug("  read bitpacked: width=%s window=(%s %s) b=%s,"
                           " current_byte=%s",
                           width, bits_wnd_l, bits_wnd_r, bin(data), current_byte)
          if bits_wnd_r >= 8:
              bits_wnd_r -= 8
              bits_wnd_l -= 8
              data >>= 8
          elif bits_wnd_l - bits_wnd_r >= width:
              res.append((data >> bits_wnd_r) & mask)
              total -= width
              bits_wnd_r += width
              if debug_logging:
                  logger.debug("  read bitpackage: added: %s", res[-1])
          elif current_byte + 1 < len(raw_bytes):
              current_byte += 1
              data |= (raw_bytes[current_byte] << bits_wnd_l)
              bits_wnd_l += 8
      return res
docs: Read a bitpacked run of the rle/bitpack hybrid.
  
      Supports width >8 (crossing bytes).