introduce timecodes display
[rugen] / src / dv1394app.c
index d367235..b1919ae 100644 (file)
@@ -555,3 +555,25 @@ void dv1394app_close( dv1394app this )
                page_close( this->pages[ -- this->page_count ] );
        free( this );
 }
+
+char* frames2tc( int f, float fps, char* buf )
+{
+       int tc[4] = { 0, 0, 0, 0 };
+       float d;
+       int t;
+
+       if ( fps )
+       {
+               d = f / fps;
+               t = d;
+
+               tc[0] = (d - t) * fps;
+               tc[1] = t % 60; t /= 60;
+               tc[2] = t % 60; t /= 60;
+               tc[3] = t % 24;
+       }
+
+       sprintf(buf, "%.2d:%.2d:%.2d:%.2d", tc[3], tc[2], tc[1], tc[0]);
+
+       return buf;
+}