7 changes: 5 additions & 2 deletions mythtv/libs/libmythtv/recorders/dtvrecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,12 @@ class DTVRecorder :
mutable QAtomicInt _continuity_error_count;
unsigned long long _frames_seen_count;
unsigned long long _frames_written_count;
double _frame_interval; // usec
double _frame_duration; // usec
double _total_duration; // usec
// Calculate _total_duration as
// _td_base + (_td_tick_count * _td_tick_framerate / 2)
double _td_base;
uint64_t _td_tick_count;
FrameRate _td_tick_framerate;

// constants
/// If the number of regular frames detected since the last
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/recorders/recorderbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RecorderBase::RecorderBase(TVRec *rec)
ntsc(true), ntsc_framerate(true),
video_frame_rate(29.97),
m_videoAspect(0), m_videoHeight(0),
m_videoWidth(0), m_frameRate(0.0),
m_videoWidth(0), m_frameRate(0),
curRecording(NULL),
request_pause(false), paused(false),
request_recording(false), recording(false),
Expand Down Expand Up @@ -353,7 +353,7 @@ void RecorderBase::CheckForRingBufferSwitch(void)
ResetForNewFile();

m_videoAspect = m_videoWidth = m_videoHeight = 0;
m_frameRate = 0.0;
m_frameRate = FrameRate(0);

SetRingBuffer(nextRingBuffer);
SetRecording(nextRecording);
Expand Down
22 changes: 20 additions & 2 deletions mythtv/libs/libmythtv/recorders/recorderbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ class ChannelBase;
class RingBuffer;
class TVRec;

class FrameRate
{
public:
FrameRate(uint n, uint d=1) : num(n), den(d) {}
double toDouble(void) const { return num / (double)den; }
bool isNonzero(void) const { return num; }
uint getNum(void) const { return num; }
uint getDen(void) const { return den; }
QString toString(void) const { return QString("%1/%2").arg(num).arg(den); }
bool operator==(const FrameRate &other) {
return num == other.num && den == other.den;
}
bool operator!=(const FrameRate &other) { return !(*this == other); }
private:
uint num;
uint den;
};

/** \class RecorderBase
* \brief This is the abstract base class for supporting
* recorder hardware.
Expand Down Expand Up @@ -191,7 +209,7 @@ class MTV_PUBLIC RecorderBase : public QRunnable

/** \brief Returns the latest frame rate.
*/
double GetFrameRate(void) { return m_frameRate / 1000; }
double GetFrameRate(void) const { return m_frameRate.toDouble(); }

/** \brief If requested, switch to new RingBuffer/ProgramInfo objects
*/
Expand Down Expand Up @@ -272,7 +290,7 @@ class MTV_PUBLIC RecorderBase : public QRunnable

uint m_videoHeight;
uint m_videoWidth;
double m_frameRate;
FrameRate m_frameRate;

RecordingInfo *curRecording;

Expand Down