diff options
author | Oleg Oshmyan <chortos@inbox.lv> | 2014-01-15 02:38:54 +0000 |
---|---|---|
committer | Oleg Oshmyan <chortos@inbox.lv> | 2014-01-15 03:43:08 +0000 |
commit | d87fd620350b891d9387e0708453610ee2b8bb49 (patch) | |
tree | 6baf3fd343b014cbe2f68512bd99d02058d23caa | |
parent | 088c617c3ee6ef0a21a71a1310972e60134fda94 (diff) | |
download | libass-d87fd620350b891d9387e0708453610ee2b8bb49.tar.bz2 libass-d87fd620350b891d9387e0708453610ee2b8bb49.tar.xz |
Fix \fade corner cases
Times in \fade(,,,-1,fadein,fadeout,-1)
are interpreted as in \fad(fadein,fadeout).
Make sure we check the times in the same
order as VSFilter in case they are not sorted.
-rw-r--r-- | libass/ass_parse.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/libass/ass_parse.c b/libass/ass_parse.c index 2b49cbb..159be3b 100644 --- a/libass/ass_parse.c +++ b/libass/ass_parse.c @@ -183,16 +183,16 @@ interpolate_alpha(long long now, long long t1, long long t2, long long t3, if (now < t1) { a = a1; - } else if (now >= t4) { - a = a3; - } else if (now < t2 && t2 > t1) { + } else if (now < t2) { cf = ((double) (now - t1)) / (t2 - t1); a = a1 * (1 - cf) + a2 * cf; - } else if (now >= t3 && t4 > t3) { + } else if (now < t3) { + a = a2; + } else if (now < t4) { cf = ((double) (now - t3)) / (t4 - t3); a = a2 * (1 - cf) + a3 * cf; - } else { // t2 <= now < t3 - a = a2; + } else { // now >= t4 + a = a3; } return a; @@ -564,10 +564,10 @@ char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr) if (*p == ')') { // 2-argument version (\fad, according to specs) // a1 and a2 are fade-in and fade-out durations - t1 = 0; - t4 = render_priv->state.event->Duration; + t1 = -1; t2 = a1; - t3 = t4 - a2; + t3 = a2; + t4 = -1; a1 = 0xFF; a2 = 0; a3 = 0xFF; @@ -586,6 +586,11 @@ char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr) mystrtoll(&p, &t4); } skipopt(')'); + if (t1 == -1 && t4 == -1) { + t1 = 0; + t4 = render_priv->state.event->Duration; + t3 = t4 - t3; + } if ((render_priv->state.parsed_tags & PARSED_FADE) == 0) { render_priv->state.fade = interpolate_alpha(render_priv->time - |