Showing the changes to codec/encoder/core/src/svc_encode_slice.cpp (1 of 8 files). Show all
Unified · Split
| @@ -94,8 +94,6 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice* · 93 unmodified lines | |||
| 94 | 94 | ||
| 95 | pCurSliceExt->bStoreRefBasePicFlag = false; | 95 | pCurSliceExt->bStoreRefBasePicFlag = false; |
| 96 | 96 | ||
| 97 | pCurSliceHeader->iFirstMbInSlice = WelsGetFirstMbOfSlice (pCurLayer->ppSliceInLayer, pSlice->uiSliceIdx); | ||
| 98 | |||
| 99 | pCurSliceHeader->iFrameNum = pParamInternal->iFrameNum; | 97 | pCurSliceHeader->iFrameNum = pParamInternal->iFrameNum; |
| 100 | pCurSliceHeader->uiIdrPicId = pParamInternal->uiIdrPicId; | 98 | pCurSliceHeader->uiIdrPicId = pParamInternal->uiIdrPicId; |
| 101 | pCurSliceHeader->iPicOrderCntLsb = pEncCtx->pEncPic->iFramePoc; // 0 | 99 | pCurSliceHeader->iPicOrderCntLsb = pEncCtx->pEncPic->iFramePoc; // 0 |
| @@ -814,49 +812,64 @@ void FreeMbCache (SMbCache* pMbCache, CMemoryAlign* pMa) { · 712 unmodified lines | |||
| 814 | } | 812 | } |
| 815 | } | 813 | } |
| 816 | 814 | ||
| 817 | //Initialize slice's MB info) | 815 | //Initialize slice's boundary info) |
| 818 | int32_t InitSliceMBInfo (SSliceArgument* pSliceArgument, | 816 | int32_t InitSliceBoundaryInfo (SDqLayer* pCurLayer, SSliceArgument* pSliceArgument) { |
| 819 | SSlice* pSlice, | 817 | |
| 820 | const int32_t kiMBWidth, | ||
| 821 | const int32_t kiMBHeight) { | ||
| 822 | SSliceHeader* pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; | ||
| 823 | const int32_t* kpSlicesAssignList = (int32_t*) & (pSliceArgument->uiSliceMbNum[0]); | 818 | const int32_t* kpSlicesAssignList = (int32_t*) & (pSliceArgument->uiSliceMbNum[0]); |
| 819 | const int32_t kiMBWidth = pCurLayer->iMbWidth; | ||
| 820 | const int32_t kiMBHeight = pCurLayer->iMbHeight; | ||
| 824 | const int32_t kiCountNumMbInFrame = kiMBWidth * kiMBHeight; | 821 | const int32_t kiCountNumMbInFrame = kiMBWidth * kiMBHeight; |
| 825 | const int32_t kiSliceIdx = pSlice->uiSliceIdx; | 822 | int32_t iSliceIdx = 0; |
| 826 | int32_t iFirstMBInSlice = 0; | 823 | int32_t iFirstMBInSlice = 0; |
| 827 | int32_t iMbNumInSlice = 0; | 824 | int32_t iMbNumInSlice = 0; |
| 828 | 825 | ||
| 829 | if (SM_SINGLE_SLICE == pSliceArgument->uiSliceMode) { | 826 | for( ;iSliceIdx < pCurLayer->iMaxSliceNum; iSliceIdx++ ){ |
| 830 | iFirstMBInSlice = 0; | 827 | if (SM_SINGLE_SLICE == pSliceArgument->uiSliceMode) { |
| 831 | iMbNumInSlice = kiCountNumMbInFrame; | 828 | iFirstMBInSlice = 0; |
| 829 | iMbNumInSlice = kiCountNumMbInFrame; | ||
| 832 | 830 | ||
| 833 | } else if ((SM_RASTER_SLICE == pSliceArgument->uiSliceMode) && (0 == pSliceArgument->uiSliceMbNum[0])) { | 831 | } else if ((SM_RASTER_SLICE == pSliceArgument->uiSliceMode) && (0 == pSliceArgument->uiSliceMbNum[0])) { |
| 834 | iFirstMBInSlice = kiSliceIdx * kiMBWidth; | 832 | iFirstMBInSlice = iSliceIdx * kiMBWidth; |
| 835 | iMbNumInSlice = kiMBWidth; | 833 | iMbNumInSlice = kiMBWidth; |
| 836 | } else if (SM_RASTER_SLICE == pSliceArgument->uiSliceMode || | 834 | } else if (SM_RASTER_SLICE == pSliceArgument->uiSliceMode || |
| 837 | SM_FIXEDSLCNUM_SLICE == pSliceArgument->uiSliceMode) { | 835 | SM_FIXEDSLCNUM_SLICE == pSliceArgument->uiSliceMode) { |
| 838 | int32_t iMbIdx = 0; | 836 | int32_t iMbIdx = 0; |
| 839 | for (int i = 0; i < kiSliceIdx; i++) { | 837 | for (int i = 0; i < iSliceIdx; i++) { |
| 840 | iMbIdx += kpSlicesAssignList[i]; | 838 | iMbIdx += kpSlicesAssignList[i]; |
| 841 | } | 839 | } |
| 842 | 840 | ||
| 843 | if (iMbIdx >= kiCountNumMbInFrame) { | 841 | if (iMbIdx >= kiCountNumMbInFrame) { |
| 844 | return ENC_RETURN_UNEXPECTED; | 842 | return ENC_RETURN_UNEXPECTED; |
| 843 | } | ||
| 844 | |||
| 845 | iFirstMBInSlice = iMbIdx; | ||
| 846 | iMbNumInSlice = kpSlicesAssignList[iSliceIdx]; | ||
| 847 | |||
| 848 | } else if (SM_SIZELIMITED_SLICE == pSliceArgument->uiSliceMode) { | ||
| 849 | iFirstMBInSlice = 0; | ||
| 850 | iMbNumInSlice = kiCountNumMbInFrame; | ||
| 851 | |||
| 852 | } else { // any else uiSliceMode? | ||
| 853 | assert (0); | ||
| 845 | } | 854 | } |
| 846 | 855 | ||
| 847 | iFirstMBInSlice = iMbIdx; | 856 | pCurLayer->pCountMbNumInSlice[iSliceIdx] = iMbNumInSlice; |
| 848 | iMbNumInSlice = kpSlicesAssignList[kiSliceIdx]; | 857 | pCurLayer->pFirstMbIdxOfSlice[iSliceIdx] = iFirstMBInSlice; |
| 858 | } | ||
| 859 | |||
| 860 | return ENC_RETURN_SUCCESS; | ||
| 861 | } | ||
| 849 | 862 | ||
| 850 | } else if (SM_SIZELIMITED_SLICE == pSliceArgument->uiSliceMode) { | 863 | int32_t SetSliceBoundaryInfo(SDqLayer* pCurLayer, SSlice* pSlice, const int32_t kiSliceIdx) { |
| 851 | iFirstMBInSlice = 0; | 864 | if(NULL == pCurLayer || NULL == pSlice || |
| 852 | iMbNumInSlice = kiCountNumMbInFrame; | 865 | NULL == pCurLayer->pFirstMbIdxOfSlice || |
| 866 | NULL == pCurLayer->pCountMbNumInSlice) { | ||
| 853 | 867 | ||
| 854 | } else { // any else uiSliceMode? | 868 | return ENC_RETURN_UNEXPECTED; |
| 855 | assert (0); | ||
| 856 | } | 869 | } |
| 857 | 870 | ||
| 858 | pSlice->iCountMbNumInSlice = iMbNumInSlice; | 871 | pSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = pCurLayer->pFirstMbIdxOfSlice[kiSliceIdx]; |
| 859 | pSliceHeader->iFirstMbInSlice = iFirstMBInSlice; | 872 | pSlice->iCountMbNumInSlice = pCurLayer->pCountMbNumInSlice[kiSliceIdx]; |
| 860 | 873 | ||
| 861 | return ENC_RETURN_SUCCESS; | 874 | return ENC_RETURN_SUCCESS; |
| 862 | } | 875 | } |
| @@ -941,9 +954,11 @@ int32_t InitSliceList (sWelsEncCtx* pCtx, · 78 unmodified lines | |||
| 941 | } | 954 | } |
| 942 | 955 | ||
| 943 | pSlice->uiSliceIdx = iSliceIdx; | 956 | pSlice->uiSliceIdx = iSliceIdx; |
| 957 | pSlice->iCountMbNumInSlice = 0; | ||
| 958 | pSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = 0; | ||
| 944 | 959 | ||
| 945 | iRet = InitSliceBsBuffer (pSlice, | 960 | iRet = InitSliceBsBuffer (pSlice, |
| 946 | & pCtx->pOut->sBsWrite, | 961 | &pCtx->pOut->sBsWrite, |
| 947 | bIndependenceBsBuffer, | 962 | bIndependenceBsBuffer, |
| 948 | iMaxSliceBufferSize, | 963 | iMaxSliceBufferSize, |
| 949 | pMa); | 964 | pMa); |
| @@ -951,12 +966,6 @@ int32_t InitSliceList (sWelsEncCtx* pCtx, · 1 unmodified line | |||
| 951 | return iRet; | 966 | return iRet; |
| 952 | } | 967 | } |
| 953 | 968 | ||
| 954 | iRet = InitSliceMBInfo (pSliceArgument, pSlice, | ||
| 955 | kiMBWidth, kiMBHeight); | ||
| 956 | |||
| 957 | if (ENC_RETURN_SUCCESS != iRet) { | ||
| 958 | return iRet; | ||
| 959 | } | ||
| 960 | iRet = AllocateSliceMBBuffer (pSlice, pMa); | 969 | iRet = AllocateSliceMBBuffer (pSlice, pMa); |
| 961 | 970 | ||
| 962 | if (ENC_RETURN_SUCCESS != iRet) { | 971 | if (ENC_RETURN_SUCCESS != iRet) { |
| @@ -993,11 +1002,6 @@ int32_t InitOneSliceInThread (sWelsEncCtx* pCtx, · 30 unmodified lines | |||
| 993 | pSlice->sSliceBs.iNalIndex = 0; | 1002 | pSlice->sSliceBs.iNalIndex = 0; |
| 994 | pSlice->sSliceBs.pBsBuffer = pCtx->pSliceThreading->pThreadBsBuffer[kiThreadIdx]; | 1003 | pSlice->sSliceBs.pBsBuffer = pCtx->pSliceThreading->pThreadBsBuffer[kiThreadIdx]; |
| 995 | 1004 | ||
| 996 | // init slice MB info | ||
| 997 | iRet = InitSliceMBInfo (pSliceArgument, pSlice, kiMBWidth, kiMBHeight); | ||
| 998 | if (ENC_RETURN_SUCCESS != iRet) { | ||
| 999 | return iRet; | ||
| 1000 | } | ||
| 1001 | return ENC_RETURN_SUCCESS; | 1005 | return ENC_RETURN_SUCCESS; |
| 1002 | } | 1006 | } |
| 1003 | */ | 1007 | */ |
| @@ -1073,6 +1077,11 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 69 unmodified lines | |||
| 1073 | return ENC_RETURN_MEMALLOCERR; | 1077 | return ENC_RETURN_MEMALLOCERR; |
| 1074 | } | 1078 | } |
| 1075 | 1079 | ||
| 1080 | iRet = InitSliceBoundaryInfo (pDqLayer, &pCtx->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument); | ||
| 1081 | if (ENC_RETURN_SUCCESS != iRet) { | ||
| 1082 | return iRet; | ||
| 1083 | } | ||
| 1084 | |||
| 1076 | InitSliceThreadInfo (pCtx, | 1085 | InitSliceThreadInfo (pCtx, |
| 1077 | pDqLayer, | 1086 | pDqLayer, |
| 1078 | kiDlayerIndex, | 1087 | kiDlayerIndex, |
| @@ -1142,7 +1151,6 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 63 unmodified lines | |||
| 1142 | const int32_t kiMaxSliceNumOld, | 1151 | const int32_t kiMaxSliceNumOld, |
| 1143 | const int32_t kiMaxSliceNumNew) { | 1152 | const int32_t kiMaxSliceNumNew) { |
| 1144 | CMemoryAlign* pMA = pCtx->pMemAlign; | 1153 | CMemoryAlign* pMA = pCtx->pMemAlign; |
| 1145 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; | ||
| 1146 | SSlice* pBaseSlice = NULL; | 1154 | SSlice* pBaseSlice = NULL; |
| 1147 | SSlice* pNewSliceList = NULL; | 1155 | SSlice* pNewSliceList = NULL; |
| 1148 | SSlice* pSlice = NULL; | 1156 | SSlice* pSlice = NULL; |
| @@ -1181,6 +1189,8 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 32 unmodified lines | |||
| 1181 | } | 1189 | } |
| 1182 | 1190 | ||
| 1183 | pSlice->uiSliceIdx = iSliceIdx; | 1191 | pSlice->uiSliceIdx = iSliceIdx; |
| 1192 | pSlice->iCountMbNumInSlice = 0; | ||
| 1193 | pSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = 0; | ||
| 1184 | 1194 | ||
| 1185 | iRet = InitSliceBsBuffer (pSlice, | 1195 | iRet = InitSliceBsBuffer (pSlice, |
| 1186 | & pCtx->pOut->sBsWrite, | 1196 | & pCtx->pOut->sBsWrite, |
| @@ -1198,15 +1208,6 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 11 unmodified lines | |||
| 1198 | return iRet; | 1208 | return iRet; |
| 1199 | } | 1209 | } |
| 1200 | 1210 | ||
| 1201 | iRet = InitSliceMBInfo (pSliceArgument, | ||
| 1202 | pSlice, | ||
| 1203 | pCurLayer->iMbWidth, | ||
| 1204 | pCurLayer->iMbHeight); | ||
| 1205 | if (ENC_RETURN_SUCCESS != iRet) { | ||
| 1206 | FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()"); | ||
| 1207 | return iRet; | ||
| 1208 | } | ||
| 1209 | |||
| 1210 | InitSliceHeadWithBase (pSlice, pBaseSlice); | 1211 | InitSliceHeadWithBase (pSlice, pBaseSlice); |
| 1211 | InitSliceRefInfoWithBase (pSlice, pBaseSlice, pCtx->iNumRef0); | 1212 | InitSliceRefInfoWithBase (pSlice, pBaseSlice, pCtx->iNumRef0); |
| 1212 | 1213 | ||
| @@ -1357,6 +1358,7 @@ int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { · 144 unmodified lines | |||
| 1357 | return ENC_RETURN_SUCCESS; | 1358 | return ENC_RETURN_SUCCESS; |
| 1358 | } | 1359 | } |
| 1359 | 1360 | ||
| 1361 | |||
| 1360 | /* | 1362 | /* |
| 1361 | int32_t ReOrderSliceInLayer (SDqLayer* pCurLayer, | 1363 | int32_t ReOrderSliceInLayer (SDqLayer* pCurLayer, |
| 1362 | const int32_t kiThreadNum, | 1364 | const int32_t kiThreadNum, |