Commit 63ccccbf authored by michael's avatar michael

Change bidir refine hash code so we only need to perform a single

hash calculation for the whole function.
negligibly faster (about 0.1%)


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@22775 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 506975c1
...@@ -1475,12 +1475,12 @@ static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y) ...@@ -1475,12 +1475,12 @@ static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y)
const int ymin= c->ymin<<shift; const int ymin= c->ymin<<shift;
const int xmax= c->xmax<<shift; const int xmax= c->xmax<<shift;
const int ymax= c->ymax<<shift; const int ymax= c->ymax<<shift;
#define HASH(fx,fy,bx,by) ((fx)+17*(fy)+63*(bx)+117*(by))
int hashidx= HASH(motion_fx,motion_fy, motion_bx, motion_by);
uint8_t map[256]; uint8_t map[256];
memset(map,0,sizeof(map)); memset(map,0,sizeof(map));
#define BIDIR_MAP(fx,fy,bx,by) \ map[hashidx&255] = 1;
map[((motion_fx+fx)+17*(motion_fy+fy)+63*(motion_bx+bx)+117*(motion_by+by))&255]
BIDIR_MAP(0,0,0,0) = 1;
fbmin= check_bidir_mv(s, motion_fx, motion_fy, fbmin= check_bidir_mv(s, motion_fx, motion_fy,
motion_bx, motion_by, motion_bx, motion_by,
...@@ -1491,12 +1491,13 @@ static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y) ...@@ -1491,12 +1491,13 @@ static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y)
if(s->avctx->bidir_refine){ if(s->avctx->bidir_refine){
int score, end; int score, end;
#define CHECK_BIDIR(fx,fy,bx,by)\ #define CHECK_BIDIR(fx,fy,bx,by)\
if( !BIDIR_MAP(fx,fy,bx,by)\ if( !map[(hashidx+HASH(fx,fy,bx,by))&255]\
&&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\ &&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\
&&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\ &&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\
BIDIR_MAP(fx,fy,bx,by) = 1;\ map[(hashidx+HASH(fx,fy,bx,by))&255] = 1;\
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);\ 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);\
if(score < fbmin){\ if(score < fbmin){\
hashidx += HASH(fx,fy,bx,by);\
fbmin= score;\ fbmin= score;\
motion_fx+=fx;\ motion_fx+=fx;\
motion_fy+=fy;\ motion_fy+=fy;\
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment