From: Mathis Rosenhauer Date: Wed, 22 Aug 2012 09:34:39 +0000 (+0200) Subject: Szip decompression error be gone X-Git-Tag: accepted/tizen/5.0/unified/20181102.025501~268 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7913651910c8aee91b955555ecc00f01956b0f1c;p=platform%2Fupstream%2Flibaec.git Szip decompression error be gone --- diff --git a/src/Makefile b/src/Makefile index 6ead29c..7a90bbf 100644 --- a/src/Makefile +++ b/src/Makefile @@ -39,11 +39,11 @@ clean: *.gcno *.gcda *.gcov gmon.out check: encode decode test_szcomp - ./encode -c -b1 -B8 -S128 ../data/example_data > ../data/test.aee - ./decode -b1 -B8 -S128 ../data/test.aee + ./encode -c -b1 -B8 -R128 ../data/example_data > ../data/test.aee + ./decode -b1 -B8 -R128 ../data/test.aee diff ../data/test ../data/example_data - ./encode -c -b1024 -B8 -S128 ../data/example_data > ../data/test.aee - ./decode -b1024 -B8 -S128 ../data/test.aee + ./encode -c -b1024 -B8 -R128 ../data/example_data > ../data/test.aee + ./decode -b1024 -B8 -R128 ../data/test.aee diff ../data/test ../data/example_data ./test_szcomp 65536 ../data/example_data_16 diff --git a/src/aed.c b/src/aed.c index e2ae370..c5f47ec 100644 --- a/src/aed.c +++ b/src/aed.c @@ -302,7 +302,7 @@ int ae_decode_init(ae_streamp strm) state->xmax = (1ULL << strm->bit_per_sample) - 1; } - state->ref_int = strm->block_size * strm->segment_size; + state->ref_int = strm->block_size * strm->rsi; state->in_blklen = (strm->block_size * strm->bit_per_sample + state->id_len) / 8 + 1; @@ -431,7 +431,7 @@ int ae_decode(ae_streamp strm, int flush) { case M_ID: if (state->pp - && (state->samples_out / strm->block_size) % strm->segment_size == 0) + && (state->samples_out / strm->block_size) % strm->rsi == 0) state->ref = 1; else state->ref = 0; @@ -513,9 +513,9 @@ int ae_decode(ae_streamp strm, int flush) if (zero_blocks == ROS) { - zero_blocks = strm->segment_size - ( + zero_blocks = 64 - ( (state->samples_out / strm->block_size) - % strm->segment_size); + % strm->rsi % 64); } else if (zero_blocks > ROS) { diff --git a/src/aee.c b/src/aee.c index 4c7ef7b..7cac51c 100644 --- a/src/aee.c +++ b/src/aee.c @@ -182,11 +182,8 @@ int ae_encode_init(ae_streamp strm) return AE_MEM_ERROR; } - /* Zero blocks can span a segment and thus need up to segment_size - bits in encoded block */ - blklen = MAX(strm->block_size * strm->bit_per_sample, - strm->segment_size + 10); - blklen = (blklen + state->id_len) / 8 + 3; + /* Largest possible block according to specs */ + blklen = (5 + 16 * 32) / 8 + 3; state->block_out = (uint8_t *)malloc(blklen); if (state->block_out == NULL) { @@ -380,7 +377,7 @@ int ae_encode(ae_streamp strm, int flush) /* If this is the first block in a segment then we need to insert a reference sample. */ - if(state->total_blocks % strm->segment_size == 1) + if(state->total_blocks % strm->rsi == 1) { state->ref = 1; state->last_in = state->block_in[0]; @@ -430,7 +427,7 @@ int ae_encode(ae_streamp strm, int flush) state->zero_blocks++; - if (state->total_blocks % strm->segment_size == 0) + if (state->total_blocks % strm->rsi % 64 == 0) { #ifdef PROFILE state->prof[0] += state->zero_blocks; diff --git a/src/decode.c b/src/decode.c index 89638d6..d187fa6 100644 --- a/src/decode.c +++ b/src/decode.c @@ -22,11 +22,11 @@ int main(int argc, char *argv[]) chunk = CHUNK; strm.bit_per_sample = 8; strm.block_size = 8; - strm.segment_size = 2; + strm.rsi = 2; strm.flags = AE_DATA_MSB | AE_DATA_PREPROCESS; opterr = 0; - while ((c = getopt (argc, argv, "cb:B:S:")) != -1) + while ((c = getopt (argc, argv, "cb:B:R:")) != -1) switch (c) { case 'b': @@ -35,8 +35,8 @@ int main(int argc, char *argv[]) case 'B': strm.bit_per_sample = atoi(optarg); break; - case 'S': - strm.segment_size = atoi(optarg); + case 'R': + strm.rsi = atoi(optarg); break; case 'c': cflag = 1; diff --git a/src/encode.c b/src/encode.c index 6499002..42c6a8c 100644 --- a/src/encode.c +++ b/src/encode.c @@ -22,11 +22,11 @@ int main(int argc, char *argv[]) chunk = CHUNK; strm.bit_per_sample = 8; strm.block_size = 8; - strm.segment_size = 2; + strm.rsi = 2; strm.flags = AE_DATA_MSB | AE_DATA_PREPROCESS; opterr = 0; - while ((c = getopt (argc, argv, "cb:B:S:")) != -1) + while ((c = getopt (argc, argv, "cb:B:R:")) != -1) switch (c) { case 'b': @@ -35,8 +35,8 @@ int main(int argc, char *argv[]) case 'B': strm.bit_per_sample = atoi(optarg); break; - case 'S': - strm.segment_size = atoi(optarg); + case 'R': + strm.rsi = atoi(optarg); break; case 'c': cflag = 1; diff --git a/src/libae.h b/src/libae.h index 51e34de..44eb6f7 100644 --- a/src/libae.h +++ b/src/libae.h @@ -18,8 +18,9 @@ typedef struct _ae_stream uint32_t bit_per_sample; /* resolution in bits per sample (n = * 1,..., 32) */ uint32_t block_size; /* block size in samples (J = 8 or 16) */ - uint32_t segment_size; /* set of blocks between consecutive - * reference samples */ + uint32_t rsi; /* Reference sample interval, the number of + blocks between consecutive reference + samples. */ uint32_t flags; struct internal_state *state; diff --git a/src/sz_compat.c b/src/sz_compat.c index a8b594c..9f301b7 100644 --- a/src/sz_compat.c +++ b/src/sz_compat.c @@ -8,7 +8,7 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen, const void *source, size_ strm.bit_per_sample = param->bits_per_pixel; strm.block_size = param->pixels_per_block; - strm.segment_size = param->pixels_per_scanline / param->pixels_per_block; + strm.rsi = param->pixels_per_scanline / param->pixels_per_block; strm.flags = param->options_mask; strm.avail_in = sourceLen; strm.avail_out = *destLen; @@ -36,7 +36,7 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen, const void *source, siz strm.bit_per_sample = param->bits_per_pixel; strm.block_size = param->pixels_per_block; - strm.segment_size = param->pixels_per_scanline / param->pixels_per_block; + strm.rsi = param->pixels_per_scanline / param->pixels_per_block; strm.flags = param->options_mask; strm.avail_in = sourceLen; strm.avail_out = *destLen;