Mercurial > libavcodec.hg
comparison h264_cabac.c @ 11181:63f55748173c libavcodec
Merge decode_cabac_mb_type_b() into calling code.
This avoids a conditional branch and is about 3 cpu cyclues faster.
author | michael |
---|---|
date | Mon, 15 Feb 2010 19:20:49 +0000 |
parents | 458393d0db0a |
children | 0c93bb2b3cb0 |
comparison
equal
deleted
inserted
replaced
11180:0b2618b091df | 11181:63f55748173c |
---|---|
746 if( get_cabac_noinline( &h->cabac, &state[2] ) ) /* cbp_chroma */ | 746 if( get_cabac_noinline( &h->cabac, &state[2] ) ) /* cbp_chroma */ |
747 mb_type += 4 + 4 * get_cabac_noinline( &h->cabac, &state[2+intra_slice] ); | 747 mb_type += 4 + 4 * get_cabac_noinline( &h->cabac, &state[2+intra_slice] ); |
748 mb_type += 2 * get_cabac_noinline( &h->cabac, &state[3+intra_slice] ); | 748 mb_type += 2 * get_cabac_noinline( &h->cabac, &state[3+intra_slice] ); |
749 mb_type += 1 * get_cabac_noinline( &h->cabac, &state[3+2*intra_slice] ); | 749 mb_type += 1 * get_cabac_noinline( &h->cabac, &state[3+2*intra_slice] ); |
750 return mb_type; | 750 return mb_type; |
751 } | |
752 | |
753 static int decode_cabac_mb_type_b( H264Context *h ) { | |
754 MpegEncContext * const s = &h->s; | |
755 | |
756 const int mba_xy = h->left_mb_xy[0]; | |
757 const int mbb_xy = h->top_mb_xy; | |
758 int ctx = 0; | |
759 int bits; | |
760 assert(h->slice_type_nos == FF_B_TYPE); | |
761 | |
762 if( h->slice_table[mba_xy] == h->slice_num && !IS_DIRECT( s->current_picture.mb_type[mba_xy] ) ) | |
763 ctx++; | |
764 if( h->slice_table[mbb_xy] == h->slice_num && !IS_DIRECT( s->current_picture.mb_type[mbb_xy] ) ) | |
765 ctx++; | |
766 | |
767 if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+ctx] ) ) | |
768 return 0; /* B_Direct_16x16 */ | |
769 | |
770 if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+3] ) ) { | |
771 return 1 + get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ); /* B_L[01]_16x16 */ | |
772 } | |
773 | |
774 bits = get_cabac_noinline( &h->cabac, &h->cabac_state[27+4] ) << 3; | |
775 bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 2; | |
776 bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 1; | |
777 bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ); | |
778 if( bits < 8 ) | |
779 return bits + 3; /* B_Bi_16x16 through B_L1_L0_16x8 */ | |
780 else if( bits == 13 ) { | |
781 return decode_cabac_intra_mb_type(h, 32, 0) + 23; | |
782 } else if( bits == 14 ) | |
783 return 11; /* B_L1_L0_8x16 */ | |
784 else if( bits == 15 ) | |
785 return 22; /* B_8x8 */ | |
786 | |
787 bits= ( bits<<1 ) | get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ); | |
788 return bits - 4; /* B_L0_Bi_* through B_Bi_Bi_* */ | |
789 } | 751 } |
790 | 752 |
791 static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) { | 753 static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) { |
792 MpegEncContext * const s = &h->s; | 754 MpegEncContext * const s = &h->s; |
793 int mba_xy, mbb_xy; | 755 int mba_xy, mbb_xy; |
1299 h->prev_mb_skipped = 0; | 1261 h->prev_mb_skipped = 0; |
1300 | 1262 |
1301 compute_mb_neighbors(h); | 1263 compute_mb_neighbors(h); |
1302 | 1264 |
1303 if( h->slice_type_nos == FF_B_TYPE ) { | 1265 if( h->slice_type_nos == FF_B_TYPE ) { |
1304 mb_type = decode_cabac_mb_type_b( h ); | 1266 const int mba_xy = h->left_mb_xy[0]; |
1305 if( mb_type < 23 ){ | 1267 const int mbb_xy = h->top_mb_xy; |
1268 int ctx = 0; | |
1269 assert(h->slice_type_nos == FF_B_TYPE); | |
1270 | |
1271 if( h->slice_table[mba_xy] == h->slice_num && !IS_DIRECT( s->current_picture.mb_type[mba_xy] ) ) | |
1272 ctx++; | |
1273 if( h->slice_table[mbb_xy] == h->slice_num && !IS_DIRECT( s->current_picture.mb_type[mbb_xy] ) ) | |
1274 ctx++; | |
1275 | |
1276 if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+ctx] ) ){ | |
1277 mb_type= 0; /* B_Direct_16x16 */ | |
1278 }else if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+3] ) ) { | |
1279 mb_type= 1 + get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ); /* B_L[01]_16x16 */ | |
1280 }else{ | |
1281 int bits; | |
1282 bits = get_cabac_noinline( &h->cabac, &h->cabac_state[27+4] ) << 3; | |
1283 bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 2; | |
1284 bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 1; | |
1285 bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ); | |
1286 if( bits < 8 ){ | |
1287 mb_type= bits + 3; /* B_Bi_16x16 through B_L1_L0_16x8 */ | |
1288 }else if( bits == 13 ){ | |
1289 mb_type= decode_cabac_intra_mb_type(h, 32, 0); | |
1290 goto decode_intra_mb; | |
1291 }else if( bits == 14 ){ | |
1292 mb_type= 11; /* B_L1_L0_8x16 */ | |
1293 }else if( bits == 15 ){ | |
1294 mb_type= 22; /* B_8x8 */ | |
1295 }else{ | |
1296 bits= ( bits<<1 ) | get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ); | |
1297 mb_type= bits - 4; /* B_L0_Bi_* through B_Bi_Bi_* */ | |
1298 } | |
1299 } | |
1306 partition_count= b_mb_type_info[mb_type].partition_count; | 1300 partition_count= b_mb_type_info[mb_type].partition_count; |
1307 mb_type= b_mb_type_info[mb_type].type; | 1301 mb_type= b_mb_type_info[mb_type].type; |
1308 }else{ | |
1309 mb_type -= 23; | |
1310 goto decode_intra_mb; | |
1311 } | |
1312 } else if( h->slice_type_nos == FF_P_TYPE ) { | 1302 } else if( h->slice_type_nos == FF_P_TYPE ) { |
1313 if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) { | 1303 if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) { |
1314 /* P-type */ | 1304 /* P-type */ |
1315 if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) { | 1305 if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) { |
1316 /* P_L0_D16x16, P_8x8 */ | 1306 /* P_L0_D16x16, P_8x8 */ |