diff --git a/source/InputStream.cpp b/source/InputStream.cpp index e67064c..be2f955 100755 --- a/source/InputStream.cpp +++ b/source/InputStream.cpp @@ -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; } } diff --git a/source/InputStream.h b/source/InputStream.h index 9560171..544dc8d 100755 --- a/source/InputStream.h +++ b/source/InputStream.h @@ -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() { diff --git a/source/lib/ffmpeg/LibAvContextHandle.h b/source/lib/ffmpeg/LibAvContextHandle.h index 96e7460..4a35751 100755 --- a/source/lib/ffmpeg/LibAvContextHandle.h +++ b/source/lib/ffmpeg/LibAvContextHandle.h @@ -43,8 +43,6 @@ extern "C" #include } - - #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();