From: Mathis Rosenhauer Date: Mon, 3 Sep 2012 09:22:14 +0000 (+0200) Subject: int64_t casts to make 32Bit samples work again X-Git-Tag: accepted/tizen/5.0/unified/20181102.025501~258 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b3e52ccd6c955c0fec84a8ce1581d79aae348702;p=platform%2Fupstream%2Flibaec.git int64_t casts to make 32Bit samples work again --- diff --git a/src/Makefile b/src/Makefile index 6a83629..8da34dc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -40,10 +40,10 @@ clean: *.gcno *.gcda *.gcov gmon.out check: encode decode test_szcomp - ./encode -c -b1 -B8 -R128 -J64 ../data/example_data > ../data/test.aee - ./decode -b1 -B8 -R128 -J64 ../data/test.aee + ./encode -c -b1 -B8 -R128 -J8 ../data/example_data > ../data/test.aee + ./decode -b1 -B8 -R128 -J8 ../data/test.aee diff ../data/test ../data/example_data - ./encode -c -b1024 -B8 -R128 -J64 ../data/example_data > ../data/test.aee - ./decode -b1024 -B8 -R128 -J64 ../data/test.aee + ./encode -c -b1024 -B32 -R128 -J64 ../data/example_data > ../data/test.aee + ./decode -b1024 -B32 -R128 -J64 ../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 9217a6f..14f386c 100644 --- a/src/aed.c +++ b/src/aed.c @@ -170,7 +170,7 @@ static inline int64_t u_get(ae_streamp strm, unsigned int n) return (state->acc >> state->bitp) & ((1ULL << n) - 1); } -static inline int u_get_fs(ae_streamp strm) +static inline int64_t u_get_fs(ae_streamp strm) { /** Interpret a Fundamental Sequence from the input buffer. @@ -179,7 +179,7 @@ static inline int u_get_fs(ae_streamp strm) 1 is encountered. TODO: faster version. */ - int fs = 0; + int64_t fs = 0; while(u_get(strm, 1) == 0) fs++; diff --git a/src/aee_mutators.c b/src/aee_mutators.c index 1c32342..aecf01d 100644 --- a/src/aee_mutators.c +++ b/src/aee_mutators.c @@ -7,10 +7,10 @@ int64_t get_lsb_32(ae_streamp strm) { int64_t data; - data = (strm->next_in[3] << 24) - | (strm->next_in[2] << 16) - | (strm->next_in[1] << 8) - | strm->next_in[0]; + data = ((int64_t)strm->next_in[3] << 24) + | ((int64_t)strm->next_in[2] << 16) + | ((int64_t)strm->next_in[1] << 8) + | (int64_t)strm->next_in[0]; strm->next_in += 4; strm->total_in += 4; @@ -22,7 +22,8 @@ int64_t get_lsb_16(ae_streamp strm) { int64_t data; - data = (strm->next_in[1] << 8) | strm->next_in[0]; + data = ((int64_t)strm->next_in[1] << 8) + | (int64_t)strm->next_in[0]; strm->next_in += 2; strm->total_in += 2; @@ -34,10 +35,10 @@ int64_t get_msb_32(ae_streamp strm) { int64_t data; - data = (strm->next_in[0] << 24) - | (strm->next_in[1] << 16) - | (strm->next_in[2] << 8) - | strm->next_in[3]; + data = ((int64_t)strm->next_in[0] << 24) + | ((int64_t)strm->next_in[1] << 16) + | ((int64_t)strm->next_in[2] << 8) + | (int64_t)strm->next_in[3]; strm->next_in += 4; strm->total_in += 4; @@ -49,7 +50,8 @@ int64_t get_msb_16(ae_streamp strm) { int64_t data; - data = (strm->next_in[0] << 8) | strm->next_in[1]; + data = ((int64_t)strm->next_in[0] << 8) + | (int64_t)strm->next_in[1]; strm->next_in += 2; strm->total_in += 2; @@ -68,14 +70,14 @@ void get_block_msb_16_bs_8(ae_streamp strm) { int64_t *block = strm->state->in_block; - block[0] = (strm->next_in[0] << 8) | strm->next_in[1]; - block[1] = (strm->next_in[2] << 8) | strm->next_in[3]; - block[2] = (strm->next_in[4] << 8) | strm->next_in[5]; - block[3] = (strm->next_in[6] << 8) | strm->next_in[7]; - block[4] = (strm->next_in[8] << 8) | strm->next_in[9]; - block[5] = (strm->next_in[10] << 8) | strm->next_in[11]; - block[6] = (strm->next_in[12] << 8) | strm->next_in[13]; - block[7] = (strm->next_in[14] << 8) | strm->next_in[15]; + block[0] = ((int64_t)strm->next_in[0] << 8) | (int64_t)strm->next_in[1]; + block[1] = ((int64_t)strm->next_in[2] << 8) | (int64_t)strm->next_in[3]; + block[2] = ((int64_t)strm->next_in[4] << 8) | (int64_t)strm->next_in[5]; + block[3] = ((int64_t)strm->next_in[6] << 8) | (int64_t)strm->next_in[7]; + block[4] = ((int64_t)strm->next_in[8] << 8) | (int64_t)strm->next_in[9]; + block[5] = ((int64_t)strm->next_in[10] << 8) | (int64_t)strm->next_in[11]; + block[6] = ((int64_t)strm->next_in[12] << 8) | (int64_t)strm->next_in[13]; + block[7] = ((int64_t)strm->next_in[14] << 8) | (int64_t)strm->next_in[15]; strm->next_in += 16; strm->total_in += 16; @@ -89,8 +91,8 @@ void get_block_msb_16(ae_streamp strm) for (i = 0; i < strm->block_size; i++) { - block[i] = (strm->next_in[2 * i] << 8) - | strm->next_in[2 * i + 1]; + block[i] = ((int64_t)strm->next_in[2 * i] << 8) + | (int64_t)strm->next_in[2 * i + 1]; } strm->next_in += 2 * strm->block_size; strm->total_in += 2 * strm->block_size; @@ -104,10 +106,10 @@ void get_block_msb_32(ae_streamp strm) for (i = 0; i < strm->block_size; i++) { - block[i] = (strm->next_in[4 * i] << 24) - | (strm->next_in[4 * i + 1] << 16) - | (strm->next_in[4 * i + 2] << 8) - | strm->next_in[4 * i + 3]; + block[i] = ((int64_t)strm->next_in[4 * i] << 24) + | ((int64_t)strm->next_in[4 * i + 1] << 16) + | ((int64_t)strm->next_in[4 * i + 2] << 8) + | (int64_t)strm->next_in[4 * i + 3]; } strm->next_in += 4 * strm->block_size; strm->total_in += 4 * strm->block_size; diff --git a/src/decode.c b/src/decode.c index c7e25ed..7b48944 100644 --- a/src/decode.c +++ b/src/decode.c @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) switch (c) { case 'b': - chunk = 2 * atoi(optarg); + chunk = atoi(optarg); break; case 'B': strm.bit_per_sample = atoi(optarg); @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) } in = (uint8_t *)malloc(chunk); - out = (uint8_t *)malloc(chunk * sizeof(uint8_t)); + out = (uint8_t *)malloc(chunk); if (in == NULL || out == NULL) return 1; diff --git a/src/encode.c b/src/encode.c index 85465c7..6eb85fd 100644 --- a/src/encode.c +++ b/src/encode.c @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) switch (c) { case 'b': - chunk = 2 * atoi(optarg); + chunk = atoi(optarg); break; case 'B': strm.bit_per_sample = atoi(optarg);