From b7f042f4313e53e5c2b7a13f6857519cdc0ec716 Mon Sep 17 00:00:00 2001 From: fechen123 <19713402+fechen123@users.noreply.github.com> Date: Tue, 17 Oct 2017 18:16:09 -0400 Subject: [PATCH 1/2] Updating tcd.c to fix issue #1033 --- src/lib/openjp2/tcd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index 1dd15405..ede3107b 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -586,7 +586,8 @@ OPJ_BOOL opj_tcd_rateallocate(opj_tcd_t *tcd, if (distoachieved < distotarget) { hi = thresh; - stable_thresh = thresh; + if (distoachieved > DBL_EPSILON) + stable_thresh = thresh; continue; } else { lo = thresh; @@ -598,7 +599,8 @@ OPJ_BOOL opj_tcd_rateallocate(opj_tcd_t *tcd, if (distoachieved < distotarget) { hi = thresh; - stable_thresh = thresh; + if (distoachieved > DBL_EPSILON) + stable_thresh = thresh; continue; } lo = thresh; @@ -618,7 +620,7 @@ OPJ_BOOL opj_tcd_rateallocate(opj_tcd_t *tcd, } } - goodthresh = stable_thresh == 0 ? thresh : stable_thresh; + goodthresh = stable_thresh == 0 ? lo : stable_thresh; opj_t2_destroy(t2); } else { From 9bbbdccc89258bc95207ae1307b7b250a0b94d76 Mon Sep 17 00:00:00 2001 From: fechen123 <19713402+fechen123@users.noreply.github.com> Date: Wed, 18 Oct 2017 19:46:29 -0400 Subject: [PATCH 2/2] update tcd.c to fix issue #1033 --- src/lib/openjp2/tcd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index ede3107b..7380c4bd 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -586,8 +586,9 @@ OPJ_BOOL opj_tcd_rateallocate(opj_tcd_t *tcd, if (distoachieved < distotarget) { hi = thresh; - if (distoachieved > DBL_EPSILON) - stable_thresh = thresh; + if (distoachieved > DBL_EPSILON) { + stable_thresh = thresh; + } continue; } else { lo = thresh; @@ -599,8 +600,9 @@ OPJ_BOOL opj_tcd_rateallocate(opj_tcd_t *tcd, if (distoachieved < distotarget) { hi = thresh; - if (distoachieved > DBL_EPSILON) - stable_thresh = thresh; + if (distoachieved > DBL_EPSILON) { + stable_thresh = thresh; + } continue; } lo = thresh;