Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 7 files). Show all
Unified · Split
| @@ -156,9 +156,9 @@ int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) { · 155 unmodified lines | |||
| 156 | } | 156 | } |
| 157 | if (pSpatialLayer->iMaxSpatialBitrate < pSpatialLayer->iSpatialBitrate * 1.1f) { | 157 | if (pSpatialLayer->iMaxSpatialBitrate < pSpatialLayer->iSpatialBitrate * 1.1f) { |
| 158 | WelsLog (pLogCtx, WELS_LOG_WARNING, | 158 | WelsLog (pLogCtx, WELS_LOG_WARNING, |
| 159 | "MaxSpatialBitrate (%d) should set be larger than 1.1 times of SpatialBitrate (%d)", | 159 | "MaxSpatialBitrate (%d) should set be larger than 1.1 times of SpatialBitrate (%d)", |
| 160 | pSpatialLayer->iMaxSpatialBitrate, pSpatialLayer->iSpatialBitrate); | 160 | pSpatialLayer->iMaxSpatialBitrate, pSpatialLayer->iSpatialBitrate); |
| 161 | // pSpatialLayer->iSpatialBitrate = (int32_t) (pSpatialLayer->iMaxSpatialBitrate/1.1f); | 161 | // pSpatialLayer->iSpatialBitrate = (int32_t) (pSpatialLayer->iMaxSpatialBitrate/1.1f); |
| 162 | } | 162 | } |
| 163 | } | 163 | } |
| 164 | if (iTotalBitrate > pCfg->iTargetBitrate) { | 164 | if (iTotalBitrate > pCfg->iTargetBitrate) { |
| @@ -1357,7 +1357,9 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 1192 unmodified lines | |||
| 1357 | iTargetSpatialBsSize = iLayerBsSize; | 1357 | iTargetSpatialBsSize = iLayerBsSize; |
| 1358 | iCountBsLen = iNonVclLayersBsSizeCount + iVclLayersBsSizeCount; | 1358 | iCountBsLen = iNonVclLayersBsSizeCount + iVclLayersBsSizeCount; |
| 1359 | 1359 | ||
| 1360 | pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT, (pParam->iUsageType==CAMERA_VIDEO_REAL_TIME?MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA:MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); | 1360 | pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT, |
| 1361 | (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : | ||
| 1362 | MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); | ||
| 1361 | 1363 | ||
| 1362 | // Output | 1364 | // Output |
| 1363 | (*ppCtx)->pOut = (SWelsEncoderOutput*)pMa->WelsMalloc (sizeof (SWelsEncoderOutput), "SWelsEncoderOutput"); | 1365 | (*ppCtx)->pOut = (SWelsEncoderOutput*)pMa->WelsMalloc (sizeof (SWelsEncoderOutput), "SWelsEncoderOutput"); |
| @@ -2015,7 +2017,9 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 651 unmodified lines | |||
| 2015 | } | 2017 | } |
| 2016 | iRet = pCodingParam->DetermineTemporalSettings(); | 2018 | iRet = pCodingParam->DetermineTemporalSettings(); |
| 2017 | if (iRet != ENC_RETURN_SUCCESS) { | 2019 | if (iRet != ENC_RETURN_SUCCESS) { |
| 2018 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), DetermineTemporalSettings failed return %d (check in/out frame rate and temporal layer setting!)", iRet); | 2020 | WelsLog (pLogCtx, WELS_LOG_ERROR, |
| 2021 | "WelsInitEncoderExt(), DetermineTemporalSettings failed return %d (check in/out frame rate and temporal layer setting!)", | ||
| 2022 | iRet); | ||
| 2019 | return iRet; | 2023 | return iRet; |
| 2020 | } | 2024 | } |
| 2021 | iRet = GetMultipleThreadIdc (pLogCtx, pCodingParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags); | 2025 | iRet = GetMultipleThreadIdc (pLogCtx, pCodingParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags); |
| @@ -3029,21 +3033,24 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 1007 unmodified lines | |||
| 3029 | if (iSpatialNum < 1) { // skip due to temporal layer settings (different frame rate) | 3033 | if (iSpatialNum < 1) { // skip due to temporal layer settings (different frame rate) |
| 3030 | ++ pCtx->iCodingIndex; | 3034 | ++ pCtx->iCodingIndex; |
| 3031 | pFbi->eFrameType = videoFrameTypeSkip; | 3035 | pFbi->eFrameType = videoFrameTypeSkip; |
| 3032 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] Frame timestamp = %8" PRId64", skip one frame", (int64_t)pSrcPic->uiTimeStamp); | 3036 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %8" PRId64", skip one frame", |
| 3037 | (int64_t)pSrcPic->uiTimeStamp); | ||
| 3033 | return ENC_RETURN_SUCCESS; | 3038 | return ENC_RETURN_SUCCESS; |
| 3034 | } | 3039 | } |
| 3035 | 3040 | ||
| 3036 | eFrameType = DecideFrameType (pCtx, iSpatialNum); | 3041 | eFrameType = DecideFrameType (pCtx, iSpatialNum); |
| 3037 | if (eFrameType == videoFrameTypeSkip) { | 3042 | if (eFrameType == videoFrameTypeSkip) { |
| 3038 | pFbi->eFrameType = eFrameType; | 3043 | pFbi->eFrameType = eFrameType; |
| 3039 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] Frame timestamp = %8" PRId64", skip one frame", (int64_t)pSrcPic->uiTimeStamp); | 3044 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %8" PRId64", skip one frame", |
| 3045 | (int64_t)pSrcPic->uiTimeStamp); | ||
| 3040 | return ENC_RETURN_SUCCESS; | 3046 | return ENC_RETURN_SUCCESS; |
| 3041 | } | 3047 | } |
| 3042 | 3048 | ||
| 3043 | //loop each layer to check if have skip frame when RC and frame skip enable | 3049 | //loop each layer to check if have skip frame when RC and frame skip enable |
| 3044 | if (CheckFrameSkipBasedMaxbr (pCtx, iSpatialNum, eFrameType, (uint32_t)pSrcPic->uiTimeStamp)) { | 3050 | if (CheckFrameSkipBasedMaxbr (pCtx, iSpatialNum, eFrameType, (uint32_t)pSrcPic->uiTimeStamp)) { |
| 3045 | pFbi->eFrameType = videoFrameTypeSkip; | 3051 | pFbi->eFrameType = videoFrameTypeSkip; |
| 3046 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] Frame timestamp = %8" PRId64", skip one frame", (int64_t)pSrcPic->uiTimeStamp); | 3052 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %8" PRId64", skip one frame", |
| 3053 | (int64_t)pSrcPic->uiTimeStamp); | ||
| 3047 | return ENC_RETURN_SUCCESS; | 3054 | return ENC_RETURN_SUCCESS; |
| 3048 | } | 3055 | } |
| 3049 | 3056 | ||
| @@ -3427,7 +3434,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 377 unmodified lines | |||
| 3427 | } | 3434 | } |
| 3428 | 3435 | ||
| 3429 | pCtx->pFuncList->pfRc.pfWelsRcPictureInfoUpdate (pCtx, iLayerSize); | 3436 | pCtx->pFuncList->pfRc.pfWelsRcPictureInfoUpdate (pCtx, iLayerSize); |
| 3430 | RcTraceFrameBits (pCtx,pSrcPic->uiTimeStamp); | 3437 | RcTraceFrameBits (pCtx, pSrcPic->uiTimeStamp); |
| 3431 | pCtx->pDecPic->iFrameAverageQp = pCtx->pWelsSvcRc->iAverageFrameQp; | 3438 | pCtx->pDecPic->iFrameAverageQp = pCtx->pWelsSvcRc->iAverageFrameQp; |
| 3432 | 3439 | ||
| 3433 | //update scc related | 3440 | //update scc related |
| @@ -3753,7 +3760,8 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 319 unmodified lines | |||
| 3753 | } else { | 3760 | } else { |
| 3754 | /* maybe adjustment introduced in bitrate or little settings adjustment and so on.. */ | 3761 | /* maybe adjustment introduced in bitrate or little settings adjustment and so on.. */ |
| 3755 | pNewParam->iNumRefFrame = WELS_CLIP3 (pNewParam->iNumRefFrame, MIN_REF_PIC_COUNT, | 3762 | pNewParam->iNumRefFrame = WELS_CLIP3 (pNewParam->iNumRefFrame, MIN_REF_PIC_COUNT, |
| 3756 | (pNewParam->iUsageType==CAMERA_VIDEO_REAL_TIME?MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA:MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); | 3763 | (pNewParam->iUsageType == CAMERA_VIDEO_REAL_TIME ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : |
| 3764 | MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); | ||
| 3757 | pNewParam->iLoopFilterDisableIdc = WELS_CLIP3 (pNewParam->iLoopFilterDisableIdc, 0, 6); | 3765 | pNewParam->iLoopFilterDisableIdc = WELS_CLIP3 (pNewParam->iLoopFilterDisableIdc, 0, 6); |
| 3758 | pNewParam->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pNewParam->iLoopFilterAlphaC0Offset, -6, 6); | 3766 | pNewParam->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pNewParam->iLoopFilterAlphaC0Offset, -6, 6); |
| 3759 | pNewParam->iLoopFilterBetaOffset = WELS_CLIP3 (pNewParam->iLoopFilterBetaOffset, -6, 6); | 3767 | pNewParam->iLoopFilterBetaOffset = WELS_CLIP3 (pNewParam->iLoopFilterBetaOffset, -6, 6); |