AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
AJATimeBase Class Reference

#include <timebase.h>

Public Member Functions

 AJATimeBase ()
 
 AJATimeBase (AJA_FrameRate ajaFrameRate)
 
 AJATimeBase (int64_t frameTimeScale, int64_t frameDuration)
 
 AJATimeBase (int64_t frameTimeScale, int64_t frameDuration, int64_t audioRate)
 
 AJATimeBase (const AJATimeBase &other)
 
virtual ~AJATimeBase ()
 
void SetToDefault (void)
 
void SetFrameRate (int64_t frameTimeScale, int64_t frameDuration)
 
void SetAJAFrameRate (AJA_FrameRate ajaFrameRate)
 
void GetFrameRate (int64_t &frameTimeScale, int64_t &frameDuration) const
 
void GetFrameRate (uint32_t &frameTimeScale, uint32_t &frameDuration) const
 
int64_t GetFrameTimeScale (void) const
 
void SetFrameTimeScale (int64_t timeScale)
 
int64_t GetFrameDuration (void) const
 
void SetAudioRate (int64_t rate)
 
int64_t GetAudioRate () const
 
AJA_FrameRate GetAJAFrameRate (void) const
 
void SetTickRate (int64_t rate)
 
int64_t GetTickRate () const
 
int64_t FramesToSamples (int64_t frames, bool round=false) const
 
int64_t FramesToTicks (int64_t frames, bool round=false) const
 
double FramesToSeconds (int64_t frames) const
 
double ScaleUnitsToSeconds (int64_t num) const
 
int64_t FramesToMicroseconds (int64_t frames, bool round=false) const
 
int64_t FramesToNanoseconds100 (int64_t frames, bool round=false) const
 
int64_t SamplesToFrames (int64_t samples, bool round=false) const
 
int64_t SamplesToTicks (int64_t samples, bool round=false) const
 
double SamplesToSeconds (int64_t samples)
 
int64_t SamplesToMicroseconds (int64_t samples, bool round=false)
 
int64_t TicksToFrames (int64_t ticks, bool round=false)
 
int64_t TicksToSamples (int64_t ticks, bool round=false)
 
double TicksToSeconds (int64_t ticks)
 
int64_t TicksToMicroseconds (int64_t ticks, bool round=false)
 
int64_t SecondsToFrames (double seconds, bool round=false)
 
int64_t SecondsToSamples (double seconds, bool round=false)
 
int64_t SecondsToTicks (double seconds, bool round=false)
 
int64_t MicrosecondsToFrames (int64_t microseconds, bool round=false)
 
int64_t Nanoseconds100ToFrames (int64_t nanoseconds100, bool round=false)
 
int64_t MicrosecondsToSamples (int64_t microseconds, bool round=false)
 
int64_t MicrosecondsToTicks (int64_t microseconds, bool round=false)
 
int64_t GetSystemTicks ()
 
bool IsCloseTo (const AJATimeBase &timeBase) const
 
bool IsCloseTo (int64_t frameTimeScale, int64_t frameDuration) const
 
bool IsNonIntegralRatio (void) const
 
float GetFramesPerSecond (void) const
 
double GetFramesPerSecondDouble (void) const
 
AJATimeBaseoperator= (const AJATimeBase &t)
 
bool operator== (const AJATimeBase &val) const
 
bool operator!= (const AJATimeBase &val) const
 

Static Public Member Functions

static int64_t SecondsToMicroseconds (double seconds, bool round=false)
 
static double MicrosecondsToSeconds (int64_t microseconds)
 
static int64_t Convert (int64_t inValue, int64_t inRate, int64_t outRate, bool round, bool large)
 
static int64_t Convert (int64_t inValue, int64_t inScale, int64_t inDuration, int64_t outScale, int64_t outDuration, bool round, bool large)
 

Detailed Description

Class provides high resolution time base conversion

Definition at line 18 of file timebase.h.

