int high;
int bits;
const uint8_t *buffer;
+ const uint8_t *end;
unsigned long code_word;
} VP56RangeCoder;
int quantizer;
uint16_t dequant_dc;
uint16_t dequant_ac;
+ int8_t *qscale_table;
/* DC predictors management */
VP56RefDc *above_blocks;
/* blocks / macroblock */
VP56mb mb_type;
VP56Macroblock *macroblocks;
- DECLARE_ALIGNED_16(DCTELEM, block_coeff[6][64]);
+ DECLARE_ALIGNED(16, DCTELEM, block_coeff)[6][64];
/* motion vectors */
VP56mv mv[6]; /* vectors for each block in MB */
c->high = 255;
c->bits = 8;
c->buffer = buf;
+ c->end = buf + buf_size;
c->code_word = bytestream_get_be16(&c->buffer);
}
while (c->high < 128) {
c->high <<= 1;
c->code_word <<= 1;
- if (--c->bits == 0) {
+ if (--c->bits == 0 && c->buffer < c->end) {
c->bits = 8;
c->code_word |= *c->buffer++;
}
/* normalize */
c->code_word <<= 1;
- if (--c->bits == 0) {
+ if (--c->bits == 0 && c->buffer < c->end) {
c->bits = 8;
c->code_word |= *c->buffer++;
}