Initial commit

This commit is contained in:
Patrick Vogler 2024-03-05 14:56:22 +01:00
commit 41ecc696ca
Signed by: Patrick Vogler
GPG key ID: 5536B08CE82E8509
42 changed files with 27087 additions and 0 deletions

201
1-bwc/CMakeLists.txt Executable file
View file

@ -0,0 +1,201 @@
#*================================================================================================*#
#| |#
#| /$$$$$$$ /$$ /$$ /$$ /$$ |#
#| | $$__ $$|__/ | $$ /$ | $$| $$ |#
#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |#
#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |#
#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |#
#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |#
#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |#
#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |#
#| /$$ \ $$ | $$ |#
#| | $$$$$$/ | $$ |#
#| \______/ |__/ |#
#| |#
#| DESCRIPTION: |#
#| ------------ |#
#| |#
#| Defines the global cmake script for the Big Whoop compression algorithm. |#
#| |#
#| -------------------------------------------------------------------------------------------- |#
#| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart |#
#| |#
#| Redistribution and use in source and binary forms, with or without modification, are |#
#| permitted provided that the following conditions are met: |#
#| |#
#| (1) Redistributions of source code must retain the above copyright notice, this list of |#
#| conditions and the following disclaimer. |#
#| |#
#| (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 provided with the distribution. |#
#| |#
#| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS |#
#| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |#
#| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |#
#| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |#
#| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |#
#| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |#
#| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |#
#| 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. |#
#| |#
#*================================================================================================*#
#----------------------------------------------------------#
# Check if the version requirement for cmake is met. #
#----------------------------------------------------------#
cmake_minimum_required(VERSION 3.5.1)
#----------------------------------------------------------#
# Set the project name and description. #
#----------------------------------------------------------#
project(BWC LANGUAGES C)
set(PROJECT_DESCRIPTION "Compression algorithm for IEEE 754 datasets")
#----------------------------------------------------------#
# Check that the current build is not a in-source build. #
#----------------------------------------------------------#
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
message(FATAL_ERROR "In-source builds are prohibited. Please create a separate build directory")
endif()
#----------------------------------------------------------#
# Save the bwc.c file in a temporary variable and match #
# the current version number with a regular expression. #
#----------------------------------------------------------#
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/src/library/libbwc.c _bwc_c_contents)
string(REGEX MATCH "V[ \t]+([0-9]+).([0-9]+).([0-9]+)" _ ${ver} ${_bwc_c_contents})
set(BWC_VERSION_MAJOR ${CMAKE_MATCH_1})
set(BWC_VERSION_MINOR ${CMAKE_MATCH_2})
set(BWC_VERSION_PATCH ${CMAKE_MATCH_3})
set(BWC_VERSION "${BWC_VERSION_MAJOR}.${BWC_VERSION_MINOR}.${BWC_VERSION_PATCH}")
#----------------------------------------------------------#
# Setup a user-specified option used to control the sample #
# precision during compression. The standard option is #
# set to double precision. #
#----------------------------------------------------------#
set(PREC "Double" CACHE STRING "User-specified option used to control\
the precision during compression")
#----------------------------------------------------------#
# Inlude the GNU standard installation directories module #
# to set up the output directories. #
#----------------------------------------------------------#
include(GNUInstallDirs)
#----------------------------------------------------------#
# Set up the output directories for the Big Whoop library #
# and utility binaries. #
#----------------------------------------------------------#
list(INSERT CMAKE_MODULE_PATH 0 "${BWC_SOURCE_DIR}/cmake")
if(${TOOL})
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BWC_SOURCE_DIR}/${CMAKE_INSTALL_BINDIR})
endif()
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BWC_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR})
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BWC_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR})
endif()
#----------------------------------------------------------#
# Set the target installation directory of the config-file #
# packaging configuration files. #
#----------------------------------------------------------#
set(CMAKE_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/bwc
CACHE PATH "Installation directory for config-file package cmake files")
#----------------------------------------------------------#
# Suggest the C standard (C99) used by the compiler. #
#----------------------------------------------------------#
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 11)
endif()
message(STATUS "Compiling with C standard: ${CMAKE_C_STANDARD}")
#----------------------------------------------------------#
# Suggest the C++ standard (CXX98) used by the compiler. #
#----------------------------------------------------------#
# Suggest C++98
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
message(STATUS "Compiling with C++ standard: ${CMAKE_CXX_STANDARD}")
#----------------------------------------------------------#
# Check if the OpenMP package is available for the current #
# setup and set the appropriate C/C++ flags. #
#----------------------------------------------------------#
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
endif()
#----------------------------------------------------------#
# Add all necessary compiler warnings for debugging. #
#----------------------------------------------------------#
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
endif()
#----------------------------------------------------------#
# Include the CMake dependent option macro. #
#----------------------------------------------------------#
include(CMakeDependentOption)
#----------------------------------------------------------#
# Set the -fPIC compile option for static libraries. #
#----------------------------------------------------------#
get_property(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
cmake_dependent_option(BUILD_SHARED_LIBS
"Whether or not to build shared libraries" ON
"SHARED_LIBS_SUPPORTED" OFF)
if(SHARED_LIBS_SUPPORTED)
cmake_dependent_option(BWC_ENABLE_PIC
"Build with Position Independent Code" ON
"NOT BUILD_SHARED_LIBS" ON)
endif()
if(BWC_ENABLE_PIC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
#----------------------------------------------------------#
# Add the project source code. #
#----------------------------------------------------------#
add_subdirectory(src/library)
#----------------------------------------------------------#
# Add the utilities source code if requested. #
#----------------------------------------------------------#
if(${TOOL})
add_subdirectory(src/tools)
endif()
#----------------------------------------------------------#
# Config-file packaging #
#----------------------------------------------------------#
export(TARGETS bwclib NAMESPACE bwc:: FILE "bwc-targets.cmake")
configure_file(${PROJECT_SOURCE_DIR}/bwc-config.cmake.in
"${PROJECT_BINARY_DIR}/bwc-config.cmake" @ONLY)
configure_file(${PROJECT_SOURCE_DIR}/bwc-config-version.cmake.in
"${PROJECT_BINARY_DIR}/bwc-config-version.cmake" @ONLY)
install( FILES "${PROJECT_BINARY_DIR}/bwc-config.cmake"
"${PROJECT_BINARY_DIR}/bwc-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_CMAKEDIR})
install( EXPORT bwc-targets
NAMESPACE bwc::
DESTINATION ${CMAKE_INSTALL_CMAKEDIR})

9
1-bwc/LICENSE Normal file
View file

@ -0,0 +1,9 @@
Copyright (c) 2023, High Performance Computing Center - University of Stuttgart
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
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 provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 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.

198
1-bwc/Makefile Executable file
View file

@ -0,0 +1,198 @@
#*====================================================================================================================*#
#| |#
#| /$$$$$$$ /$$ /$$ /$$ /$$ |#
#| | $$__ $$|__/ | $$ /$ | $$| $$ |#
#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |#
#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |#
#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |#
#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |#
#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |#
#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |#
#| /$$ \ $$ | $$ |#
#| | $$$$$$/ | $$ |#
#| \______/ |__/ |#
#| |#
#| |#
#| Version 0.1.0 |#
#| |#
#| DESCRIPTION: |#
#| ------------ |#
#| Defines a wrapper for the Big Whoop cmake & make tools. This Makefile creates the |#
#| build dir if it does not exist, switches to it and executes cmake and make. |#
#| |#
#| ---------------------------------------------------------------------------------------------------------------- |#
#| |#
#| Copyright (c) 2021, High Performance Computing Center - University of Stuttgart |#
#| |#
#| Redistribution and use in source and binary forms, with or without modification, are permitted provided that the |#
#| following conditions are met: |#
#| |#
#| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the |#
#| following disclaimer. |#
#| |#
#| (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 provided with the distribution. |#
#| |#
#| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED |#
#| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |#
#| PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |#
#| DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |#
#| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |#
#| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 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. |#
#| |#
#*====================================================================================================================*#
#*--------------------------------------------------------*#
# Define special targets for the required build commands. #
#*--------------------------------------------------------*#
.PHONY: clean
.PHONY: help
.PHONY: static
.PHONY: single
.PHONY: tool
.PHONY: eas3
.PHONY: netCDF
.PHONY: --build_debug
.PHONY: default
.PHONY: debug
.PHONY: full
#*--------------------------------------------------------*#
# Initialize the compiler flags used to build the library. #
#*--------------------------------------------------------*#
BUILD_TYPE="Release"
LINK_TYPE="Dynamic"
BUILD_PREC="Double"
BUILD_TOOL="False"
BUILD_EAS3="False"
BUILD_NETCDF="False"
#*--------------------------------------------------------*#
# Define default target. #
#*--------------------------------------------------------*#
default: | build_bwc display
#*--------------------------------------------------------*#
# Define helper target. #
#*--------------------------------------------------------*#
help:
@echo "Usage: make [options] [argument] Compile the BigWhoop library using the specified"
@echo " [options] and [argument]. Only one argument is "
@echo " accepted per compile run."
@echo ""
@echo "Arguments:"
@echo ""
@echo " [Type] [Description]"
@echo ""
@echo " debug Compiles BigWhoop and the command line tool with "
@echo " full file support. All relevant debug flags are set."
@echo ""
@echo " full Compiles BigWhoop (with OpenMP enabled if applica-"
@echo " ble) and the command line tool with full file sup-"
@echo " port. Code optimization is set to the highest level."
@echo ""
@echo " clean Removes all files and folders created during a pre-"
@echo " vious compile run."
@echo ""
@echo "Options:"
@echo ""
@echo " [Type] [Description]"
@echo ""
@echo " static Builds BigWhoop as a static library."
@echo ""
@echo " single Compiles the BigWhoop library in single precision"
@echo " mode."
@echo ""
@echo " tool Build the command line tool."
@echo ""
@echo " eas3 Adds support for the eas3 file format to the com-"
@echo " mand line tool."
@echo ""
@echo " netCDF Adds support for the eas3 file format to the com-"
@echo " mand line tool."
#*--------------------------------------------------------*#
# Define private targets. #
#*--------------------------------------------------------*#
--build_debug:
$(eval BUILD_TYPE="Debug")
#*--------------------------------------------------------*#
# Define targets used to instrument library properites. #
#*--------------------------------------------------------*#
static:
$(eval LINK_TYPE="Static")
single:
$(eval BUILD_PREC="Single")
#*--------------------------------------------------------*#
# Define target used to activate command line tool build. #
#*--------------------------------------------------------*#
tool:
$(eval BUILD_TOOL="True")
#*--------------------------------------------------------*#
# Define targets used to activate file format support. #
#*--------------------------------------------------------*#
eas3:
$(eval BUILD_EAS3="True")
netCDF:
$(eval BUILD_NETCDF="True")
#*--------------------------------------------------------*#
# Define the wrappers for the compile command targets. #
#*--------------------------------------------------------*#
debug: | clean --build_debug tool eas3 build_bwc display
release: | build_bwc display
full: | clean tool eas3 build_bwc display
#*--------------------------------------------------------*#
# Define target used to output compile information. #
#*--------------------------------------------------------*#
display:
@echo "=============================================================="
@echo ""
@echo " .:-------------: .:-------------: "
@echo " .+++++++++++++++= :+++++++++++++++- "
@echo " :+++. -++= -++= "
@echo " :+++. -++= -++= "
@echo " -++++++++++++++= -++= -++= "
@echo " .=++---------=++= -++= -++= "
@echo " :+++ :++= -++= -++= "
@echo " .+++=--------=+++---=+++---=+++------------: "
@echo " -=++++++++++++++++++++++++++++++++++++++++- "
@echo ""
@echo "----------------- Successfully Compiled -----------------"
@echo ""
@echo " Build Type: $(BUILD_TYPE)"
@echo " Link Type: $(LINK_TYPE)"
@echo " Precision: $(BUILD_PREC)"
@echo " Utilities: $(BUILD_TOOL)"
@echo ""
@echo " Build date: $(shell date)"
@echo " User: $(USER)"
@echo ""
@echo "=============================================================="
#*--------------------------------------------------------*#
# Define the main compile command targets. #
#*--------------------------------------------------------*#
build_bwc:
mkdir -p build && cd build && cmake .. "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" "-DLINK:STRING=${LINK_TYPE}" "-DPREC:STRING=${BUILD_PREC}" "-DTOOL=${BUILD_TOOL}" "-DBUILD_EAS3=${BUILD_EAS3}" "-DBUILD_NETCDF=${BUILD_NETCDF}" && $(MAKE) -j
clean:
- /bin/rm -rf build/ bin/ lib/ lib64/ include/library/public

View file

@ -0,0 +1,59 @@
#*================================================================================================*#
#| |#
#| /$$$$$$$ /$$ /$$ /$$ /$$ |#
#| | $$__ $$|__/ | $$ /$ | $$| $$ |#
#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |#
#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |#
#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |#
#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |#
#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |#
#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |#
#| /$$ \ $$ | $$ |#
#| | $$$$$$/ | $$ |#
#| \______/ |__/ |#
#| |#
#| DESCRIPTION: |#
#| ------------ |#
#| |#
#| Config that handles package versioning. |#
#| |#
#| -------------------------------------------------------------------------------------------- |#
#| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart |#
#| |#
#| Redistribution and use in source and binary forms, with or without modification, are |#
#| permitted provided that the following conditions are met: |#
#| |#
#| (1) Redistributions of source code must retain the above copyright notice, this list of |#
#| conditions and the following disclaimer. |#
#| |#
#| (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 provided with the distribution. |#
#| |#
#| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS |#
#| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |#
#| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |#
#| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |#
#| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |#
#| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |#
#| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |#
#| 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. |#
#| |#
#*================================================================================================*#
set(PACKAGE_VERSION_MAJOR @BWC_VERSION_MAJOR@)
set(PACKAGE_VERSION_MINOR @BWC_VERSION_MINOR@)
set(PACKAGE_VERSION_PATCH @BWC_VERSION_PATCH@)
set(PACKAGE_VERSION @BWC_VERSION@)
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION OR
PACKAGE_VERSION_MAJOR GREATER PACKAGE_FIND_VERSION_MAJOR)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if(PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

61
1-bwc/bwc-config.cmake.in Normal file
View file

@ -0,0 +1,61 @@
#*================================================================================================*#
#| |#
#| /$$$$$$$ /$$ /$$ /$$ /$$ |#
#| | $$__ $$|__/ | $$ /$ | $$| $$ |#
#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |#
#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |#
#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |#
#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |#
#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |#
#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |#
#| /$$ \ $$ | $$ |#
#| | $$$$$$/ | $$ |#
#| \______/ |__/ |#
#| |#
#| DESCRIPTION: |#
#| ------------ |#
#| |#
#| Config file for the bwc package defining the following variables: |#
#| |#
#| BWC_INCLUDE_DIRS - include directories for bwc, |#
#| BWC_LIBRARIES - libraries to link against, |#
#| |#
#| and the following imported targets: |#
#| |#
#| bwc::bwclib |#
#| |#
#| -------------------------------------------------------------------------------------------- |#
#| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart |#
#| |#
#| Redistribution and use in source and binary forms, with or without modification, are |#
#| permitted provided that the following conditions are met: |#
#| |#
#| (1) Redistributions of source code must retain the above copyright notice, this list of |#
#| conditions and the following disclaimer. |#
#| |#
#| (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 provided with the distribution. |#
#| |#
#| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS |#
#| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |#
#| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |#
#| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |#
#| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |#
#| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |#
#| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |#
#| 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. |#
#| |#
#*================================================================================================*#
include("${CMAKE_CURRENT_LIST_DIR}/bwc-config-version.cmake")
include(FindPackageHandleStandardArgs)
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG "${CMAKE_CURRENT_LIST_FILE}")
find_package_handle_standard_args(${CMAKE_FIND_PACKAGE_NAME} CONFIG_MODE)
if(NOT TARGET bwc::bwclib)
include("${CMAKE_CURRENT_LIST_DIR}/bwc-targets.cmake")
set(BWC_LIBRARIES "bwc::bwclib")
get_target_property(BWC_INCLUDE_DIRS bwc::bwclib INTERFACE_INCLUDE_DIRECTORIES)
endif()

View file

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 2645 630" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g transform="matrix(5.4,0,0,5.4,-1595.98,-659.601)">
<g>
<g id="g" transform="matrix(-0.233284,-1.39905e-16,-2.77556e-17,0.233284,887.632,-47.5765)">
<path d="M626.195,897.638C635.52,897.638 644.463,901.342 651.056,907.936C657.65,914.529 661.354,923.472 661.354,932.797C661.354,993.197 661.354,1174.93 661.354,1194.63C661.354,1196.12 660.761,1197.55 659.706,1198.61C658.651,1199.66 657.22,1200.26 655.728,1200.26C643.096,1200.26 612.853,1200.25 603.488,1200.25C601.935,1200.25 600.675,1198.99 600.675,1197.44C600.675,1184.01 600.675,1126.48 600.675,1113.05C600.675,1112.3 600.379,1111.59 599.852,1111.06C599.324,1110.53 598.609,1110.24 597.863,1110.24C585.601,1110.24 535.883,1110.24 501.123,1110.24C491.798,1110.24 482.855,1106.53 476.261,1099.94C469.668,1093.35 465.963,1084.4 465.963,1075.08L465.963,932.797C465.963,923.472 469.668,914.529 476.261,907.936C482.855,901.342 491.798,897.638 501.123,897.638C536.516,897.638 590.801,897.638 626.195,897.638ZM600.675,961.189C600.675,959.636 599.416,958.376 597.863,958.376C586.14,958.376 541.239,958.376 529.517,958.376C527.964,958.376 526.704,959.636 526.704,961.189C526.704,974.734 526.704,1033.14 526.704,1046.68C526.704,1048.24 527.964,1049.49 529.517,1049.49C541.239,1049.49 586.141,1049.49 597.863,1049.49C599.416,1049.49 600.675,1048.24 600.675,1046.68C600.675,1033.14 600.675,974.734 600.675,961.189Z" style="fill:rgb(255,140,0);stroke:rgb(35,43,63);stroke-width:3.75px;"/>
</g>
<g id="o" transform="matrix(0.233284,-1.39905e-16,2.77556e-17,0.233284,573.203,-47.5935)">
<path d="M626.195,897.638C635.52,897.638 644.462,901.342 651.056,907.936C657.65,914.529 661.354,923.472 661.354,932.797C661.354,972.192 661.354,1035.68 661.354,1075.08C661.354,1084.4 657.65,1093.35 651.056,1099.94C644.462,1106.53 635.52,1110.24 626.195,1110.24C586.814,1110.24 523.357,1110.24 483.976,1110.24C474.651,1110.24 465.709,1106.53 459.115,1099.94C452.521,1093.35 448.817,1084.4 448.817,1075.08C448.817,1035.68 448.817,972.192 448.817,932.797C448.817,923.472 452.521,914.529 459.115,907.936C465.709,901.342 474.651,897.638 483.976,897.638C523.357,897.638 586.814,897.638 626.195,897.638ZM600.675,961.189C600.675,959.636 599.416,958.376 597.863,958.376C584.318,958.376 525.915,958.376 512.37,958.376C510.817,958.376 509.558,959.636 509.558,961.189C509.558,974.734 509.558,1033.14 509.558,1046.68C509.558,1048.24 510.817,1049.49 512.371,1049.49C525.915,1049.49 584.318,1049.49 597.863,1049.49C599.416,1049.49 600.675,1048.24 600.675,1046.68C600.675,1033.14 600.675,974.734 600.675,961.189Z" style="fill:rgb(255,140,0);stroke:rgb(35,43,63);stroke-width:3.75px;"/>
</g>
<g id="o1" serif:id="o" transform="matrix(0.233284,-1.39905e-16,2.77556e-17,0.233284,517.76,-47.5935)">
<path d="M626.195,897.638C635.52,897.638 644.462,901.342 651.056,907.936C657.65,914.529 661.354,923.472 661.354,932.797C661.354,972.192 661.354,1035.68 661.354,1075.08C661.354,1084.4 657.65,1093.35 651.056,1099.94C644.462,1106.53 635.52,1110.24 626.195,1110.24C586.814,1110.24 523.357,1110.24 483.976,1110.24C474.651,1110.24 465.709,1106.53 459.115,1099.94C452.521,1093.35 448.817,1084.4 448.817,1075.08C448.817,1035.68 448.817,972.192 448.817,932.797C448.817,923.472 452.521,914.529 459.115,907.936C465.709,901.342 474.651,897.638 483.976,897.638C523.357,897.638 586.814,897.638 626.195,897.638ZM600.675,961.189C600.675,959.636 599.416,958.376 597.863,958.376C584.318,958.376 525.915,958.376 512.37,958.376C510.817,958.376 509.558,959.636 509.558,961.189C509.558,974.734 509.558,1033.14 509.558,1046.68C509.558,1048.24 510.817,1049.49 512.371,1049.49C525.915,1049.49 584.318,1049.49 597.863,1049.49C599.416,1049.49 600.675,1048.24 600.675,1046.68C600.675,1033.14 600.675,974.734 600.675,961.189Z" style="fill:rgb(255,140,0);stroke:rgb(35,43,63);stroke-width:3.75px;"/>
</g>
<g id="h" transform="matrix(0.233284,-1.39905e-16,2.77556e-17,0.233284,462.316,-47.5935)">
<path d="M626.195,897.638C645.613,897.638 661.354,913.379 661.354,932.797C661.354,985.291 661.354,1080.57 661.354,1104.61C661.354,1107.72 658.835,1110.24 655.729,1110.24C643.096,1110.24 612.852,1110.24 603.488,1110.24C601.934,1110.24 600.675,1108.98 600.675,1107.42C600.675,1088.52 600.675,980.098 600.675,961.189C600.675,960.443 600.379,959.728 599.851,959.2C599.324,958.673 598.608,958.376 597.862,958.376C584.318,958.377 525.914,958.378 512.37,958.378C510.816,958.378 509.557,959.638 509.557,961.191C509.557,980.1 509.557,1088.52 509.557,1107.42C509.557,1108.98 508.298,1110.24 506.744,1110.24C497.372,1110.24 467.085,1110.24 454.442,1110.24C452.95,1110.24 451.52,1109.64 450.465,1108.59C449.41,1107.53 448.817,1106.1 448.817,1104.61C448.817,1062.98 448.817,803.227 448.817,761.598C448.817,760.106 449.41,758.675 450.465,757.62C451.52,756.565 452.95,755.972 454.442,755.972C466.058,755.972 492.328,755.972 500.968,755.972C502.521,755.972 503.78,757.231 503.78,758.785C503.781,776.881 503.782,876.729 503.783,894.825C503.783,896.378 505.042,897.638 506.595,897.638C520.742,897.638 585.056,897.638 626.195,897.638Z" style="fill:rgb(255,140,0);stroke:rgb(35,43,63);stroke-width:3.75px;"/>
</g>
<g id="W" transform="matrix(0.23332,0,0,0.23332,313.135,-47.634)">
<path d="M708.676,761.532C708.676,760.04 709.269,758.61 710.324,757.555C711.379,756.5 712.809,755.907 714.301,755.907C728.634,755.907 766.14,755.907 776.715,755.907C777.461,755.907 778.176,756.204 778.704,756.731C779.231,757.259 779.528,757.974 779.528,758.72C779.528,786.354 779.528,1008.92 779.528,1036.56C779.528,1038.11 780.787,1039.37 782.34,1039.37C793.71,1039.37 836.211,1039.37 847.581,1039.37C848.327,1039.37 849.043,1039.07 849.57,1038.55C850.097,1038.02 850.394,1037.3 850.394,1036.56C850.394,1018.46 850.394,918.55 850.394,900.45C850.394,899.704 850.69,898.989 851.217,898.462C851.745,897.934 852.46,897.638 853.206,897.638C864.576,897.638 907.078,897.638 918.448,897.638C919.193,897.638 919.909,897.934 920.436,898.462C920.964,898.989 921.26,899.704 921.26,900.45C921.26,918.55 921.26,1018.46 921.26,1036.56C921.26,1037.3 921.556,1038.02 922.084,1038.55C922.611,1039.07 923.326,1039.37 924.072,1039.37C935.442,1039.37 977.944,1039.37 989.314,1039.37C990.06,1039.37 990.775,1039.07 991.302,1038.55C991.83,1038.02 992.126,1037.3 992.126,1036.56C992.126,1008.93 992.126,786.418 992.126,758.833C992.126,757.284 993.379,756.026 994.929,756.021C1005.49,755.984 1043.01,755.854 1057.36,755.804C1058.86,755.799 1060.29,756.389 1061.35,757.444C1062.41,758.5 1063.01,759.933 1063.01,761.429C1063.01,797.233 1063.01,993.835 1063.01,1075.08C1063.01,1084.41 1059.3,1093.35 1052.71,1099.94C1046.12,1106.54 1037.18,1110.24 1027.85,1110.24C959.997,1110.24 811.688,1110.24 743.832,1110.24C724.417,1110.24 708.679,1094.5 708.678,1075.08C708.678,993.842 708.677,797.275 708.676,761.532Z" style="fill:url(#_Radial1);stroke:rgb(35,43,63);stroke-width:3.75px;"/>
</g>
</g>
<g>
<g id="g1" serif:id="g" transform="matrix(0.233284,-1.39905e-16,2.77556e-17,0.233284,300.533,-47.5765)">
<path d="M626.195,897.638C635.52,897.638 644.462,901.342 651.056,907.936C657.65,914.529 661.354,923.472 661.354,932.797C661.354,993.197 661.354,1139.84 661.354,1165.1C661.354,1174.42 657.65,1183.36 651.056,1189.96C644.462,1196.55 635.52,1200.26 626.195,1200.26C586.814,1200.26 523.357,1200.26 483.976,1200.26C474.651,1200.26 465.708,1196.55 459.115,1189.96C452.521,1183.36 448.817,1174.42 448.817,1165.1C448.817,1152.31 448.817,1139.24 448.817,1132.04C448.817,1128.93 451.335,1126.41 454.442,1126.41C466.013,1126.41 492.361,1126.41 503.932,1126.41C505.424,1126.41 506.855,1127.01 507.91,1128.06C508.965,1129.12 509.558,1130.55 509.558,1132.04C509.558,1133.65 509.558,1135.34 509.558,1136.7C509.558,1138.25 510.817,1139.51 512.371,1139.51C525.915,1139.51 584.318,1139.51 597.863,1139.51C599.416,1139.51 600.675,1138.25 600.675,1136.7C600.675,1131.11 600.675,1118.64 600.675,1113.05C600.675,1111.5 599.416,1110.24 597.863,1110.24C584.173,1110.24 523.565,1110.24 483.976,1110.24C474.651,1110.24 465.708,1106.53 459.115,1099.94C452.521,1093.35 448.817,1084.4 448.817,1075.08C448.817,1035.68 448.817,972.192 448.817,932.797C448.817,923.472 452.521,914.529 459.115,907.936C465.709,901.342 474.651,897.638 483.976,897.638C523.357,897.638 586.814,897.638 626.195,897.638ZM600.675,961.189C600.675,959.636 599.416,958.376 597.863,958.376C584.318,958.376 525.915,958.376 512.37,958.376C510.817,958.376 509.558,959.636 509.558,961.189C509.558,974.734 509.558,1033.14 509.558,1046.68C509.558,1048.24 510.817,1049.49 512.371,1049.49C525.915,1049.49 584.318,1049.49 597.863,1049.49C599.416,1049.49 600.675,1048.24 600.675,1046.68C600.675,1033.14 600.675,974.734 600.675,961.189Z" style="fill:rgb(255,140,0);stroke:rgb(35,43,63);stroke-width:3.57px;"/>
</g>
<g id="i" transform="matrix(1,0,0,1,-10.822,0)">
<g id="Line" transform="matrix(0.23332,0,0,0.23332,196.471,-47.6165)">
<path d="M856.018,1110.24C852.912,1110.24 850.394,1107.72 850.394,1104.61C850.394,1073.49 850.394,922.937 850.394,900.45C850.394,898.897 851.653,897.638 853.206,897.638C864.576,897.638 907.078,897.638 918.448,897.638C920.001,897.638 921.26,898.897 921.26,900.45C921.26,922.937 921.259,1073.49 921.259,1104.61C921.259,1107.72 918.741,1110.24 915.634,1110.24C902.374,1110.24 869.278,1110.24 856.018,1110.24Z" style="fill:url(#_Radial2);stroke:rgb(35,43,63);stroke-width:3.57px;"/>
</g>
<g id="Dot" transform="matrix(0.0404145,0,0,0.0404145,369.105,97.5346)">
<g id="Right" transform="matrix(1,0,0,1,-491.281,4.90274e-13)">
<path d="M1534.3,1122.05L1534.3,1358.27L1329.72,1476.38L1329.72,1240.16L1534.3,1122.05Z" style="fill:rgb(255,140,0);stroke:rgb(35,43,63);stroke-width:22.91px;stroke-linecap:round;"/>
</g>
<g id="Left" transform="matrix(-1,0,0,1,2168.17,4.9738e-13)">
<path d="M1534.3,1122.05L1534.3,1358.27L1329.72,1476.38L1329.72,1240.16L1534.3,1122.05Z" style="fill:rgb(255,140,0);stroke:rgb(35,43,63);stroke-width:22.91px;stroke-linecap:round;"/>
</g>
<g id="Up" transform="matrix(1,0,0,1,-491.281,1.13687e-13)">
<path d="M1329.72,1003.94L1534.3,1122.05L1329.72,1240.16L1125.15,1122.05L1329.72,1003.94Z" style="fill:rgb(255,140,0);stroke:rgb(35,43,63);stroke-width:22.91px;stroke-linecap:round;"/>
</g>
</g>
<g id="Dot1" serif:id="Dot" transform="matrix(0.0404145,0,0,0.0404145,369.105,97.5346)">
<g id="Right1" serif:id="Right" transform="matrix(1,0,0,1,-491.281,4.90274e-13)">
<path d="M1534.3,1122.05L1534.3,1358.27L1329.72,1476.38L1329.72,1240.16L1534.3,1122.05Z" style="fill:rgb(255,140,0);stroke:rgb(35,43,63);stroke-width:10.31px;stroke-linecap:round;"/>
</g>
<g id="Left1" serif:id="Left" transform="matrix(-1,0,0,1,2168.17,4.9738e-13)">
<path d="M1534.3,1122.05L1534.3,1358.27L1329.72,1476.38L1329.72,1240.16L1534.3,1122.05Z" style="fill:rgb(255,140,0);stroke:rgb(35,43,63);stroke-width:10.31px;stroke-linecap:round;"/>
</g>
<g id="Up1" serif:id="Up" transform="matrix(1,0,0,1,-491.281,1.13687e-13)">
<path d="M1329.72,1003.94L1534.3,1122.05L1329.72,1240.16L1125.15,1122.05L1329.72,1003.94Z" style="fill:rgb(255,140,0);stroke:rgb(35,43,63);stroke-width:10.31px;stroke-linecap:round;"/>
</g>
</g>
</g>
<g id="B" transform="matrix(-0.233284,-1.39905e-16,-2.77556e-17,0.233284,483.966,-47.5898)">
<path d="M773.903,755.906C775.395,755.906 776.825,756.498 777.88,757.553C778.935,758.608 779.528,760.039 779.528,761.531C779.528,803.165 779.528,1062.98 779.528,1104.61C779.528,1106.1 778.935,1107.53 777.88,1108.59C776.825,1109.64 775.395,1110.24 773.903,1110.24C739.915,1110.24 560.886,1110.24 483.977,1110.24C474.652,1110.24 465.709,1106.53 459.115,1099.94C452.522,1093.34 448.817,1084.4 448.817,1075.08C448.818,1038.27 448.819,983.738 448.819,968.504C448.819,933.071 496.063,933.071 496.063,933.071C496.063,933.071 448.819,933.071 448.819,897.638C448.819,882.404 448.818,827.872 448.817,791.065C448.817,781.74 452.522,772.797 459.115,766.204C465.709,759.61 474.652,755.906 483.977,755.906C560.886,755.906 739.915,755.906 773.903,755.906ZM708.661,971.317C708.661,969.763 707.402,968.504 705.849,968.504C684.187,968.504 544.159,968.504 522.498,968.504C520.944,968.504 519.685,969.763 519.685,971.317C519.685,982.687 519.685,1025.19 519.685,1036.56C519.685,1038.11 520.944,1039.37 522.498,1039.37C544.159,1039.37 684.187,1039.37 705.849,1039.37C707.402,1039.37 708.661,1038.11 708.661,1036.56C708.661,1025.19 708.661,982.687 708.661,971.317ZM708.661,829.584C708.661,828.031 707.402,826.772 705.849,826.772C684.187,826.772 544.159,826.772 522.498,826.772C520.944,826.772 519.685,828.031 519.685,829.584C519.685,840.955 519.685,883.455 519.685,894.825C519.685,896.379 520.944,897.638 522.498,897.638C544.159,897.638 684.187,897.638 705.849,897.638C707.402,897.638 708.661,896.379 708.661,894.825C708.661,883.455 708.661,840.955 708.661,829.584Z" style="fill:rgb(255,140,0);stroke:rgb(35,43,63);stroke-width:3.57px;"/>
</g>
</g>
</g>
<defs>
<radialGradient id="_Radial1" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="matrix(621.143,268.963,1.08212e-12,438.396,517.933,451.478)"><stop offset="0" style="stop-color:rgb(251,174,81);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(255,140,0);stop-opacity:1"/></radialGradient>
<radialGradient id="_Radial2" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="matrix(621.143,268.963,1.08212e-12,438.396,517.933,451.478)"><stop offset="0" style="stop-color:rgb(251,174,81);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(255,140,0);stop-opacity:1"/></radialGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 14 KiB

94
1-bwc/docs/img/Logo.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 126 KiB

299
1-bwc/docs/templates/header.h vendored Executable file
View file

@ -0,0 +1,299 @@
/*==================================================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| File: header.h ||
|| ----- ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| DESCRIPTION NEEDED. ||
|| ||
|| STRUCTS: ||
|| -------- ||
|| ||
|| PUBLIC FUNCTIONS: ||
|| ----------------- ||
|| ||
|| DEVELOPMENT HISTORY: ||
|| -------------------- ||
|| ||
|| Date Author Change Id Release Description Of Change ||
|| ---- ------ --------- ------- --------------------- ||
|| - Patrick Vogler B87D120 V - header file created ||
|| - Patrick Vogler B880CA2 V - header file patched ||
|| - Patrick Vogler B87E7E4 V - header file updated ||
|| - Patrick Vogler B87F684 V - header file new version ||
|| ||
|| -------------------------------------------------------------------------------------------------------------------- ||
|| ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are permitted provided that the ||
|| following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and ||
|| the following disclaimer. ||
|| ||
|| (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 provided with the ||
|| distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR 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. ||
|| ||
\*==================================================================================================================================*/
#ifndef HEADER_H
#define HEADER_H
/************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************************/
/************************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! Macros: !
! ------- !
! Macro Description !
! ----- ----------- !
! !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V - Macros created !
! - Patrick Vogler B880CA2 V - Macros patched !
! - Patrick Vogler B87E7E4 V - Macros updated !
! - Patrick Vogler B87F684 V - Macros new version !
! !
\*----------------------------------------------------------------------------------------------------------*/
/************************************************************************************************************\
|| ____ ____ _ _ ____ ___ ____ _ _ ___ ____ ||
|| | | | |\ | [__ | |__| |\ | | [__ ||
|| |___ |__| | \| ___] | | | | \| | ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! CONSTANTS: !
! ----------- !
! Constant Description !
! -------- ----------- !
! !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V - Constants created !
! - Patrick Vogler B880CA2 V - Constants patched !
! - Patrick Vogler B87E7E4 V - Constants updated !
! - Patrick Vogler B87F684 V - Constants new version !
! !
\*----------------------------------------------------------------------------------------------------------*/
/************************************************************************************************************\
|| ____ _ _ ___ ____ ____ _ _ ____ _ _ _ ____ ____ _ ____ ___ _ ____ ____ ||
|| |___ \/ | |___ |__/ |\ | |__| | | | |__| |__/ | |__| |__] | |___ [__ ||
|| |___ _/\_ | |___ | \ | \| | | |___ \/ | | | \ | | | |__] |___ |___ ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! VARIABLES: !
! ----------- !
! VARIABLE Description !
! -------- ----------- !
! !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V - Variables created !
! - Patrick Vogler B880CA2 V - Variables patched !
! - Patrick Vogler B87E7E4 V - Variables updated !
! - Patrick Vogler B87F684 V - Variables new version !
! !
\*----------------------------------------------------------------------------------------------------------*/
/************************************************************************************************************\
|| ____ _ _ ___ ____ ____ _ _ ____ _ ____ ____ _ _ ____ ___ ____ _ _ ___ ____ ||
|| |___ \/ | |___ |__/ |\ | |__| | | | | |\ | [__ | |__| |\ | | [__ ||
|| |___ _/\_ | |___ | \ | \| | | |___ |___ |__| | \| ___] | | | | \| | ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! CONSTANTS: !
! ----------- !
! Constant Description !
! -------- ----------- !
! !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V - Constants created !
! - Patrick Vogler B880CA2 V - Constants patched !
! - Patrick Vogler B87E7E4 V - Constants updated !
! - Patrick Vogler B87F684 V - Constants new version !
! !
\*----------------------------------------------------------------------------------------------------------*/
/************************************************************************************************************\
|| ___ _ _ ___ ____ ____ ||
|| | \_/ |__] |___ [__ ||
|| | | | |___ ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! STRUCT NAME: Template !
! ----------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! DEPENDENCIES: !
! ------------- !
! Variable Type Description !
! -------- ---- ----------- !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V - Struct created !
! - Patrick Vogler B880CA2 V - Struct patched !
! - Patrick Vogler B87E7E4 V - Struct updated !
! - Patrick Vogler B87F684 V - Struct new version !
! !
\*----------------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------------------*\
! ENUM NAME: Template !
! ----------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! DEPENDENCIES: !
! ------------- !
! Variable Type Description !
! -------- ---- ----------- !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V - Enum created !
! - Patrick Vogler B880CA2 V - Enum patched !
! - Patrick Vogler B87E7E4 V - Enum updated !
! - Patrick Vogler B87F684 V - Enum new version !
! !
\*----------------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------------------*\
! UNION NAME: Template !
! ----------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! DEPENDENCIES: !
! ------------- !
! Variable Type Description !
! -------- ---- ----------- !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V - Union created !
! - Patrick Vogler B880CA2 V - Union patched !
! - Patrick Vogler B87E7E4 V - Union updated !
! - Patrick Vogler B87F684 V - Union new version !
! !
\*----------------------------------------------------------------------------------------------------------*/
/************************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! TYPE NAME: Template !
! ----------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
\*----------------------------------------------------------------------------------------------------------*/
#endif

179
1-bwc/docs/templates/source.c vendored Executable file
View file

@ -0,0 +1,179 @@
/*==================================================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| FILE NAME: source.c ||
|| ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| DESCRIPTION NEEDED. ||
|| ||
|| FILE REFERENCES: ||
|| ---------------- ||
|| ||
|| Name I/O Description ||
|| ---- --- ----------- ||
|| none - - ||
|| ||
|| ||
|| PRIVATE FUNCTIONS: ||
|| ------------------ ||
|| ||
|| PUBLIC FUNCTIONS: ||
|| ----------------- ||
|| ||
|| DEVELOPMENT HISTORY: ||
|| -------------------- ||
|| ||
|| Date Author Change Id Release Description Of Change ||
|| ---- ------ --------- ------- --------------------- ||
|| - Patrick Vogler B87D120 V - source file created ||
|| - Patrick Vogler B880CA2 V - source file patched ||
|| - Patrick Vogler B87E7E4 V - source file updated ||
|| - Patrick Vogler B87F684 V - source file new version ||
|| ||
|| -------------------------------------------------------------------------------------------------------------------- ||
|| ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are permitted provided that the ||
|| following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and ||
|| the following disclaimer. ||
|| ||
|| (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 provided with the ||
|| distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR 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. ||
|| ||
\*==================================================================================================================================*/
/************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************************/
/************************************************************************************************************\
|| ____ _ _ ___ ____ ____ _ _ ____ _ _ _ ____ ____ _ ____ ___ _ ____ ____ ||
|| |___ \/ | |___ |__/ |\ | |__| | | | |__| |__/ | |__| |__] | |___ [__ ||
|| |___ _/\_ | |___ | \ | \| | | |___ \/ | | | \ | | | |__] |___ |___ ___] ||
|| ||
\************************************************************************************************************/
/************************************************************************************************************\
|| ____ _ _ ___ ____ ____ _ _ ____ _ ____ ____ _ _ ____ ___ ____ _ _ ___ ____ ||
|| |___ \/ | |___ |__/ |\ | |__| | | | | |\ | [__ | |__| |\ | | [__ ||
|| |___ _/\_ | |___ | \ | \| | | |___ |___ |__| | \| ___] | | | | \| | ___] ||
|| ||
\************************************************************************************************************/
/************************************************************************************************************\
|| ___ ____ _ _ _ ____ ___ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] |__/ | | | |__| | |___ |___ | | |\ | | | | | | |\ | [__ ||
|| | | \ | \/ | | | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *template(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V - function created !
! - Patrick Vogler B880CA2 V - function patched !
! - Patrick Vogler B87E7E4 V - function updated !
! - Patrick Vogler B87F684 V - function new version !
! !
\*----------------------------------------------------------------------------------------------------------*/
/************************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V - function created !
! - Patrick Vogler B880CA2 V - function patched !
! - Patrick Vogler B87E7E4 V - function updated !
! - Patrick Vogler B87F684 V - function new version !
! !
\*----------------------------------------------------------------------------------------------------------*/
/*-----------------------*\
! DEFINE INT VARIABLES: !
\*-----------------------*/
/*-----------------------*\
! DEFINE FLOAT VARIABLES: !
\*-----------------------*/
/*-----------------------*\
! DEFINE CHAR VARIABLES: !
\*-----------------------*/
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
/*--------------------------------------------------------*\
! COMMENTCOMMENTCOMMENTCOMMENTCOMMENTCOMMENTCOMMENTCOMMENT !
\*--------------------------------------------------------*/

View file

@ -0,0 +1,360 @@
/*==================================================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| File: header.h ||
|| ----- ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| This file defines simple read and write functions used to access conforming eas3 datasets. ||
|| ||
|| STRUCTS: ||
|| -------- ||
|| - eas3_std_params ||
|| ||
|| PUBLIC FUNCTIONS: ||
|| ----------------- ||
|| - read_eas3 ||
|| - write_eas3 ||
|| ||
|| DEVELOPMENT HISTORY: ||
|| -------------------- ||
|| ||
|| Date Author Change Id Release Description Of Change ||
|| ---- ------ --------- ------- --------------------- ||
|| - Patrick Vogler B87D120 V 0.1.0 header file created ||
|| ||
|| -------------------------------------------------------------------------------------------------------------------- ||
|| ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are permitted provided that the ||
|| following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and ||
|| the following disclaimer. ||
|| ||
|| (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 provided with the ||
|| distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR 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. ||
|| ||
\*==================================================================================================================================*/
#ifndef EAS3_H
#define EAS3_H
/************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************************/
#include <bwc.h>
#include <stdio.h>
#include <stdint.h>
/************************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! DESCRIPTION: !
! ------------ !
! !
! These macros are used to identify the spatial and temporal dimensions. !
! !
! MACROS: !
! ------- !
! Name Description !
! ---- ----------- !
! DIM_X, DIM_Y, DIM_Z - Spatial Dimensions !
! !
! DIM_TS - Temporal Dimension !
! !
! DIM_ALL - All Dimensions !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description !
! ---- ------ --------- ------- ----------- !
! 04.12.2017 Patrick Vogler B87D120 V 0.1.0 macros created !
! !
\*----------------------------------------------------------------------------------------------------------*/
#define DIM_X 1
#define DIM_Y 2
#define DIM_Z 4
#define DIM_TS 8
#define DIM_ALL 15
/*----------------------------------------------------------------------------------------------------------*\
! DESCRIPTION: !
! ------------ !
! !
! These macros are used to instruct the read_eas3_header function. !
! !
! Macros: !
! ------- !
! Macro Description !
! ----- ----------- !
! EAS3_NO_ATTR 1 - Specifies that no attributes are present in the bit- !
! stream. !
! !
! EAS3_ALL_ATTR 2 - Specifies that all attributes are present in the bit- !
! bitstream. !
! !
! ATTRLEN 10 - Defines the number of bytes used to define an attrib- !
! ute. !
! !
! UDEFLEN 20 - Defines the number of bytes used to define a user de- !
! fined data. !
! !
! EAS3_NO_G 1 - Specifies that no geometry data is present in the bit- !
! stream. !
! !
! EAS3_X0DX_G 2 - Specifies that a start value and step size are present !
! in the bitstream. !
! !
! EAS3_UDEF_G 3 - Specifies that ng = number of coordinate data is pres- !
! ent in the bitstream. !
! !
! EAS3_ALL_G 4 - Specifies that an element for every appropriate di- !
! mension is present in the bitstream. !
! !
! EAS3_FULL_G 5 - Specifies that an element for every dimension is pres- !
! ent in the bitstream. !
! !
! EAS3_NO_UDEF 1 - Specifies that no user defined data is present in the !
! bitstream. !
! !
! EAS3_ALL_UDEF 2 - Specifies that all user defined fields are present in !
! the bitstream. !
! !
! EAS3_INT_UDEF 3 - Specifies that an user defined integer field is pres- !
! ent in the bitstream. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 20.06.2018 Patrick Vogler B87D120 V 0.1.0 Macros created !
\*----------------------------------------------------------------------------------------------------------*/
#define EAS3_NO_ATTR 0x100000000000000
#define EAS3_ALL_ATTR 0x200000000000000
#define EAS2_TYPE 0x100000000000000
#define EAS3_TYPE 0x200000000000000
#define ATTRLEN 10
#define UDEFLEN 20
#define EAS3_NO_G 0x100000000000000
#define EAS3_X0DX_G 0x200000000000000
#define EAS3_UDEF_G 0x300000000000000
#define EAS3_ALL_G 0x400000000000000
#define EAS3_FULL_G 0x500000000000000
#define EAS3_NO_UDEF 0x100000000000000
#define EAS3_ALL_UDEF 0x200000000000000
#define EAS3_INT_UDEF 0x300000000000000
#define AUX_SIZE 0x8000
/************************************************************************************************************\
|| ___ _ _ ___ ____ ____ ||
|| | \_/ |__] |___ [__ ||
|| | | | |___ ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure is used to read/assemble a packed codestream during coding. The !
! byte buffer is flushed to the packed stream as soon as the a single byte has !
! been assembled. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uchar error; // Error flag used during streaming.
uint64 L; // Number of bytes written to/from stream.
uint64 Lmax; // Size of packed stream.
uint64 size_incr; // Size incrmnt used for stream assembly.
uint8 T; // Byte buffer.
int8 t; // Byte buffer counter.
uchar *memory; // Memory handle for packed stream chunck.
} bitstream;
/*----------------------------------------------------------------------------------------------------------*\
! STRUCT NAME: eas3_header !
! ----------- !
! !
! DESCRIPTION: !
! ------------ !
! This structure is used to store the eas3 header information. For a more thorough discussion !
! of the eas3 datatype see: !
! !
! https://wiki.iag.uni-stuttgart.de/eas3wiki/index.php/EAS3_File_Format/de !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! file_type unsigned int(64 bit) - Defines an identifier for the EAS type. !
! !
! accuracy unsigned int(64 bit) - Defines the accuracy of an eas3 file. !
! !
! nzs unsigned int(64 bit) - Variable defining the temporal size of !
! the uncompressed dataset. !
! !
! npar unsigned int(64 bit) - Defines the number of parameters in the !
! eas3 dataset. !
! !
! ndim1, -2, -3 unsigned int(64 bit) - Variables defining the spatial size of !
! the eas3 dataset. !
! !
! attribute_mode; unsigned int(64 bit) - Defines an identifier used to signal !
! the attribute mode of the eas3 file. !
! !
! gmode_time unsigned int(64 bit) - Defines the geometry mode for the temp- !
! oral dimension. !
! !
! gmode_param unsigned int(64 bit) - Defines the geometry mode for the para- !
! meters. !
! !
! gmode_dim1 unsigned int(64 bit) - Defines the geometry mode for the first !
! spatial dimension. !
! !
! gmode_dim2 unsigned int(64 bit) - Defines the geometry mode for the sec- !
! ond spatial dimension. !
! !
! gmode_dim3 unsigned int(64 bit) - Defines the geometry mode for the third !
! spatial dimension. !
! !
! size_time unsigned int(64 bit) - Defines the geometry array size for the !
! temporal dimension. !
! !
! size_parameter unsigned int(64 bit) - Defines the geometry array size for the !
! parameters. !
! !
! size_dim1 unsigned int(64 bit) - Defines the geometry array size for the !
! first spatial dimension. !
! !
! size_dim2 unsigned int(64 bit) - Defines the geometry array size for the !
! second spatial dimension. !
! !
! size_dim3 unsigned int(64 bit) - Defines the geometry array size for the !
! third spatial dimension. !
! !
! udef_param unsigned int(64 bit) - Defines a marker used to signal which !
! user defined parameters are present in !
! the eas3 file. !
! !
! udef_char_size unsigned int(64 bit) - Defines the size for the user defined !
! char array. !
! !
! udef_int_size unsigned int(64 bit) - Defines the size for the user defined !
! int array. !
! !
! udef_real_size unsigned int(64 bit) - Defines the size for the user defined !
! real array. !
! !
! DEPENDENCIES: !
! ------------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 20.06.2018 Patrick Vogler B87D120 V 0.1.0 struct created !
! !
\*----------------------------------------------------------------------------------------------------------*/
typedef struct
{
uint64_t file_type;
uint64_t accuracy;
uint64_t nzs;
uint64_t npar;
uint64_t ndim1;
uint64_t ndim2;
uint64_t ndim3;
uint64_t attribute_mode;
uint64_t gmode_time;
uint64_t gmode_param;
uint64_t gmode_dim1;
uint64_t gmode_dim2;
uint64_t gmode_dim3;
uint64_t size_time;
uint64_t size_parameter;
uint64_t size_dim1;
uint64_t size_dim2;
uint64_t size_dim3;
uint64_t udef_param;
uint64_t udef_char_size;
uint64_t udef_int_size;
uint64_t udef_real_size;
} eas3_std_params;
/************************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: bwc_data* read_eas3(const char* const filename) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! This function opens an eas3 file and checks it for its validity. Once the specified file !
! has been verified, its header and flow field data is read and stored in the bwc_data !
! structure. !
! !
\*----------------------------------------------------------------------------------------------------------*/
bwc_data*
read_eas3(char *const filename);
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: uchar write_eas3(bwc_data *const file, char *const filename) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! This function creates a valid eas3 file from the information stored in the bwc_data !
! structure. !
! !
\*----------------------------------------------------------------------------------------------------------*/
uchar
write_eas3(bwc_data *const file, char *const filename);
#endif

View file

@ -0,0 +1,124 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This file describes a set of functions that can be used to create, manipulate ||
|| and terminate a bitstream. These functions facilitate the creation or reading ||
|| of a compressed bwc codestream and can emit/extract information on a per bit, ||
|| symbol (64-bit) or string basis. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef BITSTREAM_H
#define BITSTREAM_H
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#include "types.h"
/************************************************************************************************\
|| ___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____ ||
|| | \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ ||
|| |__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___] ||
|| ||
\************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure is used to read/assemble a packed codestream during coding. The !
! byte buffer is flushed to the packed stream as soon as the a single byte has !
! been assembled. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uchar error; // Error flag used during streaming.
uint64 L; // Number of bytes written to/from stream.
uint64 Lmax; // Size of packed stream.
uint64 size_incr; // Size incrmnt used for stream assembly.
uint8 T; // Byte buffer.
int8 t; // Byte buffer counter.
uchar *memory; // Memory handle for packed stream chunck.
} bitstream;
/************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************/
uint64 bytes_used (bitstream const *const stream);
//==========|==========================|======================|======|======|=====================
bitstream* init_stream (uchar *const memory,
uint32 const size,
char const instr);
//==========|==========================|======================|======|======|=====================
void emit_chunck (bitstream *const stream,
uchar const *const chunck,
uint64 const size);
//==========|==========================|======================|======|======|=====================
void emit_symbol (bitstream *const stream,
uint64 const symbol,
uint8 const size);
//==========|==========================|======================|======|======|=====================
void emit_bit (bitstream *const stream,
uint64 const bit);
//==========|==========================|======================|======|======|=====================
void flush_stream (bitstream *const stream);
//==========|==========================|======================|======|======|=====================
uchar* get_chunck (bitstream *const stream,
uint64 const length);
//==========|==========================|======================|======|======|=====================
uint64 get_symbol (bitstream *const stream,
uint8 const length);
//==========|==========================|======================|======|======|=====================
uchar get_bit (bitstream *const stream);
//==========|==========================|======================|======|======|=====================
uchar terminate_stream (bitstream *stream,
bwc_stream *const packed_stream);
//==========|==========================|======================|======|======|=====================
void release_packed_stream (bwc_stream *const stream);
#endif

View file

@ -0,0 +1,104 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This file describes a set of function that can be used to create and manipulate ||
|| a BigWhoop Codestream. They facilitate the assembly and parsing of the main ||
|| header and tile bitsreams as well as read and write functions used to access ||
|| conforming bwc datasets. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef CODESTREAM_H
#define CODESTREAM_H
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#include "types.h"
#include "bitstream.h"
/************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] ||
|| ||
\************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define stream manipulation operations to rewind, forward, inquire !
! the availability and get access to the current memory position of a bitstrean. !
! !
\*----------------------------------------------------------------------------------------------*/
#define rewind_stream(stream, delta) \
{ \
stream->L -= delta; \
}
#define forward_stream(stream, delta) \
{ \
stream->L += delta; \
}
#define get_access(stream) (uchar*)stream->memory + stream->L
/************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************/
uchar assemble_main_header (bwc_field *const field);
//==========|==========================|======================|======|======|=====================
uchar codestream_write_aux (bwc_stream *const header,
bwc_stream *const aux);
//==========|==========================|======================|======|======|=====================
uchar codestream_write_com (bwc_stream *const header,
bwc_stream *const com);
//==========|==========================|======================|======|======|=====================
bwc_stream* assemble_codestream (bwc_field *const field);
//==========|==========================|======================|======|======|=====================
bwc_field* parse_codestream (bwc_data *const data,
uint8 const layer);
#endif

View file

@ -0,0 +1,106 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This file defines simple constants that are used to make the code more readable. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef CONSTANTS_H
#define CONSTANTS_H
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These constants are used to signal spatial or temporal the wavelet filter. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef enum
{
bwc_dwt_9_7, // Cohen Daubechies Feauveau 9/7 Wavelet
bwc_dwt_5_3, // LeGall 5/3 Wavelet
bwc_dwt_haar // Haar Wavelet
} bwc_dwt_filter;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These constants are used to signal the packing order of the codestream. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef enum
{
bwc_prog_LRCP, // Layer / Resolution / Parameter / Packet
bwc_prog_RLCP, // Resolution / Layer / Parameter / Packet
bwc_prog_RPCL, // Resolution / Packet / Parameter / Layer
bwc_prog_PCRL, // Packet / Parameter / Resolution / Layer
bwc_prog_CPRL // Parameter / Packet / Resolution / Layer
} bwc_prog_ord;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These constants are used to signal the quantisation style during !
! (de)coompression. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef enum
{
bwc_qt_none, // No quantization
bwc_qt_derived, // Derrived according to Taubman/Marcellin
} bwc_quant_st;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These constants are used to signal dataset tiling by the function caller. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef enum
{
bwc_tile_sizeof, // Tiling defined by size of one tile
bwc_tile_numbof, // Tiling defined by the number of tiles
} bwc_tile_instr;
#endif

View file

@ -0,0 +1,169 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This file describes a set of functions that can be used to performe the forward/ ||
|| inverse discrete wavelet transform on 1- to 4-dimensional IEEE 754 data-sets. ||
|| For more information please refere to JPEG2000 by D. S. Taubman and M. W. ||
|| Marcellin. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef DWT_H
#define DWT_H
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#include "types.h"
/************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] ||
|| ||
\************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! Maximum number of wavelet layers for which the energy gain is calculated. !
! !
\*----------------------------------------------------------------------------------------------*/
#define MAX_DECOMP_LEVELS 4
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define the irrational coefficients for the high and low pass !
! synthesis filters associated with the (9-7) Cohen-Daubechies-Feauveau-Wavelet !
! as well as the coefficients for its coressponding lifting scheme. !
! !
\*----------------------------------------------------------------------------------------------*/
#define DWT_9X7_H0 1.115087052457000f // Low pass synthesis filter ...
#define DWT_9X7_H1 0.591271763114250f // ... coefficients
#define DWT_9X7_H2 -0.057543526228500f
#define DWT_9X7_H3 -0.091271763114250f
#define DWT_9X7_G0 1.205898036472721f // High pass synthesis filter ...
#define DWT_9X7_G1 -0.533728236885750f // ... coefficients
#define DWT_9X7_G2 -0.156446533057980f
#define DWT_9X7_G3 0.033728236885750f
#define DWT_9X7_G4 0.053497514821620f
#define ALPHA -1.586134342059924f // Lifting coefficients.
#define BETA -0.052980118572961f
#define GAMMA 0.882911075530934f
#define DELTA 0.360523644801462f
#define KAPPA_H 1.230174104914001f
#define KAPPA_L 0.812893066115961f
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define the irrational coefficients for the high and low pass !
! synthesis filters associated with the (5-3) LeGall-Wavelet. !
! !
\*----------------------------------------------------------------------------------------------*/
#define DWT_5X3_H0 1.0f // Low pass synthesis filter ...
#define DWT_5X3_H1 0.5f // ... coefficients
#define DWT_5X3_G0 0.75f // High pass synthesis filter
#define DWT_5X3_G1 -0.25f // ... coefficients
#define DWT_5X3_G2 -0.125f
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define the irrational coefficients for the high and low pass !
! synthesis filters associated with the Haar-Wavelet. !
! !
\*----------------------------------------------------------------------------------------------*/
#define DWT_HAAR_H0 1 // Low pass synthesis filter ...
#define DWT_HAAR_H1 1 // ... coefficients
#define DWT_HAAR_G0 0.5 // High pass synthesis filter ...
#define DWT_HAAR_G1 -0.5 // ... coefficients
/************************************************************************************************\
|| ____ _ _ ___ ____ ____ _ _ ____ _ _ _ ____ ____ _ ____ ___ _ ____ ____ ||
|| |___ \/ | |___ |__/ |\ | |__| | | | |__| |__/ | |__| |__] | |___ [__ ||
|| |___ _/\_ | |___ | \ | \| | | |___ \/ | | | \ | | | |__] |___ |___ ___] ||
|| ||
\************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This array defines a lookup table used to store the energy gain factors for the !
! one dimensional CDF(9/7), LeGall-(5/3) and Haar wavelet transform. Each LUT !
! contains energy gain factors for the 6 low-pass and 6 high-pass decomposition !
! including level zero. !
! !
\*----------------------------------------------------------------------------------------------*/
extern double DWT_ENERGY_GAIN_LUT[3][2 * MAX_DECOMP_LEVELS + 2];
/************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************/
uchar initialize_gain_lut ();
//==========|==========================|======================|======|=======|====================
bwc_float get_dwt_energy_gain (bwc_field *const field,
uchar const highband_flag,
uint16 const level);
//==========|==========================|======================|======|=======|====================
uchar forward_wavelet_transform (bwc_field *const field,
bwc_parameter *const parameter);
//==========|==========================|======================|======|=======|====================
uchar inverse_wavelet_transform (bwc_field *const field,
bwc_parameter *const parameter);
#endif

View file

@ -0,0 +1,147 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| Big Whoop is a compression codec for the lossy compression of IEEE 754 floating ||
|| point arrays defined on curvelinear compute grids. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef LIBBWC_H
#define LIBBWC_H
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#include "bitstream.h"
#include "codestream.h"
#include "constants.h"
#include "macros.h"
#include "mq_types.h"
#include "types.h"
/************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************/
//==========|==========================|======================|======|=======|====================
bwc_data* bwc_initialize_data (double *const field,
uint64 const nX,
uint64 const nY,
uint64 const nZ,
uint16 const nTS,
uint8 const nPar,
char *const file_extension);
//==========|==========================|======================|======|=======|====================
void bwc_add_param (bwc_data *const data,
char *const name,
uint8 const precision);
//==========|==========================|======================|======|=======|====================
void bwc_get_data (bwc_data *const data,
uchar *const buffer,
uint64 const size);
//==========|==========================|======================|======|=======|====================
void bwc_free_data (bwc_data *const data);
//==========|==========================|======================|======|=======|====================
uchar create_field (bwc_field *const field);
//==========|==========================|======================|======|=======|====================
void bwc_kill_compression (bwc_field *const field);
//==========|==========================|======================|======|=======|====================
bwc_field* bwc_initialize_field (bwc_data *const data);
//==========|==========================|======================|======|=======|====================
void bwc_set_error_resilience (bwc_field *const field);
//==========|==========================|======================|======|=======|====================
void bwc_set_quant_style (bwc_field *const field,
bwc_quant_st const quantization_style);
//==========|==========================|======================|======|=======|====================
void bwc_set_quant_step_size (bwc_field *const field,
double const delta);
//==========|==========================|======================|======|=======|====================
void bwc_set_progression (bwc_field *const field,
bwc_prog_ord const progression);
//==========|==========================|======================|======|=======|====================
void bwc_set_kernels (bwc_field *const field,
bwc_dwt_filter const KernelX,
bwc_dwt_filter const KernelY,
bwc_dwt_filter const KernelZ,
bwc_dwt_filter const KernelTS);
//==========|==========================|======================|======|=======|====================
void bwc_set_decomp (bwc_field *const field,
uint8 const decompX,
uint8 const decompY,
uint8 const decompZ,
uint8 const decompTS);
//==========|==========================|======================|======|=======|====================
void bwc_set_precincts (bwc_field *const field,
uint8 const pX,
uint8 const pY,
uint8 const pZ,
uint8 const pTS);
//==========|==========================|======================|======|=======|====================
void bwc_set_codeblocks (bwc_field *const field,
uint8 const cbX,
uint8 const cbY,
uint8 const cbZ,
uint8 const cbTS);
//==========|==========================|======================|======|=======|====================
void bwc_set_qm (bwc_field *const field,
uint8 const Qm);
//==========|==========================|======================|======|=======|====================
void bwc_set_tiles (bwc_field *const field,
uint64 const tilesX,
uint64 const tilesY,
uint64 const tilesZ,
uint64 const tilesTS,
bwc_tile_instr const instr);
//==========|==========================|======================|======|=======|====================
uchar bwc_create_compression (bwc_field *const field,
char *const rate_control);
//==========|==========================|======================|======|=======|====================
uchar bwc_compress (bwc_field *const field,
bwc_data *const data);
//==========|==========================|======================|======|=======|====================
bwc_field* bwc_create_decompression (bwc_data *const data,
uint8 const layer);
//==========|==========================|======================|======|=======|====================
uchar bwc_decompress (bwc_field *const field,
bwc_data *const data);
#endif

View file

@ -0,0 +1,137 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This file defines simple macros that are used to make the code more readable. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef BWC_MACROSS_H
#define BWC_MACROSS_H
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These constants are used to identify the spatial and temporal dimensions. !
! !
\*----------------------------------------------------------------------------------------------*/
#define DIM_X 1 // 1st. spacial direction
#define DIM_Y 2 // 2nd. spacial direction
#define DIM_Z 4 // 3rd. spacial direction
#define DIM_TS 8 // temporal direction
#define DIM_ALL 15 // all dimensions
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These Constants define codestream markers used to create the embedded codestream. !
! !
\*----------------------------------------------------------------------------------------------*/
#define SOC 0xFF50 // Start of codestream
#define SGI 0xFF51 // Global data-set information
#define SGC 0xFF52 // Global control parameters
#define SAX 0xFF53 // Auxiliary data-set information
#define TLM 0xFF54 // Packet lengths: main header
#define PLM 0xFF55 // Packet lengths: tile-part
#define PPM 0xFF56 // Quantization default
#define COM 0xFF57 // Comment
#define EOH 0xFF58 // End of header
#define PLT 0xFF60 // Packed packet headers: main header
#define PPT 0xFF61 // Packed packet headers: tile-part
#define SOT 0xFF90 // Start of tile
#define SOP 0xFF91 // Start of packet
#define EPH 0xFF92 // End of packet header
#define SOD 0xFF93 // Start of data
#define EOC 0xFFFF // End of code-stream
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define flags used for codestream parsing. !
! !
\*----------------------------------------------------------------------------------------------*/
#define CODESTREAM_OK 0x00 // No errors detected in Codestream
#define CODESTREAM_ERROR 0x80 // Error detexted in Codestream
#define CODESTREAM_SGI_READ 0x01 // Global data-set information read
#define CODESTREAM_SGC_READ 0x02 // Global control parameters read
#define CODESTREAM_SAX_READ 0x08 // Auxiliary information block read
#define CODESTREAM_COM_READ 0x10 // Comment block read
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define simple mathematicall oprators. !
! !
\*----------------------------------------------------------------------------------------------*/
#define MAX(x, y) (((x) < (y))?(y):(x)) // Returns maximum between two values
#define MIN(x, y) (((x) > (y))?(y):(x)) // Returns minimum between two values
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This macro is used to evaluate the size of an array. !
! !
\*----------------------------------------------------------------------------------------------*/
#define GET_DIM(x) (sizeof(x)/sizeof(*(x)))
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These Constants define common error messages used throughout the bwc library. !
! !
\*----------------------------------------------------------------------------------------------*/
#define MEMERROR "o##########################################################o\n"\
"| ERROR: Out of memory |\n"\
"o##########################################################o\n"
#define CSERROR "o##########################################################o\n"\
"| ERROR: Invalid Codestream |\n"\
"o##########################################################o\n"
#endif

View file

@ -0,0 +1,114 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| DESCRIPTION NEEDED. ||
|| | | ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef MQ_H
#define MQ_H
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#include "tier1.h"
#include "types.h"
/************************************************************************************************\
|| ____ ____ _ _ ____ ___ ____ _ _ ___ ____ ||
|| | | | |\ | [__ | |__| |\ | | [__ ||
|| |___ |__| | \| ___] | | | | \| | ___] ||
|| ||
\************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros define the context state indices used by the mq coder for !
! probability estimation. For a more thorough treatment of the context assignments !
! see page 487 JPEG2000 by David S. Taubman and Michael W. Marcellin. !
! !
\*----------------------------------------------------------------------------------------------*/
#define CONTEXT_SIG 0 // Sig. context labels starting indices
#define CONTEXT_RUN 9 // Indices for the run context label
#define CONTEXT_SIGN 10 // Sign context labels starting indices
#define CONTEXT_MAG 15 // Mag. context labels starting indices
#define CONTEXT_UNI 18 // Indices for the uni context label
#define CONTEXT_TOTAL 19 // Total number of context labels
/************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************/
uchar initialize_mq_encoder (bwc_coder *const coder,
uint8 const number_of_contexts);
//==========|==========================|======================|======|=======|====================
uchar mq_next_run (bwc_bit_coder *const bitcoder);
//==========|==========================|======================|======|=======|====================
void mq_bit_encode (bwc_bit_coder *const bitcoder,
uint8 const s,
uint8 const k);
//==========|==========================|======================|======|=======|====================
void mq_truncation_length_min (bwc_coder_state *const state);
//==========|==========================|======================|======|=======|====================
void mq_termination (bwc_bit_coder *const bitcoder);
//==========|==========================|======================|======|=======|====================
void free_mq_encoder (bwc_coder *const coder);
//==========|==========================|======================|======|=======|====================
uchar initialize_mq_decoder (bwc_coder *const coder,
uint8 const number_of_contexts,
int64 const Lmax);
//==========|==========================|======================|======|=======|====================
uint8 mq_bit_decode (bwc_bit_coder *const bitcoder,
uint8 const k);
//==========|==========================|======================|======|=======|====================
uint64 mq_get_no_bytes (bwc_bit_coder *const bitcoder);
//==========|==========================|======================|======|=======|====================
void mq_get_pass_lengths (bwc_bit_coder *const bitcoder,
bwc_encoded_cblk *const encoded_cblk);
//==========|==========================|======================|======|=======|====================
void mq_reset_ptr (bwc_bit_coder *const bitcoder,
uchar *const memory);
#endif

View file

@ -0,0 +1,121 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This header defines a the bit coder and its context states used during the ||
|| entropy encoding stage of the BigWhoop compression library. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef MQ_TYPES_H
#define MQ_TYPES_H
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#include <stdint.h>
/************************************************************************************************\
|| ___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____ ||
|| | \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ ||
|| |__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___] ||
|| ||
\************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure is used to directly access the parameter codeblocks during !
! entropy (de-)encoding to facilitate shared memory parallelization. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct context
{
uint16_t p; // LPS probability estimate
uint8_t sk; // Most probable symbol
const struct context *const MPS; // New context for Most Probable Symbol
const struct context *const LPS; // New context for Least Probable Symbol
} bwc_context_state;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! DESCRIPTION NEEDED !
! | | !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct state
{
int64_t L; // Number of bytes generated so far
uint32_t C; // Register def. lower bound of coding int
uint16_t A; // Register def. upper bound of coding int
int8_t t; // Counter evaluating when moving C into b
unsigned char *b; // Byte buffer
unsigned char T; // Temporary byte buffer
struct state *next; // State of the next coding phase
struct state *prev; // State of the previous coding phase
} bwc_coder_state;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! DESCRIPTION NEEDED !
! | | !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
int64_t Lmax; // Number of code bytes (used by decoder)
uint8_t nContext; // No. tracked context states
unsigned char *b; // Temporary byte buffer
bwc_coder_state *state; // State for the current coding pass
bwc_context_state const **context; // States for the current coding pass
} bwc_bit_coder;
#endif

View file

@ -0,0 +1,133 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This header defines a set of basic arithmetic types with specified widths to be ||
|| used in the big whoop compression algorithm. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef BWC_PRIM_TYPES_DOUBLE_H
#define BWC_PRIM_TYPES_DOUBLE_H
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#include <stdint.h>
/************************************************************************************************\
|| ___ ____ _ _ _ _ ___ _ _ _ ____ ___ _ _ ___ ____ ____ ||
|| |__] |__/ | |\/| | | | | | |___ | \_/ |__] |___ [__ ||
|| | | \ | | | | | | \/ |___ | | | |___ ___] ||
|| ||
\************************************************************************************************/
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
typedef double bwc_float;
typedef uint64 bwc_raw;
/************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] ||
|| ||
\************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros describe the minimum and maximum values for a double precision IEEE !
! 754 floating point variable. !
! !
\*----------------------------------------------------------------------------------------------*/
#define FLT_MAX 1.7976931348623157e+308 // Maximum finite value of a double
#define FLT_MIN 2.2250738585072014e-308 // Minimum finite value of a double
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros describe the precision (in bits and bytes) of the derrived floating !
! point type as well as the number of bits used to represent its mantissa and !
! exponent fields. !
! !
\*----------------------------------------------------------------------------------------------*/
#define PREC_BIT 63 // Double type precision in bits
#define PREC_MANTISSA 52 // Mantissa field precision in bits
#define PREC_EXPONENT 11 // Exponent field precision in bits
#define PREC_BYTE 8 // Double type precision in bytes
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros describe the bit masks used to access the sign, mantissa and !
! exponent of the derrived floating point type. !
! !
\*----------------------------------------------------------------------------------------------*/
#define SIGN 0x8000000000000000 // Sign bit mask
#define MANTISSA 0x000FFFFFFFFFFFFF // Mantissa bit mask
#define EXPONENT 0x7FF0000000000000 // Exponent bit mask
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This macro describe the maximum number of possible encoding passes during the !
! entropy encoding stage. !
! !
\*----------------------------------------------------------------------------------------------*/
#define MAXIMUM_NO_PASSES (64 * 3) - 2
#endif

View file

@ -0,0 +1,133 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This header defines a set of basic arithmetic types with specified widths to be ||
|| used in the big whoop compression algorithm. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef BWC_PRIM_TYPES_SINGLE_H
#define BWC_PRIM_TYPES_SINGLE_H
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#include <stdint.h>
/************************************************************************************************\
|| ___ ____ _ _ _ _ ___ _ _ _ ____ ___ _ _ ___ ____ ____ ||
|| |__] |__/ | |\/| | | | | | |___ | \_/ |__] |___ [__ ||
|| | | \ | | | | | | \/ |___ | | | |___ ___] ||
|| ||
\************************************************************************************************/
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
typedef float bwc_float;
typedef uint32 bwc_raw;
/************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] ||
|| ||
\************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros describe the minimum and maximum values for a single precision IEEE !
! 754 floating point variable. !
! !
\*----------------------------------------------------------------------------------------------*/
#define FLT_MAX 1.70141183e+38 // Maximum finite value of a float
#define FLT_MIN 1.17549435e-38 // Minimum finite value of a float
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros describe the precision (in bits and bytes) of the derrived floating !
! point type as well as the number of bits used to represent its mantissa and !
! exponent fields. !
! !
\*----------------------------------------------------------------------------------------------*/
#define PREC_BIT 31 // Float type precision in bits
#define PREC_MANTISSA 23 // Mantissa field precision in bits
#define PREC_EXPONENT 8 // Exponent field precision in bits
#define PREC_BYTE 4 // Float type precision in bytes
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! These macros describe the bit masks used to access the sign, mantissa and !
! exponent of the derrived floating point type. !
! !
\*----------------------------------------------------------------------------------------------*/
#define SIGN 0x80000000 // Sign bit mask
#define MANTISSA 0x007FFFFF // Mantissa bit mask
#define EXPONENT 0x7F800000 // Exponent bit mask
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This macro describe the maximum number of possible encoding passes during the !
! entropy encoding stage. !
! !
\*----------------------------------------------------------------------------------------------*/
#define MAXIMUM_NO_PASSES (32 * 3) - 2
#endif

View file

@ -0,0 +1,96 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This file defines a tagtree procedure used to encode/decode two types of ||
|| information found defining in a codeblock in specific quality layer: ||
|| ||
|| - The inclusion tag records if a codeblock has any contribution ||
|| to a quality layer. ||
|| - The number of leading bitplanes that are not significant/only ||
|| populated by zero bits. ||
|| ||
|| For more information on the encoding/decoding process please refere to JPEG2000 ||
|| by D. S. Taubman and M. W. Marcellin (p. 384). ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef TAGTREE_H
#define TAGTREE_H
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#include "types.h"
#include "bitstream.h"
/************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************/
void kill_tagtree (bwc_tagtree *const tagtree);
//==========|==========================|======================|======|=======|====================
void reset_tagtree (bwc_tagtree *const tagtree);
//==========|==========================|======================|======|=======|====================
bwc_tagtree* initialize_tagtree (uint64 const leafsX,
uint64 const leafsY,
uint64 const leafsZ,
uint64 const leafsTS);
//==========|==========================|======================|======|=======|====================
uint16 tagtree_get_value (bwc_tagtree const *const tagtree,
uint64 const leaf_index);
//==========|==========================|======================|======|=======|====================
void tagtree_set_value (bwc_tagtree *const tagtree,
uint64 const leaf_index,
uint16 const value);
//==========|==========================|======================|======|=======|====================
void encode_tagtree (bwc_tagtree *const tagtree,
bitstream *const stream,
uint32 const threshold,
uint32 const leaf_index,
uchar const estimate);
//==========|==========================|======================|======|=======|====================
uchar decode_tagtree (bwc_tagtree *const tagtree,
bitstream *const stream,
uint32 const threshold,
uint32 const leaf_index);
#endif

View file

@ -0,0 +1,168 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This file describes a set of functions that can be used to de-/encode bwc ||
|| codeblocks described by the bwc_field structure according to the embedded block ||
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef TIER1_H
#define TIER1_H
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#include "types.h"
/************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] ||
|| ||
\************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! The macros listed indicate how many bits, from the current coding position, !
! are used for error evaluation in the coding passes. !
! !
\*----------------------------------------------------------------------------------------------*/
#define DISTORTION_SIG 5 // Clean up/significance propagation pass.
#define DISTORTION_MAG 6 // Magnitude refinement pass.
/************************************************************************************************\
|| ___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____ ||
|| | \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ ||
|| |__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___] ||
|| ||
\************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds the sign (xi), bitfield (bit) and state (delta, sigma and !
! pi) information for four vertically adjacent samples for easy access during the !
! entropy encoding stage. Here, the delayed significance is set once the first bit !
! is encoded during the magnitude refinement pass, while the significance state !
! sigma is set once the first non-zero bit is encoded for a specific sample. !
! The stripe_* pointers are used to store the address of the left(l), upper(u), !
! right(r) and lower(d) neighbour of a specific stripe for easy access. To !
! facilitate distortion estimation the magnitude of the wavelet coefficients is !
! stored in an appropriate sample array. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct stripe
{
uint64 *sample; // Wavelet coef. for two adjacent stripes.
uint8 delta; // Delayed sig. for two adjacent stripes.
uint8 sigma; // Significance for two adjacent stripes.
uint8 pi; // Cdng pass membership for adj. stripes.
uint8 codingpass; // Last decoded coding pass.
uint8 bitplane; // Last decoded bitplane.
uint8 *bit; // Bitplanes for vertically adj. stripes.
uint8 xi; // Wvlt coef. sign bit for adj. stripes.
struct stripe *stripe_u; // Upper stripe.
struct stripe *stripe_r; // Right stripe.
struct stripe *stripe_d; // Lower stripe.
struct stripe *stripe_l; // Left stripe.
} bwc_coder_stripe;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure accumulates all necessary structures used to (de-)compress a !
! codeblock of wavelet coefficients. The spatial and temporal dimension of the !
! codeblock is defined by its width, height and number of slices (depth * dt). The !
! codeblock itself is subdivided into so-called stripes that represent 4 vertical- !
! ly adjacent coefficients. The parameter no_full_stripes stores overnumber of !
! full stripes present in one slice. !
! The look-up table sig2context is used to determine the coding context of a cur- !
! ren bit according to its significance context within the codeblock bitplane. !
! The look-up table is specific to a certain highband and is set accordingly. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uchar highband_flag; // Flag indicating current wavelet subbnd.
uint8 K; // Idx of the first significant bitplane.
uchar erres; // Flag signaling error resilience.
uint64 no_full_stripe; // Number of full, vert. adjacent stripes.
uint64 width, height; // Codeblock width and height.
uint64 no_slice; // N.o. slices in the spec. codeblock.
uint8 const *sig2context; // Signifance-to-context loop-up table.
bwc_bit_coder *bitcoder; // BWC bitcoder.
bwc_coder_stripe *data; // BWC coder stripe.
uint64 buff_size; // Size of packed stream.
uint64 buff_incr; // Increment for packed stream assembly.
uchar *compressed; // Compressed data chunck.
} bwc_coder;
/************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************/
uchar t1_encode (bwc_field *const field,
bwc_tile *const tile,
bwc_parameter *const parameter);
//==========|==========================|======================|======|=======|====================
uchar t1_decode (bwc_field *const field,
bwc_tile *const tile,
bwc_parameter *const parameter);
#endif

View file

@ -0,0 +1,86 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This file describes a set of functions that can be used to de-/encode bwc ||
|| codeblocks described by the bwc_field structure according to the embedded block ||
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef TIER2_H
#define TIER2_H
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#include "types.h"
/************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] ||
|| ||
\************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! Definition of the initial codestream packet header size. !
! !
\*----------------------------------------------------------------------------------------------*/
#define PACKET_HEADER_SIZE 512
/************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************/
uchar t2_encode (bwc_field *const field,
bwc_tile *const tile);
//==========|==========================|======================|======|=======|====================
uchar parse_packet (bwc_field *const field,
bwc_tile *const tile,
bwc_packet *const packet,
uint64 const body_size);
#endif

View file

@ -0,0 +1,736 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This header defines a set of derrived types that are used to describe and ||
|| instruct the bwc (de-)compression library. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
#ifndef BWC_TYPES_H
#define BWC_TYPES_H
#include <stdio.h>
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#ifdef BWC_SINGLE_PRECISION
#include "prim_types_single.h"
#else
#include "prim_types_double.h"
#endif
#include "constants.h"
#include "mq_types.h"
/************************************************************************************************\
|| ___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____ ||
|| | \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ ||
|| |__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___] ||
|| ||
\************************************************************************************************/
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This union describes a simple data type used to store a single sample of a !
! numerical dataset. The union allows access to the raw bit representation of the !
! data sample. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef union
{
bwc_raw raw; // Raw data sample access.
bwc_float f; // IEEE 754 representation of sample.
} bwc_sample;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure is used to store the metadata and boy of a packed stream. Tile and !
! and paramter index can be supplied to uniquely identify the stream. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint64 size; // Size of packed stream.
uint64 position; // Reading/Writing pos. in the stream.
uchar *access; // Pointer used to parse packed stream.
uchar *memory; // Memory handle for the packed stream.
} bwc_stream;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure defines a single tagtree node which stores the node value (tag), !
! node threshold as well as the address of the parent node. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct node
{
uint64 index; // Index of current node.
uint16 value; // Tagtree node value.
uint16 threshold; // Tagtree node threshold.
struct node* parent; // Parent of current node.
} bwc_tagtree_node;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure defines a tagtree instance with spatial and temporal leaves that !
! can be used to encode codeblock tags - e.g. number of significant bitplanes - to !
! efficiently store them in the compressed codestream. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint64 leavesX, leavesY; // Number of spatial tagtree leafs.
uint64 leavesZ, leavesTS; // Number of temporal tagtree leafs.
bwc_tagtree_node *nodes; // Pointer to the tagtree nodes.
} bwc_tagtree;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure defines a linked list which stores the size, index, and bit pre- !
! cision The string name is used to store the parameter name supplied by the !
! function caller. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct opt
{
char name[24]; // Parameter name.
uint8 id; // Parameter index.
uint64 size; // Parameter size after sub-sampling.
uint8 precision; // Parameter precision.
struct opt *next; // Next element in linked-list.
struct opt *root; // Linked-list root.
} bwc_cmd_opts_ll;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the global information of an uncompressed data set !
! including its spatial and temporal dimensions, number of parameters, file !
! extension and parameter information as well as the codec precision. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint64 nX, nY, nZ; // Spatial size of uncompressed data-set.
uint64 nTS; // Temp. size of uncompressed data-set.
uint8 nPar; // Number of parameters.
uint8 precision; // Flag defining codec precision.
uint8 codec_prec; // Encoder/decoder bit precision.
char f_ext[20]; // Uncompressed data set file extension.
bwc_cmd_opts_ll *parameter; // Command options linked-list.
} bwc_gl_inf;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure stores the numerical dataset/compressed bitstream passed to or !
! returned from the (de)compressor. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
bwc_gl_inf info; // Gloabal info structure.
FILE *fp; // File point to (un)compr. data-set.
struct codestream
{
bwc_stream *data; // Data codestream block.
bwc_stream *aux; // Auxiliary info. codestream block.
bwc_stream *com; // Comment codestream block.
}codestream;
struct field
{
double *d; // Double precision numerical data-set.
float *f; // Single precision numerical data-set.
}field;
} bwc_data;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure defines and stores all necessary data for a compressed codeblock. !
! The coding pass lengths and distortion rate arrays define the convex hull used !
! for during rate controlling. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint64 L[MAXIMUM_NO_PASSES]; // Coding pass lengths of an ecnoded blck.
uint16 S[MAXIMUM_NO_PASSES + 1]; // Distortion rate of an encoded block.
uint8 Kmsbs; // N.o. insignificant leading bitplanes.
uint8 K; // First significant bitplane.
uint8 Z; // Number of coding passes generated.
uchar *data; // Memory handle to compressed bitstream.
} bwc_encoded_cblk;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the control parameters for the current precinct used to !
! instruct the bwc codec to (de)compress a floating point array. The unique state !
! variables are used during length encoding both for quality layer estimation as !
! well as packet assembly. The cp_contr access pointer allows access to the memory !
! chunck employed to store the coding passes contributing to a specific quality !
! layer. The parameter K represents the most significant bitplane present in the !
! current codeblock. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint16 beta; // Codeblock unique state variable.
uint16 beta_est; // State variable used for ql estimation.
uint16 K; // Codeblock spec. significant bitplane.
int16 *memory; // Coding pass contribution to q. layer.
int16 *cp_contr; // Coding pass contribution access ptr.
} bwc_cblk_ctrl;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure is used to store the start and end points as well as the index !
! for a specific codeblock. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint32 idx; // Codeblock index w.r.t. precinct.
uint64 X0, Y0, Z0, TS0; // Codeblock starting point.
uint64 X1, Y1, Z1, TS1; // Codeblock end point.
} bwc_cblk_inf;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the necessary parameters used to define and control a !
! bwc codeblock. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
bwc_cblk_inf info; // Codeblock info structure.
bwc_cblk_ctrl control; // Codeblock control structure.
bwc_encoded_cblk *encoded_block; // Encoded block structure.
} bwc_codeblock;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the control parameters for the current precinct used to !
! instruct the bwc codec to (de)compress a floating point array. The number !
! codeblocks are stored for all spatial and temporal dimensions as well as for the !
! entire precinct. The two tagtrees are employed to record specific properties of !
! the underlying data that is to be compressed. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint64 number_of_codeblocks; // Number of codeblocks w.r.t res. level.
uint16 numCbX, numCbY; // Number of spaatial codeblocks.
uint16 numCbZ, numCbTS; // Number of temporal codeblocks.
bwc_tagtree *tag_inclusion; // Quality layer contribution tagtree.
bwc_tagtree *tag_msbs; // Most significant bit-planes tagtree.
} bwc_prec_ctrl;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! This structure is used to store the start and end points for the current !
! precinct. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint32 X0, Y0, Z0, TS0; // Precinct starting point.
uint32 X1, Y1, Z1, TS1; // Precinct end point.
} bwc_prec_inf;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the necessary parameters used to define and control a !
! bwc precinct. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
bwc_prec_inf info; // Precinct info structure.
bwc_prec_ctrl control; // Precinct control structure.
bwc_codeblock *codeblock; // Precinct specific codeblocks.
} bwc_precinct;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the control parameters for the current subband used to !
! instruct the bwc codec to (de)compress a floating point array. The highband flag !
! is used to identify the type of highband a specific wavelet band belongs to !
! (e.g. HHHH). The quantization step size mantissa and exponent for a subband is !
! stored alongside its actual value as well as the effective step size that is !
! applied to the wavelet coefficients. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uchar highband_flag; // Current wavelet highband type
uint16 Kmax; // Dynamic ranger after transformation.
uint16 qt_mantissa; // Quantization step size mantissa.
uint8 qt_exponent; // Quantization step size exponent.
bwc_float qt_effective_step_size; // Effective quantization step size.
bwc_float qt_step_size; // Quantization step size.
} bwc_subb_ctrl;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure is used to store the start and end points as well as the energy !
! gain factor of the wavelet decomposition that has been applied to the subband !
! data samples during transformation. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint64 X0, Y0, Z0, TS0; // Subband starting point.
uint64 X1, Y1, Z1, TS1; // Subband end point.
bwc_float dwt_gain; // Subband energy gain factor.
} bwc_subb_inf;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the necessary parameters used to define and control a !
! bwc subband. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
bwc_subb_inf info; // Subband info structure.
bwc_subb_ctrl control; // Subband control structure.
bwc_precinct *precinct; // Subband specific precincts.
} bwc_subband;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the parameters used to assemble a codestream packet. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
bwc_stream header; // Packed stream header.
bwc_stream body; // Packed stream body.
uint8 e; // Indicator for packet cb. contributions.
uint32 size; // Codestream packet size.
uint32 p; // Position of curr. packet in codestream.
uint8 c, l, r; // Parameter, Quality Layer and Resolution
// codestream position markers.
} bwc_packet;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the control parameters for the current resolution level !
! used to instruct the bwc codec to (de)compress a floating point array. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint16 numPX, numPY; // Spatial number of precincts.
uint16 numPZ, numPTS; // Temporal number of precincts.
uint8 rcbX, rcbY; // Real spatial codeblock size.
uint8 rcbZ, rcbTS; // Real temporal codeblock size.
uint64 number_of_precincts; // N.o. precincts in resolution level.
uint8 number_of_subbands; // N.o. subbands in resolution level.
} bwc_res_ctrl;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure is used to store the name, start and end points of the current !
! resolution level. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint64 X0, Y0, Z0, TS0; // Resolution level starting point.
uint64 X1, Y1, Z1, TS1; // Resolution level end point.
} bwc_res_inf;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the necessary parameters used to define and control a !
! bwc resolution level. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
bwc_res_inf info; // Resolution level info structure.
bwc_res_ctrl control; // Resolution level control structure.
bwc_subband *subband; // Structure defining a bwc subband.
bwc_packet *packet; // Structure defining a bwc packet.
} bwc_resolution;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure is used to directly access the parameter codeblocks during !
! entropy (de-)encoding to facilitate shared memory parallelization. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
bwc_codeblock *codeblock; // Access to all tile param. codeblocks.
bwc_precinct *precinct; // Access to all tile param. precincts.
bwc_subband *subband; // Access to all tile param. subbands.
} bwc_cblk_access;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the control parameters for the current tile param. used !
! to instruct the bwc codec to (de)compress a floating point array. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint64 number_of_codeblocks; // Number of codeblocks in the tile param.
bwc_float alpha, beta; // Parameters used for normalization.
} bwc_param_ctrl;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure is used to store the name, start and end points as well as the !
! overall size of a parameter tile. Furthermore, the minimum and maximum sample !
! values for the current parameter tile are stored. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint64 size; // Parameter size.
char *name; // Parameter name.
uint64 X0, Y0, Z0, TS0; // Tile parameter starting point.
uint64 X1, Y1, Z1, TS1; // Tile parameter end point.
uint8 precision; // Tile parameter precision.
bwc_float parameter_min; // Min. value of tile parameter.
bwc_float parameter_max; // Max. value of tile parameter.
} bwc_param_inf;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the necessary parameters used to define and control the !
! (de)compression of a bwc tile parameter. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint64 size; // Size of the bwc_float data structure.
bwc_sample *data; // Tile parameter values.
bwc_param_inf info; // Parameter info structure.
bwc_param_ctrl control; // Parameter control structure.
bwc_resolution *resolution; // Tile parameter specific resol. levels.
bwc_cblk_access *access; // Access to all tile param. codeblocks.
} bwc_parameter;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the control parameters for the current tile used to in- !
! struct the bwc codec to (de)compress a floating point array. !
! The slope_min and slope_max values represent the minimum and maximum distortion !
! rates for the compressed data-samples of a specific tile. These values define !
! the distortion-bitrate convex hull used for rate control. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint64 body_size; // Size of the tile parameter body.
uint64 Ltp; // Tile part size.
uint32 header_size; // Approx. size of the tile param. header.
uint64 nPackets; // Number of packets assembled for tile.
uint32 max_Prec; // Max. N.o. precincts in all tile params.
uint16 dflt_param_c; // Default idx when writing COD in header.
uint16 dflt_param_q; // Default idx when writing QCD in header.
uint16 slope_min, slope_max; // Min/Max for the convex hull slp.
} bwc_tile_ctrl;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure is used to store the start and end points of the tile as well as !
! its overall size and index. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint64 size; // Tile size.
uint32 tile_index; // Unique tile index.
uint64 X0, Y0, Z0, TS0; // Tile starting point.
uint64 X1, Y1, Z1, TS1; // Tile end point.
} bwc_tile_inf;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the necessary parameters used to define and control the !
! (de)compression of a bwc tile. The packet_sequence pointer array is used to !
! store the bitstream packet memory hanldes of the underlying tile in a prede- !
! fined sequence according to the bwc_progression_ord parameter. The pointer array !
! is employed during codestream assembly. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
bwc_tile_inf info; // Tile info structure.
bwc_tile_ctrl control; // Tile control structure.
bwc_parameter *parameter; // Tile specific parameter structure.
bwc_packet **packet_sequence; // Tile specific packet sequence.
} bwc_tile;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the global control parameters, including the tile, !
! precinct and codeblock sizes as well as the global number of tiles, used to !
! instruct the bwc codec to (de)compress a floating point array. !
! The number of decompositions (numDecompX etc.) define the number of times the !
! selected wavelet filter (kernelX etc.) is applied alongside each spatial and !
! temporal direction. The global number of decomposition levels is stored in the !
! appropriate variable. !
! The parameters qt_mantissa and qt_exponent define the mantissa and exponent of !
! the global quantization step size appropriate for the specified number of !
! wavelet decomposition levels. The quantization_style signals if the quantization !
! step size for the subsequent subbands should be derrived from the global !
! parameter, or not. The variable Qm represents the dynamic range of the !
! float-to-fixed point transformation employed pre-compression. !
! The bitrate array stores up to 10 bitrate values - average bits per datasample - !
! that define the codestream quality layers. The largest bitrates defines the !
! compression ratio, while the total number of defined bitrates represent the !
! number of (quality)layers. The parameter use_layer stores the index of the !
! quality layer that is used during decompression. The progression order defines !
! the packet sequence as they will appear in the compressed codestream. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uint16 CSsgc; // Flag signaling user control variable.
uchar error_resilience; // Flag signalling error resilience.
uint64 tileSizeX, tileSizeY; // Spatial tile size.
uint64 tileSizeZ, tileSizeTS; // Temporal tile size.
uint64 nTiles; // Global number of tiles.
uint8 precSizeX, precSizeY; // Spatial precinct size.
uint8 precSizeZ, precSizeTS; // Temporal precinct size.
uint8 cbX, cbY; // Spatial codeblock size.
uint8 cbZ, cbTS; // Temporal codeblock size.
bwc_dwt_filter KernelX, KernelY; // Spatial wavelet kernels.
bwc_dwt_filter KernelZ, KernelTS; // Temporal wavelet kernels.
uint8 decompX, decompY; // Number of wavelet decompositions ...
uint8 decompZ, decompTS; // ... for each of the four dimensions.
uint8 nDecomp; // Maximum No. wavelet decompositions.
uint32 qt_exponent, qt_mantissa; // Global qunatization exponent/mantissa.
uint8 Qm; // Q number format range (m).
float *bitrate; // Quality layers defined by bitrate.
uint8 nLayers; // Number of quality layers.
uint8 useLayer; // Quality layer used for decompression.
uint8 guard_bits; // Number of guard bits during quant.
bwc_stream header; // Main codestream header.
bwc_quant_st quantization_style; // Quantization style.
bwc_prog_ord progression; // Packet progression order.
} bwc_gl_ctrl;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure holds all the necessary parameters defining and controling a bwc !
! (de-)compression run. !
! !
! The meter structure is used to store measurements, including important time !
! measurements, for a particular compression run. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
bwc_gl_inf *info; // Gloabal info structure
bwc_gl_ctrl control; // Global control structure
bwc_tile *tile; // Structure defining bwc tile.
struct meter
{
double bpd; // Average bits per datapoint.
double cpr; // Compression ratio
double css; // Codestream size.
struct time
{
double ttl; // Total compression time.
double cpy; // Total time used copying data.
double nrm; // Total time used normalizing data.
double wav; // Total time used for wavelet transform.
double ent; // Total time used for entropy encoding.
double ass; // Total codestream assembly time.
} time;
} meter;
} bwc_field;
#endif

