From de1606e30252e53dcc00881715cf583ad67a5ba6 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 6 Apr 2015 00:45:02 +0100 Subject: [PATCH] Fix frame to ARGB from GRAY when bpp is different than 8 --- lib/PlaYUVerFrame.cpp | 2 +- lib/PlaYUVerStream.cpp | 8 ++++++++ lib/PlaYUVerStream.h | 16 +++++++--------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index da0c4eb..040ce69 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -187,7 +187,7 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel m_uiHeight = height; m_iPixelFormat = pel_format; m_iNumberChannels = 3; - m_iBitsPel = bitsPixel; + m_iBitsPel = bitsPixel > 8 ? bitsPixel : 8; if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > 16 ) { diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 70225b5..e6c4dc1 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -371,6 +371,14 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in return m_bInit; } + if( m_pcCurrFrame ) + { + m_uiWidth = m_pcCurrFrame->getWidth(); + m_uiHeight = m_pcCurrFrame->getHeight(); + m_iPixelFormat = m_pcCurrFrame->getPelFormat(); + m_uiBitsPerPixel = m_pcCurrFrame->getBitsPel(); + } + m_cPelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[m_iPixelFormat].c_str(); m_iCurrFrameNum = -1; diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index fc99d9a..6736c55 100644 --- a/lib/PlaYUVerStream.h +++ b/lib/PlaYUVerStream.h @@ -77,13 +77,17 @@ private: 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; + UInt m_uiWidth; + UInt m_uiHeight; Int m_iPixelFormat; UInt m_uiBitsPerPixel; + Double m_dFrameRate; + UInt64 m_uiTotalFrameNum; + Int64 m_iCurrFrameNum; + FILE* m_pFile; /**< The input file pointer >*/ + std::fstream m_fsIOStream; /**< The input file pointer >*/ Byte* m_pStreamBuffer; UInt m_uiFrameBufferSize; @@ -93,12 +97,6 @@ private: UInt m_uiFrameBufferIndex; UInt64 m_uiCurrFrameFileIdx; - UInt m_uiWidth; - UInt m_uiHeight; - Double m_dFrameRate; - UInt64 m_uiTotalFrameNum; - Int64 m_iCurrFrameNum; - public: static std::vector supportedReadFormatsExt();