diff --git a/Makefile b/Makefile index 6d562dc..e21ea6e 100755 --- a/Makefile +++ b/Makefile @@ -112,7 +112,7 @@ help: @echo " release Compiles BigWhoop (with OpenMP enabled if applica-" @echo " ble). Code optimization is set to the highest level." @echo "" - @echo " cmdl Removes all files and folders created during a pre-" + @echo " cldebug Removes all files and folders created during a pre-" @echo " vious compile run. Compiles BigWhoop (with OpenMP " @echo " enabled if applicable). All relevant debug flags " @echo " are set. " diff --git a/include/library/private/libbwc.h b/include/library/private/libbwc.h index 908c063..8418632 100755 --- a/include/library/private/libbwc.h +++ b/include/library/private/libbwc.h @@ -72,6 +72,14 @@ uint8 const nPar, char *const file_extension); //==========|==========================|======================|======|=======|==================== + uchar bwc_set_com (bwc_data *const data, + char const *const com, + uint16 const size); + //==========|==========================|======================|======|=======|==================== + 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); diff --git a/include/library/private/types.h b/include/library/private/types.h index 9f38bb8..323101f 100755 --- a/include/library/private/types.h +++ b/include/library/private/types.h @@ -689,7 +689,8 @@ uint8 guard_bits; // Number of guard bits during quant. - bwc_stream header; // Main codestream header. + uint64 headerSize; // Size estimation of the global header. + uint64 codestreamSize; // Size of entire code-stream. bwc_quant_st quantization_style; // Quantization style. bwc_prog_ord progression; // Packet progression order. @@ -713,5 +714,8 @@ 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; #endif \ No newline at end of file diff --git a/src/interfaces/reader/eas3.c b/src/interfaces/reader/eas3.c index c09fa90..2631bd9 100644 --- a/src/interfaces/reader/eas3.c +++ b/src/interfaces/reader/eas3.c @@ -1486,7 +1486,6 @@ write_eas3(bwc_data *const data, char *const filename) return 1; } - /*--------------------------------------------------------*\ ! Calculate the size of the data field used for the endian ! ! conversion and write operations. ! diff --git a/src/library/codestream.c b/src/library/codestream.c index 2ae6c73..24af2f4 100755 --- a/src/library/codestream.c +++ b/src/library/codestream.c @@ -137,20 +137,28 @@ can_read(bitstream *const stream, const uint64 length) ! ! \*----------------------------------------------------------------------------------------------------------*/ static void -codestream_write_header(bitstream *const stream, bwc_field *const field) +codestream_write_header(bitstream *const stream, + bwc_field *const field) { /*-----------------------*\ ! DEFINE INT VARIABLES: ! \*-----------------------*/ - uint32 t; - uint16 Leoh; - uint8 p; + uint64 Lcss; + uint32 t; + uint32 Laux; + uint16 Linf, Lctr, Lcom; + uint16 Leoh; + uint8 p, l; /*-----------------------*\ ! DEFINE STRUCTS: ! \*-----------------------*/ - bwc_gl_ctrl *control; - bwc_gl_inf *info; + bwc_gl_ctrl *control; + bwc_gl_inf *info; + bwc_tile *tile; + bwc_parameter *parameter; + bwc_stream *aux; + bwc_stream *com; /*-----------------------*\ ! DEFINE ASSERTIONS: ! @@ -163,46 +171,116 @@ codestream_write_header(bitstream *const stream, bwc_field *const field) ! structure to temporary variables to make the code more ! ! readable. ! \*--------------------------------------------------------*/ - control = &field->control; - info = field->info; + info = field->info; + control = &field->control; - /*--------------------------------------------------------*\ - ! Calculate the size of the end of header (EOH) maker seg- ! - ! ment - excluding the EOH marker. ! - \*--------------------------------------------------------*/ - Leoh = 2 + (control->nTiles * info->nPar * 2 * PREC_BYTE); + tile = &field->tile[0]; - /*--------------------------------------------------------*\ - ! Emit the portion of the main header already created by ! - ! the bwc_create_compression function. ! - \*--------------------------------------------------------*/ - emit_chunck(stream, control->header.memory, control->header.size); + parameter = &tile->parameter[0]; + + aux = field->aux; + com = field->com; + + Linf = 40 + info->nPar * 25; + Lctr = 50 + control->nLayers * 4; + Leoh = info->nPar * control->nTiles * 2 * PREC_BYTE; + Lcss = control->codestreamSize; + + emit_symbol(stream, SOC, 2); + emit_symbol(stream, Lcss, 8); + emit_symbol(stream, SGI, 2); + emit_symbol(stream, Linf, 2); + emit_symbol(stream, info->nX, 8); + emit_symbol(stream, info->nY, 8); + 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, SGC, 2); + emit_symbol(stream, Lctr, 2); + + emit_symbol(stream, control->CSsgc, 2); + + emit_symbol(stream, control->error_resilience, 1); + + emit_symbol(stream, control->quantization_style, 1); + emit_symbol(stream, control->guard_bits, 1); + + emit_symbol(stream, control->qt_exponent, 1); + emit_symbol(stream, control->qt_mantissa, 2); + + emit_symbol(stream, control->progression, 1); + emit_symbol(stream, control->KernelX << 6 | control->KernelY << 4 | + control->KernelZ << 2 | control->KernelTS, 1); + + emit_symbol(stream, control->decompX, 1); + emit_symbol(stream, control->decompY, 1); + emit_symbol(stream, control->decompZ, 1); + emit_symbol(stream, control->decompTS, 1); + + emit_symbol(stream, control->precSizeY << 4 | control->precSizeX, 1); + emit_symbol(stream, control->precSizeTS << 4 | control->precSizeZ, 1); + + emit_symbol(stream, control->cbX, 1); + emit_symbol(stream, control->cbY, 1); + emit_symbol(stream, control->cbZ, 1); + emit_symbol(stream, control->cbTS, 1); + + emit_symbol(stream, control->Qm, 1); + + emit_symbol(stream, control->tileSizeX, 8); + emit_symbol(stream, control->tileSizeY, 8); + emit_symbol(stream, control->tileSizeZ, 8); + emit_symbol(stream, control->tileSizeTS, 2); + + emit_symbol(stream, control->nLayers, 1); + + for(l = 0; l < control->nLayers; ++l) + { + emit_symbol(stream, *(uint32 *)&control->bitrate[l], 4); + } + + if(aux != NULL) + { + Laux = aux->size + 4; + + emit_symbol(stream, SAX, 2); + emit_symbol(stream, Laux, 4); + emit_chunck(stream, aux->memory, aux->size); + } + + if(com != NULL) + { + Lcom = com->size + 2; + + emit_symbol(stream, COM, 2); + emit_symbol(stream, Lcom, 2); + emit_chunck(stream, com->memory, com->size); + } - /*--------------------------------------------------------*\ - ! Emit the end of header (EOH) marker and EOH marker seg- ! - ! ment size Leoh. ! - \*--------------------------------------------------------*/ emit_symbol(stream, EOH, 2); emit_symbol(stream, Leoh, 2); - /*--------------------------------------------------------*\ - ! Loop through all tile parameters and... ! - \*--------------------------------------------------------*/ for(t = 0; t < control->nTiles; ++t) { for(p = 0; p < info->nPar; ++p) { - /*--------------------------------------------------------*\ - ! ...emit the maximum and minimum parameter value to the ! - ! header stream. ! - \*--------------------------------------------------------*/ - emit_symbol(stream, *(uint64 *)&field->tile[t].parameter[p].info.parameter_min, PREC_BYTE); - emit_symbol(stream, *(uint64 *)&field->tile[t].parameter[p].info.parameter_max, PREC_BYTE); - /*--------------------------------------------------------*\ - ! Reset the maximum and minimum parameter value in the ! - ! parameter structure. ! - \*--------------------------------------------------------*/ + emit_symbol(stream, *(uint64 *)&field->tile[t]. + parameter[p].info. + parameter_min, PREC_BYTE); + emit_symbol(stream, *(uint64 *)&field->tile[t]. + parameter[p].info. + parameter_max, PREC_BYTE); + field->tile[t].parameter[p].info.parameter_max = -FLT_MAX; field->tile[t].parameter[p].info.parameter_min = FLT_MAX; } @@ -475,7 +553,6 @@ assemble_tile(bwc_field *const field, bwc_tile *const tile, bitstream *const str emit_symbol(stream, tile->info.tile_index, 4); emit_symbol(stream, tile->control.body_size, 8); emit_symbol(stream, SOD, 2); - for(packet_index = 0; packet_index < tile->control.nPackets; ++packet_index) { packet = tile->packet_sequence[packet_index]; @@ -553,9 +630,7 @@ parse_main_header(bwc_data *const data,bitstream *const stream) uint16 Linf, Lctr, Lcom, Leoh, Lunk; uint16 marker; uint16 nTS; - uint8 dim; uint8 index, l; - uint8 samp; uint8 nPar, p; uint8 codec_prec, precision; @@ -601,12 +676,16 @@ parse_main_header(bwc_data *const data,bitstream *const stream) { case SOC: { - if(index != 0) + if(index != 0 && !can_read(stream, 2)) { // Invalid Codestream fprintf(stderr, CSERROR); status |= CODESTREAM_ERROR; + break; } + + stream->Lmax = (uint64)get_symbol(stream, 8); + break; } @@ -664,6 +743,8 @@ parse_main_header(bwc_data *const data,bitstream *const stream) info = field->info = &data->info; control = &field->control; + control->codestreamSize = stream->Lmax; + status |= CODESTREAM_SGI_READ; break; } @@ -1254,311 +1335,6 @@ parse_body(bwc_field *const field, bitstream *const stream) || | |__| |__] |___ | |___ | |__| | \| |___ | | |__| | \| ___] || || || \************************************************************************************************************/ -/*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void *test(void) ! -! -------------- ! -! ! -! DESCRIPTION: ! -! ------------ ! -! DESCRIPTION NEEDED ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! - - - ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! - Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -uchar -assemble_main_header(bwc_field *const field) -{ - /*-----------------------*\ - ! DEFINE INT VARIABLES: ! - \*-----------------------*/ - uint64 size; - uint16 Linf, Lctr; - uint8 p, l; - - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_ctrl *control; - bwc_gl_inf *info; - bwc_tile *tile; - bwc_parameter *parameter; - bitstream *stream; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(field); - - /*--------------------------------------------------------*\ - ! Save the global as well as the subband control and info ! - ! structure to temporary variables to make the code more ! - ! readable. ! - \*--------------------------------------------------------*/ - info = field->info; - control = &field->control; - - tile = &field->tile[0]; - - parameter = &tile->parameter[0]; - - Linf = 40 + info->nPar * 25; - Lctr = 50 + control->nLayers * 4; - - size = 6 + Linf + Lctr; - - stream = init_stream(NULL, size, 'c'); - if(!stream) - { - // memory allocation error - return 1; - } - - emit_symbol(stream, SOC, 2); - emit_symbol(stream, SGI, 2); - emit_symbol(stream, Linf, 2); - emit_symbol(stream, info->nX, 8); - emit_symbol(stream, info->nY, 8); - 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, SGC, 2); - emit_symbol(stream, Lctr, 2); - - emit_symbol(stream, control->CSsgc, 2); - - emit_symbol(stream, control->error_resilience, 1); - - emit_symbol(stream, control->quantization_style, 1); - emit_symbol(stream, control->guard_bits, 1); - - emit_symbol(stream, control->qt_exponent, 1); - emit_symbol(stream, control->qt_mantissa, 2); - - emit_symbol(stream, control->progression, 1); - emit_symbol(stream, control->KernelX << 6 | control->KernelY << 4 | - control->KernelZ << 2 | control->KernelTS, 1); - - emit_symbol(stream, control->decompX, 1); - emit_symbol(stream, control->decompY, 1); - emit_symbol(stream, control->decompZ, 1); - emit_symbol(stream, control->decompTS, 1); - - emit_symbol(stream, control->precSizeY << 4 | control->precSizeX, 1); - emit_symbol(stream, control->precSizeTS << 4 | control->precSizeZ, 1); - - emit_symbol(stream, control->cbX, 1); - emit_symbol(stream, control->cbY, 1); - emit_symbol(stream, control->cbZ, 1); - emit_symbol(stream, control->cbTS, 1); - - emit_symbol(stream, control->Qm, 1); - - emit_symbol(stream, control->tileSizeX, 8); - emit_symbol(stream, control->tileSizeY, 8); - emit_symbol(stream, control->tileSizeZ, 8); - emit_symbol(stream, control->tileSizeTS, 2); - - emit_symbol(stream, control->nLayers, 1); - - for(l = 0; l < control->nLayers; ++l) - { - emit_symbol(stream, *(uint32 *)&control->bitrate[l], 4); - } - - if(terminate_stream(stream, &control->header)) - { - // memory allocation error - fprintf(stderr, MEMERROR); - return 1; - } - - return 0; -} - -/*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void *test(void) ! -! -------------- ! -! ! -! DESCRIPTION: ! -! ------------ ! -! DESCRIPTION NEEDED ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! - - - ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! - Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -uchar -codestream_write_aux(bwc_stream *const header, bwc_stream *const aux) -{ - /*-----------------------*\ - ! DEFINE INT VARIABLES: ! - \*-----------------------*/ - uint32 Laux; - - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bitstream *stream; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(header); - assert(aux); - - stream = init_stream(header->memory, header->size, 'c'); - if(!stream) - { - // memory allocation error - return 1; - } - - Laux = aux->size + 4; - - stream->L = stream->Lmax; - stream->Lmax += Laux + 2; - stream->memory = realloc(stream->memory, stream->Lmax); - if(!stream->memory) - { - // memory allocation error - fprintf(stderr, MEMERROR); - return 1; - } - - emit_symbol(stream, SAX, 2); - emit_symbol(stream, Laux, 4); - emit_chunck(stream, aux->memory, aux->size); - - if(terminate_stream(stream, header)) - { - // memory allocation error - return 1; - } - - return 0; -} - -/*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void *test(void) ! -! -------------- ! -! ! -! DESCRIPTION: ! -! ------------ ! -! DESCRIPTION NEEDED ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! - - - ! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! - - ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! - Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -uchar -codestream_write_com(bwc_stream *const header, bwc_stream *const com) -{ - /*-----------------------*\ - ! DEFINE INT VARIABLES: ! - \*-----------------------*/ - uint16 Lcom; - - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bitstream *stream; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(header); - assert(com); - - stream = init_stream(header->memory, header->size, 'c'); - if(!stream) - { - // memory allocation error - return 1; - } - - Lcom = com->size + 2; - - stream->L = stream->Lmax; - stream->Lmax += Lcom + 2; - stream->memory = realloc(stream->memory, stream->Lmax); - if(!stream->memory) - { - // memory allocation error - fprintf(stderr, MEMERROR); - return 1; - } - - emit_symbol(stream, COM, 2); - emit_symbol(stream, Lcom, 2); - emit_chunck(stream, com->memory, com->size); - - if(terminate_stream(stream, header)) - { - // memory allocation error - return 1; - } - - return 0; -} - /*----------------------------------------------------------------------------------------------------------*\ ! FUNCTION NAME: bwc_stream* assemble_codestream(bwc_field *const field) ! ! -------------- ! @@ -1594,7 +1370,7 @@ assemble_codestream(bwc_field *const field) /*-----------------------*\ ! DEFINE INT VARIABLES: ! \*-----------------------*/ - uint64 i, size; + uint64 i; /*-----------------------*\ ! DEFINE STRUCTS: ! @@ -1616,7 +1392,8 @@ assemble_codestream(bwc_field *const field) ! bytes. ! \*--------------------------------------------------------*/ control = &field->control; - size = control->header.size; + + control->codestreamSize = control->headerSize + 2; /*--------------------------------------------------------*\ ! Walk through the tile structure and assemble the packed ! @@ -1638,15 +1415,15 @@ assemble_codestream(bwc_field *const field) { return NULL; } - - size += tile->control.header_size + tile->control.body_size; + control->codestreamSize += tile->control.header_size + + tile->control.body_size; } /*--------------------------------------------------------*\ ! Initialize the final codestream and emit the header ! ! bytes. ! \*--------------------------------------------------------*/ - stream = init_stream(NULL, size, 'c'); + stream = init_stream(NULL, control->codestreamSize, 'c'); codestream_write_header(stream, field); /*--------------------------------------------------------*\ @@ -1655,6 +1432,7 @@ assemble_codestream(bwc_field *const field) \*--------------------------------------------------------*/ for(i = 0; i < control->nTiles; ++i) { + /*--------------------------------------------------------*\ ! Save the tile structure in a temporary variable to make ! ! the code more readable. ! @@ -1734,8 +1512,7 @@ parse_codestream(bwc_data *const data, uint8 const layer) ! Initialize a bitstream used to parse the packed code- ! ! stream. ! \*--------------------------------------------------------*/ - stream = init_stream(data->codestream.data->memory, - data->codestream.data->size, 'd'); + stream = init_stream(data->codestream.data->memory, 10, 'd'); /*--------------------------------------------------------*\ ! Parse the main header and set up the field structure for ! diff --git a/src/library/dwt.c b/src/library/dwt.c index 5b94bc6..5acd238 100755 --- a/src/library/dwt.c +++ b/src/library/dwt.c @@ -1745,7 +1745,7 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter ! wavelet transform along the spatial and temporal dimen- ! ! sions specified in the control structure. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp parallel private(data, id, level, working_buffer, rX0, rX1, rY0, rY1, rZ0, rZ1, rTS0, rTS1) #endif { @@ -1798,7 +1798,7 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter ! Walk trough all the temporal and spatial slices as well ! ! as rows. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp for collapse(3) #endif for(t = 0; t < (rTS1 - rTS0); ++t) @@ -1879,7 +1879,7 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter ! Walk trough all the temporal and spatial slices as well ! ! as columns. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp for collapse(3) #endif for(t = 0; t < (rTS1 - rTS0); ++t) @@ -1959,7 +1959,7 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter /*--------------------------------------------------------*\ ! Walk trough all the temporal slices, rows and columns. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp for collapse(3) #endif for(t = 0; t < (rTS1 - rTS0); ++t) @@ -2039,7 +2039,7 @@ forward_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter /*--------------------------------------------------------*\ ! Walk trough all the spatial slices, rows and columns. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp for collapse(3) #endif for(z = 0; z < (rZ1 - rZ0); ++z) @@ -2282,7 +2282,7 @@ inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter ! wavelet transform along the spatial and temporal dimen- ! ! sions specified in the control structure. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp parallel private(data, id, level, working_buffer, rX0, rX1, rY0, rY1, rZ0, rZ1, rTS0, rTS1) #endif { @@ -2334,7 +2334,7 @@ inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter /*--------------------------------------------------------*\ ! Walk trough all the spatial slices, rows and columns. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp for collapse(3) #endif for(z = 0; z < (rZ1 - rZ0); ++z) @@ -2414,7 +2414,7 @@ inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter /*--------------------------------------------------------*\ ! Walk trough all the temporal slices, rows and columns. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp for collapse(3) #endif for(t = 0; t < (rTS1 - rTS0); ++t) @@ -2495,7 +2495,7 @@ inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter ! Walk trough all the temporal and spatial slices as well ! ! as columns. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp for collapse(3) #endif for(t = 0; t < (rTS1 - rTS0); ++t) @@ -2576,7 +2576,7 @@ inverse_wavelet_transform(bwc_field *const field, bwc_parameter *const parameter ! Walk trough all the temporal and spatial slices as well ! ! as rows. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp for collapse(3) #endif for(t = 0; t < (rTS1 - rTS0); ++t) diff --git a/src/library/libbwc.c b/src/library/libbwc.c index 02c02da..726f179 100755 --- a/src/library/libbwc.c +++ b/src/library/libbwc.c @@ -92,7 +92,7 @@ ! 04.05.2021 Patrick Vogler B87E7E4 V 0.1.0 clean up ! ! ! \*----------------------------------------------------------------------------------------------------------*/ -#if defined BWC_PROFILE +#ifdef BWC_PROFILE const char* get_size(uint64_t integer) { @@ -680,208 +680,6 @@ initialize_subband(bwc_field *const field, bwc_parameter *const parameter, bwc_r return 0; } -/*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_header_append_aux(bwc_field *const field, bwc_stream *const aux) ! -! -------------- ! -! ! -! DESCRIPTION: ! -! ------------ ! -! This function amends the main header for the compressed codestream with an auxiliary ! -! information block. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! aux unsigned char* - Memory handle for the auxiliary infor- ! -! mation block. ! -! ! -! size unsigned int(32 bit) - Size of the auxiliary information block.! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! uchar - Returns an unsigned char for error handling. ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 12.04.2019 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -static uchar -header_append_aux(bwc_field *const field, bwc_stream *const aux) -{ - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_ctrl *control; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(field); - assert(aux); - - /*--------------------------------------------------------*\ - ! Save the global control and info structure to temporary ! - ! variables to make the code more readable. ! - \*--------------------------------------------------------*/ - control = &field->control; - - /*--------------------------------------------------------*\ - ! Check if the main header is already defined in the field ! - ! structure. ! - \*--------------------------------------------------------*/ - if(!control->header.memory) - { - fprintf(stderr,"o==========================================================o\n"\ - "| ERROR: Main header not defined |\n"\ - "| |\n"\ - "| Unable to append auxiliary information since the |\n"\ - "| main header has not yet been created. Appending |\n"\ - "| information to the end of the main header can |\n"\ - "| only be done after the bwc_create_compression |\n"\ - "| function has been called. |\n"\ - "| |\n"\ - "o==========================================================o\n"); - - return 1; - } - - /*--------------------------------------------------------*\ - ! Check if the main header would exceed the maximum number ! - ! of allowable bits after appending the auxiliary ! - ! information. ! - \*--------------------------------------------------------*/ - if(((uint64)control->header.size + aux->size) >= 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; - } - - if(codestream_write_aux(&control->header, aux)) - { - return 1; - } - - return 0; -} - -/*----------------------------------------------------------------------------------------------------------*\ -! FUNCTION NAME: void bwc_header_append_com(bwc_field *const field, bwc_stream *const com) ! -! -------------- ! -! ! -! DESCRIPTION: ! -! ------------ ! -! This function amends the main header for the compressed codestream with a comment ! -! block. ! -! ! -! PARAMETERS: ! -! ----------- ! -! Variable Type Description ! -! -------- ---- ----------- ! -! field bwc_field* - Structure defining the compression/ ! -! decompression stage. ! -! ! -! com unsigned char* - Memory handle for the auxiliary infor- ! -! mation block. ! -! ! -! size unsigned int(32 bit) - Size of the auxiliary information block.! -! ! -! RETURN VALUE: ! -! ------------- ! -! Type Description ! -! ---- ----------- ! -! uchar - Returns an unsigned char for error handling. ! -! ! -! DEVELOPMENT HISTORY: ! -! -------------------- ! -! ! -! Date Author Change Id Release Description Of Change ! -! ---- ------ --------- ------- --------------------- ! -! 12.04.2019 Patrick Vogler B87D120 V 0.1.0 function created ! -! ! -\*----------------------------------------------------------------------------------------------------------*/ -static uchar -header_append_com(bwc_field *const field, bwc_stream *const com) -{ - /*-----------------------*\ - ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_ctrl *control; - - /*-----------------------*\ - ! DEFINE ASSERTIONS: ! - \*-----------------------*/ - assert(field); - - /*--------------------------------------------------------*\ - ! Save the global control and info structure to temporary ! - ! variables to make the code more readable. ! - \*--------------------------------------------------------*/ - control = &field->control; - - /*--------------------------------------------------------*\ - ! Check if the main header is already defined in the field ! - ! structure. ! - \*--------------------------------------------------------*/ - if(!control->header.memory) - { - fprintf(stderr,"o==========================================================o\n"\ - "| ERROR: Main header not defined |\n"\ - "| |\n"\ - "| Unable to append auxiliary information since the |\n"\ - "| main header has not yet been created. Appending |\n"\ - "| information to the end of the main header can |\n"\ - "| only be done after the bwc_create_compression |\n"\ - "| function has been called. |\n"\ - "| |\n"\ - "o==========================================================o\n"); - - return 1; - } - - /*--------------------------------------------------------*\ - ! Check if the main header would exceed the maximum number ! - ! of allowable bits after appending the auxiliary ! - ! information. ! - \*--------------------------------------------------------*/ - if(((uint64)control->header.size + com->size) >= 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; - } - - if(codestream_write_com(&control->header, com)) - { - return 1; - } - - return 0; -} /*----------------------------------------------------------------------------------------------------------*\ ! FUNCTION NAME: void fill_buffer(bwc_field *const field, bwc_tile *const tile, ! @@ -1035,7 +833,7 @@ fill_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const p /*--------------------------------------------------------*\ ! Walk through the tile parameter working buffer. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp parallel for collapse(3) private(dest, src_d, x) reduction(max:max) reduction(min:min) #endif for(t = 0; t < dt; ++t) @@ -1083,7 +881,7 @@ fill_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const p /*--------------------------------------------------------*\ ! Walk through the tile parameter working buffer. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp parallel for collapse(3) private(dest, src_f, x) reduction(max:max) reduction(min:min) #endif for(t = 0; t < dt; ++t) @@ -1209,7 +1007,6 @@ flush_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const \*-----------------------*/ bwc_sample *src; bwc_gl_inf *info; - bwc_param_ctrl *param_control; bwc_param_inf *param_info; bwc_cmd_opts_ll *param; @@ -1229,7 +1026,6 @@ flush_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const \*--------------------------------------------------------*/ info = field->info; - param_control = ¶meter->control; param_info = ¶meter->info; nX = info->nX; @@ -1276,7 +1072,7 @@ flush_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const /*--------------------------------------------------------*\ ! Walk through the tile parameter working buffer. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp parallel for collapse(3) private(dst_d, src, x) #endif for(t = 0; t < dt; ++t) @@ -1318,7 +1114,7 @@ flush_buffer(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const /*--------------------------------------------------------*\ ! Walk through the tile parameter working buffer. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp parallel for collapse(3) private(dst_f, src, x) #endif for(t = 0; t < dt; ++t) @@ -1457,7 +1253,7 @@ normalize_param(bwc_field *const field, bwc_parameter *const parameter) /*--------------------------------------------------------*\ ! Walk through the tile parameter working buffer. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp parallel for #endif for(x = 0; x < param_size; ++x) @@ -1580,7 +1376,7 @@ denormalize_param(bwc_field *const field, bwc_parameter *const parameter) /*--------------------------------------------------------*\ ! Walk through the tile parameter working buffer. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp parallel for #endif for(x = 0; x < param_size; ++x) @@ -1789,6 +1585,82 @@ bwc_add_param(bwc_data* data, char *name, uint8 precision) info->parameter->size = (info->nX * info->nY * info->nZ * info->nTS); } +/*----------------------------------------------------------------------------------------------------------*\ +! FUNCTION NAME: ! +! -------------- ! +! ! +! ! +! DESCRIPTION: ! +! ------------ ! +! ! +\*----------------------------------------------------------------------------------------------------------*/ +uchar +bwc_set_com(bwc_data *const data, char const *const com, uint16 size) +{ + /*-----------------------*\ + ! DEFINE ASSERTIONS: ! + \*-----------------------*/ + assert(data); + assert(com); + + /*--------------------------------------------------------*\ + ! Save the global info structure to a temporary variable ! + ! to make the code more readable. ! + \*--------------------------------------------------------*/ + data->codestream.com->memory = calloc(size, sizeof(char)); + if(!data->codestream.com->memory) + { + // memory allocation error + fprintf(stderr, MEMERROR); + return 1; + } + + memcpy(data->codestream.com->memory, com, size * sizeof(char)); + data->codestream.com->access = data->codestream.com->memory; + data->codestream.com->size = size; + data->codestream.com->position = 0; + + return 0; +} + +/*----------------------------------------------------------------------------------------------------------*\ +! FUNCTION NAME: ! +! -------------- ! +! ! +! ! +! DESCRIPTION: ! +! ------------ ! +! ! +\*----------------------------------------------------------------------------------------------------------*/ +uchar +bwc_set_aux(bwc_data *const data, char const *const aux, uint32 size) +{ + /*-----------------------*\ + ! DEFINE ASSERTIONS: ! + \*-----------------------*/ + assert(data); + assert(aux); + + /*--------------------------------------------------------*\ + ! Save the global info structure to a temporary variable ! + ! to make the code more readable. ! + \*--------------------------------------------------------*/ + data->codestream.com->memory = calloc(size, sizeof(char)); + if(!data->codestream.com->memory) + { + // memory allocation error + fprintf(stderr, MEMERROR); + return 1; + } + + memcpy(data->codestream.com->memory, aux, size * sizeof(char)); + data->codestream.com->access = data->codestream.com->memory; + data->codestream.com->size = size; + data->codestream.com->position = 0; + + return 0; +} + /*----------------------------------------------------------------------------------------------------------*\ ! FUNCTION NAME: bwc_field *bwc_initialize_data(...) ! ! -------------- ! @@ -1830,10 +1702,7 @@ bwc_get_data(bwc_data* data, uchar* buffer, uint64 size) { /*-----------------------*\ ! DEFINE STRUCTS: ! - \*-----------------------*/ - bwc_gl_inf *info; - - info = &data->info; + \*-----------------------*/ if(size != (uint64)(data->info.nX * data->info.nY * data->info.nZ * data->info.nTS * data->info.nPar)) { @@ -2074,7 +1943,7 @@ create_field(bwc_field *const field) /*--------------------------------------------------------*\ ! Initialize the tile header size. ! \*--------------------------------------------------------*/ - tile_control->header_size = 14; + tile_control->header_size = 18; /*--------------------------------------------------------*\ ! Initialize the convex hull slope threshold. ! @@ -2478,7 +2347,6 @@ bwc_kill_compression(bwc_field *const field) free(field->tile[i].parameter); } } - free(control->header.memory); free(control->bitrate); free(field->tile); free(field); @@ -3797,6 +3665,7 @@ bwc_create_compression(bwc_field *field, char *rate_control) /*-----------------------*\ ! DEFINE STRUCTS: ! \*-----------------------*/ + bwc_gl_inf *info; bwc_gl_ctrl *control; /*-----------------------*\ @@ -3808,6 +3677,7 @@ bwc_create_compression(bwc_field *field, char *rate_control) ! Save the global control structure to a temporary varia- ! ! ble to make the code more readable. ! \*--------------------------------------------------------*/ + info = field->info; control = &field->control; /*--------------------------------------------------------*\ @@ -3904,14 +3774,35 @@ bwc_create_compression(bwc_field *field, char *rate_control) } /*--------------------------------------------------------*\ - ! Create the main header for the compressed codestream and ! - ! save the memory handle in the field structure. ! + ! Evaluate the size of the main header. ! \*--------------------------------------------------------*/ - if(assemble_main_header(field)) + /*control->headerSize = 108 + info->nPar * (25 + control->nTiles * 2 * PREC_BYTE) + + control->nLayers * 4; + + if(field->aux != NULL) { - return 1; + control->headerSize += 6 + field->aux->size; } + if(field->com != NULL) + { + 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; + }*/ + return 0; } @@ -3965,17 +3856,17 @@ bwc_compress(bwc_field *const field, bwc_data *const data) double start, end; #ifdef BWC_PROFILE - double bpd; - double cpr; + double bpd = 0; + double cpr = 0; - double ttl; + double ttl = 0; - double cpy; - double nrm; + double cpy = 0; + double nrm = 0; - double wav; - double ent; - double ass; + double wav = 0; + double ent = 0; + double ass = 0; #endif /*-----------------------*\ @@ -3996,7 +3887,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) /*--------------------------------------------------------*\ ! Initialize the compression time measurement. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) ttl = omp_get_wtime(); #else @@ -4012,20 +3903,34 @@ bwc_compress(bwc_field *const field, bwc_data *const data) info = field->info; /*--------------------------------------------------------*\ - ! Check if any auxiliary information has been supplied by ! - ! the function caller and append the header accordingly. ! + ! Evaluate the size of the main header. ! \*--------------------------------------------------------*/ - if(data->codestream.aux && header_append_aux(field, data->codestream.aux)) + control->headerSize = 108 + info->nPar * (25 + control->nTiles * 2 * PREC_BYTE) + + control->nLayers * 4; + + if(data->codestream.aux != NULL) { - return 1; + field->aux = data->codestream.aux; + control->headerSize += 6 + field->aux->size; } - /*--------------------------------------------------------*\ - ! Check if any commentary information has been supplied by ! - ! the function caller and append the header accordingly. ! - \*--------------------------------------------------------*/ - if(data->codestream.com && header_append_com(field, data->codestream.com)) + 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; } @@ -4068,7 +3973,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) ! Fill the working buffer with the flow field data for the ! ! current tile parameter. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) start = omp_get_wtime(); #else @@ -4076,7 +3981,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) #endif #endif fill_buffer(field, tile, parameter, working_buffer, data, p); - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) end = omp_get_wtime(); cpy += end - start; @@ -4091,7 +3996,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) ! scale it to the dynamic range specified by the Qm param- ! ! eter. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) start = omp_get_wtime(); #else @@ -4099,7 +4004,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) #endif #endif normalize_param(field, parameter); - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) end = omp_get_wtime(); nrm += end - start; @@ -4112,7 +4017,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) /*--------------------------------------------------------*\ ! Perform the forward discrete wavelet transform. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) start = omp_get_wtime(); #else @@ -4124,7 +4029,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) free(working_buffer); return 1; } - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) end = omp_get_wtime(); wav += end - start; @@ -4137,7 +4042,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) /*--------------------------------------------------------*\ ! Tier1 encode the current tile parameter. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) start = omp_get_wtime(); #else @@ -4149,7 +4054,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) free(working_buffer); return 1; } - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) end = omp_get_wtime(); ent += end - start; @@ -4168,7 +4073,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) /*--------------------------------------------------------*\ ! Tier2 encode the current tile. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) start = omp_get_wtime(); #else @@ -4180,7 +4085,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) free(working_buffer); return 1; } - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) end = omp_get_wtime(); ent += end - start; @@ -4193,7 +4098,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) /*--------------------------------------------------------*\ ! Assemble compressed codestream. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) start = omp_get_wtime(); #else @@ -4206,7 +4111,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) free(working_buffer); return 1; } - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) end = omp_get_wtime(); ass += end - start; @@ -4224,7 +4129,7 @@ bwc_compress(bwc_field *const field, bwc_data *const data) /*--------------------------------------------------------*\ ! Output the profiling information. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) ttl = omp_get_wtime() - ttl; #else @@ -4383,7 +4288,6 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) double wav; double ent; - double ass; #endif /*-----------------------*\ @@ -4405,7 +4309,7 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) /*--------------------------------------------------------*\ ! Initialize the decompression time measurement. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) ttl = omp_get_wtime(); #else @@ -4413,7 +4317,6 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) #endif #endif - /*--------------------------------------------------------*\ ! Save the global control and info structure to temporary ! ! variables to make the code more readable. ! @@ -4499,7 +4402,7 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) /*--------------------------------------------------------*\ ! Tier1 decode the current tile parameter. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) start = omp_get_wtime(); #else @@ -4511,7 +4414,7 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) free(working_buffer); return 1; } - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) end = omp_get_wtime(); ent += end - start; @@ -4524,7 +4427,7 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) /*--------------------------------------------------------*\ ! Perform the inverse discrete wavelet transform. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) start = omp_get_wtime(); #else @@ -4536,7 +4439,7 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) free(working_buffer); return 1; } - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) end = omp_get_wtime(); wav += end - start; @@ -4550,7 +4453,7 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) ! Denormalize the working buffer scale it to the original ! ! dynamic range specified by the Qm parameter. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) start = omp_get_wtime(); #else @@ -4558,7 +4461,7 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) #endif #endif denormalize_param(field, parameter); - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) end = omp_get_wtime(); nrm += end - start; @@ -4573,7 +4476,7 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) ! in the flow field data structure for the current tile pa-! ! rameter. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) start = omp_get_wtime(); #else @@ -4581,7 +4484,7 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) #endif #endif flush_buffer(field, tile, parameter, working_buffer, data, p); - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) end = omp_get_wtime(); cpy += end - start; @@ -4607,7 +4510,7 @@ bwc_decompress(bwc_field *const field, bwc_data *const data) /*--------------------------------------------------------*\ ! Output the profiling information. ! \*--------------------------------------------------------*/ - #if defined BWC_PROFILE + #ifdef BWC_PROFILE #if defined (_OPENMP) ttl = omp_get_wtime() - ttl; #else diff --git a/src/library/tier1.c b/src/library/tier1.c index fce996e..d4bd47e 100755 --- a/src/library/tier1.c +++ b/src/library/tier1.c @@ -2977,7 +2977,7 @@ t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par } } - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp parallel private(working_buffer, codeblock, cblk_info, cbSizeX, cbSizeY, cbSizeZ, cbSizeTS) reduction(max:slope_max) reduction(min:slope_min) #endif { @@ -2995,7 +2995,7 @@ t1_encode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par ! Loop through and encode all codeblocks for the current ! ! parameter. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp for #endif for(c = 0; c < parameter->control.number_of_codeblocks; ++c) @@ -3270,7 +3270,7 @@ t1_decode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par } } - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp parallel private(working_buffer, codeblock, cblk_info, subb_ctrl,\ cbSizeX, cbSizeY, cbSizeZ, cbSizeTS) #endif @@ -3289,7 +3289,7 @@ t1_decode(bwc_field *const field, bwc_tile *const tile, bwc_parameter *const par ! Loop through and encode all codeblocks for the current ! ! parameter. ! \*--------------------------------------------------------*/ - #if defined(_OPENMP) + #if defined (_OPENMP) #pragma omp for #endif for(c = 0; c < parameter->control.number_of_codeblocks; ++c) diff --git a/src/library/tier2.c b/src/library/tier2.c index 138affd..14537b8 100755 --- a/src/library/tier2.c +++ b/src/library/tier2.c @@ -1154,7 +1154,7 @@ create_quality_layers(bwc_field *const field, bwc_tile *const tile) ! Calculate the size of the main header, including the end ! ! of header marker segment. ! \*--------------------------------------------------------*/ - main_header_size = control->header.size + 4 + (control->nTiles * info->nPar * 2 * PREC_BYTE); + main_header_size = control->headerSize; /*--------------------------------------------------------*\ ! Calculate the size of the present tile and the overall ! diff --git a/src/tools/bwccmdl.c b/src/tools/bwccmdl.c index 05ebab9..0749c24 100644 --- a/src/tools/bwccmdl.c +++ b/src/tools/bwccmdl.c @@ -1503,7 +1503,6 @@ output_info(bwc_cmdl_arg_node *const args, bwc_gl_ctrl *control; bwc_gl_inf *info; - bwc_param_ctrl *param_ctrl; bwc_param_inf *param_info; bwc_cmdl_arg_node *temp; @@ -1801,7 +1800,6 @@ output_info(bwc_cmdl_arg_node *const args, for(p = 0; p < info->nPar; ++p) { - param_ctrl = &field->tile[0].parameter[p].control; param_info = &field->tile[0].parameter[p].info; minVal = param_info->parameter_min; @@ -2653,24 +2651,15 @@ main(int argc, /*-----------------------*\ ! DEFINE INT VARIABLES: ! \*-----------------------*/ - uint64_t size=0; uint64_t i; uint8_t error_handle; /*-----------------------*\ ! DEFINE CHAR VARIABLES: ! \*-----------------------*/ - char *csSize = NULL; - char *fdSize = NULL; char buff[200]; char rate[10]; - /*-----------------------*\ - ! DEFINE FLOAT VARIABLES: ! - \*-----------------------*/ - double comp_ratio; - double bpd; - /*-----------------------*\ ! DEFINE STRUCTS: ! \*-----------------------*/ @@ -2679,11 +2668,9 @@ main(int argc, bwc_gl_ctrl *control; - bwc_dwt_filter filter[4]; + //bwc_dwt_filter filter[4]; bwc_cmdl_arg_node *args, *temp; - bwc_cmd_opts_ll *param; - /*--------------------------------------------------------*\ ! Initialize the field and args structures for proper er- ! ! ror handling, as well as the error handle itself. ! @@ -2951,11 +2938,11 @@ main(int argc, printf("----------------- Compression Parameters -----------------\n\n"); if((control->CSsgc &0x200) != 0) { - printf(" Number of Tiles: %27d\n", control->nTiles); + printf(" Number of Tiles: %27ld\n", control->nTiles); printf(" - Samples in 1.D: %27ld\n", control->tileSizeX); printf(" - Samples in 2.D: %27ld\n", control->tileSizeY); printf(" - Samples in 3.D: %27ld\n", control->tileSizeZ); - printf(" - Timesteps: %27d\n", control->tileSizeTS); + printf(" - Timesteps: %27ld\n", control->tileSizeTS); printf(" ..........................................................\n"); printf("\n"); }