Stop playing when reaches the end of file

This commit is contained in:
2014-02-02 18:01:05 +00:00
parent 5d540fe1b8
commit a65b47f8a3
3 changed files with 25 additions and 3 deletions
+19 -2
View File
@@ -145,7 +145,7 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for
m_cCurrFrame = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat );
UInt64 frame_bytes_input = m_uiWidth * m_uiHeight * 1.5;
UInt64 frame_bytes_input = m_cCurrFrame->getBytesPerFrame();
if( m_iFileFormat == YUVFormat )
{
@@ -157,8 +157,8 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for
return;
}
fseek( m_pFile, 0, SEEK_END );
fseek( m_pFile, 0, SEEK_SET );
m_uiTotalFrameNum = ftell( m_pFile ) / ( frame_bytes_input );
fseek( m_pFile, 0, SEEK_SET );
}
if( !get_mem1Dpel( &m_pInputBuffer, m_cCurrFrame->getBytesPerFrame() ) )
@@ -167,6 +167,8 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for
return;
}
m_uiCurrFrameNum = 0;
m_iStatus = 1;
return;
@@ -191,6 +193,16 @@ Void InputStream::readFrame()
}
#endif
if( m_uiCurrFrameNum < m_uiTotalFrameNum )
{
m_uiCurrFrameNum++;
}
else
{
m_iErrorStatus = END_OF_SEQ;
m_uiCurrFrameNum = 0;
seekInput( m_uiCurrFrameNum );
}
bytes_read = fread( m_pInputBuffer, sizeof(Pel), frame_bytes_input, m_pFile );
if( bytes_read != frame_bytes_input )
{
@@ -251,6 +263,11 @@ Void InputStream::seekInput( Int new_frame_num )
Bool InputStream::checkErrors( Int error_type )
{
if( m_iErrorStatus == error_type )
{
m_iErrorStatus = NO_ERROR;
return true;
}
if( m_iErrorStatus == error_type )
{
m_iErrorStatus = NO_ERROR;
+1 -1
View File
@@ -45,7 +45,7 @@ namespace plaYUVer
enum InputStream_Errors
{
NO_ERROR = 0, READING = 1,
NO_ERROR = 0, READING = 1, END_OF_SEQ = 2,
};
class InputStream
+5
View File
@@ -137,6 +137,11 @@ bool SubWindowHandle::playEvent()
QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot read %1." ).arg( m_cCurrFileName ) );
return false;
}
else if( m_currStream.checkErrors( END_OF_SEQ ) )
{
m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) );
return false;
}
m_cViewArea->setImage( QPixmap::fromImage( m_currStream.getFrameQImage() ) );
return true;
}