ref: cdd410ca66831751b6d23d7759c53c2b3e6e7fd3
parent: 24fb213d6e4e41e50af5955ab30275b1abddda8f
author: Sijia Chen <sijchen@cisco.com>
date: Thu Nov 20 07:55:48 EST 2014
refactor Sps generation
--- a/codec/encoder/core/inc/au_set.h
+++ b/codec/encoder/core/inc/au_set.h
@@ -106,7 +106,8 @@
*/
int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialLayerInternal* pLayerParamInternal,
const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
- const uint32_t kiSpsId, const bool kbEnableFrameCropping, bool bEnableRc);
+ const uint32_t kiSpsId, const bool kbEnableFrameCropping, bool bEnableRc,
+ const int32_t kiDlayerCount);
/*!
* \brief initialize subset pSps based on configurable parameters in svc
--- a/codec/encoder/core/src/au_set.cpp
+++ b/codec/encoder/core/src/au_set.cpp
@@ -347,7 +347,8 @@
}
int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialLayerInternal* pLayerParamInternal,
const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame,
- const uint32_t kuiSpsId, const bool kbEnableFrameCropping, bool bEnableRc) {
+ const uint32_t kuiSpsId, const bool kbEnableFrameCropping, bool bEnableRc,
+ const int32_t kiDlayerCount) {
memset (pSps, 0, sizeof (SWelsSPS));
pSps->uiSpsId = kuiSpsId;
@@ -383,6 +384,16 @@
pSps->iLevelIdc = 11;
pSps->bConstraintSet3Flag = true;
}
+
+ if (pLayerParam->uiProfileIdc == PRO_BASELINE) {
+ pSps->bConstraintSet0Flag = true;
+ }
+ if (pLayerParam->uiProfileIdc <= PRO_MAIN) {
+ pSps->bConstraintSet1Flag = true;
+ }
+ if (kiDlayerCount > 1) {
+ pSps->bConstraintSet2Flag = true;
+ }
return 0;
}
@@ -396,7 +407,7 @@
memset (pSubsetSps, 0, sizeof (SSubsetSps));
WelsInitSps (pSps, pLayerParam, pLayerParamInternal, kuiIntraPeriod, kiNumRefFrame, kuiSpsId, kbEnableFrameCropping,
- bEnableRc);
+ bEnableRc, 1);
pSps->uiProfileIdc = (pLayerParam->uiProfileIdc >= PRO_SCALABLE_BASELINE) ? pLayerParam->uiProfileIdc :
PRO_SCALABLE_BASELINE;
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -761,7 +761,36 @@
}
}
+int32_t WelsGenerateNewSps (sWelsEncCtx* pCtx, const bool kbUseSubsetSps, const int32_t iDlayerIndex,
+ const int32_t iDlayerCount, const int32_t kiSpsId,
+ SWelsSPS*& pSps, SSubsetSps*& pSubsetSps) {
+ int32_t iRet = 0;
+ if (!kbUseSubsetSps) {
+ pSps = & (pCtx->pSpsArray[kiSpsId]);
+ } else {
+ pSubsetSps = & (pCtx->pSubsetArray[kiSpsId]);
+ pSps = &pSubsetSps->pSps;
+ }
+
+ SWelsSvcCodingParam* pParam = pCtx->pSvcParam;
+ SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex];
+ // Need port pSps/pPps initialization due to spatial scalability changed
+ if (!kbUseSubsetSps) {
+ iRet = WelsInitSps (pSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod,
+ pParam->iMaxNumRefFrame,
+ kiSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE, iDlayerCount);
+
+
+
+ } else {
+ iRet = WelsInitSubsetSps (pSubsetSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod,
+ pParam->iMaxNumRefFrame,
+ kiSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE);
+ }
+ return iRet;
+}
+
/*!
* \brief initialize ppDqLayerList and slicepEncCtx_list due to count number of layers available
* \pParam pCtx sWelsEncCtx*
@@ -950,35 +979,11 @@
SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex];
pDqIdc->uiSpatialId = iDlayerIndex;
- pPps = & (*ppCtx)->pPPSArray[iPpsId];
- if (!bUseSubsetSps) {
- pSps = & (*ppCtx)->pSpsArray[iSpsId];
- } else {
- pSubsetSps = & (*ppCtx)->pSubsetArray[iSpsId];
- pSps = &pSubsetSps->pSps;
- }
- // Need port pSps/pPps initialization due to spatial scalability changed
- if (!bUseSubsetSps) {
- WelsInitSps (pSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod,
- pParam->iMaxNumRefFrame,
- iSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE);
+ WelsGenerateNewSps (*ppCtx, bUseSubsetSps, iDlayerIndex,
+ iDlayerCount, iSpsId, pSps, pSubsetSps);
- if (pDlayerParam->uiProfileIdc == PRO_BASELINE) {
- pSps->bConstraintSet0Flag = true;
- }
- if (pDlayerParam->uiProfileIdc <= PRO_MAIN) {
- pSps->bConstraintSet1Flag = true;
- }
- if (iDlayerCount > 1) {
- pSps->bConstraintSet2Flag = true;
- }
- } else {
- WelsInitSubsetSps (pSubsetSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod,
- pParam->iMaxNumRefFrame,
- iSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE);
- }
-
+ pPps = & (*ppCtx)->pPPSArray[iPpsId];
// initialize pPps
WelsInitPps (pPps, pSps, pSubsetSps, iPpsId, true, bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0);