diff --git a/CMakeLists.txt b/CMakeLists.txt index 0579efe..d0d4735 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,100 +1,93 @@ -#*====================================================================================================================*# -#| |# -#| /$$$$$$$ /$$ /$$ /$$ /$$ |# -#| | $$__ $$|__/ | $$ /$ | $$| $$ |# -#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |# -#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |# -#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |# -#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |# -#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |# -#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |# -#| /$$ \ $$ | $$ |# -#| | $$$$$$/ | $$ |# -#| \______/ |__/ |# -#| DESCRIPTION: |# -#| ------------ |# -#| Defines the global cmake script for the Big Whoop compression algorithm. |# -#| |# -#| |# -#| DEVELOPMENT HISTORY: |# -#| -------------------- |# -#| |# -#| Date Author Change Id Release Description Of Change |# -#| ---- ------ --------- ------- --------------------- |# -#| 30.08.2018 Patrick Vogler B87D120 V 0.1.0 Cmake 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. |# -#| |# -#*====================================================================================================================*# -#*--------------------------------------------------------*# +#*================================================================================================*# +#| |# +#| /$$$$$$$ /$$ /$$ /$$ /$$ |# +#| | $$__ $$|__/ | $$ /$ | $$| $$ |# +#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |# +#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |# +#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |# +#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |# +#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |# +#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |# +#| /$$ \ $$ | $$ |# +#| | $$$$$$/ | $$ |# +#| \______/ |__/ |# +#| |# +#| 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 "Version[ \t]+([0-9]+).([0-9]+).([0-9]+)" _ ${ver} ${_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) @@ -108,25 +101,25 @@ 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) @@ -134,10 +127,10 @@ 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) @@ -147,22 +140,22 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") 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 @@ -178,21 +171,21 @@ 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) diff --git a/bwc-config-version.cmake.in b/bwc-config-version.cmake.in index 941b2f0..8a480ef 100644 --- a/bwc-config-version.cmake.in +++ b/bwc-config-version.cmake.in @@ -1,3 +1,46 @@ +#*================================================================================================*# +#| |# +#| /$$$$$$$ /$$ /$$ /$$ /$$ |# +#| | $$__ $$|__/ | $$ /$ | $$| $$ |# +#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |# +#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |# +#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |# +#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |# +#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |# +#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |# +#| /$$ \ $$ | $$ |# +#| | $$$$$$/ | $$ |# +#| \______/ |__/ |# +#| |# +#| 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@) diff --git a/bwc-config.cmake.in b/bwc-config.cmake.in index 934d6ee..a92e0ba 100644 --- a/bwc-config.cmake.in +++ b/bwc-config.cmake.in @@ -1,12 +1,53 @@ -# - Config file for the bwc package -# -# It defines the following variables -# BWC_INCLUDE_DIRS - include directories for bwc -# BWC_LIBRARIES - libraries to link against -# -# And the following imported targets: -# bwc::bwclib - +#*================================================================================================*# +#| |# +#| /$$$$$$$ /$$ /$$ /$$ /$$ |# +#| | $$__ $$|__/ | $$ /$ | $$| $$ |# +#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |# +#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |# +#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |# +#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |# +#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |# +#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |# +#| /$$ \ $$ | $$ |# +#| | $$$$$$/ | $$ |# +#| \______/ |__/ |# +#| |# +#| 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) diff --git a/include/library/private/bitstream.h b/include/library/private/bitstream.h index 001bca4..f0c3239 100755 --- a/include/library/private/bitstream.h +++ b/include/library/private/bitstream.h @@ -1,224 +1,94 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: bwc_bitstream.h || -|| ----- || -|| || -|| 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 code- || -|| stream and can emit/extract information on a per bit, symbol (64-bit) or string basis. || -|| || -|| || -|| STRUCTS: || -|| -------- || -|| - || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| - bwc_init_stream || -|| - bwc_emit_chunck || -|| - bwc_emit_symbol || -|| - bwc_emit_bit || -|| - bwc_get_chunck || -|| - bwc_get_symbol || -|| - bwc_get_bit || -|| - bwc_terminate_stream || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 28.05.2018 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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" - /************************************************************************************************************\ - || _ _ _ ____ _ _ _ ___ ____ || - || | |\ | | | | | | \ |___ || - || | | \| |___ |___ |__| |__/ |___ || - || || - \************************************************************************************************************/ - #include "types.h" - - /************************************************************************************************************\ - || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || - || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || - || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: uint32 bytes_used(bwc_stream *const stream) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function is used to evaluate the number of bytes that have already been ! - ! written to the allocated bitstream memory block. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uint64 - bytes_used(bwc_stream *const stream); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: bwc_stream* 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 bwc_stream structure. The byte buffer counter t, ! - ! stream size Lmax and size increment are initialized with their appropriate values. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - bwc_stream* - bwc_init_stream(uchar* memory, uint32 size, char instr); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_emit_chunck(bwc_stream *const stream, const uchar* chunck, const uint64 size); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_emit_symbol(bwc_stream *const stream, const uint64 symbol, const uint8 size); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_emit_bit(bwc_stream *const stream, const uint64 bit); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - flush_stream(bwc_stream *const stream); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar* - bwc_get_chunck(bwc_stream *const stream, const uint64 length); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uint64 - bwc_get_symbol(bwc_stream *const stream, const uint8 length); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - bwc_get_bit(bwc_stream *const stream); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - bwc_terminate_stream(bwc_stream *stream, bwc_packed_stream *const packed_stream); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void release_packed_stream(bwc_packed_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. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - release_packed_stream(bwc_packed_stream *stream); + /************************************************************************************************\ + || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || + || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || + || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || + || || + \************************************************************************************************/ + uint64 bytes_used (bwc_stream const *const stream); + //==========|==========================|======================|======|======|===================== + bwc_stream* bwc_init_stream (uchar *const memory, + uint32 const size, + char const instr); + //==========|==========================|======================|======|======|===================== + void bwc_emit_chunck (bwc_stream *const stream, + uchar const *const chunck, + uint64 const size); + //==========|==========================|======================|======|======|===================== + void bwc_emit_symbol (bwc_stream *const stream, + uint64 const symbol, + uint8 const size); + //==========|==========================|======================|======|======|===================== + void bwc_emit_bit (bwc_stream *const stream, + uint64 const bit); + //==========|==========================|======================|======|======|===================== + void flush_stream (bwc_stream *const stream); + //==========|==========================|======================|======|======|===================== + uchar* bwc_get_chunck (bwc_stream *const stream, + uint64 const length); + //==========|==========================|======================|======|======|===================== + uint64 bwc_get_symbol (bwc_stream *const stream, + uint8 const length); + //==========|==========================|======================|======|======|===================== + uchar bwc_get_bit (bwc_stream *const stream); + //==========|==========================|======================|======|======|===================== + uchar bwc_terminate_stream (bwc_stream *stream, + bwc_packed_stream *const packed_stream); + //==========|==========================|======================|======|======|===================== + void release_packed_stream (bwc_packed_stream *const stream); #endif \ No newline at end of file diff --git a/include/library/private/codestream.h b/include/library/private/codestream.h index 0458d2c..d13ebd6 100755 --- a/include/library/private/codestream.h +++ b/include/library/private/codestream.h @@ -1,191 +1,107 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: codestream.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| DESCRIPTION NEEDED. || -|| || -|| STRUCTS: || -|| -------- || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 28.05.2018 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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 "types.h" - /************************************************************************************************************\ - || _ _ ____ ____ ____ ____ ____ || - || |\/| |__| | |__/ | | [__ || - || | | | | |___ | \ |__| ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! DESCRIPTION: ! - ! ------------ ! - ! These macros define stream manipulation operations to rewind, foward and get access ! - ! to the current memory position of a bwc_stream. ! - ! ! - ! Macros: ! - ! ------- ! - ! Macro Description ! - ! ----- ----------- ! - ! rewind_stream - Rewinds a stream by a user specified amount (delta) ! - ! of bits. ! - ! ! - ! foward_stream - Fowards a stream by a user specified amount (delta) ! - ! of bits. ! - ! ! - ! get_access - Get an access pointer to the current memory position ! - ! of a bwc_stream. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 07.08.2019 Patrick Vogler B87D120 V 0.1.0 Macros created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define rewind_stream(stream, delta) \ - { \ - stream->L -= delta; \ - } + /************************************************************************************************\ + || _ _ ____ ____ ____ ____ ____ || + || |\/| |__| | |__/ | | [__ || + || | | | | |___ | \ |__| ___] || + || || + \************************************************************************************************/ + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! DESCRIPTION: ! + ! ------------ ! + ! ! + ! These macros define stream manipulation operations to rewind, forward, inquire ! + ! the availability and get access to the current memory position of a bwc_stream. ! + ! ! + \*----------------------------------------------------------------------------------------------*/ + #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 + #define forward_stream(stream, delta) \ + { \ + stream->L += delta; \ + } - /************************************************************************************************************\ - || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || - || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || - || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - assemble_main_header(bwc_field *const field); + #define get_access(stream) (uchar*)stream->memory + stream->L - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - bwc_field* - bwc_parse_main_header(bwc_data *const data,bwc_stream *const stream); + /************************************************************************************************\ + || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || + || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || + || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || + || || + \************************************************************************************************/ + uchar assemble_main_header (bwc_field *const field); + //==========|==========================|======================|======|======|===================== + bwc_field* bwc_parse_main_header (bwc_data *const data, + bwc_stream *const stream); + //==========|==========================|======================|======|======|===================== + uchar codestream_write_aux (bwc_packed_stream *const header, + bwc_packed_stream *const aux); + //==========|==========================|======================|======|======|===================== + uchar codestream_write_com (bwc_packed_stream *const header, + bwc_packed_stream *const com); + //==========|==========================|======================|======|======|===================== + bwc_packed_stream* assemble_codestream (bwc_field *const field); - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - codestream_write_aux(bwc_packed_stream *const header, bwc_packed_stream *const aux); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - codestream_write_com(bwc_packed_stream *const header, bwc_packed_stream *const com); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: bwc_packed_stream* assemble_codestream(bwc_field *const field) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - bwc_packed_stream* - assemble_codestream(bwc_field *const field); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: bwc_field* parse_codestream(bwc_data *const data) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - bwc_field* - parse_codestream(bwc_data *const data, uint8 const layer); + //==========|==========================|======================|======|======|===================== + bwc_field* parse_codestream (bwc_data *const data, + uint8 const layer); #endif \ No newline at end of file diff --git a/include/library/private/constants.h b/include/library/private/constants.h index c33f78f..fc81586 100755 --- a/include/library/private/constants.h +++ b/include/library/private/constants.h @@ -1,328 +1,299 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: constants.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| DESCRIPTION NEEDED. || -|| || -|| STRUCTS: || -|| -------- || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 16.10.2017 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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 identify the spatial and temporal dimensions. ! - ! ! - ! Constants: ! - ! ----------- ! - ! Constant Description ! - ! -------- ----------- ! - ! DIM_X 1st Spatial Dimension ! - ! DIM_Y 2nd Spatial Dimension ! - ! DIM_Z 3rd Spatial Dimension ! - ! DIM_TS Temporal Dimension ! - ! DIM_ALL All Dimensions ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 04.12.2017 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define DIM_X 1 - #define DIM_Y 2 - #define DIM_Z 4 - #define DIM_TS 8 - #define DIM_ALL 15 + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! DESCRIPTION: ! + ! ------------ ! + ! ! + ! These constants are used to identify the spatial and temporal dimensions. ! + ! ! + \*----------------------------------------------------------------------------------------------*/ + #define DIM_X 1 // 1st Spatial Dimension. + #define DIM_Y 2 // 2nd Spatial Dimension. + #define DIM_Z 4 // 3rd Spatial Dimension. + #define DIM_TS 8 // Temporal Dimension. + #define DIM_ALL 15 // All Dimensions. - /*----------------------------------------------------------------------------------------------------------*\ - ! DESCRIPTION: ! - ! ------------ ! - ! ! - ! These constants describe the maximum allowable wavelet decompositions for the spatial and ! - ! temporal dimensions and the maximum allowable subbands. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 01.12.2017 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define MAXIMUM_NUMBER_OF_SPATIAL_DECOMP 64 - #define MAXIMUM_NUMBER_OF_TEMPORAL_DECOMP 32 - #define MAXIMUM_NUMBER_OF_SUBBANDS (1+(15*(64-32))) + (1+(7*32)) + /*----------------------------------------------------------------------------------------------------------*\ + ! DESCRIPTION: ! + ! ------------ ! + ! ! + ! These constants describe the maximum allowable wavelet decompositions for the spatial and ! + ! temporal dimensions and the maximum allowable subbands. ! + ! ! + ! DEVELOPMENT HISTORY: ! + ! -------------------- ! + ! ! + ! Date Author Change Id Release Description Of Change ! + ! ---- ------ --------- ------- --------------------- ! + ! 01.12.2017 Patrick Vogler B87D120 V 0.1.0 Constants created ! + \*----------------------------------------------------------------------------------------------------------*/ + #define MAXIMUM_NUMBER_OF_SPATIAL_DECOMP 64 + #define MAXIMUM_NUMBER_OF_TEMPORAL_DECOMP 32 + #define MAXIMUM_NUMBER_OF_SUBBANDS (1+(15*(64-32))) + (1+(7*32)) - /*----------------------------------------------------------------------------------------------------------*\ - ! DESCRIPTION: ! - ! ------------ ! - ! ! - ! These Constants describe the codestream markers used to create the embedded codestream. ! - ! ! - ! CONSTANTS: ! - ! ----------- ! - ! Constant Description ! - ! -------- ----------- ! - ! SOC - Start of code-stream ! - ! SGI - Global data-set information ! - ! SGC - Global control parameters ! - ! 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 Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 01.12.2017 Patrick Vogler B87D120 V 0.1.0 Constants 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 Constants describe the codestream markers used to create the embedded codestream. ! + ! ! + ! CONSTANTS: ! + ! ----------- ! + ! Constant Description ! + ! -------- ----------- ! + ! SOC - Start of code-stream ! + ! SGI - Global data-set information ! + ! SGC - Global control parameters ! + ! 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 Of Change ! + ! ---- ------ --------- ------- --------------------- ! + ! 01.12.2017 Patrick Vogler B87D120 V 0.1.0 Constants 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 Constants are used for codestream parsing. ! - ! ! - ! CONSTANTS: ! - ! ----------- ! - ! Constant Description ! - ! -------- ----------- ! - ! CODESTREAM_OK No errors detectet in Codestream ! - ! CODESTREAM_ERROR Error detectet in Codestream ! - ! CODESTREAM_SGI_READ Global data-set information read ! - ! CODESTREAM_SGC_READ Global control parameters read ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 01.08.2019 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define CODESTREAM_OK 0x00 - #define CODESTREAM_ERROR 0x80 - #define CODESTREAM_SGI_READ 0x01 - #define CODESTREAM_SGC_READ 0x02 - #define CODESTREAM_SAX_READ 0x04 - #define CODESTREAM_COM_READ 0x08 + /*----------------------------------------------------------------------------------------------------------*\ + ! DESCRIPTION: ! + ! ------------ ! + ! ! + ! These Constants are used for codestream parsing. ! + ! ! + ! CONSTANTS: ! + ! ----------- ! + ! Constant Description ! + ! -------- ----------- ! + ! CODESTREAM_OK No errors detectet in Codestream ! + ! CODESTREAM_ERROR Error detectet in Codestream ! + ! CODESTREAM_SGI_READ Global data-set information read ! + ! CODESTREAM_SGC_READ Global control parameters read ! + ! ! + ! DEVELOPMENT HISTORY: ! + ! -------------------- ! + ! ! + ! Date Author Change Id Release Description Of Change ! + ! ---- ------ --------- ------- --------------------- ! + ! 01.08.2019 Patrick Vogler B87D120 V 0.1.0 Constants created ! + \*----------------------------------------------------------------------------------------------------------*/ + #define CODESTREAM_OK 0x00 + #define CODESTREAM_ERROR 0x80 + #define CODESTREAM_SGI_READ 0x01 + #define CODESTREAM_SGC_READ 0x02 + #define CODESTREAM_SAX_READ 0x04 + #define CODESTREAM_COM_READ 0x08 - /*----------------------------------------------------------------------------------------------------------*\ - ! ENUM NAME: bwc_dwt_filter ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! ! - ! These constants describe the wavelet filter used during the transform stage. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Constant Description ! - ! -------- ----------- ! - ! bwc_dwt_9_7 - Cohen Daubechies Feauveau 9/7 Wavelet ! - ! bwc_dwt_5_3 - LeGall 5/3 Wavelet ! - ! bwc_dwt_haar - Haar Wavelet ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 07.12.2017 Patrick Vogler B87D120 V 0.1.0 Enum created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef enum{ - bwc_dwt_9_7, - bwc_dwt_5_3, - bwc_dwt_haar - } bwc_dwt_filter; + /*----------------------------------------------------------------------------------------------------------*\ + ! ENUM NAME: bwc_dwt_filter ! + ! ----------- ! + ! ! + ! DESCRIPTION: ! + ! ------------ ! + ! ! + ! These constants describe the wavelet filter used during the transform stage. ! + ! ! + ! PARAMETERS: ! + ! ----------- ! + ! Constant Description ! + ! -------- ----------- ! + ! bwc_dwt_9_7 - Cohen Daubechies Feauveau 9/7 Wavelet ! + ! bwc_dwt_5_3 - LeGall 5/3 Wavelet ! + ! bwc_dwt_haar - Haar Wavelet ! + ! ! + ! DEVELOPMENT HISTORY: ! + ! -------------------- ! + ! ! + ! Date Author Change Id Release Description Of Change ! + ! ---- ------ --------- ------- --------------------- ! + ! 07.12.2017 Patrick Vogler B87D120 V 0.1.0 Enum created ! + ! ! + \*----------------------------------------------------------------------------------------------------------*/ + typedef enum{ + bwc_dwt_9_7, + bwc_dwt_5_3, + bwc_dwt_haar + } bwc_dwt_filter; - /*----------------------------------------------------------------------------------------------------------*\ - ! ENUM NAME: bwc_prog_ord ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! ! - ! These constants describe the progression order used to pack the codestream. ! - ! The organisation of the codesstream is carried out according to the following 5 cases. ! - ! ! - ! LRCP: RLCP: ! - ! ----- for each Quality Layer: ----- for each Resolution: ! - ! for each Resolution: for each Quality Layer: ! - ! for each Parameter: for each Parameter: ! - ! for each Precinct: for each Precinct: ! - ! include Packet include Packet ! - ! ! - ! RPCL: PCRL: ! - ! ----- for each Resolution: ----- for each Precinct: ! - ! for each Precinct: for each Parameter: ! - ! for each Parameter: for each Resolution: ! - ! for each Quality Layer: for each Quality Layer: ! - ! include Packet include Packet ! - ! ! - ! CPRL: ! - ! ----- for each Quality Layer: ! - ! for each Resolution: ! - ! for each Parameter: ! - ! for each Precinct: ! - ! include Packet ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Constant Description ! - ! -------- ----------- ! - ! bwc_prog_LRCP - LRCP progression order ! - ! bwc_prog_RLCP - RLCP progression order ! - ! bwc_prog_RPCL - RPCL progression order ! - ! bwc_prog_PCRL - PCRL progression order ! - ! bwc_prog_CPRL - CPRL progression order ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 07.12.2017 Patrick Vogler B87D120 V 0.1.0 Enum created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef enum{ - bwc_prog_LRCP, - bwc_prog_RLCP, - bwc_prog_RPCL, - bwc_prog_PCRL, - bwc_prog_CPRL - } bwc_prog_ord; + /*----------------------------------------------------------------------------------------------------------*\ + ! ENUM NAME: bwc_prog_ord ! + ! ----------- ! + ! ! + ! DESCRIPTION: ! + ! ------------ ! + ! ! + ! These constants describe the progression order used to pack the codestream. ! + ! The organisation of the codesstream is carried out according to the following 5 cases. ! + ! ! + ! LRCP: RLCP: ! + ! ----- for each Quality Layer: ----- for each Resolution: ! + ! for each Resolution: for each Quality Layer: ! + ! for each Parameter: for each Parameter: ! + ! for each Precinct: for each Precinct: ! + ! include Packet include Packet ! + ! ! + ! RPCL: PCRL: ! + ! ----- for each Resolution: ----- for each Precinct: ! + ! for each Precinct: for each Parameter: ! + ! for each Parameter: for each Resolution: ! + ! for each Quality Layer: for each Quality Layer: ! + ! include Packet include Packet ! + ! ! + ! CPRL: ! + ! ----- for each Quality Layer: ! + ! for each Resolution: ! + ! for each Parameter: ! + ! for each Precinct: ! + ! include Packet ! + ! ! + ! PARAMETERS: ! + ! ----------- ! + ! Constant Description ! + ! -------- ----------- ! + ! bwc_prog_LRCP - LRCP progression order ! + ! bwc_prog_RLCP - RLCP progression order ! + ! bwc_prog_RPCL - RPCL progression order ! + ! bwc_prog_PCRL - PCRL progression order ! + ! bwc_prog_CPRL - CPRL progression order ! + ! ! + ! DEVELOPMENT HISTORY: ! + ! -------------------- ! + ! ! + ! Date Author Change Id Release Description Of Change ! + ! ---- ------ --------- ------- --------------------- ! + ! 07.12.2017 Patrick Vogler B87D120 V 0.1.0 Enum created ! + ! ! + \*----------------------------------------------------------------------------------------------------------*/ + typedef enum{ + bwc_prog_LRCP, + bwc_prog_RLCP, + bwc_prog_RPCL, + bwc_prog_PCRL, + bwc_prog_CPRL + } bwc_prog_ord; - /*----------------------------------------------------------------------------------------------------------*\ - ! ENUM NAME: bwc_quant_st ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Constant Description ! - ! -------- ----------- ! - ! - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 07.12.2017 Patrick Vogler B87D120 V 0.1.0 Enum created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef enum{ - bwc_qt_none, - bwc_qt_derived, - } bwc_quant_st; + /*----------------------------------------------------------------------------------------------------------*\ + ! ENUM NAME: bwc_quant_st ! + ! ----------- ! + ! ! + ! DESCRIPTION: ! + ! ------------ ! + ! DESCRIPTION NEEDED ! + ! ! + ! PARAMETERS: ! + ! ----------- ! + ! Constant Description ! + ! -------- ----------- ! + ! - - ! + ! ! + ! DEVELOPMENT HISTORY: ! + ! -------------------- ! + ! ! + ! Date Author Change Id Release Description Of Change ! + ! ---- ------ --------- ------- --------------------- ! + ! 07.12.2017 Patrick Vogler B87D120 V 0.1.0 Enum created ! + ! ! + \*----------------------------------------------------------------------------------------------------------*/ + typedef enum{ + bwc_qt_none, + bwc_qt_derived, + } bwc_quant_st; - /*----------------------------------------------------------------------------------------------------------*\ - ! ENUM NAME: bwc_tile_instr ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Constant Description ! - ! -------- ----------- ! - ! - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 17.04.2019 Patrick Vogler B87D120 V 0.1.0 Enum created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef enum{ - bwc_tile_sizeof, - bwc_tile_numbof, - } bwc_tile_instr; + /*----------------------------------------------------------------------------------------------------------*\ + ! ENUM NAME: bwc_tile_instr ! + ! ----------- ! + ! ! + ! DESCRIPTION: ! + ! ------------ ! + ! DESCRIPTION NEEDED ! + ! ! + ! PARAMETERS: ! + ! ----------- ! + ! Constant Description ! + ! -------- ----------- ! + ! - - ! + ! ! + ! DEVELOPMENT HISTORY: ! + ! -------------------- ! + ! ! + ! Date Author Change Id Release Description Of Change ! + ! ---- ------ --------- ------- --------------------- ! + ! 17.04.2019 Patrick Vogler B87D120 V 0.1.0 Enum created ! + ! ! + \*----------------------------------------------------------------------------------------------------------*/ + typedef enum{ + bwc_tile_sizeof, + bwc_tile_numbof, + } bwc_tile_instr; #endif \ No newline at end of file diff --git a/include/library/private/dwt.h b/include/library/private/dwt.h index 8265a03..d9fa0eb 100755 --- a/include/library/private/dwt.h +++ b/include/library/private/dwt.h @@ -1,328 +1,169 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: dwt.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| DESCRIPTION NEEDED. || -|| || -|| STRUCTS: || -|| -------- || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 21.03.2018 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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" + /************************************************************************************************\ + || _ _ _ ____ _ _ _ ___ ____ || + || | |\ | | | | | | \ |___ || + || | | \| |___ |___ |__| |__/ |___ || + || || + \************************************************************************************************/ + #include "types.h" - /************************************************************************************************************\ - || _ _ ____ ____ ____ ____ ____ || - || |\/| |__| | |__/ | | [__ || - || | | | | |___ | \ |__| ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! DESCRIPTION: ! - ! ------------ ! - ! ! - ! This macro defines the maximum decomposition level up to which the wavelet filer energy gain ! - ! is calculated. Beyond the maximum decomposition level the energy gain will only be ! - ! approximated. ! - ! ! - ! Macros: ! - ! ------- ! - ! Macro Description ! - ! ----- ----------- ! - ! MAX_DECOMPOSITION_LEVELS - Maximum number of wavelet layers for which the energy ! - ! gain is calculated. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 20.03.2018 Patrick Vogler B87D120 V 0.1.0 Macros created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define MAX_DECOMPOSITION_LEVELS 4 + /************************************************************************************************\ + || _ _ ____ ____ ____ ____ ____ || + || |\/| |__| | |__/ | | [__ || + || | | | | |___ | \ |__| ___] || + || || + \************************************************************************************************/ + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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. ! - ! ! - ! Macros: ! - ! ------- ! - ! Macro Description ! - ! ----- ----------- ! - ! DWT_9X7_H0 ! - ! DWT_9X7_H1 ! - ! DWT_9X7_H2 - Coefficients for the (9-7) ! - ! DWT_9X7_H3 low pass synthesis filter. ! - ! ! - ! DWT_9X7_G0 ! - ! DWT_9X7_G1 ! - ! DWT_9X7_G2 ! - ! DWT_9X7_G3 - Coefficients for the (9-7) ! - ! DWT_9X7_G4 high pass synthesis filter. ! - ! ! - ! ALPHA ! - ! BETA ! - ! GAMMA ! - ! DELTA ! - ! KAPPA_H - Coefficients for the (9-7) ! - ! KAPPA_L lifting scheme. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 20.03.2018 Patrick Vogler B87D120 V 0.1.0 Macros created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define DWT_9X7_H0 1.115087052457000f - #define DWT_9X7_H1 0.591271763114250f - #define DWT_9X7_H2 -0.057543526228500f - #define DWT_9X7_H3 -0.091271763114250f + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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 - #define DWT_9X7_G1 -0.533728236885750f - #define DWT_9X7_G2 -0.156446533057980f - #define DWT_9X7_G3 0.033728236885750f - #define DWT_9X7_G4 0.053497514821620f + #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 - #define BETA -0.052980118572961f - #define GAMMA 0.882911075530934f - #define DELTA 0.360523644801462f - #define KAPPA_H 1.230174104914001f - #define KAPPA_L 0.812893066115961f + #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. ! - ! ! - ! Macros: ! - ! ------- ! - ! Macro Description ! - ! ----- ----------- ! - ! DWT_5X3_H0 - Coefficients for the (9-7) ! - ! DWT_5X3_H1 low pass synthesis filter. ! - ! ! - ! DWT_5X3_G0 ! - ! DWT_5X3_G1 - Coefficients for the (9-7) ! - ! DWT_5X3_G2 high pass synthesis filter. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 20.03.2018 Patrick Vogler B87D120 V 0.1.0 Macros created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define DWT_5X3_H0 1.0f - #define DWT_5X3_H1 0.5f + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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 - #define DWT_5X3_G1 -0.25f - #define DWT_5X3_G2 -0.125f + #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. ! - ! ! - ! Macros: ! - ! ------- ! - ! Macro Description ! - ! ----- ----------- ! - ! DWT_HAAR_G0 - Coefficients for the Haar ! - ! DWT_HAAR_G1 low pass synthesis filter. ! - ! ! - ! DWT_HAAR_H1 - Coefficients for the Haar ! - ! DWT_HAAR_H2 high pass synthesis filter. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 20.03.2018 Patrick Vogler B87D120 V 0.1.0 Macros created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define DWT_HAAR_H0 1 - #define DWT_HAAR_H1 1 + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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 - #define DWT_HAAR_G1 -0.5 + #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 dimen- ! - ! sional, dyadic tree structured 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. ! - ! ! - ! VARIABLES: ! - ! ----------- ! - ! Variable Description ! - ! -------- ----------- ! - ! DWT_ENERGY_GAIN_LUT - Lookup-table for the CDF-(9/7), LG-(5/3) and Haar ! - ! dwt energy gain factor. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 21.03.2018 Patrick Vogler B87D120 V 0.1.0 Variables created ! - \*----------------------------------------------------------------------------------------------------------*/ - extern double DWT_ENERGY_GAIN_LUT[3][2 * MAX_DECOMPOSITION_LEVELS + 2]; + /************************************************************************************************\ + || ____ _ _ ___ ____ ____ _ _ ____ _ _ _ ____ ____ _ ____ ___ _ ____ ____ || + || |___ \/ | |___ |__/ |\ | |__| | | | |__| |__/ | |__| |__] | |___ [__ || + || |___ _/\_ | |___ | \ | \| | | |___ \/ | | | \ | | | |__] |___ |___ ___] || + || || + \************************************************************************************************/ + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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]; - /************************************************************************************************************\ - || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || - || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || - || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: uchar initialize_gain_lut() ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function calculates the energy gain factor Gb for the one dimensional, dyadic tree ! - ! structured CDF-(9/7), LeGall-(5/3) and Haar wavelet transform with 5 levels. The energy ! - ! gain factors are calculated according to equation (4.39) from JPEG2000 by David S. Taubman ! - ! and Michael W. Marcellin (p. 193): ! - ! ! - ! s_L1[n] = g0[n], s_H1[n] = h0[n], ! - ! s_Ld[n] = ∑(s_Ld-1[k]*g0[n-2k], k), s_Hd[n] = ∑(s_Hd-1[k]*g0[n-2k], k). ! - ! ! - ! The energy gain factors are stored in their corresponding lookup tables and used to calcu- ! - ! late the energy gain for the multi dimensional wavelet transforms according to equation ! - ! (4.40) from JPEG2000 by David S. Taubman and Michael W. Marcellin (p.193): ! - ! ! - ! s_LLD[n1,n2] = s_LD[n1] * s_LD[n2] => G_LLD = G_LD * G_LD ! - ! s_HLD[n1,n2] = s_LD[n1] * s_HD[n2] => G_HLD = G_LD * G_HD ! - ! s_LHD[n1,n2] = s_HD[n1] * s_LD[n2] => G_LHD = G_HD * G_LD ! - ! s_HHD[n1,n2] = s_HD[n1] * s_HD[n2] => G_HHD = G_HD * G_HD ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - initialize_gain_lut(); - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: bwc_float get_dwt_energy_gain(bwc_field *field, uchar highband_flag, uint level) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function evaluates the energy gain factor according to the the specified decomposition ! - ! level. For decomposition levels larger than MAX_DECOMPOSITION_LEVELS the filter gain for ! - ! the extra levels is approximated by multiplying the energy gain factor by 2. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - bwc_float - get_dwt_energy_gain(bwc_field *field, uchar highband_flag, uint16 level); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: uchar forward_discrete_wavelet_transform(bwc_field *const field, ! - ! -------------- bwc_parameter *const parameter) ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function performs the forward discrete wavelet transform on the current tile param- ! - ! eter. After loading the flow field samples for a row, column or spatial/temporal slice ! - ! into a working buffer, a boundary extension operation is performed to ensure an approp. ! - ! sample base. The working buffer is then transform using the wavelet kernel selected for ! - ! the spatial or temporal dimension, sorted into high- and low-frequency samples and flushed ! - ! back into the tile parameter memory block. This operation is performed for every row, ! - ! column and spatial/temporal slice for ndecomp number of decomposition levels. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - forward_discrete_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: uchar inverse_discrete_wavelet_transform(bwc_field *const field, ! - ! -------------- bwc_parameter *const parameter) ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function performs the inverse discrete wavelet transform on the current tile param- ! - ! eter. After loading the interweaved wavelet coefficients for a row, column or spatial/ ! - ! temporal slice into a working buffer, a boundary extension operation is performed to ! - ! ensure an appropriate sample base. The working buffer is then transform using the wave- ! - ! let kernel selected for the spatial or temporal dimension and flushed back into the tile ! - ! parameter memory block. This operation is performed for every row, column and spatial/ ! - ! temporal slice for ndecomp number of decomposition levels. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - inverse_discrete_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter); + /************************************************************************************************\ + || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || + || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || + || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || + || || + \************************************************************************************************/ + 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 \ No newline at end of file diff --git a/include/library/private/libbwc.h b/include/library/private/libbwc.h index eca0717..36d6e92 100755 --- a/include/library/private/libbwc.h +++ b/include/library/private/libbwc.h @@ -1,380 +1,147 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| Version 0.1.1 || -|| || -|| File: bwc.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| This header defines DESCRIPTION NEEDED. || -|| || -|| STRUCTS: || -|| -------- || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| - bwc_kill_compression || -|| - bwc_add_param || -|| - bwc_set_quantization_style || -|| - bwc_set_progression || -|| - bwc_set_kernels || -|| - bwc_set_levels || -|| - bwc_set_codeblocks || -|| - bwc_set_qm || -|| - bwc_set_tiles || -|| - bwc_initialize_compression || -|| - bwc_create_compression || -|| || -|| 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 BWC_H -#define BWC_H - /************************************************************************************************************\ - || _ _ _ ____ _ _ _ ___ ____ || - || | |\ | | | | | | \ |___ || - || | | \| |___ |___ |__| |__/ |___ || - || || - \************************************************************************************************************/ - #include "bitstream.h" - #include "codestream.h" - #include "constants.h" - #include "macros.h" - #include "mq_types.h" - #include "types.h" +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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" - /************************************************************************************************************\ - || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || - || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || - || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: bwc_field *bwc_initialize_data(...) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function initializes the bwc_data structure with all necessary parameters. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - bwc_data* - bwc_initialize_data(double* field, uint64 const nX, uint64 const nY, uint64 const nZ, uint16 const nTS, uint8 const nPar, char *file_extension); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_add_param(bwc_data* data, char *name, uint16 sample, uchar dim, uint8 precision) ! - ! -------------- ! - ! ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function initializes and adds new parameters to the parameter linked list. The linked ! - ! list stores the parameter name, its precision, sampling factor and the dimension for which ! - ! the sampling is active. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_add_param(bwc_data* data, char *name, uint8 precision); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: bwc_field *bwc_initialize_data(...) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function is used to copy the numerical dataset stored in the bwc_data ! - ! structure to a user supplied memory block. A size argument is necessary ! - ! to verify that the memory block has the correct size. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_get_data(bwc_data* data, uchar* buffer, uint64 size); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_free_data(bwc_data* file) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function deallocates the data structure used to store an numerical dataset/compressed ! - ! and can be called if an error occurs or once the data is no longer needed is to be closed. ! - ! The deallocation will be carried out down to the structure levels that have been allocated. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_free_data(bwc_data* data); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: uchar create_field(bwc_field *const field) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function creates the field structure used to (de)compress a floating point array de- ! - ! fined by the bwc_initialize function. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - create_field(bwc_field *const field); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void kill_compression(bwc_field *const field) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function deallocates the compression field structure used to define and control the ! - ! bwc codec and can be called if an error occurs during the (de-)compression stage or once ! - ! the codec has finished. The deallocation will be carried out down to the structure levels ! - ! that have been allocated. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_kill_compression(bwc_field *const field); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: bwc_field *bwc_initialize_field(bwc_data *const data) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function initializes the bwc_field structure with all necessary standard parameters ! - ! to (de)compress a floating point array with nX * nY * nZ grid points, nTS timesteps and ! - ! nPar parameters. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - bwc_field* - bwc_initialize_field(bwc_data *const data); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_set_error_resilience(bwc_field *const field) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function sets the error resilience marker in the bwc_field structure if an error ! - ! resilient compression approach is to be employed. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_set_error_resilience(bwc_field *const field); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_set_quantization_style(bwc_field *const field, bwc_quant_st quantization_style) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function amends the quantization style in the bwc_field structure according to the ! - ! specified value. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_set_quantization_style(bwc_field *const field, bwc_quant_st quantization_style); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_set_quantization_step_size(bwc_field *const field, double delta) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function amends the quantization step size in the bwc_field structure according to ! - ! the specified value. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_set_quantization_step_size(bwc_field *const field, double delta); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_set_progression(bwc_field *const field, bwc_prog_ord progression) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function amends the progression order in the bwc_field structure according to the ! - ! specified value. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_set_progression(bwc_field *const field, bwc_prog_ord progression); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_set_kernels(bwc_field *const field, bwc_dwt_filter KernelX, ! - ! -------------- bwc_dwt_filter KernelY, ! - ! bwc_dwt_filter KernelZ, ! - ! bwc_dwt_filter KernelTS) ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function amends the wavelet kernels in the bwc_field structure according to the ! - ! specified values. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_set_kernels(bwc_field *const field, bwc_dwt_filter KernelX, bwc_dwt_filter KernelY, - bwc_dwt_filter KernelZ, bwc_dwt_filter KernelTS); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_set_decomp(bwc_field *const field, uint8 decompX, uint8 decompY, ! - ! -------------- uint8 decompZ, uint8 decompTS) ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function amends the decomposition levels in the bwc_field structure according to the ! - ! specified values. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_set_decomp(bwc_field *const field, uint8 decompX, uint8 decompY, uint8 decompZ, uint8 decompTS); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_set_precincts(bwc_field *const field, uint8 pX, uint8 pY, uint8 pZ, uint8 pTS) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function amends the precinct size in the bwc_field structure according to the ! - ! specified values. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_set_precincts(bwc_field *const field, uint8 pX, uint8 pY, uint8 pZ, uint8 pTS); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_set_codeblocks(bwc_field *const field, uint8 cbX, uint8 cbY, ! - ! -------------- uint8 cbZ, uint8 cbTS) ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function amends the codeblock size in the bwc_field structure according to the ! - ! specified values. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_set_codeblocks(bwc_field *const field, uint8 cbX, uint8 cbY, uint8 cbZ, uint8 cbTS); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_set_qm(bwc_field *const field, uint8 Qm) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function amends the Q number formate range in the bwc_field structure according to the ! - ! specified value. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_set_qm(bwc_field *const field, uint8 Qm); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_set_tiles(bwc_field *const field, uint32 tilesX, uint32 tilesY, uint32 tilesZ, ! - ! -------------- uint32 tilesTS, uchar instr) ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function amends the tileSize and num_Tiles values in the bwc_field structure according ! - ! to the specified values. The NUMBEROF and SIZEOF constants can be used to either specify ! - ! the tile sizes or the number of tiles in each spatial and temporal directions. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - bwc_set_tiles(bwc_field *const field, uint64 tilesX, uint64 tilesY, uint64 tilesZ, uint16 tilesTS, bwc_tile_instr instr); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_create_compression(bwc_field *field, char *rate_control) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function creates the field structure used to compress a floating point array defined ! - ! by the bwc_initialize function. For a compression run, the rate_control and instr arguments ! - ! need to be passed to the function to properly set up the lossy compression stage. Here, the ! - ! instr parameter defines whether rate control is defined by a BITRATE - a floating point val-! - ! ue defining the average number of bits per datapoint - and ACCURACY - an integer value de- ! - ! fining the exponent of the maximum allowable error (i.e. 15 for err = 1e-15). ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - bwc_create_compression(bwc_field *field, char *rate_control); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: uchar bwc_compress(bwc_field *const field, bwc_float *const data) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! Description needed. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - bwc_compress(bwc_field *const field, bwc_data *const data); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_create_compression(bwc_field **field_ptr, char *rate_control, uchar instr) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function parses the supplied bwc codestream and sets up the field structure used to ! - ! decompress the numerical dataset. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - bwc_field * - bwc_create_decompression(bwc_data *const data, uint8 layer); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void bwc_create_compression(bwc_field **field, float rate_control, uchar instr) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function creates the field structure used to compress a floating point array defined ! - ! by the bwc_initialize function at a prescribed bitrate or accuracy. In this context, the ! - ! bitrate is a floating point value defining the average number of bits per datapoint and ! - ! the accuracy is an integer value defining the exponent of the maximum allowable error ! - ! (i.e. 15 for err = 1e-15). ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - bwc_decompress(bwc_field *const field, bwc_data *const data); + /************************************************************************************************\ + || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || + || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || + || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || + || || + \************************************************************************************************/ + //==========|==========================|======================|======|=======|==================== + 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 \ No newline at end of file diff --git a/include/library/private/macros.h b/include/library/private/macros.h index 749d79e..9d0a9a3 100755 --- a/include/library/private/macros.h +++ b/include/library/private/macros.h @@ -1,140 +1,82 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: macros.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| DESCRIPTION NEEDED. || -|| || -|| STRUCTS: || -|| -------- || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 29.05.2017 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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 Macros are used to calculate the maximum and minimum between two values. ! - ! ! - ! Macros: ! - ! ------- ! - ! Macro Description ! - ! ----- ----------- ! - ! MAX(x, y) - Returns the maximum value of two values. ! - ! ! - ! MIN(x, y) - Returns the minimum value of two values. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 21.03.2018 Patrick Vogler B87D120 V 0.1.0 Macros created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define MAX(x, y) (((x) < (y))?(y):(x)) - #define MIN(x, y) (((x) > (y))?(y):(x)) + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 16.09.2019 Patrick Vogler B87D120 V 0.1.0 Macros created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define GET_DIM(x) (sizeof(x)/sizeof(*(x))) + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! DESCRIPTION: ! + ! ------------ ! + ! ! + ! This macro is used to evaluate the size of an array. ! + ! ! + \*----------------------------------------------------------------------------------------------*/ + #define GET_DIM(x) (sizeof(x)/sizeof(*(x))) - /*----------------------------------------------------------------------------------------------------------*\ - ! DESCRIPTION: ! - ! ------------ ! - ! ! - ! These Constants describe the codestream markers used to create the embedded codestream. ! - ! ! - ! CONSTANTS: ! - ! ----------- ! - ! Constant Description ! - ! -------- ----------- ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 01.12.2017 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define MEMERROR "o##########################################################o\n"\ - "| ERROR: Out of memory |\n"\ - "o##########################################################o\n" - - /*----------------------------------------------------------------------------------------------------------*\ - ! DESCRIPTION: ! - ! ------------ ! - ! ! - ! These Constants describe the codestream markers used to create the embedded codestream. ! - ! ! - ! CONSTANTS: ! - ! ----------- ! - ! Constant Description ! - ! -------- ----------- ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 01.12.2017 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define CSERROR "o##########################################################o\n"\ - "| ERROR: Invalid Codestream |\n"\ + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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 \ No newline at end of file diff --git a/include/library/private/mq.h b/include/library/private/mq.h index 8a39519..98de295 100755 --- a/include/library/private/mq.h +++ b/include/library/private/mq.h @@ -1,155 +1,114 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: mq.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| DESCRIPTION NEEDED. || -|| || -|| STRUCTS: || -|| -------- || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 13.02.2019 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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" - /************************************************************************************************************\ - || _ _ _ ____ _ _ _ ___ ____ || - || | |\ | | | | | | \ |___ || - || | | \| |___ |___ |__| |__/ |___ || - || || - \************************************************************************************************************/ - #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 - /************************************************************************************************************\ - || ____ ____ _ _ ____ ___ ____ _ _ ___ ____ || - || | | | |\ | [__ | |__| |\ | | [__ || - || |___ |__| | \| ___] | | | | \| | ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! DESCRIPTION: ! - ! ------------ ! - ! ! - ! These macros define the context state indices used by the mq coder for probability estima- ! - ! tion. For a more thorough treatment of the context assignments see page 487 JPEG2000 by ! - ! David S. Taubman and Michael W. Marcellin. ! - ! ! - ! Macros: ! - ! ------- ! - ! Macro Description ! - ! ----- ----------- ! - ! CONTEXT_SIG - Starting indices for the significance context labels. ! - ! CONTEXT_RUN - Indices for the run context label. ! - ! CONTEXT_SIGN - Starting indices for the sign context labels. ! - ! CONTEXT_MAG - Starting indices for the magnitude context labels. ! - ! CONTEXT_UNI - Indices for the uni context label. ! - ! CONTEXT_TOTAL - Total number of context labels. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 21.02.2019 Patrick Vogler B87D120 V 0.1.0 Macros created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define CONTEXT_SIG 0 - #define CONTEXT_RUN 9 - #define CONTEXT_SIGN 10 - #define CONTEXT_MAG 15 - #define CONTEXT_UNI 18 - #define CONTEXT_TOTAL 19 - - /************************************************************************************************************\ - || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || - || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || - || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! TYPE NAME: Template ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - initialize_bit_encoder(bwc_coder *const coder, const uint8 number_of_contexts); - - uchar - bit_encoder_next_run(bwc_bit_coder *const bitcoder); - - void - bit_encode(bwc_bit_coder *const bitcoder, const uint8 s, const uint8 k); - - void - bit_encoder_truncation_length_min(bwc_coder_state *const state); - - void - bit_encoder_termination(bwc_bit_coder *const bitcoder); - - void - free_bit_encoder(bwc_coder *const coder); - - uchar - initialize_bit_decoder(bwc_coder *const coder, const uint8 number_of_contexts, const int64 Lmax); - - uint8 - bit_decode(bwc_bit_coder *const bitcoder, const uint8 k); - - uint64 - bit_coder_get_no_bytes(bwc_bit_coder *const bitcoder); - - void - bit_coder_get_pass_lengths(bwc_bit_coder *const bitcoder, bwc_encoded_cblk *const encoded_cblk); - - void - bit_coder_reset_ptr(bwc_bit_coder *const bitcoder, uchar *const memory); + /************************************************************************************************\ + || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || + || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || + || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || + || || + \************************************************************************************************/ + 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 \ No newline at end of file diff --git a/include/library/private/mq_types.h b/include/library/private/mq_types.h index 6f6a93f..84c5c7b 100755 --- a/include/library/private/mq_types.h +++ b/include/library/private/mq_types.h @@ -1,222 +1,121 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: prim_types_double.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| This header defines a set of derrived types used for the mq encoder during the entropy encoding stage of the big whoop || -|| compression algorithm. || -|| || -|| STRUCTS: || -|| -------- || -|| - bwc_context_state || -|| - bwc_coder_state || -|| - bwc_bit_coder || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 20.02.2019 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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 - /************************************************************************************************************\ - || _ _ _ ____ _ _ _ ___ ____ || - || | |\ | | | | | | \ |___ || - || | | \| |___ |___ |__| |__/ |___ || - || || - \************************************************************************************************************/ - #include + /************************************************************************************************\ + || ___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____ || + || | \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ || + || |__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___] || + || || + \************************************************************************************************/ + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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 - /************************************************************************************************************\ - || ___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____ || - || | \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ || - || |__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_context_state ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! - ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! p unsigned int(16 bit) - LPS Probability estimate. ! - ! ! - ! sk unsigned int(8 bit) - Most Probable Symbol. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! MPS context* - New context if the coded symbol is a ! - ! Most Probable Symbol (MPS). ! - ! ! - ! LPS context* - New context if the coded symbol is a ! - ! Least Probable Symbol (LPS). ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 14.02.2019 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct context - { - uint16_t p; - uint8_t sk; - const struct context *const MPS; - const struct context *const LPS; - } bwc_context_state; + 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; - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_coder_state ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! - ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! L int(64 bit) - Number of code bytes which have been ! - ! generated so far. ! - ! ! - ! C unsigned int(32 bit) - Lower bound register used to define ! - ! the lower bound of the coding interval. ! - ! ! - ! A unsigned int(16 bit) - Length register used to define the up- ! - ! bound of the coding interval. ! - ! ! - ! t int(8 bit) - Down counter which is used to evaluate ! - ! when partially generated code bits ! - ! should be moved out of the C register ! - ! in to the temporary byte buffer b. ! - ! ! - ! b unsigned char* - Byte buffer. ! - ! ! - ! T unsigned char - Temporary byte buffer. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! next state* - Coder state of the next coding pass. ! - ! ! - ! prev state* - Coder state of the previous coding ! - ! pass. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 14.02.2019 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct state - { - int64_t L; - uint32_t C; - uint16_t A; - int8_t t; - unsigned char *b; - unsigned char T; - struct state *next; - struct state *prev; - } bwc_coder_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 - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_bit_coder ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! - ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! Lmax unsigned int(64 bit) - Number of code bytes (used by decoder). ! - ! ! - ! nContext unsigned int(8 bit) - Number of context states that need to ! - ! be tracked during (de)compression. ! - ! ! - ! b unsigned char* - Temporary byte buffer. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! state bwc_coder_state* - Coder state for the current coding ! - ! pass. ! - ! ! - ! context bwc_coder_state* - Context states for the current coding ! - ! pass. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 14.02.2019 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - int64_t Lmax; - uint8_t nContext; - unsigned char *b; - bwc_coder_state *state; - bwc_context_state const **context; - } bwc_bit_coder; + 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 \ No newline at end of file diff --git a/include/library/private/prim_types_double.h b/include/library/private/prim_types_double.h index 948a83b..a5db7e5 100755 --- a/include/library/private/prim_types_double.h +++ b/include/library/private/prim_types_double.h @@ -1,163 +1,133 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: prim_types_double.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| This header defines a set of basic arithmetic types with specified widths to be used in || -|| the big whoop compression algorithm. The width of an arithmetic type is defined as the || -|| number of bits used to store its value. || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 07.12.2017 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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 - /************************************************************************************************************\ - || _ _ _ ____ _ _ _ ___ ____ || - || | |\ | | | | | | \ |___ || - || | | \| |___ |___ |__| |__/ |___ || - || || - \************************************************************************************************************/ - #include + /************************************************************************************************\ + || ___ ____ _ _ _ _ ___ _ _ _ ____ ___ _ _ ___ ____ ____ || + || |__] |__/ | |\/| | | | | | |___ | \_/ |__] |___ [__ || + || | | \ | | | | | | \/ |___ | | | |___ ___] || + || || + \************************************************************************************************/ + typedef unsigned char uchar; + typedef unsigned short ushort; + typedef unsigned int uint; - /************************************************************************************************************\ - || ___ ____ _ _ _ _ ___ _ _ _ ____ ___ _ _ ___ ____ ____ || - || |__] |__/ | |\/| | | | | | |___ | \_/ |__] |___ [__ || - || | | \ | | | | | | \/ |___ | | | |___ ___] || - || || - \************************************************************************************************************/ - 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 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; - 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 constants describe the minimum and maximum values for a double precision IEEE 754 ! - ! floating point variable. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 07.12.2018 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define FLT_MAX 1.7976931348623157e+308 - #define FLT_MIN 2.2250738585072014e-308 + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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 constants describe the precision (in bits and bytes) of the primitive floating point ! - ! type used during (de)compression as well as the number of bits used to represent the ! - ! mantissa and exponent fields. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 07.12.2018 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define PREC_BIT 63 - #define PREC_MANTISSA 52 - #define PREC_EXPONENT 11 - #define PREC_BYTE 8 + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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: ! - ! ------------ ! - ! ! - ! These constants describe the bit masks used to access the sign, mantissa and exponent of ! - ! the primitive floating point type used during (de)compression. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 07.12.2018 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define SIGN 0x8000000000000000 - #define MANTISSA 0x000FFFFFFFFFFFFF - #define EXPONENT 0x7FF0000000000000 - - /*----------------------------------------------------------------------------------------------------------*\ - ! DESCRIPTION: ! - ! ------------ ! - ! ! - ! This constants describe the maximum number of encoding passes during the entropy encoding ! - ! stage. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 03.07.2018 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define MAXIMUM_NO_PASSES (64 * 3) - 2 + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! DESCRIPTION: ! + ! ------------ ! + ! ! + ! This macro describe the maximum number of possible encoding passes during the ! + ! entropy encoding stage. ! + ! ! + \*----------------------------------------------------------------------------------------------*/ + #define MAXIMUM_NO_PASSES (64 * 3) - 2 #endif \ No newline at end of file diff --git a/include/library/private/prim_types_single.h b/include/library/private/prim_types_single.h index 2c3872e..e2e8365 100755 --- a/include/library/private/prim_types_single.h +++ b/include/library/private/prim_types_single.h @@ -1,163 +1,133 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: prim_types_single.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| This header defines a set of basic arithmetic types with specified widths to be used in || -|| the big whoop compression algorithm. The width of an arithmetic type is defined as the || -|| number of bits used to store its value. || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 07.12.2017 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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 - /************************************************************************************************************\ - || _ _ _ ____ _ _ _ ___ ____ || - || | |\ | | | | | | \ |___ || - || | | \| |___ |___ |__| |__/ |___ || - || || - \************************************************************************************************************/ - #include + /************************************************************************************************\ + || ___ ____ _ _ _ _ ___ _ _ _ ____ ___ _ _ ___ ____ ____ || + || |__] |__/ | |\/| | | | | | |___ | \_/ |__] |___ [__ || + || | | \ | | | | | | \/ |___ | | | |___ ___] || + || || + \************************************************************************************************/ + typedef unsigned char uchar; + typedef unsigned short ushort; + typedef unsigned int uint; - /************************************************************************************************************\ - || ___ ____ _ _ _ _ ___ _ _ _ ____ ___ _ _ ___ ____ ____ || - || |__] |__/ | |\/| | | | | | |___ | \_/ |__] |___ [__ || - || | | \ | | | | | | \/ |___ | | | |___ ___] || - || || - \************************************************************************************************************/ - 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 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; - 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 constants describe the minimum and maximum values for a double precision IEEE 754 ! - ! floating point variable. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 07.12.2018 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define FLT_MAX 1.70141183e+38 - #define FLT_MIN 1.17549435e-38 + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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 constants describe the precision (in bits and bytes) of the primitive floating point ! - ! type used during (de)compression as well as the number of bits used to represent the ! - ! mantissa and exponent fields. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 07.12.2018 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define PREC_BIT 31 - #define PREC_MANTISSA 23 - #define PREC_EXPONENT 8 - #define PREC_BYTE 4 + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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: ! - ! ------------ ! - ! ! - ! These constants describe the bit masks used to access the sign, mantissa and exponent of ! - ! the primitive floating point type used during (de)compression. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 07.12.2018 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define SIGN 0x80000000 - #define MANTISSA 0x007FFFFF - #define EXPONENT 0x7F800000 - - /*----------------------------------------------------------------------------------------------------------*\ - ! DESCRIPTION: ! - ! ------------ ! - ! ! - ! This constants describe the maximum number of encoding passes during the entropy encoding ! - ! stage. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 03.07.2018 Patrick Vogler B87D120 V 0.1.0 Constants created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define MAXIMUM_NO_PASSES (32 * 3) - 2 + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! DESCRIPTION: ! + ! ------------ ! + ! ! + ! This macro describe the maximum number of possible encoding passes during the ! + ! entropy encoding stage. ! + ! ! + \*----------------------------------------------------------------------------------------------*/ + #define MAXIMUM_NO_PASSES (32 * 3) - 2 #endif \ No newline at end of file diff --git a/include/library/private/tagtree.h b/include/library/private/tagtree.h index 4451388..721696a 100755 --- a/include/library/private/tagtree.h +++ b/include/library/private/tagtree.h @@ -1,161 +1,95 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: tagtree.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| DESCRIPTION NEEDED. || -|| || -|| STRUCTS: || -|| -------- || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 18.05.2018 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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 "types.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. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - kill_tagtree(bwc_tagtree* tagtree); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - reset_tagtree(bwc_tagtree* const tagtree); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uint16 - tagtree_get_value(const bwc_tagtree* const tagtree, const uint64 leaf_index); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - tagtree_set_value(bwc_tagtree* const tagtree, const uint64 leaf_index, const uint16 value); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - bwc_tagtree* - initialize_tagtree(const uint64 leafsX, const uint64 leafsY, const uint64 leafsZ, const uint64 leafsTS); - - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - void - encode_tagtree(bwc_tagtree *const tagtree, bwc_stream *const stream, const uint32 threshold, const uint32 leaf_index, const uchar estimate); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: void *test(void) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - decode_tagtree(bwc_tagtree *const tagtree, bwc_stream *const stream, const uint32 threshold, const uint32 leaf_index); + /************************************************************************************************\ + || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || + || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || + || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || + || || + \************************************************************************************************/ + 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, + bwc_stream *const stream, + uint32 const threshold, + uint32 const leaf_index, + uchar const estimate); + //==========|==========================|======================|======|=======|==================== + uchar decode_tagtree (bwc_tagtree *const tagtree, + bwc_stream *const stream, + uint32 const threshold, + uint32 const leaf_index); #endif \ No newline at end of file diff --git a/include/library/private/tier1.h b/include/library/private/tier1.h index 7526caa..9ce8a36 100755 --- a/include/library/private/tier1.h +++ b/include/library/private/tier1.h @@ -1,153 +1,173 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: tier1.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| DESCRIPTION NEEDED. || -|| || -|| STRUCTS: || -|| -------- || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| || -|| 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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" - /************************************************************************************************************\ - || _ _ _ ____ _ _ _ ___ ____ || - || | |\ | | | | | | \ |___ || - || | | \| |___ |___ |__| |__/ |___ || - || || - \************************************************************************************************************/ - #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 macro defines the maximum decomposition level up to which the wavelet filer energy gain ! - ! is calculated. Beyond the maximum decomposition level the energy gain will only be ! - ! approximated. ! - ! ! - ! Macros: ! - ! ------- ! - ! Macro Description ! - ! ----- ----------- ! - ! MAX_DECOMPOSITION_LEVELS - Maximum number of wavelet layers for which the energy ! - ! gain is calculated. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 20.03.2018 Patrick Vogler B87D120 V 0.1.0 Macros created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define DISTORTION_DELTA 0.5f - #define DISTORTION_MANTISSA 5 - #define DISTORTION_PRECISION 6 + /************************************************************************************************\ + || ___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____ || + || | \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ || + || |__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___] || + || || + \************************************************************************************************/ + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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. - /*----------------------------------------------------------------------------------------------------------*\ - ! DESCRIPTION: ! - ! ------------ ! - ! ! - ! These macros define the irrational coefficients for the high and low pass synthesis filters ! - ! associated with the (5-3) LeGall-Wavelet. ! - ! ! - ! Macros: ! - ! ------- ! - ! Macro Description ! - ! ----- ----------- ! - ! DWT_5X3_H0 - Coefficients for the (9-7) ! - ! DWT_5X3_H1 low pass synthesis filter. ! - ! ! - ! DWT_5X3_G0 ! - ! DWT_5X3_G1 - Coefficients for the (9-7) ! - ! DWT_5X3_G2 high pass synthesis filter. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 20.03.2018 Patrick Vogler B87D120 V 0.1.0 Macros created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define DWT_5X3_H0 1.0f - #define DWT_5X3_H1 0.5f + uint8 delta; // Delayed sig. for two adjacent stripes. + uint8 sigma; // Significance for two adjacent stripes. + uint8 pi; // Cdng pass membership for adj. stripes. - #define DWT_5X3_G0 0.75f - #define DWT_5X3_G1 -0.25f - #define DWT_5X3_G2 -0.125f + uint8 codingpass; // Last decoded coding pass. - /************************************************************************************************************\ - || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || - || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || - || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! TYPE NAME: Template ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const parameter); + uint8 bitplane; // Last decoded bitplane. + uint8 *bit; // Bitplanes for vertically adj. stripes. + uint8 xi; // Wvlt coef. sign bit for adj. stripes. - uchar - t1_decode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const parameter); + 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; + + /************************************************************************************************************\ + || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || + || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || + || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || + || || + \************************************************************************************************************/ + /*----------------------------------------------------------------------------------------------------------*\ + ! TYPE NAME: Template ! + ! ----------- ! + ! ! + ! DESCRIPTION: ! + ! ------------ ! + ! DESCRIPTION NEEDED ! + ! ! + \*----------------------------------------------------------------------------------------------------------*/ + 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 \ No newline at end of file diff --git a/include/library/private/tier2.h b/include/library/private/tier2.h index d853bfe..cf135de 100755 --- a/include/library/private/tier2.h +++ b/include/library/private/tier2.h @@ -1,133 +1,87 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: tier2.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| DESCRIPTION NEEDED. || -|| || -|| STRUCTS: || -|| -------- || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| - t2_encode || -|| || -|| 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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" - /************************************************************************************************************\ - || _ _ _ ____ _ _ _ ___ ____ || - || | |\ | | | | | | \ |___ || - || | | \| |___ |___ |__| |__/ |___ || - || || - \************************************************************************************************************/ - #include "types.h" - /************************************************************************************************************\ - || _ _ ____ ____ ____ ____ ____ || - || |\/| |__| | |__/ | | [__ || - || | | | | |___ | \ |__| ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! DESCRIPTION: ! - ! ------------ ! - ! ! - ! This macro defines the initial packet header size. ! - ! ! - ! Macros: ! - ! ------- ! - ! Macro Description ! - ! ----- ----------- ! - ! PACKET_HEADER_SIZE - Initial packet header size. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 10.05.2019 Patrick Vogler B87D120 V 0.1.0 Macros created ! - \*----------------------------------------------------------------------------------------------------------*/ - #define PACKET_HEADER_SIZE 512 + /************************************************************************************************\ + || _ _ ____ ____ ____ ____ ____ || + || |\/| |__| | |__/ | | [__ || + || | | | | |___ | \ |__| ___] || + || || + \************************************************************************************************/ + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! DESCRIPTION: ! + ! ------------ ! + ! ! + ! Definition of the initial codestream packet header size. ! + ! ! + \*----------------------------------------------------------------------------------------------*/ + #define PACKET_HEADER_SIZE 512 - /************************************************************************************************************\ - || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || - || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || - || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: uchar t2_encode(bwc_field *const field, bwc_tile *const tile) ! - ! -------------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function defines the rate control portion of the entropy encoding stage. In ! - ! the first step, the quality layers are evaluated according to the bitrates de- ! - ! fined by the user. The quality layers are then used to create the data packets ! - ! that comprise the bwc codestream. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - t2_encode(bwc_field *const field, bwc_tile *const tile); - - /*----------------------------------------------------------------------------------------------------------*\ - ! FUNCTION NAME: uchar parse_packet(bwc_field *const field, bwc_tile *const tile, ! - ! -------------- bwc_packet *const packet, ! - ! uint64 const body_size) ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This function is used to parse a codestream packet for a given precinct (prec_idx) ! - ! and quality layer (q_layer). ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - uchar - parse_packet(bwc_field *const field, bwc_tile *const tile, - bwc_packet *const packet, - uint64 const body_size); + /************************************************************************************************\ + || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || + || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || + || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || + || || + \************************************************************************************************/ + 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 \ No newline at end of file diff --git a/include/library/private/types.h b/include/library/private/types.h index a12744d..2af1a59 100755 --- a/include/library/private/types.h +++ b/include/library/private/types.h @@ -1,1787 +1,761 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| File: types.h || -|| ----- || -|| || -|| DESCRIPTION: || -|| ------------ || -|| This header defines a set of basic arithmetic types with specified widths to be used in the big whoop compression || -|| algorithm. The width of an arithmetic type is defined as the number of bits used to store its value. || -|| || -|| STRUCTS: || -|| -------- || -|| - IEEE_754_Double_Prec || -|| - bwc_sample || -|| - bwc_cblk_ctrl || -|| - bwc_cblk_inf || -|| - bwc_codeblock || -|| - bwc_prec_ctrl || -|| - bwc_prec_inf || -|| - bwc_precinct || -|| - bwc_subb_ctrl || -|| - bwc_subb_inf || -|| - bwc_subband || -|| - bwc_res_ctrl || -|| - bwc_res_inf || -|| - bwc_resolution || -|| - bwc_param_ctrl || -|| - bwc_param_inf || -|| - bwc_parameter || -|| - bwc_tile_ctrl || -|| - bwc_tile_inf || -|| - bwc_tile || -|| - bwc_mpi_ctrl || -|| - bwc_gl_ctrl || -|| - bwc_cmd_opts_ll || -|| - bwc_gl_inf || -|| - bwc_field || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 10.10.2017 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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 - /************************************************************************************************************\ - || _ _ _ ____ _ _ _ ___ ____ || - || | |\ | | | | | | \ |___ || - || | | \| |___ |___ |__| |__/ |___ || - || || - \************************************************************************************************************/ - #ifdef BWC_SINGLE_PRECISION - #include "prim_types_single.h" - #else - #include "prim_types_double.h" - #endif + #include + /************************************************************************************************\ + || _ _ _ ____ _ _ _ ___ ____ || + || | |\ | | | | | | \ |___ || + || | | \| |___ |___ |__| |__/ |___ || + || || + \************************************************************************************************/ + #ifdef BWC_SINGLE_PRECISION + #include "prim_types_single.h" + #else + #include "prim_types_double.h" + #endif - #include "constants.h" - #include "mq_types.h" + #include "constants.h" + #include "mq_types.h" - /************************************************************************************************************\ - || ___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____ || - || | \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ || - || |__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___] || - || || - \************************************************************************************************************/ - /*----------------------------------------------------------------------------------------------------------*\ - ! UNION NAME: bwc_sample ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This union holds a floating point sample of the uncompressed data set and allows access to ! - ! its raw bit representation. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! raw bwc_raw - Raw access to the data sample. ! - ! ! - ! f bwc_float - Floating point representation of the ! - ! data sample. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 11.10.2017 Patrick Vogler B87D120 V 0.1.0 union created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef union - { - bwc_raw raw; - bwc_float f; - } bwc_sample; + /************************************************************************************************\ + || ___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____ || + || | \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ || + || |__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___] || + || || + \************************************************************************************************/ + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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; - /*----------------------------------------------------------------------------------------------------------*\ - | ___ _ ___ ____ ___ ____ ____ ____ _ _ | - | |__] | | [__ | |__/ |___ |__| |\/| | - | |__] | | ___] | | \ |___ | | | | | - | | - \*----------------------------------------------------------------------------------------------------------*/ - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_packed_stream ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure is used to store the reading/writing position, overall size and memory ! - ! handle of a packed stream. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! position unsigned int(32 bit) - Reading/Writing position in the packed ! - ! stream. ! - ! ! - ! size unsigned int(32 bit) - Size of packed stream. ! - ! ! - ! access unsigned char* - Memory handle used to parse the paced ! - ! stream. ! - ! ! - ! memory unsigned char* - Memory handle for the packed stream. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 12.04.2019 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 position; - uint64 size; - uchar *access; - uchar *memory; - } bwc_packed_stream; + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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. - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_stream ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! DESCRIPTION NEEDED ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 28.05.2018 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 L; - uint64 Lmax; - uint64 size_incr; - uint8 T; - int8 t; - uchar error; - uchar *memory; - } bwc_stream; + uchar *access; // Pointer used to parse packed stream. + uchar *memory; // Memory handle for the packed stream. + } bwc_packed_stream; - /*----------------------------------------------------------------------------------------------------------*\ - | ____ _ _ ____ ____ ___ ____ ____ | - | |___ |\ | | | | | \ |___ |__/ | - | |___ | \| |___ |__| |__/ |___ | \ | - | | - \*----------------------------------------------------------------------------------------------------------*/ - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_coder_stripe ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds the sign, bitfield and state information for two vertically adjacent ! - ! sample stripes for easy access during the entropy encoding stage. To facilitate distortion ! - ! estimation the magnitude of the wavelet coefficients is stored in an appropriate sample ! - ! array. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! sample unsigned int*(64 bit) - Array holding two vertically adjacent ! - ! wavelet coefficient stripes. ! - ! ! - ! sigma_u, _r, _d, _l unsigned int*(16 bit) - Pointer used to hold the address of the ! - ! sample states for the upper (_u), right ! - ! (_r), lower (_d) and left (_l) neighbor ! - ! wavelet coefficient stripe. ! - ! ! - ! sigma unsigned int(16 bit) - Sample states for the two vertically ! - ! adjacent wavelet coefficient stripes. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 15.11.2018 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct stripe{ - uint64 *sample; - uint8 codingpass; - uint8 delta; - uint8 sigma; - uint8 bitplane; - uint8 pi; - uint8 xi; - uint8 *bit; - struct stripe *stripe_u; - struct stripe *stripe_r; - struct stripe *stripe_d; - struct stripe *stripe_l; - } bwc_coder_stripe; + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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. - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_coder ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure defines a single tagtree node which stores the node value, node threshold as ! - ! well as the address of the parent node. The tagtree node structure is used in conjuncture ! - ! with a bwc_tagtree instance to define a tagtree. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 02.07.2018 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 buff_incr, buff_size; - uint64 no_full_stripe, no_slice; - uint64 width, height; - uint8 K; - uint8 const *sig2context; - uchar erres; - uchar highband_flag; - uchar *compressed; - bwc_bit_coder *bitcoder; - bwc_coder_stripe *data; - } bwc_coder; + uint64 L; // Number of bytes written to/from stream. + uint64 Lmax; // Size of packed stream. + uint64 size_incr; // Size incrmnt used for stream assembly. - /*----------------------------------------------------------------------------------------------------------*\ - | ___ ____ ____ ___ ____ ____ ____ | - | | |__| | __ | |__/ |___ |___ | - | | | | |__] | | \ |___ |___ | - | | - \*----------------------------------------------------------------------------------------------------------*/ - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_tagtree_node ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure defines a single tagtree node which stores the node value, node threshold as ! - ! well as the address of the parent node. The tagtree node structure is used in conjuncture ! - ! with a bwc_tagtree instance to define a tagtree. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! value unsigned int(16 bit) - Tagtree node value. ! - ! ! - ! threshold unsigned int(16 bit) - Tagtree node threshold. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! parent node* - Address of the parent node. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.05.2018 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct node - { - uint64 index; - uint16 value; - uint16 threshold; - struct node* parent; - } bwc_tagtree_node; + uint8 T; // Byte buffer. + int8 t; // Byte buffer counter. - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_tagtree ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure defines a tagtree instance which stores the number of spatial and temporal ! - ! tagtree leafs as well as the tagtree itself defined by a bwc_tagtree_node linked list. ! - ! The tagtree structure ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! leavesX ,leavesY, leavesZ unsigned int(64 bit) - Variables defining the number of spa- ! - ! tial tagtree leafs. ! - ! ! - ! leavesTS unsigned int(64 bit) - Variable defining the number of tempo- ! - ! ral tagtree leafs. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! nodes bwc_tagtree_node* - Linked list storing the tagtree values ! - ! and thresholds. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 10.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 leavesX, leavesY, leavesZ; - uint64 leavesTS; - bwc_tagtree_node *nodes; - } bwc_tagtree; + uchar *memory; // Memory handle for packed stream chunck. + } bwc_stream; - /*----------------------------------------------------------------------------------------------------------*\ - | ___ ____ ___ ____ ____ ____ ___ | - | | \ |__| | |__| [__ |___ | | - | |__/ | | | | | ___] |___ | | - | | - \*----------------------------------------------------------------------------------------------------------*/ - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_cmd_opts_ll ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure defines a linked list which stores a parameters name, its index and bit ! - ! precision. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! size unsigned int(64 bit) - Size of parameter. ! - ! ! - ! id unsigned int(8 bit) - Index of the parameter. ! - ! ! - ! precision unsigned int(8 bit) - Defines the precision of a compressed ! - ! dataset. ! - ! ! - ! name char - Defines the name of parameter(id). ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! next opt* - Address for the next linked list node. ! - ! ! - ! root opt* - Address for the root linked list node. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 04.12.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! 05.12.2019 Patrick Vogler B87E7E4 V 0.1.0 Removal of unecessary parameters. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct opt - { - uint64 size; - uint8 id; - uint8 precision; - char name[24]; - struct opt *next; - struct opt *root; - } bwc_cmd_opts_ll; - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_gl_inf ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the global information of the uncompressed data set including its ! - ! spatial and temporal dimensions, number of parameters, its bit-depth precision and all the ! - ! parameter information. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! nX ,nY, nZ unsigned int(64 bit) - Variables defining the spatial size of ! - ! the uncompressed dataset. ! - ! ! - ! nTS unsigned int(16 bit) - Variable defining the temporal size of ! - ! the uncompressed dataset. ! - ! ! - ! nPar unsigned int(8 bit) - Defines the number of parameters in the ! - ! uncompressed dataset. ! - ! ! - ! precision unsigned int(8 bit) - Flag used to signal the encoder/decoder ! - ! precision. ! - ! ! - ! f_ext uchar* - Character array used to hold the file ! - ! extension ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! parameter bwc_cmd_opts_ll* - Linked list storing the parameter names,! - ! indices, size and precision. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 10.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! 05.12.2019 Patrick Vogler B87E7E4 V 0.1.0 Removal of unecessary parameters. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 nX, nY, nZ; - uint16 nTS; - uint8 nPar; - uint8 precision; - char f_ext[20]; - bwc_cmd_opts_ll *parameter; - } bwc_gl_inf; + /*----------------------------------------------------------------------------------------------*\ + ! ! + ! 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. - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_data ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure stores the numerical dataset/compressed bitstream passed to or returned ! - ! from the (de)compressor. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! field field - Structure that holds the single (f) or ! - ! double (d) precission parameters of a ! - ! numerical dataset. ! - ! ! - ! file file - Structure that holds the file pointer ! - ! and memory handle for single (f) or ! - ! double (d) precission parameters of a ! - ! numerical dataset. ! - ! ! - ! codestream codestream - Structure that holds the packed data, ! - ! auxiliary information (aux) and com- ! - ! ment stream of a compressed dataset. ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! info bwc_gl_inf* - Structure holding all the global infor- ! - ! mation of the uncompressed data set. ! - ! ! - ! data bwc_packed_stream* - Stream holding the data memory block. ! - ! ! - ! aux bwc_packed_stream* - Stream holding the auxiliary informa- ! - ! tion memory block. ! - ! ! - ! com bwc_packed_stream* - Stream holding the commentary memory ! - ! block. ! - ! ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 17.04.2019 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! 04.12.2019 Patrick Vogler B87E7E4 V 0.1.0 Cleaned up the structure and added ! - ! functionality to store both single ! - ! and double precision datasets. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - bwc_gl_inf info; + uint16 value; // Tagtree node value. + uint16 threshold; // Tagtree node threshold. - struct codestream + 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_packed_stream *data; // Data codestream block. + bwc_packed_stream *aux; // Auxiliary info. codestream block. + bwc_packed_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_packed_stream header; // Packed stream header. + bwc_packed_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_packed_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 { - bwc_packed_stream *data; - bwc_packed_stream *aux; - bwc_packed_stream *com; - }codestream; + double ttl; // Total compression time. - struct field - { - double *d; - float *f; - }field; + double cpy; // Total time used copying data. + double nrm; // Total time used normalizing data. - struct file - { - FILE *fp; - uint64 *d_root; - uint64 *f_root; - }file; - } bwc_data; - - /*----------------------------------------------------------------------------------------------------------*\ - | ____ ____ _ _ ___ ____ ____ ____ ____ _ ____ _ _ | - | | | | |\/| |__] |__/ |___ [__ [__ | | | |\ | | - | |___ |__| | | | | \ |___ ___] ___] | |__| | \| | - | | - \*----------------------------------------------------------------------------------------------------------*/ - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_encoded_block ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the necessary parameters used to define and control a bwc ! - ! codeblock. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! info bwc_cblk_inf* - Structure holding all the codeblock in- ! - ! formation. ! - ! ! - ! control bwc_cblk_ctrl* - Structure holding all the codeblock ! - ! control parameters. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 L[MAXIMUM_NO_PASSES]; - uint16 S[MAXIMUM_NO_PASSES + 1]; - uint8 Kmsbs; - uint8 K; - uint8 Z; - uchar *data; - } bwc_encoded_cblk; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_cblk_ctrl ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the control parameters for the current codeblock used to instruct ! - ! the bwc codec to (de)compress a floating point array. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint16 beta; - uint16 beta_est; - uint16 K; - int16 *cp_contr; - int16 *memory; - } bwc_cblk_ctrl; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_cblk_inf ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds the dimensions for the current codeblock. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! X0, Y0, Z0, TS0 unsigned int(32 bit) - Variables defining the spatial starting ! - ! point of a codeblock. ! - ! ! - ! X1, Y1, Z1, TS1 unsigned int(32 bit) - Variables defining the spatial end ! - ! point of a codeblock. ! - ! ! - ! idx unsigned int(32 bit) - Variable defining codeblock index in ! - ! the current precinct. ! - ! ! - ! TS0 unsigned int(16 bit) - Variable defining the temporal start- ! - ! ing point of a codeblock. ! - ! ! - ! TS1 unsigned int(16 bit) - Variable defining the temporal end ! - ! point of a codeblock. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 X0, Y0, Z0; - uint64 X1, Y1, Z1; - uint32 idx; - uint16 TS0; - uint16 TS1; - } bwc_cblk_inf; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_codeblock ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the necessary parameters used to define and control a bwc ! - ! codeblock. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! info bwc_cblk_inf* - Structure holding all the codeblock in- ! - ! formation. ! - ! ! - ! control bwc_cblk_ctrl* - Structure holding all the codeblock ! - ! control parameters. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - bwc_cblk_inf info; - bwc_cblk_ctrl control; - bwc_encoded_cblk *encoded_block; - } bwc_codeblock; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_prec_ctrl ! - ! ----------- ! - ! ! - ! 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. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! number_of_codeblocks unsigned int(64 bit) - Defines the number of codeblocks for ! - ! the current resolution level. ! - ! ! - ! numPX, -PY, -PZ, -PTS unsigned int(16 bit) - Variables defining the number of code- ! - ! blocks for the current resolution level ! - ! in all spatial and temporal directions. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! tag_inclusion bwc_tagtree* - Tagtree identifying wether the current ! - ! codeblock contributes to a specific ! - ! quality layer. ! - ! ! - ! tag_msbs bwc_tagtree* - Tagtree identifying the number of mag- ! - ! nitude bit planes used to represent the ! - ! samples of the current codeblock. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 number_of_codeblocks; - uint16 numCbX, numCbY, numCbZ, numCbTS; - bwc_tagtree *tag_inclusion; - bwc_tagtree *tag_msbs; - } bwc_prec_ctrl; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_prec_inf ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds the dimensions for the current precinct. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! X0, Y0, Z0, TS0 unsigned int(32 bit) - Variables defining the spatial starting ! - ! point of a precinct. ! - ! ! - ! X1, Y1, Z1, TS1 unsigned int(32 bit) - Variables defining the spatial end ! - ! point of a precinct. ! - ! ! - ! TS0 unsigned int(16 bit) - Variables defining the temporal start- ! - ! ing point of a precinct. ! - ! ! - ! TS1 unsigned int(16 bit) - Variables defining the temporal end ! - ! point of a precinct. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint32 X0, Y0, Z0; - uint32 X1, Y1, Z1; - uint16 TS0; - uint16 TS1; - } bwc_prec_inf; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_precinct ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the necessary parameters used to define and control a bwc ! - ! precinct. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! info bwc_prec_inf* - Structure holding all the precinct in- ! - ! formation. ! - ! ! - ! control bwc_prec_ctrl* - Structure holding all the precinct con- ! - ! trol parameters. ! - ! ! - ! codeblock bwc_codeblock* - Structure defining a bwc codeblock. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - bwc_prec_inf info; - bwc_prec_ctrl control; - bwc_codeblock *codeblock; - } bwc_precinct; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_subb_ctrl ! - ! ----------- ! - ! ! - ! 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. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! Kmax unsigned int(16 bit) - Defines the dynamic range of the cur- ! - ! rent subband after transformation. ! - ! ! - ! qt_mantissa unsigned int(16 bit) - Defines the mantissa of the subband ! - ! quantisation step size. ! - ! ! - ! qt_exponent unsigned int(8 bit) - Defines the exponent of the subband ! - ! quantisation step size. ! - ! ! - ! highband_flag unsigned char - Defines the type of highband the cur- ! - ! rent subband represents. ! - ! ! - ! qt_effective_step_size bwc_float - Defines the effective quantization step ! - ! size for the current subband. ! - ! ! - ! qt_step_size bwc_float - Defines the quantization step size for ! - ! the current subband. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint16 Kmax; - uint16 qt_mantissa; - uint8 qt_exponent; - uchar highband_flag; - bwc_float qt_effective_step_size; - bwc_float qt_step_size; - } bwc_subb_ctrl; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_subb_inf ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds the dimensions and the energy gain factor for the current subband. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! X0, Y0, Z0, TS0 unsigned int(64 bit) - Variables defining the spatial starting ! - ! point of a subband. ! - ! ! - ! X1, Y1, Z1, TS1 unsigned int(64 bit) - Variables defining the spatial end ! - ! point of a subband. ! - ! ! - ! TS0 unsigned int(16 bit) - Variables defining the temporal start- ! - ! ing point of a subband. ! - ! ! - ! TS1 unsigned int(16 bit) - Variables defining the temporal end ! - ! point of a subband. ! - ! ! - ! dwt_gain bwc_float - Defines the energy gain factor for the ! - ! current subband. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 X0, Y0, Z0; - uint64 X1, Y1, Z1; - uint16 TS0; - uint16 TS1; - bwc_float dwt_gain; - } bwc_subb_inf; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_subband ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the necessary parameters used to define and control a bwc subband. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! info bwc_subb_inf* - Structure holding all the subband in- ! - ! formation. ! - ! ! - ! control bwc_subb_ctrl* - Structure holding all the subband con- ! - ! trol parameters. ! - ! ! - ! precinct bwc_precinct* - Structure defining a bwc precinct. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - bwc_subb_inf info; - bwc_subb_ctrl control; - bwc_precinct *precinct; - } bwc_subband; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_packet ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds the position of the current packet in the compressed bitstream, the ! - ! total number of bytes occupied by the packet as well as the packed codestreams of the pack- ! - ! et body and header. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! size unsigned int(64 bit) - Overall size of the codestream packet. ! - ! e unsigned int(8 bit) - Identifier used as an indicator if no ! - ! codeblock contributions are present in ! - ! current packet. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! body bwc_packed_stream - Structure holding the packed codestream ! - ! of the current packet body. ! - ! ! - ! header bwc_packed_stream - Structure holding the packed codestream ! - ! of the current packet header. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint32 size; - uint32 p; - uint8 e; - uint8 c, l, r; - bwc_packed_stream body; - bwc_packed_stream header; - } bwc_packet; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_res_ctrl ! - ! ----------- ! - ! ! - ! 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. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! number_of_precincts unsigned int(64 bit) - Defines the number of precincts for the ! - ! current resolution level. ! - ! ! - ! numPX, -PY, -PZ, -PTS unsigned int(16 bit) - Variables defining the number of pre- ! - ! cinct for the current resolution level ! - ! in all spatial and temporal directions. ! - ! ! - ! number_of_subbands unsigned int(8 bit) - Defines the number of subbands for the ! - ! current resolution level. ! - ! ! - ! rcbX, rcbY, rcbZ, rcbTS unsigned int(8 bit) - Variables defining the real codeblock ! - ! size for the current resolution level. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 number_of_precincts; - uint16 numPX, numPY, numPZ, numPTS; - uint8 number_of_subbands; - uint8 rcbX, rcbY, rcbZ, rcbTS; - } bwc_res_ctrl; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_res_inf ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds the dimensions for the current resolution level. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! X0, Y0, Z0, TS0 unsigned int(64 bit) - Variables defining the spatial starting ! - ! point of a resolution level. ! - ! ! - ! X1, Y1, Z1, TS1 unsigned int(64 bit) - Variables defining the spatial end ! - ! point of a resolution level. ! - ! ! - ! TS0 unsigned int(16 bit) - Variables defining the temporal start- ! - ! ing point of a resolution level. ! - ! ! - ! TS1 unsigned int(16 bit) - Variables defining the temporal end ! - ! point of a resolution level. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 X0, Y0, Z0; - uint64 X1, Y1, Z1; - uint16 TS0; - uint16 TS1; - } bwc_res_inf; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_resolution ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the necessary parameters used to define and control a bwc resolu- ! - ! tion level. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! info bwc_res_inf* - Structure holding all the resolution ! - ! level information. ! - ! ! - ! control bwc_res_ctrl* - Structure holding all the resolution ! - ! level control parameters. ! - ! ! - ! subband bwc_subband* - Structure defining a bwc subband. ! - ! ! - ! packet bwc_packet** - Structure defining a bwc packet. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 23.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - bwc_res_inf info; - bwc_res_ctrl control; - bwc_subband *subband; - bwc_packet *packet; - } bwc_resolution; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_cblk_access ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure is used to directly access the parameter codeblocks during entropy de-/ ! - ! encoding to facilitate shared memory parallelization. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! codeblock bwc_codeblock* - Structure defining a bwc codeblock. ! - ! ! - ! precinct bwc_precinct* - Structure defining a bwc precinct. ! - ! ! - ! subband bwc_subband* - Structure defining a bwc subband. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 17.10.2018 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - bwc_codeblock *codeblock; - bwc_precinct *precinct; - bwc_subband *subband; - } bwc_cblk_access; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_param_ctrl ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the control parameters for the current tile param. used to in- ! - ! struct the bwc codec to (de)compress a floating point array. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! number_of_codeblocks unsigned int(64 bit) - Defines the number of codeblocks for ! - ! the current tile parameter. ! - ! ! - ! alpha, beta bwc_float - Parameters used to normalized the cur- ! - ! rent tile parameter. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 11.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 number_of_codeblocks; - bwc_float alpha, beta; - } bwc_param_ctrl; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_param_inf ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds the dimensions, name and maximum exponent for the current tile param- ! - ! eter of the uncompressed data set. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! X0, Y0, Z0, TS0 unsigned int(64 bit) - Variables defining the spatial starting ! - ! point of a tile parameter. ! - ! ! - ! X1, Y1, Z1, TS1 unsigned int(64 bit) - Variables defining the spatial end ! - ! point of a tile parameter. ! - ! ! - ! TS0 unsigned int(16 bit) - Variables defining the temporal start- ! - ! ing point of a tile parameter. ! - ! ! - ! TS1 unsigned int(16 bit) - Variables defining the temporal end ! - ! point of a tile parameter. ! - ! ! - ! parameter_max bwc_float - Defines the maximum value of the corre- ! - ! sponding parameter. ! - ! ! - ! parameter_min bwc_float - Defines the minimum value of the corre- ! - ! sponding parameter. ! - ! ! - ! parameter_name char - Defines the name of the corresponding ! - ! parameter. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 11.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 size; - uint64 X0, Y0, Z0; - uint64 X1, Y1, Z1; - uint16 TS0; - uint16 TS1; - uint8 precision; - bwc_float parameter_max; - bwc_float parameter_min; - char *name; - } bwc_param_inf; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_parameter ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the necessary parameters used to define and control the (de)com- ! - ! pression of a bwc tile parameter. Furthermore, this structure stores the uncompressed ! - ! floating point dataset pertaining to the tile parameter. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! info bwc_param_inf* - Structure holding all the tile param- ! - ! eter information of the uncompressed ! - ! data set. ! - ! ! - ! control bwc_param_ctrl* - Structure holding all the tile param- ! - ! control parameters for the bwc codec. ! - ! ! - ! resolution bwc_resolution* - Structure defining a bwc resolution ! - ! level. ! - ! ! - ! access bwc_cblk_access* - Structure used to directly access the ! - ! parameter codeblocks during the entropy ! - ! de-/encoding. ! - ! ! - ! data bwc_sample* - Structure holding the uncompressed data ! - ! set pertaining to the tile parameter. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 11.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - bwc_param_inf info; - bwc_param_ctrl control; - bwc_cblk_access *access; - bwc_resolution *resolution; - bwc_sample *data; - } bwc_parameter; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_tile_ctrl ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the control parameters for the current tile used to instruct the ! - ! bwc codec to (de)compress a floating point array. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! body_size unsigned int(64 bit) - Defines the size of the tile parameter ! - ! body. ! - ! ! - ! Ltp unsigned int(64 bit) - Tile part size. ! - ! ! - ! header_size unsigned int(32 bit) - Defines the approximate size of the ! - ! tile parameter header. ! - ! ! - ! nPackets unsigned int(32 bit) - Number of packets assembled for the ! - ! current tile. ! - ! ! - ! max_Prec unsigned int(32 bit) - Defines the maximum number of precincts ! - ! between all tile parameters. ! - ! ! - ! dflt_param_c, dflt_param_q unsigned int(16 bit) - Variables defining the default param- ! - ! eter index to use when writing COD (c) ! - ! or QCD (q) in main header. ! - ! ! - ! slope_min, slope_max unsigned int(16 bit) - Defines the minimum and maximum value ! - ! for the convex hull slope threshold. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 11.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 body_size; - uint64 Ltp; - uint32 header_size; - uint32 nPackets; - uint32 max_Prec; - uint16 dflt_param_c, dflt_param_q; - uint16 slope_min, slope_max; - } bwc_tile_ctrl; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_tile_inf ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds the dimensions for the current tile of the uncompressed data set. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! size unsigned int(64 bit) - Variable defining the size of a tile ! - ! ! - ! X0, Y0, Z0, TS0 unsigned int(64 bit) - Variables defining the spatial starting ! - ! point of a tile. ! - ! ! - ! X1, Y1, Z1, TS1 unsigned int(64 bit) - Variables defining the spatial end ! - ! point of a tile. ! - ! ! - ! tile_index unsigned int(32 bit) - Index used to uniquely identify a tile. ! - ! ! - ! TS0 unsigned int(16 bit) - Variables defining the temporal start- ! - ! ing point of a tile. ! - ! ! - ! TS1 unsigned int(16 bit) - Variables defining the temporal end ! - ! point of a tile. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 11.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 size; - uint64 X0, Y0, Z0; - uint64 X1, Y1, Z1; - uint32 tile_index; - uint16 TS0; - uint16 TS1; - } bwc_tile_inf; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_tile ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the necessary parameters used to define and control the (de)com- ! - ! pression of a bwc tile. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! - - - ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! info bwc_tile_inf* - Structure holding all the tile infor- ! - ! mation of the uncompressed data set. ! - ! ! - ! control bwc_tile_ctrl* - Structure holding all the tile control ! - ! ! - ! parameter bwc_parameter* - Structure defining a bwc tile parameter.! - ! ! - ! packet_sequence bwc_packet** - Array of pointers used to sequence the ! - ! codestream packets. ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 11.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - bwc_tile_inf info; - bwc_tile_ctrl control; - bwc_parameter *parameter; - bwc_packet **packet_sequence; - } bwc_tile; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_gl_ctrl ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the global control parameters used to instruct the bwc codec to ! - ! (de)compress a floating point array. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! tileSizeX, -Y, -Z unsigned int(64 bit) - Variables defining spatial size of a ! - ! tile. ! - ! ! - ! nTiles unsigned int(32 bit) - Defines the global number of tiles. ! - ! ! - ! qt_exponent unsigned int(32 bit) - Defines the exponent of the global ! - ! quantisation step size. ! - ! ! - ! qt_mantissa unsigned int(32 bit) - Defines the mantissa of the global ! - ! quantisation step size. ! - ! ! - ! CSsgc unsigned int(16 bit) - Variable used to keep track which con- ! - ! trol parameter was set by the user. ! - ! ! - ! tileSizeTS unsigned int(16 bit) - Defines the max temporal size of a ! - ! parameter tile. ! - ! ! - ! tileSizeTS unsigned int(16 bit) - Defines the temporal size of a tile. ! - ! ! - ! cbX, cbY, cbZ, cbTS unsigned int(8 bit) - Variables defining spatial and temporal ! - ! codeblock size in log2 exponent format. ! - ! ! - ! ! - ! decompX, decompY, decompZ unsigned int(8 bit) - Variables defining the number of spa- ! - ! tial wavelet decompositions used during ! - ! compression. ! - ! ! - ! decompTS unsigned int(8 bit) - Defines the number of temporal wavelet ! - ! decompositions used during compression. ! - ! ! - ! guard_bits unsigned int(8 bit) - Defines the number of guard bit used ! - ! during quantization. ! - ! ! - ! number_of_decomp unsigned int(8 bit) - Defines the global number of wavelet ! - ! decomposition levels. ! - ! ! - ! number_of_layers unsigned int(8 bit) - Defines the number of quality layers ! - ! used during (de)compression. ! - ! ! - ! Qm unsigned int(8 bit) - Defines the Q number format range (m). ! - ! ! - ! quantization_step_size double - Defines the global quantization step ! - ! size. ! - ! ! - ! bitrate float* - Defines the average number of bits per ! - ! datapoint after compression. ! - ! ! - ! error_resilience char - Specifies if an error resilient comp. ! - ! approach is employed. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! KernelX, KernelY, KernelZ bwc_dwt_filter - Specifies the wavelet kernels used for ! - ! spatial decomposition. ! - ! ! - ! KernelT bwc_dwt_filter - Specifies the wavelet kernel used for ! - ! temporal decomposition. ! - ! ! - ! header bwc_header* - Defines the main header stream. ! - ! ! - ! progression bwc_prog_ord - Specifies which of the five progression ! - ! orders is employed (CPRL, LRCP, PCRL, ! - ! RLCP, RPCL). ! - ! ! - ! quantization_style bwc_quant_st - Specifies which of the two quantization ! - ! styles is employed (none, derived). ! - ! ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 10.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - uint64 tileSizeX, tileSizeY, tileSizeZ; - uint32 nTiles; - uint32 qt_exponent; - uint32 qt_mantissa; - uint16 CSsgc; - uint16 tileSizeTS; - uint8 cbX, cbY, cbZ, cbTS; - uint8 decompX, decompY, decompZ, decompTS; - uint8 guard_bits; - uint8 nDecomp; - uint8 nLayers, useLayer; - uint8 precSizeX, precSizeY, precSizeZ, precSizeTS; - uint8 Qm; - float *bitrate; - uchar error_resilience; - bwc_dwt_filter KernelX, KernelY, KernelZ; - bwc_dwt_filter KernelTS; - bwc_packed_stream header; - bwc_prog_ord progression; - bwc_quant_st quantization_style; - } bwc_gl_ctrl; - - /*----------------------------------------------------------------------------------------------------------*\ - ! STRUCT NAME: bwc_field ! - ! ----------- ! - ! ! - ! DESCRIPTION: ! - ! ------------ ! - ! This structure holds all the necessary parameters used to define and control the bwc codec ! - ! to (de)compress a floating point array. ! - ! ! - ! PARAMETERS: ! - ! ----------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! codec char - Determines wether current field struc- ! - ! is defined for a compression or decom- ! - ! pression stage. ! - ! ! - ! DEPENDENCIES: ! - ! ------------- ! - ! Variable Type Description ! - ! -------- ---- ----------- ! - ! info bwc_gl_inf* - Structure holding all the global infor- ! - ! mation of the uncompressed data set. ! - ! ! - ! control bwc_gl_ctrl* - Structure holding all the global con- ! - ! trol parameters for the bwc codec. ! - ! ! - ! tile bwc_tile* - Structure holding defining a bwc tile ! - ! ! - ! ! - ! DEVELOPMENT HISTORY: ! - ! -------------------- ! - ! ! - ! Date Author Change Id Release Description Of Change ! - ! ---- ------ --------- ------- --------------------- ! - ! 10.10.2017 Patrick Vogler B87D120 V 0.1.0 struct created ! - ! 05.12.2019 Patrick Vogler B87E7E4 V 0.1.0 Removal of unecessary parameters. ! - ! ! - \*----------------------------------------------------------------------------------------------------------*/ - typedef struct - { - bwc_gl_inf *info; - bwc_gl_ctrl control; - bwc_tile *tile; - - struct meter - { - double bpd; - double cpr; - double css; - - struct time - { - double ttl; - - double cpy; - double nrm; - - double wav; - double ent; - double ass; - } time; - } meter; - } bwc_field; + 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 \ No newline at end of file diff --git a/public_header.py b/public_header.py index 3ee4c8d..7f41500 100644 --- a/public_header.py +++ b/public_header.py @@ -1,54 +1,53 @@ -#*====================================================================================================================*# -#| |# -#| /$$$$$$$ /$$ /$$ /$$ /$$ |# -#| | $$__ $$|__/ | $$ /$ | $$| $$ |# -#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |# -#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |# -#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |# -#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |# -#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |# -#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |# -#| /$$ \ $$ | $$ |# -#| | $$$$$$/ | $$ |# -#| \______/ |__/ |# -#| |# -#| DESCRIPTION: |# -#| ------------ |# -#| This file describes python script used to assemble the public header file for the |# -#| BigWhoop compression library. |# -#| |# -#| DEVELOPMENT HISTORY: |# -#| -------------------- |# -#| |# -#| Date Author Change Id Release Description Of Change |# -#| ---- ------ --------- ------- --------------------- |# -#| 02.02.2020 Patrick Vogler B87D120 V 0.1.0 script 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. |# -#| |# -#\====================================================================================================================/# +#*================================================================================================*# +#| |# +#| /$$$$$$$ /$$ /$$ /$$ /$$ |# +#| | $$__ $$|__/ | $$ /$ | $$| $$ |# +#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |# +#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |# +#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |# +#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |# +#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |# +#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |# +#| /$$ \ $$ | $$ |# +#| | $$$$$$/ | $$ |# +#| \______/ |__/ |# +#| |# +#| 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 @@ -57,6 +56,20 @@ 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, @@ -67,220 +80,254 @@ parser.add_argument('-Single', dest='SinglePrecision', action='store_const', args = parser.parse_args() + +#----------------------------------------------------------# +# Setup the paths to the source and destination. # +#----------------------------------------------------------# current_path = Path().absolute() source = current_path.joinpath('include/library/private') - -if os.path.isdir('include/library/public') == False: - os.mkdir('include/library/public') 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) -with open(source.joinpath('libbwc.h')) as f: - regex = re.compile("(?<=Version )(?:(\d+\.(?:\d+\.)*\d+))") - Version = "" - tab = "" - - for line in f: - if not Version: - Version = regex.findall(line) - if("#include" in line): - tab = line[0:len(line) - len(line.lstrip(' '))] - if tab: - if not Version: - sys.exit("No Version was specified") - else: - break -f.close - -deliminator = tab + "/*" + (116 - len(tab)) * "=" + "*/\n" -ubox = tab + "/" + (118 - len(tab)) * "*" + "\\\n" -lbox = tab + "\\" + (118 - len(tab)) * "*" + "/\n" - +#----------------------------------------------------------# +# 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" - "|| Version " + - Version[-1] + " ||\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 permitted provided ||\n" - "|| 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 materials ||\n" - "|| provided with the distribution. ||\n" - "|| ||\n" - "|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED ||\n" - "|| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A ||\n" - "|| PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ||\n" - "|| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ||\n" - "|| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ||\n" - "|| INTERRUPTION) 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, EVEN IF ||\n" - "|| ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ||\n" - "|| ||\n" - "\*====================================================================================================================*/\n" +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") -lspaces = ceil((116 - 31 - len(tab))/2) -rspaces = floor((116 - 31 - len(tab))/2) +#----------------------------------------------------------# +# Generate the necessary includes for the bwc.h file. # +#----------------------------------------------------------# +title_length = 31 -public_header.write(ubox + tab + "||" + lspaces * " " + "_ _ _ ____ _ _ _ ___ ____" + rspaces * " " + "||\n" + - tab + "||" + lspaces * " " + "| |\ | | | | | | \ |___" + rspaces * " " + "||\n" + - tab + "||" + lspaces * " " + "| | \| |___ |___ |__| |__/ |___" + rspaces * " " + "||\n" + - tab + "||" + (116 - len(tab)) * " " + "||\n" + lbox) +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 \n" + tab + "#include \n\n") -lspaces = ceil((116 - 62 - len(tab))/2) -rspaces = floor((116 - 62 - len(tab))/2) +#----------------------------------------------------------# +# Ingest primitive type definitions from the corresponding # +# header files according to the user specified precision. # +#----------------------------------------------------------# +title_length = 62 -public_header.write(ubox + tab + "||" + lspaces * " " + "___ ____ _ _ _ _ ___ _ _ _ ____ ___ _ _ ___ ____ ____" + rspaces * " " + "||\n" + - tab + "||" + lspaces * " " + "|__] |__/ | |\/| | | | | | |___ | \_/ |__] |___ [__ " + rspaces * " " + "||\n" + - tab + "||" + lspaces * " " + "| | \ | | | | | | \/ |___ | | | |___ ___]" + rspaces * " " + "||\n" + - tab + "||" + (116 - len(tab)) * " " + "||\n" + lbox) +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 = 0 +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 = 1 + print_flag = True public_header.write(line) f.close -lspaces = ceil((116 - 29 - len(tab))/2) -rspaces = floor((116 - 29 - len(tab))/2) +#----------------------------------------------------------# +# Ingest Macros with 'BWC_' prefix from all header files. # +#----------------------------------------------------------# +title_length = 29 -public_header.write(ubox + tab + "||" + lspaces * " " + "_ _ ____ ____ ____ ____ ____" + rspaces * " " + "||\n" + - tab + "||" + lspaces * " " + "|\/| |__| | |__/ | | [__ " + rspaces * " " + "||\n" + - tab + "||" + lspaces * " " + "| | | | |___ | \ |__| ___]" + rspaces * " " + "||\n" + - tab + "||" + (116 - len(tab)) * " " + "||\n" + lbox) +lspaces = ceil((text_width - 2*len(sbox) - title_length - len(tab))/2) +rspaces = floor((text_width - 2*len(sbox) - title_length - len(tab))/2) -with open(source.joinpath('prim_types_double.h')) as f: +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("PREC_BIT" in line): - public_header.write(line) - elif("#define MAXIMUM_NO_PASSES" in line): - public_header.write(line + "\n") - break + 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 -lspaces = ceil((116 - 42 - len(tab))/2) -rspaces = floor((116 - 42 - len(tab))/2) +printFlg = False +buff = "" +brktCnt = 0 -public_header.write(ubox + tab + "||" + lspaces * " " + "____ ____ _ _ ____ ___ ____ _ _ ___ ____" + rspaces * " " + "||\n" + - tab + "||" + lspaces * " " + "| | | |\ | [__ | |__| |\ | | [__ " + rspaces * " " + "||\n" + - tab + "||" + lspaces * " " + "|___ |__| | \| ___] | | | | \| | ___]" + rspaces * " " + "||\n" + - tab + "||" + (116 - len(tab)) * " " + "||\n" + lbox) +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") -print_flag = -1 -with open(source.joinpath('constants.h')) as f: - for line in f: - if(";" in line and print_flag == 1): - print_flag = 0 - public_header.write(line) - if("typedef" in line or print_flag == 1): - if(print_flag == 0): - public_header.write(deliminator) - print_flag = 1 - public_header.write(line) -f.close +#----------------------------------------------------------# +# Ingest enums with 'bwc_' prefix from all header files # +# excluding prim_types_****.h. # +#----------------------------------------------------------# +title_length = 42 -lspaces = ceil((116 - 64 - len(tab))/2) -rspaces = floor((116 - 64 - len(tab))/2) +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 + "||" + lspaces * " " + "___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____" + rspaces * " " + "||\n" + - tab + "||" + lspaces * " " + "| \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ " + rspaces * " " + "||\n" + - tab + "||" + lspaces * " " + "|__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___]" + rspaces * " " + "||\n" + - tab + "||" + (116 - len(tab)) * " " + "||\n" + lbox) +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 -preProc = "" buff = "" brktCnt = 0 -for file in ["mq_types.h", "types.h"]: +for file in header_files: with open(source.joinpath(file)) as f: for line in f: - if("typedef" in line): + if("typedef struct" in line or + "typedef union" in line): + if("bwc_" in line): + printFlg = True while True: - if("#if" in line): - if("_OPENMP" in line): - preProcFlg = True - while True: - line = next(f) - if("endif" in line): - break - preProc = preProc + line[len(tab):len(line)] - - if(preProcFlg and args.OpenMP == True): - buff = buff + preProc - - preProcFlg = False - preProc = "" - else: - buff = buff + line - + 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("bwc_" in line): - if(printFlg == True): - buff = deliminator + buff - else: - printFlg = True + if (printFlg == True): + if(delimFlg == True): + public_header.write(deliminator) public_header.write(buff) - + delimFlg = True buff = "" + f.close -lspaces = ceil((116 - 70 - len(tab))/2) -rspaces = floor((116 - 70 - len(tab))/2) +#----------------------------------------------------------# +# Ingest public functions with 'bwc_' prefix from all # +# header files excluding prim_types_****.h. # +#----------------------------------------------------------# +title_length = 70 -public_header.write("\n" + ubox + tab + "||" + lspaces * " " + "___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____" + rspaces * " " + "||\n" + - tab + "||" + lspaces * " " + "|__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ " + rspaces * " " + "||\n" + - tab + "||" + lspaces * " " + "| |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___]" + rspaces * " " + "||\n" + - tab + "||" + (116 - len(tab)) * " " + "||\n" + lbox) +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 + "extern \"C\" {\n" + @@ -295,27 +342,16 @@ buff = "" for file in files: with open(source.joinpath(file)) as f: for line in f: - - if("#ifdef" in line or "#if defined" in line): - if("_OPENMP" in line and args.OpenMP == True): - ltab = len(tab) - line = next(f) - else: - while ("#endif" not in line): - line = next(f) - if("#endif" in line): - ltab = 0 - + if("#if defined" in line): + line = next(f) if("(" in line): - tmp = line[0:line.index('(')] + tmp = line[0:line.index('(')].strip() tmp = tmp[tmp.rfind(' '):-1] else: tmp = "" - if("bwc_" in tmp and "!" not in line): - if("/*" in buff or "*/" in buff): + if("bwc_" in tmp and "!" not in line and "#if" not in line): + if("/*" in buff or "*/" in buff or "//" in buff): buff = "" - else: - buff = buff[ltab:len(buff)] if(print_flag == True): buff = deliminator + buff diff --git a/src/interfaces/reader/eas3.c b/src/interfaces/reader/eas3.c index dd0cb21..27237d0 100644 --- a/src/interfaces/reader/eas3.c +++ b/src/interfaces/reader/eas3.c @@ -239,7 +239,7 @@ read_eas3_header(bwc_data *const data) ! Save the file pointer and data info structure in tempo- ! ! rary variables to make the code more readable. ! \*--------------------------------------------------------*/ - fp = data->file.fp; + fp = data->fp; info = &data->info; /*--------------------------------------------------------*\ @@ -618,7 +618,7 @@ write_eas3_header(bwc_data *const data) ! Save the file pointer and data info structure in tempo- ! ! rary variables to make the code more readable. ! \*--------------------------------------------------------*/ - fp = data->file.fp; + fp = data->fp; info = &data->info; /*--------------------------------------------------------*\ @@ -866,7 +866,7 @@ read_eas3(char *const filename) ! Open the specified file for reading. If the file doesn't ! ! exist, exit the bwc command-line tool. ! \*--------------------------------------------------------*/ - if((data->file.fp = fopen(filename, "rb")) == NULL) + if((data->fp = fopen(filename, "rb")) == NULL) { // error opening file fprintf(stderr, "o##########################################################o\n"\ @@ -891,10 +891,10 @@ read_eas3(char *const filename) ! file and store the information in the bwc_gl_data struc- ! ! ture. ! \*--------------------------------------------------------*/ - root = ftell(data->file.fp); - fseek(data->file.fp, 0L, SEEK_END); - Lfield = (ftell(data->file.fp) - root) / sizeof(double); - fseek(data->file.fp, root, SEEK_SET); + root = ftell(data->fp); + fseek(data->fp, 0L, SEEK_END); + Lfield = (ftell(data->fp) - root) / sizeof(double); + fseek(data->fp, root, SEEK_SET); /*--------------------------------------------------------*\ ! Check if the file_size coincide with the specified dimen-! @@ -935,7 +935,7 @@ read_eas3(char *const filename) /*--------------------------------------------------------*\ ! Read the flow field data from the specified eas3 file. ! \*--------------------------------------------------------*/ - if(fread(data->field.f, sizeof(float), Lfield, data->file.fp) != Lfield) + if(fread(data->field.f, sizeof(float), Lfield, data->fp) != Lfield) { // invalid read fprintf(stderr, RDERROR); @@ -971,7 +971,7 @@ read_eas3(char *const filename) /*--------------------------------------------------------*\ ! Read the flow field data from the specified eas3 file. ! \*--------------------------------------------------------*/ - if(fread(data->field.d, sizeof(double), Lfield, data->file.fp) != Lfield) + if(fread(data->field.d, sizeof(double), Lfield, data->fp) != Lfield) { // invalid read fprintf(stderr, RDERROR); @@ -993,8 +993,8 @@ read_eas3(char *const filename) ! Close the file pointer and return the bwc_data structure ! ! to the function caller. ! \*--------------------------------------------------------*/ - fclose(data->file.fp); - data->file.fp = NULL; + fclose(data->fp); + data->fp = NULL; return data; } @@ -1051,7 +1051,7 @@ write_eas3(bwc_data *const data, char *const filename) ! exist, discard its content. If the file cannot be creat- ! ! ed, exit the bwc command-line tool. ! \*--------------------------------------------------------*/ - if((data->file.fp = fopen(filename, "wb")) == NULL) + if((data->fp = fopen(filename, "wb")) == NULL) { // error opening file fprintf(stderr, "o##########################################################o\n"\ @@ -1090,7 +1090,7 @@ write_eas3(bwc_data *const data, char *const filename) /*--------------------------------------------------------*\ ! Write the flow field data to the specified eas3 file. ! \*--------------------------------------------------------*/ - if(fwrite(data->field.f, sizeof(float), Lfield, data->file.fp) != Lfield) + if(fwrite(data->field.f, sizeof(float), Lfield, data->fp) != Lfield) { // invalid read fprintf(stderr, WRTERROR); @@ -1110,7 +1110,7 @@ write_eas3(bwc_data *const data, char *const filename) /*--------------------------------------------------------*\ ! Write the flow field data to the specified eas3 file. ! \*--------------------------------------------------------*/ - if(fwrite(data->field.d, sizeof(double), Lfield, data->file.fp) != Lfield) + if(fwrite(data->field.d, sizeof(double), Lfield, data->fp) != Lfield) { // invalid read fprintf(stderr, WRTERROR); @@ -1121,7 +1121,7 @@ write_eas3(bwc_data *const data, char *const filename) /*--------------------------------------------------------*\ ! Close the file pointer and return to the function caller.! \*--------------------------------------------------------*/ - fclose(data->file.fp); - data->file.fp = NULL; + fclose(data->fp); + data->fp = NULL; return 0; } \ No newline at end of file diff --git a/src/library/CMakeLists.txt b/src/library/CMakeLists.txt index 67a0083..d760a60 100755 --- a/src/library/CMakeLists.txt +++ b/src/library/CMakeLists.txt @@ -1,57 +1,49 @@ -#*====================================================================================================================*# -#| |# -#| /$$$$$$$ /$$ /$$ /$$ /$$ |# -#| | $$__ $$|__/ | $$ /$ | $$| $$ |# -#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |# -#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |# -#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |# -#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |# -#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |# -#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |# -#| /$$ \ $$ | $$ |# -#| | $$$$$$/ | $$ |# -#| \______/ |__/ |# -#| DESCRIPTION: |# -#| ------------ |# -#| Defines the cmake script for the libbwc library. |# -#| |# -#| |# -#| DEVELOPMENT HISTORY: |# -#| -------------------- |# -#| |# -#| Date Author Change Id Release Description Of Change |# -#| ---- ------ --------- ------- --------------------- |# -#| 30.08.2018 Patrick Vogler B87D120 V 0.1.0 cmake file created |# -#| 15.10.2021 Patrick Vogler B880CA2 V 0.1.1 Added install rules |# -#| |# -#| |# -#| ------------------------------------------------------------------------------------------------------ |# -#| |# -#| 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. |# -#| |# -#*====================================================================================================================*# -#*--------------------------------------------------------*# +#*================================================================================================*# +#| |# +#| /$$$$$$$ /$$ /$$ /$$ /$$ |# +#| | $$__ $$|__/ | $$ /$ | $$| $$ |# +#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |# +#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |# +#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |# +#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |# +#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |# +#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |# +#| /$$ \ $$ | $$ |# +#| | $$$$$$/ | $$ |# +#| \______/ |__/ |# +#| |# +#| 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") @@ -67,10 +59,10 @@ 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() @@ -86,46 +78,46 @@ add_library(bwclib ${BWC_LINK} bitstream.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 $ $) -#*--------------------------------------------------------*# +#----------------------------------------------------------# # 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) \ No newline at end of file diff --git a/src/library/bitstream.c b/src/library/bitstream.c index c38201d..962daa4 100755 --- a/src/library/bitstream.c +++ b/src/library/bitstream.c @@ -1,82 +1,49 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| FILE NAME: bitstream.c || -|| || -|| || -|| 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 code- || -|| stream and can emit/extract information on a per bit, symbol (64-bit) or string basis. || -|| || -|| || -|| FILE REFERENCES: || -|| ---------------- || -|| || -|| Name I/O Description || -|| ---- --- ----------- || -|| none - - || -|| || -|| || -|| PRIVATE FUNCTIONS: || -|| ------------------ || -|| - || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| - bytes_used || -|| - bwc_init_stream || -|| - bwc_emit_chunck || -|| - bwc_emit_symbol || -|| - bwc_emit_bit || -|| - bwc_get_chunck || -|| - bwc_get_symbol || -|| - bwc_get_bit || -|| - bwc_terminate_stream || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 28.05.2018 Patrick Vogler B87D120 V 0.1.0 source 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. || -|| || -\*==================================================================================================================================*/ - +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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. || +|| || +\*================================================================================================*/ /************************************************************************************************************\ || _ _ _ ____ _ _ _ ___ ____ || || | |\ | | | | | | \ |___ || @@ -127,7 +94,7 @@ ! ! \*----------------------------------------------------------------------------------------------------------*/ uint64 -bytes_used(bwc_stream *const stream) +bytes_used(bwc_stream const *const stream) { if(stream->T == 0xFF) { diff --git a/src/library/codestream.c b/src/library/codestream.c index 814f502..55d6353 100755 --- a/src/library/codestream.c +++ b/src/library/codestream.c @@ -1,68 +1,49 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| FILE NAME: bitstream.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 || -|| ---- ------ --------- ------- --------------------- || -|| 28.05.2018 Patrick Vogler B87D120 V 0.1.0 source 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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. || +|| || +\*================================================================================================*/ /************************************************************************************************************\ || _ _ _ ____ _ _ _ ___ ____ || || | |\ | | | | | | \ |___ || @@ -911,7 +892,7 @@ assemble_main_header(bwc_field *const field) bwc_emit_symbol(stream, control->progression, 1); bwc_emit_symbol(stream, control->KernelX << 6 | control->KernelY << 4 | - control->KernelZ << 2 | control->KernelTS, 1); + control->KernelZ << 2 | control->KernelTS, 1); bwc_emit_symbol(stream, control->decompX, 1); bwc_emit_symbol(stream, control->decompY, 1); @@ -1145,7 +1126,7 @@ bwc_parse_main_header(bwc_data *const data,bwc_stream *const stream) if(CSsgc & (0x01 << 1)) { - bwc_set_quantization_style(field, (bwc_quant_st)buff_long); + bwc_set_quant_style(field, (bwc_quant_st)buff_long); } buff_long = bwc_get_symbol(stream, 1); diff --git a/src/library/dwt.c b/src/library/dwt.c index 837241a..5b94bc6 100755 --- a/src/library/dwt.c +++ b/src/library/dwt.c @@ -1,82 +1,49 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| FILE NAME: dwt.c || -|| || -|| || -|| DESCRIPTION: || -|| ------------ || -|| DESCRIPTION NEEDED. || -|| || -|| FILE REFERENCES: || -|| ---------------- || -|| || -|| Name I/O Description || -|| ---- --- ----------- || -|| none - - || -|| || -|| || -|| PRIVATE FUNCTIONS: || -|| ------------------ || -|| - get_filter_taps || -|| - fill_forward_buffer || -|| - fill_inverse_buffer || -|| - whole_point_symmetric_extend || -|| - forward_9x7_CDF_wavelet_transform || -|| - inverse_9x7_CDF_wavelet_transform || -|| - forward_5x3_LeGall_wavelet_transform || -|| - inverse_5x3_LeGall_wavelet_transform || -|| - forward_Haar_wavelet_transform || -|| - inverse_Haar_wavelet_transform || -|| - buffer_flush_forward || -|| - buffer_flush_inverse || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| - initialize_gain_lut || -|| - get_dwt_energy_gain || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 19.03.2018 Patrick Vogler B87D120 V 0.1.0 source 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. || -|| || -\*==================================================================================================================================*/ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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. || +|| || +\*================================================================================================*/ /************************************************************************************************************\ || _ _ _ ____ _ _ _ ___ ____ || @@ -101,7 +68,7 @@ || |___ _/\_ | |___ | \ | \| | | |___ \/ | | | \ | | | |__] |___ |___ ___] || || || \************************************************************************************************************/ -double DWT_ENERGY_GAIN_LUT[3][2 * MAX_DECOMPOSITION_LEVELS + 2]; +double DWT_ENERGY_GAIN_LUT[3][2 * MAX_DECOMP_LEVELS + 2]; /************************************************************************************************************\ || ___ ____ _ _ _ ____ ___ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || @@ -1250,9 +1217,9 @@ initialize_gain_lut() ! (5/3) and Haar wavelet transform by setting the energy ! ! gain factor for level zero to one. ! \*--------------------------------------------------------*/ - DWT_ENERGY_GAIN_LUT[bwc_dwt_9_7][0] = DWT_ENERGY_GAIN_LUT[bwc_dwt_9_7][MAX_DECOMPOSITION_LEVELS + 1] = 1.0f; - DWT_ENERGY_GAIN_LUT[bwc_dwt_5_3][0] = DWT_ENERGY_GAIN_LUT[bwc_dwt_5_3][MAX_DECOMPOSITION_LEVELS + 1] = 1.0f; - DWT_ENERGY_GAIN_LUT[bwc_dwt_haar][0] = DWT_ENERGY_GAIN_LUT[bwc_dwt_haar][MAX_DECOMPOSITION_LEVELS + 1] = 1.0f; + DWT_ENERGY_GAIN_LUT[bwc_dwt_9_7][0] = DWT_ENERGY_GAIN_LUT[bwc_dwt_9_7][MAX_DECOMP_LEVELS + 1] = 1.0f; + DWT_ENERGY_GAIN_LUT[bwc_dwt_5_3][0] = DWT_ENERGY_GAIN_LUT[bwc_dwt_5_3][MAX_DECOMP_LEVELS + 1] = 1.0f; + DWT_ENERGY_GAIN_LUT[bwc_dwt_haar][0] = DWT_ENERGY_GAIN_LUT[bwc_dwt_haar][MAX_DECOMP_LEVELS + 1] = 1.0f; /*--------------------------------------------------------*\ ! Loop through the symmetric wavelet filter banks and as- ! @@ -1307,7 +1274,7 @@ initialize_gain_lut() /*--------------------------------------------------------*\ ! Loop through the remaining decomposition levels. ! \*--------------------------------------------------------*/ - for(k = 1; k < MAX_DECOMPOSITION_LEVELS; ++k) + for(k = 1; k < MAX_DECOMP_LEVELS; ++k) { /*--------------------------------------------------------*\ ! Assemble the low- or high-pass synthesis sequence for ! @@ -1346,7 +1313,7 @@ initialize_gain_lut() ! high-pass energy gain factor and set the length of work ! ! buffer 1 to the corresponding high-pass filter length. ! \*--------------------------------------------------------*/ - LUT += MAX_DECOMPOSITION_LEVELS + 1; + LUT += MAX_DECOMP_LEVELS + 1; Length_Gb = Length[1]; } /*--------------------------------------------------------*\ @@ -1399,7 +1366,7 @@ initialize_gain_lut() /*--------------------------------------------------------*\ ! Loop through the remaining decomposition levels. ! \*--------------------------------------------------------*/ - for(k = 1; k < MAX_DECOMPOSITION_LEVELS; ++k) + for(k = 1; k < MAX_DECOMP_LEVELS; ++k) { /*--------------------------------------------------------*\ ! Assemble the low- or high-pass synthesis sequence for ! @@ -1435,7 +1402,7 @@ initialize_gain_lut() ! Calculate the energy gain factor for decomposition level ! ! i by evaluating the square norm of work buffer 1. ! \*--------------------------------------------------------*/ - LUT += MAX_DECOMPOSITION_LEVELS + 1; + LUT += MAX_DECOMP_LEVELS + 1; Length_Gb = Length[1]; } /*--------------------------------------------------------*\ @@ -1457,9 +1424,9 @@ initialize_gain_lut() ! ! ! DESCRIPTION: ! ! ------------ ! -! This function evaluates the energy gain factor according to the the specified decomposition ! -! level. For decomposition levels larger than MAX_DECOMPOSITION_LEVELS the filter gain for ! -! the extra levels is approximated by multiplying the energy gain factor by 2. ! +! This function evaluates the energy gain factor according to the the specified decom- ! +! position level. For decomposition levels larger than MAX_DECOMP_LEVELS the filter gain ! +! for the extra levels is approximated by multiplying the energy gain factor by 2. ! ! ! ! PARAMETERS: ! ! ----------- ! @@ -1535,73 +1502,73 @@ get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level) /*--------------------------------------------------------*\ ! Multiply the energy gain factor with the filter gain of ! ! the wavelet kernel applied along the X-axis. For decom- ! - ! position levels larger than MAX_DECOMPOSITION_LEVELS the ! - ! energy gain for the extra levels is approximated by mul- ! - ! tiplying it by 2. ! + ! position levels larger than MAX_DECOMP_LEVELS the energy ! + ! gain for the extra levels is approximated by multiplying ! + ! it by 2. ! \*--------------------------------------------------------*/ if(level_X != 0) { - while(level_X > MAX_DECOMPOSITION_LEVELS) + while(level_X > MAX_DECOMP_LEVELS) { Gb *= 2.0f; level_X--; } - Gb *= DWT_ENERGY_GAIN_LUT[control->KernelX][level_X + ((highband_flag & DIM_X) * (MAX_DECOMPOSITION_LEVELS + 1))]; + Gb *= DWT_ENERGY_GAIN_LUT[control->KernelX][level_X + ((highband_flag & DIM_X) * (MAX_DECOMP_LEVELS + 1))]; } /*--------------------------------------------------------*\ ! Multiply the energy gain factor with the filter gain of ! ! the wavelet kernel applied along the Y-axis. For decom- ! - ! position levels larger than MAX_DECOMPOSITION_LEVELS the ! - ! energy gain for the extra levels is approximated by mul- ! - ! tiplying it by 2. ! + ! position levels larger than MAX_DECOMP_LEVELS the energy ! + ! gain for the extra levels is approximated by multiplying ! + ! it by 2. ! \*--------------------------------------------------------*/ if(level_Y != 0) { - while(level_Y > MAX_DECOMPOSITION_LEVELS) + while(level_Y > MAX_DECOMP_LEVELS) { Gb *= 2.0f; level_Y--; } - Gb *= DWT_ENERGY_GAIN_LUT[control->KernelY][level_Y + (((highband_flag & DIM_Y) >> 1) * (MAX_DECOMPOSITION_LEVELS + 1))]; + Gb *= DWT_ENERGY_GAIN_LUT[control->KernelY][level_Y + (((highband_flag & DIM_Y) >> 1) * (MAX_DECOMP_LEVELS + 1))]; } /*--------------------------------------------------------*\ ! Multiply the energy gain factor with the filter gain of ! ! the wavelet kernel applied along the Z-axis. For decom- ! - ! position levels larger than MAX_DECOMPOSITION_LEVELS the ! - ! energy gain for the extra levels is approximated by mul- ! - ! tiplying it by 2. ! + ! position levels larger than MAX_DECOMP_LEVELS the energy ! + ! gain for the extra levels is approximated by multiplying ! + ! it by 2. ! \*--------------------------------------------------------*/ if(level_Z != 0) { - while(level_Z > MAX_DECOMPOSITION_LEVELS) + while(level_Z > MAX_DECOMP_LEVELS) { Gb *= 2.0f; level_Z--; } - Gb *= DWT_ENERGY_GAIN_LUT[control->KernelZ][level_Z + (((highband_flag & DIM_Z) >> 2) * (MAX_DECOMPOSITION_LEVELS + 1))]; + Gb *= DWT_ENERGY_GAIN_LUT[control->KernelZ][level_Z + (((highband_flag & DIM_Z) >> 2) * (MAX_DECOMP_LEVELS + 1))]; } /*--------------------------------------------------------*\ ! Multiply the energy gain factor with the filter gain of ! ! the wavelet kernel applied along the TS-axis. For decom- ! - ! position levels larger than MAX_DECOMPOSITION_LEVELS the ! - ! energy gain for the extra levels is approximated by mul- ! - ! tiplying it by 2. ! + ! position levels larger than MAX_DECOMP_LEVELS the energy ! + ! gain for the extra levels is approximated by multiplying ! + ! it by 2. ! \*--------------------------------------------------------*/ if(level_TS != 0) { - while(level_TS > MAX_DECOMPOSITION_LEVELS) + while(level_TS > MAX_DECOMP_LEVELS) { Gb *= 2.0f; level_TS--; } - Gb *= DWT_ENERGY_GAIN_LUT[control->KernelTS][level_TS + (((highband_flag & DIM_TS) >> 3) * (MAX_DECOMPOSITION_LEVELS + 1))]; + Gb *= DWT_ENERGY_GAIN_LUT[control->KernelTS][level_TS + (((highband_flag & DIM_TS) >> 3) * (MAX_DECOMP_LEVELS + 1))]; } return (bwc_float)Gb; } @@ -1645,7 +1612,7 @@ get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level) ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -forward_discrete_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter) +forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -2182,7 +2149,7 @@ forward_discrete_wavelet_transform(bwc_field *const field, bwc_parameter *const ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -inverse_discrete_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter) +inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! diff --git a/src/library/libbwc.c b/src/library/libbwc.c index 54d2626..2f6aa65 100755 --- a/src/library/libbwc.c +++ b/src/library/libbwc.c @@ -1,87 +1,47 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| || -|| Version 0.1.1 || -|| || -|| DESCRIPTION: || -|| ------------ || -|| Big Whoop is a compression codec for the lossy compression of IEEE 754 floating point arrays defined on curvelinear || -|| compute grids. || -|| || -|| FILE REFERENCES: || -|| ---------------- || -|| || -|| Name I/O Description || -|| ---- --- ----------- || -|| none - - || -|| || -|| || -|| PRIVATE FUNCTIONS: || -|| ------------------ || -|| - initialize_precinct || -|| - subband_gain || -|| - initialize_subband || -|| - create_field || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| - bwc_initialize_field || -|| - bwc_add_param || -|| - bwc_set_error_resilience || -|| - bwc_set_quantization_style || -|| - bwc_set_progression || -|| - bwc_set_kernels || -|| - bwc_set_decomp || -|| - bwc_set_precincts || -|| - bwc_set_codeblocks || -|| - bwc_set_qm || -|| - bwc_set_tiles || -|| - bwc_create_compression || -|| - bwc_kill_compression || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 10.10.2017 Patrick Vogler B87D120 V 0.1.0 source 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. || -|| || -\*==================================================================================================================================*/ - +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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. || +|| || +\*================================================================================================*/ /************************************************************************************************************\ || _ _ _ ____ _ _ _ ___ ____ || || | |\ | | | | | | \ |___ || @@ -1889,15 +1849,13 @@ bwc_free_data(bwc_data* data) { release_packed_stream(data->codestream.com); } - if(data->file.fp) + if(data->fp) { - fclose(data->file.fp); + fclose(data->fp); } free(data->codestream.data); free(data->codestream.aux); free(data->codestream.com); - free(data->file.d_root); - free(data->file.f_root); free(data->field.d); free(data->field.f); free(data); @@ -2719,7 +2677,7 @@ bwc_set_error_resilience(bwc_field *const field) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_quantization_style(bwc_field *const field, bwc_quant_st quantization_style) ! +! FUNCTION NAME: void bwc_set_quant_style(bwc_field *const field, bwc_quant_st quantization_style) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -2752,7 +2710,7 @@ bwc_set_error_resilience(bwc_field *const field) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bwc_set_quantization_style(bwc_field *const field, bwc_quant_st quantization_style) +bwc_set_quant_style(bwc_field *const field, bwc_quant_st quantization_style) { /*-----------------------*\ ! DEFINE STRUCTS: ! @@ -2785,7 +2743,7 @@ bwc_set_quantization_style(bwc_field *const field, bwc_quant_st quantization_sty } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_quantization_step_size(bwc_field *const field, double delta) ! +! FUNCTION NAME: void bwc_set_quant_step_size(bwc_field *const field, double delta) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -2818,7 +2776,7 @@ bwc_set_quantization_style(bwc_field *const field, bwc_quant_st quantization_sty ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bwc_set_quantization_step_size(bwc_field *const field, double delta) +bwc_set_quant_step_size(bwc_field *const field, double delta) { /*-----------------------*\ ! DEFINE STRUCTS: ! @@ -4062,7 +4020,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) #else start = (double)clock(); #endif - if(forward_discrete_wavelet_transform(field, parameter)) + if(forward_wavelet_transform(field, parameter)) { free(working_buffer); return 1; @@ -4419,7 +4377,7 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) #else start = (double)clock(); #endif - if(inverse_discrete_wavelet_transform(field, parameter)) + if(inverse_wavelet_transform(field, parameter)) { free(working_buffer); return 1; diff --git a/src/library/mq.c b/src/library/mq.c index 41e1e1c..ff77754 100755 --- a/src/library/mq.c +++ b/src/library/mq.c @@ -1,69 +1,47 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| FILE NAME: mq.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 || -|| ---- ------ --------- ------- --------------------- || -|| 13.02.2019 Patrick Vogler B87D120 V 0.1.0 source 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. || -|| || -\*==================================================================================================================================*/ - +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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. || +|| || +\*================================================================================================*/ /************************************************************************************************************\ || _ _ _ ____ _ _ _ ___ ____ || || | |\ | | | | | | \ |___ || @@ -77,6 +55,7 @@ #include "macros.h" #include "mq.h" +#include "tier1.h" #include "types.h" /************************************************************************************************************\ @@ -346,7 +325,7 @@ static const bwc_context_state context_state[94] = ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -initialize_bit_encoder(bwc_coder *const coder, const uint8 number_of_contexts) +initialize_mq_encoder(bwc_coder *const coder, const uint8 number_of_contexts) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -427,7 +406,7 @@ initialize_bit_encoder(bwc_coder *const coder, const uint8 number_of_contexts) ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -bit_encoder_next_run(bwc_bit_coder *const bitcoder) +mq_next_run(bwc_bit_coder *const bitcoder) { /*-----------------------*\ ! DEFINE STRUCTS: ! @@ -496,7 +475,7 @@ bit_encoder_next_run(bwc_bit_coder *const bitcoder) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bit_encode(bwc_bit_coder *const bitcoder, const uint8 s, const uint8 k) +mq_bit_encode(bwc_bit_coder *const bitcoder, const uint8 s, const uint8 k) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -605,7 +584,7 @@ bit_encode(bwc_bit_coder *const bitcoder, const uint8 s, const uint8 k) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bit_encoder_truncation_length_min(bwc_coder_state *const state) +mq_truncation_length_min(bwc_coder_state *const state) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -724,7 +703,7 @@ bit_encoder_truncation_length_min(bwc_coder_state *const state) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bit_encoder_termination(bwc_bit_coder *const bitcoder) +mq_termination(bwc_bit_coder *const bitcoder) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -774,7 +753,7 @@ bit_encoder_termination(bwc_bit_coder *const bitcoder) while(state) { - bit_encoder_truncation_length_min(state); + mq_truncation_length_min(state); state = state->next; } } @@ -808,7 +787,7 @@ bit_encoder_termination(bwc_bit_coder *const bitcoder) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -free_bit_encoder(bwc_coder *const coder) +free_mq_encoder(bwc_coder *const coder) { /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -864,7 +843,7 @@ free_bit_encoder(bwc_coder *const coder) ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -initialize_bit_decoder(bwc_coder *const coder, const uint8 number_of_contexts, const int64 Lmax) +initialize_mq_decoder(bwc_coder *const coder, const uint8 number_of_contexts, const int64 Lmax) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -968,7 +947,7 @@ initialize_bit_decoder(bwc_coder *const coder, const uint8 number_of_contexts, c ! ! \*----------------------------------------------------------------------------------------------------------*/ uint8 -bit_decode(bwc_bit_coder *const bitcoder, const uint8 k) +mq_bit_decode(bwc_bit_coder *const bitcoder, const uint8 k) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -1078,7 +1057,7 @@ bit_decode(bwc_bit_coder *const bitcoder, const uint8 k) ! ! \*----------------------------------------------------------------------------------------------------------*/ uint64 -bit_coder_get_no_bytes(bwc_bit_coder *const bitcoder) +mq_get_no_bytes(bwc_bit_coder *const bitcoder) { /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -1117,7 +1096,7 @@ bit_coder_get_no_bytes(bwc_bit_coder *const bitcoder) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bit_coder_reset_ptr(bwc_bit_coder *const bitcoder, uchar *const memory) +mq_reset_ptr(bwc_bit_coder *const bitcoder, uchar *const memory) { /*-----------------------*\ ! DEFINE STRUCTS: ! @@ -1169,7 +1148,7 @@ bit_coder_reset_ptr(bwc_bit_coder *const bitcoder, uchar *const memory) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bit_coder_get_pass_lengths(bwc_bit_coder *const bitcoder, bwc_encoded_cblk *const encoded_cblk) +mq_get_pass_lengths(bwc_bit_coder *const bitcoder, bwc_encoded_cblk *const encoded_cblk) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! diff --git a/src/library/tagtree.c b/src/library/tagtree.c index 204d686..37743ad 100755 --- a/src/library/tagtree.c +++ b/src/library/tagtree.c @@ -1,76 +1,55 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| FILE NAME: tagtree.c || -|| || -|| || -|| DESCRIPTION: || -|| ------------ || -|| DESCRIPTION NEEDED. || -|| || -|| FILE REFERENCES: || -|| ---------------- || -|| || -|| Name I/O Description || -|| ---- --- ----------- || -|| none - - || -|| || -|| || -|| PRIVATE FUNCTIONS: || -|| ------------------ || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| - kill_tagtree || -|| - reset_tagtree || -|| - tagtree_get_value || -|| - tagtree_set_value || -|| - initialize_tagtree || -|| - encode_tagtree || -|| - decode_tagtree || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| 18.05.2018 Patrick Vogler B87D120 V 0.1.0 source 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. || -|| || -\*==================================================================================================================================*/ - +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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. || +|| || +\*================================================================================================*/ /************************************************************************************************************\ || _ _ _ ____ _ _ _ ___ ____ || || | |\ | | | | | | \ |___ || diff --git a/src/library/tier1.c b/src/library/tier1.c index 30c7618..fce996e 100755 --- a/src/library/tier1.c +++ b/src/library/tier1.c @@ -1,69 +1,49 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| FILE NAME: tier1.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 0.1.0 source 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. || -|| || -\*==================================================================================================================================*/ - +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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. || +|| || +\*================================================================================================*/ /************************************************************************************************************\ || _ _ _ ____ _ _ _ ___ ____ || || | |\ | | | | | | \ |___ || @@ -111,10 +91,10 @@ \*----------------------------------------------------------------------------------------------------------*/ #define encode_segmark(bitcoder) \ { \ - bit_encode(bitcoder, 1, CONTEXT_UNI); \ - bit_encode(bitcoder, 0, CONTEXT_UNI); \ - bit_encode(bitcoder, 1, CONTEXT_UNI); \ - bit_encode(bitcoder, 0, CONTEXT_UNI); \ + mq_bit_encode(bitcoder, 1, CONTEXT_UNI); \ + mq_bit_encode(bitcoder, 0, CONTEXT_UNI); \ + mq_bit_encode(bitcoder, 1, CONTEXT_UNI); \ + mq_bit_encode(bitcoder, 0, CONTEXT_UNI); \ } /************************************************************************************************************\ @@ -1014,8 +994,8 @@ significance_propagation_enc_pass(bwc_coder *const coder, const int8 b) stripe = coder->data; rest = 4 - (coder->height & 0x03); stripe_mask = ~((0x0F >> ((coder->height & 0x03))) | 0xF0); - dist_shift = (b < DISTORTION_MANTISSA) ? 0 : (b - DISTORTION_MANTISSA); - dist_corr = (b < DISTORTION_MANTISSA) ? (DISTORTION_MANTISSA - b) : 0; + dist_shift = (b < DISTORTION_SIG) ? 0 : (b - DISTORTION_SIG); + dist_corr = (b < DISTORTION_SIG) ? (DISTORTION_SIG - b) : 0; for(i = 0, k = 0; i < coder->no_slice; ++i) { @@ -1053,7 +1033,7 @@ significance_propagation_enc_pass(bwc_coder *const coder, const int8 b) if(k_sig) { - bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), coder->sig2context[k_sig]); + mq_bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), coder->sig2context[k_sig]); if(bit & bit_mask) { @@ -1075,8 +1055,8 @@ significance_propagation_enc_pass(bwc_coder *const coder, const int8 b) xi_h = SIG2XI[xi_h]; xi_v = SIG2XI[xi_v]; - bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]), - XI2CONT[(xi_h << 2) | xi_v][0]); + mq_bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]), + XI2CONT[(xi_h << 2) | xi_v][0]); mse += DISTORTION_TS_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x1F]; stripe[k].sigma |= bit_mask; @@ -1126,7 +1106,7 @@ significance_propagation_enc_pass(bwc_coder *const coder, const int8 b) if(k_sig && (stripe[k].sigma^bit_mask)) { - bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), coder->sig2context[k_sig]); + mq_bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), coder->sig2context[k_sig]); if(bit & bit_mask) { @@ -1144,8 +1124,8 @@ significance_propagation_enc_pass(bwc_coder *const coder, const int8 b) xi_h = SIG2XI[xi_h]; xi_v = SIG2XI[xi_v]; - bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]), - XI2CONT[(xi_h << 2) | xi_v][0]); + mq_bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]), + XI2CONT[(xi_h << 2) | xi_v][0]); mse += DISTORTION_TS_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x1F]; stripe[k].sigma |= bit_mask; @@ -1227,8 +1207,8 @@ magnitude_refinement_enc_pass(bwc_coder *const coder, const int8 b) stripe = coder->data; rest = 4 - (coder->height & 0x03); stripe_mask = ~((0x0F >> ((coder->height & 0x03))) | 0xF0); - dist_shift = (b < DISTORTION_MANTISSA) ? 0 : (b - DISTORTION_MANTISSA); - dist_corr = (b < DISTORTION_MANTISSA) ? (DISTORTION_MANTISSA - b) : 0; + dist_shift = (b < DISTORTION_MAG) ? 0 : (b - DISTORTION_MAG); + dist_corr = (b < DISTORTION_MAG) ? (DISTORTION_MAG - b) : 0; for(i = 0, k = 0; i < coder->no_slice; ++i) { @@ -1271,7 +1251,7 @@ magnitude_refinement_enc_pass(bwc_coder *const coder, const int8 b) } } - bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), k_mag); + mq_bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), k_mag); mse += DISTORTION_TM_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x3F]; stripe[k].delta |= bit_mask; @@ -1313,7 +1293,7 @@ magnitude_refinement_enc_pass(bwc_coder *const coder, const int8 b) } } - bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), k_mag); + mq_bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), k_mag); mse += DISTORTION_TM_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x3F]; stripe[k].delta |= bit_mask; @@ -1383,8 +1363,8 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b) mse = 0; stripe = coder->data; rest = 4 - (coder->height & 0x03); - dist_shift = (b < DISTORTION_MANTISSA) ? 0 : (b - DISTORTION_MANTISSA); - dist_corr = (b < DISTORTION_MANTISSA) ? (DISTORTION_MANTISSA - b) : 0; + dist_shift = (b < DISTORTION_SIG) ? 0 : (b - DISTORTION_SIG); + dist_corr = (b < DISTORTION_SIG) ? (DISTORTION_SIG - b) : 0; for(i = 0, k = 0; i < coder->no_slice; ++i) { @@ -1407,14 +1387,14 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b) r |= r >> 2; r = DISTORTION_LZ_LUT[r]; - bit_encode(coder->bitcoder, (uchar)1, CONTEXT_RUN); - bit_encode(coder->bitcoder, (uchar)r >> 1, CONTEXT_UNI); - bit_encode(coder->bitcoder, (uchar)r&0x01, CONTEXT_UNI); + mq_bit_encode(coder->bitcoder, (uchar)1, CONTEXT_RUN); + mq_bit_encode(coder->bitcoder, (uchar)r >> 1, CONTEXT_UNI); + mq_bit_encode(coder->bitcoder, (uchar)r&0x01, CONTEXT_UNI); } else { r = 4; - bit_encode(coder->bitcoder, (uchar)0, CONTEXT_RUN); + mq_bit_encode(coder->bitcoder, (uchar)0, CONTEXT_RUN); } } @@ -1448,7 +1428,7 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b) (0x08 & stripe[k].stripe_d->stripe_r->sigma)) >> 3; } - bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), coder->sig2context[(15 * k_h + 5 * k_v + k_d) >> l]); + mq_bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), coder->sig2context[(15 * k_h + 5 * k_v + k_d) >> l]); } if(bit & bit_mask) { @@ -1470,8 +1450,8 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b) xi_h = SIG2XI[xi_h]; xi_v = SIG2XI[xi_v]; - bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]), - XI2CONT[(xi_h << 2) | xi_v][0]); + mq_bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]), + XI2CONT[(xi_h << 2) | xi_v][0]); mse += DISTORTION_TS_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x1F]; stripe[k].sigma |= bit_mask; @@ -1503,7 +1483,7 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b) (0x01 & stripe[k].stripe_u->stripe_r->sigma)) << 3; } - bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), coder->sig2context[(15 * k_h + 5 * k_v + k_d) >> l]); + mq_bit_encode(coder->bitcoder, (uchar)((bit >> l) & 0x01), coder->sig2context[(15 * k_h + 5 * k_v + k_d) >> l]); if(bit & bit_mask) { @@ -1521,8 +1501,8 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b) xi_h = SIG2XI[xi_h]; xi_v = SIG2XI[xi_v]; - bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]), - XI2CONT[(xi_h << 2) | xi_v][0]); + mq_bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]), + XI2CONT[(xi_h << 2) | xi_v][0]); mse += DISTORTION_TS_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x1F]; stripe[k].sigma |= bit_mask; @@ -1630,7 +1610,7 @@ significance_propagation_dec_pass(bwc_coder *const coder, const int8 b) if(k_sig) { - bit = bit_decode(coder->bitcoder, coder->sig2context[k_sig]); + bit = mq_bit_decode(coder->bitcoder, coder->sig2context[k_sig]); if(bit) { @@ -1654,7 +1634,7 @@ significance_propagation_dec_pass(bwc_coder *const coder, const int8 b) xi_h = SIG2XI[xi_h]; xi_v = SIG2XI[xi_v]; - stripe[k].xi |= ((XI2CONT[(xi_h << 2) | xi_v][1] ^ bit_decode(coder->bitcoder, XI2CONT[(xi_h << 2) | xi_v][0])) << l); + stripe[k].xi |= ((XI2CONT[(xi_h << 2) | xi_v][1] ^ mq_bit_decode(coder->bitcoder, XI2CONT[(xi_h << 2) | xi_v][0])) << l); stripe[k].sigma |= bit_mask; } @@ -1703,7 +1683,7 @@ significance_propagation_dec_pass(bwc_coder *const coder, const int8 b) if(k_sig && (stripe[k].sigma^bit_mask)) { - bit = bit_decode(coder->bitcoder, coder->sig2context[k_sig]); + bit = mq_bit_decode(coder->bitcoder, coder->sig2context[k_sig]); if(bit) { @@ -1723,7 +1703,7 @@ significance_propagation_dec_pass(bwc_coder *const coder, const int8 b) xi_h = SIG2XI[xi_h]; xi_v = SIG2XI[xi_v]; - stripe[k].xi |= ((XI2CONT[(xi_h << 2) | xi_v][1] ^ bit_decode(coder->bitcoder, XI2CONT[(xi_h << 2) | xi_v][0])) << l); + stripe[k].xi |= ((XI2CONT[(xi_h << 2) | xi_v][1] ^ mq_bit_decode(coder->bitcoder, XI2CONT[(xi_h << 2) | xi_v][0])) << l); stripe[k].sigma |= bit_mask; } @@ -1843,7 +1823,7 @@ magnitude_refinement_dec_pass(bwc_coder *const coder, const int8 b) } } - stripe[k].bit[b] |= (bit_decode(coder->bitcoder, k_mag) << l); + stripe[k].bit[b] |= (mq_bit_decode(coder->bitcoder, k_mag) << l); stripe[k].delta |= bit_mask; } @@ -1884,7 +1864,7 @@ magnitude_refinement_dec_pass(bwc_coder *const coder, const int8 b) } } - stripe[k].bit[b] |= (bit_decode(coder->bitcoder, k_mag) << l); + stripe[k].bit[b] |= (mq_bit_decode(coder->bitcoder, k_mag) << l); stripe[k].delta |= bit_mask; } @@ -1965,10 +1945,10 @@ cleanup_dec_pass(bwc_coder *const coder, const int8 b) !(0x01 & stripe[k].stripe_u->stripe_r->sigma) && !stripe[k].stripe_r->sigma && !stripe[k].sigma) { - if(bit_decode(coder->bitcoder, CONTEXT_RUN)) + if(mq_bit_decode(coder->bitcoder, CONTEXT_RUN)) { - r = bit_decode(coder->bitcoder, CONTEXT_UNI); - r = (r << 1) + bit_decode(coder->bitcoder, CONTEXT_UNI); + r = mq_bit_decode(coder->bitcoder, CONTEXT_UNI); + r = (r << 1) + mq_bit_decode(coder->bitcoder, CONTEXT_UNI); bit |= (0x08 >> r); } else @@ -2007,7 +1987,7 @@ cleanup_dec_pass(bwc_coder *const coder, const int8 b) (0x08 & stripe[k].stripe_d->stripe_r->sigma)) >> 3; } - bit |= (bit_decode(coder->bitcoder, coder->sig2context[(15 * k_h + 5 * k_v + k_d) >> l]) << l); + bit |= (mq_bit_decode(coder->bitcoder, coder->sig2context[(15 * k_h + 5 * k_v + k_d) >> l]) << l); } if(bit & bit_mask) { @@ -2029,7 +2009,7 @@ cleanup_dec_pass(bwc_coder *const coder, const int8 b) xi_h = SIG2XI[xi_h]; xi_v = SIG2XI[xi_v]; - stripe[k].xi |= ((XI2CONT[(xi_h << 2) | xi_v][1] ^ bit_decode(coder->bitcoder, XI2CONT[(xi_h << 2) | xi_v][0])) << l); + stripe[k].xi |= ((XI2CONT[(xi_h << 2) | xi_v][1] ^ mq_bit_decode(coder->bitcoder, XI2CONT[(xi_h << 2) | xi_v][0])) << l); stripe[k].sigma |= bit_mask; } @@ -2063,7 +2043,7 @@ cleanup_dec_pass(bwc_coder *const coder, const int8 b) (0x01 & stripe[k].stripe_u->stripe_r->sigma)) << 3; } - bit |= (bit_decode(coder->bitcoder, coder->sig2context[(15 * k_h + 5 * k_v + k_d) >> l]) << l); + bit |= (mq_bit_decode(coder->bitcoder, coder->sig2context[(15 * k_h + 5 * k_v + k_d) >> l]) << l); if(bit & bit_mask) { @@ -2081,7 +2061,7 @@ cleanup_dec_pass(bwc_coder *const coder, const int8 b) xi_h = SIG2XI[xi_h]; xi_v = SIG2XI[xi_v]; - stripe[k].xi |= ((XI2CONT[(xi_h << 2) | xi_v][1] ^ bit_decode(coder->bitcoder, XI2CONT[(xi_h << 2) | xi_v][0])) << l); + stripe[k].xi |= ((XI2CONT[(xi_h << 2) | xi_v][1] ^ mq_bit_decode(coder->bitcoder, XI2CONT[(xi_h << 2) | xi_v][0])) << l); stripe[k].sigma |= bit_mask; } @@ -2488,7 +2468,7 @@ encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, ! Initialize the entropy encoder used for the current com- ! ! pression run. ! \*--------------------------------------------------------*/ - if(initialize_bit_encoder(&coder, CONTEXT_TOTAL)) + if(initialize_mq_encoder(&coder, CONTEXT_TOTAL)) { return; } @@ -2516,7 +2496,7 @@ encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, /*--------------------------------------------------------*\ ! Reset the bit encoder for the next coding pass. ! \*--------------------------------------------------------*/ - if(bit_encoder_next_run(coder.bitcoder)) + if(mq_next_run(coder.bitcoder)) { return; } @@ -2528,7 +2508,7 @@ encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, ! Evaluate the number of bytes generated so far by the bit ! ! encoder and increase the buffer size if necessary. ! \*--------------------------------------------------------*/ - if(coder.buff_size <= (bit_coder_get_no_bytes(coder.bitcoder) + coder.buff_incr)) + if(coder.buff_size <= (mq_get_no_bytes(coder.bitcoder) + coder.buff_incr)) { coder.buff_size += ((uint64)k >> 1) * coder.buff_incr; coder.compressed = realloc(coder.compressed, coder.buff_size * sizeof(uchar)); @@ -2539,7 +2519,7 @@ encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, return; } - bit_coder_reset_ptr(coder.bitcoder, coder.compressed); + mq_reset_ptr(coder.bitcoder, coder.compressed); } /*--------------------------------------------------------*\ ! If the error resilience flag is set, encode a segmark ! @@ -2559,7 +2539,7 @@ encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, ! Evalute the number of bytes generated by the bit encoder ! ! and increase the buffer size if necessary. ! \*--------------------------------------------------------*/ - if(coder.buff_size <= (bit_coder_get_no_bytes(coder.bitcoder) + 16)) + if(coder.buff_size <= (mq_get_no_bytes(coder.bitcoder) + 16)) { coder.buff_size += 16; coder.compressed = realloc(coder.compressed, coder.buff_size * sizeof(uchar)); @@ -2570,13 +2550,13 @@ encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, return; } - bit_coder_reset_ptr(coder.bitcoder, coder.compressed); + mq_reset_ptr(coder.bitcoder, coder.compressed); } /*--------------------------------------------------------*\ ! Flush the remaining bits in the byte buffer to the coder ! ! output and calculate the minimum truncation lengths. ! \*--------------------------------------------------------*/ - bit_encoder_termination(coder.bitcoder); + mq_termination(coder.bitcoder); /*--------------------------------------------------------*\ ! Save the number of significant bitplanes, insignificant ! @@ -2598,12 +2578,12 @@ encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, ! Save the lengths of the coding passes in the encoded ! ! codeblock structure. ! \*--------------------------------------------------------*/ - bit_coder_get_pass_lengths(coder.bitcoder, encoded_cblk); + mq_get_pass_lengths(coder.bitcoder, encoded_cblk); /*--------------------------------------------------------*\ ! Free the entropy encoder structure. ! \*--------------------------------------------------------*/ - free_bit_encoder(&coder); + free_mq_encoder(&coder); /*--------------------------------------------------------*\ ! Calculate the slope values of the distortion/rate convex ! @@ -2771,7 +2751,7 @@ decode_codeblock(bwc_field *const field, bwc_cblk_access *const access, ! Initialize the entropy encoder used for the current com- ! ! pression run. ! \*--------------------------------------------------------*/ - if(initialize_bit_decoder(&coder, CONTEXT_TOTAL, encoded_cblk->L[encoded_cblk->Z - 1])) + if(initialize_mq_decoder(&coder, CONTEXT_TOTAL, encoded_cblk->L[encoded_cblk->Z - 1])) { return; } @@ -2787,10 +2767,10 @@ decode_codeblock(bwc_field *const field, bwc_cblk_access *const access, decoding_pass[i](&coder, k); } - if((coder.erres) && (((bit_decode(coder.bitcoder, CONTEXT_UNI) << 3) | - (bit_decode(coder.bitcoder, CONTEXT_UNI) << 2) | - (bit_decode(coder.bitcoder, CONTEXT_UNI) << 1) | - bit_decode(coder.bitcoder, CONTEXT_UNI)) != 0x0A)) + if((coder.erres) && (((mq_bit_decode(coder.bitcoder, CONTEXT_UNI) << 3) | + (mq_bit_decode(coder.bitcoder, CONTEXT_UNI) << 2) | + (mq_bit_decode(coder.bitcoder, CONTEXT_UNI) << 1) | + mq_bit_decode(coder.bitcoder, CONTEXT_UNI)) != 0x0A)) { goto break_out; } @@ -2808,7 +2788,7 @@ decode_codeblock(bwc_field *const field, bwc_cblk_access *const access, /*--------------------------------------------------------*\ ! Free the entropy encoder structure. ! \*--------------------------------------------------------*/ - free_bit_encoder(&coder); + free_mq_encoder(&coder); } /************************************************************************************************************\ diff --git a/src/library/tier2.c b/src/library/tier2.c index 048dad1..560f8c8 100755 --- a/src/library/tier2.c +++ b/src/library/tier2.c @@ -1,76 +1,49 @@ -/*==================================================================================================================================*\ -|| || -|| /$$$$$$$ /$$ /$$ /$$ /$$ || -|| | $$__ $$|__/ | $$ /$ | $$| $$ || -|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || -|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || -|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || -|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || -|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || -|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || -|| /$$ \ $$ | $$ || -|| | $$$$$$/ | $$ || -|| \______/ |__/ || -|| || -|| FILE NAME: t2.c || -|| || -|| || -|| DESCRIPTION: || -|| ------------ || -|| DESCRIPTION NEEDED. || -|| || -|| FILE REFERENCES: || -|| ---------------- || -|| || -|| Name I/O Description || -|| ---- --- ----------- || -|| none - - || -|| || -|| || -|| PRIVATE FUNCTIONS: || -|| ------------------ || -|| - encode_length || -|| - decode_length || -|| - create_packet || -|| - create_packets || -|| - create_quality_layer || -|| - create_quality_layers || -|| || -|| PUBLIC FUNCTIONS: || -|| ----------------- || -|| - t2_encode || -|| || -|| DEVELOPMENT HISTORY: || -|| -------------------- || -|| || -|| Date Author Change Id Release Description Of Change || -|| ---- ------ --------- ------- --------------------- || -|| - Patrick Vogler B87D120 V 0.1.0 source 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. || -|| || -\*==================================================================================================================================*/ - +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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. || +|| || +\*================================================================================================*/ /************************************************************************************************************\ || _ _ _ ____ _ _ _ ___ ____ || || | |\ | | | | | | \ |___ || diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index b05db0f..adf9154 100755 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -1,65 +1,57 @@ -#*====================================================================================================================*# -#| |# -#| /$$$$$$$ /$$ /$$ /$$ /$$ |# -#| | $$__ $$|__/ | $$ /$ | $$| $$ |# -#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |# -#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |# -#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |# -#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |# -#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |# -#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |# -#| /$$ \ $$ | $$ |# -#| | $$$$$$/ | $$ |# -#| \______/ |__/ |# -#| DESCRIPTION: |# -#| ------------ |# -#| Defines the cmake script for the BigWhoop command line tool. |# -#| |# -#| |# -#| DEVELOPMENT HISTORY: |# -#| -------------------- |# -#| |# -#| Date Author Change Id Release Description Of Change |# -#| ---- ------ --------- ------- --------------------- |# -#| 30.08.2018 Patrick Vogler B87D120 V 0.1.0 cmake file created |# -#| 15.10.2021 Patrick Vogler B880CA2 V 0.1.1 Added install rules |# -#| |# -#| |# -#| ------------------------------------------------------------------------------------------------------ |# -#| |# -#| 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. |# -#| |# -#*====================================================================================================================*# -#*--------------------------------------------------------*# +#*================================================================================================*# +#| |# +#| /$$$$$$$ /$$ /$$ /$$ /$$ |# +#| | $$__ $$|__/ | $$ /$ | $$| $$ |# +#| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ |# +#| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ |# +#| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ |# +#| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ |# +#| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ |# +#| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ |# +#| /$$ \ $$ | $$ |# +#| | $$$$$$/ | $$ |# +#| \______/ |__/ |# +#| |# +#| 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}) @@ -70,24 +62,24 @@ 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) \ No newline at end of file diff --git a/src/tools/bwccmdl.c b/src/tools/bwccmdl.c index b758c99..73f659b 100644 --- a/src/tools/bwccmdl.c +++ b/src/tools/bwccmdl.c @@ -2845,9 +2845,9 @@ main(int argc, if((temp != NULL) && (temp->count == 1)) { if(strcmp(temp->lit_opt[0], "NONE")) - bwc_set_quantization_style(field, bwc_qt_none); + bwc_set_quant_style(field, bwc_qt_none); else - bwc_set_quantization_style(field, bwc_qt_derived); + bwc_set_quant_style(field, bwc_qt_derived); } /*--------------------------------------------------------*\ @@ -2856,7 +2856,7 @@ main(int argc, temp = retrieve_arg(args, "quantisation_step_size"); if((temp != NULL) && (temp->count == 1)) { - bwc_set_quantization_step_size(field, temp->num_opt[0]); + bwc_set_quant_step_size(field, temp->num_opt[0]); } /*--------------------------------------------------------*\