ref: 958113073f99ba45d2702f56c765254133a8e56d
parent: 37ae6505d4b697bc414195a2be94596fa1cb6adb
author: Martin Storsjö <[email protected]>
date: Tue Sep 16 07:07:47 EDT 2014
Simplify code by calling WelsFree directly instead of using a helper function This makes the code simpler and clearer. It's not necessary to use the _SafeFree helper macro in neither of the case - in one case the pointer is overwritten immediately, in the other case it's witihin the destructor where the pointer won't ever be read again.
--- a/codec/processing/src/backgrounddetection/BackgroundDetection.cpp
+++ b/codec/processing/src/backgrounddetection/BackgroundDetection.cpp
@@ -57,7 +57,7 @@
}
CBackgroundDetection::~CBackgroundDetection() {
- FreeOUArrayMemory();
+ WelsFree (m_BgdParam.pOU_array);
}
EResult CBackgroundDetection::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
@@ -80,7 +80,7 @@
int32_t iCurFrameSize = m_BgdParam.iBgdWidth * m_BgdParam.iBgdHeight;
if (m_BgdParam.pOU_array == NULL || iCurFrameSize > m_iLargestFrameSize) {
- FreeOUArrayMemory();
+ WelsFree (m_BgdParam.pOU_array);
m_BgdParam.pOU_array = AllocateOUArrayMemory (m_BgdParam.iBgdWidth, m_BgdParam.iBgdHeight);
m_iLargestFrameSize = iCurFrameSize;
}
@@ -110,10 +110,6 @@
int32_t iMaxOUWidth = (BGD_OU_SIZE - 1 + iWidth) >> LOG2_BGD_OU_SIZE;
int32_t iMaxOUHeight = (BGD_OU_SIZE - 1 + iHeight) >> LOG2_BGD_OU_SIZE;
return (SBackgroundOU*)WelsMalloc (iMaxOUWidth * iMaxOUHeight * sizeof (SBackgroundOU));
-}
-
-inline void CBackgroundDetection::FreeOUArrayMemory() {
- _SafeFree (m_BgdParam.pOU_array);
}
void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_t iMbIndex, int32_t iMbWidth,
--- a/codec/processing/src/backgrounddetection/BackgroundDetection.h
+++ b/codec/processing/src/backgrounddetection/BackgroundDetection.h
@@ -81,7 +81,6 @@
private:
inline SBackgroundOU* AllocateOUArrayMemory (int32_t iWidth, int32_t iHeight);
- inline void FreeOUArrayMemory();
inline int32_t CalculateAsdChromaEdge (uint8_t* pOriRef, uint8_t* pOriCur, int32_t iStride);
inline bool ForegroundDilation23Luma (SBackgroundOU* pBackgroundOU,
SBackgroundOU* pOUNeighbours[]); //Foreground_Dilation_2_3_Luma