From bbbb6117a9b033e5b53d3b359cf91d7c28b4245e Mon Sep 17 00:00:00 2001 From: Patrick Vogler Date: Thu, 27 Jun 2024 14:47:10 +0200 Subject: [PATCH] Preliminary split of libbwc.c in libbwc.c and codec.c. The new codec.c source file will contain all functions that create or modify the bwc_codec struct --- src/library/codec.c | 915 ++++++++++++++++++++++++++++++++++ src/library/libbwc.c | 1132 ------------------------------------------ 2 files changed, 915 insertions(+), 1132 deletions(-) create mode 100644 src/library/codec.c diff --git a/src/library/codec.c b/src/library/codec.c new file mode 100644 index 0000000..11104c7 --- /dev/null +++ b/src/library/codec.c @@ -0,0 +1,915 @@ +/*================================================================================================*\ +|| || +|| /$$$$$$$ /$$ /$$ /$$ /$$ || +|| | $$__ $$|__/ | $$ /$ | $$| $$ || +|| | $$ \ $$ /$$ /$$$$$$ | $$ /$$$| $$| $$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ || +|| | $$$$$$$ | $$ /$$__ $$ | $$/$$ $$ $$| $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ || +|| | $$__ $$| $$| $$ \ $$ | $$$$_ $$$$| $$ \ $$| $$ \ $$| $$ \ $$| $$ \ $$ || +|| | $$ \ $$| $$| $$ | $$ | $$$/ \ $$$| $$ | $$| $$ | $$| $$ | $$| $$ | $$ || +|| | $$$$$$$/| $$| $$$$$$$ | $$/ \ $$| $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$/ || +|| |_______/ |__/ \____ $$ |__/ \__/|__/ |__/ \______/ \______/ | $$____/ || +|| /$$ \ $$ | $$ || +|| | $$$$$$/ | $$ || +|| \______/ |__/ || +|| || +|| 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); + } +} + +/*----------------------------------------------------------------------------------------------------------*\ +! 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. ! +! ! +! PARAMETERS: ! +! ----------- ! +! Variable Type Description ! +! -------- ---- ----------- ! +! field bwc_field* - Structure defining the compression/ ! +! decompression stage. ! +! ! +! tilesX, tilesY, tilesZ unsigned int(32 bit) - Variables defining the size of ! +! a spatial tile. ! +! ! +! tilesTS unsigned int(32 bit) - Variables defining the size of ! +! a temporal tile. ! +! ! +! instr bwc_tile_instr - Constants used to instruct the ! +! bwc_set_tiles function. ! +! ! +! RETURN VALUE: ! +! ------------- ! +! Type Description ! +! ---- ----------- ! +! - - ! +! ! +! DEVELOPMENT HISTORY: ! +! -------------------- ! +! ! +! Date Author Change Id Release Description Of Change ! +! ---- ------ --------- ------- --------------------- ! +! 14.03.2018 Patrick Vogler B87D120 V 0.1.0 function created ! +! ! +\*----------------------------------------------------------------------------------------------------------*/ +void +bwc_set_tiles(bwc_field *const field, uint64 tilesX, uint64 tilesY, uint64 tilesZ, uint16 tilesTS, bwc_tile_instr 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); +} diff --git a/src/library/libbwc.c b/src/library/libbwc.c index 80f602e..f9478bf 100755 --- a/src/library/libbwc.c +++ b/src/library/libbwc.c @@ -1587,82 +1587,6 @@ bwc_add_param(bwc_data* data, char *name, uint8 precision) info->parameter->size = (info->nX * info->nY * info->nZ * info->nTS); } -/*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: ! -! -------------- ! -! ! -! ! -! DESCRIPTION: ! -! ------------ ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -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; -} - -/*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: ! -! -------------- ! -! ! -! ! -! DESCRIPTION: ! -! ------------ ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -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; -} - /*----------------------------------------------------------------------------------------------------------*\ ! FUNCTION NAME: bwc_field *bwc_initialize_data(...) ! ! -------------- ! @@ -2552,1062 +2476,6 @@ bwc_initialize_field(bwc_data *const data) return field; } -/*----------------------------------------------------------------------------------------------------------*\ -! 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. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 13.06.2018 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -void -bwc_set_error_resilience(bwc_field *const field) -{ - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_ctrl *control; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(field); - - /*--------------------------------------------------------*\ - ! Save the global control structure to a temporary varia- ! - ! ble to make the code more readable. ! - \*--------------------------------------------------------*/ - control = &field->control; - - /*--------------------------------------------------------*\ - ! Amend the codeblock style in the bwc_field structure ! - ! according to the specified value. ! - \*--------------------------------------------------------*/ - control->error_resilience ^= 0x01; - - /*--------------------------------------------------------*\ - ! Record the setting of the error resilience marker in the ! - ! CSsgc variable. ! - \*--------------------------------------------------------*/ - control->CSsgc ^= (0x01 << 0); -} - -/*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_quant_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. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! quantization_style bwc_quant_st - Quantization style used during compres- ! -! sion. ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 15.03.2018 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -void -set_quant_style(bwc_field *const field, bwc_quant_st quantization_style) -{ - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_ctrl *control; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(field); - assert((quantization_style == bwc_qt_derived) || (quantization_style == bwc_qt_none)); - - /*--------------------------------------------------------*\ - ! Save the global control structure to a temporary varia- ! - ! ble to make the code more readable. ! - \*--------------------------------------------------------*/ - control = &field->control; - - /*--------------------------------------------------------*\ - ! Amend the quantization style in the bwc_field structure ! - ! according to the specified value. ! - \*--------------------------------------------------------*/ - control->quantization_style = quantization_style; - - /*--------------------------------------------------------*\ - ! Record the setting of the quantization style marker in ! - ! the CSsgc variable. ! - \*--------------------------------------------------------*/ - control->CSsgc |= (0x01 << 1); -} - -/*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_quant_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. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! delta double - Quantization step size used during ! -! compression. ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 16.04.2019 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -void -set_quant_step_size(bwc_field *const field, double delta) -{ - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_ctrl *control; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(field); - - /*--------------------------------------------------------*\ - ! Save the global control structure to a temporary varia- ! - ! ble 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); -} - -/*----------------------------------------------------------------------------------------------------------*\ -! 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. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! progression bwc_prog_ord - Progression orders employed during com- ! -! pression (CPRL, LRCP, PCRL, RLCP, ! -! RPCL). ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 15.03.2018 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -void -set_progression(bwc_field *const field, bwc_prog_ord progression) -{ - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_ctrl *control; - - /*-----------------------*\ - ! 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)); - - /*--------------------------------------------------------*\ - ! Save the global control structure to a temporary varia- ! - ! ble to make the code more readable. ! - \*--------------------------------------------------------*/ - control = &field->control; - - /*--------------------------------------------------------*\ - ! Amend the progression order in the bwc_field structure ! - ! according to the specified value. ! - \*--------------------------------------------------------*/ - control->progression = progression; - - /*--------------------------------------------------------*\ - ! Record the setting of the progression order marker in ! - ! the CSsgc variable. ! - \*--------------------------------------------------------*/ - control->CSsgc |= (0x01 << 3); -} - -/*----------------------------------------------------------------------------------------------------------*\ -! 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. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! KernelX, KernelY, KernelZ bwc_dwt_filter - Wavelet kernels used for spatial ! -! decomposition. ! -! ! -! KernelT bwc_dwt_filter - Wavelet kernel used for temporal ! -! decomposition. ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 15.03.2018 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -void -set_kernels(bwc_field *const field, bwc_dwt_filter KernelX, bwc_dwt_filter KernelY, - bwc_dwt_filter KernelZ, bwc_dwt_filter KernelTS) -{ - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_ctrl *control; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(field); - - /*--------------------------------------------------------*\ - ! Save the global control structure to a temporary varia- ! - ! ble to make the code more readable. ! - \*--------------------------------------------------------*/ - control = &field->control; - - /*--------------------------------------------------------*\ - ! Amend the wavelet kernels in the bwc_field structure ac- ! - ! cording to the specified values. For all unspecified ! - ! (NULL) values the corresponding wavelet kernel is set to ! - ! bwc_dwt_9_7/bwc_dwt_haar. ! - \*--------------------------------------------------------*/ - control->KernelX = KernelX ? KernelX : bwc_dwt_9_7; - control->KernelY = KernelY ? KernelY : bwc_dwt_9_7; - control->KernelZ = KernelZ ? KernelZ : bwc_dwt_9_7; - control->KernelTS = KernelTS ? KernelTS : bwc_dwt_haar; - - /*--------------------------------------------------------*\ - ! Record the setting of the wavelet kernel order markers ! - ! in the CSsgc variable. ! - \*--------------------------------------------------------*/ - control->CSsgc |= (0x01 << 4); -} - -/*----------------------------------------------------------------------------------------------------------*\ -! 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. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! decompX, decompY, decompZ unsigned int(8 bit) - Number of spatial wavelet decomposition ! -! levels used during compression. ! -! ! -! decompTS unsigned int(8 bit) - Number of temporal wavelet decomposi- ! -! tion level used during compression. ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 14.03.2018 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -void -bwc_set_decomp(bwc_field *const field, uint8 decompX, uint8 decompY, uint8 decompZ, uint8 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 the global control and info structure to temporary ! - ! variables to make the code more readable. ! - \*--------------------------------------------------------*/ - control = &field->control; - info = field->info; - - /*--------------------------------------------------------*\ - ! Calculate the possible decomposition levels for all ! - ! spatial and temporal dimensions. ! - \*--------------------------------------------------------*/ - levelsX = log(info->nX) /log(2); - levelsY = log(info->nY) /log(2); - levelsZ = log(info->nZ) /log(2); - levelsTS = log(info->nTS)/log(2); - - /*--------------------------------------------------------*\ - ! Check if the decomposition levels are specified for a ! - ! valid spatial or temporal dimension. For all invalid and ! - ! unspecified (NULL) values the corresponding decomposi- ! - ! tion level is set to 0. For all valid dimensions the ! - ! number of decompositions is set accordingly. ! - \*--------------------------------------------------------*/ - 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; - - /*--------------------------------------------------------*\ - ! Calculate the overall number of decomposition levels. ! - \*--------------------------------------------------------*/ - control->nDecomp = MAX(control->decompX, - MAX(control->decompY, - MAX(control->decompZ, control->decompTS))); - - /*--------------------------------------------------------*\ - ! Check if the decomposition levels have valid 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"); - - /*--------------------------------------------------------*\ - ! Reset the decomposition levels to their standard values. ! - \*--------------------------------------------------------*/ - 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; - } - - /*--------------------------------------------------------*\ - ! Initialize the lookup tables used to calculate the ener- ! - ! gy gain for the multi dimensional wavelet transforms. ! - \*--------------------------------------------------------*/ - if(initialize_gain_lut()) - { - bwc_kill_compression(field); - return; - } - - /*--------------------------------------------------------*\ - ! Calculate the appropriate quantization step size for the ! - ! given number of decomposition levels according to equa- ! - ! tion (10.19) (epsilon = 6, mu = 16) from JPEG2000 by ! - ! by David S. Taubman and Michael W. Marcellin (p.437). ! - \*--------------------------------------------------------*/ - delta = 1/(pow(2, 2 + PREC_BIT) * sqrt(get_dwt_energy_gain(field, 0, control->nDecomp))); - - 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 decomposition level variables ! - ! in the CSsgc variable. ! - \*--------------------------------------------------------*/ - control->CSsgc |= (0x01 << 5); -} - -/*----------------------------------------------------------------------------------------------------------*\ -! 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. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! px, py, pz, pTS unsigned int(8 bit) - Spatial and temporal precinct dimensions! -! in log2 exponent format. ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 15.05.2018 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -void -bwc_set_precincts(bwc_field *const field, uint8 pX, uint8 pY, uint8 pZ, uint8 pTS) -{ - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_ctrl *control; - bwc_gl_inf *info; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(field); - - /*--------------------------------------------------------*\ - ! 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 precinct sizes are specified for a valid ! - ! spatial or temporal dimension. For all invalid and un- ! - ! specified (NULL) values the corresponding precinct size ! - ! is set to 0. For all valid dimensions the precinct size ! - ! is set accordingly. ! - \*--------------------------------------------------------*/ - 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 if the codeblock sizes have valid 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"); - - /*--------------------------------------------------------*\ - ! Reset the codeblock sizes to their standard values. ! - \*--------------------------------------------------------*/ - 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); -} - -/*----------------------------------------------------------------------------------------------------------*\ -! 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. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! cbx, cby, cbz, cbTS unsigned int(8 bit) - Spatial and temporal codeblock dimen- ! -! sions in log2 exponent format. ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 14.03.2018 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -void -bwc_set_codeblocks(bwc_field *const field, uint8 cbX, uint8 cbY, uint8 cbZ, uint8 cbTS) -{ - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_ctrl *control; - bwc_gl_inf *info; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(field); - - /*--------------------------------------------------------*\ - ! 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 codeblock sizes are specified for a valid ! - ! spatial or temporal dimension. For all invalid and un- ! - ! specified (NULL) values the corresponding codeblock size ! - ! is set to 0. For all valid dimensions the codeblock size ! - ! is set accordingly. ! - \*--------------------------------------------------------*/ - 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 if the codeblock sizes have valid 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"); - - /*--------------------------------------------------------*\ - ! Reset the codeblock sizes to their standard values. ! - \*--------------------------------------------------------*/ - 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); -} - -/*----------------------------------------------------------------------------------------------------------*\ -! 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. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! Qm unsigned int(8 bit) - Q number formate range (m). ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 14.03.2018 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -void -bwc_set_qm(bwc_field *const field, uint8 Qm) -{ - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_ctrl *control; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(field); - - /*--------------------------------------------------------*\ - ! Save the global control structure to a temporary varia- ! - ! ble to make the code more readable. ! - \*--------------------------------------------------------*/ - control = &field->control; - - /*--------------------------------------------------------*\ - ! Check if the Q number formate range is valid and amend ! - ! the bwc_field structure accordingly. ! - \*--------------------------------------------------------*/ - if((int8)(PREC_BIT - Qm) < 2) - { - 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; - - /*--------------------------------------------------------*\ - ! Record the setting of the Q number format range in the ! - ! CSsgc variable. ! - \*--------------------------------------------------------*/ - control->CSsgc |= (0x01 << 8); - } -} - -/*----------------------------------------------------------------------------------------------------------*\ -! 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. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! tilesX, tilesY, tilesZ unsigned int(32 bit) - Variables defining the size of ! -! a spatial tile. ! -! ! -! tilesTS unsigned int(32 bit) - Variables defining the size of ! -! a temporal tile. ! -! ! -! instr bwc_tile_instr - Constants used to instruct the ! -! bwc_set_tiles function. ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 14.03.2018 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -void -bwc_set_tiles(bwc_field *const field, uint64 tilesX, uint64 tilesY, uint64 tilesZ, uint16 tilesTS, bwc_tile_instr 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); -} - /*----------------------------------------------------------------------------------------------------------*\ ! FUNCTION NAME: void bwc_create_compression(bwc_field *field, char *rate_control) ! ! -------------- !