From 9b6af060c7873547a486494f83a627f022a02398 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 19 Feb 2015 13:31:16 +0000 Subject: [PATCH] Add new Char* string in PlaYUVerStream --- lib/PlaYUVerStream.cpp | 13 +++++++++++-- lib/PlaYUVerStream.h | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 008e818..96f1aae 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -174,6 +174,7 @@ PlaYUVerStream::PlaYUVerStream() m_iErrorStatus = 0; m_uiStreamHandler = 0; m_pFile = NULL; + m_pchFilename = NULL; m_uiWidth = 0; m_uiHeight = 0; m_uiTotalFrameNum = 0; @@ -215,6 +216,10 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in m_iPixelFormat = input_format; m_uiFrameRate = frame_rate; + m_pchFilename = new Char[m_cFilename.size() + 1]; + std::copy( m_cFilename.begin(), m_cFilename.end(), m_pchFilename ); + m_pchFilename[m_cFilename.size()] = '\0'; // don't forget the terminating 0 + if( m_bIsInput ) { m_iFileFormat = INVALID_HANDLER; @@ -267,7 +272,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in #ifdef USE_FFMPEG if( m_uiStreamHandler == FFMPEG ) { - if( !m_cLibAvContext->initAvFormat( m_cFilename.c_str(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate, m_uiTotalFrameNum ) ) + if( !m_cLibAvContext->initAvFormat( m_pchFilename, m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate, m_uiTotalFrameNum ) ) { throw "Cannot open file using FFmpeg libs"; } @@ -355,8 +360,9 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in Bool PlaYUVerStream::openFile() { + //m_fsIOStream.open( m_cFilename, std::ios::in | std::ios::binary ) m_pFile = NULL; - m_pFile = fopen( m_cFilename.c_str(), m_bIsInput ? "rb" : "wb" ); + m_pFile = fopen( m_pchFilename, m_bIsInput ? "rb" : "wb" ); if( m_pFile == NULL ) { return false; @@ -400,6 +406,9 @@ Void PlaYUVerStream::close() if( m_pStreamBuffer ) freeMem1D( m_pStreamBuffer ); + if( m_pchFilename ) + delete [] m_pchFilename; + m_bLoadAll = false; m_bInit = false; } diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index 5dfc5dc..968fd67 100644 --- a/lib/PlaYUVerStream.h +++ b/lib/PlaYUVerStream.h @@ -27,6 +27,7 @@ #include "PlaYUVerDefs.h" #include +#include #include #include #include "PlaYUVerFrame.h" @@ -65,12 +66,16 @@ private: LibAvContextHandle* m_cLibAvContext; std::string m_cFilename; + Char* m_pchFilename; + std::string m_cFormatName; std::string m_cCodedName; std::string m_cPelFmtName; FILE* m_pFile; /**< The input file pointer >*/ + std::fstream m_fsIOStream; /**< The input file pointer >*/ + Int m_iFileFormat; Int m_iPixelFormat;