diff options
author | Oleg Oshmyan <chortos@inbox.lv> | 2014-08-27 22:24:05 +0200 |
---|---|---|
committer | Oleg Oshmyan <chortos@inbox.lv> | 2020-10-27 01:24:12 +0200 |
commit | 42aedd59dd650d4f8567c48ecd03eb78178a29da (patch) | |
tree | b36944e0d5352116a34271c73fb9a65540e993eb | |
parent | ef20577a502731f28de0a4ffc2c737389b1dd4a0 (diff) | |
download | libass-42aedd59dd650d4f8567c48ecd03eb78178a29da.tar.bz2 libass-42aedd59dd650d4f8567c48ecd03eb78178a29da.tar.xz |
process_karaoke_effects: explicitly handle edge cases for \kf
In particular, don't divide by zero given \kf0.
This fixes https://github.com/libass/libass/issues/124.
The order is important: \kf accepts negative values.
-rw-r--r-- | libass/ass_parse.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libass/ass_parse.c b/libass/ass_parse.c index 20cbff6..9ab4ab8 100644 --- a/libass/ass_parse.c +++ b/libass/ass_parse.c @@ -1008,8 +1008,14 @@ void process_karaoke_effects(ASS_Renderer *render_priv) if (effect_type == EF_KARAOKE || effect_type == EF_KARAOKE_KO) { x = tm_current < tm_start ? x_start : x_end + 1; } else if (effect_type == EF_KARAOKE_KF) { - double dt = (double) (tm_current - tm_start) / (tm_end - tm_start); - x = x_start + (x_end - x_start) * dt; + if (tm_current < tm_start) + x = x_start; + else if (tm_current >= tm_end) + x = x_end + 1; + else { + double dt = (double) (tm_current - tm_start) / (tm_end - tm_start); + x = x_start + (x_end - x_start) * dt; + } } else { ass_msg(render_priv->library, MSGL_ERR, "Unknown effect type"); |