Commit 914b34e5 authored by michael's avatar michael

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.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@21859 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 9e9169fc
...@@ -688,19 +688,20 @@ static const int8_t cabac_context_init_PB[3][460][2] = ...@@ -688,19 +688,20 @@ static const int8_t cabac_context_init_PB[3][460][2] =
void ff_h264_init_cabac_states(H264Context *h) { void ff_h264_init_cabac_states(H264Context *h) {
MpegEncContext * const s = &h->s; MpegEncContext * const s = &h->s;
int i; 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 */ /* calculate pre-state */
for( i= 0; i < 460; i++ ) { for( i= 0; i < 460; i++ ) {
int pre; int pre = 2*(((tab[i][0] * s->qscale) >>4 ) + tab[i][1]) - 127;
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 );
if( pre <= 63 ) pre^= pre>>31;
h->cabac_state[i] = 2 * ( 63 - pre ) + 0; if(pre > 124)
else pre= 124 + (pre&1);
h->cabac_state[i] = 2 * ( pre - 64 ) + 1;
h->cabac_state[i] = pre;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment