diff --git a/src/lib/time.h b/src/lib/time.h index 286e2ccb8..521b5658d 100644 --- a/src/lib/time.h +++ b/src/lib/time.h @@ -85,7 +85,7 @@ extern "C" { /* ===================== C interface ======================== */ #endif #define NTSC_DROP_FRAME_FPS 29.97 -/* TODO: replace this by lib/time/FrameRate::NTSC */ +/* TODO: replace this by lib::time::FrameRate::NTSC */ /** * Formats a time value in H:MM:SS.mmm format into a temporary buffer. diff --git a/src/lib/time/digxel.hpp b/src/lib/time/digxel.hpp index ceb901461..9c49983f4 100644 --- a/src/lib/time/digxel.hpp +++ b/src/lib/time/digxel.hpp @@ -255,6 +255,7 @@ namespace time { void operator= (NUM n) { + if (n == value_) return; NUM changedValue = mutator(n); this->setValueRaw (changedValue); } diff --git a/src/lib/time/timecode.cpp b/src/lib/time/timecode.cpp index 1f3201cf0..7053800cf 100644 --- a/src/lib/time/timecode.cpp +++ b/src/lib/time/timecode.cpp @@ -59,8 +59,9 @@ namespace time { } - /** build up a frame count - * by quantising the given time value + /** build up a SMPTE timecode + * by quantising the given time value and then splitting it + * into hours, minutes, seconds and frame offset */ void Smpte::rebuild (SmpteTC& tc, QuantR quantiser, TimeValue const& rawTime) @@ -69,7 +70,8 @@ namespace time { UNIMPLEMENTED("build smpte components from raw time"); } - /** calculate the time point denoted by this frame count */ + /** calculate the time point denoted by this SMPTE timecode, + * by summing up the timecode's components */ TimeValue Smpte::evaluate (SmpteTC const& tc, QuantR quantiser) { @@ -79,6 +81,38 @@ namespace time { } + namespace { // Timecode implementation details + + + int + wrapFrames (SmpteTC& thisTC, int rawFrames) + { + int fps = 25; ////////////////////////////////TODO outch + thisTC.secs += rawFrames / fps; + return rawFrames % fps; + //////////////////////////////////TODO need floorwrap-util + } + + int + wrapSeconds (SmpteTC& thisTC, int rawSecs) + { + + } + + int + wrapMinutes (SmpteTC& thisTC, int rawMins) + { + + } + + int + wrapHours (SmpteTC& thisTC, int rawHours) + { + + } + + + }//(End)implementation details /** */ diff --git a/src/tool/try.cpp b/src/tool/try.cpp index f73e9dd6f..46080a56e 100644 --- a/src/tool/try.cpp +++ b/src/tool/try.cpp @@ -17,6 +17,7 @@ // 1/10 - can we determine at compile time the presence of a certain function (for duck-typing)? // 4/10 - pretty printing STL containers with python enabled GDB? // 1/11 - exploring numeric limits +// 1/11 - integer floor and wrap operation(s) //#include @@ -38,31 +39,24 @@ using std::string; using std::cout; using std::endl; -long -floordiv (long num, long den) - { - if (0 < (num^den)) - return num/den; - else - { - ldiv_t res = ldiv(num,den); - return (res.rem)? res.quot-1 - : res.quot; - } - } - -long -floordiv2 (long num, long den) - { - ldiv_t res = ldiv(num,den); - return (0 >= res.quot && res.rem)? res.quot-1 - : res.quot; - } +div_t +floorwrap (int num, int den) +{ + div_t res = div (num,den); + if (0 > (num^den) && res.rem) + { // wrap similar to floor() + --res.quot; + res.rem = den - (-res.rem); + } + return res; +} void checkDiv(int lhs, int rhs) { - cout << format ("%f / %f = %f \tfloor=%f floordiv=%f \n") % lhs % rhs % (lhs / rhs) % floor(double(lhs)/rhs) % floordiv2(lhs,rhs); + div_t wrap = floorwrap(lhs,rhs); + cout << format ("%2d / %2d = %2d %% = % d \tfloor=%6.2f wrap = (%2d, %2d) \n") + % lhs % rhs % (lhs/rhs) % (lhs%rhs) % floor(double(lhs)/rhs) % wrap.quot % wrap.rem; } int @@ -87,17 +81,6 @@ main (int, char**) checkDiv (-1,4); checkDiv (-1,-4); - - - int64_t muks = std::numeric_limits::max(); - muks /= 30; - double murks(muks); - - cout << format("%f // %f || %g \n") % muks % murks % std::numeric_limits::epsilon(); - - int64_t glucks = murks; - cout << glucks < + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + + +#include "lib/test/run.hpp" +#include "lib/util.hpp" + +#include +//#include +#include +#include + +using ::Test; +using std::cout; +//using std::rand; +using boost::format; + + +namespace util { +namespace test { + + + + namespace{ // Test data and operations + + div_t + floorwrap (int num, int den) + { + div_t res = div (num,den); + if (0 > (num^den) && res.rem) + { // wrap similar to floor() + --res.quot; + res.rem = den - (-res.rem); + } + return res; + } + + + void + showWrap (int val, int scale) + { + div_t wrap = floorwrap(val,scale); + cout << format ("% 3d /% 1d =% 1d %% =% d floor=% 4.1f wrap = (%2d,%2d) \n") + % val % scale % (val/scale) + % (val%scale) % floor(double(val)/scale) + % wrap.quot % wrap.rem; + } + + + + } // (End) test data and operations + + + + /********************************************************************** + * @test Evaluate a custom built integer floor function. + * This function is crucial for Lumiera's rule of quantisation + * of time values into frame intervals. This rule requires time + * points to be rounded towards the next lower frame border always, + * irrespective of the relation to the actual time origin. + * Contrast this to the built-in integer division operator, which + * truncates towards zero. + * + * @note if invoked with an non empty parameter, this test performs + * some interesting timing comparisons, which initially were + * used to tweak the implementation a bit. + * @see util.hpp + * @see QuantiserBasics_test + */ + class UtilFloorwrap_test : public Test + { + + virtual void + run (Arg arg) + { + showWrap ( 12,4); + showWrap ( 11,4); + showWrap ( 10,4); + showWrap ( 9,4); + showWrap ( 8,4); + showWrap ( 7,4); + showWrap ( 6,4); + showWrap ( 5,4); + showWrap ( 4,4); + showWrap ( 3,4); + showWrap ( 2,4); + showWrap ( 1,4); + showWrap ( 0,4); + showWrap (- 1,4); + showWrap (- 2,4); + showWrap (- 3,4); + showWrap (- 4,4); + showWrap (- 5,4); + showWrap (- 6,4); + showWrap (- 7,4); + showWrap (- 8,4); + showWrap (- 9,4); + showWrap (-10,4); + showWrap (-11,4); + showWrap (-12,4); + } + + + }; + + + + + LAUNCHER (UtilFloorwrap_test, "unit common"); + + +}} // namespace util::test diff --git a/wiki/renderengine.html b/wiki/renderengine.html index 85651f235..792a6487d 100644 --- a/wiki/renderengine.html +++ b/wiki/renderengine.html @@ -6746,7 +6746,7 @@ Question is: how fine grained and configurable needs this to be? -
+
The handling of [[Timecode]] is closely related to [[time representation and quantisation|TimeQuant]]. In fact, these two topics blend into one another. Time will be quantised into a //grid,// but this grid only makes sense when linked to a externally relevant meaning and representation, which is the Timecode. But a timecode value also denotes a specific point in time -- performing operations on a timecode is equivalent to manipulating a quantised time value.
 
 !Problem of dependencies
@@ -6771,9 +6771,9 @@ And last but not least, it is possible to get a new ~TimeValue, reflecting the c
 !!{{red{WIP 1/11}}}design tasks
 * @@color:green;✔@@ find out about the connection to the MetaAsset &rarr; [[Advice]]
 * @@color:green;✔@@ determine the primitives which need to be on the //effective quantiser API.//
-* find out how a format can address the individual components it's comprised of
+* @@color:green;✔@@ find out how a format can address the individual components it's comprised of &rarr; direct access by concrete type
 * @@color:green;✔@@ decide how a concrete TC value can refer to his quantiser &rarr; always using smart-ptr
-* maybe coin a //value handle// -- to tie the three required parts together
+* @@color:red;??@@ maybe coin a //value handle// -- to tie the three required parts together