remove pFirstMbInSlice in SSliceCtx
Unified · Split
| @@ -69,7 +69,7 @@ SMVUnitXY sP16x16Mv; · 68 unmodified lines | ||
| 69 | 69 | |
| 70 | 70 | uint8_t uiLumaQp; // uiLumaQp: pPps->iInitialQp + sSliceHeader->delta_qp + mb->dquant. |
| 71 | 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 | 73 | uint32_t uiChromPredMode; |
| 74 | 74 | int32_t iLumaDQp; |
| 75 | 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 | 86 | int32_t iSliceNumInFrame; /* count number of slices in frame; */ |
| 87 | 87 | int32_t iMbNumInFrame; /* count number of MBs in frame */ |
| 88 | 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 | 89 | int32_t* pCountMbNumInSlice; /* count number of MBs in every slice respectively; */ |
| 91 | 90 | uint32_t uiSliceSizeConstraint; /* in byte */ |
| 92 | 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 | 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 | 155 | * \param kiSliceIdc slice idc |
| 157 | 156 | * |
| 158 | 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 | 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 | 2751 | void UpdateSlicepEncCtxWithPartition (SDqLayer* pCurDq, int32_t iPartitionNum) { |
| 2752 | 2752 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 2753 | + SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer; | |
| 2753 | 2754 | const int32_t kiMbNumInFrame = pSliceCtx->iMbNumInFrame; |
| 2754 | 2755 | int32_t iCountMbNumPerPartition = kiMbNumInFrame; |
| 2755 | 2756 | int32_t iAssignableMbLeft = kiMbNumInFrame; |
| @@ -2769,7 +2770,7 @@ void UpdateSlicepEncCtxWithPartition (SDqLayer* pCurDq, int32_t iPartitionNum) { · 13 unmodified lines | ||
| 2769 | 2770 | } else { |
| 2770 | 2771 | pSliceCtx->pCountMbNumInSlice[i] = iCountMbNumPerPartition; |
| 2771 | 2772 | } |
| 2772 | − pSliceCtx->pFirstMbInSlice[i] = iFirstMbIdx; | |
| 2773 | + pSliceInLayer[i].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = iFirstMbIdx; | |
| 2773 | 2774 | |
| 2774 | 2775 | WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdx, i, |
| 2775 | 2776 | pSliceCtx->pCountMbNumInSlice[i], sizeof (uint16_t)); |
| @@ -4797,17 +4798,6 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 2021 unmodified lines | ||
| 4797 | 4798 | } |
| 4798 | 4799 | pMA->WelsFree (pCurLayer->sLayerInfo.pSliceInLayer, "Slice"); |
| 4799 | 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 | 4801 | int32_t* pCountMbNumInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t), |
| 4812 | 4802 | "pSliceSeg->pCountMbNumInSlice"); |
| 4813 | 4803 | if (NULL == pCountMbNumInSlice) { |
| @@ -4881,6 +4871,8 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 67 unmodified lines | ||
| 4881 | 4871 | |
| 4882 | 4872 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; |
| 4883 | 4873 | SSliceCtx* pSliceCtx = &pCurLayer->sSliceEncCtx; |
| 4874 | + SSlice* pSliceInLayer = pCurLayer->sLayerInfo.pSliceInLayer; | |
| 4875 | + SSlice* pStartSlice = &pSliceInLayer[iStartSliceIdx]; | |
| 4884 | 4876 | int32_t iNalIdxInLayer = *pNalIdxInLayer; |
| 4885 | 4877 | int32_t iSliceIdx = iStartSliceIdx; |
| 4886 | 4878 | const int32_t kiSliceStep = pCtx->iActiveThreadsNum; |
| @@ -4895,7 +4887,7 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 8 unmodified lines | ||
| 4895 | 4887 | |
| 4896 | 4888 | //init |
| 4897 | 4889 | { |
| 4898 | − pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbInPartition; | |
| 4890 | + pStartSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = iFirstMbInPartition; | |
| 4899 | 4891 | pCurLayer->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one slice per partition intialized, dynamic slicing inside |
| 4900 | 4892 | pCurLayer->pLastMbIdxOfPartition[kiPartitionId] = iEndMbInPartition - 1; |
| 4901 | 4893 | } |
| @@ -512,6 +512,7 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 511 unmodified lines | ||
| 512 | 512 | |
| 513 | 513 | void RcInitSliceInformation (sWelsEncCtx* pEncCtx) { |
| 514 | 514 | SSliceCtx* pCurSliceCtx = &pEncCtx->pCurDqLayer->sSliceEncCtx; |
| 515 | + SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer; | |
| 515 | 516 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; |
| 516 | 517 | SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; |
| 517 | 518 | const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; |
| @@ -520,7 +521,7 @@ void RcInitSliceInformation (sWelsEncCtx* pEncCtx) { · 2 unmodified lines | ||
| 520 | 521 | |
| 521 | 522 | for (int32_t i = 0; i < kiSliceNum; i++) { |
| 522 | 523 | pSOverRc->iStartMbSlice = |
| 523 | − pSOverRc->iEndMbSlice = pCurSliceCtx->pFirstMbInSlice[i]; | |
| 524 | + pSOverRc->iEndMbSlice = pSliceInLayer[i].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; | |
| 524 | 525 | pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1); |
| 525 | 526 | pSOverRc->iTotalQpSlice = 0; |
| 526 | 527 | pSOverRc->iTotalMbSlice = 0; |
| @@ -81,9 +81,10 @@ void UpdateMbListNeighborParallel (SDqLayer* pCurDq, · 80 unmodified lines | ||
| 81 | 81 | SMB* pMbList, |
| 82 | 82 | const int32_t uiSliceIdc) { |
| 83 | 83 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 84 | + SSlice* pUpdateSlice = &pCurDq->sLayerInfo.pSliceInLayer[uiSliceIdc]; | |
| 84 | 85 | const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; |
| 85 | 86 | const int32_t kiMbWidth = pSliceCtx->iMbWidth; |
| 86 | − int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc]; | |
| 87 | + int32_t iIdx = pUpdateSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; | |
| 87 | 88 | const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1; |
| 88 | 89 | |
| 89 | 90 | do { |
| @@ -816,10 +817,11 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 726 unmodified lines | ||
| 816 | 817 | pEncPEncCtx->pSliceThreading->pSliceConsumeTime[pEncPEncCtx->uiDependencyId][iSliceIdx] = (uint32_t) ( |
| 817 | 818 | WelsTime() - iSliceStart); |
| 818 | 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 | 821 | pEncPEncCtx->iCodingIndex, iSliceIdx, |
| 821 | 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 | 827 | #if defined(SLICE_INFO_OUTPUT) |
| @@ -847,10 +849,10 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 21 unmodified lines | ||
| 847 | 849 | const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive |
| 848 | 850 | const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive |
| 849 | 851 | int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition; |
| 852 | + SSliceHeaderExt* pStartSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt; | |
| 850 | 853 | |
| 851 | 854 | iSliceIdx = pPrivateData->iSliceIndex; |
| 852 | − | |
| 853 | − pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition; | |
| 855 | + pStartSliceHeaderExt->sSliceHeader.iFirstMbInSlice = kiFirstMbInPartition; | |
| 854 | 856 | pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = |
| 855 | 857 | 1; // one pSlice per partition intialized, dynamic slicing inside |
| 856 | 858 | pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1; |
| @@ -1005,8 +1007,10 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 148 unmodified lines | ||
| 1005 | 1007 | int32_t iEndMbIdx = 0; |
| 1006 | 1008 | int32_t iIdx = 0; |
| 1007 | 1009 | const int32_t kiEventCnt = uiNumThreads; |
| 1008 | − int32_t iLayerBsIdx = pCtx->pOut->iLayerBsIndex; | |
| 1009 | − SLayerBSInfo* pLbi = &pFrameBsInfo->sLayerInfo[iLayerBsIdx]; | |
| 1010 | + int32_t iLayerBsIdx = pCtx->pOut->iLayerBsIndex; | |
| 1011 | + SLayerBSInfo* pLbi = &pFrameBsInfo->sLayerInfo[iLayerBsIdx]; | |
| 1012 | + SSlice* pSliceInLayer = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer; | |
| 1013 | + | |
| 1010 | 1014 | |
| 1011 | 1015 | if (pPriData == NULL || pFrameBsInfo == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) { |
| 1012 | 1016 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, |
| @@ -1019,7 +1023,7 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 6 unmodified lines | ||
| 1019 | 1023 | if (bIsDynamicSlicingMode) { |
| 1020 | 1024 | iEndMbIdx = pSliceCtx->iMbNumInFrame; |
| 1021 | 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 | 1027 | pPriData[iIdx].iStartMbIndex = iFirstMbIdx; |
| 1024 | 1028 | pPriData[iIdx].iEndMbIndex = iEndMbIdx; |
| 1025 | 1029 | iEndMbIdx = iFirstMbIdx; |
| @@ -68,7 +68,9 @@ int32_t AssignMbMapSingleSlice (void* pMbMap, const int32_t kiCountMbNum, const · 67 unmodified lines | ||
| 68 | 68 | * \return 0 - successful; none 0 - failed |
| 69 | 69 | */ |
| 70 | 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 | 74 | int32_t iSliceIdx = 0; |
| 73 | 75 | if (NULL == pSliceSeg || SM_SINGLE_SLICE == pSliceSeg->uiSliceMode) |
| 74 | 76 | return 1; |
| @@ -79,9 +81,10 @@ int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSlic · 4 unmodified lines | ||
| 79 | 81 | |
| 80 | 82 | iSliceIdx = 0; |
| 81 | 83 | while (iSliceIdx < iSliceNum) { |
| 82 | − const int32_t kiFirstMb = iSliceIdx * kiMbWidth; | |
| 83 | − pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiMbWidth; | |
| 84 | − pSliceSeg->pFirstMbInSlice[iSliceIdx] = kiFirstMb; | |
| 84 | + const int32_t kiFirstMb = iSliceIdx * kiMbWidth; | |
| 85 | + SSliceHeaderExt* pSliceHeaderExt = &pSliceInLayer[iSliceIdx].sSliceHeaderExt; | |
| 86 | + pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiMbWidth; | |
| 87 | + pSliceHeaderExt->sSliceHeader.iFirstMbInSlice = kiFirstMb; | |
| 85 | 88 | WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap + kiFirstMb, iSliceIdx, |
| 86 | 89 | kiMbWidth, sizeof(uint16_t)); |
| 87 | 90 | ++ iSliceIdx; |
| @@ -97,11 +100,11 @@ int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSlic · 9 unmodified lines | ||
| 97 | 100 | |
| 98 | 101 | iSliceIdx = 0; |
| 99 | 102 | do { |
| 100 | − const int32_t kiCurRunLength = kpSlicesAssignList[iSliceIdx]; | |
| 101 | − int32_t iRunIdx = 0; | |
| 102 | − | |
| 103 | − pSliceSeg->pFirstMbInSlice[iSliceIdx] = iMbIdx; | |
| 104 | − pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCurRunLength; | |
| 103 | + const int32_t kiCurRunLength = kpSlicesAssignList[iSliceIdx]; | |
| 104 | + int32_t iRunIdx = 0; | |
| 105 | + pSliceHeaderExt = &pSliceInLayer[iSliceIdx].sSliceHeaderExt; | |
| 106 | + pSliceHeaderExt->sSliceHeader.iFirstMbInSlice = iMbIdx; | |
| 107 | + pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCurRunLength; | |
| 105 | 108 | |
| 106 | 109 | // due here need check validate mb_assign_map for input pData, can not use memset |
| 107 | 110 | do { |
| @@ -113,13 +116,14 @@ int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSlic · 5 unmodified lines | ||
| 113 | 116 | ++ iSliceIdx; |
| 114 | 117 | } while (iSliceIdx < kiCountSliceNumInFrame && iMbIdx < kiCountNumMbInFrame); |
| 115 | 118 | } else if (SM_SIZELIMITED_SLICE == pSliceSeg->uiSliceMode) { |
| 116 | − const int32_t kiMaxSliceNum = pSliceSeg->iMaxSliceNumConstraint; | |
| 119 | + const int32_t kiMaxSliceNum = pSliceSeg->iMaxSliceNumConstraint; | |
| 117 | 120 | const int32_t kiCountNumMbInFrame = pSliceSeg->iMbNumInFrame; |
| 118 | 121 | |
| 119 | 122 | iSliceIdx = 0; |
| 120 | 123 | do { |
| 121 | − pSliceSeg->pFirstMbInSlice[iSliceIdx] = 0; | |
| 122 | − pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCountNumMbInFrame; | |
| 124 | + pSliceHeaderExt = &pSliceInLayer[iSliceIdx].sSliceHeaderExt; | |
| 125 | + pSliceHeaderExt->sSliceHeader.iFirstMbInSlice = 0; | |
| 126 | + pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCountNumMbInFrame; | |
| 123 | 127 | iSliceIdx++; |
| 124 | 128 | } while (iSliceIdx < kiMaxSliceNum); |
| 125 | 129 | } else { // any else uiSliceMode? |
| @@ -378,11 +382,7 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 252 unmodified lines | ||
| 378 | 382 | |
| 379 | 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 | 386 | if (NULL != pSliceSeg->pCountMbNumInSlice) { |
| 387 | 387 | pMa->WelsFree (pSliceSeg->pCountMbNumInSlice, "pSliceSeg->pCountMbNumInSlice"); |
| 388 | 388 | |
| @@ -407,11 +407,6 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 18 unmodified lines | ||
| 407 | 407 | WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap) |
| 408 | 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 | 410 | pSliceSeg->pCountMbNumInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t), |
| 416 | 411 | "pSliceSeg->pCountMbNumInSlice"); |
| 417 | 412 | |
| @@ -422,7 +417,6 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 4 unmodified lines | ||
| 422 | 417 | pSliceSeg->iMbHeight = kiMbHeight; |
| 423 | 418 | pSliceSeg->iMbNumInFrame = kiCountMbNum; |
| 424 | 419 | pSliceSeg->pCountMbNumInSlice[0] = kiCountMbNum; |
| 425 | − pSliceSeg->pFirstMbInSlice[0] = 0; | |
| 426 | 420 | |
| 427 | 421 | return AssignMbMapSingleSlice (pSliceSeg->pOverallMbMap, kiCountMbNum, sizeof (pSliceSeg->pOverallMbMap[0])); |
| 428 | 422 | } else { //if ( SM_MULTIPLE_SLICE == uiSliceMode ) |
| @@ -444,10 +438,6 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 15 unmodified lines | ||
| 444 | 438 | "pSliceSeg->pCountMbNumInSlice"); |
| 445 | 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 | 441 | pSliceSeg->pSliceConsumeTime = (uint32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (uint32_t), |
| 452 | 442 | "pSliceSeg->pSliceConsumeTime"); |
| 453 | 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 | 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 | 487 | if (NULL != pSliceSeg->pCountMbNumInSlice) { |
| 502 | 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 | 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 | 573 | * \param kuiSliceIdc slice idc |
| 588 | 574 | * |
| 589 | 575 | * \return iFirstMb - successful; -1 - failed; |
| 590 | 576 | */ |
| 591 | −int32_t WelsGetFirstMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kuiSliceIdc) { | |
| 592 | − return pSliceCtx->pFirstMbInSlice[ kuiSliceIdc ]; | |
| 577 | +int32_t WelsGetFirstMbOfSlice (SSlice* pSliceInLayer, const int32_t 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 | 678 | int32_t DynamicAdjustSlicePEncCtxAll (SDqLayer* pCurDq, |
| 690 | 679 | int32_t* pRunLength) { |
| 691 | 680 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 681 | + SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer; | |
| 692 | 682 | const int32_t iCountNumMbInFrame = pSliceCtx->iMbNumInFrame; |
| 693 | 683 | const int32_t iCountSliceNumInFrame = pSliceCtx->iSliceNumInFrame; |
| 694 | 684 | int32_t iSameRunLenFlag = 1; |
| @@ -711,9 +701,9 @@ int32_t DynamicAdjustSlicePEncCtxAll (SDqLayer* pCurDq, · 16 unmodified lines | ||
| 711 | 701 | iSliceIdx = 0; |
| 712 | 702 | do { |
| 713 | 703 | const int32_t kiSliceRun = pRunLength[iSliceIdx]; |
| 714 | − | |
| 715 | − pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbIdx; | |
| 716 | − pSliceCtx->pCountMbNumInSlice[iSliceIdx] = kiSliceRun; | |
| 704 | + SSliceHeaderExt* pSliceHeaderExt = &pSliceInLayer[iSliceIdx].sSliceHeaderExt; | |
| 705 | + pSliceHeaderExt->sSliceHeader.iFirstMbInSlice = iFirstMbIdx; | |
| 706 | + pSliceCtx->pCountMbNumInSlice[iSliceIdx] = kiSliceRun; | |
| 717 | 707 | |
| 718 | 708 | WelsSetMemMultiplebytes_c(pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx, |
| 719 | 709 | kiSliceRun, sizeof(uint16_t)); |
| @@ -94,7 +94,7 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice* · 93 unmodified lines | ||
| 94 | 94 | |
| 95 | 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 | 99 | pCurSliceHeader->iFrameNum = pEncCtx->iFrameNum; |
| 100 | 100 | pCurSliceHeader->uiIdrPicId = pEncCtx->uiIdrPicId; |
| @@ -818,6 +818,7 @@ void UpdateMbNeighbourInfoForNextSlice (SDqLayer* pCurDq, · 717 unmodified lines | ||
| 818 | 818 | void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSliceCtx, SMB* pCurMb, |
| 819 | 819 | int32_t iFirstMbIdxOfNextSlice, const int32_t kiLastMbIdxInPartition) { |
| 820 | 820 | SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; |
| 821 | + SSlice* pSliceInLayer = pCurLayer->sLayerInfo.pSliceInLayer; | |
| 821 | 822 | int32_t iCurMbIdx = pCurMb->iMbXY; |
| 822 | 823 | uint16_t iCurSliceIdc = pSliceCtx->pOverallMbMap[ iCurMbIdx ]; |
| 823 | 824 | const int32_t kiSliceIdxStep = pEncCtx->iActiveThreadsNum; |
| @@ -842,8 +843,7 @@ void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSlic · 18 unmodified lines | ||
| 842 | 843 | (NAL_UNIT_CODED_SLICE_EXT == pCurLayer->sLayerInfo.sNalHeaderExt.sNalUnitHeader.eNalUnitType); |
| 843 | 844 | memcpy (&pNextSlice->sSliceHeaderExt, &pCurSlice->sSliceHeaderExt, |
| 844 | 845 | sizeof (SSliceHeaderExt)); // confirmed_safe_unsafe_usage |
| 845 | − | |
| 846 | − pSliceCtx->pFirstMbInSlice[iNextSliceIdc] = iFirstMbIdxOfNextSlice; | |
| 846 | + pSliceInLayer[iNextSliceIdc].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = iFirstMbIdxOfNextSlice; | |
| 847 | 847 | WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdxOfNextSlice, iNextSliceIdc, |
| 848 | 848 | (kiLastMbIdxInPartition - iFirstMbIdxOfNextSlice + 1), sizeof (uint16_t)); |
| 849 | 849 | |
| @@ -218,12 +218,12 @@ void CWelsLoadBalancingSlicingEncodingTask::FinishTask() { · 217 unmodified lines | ||
| 218 | 218 | |
| 219 | 219 | m_pCtx->pCurDqLayer->sSliceEncCtx.pSliceConsumeTime[m_iSliceIdx] = (uint32_t) (WelsTime() - m_iSliceStart); |
| 220 | 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 | 222 | m_pCtx->iCodingIndex, |
| 223 | 223 | m_iSliceIdx, |
| 224 | 224 | m_pCtx->pCurDqLayer->sSliceEncCtx.pSliceConsumeTime[m_iSliceIdx], |
| 225 | 225 | m_iSliceSize, |
| 226 | − m_pCtx->pCurDqLayer->sSliceEncCtx.pFirstMbInSlice[m_iSliceIdx], | |
| 226 | + m_pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[m_iSliceIdx].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice, | |
| 227 | 227 | m_pCtx->pCurDqLayer->sSliceEncCtx.pCountMbNumInSlice[m_iSliceIdx]); |
| 228 | 228 | } |
| 229 | 229 | |