From 54da444b4fdacdb18f814381681a0bf0dd23e916 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 6 Jul 2014 21:44:26 +0100 Subject: [PATCH] Add a static function to return the frame size for a given format --- source/lib/PlaYUVerFrame.cpp | 17 +++++++++++------ source/lib/PlaYUVerFrame.h | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source/lib/PlaYUVerFrame.cpp b/source/lib/PlaYUVerFrame.cpp index 6d366d3..79d9c7b 100644 --- a/source/lib/PlaYUVerFrame.cpp +++ b/source/lib/PlaYUVerFrame.cpp @@ -524,23 +524,28 @@ Double PlaYUVerFrame::getPSNR( PlaYUVerFrame* Org, Int component ) UInt64 PlaYUVerFrame::getBytesPerFrame() { - switch( m_iPixelFormat ) + return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); +} + +UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat ) +{ + switch( iPixelFormat ) { case YUV420p: - return m_uiWidth * m_uiHeight * 1.5; + return uiWidth * uiHeight * 1.5; break; case YUV444p: - return m_uiWidth * m_uiHeight * 3; + return uiWidth * uiHeight * 3; break; case YUV422p: case YUYV422: - return m_uiWidth * m_uiHeight * 2; + return uiWidth * uiHeight * 2; break; case GRAY: - return m_uiWidth * m_uiHeight; + return uiWidth * uiHeight; break; case RGB8: - return m_uiWidth * m_uiHeight * 3; + return uiWidth * uiHeight * 3; break; default: return 0; diff --git a/source/lib/PlaYUVerFrame.h b/source/lib/PlaYUVerFrame.h index a182bc5..1f3deb7 100644 --- a/source/lib/PlaYUVerFrame.h +++ b/source/lib/PlaYUVerFrame.h @@ -118,6 +118,7 @@ public: Double getPSNR( PlaYUVerFrame* Org, Int component ); UInt64 getBytesPerFrame(); + static UInt64 getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat ); UInt getChromaLength() const;