Constructor & Destructor Documentation

◆ AJATimeBase() [1/5]

AJATimeBase::AJATimeBase ( )

Definition at line 46 of file timebase.cpp.

◆ AJATimeBase() [2/5]

AJATimeBase::AJATimeBase ( AJA_FrameRate  ajaFrameRate)

Construct the time base class.

Parameters
[in]ajaFrameRateFrame rate define found in videotypes.h

Definition at line 51 of file timebase.cpp.

◆ AJATimeBase() [3/5]

AJATimeBase::AJATimeBase ( int64_t  frameTimeScale,
int64_t  frameDuration 
)

Construct the time base class.

Parameters
[in]frameTimeScaleTime units per second (units/second)
[in]frameDurationTime units per frame (units/frame)

Definition at line 58 of file timebase.cpp.

◆ AJATimeBase() [4/5]

AJATimeBase::AJATimeBase ( int64_t  frameTimeScale,
int64_t  frameDuration,
int64_t  audioRate 
)

Construct the time base class.

Parameters
[in]frameTimeScaleTime units per second (units/second)
[in]frameDurationTime units per frame (units/frame)
[in]audioRateAudio sample rate (samples/second)

Definition at line 65 of file timebase.cpp.

◆ AJATimeBase() [5/5]

AJATimeBase::AJATimeBase ( const AJATimeBase other)

Copy constructor

Parameters
[in]otherAJATimeBase to copy

Definition at line 73 of file timebase.cpp.

◆ ~AJATimeBase()

AJATimeBase::~AJATimeBase ( )
virtual

Definition at line 81 of file timebase.cpp.

Member Function Documentation

◆ Convert() [1/2]

int64_t AJATimeBase::Convert ( int64_t  inValue,
int64_t  inRate,
int64_t  outRate,
bool  round,
bool  large 
)
static

Definition at line 357 of file timebase.cpp.

◆ Convert() [2/2]

int64_t AJATimeBase::Convert ( int64_t  inValue,
int64_t  inScale,
int64_t  inDuration,
int64_t  outScale,
int64_t  outDuration,
bool  round,
bool  large 
)
static

Definition at line 390 of file timebase.cpp.

◆ FramesToMicroseconds()

int64_t AJATimeBase::FramesToMicroseconds ( int64_t  frames,
bool  round = false 
) const

Convert video frames to time in microseconds.

Parameters
[in]framesVideo frame count to convert.
[in]roundRound the result.
Returns
Time in microseconds.

Definition at line 223 of file timebase.cpp.

◆ FramesToNanoseconds100()

int64_t AJATimeBase::FramesToNanoseconds100 ( int64_t  frames,
bool  round = false 
) const

Convert video frames to time in 100 nanoseconds.

Parameters
[in]framesVideo frame count to convert.
[in]roundRound the result.
Returns
Time in microseconds.

Definition at line 228 of file timebase.cpp.

◆ FramesToSamples()

int64_t AJATimeBase::FramesToSamples ( int64_t  frames,
bool  round = false 
) const

Convert video frames to audio samples.

Parameters
[in]framesVideo frame count to convert.
[in]roundRound the result.
Returns
Audio sample count.

Definition at line 187 of file timebase.cpp.

◆ FramesToSeconds()

double AJATimeBase::FramesToSeconds ( int64_t  frames) const

Convert video frames to time in seconds.

Parameters
[in]framesVideo frame count to convert.
Returns
Time in seconds.

Definition at line 197 of file timebase.cpp.

◆ FramesToTicks()

int64_t AJATimeBase::FramesToTicks ( int64_t  frames,
bool  round = false 
) const

Convert video frames to system ticks.

Parameters
[in]framesVideo frame count to convert.
[in]roundRound the result.
Returns
System tick count.

Definition at line 192 of file timebase.cpp.

◆ GetAJAFrameRate()

