Try fix reload button
This commit is contained in:
1 parent
47d0636624
commit
11b5b7aafc
4 files changed
+60
-14
No files matched your search
@@ -130,18 +130,14 @@ Void VideoSubWindow::refreshSubWindow()
|
||||
{
|
||||
if( getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW )
|
||||
{
|
||||
Int currFrameNum = m_pCurrStream->getCurrFrameNum();
|
||||
if( !loadFile( m_cFilename, false ) )
|
||||
if( !m_pCurrStream->reload() )
|
||||
{
|
||||
close();
|
||||
return;
|
||||
}
|
||||
seekAbsoluteEvent( currFrameNum );
|
||||
}
|
||||
else
|
||||
{
|
||||
refreshFrame();
|
||||
//seekAbsoluteEvent( currFrameNum );
|
||||
}
|
||||
refreshFrame();
|
||||
}
|
||||
|
||||
Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
|
||||
|
||||
@@ -44,8 +44,12 @@ PlaYUVerFrameStats::PlaYUVerFrameStats() :
|
||||
PlaYUVerFrameStats::~PlaYUVerFrameStats()
|
||||
{
|
||||
if( m_puiHistogram )
|
||||
freeMem1D( m_puiHistogram );
|
||||
{
|
||||
delete [] m_puiHistogram;
|
||||
//freeMem1D( m_puiHistogram );
|
||||
}
|
||||
m_puiHistogram = NULL;
|
||||
m_bHasHistogram = false;
|
||||
}
|
||||
|
||||
// statistics
|
||||
@@ -73,20 +77,20 @@ Void PlaYUVerFrameStats::xSetupStatistics( const PlaYUVerFrame *pcFrame, UInt op
|
||||
|
||||
Void PlaYUVerFrameStats::calcHistogram()
|
||||
{
|
||||
m_bRunningFlag = true;
|
||||
//m_bHasHistogram = false;
|
||||
if( m_bHasHistogram )
|
||||
return;
|
||||
getMem1D<UInt>( &( m_puiHistogram ), m_uiHistoSegments * histoChannels );
|
||||
|
||||
m_bHasHistogram = new UInt[m_uiHistoSegments * histoChannels];
|
||||
//getMem1D<UInt>( &( m_puiHistogram ), m_uiHistoSegments * histoChannels );
|
||||
if( !m_puiHistogram )
|
||||
{
|
||||
// qWarning( ) << "PlaYUVerFrameStats::calcHistogramValuess: "
|
||||
// "Unable to allocate memory!"
|
||||
// << endl;
|
||||
// qWarning() << "PlaYUVerFrameStats::calcHistogramValuess: "
|
||||
// "Unable to allocate memory!" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
m_bRunningFlag = true;
|
||||
|
||||
UInt i, j;
|
||||
|
||||
if( imageColorSpace == PlaYUVerFrame::COLOR_YUV )
|
||||
@@ -135,6 +139,7 @@ Void PlaYUVerFrameStats::calcHistogram()
|
||||
}
|
||||
}
|
||||
m_bHasHistogram = true;
|
||||
m_bRunningFlag = false;
|
||||
}
|
||||
|
||||
Int PlaYUVerFrameStats::getHistogramSegment()
|
||||
|
||||
@@ -384,6 +384,46 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in
|
||||
return m_bInit;
|
||||
}
|
||||
|
||||
Bool PlaYUVerStream::reload()
|
||||
{
|
||||
#ifdef USE_FFMPEG
|
||||
if( m_iStreamHandler == FFMPEG )
|
||||
{
|
||||
m_cLibAvContext->closeAvFormat();
|
||||
if( !m_cLibAvContext->initAvFormat( m_pchFilename, m_uiWidth, m_uiHeight, m_iPixelFormat, m_dFrameRate, m_uiTotalFrameNum ) )
|
||||
{
|
||||
throw "Cannot open file using FFmpeg libs";
|
||||
}
|
||||
m_cCodedName = m_cLibAvContext->getCodecName();
|
||||
}
|
||||
#endif
|
||||
if( m_iStreamHandler == YUV_IO )
|
||||
{
|
||||
closeFile();
|
||||
if( !openFile() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
UInt64 frameBytesInput = m_pcCurrFrame->getBytesPerFrame();
|
||||
fseek( m_pFile, 0, SEEK_END );
|
||||
UInt64 fileSize = ftell( m_pFile );
|
||||
m_uiTotalFrameNum = fileSize / frameBytesInput;
|
||||
fseek( m_pFile, 0, SEEK_SET );
|
||||
}
|
||||
if( m_uiWidth <= 0 || m_uiHeight <= 0 || m_iPixelFormat < 0 || m_uiTotalFrameNum < 1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( UInt( m_iCurrFrameNum ) >= m_uiTotalFrameNum )
|
||||
{
|
||||
m_iCurrFrameNum = 0;
|
||||
}
|
||||
Int currFrameNum = m_iCurrFrameNum;
|
||||
m_iCurrFrameNum = -1;
|
||||
seekInput( currFrameNum );
|
||||
return true;
|
||||
}
|
||||
|
||||
Bool PlaYUVerStream::openFile()
|
||||
{
|
||||
//m_fsIOStream.open( m_cFilename, std::ios::in | std::ios::binary )
|
||||
@@ -744,6 +784,8 @@ Bool PlaYUVerStream::seekInput( UInt64 new_frame_num )
|
||||
#endif
|
||||
if( m_iStreamHandler == YUV_IO )
|
||||
{
|
||||
if( !m_pFile )
|
||||
return false;
|
||||
UInt64 frame_bytes_input = m_ppcFrameBuffer[0]->getBytesPerFrame();
|
||||
UInt64 nbytes_seek = frame_bytes_input * new_frame_num;
|
||||
fseek( m_pFile, nbytes_seek, SEEK_SET );
|
||||
|
||||
@@ -122,6 +122,9 @@ public:
|
||||
|
||||
Bool open( std::string filename, std::string resolution, std::string input_format, UInt bitsPel, UInt frame_rate, Bool bInput = true );
|
||||
Bool open( std::string filename, UInt width, UInt height, Int input_format, UInt bitsPel, UInt frame_rate, Bool bInput = true );
|
||||
|
||||
Bool reload();
|
||||
|
||||
Void close();
|
||||
|
||||
Bool openFile();
|
||||
|
||||
Reference in new issue
Block a user