summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathis Rosenhauer <rosenhauer@dkrz.de>2014-10-29 11:35:56 +0100
committerMathis Rosenhauer <rosenhauer@dkrz.de>2014-10-29 11:35:56 +0100
commitb94e56eaad32c12d70c34e8913cedfd236aa17d0 (patch)
tree29c42c117778b7119286590593c9173cf79f79d2
parentb9f9312bf6ee19195ba9fc2928fa4110f1e0df90 (diff)
downloadlibaec-b94e56eaad32c12d70c34e8913cedfd236aa17d0.tar.gz
libaec-b94e56eaad32c12d70c34e8913cedfd236aa17d0.tar.bz2
libaec-b94e56eaad32c12d70c34e8913cedfd236aa17d0.zip
Increase code sharing between CLZ implementations.
-rw-r--r--src/decode.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/decode.c b/src/decode.c
index ead9464..1637a65 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -271,10 +271,10 @@ static inline uint32_t direct_get_fs(struct aec_stream *strm)
*/
uint32_t fs = 0;
-#if HAVE_DECL___BUILTIN_CLZLL
- int lz;
-#elif HAVE_BSR64
- unsigned long lz;
+#if HAVE_BSR64
+ unsigned long i;
+#else
+ int i;
#endif
struct internal_state *state = strm->state;
@@ -290,20 +290,16 @@ static inline uint32_t direct_get_fs(struct aec_stream *strm)
}
#if HAVE_DECL___BUILTIN_CLZLL
- lz = __builtin_clzll(state->acc);
- fs += lz + state->bitp - 64;
- state->bitp = 63 - lz;
+ i = 63 - __builtin_clzll(state->acc);
#elif HAVE_BSR64
- _BitScanReverse64(&lz, state->acc);
- fs += state->bitp - 1 - lz;
- state->bitp = lz;
+ _BitScanReverse64(&i, state->acc);
#else
- state->bitp--;
- while ((state->acc & (UINT64_C(1) << state->bitp)) == 0) {
- state->bitp--;
- fs++;
- }
+ i = state->bitp - 1;
+ while ((state->acc & (UINT64_C(1) << i)) == 0)
+ i--;
#endif
+ fs += state->bitp - i - 1;
+ state->bitp = i;
return fs;
}