Commit a89386da authored by lorenm's avatar lorenm

minor simplifications in cabac_mb_type


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@5048 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 669c9da7
...@@ -5247,19 +5247,11 @@ static int decode_cabac_intra_mb_type(H264Context *h, int ctx_base, int intra_sl ...@@ -5247,19 +5247,11 @@ static int decode_cabac_intra_mb_type(H264Context *h, int ctx_base, int intra_sl
return 25; /* PCM */ return 25; /* PCM */
mb_type = 1; /* I16x16 */ mb_type = 1; /* I16x16 */
if( get_cabac( &h->cabac, &state[1] ) ) mb_type += 12 * get_cabac( &h->cabac, &state[1] ); /* cbp_luma != 0 */
mb_type += 12; /* cbp_luma != 0 */ if( get_cabac( &h->cabac, &state[2] ) ) /* cbp_chroma */
mb_type += 4 + 4 * get_cabac( &h->cabac, &state[2+intra_slice] );
if( get_cabac( &h->cabac, &state[2] ) ) { mb_type += 2 * get_cabac( &h->cabac, &state[3+intra_slice] );
if( get_cabac( &h->cabac, &state[2+intra_slice] ) ) mb_type += 1 * get_cabac( &h->cabac, &state[3+2*intra_slice] );
mb_type += 4 * 2; /* cbp_chroma == 2 */
else
mb_type += 4 * 1; /* cbp_chroma == 1 */
}
if( get_cabac( &h->cabac, &state[3+intra_slice] ) )
mb_type += 2;
if( get_cabac( &h->cabac, &state[3+2*intra_slice] ) )
mb_type += 1;
return mb_type; return mb_type;
} }
...@@ -5272,15 +5264,11 @@ static int decode_cabac_mb_type( H264Context *h ) { ...@@ -5272,15 +5264,11 @@ static int decode_cabac_mb_type( H264Context *h ) {
if( get_cabac( &h->cabac, &h->cabac_state[14] ) == 0 ) { if( get_cabac( &h->cabac, &h->cabac_state[14] ) == 0 ) {
/* P-type */ /* P-type */
if( get_cabac( &h->cabac, &h->cabac_state[15] ) == 0 ) { if( get_cabac( &h->cabac, &h->cabac_state[15] ) == 0 ) {
if( get_cabac( &h->cabac, &h->cabac_state[16] ) == 0 ) /* P_L0_D16x16, P_8x8 */
return 0; /* P_L0_D16x16; */ return 3 * get_cabac( &h->cabac, &h->cabac_state[16] );
else
return 3; /* P_8x8; */
} else { } else {
if( get_cabac( &h->cabac, &h->cabac_state[17] ) == 0 ) /* P_L0_D8x16, P_L0_D16x8 */
return 2; /* P_L0_D8x16; */ return 2 - get_cabac( &h->cabac, &h->cabac_state[17] );
else
return 1; /* P_L0_D16x8; */
} }
} else { } else {
return decode_cabac_intra_mb_type(h, 17, 0) + 5; return decode_cabac_intra_mb_type(h, 17, 0) + 5;
...@@ -5291,11 +5279,9 @@ static int decode_cabac_mb_type( H264Context *h ) { ...@@ -5291,11 +5279,9 @@ static int decode_cabac_mb_type( H264Context *h ) {
int ctx = 0; int ctx = 0;
int bits; int bits;
if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mba_xy] ) if( h->slice_table[mba_xy] == h->slice_num && !IS_DIRECT( s->current_picture.mb_type[mba_xy] ) )
&& !IS_DIRECT( s->current_picture.mb_type[mba_xy] ) )
ctx++; ctx++;
if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mbb_xy] ) if( h->slice_table[mbb_xy] == h->slice_num && !IS_DIRECT( s->current_picture.mb_type[mbb_xy] ) )
&& !IS_DIRECT( s->current_picture.mb_type[mbb_xy] ) )
ctx++; ctx++;
if( !get_cabac( &h->cabac, &h->cabac_state[27+ctx] ) ) if( !get_cabac( &h->cabac, &h->cabac_state[27+ctx] ) )
...@@ -5338,10 +5324,9 @@ static int decode_cabac_mb_skip( H264Context *h) { ...@@ -5338,10 +5324,9 @@ static int decode_cabac_mb_skip( H264Context *h) {
if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mbb_xy] )) if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.mb_type[mbb_xy] ))
ctx++; ctx++;
if( h->slice_type == P_TYPE || h->slice_type == SP_TYPE) if( h->slice_type == B_TYPE )
ctx += 13;
return get_cabac( &h->cabac, &h->cabac_state[11+ctx] ); return get_cabac( &h->cabac, &h->cabac_state[11+ctx] );
else /* B-frame */
return get_cabac( &h->cabac, &h->cabac_state[24+ctx] );
} }
static int decode_cabac_mb_intra4x4_pred_mode( H264Context *h, int pred_mode ) { static int decode_cabac_mb_intra4x4_pred_mode( H264Context *h, int pred_mode ) {
...@@ -5401,11 +5386,16 @@ static int decode_cabac_mb_cbp_luma( H264Context *h) { ...@@ -5401,11 +5386,16 @@ static int decode_cabac_mb_cbp_luma( H264Context *h) {
MpegEncContext * const s = &h->s; MpegEncContext * const s = &h->s;
int cbp = 0; int cbp = 0;
int cbp_b = -1;
int i8x8; int i8x8;
if( h->slice_table[h->top_mb_xy] == h->slice_num ) {
cbp_b = h->top_cbp;
tprintf("cbp_b = top_cbp = %x\n", cbp_b);
}
for( i8x8 = 0; i8x8 < 4; i8x8++ ) { for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
int cbp_a = -1; int cbp_a = -1;
int cbp_b = -1;
int x, y; int x, y;
int ctx = 0; int ctx = 0;
...@@ -5414,17 +5404,13 @@ static int decode_cabac_mb_cbp_luma( H264Context *h) { ...@@ -5414,17 +5404,13 @@ static int decode_cabac_mb_cbp_luma( H264Context *h) {
if( x > 0 ) if( x > 0 )
cbp_a = cbp; cbp_a = cbp;
else if( s->mb_x > 0 && (h->slice_table[h->left_mb_xy[0]] == h->slice_num)) { else if( h->slice_table[h->left_mb_xy[0]] == h->slice_num ) {
cbp_a = h->left_cbp; cbp_a = h->left_cbp;
tprintf("cbp_a = left_cbp = %x\n", cbp_a); tprintf("cbp_a = left_cbp = %x\n", cbp_a);
} }
if( y > 0 ) if( y > 0 )
cbp_b = cbp; cbp_b = cbp;
else if( s->mb_y > 0 && (h->slice_table[h->top_mb_xy] == h->slice_num)) {
cbp_b = h->top_cbp;
tprintf("cbp_b = top_cbp = %x\n", cbp_b);
}
/* No need to test for skip as we put 0 for skip block */ /* 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 */ /* No need to test for IPCM as we put 1 for IPCM block */
......
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