diff --git a/source/app/InputStream.cpp b/source/app/InputStream.cpp index ebc10d3..9a6c83a 100755 --- a/source/app/InputStream.cpp +++ b/source/app/InputStream.cpp @@ -191,6 +191,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 ); m_cTimer.start(); @@ -319,7 +320,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; @@ -370,8 +371,7 @@ Void InputStream::setNextFrame() else { m_iErrorStatus = END_OF_SEQ; - m_iCurrFrameNum = 0; - seekInput( m_iCurrFrameNum ); + seekInput( 0 ); } } @@ -393,7 +393,7 @@ Void InputStream::seekInput( UInt64 new_frame_num ) { if( !m_pFile ) return; - if( new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum ) + if( new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum || (Int64)new_frame_num == m_iCurrFrameNum ) return; #ifdef USE_FFMPEG if( m_cLibAvContext.getStatus() ) diff --git a/source/app/InputStream.h b/source/app/InputStream.h index 721f99e..24bb5a2 100755 --- a/source/app/InputStream.h +++ b/source/app/InputStream.h @@ -78,7 +78,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 1e18254..c3cdb20 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 ); } @@ -305,15 +305,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; } @@ -374,7 +384,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(); } @@ -436,6 +446,7 @@ Void plaYUVerApp::stop() seekSliderEvent( 0 ); } } + updateTotalFrameNum(); } Void plaYUVerApp::playEvent() @@ -457,6 +468,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(); @@ -487,11 +505,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 ) ); @@ -1133,7 +1152,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 e61aa0c..d2a4aed 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -121,11 +121,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();