shithub: openh264

Download patch

ref: 7cbc76d32cc8be6606e98acb5443097fabcfb698
parent: dcd388006ed5e1aef891c71098d804891790302e
author: lyao2 <[email protected]>
date: Fri Apr 4 12:03:58 EDT 2014

Squashed commit of the following:

commit a83d75aed2fae9e0ae877642fbbd8e82b6bacca6
Author: lyao2 <[email protected]>
Date:   Fri Apr 4 15:40:54 2014 +0800

    check makefile

commit 097bd858ef46b6febda098253cc0d48e2eb0c95c
Author: lyao2 <[email protected]>
Date:   Fri Apr 4 09:43:24 2014 +0800

    add mask flag

commit 34e86276000bac158abdfb839b1a5aaebac1e235
add scroll detection files

--- a/codec/processing/build/win32/WelsVP_2008.vcproj
+++ b/codec/processing/build/win32/WelsVP_2008.vcproj
@@ -802,6 +802,26 @@
 				>
 			</File>
 		</Filter>
+		<Filter
+			Name="scrolldetection"
+			>
+			<File
+				RelativePath="..\..\src\scrolldetection\ScrollDetection.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\scrolldetection\ScrollDetection.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\scrolldetection\ScrollDetectionFuncs.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\scrolldetection\ScrollDetectionFuncs.h"
+				>
+			</File>
+		</Filter>
 	</Files>
 	<Globals>
 	</Globals>
--- a/codec/processing/interface/IWelsVP.h
+++ b/codec/processing/interface/IWelsVP.h
@@ -131,6 +131,7 @@
   METHOD_COMPLEXITY_ANALYSIS   ,
   METHOD_COMPLEXITY_ANALYSIS_SCREEN,
   METHOD_IMAGE_ROTATE		  ,
+  METHOD_SCROLL_DETECTION,
   METHOD_MASK
 } EMethods;
 
@@ -137,6 +138,13 @@
 //-----------------------------------------------------------------//
 //  Algorithm parameters define
 //-----------------------------------------------------------------//
