Commit 4add047d authored by Mathis Rosenhauer's avatar Mathis Rosenhauer

Limit scope

parent 6cd141a9
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src tests
EXTRA_DIST = doc/patent.txt CMakeLists.txt cmake/config.h.in \
cmake/macros.cmake README.md README.SZIP CHANGELOG.am Copyright.txt data
cmake/macros.cmake README.md README.SZIP CHANGELOG.md Copyright.txt data
sampledata = 121B2TestData
sampledata_url = http://cwe.ccsds.org/sls/docs/SLS-DC/BB121B2TestData/$(sampledata).zip
......
This diff is collapsed.
......@@ -97,8 +97,7 @@ struct internal_state {
/* length of output block in bytes */
uint32_t out_blklen;
/* counter for samples */
uint32_t n, i;
uint32_t sample_counter;
/* accumulator for currently used bit sequence */
uint64_t acc;
......
......@@ -117,15 +117,12 @@ static inline void copy64(uint8_t *dst, uint64_t src)
static inline void emitblock_fs(struct aec_stream *strm, int k, int ref)
{
size_t i;
uint32_t used; /* used bits in 64 bit accumulator */
uint64_t acc; /* accumulator */
struct internal_state *state = strm->state;
acc = (uint64_t)*state->cds << 56;
used = 7 - state->bits;
uint64_t acc = (uint64_t)*state->cds << 56;
uint32_t used = 7 - state->bits; /* used bits in 64 bit accumulator */
for (i = ref; i < strm->block_size; i++) {
for (size_t i = ref; i < strm->block_size; i++) {
used += (state->block[i] >> k) + 1;
while (used > 63) {
copy64(state->cds, acc);
......@@ -147,16 +144,14 @@ static inline void emitblock(struct aec_stream *strm, int k, int ref)
Emit the k LSB of a whole block of input data.
*/
uint64_t a;
struct internal_state *state = strm->state;
uint32_t *in = state->block + ref;
uint32_t *in_end = state->block + strm->block_size;
uint64_t mask = (UINT64_C(1) << k) - 1;
uint8_t *o = state->cds;
uint64_t a = *o;
int p = state->bits;
a = *o;
while(in < in_end) {
a <<= 56;
p = (p % 8) + 56;
......@@ -247,12 +242,11 @@ static void preprocess_unsigned(struct aec_stream *strm)
uint32_t *restrict d = state->data_pp;
uint32_t xmax = state->xmax;
uint32_t rsi = strm->rsi * strm->block_size - 1;
size_t i;
state->ref = 1;
state->ref_sample = x[0];
d[0] = 0;
for (i = 0; i < rsi; i++) {
for (size_t i = 0; i < rsi; i++) {
if (x[i + 1] >= x[i]) {
D = x[i + 1] - x[i];
if (D <= x[i])
......@@ -284,14 +278,13 @@ static void preprocess_signed(struct aec_stream *strm)
int32_t xmin = (int32_t)state->xmin;
uint32_t rsi = strm->rsi * strm->block_size - 1;
uint32_t m = UINT64_C(1) << (strm->bits_per_sample - 1);
size_t i;
state->ref = 1;
state->ref_sample = x[0];
d[0] = 0;
x[0] = (x[0] ^ m) - m;
for (i = 0; i < rsi; i++) {
for (size_t i = 0; i < rsi; i++) {
x[i + 1] = (x[i + 1] ^ m) - m;
if (x[i + 1] < x[i]) {
D = (uint32_t)(x[i] - x[i + 1]);
......@@ -316,11 +309,10 @@ static inline uint64_t block_fs(struct aec_stream *strm, int k)
Sum FS of all samples in block for given splitting position.
*/
size_t i;
uint64_t fs = 0;
struct internal_state *state = strm->state;
uint64_t fs = 0;
for (i = 0; i < strm->block_size; i++)
for (size_t i = 0; i < strm->block_size; i++)
fs += (uint64_t)(state->block[i] >> k);
return fs;
......@@ -353,26 +345,29 @@ static uint32_t assess_splitting_option(struct aec_stream *strm)
analogue check can be done for decreasing k.
*/
int k;
int k_min;
int this_bs; /* Block size of current block */
int no_turn; /* 1 if we shouldn't reverse */
int dir; /* Direction, 1 means increasing k, 0 decreasing k */
uint64_t len; /* CDS length for current k */
uint64_t len_min; /* CDS length minimum so far */
uint64_t fs_len; /* Length of FS part (not including 1s) */
struct internal_state *state = strm->state;
this_bs = strm->block_size - state->ref;
len_min = UINT64_MAX;
k = k_min = state->k;
no_turn = k == 0;
dir = 1;
/* Block size of current block */
int this_bs = strm->block_size - state->ref;
/* CDS length minimum so far */
uint64_t len_min = UINT64_MAX;
int k = state->k;
int k_min = k;
/* 1 if we shouldn't reverse */
int no_turn = (k == 0);
/* Direction, 1 means increasing k, 0 decreasing k */
int dir = 1;
for (;;) {
fs_len = block_fs(strm, k);
len = fs_len + this_bs * (k + 1);
/* Length of FS part (not including 1s) */
uint64_t fs_len = block_fs(strm, k);
/* CDS length for current k */
uint64_t len = fs_len + this_bs * (k + 1);
if (len < len_min) {
if (len_min < UINT64_MAX)
......@@ -417,15 +412,12 @@ static uint32_t assess_se_option(struct aec_stream *strm)
If length is above limit just return UINT32_MAX.
*/
size_t i;
uint64_t len, d;
struct internal_state *state = strm->state;
uint32_t *block = state->block;
uint64_t len = 1;
len = 1;
for (i = 0; i < strm->block_size; i += 2) {
d = (uint64_t)block[i] + (uint64_t)block[i + 1];
for (size_t i = 0; i < strm->block_size; i += 2) {
uint64_t d = (uint64_t)block[i] + (uint64_t)block[i + 1];
len += d * (d + 1) / 2 + block[i + 1] + 1;
if (len > state->uncomp_len)
return UINT32_MAX;
......@@ -493,7 +485,6 @@ static int m_flush_block(struct aec_stream *strm)
Fall back to slow flushing if in buffered mode.
*/
int n;
struct internal_state *state = strm->state;
#ifdef ENABLE_RSI_PADDING
......@@ -505,7 +496,7 @@ static int m_flush_block(struct aec_stream *strm)
#endif
if (state->direct_out) {
n = (int)(state->cds - strm->next_out);
int n = (int)(state->cds - strm->next_out);
strm->next_out += n;
strm->avail_out -= n;
state->mode = m_get_block;
......@@ -546,16 +537,14 @@ static int m_encode_uncomp(struct aec_stream *strm)
static int m_encode_se(struct aec_stream *strm)
{
size_t i;
uint32_t d;
struct internal_state *state = strm->state;
emit(state, 1, state->id_len + 1);
if (state->ref)
emit(state, state->ref_sample, strm->bits_per_sample);
for (i = 0; i < strm->block_size; i+= 2) {
d = state->block[i] + state->block[i + 1];
for (size_t i = 0; i < strm->block_size; i+= 2) {
uint32_t d = state->block[i] + state->block[i + 1];
emitfs(state, d * (d + 1) / 2 + state->block[i + 1]);
}
......@@ -588,15 +577,14 @@ static int m_select_code_option(struct aec_stream *strm)
Decide which code option to use.
*/
uint32_t split_len;
uint32_t se_len;
struct internal_state *state = strm->state;
uint32_t split_len;
if (state->id_len > 1)
split_len = assess_splitting_option(strm);
else
split_len = UINT32_MAX;
se_len = assess_se_option(strm);
uint32_t se_len = assess_se_option(strm);
if (split_len < state->uncomp_len) {
if (split_len < se_len)
......@@ -620,10 +608,10 @@ static int m_check_zero_block(struct aec_stream *strm)
end of a segment or RSI.
*/
size_t i;
struct internal_state *state = strm->state;
uint32_t *p = state->block;
size_t i;
for (i = 0; i < strm->block_size; i++)
if (p[i] != 0)
break;
......@@ -912,7 +900,6 @@ int aec_encode(struct aec_stream *strm, int flush)
Finite-state machine implementation of the adaptive entropy
encoder.
*/
int n;
struct internal_state *state = strm->state;
state->flush = flush;
......@@ -922,7 +909,7 @@ int aec_encode(struct aec_stream *strm, int flush)
while (state->mode(strm) == M_CONTINUE);
if (state->direct_out) {
n = (int)(state->cds - strm->next_out);
int n = (int)(state->cds - strm->next_out);
strm->next_out += n;
strm->avail_out -= n;
......@@ -938,9 +925,8 @@ int aec_encode(struct aec_stream *strm, int flush)
int aec_encode_end(struct aec_stream *strm)
{
struct internal_state *state = strm->state;
int status;
status = AEC_OK;
int status = AEC_OK;
if (state->flush == AEC_FLUSH && state->flushed == 0)
status = AEC_STREAM_ERROR;
cleanup(strm);
......@@ -949,9 +935,7 @@ int aec_encode_end(struct aec_stream *strm)
int aec_buffer_encode(struct aec_stream *strm)
{
int status;
status = aec_encode_init(strm);
int status = aec_encode_init(strm);
if (status != AEC_OK)
return status;
status = aec_encode(strm, AEC_FLUSH);
......
......@@ -66,9 +66,7 @@ uint32_t aec_get_8(struct aec_stream *strm)
uint32_t aec_get_lsb_16(struct aec_stream *strm)
{
uint32_t data;
data = ((uint32_t)strm->next_in[1] << 8)
uint32_t data = ((uint32_t)strm->next_in[1] << 8)
| (uint32_t)strm->next_in[0];
strm->next_in += 2;
......@@ -78,9 +76,7 @@ uint32_t aec_get_lsb_16(struct aec_stream *strm)
uint32_t aec_get_msb_16(struct aec_stream *strm)
{
uint32_t data;
data = ((uint32_t)strm->next_in[0] << 8)
uint32_t data = ((uint32_t)strm->next_in[0] << 8)
| (uint32_t)strm->next_in[1];
strm->next_in += 2;
......@@ -90,9 +86,7 @@ uint32_t aec_get_msb_16(struct aec_stream *strm)
uint32_t aec_get_lsb_24(struct aec_stream *strm)
{
uint32_t data;
data = ((uint32_t)strm->next_in[2] << 16)
uint32_t data = ((uint32_t)strm->next_in[2] << 16)
| ((uint32_t)strm->next_in[1] << 8)
| (uint32_t)strm->next_in[0];
......@@ -103,9 +97,7 @@ uint32_t aec_get_lsb_24(struct aec_stream *strm)
uint32_t aec_get_msb_24(struct aec_stream *strm)
{
uint32_t data;
data = ((uint32_t)strm->next_in[0] << 16)
uint32_t data = ((uint32_t)strm->next_in[0] << 16)
| ((uint32_t)strm->next_in[1] << 8)
| (uint32_t)strm->next_in[2];
......@@ -116,9 +108,7 @@ uint32_t aec_get_msb_24(struct aec_stream *strm)
uint32_t aec_get_lsb_32(struct aec_stream *strm)
{
uint32_t data;
data = ((uint32_t)strm->next_in[3] << 24)
uint32_t data = ((uint32_t)strm->next_in[3] << 24)
| ((uint32_t)strm->next_in[2] << 16)
| ((uint32_t)strm->next_in[1] << 8)
| (uint32_t)strm->next_in[0];
......@@ -130,9 +120,7 @@ uint32_t aec_get_lsb_32(struct aec_stream *strm)
uint32_t aec_get_msb_32(struct aec_stream *strm)
{
uint32_t data;
data = ((uint32_t)strm->next_in[0] << 24)
uint32_t data = ((uint32_t)strm->next_in[0] << 24)
| ((uint32_t)strm->next_in[1] << 16)
| ((uint32_t)strm->next_in[2] << 8)
| (uint32_t)strm->next_in[3];
......@@ -144,12 +132,11 @@ uint32_t aec_get_msb_32(struct aec_stream *strm)
void aec_get_rsi_8(struct aec_stream *strm)
{
int i;
uint32_t *restrict out = strm->state->data_raw;
unsigned const char *restrict in = strm->next_in;
int rsi = strm->rsi * strm->block_size;
for (i = 0; i < rsi; i++)
for (int i = 0; i < rsi; i++)
out[i] = (uint32_t)in[i];
strm->next_in += rsi;
......@@ -158,12 +145,11 @@ void aec_get_rsi_8(struct aec_stream *strm)
void aec_get_rsi_lsb_16(struct aec_stream *strm)
{
int i;
uint32_t *restrict out = strm->state->data_raw;
const unsigned char *restrict in = strm->next_in;
int rsi = strm->rsi * strm->block_size;
for (i = 0; i < rsi; i++)
for (int i = 0; i < rsi; i++)
out[i] = (uint32_t)in[2 * i] | ((uint32_t)in[2 * i + 1] << 8);
strm->next_in += 2 * rsi;
......@@ -172,12 +158,11 @@ void aec_get_rsi_lsb_16(struct aec_stream *strm)
void aec_get_rsi_msb_16(struct aec_stream *strm)
{
int i;
uint32_t *restrict out = strm->state->data_raw;
const unsigned char *restrict in = strm->next_in;
int rsi = strm->rsi * strm->block_size;
for (i = 0; i < rsi; i++)
for (int i = 0; i < rsi; i++)
out[i] = ((uint32_t)in[2 * i] << 8) | (uint32_t)in[2 * i + 1];
strm->next_in += 2 * rsi;
......@@ -186,12 +171,11 @@ void aec_get_rsi_msb_16(struct aec_stream *strm)
void aec_get_rsi_lsb_24(struct aec_stream *strm)
{
int i;
uint32_t *restrict out = strm->state->data_raw;
const unsigned char *restrict in = strm->next_in;
int rsi = strm->rsi * strm->block_size;
for (i = 0; i < rsi; i++)
for (int i = 0; i < rsi; i++)
out[i] = (uint32_t)in[3 * i]
| ((uint32_t)in[3 * i + 1] << 8)
| ((uint32_t)in[3 * i + 2] << 16);
......@@ -202,12 +186,11 @@ void aec_get_rsi_lsb_24(struct aec_stream *strm)
void aec_get_rsi_msb_24(struct aec_stream *strm)
{
int i;
uint32_t *restrict out = strm->state->data_raw;
const unsigned char *restrict in = strm->next_in;
int rsi = strm->rsi * strm->block_size;
for (i = 0; i < rsi; i++)
for (int i = 0; i < rsi; i++)
out[i] = ((uint32_t)in[3 * i] << 16)
| ((uint32_t)in[3 * i + 1] << 8)
| (uint32_t)in[3 * i + 2];
......@@ -229,12 +212,11 @@ void aec_get_rsi_msb_24(struct aec_stream *strm)
#ifdef WORDS_BIGENDIAN
void aec_get_rsi_lsb_32(struct aec_stream *strm)
{
int i;
uint32_t *restrict out = strm->state->data_raw;
const unsigned char *restrict in = strm->next_in;
int rsi = strm->rsi * strm->block_size;
for (i = 0; i < rsi; i++)
for (int i = 0; i < rsi; i++)
out[i] = (uint32_t)in[4 * i]
| ((uint32_t)in[4 * i + 1] << 8)
| ((uint32_t)in[4 * i + 2] << 16)
......@@ -249,7 +231,6 @@ AEC_GET_RSI_NATIVE_32(msb);
#else /* !WORDS_BIGENDIAN */
void aec_get_rsi_msb_32(struct aec_stream *strm)
{
int i;
uint32_t *restrict out = strm->state->data_raw;
const unsigned char *restrict in = strm->next_in;
int rsi = strm->rsi * strm->block_size;
......@@ -257,7 +238,7 @@ void aec_get_rsi_msb_32(struct aec_stream *strm)
strm->next_in += 4 * rsi;
strm->avail_in -= 4 * rsi;
for (i = 0; i < rsi; i++)
for (int i = 0; i < rsi; i++)
out[i] = ((uint32_t)in[4 * i] << 24)
| ((uint32_t)in[4 * i + 1] << 16)
| ((uint32_t)in[4 * i + 2] << 8)
......
......@@ -12,14 +12,13 @@
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)
for (int i = 1; i < NOPTS; i <<= 1)
if (sz_opts & i)
opts |= co[i];
......@@ -39,32 +38,22 @@ 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;
int j;
const unsigned char *src8;
unsigned char *dest8;
const unsigned char *src8 = (unsigned char *)src;
unsigned char *dest8 = (unsigned char *)dest;
src8 = (unsigned char *)src;
dest8 = (unsigned char *)dest;
for (i = 0; i < n / wordsize; i++)
for (j = 0; j < wordsize; j++)
for (size_t i = 0; i < n / wordsize; i++)
for (size_t j = 0; j < wordsize; j++)
dest8[j * (n / wordsize) + i] = src8[i * wordsize + j];
}
static void deinterleave_buffer(void *dest, const void *src,
size_t n, int wordsize)
{
size_t i;
int j;
const unsigned char *src8;
unsigned char *dest8;
src8 = (unsigned char *)src;
dest8 = (unsigned char *)dest;
const unsigned char *src8 = (unsigned char *)src;
unsigned char *dest8 = (unsigned char *)dest;
for (i = 0; i < n / wordsize; i++)
for (j = 0; j < wordsize; j++)
for (size_t i = 0; i < n / wordsize; i++)
for (size_t j = 0; j < wordsize; j++)
dest8[i * wordsize + j] = src8[j * (n / wordsize) + i];
}
......@@ -72,22 +61,21 @@ static void add_padding(void *dest, const void *src, size_t src_length,
size_t line_size, size_t padding_size,
int pixel_size, int pp)
{
size_t i, j, k, ls, ps;
const char *pixel;
const char zero_pixel[] = {0, 0, 0, 0};
pixel = zero_pixel;
j = 0;
i = 0;
const char *pixel = zero_pixel;
size_t j = 0;
size_t i = 0;
while (i < src_length) {
ls = MIN(src_length - i, line_size);
size_t ps;
size_t ls = MIN(src_length - i, line_size);
memcpy((char *)dest + j, (char *)src + i, ls);
j += ls;
i += ls;
if (pp)
pixel = (char *)src + i - pixel_size;
ps = line_size + padding_size - ls;
for (k = 0; k < ps; k += pixel_size)
for (size_t k = 0; k < ps; k += pixel_size)
memcpy((char *)dest + j + k, pixel, pixel_size);
j += ps;
}
......@@ -97,11 +85,10 @@ static void remove_padding(void *buf, size_t buf_length,
size_t line_size, size_t padding_size,
int pixel_size)
{
size_t i, j;
size_t padded_line_size = line_size + padding_size;
i = line_size;
for (j = padded_line_size; j < buf_length; j += padded_line_size) {
size_t i = line_size;
for (size_t j = padded_line_size; j < buf_length; j += padded_line_size) {
memmove((char *)buf + i, (char *)buf + j, line_size);
i += line_size;
}
......@@ -113,14 +100,6 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen,
{
struct aec_stream strm;
int status;
int aec_status;
void *padbuf;
void *buf;
size_t padding_size;
size_t scanlines;
size_t padbuf_size;
int pixel_size;
int interleave;
strm.block_size = param->pixels_per_block;
strm.rsi = (param->pixels_per_scanline + param->pixels_per_block - 1)
......@@ -128,10 +107,10 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen,
strm.flags = AEC_NOT_ENFORCE | convert_options(param->options_mask);
strm.avail_out = *destLen;
strm.next_out = dest;
buf = 0;
padbuf = 0;
void *buf = 0;
void *padbuf = 0;
interleave = param->bits_per_pixel == 32 || param->bits_per_pixel == 64;
int interleave = param->bits_per_pixel == 32 || param->bits_per_pixel == 64;
if (interleave) {
strm.bits_per_sample = 8;
buf = malloc(sourceLen);
......@@ -145,18 +124,18 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen,
buf = (void *)source;
}
pixel_size = bits_to_bytes(strm.bits_per_sample);
int pixel_size = bits_to_bytes(strm.bits_per_sample);
scanlines = (sourceLen / pixel_size + param->pixels_per_scanline - 1)
size_t scanlines = (sourceLen / pixel_size + param->pixels_per_scanline - 1)
/ param->pixels_per_scanline;
padbuf_size = strm.rsi * strm.block_size * pixel_size * scanlines;
size_t padbuf_size = strm.rsi * strm.block_size * pixel_size * scanlines;
padbuf = malloc(padbuf_size);
if (padbuf == NULL) {
status = SZ_MEM_ERROR;
goto CLEANUP;
}
padding_size =
size_t padding_size =
(strm.rsi * strm.block_size - param->pixels_per_scanline)
* pixel_size;
......@@ -167,7 +146,7 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen,
strm.next_in = padbuf;
strm.avail_in = padbuf_size;
aec_status = aec_buffer_encode(&strm);
int aec_status = aec_buffer_encode(&strm);
if (aec_status == AEC_STREAM_ERROR)
status = SZ_OUTBUFF_FULL;
else
......@@ -188,14 +167,8 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen,
{
struct aec_stream strm;
int status;
void *buf;
size_t padding_size;
size_t total_out;
size_t scanlines;
size_t buf_size, total_out;
int pixel_size;
int pad_scanline;
int deinterleave;
int extra_buffer;
strm.block_size = param->pixels_per_block;
strm.rsi = (param->pixels_per_scanline + param->pixels_per_block - 1)
......@@ -203,20 +176,23 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen,
strm.flags = convert_options(param->options_mask);
strm.avail_in = sourceLen;
strm.next_in = source;
buf = 0;
void *buf = 0;
pad_scanline = param->pixels_per_scanline % param->pixels_per_block;
deinterleave = param->bits_per_pixel == 32 || param->bits_per_pixel == 64;
extra_buffer = pad_scanline || deinterleave;
int pad_scanline = param->pixels_per_scanline % param->pixels_per_block;
int deinterleave = (param->bits_per_pixel == 32
|| param->bits_per_pixel == 64);
int extra_buffer = pad_scanline || deinterleave;
int pixel_size;
if (deinterleave)
strm.bits_per_sample = 8;
else
strm.bits_per_sample = param->bits_per_pixel;
pixel_size = bits_to_bytes(strm.bits_per_sample);
if (extra_buffer) {
size_t buf_size;
if (pad_scanline) {
scanlines = (*destLen / pixel_size + param->pixels_per_scanline - 1)
/ param->pixels_per_scanline;
......@@ -241,7 +217,7 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen,
goto CLEANUP;
if (pad_scanline) {
padding_size =
size_t padding_size =
(strm.rsi * strm.block_size - param->pixels_per_scanline)
* pixel_size;
remove_padding(buf, strm.total_out,
......
......@@ -5,17 +5,13 @@
static void out_lsb(unsigned char *dest, unsigned long long int val, int size)
{
int i;
for (i = 0; i < size; i++)
for (int i = 0; i < size; i++)
dest[i] = (unsigned char)(val >> (8 * i));
}
static void out_msb(unsigned char *dest, unsigned long long int val, int size)
{
int i;
for (i = 0; i < size; i++)
for (int i = 0; i < size; i++)
dest[i] = (unsigned char)(val >> (8 * (size - 1 - i)));
}
......@@ -58,12 +54,11 @@ int update_state(struct test_state *state)
int encode_decode_small(struct test_state *state)
{
int status, i;
size_t compressed_size;
size_t n_in, avail_in, avail_out, total_out;
struct aec_stream *strm = state->strm;
status = aec_encode_init(strm);
int status = aec_encode_init(strm);
if (status != AEC_OK) {
printf("Init failed.\n");
return 99;
......@@ -175,19 +170,19 @@ int encode_decode_small(struct test_state *state)
printf("\n%s: Uncompressed output differs from input.\n", CHECK_FAIL);
printf("\nuncompressed buf");
for (i = 0; i < 80; i++) {
for (int i = 0; i < 80; i++) {
if (i % 8 == 0)
printf("\n");
printf("%02x ", state->ubuf[i]);
}
printf("\n\ncompressed buf len %li", compressed_size);
for (i = 0; i < 80; i++) {
for (int i = 0; i < 80; i++) {
if (i % 8 == 0)
printf("\n");
printf("%02x ", state->cbuf[i]);
}
printf("\n\ndecompressed buf");
for (i = 0; i < 80; i++) {
for (int i = 0; i < 80; i++) {
if (i % 8 == 0)
printf("\n%04i ", i);
printf("%02x ", state->obuf[i]);
......@@ -201,12 +196,10 @@ int encode_decode_small(struct test_state *state)
int encode_decode_large(struct test_state *state)
{
int status, i;
char fbase[1024];
char fname[1024];
FILE *fp;
int status;
int bflags;
size_t to;
char fbase[1024];
struct aec_stream *strm = state->strm;
strm->avail_in = state->ibuf_len;
......@@ -220,6 +213,8 @@ int encode_decode_large(struct test_state *state)
return 99;
}
if (state->dump) {
char fname[1024];
FILE *fp;
snprintf(fbase, sizeof(fbase), "BPS%02iID%iBS%02iRSI%04iFLG%04i",
strm->bits_per_sample,
state->id,
......@@ -254,6 +249,8 @@ int encode_decode_large(struct test_state *state)
aec_encode_end(strm);
if (state->dump) {
char fname[1024];
FILE *fp;
snprintf(fname, sizeof(fname), "%s.rz", fbase);
if ((fp = fopen(fname, "wb")) == NULL) {
fprintf(stderr, "ERROR: cannot open dump file %s\n", fname);
......@@ -288,19 +285,19 @@ int encode_decode_large(struct test_state *state)
printf("\n%s: Uncompressed output differs from input.\n", CHECK_FAIL);
printf("\nuncompressed buf");
for (i = 0; i < 80; i++) {
for (int i = 0; i < 80; i++) {
if (i % 8 == 0)
printf("\n");
printf("%02x ", state->ubuf[i]);