define or stub to get it to compile; add function time-from gridnr

This commit is contained in:
Fischlurch 2011-01-14 05:33:50 +01:00
parent a1f2a60427
commit 457d4fb7c4
9 changed files with 116 additions and 59 deletions

View file

@ -118,6 +118,13 @@ lumiera_quantise_time (gavl_time_t time, gavl_time_t origin, gavl_time_t grid)
return alignedTime;
}
gavl_time_t
lumiera_time_of_gridpoint (long nr, gavl_time_t origin, gavl_time_t grid)
{
gavl_time_t offset = nr * grid;
return origin + offset;
}
gavl_time_t
lumiera_build_time(long millis, uint secs, uint mins, uint hours)

View file

@ -116,6 +116,15 @@ lumiera_quantise_frames (gavl_time_t time, gavl_time_t origin, gavl_time_t grid)
gavl_time_t
lumiera_quantise_time (gavl_time_t time, gavl_time_t origin, gavl_time_t grid);
/**
* Calculate time of a grid point (frame start)
* @param nr index number of the grid point (0 is at origin)
* @param grid spacing of the grid intervals, measured in GAVL_TIME_SCALE
* @return time point (frame start) on the Lumiera internal time scale
*/
gavl_time_t
lumiera_time_of_gridpoint (long nr, gavl_time_t origin, gavl_time_t grid);
/**
* Builds a time value by summing up the given components.
*/

View file

@ -273,7 +273,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<long, digxel::CountFormatter> CountVal; ///< for displaying a hex byte
typedef Digxel<long, digxel::CountFormatter> CountVal; ///< for displaying a hex byte
}} // lib::time

View file

