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