Showing the changes to codec/processing/src/backgrounddetection/BackgroundDetection.cpp (1 of 64 files). Show all
Unified · Split
| @@ -107,16 +107,16 @@ EResult CBackgroundDetection::Set (int32_t iType, void* pParam) { · 106 unmodified lines | ||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | inline SBackgroundOU* CBackgroundDetection::AllocateOUArrayMemory (int32_t iWidth, int32_t iHeight) { |
| 110 | − int32_t iMaxOUWidth = (BGD_OU_SIZE - 1 + iWidth) >> LOG2_BGD_OU_SIZE; | |
| 111 | − int32_t iMaxOUHeight = (BGD_OU_SIZE - 1 + iHeight) >> LOG2_BGD_OU_SIZE; | |
| 110 | + int32_t iMaxOUWidth = (BGD_OU_SIZE - 1 + iWidth) >> LOG2_BGD_OU_SIZE; | |
| 111 | + int32_t iMaxOUHeight = (BGD_OU_SIZE - 1 + iHeight) >> LOG2_BGD_OU_SIZE; | |
| 112 | 112 | return (SBackgroundOU*)WelsMalloc (iMaxOUWidth * iMaxOUHeight * sizeof (SBackgroundOU)); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_t iMbIndex, int32_t iMbWidth, |
| 116 | 116 | SBackgroundOU* pBgdOU) { |
| 117 | − int32_t iSubSD[4]; | |
| 118 | − uint8_t iSubMAD[4]; | |
| 119 | − int32_t iSubSAD[4]; | |
| 117 | + int32_t iSubSD[4]; | |
| 118 | + uint8_t iSubMAD[4]; | |
| 119 | + int32_t iSubSAD[4]; | |
| 120 | 120 | |
| 121 | 121 | uint8_t (*pMad8x8)[4]; |
| 122 | 122 | int32_t (*pSad8x8)[4]; |
| @@ -141,9 +141,9 @@ void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_ · 18 unmodified lines | ||
| 141 | 141 | iSubMAD[2] = pMad8x8[iMbIndex][2]; |
| 142 | 142 | iSubMAD[3] = pMad8x8[iMbIndex][3]; |
| 143 | 143 | |
| 144 | − pBgdOU->iSD = iSubSD[0] + iSubSD[1] + iSubSD[2] + iSubSD[3]; | |
| 145 | − pBgdOU->iSAD = iSubSAD[0] + iSubSAD[1] + iSubSAD[2] + iSubSAD[3]; | |
| 146 | − pBgdOU->iSD = WELS_ABS (pBgdOU->iSD); | |
| 144 | + pBgdOU->iSD = iSubSD[0] + iSubSD[1] + iSubSD[2] + iSubSD[3]; | |
| 145 | + pBgdOU->iSAD = iSubSAD[0] + iSubSAD[1] + iSubSAD[2] + iSubSAD[3]; | |
| 146 | + pBgdOU->iSD = WELS_ABS (pBgdOU->iSD); | |
| 147 | 147 | |
| 148 | 148 | // get the max absolute difference (MAD) of OU and min value of the MAD of sub-blocks of OU |
| 149 | 149 | pBgdOU->iMAD = WELS_MAX (WELS_MAX (iSubMAD[0], iSubMAD[1]), WELS_MAX (iSubMAD[2], iSubMAD[3])); |
| @@ -155,9 +155,9 @@ void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_ · 5 unmodified lines | ||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | void CBackgroundDetection::ForegroundBackgroundDivision (vBGDParam* pBgdParam) { |
| 158 | − int32_t iPicWidthInOU = pBgdParam->iBgdWidth >> LOG2_BGD_OU_SIZE; | |
| 159 | − int32_t iPicHeightInOU = pBgdParam->iBgdHeight >> LOG2_BGD_OU_SIZE; | |
| 160 | − int32_t iPicWidthInMb = (15 + pBgdParam->iBgdWidth) >> 4; | |
| 158 | + int32_t iPicWidthInOU = pBgdParam->iBgdWidth >> LOG2_BGD_OU_SIZE; | |
| 159 | + int32_t iPicHeightInOU = pBgdParam->iBgdHeight >> LOG2_BGD_OU_SIZE; | |
| 160 | + int32_t iPicWidthInMb = (15 + pBgdParam->iBgdWidth) >> 4; | |
| 161 | 161 | |
| 162 | 162 | SBackgroundOU* pBackgroundOU = pBgdParam->pOU_array; |
| 163 | 163 | |
| @@ -187,8 +187,8 @@ void CBackgroundDetection::ForegroundBackgroundDivision (vBGDParam* pBgdParam) { · 23 unmodified lines | ||
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | inline int32_t CBackgroundDetection::CalculateAsdChromaEdge (uint8_t* pOriRef, uint8_t* pOriCur, int32_t iStride) { |
| 190 | − int32_t ASD = 0; | |
| 191 | − int32_t idx; | |
| 190 | + int32_t ASD = 0; | |
| 191 | + int32_t idx; | |
| 192 | 192 | for (idx = 0; idx < BGD_OU_SIZE_UV; idx++) { |
| 193 | 193 | ASD += *pOriCur - *pOriRef; |
| 194 | 194 | pOriRef += iStride; |
| @@ -199,16 +199,16 @@ inline int32_t CBackgroundDetection::CalculateAsdChromaEdge (uint8_t* pOriRef, u · 4 unmodified lines | ||
| 199 | 199 | |
| 200 | 200 | inline bool CBackgroundDetection::ForegroundDilation23Luma (SBackgroundOU* pBackgroundOU, |
| 201 | 201 | SBackgroundOU* pOUNeighbours[]) { |
| 202 | − SBackgroundOU* pOU_L = pOUNeighbours[0]; | |
| 203 | − SBackgroundOU* pOU_R = pOUNeighbours[1]; | |
| 204 | − SBackgroundOU* pOU_U = pOUNeighbours[2]; | |
| 205 | − SBackgroundOU* pOU_D = pOUNeighbours[3]; | |
| 202 | + SBackgroundOU* pOU_L = pOUNeighbours[0]; | |
| 203 | + SBackgroundOU* pOU_R = pOUNeighbours[1]; | |
| 204 | + SBackgroundOU* pOU_U = pOUNeighbours[2]; | |
| 205 | + SBackgroundOU* pOU_D = pOUNeighbours[3]; | |
| 206 | 206 | |
| 207 | 207 | if (pBackgroundOU->iMAD > pBackgroundOU->iMinSubMad << 1) { |
| 208 | 208 | int32_t iMaxNbrForegroundMad; |
| 209 | 209 | int32_t iMaxNbrBackgroundMad; |
| 210 | − int32_t aBackgroundMad[4]; | |
| 211 | − int32_t aForegroundMad[4]; | |
| 210 | + int32_t aBackgroundMad[4]; | |
| 211 | + int32_t aForegroundMad[4]; | |
| 212 | 212 | |
| 213 | 213 | aForegroundMad[0] = (pOU_L->iBackgroundFlag - 1) & pOU_L->iMAD; |
| 214 | 214 | aForegroundMad[1] = (pOU_R->iBackgroundFlag - 1) & pOU_R->iMAD; |
| @@ -232,9 +232,9 @@ inline bool CBackgroundDetection::ForegroundDilation23Luma (SBackgroundOU* pBack · 17 unmodified lines | ||
| 232 | 232 | |
| 233 | 233 | inline bool CBackgroundDetection::ForegroundDilation23Chroma (int8_t iNeighbourForegroundFlags, |
| 234 | 234 | int32_t iStartSamplePos, int32_t iPicStrideUV, vBGDParam* pBgdParam) { |
| 235 | − static const int8_t kaOUPos[4] = {OU_LEFT, OU_RIGHT, OU_TOP, OU_BOTTOM}; | |
| 236 | − int32_t aEdgeOffset[4] = {0, BGD_OU_SIZE_UV - 1, 0, iPicStrideUV* (BGD_OU_SIZE_UV - 1)}; | |
| 237 | − int32_t iStride[4] = {iPicStrideUV, iPicStrideUV, 1, 1}; | |
| 235 | + static const int8_t kaOUPos[4] = {OU_LEFT, OU_RIGHT, OU_TOP, OU_BOTTOM}; | |
| 236 | + int32_t aEdgeOffset[4] = {0, BGD_OU_SIZE_UV - 1, 0, iPicStrideUV* (BGD_OU_SIZE_UV - 1)}; | |
| 237 | + int32_t iStride[4] = {iPicStrideUV, iPicStrideUV, 1, 1}; | |
| 238 | 238 | |
| 239 | 239 | // V component first, high probability because V stands for red color and human skin colors have more weight on this component |
| 240 | 240 | for (int32_t i = 0; i < 4; i++) { |
| @@ -262,8 +262,8 @@ inline bool CBackgroundDetection::ForegroundDilation23Chroma (int8_t iNeighbourF · 21 unmodified lines | ||
| 262 | 262 | |
| 263 | 263 | inline void CBackgroundDetection::ForegroundDilation (SBackgroundOU* pBackgroundOU, SBackgroundOU* pOUNeighbours[], |
| 264 | 264 | vBGDParam* pBgdParam, int32_t iChromaSampleStartPos) { |
| 265 | − int32_t iPicStrideUV = pBgdParam->iStride[1]; | |
| 266 | − int32_t iSumNeighBackgroundFlags = pOUNeighbours[0]->iBackgroundFlag + pOUNeighbours[1]->iBackgroundFlag + | |
| 265 | + int32_t iPicStrideUV = pBgdParam->iStride[1]; | |
| 266 | + int32_t iSumNeighBackgroundFlags = pOUNeighbours[0]->iBackgroundFlag + pOUNeighbours[1]->iBackgroundFlag + | |
| 267 | 267 | pOUNeighbours[2]->iBackgroundFlag + pOUNeighbours[3]->iBackgroundFlag; |
| 268 | 268 | |
| 269 | 269 | if (pBackgroundOU->iSAD > BGD_OU_SIZE * Q_FACTOR) { |
| @@ -318,10 +318,10 @@ inline void CBackgroundDetection::SetBackgroundMbFlag (int8_t* pBackgroundMbFlag · 48 unmodified lines | ||
| 318 | 318 | inline void CBackgroundDetection::UpperOUForegroundCheck (SBackgroundOU* pCurOU, int8_t* pBackgroundMbFlag, |
| 319 | 319 | int32_t iPicWidthInOU, int32_t iPicWidthInMb) { |
| 320 | 320 | if (pCurOU->iSAD > BGD_OU_SIZE * Q_FACTOR) { |
| 321 | − SBackgroundOU* pOU_L = pCurOU - 1; | |
| 322 | − SBackgroundOU* pOU_R = pCurOU + 1; | |
| 323 | − SBackgroundOU* pOU_U = pCurOU - iPicWidthInOU; | |
| 324 | − SBackgroundOU* pOU_D = pCurOU + iPicWidthInOU; | |
| 321 | + SBackgroundOU* pOU_L = pCurOU - 1; | |
| 322 | + SBackgroundOU* pOU_R = pCurOU + 1; | |
| 323 | + SBackgroundOU* pOU_U = pCurOU - iPicWidthInOU; | |
| 324 | + SBackgroundOU* pOU_D = pCurOU + iPicWidthInOU; | |
| 325 | 325 | if (pOU_L->iBackgroundFlag + pOU_R->iBackgroundFlag + pOU_U->iBackgroundFlag + pOU_D->iBackgroundFlag <= 1) { |
| 326 | 326 | SetBackgroundMbFlag (pBackgroundMbFlag, iPicWidthInMb, 0); |
| 327 | 327 | pCurOU->iBackgroundFlag = 0; |
| @@ -330,21 +330,21 @@ inline void CBackgroundDetection::UpperOUForegroundCheck (SBackgroundOU* pCurOU, · 2 unmodified lines | ||
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | void CBackgroundDetection::ForegroundDilationAndBackgroundErosion (vBGDParam* pBgdParam) { |
| 333 | − int32_t iPicStrideUV = pBgdParam->iStride[1]; | |
| 334 | − int32_t iPicWidthInOU = pBgdParam->iBgdWidth >> LOG2_BGD_OU_SIZE; | |
| 335 | − int32_t iPicHeightInOU = pBgdParam->iBgdHeight >> LOG2_BGD_OU_SIZE; | |
| 336 | − int32_t iOUStrideUV = iPicStrideUV << (LOG2_BGD_OU_SIZE - 1); | |
| 337 | − int32_t iPicWidthInMb = (15 + pBgdParam->iBgdWidth) >> 4; | |
| 333 | + int32_t iPicStrideUV = pBgdParam->iStride[1]; | |
| 334 | + int32_t iPicWidthInOU = pBgdParam->iBgdWidth >> LOG2_BGD_OU_SIZE; | |
| 335 | + int32_t iPicHeightInOU = pBgdParam->iBgdHeight >> LOG2_BGD_OU_SIZE; | |
| 336 | + int32_t iOUStrideUV = iPicStrideUV << (LOG2_BGD_OU_SIZE - 1); | |
| 337 | + int32_t iPicWidthInMb = (15 + pBgdParam->iBgdWidth) >> 4; | |
| 338 | 338 | |
| 339 | 339 | SBackgroundOU* pBackgroundOU = pBgdParam->pOU_array; |
| 340 | − int8_t* pVaaBackgroundMbFlag = (int8_t*)pBgdParam->pBackgroundMbFlag; | |
| 341 | − SBackgroundOU* pOUNeighbours[4];//0: left; 1: right; 2: top; 3: bottom | |
| 340 | + int8_t* pVaaBackgroundMbFlag = (int8_t*)pBgdParam->pBackgroundMbFlag; | |
| 341 | + SBackgroundOU* pOUNeighbours[4];//0: left; 1: right; 2: top; 3: bottom | |
| 342 | 342 | |
| 343 | − pOUNeighbours[2] = pBackgroundOU;//top OU | |
| 343 | + pOUNeighbours[2] = pBackgroundOU;//top OU | |
| 344 | 344 | for (int32_t j = 0; j < iPicHeightInOU; j ++) { |
| 345 | 345 | int8_t* pRowSkipFlag = pVaaBackgroundMbFlag; |
| 346 | − pOUNeighbours[0] = pBackgroundOU;//left OU | |
| 347 | − pOUNeighbours[3] = pBackgroundOU + (iPicWidthInOU & ((j == iPicHeightInOU - 1) - 1)); //bottom OU | |
| 346 | + pOUNeighbours[0] = pBackgroundOU;//left OU | |
| 347 | + pOUNeighbours[3] = pBackgroundOU + (iPicWidthInOU & ((j == iPicHeightInOU - 1) - 1)); //bottom OU | |
| 348 | 348 | for (int32_t i = 0; i < iPicWidthInOU; i++) { |
| 349 | 349 | pOUNeighbours[1] = pBackgroundOU + (i < iPicWidthInOU - 1); //right OU |
| 350 | 350 | |
| @@ -367,7 +367,7 @@ void CBackgroundDetection::ForegroundDilationAndBackgroundErosion (vBGDParam* pB · 16 unmodified lines | ||
| 367 | 367 | pOUNeighbours[3]++; |
| 368 | 368 | pBackgroundOU++; |
| 369 | 369 | } |
| 370 | − pOUNeighbours[2] = pBackgroundOU - iPicWidthInOU; | |
| 370 | + pOUNeighbours[2] = pBackgroundOU - iPicWidthInOU; | |
| 371 | 371 | pVaaBackgroundMbFlag += OU_SIZE_IN_MB * iPicWidthInMb; |
| 372 | 372 | } |
| 373 | 373 | } |