Update check in opj_tcd_makelayer to be robust to different float precisions

This commit is contained in:
Matthieu Darbois 2015-09-10 15:46:51 +02:00
parent ccdce606f1
commit ee0f313848
1 changed files with 2 additions and 2 deletions

View File

@ -268,7 +268,7 @@ void opj_tcd_makelayer( opj_tcd_t *tcd,
n = passno + 1; n = passno + 1;
continue; 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; n = passno + 1;
} }
@ -565,7 +565,7 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd,
opj_t2_destroy(t2); opj_t2_destroy(t2);
} else { } else {
success = OPJ_TRUE; success = OPJ_TRUE;
goodthresh = min - DBL_EPSILON; /* do not rely on float equality for lossless transform */ goodthresh = min;
} }
if (!success) { if (!success) {