History

fix for in-middle changing simulcast avc setting

Sijia Chen committed 11 years ago

Commit bc1b28b1 parent 09518da4 files · +100 −70Browse files

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

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+58−56
@@ -141,7 +141,7 @@ void CheckLevelSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32 · 140 unmodified lines
141 SSpatialLayerConfig* pLayerInfo = &pParam->sSpatialLayers[iLayer];141 SSpatialLayerConfig* pLayerInfo = &pParam->sSpatialLayers[iLayer];
142 pLayerInfo->uiLevelIdc = uiLevelIdc;142 pLayerInfo->uiLevelIdc = uiLevelIdc;
143 if (uiLevelIdc > LEVEL_5_2) {143 if (uiLevelIdc > LEVEL_5_2) {
144 WelsLog (pLogCtx, WELS_LOG_INFO, "change unexpected levelidc(%d) setting to LEVEL_UNKNOWN", pLayerInfo->uiLevelIdc );144 WelsLog (pLogCtx, WELS_LOG_INFO, "change unexpected levelidc(%d) setting to LEVEL_UNKNOWN", pLayerInfo->uiLevelIdc);
145 pLayerInfo->uiLevelIdc = LEVEL_UNKNOWN;145 pLayerInfo->uiLevelIdc = LEVEL_UNKNOWN;
146 }146 }
147}147}
@@ -337,12 +337,14 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 189 unmodified lines
337 // eSpsPpsIdStrategy checkings337 // eSpsPpsIdStrategy checkings
338 if (pCodingParam->iSpatialLayerNum > 1 && (SPS_LISTING & pCodingParam->eSpsPpsIdStrategy)) {338 if (pCodingParam->iSpatialLayerNum > 1 && (SPS_LISTING & pCodingParam->eSpsPpsIdStrategy)) {
339 WelsLog (pLogCtx, WELS_LOG_WARNING,339 WelsLog (pLogCtx, WELS_LOG_WARNING,
340 "ParamValidationExt(), eSpsPpsIdStrategy setting (%d) with multiple SpatialLayers (%d) not supported! eSpsPpsIdStrategy adjusted to CONSTANT_ID", pCodingParam->eSpsPpsIdStrategy, pCodingParam->iSpatialLayerNum);340 "ParamValidationExt(), eSpsPpsIdStrategy setting (%d) with multiple SpatialLayers (%d) not supported! eSpsPpsIdStrategy adjusted to CONSTANT_ID",
341 pCodingParam->eSpsPpsIdStrategy, pCodingParam->iSpatialLayerNum);
341 pCodingParam->eSpsPpsIdStrategy = CONSTANT_ID;342 pCodingParam->eSpsPpsIdStrategy = CONSTANT_ID;
342 }343 }
343 if (pCodingParam->iUsageType == SCREEN_CONTENT_REAL_TIME && (SPS_LISTING & pCodingParam->eSpsPpsIdStrategy)) {344 if (pCodingParam->iUsageType == SCREEN_CONTENT_REAL_TIME && (SPS_LISTING & pCodingParam->eSpsPpsIdStrategy)) {
344 WelsLog (pLogCtx, WELS_LOG_WARNING,345 WelsLog (pLogCtx, WELS_LOG_WARNING,
345 "ParamValidationExt(), eSpsPpsIdStrategy setting (%d) with iUsageType (%d) not supported! eSpsPpsIdStrategy adjusted to CONSTANT_ID", pCodingParam->eSpsPpsIdStrategy, pCodingParam->iUsageType);346 "ParamValidationExt(), eSpsPpsIdStrategy setting (%d) with iUsageType (%d) not supported! eSpsPpsIdStrategy adjusted to CONSTANT_ID",
347 pCodingParam->eSpsPpsIdStrategy, pCodingParam->iUsageType);
346 pCodingParam->eSpsPpsIdStrategy = CONSTANT_ID;348 pCodingParam->eSpsPpsIdStrategy = CONSTANT_ID;
347 }349 }
348 350
@@ -502,7 +504,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 153 unmodified lines
502 iMbHeight = (kiPicHeight + 15) >> 4;504 iMbHeight = (kiPicHeight + 15) >> 4;
503 iMaxSliceNum = MAX_SLICES_NUM;505 iMaxSliceNum = MAX_SLICES_NUM;
504 if (iMbHeight > iMaxSliceNum) {506 if (iMbHeight > iMaxSliceNum) {
505 WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings more than MAX(%d)!", iMbHeight, MAX_SLICES_NUM);507 WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings more than MAX(%d)!",
508 iMbHeight, MAX_SLICES_NUM);
506 return ENC_RETURN_UNSUPPORTED_PARA;509 return ENC_RETURN_UNSUPPORTED_PARA;
507 }510 }
508 pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = iMbHeight;511 pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = iMbHeight;
@@ -698,9 +701,9 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 189 unmodified lines
698 // count parasets701 // count parasets
699 iCountNumNals += 1 + iNumDependencyLayers + (iCountNumLayers << 1) +702 iCountNumNals += 1 + iNumDependencyLayers + (iCountNumLayers << 1) +
700 iCountNumLayers // plus iCountNumLayers for reserved application703 iCountNumLayers // plus iCountNumLayers for reserved application
701 + ((SPS_LISTING & pParam->eSpsPpsIdStrategy) ? MAX_SPS_COUNT : 0) //for Sps704 + (*ppCtx)->GetNeededSpsNum()
702 + (((SPS_LISTING & pParam->eSpsPpsIdStrategy) && (iNumDependencyLayers > 1)) ? MAX_SPS_COUNT : 0) //for SubsetSps705 + (*ppCtx)->GetNeededSubsetSpsNum()
703 + ((SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy) ? MAX_PPS_COUNT : 0);706 + (*ppCtx)->GetNeededPpsNum();
704 707
705 // to check number of layers / nals / slices dependencies, 12/8/2010708 // to check number of layers / nals / slices dependencies, 12/8/2010
706 if (iCountNumLayers > MAX_LAYER_NUM_OF_FRAME) {709 if (iCountNumLayers > MAX_LAYER_NUM_OF_FRAME) {
@@ -1026,7 +1029,6 @@ int32_t FindExistingPps (SWelsSPS* pSps, SSubsetSps* pSubsetSps, const bool kbUs · 319 unmodified lines
1026 return INVALID_ID;1029 return INVALID_ID;
1027}1030}
1028 1031
1029
1030/*!1032/*!
1031 * \brief initialize ppDqLayerList and slicepEncCtx_list due to count number of layers available1033 * \brief initialize ppDqLayerList and slicepEncCtx_list due to count number of layers available
1032 * \pParam pCtx sWelsEncCtx*1034 * \pParam pCtx sWelsEncCtx*
@@ -1195,54 +1197,41 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 162 unmodified lines
1195 }1197 }
1196 1198
1197 // for dynamically malloc for parameter sets memory instead of maximal items for standard to reduce size, 3/18/20101199 // for dynamically malloc for parameter sets memory instead of maximal items for standard to reduce size, 3/18/2010
1198 // SPS1200 const int32_t kiNeededSpsNum = (*ppCtx)->GetNeededSpsNum();
1199 if (!pParam->bSimulcastAVC) {1201 const int32_t kiNeededSubsetSpsNum = (*ppCtx)->GetNeededSubsetSpsNum();
1200 if (! (SPS_LISTING & pParam->eSpsPpsIdStrategy)) {1202 (*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMalloc (kiNeededSpsNum * sizeof (SWelsSPS), "pSpsArray");
1201 (*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMalloc (sizeof (SWelsSPS), "pSpsArray");1203 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSpsArray), FreeMemorySvc (ppCtx))
1202 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSpsArray), FreeMemorySvc (ppCtx))1204 if (kiNeededSubsetSpsNum > 0) {
1203 if (iDlayerCount > 1) {1205 (*ppCtx)->pSubsetArray = (SSubsetSps*)pMa->WelsMalloc (kiNeededSubsetSpsNum * sizeof (SSubsetSps), "pSubsetArray");
1204 (*ppCtx)->pSubsetArray = (SSubsetSps*)pMa->WelsMalloc ((iDlayerCount - 1) * sizeof (SSubsetSps), "pSubsetArray");1206 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSubsetArray), FreeMemorySvc (ppCtx))
1205 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSubsetArray), FreeMemorySvc (ppCtx))
1206 }
1207 } else {
1208 // pParam->eSpsPpsIdStrategy == SPS_LISTING_AND_PPS_INCREASING
1209 // new memory
1210 (*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMalloc (MAX_SPS_COUNT * sizeof (SWelsSPS), "pSpsArray");
1211 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSpsArray), FreeMemorySvc (ppCtx))
1212
1213 (*ppCtx)->pSubsetArray = (SSubsetSps*)pMa->WelsMalloc (MAX_SPS_COUNT * sizeof (SSubsetSps), "pSubsetArray");
1214 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSubsetArray), FreeMemorySvc (ppCtx))
1215
1216 // copy from existing if the pointer exists
1217 if (NULL != pExistingParasetList) {
1218 (*ppCtx)->sPSOVector.uiInUseSpsNum = pExistingParasetList->uiInUseSpsNum;
1219 (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum = pExistingParasetList->uiInUseSubsetSpsNum;
1220 memcpy ((*ppCtx)->pSpsArray, pExistingParasetList->sSps, MAX_SPS_COUNT * sizeof (SWelsSPS));
1221 memcpy ((*ppCtx)->pSubsetArray, pExistingParasetList->sSubsetSps, MAX_SPS_COUNT * sizeof (SSubsetSps));
1222 }
1223 }
1224 } else {1207 } else {
1225 //bSimulcastAVC
1226 (*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMalloc (iDlayerCount * sizeof (SWelsSPS), "pSpsArray");
1227 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSpsArray), FreeMemorySvc (ppCtx))
1228 (*ppCtx)->pSubsetArray = NULL;1208 (*ppCtx)->pSubsetArray = NULL;
1229 }1209 }
1230 // PPS
1231 if (! (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy)) {
1232 (*ppCtx)->pPPSArray = (SWelsPPS*)pMa->WelsMalloc (iDlayerCount * sizeof (SWelsPPS), "pPPSArray");
1233 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pPPSArray), FreeMemorySvc (ppCtx))
1234 } else {
1235 (*ppCtx)->pPPSArray = (SWelsPPS*)pMa->WelsMalloc (MAX_PPS_COUNT * sizeof (SWelsPPS), "pPPSArray");
1236 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pPPSArray), FreeMemorySvc (ppCtx))
1237 1210
1211 if ((SPS_LISTING & pParam->eSpsPpsIdStrategy) && (NULL != pExistingParasetList)) {
1212 (*ppCtx)->sPSOVector.uiInUseSpsNum = pExistingParasetList->uiInUseSpsNum;
1213 memcpy ((*ppCtx)->pSpsArray, pExistingParasetList->sSps, MAX_SPS_COUNT * sizeof (SWelsSPS));
1238 1214
1239 // copy from existing if the pointer exists1215 if (kiNeededSubsetSpsNum > 0) {
1240 if (NULL != pExistingParasetList) {1216 (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum = pExistingParasetList->uiInUseSubsetSpsNum;
1241 (*ppCtx)->sPSOVector.uiInUsePpsNum = pExistingParasetList->uiInUsePpsNum;1217 memcpy ((*ppCtx)->pSubsetArray, pExistingParasetList->sSubsetSps, MAX_SPS_COUNT * sizeof (SSubsetSps));
1242 memcpy ((*ppCtx)->pPPSArray, pExistingParasetList->sPps, MAX_PPS_COUNT * sizeof (SWelsPPS));1218 } else {
1219 (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum = 0;
1243 }1220 }
1244 }1221 }
1245 1222
1223 // PPS
1224 const int32_t kiNeededPpsNum = (*ppCtx)->GetNeededPpsNum();
1225 (*ppCtx)->pPPSArray = (SWelsPPS*)pMa->WelsMalloc (kiNeededPpsNum * sizeof (SWelsPPS), "pPPSArray");
1226 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pPPSArray), FreeMemorySvc (ppCtx))
1227
1228 // copy from existing if the pointer exists
1229 if ((SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy) && (NULL != pExistingParasetList)) {
1230 (*ppCtx)->sPSOVector.uiInUsePpsNum = pExistingParasetList->uiInUsePpsNum;
1231 memcpy ((*ppCtx)->pPPSArray, pExistingParasetList->sPps, MAX_PPS_COUNT * sizeof (SWelsPPS));
1232 }
1233
1234
1246 if (INCREASING_ID & pParam->eSpsPpsIdStrategy) {1235 if (INCREASING_ID & pParam->eSpsPpsIdStrategy) {
1247 (*ppCtx)->pPSOVector = & ((*ppCtx)->sPSOVector);1236 (*ppCtx)->pPSOVector = & ((*ppCtx)->sPSOVector);
1248 } else {1237 } else {
@@ -1728,8 +1717,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 479 unmodified lines
1728 return 1;1717 return 1;
1729 }1718 }
1730 1719
1731 const int32_t kiSpsSize = (pParam->eSpsPpsIdStrategy & SPS_LISTING) ? (MAX_SPS_COUNT * SPS_BUFFER_SIZE): (pParam->iSpatialLayerNum * SPS_BUFFER_SIZE);1720 const int32_t kiSpsSize = (*ppCtx)->GetNeededSpsNum() * SPS_BUFFER_SIZE;
1732 const int32_t kiPpsSize = (pParam->eSpsPpsIdStrategy & SPS_PPS_LISTING) ? (MAX_PPS_COUNT * SPS_BUFFER_SIZE) : ((1 + pParam->iSpatialLayerNum) * PPS_BUFFER_SIZE);1721 const int32_t kiPpsSize = (*ppCtx)->GetNeededPpsNum() * PPS_BUFFER_SIZE;
1733 iNonVclLayersBsSizeCount = SSEI_BUFFER_SIZE + kiSpsSize + kiPpsSize;1722 iNonVclLayersBsSizeCount = SSEI_BUFFER_SIZE + kiSpsSize + kiPpsSize;
1734 1723
1735 int32_t iLayerBsSize = 0;1724 int32_t iLayerBsSize = 0;
@@ -3469,7 +3458,8 @@ int32_t WriteSavcParaset (sWelsEncCtx* pCtx, const int32_t kiSpatialNum, · 1733 unmodified lines
3469 3458
3470 // write SPS3459 // write SPS
3471 iNonVclSize = 0;3460 iNonVclSize = 0;
3472 assert (kiSpatialNum == pCtx->iSpsNum);3461
3462 assert ((kiSpatialNum == pCtx->iSpsNum) || (SPS_LISTING & pCtx->pSvcParam->eSpsPpsIdStrategy));
3473 3463
3474 for (int32_t iIdx = 0; iIdx < pCtx->iSpsNum; iIdx++) {3464 for (int32_t iIdx = 0; iIdx < pCtx->iSpsNum; iIdx++) {
3475 //writing one NAL3465 //writing one NAL
@@ -4252,13 +4242,16 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 776 unmodified lines
4252 pOldParam = (*ppCtx)->pSvcParam;4242 pOldParam = (*ppCtx)->pSvcParam;
4253 4243
4254 if (pOldParam->iUsageType != pNewParam->iUsageType) {4244 if (pOldParam->iUsageType != pNewParam->iUsageType) {
4255 WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR, "WelsEncoderParamAdjust(), does not expect in-middle change of iUsgaeType from %d to %d", pOldParam->iUsageType, pNewParam->iUsageType);4245 WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR,
4246 "WelsEncoderParamAdjust(), does not expect in-middle change of iUsgaeType from %d to %d", pOldParam->iUsageType,
4247 pNewParam->iUsageType);
4256 return ENC_RETURN_UNSUPPORTED_PARA;4248 return ENC_RETURN_UNSUPPORTED_PARA;
4257 }4249 }
4258 4250
4259 /* Decide whether need reset for IDR frame based on adjusting prarameters changed */4251 /* Decide whether need reset for IDR frame based on adjusting prarameters changed */
4260 /* Temporal levels, spatial settings and/ or quality settings changed need update parameter sets related. */4252 /* Temporal levels, spatial settings and/ or quality settings changed need update parameter sets related. */
4261 bNeedReset = (pOldParam == NULL) ||4253 bNeedReset = (pOldParam == NULL) ||
4254 (pOldParam->bSimulcastAVC != pNewParam->bSimulcastAVC) ||
4262 (pOldParam->iSpatialLayerNum != pNewParam->iSpatialLayerNum) ||4255 (pOldParam->iSpatialLayerNum != pNewParam->iSpatialLayerNum) ||
4263 (pOldParam->iPicWidth != pNewParam->iPicWidth4256 (pOldParam->iPicWidth != pNewParam->iPicWidth
4264 || pOldParam->iPicHeight != pNewParam->iPicHeight) ||4257 || pOldParam->iPicHeight != pNewParam->iPicHeight) ||
@@ -4339,21 +4332,30 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 74 unmodified lines
4339 && (SPS_LISTING & pNewParam->eSpsPpsIdStrategy)) {4332 && (SPS_LISTING & pNewParam->eSpsPpsIdStrategy)) {
4340 pExistingParasetList = &sExistingParasetList;4333 pExistingParasetList = &sExistingParasetList;
4341 sExistingParasetList.uiInUseSpsNum = (*ppCtx)->sPSOVector.uiInUseSpsNum;4334 sExistingParasetList.uiInUseSpsNum = (*ppCtx)->sPSOVector.uiInUseSpsNum;
4342 sExistingParasetList.uiInUseSubsetSpsNum = (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum;
4343 memcpy (sExistingParasetList.sSps, (*ppCtx)->pSpsArray, MAX_SPS_COUNT * sizeof (SWelsSPS));4335 memcpy (sExistingParasetList.sSps, (*ppCtx)->pSpsArray, MAX_SPS_COUNT * sizeof (SWelsSPS));
4344 memcpy (sExistingParasetList.sSubsetSps, (*ppCtx)->pSubsetArray, MAX_SPS_COUNT * sizeof (SSubsetSps));4336 if (NULL != (*ppCtx)->pSubsetArray) {
4337 sExistingParasetList.uiInUseSubsetSpsNum = (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum;
4338 memcpy (sExistingParasetList.sSubsetSps, (*ppCtx)->pSubsetArray, MAX_SPS_COUNT * sizeof (SSubsetSps));
4339 } else {
4340 sExistingParasetList.uiInUseSubsetSpsNum = 0;
4341 }
4345 }4342 }
4346 4343
4347 if ((SPS_PPS_LISTING == iOldSpsPpsIdStrategy)4344 if ((SPS_PPS_LISTING == iOldSpsPpsIdStrategy)
4348 && (SPS_PPS_LISTING == pNewParam->eSpsPpsIdStrategy)) {4345 && (SPS_PPS_LISTING == pNewParam->eSpsPpsIdStrategy)) {
4349 pExistingParasetList = &sExistingParasetList;4346 pExistingParasetList = &sExistingParasetList;
4350 sExistingParasetList.uiInUseSpsNum = (*ppCtx)->sPSOVector.uiInUseSpsNum;4347 sExistingParasetList.uiInUseSpsNum = (*ppCtx)->sPSOVector.uiInUseSpsNum;
4351 sExistingParasetList.uiInUseSubsetSpsNum = (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum;
4352 sExistingParasetList.uiInUsePpsNum = (*ppCtx)->sPSOVector.uiInUsePpsNum;4348 sExistingParasetList.uiInUsePpsNum = (*ppCtx)->sPSOVector.uiInUsePpsNum;
4353 memcpy (sExistingParasetList.sSps, (*ppCtx)->pSpsArray, MAX_SPS_COUNT * sizeof (SWelsSPS));4349 memcpy (sExistingParasetList.sSps, (*ppCtx)->pSpsArray, MAX_SPS_COUNT * sizeof (SWelsSPS));
4354 memcpy (sExistingParasetList.sSubsetSps, (*ppCtx)->pSubsetArray, MAX_SPS_COUNT * sizeof (SSubsetSps));
4355 memcpy (sExistingParasetList.sPps, (*ppCtx)->pPps, MAX_PPS_COUNT * sizeof (SWelsPPS));4350 memcpy (sExistingParasetList.sPps, (*ppCtx)->pPps, MAX_PPS_COUNT * sizeof (SWelsPPS));
4356 4351
4352 if (NULL != (*ppCtx)->pSubsetArray) {
4353 sExistingParasetList.uiInUseSubsetSpsNum = (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum;
4354 memcpy (sExistingParasetList.sSubsetSps, (*ppCtx)->pSubsetArray, MAX_SPS_COUNT * sizeof (SSubsetSps));
4355 } else {
4356 sExistingParasetList.uiInUseSubsetSpsNum = 0;
4357 }
4358
4357 memcpy (iTmpPpsIdList, ((*ppCtx)->sPSOVector.iPpsIdList), MAX_DQ_LAYER_NUM * MAX_PPS_COUNT * sizeof (int32_t));4359 memcpy (iTmpPpsIdList, ((*ppCtx)->sPSOVector.iPpsIdList), MAX_DQ_LAYER_NUM * MAX_PPS_COUNT * sizeof (int32_t));
4358 }4360 }
4359 }4361 }

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