+typedef struct{
+  SRect sMaskRect;
+  bool bMaskInfoAvailable;
+  int iScrollMvX;
+  int iScrollMvY;
+  bool bScrollDetectFlag; // 0:false ; 1:ltr; 2: scene change
+} SScrollDetectionParam;
 
 typedef enum {
   SIMILAR_SCENE,   //similar scene
--- a/codec/processing/src/common/WelsFrameWork.cpp
+++ b/codec/processing/src/common/WelsFrameWork.cpp
@@ -33,6 +33,7 @@
 #include "WelsFrameWork.h"
 #include "../denoise/denoise.h"
 #include "../downsample/downsample.h"
+#include "../scrolldetection/ScrollDetection.h"
 #include "../scenechangedetection/SceneChangeDetection.h"
 #include "../vaacalc/vaacalculation.h"
 #include "../backgrounddetection/BackgroundDetection.h"
@@ -265,6 +266,9 @@
   case METHOD_DENOISE:
     pStrategy = WelsDynamicCast (IStrategy*, new CDenoiser (iCpuFlag));
     break;
+  case METHOD_SCROLL_DETECTION:
+	pStrategy = WelsDynamicCast (IStrategy*, new CScrollDetection(iCpuFlag));
+	break;
   case METHOD_SCENE_CHANGE_DETECTION_VIDEO:
   case METHOD_SCENE_CHANGE_DETECTION_SCREEN:
     pStrategy = BuildSceneChangeDetection(m_eMethod, iCpuFlag);
--- /dev/null
+++ b/codec/processing/src/scrolldetection/ScrollDetection.cpp
@@ -1,0 +1,119 @@
+/*!
+ * \copy
+ *     Copyright (c)  2013, Cisco Systems
+ *     All rights reserved.
+ *
+ *     Redistribution and use in source and binary forms, with or without
+ *     modification, are permitted provided that the following conditions
+ *     are met:
+ *
+ *        * Redistributions of source code must retain the above copyright
+ *          notice, this list of conditions and the following disclaimer.
+ *
+ *        * Redistributions in binary form must reproduce the above copyright
+ *          notice, this list of conditions and the following disclaimer in
+ *          the documentation and/or other materials provided with the
+ *          distribution.
+ *
+ *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *     POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
+#include "ScrollDetection.h"
+#include "ScrollDetectionFuncs.h"
+#include "cpu.h"
+
+WELSVP_NAMESPACE_BEGIN
+
+EResult CScrollDetection::Process(int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap){
+  if (pRefPixMap->pPixel[0] == NULL || pRefPixMap->pPixel[1] == NULL || pRefPixMap->pPixel[2] == NULL
+    || pSrcPixMap->pPixel[0] == NULL || pSrcPixMap->pPixel[1] == NULL || pSrcPixMap->pPixel[2] == NULL
+    || pRefPixMap->sRect.iRectWidth != pSrcPixMap->sRect.iRectWidth || pRefPixMap->sRect.iRectHeight != pSrcPixMap->sRect.iRectHeight){
+  return RET_INVALIDPARAM;
+  }
+
+  if (!m_sScrollDetectionParam.bMaskInfoAvailable)
+    ScrollDetectionWithoutMask(pSrcPixMap, pRefPixMap);
+  else
+    ScrollDetectionWithMask(pSrcPixMap, pRefPixMap);
+
+  return RET_SUCCESS;
+}
+
+EResult CScrollDetection::Set(int32_t iType, void *pParam){
+  if( pParam == NULL ){
+    return RET_INVALIDPARAM;
+  }
+  m_sScrollDetectionParam = *((SScrollDetectionParam*)pParam);
+  return RET_SUCCESS;
+}
+
+EResult CScrollDetection::Get(int32_t iType, void *pParam){
+  if( pParam == NULL ){
+    return RET_INVALIDPARAM;
+  }
+  *((SScrollDetectionParam*)pParam) = m_sScrollDetectionParam;
+  return RET_SUCCESS;
+}
+
+void CScrollDetection::ScrollDetectionWithMask(SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
+  int32_t iStartX, iStartY, iWidth, iHeight;
+
+  iStartX = m_sScrollDetectionParam.sMaskRect.iRectLeft;
+  iStartY = m_sScrollDetectionParam.sMaskRect.iRectTop;
+  iWidth = m_sScrollDetectionParam.sMaskRect.iRectWidth;
+  iHeight = m_sScrollDetectionParam.sMaskRect.iRectHeight;
+
+  iWidth /= 2;
+  iStartX += iWidth/2;
+
+  m_sScrollDetectionParam.iScrollMvX = 0;
+  m_sScrollDetectionParam.iScrollMvY = 0;
+  m_sScrollDetectionParam.bScrollDetectFlag = false;
+
+  if(iStartX >= 0 && iWidth > MINIMUM_DETECT_WIDTH && iHeight > 2 * CHECK_OFFSET){
+    ScrollDetectionCore(pSrcPixMap, pRefPixMap,iWidth, iHeight, iStartX, iStartY, m_sScrollDetectionParam);
+  }
+}
+
+void CScrollDetection::ScrollDetectionWithoutMask(SPixMap* pSrcPixMap, SPixMap* pRefPixMap){
+  int32_t iStartX, iStartY, iWidth, iHeight;
+
+  const int32_t kiPicBorderWidth= pSrcPixMap->sRect.iRectHeight>>4;
+  const int32_t kiRegionWidth = (int) (pSrcPixMap->sRect.iRectWidth-(kiPicBorderWidth<<1))/3;
+  const int32_t kiRegionHeight = (pSrcPixMap->sRect.iRectHeight*7)>>3;
+  const int32_t kiHieghtStride = (int) pSrcPixMap->sRect.iRectHeight*5/24;
+
+  for (int32_t i=0; i< REGION_NUMBER;i++){
+    iStartX = kiPicBorderWidth+(i%3)*kiRegionWidth;
+    iStartY = -pSrcPixMap->sRect.iRectHeight*7/48+ (int)(i/3)*(kiHieghtStride);
+    iWidth = kiRegionWidth;
+    iHeight = kiRegionHeight;
+
+    iWidth /= 2;
+    iStartX += iWidth/2;
+
+    m_sScrollDetectionParam.iScrollMvX = 0;
+    m_sScrollDetectionParam.iScrollMvY = 0;
+    m_sScrollDetectionParam.bScrollDetectFlag = false;
+
+    ScrollDetectionCore(pSrcPixMap, pRefPixMap, iWidth, iHeight, iStartX, iStartY, m_sScrollDetectionParam);
+
+    if (m_sScrollDetectionParam.bScrollDetectFlag && m_sScrollDetectionParam.iScrollMvY)
+      break;
+  }
+}
+
+WELSVP_NAMESPACE_END
\ No newline at end of file
--- /dev/null
+++ b/codec/processing/src/scrolldetection/ScrollDetection.h
@@ -1,0 +1,73 @@
+/*!
+ * \copy
+ *     Copyright (c)  2011-2013, Cisco Systems
+ *     All rights reserved.
+ *
+ *     Redistribution and use in source and binary forms, with or without
+ *     modification, are permitted provided that the following conditions
+ *     are met:
+ *
+ *        * Redistributions of source code must retain the above copyright
+ *          notice, this list of conditions and the following disclaimer.
+ *
+ *        * Redistributions in binary form must reproduce the above copyright
+ *          notice, this list of conditions and the following disclaimer in
+ *          the documentation and/or other materials provided with the
+ *          distribution.
+ *
+ *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *     POSSIBILITY OF SUCH DAMAGE.
+ *
+* \file	        :  ScrollDectection.h
+*
+* \brief	    :  scroll detection class of wels video processor class
+*
+* \date         :  2011/04/26
+*
+* \description  :  rewrite the package code of scroll detection class
+*
+*************************************************************************************
+*/
+
+#include "util.h"
+#include "memory.h"
+#include "WelsFrameWork.h"
+#include "IWelsVP.h"
+
+WELSVP_NAMESPACE_BEGIN
+
+#ifdef HAVE_MMX
+WELSVP_EXTERN_C_BEGIN
+WELSVP_EXTERN_C_END
+#endif
+
+class CScrollDetection : public IStrategy{
+public:
+  CScrollDetection(int32_t iCpuFlag){
+    m_eMethod = METHOD_SCROLL_DETECTION;
+    WelsMemset (&m_sScrollDetectionParam, 0, sizeof (m_sScrollDetectionParam));
+  };
+  ~CScrollDetection(){
+  }
+  EResult Process(int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap);
+  EResult Set(int32_t iType, void *pParam);
+  EResult Get(int32_t iType, void *pParam);
+
+private:
+  void ScrollDetectionWithMask(SPixMap* pSrcPixMap, SPixMap* pRefPixMap);
+  void ScrollDetectionWithoutMask(SPixMap* pSrcPixMap, SPixMap* pRefPixMap);
+private:
+  SScrollDetectionParam m_sScrollDetectionParam;
+};
+
+WELSVP_NAMESPACE_END
--- /dev/null
+++ b/codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp
@@ -1,0 +1,202 @@
+/*!
+ * \copy
+ *     Copyright (c)  2013, Cisco Systems
+ *     All rights reserved.
+ *
+ *     Redistribution and use in source and binary forms, with or without
+ *     modification, are permitted provided that the following conditions
+ *     are met:
+ *
+ *        * Redistributions of source code must retain the above copyright
+ *          notice, this list of conditions and the following disclaimer.
+ *
+ *        * Redistributions in binary form must reproduce the above copyright
+ *          notice, this list of conditions and the following disclaimer in
+ *          the documentation and/or other materials provided with the
+ *          distribution.
+ *
+ *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *     POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "ScrollDetection.h"
+#include "ScrollDetectionFuncs.h"
+
+WELSVP_NAMESPACE_BEGIN
+
+int32_t CheckLine(uint8_t* pData, int32_t iWidth){
+  int32_t iQualified = 0;
+  int32_t iColorMap[8] = {0};
+  int32_t iChangedTimes = 0;
+  int32_t iColorCounts = 0;
+
+  RECORD_COLOR(pData[0], iColorMap);
+
+  for (int32_t i=1; i<iWidth; i++){
+    RECORD_COLOR(pData[i], iColorMap);
+    iChangedTimes += (pData[i] != pData[i-1]);
+  }
+  for (int32_t i=0; i<8; i++)
+    for (int32_t j=0; j<32; j++)
+      iColorCounts += ((iColorMap[i] >> j)&1);
+
+  switch(iColorCounts){
+  case 1:
+    iQualified = 0;
+    break;
+  case 2:
+  case 3:
+    iQualified = (iChangedTimes > 3);
+    break;
+  default:
+    iQualified = 1;
+    break;
+  }
+  return iQualified;
+}
+
+int32_t SelectTestLine(uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPicHeight,
+                       int32_t iStride, int32_t iOffsetX, int32_t iOffsetY){
+  const int32_t kiHalfHeight	= iHeight >> 1;
+  const int32_t kiMidPos		= iOffsetY + kiHalfHeight;
+  int32_t TestPos			= kiMidPos;
+  int32_t iOffsetAbs;
+  uint8_t* pTmp;
+
+  for (iOffsetAbs = 0; iOffsetAbs < kiHalfHeight; iOffsetAbs++){
+    TestPos = kiMidPos + iOffsetAbs;
+    if (TestPos < iPicHeight){
+      pTmp = pY + TestPos * iStride + iOffsetX;
+      if (CheckLine(pTmp, iWidth)) break;
+    }
+    TestPos = kiMidPos - iOffsetAbs;
+    if(TestPos >=0){
+      pTmp = pY + TestPos * iStride + iOffsetX;
+      if (CheckLine(pTmp, iWidth)) break;
+    }
+  }
+  if (iOffsetAbs == kiHalfHeight)
+    TestPos = -1;
+  return TestPos;
+}
+
+/*
+ * compare pixel line between previous and current one
+ * return: 0 for totally equal, otherwise 1
+ */
+int32_t CompareLine(uint8_t *pYSrc, uint8_t *pYRef, const int32_t kiWidth)
+{
+  int32_t iCmp = 1;
+
+  if ( *((int32_t*)pYSrc) != *((int32_t*)pYRef)) return 1;
+  if ( *((int32_t*)(pYSrc + 4)) != *((int32_t*)(pYRef + 4))) return 1;
+  if ( *((int32_t*)(pYSrc + 8)) != *((int32_t*)(pYRef + 8))) return 1;
+  if ( kiWidth > 12 )
+    iCmp = WelsMemcmp(pYSrc+12, pYRef+12, kiWidth-12);
+  return iCmp;
+}
+
+void ScrollDetectionCore(SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidth, int32_t iHeight,
+                         int32_t iOffsetX, int32_t iOffsetY, SScrollDetectionParam &sScrollDetectionParam){
+  bool bScrollDetected = 0;
+  uint8_t* pYLine;
+  uint8_t* pYTmp;
+  int32_t iTestPos, iSearchPos = 0, iOffsetAbs, iMaxAbs;
+  int32_t iPicHeight = pRefPixMap->sRect.iRectHeight;
+  int32_t iMinHeight = WELS_MAX(iOffsetY,0);
+  int32_t iMaxHeight = WELS_MIN(iOffsetY + iHeight - 1, iPicHeight-1) ;//offset_y + height - 1;//
+  uint8_t* pYRef, *pYSrc;
+  int32_t iYStride;
+
+  pYRef = (uint8_t*)pRefPixMap->pPixel[0];
+  pYSrc = (uint8_t*)pSrcPixMap->pPixel[0];
+  iYStride = pRefPixMap->iStride[0];
+
+  iTestPos = SelectTestLine(pYSrc, iWidth, iHeight, iPicHeight, iYStride, iOffsetX, iOffsetY);
+
+  if (iTestPos == -1){
+    sScrollDetectionParam.bScrollDetectFlag = 0;
+    return;
+  }
+  pYLine = pYSrc + iYStride * iTestPos + iOffsetX;
+  iMaxAbs = WELS_MIN(WELS_MAX(iTestPos-iMinHeight-1, iMaxHeight-iTestPos),MAX_SCROLL_MV_Y);
+  iSearchPos = iTestPos;
+  for (iOffsetAbs = 0; iOffsetAbs <= iMaxAbs; iOffsetAbs++){
+    iSearchPos = iTestPos + iOffsetAbs;
+    if (iSearchPos <= iMaxHeight){
+      pYTmp = pYRef + iSearchPos * iYStride + iOffsetX;
+      if (!CompareLine(pYLine, pYTmp, iWidth)){
+        uint8_t *pYUpper, *pYLineUpper;
+        int32_t iCheckedLines;
+        int32_t iLowOffset = WELS_MIN(iMaxHeight - iSearchPos, CHECK_OFFSET);
+        int32_t i;
+
+        iCheckedLines = WELS_MIN(iTestPos - iMinHeight + iLowOffset, 2 * CHECK_OFFSET);
+        pYUpper = pYTmp - (iCheckedLines - iLowOffset) * iYStride;
+        pYLineUpper = pYLine - (iCheckedLines - iLowOffset) * iYStride;
+
+        for(i = 0; i < iCheckedLines; i ++){
+          if (CompareLine(pYLineUpper, pYUpper, iWidth)){
+            break;
+          }
+          pYUpper += iYStride;
+          pYLineUpper += iYStride;
+        }
+        if (i == iCheckedLines){
+          bScrollDetected=1;
+          break;
+        }
+      }
+    }
+
+    iSearchPos = iTestPos - iOffsetAbs-1;
+    if (iSearchPos >= iMinHeight){
+      pYTmp = pYRef + iSearchPos * iYStride + iOffsetX;
+      if (!CompareLine(pYLine, pYTmp, iWidth))
+      {
+        uint8_t *pYUpper, *pYLineUpper;
+        int32_t iCheckedLines;
+        int32_t iUpOffset = WELS_MIN(iSearchPos - iMinHeight, CHECK_OFFSET);
+        int32_t i;
+
+        pYUpper = pYTmp - iUpOffset * iYStride;
+        pYLineUpper = pYLine - iUpOffset * iYStride;
+        iCheckedLines = WELS_MIN(iMaxHeight - iTestPos + iUpOffset, 2 * CHECK_OFFSET);
+
+        for(i = 0; i < iCheckedLines; i ++){
+          if (CompareLine(pYLineUpper,pYUpper, iWidth)){
+            break;
+          }
+          pYUpper += iYStride;
+          pYLineUpper += iYStride;
+        }
+        if (i == iCheckedLines){
+          bScrollDetected=1;
+          break;
+        }
+      }
+    }
+  }
+
+  if (!bScrollDetected){
+    sScrollDetectionParam.bScrollDetectFlag = 0;
+  }
+  else{
+    sScrollDetectionParam.bScrollDetectFlag = 1;
+    sScrollDetectionParam.iScrollMvY = iSearchPos - iTestPos; // pre_pos - cur_pos, change to mv
+    sScrollDetectionParam.iScrollMvX = 0;
+  }
+}
+
+WELSVP_NAMESPACE_END
\ No newline at end of file
--- /dev/null
+++ b/codec/processing/src/scrolldetection/ScrollDetectionFuncs.h
@@ -1,0 +1,61 @@
+/*!
+ * \copy
+ *     Copyright (c)  2011-2013, Cisco Systems
+ *     All rights reserved.
+ *
+ *     Redistribution and use in source and binary forms, with or without
+ *     modification, are permitted provided that the following conditions
+ *     are met:
+ *
+ *        * Redistributions of source code must retain the above copyright
+ *          notice, this list of conditions and the following disclaimer.
+ *
+ *        * Redistributions in binary form must reproduce the above copyright
+ *          notice, this list of conditions and the following disclaimer in
+ *          the documentation and/or other materials provided with the
+ *          distribution.
+ *
+ *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *     POSSIBILITY OF SUCH DAMAGE.
+ *
+* \file	        :  ScrollDetectionFuncs.h
+*
+* \brief	    :  scroll detection class of wels video processor class
+*
+* \date         :  2011/04/26
+*
+* \description  :  rewrite the package code of scroll detection class
+*
+*************************************************************************************
+*/
+
+WELSVP_NAMESPACE_BEGIN
+
+#define MINIMUM_DETECT_WIDTH 50  // no less than 16
+#define CHECK_OFFSET 25
+#define MAX_SCROLL_MV_Y 511
+#define REGION_NUMBER 9
+#define RECORD_COLOR(a, x)	\
+{	\
+  int32_t _t = (uint8_t)(a);	\
+  x[_t>>5] |= (1 << (_t&31)); \
+}
+
+int32_t CheckLine(uint8_t* pData, int32_t iWidth);
+int32_t SelectTestLine(uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPicHeight,
+                       int32_t iStride, int32_t iOffsetX, int32_t iOffsetY);
+int32_t CompareLine(uint8_t *pYSrc, uint8_t *pYRef, const int32_t kiWidth);
+void ScrollDetectionCore(SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidth, int32_t iHeight,
+                         int32_t iOffsetX, int32_t iOffsetY, SScrollDetectionParam &sScrollDetectionParam);
+
+WELSVP_NAMESPACE_END
\ No newline at end of file
--- a/codec/processing/targets.mk
+++ b/codec/processing/targets.mk
@@ -14,6 +14,8 @@
 	$(PROCESSING_SRCDIR)/src/imagerotate/imagerotate.cpp\
 	$(PROCESSING_SRCDIR)/src/imagerotate/imagerotatefuncs.cpp\
 	$(PROCESSING_SRCDIR)/src/scenechangedetection/SceneChangeDetection.cpp\
+	$(PROCESSING_SRCDIR)/src/scrolldetection/ScrollDetection.cpp\
+	$(PROCESSING_SRCDIR)/src/scrolldetection/ScrollDetectionFuncs.cpp\
 	$(PROCESSING_SRCDIR)/src/vaacalc/vaacalcfuncs.cpp\
 	$(PROCESSING_SRCDIR)/src/vaacalc/vaacalculation.cpp\