View file

@ -0,0 +1,350 @@
/*====================================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| This is a simple command line tool that uses the Big Whoop library to (de)com- ||
|| press a 2- to 4-dimensional IEEE 754 floating point array. For further infor- ||
|| mation use the --help (-h) argument in the command-line or consult the appro- ||
|| priate README file. ||
|| ||
|| STRUCTS: ||
|| -------- ||
|| DESCRIPTION NEEDED. ||
|| ||
|| DEVELOPMENT HISTORY: ||
|| -------------------- ||
|| ||
|| Date Author Change Id Release Description ||
|| ---- ------ --------- ------- ----------- ||
|| 13.10.2017 Patrick Vogler B87D120 V 0.1.0 source file created ||
|| 26.11.2020 Patrick Vogler B87E7E4 V 0.1.0 Command line tool refac- ||
|| tored. ||
|| ||
|| ||
|| ------------------------------------------------------------------------------------------------------ ||
|| ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are permitted ||
|| provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 ||
|| provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED ||
|| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A ||
|| PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ||
|| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ||
|| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ||
|| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*====================================================================================================================*/
#ifndef BWC_CMDL_H
#define BWC_CMDL_H
/********************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\********************************************************************************************************************/
#include <inttypes.h>
/********************************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] ||
|| ||
\********************************************************************************************************************/
/*------------------------------------------------------------------------------------------------------------------*\
! DESCRIPTION: !
! ------------ !
! !
! These macros define minimum and maximum operators as well as an operator used !
! to evaluate the size of an array. !
! !
! MACROS: !
! ------- !
! Name Description !
! ---- ----------- !
! MAX(x, y) - Returns the maximum value of !
! two values. !
! !
! MIN(x, y) - Returns the minimum value of !
! two values. !
! !
! GET_LEN(x) - Returns the size of an array. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description !
! ---- ------ --------- ------- ----------- !
! 21.03.2018 Patrick Vogler B87D120 V 0.1.0 macros created !
! 16.09.2019 Patrick Vogler B87E7E4 V 0.1.0 Added GET_LEN(X) macro. !
! !
\*------------------------------------------------------------------------------------------------------------------*/
#define MAX(x, y) (((x) < (y))?(y):(x))
#define MIN(x, y) (((x) > (y))?(y):(x))
/*------------------------------------------------------------------------------------------------------------------*\
! DESCRIPTION: !
! ------------ !
! !
! These Constants define codestream markers used to create the embedded code- !
! stream. !
! !
! MACROS: !
! ------- !
! Name Description !
! ---- ----------- !
! SOC - Start of code-stream !
! SGI - Global data-set information !
! SGC - Global control parameters !
! SGR - Global register containing tile !
! bitstream size information !
! SAX - Auxiliary data-set information !
! TLM - Packet lengths: main header !
! PLM - Packet lengths: tile-part !
! PPM - Quantization default !
! COM - Comment !
! EOH - End of header !
! PLT - Packed packet headers: main header !
! PPT - Packed packet headers: tile-part !
! SOT - Start of tile !
! SOP - Start of packet !
! EPH - End of packet header !
! SOD - Start of data !
! EOC - End of code-stream !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description !
! ---- ------ --------- ------- ----------- !
! 01.12.2017 Patrick Vogler B87D120 V 0.1.0 macros created !
! !
\*------------------------------------------------------------------------------------------------------------------*/
#define SOC 0xFF50
#define SGI 0xFF51
#define SGC 0xFF52
#define SAX 0xFF53
#define TLM 0xFF54
#define PLM 0xFF55
#define PPM 0xFF56
#define COM 0xFF57
#define EOH 0xFF58
#define PLT 0xFF60
#define PPT 0xFF61
#define SOT 0xFF90
#define SOP 0xFF91
#define EPH 0xFF92
#define SOD 0xFF93
#define EOC 0xFFFF
/*------------------------------------------------------------------------------------------------------------------*\
! DESCRIPTION: !
! ------------ !
! !
! These macros define flags used for codestream parsing. !
! !
! MACROS: !
! ------- !
! Name Description !
! ---- ----------- !
! CODESTREAM_OK - No errors detected in Codestream !
! !
! CODESTREAM_READ - Codestream has been fully read. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description !
! ---- ------ --------- ------- ----------- !
! 01.08.2019 Patrick Vogler B87D120 V 0.1.0 macros created !
! !
\*------------------------------------------------------------------------------------------------------------------*/
#define CODESTREAM_OK 0x00
#define CODESTREAM_READ 0x80
/*------------------------------------------------------------------------------------------------------------------*\
! DESCRIPTION: !
! ------------ !
! !
! These Constants define common error messages used throughout the bwc library. !
! !
! MACROS: !
! ------- !
! Name Description !
! ---- ----------- !
! CSTERROR - Codestream parser has encoun- !
! tered invalid marker. !
! !
! MEMERROR - Allocation has returned a NULL !
! pointer due to limited memory. !
! !
! RDERROR - Invalid number of bytes read !
! from file. !
! !
! WRTERROR - Invalid number of bytes writ- !
! ten to file. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description !
! ---- ------ --------- ------- ----------- !
! 01.12.2017 Patrick Vogler B87D120 V 0.1.0 macros created !
! !
\*------------------------------------------------------------------------------------------------------------------*/
#define CSTERROR "o##########################################################o\n"\
"| ERROR: Invalid Codestream |\n"\
"o##########################################################o\n"
#define MEMERROR "o##########################################################o\n"\
"| ERROR: Out of Memory |\n"\
"o##########################################################o\n"
#define RDERROR "o##########################################################o\n"\
"| ERROR: Invalid Number of Bytes Read from File. |\n"\
"o##########################################################o\n"
#define WRTERROR "o##########################################################o\n"\
"| ERROR: Invalid Number of Bytes Written to File. |\n"\
"o##########################################################o\n"
#define GET_DIM(x) (sizeof(x)/sizeof(*(x)))
/********************************************************************************************************************\
|| ___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____ ||
|| | \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ ||
|| |__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___] ||
|| ||
\********************************************************************************************************************/
/*------------------------------------------------------------------------------------------------------------------*\
! DESCRIPTION: !
! ------------ !
! !
! This structure defines the attributes of a single argument supported by the bwc !
! command line tool. !
! !
! PARAMETERS: !
! ----------- !
! Name Type Description !
! ---- ---- ----------- !
! active char - Flag indicating if the argu- !
! ment is active. !
! !
! arg_long char - Long form of the argument name. !
! !
! arg_short char - Short form of the argument !
! name. !
! !
! arg_type char - Flag signaling if the argument !
! is optional. !
! !
! type char - Flag signaling the argument !
! type. !
! !
! usage char - A string of 24 characters de- !
! scribing the argument usage. !
! !
! definition char - A string of 1024 characters !
! containing the argument de- !
! scription. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description !
! ---- ------ --------- ------- ----------- !
! 14.02.2019 Patrick Vogler B87D120 V 0.1.0 struct created !
! 26.11.2020 Patrick Vogler B87E7E4 V 0.1.0 clean up !
! !
\*------------------------------------------------------------------------------------------------------------------*/
typedef struct
{
char active;
char arg_long[25];
char arg_short[3];
char arg_type[4];
char type[5];
char usage[25];
char definition[1024];
} bwc_cmdl_args;
/*------------------------------------------------------------------------------------------------------------------*\
! DESCRIPTION: !
! ------------ !
! This structure describes a linked list which stores all the arguments and their !
! attributes supplied to the command line tool by the user. !
! !
! PARAMETERS: !
! ----------- !
! Name Type Description !
! ---- ---- ----------- !
! hash unsigned int(64 bit) - Uniquely identifiable hash that !
! corresponds to the arg/opt name. !
! !
! count unsigned int(8 bit) - Counter that signifies the num- !
! ber of modifier values stored !
! in the linked list node. !
! !
! dim unsigned int(8 bit) - Dimension(s) for which the mod- !
! ifiers have been defined !
! !
! active char - Flag indicating if the arg/opt !
! is active. !
! !
! num_opt double* - Array of numerical modifier !
! values. !
! !
! lit_opt char** - Character array of literal mod- !
! ifier values. !
! !
! DEPENDENCIES: !
! ------------- !
! Name TYPE !
! ---- ---- !
! next opt* !
! !
! root opt* !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description !
! ---- ------ --------- ------- ----------- !
! 26.04.2019 Patrick Vogler B87D120 V 0.1.0 struct created !
! 26.11.2020 Patrick Vogler B87E7E4 V 0.1.0 clean up !
! !
\*------------------------------------------------------------------------------------------------------------------*/
typedef struct arg
{
uint64_t hash;
uint8_t count;
uint8_t dim;
char active;
double *num_opt;
char **lit_opt;
struct arg *next;
struct arg *root;
} bwc_cmdl_arg_node;
#endif

