MCPcopy Create free account
hub / github.com/cisco/openh264 / WelsEncoderParamAdjust

Function WelsEncoderParamAdjust

codec/encoder/core/src/encoder_ext.cpp:4173–4468  ·  view source on GitHub ↗

! * \brief Wels SVC encoder parameters adjustment * SVC adjustment results in new requirement in memory blocks adjustment */

Source from the content-addressed store, hash-verified

4171 * SVC adjustment results in new requirement in memory blocks adjustment
4172 */
4173int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewParam) {
4174 SWelsSvcCodingParam* pOldParam = NULL;
4175 int32_t iReturn = ENC_RETURN_SUCCESS;
4176 int8_t iIndexD = 0;
4177 bool bNeedReset = false;
4178 int16_t iSliceNum = 1; // number of slices used
4179 int32_t iCacheLineSize = 16; // on chip cache line size in byte
4180 uint32_t uiCpuFeatureFlags = 0;
4181
4182 if (NULL == ppCtx || NULL == *ppCtx || NULL == pNewParam) return 1;
4183
4184 /* Check validation in new parameters */
4185 iReturn = ParamValidationExt (& (*ppCtx)->sLogCtx, pNewParam);
4186 if (iReturn != ENC_RETURN_SUCCESS) return iReturn;
4187
4188 iReturn = GetMultipleThreadIdc (& (*ppCtx)->sLogCtx, pNewParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags);
4189 if (iReturn != ENC_RETURN_SUCCESS) {
4190 WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR, "WelsEncoderParamAdjust(), GetMultipleThreadIdc failed return %d.",
4191 iReturn);
4192 return iReturn;
4193 }
4194
4195 pOldParam = (*ppCtx)->pSvcParam;
4196
4197 if (pOldParam->iUsageType != pNewParam->iUsageType) {
4198 WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR,
4199 "WelsEncoderParamAdjust(), does not expect in-middle change of iUsgaeType from %d to %d", pOldParam->iUsageType,
4200 pNewParam->iUsageType);
4201 return ENC_RETURN_UNSUPPORTED_PARA;
4202 }
4203
4204 /* Decide whether need reset for IDR frame based on adjusting prarameters changed */
4205 /* Temporal levels, spatial settings and/ or quality settings changed need update parameter sets related. */
4206 bNeedReset = (pOldParam == NULL) ||
4207 (pOldParam->bSimulcastAVC != pNewParam->bSimulcastAVC) ||
4208 (pOldParam->iSpatialLayerNum != pNewParam->iSpatialLayerNum) ||
4209 (pOldParam->iPicWidth != pNewParam->iPicWidth
4210 || pOldParam->iPicHeight != pNewParam->iPicHeight) ||
4211 (pOldParam->SUsedPicRect.iWidth != pNewParam->SUsedPicRect.iWidth
4212 || pOldParam->SUsedPicRect.iHeight != pNewParam->SUsedPicRect.iHeight) ||
4213 (pOldParam->bEnableLongTermReference != pNewParam->bEnableLongTermReference) ||
4214 (pOldParam->iLTRRefNum != pNewParam->iLTRRefNum) ||
4215 (pOldParam->iMultipleThreadIdc != pNewParam->iMultipleThreadIdc) ||
4216 (pOldParam->bEnableBackgroundDetection != pNewParam->bEnableBackgroundDetection) ||
4217 (pOldParam->bEnableAdaptiveQuant != pNewParam->bEnableAdaptiveQuant) ||
4218 (pOldParam->eSpsPpsIdStrategy != pNewParam->eSpsPpsIdStrategy);
4219 if ((pNewParam->iMaxNumRefFrame > pOldParam->iMaxNumRefFrame) ||
4220 ((pOldParam->iMaxNumRefFrame == 1) && (pOldParam->iTemporalLayerNum == 1) && (pNewParam->iTemporalLayerNum == 2))) {
4221 bNeedReset = true;
4222 }
4223 if (bNeedReset) {
4224 WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO,
4225 "WelsEncoderParamAdjust(),bSimulcastAVC(%d,%d),iSpatialLayerNum(%d,%d),iPicWidth(%d,%d),iPicHeight(%d,%d),Rect.iWidth(%d,%d),Rect.iHeight(%d,%d)",
4226 pOldParam->bSimulcastAVC, pNewParam->bSimulcastAVC,
4227 pOldParam->iSpatialLayerNum, pNewParam->iSpatialLayerNum,
4228 pOldParam->iPicWidth, pNewParam->iPicWidth,
4229 pOldParam->iPicHeight, pNewParam->iPicHeight,
4230 pOldParam->SUsedPicRect.iWidth, pNewParam->SUsedPicRect.iWidth,

Callers 2

SetOptionMethod · 0.85
WelsEncoderApplyLTRFunction · 0.85

Calls 7

ParamValidationExtFunction · 0.85
GetMultipleThreadIdcFunction · 0.85
WelsLogFunction · 0.85
WelsUninitEncoderExtFunction · 0.85
WelsInitEncoderExtFunction · 0.85
LoadPreviousStructureMethod · 0.80

Tested by

no test coverage detected