Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 13 files). Show all
Unified · Split
| @@ -1206,6 +1206,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 1205 unmodified lines | |||
| 1206 | while (iDlayerIndex < iDlayerCount) { | 1206 | while (iDlayerIndex < iDlayerCount) { |
| 1207 | SDqLayer* pDqLayer = NULL; | 1207 | SDqLayer* pDqLayer = NULL; |
| 1208 | SSpatialLayerConfig* pDlayer = &pParam->sSpatialLayers[iDlayerIndex]; | 1208 | SSpatialLayerConfig* pDlayer = &pParam->sSpatialLayers[iDlayerIndex]; |
| 1209 | SSpatialLayerInternal* pParamInternal = &pParam->sDependencyLayers[iDlayerIndex]; | ||
| 1209 | const int32_t kiMbW = (pDlayer->iVideoWidth + 0x0f) >> 4; | 1210 | const int32_t kiMbW = (pDlayer->iVideoWidth + 0x0f) >> 4; |
| 1210 | const int32_t kiMbH = (pDlayer->iVideoHeight + 0x0f) >> 4; | 1211 | const int32_t kiMbH = (pDlayer->iVideoHeight + 0x0f) >> 4; |
| 1211 | int32_t iMaxSliceNum = 1; | 1212 | int32_t iMaxSliceNum = 1; |
| @@ -1213,6 +1214,12 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 1 unmodified line | |||
| 1213 | if (iMaxSliceNum < kiSliceNum) | 1214 | if (iMaxSliceNum < kiSliceNum) |
| 1214 | iMaxSliceNum = kiSliceNum; | 1215 | iMaxSliceNum = kiSliceNum; |
| 1215 | 1216 | ||
| 1217 | pParamInternal->iSkipFrameFlag = 0; | ||
| 1218 | pParamInternal->iCodingIndex = 0; | ||
| 1219 | pParamInternal->iFrameIndex = 0; | ||
| 1220 | pParamInternal->iFrameNum = 0; | ||
| 1221 | pParamInternal->iPOC = 0; | ||
| 1222 | pParamInternal->bEncCurFrmAsIdrFlag = true; // make sure first frame is IDR | ||
| 1216 | // pDq layers list | 1223 | // pDq layers list |
| 1217 | pDqLayer = (SDqLayer*)pMa->WelsMallocz (sizeof (SDqLayer), "pDqLayer"); | 1224 | pDqLayer = (SDqLayer*)pMa->WelsMallocz (sizeof (SDqLayer), "pDqLayer"); |
| 1218 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pDqLayer), FreeMemorySvc (ppCtx)) | 1225 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pDqLayer), FreeMemorySvc (ppCtx)) |
| @@ -1900,7 +1907,6 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 681 unmodified lines | |||
| 1900 | (pMa->WelsMallocz (iCountMaxMbNum * sizeof (int32_t), "pSadCostMb")); | 1907 | (pMa->WelsMallocz (iCountMaxMbNum * sizeof (int32_t), "pSadCostMb")); |
| 1901 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSadCostMb), FreeMemorySvc (ppCtx)) | 1908 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSadCostMb), FreeMemorySvc (ppCtx)) |
| 1902 | 1909 | ||
| 1903 | (*ppCtx)->bEncCurFrmAsIdrFlag = true; // make sure first frame is IDR | ||
| 1904 | (*ppCtx)->iGlobalQp = 26; // global qp in default | 1910 | (*ppCtx)->iGlobalQp = 26; // global qp in default |
| 1905 | 1911 | ||
| 1906 | (*ppCtx)->pLtr = (SLTRState*)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SLTRState), "SLTRState"); | 1912 | (*ppCtx)->pLtr = (SLTRState*)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SLTRState), "SLTRState"); |
| @@ -2802,7 +2808,7 @@ void WelsInitCurrentLayer (sWelsEncCtx* pCtx, · 895 unmodified lines | |||
| 2802 | SDqIdc* pDqIdc = &pCtx->pDqIdcMap[kiCurDid]; | 2808 | SDqIdc* pDqIdc = &pCtx->pDqIdcMap[kiCurDid]; |
| 2803 | int32_t iIdx = 0; | 2809 | int32_t iIdx = 0; |
| 2804 | int32_t iSliceCount = 0; | 2810 | int32_t iSliceCount = 0; |
| 2805 | 2811 | SSpatialLayerInternal* pParamInternal = &pParam->sDependencyLayers[kiCurDid]; | |
| 2806 | if (NULL == pCurDq) | 2812 | if (NULL == pCurDq) |
| 2807 | return; | 2813 | return; |
| 2808 | 2814 | ||
| @@ -2856,8 +2862,9 @@ void WelsInitCurrentLayer (sWelsEncCtx* pCtx, · 47 unmodified lines | |||
| 2856 | 2862 | ||
| 2857 | pNalHdExt->uiDependencyId = kiCurDid; | 2863 | pNalHdExt->uiDependencyId = kiCurDid; |
| 2858 | pNalHdExt->bDiscardableFlag = (pCtx->bNeedPrefixNalFlag) ? (pNalHd->uiNalRefIdc == NRI_PRI_LOWEST) : false; | 2864 | pNalHdExt->bDiscardableFlag = (pCtx->bNeedPrefixNalFlag) ? (pNalHd->uiNalRefIdc == NRI_PRI_LOWEST) : false; |
| 2859 | pNalHdExt->bIdrFlag = (pCtx->iFrameNum == 0) && ((pCtx->eNalType == NAL_UNIT_CODED_SLICE_IDR) | 2865 | pNalHdExt->bIdrFlag = (pParamInternal->iFrameNum == 0) |
| 2860 | || (pCtx->eSliceType == I_SLICE)); | 2866 | && ((pCtx->eNalType == NAL_UNIT_CODED_SLICE_IDR) |
| 2867 | || (pCtx->eSliceType == I_SLICE)); | ||
| 2861 | pNalHdExt->uiTemporalId = pCtx->uiTemporalId; | 2868 | pNalHdExt->uiTemporalId = pCtx->uiTemporalId; |
| 2862 | 2869 | ||
| 2863 | // pEncPic pData | 2870 | // pEncPic pData |
| @@ -3398,9 +3405,16 @@ int32_t WritePadding (sWelsEncCtx* pCtx, int32_t iLen, int32_t& iSize) { · 534 unmodified lines | |||
| 3398 | int32_t ForceCodingIDR (sWelsEncCtx* pCtx) { | 3405 | int32_t ForceCodingIDR (sWelsEncCtx* pCtx) { |
| 3399 | if (NULL == pCtx) | 3406 | if (NULL == pCtx) |
| 3400 | return 1; | 3407 | return 1; |
| 3408 | for (int32_t iDid = 0; iDid < pCtx->pSvcParam->iSpatialLayerNum; iDid++) { | ||
| 3409 | SSpatialLayerInternal* pParamInternal = &pCtx->pSvcParam->sDependencyLayers[iDid]; | ||
| 3410 | pParamInternal->iCodingIndex = 0; | ||
| 3411 | pParamInternal->iSkipFrameFlag = 0; | ||
| 3412 | pParamInternal->iFrameIndex = 0; | ||
| 3413 | pParamInternal->iFrameNum = 0; | ||
| 3414 | pParamInternal->iPOC = 0; | ||
| 3415 | pParamInternal->bEncCurFrmAsIdrFlag = true; | ||
| 3416 | } | ||
| 3401 | 3417 | ||
| 3402 | pCtx->bEncCurFrmAsIdrFlag = true; | ||
| 3403 | pCtx->iCodingIndex = 0; | ||
| 3404 | pCtx->bCheckWindowStatusRefreshFlag = false; | 3418 | pCtx->bCheckWindowStatusRefreshFlag = false; |
| 3405 | 3419 | ||
| 3406 | WelsLog (&pCtx->sLogCtx, WELS_LOG_INFO, "ForceCodingIDR at InputFrameCount=%d\n", | 3420 | WelsLog (&pCtx->sLogCtx, WELS_LOG_INFO, "ForceCodingIDR at InputFrameCount=%d\n", |
| @@ -3427,11 +3441,10 @@ int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) { · 20 unmodified lines | |||
| 3427 | pLayerBsInfo->uiQualityId = 0; | 3441 | pLayerBsInfo->uiQualityId = 0; |
| 3428 | pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; | 3442 | pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; |
| 3429 | pLayerBsInfo->iNalCount = iCountNal; | 3443 | pLayerBsInfo->iNalCount = iCountNal; |
| 3430 | pLayerBsInfo->eFrameType = videoFrameTypeIDR; | 3444 | pLayerBsInfo->eFrameType = videoFrameTypeInvalid; |
| 3431 | //pCtx->eLastNalPriority = NRI_PRI_HIGHEST; | 3445 | //pCtx->eLastNalPriority = NRI_PRI_HIGHEST; |
| 3432 | pFbi->iLayerNum = 1; | 3446 | pFbi->iLayerNum = 1; |
| 3433 | pFbi->eFrameType = videoFrameTypeInvalid; | 3447 | pFbi->eFrameType = videoFrameTypeInvalid; |
| 3434 | |||
| 3435 | WelsEmms(); | 3448 | WelsEmms(); |
| 3436 | 3449 | ||
| 3437 | return ENC_RETURN_SUCCESS; | 3450 | return ENC_RETURN_SUCCESS; |
| @@ -3479,75 +3492,69 @@ int32_t WriteSsvcParaset (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, · 41 unmodified lines | |||
| 3479 | } | 3492 | } |
| 3480 | 3493 | ||
| 3481 | // writing parasets for simulcast avc | 3494 | // writing parasets for simulcast avc |
| 3482 | int32_t WriteSavcParaset (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, | 3495 | int32_t WriteSavcParaset (sWelsEncCtx* pCtx, const int32_t iIdx, |
| 3483 | SLayerBSInfo*& pLayerBsInfo, int32_t& iLayerNum, int32_t& iFrameSize) { | 3496 | SLayerBSInfo*& pLayerBsInfo, int32_t& iLayerNum, int32_t& iFrameSize) { |
| 3484 | int32_t iNonVclSize = 0, iCountNal = 0, iReturn = ENC_RETURN_SUCCESS; | 3497 | int32_t iNonVclSize = 0, iCountNal = 0, iReturn = ENC_RETURN_SUCCESS; |
| 3485 | 3498 | ||
| 3486 | // write SPS | 3499 | // write SPS |
| 3487 | iNonVclSize = 0; | 3500 | iNonVclSize = 0; |
| 3488 | 3501 | ||
| 3489 | assert ((kiSpatialNum == pCtx->iSpsNum) || (SPS_LISTING & pCtx->pSvcParam->eSpsPpsIdStrategy)); | 3502 | //writing one NAL |
| 3503 | int32_t iNalSize = 0; | ||
| 3504 | iCountNal = 0; | ||
| 3490 | 3505 | ||
| 3491 | for (int32_t iIdx = 0; iIdx < pCtx->iSpsNum; iIdx++) { | 3506 | iReturn = WelsWriteOneSPS (pCtx, iIdx, iNalSize); |
| 3492 | //writing one NAL | 3507 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 3493 | int32_t iNalSize = 0; | ||
| 3494 | iCountNal = 0; | ||
| 3495 | |||
| 3496 | iReturn = WelsWriteOneSPS (pCtx, iIdx, iNalSize); | ||
| 3497 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | ||
| 3498 | 3508 | ||
| 3499 | pLayerBsInfo->pNalLengthInByte[iCountNal] = iNalSize; | 3509 | pLayerBsInfo->pNalLengthInByte[iCountNal] = iNalSize; |
| 3500 | iNonVclSize += iNalSize; | 3510 | iNonVclSize += iNalSize; |
| 3501 | iCountNal = 1; | 3511 | iCountNal = 1; |
| 3502 | //finish writing one NAL | ||
| 3503 | 3512 | ||
| 3504 | pLayerBsInfo->uiSpatialId = iIdx; | 3513 | //finish writing one NAL |
| 3505 | pLayerBsInfo->uiTemporalId = 0; | ||
| 3506 | pLayerBsInfo->uiQualityId = 0; | ||
| 3507 | pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; | ||
| 3508 | pLayerBsInfo->iNalCount = iCountNal; | ||
| 3509 | pLayerBsInfo->eFrameType = videoFrameTypeIDR; | ||
| 3510 | //point to next pLayerBsInfo | ||
| 3511 | ++ pLayerBsInfo; | ||
| 3512 | ++ pCtx->pOut->iLayerBsIndex; | ||
| 3513 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | ||
| 3514 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; | ||
| 3515 | //update for external countings | ||
| 3516 | ++ iLayerNum; | ||
| 3517 | 3514 | ||
| 3518 | } | 3515 | pLayerBsInfo->uiSpatialId = iIdx; |
| 3516 | pLayerBsInfo->uiTemporalId = 0; | ||
| 3517 | pLayerBsInfo->uiQualityId = 0; | ||
| 3518 | pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; | ||
| 3519 | pLayerBsInfo->iNalCount = iCountNal; | ||
| 3520 | pLayerBsInfo->eFrameType = videoFrameTypeIDR; | ||
| 3521 | //point to next pLayerBsInfo | ||
| 3522 | ++ pLayerBsInfo; | ||
| 3523 | ++ pCtx->pOut->iLayerBsIndex; | ||
| 3524 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | ||
| 3525 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; | ||
| 3526 | //update for external countings | ||
| 3527 | ++ iLayerNum; | ||
| 3519 | 3528 | ||
| 3520 | // write PPS | 3529 | // write PPS |
| 3521 | 3530 | ||
| 3522 | //TODO: under new strategy, will PPS be correctly updated? | 3531 | //TODO: under new strategy, will PPS be correctly updated? |
| 3523 | 3532 | ||
| 3524 | for (int32_t iIdx = 0; iIdx < pCtx->iPpsNum; iIdx++) { | 3533 | //writing one NAL |
| 3525 | //writing one NAL | 3534 | iNalSize = 0; |
| 3526 | int32_t iNalSize = 0; | 3535 | iCountNal = 0; |
| 3527 | iCountNal = 0; | ||
| 3528 | 3536 | ||
| 3529 | iReturn = WelsWriteOnePPS (pCtx, iIdx, iNalSize); | 3537 | iReturn = WelsWriteOnePPS (pCtx, iIdx, iNalSize); |
| 3530 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | 3538 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 3531 | 3539 | ||
| 3532 | pLayerBsInfo->pNalLengthInByte[iCountNal] = iNalSize; | 3540 | pLayerBsInfo->pNalLengthInByte[iCountNal] = iNalSize; |
| 3533 | iNonVclSize += iNalSize; | 3541 | iNonVclSize += iNalSize; |
| 3534 | iCountNal = 1; | 3542 | iCountNal = 1; |
| 3535 | //finish writing one NAL | 3543 | //finish writing one NAL |
| 3536 | 3544 | ||
| 3537 | pLayerBsInfo->uiSpatialId = iIdx; | 3545 | pLayerBsInfo->uiSpatialId = iIdx; |
| 3538 | pLayerBsInfo->uiTemporalId = 0; | 3546 | pLayerBsInfo->uiTemporalId = 0; |
| 3539 | pLayerBsInfo->uiQualityId = 0; | 3547 | pLayerBsInfo->uiQualityId = 0; |
| 3540 | pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; | 3548 | pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; |
| 3541 | pLayerBsInfo->iNalCount = iCountNal; | 3549 | pLayerBsInfo->iNalCount = iCountNal; |
| 3542 | pLayerBsInfo->eFrameType = videoFrameTypeIDR; | 3550 | pLayerBsInfo->eFrameType = videoFrameTypeIDR; |
| 3543 | //point to next pLayerBsInfo | 3551 | //point to next pLayerBsInfo |
| 3544 | ++ pLayerBsInfo; | 3552 | ++ pLayerBsInfo; |
| 3545 | ++ pCtx->pOut->iLayerBsIndex; | 3553 | ++ pCtx->pOut->iLayerBsIndex; |
| 3546 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 3554 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 3547 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; | 3555 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; |
| 3548 | //update for external countings | 3556 | //update for external countings |
| 3549 | ++ iLayerNum; | 3557 | ++ iLayerNum; |
| 3550 | } | ||
| 3551 | 3558 | ||
| 3552 | // to check number of layers / nals / slices dependencies | 3559 | // to check number of layers / nals / slices dependencies |
| 3553 | if (iLayerNum > MAX_LAYER_NUM_OF_FRAME) { | 3560 | if (iLayerNum > MAX_LAYER_NUM_OF_FRAME) { |
| @@ -3645,6 +3652,7 @@ int32_t WriteSavcParaset_Listing (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, · 91 unmodified lines | |||
| 3645 | 3652 | ||
| 3646 | void StackBackEncoderStatus (sWelsEncCtx* pEncCtx, | 3653 | void StackBackEncoderStatus (sWelsEncCtx* pEncCtx, |
| 3647 | EVideoFrameType keFrameType) { | 3654 | EVideoFrameType keFrameType) { |
| 3655 | SSpatialLayerInternal* pParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId]; | ||
| 3648 | // for bitstream writing | 3656 | // for bitstream writing |
| 3649 | pEncCtx->iPosBsBuffer = 0; // reset bs pBuffer position | 3657 | pEncCtx->iPosBsBuffer = 0; // reset bs pBuffer position |
| 3650 | pEncCtx->pOut->iNalIndex = 0; // reset NAL index | 3658 | pEncCtx->pOut->iNalIndex = 0; // reset NAL index |
| @@ -3652,14 +3660,15 @@ void StackBackEncoderStatus (sWelsEncCtx* pEncCtx, · 1 unmodified line | |||
| 3652 | 3660 | ||
| 3653 | InitBits (&pEncCtx->pOut->sBsWrite, pEncCtx->pOut->pBsBuffer, pEncCtx->pOut->uiSize); | 3661 | InitBits (&pEncCtx->pOut->sBsWrite, pEncCtx->pOut->pBsBuffer, pEncCtx->pOut->uiSize); |
| 3654 | if ((keFrameType == videoFrameTypeP) || (keFrameType == videoFrameTypeI)) { | 3662 | if ((keFrameType == videoFrameTypeP) || (keFrameType == videoFrameTypeI)) { |
| 3655 | pEncCtx->iFrameIndex --; | 3663 | pParamInternal->iFrameIndex --; |
| 3656 | if (pEncCtx->iPOC != 0) { | 3664 | if (pParamInternal->iPOC != 0) { |
| 3657 | pEncCtx->iPOC -= 2; | 3665 | pParamInternal->iPOC -= 2; |
| 3658 | } else { | 3666 | } else { |
| 3659 | pEncCtx->iPOC = (1 << pEncCtx->pSps->iLog2MaxPocLsb) - 2; | 3667 | pParamInternal->iPOC = (1 << pEncCtx->pSps->iLog2MaxPocLsb) - 2; |
| 3660 | } | 3668 | } |
| 3661 | 3669 | ||
| 3662 | LoadBackFrameNum (pEncCtx); | 3670 | LoadBackFrameNum (pEncCtx, pEncCtx->uiDependencyId); |
| 3671 | |||
| 3663 | pEncCtx->eNalType = NAL_UNIT_CODED_SLICE; | 3672 | pEncCtx->eNalType = NAL_UNIT_CODED_SLICE; |
| 3664 | pEncCtx->eSliceType = P_SLICE; | 3673 | pEncCtx->eSliceType = P_SLICE; |
| 3665 | //pEncCtx->eNalPriority = pEncCtx->eLastNalPriority; //not need this since eNalPriority will be updated at the beginning of coding a frame | 3674 | //pEncCtx->eNalPriority = pEncCtx->eLastNalPriority; //not need this since eNalPriority will be updated at the beginning of coding a frame |
| @@ -3682,10 +3691,10 @@ void ClearFrameBsInfo (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi) { · 16 unmodified lines | |||
| 3682 | 3691 | ||
| 3683 | for (int i = 0; i < pFbi->iLayerNum; i++) { | 3692 | for (int i = 0; i < pFbi->iLayerNum; i++) { |
| 3684 | pFbi->sLayerInfo[i].iNalCount = 0; | 3693 | pFbi->sLayerInfo[i].iNalCount = 0; |
| 3694 | pFbi->sLayerInfo[i].eFrameType = videoFrameTypeSkip; | ||
| 3685 | } | 3695 | } |
| 3686 | pFbi->iLayerNum = 0; | 3696 | pFbi->iLayerNum = 0; |
| 3687 | pFbi->iFrameSizeInBytes = 0; | 3697 | pFbi->iFrameSizeInBytes = 0; |
| 3688 | pFbi->eFrameType = videoFrameTypeSkip; | ||
| 3689 | } | 3698 | } |
| 3690 | 3699 | ||
| 3691 | /*! | 3700 | /*! |
| @@ -3725,6 +3734,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 33 unmodified lines | |||
| 3725 | int8_t iCurTid = 0; | 3734 | int8_t iCurTid = 0; |
| 3726 | bool bAvcBased = false; | 3735 | bool bAvcBased = false; |
| 3727 | SLogContext* pLogCtx = & (pCtx->sLogCtx); | 3736 | SLogContext* pLogCtx = & (pCtx->sLogCtx); |
| 3737 | bool bFinishedWriteHeader = false; | ||
| 3728 | #if defined(ENABLE_PSNR_CALC) | 3738 | #if defined(ENABLE_PSNR_CALC) |
| 3729 | float fSnrY = .0f, fSnrU = .0f, fSnrV = .0f; | 3739 | float fSnrY = .0f, fSnrU = .0f, fSnrV = .0f; |
| 3730 | #endif//ENABLE_PSNR_CALC | 3740 | #endif//ENABLE_PSNR_CALC |
| @@ -3732,7 +3742,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 1 unmodified line | |||
| 3732 | #if defined(_DEBUG) | 3742 | #if defined(_DEBUG) |
| 3733 | int32_t i = 0, j = 0, k = 0; | 3743 | int32_t i = 0, j = 0, k = 0; |
| 3734 | #endif//_DEBUG | 3744 | #endif//_DEBUG |
| 3735 | |||
| 3736 | pCtx->iEncoderError = ENC_RETURN_SUCCESS; | 3745 | pCtx->iEncoderError = ENC_RETURN_SUCCESS; |
| 3737 | pCtx->bCurFrameMarkedAsSceneLtr = false; | 3746 | pCtx->bCurFrameMarkedAsSceneLtr = false; |
| 3738 | pFbi->iLayerNum = 0; // for initialization | 3747 | pFbi->iLayerNum = 0; // for initialization |
| @@ -3746,76 +3755,116 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 7 unmodified lines | |||
| 3746 | pCtx->pFuncList->pfRc.pfWelsUpdateMaxBrWindowStatus (pCtx, iSpatialNum, pSrcPic->uiTimeStamp); | 3755 | pCtx->pFuncList->pfRc.pfWelsUpdateMaxBrWindowStatus (pCtx, iSpatialNum, pSrcPic->uiTimeStamp); |
| 3747 | } | 3756 | } |
| 3748 | 3757 | ||
| 3749 | if (iSpatialNum < 1) { // skip due to temporal layer settings (different frame rate) | 3758 | if (iSpatialNum < 1) { |
| 3750 | ++ pCtx->iCodingIndex; | 3759 | // ++ pCtx->iCodingIndex; |
| 3760 | pLayerBsInfo->eFrameType = videoFrameTypeSkip; | ||
| 3751 | pFbi->eFrameType = videoFrameTypeSkip; | 3761 | pFbi->eFrameType = videoFrameTypeSkip; |
| 3752 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, | 3762 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, |
| 3753 | "[Rc] Frame timestamp = %lld, skip one frame due to preprocessing return (temporal layer settings or else), continual skipped %d frames", | 3763 | "[Rc] Frame timestamp = %lld, skip one frame due to preprocessing return (temporal layer settings or else), continual skipped %d frames", |
| 3754 | pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); | 3764 | pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); |
| 3755 | return ENC_RETURN_SUCCESS; | 3765 | return ENC_RETURN_SUCCESS; |
| 3756 | } | 3766 | } |
| 3757 | 3767 | if (!pSvcParam->bSimulcastAVC) { | |
| 3758 | eFrameType = DecideFrameType (pCtx, iSpatialNum); | 3768 | pCtx->iSkipFrameFlag = false; |
| 3759 | if (eFrameType == videoFrameTypeSkip) { | 3769 | for (int32_t iDid = 0; iDid < iSpatialNum; iDid++) { |
| 3760 | if (pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip) | 3770 | if (pCtx->pSvcParam->sDependencyLayers[iDid].iSkipFrameFlag) |
| 3761 | pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip (pCtx, iSpatialNum); | 3771 | pCtx->iSkipFrameFlag = 1; |
| 3762 | pFbi->eFrameType = eFrameType; | ||
| 3763 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, | ||
| 3764 | "[Rc] Frame timestamp = %lld, skip one frame due to target_br, continual skipped %d frames", | ||
| 3765 | pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); | ||
| 3766 | return ENC_RETURN_SUCCESS; | ||
| 3767 | } | ||
| 3768 | |||
| 3769 | //loop each layer to check if have skip frame when RC and frame skip enable | ||
| 3770 | if (pCtx->pFuncList->pfRc.pfWelsCheckSkipBasedMaxbr) { | ||
| 3771 | bool bSkip = pCtx->pFuncList->pfRc.pfWelsCheckSkipBasedMaxbr (pCtx, iSpatialNum, eFrameType, | ||
| 3772 | (uint32_t)pSrcPic->uiTimeStamp); | ||
| 3773 | if (bSkip) { | ||
| 3774 | pFbi->eFrameType = videoFrameTypeSkip; | ||
| 3775 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, | ||
| 3776 | "[Rc] Frame timestamp = %lld, skip one frame due to max_br, continual skipped %d frames", | ||
| 3777 | pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); | ||
| 3778 | return ENC_RETURN_SUCCESS; | ||
| 3779 | } | 3772 | } |
| 3780 | } | 3773 | } |
| 3781 | 3774 | ||
| 3782 | pCtx->iContinualSkipFrames = 0; | 3775 | InitBitStream (pCtx); |
| 3783 | InitFrameCoding (pCtx, eFrameType); | ||
| 3784 | |||
| 3785 | iCurTid = GetTemporalLevel (&pSvcParam->sDependencyLayers[pSpatialIndexMap->iDid], pCtx->iCodingIndex, | ||
| 3786 | pSvcParam->uiGopSize); | ||
| 3787 | pCtx->uiTemporalId = iCurTid; | ||
| 3788 | |||
| 3789 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs ; | 3776 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs ; |
| 3790 | pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen; | 3777 | pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen; |
| 3791 | 3778 | ||
| 3792 | if (eFrameType == videoFrameTypeIDR) { | ||
| 3793 | ++ pCtx->uiIdrPicId; | ||
| 3794 | // write parameter sets bitstream or SEI/SSEI (if any) here | ||
| 3795 | // TODO: use function pointer instead | ||
| 3796 | if (! (SPS_LISTING & pCtx->pSvcParam->eSpsPpsIdStrategy)) { | ||
| 3797 | pCtx->iEncoderError = ((!pSvcParam->bSimulcastAVC) | ||
| 3798 | ? (WriteSsvcParaset (pCtx, iSpatialNum, pLayerBsInfo, iLayerNum, iFrameSize)) | ||
| 3799 | : (WriteSavcParaset (pCtx, iSpatialNum, pLayerBsInfo, iLayerNum, iFrameSize))); | ||
| 3800 | } else { | ||
| 3801 | pCtx->iEncoderError = WriteSavcParaset_Listing (pCtx, iSpatialNum, pLayerBsInfo, iLayerNum, iFrameSize); | ||
| 3802 | } | ||
| 3803 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | ||
| 3804 | } | ||
| 3805 | |||
| 3806 | pCtx->pCurDqLayer = pCtx->ppDqLayerList[pSpatialIndexMap->iDid]; | 3779 | pCtx->pCurDqLayer = pCtx->ppDqLayerList[pSpatialIndexMap->iDid]; |
| 3807 | pCtx->pCurDqLayer->pRefLayer = NULL; | 3780 | pCtx->pCurDqLayer->pRefLayer = NULL; |
| 3808 | 3781 | ||
| 3809 | while (iSpatialIdx < iSpatialNum) { | 3782 | while (iSpatialIdx < iSpatialNum) { |
| 3810 | const int32_t iDidIdx = (pSpatialIndexMap + iSpatialIdx)->iDid; // get iDid | 3783 | bool bEncoding = pCtx->pVpp->BuildSpatialLayer (pCtx, pSrcPic, iSpatialIdx); |
| 3784 | if (!bEncoding) { | ||
| 3785 | ++iSpatialIdx; | ||
| 3786 | continue; | ||
| 3787 | } | ||
| 3788 | const int32_t iDidIdx = (pSpatialIndexMap + iSpatialIdx)->iDid; | ||
| 3811 | SSpatialLayerConfig* pParam = &pSvcParam->sSpatialLayers[iDidIdx]; | 3789 | SSpatialLayerConfig* pParam = &pSvcParam->sSpatialLayers[iDidIdx]; |
| 3790 | SSpatialLayerInternal* pParamInternal = &pSvcParam->sDependencyLayers[iDidIdx]; | ||
| 3812 | int32_t iDecompositionStages = pSvcParam->sDependencyLayers[iDidIdx].iDecompositionStages; | 3791 | int32_t iDecompositionStages = pSvcParam->sDependencyLayers[iDidIdx].iDecompositionStages; |
| 3792 | pCtx->pCurDqLayer = pCtx->ppDqLayerList[iDidIdx]; | ||
| 3813 | pCtx->uiDependencyId = iCurDid = (int8_t)iDidIdx; | 3793 | pCtx->uiDependencyId = iCurDid = (int8_t)iDidIdx; |
| 3794 | |||
| 3795 | eFrameType = DecideFrameType (pCtx, iSpatialNum, iDidIdx); | ||
| 3796 | if (eFrameType == videoFrameTypeSkip) { | ||
| 3797 | eFrameType = videoFrameTypeSkip; | ||
| 3798 | pLayerBsInfo->eFrameType = eFrameType; | ||
| 3799 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, | ||
| 3800 | "[Rc] Frame timestamp = %lld, skip one frame due to target_br, continual skipped %d frames", | ||
| 3801 | pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); | ||
| 3802 | ++ iSpatialIdx; | ||
| 3803 | if (pSvcParam->bSimulcastAVC) { | ||
| 3804 | if (pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip) | ||
| 3805 | pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip (pCtx, iDidIdx); | ||
| 3806 | continue; | ||
| 3807 | } | ||
| 3808 | |||
| 3809 | else { | ||
| 3810 | if (pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip) { | ||
| 3811 | for (int32_t i = 0; i < iSpatialNum; i++) { | ||
| 3812 | pCtx->pSvcParam->sDependencyLayers[i].iSkipFrameFlag = false; | ||
| 3813 | pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip (pCtx, (pSpatialIndexMap + i)->iDid); | ||
| 3814 | } | ||
| 3815 | } | ||
| 3816 | return ENC_RETURN_SUCCESS; | ||
| 3817 | } | ||
| 3818 | } | ||
| 3819 | //loop each layer to check if have skip frame when RC and frame skip enable | ||
| 3820 | if (pCtx->pFuncList->pfRc.pfWelsCheckSkipBasedMaxbr) { | ||
| 3821 | bool bSkip = pCtx->pFuncList->pfRc.pfWelsCheckSkipBasedMaxbr (pCtx, iSpatialNum, eFrameType, | ||
| 3822 | (uint32_t)pSrcPic->uiTimeStamp); | ||
| 3823 | if (bSkip) { | ||
| 3824 | eFrameType = videoFrameTypeSkip; | ||
| 3825 | pLayerBsInfo->eFrameType = videoFrameTypeSkip; | ||
| 3826 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, | ||
| 3827 | "[Rc] Frame timestamp = %lld, skip one frame due to max_br, continual skipped %d frames", | ||
| 3828 | pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); | ||
| 3829 | ++ iSpatialIdx; | ||
| 3830 | if (pSvcParam->bSimulcastAVC) | ||
| 3831 | continue; | ||
| 3832 | else | ||
| 3833 | return ENC_RETURN_SUCCESS; | ||
| 3834 | } | ||
| 3835 | } | ||
| 3836 | pCtx->iContinualSkipFrames = 0; | ||
| 3837 | |||
| 3838 | InitFrameCoding (pCtx, eFrameType, iDidIdx); | ||
| 3839 | iCurTid = GetTemporalLevel (&pSvcParam->sDependencyLayers[iSpatialIdx], pParamInternal->iCodingIndex, | ||
| 3840 | pSvcParam->uiGopSize); | ||
| 3841 | pCtx->uiTemporalId = iCurTid; | ||
| 3842 | |||
| 3843 | if (eFrameType == videoFrameTypeIDR) { | ||
| 3844 | // write parameter sets bitstream or SEI/SSEI (if any) here | ||
| 3845 | // TODO: use function pointer instead | ||
| 3846 | if (! (SPS_LISTING & pCtx->pSvcParam->eSpsPpsIdStrategy)) { | ||
| 3847 | if (pSvcParam->bSimulcastAVC) { | ||
| 3848 | pCtx->iEncoderError = WriteSavcParaset (pCtx, iCurDid, pLayerBsInfo, iLayerNum, iFrameSize); | ||
| 3849 | ++ pCtx->uiIdrPicId; | ||
| 3850 | } else if (!bFinishedWriteHeader) { | ||
| 3851 | pCtx->iEncoderError = WriteSsvcParaset (pCtx, iSpatialNum, pLayerBsInfo, iLayerNum, iFrameSize); | ||
| 3852 | ++ pCtx->uiIdrPicId; | ||
| 3853 | bFinishedWriteHeader = true; | ||
| 3854 | } | ||
| 3855 | } else if (!bFinishedWriteHeader) { | ||
| 3856 | pCtx->iEncoderError = WriteSavcParaset_Listing (pCtx, iSpatialNum, pLayerBsInfo, iLayerNum, iFrameSize); | ||
| 3857 | bFinishedWriteHeader = true; | ||
| 3858 | ++ pCtx->uiIdrPicId; | ||
| 3859 | } | ||
| 3860 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | ||
| 3861 | } | ||
| 3862 | |||
| 3814 | pCtx->pVpp->AnalyzeSpatialPic (pCtx, iDidIdx); | 3863 | pCtx->pVpp->AnalyzeSpatialPic (pCtx, iDidIdx); |
| 3815 | 3864 | ||
| 3816 | pCtx->pEncPic = pEncPic = (pSpatialIndexMap + iSpatialIdx)->pSrc; | 3865 | pCtx->pEncPic = pEncPic = (pSpatialIndexMap + iSpatialIdx)->pSrc; |
| 3817 | pCtx->pEncPic->iPictureType = pCtx->eSliceType; | 3866 | pCtx->pEncPic->iPictureType = pCtx->eSliceType; |
| 3818 | pCtx->pEncPic->iFramePoc = pCtx->iPOC; | 3867 | pCtx->pEncPic->iFramePoc = pParamInternal->iPOC; |
| 3819 | 3868 | ||
| 3820 | iCurWidth = pParam->iVideoWidth; | 3869 | iCurWidth = pParam->iVideoWidth; |
| 3821 | iCurHeight = pParam->iVideoHeight; | 3870 | iCurHeight = pParam->iVideoHeight; |
| @@ -3880,12 +3929,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 58 unmodified lines | |||
| 3880 | fsnr = pCtx->pDecPic; | 3929 | fsnr = pCtx->pDecPic; |
| 3881 | #endif//#if defined(ENABLE_FRAME_DUMP) || defined(ENABLE_PSNR_CALC) | 3930 | #endif//#if defined(ENABLE_FRAME_DUMP) || defined(ENABLE_PSNR_CALC) |
| 3882 | pCtx->pDecPic->iPictureType = pCtx->eSliceType; | 3931 | pCtx->pDecPic->iPictureType = pCtx->eSliceType; |
| 3883 | pCtx->pDecPic->iFramePoc = pCtx->iPOC; | 3932 | pCtx->pDecPic->iFramePoc = pParamInternal->iPOC; |
| 3884 | 3933 | ||
| 3885 | WelsInitCurrentLayer (pCtx, iCurWidth, iCurHeight); | 3934 | WelsInitCurrentLayer (pCtx, iCurWidth, iCurHeight); |
| 3886 | 3935 | ||
| 3887 | pCtx->pFuncList->pMarkPic (pCtx); | 3936 | pCtx->pFuncList->pMarkPic (pCtx); |
| 3888 | if (!pCtx->pFuncList->pBuildRefList (pCtx, pCtx->iPOC, 0)) { | 3937 | if (!pCtx->pFuncList->pBuildRefList (pCtx, pParamInternal->iPOC, 0)) { |
| 3889 | WelsLog (pLogCtx, WELS_LOG_WARNING, | 3938 | WelsLog (pLogCtx, WELS_LOG_WARNING, |
| 3890 | "WelsEncoderEncodeExt(), WelsBuildRefList failed for P frames, pCtx->iNumRef0= %d. ForceCodingIDR!", | 3939 | "WelsEncoderEncodeExt(), WelsBuildRefList failed for P frames, pCtx->iNumRef0= %d. ForceCodingIDR!", |
| 3891 | pCtx->iNumRef0); | 3940 | pCtx->iNumRef0); |
| @@ -3904,7 +3953,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 12 unmodified lines | |||
| 3904 | pCtx->pVpp->AnalyzePictureComplexity (pCtx, pCtx->pEncPic, ((pCtx->eSliceType == P_SLICE) | 3953 | pCtx->pVpp->AnalyzePictureComplexity (pCtx, pCtx->pEncPic, ((pCtx->eSliceType == P_SLICE) |
| 3905 | && (pCtx->iNumRef0 > 0)) ? pCtx->pRefList0[0] : NULL, | 3954 | && (pCtx->iNumRef0 > 0)) ? pCtx->pRefList0[0] : NULL, |
| 3906 | iCurDid, (pCtx->eSliceType == P_SLICE) && pSvcParam->bEnableBackgroundDetection); | 3955 | iCurDid, (pCtx->eSliceType == P_SLICE) && pSvcParam->bEnableBackgroundDetection); |
| 3907 | WelsUpdateRefSyntax (pCtx, pCtx->iPOC, | 3956 | WelsUpdateRefSyntax (pCtx, pParamInternal->iPOC, |
| 3908 | eFrameType); //get reordering syntax used for writing slice header and transmit to encoder. | 3957 | eFrameType); //get reordering syntax used for writing slice header and transmit to encoder. |
| 3909 | PrefetchReferencePicture (pCtx, eFrameType); // update reference picture for current pDq layer | 3958 | PrefetchReferencePicture (pCtx, eFrameType); // update reference picture for current pDq layer |
| 3910 | 3959 | ||
| @@ -4033,6 +4082,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 122 unmodified lines | |||
| 4033 | pLbi->uiQualityId = 0; | 4082 | pLbi->uiQualityId = 0; |
| 4034 | pLbi->iNalCount = 0; | 4083 | pLbi->iNalCount = 0; |
| 4035 | pLbi->eFrameType = eFrameType; | 4084 | pLbi->eFrameType = eFrameType; |
| 4085 | |||
| 4036 | int32_t iIdx = 0; | 4086 | int32_t iIdx = 0; |
| 4037 | while (iIdx < kiPartitionCnt) { | 4087 | while (iIdx < kiPartitionCnt) { |
| 4038 | pCtx->pSliceThreading->pThreadPEncCtx[iIdx].pFrameBsInfo = pFbi; | 4088 | pCtx->pSliceThreading->pThreadPEncCtx[iIdx].pFrameBsInfo = pFbi; |
| @@ -4252,7 +4302,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 213 unmodified lines | |||
| 4252 | ++ iLayerNum; | 4302 | ++ iLayerNum; |
| 4253 | ++ pLayerBsInfo; | 4303 | ++ pLayerBsInfo; |
| 4254 | ++ pCtx->pOut->iLayerBsIndex; | 4304 | ++ pCtx->pOut->iLayerBsIndex; |
| 4255 | 4305 | WelsLog (pLogCtx, WELS_LOG_DEBUG, | |
| 4306 | "WelsEncoderEncodeExt() test iLayerNum = %d,iCountNal = %d,iLayerSize = %d", iLayerNum, iCountNal, iLayerSize); | ||
| 4256 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 4307 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 4257 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; | 4308 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; |
| 4258 | 4309 | ||
| @@ -4321,6 +4372,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 62 unmodified lines | |||
| 4321 | && (pCtx->pLtr[pCtx->uiDependencyId].iLTRMarkMode == LTR_DIRECT_MARK)) || eFrameType == videoFrameTypeIDR)) { | 4372 | && (pCtx->pLtr[pCtx->uiDependencyId].iLTRMarkMode == LTR_DIRECT_MARK)) || eFrameType == videoFrameTypeIDR)) { |
| 4322 | pCtx->bRefOfCurTidIsLtr[iDidIdx][iCurTid] = true; | 4373 | pCtx->bRefOfCurTidIsLtr[iDidIdx][iCurTid] = true; |
| 4323 | } | 4374 | } |
| 4375 | ++ pParamInternal->iCodingIndex; | ||
| 4324 | }//end of (iSpatialIdx/iSpatialNum) | 4376 | }//end of (iSpatialIdx/iSpatialNum) |
| 4325 | 4377 | ||
| 4326 | if (ENC_RETURN_CORRECTED == pCtx->iEncoderError) { | 4378 | if (ENC_RETURN_CORRECTED == pCtx->iEncoderError) { |
| @@ -4361,7 +4413,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 34 unmodified lines | |||
| 4361 | return 1; | 4413 | return 1; |
| 4362 | } | 4414 | } |
| 4363 | 4415 | ||
| 4364 | ++ pCtx->iCodingIndex; | 4416 | |
| 4365 | pFbi->iLayerNum = iLayerNum; | 4417 | pFbi->iLayerNum = iLayerNum; |
| 4366 | pFbi->iSubSeqId = GetSubSequenceId (pCtx, eFrameType); | 4418 | pFbi->iSubSeqId = GetSubSequenceId (pCtx, eFrameType); |
| 4367 | 4419 | ||
| @@ -4370,13 +4422,19 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 2 unmodified lines | |||
| 4370 | pFbi->iSubSeqId, iFrameSize); | 4422 | pFbi->iSubSeqId, iFrameSize); |
| 4371 | for (int32_t i = 0; i < iLayerNum; i++) | 4423 | for (int32_t i = 0; i < iLayerNum; i++) |
| 4372 | WelsLog (pLogCtx, WELS_LOG_DEBUG, | 4424 | WelsLog (pLogCtx, WELS_LOG_DEBUG, |
| 4373 | "WelsEncoderEncodeExt() OutputInfo iLayerId = %d,iNalType = %d,iNalCount = %d, first Nal Length=%d", i, | 4425 | "WelsEncoderEncodeExt() OutputInfo iLayerId = %d,iNalType = %d,iNalCount = %d, first Nal Length=%d,uiSpatialId = %d", i, |
| 4374 | pFbi->sLayerInfo[i].uiLayerType, pFbi->sLayerInfo[i].iNalCount, pFbi->sLayerInfo[i].pNalLengthInByte[0]); | 4426 | pFbi->sLayerInfo[i].uiLayerType, pFbi->sLayerInfo[i].iNalCount, pFbi->sLayerInfo[i].pNalLengthInByte[0], |
| 4427 | pFbi->sLayerInfo[i].uiSpatialId); | ||
| 4375 | WelsEmms(); | 4428 | WelsEmms(); |
| 4376 | 4429 | ||
| 4377 | pFbi->eFrameType = eFrameType; | 4430 | pLayerBsInfo->eFrameType = eFrameType; |
| 4378 | pFbi->iFrameSizeInBytes = iFrameSize; | 4431 | pFbi->iFrameSizeInBytes = iFrameSize; |
| 4379 | 4432 | pFbi->eFrameType = eFrameType; | |
| 4433 | for (int32_t k = 0; k < pFbi->iLayerNum; k++) { | ||
| 4434 | if (pFbi->eFrameType != pFbi->sLayerInfo[k].eFrameType) { | ||
| 4435 | pFbi->eFrameType = videoFrameTypeIPMixed; | ||
| 4436 | } | ||
| 4437 | } | ||
| 4380 | #ifdef _DEBUG | 4438 | #ifdef _DEBUG |
| 4381 | if (pFbi->iLayerNum > MAX_LAYER_NUM_OF_FRAME) { | 4439 | if (pFbi->iLayerNum > MAX_LAYER_NUM_OF_FRAME) { |
| 4382 | WelsLog (& pCtx->sLogCtx, WELS_LOG_ERROR, "WelsEncoderEncodeExt(), iLayerNum(%d) > MAX_LAYER_NUM_OF_FRAME(%d)!", | 4440 | WelsLog (& pCtx->sLogCtx, WELS_LOG_ERROR, "WelsEncoderEncodeExt(), iLayerNum(%d) > MAX_LAYER_NUM_OF_FRAME(%d)!", |
| @@ -4402,7 +4460,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 19 unmodified lines | |||
| 4402 | return ENC_RETURN_UNEXPECTED; | 4460 | return ENC_RETURN_UNEXPECTED; |
| 4403 | } | 4461 | } |
| 4404 | #endif | 4462 | #endif |
| 4405 | 4463 | WelsLog (& pCtx->sLogCtx, WELS_LOG_INFO, "return ENC_RETURN_SUCCESS"); | |
| 4406 | return ENC_RETURN_SUCCESS; | 4464 | return ENC_RETURN_SUCCESS; |
| 4407 | } | 4465 | } |
| 4408 | 4466 | ||
| @@ -4565,9 +4623,8 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 156 unmodified lines | |||
| 4565 | // reset the scaled spatial picture size | 4623 | // reset the scaled spatial picture size |
| 4566 | (*ppCtx)->pVpp->WelsPreprocessReset (*ppCtx); | 4624 | (*ppCtx)->pVpp->WelsPreprocessReset (*ppCtx); |
| 4567 | //if WelsInitEncoderExt succeed | 4625 | //if WelsInitEncoderExt succeed |
| 4568 | |||
| 4569 | //for LTR | 4626 | //for LTR |
| 4570 | (*ppCtx)->uiIdrPicId = uiTmpIdrPicId; | 4627 | (*ppCtx)->uiIdrPicId = uiTmpIdrPicId ;//this is for LTR!; //this is for LTR! |
| 4571 | 4628 | ||
| 4572 | //for sEncoderStatistics | 4629 | //for sEncoderStatistics |
| 4573 | memcpy ((*ppCtx)->sEncoderStatistics, sTempEncoderStatistics, sizeof (sTempEncoderStatistics)); | 4630 | memcpy ((*ppCtx)->sEncoderStatistics, sTempEncoderStatistics, sizeof (sTempEncoderStatistics)); |
| @@ -4601,7 +4658,8 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 27 unmodified lines | |||
| 4601 | pOldParam->uiGopSize = pNewParam->uiGopSize; | 4658 | pOldParam->uiGopSize = pNewParam->uiGopSize; |
| 4602 | if (pOldParam->iTemporalLayerNum != pNewParam->iTemporalLayerNum) { | 4659 | if (pOldParam->iTemporalLayerNum != pNewParam->iTemporalLayerNum) { |
| 4603 | pOldParam->iTemporalLayerNum = pNewParam->iTemporalLayerNum; | 4660 | pOldParam->iTemporalLayerNum = pNewParam->iTemporalLayerNum; |
| 4604 | (*ppCtx)->iCodingIndex = 0; | 4661 | for (int32_t iIndexD = 0; iIndexD < MAX_DEPENDENCY_LAYER; iIndexD++) |
| 4662 | pOldParam->sDependencyLayers[iIndexD].iCodingIndex = 0; | ||
| 4605 | } | 4663 | } |
| 4606 | pOldParam->iDecompStages = pNewParam->iDecompStages; | 4664 | pOldParam->iDecompStages = pNewParam->iDecompStages; |
| 4607 | /* denoise control */ | 4665 | /* denoise control */ |
| @@ -4663,7 +4721,6 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 55 unmodified lines | |||
| 4663 | 4721 | ||
| 4664 | memcpy (pOldDlpInternal->uiCodingIdx2TemporalId, pNewDlpInternal->uiCodingIdx2TemporalId, | 4722 | memcpy (pOldDlpInternal->uiCodingIdx2TemporalId, pNewDlpInternal->uiCodingIdx2TemporalId, |
| 4665 | sizeof (pOldDlpInternal->uiCodingIdx2TemporalId)); // confirmed_safe_unsafe_usage | 4723 | sizeof (pOldDlpInternal->uiCodingIdx2TemporalId)); // confirmed_safe_unsafe_usage |
| 4666 | |||
| 4667 | ++ iIndexD; | 4724 | ++ iIndexD; |
| 4668 | } while (iIndexD < pOldParam->iSpatialLayerNum); | 4725 | } while (iIndexD < pOldParam->iSpatialLayerNum); |
| 4669 | } | 4726 | } |