Ejemplo n.º 1
0
    def extract_chunk(self, index):
        data_stream = self._data_stream

        chunk_size = self.sizeof(index)
        self._seek(index)
        chunk = stream_read(data_stream, chunk_size)
        return chunk
Ejemplo n.º 2
0
    def extract_chunk(self, index):
        self._log_extract_chunk(index)
        data_stream = self._data_stream

        chunk_size = self.sizeof(index)
        self._seek(index)
        chunk = stream_read(data_stream, chunk_size)
        return chunk
Ejemplo n.º 3
0
    def extract_chunk(self, index):
        chunk_count = self._chunk_count
        data_stream = self._data_stream
        huffman_nodes = self._huffman_nodes
        index = sequence_index(index, chunk_count)

        chunk = b''
        chunk_size = self.sizeof(index)
        if chunk_size:
            self._seek(index)
            compressed_size, expanded_size = self._read_sizes(index)
            chunk = stream_read(data_stream, compressed_size)
            chunk = huffman_expand(chunk, expanded_size, huffman_nodes)
        return chunk
Ejemplo n.º 4
0
    def extract_chunk(self, index):
        self._log_extract_chunk(index)
        chunk_count = self._chunk_count
        data_stream = self._data_stream
        huffman_nodes = self._huffman_nodes
        index = sequence_index(index, chunk_count)

        chunk = b''
        chunk_size = self.sizeof(index)
        if chunk_size:
            self._seek(index)
            compressed_size, expanded_size = self._read_sizes(index)
            chunk = stream_read(data_stream, compressed_size)
            chunk = huffman_expand(chunk, expanded_size, huffman_nodes)
        return chunk
Ejemplo n.º 5
0
    def extract_chunk(self, index):
        data_stream = self._data_stream
        carmacized = self._carmacized
        rlew_tag = self._rlew_tag
        planes_count = self.planes_count

        header = None
        planes = [None] * planes_count
        chunk_size = self.sizeof(index)
        if chunk_size:
            self._seek(index)
            header = TileMapHeader.from_stream(data_stream, planes_count)

            for i in range(planes_count):
                self._seek(i, header.plane_offsets)
                expanded_size = stream_unpack('<H', data_stream)[0]
                compressed_size = header.plane_sizes[i] - 2
                chunk = stream_read(data_stream, compressed_size)
                if carmacized:
                    chunk = carmack_expand(chunk, expanded_size)[2:]
                planes[i] = rlew_expand(chunk, rlew_tag)
        return (header, planes)
Ejemplo n.º 6
0
    def extract_chunk(self, index):
        self._log_extract_chunk(index)
        data_stream = self._data_stream
        carmacized = self._carmacized
        rlew_tag = self._rlew_tag
        planes_count = self.planes_count

        header = None
        planes = [None] * planes_count
        chunk_size = self.sizeof(index)
        if chunk_size:
            self._seek(index)
            header = TileMapHeader.from_stream(data_stream, planes_count)

            for i in range(planes_count):
                self._seek(i, header.plane_offsets)
                expanded_size = stream_unpack('<H', data_stream)[0]
                compressed_size = header.plane_sizes[i] - struct.calcsize('<H')
                chunk = stream_read(data_stream, compressed_size)
                if carmacized:
                    chunk = carmack_expand(chunk, expanded_size)[struct.calcsize('<H'):]
                planes[i] = rlew_expand(chunk, rlew_tag)
        return (header, planes)
Ejemplo n.º 7
0
 def from_stream(cls, stream):
     header = AdLibSoundHeader.from_stream(stream)
     events = stream_read(stream, header.length)
     return cls(header, events)