[Encoder] refactor Sps generation: passed review at https://rbcommons.com/s/OpenH264/r/930/
Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 3 files). Show all
Unified · Split
| @@ -763,6 +763,35 @@ void FreeMbCache (SMbCache* pMbCache, CMemoryAlign* pMa) { · 762 unmodified lines | |||
| 763 | } | 763 | } |
| 764 | } | 764 | } |
| 765 | 765 | ||
| 766 | int32_t WelsGenerateNewSps (sWelsEncCtx* pCtx, const bool kbUseSubsetSps, const int32_t iDlayerIndex, | ||
| 767 | const int32_t iDlayerCount, const int32_t kiSpsId, | ||
| 768 | SWelsSPS*& pSps, SSubsetSps*& pSubsetSps) { | ||
| 769 | int32_t iRet = 0; | ||
| 770 | |||
| 771 | if (!kbUseSubsetSps) { | ||
| 772 | pSps = & (pCtx->pSpsArray[kiSpsId]); | ||
| 773 | } else { | ||
| 774 | pSubsetSps = & (pCtx->pSubsetArray[kiSpsId]); | ||
| 775 | pSps = &pSubsetSps->pSps; | ||
| 776 | } | ||
| 777 | |||
| 778 | SWelsSvcCodingParam* pParam = pCtx->pSvcParam; | ||
| 779 | SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; | ||
| 780 | // Need port pSps/pPps initialization due to spatial scalability changed | ||
| 781 | if (!kbUseSubsetSps) { | ||
| 782 | iRet = WelsInitSps (pSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, | ||
| 783 | pParam->iMaxNumRefFrame, | ||
| 784 | kiSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE, iDlayerCount); | ||
| 785 | |||
| 786 | |||
| 787 | |||
| 788 | } else { | ||
| 789 | iRet = WelsInitSubsetSps (pSubsetSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, | ||
| 790 | pParam->iMaxNumRefFrame, | ||
| 791 | kiSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE); | ||
| 792 | } | ||
| 793 | return iRet; | ||
| 794 | } | ||
| 766 | 795 | ||
| 767 | /*! | 796 | /*! |
| 768 | * \brief initialize ppDqLayerList and slicepEncCtx_list due to count number of layers available | 797 | * \brief initialize ppDqLayerList and slicepEncCtx_list due to count number of layers available |
| @@ -952,35 +981,11 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 183 unmodified lines | |||
| 952 | SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; | 981 | SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; |
| 953 | 982 | ||
| 954 | pDqIdc->uiSpatialId = iDlayerIndex; | 983 | pDqIdc->uiSpatialId = iDlayerIndex; |
| 955 | pPps = & (*ppCtx)->pPPSArray[iPpsId]; | ||
| 956 | if (!bUseSubsetSps) { | ||
| 957 | pSps = & (*ppCtx)->pSpsArray[iSpsId]; | ||
| 958 | } else { | ||
| 959 | pSubsetSps = & (*ppCtx)->pSubsetArray[iSpsId]; | ||
| 960 | pSps = &pSubsetSps->pSps; | ||
| 961 | } | ||
| 962 | 984 | ||
| 963 | // Need port pSps/pPps initialization due to spatial scalability changed | 985 | WelsGenerateNewSps (*ppCtx, bUseSubsetSps, iDlayerIndex, |
| 964 | if (!bUseSubsetSps) { | 986 | iDlayerCount, iSpsId, pSps, pSubsetSps); |
| 965 | WelsInitSps (pSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, | ||
| 966 | pParam->iMaxNumRefFrame, | ||
| 967 | iSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE); | ||
| 968 | |||
| 969 | if (pDlayerParam->uiProfileIdc == PRO_BASELINE) { | ||
| 970 | pSps->bConstraintSet0Flag = true; | ||
| 971 | } | ||
| 972 | if (pDlayerParam->uiProfileIdc <= PRO_MAIN) { | ||
| 973 | pSps->bConstraintSet1Flag = true; | ||
| 974 | } | ||
| 975 | if (iDlayerCount > 1) { | ||
| 976 | pSps->bConstraintSet2Flag = true; | ||
| 977 | } | ||
| 978 | } else { | ||
| 979 | WelsInitSubsetSps (pSubsetSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, | ||
| 980 | pParam->iMaxNumRefFrame, | ||
| 981 | iSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE); | ||
| 982 | } | ||
| 983 | 987 | ||
| 988 | pPps = & (*ppCtx)->pPPSArray[iPpsId]; | ||
| 984 | // initialize pPps | 989 | // initialize pPps |
| 985 | WelsInitPps (pPps, pSps, pSubsetSps, iPpsId, true, bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0); | 990 | WelsInitPps (pPps, pSps, pSubsetSps, iPpsId, true, bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0); |
| 986 | 991 | ||