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

Function WelsBitRateVerification

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

Source from the content-addressed store, hash-verified

71
72
73int32_t WelsBitRateVerification (SLogContext* pLogCtx, SSpatialLayerConfig* pLayerParam, int32_t iLayerId) {
74 if ((pLayerParam->iSpatialBitrate <= 0)
75 || (static_cast<float> (pLayerParam->iSpatialBitrate) < pLayerParam->fFrameRate)) {
76 WelsLog (pLogCtx, WELS_LOG_ERROR, "Invalid bitrate settings in layer %d, bitrate= %d at FrameRate(%f)", iLayerId,
77 pLayerParam->iSpatialBitrate, pLayerParam->fFrameRate);
78 return ENC_RETURN_UNSUPPORTED_PARA;
79 }
80
81 // deal with LEVEL_MAX_BR and MAX_BR setting
82 const SLevelLimits* pCurLevelLimit = g_ksLevelLimits;
83 while ((pCurLevelLimit->uiLevelIdc != LEVEL_5_2) && (pCurLevelLimit->uiLevelIdc != pLayerParam->uiLevelIdc))
84 pCurLevelLimit++;
85 const int32_t iLevelMaxBitrate = pCurLevelLimit->uiMaxBR * CpbBrNalFactor;
86 const int32_t iLevel52MaxBitrate = g_ksLevelLimits[LEVEL_NUMBER - 1].uiMaxBR * CpbBrNalFactor;
87 if (UNSPECIFIED_BIT_RATE != iLevelMaxBitrate) {
88 if ((pLayerParam->iMaxSpatialBitrate == UNSPECIFIED_BIT_RATE)
89 || (pLayerParam->iMaxSpatialBitrate > iLevel52MaxBitrate)) {
90 pLayerParam->iMaxSpatialBitrate = iLevelMaxBitrate;
91 WelsLog (pLogCtx, WELS_LOG_INFO,
92 "Current MaxSpatialBitrate is invalid (UNSPECIFIED_BIT_RATE or larger than LEVEL5_2) but level setting is valid, set iMaxSpatialBitrate to %d from level (%d)",
93 pLayerParam->iMaxSpatialBitrate, pLayerParam->uiLevelIdc);
94 } else if (pLayerParam->iMaxSpatialBitrate > iLevelMaxBitrate) {
95 ELevelIdc iCurLevel = pLayerParam->uiLevelIdc;
96 WelsAdjustLevel (pLayerParam, pCurLevelLimit);
97 WelsLog (pLogCtx, WELS_LOG_INFO,
98 "LevelIdc is changed from (%d) to (%d) according to the iMaxSpatialBitrate(%d)",
99 iCurLevel, pLayerParam->uiLevelIdc, pLayerParam->iMaxSpatialBitrate);
100 }
101 } else if ((pLayerParam->iMaxSpatialBitrate != UNSPECIFIED_BIT_RATE)
102 && (pLayerParam->iMaxSpatialBitrate > iLevel52MaxBitrate)) {
103 // no level limitation, just need to check if iMaxSpatialBitrate is too big from reasonable
104 WelsLog (pLogCtx, WELS_LOG_WARNING,
105 "No LevelIdc setting and iMaxSpatialBitrate (%d) is considered too big to be valid, changed to UNSPECIFIED_BIT_RATE",
106 pLayerParam->iMaxSpatialBitrate);
107 pLayerParam->iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE;
108 }
109
110 // deal with iSpatialBitrate and iMaxSpatialBitrate setting
111 if (pLayerParam->iMaxSpatialBitrate != UNSPECIFIED_BIT_RATE) {
112 if (pLayerParam->iMaxSpatialBitrate == pLayerParam->iSpatialBitrate) {
113 WelsLog (pLogCtx, WELS_LOG_INFO,
114 "Setting MaxSpatialBitrate (%d) the same at SpatialBitrate (%d) will make the actual bit rate lower than SpatialBitrate",
115 pLayerParam->iMaxSpatialBitrate, pLayerParam->iSpatialBitrate);
116 } else if (pLayerParam->iMaxSpatialBitrate < pLayerParam->iSpatialBitrate) {
117 WelsLog (pLogCtx, WELS_LOG_ERROR,
118 "MaxSpatialBitrate (%d) should be larger than SpatialBitrate (%d), considering it as error setting",
119 pLayerParam->iMaxSpatialBitrate, pLayerParam->iSpatialBitrate);
120 return ENC_RETURN_UNSUPPORTED_PARA;
121 }
122 }
123 return ENC_RETURN_SUCCESS;
124}
125
126void CheckProfileSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iLayer, EProfileIdc uiProfileIdc) {
127 SSpatialLayerConfig* pLayerInfo = &pParam->sSpatialLayers[iLayer];

Callers 3

ParamValidationFunction · 0.85
WelsEncoderApplyBitRateFunction · 0.85

Calls 2

WelsLogFunction · 0.85
WelsAdjustLevelFunction · 0.85

Tested by

no test coverage detected