Init LibAvContextHandle flags. fix current frame number variable. Add disconnect function when stop is clicked

This commit is contained in:
2014-02-08 01:02:48 +00:00
parent 3ee9a4b277
commit fcef6e09c4
3 changed files with 20 additions and 18 deletions
+13 -13
View File
@@ -39,7 +39,7 @@ InputStream::InputStream()
m_uiWidth = 0;
m_uiHeight = 0;
m_uiTotalFrameNum = 0;
m_uiCurrFrameNum = 0;
m_iCurrFrameNum = -1;
m_iErrorStatus = 0;
m_iPixelFormat = -1;
@@ -137,9 +137,12 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for
m_cStreamInformationString = QString( "[" );
#ifdef USE_FFMPEG
avStatus = m_cLibAvContext.initAvFormat( m_cFilename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate );
m_cStreamInformationString.append( QString::fromUtf8( m_cLibAvContext.getStreamInformation() ) );
m_uiTotalFrameNum = 100;
if( QFileInfo( filename ).completeSuffix().compare( QString( "yuv" ) ) )
{
avStatus = m_cLibAvContext.initAvFormat( m_cFilename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate );
m_cStreamInformationString.append( QString::fromUtf8( m_cLibAvContext.getStreamInformation() ) );
m_uiTotalFrameNum = 100;
}
#endif
if( m_uiWidth <= 0 || m_uiHeight <= 0 )
@@ -181,7 +184,7 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for
m_cStreamInformationString.append( QFileInfo( m_cFilename ).fileName() );
m_uiCurrFrameNum = 0;
m_iCurrFrameNum = -1;
m_iStatus = 1;
return;
@@ -208,15 +211,12 @@ Void InputStream::readFrame()
return;
}
if( m_uiCurrFrameNum < m_uiTotalFrameNum )
{
m_uiCurrFrameNum++;
}
else
m_iCurrFrameNum++;
if( m_iCurrFrameNum >= m_uiTotalFrameNum )
{
m_iErrorStatus = END_OF_SEQ;
m_uiCurrFrameNum = 0;
seekInput( m_uiCurrFrameNum );
m_iCurrFrameNum = 0;
seekInput( m_iCurrFrameNum );
}
#ifdef USE_FFMPEG
@@ -292,7 +292,7 @@ Void InputStream::seekInput( Int new_frame_num )
UInt64 frame_bytes_input = m_uiWidth * m_uiHeight * 1.5;
UInt64 nbytes_seek = frame_bytes_input * new_frame_num;
fseek( m_pFile, nbytes_seek, SEEK_SET );
m_uiCurrFrameNum = new_frame_num;
m_iCurrFrameNum = new_frame_num;
}
}
+3 -3
View File
@@ -78,7 +78,7 @@ private:
UInt m_uiHeight;
UInt m_uiFrameRate;
UInt m_uiTotalFrameNum;
UInt m_uiCurrFrameNum;
Int m_iCurrFrameNum;
public:
InputStream();
@@ -136,9 +136,9 @@ public:
{
return m_uiHeight;
}
UInt getCurrFrameNum()
Int getCurrFrameNum()
{
return m_uiCurrFrameNum;
return m_iCurrFrameNum;
}
UInt getFrameRate()
{
+4 -2
View File
@@ -43,8 +43,6 @@ extern "C"
#include <libavformat/avformat.h>
}
#include "TypeDef.h"
namespace plaYUVer
@@ -53,6 +51,10 @@ namespace plaYUVer
class LibAvContextHandle
{
public:
LibAvContextHandle() :
m_bHasStream( false )
{
}
Bool initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate );
Void closeAvFormat();
Bool decodeAvFormat();