changeset 19398:bb5164e0f70f

Allow \fade to be used in place of \fad and vice versa. Now they are distinguished by the number of arguments.
author eugeni
date Tue, 15 Aug 2006 14:40:57 +0000
parents 0074c9c77a0e
children 68fd9f8a7618
files libass/ass_render.c
diffstat 1 files changed, 23 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass_render.c	Tue Aug 15 14:32:50 2006 +0000
+++ b/libass/ass_render.c	Tue Aug 15 14:40:57 2006 +0000
@@ -752,38 +752,40 @@
 		render_context.detect_collisions = 0;
 		render_context.pos_x = v1;
 		render_context.pos_y = v2;
-	} else if (mystrcmp(&p, "fade")) {
-		int a1, a2, a3, v1, v2, v3, v4;
+	} else if (mystrcmp(&p, "fad")) {
+		int a1, a2, a3;
+		long long t1, t2, t3, t4;
+		if (*p == 'e') ++p; // either \fad or \fade
 		skip('(');
 		a1 = strtol(p, &p, 10);
 		skip(',');
 		a2 = strtol(p, &p, 10);
+		if (*p == ')') {
+			// 2-argument version (\fad, according to specs)
+			// a1 and a2 are fade-in and fade-out durations
+			t1 = 0;
+			t4 = render_context.event->Duration;
+			t2 = a1;
+			t3 = t4 - a2;
+			a1 = 0xFF;
+			a2 = 0;
+			a3 = 0xFF;
+		} else {
+		// 6-argument version (\fade)
+		// a1 and a2 (and a3) are opacity values
 		skip(',');
 		a3 = strtol(p, &p, 10);
 		skip(',');
-		v1 = strtol(p, &p, 10);
+		t1 = strtoll(p, &p, 10);
 		skip(',');
-		v2 = strtol(p, &p, 10);
+		t2 = strtoll(p, &p, 10);
 		skip(',');
-		v3 = strtol(p, &p, 10);
+		t3 = strtoll(p, &p, 10);
 		skip(',');
-		v4 = strtol(p, &p, 10);
+		t4 = strtoll(p, &p, 10);
+		}
 		skip(')');
-		interpolate_alpha(frame_context.time - render_context.event->Start, v1, v2, v3, v4, a1, a2, a3);
-	} else if (mystrcmp(&p, "fad")) {
-		int v1, v2;
-		long long now, t1, t2, t3, t4;
-		skip('(');
-		v1 = strtol(p, &p, 10);
-		skip(',');
-		v2 = strtol(p, &p, 10);
-		skip(')');
-		now = frame_context.time;
-		t1 = render_context.event->Start;
-		t2 = t1 + v1;
-		t4 = render_context.event->Start + render_context.event->Duration;
-		t3 = t4 - v2;
-		interpolate_alpha(now, t1, t2, t3, t4, 0xFF, 0, 0xFF);
+		interpolate_alpha(frame_context.time - render_context.event->Start, t1, t2, t3, t4, a1, a2, a3);
 	} else if (mystrcmp(&p, "org")) {
 		int v1, v2;
 		skip('(');