comparison motion_est_template.c @ 4259:9b74144471c5 libavcodec

spelling cosmetics: cliped --> clipped
author diego
date Sat, 02 Dec 2006 14:19:49 +0000
parents ac98478e056d
children 4241e92fb0c7
comparison
equal deleted inserted replaced
4258:4d2f162506e3 4259:9b74144471c5
513 /*printf("score:%d\n", d);*/\ 513 /*printf("score:%d\n", d);*/\
514 COPY3_IF_LT(dmin, d, best[0], x, best[1], y)\ 514 COPY3_IF_LT(dmin, d, best[0], x, best[1], y)\
515 }\ 515 }\
516 } 516 }
517 517
518 #define CHECK_CLIPED_MV(ax,ay)\ 518 #define CHECK_CLIPPED_MV(ax,ay)\
519 {\ 519 {\
520 const int Lx= ax;\ 520 const int Lx= ax;\
521 const int Ly= ay;\ 521 const int Ly= ay;\
522 const int Lx2= FFMAX(xmin, FFMIN(Lx, xmax));\ 522 const int Lx2= FFMAX(xmin, FFMIN(Lx, xmax));\
523 const int Ly2= FFMAX(ymin, FFMIN(Ly, ymax));\ 523 const int Ly2= FFMAX(ymin, FFMIN(Ly, ymax));\
676 for(;dia_size; dia_size--){ 676 for(;dia_size; dia_size--){
677 do{ 677 do{
678 x= best[0]; 678 x= best[0];
679 y= best[1]; 679 y= best[1];
680 for(i=0; i<6; i++){ 680 for(i=0; i<6; i++){
681 CHECK_CLIPED_MV(x+hex[i][0]*dia_size, y+hex[i][1]*dia_size); 681 CHECK_CLIPPED_MV(x+hex[i][0]*dia_size, y+hex[i][1]*dia_size);
682 } 682 }
683 }while(best[0] != x || best[1] != y); 683 }while(best[0] != x || best[1] != y);
684 } 684 }
685 685
686 do{ 686 do{
687 x= best[0]; 687 x= best[0];
688 y= best[1]; 688 y= best[1];
689 CHECK_CLIPED_MV(x+1, y); 689 CHECK_CLIPPED_MV(x+1, y);
690 CHECK_CLIPED_MV(x, y+1); 690 CHECK_CLIPPED_MV(x, y+1);
691 CHECK_CLIPED_MV(x-1, y); 691 CHECK_CLIPPED_MV(x-1, y);
692 CHECK_CLIPED_MV(x, y-1); 692 CHECK_CLIPPED_MV(x, y-1);
693 }while(best[0] != x || best[1] != y); 693 }while(best[0] != x || best[1] != y);
694 694
695 return dmin; 695 return dmin;
696 } 696 }
697 697
714 for(dia_size= c->dia_size&0xFF; dia_size; dia_size--){ 714 for(dia_size= c->dia_size&0xFF; dia_size; dia_size--){
715 do{ 715 do{
716 x= best[0]; 716 x= best[0];
717 y= best[1]; 717 y= best[1];
718 for(i=0; i<8; i++){ 718 for(i=0; i<8; i++){
719 CHECK_CLIPED_MV(x+hex[i][0]*dia_size, y+hex[i][1]*dia_size); 719 CHECK_CLIPPED_MV(x+hex[i][0]*dia_size, y+hex[i][1]*dia_size);
720 } 720 }
721 }while(best[0] != x || best[1] != y); 721 }while(best[0] != x || best[1] != y);
722 } 722 }
723 723
724 x= best[0]; 724 x= best[0];
725 y= best[1]; 725 y= best[1];
726 CHECK_CLIPED_MV(x+1, y); 726 CHECK_CLIPPED_MV(x+1, y);
727 CHECK_CLIPED_MV(x, y+1); 727 CHECK_CLIPPED_MV(x, y+1);
728 CHECK_CLIPED_MV(x-1, y); 728 CHECK_CLIPPED_MV(x-1, y);
729 CHECK_CLIPED_MV(x, y-1); 729 CHECK_CLIPPED_MV(x, y-1);
730 730
731 return dmin; 731 return dmin;
732 } 732 }
733 733
734 static int umh_search(MpegEncContext * s, int *best, int dmin, 734 static int umh_search(MpegEncContext * s, int *best, int dmin,
769 769
770 //FIXME prevent the CLIP stuff 770 //FIXME prevent the CLIP stuff
771 771
772 for(j=1; j<=dia_size/4; j++){ 772 for(j=1; j<=dia_size/4; j++){
773 for(i=0; i<16; i++){ 773 for(i=0; i<16; i++){
774 CHECK_CLIPED_MV(x+hex[i][0]*j, y+hex[i][1]*j); 774 CHECK_CLIPPED_MV(x+hex[i][0]*j, y+hex[i][1]*j);
775 } 775 }
776 } 776 }
777 777
778 return hex_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags, 1); 778 return hex_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags, 1);
779 } 779 }
1019 score_map[0]= dmin; 1019 score_map[0]= dmin;
1020 1020
1021 /* first line */ 1021 /* first line */
1022 if (s->first_slice_line) { 1022 if (s->first_slice_line) {
1023 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift) 1023 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
1024 CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, 1024 CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1025 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16) 1025 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
1026 }else{ 1026 }else{
1027 if(dmin<((h*h*s->avctx->mv0_threshold)>>8) 1027 if(dmin<((h*h*s->avctx->mv0_threshold)>>8)
1028 && ( P_LEFT[0] |P_LEFT[1] 1028 && ( P_LEFT[0] |P_LEFT[1]
1029 |P_TOP[0] |P_TOP[1] 1029 |P_TOP[0] |P_TOP[1]
1032 *my_ptr= 0; 1032 *my_ptr= 0;
1033 c->skip=1; 1033 c->skip=1;
1034 return dmin; 1034 return dmin;
1035 } 1035 }
1036 CHECK_MV( P_MEDIAN[0] >>shift , P_MEDIAN[1] >>shift) 1036 CHECK_MV( P_MEDIAN[0] >>shift , P_MEDIAN[1] >>shift)
1037 CHECK_CLIPED_MV((P_MEDIAN[0]>>shift) , (P_MEDIAN[1]>>shift)-1) 1037 CHECK_CLIPPED_MV((P_MEDIAN[0]>>shift) , (P_MEDIAN[1]>>shift)-1)
1038 CHECK_CLIPED_MV((P_MEDIAN[0]>>shift) , (P_MEDIAN[1]>>shift)+1) 1038 CHECK_CLIPPED_MV((P_MEDIAN[0]>>shift) , (P_MEDIAN[1]>>shift)+1)
1039 CHECK_CLIPED_MV((P_MEDIAN[0]>>shift)-1, (P_MEDIAN[1]>>shift) ) 1039 CHECK_CLIPPED_MV((P_MEDIAN[0]>>shift)-1, (P_MEDIAN[1]>>shift) )
1040 CHECK_CLIPED_MV((P_MEDIAN[0]>>shift)+1, (P_MEDIAN[1]>>shift) ) 1040 CHECK_CLIPPED_MV((P_MEDIAN[0]>>shift)+1, (P_MEDIAN[1]>>shift) )
1041 CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, 1041 CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1042 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16) 1042 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
1043 CHECK_MV(P_LEFT[0] >>shift, P_LEFT[1] >>shift) 1043 CHECK_MV(P_LEFT[0] >>shift, P_LEFT[1] >>shift)
1044 CHECK_MV(P_TOP[0] >>shift, P_TOP[1] >>shift) 1044 CHECK_MV(P_TOP[0] >>shift, P_TOP[1] >>shift)
1045 CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift) 1045 CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
1046 } 1046 }
1047 if(dmin>h*h*4){ 1047 if(dmin>h*h*4){
1048 if(c->pre_pass){ 1048 if(c->pre_pass){
1049 CHECK_CLIPED_MV((last_mv[ref_mv_xy-1][0]*ref_mv_scale + (1<<15))>>16, 1049 CHECK_CLIPPED_MV((last_mv[ref_mv_xy-1][0]*ref_mv_scale + (1<<15))>>16,
1050 (last_mv[ref_mv_xy-1][1]*ref_mv_scale + (1<<15))>>16) 1050 (last_mv[ref_mv_xy-1][1]*ref_mv_scale + (1<<15))>>16)
1051 if(!s->first_slice_line) 1051 if(!s->first_slice_line)
1052 CHECK_CLIPED_MV((last_mv[ref_mv_xy-ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16, 1052 CHECK_CLIPPED_MV((last_mv[ref_mv_xy-ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
1053 (last_mv[ref_mv_xy-ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16) 1053 (last_mv[ref_mv_xy-ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
1054 }else{ 1054 }else{
1055 CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16, 1055 CHECK_CLIPPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
1056 (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16) 1056 (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
1057 if(s->mb_y+1<s->end_mb_y) //FIXME replace at least with last_slice_line 1057 if(s->mb_y+1<s->end_mb_y) //FIXME replace at least with last_slice_line
1058 CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16, 1058 CHECK_CLIPPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
1059 (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16) 1059 (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
1060 } 1060 }
1061 } 1061 }
1062 1062
1063 if(c->avctx->last_predictor_count){ 1063 if(c->avctx->last_predictor_count){
1135 dmin = 1000000; 1135 dmin = 1000000;
1136 //printf("%d %d %d %d //",xmin, ymin, xmax, ymax); 1136 //printf("%d %d %d %d //",xmin, ymin, xmax, ymax);
1137 /* first line */ 1137 /* first line */
1138 if (s->first_slice_line) { 1138 if (s->first_slice_line) {
1139 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift) 1139 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
1140 CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, 1140 CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1141 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16) 1141 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
1142 CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift) 1142 CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
1143 }else{ 1143 }else{
1144 CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift) 1144 CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
1145 //FIXME try some early stop 1145 //FIXME try some early stop
1146 CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift) 1146 CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)
1147 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift) 1147 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
1148 CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift) 1148 CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift)
1149 CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift) 1149 CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
1150 CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, 1150 CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1151 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16) 1151 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
1152 } 1152 }
1153 if(dmin>64*4){ 1153 if(dmin>64*4){
1154 CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16, 1154 CHECK_CLIPPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
1155 (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16) 1155 (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
1156 if(s->mb_y+1<s->end_mb_y) //FIXME replace at least with last_slice_line 1156 if(s->mb_y+1<s->end_mb_y) //FIXME replace at least with last_slice_line
1157 CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16, 1157 CHECK_CLIPPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
1158 (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16) 1158 (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
1159 } 1159 }
1160 1160
1161 dmin= diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags); 1161 dmin= diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
1162 1162
1195 dmin = 1000000; 1195 dmin = 1000000;
1196 //printf("%d %d %d %d //",xmin, ymin, xmax, ymax); 1196 //printf("%d %d %d %d //",xmin, ymin, xmax, ymax);
1197 /* first line */ 1197 /* first line */
1198 if (s->first_slice_line) { 1198 if (s->first_slice_line) {
1199 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift) 1199 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
1200 CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, 1200 CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1201 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16) 1201 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
1202 CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift) 1202 CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
1203 }else{ 1203 }else{
1204 CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift) 1204 CHECK_MV(P_MV1[0]>>shift, P_MV1[1]>>shift)
1205 //FIXME try some early stop 1205 //FIXME try some early stop
1206 CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift) 1206 CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)
1207 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift) 1207 CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
1208 CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift) 1208 CHECK_MV(P_TOP[0]>>shift, P_TOP[1]>>shift)
1209 CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift) 1209 CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
1210 CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16, 1210 CHECK_CLIPPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
1211 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16) 1211 (last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
1212 } 1212 }
1213 if(dmin>64*4){ 1213 if(dmin>64*4){
1214 CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16, 1214 CHECK_CLIPPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
1215 (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16) 1215 (last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
1216 if(s->mb_y+1<s->end_mb_y) //FIXME replace at least with last_slice_line 1216 if(s->mb_y+1<s->end_mb_y) //FIXME replace at least with last_slice_line
1217 CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16, 1217 CHECK_CLIPPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
1218 (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16) 1218 (last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
1219 } 1219 }
1220 1220
1221 dmin= diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags); 1221 dmin= diamond_search(s, best, dmin, src_index, ref_index, penalty_factor, size, h, flags);
1222 1222