Showing the changes to codec/encoder/core/src/svc_encode_slice.cpp (1 of 54 files). Show all
Unified · Split
| @@ -67,10 +67,10 @@ void UpdateNonZeroCountCache (SMB* pMb, SMbCache* pMbCache) { · 66 unmodified lines | |||
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | void WelsSliceHeaderScalExtInit (SDqLayer* pCurLayer, SSlice* pSlice) { | 69 | void WelsSliceHeaderScalExtInit (SDqLayer* pCurLayer, SSlice* pSlice) { |
| 70 | SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt; | 70 | SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt; |
| 71 | SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt; | 71 | SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt; |
| 72 | 72 | ||
| 73 | uint8_t uiDependencyId = pNalHeadExt->uiDependencyId; | 73 | uint8_t uiDependencyId = pNalHeadExt->uiDependencyId; |
| 74 | 74 | ||
| 75 | pSliceHeadExt->bSliceSkipFlag = false; | 75 | pSliceHeadExt->bSliceSkipFlag = false; |
| 76 | 76 | ||
| @@ -90,7 +90,7 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice* · 13 unmodified lines | |||
| 90 | SSliceHeaderExt* pCurSliceExt = &pSlice->sSliceHeaderExt; | 90 | SSliceHeaderExt* pCurSliceExt = &pSlice->sSliceHeaderExt; |
| 91 | SSliceHeader* pCurSliceHeader = &pCurSliceExt->sSliceHeader; | 91 | SSliceHeader* pCurSliceHeader = &pCurSliceExt->sSliceHeader; |
| 92 | 92 | ||
| 93 | pCurSliceHeader->eSliceType = pEncCtx->eSliceType; | 93 | pCurSliceHeader->eSliceType = pEncCtx->eSliceType; |
| 94 | 94 | ||
| 95 | pCurSliceExt->bStoreRefBasePicFlag = false; | 95 | pCurSliceExt->bStoreRefBasePicFlag = false; |
| 96 | 96 | ||
| @@ -99,14 +99,14 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice* · 2 unmodified lines | |||
| 99 | pCurSliceHeader->iFrameNum = pEncCtx->iFrameNum; | 99 | pCurSliceHeader->iFrameNum = pEncCtx->iFrameNum; |
| 100 | pCurSliceHeader->uiIdrPicId = pEncCtx->uiIdrPicId; | 100 | pCurSliceHeader->uiIdrPicId = pEncCtx->uiIdrPicId; |
| 101 | 101 | ||
| 102 | pCurSliceHeader->iPicOrderCntLsb = pEncCtx->pEncPic->iFramePoc; // 0 | 102 | pCurSliceHeader->iPicOrderCntLsb = pEncCtx->pEncPic->iFramePoc; // 0 |
| 103 | 103 | ||
| 104 | if (P_SLICE == pEncCtx->eSliceType) { | 104 | if (P_SLICE == pEncCtx->eSliceType) { |
| 105 | pCurSliceHeader->uiNumRefIdxL0Active = 1; | 105 | pCurSliceHeader->uiNumRefIdxL0Active = 1; |
| 106 | if (pCurSliceHeader->uiRefCount > 0 && | 106 | if (pCurSliceHeader->uiRefCount > 0 && |
| 107 | pCurSliceHeader->uiRefCount < pCurLayer->sLayerInfo.pSpsP->iNumRefFrames) { | 107 | pCurSliceHeader->uiRefCount < pCurLayer->sLayerInfo.pSpsP->iNumRefFrames) { |
| 108 | pCurSliceHeader->bNumRefIdxActiveOverrideFlag = true; | 108 | pCurSliceHeader->bNumRefIdxActiveOverrideFlag = true; |
| 109 | pCurSliceHeader->uiNumRefIdxL0Active = pCurSliceHeader->uiRefCount; | 109 | pCurSliceHeader->uiNumRefIdxL0Active = pCurSliceHeader->uiRefCount; |
| 110 | } | 110 | } |
| 111 | //to solve mismatch between debug&release | 111 | //to solve mismatch between debug&release |
| 112 | else { | 112 | else { |
| @@ -117,23 +117,23 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice* · 4 unmodified lines | |||
| 117 | pCurSliceHeader->iSliceQpDelta = pEncCtx->iGlobalQp - pCurLayer->sLayerInfo.pPpsP->iPicInitQp; | 117 | pCurSliceHeader->iSliceQpDelta = pEncCtx->iGlobalQp - pCurLayer->sLayerInfo.pPpsP->iPicInitQp; |
| 118 | 118 | ||
| 119 | //for deblocking initial | 119 | //for deblocking initial |
| 120 | pCurSliceHeader->uiDisableDeblockingFilterIdc = pCurLayer->iLoopFilterDisableIdc; | 120 | pCurSliceHeader->uiDisableDeblockingFilterIdc = pCurLayer->iLoopFilterDisableIdc; |
| 121 | pCurSliceHeader->iSliceAlphaC0Offset = | 121 | pCurSliceHeader->iSliceAlphaC0Offset = |
| 122 | pCurLayer->iLoopFilterAlphaC0Offset; // need update iSliceAlphaC0Offset & iSliceBetaOffset for pSlice-header if loop_filter_idc != 1 | 122 | pCurLayer->iLoopFilterAlphaC0Offset; // need update iSliceAlphaC0Offset & iSliceBetaOffset for pSlice-header if loop_filter_idc != 1 |
| 123 | pCurSliceHeader->iSliceBetaOffset = pCurLayer->iLoopFilterBetaOffset; | 123 | pCurSliceHeader->iSliceBetaOffset = pCurLayer->iLoopFilterBetaOffset; |
| 124 | pCurSliceExt->uiDisableInterLayerDeblockingFilterIdc = pCurLayer->uiDisableInterLayerDeblockingFilterIdc; | 124 | pCurSliceExt->uiDisableInterLayerDeblockingFilterIdc = pCurLayer->uiDisableInterLayerDeblockingFilterIdc; |
| 125 | 125 | ||
| 126 | if (pSlice->bSliceHeaderExtFlag) { | 126 | if (pSlice->bSliceHeaderExtFlag) { |
| 127 | WelsSliceHeaderScalExtInit (pCurLayer, pSlice); | 127 | WelsSliceHeaderScalExtInit (pCurLayer, pSlice); |
| 128 | } else { | 128 | } else { |
| 129 | //both adaptive and default flags should equal to 0. | 129 | //both adaptive and default flags should equal to 0. |
| 130 | pCurSliceExt->bAdaptiveBaseModeFlag = | 130 | pCurSliceExt->bAdaptiveBaseModeFlag = |
| 131 | pCurSliceExt->bAdaptiveMotionPredFlag = | 131 | pCurSliceExt->bAdaptiveMotionPredFlag = |
| 132 | pCurSliceExt->bAdaptiveResidualPredFlag = false; | 132 | pCurSliceExt->bAdaptiveResidualPredFlag = false; |
| 133 | 133 | ||
| 134 | pCurSliceExt->bDefaultBaseModeFlag = | 134 | pCurSliceExt->bDefaultBaseModeFlag = |
| 135 | pCurSliceExt->bDefaultMotionPredFlag = | 135 | pCurSliceExt->bDefaultMotionPredFlag = |
| 136 | pCurSliceExt->bDefaultResidualPredFlag = false; | 136 | pCurSliceExt->bDefaultResidualPredFlag = false; |
| 137 | } | 137 | } |
| 138 | } | 138 | } |
| 139 | 139 | ||
| @@ -204,7 +204,7 @@ void WriteReferenceReorder (SBitStringAux* pBs, SSliceHeader* sSliceHeader) { · 64 unmodified lines | |||
| 204 | * \brief write reference picture marking syntax in pSlice header | 204 | * \brief write reference picture marking syntax in pSlice header |
| 205 | */ | 205 | */ |
| 206 | void WriteRefPicMarking (SBitStringAux* pBs, SSliceHeader* pSliceHeader, SNalUnitHeaderExt* pNalHdrExt) { | 206 | void WriteRefPicMarking (SBitStringAux* pBs, SSliceHeader* pSliceHeader, SNalUnitHeaderExt* pNalHdrExt) { |
| 207 | SRefPicMarking* sRefMarking = &pSliceHeader->sRefMarking; | 207 | SRefPicMarking* sRefMarking = &pSliceHeader->sRefMarking; |
| 208 | int16_t n = 0; | 208 | int16_t n = 0; |
| 209 | 209 | ||
| 210 | if (pNalHdrExt->bIdrFlag) { | 210 | if (pNalHdrExt->bIdrFlag) { |
| @@ -503,7 +503,7 @@ int32_t WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encodin · 292 unmodified lines | |||
| 503 | } | 503 | } |
| 504 | for (; ;) { | 504 | for (; ;) { |
| 505 | pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, 0); | 505 | pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, 0); |
| 506 | iCurMbIdx = iNextMbIdx; | 506 | iCurMbIdx = iNextMbIdx; |
| 507 | pCurMb = &pMbList[ iCurMbIdx ]; | 507 | pCurMb = &pMbList[ iCurMbIdx ]; |
| 508 | 508 | ||
| 509 | pEncCtx->pFuncList->pfRc.pfWelsRcMbInit (pEncCtx, pCurMb, pSlice); | 509 | pEncCtx->pFuncList->pfRc.pfWelsRcMbInit (pEncCtx, pCurMb, pSlice); |
| @@ -567,7 +567,7 @@ int32_t WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + · 57 unmodified lines | |||
| 567 | WelsInitSliceCabac (pEncCtx, pSlice); | 567 | WelsInitSliceCabac (pEncCtx, pSlice); |
| 568 | } | 568 | } |
| 569 | for (; ;) { | 569 | for (; ;) { |
| 570 | iCurMbIdx = iNextMbIdx; | 570 | iCurMbIdx = iNextMbIdx; |
| 571 | pCurMb = &pMbList[ iCurMbIdx ]; | 571 | pCurMb = &pMbList[ iCurMbIdx ]; |
| 572 | 572 | ||
| 573 | pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, 0); | 573 | pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, 0); |
| @@ -618,7 +618,7 @@ TRY_REENCODING: · 44 unmodified lines | |||
| 618 | iNextMbIdx = WelsGetNextMbOfSlice (pSliceCtx, iCurMbIdx); | 618 | iNextMbIdx = WelsGetNextMbOfSlice (pSliceCtx, iCurMbIdx); |
| 619 | //whether all of MB in current pSlice encoded or not | 619 | //whether all of MB in current pSlice encoded or not |
| 620 | if (iNextMbIdx == -1 || iNextMbIdx >= kiTotalNumMb || iNumMbCoded >= kiTotalNumMb) { | 620 | if (iNextMbIdx == -1 || iNextMbIdx >= kiTotalNumMb || iNumMbCoded >= kiTotalNumMb) { |
| 621 | pSliceCtx->pCountMbNumInSlice[kiSliceIdx] = iCurMbIdx - pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId]; | 621 | pSliceCtx->pCountMbNumInSlice[kiSliceIdx] = iCurMbIdx - pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId]; |
| 622 | pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId] = | 622 | pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId] = |
| 623 | iCurMbIdx; // update pLastCodedMbIdxOfPartition, finish coding, use iCurMbIdx directly | 623 | iCurMbIdx; // update pLastCodedMbIdxOfPartition, finish coding, use iCurMbIdx directly |
| 624 | break; | 624 | break; |
| @@ -662,38 +662,38 @@ int32_t WelsPSliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool · 37 unmodified lines | |||
| 662 | 662 | ||
| 663 | int32_t WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) { | 663 | int32_t WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) { |
| 664 | //pSlice-level init should be outside and before this function | 664 | //pSlice-level init should be outside and before this function |
| 665 | SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; | 665 | SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; |
| 666 | 666 | ||
| 667 | const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag; | 667 | const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag; |
| 668 | const bool kbHighestSpatial = pEncCtx->pSvcParam->iSpatialLayerNum == | 668 | const bool kbHighestSpatial = pEncCtx->pSvcParam->iSpatialLayerNum == |
| 669 | (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1); | 669 | (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1); |
| 670 | 670 | ||
| 671 | //MD switch | 671 | //MD switch |
| 672 | if (kbBaseAvail && kbHighestSpatial) { | 672 | if (kbBaseAvail && kbHighestSpatial) { |
| 673 | //initial pMd pointer | 673 | //initial pMd pointer |
| 674 | pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer; | 674 | pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer; |
| 675 | } else { | 675 | } else { |
| 676 | //initial pMd pointer | 676 | //initial pMd pointer |
| 677 | pEncCtx->pFuncList->pfInterMd = WelsMdInterMb; | 677 | pEncCtx->pFuncList->pfInterMd = WelsMdInterMb; |
| 678 | } | 678 | } |
| 679 | return WelsPSliceMdEnc (pEncCtx, pSlice, kbHighestSpatial); | 679 | return WelsPSliceMdEnc (pEncCtx, pSlice, kbHighestSpatial); |
| 680 | } | 680 | } |
| 681 | 681 | ||
| 682 | int32_t WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) { | 682 | int32_t WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) { |
| 683 | //pSlice-level init should be outside and before this function | 683 | //pSlice-level init should be outside and before this function |
| 684 | SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; | 684 | SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; |
| 685 | 685 | ||
| 686 | const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag; | 686 | const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag; |
| 687 | const bool kbHighestSpatial = pEncCtx->pSvcParam->iSpatialLayerNum == | 687 | const bool kbHighestSpatial = pEncCtx->pSvcParam->iSpatialLayerNum == |
| 688 | (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1); | 688 | (pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1); |
| 689 | 689 | ||
| 690 | //MD switch | 690 | //MD switch |
| 691 | if (kbBaseAvail && kbHighestSpatial) { | 691 | if (kbBaseAvail && kbHighestSpatial) { |
| 692 | //initial pMd pointer | 692 | //initial pMd pointer |
| 693 | pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer; | 693 | pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer; |
| 694 | } else { | 694 | } else { |
| 695 | //initial pMd pointer | 695 | //initial pMd pointer |
| 696 | pEncCtx->pFuncList->pfInterMd = WelsMdInterMb; | 696 | pEncCtx->pFuncList->pfInterMd = WelsMdInterMb; |
| 697 | } | 697 | } |
| 698 | return WelsPSliceMdEncDynamic (pEncCtx, pSlice, kbHighestSpatial); | 698 | return WelsPSliceMdEncDynamic (pEncCtx, pSlice, kbHighestSpatial); |
| 699 | } | 699 | } |
| @@ -781,9 +781,9 @@ void UpdateMbNeighbourInfoForNextSlice (SSliceCtx* pSliceCtx, · 81 unmodified lines | |||
| 781 | bool bLeftTop; | 781 | bool bLeftTop; |
| 782 | bool bRightTop; | 782 | bool bRightTop; |
| 783 | int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY; | 783 | int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY; |
| 784 | const uint16_t kuiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY); | 784 | const uint16_t kuiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY); |
| 785 | 785 | ||
| 786 | pMb->uiSliceIdc = kuiSliceIdc; | 786 | pMb->uiSliceIdc = kuiSliceIdc; |
| 787 | iLeftXY = kiMbXY - 1; | 787 | iLeftXY = kiMbXY - 1; |
| 788 | iTopXY = kiMbXY - kiMbWidth; | 788 | iTopXY = kiMbXY - kiMbWidth; |
| 789 | iLeftTopXY = iTopXY - 1; | 789 | iLeftTopXY = iTopXY - 1; |
| @@ -806,7 +806,7 @@ void UpdateMbNeighbourInfoForNextSlice (SSliceCtx* pSliceCtx, · 16 unmodified lines | |||
| 806 | if (bRightTop) { | 806 | if (bRightTop) { |
| 807 | uiNeighborAvailFlag |= TOPRIGHT_MB_POS; | 807 | uiNeighborAvailFlag |= TOPRIGHT_MB_POS; |
| 808 | } | 808 | } |
| 809 | pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; | 809 | pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; |
| 810 | 810 | ||
| 811 | ++ pMb; | 811 | ++ pMb; |
| 812 | ++ iIdx; | 812 | ++ iIdx; |
| @@ -824,10 +824,10 @@ void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSlic · 11 unmodified lines | |||
| 824 | uint16_t iNextSliceIdc = iCurSliceIdc + kiSliceIdxStep; | 824 | uint16_t iNextSliceIdc = iCurSliceIdc + kiSliceIdxStep; |
| 825 | SSlice* pNextSlice = NULL; | 825 | SSlice* pNextSlice = NULL; |
| 826 | 826 | ||
| 827 | SMB* pMbList = pCurLayer->sMbDataP; | 827 | SMB* pMbList = pCurLayer->sMbDataP; |
| 828 | 828 | ||
| 829 | //update cur pSlice info | 829 | //update cur pSlice info |
| 830 | pCurSlice->sSliceHeaderExt.uiNumMbsInSlice = 1 + iCurMbIdx - pCurSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; | 830 | pCurSlice->sSliceHeaderExt.uiNumMbsInSlice = 1 + iCurMbIdx - pCurSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; |
| 831 | 831 | ||
| 832 | //pNextSlice pointer/initialization | 832 | //pNextSlice pointer/initialization |
| 833 | pNextSlice = & (pCurLayer->sLayerInfo.pSliceInLayer[ iNextSliceIdc ]); | 833 | pNextSlice = & (pCurLayer->sLayerInfo.pSliceInLayer[ iNextSliceIdc ]); |
| @@ -860,7 +860,7 @@ bool DynSlcJudgeSliceBoundaryStepBack (void* pCtx, void* pSlice, SSliceCtx* pSli · 26 unmodified lines | |||
| 860 | int32_t iPosBitOffset = 0; | 860 | int32_t iPosBitOffset = 0; |
| 861 | const int32_t kiActiveThreadsNum = pEncCtx->iActiveThreadsNum; | 861 | const int32_t kiActiveThreadsNum = pEncCtx->iActiveThreadsNum; |
| 862 | const int32_t kiPartitaionId = pCurSlice->uiSliceIdx % kiActiveThreadsNum; | 862 | const int32_t kiPartitaionId = pCurSlice->uiSliceIdx % kiActiveThreadsNum; |
| 863 | const int32_t kiLastMbIdxInPartition = pEncCtx->pCurDqLayer->pLastMbIdxOfPartition[kiPartitaionId]; | 863 | const int32_t kiLastMbIdxInPartition = pEncCtx->pCurDqLayer->pLastMbIdxOfPartition[kiPartitaionId]; |
| 864 | 864 | ||
| 865 | const bool kbCurMbNotFirstMbOfCurSlice = (pSliceCtx->pOverallMbMap[iCurMbIdx] == | 865 | const bool kbCurMbNotFirstMbOfCurSlice = (pSliceCtx->pOverallMbMap[iCurMbIdx] == |
| 866 | pSliceCtx->pOverallMbMap[iCurMbIdx - 1]); | 866 | pSliceCtx->pOverallMbMap[iCurMbIdx - 1]); |
| @@ -963,7 +963,7 @@ int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, · 96 unmodified lines | |||
| 963 | for (;;) { | 963 | for (;;) { |
| 964 | pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, pSlice->iMbSkipRun); | 964 | pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, pSlice->iMbSkipRun); |
| 965 | //point to current pMb | 965 | //point to current pMb |
| 966 | iCurMbIdx = iNextMbIdx; | 966 | iCurMbIdx = iNextMbIdx; |
| 967 | pCurMb = &pMbList[ iCurMbIdx ]; | 967 | pCurMb = &pMbList[ iCurMbIdx ]; |
| 968 | 968 | ||
| 969 | 969 | ||
| @@ -1060,7 +1060,7 @@ int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, · 90 unmodified lines | |||
| 1060 | pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, pSlice->iMbSkipRun); | 1060 | pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, pSlice->iMbSkipRun); |
| 1061 | 1061 | ||
| 1062 | //point to current pMb | 1062 | //point to current pMb |
| 1063 | iCurMbIdx = iNextMbIdx; | 1063 | iCurMbIdx = iNextMbIdx; |
| 1064 | pCurMb = &pMbList[ iCurMbIdx ]; | 1064 | pCurMb = &pMbList[ iCurMbIdx ]; |
| 1065 | 1065 | ||
| 1066 | //step(1): set QP for the current MB | 1066 | //step(1): set QP for the current MB |