Revision a305449d libavcodec/h264_cabac.c

View differences:

libavcodec/h264_cabac.c
910 910
}
911 911

  
912 912
static int decode_cabac_mb_mvd( H264Context *h, int list, int n, int l ) {
913
    int amvd = abs( h->mvd_cache[list][scan8[n] - 1][l] ) +
914
               abs( h->mvd_cache[list][scan8[n] - 8][l] );
913
    int amvd = h->mvd_cache[list][scan8[n] - 1][l] +
914
               h->mvd_cache[list][scan8[n] - 8][l];
915 915
    int ctxbase = (l == 0) ? 40 : 47;
916 916
    int mvd;
917 917
    int ctx = (amvd>2) + (amvd>32);
......
1439 1439
                        my = mpy + decode_cabac_mb_mvd( h, list, index, 1 );
1440 1440
                        tprintf(s->avctx, "final mv:%d %d\n", mx, my);
1441 1441

  
1442
                        mpx= abs(mpx-mx);
1443
                        mpy= abs(mpy-my);
1442 1444
                        if(IS_SUB_8X8(sub_mb_type)){
1443 1445
                            mv_cache[ 1 ][0]=
1444 1446
                            mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx;
......
1446 1448
                            mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my;
1447 1449

  
1448 1450
                            mvd_cache[ 1 ][0]=
1449
                            mvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= mx - mpx;
1451
                            mvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= mpx;
1450 1452
                            mvd_cache[ 1 ][1]=
1451
                            mvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= my - mpy;
1453
                            mvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= mpy;
1452 1454
                        }else if(IS_SUB_8X4(sub_mb_type)){
1453 1455
                            mv_cache[ 1 ][0]= mx;
1454 1456
                            mv_cache[ 1 ][1]= my;
1455 1457

  
1456
                            mvd_cache[ 1 ][0]= mx - mpx;
1457
                            mvd_cache[ 1 ][1]= my - mpy;
1458
                            mvd_cache[ 1 ][0]=  mpx;
1459
                            mvd_cache[ 1 ][1]= mpy;
1458 1460
                        }else if(IS_SUB_4X8(sub_mb_type)){
1459 1461
                            mv_cache[ 8 ][0]= mx;
1460 1462
                            mv_cache[ 8 ][1]= my;
1461 1463

  
1462
                            mvd_cache[ 8 ][0]= mx - mpx;
1463
                            mvd_cache[ 8 ][1]= my - mpy;
1464
                            mvd_cache[ 8 ][0]= mpx;
1465
                            mvd_cache[ 8 ][1]= mpy;
1464 1466
                        }
1465 1467
                        mv_cache[ 0 ][0]= mx;
1466 1468
                        mv_cache[ 0 ][1]= my;
1467 1469

  
1468
                        mvd_cache[ 0 ][0]= mx - mpx;
1469
                        mvd_cache[ 0 ][1]= my - mpy;
1470
                        mvd_cache[ 0 ][0]= mpx;
1471
                        mvd_cache[ 0 ][1]= mpy;
1470 1472
                    }
1471 1473
                }else{
1472 1474
                    uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0];
......
1507 1509
                    my = mpy + decode_cabac_mb_mvd( h, list, 0, 1 );
1508 1510
                    tprintf(s->avctx, "final mv:%d %d\n", mx, my);
1509 1511

  
1510
                    fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
1512
                    fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(abs(mx-mpx),abs(my-mpy)), 4);
1511 1513
                    fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
1512 1514
                }else
1513 1515
                    fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, 0, 4);
......
1539 1541
                        my = mpy + decode_cabac_mb_mvd( h, list, 8*i, 1 );
1540 1542
                        tprintf(s->avctx, "final mv:%d %d\n", mx, my);
1541 1543

  
1542
                        fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx-mpx,my-mpy), 4);
1544
                        fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(abs(mx-mpx),abs(my-mpy)), 4);
1543 1545
                        fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4);
1544 1546
                    }else{
1545 1547
                        fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
......
1574 1576
                        my = mpy + decode_cabac_mb_mvd( h, list, 4*i, 1 );
1575 1577

  
1576 1578
                        tprintf(s->avctx, "final mv:%d %d\n", mx, my);
1577
                        fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
1579
                        fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(abs(mx-mpx),abs(my-mpy)), 4);
1578 1580
                        fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4);
1579 1581
                    }else{
1580 1582
                        fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);

Also available in: Unified diff