History

Merge pull request #2452 from sijchen/refactor_sps2

ruil2 committed 10 years ago

Commit 0ec686f2 parents 1eb7352 ffb850414 files · +1126 −494Browse files

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

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+56−405
@@ -767,12 +767,15 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 766 unmodified lines
767 ++ iDIndex;767 ++ iDIndex;
768 } while (iDIndex < iNumDependencyLayers);768 } while (iDIndex < iNumDependencyLayers);
769 769
770 if (NULL == (*ppCtx)->pFuncList || NULL == (*ppCtx)->pFuncList->pParametersetStrategy) {
771 WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR,
772 "AcquireLayersNals(), pFuncList and pParametersetStrategy needed to be initialized first!");
773 return 1;
774 }
770 // count parasets775 // count parasets
771 iCountNumNals += 1 + iNumDependencyLayers + (iCountNumLayers << 1) +776 iCountNumNals += 1 + iNumDependencyLayers + (iCountNumLayers << 1) +
772 iCountNumLayers // plus iCountNumLayers for reserved application777 iCountNumLayers // plus iCountNumLayers for reserved application
773 + (*ppCtx)->GetNeededSpsNum()778 + (*ppCtx)->pFuncList->pParametersetStrategy->GetAllNeededParasetNum();
774 + (*ppCtx)->GetNeededSubsetSpsNum()
775 + (*ppCtx)->GetNeededPpsNum();
776 779
777 // to check number of layers / nals / slices dependencies, 12/8/2010780 // to check number of layers / nals / slices dependencies, 12/8/2010
778 if (iCountNumLayers > MAX_LAYER_NUM_OF_FRAME) {781 if (iCountNumLayers > MAX_LAYER_NUM_OF_FRAME) {
@@ -956,152 +959,7 @@ void FreeRefList (SRefList*& pRefList, CMemoryAlign* pMa, const int iMaxNumRefF · 177 unmodified lines
956 pRefList = NULL;959 pRefList = NULL;
957}960}
958 961
959static int32_t WelsGenerateNewSps (sWelsEncCtx* pCtx, const bool kbUseSubsetSps, const int32_t iDlayerIndex,
960 const int32_t iDlayerCount, const int32_t kiSpsId,
961 SWelsSPS*& pSps, SSubsetSps*& pSubsetSps, bool bSVCBaselayer) {
962 int32_t iRet = 0;
963
964 if (!kbUseSubsetSps) {
965 pSps = & (pCtx->pSpsArray[kiSpsId]);
966 } else {
967 pSubsetSps = & (pCtx->pSubsetArray[kiSpsId]);
968 pSps = &pSubsetSps->pSps;
969 }
970
971 SWelsSvcCodingParam* pParam = pCtx->pSvcParam;
972 SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex];
973 // Need port pSps/pPps initialization due to spatial scalability changed
974 if (!kbUseSubsetSps) {
975 iRet = WelsInitSps (pSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod,
976 pParam->iMaxNumRefFrame,
977 kiSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE, iDlayerCount,
978 bSVCBaselayer);
979 } else {
980 iRet = WelsInitSubsetSps (pSubsetSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod,
981 pParam->iMaxNumRefFrame,
982 kiSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE, iDlayerCount);
983 }
984 return iRet;
985}
986
987static bool CheckMatchedSps (SWelsSPS* const pSps1, SWelsSPS* const pSps2) {
988
989 if ((pSps1->iMbWidth != pSps2->iMbWidth)
990 || (pSps1->iMbHeight != pSps2->iMbHeight)) {
991 return false;
992 }
993
994 if ((pSps1->uiLog2MaxFrameNum != pSps2->uiLog2MaxFrameNum)
995 || (pSps1->iLog2MaxPocLsb != pSps2->iLog2MaxPocLsb)) {
996 return false;
997 }
998
999 if (pSps1->iNumRefFrames != pSps2->iNumRefFrames) {
1000 return false;
1001 }
1002
1003 if ((pSps1->bFrameCroppingFlag != pSps2->bFrameCroppingFlag)
1004 || (pSps1->sFrameCrop.iCropLeft != pSps2->sFrameCrop.iCropLeft)
1005 || (pSps1->sFrameCrop.iCropRight != pSps2->sFrameCrop.iCropRight)
1006 || (pSps1->sFrameCrop.iCropTop != pSps2->sFrameCrop.iCropTop)
1007 || (pSps1->sFrameCrop.iCropBottom != pSps2->sFrameCrop.iCropBottom)
1008 ) {
1009 return false;
1010 }
1011
1012 if ((pSps1->uiProfileIdc != pSps2->uiProfileIdc)
1013 || (pSps1->bConstraintSet0Flag != pSps2->bConstraintSet0Flag)
1014 || (pSps1->bConstraintSet1Flag != pSps2->bConstraintSet1Flag)
1015 || (pSps1->bConstraintSet2Flag != pSps2->bConstraintSet2Flag)
1016 || (pSps1->bConstraintSet3Flag != pSps2->bConstraintSet3Flag)
1017 || (pSps1->iLevelIdc != pSps2->iLevelIdc)) {
1018 return false;
1019 }
1020
1021 return true;
1022}
1023 962
1024static bool CheckMatchedSubsetSps (SSubsetSps* const pSubsetSps1, SSubsetSps* const pSubsetSps2) {
1025 if (!CheckMatchedSps (&pSubsetSps1->pSps, &pSubsetSps2->pSps)) {
1026 return false;
1027 }
1028
1029 if ((pSubsetSps1->sSpsSvcExt.iExtendedSpatialScalability != pSubsetSps2->sSpsSvcExt.iExtendedSpatialScalability)
1030 || (pSubsetSps1->sSpsSvcExt.bAdaptiveTcoeffLevelPredFlag != pSubsetSps2->sSpsSvcExt.bAdaptiveTcoeffLevelPredFlag)
1031 || (pSubsetSps1->sSpsSvcExt.bSeqTcoeffLevelPredFlag != pSubsetSps2->sSpsSvcExt.bSeqTcoeffLevelPredFlag)
1032 || (pSubsetSps1->sSpsSvcExt.bSliceHeaderRestrictionFlag != pSubsetSps2->sSpsSvcExt.bSliceHeaderRestrictionFlag)) {
1033 return false;
1034 }
1035
1036 return true;
1037}
1038
1039int32_t FindExistingSps (SWelsSvcCodingParam* pParam, const bool kbUseSubsetSps, const int32_t iDlayerIndex,
1040 const int32_t iDlayerCount, const int32_t iSpsNumInUse,
1041 SWelsSPS* pSpsArray,
1042 SSubsetSps* pSubsetArray, bool bSVCBaseLayer) {
1043 SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex];
1044
1045 assert (iSpsNumInUse <= MAX_SPS_COUNT);
1046 if (!kbUseSubsetSps) {
1047 SWelsSPS sTmpSps;
1048 WelsInitSps (&sTmpSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod,
1049 pParam->iMaxNumRefFrame,
1050 0, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE, iDlayerCount,
1051 bSVCBaseLayer);
1052 for (int32_t iId = 0; iId < iSpsNumInUse; iId++) {
1053 if (CheckMatchedSps (&sTmpSps, &pSpsArray[iId])) {
1054 return iId;
1055 }
1056 }
1057 } else {
1058 SSubsetSps sTmpSubsetSps;
1059 WelsInitSubsetSps (&sTmpSubsetSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod,
1060 pParam->iMaxNumRefFrame,
1061 0, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE, iDlayerCount);
1062
1063 for (int32_t iId = 0; iId < iSpsNumInUse; iId++) {
1064 if (CheckMatchedSubsetSps (&sTmpSubsetSps, &pSubsetArray[iId])) {
1065 return iId;
1066 }
1067 }
1068 }
1069
1070 return INVALID_ID;
1071}
1072
1073int32_t FindExistingPps (SWelsSPS* pSps, SSubsetSps* pSubsetSps, const bool kbUseSubsetSps, const int32_t iSpsId,
1074 const bool kbEntropyCodingFlag, const int32_t iPpsNumInUse,
1075 SWelsPPS* pPpsArray) {
1076#if !defined(DISABLE_FMO_FEATURE)
1077 // feature not supported yet
1078 return INVALID_ID;
1079#endif//!DISABLE_FMO_FEATURE
1080
1081 SWelsPPS sTmpPps;
1082 WelsInitPps (&sTmpPps,
1083 pSps,
1084 pSubsetSps,
1085 0,
1086 true,
1087 kbUseSubsetSps,
1088 kbEntropyCodingFlag);
1089
1090 assert (iPpsNumInUse <= MAX_PPS_COUNT);
1091 for (int32_t iId = 0; iId < iPpsNumInUse; iId++) {
1092 if ((sTmpPps.iSpsId == pPpsArray[iId].iSpsId)
1093 && (sTmpPps.bEntropyCodingModeFlag == pPpsArray[iId].bEntropyCodingModeFlag)
1094 && (sTmpPps.iPicInitQp == pPpsArray[iId].iPicInitQp)
1095 && (sTmpPps.iPicInitQs == pPpsArray[iId].iPicInitQs)
1096 && (sTmpPps.uiChromaQpIndexOffset == pPpsArray[iId].uiChromaQpIndexOffset)
1097 && (sTmpPps.bDeblockingFilterControlPresentFlag == pPpsArray[iId].bDeblockingFilterControlPresentFlag)
1098 ) {
1099 return iId;
1100 }
1101 }
1102
1103 return INVALID_ID;
1104}
1105 963
1106static inline int32_t InitSliceList (sWelsEncCtx** ppCtx,964static inline int32_t InitSliceList (sWelsEncCtx** ppCtx,
1107 SDqLayer* pDqLayer,965 SDqLayer* pDqLayer,
@@ -1248,7 +1106,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 140 unmodified lines
1248 CMemoryAlign* pMa = NULL;1106 CMemoryAlign* pMa = NULL;
1249 int32_t iDlayerCount = 0;1107 int32_t iDlayerCount = 0;
1250 int32_t iDlayerIndex = 0;1108 int32_t iDlayerIndex = 0;
1251 uint32_t iSpsId = 0;1109 int32_t iSpsId = 0;
1252 uint32_t iPpsId = 0;1110 uint32_t iPpsId = 0;
1253 uint32_t iNumRef = 0;1111 uint32_t iNumRef = 0;
1254 int32_t iResult = 0;1112 int32_t iResult = 0;
@@ -1388,8 +1246,10 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 133 unmodified lines
1388 }1246 }
1389 1247
1390 // for dynamically malloc for parameter sets memory instead of maximal items for standard to reduce size, 3/18/20101248 // for dynamically malloc for parameter sets memory instead of maximal items for standard to reduce size, 3/18/2010
1391 const int32_t kiNeededSpsNum = (*ppCtx)->GetNeededSpsNum();1249 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFuncList), FreeMemorySvc (ppCtx))
1392 const int32_t kiNeededSubsetSpsNum = (*ppCtx)->GetNeededSubsetSpsNum();1250 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFuncList->pParametersetStrategy), FreeMemorySvc (ppCtx))
1251 const int32_t kiNeededSpsNum = (*ppCtx)->pFuncList->pParametersetStrategy->GetNeededSpsNum();
1252 const int32_t kiNeededSubsetSpsNum = (*ppCtx)->pFuncList->pParametersetStrategy->GetNeededSubsetSpsNum();
1393 (*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMallocz (kiNeededSpsNum * sizeof (SWelsSPS), "pSpsArray");1253 (*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMallocz (kiNeededSpsNum * sizeof (SWelsSPS), "pSpsArray");
1394 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSpsArray), FreeMemorySvc (ppCtx))1254 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSpsArray), FreeMemorySvc (ppCtx))
1395 if (kiNeededSubsetSpsNum > 0) {1255 if (kiNeededSubsetSpsNum > 0) {
@@ -1399,36 +1259,15 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 3 unmodified lines
1399 (*ppCtx)->pSubsetArray = NULL;1259 (*ppCtx)->pSubsetArray = NULL;
1400 }1260 }
1401 1261
1402 if ((SPS_LISTING & pParam->eSpsPpsIdStrategy) && (NULL != pExistingParasetList)) {
1403 (*ppCtx)->sPSOVector.uiInUseSpsNum = pExistingParasetList->uiInUseSpsNum;
1404 memcpy ((*ppCtx)->pSpsArray, pExistingParasetList->sSps, MAX_SPS_COUNT * sizeof (SWelsSPS));
1405
1406 if (kiNeededSubsetSpsNum > 0) {
1407 (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum = pExistingParasetList->uiInUseSubsetSpsNum;
1408 memcpy ((*ppCtx)->pSubsetArray, pExistingParasetList->sSubsetSps, MAX_SPS_COUNT * sizeof (SSubsetSps));
1409 } else {
1410 (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum = 0;
1411 }
1412 }
1413
1414 // PPS1262 // PPS
1415 const int32_t kiNeededPpsNum = (*ppCtx)->GetNeededPpsNum();1263 const int32_t kiNeededPpsNum = (*ppCtx)->pFuncList->pParametersetStrategy->GetNeededPpsNum();
1416 (*ppCtx)->pPPSArray = (SWelsPPS*)pMa->WelsMallocz (kiNeededPpsNum * sizeof (SWelsPPS), "pPPSArray");1264 (*ppCtx)->pPPSArray = (SWelsPPS*)pMa->WelsMallocz (kiNeededPpsNum * sizeof (SWelsPPS), "pPPSArray");
1417 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pPPSArray), FreeMemorySvc (ppCtx))1265 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pPPSArray), FreeMemorySvc (ppCtx))
1418 1266
1419 // copy from existing if the pointer exists1267 (*ppCtx)->pFuncList->pParametersetStrategy->LoadPrevious (pExistingParasetList, (*ppCtx)->pSpsArray,
1420 if ((SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy) && (NULL != pExistingParasetList)) {1268 (*ppCtx)->pSubsetArray, (*ppCtx)->pPPSArray);
1421 (*ppCtx)->sPSOVector.uiInUsePpsNum = pExistingParasetList->uiInUsePpsNum;
1422 memcpy ((*ppCtx)->pPPSArray, pExistingParasetList->sPps, MAX_PPS_COUNT * sizeof (SWelsPPS));
1423 }
1424 1269
1425 1270
1426 if (INCREASING_ID & pParam->eSpsPpsIdStrategy) {
1427 (*ppCtx)->pPSOVector = & ((*ppCtx)->sPSOVector);
1428 } else {
1429 (*ppCtx)->pPSOVector = NULL;
1430 }
1431
1432 (*ppCtx)->pDqIdcMap = (SDqIdc*)pMa->WelsMallocz (iDlayerCount * sizeof (SDqIdc), "pDqIdcMap");1271 (*ppCtx)->pDqIdcMap = (SDqIdc*)pMa->WelsMallocz (iDlayerCount * sizeof (SDqIdc), "pDqIdcMap");
1433 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pDqIdcMap), FreeMemorySvc (ppCtx))1272 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pDqIdcMap), FreeMemorySvc (ppCtx))
1434 1273
@@ -1441,79 +1280,18 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 6 unmodified lines
1441 && (iDlayerIndex == BASE_DEPENDENCY_ID);1280 && (iDlayerIndex == BASE_DEPENDENCY_ID);
1442 pDqIdc->uiSpatialId = iDlayerIndex;1281 pDqIdc->uiSpatialId = iDlayerIndex;
1443 1282
1444 if (! (SPS_LISTING & pParam->eSpsPpsIdStrategy)) {1283 iSpsId = (*ppCtx)->pFuncList->pParametersetStrategy->GenerateNewSps (*ppCtx, bUseSubsetSps, iDlayerIndex,
1445 WelsGenerateNewSps (*ppCtx, bUseSubsetSps, iDlayerIndex,1284 iDlayerCount, iSpsId, pSps, pSubsetSps, bSvcBaselayer);
1446 iDlayerCount, iSpsId, pSps, pSubsetSps, bSvcBaselayer);1285 WELS_VERIFY_RETURN_IF (ENC_RETURN_UNSUPPORTED_PARA, (0 > iSpsId))
1286 if (!bUseSubsetSps) {
1287 pSps = & ((*ppCtx)->pSpsArray[iSpsId]);
1447 } else {1288 } else {
1448 //SPS_LISTING_AND_PPS_INCREASING == pParam->eSpsPpsIdStrategy1289 pSubsetSps = & ((*ppCtx)->pSubsetArray[iSpsId]);
1449 //check if the current param can fit in an existing SPS
1450 const int32_t kiFoundSpsId = FindExistingSps ((*ppCtx)->pSvcParam, bUseSubsetSps, iDlayerIndex, iDlayerCount,
1451 bUseSubsetSps ? ((*ppCtx)->sPSOVector.uiInUseSubsetSpsNum) : ((*ppCtx)->sPSOVector.uiInUseSpsNum),
1452 (*ppCtx)->pSpsArray,
1453 (*ppCtx)->pSubsetArray, bSvcBaselayer);
1454
1455
1456 if (INVALID_ID != kiFoundSpsId) {
1457 //if yes, set pSps or pSubsetSps to it
1458 iSpsId = kiFoundSpsId;
1459 if (!bUseSubsetSps) {
1460 pSps = & ((*ppCtx)->pSpsArray[kiFoundSpsId]);
1461 } else {
1462 pSubsetSps = & ((*ppCtx)->pSubsetArray[kiFoundSpsId]);
1463 }
1464 } else {
1465 //if no, generate a new SPS as usual
1466 if ((SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy) && (MAX_PPS_COUNT <= (*ppCtx)->sPSOVector.uiInUsePpsNum)) {
1467 //check if we can generate new SPS or not
1468 WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR,
1469 "InitDqLayers(), cannot generate new SPS under the SPS_PPS_LISTING mode!");
1470 return ENC_RETURN_UNSUPPORTED_PARA;
1471 }
1472
1473 iSpsId = (!bUseSubsetSps) ? ((*ppCtx)->sPSOVector.uiInUseSpsNum++) : ((*ppCtx)->sPSOVector.uiInUseSubsetSpsNum++);
1474 if (iSpsId >= MAX_SPS_COUNT) {
1475 if (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy) {
1476 WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR,
1477 "InitDqLayers(), cannot generate new SPS under the SPS_PPS_LISTING mode!");
1478 return ENC_RETURN_UNSUPPORTED_PARA;
1479 }
1480 // reset current list
1481 if (!bUseSubsetSps) {
1482 (*ppCtx)->sPSOVector.uiInUseSpsNum = 1;
1483 memset ((*ppCtx)->pSpsArray, 0, MAX_SPS_COUNT * sizeof (SWelsSPS));
1484 } else {
1485 (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum = 1;
1486 memset ((*ppCtx)->pSubsetArray, 0, MAX_SPS_COUNT * sizeof (SSubsetSps));
1487 }
1488 iSpsId = 0;
1489 }
1490
1491 WelsGenerateNewSps (*ppCtx, bUseSubsetSps, iDlayerIndex,
1492 iDlayerCount, iSpsId, pSps, pSubsetSps, bSvcBaselayer);
1493 }
1494 }1290 }
1495 1291
1496 if (! (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy)) {1292 iPpsId = (*ppCtx)->pFuncList->pParametersetStrategy->InitPps ((*ppCtx), iSpsId, pSps, pSubsetSps, iPpsId, true,
1497 pPps = & (*ppCtx)->pPPSArray[iPpsId];1293 bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0);
1498 // initialize pPps1294 pPps = & ((*ppCtx)->pPPSArray[iPpsId]);
1499 WelsInitPps (pPps, pSps, pSubsetSps, iPpsId, true, bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0);
1500 } else {
1501 const int32_t kiFoundPpsId = FindExistingPps (pSps, pSubsetSps, bUseSubsetSps, iSpsId,
1502 pParam->iEntropyCodingModeFlag != 0,
1503 (*ppCtx)->sPSOVector.uiInUsePpsNum,
1504 (*ppCtx)->pPPSArray);
1505
1506
1507 if (INVALID_ID != kiFoundPpsId) {
1508 //if yes, set pPps to it
1509 iPpsId = kiFoundPpsId;
1510 pPps = & ((*ppCtx)->pPPSArray[kiFoundPpsId]);
1511 } else {
1512 iPpsId = ((*ppCtx)->sPSOVector.uiInUsePpsNum++);
1513 pPps = & (*ppCtx)->pPPSArray[iPpsId];
1514 WelsInitPps (pPps, pSps, pSubsetSps, iPpsId, true, bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0);
1515 }
1516 }
1517 1295
1518 // Not using FMO in SVC coding so far, come back if need FMO1296 // Not using FMO in SVC coding so far, come back if need FMO
1519 {1297 {
@@ -1533,8 +1311,6 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 13 unmodified lines
1533 pDqIdc->iSpsId = iSpsId;1311 pDqIdc->iSpsId = iSpsId;
1534 pDqIdc->iPpsId = iPpsId;1312 pDqIdc->iPpsId = iPpsId;
1535 1313
1536 (*ppCtx)->sPSOVector.bPpsIdMappingIntoSubsetsps[iPpsId] = bUseSubsetSps;
1537
1538 if ((pParam->bSimulcastAVC) || (bUseSubsetSps))1314 if ((pParam->bSimulcastAVC) || (bUseSubsetSps))
1539 ++ iSpsId;1315 ++ iSpsId;
1540 ++ iPpsId;1316 ++ iPpsId;
@@ -1547,13 +1323,8 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 6 unmodified lines
1547 1323
1548 ++ iDlayerIndex;1324 ++ iDlayerIndex;
1549 }1325 }
1550 if (SPS_LISTING & pParam->eSpsPpsIdStrategy) {1326
1551 (*ppCtx)->iSpsNum = (*ppCtx)->sPSOVector.uiInUseSpsNum;1327 (*ppCtx)->pFuncList->pParametersetStrategy->UpdateParaSetNum ((*ppCtx));
1552 (*ppCtx)->iSubsetSpsNum = (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum;
1553 }
1554 if (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy) {
1555 (*ppCtx)->iPpsNum = (*ppCtx)->sPSOVector.uiInUsePpsNum;
1556 }
1557 return ENC_RETURN_SUCCESS;1328 return ENC_RETURN_SUCCESS;
1558}1329}
1559 1330
@@ -1908,8 +1679,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 348 unmodified lines
1908 return 1;1679 return 1;
1909 }1680 }
1910 1681
1911 const int32_t kiSpsSize = (*ppCtx)->GetNeededSpsNum() * SPS_BUFFER_SIZE;1682 const int32_t kiSpsSize = (*ppCtx)->pFuncList->pParametersetStrategy->GetNeededSpsNum() * SPS_BUFFER_SIZE;
1912 const int32_t kiPpsSize = (*ppCtx)->GetNeededPpsNum() * PPS_BUFFER_SIZE;1683 const int32_t kiPpsSize = (*ppCtx)->pFuncList->pParametersetStrategy->GetNeededPpsNum() * PPS_BUFFER_SIZE;
1913 iNonVclLayersBsSizeCount = SSEI_BUFFER_SIZE + kiSpsSize + kiPpsSize;1684 iNonVclLayersBsSizeCount = SSEI_BUFFER_SIZE + kiSpsSize + kiPpsSize;
1914 1685
1915 bool bDynamicSlice = false;1686 bool bDynamicSlice = false;
@@ -2309,6 +2080,10 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 393 unmodified lines
2309 2080
2310 FreeCodingParam (&pCtx->pSvcParam, pMa);2081 FreeCodingParam (&pCtx->pSvcParam, pMa);
2311 if (NULL != pCtx->pFuncList) {2082 if (NULL != pCtx->pFuncList) {
2083 if (NULL != pCtx->pFuncList->pParametersetStrategy) {
2084 WELS_DELETE_OP (pCtx->pFuncList->pParametersetStrategy);
2085 }
2086
2312 pMa->WelsFree (pCtx->pFuncList, "SWelsFuncPtrList");2087 pMa->WelsFree (pCtx->pFuncList, "SWelsFuncPtrList");
2313 pCtx->pFuncList = NULL;2088 pCtx->pFuncList = NULL;
2314 }2089 }
@@ -2860,9 +2635,8 @@ void WelsInitCurrentLayer (sWelsEncCtx* pCtx, · 545 unmodified lines
2860 int32_t iCurPpsId = pDqIdc->iPpsId;2635 int32_t iCurPpsId = pDqIdc->iPpsId;
2861 int32_t iCurSpsId = pDqIdc->iSpsId;2636 int32_t iCurSpsId = pDqIdc->iSpsId;
2862 2637
2863 if (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy) {2638 iCurPpsId = pCtx->pFuncList->pParametersetStrategy->GetCurrentPpsId (iCurPpsId,
2864 iCurPpsId = pCtx->sPSOVector.iPpsIdList[pDqIdc->iPpsId][WELS_ABS (pCtx->uiIdrPicId - 1) % MAX_PPS_COUNT];2639 WELS_ABS (pCtx->uiIdrPicId - 1) % MAX_PPS_COUNT);
2865 }
2866 2640
2867 pBaseSlice->sSliceHeaderExt.sSliceHeader.iPpsId = iCurPpsId;2641 pBaseSlice->sSliceHeaderExt.sSliceHeader.iPpsId = iCurPpsId;
2868 pCurDq->sLayerInfo.pPpsP =2642 pCurDq->sLayerInfo.pPpsP =
@@ -3141,45 +2915,12 @@ static inline void PrefetchReferencePicture (sWelsEncCtx* pCtx, const EVideoFram · 272 unmodified lines
3141 }2915 }
3142}2916}
3143 2917
3144
3145void ParasetIdAdditionIdAdjust (SParaSetOffsetVariable* sParaSetOffsetVariable, const int32_t kiCurEncoderParaSetId,
3146 const uint32_t kuiMaxIdInBs) { //paraset_type = 0: SPS; =1: PPS
3147 //SPS_ID in avc_sps and pSubsetSps will be different using this
3148 //SPS_ID case example:
3149 //1st enter: next_spsid_in_bs == 0; spsid == 0; delta==0; //actual spsid_in_bs == 0
3150 //1st finish: next_spsid_in_bs == 1;
3151 //2nd enter: next_spsid_in_bs == 1; spsid == 0; delta==1; //actual spsid_in_bs == 1
3152 //2nd finish: next_spsid_in_bs == 2;
3153 //31st enter: next_spsid_in_bs == 31; spsid == 0~2; delta==31~29; //actual spsid_in_bs == 31
3154 //31st finish:next_spsid_in_bs == 0;
3155 //31st enter: next_spsid_in_bs == 0; spsid == 0~2; delta==-2~0; //actual spsid_in_bs == 0
3156 //31st finish:next_spsid_in_bs == 1;
3157
3158 const int32_t kiEncId = kiCurEncoderParaSetId;
3159 uint32_t uiNextIdInBs = sParaSetOffsetVariable->uiNextParaSetIdToUseInBs;
3160
3161 //update current layer's pCodingParam
3162 sParaSetOffsetVariable->iParaSetIdDelta[kiEncId] = uiNextIdInBs -
3163 kiEncId; //for current parameter set, change its id_delta
3164 //write pso pData for next update:
3165 sParaSetOffsetVariable->bUsedParaSetIdInBs[uiNextIdInBs] = true; // update current used_id
3166
3167 //prepare for next update:
3168 // find the next avaibable iId
3169 ++uiNextIdInBs;
3170 if (uiNextIdInBs >= kuiMaxIdInBs) {
3171 uiNextIdInBs = 0;//ensure the SPS_ID wound not exceed MAX_SPS_COUNT
3172 }
3173 // update next_id
3174 sParaSetOffsetVariable->uiNextParaSetIdToUseInBs = uiNextIdInBs;
3175}
3176
3177int32_t WelsWriteOneSPS (sWelsEncCtx* pCtx, const int32_t kiSpsIdx, int32_t& iNalSize) {2918int32_t WelsWriteOneSPS (sWelsEncCtx* pCtx, const int32_t kiSpsIdx, int32_t& iNalSize) {
3178 int iNal = pCtx->pOut->iNalIndex;2919 int iNal = pCtx->pOut->iNalIndex;
3179 WelsLoadNal (pCtx->pOut, NAL_UNIT_SPS, NRI_PRI_HIGHEST);2920 WelsLoadNal (pCtx->pOut, NAL_UNIT_SPS, NRI_PRI_HIGHEST);
3180 2921
3181 WelsWriteSpsNal (&pCtx->pSpsArray[kiSpsIdx], &pCtx->pOut->sBsWrite,2922 WelsWriteSpsNal (&pCtx->pSpsArray[kiSpsIdx], &pCtx->pOut->sBsWrite,
3182 & (pCtx->sPSOVector.sParaSetOffsetVariable[PARA_SET_TYPE_AVCSPS].iParaSetIdDelta[0]));2923 pCtx->pFuncList->pParametersetStrategy->GetSpsIdOffsetList (PARA_SET_TYPE_AVCSPS));
3183 WelsUnloadNal (pCtx->pOut);2924 WelsUnloadNal (pCtx->pOut);
3184 2925
3185 int32_t iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[iNal], NULL,2926 int32_t iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[iNal], NULL,
@@ -3197,8 +2938,9 @@ int32_t WelsWriteOnePPS (sWelsEncCtx* pCtx, const int32_t kiPpsIdx, int32_t& iNa · 11 unmodified lines
3197 int32_t iNal = pCtx->pOut->iNalIndex;2938 int32_t iNal = pCtx->pOut->iNalIndex;
3198 /* generate picture parameter set */2939 /* generate picture parameter set */
3199 WelsLoadNal (pCtx->pOut, NAL_UNIT_PPS, NRI_PRI_HIGHEST);2940 WelsLoadNal (pCtx->pOut, NAL_UNIT_PPS, NRI_PRI_HIGHEST);
2941
3200 WelsWritePpsSyntax (&pCtx->pPPSArray[kiPpsIdx], &pCtx->pOut->sBsWrite,2942 WelsWritePpsSyntax (&pCtx->pPPSArray[kiPpsIdx], &pCtx->pOut->sBsWrite,
3201 ((SPS_PPS_LISTING != pCtx->pSvcParam->eSpsPpsIdStrategy)) ? (& (pCtx->sPSOVector)) : NULL);2943 pCtx->pFuncList->pParametersetStrategy);
3202 WelsUnloadNal (pCtx->pOut);2944 WelsUnloadNal (pCtx->pOut);
3203 2945
3204 int32_t iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[iNal], NULL,2946 int32_t iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[iNal], NULL,
@@ -3211,43 +2953,6 @@ int32_t WelsWriteOnePPS (sWelsEncCtx* pCtx, const int32_t kiPpsIdx, int32_t& iNa · 6 unmodified lines
3211 return ENC_RETURN_SUCCESS;2953 return ENC_RETURN_SUCCESS;
3212}2954}
3213 2955
3214void UpdatePpsList (sWelsEncCtx* pCtx) {
3215 assert (pCtx->iPpsNum <= MAX_DQ_LAYER_NUM);
3216
3217 //Generate PPS LIST
3218 int32_t iPpsId = 0, iUsePpsNum = pCtx->iPpsNum;
3219
3220 for (int32_t iIdrRound = 0; iIdrRound < MAX_PPS_COUNT; iIdrRound++) {
3221 for (iPpsId = 0; iPpsId < pCtx->iPpsNum; iPpsId++) {
3222 pCtx->sPSOVector.iPpsIdList[iPpsId][iIdrRound] = ((iIdrRound * iUsePpsNum + iPpsId) % MAX_PPS_COUNT);
3223 }
3224 }
3225
3226 for (iPpsId = iUsePpsNum; iPpsId < MAX_PPS_COUNT; iPpsId++) {
3227 memcpy (& (pCtx->pPPSArray[iPpsId]), & (pCtx->pPPSArray[iPpsId % iUsePpsNum]), sizeof (SWelsPPS));
3228 pCtx->pPPSArray[iPpsId].iPpsId = iPpsId;
3229 pCtx->iPpsNum++;
3230 }
3231
3232 assert (pCtx->iPpsNum == MAX_PPS_COUNT);
3233 pCtx->sPSOVector.uiInUsePpsNum = pCtx->iPpsNum;
3234
3235}
3236
3237void UpdateSpsPpsIdStrategyWithIncreasingId (SParaSetOffset* pPSOVector, const uint32_t kuiId, const int iParasetType) {
3238#if _DEBUG
3239 pPSOVector->eSpsPpsIdStrategy = INCREASING_ID;
3240 assert (kuiId < MAX_DQ_LAYER_NUM);
3241#endif
3242
3243 ParasetIdAdditionIdAdjust (& (pPSOVector->sParaSetOffsetVariable[iParasetType]),
3244 kuiId,
3245 (iParasetType != PARA_SET_TYPE_PPS) ? MAX_SPS_COUNT : MAX_PPS_COUNT);
3246}
3247
3248void UpdateSpsPpsIdStrategyWithConstantId (SParaSetOffset* pPSOVector, const uint32_t kuiId, const int iParasetType) {
3249 memset (pPSOVector, 0, sizeof (SParaSetOffset));
3250}
3251 2956
3252/*!2957/*!
3253 * \brief write all parameter sets introduced in SVC extension2958 * \brief write all parameter sets introduced in SVC extension
@@ -3262,22 +2967,16 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN · 8 unmodified lines
3262 int32_t iNalLength = 0;2967 int32_t iNalLength = 0;
3263 int32_t iReturn = ENC_RETURN_SUCCESS;2968 int32_t iReturn = ENC_RETURN_SUCCESS;
3264 2969
3265 if (NULL == pCtx || NULL == pNalLen || NULL == pNumNal)2970 if (NULL == pCtx || NULL == pNalLen || NULL == pNumNal || NULL == pCtx->pFuncList->pParametersetStrategy)
3266 return ENC_RETURN_UNEXPECTED;2971 return ENC_RETURN_UNEXPECTED;
3267 2972
3268 *pTotalLength = 0;2973 *pTotalLength = 0;
3269 /* write all SPS */2974 /* write all SPS */
3270 iIdx = 0;2975 iIdx = 0;
3271 while (iIdx < pCtx->iSpsNum) {2976 while (iIdx < pCtx->iSpsNum) {
3272 // TODO (Sijia) wrap different operation of eSpsPpsIdStrategy to classes to hide the details2977 pCtx->pFuncList->pParametersetStrategy->Update (pCtx->pSpsArray[iIdx].uiSpsId, PARA_SET_TYPE_AVCSPS);
3273 if (INCREASING_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) {
3274 UpdateSpsPpsIdStrategyWithIncreasingId (& (pCtx->sPSOVector), pCtx->pSpsArray[0].uiSpsId, PARA_SET_TYPE_AVCSPS);
3275 } else if (CONSTANT_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) {
3276 UpdateSpsPpsIdStrategyWithConstantId (& (pCtx->sPSOVector), pCtx->pSpsArray[0].uiSpsId, PARA_SET_TYPE_AVCSPS);
3277 }
3278
3279 /* generate sequence parameters set */2978 /* generate sequence parameters set */
3280 iId = (SPS_LISTING & pCtx->pSvcParam->eSpsPpsIdStrategy) ? iIdx : 0;2979 iId = pCtx->pFuncList->pParametersetStrategy->GetSpsIdx (iIdx);
3281 2980
3282 WelsWriteOneSPS (pCtx, iId, iNalLength);2981 WelsWriteOneSPS (pCtx, iId, iNalLength);
3283 2982
@@ -3293,11 +2992,7 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN · 9 unmodified lines
3293 while (iIdx < pCtx->iSubsetSpsNum) {2992 while (iIdx < pCtx->iSubsetSpsNum) {
3294 iNal = pCtx->pOut->iNalIndex;2993 iNal = pCtx->pOut->iNalIndex;
3295 2994
3296 if (INCREASING_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) {2995 pCtx->pFuncList->pParametersetStrategy->Update (pCtx->pSubsetArray[iIdx].pSps.uiSpsId, PARA_SET_TYPE_SUBSETSPS);
3297 UpdateSpsPpsIdStrategyWithIncreasingId (& (pCtx->sPSOVector), pCtx->pSubsetArray[iIdx].pSps.uiSpsId,
3298 PARA_SET_TYPE_SUBSETSPS);
3299 }
3300
3301 2996
3302 iId = iIdx;2997 iId = iIdx;
3303 2998
@@ -3305,7 +3000,7 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN · 1 unmodified line
3305 WelsLoadNal (pCtx->pOut, NAL_UNIT_SUBSET_SPS, NRI_PRI_HIGHEST);3000 WelsLoadNal (pCtx->pOut, NAL_UNIT_SUBSET_SPS, NRI_PRI_HIGHEST);
3306 3001
3307 WelsWriteSubsetSpsSyntax (&pCtx->pSubsetArray[iId], &pCtx->pOut->sBsWrite,3002 WelsWriteSubsetSpsSyntax (&pCtx->pSubsetArray[iId], &pCtx->pOut->sBsWrite,
3308 & (pCtx->sPSOVector.sParaSetOffsetVariable[PARA_SET_TYPE_SUBSETSPS].iParaSetIdDelta[0]));3003 pCtx->pFuncList->pParametersetStrategy->GetSpsIdOffsetList (PARA_SET_TYPE_SUBSETSPS));
3309 WelsUnloadNal (pCtx->pOut);3004 WelsUnloadNal (pCtx->pOut);
3310 3005
3311 iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[iNal], NULL,3006 iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[iNal], NULL,
@@ -3322,16 +3017,11 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN · 10 unmodified lines
3322 ++ iCountNal;3017 ++ iCountNal;
3323 }3018 }
3324 3019
3325 /* write all PPS */3020 pCtx->pFuncList->pParametersetStrategy->UpdatePpsList (pCtx);
3326 if ((SPS_PPS_LISTING == pCtx->pSvcParam->eSpsPpsIdStrategy) && (pCtx->iPpsNum < MAX_PPS_COUNT)) {
3327 UpdatePpsList (pCtx);
3328 }
3329 3021
3330 iIdx = 0;3022 iIdx = 0;
3331 while (iIdx < pCtx->iPpsNum) {3023 while (iIdx < pCtx->iPpsNum) {
3332 if ((INCREASING_ID & pCtx->pSvcParam->eSpsPpsIdStrategy)) {3024 pCtx->pFuncList->pParametersetStrategy->Update (pCtx->pPPSArray[iIdx].iPpsId, PARA_SET_TYPE_PPS);
3333 UpdateSpsPpsIdStrategyWithIncreasingId (& (pCtx->sPSOVector), pCtx->pPPSArray[iIdx].iPpsId, PARA_SET_TYPE_PPS);
3334 }
3335 3025
3336 WelsWriteOnePPS (pCtx, iIdx, iNalLength);3026 WelsWriteOnePPS (pCtx, iIdx, iNalLength);
3337 3027
@@ -3545,10 +3235,9 @@ int32_t WriteSavcParaset (sWelsEncCtx* pCtx, const int32_t iIdx, · 207 unmodified lines
3545 int32_t iNalSize = 0;3235 int32_t iNalSize = 0;
3546 iCountNal = 0;3236 iCountNal = 0;
3547 3237
3548 if (INCREASING_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) {3238
3549 UpdateSpsPpsIdStrategyWithIncreasingId (& (pCtx->sPSOVector), pCtx->pSpsArray[iIdx].uiSpsId, PARA_SET_TYPE_AVCSPS);3239 if (pCtx->pFuncList->pParametersetStrategy) {
3550 } else if (CONSTANT_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) {3240 pCtx->pFuncList->pParametersetStrategy->Update (pCtx->pSpsArray[iIdx].uiSpsId, PARA_SET_TYPE_AVCSPS);
3551 UpdateSpsPpsIdStrategyWithConstantId (& (pCtx->sPSOVector), pCtx->pSpsArray[iIdx].uiSpsId, PARA_SET_TYPE_AVCSPS);
3552 }3241 }
3553 3242
3554 iReturn = WelsWriteOneSPS (pCtx, iIdx, iNalSize);3243 iReturn = WelsWriteOneSPS (pCtx, iIdx, iNalSize);
@@ -3582,10 +3271,8 @@ int32_t WriteSavcParaset (sWelsEncCtx* pCtx, const int32_t iIdx, · 27 unmodified lines
3582 iNalSize = 0;3271 iNalSize = 0;
3583 iCountNal = 0;3272 iCountNal = 0;
3584 3273
3585 if (INCREASING_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) {3274 if (pCtx->pFuncList->pParametersetStrategy) {
3586 UpdateSpsPpsIdStrategyWithIncreasingId (& (pCtx->sPSOVector), pCtx->pPPSArray[iIdx].iPpsId, PARA_SET_TYPE_PPS);3275 pCtx->pFuncList->pParametersetStrategy->Update (pCtx->pPPSArray[iIdx].iPpsId, PARA_SET_TYPE_PPS);
3587 } else if (CONSTANT_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) {
3588 UpdateSpsPpsIdStrategyWithConstantId (& (pCtx->sPSOVector), pCtx->pPPSArray[iIdx].iPpsId, PARA_SET_TYPE_PPS);
3589 }3276 }
3590 3277
3591 iReturn = WelsWriteOnePPS (pCtx, iIdx, iNalSize);3278 iReturn = WelsWriteOnePPS (pCtx, iIdx, iNalSize);
@@ -3659,9 +3346,7 @@ int32_t WriteSavcParaset_Listing (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, · 67 unmodified lines
3659 }3346 }
3660 3347
3661 // write PPS3348 // write PPS
3662 if ((SPS_PPS_LISTING == pCtx->pSvcParam->eSpsPpsIdStrategy) && (pCtx->iPpsNum < MAX_PPS_COUNT)) {3349 pCtx->pFuncList->pParametersetStrategy->UpdatePpsList (pCtx);
3663 UpdatePpsList (pCtx);
3664 }
3665 3350
3666 //TODO: under new strategy, will PPS be correctly updated?3351 //TODO: under new strategy, will PPS be correctly updated?
3667 for (int32_t iSpatialId = 0; iSpatialId < kiSpatialNum; iSpatialId++) {3352 for (int32_t iSpatialId = 0; iSpatialId < kiSpatialNum; iSpatialId++) {
@@ -4652,46 +4337,16 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 984 unmodified lines
4652 SExistingParasetList sExistingParasetList;4337 SExistingParasetList sExistingParasetList;
4653 SExistingParasetList* pExistingParasetList = NULL;4338 SExistingParasetList* pExistingParasetList = NULL;
4654 4339
4655 if ((CONSTANT_ID != iOldSpsPpsIdStrategy) && (CONSTANT_ID != pNewParam->eSpsPpsIdStrategy)) {4340 if (((CONSTANT_ID != iOldSpsPpsIdStrategy) && (CONSTANT_ID != pNewParam->eSpsPpsIdStrategy))) {
4656 for (int32_t k = 0; k < PARA_SET_TYPE; k++) {4341 (*ppCtx)->pFuncList->pParametersetStrategy->OutputCurrentStructure (sTmpPsoVariable, iTmpPpsIdList, (*ppCtx),
4657 memset (((*ppCtx)->sPSOVector.sParaSetOffsetVariable[k].bUsedParaSetIdInBs), 0, MAX_PPS_COUNT * sizeof (bool));4342 &sExistingParasetList);
4658 }
4659 memcpy (sTmpPsoVariable, (*ppCtx)->sPSOVector.sParaSetOffsetVariable,
4660 (PARA_SET_TYPE)*sizeof (SParaSetOffsetVariable)); // confirmed_safe_unsafe_usage
4661 4343
4662 if ((SPS_LISTING & iOldSpsPpsIdStrategy)4344 if ((SPS_LISTING & iOldSpsPpsIdStrategy)
4663 && (SPS_LISTING & pNewParam->eSpsPpsIdStrategy)) {4345 && (SPS_LISTING & pNewParam->eSpsPpsIdStrategy)) {
4664 pExistingParasetList = &sExistingParasetList;4346 pExistingParasetList = &sExistingParasetList;
4665 sExistingParasetList.uiInUseSpsNum = (*ppCtx)->sPSOVector.uiInUseSpsNum;
4666 memcpy (sExistingParasetList.sSps, (*ppCtx)->pSpsArray, MAX_SPS_COUNT * sizeof (SWelsSPS));
4667 if (NULL != (*ppCtx)->pSubsetArray) {
4668 sExistingParasetList.uiInUseSubsetSpsNum = (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum;
4669 memcpy (sExistingParasetList.sSubsetSps, (*ppCtx)->pSubsetArray, MAX_SPS_COUNT * sizeof (SSubsetSps));
4670 } else {
4671 sExistingParasetList.uiInUseSubsetSpsNum = 0;
4672 }
4673 }
4674
4675 if ((SPS_PPS_LISTING == iOldSpsPpsIdStrategy)
4676 && (SPS_PPS_LISTING == pNewParam->eSpsPpsIdStrategy)) {
4677 pExistingParasetList = &sExistingParasetList;
4678 sExistingParasetList.uiInUseSpsNum = (*ppCtx)->sPSOVector.uiInUseSpsNum;
4679 sExistingParasetList.uiInUsePpsNum = (*ppCtx)->sPSOVector.uiInUsePpsNum;
4680 memcpy (sExistingParasetList.sSps, (*ppCtx)->pSpsArray, MAX_SPS_COUNT * sizeof (SWelsSPS));
4681 memcpy (sExistingParasetList.sPps, (*ppCtx)->pPps, MAX_PPS_COUNT * sizeof (SWelsPPS));
4682
4683 if (NULL != (*ppCtx)->pSubsetArray) {
4684 sExistingParasetList.uiInUseSubsetSpsNum = (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum;
4685 memcpy (sExistingParasetList.sSubsetSps, (*ppCtx)->pSubsetArray, MAX_SPS_COUNT * sizeof (SSubsetSps));
4686 } else {
4687 sExistingParasetList.uiInUseSubsetSpsNum = 0;
4688 }
4689
4690 memcpy (iTmpPpsIdList, ((*ppCtx)->sPSOVector.iPpsIdList), MAX_DQ_LAYER_NUM * MAX_PPS_COUNT * sizeof (int32_t));
4691 }4347 }
4692 }4348 }
4693 4349
4694
4695 WelsUninitEncoderExt (ppCtx);4350 WelsUninitEncoderExt (ppCtx);
4696 4351
4697 /* Update new parameters */4352 /* Update new parameters */
@@ -4704,14 +4359,10 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 6 unmodified lines
4704 //for sEncoderStatistics4359 //for sEncoderStatistics
4705 memcpy ((*ppCtx)->sEncoderStatistics, sTempEncoderStatistics, sizeof (sTempEncoderStatistics));4360 memcpy ((*ppCtx)->sEncoderStatistics, sTempEncoderStatistics, sizeof (sTempEncoderStatistics));
4706 //load back the needed structure for eSpsPpsIdStrategy4361 //load back the needed structure for eSpsPpsIdStrategy
4707 if ((CONSTANT_ID != iOldSpsPpsIdStrategy) && (CONSTANT_ID != pNewParam->eSpsPpsIdStrategy)) {4362 if (((CONSTANT_ID != iOldSpsPpsIdStrategy) && (CONSTANT_ID != pNewParam->eSpsPpsIdStrategy))
4708 memcpy ((*ppCtx)->sPSOVector.sParaSetOffsetVariable, sTmpPsoVariable,4363 || ((SPS_PPS_LISTING == iOldSpsPpsIdStrategy)
4709 (PARA_SET_TYPE)*sizeof (SParaSetOffsetVariable)); // confirmed_safe_unsafe_usage4364 && (SPS_PPS_LISTING == pNewParam->eSpsPpsIdStrategy))) {
4710 }4365 (*ppCtx)->pFuncList->pParametersetStrategy->LoadPreviousStructure (sTmpPsoVariable, iTmpPpsIdList);
4711
4712 if ((SPS_PPS_LISTING == iOldSpsPpsIdStrategy)
4713 && (SPS_PPS_LISTING == pNewParam->eSpsPpsIdStrategy)) {
4714 memcpy (((*ppCtx)->sPSOVector.iPpsIdList), iTmpPpsIdList, MAX_DQ_LAYER_NUM * MAX_PPS_COUNT * sizeof (int32_t));
4715 }4366 }
4716 } else {4367 } else {
4717 /* maybe adjustment introduced in bitrate or little settings adjustment and so on.. */4368 /* maybe adjustment introduced in bitrate or little settings adjustment and so on.. */

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