diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-02-18 19:54:24 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-02-24 08:53:43 +0100 |
commit | bce9c5e276be3da2cc44f6ff04673c7f1e8bfb2f (patch) | |
tree | 420c08680e8cbd8379a4deff4f7e00a93ab8e410 /libavcodec/tests | |
parent | f729dee615542f69c071d2759417e03a5645ef8a (diff) | |
download | ffmpeg-bce9c5e276be3da2cc44f6ff04673c7f1e8bfb2f.tar.gz |
avcodec/rangecoder: Move ff_rac_check_termination to tests/rangecoder.c
It is only used there.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/tests')
-rw-r--r-- | libavcodec/tests/rangecoder.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/libavcodec/tests/rangecoder.c b/libavcodec/tests/rangecoder.c index d6cf9ec380..ca96e13c99 100644 --- a/libavcodec/tests/rangecoder.c +++ b/libavcodec/tests/rangecoder.c @@ -26,6 +26,32 @@ #define SIZE 1240 +/** + * Check if at the current position there is a valid looking termination + * @param version version 0 requires the decoder to know the data size in bytes + * version 1 needs about 1 bit more space but does not need to + * carry the size from encoder to decoder + * @returns negative AVERROR code on error or non negative. + */ +static int 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; +} + int main(void) { RangeCoder c; @@ -61,7 +87,7 @@ int main(void) return 1; } - if (ff_rac_check_termination(&c, version) < 0) { + if (rac_check_termination(&c, version) < 0) { av_log(NULL, AV_LOG_ERROR, "rac failure at termination pass %d version %d\n", p, version); return 1; } |