initial test compression with new api; working eas3 reader
This commit is contained in:
parent
49a9cf3d63
commit
43dc27014b
1 changed files with 58 additions and 0 deletions
|
@ -52,6 +52,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#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 main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
int size = 0;
|
||||||
/*-----------------------*\
|
/*-----------------------*\
|
||||||
! DEFINE STRUCTS: !
|
! DEFINE STRUCTS: !
|
||||||
\*-----------------------*/
|
\*-----------------------*/
|
||||||
cli_arguments arguments = {0};
|
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. !
|
! Initialize the arguments structure. !
|
||||||
\*--------------------------------------------------------*/
|
\*--------------------------------------------------------*/
|
||||||
|
|
Loading…
Reference in a new issue