History

Merge pull request #2262 from shihuade/MultiThread_V4.2_SSliceCtx_PFirstMBInSlice_Pull

remove pFirstMbInSlice in SSliceCtx

ruil2 committed 10 years ago

Commit 2d3071e2 parents 6f15550 9ef07c58 files · +53 −67Browse files

Unified · Split

8 files
  1. codec/encoder/core/inc/svc_enc_macroblock.h +1 −1
  2. codec/encoder/core/inc/svc_enc_slice_segment.h +2 −3
  3. codec/encoder/core/src/encoder_ext.cpp +5 −13
  4. codec/encoder/core/src/ratectl.cpp +2 −1
  5. codec/encoder/core/src/slice_multi_threading.cpp +12 −8
  6. codec/encoder/core/src/svc_enc_slice_segment.cpp +26 −36
  7. codec/encoder/core/src/svc_encode_slice.cpp +3 −3
  8. codec/encoder/core/src/wels_task_encoder.cpp +2 −2
codec/encoder/core/inc/svc_enc_macroblock.h+1−1
@@ -69,7 +69,7 @@ SMVUnitXY sP16x16Mv; · 68 unmodified lines
6969
7070 uint8_t uiLumaQp; // uiLumaQp: pPps->iInitialQp + sSliceHeader->delta_qp + mb->dquant.
7171 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);
7373 uint32_t uiChromPredMode;
7474 int32_t iLumaDQp;
7575 SMVUnitXY sMvd[MB_BLOCK4x4_NUM]; //only for CABAC writing; storage structure the same as sMv, in 4x4 scan order.
codec/encoder/core/inc/svc_enc_slice_segment.h+2−3
@@ -86,7 +86,6 @@ int16_t iMbHeight; /* height of picture size in mb · 85 unmodified lines
8686 int32_t iSliceNumInFrame; /* count number of slices in frame; */
8787 int32_t iMbNumInFrame; /* count number of MBs in frame */
8888 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; */
9089 int32_t* pCountMbNumInSlice; /* count number of MBs in every slice respectively; */
9190 uint32_t uiSliceSizeConstraint; /* in byte */
9291 int32_t iMaxSliceNumConstraint; /* maximal number of slices constraint */
@@ -152,12 +151,12 @@ uint16_t WelsMbToSliceIdc (SDqLayer* pCurDq, const int32_t kiMbXY); · 59 unmodified lines
152151 /*!
153152 * \brief Get first mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
154153 *
155− * \param pSliceCtx SSlice context
154+ * \param pSliceInLayer slice list in current layer
156155 * \param kiSliceIdc slice idc
157156 *
158157 * \return first_mb - successful; -1 - failed;
159158 */
160−int32_t WelsGetFirstMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiSliceIdc);
159+int32_t WelsGetFirstMbOfSlice (SSlice* pSliceInLayer, const int32_t kiSliceIdc);
161160
162161 /*!
163162 * \brief Get successive mb to be processed in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
codec/encoder/core/src/encoder_ext.cpp+5−13
@@ -2750,6 +2750,7 @@ void WelsInitCurrentQBLayerMltslc (sWelsEncCtx* pCtx) { · 2749 unmodified lines
27502750
27512751 void UpdateSlicepEncCtxWithPartition (SDqLayer* pCurDq, int32_t iPartitionNum) {
27522752 SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
2753+ SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer;
27532754 const int32_t kiMbNumInFrame = pSliceCtx->iMbNumInFrame;
27542755 int32_t iCountMbNumPerPartition = kiMbNumInFrame;
27552756 int32_t iAssignableMbLeft = kiMbNumInFrame;
@@ -2769,7 +2770,7 @@ void UpdateSlicepEncCtxWithPartition (SDqLayer* pCurDq, int32_t iPartitionNum) { · 13 unmodified lines
27692770 } else {
27702771 pSliceCtx->pCountMbNumInSlice[i] = iCountMbNumPerPartition;
27712772 }
2772− pSliceCtx->pFirstMbInSlice[i] = iFirstMbIdx;
2773+ pSliceInLayer[i].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = iFirstMbIdx;
27732774
27742775 WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdx, i,
27752776 pSliceCtx->pCountMbNumInSlice[i], sizeof (uint16_t));
@@ -4797,17 +4798,6 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 2021 unmodified lines
47974798 }
47984799 pMA->WelsFree (pCurLayer->sLayerInfo.pSliceInLayer, "Slice");
47994800 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−
48114801 int32_t* pCountMbNumInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t),
48124802 "pSliceSeg->pCountMbNumInSlice");
48134803 if (NULL == pCountMbNumInSlice) {
@@ -4881,6 +4871,8 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 67 unmodified lines
48814871
48824872 SDqLayer* pCurLayer = pCtx->pCurDqLayer;
48834873 SSliceCtx* pSliceCtx = &pCurLayer->sSliceEncCtx;
4874+ SSlice* pSliceInLayer = pCurLayer->sLayerInfo.pSliceInLayer;
4875+ SSlice* pStartSlice = &pSliceInLayer[iStartSliceIdx];
48844876 int32_t iNalIdxInLayer = *pNalIdxInLayer;
48854877 int32_t iSliceIdx = iStartSliceIdx;
48864878 const int32_t kiSliceStep = pCtx->iActiveThreadsNum;
@@ -4895,7 +4887,7 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 8 unmodified lines
48954887
48964888 //init
48974889 {
4898− pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbInPartition;
4890+ pStartSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = iFirstMbInPartition;
48994891 pCurLayer->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one slice per partition intialized, dynamic slicing inside
49004892 pCurLayer->pLastMbIdxOfPartition[kiPartitionId] = iEndMbInPartition - 1;
49014893 }
codec/encoder/core/src/ratectl.cpp+2−1
@@ -512,6 +512,7 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 511 unmodified lines
512512
513513 void RcInitSliceInformation (sWelsEncCtx* pEncCtx) {
514514 SSliceCtx* pCurSliceCtx = &pEncCtx->pCurDqLayer->sSliceEncCtx;
515+ SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
515516 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
516517 SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
517518 const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
@@ -520,7 +521,7 @@ void RcInitSliceInformation (sWelsEncCtx* pEncCtx) { · 2 unmodified lines
520521
521522 for (int32_t i = 0; i < kiSliceNum; i++) {
522523 pSOverRc->iStartMbSlice =
523− pSOverRc->iEndMbSlice = pCurSliceCtx->pFirstMbInSlice[i];
524+ pSOverRc->iEndMbSlice = pSliceInLayer[i].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice;
524525 pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1);
525526 pSOverRc->iTotalQpSlice = 0;
526527 pSOverRc->iTotalMbSlice = 0;
codec/encoder/core/src/slice_multi_threading.cpp+12−8
@@ -81,9 +81,10 @@ void UpdateMbListNeighborParallel (SDqLayer* pCurDq, · 80 unmodified lines
8181 SMB* pMbList,
8282 const int32_t uiSliceIdc) {
8383 SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
84+ SSlice* pUpdateSlice = &pCurDq->sLayerInfo.pSliceInLayer[uiSliceIdc];
8485 const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap;
8586 const int32_t kiMbWidth = pSliceCtx->iMbWidth;
86− int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc];
87+ int32_t iIdx = pUpdateSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice;
8788 const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1;
8889
8990 do {
@@ -816,10 +817,11 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 726 unmodified lines
816817 pEncPEncCtx->pSliceThreading->pSliceConsumeTime[pEncPEncCtx->uiDependencyId][iSliceIdx] = (uint32_t) (
817818 WelsTime() - iSliceStart);
818819 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",
820821 pEncPEncCtx->iCodingIndex, iSliceIdx,
821822 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]);
823825 }
824826
825827 #if defined(SLICE_INFO_OUTPUT)
@@ -847,10 +849,10 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 21 unmodified lines
847849 const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive
848850 const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive
849851 int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition;
852+ SSliceHeaderExt* pStartSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt;
850853
851854 iSliceIdx = pPrivateData->iSliceIndex;
852−
853− pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition;
855+ pStartSliceHeaderExt->sSliceHeader.iFirstMbInSlice = kiFirstMbInPartition;
854856 pCurDq->pNumSliceCodedOfPartition[kiPartitionId] =
855857 1; // one pSlice per partition intialized, dynamic slicing inside
856858 pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1;
@@ -1005,8 +1007,10 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 148 unmodified lines
10051007 int32_t iEndMbIdx = 0;
10061008 int32_t iIdx = 0;
10071009 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+
10101014
10111015 if (pPriData == NULL || pFrameBsInfo == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) {
10121016 WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
@@ -1019,7 +1023,7 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 6 unmodified lines
10191023 if (bIsDynamicSlicingMode) {
10201024 iEndMbIdx = pSliceCtx->iMbNumInFrame;
10211025 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;
10231027 pPriData[iIdx].iStartMbIndex = iFirstMbIdx;
10241028 pPriData[iIdx].iEndMbIndex = iEndMbIdx;
10251029 iEndMbIdx = iFirstMbIdx;
codec/encoder/core/src/svc_enc_slice_segment.cpp+26−36
@@ -68,7 +68,9 @@ int32_t AssignMbMapSingleSlice (void* pMbMap, const int32_t kiCountMbNum, const · 67 unmodified lines
6868 * \return 0 - successful; none 0 - failed
6969 */
7070 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;
7274 int32_t iSliceIdx = 0;
7375 if (NULL == pSliceSeg || SM_SINGLE_SLICE == pSliceSeg->uiSliceMode)
7476 return 1;
@@ -79,9 +81,10 @@ int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSlic · 4 unmodified lines
7981
8082 iSliceIdx = 0;
8183 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;
8588 WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap + kiFirstMb, iSliceIdx,
8689 kiMbWidth, sizeof(uint16_t));
8790 ++ iSliceIdx;
@@ -97,11 +100,11 @@ int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSlic · 9 unmodified lines
97100
98101 iSliceIdx = 0;
99102 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;
105108
106109 // due here need check validate mb_assign_map for input pData, can not use memset
107110 do {
@@ -113,13 +116,14 @@ int32_t AssignMbMapMultipleSlices (SDqLayer* pCurDq,const SSliceArgument* kpSlic · 5 unmodified lines
113116 ++ iSliceIdx;
114117 } while (iSliceIdx < kiCountSliceNumInFrame && iMbIdx < kiCountNumMbInFrame);
115118 } else if (SM_SIZELIMITED_SLICE == pSliceSeg->uiSliceMode) {
116− const int32_t kiMaxSliceNum = pSliceSeg->iMaxSliceNumConstraint;
119+ const int32_t kiMaxSliceNum = pSliceSeg->iMaxSliceNumConstraint;
117120 const int32_t kiCountNumMbInFrame = pSliceSeg->iMbNumInFrame;
118121
119122 iSliceIdx = 0;
120123 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;
123127 iSliceIdx++;
124128 } while (iSliceIdx < kiMaxSliceNum);
125129 } else { // any else uiSliceMode?
@@ -378,11 +382,7 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 252 unmodified lines
378382
379383 pSliceSeg->pOverallMbMap = NULL;
380384 }
381− if (NULL != pSliceSeg->pFirstMbInSlice) {
382− pMa->WelsFree (pSliceSeg->pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice");
383385
384− pSliceSeg->pFirstMbInSlice = NULL;
385− }
386386 if (NULL != pSliceSeg->pCountMbNumInSlice) {
387387 pMa->WelsFree (pSliceSeg->pCountMbNumInSlice, "pSliceSeg->pCountMbNumInSlice");
388388
@@ -407,11 +407,6 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 18 unmodified lines
407407 WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap)
408408 pSliceSeg->iSliceNumInFrame = 1;
409409
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−
415410 pSliceSeg->pCountMbNumInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t),
416411 "pSliceSeg->pCountMbNumInSlice");
417412
@@ -422,7 +417,6 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 4 unmodified lines
422417 pSliceSeg->iMbHeight = kiMbHeight;
423418 pSliceSeg->iMbNumInFrame = kiCountMbNum;
424419 pSliceSeg->pCountMbNumInSlice[0] = kiCountMbNum;
425− pSliceSeg->pFirstMbInSlice[0] = 0;
426420
427421 return AssignMbMapSingleSlice (pSliceSeg->pOverallMbMap, kiCountMbNum, sizeof (pSliceSeg->pOverallMbMap[0]));
428422 } else { //if ( SM_MULTIPLE_SLICE == uiSliceMode )
@@ -444,10 +438,6 @@ int32_t InitSliceSegment (SDqLayer* pCurDq, · 15 unmodified lines
444438 "pSliceSeg->pCountMbNumInSlice");
445439 WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pCountMbNumInSlice)
446440
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−
451441 pSliceSeg->pSliceConsumeTime = (uint32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (uint32_t),
452442 "pSliceSeg->pSliceConsumeTime");
453443 WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pSliceConsumeTime)
@@ -493,11 +483,7 @@ void UninitSliceSegment (SDqLayer* pCurDq, CMemoryAlign* pMa) { · 39 unmodified lines
493483
494484 pSliceSeg->pOverallMbMap = NULL;
495485 }
496− if (NULL != pSliceSeg->pFirstMbInSlice) {
497− pMa->WelsFree (pSliceSeg->pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice");
498486
499− pSliceSeg->pFirstMbInSlice = NULL;
500− }
501487 if (NULL != pSliceSeg->pCountMbNumInSlice) {
502488 pMa->WelsFree (pSliceSeg->pCountMbNumInSlice, "pSliceSeg->pCountMbNumInSlice");
503489
@@ -583,13 +569,16 @@ uint16_t WelsMbToSliceIdc (SDqLayer* pCurDq, const int32_t kiMbXY) { · 79 unmodified lines
583569 /*!
584570 * \brief Get first mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
585571 *
586− * \param pSliceCtx SSlice context
572+ * \param pSliceInLayer slice list in current layer
587573 * \param kuiSliceIdc slice idc
588574 *
589575 * \return iFirstMb - successful; -1 - failed;
590576 */
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;
593582 }
594583
595584 /*!
@@ -689,6 +678,7 @@ int32_t GetCurrentSliceNum (const SDqLayer* pCurDq) { · 93 unmodified lines
689678 int32_t DynamicAdjustSlicePEncCtxAll (SDqLayer* pCurDq,
690679 int32_t* pRunLength) {
691680 SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
681+ SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer;
692682 const int32_t iCountNumMbInFrame = pSliceCtx->iMbNumInFrame;
693683 const int32_t iCountSliceNumInFrame = pSliceCtx->iSliceNumInFrame;
694684 int32_t iSameRunLenFlag = 1;
@@ -711,9 +701,9 @@ int32_t DynamicAdjustSlicePEncCtxAll (SDqLayer* pCurDq, · 16 unmodified lines
711701 iSliceIdx = 0;
712702 do {
713703 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;
717707
718708 WelsSetMemMultiplebytes_c(pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx,
719709 kiSliceRun, sizeof(uint16_t));
codec/encoder/core/src/svc_encode_slice.cpp+3−3
@@ -94,7 +94,7 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice* · 93 unmodified lines
9494
9595 pCurSliceExt->bStoreRefBasePicFlag = false;
9696
97− pCurSliceHeader->iFirstMbInSlice = WelsGetFirstMbOfSlice (&pCurLayer->sSliceEncCtx, pSlice->uiSliceIdx);
97+ pCurSliceHeader->iFirstMbInSlice = WelsGetFirstMbOfSlice (pCurLayer->sLayerInfo.pSliceInLayer, pSlice->uiSliceIdx);
9898
9999 pCurSliceHeader->iFrameNum = pEncCtx->iFrameNum;
100100 pCurSliceHeader->uiIdrPicId = pEncCtx->uiIdrPicId;
@@ -818,6 +818,7 @@ void UpdateMbNeighbourInfoForNextSlice (SDqLayer* pCurDq, · 717 unmodified lines
818818 void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSliceCtx, SMB* pCurMb,
819819 int32_t iFirstMbIdxOfNextSlice, const int32_t kiLastMbIdxInPartition) {
820820 SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
821+ SSlice* pSliceInLayer = pCurLayer->sLayerInfo.pSliceInLayer;
821822 int32_t iCurMbIdx = pCurMb->iMbXY;
822823 uint16_t iCurSliceIdc = pSliceCtx->pOverallMbMap[ iCurMbIdx ];
823824 const int32_t kiSliceIdxStep = pEncCtx->iActiveThreadsNum;
@@ -842,8 +843,7 @@ void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSlic · 18 unmodified lines
842843 (NAL_UNIT_CODED_SLICE_EXT == pCurLayer->sLayerInfo.sNalHeaderExt.sNalUnitHeader.eNalUnitType);
843844 memcpy (&pNextSlice->sSliceHeaderExt, &pCurSlice->sSliceHeaderExt,
844845 sizeof (SSliceHeaderExt)); // confirmed_safe_unsafe_usage
845−
846− pSliceCtx->pFirstMbInSlice[iNextSliceIdc] = iFirstMbIdxOfNextSlice;
846+ pSliceInLayer[iNextSliceIdc].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = iFirstMbIdxOfNextSlice;
847847 WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdxOfNextSlice, iNextSliceIdc,
848848 (kiLastMbIdxInPartition - iFirstMbIdxOfNextSlice + 1), sizeof (uint16_t));
849849
codec/encoder/core/src/wels_task_encoder.cpp+2−2
@@ -218,12 +218,12 @@ void CWelsLoadBalancingSlicingEncodingTask::FinishTask() { · 217 unmodified lines
218218
219219 m_pCtx->pCurDqLayer->sSliceEncCtx.pSliceConsumeTime[m_iSliceIdx] = (uint32_t) (WelsTime() - m_iSliceStart);
220220 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",
222222 m_pCtx->iCodingIndex,
223223 m_iSliceIdx,
224224 m_pCtx->pCurDqLayer->sSliceEncCtx.pSliceConsumeTime[m_iSliceIdx],
225225 m_iSliceSize,
226− m_pCtx->pCurDqLayer->sSliceEncCtx.pFirstMbInSlice[m_iSliceIdx],
226+ m_pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[m_iSliceIdx].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice,
227227 m_pCtx->pCurDqLayer->sSliceEncCtx.pCountMbNumInSlice[m_iSliceIdx]);
228228 }
229229

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t