enable Scroll detection into workflow
This commit is contained in:
@@ -104,9 +104,8 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct SVAAFrameInfoExt_t: public SVAAFrameInfo {
|
typedef struct SVAAFrameInfoExt_t: public SVAAFrameInfo {
|
||||||
SComplexityAnalysisScreenParam sComplexityScreenParam;
|
SComplexityAnalysisScreenParam sComplexityScreenParam;
|
||||||
SScrollDetectionResult sScrollDetectInfo;
|
SScrollDetectionParam sScrollDetectInfo;
|
||||||
//TOP3_BEST_REF_NO_TID
|
SRefInfoParam sVaaStrBestRefCandidate[MAX_REF_PIC_COUNT]; //TOP3_BEST_REF_NO_TID
|
||||||
SRefInfoParam sVaaStrBestRefCandidate[MAX_REF_PIC_COUNT];
|
|
||||||
int32_t iNumOfAvailableRef;
|
int32_t iNumOfAvailableRef;
|
||||||
|
|
||||||
uint8_t* pVaaBestBlockStaticIdc;//pointer
|
uint8_t* pVaaBestBlockStaticIdc;//pointer
|
||||||
|
|||||||
@@ -997,7 +997,8 @@ ESceneChangeIdc CWelsPreProcess::DetectSceneChangeScreen (sWelsEncCtx* pCtx, SPi
|
|||||||
for (iScdIdx = 0; iScdIdx < iAvailableRefNum; iScdIdx ++) {
|
for (iScdIdx = 0; iScdIdx < iAvailableRefNum; iScdIdx ++) {
|
||||||
pCurBlockStaticPointer = pVaaExt->pVaaBlockStaticIdc[iScdIdx];
|
pCurBlockStaticPointer = pVaaExt->pVaaBlockStaticIdc[iScdIdx];
|
||||||
sSceneChangeResult.eSceneChangeIdc = SIMILAR_SCENE;
|
sSceneChangeResult.eSceneChangeIdc = SIMILAR_SCENE;
|
||||||
sSceneChangeResult.pStaticBlockIdc = pCurBlockStaticPointer;//
|
sSceneChangeResult.pStaticBlockIdc = pCurBlockStaticPointer;
|
||||||
|
sSceneChangeResult.sScrollResult.bScrollDetectFlag = false;
|
||||||
|
|
||||||
pRefPicInfo = & (sAvailableRefList[iScdIdx]);
|
pRefPicInfo = & (sAvailableRefList[iScdIdx]);
|
||||||
assert (NULL != pRefPicInfo);
|
assert (NULL != pRefPicInfo);
|
||||||
@@ -1005,8 +1006,22 @@ ESceneChangeIdc CWelsPreProcess::DetectSceneChangeScreen (sWelsEncCtx* pCtx, SPi
|
|||||||
InitPixMap (pRefPic, &sRefMap);
|
InitPixMap (pRefPic, &sRefMap);
|
||||||
|
|
||||||
bIsClosestLtrFrame = (pRefPic->iLongTermPicNum == iClosestLtrFrameNum);
|
bIsClosestLtrFrame = (pRefPic->iLongTermPicNum == iClosestLtrFrameNum);
|
||||||
|
if (0 == iScdIdx) {
|
||||||
|
int32_t ret = 1;
|
||||||
|
SScrollDetectionParam* pScrollDetectInfo = & (pVaaExt->sScrollDetectInfo);
|
||||||
|
memset (pScrollDetectInfo, 0, sizeof (SScrollDetectionParam));
|
||||||
|
|
||||||
|
int32_t iMethodIdx = METHOD_SCROLL_DETECTION;
|
||||||
|
|
||||||
|
m_pInterfaceVp->Set (iMethodIdx, (void*) (pScrollDetectInfo));
|
||||||
|
ret = m_pInterfaceVp->Process (iMethodIdx, &sSrcMap, &sRefMap);
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
m_pInterfaceVp->Get (iMethodIdx, (void*) (pScrollDetectInfo));
|
||||||
|
}
|
||||||
|
sSceneChangeResult.sScrollResult = pVaaExt->sScrollDetectInfo;
|
||||||
|
}
|
||||||
|
|
||||||
//TBD scrolling detection
|
|
||||||
m_pInterfaceVp->Set (iSceneChangeMethodIdx, (void*) (&sSceneChangeResult));
|
m_pInterfaceVp->Set (iSceneChangeMethodIdx, (void*) (&sSceneChangeResult));
|
||||||
ret = m_pInterfaceVp->Process (iSceneChangeMethodIdx, &sSrcMap, &sRefMap);
|
ret = m_pInterfaceVp->Process (iSceneChangeMethodIdx, &sSrcMap, &sRefMap);
|
||||||
|
|
||||||
|
|||||||
@@ -138,13 +138,6 @@ typedef enum {
|
|||||||
//-----------------------------------------------------------------//
|
//-----------------------------------------------------------------//
|
||||||
// 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
|
||||||
@@ -159,11 +152,20 @@ typedef enum {
|
|||||||
BLOCK_STATIC_IDC_ALL,
|
BLOCK_STATIC_IDC_ALL,
|
||||||
} EStaticBlockIdc;
|
} EStaticBlockIdc;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SRect sMaskRect;
|
||||||
|
bool bMaskInfoAvailable;
|
||||||
|
int iScrollMvX;
|
||||||
|
int iScrollMvY;
|
||||||
|
bool bScrollDetectFlag; // 0:false ; 1:ltr; 2: scene change
|
||||||
|
} SScrollDetectionParam;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ESceneChangeIdc eSceneChangeIdc; // SIMILAR_SCENE, MEDIUM_CHANGED_SCENE, LARGE_CHANGED_SCENE
|
ESceneChangeIdc eSceneChangeIdc; // SIMILAR_SCENE, MEDIUM_CHANGED_SCENE, LARGE_CHANGED_SCENE
|
||||||
int iMotionBlockNum; // Number of motion blocks
|
int iMotionBlockNum; // Number of motion blocks
|
||||||
int iFrameComplexity; // frame complexity
|
int iFrameComplexity; // frame complexity
|
||||||
unsigned char* pStaticBlockIdc; // static block idc
|
unsigned char* pStaticBlockIdc; // static block idc
|
||||||
|
SScrollDetectionParam sScrollResult; //results from scroll detection
|
||||||
} SSceneChangeResult;
|
} SSceneChangeResult;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -216,12 +218,6 @@ typedef enum {
|
|||||||
GOM_VAR = -2
|
GOM_VAR = -2
|
||||||
} EComplexityAnalysisMode;
|
} EComplexityAnalysisMode;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int iScrollMvX;
|
|
||||||
int iScrollMvY;
|
|
||||||
bool bScrollDetectFlag; // 0:false ; 1:ltr; 2: scene change
|
|
||||||
} SScrollDetectionResult;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int iComplexityAnalysisMode;
|
int iComplexityAnalysisMode;
|
||||||
int iCalcBgd;
|
int iCalcBgd;
|
||||||
@@ -240,7 +236,7 @@ typedef struct {
|
|||||||
int iGomNumInFrame;
|
int iGomNumInFrame;
|
||||||
int iFrameComplexity;
|
int iFrameComplexity;
|
||||||
int iIdrFlag;
|
int iIdrFlag;
|
||||||
SScrollDetectionResult sScrollResult;
|
SScrollDetectionParam sScrollResult;
|
||||||
} SComplexityAnalysisScreenParam;
|
} SComplexityAnalysisScreenParam;
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,18 @@
|
|||||||
|
|
||||||
WELSVP_NAMESPACE_BEGIN
|
WELSVP_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t iWidth;
|
||||||
|
int32_t iHeight;
|
||||||
|
int32_t iBlock8x8Width;
|
||||||
|
int32_t iBlock8x8Height;
|
||||||
|
uint8_t* pRefY;
|
||||||
|
uint8_t* pCurY;
|
||||||
|
int32_t iRefStride;
|
||||||
|
int32_t iCurStride;
|
||||||
|
uint8_t* pStaticBlockIdc;
|
||||||
|
} SLocalParam;
|
||||||
|
|
||||||
class CSceneChangeDetectorVideo {
|
class CSceneChangeDetectorVideo {
|
||||||
public:
|
public:
|
||||||
CSceneChangeDetectorVideo (SSceneChangeResult& sParam, int32_t iCpuFlag) : m_sParam (sParam) {
|
CSceneChangeDetectorVideo (SSceneChangeResult& sParam, int32_t iCpuFlag) : m_sParam (sParam) {
|
||||||
@@ -72,9 +84,27 @@ class CSceneChangeDetectorVideo {
|
|||||||
}
|
}
|
||||||
virtual ~CSceneChangeDetectorVideo() {
|
virtual ~CSceneChangeDetectorVideo() {
|
||||||
}
|
}
|
||||||
void operator() (uint8_t* pSrcY, int32_t iSrcStrideY, uint8_t* pRefY, int32_t iRefStrideY, uint8_t*& pStaticBlockIdc) {
|
void operator() (SLocalParam& sLocalParam) {
|
||||||
int32_t iSad = m_pfSad (pSrcY, iSrcStrideY, pRefY, iSrcStrideY);
|
int32_t iRefRowStride = 0, iCurRowStride = 0;
|
||||||
m_sParam.iMotionBlockNum += iSad > HIGH_MOTION_BLOCK_THRESHOLD;
|
uint8_t* pRefY = sLocalParam.pRefY;
|
||||||
|
uint8_t* pCurY = sLocalParam.pCurY;
|
||||||
|
uint8_t* pRefTmp = NULL, *pCurTmp = NULL;
|
||||||
|
|
||||||
|
iRefRowStride = sLocalParam.iRefStride << 3;
|
||||||
|
iCurRowStride = sLocalParam.iCurStride << 3;
|
||||||
|
|
||||||
|
for (int32_t j = 0; j < sLocalParam.iBlock8x8Height; j++) {
|
||||||
|
pRefTmp = pRefY;
|
||||||
|
pCurTmp = pCurY;
|
||||||
|
for (int32_t i = 0; i < sLocalParam.iBlock8x8Width; i++) {
|
||||||
|
int32_t iSad = m_pfSad (pCurTmp, sLocalParam.iCurStride, pRefTmp, sLocalParam.iRefStride);
|
||||||
|
m_sParam.iMotionBlockNum += iSad > HIGH_MOTION_BLOCK_THRESHOLD;
|
||||||
|
pRefTmp += 8;
|
||||||
|
pCurTmp += 8;
|
||||||
|
}
|
||||||
|
pRefY += iRefRowStride;
|
||||||
|
pCurY += iCurRowStride;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
SadFuncPtr m_pfSad;
|
SadFuncPtr m_pfSad;
|
||||||
@@ -88,14 +118,53 @@ class CSceneChangeDetectorScreen : public CSceneChangeDetectorVideo {
|
|||||||
}
|
}
|
||||||
virtual ~CSceneChangeDetectorScreen() {
|
virtual ~CSceneChangeDetectorScreen() {
|
||||||
}
|
}
|
||||||
void operator() (uint8_t* pSrcY, int32_t iSrcStrideY, uint8_t* pRefY, int32_t iRefStrideY, uint8_t*& pStaticBlockIdc) {
|
void operator() (SLocalParam& sLocalParam) {
|
||||||
int32_t iSad = m_pfSad (pSrcY, iSrcStrideY, pRefY, iSrcStrideY);
|
bool bScrollDetectFlag = m_sParam.sScrollResult.bScrollDetectFlag;
|
||||||
if (iSad == 0) {
|
int32_t iScrollMvX = m_sParam.sScrollResult.iScrollMvX;
|
||||||
*pStaticBlockIdc ++ = COLLOCATED_STATIC;
|
int32_t iScrollMvY = m_sParam.sScrollResult.iScrollMvY;
|
||||||
} else {
|
|
||||||
m_sParam.iFrameComplexity += iSad;
|
int32_t iRefRowStride = 0, iCurRowStride = 0;
|
||||||
m_sParam.iMotionBlockNum += iSad > HIGH_MOTION_BLOCK_THRESHOLD;
|
uint8_t* pRefY = sLocalParam.pRefY;
|
||||||
*pStaticBlockIdc ++ = NO_STATIC;
|
uint8_t* pCurY = sLocalParam.pCurY;
|
||||||
|
uint8_t* pRefTmp = NULL, *pCurTmp = NULL;
|
||||||
|
int32_t iWidth = sLocalParam.iWidth;
|
||||||
|
int32_t iHeight = sLocalParam.iHeight;
|
||||||
|
|
||||||
|
iRefRowStride = sLocalParam.iRefStride << 3;
|
||||||
|
iCurRowStride = sLocalParam.iCurStride << 3;
|
||||||
|
|
||||||
|
for (int32_t j = 0; j < sLocalParam.iBlock8x8Height; j++) {
|
||||||
|
pRefTmp = pRefY;
|
||||||
|
pCurTmp = pCurY;
|
||||||
|
for (int32_t i = 0; i < sLocalParam.iBlock8x8Width; i++) {
|
||||||
|
int32_t iBlockPointX = i << 3;
|
||||||
|
int32_t iBlockPointY = j << 3;
|
||||||
|
uint8_t uiBlockIdcTmp = NO_STATIC;
|
||||||
|
int32_t iSad = m_pfSad (pCurTmp, sLocalParam.iCurStride, pRefTmp, sLocalParam.iRefStride);
|
||||||
|
if (iSad == 0) {
|
||||||
|
uiBlockIdcTmp = COLLOCATED_STATIC;
|
||||||
|
} else if (bScrollDetectFlag && (!iScrollMvX || !iScrollMvY) && (iBlockPointX + iScrollMvX >= 0)
|
||||||
|
&& (iBlockPointX + iScrollMvX <= iWidth - 8) &&
|
||||||
|
(iBlockPointY + iScrollMvY >= 0) && (iBlockPointY + iScrollMvY <= iHeight - 8)) {
|
||||||
|
uint8_t* pRefTmpScroll = pRefTmp + iScrollMvY * sLocalParam.iRefStride + iScrollMvX;
|
||||||
|
int32_t iSadScroll = m_pfSad (pCurTmp, sLocalParam.iCurStride, pRefTmpScroll, sLocalParam.iRefStride);
|
||||||
|
|
||||||
|
if (iSadScroll == 0) {
|
||||||
|
uiBlockIdcTmp = SCROLLED_STATIC;
|
||||||
|
} else {
|
||||||
|
m_sParam.iFrameComplexity += iSad;
|
||||||
|
m_sParam.iMotionBlockNum += iSad > HIGH_MOTION_BLOCK_THRESHOLD;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_sParam.iFrameComplexity += iSad;
|
||||||
|
m_sParam.iMotionBlockNum += iSad > HIGH_MOTION_BLOCK_THRESHOLD;
|
||||||
|
}
|
||||||
|
* (sLocalParam.pStaticBlockIdc) ++ = uiBlockIdcTmp;
|
||||||
|
pRefTmp += 8;
|
||||||
|
pCurTmp += 8;
|
||||||
|
}
|
||||||
|
pRefY += iRefRowStride;
|
||||||
|
pCurY += iCurRowStride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -113,47 +182,28 @@ class CSceneChangeDetection : public IStrategy {
|
|||||||
|
|
||||||
EResult Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
|
EResult Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
|
||||||
EResult eReturn = RET_INVALIDPARAM;
|
EResult eReturn = RET_INVALIDPARAM;
|
||||||
int32_t iWidth = pSrcPixMap->sRect.iRectWidth;
|
|
||||||
int32_t iHeight = pSrcPixMap->sRect.iRectHeight;
|
m_sLocalParam.iWidth = pSrcPixMap->sRect.iRectWidth;
|
||||||
int32_t iBlock8x8Width = iWidth >> 3;
|
m_sLocalParam.iHeight = pSrcPixMap->sRect.iRectHeight;
|
||||||
int32_t iBlock8x8Height = iHeight >> 3;
|
m_sLocalParam.iBlock8x8Width = m_sLocalParam.iWidth >> 3;
|
||||||
int32_t iBlock8x8Num = iBlock8x8Width * iBlock8x8Height;
|
m_sLocalParam.iBlock8x8Height = m_sLocalParam.iHeight >> 3;
|
||||||
|
m_sLocalParam.pRefY = (uint8_t*)pRefPixMap->pPixel[0];
|
||||||
|
m_sLocalParam.pCurY = (uint8_t*)pSrcPixMap->pPixel[0];
|
||||||
|
m_sLocalParam.iRefStride = pRefPixMap->iStride[0];
|
||||||
|
m_sLocalParam.iCurStride = pSrcPixMap->iStride[0];
|
||||||
|
m_sLocalParam.pStaticBlockIdc = m_sSceneChangeParam.pStaticBlockIdc;
|
||||||
|
|
||||||
|
int32_t iBlock8x8Num = m_sLocalParam.iBlock8x8Width * m_sLocalParam.iBlock8x8Height;
|
||||||
int32_t iSceneChangeThresholdLarge = WelsStaticCast (int32_t,
|
int32_t iSceneChangeThresholdLarge = WelsStaticCast (int32_t,
|
||||||
SCENE_CHANGE_MOTION_RATIO_LARGE * iBlock8x8Num + 0.5f + PESN);
|
SCENE_CHANGE_MOTION_RATIO_LARGE * iBlock8x8Num + 0.5f + PESN);
|
||||||
int32_t iSceneChangeThresholdMedium = WelsStaticCast (int32_t,
|
int32_t iSceneChangeThresholdMedium = WelsStaticCast (int32_t,
|
||||||
SCENE_CHANGE_MOTION_RATIO_MEDIUM * iBlock8x8Num + 0.5f + PESN);
|
SCENE_CHANGE_MOTION_RATIO_MEDIUM * iBlock8x8Num + 0.5f + PESN);
|
||||||
uint8_t* pRefY = NULL, *pCurY = NULL;
|
|
||||||
int32_t iRefStride = 0, iCurStride = 0;
|
|
||||||
int32_t iRefRowStride = 0, iCurRowStride = 0;
|
|
||||||
uint8_t* pRefTmp = NULL, *pCurTmp = NULL;
|
|
||||||
uint8_t* pStaticBlockIdc = m_sSceneChangeParam.pStaticBlockIdc;
|
|
||||||
|
|
||||||
pRefY = (uint8_t*)pRefPixMap->pPixel[0];
|
|
||||||
pCurY = (uint8_t*)pSrcPixMap->pPixel[0];
|
|
||||||
|
|
||||||
iRefStride = pRefPixMap->iStride[0];
|
|
||||||
iCurStride = pSrcPixMap->iStride[0];
|
|
||||||
|
|
||||||
iRefRowStride = pRefPixMap->iStride[0] << 3;
|
|
||||||
iCurRowStride = pSrcPixMap->iStride[0] << 3;
|
|
||||||
|
|
||||||
m_sSceneChangeParam.iMotionBlockNum = 0;
|
m_sSceneChangeParam.iMotionBlockNum = 0;
|
||||||
m_sSceneChangeParam.iFrameComplexity = 0;
|
m_sSceneChangeParam.iFrameComplexity = 0;
|
||||||
m_sSceneChangeParam.eSceneChangeIdc = SIMILAR_SCENE;
|
m_sSceneChangeParam.eSceneChangeIdc = SIMILAR_SCENE;
|
||||||
|
|
||||||
for (int32_t j = 0; j < iBlock8x8Height; j ++) {
|
m_cDetector (m_sLocalParam);
|
||||||
pRefTmp = pRefY;
|
|
||||||
pCurTmp = pCurY;
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < iBlock8x8Width; i++) {
|
|
||||||
m_cDetector (pRefTmp, iRefStride, pCurTmp, iCurStride, pStaticBlockIdc);
|
|
||||||
pRefTmp += 8;
|
|
||||||
pCurTmp += 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
pRefY += iRefRowStride;
|
|
||||||
pCurY += iCurRowStride;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_sSceneChangeParam.iMotionBlockNum >= iSceneChangeThresholdLarge) {
|
if (m_sSceneChangeParam.iMotionBlockNum >= iSceneChangeThresholdLarge) {
|
||||||
m_sSceneChangeParam.eSceneChangeIdc = LARGE_CHANGED_SCENE;
|
m_sSceneChangeParam.eSceneChangeIdc = LARGE_CHANGED_SCENE;
|
||||||
@@ -183,6 +233,7 @@ class CSceneChangeDetection : public IStrategy {
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
SSceneChangeResult m_sSceneChangeParam;
|
SSceneChangeResult m_sSceneChangeParam;
|
||||||
|
SLocalParam m_sLocalParam;
|
||||||
T m_cDetector;
|
T m_cDetector;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -105,10 +105,6 @@ void CScrollDetection::ScrollDetectionWithoutMask (SPixMap* pSrcPixMap, SPixMap*
|
|||||||
iWidth /= 2;
|
iWidth /= 2;
|
||||||
iStartX += 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);
|
ScrollDetectionCore (pSrcPixMap, pRefPixMap, iWidth, iHeight, iStartX, iStartY, m_sScrollDetectionParam);
|
||||||
|
|
||||||
if (m_sScrollDetectionParam.bScrollDetectFlag && m_sScrollDetectionParam.iScrollMvY)
|
if (m_sScrollDetectionParam.bScrollDetectFlag && m_sScrollDetectionParam.iScrollMvY)
|
||||||
|
|||||||
Reference in New Issue
Block a user