diff options
author | Mathis Rosenhauer <rosenhauer@dkrz.de> | 2012-10-04 17:23:30 +0200 |
---|---|---|
committer | Thomas Jahns <jahns@dkrz.de> | 2013-02-19 11:33:00 +0100 |
commit | 72f362415e517f5b796502128c1c8f9b1f0d7208 (patch) | |
tree | b5304d0883b5a8800e25f3e6c60a19db7bcf9036 | |
parent | b63f830b39d9d6f344bc36eedf0d46d046227474 (diff) | |
download | libaec-72f362415e517f5b796502128c1c8f9b1f0d7208.tar.gz libaec-72f362415e517f5b796502128c1c8f9b1f0d7208.tar.bz2 libaec-72f362415e517f5b796502128c1c8f9b1f0d7208.zip |
Improve compatibility with HDF5 - all checks passed
-rw-r--r-- | src/libaec.h | 15 | ||||
-rw-r--r-- | src/sz_compat.c | 27 | ||||
-rw-r--r-- | src/szlib.h | 18 |
3 files changed, 46 insertions, 14 deletions
diff --git a/src/libaec.h b/src/libaec.h index 1587857..91c8485 100644 --- a/src/libaec.h +++ b/src/libaec.h @@ -30,19 +30,18 @@ struct aec_stream { }; /* Sample data description flags */ -#define AEC_DATA_UNSIGNED 0 /* Samples are unsigned integers (default) */ -#define AEC_DATA_SIGNED 1 /* Samples are signed. Telling libaec +#define AEC_DATA_SIGNED 1 /* Samples are signed. Telling libaec * this results in a slightly better - * compression ratio. + * compression ratio. Default is + * unsigned. */ -#define AEC_DATA_3BYTE 2 /* 24 bit samples are coded in 3 bytes */ -#define AEC_DATA_MSB 16 /* Samples are stored with their most +#define AEC_DATA_3BYTE 2 /* 24 bit samples are coded in 3 bytes */ +#define AEC_DATA_MSB 4 /* Samples are stored with their most * significant bit first. This has * nothing to do with the endianness - * of the host. + * of the host. Default is LSB. */ -#define AEC_DATA_LSB 0 /* Samples are stored LSB first (default) */ -#define AEC_DATA_PREPROCESS 32 /* Set if preprocessor should be used */ +#define AEC_DATA_PREPROCESS 8 /* Set if preprocessor should be used */ /* Return codes of library functions */ #define AEC_OK 0 diff --git a/src/sz_compat.c b/src/sz_compat.c index 7e32ea2..b61818a 100644 --- a/src/sz_compat.c +++ b/src/sz_compat.c @@ -3,6 +3,24 @@ #include "szlib.h" #include "libaec.h" +#define NOPTS 129 + +static int convert_options(int sz_opts) +{ + int co[NOPTS]; + int i; + int opts = 0; + + memset(co, 0, sizeof(int) * NOPTS); + co[SZ_MSB_OPTION_MASK] = AEC_DATA_MSB; + co[SZ_NN_OPTION_MASK] = AEC_DATA_PREPROCESS; + + for (i = 1; i < NOPTS; i <<= 1) + opts |= co[i]; + + return opts; +} + int SZ_BufftoBuffCompress(void *dest, size_t *destLen, const void *source, size_t sourceLen, SZ_com_t *param) @@ -13,7 +31,7 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen, strm.bit_per_sample = param->bits_per_pixel; strm.block_size = param->pixels_per_block; strm.rsi = param->pixels_per_scanline / param->pixels_per_block; - strm.flags = param->options_mask; + strm.flags = convert_options(param->options_mask); strm.avail_in = sourceLen; strm.avail_out = *destLen; strm.next_out = dest; @@ -37,7 +55,7 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen, strm.bit_per_sample = param->bits_per_pixel; strm.block_size = param->pixels_per_block; strm.rsi = param->pixels_per_scanline / param->pixels_per_block; - strm.flags = param->options_mask; + strm.flags = convert_options(param->options_mask); strm.avail_in = sourceLen; strm.avail_out = *destLen; strm.next_out = dest; @@ -50,3 +68,8 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen, *destLen = strm.total_out; return SZ_OK; } + +int SZ_encoder_enabled(void) +{ + return 1; +} diff --git a/src/szlib.h b/src/szlib.h index 5ce9e65..4ad55cf 100644 --- a/src/szlib.h +++ b/src/szlib.h @@ -3,16 +3,24 @@ #include "libaec.h" +#define SZ_ALLOW_K13_OPTION_MASK 1 +#define SZ_CHIP_OPTION_MASK 2 +#define SZ_EC_OPTION_MASK 4 +#define SZ_LSB_OPTION_MASK 8 +#define SZ_MSB_OPTION_MASK 16 +#define SZ_NN_OPTION_MASK 32 +#define SZ_RAW_OPTION_MASK 128 + #define SZ_OK AEC_OK #define SZ_NO_ENCODER_ERROR -1 #define SZ_PARAM_ERROR AEC_CONF_ERROR #define SZ_MEM_ERROR AEC_MEM_ERROR #define SZ_OUTBUFF_FULL -2 -#define SZ_RAW_OPTION_MASK 128 -#define SZ_NN_OPTION_MASK AEC_DATA_PREPROCESS -#define SZ_LSB_OPTION_MASK AEC_DATA_LSB -#define SZ_MSB_OPTION_MASK AEC_DATA_MSB +#define SZ_MAX_PIXELS_PER_BLOCK 32 +#define SZ_MAX_BLOCKS_PER_SCANLINE 128 +#define SZ_MAX_PIXELS_PER_SCANLINE \ + (SZ_MAX_BLOCKS_PER_SCANLINE) * (SZ_MAX_PIXELS_PER_BLOCK) typedef struct SZ_com_t_s { @@ -29,4 +37,6 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen, const void *source, size_t sourceLen, SZ_com_t *param); +int SZ_encoder_enabled(void); + #endif /* SZLIB_H */ |