comparison motion_est_template.c @ 7229:f03d29b6fefe libavcodec

New full search ME
author michael
date Wed, 09 Jul 2008 18:59:52 +0000
parents 493dc59d469a
children 3f819263176e
comparison
equal deleted inserted replaced
7228:29bce9b314ec 7229:f03d29b6fefe
774 } 774 }
775 775
776 return hex_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags, 2); 776 return hex_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags, 2);
777 } 777 }
778 778
779 static int full_search(MpegEncContext * s, int *best, int dmin,
780 int src_index, int ref_index, int const penalty_factor,
781 int size, int h, int flags)
782 {
783 MotionEstContext * const c= &s->me;
784 me_cmp_func cmpf, chroma_cmpf;
785 LOAD_COMMON
786 LOAD_COMMON2
787 int map_generation= c->map_generation;
788 int x,y, d;
789 const int dia_size= c->dia_size&0xFF;
790
791 cmpf= s->dsp.me_cmp[size];
792 chroma_cmpf= s->dsp.me_cmp[size+1];
793
794 for(y=FFMAX(-dia_size, ymin); y<=FFMIN(dia_size,ymax); y++){
795 for(x=FFMAX(-dia_size, xmin); x<=FFMIN(dia_size,xmax); x++){
796 CHECK_MV(x, y);
797 }
798 }
799
800 x= best[0];
801 y= best[1];
802 d= dmin;
803 CHECK_CLIPPED_MV(x , y);
804 CHECK_CLIPPED_MV(x+1, y);
805 CHECK_CLIPPED_MV(x, y+1);
806 CHECK_CLIPPED_MV(x-1, y);
807 CHECK_CLIPPED_MV(x, y-1);
808 best[0]= x;
809 best[1]= y;
810
811 return d;
812 }
813
779 #define SAB_CHECK_MV(ax,ay)\ 814 #define SAB_CHECK_MV(ax,ay)\
780 {\ 815 {\
781 const int key= ((ay)<<ME_MAP_MV_BITS) + (ax) + map_generation;\ 816 const int key= ((ay)<<ME_MAP_MV_BITS) + (ax) + map_generation;\
782 const int index= (((ay)<<ME_MAP_SHIFT) + (ax))&(ME_MAP_SIZE-1);\ 817 const int index= (((ay)<<ME_MAP_SHIFT) + (ax))&(ME_MAP_SIZE-1);\
783 /*printf("sab check %d %d\n", ax, ay);*/\ 818 /*printf("sab check %d %d\n", ax, ay);*/\
978 return funny_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags); 1013 return funny_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
979 else if(c->dia_size<-1) 1014 else if(c->dia_size<-1)
980 return sab_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags); 1015 return sab_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
981 else if(c->dia_size<2) 1016 else if(c->dia_size<2)
982 return small_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags); 1017 return small_diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
1018 else if(c->dia_size>1024)
1019 return full_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
983 else if(c->dia_size>768) 1020 else if(c->dia_size>768)
984 return umh_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags); 1021 return umh_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
985 else if(c->dia_size>512) 1022 else if(c->dia_size>512)
986 return hex_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags, c->dia_size&0xFF); 1023 return hex_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags, c->dia_size&0xFF);
987 else if(c->dia_size>256) 1024 else if(c->dia_size>256)