fix dependency ID mapping issue
This commit is contained in:
parent
39c2fb3d6b
commit
e3c306608c
@ -810,7 +810,7 @@ int ProcessEncoding (ISVCEncoder* pPtrEnc, int argc, char** argv, bool bConfigFi
|
||||
sSvcParam.iPicHeight = (!sSvcParam.iPicHeight) ? iSourceHeight : sSvcParam.iPicHeight;
|
||||
|
||||
iTotalFrameMax = (int32_t)fs.uiFrameToBeCoded;
|
||||
|
||||
// sSvcParam.bSimulcastAVC = true;
|
||||
if (cmResultSuccess != pPtrEnc->InitializeExt (&sSvcParam)) { // SVC encoder initialization
|
||||
fprintf (stderr, "SVC encoder Initialize failed\n");
|
||||
iRet = 1;
|
||||
|
@ -1754,7 +1754,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa
|
||||
return 1;
|
||||
}
|
||||
|
||||
(*ppCtx)->pReferenceStrategy = IWelsReferenceStrategy::CreateReferenceStrategy((*ppCtx), pParam->iUsageType, pParam->bEnableLongTermReference);
|
||||
(*ppCtx)->pReferenceStrategy = IWelsReferenceStrategy::CreateReferenceStrategy ((*ppCtx), pParam->iUsageType,
|
||||
pParam->bEnableLongTermReference);
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pReferenceStrategy), FreeMemorySvc (ppCtx))
|
||||
|
||||
(*ppCtx)->pIntra4x4PredModeBlocks = static_cast<int8_t*>
|
||||
@ -1946,7 +1947,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) {
|
||||
ReleaseMtResource (ppCtx);
|
||||
|
||||
if (NULL != pCtx->pReferenceStrategy) {
|
||||
WELS_DELETE_OP(pCtx->pReferenceStrategy);
|
||||
WELS_DELETE_OP (pCtx->pReferenceStrategy);
|
||||
}
|
||||
|
||||
// frame bitstream pBuffer
|
||||
@ -3453,7 +3454,6 @@ EVideoFrameType PrepareEncodeFrame (sWelsEncCtx* pCtx, SLayerBSInfo*& pLayerBsIn
|
||||
int32_t& iLayerNum, int32_t& iFrameSize, long long uiTimeStamp) {
|
||||
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
|
||||
SSpatialPicIndex* pSpatialIndexMap = &pCtx->sSpatialIndexMap[0];
|
||||
|
||||
if (!pSvcParam->bSimulcastAVC) {
|
||||
pCtx->iSkipFrameFlag = false;
|
||||
for (int32_t iDid = 0; iDid < iSpatialNum; iDid++) {
|
||||
@ -3461,8 +3461,6 @@ EVideoFrameType PrepareEncodeFrame (sWelsEncCtx* pCtx, SLayerBSInfo*& pLayerBsIn
|
||||
pCtx->iSkipFrameFlag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EVideoFrameType eFrameType = DecideFrameType (pCtx, iSpatialNum, iCurDid);
|
||||
|
||||
if (eFrameType == videoFrameTypeSkip) {
|
||||
@ -3502,12 +3500,6 @@ EVideoFrameType PrepareEncodeFrame (sWelsEncCtx* pCtx, SLayerBSInfo*& pLayerBsIn
|
||||
pCtx->iContinualSkipFrames = 0;
|
||||
iCurTid = GetTemporalLevel (&pSvcParam->sDependencyLayers[iCurDid], pParamInternal->iCodingIndex,
|
||||
pSvcParam->uiGopSize);
|
||||
//skip this spatial layer
|
||||
if (iCurTid == INVALID_TEMPORAL_ID) {
|
||||
pParamInternal->iCodingIndex ++;
|
||||
eFrameType = videoFrameTypeSkip;
|
||||
pLayerBsInfo->eFrameType = videoFrameTypeSkip;
|
||||
} else {
|
||||
pCtx->uiTemporalId = iCurTid;
|
||||
if (eFrameType == videoFrameTypeIDR) {
|
||||
// write parameter sets bitstream or SEI/SSEI (if any) here
|
||||
@ -3526,11 +3518,16 @@ EVideoFrameType PrepareEncodeFrame (sWelsEncCtx* pCtx, SLayerBSInfo*& pLayerBsIn
|
||||
++ pCtx->uiIdrPicId;
|
||||
}
|
||||
}
|
||||
if (!pSvcParam->bSimulcastAVC) {
|
||||
for (int32_t i = 0; i < pSvcParam->iSpatialLayerNum; i++) {
|
||||
SSpatialLayerInternal* pParamInternal = &pSvcParam->sDependencyLayers[i];
|
||||
pParamInternal->iCodingIndex ++;
|
||||
}
|
||||
} else {
|
||||
SSpatialLayerInternal* pParamInternal = &pSvcParam->sDependencyLayers[iCurDid];
|
||||
pParamInternal->iCodingIndex++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return eFrameType;
|
||||
}
|
||||
/*!
|
||||
@ -3608,8 +3605,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
||||
InitBitStream (pCtx);
|
||||
pLayerBsInfo->pBsBuf = pCtx->pFrameBs ;
|
||||
pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen;
|
||||
|
||||
pCtx->pCurDqLayer = pCtx->ppDqLayerList[pSpatialIndexMap->iDid];
|
||||
iCurDid = pSpatialIndexMap->iDid;
|
||||
pCtx->pCurDqLayer = pCtx->ppDqLayerList[iCurDid];
|
||||
pCtx->pCurDqLayer->pRefLayer = NULL;
|
||||
if (!pSvcParam->bSimulcastAVC) {
|
||||
eFrameType = PrepareEncodeFrame (pCtx, pLayerBsInfo, iSpatialNum , iCurDid, iCurTid, iLayerNum, iFrameSize,
|
||||
@ -3617,9 +3614,16 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
||||
if (eFrameType == videoFrameTypeSkip) {
|
||||
pFbi->eFrameType = videoFrameTypeSkip;
|
||||
pLayerBsInfo->eFrameType = videoFrameTypeSkip;
|
||||
|
||||
return ENC_RETURN_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
for (int32_t iDidIdx = 0; iDidIdx < pSvcParam->iSpatialLayerNum; iDidIdx++) {
|
||||
SSpatialLayerInternal* pParamInternal = &pSvcParam->sDependencyLayers[iDidIdx];
|
||||
int32_t iTemporalId = GetTemporalLevel (pParamInternal, pParamInternal->iCodingIndex,
|
||||
pSvcParam->uiGopSize);
|
||||
if (iTemporalId == INVALID_TEMPORAL_ID)
|
||||
pParamInternal->iCodingIndex ++;
|
||||
}
|
||||
}
|
||||
|
||||
while (iSpatialIdx < iSpatialNum) {
|
||||
@ -3713,7 +3717,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
||||
|
||||
WelsInitCurrentLayer (pCtx, iCurWidth, iCurHeight);
|
||||
|
||||
pCtx->pReferenceStrategy->MarkPic ();
|
||||
pCtx->pReferenceStrategy->MarkPic();
|
||||
if (!pCtx->pReferenceStrategy->BuildRefList (pParamInternal->iPOC, 0)) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING,
|
||||
"WelsEncoderEncodeExt(), WelsBuildRefList failed for P frames, pCtx->iNumRef0= %d. ForceCodingIDR!",
|
||||
@ -3723,7 +3727,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
||||
break;
|
||||
}
|
||||
if (pCtx->eSliceType != I_SLICE) {
|
||||
pCtx->pReferenceStrategy->AfterBuildRefList ();
|
||||
pCtx->pReferenceStrategy->AfterBuildRefList();
|
||||
}
|
||||
#ifdef LONG_TERM_REF_DUMP
|
||||
DumpRef (pCtx);
|
||||
@ -3981,7 +3985,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
||||
|
||||
// reference picture list update
|
||||
if (eNalRefIdc != NRI_PRI_LOWEST) {
|
||||
if (!pCtx->pReferenceStrategy->UpdateRefList ()) {
|
||||
if (!pCtx->pReferenceStrategy->UpdateRefList()) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "WelsEncoderEncodeExt(), WelsUpdateRefList failed. ForceCodingIDR!");
|
||||
//the above is to set the next frame to be IDR
|
||||
pCtx->iEncoderError = ENC_RETURN_CORRECTED;
|
||||
@ -4155,7 +4159,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
||||
&& (pCtx->pLtr[pCtx->uiDependencyId].iLTRMarkMode == LTR_DIRECT_MARK)) || eFrameType == videoFrameTypeIDR)) {
|
||||
pCtx->bRefOfCurTidIsLtr[iCurDid][iCurTid] = true;
|
||||
}
|
||||
++ pParamInternal->iCodingIndex;
|
||||
// ++ pParamInternal->iCodingIndex;
|
||||
}//end of (iSpatialIdx/iSpatialNum)
|
||||
|
||||
if (ENC_RETURN_CORRECTED == pCtx->iEncoderError) {
|
||||
|
@ -785,18 +785,20 @@ bool CheckFrameSkipBasedMaxbr (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, EVideo
|
||||
if (true == pEncCtx->pWelsSvcRc[iDidIdx].bSkipFlag) {
|
||||
bSkipMustFlag = true;
|
||||
pEncCtx->pWelsSvcRc[iDidIdx].uiLastTimeStamp = uiTimeStamp;
|
||||
pEncCtx->pWelsSvcRc[iDidIdx].bSkipFlag = false;
|
||||
pEncCtx->iContinualSkipFrames++;
|
||||
}
|
||||
}else{
|
||||
for(int32_t i = 0;i<iSpatialNum;i++){
|
||||
if (UNSPECIFIED_BIT_RATE == pEncCtx->pSvcParam->sSpatialLayers[i].iMaxSpatialBitrate)
|
||||
break;
|
||||
iDidIdx = (pSpatialIndexMap + i)->iDid;
|
||||
if (UNSPECIFIED_BIT_RATE == pEncCtx->pSvcParam->sSpatialLayers[iDidIdx].iMaxSpatialBitrate)
|
||||
break;
|
||||
pEncCtx->pFuncList->pfRc.pfWelsRcPicDelayJudge (pEncCtx, eFrameType, uiTimeStamp,iDidIdx);
|
||||
if (true == pEncCtx->pWelsSvcRc[i].bSkipFlag) {
|
||||
if (true == pEncCtx->pWelsSvcRc[iDidIdx].bSkipFlag) {
|
||||
bSkipMustFlag = true;
|
||||
pEncCtx->pWelsSvcRc[i].uiLastTimeStamp = uiTimeStamp;
|
||||
pEncCtx->pWelsSvcRc[iDidIdx].uiLastTimeStamp = uiTimeStamp;
|
||||
pEncCtx->iContinualSkipFrames++;
|
||||
pEncCtx->pWelsSvcRc[iDidIdx].bSkipFlag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1285,7 +1287,7 @@ void InitRcModuleTimeStamp (sWelsEncCtx* pEncCtx) {
|
||||
pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO;
|
||||
}
|
||||
void WelsRcFrameDelayJudgeTimeStamp (sWelsEncCtx* pEncCtx, EVideoFrameType eFrameType, long long uiTimeStamp,int32_t iDidIdx) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[iDidIdx];
|
||||
SSpatialLayerConfig* pDLayerConfig = &pEncCtx->pSvcParam->sSpatialLayers[iDidIdx];
|
||||
|
||||
if (pDLayerConfig->iSpatialBitrate > pDLayerConfig->iMaxSpatialBitrate)
|
||||
@ -1300,6 +1302,11 @@ void WelsRcFrameDelayJudgeTimeStamp (sWelsEncCtx* pEncCtx, EVideoFrameType eFram
|
||||
int32_t iSentBits = (int32_t) ((double)iBitRate * iEncTimeInv * (1.0E-3) + 0.5);
|
||||
iSentBits = WELS_MAX (iSentBits, 0);
|
||||
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"WelsRcFrameDelayJudgeTimeStamp AiDidIdx = %d,iSkipFrameNum = %d,buffer = %" PRId64
|
||||
",threadhold = %d,bitrate = %d,iSentBits = %d,lasttimestamp = %lld,timestamp=%lld\n",iDidIdx,
|
||||
pWelsSvcRc->iSkipFrameNum, pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferSizeSkip, iBitRate, iSentBits,
|
||||
pWelsSvcRc->uiLastTimeStamp, uiTimeStamp);
|
||||
//When bitrate is changed, pBuffer size should be updated
|
||||
pWelsSvcRc->iBufferSizeSkip = WELS_DIV_ROUND (pDLayerConfig->iSpatialBitrate * pWelsSvcRc->iSkipBufferRatio,
|
||||
INT_MULTIPLY);
|
||||
@ -1319,8 +1326,8 @@ void WelsRcFrameDelayJudgeTimeStamp (sWelsEncCtx* pEncCtx, EVideoFrameType eFram
|
||||
}
|
||||
}
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"WelsRcFrameDelayJudgeTimeStamp iSkipFrameNum = %d,buffer = %" PRId64
|
||||
",threadhold = %d,bitrate = %d,iSentBits = %d,lasttimestamp = %lld,timestamp=%lld\n",
|
||||
"WelsRcFrameDelayJudgeTimeStamp iDidIdx = %d,iSkipFrameNum = %d,buffer = %" PRId64
|
||||
",threadhold = %d,bitrate = %d,iSentBits = %d,lasttimestamp = %lld,timestamp=%lld\n",iDidIdx,
|
||||
pWelsSvcRc->iSkipFrameNum, pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferSizeSkip, iBitRate, iSentBits,
|
||||
pWelsSvcRc->uiLastTimeStamp, uiTimeStamp);
|
||||
}
|
||||
@ -1451,7 +1458,6 @@ void WelsRcPictureInfoUpdateGomTimeStamp (sWelsEncCtx* pEncCtx, int32_t iLayerS
|
||||
//condition 1: whole pBuffer fullness
|
||||
pWelsSvcRc->iBufferFullnessSkip += pWelsSvcRc->iFrameDqBits;
|
||||
|
||||
|
||||
if (pEncCtx->pSvcParam->iPaddingFlag)
|
||||
RcVBufferCalculationPadding (pEncCtx);
|
||||
pWelsSvcRc->iFrameCodedInVGop++;
|
||||
|
@ -109,7 +109,7 @@ int32_t CWelsPreProcess::WelsPreprocessDestroy() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CWelsPreProcess::WelsPreprocessReset (sWelsEncCtx* pCtx,int32_t iWidth,int32_t iHeight) {
|
||||
int32_t CWelsPreProcess::WelsPreprocessReset (sWelsEncCtx* pCtx, int32_t iWidth, int32_t iHeight) {
|
||||
int32_t iRet = -1;
|
||||
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
|
||||
//init source width and height
|
||||
@ -118,7 +118,8 @@ int32_t CWelsPreProcess::WelsPreprocessReset (sWelsEncCtx* pCtx,int32_t iWidth,i
|
||||
pSvcParam->SUsedPicRect.iWidth = iWidth;
|
||||
pSvcParam->SUsedPicRect.iHeight = iHeight;
|
||||
if ((iWidth < 16) || ((iHeight < 16))) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "Don't support width(%d) or height(%d) which is less than 16 ",iWidth, iHeight);
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "Don't support width(%d) or height(%d) which is less than 16 ", iWidth,
|
||||
iHeight);
|
||||
return iRet;
|
||||
}
|
||||
if (pCtx) {
|
||||
@ -191,7 +192,7 @@ int32_t CWelsPreProcess::BuildSpatialPicList (sWelsEncCtx* pCtx, const SSourcePi
|
||||
if (WelsPreprocessCreate() != 0)
|
||||
return -1;
|
||||
|
||||
if (WelsPreprocessReset (pCtx,iWidth,iHeight) != 0)
|
||||
if (WelsPreprocessReset (pCtx, iWidth, iHeight) != 0)
|
||||
return -1;
|
||||
|
||||
m_iAvaliableRefInSpatialPicList = pSvcParam->iNumRefFrame;
|
||||
@ -199,7 +200,7 @@ int32_t CWelsPreProcess::BuildSpatialPicList (sWelsEncCtx* pCtx, const SSourcePi
|
||||
m_bInitDone = true;
|
||||
} else {
|
||||
if ((iWidth != pSvcParam->SUsedPicRect.iWidth) || (iHeight != pSvcParam->SUsedPicRect.iHeight)) {
|
||||
if (WelsPreprocessReset (pCtx,iWidth,iHeight) != 0)
|
||||
if (WelsPreprocessReset (pCtx, iWidth, iHeight) != 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -331,8 +332,7 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
|
||||
pDlayerParam = &pSvcParam->sSpatialLayers[iDependencyId];
|
||||
iTargetWidth = pDlayerParam->iVideoWidth;
|
||||
iTargetHeight = pDlayerParam->iVideoHeight;
|
||||
iTemporalId = pDlayerParamInternal->uiCodingIdx2TemporalId[pDlayerParamInternal->iCodingIndex &
|
||||
(pSvcParam->uiGopSize - 1)];
|
||||
|
||||
iSrcWidth = pSvcParam->SUsedPicRect.iWidth;
|
||||
iSrcHeight = pSvcParam->SUsedPicRect.iHeight;
|
||||
if (pSvcParam->uiIntraPeriod)
|
||||
@ -376,14 +376,28 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < pSvcParam->iSpatialLayerNum; i++) {
|
||||
pDlayerParamInternal = &pSvcParam->sDependencyLayers[i];
|
||||
iTemporalId = pDlayerParamInternal->uiCodingIdx2TemporalId[pDlayerParamInternal->iCodingIndex &
|
||||
(pSvcParam->uiGopSize - 1)];
|
||||
if (iTemporalId != INVALID_TEMPORAL_ID) {
|
||||
++ iSpatialNum;
|
||||
}
|
||||
}
|
||||
pDlayerParamInternal = &pSvcParam->sDependencyLayers[iDependencyId];
|
||||
iTemporalId = pDlayerParamInternal->uiCodingIdx2TemporalId[pDlayerParamInternal->iCodingIndex &
|
||||
(pSvcParam->uiGopSize - 1)];
|
||||
int iActualSpatialNum = iSpatialNum - 1;
|
||||
if (iTemporalId != INVALID_TEMPORAL_ID) {
|
||||
WelsUpdateSpatialIdxMap (pCtx, iActualSpatialNum, pDstPic, iDependencyId);
|
||||
-- iActualSpatialNum;
|
||||
}
|
||||
|
||||
WelsUpdateSpatialIdxMap (pCtx, iDependencyId, pDstPic, iDependencyId);
|
||||
m_pLastSpatialPicture[iDependencyId][1] = m_pSpatialPic[iDependencyId][iPicturePos];
|
||||
-- iDependencyId;
|
||||
|
||||
|
||||
// generate other spacial layer
|
||||
// pSrc is
|
||||
// -- padded input pic, if downsample should be applied to generate highest layer, [if] block above
|
||||
@ -409,9 +423,10 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
|
||||
DownsamplePadding (pSrcPic, pDstPic, iSrcWidth, iSrcHeight, iShrinkWidth, iShrinkHeight, iTargetWidth, iTargetHeight,
|
||||
true);
|
||||
|
||||
WelsUpdateSpatialIdxMap (pCtx, iDependencyId, pDstPic, iDependencyId);
|
||||
if ((iTemporalId != INVALID_TEMPORAL_ID))
|
||||
++ iSpatialNum;
|
||||
if ((iTemporalId != INVALID_TEMPORAL_ID)) {
|
||||
WelsUpdateSpatialIdxMap (pCtx, iActualSpatialNum, pDstPic, iDependencyId);
|
||||
iActualSpatialNum--;
|
||||
}
|
||||
m_pLastSpatialPicture[iDependencyId][1] = m_pSpatialPic[iDependencyId][iPicturePos];
|
||||
|
||||
iClosestDid = iDependencyId;
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user