From: Matthieu Darbois Date: Thu, 10 Sep 2015 13:46:51 +0000 (+0200) Subject: Update check in opj_tcd_makelayer to be robust to different float precisions X-Git-Tag: v2.1.1~22^2~62^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee0f3138482fc5ef44f92e6164206bc8df34efe4;p=openjpeg Update check in opj_tcd_makelayer to be robust to different float precisions --- 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) {