summaryrefslogtreecommitdiff
path: root/libavcodec/motion_est_template.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-12-05 12:34:52 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-12-05 12:34:52 +0000
commitf852ff32571bfd5ddd239a8c273445377c6462b4 (patch)
tree351d3407447bc2e1960b0db16bc7979638a9dec4 /libavcodec/motion_est_template.c
parent6bc0e1cfba12648bf6ea161d4f43b8a316baee94 (diff)
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 Originally committed as revision 7223 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/motion_est_template.c')
-rw-r--r--libavcodec/motion_est_template.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c
index d8feaff5a9..ee3c08295c 100644
--- a/libavcodec/motion_est_template.c
+++ b/libavcodec/motion_est_template.c
@@ -667,31 +667,28 @@ static int hex_search(MpegEncContext * s, int *best, int dmin,
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 @@ static int l2s_dia_search(MpegEncContext * s, int *best, int dmin,
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];