diff options
author | Mathis Rosenhauer <rosenhauer@dkrz.de> | 2015-02-04 09:39:05 +0100 |
---|---|---|
committer | Mathis Rosenhauer <rosenhauer@dkrz.de> | 2015-02-04 09:39:05 +0100 |
commit | d4d3a273150318ef9fa182d3dbc459aba561c6f0 (patch) | |
tree | 3b0ed29494595dbc4c38fad7905edea0e09e1ec1 | |
parent | 6c0595c86592343963d8acca7536616f8a809e2b (diff) | |
download | libaec-d4d3a273150318ef9fa182d3dbc459aba561c6f0.tar.gz libaec-d4d3a273150318ef9fa182d3dbc459aba561c6f0.tar.bz2 libaec-d4d3a273150318ef9fa182d3dbc459aba561c6f0.zip |
Allow nonconforming block sizes in SZ mode.
-rw-r--r-- | src/encode.c | 17 | ||||
-rw-r--r-- | src/libaec.h | 3 | ||||
-rw-r--r-- | src/sz_compat.c | 6 |
3 files changed, 18 insertions, 8 deletions
diff --git a/src/encode.c b/src/encode.c index 1c36008..b6b5e26 100644 --- a/src/encode.c +++ b/src/encode.c @@ -775,11 +775,18 @@ int aec_encode_init(struct aec_stream *strm) if (strm->bits_per_sample > 32 || strm->bits_per_sample == 0) return AEC_CONF_ERROR; - if (strm->block_size != 8 - && strm->block_size != 16 - && strm->block_size != 32 - && strm->block_size != 64) - return AEC_CONF_ERROR; + if (strm->flags & AEC_NOT_ENFORCE) { + /* All even block sizes are allowed. */ + if (strm->block_size & 1) + return AEC_CONF_ERROR; + } else { + /* Only allow standard conforming block sizes */ + if (strm->block_size != 8 + && strm->block_size != 16 + && strm->block_size != 32 + && strm->block_size != 64) + return AEC_CONF_ERROR; + } if (strm->rsi > 4096) return AEC_CONF_ERROR; diff --git a/src/libaec.h b/src/libaec.h index dd90ba4..e1ba30c 100644 --- a/src/libaec.h +++ b/src/libaec.h @@ -120,6 +120,9 @@ struct aec_stream { /* Pad RSI to byte boundary. Only for decoding CCSDS sample data. */ #define AEC_PAD_RSI 32 +/* Do not enforce standard regarding legal block sizes. */ +#define AEC_NOT_ENFORCE 64 + /*************************************/ /* Return codes of library functions */ /*************************************/ diff --git a/src/sz_compat.c b/src/sz_compat.c index 10f9232..0f7a4c7 100644 --- a/src/sz_compat.c +++ b/src/sz_compat.c @@ -70,8 +70,8 @@ static void deinterleave_buffer(void *dest, const void *src, } static void add_padding(void *dest, const void *src, size_t total, - size_t line_size, size_t padding_size, - int pixel_size, int pp) + size_t line_size, size_t padding_size, + int pixel_size, int pp) { size_t i, j, k, ls, ps; const char *pixel; @@ -127,7 +127,7 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen, strm.block_size = param->pixels_per_block; strm.rsi = (param->pixels_per_scanline + param->pixels_per_block - 1) / param->pixels_per_block; - strm.flags = convert_options(param->options_mask); + strm.flags = AEC_NOT_ENFORCE | convert_options(param->options_mask); strm.avail_out = *destLen; strm.next_out = dest; buf = 0; |