Revision 316a2ec8 libavcodec/motion_est.c
libavcodec/motion_est.c  

1617  1617 
/* refine the bidir vectors in hq mode and return the score in both lq & hq mode*/ 
1618  1618 
static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y) 
1619  1619 
{ 
1620 
MotionEstContext * const c= &s>me; 

1620  1621 
const int mot_stride = s>mb_stride; 
1621  1622 
const int xy = mb_y *mot_stride + mb_x; 
1622  1623 
int fbmin; 
...  ...  
1628  1629 
int motion_fy= s>b_bidir_forw_mv_table[xy][1]= s>b_forw_mv_table[xy][1]; 
1629  1630 
int motion_bx= s>b_bidir_back_mv_table[xy][0]= s>b_back_mv_table[xy][0]; 
1630  1631 
int motion_by= s>b_bidir_back_mv_table[xy][1]= s>b_back_mv_table[xy][1]; 
1631  
1632 
//FIXME do refinement and add flag 

1632 
const int flags= c>sub_flags; 

1633 
const int qpel= flags&FLAG_QPEL; 

1634 
const int shift= 1+qpel; 

1635 
const int xmin= c>xmin<<shift; 

1636 
const int ymin= c>ymin<<shift; 

1637 
const int xmax= c>xmax<<shift; 

1638 
const int ymax= c>ymax<<shift; 

1633  1639  
1634  1640 
fbmin= check_bidir_mv(s, motion_fx, motion_fy, 
1635  1641 
motion_bx, motion_by, 
...  ...  
1637  1643 
pred_bx, pred_by, 
1638  1644 
0, 16); 
1639  1645  
1640 
return fbmin; 

1646 
if(s>avctx>bidir_refine){ 

1647 
int score, end; 

1648 
#define CHECK_BIDIR(fx,fy,bx,by)\ 

1649 
score= check_bidir_mv(s, motion_fx+fx, motion_fy+fy, motion_bx+bx, motion_by+by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16);\ 

1650 
if(score < fbmin){\ 

1651 
fbmin= score;\ 

1652 
motion_fx+=fx;\ 

1653 
motion_fy+=fy;\ 

1654 
motion_bx+=bx;\ 

1655 
motion_by+=by;\ 

1656 
end=0;\ 

1657 
} 

1658 
#define CHECK_BIDIR2(a,b,c,d)\ 

1659 
CHECK_BIDIR(a,b,c,d)\ 

1660 
CHECK_BIDIR(a,b,c,d) 

1661  
1662 
#define CHECK_BIDIRR(a,b,c,d)\ 

1663 
CHECK_BIDIR2(a,b,c,d)\ 

1664 
CHECK_BIDIR2(b,c,d,a)\ 

1665 
CHECK_BIDIR2(c,d,a,b)\ 

1666 
CHECK_BIDIR2(d,a,b,c) 

1667  
1668 
do{ 

1669 
end=1; 

1670  
1671 
if( motion_fx >= xmax  motion_bx >= xmax  motion_fx <= xmin  motion_bx <= xmin 

1672 
 motion_fy >= ymax  motion_by >= ymax  motion_fy <= ymin  motion_by <= ymin) 

1673 
break; 

1674  
1675 
CHECK_BIDIRR( 0, 0, 0, 1) 

1676 
if(s>avctx>bidir_refine > 1){ 

1677 
CHECK_BIDIRR( 0, 0, 1, 1) 

1678 
CHECK_BIDIR2( 0, 1, 0, 1) 

1679 
CHECK_BIDIR2( 1, 0, 1, 0) 

1680 
CHECK_BIDIRR( 0, 0,1, 1) 

1681 
CHECK_BIDIR2( 0,1, 0, 1) 

1682 
CHECK_BIDIR2(1, 0, 1, 0) 

1683 
if(s>avctx>bidir_refine > 2){ 

1684 
CHECK_BIDIRR( 0, 1, 1, 1) 

1685 
CHECK_BIDIRR( 0,1, 1, 1) 

1686 
CHECK_BIDIRR( 0, 1,1, 1) 

1687 
CHECK_BIDIRR( 0, 1, 1,1) 

1688 
if(s>avctx>bidir_refine > 3){ 

1689 
CHECK_BIDIR2( 1, 1, 1, 1) 

1690 
CHECK_BIDIRR( 1, 1, 1,1) 

1691 
CHECK_BIDIR2( 1, 1,1,1) 

1692 
CHECK_BIDIR2( 1,1,1, 1) 

1693 
CHECK_BIDIR2( 1,1, 1,1) 

1694 
} 

1695 
} 

1696 
} 

1697 
}while(!end); 

1698 
} 

1699  
1700 
return fbmin; 

1641  1701 
} 
1642  1702  
1643  1703 
static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y) 
Also available in: Unified diff