Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 7 files). Show all
Unified · Split
| @@ -1812,8 +1812,9 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 1811 unmodified lines | |||
| 1812 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->sNalList), FreeMemorySvc (ppCtx)) | 1812 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->sNalList), FreeMemorySvc (ppCtx)) |
| 1813 | (*ppCtx)->pOut->pNalLen = (int32_t*)pMa->WelsMallocz (iCountNals * sizeof (int32_t), "pOut->pNalLen"); | 1813 | (*ppCtx)->pOut->pNalLen = (int32_t*)pMa->WelsMallocz (iCountNals * sizeof (int32_t), "pOut->pNalLen"); |
| 1814 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->pNalLen), FreeMemorySvc (ppCtx)) | 1814 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->pNalLen), FreeMemorySvc (ppCtx)) |
| 1815 | (*ppCtx)->pOut->iCountNals = iCountNals; | 1815 | (*ppCtx)->pOut->iCountNals = iCountNals; |
| 1816 | (*ppCtx)->pOut->iNalIndex = 0; | 1816 | (*ppCtx)->pOut->iNalIndex = 0; |
| 1817 | (*ppCtx)->pOut->iLayerBsIndex = 0; | ||
| 1817 | 1818 | ||
| 1818 | 1819 | ||
| 1819 | (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iTotalLength, "pFrameBs"); | 1820 | (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iTotalLength, "pFrameBs"); |
| @@ -3520,8 +3521,10 @@ int32_t WriteSsvcParaset (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, · 1700 unmodified lines | |||
| 3520 | 3521 | ||
| 3521 | //point to next pLayerBsInfo | 3522 | //point to next pLayerBsInfo |
| 3522 | ++ pLayerBsInfo; | 3523 | ++ pLayerBsInfo; |
| 3524 | ++ pCtx->pOut->iLayerBsIndex; | ||
| 3523 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 3525 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 3524 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; | 3526 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; |
| 3527 | |||
| 3525 | //update for external countings | 3528 | //update for external countings |
| 3526 | ++ iLayerNum; | 3529 | ++ iLayerNum; |
| 3527 | iFrameSize += iNonVclSize; | 3530 | iFrameSize += iNonVclSize; |
| @@ -3557,6 +3560,7 @@ int32_t WriteSavcParaset (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, · 29 unmodified lines | |||
| 3557 | 3560 | ||
| 3558 | //point to next pLayerBsInfo | 3561 | //point to next pLayerBsInfo |
| 3559 | ++ pLayerBsInfo; | 3562 | ++ pLayerBsInfo; |
| 3563 | ++ pCtx->pOut->iLayerBsIndex; | ||
| 3560 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 3564 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 3561 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; | 3565 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; |
| 3562 | //update for external countings | 3566 | //update for external countings |
| @@ -3588,6 +3592,7 @@ int32_t WriteSavcParaset (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, · 25 unmodified lines | |||
| 3588 | 3592 | ||
| 3589 | //point to next pLayerBsInfo | 3593 | //point to next pLayerBsInfo |
| 3590 | ++ pLayerBsInfo; | 3594 | ++ pLayerBsInfo; |
| 3595 | ++ pCtx->pOut->iLayerBsIndex; | ||
| 3591 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 3596 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 3592 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; | 3597 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; |
| 3593 | //update for external countings | 3598 | //update for external countings |
| @@ -3636,6 +3641,7 @@ int32_t WriteSavcParaset_Listing (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, · 42 unmodified lines | |||
| 3636 | 3641 | ||
| 3637 | //point to next pLayerBsInfo | 3642 | //point to next pLayerBsInfo |
| 3638 | ++ pLayerBsInfo; | 3643 | ++ pLayerBsInfo; |
| 3644 | ++ pCtx->pOut->iLayerBsIndex; | ||
| 3639 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 3645 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 3640 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; | 3646 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; |
| 3641 | //update for external countings | 3647 | //update for external countings |
| @@ -3671,6 +3677,7 @@ int32_t WriteSavcParaset_Listing (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, · 29 unmodified lines | |||
| 3671 | 3677 | ||
| 3672 | //point to next pLayerBsInfo | 3678 | //point to next pLayerBsInfo |
| 3673 | ++ pLayerBsInfo; | 3679 | ++ pLayerBsInfo; |
| 3680 | ++ pCtx->pOut->iLayerBsIndex; | ||
| 3674 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 3681 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 3675 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; | 3682 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; |
| 3676 | //update for external countings | 3683 | //update for external countings |
| @@ -3692,8 +3699,9 @@ int32_t WriteSavcParaset_Listing (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, · 15 unmodified lines | |||
| 3692 | void StackBackEncoderStatus (sWelsEncCtx* pEncCtx, | 3699 | void StackBackEncoderStatus (sWelsEncCtx* pEncCtx, |
| 3693 | EVideoFrameType keFrameType) { | 3700 | EVideoFrameType keFrameType) { |
| 3694 | // for bitstream writing | 3701 | // for bitstream writing |
| 3695 | pEncCtx->iPosBsBuffer = 0; // reset bs pBuffer position | 3702 | pEncCtx->iPosBsBuffer = 0; // reset bs pBuffer position |
| 3696 | pEncCtx->pOut->iNalIndex = 0; // reset NAL index | 3703 | pEncCtx->pOut->iNalIndex = 0; // reset NAL index |
| 3704 | pEncCtx->pOut->iLayerBsIndex = 0; // reset index of Layer Bs | ||
| 3697 | 3705 | ||
| 3698 | InitBits (&pEncCtx->pOut->sBsWrite, pEncCtx->pOut->pBsBuffer, pEncCtx->pOut->uiSize); | 3706 | InitBits (&pEncCtx->pOut->sBsWrite, pEncCtx->pOut->pBsBuffer, pEncCtx->pOut->uiSize); |
| 3699 | if ((keFrameType == videoFrameTypeP) || (keFrameType == videoFrameTypeI)) { | 3707 | if ((keFrameType == videoFrameTypeP) || (keFrameType == videoFrameTypeI)) { |
| @@ -4033,7 +4041,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 333 unmodified lines | |||
| 4033 | iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], | 4041 | iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], |
| 4034 | &pCtx->pSliceThreading->pReadySliceCodingEvent[0], | 4042 | &pCtx->pSliceThreading->pReadySliceCodingEvent[0], |
| 4035 | &pCtx->pSliceThreading->pThreadMasterEvent[0], | 4043 | &pCtx->pSliceThreading->pThreadMasterEvent[0], |
| 4036 | pLayerBsInfo, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false); | 4044 | pFbi, iSliceCount, pCtx->pCurDqLayer->pSliceEncCtx, false); |
| 4037 | if (iRet) { | 4045 | if (iRet) { |
| 4038 | WelsLog (pLogCtx, WELS_LOG_ERROR, | 4046 | WelsLog (pLogCtx, WELS_LOG_ERROR, |
| 4039 | "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!", | 4047 | "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!", |
| @@ -4073,7 +4081,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 33 unmodified lines | |||
| 4073 | iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], | 4081 | iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], |
| 4074 | &pCtx->pSliceThreading->pReadySliceCodingEvent[0], | 4082 | &pCtx->pSliceThreading->pReadySliceCodingEvent[0], |
| 4075 | &pCtx->pSliceThreading->pThreadMasterEvent[0], | 4083 | &pCtx->pSliceThreading->pThreadMasterEvent[0], |
| 4076 | pLayerBsInfo, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false); | 4084 | pFbi, iNumThreadsRunning, pCtx->pCurDqLayer->pSliceEncCtx, false); |
| 4077 | if (iRet) { | 4085 | if (iRet) { |
| 4078 | WelsLog (pLogCtx, WELS_LOG_ERROR, | 4086 | WelsLog (pLogCtx, WELS_LOG_ERROR, |
| 4079 | "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!", | 4087 | "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!", |
| @@ -4120,7 +4128,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 40 unmodified lines | |||
| 4120 | iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], | 4128 | iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], |
| 4121 | &pCtx->pSliceThreading->pReadySliceCodingEvent[0], | 4129 | &pCtx->pSliceThreading->pReadySliceCodingEvent[0], |
| 4122 | &pCtx->pSliceThreading->pThreadMasterEvent[0], | 4130 | &pCtx->pSliceThreading->pThreadMasterEvent[0], |
| 4123 | pLayerBsInfo, kiPartitionCnt, pCtx->pCurDqLayer->pSliceEncCtx, true); | 4131 | pFbi, kiPartitionCnt, pCtx->pCurDqLayer->pSliceEncCtx, true); |
| 4124 | if (iRet) { | 4132 | if (iRet) { |
| 4125 | WelsLog (pLogCtx, WELS_LOG_ERROR, | 4133 | WelsLog (pLogCtx, WELS_LOG_ERROR, |
| 4126 | "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!", | 4134 | "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iCountThreadsNum= %d, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!", |
| @@ -4332,6 +4340,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 205 unmodified lines | |||
| 4332 | iCountNal = pLayerBsInfo->iNalCount; | 4340 | iCountNal = pLayerBsInfo->iNalCount; |
| 4333 | ++ iLayerNum; | 4341 | ++ iLayerNum; |
| 4334 | ++ pLayerBsInfo; | 4342 | ++ pLayerBsInfo; |
| 4343 | ++ pCtx->pOut->iLayerBsIndex; | ||
| 4335 | 4344 | ||
| 4336 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 4345 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 4337 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; | 4346 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; |
| @@ -4360,6 +4369,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 22 unmodified lines | |||
| 4360 | pLayerBsInfo->iNalCount = 1; | 4369 | pLayerBsInfo->iNalCount = 1; |
| 4361 | pLayerBsInfo->pNalLengthInByte[0] = iPaddingNalSize; | 4370 | pLayerBsInfo->pNalLengthInByte[0] = iPaddingNalSize; |
| 4362 | ++ pLayerBsInfo; | 4371 | ++ pLayerBsInfo; |
| 4372 | ++ pCtx->pOut->iLayerBsIndex; | ||
| 4363 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 4373 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 4364 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + 1; | 4374 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + 1; |
| 4365 | ++ iLayerNum; | 4375 | ++ iLayerNum; |
| @@ -4928,6 +4938,7 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 562 unmodified lines | |||
| 4928 | pCurLayer->pSliceEncCtx->iMaxSliceNumConstraint = iMaxSliceNum; | 4938 | pCurLayer->pSliceEncCtx->iMaxSliceNumConstraint = iMaxSliceNum; |
| 4929 | return ENC_RETURN_SUCCESS; | 4939 | return ENC_RETURN_SUCCESS; |
| 4930 | } | 4940 | } |
| 4941 | |||
| 4931 | int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, | 4942 | int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, |
| 4932 | SFrameBSInfo* pFrameBSInfo, | 4943 | SFrameBSInfo* pFrameBSInfo, |
| 4933 | SLayerBSInfo* pLayerBsInfo, | 4944 | SLayerBSInfo* pLayerBsInfo, |