diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2010-02-16 23:43:08 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2010-02-16 23:43:08 +0000 |
commit | 59f733d1b1814ff7e2ead43415bb4b89cbed4b0f (patch) | |
tree | 0b064677f34046b4b1abe363358e323da1353bd3 /libavcodec/h264_cabac.c | |
parent | fc78b0cb7e115ae494861c37a9928cff74df8db9 (diff) | |
download | ffmpeg-59f733d1b1814ff7e2ead43415bb4b89cbed4b0f.tar.gz |
2x faster ff_h264_init_cabac_states(), 4k cpu cycles less.
Sadly this is just per slice so the speedup with normal files should be negligible.
Originally committed as revision 21859 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/h264_cabac.c')
-rw-r--r-- | libavcodec/h264_cabac.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c index 93652282b3..45a96506af 100644 --- a/libavcodec/h264_cabac.c +++ b/libavcodec/h264_cabac.c @@ -688,19 +688,20 @@ static const int8_t cabac_context_init_PB[3][460][2] = void ff_h264_init_cabac_states(H264Context *h) { MpegEncContext * const s = &h->s; int i; + const int8_t (*tab)[2]; + + if( h->slice_type_nos == FF_I_TYPE ) tab = cabac_context_init_I; + else tab = cabac_context_init_PB[h->cabac_init_idc]; /* calculate pre-state */ for( i= 0; i < 460; i++ ) { - int pre; - if( h->slice_type_nos == FF_I_TYPE ) - pre = av_clip( ((cabac_context_init_I[i][0] * s->qscale) >>4 ) + cabac_context_init_I[i][1], 1, 126 ); - else - pre = av_clip( ((cabac_context_init_PB[h->cabac_init_idc][i][0] * s->qscale) >>4 ) + cabac_context_init_PB[h->cabac_init_idc][i][1], 1, 126 ); + int pre = 2*(((tab[i][0] * s->qscale) >>4 ) + tab[i][1]) - 127; - if( pre <= 63 ) - h->cabac_state[i] = 2 * ( 63 - pre ) + 0; - else - h->cabac_state[i] = 2 * ( pre - 64 ) + 1; + pre^= pre>>31; + if(pre > 124) + pre= 124 + (pre&1); + + h->cabac_state[i] = pre; } } |