From a3d51d4e35d151b5636431537035fbc16e90b607 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 22 Jul 2014 15:28:14 +0100 Subject: [PATCH] Check if frame number is less than one and add some debug outputs --- source/lib/PlaYUVerStream.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/lib/PlaYUVerStream.cpp b/source/lib/PlaYUVerStream.cpp index b3e4b58..19cf2e7 100644 --- a/source/lib/PlaYUVerStream.cpp +++ b/source/lib/PlaYUVerStream.cpp @@ -130,6 +130,7 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ if( m_uiWidth <= 0 || m_uiHeight <= 0 || m_iPixelFormat < 0 ) { + qDebug( ) << "Incorrect configuration"; close(); return m_bInit; } @@ -140,6 +141,7 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); if( !m_ppcFrameBuffer[i] ) { + qDebug( ) << "Cannot allocated frame buffer"; close(); return m_bInit; } @@ -164,7 +166,17 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ if( m_bIsInput ) { fseek( m_pFile, 0, SEEK_END ); - m_uiTotalFrameNum = ftell( m_pFile ) / ( frame_bytes_input ); + UInt64 fileSize = ftell( m_pFile ); +#if 0 + if( fileSize % frame_bytes_input ) + { + Int remaining = fileSize % frame_bytes_input; + qDebug( ) << "Incorrect configuration: failed ( fileSize % frame_bytes_input = " << remaining << " )" ; + close(); + return m_bInit; + } +#endif + m_uiTotalFrameNum = fileSize / frame_bytes_input; fseek( m_pFile, 0, SEEK_SET ); } m_cFormatName = QString::fromUtf8( "YUV" ); @@ -173,6 +185,7 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ if( m_bIsInput && m_uiTotalFrameNum <= 0 ) { + qDebug( ) << "Incorrect configuration: less than one frame"; close(); return m_bInit; }