Merge pull request #635 from lyao2/new_scroll_dev
add scroll detection files
This commit is contained in:
commit
a758282ee7
@ -802,6 +802,26 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</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>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
|
@ -131,12 +131,20 @@ typedef enum {
|
|||||||
METHOD_COMPLEXITY_ANALYSIS ,
|
METHOD_COMPLEXITY_ANALYSIS ,
|
||||||
METHOD_COMPLEXITY_ANALYSIS_SCREEN,
|
METHOD_COMPLEXITY_ANALYSIS_SCREEN,
|
||||||
METHOD_IMAGE_ROTATE ,
|
METHOD_IMAGE_ROTATE ,
|
||||||
|
METHOD_SCROLL_DETECTION,
|
||||||
METHOD_MASK
|
METHOD_MASK
|
||||||
} EMethods;
|
} EMethods;
|
||||||
|
|
||||||
//-----------------------------------------------------------------//
|
//-----------------------------------------------------------------//
|
||||||
// Algorithm parameters define
|
// 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 {
|
typedef enum {
|
||||||
SIMILAR_SCENE, //similar scene
|
SIMILAR_SCENE, //similar scene
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "WelsFrameWork.h"
|
#include "WelsFrameWork.h"
|
||||||
#include "../denoise/denoise.h"
|
#include "../denoise/denoise.h"
|
||||||
#include "../downsample/downsample.h"
|
#include "../downsample/downsample.h"
|
||||||
|
#include "../scrolldetection/ScrollDetection.h"
|
||||||
#include "../scenechangedetection/SceneChangeDetection.h"
|
#include "../scenechangedetection/SceneChangeDetection.h"
|
||||||
#include "../vaacalc/vaacalculation.h"
|
#include "../vaacalc/vaacalculation.h"
|
||||||
#include "../backgrounddetection/BackgroundDetection.h"
|
#include "../backgrounddetection/BackgroundDetection.h"
|
||||||
@ -265,6 +266,9 @@ IStrategy* CVpFrameWork::CreateStrategy (EMethods m_eMethod, int32_t iCpuFlag) {
|
|||||||
case METHOD_DENOISE:
|
case METHOD_DENOISE:
|
||||||
pStrategy = WelsDynamicCast (IStrategy*, new CDenoiser (iCpuFlag));
|
pStrategy = WelsDynamicCast (IStrategy*, new CDenoiser (iCpuFlag));
|
||||||
break;
|
break;
|
||||||
|
case METHOD_SCROLL_DETECTION:
|
||||||
|
pStrategy = WelsDynamicCast (IStrategy*, new CScrollDetection(iCpuFlag));
|
||||||
|
break;
|
||||||
case METHOD_SCENE_CHANGE_DETECTION_VIDEO:
|
case METHOD_SCENE_CHANGE_DETECTION_VIDEO:
|
||||||
case METHOD_SCENE_CHANGE_DETECTION_SCREEN:
|
case METHOD_SCENE_CHANGE_DETECTION_SCREEN:
|
||||||
pStrategy = BuildSceneChangeDetection(m_eMethod, iCpuFlag);
|
pStrategy = BuildSceneChangeDetection(m_eMethod, iCpuFlag);
|
||||||
|
@ -28,16 +28,16 @@
|
|||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* \file : SceneChangeDetection.h
|
* \file : SceneChangeDetection.h
|
||||||
*
|
*
|
||||||
* \brief : scene change detection class of wels video processor class
|
* \brief : scene change detection class of wels video processor class
|
||||||
*
|
*
|
||||||
* \date : 2011/03/14
|
* \date : 2011/03/14
|
||||||
*
|
*
|
||||||
* \description : 1. rewrite the package code of scene change detection class
|
* \description : 1. rewrite the package code of scene change detection class
|
||||||
*
|
*
|
||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WELSVP_SCENECHANGEDETECTION_H
|
#ifndef WELSVP_SCENECHANGEDETECTION_H
|
||||||
#define WELSVP_SCENECHANGEDETECTION_H
|
#define WELSVP_SCENECHANGEDETECTION_H
|
||||||
|
119
codec/processing/src/scrolldetection/ScrollDetection.cpp
Normal file
119
codec/processing/src/scrolldetection/ScrollDetection.cpp
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/*!
|
||||||
|
* \copy
|
||||||
|
* Copyright (c) 2009-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
|
73
codec/processing/src/scrolldetection/ScrollDetection.h
Normal file
73
codec/processing/src/scrolldetection/ScrollDetection.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*!
|
||||||
|
* \copy
|
||||||
|
* Copyright (c) 2009-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
|
202
codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp
Normal file
202
codec/processing/src/scrolldetection/ScrollDetectionFuncs.cpp
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
/*!
|
||||||
|
* \copy
|
||||||
|
* Copyright (c) 2009-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
|
61
codec/processing/src/scrolldetection/ScrollDetectionFuncs.h
Normal file
61
codec/processing/src/scrolldetection/ScrollDetectionFuncs.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*!
|
||||||
|
* \copy
|
||||||
|
* Copyright (c) 2009-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
|
@ -14,6 +14,8 @@ PROCESSING_CPP_SRCS=\
|
|||||||
$(PROCESSING_SRCDIR)/src/imagerotate/imagerotate.cpp\
|
$(PROCESSING_SRCDIR)/src/imagerotate/imagerotate.cpp\
|
||||||
$(PROCESSING_SRCDIR)/src/imagerotate/imagerotatefuncs.cpp\
|
$(PROCESSING_SRCDIR)/src/imagerotate/imagerotatefuncs.cpp\
|
||||||
$(PROCESSING_SRCDIR)/src/scenechangedetection/SceneChangeDetection.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/vaacalcfuncs.cpp\
|
||||||
$(PROCESSING_SRCDIR)/src/vaacalc/vaacalculation.cpp\
|
$(PROCESSING_SRCDIR)/src/vaacalc/vaacalculation.cpp\
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user