feat/api #46

Open
Gregor Weiss wants to merge 56 commits from feat/api into main
9 changed files with 1793 additions and 973 deletions
Showing only changes of commit a2309b0ba2 - Show all commits

View file

@ -347,6 +347,21 @@
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\
! !
! DESCRIPTION: !
! ------------ !
! This function deallocates the data structure used to store an numerical dataset !
! and can be called if an error occurs or once the data is no longer needed is to be closed. !
! The deallocation will be carried out down to the structure levels that have been allocated. !
! !
\*----------------------------------------------------------------------------------------------------------*/
void
eas3_free_data(eas3_data* data);
uchar
bwc_to_eas3(bwc_stream *const stream, eas3_data *const data);
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: bwc_data* read_eas3(const char* const filename) ! ! FUNCTION NAME: bwc_data* read_eas3(const char* const filename) !
! -------------- ! ! -------------- !

View file

@ -100,6 +100,10 @@
size_t assemble_codestream (bwc_codec *const codec, size_t assemble_codestream (bwc_codec *const codec,
bwc_stream *const stream); bwc_stream *const stream);
//==========|==========================|======================|======|======|===================== //==========|==========================|======================|======|======|=====================
bwc_codec* parse_main_header (bwc_codec *const codec,
bwc_stream *const data,
bitstream *const stream);
//==========|==========================|======================|======|======|=====================
bwc_codec* parse_codestream (bwc_codec *const codec, bwc_codec* parse_codestream (bwc_codec *const codec,
bwc_stream *const stream, bwc_stream *const stream,
uint8 const layer); uint8 const layer);

View file

@ -142,6 +142,10 @@
uint64 const tilesTS, uint64 const tilesTS,
bwc_tile_instr const instr); bwc_tile_instr const instr);
//==========|==========================|======================|======|=======|==================== //==========|==========================|======================|======|=======|====================
bwc_header* bwc_open_header (void *const inpbuf);
//==========|==========================|======================|======|=======|====================
void bwc_close_header (bwc_header *const header);
//==========|==========================|======================|======|=======|====================
uchar bwc_create_compression (bwc_codec *const codec, uchar bwc_create_compression (bwc_codec *const codec,
bwc_stream *const data, bwc_stream *const data,
char *const rate_control); char *const rate_control);

View file

