Skip to content

Commit

Permalink
Add an offset to double comparison in mv_cost to fix problems on some…
Browse files Browse the repository at this point in the history
… platforms
  • Loading branch information
fador committed Aug 14, 2024
1 parent 6bd2373 commit 2f9a214
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/search_inter.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ static bool check_mv_cost(inter_search_info_t *info,
info->height,
info->optimized_sad
);

if (cost >= *best_cost) return false;
// On some platforms comparing two doubles give weird results, so add an offset
#define KVZ_TEMP_DOUBLE_PRECISION 0.001
if (cost + KVZ_TEMP_DOUBLE_PRECISION >= *best_cost) return false;

cost += info->mvd_cost_func(
info->state,
Expand All @@ -233,7 +234,8 @@ static bool check_mv_cost(inter_search_info_t *info,
&bitcost
);

if (cost >= *best_cost) return false;
if (cost + KVZ_TEMP_DOUBLE_PRECISION >= *best_cost) return false;
#undef KVZ_TEMP_DOUBLE_PRECISION

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

0 comments on commit 2f9a214

Please sign in to comment.