diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-05-30 01:05:48 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-05-30 01:05:48 +0000 |
commit | 61ccfcc00950ae53725abc50435b2cce72ec8deb (patch) | |
tree | 209e59d4a37eea0ec72c8f247db41f2f255749d2 /libavcodec/cabac.c | |
parent | cf713bb8624d3e56e5077d51283f4e1ae02a5910 (diff) | |
download | ffmpeg-61ccfcc00950ae53725abc50435b2cce72ec8deb.tar.gz |
(truncated) unary binerization
unary k-th order exp golomb binarization
Originally committed as revision 1920 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/cabac.c')
-rw-r--r-- | libavcodec/cabac.c | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c index 4d018823f2..c4bd2740cb 100644 --- a/libavcodec/cabac.c +++ b/libavcodec/cabac.c @@ -127,49 +127,75 @@ void ff_init_cabac_states(CABACContext *c, uint8_t const (*lps_range)[4], int main(){ CABACContext c; uint8_t b[9*SIZE]; - uint8_t bit[9*SIZE]; + uint8_t r[9*SIZE]; int i; - uint8_t state= 0; + uint8_t state[10]= {0}; ff_init_cabac_encoder(&c, b, SIZE); ff_init_cabac_states(&c, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64); for(i=0; i<SIZE; i++){ - bit[i]= (random()%7)&1; + r[i]= random()%7; } for(i=0; i<SIZE; i++){ START_TIMER - put_cabac_bypass(&c, bit[i]); + put_cabac_bypass(&c, r[i]&1); STOP_TIMER("put_cabac_bypass") } for(i=0; i<SIZE; i++){ START_TIMER - put_cabac(&c, &state, bit[i]); + put_cabac(&c, state, r[i]&1); STOP_TIMER("put_cabac") } + for(i=0; i<SIZE; i++){ +START_TIMER + put_cabac_u(&c, state, r[i], 6, 3, i&1); +STOP_TIMER("put_cabac_u") + } + + for(i=0; i<SIZE; i++){ +START_TIMER + put_cabac_ueg(&c, state, r[i], 0, 3, 0, 1, 2); +STOP_TIMER("put_cabac_ueg") + } + put_cabac_terminate(&c, 1); ff_init_cabac_decoder(&c, b, SIZE); - state=0; + memset(state, 0, sizeof(state)); for(i=0; i<SIZE; i++){ START_TIMER - if( bit[i] != get_cabac_bypass(&c) ) + if( (r[i]&1) != get_cabac_bypass(&c) ) printf("CABAC bypass failure at %d\n", i); STOP_TIMER("get_cabac_bypass") } for(i=0; i<SIZE; i++){ START_TIMER - if( bit[i] != get_cabac(&c, &state) ) + if( (r[i]&1) != get_cabac(&c, state) ) printf("CABAC failure at %d\n", i); STOP_TIMER("get_cabac") } - + + for(i=0; i<SIZE; i++){ +START_TIMER + if( r[i] != get_cabac_u(&c, state, (i&1) ? 6 : 7, 3, i&1) ) + printf("CABAC unary (truncated) binarization failure at %d\n", i); +STOP_TIMER("get_cabac_u") + } + + for(i=0; i<SIZE; i++){ +START_TIMER + if( r[i] != get_cabac_ueg(&c, state, 3, 0, 1, 2)) + printf("CABAC unary (truncated) binarization failure at %d\n", i); +STOP_TIMER("get_cabac_ueg") + } + if(!get_cabac_terminate(&c)) printf("where's the Terminator?\n"); |