From 807a767908b1bcd6cfd414f3f232306b285223db Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Mon, 29 Aug 2011 19:15:31 +0200 Subject: Fix off-by-one error in \fad, \fade Typical greater vs. greater-or-equal case. This especially fixes fades with zero delays. A zero delay in the two-argument form means no fade at all, but previously this faded over a single frame, since the code used "greater" semantics, while "greater or equal" is required here. Notably, this avoids blinking/flickering in some tightly timed karaoke scripts. --- libass/ass_parse.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libass/ass_parse.c b/libass/ass_parse.c index 274d84d..92a47b3 100644 --- a/libass/ass_parse.c +++ b/libass/ass_parse.c @@ -190,17 +190,18 @@ interpolate_alpha(long long now, long long t1, long long t2, long long t3, { unsigned a; double cf; - if (now <= t1) { + + if (now < t1) { a = a1; } else if (now >= t4) { a = a3; - } else if (now < t2) { // and > t1 + } else if (now < t2 && t2 > t1) { cf = ((double) (now - t1)) / (t2 - t1); a = a1 * (1 - cf) + a2 * cf; - } else if (now > t3) { + } else if (now >= t3 && t4 > t3) { cf = ((double) (now - t3)) / (t4 - t3); a = a2 * (1 - cf) + a3 * cf; - } else { // t2 <= now <= t3 + } else { // t2 <= now < t3 a = a2; } -- cgit v1.2.3