From: Andre Noll Date: Sun, 18 Oct 2009 20:21:55 +0000 (+0200) Subject: Simplify get_bits1(). X-Git-Tag: v0.4.1~58 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=4163d3460d5dc61264636ebeb7b3fe8052b93568;p=paraslash.git Simplify get_bits1(). --- diff --git a/bitstream.h b/bitstream.h index cc56a83c..d13ef4c2 100644 --- a/bitstream.h +++ b/bitstream.h @@ -56,16 +56,12 @@ static inline unsigned int get_bits(struct getbit_context *gbc, int n) return ret; } +/* This is rather hot, we can do better than get_bits(gbc, 1). */ static inline unsigned int get_bits1(struct getbit_context *gbc) { - int idx = gbc->index; - uint8_t result = gbc->buffer[idx >> 3]; - - result <<= (idx & 0x07); - result >>= 8 - 1; - idx++; - gbc->index = idx; - return result; + int idx = gbc->index++; + uint8_t tmp = gbc->buffer[idx >> 3], mask = (1 << (7 - (idx & 7))); + return !!(tmp & mask); } /**