! * \brief core svc encoding process * * \pParam pCtx sWelsEncCtx*, encoder context * \pParam pFbi FrameBSInfo* * \pParam pSrcPic Source Picture * \return EFrameType (videoFrameTypeIDR/videoFrameTypeI/videoFrameTypeP) */
| 3439 | * \return EFrameType (videoFrameTypeIDR/videoFrameTypeI/videoFrameTypeP) |
| 3440 | */ |
| 3441 | int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSourcePicture* pSrcPic) { |
| 3442 | if (pCtx == NULL) { |
| 3443 | return ENC_RETURN_MEMALLOCERR; |
| 3444 | } |
| 3445 | SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0]; |
| 3446 | SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam; |
| 3447 | SSpatialPicIndex* pSpatialIndexMap = &pCtx->sSpatialIndexMap[0]; |
| 3448 | SPicture* fsnr = NULL; |
| 3449 | SPicture* pEncPic = NULL; // to be decided later |
| 3450 | #if defined(MT_DEBUG) |
| 3451 | int32_t iDidList[MAX_DEPENDENCY_LAYER] = {0}; |
| 3452 | #endif |
| 3453 | int32_t iLayerNum = 0; |
| 3454 | int32_t iLayerSize = 0; |
| 3455 | int32_t iSpatialNum = |
| 3456 | 0; // available count number of spatial layers due to frame size changed in this given frame |
| 3457 | int32_t iSpatialIdx = 0; // iIndex of spatial layers due to frame size changed in this given frame |
| 3458 | int32_t iFrameSize = 0; |
| 3459 | int32_t iNalIdxInLayer = 0; |
| 3460 | int32_t iCountNal = 0; |
| 3461 | EVideoFrameType eFrameType = videoFrameTypeInvalid; |
| 3462 | int32_t iCurWidth = 0; |
| 3463 | int32_t iCurHeight = 0; |
| 3464 | EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; |
| 3465 | EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST; |
| 3466 | int8_t iCurDid = 0; |
| 3467 | int32_t iCurTid = 0; |
| 3468 | bool bAvcBased = false; |
| 3469 | SLogContext* pLogCtx = & (pCtx->sLogCtx); |
| 3470 | float fSnrY = .0f, fSnrU = .0f, fSnrV = .0f; |
| 3471 | |
| 3472 | #if defined(_DEBUG) |
| 3473 | int32_t i = 0, j = 0, k = 0; |
| 3474 | #endif//_DEBUG |
| 3475 | pCtx->iEncoderError = ENC_RETURN_SUCCESS; |
| 3476 | pCtx->bCurFrameMarkedAsSceneLtr = false; |
| 3477 | pFbi->eFrameType = videoFrameTypeSkip; |
| 3478 | pFbi->iLayerNum = 0; // for initialization |
| 3479 | pFbi->uiTimeStamp = GetTimestampForRc (pSrcPic->uiTimeStamp, pCtx->uiLastTimestamp, |
| 3480 | pCtx->pSvcParam->sSpatialLayers[pCtx->pSvcParam->iSpatialLayerNum - 1].fFrameRate); |
| 3481 | for (int32_t iNalIdx = 0; iNalIdx < MAX_LAYER_NUM_OF_FRAME; iNalIdx++) { |
| 3482 | pFbi->sLayerInfo[iNalIdx].eFrameType = videoFrameTypeSkip; |
| 3483 | pFbi->sLayerInfo[iNalIdx].iNalCount = 0; |
| 3484 | } |
| 3485 | // perform csc/denoise/downsample/padding, generate spatial layers |
| 3486 | iSpatialNum = pCtx->pVpp->BuildSpatialPicList (pCtx, pSrcPic); |
| 3487 | if (iSpatialNum == -1) { |
| 3488 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "Failed in allocating memory in BuildSpatialPicList"); |
| 3489 | return ENC_RETURN_MEMALLOCERR; |
| 3490 | } |
| 3491 | |
| 3492 | if (pCtx->pFuncList->pfRc.pfWelsUpdateMaxBrWindowStatus) { |
| 3493 | pCtx->pFuncList->pfRc.pfWelsUpdateMaxBrWindowStatus (pCtx, iSpatialNum, pFbi->uiTimeStamp); |
| 3494 | } |
| 3495 | |
| 3496 | if (iSpatialNum < 1) { |
| 3497 | for (int32_t iDidIdx = 0; iDidIdx < pSvcParam->iSpatialLayerNum; iDidIdx++) { |
| 3498 | SSpatialLayerInternal* pParamInternal = &pSvcParam->sDependencyLayers[iDidIdx]; |
no test coverage detected