Ticket #113: ffmpeg-mbcabac-loops.patch

File ffmpeg-mbcabac-loops.patch, 1.5 kB (added by astrange, 2 years ago)

Small change in cabac, small but positive speed gain.

  • h264.c

    old new  
    56555655        const int mba_xy = h->left_mb_xy[0]; 
    56565656        const int mbb_xy = h->top_mb_xy; 
    56575657        int ctx = 0; 
    5658         int bits
     5658        int bits, i = 2
    56595659 
    56605660        if( h->slice_table[mba_xy] == h->slice_num && !IS_DIRECT( s->current_picture.mb_type[mba_xy] ) ) 
    56615661            ctx++; 
     
    56705670        } 
    56715671 
    56725672        bits = get_cabac_noinline( &h->cabac, &h->cabac_state[27+4] ) << 3; 
    5673         bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 2; 
    5674         bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 1; 
    5675         bits|= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ); 
     5673        for (; i >= 0; i--) bits |= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << i; 
     5674 
    56765675        if( bits < 8 ) 
    56775676            return bits + 3; /* B_Bi_16x16 through B_L1_L0_16x8 */ 
    56785677        else if( bits == 13 ) { 
     
    57275726} 
    57285727 
    57295728static int decode_cabac_mb_intra4x4_pred_mode( H264Context *h, int pred_mode ) { 
    5730     int mode = 0
     5729    int mode = 0, i = 0
    57315730 
    57325731    if( get_cabac( &h->cabac, &h->cabac_state[68] ) ) 
    57335732        return pred_mode; 
    57345733 
    5735     mode += 1 * get_cabac( &h->cabac, &h->cabac_state[69] ); 
    5736     mode += 2 * get_cabac( &h->cabac, &h->cabac_state[69] ); 
    5737     mode += 4 * get_cabac( &h->cabac, &h->cabac_state[69] ); 
     5734    for (; i <= 2; i++) mode |= get_cabac( &h->cabac, &h->cabac_state[69] ) << i; 
    57385735 
    57395736    if( mode >= pred_mode ) 
    57405737        return mode + 1;