Ported Header files to new coding standard.

This commit is contained in:
Patrick Vogler 2024-02-22 11:27:40 +01:00
parent d2b88391b9
commit 8850d525f2
Signed by: Patrick Vogler
GPG key ID: 5536B08CE82E8509
30 changed files with 3442 additions and 5574 deletions

View file

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

View file

@ -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_MAJOR @BWC_VERSION_MAJOR@)
set(PACKAGE_VERSION_MINOR @BWC_VERSION_MINOR@) set(PACKAGE_VERSION_MINOR @BWC_VERSION_MINOR@)
set(PACKAGE_VERSION_PATCH @BWC_VERSION_PATCH@) set(PACKAGE_VERSION_PATCH @BWC_VERSION_PATCH@)

View file

@ -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("${CMAKE_CURRENT_LIST_DIR}/bwc-config-version.cmake")
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,213 +12,83 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| File: bwc_bitstream.h ||
|| ----- ||
|| ||
|| DESCRIPTION: || || 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. ||
|| || || ||
|| 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. ||
|| || || ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 #ifndef BITSTREAM_H
#define BITSTREAM_H #define BITSTREAM_H
/************************************************************************************************\
/************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ || || _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ || || | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ || || | | \| |___ |___ |__| |__/ |___ ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
#include "types.h" #include "types.h"
/************************************************************************************************************\ /************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ uint64 bytes_used (bwc_stream const *const stream);
! FUNCTION NAME: uint32 bytes_used(bwc_stream *const stream) ! //==========|==========================|======================|======|======|=====================
! -------------- ! bwc_stream* bwc_init_stream (uchar *const memory,
! ! uint32 const size,
! DESCRIPTION: ! char const instr);
! ------------ ! //==========|==========================|======================|======|======|=====================
! This function is used to evaluate the number of bytes that have already been ! void bwc_emit_chunck (bwc_stream *const stream,
! written to the allocated bitstream memory block. ! uchar const *const chunck,
! ! uint64 const size);
\*----------------------------------------------------------------------------------------------------------*/ //==========|==========================|======================|======|======|=====================
uint64 void bwc_emit_symbol (bwc_stream *const stream,
bytes_used(bwc_stream *const stream); uint64 const symbol,
uint8 const size);
/*----------------------------------------------------------------------------------------------------------*\ //==========|==========================|======================|======|======|=====================
! FUNCTION NAME: bwc_stream* bwc_init_stream(uchar* memory, uint32 size, char instr) ! void bwc_emit_bit (bwc_stream *const stream,
! -------------- ! uint64 const bit);
! ! //==========|==========================|======================|======|======|=====================
! DESCRIPTION: ! void flush_stream (bwc_stream *const stream);
! ------------ ! //==========|==========================|======================|======|======|=====================
! This function is used to initialize a bwc bitstream. For encoding, a null pointer ! uchar* bwc_get_chunck (bwc_stream *const stream,
! is passed as a memory handle and the function will allocate a memory block with the ! uint64 const length);
! 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, ! uint64 bwc_get_symbol (bwc_stream *const stream,
! stream size Lmax and size increment are initialized with their appropriate values. ! uint8 const length);
! ! //==========|==========================|======================|======|======|=====================
\*----------------------------------------------------------------------------------------------------------*/ uchar bwc_get_bit (bwc_stream *const stream);
bwc_stream* //==========|==========================|======================|======|======|=====================
bwc_init_stream(uchar* memory, uint32 size, char instr); uchar bwc_terminate_stream (bwc_stream *stream,
bwc_packed_stream *const packed_stream);
/*----------------------------------------------------------------------------------------------------------*\ //==========|==========================|======================|======|======|=====================
! FUNCTION NAME: void *test(void) ! void release_packed_stream (bwc_packed_stream *const stream);
! -------------- !
! !
! 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);
#endif #endif

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,92 +12,64 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| File: codestream.h ||
|| ----- ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| DESCRIPTION NEEDED. ||
|| || || ||
|| STRUCTS: || || 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 ||
|| PUBLIC FUNCTIONS: || || conforming bwc datasets. ||
|| ----------------- ||
|| ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 #ifndef CODESTREAM_H
#define CODESTREAM_H #define CODESTREAM_H
/************************************************************************************************************\ /************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ || || _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ || || | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ || || | | \| |___ |___ |__| |__/ |___ ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
#include "types.h" #include "types.h"
/************************************************************************************************************\ /************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ || || _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ || || |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] || || | | | | |___ | \ |__| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! These macros define stream manipulation operations to rewind, foward and get access !
! to the current memory position of a bwc_stream. !
! ! ! !
! Macros: ! ! These macros define stream manipulation operations to rewind, forward, inquire !
! ------- ! ! the availability and get access to the current memory position of a bwc_stream. !
! 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) \ #define rewind_stream(stream, delta) \
{ \ { \
stream->L -= delta; \ stream->L -= delta; \
@ -110,82 +82,26 @@
#define get_access(stream) (uchar*)stream->memory + stream->L #define get_access(stream) (uchar*)stream->memory + stream->L
/************************************************************************************************************\ /************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ uchar assemble_main_header (bwc_field *const field);
! FUNCTION NAME: void *test(void) ! //==========|==========================|======================|======|======|=====================
! -------------- ! bwc_field* bwc_parse_main_header (bwc_data *const data,
! ! bwc_stream *const stream);
! DESCRIPTION: ! //==========|==========================|======================|======|======|=====================
! ------------ ! uchar codestream_write_aux (bwc_packed_stream *const header,
! DESCRIPTION NEEDED ! bwc_packed_stream *const aux);
! ! //==========|==========================|======================|======|======|=====================
\*----------------------------------------------------------------------------------------------------------*/ uchar codestream_write_com (bwc_packed_stream *const header,
uchar bwc_packed_stream *const com);
assemble_main_header(bwc_field *const field); //==========|==========================|======================|======|======|=====================
bwc_packed_stream* assemble_codestream (bwc_field *const field);
/*----------------------------------------------------------------------------------------------------------*\ //==========|==========================|======================|======|======|=====================
! FUNCTION NAME: void *test(void) ! bwc_field* parse_codestream (bwc_data *const data,
! -------------- ! uint8 const layer);
! !
! DESCRIPTION: !
! ------------ !
! DESCRIPTION NEEDED !
! !
\*----------------------------------------------------------------------------------------------------------*/
bwc_field*
bwc_parse_main_header(bwc_data *const data,bwc_stream *const stream);
/*----------------------------------------------------------------------------------------------------------*\
! 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);
#endif #endif

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,79 +12,50 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| File: constants.h ||
|| ----- ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| DESCRIPTION NEEDED. ||
|| || || ||
|| STRUCTS: || || This file defines simple constants that are used to make the code more readable. ||
|| -------- ||
|| ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 #ifndef CONSTANTS_H
#define CONSTANTS_H #define CONSTANTS_H
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! These constants are used to identify the spatial and temporal dimensions. ! ! These constants are used to identify the spatial and temporal dimensions. !
! ! ! !
! Constants: ! \*----------------------------------------------------------------------------------------------*/
! ----------- ! #define DIM_X 1 // 1st Spatial Dimension.
! Constant Description ! #define DIM_Y 2 // 2nd Spatial Dimension.
! -------- ----------- ! #define DIM_Z 4 // 3rd Spatial Dimension.
! DIM_X 1st Spatial Dimension ! #define DIM_TS 8 // Temporal Dimension.
! DIM_Y 2nd Spatial Dimension ! #define DIM_ALL 15 // All Dimensions.
! 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: ! ! DESCRIPTION: !

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,317 +12,158 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| File: dwt.h ||
|| ----- ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| DESCRIPTION NEEDED. ||
|| || || ||
|| STRUCTS: || || 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. ||
|| PUBLIC FUNCTIONS: || || Marcellin. ||
|| ----------------- ||
|| ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 #ifndef DWT_H
#define DWT_H #define DWT_H
/************************************************************************************************************\ /************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ || || _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ || || | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ || || | | \| |___ |___ |__| |__/ |___ ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
#include "types.h" #include "types.h"
/************************************************************************************************************\ /************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ || || _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ || || |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] || || | | | | |___ | \ |__| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! This macro defines the maximum decomposition level up to which the wavelet filer energy gain ! ! Maximum number of wavelet layers for which the energy gain is calculated. !
! is calculated. Beyond the maximum decomposition level the energy gain will only be !
! approximated. !
! ! ! !
! Macros: ! \*----------------------------------------------------------------------------------------------*/
! ------- ! #define MAX_DECOMP_LEVELS 4
! 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: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! These macros define the irrational coefficients for the high and low pass synthesis filters ! ! These macros define the irrational coefficients for the high and low pass !
! associated with the (9-7) Cohen-Daubechies-Feauveau-Wavelet as well as the coefficients for ! ! synthesis filters associated with the (9-7) Cohen-Daubechies-Feauveau-Wavelet !
! its coressponding lifting scheme. ! ! as well as the coefficients for its coressponding lifting scheme. !
! ! ! !
! Macros: ! \*----------------------------------------------------------------------------------------------*/
! ------- ! #define DWT_9X7_H0 1.115087052457000f // Low pass synthesis filter ...
! Macro Description ! #define DWT_9X7_H1 0.591271763114250f // ... coefficients
! ----- ----------- !
! 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_H2 -0.057543526228500f
#define DWT_9X7_H3 -0.091271763114250f #define DWT_9X7_H3 -0.091271763114250f
#define DWT_9X7_G0 1.205898036472721f #define DWT_9X7_G0 1.205898036472721f // High pass synthesis filter ...
#define DWT_9X7_G1 -0.533728236885750f #define DWT_9X7_G1 -0.533728236885750f // ... coefficients
#define DWT_9X7_G2 -0.156446533057980f #define DWT_9X7_G2 -0.156446533057980f
#define DWT_9X7_G3 0.033728236885750f #define DWT_9X7_G3 0.033728236885750f
#define DWT_9X7_G4 0.053497514821620f #define DWT_9X7_G4 0.053497514821620f
#define ALPHA -1.586134342059924f #define ALPHA -1.586134342059924f // Lifting coefficients.
#define BETA -0.052980118572961f #define BETA -0.052980118572961f
#define GAMMA 0.882911075530934f #define GAMMA 0.882911075530934f
#define DELTA 0.360523644801462f #define DELTA 0.360523644801462f
#define KAPPA_H 1.230174104914001f #define KAPPA_H 1.230174104914001f
#define KAPPA_L 0.812893066115961f #define KAPPA_L 0.812893066115961f
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! These macros define the irrational coefficients for the high and low pass synthesis filters ! ! These macros define the irrational coefficients for the high and low pass !
! associated with the (5-3) LeGall-Wavelet. ! ! synthesis filters associated with the (5-3) LeGall-Wavelet. !
! ! ! !
! Macros: ! \*----------------------------------------------------------------------------------------------*/
! ------- ! #define DWT_5X3_H0 1.0f // Low pass synthesis filter ...
! Macro Description ! #define DWT_5X3_H1 0.5f // ... coefficients
! ----- ----------- !
! 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
#define DWT_5X3_G0 0.75f #define DWT_5X3_G0 0.75f // High pass synthesis filter
#define DWT_5X3_G1 -0.25f #define DWT_5X3_G1 -0.25f // ... coefficients
#define DWT_5X3_G2 -0.125f #define DWT_5X3_G2 -0.125f
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! These macros define the irrational coefficients for the high and low pass synthesis filters ! ! These macros define the irrational coefficients for the high and low pass !
! associated with the Haar-Wavelet. ! ! synthesis filters associated with the Haar-Wavelet. !
! ! ! !
! Macros: ! \*----------------------------------------------------------------------------------------------*/
! ------- ! #define DWT_HAAR_H0 1 // Low pass synthesis filter ...
! Macro Description ! #define DWT_HAAR_H1 1 // ... coefficients
! ----- ----------- !
! 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
#define DWT_HAAR_G0 0.5 #define DWT_HAAR_G0 0.5 // High pass synthesis filter ...
#define DWT_HAAR_G1 -0.5 #define DWT_HAAR_G1 -0.5 // ... coefficients
/************************************************************************************************************\ /************************************************************************************************\
|| ____ _ _ ___ ____ ____ _ _ ____ _ _ _ ____ ____ _ ____ ___ _ ____ ____ || || ____ _ _ ___ ____ ____ _ _ ____ _ _ _ ____ ____ _ ____ ___ _ ____ ____ ||
|| |___ \/ | |___ |__/ |\ | |__| | | | |__| |__/ | |__| |__] | |___ [__ || || |___ \/ | |___ |__/ |\ | |__| | | | |__| |__/ | |__| |__] | |___ [__ ||
|| |___ _/\_ | |___ | \ | \| | | |___ \/ | | | \ | | | |__] |___ |___ ___] || || |___ _/\_ | |___ | \ | \| | | |___ \/ | | | \ | | | |__] |___ |___ ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! This array defines a lookup table used to store the energy gain factors for the one dimen- ! ! This array defines a lookup table used to store the energy gain factors for the !
! sional, dyadic tree structured CDF-(9/7), LeGall-(5/3) and Haar wavelet transform. Each LUT ! ! 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 ! ! contains energy gain factors for the 6 low-pass and 6 high-pass decomposition !
! zero. ! ! including level zero. !
! ! ! !
! VARIABLES: ! \*----------------------------------------------------------------------------------------------*/
! ----------- ! extern double DWT_ENERGY_GAIN_LUT[3][2 * MAX_DECOMP_LEVELS + 2];
! 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];
/************************************************************************************************************\
/************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ uchar initialize_gain_lut ();
! FUNCTION NAME: uchar initialize_gain_lut() ! //==========|==========================|======================|======|=======|====================
! -------------- ! bwc_float get_dwt_energy_gain (bwc_field *const field,
! ! uchar const highband_flag,
! DESCRIPTION: ! uint16 const level);
! ------------ ! //==========|==========================|======================|======|=======|====================
! This function calculates the energy gain factor Gb for the one dimensional, dyadic tree ! uchar forward_wavelet_transform (bwc_field *const field,
! structured CDF-(9/7), LeGall-(5/3) and Haar wavelet transform with 5 levels. The energy ! bwc_parameter *const parameter);
! gain factors are calculated according to equation (4.39) from JPEG2000 by David S. Taubman ! //==========|==========================|======================|======|=======|====================
! and Michael W. Marcellin (p. 193): ! uchar inverse_wavelet_transform (bwc_field *const field,
! ! bwc_parameter *const parameter);
! 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);
#endif #endif

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,70 +12,44 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| Version 0.1.1 ||
|| ||
|| File: bwc.h ||
|| ----- ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| This header defines DESCRIPTION NEEDED. ||
|| || || ||
|| STRUCTS: || || Big Whoop is a compression codec for the lossy compression of IEEE 754 floating ||
|| -------- || || point arrays defined on curvelinear compute grids. ||
|| ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 #ifndef LIBBWC_H
#define BWC_H #define LIBBWC_H
/************************************************************************************************************\ /************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ || || _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ || || | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ || || | | \| |___ |___ |__| |__/ |___ ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
#include "bitstream.h" #include "bitstream.h"
#include "codestream.h" #include "codestream.h"
#include "constants.h" #include "constants.h"
@ -83,298 +57,91 @@
#include "mq_types.h" #include "mq_types.h"
#include "types.h" #include "types.h"
/************************************************************************************************************\ /************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ //==========|==========================|======================|======|=======|====================
! FUNCTION NAME: bwc_field *bwc_initialize_data(...) ! bwc_data* bwc_initialize_data (double *const field,
! -------------- ! uint64 const nX,
! ! uint64 const nY,
! DESCRIPTION: ! uint64 const nZ,
! ------------ ! uint16 const nTS,
! This function initializes the bwc_data structure with all necessary parameters. ! uint8 const nPar,
! ! char *const file_extension);
\*----------------------------------------------------------------------------------------------------------*/ //==========|==========================|======================|======|=======|====================
bwc_data* void bwc_add_param (bwc_data *const data,
bwc_initialize_data(double* field, uint64 const nX, uint64 const nY, uint64 const nZ, uint16 const nTS, uint8 const nPar, char *file_extension); char *const name,
uint8 const precision);
/*----------------------------------------------------------------------------------------------------------*\ //==========|==========================|======================|======|=======|====================
! FUNCTION NAME: void bwc_add_param(bwc_data* data, char *name, uint16 sample, uchar dim, uint8 precision) ! void bwc_get_data (bwc_data *const data,
! -------------- ! uchar *const buffer,
! ! uint64 const size);
! ! //==========|==========================|======================|======|=======|====================
! DESCRIPTION: ! void bwc_free_data (bwc_data *const data);
! ------------ ! //==========|==========================|======================|======|=======|====================
! This function initializes and adds new parameters to the parameter linked list. The linked ! uchar create_field (bwc_field *const field);
! list stores the parameter name, its precision, sampling factor and the dimension for which ! //==========|==========================|======================|======|=======|====================
! the sampling is active. ! void bwc_kill_compression (bwc_field *const field);
! ! //==========|==========================|======================|======|=======|====================
\*----------------------------------------------------------------------------------------------------------*/ bwc_field* bwc_initialize_field (bwc_data *const data);
void //==========|==========================|======================|======|=======|====================
bwc_add_param(bwc_data* data, char *name, uint8 precision); void bwc_set_error_resilience (bwc_field *const field);
//==========|==========================|======================|======|=======|====================
/*----------------------------------------------------------------------------------------------------------*\ void bwc_set_quant_style (bwc_field *const field,
! FUNCTION NAME: bwc_field *bwc_initialize_data(...) ! bwc_quant_st const quantization_style);
! -------------- ! //==========|==========================|======================|======|=======|====================
! ! void bwc_set_quant_step_size (bwc_field *const field,
! DESCRIPTION: ! double const delta);
! ------------ ! //==========|==========================|======================|======|=======|====================
! This function is used to copy the numerical dataset stored in the bwc_data ! void bwc_set_progression (bwc_field *const field,
! structure to a user supplied memory block. A size argument is necessary ! bwc_prog_ord const progression);
! to verify that the memory block has the correct size. ! //==========|==========================|======================|======|=======|====================
! ! void bwc_set_kernels (bwc_field *const field,
\*----------------------------------------------------------------------------------------------------------*/ bwc_dwt_filter const KernelX,
void bwc_dwt_filter const KernelY,
bwc_get_data(bwc_data* data, uchar* buffer, uint64 size); bwc_dwt_filter const KernelZ,
bwc_dwt_filter const KernelTS);
/*----------------------------------------------------------------------------------------------------------*\ //==========|==========================|======================|======|=======|====================
! FUNCTION NAME: void bwc_free_data(bwc_data* file) ! void bwc_set_decomp (bwc_field *const field,
! -------------- ! uint8 const decompX,
! ! uint8 const decompY,
! DESCRIPTION: ! uint8 const decompZ,
! ------------ ! uint8 const decompTS);
! 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. ! void bwc_set_precincts (bwc_field *const field,
! The deallocation will be carried out down to the structure levels that have been allocated. ! uint8 const pX,
! ! uint8 const pY,
\*----------------------------------------------------------------------------------------------------------*/ uint8 const pZ,
void uint8 const pTS);
bwc_free_data(bwc_data* data); //==========|==========================|======================|======|=======|====================
void bwc_set_codeblocks (bwc_field *const field,
/*----------------------------------------------------------------------------------------------------------*\ uint8 const cbX,
! FUNCTION NAME: uchar create_field(bwc_field *const field) ! uint8 const cbY,
! -------------- ! uint8 const cbZ,
! ! uint8 const cbTS);
! DESCRIPTION: ! //==========|==========================|======================|======|=======|====================
! ------------ ! void bwc_set_qm (bwc_field *const field,
! This function creates the field structure used to (de)compress a floating point array de- ! uint8 const Qm);
! fined by the bwc_initialize function. ! //==========|==========================|======================|======|=======|====================
! ! void bwc_set_tiles (bwc_field *const field,
\*----------------------------------------------------------------------------------------------------------*/ uint64 const tilesX,
uchar uint64 const tilesY,
create_field(bwc_field *const field); uint64 const tilesZ,
uint64 const tilesTS,
/*----------------------------------------------------------------------------------------------------------*\ bwc_tile_instr const instr);
! FUNCTION NAME: void kill_compression(bwc_field *const field) ! //==========|==========================|======================|======|=======|====================
! -------------- ! uchar bwc_create_compression (bwc_field *const field,
! ! char *const rate_control);
! DESCRIPTION: ! //==========|==========================|======================|======|=======|====================
! ------------ ! uchar bwc_compress (bwc_field *const field,
! This function deallocates the compression field structure used to define and control the ! bwc_data *const data);
! 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 ! bwc_field* bwc_create_decompression (bwc_data *const data,
! that have been allocated. ! uint8 const layer);
! ! //==========|==========================|======================|======|=======|====================
\*----------------------------------------------------------------------------------------------------------*/ uchar bwc_decompress (bwc_field *const field,
void bwc_data *const data);
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);
#endif #endif

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,128 +12,70 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| File: macros.h ||
|| ----- ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| DESCRIPTION NEEDED. ||
|| || || ||
|| STRUCTS: || || This file defines simple macros that are used to make the code more readable. ||
|| -------- ||
|| ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 #ifndef BWC_MACROSS_H
#define BWC_MACROSS_H #define BWC_MACROSS_H
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! These Macros are used to calculate the maximum and minimum between two values. !
! ! ! !
! Macros: ! ! These macros define simple mathematicall oprators. !
! ------- !
! Macro Description !
! ----- ----------- !
! MAX(x, y) - Returns the maximum value of two values. !
! ! ! !
! MIN(x, y) - Returns the minimum value of two values. ! \*----------------------------------------------------------------------------------------------*/
! ! #define MAX(x, y) (((x) < (y))?(y):(x)) // Returns maximum between two values
! DEVELOPMENT HISTORY: ! #define MIN(x, y) (((x) > (y))?(y):(x)) // Returns minimum between two values
! -------------------- !
! !
! 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: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! !
! This macro is used to evaluate the size of an array. ! ! 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))) #define GET_DIM(x) (sizeof(x)/sizeof(*(x)))
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! These Constants describe the codestream markers used to create the embedded codestream. ! ! These Constants define common error messages used throughout the bwc library. !
! ! ! !
! 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"\ #define MEMERROR "o##########################################################o\n"\
"| ERROR: Out of memory |\n"\ "| ERROR: Out of memory |\n"\
"o##########################################################o\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"\ #define CSERROR "o##########################################################o\n"\
"| ERROR: Invalid Codestream |\n"\ "| ERROR: Invalid Codestream |\n"\
"o##########################################################o\n" "o##########################################################o\n"

