Skip to content

Commit 2f9a214

Browse files
committed
Add an offset to double comparison in mv_cost to fix problems on some platforms
1 parent 6bd2373 commit 2f9a214

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/search_inter.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ static bool check_mv_cost(inter_search_info_t *info,
220220
info->height,
221221
info->optimized_sad
222222
);
223-
224-
if (cost >= *best_cost) return false;
223+
// On some platforms comparing two doubles give weird results, so add an offset
224+
#define KVZ_TEMP_DOUBLE_PRECISION 0.001
225+
if (cost + KVZ_TEMP_DOUBLE_PRECISION >= *best_cost) return false;
225226

226227
cost += info->mvd_cost_func(
227228
info->state,
@@ -233,7 +234,8 @@ static bool check_mv_cost(inter_search_info_t *info,
233234
&bitcost
234235
);
235236

236-
if (cost >= *best_cost) return false;
237+
if (cost + KVZ_TEMP_DOUBLE_PRECISION >= *best_cost) return false;
238+
#undef KVZ_TEMP_DOUBLE_PRECISION
237239

238240
// Set to motion vector in quarter pixel precision.
239241
best_mv->x = x * 4;

0 commit comments

Comments
 (0)