ref: 9722adfe09c17ffc5cf1bf31cf2e768e160006fb
parent: 62139f09819f7e09a713fae90aa09c7c22db582f
parent: 4751fe7690d44635bf919da02930b369daa0dc1b
author: Licai Guo <[email protected]>
date: Fri Mar 28 12:40:28 EDT 2014
Merge pull request #596 from ruil2/enc_processing add scene change detection in workflow for screen content
--- a/codec/encoder/core/inc/wels_preprocess.h
+++ b/codec/encoder/core/inc/wels_preprocess.h
@@ -161,6 +161,7 @@
void WelsMoveMemoryWrapper (SWelsSvcCodingParam* pSvcParam, SPicture* pDstPic, const SSourcePicture* kpSrc,
const int32_t kiWidth, const int32_t kiHeight);
+ ESceneChangeIdc DetectSceneChangeScreen(sWelsEncCtx* pCtx,SPicture* pCurPicture);
private:
Scaled_Picture m_sScaledPicture;
SPicture* m_pLastSpatialPicture[MAX_DEPENDENCY_LAYER][2];
--- a/codec/encoder/core/src/wels_preprocess.cpp
+++ b/codec/encoder/core/src/wels_preprocess.cpp
@@ -442,14 +442,22 @@
}
DownsamplePadding (pSrcPic, pDstPic, iSrcWidth, iSrcHeight, iShrinkWidth, iShrinkHeight, iTargetWidth, iTargetHeight);
- if (pSvcParam->bEnableSceneChangeDetect && !pCtx->pVaa->bIdrPeriodFlag
- && !pCtx->bEncCurFrmAsIdrFlag
- && ! (pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1))) {
- SPicture* pRefPic = pCtx->pLtr[iDependencyId].bReceivedT0LostFlag ?
+ if (pSvcParam->bEnableSceneChangeDetect && !pCtx->pVaa->bIdrPeriodFlag){
+ if(pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
+ {
+ pCtx->pVaa->eSceneChangeIdc = (pCtx->bEncCurFrmAsIdrFlag ? LARGE_CHANGED_SCENE: DetectSceneChangeScreen(pCtx,pDstPic));
+ pCtx->pVaa->bSceneChangeFlag = ( LARGE_CHANGED_SCENE == pCtx->pVaa->eSceneChangeIdc);
+ }
+ else
+ {
+ if((!pCtx->bEncCurFrmAsIdrFlag )&& ! (pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1))) {
+ SPicture* pRefPic = pCtx->pLtr[iDependencyId].bReceivedT0LostFlag ?
m_pSpatialPic[iDependencyId][m_uiSpatialLayersInTemporal[iDependencyId] +
pCtx->pVaa->uiValidLongTermPicIdx] : m_pLastSpatialPicture[iDependencyId][0];
- pCtx->pVaa->bSceneChangeFlag = DetectSceneChange (pDstPic, pRefPic);
+ pCtx->pVaa->bSceneChangeFlag = DetectSceneChange (pDstPic, pRefPic);
+ }
+ }
}
for (int32_t i = 0; i < pSvcParam->iSpatialLayerNum; i++) {
@@ -893,6 +901,33 @@
}
}
+
+ESceneChangeIdc CWelsPreProcess::DetectSceneChangeScreen(sWelsEncCtx* pCtx,SPicture* pCurPicture)
+{
+#define STATIC_SCENE_MOTION_RATIO 0.01f
+ SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
+ SVAAFrameInfoExt *pVaaExt = static_cast<SVAAFrameInfoExt *>(pCtx->pVaa);
+ if ( NULL==pCtx || NULL == pVaaExt || NULL== pCurPicture)
+ {
+ return LARGE_CHANGED_SCENE;
+ }
+
+ const int32_t iTargetDid = pSvcParam->iSpatialLayerNum-1;
+ if ( 0!= iTargetDid )
+ {
+ return LARGE_CHANGED_SCENE;
+ }
+
+ ESceneChangeIdc iVaaFrameSceneChangeIdc = LARGE_CHANGED_SCENE;
+
+ SPicture **pSrcPicList = &m_pSpatialPic[iTargetDid][1];
+ if ( NULL==pSrcPicList )
+ {
+ return LARGE_CHANGED_SCENE;
+ }
+
+ return static_cast<ESceneChangeIdc>(iVaaFrameSceneChangeIdc);
+}
void CWelsPreProcess::Padding (uint8_t* pSrcY, uint8_t* pSrcU, uint8_t* pSrcV, int32_t iStrideY, int32_t iStrideUV,
int32_t iActualWidth, int32_t iPaddingWidth, int32_t iActualHeight, int32_t iPaddingHeight) {
int32_t i;