Mercurial > libavcodec.hg
comparison motion_est.c @ 952:f348d302a51e libavcodec
pre motion estimation cleanup/bugfix
author | michaelni |
---|---|
date | Thu, 02 Jan 2003 12:48:09 +0000 |
parents | ad264a7d4f94 |
children | 13aec7e50c52 |
comparison
equal
deleted
inserted
replaced
951:ad264a7d4f94 | 952:f348d302a51e |
---|---|
801 P_LEFT[1] = s->motion_val[mot_xy - 1][1]; | 801 P_LEFT[1] = s->motion_val[mot_xy - 1][1]; |
802 | 802 |
803 if(P_LEFT[0] > (rel_xmax4<<shift)) P_LEFT[0] = (rel_xmax4<<shift); | 803 if(P_LEFT[0] > (rel_xmax4<<shift)) P_LEFT[0] = (rel_xmax4<<shift); |
804 | 804 |
805 /* special case for first line */ | 805 /* special case for first line */ |
806 if ((s->mb_y == 0 || s->first_slice_line) && block<2) { | 806 if (s->mb_y == 0 && block<2) { |
807 pred_x4= P_LEFT[0]; | 807 pred_x4= P_LEFT[0]; |
808 pred_y4= P_LEFT[1]; | 808 pred_y4= P_LEFT[1]; |
809 } else { | 809 } else { |
810 P_TOP[0] = s->motion_val[mot_xy - mot_stride ][0]; | 810 P_TOP[0] = s->motion_val[mot_xy - mot_stride ][0]; |
811 P_TOP[1] = s->motion_val[mot_xy - mot_stride ][1]; | 811 P_TOP[1] = s->motion_val[mot_xy - mot_stride ][1]; |
902 P_LEFT[0] = s->motion_val[mot_xy - 1][0]; | 902 P_LEFT[0] = s->motion_val[mot_xy - 1][0]; |
903 P_LEFT[1] = s->motion_val[mot_xy - 1][1]; | 903 P_LEFT[1] = s->motion_val[mot_xy - 1][1]; |
904 | 904 |
905 if(P_LEFT[0] > (rel_xmax<<shift)) P_LEFT[0] = (rel_xmax<<shift); | 905 if(P_LEFT[0] > (rel_xmax<<shift)) P_LEFT[0] = (rel_xmax<<shift); |
906 | 906 |
907 /* special case for first line */ | 907 if(mb_y) { |
908 if ((mb_y == 0 || s->first_slice_line)) { | |
909 pred_x= P_LEFT[0]; | |
910 pred_y= P_LEFT[1]; | |
911 } else { | |
912 P_TOP[0] = s->motion_val[mot_xy - mot_stride ][0]; | 908 P_TOP[0] = s->motion_val[mot_xy - mot_stride ][0]; |
913 P_TOP[1] = s->motion_val[mot_xy - mot_stride ][1]; | 909 P_TOP[1] = s->motion_val[mot_xy - mot_stride ][1]; |
914 P_TOPRIGHT[0] = s->motion_val[mot_xy - mot_stride + 2][0]; | 910 P_TOPRIGHT[0] = s->motion_val[mot_xy - mot_stride + 2][0]; |
915 P_TOPRIGHT[1] = s->motion_val[mot_xy - mot_stride + 2][1]; | 911 P_TOPRIGHT[1] = s->motion_val[mot_xy - mot_stride + 2][1]; |
916 if(P_TOP[1] > (rel_ymax<<shift)) P_TOP[1] = (rel_ymax<<shift); | 912 if(P_TOP[1] > (rel_ymax<<shift)) P_TOP[1] = (rel_ymax<<shift); |
925 pred_y = P_MEDIAN[1]; | 921 pred_y = P_MEDIAN[1]; |
926 }else { /* mpeg1 at least */ | 922 }else { /* mpeg1 at least */ |
927 pred_x= P_LEFT[0]; | 923 pred_x= P_LEFT[0]; |
928 pred_y= P_LEFT[1]; | 924 pred_y= P_LEFT[1]; |
929 } | 925 } |
926 }else{ | |
927 pred_x= P_LEFT[0]; | |
928 pred_y= P_LEFT[1]; | |
930 } | 929 } |
930 | |
931 } | 931 } |
932 dmin = s->me.motion_search[0](s, 0, &mx, &my, P, pred_x, pred_y, rel_xmin, rel_ymin, rel_xmax, rel_ymax, | 932 dmin = s->me.motion_search[0](s, 0, &mx, &my, P, pred_x, pred_y, rel_xmin, rel_ymin, rel_xmax, rel_ymax, |
933 &s->last_picture, s->p_mv_table, (1<<16)>>shift, mv_penalty); | 933 &s->last_picture, s->p_mv_table, (1<<16)>>shift, mv_penalty); |
934 | 934 |
935 break; | 935 break; |
1053 | 1053 |
1054 /* special case for first line */ | 1054 /* special case for first line */ |
1055 if (mb_y == s->mb_height-1) { | 1055 if (mb_y == s->mb_height-1) { |
1056 pred_x= P_LEFT[0]; | 1056 pred_x= P_LEFT[0]; |
1057 pred_y= P_LEFT[1]; | 1057 pred_y= P_LEFT[1]; |
1058 P_TOP[0]= P_TOPRIGHT[0]= P_MEDIAN[0]= | |
1059 P_TOP[1]= P_TOPRIGHT[1]= P_MEDIAN[1]= 0; //FIXME | |
1058 } else { | 1060 } else { |
1059 P_TOP[0] = s->p_mv_table[xy + mv_stride ][0]; | 1061 P_TOP[0] = s->p_mv_table[xy + mv_stride ][0]; |
1060 P_TOP[1] = s->p_mv_table[xy + mv_stride ][1]; | 1062 P_TOP[1] = s->p_mv_table[xy + mv_stride ][1]; |
1061 P_TOPRIGHT[0] = s->p_mv_table[xy + mv_stride - 1][0]; | 1063 P_TOPRIGHT[0] = s->p_mv_table[xy + mv_stride - 1][0]; |
1062 P_TOPRIGHT[1] = s->p_mv_table[xy + mv_stride - 1][1]; | 1064 P_TOPRIGHT[1] = s->p_mv_table[xy + mv_stride - 1][1]; |
1065 if(P_TOPRIGHT[1] < (rel_ymin<<shift)) P_TOPRIGHT[1]= (rel_ymin<<shift); | 1067 if(P_TOPRIGHT[1] < (rel_ymin<<shift)) P_TOPRIGHT[1]= (rel_ymin<<shift); |
1066 | 1068 |
1067 P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]); | 1069 P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]); |
1068 P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]); | 1070 P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]); |
1069 | 1071 |
1070 if(s->out_format == FMT_H263){ | 1072 pred_x = P_MEDIAN[0]; |
1071 pred_x = P_MEDIAN[0]; | 1073 pred_y = P_MEDIAN[1]; |
1072 pred_y = P_MEDIAN[1]; | |
1073 }else { /* mpeg1 at least */ | |
1074 pred_x= P_LEFT[0]; | |
1075 pred_y= P_LEFT[1]; | |
1076 } | |
1077 } | 1074 } |
1078 dmin = s->me.motion_search[0](s, 0, &mx, &my, P, pred_x, pred_y, rel_xmin, rel_ymin, rel_xmax, rel_ymax, | 1075 dmin = s->me.motion_search[0](s, 0, &mx, &my, P, pred_x, pred_y, rel_xmin, rel_ymin, rel_xmax, rel_ymax, |
1079 &s->last_picture, s->p_mv_table, (1<<16)>>shift, mv_penalty); | 1076 &s->last_picture, s->p_mv_table, (1<<16)>>shift, mv_penalty); |
1080 | 1077 |
1081 s->p_mv_table[xy][0] = mx<<shift; | 1078 s->p_mv_table[xy][0] = mx<<shift; |
1082 s->p_mv_table[xy][1] = my<<shift; | 1079 s->p_mv_table[xy][1] = my<<shift; |
1083 | 1080 |
1084 return dmin; | 1081 return dmin; |
1085 } | 1082 } |
1138 P_LEFT[1] = mv_table[mot_xy - 1][1]; | 1135 P_LEFT[1] = mv_table[mot_xy - 1][1]; |
1139 | 1136 |
1140 if(P_LEFT[0] > (rel_xmax<<shift)) P_LEFT[0] = (rel_xmax<<shift); | 1137 if(P_LEFT[0] > (rel_xmax<<shift)) P_LEFT[0] = (rel_xmax<<shift); |
1141 | 1138 |
1142 /* special case for first line */ | 1139 /* special case for first line */ |
1143 if ((mb_y == 0 || s->first_slice_line)) { | 1140 if (mb_y) { |
1144 } else { | |
1145 P_TOP[0] = mv_table[mot_xy - mot_stride ][0]; | 1141 P_TOP[0] = mv_table[mot_xy - mot_stride ][0]; |
1146 P_TOP[1] = mv_table[mot_xy - mot_stride ][1]; | 1142 P_TOP[1] = mv_table[mot_xy - mot_stride ][1]; |
1147 P_TOPRIGHT[0] = mv_table[mot_xy - mot_stride + 1 ][0]; | 1143 P_TOPRIGHT[0] = mv_table[mot_xy - mot_stride + 1 ][0]; |
1148 P_TOPRIGHT[1] = mv_table[mot_xy - mot_stride + 1 ][1]; | 1144 P_TOPRIGHT[1] = mv_table[mot_xy - mot_stride + 1 ][1]; |
1149 if(P_TOP[1] > (rel_ymax<<shift)) P_TOP[1]= (rel_ymax<<shift); | 1145 if(P_TOP[1] > (rel_ymax<<shift)) P_TOP[1]= (rel_ymax<<shift); |
1330 | 1326 |
1331 P_LEFT[0] = clip(mv_table[mot_xy - 1][0], xmin<<shift, xmax<<shift); | 1327 P_LEFT[0] = clip(mv_table[mot_xy - 1][0], xmin<<shift, xmax<<shift); |
1332 P_LEFT[1] = clip(mv_table[mot_xy - 1][1], ymin<<shift, ymax<<shift); | 1328 P_LEFT[1] = clip(mv_table[mot_xy - 1][1], ymin<<shift, ymax<<shift); |
1333 | 1329 |
1334 /* special case for first line */ | 1330 /* special case for first line */ |
1335 if ((mb_y == 0 || s->first_slice_line)) { | 1331 if (mb_y) { |
1336 } else { | |
1337 P_TOP[0] = clip(mv_table[mot_xy - mot_stride ][0], xmin<<shift, xmax<<shift); | 1332 P_TOP[0] = clip(mv_table[mot_xy - mot_stride ][0], xmin<<shift, xmax<<shift); |
1338 P_TOP[1] = clip(mv_table[mot_xy - mot_stride ][1], ymin<<shift, ymax<<shift); | 1333 P_TOP[1] = clip(mv_table[mot_xy - mot_stride ][1], ymin<<shift, ymax<<shift); |
1339 P_TOPRIGHT[0] = clip(mv_table[mot_xy - mot_stride + 1 ][0], xmin<<shift, xmax<<shift); | 1334 P_TOPRIGHT[0] = clip(mv_table[mot_xy - mot_stride + 1 ][0], xmin<<shift, xmax<<shift); |
1340 P_TOPRIGHT[1] = clip(mv_table[mot_xy - mot_stride + 1 ][1], ymin<<shift, ymax<<shift); | 1335 P_TOPRIGHT[1] = clip(mv_table[mot_xy - mot_stride + 1 ][1], ymin<<shift, ymax<<shift); |
1341 | 1336 |