Try fix reload button
This commit is contained in:
@@ -130,18 +130,14 @@ Void VideoSubWindow::refreshSubWindow()
|
|||||||
{
|
{
|
||||||
if( getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW )
|
if( getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW )
|
||||||
{
|
{
|
||||||
Int currFrameNum = m_pCurrStream->getCurrFrameNum();
|
if( !m_pCurrStream->reload() )
|
||||||
if( !loadFile( m_cFilename, false ) )
|
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
seekAbsoluteEvent( currFrameNum );
|
//seekAbsoluteEvent( currFrameNum );
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
refreshFrame();
|
|
||||||
}
|
}
|
||||||
|
refreshFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
|
Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
|
||||||
|
|||||||
@@ -44,8 +44,12 @@ PlaYUVerFrameStats::PlaYUVerFrameStats() :
|
|||||||
PlaYUVerFrameStats::~PlaYUVerFrameStats()
|
PlaYUVerFrameStats::~PlaYUVerFrameStats()
|
||||||
{
|
{
|
||||||
if( m_puiHistogram )
|
if( m_puiHistogram )
|
||||||
freeMem1D( m_puiHistogram );
|
{
|
||||||
|
delete [] m_puiHistogram;
|
||||||
|
//freeMem1D( m_puiHistogram );
|
||||||
|
}
|
||||||
m_puiHistogram = NULL;
|
m_puiHistogram = NULL;
|
||||||
|
m_bHasHistogram = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// statistics
|
// statistics
|
||||||
@@ -73,20 +77,20 @@ Void PlaYUVerFrameStats::xSetupStatistics( const PlaYUVerFrame *pcFrame, UInt op
|
|||||||
|
|
||||||
Void PlaYUVerFrameStats::calcHistogram()
|
Void PlaYUVerFrameStats::calcHistogram()
|
||||||
{
|
{
|
||||||
m_bRunningFlag = true;
|
|
||||||
//m_bHasHistogram = false;
|
|
||||||
if( m_bHasHistogram )
|
if( m_bHasHistogram )
|
||||||
return;
|
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 )
|
if( !m_puiHistogram )
|
||||||
{
|
{
|
||||||
// qWarning( ) << "PlaYUVerFrameStats::calcHistogramValuess: "
|
// qWarning() << "PlaYUVerFrameStats::calcHistogramValuess: "
|
||||||
// "Unable to allocate memory!"
|
// "Unable to allocate memory!" << endl;
|
||||||
// << endl;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_bRunningFlag = true;
|
||||||
|
|
||||||
UInt i, j;
|
UInt i, j;
|
||||||
|
|
||||||
if( imageColorSpace == PlaYUVerFrame::COLOR_YUV )
|
if( imageColorSpace == PlaYUVerFrame::COLOR_YUV )
|
||||||
@@ -135,6 +139,7 @@ Void PlaYUVerFrameStats::calcHistogram()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_bHasHistogram = true;
|
m_bHasHistogram = true;
|
||||||
|
m_bRunningFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Int PlaYUVerFrameStats::getHistogramSegment()
|
Int PlaYUVerFrameStats::getHistogramSegment()
|
||||||
|
|||||||
@@ -384,6 +384,46 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in
|
|||||||
return m_bInit;
|
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()
|
Bool PlaYUVerStream::openFile()
|
||||||
{
|
{
|
||||||
//m_fsIOStream.open( m_cFilename, std::ios::in | std::ios::binary )
|
//m_fsIOStream.open( m_cFilename, std::ios::in | std::ios::binary )
|
||||||
@@ -744,6 +784,8 @@ Bool PlaYUVerStream::seekInput( UInt64 new_frame_num )
|
|||||||
#endif
|
#endif
|
||||||
if( m_iStreamHandler == YUV_IO )
|
if( m_iStreamHandler == YUV_IO )
|
||||||
{
|
{
|
||||||
|
if( !m_pFile )
|
||||||
|
return false;
|
||||||
UInt64 frame_bytes_input = m_ppcFrameBuffer[0]->getBytesPerFrame();
|
UInt64 frame_bytes_input = m_ppcFrameBuffer[0]->getBytesPerFrame();
|
||||||
UInt64 nbytes_seek = frame_bytes_input * new_frame_num;
|
UInt64 nbytes_seek = frame_bytes_input * new_frame_num;
|
||||||
fseek( m_pFile, nbytes_seek, SEEK_SET );
|
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, 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 open( std::string filename, UInt width, UInt height, Int input_format, UInt bitsPel, UInt frame_rate, Bool bInput = true );
|
||||||
|
|
||||||
|
Bool reload();
|
||||||
|
|
||||||
Void close();
|
Void close();
|
||||||
|
|
||||||
Bool openFile();
|
Bool openFile();
|
||||||
|
|||||||
Reference in New Issue
Block a user