/* This is rather hot, we can do better than get_bits(gbc, 1). */
static inline unsigned int get_bit(struct getbit_context *gbc)
{
/* This is rather hot, we can do better than get_bits(gbc, 1). */
static inline unsigned int get_bit(struct getbit_context *gbc)
{
- int idx = gbc->index++;
- uint8_t tmp = gbc->buffer[idx >> 3], mask = 1 << (7 - (idx & 7));
+ int idx;
+ uint8_t tmp, mask;
+
+ assert(gbc->index < gbc->num_bits);
+ idx = gbc->index++;
+ tmp = gbc->buffer[idx >> 3];
+ mask = 1 << (7 - (idx & 7));