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.
Showing the changes to codec/processing/src/backgrounddetection/BackgroundDetection.cpp (1 of 2 files). Show all
Unified · Split
| @@ -57,7 +57,7 @@ CBackgroundDetection::CBackgroundDetection (int32_t iCpuFlag) { · 56 unmodified lines | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | CBackgroundDetection::~CBackgroundDetection() { | 59 | CBackgroundDetection::~CBackgroundDetection() { |
| 60 | FreeOUArrayMemory(); | 60 | WelsFree (m_BgdParam.pOU_array); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | EResult CBackgroundDetection::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) { | 63 | EResult CBackgroundDetection::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) { |
| @@ -80,7 +80,7 @@ EResult CBackgroundDetection::Process (int32_t iType, SPixMap* pSrcPixMap, SPixM · 16 unmodified lines | |||
| 80 | 80 | ||
| 81 | int32_t iCurFrameSize = m_BgdParam.iBgdWidth * m_BgdParam.iBgdHeight; | 81 | int32_t iCurFrameSize = m_BgdParam.iBgdWidth * m_BgdParam.iBgdHeight; |
| 82 | if (m_BgdParam.pOU_array == NULL || iCurFrameSize > m_iLargestFrameSize) { | 82 | if (m_BgdParam.pOU_array == NULL || iCurFrameSize > m_iLargestFrameSize) { |
| 83 | FreeOUArrayMemory(); | 83 | WelsFree (m_BgdParam.pOU_array); |
| 84 | m_BgdParam.pOU_array = AllocateOUArrayMemory (m_BgdParam.iBgdWidth, m_BgdParam.iBgdHeight); | 84 | m_BgdParam.pOU_array = AllocateOUArrayMemory (m_BgdParam.iBgdWidth, m_BgdParam.iBgdHeight); |
| 85 | m_iLargestFrameSize = iCurFrameSize; | 85 | m_iLargestFrameSize = iCurFrameSize; |
| 86 | } | 86 | } |
| @@ -112,10 +112,6 @@ inline SBackgroundOU* CBackgroundDetection::AllocateOUArrayMemory (int32_t iWidt · 25 unmodified lines | |||
| 112 | return (SBackgroundOU*)WelsMalloc (iMaxOUWidth * iMaxOUHeight * sizeof (SBackgroundOU)); | 112 | return (SBackgroundOU*)WelsMalloc (iMaxOUWidth * iMaxOUHeight * sizeof (SBackgroundOU)); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | inline void CBackgroundDetection::FreeOUArrayMemory() { | ||
| 116 | _SafeFree (m_BgdParam.pOU_array); | ||
| 117 | } | ||
| 118 | |||
| 119 | void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_t iMbIndex, int32_t iMbWidth, | 115 | void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_t iMbIndex, int32_t iMbWidth, |
| 120 | SBackgroundOU* pBgdOU) { | 116 | SBackgroundOU* pBgdOU) { |
| 121 | int32_t iSubSD[4]; | 117 | int32_t iSubSD[4]; |