From 12a94f75d36d3b41d1d94a7281ed1d0a46d5d745 Mon Sep 17 00:00:00 2001 From: Mathis Rosenhauer Date: Thu, 6 Feb 2014 16:44:52 +0100 Subject: [PATCH] 56 bits for FS are not enough for lage block situations. Fixed --- src/decode.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/decode.c b/src/decode.c index e0f5e00..0020654 100644 --- a/src/decode.c +++ b/src/decode.c @@ -271,16 +271,23 @@ static inline uint32_t direct_get_fs(struct aec_stream *strm) */ uint32_t fs = 0; +#ifdef HAVE_DECL___BUILTIN_CLZLL + uint32_t clz; +#endif struct internal_state *state = strm->state; state->acc &= ((1ULL << state->bitp) - 1); - if (state->acc == 0) + while (state->acc == 0) { + fs += state->bitp; + state->bitp = 0; fill_acc(strm); + } #ifdef HAVE_DECL___BUILTIN_CLZLL - fs = __builtin_clzll(state->acc) - (64 - state->bitp); - state->bitp -= fs + 1; + clz = __builtin_clzll(state->acc); + fs += clz + state->bitp - 64; + state->bitp = 63 - clz; #else state->bitp--; while ((state->acc & (1ULL << state->bitp)) == 0) { -- 2.7.4