summaryrefslogtreecommitdiffstats
path: root/libass/ass_parse.c
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2009-09-11 04:02:00 +0200
committerGrigori Goronzy <greg@blackbox>2009-09-16 02:36:56 +0200
commit45ca8450a9cfb5f6bae1defd51af465e9526633a (patch)
tree07468bb3f089ee21184e3e5f857ebcd8a31c9f0f /libass/ass_parse.c
parent69b167d70bc918d2e8749c8119efe4753214f668 (diff)
downloadlibass-45ca8450a9cfb5f6bae1defd51af465e9526633a.tar.bz2
libass-45ca8450a9cfb5f6bae1defd51af465e9526633a.tar.xz
Refactor: effect parsing should be in ass_parse.c
Move the function apply_transition_effects, which parses event-global effects and adjusts a few state variables, into ass_parse.c.
Diffstat (limited to 'libass/ass_parse.c')
-rw-r--r--libass/ass_parse.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/libass/ass_parse.c b/libass/ass_parse.c
index 0f3b441..535e16f 100644
--- a/libass/ass_parse.c
+++ b/libass/ass_parse.c
@@ -802,6 +802,81 @@ static char *parse_tag(ASS_Renderer *render_priv, char *p, double pwr)
return p;
}
+void apply_transition_effects(ASS_Renderer *render_priv, ASS_Event *event)
+{
+ int v[4];
+ int cnt;
+ char *p = event->Effect;
+
+ if (!p || !*p)
+ return;
+
+ cnt = 0;
+ while (cnt < 4 && (p = strchr(p, ';'))) {
+ v[cnt++] = atoi(++p);
+ }
+
+ if (strncmp(event->Effect, "Banner;", 7) == 0) {
+ int delay;
+ if (cnt < 1) {
+ ass_msg(render_priv->library, MSGL_V,
+ "Error parsing effect: '%s'", event->Effect);
+ return;
+ }
+ if (cnt >= 2 && v[1] == 0) // right-to-left
+ render_priv->state.scroll_direction = SCROLL_RL;
+ else // left-to-right
+ render_priv->state.scroll_direction = SCROLL_LR;
+
+ delay = v[0];
+ if (delay == 0)
+ delay = 1; // ?
+ render_priv->state.scroll_shift =
+ (render_priv->time - render_priv->state.event->Start) / delay;
+ render_priv->state.evt_type = EVENT_HSCROLL;
+ return;
+ }
+
+ if (strncmp(event->Effect, "Scroll up;", 10) == 0) {
+ render_priv->state.scroll_direction = SCROLL_BT;
+ } else if (strncmp(event->Effect, "Scroll down;", 12) == 0) {
+ render_priv->state.scroll_direction = SCROLL_TB;
+ } else {
+ ass_msg(render_priv->library, MSGL_V,
+ "Unknown transition effect: '%s'", event->Effect);
+ return;
+ }
+ // parse scroll up/down parameters
+ {
+ int delay;
+ int y0, y1;
+ if (cnt < 3) {
+ ass_msg(render_priv->library, MSGL_V,
+ "Error parsing effect: '%s'", event->Effect);
+ return;
+ }
+ delay = v[2];
+ if (delay == 0)
+ delay = 1; // ?
+ render_priv->state.scroll_shift =
+ (render_priv->time - render_priv->state.event->Start) / delay;
+ if (v[0] < v[1]) {
+ y0 = v[0];
+ y1 = v[1];
+ } else {
+ y0 = v[1];
+ y1 = v[0];
+ }
+ if (y1 == 0)
+ y1 = render_priv->track->PlayResY; // y0=y1=0 means fullscreen scrolling
+ render_priv->state.clip_y0 = y0;
+ render_priv->state.clip_y1 = y1;
+ render_priv->state.evt_type = EVENT_VSCROLL;
+ render_priv->state.detect_collisions = 0;
+ }
+
+}
+
/**
* \brief Get next ucs4 char from string, parsing and executing style overrides
* \param str string pointer