From 43dc27014b8cb39307c2924d4ab06f17c6b1a7a0 Mon Sep 17 00:00:00 2001 From: Gregor Weiss Date: Thu, 17 Oct 2024 15:16:19 +0200 Subject: [PATCH] initial test compression with new api; working eas3 reader --- src/tools/bwccmdl.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/tools/bwccmdl.c b/src/tools/bwccmdl.c index f59e5b4..a9c9a69 100644 --- a/src/tools/bwccmdl.c +++ b/src/tools/bwccmdl.c @@ -52,6 +52,10 @@ #include #include +#include "eas3.h" +#include "bwc.h" +#include "bwccmdl.h" + /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*\ || _ _ ____ ____ ____ ____ ____ || || |\/| |__| | |__/ | | [__ || @@ -631,11 +635,65 @@ static struct argp argp = {options, parse_opt, 0, doc}; int main(int argc, char *argv[]) { int i = 0; + int size = 0; /*-----------------------*\ ! DEFINE STRUCTS: ! \*-----------------------*/ cli_arguments arguments = {0}; + eas3_data *data; + uchar *input; + uchar *output; + + data = read_eas3("TGV_125.eas"); + + printf("I read eas3. No guarantees. Check validity. Compression will start now ...\n"); + + size = data->params.ndim1 * data->params.ndim2 * + data->params.ndim3 * data->params.nts * + data->params.npar; + + bwc_precision precision; + if (data->params.accuracy == 1) + { + precision = bwc_precision_single; + input = (uchar*)data->field.f; + output = calloc(size, sizeof(float)); + } + else if (data->params.accuracy == 2) + { + precision = bwc_precision_double; + input = (uchar*)data->field.d; + output = calloc(size, sizeof(double)); + } + + bwc_mode mode = comp; + bwc_stream* stream = bwc_init_stream(input, output, comp); + bwc_codec* coder = bwc_alloc_coder(data->params.ndim1, + data->params.ndim2, + data->params.ndim3, + data->params.nts, + data->params.npar, + precision); + // TODO: implement setters for codeblocks, decomposition etc. + //bwc_set_qm(coder, 32); + char rate[10]; // TODO: replace with cmdl argument + sprintf(rate, "%05.3f", 4.0); + rate[strlen(rate)-1] = '0'; + printf("rate %s \n", rate); + + bwc_create_compression(coder, stream, rate); + bwc_compress(coder, stream); + bwc_free_codec(coder); + + // TODO: implement I/O of bwc file + // TODO: bwc_header_info + + //write_eas3(data, "output2.eas"); + + eas3_free_data(data); + free(output); + /*--------------------------------------------------------*\ ! Initialize the arguments structure. ! \*--------------------------------------------------------*/