Compare commits

..

4 commits

9 changed files with 2061 additions and 1184 deletions

17
.gitignore vendored
View file

@ -2,6 +2,10 @@
# Prerequisites # Prerequisites
*.d *.d
# Data Files
*.bwc
*.eas
# Object files # Object files
*.o *.o
*.ko *.ko
@ -131,13 +135,9 @@ share/python-wheels/
MANIFEST MANIFEST
# Files and Archives # Files and Archives
*.eas .eas
*.npz .npz
*.zip .zip
*.bwc
# Profiling assets
valgrind-out.txt
# PyInstaller # PyInstaller
# Usually these files are written by a python script from a template # Usually these files are written by a python script from a template
@ -196,9 +196,6 @@ target/
profile_default/ profile_default/
ipython_config.py ipython_config.py
# vscode
.vscode
# pyenv # pyenv
# For a library or package, you might want to ignore these files since the code is # For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in: # intended to run in multiple environments; otherwise, check them in:

View file

@ -131,8 +131,7 @@ 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" OR "${OMP}") if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
message(STATUS "Enable OpenMP parallelization")
find_package(OpenMP) find_package(OpenMP)
if (OPENMP_FOUND) if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")

View file

@ -54,7 +54,6 @@
.PHONY: tool .PHONY: tool
.PHONY: profiling .PHONY: profiling
.PHONY: omp
.PHONY: eas3 .PHONY: eas3
.PHONY: netCDF .PHONY: netCDF
@ -81,8 +80,6 @@ BUILD_TOOL="False"
BUILD_PROF="False" BUILD_PROF="False"
BUILD_OMP="False"
BUILD_EAS3="False" BUILD_EAS3="False"
BUILD_NETCDF="False" BUILD_NETCDF="False"
@ -141,8 +138,6 @@ help:
@echo "" @echo ""
@echo " profiling Enable Profiling." @echo " profiling Enable Profiling."
@echo "" @echo ""
@echo " omp Enable OpenMP parallelization."
@echo ""
@echo " eas3 Adds support for the eas3 file format to the com-" @echo " eas3 Adds support for the eas3 file format to the com-"
@echo " mand line tool." @echo " mand line tool."
@echo "" @echo ""
@ -171,17 +166,11 @@ tool:
$(eval BUILD_TOOL="True") $(eval BUILD_TOOL="True")
#*--------------------------------------------------------*# #*--------------------------------------------------------*#
# Define target used to activate profiling. # # Define target used to activate command line tool build. #
#*--------------------------------------------------------*# #*--------------------------------------------------------*#
profiling: profiling:
$(eval BUILD_PROF="True") $(eval BUILD_PROF="True")
#*--------------------------------------------------------*#
# Define target used to activate OpenMP parallelization. #
#*--------------------------------------------------------*#
omp:
$(eval BUILD_OMP="True")
#*--------------------------------------------------------*# #*--------------------------------------------------------*#
# Define targets used to activate file format support. # # Define targets used to activate file format support. #
#*--------------------------------------------------------*# #*--------------------------------------------------------*#
@ -233,7 +222,7 @@ display:
# Define the main compile command targets. # # Define the main compile command targets. #
#*--------------------------------------------------------*# #*--------------------------------------------------------*#
build_bwc: build_bwc:
mkdir -p build && cd build && cmake .. "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" "-DLINK:STRING=${LINK_TYPE}" "-DPREC:STRING=${BUILD_PREC}" "-DTOOL=${BUILD_TOOL}" "-DPROF=${BUILD_PROF}" "-DOMP=${BUILD_OMP}" "-DBUILD_EAS3=${BUILD_EAS3}" "-DBUILD_NETCDF=${BUILD_NETCDF}" && $(MAKE) -j mkdir -p build && cd build && cmake .. "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" "-DLINK:STRING=${LINK_TYPE}" "-DPREC:STRING=${BUILD_PREC}" "-DTOOL=${BUILD_TOOL}" "-DPROF=${BUILD_PROF}" "-DBUILD_EAS3=${BUILD_EAS3}" "-DBUILD_NETCDF=${BUILD_NETCDF}" && $(MAKE) -j
clean: clean:
- /bin/rm -rf build/ bin/ lib/ lib64/ include/library/public - /bin/rm -rf build/ bin/ lib/ lib64/ include/library/public

View file

