|
|
|
|
@@ -242,14 +242,9 @@ int32_t CWelsPreProcess::AnalyzeSpatialPic (sWelsEncCtx* pCtx, const int32_t kiD
|
|
|
|
|
|
|
|
|
|
AdaptiveQuantCalculation (pCtx->pVaa, pCurPic, pRefPic);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(pSvcParam->iUsageType != SCREEN_CONTENT_REAL_TIME){
|
|
|
|
|
if (pSvcParam->iRCMode != RC_OFF_MODE) {
|
|
|
|
|
AnalyzePictureComplexity (pCtx, pCurPic, pRefPic, kiDidx, bCalculateBGD);
|
|
|
|
|
}
|
|
|
|
|
WelsExchangeSpatialPictures (&m_pLastSpatialPicture[kiDidx][1], &m_pLastSpatialPicture[kiDidx][0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -723,11 +718,66 @@ void CWelsPreProcess::SetRefMbType (sWelsEncCtx* pCtx, uint32_t** pRefMbTypeArra
|
|
|
|
|
void CWelsPreProcess::AnalyzePictureComplexity (sWelsEncCtx* pCtx, SPicture* pCurPicture, SPicture* pRefPicture,
|
|
|
|
|
const int32_t kiDependencyId, const bool bCalculateBGD) {
|
|
|
|
|
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
|
|
|
|
|
SVAAFrameInfo* pVaaInfo = pCtx->pVaa;
|
|
|
|
|
int32_t iComplexityAnalysisMode = 0;
|
|
|
|
|
|
|
|
|
|
if (pSvcParam->iRCMode == RC_OFF_MODE)
|
|
|
|
|
return;
|
|
|
|
|
if (pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
|
|
|
|
|
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa);
|
|
|
|
|
SComplexityAnalysisScreenParam* sComplexityAnalysisParam = &pVaaExt->sComplexityScreenParam;
|
|
|
|
|
SWelsSvcRc* pWelsSvcRc = &pCtx->pWelsSvcRc[kiDependencyId];
|
|
|
|
|
|
|
|
|
|
if (pCtx->eSliceType == P_SLICE)
|
|
|
|
|
iComplexityAnalysisMode = GOM_SAD;
|
|
|
|
|
else if (pCtx->eSliceType == I_SLICE)
|
|
|
|
|
iComplexityAnalysisMode = GOM_VAR;
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
memset (pWelsSvcRc->pGomForegroundBlockNum, 0, pWelsSvcRc->iGomSize * sizeof (int32_t));
|
|
|
|
|
memset (pWelsSvcRc->pCurrentFrameGomSad, 0, pWelsSvcRc->iGomSize * sizeof (int32_t));
|
|
|
|
|
|
|
|
|
|
sComplexityAnalysisParam->iFrameComplexity = 0;
|
|
|
|
|
sComplexityAnalysisParam->pGomComplexity = pWelsSvcRc->pCurrentFrameGomSad;
|
|
|
|
|
sComplexityAnalysisParam->iGomNumInFrame = pWelsSvcRc->iGomSize;
|
|
|
|
|
sComplexityAnalysisParam->iIdrFlag = (pCtx->eSliceType == I_SLICE);
|
|
|
|
|
sComplexityAnalysisParam->iMbRowInGom = GOM_H_SCC;
|
|
|
|
|
sComplexityAnalysisParam->sScrollResult.bScrollDetectFlag = false;
|
|
|
|
|
sComplexityAnalysisParam->sScrollResult.iScrollMvX = 0;
|
|
|
|
|
sComplexityAnalysisParam->sScrollResult.iScrollMvY = 0;
|
|
|
|
|
|
|
|
|
|
const int32_t iMethodIdx = METHOD_COMPLEXITY_ANALYSIS_SCREEN;
|
|
|
|
|
SPixMap sSrcPixMap;
|
|
|
|
|
SPixMap sRefPixMap;
|
|
|
|
|
memset (&sSrcPixMap, 0, sizeof (SPixMap));
|
|
|
|
|
memset (&sRefPixMap, 0, sizeof (SPixMap));
|
|
|
|
|
int32_t iRet = 0;
|
|
|
|
|
|
|
|
|
|
sSrcPixMap.pPixel[0] = pCurPicture->pData[0];
|
|
|
|
|
sSrcPixMap.iSizeInBits = g_kiPixMapSizeInBits;
|
|
|
|
|
sSrcPixMap.iStride[0] = pCurPicture->iLineSize[0];
|
|
|
|
|
sSrcPixMap.sRect.iRectWidth = pCurPicture->iWidthInPixel;
|
|
|
|
|
sSrcPixMap.sRect.iRectHeight = pCurPicture->iHeightInPixel;
|
|
|
|
|
sSrcPixMap.eFormat = VIDEO_FORMAT_I420;
|
|
|
|
|
|
|
|
|
|
if (pRefPicture != NULL) {
|
|
|
|
|
sRefPixMap.pPixel[0] = pRefPicture->pData[0];
|
|
|
|
|
sRefPixMap.iSizeInBits = g_kiPixMapSizeInBits;
|
|
|
|
|
sRefPixMap.iStride[0] = pRefPicture->iLineSize[0];
|
|
|
|
|
sRefPixMap.sRect.iRectWidth = pRefPicture->iWidthInPixel;
|
|
|
|
|
sRefPixMap.sRect.iRectHeight = pRefPicture->iHeightInPixel;
|
|
|
|
|
sRefPixMap.eFormat = VIDEO_FORMAT_I420;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iRet = m_pInterfaceVp->Set (iMethodIdx, (void*)sComplexityAnalysisParam);
|
|
|
|
|
iRet = m_pInterfaceVp->Process (iMethodIdx, &sSrcPixMap, &sRefPixMap);
|
|
|
|
|
if (iRet == 0)
|
|
|
|
|
m_pInterfaceVp->Get (iMethodIdx, (void*)sComplexityAnalysisParam);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
SVAAFrameInfo* pVaaInfo = pCtx->pVaa;
|
|
|
|
|
SComplexityAnalysisParam* sComplexityAnalysisParam = & (pVaaInfo->sComplexityAnalysisParam);
|
|
|
|
|
SWelsSvcRc* SWelsSvcRc = &pCtx->pWelsSvcRc[kiDependencyId];
|
|
|
|
|
int32_t iComplexityAnalysisMode = 0;
|
|
|
|
|
|
|
|
|
|
if (pSvcParam->iRCMode == RC_QUALITY_MODE && pCtx->eSliceType == P_SLICE) {
|
|
|
|
|
iComplexityAnalysisMode = FRAME_SAD;
|
|
|
|
|
@@ -738,7 +788,6 @@ void CWelsPreProcess::AnalyzePictureComplexity (sWelsEncCtx* pCtx, SPicture* pCu
|
|
|
|
|
} else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sComplexityAnalysisParam->iComplexityAnalysisMode = iComplexityAnalysisMode;
|
|
|
|
|
sComplexityAnalysisParam->pCalcResult = & (pVaaInfo->sVaaCalcInfo);
|
|
|
|
|
sComplexityAnalysisParam->pBackgroundMbFlag = pVaaInfo->pVaaBackgroundMbFlag;
|
|
|
|
|
@@ -782,6 +831,7 @@ void CWelsPreProcess::AnalyzePictureComplexity (sWelsEncCtx* pCtx, SPicture* pCu
|
|
|
|
|
m_pInterfaceVp->Get (iMethodIdx, (void*)sComplexityAnalysisParam);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CWelsPreProcess::InitPixMap (const SPicture* pPicture, SPixMap* pPixMap) {
|
|
|
|
|
@@ -1007,8 +1057,7 @@ ESceneChangeIdc CWelsPreProcess::DetectSceneChangeScreen (sWelsEncCtx* pCtx, SPi
|
|
|
|
|
return static_cast<ESceneChangeIdc> (iVaaFrameSceneChangeIdc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t CWelsPreProcess::GetRefCandidateLtrIndex(int32_t iRefIdx)
|
|
|
|
|
{
|
|
|
|
|
int32_t CWelsPreProcess::GetRefCandidateLtrIndex (int32_t iRefIdx) {
|
|
|
|
|
const int32_t iTargetDid = m_pEncCtx->pSvcParam->iSpatialLayerNum - 1;
|
|
|
|
|
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (m_pEncCtx->pVaa);
|
|
|
|
|
SRefInfoParam* BestRefCandidateParam = & (pVaaExt->sVaaStrBestRefCandidate[iRefIdx]);
|
|
|
|
|
|