AJA_FrameRate AJATimeBase::GetAJAFrameRate ( void  ) const

Get the AJA_FrameRate which is close to the current value, return unknown if not close.

Returns
AJA_FrameRate value, may be unknown

Definition at line 427 of file timebase.cpp.

◆ GetAudioRate()

int64_t AJATimeBase::GetAudioRate ( ) const

Get the audio sample rate used in conversions.

Returns
Audio rate in samples/second.

Definition at line 159 of file timebase.cpp.

◆ GetFrameDuration()

int64_t AJATimeBase::GetFrameDuration ( void  ) const

Get the video frame duration used in conversions.

Returns
frameDuration Time units per frame (units/frame)

Definition at line 149 of file timebase.cpp.

◆ GetFrameRate() [1/2]

void AJATimeBase::GetFrameRate ( int64_t &  frameTimeScale,
int64_t &  frameDuration 
) const

Get the video frame rate used in conversions.

The frame rate is specified as frameTimeScale/frameDuration = frames/seconds.

Parameters
[out]frameTimeScaleTime units per second (units/second)
[out]frameDurationTime units per frame (units/frame)

Definition at line 133 of file timebase.cpp.

◆ GetFrameRate() [2/2]

void AJATimeBase::GetFrameRate ( uint32_t &  frameTimeScale,
uint32_t &  frameDuration 
) const

◆ GetFramesPerSecond()

float AJATimeBase::GetFramesPerSecond ( void  ) const

Returns frames per second

Returns
frames per second

Definition at line 207 of file timebase.cpp.

◆ GetFramesPerSecondDouble()

double AJATimeBase::GetFramesPerSecondDouble ( void  ) const

Definition at line 215 of file timebase.cpp.

◆ GetFrameTimeScale()

int64_t AJATimeBase::GetFrameTimeScale ( void  ) const

Get the video frame time scale used in conversions.

Returns
frameTimeScale Time units per second (units/second)

Definition at line 139 of file timebase.cpp.

◆ GetSystemTicks()

int64_t AJATimeBase::GetSystemTicks ( )

Get the current value of the system tick count.

Returns
System tick count.

Definition at line 344 of file timebase.cpp.

◆ GetTickRate()

int64_t AJATimeBase::GetTickRate ( ) const

Get the system tick rate used in conversions.

Returns
Tick rate in ticks/second.

Definition at line 182 of file timebase.cpp.

◆ IsCloseTo() [1/2]

bool AJATimeBase::IsCloseTo ( const AJATimeBase timeBase) const

Returns if timebases are reasonably close

Parameters
[in]timeBaseTime base to compare.
Returns
True if the same or close (returns false if either duration is zero).

Definition at line 318 of file timebase.cpp.

◆ IsCloseTo() [2/2]

bool AJATimeBase::IsCloseTo ( int64_t  frameTimeScale,
int64_t  frameDuration 
) const

Returns if timebases are reasonably close

Parameters
[in]frameTimeScaleTime scale to compare.
[in]frameDurationTime duration to compare.
Returns
True if the same or close (returns false if either duration is zero).

Definition at line 333 of file timebase.cpp.

◆ IsNonIntegralRatio()

bool AJATimeBase::IsNonIntegralRatio ( void  ) const

Test if the timescale is not a simple multiple of the duration

The intent is that even ratios are "non-drop", otherwise the timebase is "drop frame" In this sense, this method can be thought of as equivalent to IsDropFrame()

Returns
True if the timescale/duration ratio has a non-zero fraction, i.e. "drop frame".

Definition at line 339 of file timebase.cpp.

◆ MicrosecondsToFrames()

int64_t AJATimeBase::MicrosecondsToFrames ( int64_t  microseconds,
bool  round = false 
)

Convert microseconds to video frames.

Parameters
[in]microsecondsSystem tick count to convert.
[in]roundRound the result.
Returns
Video frame count.

Definition at line 288 of file timebase.cpp.

