From de9bbb26fd65914a7e5562fb58917f93bec174fe Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 10 Mar 2017 02:32:49 +0100 Subject: [PATCH] ATV Modulator: corected end of file condition check and reset of FPS counters --- plugins/channeltx/modatv/atvmod.cpp | 15 ++++++++++++--- plugins/channeltx/modatv/atvmod.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/channeltx/modatv/atvmod.cpp b/plugins/channeltx/modatv/atvmod.cpp index be671d8cc..2c20413ee 100644 --- a/plugins/channeltx/modatv/atvmod.cpp +++ b/plugins/channeltx/modatv/atvmod.cpp @@ -45,6 +45,7 @@ ATVMod::ATVMod() : m_videoFPSq(1.0f), m_videoFPSCount(0.0f), m_videoPrevFPSCount(0), + m_videoEOF(false), m_videoOK(false) { setObjectName("ATVMod"); @@ -194,7 +195,7 @@ void ATVMod::pullVideo(Real& sample) m_lineCount = 0; m_evenImage = !m_evenImage; - if ((m_running.m_atvModInput == ATVModInputVideo) && m_videoOK && (m_running.m_videoPlay)) + if ((m_running.m_atvModInput == ATVModInputVideo) && m_videoOK && (m_running.m_videoPlay) && !m_videoEOF) { int grabOK; int fpsIncrement = (int) m_videoFPSCount - m_videoPrevFPSCount; @@ -221,9 +222,10 @@ void ATVMod::pullVideo(Real& sample) } else { - if (m_running.m_videoPlayLoop) // play loop - { + if (m_running.m_videoPlayLoop) { // play loop seekVideoFileStream(0); + } else { // stops + m_videoEOF = true; } } @@ -511,7 +513,9 @@ void ATVMod::openVideo(const QString& fileName) m_videoHeight, m_videoLength, ext); + calculateVideoSizes(); + m_videoEOF = false; MsgReportVideoFileSourceStreamData *report; report = MsgReportVideoFileSourceStreamData::create(m_videoFPS, m_videoLength); @@ -536,6 +540,8 @@ void ATVMod::calculateVideoSizes() m_videoFy = (m_nbImageLines - 2*m_nbBlankLines) / (float) m_videoHeight; m_videoFx = m_pointsPerImgLine / (float) m_videoWidth; m_videoFPSq = m_videoFPS / m_fps; + m_videoFPSCount = m_videoFPSq; + m_videoPrevFPSCount = 0; qDebug("ATVMod::resizeVideo: factors: %f x %f FPSq: %f", m_videoFx, m_videoFy, m_videoFPSq); } @@ -555,6 +561,9 @@ void ATVMod::seekVideoFileStream(int seekPercentage) { int seekPoint = ((m_videoLength * seekPercentage) / 100); m_video.set(CV_CAP_PROP_POS_FRAMES, seekPoint); + m_videoFPSCount = m_videoFPSq; + m_videoPrevFPSCount = 0; + m_videoEOF = false; } } diff --git a/plugins/channeltx/modatv/atvmod.h b/plugins/channeltx/modatv/atvmod.h index 2d3f1c3ba..733bc0c2f 100644 --- a/plugins/channeltx/modatv/atvmod.h +++ b/plugins/channeltx/modatv/atvmod.h @@ -358,6 +358,7 @@ private: float m_videoFPSCount; //!< current video FPS fractional counter int m_videoPrevFPSCount; //!< current video FPS previous integer counter int m_videoLength; //!< current video length in frames + bool m_videoEOF; //!< current video has reached end of file bool m_videoOK; static const float m_blackLevel;