diff --git a/source/app/InputStream.cpp b/source/app/InputStream.cpp index 60ccfd3..34dd57c 100755 --- a/source/app/InputStream.cpp +++ b/source/app/InputStream.cpp @@ -307,7 +307,7 @@ Void InputStream::readNextFrame() } #endif - UInt64 frame_bytes_input = m_ppcFrameBuffer[0]->getBytesPerFrame(); + UInt64 frame_bytes_input = m_pcNextFrame->getBytesPerFrame(); bytes_read = fread( m_pInputBuffer, sizeof(Pel), frame_bytes_input, m_pFile ); if( bytes_read != frame_bytes_input ) { diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index a554572..7312533 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -220,11 +220,14 @@ void plaYUVerApp::updateProperties() void plaYUVerApp::play() { playingTimer->stop(); - if( activeSubWindow() ) + m_uiAveragePlayInterval = 0; + if( m_pcCurrentSubWindow ) { UInt frameRate = activeSubWindow()->getInputStream()->getFrameRate(); UInt timeInterval = ( UInt )( 1000.0 / frameRate + 0.5 ); + qDebug() << "Desired frame rate: " << QString::number( 1000 / timeInterval ) << " fps"; playingTimer->start( timeInterval ); + m_cTimer.start(); } } @@ -235,23 +238,33 @@ void plaYUVerApp::pause() void plaYUVerApp::stop() { - activeSubWindow()->stopEvent(); - m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() ); - playingTimer->stop(); + if( m_pcCurrentSubWindow ) + { + m_pcCurrentSubWindow->stopEvent(); + m_pcFrameSlider->setValue( m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum() ); + playingTimer->stop(); + if( m_uiAveragePlayInterval ) + qDebug() << "Real display time: " << QString::number( 1000 / m_uiAveragePlayInterval ) << " fps"; + m_uiAveragePlayInterval = 0; + } } void plaYUVerApp::playEvent() { - if( activeSubWindow() ) + //m_cTimer.restart(); + if( m_pcCurrentSubWindow ) { - if( !activeSubWindow()->playEvent() ) + UInt time = m_cTimer.elapsed(); + m_cTimer.restart(); + m_uiAveragePlayInterval = ( m_uiAveragePlayInterval + time) / 2; + if( !m_pcCurrentSubWindow->playEvent() ) { if( !actionVideoLoop->isChecked() ) { stop(); } } - m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() ); + m_pcFrameSlider->setValue( m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum() ); } } diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index 43ee08a..a1f95d2 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -103,6 +103,8 @@ private: QString m_cLastOpenPath; QTimer *playingTimer; + QTime m_cTimer; + UInt m_uiAveragePlayInterval; Void updateMenus(); Void updateProperties();