History

Squashed commit of the following:

commit a83d75aed2fae9e0ae877642fbbd8e82b6bacca6 Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Fri Apr 4 15:40:54 2014 +0800 check makefile commit 097bd858ef46b6febda098253cc0d48e2eb0c95c Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Fri Apr 4 09:43:24 2014 +0800 add mask flag commit 34e86276000bac158abdfb839b1a5aaebac1e235 add scroll detection files

lyao2 committed 12 years ago

Commit 7cbc76d1 parent dcd38808 files · +489 −0Browse files

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

Unified · Split

codec/processing/src/scrolldetection/ScrollDetection.cpp+119−0
@@ -0,0 +1,119 @@
1+/*!
2+ * \copy
3+ * Copyright (c) 2013, Cisco Systems
4+ * All rights reserved.
5+ *
6+ * Redistribution and use in source and binary forms, with or without
7+ * modification, are permitted provided that the following conditions
8+ * are met:
9+ *
10+ * * Redistributions of source code must retain the above copyright
11+ * notice, this list of conditions and the following disclaimer.
12+ *
13+ * * Redistributions in binary form must reproduce the above copyright
14+ * notice, this list of conditions and the following disclaimer in
15+ * the documentation and/or other materials provided with the
16+ * distribution.
17+ *
18+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29+ * POSSIBILITY OF SUCH DAMAGE.
30+ *
31+ */
32+
33+
34+#include "ScrollDetection.h"
35+#include "ScrollDetectionFuncs.h"
36+#include "cpu.h"
37+
38+WELSVP_NAMESPACE_BEGIN
39+
40+EResult CScrollDetection::Process(int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap){
41+ if (pRefPixMap->pPixel[0] == NULL || pRefPixMap->pPixel[1] == NULL || pRefPixMap->pPixel[2] == NULL
42+ || pSrcPixMap->pPixel[0] == NULL || pSrcPixMap->pPixel[1] == NULL || pSrcPixMap->pPixel[2] == NULL
43+ || pRefPixMap->sRect.iRectWidth != pSrcPixMap->sRect.iRectWidth || pRefPixMap->sRect.iRectHeight != pSrcPixMap->sRect.iRectHeight){
44+ return RET_INVALIDPARAM;
45+ }
46+
47+ if (!m_sScrollDetectionParam.bMaskInfoAvailable)
48+ ScrollDetectionWithoutMask(pSrcPixMap, pRefPixMap);
49+ else
50+ ScrollDetectionWithMask(pSrcPixMap, pRefPixMap);
51+
52+ return RET_SUCCESS;
53+}
54+
55+EResult CScrollDetection::Set(int32_t iType, void *pParam){
56+ if( pParam == NULL ){
57+ return RET_INVALIDPARAM;
58+ }
59+ m_sScrollDetectionParam = *((SScrollDetectionParam*)pParam);
60+ return RET_SUCCESS;
61+}
62+
63+EResult CScrollDetection::Get(int32_t iType, void *pParam){
64+ if( pParam == NULL ){
65+ return RET_INVALIDPARAM;
66+ }
67+ *((SScrollDetectionParam*)pParam) = m_sScrollDetectionParam;
68+ return RET_SUCCESS;
69+}
70+
71+void CScrollDetection::ScrollDetectionWithMask(SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
72+ int32_t iStartX, iStartY, iWidth, iHeight;
73+
74+ iStartX = m_sScrollDetectionParam.sMaskRect.iRectLeft;
75+ iStartY = m_sScrollDetectionParam.sMaskRect.iRectTop;
76+ iWidth = m_sScrollDetectionParam.sMaskRect.iRectWidth;
77+ iHeight = m_sScrollDetectionParam.sMaskRect.iRectHeight;
78+
79+ iWidth /= 2;
80+ iStartX += iWidth/2;
81+
82+ m_sScrollDetectionParam.iScrollMvX = 0;
83+ m_sScrollDetectionParam.iScrollMvY = 0;
84+ m_sScrollDetectionParam.bScrollDetectFlag = false;
85+
86+ if(iStartX >= 0 && iWidth > MINIMUM_DETECT_WIDTH && iHeight > 2 * CHECK_OFFSET){
87+ ScrollDetectionCore(pSrcPixMap, pRefPixMap,iWidth, iHeight, iStartX, iStartY, m_sScrollDetectionParam);
88+ }
89+}
90+
91+void CScrollDetection::ScrollDetectionWithoutMask(SPixMap* pSrcPixMap, SPixMap* pRefPixMap){
92+ int32_t iStartX, iStartY, iWidth, iHeight;
93+
94+ const int32_t kiPicBorderWidth= pSrcPixMap->sRect.iRectHeight>>4;
95+ const int32_t kiRegionWidth = (int) (pSrcPixMap->sRect.iRectWidth-(kiPicBorderWidth<<1))/3;
96+ const int32_t kiRegionHeight = (pSrcPixMap->sRect.iRectHeight*7)>>3;
97+ const int32_t kiHieghtStride = (int) pSrcPixMap->sRect.iRectHeight*5/24;
98+
99+ for (int32_t i=0; i< REGION_NUMBER;i++){
100+ iStartX = kiPicBorderWidth+(i%3)*kiRegionWidth;
101+ iStartY = -pSrcPixMap->sRect.iRectHeight*7/48+ (int)(i/3)*(kiHieghtStride);
102+ iWidth = kiRegionWidth;
103+ iHeight = kiRegionHeight;
104+
105+ iWidth /= 2;
106+ iStartX += iWidth/2;
107+
108+ m_sScrollDetectionParam.iScrollMvX = 0;
109+ m_sScrollDetectionParam.iScrollMvY = 0;
110+ m_sScrollDetectionParam.bScrollDetectFlag = false;
111+
112+ ScrollDetectionCore(pSrcPixMap, pRefPixMap, iWidth, iHeight, iStartX, iStartY, m_sScrollDetectionParam);
113+
114+ if (m_sScrollDetectionParam.bScrollDetectFlag && m_sScrollDetectionParam.iScrollMvY)
115+ break;
116+ }
117+}
118+
119+WELSVP_NAMESPACE_END

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