@ -0,0 +1,70 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| This file defines simple read and write functions used to access conforming ||
|| netCDF datasets. ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| of conditions and the following disclaimer in the documentation and/or other ||
|| materials provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ||
|| EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ||
|| ||
\*================================================================================================*/
#ifndef NETCDF_H
#define NETCDF_H
/************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\************************************************************************************************/
#include <bwc.h>
#include <stdio.h>
#include "utilities.h"
/************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\************************************************************************************************/
bwc_data* read_netCDF (char *const filename);
//==========|==========================|======================|======|=======|====================
uchar write_netCDF (bwc_data *const file,
char *const filename);
#endif

File diff suppressed because it is too large Load diff

896
src/library/codec.c Normal file
View file

@ -0,0 +1,896 @@
/*================================================================================================*\
|| ||
|| /$$$$$$$ /$$ /$$ /$$ /$$ ||
|| | $$__ $$|__/ | $$ /$ | $$| $$ ||
|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ ||
|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ ||
|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ ||
|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ ||
|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ ||
|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ ||
|| /$$ \ $$ | $$ ||
|| | $$$$$$/ | $$ ||
|| \______/ |__/ ||
|| ||
|| DESCRIPTION: ||
|| ------------ ||
|| ||
|| DESCRIPTION NEEDED. ||
|| | | ||
|| ||
|| -------------------------------------------------------------------------------------------- ||
|| Copyright (c) 2023, High Performance Computing Center - University of Stuttgart ||
|| ||
|| Redistribution and use in source and binary forms, with or without modification, are ||
|| permitted provided that the following conditions are met: ||
|| ||
|| (1) Redistributions of source code must retain the above copyright notice, this list of ||
|| conditions and the following disclaimer. ||
|| ||
|| (2) Redistributions in binary form must reproduce the above copyright notice, this list ||
|| of conditions and the following disclaimer in the documentation and/or other ||
|| materials provided with the distribution. ||
|| ||
|| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS ||
|| OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ||
|| MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ||
|| COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ||
|| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ||
|| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ||
|| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ||
|| TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ||
|| EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ||
|| ||
\*================================================================================================*/
/**************************************************************************************************\
|| _ _ _ ____ _ _ _ ___ ____ ||
|| | |\ | | | | | | \ |___ ||
|| | | \| |___ |___ |__| |__/ |___ ||
|| ||
\**************************************************************************************************/
/**************************************************************************************************\
|| ___ ____ _ _ _ ____ ___ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] |__/ | | | |__| | |___ |___ | | |\ | | | | | | |\ | [__ ||
|| | | \ | \/ | | | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\**************************************************************************************************/
/**************************************************************************************************\
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| ||
\**************************************************************************************************/
/*------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! DESCRIPTION NEEDED !
! | | !
! !
! RETURN: !
! ------- !
! !
! DESCRIPTION NEEDED !
! | | !
! !
\*------------------------------------------------------------------------------------------------*/
uchar
bwc_set_com(bwc_data *const data, char const *const com, uint16 size)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(data);
assert(com);
/*--------------------------------------------------------*\
! Save the global info structure to a temporary variable !
! to make the code more readable. !
\*--------------------------------------------------------*/
data->codestream.com->memory = calloc(size, sizeof(char));
if(!data->codestream.com->memory)
{
// memory allocation error
fprintf(stderr, MEMERROR);
return 1;
}
memcpy(data->codestream.com->memory, com, size * sizeof(char));
data->codestream.com->access = data->codestream.com->memory;
data->codestream.com->size = size;
data->codestream.com->position = 0;
return 0;
}
/*------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! DESCRIPTION NEEDED !
! | | !
! !
! RETURN: !
! ------- !
! !
! DESCRIPTION NEEDED !
! | | !
! !
\*------------------------------------------------------------------------------------------------*/
uchar
bwc_set_aux(bwc_data *const data, char const *const aux, uint32 size)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(data);
assert(aux);
/*--------------------------------------------------------*\
! Save the global info structure to a temporary variable !
! to make the code more readable. !
\*--------------------------------------------------------*/
data->codestream.com->memory = calloc(size, sizeof(char));
if(!data->codestream.com->memory)
{
// memory allocation error
fprintf(stderr, MEMERROR);
return 1;
}
memcpy(data->codestream.com->memory, aux, size * sizeof(char));
data->codestream.com->access = data->codestream.com->memory;
data->codestream.com->size = size;
data->codestream.com->position = 0;
return 0;
}
/*------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This function sets the error resilience marker in the bwc_field structure if an !
! error resilient compression approach is to be employed. !
! !
! RETURN: !
! ------- !
! !
! - !
! !
\*------------------------------------------------------------------------------------------------*/
void
bwc_set_error_resilience(bwc_field *const field)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(field);
/*--------------------------------------------------------*\
! Set the error resilience flag in the bwc_field structure !
! and record the setting in the CSsgc variable. !
\*--------------------------------------------------------*/
field->control.resilience ^= 0x01;
field->control.CSsgc ^= (0x01 << 0);
}
/*------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This function amends the quantization style in the bwc_field structure according !
! to the specified value. !
! !
! RETURN: !
! ------- !
! !
! - !
! !
\*------------------------------------------------------------------------------------------------*/
void
set_quant_style(bwc_field *const field,
bwc_quant_st const quantization_style)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(field);
assert((quantization_style == bwc_qt_derived) ||
(quantization_style == bwc_qt_none));
/*--------------------------------------------------------*\
! Amend the quantization style in the bwc_field structure !
! and record the setting in the CSsgc variable. !
\*--------------------------------------------------------*/
field->control.quantization_style = quantization_style;
field->control.CSsgc |= (0x01 << 1);
}
/*------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This function amends the quantization step size in the bwc_field structure !
! according to the specified value. !
! !
! RETURN: !
! ------- !
! !
! - !
! !
\*------------------------------------------------------------------------------------------------*/
void
set_quant_step_size(bwc_field *const field,
double delta)
{
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
bwc_gl_ctrl *control;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(field);
/*--------------------------------------------------------*\
! Save frequently used variables/structures to temporary !
! variables to make the code more readable. !
\*--------------------------------------------------------*/
control = &field->control;
/*--------------------------------------------------------*\
! Check if the quantization step size lies within the ac- !
! ceptable range. !
\*--------------------------------------------------------*/
if((delta <= 0) || (delta >= 2))
{
fprintf(stderr, "o==========================================================o\n"\
"| WARNING: Invalid quantization step size |\n"\
"| |\n"\
"| The quantization step size does not lie within |\n"\
"| the acceptable range of: |\n"\
"| |\n"\
"| 0 < step size < 2 |\n"\
"| |\n"\
"o==========================================================o\n");
return;
}
/*--------------------------------------------------------*\
! Reevaluate the mantissa and exponent of the user defined !
! quantization step size. !
\*--------------------------------------------------------*/
for(control->qt_exponent = 0; delta < 1; ++control->qt_exponent, delta *= 2);
control->qt_mantissa = (uint16)floor(0.5f + ((delta - 1.0f) * (1 << 16)));
if(control->qt_exponent > PREC_BIT)
{
control->qt_exponent = PREC_BIT;
control->qt_mantissa = 0;
}
if(control->qt_mantissa >= 1 << 16)
{
if(control->qt_exponent == 0)
{
control->qt_exponent = 0;
control->qt_mantissa = (1 << 16) - 1;
}
else
{
control->qt_exponent--;
control->qt_mantissa = 0;
}
}
/*--------------------------------------------------------*\
! Record the setting of the quantization step size in the !
! CSsgc variable. !
\*--------------------------------------------------------*/
control->CSsgc |= (0x01 << 2);
}
/*------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This function amends the progression order in the bwc_field structure according !
! to the specified value. !
! !
! RETURN: !
! ------- !
! !
! - !
! !
\*------------------------------------------------------------------------------------------------*/
void
set_progression(bwc_field *const field,
bwc_prog_ord const progression)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(field);
assert((progression == bwc_prog_CPRL) || (progression == bwc_prog_LRCP) ||
(progression == bwc_prog_PCRL) || (progression == bwc_prog_RLCP) ||
(progression == bwc_prog_RPCL));
/*--------------------------------------------------------*\
! Set the progression order in the bwc_field structure and !
! record the setting in the CSsgc variable. !
\*--------------------------------------------------------*/
field->control.progression = progression;
field->control.CSsgc |= (0x01 << 3);
}
/*------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This function amends the wavelet kernels in the bwc_field structure according !
! to the specified values. !
! !
! RETURN: !
! ------- !
! !
! - !
! !
\*------------------------------------------------------------------------------------------------*/
void
set_kernels(bwc_field *const field,
bwc_dwt_filter const KernelX,
bwc_dwt_filter const KernelY,
bwc_dwt_filter const KernelZ,
bwc_dwt_filter const KernelTS)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(field);
/*--------------------------------------------------------*\
! Set the wavelet kernel in the bwc_field structure and !
! record the setting in the CSsgc variable. !
\*--------------------------------------------------------*/
field->control.KernelX = KernelX ? KernelX : bwc_dwt_9_7;
field->control.KernelY = KernelY ? KernelY : bwc_dwt_9_7;
field->control.KernelZ = KernelZ ? KernelZ : bwc_dwt_9_7;
field->control.KernelTS = KernelTS ? KernelTS : bwc_dwt_haar;
field->control.CSsgc |= (0x01 << 4);
}
/*------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This function amends the decomposition levels in the bwc_field structure !
! according to the specified values. !
! !
! RETURN: !
! ------- !
! !
! - !
! !
\*------------------------------------------------------------------------------------------------*/
void
bwc_set_decomp(bwc_field *const field,
uint8 const decompX,
uint8 const decompY,
uint8 const decompZ,
uint8 const decompTS)
{
/*-----------------------*\
! DEFINE FLOAT VARIABLES: !
\*-----------------------*/
double delta;
/*-----------------------*\
! DEFINE CHAR VARIABLES: !
\*-----------------------*/
uint8 levelsX, levelsY, levelsZ, levelsTS;
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
bwc_gl_ctrl *control;
bwc_gl_inf *info;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(field);
/*--------------------------------------------------------*\
! Save frequently used variables/structures to temporary !
! variables to make the code more readable. !
\*--------------------------------------------------------*/
control = &field->control;
info = field->info;
/*--------------------------------------------------------*\
! Calculate the maximum posssible decorrelations and eval- !
! uate the number of decomposition levels accordingly. !
\*--------------------------------------------------------*/
levelsX = log(info->nX) /log(2);
levelsY = log(info->nY) /log(2);
levelsZ = log(info->nZ) /log(2);
levelsTS = log(info->nTS)/log(2);
control->decompX = (info->nX >> 1) ? ((decompX < levelsX) ? decompX : levelsX) : 0;
control->decompY = (info->nY >> 1) ? ((decompY < levelsY) ? decompY : levelsY) : 0;
control->decompZ = (info->nZ >> 1) ? ((decompZ < levelsZ) ? decompZ : levelsZ) : 0;
control->decompTS = (info->nTS >> 1) ? ((decompTS < levelsTS) ? decompTS : levelsTS) : 0;
control->nDecomp = MAX(control->decompX,
MAX(control->decompY,
MAX(control->decompZ, control->decompTS)));
/*--------------------------------------------------------*\
! Check validity of decomp levels and, if necessary, reset !
! them to teir standard values. !
\*--------------------------------------------------------*/
if((control->decompX > 63) || (control->decompY > 63) ||
(control->decompZ > 63) || (control->decompTS > 31))
{
fprintf(stderr, "o==========================================================o\n"\
"| WARNING: Invalid decomposition level value |\n"\
"| |\n"\
"| The maximum acceptable decomposition level is |\n"\
"| 63 for all spatial and 31 for the temporal |\n"\
"| dimensions. |\n"\
"| |\n"\
"o==========================================================o\n");
control->decompX = (info->nX >> 1) ? 4 : 0;
control->decompY = (info->nY >> 1) ? 4 : 0;
control->decompZ = (info->nZ >> 1) ? 4 : 0;
control->decompTS = (info->nTS >> 1) ? 4 : 0;
return;
}
/*--------------------------------------------------------*\
! Record the setting of the decomposition level variables !
! in the CSsgc variable. !
\*--------------------------------------------------------*/
control->CSsgc |= (0x01 << 5);
}
/*------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This function amends the precinct size in the bwc_field structure according !
! to the specified values. !
! !
! RETURN: !
! ------- !
! !
! - !
! !
\*------------------------------------------------------------------------------------------------*/
void
bwc_set_precincts(bwc_field *const field,
uint8 const pX,
uint8 const pY,
uint8 const pZ,
uint8 const pTS)
{
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
bwc_gl_ctrl *control;
bwc_gl_inf *info;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(field);
/*--------------------------------------------------------*\
! Save frequently used variables/structures to temporary !
! variables to make the code more readable. !
\*--------------------------------------------------------*/
control = &field->control;
info = field->info;
/*--------------------------------------------------------*\
! Set the specified precinct values for all valid dimen- !
! sions taking the maximum allowable size into account. !
\*--------------------------------------------------------*/
control->precSizeX = (info->nX >> 1) ? (pX ? pX : 15) : 0;
control->precSizeY = (info->nY >> 1) ? (pY ? pY : 15) : 0;
control->precSizeZ = (info->nZ >> 1) ? (pZ ? pZ : 15) : 0;
control->precSizeTS = (info->nTS >> 1) ? (pTS ? pTS : 15) : 0;
/*--------------------------------------------------------*\
! Check validity of the precint size and reset them, if !
! necessary to teir standard values. !
\*--------------------------------------------------------*/
if(((control->precSizeX < 1) && (info->nX >> 1)) ||
((control->precSizeY < 1) && (info->nY >> 1)) ||
((control->precSizeZ < 1) && (info->nZ >> 1)) ||
((control->precSizeTS < 1) && (info->nTS >> 1)) ||
(control->precSizeX > 15) || (control->precSizeY > 15) ||
(control->precSizeZ > 15) || (control->precSizeTS > 15))
{
fprintf(stderr, "o==========================================================o\n"\
"| WARNING: Invalid precinct size |\n"\
"| |\n"\
"| The maximum acceptable precinct size is 2^15, |\n"\
"| the smallest valid precinct size is 2^1. |\n"\
"| |\n"\
"o==========================================================o\n");
control->precSizeX = (info->nX >> 1) ? 15 : 0;
control->precSizeY = (info->nY >> 1) ? 15 : 0;
control->precSizeZ = (info->nZ >> 1) ? 15 : 0;
control->precSizeTS = (info->nTS >> 1) ? 15 : 0;
return;
}
/*--------------------------------------------------------*\
! Record the setting of the precinct size variables in the !
! CSsgc variable. !
\*--------------------------------------------------------*/
control->CSsgc |= (0x01 << 6);
}
/*------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This function amends the codeblock size in the bwc_field structure according !
! to the specified values. !
! !
! RETURN: !
! ------- !
! !
! - !
! !
\*------------------------------------------------------------------------------------------------*/
void
bwc_set_codeblocks(bwc_field *const field,
uint8 const cbX,
uint8 const cbY,
uint8 const cbZ,
uint8 const cbTS)
{
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
bwc_gl_ctrl *control;
bwc_gl_inf *info;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(field);
/*--------------------------------------------------------*\
! Save frequently used variables/structures to temporary !
! variables to make the code more readable. !
\*--------------------------------------------------------*/
control = &field->control;
info = field->info;
/*--------------------------------------------------------*\
! Set the specified codeblock values for all valid dimen- !
! sions taking the maximum allowable size into account. !
\*--------------------------------------------------------*/
control->cbX = (info->nX >> 1) ? (cbX ? cbX : 5) : 0;
control->cbY = (info->nY >> 1) ? (cbY ? cbY : 5) : 0;
control->cbZ = (info->nZ >> 1) ? (cbZ ? cbZ : 5) : 0;
control->cbTS = (info->nTS >> 1) ? (cbTS ? cbTS : 5) : 0;
/*--------------------------------------------------------*\
! Check validity of the codeblock size and reset them, if !
! necessary to teir standard values. !
\*--------------------------------------------------------*/
if((control->cbX > 10) || (control->cbY > 10) || (control->cbZ > 10) || (control->cbTS > 10)||
((control->cbX + control->cbY + control->cbZ + control->cbTS) < 4) ||
((control->cbX + control->cbY + control->cbZ + control->cbTS) > 20))
{
fprintf(stderr, "o==========================================================o\n"\
"| WARNING: Invalid codeblock size |\n"\
"| |\n"\
"| The maximum acceptable codeblock size is 2^20 |\n"\
"| with a maximum allowable number of datapoints |\n"\
"| in each dimension of 2^10. The smallest valid |\n"\
"| codeblock size is 2^4. |\n"\
"| |\n"\
"o==========================================================o\n");
control->cbX = (info->nX >> 1) ? 5 : 0;
control->cbY = (info->nY >> 1) ? 5 : 0;
control->cbZ = (info->nZ >> 1) ? 5 : 0;
control->cbTS = (info->nTS >> 1) ? 5 : 0;
return;
}
/*--------------------------------------------------------*\
! Record the setting of the codeblock size variables in !
! the CSsgc variable. !
\*--------------------------------------------------------*/
control->CSsgc |= (0x01 << 7);
}
/*------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This function amends the Q number formate range in the bwc_field structure !
! according to the specified value. !
! !
! RETURN: !
! ------- !
! !
! - !
! !
\*------------------------------------------------------------------------------------------------*/
void
bwc_set_qm(bwc_field *const field,
uint8 const Qm)
{
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(field);
/*--------------------------------------------------------*\
! Check validity of the specified Qm ammend its value and !
! the CSsgc flag accordingly. !
\*--------------------------------------------------------*/
if((int8)(PREC_BIT - Qm) < 1)
{
fprintf(stderr, "o==========================================================o\n"\
"| WARNING: Invalid Q number formate range |\n"\
"| |\n"\
"| The specified Q number formate range is larger |\n");
#ifdef BWC_SINGLE_PRECISION
fprintf(stderr, "| than the permitted 30 bits. |\n");
#else
fprintf(stderr, "| than the permitted 62 bits. |\n");
#endif
fprintf(stderr, "| |\n"\
"o==========================================================o\n");
}
else
{
control->Qm = Qm;
control->CSsgc |= (0x01 << 8);
}
}
/*------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! !
! This function amends the tileSize and num_Tiles values in the bwc_field struc- !
! ture 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. !
! !
! RETURN: !
! ------- !
! !
! - !
! !
\*------------------------------------------------------------------------------------------------*/
void
bwc_set_tiles(bwc_field *const field,
uint64 const *const tilesX,
uint64 const *const tilesY,
uint64 const *const tilesZ,
uint16 const *const tilesTS,
bwc_tile_instr const instr)
{
/*-----------------------*\
! DEFINE INT VARIABLES: !
\*-----------------------*/
uint64 num_tiles_X, num_tiles_Y, num_tiles_Z;
uint16 num_tiles_TS;
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
bwc_gl_ctrl *control;
bwc_gl_inf *info;
/*-----------------------*\
! DEFINE ASSERTIONS: !
\*-----------------------*/
assert(field);
assert(instr == bwc_tile_sizeof || instr == bwc_tile_numbof);
/*--------------------------------------------------------*\
! Save the global control and info structure to temporary !
! variables to make the code more readable. !
\*--------------------------------------------------------*/
control = &field->control;
info = field->info;
/*--------------------------------------------------------*\
! Check if the size of one tile or the overall number of !
! tiles are defined. !
\*--------------------------------------------------------*/
if(instr == bwc_tile_sizeof)
{
/*--------------------------------------------------------*\
! Check if the tile sizes have valid values. !
\*--------------------------------------------------------*/
if((control->tileSizeX < 16 && control->tileSizeX > info->nX)||
(control->tileSizeY < 16 && control->tileSizeY > info->nY)||
(control->tileSizeZ < 16 && control->tileSizeZ > info->nZ)||
(control->tileSizeTS < 16 && control->tileSizeTS > info->nTS))
{
fprintf(stderr,"o==========================================================o\n"\
"| WARNING: Invalid Tile Dimensions |\n"\
"| |\n"\
"| One or more of the specified tile dimensions |\n"\
"| has a value that falls outside of its valid |\n"\
"| range. Please verify that all tile dimension |\n"\
"| are within the range of: |\n"\
"| |\n"\
"| 16 ≤ Tile_Size_Xi ≤ Grid_Points_Xi |\n"\
"| |\n"\
"o==========================================================o\n");
return;
}
/*--------------------------------------------------------*\
! Check if the tile dimensions are specified for a valid !
! spatial or temporal dimension. All invalid and unspeci- !
! fied (NULL) values are set to the maximum allowable tile !
! size. !
\*--------------------------------------------------------*/
control->tileSizeX = (info->nX >> 1) ? (tilesX ? tilesX : info->nX) : info->nX;
control->tileSizeY = (info->nY >> 1) ? (tilesY ? tilesY : info->nY) : info->nY;
control->tileSizeZ = (info->nZ >> 1) ? (tilesZ ? tilesZ : info->nZ) : info->nZ;
control->tileSizeTS = (info->nTS >> 1) ? (tilesTS ? tilesTS : info->nTS) : info->nTS;
/*--------------------------------------------------------*\
! Calculate the number of tiles in all spatial and tempo- !
! ral directions and the overall number of tiles. !
\*--------------------------------------------------------*/
num_tiles_X = (uint64)ceil(((float)info->nX / control->tileSizeX));
num_tiles_Y = (uint64)ceil(((float)info->nY / control->tileSizeY));
num_tiles_Z = (uint64)ceil(((float)info->nZ / control->tileSizeZ));
num_tiles_TS = (uint16)ceil(((float)info->nTS/ control->tileSizeTS));
control->nTiles = num_tiles_X * num_tiles_Y * num_tiles_Z * num_tiles_TS;
/*--------------------------------------------------------*\
! Check if the number of tiles exceeds its maximum allowa- !
! ble value. !
\*--------------------------------------------------------*/
if(((double)num_tiles_X * num_tiles_Y * num_tiles_Z * num_tiles_TS) > 0xFFFFFFFFFFFFFFFF)
{
fprintf(stderr,"o==========================================================o\n"\
"| WARNING: Invalid Tile Dimensions |\n"\
"| |\n"\
"| The number of tiles exceeds its maxmum allowa- |\n"\
"| ble value. Please adjust all tile dimension so |\n"\
"| that the number of tiles falls within the range |\n"\
"| of: |\n"\
"| Number_of_Tiles < 2^64 |\n"\
"| |\n"\
"o==========================================================o\n");
/*--------------------------------------------------------*\
! Reset the tile sizes to their standard values. !
\*--------------------------------------------------------*/
control->tileSizeX = info->nX;
control->tileSizeY = info->nY;
control->tileSizeZ = info->nZ;
control->tileSizeTS = info->nTS;
return;
}
}
else if(bwc_tile_numbof)
{
/*--------------------------------------------------------*\
! Check if the number of tiles exceeds its maximum allowa- !
! ble value. !
\*--------------------------------------------------------*/
if(((double)tilesX * tilesY * tilesZ * tilesTS) > 0xFFFFFFFFFFFFFFFF)
{
fprintf(stderr,"o==========================================================o\n"\
"| WARNING: Invalid Number Of Tiles |\n"\
"| |\n"\
"| The number of tiles exceeds its maxmum allowa- |\n"\
"| ble value of: |\n"\
"| |\n"\
"| Number_of_Tiles < 2^64 |\n"\
"| |\n"\
"o==========================================================o\n");
return;
}
/*--------------------------------------------------------*\
! Check if the number of tiles are specified for a valid !
! spatial or temporal dimension. For all invalid and un- !
! specified (NULL) values the corresponding tile size is !
! set to its maximum allowable value. For all valid values !
! the tile sizes are calculated accordingly. !
\*--------------------------------------------------------*/
control->tileSizeX = (info->nX >> 1) ? (tilesX ? (uint64)ceil(((float)info->nX / tilesX)) : info->nX) : info->nX;
control->tileSizeY = (info->nY >> 1) ? (tilesY ? (uint64)ceil(((float)info->nY / tilesY)) : info->nY) : info->nY;
control->tileSizeZ = (info->nZ >> 1) ? (tilesZ ? (uint64)ceil(((float)info->nZ / tilesZ)) : info->nZ) : info->nZ;
control->tileSizeTS = (info->nTS >> 1) ? (tilesTS ? (uint16)ceil(((float)info->nTS/ tilesTS)) : info->nTS) : info->nTS;
/*--------------------------------------------------------*\
! Check if the tile sizes have valid values. !
\*--------------------------------------------------------*/
if((control->tileSizeX < 16 && control->tileSizeX > info->nX)||
(control->tileSizeY < 16 && control->tileSizeY > info->nY)||
(control->tileSizeZ < 16 && control->tileSizeZ > info->nZ)||
(control->tileSizeTS < 16 && control->tileSizeTS > info->nTS))
{
fprintf(stderr,"o==========================================================o\n"\
"| WARNING: Invalid Number Of Tiles |\n"\
"| |\n"\
"| One or more of the tile dimensions has a value |\n"\
"| that falls outside of its valid range. Please |\n"\
"| verify that the number of tiles for all dimen- |\n"\
"| sions are set so that the corresponding tile |\n"\
"| sizes fall within the range of: |\n"\
"| |\n"\
"| 16 ≤ Tile_Size_Xi ≤ Grid_Points_Xi |\n"\
"| |\n"\
"o==========================================================o\n");
/*--------------------------------------------------------*\
! Reset the tile sizes to their standard values. !
\*--------------------------------------------------------*/
control->tileSizeX = info->nX;
control->tileSizeY = info->nY;
control->tileSizeZ = info->nZ;
control->tileSizeTS = info->nTS;
return;
}
/*--------------------------------------------------------*\
! Reevaluate the number of tiles in all spatial and tempo- !
! ral directions and the overall number of tiles. !
\*--------------------------------------------------------*/
num_tiles_X = (uint64)ceil(((float)info->nX / control->tileSizeX));
num_tiles_Y = (uint64)ceil(((float)info->nY / control->tileSizeY));
num_tiles_Z = (uint64)ceil(((float)info->nZ / control->tileSizeZ));
num_tiles_TS = (uint16)ceil(((float)info->nTS/ control->tileSizeTS));
control->nTiles = num_tiles_X * num_tiles_Y * num_tiles_Z * num_tiles_TS;
}
/*--------------------------------------------------------*\
! Record the setting of the tile size variables in the !
! CSsgc variable. !
\*--------------------------------------------------------*/
control->CSsgc |= (0x01 << 9);
}

