Showing the changes to codec/encoder/core/src/svc_encode_slice.cpp (1 of 2 files). Show all
Unified · Split
| @@ -974,7 +974,7 @@ int32_t InitSliceList (SSlice*& pSliceList, · 973 unmodified lines | |||
| 974 | int32_t InitAllSlicesInThread (sWelsEncCtx* pCtx) { | 974 | int32_t InitAllSlicesInThread (sWelsEncCtx* pCtx) { |
| 975 | SDqLayer* pCurDqLayer = pCtx->pCurDqLayer; | 975 | SDqLayer* pCurDqLayer = pCtx->pCurDqLayer; |
| 976 | int32_t iSliceIdx = 0; | 976 | int32_t iSliceIdx = 0; |
| 977 | int32_t iTheadIdx = 0; | 977 | int32_t iSlcBuffIdx = 0; |
| 978 | 978 | ||
| 979 | for( ; iSliceIdx < pCurDqLayer->iMaxSliceNum; iSliceIdx++) { | 979 | for( ; iSliceIdx < pCurDqLayer->iMaxSliceNum; iSliceIdx++) { |
| 980 | if(NULL == pCurDqLayer->ppSliceInLayer[iSliceIdx]) { | 980 | if(NULL == pCurDqLayer->ppSliceInLayer[iSliceIdx]) { |
| @@ -984,8 +984,8 @@ int32_t InitAllSlicesInThread (sWelsEncCtx* pCtx) { · 3 unmodified lines | |||
| 984 | pCurDqLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx = -1; | 984 | pCurDqLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx = -1; |
| 985 | } | 985 | } |
| 986 | 986 | ||
| 987 | for( ; iTheadIdx < pCtx->iActiveThreadsNum; iTheadIdx++ ) { | 987 | for( ; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { |
| 988 | pCurDqLayer->sSliceBufferInfo[iTheadIdx].iCodedSliceNum = 0; | 988 | pCurDqLayer->sSliceBufferInfo[iSlcBuffIdx].iCodedSliceNum = 0; |
| 989 | } | 989 | } |
| 990 | 990 | ||
| 991 | return ENC_RETURN_SUCCESS; | 991 | return ENC_RETURN_SUCCESS; |
| @@ -993,24 +993,24 @@ int32_t InitAllSlicesInThread (sWelsEncCtx* pCtx) { · 1 unmodified line | |||
| 993 | 993 | ||
| 994 | int32_t InitOneSliceInThread (sWelsEncCtx* pCtx, | 994 | int32_t InitOneSliceInThread (sWelsEncCtx* pCtx, |
| 995 | SSlice*& pSlice, | 995 | SSlice*& pSlice, |
| 996 | const int32_t kiThreadIdx, | 996 | const int32_t kiSlcBuffIdx, |
| 997 | const int32_t kiDlayerIdx, | 997 | const int32_t kiDlayerIdx, |
| 998 | const int32_t kiSliceIdx) { | 998 | const int32_t kiSliceIdx) { |
| 999 | 999 | ||
| 1000 | if (pCtx->pCurDqLayer->bThreadSlcBufferFlag) { | 1000 | if (pCtx->pCurDqLayer->bThreadSlcBufferFlag) { |
| 1001 | const int32_t kiCodedNumInThread = pCtx->pCurDqLayer->sSliceBufferInfo[kiThreadIdx].iCodedSliceNum; | 1001 | const int32_t kiCodedNumInThread = pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iCodedSliceNum; |
| 1002 | assert(kiCodedNumInThread <= pCtx->pCurDqLayer->sSliceBufferInfo[kiThreadIdx].iMaxSliceNum -1 ); | 1002 | assert(kiCodedNumInThread <= pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iMaxSliceNum -1 ); |
| 1003 | pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [kiThreadIdx].pSliceBuffer[kiCodedNumInThread]; | 1003 | pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [kiSlcBuffIdx].pSliceBuffer[kiCodedNumInThread]; |
| 1004 | } else { | 1004 | } else { |
| 1005 | pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [0].pSliceBuffer[kiSliceIdx]; | 1005 | pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [0].pSliceBuffer[kiSliceIdx]; |
| 1006 | } | 1006 | } |
| 1007 | pSlice->iSliceIdx = kiSliceIdx; | 1007 | pSlice->iSliceIdx = kiSliceIdx; |
| 1008 | pSlice->uiThreadIdx = kiThreadIdx; | 1008 | pSlice->uiThreadIdx = kiSlcBuffIdx; |
| 1009 | 1009 | ||
| 1010 | // Initialize slice bs buffer info | 1010 | // Initialize slice bs buffer info |
| 1011 | pSlice->sSliceBs.uiBsPos = 0; | 1011 | pSlice->sSliceBs.uiBsPos = 0; |
| 1012 | pSlice->sSliceBs.iNalIndex = 0; | 1012 | pSlice->sSliceBs.iNalIndex = 0; |
| 1013 | pSlice->sSliceBs.pBsBuffer = pCtx->pSliceThreading->pThreadBsBuffer[kiThreadIdx]; | 1013 | pSlice->sSliceBs.pBsBuffer = pCtx->pSliceThreading->pThreadBsBuffer[kiSlcBuffIdx]; |
| 1014 | 1014 | ||
| 1015 | return ENC_RETURN_SUCCESS; | 1015 | return ENC_RETURN_SUCCESS; |
| 1016 | } | 1016 | } |
| @@ -1072,7 +1072,7 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 55 unmodified lines | |||
| 1072 | CMemoryAlign* pMa) { | 1072 | CMemoryAlign* pMa) { |
| 1073 | int32_t iRet = 0; | 1073 | int32_t iRet = 0; |
| 1074 | int32_t iSliceIdx = 0; | 1074 | int32_t iSliceIdx = 0; |
| 1075 | int32_t iThreadIdx = 0; | 1075 | int32_t iSlcBuffIdx = 0; |
| 1076 | int32_t iStartIdx = 0; | 1076 | int32_t iStartIdx = 0; |
| 1077 | int32_t iMaxSliceNum = pDqLayer->iMaxSliceNum; | 1077 | int32_t iMaxSliceNum = pDqLayer->iMaxSliceNum; |
| 1078 | SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument; | 1078 | SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument; |
| @@ -1094,8 +1094,8 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 15 unmodified lines | |||
| 1094 | } | 1094 | } |
| 1095 | 1095 | ||
| 1096 | pDqLayer->iMaxSliceNum = 0; | 1096 | pDqLayer->iMaxSliceNum = 0; |
| 1097 | for(iThreadIdx = 0; iThreadIdx < pCtx->iActiveThreadsNum; iThreadIdx++ ) { | 1097 | for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { |
| 1098 | pDqLayer->iMaxSliceNum += pDqLayer->sSliceBufferInfo[iThreadIdx].iMaxSliceNum; | 1098 | pDqLayer->iMaxSliceNum += pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1099 | } | 1099 | } |
| 1100 | 1100 | ||
| 1101 | pDqLayer->ppSliceInLayer = (SSlice**)pMa->WelsMallocz (sizeof (SSlice*) * pDqLayer->iMaxSliceNum, "ppSliceInLayer"); | 1101 | pDqLayer->ppSliceInLayer = (SSlice**)pMa->WelsMallocz (sizeof (SSlice*) * pDqLayer->iMaxSliceNum, "ppSliceInLayer"); |
| @@ -1122,12 +1122,12 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 20 unmodified lines | |||
| 1122 | } | 1122 | } |
| 1123 | 1123 | ||
| 1124 | iStartIdx = 0; | 1124 | iStartIdx = 0; |
| 1125 | for(iThreadIdx = 0; iThreadIdx < pCtx->iActiveThreadsNum; iThreadIdx++ ) { | 1125 | for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { |
| 1126 | for (iSliceIdx = 0; iSliceIdx < pDqLayer->sSliceBufferInfo[iThreadIdx].iMaxSliceNum; iSliceIdx++ ) { | 1126 | for (iSliceIdx = 0; iSliceIdx < pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++ ) { |
| 1127 | pDqLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pDqLayer->sSliceBufferInfo[iThreadIdx].pSliceBuffer+ iSliceIdx; | 1127 | pDqLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pDqLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer+ iSliceIdx; |
| 1128 | } | 1128 | } |
| 1129 | 1129 | ||
| 1130 | iStartIdx += pDqLayer->sSliceBufferInfo[iThreadIdx].iMaxSliceNum; | 1130 | iStartIdx += pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1131 | } | 1131 | } |
| 1132 | 1132 | ||
| 1133 | return ENC_RETURN_SUCCESS; | 1133 | return ENC_RETURN_SUCCESS; |
| @@ -1300,11 +1300,11 @@ int32_t CalculateNewSliceNum (sWelsEncCtx* pCtx, · 166 unmodified lines | |||
| 1300 | int32_t ReallocateSliceInThread (sWelsEncCtx* pCtx, | 1300 | int32_t ReallocateSliceInThread (sWelsEncCtx* pCtx, |
| 1301 | SDqLayer* pDqLayer, | 1301 | SDqLayer* pDqLayer, |
| 1302 | const int32_t kiDlayerIdx, | 1302 | const int32_t kiDlayerIdx, |
| 1303 | const int32_t kiThreadIndex) { | 1303 | const int32_t KiSlcBuffIdx) { |
| 1304 | int32_t iMaxSliceNum = pDqLayer->sSliceBufferInfo[kiThreadIndex].iMaxSliceNum; | 1304 | int32_t iMaxSliceNum = pDqLayer->sSliceBufferInfo[KiSlcBuffIdx].iMaxSliceNum; |
| 1305 | int32_t iMaxSliceNumNew = 0; | 1305 | int32_t iMaxSliceNumNew = 0; |
| 1306 | int32_t iRet = 0; | 1306 | int32_t iRet = 0; |
| 1307 | SSlice* pLastCodedSlice = &pDqLayer->sSliceBufferInfo[kiThreadIndex].pSliceBuffer [iMaxSliceNum - 1]; | 1307 | SSlice* pLastCodedSlice = &pDqLayer->sSliceBufferInfo[KiSlcBuffIdx].pSliceBuffer [iMaxSliceNum - 1]; |
| 1308 | SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiDlayerIdx].sSliceArgument; | 1308 | SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiDlayerIdx].sSliceArgument; |
| 1309 | 1309 | ||
| 1310 | iRet = CalculateNewSliceNum (pCtx, | 1310 | iRet = CalculateNewSliceNum (pCtx, |
| @@ -1317,14 +1317,14 @@ int32_t ReallocateSliceInThread (sWelsEncCtx* pCtx, · 6 unmodified lines | |||
| 1317 | 1317 | ||
| 1318 | iRet = ReallocateSliceList (pCtx, | 1318 | iRet = ReallocateSliceList (pCtx, |
| 1319 | pSliceArgument, | 1319 | pSliceArgument, |
| 1320 | pDqLayer->sSliceBufferInfo[kiThreadIndex].pSliceBuffer, | 1320 | pDqLayer->sSliceBufferInfo[KiSlcBuffIdx].pSliceBuffer, |
| 1321 | iMaxSliceNum, | 1321 | iMaxSliceNum, |
| 1322 | iMaxSliceNumNew); | 1322 | iMaxSliceNumNew); |
| 1323 | if (ENC_RETURN_SUCCESS != iRet) { | 1323 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1324 | return iRet; | 1324 | return iRet; |
| 1325 | } | 1325 | } |
| 1326 | 1326 | ||
| 1327 | pDqLayer->sSliceBufferInfo[kiThreadIndex].iMaxSliceNum = iMaxSliceNumNew; | 1327 | pDqLayer->sSliceBufferInfo[KiSlcBuffIdx].iMaxSliceNum = iMaxSliceNumNew; |
| 1328 | 1328 | ||
| 1329 | return ENC_RETURN_SUCCESS; | 1329 | return ENC_RETURN_SUCCESS; |
| 1330 | } | 1330 | } |
| @@ -1379,7 +1379,7 @@ int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { · 48 unmodified lines | |||
| 1379 | int32_t iMaxSliceNumNew = 0; | 1379 | int32_t iMaxSliceNumNew = 0; |
| 1380 | int32_t iRet = 0; | 1380 | int32_t iRet = 0; |
| 1381 | int32_t iSliceIdx = 0; | 1381 | int32_t iSliceIdx = 0; |
| 1382 | int32_t iThreadIdx = 0; | 1382 | int32_t iSlcBuffIdx = 0; |
| 1383 | int32_t iStartIdx = 0; | 1383 | int32_t iStartIdx = 0; |
| 1384 | const int32_t kiCurDid = pCtx->uiDependencyId; | 1384 | const int32_t kiCurDid = pCtx->uiDependencyId; |
| 1385 | SSlice* pLastCodedSlice = pCurLayer->sSliceBufferInfo[0].pSliceBuffer + (iMaxSliceNumOld - 1); | 1385 | SSlice* pLastCodedSlice = pCurLayer->sSliceBufferInfo[0].pSliceBuffer + (iMaxSliceNumOld - 1); |
| @@ -1405,8 +1405,8 @@ int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { · 19 unmodified lines | |||
| 1405 | pCurLayer->sSliceBufferInfo[0].iMaxSliceNum = iMaxSliceNumNew; | 1405 | pCurLayer->sSliceBufferInfo[0].iMaxSliceNum = iMaxSliceNumNew; |
| 1406 | 1406 | ||
| 1407 | iMaxSliceNumNew = 0; | 1407 | iMaxSliceNumNew = 0; |
| 1408 | for(iThreadIdx = 0; iThreadIdx < pCtx->iActiveThreadsNum; iThreadIdx++ ) { | 1408 | for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { |
| 1409 | iMaxSliceNumNew += pCurLayer->sSliceBufferInfo[iThreadIdx].iMaxSliceNum; | 1409 | iMaxSliceNumNew += pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1410 | } | 1410 | } |
| 1411 | 1411 | ||
| 1412 | iRet = ExtendLayerBuffer(pCtx, pCurLayer->iMaxSliceNum, iMaxSliceNumNew); | 1412 | iRet = ExtendLayerBuffer(pCtx, pCurLayer->iMaxSliceNum, iMaxSliceNumNew); |
| @@ -1414,11 +1414,11 @@ int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { · 1 unmodified line | |||
| 1414 | return iRet; | 1414 | return iRet; |
| 1415 | } | 1415 | } |
| 1416 | 1416 | ||
| 1417 | for(iThreadIdx = 0; iThreadIdx < pCtx->iActiveThreadsNum; iThreadIdx++ ) { | 1417 | for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { |
| 1418 | for (iSliceIdx = 0; iSliceIdx < pCurLayer->sSliceBufferInfo[iThreadIdx].iMaxSliceNum; iSliceIdx++) { | 1418 | for (iSliceIdx = 0; iSliceIdx < pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++) { |
| 1419 | pCurLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pCurLayer->sSliceBufferInfo[iThreadIdx].pSliceBuffer + iSliceIdx; | 1419 | pCurLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx; |
| 1420 | } | 1420 | } |
| 1421 | iStartIdx += pCurLayer->sSliceBufferInfo[iThreadIdx].iMaxSliceNum; | 1421 | iStartIdx += pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1422 | } | 1422 | } |
| 1423 | 1423 | ||
| 1424 | pCurLayer->iMaxSliceNum = iMaxSliceNumNew; | 1424 | pCurLayer->iMaxSliceNum = iMaxSliceNumNew; |
| @@ -1446,7 +1446,7 @@ int32_t ReOrderSliceInLayer (sWelsEncCtx* pCtx, · 21 unmodified lines | |||
| 1446 | const int32_t kiThreadNum) { | 1446 | const int32_t kiThreadNum) { |
| 1447 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; | 1447 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; |
| 1448 | SSlice* pSliceBuffer = NULL; | 1448 | SSlice* pSliceBuffer = NULL; |
| 1449 | int32_t iThreadIdx = 0; | 1449 | int32_t iSlcBuffIdx = 0; |
| 1450 | int32_t iPartitionIdx = 0; | 1450 | int32_t iPartitionIdx = 0; |
| 1451 | int32_t iPartitionID = 0; | 1451 | int32_t iPartitionID = 0; |
| 1452 | int32_t iSliceIdx = 0; | 1452 | int32_t iSliceIdx = 0; |
| @@ -1476,11 +1476,11 @@ int32_t ReOrderSliceInLayer (sWelsEncCtx* pCtx, · 23 unmodified lines | |||
| 1476 | 1476 | ||
| 1477 | //before encode all slices in layer, slices' index are init with -1 | 1477 | //before encode all slices in layer, slices' index are init with -1 |
| 1478 | //pSliceBuffer->iSliceIdx will be set to actual slice index when encode one slice | 1478 | //pSliceBuffer->iSliceIdx will be set to actual slice index when encode one slice |
| 1479 | for (iThreadIdx = 0; iThreadIdx < kiThreadNum; iThreadIdx++) { | 1479 | for (iSlcBuffIdx = 0; iSlcBuffIdx < kiThreadNum; iSlcBuffIdx++) { |
| 1480 | iSliceNumInThread = pCurLayer->sSliceBufferInfo[iThreadIdx].iMaxSliceNum; | 1480 | iSliceNumInThread = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1481 | 1481 | ||
| 1482 | for(iSliceIdx =0; iSliceIdx < iSliceNumInThread; iSliceIdx++) { | 1482 | for(iSliceIdx =0; iSliceIdx < iSliceNumInThread; iSliceIdx++) { |
| 1483 | pSliceBuffer = pCurLayer->sSliceBufferInfo[iThreadIdx].pSliceBuffer + iSliceIdx; | 1483 | pSliceBuffer = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx; |
| 1484 | if (NULL == pSliceBuffer) { | 1484 | if (NULL == pSliceBuffer) { |
| 1485 | return ENC_RETURN_UNEXPECTED; | 1485 | return ENC_RETURN_UNEXPECTED; |
| 1486 | } | 1486 | } |
| @@ -1581,8 +1581,8 @@ int32_t SliceLayerInfoUpdate (sWelsEncCtx* pCtx, · 94 unmodified lines | |||
| 1581 | int32_t iCodedNalCount = 0; | 1581 | int32_t iCodedNalCount = 0; |
| 1582 | int32_t iRet = 0; | 1582 | int32_t iRet = 0; |
| 1583 | 1583 | ||
| 1584 | for ( int32_t iThreadIdx = 0; iThreadIdx < pCtx->iActiveThreadsNum; iThreadIdx++) { | 1584 | for ( int32_t iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { |
| 1585 | iMaxSliceNum += pCtx->pCurDqLayer->sSliceBufferInfo[iThreadIdx].iMaxSliceNum; | 1585 | iMaxSliceNum += pCtx->pCurDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1586 | } | 1586 | } |
| 1587 | 1587 | ||
| 1588 | //reallocate ppSliceInLayer if total encoded slice num exceed max slice num | 1588 | //reallocate ppSliceInLayer if total encoded slice num exceed max slice num |