rc->range *= freq;
while (rc->range < TOP && bytestream2_get_bytes_left(gb) > 0) {
- unsigned byte = bytestream2_get_byte(gb);
+ unsigned byte = bytestream2_get_byteu(gb);
rc->code = (rc->code << 8) | byte;
rc->range <<= 8;
}
rc->range = rc->range * (uint64_t)(freq + cumFreq) / total_freq - (t + 1);
while (rc->range < TOP && bytestream2_get_bytes_left(gb) > 0) {
- unsigned byte = bytestream2_get_byte(gb);
+ unsigned byte = bytestream2_get_byteu(gb);
rc->code = (rc->code << 8) | byte;
rc->code1 <<= 8;
rc->range <<= 8;
int backstep = linesize - avctx->width;
if (bytestream2_get_byte(gb) == 0)
- return 0;
+ return 1;
bytestream2_skip(gb, 1);
init_rangecoder(&s->rc, gb);
return ret;
max += temp << 8;
- if (min > max)
+ if (min > max || min >= s->nbcount)
return AVERROR_INVALIDDATA;
memset(s->blocks, 0, sizeof(*s->blocks) * s->nbcount);
ret |= decode_value(s, s->count_model, 256, 20, &count);
if (ret < 0)
return ret;
+ if (count <= 0)
+ return AVERROR_INVALIDDATA;
while (min < s->nbcount && count-- > 0) {
s->blocks[min++] = fill;
s->current_frame->linesize[0] / 4,
(uint32_t *)s->last_frame->data[0],
s->last_frame->linesize[0] / 4);
+ if (ret == 1)
+ return avpkt->size;
} else {
return AVERROR_PATCHWELCOME;
}