comparison motion_est.c @ 11576:56b71cbf22ac libavcodec

Change bidir refine hash code so we only need to perform a single hash calculation for the whole function. negligibly faster (about 0.1%)
author michael
date Fri, 02 Apr 2010 12:34:08 +0000
parents 5a7797213359
children e4a69ce0256f
comparison
equal deleted inserted replaced
11575:5a7797213359 11576:56b71cbf22ac
1473 const int shift= 1+qpel; 1473 const int shift= 1+qpel;
1474 const int xmin= c->xmin<<shift; 1474 const int xmin= c->xmin<<shift;
1475 const int ymin= c->ymin<<shift; 1475 const int ymin= c->ymin<<shift;
1476 const int xmax= c->xmax<<shift; 1476 const int xmax= c->xmax<<shift;
1477 const int ymax= c->ymax<<shift; 1477 const int ymax= c->ymax<<shift;
1478 #define HASH(fx,fy,bx,by) ((fx)+17*(fy)+63*(bx)+117*(by))
1479 int hashidx= HASH(motion_fx,motion_fy, motion_bx, motion_by);
1478 uint8_t map[256]; 1480 uint8_t map[256];
1479 1481
1480 memset(map,0,sizeof(map)); 1482 memset(map,0,sizeof(map));
1481 #define BIDIR_MAP(fx,fy,bx,by) \ 1483 map[hashidx&255] = 1;
1482 map[((motion_fx+fx)+17*(motion_fy+fy)+63*(motion_bx+bx)+117*(motion_by+by))&255]
1483 BIDIR_MAP(0,0,0,0) = 1;
1484 1484
1485 fbmin= check_bidir_mv(s, motion_fx, motion_fy, 1485 fbmin= check_bidir_mv(s, motion_fx, motion_fy,
1486 motion_bx, motion_by, 1486 motion_bx, motion_by,
1487 pred_fx, pred_fy, 1487 pred_fx, pred_fy,
1488 pred_bx, pred_by, 1488 pred_bx, pred_by,
1489 0, 16); 1489 0, 16);
1490 1490
1491 if(s->avctx->bidir_refine){ 1491 if(s->avctx->bidir_refine){
1492 int score, end; 1492 int score, end;
1493 #define CHECK_BIDIR(fx,fy,bx,by)\ 1493 #define CHECK_BIDIR(fx,fy,bx,by)\
1494 if( !BIDIR_MAP(fx,fy,bx,by)\ 1494 if( !map[(hashidx+HASH(fx,fy,bx,by))&255]\
1495 &&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\ 1495 &&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\
1496 &&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\ 1496 &&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\
1497 BIDIR_MAP(fx,fy,bx,by) = 1;\ 1497 map[(hashidx+HASH(fx,fy,bx,by))&255] = 1;\
1498 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);\ 1498 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);\
1499 if(score < fbmin){\ 1499 if(score < fbmin){\
1500 hashidx += HASH(fx,fy,bx,by);\
1500 fbmin= score;\ 1501 fbmin= score;\
1501 motion_fx+=fx;\ 1502 motion_fx+=fx;\
1502 motion_fy+=fy;\ 1503 motion_fy+=fy;\
1503 motion_bx+=bx;\ 1504 motion_bx+=bx;\
1504 motion_by+=by;\ 1505 motion_by+=by;\