@ -44,6 +44,25 @@ namespace time {
class Quantiser; // API for grid aligning
/**
* smart reference for accessing an existing quantiser
*/
class QuantiserRef
{
size_t hashID_;
public:
QuantiserRef (Quantiser const&);
// using standard copy;
const Quantiser *
operator-> ()
{
UNIMPLEMENTED ("how to manage and address the existing quantisers");
}
};
/**
@ -74,10 +93,11 @@ namespace time {
* these frame counts. As with any timecode, the
* underlying framerate/quantisation remains implicit.
*/
class Frames
: public Format
struct Frames
: Format
{
static void rebuild (FrameNr&, Quantiser const&, TimeValue const&);
static void rebuild (FrameNr&, Quantiser const&, TimeValue const&);
static TimeValue evaluate (FrameNr const&, QuantiserRef);
};
@ -87,10 +107,11 @@ namespace time {
* by specifying time as hour-minute-second plus the
* frame number within the actual second.
*/
class Smpte
: public Format
struct Smpte
: Format
{
static void rebuild (SmpteTC&, Quantiser const&);
static void rebuild (SmpteTC&, Quantiser const&);
static TimeValue evaluate (SmpteTC const&, QuantiserRef);
};
@ -101,10 +122,11 @@ namespace time {
* entity in time. HMS-Timecode is similar to SMPTE, but uses a
* floating point milliseconds value instead of the frame count
*/
class Hms
: public Format
struct Hms
: Format
{
static void rebuild (HmsTC&, Quantiser const&);
static void rebuild (HmsTC&, Quantiser const&);
static TimeValue evaluate (HmsTC const&, QuantiserRef);
};
@ -117,10 +139,11 @@ namespace time {
* @note Seconds is implemented as rational number and thus uses
* decimal format, not the usual sexagesimal time format
*/
class Seconds
: public Format
struct Seconds
: Format
{
static void rebuild (Secs&, Quantiser const&);
static void rebuild (Secs&, Quantiser const&);
static TimeValue evaluate (Secs const&, QuantiserRef);
};

View file

@ -92,7 +92,7 @@ namespace time {
* @see #lumiera_quantise_time
*/
TimeValue
FixedFrameQuantiser::gridAlign (TimeValue const& rawTime)
FixedFrameQuantiser::gridAlign (TimeValue const& rawTime) const
{
return TimeValue (lumiera_quantise_time (_raw(rawTime), _raw(origin_), _raw(raster_)));
}
@ -107,11 +107,23 @@ namespace time {
* @see #lumiera_quantise_frames
*/
long
FixedFrameQuantiser::gridPoint (TimeValue const& rawTime)
FixedFrameQuantiser::gridPoint (TimeValue const& rawTime) const
{
return lumiera_quantise_frames (_raw(rawTime), _raw(origin_), _raw(raster_));
}
/** calculate time value of a grid interval (frame) start point
* @return time point measured in Lumiera internal time
* @warning returned time values are limited by the
* valid range of lumiera::Time
*/
TimeValue
FixedFrameQuantiser::timeOf (long gridPoint) const
{
return TimeValue (lumiera_time_of_gridpoint (gridPoint, _raw(origin_), _raw(raster_)));
}

View file

@ -84,32 +84,13 @@ namespace time {
typedef _Iter iterator;
iterator getSupportedFormats() const;
virtual TimeValue gridAlign (TimeValue const& raw) =0;
virtual long gridPoint (TimeValue const& raw) =0;
virtual TimeValue gridAlign (TimeValue const& raw) const =0;
virtual long gridPoint (TimeValue const& raw) const =0;
virtual TimeValue timeOf (long gridPoint) const =0;
};
/**
* smart reference
* for accessing an existing quantiser
*/
class QuantiserRef
{
size_t hashID_;
public:
QuantiserRef (Quantiser const&);
// using standard copy;
Quantiser const&
operator-> ()
{
UNIMPLEMENTED ("how to manage and address the existing quantisers");
}
};
@ -133,8 +114,9 @@ namespace time {
FixedFrameQuantiser (Duration const& frame_duration, TimeValue referencePoint =TimeValue(0));
TimeValue gridAlign (TimeValue const&);
long gridPoint (TimeValue const&);
TimeValue gridAlign (TimeValue const&) const;
long gridPoint (TimeValue const&) const;
TimeValue timeOf (long gridPoint) const;
};

View file

@ -49,24 +49,50 @@ namespace time {
{
framecnt.setValueRaw(quantiser.gridPoint (rawTime));
}
/** calculate the time point denoted by this frame count */
TimeValue
Frames::evaluate (FrameNr const& framecnt, QuantiserRef quantiser)
{
return quantiser->timeOf (framecnt);
}
}
/** */
QuantiserRef::QuantiserRef (Quantiser const&)
: hashID_(123) /////////////////////////////////////////////////TODO
{ }
/** */
FrameNr::FrameNr (QuTime const& quantisedTime)
: TCode(quantisedTime)
, CountVal()
{
quantisedTime.castInto (*this);
}
/** */
SmpteTC::SmpteTC (QuTime const& quantisedTime)
: tpoint_(quantisedTime) /////////////////////////////TODO eternal bullshit
: TCode(quantisedTime)
// : tpoint_(quantisedTime) /////////////////////////////TODO eternal bullshit
{ }
/** */
HmsTC::HmsTC (QuTime const& quantisedTime)
: tpoint_(quantisedTime) /////////////////////////////TODO bullshit
: TCode(quantisedTime)
// : tpoint_(quantisedTime) /////////////////////////////TODO bullshit
{ }
/** */
Secs::Secs (QuTime const& quantisedTime)
: sec_(TimeVar(quantisedTime) / GAVL_TIME_SCALE) /////////////TODO bullshit
: TCode(quantisedTime)
// : sec_(TimeVar(quantisedTime) / GAVL_TIME_SCALE) /////////////TODO bullshit
{ }

View file

@ -50,7 +50,6 @@ namespace time {
*/
class TCode
{
QuantiserRef qID_;
public:
virtual ~TCode();
@ -67,6 +66,9 @@ namespace time {
virtual string show() const =0;
virtual Literal tcID() const =0;
virtual TimeValue value() const =0;
protected:
QuantiserRef qID_;
};
@ -81,24 +83,19 @@ namespace time {
*/
class FrameNr
: public TCode
, CountVal
, public CountVal
{
string show() const { return lexical_cast<string>(nr_)+"fr"; }
string show() const { return string(show())+"fr"; }
Literal tcID() const { return "Frame-count"; }
TimeValue value() const { return Time(FACTOR_TODO * nr_); }
TimeValue value() const { return Format::evaluate (*this, qID_); }
public:
typedef format::Frames Format;
FrameNr (QuTime const& quantisedTime)
: TCode(quantisedTime)
, CountVal()
{
quantisedTime.castInto (*this);
}
FrameNr (QuTime const& quantisedTime);
operator long() const { return nr_; }
// CountVal implicitly convertible to long
};

View file

@ -70,7 +70,8 @@ namespace time {
/* == implementation == */
inline
QuTime::operator QuantiserRef() const
{
ASSERT (quantiser_);
@ -78,7 +79,7 @@ namespace time {
}
template<class FMT>
bool
inline bool
QuTime::supports() const
{
return false; ////////////////TODO;
@ -86,7 +87,7 @@ namespace time {
template<class FMT>
typename format::Traits<FMT>::TimeCode
inline typename format::Traits<FMT>::TimeCode
QuTime::formatAs() const
{
typedef typename format::Traits<FMT>::TimeCode TC;
@ -95,12 +96,12 @@ namespace time {
template<class TC>
void
inline void
QuTime::castInto (TC& timecode) const
{
typedef typename TC::Format Format;
Format::rebuild (timecode, *quantiser_);
Format::rebuild (timecode, *quantiser_, TimeValue(*this));
}