From f930703e86fe913cfa3c9f7f67719f701260b13a Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 20 Jan 2011 22:17:25 +0100 Subject: [PATCH] WIP draft cascading breakdown of time into timecode components TODO not entirely correct... and how to access the framerate? --- src/lib/time/timecode.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/lib/time/timecode.cpp b/src/lib/time/timecode.cpp index 7053800cf..26a0ffa79 100644 --- a/src/lib/time/timecode.cpp +++ b/src/lib/time/timecode.cpp @@ -30,8 +30,9 @@ #include "lib/util.hpp" -using util::unConst; using std::string; +using util::unConst; +using util::IDiv; namespace lib { @@ -88,27 +89,32 @@ namespace time { wrapFrames (SmpteTC& thisTC, int rawFrames) { int fps = 25; ////////////////////////////////TODO outch - thisTC.secs += rawFrames / fps; - return rawFrames % fps; - //////////////////////////////////TODO need floorwrap-util + IDiv scaleRelation(rawFrames, fps); + thisTC.secs += scaleRelation.quot; + return scaleRelation.rem; } int wrapSeconds (SmpteTC& thisTC, int rawSecs) { - + IDiv scaleRelation(rawSecs, 60); + thisTC.mins += scaleRelation.quot; + return scaleRelation.rem; } int wrapMinutes (SmpteTC& thisTC, int rawMins) { - + IDiv scaleRelation(rawMins, 60); + thisTC.hours += scaleRelation.quot; + return scaleRelation.rem; } int wrapHours (SmpteTC& thisTC, int rawHours) { - + thisTC.sgn = rawHours; + return rawHours; }