From c9549d5d4072666666179db8fe43d69152ed61bb Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 8 Feb 2014 23:32:17 +0000 Subject: [PATCH] Add a function to copy PlaYUVerFrame --- source/PlaYUVerFrame.cpp | 27 +++++++++++++++++++++++++-- source/PlaYUVerFrame.h | 5 +++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/source/PlaYUVerFrame.cpp b/source/PlaYUVerFrame.cpp index 7f93389..f0ad873 100755 --- a/source/PlaYUVerFrame.cpp +++ b/source/PlaYUVerFrame.cpp @@ -165,9 +165,7 @@ Void PlaYUVerFrame::FrameFromBuffer( Pel *input_buffer, Int pel_format ) { return; } - UInt64 frame_bytes_input = m_uiWidth * m_uiHeight; - switch( m_iPixelFormat ) { case YUV420: @@ -185,6 +183,31 @@ Void PlaYUVerFrame::FrameFromBuffer( Pel *input_buffer, Int pel_format ) } } +Void PlaYUVerFrame::CopyFrom( PlaYUVerFrame* input_frame ) +{ + if( m_iPixelFormat != input_frame->getPelFormat() ) + { + return; + } + UInt64 num_bytes = m_uiWidth * m_uiHeight; + switch( m_iPixelFormat ) + { + case YUV420: + input_frame->getPelBufferYUV() + memcpy( &m_pppcInputPel[0][0][0], &( input_frame->getPelBufferYUV()[0][0][0] ), num_bytes * sizeof(Pel) ); + memcpy( &m_pppcInputPel[1][0][0], &( input_frame->getPelBufferYUV()[1][0][0] ), num_bytes / 4 * sizeof(Pel) ); + memcpy( &m_pppcInputPel[2][0][0], &( input_frame->getPelBufferYUV()[2][0][0] ), num_bytes / 4 * sizeof(Pel) ); + YUV420toRGB(); + break; + case YUV422: + break; + case YUV400: + break; + case RGB: + break; + } +} + UInt64 PlaYUVerFrame::getBytesPerFrame() { switch( m_iPixelFormat ) diff --git a/source/PlaYUVerFrame.h b/source/PlaYUVerFrame.h index 5823561..7a2961f 100755 --- a/source/PlaYUVerFrame.h +++ b/source/PlaYUVerFrame.h @@ -45,6 +45,7 @@ public: static QStringList supportedPixelFormatList(); Void FrameFromBuffer( Pel *input_buffer, Int pel_format ); + Void CopyFrom( PlaYUVerFrame* ); UInt64 getBytesPerFrame(); @@ -56,6 +57,10 @@ public: { return m_pppcRGBPel; } + Int getPelFormat() + { + return m_iPixelFormat; + } private: Void YUV420toRGB();