summaryrefslogtreecommitdiff
path: root/libavcodec/h264.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2008-12-22 16:46:17 +0000
committerMichael Niedermayer <michaelni@gmx.at>2008-12-22 16:46:17 +0000
commitb68a4553138ae1eee043f9b6b791b613726f87b6 (patch)
treed4169f6d5e976a5ed2c35d090d80be06423bdb6d /libavcodec/h264.c
parent1952ac3713834e0e14f5700157c635acdb4da6f9 (diff)
inline decode_cabac_mb_type for I & P frames, 9 cycles faster on pentium dual.
Originally committed as revision 16277 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r--libavcodec/h264.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 90e4190eda..4bf621dab0 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -4777,25 +4777,9 @@ static int decode_cabac_intra_mb_type(H264Context *h, int ctx_base, int intra_sl
return mb_type;
}
-static int decode_cabac_mb_type( H264Context *h ) {
+static int decode_cabac_mb_type_b( H264Context *h ) {
MpegEncContext * const s = &h->s;
- if( h->slice_type_nos == FF_I_TYPE ) {
- return decode_cabac_intra_mb_type(h, 3, 1);
- } else if( h->slice_type_nos == FF_P_TYPE ) {
- if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) {
- /* P-type */
- if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) {
- /* P_L0_D16x16, P_8x8 */
- return 3 * get_cabac_noinline( &h->cabac, &h->cabac_state[16] );
- } else {
- /* P_L0_D8x16, P_L0_D16x8 */
- return 2 - get_cabac_noinline( &h->cabac, &h->cabac_state[17] );
- }
- } else {
- return decode_cabac_intra_mb_type(h, 17, 0) + 5;
- }
- } else {
const int mba_xy = h->left_mb_xy[0];
const int mbb_xy = h->top_mb_xy;
int ctx = 0;
@@ -4829,7 +4813,6 @@ static int decode_cabac_mb_type( H264Context *h ) {
bits= ( bits<<1 ) | get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] );
return bits - 4; /* B_L0_Bi_* through B_Bi_Bi_* */
- }
}
static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) {
@@ -5365,10 +5348,9 @@ static int decode_mb_cabac(H264Context *h) {
h->prev_mb_skipped = 0;
compute_mb_neighbors(h);
- mb_type = decode_cabac_mb_type( h );
- assert(mb_type >= 0);
if( h->slice_type_nos == FF_B_TYPE ) {
+ mb_type = decode_cabac_mb_type_b( h );
if( mb_type < 23 ){
partition_count= b_mb_type_info[mb_type].partition_count;
mb_type= b_mb_type_info[mb_type].type;
@@ -5377,14 +5359,23 @@ static int decode_mb_cabac(H264Context *h) {
goto decode_intra_mb;
}
} else if( h->slice_type_nos == FF_P_TYPE ) {
- if( mb_type < 5) {
+ if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) {
+ /* P-type */
+ if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) {
+ /* P_L0_D16x16, P_8x8 */
+ mb_type= 3 * get_cabac_noinline( &h->cabac, &h->cabac_state[16] );
+ } else {
+ /* P_L0_D8x16, P_L0_D16x8 */
+ mb_type= 2 - get_cabac_noinline( &h->cabac, &h->cabac_state[17] );
+ }
partition_count= p_mb_type_info[mb_type].partition_count;
mb_type= p_mb_type_info[mb_type].type;
} else {
- mb_type -= 5;
+ mb_type= decode_cabac_intra_mb_type(h, 17, 0);
goto decode_intra_mb;
}
} else {
+ mb_type= decode_cabac_intra_mb_type(h, 3, 1);
if(h->slice_type == FF_SI_TYPE && mb_type)
mb_type--;
assert(h->slice_type_nos == FF_I_TYPE);