History

astyle all files

huili2 committed 12 years ago

Commit 5ed24f21 parent 0c24686120 files · +3967 −3886Browse files

Showing the changes to codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp (1 of 120 files). Show all

Unified · Split

codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp+51−54
@@ -35,23 +35,23 @@ · 34 unmodified lines
3535
3636 WELSVP_NAMESPACE_BEGIN
3737
38−int32_t CheckLine(uint8_t* pData, int32_t iWidth){
38+int32_t CheckLine (uint8_t* pData, int32_t iWidth) {
3939 int32_t iQualified = 0;
4040 int32_t iColorMap[8] = {0};
4141 int32_t iChangedTimes = 0;
4242 int32_t iColorCounts = 0;
4343
44− RECORD_COLOR(pData[0], iColorMap);
44+ RECORD_COLOR (pData[0], iColorMap);
4545
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]);
4949 }
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);
5353
54− switch(iColorCounts){
54+ switch (iColorCounts) {
5555 case 1:
5656 iQualified = 0;
5757 break;
@@ -66,24 +66,24 @@ int32_t CheckLine(uint8_t* pData, int32_t iWidth){ · 8 unmodified lines
6666 return iQualified;
6767 }
6868
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) {
7171 const int32_t kiHalfHeight = iHeight >> 1;
7272 const int32_t kiMidPos = iOffsetY + kiHalfHeight;
7373 int32_t TestPos = kiMidPos;
7474 int32_t iOffsetAbs;
7575 uint8_t* pTmp;
7676
77− for (iOffsetAbs = 0; iOffsetAbs < kiHalfHeight; iOffsetAbs++){
77+ for (iOffsetAbs = 0; iOffsetAbs < kiHalfHeight; iOffsetAbs++) {
7878 TestPos = kiMidPos + iOffsetAbs;
79− if (TestPos < iPicHeight){
79+ if (TestPos < iPicHeight) {
8080 pTmp = pY + TestPos * iStride + iOffsetX;
81− if (CheckLine(pTmp, iWidth)) break;
81+ if (CheckLine (pTmp, iWidth)) break;
8282 }
8383 TestPos = kiMidPos - iOffsetAbs;
84− if(TestPos >=0){
84+ if (TestPos >= 0) {
8585 pTmp = pY + TestPos * iStride + iOffsetX;
86− if (CheckLine(pTmp, iWidth)) break;
86+ if (CheckLine (pTmp, iWidth)) break;
8787 }
8888 }
8989 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
9595 * compare pixel line between previous and current one
9696 * return: 0 for totally equal, otherwise 1
9797 */
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) {
10099 int32_t iCmp = 1;
101100
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);
107106 return iCmp;
108107 }
109108
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) {
112111 bool bScrollDetected = 0;
113112 uint8_t* pYLine;
114113 uint8_t* pYTmp;
115114 int32_t iTestPos, iSearchPos = 0, iOffsetAbs, iMaxAbs;
116115 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;//
119118 uint8_t* pYRef, *pYSrc;
120119 int32_t iYStride;
121120
@@ -123,76 +122,74 @@ void ScrollDetectionCore(SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidt · 1 unmodified line
123122 pYSrc = (uint8_t*)pSrcPixMap->pPixel[0];
124123 iYStride = pRefPixMap->iStride[0];
125124
126− iTestPos = SelectTestLine(pYSrc, iWidth, iHeight, iPicHeight, iYStride, iOffsetX, iOffsetY);
125+ iTestPos = SelectTestLine (pYSrc, iWidth, iHeight, iPicHeight, iYStride, iOffsetX, iOffsetY);
127126
128− if (iTestPos == -1){
127+ if (iTestPos == -1) {
129128 sScrollDetectionParam.bScrollDetectFlag = 0;
130129 return;
131130 }
132131 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);
134133 iSearchPos = iTestPos;
135− for (iOffsetAbs = 0; iOffsetAbs <= iMaxAbs; iOffsetAbs++){
134+ for (iOffsetAbs = 0; iOffsetAbs <= iMaxAbs; iOffsetAbs++) {
136135 iSearchPos = iTestPos + iOffsetAbs;
137− if (iSearchPos <= iMaxHeight){
136+ if (iSearchPos <= iMaxHeight) {
138137 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;
141140 int32_t iCheckedLines;
142− int32_t iLowOffset = WELS_MIN(iMaxHeight - iSearchPos, CHECK_OFFSET);
141+ int32_t iLowOffset = WELS_MIN (iMaxHeight - iSearchPos, CHECK_OFFSET);
143142 int32_t i;
144143
145− iCheckedLines = WELS_MIN(iTestPos - iMinHeight + iLowOffset, 2 * CHECK_OFFSET);
144+ iCheckedLines = WELS_MIN (iTestPos - iMinHeight + iLowOffset, 2 * CHECK_OFFSET);
146145 pYUpper = pYTmp - (iCheckedLines - iLowOffset) * iYStride;
147146 pYLineUpper = pYLine - (iCheckedLines - iLowOffset) * iYStride;
148147
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)) {
151150 break;
152151 }
153152 pYUpper += iYStride;
154153 pYLineUpper += iYStride;
155154 }
156− if (i == iCheckedLines){
157− bScrollDetected=1;
155+ if (i == iCheckedLines) {
156+ bScrollDetected = 1;
158157 break;
159158 }
160159 }
161160 }
162161
163− iSearchPos = iTestPos - iOffsetAbs-1;
164− if (iSearchPos >= iMinHeight){
162+ iSearchPos = iTestPos - iOffsetAbs - 1;
163+ if (iSearchPos >= iMinHeight) {
165164 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;
169167 int32_t iCheckedLines;
170− int32_t iUpOffset = WELS_MIN(iSearchPos - iMinHeight, CHECK_OFFSET);
168+ int32_t iUpOffset = WELS_MIN (iSearchPos - iMinHeight, CHECK_OFFSET);
171169 int32_t i;
172170
173171 pYUpper = pYTmp - iUpOffset * iYStride;
174172 pYLineUpper = pYLine - iUpOffset * iYStride;
175− iCheckedLines = WELS_MIN(iMaxHeight - iTestPos + iUpOffset, 2 * CHECK_OFFSET);
173+ iCheckedLines = WELS_MIN (iMaxHeight - iTestPos + iUpOffset, 2 * CHECK_OFFSET);
176174
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)) {
179177 break;
180178 }
181179 pYUpper += iYStride;
182180 pYLineUpper += iYStride;
183181 }
184− if (i == iCheckedLines){
185− bScrollDetected=1;
182+ if (i == iCheckedLines) {
183+ bScrollDetected = 1;
186184 break;
187185 }
188186 }
189187 }
190188 }
191189
192− if (!bScrollDetected){
190+ if (!bScrollDetected) {
193191 sScrollDetectionParam.bScrollDetectFlag = 0;
194− }
195− else{
192+ } else {
196193 sScrollDetectionParam.bScrollDetectFlag = 1;
197194 sScrollDetectionParam.iScrollMvY = iSearchPos - iTestPos; // pre_pos - cur_pos, change to mv
198195 sScrollDetectionParam.iScrollMvX = 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t