View file

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

View file

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

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,62 +12,52 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| File: prim_types_double.h ||
|| ----- ||
|| ||
|| DESCRIPTION: || || 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: || || This header defines a set of basic arithmetic types with specified widths to be ||
|| -------------------- || || used in the big whoop compression algorithm. ||
|| ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 #ifndef BWC_PRIM_TYPES_DOUBLE_H
#define BWC_PRIM_TYPES_DOUBLE_H #define BWC_PRIM_TYPES_DOUBLE_H
/************************************************************************************************\
/************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ || || _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ || || | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ || || | | \| |___ |___ |__| |__/ |___ ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
#include <stdint.h> #include <stdint.h>
/************************************************************************************************************\ /************************************************************************************************\
|| ___ ____ _ _ _ _ ___ _ _ _ ____ ___ _ _ ___ ____ ____ || || ___ ____ _ _ _ _ ___ _ _ _ ____ ___ _ _ ___ ____ ____ ||
|| |__] |__/ | |\/| | | | | | |___ | \_/ |__] |___ [__ || || |__] |__/ | |\/| | | | | | |___ | \_/ |__] |___ [__ ||
|| | | \ | | | | | | \/ |___ | | | |___ ___] || || | | \ | | | | | | \/ |___ | | | |___ ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
typedef unsigned char uchar; typedef unsigned char uchar;
typedef unsigned short ushort; typedef unsigned short ushort;
typedef unsigned int uint; typedef unsigned int uint;
@ -84,80 +74,60 @@
typedef double bwc_float; typedef double bwc_float;
typedef uint64 bwc_raw; typedef uint64 bwc_raw;
/************************************************************************************************************\ /************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ || || _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ || || |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] || || | | | | |___ | \ |__| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! These constants describe the minimum and maximum values for a double precision IEEE 754 ! ! These macros describe the minimum and maximum values for a double precision IEEE !
! floating point variable. ! ! 754 floating point variable. !
! ! ! !
! DEVELOPMENT HISTORY: ! \*----------------------------------------------------------------------------------------------*/
! -------------------- ! #define FLT_MAX 1.7976931348623157e+308 // Maximum finite value of a double
! ! #define FLT_MIN 2.2250738585072014e-308 // Minimum finite value of a double
! 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: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! These constants describe the precision (in bits and bytes) of the primitive floating point ! ! These macros describe the precision (in bits and bytes) of the derrived floating !
! type used during (de)compression as well as the number of bits used to represent the ! ! point type as well as the number of bits used to represent its mantissa and !
! mantissa and exponent fields. ! ! exponent fields. !
! ! ! !
! DEVELOPMENT HISTORY: ! \*----------------------------------------------------------------------------------------------*/
! -------------------- ! #define PREC_BIT 63 // Double type precision in bits
! ! #define PREC_MANTISSA 52 // Mantissa field precision in bits
! Date Author Change Id Release Description Of Change ! #define PREC_EXPONENT 11 // Exponent field precision in bits
! ---- ------ --------- ------- --------------------- ! #define PREC_BYTE 8 // Double type precision in bytes
! 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: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! These constants describe the bit masks used to access the sign, mantissa and exponent of ! ! These macros describe the bit masks used to access the sign, mantissa and !
! the primitive floating point type used during (de)compression. ! ! exponent of the derrived floating point type. !
! ! ! !
! DEVELOPMENT HISTORY: ! \*----------------------------------------------------------------------------------------------*/
! -------------------- ! #define SIGN 0x8000000000000000 // Sign bit mask
! ! #define MANTISSA 0x000FFFFFFFFFFFFF // Mantissa bit mask
! Date Author Change Id Release Description Of Change ! #define EXPONENT 0x7FF0000000000000 // Exponent bit mask
! ---- ------ --------- ------- --------------------- !
! 07.12.2018 Patrick Vogler B87D120 V 0.1.0 Constants created !
\*----------------------------------------------------------------------------------------------------------*/
#define SIGN 0x8000000000000000
#define MANTISSA 0x000FFFFFFFFFFFFF
#define EXPONENT 0x7FF0000000000000
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! This constants describe the maximum number of encoding passes during the entropy encoding ! ! This macro describe the maximum number of possible encoding passes during the !
! stage. ! ! 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 #define MAXIMUM_NO_PASSES (64 * 3) - 2
#endif #endif

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,62 +12,52 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| File: prim_types_single.h ||
|| ----- ||
|| ||
|| DESCRIPTION: || || 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: || || This header defines a set of basic arithmetic types with specified widths to be ||
|| -------------------- || || used in the big whoop compression algorithm. ||
|| ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 #ifndef BWC_PRIM_TYPES_SINGLE_H
#define BWC_PRIM_TYPES_SINGLE_H #define BWC_PRIM_TYPES_SINGLE_H
/************************************************************************************************\
/************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ || || _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ || || | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ || || | | \| |___ |___ |__| |__/ |___ ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
#include <stdint.h> #include <stdint.h>
/************************************************************************************************************\ /************************************************************************************************\
|| ___ ____ _ _ _ _ ___ _ _ _ ____ ___ _ _ ___ ____ ____ || || ___ ____ _ _ _ _ ___ _ _ _ ____ ___ _ _ ___ ____ ____ ||
|| |__] |__/ | |\/| | | | | | |___ | \_/ |__] |___ [__ || || |__] |__/ | |\/| | | | | | |___ | \_/ |__] |___ [__ ||
|| | | \ | | | | | | \/ |___ | | | |___ ___] || || | | \ | | | | | | \/ |___ | | | |___ ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
typedef unsigned char uchar; typedef unsigned char uchar;
typedef unsigned short ushort; typedef unsigned short ushort;
typedef unsigned int uint; typedef unsigned int uint;
@ -84,80 +74,60 @@
typedef float bwc_float; typedef float bwc_float;
typedef uint32 bwc_raw; typedef uint32 bwc_raw;
/************************************************************************************************************\ /************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ || || _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ || || |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] || || | | | | |___ | \ |__| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! These constants describe the minimum and maximum values for a double precision IEEE 754 ! ! These macros describe the minimum and maximum values for a single precision IEEE !
! floating point variable. ! ! 754 floating point variable. !
! ! ! !
! DEVELOPMENT HISTORY: ! \*----------------------------------------------------------------------------------------------*/
! -------------------- ! #define FLT_MAX 1.70141183e+38 // Maximum finite value of a float
! ! #define FLT_MIN 1.17549435e-38 // Minimum finite value of a float
! 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: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! These constants describe the precision (in bits and bytes) of the primitive floating point ! ! These macros describe the precision (in bits and bytes) of the derrived floating !
! type used during (de)compression as well as the number of bits used to represent the ! ! point type as well as the number of bits used to represent its mantissa and !
! mantissa and exponent fields. ! ! exponent fields. !
! ! ! !
! DEVELOPMENT HISTORY: ! \*----------------------------------------------------------------------------------------------*/
! -------------------- ! #define PREC_BIT 31 // Float type precision in bits
! ! #define PREC_MANTISSA 23 // Mantissa field precision in bits
! Date Author Change Id Release Description Of Change ! #define PREC_EXPONENT 8 // Exponent field precision in bits
! ---- ------ --------- ------- --------------------- ! #define PREC_BYTE 4 // Float type precision in bytes
! 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: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! These constants describe the bit masks used to access the sign, mantissa and exponent of ! ! These macros describe the bit masks used to access the sign, mantissa and !
! the primitive floating point type used during (de)compression. ! ! exponent of the derrived floating point type. !
! ! ! !
! DEVELOPMENT HISTORY: ! \*----------------------------------------------------------------------------------------------*/
! -------------------- ! #define SIGN 0x80000000 // Sign bit mask
! ! #define MANTISSA 0x007FFFFF // Mantissa bit mask
! Date Author Change Id Release Description Of Change ! #define EXPONENT 0x7F800000 // Exponent bit mask
! ---- ------ --------- ------- --------------------- !
! 07.12.2018 Patrick Vogler B87D120 V 0.1.0 Constants created !
\*----------------------------------------------------------------------------------------------------------*/
#define SIGN 0x80000000
#define MANTISSA 0x007FFFFF
#define EXPONENT 0x7F800000
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! This constants describe the maximum number of encoding passes during the entropy encoding ! ! This macro describe the maximum number of possible encoding passes during the !
! stage. ! ! 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 #define MAXIMUM_NO_PASSES (32 * 3) - 2
#endif #endif

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,150 +12,84 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| File: tagtree.h ||
|| ----- ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| DESCRIPTION NEEDED. ||
|| || || ||
|| STRUCTS: || || This file defines a tagtree procedure used to encode/decode two types of ||
|| -------- || || information found defining in a codeblock in specific quality layer: ||
|| || || ||
|| PUBLIC FUNCTIONS: || || - 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. ||
|| || || ||
|| DEVELOPMENT HISTORY: || || For more information on the encoding/decoding process please refere to JPEG2000 ||
|| -------------------- || || by D. S. Taubman and M. W. Marcellin (p. 384). ||
|| ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 #ifndef TAGTREE_H
#define TAGTREE_H #define TAGTREE_H
/************************************************************************************************\
/************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ || || _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ || || | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ || || | | \| |___ |___ |__| |__/ |___ ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
#include "types.h" #include "types.h"
/************************************************************************************************************\ /************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ void kill_tagtree (bwc_tagtree *const tagtree);
! FUNCTION NAME: void kill_tagtree(bwc_tagtree* tagtree) ! //==========|==========================|======================|======|=======|====================
! -------------- ! void reset_tagtree (bwc_tagtree *const tagtree);
! ! //==========|==========================|======================|======|=======|====================
! DESCRIPTION: ! bwc_tagtree* initialize_tagtree (uint64 const leafsX,
! ------------ ! uint64 const leafsY,
! This function deallocates a tagtree instance used to encode codeblock contributions to a ! uint64 const leafsZ,
! specific quality layer as well as the number of magnitude bit planes used to represent the ! uint64 const leafsTS);
! samples of a specific codeblock. ! //==========|==========================|======================|======|=======|====================
! ! uint16 tagtree_get_value (bwc_tagtree const *const tagtree,
\*----------------------------------------------------------------------------------------------------------*/ uint64 const leaf_index);
void //==========|==========================|======================|======|=======|====================
kill_tagtree(bwc_tagtree* tagtree); void tagtree_set_value (bwc_tagtree *const tagtree,
uint64 const leaf_index,
/*----------------------------------------------------------------------------------------------------------*\ uint16 const value);
! FUNCTION NAME: void *test(void) ! //==========|==========================|======================|======|=======|====================
! -------------- ! void encode_tagtree (bwc_tagtree *const tagtree,
! ! bwc_stream *const stream,
! DESCRIPTION: ! uint32 const threshold,
! ------------ ! uint32 const leaf_index,
! DESCRIPTION NEEDED ! uchar const estimate);
! ! //==========|==========================|======================|======|=======|====================
\*----------------------------------------------------------------------------------------------------------*/ uchar decode_tagtree (bwc_tagtree *const tagtree,
void bwc_stream *const stream,
reset_tagtree(bwc_tagtree* const tagtree); uint32 const threshold,
uint32 const leaf_index);
/*----------------------------------------------------------------------------------------------------------*\
! 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);
#endif #endif

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,123 +12,143 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| File: tier1.h ||
|| ----- ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| DESCRIPTION NEEDED. ||
|| || || ||
|| STRUCTS: || || 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 ||
|| PUBLIC FUNCTIONS: || || refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|| ----------------- ||
|| ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 #ifndef TIER1_H
#define TIER1_H #define TIER1_H
/************************************************************************************************\
/************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ || || _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ || || | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ || || | | \| |___ |___ |__| |__/ |___ ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
#include "types.h" #include "types.h"
/************************************************************************************************************\ /************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ || || _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ || || |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] || || | | | | |___ | \ |__| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! This macro defines the maximum decomposition level up to which the wavelet filer energy gain ! ! The macros listed indicate how many bits, from the current coding position, !
! is calculated. Beyond the maximum decomposition level the energy gain will only be ! ! are used for error evaluation in the coding passes. !
! approximated. !
! ! ! !
! Macros: ! \*----------------------------------------------------------------------------------------------*/
! ------- ! #define DISTORTION_SIG 5 // Clean up/significance propagation pass.
! Macro Description ! #define DISTORTION_MAG 6 // Magnitude refinement pass.
! ----- ----------- !
! 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: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! These macros define the irrational coefficients for the high and low pass synthesis filters ! ! This structure holds the sign (xi), bitfield (bit) and state (delta, sigma and !
! associated with the (5-3) LeGall-Wavelet. ! ! 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. !
! ! ! !
! Macros: ! \*----------------------------------------------------------------------------------------------*/
! ------- ! typedef struct stripe
! Macro Description ! {
! ----- ----------- ! uint64 *sample; // Wavelet coef. for two adjacent stripes.
! 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
#define DWT_5X3_G0 0.75f uint8 delta; // Delayed sig. for two adjacent stripes.
#define DWT_5X3_G1 -0.25f uint8 sigma; // Significance for two adjacent stripes.
#define DWT_5X3_G2 -0.125f uint8 pi; // Cdng pass membership for adj. stripes.
uint8 codingpass; // Last decoded coding pass.
uint8 bitplane; // Last decoded bitplane.
uint8 *bit; // Bitplanes for vertically adj. stripes.
uint8 xi; // Wvlt coef. sign bit for adj. stripes.
struct stripe *stripe_u; // Upper stripe.
struct stripe *stripe_r; // Right stripe.
struct stripe *stripe_d; // Lower stripe.
struct stripe *stripe_l; // Left stripe.
} bwc_coder_stripe;
/*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This structure accumulates all necessary structures used to (de-)compress a !
! codeblock of wavelet coefficients. The spatial and temporal dimension of the !
! codeblock is defined by its width, height and number of slices (depth * dt). The !
! codeblock itself is subdivided into so-called stripes that represent 4 vertical- !
! ly adjacent coefficients. The parameter no_full_stripes stores overnumber of !
! full stripes present in one slice. !
! The look-up table sig2context is used to determine the coding context of a cur- !
! ren bit according to its significance context within the codeblock bitplane. !
! The look-up table is specific to a certain highband and is set accordingly. !
! !
\*----------------------------------------------------------------------------------------------*/
typedef struct
{
uchar highband_flag; // Flag indicating current wavelet subbnd.
uint8 K; // Idx of the first significant bitplane.
uchar erres; // Flag signaling error resilience.
uint64 no_full_stripe; // Number of full, vert. adjacent stripes.
uint64 width, height; // Codeblock width and height.
uint64 no_slice; // N.o. slices in the spec. codeblock.
uint8 const *sig2context; // Signifance-to-context loop-up table.
bwc_bit_coder *bitcoder; // BWC bitcoder.
bwc_coder_stripe *data; // BWC coder stripe.
uint64 buff_size; // Size of packed stream.
uint64 buff_incr; // Increment for packed stream assembly.
uchar *compressed; // Compressed data chunck.
} bwc_coder;
/************************************************************************************************************\ /************************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,122 +12,76 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| File: tier2.h ||
|| ----- ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| DESCRIPTION NEEDED. ||
|| || || ||
|| STRUCTS: || || 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 ||
|| PUBLIC FUNCTIONS: || || refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|| ----------------- ||
|| - 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 #ifndef TIER2_H
#define TIER2_H #define TIER2_H
/************************************************************************************************\
/************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ || || _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ || || | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ || || | | \| |___ |___ |__| |__/ |___ ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
#include "types.h" #include "types.h"
/************************************************************************************************************\
/************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ || || _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ || || |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] || || | | | | |___ | \ |__| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! ! ! !
! This macro defines the initial packet header size. ! ! Definition of the initial codestream 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 #define PACKET_HEADER_SIZE 512
/************************************************************************************************************\ /************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || || ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ || || |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ uchar t2_encode (bwc_field *const field,
! FUNCTION NAME: uchar t2_encode(bwc_field *const field, bwc_tile *const tile) ! bwc_tile *const tile);
! -------------- ! //==========|==========================|======================|======|=======|====================
! ! uchar parse_packet (bwc_field *const field,
! DESCRIPTION: ! bwc_tile *const tile,
! ------------ !
! 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, bwc_packet *const packet,
uint64 const body_size); uint64 const body_size);
#endif #endif

File diff suppressed because it is too large Load diff

View file

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

View file

@ -239,7 +239,7 @@ read_eas3_header(bwc_data *const data)
! Save the file pointer and data info structure in tempo- ! ! Save the file pointer and data info structure in tempo- !
! rary variables to make the code more readable. ! ! rary variables to make the code more readable. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
fp = data->file.fp; fp = data->fp;
info = &data->info; info = &data->info;
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
@ -618,7 +618,7 @@ write_eas3_header(bwc_data *const data)
! Save the file pointer and data info structure in tempo- ! ! Save the file pointer and data info structure in tempo- !
! rary variables to make the code more readable. ! ! rary variables to make the code more readable. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
fp = data->file.fp; fp = data->fp;
info = &data->info; info = &data->info;
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
@ -866,7 +866,7 @@ read_eas3(char *const filename)
! Open the specified file for reading. If the file doesn't ! ! Open the specified file for reading. If the file doesn't !
! exist, exit the bwc command-line tool. ! ! 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 // error opening file
fprintf(stderr, "o##########################################################o\n"\ 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- ! ! file and store the information in the bwc_gl_data struc- !
! ture. ! ! ture. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
root = ftell(data->file.fp); root = ftell(data->fp);
fseek(data->file.fp, 0L, SEEK_END); fseek(data->fp, 0L, SEEK_END);
Lfield = (ftell(data->file.fp) - root) / sizeof(double); Lfield = (ftell(data->fp) - root) / sizeof(double);
fseek(data->file.fp, root, SEEK_SET); fseek(data->fp, root, SEEK_SET);
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Check if the file_size coincide with the specified dimen-! ! 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. ! ! 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 // invalid read
fprintf(stderr, RDERROR); fprintf(stderr, RDERROR);
@ -971,7 +971,7 @@ read_eas3(char *const filename)
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Read the flow field data from the specified eas3 file. ! ! 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 // invalid read
fprintf(stderr, RDERROR); fprintf(stderr, RDERROR);
@ -993,8 +993,8 @@ read_eas3(char *const filename)
! Close the file pointer and return the bwc_data structure ! ! Close the file pointer and return the bwc_data structure !
! to the function caller. ! ! to the function caller. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
fclose(data->file.fp); fclose(data->fp);
data->file.fp = NULL; data->fp = NULL;
return data; 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- ! ! exist, discard its content. If the file cannot be creat- !
! ed, exit the bwc command-line tool. ! ! 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 // error opening file
fprintf(stderr, "o##########################################################o\n"\ 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. ! ! 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 // invalid read
fprintf(stderr, WRTERROR); 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. ! ! 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 // invalid read
fprintf(stderr, WRTERROR); 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.! ! Close the file pointer and return to the function caller.!
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
fclose(data->file.fp); fclose(data->fp);
data->file.fp = NULL; data->fp = NULL;
return 0; return 0;
} }

View file

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

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,71 +12,38 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| FILE NAME: bitstream.c ||
|| ||
|| ||
|| DESCRIPTION: || || 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. ||
|| || || ||
|| 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. ||
|| || || ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 uint64
bytes_used(bwc_stream *const stream) bytes_used(bwc_stream const *const stream)
{ {
if(stream->T == 0xFF) if(stream->T == 0xFF)
{ {

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,57 +12,38 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| FILE NAME: bitstream.c ||
|| ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| DESCRIPTION NEEDED. ||
|| || || ||
|| FILE REFERENCES: || || 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 ||
|| Name I/O Description || || conforming bwc datasets. ||
|| ---- --- ----------- ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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. ||
|| || || ||
\*==================================================================================================================================*/ \*================================================================================================*/
/************************************************************************************************************\ /************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ || || _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ || || | |\ | | | | | | \ |___ ||
@ -1145,7 +1126,7 @@ bwc_parse_main_header(bwc_data *const data,bwc_stream *const stream)
if(CSsgc & (0x01 << 1)) 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); buff_long = bwc_get_symbol(stream, 1);

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,71 +12,38 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| FILE NAME: dwt.c ||
|| ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| DESCRIPTION NEEDED. ||
|| || || ||
|| FILE REFERENCES: || || 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. ||
|| Name I/O Description || || Marcellin. ||
|| ---- --- ----------- ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 ! ! (5/3) and Haar wavelet transform by setting the energy !
! gain factor for level zero to one. ! ! 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_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_DECOMPOSITION_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_DECOMPOSITION_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- ! ! Loop through the symmetric wavelet filter banks and as- !
@ -1307,7 +1274,7 @@ initialize_gain_lut()
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Loop through the remaining decomposition levels. ! ! 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 ! ! 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 ! ! high-pass energy gain factor and set the length of work !
! buffer 1 to the corresponding high-pass filter length. ! ! buffer 1 to the corresponding high-pass filter length. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
LUT += MAX_DECOMPOSITION_LEVELS + 1; LUT += MAX_DECOMP_LEVELS + 1;
Length_Gb = Length[1]; Length_Gb = Length[1];
} }
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
@ -1399,7 +1366,7 @@ initialize_gain_lut()
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Loop through the remaining decomposition levels. ! ! 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 ! ! Assemble the low- or high-pass synthesis sequence for !
@ -1435,7 +1402,7 @@ initialize_gain_lut()
! Calculate the energy gain factor for decomposition level ! ! Calculate the energy gain factor for decomposition level !
! i by evaluating the square norm of work buffer 1. ! ! i by evaluating the square norm of work buffer 1. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
LUT += MAX_DECOMPOSITION_LEVELS + 1; LUT += MAX_DECOMP_LEVELS + 1;
Length_Gb = Length[1]; Length_Gb = Length[1];
} }
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
@ -1457,9 +1424,9 @@ initialize_gain_lut()
! ! ! !
! DESCRIPTION: ! ! DESCRIPTION: !
! ------------ ! ! ------------ !
! This function evaluates the energy gain factor according to the the specified decomposition ! ! This function evaluates the energy gain factor according to the the specified decom- !
! level. For decomposition levels larger than MAX_DECOMPOSITION_LEVELS the filter gain for ! ! position level. For decomposition levels larger than MAX_DECOMP_LEVELS the filter gain !
! the extra levels is approximated by multiplying the energy gain factor by 2. ! ! for the extra levels is approximated by multiplying the energy gain factor by 2. !
! ! ! !
! PARAMETERS: ! ! 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 ! ! Multiply the energy gain factor with the filter gain of !
! the wavelet kernel applied along the X-axis. For decom- ! ! the wavelet kernel applied along the X-axis. For decom- !
! position levels larger than MAX_DECOMPOSITION_LEVELS the ! ! position levels larger than MAX_DECOMP_LEVELS the energy !
! energy gain for the extra levels is approximated by mul- ! ! gain for the extra levels is approximated by multiplying !
! tiplying it by 2. ! ! it by 2. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
if(level_X != 0) if(level_X != 0)
{ {
while(level_X > MAX_DECOMPOSITION_LEVELS) while(level_X > MAX_DECOMP_LEVELS)
{ {
Gb *= 2.0f; Gb *= 2.0f;
level_X--; 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 ! ! Multiply the energy gain factor with the filter gain of !
! the wavelet kernel applied along the Y-axis. For decom- ! ! the wavelet kernel applied along the Y-axis. For decom- !
! position levels larger than MAX_DECOMPOSITION_LEVELS the ! ! position levels larger than MAX_DECOMP_LEVELS the energy !
! energy gain for the extra levels is approximated by mul- ! ! gain for the extra levels is approximated by multiplying !
! tiplying it by 2. ! ! it by 2. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
if(level_Y != 0) if(level_Y != 0)
{ {
while(level_Y > MAX_DECOMPOSITION_LEVELS) while(level_Y > MAX_DECOMP_LEVELS)
{ {
Gb *= 2.0f; Gb *= 2.0f;
level_Y--; 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 ! ! Multiply the energy gain factor with the filter gain of !
! the wavelet kernel applied along the Z-axis. For decom- ! ! the wavelet kernel applied along the Z-axis. For decom- !
! position levels larger than MAX_DECOMPOSITION_LEVELS the ! ! position levels larger than MAX_DECOMP_LEVELS the energy !
! energy gain for the extra levels is approximated by mul- ! ! gain for the extra levels is approximated by multiplying !
! tiplying it by 2. ! ! it by 2. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
if(level_Z != 0) if(level_Z != 0)
{ {
while(level_Z > MAX_DECOMPOSITION_LEVELS) while(level_Z > MAX_DECOMP_LEVELS)
{ {
Gb *= 2.0f; Gb *= 2.0f;
level_Z--; 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 ! ! Multiply the energy gain factor with the filter gain of !
! the wavelet kernel applied along the TS-axis. For decom- ! ! the wavelet kernel applied along the TS-axis. For decom- !
! position levels larger than MAX_DECOMPOSITION_LEVELS the ! ! position levels larger than MAX_DECOMP_LEVELS the energy !
! energy gain for the extra levels is approximated by mul- ! ! gain for the extra levels is approximated by multiplying !
! tiplying it by 2. ! ! it by 2. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
if(level_TS != 0) if(level_TS != 0)
{ {
while(level_TS > MAX_DECOMPOSITION_LEVELS) while(level_TS > MAX_DECOMP_LEVELS)
{ {
Gb *= 2.0f; Gb *= 2.0f;
level_TS--; 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; return (bwc_float)Gb;
} }
@ -1645,7 +1612,7 @@ get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level)
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
uchar 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: ! ! DEFINE INT VARIABLES: !
@ -2182,7 +2149,7 @@ forward_discrete_wavelet_transform(bwc_field *const field, bwc_parameter *const
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
uchar 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: ! ! DEFINE INT VARIABLES: !

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,76 +12,36 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| ||
|| Version 0.1.1 ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| Big Whoop is a compression codec for the lossy compression of IEEE 754 floating point arrays defined on curvelinear ||
|| compute grids. ||
|| || || ||
|| FILE REFERENCES: || || Big Whoop is a compression codec for the lossy compression of IEEE 754 floating ||
|| ---------------- || || point arrays defined on curvelinear compute grids. ||
|| ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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); 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.data);
free(data->codestream.aux); free(data->codestream.aux);
free(data->codestream.com); free(data->codestream.com);
free(data->file.d_root);
free(data->file.f_root);
free(data->field.d); free(data->field.d);
free(data->field.f); free(data->field.f);
free(data); 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: ! ! DESCRIPTION: !
@ -2752,7 +2710,7 @@ bwc_set_error_resilience(bwc_field *const field)
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
void 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: ! ! 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: ! ! DESCRIPTION: !
@ -2818,7 +2776,7 @@ bwc_set_quantization_style(bwc_field *const field, bwc_quant_st quantization_sty
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
void 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: ! ! DEFINE STRUCTS: !
@ -4062,7 +4020,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data)
#else #else
start = (double)clock(); start = (double)clock();
#endif #endif
if(forward_discrete_wavelet_transform(field, parameter)) if(forward_wavelet_transform(field, parameter))
{ {
free(working_buffer); free(working_buffer);
return 1; return 1;
@ -4419,7 +4377,7 @@ bwc_decompress(bwc_field *const field, bwc_data *const data)
#else #else
start = (double)clock(); start = (double)clock();
#endif #endif
if(inverse_discrete_wavelet_transform(field, parameter)) if(inverse_wavelet_transform(field, parameter))
{ {
free(working_buffer); free(working_buffer);
return 1; return 1;

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,58 +12,36 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| FILE NAME: mq.c ||
|| ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| ||
|| DESCRIPTION NEEDED. || || 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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 "macros.h"
#include "mq.h" #include "mq.h"
#include "tier1.h"
#include "types.h" #include "types.h"
/************************************************************************************************************\ /************************************************************************************************************\
@ -346,7 +325,7 @@ static const bwc_context_state context_state[94] =
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
uchar 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: ! ! DEFINE INT VARIABLES: !
@ -427,7 +406,7 @@ initialize_bit_encoder(bwc_coder *const coder, const uint8 number_of_contexts)
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
uchar uchar
bit_encoder_next_run(bwc_bit_coder *const bitcoder) mq_next_run(bwc_bit_coder *const bitcoder)
{ {
/*-----------------------*\ /*-----------------------*\
! DEFINE STRUCTS: ! ! DEFINE STRUCTS: !
@ -496,7 +475,7 @@ bit_encoder_next_run(bwc_bit_coder *const bitcoder)
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
void 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: ! ! DEFINE INT VARIABLES: !
@ -605,7 +584,7 @@ bit_encode(bwc_bit_coder *const bitcoder, const uint8 s, const uint8 k)
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
void void
bit_encoder_truncation_length_min(bwc_coder_state *const state) mq_truncation_length_min(bwc_coder_state *const state)
{ {
/*-----------------------*\ /*-----------------------*\
! DEFINE INT VARIABLES: ! ! DEFINE INT VARIABLES: !
@ -724,7 +703,7 @@ bit_encoder_truncation_length_min(bwc_coder_state *const state)
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
void void
bit_encoder_termination(bwc_bit_coder *const bitcoder) mq_termination(bwc_bit_coder *const bitcoder)
{ {
/*-----------------------*\ /*-----------------------*\
! DEFINE INT VARIABLES: ! ! DEFINE INT VARIABLES: !
@ -774,7 +753,7 @@ bit_encoder_termination(bwc_bit_coder *const bitcoder)
while(state) while(state)
{ {
bit_encoder_truncation_length_min(state); mq_truncation_length_min(state);
state = state->next; state = state->next;
} }
} }
@ -808,7 +787,7 @@ bit_encoder_termination(bwc_bit_coder *const bitcoder)
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
void void
free_bit_encoder(bwc_coder *const coder) free_mq_encoder(bwc_coder *const coder)
{ {
/*-----------------------*\ /*-----------------------*\
! DEFINE ASSERTIONS: ! ! DEFINE ASSERTIONS: !
@ -864,7 +843,7 @@ free_bit_encoder(bwc_coder *const coder)
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
uchar 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: ! ! DEFINE INT VARIABLES: !
@ -968,7 +947,7 @@ initialize_bit_decoder(bwc_coder *const coder, const uint8 number_of_contexts, c
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
uint8 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: ! ! DEFINE INT VARIABLES: !
@ -1078,7 +1057,7 @@ bit_decode(bwc_bit_coder *const bitcoder, const uint8 k)
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
uint64 uint64
bit_coder_get_no_bytes(bwc_bit_coder *const bitcoder) mq_get_no_bytes(bwc_bit_coder *const bitcoder)
{ {
/*-----------------------*\ /*-----------------------*\
! DEFINE ASSERTIONS: ! ! DEFINE ASSERTIONS: !
@ -1117,7 +1096,7 @@ bit_coder_get_no_bytes(bwc_bit_coder *const bitcoder)
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
void 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: ! ! DEFINE STRUCTS: !
@ -1169,7 +1148,7 @@ bit_coder_reset_ptr(bwc_bit_coder *const bitcoder, uchar *const memory)
! ! ! !
\*----------------------------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------------------------*/
void 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: ! ! DEFINE INT VARIABLES: !

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,65 +12,44 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| FILE NAME: tagtree.c ||
|| ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| DESCRIPTION NEEDED. ||
|| || || ||
|| FILE REFERENCES: || || This file defines a tagtree procedure used to encode/decode two types of ||
|| ---------------- || || information found defining in a codeblock in specific quality layer: ||
|| || || ||
|| Name I/O Description || || - The inclusion tag records if a codeblock has any contribution ||
|| ---- --- ----------- || || to a quality layer. ||
|| none - - || || - 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). ||
|| || || ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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. ||
|| || || ||
\*==================================================================================================================================*/ \*================================================================================================*/
/************************************************************************************************************\ /************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ || || _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ || || | |\ | | | | | | \ |___ ||

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,58 +12,38 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| FILE NAME: tier1.c ||
|| ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| DESCRIPTION NEEDED. ||
|| || || ||
|| FILE REFERENCES: || || 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 ||
|| Name I/O Description || || refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|| ---- --- ----------- ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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) \ #define encode_segmark(bitcoder) \
{ \ { \
bit_encode(bitcoder, 1, CONTEXT_UNI); \ mq_bit_encode(bitcoder, 1, CONTEXT_UNI); \
bit_encode(bitcoder, 0, CONTEXT_UNI); \ mq_bit_encode(bitcoder, 0, CONTEXT_UNI); \
bit_encode(bitcoder, 1, CONTEXT_UNI); \ mq_bit_encode(bitcoder, 1, CONTEXT_UNI); \
bit_encode(bitcoder, 0, 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; stripe = coder->data;
rest = 4 - (coder->height & 0x03); rest = 4 - (coder->height & 0x03);
stripe_mask = ~((0x0F >> ((coder->height & 0x03))) | 0xF0); stripe_mask = ~((0x0F >> ((coder->height & 0x03))) | 0xF0);
dist_shift = (b < DISTORTION_MANTISSA) ? 0 : (b - DISTORTION_MANTISSA); dist_shift = (b < DISTORTION_SIG) ? 0 : (b - DISTORTION_SIG);
dist_corr = (b < DISTORTION_MANTISSA) ? (DISTORTION_MANTISSA - b) : 0; dist_corr = (b < DISTORTION_SIG) ? (DISTORTION_SIG - b) : 0;
for(i = 0, k = 0; i < coder->no_slice; ++i) 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) 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) if(bit & bit_mask)
{ {
@ -1075,7 +1055,7 @@ significance_propagation_enc_pass(bwc_coder *const coder, const int8 b)
xi_h = SIG2XI[xi_h]; xi_h = SIG2XI[xi_h];
xi_v = SIG2XI[xi_v]; xi_v = SIG2XI[xi_v];
bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]), 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]); XI2CONT[(xi_h << 2) | xi_v][0]);
mse += DISTORTION_TS_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x1F]; mse += DISTORTION_TS_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x1F];
@ -1126,7 +1106,7 @@ significance_propagation_enc_pass(bwc_coder *const coder, const int8 b)
if(k_sig && (stripe[k].sigma^bit_mask)) 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) if(bit & bit_mask)
{ {
@ -1144,7 +1124,7 @@ significance_propagation_enc_pass(bwc_coder *const coder, const int8 b)
xi_h = SIG2XI[xi_h]; xi_h = SIG2XI[xi_h];
xi_v = SIG2XI[xi_v]; xi_v = SIG2XI[xi_v];
bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]), 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]); XI2CONT[(xi_h << 2) | xi_v][0]);
mse += DISTORTION_TS_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x1F]; mse += DISTORTION_TS_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x1F];
@ -1227,8 +1207,8 @@ magnitude_refinement_enc_pass(bwc_coder *const coder, const int8 b)
stripe = coder->data; stripe = coder->data;
rest = 4 - (coder->height & 0x03); rest = 4 - (coder->height & 0x03);
stripe_mask = ~((0x0F >> ((coder->height & 0x03))) | 0xF0); stripe_mask = ~((0x0F >> ((coder->height & 0x03))) | 0xF0);
dist_shift = (b < DISTORTION_MANTISSA) ? 0 : (b - DISTORTION_MANTISSA); dist_shift = (b < DISTORTION_MAG) ? 0 : (b - DISTORTION_MAG);
dist_corr = (b < DISTORTION_MANTISSA) ? (DISTORTION_MANTISSA - b) : 0; dist_corr = (b < DISTORTION_MAG) ? (DISTORTION_MAG - b) : 0;
for(i = 0, k = 0; i < coder->no_slice; ++i) 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]; mse += DISTORTION_TM_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x3F];
stripe[k].delta |= bit_mask; 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]; mse += DISTORTION_TM_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x3F];
stripe[k].delta |= bit_mask; stripe[k].delta |= bit_mask;
@ -1383,8 +1363,8 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b)
mse = 0; mse = 0;
stripe = coder->data; stripe = coder->data;
rest = 4 - (coder->height & 0x03); rest = 4 - (coder->height & 0x03);
dist_shift = (b < DISTORTION_MANTISSA) ? 0 : (b - DISTORTION_MANTISSA); dist_shift = (b < DISTORTION_SIG) ? 0 : (b - DISTORTION_SIG);
dist_corr = (b < DISTORTION_MANTISSA) ? (DISTORTION_MANTISSA - b) : 0; dist_corr = (b < DISTORTION_SIG) ? (DISTORTION_SIG - b) : 0;
for(i = 0, k = 0; i < coder->no_slice; ++i) 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 |= r >> 2;
r = DISTORTION_LZ_LUT[r]; r = DISTORTION_LZ_LUT[r];
bit_encode(coder->bitcoder, (uchar)1, CONTEXT_RUN); mq_bit_encode(coder->bitcoder, (uchar)1, CONTEXT_RUN);
bit_encode(coder->bitcoder, (uchar)r >> 1, CONTEXT_UNI); mq_bit_encode(coder->bitcoder, (uchar)r >> 1, CONTEXT_UNI);
bit_encode(coder->bitcoder, (uchar)r&0x01, CONTEXT_UNI); mq_bit_encode(coder->bitcoder, (uchar)r&0x01, CONTEXT_UNI);
} }
else else
{ {
r = 4; 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; (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) if(bit & bit_mask)
{ {
@ -1470,7 +1450,7 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b)
xi_h = SIG2XI[xi_h]; xi_h = SIG2XI[xi_h];
xi_v = SIG2XI[xi_v]; xi_v = SIG2XI[xi_v];
bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]), 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]); XI2CONT[(xi_h << 2) | xi_v][0]);
mse += DISTORTION_TS_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x1F]; mse += DISTORTION_TS_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x1F];
@ -1503,7 +1483,7 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b)
(0x01 & stripe[k].stripe_u->stripe_r->sigma)) << 3; (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) if(bit & bit_mask)
{ {
@ -1521,7 +1501,7 @@ cleanup_enc_pass(bwc_coder *const coder, const int8 b)
xi_h = SIG2XI[xi_h]; xi_h = SIG2XI[xi_h];
xi_v = SIG2XI[xi_v]; xi_v = SIG2XI[xi_v];
bit_encode(coder->bitcoder, (uchar)(((bit_mask & stripe[k].xi) >> l)^XI2CONT[(xi_h << 2) | xi_v][1]), 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]); XI2CONT[(xi_h << 2) | xi_v][0]);
mse += DISTORTION_TS_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x1F]; mse += DISTORTION_TS_LUT[((stripe[k].sample[l] >> dist_shift) << dist_corr) & 0x1F];
@ -1630,7 +1610,7 @@ significance_propagation_dec_pass(bwc_coder *const coder, const int8 b)
if(k_sig) if(k_sig)
{ {
bit = bit_decode(coder->bitcoder, coder->sig2context[k_sig]); bit = mq_bit_decode(coder->bitcoder, coder->sig2context[k_sig]);
if(bit) if(bit)
{ {
@ -1654,7 +1634,7 @@ significance_propagation_dec_pass(bwc_coder *const coder, const int8 b)
xi_h = SIG2XI[xi_h]; xi_h = SIG2XI[xi_h];
xi_v = SIG2XI[xi_v]; 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; 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)) 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) if(bit)
{ {
@ -1723,7 +1703,7 @@ significance_propagation_dec_pass(bwc_coder *const coder, const int8 b)
xi_h = SIG2XI[xi_h]; xi_h = SIG2XI[xi_h];
xi_v = SIG2XI[xi_v]; 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; 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; 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; 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 && !(0x01 & stripe[k].stripe_u->stripe_r->sigma) && !stripe[k].stripe_r->sigma &&
!stripe[k].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 = mq_bit_decode(coder->bitcoder, CONTEXT_UNI);
r = (r << 1) + bit_decode(coder->bitcoder, CONTEXT_UNI); r = (r << 1) + mq_bit_decode(coder->bitcoder, CONTEXT_UNI);
bit |= (0x08 >> r); bit |= (0x08 >> r);
} }
else else
@ -2007,7 +1987,7 @@ cleanup_dec_pass(bwc_coder *const coder, const int8 b)
(0x08 & stripe[k].stripe_d->stripe_r->sigma)) >> 3; (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) if(bit & bit_mask)
{ {
@ -2029,7 +2009,7 @@ cleanup_dec_pass(bwc_coder *const coder, const int8 b)
xi_h = SIG2XI[xi_h]; xi_h = SIG2XI[xi_h];
xi_v = SIG2XI[xi_v]; 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; 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; (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) if(bit & bit_mask)
{ {
@ -2081,7 +2061,7 @@ cleanup_dec_pass(bwc_coder *const coder, const int8 b)
xi_h = SIG2XI[xi_h]; xi_h = SIG2XI[xi_h];
xi_v = SIG2XI[xi_v]; 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; 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- ! ! Initialize the entropy encoder used for the current com- !
! pression run. ! ! pression run. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
if(initialize_bit_encoder(&coder, CONTEXT_TOTAL)) if(initialize_mq_encoder(&coder, CONTEXT_TOTAL))
{ {
return; 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. ! ! Reset the bit encoder for the next coding pass. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
if(bit_encoder_next_run(coder.bitcoder)) if(mq_next_run(coder.bitcoder))
{ {
return; 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 ! ! Evaluate the number of bytes generated so far by the bit !
! encoder and increase the buffer size if necessary. ! ! 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.buff_size += ((uint64)k >> 1) * coder.buff_incr;
coder.compressed = realloc(coder.compressed, coder.buff_size * sizeof(uchar)); 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; 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 ! ! 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 ! ! Evalute the number of bytes generated by the bit encoder !
! and increase the buffer size if necessary. ! ! 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.buff_size += 16;
coder.compressed = realloc(coder.compressed, coder.buff_size * sizeof(uchar)); 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; 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 ! ! Flush the remaining bits in the byte buffer to the coder !
! output and calculate the minimum truncation lengths. ! ! output and calculate the minimum truncation lengths. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
bit_encoder_termination(coder.bitcoder); mq_termination(coder.bitcoder);
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Save the number of significant bitplanes, insignificant ! ! 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 ! ! Save the lengths of the coding passes in the encoded !
! codeblock structure. ! ! 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 the entropy encoder structure. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
free_bit_encoder(&coder); free_mq_encoder(&coder);
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Calculate the slope values of the distortion/rate convex ! ! 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- ! ! Initialize the entropy encoder used for the current com- !
! pression run. ! ! 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; return;
} }
@ -2787,10 +2767,10 @@ decode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
decoding_pass[i](&coder, k); decoding_pass[i](&coder, k);
} }
if((coder.erres) && (((bit_decode(coder.bitcoder, CONTEXT_UNI) << 3) | if((coder.erres) && (((mq_bit_decode(coder.bitcoder, CONTEXT_UNI) << 3) |
(bit_decode(coder.bitcoder, CONTEXT_UNI) << 2) | (mq_bit_decode(coder.bitcoder, CONTEXT_UNI) << 2) |
(bit_decode(coder.bitcoder, CONTEXT_UNI) << 1) | (mq_bit_decode(coder.bitcoder, CONTEXT_UNI) << 1) |
bit_decode(coder.bitcoder, CONTEXT_UNI)) != 0x0A)) mq_bit_decode(coder.bitcoder, CONTEXT_UNI)) != 0x0A))
{ {
goto break_out; goto break_out;
} }
@ -2808,7 +2788,7 @@ decode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Free the entropy encoder structure. ! ! Free the entropy encoder structure. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
free_bit_encoder(&coder); free_mq_encoder(&coder);
} }
/************************************************************************************************************\ /************************************************************************************************************\

View file

@ -1,4 +1,4 @@
/*==================================================================================================================================*\ /*================================================================================================*\
|| || || ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ || || /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ || || | $$__ $$|__/ | $$ /$ | $$| $$ ||
@ -12,65 +12,38 @@
|| | $$$$$$/ | $$ || || | $$$$$$/ | $$ ||
|| \______/ |__/ || || \______/ |__/ ||
|| || || ||
|| FILE NAME: t2.c ||
|| ||
|| ||
|| DESCRIPTION: || || DESCRIPTION: ||
|| ------------ || || ------------ ||
|| DESCRIPTION NEEDED. ||
|| || || ||
|| FILE REFERENCES: || || 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 ||
|| Name I/O Description || || refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|| ---- --- ----------- ||
|| 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 || || 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 || || Redistribution and use in source and binary forms, with or without modification, are ||
|| following conditions are met: || || permitted provided that the following conditions are met: ||
|| || || ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of conditions and || || (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| the following disclaimer. || || conditions and the following disclaimer. ||
|| || || ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions || || (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| and the following disclaimer in the documentation and/or other materials provided with the || || of conditions and the following disclaimer in the documentation and/or other ||
|| distribution. || || materials provided with the distribution. ||
|| || || ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, || || THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE || || OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, || || MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR || || COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, || || EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE || || SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. || || 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. ||
|| || || ||
\*==================================================================================================================================*/ \*================================================================================================*/
/************************************************************************************************************\ /************************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ || || _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ || || | |\ | | | | | | \ |___ ||

View file

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

View file

@ -2845,9 +2845,9 @@ main(int argc,
if((temp != NULL) && (temp->count == 1)) if((temp != NULL) && (temp->count == 1))
{ {
if(strcmp(temp->lit_opt[0], "NONE")) if(strcmp(temp->lit_opt[0], "NONE"))
bwc_set_quantization_style(field, bwc_qt_none); bwc_set_quant_style(field, bwc_qt_none);
else 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"); temp = retrieve_arg(args, "quantisation_step_size");
if((temp != NULL) && (temp->count == 1)) 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]);
} }
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\