History

enhance max-br checking logic

Sijia Chen committed 11 years ago

Commit d74234d1 parent 66645931 file · +37 −25Browse files

Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 1 file). Show all

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+37−25
@@ -76,34 +76,46 @@ int32_t WelsBitRateVerification (SLogContext* pLogCtx, SSpatialLayerConfig* pLay · 75 unmodified lines
76 pLayerParam->iSpatialBitrate);76 pLayerParam->iSpatialBitrate);
77 return ENC_RETURN_UNSUPPORTED_PARA;77 return ENC_RETURN_UNSUPPORTED_PARA;
78 }78 }
79 int32_t iLevelMaxBitrate = g_ksLevelLimits[pLayerParam->uiLevelIdc - 1].uiMaxBR * CpbBrNalFactor;79
80 if (pLayerParam->iMaxSpatialBitrate == UNSPECIFIED_BIT_RATE) {80 // deal with LEVEL_MAX_BR and MAX_BR setting
81 pLayerParam->iMaxSpatialBitrate = iLevelMaxBitrate;81 const int32_t iLevelMaxBitrate = (pLayerParam->uiLevelIdc != LEVEL_UNKNOWN) ? (g_ksLevelLimits[pLayerParam->uiLevelIdc -
82 WelsLog (pLogCtx, WELS_LOG_INFO, "Current MaxSpatialBitrate is zero,Get this value from level limitation(%d)",82 1].uiMaxBR * CpbBrNalFactor) : UNSPECIFIED_BIT_RATE;
83 const int32_t iLevel52MaxBitrate = g_ksLevelLimits[LEVEL_NUMBER - 1].uiMaxBR * CpbBrNalFactor;
84 if (UNSPECIFIED_BIT_RATE != iLevelMaxBitrate) {
85 if ((pLayerParam->iMaxSpatialBitrate == UNSPECIFIED_BIT_RATE)
86 || (pLayerParam->iMaxSpatialBitrate > iLevel52MaxBitrate)) {
87 pLayerParam->iMaxSpatialBitrate = iLevelMaxBitrate;
88 WelsLog (pLogCtx, WELS_LOG_INFO,
89 "Current MaxSpatialBitrate is invalid (UNSPECIFIED_BIT_RATE or larger than LEVEL5_2) but level setting is valid, set iMaxSpatialBitrate to %d from level (%d)",
90 pLayerParam->iMaxSpatialBitrate, pLayerParam->uiLevelIdc);
91 } else if (pLayerParam->iMaxSpatialBitrate > iLevelMaxBitrate) {
92 ELevelIdc iCurLevel = pLayerParam->uiLevelIdc;
93 WelsAdjustLevel (pLayerParam);
94 WelsLog (pLogCtx, WELS_LOG_INFO,
95 "LevelIdc is changed from (%d) to (%d) according to the iMaxSpatialBitrate(%d)",
96 iCurLevel, pLayerParam->uiLevelIdc, pLayerParam->iMaxSpatialBitrate);
97 }
98 } else if ((pLayerParam->iMaxSpatialBitrate != UNSPECIFIED_BIT_RATE)
99 && (pLayerParam->iMaxSpatialBitrate > iLevel52MaxBitrate)) {
100 // no level limitation, just need to check if iMaxSpatialBitrate is too big from reasonable
101 WelsLog (pLogCtx, WELS_LOG_WARNING,
102 "No LevelIdc setting and iMaxSpatialBitrate (%d) is considered too big to be valid, changed to UNSPECIFIED_BIT_RATE",
83 pLayerParam->iMaxSpatialBitrate);103 pLayerParam->iMaxSpatialBitrate);
104 pLayerParam->iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE;
84 }105 }
85 if (pLayerParam->iMaxSpatialBitrate > iLevelMaxBitrate) {106
86 ELevelIdc iCurLevel = pLayerParam->uiLevelIdc;107 // deal with iSpatialBitrate and iMaxSpatialBitrate setting
87 if (WelsAdjustLevel (pLayerParam)) {108 if (pLayerParam->iMaxSpatialBitrate != UNSPECIFIED_BIT_RATE) {
88 int32_t iLevel52MaxBitrate = g_ksLevelLimits[LEVEL_NUMBER - 1].uiMaxBR * CpbBrNalFactor;109 if (pLayerParam->iMaxSpatialBitrate == pLayerParam->iSpatialBitrate) {
89 WelsLog (pLogCtx, WELS_LOG_WARNING,110 WelsLog (pLogCtx, WELS_LOG_INFO,
90 "MaxSpatialBitrate (%d) is larger that the limitation LEVEL_5_2, the setting will be invalid, and will use max-br (%d) of LEVEL_5_2",111 "Setting MaxSpatialBitrate (%d) the same at SpatialBitrate (%d) will make the actual bit rate lower than SpatialBitrate",
91 pLayerParam->iMaxSpatialBitrate, iLevel52MaxBitrate);112 pLayerParam->iMaxSpatialBitrate, pLayerParam->iSpatialBitrate);
92 pLayerParam->iMaxSpatialBitrate = iLevel52MaxBitrate;113 } else if (pLayerParam->iMaxSpatialBitrate < pLayerParam->iSpatialBitrate) {
114 WelsLog (pLogCtx, WELS_LOG_ERROR,
115 "MaxSpatialBitrate (%d) should be larger than SpatialBitrate (%d), considering it as error setting",
116 pLayerParam->iMaxSpatialBitrate, pLayerParam->iSpatialBitrate);
117 return ENC_RETURN_UNSUPPORTED_PARA;
93 }118 }
94 WelsLog (pLogCtx, WELS_LOG_INFO,
95 "Level is changed from (%d) to (%d) according to the maxbitrate",
96 iCurLevel, pLayerParam->uiLevelIdc);
97 }
98 if (pLayerParam->iMaxSpatialBitrate == pLayerParam->iSpatialBitrate) {
99 WelsLog (pLogCtx, WELS_LOG_INFO,
100 "Setting MaxSpatialBitrate (%d) the same at SpatialBitrate (%d) will make the actual bit rate lower than SpatialBitrate",
101 pLayerParam->iMaxSpatialBitrate, pLayerParam->iSpatialBitrate);
102 } else if (pLayerParam->iMaxSpatialBitrate < pLayerParam->iSpatialBitrate) {
103 WelsLog (pLogCtx, WELS_LOG_ERROR,
104 "MaxSpatialBitrate (%d) should be larger than SpatialBitrate (%d), considering it as error setting",
105 pLayerParam->iMaxSpatialBitrate, pLayerParam->iSpatialBitrate);
106 return ENC_RETURN_UNSUPPORTED_PARA;
107 }119 }
108 return ENC_RETURN_SUCCESS;120 return ENC_RETURN_SUCCESS;
109}121}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t