Skip to content

Commit

Permalink
Fix the counting of frames played.
Browse files Browse the repository at this point in the history
DisplayNormalFrame() doesn't always process a frame but VideoLoop()
unconditionally increments the frames played counter every time.  This
leads to inflated counts.  Fix the problem by returning an indication
that a frame was processed and only increment the count when it is
set.

(cherry picked from commit c032b28)
  • Loading branch information
gigem committed Feb 22, 2022
1 parent dfc8d07 commit d1efdd4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions mythtv/libs/libmythtv/mythplayerui.cpp
Expand Up @@ -477,15 +477,17 @@ bool MythPlayerUI::VideoLoop()

if (m_videoPaused || m_isDummy)
DisplayPauseFrame();
else
DisplayNormalFrame();

if (FlagIsSet(kVideoIsNull) && m_decoder)
m_decoder->UpdateFramesPlayed();
else if (m_decoder && m_decoder->GetEof() != kEofStateNone)
++m_framesPlayed;
else
m_framesPlayed = static_cast<uint64_t>(m_videoOutput->GetFramesPlayed());
else if (DisplayNormalFrame())
{
if (FlagIsSet(kVideoIsNull) && m_decoder)
m_decoder->UpdateFramesPlayed();
else if (m_decoder && m_decoder->GetEof() != kEofStateNone)
++m_framesPlayed;
else
m_framesPlayed = static_cast<uint64_t>(
m_videoOutput->GetFramesPlayed());
}

return !IsErrored();
}

Expand Down Expand Up @@ -641,13 +643,13 @@ void MythPlayerUI::DisplayPauseFrame()
RenderVideoFrame(nullptr, scan, true, 0ms);
}

void MythPlayerUI::DisplayNormalFrame(bool CheckPrebuffer)
bool MythPlayerUI::DisplayNormalFrame(bool CheckPrebuffer)
{
if (m_allPaused)
return;
return false;

if (CheckPrebuffer && !PrebufferEnoughFrames())
return;
return false;

// clear the buffering state
SetBuffering(false);
Expand Down Expand Up @@ -688,6 +690,8 @@ void MythPlayerUI::DisplayNormalFrame(bool CheckPrebuffer)
DoDisplayVideoFrame(frame, due);
m_videoOutput->DoneDisplayingFrame(frame);
m_outputJmeter.RecordCycleTime();

return true;
}

void MythPlayerUI::SetVideoParams(int Width, int Height, double FrameRate, float Aspect,
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mythplayerui.h
Expand Up @@ -45,7 +45,7 @@ class MTV_PUBLIC MythPlayerUI : public MythPlayerEditorUI, public MythVideoScanT
protected:
void InitFrameInterval() override;
virtual void DisplayPauseFrame();
virtual void DisplayNormalFrame(bool CheckPrebuffer = true);
virtual bool DisplayNormalFrame(bool CheckPrebuffer = true);

void FileChanged();
void RefreshPauseFrame();
Expand Down

0 comments on commit d1efdd4

Please sign in to comment.