Merge pull request #728 from ruil2/enc_type2

add decide frame type for screen content
This commit is contained in:
Licai Guo 2014-04-22 10:15:25 +08:00
commit f5eb6d4fdc
3 changed files with 65 additions and 24 deletions

View File

@ -285,6 +285,41 @@ EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum
EVideoFrameType iFrameType = videoFrameTypeInvalid;
bool bSceneChangeFlag = false;
if (pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
if ((!pSvcParam->bEnableSceneChangeDetect) || pEncCtx->pVaa->bIdrPeriodFlag ||
(kiSpatialNum < pSvcParam->iSpatialLayerNum)) {
bSceneChangeFlag = false;
} else {
bSceneChangeFlag = pEncCtx->pVaa->bSceneChangeFlag;
}
pEncCtx->bCurFrameMarkedAsSceneLtr = false;
if (pEncCtx->pVaa->bIdrPeriodFlag || pEncCtx->bEncCurFrmAsIdrFlag || (!pSvcParam->bEnableLongTermReference
&& bSceneChangeFlag)) {
iFrameType = videoFrameTypeIDR;
} else if (pSvcParam->bEnableLongTermReference && (bSceneChangeFlag
|| pEncCtx->pVaa->eSceneChangeIdc == LARGE_CHANGED_SCENE)) {
int iActualLtrcount = 0;
SPicture** pLongTermRefList = pEncCtx->ppRefPicListExt[0]->pLongRefList;
for (int i = 0; i < pSvcParam->iLTRRefNum; ++i) {
if (NULL != pLongTermRefList[i] && pLongTermRefList[i]->bUsedAsRef && pLongTermRefList[i]->bIsLongRef
&& pLongTermRefList[i]->bIsSceneLTR) {
++iActualLtrcount;
}
}
if (iActualLtrcount == pSvcParam->iLTRRefNum && bSceneChangeFlag) {
iFrameType = videoFrameTypeIDR;
} else {
iFrameType = videoFrameTypeP;
pEncCtx->bCurFrameMarkedAsSceneLtr = true;
}
} else {
iFrameType = videoFrameTypeP;
}
if (videoFrameTypeIDR == iFrameType) {
pEncCtx->iCodingIndex = 0;
pEncCtx->bCurFrameMarkedAsSceneLtr = true;
}
} else {
// perform scene change detection
if ((!pSvcParam->bEnableSceneChangeDetect) || pEncCtx->pVaa->bIdrPeriodFlag ||
(kiSpatialNum < pSvcParam->iSpatialLayerNum)
@ -306,7 +341,7 @@ EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum
} else if (videoFrameTypeIDR == iFrameType) {
pEncCtx->iCodingIndex = 0;
}
}
return iFrameType;
}

View File

@ -599,6 +599,8 @@ bool WelsBuildRefList (void* pEncCtx, const int32_t iPOC, int32_t iBestLtrRefIdx
SPicture* pRef = pRefList->pShortRefList[i];
if (pRef != NULL && pRef->bUsedAsRef && pRef->iFramePoc >= 0 && pRef->uiTemporalId <= kuiTid) {
pCtx->pRefList0[pCtx->iNumRef0++] = pRef;
WelsLog (pCtx, WELS_LOG_INFO, "WelsBuildRefList pCtx->uiTemporalId = %d,pRef->iFrameNum = %d,pRef->uiTemporalId = %d\n",
pCtx->uiTemporalId,pRef->iFrameNum,pRef->uiTemporalId);
break;
}
}
@ -770,6 +772,8 @@ bool WelsBuildRefListScreen (void* pEncCtx, const int32_t iPOC, int32_t iBestLtr
"WelsBuildRefListScreen(), ref !current iFrameNum = %d, ref iFrameNum = %d,LTR number = %d,iNumRef = %d ref is Scene LTR = %d\n",
pCtx->iFrameNum, pCtx->pRefList0[pCtx->iNumRef0 - 1]->iFrameNum, pRefList->uiLongRefCount, iNumRef,
pRefPic->bIsSceneLTR);
WelsLog (pCtx, WELS_LOG_INFO, "WelsBuildRefListScreen pCtx->uiTemporalId = %d,pRef->iFrameNum = %d,pRef->uiTemporalId = %d\n",
pCtx->uiTemporalId,pRefPic->iFrameNum,pRefPic->uiTemporalId);
}
}
} else {

View File

@ -1047,6 +1047,8 @@ ESceneChangeIdc CWelsPreProcess::DetectSceneChangeScreen (sWelsEncCtx* pCtx, SPi
iVaaFrameSceneChangeIdc = SIMILAR_SCENE;
}
WelsLog(pCtx,WELS_LOG_INFO,"iVaaFrameSceneChangeIdc = %d,codingIdx = %d\n",iVaaFrameSceneChangeIdc,pCtx->iCodingIndex);
SaveBestRefToVaa (sLtrSaved, & (pVaaExt->sVaaStrBestRefCandidate[0]));
if (0 == iAvailableSceneRefNum) {