feat/api #46
20 changed files with 3373 additions and 6591 deletions
|
@ -181,36 +181,6 @@
|
||||||
|
|
||||||
#define AUX_SIZE 0x8000
|
#define AUX_SIZE 0x8000
|
||||||
|
|
||||||
/************************************************************************************************************\
|
|
||||||
|| ___ _ _ ___ ____ ____ ||
|
|
||||||
|| | \_/ |__] |___ [__ ||
|
|
||||||
|| | | | |___ ___] ||
|
|
||||||
|| ||
|
|
||||||
\************************************************************************************************************/
|
|
||||||
/*----------------------------------------------------------------------------------------------*\
|
|
||||||
! !
|
|
||||||
! 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;
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! STRUCT NAME: eas3_header !
|
! STRUCT NAME: eas3_header !
|
||||||
! ----------- !
|
! ----------- !
|
||||||
|
@ -303,7 +273,7 @@
|
||||||
{
|
{
|
||||||
uint64_t file_type;
|
uint64_t file_type;
|
||||||
uint64_t accuracy;
|
uint64_t accuracy;
|
||||||
uint64_t nzs;
|
uint64_t nts;
|
||||||
uint64_t npar;
|
uint64_t npar;
|
||||||
uint64_t ndim1;
|
uint64_t ndim1;
|
||||||
uint64_t ndim2;
|
uint64_t ndim2;
|
||||||
|
@ -324,6 +294,52 @@
|
||||||
uint64_t udef_int_size;
|
uint64_t udef_int_size;
|
||||||
uint64_t udef_real_size;
|
uint64_t udef_real_size;
|
||||||
} eas3_std_params;
|
} eas3_std_params;
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------------------------*\
|
||||||
|
! !
|
||||||
|
! DESCRIPTION: !
|
||||||
|
! ------------ !
|
||||||
|
! !
|
||||||
|
! This structure is used to store field names eas3 file. !
|
||||||
|
! !
|
||||||
|
\*----------------------------------------------------------------------------------------------*/
|
||||||
|
typedef struct name
|
||||||
|
{
|
||||||
|
char name[24]; // Parameter name.
|
||||||
|
uint8 id; // Parameter index.
|
||||||
|
|
||||||
|
struct name *next; // Next element in linked-list.
|
||||||
|
struct name *root; // Linked-list root.
|
||||||
|
} eas3_param_names;
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------------------------*\
|
||||||
|
! !
|
||||||
|
! DESCRIPTION: !
|
||||||
|
! ------------ !
|
||||||
|
! !
|
||||||
|
! This structure is used to read eas3 stuff. !
|
||||||
|
! !
|
||||||
|
\*----------------------------------------------------------------------------------------------*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
eas3_param_names *param_names;
|
||||||
|
eas3_std_params params;
|
||||||
|
|
||||||
|
struct field
|
||||||
|
{
|
||||||
|
double *d;
|
||||||
|
float *f;
|
||||||
|
} field;
|
||||||
|
|
||||||
|
// TODO: implement aux as queue
|
||||||
|
struct aux
|
||||||
|
{
|
||||||
|
uchar *ptr;
|
||||||
|
uint32 pos;
|
||||||
|
uint32 len;
|
||||||
|
} aux;
|
||||||
|
|
||||||
|
} eas3_data;
|
||||||
|
|
||||||
/************************************************************************************************************\
|
/************************************************************************************************************\
|
||||||
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|
|| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ ||
|
||||||
|
@ -331,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) !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
|
@ -342,7 +373,7 @@
|
||||||
! structure. !
|
! structure. !
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
bwc_data*
|
eas3_data*
|
||||||
read_eas3(char *const filename);
|
read_eas3(char *const filename);
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
|
@ -356,5 +387,5 @@
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
uchar
|
uchar
|
||||||
write_eas3(bwc_data *const file, char *const filename);
|
write_eas3(eas3_data *const file, char *const filename);
|
||||||
#endif
|
#endif
|
|
@ -92,7 +92,7 @@
|
||||||
\************************************************************************************************/
|
\************************************************************************************************/
|
||||||
uint64 bytes_used (bitstream const *const stream);
|
uint64 bytes_used (bitstream const *const stream);
|
||||||
//==========|==========================|======================|======|======|=====================
|
//==========|==========================|======================|======|======|=====================
|
||||||
bitstream* init_stream (uchar *const memory,
|
bitstream* init_bitstream (uchar *const memory,
|
||||||
uint32 const size,
|
uint32 const size,
|
||||||
char const instr);
|
char const instr);
|
||||||
//==========|==========================|======================|======|======|=====================
|
//==========|==========================|======================|======|======|=====================
|
||||||
|
@ -117,8 +117,10 @@
|
||||||
//==========|==========================|======================|======|======|=====================
|
//==========|==========================|======================|======|======|=====================
|
||||||
uchar get_bit (bitstream *const stream);
|
uchar get_bit (bitstream *const stream);
|
||||||
//==========|==========================|======================|======|======|=====================
|
//==========|==========================|======================|======|======|=====================
|
||||||
uchar terminate_stream (bitstream *stream,
|
uchar shrink_to_fit (bitstream *const stream);
|
||||||
bwc_stream *const packed_stream);
|
|
||||||
//==========|==========================|======================|======|======|=====================
|
//==========|==========================|======================|======|======|=====================
|
||||||
void release_packed_stream (bwc_stream *const stream);
|
uchar transfer_to_span (bitstream *const stream,
|
||||||
|
bwc_span *const span);
|
||||||
|
//==========|==========================|======================|======|======|=====================
|
||||||
|
void release_packed_stream (bwc_span *const stream);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -89,16 +89,22 @@
|
||||||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
||||||
|| ||
|
|| ||
|
||||||
\************************************************************************************************/
|
\************************************************************************************************/
|
||||||
uchar assemble_main_header (bwc_field *const field);
|
uchar assemble_main_header (bwc_codec *const codec);
|
||||||
//==========|==========================|======================|======|======|=====================
|
//==========|==========================|======================|======|======|=====================
|
||||||
uchar codestream_write_aux (bwc_stream *const header,
|
uchar codestream_write_aux (bwc_span *const header,
|
||||||
bwc_stream *const aux);
|
bwc_span *const aux);
|
||||||
//==========|==========================|======================|======|======|=====================
|
//==========|==========================|======================|======|======|=====================
|
||||||
uchar codestream_write_com (bwc_stream *const header,
|
uchar codestream_write_com (bwc_span *const header,
|
||||||
bwc_stream *const com);
|
bwc_span *const com);
|
||||||
//==========|==========================|======================|======|======|=====================
|
//==========|==========================|======================|======|======|=====================
|
||||||
bwc_stream* assemble_codestream (bwc_field *const field);
|
size_t assemble_codestream (bwc_codec *const codec,
|
||||||
|
bwc_stream *const stream);
|
||||||
//==========|==========================|======================|======|======|=====================
|
//==========|==========================|======================|======|======|=====================
|
||||||
bwc_field* parse_codestream (bwc_data *const data,
|
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_stream *const stream,
|
||||||
uint8 const layer);
|
uint8 const layer);
|
||||||
#endif
|
#endif
|
|
@ -114,8 +114,14 @@
|
||||||
\*----------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
bwc_type_half,
|
bwc_precision_half = 2,
|
||||||
bwc_type_single,
|
bwc_precision_single = 4,
|
||||||
bwc_type_double,
|
bwc_precision_double = 8,
|
||||||
} bwc_type;
|
} bwc_precision;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
comp,
|
||||||
|
decomp,
|
||||||
|
} bwc_mode;
|
||||||
#endif
|
#endif
|
|
@ -157,13 +157,13 @@
|
||||||
\************************************************************************************************/
|
\************************************************************************************************/
|
||||||
uchar initialize_gain_lut ();
|
uchar initialize_gain_lut ();
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
bwc_float get_dwt_energy_gain (bwc_field *const field,
|
bwc_float get_dwt_energy_gain (bwc_codec *const codec,
|
||||||
uchar const highband_flag,
|
uchar const highband_flag,
|
||||||
uint16 const level);
|
uint16 const level);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
uchar forward_wavelet_transform (bwc_field *const field,
|
uchar forward_wavelet_transform (bwc_codec *const codec,
|
||||||
bwc_parameter *const parameter);
|
bwc_parameter *const parameter);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
uchar inverse_wavelet_transform (bwc_field *const field,
|
uchar inverse_wavelet_transform (bwc_codec *const codec,
|
||||||
bwc_parameter *const parameter);
|
bwc_parameter *const parameter);
|
||||||
#endif
|
#endif
|
|
@ -64,92 +64,99 @@
|
||||||
|| ||
|
|| ||
|
||||||
\************************************************************************************************/
|
\************************************************************************************************/
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
bwc_data* bwc_initialize_data (double *const field,
|
bwc_stream* bwc_init_stream (void *const inpbuf,
|
||||||
uint64 const nX,
|
void *const outbuf,
|
||||||
uint64 const nY,
|
bwc_mode const mode);
|
||||||
uint64 const nZ,
|
|
||||||
uint16 const nTS,
|
|
||||||
uint8 const nPar,
|
|
||||||
char *const file_extension);
|
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
uchar bwc_set_com (bwc_data *const data,
|
uchar bwc_set_com (bwc_stream *const stream,
|
||||||
char const *const com,
|
char const *const com,
|
||||||
uint16 const size);
|
uint16 const size);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
uchar bwc_set_aux (bwc_data *const data,
|
uchar bwc_set_aux (bwc_stream *const stream,
|
||||||
char const *const aux,
|
char const *const aux,
|
||||||
uint32 const size);
|
uint32 const size);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void bwc_add_param (bwc_data *const data,
|
uchar create_codec (bwc_codec *const codec);
|
||||||
char *const name,
|
|
||||||
uint8 const precision);
|
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void bwc_get_data (bwc_data *const data,
|
bwc_codec* configure_codec (bwc_codec *const codec,
|
||||||
uchar *const buffer,
|
uint64 const nX,
|
||||||
uint64 const size);
|
uint64 const nY,
|
||||||
|
uint64 const nZ,
|
||||||
|
uint64 const nTS,
|
||||||
|
uint8 const nPar,
|
||||||
|
bwc_precision const prec);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void bwc_free_data (bwc_data *const data);
|
bwc_codec* bwc_alloc_coder (uint64 const nX,
|
||||||
|
uint64 const nY,
|
||||||
|
uint64 const nZ,
|
||||||
|
uint64 const nTS,
|
||||||
|
uint8 const nPar,
|
||||||
|
bwc_precision const prec);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
uchar create_field (bwc_field *const field);
|
bwc_codec* bwc_alloc_decoder ();
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void bwc_kill_compression (bwc_field *const field);
|
void bwc_free_codec (bwc_codec *const codec);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
bwc_field* bwc_initialize_field (bwc_data *const data);
|
void bwc_set_error_resilience (bwc_codec *const codec);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void bwc_set_error_resilience (bwc_field *const field);
|
void set_quant_style (bwc_codec *const codec,
|
||||||
//==========|==========================|======================|======|=======|====================
|
|
||||||
void set_quant_style (bwc_field *const field,
|
|
||||||
bwc_quant_st const quantization_style);
|
bwc_quant_st const quantization_style);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void set_quant_step_size (bwc_field *const field,
|
void set_quant_step_size (bwc_codec *const codec,
|
||||||
double const delta);
|
double const delta);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void set_progression (bwc_field *const field,
|
void set_progression (bwc_codec *const codec,
|
||||||
bwc_prog_ord const progression);
|
bwc_prog_ord const progression);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void set_kernels (bwc_field *const field,
|
void set_kernels (bwc_codec *const codec,
|
||||||
bwc_dwt_filter const KernelX,
|
bwc_dwt_filter const KernelX,
|
||||||
bwc_dwt_filter const KernelY,
|
bwc_dwt_filter const KernelY,
|
||||||
bwc_dwt_filter const KernelZ,
|
bwc_dwt_filter const KernelZ,
|
||||||
bwc_dwt_filter const KernelTS);
|
bwc_dwt_filter const KernelTS);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void bwc_set_decomp (bwc_field *const field,
|
void bwc_set_decomp (bwc_codec *const codec,
|
||||||
uint8 const decompX,
|
uint8 const decompX,
|
||||||
uint8 const decompY,
|
uint8 const decompY,
|
||||||
uint8 const decompZ,
|
uint8 const decompZ,
|
||||||
uint8 const decompTS);
|
uint8 const decompTS);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void bwc_set_precincts (bwc_field *const field,
|
void bwc_set_precincts (bwc_codec *const codec,
|
||||||
uint8 const pX,
|
uint8 const pX,
|
||||||
uint8 const pY,
|
uint8 const pY,
|
||||||
uint8 const pZ,
|
uint8 const pZ,
|
||||||
uint8 const pTS);
|
uint8 const pTS);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void bwc_set_codeblocks (bwc_field *const field,
|
void bwc_set_codeblocks (bwc_codec *const codec,
|
||||||
uint8 const cbX,
|
uint8 const cbX,
|
||||||
uint8 const cbY,
|
uint8 const cbY,
|
||||||
uint8 const cbZ,
|
uint8 const cbZ,
|
||||||
uint8 const cbTS);
|
uint8 const cbTS);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void bwc_set_qm (bwc_field *const field,
|
void bwc_set_qm (bwc_codec *const codec,
|
||||||
uint8 const Qm);
|
uint8 const Qm);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
void bwc_set_tiles (bwc_field *const field,
|
void bwc_set_tiles (bwc_codec *const codec,
|
||||||
uint64 const tilesX,
|
uint64 const tilesX,
|
||||||
uint64 const tilesY,
|
uint64 const tilesY,
|
||||||
uint64 const tilesZ,
|
uint64 const tilesZ,
|
||||||
uint64 const tilesTS,
|
uint64 const tilesTS,
|
||||||
bwc_tile_instr const instr);
|
bwc_tile_instr const instr);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
uchar bwc_create_compression (bwc_field *const field,
|
bwc_header* bwc_open_header (void *const inpbuf);
|
||||||
|
//==========|==========================|======================|======|=======|====================
|
||||||
|
void bwc_close_header (bwc_header *const header);
|
||||||
|
//==========|==========================|======================|======|=======|====================
|
||||||
|
uchar bwc_create_compression (bwc_codec *const codec,
|
||||||
|
bwc_stream *const data,
|
||||||
char *const rate_control);
|
char *const rate_control);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
uchar bwc_compress (bwc_field *const field,
|
size_t bwc_compress (bwc_codec *const codec,
|
||||||
bwc_data *const data);
|
bwc_stream *const data);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
bwc_field* bwc_create_decompression (bwc_data *const data,
|
uchar bwc_create_decompression (bwc_codec *const codec,
|
||||||
|
bwc_stream *const stream,
|
||||||
uint8 const layer);
|
uint8 const layer);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
uchar bwc_decompress (bwc_field *const field,
|
uchar bwc_decompress (bwc_codec *const codec,
|
||||||
bwc_data *const data);
|
bwc_stream *const stream);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|| ------------ ||
|
|| ------------ ||
|
||||||
|| ||
|
|| ||
|
||||||
|| This file describes a set of functions that can be used to de-/encode bwc ||
|
|| This file describes a set of functions that can be used to de-/encode bwc ||
|
||||||
|| codeblocks described by the bwc_field structure according to the embedded block ||
|
|| codeblocks described by the bwc_codec structure according to the embedded block ||
|
||||||
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|
||||||
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|
||||||
|| ||
|
|| ||
|
||||||
|
@ -156,11 +156,11 @@
|
||||||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
||||||
|| ||
|
|| ||
|
||||||
\************************************************************************************************/
|
\************************************************************************************************/
|
||||||
uchar t1_encode (bwc_field *const field,
|
uchar t1_encode (bwc_codec *const codec,
|
||||||
bwc_tile *const tile,
|
bwc_tile *const tile,
|
||||||
bwc_parameter *const parameter);
|
bwc_parameter *const parameter);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
uchar t1_decode (bwc_field *const field,
|
uchar t1_decode (bwc_codec *const codec,
|
||||||
bwc_tile *const tile,
|
bwc_tile *const tile,
|
||||||
bwc_parameter *const parameter);
|
bwc_parameter *const parameter);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|| ------------ ||
|
|| ------------ ||
|
||||||
|| ||
|
|| ||
|
||||||
|| This file describes a set of functions that can be used to de-/encode bwc ||
|
|| This file describes a set of functions that can be used to de-/encode bwc ||
|
||||||
|| codeblocks described by the bwc_field structure according to the embedded block ||
|
|| codeblocks described by the bwc_codec structure according to the embedded block ||
|
||||||
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|
||||||
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|
||||||
|| ||
|
|| ||
|
||||||
|
@ -76,10 +76,10 @@
|
||||||
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
|| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] ||
|
||||||
|| ||
|
|| ||
|
||||||
\************************************************************************************************/
|
\************************************************************************************************/
|
||||||
uchar t2_encode (bwc_field *const field,
|
uchar t2_encode (bwc_codec *const codec,
|
||||||
bwc_tile *const tile);
|
bwc_tile *const tile);
|
||||||
//==========|==========================|======================|======|=======|====================
|
//==========|==========================|======================|======|=======|====================
|
||||||
uchar parse_packet (bwc_field *const field,
|
uchar parse_packet (bwc_codec *const codec,
|
||||||
bwc_tile *const tile,
|
bwc_tile *const tile,
|
||||||
bwc_packet *const packet,
|
bwc_packet *const packet,
|
||||||
uint64 const body_size);
|
uint64 const body_size);
|
||||||
|
|
|
@ -99,7 +99,7 @@
|
||||||
|
|
||||||
uchar *access; // Pointer used to parse packed stream.
|
uchar *access; // Pointer used to parse packed stream.
|
||||||
uchar *memory; // Memory handle for the packed stream.
|
uchar *memory; // Memory handle for the packed stream.
|
||||||
} bwc_stream;
|
} bwc_span;
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------*\
|
||||||
! !
|
! !
|
||||||
|
@ -138,29 +138,6 @@
|
||||||
bwc_tagtree_node *nodes; // Pointer to the tagtree nodes.
|
bwc_tagtree_node *nodes; // Pointer to the tagtree nodes.
|
||||||
} bwc_tagtree;
|
} bwc_tagtree;
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------*\
|
|
||||||
! !
|
|
||||||
! DESCRIPTION: !
|
|
||||||
! ------------ !
|
|
||||||
! !
|
|
||||||
! This structure defines a linked list which stores the size, index, and bit pre- !
|
|
||||||
! cision The string name is used to store the parameter name supplied by the !
|
|
||||||
! function caller. !
|
|
||||||
! !
|
|
||||||
\*----------------------------------------------------------------------------------------------*/
|
|
||||||
typedef struct opt
|
|
||||||
{
|
|
||||||
char name[24]; // Parameter name.
|
|
||||||
uint8 id; // Parameter index.
|
|
||||||
|
|
||||||
uint64 size; // Parameter size after sub-sampling.
|
|
||||||
uint8 precision; // Parameter precision.
|
|
||||||
|
|
||||||
struct opt *next; // Next element in linked-list.
|
|
||||||
struct opt *root; // Linked-list root.
|
|
||||||
} bwc_cmd_opts_ll;
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------*\
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -178,12 +155,8 @@
|
||||||
|
|
||||||
uint8 nPar; // Number of parameters.
|
uint8 nPar; // Number of parameters.
|
||||||
|
|
||||||
uint8 precision; // Flag defining codec precision.
|
bwc_precision data_prec; // Data type of uncompressed field data.
|
||||||
|
bwc_precision codec_prec; // Encoder/decoder bit precision.
|
||||||
uint8 codec_prec; // Encoder/decoder bit precision.
|
|
||||||
char f_ext[20]; // Uncompressed data set file extension.
|
|
||||||
|
|
||||||
bwc_cmd_opts_ll *parameter; // Command options linked-list.
|
|
||||||
} bwc_gl_inf;
|
} bwc_gl_inf;
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------*\
|
||||||
|
@ -197,22 +170,17 @@
|
||||||
\*----------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
bwc_gl_inf info; // Gloabal info structure.
|
|
||||||
FILE *fp; // File point to (un)compr. data-set.
|
|
||||||
|
|
||||||
struct codestream
|
struct codestream
|
||||||
{
|
{
|
||||||
bwc_stream *data; // Data codestream block.
|
bwc_span *aux; // Auxiliary info. codestream block.
|
||||||
bwc_stream *aux; // Auxiliary info. codestream block.
|
bwc_span *com; // Comment codestream block.
|
||||||
bwc_stream *com; // Comment codestream block.
|
|
||||||
}codestream;
|
}codestream;
|
||||||
|
|
||||||
struct field
|
void *inp; // User managed buffer for input
|
||||||
{
|
void *out; // User managed buffer for output
|
||||||
double *d; // Double precision numerical data-set.
|
|
||||||
float *f; // Single precision numerical data-set.
|
bwc_mode mode; // Flag to signal (de-)compression
|
||||||
}field;
|
} bwc_stream;
|
||||||
} bwc_data;
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------*\
|
||||||
! !
|
! !
|
||||||
|
@ -420,8 +388,8 @@
|
||||||
\*----------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
bwc_stream header; // Packed stream header.
|
bwc_span header; // Packed stream header.
|
||||||
bwc_stream body; // Packed stream body.
|
bwc_span body; // Packed stream body.
|
||||||
uint8 e; // Indicator for packet cb. contributions.
|
uint8 e; // Indicator for packet cb. contributions.
|
||||||
|
|
||||||
uint32 size; // Codestream packet size.
|
uint32 size; // Codestream packet size.
|
||||||
|
@ -528,14 +496,9 @@
|
||||||
\*----------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint64 size; // Parameter size.
|
|
||||||
char *name; // Parameter name.
|
|
||||||
|
|
||||||
uint64 X0, Y0, Z0, TS0; // Tile parameter starting point.
|
uint64 X0, Y0, Z0, TS0; // Tile parameter starting point.
|
||||||
uint64 X1, Y1, Z1, TS1; // Tile parameter end point.
|
uint64 X1, Y1, Z1, TS1; // Tile parameter end point.
|
||||||
|
|
||||||
uint8 precision; // Tile parameter precision.
|
|
||||||
|
|
||||||
bwc_float parameter_min; // Min. value of tile parameter.
|
bwc_float parameter_min; // Min. value of tile parameter.
|
||||||
bwc_float parameter_max; // Max. value of tile parameter.
|
bwc_float parameter_max; // Max. value of tile parameter.
|
||||||
} bwc_param_inf;
|
} bwc_param_inf;
|
||||||
|
@ -696,26 +659,32 @@
|
||||||
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 !
|
|
||||||
! (de-)compression run. !
|
|
||||||
! !
|
|
||||||
! The meter structure is used to store measurements, including important time !
|
|
||||||
! measurements, for a particular compression run. !
|
|
||||||
! !
|
|
||||||
\*----------------------------------------------------------------------------------------------*/
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
bwc_gl_inf *info; // Gloabal info structure
|
bwc_gl_inf info; // Global info structure
|
||||||
|
bwc_gl_ctrl control; // Global control structure
|
||||||
|
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
|
||||||
|
{
|
||||||
|
bwc_gl_inf info; // Global info structure
|
||||||
bwc_gl_ctrl control; // Global control structure
|
bwc_gl_ctrl control; // Global control structure
|
||||||
|
|
||||||
bwc_tile *tile; // Structure defining bwc tile.
|
bwc_tile *tile; // Structure defining bwc tile.
|
||||||
|
|
||||||
bwc_stream *aux; // Auxiliary info. codestream block.
|
bwc_mode mode; // Flag to signal (de-)compression
|
||||||
bwc_stream *com; // Comment codestream block.
|
} bwc_codec;
|
||||||
} bwc_field;
|
|
||||||
#endif
|
#endif
|
|
@ -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
|
|
|
@ -48,10 +48,10 @@ module bwc
|
||||||
!| | | \| |___ |___ |__| |__/ |___ |!
|
!| | | \| |___ |___ |__| |__/ |___ |!
|
||||||
!| |!
|
!| |!
|
||||||
!************************************************************************************************!
|
!************************************************************************************************!
|
||||||
use, intrinsic :: iso_c_binding, only: C_PTR, C_INT64_T, C_INT32_T, C_INT16_T, C_INT8_T, &
|
use, intrinsic :: iso_c_binding, only: c_ptr, c_int64_t, c_int32_t, c_int16_t, c_int8_t, &
|
||||||
C_INT, C_DOUBLE, C_CHAR, C_SIGNED_CHAR
|
c_int, c_double, c_char, c_signed_char
|
||||||
IMPLICIT NONE
|
implicit none
|
||||||
PRIVATE
|
private
|
||||||
|
|
||||||
!************************************************************************************************!
|
!************************************************************************************************!
|
||||||
!| ____ ____ _ _ ____ ___ ____ _ _ ___ ____ |!
|
!| ____ ____ _ _ ____ ___ ____ _ _ ___ ____ |!
|
||||||
|
@ -59,25 +59,25 @@ module bwc
|
||||||
!| |___ |__| | \| ___] | | | | \| | ___] |!
|
!| |___ |__| | \| ___] | | | | \| | ___] |!
|
||||||
!| |!
|
!| |!
|
||||||
!************************************************************************************************!
|
!************************************************************************************************!
|
||||||
ENUM, BIND(C)
|
enum, bind(c)
|
||||||
enumerator :: bwc_dwt_9_7 = 0, &
|
enumerator :: bwc_dwt_9_7 = 0, &
|
||||||
bwc_dwt_5_3 = 1, &
|
bwc_dwt_5_3 = 1, &
|
||||||
bwc_dwt_haar = 2
|
bwc_dwt_haar = 2
|
||||||
END ENUM
|
end enum
|
||||||
!*==============================================================================================*!
|
!*==============================================================================================*!
|
||||||
ENUM, BIND(C)
|
enum, bind(c)
|
||||||
enumerator :: bwc_prog_LRCP = 0
|
enumerator :: bwc_prog_lrcp = 0
|
||||||
END ENUM
|
end enum
|
||||||
!*==============================================================================================*!
|
!*==============================================================================================*!
|
||||||
ENUM, BIND(C)
|
enum, bind(c)
|
||||||
enumerator :: bwc_qt_none = 0, &
|
enumerator :: bwc_qt_none = 0, &
|
||||||
bwc_qt_derived = 1
|
bwc_qt_derived = 1
|
||||||
END ENUM
|
end enum
|
||||||
!*==============================================================================================*!
|
!*==============================================================================================*!
|
||||||
ENUM, BIND(C)
|
enum, bind(c)
|
||||||
enumerator :: bwc_tile_sizeof = 0, &
|
enumerator :: bwc_tile_sizeof = 0, &
|
||||||
bwc_tile_numbof = 1
|
bwc_tile_numbof = 1
|
||||||
END ENUM
|
end enum
|
||||||
|
|
||||||
!************************************************************************************************!
|
!************************************************************************************************!
|
||||||
!| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ |!
|
!| ___ _ _ ___ _ _ ____ ____ _ _ _ _ ____ ___ _ ____ _ _ ____ |!
|
||||||
|
@ -86,294 +86,113 @@ module bwc
|
||||||
!| |!
|
!| |!
|
||||||
!************************************************************************************************!
|
!************************************************************************************************!
|
||||||
interface
|
interface
|
||||||
function initialize_data_f(field, nX, nY, nZ, nTS, nPar, file_extension) result(data) &
|
function init_stream_f(inpbuf, outbuf, mode) result(stream) &
|
||||||
BIND(C, NAME="bwc_initialize_data")
|
bind(c, name="bwc_init_stream")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
type(c_ptr) :: stream
|
||||||
! DEFINE POINTERS: !
|
type(c_ptr), value :: inpbuf
|
||||||
!*-----------------------*!
|
type(c_ptr), value :: outbuf
|
||||||
TYPE(C_PTR), VALUE :: field
|
integer(kind=c_int), value :: mode
|
||||||
TYPE(C_PTR) :: data
|
end function init_stream_f
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT16_T), VALUE :: nX, nY, nZ
|
|
||||||
INTEGER(KIND=C_INT8_T), VALUE :: nTS, nPar
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE CHAR VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
CHARACTER(KIND=C_CHAR) :: file_extension(*)
|
|
||||||
end function initialize_data_f
|
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
subroutine add_param_f(data, name, sample, dim, precision) &
|
function alloc_coder_f(nx, ny, nz, nts, npar, prec) result(codec) &
|
||||||
BIND(C, NAME="bwc_add_param")
|
bind(c, name="bwc_alloc_coder")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
type(c_ptr) :: codec
|
||||||
! DEFINE POINTERS: !
|
integer(kind=c_int64_t), value :: nx, ny, nz, nts
|
||||||
!*-----------------------*!
|
integer(kind=c_int8_t), value :: npar
|
||||||
TYPE(C_PTR), VALUE :: data
|
integer(kind=c_int), value :: prec
|
||||||
|
end function alloc_coder_f
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT16_T), VALUE :: sample
|
|
||||||
INTEGER(KIND=C_INT8_T), VALUE :: precision
|
|
||||||
INTEGER(KIND=C_SIGNED_CHAR), VALUE :: dim
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE CHAR VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
CHARACTER(KIND=C_CHAR) :: name(*)
|
|
||||||
end subroutine add_param_f
|
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
subroutine get_data_f(data, buffer, size) &
|
function alloc_decoder_f() result(codec) &
|
||||||
BIND(C, NAME="bwc_get_data")
|
bind(c, name="bwc_alloc_decoder")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
type(c_ptr) :: codec
|
||||||
! DEFINE POINTERS: !
|
end function alloc_decoder_f
|
||||||
!*-----------------------*!
|
|
||||||
TYPE(C_PTR), VALUE :: data
|
|
||||||
TYPE(C_PTR), VALUE :: buffer
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT64_T), Value :: size
|
|
||||||
end subroutine get_data_f
|
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
subroutine free_data_f(data) &
|
subroutine free_codec_f(codec) &
|
||||||
BIND(C, NAME="bwc_free_data")
|
bind(c, name="bwc_free_codec")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
type(c_ptr), value :: codec
|
||||||
! DEFINE POINTERS: !
|
end subroutine free_codec_f
|
||||||
!*-----------------------*!
|
|
||||||
TYPE(C_PTR), VALUE :: data
|
|
||||||
end subroutine free_data_f
|
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
subroutine kill_compression_f(field) &
|
subroutine set_error_resilience_f(codec) &
|
||||||
BIND(C, NAME="bwc_kill_compression")
|
bind(c, name="bwc_set_error_resilience")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
type(c_ptr), value :: codec
|
||||||
! DEFINE POINTERS: !
|
|
||||||
!*-----------------------*!
|
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
end subroutine kill_compression_f
|
|
||||||
!*============================================================================================*!
|
|
||||||
function initialize_field_f(data) result(field) &
|
|
||||||
BIND(C, NAME="bwc_initialize_field")
|
|
||||||
IMPORT
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE POINTERS: !
|
|
||||||
!*-----------------------*!
|
|
||||||
TYPE(C_PTR), VALUE :: data
|
|
||||||
TYPE(C_PTR) :: field
|
|
||||||
end function initialize_field_f
|
|
||||||
!*============================================================================================*!
|
|
||||||
subroutine set_error_resilience_f(field) &
|
|
||||||
BIND(C, NAME="bwc_set_error_resilience")
|
|
||||||
IMPORT
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE POINTERS: !
|
|
||||||
!*-----------------------*!
|
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
end subroutine set_error_resilience_f
|
end subroutine set_error_resilience_f
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
subroutine set_quantization_style_f(field, quantization_style) &
|
subroutine set_decomp_f(codec, decompx, decompy, decompz, decompts) &
|
||||||
BIND(C, NAME="bwc_set_quantization_style")
|
bind(c, name="bwc_set_decomp")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
type(c_ptr), value :: codec
|
||||||
! DEFINE POINTERS: !
|
integer(kind=c_int8_t), value :: decompx, decompy
|
||||||
!*-----------------------*!
|
integer(kind=c_int8_t), value :: decompz, decompts
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT), VALUE :: quantization_style
|
|
||||||
end subroutine set_quantization_style_f
|
|
||||||
!*============================================================================================*!
|
|
||||||
subroutine set_quantization_step_size_f(field, delta) &
|
|
||||||
BIND(C, NAME="bwc_set_quantization_step_size")
|
|
||||||
IMPORT
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE POINTERS: !
|
|
||||||
!*-----------------------*!
|
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE FLOAT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
REAL(KIND=C_DOUBLE), VALUE :: delta
|
|
||||||
end subroutine set_quantization_step_size_f
|
|
||||||
!*============================================================================================*!
|
|
||||||
subroutine set_progression_f(field, progression) &
|
|
||||||
BIND(C, NAME="bwc_set_progression")
|
|
||||||
IMPORT
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE POINTERS: !
|
|
||||||
!*-----------------------*!
|
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT), VALUE :: progression
|
|
||||||
end subroutine set_progression_f
|
|
||||||
!*============================================================================================*!
|
|
||||||
subroutine set_kernels_f(field, KernelX, KernelY, KernelZ, KernelTS) &
|
|
||||||
BIND(C, NAME="bwc_set_kernels")
|
|
||||||
IMPORT
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE POINTERS: !
|
|
||||||
!*-----------------------*!
|
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT), VALUE :: KernelX, KernelY
|
|
||||||
INTEGER(KIND=C_INT), VALUE :: KernelZ, KernelTS
|
|
||||||
end subroutine set_kernels_f
|
|
||||||
!*============================================================================================*!
|
|
||||||
subroutine set_decomp_f(field, decompX, decompY, decompZ, decompTS) &
|
|
||||||
BIND(C, NAME="bwc_set_decomp")
|
|
||||||
IMPORT
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE POINTERS: !
|
|
||||||
!*-----------------------*!
|
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT8_T), VALUE :: decompX, decompY
|
|
||||||
INTEGER(KIND=C_INT8_T), VALUE :: decompZ, decompTS
|
|
||||||
end subroutine set_decomp_f
|
end subroutine set_decomp_f
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
subroutine set_precincts_f(field, pX, pY, pZ, pTS) &
|
subroutine set_precincts_f(codec, px, py, pz, pts) &
|
||||||
BIND(C, NAME="bwc_set_precincts")
|
bind(c, name="bwc_set_precincts")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
type(c_ptr), value :: codec
|
||||||
! DEFINE POINTERS: !
|
integer(kind=c_int8_t), value :: px, py
|
||||||
!*-----------------------*!
|
integer(kind=c_int8_t), value :: pz, pts
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT8_T), VALUE :: pX, pY
|
|
||||||
INTEGER(KIND=C_INT8_T), VALUE :: pZ, pTS
|
|
||||||
end subroutine set_precincts_f
|
end subroutine set_precincts_f
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
subroutine set_codeblocks_f(field, cbX, cbY, cbZ, cbTS) &
|
subroutine set_codeblocks_f(codec, cbx, cby, cbz, cbts) &
|
||||||
BIND(C, NAME="bwc_set_codeblocks")
|
bind(c, name="bwc_set_codeblocks")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
type(c_ptr), value :: codec
|
||||||
! DEFINE POINTERS: !
|
integer(kind=c_int8_t), value :: cbx, cby
|
||||||
!*-----------------------*!
|
integer(kind=c_int8_t), value :: cbz, cbts
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT8_T), VALUE :: cbX, cbY
|
|
||||||
INTEGER(KIND=C_INT8_T), VALUE :: cbZ, cbTS
|
|
||||||
end subroutine set_codeblocks_f
|
end subroutine set_codeblocks_f
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
subroutine set_qm_f(field, Qm) &
|
subroutine set_qm_f(codec, qm) &
|
||||||
BIND(C, NAME="bwc_set_qm")
|
bind(c, name="bwc_set_qm")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
type(c_ptr), value :: codec
|
||||||
! DEFINE POINTERS: !
|
integer(kind=c_int8_t), value :: qm
|
||||||
!*-----------------------*!
|
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT8_T), VALUE :: Qm
|
|
||||||
end subroutine set_qm_f
|
end subroutine set_qm_f
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
subroutine set_tiles_f(field, tilesX, tilesY, tilesZ, tilesTS, instr) &
|
subroutine set_tiles_f(codec, tilesx, tilesy, tilesz, tilests, instr) &
|
||||||
BIND(C, NAME="bwc_set_tiles")
|
bind(c, name="bwc_set_tiles")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
type(c_ptr), value :: codec
|
||||||
! DEFINE POINTERS: !
|
integer(kind=c_int64_t), value :: tilesx, tilesy, tilesz, tilests
|
||||||
!*-----------------------*!
|
integer(kind=c_int), value :: instr
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT64_T), VALUE :: tilesX, tilesY, tilesZ
|
|
||||||
INTEGER(KIND=C_INT16_T), VALUE :: tilesTS
|
|
||||||
INTEGER(KIND=C_INT), VALUE :: instr
|
|
||||||
end subroutine set_tiles_f
|
end subroutine set_tiles_f
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
function create_compression_f(field, rate_control) result(error_flag) &
|
function create_compression_f(codec, stream, rate_control) result(error_flag) &
|
||||||
BIND(C, NAME="bwc_create_compression")
|
bind(c, name="bwc_create_compression")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
integer(kind=c_int8_t) :: error_flag
|
||||||
! DEFINE POINTERS: !
|
type(c_ptr), value :: codec
|
||||||
!*-----------------------*!
|
type(c_ptr), value :: stream
|
||||||
TYPE(C_PTR), VALUE :: field
|
character(kind=c_char) :: rate_control(*)
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT8_T) :: error_flag
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE CHAR VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
CHARACTER(KIND=C_CHAR) :: rate_control(*)
|
|
||||||
end function create_compression_f
|
end function create_compression_f
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
function compress_f(field, data) result(error_flag) &
|
function compress_f(codec, stream) result(error_flag) &
|
||||||
BIND(C, NAME="bwc_compress")
|
bind(c, name="bwc_compress")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
integer(kind=c_int8_t) :: error_flag
|
||||||
! DEFINE POINTERS: !
|
type(c_ptr), value :: codec
|
||||||
!*-----------------------*!
|
type(c_ptr), value :: stream
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
TYPE(C_PTR), VALUE :: data
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT8_T) :: error_flag
|
|
||||||
end function compress_f
|
end function compress_f
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
function create_decompression_f(data, layer) result(field) &
|
function create_decompression_f(codec, stream, layer) result(error_flag) &
|
||||||
BIND(C, NAME="bwc_create_decompression")
|
bind(c, name="bwc_create_decompression")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
integer(kind=c_int8_t) :: error_flag
|
||||||
! DEFINE POINTERS: !
|
type(c_ptr), value :: codec
|
||||||
!*-----------------------*!
|
type(c_ptr), value :: stream
|
||||||
TYPE(C_PTR) :: field
|
integer(kind=c_int8_t), value :: layer
|
||||||
TYPE(C_PTR), VALUE :: data
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT8_T), VALUE :: layer
|
|
||||||
end function create_decompression_f
|
end function create_decompression_f
|
||||||
!*============================================================================================*!
|
!*============================================================================================*!
|
||||||
function decompress_f(field, data) result(error_flag) &
|
function decompress_f(codec, stream) result(error_flag) &
|
||||||
BIND(C, NAME="bwc_decompress")
|
bind(c, name="bwc_decompress")
|
||||||
IMPORT
|
import
|
||||||
!*-----------------------*!
|
integer(kind=c_int8_t) :: error_flag
|
||||||
! DEFINE POINTERS: !
|
type(c_ptr), value :: codec
|
||||||
!*-----------------------*!
|
type(c_ptr), value :: stream
|
||||||
TYPE(C_PTR), VALUE :: field
|
|
||||||
TYPE(C_PTR), VALUE :: data
|
|
||||||
|
|
||||||
!*-----------------------*!
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
!*-----------------------*!
|
|
||||||
INTEGER(KIND=C_INT8_T) :: error_flag
|
|
||||||
end function decompress_f
|
end function decompress_f
|
||||||
end interface
|
end interface
|
||||||
|
|
||||||
|
@ -395,24 +214,17 @@ module bwc
|
||||||
public :: bwc_tile_sizeof, &
|
public :: bwc_tile_sizeof, &
|
||||||
bwc_tile_numbof
|
bwc_tile_numbof
|
||||||
|
|
||||||
public :: bwc_initialize_data, &
|
public :: bwc_init_stream, &
|
||||||
bwc_get_data, &
|
bwc_alloc_coder, &
|
||||||
bwc_free_data
|
bwc_alloc_decoder, &
|
||||||
|
bwc_free_codec
|
||||||
public :: bwc_initialize_field, &
|
|
||||||
bwc_add_param, &
|
|
||||||
bwc_kill_compression
|
|
||||||
|
|
||||||
public :: bwc_set_error_resilience, &
|
public :: bwc_set_error_resilience, &
|
||||||
bwc_set_quantization_style, &
|
|
||||||
bwc_set_quantization_step_size, &
|
|
||||||
bwc_set_progression, &
|
|
||||||
bwc_set_kernels, &
|
|
||||||
bwc_set_decomp, &
|
bwc_set_decomp, &
|
||||||
bwc_set_precincts, &
|
bwc_set_precincts, &
|
||||||
bwc_set_codeblocks, &
|
bwc_set_codeblocks, &
|
||||||
bwc_set_qm, &
|
bwc_set_qm, &
|
||||||
bwc_set_tiles,
|
bwc_set_tiles
|
||||||
|
|
||||||
public :: bwc_create_compression, &
|
public :: bwc_create_compression, &
|
||||||
bwc_compress, &
|
bwc_compress, &
|
||||||
|
|
|
@ -84,55 +84,37 @@ const = _const()
|
||||||
#| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] |#
|
#| | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] |#
|
||||||
#| |#
|
#| |#
|
||||||
#**************************************************************************************************#
|
#**************************************************************************************************#
|
||||||
def free_data(data):
|
def init_stream(inpbuf, outbuf, mode):
|
||||||
fun = libbwc.bwc_free_data
|
fun = libbwc.bwc_init_stream
|
||||||
fun.restype = None
|
|
||||||
fun.argtypes = [ctypes.c_void_p]
|
|
||||||
fun(data)
|
|
||||||
#==================================================================================================#
|
|
||||||
def initialize_data(data, nX, nY, nZ, nTS, nPar, file_extension):
|
|
||||||
fun = libbwc.bwc_initialize_data
|
|
||||||
fun.restype = ctypes.c_void_p
|
fun.restype = ctypes.c_void_p
|
||||||
fun.argtypes = [ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
|
fun.argtypes = [ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
|
||||||
|
ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
|
||||||
|
ctypes.c_char_p]
|
||||||
|
return ctypes.c_void_p(fun(inpbuf, outbuf, mode.encode('utf-8')))
|
||||||
|
#==================================================================================================#
|
||||||
|
def alloc_coder(nX, nY, nZ, nTS, nPar, prec):
|
||||||
|
fun = libbwc.bwc_alloc_coder
|
||||||
|
fun.restype = ctypes.c_void_p
|
||||||
|
fun.argtypes = [ctypes.c_uint64,
|
||||||
ctypes.c_uint64,
|
ctypes.c_uint64,
|
||||||
ctypes.c_uint64,
|
ctypes.c_uint64,
|
||||||
ctypes.c_uint64,
|
|
||||||
ctypes.c_uint16,
|
|
||||||
ctypes.c_uint8,
|
ctypes.c_uint8,
|
||||||
ctypes.c_char_p]
|
ctypes.c_char_p]
|
||||||
return ctypes.c_void_p(fun(data, nX, nY, nZ, nTS, nPar, file_extension.encode('utf-8')))
|
return ctypes.c_void_p(fun(nX, nY, nZ, nTS, nPar, prec.encode('utf-8')))
|
||||||
#==================================================================================================#
|
#==================================================================================================#
|
||||||
def get_data(data, buffer, size):
|
def alloc_decoder():
|
||||||
fun = libbwc.bwc_get_data
|
fun = libbwc.bwc_alloc_decoder
|
||||||
fun.restype = None
|
|
||||||
fun.argtypes = [ctypes.c_void_p,
|
|
||||||
ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"),
|
|
||||||
ctypes.c_uint64]
|
|
||||||
fun(data, buffer, size)
|
|
||||||
#==================================================================================================#
|
|
||||||
def add_param(data, name, sample, dim, precision):
|
|
||||||
fun = libbwc.bwc_add_param
|
|
||||||
fun.restype = None
|
|
||||||
fun.argtypes = [ctypes.c_void_p,
|
|
||||||
ctypes.c_char_p,
|
|
||||||
ctypes.c_uint16,
|
|
||||||
ctypes.c_uint8,
|
|
||||||
ctypes.c_uint8]
|
|
||||||
fun(data, name.encode('utf-8'), sample, dim, precision)
|
|
||||||
#==================================================================================================#
|
|
||||||
def kill_compression(field):
|
|
||||||
fun = libbwc.bwc_kill_compression
|
|
||||||
fun.restype = None
|
|
||||||
fun.argtypes = [ctypes.c_void_p]
|
|
||||||
fun(field)
|
|
||||||
#==================================================================================================#
|
|
||||||
def initialize_field(data):
|
|
||||||
fun = libbwc.bwc_initialize_field
|
|
||||||
fun.restype = ctypes.c_void_p
|
fun.restype = ctypes.c_void_p
|
||||||
fun.argtypes = [ctypes.c_void_p]
|
fun.argtypes = []
|
||||||
return ctypes.c_void_p(fun(data))
|
return ctypes.c_void_p(fun())
|
||||||
#==================================================================================================#
|
#==================================================================================================#
|
||||||
def set_codeblocks(field, cbX, cbY, cbZ, cbTS):
|
def free_codec(codec):
|
||||||
|
fun = libbwc.bwc_free_codec
|
||||||
|
fun.restype = None
|
||||||
|
fun.argtypes = [ctypes.c_void_p]
|
||||||
|
fun(codec)
|
||||||
|
#==================================================================================================#
|
||||||
|
def set_codeblocks(codec, cbX, cbY, cbZ, cbTS):
|
||||||
fun = libbwc.bwc_set_codeblocks
|
fun = libbwc.bwc_set_codeblocks
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p,
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
@ -140,9 +122,9 @@ def set_codeblocks(field, cbX, cbY, cbZ, cbTS):
|
||||||
ctypes.c_uint8,
|
ctypes.c_uint8,
|
||||||
ctypes.c_uint8,
|
ctypes.c_uint8,
|
||||||
ctypes.c_uint8]
|
ctypes.c_uint8]
|
||||||
fun(field, cbX, cbY, cbZ, cbTS)
|
fun(codec, cbX, cbY, cbZ, cbTS)
|
||||||
#==================================================================================================#
|
#==================================================================================================#
|
||||||
def set_decomp(field, decompX, decompY, decompZ, decompTS):
|
def set_decomp(codec, decompX, decompY, decompZ, decompTS):
|
||||||
fun = libbwc.bwc_set_decomp
|
fun = libbwc.bwc_set_decomp
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p,
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
@ -150,16 +132,16 @@ def set_decomp(field, decompX, decompY, decompZ, decompTS):
|
||||||
ctypes.c_uint8,
|
ctypes.c_uint8,
|
||||||
ctypes.c_uint8,
|
ctypes.c_uint8,
|
||||||
ctypes.c_uint8]
|
ctypes.c_uint8]
|
||||||
fun(field, decompX, decompY, decompZ, decompTS)
|
fun(codec, decompX, decompY, decompZ, decompTS)
|
||||||
#==================================================================================================#
|
#==================================================================================================#
|
||||||
def set_qm(field, Qm):
|
def set_qm(codec, Qm):
|
||||||
fun = libbwc.bwc_set_qm
|
fun = libbwc.bwc_set_qm
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p,
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
ctypes.c_int8]
|
ctypes.c_uint8]
|
||||||
fun(field, Qm)
|
fun(codec, Qm)
|
||||||
#==================================================================================================#
|
#==================================================================================================#
|
||||||
def set_tiles(field, tilesX, tilesY, tilesZ, tilesTS, instr):
|
def set_tiles(codec, tilesX, tilesY, tilesZ, tilesTS, instr):
|
||||||
fun = libbwc.bwc_set_tiles
|
fun = libbwc.bwc_set_tiles
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p,
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
@ -168,9 +150,9 @@ def set_tiles(field, tilesX, tilesY, tilesZ, tilesTS, instr):
|
||||||
ctypes.c_uint64,
|
ctypes.c_uint64,
|
||||||
ctypes.c_uint64,
|
ctypes.c_uint64,
|
||||||
ctypes.c_char_p]
|
ctypes.c_char_p]
|
||||||
fun(field, tilesX, tilesY, tilesZ, tilesTS, instr.encode('utf-8'))
|
fun(codec, tilesX, tilesY, tilesZ, tilesTS, instr.encode('utf-8'))
|
||||||
#==================================================================================================#
|
#==================================================================================================#
|
||||||
def set_precincts(field, pX, pY, pZ, pTS):
|
def set_precincts(codec, pX, pY, pZ, pTS):
|
||||||
fun = libbwc.bwc_set_precincts
|
fun = libbwc.bwc_set_precincts
|
||||||
fun.restype = None
|
fun.restype = None
|
||||||
fun.argtypes = [ctypes.c_void_p,
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
@ -178,32 +160,34 @@ def set_precincts(field, pX, pY, pZ, pTS):
|
||||||
ctypes.c_uint8,
|
ctypes.c_uint8,
|
||||||
ctypes.c_uint8,
|
ctypes.c_uint8,
|
||||||
ctypes.c_uint8]
|
ctypes.c_uint8]
|
||||||
fun(field, pX, pY, pZ, pTS)
|
fun(codec, pX, pY, pZ, pTS)
|
||||||
#==================================================================================================#
|
#==================================================================================================#
|
||||||
def create_compression(field, rate_control):
|
def create_compression(codec, stream, rate_control):
|
||||||
fun = libbwc.bwc_create_compression
|
fun = libbwc.bwc_create_compression
|
||||||
fun.restype = None
|
fun.restype = ctypes.c_uchar
|
||||||
fun.argtypes = [ctypes.c_void_p,
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
ctypes.c_void_p,
|
||||||
ctypes.c_char_p]
|
ctypes.c_char_p]
|
||||||
fun(field, rate_control.encode('utf-8'))
|
return ctypes.c_uchar(fun(codec, stream, rate_control.encode('utf-8')))
|
||||||
#==================================================================================================#
|
#==================================================================================================#
|
||||||
def compress(field, data):
|
def compress(codec, stream):
|
||||||
fun = libbwc.bwc_compress
|
fun = libbwc.bwc_compress
|
||||||
fun.restype = None
|
fun.restype = ctypes.c_size_t
|
||||||
fun.argtypes = [ctypes.c_void_p,
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
ctypes.c_void_p]
|
ctypes.c_void_p]
|
||||||
fun(field, data)
|
return ctypes.c_size_t(fun(codec, stream))
|
||||||
#==================================================================================================#
|
#==================================================================================================#
|
||||||
def create_decompression(field, data):
|
def create_decompression(codec, stream, layer):
|
||||||
fun = libbwc.bwc_create_decompression
|
fun = libbwc.bwc_create_decompression
|
||||||
fun.restype = ctypes.c_void_p
|
fun.restype = ctypes.c_uchar
|
||||||
fun.argtypes = [ctypes.c_void_p,
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
|
ctypes.c_void_p,
|
||||||
ctypes.c_uint8]
|
ctypes.c_uint8]
|
||||||
return ctypes.c_void_p(fun(field, data))
|
return ctypes.c_uchar(fun(codec, stream, layer))
|
||||||
#==================================================================================================#
|
#==================================================================================================#
|
||||||
def decompress(field, data):
|
def decompress(codec, stream):
|
||||||
fun = libbwc.bwc_decompress
|
fun = libbwc.bwc_decompress
|
||||||
fun.restype = None
|
fun.restype = ctypes.c_uchar
|
||||||
fun.argtypes = [ctypes.c_void_p,
|
fun.argtypes = [ctypes.c_void_p,
|
||||||
ctypes.c_void_p]
|
ctypes.c_void_p]
|
||||||
fun(field, data)
|
return ctypes.c_uchar(fun(codec, stream))
|
File diff suppressed because it is too large
Load diff
|
@ -107,8 +107,6 @@ bytes_used(bitstream const *const stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: bitstream* bwc_init_stream(uchar* memory, uint32 size, char instr) !
|
|
||||||
! -------------- !
|
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
! ------------ !
|
! ------------ !
|
||||||
|
@ -145,7 +143,7 @@ bytes_used(bitstream const *const stream)
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
bitstream*
|
bitstream*
|
||||||
init_stream(uchar* memory, uint32 size, char instr)
|
init_bitstream(uchar* memory, uint32 size, char instr)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE STRUCTS: !
|
! DEFINE STRUCTS: !
|
||||||
|
@ -155,6 +153,7 @@ init_stream(uchar* memory, uint32 size, char instr)
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
|
assert(memory);
|
||||||
assert(instr == 'c' || instr == 'd');
|
assert(instr == 'c' || instr == 'd');
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
|
@ -168,37 +167,11 @@ init_stream(uchar* memory, uint32 size, char instr)
|
||||||
return NULL;
|
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 !
|
! Initialize the byte buffer counter, stream size and size !
|
||||||
! increment for the current stream. !
|
! increment for the current stream. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
|
stream->memory = memory;
|
||||||
stream->t = (instr == 'c') ? 8 : 0;
|
stream->t = (instr == 'c') ? 8 : 0;
|
||||||
stream->Lmax = size;
|
stream->Lmax = size;
|
||||||
stream->size_incr = (uint64)(size / 2);
|
stream->size_incr = (uint64)(size / 2);
|
||||||
|
@ -247,11 +220,6 @@ init_stream(uchar* memory, uint32 size, char instr)
|
||||||
void
|
void
|
||||||
emit_chunck(bitstream *const stream, const uchar* chunck, const uint64 size)
|
emit_chunck(bitstream *const stream, const uchar* chunck, const uint64 size)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
|
||||||
! DEFINE INT VARIABLES: !
|
|
||||||
\*-----------------------*/
|
|
||||||
uint64 Lreq;
|
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
|
@ -259,54 +227,30 @@ emit_chunck(bitstream *const stream, const uchar* chunck, const uint64 size)
|
||||||
assert(chunck);
|
assert(chunck);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Evaluate the memory block size if the current chunck of !
|
! Check if an error was encountered in a previous writing !
|
||||||
! data is written to the stream. !
|
! operation !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
Lreq = (bytes_used(stream) + size);
|
if(!stream->error)
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
|
||||||
! 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 !
|
! Check if the enough memory has been allocated for the !
|
||||||
! to an error encountered in a previous writing operation !
|
! stream to store the additional symbol. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
if(!stream->error)
|
if((bytes_used(stream) + size) > stream->Lmax)
|
||||||
{
|
{
|
||||||
/*--------------------------------------------------------*\
|
// memory allocation error
|
||||||
! If the error flag is not set, increase the stream size !
|
stream->error |= 1;
|
||||||
! until it is large enough to store the additional data !
|
stream->Lmax = 0;
|
||||||
! 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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------*\
|
||||||
|
! Exit to function caller if error flag has been set. !
|
||||||
|
\*--------------------------------------------------------*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Copy the additional data to the stream memory block. !
|
! Copy the additional data to the stream memory block. !
|
||||||
|
@ -370,44 +314,30 @@ emit_symbol(bitstream *const stream, const uint64 symbol, const uint8 size)
|
||||||
assert(stream);
|
assert(stream);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Check if the enough memory has been allocated for the !
|
! Check if an error was encountered in a previous writing !
|
||||||
! stream to store the additional symbol. !
|
! operation !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
if((bytes_used(stream) + size) > stream->Lmax)
|
if(!stream->error)
|
||||||
{
|
{
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! If the stream is not large enough, check if this is due !
|
! Check if the enough memory has been allocated for the !
|
||||||
! to an error encountered in a previous writing operation !
|
! stream to store the additional symbol. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
if(!stream->error)
|
if((bytes_used(stream) + size) > stream->Lmax)
|
||||||
{
|
{
|
||||||
/*--------------------------------------------------------*\
|
// memory allocation error
|
||||||
! If the error flag is not set, increment the stream size !
|
stream->error |= 1;
|
||||||
! to store the additional symbol. !
|
stream->Lmax = 0;
|
||||||
\*--------------------------------------------------------*/
|
|
||||||
stream->Lmax += stream->size_incr;
|
|
||||||
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------*\
|
||||||
|
! Exit to function caller if error flag has been set. !
|
||||||
|
\*--------------------------------------------------------*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Copy the additional symbol to the stream memory block !
|
! Copy the additional symbol to the stream memory block !
|
||||||
|
@ -868,76 +798,79 @@ flush_stream(bitstream *const stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: void *test(void) !
|
|
||||||
! -------------- !
|
|
||||||
! !
|
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
! ------------ !
|
! ------------ !
|
||||||
! DESCRIPTION NEEDED !
|
! Shrinks the bitstream memory to the actually filled range. !
|
||||||
! !
|
|
||||||
! PARAMETERS: !
|
|
||||||
! ----------- !
|
|
||||||
! Variable Type Description !
|
|
||||||
! -------- ---- ----------- !
|
|
||||||
! - - - !
|
|
||||||
! !
|
! !
|
||||||
! RETURN VALUE: !
|
! RETURN VALUE: !
|
||||||
! ------------- !
|
! ------------- !
|
||||||
! Type Description !
|
! Returns 0 if successfull and 1 if memory could not be resized. !
|
||||||
! ---- ----------- !
|
|
||||||
! - - !
|
|
||||||
! !
|
|
||||||
! DEVELOPMENT HISTORY: !
|
|
||||||
! -------------------- !
|
|
||||||
! !
|
|
||||||
! Date Author Change Id Release Description Of Change !
|
|
||||||
! ---- ------ --------- ------- --------------------- !
|
|
||||||
! - Patrick Vogler B87D120 V 0.1.0 function created !
|
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
uchar
|
uchar
|
||||||
terminate_stream(bitstream *stream, bwc_stream *const packed_stream)
|
shrink_to_fit(bitstream *const stream)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(stream);
|
assert(stream);
|
||||||
|
|
||||||
if(packed_stream)
|
if(stream->error)
|
||||||
{
|
{
|
||||||
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;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: void release_packed_stream(bwc_stream *stream) !
|
! DESCRIPTION: !
|
||||||
|
! ------------ !
|
||||||
|
! Swap memory pointer and size to span. Invalidates stream pointers. !
|
||||||
|
! !
|
||||||
|
! RETURN VALUE: !
|
||||||
|
! ------------- !
|
||||||
|
! Returns 0 if successfull and 1 if stream had previous memory error. !
|
||||||
|
! !
|
||||||
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
|
uchar
|
||||||
|
transfer_to_span(bitstream *const stream, bwc_span *const span)
|
||||||
|
{
|
||||||
|
/*-----------------------*\
|
||||||
|
! DEFINE ASSERTIONS: !
|
||||||
|
\*-----------------------*/
|
||||||
|
assert(stream);
|
||||||
|
assert(span);
|
||||||
|
|
||||||
|
if(stream->error)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
span->memory = stream->memory;
|
||||||
|
span->access = stream->memory;
|
||||||
|
span->size = stream->L;
|
||||||
|
span->position = 0;
|
||||||
|
|
||||||
|
stream->memory = NULL;
|
||||||
|
stream->L = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
|
! FUNCTION NAME: void release_packed_stream(bwc_span *stream) !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -949,7 +882,7 @@ terminate_stream(bitstream *stream, bwc_stream *const packed_stream)
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! stream bwc_stream - Packed bitstream used to store parts of !
|
! stream bwc_span - Packed bitstream used to store parts of !
|
||||||
! the bwc codestream. !
|
! the bwc codestream. !
|
||||||
! !
|
! !
|
||||||
! RETURN VALUE: !
|
! RETURN VALUE: !
|
||||||
|
@ -967,7 +900,7 @@ terminate_stream(bitstream *stream, bwc_stream *const packed_stream)
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
release_packed_stream(bwc_stream *stream)
|
release_packed_stream(bwc_span *stream)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
|
|
|
@ -104,7 +104,7 @@ can_read(bitstream *const stream, const uint64 length)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: void codestream_write_header(bitstream *const stream, bwc_field *const field) !
|
! FUNCTION NAME: void codestream_write_header(bitstream *const stream, bwc_codec *const codec) !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -116,7 +116,7 @@ can_read(bitstream *const stream, const uint64 length)
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
! codec bwc_codec* - Structure defining the compression/ !
|
||||||
! decompression stage. !
|
! decompression stage. !
|
||||||
! !
|
! !
|
||||||
! stream bitstream* - Structure used to assemble a bwc bit- !
|
! stream bitstream* - Structure used to assemble a bwc bit- !
|
||||||
|
@ -138,7 +138,8 @@ can_read(bitstream *const stream, const uint64 length)
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
codestream_write_header(bitstream *const stream,
|
codestream_write_header(bitstream *const stream,
|
||||||
bwc_field *const field)
|
bwc_codec *const codec,
|
||||||
|
bwc_stream *const data)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
|
@ -155,33 +156,27 @@ codestream_write_header(bitstream *const stream,
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
bwc_gl_ctrl *control;
|
bwc_gl_ctrl *control;
|
||||||
bwc_gl_inf *info;
|
bwc_gl_inf *info;
|
||||||
bwc_tile *tile;
|
bwc_span *aux;
|
||||||
bwc_parameter *parameter;
|
bwc_span *com;
|
||||||
bwc_stream *aux;
|
|
||||||
bwc_stream *com;
|
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(stream);
|
assert(stream);
|
||||||
assert(field);
|
assert(codec);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Save the global as well as the subband control and info !
|
! Save the global as well as the subband control and info !
|
||||||
! structure to temporary variables to make the code more !
|
! structure to temporary variables to make the code more !
|
||||||
! readable. !
|
! readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
info = field->info;
|
info = &codec->info;
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
|
|
||||||
tile = &field->tile[0];
|
aux = data->codestream.aux;
|
||||||
|
com = data->codestream.com;
|
||||||
parameter = &tile->parameter[0];
|
|
||||||
|
|
||||||
aux = field->aux;
|
|
||||||
com = field->com;
|
|
||||||
|
|
||||||
Linf = 40 + info->nPar * 25;
|
Linf = 31;
|
||||||
Lctr = 50 + control->nLayers * 4;
|
Lctr = 50 + control->nLayers * 4;
|
||||||
Leoh = info->nPar * control->nTiles * 2 * PREC_BYTE;
|
Leoh = info->nPar * control->nTiles * 2 * PREC_BYTE;
|
||||||
Lcss = control->codestreamSize;
|
Lcss = control->codestreamSize;
|
||||||
|
@ -193,16 +188,10 @@ codestream_write_header(bitstream *const stream,
|
||||||
emit_symbol(stream, info->nX, 8);
|
emit_symbol(stream, info->nX, 8);
|
||||||
emit_symbol(stream, info->nY, 8);
|
emit_symbol(stream, info->nY, 8);
|
||||||
emit_symbol(stream, info->nZ, 8);
|
emit_symbol(stream, info->nZ, 8);
|
||||||
emit_symbol(stream, info->nTS, 2);
|
emit_symbol(stream, info->nTS, 8);
|
||||||
emit_symbol(stream, info->nPar, 1);
|
emit_symbol(stream, info->nPar, 1);
|
||||||
emit_symbol(stream, info->precision, 1);
|
emit_symbol(stream, (uint8)info->data_prec, 1);
|
||||||
emit_chunck(stream, (uchar*)info->f_ext, 10);
|
emit_symbol(stream, (uint8)info->codec_prec, 1);
|
||||||
|
|
||||||
for(p = 0; p < info->nPar; ++p)
|
|
||||||
{
|
|
||||||
emit_chunck(stream, (uchar*)parameter[p].info.name, 24);
|
|
||||||
emit_symbol(stream, parameter[p].info.precision, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit_symbol(stream, SGC, 2);
|
emit_symbol(stream, SGC, 2);
|
||||||
emit_symbol(stream, Lctr, 2);
|
emit_symbol(stream, Lctr, 2);
|
||||||
|
@ -239,7 +228,7 @@ codestream_write_header(bitstream *const stream,
|
||||||
emit_symbol(stream, control->tileSizeX, 8);
|
emit_symbol(stream, control->tileSizeX, 8);
|
||||||
emit_symbol(stream, control->tileSizeY, 8);
|
emit_symbol(stream, control->tileSizeY, 8);
|
||||||
emit_symbol(stream, control->tileSizeZ, 8);
|
emit_symbol(stream, control->tileSizeZ, 8);
|
||||||
emit_symbol(stream, control->tileSizeTS, 2);
|
emit_symbol(stream, control->tileSizeTS, 8);
|
||||||
|
|
||||||
emit_symbol(stream, control->nLayers, 1);
|
emit_symbol(stream, control->nLayers, 1);
|
||||||
|
|
||||||
|
@ -274,21 +263,21 @@ codestream_write_header(bitstream *const stream,
|
||||||
for(p = 0; p < info->nPar; ++p)
|
for(p = 0; p < info->nPar; ++p)
|
||||||
{
|
{
|
||||||
|
|
||||||
emit_symbol(stream, *(uint64 *)&field->tile[t].
|
emit_symbol(stream, *(uint64 *)&codec->tile[t].
|
||||||
parameter[p].info.
|
parameter[p].info.
|
||||||
parameter_min, PREC_BYTE);
|
parameter_min, PREC_BYTE);
|
||||||
emit_symbol(stream, *(uint64 *)&field->tile[t].
|
emit_symbol(stream, *(uint64 *)&codec->tile[t].
|
||||||
parameter[p].info.
|
parameter[p].info.
|
||||||
parameter_max, PREC_BYTE);
|
parameter_max, PREC_BYTE);
|
||||||
|
|
||||||
field->tile[t].parameter[p].info.parameter_max = -FLT_MAX;
|
codec->tile[t].parameter[p].info.parameter_max = -FLT_MAX;
|
||||||
field->tile[t].parameter[p].info.parameter_min = FLT_MAX;
|
codec->tile[t].parameter[p].info.parameter_min = FLT_MAX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: uchar sequence_packets(bwc_field *const field, bwc_field *const field) !
|
! FUNCTION NAME: uchar sequence_packets(bwc_codec *const codec, bwc_tile *const tile) !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -299,7 +288,7 @@ codestream_write_header(bitstream *const stream,
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
! codec bwc_codec* - Structure defining the compression/ !
|
||||||
! decompression stage. !
|
! decompression stage. !
|
||||||
! !
|
! !
|
||||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||||
|
@ -319,7 +308,7 @@ codestream_write_header(bitstream *const stream,
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
static uchar
|
static uchar
|
||||||
sequence_packets(bwc_field *const field, bwc_tile *const tile)
|
sequence_packets(bwc_codec *const codec, bwc_tile *const tile)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
|
@ -347,8 +336,8 @@ sequence_packets(bwc_field *const field, bwc_tile *const tile)
|
||||||
! sequence structure to temporary variables to make the !
|
! sequence structure to temporary variables to make the !
|
||||||
! code more readable. !
|
! code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
info = field->info;
|
info = &codec->info;
|
||||||
|
|
||||||
packet_sequence = tile->packet_sequence;
|
packet_sequence = tile->packet_sequence;
|
||||||
|
|
||||||
|
@ -490,7 +479,7 @@ sequence_packets(bwc_field *const field, bwc_tile *const tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: uchar sequence_packets(bwc_field *const field, bwc_field *const field) !
|
! FUNCTION NAME: !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -501,16 +490,11 @@ sequence_packets(bwc_field *const field, bwc_tile *const tile)
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
|
||||||
! decompression stage. !
|
|
||||||
! !
|
|
||||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
|
||||||
! !
|
! !
|
||||||
! RETURN VALUE: !
|
! RETURN VALUE: !
|
||||||
! ------------- !
|
! ------------- !
|
||||||
! Type Description !
|
! Type Description !
|
||||||
! ---- ----------- !
|
! ---- ----------- !
|
||||||
! uchar - Returns an unsigned char for error handling. !
|
|
||||||
! !
|
! !
|
||||||
! DEVELOPMENT HISTORY: !
|
! DEVELOPMENT HISTORY: !
|
||||||
! -------------------- !
|
! -------------------- !
|
||||||
|
@ -521,7 +505,7 @@ sequence_packets(bwc_field *const field, bwc_tile *const tile)
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
assemble_tile(bwc_field *const field, bwc_tile *const tile, bitstream *const stream)
|
assemble_tile(bwc_codec *const codec, bwc_tile *const tile, bitstream *const stream)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
|
@ -537,7 +521,7 @@ assemble_tile(bwc_field *const field, bwc_tile *const tile, bitstream *const str
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(tile);
|
assert(tile);
|
||||||
assert(stream);
|
assert(stream);
|
||||||
|
|
||||||
|
@ -546,7 +530,7 @@ assemble_tile(bwc_field *const field, bwc_tile *const tile, bitstream *const str
|
||||||
! sequence structure to temporary variables to make the !
|
! sequence structure to temporary variables to make the !
|
||||||
! code more readable. !
|
! code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
|
|
||||||
emit_symbol(stream, SOT, 2);
|
emit_symbol(stream, SOT, 2);
|
||||||
emit_symbol(stream, 14, 2);
|
emit_symbol(stream, 14, 2);
|
||||||
|
@ -613,14 +597,14 @@ assemble_tile(bwc_field *const field, bwc_tile *const tile, bitstream *const str
|
||||||
! - Patrick Vogler B87D120 V 0.1.0 function created !
|
! - Patrick Vogler B87D120 V 0.1.0 function created !
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
bwc_field*
|
bwc_codec*
|
||||||
parse_main_header(bwc_data *const data,bitstream *const stream)
|
parse_main_header(bwc_codec *const codec, bwc_stream *const data, bitstream *const stream)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
uint64 buff_long, buffX, buffY, buffZ, buffTS;
|
uint64 buff_long, buffX, buffY, buffZ, buffTS;
|
||||||
uint64 nX, nY, nZ;
|
uint64 nX, nY, nZ, nTS;
|
||||||
uint32 buff;
|
uint32 buff;
|
||||||
uint32 bitrate;
|
uint32 bitrate;
|
||||||
uint32 Lsax;
|
uint32 Lsax;
|
||||||
|
@ -629,35 +613,34 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
uint16 CSsgc;
|
uint16 CSsgc;
|
||||||
uint16 Linf, Lctr, Lcom, Leoh, Lunk;
|
uint16 Linf, Lctr, Lcom, Leoh, Lunk;
|
||||||
uint16 marker;
|
uint16 marker;
|
||||||
uint16 nTS;
|
|
||||||
uint8 index, l;
|
uint8 index, l;
|
||||||
uint8 nPar, p;
|
uint8 nPar, p;
|
||||||
uint8 codec_prec, precision;
|
bwc_precision data_prec, codec_prec;
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE CHAR VARIABLES: !
|
! DEFINE CHAR VARIABLES: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
char* buffer_char;
|
|
||||||
char status;
|
char status;
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE STRUCTS: !
|
! DEFINE STRUCTS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
bwc_field *field;
|
|
||||||
bwc_gl_ctrl *control;
|
bwc_gl_ctrl *control;
|
||||||
bwc_gl_inf *info;
|
bwc_gl_inf *info;
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
|
assert(codec);
|
||||||
assert(data);
|
assert(data);
|
||||||
assert(stream);
|
assert(stream);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Save the data info structure to a temporary variable to !
|
! Save the global control and info structure to temporary !
|
||||||
! make the code more readable. !
|
! variables to make the code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
info = &data->info;
|
info = &codec->info;
|
||||||
|
control = &codec->control;
|
||||||
|
|
||||||
status = CODESTREAM_OK;
|
status = CODESTREAM_OK;
|
||||||
index = 0;
|
index = 0;
|
||||||
|
@ -708,41 +691,23 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->nX = nX = get_symbol(stream, 8);
|
nX = get_symbol(stream, 8);
|
||||||
info->nY = nY = get_symbol(stream, 8);
|
nY = get_symbol(stream, 8);
|
||||||
info->nZ = nZ = get_symbol(stream, 8);
|
nZ = get_symbol(stream, 8);
|
||||||
info->nTS = nTS = (uint16)get_symbol(stream, 2);
|
nTS = get_symbol(stream, 8);
|
||||||
info->nPar = nPar = (uint8)get_symbol(stream, 1);
|
nPar = (uint8)get_symbol(stream, 1);
|
||||||
info->precision = codec_prec = (uint8)get_symbol(stream, 1);
|
data_prec = (bwc_precision)get_symbol(stream, 1);
|
||||||
|
codec_prec = (bwc_precision)get_symbol(stream, 1);
|
||||||
|
|
||||||
buffer_char = (char*)get_chunck(stream, 10);
|
info->codec_prec = codec_prec;
|
||||||
strncpy(info->f_ext, buffer_char, sizeof(buffer_char)/sizeof(*buffer_char));
|
|
||||||
free(buffer_char);
|
|
||||||
|
|
||||||
for(p = 0; p < nPar; ++p)
|
configure_codec(codec, nX, nY, nZ, nTS, nPar, data_prec);
|
||||||
{
|
if(!codec)
|
||||||
buffer_char = (char*)get_chunck(stream, 24);
|
|
||||||
precision = (uint8)get_symbol(stream, 1);
|
|
||||||
|
|
||||||
bwc_add_param(data, buffer_char, precision);
|
|
||||||
|
|
||||||
free(buffer_char);
|
|
||||||
}
|
|
||||||
|
|
||||||
field = bwc_initialize_field(data);
|
|
||||||
if(!field)
|
|
||||||
{
|
{
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
|
||||||
! Save the global control and info structure to temporary !
|
|
||||||
! variables to make the code more readable. !
|
|
||||||
\*--------------------------------------------------------*/
|
|
||||||
info = field->info = &data->info;
|
|
||||||
control = &field->control;
|
|
||||||
|
|
||||||
control->codestreamSize = stream->Lmax;
|
control->codestreamSize = stream->Lmax;
|
||||||
|
|
||||||
status |= CODESTREAM_SGI_READ;
|
status |= CODESTREAM_SGI_READ;
|
||||||
|
@ -755,7 +720,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -766,7 +731,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -777,14 +742,14 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
buff_long = get_symbol(stream, 1);
|
buff_long = get_symbol(stream, 1);
|
||||||
if(CSsgc & (0x01 << 0))
|
if(CSsgc & (0x01 << 0))
|
||||||
{
|
{
|
||||||
bwc_set_error_resilience(field);
|
bwc_set_error_resilience(codec);
|
||||||
}
|
}
|
||||||
|
|
||||||
buff_long = get_symbol(stream, 1);
|
buff_long = get_symbol(stream, 1);
|
||||||
|
|
||||||
if(CSsgc & (0x01 << 1))
|
if(CSsgc & (0x01 << 1))
|
||||||
{
|
{
|
||||||
set_quant_style(field, (bwc_quant_st)buff_long);
|
set_quant_style(codec, (bwc_quant_st)buff_long);
|
||||||
}
|
}
|
||||||
|
|
||||||
buff_long = get_symbol(stream, 1);
|
buff_long = get_symbol(stream, 1);
|
||||||
|
@ -800,50 +765,50 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
buff_long = get_symbol(stream, 1);
|
buff_long = get_symbol(stream, 1);
|
||||||
if(CSsgc & (0x01 << 3))
|
if(CSsgc & (0x01 << 3))
|
||||||
{
|
{
|
||||||
set_progression(field, (uint8)buff_long);
|
set_progression(codec, (uint8)buff_long);
|
||||||
}
|
}
|
||||||
|
|
||||||
buff_long = get_symbol(stream, 1);
|
buff_long = get_symbol(stream, 1);
|
||||||
if(CSsgc & (0x01 << 4))
|
if(CSsgc & (0x01 << 4))
|
||||||
{
|
{
|
||||||
set_kernels(field, (uint8)(0x03 & (buff_long >> 6)), (uint8)(0x03 & (buff_long >> 4)),
|
set_kernels(codec, (uint8)(0x03 & (buff_long >> 6)), (uint8)(0x03 & (buff_long >> 4)),
|
||||||
(uint8)(0x03 & (buff_long >> 2)), (uint8)(0x03 & buff_long));
|
(uint8)(0x03 & (buff_long >> 2)), (uint8)(0x03 & buff_long));
|
||||||
}
|
}
|
||||||
|
|
||||||
buff_long = get_symbol(stream, 4);
|
buff_long = get_symbol(stream, 4);
|
||||||
if(CSsgc & (0x01 << 5))
|
if(CSsgc & (0x01 << 5))
|
||||||
{
|
{
|
||||||
bwc_set_decomp(field, (uint8)(0xFF & (buff_long >> 24)), (uint8)(0xFF & (buff_long >> 16)),
|
bwc_set_decomp(codec, (uint8)(0xFF & (buff_long >> 24)), (uint8)(0xFF & (buff_long >> 16)),
|
||||||
(uint8)(0xFF & (buff_long >> 8)), (uint8)(0xFF & buff_long));
|
(uint8)(0xFF & (buff_long >> 8)), (uint8)(0xFF & buff_long));
|
||||||
}
|
}
|
||||||
|
|
||||||
buff_long = get_symbol(stream, 2);
|
buff_long = get_symbol(stream, 2);
|
||||||
if(CSsgc & (0x01 << 6))
|
if(CSsgc & (0x01 << 6))
|
||||||
{
|
{
|
||||||
bwc_set_precincts(field, (uint8)(0x0F & (buff_long >> 8)), (uint8)(0x0F & (buff_long >> 12)),
|
bwc_set_precincts(codec, (uint8)(0x0F & (buff_long >> 8)), (uint8)(0x0F & (buff_long >> 12)),
|
||||||
(uint8)(0x0F & buff_long), (uint8)(0x0F & (buff_long >> 4)));
|
(uint8)(0x0F & buff_long), (uint8)(0x0F & (buff_long >> 4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
buff_long = get_symbol(stream, 4);
|
buff_long = get_symbol(stream, 4);
|
||||||
if(CSsgc & (0x01 << 7))
|
if(CSsgc & (0x01 << 7))
|
||||||
{
|
{
|
||||||
bwc_set_codeblocks(field, (uint8)(0xFF & (buff_long >> 24)), (uint8)(0xFF & (buff_long >> 16)),
|
bwc_set_codeblocks(codec, (uint8)(0xFF & (buff_long >> 24)), (uint8)(0xFF & (buff_long >> 16)),
|
||||||
(uint8)(0xFF & (buff_long >> 8)), (uint8)(0xFF & buff_long));
|
(uint8)(0xFF & (buff_long >> 8)), (uint8)(0xFF & buff_long));
|
||||||
}
|
}
|
||||||
|
|
||||||
buff_long = get_symbol(stream, 1);
|
buff_long = get_symbol(stream, 1);
|
||||||
if(CSsgc & (0x01 << 8))
|
if(CSsgc & (0x01 << 8))
|
||||||
{
|
{
|
||||||
bwc_set_qm(field, (uint8)buff_long);
|
bwc_set_qm(codec, (uint8)buff_long);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffX = get_symbol(stream, 8);
|
buffX = get_symbol(stream, 8);
|
||||||
buffY = get_symbol(stream, 8);
|
buffY = get_symbol(stream, 8);
|
||||||
buffZ = get_symbol(stream, 8);
|
buffZ = get_symbol(stream, 8);
|
||||||
buffTS = get_symbol(stream, 2);
|
buffTS = get_symbol(stream, 8);
|
||||||
if(CSsgc & (0x01 << 9))
|
if(CSsgc & (0x01 << 9))
|
||||||
{
|
{
|
||||||
bwc_set_tiles(field, buffX, buffY, buffZ, (uint16)buffTS, bwc_tile_sizeof);
|
bwc_set_tiles(codec, buffX, buffY, buffZ, buffTS, bwc_tile_sizeof);
|
||||||
}
|
}
|
||||||
|
|
||||||
control->nLayers = get_symbol(stream, 1);
|
control->nLayers = get_symbol(stream, 1);
|
||||||
|
@ -852,7 +817,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
{
|
{
|
||||||
// memory allocation error
|
// memory allocation error
|
||||||
fprintf(stderr, MEMERROR);
|
fprintf(stderr, MEMERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status|= CODESTREAM_ERROR;
|
status|= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -863,10 +828,10 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
control->bitrate[l] = *(float *)&bitrate;
|
control->bitrate[l] = *(float *)&bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
create_field(field);
|
create_codec(codec);
|
||||||
if(!field)
|
if(!codec)
|
||||||
{
|
{
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -881,7 +846,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -891,17 +856,17 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->codestream.aux = calloc(1, sizeof(bwc_stream));
|
data->codestream.aux = calloc(1, sizeof(bwc_span));
|
||||||
if(!data->codestream.aux)
|
if(!data->codestream.aux)
|
||||||
{
|
{
|
||||||
// memory allocation error
|
// memory allocation error
|
||||||
fprintf(stderr, MEMERROR);
|
fprintf(stderr, MEMERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -919,7 +884,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -929,17 +894,17 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->codestream.com = calloc(1, sizeof(bwc_stream));
|
data->codestream.com = calloc(1, sizeof(bwc_span));
|
||||||
if(!data->codestream.com)
|
if(!data->codestream.com)
|
||||||
{
|
{
|
||||||
// memory allocation error
|
// memory allocation error
|
||||||
fprintf(stderr, MEMERROR);
|
fprintf(stderr, MEMERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -947,7 +912,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,7 +924,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -969,12 +934,12 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(codec_prec == 8)
|
if(codec_prec == bwc_precision_double)
|
||||||
{
|
{
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Loop through all tile parameters and... !
|
! Loop through all tile parameters and... !
|
||||||
|
@ -988,14 +953,14 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
! header stream. !
|
! header stream. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
buff_long = get_symbol(stream, sizeof(double));
|
buff_long = get_symbol(stream, sizeof(double));
|
||||||
field->tile[t].parameter[p].info.parameter_min = (bwc_float)*(double*)&buff_long;
|
codec->tile[t].parameter[p].info.parameter_min = (bwc_float)*(double*)&buff_long;
|
||||||
|
|
||||||
buff_long = get_symbol(stream, sizeof(double));
|
buff_long = get_symbol(stream, sizeof(double));
|
||||||
field->tile[t].parameter[p].info.parameter_max = (bwc_float)*(double*)&buff_long;
|
codec->tile[t].parameter[p].info.parameter_max = (bwc_float)*(double*)&buff_long;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(codec_prec == 4)
|
else if(codec_prec == bwc_precision_single)
|
||||||
{
|
{
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Loop through all tile parameters and... !
|
! Loop through all tile parameters and... !
|
||||||
|
@ -1009,20 +974,20 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
! header stream. !
|
! header stream. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
buff = get_symbol(stream, sizeof(float));
|
buff = get_symbol(stream, sizeof(float));
|
||||||
field->tile[t].parameter[p].info.parameter_min = (bwc_float)*(float*)&buff;
|
codec->tile[t].parameter[p].info.parameter_min = (bwc_float)*(float*)&buff;
|
||||||
|
|
||||||
buff = get_symbol(stream, sizeof(float));
|
buff = get_symbol(stream, sizeof(float));
|
||||||
field->tile[t].parameter[p].info.parameter_max = (bwc_float)*(float*)&buff;
|
codec->tile[t].parameter[p].info.parameter_max = (bwc_float)*(float*)&buff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return field;
|
return codec;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1034,7 +999,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1044,7 +1009,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1059,7 +1024,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: uchar sequence_packets(bwc_field *const field, bwc_field *const field) !
|
! FUNCTION NAME: !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -1070,16 +1035,11 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
|
||||||
! decompression stage. !
|
|
||||||
! !
|
|
||||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
|
||||||
! !
|
! !
|
||||||
! RETURN VALUE: !
|
! RETURN VALUE: !
|
||||||
! ------------- !
|
! ------------- !
|
||||||
! Type Description !
|
! Type Description !
|
||||||
! ---- ----------- !
|
! ---- ----------- !
|
||||||
! uchar - Returns an unsigned char for error handling. !
|
|
||||||
! !
|
! !
|
||||||
! DEVELOPMENT HISTORY: !
|
! DEVELOPMENT HISTORY: !
|
||||||
! -------------------- !
|
! -------------------- !
|
||||||
|
@ -1090,7 +1050,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream)
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
static uchar
|
static uchar
|
||||||
parse_tile(bwc_field *const field, bitstream *const stream)
|
parse_tile(bwc_codec *const codec, bitstream *const stream)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
|
@ -1110,7 +1070,7 @@ parse_tile(bwc_field *const field, bitstream *const stream)
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(stream);
|
assert(stream);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
|
@ -1118,7 +1078,7 @@ parse_tile(bwc_field *const field, bitstream *const stream)
|
||||||
! sequence structure to temporary variables to make the !
|
! sequence structure to temporary variables to make the !
|
||||||
! code more readable. !
|
! code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
|
|
||||||
if(!can_read(stream, 2))
|
if(!can_read(stream, 2))
|
||||||
{
|
{
|
||||||
|
@ -1144,7 +1104,7 @@ parse_tile(bwc_field *const field, bitstream *const stream)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tile = &field->tile[buf];
|
tile = &codec->tile[buf];
|
||||||
tile->control.body_size =
|
tile->control.body_size =
|
||||||
body_size = (uint64)get_symbol(stream, 8);
|
body_size = (uint64)get_symbol(stream, 8);
|
||||||
|
|
||||||
|
@ -1160,7 +1120,7 @@ parse_tile(bwc_field *const field, bitstream *const stream)
|
||||||
! Sequence the packets according to the user specified op- !
|
! Sequence the packets according to the user specified op- !
|
||||||
! tion. !
|
! tion. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
if(sequence_packets(field, tile))
|
if(sequence_packets(codec, tile))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1198,7 +1158,7 @@ parse_tile(bwc_field *const field, bitstream *const stream)
|
||||||
|
|
||||||
packet->header.memory = get_access(stream);
|
packet->header.memory = get_access(stream);
|
||||||
|
|
||||||
if(parse_packet(field, tile, packet, body_size))
|
if(parse_packet(codec, tile, packet, body_size))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1240,7 +1200,7 @@ parse_tile(bwc_field *const field, bitstream *const stream)
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
static uchar
|
static uchar
|
||||||
parse_body(bwc_field *const field, bitstream *const stream)
|
parse_body(bwc_codec *const codec, bitstream *const stream)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
|
@ -1256,7 +1216,7 @@ parse_body(bwc_field *const field, bitstream *const stream)
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
|
|
||||||
status = CODESTREAM_OK;
|
status = CODESTREAM_OK;
|
||||||
|
|
||||||
|
@ -1274,7 +1234,7 @@ parse_body(bwc_field *const field, bitstream *const stream)
|
||||||
{
|
{
|
||||||
case SOT:
|
case SOT:
|
||||||
{
|
{
|
||||||
if(parse_tile(field, stream))
|
if(parse_tile(codec, stream))
|
||||||
{
|
{
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1307,7 +1267,7 @@ parse_body(bwc_field *const field, bitstream *const stream)
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1317,7 +1277,7 @@ parse_body(bwc_field *const field, bitstream *const stream)
|
||||||
{
|
{
|
||||||
// Invalid Codestream
|
// Invalid Codestream
|
||||||
fprintf(stderr, CSERROR);
|
fprintf(stderr, CSERROR);
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
status |= CODESTREAM_ERROR;
|
status |= CODESTREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1336,7 +1296,7 @@ parse_body(bwc_field *const field, bitstream *const stream)
|
||||||
|| ||
|
|| ||
|
||||||
\************************************************************************************************************/
|
\************************************************************************************************************/
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: bwc_stream* assemble_codestream(bwc_field *const field) !
|
! FUNCTION NAME: bwc_span* assemble_codestream(bwc_codec *const codec, bwc_stream *const data) !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -1347,14 +1307,14 @@ parse_body(bwc_field *const field, bitstream *const stream)
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
! codec bwc_codec* - Structure defining the compression/ !
|
||||||
! decompression stage. !
|
! decompression stage. !
|
||||||
! !
|
! !
|
||||||
! RETURN VALUE: !
|
! RETURN VALUE: !
|
||||||
! ------------- !
|
! ------------- !
|
||||||
! Type Description !
|
! Type Description !
|
||||||
! ---- ----------- !
|
! ---- ----------- !
|
||||||
! bwc_stream* - Packed stream containing the compressed data set. !
|
! bwc_span* - Packed stream containing the compressed data set. !
|
||||||
! !
|
! !
|
||||||
! DEVELOPMENT HISTORY: !
|
! DEVELOPMENT HISTORY: !
|
||||||
! -------------------- !
|
! -------------------- !
|
||||||
|
@ -1364,12 +1324,13 @@ parse_body(bwc_field *const field, bitstream *const stream)
|
||||||
! 13.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
|
! 13.06.2019 Patrick Vogler B87D120 V 0.1.0 function created !
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
bwc_stream*
|
size_t
|
||||||
assemble_codestream(bwc_field *const field)
|
assemble_codestream(bwc_codec *const codec, bwc_stream *const data)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
|
size_t compressed_size;
|
||||||
uint64 i;
|
uint64 i;
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
|
@ -1378,12 +1339,12 @@ assemble_codestream(bwc_field *const field)
|
||||||
bwc_gl_ctrl *control;
|
bwc_gl_ctrl *control;
|
||||||
bwc_tile *tile;
|
bwc_tile *tile;
|
||||||
bitstream *stream;
|
bitstream *stream;
|
||||||
bwc_stream *packed_stream;
|
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
|
assert(data);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Save the global control and info structure to temporary !
|
! Save the global control and info structure to temporary !
|
||||||
|
@ -1391,7 +1352,7 @@ assemble_codestream(bwc_field *const field)
|
||||||
! the final codestream size with the number of header !
|
! the final codestream size with the number of header !
|
||||||
! bytes. !
|
! bytes. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
|
|
||||||
control->codestreamSize = control->headerSize + 2;
|
control->codestreamSize = control->headerSize + 2;
|
||||||
|
|
||||||
|
@ -1405,15 +1366,15 @@ assemble_codestream(bwc_field *const field)
|
||||||
! Save the tile structure in a temporary variable to make !
|
! Save the tile structure in a temporary variable to make !
|
||||||
! the code more readable. !
|
! the code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
tile = &field->tile[i];
|
tile = &codec->tile[i];
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Sequence the packets according to the user specified op- !
|
! Sequence the packets according to the user specified op- !
|
||||||
! tion and iterate the size of the codestream. !
|
! tion and iterate the size of the codestream. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
if(sequence_packets(field, tile))
|
if(sequence_packets(codec, tile))
|
||||||
{
|
{
|
||||||
return NULL;
|
return 0;
|
||||||
}
|
}
|
||||||
control->codestreamSize += tile->control.header_size +
|
control->codestreamSize += tile->control.header_size +
|
||||||
tile->control.body_size;
|
tile->control.body_size;
|
||||||
|
@ -1423,8 +1384,8 @@ assemble_codestream(bwc_field *const field)
|
||||||
! Initialize the final codestream and emit the header !
|
! Initialize the final codestream and emit the header !
|
||||||
! bytes. !
|
! bytes. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
stream = init_stream(NULL, control->codestreamSize, 'c');
|
stream = init_bitstream(data->out, control->codestreamSize, 'c');
|
||||||
codestream_write_header(stream, field);
|
codestream_write_header(stream, codec, data);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Walk through the tile structure and assemble the packed !
|
! Walk through the tile structure and assemble the packed !
|
||||||
|
@ -1437,33 +1398,21 @@ assemble_codestream(bwc_field *const field)
|
||||||
! Save the tile structure in a temporary variable to make !
|
! Save the tile structure in a temporary variable to make !
|
||||||
! the code more readable. !
|
! the code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
tile = &field->tile[i];
|
tile = &codec->tile[i];
|
||||||
|
|
||||||
assemble_tile(field, tile, stream);
|
assemble_tile(codec, tile, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit_symbol(stream, EOC, 2);
|
emit_symbol(stream, EOC, 2);
|
||||||
|
|
||||||
packed_stream = calloc(1, sizeof(bwc_stream));
|
compressed_size = stream->L;
|
||||||
if(!packed_stream)
|
free(stream);
|
||||||
{
|
|
||||||
// memory allocation error
|
|
||||||
fprintf(stderr, MEMERROR);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(terminate_stream(stream, packed_stream))
|
return compressed_size;
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return packed_stream;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: uchar parse_codestream(bwc_field *const field, bitstream *const stream) !
|
! FUNCTION NAME: uchar parse_codestream(bwc_codec *const codec, bitstream *const stream) !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -1474,7 +1423,7 @@ assemble_codestream(bwc_field *const field)
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
! codec bwc_codec* - Structure defining the compression/ !
|
||||||
! decompression stage. !
|
! decompression stage. !
|
||||||
! !
|
! !
|
||||||
! stream bitstream* - Structure used to assemble a bwc bit- !
|
! stream bitstream* - Structure used to assemble a bwc bit- !
|
||||||
|
@ -1494,32 +1443,32 @@ assemble_codestream(bwc_field *const field)
|
||||||
! 05.08.2019 Patrick Vogler B87D120 V 0.1.0 function created !
|
! 05.08.2019 Patrick Vogler B87D120 V 0.1.0 function created !
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
bwc_field*
|
bwc_codec*
|
||||||
parse_codestream(bwc_data *const data, uint8 const layer)
|
parse_codestream(bwc_codec *const codec, bwc_stream *const data, uint8 const layer)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE STRUCTS: !
|
! DEFINE STRUCTS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
bwc_field *field;
|
|
||||||
bitstream *stream;
|
bitstream *stream;
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(data);
|
assert(data);
|
||||||
|
assert(codec);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Initialize a bitstream used to parse the packed code- !
|
! Initialize a bitstream used to parse the packed code- !
|
||||||
! stream. !
|
! stream. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
stream = init_stream(data->codestream.data->memory, 10, 'd');
|
stream = init_bitstream(data->inp, 10, 'd');
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Parse the main header and set up the field structure for !
|
! Parse the main header and set up the codec structure for !
|
||||||
! the current decompression run. !
|
! the current decompression run. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
field = parse_main_header(data, stream);
|
parse_main_header(codec, data, stream);
|
||||||
if(!field)
|
if(!codec)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1528,36 +1477,36 @@ parse_codestream(bwc_data *const data, uint8 const layer)
|
||||||
! Initialize the useLayer option to decompress the entire !
|
! Initialize the useLayer option to decompress the entire !
|
||||||
! codestream. !
|
! codestream. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
field->control.useLayer = field->control.nLayers - 1;
|
codec->control.useLayer = codec->control.nLayers - 1;
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Check if the layer index supplied by the function caller !
|
! Check if the layer index supplied by the function caller !
|
||||||
! is valid. !
|
! is valid. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
if(layer < field->control.nLayers && layer > 0)
|
if(layer < codec->control.nLayers && layer > 0)
|
||||||
{
|
{
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Amend the use layer variable in the global control struc-!
|
! Amend the use layer variable in the global control struc-!
|
||||||
! ture. !
|
! ture. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
field->control.useLayer = layer;
|
codec->control.useLayer = layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Parse the rest of the compressed codestream and load the !
|
! Parse the rest of the compressed codestream and load the !
|
||||||
! body into the field structure. !
|
! body into the codec structure. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
if(parse_body(field, stream))
|
if(parse_body(codec, stream))
|
||||||
{
|
{
|
||||||
bwc_kill_compression(field);
|
bwc_free_codec(codec);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Free the bitstream used to parse the codestream and re- !
|
! Free the bitstream used to parse the codestream and re- !
|
||||||
! turn the field structure to the function caller. !
|
! turn the codec structure to the function caller. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
free(stream);
|
free(stream);
|
||||||
|
|
||||||
return field;
|
return codec;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1421,7 +1421,7 @@ initialize_gain_lut()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: bwc_float get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level) !
|
! FUNCTION NAME: bwc_float get_dwt_energy_gain(bwc_codec *const codec, uchar highband_flag, uint16 level) !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -1434,7 +1434,7 @@ initialize_gain_lut()
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
! codec bwc_codec* - Structure defining the compression/ !
|
||||||
! decompression stage. !
|
! decompression stage. !
|
||||||
! !
|
! !
|
||||||
! highband_flag uchar - Defines the subband for which Gb is !
|
! highband_flag uchar - Defines the subband for which Gb is !
|
||||||
|
@ -1459,7 +1459,7 @@ initialize_gain_lut()
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
bwc_float
|
bwc_float
|
||||||
get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level)
|
get_dwt_energy_gain(bwc_codec *const codec, uchar highband_flag, uint16 level)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
|
@ -1480,15 +1480,15 @@ get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level)
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(level <= field->control.nDecomp + 1);
|
assert(level <= codec->control.nDecomp + 1);
|
||||||
assert(highband_flag <= DIM_ALL);
|
assert(highband_flag <= DIM_ALL);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Save the global control structure to a temporary varia- !
|
! Save the global control structure to a temporary varia- !
|
||||||
! ble to make the code more readable. !
|
! ble to make the code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Evaluate the number of decompositions in each temporal & !
|
! Evaluate the number of decompositions in each temporal & !
|
||||||
|
@ -1576,7 +1576,7 @@ get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: uchar forward_discrete_wavelet_transform(bwc_field *const field, !
|
! FUNCTION NAME: uchar forward_discrete_wavelet_transform(bwc_codec *const codec, !
|
||||||
! -------------- bwc_parameter *const parameter) !
|
! -------------- bwc_parameter *const parameter) !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -1594,7 +1594,7 @@ get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level)
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
! codec bwc_codec* - Structure defining the compression/ !
|
||||||
! decompression stage. !
|
! decompression stage. !
|
||||||
! !
|
! !
|
||||||
! parameter bwc_parameter* - Structure defining a bwc parameter. !
|
! parameter bwc_parameter* - Structure defining a bwc parameter. !
|
||||||
|
@ -1614,28 +1614,22 @@ get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level)
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
uchar
|
uchar
|
||||||
forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter)
|
forward_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
uint64 incr_X, incr_Y, incr_Z;
|
uint64 incr_X, incr_Y, incr_Z, incr_TS;
|
||||||
uint64 rX0, rY0, rZ0;
|
uint64 rX0, rY0, rZ0, rTS0;
|
||||||
uint64 rX1, rY1, rZ1;
|
uint64 rX1, rY1, rZ1, rTS1;
|
||||||
uint64 width, height, depth;
|
uint64 width, height, depth, dt;
|
||||||
uint64 x, y, z;
|
uint64 x, y, z, t;
|
||||||
|
|
||||||
int64 nThreads;
|
int64 nThreads;
|
||||||
int16 i;
|
int16 i;
|
||||||
|
|
||||||
uint32 buff_size;
|
uint32 buff_size;
|
||||||
|
|
||||||
uint16 incr_TS;
|
|
||||||
uint16 rTS0;
|
|
||||||
uint16 rTS1;
|
|
||||||
uint16 dt;
|
|
||||||
uint16 t;
|
|
||||||
|
|
||||||
uint8 id;
|
uint8 id;
|
||||||
uint8 filter_tapsX, filter_tapsY, filter_tapsZ;
|
uint8 filter_tapsX, filter_tapsY, filter_tapsZ;
|
||||||
uint8 filter_tapsTS;
|
uint8 filter_tapsTS;
|
||||||
|
@ -1652,7 +1646,7 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(parameter);
|
assert(parameter);
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
|
@ -1670,7 +1664,7 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter
|
||||||
! Save the global control and parameter info structure to !
|
! Save the global control and parameter info structure to !
|
||||||
! temporary variables to make the code more readable. !
|
! temporary variables to make the code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
param_info = ¶meter->info;
|
param_info = ¶meter->info;
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
|
@ -1777,8 +1771,8 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter
|
||||||
rY1 = (uint64)parameter->resolution[control->nDecomp - level].info.Y1;
|
rY1 = (uint64)parameter->resolution[control->nDecomp - level].info.Y1;
|
||||||
rZ0 = (uint64)parameter->resolution[control->nDecomp - level].info.Z0;
|
rZ0 = (uint64)parameter->resolution[control->nDecomp - level].info.Z0;
|
||||||
rZ1 = (uint64)parameter->resolution[control->nDecomp - level].info.Z1;
|
rZ1 = (uint64)parameter->resolution[control->nDecomp - level].info.Z1;
|
||||||
rTS0 = (uint16)parameter->resolution[control->nDecomp - level].info.TS0;
|
rTS0 = (uint64)parameter->resolution[control->nDecomp - level].info.TS0;
|
||||||
rTS1 = (uint16)parameter->resolution[control->nDecomp - level].info.TS1;
|
rTS1 = (uint64)parameter->resolution[control->nDecomp - level].info.TS1;
|
||||||
|
|
||||||
if(level < control->decompX && (rX1 - rX0) > 1)
|
if(level < control->decompX && (rX1 - rX0) > 1)
|
||||||
{
|
{
|
||||||
|
@ -2117,7 +2111,7 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: uchar inverse_discrete_wavelet_transform(bwc_field *const field, !
|
! FUNCTION NAME: uchar inverse_discrete_wavelet_transform(bwc_codec *const codec, !
|
||||||
! -------------- bwc_parameter *const parameter) !
|
! -------------- bwc_parameter *const parameter) !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -2135,7 +2129,7 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
! codec bwc_codec* - Structure defining the compression/ !
|
||||||
! decompression stage. !
|
! decompression stage. !
|
||||||
! !
|
! !
|
||||||
! parameter bwc_parameter* - Structure defining a bwc parameter. !
|
! parameter bwc_parameter* - Structure defining a bwc parameter. !
|
||||||
|
@ -2155,28 +2149,22 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
uchar
|
uchar
|
||||||
inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter)
|
inverse_wavelet_transform(bwc_codec *const codec, bwc_parameter *const parameter)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
uint64 incr_X, incr_Y, incr_Z;
|
uint64 incr_X, incr_Y, incr_Z, incr_TS;
|
||||||
uint64 rX0, rY0, rZ0;
|
uint64 rX0, rY0, rZ0, rTS0;
|
||||||
uint64 rX1, rY1, rZ1;
|
uint64 rX1, rY1, rZ1, rTS1;
|
||||||
uint64 width, height, depth;
|
uint64 width, height, depth, dt;
|
||||||
uint64 x, y, z;
|
uint64 x, y, z, t;
|
||||||
|
|
||||||
int64 nThreads;
|
int64 nThreads;
|
||||||
int64 i;
|
int64 i;
|
||||||
|
|
||||||
uint32 buff_size;
|
uint32 buff_size;
|
||||||
|
|
||||||
uint16 incr_TS;
|
|
||||||
uint16 rTS0;
|
|
||||||
uint16 rTS1;
|
|
||||||
uint16 dt;
|
|
||||||
uint16 t;
|
|
||||||
|
|
||||||
uint8 id;
|
uint8 id;
|
||||||
uint8 filter_tapsX, filter_tapsY, filter_tapsZ;
|
uint8 filter_tapsX, filter_tapsY, filter_tapsZ;
|
||||||
uint8 filter_tapsTS;
|
uint8 filter_tapsTS;
|
||||||
|
@ -2193,7 +2181,7 @@ inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(parameter);
|
assert(parameter);
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
|
@ -2211,7 +2199,7 @@ inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter
|
||||||
! Save the global control and parameter info structure to !
|
! Save the global control and parameter info structure to !
|
||||||
! temporary variables to make the code more readable. !
|
! temporary variables to make the code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
param_info = ¶meter->info;
|
param_info = ¶meter->info;
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
|
@ -2318,8 +2306,8 @@ inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter
|
||||||
rY1 = (uint64)parameter->resolution[control->nDecomp - level].info.Y1;
|
rY1 = (uint64)parameter->resolution[control->nDecomp - level].info.Y1;
|
||||||
rZ0 = (uint64)parameter->resolution[control->nDecomp - level].info.Z0;
|
rZ0 = (uint64)parameter->resolution[control->nDecomp - level].info.Z0;
|
||||||
rZ1 = (uint64)parameter->resolution[control->nDecomp - level].info.Z1;
|
rZ1 = (uint64)parameter->resolution[control->nDecomp - level].info.Z1;
|
||||||
rTS0 = (uint16)parameter->resolution[control->nDecomp - level].info.TS0;
|
rTS0 = (uint64)parameter->resolution[control->nDecomp - level].info.TS0;
|
||||||
rTS1 = (uint16)parameter->resolution[control->nDecomp - level].info.TS1;
|
rTS1 = (uint64)parameter->resolution[control->nDecomp - level].info.TS1;
|
||||||
|
|
||||||
if(level < control->decompTS && (rTS1 - rTS0) > 1)
|
if(level < control->decompTS && (rTS1 - rTS0) > 1)
|
||||||
{
|
{
|
||||||
|
|
2398
src/library/libbwc.c
2398
src/library/libbwc.c
File diff suppressed because it is too large
Load diff
|
@ -16,7 +16,7 @@
|
||||||
|| ------------ ||
|
|| ------------ ||
|
||||||
|| ||
|
|| ||
|
||||||
|| This file describes a set of functions that can be used to de-/encode bwc ||
|
|| This file describes a set of functions that can be used to de-/encode bwc ||
|
||||||
|| codeblocks described by the bwc_field structure according to the embedded block ||
|
|| codeblocks described by the bwc_codec structure according to the embedded block ||
|
||||||
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|
||||||
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|
||||||
|| ||
|
|| ||
|
||||||
|
@ -398,9 +398,8 @@ cblkreset_inv(bwc_coder_stripe *const cblk, const uint64 width, const uint64 hei
|
||||||
uint64 i;
|
uint64 i;
|
||||||
uint64 limit;
|
uint64 limit;
|
||||||
uint64 cblk_stripe;
|
uint64 cblk_stripe;
|
||||||
uint64 x, y, z;
|
uint64 x, y, z, t;
|
||||||
int64 idx_u, idx_r, idx_d, idx_l;
|
int64 idx_u, idx_r, idx_d, idx_l;
|
||||||
uint16 t;
|
|
||||||
uint8 s;
|
uint8 s;
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
|
@ -533,15 +532,12 @@ cblkcopy_forward(bwc_coder_stripe *const destination, bwc_sample *const source,
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
bwc_raw buff, sign_mask;
|
bwc_raw buff, sign_mask;
|
||||||
uint64 bit_mask, limit;
|
uint64 bit_mask, limit;
|
||||||
uint64 cblk_width, cblk_height, cblk_depth, cblk_stripe;
|
uint64 cblk_width, cblk_height, cblk_depth, cblk_dt, cblk_stripe;
|
||||||
uint64 incrX, incrY, incrZ;
|
uint64 incrX, incrY, incrZ;
|
||||||
uint64 i, x, y, z;
|
uint64 i, x, y, z, t;
|
||||||
uint64 X0, Y0, Z0;
|
uint64 X0, Y0, Z0, TS0;
|
||||||
uint64 X1, Y1, Z1;
|
uint64 X1, Y1, Z1, TS1;
|
||||||
int64 idx_u, idx_r, idx_d, idx_l;
|
int64 idx_u, idx_r, idx_d, idx_l;
|
||||||
uint16 TS0, TS1;
|
|
||||||
uint16 cblk_dt;
|
|
||||||
uint16 t;
|
|
||||||
uint8 b, Kmax, s;
|
uint8 b, Kmax, s;
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
|
@ -775,15 +771,12 @@ cblkcopy_inverse(bwc_coder_stripe *const source, bwc_sample *const destinat
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
uint64 cblk_width, cblk_height, cblk_depth, cblk_stripe;
|
uint64 cblk_width, cblk_height, cblk_depth, cblk_dt, cblk_stripe;
|
||||||
uint64 bit_shift, buff, limit;
|
uint64 bit_shift, buff, limit;
|
||||||
uint64 incrX, incrY, incrZ;
|
uint64 incrX, incrY, incrZ;
|
||||||
uint64 i, x, y, z;
|
uint64 i, x, y, z, t;
|
||||||
uint64 X0, Y0, Z0;
|
uint64 X0, Y0, Z0, TS0;
|
||||||
uint64 X1, Y1, Z1;
|
uint64 X1, Y1, Z1, TS1;
|
||||||
uint16 TS0, TS1;
|
|
||||||
uint16 cblk_dt;
|
|
||||||
uint16 t;
|
|
||||||
uint8 bitplane;
|
uint8 bitplane;
|
||||||
uint8 codingpass;
|
uint8 codingpass;
|
||||||
uint8 s;
|
uint8 s;
|
||||||
|
@ -2274,12 +2267,12 @@ compute_convex_hull(bwc_encoded_cblk *const encoded_codeblock, double *const mse
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: bwc_encoded_cblk* encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, !
|
! FUNCTION NAME: void encode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access, !
|
||||||
! -------------- bwc_coder_stripe *const codeblock, !
|
! -------------- bwc_coder_stripe *const codeblock, !
|
||||||
! const uint64 width, !
|
! const uint64 width, !
|
||||||
! const uint64 height, !
|
! const uint64 height, !
|
||||||
! const uint64 depth, !
|
! const uint64 depth, !
|
||||||
! const uint16 dt) !
|
! const uint64 dt) !
|
||||||
! !
|
! !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -2307,12 +2300,12 @@ compute_convex_hull(bwc_encoded_cblk *const encoded_codeblock, double *const mse
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
encode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
|
encode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access,
|
||||||
bwc_coder_stripe *const codeblock,
|
bwc_coder_stripe *const codeblock,
|
||||||
const uint64 width,
|
const uint64 width,
|
||||||
const uint64 height,
|
const uint64 height,
|
||||||
const uint64 depth,
|
const uint64 depth,
|
||||||
const uint16 dt)
|
const uint64 dt)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
|
@ -2340,7 +2333,7 @@ encode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(access);
|
assert(access);
|
||||||
assert(codeblock);
|
assert(codeblock);
|
||||||
assert(access->subband->control.highband_flag <= 15);
|
assert(access->subband->control.highband_flag <= 15);
|
||||||
|
@ -2359,7 +2352,7 @@ encode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
|
||||||
! info and encoded block structure to temporary variables !
|
! info and encoded block structure to temporary variables !
|
||||||
! to make the code more readable. !
|
! to make the code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
|
|
||||||
subb_ctrl = &access->subband->control;
|
subb_ctrl = &access->subband->control;
|
||||||
subb_inf = &access->subband->info;
|
subb_inf = &access->subband->info;
|
||||||
|
@ -2595,12 +2588,12 @@ encode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: bwc_encoded_cblk* encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, !
|
! FUNCTION NAME: void decode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access, !
|
||||||
! bwc_coder_stripe *const codeblock, !
|
! bwc_coder_stripe *const codeblock, !
|
||||||
! const uint64 width, !
|
! const uint64 width, !
|
||||||
! const uint64 height, !
|
! const uint64 height, !
|
||||||
! const uint64 depth, !
|
! const uint64 depth, !
|
||||||
! const uint16 dt) !
|
! const uint64 dt) !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -2628,12 +2621,12 @@ encode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
decode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
|
decode_codeblock(bwc_codec *const codec, bwc_cblk_access *const access,
|
||||||
bwc_coder_stripe *const codeblock,
|
bwc_coder_stripe *const codeblock,
|
||||||
const uint64 width,
|
const uint64 width,
|
||||||
const uint64 height,
|
const uint64 height,
|
||||||
const uint64 depth,
|
const uint64 depth,
|
||||||
const uint16 dt)
|
const uint64 dt)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
|
@ -2652,7 +2645,7 @@ decode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(access);
|
assert(access);
|
||||||
assert(codeblock);
|
assert(codeblock);
|
||||||
assert(access->subband->control.highband_flag <= 15);
|
assert(access->subband->control.highband_flag <= 15);
|
||||||
|
@ -2671,7 +2664,7 @@ decode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
|
||||||
! structure to temporary variables to make the code more !
|
! structure to temporary variables to make the code more !
|
||||||
! readable. !
|
! readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
|
|
||||||
subb_ctrl = &access->subband->control;
|
subb_ctrl = &access->subband->control;
|
||||||
|
|
||||||
|
@ -2828,20 +2821,19 @@ decode_codeblock(bwc_field *const field, bwc_cblk_access *const access,
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
uchar
|
uchar
|
||||||
t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const parameter)
|
t1_encode(bwc_codec *const codec, bwc_tile *const tile, bwc_parameter *const parameter)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
uint64 c;
|
uint64 c;
|
||||||
uint64 cbSizeX, cbSizeY, cbSizeZ;
|
uint64 cbSizeX, cbSizeY, cbSizeZ, cbSizeTS;
|
||||||
uint64 width, height, depth;
|
uint64 width, height, depth;
|
||||||
|
|
||||||
int64 buff_size;
|
int64 buff_size;
|
||||||
int64 i, j;
|
int64 i, j;
|
||||||
int64 nThreads;
|
int64 nThreads;
|
||||||
|
|
||||||
uint16 cbSizeTS;
|
|
||||||
uint16 slope_max, slope_min;
|
uint16 slope_max, slope_min;
|
||||||
int16 z;
|
int16 z;
|
||||||
|
|
||||||
|
@ -2857,7 +2849,7 @@ t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(tile);
|
assert(tile);
|
||||||
assert(parameter);
|
assert(parameter);
|
||||||
|
|
||||||
|
@ -2865,7 +2857,7 @@ t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par
|
||||||
! Save the global control structure to a temporary varia- !
|
! Save the global control structure to a temporary varia- !
|
||||||
! ble to make the code more readable. !
|
! ble to make the code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Save the minimum and maximum slope values for the cur- !
|
! Save the minimum and maximum slope values for the cur- !
|
||||||
|
@ -3040,7 +3032,7 @@ t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par
|
||||||
! truncation points (L) and possible slope values (S) in !
|
! truncation points (L) and possible slope values (S) in !
|
||||||
! the bwc_encoded_cblk structure. !
|
! the bwc_encoded_cblk structure. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
encode_codeblock(field, ¶meter->access[c], working_buffer,
|
encode_codeblock(codec, ¶meter->access[c], working_buffer,
|
||||||
cbSizeX, cbSizeY,
|
cbSizeX, cbSizeY,
|
||||||
cbSizeZ, cbSizeTS);
|
cbSizeZ, cbSizeTS);
|
||||||
|
|
||||||
|
@ -3131,21 +3123,19 @@ t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
uchar
|
uchar
|
||||||
t1_decode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const parameter)
|
t1_decode(bwc_codec *const codec, bwc_tile *const tile, bwc_parameter *const parameter)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
uint64 c;
|
uint64 c;
|
||||||
uint64 cbSizeX, cbSizeY, cbSizeZ;
|
uint64 cbSizeX, cbSizeY, cbSizeZ, cbSizeTS;
|
||||||
uint64 width, height, depth;
|
uint64 width, height, depth;
|
||||||
|
|
||||||
int64 buff_size;
|
int64 buff_size;
|
||||||
int64 i, j;
|
int64 i, j;
|
||||||
int64 nThreads;
|
int64 nThreads;
|
||||||
|
|
||||||
uint16 cbSizeTS;
|
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE STRUCTS: !
|
! DEFINE STRUCTS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
|
@ -3159,7 +3149,7 @@ t1_decode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(tile);
|
assert(tile);
|
||||||
assert(parameter);
|
assert(parameter);
|
||||||
|
|
||||||
|
@ -3167,7 +3157,7 @@ t1_decode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par
|
||||||
! Save the global control structure to a temporary varia- !
|
! Save the global control structure to a temporary varia- !
|
||||||
! ble to make the code more readable. !
|
! ble to make the code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Evaluate the width, height and depth of the current !
|
! Evaluate the width, height and depth of the current !
|
||||||
|
@ -3332,7 +3322,7 @@ t1_decode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par
|
||||||
|
|
||||||
if(codeblock->encoded_block->Z > 0)
|
if(codeblock->encoded_block->Z > 0)
|
||||||
{
|
{
|
||||||
decode_codeblock(field, ¶meter->access[c], working_buffer,
|
decode_codeblock(codec, ¶meter->access[c], working_buffer,
|
||||||
cbSizeX, cbSizeY,
|
cbSizeX, cbSizeY,
|
||||||
cbSizeZ, cbSizeTS);
|
cbSizeZ, cbSizeTS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|| ------------ ||
|
|| ------------ ||
|
||||||
|| ||
|
|| ||
|
||||||
|| This file describes a set of functions that can be used to de-/encode bwc ||
|
|| This file describes a set of functions that can be used to de-/encode bwc ||
|
||||||
|| codeblocks described by the bwc_field structure according to the embedded block ||
|
|| codeblocks described by the bwc_codec structure according to the embedded block ||
|
||||||
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|
|| coding paradigm described by the JPEG 2000 standard. For more information please ||
|
||||||
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|
|| refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. ||
|
||||||
|| ||
|
|| ||
|
||||||
|
@ -312,7 +312,7 @@ encode_length(bitstream *const header, bwc_codeblock *const codeblock,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: void create_quality_layers(bwc_field *const field, bwc_tile *const tile) !
|
! FUNCTION NAME: !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! !
|
! !
|
||||||
|
@ -385,11 +385,10 @@ decode_length(bitstream *const header, bwc_codeblock *const codeblock, int8 cons
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: int64 create_packet(bwc_field *const field, bwc_tile *const tile, !
|
! FUNCTION NAME: int64 create_packet(bwc_tile *const tile, bwc_resolution *const resolution, !
|
||||||
! -------------- bwc_resolution *const resolution, !
|
! -------------- uint32 const prec_idx, !
|
||||||
! uint32 const prec_idx, !
|
! int8 const q_layer, !
|
||||||
! int8 const q_layer, !
|
! uchar const est) !
|
||||||
! uchar const est) !
|
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
! ------------ !
|
! ------------ !
|
||||||
|
@ -403,9 +402,6 @@ decode_length(bitstream *const header, bwc_codeblock *const codeblock, int8 cons
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
|
||||||
! decompression stage. !
|
|
||||||
! !
|
|
||||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||||
! !
|
! !
|
||||||
! resolution bwc_resolution* - Structure defining a bwc resolution !
|
! resolution bwc_resolution* - Structure defining a bwc resolution !
|
||||||
|
@ -435,11 +431,10 @@ decode_length(bitstream *const header, bwc_codeblock *const codeblock, int8 cons
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
static int32
|
static int32
|
||||||
create_packet(bwc_field *const field, bwc_tile *const tile,
|
create_packet(bwc_tile *const tile, bwc_resolution *const resolution,
|
||||||
bwc_resolution *const resolution,
|
uint32 const prec_idx,
|
||||||
uint32 const prec_idx,
|
int16 const q_layer,
|
||||||
int16 const q_layer,
|
uchar const est)
|
||||||
uchar const est)
|
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
|
@ -450,6 +445,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
||||||
int16 *cp_contr;
|
int16 *cp_contr;
|
||||||
int16 delta_z;
|
int16 delta_z;
|
||||||
int8 m;
|
int8 m;
|
||||||
|
uchar *memory;
|
||||||
|
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE STRUCTS: !
|
! DEFINE STRUCTS: !
|
||||||
|
@ -462,7 +458,6 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
|
||||||
assert(tile);
|
assert(tile);
|
||||||
assert(resolution);
|
assert(resolution);
|
||||||
|
|
||||||
|
@ -482,7 +477,14 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
||||||
! Initialize the stream that is used to assemble the pack- !
|
! Initialize the stream that is used to assemble the pack- !
|
||||||
! et header. !
|
! et header. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
header = init_stream(NULL, PACKET_HEADER_SIZE, 'c');
|
memory = calloc(PACKET_HEADER_SIZE, sizeof(uchar));
|
||||||
|
if(!memory)
|
||||||
|
{
|
||||||
|
// memory allocation error
|
||||||
|
fprintf(stderr, MEMERROR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
header = init_bitstream(memory, PACKET_HEADER_SIZE, 'c');
|
||||||
if(!header)
|
if(!header)
|
||||||
{
|
{
|
||||||
// memory allocation error
|
// memory allocation error
|
||||||
|
@ -498,7 +500,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
||||||
if(!est)
|
if(!est)
|
||||||
{
|
{
|
||||||
packet->body.access =
|
packet->body.access =
|
||||||
packet->body.memory = calloc(packet->body.size, sizeof(bwc_stream));
|
packet->body.memory = calloc(packet->body.size, sizeof(bwc_span));
|
||||||
if(!packet->body.memory)
|
if(!packet->body.memory)
|
||||||
{
|
{
|
||||||
// memory allocation error
|
// memory allocation error
|
||||||
|
@ -644,7 +646,8 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
||||||
}
|
}
|
||||||
|
|
||||||
k = header->L;
|
k = header->L;
|
||||||
terminate_stream(header, NULL);
|
free(header->memory);
|
||||||
|
free(header);
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
|
@ -655,11 +658,13 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(terminate_stream(header, &packet->header))
|
if(shrink_to_fit(header))
|
||||||
{
|
{
|
||||||
// memory allocation error
|
// memory allocation error
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
transfer_to_span(header, &packet->header);
|
||||||
|
free(header);
|
||||||
|
|
||||||
packet->size = packet->body.size + packet->header.size;
|
packet->size = packet->body.size + packet->header.size;
|
||||||
|
|
||||||
|
@ -706,7 +711,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: uchar create_packets(bwc_field *const field, bwc_tile *const tile) !
|
! FUNCTION NAME: uchar create_packets(bwc_codec *const codec, bwc_tile *const tile) !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -723,7 +728,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
! codec bwc_codec* - Structure defining the compression/ !
|
||||||
! decompression stage. !
|
! decompression stage. !
|
||||||
! !
|
! !
|
||||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||||
|
@ -743,7 +748,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile,
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
static uchar
|
static uchar
|
||||||
create_packets(bwc_field *const field, bwc_tile *const tile)
|
create_packets(bwc_codec *const codec, bwc_tile *const tile)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
|
@ -764,15 +769,15 @@ create_packets(bwc_field *const field, bwc_tile *const tile)
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(tile);
|
assert(tile);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Save the global control and info structure to temporary !
|
! Save the global control and info structure to temporary !
|
||||||
! variables to make the code more readable. !
|
! variables to make the code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
info = field->info;
|
info = &codec->info;
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Iterate overall quality layers for every precinct in all !
|
! Iterate overall quality layers for every precinct in all !
|
||||||
|
@ -799,7 +804,7 @@ create_packets(bwc_field *const field, bwc_tile *const tile)
|
||||||
{
|
{
|
||||||
for(l = 0; l < control->nLayers; ++l)
|
for(l = 0; l < control->nLayers; ++l)
|
||||||
{
|
{
|
||||||
if(create_packet(field, tile, resolution, p, l, 0) < 0)
|
if(create_packet(tile, resolution, p, l, 0) < 0)
|
||||||
{
|
{
|
||||||
// memory allocation error
|
// memory allocation error
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -845,7 +850,7 @@ create_packets(bwc_field *const field, bwc_tile *const tile)
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: int64 create_quality_layer(bwc_field *const field, bwc_tile *const tile, !
|
! FUNCTION NAME: int64 create_quality_layer(bwc_codec *const codec, bwc_tile *const tile, !
|
||||||
! -------------- uint16 const threshold, !
|
! -------------- uint16 const threshold, !
|
||||||
! int16 const q_layer, !
|
! int16 const q_layer, !
|
||||||
! uchar const est) !
|
! uchar const est) !
|
||||||
|
@ -860,7 +865,7 @@ create_packets(bwc_field *const field, bwc_tile *const tile)
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
! codec bwc_codec* - Structure defining the compression/ !
|
||||||
! decompression stage. !
|
! decompression stage. !
|
||||||
! !
|
! !
|
||||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||||
|
@ -888,7 +893,7 @@ create_packets(bwc_field *const field, bwc_tile *const tile)
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
static int64
|
static int64
|
||||||
create_quality_layer(bwc_field *const field, bwc_tile *const tile,
|
create_quality_layer(bwc_codec *const codec, bwc_tile *const tile,
|
||||||
uint16 const threshold,
|
uint16 const threshold,
|
||||||
int16 const q_layer,
|
int16 const q_layer,
|
||||||
uchar const est)
|
uchar const est)
|
||||||
|
@ -916,15 +921,15 @@ create_quality_layer(bwc_field *const field, bwc_tile *const tile,
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(tile);
|
assert(tile);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Save the global control and info structure to temporary !
|
! Save the global control and info structure to temporary !
|
||||||
! variables to make the code more readable. !
|
! variables to make the code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
info = field->info;
|
info = &codec->info;
|
||||||
|
|
||||||
for(j = 0, estimated_ql_size = 0; j < info->nPar; ++j)
|
for(j = 0, estimated_ql_size = 0; j < info->nPar; ++j)
|
||||||
{
|
{
|
||||||
|
@ -1056,7 +1061,7 @@ create_quality_layer(bwc_field *const field, bwc_tile *const tile,
|
||||||
|
|
||||||
for(p = 0; p < resolution->control.number_of_precincts; ++p)
|
for(p = 0; p < resolution->control.number_of_precincts; ++p)
|
||||||
{
|
{
|
||||||
estimated_ph_size = create_packet(field, tile, resolution, p, q_layer, est + 1);
|
estimated_ph_size = create_packet(tile, resolution, p, q_layer, est + 1);
|
||||||
|
|
||||||
if(estimated_ph_size < 0)
|
if(estimated_ph_size < 0)
|
||||||
{
|
{
|
||||||
|
@ -1075,7 +1080,7 @@ create_quality_layer(bwc_field *const field, bwc_tile *const tile,
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: void create_quality_layers(bwc_field *const field, bwc_tile *const tile) !
|
! FUNCTION NAME: void create_quality_layers(bwc_codec *const codec, bwc_tile *const tile) !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! !
|
! !
|
||||||
|
@ -1087,7 +1092,7 @@ create_quality_layer(bwc_field *const field, bwc_tile *const tile,
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
! codec bwc_codec* - Structure defining the compression/ !
|
||||||
! decompression stage. !
|
! decompression stage. !
|
||||||
! !
|
! !
|
||||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||||
|
@ -1107,7 +1112,7 @@ create_quality_layer(bwc_field *const field, bwc_tile *const tile,
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
static uchar
|
static uchar
|
||||||
create_quality_layers(bwc_field *const field, bwc_tile *const tile)
|
create_quality_layers(bwc_codec *const codec, bwc_tile *const tile)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE INT VARIABLES: !
|
! DEFINE INT VARIABLES: !
|
||||||
|
@ -1131,15 +1136,15 @@ create_quality_layers(bwc_field *const field, bwc_tile *const tile)
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(tile);
|
assert(tile);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Save the global and tile control and info structure to !
|
! Save the global and tile control and info structure to !
|
||||||
! temporary variables to make the code more readable. !
|
! temporary variables to make the code more readable. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
control = &field->control;
|
control = &codec->control;
|
||||||
info = field->info;
|
info = &codec->info;
|
||||||
|
|
||||||
tile_control = &tile->control;
|
tile_control = &tile->control;
|
||||||
tile_info = &tile->info;
|
tile_info = &tile->info;
|
||||||
|
@ -1189,7 +1194,7 @@ create_quality_layers(bwc_field *const field, bwc_tile *const tile)
|
||||||
{
|
{
|
||||||
slope = (slope_max + slope_min) >> 1;
|
slope = (slope_max + slope_min) >> 1;
|
||||||
|
|
||||||
estimated_ql_size = create_quality_layer(field, tile, slope, l, 1);
|
estimated_ql_size = create_quality_layer(codec, tile, slope, l, 1);
|
||||||
|
|
||||||
if(estimated_ql_size >= 0)
|
if(estimated_ql_size >= 0)
|
||||||
{
|
{
|
||||||
|
@ -1234,7 +1239,7 @@ create_quality_layers(bwc_field *const field, bwc_tile *const tile)
|
||||||
slope = 0;
|
slope = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
estimated_ql_size = create_quality_layer(field, tile, slope, l, 0);
|
estimated_ql_size = create_quality_layer(codec, tile, slope, l, 0);
|
||||||
|
|
||||||
if(estimated_ql_size >= 0)
|
if(estimated_ql_size >= 0)
|
||||||
{
|
{
|
||||||
|
@ -1255,7 +1260,7 @@ create_quality_layers(bwc_field *const field, bwc_tile *const tile)
|
||||||
|| ||
|
|| ||
|
||||||
\************************************************************************************************************/
|
\************************************************************************************************************/
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: uchar t2_encode(bwc_field *const field, bwc_tile *const tile) !
|
! FUNCTION NAME: uchar t2_encode(bwc_codec *const codec, bwc_tile *const tile) !
|
||||||
! -------------- !
|
! -------------- !
|
||||||
! !
|
! !
|
||||||
! DESCRIPTION: !
|
! DESCRIPTION: !
|
||||||
|
@ -1269,7 +1274,7 @@ create_quality_layers(bwc_field *const field, bwc_tile *const tile)
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
! codec bwc_codec* - Structure defining the compression/ !
|
||||||
! decompression stage. !
|
! decompression stage. !
|
||||||
! !
|
! !
|
||||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||||
|
@ -1289,19 +1294,19 @@ create_quality_layers(bwc_field *const field, bwc_tile *const tile)
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
uchar
|
uchar
|
||||||
t2_encode(bwc_field *const field, bwc_tile *const tile)
|
t2_encode(bwc_codec *const codec, bwc_tile *const tile)
|
||||||
{
|
{
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(tile);
|
assert(tile);
|
||||||
|
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! Create the quality layers according to the bitrate val- !
|
! Create the quality layers according to the bitrate val- !
|
||||||
! ues provided by the user. !
|
! ues provided by the user. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
if(create_quality_layers(field, tile))
|
if(create_quality_layers(codec, tile))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1310,7 +1315,7 @@ t2_encode(bwc_field *const field, bwc_tile *const tile)
|
||||||
! Create the data packets according to the quality layers !
|
! Create the data packets according to the quality layers !
|
||||||
! evaluated in the previous step. !
|
! evaluated in the previous step. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
if(create_packets(field, tile))
|
if(create_packets(codec, tile))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1319,7 +1324,7 @@ t2_encode(bwc_field *const field, bwc_tile *const tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------------------------------------*\
|
/*----------------------------------------------------------------------------------------------------------*\
|
||||||
! FUNCTION NAME: uchar parse_packet(bwc_field *const field, bwc_tile *const tile, !
|
! FUNCTION NAME: uchar parse_packet(bwc_codec *const codec, bwc_tile *const tile, !
|
||||||
! -------------- bwc_packet *const packet, !
|
! -------------- bwc_packet *const packet, !
|
||||||
! uint64 const body_size) !
|
! uint64 const body_size) !
|
||||||
! !
|
! !
|
||||||
|
@ -1332,7 +1337,7 @@ t2_encode(bwc_field *const field, bwc_tile *const tile)
|
||||||
! ----------- !
|
! ----------- !
|
||||||
! Variable Type Description !
|
! Variable Type Description !
|
||||||
! -------- ---- ----------- !
|
! -------- ---- ----------- !
|
||||||
! field bwc_field* - Structure defining the compression/ !
|
! codec bwc_codec* - Structure defining the compression/ !
|
||||||
! decompression stage. !
|
! decompression stage. !
|
||||||
! !
|
! !
|
||||||
! tile bwc_tile* - Structure defining a bwc tile. !
|
! tile bwc_tile* - Structure defining a bwc tile. !
|
||||||
|
@ -1356,7 +1361,7 @@ t2_encode(bwc_field *const field, bwc_tile *const tile)
|
||||||
! !
|
! !
|
||||||
\*----------------------------------------------------------------------------------------------------------*/
|
\*----------------------------------------------------------------------------------------------------------*/
|
||||||
uchar
|
uchar
|
||||||
parse_packet(bwc_field *const field, bwc_tile *const tile,
|
parse_packet(bwc_codec *const codec, bwc_tile *const tile,
|
||||||
bwc_packet *const packet,
|
bwc_packet *const packet,
|
||||||
uint64 const body_size)
|
uint64 const body_size)
|
||||||
{
|
{
|
||||||
|
@ -1382,7 +1387,7 @@ parse_packet(bwc_field *const field, bwc_tile *const tile,
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE ASSERTIONS: !
|
! DEFINE ASSERTIONS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
assert(field);
|
assert(codec);
|
||||||
assert(tile);
|
assert(tile);
|
||||||
assert(packet);
|
assert(packet);
|
||||||
|
|
||||||
|
@ -1392,7 +1397,7 @@ parse_packet(bwc_field *const field, bwc_tile *const tile,
|
||||||
! Initialize the stream that is used to parse the packet !
|
! Initialize the stream that is used to parse the packet !
|
||||||
! codestream. !
|
! codestream. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
header = init_stream(packet->header.memory, body_size, 'd');
|
header = init_bitstream(packet->header.memory, body_size, 'd');
|
||||||
if(!header)
|
if(!header)
|
||||||
{
|
{
|
||||||
// memory allocation error
|
// memory allocation error
|
||||||
|
@ -1572,7 +1577,7 @@ parse_packet(bwc_field *const field, bwc_tile *const tile,
|
||||||
! If the error resilience mode is active for the current !
|
! If the error resilience mode is active for the current !
|
||||||
! codestream... !
|
! codestream... !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
if(field->control.error_resilience)
|
if(codec->control.error_resilience)
|
||||||
{
|
{
|
||||||
/*--------------------------------------------------------*\
|
/*--------------------------------------------------------*\
|
||||||
! check if the next symbol corresponds to the end of pack- !
|
! check if the next symbol corresponds to the end of pack- !
|
||||||
|
|
4357
src/tools/bwccmdl.c
4357
src/tools/bwccmdl.c
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue