]> granicus.if.org Git - libass/commitdiff
Refactor: effect parsing should be in ass_parse.c
authorGrigori Goronzy <greg@blackbox>
Fri, 11 Sep 2009 02:02:00 +0000 (04:02 +0200)
committerGrigori Goronzy <greg@blackbox>
Wed, 16 Sep 2009 00:36:56 +0000 (02:36 +0200)
Move the function apply_transition_effects, which parses event-global
effects and adjusts a few state variables, into ass_parse.c.

libass/ass_parse.c
libass/ass_parse.h
libass/ass_render.c

index 0f3b4414acc4c436669edce8e84f3235a38953f6..535e16f4b47b438cdff3ac2c82e7a94029d8a2fa 100644 (file)
@@ -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
index e4b37487fd137ca6e9f2eba6e2f80a0bb68384e6..c65b56515816cc04da4f0bbcf400dfb40615c0ed 100644 (file)
@@ -29,6 +29,7 @@
 void update_font(ASS_Renderer *render_priv);
 void change_border(ASS_Renderer *render_priv, double border_x,
                    double border_y);
+void apply_transition_effects(ASS_Renderer *render_priv, ASS_Event *event);
 unsigned get_next_char(ASS_Renderer *render_priv, char **str);
 extern void change_alpha(uint32_t *var, uint32_t new, double pwr);
 extern uint32_t mult_alpha(uint32_t a, uint32_t b);
index e713ab004460666ed6f311528947864851571e35..c2756fde44b47f3e43a42d9baf97b82cd2c8d8bf 100644 (file)
@@ -809,82 +809,6 @@ static void compute_string_bbox(TextInfo *info, DBBox *bbox)
         bbox->xMin = bbox->xMax = bbox->yMin = bbox->yMax = 0.;
 }
 
-static 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 partially reset render_context to style values
  * Works like {\r}: resets some style overrides