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 | * Force coding IDR as follows | 3141 | * Force coding IDR as follows |
| 3142 | */ | 3142 | */ |
| 3143 | int32_t ForceCodingIDR (sWelsEncCtx* pCtx) { | 3143 | int32_t ForceCodingIDR (sWelsEncCtx* pCtx, int32_t iLayerId) { |
| 3144 | if (NULL == pCtx) | 3144 | if (NULL == pCtx) |
| 3145 | return 1; | 3145 | return 1; |
| 3146 | for (int32_t iDid = 0; iDid < pCtx->pSvcParam->iSpatialLayerNum; iDid++) { | 3146 | if ((iLayerId < 0) || (iLayerId >= MAX_SPATIAL_LAYER_NUM) || (!pCtx->pSvcParam->bSimulcastAVC)) { |
| 3147 | SSpatialLayerInternal* pParamInternal = &pCtx->pSvcParam->sDependencyLayers[iDid]; | 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 | pParamInternal->iCodingIndex = 0; | 3163 | pParamInternal->iCodingIndex = 0; |
| 3149 | pParamInternal->iFrameIndex = 0; | 3164 | pParamInternal->iFrameIndex = 0; |
| 3150 | pParamInternal->iFrameNum = 0; | 3165 | pParamInternal->iFrameNum = 0; |
| 3151 | pParamInternal->iPOC = 0; | 3166 | pParamInternal->iPOC = 0; |
| 3152 | pParamInternal->bEncCurFrmAsIdrFlag = true; | 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 | pCtx->bCheckWindowStatusRefreshFlag = false; | 3172 | pCtx->bCheckWindowStatusRefreshFlag = false; |
| 3156 | 3173 | ||
| 3157 | WelsLog (&pCtx->sLogCtx, WELS_LOG_INFO, "ForceCodingIDR at InputFrameCount=%d\n", | 3174 | |
| 3158 | pCtx->sEncoderStatistics[0].uiInputFrameCount); | ||
| 3159 | return 0; | 3175 | return 0; |
| 3160 | } | 3176 | } |
| 3161 | 3177 | ||
| @@ -3430,7 +3446,7 @@ void StackBackEncoderStatus (sWelsEncCtx* pEncCtx, · 268 unmodified lines | |||
| 3430 | pEncCtx->uiIdrPicId --; | 3446 | pEncCtx->uiIdrPicId --; |
| 3431 | 3447 | ||
| 3432 | //set the next frame to be IDR | 3448 | //set the next frame to be IDR |
| 3433 | ForceCodingIDR (pEncCtx); | 3449 | ForceCodingIDR (pEncCtx, pEncCtx->uiDependencyId); |
| 3434 | } else { // B pictures are not supported now, any else? | 3450 | } else { // B pictures are not supported now, any else? |
| 3435 | assert (0); | 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 | if (pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, iCurDid) != 0) { | 4114 | if (pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, iCurDid) != 0) { |
| 4099 | ForceCodingIDR (pCtx); | 4115 | ForceCodingIDR (pCtx, iCurDid); |
| 4100 | WelsLog (pLogCtx, WELS_LOG_WARNING, | 4116 | WelsLog (pLogCtx, WELS_LOG_WARNING, |
| 4101 | "WelsEncoderEncodeExt(), Logic Error Found in Preprocess updating. ForceCodingIDR!"); | 4117 | "WelsEncoderEncodeExt(), Logic Error Found in Preprocess updating. ForceCodingIDR!"); |
| 4102 | //the above is to set the next frame IDR | 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 | if (ENC_RETURN_CORRECTED == pCtx->iEncoderError) { | 4139 | if (ENC_RETURN_CORRECTED == pCtx->iEncoderError) { |
| 4124 | pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, (pSpatialIndexMap + iSpatialIdx)->iDid); | 4140 | pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, (pSpatialIndexMap + iSpatialIdx)->iDid); |
| 4125 | ForceCodingIDR (pCtx); | 4141 | ForceCodingIDR (pCtx, (pSpatialIndexMap + iSpatialIdx)->iDid); |
| 4126 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsEncoderEncodeExt(), Logic Error Found in temporal level. ForceCodingIDR!"); | 4142 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsEncoderEncodeExt(), Logic Error Found in temporal level. ForceCodingIDR!"); |
| 4127 | //the above is to set the next frame IDR | 4143 | //the above is to set the next frame IDR |
| 4128 | pFbi->eFrameType = eFrameType; | 4144 | pFbi->eFrameType = eFrameType; |