uint64_t time_unit;
uint64_t spu;
uint32_t size;
+ int ret;
bytestream2_init(&p, os->buf + os->pstart, os->psize);
if (!(bytestream2_peek_byte(&p) & 1))
size -= 52;
if (bytestream2_get_bytes_left(&p) < size)
return AVERROR_INVALIDDATA;
- av_freep(&st->codecpar->extradata);
- if (ff_alloc_extradata(st->codecpar, size) < 0)
- return AVERROR(ENOMEM);
+ if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0)
+ return ret;
bytestream2_get_buffer(&p, st->codecpar->extradata, st->codecpar->extradata_size);
}
}
+
+ // Update internal avctx with changes to codecpar above.
+ st->internal->need_context_update = 1;
} else if (bytestream2_peek_byte(&p) == 3) {
bytestream2_skip(&p, 7);
if (bytestream2_get_bytes_left(&p) > 1)
os->pflags |= AV_PKT_FLAG_KEY;
lb = ((*p & 2) << 1) | ((*p >> 6) & 3);
+ if (os->psize < lb + 1)
+ return AVERROR_INVALIDDATA;
+
os->pstart += lb + 1;
os->psize -= lb + 1;
while (lb--)
- os->pduration += p[lb+1] << (lb*8);
+ os->pduration += (uint64_t)p[lb+1] << (lb*8);
return 0;
}