Revision 01b35be1 libavcodec/h264_cabac.c

View differences:

libavcodec/h264_cabac.c
909 909
    return ref;
910 910
}
911 911

  
912
static int decode_cabac_mb_mvd( H264Context *h, int list, int n, int l ) {
913
    int amvd = h->mvd_cache[list][scan8[n] - 1][l] +
914
               h->mvd_cache[list][scan8[n] - 8][l];
915
    int ctxbase = (l == 0) ? 40 : 47;
912
static int decode_cabac_mb_mvd( H264Context *h, int ctxbase, int amvd ) {
916 913
    int mvd;
917 914

  
918 915
    if(!get_cabac(&h->cabac, &h->cabac_state[ctxbase+FFMIN(((amvd+28)*17)>>9,2)]))
......
943 940
    return get_cabac_bypass_sign( &h->cabac, -mvd );
944 941
}
945 942

  
943
#define DECODE_CABAC_MB_MVD( h,  list,  n )\
944
{\
945
    int amvd0 = h->mvd_cache[list][scan8[n] - 1][0] +\
946
                h->mvd_cache[list][scan8[n] - 8][0];\
947
    int amvd1 = h->mvd_cache[list][scan8[n] - 1][1] +\
948
                h->mvd_cache[list][scan8[n] - 8][1];\
949
\
950
    mx = mpx + decode_cabac_mb_mvd( h, 40, amvd0 );\
951
    my = mpy + decode_cabac_mb_mvd( h, 47, amvd1 );\
952
}
953

  
946 954
static av_always_inline int get_cabac_cbf_ctx( H264Context *h, int cat, int idx, int is_dc ) {
947 955
    int nza, nzb;
948 956
    int ctx = 0;
......
1433 1441
                        int16_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[index] ];
1434 1442
                        pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mpx, &mpy);
1435 1443

  
1436
                        mx = mpx + decode_cabac_mb_mvd( h, list, index, 0 );
1437
                        my = mpy + decode_cabac_mb_mvd( h, list, index, 1 );
1444
                        DECODE_CABAC_MB_MVD( h, list, index)
1438 1445
                        tprintf(s->avctx, "final mv:%d %d\n", mx, my);
1439 1446

  
1440 1447
                        mpx= abs(mpx-mx);
......
1500 1507
            for(list=0; list<h->list_count; list++){
1501 1508
                if(IS_DIR(mb_type, 0, list)){
1502 1509
                    pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mpx, &mpy);
1503

  
1504
                    mx = mpx + decode_cabac_mb_mvd( h, list, 0, 0 );
1505
                    my = mpy + decode_cabac_mb_mvd( h, list, 0, 1 );
1510
                    DECODE_CABAC_MB_MVD( h, list, 0)
1506 1511
                    tprintf(s->avctx, "final mv:%d %d\n", mx, my);
1507 1512

  
1508 1513
                    fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(abs(mx-mpx),abs(my-mpy)), 4);
......
1533 1538
                for(i=0; i<2; i++){
1534 1539
                    if(IS_DIR(mb_type, i, list)){
1535 1540
                        pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mpx, &mpy);
1536
                        mx = mpx + decode_cabac_mb_mvd( h, list, 8*i, 0 );
1537
                        my = mpy + decode_cabac_mb_mvd( h, list, 8*i, 1 );
1541
                        DECODE_CABAC_MB_MVD( h, list, 8*i)
1538 1542
                        tprintf(s->avctx, "final mv:%d %d\n", mx, my);
1539 1543

  
1540 1544
                        fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(abs(mx-mpx),abs(my-mpy)), 4);
......
1568 1572
                for(i=0; i<2; i++){
1569 1573
                    if(IS_DIR(mb_type, i, list)){
1570 1574
                        pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mpx, &mpy);
1571
                        mx = mpx + decode_cabac_mb_mvd( h, list, 4*i, 0 );
1572
                        my = mpy + decode_cabac_mb_mvd( h, list, 4*i, 1 );
1575
                        DECODE_CABAC_MB_MVD( h, list, 4*i)
1573 1576

  
1574 1577
                        tprintf(s->avctx, "final mv:%d %d\n", mx, my);
1575 1578
                        fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(abs(mx-mpx),abs(my-mpy)), 4);

Also available in: Unified diff