376
1-bwc/public_header.py Normal file
View file

@ -0,0 +1,376 @@
#*================================================================================================*#
#| |#
#| /$$$$$$$ /$$ /$$ /$$ /$$ |#
#| | $$__ $$|__/ | $$ /$ | $$| $$ |#
#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |#
#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |#
#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |#
#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |#
#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |#
#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |#
#| /$$ \ $$ | $$ |#
#| | $$$$$$/ | $$ |#
#| \______/ |__/ |#
#| |#
#| DESCRIPTION: |#
#| ------------ |#
#| |#
#| This file describes python script used to assemble the public header file for |#
#| the BigWhoop compression library. |#
#| |#
#| -------------------------------------------------------------------------------------------- |#
#| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart |#
#| |#
#| Redistribution and use in source and binary forms, with or without modification, are |#
#| permitted provided that the following conditions are met: |#
#| |#
#| (1) Redistributions of source code must retain the above copyright notice, this list of |#
#| conditions and the following disclaimer. |#
#| |#
#| (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 provided with the distribution. |#
#| |#
#| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS |#
#| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |#
#| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |#
#| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |#
#| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |#
#| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |#
#| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |#
#| 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. |#
#| |#
#*================================================================================================*#
#**************************************************************************************************#
#| _ _ _ ___ ____ ____ ___ |#
#| | |\/| |__] | | |__/ | |#
#| | | | | |__| | \ | |#
#| |#
#**************************************************************************************************#
from argparse import ArgumentParser
from math import ceil, floor
from pathlib import Path
import os
import re
import sys
#-------------------------#
# DEFINE CONSTANTS: #
#-------------------------#
tab = " "
text_width = 100
deliminator = tab + "/*" + (text_width - 4 - len(tab)) * "=" + "*/\n"
ubox = tab + "/" + (text_width - 2 - len(tab)) * "*" + "\\\n"
lbox = tab + "\\" + (text_width - 2 - len(tab)) * "*" + "/\n"
sbox = "||"
#----------------------------------------------------------#
# Setup the argument parser for the public header script #
# and parse for the user defined OpenMP and Precision arg. #
#----------------------------------------------------------#
parser = ArgumentParser(description='Public Header Assembly Script')
parser.add_argument('-OMP', dest='OpenMP', action='store_const',
const=True, default=False,
help='OpenMP Parallelization')
parser.add_argument('-Single', dest='SinglePrecision', action='store_const',
const=True, default=False,
help='Compilation using Single Precision Encoder')
args = parser.parse_args()
#----------------------------------------------------------#
# Setup the paths to the source and destination. #
#----------------------------------------------------------#
current_path = Path().absolute()
source = current_path.joinpath('include/library/private')
destination = current_path.joinpath('include/library/public')
if os.path.isdir(destination) == False:
os.mkdir(destination)
header_files = [f for f in os.listdir(source) if os.path.isfile(os.path.join(source, f))]
header_files.remove('prim_types_double.h')
header_files.remove('prim_types_single.h')
print(header_files)
#----------------------------------------------------------#
# Create the I/O stream and write the bwc file header. #
#----------------------------------------------------------#
public_header = open(destination.joinpath('bwc.h'), 'w+')
public_header.write("/*================================================================================================*\\\n"
"|| ||\n"
"|| /$$$$$$$ /$$ /$$ /$$ /$$ ||\n"
"|| | $$__ $$|__/ | $$ /$ | $$| $$ ||\n"
"|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||\n"
"|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||\n"
"|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||\n"
"|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||\n"
"|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||\n"
"|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||\n"
"|| /$$ \ $$ | $$ ||\n"
"|| | $$$$$$/ | $$ ||\n"
"|| \______/ |__/ ||\n"
"|| ||\n"
"|| -------------------------------------------------------------------------------------------- ||\n"
"|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||\n"
"|| ||\n"
"|| Redistribution and use in source and binary forms, with or without modification, are ||\n"
"|| permitted provided that the following conditions are met: ||\n"
"|| ||\n"
"|| (1) Redistributions of source code must retain the above copyright notice, this list of ||\n"
"|| conditions and the following disclaimer. ||\n"
"|| ||\n"
"|| (2) Redistributions in binary form must reproduce the above copyright notice, this list ||\n"
"|| of conditions and the following disclaimer in the documentation and/or other ||\n"
"|| materials provided with the distribution. ||\n"
"|| ||\n"
"|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS ||\n"
"|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||\n"
"|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||\n"
"|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||\n"
"|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||\n"
"|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||\n"
"|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||\n"
"|| TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ||\n"
"|| EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ||\n"
"|| ||\n"
"\*================================================================================================*/\n"
"#ifndef BWC_H\n"
"#define BWC_H\n")
#----------------------------------------------------------#
# Generate the necessary includes for the bwc.h file. #
#----------------------------------------------------------#
title_length = 31
lspaces = ceil((text_width - 2*len(sbox) - title_length - len(tab))/2)
rspaces = floor((text_width - 2*len(sbox) - title_length - len(tab))/2)
public_header.write(ubox + tab + sbox + lspaces * " " + "_ _ _ ____ _ _ _ ___ ____" + rspaces * " " + sbox + "\n" +
tab + sbox + lspaces * " " + "| |\ | | | | | | \ |___" + rspaces * " " + sbox + "\n" +
tab + sbox + lspaces * " " + "| | \| |___ |___ |__| |__/ |___" + rspaces * " " + sbox + "\n" +
tab + sbox + (text_width - 2*len(sbox) - len(tab)) * " " + "||\n" + lbox)
public_header.write(tab + "#include <stdio.h>\n" + tab + "#include <stdint.h>\n\n")
#----------------------------------------------------------#
# Ingest primitive type definitions from the corresponding #
# header files according to the user specified precision. #
#----------------------------------------------------------#
title_length = 62
lspaces = ceil((text_width - 2*len(sbox) - title_length - len(tab))/2)
rspaces = floor((text_width - 2*len(sbox) - title_length - len(tab))/2)
public_header.write(ubox + tab + sbox + lspaces * " " + "___ ____ _ _ _ _ ___ _ _ _ ____ ___ _ _ ___ ____ ____" + rspaces * " " + "||\n" +
tab + sbox + lspaces * " " + "|__] |__/ | |\/| | | | | | |___ | \_/ |__] |___ [__ " + rspaces * " " + "||\n" +
tab + sbox + lspaces * " " + "| | \ | | | | | | \/ |___ | | | |___ ___]" + rspaces * " " + "||\n" +
tab + sbox + (text_width - 2*len(sbox) - len(tab)) * " " + "||\n" + lbox)
if(args.SinglePrecision == True):
file = "prim_types_single.h"
else:
file = "prim_types_double.h"
print_flag = False
with open(source.joinpath(file)) as f:
for line in f:
if("/*" in line and print_flag == 1):
break
if("typedef" in line or print_flag == 1):
print_flag = True
public_header.write(line)
f.close
#----------------------------------------------------------#
# Ingest Macros with 'BWC_' prefix from all header files. #
#----------------------------------------------------------#
title_length = 29
lspaces = ceil((text_width - 2*len(sbox) - title_length - len(tab))/2)
rspaces = floor((text_width - 2*len(sbox) - title_length - len(tab))/2)
public_header.write(ubox + tab + sbox + lspaces * " " + "_ _ ____ ____ ____ ____ ____" + rspaces * " " + "||\n" +
tab + sbox + lspaces * " " + "|\/| |__| | |__/ | | [__ " + rspaces * " " + "||\n" +
tab + sbox + lspaces * " " + "| | | | |___ | \ |__| ___]" + rspaces * " " + "||\n" +
tab + sbox + (text_width - 2*len(sbox) - len(tab)) * " " + "||\n" + lbox)
with open(source.joinpath(file)) as f:
for line in f:
if("#define" in line):
if("MAXIMUM_NO_PASSES" in line or
"PREC_BIT" in line):
if("//" in line):
public_header.write((line.split('/', 1)[0]).rstrip() + '\n')
else:
public_header.write(line)
f.close
printFlg = False
buff = ""
brktCnt = 0
for file in header_files:
with open(source.joinpath(file)) as f:
for line in f:
if("BWC_" in line):
if("ifndef" in line):
next(f)
elif("#define" in line and line[len(line) - len(line.lstrip())] != "/"):
while True:
if("//" in line):
buff = buff + (line.split('/', 1)[0]).rstrip() + '\n'
else:
buff = buff + line
if("\\" not in line):
public_header.write(buff+"\n")
buff = ""
break
line = next(f)
f.close
public_header.write("\n")
#----------------------------------------------------------#
# Ingest enums with 'bwc_' prefix from all header files #
# excluding prim_types_****.h. #
#----------------------------------------------------------#
title_length = 42
lspaces = ceil((text_width - 2*len(sbox) - title_length - len(tab))/2)
rspaces = floor((text_width - 2*len(sbox) - title_length - len(tab))/2)
public_header.write(ubox + tab + sbox + lspaces * " " + "____ ____ _ _ ____ ___ ____ _ _ ___ ____" + rspaces * " " + "||\n" +
tab + sbox + lspaces * " " + "| | | |\ | [__ | |__| |\ | | [__ " + rspaces * " " + "||\n" +
tab + sbox + lspaces * " " + "|___ |__| | \| ___] | | | | \| | ___]" + rspaces * " " + "||\n" +
tab + sbox + (text_width - 2*len(sbox) - len(tab)) * " " + "||\n" + lbox)
delimFlg = False
buff = ""
for file in header_files:
with open(source.joinpath(file)) as f:
for line in f:
if("typedef enum" in line):
while True:
buff = buff + (line.split('/', 1)[0]).rstrip() + '\n'
if("}" in line and ";" in line):
if("bwc_" in line):
if(delimFlg == True):
public_header.write(deliminator)
public_header.write(buff)
delimFlg = True
buff = ""
break
line = next(f)
f.close
#----------------------------------------------------------#
# Ingest derived types with 'bwc_' prefix from all header #
# files excluding prim_types_****.h. #
#----------------------------------------------------------#
title_length = 64
lspaces = ceil((text_width - 2*len(sbox) - title_length - len(tab))/2)
rspaces = floor((text_width - 2*len(sbox) - title_length - len(tab))/2)
public_header.write("\n")
public_header.write(ubox + tab + sbox + lspaces * " " + "___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____" + rspaces * " " + "||\n" +
tab + sbox + lspaces * " " + "| \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ " + rspaces * " " + "||\n" +
tab + sbox + lspaces * " " + "|__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___]" + rspaces * " " + "||\n" +
tab + sbox + (text_width - 2*len(sbox) - len(tab)) * " " + "||\n" + lbox)
printFlg = False
delimFlg = False
preProcFlg = False
buff = ""
brktCnt = 0
for file in header_files:
with open(source.joinpath(file)) as f:
for line in f:
if("typedef struct" in line or
"typedef union" in line):
if("bwc_" in line):
printFlg = True
while True:
buff = buff + (line.split('/', 1)[0]).rstrip() + '\n'
if("{" in line):
brktCnt = brktCnt + 1
if("}" in line):
brktCnt = brktCnt - 1
if(brktCnt == 0):
if("bwc_" in line):
printFlg = True
break
line = next(f)
if (printFlg == True):
if(delimFlg == True):
public_header.write(deliminator)
public_header.write(buff)
delimFlg = True
buff = ""
f.close
#----------------------------------------------------------#
# Ingest public functions with 'bwc_' prefix from all #
# header files excluding prim_types_****.h. #
#----------------------------------------------------------#
title_length = 70
lspaces = ceil((text_width - 2*len(sbox) - title_length - len(tab))/2)
rspaces = floor((text_width - 2*len(sbox) - title_length - len(tab))/2)
public_header.write("\n" + ubox + tab + sbox + lspaces * " " + "___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____" + rspaces * " " + "||\n" +
tab + sbox + lspaces * " " + "|__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ " + rspaces * " " + "||\n" +
tab + sbox + lspaces * " " + "| |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___]" + rspaces * " " + "||\n" +
tab + sbox + (text_width - 2*len(sbox) - len(tab)) * " " + "||\n" + lbox)
public_header.write(tab + "#ifdef __cplusplus\n" +
tab + tab + "extern \"C\" {\n" +
tab + "#endif\n\n")
files = os.listdir("include/library/private")
printFlg = False
ltab = 0
tmp = ""
buff = ""
for file in files:
with open(source.joinpath(file)) as f:
for line in f:
if("#if defined" in line):
line = next(f)
if("(" in line):
tmp = line[0:line.index('(')].strip()
tmp = tmp[tmp.rfind(' '):-1]
else:
tmp = ""
if("bwc_" in tmp and "!" not in line and "#if" not in line):
if("/*" in buff or "*/" in buff or "//" in buff):
buff = ""
if(print_flag == True):
buff = deliminator + buff
else:
print_flag = True
while True:
buff = buff + line[ltab:len(line)]
if(");" in line):
break
line = next(f)
public_header.write(buff)
buff = line
f.close
public_header.write("\n" + tab + "#ifdef __cplusplus\n" +
tab + tab + "}\n" +
tab + "#endif\n")
public_header.write("#endif")
public_header.close

