* bytes larger then the actual read bits * because some optimized bitstream
* readers read 32 or 64 bit at once and could read over the end.
*
- * \param bit_size The size of the buffer in bits.
+ * \param bit_size The size of the buffer in bytes.
*/
static inline void init_get_bits(struct getbit_context *s,
- const uint8_t *buffer, int bit_size)
+ const uint8_t *buffer, int size)
{
- int buffer_size = (bit_size + 7) >> 3;
- if (buffer_size < 0 || bit_size < 0) {
- buffer_size = bit_size = 0;
- buffer = NULL;
- }
s->buffer = buffer;
- s->buffer_end = buffer + buffer_size;
+ s->buffer_end = buffer + size;
s->index = 0;
}
return 0;
buf_size = pwd->ahi.block_align;
samples = data;
- init_get_bits(&pwd->gb, buf, buf_size * 8);
+ init_get_bits(&pwd->gb, buf, buf_size);
if (pwd->use_bit_reservoir) {
/* read super frame header */
skip_bits(&pwd->gb, 4); /* super frame index */
/* XXX: bit_offset bits into last frame */
init_get_bits(&pwd->gb, pwd->last_superframe,
- MAX_CODED_SUPERFRAME_SIZE * 8);
+ MAX_CODED_SUPERFRAME_SIZE);
/* skip unused bits */
if (pwd->last_bitoffset > 0)
skip_bits(&pwd->gb, pwd->last_bitoffset);
/* read each frame starting from bit_offset */
pos = bit_offset + 4 + 4 + pwd->byte_offset_bits + 3;
init_get_bits(&pwd->gb, buf + (pos >> 3),
- (MAX_CODED_SUPERFRAME_SIZE - (pos >> 3)) * 8);
+ (MAX_CODED_SUPERFRAME_SIZE - (pos >> 3)));
len = pos & 7;
if (len > 0)
skip_bits(&pwd->gb, len);