From acf703f6502efa1ef869068af0380a1c0cdc59b1 Mon Sep 17 00:00:00 2001 From: Gregor Weiss Date: Wed, 6 Nov 2024 17:23:09 +0100 Subject: [PATCH] refactor/clean up in cmdl tool --- src/tools/bwccmdl.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/tools/bwccmdl.c b/src/tools/bwccmdl.c index 2651b2c..20a1ce9 100644 --- a/src/tools/bwccmdl.c +++ b/src/tools/bwccmdl.c @@ -1219,6 +1219,7 @@ int main(int argc, char *argv[]) data->params.nts, data->params.npar, precision); + bwc_set_aux(stream, (char*)data->aux.ptr, data->aux.len); /* Apply the user supplied compression options using the * * appropriate setter functions. */ @@ -1416,8 +1417,6 @@ int main(int argc, char *argv[]) printf("%s", cli_verbose); } - bwc_set_aux(stream, (char*)data->aux.ptr, data->aux.len); - /* Initialize the rate control string according to the * * specified bit rate/compression ratio. */ if (bwc_create_compression(coder, stream, rate) == EXIT_FAILURE) @@ -1494,14 +1493,6 @@ int main(int argc, char *argv[]) memset(cli_buffer, '0', sizeof(char) * 1024); } - if ((arguments.verbose == true) && - (delim == true)) - { - - strcat(cli_verbose, " __________________________________________________________\n"); - strcat(cli_verbose, "\n"); - } - if (arguments.verbose == true) { memset(cli_buffer, '0', sizeof(char) * 1024); @@ -1509,7 +1500,7 @@ int main(int argc, char *argv[]) printf("%s", cli_verbose); } - /* Read the codestream from the specified file. */ + /* Read the compressed data from the input file. */ input = calloc(Lfield, sizeof(uchar)); if (fread(input, sizeof(uchar), Lfield, fp) != Lfield) { @@ -1518,11 +1509,10 @@ int main(int argc, char *argv[]) goto OUT; } + /* Retrieve header information and allocate output buffer. */ header = bwc_open_header(input); - size = header->info.nX * header->info.nY * header->info.nZ * header->info.nTS * header->info.nPar; - if(header->info.data_prec == bwc_precision_double) { output = calloc(size, sizeof(double)); @@ -1531,29 +1521,20 @@ int main(int argc, char *argv[]) { output = calloc(size, sizeof(float)); } - bwc_close_header(header); + /* Initialize and run the decompression. */ stream = bwc_init_stream(input, output, comp); coder = bwc_alloc_decoder(); - - //if (arguments.verbose == true) - //{ - //memset(cli_buffer, '0', sizeof(char) * 1024); - //strcat(cli_verbose, "\n==============================================================\n"); - //printf("%s", cli_verbose); - //} - - /* Initialize the rate control string according to the * - * specified bit rate/compression ratio. */ if (bwc_create_decompression(coder, stream, 0) == EXIT_FAILURE) { error_handle = EXIT_FAILURE; goto OUT; } - bwc_decompress(coder, stream); + /* Parse decompressed data into eas3 data structure * + * and write to the output file. */ data = calloc(1, sizeof(eas3_data)); bwc_to_eas3(stream, data); write_eas3(data, cli_output);