| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <limits.h> | 11 #include <limits.h> |
| 12 #include <math.h> | 12 #include <math.h> |
| 13 #include <stdio.h> | 13 #include <stdio.h> |
| 14 | 14 |
| 15 #include "./vpx_config.h" | 15 #include "./vpx_config.h" |
| 16 | 16 |
| 17 #include "vpx_mem/vpx_mem.h" | 17 #include "vpx_mem/vpx_mem.h" |
| 18 | 18 |
| 19 #include "vp9/common/vp9_findnearmv.h" | 19 #include "vp9/common/vp9_findnearmv.h" |
| 20 #include "vp9/common/vp9_common.h" | 20 #include "vp9/common/vp9_common.h" |
| 21 | 21 |
| 22 #include "vp9/encoder/vp9_onyx_int.h" | 22 #include "vp9/encoder/vp9_onyx_int.h" |
| 23 #include "vp9/encoder/vp9_mcomp.h" | 23 #include "vp9/encoder/vp9_mcomp.h" |
| 24 | 24 |
| 25 // #define NEW_DIAMOND_SEARCH | 25 // #define NEW_DIAMOND_SEARCH |
| 26 | 26 |
| 27 void vp9_clamp_mv_min_max(MACROBLOCK *x, MV *mv) { | 27 void vp9_set_mv_search_range(MACROBLOCK *x, MV *mv) { |
| 28 const int col_min = (mv->col >> 3) - MAX_FULL_PEL_VAL + (mv->col & 7 ? 1 : 0); | 28 const int col_min = (mv->col >> 3) - MAX_FULL_PEL_VAL + (mv->col & 7 ? 1 : 0); |
| 29 const int row_min = (mv->row >> 3) - MAX_FULL_PEL_VAL + (mv->row & 7 ? 1 : 0); | 29 const int row_min = (mv->row >> 3) - MAX_FULL_PEL_VAL + (mv->row & 7 ? 1 : 0); |
| 30 const int col_max = (mv->col >> 3) + MAX_FULL_PEL_VAL; | 30 const int col_max = (mv->col >> 3) + MAX_FULL_PEL_VAL; |
| 31 const int row_max = (mv->row >> 3) + MAX_FULL_PEL_VAL; | 31 const int row_max = (mv->row >> 3) + MAX_FULL_PEL_VAL; |
| 32 | 32 |
| 33 // Get intersection of UMV window and valid MV window to reduce # of checks | 33 // Get intersection of UMV window and valid MV window to reduce # of checks |
| 34 // in diamond search. | 34 // in diamond search. |
| 35 if (x->mv_col_min < col_min) | 35 if (x->mv_col_min < col_min) |
| 36 x->mv_col_min = col_min; | 36 x->mv_col_min = col_min; |
| 37 if (x->mv_col_max > col_max) | 37 if (x->mv_col_max > col_max) |
| 38 x->mv_col_max = col_max; | 38 x->mv_col_max = col_max; |
| 39 if (x->mv_row_min < row_min) | 39 if (x->mv_row_min < row_min) |
| 40 x->mv_row_min = row_min; | 40 x->mv_row_min = row_min; |
| 41 if (x->mv_row_max > row_max) | 41 if (x->mv_row_max > row_max) |
| 42 x->mv_row_max = row_max; | 42 x->mv_row_max = row_max; |
| 43 } | 43 } |
| 44 | 44 |
| 45 int vp9_init_search_range(VP9_COMP *cpi, int size) { | 45 int vp9_init_search_range(VP9_COMP *cpi, int size) { |
| 46 int sr = 0; | 46 int sr = 0; |
| 47 | 47 |
| 48 // Minimum search size no matter what the passed in value. | 48 // Minimum search size no matter what the passed in value. |
| 49 size = MAX(16, size); | 49 size = MAX(16, size); |
| 50 | 50 |
| 51 while ((size << sr) < MAX_FULL_PEL_VAL) | 51 while ((size << sr) < MAX_FULL_PEL_VAL) |
| 52 sr++; | 52 sr++; |
| 53 | 53 |
| 54 if (sr) | |
| 55 sr--; | |
| 56 | |
| 57 sr += cpi->sf.reduce_first_step_size; | 54 sr += cpi->sf.reduce_first_step_size; |
| 58 sr = MIN(sr, (cpi->sf.max_step_search_steps - 2)); | 55 sr = MIN(sr, (cpi->sf.max_step_search_steps - 2)); |
| 59 return sr; | 56 return sr; |
| 60 } | 57 } |
| 61 | 58 |
| 62 static INLINE int mv_cost(const MV *mv, | 59 static INLINE int mv_cost(const MV *mv, |
| 63 const int *joint_cost, int *comp_cost[2]) { | 60 const int *joint_cost, int *comp_cost[2]) { |
| 64 return joint_cost[vp9_get_mv_joint(mv)] + | 61 return joint_cost[vp9_get_mv_joint(mv)] + |
| 65 comp_cost[0][mv->row] + comp_cost[1][mv->col]; | 62 comp_cost[0][mv->row] + comp_cost[1][mv->col]; |
| 66 } | 63 } |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 return vp9_pattern_search(x, ref_mv, search_param, sad_per_bit, | 1059 return vp9_pattern_search(x, ref_mv, search_param, sad_per_bit, |
| 1063 do_init_search, 0, vfp, use_mvcost, | 1060 do_init_search, 0, vfp, use_mvcost, |
| 1064 center_mv, best_mv, | 1061 center_mv, best_mv, |
| 1065 square_num_candidates, square_candidates); | 1062 square_num_candidates, square_candidates); |
| 1066 }; | 1063 }; |
| 1067 | 1064 |
| 1068 #undef CHECK_BOUNDS | 1065 #undef CHECK_BOUNDS |
| 1069 #undef CHECK_POINT | 1066 #undef CHECK_POINT |
| 1070 #undef CHECK_BETTER | 1067 #undef CHECK_BETTER |
| 1071 | 1068 |
| 1069 int vp9_full_range_search_c(MACROBLOCK *x, MV *ref_mv, MV *best_mv, |
| 1070 int search_param, int sad_per_bit, int *num00, |
| 1071 vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost, |
| 1072 int *mvcost[2], const MV *center_mv) { |
| 1073 const MACROBLOCKD* const xd = &x->e_mbd; |
| 1074 uint8_t *what = x->plane[0].src.buf; |
| 1075 int what_stride = x->plane[0].src.stride; |
| 1076 uint8_t *in_what; |
| 1077 int in_what_stride = xd->plane[0].pre[0].stride; |
| 1078 uint8_t *best_address; |
| 1079 |
| 1080 MV this_mv; |
| 1081 |
| 1082 int bestsad = INT_MAX; |
| 1083 int ref_row, ref_col; |
| 1084 |
| 1085 uint8_t *check_here; |
| 1086 int thissad; |
| 1087 MV fcenter_mv; |
| 1088 |
| 1089 int *mvjsadcost = x->nmvjointsadcost; |
| 1090 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; |
| 1091 |
| 1092 int tr, tc; |
| 1093 int best_tr = 0; |
| 1094 int best_tc = 0; |
| 1095 int range = 64; |
| 1096 |
| 1097 int start_col, end_col; |
| 1098 int start_row, end_row; |
| 1099 int i; |
| 1100 |
| 1101 fcenter_mv.row = center_mv->row >> 3; |
| 1102 fcenter_mv.col = center_mv->col >> 3; |
| 1103 |
| 1104 clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max); |
| 1105 ref_row = ref_mv->row; |
| 1106 ref_col = ref_mv->col; |
| 1107 *num00 = 11; |
| 1108 best_mv->row = ref_row; |
| 1109 best_mv->col = ref_col; |
| 1110 |
| 1111 // Work out the start point for the search |
| 1112 in_what = (uint8_t *)(xd->plane[0].pre[0].buf + |
| 1113 (ref_row * (xd->plane[0].pre[0].stride)) + ref_col); |
| 1114 best_address = in_what; |
| 1115 |
| 1116 // Check the starting position |
| 1117 bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) |
| 1118 + mvsad_err_cost(best_mv, &fcenter_mv, |
| 1119 mvjsadcost, mvsadcost, sad_per_bit); |
| 1120 |
| 1121 start_row = MAX(-range, x->mv_row_min - ref_row); |
| 1122 start_col = MAX(-range, x->mv_col_min - ref_col); |
| 1123 end_row = MIN(range, x->mv_row_max - ref_row); |
| 1124 end_col = MIN(range, x->mv_col_max - ref_col); |
| 1125 |
| 1126 for (tr = start_row; tr <= end_row; ++tr) { |
| 1127 for (tc = start_col; tc <= end_col; tc += 4) { |
| 1128 if ((tc + 3) <= end_col) { |
| 1129 unsigned int sad_array[4]; |
| 1130 unsigned char const *addr_ref[4]; |
| 1131 for (i = 0; i < 4; ++i) |
| 1132 addr_ref[i] = in_what + tr * in_what_stride + tc + i; |
| 1133 |
| 1134 fn_ptr->sdx4df(what, what_stride, addr_ref, in_what_stride, sad_array); |
| 1135 |
| 1136 for (i = 0; i < 4; ++i) { |
| 1137 if (sad_array[i] < bestsad) { |
| 1138 this_mv.row = ref_row + tr; |
| 1139 this_mv.col = ref_col + tc + i; |
| 1140 thissad = sad_array[i] + |
| 1141 mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1142 mvjsadcost, mvsadcost, sad_per_bit); |
| 1143 if (thissad < bestsad) { |
| 1144 bestsad = thissad; |
| 1145 best_tr = tr; |
| 1146 best_tc = tc + i; |
| 1147 } |
| 1148 } |
| 1149 } |
| 1150 } else { |
| 1151 for (i = 0; i < end_col - tc; ++i) { |
| 1152 check_here = in_what + tr * in_what_stride + tc + i; |
| 1153 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, |
| 1154 bestsad); |
| 1155 |
| 1156 if (thissad < bestsad) { |
| 1157 this_mv.row = ref_row + tr; |
| 1158 this_mv.col = ref_col + tc + i; |
| 1159 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1160 mvjsadcost, mvsadcost, sad_per_bit); |
| 1161 |
| 1162 if (thissad < bestsad) { |
| 1163 bestsad = thissad; |
| 1164 best_tr = tr; |
| 1165 best_tc = tc + i; |
| 1166 } |
| 1167 } |
| 1168 } |
| 1169 } |
| 1170 } |
| 1171 } |
| 1172 |
| 1173 best_mv->row += best_tr; |
| 1174 best_mv->col += best_tc; |
| 1175 |
| 1176 this_mv.row = best_mv->row * 8; |
| 1177 this_mv.col = best_mv->col * 8; |
| 1178 |
| 1179 if (bestsad == INT_MAX) |
| 1180 return INT_MAX; |
| 1181 |
| 1182 return fn_ptr->vf(what, what_stride, best_address, in_what_stride, |
| 1183 (unsigned int *)(&thissad)) + |
| 1184 mv_err_cost(&this_mv, center_mv, |
| 1185 mvjcost, mvcost, x->errorperbit); |
| 1186 } |
| 1187 |
| 1072 int vp9_diamond_search_sad_c(MACROBLOCK *x, | 1188 int vp9_diamond_search_sad_c(MACROBLOCK *x, |
| 1073 int_mv *ref_mv, int_mv *best_mv, | 1189 MV *ref_mv, MV *best_mv, |
| 1074 int search_param, int sad_per_bit, int *num00, | 1190 int search_param, int sad_per_bit, int *num00, |
| 1075 vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost, | 1191 vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost, |
| 1076 int *mvcost[2], int_mv *center_mv) { | 1192 int *mvcost[2], const MV *center_mv) { |
| 1077 int i, j, step; | 1193 int i, j, step; |
| 1078 | 1194 |
| 1079 const MACROBLOCKD* const xd = &x->e_mbd; | 1195 const MACROBLOCKD* const xd = &x->e_mbd; |
| 1080 uint8_t *what = x->plane[0].src.buf; | 1196 uint8_t *what = x->plane[0].src.buf; |
| 1081 int what_stride = x->plane[0].src.stride; | 1197 int what_stride = x->plane[0].src.stride; |
| 1082 uint8_t *in_what; | 1198 uint8_t *in_what; |
| 1083 int in_what_stride = xd->plane[0].pre[0].stride; | 1199 int in_what_stride = xd->plane[0].pre[0].stride; |
| 1084 uint8_t *best_address; | 1200 uint8_t *best_address; |
| 1085 | 1201 |
| 1086 int tot_steps; | 1202 int tot_steps; |
| 1087 int_mv this_mv; | 1203 MV this_mv; |
| 1088 | 1204 |
| 1089 int bestsad = INT_MAX; | 1205 int bestsad = INT_MAX; |
| 1090 int best_site = 0; | 1206 int best_site = 0; |
| 1091 int last_site = 0; | 1207 int last_site = 0; |
| 1092 | 1208 |
| 1093 int ref_row, ref_col; | 1209 int ref_row, ref_col; |
| 1094 int this_row_offset, this_col_offset; | 1210 int this_row_offset, this_col_offset; |
| 1095 search_site *ss; | 1211 search_site *ss; |
| 1096 | 1212 |
| 1097 uint8_t *check_here; | 1213 uint8_t *check_here; |
| 1098 int thissad; | 1214 int thissad; |
| 1099 int_mv fcenter_mv; | 1215 int_mv fcenter_mv; |
| 1100 | 1216 |
| 1101 int *mvjsadcost = x->nmvjointsadcost; | 1217 int *mvjsadcost = x->nmvjointsadcost; |
| 1102 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; | 1218 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; |
| 1103 | 1219 |
| 1104 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; | 1220 fcenter_mv.as_mv.row = center_mv->row >> 3; |
| 1105 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; | 1221 fcenter_mv.as_mv.col = center_mv->col >> 3; |
| 1106 | 1222 |
| 1107 clamp_mv(&ref_mv->as_mv, | 1223 clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max); |
| 1108 x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max); | 1224 ref_row = ref_mv->row; |
| 1109 ref_row = ref_mv->as_mv.row; | 1225 ref_col = ref_mv->col; |
| 1110 ref_col = ref_mv->as_mv.col; | |
| 1111 *num00 = 0; | 1226 *num00 = 0; |
| 1112 best_mv->as_mv.row = ref_row; | 1227 best_mv->row = ref_row; |
| 1113 best_mv->as_mv.col = ref_col; | 1228 best_mv->col = ref_col; |
| 1114 | 1229 |
| 1115 // Work out the start point for the search | 1230 // Work out the start point for the search |
| 1116 in_what = (uint8_t *)(xd->plane[0].pre[0].buf + | 1231 in_what = (uint8_t *)(xd->plane[0].pre[0].buf + |
| 1117 (ref_row * (xd->plane[0].pre[0].stride)) + ref_col); | 1232 ref_row * in_what_stride + ref_col); |
| 1118 best_address = in_what; | 1233 best_address = in_what; |
| 1119 | 1234 |
| 1120 // Check the starting position | 1235 // Check the starting position |
| 1121 bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) | 1236 bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) |
| 1122 + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv, | 1237 + mvsad_err_cost(best_mv, &fcenter_mv.as_mv, |
| 1123 mvjsadcost, mvsadcost, sad_per_bit); | 1238 mvjsadcost, mvsadcost, sad_per_bit); |
| 1124 | 1239 |
| 1125 // search_param determines the length of the initial step and hence the number | 1240 // search_param determines the length of the initial step and hence the number |
| 1126 // of iterations | 1241 // of iterations |
| 1127 // 0 = initial step (MAX_FIRST_STEP) pel : 1 = (MAX_FIRST_STEP/2) pel, 2 = | 1242 // 0 = initial step (MAX_FIRST_STEP) pel : 1 = (MAX_FIRST_STEP/2) pel, 2 = |
| 1128 // (MAX_FIRST_STEP/4) pel... etc. | 1243 // (MAX_FIRST_STEP/4) pel... etc. |
| 1129 ss = &x->ss[search_param * x->searches_per_step]; | 1244 ss = &x->ss[search_param * x->searches_per_step]; |
| 1130 tot_steps = (x->ss_count / x->searches_per_step) - search_param; | 1245 tot_steps = (x->ss_count / x->searches_per_step) - search_param; |
| 1131 | 1246 |
| 1132 i = 1; | 1247 i = 1; |
| 1133 | 1248 |
| 1134 for (step = 0; step < tot_steps; step++) { | 1249 for (step = 0; step < tot_steps; step++) { |
| 1135 for (j = 0; j < x->searches_per_step; j++) { | 1250 for (j = 0; j < x->searches_per_step; j++) { |
| 1136 // Trap illegal vectors | 1251 // Trap illegal vectors |
| 1137 this_row_offset = best_mv->as_mv.row + ss[i].mv.row; | 1252 this_row_offset = best_mv->row + ss[i].mv.row; |
| 1138 this_col_offset = best_mv->as_mv.col + ss[i].mv.col; | 1253 this_col_offset = best_mv->col + ss[i].mv.col; |
| 1139 | 1254 |
| 1140 if ((this_col_offset > x->mv_col_min) && | 1255 if ((this_col_offset > x->mv_col_min) && |
| 1141 (this_col_offset < x->mv_col_max) && | 1256 (this_col_offset < x->mv_col_max) && |
| 1142 (this_row_offset > x->mv_row_min) && | 1257 (this_row_offset > x->mv_row_min) && |
| 1143 (this_row_offset < x->mv_row_max)) { | 1258 (this_row_offset < x->mv_row_max)) { |
| 1144 check_here = ss[i].offset + best_address; | 1259 check_here = ss[i].offset + best_address; |
| 1145 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, | 1260 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, |
| 1146 bestsad); | 1261 bestsad); |
| 1147 | 1262 |
| 1148 if (thissad < bestsad) { | 1263 if (thissad < bestsad) { |
| 1149 this_mv.as_mv.row = this_row_offset; | 1264 this_mv.row = this_row_offset; |
| 1150 this_mv.as_mv.col = this_col_offset; | 1265 this_mv.col = this_col_offset; |
| 1151 thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 1266 thissad += mvsad_err_cost(&this_mv, &fcenter_mv.as_mv, |
| 1152 mvjsadcost, mvsadcost, sad_per_bit); | 1267 mvjsadcost, mvsadcost, sad_per_bit); |
| 1153 | 1268 |
| 1154 if (thissad < bestsad) { | 1269 if (thissad < bestsad) { |
| 1155 bestsad = thissad; | 1270 bestsad = thissad; |
| 1156 best_site = i; | 1271 best_site = i; |
| 1157 } | 1272 } |
| 1158 } | 1273 } |
| 1159 } | 1274 } |
| 1160 | 1275 |
| 1161 i++; | 1276 i++; |
| 1162 } | 1277 } |
| 1163 | 1278 |
| 1164 if (best_site != last_site) { | 1279 if (best_site != last_site) { |
| 1165 best_mv->as_mv.row += ss[best_site].mv.row; | 1280 best_mv->row += ss[best_site].mv.row; |
| 1166 best_mv->as_mv.col += ss[best_site].mv.col; | 1281 best_mv->col += ss[best_site].mv.col; |
| 1167 best_address += ss[best_site].offset; | 1282 best_address += ss[best_site].offset; |
| 1168 last_site = best_site; | 1283 last_site = best_site; |
| 1169 #if defined(NEW_DIAMOND_SEARCH) | 1284 #if defined(NEW_DIAMOND_SEARCH) |
| 1170 while (1) { | 1285 while (1) { |
| 1171 this_row_offset = best_mv->as_mv.row + ss[best_site].mv.row; | 1286 this_row_offset = best_mv->row + ss[best_site].mv.row; |
| 1172 this_col_offset = best_mv->as_mv.col + ss[best_site].mv.col; | 1287 this_col_offset = best_mv->col + ss[best_site].mv.col; |
| 1173 if ((this_col_offset > x->mv_col_min) && | 1288 if ((this_col_offset > x->mv_col_min) && |
| 1174 (this_col_offset < x->mv_col_max) && | 1289 (this_col_offset < x->mv_col_max) && |
| 1175 (this_row_offset > x->mv_row_min) && | 1290 (this_row_offset > x->mv_row_min) && |
| 1176 (this_row_offset < x->mv_row_max)) { | 1291 (this_row_offset < x->mv_row_max)) { |
| 1177 check_here = ss[best_site].offset + best_address; | 1292 check_here = ss[best_site].offset + best_address; |
| 1178 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, | 1293 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, |
| 1179 bestsad); | 1294 bestsad); |
| 1180 if (thissad < bestsad) { | 1295 if (thissad < bestsad) { |
| 1181 this_mv.as_mv.row = this_row_offset; | 1296 this_mv.row = this_row_offset; |
| 1182 this_mv.as_mv.col = this_col_offset; | 1297 this_mv.col = this_col_offset; |
| 1183 thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 1298 thissad += mvsad_err_cost(&this_mv, &fcenter_mv.as_mv, |
| 1184 mvjsadcost, mvsadcost, sad_per_bit); | 1299 mvjsadcost, mvsadcost, sad_per_bit); |
| 1185 if (thissad < bestsad) { | 1300 if (thissad < bestsad) { |
| 1186 bestsad = thissad; | 1301 bestsad = thissad; |
| 1187 best_mv->as_mv.row += ss[best_site].mv.row; | 1302 best_mv->row += ss[best_site].mv.row; |
| 1188 best_mv->as_mv.col += ss[best_site].mv.col; | 1303 best_mv->col += ss[best_site].mv.col; |
| 1189 best_address += ss[best_site].offset; | 1304 best_address += ss[best_site].offset; |
| 1190 continue; | 1305 continue; |
| 1191 } | 1306 } |
| 1192 } | 1307 } |
| 1193 } | 1308 } |
| 1194 break; | 1309 break; |
| 1195 }; | 1310 }; |
| 1196 #endif | 1311 #endif |
| 1197 } else if (best_address == in_what) { | 1312 } else if (best_address == in_what) { |
| 1198 (*num00)++; | 1313 (*num00)++; |
| 1199 } | 1314 } |
| 1200 } | 1315 } |
| 1201 | 1316 |
| 1202 this_mv.as_mv.row = best_mv->as_mv.row * 8; | 1317 this_mv.row = best_mv->row * 8; |
| 1203 this_mv.as_mv.col = best_mv->as_mv.col * 8; | 1318 this_mv.col = best_mv->col * 8; |
| 1204 | 1319 |
| 1205 if (bestsad == INT_MAX) | 1320 if (bestsad == INT_MAX) |
| 1206 return INT_MAX; | 1321 return INT_MAX; |
| 1207 | 1322 |
| 1208 return fn_ptr->vf(what, what_stride, best_address, in_what_stride, | 1323 return fn_ptr->vf(what, what_stride, best_address, in_what_stride, |
| 1209 (unsigned int *)(&thissad)) + | 1324 (unsigned int *)(&thissad)) + |
| 1210 mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, | 1325 mv_err_cost(&this_mv, center_mv, |
| 1211 mvjcost, mvcost, x->errorperbit); | 1326 mvjcost, mvcost, x->errorperbit); |
| 1212 } | 1327 } |
| 1213 | 1328 |
| 1214 int vp9_diamond_search_sadx4(MACROBLOCK *x, | 1329 int vp9_diamond_search_sadx4(MACROBLOCK *x, |
| 1215 int_mv *ref_mv, int_mv *best_mv, int search_param, | 1330 MV *ref_mv, MV *best_mv, int search_param, |
| 1216 int sad_per_bit, int *num00, | 1331 int sad_per_bit, int *num00, |
| 1217 vp9_variance_fn_ptr_t *fn_ptr, | 1332 vp9_variance_fn_ptr_t *fn_ptr, |
| 1218 int *mvjcost, int *mvcost[2], int_mv *center_mv) { | 1333 int *mvjcost, int *mvcost[2], |
| 1334 const MV *center_mv) { |
| 1219 int i, j, step; | 1335 int i, j, step; |
| 1220 | 1336 |
| 1221 const MACROBLOCKD* const xd = &x->e_mbd; | 1337 const MACROBLOCKD* const xd = &x->e_mbd; |
| 1222 uint8_t *what = x->plane[0].src.buf; | 1338 uint8_t *what = x->plane[0].src.buf; |
| 1223 int what_stride = x->plane[0].src.stride; | 1339 int what_stride = x->plane[0].src.stride; |
| 1224 uint8_t *in_what; | 1340 uint8_t *in_what; |
| 1225 int in_what_stride = xd->plane[0].pre[0].stride; | 1341 int in_what_stride = xd->plane[0].pre[0].stride; |
| 1226 uint8_t *best_address; | 1342 uint8_t *best_address; |
| 1227 | 1343 |
| 1228 int tot_steps; | 1344 int tot_steps; |
| 1229 int_mv this_mv; | 1345 MV this_mv; |
| 1230 | 1346 |
| 1231 unsigned int bestsad = INT_MAX; | 1347 unsigned int bestsad = INT_MAX; |
| 1232 int best_site = 0; | 1348 int best_site = 0; |
| 1233 int last_site = 0; | 1349 int last_site = 0; |
| 1234 | 1350 |
| 1235 int ref_row; | 1351 int ref_row; |
| 1236 int ref_col; | 1352 int ref_col; |
| 1237 int this_row_offset; | 1353 int this_row_offset; |
| 1238 int this_col_offset; | 1354 int this_col_offset; |
| 1239 search_site *ss; | 1355 search_site *ss; |
| 1240 | 1356 |
| 1241 uint8_t *check_here; | 1357 uint8_t *check_here; |
| 1242 unsigned int thissad; | 1358 unsigned int thissad; |
| 1243 int_mv fcenter_mv; | 1359 int_mv fcenter_mv; |
| 1244 | 1360 |
| 1245 int *mvjsadcost = x->nmvjointsadcost; | 1361 int *mvjsadcost = x->nmvjointsadcost; |
| 1246 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; | 1362 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; |
| 1247 | 1363 |
| 1248 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; | 1364 fcenter_mv.as_mv.row = center_mv->row >> 3; |
| 1249 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; | 1365 fcenter_mv.as_mv.col = center_mv->col >> 3; |
| 1250 | 1366 |
| 1251 clamp_mv(&ref_mv->as_mv, | 1367 clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max); |
| 1252 x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max); | 1368 ref_row = ref_mv->row; |
| 1253 ref_row = ref_mv->as_mv.row; | 1369 ref_col = ref_mv->col; |
| 1254 ref_col = ref_mv->as_mv.col; | |
| 1255 *num00 = 0; | 1370 *num00 = 0; |
| 1256 best_mv->as_mv.row = ref_row; | 1371 best_mv->row = ref_row; |
| 1257 best_mv->as_mv.col = ref_col; | 1372 best_mv->col = ref_col; |
| 1258 | 1373 |
| 1259 // Work out the start point for the search | 1374 // Work out the start point for the search |
| 1260 in_what = (uint8_t *)(xd->plane[0].pre[0].buf + | 1375 in_what = (uint8_t *)(xd->plane[0].pre[0].buf + |
| 1261 (ref_row * (xd->plane[0].pre[0].stride)) + ref_col); | 1376 ref_row * in_what_stride + ref_col); |
| 1262 best_address = in_what; | 1377 best_address = in_what; |
| 1263 | 1378 |
| 1264 // Check the starting position | 1379 // Check the starting position |
| 1265 bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) | 1380 bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, 0x7fffffff) |
| 1266 + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv, | 1381 + mvsad_err_cost(best_mv, &fcenter_mv.as_mv, |
| 1267 mvjsadcost, mvsadcost, sad_per_bit); | 1382 mvjsadcost, mvsadcost, sad_per_bit); |
| 1268 | 1383 |
| 1269 // search_param determines the length of the initial step and hence the number | 1384 // search_param determines the length of the initial step and hence the number |
| 1270 // of iterations. | 1385 // of iterations. |
| 1271 // 0 = initial step (MAX_FIRST_STEP) pel | 1386 // 0 = initial step (MAX_FIRST_STEP) pel |
| 1272 // 1 = (MAX_FIRST_STEP/2) pel, | 1387 // 1 = (MAX_FIRST_STEP/2) pel, |
| 1273 // 2 = (MAX_FIRST_STEP/4) pel... | 1388 // 2 = (MAX_FIRST_STEP/4) pel... |
| 1274 ss = &x->ss[search_param * x->searches_per_step]; | 1389 ss = &x->ss[search_param * x->searches_per_step]; |
| 1275 tot_steps = (x->ss_count / x->searches_per_step) - search_param; | 1390 tot_steps = (x->ss_count / x->searches_per_step) - search_param; |
| 1276 | 1391 |
| 1277 i = 1; | 1392 i = 1; |
| 1278 | 1393 |
| 1279 for (step = 0; step < tot_steps; step++) { | 1394 for (step = 0; step < tot_steps; step++) { |
| 1280 int all_in = 1, t; | 1395 int all_in = 1, t; |
| 1281 | 1396 |
| 1282 // All_in is true if every one of the points we are checking are within | 1397 // All_in is true if every one of the points we are checking are within |
| 1283 // the bounds of the image. | 1398 // the bounds of the image. |
| 1284 all_in &= ((best_mv->as_mv.row + ss[i].mv.row) > x->mv_row_min); | 1399 all_in &= ((best_mv->row + ss[i].mv.row) > x->mv_row_min); |
| 1285 all_in &= ((best_mv->as_mv.row + ss[i + 1].mv.row) < x->mv_row_max); | 1400 all_in &= ((best_mv->row + ss[i + 1].mv.row) < x->mv_row_max); |
| 1286 all_in &= ((best_mv->as_mv.col + ss[i + 2].mv.col) > x->mv_col_min); | 1401 all_in &= ((best_mv->col + ss[i + 2].mv.col) > x->mv_col_min); |
| 1287 all_in &= ((best_mv->as_mv.col + ss[i + 3].mv.col) < x->mv_col_max); | 1402 all_in &= ((best_mv->col + ss[i + 3].mv.col) < x->mv_col_max); |
| 1288 | 1403 |
| 1289 // If all the pixels are within the bounds we don't check whether the | 1404 // If all the pixels are within the bounds we don't check whether the |
| 1290 // search point is valid in this loop, otherwise we check each point | 1405 // search point is valid in this loop, otherwise we check each point |
| 1291 // for validity.. | 1406 // for validity.. |
| 1292 if (all_in) { | 1407 if (all_in) { |
| 1293 unsigned int sad_array[4]; | 1408 unsigned int sad_array[4]; |
| 1294 | 1409 |
| 1295 for (j = 0; j < x->searches_per_step; j += 4) { | 1410 for (j = 0; j < x->searches_per_step; j += 4) { |
| 1296 unsigned char const *block_offset[4]; | 1411 unsigned char const *block_offset[4]; |
| 1297 | 1412 |
| 1298 for (t = 0; t < 4; t++) | 1413 for (t = 0; t < 4; t++) |
| 1299 block_offset[t] = ss[i + t].offset + best_address; | 1414 block_offset[t] = ss[i + t].offset + best_address; |
| 1300 | 1415 |
| 1301 fn_ptr->sdx4df(what, what_stride, block_offset, in_what_stride, | 1416 fn_ptr->sdx4df(what, what_stride, block_offset, in_what_stride, |
| 1302 sad_array); | 1417 sad_array); |
| 1303 | 1418 |
| 1304 for (t = 0; t < 4; t++, i++) { | 1419 for (t = 0; t < 4; t++, i++) { |
| 1305 if (sad_array[t] < bestsad) { | 1420 if (sad_array[t] < bestsad) { |
| 1306 this_mv.as_mv.row = best_mv->as_mv.row + ss[i].mv.row; | 1421 this_mv.row = best_mv->row + ss[i].mv.row; |
| 1307 this_mv.as_mv.col = best_mv->as_mv.col + ss[i].mv.col; | 1422 this_mv.col = best_mv->col + ss[i].mv.col; |
| 1308 sad_array[t] += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 1423 sad_array[t] += mvsad_err_cost(&this_mv, &fcenter_mv.as_mv, |
| 1309 mvjsadcost, mvsadcost, sad_per_bit); | 1424 mvjsadcost, mvsadcost, sad_per_bit); |
| 1310 | 1425 |
| 1311 if (sad_array[t] < bestsad) { | 1426 if (sad_array[t] < bestsad) { |
| 1312 bestsad = sad_array[t]; | 1427 bestsad = sad_array[t]; |
| 1313 best_site = i; | 1428 best_site = i; |
| 1314 } | 1429 } |
| 1315 } | 1430 } |
| 1316 } | 1431 } |
| 1317 } | 1432 } |
| 1318 } else { | 1433 } else { |
| 1319 for (j = 0; j < x->searches_per_step; j++) { | 1434 for (j = 0; j < x->searches_per_step; j++) { |
| 1320 // Trap illegal vectors | 1435 // Trap illegal vectors |
| 1321 this_row_offset = best_mv->as_mv.row + ss[i].mv.row; | 1436 this_row_offset = best_mv->row + ss[i].mv.row; |
| 1322 this_col_offset = best_mv->as_mv.col + ss[i].mv.col; | 1437 this_col_offset = best_mv->col + ss[i].mv.col; |
| 1323 | 1438 |
| 1324 if ((this_col_offset > x->mv_col_min) && | 1439 if ((this_col_offset > x->mv_col_min) && |
| 1325 (this_col_offset < x->mv_col_max) && | 1440 (this_col_offset < x->mv_col_max) && |
| 1326 (this_row_offset > x->mv_row_min) && | 1441 (this_row_offset > x->mv_row_min) && |
| 1327 (this_row_offset < x->mv_row_max)) { | 1442 (this_row_offset < x->mv_row_max)) { |
| 1328 check_here = ss[i].offset + best_address; | 1443 check_here = ss[i].offset + best_address; |
| 1329 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, | 1444 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, |
| 1330 bestsad); | 1445 bestsad); |
| 1331 | 1446 |
| 1332 if (thissad < bestsad) { | 1447 if (thissad < bestsad) { |
| 1333 this_mv.as_mv.row = this_row_offset; | 1448 this_mv.row = this_row_offset; |
| 1334 this_mv.as_mv.col = this_col_offset; | 1449 this_mv.col = this_col_offset; |
| 1335 thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 1450 thissad += mvsad_err_cost(&this_mv, &fcenter_mv.as_mv, |
| 1336 mvjsadcost, mvsadcost, sad_per_bit); | 1451 mvjsadcost, mvsadcost, sad_per_bit); |
| 1337 | 1452 |
| 1338 if (thissad < bestsad) { | 1453 if (thissad < bestsad) { |
| 1339 bestsad = thissad; | 1454 bestsad = thissad; |
| 1340 best_site = i; | 1455 best_site = i; |
| 1341 } | 1456 } |
| 1342 } | 1457 } |
| 1343 } | 1458 } |
| 1344 i++; | 1459 i++; |
| 1345 } | 1460 } |
| 1346 } | 1461 } |
| 1347 if (best_site != last_site) { | 1462 if (best_site != last_site) { |
| 1348 best_mv->as_mv.row += ss[best_site].mv.row; | 1463 best_mv->row += ss[best_site].mv.row; |
| 1349 best_mv->as_mv.col += ss[best_site].mv.col; | 1464 best_mv->col += ss[best_site].mv.col; |
| 1350 best_address += ss[best_site].offset; | 1465 best_address += ss[best_site].offset; |
| 1351 last_site = best_site; | 1466 last_site = best_site; |
| 1352 #if defined(NEW_DIAMOND_SEARCH) | 1467 #if defined(NEW_DIAMOND_SEARCH) |
| 1353 while (1) { | 1468 while (1) { |
| 1354 this_row_offset = best_mv->as_mv.row + ss[best_site].mv.row; | 1469 this_row_offset = best_mv->row + ss[best_site].mv.row; |
| 1355 this_col_offset = best_mv->as_mv.col + ss[best_site].mv.col; | 1470 this_col_offset = best_mv->col + ss[best_site].mv.col; |
| 1356 if ((this_col_offset > x->mv_col_min) && | 1471 if ((this_col_offset > x->mv_col_min) && |
| 1357 (this_col_offset < x->mv_col_max) && | 1472 (this_col_offset < x->mv_col_max) && |
| 1358 (this_row_offset > x->mv_row_min) && | 1473 (this_row_offset > x->mv_row_min) && |
| 1359 (this_row_offset < x->mv_row_max)) { | 1474 (this_row_offset < x->mv_row_max)) { |
| 1360 check_here = ss[best_site].offset + best_address; | 1475 check_here = ss[best_site].offset + best_address; |
| 1361 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, | 1476 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, |
| 1362 bestsad); | 1477 bestsad); |
| 1363 if (thissad < bestsad) { | 1478 if (thissad < bestsad) { |
| 1364 this_mv.as_mv.row = this_row_offset; | 1479 this_mv.row = this_row_offset; |
| 1365 this_mv.as_mv.col = this_col_offset; | 1480 this_mv.col = this_col_offset; |
| 1366 thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 1481 thissad += mvsad_err_cost(&this_mv, &fcenter_mv.as_mv, |
| 1367 mvjsadcost, mvsadcost, sad_per_bit); | 1482 mvjsadcost, mvsadcost, sad_per_bit); |
| 1368 if (thissad < bestsad) { | 1483 if (thissad < bestsad) { |
| 1369 bestsad = thissad; | 1484 bestsad = thissad; |
| 1370 best_mv->as_mv.row += ss[best_site].mv.row; | 1485 best_mv->row += ss[best_site].mv.row; |
| 1371 best_mv->as_mv.col += ss[best_site].mv.col; | 1486 best_mv->col += ss[best_site].mv.col; |
| 1372 best_address += ss[best_site].offset; | 1487 best_address += ss[best_site].offset; |
| 1373 continue; | 1488 continue; |
| 1374 } | 1489 } |
| 1375 } | 1490 } |
| 1376 } | 1491 } |
| 1377 break; | 1492 break; |
| 1378 }; | 1493 }; |
| 1379 #endif | 1494 #endif |
| 1380 } else if (best_address == in_what) { | 1495 } else if (best_address == in_what) { |
| 1381 (*num00)++; | 1496 (*num00)++; |
| 1382 } | 1497 } |
| 1383 } | 1498 } |
| 1384 | 1499 |
| 1385 this_mv.as_mv.row = best_mv->as_mv.row * 8; | 1500 this_mv.row = best_mv->row * 8; |
| 1386 this_mv.as_mv.col = best_mv->as_mv.col * 8; | 1501 this_mv.col = best_mv->col * 8; |
| 1387 | 1502 |
| 1388 if (bestsad == INT_MAX) | 1503 if (bestsad == INT_MAX) |
| 1389 return INT_MAX; | 1504 return INT_MAX; |
| 1390 | 1505 |
| 1391 return fn_ptr->vf(what, what_stride, best_address, in_what_stride, | 1506 return fn_ptr->vf(what, what_stride, best_address, in_what_stride, |
| 1392 (unsigned int *)(&thissad)) + | 1507 (unsigned int *)(&thissad)) + |
| 1393 mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, | 1508 mv_err_cost(&this_mv, center_mv, |
| 1394 mvjcost, mvcost, x->errorperbit); | 1509 mvjcost, mvcost, x->errorperbit); |
| 1395 } | 1510 } |
| 1396 | 1511 |
| 1397 /* do_refine: If last step (1-away) of n-step search doesn't pick the center | 1512 /* do_refine: If last step (1-away) of n-step search doesn't pick the center |
| 1398 point as the best match, we will do a final 1-away diamond | 1513 point as the best match, we will do a final 1-away diamond |
| 1399 refining search */ | 1514 refining search */ |
| 1400 | 1515 |
| 1401 int vp9_full_pixel_diamond(VP9_COMP *cpi, MACROBLOCK *x, | 1516 int vp9_full_pixel_diamond(VP9_COMP *cpi, MACROBLOCK *x, |
| 1402 int_mv *mvp_full, int step_param, | 1517 int_mv *mvp_full, int step_param, |
| 1403 int sadpb, int further_steps, | 1518 int sadpb, int further_steps, |
| 1404 int do_refine, vp9_variance_fn_ptr_t *fn_ptr, | 1519 int do_refine, vp9_variance_fn_ptr_t *fn_ptr, |
| 1405 int_mv *ref_mv, int_mv *dst_mv) { | 1520 int_mv *ref_mv, int_mv *dst_mv) { |
| 1406 int_mv temp_mv; | 1521 int_mv temp_mv; |
| 1407 int thissme, n, num00; | 1522 int thissme, n, num00; |
| 1408 int bestsme = cpi->diamond_search_sad(x, mvp_full, &temp_mv, | 1523 int bestsme = cpi->diamond_search_sad(x, &mvp_full->as_mv, &temp_mv.as_mv, |
| 1409 step_param, sadpb, &num00, | 1524 step_param, sadpb, &num00, |
| 1410 fn_ptr, x->nmvjointcost, | 1525 fn_ptr, x->nmvjointcost, |
| 1411 x->mvcost, ref_mv); | 1526 x->mvcost, &ref_mv->as_mv); |
| 1412 dst_mv->as_int = temp_mv.as_int; | 1527 dst_mv->as_int = temp_mv.as_int; |
| 1413 | 1528 |
| 1414 n = num00; | 1529 n = num00; |
| 1415 num00 = 0; | 1530 num00 = 0; |
| 1416 | 1531 |
| 1417 /* If there won't be more n-step search, check to see if refining search is | 1532 /* If there won't be more n-step search, check to see if refining search is |
| 1418 * needed. */ | 1533 * needed. */ |
| 1419 if (n > further_steps) | 1534 if (n > further_steps) |
| 1420 do_refine = 0; | 1535 do_refine = 0; |
| 1421 | 1536 |
| 1422 while (n < further_steps) { | 1537 while (n < further_steps) { |
| 1423 n++; | 1538 n++; |
| 1424 | 1539 |
| 1425 if (num00) { | 1540 if (num00) { |
| 1426 num00--; | 1541 num00--; |
| 1427 } else { | 1542 } else { |
| 1428 thissme = cpi->diamond_search_sad(x, mvp_full, &temp_mv, | 1543 thissme = cpi->diamond_search_sad(x, &mvp_full->as_mv, &temp_mv.as_mv, |
| 1429 step_param + n, sadpb, &num00, | 1544 step_param + n, sadpb, &num00, |
| 1430 fn_ptr, x->nmvjointcost, x->mvcost, | 1545 fn_ptr, x->nmvjointcost, x->mvcost, |
| 1431 ref_mv); | 1546 &ref_mv->as_mv); |
| 1432 | 1547 |
| 1433 /* check to see if refining search is needed. */ | 1548 /* check to see if refining search is needed. */ |
| 1434 if (num00 > (further_steps - n)) | 1549 if (num00 > (further_steps - n)) |
| 1435 do_refine = 0; | 1550 do_refine = 0; |
| 1436 | 1551 |
| 1437 if (thissme < bestsme) { | 1552 if (thissme < bestsme) { |
| 1438 bestsme = thissme; | 1553 bestsme = thissme; |
| 1439 dst_mv->as_int = temp_mv.as_int; | 1554 dst_mv->as_int = temp_mv.as_int; |
| 1440 } | 1555 } |
| 1441 } | 1556 } |
| 1442 } | 1557 } |
| 1443 | 1558 |
| 1444 /* final 1-away diamond refining search */ | 1559 /* final 1-away diamond refining search */ |
| 1445 if (do_refine == 1) { | 1560 if (do_refine == 1) { |
| 1446 int search_range = 8; | 1561 int search_range = 8; |
| 1447 int_mv best_mv; | 1562 int_mv best_mv; |
| 1448 best_mv.as_int = dst_mv->as_int; | 1563 best_mv.as_int = dst_mv->as_int; |
| 1449 thissme = cpi->refining_search_sad(x, &best_mv, sadpb, search_range, | 1564 thissme = cpi->refining_search_sad(x, &best_mv.as_mv, sadpb, search_range, |
| 1450 fn_ptr, x->nmvjointcost, x->mvcost, | 1565 fn_ptr, x->nmvjointcost, x->mvcost, |
| 1451 ref_mv); | 1566 &ref_mv->as_mv); |
| 1452 | 1567 |
| 1453 if (thissme < bestsme) { | 1568 if (thissme < bestsme) { |
| 1454 bestsme = thissme; | 1569 bestsme = thissme; |
| 1455 dst_mv->as_int = best_mv.as_int; | 1570 dst_mv->as_int = best_mv.as_int; |
| 1456 } | 1571 } |
| 1457 } | 1572 } |
| 1458 return bestsme; | 1573 return bestsme; |
| 1459 } | 1574 } |
| 1460 | 1575 |
| 1461 int vp9_full_search_sad_c(MACROBLOCK *x, int_mv *ref_mv, | 1576 int vp9_full_search_sad_c(MACROBLOCK *x, MV *ref_mv, |
| 1462 int sad_per_bit, int distance, | 1577 int sad_per_bit, int distance, |
| 1463 vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost, | 1578 vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost, |
| 1464 int *mvcost[2], | 1579 int *mvcost[2], |
| 1465 int_mv *center_mv, int n) { | 1580 const MV *center_mv, int n) { |
| 1466 const MACROBLOCKD* const xd = &x->e_mbd; | 1581 const MACROBLOCKD* const xd = &x->e_mbd; |
| 1467 uint8_t *what = x->plane[0].src.buf; | 1582 uint8_t *what = x->plane[0].src.buf; |
| 1468 int what_stride = x->plane[0].src.stride; | 1583 int what_stride = x->plane[0].src.stride; |
| 1469 uint8_t *in_what; | 1584 uint8_t *in_what; |
| 1470 int in_what_stride = xd->plane[0].pre[0].stride; | 1585 int in_what_stride = xd->plane[0].pre[0].stride; |
| 1471 int mv_stride = xd->plane[0].pre[0].stride; | 1586 int mv_stride = xd->plane[0].pre[0].stride; |
| 1472 uint8_t *bestaddress; | 1587 uint8_t *bestaddress; |
| 1473 int_mv *best_mv = &x->e_mbd.mi_8x8[0]->bmi[n].as_mv[0]; | 1588 int_mv *best_mv = &x->e_mbd.mi_8x8[0]->bmi[n].as_mv[0]; |
| 1474 int_mv this_mv; | 1589 MV this_mv; |
| 1475 int bestsad = INT_MAX; | 1590 int bestsad = INT_MAX; |
| 1476 int r, c; | 1591 int r, c; |
| 1477 | 1592 |
| 1478 uint8_t *check_here; | 1593 uint8_t *check_here; |
| 1479 int thissad; | 1594 int thissad; |
| 1480 | 1595 |
| 1481 int ref_row = ref_mv->as_mv.row; | 1596 int ref_row = ref_mv->row; |
| 1482 int ref_col = ref_mv->as_mv.col; | 1597 int ref_col = ref_mv->col; |
| 1483 | 1598 |
| 1484 int row_min = ref_row - distance; | 1599 int row_min = ref_row - distance; |
| 1485 int row_max = ref_row + distance; | 1600 int row_max = ref_row + distance; |
| 1486 int col_min = ref_col - distance; | 1601 int col_min = ref_col - distance; |
| 1487 int col_max = ref_col + distance; | 1602 int col_max = ref_col + distance; |
| 1488 int_mv fcenter_mv; | 1603 MV fcenter_mv; |
| 1489 | 1604 |
| 1490 int *mvjsadcost = x->nmvjointsadcost; | 1605 int *mvjsadcost = x->nmvjointsadcost; |
| 1491 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; | 1606 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; |
| 1492 | 1607 |
| 1493 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; | 1608 fcenter_mv.row = center_mv->row >> 3; |
| 1494 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; | 1609 fcenter_mv.col = center_mv->col >> 3; |
| 1495 | 1610 |
| 1496 // Work out the mid point for the search | 1611 // Work out the mid point for the search |
| 1497 in_what = xd->plane[0].pre[0].buf; | 1612 in_what = xd->plane[0].pre[0].buf; |
| 1498 bestaddress = in_what + (ref_row * xd->plane[0].pre[0].stride) + ref_col; | 1613 bestaddress = in_what + (ref_row * xd->plane[0].pre[0].stride) + ref_col; |
| 1499 | 1614 |
| 1500 best_mv->as_mv.row = ref_row; | 1615 best_mv->as_mv.row = ref_row; |
| 1501 best_mv->as_mv.col = ref_col; | 1616 best_mv->as_mv.col = ref_col; |
| 1502 | 1617 |
| 1503 // Baseline value at the centre | 1618 // Baseline value at the centre |
| 1504 bestsad = fn_ptr->sdf(what, what_stride, bestaddress, | 1619 bestsad = fn_ptr->sdf(what, what_stride, bestaddress, |
| 1505 in_what_stride, 0x7fffffff) | 1620 in_what_stride, 0x7fffffff) |
| 1506 + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv, | 1621 + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv, |
| 1507 mvjsadcost, mvsadcost, sad_per_bit); | 1622 mvjsadcost, mvsadcost, sad_per_bit); |
| 1508 | 1623 |
| 1509 // Apply further limits to prevent us looking using vectors that stretch | 1624 // Apply further limits to prevent us looking using vectors that stretch |
| 1510 // beyond the UMV border | 1625 // beyond the UMV border |
| 1511 col_min = MAX(col_min, x->mv_col_min); | 1626 col_min = MAX(col_min, x->mv_col_min); |
| 1512 col_max = MIN(col_max, x->mv_col_max); | 1627 col_max = MIN(col_max, x->mv_col_max); |
| 1513 row_min = MAX(row_min, x->mv_row_min); | 1628 row_min = MAX(row_min, x->mv_row_min); |
| 1514 row_max = MIN(row_max, x->mv_row_max); | 1629 row_max = MIN(row_max, x->mv_row_max); |
| 1515 | 1630 |
| 1516 for (r = row_min; r < row_max; r++) { | 1631 for (r = row_min; r < row_max; r++) { |
| 1517 this_mv.as_mv.row = r; | 1632 this_mv.row = r; |
| 1518 check_here = r * mv_stride + in_what + col_min; | 1633 check_here = r * mv_stride + in_what + col_min; |
| 1519 | 1634 |
| 1520 for (c = col_min; c < col_max; c++) { | 1635 for (c = col_min; c < col_max; c++) { |
| 1521 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, | 1636 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, |
| 1522 bestsad); | 1637 bestsad); |
| 1523 | 1638 |
| 1524 this_mv.as_mv.col = c; | 1639 this_mv.col = c; |
| 1525 thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 1640 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1526 mvjsadcost, mvsadcost, sad_per_bit); | 1641 mvjsadcost, mvsadcost, sad_per_bit); |
| 1527 | 1642 |
| 1528 if (thissad < bestsad) { | 1643 if (thissad < bestsad) { |
| 1529 bestsad = thissad; | 1644 bestsad = thissad; |
| 1530 best_mv->as_mv.row = r; | 1645 best_mv->as_mv.row = r; |
| 1531 best_mv->as_mv.col = c; | 1646 best_mv->as_mv.col = c; |
| 1532 bestaddress = check_here; | 1647 bestaddress = check_here; |
| 1533 } | 1648 } |
| 1534 | 1649 |
| 1535 check_here++; | 1650 check_here++; |
| 1536 } | 1651 } |
| 1537 } | 1652 } |
| 1538 | 1653 |
| 1539 this_mv.as_mv.row = best_mv->as_mv.row * 8; | 1654 this_mv.row = best_mv->as_mv.row * 8; |
| 1540 this_mv.as_mv.col = best_mv->as_mv.col * 8; | 1655 this_mv.col = best_mv->as_mv.col * 8; |
| 1541 | 1656 |
| 1542 if (bestsad < INT_MAX) | 1657 if (bestsad < INT_MAX) |
| 1543 return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, | 1658 return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, |
| 1544 (unsigned int *)(&thissad)) + | 1659 (unsigned int *)(&thissad)) + |
| 1545 mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, | 1660 mv_err_cost(&this_mv, center_mv, |
| 1546 mvjcost, mvcost, x->errorperbit); | 1661 mvjcost, mvcost, x->errorperbit); |
| 1547 else | 1662 else |
| 1548 return INT_MAX; | 1663 return INT_MAX; |
| 1549 } | 1664 } |
| 1550 | 1665 |
| 1551 int vp9_full_search_sadx3(MACROBLOCK *x, int_mv *ref_mv, | 1666 int vp9_full_search_sadx3(MACROBLOCK *x, MV *ref_mv, |
| 1552 int sad_per_bit, int distance, | 1667 int sad_per_bit, int distance, |
| 1553 vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost, | 1668 vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost, |
| 1554 int *mvcost[2], int_mv *center_mv, int n) { | 1669 int *mvcost[2], const MV *center_mv, int n) { |
| 1555 const MACROBLOCKD* const xd = &x->e_mbd; | 1670 const MACROBLOCKD* const xd = &x->e_mbd; |
| 1556 uint8_t *what = x->plane[0].src.buf; | 1671 uint8_t *what = x->plane[0].src.buf; |
| 1557 int what_stride = x->plane[0].src.stride; | 1672 int what_stride = x->plane[0].src.stride; |
| 1558 uint8_t *in_what; | 1673 uint8_t *in_what; |
| 1559 int in_what_stride = xd->plane[0].pre[0].stride; | 1674 int in_what_stride = xd->plane[0].pre[0].stride; |
| 1560 int mv_stride = xd->plane[0].pre[0].stride; | 1675 int mv_stride = xd->plane[0].pre[0].stride; |
| 1561 uint8_t *bestaddress; | 1676 uint8_t *bestaddress; |
| 1562 int_mv *best_mv = &x->e_mbd.mi_8x8[0]->bmi[n].as_mv[0]; | 1677 int_mv *best_mv = &x->e_mbd.mi_8x8[0]->bmi[n].as_mv[0]; |
| 1563 int_mv this_mv; | 1678 MV this_mv; |
| 1564 unsigned int bestsad = INT_MAX; | 1679 unsigned int bestsad = INT_MAX; |
| 1565 int r, c; | 1680 int r, c; |
| 1566 | 1681 |
| 1567 uint8_t *check_here; | 1682 uint8_t *check_here; |
| 1568 unsigned int thissad; | 1683 unsigned int thissad; |
| 1569 | 1684 |
| 1570 int ref_row = ref_mv->as_mv.row; | 1685 int ref_row = ref_mv->row; |
| 1571 int ref_col = ref_mv->as_mv.col; | 1686 int ref_col = ref_mv->col; |
| 1572 | 1687 |
| 1573 int row_min = ref_row - distance; | 1688 int row_min = ref_row - distance; |
| 1574 int row_max = ref_row + distance; | 1689 int row_max = ref_row + distance; |
| 1575 int col_min = ref_col - distance; | 1690 int col_min = ref_col - distance; |
| 1576 int col_max = ref_col + distance; | 1691 int col_max = ref_col + distance; |
| 1577 | 1692 |
| 1578 unsigned int sad_array[3]; | 1693 unsigned int sad_array[3]; |
| 1579 int_mv fcenter_mv; | 1694 MV fcenter_mv; |
| 1580 | 1695 |
| 1581 int *mvjsadcost = x->nmvjointsadcost; | 1696 int *mvjsadcost = x->nmvjointsadcost; |
| 1582 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; | 1697 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; |
| 1583 | 1698 |
| 1584 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; | 1699 fcenter_mv.row = center_mv->row >> 3; |
| 1585 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; | 1700 fcenter_mv.col = center_mv->col >> 3; |
| 1586 | 1701 |
| 1587 // Work out the mid point for the search | 1702 // Work out the mid point for the search |
| 1588 in_what = xd->plane[0].pre[0].buf; | 1703 in_what = xd->plane[0].pre[0].buf; |
| 1589 bestaddress = in_what + (ref_row * xd->plane[0].pre[0].stride) + ref_col; | 1704 bestaddress = in_what + (ref_row * xd->plane[0].pre[0].stride) + ref_col; |
| 1590 | 1705 |
| 1591 best_mv->as_mv.row = ref_row; | 1706 best_mv->as_mv.row = ref_row; |
| 1592 best_mv->as_mv.col = ref_col; | 1707 best_mv->as_mv.col = ref_col; |
| 1593 | 1708 |
| 1594 // Baseline value at the centre | 1709 // Baseline value at the centre |
| 1595 bestsad = fn_ptr->sdf(what, what_stride, | 1710 bestsad = fn_ptr->sdf(what, what_stride, |
| 1596 bestaddress, in_what_stride, 0x7fffffff) | 1711 bestaddress, in_what_stride, 0x7fffffff) |
| 1597 + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv, | 1712 + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv, |
| 1598 mvjsadcost, mvsadcost, sad_per_bit); | 1713 mvjsadcost, mvsadcost, sad_per_bit); |
| 1599 | 1714 |
| 1600 // Apply further limits to prevent us looking using vectors that stretch | 1715 // Apply further limits to prevent us looking using vectors that stretch |
| 1601 // beyond the UMV border | 1716 // beyond the UMV border |
| 1602 col_min = MAX(col_min, x->mv_col_min); | 1717 col_min = MAX(col_min, x->mv_col_min); |
| 1603 col_max = MIN(col_max, x->mv_col_max); | 1718 col_max = MIN(col_max, x->mv_col_max); |
| 1604 row_min = MAX(row_min, x->mv_row_min); | 1719 row_min = MAX(row_min, x->mv_row_min); |
| 1605 row_max = MIN(row_max, x->mv_row_max); | 1720 row_max = MIN(row_max, x->mv_row_max); |
| 1606 | 1721 |
| 1607 for (r = row_min; r < row_max; r++) { | 1722 for (r = row_min; r < row_max; r++) { |
| 1608 this_mv.as_mv.row = r; | 1723 this_mv.row = r; |
| 1609 check_here = r * mv_stride + in_what + col_min; | 1724 check_here = r * mv_stride + in_what + col_min; |
| 1610 c = col_min; | 1725 c = col_min; |
| 1611 | 1726 |
| 1612 while ((c + 2) < col_max) { | 1727 while ((c + 2) < col_max && fn_ptr->sdx3f != NULL) { |
| 1613 int i; | 1728 int i; |
| 1614 | 1729 |
| 1615 fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array); | 1730 fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array); |
| 1616 | 1731 |
| 1617 for (i = 0; i < 3; i++) { | 1732 for (i = 0; i < 3; i++) { |
| 1618 thissad = sad_array[i]; | 1733 thissad = sad_array[i]; |
| 1619 | 1734 |
| 1620 if (thissad < bestsad) { | 1735 if (thissad < bestsad) { |
| 1621 this_mv.as_mv.col = c; | 1736 this_mv.col = c; |
| 1622 thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 1737 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1623 mvjsadcost, mvsadcost, sad_per_bit); | 1738 mvjsadcost, mvsadcost, sad_per_bit); |
| 1624 | 1739 |
| 1625 if (thissad < bestsad) { | 1740 if (thissad < bestsad) { |
| 1626 bestsad = thissad; | 1741 bestsad = thissad; |
| 1627 best_mv->as_mv.row = r; | 1742 best_mv->as_mv.row = r; |
| 1628 best_mv->as_mv.col = c; | 1743 best_mv->as_mv.col = c; |
| 1629 bestaddress = check_here; | 1744 bestaddress = check_here; |
| 1630 } | 1745 } |
| 1631 } | 1746 } |
| 1632 | 1747 |
| 1633 check_here++; | 1748 check_here++; |
| 1634 c++; | 1749 c++; |
| 1635 } | 1750 } |
| 1636 } | 1751 } |
| 1637 | 1752 |
| 1638 while (c < col_max) { | 1753 while (c < col_max) { |
| 1639 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, | 1754 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, |
| 1640 bestsad); | 1755 bestsad); |
| 1641 | 1756 |
| 1642 if (thissad < bestsad) { | 1757 if (thissad < bestsad) { |
| 1643 this_mv.as_mv.col = c; | 1758 this_mv.col = c; |
| 1644 thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 1759 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1645 mvjsadcost, mvsadcost, sad_per_bit); | 1760 mvjsadcost, mvsadcost, sad_per_bit); |
| 1646 | 1761 |
| 1647 if (thissad < bestsad) { | 1762 if (thissad < bestsad) { |
| 1648 bestsad = thissad; | 1763 bestsad = thissad; |
| 1649 best_mv->as_mv.row = r; | 1764 best_mv->as_mv.row = r; |
| 1650 best_mv->as_mv.col = c; | 1765 best_mv->as_mv.col = c; |
| 1651 bestaddress = check_here; | 1766 bestaddress = check_here; |
| 1652 } | 1767 } |
| 1653 } | 1768 } |
| 1654 | 1769 |
| 1655 check_here++; | 1770 check_here++; |
| 1656 c++; | 1771 c++; |
| 1657 } | 1772 } |
| 1658 } | 1773 } |
| 1659 | 1774 |
| 1660 this_mv.as_mv.row = best_mv->as_mv.row * 8; | 1775 this_mv.row = best_mv->as_mv.row * 8; |
| 1661 this_mv.as_mv.col = best_mv->as_mv.col * 8; | 1776 this_mv.col = best_mv->as_mv.col * 8; |
| 1662 | 1777 |
| 1663 if (bestsad < INT_MAX) | 1778 if (bestsad < INT_MAX) |
| 1664 return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, | 1779 return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, |
| 1665 (unsigned int *)(&thissad)) + | 1780 (unsigned int *)(&thissad)) + |
| 1666 mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, | 1781 mv_err_cost(&this_mv, center_mv, |
| 1667 mvjcost, mvcost, x->errorperbit); | 1782 mvjcost, mvcost, x->errorperbit); |
| 1668 else | 1783 else |
| 1669 return INT_MAX; | 1784 return INT_MAX; |
| 1670 } | 1785 } |
| 1671 | 1786 |
| 1672 int vp9_full_search_sadx8(MACROBLOCK *x, int_mv *ref_mv, | 1787 int vp9_full_search_sadx8(MACROBLOCK *x, MV *ref_mv, |
| 1673 int sad_per_bit, int distance, | 1788 int sad_per_bit, int distance, |
| 1674 vp9_variance_fn_ptr_t *fn_ptr, | 1789 vp9_variance_fn_ptr_t *fn_ptr, |
| 1675 int *mvjcost, int *mvcost[2], | 1790 int *mvjcost, int *mvcost[2], |
| 1676 int_mv *center_mv, int n) { | 1791 const MV *center_mv, int n) { |
| 1677 const MACROBLOCKD* const xd = &x->e_mbd; | 1792 const MACROBLOCKD* const xd = &x->e_mbd; |
| 1678 uint8_t *what = x->plane[0].src.buf; | 1793 uint8_t *what = x->plane[0].src.buf; |
| 1679 int what_stride = x->plane[0].src.stride; | 1794 int what_stride = x->plane[0].src.stride; |
| 1680 uint8_t *in_what; | 1795 uint8_t *in_what; |
| 1681 int in_what_stride = xd->plane[0].pre[0].stride; | 1796 int in_what_stride = xd->plane[0].pre[0].stride; |
| 1682 int mv_stride = xd->plane[0].pre[0].stride; | 1797 int mv_stride = xd->plane[0].pre[0].stride; |
| 1683 uint8_t *bestaddress; | 1798 uint8_t *bestaddress; |
| 1684 int_mv *best_mv = &x->e_mbd.mi_8x8[0]->bmi[n].as_mv[0]; | 1799 int_mv *best_mv = &x->e_mbd.mi_8x8[0]->bmi[n].as_mv[0]; |
| 1685 int_mv this_mv; | 1800 MV this_mv; |
| 1686 unsigned int bestsad = INT_MAX; | 1801 unsigned int bestsad = INT_MAX; |
| 1687 int r, c; | 1802 int r, c; |
| 1688 | 1803 |
| 1689 uint8_t *check_here; | 1804 uint8_t *check_here; |
| 1690 unsigned int thissad; | 1805 unsigned int thissad; |
| 1691 | 1806 |
| 1692 int ref_row = ref_mv->as_mv.row; | 1807 int ref_row = ref_mv->row; |
| 1693 int ref_col = ref_mv->as_mv.col; | 1808 int ref_col = ref_mv->col; |
| 1694 | 1809 |
| 1695 int row_min = ref_row - distance; | 1810 int row_min = ref_row - distance; |
| 1696 int row_max = ref_row + distance; | 1811 int row_max = ref_row + distance; |
| 1697 int col_min = ref_col - distance; | 1812 int col_min = ref_col - distance; |
| 1698 int col_max = ref_col + distance; | 1813 int col_max = ref_col + distance; |
| 1699 | 1814 |
| 1700 DECLARE_ALIGNED_ARRAY(16, uint32_t, sad_array8, 8); | 1815 DECLARE_ALIGNED_ARRAY(16, uint32_t, sad_array8, 8); |
| 1701 unsigned int sad_array[3]; | 1816 unsigned int sad_array[3]; |
| 1702 int_mv fcenter_mv; | 1817 MV fcenter_mv; |
| 1703 | 1818 |
| 1704 int *mvjsadcost = x->nmvjointsadcost; | 1819 int *mvjsadcost = x->nmvjointsadcost; |
| 1705 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; | 1820 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; |
| 1706 | 1821 |
| 1707 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; | 1822 fcenter_mv.row = center_mv->row >> 3; |
| 1708 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; | 1823 fcenter_mv.col = center_mv->col >> 3; |
| 1709 | 1824 |
| 1710 // Work out the mid point for the search | 1825 // Work out the mid point for the search |
| 1711 in_what = xd->plane[0].pre[0].buf; | 1826 in_what = xd->plane[0].pre[0].buf; |
| 1712 bestaddress = in_what + (ref_row * xd->plane[0].pre[0].stride) + ref_col; | 1827 bestaddress = in_what + (ref_row * xd->plane[0].pre[0].stride) + ref_col; |
| 1713 | 1828 |
| 1714 best_mv->as_mv.row = ref_row; | 1829 best_mv->as_mv.row = ref_row; |
| 1715 best_mv->as_mv.col = ref_col; | 1830 best_mv->as_mv.col = ref_col; |
| 1716 | 1831 |
| 1717 // Baseline value at the centre | 1832 // Baseline value at the centre |
| 1718 bestsad = fn_ptr->sdf(what, what_stride, | 1833 bestsad = fn_ptr->sdf(what, what_stride, |
| 1719 bestaddress, in_what_stride, 0x7fffffff) | 1834 bestaddress, in_what_stride, 0x7fffffff) |
| 1720 + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv.as_mv, | 1835 + mvsad_err_cost(&best_mv->as_mv, &fcenter_mv, |
| 1721 mvjsadcost, mvsadcost, sad_per_bit); | 1836 mvjsadcost, mvsadcost, sad_per_bit); |
| 1722 | 1837 |
| 1723 // Apply further limits to prevent us looking using vectors that stretch | 1838 // Apply further limits to prevent us looking using vectors that stretch |
| 1724 // beyond the UMV border | 1839 // beyond the UMV border |
| 1725 col_min = MAX(col_min, x->mv_col_min); | 1840 col_min = MAX(col_min, x->mv_col_min); |
| 1726 col_max = MIN(col_max, x->mv_col_max); | 1841 col_max = MIN(col_max, x->mv_col_max); |
| 1727 row_min = MAX(row_min, x->mv_row_min); | 1842 row_min = MAX(row_min, x->mv_row_min); |
| 1728 row_max = MIN(row_max, x->mv_row_max); | 1843 row_max = MIN(row_max, x->mv_row_max); |
| 1729 | 1844 |
| 1730 for (r = row_min; r < row_max; r++) { | 1845 for (r = row_min; r < row_max; r++) { |
| 1731 this_mv.as_mv.row = r; | 1846 this_mv.row = r; |
| 1732 check_here = r * mv_stride + in_what + col_min; | 1847 check_here = r * mv_stride + in_what + col_min; |
| 1733 c = col_min; | 1848 c = col_min; |
| 1734 | 1849 |
| 1735 while ((c + 7) < col_max) { | 1850 while ((c + 7) < col_max) { |
| 1736 int i; | 1851 int i; |
| 1737 | 1852 |
| 1738 fn_ptr->sdx8f(what, what_stride, check_here, in_what_stride, sad_array8); | 1853 fn_ptr->sdx8f(what, what_stride, check_here, in_what_stride, sad_array8); |
| 1739 | 1854 |
| 1740 for (i = 0; i < 8; i++) { | 1855 for (i = 0; i < 8; i++) { |
| 1741 thissad = (unsigned int)sad_array8[i]; | 1856 thissad = (unsigned int)sad_array8[i]; |
| 1742 | 1857 |
| 1743 if (thissad < bestsad) { | 1858 if (thissad < bestsad) { |
| 1744 this_mv.as_mv.col = c; | 1859 this_mv.col = c; |
| 1745 thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 1860 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1746 mvjsadcost, mvsadcost, sad_per_bit); | 1861 mvjsadcost, mvsadcost, sad_per_bit); |
| 1747 | 1862 |
| 1748 if (thissad < bestsad) { | 1863 if (thissad < bestsad) { |
| 1749 bestsad = thissad; | 1864 bestsad = thissad; |
| 1750 best_mv->as_mv.row = r; | 1865 best_mv->as_mv.row = r; |
| 1751 best_mv->as_mv.col = c; | 1866 best_mv->as_mv.col = c; |
| 1752 bestaddress = check_here; | 1867 bestaddress = check_here; |
| 1753 } | 1868 } |
| 1754 } | 1869 } |
| 1755 | 1870 |
| 1756 check_here++; | 1871 check_here++; |
| 1757 c++; | 1872 c++; |
| 1758 } | 1873 } |
| 1759 } | 1874 } |
| 1760 | 1875 |
| 1761 while ((c + 2) < col_max && fn_ptr->sdx3f != NULL) { | 1876 while ((c + 2) < col_max && fn_ptr->sdx3f != NULL) { |
| 1762 int i; | 1877 int i; |
| 1763 | 1878 |
| 1764 fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array); | 1879 fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array); |
| 1765 | 1880 |
| 1766 for (i = 0; i < 3; i++) { | 1881 for (i = 0; i < 3; i++) { |
| 1767 thissad = sad_array[i]; | 1882 thissad = sad_array[i]; |
| 1768 | 1883 |
| 1769 if (thissad < bestsad) { | 1884 if (thissad < bestsad) { |
| 1770 this_mv.as_mv.col = c; | 1885 this_mv.col = c; |
| 1771 thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 1886 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1772 mvjsadcost, mvsadcost, sad_per_bit); | 1887 mvjsadcost, mvsadcost, sad_per_bit); |
| 1773 | 1888 |
| 1774 if (thissad < bestsad) { | 1889 if (thissad < bestsad) { |
| 1775 bestsad = thissad; | 1890 bestsad = thissad; |
| 1776 best_mv->as_mv.row = r; | 1891 best_mv->as_mv.row = r; |
| 1777 best_mv->as_mv.col = c; | 1892 best_mv->as_mv.col = c; |
| 1778 bestaddress = check_here; | 1893 bestaddress = check_here; |
| 1779 } | 1894 } |
| 1780 } | 1895 } |
| 1781 | 1896 |
| 1782 check_here++; | 1897 check_here++; |
| 1783 c++; | 1898 c++; |
| 1784 } | 1899 } |
| 1785 } | 1900 } |
| 1786 | 1901 |
| 1787 while (c < col_max) { | 1902 while (c < col_max) { |
| 1788 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, | 1903 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, |
| 1789 bestsad); | 1904 bestsad); |
| 1790 | 1905 |
| 1791 if (thissad < bestsad) { | 1906 if (thissad < bestsad) { |
| 1792 this_mv.as_mv.col = c; | 1907 this_mv.col = c; |
| 1793 thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 1908 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1794 mvjsadcost, mvsadcost, sad_per_bit); | 1909 mvjsadcost, mvsadcost, sad_per_bit); |
| 1795 | 1910 |
| 1796 if (thissad < bestsad) { | 1911 if (thissad < bestsad) { |
| 1797 bestsad = thissad; | 1912 bestsad = thissad; |
| 1798 best_mv->as_mv.row = r; | 1913 best_mv->as_mv.row = r; |
| 1799 best_mv->as_mv.col = c; | 1914 best_mv->as_mv.col = c; |
| 1800 bestaddress = check_here; | 1915 bestaddress = check_here; |
| 1801 } | 1916 } |
| 1802 } | 1917 } |
| 1803 | 1918 |
| 1804 check_here++; | 1919 check_here++; |
| 1805 c++; | 1920 c++; |
| 1806 } | 1921 } |
| 1807 } | 1922 } |
| 1808 | 1923 |
| 1809 this_mv.as_mv.row = best_mv->as_mv.row * 8; | 1924 this_mv.row = best_mv->as_mv.row * 8; |
| 1810 this_mv.as_mv.col = best_mv->as_mv.col * 8; | 1925 this_mv.col = best_mv->as_mv.col * 8; |
| 1811 | 1926 |
| 1812 if (bestsad < INT_MAX) | 1927 if (bestsad < INT_MAX) |
| 1813 return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, | 1928 return fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, |
| 1814 (unsigned int *)(&thissad)) + | 1929 (unsigned int *)(&thissad)) + |
| 1815 mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, | 1930 mv_err_cost(&this_mv, center_mv, |
| 1816 mvjcost, mvcost, x->errorperbit); | 1931 mvjcost, mvcost, x->errorperbit); |
| 1817 else | 1932 else |
| 1818 return INT_MAX; | 1933 return INT_MAX; |
| 1819 } | 1934 } |
| 1820 int vp9_refining_search_sad_c(MACROBLOCK *x, | 1935 int vp9_refining_search_sad_c(MACROBLOCK *x, |
| 1821 int_mv *ref_mv, int error_per_bit, | 1936 MV *ref_mv, int error_per_bit, |
| 1822 int search_range, vp9_variance_fn_ptr_t *fn_ptr, | 1937 int search_range, vp9_variance_fn_ptr_t *fn_ptr, |
| 1823 int *mvjcost, int *mvcost[2], int_mv *center_mv) { | 1938 int *mvjcost, int *mvcost[2], |
| 1939 const MV *center_mv) { |
| 1824 const MACROBLOCKD* const xd = &x->e_mbd; | 1940 const MACROBLOCKD* const xd = &x->e_mbd; |
| 1825 MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; | 1941 MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; |
| 1826 int i, j; | 1942 int i, j; |
| 1827 int this_row_offset, this_col_offset; | 1943 int this_row_offset, this_col_offset; |
| 1828 | 1944 |
| 1829 int what_stride = x->plane[0].src.stride; | 1945 int what_stride = x->plane[0].src.stride; |
| 1830 int in_what_stride = xd->plane[0].pre[0].stride; | 1946 int in_what_stride = xd->plane[0].pre[0].stride; |
| 1831 uint8_t *what = x->plane[0].src.buf; | 1947 uint8_t *what = x->plane[0].src.buf; |
| 1832 uint8_t *best_address = xd->plane[0].pre[0].buf + | 1948 uint8_t *best_address = xd->plane[0].pre[0].buf + |
| 1833 (ref_mv->as_mv.row * xd->plane[0].pre[0].stride) + | 1949 (ref_mv->row * xd->plane[0].pre[0].stride) + |
| 1834 ref_mv->as_mv.col; | 1950 ref_mv->col; |
| 1835 uint8_t *check_here; | 1951 uint8_t *check_here; |
| 1836 unsigned int thissad; | 1952 unsigned int thissad; |
| 1837 int_mv this_mv; | 1953 MV this_mv; |
| 1838 unsigned int bestsad = INT_MAX; | 1954 unsigned int bestsad = INT_MAX; |
| 1839 int_mv fcenter_mv; | 1955 MV fcenter_mv; |
| 1840 | 1956 |
| 1841 int *mvjsadcost = x->nmvjointsadcost; | 1957 int *mvjsadcost = x->nmvjointsadcost; |
| 1842 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; | 1958 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; |
| 1843 | 1959 |
| 1844 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; | 1960 fcenter_mv.row = center_mv->row >> 3; |
| 1845 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; | 1961 fcenter_mv.col = center_mv->col >> 3; |
| 1846 | 1962 |
| 1847 bestsad = fn_ptr->sdf(what, what_stride, best_address, | 1963 bestsad = fn_ptr->sdf(what, what_stride, best_address, |
| 1848 in_what_stride, 0x7fffffff) + | 1964 in_what_stride, 0x7fffffff) + |
| 1849 mvsad_err_cost(&ref_mv->as_mv, &fcenter_mv.as_mv, | 1965 mvsad_err_cost(ref_mv, &fcenter_mv, |
| 1850 mvjsadcost, mvsadcost, error_per_bit); | 1966 mvjsadcost, mvsadcost, error_per_bit); |
| 1851 | 1967 |
| 1852 for (i = 0; i < search_range; i++) { | 1968 for (i = 0; i < search_range; i++) { |
| 1853 int best_site = -1; | 1969 int best_site = -1; |
| 1854 | 1970 |
| 1855 for (j = 0; j < 4; j++) { | 1971 for (j = 0; j < 4; j++) { |
| 1856 this_row_offset = ref_mv->as_mv.row + neighbors[j].row; | 1972 this_row_offset = ref_mv->row + neighbors[j].row; |
| 1857 this_col_offset = ref_mv->as_mv.col + neighbors[j].col; | 1973 this_col_offset = ref_mv->col + neighbors[j].col; |
| 1858 | 1974 |
| 1859 if ((this_col_offset > x->mv_col_min) && | 1975 if ((this_col_offset > x->mv_col_min) && |
| 1860 (this_col_offset < x->mv_col_max) && | 1976 (this_col_offset < x->mv_col_max) && |
| 1861 (this_row_offset > x->mv_row_min) && | 1977 (this_row_offset > x->mv_row_min) && |
| 1862 (this_row_offset < x->mv_row_max)) { | 1978 (this_row_offset < x->mv_row_max)) { |
| 1863 check_here = (neighbors[j].row) * in_what_stride + neighbors[j].col + | 1979 check_here = (neighbors[j].row) * in_what_stride + neighbors[j].col + |
| 1864 best_address; | 1980 best_address; |
| 1865 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, | 1981 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, |
| 1866 bestsad); | 1982 bestsad); |
| 1867 | 1983 |
| 1868 if (thissad < bestsad) { | 1984 if (thissad < bestsad) { |
| 1869 this_mv.as_mv.row = this_row_offset; | 1985 this_mv.row = this_row_offset; |
| 1870 this_mv.as_mv.col = this_col_offset; | 1986 this_mv.col = this_col_offset; |
| 1871 thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 1987 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1872 mvjsadcost, mvsadcost, error_per_bit); | 1988 mvjsadcost, mvsadcost, error_per_bit); |
| 1873 | 1989 |
| 1874 if (thissad < bestsad) { | 1990 if (thissad < bestsad) { |
| 1875 bestsad = thissad; | 1991 bestsad = thissad; |
| 1876 best_site = j; | 1992 best_site = j; |
| 1877 } | 1993 } |
| 1878 } | 1994 } |
| 1879 } | 1995 } |
| 1880 } | 1996 } |
| 1881 | 1997 |
| 1882 if (best_site == -1) { | 1998 if (best_site == -1) { |
| 1883 break; | 1999 break; |
| 1884 } else { | 2000 } else { |
| 1885 ref_mv->as_mv.row += neighbors[best_site].row; | 2001 ref_mv->row += neighbors[best_site].row; |
| 1886 ref_mv->as_mv.col += neighbors[best_site].col; | 2002 ref_mv->col += neighbors[best_site].col; |
| 1887 best_address += (neighbors[best_site].row) * in_what_stride + | 2003 best_address += (neighbors[best_site].row) * in_what_stride + |
| 1888 neighbors[best_site].col; | 2004 neighbors[best_site].col; |
| 1889 } | 2005 } |
| 1890 } | 2006 } |
| 1891 | 2007 |
| 1892 this_mv.as_mv.row = ref_mv->as_mv.row * 8; | 2008 this_mv.row = ref_mv->row * 8; |
| 1893 this_mv.as_mv.col = ref_mv->as_mv.col * 8; | 2009 this_mv.col = ref_mv->col * 8; |
| 1894 | 2010 |
| 1895 if (bestsad < INT_MAX) | 2011 if (bestsad < INT_MAX) |
| 1896 return fn_ptr->vf(what, what_stride, best_address, in_what_stride, | 2012 return fn_ptr->vf(what, what_stride, best_address, in_what_stride, |
| 1897 (unsigned int *)(&thissad)) + | 2013 (unsigned int *)(&thissad)) + |
| 1898 mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, | 2014 mv_err_cost(&this_mv, center_mv, |
| 1899 mvjcost, mvcost, x->errorperbit); | 2015 mvjcost, mvcost, x->errorperbit); |
| 1900 else | 2016 else |
| 1901 return INT_MAX; | 2017 return INT_MAX; |
| 1902 } | 2018 } |
| 1903 | 2019 |
| 1904 int vp9_refining_search_sadx4(MACROBLOCK *x, | 2020 int vp9_refining_search_sadx4(MACROBLOCK *x, |
| 1905 int_mv *ref_mv, int error_per_bit, | 2021 MV *ref_mv, int error_per_bit, |
| 1906 int search_range, vp9_variance_fn_ptr_t *fn_ptr, | 2022 int search_range, vp9_variance_fn_ptr_t *fn_ptr, |
| 1907 int *mvjcost, int *mvcost[2], int_mv *center_mv) { | 2023 int *mvjcost, int *mvcost[2], |
| 2024 const MV *center_mv) { |
| 1908 const MACROBLOCKD* const xd = &x->e_mbd; | 2025 const MACROBLOCKD* const xd = &x->e_mbd; |
| 1909 MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; | 2026 MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; |
| 1910 int i, j; | 2027 int i, j; |
| 1911 int this_row_offset, this_col_offset; | 2028 int this_row_offset, this_col_offset; |
| 1912 | 2029 |
| 1913 int what_stride = x->plane[0].src.stride; | 2030 int what_stride = x->plane[0].src.stride; |
| 1914 int in_what_stride = xd->plane[0].pre[0].stride; | 2031 int in_what_stride = xd->plane[0].pre[0].stride; |
| 1915 uint8_t *what = x->plane[0].src.buf; | 2032 uint8_t *what = x->plane[0].src.buf; |
| 1916 uint8_t *best_address = xd->plane[0].pre[0].buf + | 2033 uint8_t *best_address = xd->plane[0].pre[0].buf + |
| 1917 (ref_mv->as_mv.row * xd->plane[0].pre[0].stride) + | 2034 (ref_mv->row * xd->plane[0].pre[0].stride) + |
| 1918 ref_mv->as_mv.col; | 2035 ref_mv->col; |
| 1919 uint8_t *check_here; | 2036 uint8_t *check_here; |
| 1920 unsigned int thissad; | 2037 unsigned int thissad; |
| 1921 int_mv this_mv; | 2038 MV this_mv; |
| 1922 unsigned int bestsad = INT_MAX; | 2039 unsigned int bestsad = INT_MAX; |
| 1923 int_mv fcenter_mv; | 2040 MV fcenter_mv; |
| 1924 | 2041 |
| 1925 int *mvjsadcost = x->nmvjointsadcost; | 2042 int *mvjsadcost = x->nmvjointsadcost; |
| 1926 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; | 2043 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; |
| 1927 | 2044 |
| 1928 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; | 2045 fcenter_mv.row = center_mv->row >> 3; |
| 1929 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; | 2046 fcenter_mv.col = center_mv->col >> 3; |
| 1930 | 2047 |
| 1931 bestsad = fn_ptr->sdf(what, what_stride, best_address, | 2048 bestsad = fn_ptr->sdf(what, what_stride, best_address, |
| 1932 in_what_stride, 0x7fffffff) + | 2049 in_what_stride, 0x7fffffff) + |
| 1933 mvsad_err_cost(&ref_mv->as_mv, &fcenter_mv.as_mv, | 2050 mvsad_err_cost(ref_mv, &fcenter_mv, |
| 1934 mvjsadcost, mvsadcost, error_per_bit); | 2051 mvjsadcost, mvsadcost, error_per_bit); |
| 1935 | 2052 |
| 1936 for (i = 0; i < search_range; i++) { | 2053 for (i = 0; i < search_range; i++) { |
| 1937 int best_site = -1; | 2054 int best_site = -1; |
| 1938 int all_in = ((ref_mv->as_mv.row - 1) > x->mv_row_min) & | 2055 int all_in = ((ref_mv->row - 1) > x->mv_row_min) & |
| 1939 ((ref_mv->as_mv.row + 1) < x->mv_row_max) & | 2056 ((ref_mv->row + 1) < x->mv_row_max) & |
| 1940 ((ref_mv->as_mv.col - 1) > x->mv_col_min) & | 2057 ((ref_mv->col - 1) > x->mv_col_min) & |
| 1941 ((ref_mv->as_mv.col + 1) < x->mv_col_max); | 2058 ((ref_mv->col + 1) < x->mv_col_max); |
| 1942 | 2059 |
| 1943 if (all_in) { | 2060 if (all_in) { |
| 1944 unsigned int sad_array[4]; | 2061 unsigned int sad_array[4]; |
| 1945 unsigned char const *block_offset[4]; | 2062 unsigned char const *block_offset[4]; |
| 1946 block_offset[0] = best_address - in_what_stride; | 2063 block_offset[0] = best_address - in_what_stride; |
| 1947 block_offset[1] = best_address - 1; | 2064 block_offset[1] = best_address - 1; |
| 1948 block_offset[2] = best_address + 1; | 2065 block_offset[2] = best_address + 1; |
| 1949 block_offset[3] = best_address + in_what_stride; | 2066 block_offset[3] = best_address + in_what_stride; |
| 1950 | 2067 |
| 1951 fn_ptr->sdx4df(what, what_stride, block_offset, in_what_stride, | 2068 fn_ptr->sdx4df(what, what_stride, block_offset, in_what_stride, |
| 1952 sad_array); | 2069 sad_array); |
| 1953 | 2070 |
| 1954 for (j = 0; j < 4; j++) { | 2071 for (j = 0; j < 4; j++) { |
| 1955 if (sad_array[j] < bestsad) { | 2072 if (sad_array[j] < bestsad) { |
| 1956 this_mv.as_mv.row = ref_mv->as_mv.row + neighbors[j].row; | 2073 this_mv.row = ref_mv->row + neighbors[j].row; |
| 1957 this_mv.as_mv.col = ref_mv->as_mv.col + neighbors[j].col; | 2074 this_mv.col = ref_mv->col + neighbors[j].col; |
| 1958 sad_array[j] += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 2075 sad_array[j] += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1959 mvjsadcost, mvsadcost, error_per_bit); | 2076 mvjsadcost, mvsadcost, error_per_bit); |
| 1960 | 2077 |
| 1961 if (sad_array[j] < bestsad) { | 2078 if (sad_array[j] < bestsad) { |
| 1962 bestsad = sad_array[j]; | 2079 bestsad = sad_array[j]; |
| 1963 best_site = j; | 2080 best_site = j; |
| 1964 } | 2081 } |
| 1965 } | 2082 } |
| 1966 } | 2083 } |
| 1967 } else { | 2084 } else { |
| 1968 for (j = 0; j < 4; j++) { | 2085 for (j = 0; j < 4; j++) { |
| 1969 this_row_offset = ref_mv->as_mv.row + neighbors[j].row; | 2086 this_row_offset = ref_mv->row + neighbors[j].row; |
| 1970 this_col_offset = ref_mv->as_mv.col + neighbors[j].col; | 2087 this_col_offset = ref_mv->col + neighbors[j].col; |
| 1971 | 2088 |
| 1972 if ((this_col_offset > x->mv_col_min) && | 2089 if ((this_col_offset > x->mv_col_min) && |
| 1973 (this_col_offset < x->mv_col_max) && | 2090 (this_col_offset < x->mv_col_max) && |
| 1974 (this_row_offset > x->mv_row_min) && | 2091 (this_row_offset > x->mv_row_min) && |
| 1975 (this_row_offset < x->mv_row_max)) { | 2092 (this_row_offset < x->mv_row_max)) { |
| 1976 check_here = (neighbors[j].row) * in_what_stride + neighbors[j].col + | 2093 check_here = (neighbors[j].row) * in_what_stride + neighbors[j].col + |
| 1977 best_address; | 2094 best_address; |
| 1978 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, | 2095 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, |
| 1979 bestsad); | 2096 bestsad); |
| 1980 | 2097 |
| 1981 if (thissad < bestsad) { | 2098 if (thissad < bestsad) { |
| 1982 this_mv.as_mv.row = this_row_offset; | 2099 this_mv.row = this_row_offset; |
| 1983 this_mv.as_mv.col = this_col_offset; | 2100 this_mv.col = this_col_offset; |
| 1984 thissad += mvsad_err_cost(&this_mv.as_mv, &fcenter_mv.as_mv, | 2101 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1985 mvjsadcost, mvsadcost, error_per_bit); | 2102 mvjsadcost, mvsadcost, error_per_bit); |
| 1986 | 2103 |
| 1987 if (thissad < bestsad) { | 2104 if (thissad < bestsad) { |
| 1988 bestsad = thissad; | 2105 bestsad = thissad; |
| 1989 best_site = j; | 2106 best_site = j; |
| 1990 } | 2107 } |
| 1991 } | 2108 } |
| 1992 } | 2109 } |
| 1993 } | 2110 } |
| 1994 } | 2111 } |
| 1995 | 2112 |
| 1996 if (best_site == -1) { | 2113 if (best_site == -1) { |
| 1997 break; | 2114 break; |
| 1998 } else { | 2115 } else { |
| 1999 ref_mv->as_mv.row += neighbors[best_site].row; | 2116 ref_mv->row += neighbors[best_site].row; |
| 2000 ref_mv->as_mv.col += neighbors[best_site].col; | 2117 ref_mv->col += neighbors[best_site].col; |
| 2001 best_address += (neighbors[best_site].row) * in_what_stride + | 2118 best_address += (neighbors[best_site].row) * in_what_stride + |
| 2002 neighbors[best_site].col; | 2119 neighbors[best_site].col; |
| 2003 } | 2120 } |
| 2004 } | 2121 } |
| 2005 | 2122 |
| 2006 this_mv.as_mv.row = ref_mv->as_mv.row * 8; | 2123 this_mv.row = ref_mv->row * 8; |
| 2007 this_mv.as_mv.col = ref_mv->as_mv.col * 8; | 2124 this_mv.col = ref_mv->col * 8; |
| 2008 | 2125 |
| 2009 if (bestsad < INT_MAX) | 2126 if (bestsad < INT_MAX) |
| 2010 return fn_ptr->vf(what, what_stride, best_address, in_what_stride, | 2127 return fn_ptr->vf(what, what_stride, best_address, in_what_stride, |
| 2011 (unsigned int *)(&thissad)) + | 2128 (unsigned int *)(&thissad)) + |
| 2012 mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, | 2129 mv_err_cost(&this_mv, center_mv, |
| 2013 mvjcost, mvcost, x->errorperbit); | 2130 mvjcost, mvcost, x->errorperbit); |
| 2014 else | 2131 else |
| 2015 return INT_MAX; | 2132 return INT_MAX; |
| 2016 } | 2133 } |
| 2017 | 2134 |
| 2018 /* This function is called when we do joint motion search in comp_inter_inter | 2135 /* This function is called when we do joint motion search in comp_inter_inter |
| 2019 * mode. | 2136 * mode. |
| 2020 */ | 2137 */ |
| 2021 int vp9_refining_search_8p_c(MACROBLOCK *x, | 2138 int vp9_refining_search_8p_c(MACROBLOCK *x, |
| 2022 int_mv *ref_mv, int error_per_bit, | 2139 int_mv *ref_mv, int error_per_bit, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2101 // FIXME(rbultje, yunqing): add full-pixel averaging variance functions | 2218 // FIXME(rbultje, yunqing): add full-pixel averaging variance functions |
| 2102 // so we don't have to use the subpixel with xoff=0,yoff=0 here. | 2219 // so we don't have to use the subpixel with xoff=0,yoff=0 here. |
| 2103 return fn_ptr->svaf(best_address, in_what_stride, 0, 0, what, what_stride, | 2220 return fn_ptr->svaf(best_address, in_what_stride, 0, 0, what, what_stride, |
| 2104 (unsigned int *)(&thissad), second_pred) + | 2221 (unsigned int *)(&thissad), second_pred) + |
| 2105 mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, | 2222 mv_err_cost(&this_mv.as_mv, ¢er_mv->as_mv, |
| 2106 mvjcost, mvcost, x->errorperbit); | 2223 mvjcost, mvcost, x->errorperbit); |
| 2107 } else { | 2224 } else { |
| 2108 return INT_MAX; | 2225 return INT_MAX; |
| 2109 } | 2226 } |
| 2110 } | 2227 } |
| OLD | NEW |