diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2018-12-23 14:17:11 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2018-12-31 17:44:22 +0100 |
commit | b6c2c589041cd99c5bf4117d13708ab010f97bd1 (patch) | |
tree | bd64ae8d37b041174c1c9eb42ca9d0fd11e855d6 /libavcodec/rangecoder.c | |
parent | 20b10ba83c46d1f2b381b0b3e70ce44195473815 (diff) | |
download | ffmpeg-b6c2c589041cd99c5bf4117d13708ab010f97bd1.tar.gz |
avcodec/rangecoder: Add and test ff_rac_check_termination()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/rangecoder.c')
-rw-r--r-- | libavcodec/rangecoder.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libavcodec/rangecoder.c b/libavcodec/rangecoder.c index fa7d5526d1..a6a3f082ef 100644 --- a/libavcodec/rangecoder.c +++ b/libavcodec/rangecoder.c @@ -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; +} |