]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Simplify get_bits1().
authorAndre Noll <maan@systemlinux.org>
Sun, 18 Oct 2009 20:21:55 +0000 (22:21 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 18 Nov 2009 18:34:23 +0000 (19:34 +0100)
bitstream.h

index cc56a83c0207c2abc9c6fd25e9e9fd1aa4c5bb7d..d13ef4c2bd6946deff17e9104432052b1319b25e 100644 (file)
@@ -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);
 }
 
 /**