Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 7 files). Show all
Unified · Split
| @@ -3035,29 +3035,6 @@ int32_t GetSubSequenceId (sWelsEncCtx* pCtx, EVideoFrameType eFrameType) { · 3034 unmodified lines | ||
| 3035 | 3035 | return iSubSeqId; |
| 3036 | 3036 | } |
| 3037 | 3037 | |
| 3038 | −//loop each layer to check if have skip frame when RC and frame skip enable (maxbr>0) | |
| 3039 | −bool CheckFrameSkipBasedMaxbr (sWelsEncCtx* pCtx, int32_t iSpatialNum, EVideoFrameType eFrameType, | |
| 3040 | − const long long uiTimeStamp) { | |
| 3041 | − SSpatialPicIndex* pSpatialIndexMap = &pCtx->sSpatialIndexMap[0]; | |
| 3042 | − bool bSkipMustFlag = false; | |
| 3043 | − if (pCtx->pSvcParam->bEnableFrameSkip) { | |
| 3044 | − if ((RC_QUALITY_MODE == pCtx->pSvcParam->iRCMode) || (RC_BITRATE_MODE == pCtx->pSvcParam->iRCMode)) { | |
| 3045 | − for (int32_t i = 0; i < iSpatialNum; i++) { | |
| 3046 | − if (UNSPECIFIED_BIT_RATE == pCtx->pSvcParam->sSpatialLayers[i].iMaxSpatialBitrate) { | |
| 3047 | − break; | |
| 3048 | − } | |
| 3049 | − pCtx->uiDependencyId = (uint8_t) (pSpatialIndexMap + i)->iDid; | |
| 3050 | − pCtx->pFuncList->pfRc.pfWelsRcPicDelayJudge (pCtx, eFrameType, uiTimeStamp); | |
| 3051 | − if (true == pCtx->pWelsSvcRc[pCtx->uiDependencyId].bSkipFlag) { | |
| 3052 | − bSkipMustFlag = true; | |
| 3053 | − break; | |
| 3054 | − } | |
| 3055 | − } | |
| 3056 | − } | |
| 3057 | − } | |
| 3058 | − return bSkipMustFlag; | |
| 3059 | −} | |
| 3060 | − | |
| 3061 | 3038 | /*! |
| 3062 | 3039 | * \brief core svc encoding process |
| 3063 | 3040 | * |
| @@ -3108,29 +3085,37 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 44 unmodified lines | ||
| 3108 | 3085 | pFbi->uiTimeStamp = pSrcPic->uiTimeStamp; |
| 3109 | 3086 | // perform csc/denoise/downsample/padding, generate spatial layers |
| 3110 | 3087 | iSpatialNum = pCtx->pVpp->BuildSpatialPicList (pCtx, pSrcPic); |
| 3088 | + | |
| 3089 | + if (pCtx->pSvcParam->bEnableFrameSkip) { | |
| 3090 | + UpdateMaxBrCheckWindowStatus(pCtx, iSpatialNum, pSrcPic->uiTimeStamp); | |
| 3091 | + } | |
| 3092 | + | |
| 3111 | 3093 | if (iSpatialNum < 1) { // skip due to temporal layer settings (different frame rate) |
| 3112 | 3094 | ++ pCtx->iCodingIndex; |
| 3113 | 3095 | pFbi->eFrameType = videoFrameTypeSkip; |
| 3114 | − WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, Frame type =%d", | |
| 3115 | − pSrcPic->uiTimeStamp, pFbi->eFrameType); | |
| 3096 | + WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, skip one frame, continual skipped %d frames", | |
| 3097 | + pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); | |
| 3116 | 3098 | return ENC_RETURN_SUCCESS; |
| 3117 | 3099 | } |
| 3118 | 3100 | |
| 3119 | 3101 | eFrameType = DecideFrameType (pCtx, iSpatialNum); |
| 3120 | 3102 | if (eFrameType == videoFrameTypeSkip) { |
| 3103 | + UpdateBufferWhenFrameSkipped(pCtx, iSpatialNum); | |
| 3121 | 3104 | pFbi->eFrameType = eFrameType; |
| 3122 | − WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, Frame type =%d", | |
| 3123 | − pSrcPic->uiTimeStamp, pFbi->eFrameType); | |
| 3105 | + WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, skip one frame, continual skipped %d frames", | |
| 3106 | + pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); | |
| 3124 | 3107 | return ENC_RETURN_SUCCESS; |
| 3125 | 3108 | } |
| 3126 | 3109 | |
| 3127 | 3110 | //loop each layer to check if have skip frame when RC and frame skip enable |
| 3128 | − if (CheckFrameSkipBasedMaxbr (pCtx, iSpatialNum, eFrameType, pSrcPic->uiTimeStamp)) { | |
| 3111 | + if (CheckFrameSkipBasedMaxbr (pCtx, iSpatialNum, eFrameType, (uint32_t)pSrcPic->uiTimeStamp)) { | |
| 3129 | 3112 | pFbi->eFrameType = videoFrameTypeSkip; |
| 3130 | − WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, Frame type =%d", | |
| 3131 | − pSrcPic->uiTimeStamp, pFbi->eFrameType); | |
| 3113 | + WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, skip one frame, continual skipped %d frames", | |
| 3114 | + pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); | |
| 3132 | 3115 | return ENC_RETURN_SUCCESS; |
| 3133 | 3116 | } |
| 3117 | + | |
| 3118 | + pCtx->iContinualSkipFrames = 0; | |
| 3134 | 3119 | InitFrameCoding (pCtx, eFrameType); |
| 3135 | 3120 | |
| 3136 | 3121 | iCurTid = GetTemporalLevel (&pSvcParam->sDependencyLayers[pSpatialIndexMap->iDid], pCtx->iCodingIndex, |