remove pFirstMbInSlice in SSliceCtx
Unified · Split
| @@ -69,7 +69,7 @@ SMVUnitXY sP16x16Mv; · 68 unmodified lines | |||
| 69 | 69 | ||
| 70 | uint8_t uiLumaQp; // uiLumaQp: pPps->iInitialQp + sSliceHeader->delta_qp + mb->dquant. | 70 | uint8_t uiLumaQp; // uiLumaQp: pPps->iInitialQp + sSliceHeader->delta_qp + mb->dquant. |
| 71 | uint8_t uiChromaQp; | 71 | uint8_t uiChromaQp; |
| 72 | uint16_t uiSliceIdc; // 2^16=65536 > MaxFS(36864) of level 5.1; AVC: pFirstMbInSlice?; SVC: (pFirstMbInSlice << 7) | ((uiDependencyId << 4) | uiQualityId); | 72 | uint16_t uiSliceIdc; // 2^16=65536 > MaxFS(36864) of level 5.1; AVC: iFirstMbInSlice?; SVC: (iFirstMbInSlice << 7) | ((uiDependencyId << 4) | uiQualityId); |
| 73 | uint32_t uiChromPredMode; | 73 | uint32_t uiChromPredMode; |
| 74 | int32_t iLumaDQp; | 74 | int32_t iLumaDQp; |
| 75 | SMVUnitXY sMvd[MB_BLOCK4x4_NUM]; //only for CABAC writing; storage structure the same as sMv, in 4x4 scan order. | 75 | SMVUnitXY sMvd[MB_BLOCK4x4_NUM]; //only for CABAC writing; storage structure the same as sMv, in 4x4 scan order. |
| @@ -86,7 +86,6 @@ int16_t iMbHeight; /* height of picture size in mb · 85 unmodified lines | |||
| 86 | int32_t iSliceNumInFrame; /* count number of slices in frame; */ | 86 | int32_t iSliceNumInFrame; /* count number of slices in frame; */ |
| 87 | int32_t iMbNumInFrame; /* count number of MBs in frame */ | 87 | int32_t iMbNumInFrame; /* count number of MBs in frame */ |
| 88 | uint16_t* pOverallMbMap; /* overall MB map in frame, store virtual slice idc; */ | 88 | uint16_t* pOverallMbMap; /* overall MB map in frame, store virtual slice idc; */ |
| 89 | int32_t* pFirstMbInSlice; /* first MB address top-left based in every slice respectively; */ | ||
| 90 | int32_t* pCountMbNumInSlice; /* count number of MBs in every slice respectively; */ | 89 | int32_t* pCountMbNumInSlice; /* count number of MBs in every slice respectively; */ |
| 91 | uint32_t uiSliceSizeConstraint; /* in byte */ | 90 | uint32_t uiSliceSizeConstraint; /* in byte */ |
| 92 | int32_t iMaxSliceNumConstraint; /* maximal number of slices constraint */ | 91 | int32_t iMaxSliceNumConstraint; /* maximal number of slices constraint */ |
| @@ -152,12 +151,12 @@ uint16_t WelsMbToSliceIdc (SDqLayer* pCurDq, const int32_t kiMbXY); · 59 unmodified lines | |||
| 152 | /*! | 151 | /*! |
| 153 | * \brief Get first mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO) | 152 | * \brief Get first mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO) |
| 154 | * | 153 | * |
| 155 | * \param pSliceCtx SSlice context | 154 | * \param pSliceInLayer slice list in current layer |
| 156 | * \param kiSliceIdc slice idc | 155 | * \param kiSliceIdc slice idc |
| 157 | * | 156 | * |
| 158 | * \return first_mb - successful; -1 - failed; | 157 | * \return first_mb - successful; -1 - failed; |
| 159 | */ | 158 | */ |
| 160 | int32_t WelsGetFirstMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiSliceIdc); | 159 | int32_t WelsGetFirstMbOfSlice (SSlice* pSliceInLayer, const int32_t kiSliceIdc); |
| 161 | 160 | ||
| 162 | /*! | 161 | /*! |
| 163 | * \brief Get successive mb to be processed in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO) | 162 | * \brief Get successive mb to be processed in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO) |
| @@ -2750,6 +2750,7 @@ void WelsInitCurrentQBLayerMltslc (sWelsEncCtx* pCtx) { · 2749 unmodified lines | |||
| 2750 | 2750 | ||
| 2751 | void UpdateSlicepEncCtxWithPartition (SDqLayer* pCurDq, int32_t iPartitionNum) { | 2751 | void UpdateSlicepEncCtxWithPartition (SDqLayer* pCurDq, int32_t iPartitionNum) { |
| 2752 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; | 2752 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 2753 | SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer; | ||
| 2753 | const int32_t kiMbNumInFrame = pSliceCtx->iMbNumInFrame; | 2754 | const int32_t kiMbNumInFrame = pSliceCtx->iMbNumInFrame; |
| 2754 | int32_t iCountMbNumPerPartition = kiMbNumInFrame; | 2755 | int32_t iCountMbNumPerPartition = kiMbNumInFrame; |
| 2755 | int32_t iAssignableMbLeft = kiMbNumInFrame; | 2756 | int32_t iAssignableMbLeft = kiMbNumInFrame; |
| @@ -2769,7 +2770,7 @@ void UpdateSlicepEncCtxWithPartition (SDqLayer* pCurDq, int32_t iPartitionNum) { · 13 unmodified lines | |||
| 2769 | } else { | 2770 | } else { |
| 2770 | pSliceCtx->pCountMbNumInSlice[i] = iCountMbNumPerPartition; | 2771 | pSliceCtx->pCountMbNumInSlice[i] = iCountMbNumPerPartition; |
| 2771 | } | 2772 | } |
| 2772 | pSliceCtx->pFirstMbInSlice[i] = iFirstMbIdx; | 2773 | pSliceInLayer[i].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = iFirstMbIdx; |
| 2773 | 2774 | ||
| 2774 | WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdx, i, | 2775 | WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdx, i, |
| 2775 | pSliceCtx->pCountMbNumInSlice[i], sizeof (uint16_t)); | 2776 | pSliceCtx->pCountMbNumInSlice[i], sizeof (uint16_t)); |
| @@ -4797,17 +4798,6 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 2021 unmodified lines | |||
| 4797 | } | 4798 | } |
| 4798 | pMA->WelsFree (pCurLayer->sLayerInfo.pSliceInLayer, "Slice"); | 4799 | pMA->WelsFree (pCurLayer->sLayerInfo.pSliceInLayer, "Slice"); |
| 4799 | pCurLayer->sLayerInfo.pSliceInLayer = pSlice; | 4800 | pCurLayer->sLayerInfo.pSliceInLayer = pSlice; |
| 4800 | |||
| 4801 | int32_t* pFirstMbInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t), "pSliceSeg->pFirstMbInSlice"); | ||
| 4802 | if (NULL == pFirstMbInSlice) { | ||
| 4803 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: pFirstMbInSlice is NULL"); | ||
| 4804 | return ENC_RETURN_MEMALLOCERR; | ||
| 4805 | } | ||
| 4806 | memset (pFirstMbInSlice, 0, sizeof (int32_t) * iMaxSliceNum); | ||
| 4807 | memcpy (pFirstMbInSlice, pCurLayer->sSliceEncCtx.pFirstMbInSlice, sizeof (int32_t) * iMaxSliceNumOld); | ||
| 4808 | pMA->WelsFree (pCurLayer->sSliceEncCtx.pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice"); | ||
| 4809 | pCurLayer->sSliceEncCtx.pFirstMbInSlice = pFirstMbInSlice; | ||
| 4810 | |||
| 4811 | int32_t* pCountMbNumInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t), | 4801 | int32_t* pCountMbNumInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t), |
| 4812 | "pSliceSeg->pCountMbNumInSlice"); | 4802 | "pSliceSeg->pCountMbNumInSlice"); |
| 4813 | if (NULL == pCountMbNumInSlice) { | 4803 | if (NULL == pCountMbNumInSlice) { |
| @@ -4881,6 +4871,8 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 67 unmodified lines | |||
| 4881 | 4871 | ||
| 4882 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; | 4872 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; |
| 4883 | SSliceCtx* pSliceCtx = &pCurLayer->sSliceEncCtx; | 4873 | SSliceCtx* pSliceCtx = &pCurLayer->sSliceEncCtx; |
| 4874 | SSlice* pSliceInLayer = pCurLayer->sLayerInfo.pSliceInLayer; | ||
| 4875 | SSlice* pStartSlice = &pSliceInLayer[iStartSliceIdx]; | ||
| 4884 | int32_t iNalIdxInLayer = *pNalIdxInLayer; | 4876 | int32_t iNalIdxInLayer = *pNalIdxInLayer; |
| 4885 | int32_t iSliceIdx = iStartSliceIdx; | 4877 | int32_t iSliceIdx = iStartSliceIdx; |
| 4886 | const int32_t kiSliceStep = pCtx->iActiveThreadsNum; | 4878 | const int32_t kiSliceStep = pCtx->iActiveThreadsNum; |
| @@ -4895,7 +4887,7 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 8 unmodified lines | |||
| 4895 | 4887 | ||
| 4896 | //init | 4888 | //init |
| 4897 | { | 4889 | { |
| 4898 | pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbInPartition; | 4890 | pStartSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = iFirstMbInPartition; |
| 4899 | pCurLayer->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one slice per partition intialized, dynamic slicing inside | 4891 | pCurLayer->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one slice per partition intialized, dynamic slicing inside |
| 4900 | pCurLayer->pLastMbIdxOfPartition[kiPartitionId] = iEndMbInPartition - 1; | 4892 | pCurLayer->pLastMbIdxOfPartition[kiPartitionId] = iEndMbInPartition - 1; |
| 4901 | } | 4893 | } |
| @@ -512,6 +512,7 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 511 unmodified lines | |||
| 512 | 512 | ||
| 513 | void RcInitSliceInformation (sWelsEncCtx* pEncCtx) { | 513 | void RcInitSliceInformation (sWelsEncCtx* pEncCtx) { |
| 514 | SSliceCtx* pCurSliceCtx = &pEncCtx->pCurDqLayer->sSliceEncCtx; | 514 | SSliceCtx* pCurSliceCtx = &pEncCtx->pCurDqLayer->sSliceEncCtx; |
| 515 | SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer; | ||
| 515 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; | 516 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; |
| 516 | SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; | 517 | SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; |
| 517 | const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; | 518 | const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; |
| @@ -520,7 +521,7 @@ void RcInitSliceInformation (sWelsEncCtx* pEncCtx) { · 2 unmodified lines | |||
| 520 | 521 | ||
| 521 | for (int32_t i = 0; i < kiSliceNum; i++) { | 522 | for (int32_t i = 0; i < kiSliceNum; i++) { |
| 522 | pSOverRc->iStartMbSlice = | 523 | pSOverRc->iStartMbSlice = |
| 523 | pSOverRc->iEndMbSlice = pCurSliceCtx->pFirstMbInSlice[i]; | 524 | pSOverRc->iEndMbSlice = pSliceInLayer[i].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; |
| 524 | pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1); | 525 | pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1); |
| 525 | pSOverRc->iTotalQpSlice = 0; | 526 | pSOverRc->iTotalQpSlice = 0; |
| 526 | pSOverRc->iTotalMbSlice = 0; | 527 | pSOverRc->iTotalMbSlice = 0; |
| @@ -81,9 +81,10 @@ void UpdateMbListNeighborParallel (SDqLayer* pCurDq, · 80 unmodified lines | |||
| 81 | SMB* pMbList, | 81 | SMB* pMbList, |
| 82 | const int32_t uiSliceIdc) { | 82 | const int32_t uiSliceIdc) { |
| 83 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; | 83 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 84 | SSlice* pUpdateSlice = &pCurDq->sLayerInfo.pSliceInLayer[uiSliceIdc]; | ||
| 84 | const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; | 85 | const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; |
| 85 | const int32_t kiMbWidth = pSliceCtx->iMbWidth; | 86 | const int32_t kiMbWidth = pSliceCtx->iMbWidth; |
| 86 | int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc]; | 87 | int32_t iIdx = pUpdateSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; |
| 87 | const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1; | 88 | const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1; |
| 88 | 89 | ||
| 89 | do { | 90 | do { |
| @@ -816,10 +817,11 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 726 unmodified lines | |||
| 816 | pEncPEncCtx->pSliceThreading->pSliceConsumeTime[pEncPEncCtx->uiDependencyId][iSliceIdx] = (uint32_t) ( | 817 | pEncPEncCtx->pSliceThreading->pSliceConsumeTime[pEncPEncCtx->uiDependencyId][iSliceIdx] = (uint32_t) ( |
| 817 | WelsTime() - iSliceStart); | 818 | WelsTime() - iSliceStart); |
| 818 | MT_TRACE_LOG (& (pEncPEncCtx->sLogCtx), WELS_LOG_INFO, | 819 | MT_TRACE_LOG (& (pEncPEncCtx->sLogCtx), WELS_LOG_INFO, |
| 819 | "[MT] CodingSliceThreadProc(), coding_idx %d, uiSliceIdx %d, pSliceConsumeTime %d, iSliceSize %d, pFirstMbInSlice %d, count_num_mb_in_slice %d", | 820 | "[MT] CodingSliceThreadProc(), coding_idx %d, uiSliceIdx %d, pSliceConsumeTime %d, iSliceSize %d, iFirstMbInSlice %d, count_num_mb_in_slice %d", |
| 820 | pEncPEncCtx->iCodingIndex, iSliceIdx, | 821 | pEncPEncCtx->iCodingIndex, iSliceIdx, |
| 821 | pEncPEncCtx->pSliceThreading->pSliceConsumeTime[pEncPEncCtx->uiDependencyId][iSliceIdx], iSliceSize, | 822 | pEncPEncCtx->pSliceThreading->pSliceConsumeTime[pEncPEncCtx->uiDependencyId][iSliceIdx], iSliceSize, |
| 822 | pCurDq->sSliceEncCtx.pFirstMbInSlice[iSliceIdx], pCurDq->sSliceEncCtx.pCountMbNumInSlice[iSliceIdx]); | 823 | pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice, |
| 824 | pCurDq->sSliceEncCtx.pCountMbNumInSlice[iSliceIdx]); | ||
| 823 | } | 825 | } |
| 824 | 826 | ||
| 825 | #if defined(SLICE_INFO_OUTPUT) | 827 | #if defined(SLICE_INFO_OUTPUT) |
| @@ -847,10 +849,10 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 21 unmodified lines | |||
| 847 | const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive | 849 | const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive |
| 848 | const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive | 850 | const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive |
| 849 | int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition; | 851 | int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition; |
| 852 | SSliceHeaderExt* pStartSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt; | ||
| 850 | 853 | ||
| 851 | iSliceIdx = pPrivateData->iSliceIndex; | 854 | iSliceIdx = pPrivateData->iSliceIndex; |
| 852 | 855 | pStartSliceHeaderExt->sSliceHeader.iFirstMbInSlice = kiFirstMbInPartition; | |
| 853 | pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition; | ||
| 854 | pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = | 856 | pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = |
| 855 | 1; // one pSlice per partition intialized, dynamic slicing inside | 857 | 1; // one pSlice per partition intialized, dynamic slicing inside |
| 856 | pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1; | 858 | pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1; |
| @@ -1005,8 +1007,10 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 148 unmodified lines | |||
| 1005 | int32_t iEndMbIdx = 0; | 1007 | int32_t iEndMbIdx = 0; |
| 1006 | int32_t iIdx = 0; | 1008 | int32_t iIdx = 0; |
| 1007 | const int32_t kiEventCnt = uiNumThreads; | 1009 | const int32_t kiEventCnt = uiNumThreads; |
| 1008 | int32_t iLayerBsIdx = pCtx->pOut->iLayerBsIndex; | 1010 | int32_t iLayerBsIdx = pCtx->pOut->iLayerBsIndex; |
| 1009 | SLayerBSInfo* pLbi = &pFrameBsInfo->sLayerInfo[iLayerBsIdx]; | 1011 | SLayerBSInfo* pLbi = &pFrameBsInfo->sLayerInfo[iLayerBsIdx]; |
| 1012 | SSlice* pSliceInLayer = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer; | ||
| 1013 | |||
| 1010 | 1014 | ||
| 1011 | if (pPriData == NULL || pFrameBsInfo == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) { | 1015 | if (pPriData == NULL || pFrameBsInfo == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) { |
| 1012 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, | 1016 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, |
| @@ -1019,7 +1023,7 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 6 unmodified lines | |||
| 1019 | if (bIsDynamicSlicingMode) { | 1023 | if (bIsDynamicSlicingMode) { |
| 1020 | iEndMbIdx = pSliceCtx->iMbNumInFrame; | 1024 | iEndMbIdx = pSliceCtx->iMbNumInFrame; |
| 1021 | for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) { | 1025 | for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) { |
| 1022 | const int32_t iFirstMbIdx = pSliceCtx->pFirstMbInSlice[iIdx]; | 1026 | const int32_t iFirstMbIdx = pSliceInLayer[iIdx].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; |
| 1023 | pPriData[iIdx].iStartMbIndex = iFirstMbIdx; | 1027 | pPriData[iIdx].iStartMbIndex = iFirstMbIdx; |
| 1024 | pPriData[iIdx].iEndMbIndex = iEndMbIdx; | 1028 | pPriData[iIdx].iEndMbIndex = iEndMbIdx; |
| 1025 | iEndMbIdx = iFirstMbIdx; | 1029 | iEndMbIdx = iFirstMbIdx; |
| @@ -68,7 +68,9 @@ int32_t AssignMbMapSingleSlice (void* pMbMap, const int32_t kiCountMbNum, const · 67 unmodified lines | |||
| 68 | * \return 0 - successful; none 0 - failed | 68 | * \return 0 - successful; none 0 - failed |
| 69 | */ | 69 | */ |
| 70 | int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSliceArgument) { | 70 | int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSliceArgument) { |
| 71 | SSliceCtx* pSliceSeg = &pCurDq->sSliceEncCtx; | 71 | SSliceCtx* pSliceSeg = &pCurDq->sSliceEncCtx; |
| 72 | SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer; | ||
| 73 | SSliceHeaderExt* pSliceHeaderExt = NULL; | ||
| 72 | int32_t iSliceIdx = 0; | 74 | int32_t iSliceIdx = 0; |
| 73 | if (NULL == pSliceSeg || SM_SINGLE_SLICE == pSliceSeg->uiSliceMode) | 75 | if (NULL == pSliceSeg || SM_SINGLE_SLICE == pSliceSeg->uiSliceMode) |
| 74 | return 1; | 76 | return 1; |
| @@ -79,9 +81,10 @@ int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSlic · 4 unmodified lines | |||
| 79 | 81 | ||
| 80 | iSliceIdx = 0; | 82 | iSliceIdx = 0; |
| 81 | while (iSliceIdx < iSliceNum) { | 83 | while (iSliceIdx < iSliceNum) { |
| 82 | const int32_t kiFirstMb = iSliceIdx * kiMbWidth; | 84 | const int32_t kiFirstMb = iSliceIdx * kiMbWidth; |
| 83 | pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiMbWidth; | 85 | SSliceHeaderExt* pSliceHeaderExt = &pSliceInLayer[iSliceIdx].sSliceHeaderExt; |
| 84 | pSliceSeg->pFirstMbInSlice[iSliceIdx] = kiFirstMb; | 86 | pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiMbWidth; |
| 87 | pSliceHeaderExt->sSliceHeader.iFirstMbInSlice = kiFirstMb; | ||
| 85 | WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap + kiFirstMb, iSliceIdx, | 88 | WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap + kiFirstMb, iSliceIdx, |
| 86 | kiMbWidth, sizeof(uint16_t)); | 89 | kiMbWidth, sizeof(uint16_t)); |
| 87 | ++ iSliceIdx; | 90 | ++ iSliceIdx; |
| @@ -97,11 +100,11 @@ int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSlic · 9 unmodified lines | |||
| 97 | 100 | ||
| 98 | iSliceIdx = 0; | 101 | iSliceIdx = 0; |
| 99 | do { | 102 | do { |
| 100 | const int32_t kiCurRunLength = kpSlicesAssignList[iSliceIdx]; | 103 | const int32_t kiCurRunLength = kpSlicesAssignList[iSliceIdx]; |
| 101 | int32_t iRunIdx = 0; | 104 | int32_t iRunIdx = 0; |
| 102 | 105 | pSliceHeaderExt = &pSliceInLayer[iSliceIdx].sSliceHeaderExt; | |
| 103 | pSliceSeg->pFirstMbInSlice[iSliceIdx] = iMbIdx; | 106 | pSliceHeaderExt->sSliceHeader.iFirstMbInSlice = iMbIdx; |
| 104 | pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCurRunLength; | 107 | pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCurRunLength; |
| 105 | 108 | ||
| 106 | // due here need check validate mb_assign_map for input pData, can not use memset | 109 | // due here need check validate mb_assign_map for input pData, can not use memset |
| 107 | do { | 110 | do { |
| @@ -113,13 +116,14 @@ int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSlic · 5 unmodified lines | |||
| 113 | ++ iSliceIdx; | 116 | ++ iSliceIdx; |
| 114 | } while (iSliceIdx < kiCountSliceNumInFrame && iMbIdx < kiCountNumMbInFrame); | 117 | } while (iSliceIdx < kiCountSliceNumInFrame && iMbIdx < kiCountNumMbInFrame); |
| 115 | } else if (SM_SIZELIMITED_SLICE == pSliceSeg->uiSliceMode) { | 118 | } else if (SM_SIZELIMITED_SLICE == pSliceSeg->uiSliceMode) { |
| 116 | const int32_t kiMaxSliceNum = pSliceSeg->iMaxSliceNumConstraint; | 119 | const int32_t kiMaxSliceNum = pSliceSeg->iMaxSliceNumConstraint; |
| 117 | const int32_t kiCountNumMbInFrame = pSliceSeg->iMbNumInFrame; | 120 | const int32_t kiCountNumMbInFrame = pSliceSeg->iMbNumInFrame; |
| 118 | 121 | ||
| 119 | iSliceIdx = 0; | 122 | iSliceIdx = 0; |
| 120 | do { | 123 | do { |
| 121 | pSliceSeg->pFirstMbInSlice[iSliceIdx] = 0; | 124 | pSliceHeaderExt = &pSliceInLayer[iSliceIdx].sSliceHeaderExt; |
| 122 | pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCountNumMbInFrame; | 125 | pSliceHeaderExt->sSliceHeader.iFirstMbInSlice = 0; |
| 126 | pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCountNumMbInFrame; | ||
| 123 | iSliceIdx++; | 127 | iSliceIdx++; |
| 124 | } while (iSliceIdx < kiMaxSliceNum); | 128 | } while (iSliceIdx < kiMaxSliceNum); |
| 125 | } else { // any else uiSliceMode? | 129 | } else { // any else uiSliceMode? |
| @@ -378,11 +382,7 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 252 unmodified lines | |||
| 378 | 382 | ||
| 379 | pSliceSeg->pOverallMbMap = NULL; | 383 | pSliceSeg->pOverallMbMap = NULL; |
| 380 | } | 384 | } |
| 381 | if (NULL != pSliceSeg->pFirstMbInSlice) { | ||
| 382 | pMa->WelsFree (pSliceSeg->pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice"); | ||
| 383 | 385 | ||
| 384 | pSliceSeg->pFirstMbInSlice = NULL; | ||
| 385 | } | ||
| 386 | if (NULL != pSliceSeg->pCountMbNumInSlice) { | 386 | if (NULL != pSliceSeg->pCountMbNumInSlice) { |
| 387 | pMa->WelsFree (pSliceSeg->pCountMbNumInSlice, "pSliceSeg->pCountMbNumInSlice"); | 387 | pMa->WelsFree (pSliceSeg->pCountMbNumInSlice, "pSliceSeg->pCountMbNumInSlice"); |
| 388 | 388 | ||
| @@ -407,11 +407,6 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 18 unmodified lines | |||
| 407 | WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap) | 407 | WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap) |
| 408 | pSliceSeg->iSliceNumInFrame = 1; | 408 | pSliceSeg->iSliceNumInFrame = 1; |
| 409 | 409 | ||
| 410 | pSliceSeg->pFirstMbInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t), | ||
| 411 | "pSliceSeg->pFirstMbInSlice"); | ||
| 412 | |||
| 413 | WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pFirstMbInSlice) | ||
| 414 | |||
| 415 | pSliceSeg->pCountMbNumInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t), | 410 | pSliceSeg->pCountMbNumInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t), |
| 416 | "pSliceSeg->pCountMbNumInSlice"); | 411 | "pSliceSeg->pCountMbNumInSlice"); |
| 417 | 412 | ||
| @@ -422,7 +417,6 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 4 unmodified lines | |||
| 422 | pSliceSeg->iMbHeight = kiMbHeight; | 417 | pSliceSeg->iMbHeight = kiMbHeight; |
| 423 | pSliceSeg->iMbNumInFrame = kiCountMbNum; | 418 | pSliceSeg->iMbNumInFrame = kiCountMbNum; |
| 424 | pSliceSeg->pCountMbNumInSlice[0] = kiCountMbNum; | 419 | pSliceSeg->pCountMbNumInSlice[0] = kiCountMbNum; |
| 425 | pSliceSeg->pFirstMbInSlice[0] = 0; | ||
| 426 | 420 | ||
| 427 | return AssignMbMapSingleSlice (pSliceSeg->pOverallMbMap, kiCountMbNum, sizeof (pSliceSeg->pOverallMbMap[0])); | 421 | return AssignMbMapSingleSlice (pSliceSeg->pOverallMbMap, kiCountMbNum, sizeof (pSliceSeg->pOverallMbMap[0])); |
| 428 | } else { //if ( SM_MULTIPLE_SLICE == uiSliceMode ) | 422 | } else { //if ( SM_MULTIPLE_SLICE == uiSliceMode ) |
| @@ -444,10 +438,6 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 15 unmodified lines | |||
| 444 | "pSliceSeg->pCountMbNumInSlice"); | 438 | "pSliceSeg->pCountMbNumInSlice"); |
| 445 | WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pCountMbNumInSlice) | 439 | WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pCountMbNumInSlice) |
| 446 | 440 | ||
| 447 | pSliceSeg->pFirstMbInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t), | ||
| 448 | "pSliceSeg->pFirstMbInSlice"); | ||
| 449 | WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pFirstMbInSlice) | ||
| 450 | |||
| 451 | pSliceSeg->pSliceConsumeTime = (uint32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (uint32_t), | 441 | pSliceSeg->pSliceConsumeTime = (uint32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (uint32_t), |
| 452 | "pSliceSeg->pSliceConsumeTime"); | 442 | "pSliceSeg->pSliceConsumeTime"); |
| 453 | WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pSliceConsumeTime) | 443 | WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pSliceConsumeTime) |
| @@ -493,11 +483,7 @@ void UninitSliceSegment (SDqLayer* pCurDq, CMemoryAlign* pMa) { · 39 unmodified lines | |||
| 493 | 483 | ||
| 494 | pSliceSeg->pOverallMbMap = NULL; | 484 | pSliceSeg->pOverallMbMap = NULL; |
| 495 | } | 485 | } |
| 496 | if (NULL != pSliceSeg->pFirstMbInSlice) { | ||
| 497 | pMa->WelsFree (pSliceSeg->pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice"); | ||
| 498 | 486 | ||
| 499 | pSliceSeg->pFirstMbInSlice = NULL; | ||
| 500 | } | ||
| 501 | if (NULL != pSliceSeg->pCountMbNumInSlice) { | 487 | if (NULL != pSliceSeg->pCountMbNumInSlice) { |
| 502 | pMa->WelsFree (pSliceSeg->pCountMbNumInSlice, "pSliceSeg->pCountMbNumInSlice"); | 488 | pMa->WelsFree (pSliceSeg->pCountMbNumInSlice, "pSliceSeg->pCountMbNumInSlice"); |
| 503 | 489 | ||
| @@ -583,13 +569,16 @@ uint16_t WelsMbToSliceIdc (SDqLayer* pCurDq, const int32_t kiMbXY) { · 79 unmodified lines | |||
| 583 | /*! | 569 | /*! |
| 584 | * \brief Get first mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO) | 570 | * \brief Get first mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO) |
| 585 | * | 571 | * |
| 586 | * \param pSliceCtx SSlice context | 572 | * \param pSliceInLayer slice list in current layer |
| 587 | * \param kuiSliceIdc slice idc | 573 | * \param kuiSliceIdc slice idc |
| 588 | * | 574 | * |
| 589 | * \return iFirstMb - successful; -1 - failed; | 575 | * \return iFirstMb - successful; -1 - failed; |
| 590 | */ | 576 | */ |
| 591 | int32_t WelsGetFirstMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kuiSliceIdc) { | 577 | int32_t WelsGetFirstMbOfSlice (SSlice* pSliceInLayer, const int32_t kuiSliceIdc) { |
| 592 | return pSliceCtx->pFirstMbInSlice[ kuiSliceIdc ]; | 578 | if ( NULL == pSliceInLayer || NULL == &pSliceInLayer[kuiSliceIdc] ) |
| 579 | return -1; | ||
| 580 | |||
| 581 | return pSliceInLayer[kuiSliceIdc].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; | ||
| 593 | } | 582 | } |
| 594 | 583 | ||
| 595 | /*! | 584 | /*! |
| @@ -689,6 +678,7 @@ int32_t GetCurrentSliceNum (const SDqLayer* pCurDq) { · 93 unmodified lines | |||
| 689 | int32_t DynamicAdjustSlicePEncCtxAll (SDqLayer* pCurDq, | 678 | int32_t DynamicAdjustSlicePEncCtxAll (SDqLayer* pCurDq, |
| 690 | int32_t* pRunLength) { | 679 | int32_t* pRunLength) { |
| 691 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; | 680 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 681 | SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer; | ||
| 692 | const int32_t iCountNumMbInFrame = pSliceCtx->iMbNumInFrame; | 682 | const int32_t iCountNumMbInFrame = pSliceCtx->iMbNumInFrame; |
| 693 | const int32_t iCountSliceNumInFrame = pSliceCtx->iSliceNumInFrame; | 683 | const int32_t iCountSliceNumInFrame = pSliceCtx->iSliceNumInFrame; |
| 694 | int32_t iSameRunLenFlag = 1; | 684 | int32_t iSameRunLenFlag = 1; |
| @@ -711,9 +701,9 @@ int32_t DynamicAdjustSlicePEncCtxAll (SDqLayer* pCurDq, · 16 unmodified lines | |||
| 711 | iSliceIdx = 0; | 701 | iSliceIdx = 0; |
| 712 | do { | 702 | do { |
| 713 | const int32_t kiSliceRun = pRunLength[iSliceIdx]; | 703 | const int32_t kiSliceRun = pRunLength[iSliceIdx]; |
| 714 | 704 | SSliceHeaderExt* pSliceHeaderExt = &pSliceInLayer[iSliceIdx].sSliceHeaderExt; | |
| 715 | pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbIdx; | 705 | pSliceHeaderExt->sSliceHeader.iFirstMbInSlice = iFirstMbIdx; |
| 716 | pSliceCtx->pCountMbNumInSlice[iSliceIdx] = kiSliceRun; | 706 | pSliceCtx->pCountMbNumInSlice[iSliceIdx] = kiSliceRun; |
| 717 | 707 | ||
| 718 | WelsSetMemMultiplebytes_c(pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx, | 708 | WelsSetMemMultiplebytes_c(pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx, |
| 719 | kiSliceRun, sizeof(uint16_t)); | 709 | kiSliceRun, sizeof(uint16_t)); |
| @@ -94,7 +94,7 @@ 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->sSliceEncCtx, pSlice->uiSliceIdx); | 97 | pCurSliceHeader->iFirstMbInSlice = WelsGetFirstMbOfSlice (pCurLayer->sLayerInfo.pSliceInLayer, pSlice->uiSliceIdx); |
| 98 | 98 | ||
| 99 | pCurSliceHeader->iFrameNum = pEncCtx->iFrameNum; | 99 | pCurSliceHeader->iFrameNum = pEncCtx->iFrameNum; |
| 100 | pCurSliceHeader->uiIdrPicId = pEncCtx->uiIdrPicId; | 100 | pCurSliceHeader->uiIdrPicId = pEncCtx->uiIdrPicId; |
| @@ -818,6 +818,7 @@ void UpdateMbNeighbourInfoForNextSlice (SDqLayer* pCurDq, · 717 unmodified lines | |||
| 818 | void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSliceCtx, SMB* pCurMb, | 818 | void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSliceCtx, SMB* pCurMb, |
| 819 | int32_t iFirstMbIdxOfNextSlice, const int32_t kiLastMbIdxInPartition) { | 819 | int32_t iFirstMbIdxOfNextSlice, const int32_t kiLastMbIdxInPartition) { |
| 820 | SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; | 820 | SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; |
| 821 | SSlice* pSliceInLayer = pCurLayer->sLayerInfo.pSliceInLayer; | ||
| 821 | int32_t iCurMbIdx = pCurMb->iMbXY; | 822 | int32_t iCurMbIdx = pCurMb->iMbXY; |
| 822 | uint16_t iCurSliceIdc = pSliceCtx->pOverallMbMap[ iCurMbIdx ]; | 823 | uint16_t iCurSliceIdc = pSliceCtx->pOverallMbMap[ iCurMbIdx ]; |
| 823 | const int32_t kiSliceIdxStep = pEncCtx->iActiveThreadsNum; | 824 | const int32_t kiSliceIdxStep = pEncCtx->iActiveThreadsNum; |
| @@ -842,8 +843,7 @@ void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSlic · 18 unmodified lines | |||
| 842 | (NAL_UNIT_CODED_SLICE_EXT == pCurLayer->sLayerInfo.sNalHeaderExt.sNalUnitHeader.eNalUnitType); | 843 | (NAL_UNIT_CODED_SLICE_EXT == pCurLayer->sLayerInfo.sNalHeaderExt.sNalUnitHeader.eNalUnitType); |
| 843 | memcpy (&pNextSlice->sSliceHeaderExt, &pCurSlice->sSliceHeaderExt, | 844 | memcpy (&pNextSlice->sSliceHeaderExt, &pCurSlice->sSliceHeaderExt, |
| 844 | sizeof (SSliceHeaderExt)); // confirmed_safe_unsafe_usage | 845 | sizeof (SSliceHeaderExt)); // confirmed_safe_unsafe_usage |
| 845 | 846 | pSliceInLayer[iNextSliceIdc].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = iFirstMbIdxOfNextSlice; | |
| 846 | pSliceCtx->pFirstMbInSlice[iNextSliceIdc] = iFirstMbIdxOfNextSlice; | ||
| 847 | WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdxOfNextSlice, iNextSliceIdc, | 847 | WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdxOfNextSlice, iNextSliceIdc, |
| 848 | (kiLastMbIdxInPartition - iFirstMbIdxOfNextSlice + 1), sizeof (uint16_t)); | 848 | (kiLastMbIdxInPartition - iFirstMbIdxOfNextSlice + 1), sizeof (uint16_t)); |
| 849 | 849 | ||
| @@ -218,12 +218,12 @@ void CWelsLoadBalancingSlicingEncodingTask::FinishTask() { · 217 unmodified lines | |||
| 218 | 218 | ||
| 219 | m_pCtx->pCurDqLayer->sSliceEncCtx.pSliceConsumeTime[m_iSliceIdx] = (uint32_t) (WelsTime() - m_iSliceStart); | 219 | m_pCtx->pCurDqLayer->sSliceEncCtx.pSliceConsumeTime[m_iSliceIdx] = (uint32_t) (WelsTime() - m_iSliceStart); |
| 220 | WelsLog (&m_pCtx->sLogCtx, WELS_LOG_DEBUG, | 220 | WelsLog (&m_pCtx->sLogCtx, WELS_LOG_DEBUG, |
| 221 | "[MT] CWelsLoadBalancingSlicingEncodingTask()FinishTask, coding_idx %d, um_iSliceIdx %d, pSliceConsumeTime %d, iSliceSize %d, pFirstMbInSlice %d, count_num_mb_in_slice %d", | 221 | "[MT] CWelsLoadBalancingSlicingEncodingTask()FinishTask, coding_idx %d, um_iSliceIdx %d, pSliceConsumeTime %d, iSliceSize %d, iFirstMbInSlice %d, count_num_mb_in_slice %d", |
| 222 | m_pCtx->iCodingIndex, | 222 | m_pCtx->iCodingIndex, |
| 223 | m_iSliceIdx, | 223 | m_iSliceIdx, |
| 224 | m_pCtx->pCurDqLayer->sSliceEncCtx.pSliceConsumeTime[m_iSliceIdx], | 224 | m_pCtx->pCurDqLayer->sSliceEncCtx.pSliceConsumeTime[m_iSliceIdx], |
| 225 | m_iSliceSize, | 225 | m_iSliceSize, |
| 226 | m_pCtx->pCurDqLayer->sSliceEncCtx.pFirstMbInSlice[m_iSliceIdx], | 226 | m_pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[m_iSliceIdx].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice, |
| 227 | m_pCtx->pCurDqLayer->sSliceEncCtx.pCountMbNumInSlice[m_iSliceIdx]); | 227 | m_pCtx->pCurDqLayer->sSliceEncCtx.pCountMbNumInSlice[m_iSliceIdx]); |
| 228 | } | 228 | } |
| 229 | 229 | ||