History

Multi-thread-fixed:RBC#1683:add ppSlice update module

huade committed 9 years ago

Commit 37a6e8f1 parent 4ca5d946 files · +115 −3Browse files

Showing the changes to codec/encoder/core/src/svc_encode_slice.cpp (1 of 6 files). Show all

Unified · Split

codec/encoder/core/src/svc_encode_slice.cpp+104−0
@@ -1325,6 +1325,110 @@ int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { · 1324 unmodified lines
1325 return ENC_RETURN_SUCCESS;1325 return ENC_RETURN_SUCCESS;
1326}1326}
1327 1327
1328/*
1329int32_t ReOrderSliceInLayer (SDqLayer* pCurLayer,
1330 const int32_t kiThreadNum,
1331 const int32_t kiPartitionNum) {
1332 SSlice* pSliceInThread = NULL;
1333 int32_t iThreadIdx = 0;
1334 int32_t iPartitionIdx = 0;
1335 int32_t iPartitionID = 0;
1336 int32_t iSliceIdx = 0;
1337 int32_t iSliceNumInThread = 0;
1338 int32_t iPartitionOffset = 0;
1339 int32_t iActualSliceIdx = 0;
1340 int32_t aiPartitionOffset[MAX_THREADS_NUM] = {0};
1341
1342 //for non-dynamic slice mode, kiPartitionNum = 1, iPartitionOffset = 0
1343 for(iPartitionIdx = 0; iPartitionIdx < kiPartitionNum; iPartitionIdx++) {
1344 aiPartitionOffset[iPartitionIdx] = iPartitionOffset;
1345 iPartitionOffset += pCurLayer->pNumSliceCodedOfPartition[iPartitionIdx];
1346 }
1347
1348 for (iThreadIdx = 0; iThreadIdx < kiThreadNum; iThreadIdx++) {
1349 iSliceNumInThread = pCurLayer->sSliceThreadInfo.iEncodedSliceNumInThread[iThreadIdx];
1350
1351 for(iSliceIdx =0; iSliceIdx < iSliceNumInThread; iSliceIdx++) {
1352 pSliceInThread = pCurLayer->sSliceThreadInfo.pSliceInThread[iThreadIdx] + iSliceIdx;
1353 if (NULL == pSliceInThread) {
1354 return ENC_RETURN_UNEXPECTED;
1355 }
1356
1357 iPartitionID = pSliceInThread->uiSliceIdx % kiPartitionNum;
1358 iActualSliceIdx = aiPartitionOffset[iPartitionID] + pSliceInThread->uiSliceIdx / kiPartitionNum;
1359 pCurLayer->ppSliceInLayer[iActualSliceIdx] = pSliceInThread;
1360 }
1361 }
1362
1363 return ENC_RETURN_SUCCESS;
1364}
1365
1366static inline int32_t CheckAllSliceBuffer(SDqLayer* pCurLayer, const int32_t kiCodedSliceNum) {
1367 int32_t iSliceIdx = 0;
1368 for(; iSliceIdx <kiCodedSliceNum ; iSliceIdx ++ ) {
1369 if ( NULL == pCurLayer->ppSliceInLayer[iSliceIdx]) {
1370 return ENC_RETURN_UNEXPECTED;
1371 }
1372
1373 if ( iSliceIdx != pCurLayer->ppSliceInLayer[iSliceIdx]->uiSliceIdx) {
1374 return ENC_RETURN_UNEXPECTED;
1375 }
1376 }
1377
1378 return ENC_RETURN_SUCCESS;
1379}
1380
1381int32_t SliceLayerInfoUpdate (sWelsEncCtx* pCtx, const int32_t kiDlayerIndex) {
1382
1383 CMemoryAlign* pMA = pCtx->pMemAlign;
1384 SDqLayer* pCurLayer = pCtx->pCurDqLayer;
1385 SSlice** ppSlice = NULL;
1386 int32_t iCodedSliceNum = 0;
1387 int32_t iThreadIdx = 0;
1388 int32_t iRet = 0;
1389 SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument;
1390 int32_t iPartitionNum = (SM_SIZELIMITED_SLICE == pSliceArgument->uiSliceMode) ? pCtx->iActiveThreadsNum : 1;
1391
1392 for ( ; iThreadIdx < pCtx->iActiveThreadsNum; iThreadIdx++) {
1393 iCodedSliceNum += pCurLayer->sSliceThreadInfo.iMaxSliceNumInThread[iThreadIdx];
1394 }
1395
1396 if (iCodedSliceNum <= 0) {
1397 return ENC_RETURN_UNEXPECTED;
1398 }
1399
1400 //reallocate ppSliceInLayer if total encoded slice num exceed max slice num
1401 if (iCodedSliceNum > pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint) {
1402 ppSlice = (SSlice**)pMA->WelsMallocz (sizeof (SSlice*) * iCodedSliceNum, "ppSlice");
1403 if (NULL == ppSlice) {
1404 WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::SliceLayerInfoUpdate: ppSlice is NULL");
1405 return ENC_RETURN_MEMALLOCERR;
1406 }
1407
1408 pMA->WelsFree (pCurLayer->ppSliceInLayer, "ppSliceInLayer");
1409 pCurLayer->ppSliceInLayer = ppSlice;
1410 pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint = iCodedSliceNum;
1411 }
1412
1413 //update ppSliceInLayer based on pSliceInThread, reordering based on slice index
1414 iRet = ReOrderSliceInLayer (pCurLayer, pCtx->iActiveThreadsNum, iPartitionNum);
1415 if (ENC_RETURN_SUCCESS != iRet) {
1416 WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
1417 "CWelsH264SVCEncoder::SliceLayerInfoUpdate: ReOrderSliceInLayer failed");
1418 return iRet;
1419 }
1420
1421 iRet = CheckAllSliceBuffer(pCurLayer, pCtx->iActiveThreadsNum);
1422 if (ENC_RETURN_SUCCESS != iRet) {
1423 WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
1424 "CWelsH264SVCEncoder::SliceLayerInfoUpdate: ReOrderSliceInLayerDynamic failed");
1425 return iRet;
1426 }
1427
1428 return ENC_RETURN_SUCCESS;
1429}
1430*/
1431
1328int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const int32_t kiNalType) {1432int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const int32_t kiNalType) {
1329 SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;1433 SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
1330 SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt;1434 SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt;

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