dia_size=-1 -> funny_diamond_search()

dia_siue=768 + size -> umh search (old -1 was 784)

Originally committed as revision 7205 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2006-12-02 10:58:20 +00:00
parent 376edfcc0f
commit 1994e7c6b6
1 changed files with 7 additions and 4 deletions

View File

@ -741,6 +741,7 @@ static int umh_search(MpegEncContext * s, int *best, int dmin,
LOAD_COMMON2
int map_generation= c->map_generation;
int x,y,x2,y2, i, j, d;
const int dia_size= c->dia_size&0xFE;
static const int hex[16][2]={{-4,-2}, {-4,-1}, {-4, 0}, {-4, 1}, {-4, 2},
{ 4,-2}, { 4,-1}, { 4, 0}, { 4, 1}, { 4, 2},
{-2, 3}, { 0, 4}, { 2, 3},
@ -751,10 +752,10 @@ static int umh_search(MpegEncContext * s, int *best, int dmin,
x= best[0];
y= best[1];
for(x2=FFMAX(x-15, xmin); x2<=FFMIN(x+15,xmax); x2+=2){
for(x2=FFMAX(x-dia_size+1, xmin); x2<=FFMIN(x+dia_size-1,xmax); x2+=2){
CHECK_MV(x2, y);
}
for(y2=FFMAX(y- 7, ymin); y2<=FFMIN(y+ 7,ymax); y2+=2){
for(y2=FFMAX(y-dia_size/2+1, ymin); y2<=FFMIN(y+dia_size/2-1,ymax); y2+=2){
CHECK_MV(x, y2);
}
@ -768,7 +769,7 @@ static int umh_search(MpegEncContext * s, int *best, int dmin,
//FIXME prevent the CLIP stuff
for(j=1; j<=4; j++){
for(j=1; j<=dia_size/4; j++){
for(i=0; i<16; i++){
CHECK_CLIPED_MV(x+hex[i][0]*j, y+hex[i][1]*j);
}
@ -969,11 +970,13 @@ static always_inline int diamond_search(MpegEncContext * s, int *best, int dmin,
int size, int h, int flags){
MotionEstContext * const c= &s->me;
if(c->dia_size==-1)
return umh_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
return funny_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
else if(c->dia_size<-1)
return sab_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
else if(c->dia_size<2)
return small_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
else if(c->dia_size>768)
return umh_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
else if(c->dia_size>512)
return hex_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags, c->dia_size&0xFF);
else if(c->dia_size>256)