View file

@ -0,0 +1,421 @@
!*================================================================================================*!
!| |!
!| /$$$$$$$ /$$ /$$ /$$ /$$ |!
!| | $$__ $$|__/ | $$ /$ | $$| $$ |!
!| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |!
!| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |!
!| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |!
!| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |!
!| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |!
!| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |!
!| /$$ \ $$ | $$ |!
!| | $$$$$$/ | $$ |!
!| \______/ |__/ |!
!| |!
!| DESCRIPTION: |!
!| ------------ |!
!| |!
!| This file defines a Fortran interface for the Big Whoop compression library. |!
!| |!
!| -------------------------------------------------------------------------------------------- |!
!| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart |!
!| |!
!| Redistribution and use in source and binary forms, with or without modification, are |!
!| permitted provided that the following conditions are met: |!
!| |!
!| (1) Redistributions of source code must retain the above copyright notice, this list of |!
!| conditions and the following disclaimer. |!
!| |!
!| (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 provided with the distribution. |!
!| |!
!| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS |!
!| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |!
!| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |!
!| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |!
!| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |!
!| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |!
!| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |!
!| 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. |!
!| |!
!*================================================================================================*!
module bwc
!************************************************************************************************!
!| _ _ _ ____ _ _ _ ___ ____ |!
!| | |\ | | | | | | \ |___ |!
!| | | \| |___ |___ |__| |__/ |___ |!
!| |!
!************************************************************************************************!
use, intrinsic :: iso_c_binding, only: C_PTR, C_INT64_T, C_INT32_T, C_INT16_T, C_INT8_T, &
C_INT, C_DOUBLE, C_CHAR, C_SIGNED_CHAR
IMPLICIT NONE
PRIVATE
!************************************************************************************************!
!| ____ ____ _ _ ____ ___ ____ _ _ ___ ____ |!
!| | | | |\ | [__ | |__| |\ | | [__ |!
!| |___ |__| | \| ___] | | | | \| | ___] |!
!| |!
!************************************************************************************************!
ENUM, BIND(C)
enumerator :: bwc_dwt_9_7 = 0, &
bwc_dwt_5_3 = 1, &
bwc_dwt_haar = 2
END ENUM
!*==============================================================================================*!
ENUM, BIND(C)
enumerator :: bwc_prog_LRCP = 0
END ENUM
!*==============================================================================================*!
ENUM, BIND(C)
enumerator :: bwc_qt_none = 0, &
bwc_qt_derived = 1
END ENUM
!*==============================================================================================*!
ENUM, BIND(C)
enumerator :: bwc_tile_sizeof = 0, &
bwc_tile_numbof = 1
END ENUM
!************************************************************************************************!
!| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ |!
!| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ |!
!| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] |!
!| |!
!************************************************************************************************!
interface
function initialize_data_f(field, nX, nY, nZ, nTS, nPar, file_extension) result(data) &
BIND(C, NAME="bwc_initialize_data")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
TYPE(C_PTR) :: data
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT16_T), VALUE :: nX, nY, nZ
INTEGER(KIND=C_INT8_T), VALUE :: nTS, nPar
!*-----------------------*!
! DEFINE CHAR VARIABLES: !
!*-----------------------*!
CHARACTER(KIND=C_CHAR) :: file_extension(*)
end function initialize_data_f
!*============================================================================================*!
subroutine add_param_f(data, name, sample, dim, precision) &
BIND(C, NAME="bwc_add_param")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: data
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT16_T), VALUE :: sample
INTEGER(KIND=C_INT8_T), VALUE :: precision
INTEGER(KIND=C_SIGNED_CHAR), VALUE :: dim
!*-----------------------*!
! DEFINE CHAR VARIABLES: !
!*-----------------------*!
CHARACTER(KIND=C_CHAR) :: name(*)
end subroutine add_param_f
!*============================================================================================*!
subroutine get_data_f(data, buffer, size) &
BIND(C, NAME="bwc_get_data")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: data
TYPE(C_PTR), VALUE :: buffer
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT64_T), Value :: size
end subroutine get_data_f
!*============================================================================================*!
subroutine free_data_f(data) &
BIND(C, NAME="bwc_free_data")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: data
end subroutine free_data_f
!*============================================================================================*!
subroutine kill_compression_f(field) &
BIND(C, NAME="bwc_kill_compression")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
end subroutine kill_compression_f
!*============================================================================================*!
function initialize_field_f(data) result(field) &
BIND(C, NAME="bwc_initialize_field")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: data
TYPE(C_PTR) :: field
end function initialize_field_f
!*============================================================================================*!
subroutine set_error_resilience_f(field) &
BIND(C, NAME="bwc_set_error_resilience")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
end subroutine set_error_resilience_f
!*============================================================================================*!
subroutine set_quantization_style_f(field, quantization_style) &
BIND(C, NAME="bwc_set_quantization_style")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT), VALUE :: quantization_style
end subroutine set_quantization_style_f
!*============================================================================================*!
subroutine set_quantization_step_size_f(field, delta) &
BIND(C, NAME="bwc_set_quantization_step_size")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
!*-----------------------*!
! DEFINE FLOAT VARIABLES: !
!*-----------------------*!
REAL(KIND=C_DOUBLE), VALUE :: delta
end subroutine set_quantization_step_size_f
!*============================================================================================*!
subroutine set_progression_f(field, progression) &
BIND(C, NAME="bwc_set_progression")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT), VALUE :: progression
end subroutine set_progression_f
!*============================================================================================*!
subroutine set_kernels_f(field, KernelX, KernelY, KernelZ, KernelTS) &
BIND(C, NAME="bwc_set_kernels")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT), VALUE :: KernelX, KernelY
INTEGER(KIND=C_INT), VALUE :: KernelZ, KernelTS
end subroutine set_kernels_f
!*============================================================================================*!
subroutine set_decomp_f(field, decompX, decompY, decompZ, decompTS) &
BIND(C, NAME="bwc_set_decomp")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT8_T), VALUE :: decompX, decompY
INTEGER(KIND=C_INT8_T), VALUE :: decompZ, decompTS
end subroutine set_decomp_f
!*============================================================================================*!
subroutine set_precincts_f(field, pX, pY, pZ, pTS) &
BIND(C, NAME="bwc_set_precincts")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT8_T), VALUE :: pX, pY
INTEGER(KIND=C_INT8_T), VALUE :: pZ, pTS
end subroutine set_precincts_f
!*============================================================================================*!
subroutine set_codeblocks_f(field, cbX, cbY, cbZ, cbTS) &
BIND(C, NAME="bwc_set_codeblocks")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT8_T), VALUE :: cbX, cbY
INTEGER(KIND=C_INT8_T), VALUE :: cbZ, cbTS
end subroutine set_codeblocks_f
!*============================================================================================*!
subroutine set_qm_f(field, Qm) &
BIND(C, NAME="bwc_set_qm")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT8_T), VALUE :: Qm
end subroutine set_qm_f
!*============================================================================================*!
subroutine set_tiles_f(field, tilesX, tilesY, tilesZ, tilesTS, instr) &
BIND(C, NAME="bwc_set_tiles")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT64_T), VALUE :: tilesX, tilesY, tilesZ
INTEGER(KIND=C_INT16_T), VALUE :: tilesTS
INTEGER(KIND=C_INT), VALUE :: instr
end subroutine set_tiles_f
!*============================================================================================*!
function create_compression_f(field, rate_control) result(error_flag) &
BIND(C, NAME="bwc_create_compression")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT8_T) :: error_flag
!*-----------------------*!
! DEFINE CHAR VARIABLES: !
!*-----------------------*!
CHARACTER(KIND=C_CHAR) :: rate_control(*)
end function create_compression_f
!*============================================================================================*!
function compress_f(field, data) result(error_flag) &
BIND(C, NAME="bwc_compress")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
TYPE(C_PTR), VALUE :: data
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT8_T) :: error_flag
end function compress_f
!*============================================================================================*!
function create_decompression_f(data, layer) result(field) &
BIND(C, NAME="bwc_create_decompression")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR) :: field
TYPE(C_PTR), VALUE :: data
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT8_T), VALUE :: layer
end function create_decompression_f
!*============================================================================================*!
function decompress_f(field, data) result(error_flag) &
BIND(C, NAME="bwc_decompress")
IMPORT
!*-----------------------*!
! DEFINE POINTERS: !
!*-----------------------*!
TYPE(C_PTR), VALUE :: field
TYPE(C_PTR), VALUE :: data
!*-----------------------*!
! DEFINE INT VARIABLES: !
!*-----------------------*!
INTEGER(KIND=C_INT8_T) :: error_flag
end function decompress_f
end interface
!************************************************************************************************!
!| _ _ _ ___ ____ ____ ____ ____ ____ ____ |!
!| | |\ | | |___ |__/ |___ |__| | |___ |!
!| | | \| | |___ | \ | | | |___ |___ |!
!| |!
!************************************************************************************************!
public :: bwc_dwt_9_7, &
bwc_dwt_5_3, &
bwc_dwt_haar
public :: bwc_prog_LRCP
public :: bwc_qt_none, &
bwc_qt_derived
public :: bwc_tile_sizeof, &
bwc_tile_numbof
public :: bwc_initialize_data, &
bwc_get_data, &
bwc_free_data
public :: bwc_initialize_field, &
bwc_add_param, &
bwc_kill_compression
public :: bwc_set_error_resilience, &
bwc_set_quantization_style, &
bwc_set_quantization_step_size, &
bwc_set_progression, &
bwc_set_kernels, &
bwc_set_decomp, &
bwc_set_precincts, &
bwc_set_codeblocks, &
bwc_set_qm, &
bwc_set_tiles,
public :: bwc_create_compression, &
bwc_compress, &
bwc_create_decompression, &
bwc_decompress
end module bwc