View file

@ -1624,22 +1624,18 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter
uint64 rX1, rY1, rZ1; uint64 rX1, rY1, rZ1;
uint64 width, height, depth; uint64 width, height, depth;
uint64 x, y, z; uint64 x, y, z;
int64 nThreads;
int16 i;
uint32 buff_size; uint32 buff_size;
int16 i;
uint16 incr_TS; uint16 incr_TS;
uint16 rTS0; uint16 rTS0;
uint16 rTS1; uint16 rTS1;
uint16 dt; uint16 dt;
uint16 t; uint16 t;
uint8 id; uint8 id;
uint8 filter_tapsX, filter_tapsY, filter_tapsZ; uint8 filter_tapsX, filter_tapsY, filter_tapsZ;
uint8 filter_tapsTS; uint8 filter_tapsTS;
uint8 level; uint8 level;
uint8 nThreads;
/*-----------------------*\ /*-----------------------*\
! DEFINE STRUCTS: ! ! DEFINE STRUCTS: !
@ -2165,22 +2161,18 @@ inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter
uint64 rX1, rY1, rZ1; uint64 rX1, rY1, rZ1;
uint64 width, height, depth; uint64 width, height, depth;
uint64 x, y, z; uint64 x, y, z;
int64 nThreads;
int64 i;
uint32 buff_size; uint32 buff_size;
int16 i;
uint16 incr_TS; uint16 incr_TS;
uint16 rTS0; uint16 rTS0;
uint16 rTS1; uint16 rTS1;
uint16 dt; uint16 dt;
uint16 t; uint16 t;
uint8 id; uint8 id;
uint8 filter_tapsX, filter_tapsY, filter_tapsZ; uint8 filter_tapsX, filter_tapsY, filter_tapsZ;
uint8 filter_tapsTS; uint8 filter_tapsTS;
uint8 level; uint8 level;
uint8 nThreads;
/*-----------------------*\ /*-----------------------*\
! DEFINE STRUCTS: ! ! DEFINE STRUCTS: !

File diff suppressed because it is too large Load diff

View file

@ -2836,14 +2836,12 @@ t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par
uint64 c; uint64 c;
uint64 cbSizeX, cbSizeY, cbSizeZ; uint64 cbSizeX, cbSizeY, cbSizeZ;
uint64 width, height, depth; uint64 width, height, depth;
int64 buff_size; int64 buff_size;
int64 i, j; int64 j;
int64 nThreads;
uint16 cbSizeTS; uint16 cbSizeTS;
uint16 slope_max, slope_min; uint16 slope_max, slope_min;
int16 z; int16 i, z;
uint8 nThreads;
/*-----------------------*\ /*-----------------------*\
! DEFINE STRUCTS: ! ! DEFINE STRUCTS: !
@ -2923,7 +2921,7 @@ t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par
! threads during a parallel run. For a serial run only one ! ! threads during a parallel run. For a serial run only one !
! working buffer is allocated. ! ! working buffer is allocated. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
for(i = 0; i < (int64)nThreads; ++i) for(i = 0; i < nThreads; ++i)
{ {
memory[i] = calloc(buff_size, sizeof(bwc_coder_stripe)); memory[i] = calloc(buff_size, sizeof(bwc_coder_stripe));
if(!memory[i]) if(!memory[i])
@ -3139,12 +3137,11 @@ t1_decode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par
uint64 c; uint64 c;
uint64 cbSizeX, cbSizeY, cbSizeZ; uint64 cbSizeX, cbSizeY, cbSizeZ;
uint64 width, height, depth; uint64 width, height, depth;
int64 buff_size; int64 buff_size;
int64 i, j; int64 j;
int64 nThreads;
uint16 cbSizeTS; uint16 cbSizeTS;
int16 i;
uint8 nThreads;
/*-----------------------*\ /*-----------------------*\
! DEFINE STRUCTS: ! ! DEFINE STRUCTS: !
@ -3217,7 +3214,7 @@ t1_decode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par
! threads during a parallel run. For a serial run only one ! ! threads during a parallel run. For a serial run only one !
! working buffer is allocated. ! ! working buffer is allocated. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
for(i = 0; i < (int64)nThreads; ++i) for(i = 0; i < nThreads; ++i)
{ {
memory[i] = calloc(buff_size, sizeof(bwc_coder_stripe)); memory[i] = calloc(buff_size, sizeof(bwc_coder_stripe));
if(!memory[i]) if(!memory[i])