◆ MicrosecondsToSamples()

int64_t AJATimeBase::MicrosecondsToSamples ( int64_t  microseconds,
bool  round = false 
)

Convert microseconds to audio samples.

Parameters
[in]microsecondsSystem tick count to convert.
[in]roundRound the result.
Returns
Audio sample count.

Definition at line 298 of file timebase.cpp.

◆ MicrosecondsToSeconds()

double AJATimeBase::MicrosecondsToSeconds ( int64_t  microseconds)
static

Convert microseconds to time in seconds.

Parameters
[in]microsecondsSystem tick count to convert.
Returns
Time in seconds.

Definition at line 313 of file timebase.cpp.

◆ MicrosecondsToTicks()

int64_t AJATimeBase::MicrosecondsToTicks ( int64_t  microseconds,
bool  round = false 
)

Convert microseconds to system ticks.

Parameters
[in]microsecondsSystem tick count to convert.
[in]roundRound the result.
Returns
Time in microseconds.

Definition at line 303 of file timebase.cpp.

◆ Nanoseconds100ToFrames()

int64_t AJATimeBase::Nanoseconds100ToFrames ( int64_t  nanoseconds100,
bool  round = false 
)

Convert 100 nanoseconds to video frames.

Parameters
[in]nanoseconds100100 nanosecond intervals to convert.
[in]roundRound the result.
Returns
Video frame count.

Definition at line 293 of file timebase.cpp.

◆ operator!=()

bool AJATimeBase::operator!= ( const AJATimeBase val) const

Definition at line 122 of file timebase.cpp.

◆ operator=()

AJATimeBase & AJATimeBase::operator= ( const AJATimeBase t)

Definition at line 93 of file timebase.cpp.

◆ operator==()

bool AJATimeBase::operator== ( const AJATimeBase val) const

Definition at line 106 of file timebase.cpp.

◆ SamplesToFrames()

int64_t AJATimeBase::SamplesToFrames ( int64_t  samples,
bool  round = false 
) const

Convert audio samples to video frames.

Parameters
[in]samplesAudio sample count to convert.
[in]roundRound the result.
Returns
Video frame count.

Definition at line 233 of file timebase.cpp.

◆ SamplesToMicroseconds()

int64_t AJATimeBase::SamplesToMicroseconds ( int64_t  samples,
bool  round = false 
)

Convert audio samples to time in microseconds.

Parameters
[in]samplesSample count to convert.
[in]roundRound the result.
Returns
Time in microseconds.

Definition at line 248 of file timebase.cpp.

◆ SamplesToSeconds()

double AJATimeBase::SamplesToSeconds ( int64_t  samples)

Convert audio samples to time in seconds.

Parameters
[in]samplesSample count to convert.
Returns
Time in seconds.

Definition at line 243 of file timebase.cpp.

◆ SamplesToTicks()

int64_t AJATimeBase::SamplesToTicks ( int64_t  samples,
bool  round = false 
) const

Convert audio samples to system ticks.

Parameters
[in]samplesAudio sample count to convert.
[in]roundRound the result.
Returns
System tick count.

Definition at line 238 of file timebase.cpp.

◆ ScaleUnitsToSeconds()

double AJATimeBase::ScaleUnitsToSeconds ( int64_t  num) const

Convert time scale units to time in seconds.

Parameters
[in]numTime scale units to convert.
Returns
Time in seconds.

Definition at line 202 of file timebase.cpp.

◆ SecondsToFrames()

int64_t AJATimeBase::SecondsToFrames ( double  seconds,
bool  round = false 
)

Convert time in seconds to video frames.

Parameters
[in]secondsTime in seconds.
[in]roundRound the result.
Returns
Video frame count.

Definition at line 273 of file timebase.cpp.

◆ SecondsToMicroseconds()

int64_t AJATimeBase::SecondsToMicroseconds ( double  seconds,
bool  round = false 
)
static

