diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2018-12-19 02:40:19 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2018-12-31 17:44:19 +0100 |
commit | 0c4af1390f12a391c483086758bcdfd17f3edc63 (patch) | |
tree | 004e12c51df52463017b77d45570e1f0bd13d654 | |
parent | 1be9a28f8e8cd2553f978670901174a8808b9a1a (diff) | |
download | ffmpeg-0c4af1390f12a391c483086758bcdfd17f3edc63.tar.gz |
avcodec/tests/rangecoder: Test coder more completely
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/tests/rangecoder.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/libavcodec/tests/rangecoder.c b/libavcodec/tests/rangecoder.c index 76a13e7091..3fd07ed9a9 100644 --- a/libavcodec/tests/rangecoder.c +++ b/libavcodec/tests/rangecoder.c @@ -24,41 +24,50 @@ #include "libavcodec/rangecoder.h" -#define SIZE 10240 +#define SIZE 1240 int main(void) { RangeCoder c; uint8_t b[9 * SIZE]; uint8_t r[9 * SIZE]; - int i; + int i, p, actual_length, version; uint8_t state[10]; AVLFG prng; av_lfg_init(&prng, 1); + for (version = 0; version < 2; version++) { + for (p = 0; p< 1024; p++) { + ff_init_range_encoder(&c, b, SIZE); + ff_build_rac_states(&c, (1LL << 32) / 20, 128 + 64 + 32 + 16); - ff_init_range_encoder(&c, b, SIZE); - ff_build_rac_states(&c, (1LL << 32) / 20, 128 + 64 + 32 + 16); + memset(state, 128, sizeof(state)); - memset(state, 128, sizeof(state)); + for (i = 0; i < SIZE; i++) + r[i] = av_lfg_get(&prng) % 7; - for (i = 0; i < SIZE; i++) - r[i] = av_lfg_get(&prng) % 7; + for (i = 0; i < SIZE; i++) + put_rac(&c, state, r[i] & 1); - for (i = 0; i < SIZE; i++) - put_rac(&c, state, r[i] & 1); + actual_length = ff_rac_terminate(&c, version); - ff_rac_terminate(&c, 0); + ff_init_range_decoder(&c, b, version ? SIZE : actual_length); - ff_init_range_decoder(&c, b, SIZE); + memset(state, 128, sizeof(state)); - memset(state, 128, sizeof(state)); - - for (i = 0; i < SIZE; i++) - if ((r[i] & 1) != get_rac(&c, state)) { - av_log(NULL, AV_LOG_ERROR, "rac failure at %d\n", i); - return 1; + for (i = 0; i < SIZE; i++) + if ((r[i] & 1) != get_rac(&c, state)) { + av_log(NULL, AV_LOG_ERROR, "rac failure at %d pass %d version %d\n", i, p, version); + return 1; + } + if(version) + get_rac(&c, (uint8_t[]) { 129 }); + if (c.bytestream - c.bytestream_start - actual_length != version) { + av_log(NULL, AV_LOG_ERROR, "rac failure at pass %d version %d\n", p, version); + return 1; + } } + } return 0; } |