comparison h264.c @ 8436:59171c70bc9f libavcodec

inline decode_cabac_mb_type for I & P frames, 9 cycles faster on pentium dual.
author michael
date Mon, 22 Dec 2008 16:46:17 +0000
parents adab508880c6
children 94c16f1cd5cf
comparison
equal deleted inserted replaced
8435:adab508880c6 8436:59171c70bc9f
4775 mb_type += 2 * get_cabac_noinline( &h->cabac, &state[3+intra_slice] ); 4775 mb_type += 2 * get_cabac_noinline( &h->cabac, &state[3+intra_slice] );
4776 mb_type += 1 * get_cabac_noinline( &h->cabac, &state[3+2*intra_slice] ); 4776 mb_type += 1 * get_cabac_noinline( &h->cabac, &state[3+2*intra_slice] );
4777 return mb_type; 4777 return mb_type;
4778 } 4778 }
4779 4779
4780 static int decode_cabac_mb_type( H264Context *h ) { 4780 static int decode_cabac_mb_type_b( H264Context *h ) {
4781 MpegEncContext * const s = &h->s; 4781 MpegEncContext * const s = &h->s;
4782 4782
4783 if( h->slice_type_nos == FF_I_TYPE ) {
4784 return decode_cabac_intra_mb_type(h, 3, 1);
4785 } else if( h->slice_type_nos == FF_P_TYPE ) {
4786 if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) {
4787 /* P-type */
4788 if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) {
4789 /* P_L0_D16x16, P_8x8 */
4790 return 3 * get_cabac_noinline( &h->cabac, &h->cabac_state[16] );
4791 } else {
4792 /* P_L0_D8x16, P_L0_D16x8 */
4793 return 2 - get_cabac_noinline( &h->cabac, &h->cabac_state[17] );
4794 }
4795 } else {
4796 return decode_cabac_intra_mb_type(h, 17, 0) + 5;
4797 }
4798 } else {
4799 const int mba_xy = h->left_mb_xy[0]; 4783 const int mba_xy = h->left_mb_xy[0];
4800 const int mbb_xy = h->top_mb_xy; 4784 const int mbb_xy = h->top_mb_xy;
4801 int ctx = 0; 4785 int ctx = 0;
4802 int bits; 4786 int bits;
4803 assert(h->slice_type_nos == FF_B_TYPE); 4787 assert(h->slice_type_nos == FF_B_TYPE);
4827 else if( bits == 15 ) 4811 else if( bits == 15 )
4828 return 22; /* B_8x8 */ 4812 return 22; /* B_8x8 */
4829 4813
4830 bits= ( bits<<1 ) | get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ); 4814 bits= ( bits<<1 ) | get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] );
4831 return bits - 4; /* B_L0_Bi_* through B_Bi_Bi_* */ 4815 return bits - 4; /* B_L0_Bi_* through B_Bi_Bi_* */
4832 }
4833 } 4816 }
4834 4817
4835 static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) { 4818 static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) {
4836 MpegEncContext * const s = &h->s; 4819 MpegEncContext * const s = &h->s;
4837 int mba_xy, mbb_xy; 4820 int mba_xy, mbb_xy;
5363 } 5346 }
5364 5347
5365 h->prev_mb_skipped = 0; 5348 h->prev_mb_skipped = 0;
5366 5349
5367 compute_mb_neighbors(h); 5350 compute_mb_neighbors(h);
5368 mb_type = decode_cabac_mb_type( h );
5369 assert(mb_type >= 0);
5370 5351
5371 if( h->slice_type_nos == FF_B_TYPE ) { 5352 if( h->slice_type_nos == FF_B_TYPE ) {
5353 mb_type = decode_cabac_mb_type_b( h );
5372 if( mb_type < 23 ){ 5354 if( mb_type < 23 ){
5373 partition_count= b_mb_type_info[mb_type].partition_count; 5355 partition_count= b_mb_type_info[mb_type].partition_count;
5374 mb_type= b_mb_type_info[mb_type].type; 5356 mb_type= b_mb_type_info[mb_type].type;
5375 }else{ 5357 }else{
5376 mb_type -= 23; 5358 mb_type -= 23;
5377 goto decode_intra_mb; 5359 goto decode_intra_mb;
5378 } 5360 }
5379 } else if( h->slice_type_nos == FF_P_TYPE ) { 5361 } else if( h->slice_type_nos == FF_P_TYPE ) {
5380 if( mb_type < 5) { 5362 if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) {
5363 /* P-type */
5364 if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) {
5365 /* P_L0_D16x16, P_8x8 */
5366 mb_type= 3 * get_cabac_noinline( &h->cabac, &h->cabac_state[16] );
5367 } else {
5368 /* P_L0_D8x16, P_L0_D16x8 */
5369 mb_type= 2 - get_cabac_noinline( &h->cabac, &h->cabac_state[17] );
5370 }
5381 partition_count= p_mb_type_info[mb_type].partition_count; 5371 partition_count= p_mb_type_info[mb_type].partition_count;
5382 mb_type= p_mb_type_info[mb_type].type; 5372 mb_type= p_mb_type_info[mb_type].type;
5383 } else { 5373 } else {
5384 mb_type -= 5; 5374 mb_type= decode_cabac_intra_mb_type(h, 17, 0);
5385 goto decode_intra_mb; 5375 goto decode_intra_mb;
5386 } 5376 }
5387 } else { 5377 } else {
5378 mb_type= decode_cabac_intra_mb_type(h, 3, 1);
5388 if(h->slice_type == FF_SI_TYPE && mb_type) 5379 if(h->slice_type == FF_SI_TYPE && mb_type)
5389 mb_type--; 5380 mb_type--;
5390 assert(h->slice_type_nos == FF_I_TYPE); 5381 assert(h->slice_type_nos == FF_I_TYPE);
5391 decode_intra_mb: 5382 decode_intra_mb:
5392 partition_count = 0; 5383 partition_count = 0;