mirror of https://git.ffmpeg.org/ffmpeg.git
Simplify H.264 decode_cabac_mb_cbp_luma(), giving a ~0.5% speedup.
patch by Andreas Öman, andreas olebyn nu Date: Thu, 20 Sep 2007 12:59:19 +0200 Subject: [FFmpeg-devel] [PATCH] simplify h264's decode_cabac_mb_cbp_luma() Originally committed as revision 10537 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
dee15eceae
commit
a27d6e714f
|
@ -4795,65 +4795,20 @@ static int decode_cabac_mb_chroma_pre_mode( H264Context *h) {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const uint8_t block_idx_x[16] = {
|
|
||||||
0, 1, 0, 1, 2, 3, 2, 3, 0, 1, 0, 1, 2, 3, 2, 3
|
|
||||||
};
|
|
||||||
static const uint8_t block_idx_y[16] = {
|
|
||||||
0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3
|
|
||||||
};
|
|
||||||
static const uint8_t block_idx_xy[4][4] = {
|
|
||||||
{ 0, 2, 8, 10},
|
|
||||||
{ 1, 3, 9, 11},
|
|
||||||
{ 4, 6, 12, 14},
|
|
||||||
{ 5, 7, 13, 15}
|
|
||||||
};
|
|
||||||
|
|
||||||
static int decode_cabac_mb_cbp_luma( H264Context *h) {
|
static int decode_cabac_mb_cbp_luma( H264Context *h) {
|
||||||
int cbp = 0;
|
int cbp_b, cbp_a, ctx, cbp = 0;
|
||||||
int cbp_b = -1;
|
|
||||||
int i8x8;
|
|
||||||
|
|
||||||
if( h->slice_table[h->top_mb_xy] == h->slice_num ) {
|
cbp_a = h->slice_table[h->left_mb_xy[0]] == h->slice_num ? h->left_cbp : -1;
|
||||||
cbp_b = h->top_cbp;
|
cbp_b = h->slice_table[h->top_mb_xy] == h->slice_num ? h->top_cbp : -1;
|
||||||
tprintf(h->s.avctx, "cbp_b = top_cbp = %x\n", cbp_b);
|
|
||||||
}
|
|
||||||
|
|
||||||
for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
|
ctx = !(cbp_a & 0x02) + 2 * !(cbp_b & 0x04);
|
||||||
int cbp_a = -1;
|
cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]);
|
||||||
int x, y;
|
ctx = !(cbp & 0x01) + 2 * !(cbp_b & 0x08);
|
||||||
int ctx = 0;
|
cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 1;
|
||||||
|
ctx = !(cbp_a & 0x08) + 2 * !(cbp & 0x01);
|
||||||
x = block_idx_x[4*i8x8];
|
cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 2;
|
||||||
y = block_idx_y[4*i8x8];
|
ctx = !(cbp & 0x04) + 2 * !(cbp & 0x02);
|
||||||
|
cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 3;
|
||||||
if( x > 0 )
|
|
||||||
cbp_a = cbp;
|
|
||||||
else if( h->slice_table[h->left_mb_xy[0]] == h->slice_num ) {
|
|
||||||
cbp_a = h->left_cbp;
|
|
||||||
tprintf(h->s.avctx, "cbp_a = left_cbp = %x\n", cbp_a);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( y > 0 )
|
|
||||||
cbp_b = cbp;
|
|
||||||
|
|
||||||
/* No need to test for skip as we put 0 for skip block */
|
|
||||||
/* No need to test for IPCM as we put 1 for IPCM block */
|
|
||||||
if( cbp_a >= 0 ) {
|
|
||||||
int i8x8a = block_idx_xy[(x-1)&0x03][y]/4;
|
|
||||||
if( ((cbp_a >> i8x8a)&0x01) == 0 )
|
|
||||||
ctx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cbp_b >= 0 ) {
|
|
||||||
int i8x8b = block_idx_xy[x][(y-1)&0x03]/4;
|
|
||||||
if( ((cbp_b >> i8x8b)&0x01) == 0 )
|
|
||||||
ctx += 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( get_cabac( &h->cabac, &h->cabac_state[73 + ctx] ) ) {
|
|
||||||
cbp |= 1 << i8x8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cbp;
|
return cbp;
|
||||||
}
|
}
|
||||||
static int decode_cabac_mb_cbp_chroma( H264Context *h) {
|
static int decode_cabac_mb_cbp_chroma( H264Context *h) {
|
||||||
|
|
Loading…
Reference in New Issue