History

add scene change detector for further extension

volvet committed 12 years ago

Commit d7b74191 parent 62be92c5 files · +112 −113Browse files

Showing the changes to codec/processing/src/scenechangedetection/SceneChangeDetection.cpp (1 of 5 files). Show all

Unified · Split

codec/processing/src/scenechangedetection/SceneChangeDetection.cpp+10−101
@@ -35,108 +35,17 @@ · 34 unmodified lines
3535
3636 WELSVP_NAMESPACE_BEGIN
3737
38−#define HIGH_MOTION_BLOCK_THRESHOLD 320
39−#define SCENE_CHANGE_MOTION_RATIO 0.85f
40−
41−
42−
43−///////////////////////////////////////////////////////////////////////////////////////////////////////////////
44−
45−CSceneChangeDetection::CSceneChangeDetection (int32_t iCpuFlag) {
46− m_iCpuFlag = iCpuFlag;
47− m_eMethod = METHOD_SCENE_CHANGE_DETECTION;
48− m_pfSad = NULL;
49− WelsMemset (&m_sSceneChangeParam, 0, sizeof (m_sSceneChangeParam));
50− InitSadFuncs (m_pfSad, m_iCpuFlag);
51−}
52−
53−CSceneChangeDetection::~CSceneChangeDetection() {
54−}
55−
56−EResult CSceneChangeDetection::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
57− EResult eReturn = RET_INVALIDPARAM;
58−
59− int32_t iWidth = pSrcPixMap->sRect.iRectWidth;
60− int32_t iHeight = pSrcPixMap->sRect.iRectHeight;
61− int32_t iBlock8x8Width = iWidth >> 3;
62− int32_t iBlock8x8Height = iHeight >> 3;
63− int32_t iBlock8x8Num = iBlock8x8Width * iBlock8x8Height;
64− int32_t iSceneChangeThreshold = WelsStaticCast (int32_t, SCENE_CHANGE_MOTION_RATIO * iBlock8x8Num + 0.5f + PESN);
65−
66− int32_t iBlockSad = 0;
67− int32_t iMotionBlockNum = 0;
68−
69− uint8_t* pRefY = NULL, *pCurY = NULL;
70− int32_t iRefStride = 0, iCurStride = 0;
71− int32_t iRefRowStride = 0, iCurRowStride = 0;
72−
73− uint8_t* pRefTmp = NULL, *pCurTmp = NULL;
74−
75− pRefY = (uint8_t*)pRefPixMap->pPixel[0];
76− pCurY = (uint8_t*)pSrcPixMap->pPixel[0];
77−
78− iRefStride = pRefPixMap->iStride[0];
79− iCurStride = pSrcPixMap->iStride[0];
80−
81− iRefRowStride = pRefPixMap->iStride[0] << 3;
82− iCurRowStride = pSrcPixMap->iStride[0] << 3;
83−
84− m_sSceneChangeParam.eSceneChangeIdc = SIMILAR_SCENE;
85−
86− for (int32_t j = 0; j < iBlock8x8Height; j ++) {
87− pRefTmp = pRefY;
88− pCurTmp = pCurY;
89−
90− for (int32_t i = 0; i < iBlock8x8Width; i++) {
91− iBlockSad = m_pfSad (pRefTmp, iRefStride, pCurTmp, iCurStride);
92−
93− iMotionBlockNum += (iBlockSad > HIGH_MOTION_BLOCK_THRESHOLD);
94−
95− pRefTmp += 8;
96− pCurTmp += 8;
97− }
98−
99− pRefY += iRefRowStride;
100− pCurY += iCurRowStride;
101− }
102−
103− if (iMotionBlockNum >= iSceneChangeThreshold) {
104− m_sSceneChangeParam.eSceneChangeIdc = LARGE_CHANGED_SCENE;
105− }
106−
107− eReturn = RET_SUCCESS;
108−
109− return eReturn;
110−}
111−
112−
113−EResult CSceneChangeDetection::Get (int32_t iType, void* pParam) {
114− if (pParam == NULL) {
115− return RET_INVALIDPARAM;
116− }
117−
118− * (SSceneChangeResult*)pParam = m_sSceneChangeParam;
119−
120− return RET_SUCCESS;
121−}
122−
123−///////////////////////////////////////////////////////////////////////////////////////////////
124−
125−void CSceneChangeDetection::InitSadFuncs (SadFuncPtr& pfSad, int32_t iCpuFlag) {
126− pfSad = WelsSampleSad8x8_c;
127−
128−#ifdef X86_ASM
129− if (iCpuFlag & WELS_CPU_SSE2) {
130− pfSad = WelsSampleSad8x8_sse21;
131− }
132−#endif
133−
134−#ifdef HAVE_NEON
135− if (iCpuFlag & WELS_CPU_NEON) {
136− pfSad = WelsProcessingSampleSad8x8_neon;
38+IStrategy * BuildSceneChangeDetection(EMethods eMethod, int32_t iCpuFlag){
39+ switch(eMethod){
40+ case METHOD_SCENE_CHANGE_DETECTION_VIDEO:
41+ return new CSceneChangeDetection<CSceneChangeDetectorVideo>(eMethod, iCpuFlag);
42+ break;
43+ case METHOD_SCENE_CHANGE_DETECTION_SCREEN:
44+ default:
45+ // not support yet
46+ return NULL;
13747 }
138−#endif
13948 }
14049
141−
14250 WELSVP_NAMESPACE_END
51+

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