55 SetAJAFrameRatePrivate(ajaFrameRate);
61 mFrameTimeScale = frameTimeScale;
62 mFrameDuration = frameDuration;
68 mFrameTimeScale = frameTimeScale;
69 mFrameDuration = frameDuration;
70 mAudioRate = audioRate;
75 mFrameTimeScale = other.mFrameTimeScale;
76 mFrameDuration = other.mFrameDuration;
77 mAudioRate = other.mAudioRate;
78 mTickRate = other.mTickRate;
97 mFrameTimeScale = t.mFrameTimeScale;
98 mFrameDuration = t.mFrameDuration;
99 mAudioRate = t.mAudioRate;
100 mTickRate = t.mTickRate;
110 if (mFrameTimeScale != b.mFrameTimeScale)
112 if (mFrameDuration != b.mFrameDuration)
114 if (mAudioRate != b.mAudioRate)
116 if (mTickRate != b.mTickRate)
124 return !(*
this == a);
129 mFrameTimeScale = frameTimeScale;
130 mFrameDuration = frameDuration;
135 frameTimeScale = mFrameTimeScale;
136 frameDuration = mFrameDuration;
141 return mFrameTimeScale;
146 mFrameTimeScale = timeScale;
151 return mFrameDuration;
166 SetAJAFrameRatePrivate(ajaFrameRate);
189 return Convert(frames, mFrameTimeScale, mFrameDuration, mAudioRate, 1, round,
true);
194 return Convert(frames, mFrameTimeScale, mFrameDuration, mTickRate, 1, round,
true);
199 return (
double)frames * (double)mFrameDuration / (
double)mFrameTimeScale;
204 return (
double)scaleUnits / (double)mFrameTimeScale;
211 val = (float)mFrameTimeScale / (
float)mFrameDuration;
219 val = (double)mFrameTimeScale / (
double)mFrameDuration;
225 return Convert(frames, mFrameTimeScale, mFrameDuration, 1000000, 1, round,
true);
230 return Convert(frames, mFrameTimeScale, mFrameDuration, 10000000, 1, round,
true);
235 return Convert(samples, mAudioRate, 1, mFrameTimeScale, mFrameDuration, round,
true);
240 return Convert(samples, mAudioRate, mTickRate, round,
true);
245 return (
double)samples / (double)mAudioRate;
250 return Convert(samples, mAudioRate, 1000000, round,
true);
255 return Convert(ticks, mTickRate, 1, mFrameTimeScale, mFrameDuration, round,
true);
260 return Convert(ticks, mTickRate, mAudioRate, round,
true);
265 return (
double)ticks / (double)mTickRate;
270 return Convert(ticks, mTickRate, 1000000, round,
true);
275 return Convert((int64_t)(seconds * 1000000000.0), 1000000000, 1, mFrameTimeScale, mFrameDuration, round,
true);
280 return Convert((int64_t)(seconds * 1000000000.0), 1000000000, mAudioRate, round,
true);
285 return Convert((int64_t)(seconds * 1000000000.0), 1000000000, mTickRate, round,
true);
290 return Convert(microseconds, 1000000, 1, mFrameTimeScale, mFrameDuration, round,
true);
295 return Convert(nanoseconds100, 10000000, 1, mFrameTimeScale, mFrameDuration, round,
true);
300 return Convert(microseconds, 1000000, mAudioRate, round,
true);
305 return Convert(microseconds, 1000000, mTickRate, round,
true);
310 return Convert((int64_t)(seconds * 1000000.0), 1000000, 1000000, round,
false);
315 return (
double)microseconds / 1000000.0;
320 bool bIsClose =
false;
323 double dif = rate1 / rate2;
328 if ((dif >= .9999) && (dif <= 1.0001))
341 return ((mFrameTimeScale % mFrameDuration) != 0) ?
true :
false;
349 if (rate != mTickRate)
351 ticks =
Convert(ticks, rate, mTickRate,
false,
true);
359 int64_t outValue = 0;
364 int64_t roundValue = inRate / (outRate * 2);
367 inValue += roundValue;
371 inValue -= roundValue;
378 outValue = inValue / inRate * outRate;
379 outValue += (inValue % inRate) * outRate / inRate;
384 outValue = inValue * outRate / inRate;
391 int64_t outScale, int64_t outDuration,
bool round,
bool large)
393 int64_t outValue = 0;
394 int64_t roundValue = 0;
395 int64_t inScaleOutDuration = inScale * outDuration;
396 int64_t outScaleInDuration = outScale * inDuration;
401 roundValue = inScaleOutDuration / (outScaleInDuration * 2);
404 inValue += roundValue;
408 inValue -= roundValue;
415 outValue = inValue / inScaleOutDuration * outScaleInDuration;
416 outValue += (inValue % inScaleOutDuration) * outScaleInDuration / inScaleOutDuration;
421 outValue = inValue * outScaleInDuration / inScaleOutDuration;
442 void AJATimeBase::SetAJAFrameRatePrivate(
AJA_FrameRate ajaFrameRate)
const int64_t AJATimeBaseDefaultTimeScale
int64_t SamplesToFrames(int64_t samples, bool round=false) const
double FramesToSeconds(int64_t frames) const
double GetFramesPerSecondDouble(void) const
void SetAJAFrameRate(AJA_FrameRate ajaFrameRate)
int64_t SamplesToTicks(int64_t samples, bool round=false) const
const AJAFrameRateEntry AJAFrameRateTable[]
int64_t SecondsToSamples(double seconds, bool round=false)
int64_t MicrosecondsToTicks(int64_t microseconds, bool round=false)
int64_t Nanoseconds100ToFrames(int64_t nanoseconds100, bool round=false)
bool operator!=(const AJATimeBase &val) const
Declares the AJATime class.
double ScaleUnitsToSeconds(int64_t num) const
int64_t TicksToFrames(int64_t ticks, bool round=false)
AJA_FrameRate GetAJAFrameRate(void) const
double TicksToSeconds(int64_t ticks)
int64_t FramesToMicroseconds(int64_t frames, bool round=false) const
Declares the AJATimeBase class.
void GetFrameRate(int64_t &frameTimeScale, int64_t &frameDuration) const
void SetTickRate(int64_t rate)
float GetFramesPerSecond(void) const
int64_t GetTickRate() const
int64_t FramesToNanoseconds100(int64_t frames, bool round=false) const
int64_t MicrosecondsToSamples(int64_t microseconds, bool round=false)
static int64_t GetSystemCounter(void)
Returns the current value of the host system's high-resolution time counter.
static double MicrosecondsToSeconds(int64_t microseconds)
static int64_t SecondsToMicroseconds(double seconds, bool round=false)
static int64_t GetSystemFrequency(void)
Returns the frequency of the host system's high-resolution time counter.
int64_t GetFrameTimeScale(void) const
int64_t SecondsToFrames(double seconds, bool round=false)
bool IsCloseTo(const AJATimeBase &timeBase) const
int64_t GetFrameDuration(void) const
int64_t MicrosecondsToFrames(int64_t microseconds, bool round=false)
int64_t SamplesToMicroseconds(int64_t samples, bool round=false)
int64_t TicksToSamples(int64_t ticks, bool round=false)
void SetAudioRate(int64_t rate)
const int64_t AJATimeBaseDefaultDuration
double SamplesToSeconds(int64_t samples)
int64_t FramesToTicks(int64_t frames, bool round=false) const
bool operator==(const AJATimeBase &val) const
bool IsNonIntegralRatio(void) const
static int64_t Convert(int64_t inValue, int64_t inRate, int64_t outRate, bool round, bool large)
Private include file for all ajabase sources.
int64_t FramesToSamples(int64_t frames, bool round=false) const
int64_t GetAudioRate() const
void SetFrameRate(int64_t frameTimeScale, int64_t frameDuration)
int64_t TicksToMicroseconds(int64_t ticks, bool round=false)
void SetFrameTimeScale(int64_t timeScale)
AJATimeBase & operator=(const AJATimeBase &t)
AJA_FrameRate ajaFrameRate
int64_t SecondsToTicks(double seconds, bool round=false)
const size_t AJAFrameRateTableSize
const int64_t AJATimeBaseDefaultAudioRate