From b5a5bb90f9e433af307df09b3b87a51e38c6e58d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 20 Feb 2019 04:41:07 +0000 Subject: [PATCH] Fix bugs in CalypFrame --- lib/CalypFrame.cpp | 14 ++++++++++++-- lib/CalypFrame.h | 6 ++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/CalypFrame.cpp b/lib/CalypFrame.cpp index 93c1610..d979e8b 100644 --- a/lib/CalypFrame.cpp +++ b/lib/CalypFrame.cpp @@ -390,7 +390,17 @@ unsigned int CalypFrame::getHeight( int channel ) const unsigned int CalypFrame::getPixels( int channel ) const { - return getWidth( channel ) * getWidth( channel ); + return getWidth( channel ) * getHeight( channel ); +} + +unsigned long CalypFrame::getTotalNumberOfPixels() const +{ + unsigned long numberPixels = 0; + for( int i = 0; i < getNumberChannels(); i++ ) + { + numberPixels += getPixels( i ); + } + return numberPixels; } unsigned char CalypFrame::getChromaWidthRatio() const @@ -518,7 +528,7 @@ void CalypFrame::copyFrom( const CalypFrame& other ) return; d->m_bHasRGBPel = false; d->m_bHasHistogram = false; - memcpy( *d->m_pppcInputPel[CLP_LUMA], other.getPelBufferYUV()[CLP_LUMA][0], getBytesPerFrame() * sizeof( ClpPel ) ); + memcpy( *d->m_pppcInputPel[CLP_LUMA], other.getPelBufferYUV()[CLP_LUMA][0], getTotalNumberOfPixels() * sizeof( ClpPel ) ); } void CalypFrame::copyFrom( const CalypFrame* other ) diff --git a/lib/CalypFrame.h b/lib/CalypFrame.h index c9ff227..bfa0136 100644 --- a/lib/CalypFrame.h +++ b/lib/CalypFrame.h @@ -202,6 +202,12 @@ public: */ unsigned int getPixels( int channel = 0 ) const; + /** + * Get the total number of pixels of the frame + * @return number of pixels + */ + unsigned long getTotalNumberOfPixels() const; + /** * Get chroma width ratio * @return ratio multiple of 2