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.
This commit is contained in:
Martin Storsjö
2014-09-16 11:07:47 +03:00
parent 37ae6505d4
commit 958113073f
2 changed files with 2 additions and 7 deletions

View File

@@ -57,7 +57,7 @@ CBackgroundDetection::CBackgroundDetection (int32_t iCpuFlag) {
} }
CBackgroundDetection::~CBackgroundDetection() { CBackgroundDetection::~CBackgroundDetection() {
FreeOUArrayMemory(); WelsFree (m_BgdParam.pOU_array);
} }
EResult CBackgroundDetection::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) { EResult CBackgroundDetection::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
@@ -80,7 +80,7 @@ EResult CBackgroundDetection::Process (int32_t iType, SPixMap* pSrcPixMap, SPixM
int32_t iCurFrameSize = m_BgdParam.iBgdWidth * m_BgdParam.iBgdHeight; int32_t iCurFrameSize = m_BgdParam.iBgdWidth * m_BgdParam.iBgdHeight;
if (m_BgdParam.pOU_array == NULL || iCurFrameSize > m_iLargestFrameSize) { 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_BgdParam.pOU_array = AllocateOUArrayMemory (m_BgdParam.iBgdWidth, m_BgdParam.iBgdHeight);
m_iLargestFrameSize = iCurFrameSize; m_iLargestFrameSize = iCurFrameSize;
} }
@@ -112,10 +112,6 @@ inline SBackgroundOU* CBackgroundDetection::AllocateOUArrayMemory (int32_t iWidt
return (SBackgroundOU*)WelsMalloc (iMaxOUWidth * iMaxOUHeight * sizeof (SBackgroundOU)); 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, void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_t iMbIndex, int32_t iMbWidth,
SBackgroundOU* pBgdOU) { SBackgroundOU* pBgdOU) {
int32_t iSubSD[4]; int32_t iSubSD[4];

View File

@@ -81,7 +81,6 @@ class CBackgroundDetection : public IStrategy {
private: private:
inline SBackgroundOU* AllocateOUArrayMemory (int32_t iWidth, int32_t iHeight); 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 int32_t CalculateAsdChromaEdge (uint8_t* pOriRef, uint8_t* pOriCur, int32_t iStride);
inline bool ForegroundDilation23Luma (SBackgroundOU* pBackgroundOU, inline bool ForegroundDilation23Luma (SBackgroundOU* pBackgroundOU,
SBackgroundOU* pOUNeighbours[]); //Foreground_Dilation_2_3_Luma SBackgroundOU* pOUNeighbours[]); //Foreground_Dilation_2_3_Luma