summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathis Rosenhauer <rosenhauer@dkrz.de>2014-08-01 13:51:04 +0200
committerMathis Rosenhauer <rosenhauer@dkrz.de>2014-08-01 15:16:51 +0200
commit6f2ffa1769746b622c4860d2491b0f7ff3407259 (patch)
tree73e8a136791ab6eef469cca33ae6ee1eaf5ccc1f /src
parent8e055aaa334e5d41828932bc898e0cb42870b6af (diff)
downloadlibaec-6f2ffa1769746b622c4860d2491b0f7ff3407259.tar.gz
libaec-6f2ffa1769746b622c4860d2491b0f7ff3407259.tar.bz2
libaec-6f2ffa1769746b622c4860d2491b0f7ff3407259.zip
More explicit casting to shup up VS.
Diffstat (limited to 'src')
-rw-r--r--src/decode.c64
-rw-r--r--src/decode.h85
-rw-r--r--src/encode.c126
-rw-r--r--src/encode.h104
-rw-r--r--src/libaec.h123
-rw-r--r--src/sz_compat.c6
6 files changed, 307 insertions, 201 deletions
diff --git a/src/decode.c b/src/decode.c
index ecd027d..eea6542 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -86,7 +86,7 @@
/* Reference samples have to be sign extended */ \
state->last_out = (state->last_out ^ m) - m; \
} \
- put_##KIND(strm, state->last_out); \
+ put_##KIND(strm, (uint32_t)state->last_out); \
state->flush_start++; \
} \
\
@@ -122,7 +122,7 @@
data = xmax - d; \
} \
} \
- put_##KIND(strm, data); \
+ put_##KIND(strm, (uint32_t)data); \
} \
state->last_out = data; \
} else { \
@@ -135,49 +135,49 @@
static inline void put_msb_32(struct aec_stream *strm, uint32_t data)
{
- *strm->next_out++ = data >> 24;
- *strm->next_out++ = data >> 16;
- *strm->next_out++ = data >> 8;
- *strm->next_out++ = data;
+ *strm->next_out++ = (unsigned char)(data >> 24);
+ *strm->next_out++ = (unsigned char)(data >> 16);
+ *strm->next_out++ = (unsigned char)(data >> 8);
+ *strm->next_out++ = (unsigned char)data;
}
static inline void put_msb_24(struct aec_stream *strm, uint32_t data)
{
- *strm->next_out++ = data >> 16;
- *strm->next_out++ = data >> 8;
- *strm->next_out++ = data;
+ *strm->next_out++ = (unsigned char)(data >> 16);
+ *strm->next_out++ = (unsigned char)(data >> 8);
+ *strm->next_out++ = (unsigned char)data;
}
static inline void put_msb_16(struct aec_stream *strm, uint32_t data)
{
- *strm->next_out++ = data >> 8;
- *strm->next_out++ = data;
+ *strm->next_out++ = (unsigned char)(data >> 8);
+ *strm->next_out++ = (unsigned char)data;
}
static inline void put_lsb_32(struct aec_stream *strm, uint32_t data)
{
- *strm->next_out++ = data;
- *strm->next_out++ = data >> 8;
- *strm->next_out++ = data >> 16;
- *strm->next_out++ = data >> 24;
+ *strm->next_out++ = (unsigned char)data;
+ *strm->next_out++ = (unsigned char)(data >> 8);
+ *strm->next_out++ = (unsigned char)(data >> 16);
+ *strm->next_out++ = (unsigned char)(data >> 24);
}
static inline void put_lsb_24(struct aec_stream *strm, uint32_t data)
{
- *strm->next_out++ = data;
- *strm->next_out++ = data >> 8;
- *strm->next_out++ = data >> 16;
+ *strm->next_out++ = (unsigned char)data;
+ *strm->next_out++ = (unsigned char)(data >> 8);
+ *strm->next_out++ = (unsigned char)(data >> 16);
}
static inline void put_lsb_16(struct aec_stream *strm, uint32_t data)
{
- *strm->next_out++ = data;
- *strm->next_out++ = data >> 8;
+ *strm->next_out++ = (unsigned char)data;
+ *strm->next_out++ = (unsigned char)(data >> 8);
}
static inline void put_8(struct aec_stream *strm, uint32_t data)
{
- *strm->next_out++ = data;
+ *strm->next_out++ = (unsigned char)data;
}
FLUSH(msb_32)
@@ -195,7 +195,7 @@ static inline void check_rsi_end(struct aec_stream *strm)
*/
struct internal_state *state = strm->state;
- if (state->rsip - state->rsi_buffer == state->rsi_size) {
+ if (state->rsi_size == (size_t)(state->rsip - state->rsi_buffer)) {
state->flush_output(strm);
state->flush_start = state->rsi_buffer;
state->rsip = state->rsi_buffer;
@@ -237,7 +237,7 @@ static inline void fill_acc(struct aec_stream *strm)
}
-static inline uint32_t direct_get(struct aec_stream *strm, unsigned int n)
+static inline uint32_t direct_get(struct aec_stream *strm, int n)
{
/**
Get n bit from input stream
@@ -264,8 +264,10 @@ static inline uint32_t direct_get_fs(struct aec_stream *strm)
*/
uint32_t fs = 0;
-#if HAVE_DECL___BUILTIN_CLZLL||HAVE_BSR64
- uint32_t lz;
+#if HAVE_DECL___BUILTIN_CLZLL
+ int lz;
+#elif HAVE_BSR64
+ unsigned long lz;
#endif
struct internal_state *state = strm->state;
@@ -413,7 +415,7 @@ static int m_split_fs(struct aec_stream *strm)
static int m_split(struct aec_stream *strm)
{
- int i, k;
+ uint32_t i, k;
struct internal_state *state = strm->state;
if (BUFFERSPACE(strm)) {
@@ -464,7 +466,7 @@ static int m_zero_output(struct aec_stream *strm)
static int m_zero_block(struct aec_stream *strm)
{
- int i, zero_blocks, b, zero_bytes;
+ uint32_t i, zero_blocks, b, zero_bytes;
struct internal_state *state = strm->state;
if (fs_ask(strm) == 0)
@@ -473,7 +475,7 @@ static int m_zero_block(struct aec_stream *strm)
fs_drop(strm);
if (zero_blocks == ROS) {
- b = (state->rsip - state->rsi_buffer) / strm->block_size;
+ b = (int)(state->rsip - state->rsi_buffer) / strm->block_size;
zero_blocks = MIN(strm->rsi - b, 64 - (b % 64));
} else if (zero_blocks > ROS) {
zero_blocks--;
@@ -535,7 +537,7 @@ static int m_se_decode(struct aec_stream *strm)
static int m_se(struct aec_stream *strm)
{
- int i;
+ uint32_t i;
int32_t m, d1;
struct internal_state *state = strm->state;
@@ -605,7 +607,7 @@ static int m_uncomp_copy(struct aec_stream *strm)
static int m_uncomp(struct aec_stream *strm)
{
- int i;
+ uint32_t i;
struct internal_state *state = strm->state;
if (BUFFERSPACE(strm)) {
@@ -701,7 +703,7 @@ int aec_decode_init(struct aec_stream *strm)
}
if (strm->flags & AEC_DATA_SIGNED) {
- state->xmin = -(1ULL << (strm->bits_per_sample - 1));
+ state->xmin = -(1LL << (strm->bits_per_sample - 1));
state->xmax = (1ULL << (strm->bits_per_sample - 1)) - 1;
} else {
state->xmin = 0;
diff --git a/src/decode.h b/src/decode.h
index af65bd7..9d727be 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -70,30 +70,69 @@
struct internal_state {
int (*mode)(struct aec_stream *);
- int id; /* option ID */
- int id_len; /* bit length of code option identification key */
- int (**id_table)(struct aec_stream *); /* table maps IDs to states */
+
+ /* option ID */
+ int id;
+
+ /* bit length of code option identification key */
+ int id_len;
+
+ /* table maps IDs to states */
+ int (**id_table)(struct aec_stream *);
+
void (*flush_output)(struct aec_stream *);
- int64_t last_out; /* previous output for post-processing */
- int64_t xmin; /* minimum integer for post-processing */
- int64_t xmax; /* maximum integer for post-processing */
- int in_blklen; /* length of uncompressed input block
- should be the longest possible block */
- int out_blklen; /* length of output block in bytes */
- int n, i; /* counter for samples */
- uint64_t acc; /* accumulator for currently used bit sequence */
- int bitp; /* bit pointer to the next unused bit in
- accumulator */
- int fs; /* last fundamental sequence in accumulator */
- int ref; /* 1 if current block has reference sample */
- int pp; /* 1 if postprocessor has to be used */
- int bytes_per_sample; /* storage size of samples in bytes */
- uint32_t *rsi_buffer; /* output buffer holding one reference
- sample interval */
- uint32_t *rsip; /* current position of output in rsi_buffer */
- size_t rsi_size; /* rsi in bytes */
- uint32_t *flush_start; /* first not yet flushed byte in rsi_buffer */
- int se_table[182]; /* table for decoding second extension option */
+
+ /* previous output for post-processing */
+ int64_t last_out;
+
+ /* minimum integer for post-processing */
+ int64_t xmin;
+
+ /* maximum integer for post-processing */
+ int64_t xmax;
+
+ /* length of uncompressed input block should be the longest
+ possible block */
+ uint32_t in_blklen;
+
+ /* length of output block in bytes */
+ uint32_t out_blklen;
+
+ /* counter for samples */
+ uint32_t n, i;
+
+ /* accumulator for currently used bit sequence */
+ uint64_t acc;
+
+ /* bit pointer to the next unused bit in accumulator */
+ int bitp;
+
+ /* last fundamental sequence in accumulator */
+ int fs;
+
+ /* 1 if current block has reference sample */
+ int ref;
+
+ /* 1 if postprocessor has to be used */
+ int pp;
+
+ /* storage size of samples in bytes */
+ uint32_t bytes_per_sample;
+
+ /* output buffer holding one reference sample interval */
+ uint32_t *rsi_buffer;
+
+ /* current position of output in rsi_buffer */
+ uint32_t *rsip;
+
+ /* rsi in bytes */
+ size_t rsi_size;
+
+ /* first not yet flushed byte in rsi_buffer */
+ uint32_t *flush_start;
+
+ /* table for decoding second extension option */
+ int se_table[182];
} decode_state;
#endif /* DECODE_H */
diff --git a/src/encode.c b/src/encode.c
index 71a638c..502c74e 100644
--- a/src/encode.c
+++ b/src/encode.c
@@ -70,18 +70,18 @@ static inline void emit(struct internal_state *state,
if (bits <= state->bits) {
state->bits -= bits;
- *state->cds += data << state->bits;
+ *state->cds += (uint8_t)(data << state->bits);
} else {
bits -= state->bits;
- *state->cds++ += (uint64_t)data >> bits;
+ *state->cds++ += (uint8_t)((uint64_t)data >> bits);
while (bits > 8) {
bits -= 8;
- *state->cds++ = data >> bits;
+ *state->cds++ = (uint8_t)(data >> bits);
}
state->bits = 8 - bits;
- *state->cds = data << state->bits;
+ *state->cds = (uint8_t)(data << state->bits);
}
}
@@ -108,20 +108,20 @@ static inline void emitfs(struct internal_state *state, int fs)
static inline void copy64(uint8_t *dst, uint64_t src)
{
- dst[0] = src >> 56;
- dst[1] = src >> 48;
- dst[2] = src >> 40;
- dst[3] = src >> 32;
- dst[4] = src >> 24;
- dst[5] = src >> 16;
- dst[6] = src >> 8;
- dst[7] = src;
+ dst[0] = (uint8_t)(src >> 56);
+ dst[1] = (uint8_t)(src >> 48);
+ dst[2] = (uint8_t)(src >> 40);
+ dst[3] = (uint8_t)(src >> 32);
+ dst[4] = (uint8_t)(src >> 24);
+ dst[5] = (uint8_t)(src >> 16);
+ dst[6] = (uint8_t)(src >> 8);
+ dst[7] = (uint8_t)src;
}
static inline void emitblock_fs(struct aec_stream *strm, int k, int ref)
{
- int i;
- int used; /* used bits in 64 bit accumulator */
+ uint32_t i;
+ uint32_t used; /* used bits in 64 bit accumulator */
uint64_t acc; /* accumulator */
struct internal_state *state = strm->state;
@@ -171,57 +171,57 @@ static inline void emitblock(struct aec_stream *strm, int k, int ref)
switch (p & ~7) {
case 0:
- o[0] = a >> 56;
- o[1] = a >> 48;
- o[2] = a >> 40;
- o[3] = a >> 32;
- o[4] = a >> 24;
- o[5] = a >> 16;
- o[6] = a >> 8;
+ o[0] = (uint8_t)(a >> 56);
+ o[1] = (uint8_t)(a >> 48);
+ o[2] = (uint8_t)(a >> 40);
+ o[3] = (uint8_t)(a >> 32);
+ o[4] = (uint8_t)(a >> 24);
+ o[5] = (uint8_t)(a >> 16);
+ o[6] = (uint8_t)(a >> 8);
o += 7;
break;
case 8:
- o[0] = a >> 56;
- o[1] = a >> 48;
- o[2] = a >> 40;
- o[3] = a >> 32;
- o[4] = a >> 24;
- o[5] = a >> 16;
+ o[0] = (uint8_t)(a >> 56);
+ o[1] = (uint8_t)(a >> 48);
+ o[2] = (uint8_t)(a >> 40);
+ o[3] = (uint8_t)(a >> 32);
+ o[4] = (uint8_t)(a >> 24);
+ o[5] = (uint8_t)(a >> 16);
a >>= 8;
o += 6;
break;
case 16:
- o[0] = a >> 56;
- o[1] = a >> 48;
- o[2] = a >> 40;
- o[3] = a >> 32;
- o[4] = a >> 24;
+ o[0] = (uint8_t)(a >> 56);
+ o[1] = (uint8_t)(a >> 48);
+ o[2] = (uint8_t)(a >> 40);
+ o[3] = (uint8_t)(a >> 32);
+ o[4] = (uint8_t)(a >> 24);
a >>= 16;
o += 5;
break;
case 24:
- o[0] = a >> 56;
- o[1] = a >> 48;
- o[2] = a >> 40;
- o[3] = a >> 32;
+ o[0] = (uint8_t)(a >> 56);
+ o[1] = (uint8_t)(a >> 48);
+ o[2] = (uint8_t)(a >> 40);
+ o[3] = (uint8_t)(a >> 32);
a >>= 24;
o += 4;
break;
case 32:
- o[0] = a >> 56;
- o[1] = a >> 48;
- o[2] = a >> 40;
+ o[0] = (uint8_t)(a >> 56);
+ o[1] = (uint8_t)(a >> 48);
+ o[2] = (uint8_t)(a >> 40);
a >>= 32;
o += 3;
break;
case 40:
- o[0] = a >> 56;
- o[1] = a >> 48;
+ o[0] = (uint8_t)(a >> 56);
+ o[1] = (uint8_t)(a >> 48);
a >>= 40;
o += 2;
break;
case 48:
- *o++ = a >> 56;
+ *o++ = (uint8_t)(a >> 56);
a >>= 48;
break;
default:
@@ -230,7 +230,7 @@ static inline void emitblock(struct aec_stream *strm, int k, int ref)
}
}
- *o = a;
+ *o = (uint8_t)a;
state->cds = o;
state->bits = p % 8;
}
@@ -248,9 +248,9 @@ static void preprocess_unsigned(struct aec_stream *strm)
struct internal_state *state = strm->state;
const uint32_t *restrict x = state->data_raw;
uint32_t *restrict d = state->data_pp;
- uint32_t xmax = state->xmax;
+ uint32_t xmax = (uint32_t)state->xmax;
uint32_t rsi = strm->rsi * strm->block_size - 1;
- int i;
+ unsigned int i;
d[0] = x[0];
for (i = 0; i < rsi; i++) {
@@ -282,11 +282,11 @@ static void preprocess_signed(struct aec_stream *strm)
struct internal_state *state = strm->state;
uint32_t *restrict d = state->data_pp;
int32_t *restrict x = (int32_t *)state->data_raw;
- uint64_t m = 1ULL << (strm->bits_per_sample - 1);
+ uint32_t m = 1ULL << (strm->bits_per_sample - 1);
int64_t xmax = state->xmax;
int64_t xmin = state->xmin;
uint32_t rsi = strm->rsi * strm->block_size - 1;
- int i;
+ unsigned int i;
d[0] = (uint32_t)x[0];
x[0] = (x[0] ^ m) - m;
@@ -296,15 +296,15 @@ static void preprocess_signed(struct aec_stream *strm)
if (x[i + 1] < x[i]) {
D = (int64_t)x[i] - x[i + 1];
if (D <= xmax - x[i])
- d[i + 1] = 2 * D - 1;
+ d[i + 1] = 2 * (uint32_t)D - 1;
else
- d[i + 1] = xmax - x[i + 1];
+ d[i + 1] = (uint32_t)xmax - x[i + 1];
} else {
D = (int64_t)x[i + 1] - x[i];
if (D <= x[i] - xmin)
- d[i + 1] = 2 * D;
+ d[i + 1] = 2 * (uint32_t)D;
else
- d[i + 1] = x[i + 1] - xmin;
+ d[i + 1] = x[i + 1] - (uint32_t)xmin;
}
}
state->ref = 1;
@@ -317,7 +317,7 @@ static inline uint64_t block_fs(struct aec_stream *strm, int k)
Sum FS of all samples in block for given splitting position.
*/
- int i;
+ uint32_t i;
uint64_t fs = 0;
struct internal_state *state = strm->state;
@@ -410,7 +410,7 @@ static uint32_t assess_splitting_option(struct aec_stream *strm)
}
state->k = k_min;
- return len_min;
+ return (uint32_t)len_min;
}
static uint32_t assess_se_option(struct aec_stream *strm)
@@ -421,9 +421,9 @@ static uint32_t assess_se_option(struct aec_stream *strm)
If length is above limit just return UINT32_MAX.
*/
- int i;
- uint64_t d;
+ uint32_t i;
uint32_t len;
+ uint64_t d;
struct internal_state *state = strm->state;
len = 1;
@@ -439,7 +439,8 @@ static uint32_t assess_se_option(struct aec_stream *strm)
len = UINT32_MAX;
break;
} else {
- len += d * (d + 1) / 2 + state->block[i + 1] + 1;
+ len += (uint32_t)d * ((uint32_t)d + 1)
+ / 2 + state->block[i + 1] + 1;
}
}
return len;
@@ -483,7 +484,8 @@ static int m_flush_block_resumable(struct aec_stream *strm)
*/
struct internal_state *state = strm->state;
- int n = MIN(state->cds - state->cds_buf - state->i, strm->avail_out);
+ int n = (int)MIN((size_t)(state->cds - state->cds_buf - state->i),
+ strm->avail_out);
memcpy(strm->next_out, state->cds_buf + state->i, n);
strm->next_out += n;
strm->avail_out -= n;
@@ -516,7 +518,7 @@ static int m_flush_block(struct aec_stream *strm)
#endif
if (state->direct_out) {
- n = state->cds - strm->next_out;
+ n = (int)(state->cds - strm->next_out);
strm->next_out += n;
strm->avail_out -= n;
state->mode = m_get_block;
@@ -555,7 +557,7 @@ static int m_encode_uncomp(struct aec_stream *strm)
static int m_encode_se(struct aec_stream *strm)
{
- int i;
+ uint32_t i;
uint32_t d;
struct internal_state *state = strm->state;
@@ -631,7 +633,7 @@ static int m_check_zero_block(struct aec_stream *strm)
end of a segment or RSI.
*/
- int i;
+ uint32_t i;
struct internal_state *state = strm->state;
uint32_t *p = state->block;
@@ -861,7 +863,7 @@ int aec_encode_init(struct aec_stream *strm)
state->rsi_len = strm->rsi * strm->block_size * state->bytes_per_sample;
if (strm->flags & AEC_DATA_SIGNED) {
- state->xmin = -(1ULL << (strm->bits_per_sample - 1));
+ state->xmin = -(1LL << (strm->bits_per_sample - 1));
state->xmax = (1ULL << (strm->bits_per_sample - 1)) - 1;
state->preprocess = preprocess_signed;
} else {
@@ -922,7 +924,7 @@ int aec_encode(struct aec_stream *strm, int flush)
while (state->mode(strm) == M_CONTINUE);
if (state->direct_out) {
- n = state->cds - strm->next_out;
+ n = (int)(state->cds - strm->next_out);
strm->next_out += n;
strm->avail_out -= n;
diff --git a/src/encode.h b/src/encode.h
index 69fa05b..4070689 100644
--- a/src/encode.h
+++ b/src/encode.h
@@ -79,37 +79,79 @@ struct internal_state {
void (*get_rsi)(struct aec_stream *);
void (*preprocess)(struct aec_stream *);
- int id_len; /* bit length of code option identification key */
- int64_t xmin; /* minimum integer for preprocessing */
- int64_t xmax; /* maximum integer for preprocessing */
- int i; /* counter */
- uint32_t *data_pp; /* RSI blocks of preprocessed input */
- uint32_t *data_raw; /* RSI blocks of input */
- int blocks_avail; /* remaining blocks in buffer */
- uint32_t *block; /* current (preprocessed) input block */
- int rsi_len; /* reference sample interval in byte */
- uint8_t *cds; /* current Coded Data Set output */
- uint8_t cds_buf[CDSLEN];/* buffer for one CDS (only used if
- * strm->next_out cannot hold full CDS) */
- int direct_out; /* cds points to strm->next_out (1)
- * or cds_buf (0) */
- int bits; /* Free bits (LSB) in output buffer or
- * accumulator */
- int ref; /* length of reference sample in current
- * block i.e. 0 or 1 depending on whether
- * the block has a reference sample or
- * not */
- int zero_ref; /* current zero block has a reference sample */
- uint32_t zero_ref_sample;/* reference sample of zero block */
- int bytes_per_sample; /* storage size of samples in bytes */
- int zero_blocks; /* number of contiguous zero blocks */
- int block_nonzero; /* 1 if this is the first non-zero block
- * after one or more zero blocks */
- int k; /* splitting position */
- int kmax; /* maximum number for k depending on id_len */
- int flush; /* flush option copied from argument */
- int flushed; /* 1 if flushing was successful */
- uint32_t uncomp_len; /* length of uncompressed CDS */
+ /* bit length of code option identification key */
+ int id_len;
+
+ /* minimum integer for preprocessing */
+ int64_t xmin;
+
+ /* maximum integer for preprocessing */
+ int64_t xmax;
+
+ uint32_t i;
+
+ /* RSI blocks of preprocessed input */
+ uint32_t *data_pp;
+
+ /* RSI blocks of input */
+ uint32_t *data_raw;
+
+ /* remaining blocks in buffer */
+ int blocks_avail;
+
+ /* current (preprocessed) input block */
+ uint32_t *block;
+
+ /* reference sample interval in byte */
+ uint32_t rsi_len;
+
+ /* current Coded Data Set output */
+ uint8_t *cds;
+
+ /* buffer for one CDS (only used if strm->next_out cannot hold
+ * full CDS) */
+ uint8_t cds_buf[CDSLEN];
+
+ /* cds points to strm->next_out (1) or cds_buf (0) */
+ int direct_out;
+
+ /* Free bits (LSB) in output buffer or accumulator */
+ int bits;
+
+ /* length of reference sample in current block i.e. 0 or 1
+ * depending on whether the block has a reference sample or not */
+ int ref;
+
+ /* current zero block has a reference sample */
+ int zero_ref;
+
+ /* reference sample of zero block */
+ uint32_t zero_ref_sample;
+
+ /* storage size of samples in bytes */
+ uint32_t bytes_per_sample;
+
+ /* number of contiguous zero blocks */
+ int zero_blocks;
+
+ /* 1 if this is the first non-zero block after one or more zero
+ * blocks */
+ int block_nonzero;
+
+ /* splitting position */
+ int k;
+
+ /* maximum number for k depending on id_len */
+ int kmax;
+
+ /* flush option copied from argument */
+ int flush;
+
+ /* 1 if flushing was successful */
+ int flushed;
+
+ /* length of uncompressed CDS */
+ uint32_t uncomp_len;
};
#endif /* ENCODE_H */
diff --git a/src/libaec.h b/src/libaec.h
index 736a069..dc3d236 100644
--- a/src/libaec.h
+++ b/src/libaec.h
@@ -69,71 +69,88 @@ struct internal_state;
struct aec_stream {
const unsigned char *next_in;
- size_t avail_in; /* number of bytes available at
- * next_in
- */
- size_t total_in; /* total number of input bytes read so
- * far
- */
+
+ /* number of bytes available at next_in */
+ size_t avail_in;
+
+ /* total number of input bytes read so far */
+ size_t total_in;
+
unsigned char *next_out;
- size_t avail_out; /* remaining free space at next_out */
- size_t total_out; /* total number of bytes output so far */
- int bits_per_sample; /* resolution in bits per sample (n =
- * 1, ..., 32)
- */
- int block_size; /* block size in samples */
- int rsi; /* Reference sample interval, the
- * number of Coded Data Sets between
- * consecutive reference samples (up
- * to 4096).
- */
- int flags;
+
+ /* remaining free space at next_out */
+ size_t avail_out;
+
+ /* total number of bytes output so far */
+ size_t total_out;
+
+ /* resolution in bits per sample (n = 1, ..., 32) */
+ unsigned int bits_per_sample;
+
+ /* block size in samples */
+ unsigned int block_size;
+
+ /* Reference sample interval, the number of Coded Data Sets
+ * between consecutive reference samples (up to 4096). */
+ unsigned int rsi;
+
+ unsigned int flags;
struct internal_state *state;
};
+/*********************************/
/* Sample data description flags */
-#define AEC_DATA_SIGNED 1 /* Samples are signed. Telling libaec
- * this results in a slightly better
- * compression ratio. Default is
- * unsigned.
- */
-#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. Default is LSB.
- */
-#define AEC_DATA_PREPROCESS 8 /* Set if preprocessor should be used */
-
-#define AEC_RESTRICTED 16 /* Use restricted set of code options */
-#define AEC_PAD_RSI 32 /* Pad RSI to byte boundary. Only for
- * decoding CCSDS sample data. */
+/*********************************/
+/* Samples are signed. Telling libaec this results in a slightly
+ * better compression ratio. Default is unsigned. */
+#define AEC_DATA_SIGNED 1
+
+/* 24 bit samples are coded in 3 bytes */
+#define AEC_DATA_3BYTE 2
+
+/* Samples are stored with their most significant bit first. This has
+ * nothing to do with the endianness of the host. Default is LSB. */
+#define AEC_DATA_MSB 4
+
+/* Set if preprocessor should be used */
+#define AEC_DATA_PREPROCESS 8
+
+/* Use restricted set of code options */
+#define AEC_RESTRICTED 16
+
+/* Pad RSI to byte boundary. Only for decoding CCSDS sample data. */
+#define AEC_PAD_RSI 32
+
+/*************************************/
/* Return codes of library functions */
-#define AEC_OK 0
-#define AEC_CONF_ERROR (-1)
+/*************************************/
+#define AEC_OK 0
+#define AEC_CONF_ERROR (-1)
#define AEC_STREAM_ERROR (-2)
-#define AEC_DATA_ERROR (-3)
-#define AEC_MEM_ERROR (-4)
+#define AEC_DATA_ERROR (-3)
+#define AEC_MEM_ERROR (-4)
+/************************/
/* Options for flushing */
-#define AEC_NO_FLUSH 0 /* Do not enforce output
- * flushing. More input may be
- * provided with later calls. So far
- * only relevant for encoding.
- */
-#define AEC_FLUSH 1 /* Flush output and end encoding. The
- * last call to aec_encode() must set
- * AEC_FLUSH to drain all output.
- *
- * It is not possible to continue
- * encoding of the same stream after it
- * has been flushed because the last byte
- * may be padded with fill bits.
- */
+/************************/
+
+/* Do not enforce output flushing. More input may be provided with
+ * later calls. So far only relevant for encoding. */
+#define AEC_NO_FLUSH 0
+
+/* Flush output and end encoding. The last call to aec_encode() must
+ * set AEC_FLUSH to drain all output.
+ *
+ * It is not possible to continue encoding of the same stream after it
+ * has been flushed because the last byte may be padded with fill
+ * bits. */
+#define AEC_FLUSH 1
+/*********************************************/
/* Streaming encoding and decoding functions */
+/*********************************************/
AEC_SCOPE int aec_encode_init(struct aec_stream *strm);
AEC_SCOPE int aec_encode(struct aec_stream *strm, int flush);
AEC_SCOPE int aec_encode_end(struct aec_stream *strm);
@@ -142,7 +159,9 @@ AEC_SCOPE int aec_decode_init(struct aec_stream *strm);
AEC_SCOPE int aec_decode(struct aec_stream *strm, int flush);
AEC_SCOPE int aec_decode_end(struct aec_stream *strm);
+/***************************************************************/
/* Utility functions for encoding or decoding a memory buffer. */
+/***************************************************************/
AEC_SCOPE int aec_buffer_encode(struct aec_stream *strm);
AEC_SCOPE int aec_buffer_decode(struct aec_stream *strm);
diff --git a/src/sz_compat.c b/src/sz_compat.c
index b685c64..bfbc981 100644
--- a/src/sz_compat.c
+++ b/src/sz_compat.c
@@ -39,7 +39,8 @@ static int bits_to_bytes(int bit_length)
static void interleave_buffer(void *dest, const void *src,
size_t n, int wordsize)
{
- size_t i, j;
+ size_t i;
+ int j;
const unsigned char *src8;
unsigned char *dest8;
@@ -54,7 +55,8 @@ static void interleave_buffer(void *dest, const void *src,
static void deinterleave_buffer(void *dest, const void *src,
size_t n, int wordsize)
{
- size_t i, j;
+ size_t i;
+ int j;
const unsigned char *src8;
unsigned char *dest8;