From ee0f3138482fc5ef44f92e6164206bc8df34efe4 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 10 Sep 2015 15:46:51 +0200 Subject: [PATCH] Update check in opj_tcd_makelayer to be robust to different float precisions --- src/lib/openjp2/tcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index d227e388..32db260b 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -268,7 +268,7 @@ void opj_tcd_makelayer( opj_tcd_t *tcd, n = passno + 1; continue; } - if (dd / dr > thresh) + if (thresh - (dd / dr) <= DBL_EPSILON) /* do not rely on float equality, check with DBL_EPSILON margin */ n = passno + 1; } @@ -565,7 +565,7 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd, opj_t2_destroy(t2); } else { success = OPJ_TRUE; - goodthresh = min - DBL_EPSILON; /* do not rely on float equality for lossless transform */ + goodthresh = min; } if (!success) {