Separate the open and close code from the main functions
This commit is contained in:
1 parent
de5ee3290a
commit
1edb0fe1af
2 files changed
+41
-8
No files matched your search
@@ -38,6 +38,7 @@ PlaYUVerStream::PlaYUVerStream()
|
||||
{
|
||||
m_bInit = false;
|
||||
m_bIsInput = true;
|
||||
m_bIsOpened = false;
|
||||
m_bLoadAll = false;
|
||||
m_iErrorStatus = 0;
|
||||
|
||||
@@ -151,14 +152,20 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
|
||||
|
||||
UInt64 frame_bytes_input = m_pcCurrFrame->getBytesPerFrame();
|
||||
|
||||
if( !avStatus )
|
||||
{
|
||||
if( !openFile() )
|
||||
{
|
||||
close();
|
||||
return m_bInit;
|
||||
}
|
||||
m_cFormatName = QString::fromUtf8( "YUV" );
|
||||
m_cCodedName = QString::fromUtf8( "Raw Video" );
|
||||
}
|
||||
|
||||
if( !avStatus && m_iFileFormat == YUVINPUT )
|
||||
{
|
||||
m_pFile = NULL;
|
||||
Char *filename = new char[m_cFilename.length() + 1];
|
||||
memcpy( filename, m_cFilename.toUtf8().constData(), m_cFilename.length() + 1 * sizeof(char) );
|
||||
m_pFile = fopen( filename, m_bIsInput ? "rb" : "wb" );
|
||||
delete[] filename;
|
||||
if( m_pFile == NULL )
|
||||
if( !openFile() )
|
||||
{
|
||||
close();
|
||||
return m_bInit;
|
||||
@@ -218,13 +225,34 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
|
||||
return m_bInit;
|
||||
}
|
||||
|
||||
Bool PlaYUVerStream::openFile()
|
||||
{
|
||||
m_pFile = NULL;
|
||||
Char *filename = new char[m_cFilename.length() + 1];
|
||||
memcpy( filename, m_cFilename.toUtf8().constData(), m_cFilename.length() + 1 * sizeof(char) );
|
||||
m_pFile = fopen( filename, m_bIsInput ? "rb" : "wb" );
|
||||
delete[] filename;
|
||||
if( m_pFile == NULL )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
fseek( m_pFile, m_iCurrFrameNum >= 0 ? m_iCurrFrameNum : 0, SEEK_SET );
|
||||
return true;
|
||||
}
|
||||
|
||||
Void PlaYUVerStream::closeFile()
|
||||
{
|
||||
if( !m_bInit && m_pFile )
|
||||
return;
|
||||
fclose( m_pFile );
|
||||
}
|
||||
|
||||
Void PlaYUVerStream::close()
|
||||
{
|
||||
if( !m_bInit )
|
||||
return;
|
||||
|
||||
if( m_pFile )
|
||||
fclose( m_pFile );
|
||||
closeFile();
|
||||
|
||||
#ifdef USE_FFMPEG
|
||||
m_cLibAvContext->closeAvFormat();
|
||||
|
||||
@@ -42,6 +42,8 @@ private:
|
||||
|
||||
Bool m_bInit;
|
||||
Bool m_bIsInput;
|
||||
Bool m_bIsOpened;
|
||||
|
||||
Bool m_bLoadAll;
|
||||
Int m_iErrorStatus;
|
||||
|
||||
@@ -216,6 +218,9 @@ public:
|
||||
Bool open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput = true );
|
||||
Void close();
|
||||
|
||||
Bool openFile();
|
||||
Void closeFile();
|
||||
|
||||
static Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
|
||||
|
||||
Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
|
||||
|
||||
Reference in new issue
Block a user