Ported python interface to new coding style
This commit is contained in:
parent
9aabc7b4f3
commit
695d518f76
1 changed files with 106 additions and 111 deletions
|
@ -1,9 +1,9 @@
|
||||||
#/=====================================================================================================================\#
|
#*================================================================================================*#
|
||||||
#| |#
|
#| |#
|
||||||
#| /$$$$$$$ /$$ /$$ /$$ /$$ |#
|
#| /$$$$$$$ /$$ /$$ /$$ /$$ |#
|
||||||
#| | $$__ $$|__/ | $$ /$ | $$| $$ |#
|
#| | $$__ $$|__/ | $$ /$ | $$| $$ |#
|
||||||
#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |#
|
#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |#
|
||||||
#! | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |#
|
#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |#
|
||||||
#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |#
|
#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |#
|
||||||
#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |#
|
#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |#
|
||||||
#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |#
|
#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |#
|
||||||
|
@ -15,65 +15,38 @@
|
||||||
#| DESCRIPTION: |#
|
#| DESCRIPTION: |#
|
||||||
#| ------------ |#
|
#| ------------ |#
|
||||||
#| |#
|
#| |#
|
||||||
#| This file defines a Python interface for the Big Whoop compression library |#
|
#| This file defines a Python interface for the Big Whoop compression library. |#
|
||||||
#| |#
|
|
||||||
#| FUNCTIONS: |#
|
|
||||||
#| ---------- |#
|
|
||||||
#| - bwc_free_field |#
|
|
||||||
#| - bwc_add_param |#
|
|
||||||
#| - bwc_set_tiles |#
|
|
||||||
#| - bwc_set_kernels |#
|
|
||||||
#| - bwc_set_decomp |#
|
|
||||||
#| - bwc_set_precincts |#
|
|
||||||
#| - bwc_set_codeblocks |#
|
|
||||||
#| - bwc_set_progression |#
|
|
||||||
#| - bwc_set_error_resilience |#
|
|
||||||
#| - bwc_set_quantization_style |#
|
|
||||||
#| - bwc_set_qm |#
|
|
||||||
#| - bwc_set_quantization_step_size |#
|
|
||||||
#| - bwc_set_memory_limit |#
|
|
||||||
#| - bwc_compress |#
|
|
||||||
#| - bwc_decompress |#
|
|
||||||
#| |#
|
|
||||||
#| |#
|
|
||||||
#| DEVELOPMENT HISTORY: |#
|
|
||||||
#| -------------------- |#
|
|
||||||
#| |#
|
|
||||||
#| Date Author Change Id Release Description |#
|
|
||||||
#| ---- ------ --------- ------- ----------- |#
|
|
||||||
#| 17.03.2021 Patrick Vogler B87D120 V 0.1.0 Python Module created |#
|
|
||||||
#| |#
|
|
||||||
#| |#
|
|
||||||
#| ------------------------------------------------------------------------------------------------------ |#
|
|
||||||
#| |#
|
#| |#
|
||||||
|
#| -------------------------------------------------------------------------------------------- |#
|
||||||
#| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart |#
|
#| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart |#
|
||||||
#| |#
|
#| |#
|
||||||
#| Redistribution and use in source and binary forms, with or without modification, are permitted |#
|
#| Redistribution and use in source and binary forms, with or without modification, are |#
|
||||||
#| provided that the following conditions are met: |#
|
#| permitted provided that the following conditions are met: |#
|
||||||
#| |#
|
#| |#
|
||||||
#| (1) Redistributions of source code must retain the above copyright notice, this list of |#
|
#| (1) Redistributions of source code must retain the above copyright notice, this list of |#
|
||||||
#| conditions and the following disclaimer. |#
|
#| conditions and the following disclaimer. |#
|
||||||
#| |#
|
#| |#
|
||||||
#| (2) Redistributions in binary form must reproduce the above copyright notice, this list |#
|
#| (2) Redistributions in binary form must reproduce the above copyright notice, this list |#
|
||||||
#| of conditions and the following disclaimer in the documentation and/or other materials |#
|
#| of conditions and the following disclaimer in the documentation and/or other |#
|
||||||
#| provided with the distribution. |#
|
#| materials provided with the distribution. |#
|
||||||
#| |#
|
#| |#
|
||||||
#| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |#
|
#| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS |#
|
||||||
#| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |#
|
#| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |#
|
||||||
#| PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |#
|
#| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |#
|
||||||
#| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |#
|
#| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |#
|
||||||
#| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |#
|
#| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |#
|
||||||
#| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |#
|
#| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |#
|
||||||
#| TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |#
|
#| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |#
|
||||||
#| ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |#
|
#| TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |#
|
||||||
|
#| EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |#
|
||||||
#| |#
|
#| |#
|
||||||
#\=====================================================================================================================/#
|
#*================================================================================================*#
|
||||||
#/=====================================================================================================================\#
|
#**************************************************************************************************#
|
||||||
#| _ _ _ ____ _ _ _ ___ ____ |#
|
#| _ _ _ ____ _ _ _ ___ ____ |#
|
||||||
#| | |\ | | | | | | \ |___ |#
|
#| | |\ | | | | | | \ |___ |#
|
||||||
#| | | \| |___ |___ |__| |__/ |___ |#
|
#| | | \| |___ |___ |__| |__/ |___ |#
|
||||||
#| |#
|
#| |#
|
||||||
#\=====================================================================================================================/#
|
#**************************************************************************************************#
|
||||||
import ctypes
|
import ctypes
|
||||||
|
|
||||||
from numpy.ctypeslib import ndpointer
|
from numpy.ctypeslib import ndpointer
|
||||||
|
@ -81,12 +54,12 @@ from enum import Enum
|
||||||
|
|
||||||
libbwc = ctypes.cdll.LoadLibrary("../../../lib/libbwc.so")
|
libbwc = ctypes.cdll.LoadLibrary("../../../lib/libbwc.so")
|
||||||
|
|
||||||
#/=====================================================================================================================\#
|
#**************************************************************************************************#
|
||||||
#| ____ ____ _ _ ____ ___ ____ _ _ ___ ____ |#
|
#| ____ ____ _ _ ____ ___ ____ _ _ ___ ____ |#
|
||||||
#| | | | |\ | [__ | |__| |\ | | [__ |#
|
#| | | | |\ | [__ | |__| |\ | | [__ |#
|
||||||
#| |___ |__| | \| ___] | | | | \| | ___] |#
|
#| |___ |__| | \| ___] | | | | \| | ___] |#
|
||||||
#| |#
|
#| |#
|
||||||
#\=====================================================================================================================/#
|
#**************************************************************************************************#
|
||||||
class _const():
|
class _const():
|
||||||
class DWT(Enum):
|
class DWT(Enum):
|
||||||
CDF_9_7 = 0
|
CDF_9_7 = 0
|
||||||
|
@ -105,18 +78,18 @@ class _const():
|
||||||
NUMBOF = 1
|
NUMBOF = 1
|
||||||
const = _const()
|
const = _const()
|
||||||
|
|
||||||
#/=====================================================================================================================\#
|
#**************************************************************************************************#
|
||||||
#| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ |#
|
#| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ |#
|
||||||
#| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ |#
|
#| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ |#
|
||||||
#| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] |#
|
#| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] |#
|
||||||
#| |#
|
#| |#
|
||||||
#\=====================================================================================================================/#
|
#**************************************************************************************************#
|
||||||
def free_data(data):
|
def free_data(data):
|
||||||
fun = libbwc.bwc_free_data
|
fun = libbwc.bwc_free_data
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p]
|
fun.argtypes = [ctypes.c_void_p]
|
||||||
fun(data)
|
fun(data)
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def initialize_data(data, nX, nY, nZ, nTS, nPar, file_extension):
|
def initialize_data(data, nX, nY, nZ, nTS, nPar, file_extension):
|
||||||
fun = libbwc.bwc_initialize_data
|
fun = libbwc.bwc_initialize_data
|
||||||
fun.restype = ctypes.c_void_p
|
fun.restype = ctypes.c_void_p
|
||||||
|
@ -128,7 +101,7 @@ def initialize_data(data, nX, nY, nZ, nTS, nPar, file_extension):
|
||||||
ctypes.c_uint8,
|
ctypes.c_uint8,
|
||||||
ctypes.c_char_p]
|
ctypes.c_char_p]
|
||||||
return ctypes.c_void_p(fun(data, nX, nY, nZ, nTS, nPar, file_extension.encode('utf-8')))
|
return ctypes.c_void_p(fun(data, nX, nY, nZ, nTS, nPar, file_extension.encode('utf-8')))
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def get_data(data, buffer, size):
|
def get_data(data, buffer, size):
|
||||||
fun = libbwc.bwc_get_data
|
fun = libbwc.bwc_get_data
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
|
@ -136,7 +109,7 @@ def get_data(data, buffer, size):
|
||||||
ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
|
ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
|
||||||
ctypes.c_uint64]
|
ctypes.c_uint64]
|
||||||
fun(data, buffer, size)
|
fun(data, buffer, size)
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def add_param(data, name, sample, dim, precision):
|
def add_param(data, name, sample, dim, precision):
|
||||||
fun = libbwc.bwc_add_param
|
fun = libbwc.bwc_add_param
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
|
@ -146,69 +119,91 @@ def add_param(data, name, sample, dim, precision):
|
||||||
ctypes.c_uint8,
|
ctypes.c_uint8,
|
||||||
ctypes.c_uint8]
|
ctypes.c_uint8]
|
||||||
fun(data, name.encode('utf-8'), sample, dim, precision)
|
fun(data, name.encode('utf-8'), sample, dim, precision)
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def kill_compression(field):
|
def kill_compression(field):
|
||||||
fun = libbwc.bwc_kill_compression
|
fun = libbwc.bwc_kill_compression
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p]
|
fun.argtypes = [ctypes.c_void_p]
|
||||||
fun(field)
|
fun(field)
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def initialize_field(data):
|
def initialize_field(data):
|
||||||
fun = libbwc.bwc_initialize_field
|
fun = libbwc.bwc_initialize_field
|
||||||
fun.restype = ctypes.c_void_p
|
fun.restype = ctypes.c_void_p
|
||||||
fun.argtypes = [ctypes.c_void_p]
|
fun.argtypes = [ctypes.c_void_p]
|
||||||
return ctypes.c_void_p(fun(data))
|
return ctypes.c_void_p(fun(data))
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def set_codeblocks(field, cbX, cbY, cbZ, cbTS):
|
def set_codeblocks(field, cbX, cbY, cbZ, cbTS):
|
||||||
fun = libbwc.bwc_set_codeblocks
|
fun = libbwc.bwc_set_codeblocks
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8]
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
ctypes.c_uint8,
|
||||||
|
ctypes.c_uint8,
|
||||||
|
ctypes.c_uint8,
|
||||||
|
ctypes.c_uint8]
|
||||||
fun(field, cbX, cbY, cbZ, cbTS)
|
fun(field, cbX, cbY, cbZ, cbTS)
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def set_decomp(field, decompX, decompY, decompZ, decompTS):
|
def set_decomp(field, decompX, decompY, decompZ, decompTS):
|
||||||
fun = libbwc.bwc_set_decomp
|
fun = libbwc.bwc_set_decomp
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8]
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
ctypes.c_uint8,
|
||||||
|
ctypes.c_uint8,
|
||||||
|
ctypes.c_uint8,
|
||||||
|
ctypes.c_uint8]
|
||||||
fun(field, decompX, decompY, decompZ, decompTS)
|
fun(field, decompX, decompY, decompZ, decompTS)
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def set_qm(field, Qm):
|
def set_qm(field, Qm):
|
||||||
fun = libbwc.bwc_set_qm
|
fun = libbwc.bwc_set_qm
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p, ctypes.c_int8]
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
ctypes.c_int8]
|
||||||
fun(field, Qm)
|
fun(field, Qm)
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def set_tiles(field, tilesX, tilesY, tilesZ, tilesTS, instr):
|
def set_tiles(field, tilesX, tilesY, tilesZ, tilesTS, instr):
|
||||||
fun = libbwc.bwc_set_tiles
|
fun = libbwc.bwc_set_tiles
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_char_p]
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
ctypes.c_uint64,
|
||||||
|
ctypes.c_uint64,
|
||||||
|
ctypes.c_uint64,
|
||||||
|
ctypes.c_uint64,
|
||||||
|
ctypes.c_char_p]
|
||||||
fun(field, tilesX, tilesY, tilesZ, tilesTS, instr.encode('utf-8'))
|
fun(field, tilesX, tilesY, tilesZ, tilesTS, instr.encode('utf-8'))
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def set_precincts(field, pX, pY, pZ, pTS):
|
def set_precincts(field, pX, pY, pZ, pTS):
|
||||||
fun = libbwc.bwc_set_precincts
|
fun = libbwc.bwc_set_precincts
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8]
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
ctypes.c_uint8,
|
||||||
|
ctypes.c_uint8,
|
||||||
|
ctypes.c_uint8,
|
||||||
|
ctypes.c_uint8]
|
||||||
fun(field, pX, pY, pZ, pTS)
|
fun(field, pX, pY, pZ, pTS)
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def create_compression(field, rate_control):
|
def create_compression(field, rate_control):
|
||||||
fun = libbwc.bwc_create_compression
|
fun = libbwc.bwc_create_compression
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p, ctypes.c_char_p]
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
ctypes.c_char_p]
|
||||||
fun(field, rate_control.encode('utf-8'))
|
fun(field, rate_control.encode('utf-8'))
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def compress(field, data):
|
def compress(field, data):
|
||||||
fun = libbwc.bwc_compress
|
fun = libbwc.bwc_compress
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
ctypes.c_void_p]
|
||||||
fun(field, data)
|
fun(field, data)
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def create_decompression(field, data):
|
def create_decompression(field, data):
|
||||||
fun = libbwc.bwc_create_decompression
|
fun = libbwc.bwc_create_decompression
|
||||||
fun.restype = ctypes.c_void_p
|
fun.restype = ctypes.c_void_p
|
||||||
fun.argtypes = [ctypes.c_void_p, ctypes.c_uint8]
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
ctypes.c_uint8]
|
||||||
return ctypes.c_void_p(fun(field, data))
|
return ctypes.c_void_p(fun(field, data))
|
||||||
#=======================================================================================================================#
|
#==================================================================================================#
|
||||||
def decompress(field, data):
|
def decompress(field, data):
|
||||||
fun = libbwc.bwc_decompress
|
fun = libbwc.bwc_decompress
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
ctypes.c_void_p]
|
||||||
fun(field, data)
|
fun(field, data)
|
Loading…
Reference in a new issue