Removed the streaming functions from the public header to clean up the API.
This commit is contained in:
parent
8850d525f2
commit
eae976b9ba
15 changed files with 1966 additions and 1536 deletions
6
Makefile
6
Makefile
|
@ -18,7 +18,7 @@
|
|||
#| DESCRIPTION: |#
|
||||
#| ------------ |#
|
||||
#| Defines a wrapper for the Big Whoop cmake & make tools. This Makefile creates the |#
|
||||
#| build dir if it does not exist, switches to it and executes cmake and make. |#
|
||||
#| build dir if it does not exist, switches to it and executes cmake and make. |#
|
||||
#| |#
|
||||
#| ---------------------------------------------------------------------------------------------------------------- |#
|
||||
#| |#
|
||||
|
@ -78,12 +78,12 @@ BUILD_EAS3="False"
|
|||
BUILD_NETCDF="False"
|
||||
|
||||
#*--------------------------------------------------------*#
|
||||
# Define default target. #
|
||||
# Define default target. #
|
||||
#*--------------------------------------------------------*#
|
||||
default: | build_bwc display
|
||||
|
||||
#*--------------------------------------------------------*#
|
||||
# Define helper target. #
|
||||
# Define helper target. #
|
||||
#*--------------------------------------------------------*#
|
||||
help:
|
||||
|
||||
|
|
|
@ -61,276 +61,300 @@
|
|||
#ifndef EAS3_H
|
||||
#define EAS3_H
|
||||
|
||||
/************************************************************************************************************\
|
||||
|| _ _ _ ____ _ _ _ ___ ____ ||
|
||||
|| | |\ | | | | | | \ |___ ||
|
||||
|| | | \| |___ |___ |__| |__/ |___ ||
|
||||
|| ||
|
||||
\************************************************************************************************************/
|
||||
#include <bwc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
/************************************************************************************************************\
|
||||
|| _ _ _ ____ _ _ _ ___ ____ ||
|
||||
|| | |\ | | | | | | \ |___ ||
|
||||
|| | | \| |___ |___ |__| |__/ |___ ||
|
||||
|| ||
|
||||
\************************************************************************************************************/
|
||||
#include <bwc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/************************************************************************************************************\
|
||||
|| _ _ ____ ____ ____ ____ ____ ||
|
||||
|| |\/| |__| | |__/ | | [__ ||
|
||||
|| | | | | |___ | \ |__| ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************************/
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! !
|
||||
! These macros are used to identify the spatial and temporal dimensions. !
|
||||
! !
|
||||
! MACROS: !
|
||||
! ------- !
|
||||
! Name Description !
|
||||
! ---- ----------- !
|
||||
! DIM_X, DIM_Y, DIM_Z - Spatial Dimensions !
|
||||
! !
|
||||
! DIM_TS - Temporal Dimension !
|
||||
! !
|
||||
! DIM_ALL - All Dimensions !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
! !
|
||||
! Date Author Change Id Release Description !
|
||||
! ---- ------ --------- ------- ----------- !
|
||||
! 04.12.2017 Patrick Vogler B87D120 V 0.1.0 macros created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
#define DIM_X 1
|
||||
#define DIM_Y 2
|
||||
#define DIM_Z 4
|
||||
#define DIM_TS 8
|
||||
#define DIM_ALL 15
|
||||
/************************************************************************************************************\
|
||||
|| _ _ ____ ____ ____ ____ ____ ||
|
||||
|| |\/| |__| | |__/ | | [__ ||
|
||||
|| | | | | |___ | \ |__| ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************************/
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! !
|
||||
! These macros are used to identify the spatial and temporal dimensions. !
|
||||
! !
|
||||
! MACROS: !
|
||||
! ------- !
|
||||
! Name Description !
|
||||
! ---- ----------- !
|
||||
! DIM_X, DIM_Y, DIM_Z - Spatial Dimensions !
|
||||
! !
|
||||
! DIM_TS - Temporal Dimension !
|
||||
! !
|
||||
! DIM_ALL - All Dimensions !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
! !
|
||||
! Date Author Change Id Release Description !
|
||||
! ---- ------ --------- ------- ----------- !
|
||||
! 04.12.2017 Patrick Vogler B87D120 V 0.1.0 macros created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
#define DIM_X 1
|
||||
#define DIM_Y 2
|
||||
#define DIM_Z 4
|
||||
#define DIM_TS 8
|
||||
#define DIM_ALL 15
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! !
|
||||
! These macros are used to instruct the read_eas3_header function. !
|
||||
! !
|
||||
! Macros: !
|
||||
! ------- !
|
||||
! Macro Description !
|
||||
! ----- ----------- !
|
||||
! EAS3_NO_ATTR 1 - Specifies that no attributes are present in the bit- !
|
||||
! stream. !
|
||||
! !
|
||||
! EAS3_ALL_ATTR 2 - Specifies that all attributes are present in the bit- !
|
||||
! bitstream. !
|
||||
! !
|
||||
! ATTRLEN 10 - Defines the number of bytes used to define an attrib- !
|
||||
! ute. !
|
||||
! !
|
||||
! UDEFLEN 20 - Defines the number of bytes used to define a user de- !
|
||||
! fined data. !
|
||||
! !
|
||||
! EAS3_NO_G 1 - Specifies that no geometry data is present in the bit- !
|
||||
! stream. !
|
||||
! !
|
||||
! EAS3_X0DX_G 2 - Specifies that a start value and step size are present !
|
||||
! in the bitstream. !
|
||||
! !
|
||||
! EAS3_UDEF_G 3 - Specifies that ng = number of coordinate data is pres- !
|
||||
! ent in the bitstream. !
|
||||
! !
|
||||
! EAS3_ALL_G 4 - Specifies that an element for every appropriate di- !
|
||||
! mension is present in the bitstream. !
|
||||
! !
|
||||
! EAS3_FULL_G 5 - Specifies that an element for every dimension is pres- !
|
||||
! ent in the bitstream. !
|
||||
! !
|
||||
! EAS3_NO_UDEF 1 - Specifies that no user defined data is present in the !
|
||||
! bitstream. !
|
||||
! !
|
||||
! EAS3_ALL_UDEF 2 - Specifies that all user defined fields are present in !
|
||||
! the bitstream. !
|
||||
! !
|
||||
! EAS3_INT_UDEF 3 - Specifies that an user defined integer field is pres- !
|
||||
! ent in the bitstream. !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
! !
|
||||
! Date Author Change Id Release Description Of Change !
|
||||
! ---- ------ --------- ------- --------------------- !
|
||||
! 20.06.2018 Patrick Vogler B87D120 V 0.1.0 Macros created !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
#define EAS3_NO_ATTR 0x100000000000000
|
||||
#define EAS3_ALL_ATTR 0x200000000000000
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! !
|
||||
! These macros are used to instruct the read_eas3_header function. !
|
||||
! !
|
||||
! Macros: !
|
||||
! ------- !
|
||||
! Macro Description !
|
||||
! ----- ----------- !
|
||||
! EAS3_NO_ATTR 1 - Specifies that no attributes are present in the bit- !
|
||||
! stream. !
|
||||
! !
|
||||
! EAS3_ALL_ATTR 2 - Specifies that all attributes are present in the bit- !
|
||||
! bitstream. !
|
||||
! !
|
||||
! ATTRLEN 10 - Defines the number of bytes used to define an attrib- !
|
||||
! ute. !
|
||||
! !
|
||||
! UDEFLEN 20 - Defines the number of bytes used to define a user de- !
|
||||
! fined data. !
|
||||
! !
|
||||
! EAS3_NO_G 1 - Specifies that no geometry data is present in the bit- !
|
||||
! stream. !
|
||||
! !
|
||||
! EAS3_X0DX_G 2 - Specifies that a start value and step size are present !
|
||||
! in the bitstream. !
|
||||
! !
|
||||
! EAS3_UDEF_G 3 - Specifies that ng = number of coordinate data is pres- !
|
||||
! ent in the bitstream. !
|
||||
! !
|
||||
! EAS3_ALL_G 4 - Specifies that an element for every appropriate di- !
|
||||
! mension is present in the bitstream. !
|
||||
! !
|
||||
! EAS3_FULL_G 5 - Specifies that an element for every dimension is pres- !
|
||||
! ent in the bitstream. !
|
||||
! !
|
||||
! EAS3_NO_UDEF 1 - Specifies that no user defined data is present in the !
|
||||
! bitstream. !
|
||||
! !
|
||||
! EAS3_ALL_UDEF 2 - Specifies that all user defined fields are present in !
|
||||
! the bitstream. !
|
||||
! !
|
||||
! EAS3_INT_UDEF 3 - Specifies that an user defined integer field is pres- !
|
||||
! ent in the bitstream. !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
! !
|
||||
! Date Author Change Id Release Description Of Change !
|
||||
! ---- ------ --------- ------- --------------------- !
|
||||
! 20.06.2018 Patrick Vogler B87D120 V 0.1.0 Macros created !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
#define EAS3_NO_ATTR 0x100000000000000
|
||||
#define EAS3_ALL_ATTR 0x200000000000000
|
||||
|
||||
#define EAS2_TYPE 0x100000000000000
|
||||
#define EAS3_TYPE 0x200000000000000
|
||||
#define EAS2_TYPE 0x100000000000000
|
||||
#define EAS3_TYPE 0x200000000000000
|
||||
|
||||
#define ATTRLEN 10
|
||||
#define UDEFLEN 20
|
||||
#define ATTRLEN 10
|
||||
#define UDEFLEN 20
|
||||
|
||||
#define EAS3_NO_G 0x100000000000000
|
||||
#define EAS3_X0DX_G 0x200000000000000
|
||||
#define EAS3_UDEF_G 0x300000000000000
|
||||
#define EAS3_ALL_G 0x400000000000000
|
||||
#define EAS3_FULL_G 0x500000000000000
|
||||
#define EAS3_NO_G 0x100000000000000
|
||||
#define EAS3_X0DX_G 0x200000000000000
|
||||
#define EAS3_UDEF_G 0x300000000000000
|
||||
#define EAS3_ALL_G 0x400000000000000
|
||||
#define EAS3_FULL_G 0x500000000000000
|
||||
|
||||
#define EAS3_NO_UDEF 0x100000000000000
|
||||
#define EAS3_ALL_UDEF 0x200000000000000
|
||||
#define EAS3_INT_UDEF 0x300000000000000
|
||||
#define EAS3_NO_UDEF 0x100000000000000
|
||||
#define EAS3_ALL_UDEF 0x200000000000000
|
||||
#define EAS3_INT_UDEF 0x300000000000000
|
||||
|
||||
#define AUX_SIZE 0x8000
|
||||
#define AUX_SIZE 0x8000
|
||||
|
||||
/************************************************************************************************************\
|
||||
|| ___ _ _ ___ ____ ____ ||
|
||||
|| | \_/ |__] |___ [__ ||
|
||||
|| | | | |___ ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************************/
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! STRUCT NAME: eas3_header !
|
||||
! ----------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! This structure is used to store the eas3 header information. For a more thorough discussion !
|
||||
! of the eas3 datatype see: !
|
||||
! !
|
||||
! https://wiki.iag.uni-stuttgart.de/eas3wiki/index.php/EAS3_File_Format/de !
|
||||
! !
|
||||
! PARAMETERS: !
|
||||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! file_type unsigned int(64 bit) - Defines an identifier for the EAS type. !
|
||||
! !
|
||||
! accuracy unsigned int(64 bit) - Defines the accuracy of an eas3 file. !
|
||||
! !
|
||||
! nzs unsigned int(64 bit) - Variable defining the temporal size of !
|
||||
! the uncompressed dataset. !
|
||||
! !
|
||||
! npar unsigned int(64 bit) - Defines the number of parameters in the !
|
||||
! eas3 dataset. !
|
||||
! !
|
||||
! ndim1, -2, -3 unsigned int(64 bit) - Variables defining the spatial size of !
|
||||
! the eas3 dataset. !
|
||||
! !
|
||||
! attribute_mode; unsigned int(64 bit) - Defines an identifier used to signal !
|
||||
! the attribute mode of the eas3 file. !
|
||||
! !
|
||||
! gmode_time unsigned int(64 bit) - Defines the geometry mode for the temp- !
|
||||
! oral dimension. !
|
||||
! !
|
||||
! gmode_param unsigned int(64 bit) - Defines the geometry mode for the para- !
|
||||
! meters. !
|
||||
! !
|
||||
! gmode_dim1 unsigned int(64 bit) - Defines the geometry mode for the first !
|
||||
! spatial dimension. !
|
||||
! !
|
||||
! gmode_dim2 unsigned int(64 bit) - Defines the geometry mode for the sec- !
|
||||
! ond spatial dimension. !
|
||||
! !
|
||||
! gmode_dim3 unsigned int(64 bit) - Defines the geometry mode for the third !
|
||||
! spatial dimension. !
|
||||
! !
|
||||
! size_time unsigned int(64 bit) - Defines the geometry array size for the !
|
||||
! temporal dimension. !
|
||||
! !
|
||||
! size_parameter unsigned int(64 bit) - Defines the geometry array size for the !
|
||||
! parameters. !
|
||||
! !
|
||||
! size_dim1 unsigned int(64 bit) - Defines the geometry array size for the !
|
||||
! first spatial dimension. !
|
||||
! !
|
||||
! size_dim2 unsigned int(64 bit) - Defines the geometry array size for the !
|
||||
! second spatial dimension. !
|
||||
! !
|
||||
! size_dim3 unsigned int(64 bit) - Defines the geometry array size for the !
|
||||
! third spatial dimension. !
|
||||
! !
|
||||
! udef_param unsigned int(64 bit) - Defines a marker used to signal which !
|
||||
! user defined parameters are present in !
|
||||
! the eas3 file. !
|
||||
! !
|
||||
! udef_char_size unsigned int(64 bit) - Defines the size for the user defined !
|
||||
! char array. !
|
||||
! !
|
||||
! udef_int_size unsigned int(64 bit) - Defines the size for the user defined !
|
||||
! int array. !
|
||||
! !
|
||||
! udef_real_size unsigned int(64 bit) - Defines the size for the user defined !
|
||||
! real array. !
|
||||
! !
|
||||
! DEPENDENCIES: !
|
||||
! ------------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! - - - !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
! !
|
||||
! Date Author Change Id Release Description Of Change !
|
||||
! ---- ------ --------- ------- --------------------- !
|
||||
! 20.06.2018 Patrick Vogler B87D120 V 0.1.0 struct created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t file_type;
|
||||
uint64_t accuracy;
|
||||
uint64_t nzs;
|
||||
uint64_t npar;
|
||||
uint64_t ndim1;
|
||||
uint64_t ndim2;
|
||||
uint64_t ndim3;
|
||||
uint64_t attribute_mode;
|
||||
uint64_t gmode_time;
|
||||
uint64_t gmode_param;
|
||||
uint64_t gmode_dim1;
|
||||
uint64_t gmode_dim2;
|
||||
uint64_t gmode_dim3;
|
||||
uint64_t size_time;
|
||||
uint64_t size_parameter;
|
||||
uint64_t size_dim1;
|
||||
uint64_t size_dim2;
|
||||
uint64_t size_dim3;
|
||||
uint64_t udef_param;
|
||||
uint64_t udef_char_size;
|
||||
uint64_t udef_int_size;
|
||||
uint64_t udef_real_size;
|
||||
} eas3_std_params;
|
||||
|
||||
/************************************************************************************************************\
|
||||
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|
||||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|
||||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************************/
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: bwc_data* read_eas3(const char* const filename) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! 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 !
|
||||
! structure. !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
bwc_data*
|
||||
read_eas3(char *const filename);
|
||||
/************************************************************************************************************\
|
||||
|| ___ _ _ ___ ____ ____ ||
|
||||
|| | \_/ |__] |___ [__ ||
|
||||
|| | | | |___ ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************************/
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! !
|
||||
! This structure is used to read/assemble a packed codestream during coding. The !
|
||||
! byte buffer is flushed to the packed stream as soon as the a single byte has !
|
||||
! been assembled. !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uchar error; // Error flag used during streaming.
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: uchar write_eas3(bwc_data *const file, char *const filename) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! This function creates a valid eas3 file from the information stored in the bwc_data !
|
||||
! structure. !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
write_eas3(bwc_data *const file, char *const filename);
|
||||
uint64 L; // Number of bytes written to/from stream.
|
||||
uint64 Lmax; // Size of packed stream.
|
||||
uint64 size_incr; // Size incrmnt used for stream assembly.
|
||||
|
||||
uint8 T; // Byte buffer.
|
||||
int8 t; // Byte buffer counter.
|
||||
|
||||
uchar *memory; // Memory handle for packed stream chunck.
|
||||
} bitstream;
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! STRUCT NAME: eas3_header !
|
||||
! ----------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! This structure is used to store the eas3 header information. For a more thorough discussion !
|
||||
! of the eas3 datatype see: !
|
||||
! !
|
||||
! https://wiki.iag.uni-stuttgart.de/eas3wiki/index.php/EAS3_File_Format/de !
|
||||
! !
|
||||
! PARAMETERS: !
|
||||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! file_type unsigned int(64 bit) - Defines an identifier for the EAS type. !
|
||||
! !
|
||||
! accuracy unsigned int(64 bit) - Defines the accuracy of an eas3 file. !
|
||||
! !
|
||||
! nzs unsigned int(64 bit) - Variable defining the temporal size of !
|
||||
! the uncompressed dataset. !
|
||||
! !
|
||||
! npar unsigned int(64 bit) - Defines the number of parameters in the !
|
||||
! eas3 dataset. !
|
||||
! !
|
||||
! ndim1, -2, -3 unsigned int(64 bit) - Variables defining the spatial size of !
|
||||
! the eas3 dataset. !
|
||||
! !
|
||||
! attribute_mode; unsigned int(64 bit) - Defines an identifier used to signal !
|
||||
! the attribute mode of the eas3 file. !
|
||||
! !
|
||||
! gmode_time unsigned int(64 bit) - Defines the geometry mode for the temp- !
|
||||
! oral dimension. !
|
||||
! !
|
||||
! gmode_param unsigned int(64 bit) - Defines the geometry mode for the para- !
|
||||
! meters. !
|
||||
! !
|
||||
! gmode_dim1 unsigned int(64 bit) - Defines the geometry mode for the first !
|
||||
! spatial dimension. !
|
||||
! !
|
||||
! gmode_dim2 unsigned int(64 bit) - Defines the geometry mode for the sec- !
|
||||
! ond spatial dimension. !
|
||||
! !
|
||||
! gmode_dim3 unsigned int(64 bit) - Defines the geometry mode for the third !
|
||||
! spatial dimension. !
|
||||
! !
|
||||
! size_time unsigned int(64 bit) - Defines the geometry array size for the !
|
||||
! temporal dimension. !
|
||||
! !
|
||||
! size_parameter unsigned int(64 bit) - Defines the geometry array size for the !
|
||||
! parameters. !
|
||||
! !
|
||||
! size_dim1 unsigned int(64 bit) - Defines the geometry array size for the !
|
||||
! first spatial dimension. !
|
||||
! !
|
||||
! size_dim2 unsigned int(64 bit) - Defines the geometry array size for the !
|
||||
! second spatial dimension. !
|
||||
! !
|
||||
! size_dim3 unsigned int(64 bit) - Defines the geometry array size for the !
|
||||
! third spatial dimension. !
|
||||
! !
|
||||
! udef_param unsigned int(64 bit) - Defines a marker used to signal which !
|
||||
! user defined parameters are present in !
|
||||
! the eas3 file. !
|
||||
! !
|
||||
! udef_char_size unsigned int(64 bit) - Defines the size for the user defined !
|
||||
! char array. !
|
||||
! !
|
||||
! udef_int_size unsigned int(64 bit) - Defines the size for the user defined !
|
||||
! int array. !
|
||||
! !
|
||||
! udef_real_size unsigned int(64 bit) - Defines the size for the user defined !
|
||||
! real array. !
|
||||
! !
|
||||
! DEPENDENCIES: !
|
||||
! ------------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! - - - !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
! !
|
||||
! Date Author Change Id Release Description Of Change !
|
||||
! ---- ------ --------- ------- --------------------- !
|
||||
! 20.06.2018 Patrick Vogler B87D120 V 0.1.0 struct created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint64_t file_type;
|
||||
uint64_t accuracy;
|
||||
uint64_t nzs;
|
||||
uint64_t npar;
|
||||
uint64_t ndim1;
|
||||
uint64_t ndim2;
|
||||
uint64_t ndim3;
|
||||
uint64_t attribute_mode;
|
||||
uint64_t gmode_time;
|
||||
uint64_t gmode_param;
|
||||
uint64_t gmode_dim1;
|
||||
uint64_t gmode_dim2;
|
||||
uint64_t gmode_dim3;
|
||||
uint64_t size_time;
|
||||
uint64_t size_parameter;
|
||||
uint64_t size_dim1;
|
||||
uint64_t size_dim2;
|
||||
uint64_t size_dim3;
|
||||
uint64_t udef_param;
|
||||
uint64_t udef_char_size;
|
||||
uint64_t udef_int_size;
|
||||
uint64_t udef_real_size;
|
||||
} eas3_std_params;
|
||||
|
||||
/************************************************************************************************************\
|
||||
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|
||||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|
||||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************************/
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: bwc_data* read_eas3(const char* const filename) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! 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 !
|
||||
! structure. !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
bwc_data*
|
||||
read_eas3(char *const filename);
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: uchar write_eas3(bwc_data *const file, char *const filename) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! This function creates a valid eas3 file from the information stored in the bwc_data !
|
||||
! structure. !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
write_eas3(bwc_data *const file, char *const filename);
|
||||
#endif
|
|
@ -54,41 +54,71 @@
|
|||
\************************************************************************************************/
|
||||
#include "types.h"
|
||||
|
||||
/************************************************************************************************\
|
||||
|| ___ ____ ____ ____ _ _ _ ____ ___ ___ _ _ ___ ____ ____ ||
|
||||
|| | \ |___ |__/ |__/ | | | |___ | \ | \_/ |__] |___ [__ ||
|
||||
|| |__/ |___ | \ | \ | \/ |___ |__/ | | | |___ ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************/
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! !
|
||||
! This structure is used to read/assemble a packed codestream during coding. The !
|
||||
! byte buffer is flushed to the packed stream as soon as the a single byte has !
|
||||
! been assembled. !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uchar error; // Error flag used during streaming.
|
||||
|
||||
uint64 L; // Number of bytes written to/from stream.
|
||||
uint64 Lmax; // Size of packed stream.
|
||||
uint64 size_incr; // Size incrmnt used for stream assembly.
|
||||
|
||||
uint8 T; // Byte buffer.
|
||||
int8 t; // Byte buffer counter.
|
||||
|
||||
uchar *memory; // Memory handle for packed stream chunck.
|
||||
} bitstream;
|
||||
|
||||
/************************************************************************************************\
|
||||
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|
||||
|| |__] | | |__] | | | |___ | | |\ | | | | | | |\ | [__ ||
|
||||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************/
|
||||
uint64 bytes_used (bwc_stream const *const stream);
|
||||
uint64 bytes_used (bitstream const *const stream);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
bwc_stream* bwc_init_stream (uchar *const memory,
|
||||
bitstream* init_stream (uchar *const memory,
|
||||
uint32 const size,
|
||||
char const instr);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
void bwc_emit_chunck (bwc_stream *const stream,
|
||||
void emit_chunck (bitstream *const stream,
|
||||
uchar const *const chunck,
|
||||
uint64 const size);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
void bwc_emit_symbol (bwc_stream *const stream,
|
||||
void emit_symbol (bitstream *const stream,
|
||||
uint64 const symbol,
|
||||
uint8 const size);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
void bwc_emit_bit (bwc_stream *const stream,
|
||||
void emit_bit (bitstream *const stream,
|
||||
uint64 const bit);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
void flush_stream (bwc_stream *const stream);
|
||||
void flush_stream (bitstream *const stream);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
uchar* bwc_get_chunck (bwc_stream *const stream,
|
||||
uchar* get_chunck (bitstream *const stream,
|
||||
uint64 const length);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
uint64 bwc_get_symbol (bwc_stream *const stream,
|
||||
uint64 get_symbol (bitstream *const stream,
|
||||
uint8 const length);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
uchar bwc_get_bit (bwc_stream *const stream);
|
||||
uchar get_bit (bitstream *const stream);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
uchar bwc_terminate_stream (bwc_stream *stream,
|
||||
bwc_packed_stream *const packed_stream);
|
||||
uchar terminate_stream (bitstream *stream,
|
||||
bwc_stream *const packed_stream);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
void release_packed_stream (bwc_packed_stream *const stream);
|
||||
#endif
|
||||
void release_packed_stream (bwc_stream *const stream);
|
||||
#endif
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
|| ||
|
||||
\************************************************************************************************/
|
||||
#include "types.h"
|
||||
#include "bitstream.h"
|
||||
|
||||
/************************************************************************************************\
|
||||
|| _ _ ____ ____ ____ ____ ____ ||
|
||||
|
@ -67,7 +68,7 @@
|
|||
! ------------ !
|
||||
! !
|
||||
! These macros define stream manipulation operations to rewind, forward, inquire !
|
||||
! the availability and get access to the current memory position of a bwc_stream. !
|
||||
! the availability and get access to the current memory position of a bitstrean. !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------*/
|
||||
#define rewind_stream(stream, delta) \
|
||||
|
@ -90,17 +91,13 @@
|
|||
\************************************************************************************************/
|
||||
uchar assemble_main_header (bwc_field *const field);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
bwc_field* bwc_parse_main_header (bwc_data *const data,
|
||||
bwc_stream *const stream);
|
||||
uchar codestream_write_aux (bwc_stream *const header,
|
||||
bwc_stream *const aux);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
uchar codestream_write_aux (bwc_packed_stream *const header,
|
||||
bwc_packed_stream *const aux);
|
||||
uchar codestream_write_com (bwc_stream *const header,
|
||||
bwc_stream *const com);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
uchar codestream_write_com (bwc_packed_stream *const header,
|
||||
bwc_packed_stream *const com);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
bwc_packed_stream* assemble_codestream (bwc_field *const field);
|
||||
|
||||
bwc_stream* assemble_codestream (bwc_field *const field);
|
||||
//==========|==========================|======================|======|======|=====================
|
||||
bwc_field* parse_codestream (bwc_data *const data,
|
||||
uint8 const layer);
|
||||
|
|
|
@ -58,21 +58,21 @@
|
|||
|| | | \ | | | | | | \/ |___ | | | |___ ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************/
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
|
||||
typedef int8_t int8;
|
||||
typedef uint8_t uint8;
|
||||
typedef int16_t int16;
|
||||
typedef uint16_t uint16;
|
||||
typedef int32_t int32;
|
||||
typedef uint32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
typedef int8_t int8;
|
||||
typedef uint8_t uint8;
|
||||
typedef int16_t int16;
|
||||
typedef uint16_t uint16;
|
||||
typedef int32_t int32;
|
||||
typedef uint32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
|
||||
typedef double bwc_float;
|
||||
typedef uint64 bwc_raw;
|
||||
typedef double bwc_float;
|
||||
typedef uint64 bwc_raw;
|
||||
|
||||
/************************************************************************************************\
|
||||
|| _ _ ____ ____ ____ ____ ____ ||
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
|| ||
|
||||
\************************************************************************************************/
|
||||
#include "types.h"
|
||||
#include "bitstream.h"
|
||||
|
||||
/************************************************************************************************\
|
||||
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|
||||
|
@ -83,13 +84,13 @@
|
|||
uint16 const value);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
void encode_tagtree (bwc_tagtree *const tagtree,
|
||||
bwc_stream *const stream,
|
||||
bitstream *const stream,
|
||||
uint32 const threshold,
|
||||
uint32 const leaf_index,
|
||||
uchar const estimate);
|
||||
//==========|==========================|======================|======|=======|====================
|
||||
uchar decode_tagtree (bwc_tagtree *const tagtree,
|
||||
bwc_stream *const stream,
|
||||
bitstream *const stream,
|
||||
uint32 const threshold,
|
||||
uint32 const leaf_index);
|
||||
#endif
|
|
@ -54,7 +54,6 @@
|
|||
\************************************************************************************************/
|
||||
#include "types.h"
|
||||
|
||||
|
||||
/************************************************************************************************\
|
||||
|| _ _ ____ ____ ____ ____ ____ ||
|
||||
|| |\/| |__| | |__/ | | [__ ||
|
||||
|
|
|
@ -99,33 +99,8 @@
|
|||
|
||||
uchar *access; // Pointer used to parse packed stream.
|
||||
uchar *memory; // Memory handle for the packed stream.
|
||||
} bwc_packed_stream;
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! !
|
||||
! This structure is used to read/assemble a packed codestream during coding. The !
|
||||
! byte buffer is flushed to the packed stream as soon as the a single byte has !
|
||||
! been assembled. !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uchar error; // Error flag used during streaming.
|
||||
|
||||
uint64 L; // Number of bytes written to/from stream.
|
||||
uint64 Lmax; // Size of packed stream.
|
||||
uint64 size_incr; // Size incrmnt used for stream assembly.
|
||||
|
||||
uint8 T; // Byte buffer.
|
||||
int8 t; // Byte buffer counter.
|
||||
|
||||
uchar *memory; // Memory handle for packed stream chunck.
|
||||
} bwc_stream;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -227,9 +202,9 @@
|
|||
|
||||
struct codestream
|
||||
{
|
||||
bwc_packed_stream *data; // Data codestream block.
|
||||
bwc_packed_stream *aux; // Auxiliary info. codestream block.
|
||||
bwc_packed_stream *com; // Comment codestream block.
|
||||
bwc_stream *data; // Data codestream block.
|
||||
bwc_stream *aux; // Auxiliary info. codestream block.
|
||||
bwc_stream *com; // Comment codestream block.
|
||||
}codestream;
|
||||
|
||||
struct field
|
||||
|
@ -445,8 +420,8 @@
|
|||
\*----------------------------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
bwc_packed_stream header; // Packed stream header.
|
||||
bwc_packed_stream body; // Packed stream body.
|
||||
bwc_stream header; // Packed stream header.
|
||||
bwc_stream body; // Packed stream body.
|
||||
uint8 e; // Indicator for packet cb. contributions.
|
||||
|
||||
uint32 size; // Codestream packet size.
|
||||
|
@ -714,7 +689,7 @@
|
|||
|
||||
uint8 guard_bits; // Number of guard bits during quant.
|
||||
|
||||
bwc_packed_stream header; // Main codestream header.
|
||||
bwc_stream header; // Main codestream header.
|
||||
|
||||
bwc_quant_st quantization_style; // Quantization style.
|
||||
bwc_prog_ord progression; // Packet progression order.
|
||||
|
|
|
@ -84,6 +84,423 @@
|
|||
|| | | \ | \/ | | | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
||||
|| ||
|
||||
\************************************************************************************************************/
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: uint32 bytes_used(bitstream *const stream) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! This function is used to evaluate the number of bytes that have already been !
|
||||
! written to the allocated bitstream memory block. !
|
||||
! !
|
||||
! PARAMETERS: !
|
||||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! stream bitstream* - Structure that !
|
||||
! !
|
||||
! RETURN VALUE: !
|
||||
! ------------- !
|
||||
! Type Description !
|
||||
! ---- ----------- !
|
||||
! unsigned int(32 bit) - Number of bites that have been written to the !
|
||||
! bitstream. !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
! !
|
||||
! Date Author Change Id Release Description Of Change !
|
||||
! ---- ------ --------- ------- --------------------- !
|
||||
! 13.05.2019 Patrick Vogler B87D120 V 0.1.0 function created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uint64
|
||||
bytes_used(bitstream const *const stream)
|
||||
{
|
||||
if(stream->T == 0xFF)
|
||||
{
|
||||
return stream->L + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return stream->L;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: bitstream* bwc_init_stream(uchar* memory, uint32 size, char instr) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! This function is used to initialize a bwc bitstream. For encoding, a null pointer !
|
||||
! is passed as a memory handle and the function will allocate a memory block with the !
|
||||
! specified stream size. For decoding, a valid memory handle, passed by the function !
|
||||
! caller, will be stored in the bitstream structure. The byte buffer counter t, !
|
||||
! stream size Lmax and size increment are initialized with their appropriate values. !
|
||||
! !
|
||||
! PARAMETERS: !
|
||||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! size unsigned int(32 bit) - Initial size of the bwc stream. !
|
||||
! !
|
||||
! memory unsigned char - Memory handle for the bwc stream memory !
|
||||
! block. !
|
||||
! !
|
||||
! instr char - Constant used to instruct the field !
|
||||
! initialization. !
|
||||
! !
|
||||
! RETURN VALUE: !
|
||||
! ------------- !
|
||||
! Type Description !
|
||||
! ---- ----------- !
|
||||
! bitstream* - Memory handle for the initialized bwc stream. !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
! !
|
||||
! Date Author Change Id Release Description Of Change !
|
||||
! ---- ------ --------- ------- --------------------- !
|
||||
! 19.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
bitstream*
|
||||
init_stream(uchar* memory, uint32 size, char instr)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE STRUCTS: !
|
||||
\*-----------------------*/
|
||||
bitstream *stream;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(instr == 'c' || instr == 'd');
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Allocate the bwc stream structure. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream = calloc(1, sizeof(bitstream));
|
||||
if(!stream)
|
||||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Evaluate if a valid memory handle has been passed by the !
|
||||
! function caller. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(!memory)
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! If no valid memory handle has been passed, allocate a !
|
||||
! memory block with the specifiec stream size. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream->memory = calloc(size, sizeof(uchar));
|
||||
if(!stream->memory)
|
||||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! If a valid memory handle has been passed for decoding, !
|
||||
! save the memory handle in the bwc stream structure. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream->memory = memory;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Initialize the byte buffer counter, stream size and size !
|
||||
! increment for the current stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream->t = (instr == 'c') ? 8 : 0;
|
||||
stream->Lmax = size;
|
||||
stream->size_incr = (uint64)(size / 2);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Return the stream memory handle. !
|
||||
\*--------------------------------------------------------*/
|
||||
return stream;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: void bwc_emit_chunck(bitstream *const stream, const uchar* string, const uint64 length) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! This function is used to write an additional chunck of size length to a bwc bitstream. !
|
||||
! !
|
||||
! !
|
||||
! PARAMETERS: !
|
||||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! stream bitstream* - Structure used to assemble a bwc bit- !
|
||||
! bitstream. !
|
||||
! !
|
||||
! chunck unsigned char* - Memory handle for a data block that is !
|
||||
! to be written to the bwc bitstream. !
|
||||
! !
|
||||
! size unsigned int(64 bit) - Size of the data block. !
|
||||
! !
|
||||
! RETURN VALUE: !
|
||||
! ------------- !
|
||||
! Type Description !
|
||||
! ---- ----------- !
|
||||
! - - !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
! !
|
||||
! Date Author Change Id Release Description Of Change !
|
||||
! ---- ------ --------- ------- --------------------- !
|
||||
! 22.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
void
|
||||
emit_chunck(bitstream *const stream, const uchar* chunck, const uint64 size)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
\*-----------------------*/
|
||||
uint64 Lreq;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(stream);
|
||||
assert(chunck);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Evaluate the memory block size if the current chunck of !
|
||||
! data is written to the stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
Lreq = (bytes_used(stream) + size);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Check if the enough memory has been allocated for the !
|
||||
! stream to store the additional data chunck. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(Lreq > stream->Lmax)
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! If the stream is not large enough, check if this is due !
|
||||
! to an error encountered in a previous writing operation !
|
||||
\*--------------------------------------------------------*/
|
||||
if(!stream->error)
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! If the error flag is not set, increase the stream size !
|
||||
! until it is large enough to store the additional data !
|
||||
! chunck. !
|
||||
\*--------------------------------------------------------*/
|
||||
while(Lreq > stream->Lmax)
|
||||
{
|
||||
stream->Lmax += stream->size_incr + size;
|
||||
stream->size_incr = (uint64)(stream->Lmax / 2);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Reallocate the stream data block. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream->memory = realloc(stream->memory, stream->Lmax);
|
||||
if(!stream->memory)
|
||||
{
|
||||
// memory allocation error
|
||||
stream->error |= 1;
|
||||
stream->Lmax = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Exit to function caller if error flag has been set. !
|
||||
\*--------------------------------------------------------*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Copy the additional data to the stream memory block. !
|
||||
\*--------------------------------------------------------*/
|
||||
memcpy(stream->memory + stream->L, chunck, size);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Increment the number of bytes written to the stream with !
|
||||
! the size of the newly added data chunck. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream->L += size;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: void *test(void) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! DESCRIPTION NEEDED !
|
||||
! !
|
||||
! PARAMETERS: !
|
||||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! stream bitstream* - Structure used to assemble a bwc bit- !
|
||||
! bitstream. !
|
||||
! !
|
||||
! size unsigned int(64 bit) - Size of the data block. !
|
||||
! !
|
||||
! RETURN VALUE: !
|
||||
! ------------- !
|
||||
! Type Description !
|
||||
! ---- ----------- !
|
||||
! uchar* - Data chunck requested by the function caller. !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
! !
|
||||
! Date Author Change Id Release Description Of Change !
|
||||
! ---- ------ --------- ------- --------------------- !
|
||||
! 22.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar*
|
||||
get_chunck(bitstream *const stream, const uint64 size)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE CHAR VARIABLES: !
|
||||
\*-----------------------*/
|
||||
uchar *tmp;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(stream);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Check if the number of bytes to be read from the stream !
|
||||
! does not exceed the number of bytes still present in its !
|
||||
! memory block. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(bytes_used(stream) + size <= stream->Lmax)
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! Allocate a temporary array used to store the bytes that !
|
||||
! are extracted from the stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
tmp = calloc(size, sizeof(uchar));
|
||||
if(!tmp)
|
||||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Copy the bytes requested from the function caller from !
|
||||
! the stream to the temporary data block. !
|
||||
\*--------------------------------------------------------*/
|
||||
memcpy(tmp, stream->memory + stream->L, size);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Increment the number of bytes read from the bitstream. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream->L += size;
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Return the temporary data block to the function caller. !
|
||||
\*--------------------------------------------------------*/
|
||||
return tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*--------------------------------------------------------*\
|
||||
! If the requested block size exceeds the information left !
|
||||
! in the bitstream, set the bitstream error flag and !
|
||||
! return a NULL pointer. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream->error |= 1;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: void *test(void) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
! ------------ !
|
||||
! DESCRIPTION NEEDED !
|
||||
! !
|
||||
! PARAMETERS: !
|
||||
! ----------- !
|
||||
! Variable Type Description !
|
||||
! -------- ---- ----------- !
|
||||
! - - - !
|
||||
! !
|
||||
! RETURN VALUE: !
|
||||
! ------------- !
|
||||
! Type Description !
|
||||
! ---- ----------- !
|
||||
! - - !
|
||||
! !
|
||||
! DEVELOPMENT HISTORY: !
|
||||
! -------------------- !
|
||||
! !
|
||||
! Date Author Change Id Release Description Of Change !
|
||||
! ---- ------ --------- ------- --------------------- !
|
||||
! - Patrick Vogler B87D120 V 0.1.0 function created !
|
||||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
terminate_stream(bitstream *stream, bwc_stream *const packed_stream)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
\*-----------------------*/
|
||||
assert(stream);
|
||||
|
||||
if(packed_stream)
|
||||
{
|
||||
if(stream->error)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if(stream->L != stream->Lmax)
|
||||
{
|
||||
stream->Lmax = stream->L;
|
||||
stream->memory = realloc(stream->memory, stream->Lmax);
|
||||
if(!stream->memory)
|
||||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
stream->Lmax = 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
packed_stream->memory = stream->memory;
|
||||
packed_stream->access = stream->memory;
|
||||
packed_stream->size = stream->L;
|
||||
packed_stream->position = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
free(stream->memory);
|
||||
}
|
||||
|
||||
free(stream);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -222,7 +639,7 @@ read_eas3_header(bwc_data *const data)
|
|||
! DEFINE STRUCTS: !
|
||||
\*-----------------------*/
|
||||
bwc_gl_inf *info;
|
||||
bwc_stream *aux;
|
||||
bitstream *aux;
|
||||
eas3_std_params params;
|
||||
|
||||
/*-----------------------*\
|
||||
|
@ -284,7 +701,7 @@ read_eas3_header(bwc_data *const data)
|
|||
/*--------------------------------------------------------*\
|
||||
! Allocate the auxiliary information packed stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
data->codestream.aux = calloc(1, sizeof(bwc_packed_stream));
|
||||
data->codestream.aux = calloc(1, sizeof(bwc_stream));
|
||||
if(!data->codestream.aux)
|
||||
{
|
||||
// memory allocation error
|
||||
|
@ -299,7 +716,7 @@ read_eas3_header(bwc_data *const data)
|
|||
! block has been chosen arbitrarily and should be large !
|
||||
! enough to prevent excessive reallocation. !
|
||||
\*--------------------------------------------------------*/
|
||||
aux = bwc_init_stream(NULL, AUX_SIZE, 'c');
|
||||
aux = init_stream(NULL, AUX_SIZE, 'c');
|
||||
if(!aux)
|
||||
{
|
||||
// memory allocation error
|
||||
|
@ -346,7 +763,7 @@ read_eas3_header(bwc_data *const data)
|
|||
! Emit the standard parameters to the auxiliary informa- !
|
||||
! tion information memory block. !
|
||||
\*--------------------------------------------------------*/
|
||||
bwc_emit_chunck(aux, (uchar*)¶ms, 176);
|
||||
emit_chunck(aux, (uchar*)¶ms, 176);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Convert the parameters required for the bwc compression !
|
||||
|
@ -423,7 +840,7 @@ read_eas3_header(bwc_data *const data)
|
|||
! Emit the time step array to the auxiliary information !
|
||||
! memory block. !
|
||||
\*--------------------------------------------------------*/
|
||||
bwc_emit_chunck(aux, buffer_char, info->nTS * sizeof(uint64));
|
||||
emit_chunck(aux, buffer_char, info->nTS * sizeof(uint64));
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Check if any attributes have been specified in the eas3 !
|
||||
|
@ -456,7 +873,7 @@ read_eas3_header(bwc_data *const data)
|
|||
! Emit the timestep attribute array to the auxiliary infor-!
|
||||
! mation memory block. !
|
||||
\*--------------------------------------------------------*/
|
||||
bwc_emit_chunck(aux, buffer_char, info->nTS * ATTRLEN * sizeof(char));
|
||||
emit_chunck(aux, buffer_char, info->nTS * ATTRLEN * sizeof(char));
|
||||
|
||||
for(i = 0; i < info->nPar; ++i)
|
||||
{
|
||||
|
@ -527,7 +944,7 @@ read_eas3_header(bwc_data *const data)
|
|||
! Emit the remaining header information the the auxiliary !
|
||||
! information stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
bwc_emit_chunck(aux, buffer_char, Lread);
|
||||
emit_chunck(aux, buffer_char, Lread);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Free the buffer character array. !
|
||||
|
@ -539,7 +956,7 @@ read_eas3_header(bwc_data *const data)
|
|||
! ful, the address to the aux memory block stored is !
|
||||
! stored in the file structure alongside its size. !
|
||||
\*--------------------------------------------------------*/
|
||||
if(bwc_terminate_stream(aux, data->codestream.aux))
|
||||
if(terminate_stream(aux, data->codestream.aux))
|
||||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
|
@ -600,7 +1017,7 @@ write_eas3_header(bwc_data *const data)
|
|||
! DEFINE STRUCTS: !
|
||||
\*-----------------------*/
|
||||
bwc_gl_inf *info;
|
||||
bwc_stream *aux;
|
||||
bitstream *aux;
|
||||
eas3_std_params *params;
|
||||
bwc_cmd_opts_ll *param;
|
||||
|
||||
|
@ -634,14 +1051,14 @@ write_eas3_header(bwc_data *const data)
|
|||
/*--------------------------------------------------------*\
|
||||
! Initialize the auxiliary information stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
aux = bwc_init_stream(data->codestream.aux->memory,
|
||||
data->codestream.aux->size, 'd');
|
||||
aux = init_stream(data->codestream.aux->memory,
|
||||
data->codestream.aux->size, 'd');
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Get the standard parameters from the auxiliary informa- !
|
||||
! memory block and write them to the file stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
params = (eas3_std_params*)bwc_get_chunck(aux, 176);
|
||||
params = (eas3_std_params*)get_chunck(aux, 176);
|
||||
|
||||
if(fwrite(params, sizeof(uint64), 22, fp) != 22)
|
||||
{
|
||||
|
@ -669,7 +1086,7 @@ write_eas3_header(bwc_data *const data)
|
|||
! the timestep array from the auxiliary information block !
|
||||
! and write it to the file stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
buffer_char = bwc_get_chunck(aux, info->nTS * sizeof(uint64));
|
||||
buffer_char = get_chunck(aux, info->nTS * sizeof(uint64));
|
||||
if(!buffer_char)
|
||||
{
|
||||
// memory allocation error
|
||||
|
@ -698,7 +1115,7 @@ write_eas3_header(bwc_data *const data)
|
|||
! the timestep attribute array from the auxiliary informa- !
|
||||
! tion block and write it to the file stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
buffer_char = bwc_get_chunck(aux, info->nTS * ATTRLEN);
|
||||
buffer_char = get_chunck(aux, info->nTS * ATTRLEN);
|
||||
if(!buffer_char)
|
||||
{
|
||||
// memory allocation error
|
||||
|
@ -762,7 +1179,7 @@ write_eas3_header(bwc_data *const data)
|
|||
! the remaining eas header bytes from the auxiliary infor- !
|
||||
! mation block and write it to the file stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
buffer_char = bwc_get_chunck(aux, Lwrite);
|
||||
buffer_char = get_chunck(aux, Lwrite);
|
||||
if(!buffer_char)
|
||||
{
|
||||
// memory allocation error
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -612,7 +612,7 @@ initialize_subband(bwc_field *const field, bwc_parameter *const parameter, bwc_r
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: void bwc_header_append_aux(bwc_field *const field, bwc_packed_stream *const aux) !
|
||||
! FUNCTION NAME: void bwc_header_append_aux(bwc_field *const field, bwc_stream *const aux) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -647,7 +647,7 @@ initialize_subband(bwc_field *const field, bwc_parameter *const parameter, bwc_r
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static uchar
|
||||
header_append_aux(bwc_field *const field, bwc_packed_stream *const aux)
|
||||
header_append_aux(bwc_field *const field, bwc_stream *const aux)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE STRUCTS: !
|
||||
|
@ -714,7 +714,7 @@ header_append_aux(bwc_field *const field, bwc_packed_stream *const aux)
|
|||
}
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: void bwc_header_append_com(bwc_field *const field, bwc_packed_stream *const com) !
|
||||
! FUNCTION NAME: void bwc_header_append_com(bwc_field *const field, bwc_stream *const com) !
|
||||
! -------------- !
|
||||
! !
|
||||
! DESCRIPTION: !
|
||||
|
@ -749,7 +749,7 @@ header_append_aux(bwc_field *const field, bwc_packed_stream *const aux)
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static uchar
|
||||
header_append_com(bwc_field *const field, bwc_packed_stream *const com)
|
||||
header_append_com(bwc_field *const field, bwc_stream *const com)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE STRUCTS: !
|
||||
|
|
|
@ -419,7 +419,7 @@ initialize_tagtree(const uint64 leafsX, const uint64 leafsY, const uint64 leafsZ
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
void
|
||||
encode_tagtree(bwc_tagtree *const tagtree, bwc_stream *const stream, const uint32 threshold, const uint32 leaf_index, const uchar estimate)
|
||||
encode_tagtree(bwc_tagtree *const tagtree, bitstream *const stream, const uint32 threshold, const uint32 leaf_index, const uchar estimate)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -461,11 +461,11 @@ encode_tagtree(bwc_tagtree *const tagtree, bwc_stream *const stream, const uint3
|
|||
threshold_tmp++;
|
||||
if(node->value >= threshold_tmp)
|
||||
{
|
||||
bwc_emit_bit(stream, 0);
|
||||
emit_bit(stream, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bwc_emit_bit(stream, 1);
|
||||
emit_bit(stream, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -512,7 +512,7 @@ encode_tagtree(bwc_tagtree *const tagtree, bwc_stream *const stream, const uint3
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
uchar
|
||||
decode_tagtree(bwc_tagtree *const tagtree, bwc_stream *const stream, const uint32 threshold, const uint32 leaf_index)
|
||||
decode_tagtree(bwc_tagtree *const tagtree, bitstream *const stream, const uint32 threshold, const uint32 leaf_index)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -556,7 +556,7 @@ decode_tagtree(bwc_tagtree *const tagtree, bwc_stream *const stream, const uint3
|
|||
while((node->value == node->threshold) && (node->threshold < threshold))
|
||||
{
|
||||
node->threshold++;
|
||||
if(!bwc_get_bit(stream))
|
||||
if(!get_bit(stream))
|
||||
{
|
||||
node->value++;
|
||||
}
|
||||
|
|
|
@ -99,71 +99,71 @@
|
|||
{ \
|
||||
if(delta_z == 1) \
|
||||
{ \
|
||||
bwc_emit_bit(stream, 0); \
|
||||
emit_bit(stream, 0); \
|
||||
} \
|
||||
else if(delta_z == 2) \
|
||||
{ \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 0); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 0); \
|
||||
} \
|
||||
else if(delta_z < 6) \
|
||||
{ \
|
||||
delta_z -= 3; \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 0x02 & delta_z); \
|
||||
bwc_emit_bit(stream, 0x01 & delta_z); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 0x02 & delta_z); \
|
||||
emit_bit(stream, 0x01 & delta_z); \
|
||||
} \
|
||||
else if(delta_z < 37) \
|
||||
{ \
|
||||
delta_z -= 6; \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 0x10 & delta_z); \
|
||||
bwc_emit_bit(stream, 0x08 & delta_z); \
|
||||
bwc_emit_bit(stream, 0x04 & delta_z); \
|
||||
bwc_emit_bit(stream, 0x02 & delta_z); \
|
||||
bwc_emit_bit(stream, 0x01 & delta_z); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 0x10 & delta_z); \
|
||||
emit_bit(stream, 0x08 & delta_z); \
|
||||
emit_bit(stream, 0x04 & delta_z); \
|
||||
emit_bit(stream, 0x02 & delta_z); \
|
||||
emit_bit(stream, 0x01 & delta_z); \
|
||||
} \
|
||||
else if(delta_z < 293) \
|
||||
{ \
|
||||
delta_z -= 37; \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 1); \
|
||||
bwc_emit_bit(stream, 0x080 & delta_z); \
|
||||
bwc_emit_bit(stream, 0x040 & delta_z); \
|
||||
bwc_emit_bit(stream, 0x020 & delta_z); \
|
||||
bwc_emit_bit(stream, 0x010 & delta_z); \
|
||||
bwc_emit_bit(stream, 0x008 & delta_z); \
|
||||
bwc_emit_bit(stream, 0x004 & delta_z); \
|
||||
bwc_emit_bit(stream, 0x002 & delta_z); \
|
||||
bwc_emit_bit(stream, 0x001 & delta_z); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 1); \
|
||||
emit_bit(stream, 0x080 & delta_z); \
|
||||
emit_bit(stream, 0x040 & delta_z); \
|
||||
emit_bit(stream, 0x020 & delta_z); \
|
||||
emit_bit(stream, 0x010 & delta_z); \
|
||||
emit_bit(stream, 0x008 & delta_z); \
|
||||
emit_bit(stream, 0x004 & delta_z); \
|
||||
emit_bit(stream, 0x002 & delta_z); \
|
||||
emit_bit(stream, 0x001 & delta_z); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define decode_delta_z(stream, delta_z) \
|
||||
{ \
|
||||
if(!bwc_get_bit(stream)) \
|
||||
if(!get_bit(stream)) \
|
||||
{ \
|
||||
delta_z = 1; \
|
||||
} \
|
||||
else if(!bwc_get_bit(stream)) \
|
||||
else if(!get_bit(stream)) \
|
||||
{ \
|
||||
delta_z = 2; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
delta_z = (bwc_get_bit(stream) << 1) | \
|
||||
bwc_get_bit(stream); \
|
||||
delta_z = (get_bit(stream) << 1) | \
|
||||
get_bit(stream); \
|
||||
\
|
||||
if(delta_z < 3) \
|
||||
{ \
|
||||
|
@ -171,11 +171,11 @@
|
|||
} \
|
||||
else \
|
||||
{ \
|
||||
delta_z = (bwc_get_bit(stream) << 4) | \
|
||||
(bwc_get_bit(stream) << 3) | \
|
||||
(bwc_get_bit(stream) << 2) | \
|
||||
(bwc_get_bit(stream) << 1) | \
|
||||
bwc_get_bit(stream); \
|
||||
delta_z = (get_bit(stream) << 4) | \
|
||||
(get_bit(stream) << 3) | \
|
||||
(get_bit(stream) << 2) | \
|
||||
(get_bit(stream) << 1) | \
|
||||
get_bit(stream); \
|
||||
\
|
||||
if(delta_z < 31) \
|
||||
{ \
|
||||
|
@ -183,14 +183,14 @@
|
|||
} \
|
||||
else \
|
||||
{ \
|
||||
delta_z = (bwc_get_bit(stream) << 7) | \
|
||||
(bwc_get_bit(stream) << 6) | \
|
||||
(bwc_get_bit(stream) << 5) | \
|
||||
(bwc_get_bit(stream) << 4) | \
|
||||
(bwc_get_bit(stream) << 3) | \
|
||||
(bwc_get_bit(stream) << 2) | \
|
||||
(bwc_get_bit(stream) << 1) | \
|
||||
bwc_get_bit(stream); \
|
||||
delta_z = (get_bit(stream) << 7) | \
|
||||
(get_bit(stream) << 6) | \
|
||||
(get_bit(stream) << 5) | \
|
||||
(get_bit(stream) << 4) | \
|
||||
(get_bit(stream) << 3) | \
|
||||
(get_bit(stream) << 2) | \
|
||||
(get_bit(stream) << 1) | \
|
||||
get_bit(stream); \
|
||||
\
|
||||
delta_z += 37; \
|
||||
} \
|
||||
|
@ -205,7 +205,7 @@
|
|||
|| ||
|
||||
\************************************************************************************************************/
|
||||
/*----------------------------------------------------------------------------------------------------------*\
|
||||
! FUNCTION NAME: void encode_length(bwc_stream *const header, bwc_codeblock *const codeblock, !
|
||||
! FUNCTION NAME: void encode_length(bitstream *const header, bwc_codeblock *const codeblock, !
|
||||
! -------------- int8 const quality_layer, !
|
||||
! uchar const estimate) !
|
||||
! !
|
||||
|
@ -236,9 +236,9 @@
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static void
|
||||
encode_length(bwc_stream *const header, bwc_codeblock *const codeblock,
|
||||
int8 const quality_layer,
|
||||
uchar const estimate)
|
||||
encode_length(bitstream *const header, bwc_codeblock *const codeblock,
|
||||
int8 const quality_layer,
|
||||
uchar const estimate)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -284,17 +284,17 @@ encode_length(bwc_stream *const header, bwc_codeblock *const codeblock,
|
|||
|
||||
while(beta < max_beta)
|
||||
{
|
||||
bwc_emit_bit(header, 1);
|
||||
emit_bit(header, 1);
|
||||
beta++;
|
||||
}
|
||||
|
||||
bwc_emit_bit(header, 0);
|
||||
emit_bit(header, 0);
|
||||
|
||||
L_bits = 1 << (beta + cp_bits - 1);
|
||||
|
||||
while(L_bits > 0)
|
||||
{
|
||||
bwc_emit_bit(header, L & L_bits);
|
||||
emit_bit(header, L & L_bits);
|
||||
L_bits >>= 1;
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ encode_length(bwc_stream *const header, bwc_codeblock *const codeblock,
|
|||
! !
|
||||
\*----------------------------------------------------------------------------------------------------------*/
|
||||
static void
|
||||
decode_length(bwc_stream *const header, bwc_codeblock *const codeblock, int8 const quality_layer)
|
||||
decode_length(bitstream *const header, bwc_codeblock *const codeblock, int8 const quality_layer)
|
||||
{
|
||||
/*-----------------------*\
|
||||
! DEFINE INT VARIABLES: !
|
||||
|
@ -363,7 +363,7 @@ decode_length(bwc_stream *const header, bwc_codeblock *const codeblock, int8 con
|
|||
cblk_ctrl = &codeblock->control;
|
||||
cp_contr = cblk_ctrl->cp_contr;
|
||||
|
||||
while(bwc_get_bit(header))
|
||||
while(get_bit(header))
|
||||
{
|
||||
cblk_ctrl->beta++;
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ decode_length(bwc_stream *const header, bwc_codeblock *const codeblock, int8 con
|
|||
for(i = 0; L_bits > 0; --L_bits)
|
||||
{
|
||||
i <<= 1;
|
||||
i |= bwc_get_bit(header);
|
||||
i |= get_bit(header);
|
||||
}
|
||||
|
||||
codeblock->encoded_block->L[z_curr] = ((z_prev >= 0) ? codeblock->encoded_block->L[z_prev] : 0) + i;
|
||||
|
@ -455,7 +455,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
|||
bwc_packet *packet;
|
||||
bwc_precinct *precinct;
|
||||
bwc_codeblock *codeblock;
|
||||
bwc_stream *header;
|
||||
bitstream *header;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
|
@ -480,7 +480,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
|||
! Initialize the stream that is used to assemble the pack- !
|
||||
! et header. !
|
||||
\*--------------------------------------------------------*/
|
||||
header = bwc_init_stream(NULL, PACKET_HEADER_SIZE, 'c');
|
||||
header = init_stream(NULL, PACKET_HEADER_SIZE, 'c');
|
||||
if(!header)
|
||||
{
|
||||
// memory allocation error
|
||||
|
@ -496,7 +496,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
|||
if(!est)
|
||||
{
|
||||
packet->body.access =
|
||||
packet->body.memory = calloc(packet->body.size, sizeof(bwc_packed_stream));
|
||||
packet->body.memory = calloc(packet->body.size, sizeof(bwc_stream));
|
||||
if(!packet->body.memory)
|
||||
{
|
||||
// memory allocation error
|
||||
|
@ -509,7 +509,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
|||
! Emit the contribution bit to the packet header that sig- !
|
||||
! nals a non-empty packet body. !
|
||||
\*--------------------------------------------------------*/
|
||||
bwc_emit_bit(header, 1);
|
||||
emit_bit(header, 1);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Iterate over all codeblocks in all subbands to assemble !
|
||||
|
@ -571,7 +571,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
|||
! If a contribution has already been made, transmit a flag !
|
||||
! to signal if new coding passes are to be contributed. !
|
||||
\*--------------------------------------------------------*/
|
||||
bwc_emit_bit(header, delta_z);
|
||||
emit_bit(header, delta_z);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
|
@ -642,7 +642,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
|||
}
|
||||
|
||||
k = header->L;
|
||||
bwc_terminate_stream(header, NULL);
|
||||
terminate_stream(header, NULL);
|
||||
return k;
|
||||
}
|
||||
/*--------------------------------------------------------*\
|
||||
|
@ -653,7 +653,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
|||
\*--------------------------------------------------------*/
|
||||
else
|
||||
{
|
||||
if(bwc_terminate_stream(header, &packet->header))
|
||||
if(terminate_stream(header, &packet->header))
|
||||
{
|
||||
// memory allocation error
|
||||
return -1;
|
||||
|
@ -1375,7 +1375,7 @@ parse_packet(bwc_field *const field, bwc_tile *const tile,
|
|||
bwc_precinct *precinct;
|
||||
bwc_codeblock *codeblock;
|
||||
bwc_encoded_cblk *encoded_block;
|
||||
bwc_stream *header;
|
||||
bitstream *header;
|
||||
|
||||
/*-----------------------*\
|
||||
! DEFINE ASSERTIONS: !
|
||||
|
@ -1390,7 +1390,7 @@ parse_packet(bwc_field *const field, bwc_tile *const tile,
|
|||
! Initialize the stream that is used to parse the packet !
|
||||
! codestream. !
|
||||
\*--------------------------------------------------------*/
|
||||
header = bwc_init_stream(packet->header.memory, body_size, 'd');
|
||||
header = init_stream(packet->header.memory, body_size, 'd');
|
||||
if(!header)
|
||||
{
|
||||
// memory allocation error
|
||||
|
@ -1401,7 +1401,7 @@ parse_packet(bwc_field *const field, bwc_tile *const tile,
|
|||
! Extract the codeblock contribution marker from the code- !
|
||||
! stream. !
|
||||
\*--------------------------------------------------------*/
|
||||
packet->e = bwc_get_bit(header);
|
||||
packet->e = get_bit(header);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Check if the current packet has any codeblock contribu- !
|
||||
|
@ -1471,7 +1471,7 @@ parse_packet(bwc_field *const field, bwc_tile *const tile,
|
|||
! flag from the codestream that signals if new coding pas- !
|
||||
! ses are available. !
|
||||
\*--------------------------------------------------------*/
|
||||
delta_z = bwc_get_bit(header);
|
||||
delta_z = get_bit(header);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1507,8 +1507,7 @@ output_info(bwc_cmdl_arg_node *const args,
|
|||
bwc_param_inf *param_info;
|
||||
|
||||
bwc_cmdl_arg_node *temp;
|
||||
|
||||
bwc_stream *stream;
|
||||
|
||||
struct stat buf;
|
||||
|
||||
/*-----------------------*\
|
||||
|
@ -1672,7 +1671,7 @@ output_info(bwc_cmdl_arg_node *const args,
|
|||
return;
|
||||
}
|
||||
|
||||
data->codestream.data = calloc(1, sizeof(bwc_packed_stream));
|
||||
data->codestream.data = calloc(1, sizeof(bwc_stream));
|
||||
if(data->codestream.data == NULL)
|
||||
{
|
||||
// memory allocation error
|
||||
|
@ -1713,33 +1712,16 @@ output_info(bwc_cmdl_arg_node *const args,
|
|||
! Initialize the bitstream, parse the main header and set !
|
||||
! up the field structure for the current dataset. !
|
||||
\*--------------------------------------------------------*/
|
||||
stream = calloc(1, sizeof(bwc_stream));
|
||||
if(stream == NULL)
|
||||
{
|
||||
// memory allocation error
|
||||
fprintf(stderr, MEMERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
stream->memory = data->codestream.data->memory;
|
||||
|
||||
stream->t = 0;
|
||||
stream->Lmax = data->codestream.data->size;
|
||||
stream->size_incr = (uint64)(stream->Lmax / 2);
|
||||
|
||||
field = bwc_parse_main_header(data, stream);
|
||||
field = bwc_create_decompression(data, 0);
|
||||
if(field == NULL)
|
||||
{
|
||||
bwc_free_data(data);
|
||||
free(stream);
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
control = &field->control;
|
||||
info = field->info;
|
||||
|
||||
free(stream);
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Write the help message to the standard output. !
|
||||
\*--------------------------------------------------------*/
|
||||
|
@ -1755,16 +1737,15 @@ output_info(bwc_cmdl_arg_node *const args,
|
|||
"| .+++=--------=+++---=+++---=+++------------: |\n"\
|
||||
"| -=++++++++++++++++++++++++++++++++++++++++- |\n"\
|
||||
"| |\n"\
|
||||
"|-------------------------------General Information------------------------------|\n"\
|
||||
"|------------------------------ General Information -----------------------------|\n"\
|
||||
"| |\n");
|
||||
|
||||
/*--------------------------------------------------------*\
|
||||
! Print the original file size and format. !
|
||||
\*--------------------------------------------------------*/
|
||||
fseek(fp, 0L, SEEK_END);
|
||||
Ld = ftell(fp);
|
||||
buff = get_size(Ld);
|
||||
fclose(fp);
|
||||
data_points = (uint64)info->nX * info->nY * info->nZ *
|
||||
info->nTS * info->nPar;
|
||||
buff = get_size(data_points * 8);
|
||||
|
||||
printf("| Original size: %42s |\n"\
|
||||
"| Original file format: %42s |\n"\
|
||||
|
@ -1775,9 +1756,10 @@ output_info(bwc_cmdl_arg_node *const args,
|
|||
/*--------------------------------------------------------*\
|
||||
! Print the file size and compression ratio. !
|
||||
\*--------------------------------------------------------*/
|
||||
data_points = (uint64)info->nX * info->nY * info->nZ *
|
||||
info->nTS * info->nPar;
|
||||
buff = get_size(data_points * 8);
|
||||
fseek(fp, 0L, SEEK_END);
|
||||
Ld = ftell(fp);
|
||||
buff = get_size(Ld);
|
||||
fclose(fp);
|
||||
|
||||
printf("| Size on Disk: %42s |\n"\
|
||||
"| Comp. Ratio: %42.2f |\n"\
|
||||
|
@ -1814,7 +1796,7 @@ output_info(bwc_cmdl_arg_node *const args,
|
|||
/*--------------------------------------------------------*\
|
||||
! Print the numerical Datapoints. !
|
||||
\*--------------------------------------------------------*/
|
||||
printf("|------------------------------Numerical Parameters------------------------------|\n"\
|
||||
printf("|----------------------------- Numerical Parameters -----------------------------|\n"\
|
||||
"| |\n");
|
||||
|
||||
for(p = 0; p < info->nPar; ++p)
|
||||
|
@ -1835,19 +1817,23 @@ output_info(bwc_cmdl_arg_node *const args,
|
|||
while(buff > param_info->name && isspace((unsigned char)*buff)) buff--;
|
||||
buff[1] = '\0';
|
||||
|
||||
if(p != 0)
|
||||
{
|
||||
printf("| ........................................................................ |\n"
|
||||
"|%80s|\n"," ");
|
||||
}
|
||||
|
||||
printf("| Name: %55s |\n"\
|
||||
"| Minimum value: %55.2e |\n"\
|
||||
"| Maximum value: %55.2e |\n"\
|
||||
"| ........................................................................ |\n"
|
||||
"|%80s|\n", param_info->name,
|
||||
minVal,
|
||||
maxVal, " ");
|
||||
"| Maximum value: %55.2e |\n", param_info->name,
|
||||
minVal,
|
||||
maxVal);
|
||||
}
|
||||
|
||||
printf("|%80s|\n"," ");
|
||||
/*--------------------------------------------------------*\
|
||||
! Print the quality layers. !
|
||||
\*--------------------------------------------------------*/
|
||||
printf("|---------------------------------Quality Layers---------------------------------|\n"\
|
||||
printf("|-------------------------------- Quality Layers --------------------------------|\n"\
|
||||
"| |\n");
|
||||
|
||||
for(l = 0; l < control->nLayers; ++l)
|
||||
|
@ -1959,7 +1945,7 @@ read_bwc(char *const filename)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
file->codestream.data = calloc(1, sizeof(bwc_packed_stream));
|
||||
file->codestream.data = calloc(1, sizeof(bwc_stream));
|
||||
if(file->codestream.data == NULL)
|
||||
{
|
||||
// memory allocation error
|
||||
|
|
Loading…
Reference in a new issue