From 008ccfa4a9d5fe2616c289677ad8f6e58d1f0f49 Mon Sep 17 00:00:00 2001 From: Gregor Weiss Date: Wed, 27 Mar 2024 17:25:05 +0100 Subject: [PATCH] Reorganize bwc_field and bwc_data to split codec settings and data stream semantically into data structures `bwc_codec` and `bwc_stream`. Cleaning up by removal of redundant information like parameter linked list, file extension, and file pointer including associated functionality. Start constructing an API taking void pointers to the original data for compression. --- include/library/private/bitstream.h | 4 +- include/library/private/codestream.h | 15 +- include/library/private/constants.h | 8 +- include/library/private/dwt.h | 6 +- include/library/private/libbwc.h | 79 ++-- include/library/private/tier1.h | 6 +- include/library/private/tier2.h | 6 +- include/library/private/types.h | 60 +-- src/interfaces/fortran/bwc.F90 | 38 -- src/interfaces/python/bwc.py | 18 - src/library/bitstream.c | 8 +- src/library/codestream.c | 143 +++--- src/library/dwt.c | 18 +- src/library/libbwc.c | 663 ++++++++------------------- src/library/tier1.c | 14 +- src/library/tier2.c | 48 +- 16 files changed, 359 insertions(+), 775 deletions(-) diff --git a/include/library/private/bitstream.h b/include/library/private/bitstream.h index 6363775..3ec7a78 100755 --- a/include/library/private/bitstream.h +++ b/include/library/private/bitstream.h @@ -118,7 +118,7 @@ uchar get_bit (bitstream *const stream); //==========|==========================|======================|======|======|===================== uchar terminate_stream (bitstream *stream, - bwc_stream *const packed_stream); + bwc_span *const packed_stream); //==========|==========================|======================|======|======|===================== - void release_packed_stream (bwc_stream *const stream); + void release_packed_stream (bwc_span *const stream); #endif diff --git a/include/library/private/codestream.h b/include/library/private/codestream.h index 482b8eb..7b2c1f5 100755 --- a/include/library/private/codestream.h +++ b/include/library/private/codestream.h @@ -89,16 +89,17 @@ || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || || || \************************************************************************************************/ - uchar assemble_main_header (bwc_field *const field); + uchar assemble_main_header (bwc_codec *const field); //==========|==========================|======================|======|======|===================== - uchar codestream_write_aux (bwc_stream *const header, - bwc_stream *const aux); + uchar codestream_write_aux (bwc_span *const header, + bwc_span *const aux); //==========|==========================|======================|======|======|===================== - uchar codestream_write_com (bwc_stream *const header, - bwc_stream *const com); + uchar codestream_write_com (bwc_span *const header, + bwc_span *const com); //==========|==========================|======================|======|======|===================== - bwc_stream* assemble_codestream (bwc_field *const field); + bwc_span* assemble_codestream (bwc_codec *const field, + bwc_stream *const data); //==========|==========================|======================|======|======|===================== - bwc_field* parse_codestream (bwc_data *const data, + bwc_codec* parse_codestream (bwc_stream *const data, uint8 const layer); #endif \ No newline at end of file diff --git a/include/library/private/constants.h b/include/library/private/constants.h index c8af8d0..35bd7ef 100755 --- a/include/library/private/constants.h +++ b/include/library/private/constants.h @@ -114,8 +114,8 @@ \*----------------------------------------------------------------------------------------------*/ typedef enum { - bwc_type_half, - bwc_type_single, - bwc_type_double, - } bwc_type; + bwc_precision_half = 2, + bwc_precision_single = 4, + bwc_precision_double = 8, + } bwc_precision; #endif \ No newline at end of file diff --git a/include/library/private/dwt.h b/include/library/private/dwt.h index d9fa0eb..fa08858 100755 --- a/include/library/private/dwt.h +++ b/include/library/private/dwt.h @@ -157,13 +157,13 @@ \************************************************************************************************/ uchar initialize_gain_lut (); //==========|==========================|======================|======|=======|==================== - bwc_float get_dwt_energy_gain (bwc_field *const field, + bwc_float get_dwt_energy_gain (bwc_codec *const field, uchar const highband_flag, uint16 const level); //==========|==========================|======================|======|=======|==================== - uchar forward_wavelet_transform (bwc_field *const field, + uchar forward_wavelet_transform (bwc_codec *const field, bwc_parameter *const parameter); //==========|==========================|======================|======|=======|==================== - uchar inverse_wavelet_transform (bwc_field *const field, + uchar inverse_wavelet_transform (bwc_codec *const field, bwc_parameter *const parameter); #endif \ No newline at end of file diff --git a/include/library/private/libbwc.h b/include/library/private/libbwc.h index 8418632..fdeb409 100755 --- a/include/library/private/libbwc.h +++ b/include/library/private/libbwc.h @@ -64,92 +64,85 @@ || || \************************************************************************************************/ //==========|==========================|======================|======|=======|==================== - bwc_data* bwc_initialize_data (double *const field, + bwc_stream* bwc_initialize_data (void *const data, + bwc_precision const prec); + //==========|==========================|======================|======|=======|==================== + uchar bwc_set_com (bwc_stream *const data, + char const *const com, + uint16 const size); + //==========|==========================|======================|======|=======|==================== + uchar bwc_set_aux (bwc_stream *const data, + char const *const aux, + uint32 const size); + //==========|==========================|======================|======|=======|==================== + void bwc_free_data (bwc_stream *const data); + //==========|==========================|======================|======|=======|==================== + uchar create_field (bwc_codec *const field); + //==========|==========================|======================|======|=======|==================== + void bwc_kill_compression (bwc_codec *const field); + //==========|==========================|======================|======|=======|==================== + bwc_codec* bwc_initialize_field (bwc_precision const prec, uint64 const nX, uint64 const nY, uint64 const nZ, uint16 const nTS, - uint8 const nPar, - char *const file_extension); + uint8 const nPar); //==========|==========================|======================|======|=======|==================== - uchar bwc_set_com (bwc_data *const data, - char const *const com, - uint16 const size); + void bwc_set_error_resilience (bwc_codec *const field); //==========|==========================|======================|======|=======|==================== - uchar bwc_set_aux (bwc_data *const data, - char const *const aux, - uint32 const size); - //==========|==========================|======================|======|=======|==================== - void bwc_add_param (bwc_data *const data, - char *const name, - uint8 const precision); - //==========|==========================|======================|======|=======|==================== - void bwc_get_data (bwc_data *const data, - uchar *const buffer, - uint64 const size); - //==========|==========================|======================|======|=======|==================== - void bwc_free_data (bwc_data *const data); - //==========|==========================|======================|======|=======|==================== - uchar create_field (bwc_field *const field); - //==========|==========================|======================|======|=======|==================== - void bwc_kill_compression (bwc_field *const field); - //==========|==========================|======================|======|=======|==================== - bwc_field* bwc_initialize_field (bwc_data *const data); - //==========|==========================|======================|======|=======|==================== - void bwc_set_error_resilience (bwc_field *const field); - //==========|==========================|======================|======|=======|==================== - void set_quant_style (bwc_field *const field, + void set_quant_style (bwc_codec *const field, bwc_quant_st const quantization_style); //==========|==========================|======================|======|=======|==================== - void set_quant_step_size (bwc_field *const field, + void set_quant_step_size (bwc_codec *const field, double const delta); //==========|==========================|======================|======|=======|==================== - void set_progression (bwc_field *const field, + void set_progression (bwc_codec *const field, bwc_prog_ord const progression); //==========|==========================|======================|======|=======|==================== - void set_kernels (bwc_field *const field, + void set_kernels (bwc_codec *const field, bwc_dwt_filter const KernelX, bwc_dwt_filter const KernelY, bwc_dwt_filter const KernelZ, bwc_dwt_filter const KernelTS); //==========|==========================|======================|======|=======|==================== - void bwc_set_decomp (bwc_field *const field, + void bwc_set_decomp (bwc_codec *const field, uint8 const decompX, uint8 const decompY, uint8 const decompZ, uint8 const decompTS); //==========|==========================|======================|======|=======|==================== - void bwc_set_precincts (bwc_field *const field, + void bwc_set_precincts (bwc_codec *const field, uint8 const pX, uint8 const pY, uint8 const pZ, uint8 const pTS); //==========|==========================|======================|======|=======|==================== - void bwc_set_codeblocks (bwc_field *const field, + void bwc_set_codeblocks (bwc_codec *const field, uint8 const cbX, uint8 const cbY, uint8 const cbZ, uint8 const cbTS); //==========|==========================|======================|======|=======|==================== - void bwc_set_qm (bwc_field *const field, + void bwc_set_qm (bwc_codec *const field, uint8 const Qm); //==========|==========================|======================|======|=======|==================== - void bwc_set_tiles (bwc_field *const field, + void bwc_set_tiles (bwc_codec *const field, uint64 const tilesX, uint64 const tilesY, uint64 const tilesZ, uint64 const tilesTS, bwc_tile_instr const instr); //==========|==========================|======================|======|=======|==================== - uchar bwc_create_compression (bwc_field *const field, + uchar bwc_create_compression (bwc_codec *const codec, + bwc_stream *const data, char *const rate_control); //==========|==========================|======================|======|=======|==================== - uchar bwc_compress (bwc_field *const field, - bwc_data *const data); + uchar bwc_compress (bwc_codec *const field, + bwc_stream *const data); //==========|==========================|======================|======|=======|==================== - bwc_field* bwc_create_decompression (bwc_data *const data, + bwc_codec* bwc_create_decompression (bwc_stream *const data, uint8 const layer); //==========|==========================|======================|======|=======|==================== - uchar bwc_decompress (bwc_field *const field, - bwc_data *const data); + uchar bwc_decompress (bwc_codec *const field, + bwc_stream *const data); #endif \ No newline at end of file diff --git a/include/library/private/tier1.h b/include/library/private/tier1.h index 13f60eb..7f0e19c 100755 --- a/include/library/private/tier1.h +++ b/include/library/private/tier1.h @@ -16,7 +16,7 @@ || ------------ || || || || 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 || || 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 field, bwc_tile *const tile, bwc_parameter *const parameter); //==========|==========================|======================|======|=======|==================== - uchar t1_decode (bwc_field *const field, + uchar t1_decode (bwc_codec *const field, bwc_tile *const tile, bwc_parameter *const parameter); diff --git a/include/library/private/tier2.h b/include/library/private/tier2.h index 3dc0bb2..074e49d 100755 --- a/include/library/private/tier2.h +++ b/include/library/private/tier2.h @@ -16,7 +16,7 @@ || ------------ || || || || 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 || || 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 field, bwc_tile *const tile); //==========|==========================|======================|======|=======|==================== - uchar parse_packet (bwc_field *const field, + uchar parse_packet (bwc_codec *const field, bwc_tile *const tile, bwc_packet *const packet, uint64 const body_size); diff --git a/include/library/private/types.h b/include/library/private/types.h index 323101f..fcacd32 100755 --- a/include/library/private/types.h +++ b/include/library/private/types.h @@ -99,7 +99,7 @@ uchar *access; // Pointer used to parse 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; - - /*----------------------------------------------------------------------------------------------*\ - ! ! - ! 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: ! @@ -178,12 +155,8 @@ uint8 nPar; // Number of parameters. - uint8 precision; // Flag defining codec 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_precision data_prec; // Data type of uncompressed field data. + bwc_precision codec_prec; // Encoder/decoder bit precision. } bwc_gl_inf; /*----------------------------------------------------------------------------------------------*\ @@ -197,14 +170,11 @@ \*----------------------------------------------------------------------------------------------*/ typedef struct { - bwc_gl_inf info; // Gloabal info structure. - FILE *fp; // File point to (un)compr. data-set. - struct codestream { - bwc_stream *data; // Data codestream block. - bwc_stream *aux; // Auxiliary info. codestream block. - bwc_stream *com; // Comment codestream block. + bwc_span *data; // Data codestream block. + bwc_span *aux; // Auxiliary info. codestream block. + bwc_span *com; // Comment codestream block. }codestream; struct field @@ -212,7 +182,7 @@ double *d; // Double precision numerical data-set. float *f; // Single precision numerical data-set. }field; - } bwc_data; + } bwc_stream; /*----------------------------------------------------------------------------------------------*\ ! ! @@ -420,8 +390,8 @@ \*----------------------------------------------------------------------------------------------*/ typedef struct { - bwc_stream header; // Packed stream header. - bwc_stream body; // Packed stream body. + bwc_span header; // Packed stream header. + bwc_span body; // Packed stream body. uint8 e; // Indicator for packet cb. contributions. uint32 size; // Codestream packet size. @@ -528,14 +498,9 @@ \*----------------------------------------------------------------------------------------------*/ typedef struct { - uint64 size; // Parameter size. - char *name; // Parameter name. - uint64 X0, Y0, Z0, TS0; // Tile parameter starting 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_max; // Max. value of tile parameter. } bwc_param_inf; @@ -710,12 +675,9 @@ \*----------------------------------------------------------------------------------------------*/ typedef struct { - bwc_gl_inf *info; // Gloabal info structure + bwc_gl_inf info; // Global info structure bwc_gl_ctrl control; // Global control structure bwc_tile *tile; // Structure defining bwc tile. - - bwc_stream *aux; // Auxiliary info. codestream block. - bwc_stream *com; // Comment codestream block. - } bwc_field; + } bwc_codec; #endif \ No newline at end of file diff --git a/src/interfaces/fortran/bwc.F90 b/src/interfaces/fortran/bwc.F90 index b71e98a..aa413e9 100644 --- a/src/interfaces/fortran/bwc.F90 +++ b/src/interfaces/fortran/bwc.F90 @@ -107,42 +107,6 @@ module bwc CHARACTER(KIND=C_CHAR) :: file_extension(*) end function initialize_data_f !*============================================================================================*! - subroutine add_param_f(data, name, sample, dim, precision) & - BIND(C, NAME="bwc_add_param") - IMPORT - !*-----------------------*! - ! DEFINE POINTERS: ! - !*-----------------------*! - TYPE(C_PTR), VALUE :: data - - !*-----------------------*! - ! 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) & - BIND(C, NAME="bwc_get_data") - IMPORT - !*-----------------------*! - ! DEFINE POINTERS: ! - !*-----------------------*! - 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) & BIND(C, NAME="bwc_free_data") IMPORT @@ -396,11 +360,9 @@ module bwc bwc_tile_numbof public :: bwc_initialize_data, & - bwc_get_data, & bwc_free_data public :: bwc_initialize_field, & - bwc_add_param, & bwc_kill_compression public :: bwc_set_error_resilience, & diff --git a/src/interfaces/python/bwc.py b/src/interfaces/python/bwc.py index e45984e..670ec90 100644 --- a/src/interfaces/python/bwc.py +++ b/src/interfaces/python/bwc.py @@ -102,24 +102,6 @@ def initialize_data(data, nX, nY, nZ, nTS, nPar, file_extension): ctypes.c_char_p] return ctypes.c_void_p(fun(data, nX, nY, nZ, nTS, nPar, file_extension.encode('utf-8'))) #==================================================================================================# -def get_data(data, buffer, size): - fun = libbwc.bwc_get_data - 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 diff --git a/src/library/bitstream.c b/src/library/bitstream.c index 1618c87..fee6777 100755 --- a/src/library/bitstream.c +++ b/src/library/bitstream.c @@ -896,7 +896,7 @@ flush_stream(bitstream *const stream) ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -terminate_stream(bitstream *stream, bwc_stream *const packed_stream) +terminate_stream(bitstream *stream, bwc_span *const packed_stream) { /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -937,7 +937,7 @@ terminate_stream(bitstream *stream, bwc_stream *const packed_stream) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void release_packed_stream(bwc_stream *stream) ! +! FUNCTION NAME: void release_packed_stream(bwc_span *stream) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -949,7 +949,7 @@ terminate_stream(bitstream *stream, bwc_stream *const packed_stream) ! ----------- ! ! 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. ! ! ! ! RETURN VALUE: ! @@ -967,7 +967,7 @@ terminate_stream(bitstream *stream, bwc_stream *const packed_stream) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -release_packed_stream(bwc_stream *stream) +release_packed_stream(bwc_span *stream) { /*-----------------------*\ ! DEFINE ASSERTIONS: ! diff --git a/src/library/codestream.c b/src/library/codestream.c index 24af2f4..24955ad 100755 --- a/src/library/codestream.c +++ b/src/library/codestream.c @@ -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 field) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -116,7 +116,7 @@ can_read(bitstream *const stream, const uint64 length) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! stream bitstream* - Structure used to assemble a bwc bit- ! @@ -138,7 +138,8 @@ can_read(bitstream *const stream, const uint64 length) \*----------------------------------------------------------------------------------------------------------*/ static void codestream_write_header(bitstream *const stream, - bwc_field *const field) + bwc_codec *const field, + bwc_stream *const data) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -155,10 +156,8 @@ codestream_write_header(bitstream *const stream, \*-----------------------*/ bwc_gl_ctrl *control; bwc_gl_inf *info; - bwc_tile *tile; - bwc_parameter *parameter; - bwc_stream *aux; - bwc_stream *com; + bwc_span *aux; + bwc_span *com; /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -171,17 +170,13 @@ codestream_write_header(bitstream *const stream, ! structure to temporary variables to make the code more ! ! readable. ! \*--------------------------------------------------------*/ - info = field->info; + info = &field->info; control = &field->control; - tile = &field->tile[0]; - - parameter = &tile->parameter[0]; - - aux = field->aux; - com = field->com; + aux = data->codestream.aux; + com = data->codestream.com; - Linf = 40 + info->nPar * 25; + Linf = 31; Lctr = 50 + control->nLayers * 4; Leoh = info->nPar * control->nTiles * 2 * PREC_BYTE; Lcss = control->codestreamSize; @@ -195,14 +190,8 @@ codestream_write_header(bitstream *const stream, emit_symbol(stream, info->nZ, 8); emit_symbol(stream, info->nTS, 2); emit_symbol(stream, info->nPar, 1); - emit_symbol(stream, info->precision, 1); - emit_chunck(stream, (uchar*)info->f_ext, 10); - - 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, (uint8)info->data_prec, 1); + emit_symbol(stream, (uint8)info->codec_prec, 1); emit_symbol(stream, SGC, 2); emit_symbol(stream, Lctr, 2); @@ -288,7 +277,7 @@ codestream_write_header(bitstream *const stream, } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: uchar sequence_packets(bwc_field *const field, bwc_field *const field) ! +! FUNCTION NAME: uchar sequence_packets(bwc_codec *const field, bwc_codec *const field) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -299,7 +288,7 @@ codestream_write_header(bitstream *const stream, ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! tile bwc_tile* - Structure defining a bwc tile. ! @@ -319,7 +308,7 @@ codestream_write_header(bitstream *const stream, ! ! \*----------------------------------------------------------------------------------------------------------*/ static uchar -sequence_packets(bwc_field *const field, bwc_tile *const tile) +sequence_packets(bwc_codec *const field, bwc_tile *const tile) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -348,7 +337,7 @@ sequence_packets(bwc_field *const field, bwc_tile *const tile) ! code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info; + info = &field->info; 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: uchar sequence_packets(bwc_codec *const field, bwc_codec *const field) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -501,7 +490,7 @@ sequence_packets(bwc_field *const field, bwc_tile *const tile) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! tile bwc_tile* - Structure defining a bwc tile. ! @@ -521,7 +510,7 @@ sequence_packets(bwc_field *const field, bwc_tile *const tile) ! ! \*----------------------------------------------------------------------------------------------------------*/ static void -assemble_tile(bwc_field *const field, bwc_tile *const tile, bitstream *const stream) +assemble_tile(bwc_codec *const field, bwc_tile *const tile, bitstream *const stream) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -613,8 +602,8 @@ assemble_tile(bwc_field *const field, bwc_tile *const tile, bitstream *const str ! - Patrick Vogler B87D120 V 0.1.0 function created ! ! ! \*----------------------------------------------------------------------------------------------------------*/ -bwc_field* -parse_main_header(bwc_data *const data,bitstream *const stream) +bwc_codec* +parse_main_header(bwc_stream *const data, bitstream *const stream) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -632,18 +621,17 @@ parse_main_header(bwc_data *const data,bitstream *const stream) uint16 nTS; uint8 index, l; uint8 nPar, p; - uint8 codec_prec, precision; + bwc_precision data_prec, codec_prec; /*-----------------------*\ ! DEFINE CHAR VARIABLES: ! \*-----------------------*/ - char* buffer_char; char status; /*-----------------------*\ ! DEFINE STRUCTS: ! \*-----------------------*/ - bwc_field *field; + bwc_codec *field; bwc_gl_ctrl *control; bwc_gl_inf *info; @@ -653,12 +641,6 @@ parse_main_header(bwc_data *const data,bitstream *const stream) assert(data); assert(stream); - /*--------------------------------------------------------*\ - ! Save the data info structure to a temporary variable to ! - ! make the code more readable. ! - \*--------------------------------------------------------*/ - info = &data->info; - status = CODESTREAM_OK; index = 0; @@ -708,41 +690,24 @@ parse_main_header(bwc_data *const data,bitstream *const stream) break; } - info->nX = nX = get_symbol(stream, 8); - info->nY = nY = get_symbol(stream, 8); - info->nZ = nZ = get_symbol(stream, 8); - info->nTS = nTS = (uint16)get_symbol(stream, 2); - info->nPar = nPar = (uint8)get_symbol(stream, 1); - info->precision = codec_prec = (uint8)get_symbol(stream, 1); + nX = get_symbol(stream, 8); + nY = get_symbol(stream, 8); + nZ = get_symbol(stream, 8); + nTS = (uint16)get_symbol(stream, 2); + nPar = (uint8)get_symbol(stream, 1); + data_prec = (bwc_precision)get_symbol(stream, 1); - buffer_char = (char*)get_chunck(stream, 10); - strncpy(info->f_ext, buffer_char, sizeof(buffer_char)/sizeof(*buffer_char)); - free(buffer_char); - - for(p = 0; p < nPar; ++p) - { - 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); + field = bwc_initialize_field(data_prec, nX, nY, nZ, nTS, nPar); if(!field) { status |= CODESTREAM_ERROR; break; } - - /*--------------------------------------------------------*\ - ! Save the global control and info structure to temporary ! - ! variables to make the code more readable. ! - \*--------------------------------------------------------*/ - info = field->info = &data->info; + info = &field->info; control = &field->control; + info->codec_prec = codec_prec = (bwc_precision)get_symbol(stream, 1); + control->codestreamSize = stream->Lmax; status |= CODESTREAM_SGI_READ; @@ -896,7 +861,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream) break; } - data->codestream.aux = calloc(1, sizeof(bwc_stream)); + data->codestream.aux = calloc(1, sizeof(bwc_span)); if(!data->codestream.aux) { // memory allocation error @@ -934,7 +899,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream) break; } - data->codestream.com = calloc(1, sizeof(bwc_stream)); + data->codestream.com = calloc(1, sizeof(bwc_span)); if(!data->codestream.com) { // memory allocation error @@ -974,7 +939,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream) break; } - if(codec_prec == 8) + if(codec_prec == bwc_precision_double) { /*--------------------------------------------------------*\ ! Loop through all tile parameters and... ! @@ -995,7 +960,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream) } } } - else if(codec_prec == 4) + else if(codec_prec == bwc_precision_single) { /*--------------------------------------------------------*\ ! Loop through all tile parameters and... ! @@ -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: uchar sequence_packets(bwc_codec *const field, bwc_codec *const field) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -1070,7 +1035,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! tile bwc_tile* - Structure defining a bwc tile. ! @@ -1090,7 +1055,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream) ! ! \*----------------------------------------------------------------------------------------------------------*/ static uchar -parse_tile(bwc_field *const field, bitstream *const stream) +parse_tile(bwc_codec *const field, bitstream *const stream) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -1240,7 +1205,7 @@ parse_tile(bwc_field *const field, bitstream *const stream) ! ! \*----------------------------------------------------------------------------------------------------------*/ static uchar -parse_body(bwc_field *const field, bitstream *const stream) +parse_body(bwc_codec *const field, bitstream *const stream) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -1336,7 +1301,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 field) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -1347,14 +1312,14 @@ parse_body(bwc_field *const field, bitstream *const stream) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! RETURN VALUE: ! ! ------------- ! ! Type Description ! ! ---- ----------- ! -! bwc_stream* - Packed stream containing the compressed data set. ! +! bwc_span* - Packed stream containing the compressed data set. ! ! ! ! DEVELOPMENT HISTORY: ! ! -------------------- ! @@ -1364,8 +1329,8 @@ parse_body(bwc_field *const field, bitstream *const stream) ! 13.06.2019 Patrick Vogler B87D120 V 0.1.0 function created ! ! ! \*----------------------------------------------------------------------------------------------------------*/ -bwc_stream* -assemble_codestream(bwc_field *const field) +bwc_span* +assemble_codestream(bwc_codec *const field, bwc_stream *const data) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -1378,7 +1343,7 @@ assemble_codestream(bwc_field *const field) bwc_gl_ctrl *control; bwc_tile *tile; bitstream *stream; - bwc_stream *packed_stream; + bwc_span *packed_stream; /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -1424,7 +1389,7 @@ assemble_codestream(bwc_field *const field) ! bytes. ! \*--------------------------------------------------------*/ stream = init_stream(NULL, control->codestreamSize, 'c'); - codestream_write_header(stream, field); + codestream_write_header(stream, field, data); /*--------------------------------------------------------*\ ! Walk through the tile structure and assemble the packed ! @@ -1444,7 +1409,7 @@ assemble_codestream(bwc_field *const field) emit_symbol(stream, EOC, 2); - packed_stream = calloc(1, sizeof(bwc_stream)); + packed_stream = calloc(1, sizeof(bwc_span)); if(!packed_stream) { // memory allocation error @@ -1463,7 +1428,7 @@ assemble_codestream(bwc_field *const field) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: uchar parse_codestream(bwc_field *const field, bitstream *const stream) ! +! FUNCTION NAME: uchar parse_codestream(bwc_codec *const field, bitstream *const stream) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -1474,7 +1439,7 @@ assemble_codestream(bwc_field *const field) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! stream bitstream* - Structure used to assemble a bwc bit- ! @@ -1494,13 +1459,13 @@ assemble_codestream(bwc_field *const field) ! 05.08.2019 Patrick Vogler B87D120 V 0.1.0 function created ! ! ! \*----------------------------------------------------------------------------------------------------------*/ -bwc_field* -parse_codestream(bwc_data *const data, uint8 const layer) +bwc_codec* +parse_codestream(bwc_stream *const data, uint8 const layer) { /*-----------------------*\ ! DEFINE STRUCTS: ! \*-----------------------*/ - bwc_field *field; + bwc_codec *field; bitstream *stream; /*-----------------------*\ diff --git a/src/library/dwt.c b/src/library/dwt.c index b22c7f2..1fc9136 100755 --- a/src/library/dwt.c +++ b/src/library/dwt.c @@ -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 field, uchar highband_flag, uint16 level) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -1434,7 +1434,7 @@ initialize_gain_lut() ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! highband_flag uchar - Defines the subband for which Gb is ! @@ -1459,7 +1459,7 @@ initialize_gain_lut() ! ! \*----------------------------------------------------------------------------------------------------------*/ bwc_float -get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level) +get_dwt_energy_gain(bwc_codec *const field, uchar highband_flag, uint16 level) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -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 field, ! ! -------------- bwc_parameter *const parameter) ! ! ! ! DESCRIPTION: ! @@ -1594,7 +1594,7 @@ get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! parameter bwc_parameter* - Structure defining a bwc parameter. ! @@ -1614,7 +1614,7 @@ get_dwt_energy_gain(bwc_field *const field, uchar highband_flag, uint16 level) ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter) +forward_wavelet_transform(bwc_codec *const field, bwc_parameter *const parameter) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -2117,7 +2117,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 field, ! ! -------------- bwc_parameter *const parameter) ! ! ! ! DESCRIPTION: ! @@ -2135,7 +2135,7 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! parameter bwc_parameter* - Structure defining a bwc parameter. ! @@ -2155,7 +2155,7 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter) +inverse_wavelet_transform(bwc_codec *const field, bwc_parameter *const parameter) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! diff --git a/src/library/libbwc.c b/src/library/libbwc.c index 7917322..83d7c9b 100755 --- a/src/library/libbwc.c +++ b/src/library/libbwc.c @@ -145,7 +145,7 @@ #endif /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: uint8 initialize_precinct(bwc_field *const field, bwc_precinct *precinct, ! +! FUNCTION NAME: uint8 initialize_precinct(bwc_codec *const field, bwc_precinct *precinct, ! ! -------------- const uint32 dX, const uint32 dY, ! ! const uint32 dZ, const uint32 dTS) ! ! ! @@ -157,7 +157,7 @@ ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! precinct bwc_precinct* - Structure defining a bwc precinct. ! @@ -180,7 +180,7 @@ ! ! \*----------------------------------------------------------------------------------------------------------*/ static uint8 -initialize_precinct(bwc_field *const field, bwc_precinct *precinct, const uint32 dX, const uint32 dY, +initialize_precinct(bwc_codec *const field, bwc_precinct *precinct, const uint32 dX, const uint32 dY, const uint32 dZ, const uint32 dTS) { /*-----------------------*\ @@ -386,7 +386,7 @@ static uint8 subband_gain(const uint8 highband_flag) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: uchar initialize_subband(bwc_field *const field, bwc_parameter *const parameter, ! +! FUNCTION NAME: uchar initialize_subband(bwc_codec *const field, bwc_parameter *const parameter, ! ! -------------- bwc_resolution *const resolution, ! ! bwc_subband *const subband, ! ! int32 resolution_level, ! @@ -403,7 +403,7 @@ static uint8 subband_gain(const uint8 highband_flag) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! parameter bwc_parameter* - Structure defining a bwc tile parameter.! @@ -433,7 +433,7 @@ static uint8 subband_gain(const uint8 highband_flag) ! ! \*----------------------------------------------------------------------------------------------------------*/ static uchar -initialize_subband(bwc_field *const field, bwc_parameter *const parameter, bwc_resolution *const resolution, +initialize_subband(bwc_codec *const field, bwc_parameter *const parameter, bwc_resolution *const resolution, bwc_subband *const subband, int32 resolution_level, int16 highband_flag) @@ -684,7 +684,7 @@ initialize_subband(bwc_field *const field, bwc_parameter *const parameter, bwc_r /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void fill_buffer(bwc_field *const field, bwc_tile *const tile, ! +! FUNCTION NAME: void fill_buffer(bwc_codec *const field, bwc_tile *const tile, ! ! ------------ bwc_parameter *const parameter, ! ! bwc_sample *const working_buffer, ! ! double *const data, ! @@ -701,7 +701,7 @@ initialize_subband(bwc_field *const field, bwc_parameter *const parameter, bwc_r ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! tile bwc_tile* - Structure defining a bwc tile. ! @@ -732,9 +732,9 @@ initialize_subband(bwc_field *const field, bwc_parameter *const parameter, bwc_r ! ! \*----------------------------------------------------------------------------------------------------------*/ static void -fill_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const parameter, +fill_buffer(bwc_codec *const field, bwc_tile *const tile, bwc_parameter *const parameter, bwc_sample *const working_buffer, - bwc_data *const data, + bwc_stream *const data, uint16 param_id) { /*-----------------------*\ @@ -760,7 +760,6 @@ fill_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const p bwc_tile_inf *tile_info; bwc_param_ctrl *param_control; bwc_param_inf *param_info; - bwc_cmd_opts_ll *param; /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -776,7 +775,7 @@ fill_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const p ! structures to temporary variables to make the code more ! ! readable. ! \*--------------------------------------------------------*/ - info = field->info; + info = &field->info; tile_info = &tile->info; @@ -787,17 +786,7 @@ fill_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const p ! Calculate the offset of the current parameter in the da- ! ! ta array. ! \*--------------------------------------------------------*/ - param_offset = 0; - param = data->info.parameter->root; - - while(param != NULL && param->id < param_id) - { - if(param->precision == param_info->precision) - { - param_offset += param->size; - } - param = param -> next; - } + param_offset = info->nX * info->nY * info->nZ * info->nTS * param_id; /*--------------------------------------------------------*\ ! Associate the working buffer with the data pointer in ! @@ -824,7 +813,7 @@ fill_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const p ! Check if the parameter is single or double precision and ! ! handle the field accordingly. ! \*--------------------------------------------------------*/ - if(param_info->precision == 8) + if(info->data_prec == bwc_precision_double) { /*--------------------------------------------------------*\ ! Safe the field pointer to a temporary variable to make ! @@ -937,7 +926,7 @@ fill_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const p } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void fill_buffer(bwc_field *const field, bwc_tile *const tile, ! +! FUNCTION NAME: void fill_buffer(bwc_codec *const field, bwc_tile *const tile, ! ! ------------ bwc_parameter *const parameter, ! ! bwc_sample *const working_buffer, ! ! double *const data, ! @@ -953,7 +942,7 @@ fill_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const p ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! tile bwc_tile* - Structure defining a bwc tile. ! @@ -984,9 +973,9 @@ fill_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const p ! ! \*----------------------------------------------------------------------------------------------------------*/ static void -flush_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const parameter, +flush_buffer(bwc_codec *const field, bwc_tile *const tile, bwc_parameter *const parameter, bwc_sample *const working_buffer, - bwc_data *const data, + bwc_stream *const data, uint16 param_id) { /*-----------------------*\ @@ -1010,7 +999,6 @@ flush_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const bwc_sample *src; bwc_gl_inf *info; bwc_param_inf *param_info; - bwc_cmd_opts_ll *param; /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -1026,7 +1014,7 @@ flush_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const ! structures to temporary variables to make the code more ! ! readable. ! \*--------------------------------------------------------*/ - info = field->info; + info = &field->info; param_info = ¶meter->info; @@ -1038,17 +1026,7 @@ flush_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const ! Calculate the offset of the current parameter in the da- ! ! ta array. ! \*--------------------------------------------------------*/ - param_offset = 0; - param = data->info.parameter->root; - - while(param != NULL && param->id < param_id) - { - if(param->precision == param_info->precision) - { - param_offset += param->size; - } - param = param -> next; - } + param_offset = info->nX * info->nY * info->nZ * info->nTS * param_id; /*--------------------------------------------------------*\ ! Calculate the width, height, depth and dt of the current ! @@ -1063,7 +1041,7 @@ flush_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const ! Check if the parameter is single or double precision and ! ! handle the field accordingly. ! \*--------------------------------------------------------*/ - if(param_info->precision == 8) + if(info->data_prec == bwc_precision_double) { /*--------------------------------------------------------*\ ! Safe the field pointer to a temporary variable to make ! @@ -1150,7 +1128,7 @@ flush_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void buff_normalize(bwc_field *const field, bwc_parameter *const parameter) ! +! FUNCTION NAME: void buff_normalize(bwc_codec *const field, bwc_parameter *const parameter) ! ! ! ! ! ! DESCRIPTION: ! @@ -1187,7 +1165,7 @@ flush_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const ! ! \*----------------------------------------------------------------------------------------------------------*/ static void -normalize_param(bwc_field *const field, bwc_parameter *const parameter) +normalize_param(bwc_codec *const field, bwc_parameter *const parameter) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -1275,7 +1253,7 @@ normalize_param(bwc_field *const field, bwc_parameter *const parameter) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void denormalize_param(bwc_field *const field, bwc_parameter *const parameter) ! +! FUNCTION NAME: void denormalize_param(bwc_codec *const field, bwc_parameter *const parameter) ! ! ! ! ! ! DESCRIPTION: ! @@ -1312,7 +1290,7 @@ normalize_param(bwc_field *const field, bwc_parameter *const parameter) ! ! \*----------------------------------------------------------------------------------------------------------*/ static void -denormalize_param(bwc_field *const field, bwc_parameter *const parameter) +denormalize_param(bwc_codec *const field, bwc_parameter *const parameter) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -1404,31 +1382,30 @@ denormalize_param(bwc_field *const field, bwc_parameter *const parameter) || || \************************************************************************************************************/ /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: bwc_field *bwc_initialize_data(...) ! +! FUNCTION NAME: bwc_codec *bwc_initialize_data(...) ! ! -------------- ! ! ! ! DESCRIPTION: ! ! ------------ ! -! This function initializes the bwc_data structure with all necessary parameters. ! +! This function initializes the bwc_stream structure with all necessary parameters. ! ! ! ! PARAMETERS: ! ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! +! prec bwc_precision - Input data precision ! +! ! ! nX ,nY, nZ unsigned int(64 bit) - Number of spatial Datapoints ! ! ! ! nTS unsigned int(16 bit) - Number of Timesteps. ! ! ! ! nPar unsigned int(8 bit) - Number of Parameters ! ! ! -! file_extension char* - File extension associated ! -! with the numerical dataset. ! -! ! ! RETURN VALUE: ! ! ------------- ! ! Type Description ! ! ---- ----------- ! -! bwc_data* - Structure used to store a numerical ! +! bwc_stream* - Structure used to store a numerical ! ! dataset/compressed bitstream. ! ! ! ! DEVELOPMENT HISTORY: ! @@ -1439,16 +1416,15 @@ denormalize_param(bwc_field *const field, bwc_parameter *const parameter) ! 09.06.2021 Patrick Vogler B87D120 V 0.1.0 function created ! ! ! \*----------------------------------------------------------------------------------------------------------*/ -bwc_data* -bwc_initialize_data(double* field, uint64 const nX, uint64 const nY, uint64 const nZ, uint16 const nTS, uint8 const nPar, char *file_extension) +bwc_stream* +bwc_initialize_data(void *const data, bwc_precision const prec) { /*-----------------------*\ ! DEFINE STRUCTS: ! \*-----------------------*/ - bwc_gl_inf *info; - bwc_data *file; + bwc_stream *file; - file = calloc(1, sizeof(bwc_data)); + file = calloc(1, sizeof(bwc_stream)); if(!file) { // memory allocation error @@ -1456,137 +1432,18 @@ bwc_initialize_data(double* field, uint64 const nX, uint64 const nY, uint64 cons return NULL; } - info = &file->info; - - info->nX = nX; - info->nY = nY; - info->nZ = nZ; - info->nTS = nTS; - info->nPar = nPar; - memcpy(&info->f_ext, file_extension, sizeof(char) * 19); - - file->field.d = field; + if (prec == bwc_precision_double) + { + file->field.d = (double *)data; + } + else if (prec == bwc_precision_single) + { + file->field.f = (float *)data; + } return file; } -/*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_add_param(bwc_data* data, char *name, uint16 sample, uchar dim, uint8 precision) ! -! -------------- ! -! ! -! ! -! DESCRIPTION: ! -! ------------ ! -! This function initializes and adds new parameters to the parameter linked list. The linked ! -! list stores the parameter name, its precision, sampling factor and the dimension for which ! -! the sampling is active. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! name char* - Name of parameter(id). ! -! ! -! sample unsigned int(16 bit) - Sampling factor for parameter(id). ! -! ! -! dim unsigned char - Dimension(s) for which the sampling ! -! factor is active. ! -! ! -! precision unsigned int(8 bit) - Bit precision of the parameter. ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 19.10.2017 Patrick Vogler B87D120 V 0.1.0 function created ! -! 03.12.2019 Patrick Vogler B87E7E4 V 0.1.0 redefined the function for the ! -! bwc_data structure. ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -void -bwc_add_param(bwc_data* data, char *name, uint8 precision) -{ - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_inf *info; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(data); - - /*--------------------------------------------------------*\ - ! Save the global info structure to a temporary variable ! - ! to make the code more readable. ! - \*--------------------------------------------------------*/ - info = &data->info; - - /*--------------------------------------------------------*\ - ! Check if the specified parameter name has the proper ! - ! length. ! - \*--------------------------------------------------------*/ - if((strlen(name) > 24) && name) - { - fprintf(stderr, "o==========================================================o\n"\ - "| WARNING: Invalid parameter name: %-24s|\n"\ - "| |\n"\ - "| Parameter names cannot exceed 24 characters. |\n"\ - "| |\n"\ - "o==========================================================o\n",name); - } - - /*--------------------------------------------------------*\ - ! Check if the parameter structure has already been allo- ! - ! cated. ! - \*--------------------------------------------------------*/ - if(info->parameter == NULL) - { - /*--------------------------------------------------------*\ - ! If the bwc_add_param function is called for the first ! - ! time, allocate the parameter structure and save the root ! - ! node address. ! - \*--------------------------------------------------------*/ - info->parameter = calloc(1, sizeof(bwc_cmd_opts_ll)); - info->parameter->root = info->parameter; - } - else - { - /*--------------------------------------------------------*\ - ! If a new parameter is added, allocate the nex linked ! - ! list node, save the root node address in its structure ! - ! and set the linked list access pointer to the new node. ! - \*--------------------------------------------------------*/ - info->parameter->next = calloc(1, sizeof(bwc_cmd_opts_ll)); - info->parameter->next->root = info->parameter->root; - info->parameter->next->id = info->parameter->id + 1; - info->parameter = info->parameter->next; - } - - /*--------------------------------------------------------*\ - ! Save the name of the new parameter its precision in the ! - ! structure of the new node. ! - \*--------------------------------------------------------*/ - strcpy(info->parameter->name, name ? name : "undefined"); - info->parameter->precision = precision ? precision : PREC_BYTE; - - /*--------------------------------------------------------*\ - ! Evaluate the parameter size the information in the ! - ! linked list. ! - \*--------------------------------------------------------*/ - info->parameter->size = (info->nX * info->nY * info->nZ * info->nTS); -} - /*----------------------------------------------------------------------------------------------------------*\ ! FUNCTION NAME: ! ! -------------- ! @@ -1597,7 +1454,7 @@ bwc_add_param(bwc_data* data, char *name, uint8 precision) ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -bwc_set_com(bwc_data *const data, char const *const com, uint16 size) +bwc_set_com(bwc_stream *const data, char const *const com, uint16 size) { /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -1635,7 +1492,7 @@ bwc_set_com(bwc_data *const data, char const *const com, uint16 size) ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -bwc_set_aux(bwc_data *const data, char const *const aux, uint32 size) +bwc_set_aux(bwc_stream *const data, char const *const aux, uint32 size) { /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -1664,60 +1521,7 @@ bwc_set_aux(bwc_data *const data, char const *const aux, uint32 size) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: bwc_field *bwc_initialize_data(...) ! -! -------------- ! -! ! -! DESCRIPTION: ! -! ------------ ! -! This function is used to copy the numerical dataset stored in the bwc_data ! -! structure to a user supplied memory block. A size argument is necessary ! -! to verify that the memory block has the correct size. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! data bwc_data* - Structure used to store a numerical ! -! dataset/compressed bitstream. ! -! ! -! buffer unsigned char* - Memory block supplied by ! -! the function caller. ! -! ! -! data bwc_data* - Size of memory block. ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 09.06.2021 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -void -bwc_get_data(bwc_data* data, uchar* buffer, uint64 size) -{ - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - - if(size != (uint64)(data->info.nX * data->info.nY * data->info.nZ * data->info.nTS * data->info.nPar)) - { - fprintf(stderr, "Incorrect buffer size\n"); - } - else - { - memcpy(buffer, data->field.d, size * sizeof(double)); - } -} - -/*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_free_data(bwc_data* file) ! +! FUNCTION NAME: void bwc_free_data(bwc_stream* file) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -1731,7 +1535,7 @@ bwc_get_data(bwc_data* data, uchar* buffer, uint64 size) ! ! ! Variable Type Description ! ! -------- ---- ----------- ! -! file bwc_data - Defines a structure used to store all ! +! file bwc_stream - Defines a structure used to store all ! ! the relevant parameters and the data ! ! field of a numerical dataset or com- ! ! pressed codestream. ! @@ -1753,57 +1557,33 @@ bwc_get_data(bwc_data* data, uchar* buffer, uint64 size) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bwc_free_data(bwc_data* data) +bwc_free_data(bwc_stream* data) { - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_cmd_opts_ll *param, *temp; - if(data) { - if(data->info.parameter) + if(data->codestream.data) { - param = data->info.parameter->root; - - while(param != NULL) - { - temp = param; - param = param -> next; - free(temp); - } + release_packed_stream(data->codestream.data); } - - if(data) + if(data->codestream.aux) { - if(data->codestream.data) - { - release_packed_stream(data->codestream.data); - } - if(data->codestream.aux) - { - release_packed_stream(data->codestream.aux); - } - if(data->codestream.com) - { - release_packed_stream(data->codestream.com); - } - if(data->fp) - { - fclose(data->fp); - } - free(data->codestream.data); - free(data->codestream.aux); - free(data->codestream.com); - free(data->field.d); - free(data->field.f); - free(data); + release_packed_stream(data->codestream.aux); } + if(data->codestream.com) + { + release_packed_stream(data->codestream.com); + } + free(data->codestream.data); + free(data->codestream.aux); + free(data->codestream.com); + free(data->field.d); + free(data->field.f); + free(data); } } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: uchar create_field(bwc_field *const field) ! +! FUNCTION NAME: uchar create_field(bwc_codec *const field) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -1815,7 +1595,7 @@ bwc_free_data(bwc_data* data) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! RETURN VALUE: ! @@ -1833,7 +1613,7 @@ bwc_free_data(bwc_data* data) ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -create_field(bwc_field *const field) +create_field(bwc_codec *const field) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -1856,7 +1636,6 @@ create_field(bwc_field *const field) \*-----------------------*/ bwc_gl_ctrl *control; bwc_gl_inf *info; - bwc_cmd_opts_ll *param; bwc_parameter *parameter; bwc_param_ctrl *param_control; bwc_param_inf *param_info; @@ -1878,7 +1657,7 @@ create_field(bwc_field *const field) ! variables to make the code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info; + info = &field->info; /*--------------------------------------------------------*\ ! Calculate the number of tiles in all spatial and tempo- ! @@ -1965,23 +1744,8 @@ create_field(bwc_field *const field) return 1; } - /*--------------------------------------------------------*\ - ! Initialize the parameter information linked listed. ! - \*--------------------------------------------------------*/ - param = info->parameter->root; - for(j = 0; j < info->nPar; ++j) { - /*--------------------------------------------------------*\ - ! Check if there is a node in the parameter information ! - ! linked list corresponding to the current paramter. ! - \*--------------------------------------------------------*/ - if(!param && (param->id == j)) - { - fprintf(stderr, MEMERROR); - return 1; - } - /*--------------------------------------------------------*\ ! Save the parameter and its info and control structure to ! ! temporary variables to make the code more readable. ! @@ -1990,13 +1754,6 @@ create_field(bwc_field *const field) param_control = ¶meter->control; param_info = ¶meter->info; - /*--------------------------------------------------------*\ - ! Save the corresponding parameter name and its sampling ! - ! factors and precision in the info and control structures.! - \*--------------------------------------------------------*/ - param_info->name = param->name; - param_info->precision = param->precision; - /*--------------------------------------------------------*\ ! Initialize the number of codeblocks for the current ! ! parameter. ! @@ -2199,12 +1956,6 @@ create_field(bwc_field *const field) } } } - - /*--------------------------------------------------------*\ - ! Advance the parameter information linked listed to the ! - ! next node. ! - \*--------------------------------------------------------*/ - param = param->next; } /*--------------------------------------------------------*\ @@ -2236,7 +1987,7 @@ create_field(bwc_field *const field) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void kill_compression(bwc_field *const field) ! +! FUNCTION NAME: void kill_compression(bwc_codec *const field) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -2251,7 +2002,7 @@ create_field(bwc_field *const field) ! ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! RETURN VALUE: ! @@ -2269,7 +2020,7 @@ create_field(bwc_field *const field) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bwc_kill_compression(bwc_field *const field) +bwc_kill_compression(bwc_codec *const field) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -2292,7 +2043,7 @@ bwc_kill_compression(bwc_field *const field) ! variables to make the code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info; + info = &field->info; if(field->tile) { @@ -2356,12 +2107,12 @@ bwc_kill_compression(bwc_field *const field) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: bwc_field *bwc_initialize_field(bwc_data *const data) ! +! FUNCTION NAME: bwc_codec *bwc_initialize_field(bwc_stream *const data) ! ! -------------- ! ! ! ! DESCRIPTION: ! ! ------------ ! -! This function initializes the bwc_field structure with all necessary standard parameters ! +! This function initializes the bwc_codec structure with all necessary standard parameters ! ! to (de)compress a floating point array with nX * nY * nZ grid points, nTS timesteps and ! ! nPar parameters. ! ! ! @@ -2376,7 +2127,7 @@ bwc_kill_compression(bwc_field *const field) ! ------------- ! ! Type Description ! ! ---- ----------- ! -! bwc_field* Defines the (de)compression data structure. ! +! bwc_codec* Defines the (de)compression data structure. ! ! ! ! DEVELOPMENT HISTORY: ! ! -------------------- ! @@ -2386,8 +2137,8 @@ bwc_kill_compression(bwc_field *const field) ! 14.03.2018 Patrick Vogler B87D120 V 0.1.0 function created ! ! ! \*----------------------------------------------------------------------------------------------------------*/ -bwc_field* -bwc_initialize_field(bwc_data *const data) +bwc_codec* +bwc_initialize_field(bwc_precision const prec, uint64 const nX, uint64 const nY, uint64 const nZ, uint16 const nTS, uint8 const nPar) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -2409,7 +2160,7 @@ bwc_initialize_field(bwc_data *const data) /*--------------------------------------------------------*\ ! Allocate the root compression data structure. ! \*--------------------------------------------------------*/ - bwc_field *field = calloc(1, sizeof(bwc_field)); + bwc_codec *field = calloc(1, sizeof(bwc_codec)); if(!field) { // memory allocation error @@ -2423,7 +2174,23 @@ bwc_initialize_field(bwc_data *const data) ! variables to make the code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info = &data->info; + info = &field->info; + + info->nX = nX; + info->nY = nY; + info->nZ = nZ; + info->nTS = nTS; + info->nPar = nPar; + info->data_prec = prec; + + /*--------------------------------------------------------*\ + ! Save the codec precision in the info structure. ! + \*--------------------------------------------------------*/ +#if PREC_BYTE == 8 + info->codec_prec = bwc_precision_double; +#elif PREC_BYTE == 4 + info->codec_prec = bwc_precision_single; +#endif /*--------------------------------------------------------*\ ! Set all tile sizes to their maximum allowable value. The ! @@ -2479,11 +2246,6 @@ bwc_initialize_field(bwc_data *const data) control->bitrate = 0; control->guard_bits = 2; - /*--------------------------------------------------------*\ - ! Save the codec precision in the info structure. ! - \*--------------------------------------------------------*/ - info->precision = PREC_BYTE; - /*--------------------------------------------------------*\ ! Calculate the possible decomposition levels for all ! ! spatial and temporal dimensions. ! @@ -2553,19 +2315,19 @@ bwc_initialize_field(bwc_data *const data) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_error_resilience(bwc_field *const field) ! +! FUNCTION NAME: void bwc_set_error_resilience(bwc_codec *const field) ! ! -------------- ! ! ! ! DESCRIPTION: ! ! ------------ ! -! This function sets the error resilience marker in the bwc_field structure if an error ! +! This function sets the error resilience marker in the bwc_codec structure if an error ! ! resilient compression approach is to be employed. ! ! ! ! PARAMETERS: ! ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! RETURN VALUE: ! @@ -2583,7 +2345,7 @@ bwc_initialize_field(bwc_data *const data) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bwc_set_error_resilience(bwc_field *const field) +bwc_set_error_resilience(bwc_codec *const field) { /*-----------------------*\ ! DEFINE STRUCTS: ! @@ -2602,7 +2364,7 @@ bwc_set_error_resilience(bwc_field *const field) control = &field->control; /*--------------------------------------------------------*\ - ! Amend the codeblock style in the bwc_field structure ! + ! Amend the codeblock style in the bwc_codec structure ! ! according to the specified value. ! \*--------------------------------------------------------*/ control->error_resilience ^= 0x01; @@ -2615,19 +2377,19 @@ bwc_set_error_resilience(bwc_field *const field) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_quant_style(bwc_field *const field, bwc_quant_st quantization_style) ! +! FUNCTION NAME: void bwc_set_quant_style(bwc_codec *const field, bwc_quant_st quantization_style) ! ! -------------- ! ! ! ! DESCRIPTION: ! ! ------------ ! -! This function amends the quantization style in the bwc_field structure according to the ! +! This function amends the quantization style in the bwc_codec structure according to the ! ! specified value. ! ! ! ! PARAMETERS: ! ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! quantization_style bwc_quant_st - Quantization style used during compres- ! @@ -2648,7 +2410,7 @@ bwc_set_error_resilience(bwc_field *const field) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -set_quant_style(bwc_field *const field, bwc_quant_st quantization_style) +set_quant_style(bwc_codec *const field, bwc_quant_st quantization_style) { /*-----------------------*\ ! DEFINE STRUCTS: ! @@ -2668,7 +2430,7 @@ set_quant_style(bwc_field *const field, bwc_quant_st quantization_style) control = &field->control; /*--------------------------------------------------------*\ - ! Amend the quantization style in the bwc_field structure ! + ! Amend the quantization style in the bwc_codec structure ! ! according to the specified value. ! \*--------------------------------------------------------*/ control->quantization_style = quantization_style; @@ -2681,19 +2443,19 @@ set_quant_style(bwc_field *const field, bwc_quant_st quantization_style) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_quant_step_size(bwc_field *const field, double delta) ! +! FUNCTION NAME: void bwc_set_quant_step_size(bwc_codec *const field, double delta) ! ! -------------- ! ! ! ! DESCRIPTION: ! ! ------------ ! -! This function amends the quantization step size in the bwc_field structure according to ! +! This function amends the quantization step size in the bwc_codec structure according to ! ! the specified value. ! ! ! ! PARAMETERS: ! ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! delta double - Quantization step size used during ! @@ -2714,7 +2476,7 @@ set_quant_style(bwc_field *const field, bwc_quant_st quantization_style) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -set_quant_step_size(bwc_field *const field, double delta) +set_quant_step_size(bwc_codec *const field, double delta) { /*-----------------------*\ ! DEFINE STRUCTS: ! @@ -2785,19 +2547,19 @@ set_quant_step_size(bwc_field *const field, double delta) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_progression(bwc_field *const field, bwc_prog_ord progression) ! +! FUNCTION NAME: void bwc_set_progression(bwc_codec *const field, bwc_prog_ord progression) ! ! -------------- ! ! ! ! DESCRIPTION: ! ! ------------ ! -! This function amends the progression order in the bwc_field structure according to the ! +! This function amends the progression order in the bwc_codec structure according to the ! ! specified value. ! ! ! ! PARAMETERS: ! ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! progression bwc_prog_ord - Progression orders employed during com- ! @@ -2819,7 +2581,7 @@ set_quant_step_size(bwc_field *const field, double delta) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -set_progression(bwc_field *const field, bwc_prog_ord progression) +set_progression(bwc_codec *const field, bwc_prog_ord progression) { /*-----------------------*\ ! DEFINE STRUCTS: ! @@ -2841,7 +2603,7 @@ set_progression(bwc_field *const field, bwc_prog_ord progression) control = &field->control; /*--------------------------------------------------------*\ - ! Amend the progression order in the bwc_field structure ! + ! Amend the progression order in the bwc_codec structure ! ! according to the specified value. ! \*--------------------------------------------------------*/ control->progression = progression; @@ -2854,21 +2616,21 @@ set_progression(bwc_field *const field, bwc_prog_ord progression) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_kernels(bwc_field *const field, bwc_dwt_filter KernelX, ! +! FUNCTION NAME: void bwc_set_kernels(bwc_codec *const field, bwc_dwt_filter KernelX, ! ! -------------- bwc_dwt_filter KernelY, ! ! bwc_dwt_filter KernelZ, ! ! bwc_dwt_filter KernelTS) ! ! ! ! DESCRIPTION: ! ! ------------ ! -! This function amends the wavelet kernels in the bwc_field structure according to the ! +! This function amends the wavelet kernels in the bwc_codec structure according to the ! ! specified values. ! ! ! ! PARAMETERS: ! ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! KernelX, KernelY, KernelZ bwc_dwt_filter - Wavelet kernels used for spatial ! @@ -2892,7 +2654,7 @@ set_progression(bwc_field *const field, bwc_prog_ord progression) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -set_kernels(bwc_field *const field, bwc_dwt_filter KernelX, bwc_dwt_filter KernelY, +set_kernels(bwc_codec *const field, bwc_dwt_filter KernelX, bwc_dwt_filter KernelY, bwc_dwt_filter KernelZ, bwc_dwt_filter KernelTS) { /*-----------------------*\ @@ -2912,7 +2674,7 @@ set_kernels(bwc_field *const field, bwc_dwt_filter KernelX, bwc_dwt_filter Kerne control = &field->control; /*--------------------------------------------------------*\ - ! Amend the wavelet kernels in the bwc_field structure ac- ! + ! Amend the wavelet kernels in the bwc_codec structure ac- ! ! cording to the specified values. For all unspecified ! ! (NULL) values the corresponding wavelet kernel is set to ! ! bwc_dwt_9_7/bwc_dwt_haar. ! @@ -2930,19 +2692,19 @@ set_kernels(bwc_field *const field, bwc_dwt_filter KernelX, bwc_dwt_filter Kerne } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_decomp(bwc_field *const field, uint8 decompX, uint8 decompY, ! +! FUNCTION NAME: void bwc_set_decomp(bwc_codec *const field, uint8 decompX, uint8 decompY, ! ! -------------- uint8 decompZ, uint8 decompTS) ! ! ! ! DESCRIPTION: ! ! ------------ ! -! This function amends the decomposition levels in the bwc_field structure according to the ! +! This function amends the decomposition levels in the bwc_codec structure according to the ! ! specified values. ! ! ! ! PARAMETERS: ! ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! decompX, decompY, decompZ unsigned int(8 bit) - Number of spatial wavelet decomposition ! @@ -2966,7 +2728,7 @@ set_kernels(bwc_field *const field, bwc_dwt_filter KernelX, bwc_dwt_filter Kerne ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bwc_set_decomp(bwc_field *const field, uint8 decompX, uint8 decompY, uint8 decompZ, uint8 decompTS) +bwc_set_decomp(bwc_codec *const field, uint8 decompX, uint8 decompY, uint8 decompZ, uint8 decompTS) { /*-----------------------*\ ! DEFINE FLOAT VARIABLES: ! @@ -2994,7 +2756,7 @@ bwc_set_decomp(bwc_field *const field, uint8 decompX, uint8 decompY, uint8 decom ! variables to make the code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info; + info = &field->info; /*--------------------------------------------------------*\ ! Calculate the possible decomposition levels for all ! @@ -3098,19 +2860,19 @@ bwc_set_decomp(bwc_field *const field, uint8 decompX, uint8 decompY, uint8 decom } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_precincts(bwc_field *const field, uint8 pX, uint8 pY, uint8 pZ, uint8 pTS) ! +! FUNCTION NAME: void bwc_set_precincts(bwc_codec *const field, uint8 pX, uint8 pY, uint8 pZ, uint8 pTS) ! ! -------------- ! ! ! ! DESCRIPTION: ! ! ------------ ! -! This function amends the precinct size in the bwc_field structure according to the ! +! This function amends the precinct size in the bwc_codec structure according to the ! ! specified values. ! ! ! ! PARAMETERS: ! ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! px, py, pz, pTS unsigned int(8 bit) - Spatial and temporal precinct dimensions! @@ -3131,7 +2893,7 @@ bwc_set_decomp(bwc_field *const field, uint8 decompX, uint8 decompY, uint8 decom ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bwc_set_precincts(bwc_field *const field, uint8 pX, uint8 pY, uint8 pZ, uint8 pTS) +bwc_set_precincts(bwc_codec *const field, uint8 pX, uint8 pY, uint8 pZ, uint8 pTS) { /*-----------------------*\ ! DEFINE STRUCTS: ! @@ -3149,7 +2911,7 @@ bwc_set_precincts(bwc_field *const field, uint8 pX, uint8 pY, uint8 pZ, uint8 pT ! variables to make the code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info; + info = &field->info; /*--------------------------------------------------------*\ ! Check if the precinct sizes are specified for a valid ! @@ -3199,19 +2961,19 @@ bwc_set_precincts(bwc_field *const field, uint8 pX, uint8 pY, uint8 pZ, uint8 pT } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_codeblocks(bwc_field *const field, uint8 cbX, uint8 cbY, ! +! FUNCTION NAME: void bwc_set_codeblocks(bwc_codec *const field, uint8 cbX, uint8 cbY, ! ! -------------- uint8 cbZ, uint8 cbTS) ! ! ! ! DESCRIPTION: ! ! ------------ ! -! This function amends the codeblock size in the bwc_field structure according to the ! +! This function amends the codeblock size in the bwc_codec structure according to the ! ! specified values. ! ! ! ! PARAMETERS: ! ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! cbx, cby, cbz, cbTS unsigned int(8 bit) - Spatial and temporal codeblock dimen- ! @@ -3232,7 +2994,7 @@ bwc_set_precincts(bwc_field *const field, uint8 pX, uint8 pY, uint8 pZ, uint8 pT ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bwc_set_codeblocks(bwc_field *const field, uint8 cbX, uint8 cbY, uint8 cbZ, uint8 cbTS) +bwc_set_codeblocks(bwc_codec *const field, uint8 cbX, uint8 cbY, uint8 cbZ, uint8 cbTS) { /*-----------------------*\ ! DEFINE STRUCTS: ! @@ -3250,7 +3012,7 @@ bwc_set_codeblocks(bwc_field *const field, uint8 cbX, uint8 cbY, uint8 cbZ, uint ! variables to make the code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info; + info = &field->info; /*--------------------------------------------------------*\ ! Check if the codeblock sizes are specified for a valid ! @@ -3300,19 +3062,19 @@ bwc_set_codeblocks(bwc_field *const field, uint8 cbX, uint8 cbY, uint8 cbZ, uint } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_qm(bwc_field *const field, uint8 Qm) ! +! FUNCTION NAME: void bwc_set_qm(bwc_codec *const field, uint8 Qm) ! ! -------------- ! ! ! ! DESCRIPTION: ! ! ------------ ! -! This function amends the Q number formate range in the bwc_field structure according to the ! +! This function amends the Q number formate range in the bwc_codec structure according to the ! ! specified value. ! ! ! ! PARAMETERS: ! ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! Qm unsigned int(8 bit) - Q number formate range (m). ! @@ -3332,7 +3094,7 @@ bwc_set_codeblocks(bwc_field *const field, uint8 cbX, uint8 cbY, uint8 cbZ, uint ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bwc_set_qm(bwc_field *const field, uint8 Qm) +bwc_set_qm(bwc_codec *const field, uint8 Qm) { /*-----------------------*\ ! DEFINE STRUCTS: ! @@ -3352,7 +3114,7 @@ bwc_set_qm(bwc_field *const field, uint8 Qm) /*--------------------------------------------------------*\ ! Check if the Q number formate range is valid and amend ! - ! the bwc_field structure accordingly. ! + ! the bwc_codec structure accordingly. ! \*--------------------------------------------------------*/ if((int8)(PREC_BIT - Qm) < 2) { @@ -3381,12 +3143,12 @@ bwc_set_qm(bwc_field *const field, uint8 Qm) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_set_tiles(bwc_field *const field, uint32 tilesX, uint32 tilesY, uint32 tilesZ, ! +! FUNCTION NAME: void bwc_set_tiles(bwc_codec *const field, uint32 tilesX, uint32 tilesY, uint32 tilesZ, ! ! -------------- uint32 tilesTS, uchar instr) ! ! ! ! DESCRIPTION: ! ! ------------ ! -! This function amends the tileSize and num_Tiles values in the bwc_field structure according ! +! This function amends the tileSize and num_Tiles values in the bwc_codec structure according ! ! to the specified values. The NUMBEROF and SIZEOF constants can be used to either specify ! ! the tile sizes or the number of tiles in each spatial and temporal directions. ! ! ! @@ -3394,7 +3156,7 @@ bwc_set_qm(bwc_field *const field, uint8 Qm) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! tilesX, tilesY, tilesZ unsigned int(32 bit) - Variables defining the size of ! @@ -3421,7 +3183,7 @@ bwc_set_qm(bwc_field *const field, uint8 Qm) ! ! \*----------------------------------------------------------------------------------------------------------*/ void -bwc_set_tiles(bwc_field *const field, uint64 tilesX, uint64 tilesY, uint64 tilesZ, uint16 tilesTS, bwc_tile_instr instr) +bwc_set_tiles(bwc_codec *const field, uint64 tilesX, uint64 tilesY, uint64 tilesZ, uint16 tilesTS, bwc_tile_instr instr) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -3446,7 +3208,7 @@ bwc_set_tiles(bwc_field *const field, uint64 tilesX, uint64 tilesY, uint64 tiles ! variables to make the code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info; + info = &field->info; /*--------------------------------------------------------*\ ! Check if the size of one tile or the overall number of ! @@ -3609,7 +3371,7 @@ bwc_set_tiles(bwc_field *const field, uint64 tilesX, uint64 tilesY, uint64 tiles } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_create_compression(bwc_field *field, char *rate_control) ! +! FUNCTION NAME: void bwc_create_compression(bwc_codec *field, char *rate_control) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -3625,7 +3387,7 @@ bwc_set_tiles(bwc_field *const field, uint64 tilesX, uint64 tilesY, uint64 tiles ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! rate_control char* - Variable defining the bitrate. ! @@ -3646,7 +3408,7 @@ bwc_set_tiles(bwc_field *const field, uint64 tilesX, uint64 tilesY, uint64 tiles ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -bwc_create_compression(bwc_field *field, char *rate_control) +bwc_create_compression(bwc_codec *codec, bwc_stream *stream, char *rate_control) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -3673,14 +3435,14 @@ bwc_create_compression(bwc_field *field, char *rate_control) /*-----------------------*\ ! DEFINE ASSERTIONS: ! \*-----------------------*/ - assert(field); + assert(codec); /*--------------------------------------------------------*\ ! Save the global control structure to a temporary varia- ! ! ble to make the code more readable. ! \*--------------------------------------------------------*/ - info = field->info; - control = &field->control; + info = &codec->info; + control = &codec->control; /*--------------------------------------------------------*\ ! Allocate the array used to hold the quality layer bit- ! @@ -3767,10 +3529,10 @@ bwc_create_compression(bwc_field *field, char *rate_control) control->bitrate = realloc(control->bitrate, control->nLayers * sizeof(float)); /*--------------------------------------------------------*\ - ! Create the field structure used to compress a floating ! + ! Create the codec structure used to compress a floating ! ! point array defined by the bwc_initialize function. ! \*--------------------------------------------------------*/ - if(create_field(field)) + if(create_field(codec)) { return 1; } @@ -3778,17 +3540,17 @@ bwc_create_compression(bwc_field *field, char *rate_control) /*--------------------------------------------------------*\ ! Evaluate the size of the main header. ! \*--------------------------------------------------------*/ - /*control->headerSize = 108 + info->nPar * (25 + control->nTiles * 2 * PREC_BYTE) - + control->nLayers * 4; + control->headerSize = 99 + info->nPar * control->nTiles * 2 * PREC_BYTE + + control->nLayers * 4; - if(field->aux != NULL) + if(stream->codestream.aux != NULL) { - control->headerSize += 6 + field->aux->size; + control->headerSize += 6 + stream->codestream.aux->size; } - if(field->com != NULL) + if(stream->codestream.com != NULL) { - control->headerSize += 6 + field->com->size; + control->headerSize += 6 + stream->codestream.com->size; } if(control->headerSize >= 0xFFFFFFFF) @@ -3803,13 +3565,13 @@ bwc_create_compression(bwc_field *field, char *rate_control) "o==========================================================o\n"); return 1; - }*/ + } return 0; } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: uchar bwc_compress(bwc_field *const field, bwc_float *const data) ! +! FUNCTION NAME: uchar bwc_compress(bwc_codec *const field, bwc_float *const data) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -3820,7 +3582,7 @@ bwc_create_compression(bwc_field *field, char *rate_control) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! RETURN VALUE: ! @@ -3838,7 +3600,7 @@ bwc_create_compression(bwc_field *field, char *rate_control) ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -bwc_compress(bwc_field *const field, bwc_data *const data) +bwc_compress(bwc_codec *const field, bwc_stream *const data) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -3902,39 +3664,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) ! variables to make the code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info; - - /*--------------------------------------------------------*\ - ! Evaluate the size of the main header. ! - \*--------------------------------------------------------*/ - control->headerSize = 108 + info->nPar * (25 + control->nTiles * 2 * PREC_BYTE) - + control->nLayers * 4; - - if(data->codestream.aux != NULL) - { - field->aux = data->codestream.aux; - control->headerSize += 6 + field->aux->size; - } - - if(data->codestream.com != NULL) - { - field->com = data->codestream.com; - control->headerSize += 6 + field->com->size; - } - - if(control->headerSize >= 0xFFFFFFFF) - { - fprintf(stderr,"o==========================================================o\n"\ - "| ERROR: Main header exceeds maximum size limit |\n"\ - "| |\n"\ - "| Appending the auxiliary information to the main |\n"\ - "| header would exceed its maximum size limit of |\n"\ - "| 4294967295 bytes. |\n"\ - "| |\n"\ - "o==========================================================o\n"); - - return 1; - } + info = &field->info; /*--------------------------------------------------------*\ ! Evaluate the working buffer size and allocate it accord- ! @@ -4107,7 +3837,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) start = (double)clock(); #endif #endif - data->codestream.data = assemble_codestream(field); + data->codestream.data = assemble_codestream(field, data); if(!data->codestream.data) { free(working_buffer); @@ -4138,7 +3868,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) ttl = ((double)clock() - ttl)/CLOCKS_PER_SEC; #endif - nfs = (uint64)(info->nX * info->nY * info->nZ * info->nTS * info->nPar * info->precision); + nfs = (uint64)(info->nX * info->nY * info->nZ * info->nTS * info->nPar * info->data_prec); css = (uint64)data->codestream.data->size; @@ -4165,7 +3895,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: uchar bwc_create_compression(bwc_field *field_ptr, char *rate_control, uchar instr) ! +! FUNCTION NAME: uchar bwc_create_compression(bwc_codec *field_ptr, char *rate_control, uchar instr) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -4177,7 +3907,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! rate_control (opt) char* - Variable defining the bitrate/accuracy. ! @@ -4199,13 +3929,13 @@ bwc_compress(bwc_field *const field, bwc_data *const data) ! 15.03.2018 Patrick Vogler B87D120 V 0.1.0 function created ! ! ! \*----------------------------------------------------------------------------------------------------------*/ -bwc_field * -bwc_create_decompression(bwc_data *const data, uint8 layer) +bwc_codec * +bwc_create_decompression(bwc_stream *const data, uint8 layer) { /*-----------------------*\ ! DEFINE STRUCTS: ! \*-----------------------*/ - bwc_field *field; + bwc_codec *field; /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -4229,7 +3959,7 @@ bwc_create_decompression(bwc_data *const data, uint8 layer) } /*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: uchar bwc_create_compression(bwc_field *field, float rate_control, uchar instr) ! +! FUNCTION NAME: uchar bwc_create_compression(bwc_codec *field, float rate_control, uchar instr) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -4244,7 +3974,7 @@ bwc_create_decompression(bwc_data *const data, uint8 layer) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! rate_control float - Variable defining the bitrate/accuracy. ! @@ -4267,13 +3997,13 @@ bwc_create_decompression(bwc_data *const data, uint8 layer) ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -bwc_decompress(bwc_field *const field, bwc_data *const data) +bwc_decompress(bwc_codec *const field, bwc_stream *const data) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! \*-----------------------*/ uint64 buff_size; - uint64 single_size, double_size; + uint64 data_size; uint64 i; uint16 p; @@ -4300,7 +4030,6 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) bwc_tile *tile; bwc_parameter *parameter; bwc_sample *working_buffer; - bwc_cmd_opts_ll *param; /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -4324,40 +4053,30 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) ! variables to make the code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info; + info = &field->info; - /*--------------------------------------------------------*\ - ! Calculate the field size after subsampling and allocate ! - ! the field memory blocks. ! - \*--------------------------------------------------------*/ - if(data->info.parameter) + data_size = info->nX * info->nY * info->nZ * info->nTS * info->nPar; + if(info->data_prec == bwc_precision_double) { - param = data->info.parameter->root; - double_size = - single_size = 0; - - while(param != NULL) - { - if(param->precision == 8) - { - double_size += param->size; - } - else if (param->precision == 4) - { - single_size += param->size; - } - - param = param -> next; - } + data->field.d = calloc(data_size, sizeof(double)); + data->field.f = calloc(0, sizeof(float)); + if(!data->field.d) + { + // memory allocation error + fprintf(stderr, MEMERROR); + return 1; + } } - - data->field.d = calloc(double_size, sizeof(double)); - data->field.f = calloc(single_size, sizeof(float)); - if(!data->field.d || !data->field.f) + else if (info->data_prec == bwc_precision_single) { - // memory allocation error - fprintf(stderr, MEMERROR); - return 1; + data->field.d = calloc(0, sizeof(double)); + data->field.f = calloc(data_size, sizeof(float)); + if(!data->field.f) + { + // memory allocation error + fprintf(stderr, MEMERROR); + return 1; + } } /*--------------------------------------------------------*\ @@ -4528,4 +4247,4 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) return 0; -} \ No newline at end of file +} diff --git a/src/library/tier1.c b/src/library/tier1.c index 60abda2..79a09e8 100755 --- a/src/library/tier1.c +++ b/src/library/tier1.c @@ -16,7 +16,7 @@ || ------------ || || || || 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 || || refere to JPEG2000 by D. S. Taubman and M. W. Marcellin. || || || @@ -2274,7 +2274,7 @@ 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: bwc_encoded_cblk* encode_codeblock(bwc_codec *const field, bwc_cblk_access *const access, ! ! -------------- bwc_coder_stripe *const codeblock, ! ! const uint64 width, ! ! const uint64 height, ! @@ -2307,7 +2307,7 @@ compute_convex_hull(bwc_encoded_cblk *const encoded_codeblock, double *const mse ! ! \*----------------------------------------------------------------------------------------------------------*/ static void -encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, +encode_codeblock(bwc_codec *const field, bwc_cblk_access *const access, bwc_coder_stripe *const codeblock, const uint64 width, const uint64 height, @@ -2595,7 +2595,7 @@ 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: bwc_encoded_cblk* encode_codeblock(bwc_codec *const field, bwc_cblk_access *const access, ! ! bwc_coder_stripe *const codeblock, ! ! const uint64 width, ! ! const uint64 height, ! @@ -2628,7 +2628,7 @@ encode_codeblock(bwc_field *const field, bwc_cblk_access *const access, ! ! \*----------------------------------------------------------------------------------------------------------*/ static void -decode_codeblock(bwc_field *const field, bwc_cblk_access *const access, +decode_codeblock(bwc_codec *const field, bwc_cblk_access *const access, bwc_coder_stripe *const codeblock, const uint64 width, const uint64 height, @@ -2828,7 +2828,7 @@ decode_codeblock(bwc_field *const field, bwc_cblk_access *const access, ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const parameter) +t1_encode(bwc_codec *const field, bwc_tile *const tile, bwc_parameter *const parameter) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -3131,7 +3131,7 @@ t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -t1_decode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const parameter) +t1_decode(bwc_codec *const field, bwc_tile *const tile, bwc_parameter *const parameter) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! diff --git a/src/library/tier2.c b/src/library/tier2.c index 96ac025..5c3a08a 100755 --- a/src/library/tier2.c +++ b/src/library/tier2.c @@ -16,7 +16,7 @@ || ------------ || || || || 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 || || 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: void create_quality_layers(bwc_codec *const field, bwc_tile *const tile) ! ! -------------- ! ! ! ! ! @@ -385,7 +385,7 @@ 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_codec *const field, bwc_tile *const tile, ! ! -------------- bwc_resolution *const resolution, ! ! uint32 const prec_idx, ! ! int8 const q_layer, ! @@ -403,7 +403,7 @@ decode_length(bitstream *const header, bwc_codeblock *const codeblock, int8 cons ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! tile bwc_tile* - Structure defining a bwc tile. ! @@ -435,7 +435,7 @@ decode_length(bitstream *const header, bwc_codeblock *const codeblock, int8 cons ! ! \*----------------------------------------------------------------------------------------------------------*/ static int32 -create_packet(bwc_field *const field, bwc_tile *const tile, +create_packet(bwc_codec *const field, bwc_tile *const tile, bwc_resolution *const resolution, uint32 const prec_idx, int16 const q_layer, @@ -498,7 +498,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile, if(!est) { packet->body.access = - packet->body.memory = calloc(packet->body.size, sizeof(bwc_stream)); + packet->body.memory = calloc(packet->body.size, sizeof(bwc_span)); if(!packet->body.memory) { // memory allocation error @@ -706,7 +706,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 field, bwc_tile *const tile) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -723,7 +723,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile, ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! tile bwc_tile* - Structure defining a bwc tile. ! @@ -743,7 +743,7 @@ create_packet(bwc_field *const field, bwc_tile *const tile, ! ! \*----------------------------------------------------------------------------------------------------------*/ static uchar -create_packets(bwc_field *const field, bwc_tile *const tile) +create_packets(bwc_codec *const field, bwc_tile *const tile) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -772,7 +772,7 @@ create_packets(bwc_field *const field, bwc_tile *const tile) ! variables to make the code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info; + info = &field->info; /*--------------------------------------------------------*\ ! Iterate overall quality layers for every precinct in all ! @@ -845,7 +845,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 field, bwc_tile *const tile, ! ! -------------- uint16 const threshold, ! ! int16 const q_layer, ! ! uchar const est) ! @@ -860,7 +860,7 @@ create_packets(bwc_field *const field, bwc_tile *const tile) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! tile bwc_tile* - Structure defining a bwc tile. ! @@ -888,7 +888,7 @@ create_packets(bwc_field *const field, bwc_tile *const tile) ! ! \*----------------------------------------------------------------------------------------------------------*/ static int64 -create_quality_layer(bwc_field *const field, bwc_tile *const tile, +create_quality_layer(bwc_codec *const field, bwc_tile *const tile, uint16 const threshold, int16 const q_layer, uchar const est) @@ -924,7 +924,7 @@ create_quality_layer(bwc_field *const field, bwc_tile *const tile, ! variables to make the code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info; + info = &field->info; for(j = 0, estimated_ql_size = 0; j < info->nPar; ++j) { @@ -1075,7 +1075,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 field, bwc_tile *const tile) ! ! -------------- ! ! ! ! ! @@ -1087,7 +1087,7 @@ create_quality_layer(bwc_field *const field, bwc_tile *const tile, ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! tile bwc_tile* - Structure defining a bwc tile. ! @@ -1107,7 +1107,7 @@ create_quality_layer(bwc_field *const field, bwc_tile *const tile, ! ! \*----------------------------------------------------------------------------------------------------------*/ static uchar -create_quality_layers(bwc_field *const field, bwc_tile *const tile) +create_quality_layers(bwc_codec *const field, bwc_tile *const tile) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! @@ -1139,7 +1139,7 @@ create_quality_layers(bwc_field *const field, bwc_tile *const tile) ! temporary variables to make the code more readable. ! \*--------------------------------------------------------*/ control = &field->control; - info = field->info; + info = &field->info; tile_control = &tile->control; tile_info = &tile->info; @@ -1255,7 +1255,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 field, bwc_tile *const tile) ! ! -------------- ! ! ! ! DESCRIPTION: ! @@ -1269,7 +1269,7 @@ create_quality_layers(bwc_field *const field, bwc_tile *const tile) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! tile bwc_tile* - Structure defining a bwc tile. ! @@ -1289,7 +1289,7 @@ create_quality_layers(bwc_field *const field, bwc_tile *const tile) ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -t2_encode(bwc_field *const field, bwc_tile *const tile) +t2_encode(bwc_codec *const field, bwc_tile *const tile) { /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -1319,7 +1319,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 field, bwc_tile *const tile, ! ! -------------- bwc_packet *const packet, ! ! uint64 const body_size) ! ! ! @@ -1332,7 +1332,7 @@ t2_encode(bwc_field *const field, bwc_tile *const tile) ! ----------- ! ! Variable Type Description ! ! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! +! field bwc_codec* - Structure defining the compression/ ! ! decompression stage. ! ! ! ! tile bwc_tile* - Structure defining a bwc tile. ! @@ -1356,7 +1356,7 @@ t2_encode(bwc_field *const field, bwc_tile *const tile) ! ! \*----------------------------------------------------------------------------------------------------------*/ uchar -parse_packet(bwc_field *const field, bwc_tile *const tile, +parse_packet(bwc_codec *const field, bwc_tile *const tile, bwc_packet *const packet, uint64 const body_size) {