Mercurial > libavcodec.hg
comparison motion_est.c @ 3026:10934895be5a libavcodec
10l: bidir_refine didn't save the new mvs. also improve speed.
author | lorenm |
---|---|
date | Mon, 09 Jan 2006 02:08:12 +0000 |
parents | 8f9eab06237b |
children | 0b546eab515d |
comparison
equal
deleted
inserted
replaced
3025:8a7d694a21eb | 3026:10934895be5a |
---|---|
1634 const int shift= 1+qpel; | 1634 const int shift= 1+qpel; |
1635 const int xmin= c->xmin<<shift; | 1635 const int xmin= c->xmin<<shift; |
1636 const int ymin= c->ymin<<shift; | 1636 const int ymin= c->ymin<<shift; |
1637 const int xmax= c->xmax<<shift; | 1637 const int xmax= c->xmax<<shift; |
1638 const int ymax= c->ymax<<shift; | 1638 const int ymax= c->ymax<<shift; |
1639 uint8_t map[8][8][8][8]; | |
1640 | |
1641 memset(map,0,sizeof(map)); | |
1642 #define BIDIR_MAP(fx,fy,bx,by) \ | |
1643 map[(motion_fx+fx)&7][(motion_fy+fy)&7][(motion_bx+bx)&7][(motion_by+by)&7] | |
1644 BIDIR_MAP(0,0,0,0) = 1; | |
1639 | 1645 |
1640 fbmin= check_bidir_mv(s, motion_fx, motion_fy, | 1646 fbmin= check_bidir_mv(s, motion_fx, motion_fy, |
1641 motion_bx, motion_by, | 1647 motion_bx, motion_by, |
1642 pred_fx, pred_fy, | 1648 pred_fx, pred_fy, |
1643 pred_bx, pred_by, | 1649 pred_bx, pred_by, |
1644 0, 16); | 1650 0, 16); |
1645 | 1651 |
1646 if(s->avctx->bidir_refine){ | 1652 if(s->avctx->bidir_refine){ |
1647 int score, end; | 1653 int score, end; |
1648 #define CHECK_BIDIR(fx,fy,bx,by)\ | 1654 #define CHECK_BIDIR(fx,fy,bx,by)\ |
1649 if( (fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\ | 1655 if( !BIDIR_MAP(fx,fy,bx,by)\ |
1656 &&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\ | |
1650 &&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\ | 1657 &&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\ |
1658 BIDIR_MAP(fx,fy,bx,by) = 1;\ | |
1651 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);\ | 1659 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);\ |
1652 if(score < fbmin){\ | 1660 if(score < fbmin){\ |
1653 fbmin= score;\ | 1661 fbmin= score;\ |
1654 motion_fx+=fx;\ | 1662 motion_fx+=fx;\ |
1655 motion_fy+=fy;\ | 1663 motion_fy+=fy;\ |
1694 } | 1702 } |
1695 } | 1703 } |
1696 }while(!end); | 1704 }while(!end); |
1697 } | 1705 } |
1698 | 1706 |
1707 s->b_bidir_forw_mv_table[xy][0]= motion_fx; | |
1708 s->b_bidir_forw_mv_table[xy][1]= motion_fy; | |
1709 s->b_bidir_back_mv_table[xy][0]= motion_bx; | |
1710 s->b_bidir_back_mv_table[xy][1]= motion_by; | |
1711 | |
1699 return fbmin; | 1712 return fbmin; |
1700 } | 1713 } |
1701 | 1714 |
1702 static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y) | 1715 static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y) |
1703 { | 1716 { |