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
Showing the changes to codec/processing/src (5 of 8 files). Show all
Unified · Split
| @@ -33,6 +33,7 @@ · 32 unmodified lines | |||
| 33 | #include "WelsFrameWork.h" | 33 | #include "WelsFrameWork.h" |
| 34 | #include "../denoise/denoise.h" | 34 | #include "../denoise/denoise.h" |
| 35 | #include "../downsample/downsample.h" | 35 | #include "../downsample/downsample.h" |
| 36 | #include "../scrolldetection/ScrollDetection.h" | ||
| 36 | #include "../scenechangedetection/SceneChangeDetection.h" | 37 | #include "../scenechangedetection/SceneChangeDetection.h" |
| 37 | #include "../vaacalc/vaacalculation.h" | 38 | #include "../vaacalc/vaacalculation.h" |
| 38 | #include "../backgrounddetection/BackgroundDetection.h" | 39 | #include "../backgrounddetection/BackgroundDetection.h" |
| @@ -265,6 +266,9 @@ IStrategy* CVpFrameWork::CreateStrategy (EMethods m_eMethod, int32_t iCpuFlag) { · 226 unmodified lines | |||
| 265 | case METHOD_DENOISE: | 266 | case METHOD_DENOISE: |
| 266 | pStrategy = WelsDynamicCast (IStrategy*, new CDenoiser (iCpuFlag)); | 267 | pStrategy = WelsDynamicCast (IStrategy*, new CDenoiser (iCpuFlag)); |
| 267 | break; | 268 | break; |
| 269 | case METHOD_SCROLL_DETECTION: | ||
| 270 | pStrategy = WelsDynamicCast (IStrategy*, new CScrollDetection(iCpuFlag)); | ||
| 271 | break; | ||
| 268 | case METHOD_SCENE_CHANGE_DETECTION_VIDEO: | 272 | case METHOD_SCENE_CHANGE_DETECTION_VIDEO: |
| 269 | case METHOD_SCENE_CHANGE_DETECTION_SCREEN: | 273 | case METHOD_SCENE_CHANGE_DETECTION_SCREEN: |
| 270 | pStrategy = BuildSceneChangeDetection(m_eMethod, iCpuFlag); | 274 | pStrategy = BuildSceneChangeDetection(m_eMethod, iCpuFlag); |
| @@ -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 | ||
| @@ -0,0 +1,73 @@ | |||
| 1 | /*! | ||
| 2 | * \copy | ||
| 3 | * Copyright (c) 2011-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 | * \file : ScrollDectection.h | ||
| 32 | * | ||
| 33 | * \brief : scroll detection class of wels video processor class | ||
| 34 | * | ||
| 35 | * \date : 2011/04/26 | ||
| 36 | * | ||
| 37 | * \description : rewrite the package code of scroll detection class | ||
| 38 | * | ||
| 39 | ************************************************************************************* | ||
| 40 | */ | ||
| 41 | |||
| 42 | #include "util.h" | ||
| 43 | #include "memory.h" | ||
| 44 | #include "WelsFrameWork.h" | ||
| 45 | #include "IWelsVP.h" | ||
| 46 | |||
| 47 | WELSVP_NAMESPACE_BEGIN | ||
| 48 | |||
| 49 | #ifdef HAVE_MMX | ||
| 50 | WELSVP_EXTERN_C_BEGIN | ||
| 51 | WELSVP_EXTERN_C_END | ||
| 52 | #endif | ||
| 53 | |||
| 54 | class CScrollDetection : public IStrategy{ | ||
| 55 | public: | ||
| 56 | CScrollDetection(int32_t iCpuFlag){ | ||
| 57 | m_eMethod = METHOD_SCROLL_DETECTION; | ||
| 58 | WelsMemset (&m_sScrollDetectionParam, 0, sizeof (m_sScrollDetectionParam)); | ||
| 59 | }; | ||
| 60 | ~CScrollDetection(){ | ||
| 61 | } | ||
| 62 | EResult Process(int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap); | ||
| 63 | EResult Set(int32_t iType, void *pParam); | ||
| 64 | EResult Get(int32_t iType, void *pParam); | ||
| 65 | |||
| 66 | private: | ||
| 67 | void ScrollDetectionWithMask(SPixMap* pSrcPixMap, SPixMap* pRefPixMap); | ||
| 68 | void ScrollDetectionWithoutMask(SPixMap* pSrcPixMap, SPixMap* pRefPixMap); | ||
| 69 | private: | ||
| 70 | SScrollDetectionParam m_sScrollDetectionParam; | ||
| 71 | }; | ||
| 72 | |||
| 73 | WELSVP_NAMESPACE_END | ||
| @@ -0,0 +1,202 @@ | |||
| 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 | #include "ScrollDetection.h" | ||
| 34 | #include "ScrollDetectionFuncs.h" | ||
| 35 | |||
| 36 | WELSVP_NAMESPACE_BEGIN | ||
| 37 | |||
| 38 | int32_t CheckLine(uint8_t* pData, int32_t iWidth){ | ||
| 39 | int32_t iQualified = 0; | ||
| 40 | int32_t iColorMap[8] = {0}; | ||
| 41 | int32_t iChangedTimes = 0; | ||
| 42 | int32_t iColorCounts = 0; | ||
| 43 | |||
| 44 | RECORD_COLOR(pData[0], iColorMap); | ||
| 45 | |||
| 46 | for (int32_t i=1; i<iWidth; i++){ | ||
| 47 | RECORD_COLOR(pData[i], iColorMap); | ||
| 48 | iChangedTimes += (pData[i] != pData[i-1]); | ||
| 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); | ||
| 53 | |||
| 54 | switch(iColorCounts){ | ||
| 55 | case 1: | ||
| 56 | iQualified = 0; | ||
| 57 | break; | ||
| 58 | case 2: | ||
| 59 | case 3: | ||
| 60 | iQualified = (iChangedTimes > 3); | ||
| 61 | break; | ||
| 62 | default: | ||
| 63 | iQualified = 1; | ||
| 64 | break; | ||
| 65 | } | ||
| 66 | return iQualified; | ||
| 67 | } | ||
| 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){ | ||
| 71 | const int32_t kiHalfHeight = iHeight >> 1; | ||
| 72 | const int32_t kiMidPos = iOffsetY + kiHalfHeight; | ||
| 73 | int32_t TestPos = kiMidPos; | ||
| 74 | int32_t iOffsetAbs; | ||
| 75 | uint8_t* pTmp; | ||
| 76 | |||
| 77 | for (iOffsetAbs = 0; iOffsetAbs < kiHalfHeight; iOffsetAbs++){ | ||
| 78 | TestPos = kiMidPos + iOffsetAbs; | ||
| 79 | if (TestPos < iPicHeight){ | ||
| 80 | pTmp = pY + TestPos * iStride + iOffsetX; | ||
| 81 | if (CheckLine(pTmp, iWidth)) break; | ||
| 82 | } | ||
| 83 | TestPos = kiMidPos - iOffsetAbs; | ||
| 84 | if(TestPos >=0){ | ||
| 85 | pTmp = pY + TestPos * iStride + iOffsetX; | ||
| 86 | if (CheckLine(pTmp, iWidth)) break; | ||
| 87 | } | ||
| 88 | } | ||
| 89 | if (iOffsetAbs == kiHalfHeight) | ||
| 90 | TestPos = -1; | ||
| 91 | return TestPos; | ||
| 92 | } | ||
| 93 | |||
| 94 | /* | ||
| 95 | * compare pixel line between previous and current one | ||
| 96 | * return: 0 for totally equal, otherwise 1 | ||
| 97 | */ | ||
| 98 | int32_t CompareLine(uint8_t *pYSrc, uint8_t *pYRef, const int32_t kiWidth) | ||
| 99 | { | ||
| 100 | int32_t iCmp = 1; | ||
| 101 | |||
| 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); | ||
| 107 | return iCmp; | ||
| 108 | } | ||
| 109 | |||
| 110 | void ScrollDetectionCore(SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidth, int32_t iHeight, | ||
| 111 | int32_t iOffsetX, int32_t iOffsetY, SScrollDetectionParam &sScrollDetectionParam){ | ||
| 112 | bool bScrollDetected = 0; | ||
| 113 | uint8_t* pYLine; | ||
| 114 | uint8_t* pYTmp; | ||
| 115 | int32_t iTestPos, iSearchPos = 0, iOffsetAbs, iMaxAbs; | ||
| 116 | 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;// | ||
| 119 | uint8_t* pYRef, *pYSrc; | ||
| 120 | int32_t iYStride; | ||
| 121 | |||
| 122 | pYRef = (uint8_t*)pRefPixMap->pPixel[0]; | ||
| 123 | pYSrc = (uint8_t*)pSrcPixMap->pPixel[0]; | ||
| 124 | iYStride = pRefPixMap->iStride[0]; | ||
| 125 | |||
| 126 | iTestPos = SelectTestLine(pYSrc, iWidth, iHeight, iPicHeight, iYStride, iOffsetX, iOffsetY); | ||
| 127 | |||
| 128 | if (iTestPos == -1){ | ||
| 129 | sScrollDetectionParam.bScrollDetectFlag = 0; | ||
| 130 | return; | ||
| 131 | } | ||
| 132 | pYLine = pYSrc + iYStride * iTestPos + iOffsetX; | ||
| 133 | iMaxAbs = WELS_MIN(WELS_MAX(iTestPos-iMinHeight-1, iMaxHeight-iTestPos),MAX_SCROLL_MV_Y); | ||
| 134 | iSearchPos = iTestPos; | ||
| 135 | for (iOffsetAbs = 0; iOffsetAbs <= iMaxAbs; iOffsetAbs++){ | ||
| 136 | iSearchPos = iTestPos + iOffsetAbs; | ||
| 137 | if (iSearchPos <= iMaxHeight){ | ||
| 138 | pYTmp = pYRef + iSearchPos * iYStride + iOffsetX; | ||
| 139 | if (!CompareLine(pYLine, pYTmp, iWidth)){ | ||
| 140 | uint8_t *pYUpper, *pYLineUpper; | ||
| 141 | int32_t iCheckedLines; | ||
| 142 | int32_t iLowOffset = WELS_MIN(iMaxHeight - iSearchPos, CHECK_OFFSET); | ||
| 143 | int32_t i; | ||
| 144 | |||
| 145 | iCheckedLines = WELS_MIN(iTestPos - iMinHeight + iLowOffset, 2 * CHECK_OFFSET); | ||
| 146 | pYUpper = pYTmp - (iCheckedLines - iLowOffset) * iYStride; | ||
| 147 | pYLineUpper = pYLine - (iCheckedLines - iLowOffset) * iYStride; | ||
| 148 | |||
| 149 | for(i = 0; i < iCheckedLines; i ++){ | ||
| 150 | if (CompareLine(pYLineUpper, pYUpper, iWidth)){ | ||
| 151 | break; | ||
| 152 | } | ||
| 153 | pYUpper += iYStride; | ||
| 154 | pYLineUpper += iYStride; | ||
| 155 | } | ||
| 156 | if (i == iCheckedLines){ | ||
| 157 | bScrollDetected=1; | ||
| 158 | break; | ||
| 159 | } | ||
| 160 | } | ||
| 161 | } | ||
| 162 | |||
| 163 | iSearchPos = iTestPos - iOffsetAbs-1; | ||
| 164 | if (iSearchPos >= iMinHeight){ | ||
| 165 | pYTmp = pYRef + iSearchPos * iYStride + iOffsetX; | ||
| 166 | if (!CompareLine(pYLine, pYTmp, iWidth)) | ||
| 167 | { | ||
| 168 | uint8_t *pYUpper, *pYLineUpper; | ||
| 169 | int32_t iCheckedLines; | ||
| 170 | int32_t iUpOffset = WELS_MIN(iSearchPos - iMinHeight, CHECK_OFFSET); | ||
| 171 | int32_t i; | ||
| 172 | |||
| 173 | pYUpper = pYTmp - iUpOffset * iYStride; | ||
| 174 | pYLineUpper = pYLine - iUpOffset * iYStride; | ||
| 175 | iCheckedLines = WELS_MIN(iMaxHeight - iTestPos + iUpOffset, 2 * CHECK_OFFSET); | ||
| 176 | |||
| 177 | for(i = 0; i < iCheckedLines; i ++){ | ||
| 178 | if (CompareLine(pYLineUpper,pYUpper, iWidth)){ | ||
| 179 | break; | ||
| 180 | } | ||
| 181 | pYUpper += iYStride; | ||
| 182 | pYLineUpper += iYStride; | ||
| 183 | } | ||
| 184 | if (i == iCheckedLines){ | ||
| 185 | bScrollDetected=1; | ||
| 186 | break; | ||
| 187 | } | ||
| 188 | } | ||
| 189 | } | ||
| 190 | } | ||
| 191 | |||
| 192 | if (!bScrollDetected){ | ||
| 193 | sScrollDetectionParam.bScrollDetectFlag = 0; | ||
| 194 | } | ||
| 195 | else{ | ||
| 196 | sScrollDetectionParam.bScrollDetectFlag = 1; | ||
| 197 | sScrollDetectionParam.iScrollMvY = iSearchPos - iTestPos; // pre_pos - cur_pos, change to mv | ||
| 198 | sScrollDetectionParam.iScrollMvX = 0; | ||
| 199 | } | ||
| 200 | } | ||
| 201 | |||
| 202 | WELSVP_NAMESPACE_END | ||
| @@ -0,0 +1,61 @@ | |||
| 1 | /*! | ||
| 2 | * \copy | ||
| 3 | * Copyright (c) 2011-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 | * \file : ScrollDetectionFuncs.h | ||
| 32 | * | ||
| 33 | * \brief : scroll detection class of wels video processor class | ||
| 34 | * | ||
| 35 | * \date : 2011/04/26 | ||
| 36 | * | ||
| 37 | * \description : rewrite the package code of scroll detection class | ||
| 38 | * | ||
| 39 | ************************************************************************************* | ||
| 40 | */ | ||
| 41 | |||
| 42 | WELSVP_NAMESPACE_BEGIN | ||
| 43 | |||
| 44 | #define MINIMUM_DETECT_WIDTH 50 // no less than 16 | ||
| 45 | #define CHECK_OFFSET 25 | ||
| 46 | #define MAX_SCROLL_MV_Y 511 | ||
| 47 | #define REGION_NUMBER 9 | ||
| 48 | #define RECORD_COLOR(a, x) \ | ||
| 49 | { \ | ||
| 50 | int32_t _t = (uint8_t)(a); \ | ||
| 51 | x[_t>>5] |= (1 << (_t&31)); \ | ||
| 52 | } | ||
| 53 | |||
| 54 | int32_t CheckLine(uint8_t* pData, int32_t iWidth); | ||
| 55 | int32_t SelectTestLine(uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPicHeight, | ||
| 56 | int32_t iStride, int32_t iOffsetX, int32_t iOffsetY); | ||
| 57 | int32_t CompareLine(uint8_t *pYSrc, uint8_t *pYRef, const int32_t kiWidth); | ||
| 58 | void ScrollDetectionCore(SPixMap* pSrcPixMap, SPixMap* pRefPixMap, int32_t iWidth, int32_t iHeight, | ||
| 59 | int32_t iOffsetX, int32_t iOffsetY, SScrollDetectionParam &sScrollDetectionParam); | ||
| 60 | |||
| 61 | WELSVP_NAMESPACE_END | ||