View file

@ -0,0 +1,214 @@
#/=====================================================================================================================\#
#| |#
#| /$$$$$$$ /$$ /$$ /$$ /$$ |#
#| | $$__ $$|__/ | $$ /$ | $$| $$ |#
#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |#
#! | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |#
#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |#
#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |#
#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |#
#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |#
#| /$$ \ $$ | $$ |#
#| | $$$$$$/ | $$ |#
#| \______/ |__/ |#
#| |#
#| DESCRIPTION: |#
#| ------------ |#
#| |#
#| 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 |#
#| |#
#| Redistribution and use in source and binary forms, with or without modification, are permitted |#
#| provided that the following conditions are met: |#
#| |#
#| (1) Redistributions of source code must retain the above copyright notice, this list of |#
#| conditions and the following disclaimer. |#
#| |#
#| (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 |#
#| provided with the distribution. |#
#| |#
#| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |#
#| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |#
#| PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |#
#| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |#
#| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |#
#| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |#
#| 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
from numpy.ctypeslib import ndpointer
from enum import Enum
libbwc = ctypes.cdll.LoadLibrary("../../../lib/libbwc.so")
#/=====================================================================================================================\#
#| ____ ____ _ _ ____ ___ ____ _ _ ___ ____ |#
#| | | | |\ | [__ | |__| |\ | | [__ |#
#| |___ |__| | \| ___] | | | | \| | ___] |#
#| |#
#\=====================================================================================================================/#
class _const():
class DWT(Enum):
CDF_9_7 = 0
LEGALL_5_3 = 1
HAAR = 2
class PROG(Enum):
LRCP = 0
class QT(object):
NONE = 0
DERIVED = 1
class TILE(Enum):
SIZEOF = 0
NUMBOF = 1
const = _const()
#/=====================================================================================================================\#
#| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ |#
#| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ |#
#| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] |#
#| |#
#\=====================================================================================================================/#
def free_data(data):
fun = libbwc.bwc_free_data
fun.restype = None
fun.argtypes = [ctypes.c_void_p]
fun(data)
#=======================================================================================================================#
def initialize_data(data, nX, nY, nZ, nTS, nPar, file_extension):
fun = libbwc.bwc_initialize_data
fun.restype = ctypes.c_void_p
fun.argtypes = [ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
ctypes.c_uint64,
ctypes.c_uint64,
ctypes.c_uint64,
ctypes.c_uint16,
ctypes.c_uint8,
ctypes.c_char_p]
return ctypes.c_void_p(fun(data, nX, nY, nZ, nTS, nPar, file_extension.encode('utf-8')))
#=======================================================================================================================#
def get_data(data, buffer, size):
fun = libbwc.bwc_get_data
fun.restype = None
fun.argtypes = [ctypes.c_void_p,
ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
ctypes.c_uint64]
fun(data, buffer, size)
#=======================================================================================================================#
def add_param(data, name, sample, dim, precision):
fun = libbwc.bwc_add_param
fun.restype = None
fun.argtypes = [ctypes.c_void_p,
ctypes.c_char_p,
ctypes.c_uint16,
ctypes.c_uint8,
ctypes.c_uint8]
fun(data, name.encode('utf-8'), sample, dim, precision)
#=======================================================================================================================#
def kill_compression(field):
fun = libbwc.bwc_kill_compression
fun.restype = None
fun.argtypes = [ctypes.c_void_p]
fun(field)
#=======================================================================================================================#
def initialize_field(data):
fun = libbwc.bwc_initialize_field
fun.restype = ctypes.c_void_p
fun.argtypes = [ctypes.c_void_p]
return ctypes.c_void_p(fun(data))
#=======================================================================================================================#
def set_codeblocks(field, cbX, cbY, cbZ, cbTS):
fun = libbwc.bwc_set_codeblocks
fun.restype = None
fun.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8]
fun(field, cbX, cbY, cbZ, cbTS)
#=======================================================================================================================#
def set_decomp(field, decompX, decompY, decompZ, decompTS):
fun = libbwc.bwc_set_decomp
fun.restype = None
fun.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8]
fun(field, decompX, decompY, decompZ, decompTS)
#=======================================================================================================================#
def set_qm(field, Qm):
fun = libbwc.bwc_set_qm
fun.restype = None
fun.argtypes = [ctypes.c_void_p, ctypes.c_int8]
fun(field, Qm)
#=======================================================================================================================#
def set_tiles(field, tilesX, tilesY, tilesZ, tilesTS, instr):
fun = libbwc.bwc_set_tiles
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(field, tilesX, tilesY, tilesZ, tilesTS, instr.encode('utf-8'))
#=======================================================================================================================#
def set_precincts(field, pX, pY, pZ, pTS):
fun = libbwc.bwc_set_precincts
fun.restype = None
fun.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8]
fun(field, pX, pY, pZ, pTS)
#=======================================================================================================================#
def create_compression(field, rate_control):
fun = libbwc.bwc_create_compression
fun.restype = None
fun.argtypes = [ctypes.c_void_p, ctypes.c_char_p]
fun(field, rate_control.encode('utf-8'))
#=======================================================================================================================#
def compress(field, data):
fun = libbwc.bwc_compress
fun.restype = None
fun.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
fun(field, data)
#=======================================================================================================================#
def create_decompression(field, data):
fun = libbwc.bwc_create_decompression
fun.restype = ctypes.c_void_p
fun.argtypes = [ctypes.c_void_p, ctypes.c_uint8]
return ctypes.c_void_p(fun(field, data))
#=======================================================================================================================#
def decompress(field, data):
fun = libbwc.bwc_decompress
fun.restype = None
fun.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
fun(field, data)

