def read_rle(file_obj, header, bit_width, debug_logging):
 count = (header >> 1)
 zero_data = '\x00\x00\x00\x00'
 width = ((bit_width + 7) // 8)
 data = file_obj.read(width)
 data = (data + zero_data[len(data):])
 value = struct.unpack('<i', data)[0]
 if debug_logging:
  logger.debug(u'Read RLE group with value %s of byte-width %s and count %s', value, width, count)
 for _ in range(count):
  (yield value)

def read_rle ( file_obj , header , bit_width , debug_logging ) : count = ( header >> 1 ) zero_data = '\x00\x00\x00\x00' width = ( ( bit_width + 7 ) // 8 ) data = file_obj . read ( width ) data = ( data + zero_data [ len ( data ) : ] ) value = struct . unpack ( '<i' , data ) [ 0 ] if debug_logging : logger . debug ( u'Read RLE group with value %s of byte-width %s and count %s' , value , width , count ) for _ in range ( count ) : ( yield value )
read a run-length encoded run from the given fo with the given header and bit_width .