From 5b7f931b83644da0f3b1df3ea99c14854a9ca728 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 14 Jun 2014 21:11:18 +0100 Subject: [PATCH] Merge with master --- source/app/InputStream.cpp | 8 +++---- source/app/InputStream.h | 2 +- source/app/plaYUVerApp.cpp | 49 ++++++++++++++++++++++++++------------ source/app/plaYUVerApp.h | 4 ++-- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/source/app/InputStream.cpp b/source/app/InputStream.cpp index 0559ea1..039a3fd 100755 --- a/source/app/InputStream.cpp +++ b/source/app/InputStream.cpp @@ -194,6 +194,7 @@ Bool InputStream::open( QString filename, UInt width, UInt height, Int input_for m_cStreamInformationString.append( "] " ); m_cStreamInformationString.append( QFileInfo( m_cFilename ).fileName() ); + m_iCurrFrameNum = -1; seekInput( 0 ); //loadAll(); @@ -359,7 +360,7 @@ Void InputStream::readNextFrame() UInt64 bytes_read = 0; //m_cTimer.restart(); - if( m_iCurrFrameNum + 1 >= ( Int )m_uiTotalFrameNum ) + if( m_iCurrFrameNum + 1 >= (Int64)m_uiTotalFrameNum ) { m_iErrorStatus = LAST_FRAME; m_pcNextFrame = NULL; @@ -419,8 +420,7 @@ Void InputStream::setNextFrame() else { m_iErrorStatus = END_OF_SEQ; - m_iCurrFrameNum = 0; - seekInput( m_iCurrFrameNum ); + seekInput( 0 ); } } @@ -440,7 +440,7 @@ PlaYUVerFrame* InputStream::getCurrFrame() Void InputStream::seekInput( UInt64 new_frame_num ) { - if( !m_pFile || new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum) + if( !m_pFile || new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum || (Int64)new_frame_num == m_iCurrFrameNum ) return; m_iCurrFrameNum = new_frame_num - 1; diff --git a/source/app/InputStream.h b/source/app/InputStream.h index 031a9c1..02325cd 100755 --- a/source/app/InputStream.h +++ b/source/app/InputStream.h @@ -79,7 +79,7 @@ private: UInt m_uiHeight; UInt m_uiFrameRate; UInt64 m_uiTotalFrameNum; - Int m_iCurrFrameNum; + Int64 m_iCurrFrameNum; public: InputStream(); diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 4e9ae91..6a9580e 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -103,10 +103,10 @@ Void plaYUVerApp::about() { QString about_message; about_message.append( "The plaYUVer is an open-source raw video player! " ); - about_message.append("Developed by "); - about_message.append("João Carreira "); - about_message.append("and "); - about_message.append("Luís Lucas"); + about_message.append( "Developed by " ); + about_message.append( "João Carreira " ); + about_message.append( "and " ); + about_message.append( "Luís Lucas" ); QMessageBox::about( this, "About plaYUVer", about_message ); } @@ -316,15 +316,25 @@ Void plaYUVerApp::updatePropertiesSelectedArea( QRect area ) // ----------------------- Playing Functions -------------------- -UInt plaYUVerApp::getMaxFrameNumber() +UInt64 plaYUVerApp::getMaxFrameNumber() { UInt currFrames; - UInt maxFrames = INT_MAX; - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + UInt64 maxFrames = INT_MAX; + if( m_pcCurrentSubWindow ) { - currFrames = m_acPlayingSubWindows.at( i )->getInputStream()->getFrameNum(); - if( currFrames < maxFrames ) - maxFrames = currFrames; + if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) + { + for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + { + currFrames = m_acPlayingSubWindows.at( i )->getInputStream()->getFrameNum(); + if( currFrames < maxFrames ) + maxFrames = currFrames; + } + } + else + { + maxFrames = m_pcCurrentSubWindow->getInputStream()->getFrameNum(); + } } return maxFrames; } @@ -385,7 +395,7 @@ Void plaYUVerApp::play() { m_acPlayingSubWindows.append( m_pcCurrentSubWindow ); m_pcCurrentSubWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() ); - m_pcFrameSlider->setMaximum( getMaxFrameNumber() - 1 ); + updateTotalFrameNum(); } m_pcCurrentSubWindow->play(); } @@ -447,6 +457,7 @@ Void plaYUVerApp::stop() seekSliderEvent( 0 ); } } + updateTotalFrameNum(); } Void plaYUVerApp::playEvent() @@ -468,6 +479,13 @@ Void plaYUVerApp::playEvent() updateFrameProperties(); return; } + else + { + for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + { + m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( 0 ); + } + } break; case -3: m_acPlayingSubWindows.at( i )->close(); @@ -498,11 +516,12 @@ Void plaYUVerApp::updateCurrFrameNum() m_pcCurrFrameNumLabel->setText( "1" ); } } -Void plaYUVerApp::updateTotalFrameNum( UInt total_frame_num ) +Void plaYUVerApp::updateTotalFrameNum() { - if( m_pcCurrentSubWindow && m_pcCurrentSubWindow->getInputStream() && total_frame_num == 1 ) + UInt64 total_frame_num = 1; + if( m_pcCurrentSubWindow && m_pcCurrentSubWindow->getInputStream() ) { - total_frame_num = m_pcCurrentSubWindow->getInputStream()->getFrameNum(); + total_frame_num = getMaxFrameNumber(); } m_pcFrameSlider->setMaximum( total_frame_num - 1 ); m_pcTotalFrameNumLabel->setText( QString( tr( "%1" ) ).arg( total_frame_num ) ); @@ -1151,7 +1170,7 @@ Void plaYUVerApp::writeSettings() settings.setMainWindowPos( pos() ); settings.setMainWindowSize( size() ); settings.setLastOpenPath( m_cLastOpenPath ); - settings.setSelectedTool( (Int)m_appTool ); + settings.setSelectedTool( ( Int )m_appTool ); settings.setPlayingSettings( m_arrayActions[VIDEO_LOOP_ACT]->isChecked(), m_arrayActions[VIDEO_LOCK_ACT]->isChecked() ); } diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index d7f5236..b8d5f4f 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -122,11 +122,11 @@ private: Void zoomToFitAll(); //! Playing functions - UInt getMaxFrameNumber(); + UInt64 getMaxFrameNumber(); Void startPlay(); Void setTimerStatus(); Void updateCurrFrameNum(); - Void updateTotalFrameNum( UInt total_frame_num = 1 ); + Void updateTotalFrameNum(); Void updateMenus(); Void updateStreamProperties();