SMPTE Timecode: first round of debugging and testing
This commit is contained in:
parent
0493caac1d
commit
1a07cc9bb2
4 changed files with 90 additions and 34 deletions
|
|
@ -175,6 +175,12 @@ namespace time {
|
|||
CountFormatter() : PrintfFormatter<long,20>("%04ld") { }
|
||||
};
|
||||
|
||||
struct HourFormatter
|
||||
: PrintfFormatter<int, 9>
|
||||
{
|
||||
HourFormatter() : PrintfFormatter<int,9>("%2d") { }
|
||||
};
|
||||
|
||||
|
||||
struct SignFormatter
|
||||
{
|
||||
|
|
@ -290,6 +296,7 @@ namespace time {
|
|||
/* == predefined Digxel configurations == */
|
||||
typedef Digxel< int, digxel::SexaFormatter> SexaDigit; ///< for displaying time components (sexagesimal)
|
||||
typedef Digxel<uint, digxel::HexaFormatter> HexaDigit; ///< for displaying a hex byte
|
||||
typedef Digxel< int, digxel::HourFormatter> HourDigit; ///< for displaying hours in H:M.S
|
||||
typedef Digxel<long, digxel::CountFormatter> CountVal; ///< for displaying a counter
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,7 @@
|
|||
|
||||
using std::string;
|
||||
using util::unConst;
|
||||
using std::tr1::bind;
|
||||
using std::tr1::placeholders::_1;
|
||||
using util::isSameObject;
|
||||
|
||||
|
||||
namespace lib {
|
||||
|
|
@ -117,37 +116,51 @@ namespace time {
|
|||
typedef util::IDiv<int> Div;
|
||||
|
||||
int
|
||||
wrapFrames (SmpteTC& thisTC, int rawFrames)
|
||||
wrapFrames (SmpteTC* thisTC, int rawFrames)
|
||||
{
|
||||
Div scaleRelation(rawFrames, thisTC.getFps());
|
||||
thisTC.secs += scaleRelation.quot;
|
||||
Div scaleRelation(rawFrames, thisTC->getFps());
|
||||
thisTC->secs += scaleRelation.quot;
|
||||
return scaleRelation.rem;
|
||||
}
|
||||
|
||||
int
|
||||
wrapSeconds (SmpteTC& thisTC, int rawSecs)
|
||||
wrapSeconds (SmpteTC* thisTC, int rawSecs)
|
||||
{
|
||||
Div scaleRelation(rawSecs, 60);
|
||||
thisTC.mins += scaleRelation.quot;
|
||||
thisTC->mins += scaleRelation.quot;
|
||||
return scaleRelation.rem;
|
||||
}
|
||||
|
||||
int
|
||||
wrapMinutes (SmpteTC& thisTC, int rawMins)
|
||||
wrapMinutes (SmpteTC* thisTC, int rawMins)
|
||||
{
|
||||
Div scaleRelation(rawMins, 60);
|
||||
thisTC.hours += scaleRelation.quot;
|
||||
thisTC->hours += scaleRelation.quot;
|
||||
return scaleRelation.rem;
|
||||
}
|
||||
|
||||
int
|
||||
wrapHours (SmpteTC& thisTC, int rawHours)
|
||||
wrapHours (SmpteTC* thisTC, int rawHours)
|
||||
{
|
||||
thisTC.sgn = rawHours;
|
||||
thisTC->sgn = rawHours;
|
||||
return rawHours;
|
||||
}
|
||||
|
||||
|
||||
using std::tr1::bind;
|
||||
using std::tr1::placeholders::_1;
|
||||
|
||||
/** bind the individual Digxel mutation functors
|
||||
* to normalise raw component values */
|
||||
inline void
|
||||
setupComponentNormalisation (SmpteTC * thisTC)
|
||||
{
|
||||
thisTC->hours.mutator = bind (wrapHours, thisTC, _1 );
|
||||
thisTC->mins.mutator = bind (wrapMinutes, thisTC, _1 );
|
||||
thisTC->secs.mutator = bind (wrapSeconds, thisTC, _1 );
|
||||
thisTC->frames.mutator = bind (wrapFrames, thisTC, _1 );
|
||||
}
|
||||
|
||||
}//(End)implementation details
|
||||
|
||||
|
||||
|
|
@ -165,16 +178,41 @@ namespace time {
|
|||
: TCode(quantisedTime)
|
||||
, effectiveFramerate_(Format::getFramerate (*quantiser_, quantisedTime))
|
||||
{
|
||||
// Functors to normalise raw component values
|
||||
hours.mutator = bind (wrapHours, *this, _1 );
|
||||
mins.mutator = bind (wrapMinutes, *this, _1 );
|
||||
secs.mutator = bind (wrapSeconds, *this, _1 );
|
||||
frames.mutator = bind (wrapFrames, *this, _1 );
|
||||
|
||||
setupComponentNormalisation (this);
|
||||
quantisedTime.castInto (*this);
|
||||
}
|
||||
|
||||
|
||||
SmpteTC::SmpteTC (SmpteTC const& o)
|
||||
: TCode(o)
|
||||
, effectiveFramerate_(o.effectiveFramerate_)
|
||||
{
|
||||
setupComponentNormalisation (this);
|
||||
sgn = o.sgn;
|
||||
hours = o.hours;
|
||||
mins = o.mins;
|
||||
secs = o.secs;
|
||||
frames = o.frames;
|
||||
}
|
||||
|
||||
|
||||
SmpteTC&
|
||||
SmpteTC::operator= (SmpteTC const& o)
|
||||
{
|
||||
if (!isSameObject (*this, o))
|
||||
{
|
||||
TCode::operator= (o);
|
||||
effectiveFramerate_ = o.effectiveFramerate_;
|
||||
sgn = o.sgn;
|
||||
hours = o.hours;
|
||||
mins = o.mins;
|
||||
secs = o.secs;
|
||||
frames = o.frames;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/** */
|
||||
HmsTC::HmsTC (QuTime const& quantisedTime)
|
||||
: TCode(quantisedTime)
|
||||
|
|
@ -208,7 +246,6 @@ namespace time {
|
|||
string
|
||||
SmpteTC::show() const
|
||||
{
|
||||
rebuild();
|
||||
string tc;
|
||||
tc.reserve(15);
|
||||
tc += sgn.show();
|
||||
|
|
|
|||
|
|
@ -117,15 +117,17 @@ namespace time {
|
|||
typedef format::Smpte Format;
|
||||
|
||||
SmpteTC (QuTime const& quantisedTime);
|
||||
SmpteTC (SmpteTC const&);
|
||||
SmpteTC& operator= (SmpteTC const&);
|
||||
|
||||
void rebuild() const;
|
||||
uint getFps() const;
|
||||
|
||||
Digxel<int> hours;
|
||||
SexaDigit mins;
|
||||
SexaDigit secs;
|
||||
SexaDigit frames;
|
||||
Signum sgn;
|
||||
HourDigit hours;
|
||||
SexaDigit mins;
|
||||
SexaDigit secs;
|
||||
SexaDigit frames;
|
||||
Signum sgn;
|
||||
|
||||
SmpteTC& operator++();
|
||||
SmpteTC& operator--();
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ namespace test{
|
|||
// checkHms ();
|
||||
checkSmpte();
|
||||
// checkDropFrame();
|
||||
// checkCopyAssignments();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -107,13 +108,13 @@ namespace test{
|
|||
void
|
||||
checkSmpte ()
|
||||
{
|
||||
Time raw(0.5,23,42,5);
|
||||
Time raw(555,23,42,5);
|
||||
QuTime t1 (raw, "pal0");
|
||||
SmpteTC smpte(t1);
|
||||
|
||||
showTimeCode(smpte);
|
||||
CHECK ("5:42:23:13" == string(smpte));
|
||||
CHECK (raw + Time(0.02,0) == smpte.getTime());
|
||||
CHECK (" 5:42:23:13" == string(smpte));
|
||||
CHECK (raw - Time(35,0) == smpte.getTime());
|
||||
CHECK (13 == smpte.frames);
|
||||
CHECK (23 == smpte.secs);
|
||||
CHECK (42 == smpte.mins);
|
||||
|
|
@ -122,29 +123,31 @@ namespace test{
|
|||
CHECK ("SMPTE" == smpte.describe());
|
||||
|
||||
++smpte;
|
||||
CHECK ("5:42:23:14" == string(smpte));
|
||||
CHECK (" 5:42:23:14" == string(smpte));
|
||||
smpte.frames += 12;
|
||||
CHECK ("5:42:24:01" == string(smpte));
|
||||
CHECK (" 5:42:24:01" == string(smpte));
|
||||
smpte.secs = -120;
|
||||
CHECK ("5:40:00:01" == string(smpte));
|
||||
CHECK (" 5:40:00:01" == string(smpte));
|
||||
CHECK (smpte.mins-- == 40);
|
||||
CHECK (--smpte.mins == 38);
|
||||
CHECK ("5:38:00:01" == string(smpte));
|
||||
CHECK (" 5:38:00:01" == string(smpte));
|
||||
Time tx = smpte.getTime();
|
||||
smpte.hours -= 6;
|
||||
CHECK ("-0:21:59:24"== string(smpte));
|
||||
CHECK ("- 0:21:59:24"== string(smpte));
|
||||
CHECK (tx - Time(6*60*60) == smpte.getTime());
|
||||
CHECK (-1 == smpte.sgn);
|
||||
smpte.sgn += 123;
|
||||
CHECK ("0:21:59:24"== string(smpte));
|
||||
CHECK (" 0:21:59:24"== string(smpte));
|
||||
|
||||
smpte.secs.setValueRaw(61);
|
||||
CHECK (smpte.secs == 61);
|
||||
CHECK (smpte.getTime() == Time(24.0/25,01,22));
|
||||
CHECK (smpte.getTime() == Time(1000*24/25, 01, 22));
|
||||
CHECK (smpte.secs == 61);
|
||||
smpte.hours += 0;
|
||||
CHECK (" 0:21:61:24"== string(smpte));
|
||||
smpte.rebuild();
|
||||
CHECK (smpte.secs == 1);
|
||||
CHECK (smpte.mins == 22);
|
||||
CHECK (" 0:22:01:24"== string(smpte));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -153,6 +156,13 @@ namespace test{
|
|||
{
|
||||
UNIMPLEMENTED ("verify especially SMPTE-drop-frame timecode");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
checkCopyAssignments ()
|
||||
{
|
||||
UNIMPLEMENTED ("verify Timecode values can be copied and assigned properly");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue