1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-06-20 06:16:02 +02:00

avcodec/rangecoder: Add and test ff_rac_check_termination()

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer
2018-12-23 14:17:11 +01:00
parent 20b10ba83c
commit b6c2c58904
3 changed files with 33 additions and 2 deletions

View File

@ -121,3 +121,22 @@ int ff_rac_terminate(RangeCoder *c, int version)
return c->bytestream - c->bytestream_start;
}
int ff_rac_check_termination(RangeCoder *c, int version)
{
if (version == 1) {
RangeCoder tmp = *c;
get_rac(c, (uint8_t[]) { 129 });
if (c->bytestream == tmp.bytestream && c->bytestream > c->bytestream_start)
tmp.low -= *--tmp.bytestream;
tmp.bytestream_end = tmp.bytestream;
if (get_rac(&tmp, (uint8_t[]) { 129 }))
return AVERROR_INVALIDDATA;
} else {
if (c->bytestream_end != c->bytestream)
return AVERROR_INVALIDDATA;
}
return 0;
}