History

Set IDR frame independently for simulcast AVC

Karina committed 10 years ago

Commit 61e66851 parent 28db1bc7 files · +175 −102Browse files

Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 7 files). Show all

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+25−9
@@ -3140,22 +3140,38 @@ int32_t WritePadding (sWelsEncCtx* pCtx, int32_t iLen, int32_t& iSize) { · 3139 unmodified lines
31403140 /*
31413141 * Force coding IDR as follows
31423142 */
3143−int32_t ForceCodingIDR (sWelsEncCtx* pCtx) {
3143+int32_t ForceCodingIDR (sWelsEncCtx* pCtx, int32_t iLayerId) {
31443144 if (NULL == pCtx)
31453145 return 1;
3146− for (int32_t iDid = 0; iDid < pCtx->pSvcParam->iSpatialLayerNum; iDid++) {
3147− SSpatialLayerInternal* pParamInternal = &pCtx->pSvcParam->sDependencyLayers[iDid];
3146+ if ((iLayerId < 0) || (iLayerId >= MAX_SPATIAL_LAYER_NUM) || (!pCtx->pSvcParam->bSimulcastAVC)) {
3147+ for (int32_t iDid = 0; iDid < pCtx->pSvcParam->iSpatialLayerNum; iDid++) {
3148+ SSpatialLayerInternal* pParamInternal = &pCtx->pSvcParam->sDependencyLayers[iDid];
3149+ pParamInternal->iCodingIndex = 0;
3150+ pParamInternal->iFrameIndex = 0;
3151+ pParamInternal->iFrameNum = 0;
3152+ pParamInternal->iPOC = 0;
3153+ pParamInternal->bEncCurFrmAsIdrFlag = true;
3154+ pCtx->sEncoderStatistics[0].uiIDRReqNum++;
3155+ }
3156+ WelsLog (&pCtx->sLogCtx, WELS_LOG_INFO, "ForceCodingIDR(iDid 0-%d)at InputFrameCount=%d\n",
3157+ pCtx->pSvcParam->iSpatialLayerNum - 1, pCtx->sEncoderStatistics[0].uiInputFrameCount);
3158+
3159+
3160+
3161+ } else {
3162+ SSpatialLayerInternal* pParamInternal = &pCtx->pSvcParam->sDependencyLayers[iLayerId];
31483163 pParamInternal->iCodingIndex = 0;
31493164 pParamInternal->iFrameIndex = 0;
31503165 pParamInternal->iFrameNum = 0;
31513166 pParamInternal->iPOC = 0;
31523167 pParamInternal->bEncCurFrmAsIdrFlag = true;
3168+ pCtx->sEncoderStatistics[iLayerId].uiIDRReqNum++;
3169+ WelsLog (&pCtx->sLogCtx, WELS_LOG_INFO, "ForceCodingIDR(iDid %d)at InputFrameCount=%d\n", iLayerId,
3170+ pCtx->sEncoderStatistics[iLayerId].uiInputFrameCount);
31533171 }
3154−
31553172 pCtx->bCheckWindowStatusRefreshFlag = false;
31563173
3157− WelsLog (&pCtx->sLogCtx, WELS_LOG_INFO, "ForceCodingIDR at InputFrameCount=%d\n",
3158− pCtx->sEncoderStatistics[0].uiInputFrameCount);
3174+
31593175 return 0;
31603176 }
31613177
@@ -3430,7 +3446,7 @@ void StackBackEncoderStatus (sWelsEncCtx* pEncCtx, · 268 unmodified lines
34303446 pEncCtx->uiIdrPicId --;
34313447
34323448 //set the next frame to be IDR
3433− ForceCodingIDR (pEncCtx);
3449+ ForceCodingIDR (pEncCtx, pEncCtx->uiDependencyId);
34343450 } else { // B pictures are not supported now, any else?
34353451 assert (0);
34363452 }
@@ -4096,7 +4112,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 659 unmodified lines
40964112 }
40974113
40984114 if (pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, iCurDid) != 0) {
4099− ForceCodingIDR (pCtx);
4115+ ForceCodingIDR (pCtx, iCurDid);
41004116 WelsLog (pLogCtx, WELS_LOG_WARNING,
41014117 "WelsEncoderEncodeExt(), Logic Error Found in Preprocess updating. ForceCodingIDR!");
41024118 //the above is to set the next frame IDR
@@ -4122,7 +4138,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 19 unmodified lines
41224138
41234139 if (ENC_RETURN_CORRECTED == pCtx->iEncoderError) {
41244140 pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, (pSpatialIndexMap + iSpatialIdx)->iDid);
4125− ForceCodingIDR (pCtx);
4141+ ForceCodingIDR (pCtx, (pSpatialIndexMap + iSpatialIdx)->iDid);
41264142 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsEncoderEncodeExt(), Logic Error Found in temporal level. ForceCodingIDR!");
41274143 //the above is to set the next frame IDR
41284144 pFbi->eFrameType = eFrameType;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t