Added support to get a constant number of frames between faces
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 16 Aug 2008 16:01:16 +0000 (13:01 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 16 Aug 2008 16:01:16 +0000 (13:01 -0300)
gdk.c
movie.c
point.h

diff --git a/gdk.c b/gdk.c
index a6b6113..4c68e64 100644 (file)
--- a/gdk.c
+++ b/gdk.c
@@ -98,6 +98,7 @@ main (int argc, char **argv)
   else
     filename = argv[1];
   ctx.points = ReadPoints ("pro-gnu");
+  ctx.points = drop_dup_frames (ctx.points, 20);
   rescale_points (ctx.points);
   ctx.picture = gdk_pixbuf_new_from_file (filename, NULL);
   ctx.i = ctx.points->len;
diff --git a/movie.c b/movie.c
index 4ff67db..d348869 100644 (file)
--- a/movie.c
+++ b/movie.c
@@ -103,6 +103,44 @@ ReadPoints (char *filename)
   return points;
 }
 
+GArray *
+drop_dup_frames (GArray *points, int n)
+{
+  GArray *frames;
+  Point *point;
+  Point *next;
+  int i;
+  int j;
+  int inc;
+  int thre;
+  int err;
+  inc = n;
+  frames = g_array_new (FALSE, TRUE, sizeof (Point));
+  for (i = 0; i < points->len;)
+    {
+      j = i + 1;
+      point = next = &(g_array_index (points, Point, j));
+      while (next->name == NULL && j < points->len)
+        {
+         j++;
+          next = &(g_array_index (points, Point, j));
+       }
+      thre = j - i;
+      err = 0;
+      g_array_append_val (frames, g_array_index (points, Point, i));
+      for (; i < j; i++)
+        {
+         err += inc;
+         while (err > thre)
+           {
+             err -= thre;
+              g_array_append_val (frames, g_array_index (points, Point, i));
+           }
+       }
+    }
+  return frames;
+}
+
 void
 rescale_points (GArray *points)
 {
diff --git a/point.h b/point.h
index fc27a9b..0fd54ce 100644 (file)
--- a/point.h
+++ b/point.h
@@ -31,5 +31,6 @@ typedef struct
 
 GArray * ReadPoints (char *);
 void rescale_points (GArray *);
+GArray * drop_dup_frames (GArray *, int);
 
 #endif