summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2014-01-15 02:16:58 +0000
committerOleg Oshmyan <chortos@inbox.lv>2014-01-15 03:43:08 +0000
commit088c617c3ee6ef0a21a71a1310972e60134fda94 (patch)
tree85fecf50281350b3215fbd10a1594ee694db46f9
parentf6211a334e238483ba1da05e5879e3c54e93f401 (diff)
downloadlibass-088c617c3ee6ef0a21a71a1310972e60134fda94.tar.bz2
libass-088c617c3ee6ef0a21a71a1310972e60134fda94.tar.xz
Fix \t corner cases
The end time is reset to line duration if and only if it is zero. Negative accelerations are allowed (and can cause overflow later).
-rw-r--r--libass/ass_parse.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/libass/ass_parse.c b/libass/ass_parse.c
index c426d13..2b49cbb 100644
--- a/libass/ass_parse.c
+++ b/libass/ass_parse.c
@@ -609,8 +609,7 @@ char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr)
}
} else if (mystrcmp(&p, "t")) {
double v[3];
- int v1, v2;
- double v3;
+ double accel;
int cnt;
long long t1, t2, t, delta_t;
double k;
@@ -621,28 +620,26 @@ char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr)
skip(',');
}
if (cnt == 3) {
- v1 = v[0];
- v2 = (v[1] < v1) ? render_priv->state.event->Duration : v[1];
- v3 = v[2];
+ t1 = v[0];
+ t2 = v[1];
+ accel = v[2];
} else if (cnt == 2) {
- v1 = v[0];
- v2 = (v[1] < v1) ? render_priv->state.event->Duration : v[1];
- v3 = 1.;
+ t1 = v[0];
+ t2 = v[1];
+ accel = 1.;
} else if (cnt == 1) {
- v1 = 0;
- v2 = render_priv->state.event->Duration;
- v3 = v[0];
+ t1 = 0;
+ t2 = 0;
+ accel = v[0];
} else { // cnt == 0
- v1 = 0;
- v2 = render_priv->state.event->Duration;
- v3 = 1.;
+ t1 = 0;
+ t2 = 0;
+ accel = 1.;
}
render_priv->state.detect_collisions = 0;
- t1 = v1;
- t2 = v2;
- delta_t = v2 - v1;
- if (v3 < 0.)
- v3 = 0.;
+ if (t2 == 0)
+ t2 = render_priv->state.event->Duration;
+ delta_t = t2 - t1;
t = render_priv->time - render_priv->state.event->Start; // FIXME: move to render_context
if (t <= t1)
k = 0.;
@@ -650,7 +647,7 @@ char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr)
k = 1.;
else {
assert(delta_t != 0.);
- k = pow(((double) (t - t1)) / delta_t, v3);
+ k = pow(((double) (t - t1)) / delta_t, accel);
}
while (*p != ')' && *p != '}' && *p != '\0')
p = parse_tag(render_priv, p, k); // maybe k*pwr ? no, specs forbid nested \t's