aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAlberto Delmás <adelmas@gmail.com>2012-09-03 17:32:01 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2012-09-06 20:44:04 +0200
commit9699b3a2d7ebc62ae58c4e70997190f5f7b45d27 (patch)
tree7c4d1aa78b53c3edf474eb52d7ca331d751186bc /libavcodec
parent6ceef07b21a6b828d98f25edefb66e322a628667 (diff)
downloadffmpeg-9699b3a2d7ebc62ae58c4e70997190f5f7b45d27.tar.gz
mss12: avoid unnecessary division in arith*_get_bit()
That division can be replaced with a comparison: ((c->value - c->low) << 1) + 1 >= range By expanding 'range' definition and simplifying this inequation we obtain the final expression. Suggested by Michael Niedermayer <michaelni@gmx.at> Signed-off-by: Kostya Shishkov <kostya.shishkov@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mss12.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/mss12.h b/libavcodec/mss12.h
index 678a0c0dfb..f5d03662b8 100644
--- a/libavcodec/mss12.h
+++ b/libavcodec/mss12.h
@@ -103,7 +103,7 @@ av_cold int ff_mss12_decode_end(MSS12Context *ctx);
static int arith ## VERSION ## _get_bit(ArithCoder *c) \
{ \
int range = c->high - c->low + 1; \
- int bit = (((c->value - c->low) << 1) + 1) / range; \
+ int bit = 2 * c->value - c->low >= c->high; \
\
if (bit) \
c->low += range >> 1; \