diff options
author | Grigori Goronzy <greg@blackbox> | 2011-08-29 19:15:31 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2011-08-29 19:15:31 +0200 |
commit | 807a767908b1bcd6cfd414f3f232306b285223db (patch) | |
tree | fffd002f648165828696f5feaa676a174e0d96d8 | |
parent | a0b118ea048a5c1898657f76fae9776227f49891 (diff) | |
download | libass-807a767908b1bcd6cfd414f3f232306b285223db.tar.bz2 libass-807a767908b1bcd6cfd414f3f232306b285223db.tar.xz |
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.
-rw-r--r-- | libass/ass_parse.c | 9 |
1 files 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; } |