[Encoder] fix timestamp = 0 issue when rc mode is BITRATE mode
Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 6 files). Show all
Unified · Split
| @@ -2582,7 +2582,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 2581 unmodified lines | ||
| 2582 | 2582 | #endif//MEMORY_MONITOR |
| 2583 | 2583 | |
| 2584 | 2584 | pCtx->iStatisticsLogInterval = STATISTICS_LOG_INTERVAL_MS; |
| 2585 | − | |
| 2585 | + pCtx->uiLastTimestamp = -1; | |
| 2586 | 2586 | *ppCtx = pCtx; |
| 2587 | 2587 | |
| 2588 | 2588 | WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsInitEncoderExt(), pCtx= 0x%p.", (void*)pCtx); |
| @@ -3716,7 +3716,7 @@ void ClearFrameBsInfo (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi) { · 1127 unmodified lines | ||
| 3716 | 3716 | * \pParam pSrcPic Source Picture |
| 3717 | 3717 | * \return EFrameType (videoFrameTypeIDR/videoFrameTypeI/videoFrameTypeP) |
| 3718 | 3718 | */ |
| 3719 | −int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSourcePicture* pSrcPic) { | |
| 3719 | +int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSourcePicture* pSrcPic ) { | |
| 3720 | 3720 | if (pCtx == NULL) { |
| 3721 | 3721 | return ENC_RETURN_MEMALLOCERR; |
| 3722 | 3722 | } |
| @@ -3756,14 +3756,14 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 33 unmodified lines | ||
| 3756 | 3756 | pCtx->iEncoderError = ENC_RETURN_SUCCESS; |
| 3757 | 3757 | pCtx->bCurFrameMarkedAsSceneLtr = false; |
| 3758 | 3758 | pFbi->iLayerNum = 0; // for initialization |
| 3759 | − pFbi->uiTimeStamp = pSrcPic->uiTimeStamp; | |
| 3759 | + pFbi->uiTimeStamp = GetTimestampForRc(pSrcPic->uiTimeStamp, pCtx->uiLastTimestamp, pCtx->pSvcParam->sSpatialLayers[pCtx->pSvcParam->iSpatialLayerNum-1].fFrameRate); | |
| 3760 | 3760 | for (int32_t iNalIdx = 0; iNalIdx < MAX_LAYER_NUM_OF_FRAME; iNalIdx++) { |
| 3761 | 3761 | pFbi->sLayerInfo[iNalIdx].eFrameType = videoFrameTypeSkip; |
| 3762 | 3762 | } |
| 3763 | 3763 | // perform csc/denoise/downsample/padding, generate spatial layers |
| 3764 | 3764 | iSpatialNum = pCtx->pVpp->BuildSpatialPicList (pCtx, pSrcPic); |
| 3765 | 3765 | if (pCtx->pFuncList->pfRc.pfWelsUpdateMaxBrWindowStatus) { |
| 3766 | − pCtx->pFuncList->pfRc.pfWelsUpdateMaxBrWindowStatus (pCtx, iSpatialNum, pSrcPic->uiTimeStamp); | |
| 3766 | + pCtx->pFuncList->pfRc.pfWelsUpdateMaxBrWindowStatus (pCtx, iSpatialNum, pFbi->uiTimeStamp); | |
| 3767 | 3767 | } |
| 3768 | 3768 | |
| 3769 | 3769 | if (iSpatialNum < 1) { |
| @@ -3809,7 +3809,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 39 unmodified lines | ||
| 3809 | 3809 | pLayerBsInfo->eFrameType = eFrameType; |
| 3810 | 3810 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, |
| 3811 | 3811 | "[Rc] Frame timestamp = %lld, skip one frame due to target_br, continual skipped %d frames", |
| 3812 | − pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); | |
| 3812 | + pFbi->uiTimeStamp, pCtx->iContinualSkipFrames); | |
| 3813 | 3813 | ++ iSpatialIdx; |
| 3814 | 3814 | if (pSvcParam->bSimulcastAVC) { |
| 3815 | 3815 | if (pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip) |
| @@ -3830,13 +3830,13 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 14 unmodified lines | ||
| 3830 | 3830 | //loop each layer to check if have skip frame when RC and frame skip enable |
| 3831 | 3831 | if (pCtx->pFuncList->pfRc.pfWelsCheckSkipBasedMaxbr) { |
| 3832 | 3832 | bool bSkip = pCtx->pFuncList->pfRc.pfWelsCheckSkipBasedMaxbr (pCtx, iSpatialNum, eFrameType, |
| 3833 | − (uint32_t)pSrcPic->uiTimeStamp); | |
| 3833 | + (uint32_t)pFbi->uiTimeStamp); | |
| 3834 | 3834 | if (bSkip) { |
| 3835 | 3835 | eFrameType = videoFrameTypeSkip; |
| 3836 | 3836 | pLayerBsInfo->eFrameType = videoFrameTypeSkip; |
| 3837 | 3837 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, |
| 3838 | 3838 | "[Rc] Frame timestamp = %lld, skip one frame due to max_br, continual skipped %d frames", |
| 3839 | − pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); | |
| 3839 | + pFbi->uiTimeStamp, pCtx->iContinualSkipFrames); | |
| 3840 | 3840 | ++ iSpatialIdx; |
| 3841 | 3841 | if (pSvcParam->bSimulcastAVC) |
| 3842 | 3842 | continue; |
| @@ -3968,7 +3968,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 125 unmodified lines | ||
| 3968 | 3968 | eFrameType); //get reordering syntax used for writing slice header and transmit to encoder. |
| 3969 | 3969 | PrefetchReferencePicture (pCtx, eFrameType); // update reference picture for current pDq layer |
| 3970 | 3970 | |
| 3971 | − pCtx->pFuncList->pfRc.pfWelsRcPictureInit (pCtx, pSrcPic->uiTimeStamp); | |
| 3971 | + pCtx->pFuncList->pfRc.pfWelsRcPictureInit (pCtx, pFbi->uiTimeStamp); | |
| 3972 | 3972 | PreprocessSliceCoding (pCtx); // MUST be called after pfWelsRcPictureInit() and WelsInitCurrentLayer() |
| 3973 | 3973 | |
| 3974 | 3974 | //TODO Complexity Calculation here for screen content |
| @@ -4166,7 +4166,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 191 unmodified lines | ||
| 4166 | 4166 | } |
| 4167 | 4167 | |
| 4168 | 4168 | if (NULL != pCtx->pFuncList->pfRc.pfWelsRcPostFrameSkipping |
| 4169 | − && pCtx->pFuncList->pfRc.pfWelsRcPostFrameSkipping (pCtx, iCurDid, pSrcPic->uiTimeStamp)) { | |
| 4169 | + && pCtx->pFuncList->pfRc.pfWelsRcPostFrameSkipping (pCtx, iCurDid, pFbi->uiTimeStamp)) { | |
| 4170 | 4170 | |
| 4171 | 4171 | StackBackEncoderStatus (pCtx, eFrameType); |
| 4172 | 4172 | ClearFrameBsInfo (pCtx, pFbi); |
| @@ -4182,7 +4182,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 9 unmodified lines | ||
| 4182 | 4182 | WelsRcPostFrameSkippedUpdate (pCtx, iCurDid); |
| 4183 | 4183 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, |
| 4184 | 4184 | "[Rc] Frame timestamp = %lld, skip one frame due to post skip, continual skipped %d frames", |
| 4185 | − pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); | |
| 4185 | + pFbi->uiTimeStamp, pCtx->iContinualSkipFrames); | |
| 4186 | 4186 | pCtx->iEncoderError = ENC_RETURN_SUCCESS; |
| 4187 | 4187 | return ENC_RETURN_SUCCESS; |
| 4188 | 4188 | } |
| @@ -4200,7 +4200,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 11 unmodified lines | ||
| 4200 | 4200 | } |
| 4201 | 4201 | |
| 4202 | 4202 | pCtx->pFuncList->pfRc.pfWelsRcPictureInfoUpdate (pCtx, iLayerSize); |
| 4203 | − RcTraceFrameBits (pCtx, pSrcPic->uiTimeStamp); | |
| 4203 | + RcTraceFrameBits (pCtx, pFbi->uiTimeStamp); | |
| 4204 | 4204 | pCtx->pDecPic->iFrameAverageQp = pCtx->pWelsSvcRc[iDidIdx].iAverageFrameQp; |
| 4205 | 4205 | |
| 4206 | 4206 | //update scc related |