From d6932128aaa4042c610b9e117f7389f39057fc12 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Thu, 19 Sep 2013 13:10:32 +0300 Subject: [PATCH] Fix incorrect precedence. - This bug was due to incorrect translation of ternary to if-expression during refactoring. Addition has higher precedence than bit shift. --- src/context.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/context.c b/src/context.c index 3dfed865..2eabeec3 100644 --- a/src/context.c +++ b/src/context.c @@ -55,10 +55,9 @@ void ctx_init(cabac_ctx *ctx, uint32_t qp, uint32_t init_value) int slope = (init_value >> 4) * 5 - 45; int offset = ((init_value & 15) << 3) - 16; int init_state = MIN(MAX(1, ((slope * (int)qp) >> 4) + offset), 126); - uint8_t mp_state = (init_state >= 64) ? 1 : 0; - if (mp_state) { - ctx->uc_state = (init_state - 64) << 1 + mp_state; + if (init_state >= 64) { + ctx->uc_state = ((init_state - 64) << 1) + 1; } else { ctx->uc_state = (63 - init_state) << 1; }