File diff suppressed because it is too large Load diff

123
1-bwc/src/library/CMakeLists.txt Executable file
View file

@ -0,0 +1,123 @@
#*================================================================================================*#
#| |#
#| /$$$$$$$ /$$ /$$ /$$ /$$ |#
#| | $$__ $$|__/ | $$ /$ | $$| $$ |#
#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |#
#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |#
#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |#
#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |#
#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |#
#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |#
#| /$$ \ $$ | $$ |#
#| | $$$$$$/ | $$ |#
#| \______/ |__/ |#
#| |#
#| DESCRIPTION: |#
#| ------------ |#
#| |#
#| Defines the cmake script for the libbwc library. |#
#| |#
#| -------------------------------------------------------------------------------------------- |#
#| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart |#
#| |#
#| Redistribution and use in source and binary forms, with or without modification, are |#
#| permitted provided that the following conditions are met: |#
#| |#
#| (1) Redistributions of source code must retain the above copyright notice, this list of |#
#| conditions and the following disclaimer. |#
#| |#
#| (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 provided with the distribution. |#
#| |#
#| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS |#
#| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |#
#| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |#
#| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |#
#| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |#
#| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |#
#| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |#
#| 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. |#
#| |#
#*================================================================================================*#
#----------------------------------------------------------#
# Assemble the public header for the BigWhoop library #
#----------------------------------------------------------#
set(PYTHON_ARGUMENT "")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
if(OPENMP_FOUND)
set(PYTHON_ARGUMENT ${PYTHON_ARGUMENT} -OMP)
endif()
endif()
if("${PREC}" STREQUAL "Single")
set(PYTHON_ARGUMENT ${PYTHON_ARGUMENT} -Single)
endif()
execute_process(COMMAND python3 public_header.py ${PYTHON_ARGUMENT}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
#----------------------------------------------------------#
# Set the linking type according to user choice and add #
# the library to the current project #
#----------------------------------------------------------#
if("${LINK}" STREQUAL "Static")
set(BWC_LINK "STATIC")
else()
set(BWC_LINK "SHARED")
endif()
add_library(bwclib ${BWC_LINK} bitstream.c
libbwc.c
codestream.c
dwt.c
mq.c
tier1.c
tier2.c
tagtree.c)
#----------------------------------------------------------#
# Set the target compile definition for the encoder/decod- #
# er bit precision. #
#----------------------------------------------------------#
if("${PREC}" STREQUAL "Single")
target_compile_definitions(bwclib PRIVATE -DBWC_SINGLE_PRECISION)
else()
target_compile_definitions(bwclib PRIVATE -DBWC_DOUBLE_PRECISION)
endif()
#----------------------------------------------------------#
# Set the Version and SOVersion and define the public API #
# for the BigWhoop library. #
#----------------------------------------------------------#
set_target_properties(bwclib PROPERTIES VERSION ${BWC_VERSION}
SOVERSION ${BWC_VERSION_MAJOR}
PUBLIC_HEADER ${CMAKE_SOURCE_DIR}/include/library/public/bwc.h)
#----------------------------------------------------------#
# Setup up the include directory for the BigWhoop library. #
#----------------------------------------------------------#
target_include_directories(bwclib PRIVATE ${CMAKE_SOURCE_DIR}/include/library/private
PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/library/public>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
#----------------------------------------------------------#
# Link the BigWhoop library to the math.h library. #
#----------------------------------------------------------#
target_link_libraries(bwclib PRIVATE m)
#----------------------------------------------------------#
# Setup the install directories and target exporting for #
# config-file packaging. #
#----------------------------------------------------------#
install( TARGETS bwclib
EXPORT bwc-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
#----------------------------------------------------------#
# Define the output name for the BigWhoop library. #
#----------------------------------------------------------#
set_property(TARGET bwclib PROPERTY OUTPUT_NAME bwc)

988
1-bwc/src/library/bitstream.c Executable file
View file

@ -0,0 +1,988 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This file describes a set of functions that can be used to create, manipulate ||
|| and terminate a bitstream. These functions facilitate the creation or reading ||
|| of a compressed bwc codestream and can emit/extract information on a per bit, ||
|| symbol (64-bit) or string basis. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
/************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************************/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libbwc.h"
/************************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: uint32 bytes_used(bitstream *const stream) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! This function is used to evaluate the number of bytes that have already been !
! written to the allocated bitstream memory block. !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! stream bitstream* - Structure that !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! unsigned int(32 bit) - Number of bites that have been written to the !
! bitstream. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 13.05.2019 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
uint64
bytes_used(bitstream const *const stream)
{
if(stream->T == 0xFF)
{
return stream->L + 1;
}
else
{
return stream->L;
}
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: bitstream* bwc_init_stream(uchar* memory, uint32 size, char instr) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! This function is used to initialize a bwc bitstream. For encoding, a null pointer !
! is passed as a memory handle and the function will allocate a memory block with the !
! specified stream size. For decoding, a valid memory handle, passed by the function !
! caller, will be stored in the bitstream structure. The byte buffer counter t, !
! stream size Lmax and size increment are initialized with their appropriate values. !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! size unsigned int(32 bit) - Initial size of the bwc stream. !
! !
! memory unsigned char - Memory handle for the bwc stream memory !
! block. !
! !
! instr char - Constant used to instruct the field !
! initialization. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! bitstream* - Memory handle for the initialized bwc stream. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 19.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
bitstream*
init_stream(uchar* memory, uint32 size, char instr)
{
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
bitstream *stream;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(instr == 'c' || instr == 'd');
/*--------------------------------------------------------*\
! Allocate the bwc stream structure. !
\*--------------------------------------------------------*/
stream = calloc(1, sizeof(bitstream));
if(!stream)
{
// memory allocation error
fprintf(stderr, MEMERROR);
return NULL;
}
/*--------------------------------------------------------*\
! Evaluate if a valid memory handle has been passed by the !
! function caller. !
\*--------------------------------------------------------*/
if(!memory)
{
/*--------------------------------------------------------*\
! If no valid memory handle has been passed, allocate a !
! memory block with the specifiec stream size. !
\*--------------------------------------------------------*/
stream->memory = calloc(size, sizeof(uchar));
if(!stream->memory)
{
// memory allocation error
fprintf(stderr, MEMERROR);
return NULL;
}
}
else
{
/*--------------------------------------------------------*\
! If a valid memory handle has been passed for decoding, !
! save the memory handle in the bwc stream structure. !
\*--------------------------------------------------------*/
stream->memory = memory;
}
/*--------------------------------------------------------*\
! Initialize the byte buffer counter, stream size and size !
! increment for the current stream. !
\*--------------------------------------------------------*/
stream->t = (instr == 'c') ? 8 : 0;
stream->Lmax = size;
stream->size_incr = (uint64)(size / 2);
/*--------------------------------------------------------*\
! Return the stream memory handle. !
\*--------------------------------------------------------*/
return stream;
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void bwc_emit_chunck(bitstream *const stream, const uchar* string, const uint64 length) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! This function is used to write an additional chunck of size length to a bwc bitstream. !
! !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! stream bitstream* - Structure used to assemble a bwc bit- !
! bitstream. !
! !
! chunck unsigned char* - Memory handle for a data block that is !
! to be written to the bwc bitstream. !
! !
! size unsigned int(64 bit) - Size of the data block. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 22.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
void
emit_chunck(bitstream *const stream, const uchar* chunck, const uint64 size)
{
/*-----------------------*\
! DEFINE INT VARIABLES: !
\*-----------------------*/
uint64 Lreq;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(stream);
assert(chunck);
/*--------------------------------------------------------*\
! Evaluate the memory block size if the current chunck of !
! data is written to the stream. !
\*--------------------------------------------------------*/
Lreq = (bytes_used(stream) + size);
/*--------------------------------------------------------*\
! Check if the enough memory has been allocated for the !
! stream to store the additional data chunck. !
\*--------------------------------------------------------*/
if(Lreq > stream->Lmax)
{
/*--------------------------------------------------------*\
! If the stream is not large enough, check if this is due !
! to an error encountered in a previous writing operation !
\*--------------------------------------------------------*/
if(!stream->error)
{
/*--------------------------------------------------------*\
! If the error flag is not set, increase the stream size !
! until it is large enough to store the additional data !
! chunck. !
\*--------------------------------------------------------*/
while(Lreq > stream->Lmax)
{
stream->Lmax += stream->size_incr + size;
stream->size_incr = (uint64)(stream->Lmax / 2);
}
/*--------------------------------------------------------*\
! Reallocate the stream data block. !
\*--------------------------------------------------------*/
stream->memory = realloc(stream->memory, stream->Lmax);
if(!stream->memory)
{
// memory allocation error
stream->error |= 1;
stream->Lmax = 0;
return;
}
}
else
{
/*--------------------------------------------------------*\
! Exit to function caller if error flag has been set. !
\*--------------------------------------------------------*/
return;
}
}
/*--------------------------------------------------------*\
! Copy the additional data to the stream memory block. !
\*--------------------------------------------------------*/
memcpy(stream->memory + stream->L, chunck, size);
/*--------------------------------------------------------*\
! Increment the number of bytes written to the stream with !
! the size of the newly added data chunck. !
\*--------------------------------------------------------*/
stream->L += size;
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! stream bitstream* - Structure used to assemble a bwc bit- !
! bitstream. !
! !
! symbol unsigned int(64 bit) - Symbol that is to be written to the bwc !
! bitstream. !
! !
! size unsigned int(8 bit) - Number of significant bytes in the !
! symbol. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 22.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
void
emit_symbol(bitstream *const stream, const uint64 symbol, const uint8 size)
{
/*-----------------------*\
! DEFINE INT VARIABLES: !
\*-----------------------*/
uint8 byte;
int8 i;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(stream);
/*--------------------------------------------------------*\
! Check if the enough memory has been allocated for the !
! stream to store the additional symbol. !
\*--------------------------------------------------------*/
if((bytes_used(stream) + size) > stream->Lmax)
{
/*--------------------------------------------------------*\
! If the stream is not large enough, check if this is due !
! to an error encountered in a previous writing operation !
\*--------------------------------------------------------*/
if(!stream->error)
{
/*--------------------------------------------------------*\
! If the error flag is not set, increment the stream size !
! to store the additional symbol. !
\*--------------------------------------------------------*/
stream->Lmax += stream->size_incr;
stream->size_incr = (uint64)(stream->Lmax / 2);
/*--------------------------------------------------------*\
! Reallocate the stream data block. !
\*--------------------------------------------------------*/
stream->memory = realloc(stream->memory, stream->Lmax);
if(!stream->memory)
{
// memory allocation error
stream->error |= 1;
stream->Lmax = 0;
return;
}
}
else
{
/*--------------------------------------------------------*\
! Exit to function caller if error flag has been set. !
\*--------------------------------------------------------*/
return;
}
}
/*--------------------------------------------------------*\
! Copy the additional symbol to the stream memory block !
! one byte at a time and Increment the number of bytes !
! written to the stream. !
\*--------------------------------------------------------*/
for(i = size; i --> 0;)
{
byte = (uint8)((symbol >> (8 * i)) & 0xFF);
stream->memory[stream->L++] = (uchar)byte;
}
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void bwc_emit_bit(bitstream *const stream, const uint64 bit) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! stream bitstream* - Structure used to assemble a bwc bit- !
! bitstream. !
! !
! bit unsigned int(64 bit) - Bit that is to be written to the bwc !
! bitstream. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 22.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
void
emit_bit(bitstream *const stream, const uint64 bit)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(stream);
/*--------------------------------------------------------*\
! Decrement the bit buffer counter. !
\*--------------------------------------------------------*/
stream->t--;
/*--------------------------------------------------------*\
! If the bit is significant, store the information at the !
! appropriate position in the bit buffer. !
\*--------------------------------------------------------*/
if(bit)
{
stream->T |= (1 << stream->t);
}
/*--------------------------------------------------------*\
! Check the bit buffer counter to see if the bit buffer is !
! full. !
\*--------------------------------------------------------*/
if(!stream->t)
{
/*--------------------------------------------------------*\
! Check if the enough memory has been allocated for the !
! stream to store the additional byte. !
\*--------------------------------------------------------*/
if(bytes_used(stream) + 1 > stream->Lmax)
{
/*--------------------------------------------------------*\
! If the stream is not large enough, check if this is due !
! to an error encountered in a previous writing operation !
\*--------------------------------------------------------*/
if(!stream->error)
{
/*--------------------------------------------------------*\
! If the error flag is not set, increment the stream size !
! to store the additional byte. !
\*--------------------------------------------------------*/
stream->Lmax += stream->size_incr;
stream->size_incr = (uint64)(stream->Lmax / 2);
/*--------------------------------------------------------*\
! Reallocate the stream data block. !
\*--------------------------------------------------------*/
stream->memory = realloc(stream->memory, stream->Lmax);
if(!stream->memory)
{
// memory allocation error
stream->error |= 1;
stream->Lmax = 0;
return;
}
}
else
{
/*--------------------------------------------------------*\
! Exit to function caller if error flag has been set. !
\*--------------------------------------------------------*/
return;
}
}
/*--------------------------------------------------------*\
! Copy the additional byte to the stream memory block and !
! increment the number of bytes written to the stream. !
\*--------------------------------------------------------*/
stream->memory[stream->L++] = (uchar)stream->T;
/*--------------------------------------------------------*\
! Reset the byte buffer counter. If the current buffer has !
! a value of 255, limit the counter to 7 bits to ensure !
! that the range FFFF to FF80 is reserved for the code- !
! stream markers. !
\*--------------------------------------------------------*/
if(stream->T == 0xFF)
{
stream->t = 7;
}
else
{
stream->t = 8;
}
/*--------------------------------------------------------*\
! Reset the byte buffer. !
\*--------------------------------------------------------*/
stream->T = 0;
}
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! stream bitstream* - Structure used to assemble a bwc bit- !
! bitstream. !
! !
! size unsigned int(64 bit) - Size of the data block. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! uchar* - Data chunck requested by the function caller. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 22.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
uchar*
get_chunck(bitstream *const stream, const uint64 size)
{
/*-----------------------*\
! DEFINE CHAR VARIABLES: !
\*-----------------------*/
uchar *tmp;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(stream);
/*--------------------------------------------------------*\
! Check if the number of bytes to be read from the stream !
! does not exceed the number of bytes still present in its !
! memory block. !
\*--------------------------------------------------------*/
if(bytes_used(stream) + size <= stream->Lmax)
{
/*--------------------------------------------------------*\
! Allocate a temporary array used to store the bytes that !
! are extracted from the stream. !
\*--------------------------------------------------------*/
tmp = calloc(size, sizeof(uchar));
if(!tmp)
{
// memory allocation error
fprintf(stderr, MEMERROR);
return NULL;
}
/*--------------------------------------------------------*\
! Copy the bytes requested from the function caller from !
! the stream to the temporary data block. !
\*--------------------------------------------------------*/
memcpy(tmp, stream->memory + stream->L, size);
/*--------------------------------------------------------*\
! Increment the number of bytes read from the bitstream. !
\*--------------------------------------------------------*/
stream->L += size;
/*--------------------------------------------------------*\
! Return the temporary data block to the function caller. !
\*--------------------------------------------------------*/
return tmp;
}
else
{
/*--------------------------------------------------------*\
! If the requested block size exceeds the information left !
! in the bitstream, set the bitstream error flag and !
! return a NULL pointer. !
\*--------------------------------------------------------*/
stream->error |= 1;
return NULL;
}
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! stream bitstream* - Structure used to assemble a bwc bit- !
! bitstream. !
! !
! size unsigned int(8 bit) - Number of significant bytes in the !
! symbol. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! uchar* - Symbol requested by the function caller. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
uint64
get_symbol(bitstream *const stream, const uint8 size)
{
/*-----------------------*\
! DEFINE INT VARIABLES: !
\*-----------------------*/
uint64 symbol;
uint8 byte;
int8 i;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(stream);
/*--------------------------------------------------------*\
! Check if the number of bytes to be read from the stream !
! does not exceed the number of bytes still present in its !
! memory block. !
\*--------------------------------------------------------*/
if(bytes_used(stream) + size <= stream->Lmax)
{
/*--------------------------------------------------------*\
! Extract the requested information from the bitstream one !
! byte at a time. Adjust the number of bytes read from the !
! stream accordingly. !
\*--------------------------------------------------------*/
for(i = size, symbol = 0; i --> 0;)
{
byte = (uint8)stream->memory[stream->L++];
symbol |= ((uint64)byte << (i * 8));
}
/*--------------------------------------------------------*\
! Return the symbol to the function caller. !
\*--------------------------------------------------------*/
return symbol;
}
else
{
/*--------------------------------------------------------*\
! If the requested block size exceeds the information left !
! in the bitstream, set the bitstream error flag and !
! return zero. !
\*--------------------------------------------------------*/
stream->error |= 1;
return 0;
}
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
uchar
get_bit(bitstream *const stream)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(stream);
if(!stream->t)
{
if(stream->L == stream->Lmax)
{
return 1;
}
if(stream->T == 0xFF)
{
stream->t = 7;
}
else
{
stream->t = 8;
}
stream->T = (uint16)stream->memory[stream->L++];
}
stream->t--;
return ((stream->T & (1 << stream->t)) >> stream->t);
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
void
flush_stream(bitstream *const stream)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(stream);
/*--------------------------------------------------------*\
! Check the if the bit buffer contains information. !
\*--------------------------------------------------------*/
if(stream->t != 8)
{
/*--------------------------------------------------------*\
! Check if the enough memory has been allocated for the !
! stream to store the additional byte. !
\*--------------------------------------------------------*/
if((bytes_used(stream) + 1) > stream->Lmax)
{
/*--------------------------------------------------------*\
! If the stream is not large enough, check if this is due !
! to an error encountered in a previous writing operation !
\*--------------------------------------------------------*/
if(!stream->error)
{
/*--------------------------------------------------------*\
! If the error flag is not set, increment the stream size !
! to store the additional byte. !
\*--------------------------------------------------------*/
stream->Lmax += stream->size_incr;
stream->size_incr = (uint64)(stream->Lmax / 2);
/*--------------------------------------------------------*\
! Reallocate the stream data block. !
\*--------------------------------------------------------*/
stream->memory = realloc(stream->memory, stream->Lmax);
if(!stream->memory)
{
// memory allocation error
stream->error |= 1;
stream->Lmax = 0;
return;
}
}
else
{
/*--------------------------------------------------------*\
! Exit to function caller if error flag has been set. !
\*--------------------------------------------------------*/
return;
}
}
/*--------------------------------------------------------*\
! Copy the additional byte to the stream memory block and !
! increment the number of bytes written to the stream. !
\*--------------------------------------------------------*/
stream->memory[stream->L++] = (uchar)stream->T;
}
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! - Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
uchar
terminate_stream(bitstream *stream, bwc_stream *const packed_stream)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(stream);
if(packed_stream)
{
if(stream->error)
{
return 1;
}
else if(stream->L != stream->Lmax)
{
stream->Lmax = stream->L;
stream->memory = realloc(stream->memory, stream->Lmax);
if(!stream->memory)
{
// memory allocation error
fprintf(stderr, MEMERROR);
stream->Lmax = 0;
return 1;
}
}
packed_stream->memory = stream->memory;
packed_stream->access = stream->memory;
packed_stream->size = stream->L;
packed_stream->position = 0;
}
else
{
free(stream->memory);
}
free(stream);
return 0;
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void release_packed_stream(bwc_stream *stream) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! This function is used to release all the information stored in a packed bitstream !
! and reset the parameters for another (de)compression run. !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! stream bwc_stream - Packed bitstream used to store parts of !
! the bwc codestream. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 22.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
void
release_packed_stream(bwc_stream *stream)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(stream);
/*--------------------------------------------------------*\
! Free the data block of the packed bitstream. !
\*--------------------------------------------------------*/
free(stream->memory);
/*--------------------------------------------------------*\
! Reset all the packed stream parameters. !
\*--------------------------------------------------------*/
stream->access = NULL;
stream->position = 0;
stream->size = 0;
}

1786
1-bwc/src/library/codestream.c Executable file

File diff suppressed because it is too large Load diff

2648
1-bwc/src/library/dwt.c Executable file

File diff suppressed because it is too large Load diff

4453
1-bwc/src/library/libbwc.c Executable file

File diff suppressed because it is too large Load diff

1175
1-bwc/src/library/mq.c Executable file

File diff suppressed because it is too large Load diff

573
1-bwc/src/library/tagtree.c Executable file
View file

@ -0,0 +1,573 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This file defines a tagtree procedure used to encode/decode two types of ||
|| information found defining in a codeblock in specific quality layer: ||
|| ||
|| - The inclusion tag records if a codeblock has any contribution ||
|| to a quality layer. ||
|| - The number of leading bitplanes that are not significant/only ||
|| populated by zero bits. ||
|| ||
|| For more information on the encoding/decoding process please refere to JPEG2000 ||
|| by D. S. Taubman and M. W. Marcellin (p. 384). ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (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 provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| 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. ||
|| ||
\*================================================================================================*/
/************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************************/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "bitstream.h"
#include "macros.h"
#include "types.h"
#include "tagtree.h"
/************************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void kill_tagtree(bwc_tagtree* tagtree) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! This function deallocates a tagtree instance used to encode codeblock contributions to a !
! specific quality layer as well as the number of magnitude bit planes used to represent the !
! samples of a specific codeblock. !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! tagtree bwc_tagtree* - Structure defining a tagtree instance. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 14.06.2018 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
void
kill_tagtree(bwc_tagtree* tagtree)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(tagtree);
free(tagtree->nodes);
free(tagtree);
return;
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 14.06.2018 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
void
reset_tagtree(bwc_tagtree* const tagtree)
{
/*-----------------------*\
! DEFINE INT VARIABLES: !
\*-----------------------*/
uint64 i = 0;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(tagtree);
do
{
tagtree->nodes[i].value = 0xFFFF;
tagtree->nodes[i].threshold = 0;
}while(tagtree->nodes[i++].parent);
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 14.06.2018 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
uint16
tagtree_get_value(const bwc_tagtree* const tagtree, const uint64 leaf_index)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(tagtree);
assert(leaf_index < tagtree->leavesX * tagtree->leavesY * tagtree->leavesZ * tagtree->leavesTS);
assert(tagtree->nodes[leaf_index].value != 0xFFFF);
return tagtree->nodes[leaf_index].value;
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 14.06.2018 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
void
tagtree_set_value(bwc_tagtree* const tagtree, const uint64 leaf_index, const uint16 value)
{
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
bwc_tagtree_node *node;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(tagtree);
assert(leaf_index < tagtree->leavesX * tagtree->leavesY * tagtree->leavesZ * tagtree->leavesTS);
assert(tagtree->nodes[leaf_index].value == 0xFFFF);
assert(value < 0xFFFF);
node = &tagtree->nodes[leaf_index];
do
{
node->value = value;
node = node->parent;
}while(node && (node->value > value));
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 14.06.2018 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
bwc_tagtree*
initialize_tagtree(const uint64 leafsX, const uint64 leafsY, const uint64 leafsZ, const uint64 leafsTS)
{
/*-----------------------*\
! DEFINE INT VARIABLES: !
\*-----------------------*/
uint64 levels, number_of_nodes;
uint32 nlX[32] = {0}, nlY[32] = {0}, nlZ[32] = {0}, nlTS[32] = {0};
uint32 i, j, k, l, n;
uint16 a,b,c,d;
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
bwc_tagtree_node *node, *parent_x, *parent_y, *parent_z, *parent_ts;
bwc_tagtree *tagtree;
for(nlX[0] = leafsX, nlY[0] = leafsY,
nlZ[0] = leafsZ, nlTS[0] = leafsTS,
levels = 0, number_of_nodes = 1;
nlX[levels] * nlY[levels] *
nlZ[levels] * nlTS[levels] > 1;
++levels)
{
number_of_nodes += nlX[levels] * nlY[levels] * nlZ[levels] * nlTS[levels];
nlX[levels + 1] = (nlX[levels] + 1) >> 1;
nlY[levels + 1] = (nlY[levels] + 1) >> 1;
nlZ[levels + 1] = (nlZ[levels] + 1) >> 1;
nlTS[levels + 1] = (nlTS[levels] + 1) >> 1;
}
tagtree = calloc(1, sizeof(bwc_tagtree));
if (!tagtree)
{
// memory allocation error
fprintf(stderr, MEMERROR);
return 0;
}
tagtree->nodes = calloc(number_of_nodes, sizeof(bwc_tagtree_node));
if (!tagtree->nodes)
{
// memory allocation error
fprintf(stderr, MEMERROR);
free(tagtree);
return 0;
}
node = tagtree->nodes;
for(i = 0; i < number_of_nodes; ++i)
{
node->index = i;
++node;
}
tagtree->leavesX = leafsX;
tagtree->leavesY = leafsY;
tagtree->leavesZ = leafsZ;
tagtree->leavesTS = leafsTS;
parent_ts = tagtree->nodes;
node = tagtree->nodes;
for(n = 0; n < levels; ++n)
{
parent_ts += (uint32)(nlX[n] * nlY[n] * nlZ[n] * nlTS[n]);
for(l = 0, d = 0; l < nlTS[n]; ++l, ++d)
{
if(d >> 1)
{
parent_ts += nlX[n+1] * nlY[n+1] * nlZ[n+1];
d = 0;
}
for(k = 0, c = 0, parent_z = parent_ts; k < nlZ[n]; ++k, ++c)
{
if(c >> 1)
{
parent_z += nlX[n+1] * nlY[n+1];
c = 0;
}
for(j = 0, b = 0, parent_y = parent_z; j < nlY[n]; ++j, ++b)
{
if(b >> 1)
{
parent_y += nlX[n+1];
b = 0;
}
for(i = 0, a = 0, parent_x = parent_y; i < nlX[n]; ++i, ++a)
{
if(a >> 1)
{
parent_x++;
a = 0;
}
node->parent = parent_x;
node++;
}
}
}
}
}
reset_tagtree(tagtree);
return tagtree;
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 14.06.2018 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
void
encode_tagtree(bwc_tagtree *const tagtree, bitstream *const stream, const uint32 threshold, const uint32 leaf_index, const uchar estimate)
{
/*-----------------------*\
! DEFINE INT VARIABLES: !
\*-----------------------*/
uint32 threshold_tmp, threshold_min;
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
bwc_tagtree_node *node;
bwc_tagtree_node **branch_ptr, *branch[32];
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(tagtree);
assert(stream);
assert(leaf_index < (tagtree->leavesX * tagtree->leavesY * tagtree->leavesZ * tagtree->leavesTS));
node = &tagtree->nodes[leaf_index];
branch_ptr = branch;
while(node->parent)
{
*branch_ptr++ = node;
node = node->parent;
}
for(threshold_min = 0; ; node = *--branch_ptr)
{
threshold_tmp = node->threshold;
if(threshold_tmp < threshold_min)
{
threshold_tmp = threshold_min;
}
while((node->value >= threshold_tmp) && (threshold_tmp < threshold)) //this conditional jump needs to be checked
{
threshold_tmp++;
if(node->value >= threshold_tmp)
{
emit_bit(stream, 0);
}
else
{
emit_bit(stream, 1);
}
}
threshold_min = MIN(node->value, threshold_tmp);
if(!estimate)
{
node->threshold = threshold_tmp;
}
if(node == &tagtree->nodes[leaf_index])
{
break;
}
}
}
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void *test(void) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! - - - !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 14.06.2018 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
uchar
decode_tagtree(bwc_tagtree *const tagtree, bitstream *const stream, const uint32 threshold, const uint32 leaf_index)
{
/*-----------------------*\
! DEFINE INT VARIABLES: !
\*-----------------------*/
uint32 threshold_min;
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
bwc_tagtree_node *node;
bwc_tagtree_node **branch_ptr, *branch[32];
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(tagtree);
assert(stream);
assert(leaf_index < (tagtree->leavesX * tagtree->leavesY * tagtree->leavesZ * tagtree->leavesTS));
node = &tagtree->nodes[leaf_index];
branch_ptr = branch;
while(node)
{
if(node->value == 0xFFFF)
{
node->value = 0;
}
*branch_ptr++ = node;
node = node->parent;
}
for(*branch_ptr--, node = *branch_ptr--, threshold_min = 0; ; node = *branch_ptr--)
{
if(node->threshold < threshold_min)
{
node->value = threshold_min;
node->threshold = threshold_min;
}
while((node->value == node->threshold) && (node->threshold < threshold))
{
node->threshold++;
if(!get_bit(stream))
{
node->value++;
}
}
threshold_min = MIN(node->value, node->threshold);
if(node == &tagtree->nodes[leaf_index])
{
break;
}
}
return (node->value < threshold) ? 0 : 1;
}

3361
1-bwc/src/library/tier1.c Executable file

File diff suppressed because it is too large Load diff

1677
1-bwc/src/library/tier2.c Executable file

File diff suppressed because it is too large Load diff

85
1-bwc/src/tools/CMakeLists.txt Executable file
View file

@ -0,0 +1,85 @@
#*================================================================================================*#
#| |#
#| /$$$$$$$ /$$ /$$ /$$ /$$ |#
#| | $$__ $$|__/ | $$ /$ | $$| $$ |#
#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |#
#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |#
#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |#
#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |#
#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |#
#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |#
#| /$$ \ $$ | $$ |#
#| | $$$$$$/ | $$ |#
#| \______/ |__/ |#
#| |#
#| DESCRIPTION: |#
#| ------------ |#
#| |#
#| Defines the cmake script for the BigWhoop command line tool. |#
#| |#
#| -------------------------------------------------------------------------------------------- |#
#| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart |#
#| |#
#| Redistribution and use in source and binary forms, with or without modification, are |#
#| permitted provided that the following conditions are met: |#
#| |#
#| (1) Redistributions of source code must retain the above copyright notice, this list of |#
#| conditions and the following disclaimer. |#
#| |#
#| (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 provided with the distribution. |#
#| |#
#| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS |#
#| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |#
#| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |#
#| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |#
#| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |#
#| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |#
#| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |#
#| 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. |#
#| |#
#*================================================================================================*#
#----------------------------------------------------------#
# Add the bwc command line utility and get hash tool to #
# the current project using the utility source files. #
#----------------------------------------------------------#
add_executable(bwccmd bwccmdl.c
../interfaces/reader/eas3.c)
#----------------------------------------------------------#
# Set the target compile definition for the requested file #
# format support. #
#----------------------------------------------------------#
MESSAGE(STATUS "EAS3 file format support: ${BUILD_EAS3}")
if(${BUILD_EAS3})
target_compile_definitions(bwccmd PRIVATE -DBWC_EAS3)
endif()
if(${BUILD_NETCDF})
target_compile_definitions(bwccmd PRIVATE -DBWC_NETCDF)
endif()
#----------------------------------------------------------#
# Define the output name for the utility binaries. #
#----------------------------------------------------------#
set_property(TARGET bwccmd PROPERTY OUTPUT_NAME bwc)
#----------------------------------------------------------#
# Setup up the include directory for the bwc utilities. #
#----------------------------------------------------------#
target_include_directories(bwccmd PRIVATE ${CMAKE_SOURCE_DIR}/include/tools)
target_include_directories(bwccmd PRIVATE ${CMAKE_SOURCE_DIR}/include/library/public)
target_include_directories(bwccmd PRIVATE ${CMAKE_SOURCE_DIR}/include/interfaces/reader)
#----------------------------------------------------------#
# Setup the install directories. #
#----------------------------------------------------------#
install(TARGETS bwccmd DESTINATION ${CMAKE_INSTALL_BINDIR})
#----------------------------------------------------------#
# Link the bwc utility to the bwc library. #
#----------------------------------------------------------#
target_link_libraries(bwccmd PRIVATE bwclib m)

3222
1-bwc/src/tools/bwccmdl.c Normal file

File diff suppressed because it is too large Load diff

154
1-bwc/src/tools/get_hash.c Executable file
View file

@ -0,0 +1,154 @@
/*==================================================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| FILE NAME: get_hash.c ||
|| ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| This is a simple command line tool that converts the command-line arguments to a uniquely identifiable ||
|| hash. ||
|| ||
|| ||
|| PUBLIC FUNCTIONS: ||
|| ----------------- ||
|| - main ||
|| ||
|| DEVELOPMENT HISTORY: ||
|| -------------------- ||
|| ||
|| Date Author Change Id Release Description Of Change ||
|| ---- ------ --------- ------- --------------------- ||
|| 02.05.2019 Patrick Vogler B87D120 V 0.1.0 module created ||
|| ||
|| -------------------------------------------------------------------------------------------------------------------- ||
|| ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are permitted provided that the ||
|| following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and ||
|| the following disclaimer. ||
|| ||
|| (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 provided with the ||
|| distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR 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. ||
|| ||
\*==================================================================================================================================*/
/************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************************/
#include <assert.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
/*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: int main(int argc, char* argv[]) !
! -------------- !
! !
! DESCRIPTION: !
! ------------ !
! !
! This function uses a variant of the DJB hash function to turn the command-line argument !
! strings and converts them to a uniquely identifiable hash. The hashes are written to the !
! command-line in a hexadecimal format. !
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! argc int - Number of strings pointed to by argv. !
! !
! argv char** - Array of arguments. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! int - Return value signaling a normal or abnormal process exit. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 02.05.2019 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
int main(int argc, char* argv[])
{
/*-----------------------*\
! DEFINE INT VARIABLES: !
\*-----------------------*/
uint64_t hash;
uint8_t c, i;
/*-----------------------*\
! DEFINE CHAR VARIABLES: !
\*-----------------------*/
char* str;
/*--------------------------------------------------------*\
! Loop through all additional command-line arguments. !
\*--------------------------------------------------------*/
for(i = 1, str = argv[1]; i < argc; ++i, str = argv[i])
{
/*--------------------------------------------------------*\
! Initialize the hash with a magic number. !
\*--------------------------------------------------------*/
hash = 0x1505;
/*--------------------------------------------------------*\
! Walk through all the characters in the string. !
\*--------------------------------------------------------*/
while ((c = *str++))
{
/*--------------------------------------------------------*\
! Convert the current characters to uppercase. !
\*--------------------------------------------------------*/
if((c >= 97) && (c <= 122))
{
c = c - 32;
}
/*--------------------------------------------------------*\
! Multiply the hash with 33 and add the current character !
! to the hash. !
\*--------------------------------------------------------*/
hash = (hash * 33) ^ c;
}
/*--------------------------------------------------------*\
! Write the hash to the command-line. !
\*--------------------------------------------------------*/
printf("%#020lX \n", hash);
}
return 0;
}

41
README.md Normal file
View file

@ -0,0 +1,41 @@
<h1 align="center">Data Compression of numerical data sets with the BigWhoop library</h1>
This repository contains all the resources needed to participate in the hands-on sessions of the lecture `Data Compression of numerical data sets with the BigWhoop library`. The repository is organized as follows.
- 0-docs lecture slides
- 1-bwc source code of the BigWhoop compression library
- 2-data Test data sets.
<h1 align="center">Building BigWhoop</h1>
### Dependencies
* make
* cmake (>= 3.5.1)
* gcc (>= 8.5.0)
### Building
pull the sources from HLRS' gitea instance (note: default branch is `main`):
```
git pull https://code.hlrs.de/hpcpvogl/BigWhoop.git
```
Now change into the source directory and run the following commands.
**for a simple build**
```
make clean
make
```
**for a full build (including command line tool)**
```
make full
```
**for debugging**
```
make clean
make debug
```
This builds the library and places the associated files in the `/lib` or `/lib64` folders. If a full build was attempted, the command line tool binaries are placed in the `/bin` folder.