/*! * \brief check if the current parameter can found a presenting sps * \param pParam the current encoding paramter in SWelsSvcCodingParam * \param kbUseSubsetSps bool * \param iDlayerIndex int, the index of current D layer * \param iDlayerCount int, the number of total D layer * \param pSpsArray array of all the stored SPSs * \param pSubsetArray array of all the stored Subset-SPSs * \return 0 - successful * -1 - cannot find existing SPS for current encoder parameter */ int32_t FindExistingSps (SWelsSvcCodingParam* pParam, const bool kbUseSubsetSps, const int32_t iDlayerIndex, const int32_t iDlayerCount, const int32_t iSpsNumInUse, SWelsSPS* pSpsArray, SSubsetSps* pSubsetArray, bool bSVCBaseLayer) { SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; assert (iSpsNumInUse <= MAX_SPS_COUNT); if (!kbUseSubsetSps) { SWelsSPS sTmpSps; WelsInitSps (&sTmpSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, pParam->iMaxNumRefFrame, 0, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE, iDlayerCount, bSVCBaseLayer); for (int32_t iId = 0; iId < iSpsNumInUse; iId++) { if (CheckMatchedSps (&sTmpSps, &pSpsArray[iId])) { return iId; } } } else { SSubsetSps sTmpSubsetSps; WelsInitSubsetSps (&sTmpSubsetSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, pParam->iMaxNumRefFrame, 0, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE, iDlayerCount); for (int32_t iId = 0; iId < iSpsNumInUse; iId++) { if (CheckMatchedSubsetSps (&sTmpSubsetSps, &pSubsetArray[iId])) { return iId; } } } return INVALID_ID; }
static int32_t WelsGenerateNewSps (sWelsEncCtx* pCtx, const bool kbUseSubsetSps, const int32_t iDlayerIndex, const int32_t iDlayerCount, const int32_t kiSpsId, SWelsSPS*& pSps, SSubsetSps*& pSubsetSps, bool bSVCBaselayer) { 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, bSVCBaselayer); } else { iRet = WelsInitSubsetSps (pSubsetSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, pParam->iMaxNumRefFrame, kiSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE, iDlayerCount); } return iRet; }
int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SDLayerParam* pLayerParam, const uint32_t kuiIntraPeriod, const int32_t kiNumRefFrame, const uint32_t kuiSpsId, const bool kbEnableFrameCropping, bool bEnableRc) { SWelsSPS* pSps = &pSubsetSps->pSps; memset (pSubsetSps, 0, sizeof (SSubsetSps)); WelsInitSps (pSps, pLayerParam, kuiIntraPeriod, kiNumRefFrame, kuiSpsId, kbEnableFrameCropping, bEnableRc); pSps->uiProfileIdc = (pLayerParam->uiProfileIdc >= PRO_SCALABLE_BASELINE) ? pLayerParam->uiProfileIdc : PRO_SCALABLE_BASELINE; pSubsetSps->sSpsSvcExt.iExtendedSpatialScalability = 0; /* ESS is 0 in default */ pSubsetSps->sSpsSvcExt.bAdaptiveTcoeffLevelPredFlag = false; pSubsetSps->sSpsSvcExt.bSeqTcoeffLevelPredFlag = false; pSubsetSps->sSpsSvcExt.bSliceHeaderRestrictionFlag = true; return 0; }