summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorAaron Boxer <boxerab@gmail.com>2017-09-01 19:33:40 -0400
committercah <cah@ableton.com>2019-12-03 11:36:51 +0100
commit531f1a7146baa2f711e76927bc92bc33b053055d (patch)
tree8317880942e99cb3682af682f3feaa28609cde55 /src/lib
parente9335061e8186786eefe065720ecbd4ce7cafdd4 (diff)
use tolerance to bail out early from rate control : much faster
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/openjp2/tcd.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c
index 13d6692b..b3e789e3 100644
--- a/src/lib/openjp2/tcd.c
+++ b/src/lib/openjp2/tcd.c
@@ -539,6 +539,8 @@ OPJ_BOOL opj_tcd_rateallocate(opj_tcd_t *tcd,
OPJ_UINT32) ceil(tcd_tcp->rates[layno])), len) : len;
OPJ_FLOAT64 goodthresh = 0;
OPJ_FLOAT64 stable_thresh = 0;
+ OPJ_FLOAT64 old_thresh = -1;
+ const OPJ_FLOAT64 tolerance = 0.01;
OPJ_UINT32 i;
OPJ_FLOAT64 distotarget; /* fixed_quality */
@@ -567,6 +569,9 @@ OPJ_BOOL opj_tcd_rateallocate(opj_tcd_t *tcd,
thresh = (lo + hi) / 2;
opj_tcd_makelayer(tcd, layno, thresh, 0);
+ if ((fabs(old_thresh - thresh)) < tolerance)
+ break;
+ old_thresh = thresh;
if (cp->m_specific_param.m_enc.m_fixed_quality) { /* fixed_quality */
if (OPJ_IS_CINEMA(cp->rsiz)) {