Add loop termination to TZ grid search
Terminates the grid search if no better motion vector was found in the
last three iterations.
@@ -634,8 +634,13 @@ static void tz_search(inter_search_info_t *info, vector2d_t extra_mv)
vector2d_t start = { info->best_mv.x >> 2, info->best_mv.y >> 2 };
//step 2, grid search
+ int rounds_without_improvement = 0;
for (int iDist = 1; iDist <= iSearchRange; iDist *= 2) {
kvz_tz_pattern_search(info, step2_type, iDist, start, &best_dist);
+
+ // Break the loop if the last three rounds didn't produce a better MV.
+ if (best_dist != iDist) rounds_without_improvement++;
+ if (rounds_without_improvement >= 3) break;
}
//step 3, raster scan
