Mercurial > libavcodec.hg
changeset 4265:4241e92fb0c7 libavcodec
make hex and large 2 small diamond search half their size instead or -1 if the initial size was a power of 2
double the hex size so odd sized hexagons are possible
author | michael |
---|---|
date | Tue, 05 Dec 2006 12:34:52 +0000 |
parents | 769ea5de44d3 |
children | 8a50de4eafca |
files | motion_est_template.c |
diffstat | 1 files changed, 15 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/motion_est_template.c Mon Dec 04 12:04:53 2006 +0000 +++ b/motion_est_template.c Tue Dec 05 12:34:52 2006 +0000 @@ -667,31 +667,28 @@ LOAD_COMMON LOAD_COMMON2 int map_generation= c->map_generation; - int x,y,i,d; - static const int hex[6][2]={{-2, 0}, { 2,0}, {-1,-2}, {1,-2}, {-1,2},{1,2}}; + int x,y,d; + const int dec= dia_size & (dia_size-1); cmpf= s->dsp.me_cmp[size]; chroma_cmpf= s->dsp.me_cmp[size+1]; - for(;dia_size; dia_size--){ + for(;dia_size; dia_size= dec ? dia_size-1 : dia_size>>1){ do{ x= best[0]; y= best[1]; - for(i=0; i<6; i++){ - CHECK_CLIPPED_MV(x+hex[i][0]*dia_size, y+hex[i][1]*dia_size); + + CHECK_CLIPPED_MV(x -dia_size , y); + CHECK_CLIPPED_MV(x+ dia_size , y); + CHECK_CLIPPED_MV(x+( dia_size>>1), y+dia_size); + CHECK_CLIPPED_MV(x+( dia_size>>1), y-dia_size); + if(dia_size>1){ + CHECK_CLIPPED_MV(x+(-dia_size>>1), y+dia_size); + CHECK_CLIPPED_MV(x+(-dia_size>>1), y-dia_size); } }while(best[0] != x || best[1] != y); } - do{ - x= best[0]; - y= best[1]; - CHECK_CLIPPED_MV(x+1, y); - CHECK_CLIPPED_MV(x, y+1); - CHECK_CLIPPED_MV(x-1, y); - CHECK_CLIPPED_MV(x, y-1); - }while(best[0] != x || best[1] != y); - return dmin; } @@ -704,14 +701,16 @@ LOAD_COMMON LOAD_COMMON2 int map_generation= c->map_generation; - int x,y,i,d, dia_size; + int x,y,i,d; + int dia_size= c->dia_size&0xFF; + const int dec= dia_size & (dia_size-1); static const int hex[8][2]={{-2, 0}, {-1,-1}, { 0,-2}, { 1,-1}, { 2, 0}, { 1, 1}, { 0, 2}, {-1, 1}}; cmpf= s->dsp.me_cmp[size]; chroma_cmpf= s->dsp.me_cmp[size+1]; - for(dia_size= c->dia_size&0xFF; dia_size; dia_size--){ + for(; dia_size; dia_size= dec ? dia_size-1 : dia_size>>1){ do{ x= best[0]; y= best[1];