Revision f4060611 libavcodec/h264_cabac.c

View differences:

libavcodec/h264_cabac.c
750 750
    return mb_type;
751 751
}
752 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
}
790

  
791 753
static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) {
792 754
    MpegEncContext * const s = &h->s;
793 755
    int mba_xy, mbb_xy;
......
1301 1263
    compute_mb_neighbors(h);
1302 1264

  
1303 1265
    if( h->slice_type_nos == FF_B_TYPE ) {
1304
        mb_type = decode_cabac_mb_type_b( h );
1305
        if( mb_type < 23 ){
1306
            partition_count= b_mb_type_info[mb_type].partition_count;
1307
            mb_type=         b_mb_type_info[mb_type].type;
1266
        const int mba_xy = h->left_mb_xy[0];
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 */
1308 1280
        }else{
1309
            mb_type -= 23;
1310
            goto decode_intra_mb;
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
            }
1311 1299
        }
1300
            partition_count= b_mb_type_info[mb_type].partition_count;
1301
            mb_type=         b_mb_type_info[mb_type].type;
1312 1302
    } else if( h->slice_type_nos == FF_P_TYPE ) {
1313 1303
        if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) {
1314 1304
            /* P-type */

Also available in: Unified diff