Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 7 files). Show all
Unified · Split
| @@ -3140,22 +3140,38 @@ int32_t WritePadding (sWelsEncCtx* pCtx, int32_t iLen, int32_t& iSize) { · 3139 unmodified lines | ||
| 3140 | 3140 | /* |
| 3141 | 3141 | * Force coding IDR as follows |
| 3142 | 3142 | */ |
| 3143 | −int32_t ForceCodingIDR (sWelsEncCtx* pCtx) { | |
| 3143 | +int32_t ForceCodingIDR (sWelsEncCtx* pCtx, int32_t iLayerId) { | |
| 3144 | 3144 | if (NULL == pCtx) |
| 3145 | 3145 | 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]; | |
| 3148 | 3163 | pParamInternal->iCodingIndex = 0; |
| 3149 | 3164 | pParamInternal->iFrameIndex = 0; |
| 3150 | 3165 | pParamInternal->iFrameNum = 0; |
| 3151 | 3166 | pParamInternal->iPOC = 0; |
| 3152 | 3167 | 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); | |
| 3153 | 3171 | } |
| 3154 | − | |
| 3155 | 3172 | pCtx->bCheckWindowStatusRefreshFlag = false; |
| 3156 | 3173 | |
| 3157 | − WelsLog (&pCtx->sLogCtx, WELS_LOG_INFO, "ForceCodingIDR at InputFrameCount=%d\n", | |
| 3158 | − pCtx->sEncoderStatistics[0].uiInputFrameCount); | |
| 3174 | + | |
| 3159 | 3175 | return 0; |
| 3160 | 3176 | } |
| 3161 | 3177 | |
| @@ -3430,7 +3446,7 @@ void StackBackEncoderStatus (sWelsEncCtx* pEncCtx, · 268 unmodified lines | ||
| 3430 | 3446 | pEncCtx->uiIdrPicId --; |
| 3431 | 3447 | |
| 3432 | 3448 | //set the next frame to be IDR |
| 3433 | − ForceCodingIDR (pEncCtx); | |
| 3449 | + ForceCodingIDR (pEncCtx, pEncCtx->uiDependencyId); | |
| 3434 | 3450 | } else { // B pictures are not supported now, any else? |
| 3435 | 3451 | assert (0); |
| 3436 | 3452 | } |
| @@ -4096,7 +4112,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 659 unmodified lines | ||
| 4096 | 4112 | } |
| 4097 | 4113 | |
| 4098 | 4114 | if (pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, iCurDid) != 0) { |
| 4099 | − ForceCodingIDR (pCtx); | |
| 4115 | + ForceCodingIDR (pCtx, iCurDid); | |
| 4100 | 4116 | WelsLog (pLogCtx, WELS_LOG_WARNING, |
| 4101 | 4117 | "WelsEncoderEncodeExt(), Logic Error Found in Preprocess updating. ForceCodingIDR!"); |
| 4102 | 4118 | //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 | ||
| 4122 | 4138 | |
| 4123 | 4139 | if (ENC_RETURN_CORRECTED == pCtx->iEncoderError) { |
| 4124 | 4140 | pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, (pSpatialIndexMap + iSpatialIdx)->iDid); |
| 4125 | − ForceCodingIDR (pCtx); | |
| 4141 | + ForceCodingIDR (pCtx, (pSpatialIndexMap + iSpatialIdx)->iDid); | |
| 4126 | 4142 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsEncoderEncodeExt(), Logic Error Found in temporal level. ForceCodingIDR!"); |
| 4127 | 4143 | //the above is to set the next frame IDR |
| 4128 | 4144 | pFbi->eFrameType = eFrameType; |