Convert time in seconds to microseconds.

Parameters
[in]secondsTime in seconds.
[in]roundRound the result.
Returns
Time in microseconds.

Definition at line 308 of file timebase.cpp.

◆ SecondsToSamples()

int64_t AJATimeBase::SecondsToSamples ( double  seconds,
bool  round = false 
)

Convert time in seconds to audio samples.

Parameters
[in]secondsTime in seconds.
[in]roundRound the result.
Returns
Audio sample count.

Definition at line 278 of file timebase.cpp.

◆ SecondsToTicks()

int64_t AJATimeBase::SecondsToTicks ( double  seconds,
bool  round = false 
)

Convert time in seconds to system ticks.

Parameters
[in]secondsTime in seconds.
[in]roundRound the result.
Returns
System tick count.

Definition at line 283 of file timebase.cpp.

◆ SetAJAFrameRate()

void AJATimeBase::SetAJAFrameRate ( AJA_FrameRate  ajaFrameRate)

Set the video frame rate to use in conversions.

The frame rate is specified Frame rate define found in videotypes.h

Parameters
[in]ajaFrameRateAJA_FrameRate

Definition at line 164 of file timebase.cpp.

◆ SetAudioRate()

void AJATimeBase::SetAudioRate ( int64_t  rate)

Set the audio sample rate to use in conversions.

Parameters
[in]rateAudio rate in samples/second.

Definition at line 154 of file timebase.cpp.

◆ SetFrameRate()

void AJATimeBase::SetFrameRate ( int64_t  frameTimeScale,
int64_t  frameDuration 
)

Set the video frame rate to use in conversions.

The frame rate is specified as frameTimeScale/frameDuration = frames/second.

Parameters
[in]frameTimeScaleTime units per second (units/second)
[in]frameDurationTime units per frame (units/frame)

Definition at line 127 of file timebase.cpp.

◆ SetFrameTimeScale()

void AJATimeBase::SetFrameTimeScale ( int64_t  timeScale)

Set the video frame duration used in conversions.

Parameters
[in]timeScaleTime units per second (units/second)

Definition at line 144 of file timebase.cpp.

◆ SetTickRate()

void AJATimeBase::SetTickRate ( int64_t  rate)

Set the system tick rate to use in conversions.

Parameters
[in]rateSystem tick rate in ticks/second. 0 == system native rate.

Definition at line 169 of file timebase.cpp.

◆ SetToDefault()

void AJATimeBase::SetToDefault ( void  )

Set to default value.

Definition at line 85 of file timebase.cpp.

◆ TicksToFrames()

int64_t AJATimeBase::TicksToFrames ( int64_t  ticks,
bool  round = false 
)

Convert system ticks to video frames.

Parameters
[in]ticksSystem tick count to convert.
[in]roundRound the result.
Returns
Video frame count.

Definition at line 253 of file timebase.cpp.

◆ TicksToMicroseconds()

int64_t AJATimeBase::TicksToMicroseconds ( int64_t  ticks,
bool  round = false 
)

Convert system ticks to time in microseconds.

Parameters
[in]ticksSystem tick count to convert.
[in]roundRound the result.
Returns
Time in microseconds.

Definition at line 268 of file timebase.cpp.

◆ TicksToSamples()

int64_t AJATimeBase::TicksToSamples ( int64_t  ticks,
bool  round = false 
)

Convert system ticks to audio samples.

Parameters
[in]ticksSystem tick count to convert.
[in]roundRound the result.
Returns
Audio sample count.

Definition at line 258 of file timebase.cpp.

◆ TicksToSeconds()

double AJATimeBase::TicksToSeconds ( int64_t  ticks)

Convert system ticks to time in seconds.

Parameters
[in]ticksSystem tick count to convert.
Returns
Time in seconds.

Definition at line 263 of file timebase.cpp.


The documentation for this class was generated from the following files: