Showing the changes to codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp (1 of 120 files). Show all
Unified · Split
| @@ -35,23 +35,23 @@ · 34 unmodified lines | |||
| 35 | 35 | ||
| 36 | WELSVP_NAMESPACE_BEGIN | 36 | WELSVP_NAMESPACE_BEGIN |
| 37 | 37 | ||
| 38 | int32_t CheckLine(uint8_t* pData, int32_t iWidth){ | 38 | int32_t CheckLine (uint8_t* pData, int32_t iWidth) { |
| 39 | int32_t iQualified = 0; | 39 | int32_t iQualified = 0; |
| 40 | int32_t iColorMap[8] = {0}; | 40 | int32_t iColorMap[8] = {0}; |
| 41 | int32_t iChangedTimes = 0; | 41 | int32_t iChangedTimes = 0; |
| 42 | int32_t iColorCounts = 0; | 42 | int32_t iColorCounts = 0; |
| 43 | 43 | ||
| 44 | RECORD_COLOR(pData[0], iColorMap); | 44 | RECORD_COLOR (pData[0], iColorMap); |
| 45 | 45 | ||
| 46 | for (int32_t i=1; i<iWidth; i++){ | 46 | for (int32_t i = 1; i < iWidth; i++) { |
| 47 | RECORD_COLOR(pData[i], iColorMap); | 47 | RECORD_COLOR (pData[i], iColorMap); |
| 48 | iChangedTimes += (pData[i] != pData[i-1]); | 48 | iChangedTimes += (pData[i] != pData[i - 1]); |
| 49 | } | 49 | } |
| 50 | for (int32_t i=0; i<8; i++) | 50 | for (int32_t i = 0; i < 8; i++) |
| 51 | for (int32_t j=0; j<32; j++) | 51 | for (int32_t j = 0; j < 32; j++) |
| 52 | iColorCounts += ((iColorMap[i] >> j)&1); | 52 | iColorCounts += ((iColorMap[i] >> j) & 1); |
| 53 | 53 | ||
| 54 | switch(iColorCounts){ | 54 | switch (iColorCounts) { |
| 55 | case 1: | 55 | case 1: |
| 56 | iQualified = 0; | 56 | iQualified = 0; |
| 57 | break; | 57 | break; |
| @@ -66,24 +66,24 @@ int32_t CheckLine(uint8_t* pData, int32_t iWidth){ · 8 unmodified lines | |||
| 66 | return iQualified; | 66 | return iQualified; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | int32_t SelectTestLine(uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPicHeight, | 69 | int32_t SelectTestLine (uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPicHeight, |
| 70 | int32_t iStride, int32_t iOffsetX, int32_t iOffsetY){ | 70 | int32_t iStride, int32_t iOffsetX, int32_t iOffsetY) { |
| 71 | const int32_t kiHalfHeight = iHeight >> 1; | 71 | const int32_t kiHalfHeight = iHeight >> 1; |
| 72 | const int32_t kiMidPos = iOffsetY + kiHalfHeight; | 72 | const int32_t kiMidPos = iOffsetY + kiHalfHeight; |
| 73 | int32_t TestPos = kiMidPos; | 73 | int32_t TestPos = kiMidPos; |
| 74 | int32_t iOffsetAbs; | 74 | int32_t iOffsetAbs; |
| 75 | uint8_t* pTmp; | 75 | uint8_t* pTmp; |
| 76 | 76 | ||
| 77 | for (iOffsetAbs = 0; iOffsetAbs < kiHalfHeight; iOffsetAbs++){ | 77 | for (iOffsetAbs = 0; iOffsetAbs < kiHalfHeight; iOffsetAbs++) { |
| 78 | TestPos = kiMidPos + iOffsetAbs; | 78 | TestPos = kiMidPos + iOffsetAbs; |
| 79 | if (TestPos < iPicHeight){ | 79 | if (TestPos < iPicHeight) { |
| 80 | pTmp = pY + TestPos * iStride + iOffsetX; | 80 | pTmp = pY + TestPos * iStride + iOffsetX; |
| 81 | if (CheckLine(pTmp, iWidth)) break; | 81 | if (CheckLine (pTmp, iWidth)) break; |
| 82 | } | 82 | } |
| 83 | TestPos = kiMidPos - iOffsetAbs; | 83 | TestPos = kiMidPos - iOffsetAbs; |
| 84 | if(TestPos >=0){ | 84 | if (TestPos >= 0) { |
| 85 | pTmp = pY + TestPos * iStride + iOffsetX; | 85 | pTmp = pY + TestPos * iStride + iOffsetX; |
| 86 | if (CheckLine(pTmp, iWidth)) break; | 86 | if (CheckLine (pTmp, iWidth)) break; |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | if (iOffsetAbs == kiHalfHeight) | 89 | if (iOffsetAbs == kiHalfHeight) |
| @@ -95,27 +95,26 @@ int32_t SelectTestLine(uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPi · 5 unmodified lines | |||
| 95 | * compare pixel line between previous and current one | 95 | * compare pixel line between previous and current one |
| 96 | * return: 0 for totally equal, otherwise 1 | 96 | * return: 0 for totally equal, otherwise 1 |
| 97 | */ | 97 | */ |
| 98 | int32_t CompareLine(uint8_t *pYSrc, uint8_t *pYRef, const int32_t kiWidth) | 98 | int32_t CompareLine (uint8_t* pYSrc, uint8_t* pYRef, const int32_t kiWidth) { |
| 99 | { | ||
| 100 | int32_t iCmp = 1; | 99 | int32_t iCmp = 1; |
| 101 | 100 | ||
| 102 | if ( *((int32_t*)pYSrc) != *((int32_t*)pYRef)) return 1; | 101 | if (* ((int32_t*)pYSrc) != * ((int32_t*)pYRef)) return 1; |
| 103 | if ( *((int32_t*)(pYSrc + 4)) != *((int32_t*)(pYRef + 4))) return 1; | 102 | if (* ((int32_t*) (pYSrc + 4)) != * ((int32_t*) (pYRef + 4))) return 1; |
| 104 | if ( *((int32_t*)(pYSrc + 8)) != *((int32_t*)(pYRef + 8))) return 1; | 103 | if (* ((int32_t*) (pYSrc + 8)) != * ((int32_t*) (pYRef + 8))) return 1; |
| 105 | if ( kiWidth > 12 ) | 104 | if (kiWidth > 12) |
| 106 | iCmp = WelsMemcmp(pYSrc+12, pYRef+12, kiWidth-12); | 105 | iCmp = WelsMemcmp (pYSrc + 12, pYRef + 12, kiWidth - 12); |
| 107 | return iCmp; | 106 | return iCmp; |
| 108 | } | 107 | } |
| 109 | 108 | ||
| 110 | void ScrollDetectionCore(SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidth, int32_t iHeight, | 109 | void ScrollDetectionCore (SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidth, int32_t iHeight, |
| 111 | int32_t iOffsetX, int32_t iOffsetY, SScrollDetectionParam &sScrollDetectionParam){ | 110 | int32_t iOffsetX, int32_t iOffsetY, SScrollDetectionParam& sScrollDetectionParam) { |
| 112 | bool bScrollDetected = 0; | 111 | bool bScrollDetected = 0; |
| 113 | uint8_t* pYLine; | 112 | uint8_t* pYLine; |
| 114 | uint8_t* pYTmp; | 113 | uint8_t* pYTmp; |
| 115 | int32_t iTestPos, iSearchPos = 0, iOffsetAbs, iMaxAbs; | 114 | int32_t iTestPos, iSearchPos = 0, iOffsetAbs, iMaxAbs; |
| 116 | int32_t iPicHeight = pRefPixMap->sRect.iRectHeight; | 115 | int32_t iPicHeight = pRefPixMap->sRect.iRectHeight; |
| 117 | int32_t iMinHeight = WELS_MAX(iOffsetY,0); | 116 | int32_t iMinHeight = WELS_MAX (iOffsetY, 0); |
| 118 | int32_t iMaxHeight = WELS_MIN(iOffsetY + iHeight - 1, iPicHeight-1) ;//offset_y + height - 1;// | 117 | int32_t iMaxHeight = WELS_MIN (iOffsetY + iHeight - 1, iPicHeight - 1) ; //offset_y + height - 1;// |
| 119 | uint8_t* pYRef, *pYSrc; | 118 | uint8_t* pYRef, *pYSrc; |
| 120 | int32_t iYStride; | 119 | int32_t iYStride; |
| 121 | 120 | ||
| @@ -123,76 +122,74 @@ void ScrollDetectionCore(SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidt · 1 unmodified line | |||
| 123 | pYSrc = (uint8_t*)pSrcPixMap->pPixel[0]; | 122 | pYSrc = (uint8_t*)pSrcPixMap->pPixel[0]; |
| 124 | iYStride = pRefPixMap->iStride[0]; | 123 | iYStride = pRefPixMap->iStride[0]; |
| 125 | 124 | ||
| 126 | iTestPos = SelectTestLine(pYSrc, iWidth, iHeight, iPicHeight, iYStride, iOffsetX, iOffsetY); | 125 | iTestPos = SelectTestLine (pYSrc, iWidth, iHeight, iPicHeight, iYStride, iOffsetX, iOffsetY); |
| 127 | 126 | ||
| 128 | if (iTestPos == -1){ | 127 | if (iTestPos == -1) { |
| 129 | sScrollDetectionParam.bScrollDetectFlag = 0; | 128 | sScrollDetectionParam.bScrollDetectFlag = 0; |
| 130 | return; | 129 | return; |
| 131 | } | 130 | } |
| 132 | pYLine = pYSrc + iYStride * iTestPos + iOffsetX; | 131 | pYLine = pYSrc + iYStride * iTestPos + iOffsetX; |
| 133 | iMaxAbs = WELS_MIN(WELS_MAX(iTestPos-iMinHeight-1, iMaxHeight-iTestPos),MAX_SCROLL_MV_Y); | 132 | iMaxAbs = WELS_MIN (WELS_MAX (iTestPos - iMinHeight - 1, iMaxHeight - iTestPos), MAX_SCROLL_MV_Y); |
| 134 | iSearchPos = iTestPos; | 133 | iSearchPos = iTestPos; |
| 135 | for (iOffsetAbs = 0; iOffsetAbs <= iMaxAbs; iOffsetAbs++){ | 134 | for (iOffsetAbs = 0; iOffsetAbs <= iMaxAbs; iOffsetAbs++) { |
| 136 | iSearchPos = iTestPos + iOffsetAbs; | 135 | iSearchPos = iTestPos + iOffsetAbs; |
| 137 | if (iSearchPos <= iMaxHeight){ | 136 | if (iSearchPos <= iMaxHeight) { |
| 138 | pYTmp = pYRef + iSearchPos * iYStride + iOffsetX; | 137 | pYTmp = pYRef + iSearchPos * iYStride + iOffsetX; |
| 139 | if (!CompareLine(pYLine, pYTmp, iWidth)){ | 138 | if (!CompareLine (pYLine, pYTmp, iWidth)) { |
| 140 | uint8_t *pYUpper, *pYLineUpper; | 139 | uint8_t* pYUpper, *pYLineUpper; |
| 141 | int32_t iCheckedLines; | 140 | int32_t iCheckedLines; |
| 142 | int32_t iLowOffset = WELS_MIN(iMaxHeight - iSearchPos, CHECK_OFFSET); | 141 | int32_t iLowOffset = WELS_MIN (iMaxHeight - iSearchPos, CHECK_OFFSET); |
| 143 | int32_t i; | 142 | int32_t i; |
| 144 | 143 | ||
| 145 | iCheckedLines = WELS_MIN(iTestPos - iMinHeight + iLowOffset, 2 * CHECK_OFFSET); | 144 | iCheckedLines = WELS_MIN (iTestPos - iMinHeight + iLowOffset, 2 * CHECK_OFFSET); |
| 146 | pYUpper = pYTmp - (iCheckedLines - iLowOffset) * iYStride; | 145 | pYUpper = pYTmp - (iCheckedLines - iLowOffset) * iYStride; |
| 147 | pYLineUpper = pYLine - (iCheckedLines - iLowOffset) * iYStride; | 146 | pYLineUpper = pYLine - (iCheckedLines - iLowOffset) * iYStride; |
| 148 | 147 | ||
| 149 | for(i = 0; i < iCheckedLines; i ++){ | 148 | for (i = 0; i < iCheckedLines; i ++) { |
| 150 | if (CompareLine(pYLineUpper, pYUpper, iWidth)){ | 149 | if (CompareLine (pYLineUpper, pYUpper, iWidth)) { |
| 151 | break; | 150 | break; |
| 152 | } | 151 | } |
| 153 | pYUpper += iYStride; | 152 | pYUpper += iYStride; |
| 154 | pYLineUpper += iYStride; | 153 | pYLineUpper += iYStride; |
| 155 | } | 154 | } |
| 156 | if (i == iCheckedLines){ | 155 | if (i == iCheckedLines) { |
| 157 | bScrollDetected=1; | 156 | bScrollDetected = 1; |
| 158 | break; | 157 | break; |
| 159 | } | 158 | } |
| 160 | } | 159 | } |
| 161 | } | 160 | } |
| 162 | 161 | ||
| 163 | iSearchPos = iTestPos - iOffsetAbs-1; | 162 | iSearchPos = iTestPos - iOffsetAbs - 1; |
| 164 | if (iSearchPos >= iMinHeight){ | 163 | if (iSearchPos >= iMinHeight) { |
| 165 | pYTmp = pYRef + iSearchPos * iYStride + iOffsetX; | 164 | pYTmp = pYRef + iSearchPos * iYStride + iOffsetX; |
| 166 | if (!CompareLine(pYLine, pYTmp, iWidth)) | 165 | if (!CompareLine (pYLine, pYTmp, iWidth)) { |
| 167 | { | 166 | uint8_t* pYUpper, *pYLineUpper; |
| 168 | uint8_t *pYUpper, *pYLineUpper; | ||
| 169 | int32_t iCheckedLines; | 167 | int32_t iCheckedLines; |
| 170 | int32_t iUpOffset = WELS_MIN(iSearchPos - iMinHeight, CHECK_OFFSET); | 168 | int32_t iUpOffset = WELS_MIN (iSearchPos - iMinHeight, CHECK_OFFSET); |
| 171 | int32_t i; | 169 | int32_t i; |
| 172 | 170 | ||
| 173 | pYUpper = pYTmp - iUpOffset * iYStride; | 171 | pYUpper = pYTmp - iUpOffset * iYStride; |
| 174 | pYLineUpper = pYLine - iUpOffset * iYStride; | 172 | pYLineUpper = pYLine - iUpOffset * iYStride; |
| 175 | iCheckedLines = WELS_MIN(iMaxHeight - iTestPos + iUpOffset, 2 * CHECK_OFFSET); | 173 | iCheckedLines = WELS_MIN (iMaxHeight - iTestPos + iUpOffset, 2 * CHECK_OFFSET); |
| 176 | 174 | ||
| 177 | for(i = 0; i < iCheckedLines; i ++){ | 175 | for (i = 0; i < iCheckedLines; i ++) { |
| 178 | if (CompareLine(pYLineUpper,pYUpper, iWidth)){ | 176 | if (CompareLine (pYLineUpper, pYUpper, iWidth)) { |
| 179 | break; | 177 | break; |
| 180 | } | 178 | } |
| 181 | pYUpper += iYStride; | 179 | pYUpper += iYStride; |
| 182 | pYLineUpper += iYStride; | 180 | pYLineUpper += iYStride; |
| 183 | } | 181 | } |
| 184 | if (i == iCheckedLines){ | 182 | if (i == iCheckedLines) { |
| 185 | bScrollDetected=1; | 183 | bScrollDetected = 1; |
| 186 | break; | 184 | break; |
| 187 | } | 185 | } |
| 188 | } | 186 | } |
| 189 | } | 187 | } |
| 190 | } | 188 | } |
| 191 | 189 | ||
| 192 | if (!bScrollDetected){ | 190 | if (!bScrollDetected) { |
| 193 | sScrollDetectionParam.bScrollDetectFlag = 0; | 191 | sScrollDetectionParam.bScrollDetectFlag = 0; |
| 194 | } | 192 | } else { |
| 195 | else{ | ||
| 196 | sScrollDetectionParam.bScrollDetectFlag = 1; | 193 | sScrollDetectionParam.bScrollDetectFlag = 1; |
| 197 | sScrollDetectionParam.iScrollMvY = iSearchPos - iTestPos; // pre_pos - cur_pos, change to mv | 194 | sScrollDetectionParam.iScrollMvY = iSearchPos - iTestPos; // pre_pos - cur_pos, change to mv |
| 198 | sScrollDetectionParam.iScrollMvX = 0; | 195 | sScrollDetectionParam.iScrollMvX = 0; |