@ -659,18 +659,25 @@
bwc_prog_ord progression; // Packet progression order. bwc_prog_ord progression; // Packet progression order.
} bwc_gl_ctrl; } bwc_gl_ctrl;
/*----------------------------------------------------------------------------------------------*\ /*================================================================================================*/
! ! /**
! DESCRIPTION: ! * @details Structure that is used to probe header information from a compressed data set.
! ------------ ! */
! ! /*================================================================================================*/
! This structure holds all the necessary parameters defining and controling a bwc ! typedef struct
! (de-)compression run. ! {
! ! bwc_gl_inf info; // Global info structure
! The meter structure is used to store measurements, including important time ! bwc_gl_ctrl control; // Global control structure
! measurements, for a particular compression run. ! bwc_span aux; // Auxiliary info. codestream block.
! ! bwc_span com; // Comment codestream block.
\*----------------------------------------------------------------------------------------------*/ } bwc_header;
/*================================================================================================*/
/**
* @details Structure holding all the necessary parameters defining and controlling a bwc
* (de-)compression run.
*/
/*================================================================================================*/
typedef struct typedef struct
{ {
bwc_gl_inf info; // Global info structure bwc_gl_inf info; // Global info structure

View file

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

View file

@ -76,7 +76,25 @@
#include <string.h> #include <string.h>
#include "eas3.h" #include "eas3.h"
#include "bwccmdl.h"
/************************************************************************************************************\
|| _ _ ____ ____ ____ ____ ____ ||
|| |\/| |__| | |__/ | | [__ ||
|| | | | | |___ | \ |__| ___] ||
|| ||
\************************************************************************************************************/
#define MEMERROR "o##########################################################o\n"\
"| ERROR: Out of memory |\n"\
"o##########################################################o\n"
#define RDERROR "o##########################################################o\n"\
"| ERROR: Invalid Number of Bytes Read from File. |\n"\
"o##########################################################o\n"
#define WRTERROR "o##########################################################o\n"\
"| ERROR: Invalid Number of Bytes Written to File. |\n"\
"o##########################################################o\n"
/************************************************************************************************************\ /************************************************************************************************************\
|| ___ ____ _ _ _ ____ ___ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ || || ___ ____ _ _ _ ____ ___ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
@ -84,15 +102,11 @@
|| | | \ | \/ | | | |___ | |__| | \| |___ | | |__| | \| ___] || || | | \ | \/ | | | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************************/
/*================================================================================================*/
/*----------------------------------------------------------------------------------------------------------*\ /**
! ! * @details Enqueues a chunck of size length to the auxilliary information.
! DESCRIPTION: ! */
! ------------ ! /*================================================================================================*/
! This macro is used to write an additional chunck of size length to the auxilliary !
! information. !
! !
\*----------------------------------------------------------------------------------------------------------*/
#define aux_enqueue(aux, chunck, chunck_len) \ #define aux_enqueue(aux, chunck, chunck_len) \
{ \ { \
if (aux.pos + chunck_len > aux.len) \ if (aux.pos + chunck_len > aux.len) \
@ -107,6 +121,11 @@
aux.pos += chunck_len; \ aux.pos += chunck_len; \
} }
/*================================================================================================*/
/**
* @details Dequeues a chunck of size length from the auxilliary information.
*/
/*================================================================================================*/
#define aux_dequeue(aux, chunck, chunck_len) \ #define aux_dequeue(aux, chunck, chunck_len) \
{ \ { \
if(aux.pos + chunck_len <= aux.len) { \ if(aux.pos + chunck_len <= aux.len) { \
@ -117,37 +136,14 @@
} \ } \
} }
/*----------------------------------------------------------------------------------------------------------*\ /*================================================================================================*/
! ! /**
! DESCRIPTION: ! * @details Converts the endianess of half, single, or double precision values.
! ------------ ! *
! This function converts the endianess of half, single or double precision values. ! * @param[inout] value Pointer to the parameter to be converted.
! ! * @param[in] accuracy Precision/accuracy of the pointed parameter.
! PARAMETERS: ! */
! ----------- ! /*================================================================================================*/
! Variable Type Description !
! -------- ---- ----------- !
! value void* - Memory address of the parame- !
! ter to be converted. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! - - !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description !
! ---- ------ --------- ------- ----------- !
! 30.04.2019 Patrick Vogler B87D120 V 0.1.0 function created !
! 21.11.2019 Patrick Vogler B87E7E4 V 0.1.0 functionality expanded !
! to 32 bit integers !
! 21.11.2019 Patrick Vogler B87E7E4 V 0.1.0 functionality expanded !
! to 16 bit integers !
! !
\*----------------------------------------------------------------------------------------------------------*/
static void static void
endian_conversion(void *value, endian_conversion(void *value,
uint8_t const accuracy) uint8_t const accuracy)
@ -201,34 +197,56 @@ endian_conversion(void *value,
} }
} }
/*----------------------------------------------------------------------------------------------------------*\ /*================================================================================================*/
! ! /**
! DESCRIPTION: ! * @details Deallocates the provided eas3_data structure including all contained data.
! ------------ ! *
! This function deallocates the data structure used to store an numerical dataset ! * @param[in] data Pointer to eas3_data structure to be filled.
! and can be called if an error occurs or once the data is no longer needed is to be closed. ! */
! The deallocation will be carried out down to the structure levels that have been allocated. ! /*================================================================================================*/
! !
\*----------------------------------------------------------------------------------------------------------*/
void void
eas3_free_data(eas3_data* data) eas3_free_data(eas3_data* data)
{ {
if(data) /*-----------------------*\
{ ! DEFINE STRUCTS: !
//if(data->aux) \*-----------------------*/
//{ eas3_param_names *param, *temp;
//free(data->aux->memory);
//data->aux->access = NULL; if(data != NULL)
//data->aux->position = 0; {
//data->aux->size = 0; if (data->param_names != NULL)
// TODO: remove {
//data->aux->L = 0; param = data->param_names->root;
//}
//free(data->aux); while(param != NULL)
free(data); {
} temp = param;
param = param -> next;
free(temp);
}
}
if (data->field.d != NULL)
free(data->field.d);
if (data->field.f != NULL)
free(data->field.f);
if(data->aux.ptr != NULL)
free(data->aux.ptr);
free(data);
}
} }
/*================================================================================================*/
/**
* @details Adds a parameter name to the linked list inside the eas3_data structure.
*
* @param[in] data Pointer to eas3_data structure to be filled.
* @param[in] name Name to be added to the linked list.
*/
/*================================================================================================*/
void void
eas3_add_param_name(eas3_data *const data, char *name) eas3_add_param_name(eas3_data *const data, char *name)
{ {
@ -283,49 +301,137 @@ eas3_add_param_name(eas3_data *const data, char *name)
strcpy(data->param_names->name, name ? name : "undefined"); strcpy(data->param_names->name, name ? name : "undefined");
} }
/*----------------------------------------------------------------------------------------------------------*\ /*================================================================================================*/
! FUNCTION NAME: uchar read_eas3_header(bwc_data *const data) ! /**
! -------------- ! * @details Parses the uncompressed output from bwc_stream into the eas3_data.
! ! *
! DESCRIPTION: ! * @param[in] stream Pointer to uncompressed data set.
! ------------ ! * @param[inout] data Pointer to eas3_data structure to be filled.
! This function opens an eas3 file and checks it for its validity. Once the specified file ! *
! has been verified, its header and flow field data is read and stored in the bwc_data ! * @retval uchar
! structure. ! */
! ! /*================================================================================================*/
! ! uchar
! PARAMETERS: ! bwc_to_eas3(bwc_stream *const stream, eas3_data *const data)
! ----------- ! {
! Variable Type Description ! /*-----------------------*\
! -------- ---- ----------- ! ! DEFINE INT VARIABLES: !
! filename char* - Defines the filename of the eas3 file ! \*-----------------------*/
! that is to be opened and read. ! uint64 Lread;
! ! uint64 size;
! RETURN VALUE: ! uint64 i;
! ------------- !
! Type Description ! /*-----------------------*\
! ---- ----------- ! ! DEFINE CHAR VARIABLES: !
! file - Defines a structure used to store all ! \*-----------------------*/
! the relevant parameters and the data ! uchar *buffer_char;
! field of an eas3 file. ! char param_name[ATTRLEN + 1] = {};
! !
! DEVELOPMENT HISTORY: ! /*-----------------------*\
! -------------------- ! ! DEFINE STRUCTS: !
! ! \*-----------------------*/
! Date Author Change Id Release Description Of Change ! eas3_std_params *params;
! ---- ------ --------- ------- --------------------- !
! 20.06.2018 Patrick Vogler B87D120 V 0.1.0 function created ! params = &data->params;
! !
\*----------------------------------------------------------------------------------------------------------*/ data->aux.ptr = calloc(stream->codestream.aux->size, sizeof(uchar));
static uchar data->aux.pos = 0;
read_eas3_header(FILE *const fp, eas3_data *const data) data->aux.len = stream->codestream.aux->size;
if(!data->aux.ptr)
{
// memory allocation error
fprintf(stderr, MEMERROR);
free(data->aux.ptr);
return 1;
}
memcpy(data->aux.ptr, stream->codestream.aux->memory,
stream->codestream.aux->size);
aux_dequeue(data->aux, (uchar*)params, 176);
endian_conversion(&params->nts, 8);
endian_conversion(&params->npar, 8);
endian_conversion(&params->ndim1, 8);
endian_conversion(&params->ndim2, 8);
endian_conversion(&params->ndim3, 8);
endian_conversion(&params->accuracy, 8);
if(params->accuracy != 1 && params->accuracy != 2)
{
fprintf(stderr, "o##########################################################o\n"\
"| ERROR: The accuracy of the specified dataset is not sup- |\n"\
"| ported by the compression algorithm. |\n"\
"o##########################################################o\n");
return 1;
}
buffer_char = calloc(params->nts, sizeof(uint64));
if(!buffer_char)
{
// memory allocation error
fprintf(stderr, MEMERROR);
free(buffer_char);
return 1;
}
aux_dequeue(data->aux, buffer_char, params->nts * sizeof(uint64));
if(params->attribute_mode == EAS3_ALL_ATTR)
{
buffer_char = realloc(buffer_char, params->nts * ATTRLEN * sizeof(char));
if(!buffer_char)
{
// memory allocation error
fprintf(stderr, MEMERROR);
free(buffer_char);
return 1;
}
aux_dequeue(data->aux, buffer_char, params->nts * ATTRLEN * sizeof(char));
for(i = 0; i < params->npar; ++i)
{
aux_dequeue(data->aux, param_name, ATTRLEN * sizeof(char));
eas3_add_param_name(data, param_name);
memset(param_name, 0, ATTRLEN + 1);
}
}
size = params->ndim1 * params->ndim2 * params->ndim3 *
params->nts * params->npar;
if(params->accuracy == 1)
{
data->field.d = NULL;
data->field.f = calloc(size, sizeof(float));
memcpy(data->field.f, stream->out, size*sizeof(float));
}
else if(params->accuracy == 2)
{
data->field.f = NULL;
data->field.d = calloc(size, sizeof(double));
memcpy(data->field.d, stream->out, size*sizeof(double));
}
return 0;
}
/*================================================================================================*/
/**
* @details Reads the header from an open eas3 file pointer parsing the header information into
* the eas3_data structure argument.
*
* @param[in] fp Readily opened file pointer.
* @param[inout] data Structure to store eas3 data.
*
* @retval uchar
*/
/*================================================================================================*/
static uchar
read_eas3_header(FILE *const fp, eas3_data *const data)
{ {
/*-----------------------*\ /*-----------------------*\
! DEFINE INT VARIABLES: ! ! DEFINE INT VARIABLES: !
\*-----------------------*/ \*-----------------------*/
uint64 Lread; uint64 Lread;
uint64 i; uint64 i;
uint8 precision;
/*-----------------------*\ /*-----------------------*\
! DEFINE CHAR VARIABLES: ! ! DEFINE CHAR VARIABLES: !
@ -336,7 +442,6 @@ read_eas3_header(FILE *const fp, eas3_data *const data)
/*-----------------------*\ /*-----------------------*\
! DEFINE STRUCTS: ! ! DEFINE STRUCTS: !
\*-----------------------*/ \*-----------------------*/
bwc_gl_inf *info;
eas3_std_params *params; eas3_std_params *params;
/*-----------------------*\ /*-----------------------*\
@ -550,13 +655,9 @@ read_eas3_header(FILE *const fp, eas3_data *const data)
return 1; return 1;
} }
aux_enqueue(data->aux, param_name, ATTRLEN * sizeof(char));
eas3_add_param_name(data, param_name); eas3_add_param_name(data, param_name);
/*--------------------------------------------------------*\
! Read the parameter name from the file stream and add all !
! the necessary parameter information to the paramter !
! linked list. |
\*--------------------------------------------------------*/
memset(param_name, 0, ATTRLEN + 1); memset(param_name, 0, ATTRLEN + 1);
} }
} }
@ -632,40 +733,17 @@ read_eas3_header(FILE *const fp, eas3_data *const data)
return 0; return 0;
} }
/*----------------------------------------------------------------------------------------------------------*\ /*================================================================================================*/
! FUNCTION NAME: uchar read_eas3_header(bwc_data *const data) ! /**
! -------------- ! * @details Writes the header information from the eas3_data structure into the open eas3
! ! * file pointer.
! DESCRIPTION: ! *
! ------------ ! * @param[in] fp Readily opened file pointer.
! This function opens an eas3 file and checks it for its validity. Once the specified file ! * @param[inout] data Structure to store eas3 data.
! has been verified, its header and flow field data is read and stored in the bwc_data ! *
! structure. ! * @retval uchar
! ! */
! ! /*================================================================================================*/
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! filename char* - Defines the filename of the eas3 file !
! that is to be opened and read. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! file - Defines a structure used to store all !
! the relevant parameters and the data !
! field of an eas3 file. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 20.06.2018 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
static uchar static uchar
write_eas3_header(FILE *const fp, eas3_data *const data) write_eas3_header(FILE *const fp, eas3_data *const data)
{ {
@ -682,7 +760,6 @@ write_eas3_header(FILE *const fp, eas3_data *const data)
/*-----------------------*\ /*-----------------------*\
! DEFINE STRUCTS: ! ! DEFINE STRUCTS: !
\*-----------------------*/ \*-----------------------*/
bwc_gl_inf *info;
eas3_std_params *params; eas3_std_params *params;
eas3_param_names *param_names; eas3_param_names *param_names;
@ -729,7 +806,13 @@ write_eas3_header(FILE *const fp, eas3_data *const data)
! Convert the size parameters, used to write the rest of ! ! Convert the size parameters, used to write the rest of !
! the header, to little endian. ! ! the header, to little endian. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
endian_conversion(&params->file_type, 8);
endian_conversion(&params->accuracy, 8); endian_conversion(&params->accuracy, 8);
endian_conversion(&params->nts, 8);
endian_conversion(&params->npar, 8);
endian_conversion(&params->ndim1, 8);
endian_conversion(&params->ndim2, 8);
endian_conversion(&params->ndim3, 8);
endian_conversion(&params->size_time, 8); endian_conversion(&params->size_time, 8);
endian_conversion(&params->size_parameter, 8); endian_conversion(&params->size_parameter, 8);
endian_conversion(&params->size_dim1, 8); endian_conversion(&params->size_dim1, 8);
@ -739,6 +822,8 @@ write_eas3_header(FILE *const fp, eas3_data *const data)
endian_conversion(&params->udef_int_size, 8); endian_conversion(&params->udef_int_size, 8);
endian_conversion(&params->udef_real_size, 8); endian_conversion(&params->udef_real_size, 8);
data->params = *params;
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Allocate the buffer character array. If successful, get ! ! Allocate the buffer character array. If successful, get !
! the timestep array from the auxiliary information block ! ! the timestep array from the auxiliary information block !
@ -872,40 +957,16 @@ write_eas3_header(FILE *const fp, eas3_data *const data)
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|| || || ||
\************************************************************************************************************/ \************************************************************************************************************/
/*----------------------------------------------------------------------------------------------------------*\ /*================================================================================================*/
! FUNCTION NAME: bwc_data* read_eas3(const char* const filename) ! /**
! -------------- ! * @details Opens an eas3 file and checks it for its validity. Then, it reads header and flow
! ! * field data and returns a filled instance of the eas3_data structure.
! DESCRIPTION: ! *
! ------------ ! * @param[in] filename Name of the eas3 file.
! This function opens an eas3 file and checks it for its validity. Once the specified file ! *
! has been verified, its header and flow field data is read and stored in the bwc_data ! * @retval eas3_data*
! structure. ! */
! ! /*================================================================================================*/
! !
! PARAMETERS: !
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! filename char* - Defines the filename of the eas3 file !
! that is to be opened and read. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! file - Defines a structure used to store all !
! the relevant parameters and the data !
! field of an eas3 file. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 20.06.2018 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
eas3_data* eas3_data*
read_eas3(char *const filename) read_eas3(char *const filename)
{ {
@ -1068,40 +1129,16 @@ read_eas3(char *const filename)
return data; return data;
} }
/*----------------------------------------------------------------------------------------------------------*\ /*================================================================================================*/
! FUNCTION NAME: uchar write_eas3(bwc_data *const file, char *const filename) ! /**
! -------------- ! * @details Opens an eas3 file and writes the content from the provided eas3_data structure.
! ! *
! DESCRIPTION: ! * @param[in] data Data to be written into the eas3 file.
! ------------ ! * @param[in] filename Name of the eas3 file.
! This function creates a valid eas3 file from the information stored in the bwc_data ! *
! structure. ! * @retval uchar
! ! */
! PARAMETERS: ! /*================================================================================================*/
! ----------- !
! Variable Type Description !
! -------- ---- ----------- !
! filename char* - Defines the filename of the eas3 file !
! that is to be opened and read. !
! !
! file bwc_data* - Defines a structure used to store all !
! the relevant parameters and the data !
! field of an eas3 file. !
! !
! RETURN VALUE: !
! ------------- !
! Type Description !
! ---- ----------- !
! uchar - Returns an unsigned char for error handling. !
! !
! DEVELOPMENT HISTORY: !
! -------------------- !
! !
! Date Author Change Id Release Description Of Change !
! ---- ------ --------- ------- --------------------- !
! 20.06.2018 Patrick Vogler B87D120 V 0.1.0 function created !
! !
\*----------------------------------------------------------------------------------------------------------*/
uchar uchar
write_eas3(eas3_data *const data, char *const filename) write_eas3(eas3_data *const data, char *const filename)
{ {

View file

@ -912,7 +912,7 @@ parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *con
data->codestream.com->memory = get_chunck(stream, Lcom - 2); data->codestream.com->memory = get_chunck(stream, Lcom - 2);
data->codestream.com->size = Lcom -2; data->codestream.com->size = Lcom -2;
status |= CODESTREAM_ERROR; status |= CODESTREAM_COM_READ;
break; break;
} }

View file

@ -1498,8 +1498,9 @@ bwc_set_com(bwc_stream *const data, char const *const com, uint16 size)
! Save the global info structure to a temporary variable ! ! Save the global info structure to a temporary variable !
! to make the code more readable. ! ! to make the code more readable. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
data->codestream.com = calloc(1, sizeof(bwc_span));
data->codestream.com->memory = calloc(size, sizeof(char)); data->codestream.com->memory = calloc(size, sizeof(char));
if(!data->codestream.com->memory) if(!data->codestream.com->memory)
{ {
// memory allocation error // memory allocation error
fprintf(stderr, MEMERROR); fprintf(stderr, MEMERROR);
@ -1536,18 +1537,19 @@ bwc_set_aux(bwc_stream *const data, char const *const aux, uint32 size)
! Save the global info structure to a temporary variable ! ! Save the global info structure to a temporary variable !
! to make the code more readable. ! ! to make the code more readable. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
data->codestream.com->memory = calloc(size, sizeof(char)); data->codestream.aux = calloc(1, sizeof(bwc_span));
if(!data->codestream.com->memory) data->codestream.aux->memory = calloc(size, sizeof(char));
if(!data->codestream.aux->memory)
{ {
// memory allocation error // memory allocation error
fprintf(stderr, MEMERROR); fprintf(stderr, MEMERROR);
return 1; return 1;
} }
memcpy(data->codestream.com->memory, aux, size * sizeof(char)); memcpy(data->codestream.aux->memory, aux, size * sizeof(char));
data->codestream.com->access = data->codestream.com->memory; data->codestream.aux->access = data->codestream.aux->memory;
data->codestream.com->size = size; data->codestream.aux->size = size;
data->codestream.com->position = 0; data->codestream.aux->position = 0;
return 0; return 0;
} }
@ -2490,15 +2492,14 @@ set_quant_step_size(bwc_codec *const codec, double delta)
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
if((delta <= 0) || (delta >= 2)) if((delta <= 0) || (delta >= 2))
{ {
fprintf(stderr, "o==========================================================o\n"\ fprintf(stderr, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"\
"| WARNING: Invalid quantization step size |\n"\ " WARNING: Invalid quantization step size \n"\
"| |\n"\ " \n"\
"| The quantization step size does not lie within |\n"\ " The quantization step size does not lie within \n"\
"| the acceptable range of: |\n"\ " the acceptable range of: \n"\
"| |\n"\ " \n"\
"| 0 < step size < 2 |\n"\ " 0 < step size < 2 \n"\
"| |\n"\ ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
"o==========================================================o\n");
return; return;
} }
@ -2782,14 +2783,13 @@ bwc_set_decomp(bwc_codec *const codec, uint8 decompX, uint8 decompY, uint8 decom
if((control->decompX > 63) || (control->decompY > 63) || if((control->decompX > 63) || (control->decompY > 63) ||
(control->decompZ > 63) || (control->decompTS > 31)) (control->decompZ > 63) || (control->decompTS > 31))
{ {
fprintf(stderr, "o==========================================================o\n"\ fprintf(stderr, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"\
"| WARNING: Invalid decomposition level value |\n"\ " WARNING: Invalid decomposition level value \n"\
"| |\n"\ " \n"\
"| The maximum acceptable decomposition level is |\n"\ " The maximum acceptable decomposition level is \n"\
"| 63 for all spatial and 31 for the temporal |\n"\ " 63 for all spatial and 31 for the temporal \n"\
"| dimensions. |\n"\ " dimensions. \n"\
"| |\n"\ ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
"o==========================================================o\n");
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Reset the decomposition levels to their standard values. ! ! Reset the decomposition levels to their standard values. !
@ -2924,13 +2924,12 @@ bwc_set_precincts(bwc_codec *const codec, uint8 pX, uint8 pY, uint8 pZ, uint8 pT
((control->precSizeTS < 1) && (info->nTS >> 1)) || ((control->precSizeTS < 1) && (info->nTS >> 1)) ||
(control->precSizeX > 15) || (control->precSizeY > 15) || (control->precSizeZ > 15) || (control->precSizeTS > 15)) (control->precSizeX > 15) || (control->precSizeY > 15) || (control->precSizeZ > 15) || (control->precSizeTS > 15))
{ {
fprintf(stderr, "o==========================================================o\n"\ fprintf(stderr, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"\
"| WARNING: Invalid precinct size |\n"\ " WARNING: Invalid precinct size \n"\
"| |\n"\ " \n"\
"| The maximum acceptable precinct size is 2^15, |\n"\ " The maximum acceptable precinct size is 2^15, \n"\
"| the smallest valid precinct size is 2^1. |\n"\ " the smallest valid precinct size is 2^1. \n"\
"| |\n"\ ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
"o==========================================================o\n");
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Reset the codeblock sizes to their standard values. ! ! Reset the codeblock sizes to their standard values. !
@ -3023,15 +3022,14 @@ bwc_set_codeblocks(bwc_codec *const codec, uint8 cbX, uint8 cbY, uint8 cbZ, uint
((control->cbX + control->cbY + control->cbZ + control->cbTS) < 4) || ((control->cbX + control->cbY + control->cbZ + control->cbTS) < 4) ||
((control->cbX + control->cbY + control->cbZ + control->cbTS) > 20)) ((control->cbX + control->cbY + control->cbZ + control->cbTS) > 20))
{ {
fprintf(stderr, "o==========================================================o\n"\ fprintf(stderr, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"\
"| WARNING: Invalid codeblock size |\n"\ " WARNING: Invalid codeblock size \n"\
"| |\n"\ " \n"\
"| The maximum acceptable codeblock size is 2^20 |\n"\ " The maximum acceptable codeblock size is 2^20 \n"\
"| with a maximum allowable number of datapoints |\n"\ " with a maximum allowable number of datapoints \n"\
"| in each dimension of 2^10. The smallest valid |\n"\ " in each dimension of 2^10. The smallest valid \n"\
"| codeblock size is 2^4. |\n"\ " codeblock size is 2^4. \n"\
"| |\n"\ ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
"o==========================================================o\n");
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Reset the codeblock sizes to their standard values. ! ! Reset the codeblock sizes to their standard values. !
@ -3106,19 +3104,18 @@ bwc_set_qm(bwc_codec *const codec, uint8 Qm)
! Check if the Q number formate range is valid and amend ! ! Check if the Q number formate range is valid and amend !
! the bwc_codec structure accordingly. ! ! the bwc_codec structure accordingly. !
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
if((int8)(PREC_BIT - Qm) < 2) if((int8)(PREC_BIT - Qm) < 1)
{ {
fprintf(stderr, "o==========================================================o\n"\ fprintf(stderr, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"\
"| WARNING: Invalid Q number formate range |\n"\ " WARNING: Invalid Q number formate range \n"\
"| |\n"\ " \n"\
"| The specified Q number formate range is larger |\n"); " The specified Q number formate range is larger \n");
#ifdef BWC_SINGLE_PRECISION #ifdef BWC_SINGLE_PRECISION
fprintf(stderr, "| than the permitted 30 bits. |\n"); fprintf(stderr, " than the permitted 30 bits. \n");
#else #else
fprintf(stderr, "| than the permitted 62 bits. |\n"); fprintf(stderr, " than the permitted 62 bits. \n");
#endif #endif
fprintf(stderr, "| |\n"\ fprintf(stderr, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
"o==========================================================o\n");
} }
else else
{ {
@ -3213,17 +3210,16 @@ bwc_set_tiles(bwc_codec *const codec, uint64 tilesX, uint64 tilesY, uint64 tiles
(control->tileSizeZ < 16 && control->tileSizeZ > info->nZ)|| (control->tileSizeZ < 16 && control->tileSizeZ > info->nZ)||
(control->tileSizeTS < 16 && control->tileSizeTS > info->nTS)) (control->tileSizeTS < 16 && control->tileSizeTS > info->nTS))
{ {
fprintf(stderr,"o==========================================================o\n"\ fprintf(stderr,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"\
"| WARNING: Invalid Tile Dimensions |\n"\ " WARNING: Invalid Tile Dimensions \n"\
"| |\n"\ " \n"\
"| One or more of the specified tile dimensions |\n"\ " One or more of the specified tile dimensions \n"\
"| has a value that falls outside of its valid |\n"\ " has a value that falls outside of its valid \n"\
"| range. Please verify that all tile dimension |\n"\ " range. Please verify that all tile dimension \n"\
"| are within the range of: |\n"\ " are within the range of: \n"\
"| |\n"\ " \n"\
"| 16 ≤ Tile_Size_Xi ≤ Grid_Points_Xi |\n"\ " 16 ≤ Tile_Size_Xi ≤ Grid_Points_Xi \n"\
"| |\n"\ ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
"o==========================================================o\n");
return; return;
} }
@ -3255,16 +3251,15 @@ bwc_set_tiles(bwc_codec *const codec, uint64 tilesX, uint64 tilesY, uint64 tiles
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
if(((double)num_tiles_X * num_tiles_Y * num_tiles_Z * num_tiles_TS) > 0xFFFFFFFFFFFFFFFF) if(((double)num_tiles_X * num_tiles_Y * num_tiles_Z * num_tiles_TS) > 0xFFFFFFFFFFFFFFFF)
{ {
fprintf(stderr,"o==========================================================o\n"\ fprintf(stderr,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"\
"| WARNING: Invalid Tile Dimensions |\n"\ " WARNING: Invalid Tile Dimensions \n"\
"| |\n"\ " \n"\
"| The number of tiles exceeds its maxmum allowa- |\n"\ " The number of tiles exceeds its maxmum allowa- \n"\
"| ble value. Please adjust all tile dimension so |\n"\ " ble value. Please adjust all tile dimension so \n"\
"| that the number of tiles falls within the range |\n"\ " that the number of tiles falls within the range \n"\
"| of: |\n"\ " of: \n"\
"| Number_of_Tiles < 2^64 |\n"\ " Number_of_Tiles < 2^64 \n"\
"| |\n"\ ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
"o==========================================================o\n");
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Reset the tile sizes to their standard values. ! ! Reset the tile sizes to their standard values. !
@ -3285,15 +3280,14 @@ bwc_set_tiles(bwc_codec *const codec, uint64 tilesX, uint64 tilesY, uint64 tiles
\*--------------------------------------------------------*/ \*--------------------------------------------------------*/
if(((double)tilesX * tilesY * tilesZ * tilesTS) > 0xFFFFFFFFFFFFFFFF) if(((double)tilesX * tilesY * tilesZ * tilesTS) > 0xFFFFFFFFFFFFFFFF)
{ {
fprintf(stderr,"o==========================================================o\n"\ fprintf(stderr,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"\
"| WARNING: Invalid Number Of Tiles |\n"\ " WARNING: Invalid Number Of Tiles \n"\
"| |\n"\ " \n"\
"| The number of tiles exceeds its maxmum allowa- |\n"\ " The number of tiles exceeds its maxmum allowa- \n"\
"| ble value of: |\n"\ " ble value of: \n"\
"| |\n"\ " \n"\
"| Number_of_Tiles < 2^64 |\n"\ " Number_of_Tiles < 2^64 \n"\
"| |\n"\ ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
"o==========================================================o\n");
return; return;
} }
@ -3318,18 +3312,17 @@ bwc_set_tiles(bwc_codec *const codec, uint64 tilesX, uint64 tilesY, uint64 tiles
(control->tileSizeZ < 16 && control->tileSizeZ > info->nZ)|| (control->tileSizeZ < 16 && control->tileSizeZ > info->nZ)||
(control->tileSizeTS < 16 && control->tileSizeTS > info->nTS)) (control->tileSizeTS < 16 && control->tileSizeTS > info->nTS))
{ {
fprintf(stderr,"o==========================================================o\n"\ fprintf(stderr,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"\
"| WARNING: Invalid Number Of Tiles |\n"\ " WARNING: Invalid Number Of Tiles \n"\
"| |\n"\ " \n"\
"| One or more of the tile dimensions has a value |\n"\ " One or more of the tile dimensions has a value \n"\
"| that falls outside of its valid range. Please |\n"\ " that falls outside of its valid range. Please \n"\
"| verify that the number of tiles for all dimen- |\n"\ " verify that the number of tiles for all dimen- \n"\
"| sions are set so that the corresponding tile |\n"\ " sions are set so that the corresponding tile \n"\
"| sizes fall within the range of: |\n"\ " sizes fall within the range of: \n"\
"| |\n"\ " \n"\
"| 16 ≤ Tile_Size_Xi ≤ Grid_Points_Xi |\n"\ " 16 ≤ Tile_Size_Xi ≤ Grid_Points_Xi \n"\
"| |\n"\ ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
"o==========================================================o\n");
/*--------------------------------------------------------*\ /*--------------------------------------------------------*\
! Reset the tile sizes to their standard values. ! ! Reset the tile sizes to their standard values. !
@ -3359,6 +3352,98 @@ bwc_set_tiles(bwc_codec *const codec, uint64 tilesX, uint64 tilesY, uint64 tiles
control->CSsgc |= (0x01 << 9); control->CSsgc |= (0x01 << 9);
} }
/*================================================================================================*/
/**
* @details This function opens the header of a compressed data set and parses it into an
* instance of type bwc_header.
*
* @param[in] inpbuf Pointer to compressed data set.
*
* @retval bwc_header*
*/
/*================================================================================================*/
bwc_header* bwc_open_header(void *const inpbuf)
{
/*-----------------------*\
! DEFINE STRUCTS: !
\*-----------------------*/
bwc_codec* codec;
bwc_stream* data;
bitstream* stream;
bwc_header* header;
/*--------------------------------------------------------*\
! Initialize a codec, stream, and bitstream for parsing. !
\*--------------------------------------------------------*/
data = bwc_init_stream(inpbuf, NULL, decomp);
codec = bwc_alloc_decoder();
stream = init_bitstream(data->inp, 10, 'd');
/*--------------------------------------------------------*\
! Parse the main header into the codec structure. !
\*--------------------------------------------------------*/
parse_main_header(codec, data, stream);
if(!codec)
{
return NULL;
}
/*--------------------------------------------------------*\
! Allocate header and copy info and control structures. !
\*--------------------------------------------------------*/
header = calloc(1, sizeof(bwc_header));
header->info = codec->info;
header->control = codec->control;
/*--------------------------------------------------------*\
! Shallow copy aux data to span. !
\*--------------------------------------------------------*/
if (data->codestream.aux)
{
header->aux.memory = data->codestream.aux->memory;
header->aux.size = data->codestream.aux->size;
}
/*--------------------------------------------------------*\
! Shallow copy com data to span. !
\*--------------------------------------------------------*/
if (data->codestream.com)
{
header->com.memory = data->codestream.com->memory;
header->com.size = data->codestream.com->size;
}
free(stream);
free(data);
free(codec);
return header;
}
/*================================================================================================*/
/**
* @details This function closes the header information in the bwc_header pointer.
*
* @param[in] header Instance of type bwc_header.
*/
/*================================================================================================*/
void bwc_close_header(bwc_header *const header)
{
if (header)
{
if (header->aux.memory)
{
free(header->aux.memory);
}
if (header->com.memory)
{
free(header->com.memory);
}
free(header);
}
}
/*----------------------------------------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------------------------------------*\
! FUNCTION NAME: void bwc_create_compression(bwc_codec *codec, char *rate_control) ! ! FUNCTION NAME: void bwc_create_compression(bwc_codec *codec, char *rate_control) !
! -------------- ! ! -------------- !

File diff suppressed because it is too large Load diff