Beispiel #1
0
    def decode(self, compressed, decompressed=None):
        """perform decompression

        params:
            compressed: bytes - the data to be decompressed
            decompressed: numpy.ndarray - memory to be used to decompress data into
        """
        compressed_lp = None
        decompressed_lp = None
        try:
            compressed_lp = pressio.io_data_from_bytes(compressed)
            decompressed_lp = pressio.io_data_from_numpy(decompressed)

            rc = pressio.compressor_decompress(self._compressor, compressed_lp,
                                               decompressed_lp)
            if rc:
                raise PressioException.from_compressor(self._compressor)

            dec = pressio.io_data_to_numpy(decompressed_lp)

            if decompressed is not None:
                return dec
            else:
                return ndarray_copy(dec, decompressed)
        finally:
            pressio.data_free(compressed_lp)
            pressio.data_free(decompressed_lp)
Beispiel #2
0
    pressio.compressor_set_options(compressor, sz_options)
    pressio.compressor_set_metrics(compressor, metrics)

    input_data = pressio.io_data_from_numpy(floatArray)

    compressed_data = pressio.data_new_empty(pressio.byte_dtype,
                                             pressio.vector_uint64_t())

    dims = pressio.vector_uint64_t([height, width, 3])

    decompressed_data = pressio.data_new_empty(pressio.double_dtype, dims)

    #compress data with selected compressor
    pressio.compressor_compress(compressor, input_data, compressed_data)
    #decompress data with selected compressor
    pressio.compressor_decompress(compressor, compressed_data,
                                  decompressed_data)
    #get metric results for compression
    metric_results = pressio.compressor_get_metrics_results(compressor)

    #Grab relevant compression metrics
    compression_ratio = pressio.new_double()
    compressed_size = pressio.new_uint32()
    uncompressed_size = pressio.new_uint32()
    decompressed_size = pressio.new_uint32()
    pressio.options_get_double(metric_results, b"size:compression_ratio",
                               compression_ratio)
    pressio.options_get_uinteger(metric_results, b"size:compressed_size",
                                 compressed_size)
    pressio.options_get_uinteger(metric_results, b"size:uncompressed_size",
                                 uncompressed_size)
    pressio.options_get_uinteger(metric_results, b"size:decompressed_size",