|
|
|
@ -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; |
|
|
|
|
} |
|
|
|
|