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);
}
/**