History

change profile and level setting and add ut cases

Karina committed 9 years ago

Commit f09c85f1 parent a683dae14 files · +6051 −5856Browse files

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

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+52−27
@@ -79,8 +79,10 @@ int32_t WelsBitRateVerification (SLogContext* pLogCtx, SSpatialLayerConfig* pLay · 78 unmodified lines
7979 }
8080
8181 // deal with LEVEL_MAX_BR and MAX_BR setting
82− const int32_t iLevelMaxBitrate = (pLayerParam->uiLevelIdc != LEVEL_UNKNOWN) ? (g_ksLevelLimits[pLayerParam->uiLevelIdc -
83− 1].uiMaxBR * CpbBrNalFactor) : UNSPECIFIED_BIT_RATE;
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;
8486 const int32_t iLevel52MaxBitrate = g_ksLevelLimits[LEVEL_NUMBER - 1].uiMaxBR * CpbBrNalFactor;
8587 if (UNSPECIFIED_BIT_RATE != iLevelMaxBitrate) {
8688 if ((pLayerParam->iMaxSpatialBitrate == UNSPECIFIED_BIT_RATE)
@@ -91,7 +93,7 @@ int32_t WelsBitRateVerification (SLogContext* pLogCtx, SSpatialLayerConfig* pLay · 4 unmodified lines
9193 pLayerParam->iMaxSpatialBitrate, pLayerParam->uiLevelIdc);
9294 } else if (pLayerParam->iMaxSpatialBitrate > iLevelMaxBitrate) {
9395 ELevelIdc iCurLevel = pLayerParam->uiLevelIdc;
94− WelsAdjustLevel (pLayerParam);
96+ WelsAdjustLevel (pLayerParam, pCurLevelLimit);
9597 WelsLog (pLogCtx, WELS_LOG_INFO,
9698 "LevelIdc is changed from (%d) to (%d) according to the iMaxSpatialBitrate(%d)",
9799 iCurLevel, pLayerParam->uiLevelIdc, pLayerParam->iMaxSpatialBitrate);
@@ -123,36 +125,55 @@ int32_t WelsBitRateVerification (SLogContext* pLogCtx, SSpatialLayerConfig* pLay · 25 unmodified lines
123125
124126 void CheckProfileSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iLayer, EProfileIdc uiProfileIdc) {
125127 SSpatialLayerConfig* pLayerInfo = &pParam->sSpatialLayers[iLayer];
126− if (PRO_UNKNOWN == uiProfileIdc) {
127− pLayerInfo->uiProfileIdc = (((iLayer == SPATIAL_LAYER_0)
128− || pParam->bSimulcastAVC) ? PRO_BASELINE : PRO_SCALABLE_BASELINE);
129− } else {
130− pLayerInfo->uiProfileIdc = uiProfileIdc;
131− if ((iLayer == SPATIAL_LAYER_0) && (uiProfileIdc != PRO_BASELINE)) {
132− WelsLog (pLogCtx, WELS_LOG_WARNING, "doesn't support profile(%d), change to baseline profile",
128+ pLayerInfo->uiProfileIdc = uiProfileIdc;
129+ if (pParam->bSimulcastAVC) {
130+ if ((uiProfileIdc != PRO_BASELINE) && (uiProfileIdc != PRO_MAIN) && (uiProfileIdc != PRO_HIGH)) {
131+ WelsLog (pLogCtx, WELS_LOG_WARNING, "layerId(%d) doesn't support profile(%d), change to baseline profile", iLayer,
133132 uiProfileIdc);
134133 pLayerInfo->uiProfileIdc = PRO_BASELINE;
135134 }
136− if (iLayer > SPATIAL_LAYER_0) {
137− if (pParam->bSimulcastAVC && (uiProfileIdc != PRO_BASELINE)) {
138− pLayerInfo->uiProfileIdc = PRO_BASELINE;
139− WelsLog (pLogCtx, WELS_LOG_WARNING, "doesn't support profile(%d) with bSimulcastAVC, change to baseline profile",
135+ if (pParam->iEntropyCodingModeFlag && pLayerInfo->uiProfileIdc == PRO_BASELINE) {
136+ pLayerInfo->uiProfileIdc = PRO_MAIN;
137+ WelsLog (pLogCtx, WELS_LOG_WARNING, "layerId(%d) change to main profile because cabac is enabled", iLayer);
138+ }
139+ } else {
140+ if (iLayer == SPATIAL_LAYER_0) {
141+ if ((uiProfileIdc != PRO_BASELINE) && (uiProfileIdc != PRO_MAIN) && (uiProfileIdc != PRO_HIGH)) {
142+ WelsLog (pLogCtx, WELS_LOG_WARNING, "layerId(%d) doesn't support profile(%d), change to baseline profile", iLayer,
140143 uiProfileIdc);
141− }
142− if ((uiProfileIdc != PRO_BASELINE) || (uiProfileIdc != PRO_SCALABLE_BASELINE)) {
143144 pLayerInfo->uiProfileIdc = PRO_BASELINE;
144− WelsLog (pLogCtx, WELS_LOG_WARNING, "doesn't support profile(%d), change to baseline profile",
145− uiProfileIdc);
145+ }
146+ if (pParam->iEntropyCodingModeFlag && (pLayerInfo->uiProfileIdc == PRO_BASELINE)) {
147+ pLayerInfo->uiProfileIdc = PRO_MAIN;
148+ WelsLog (pLogCtx, WELS_LOG_WARNING, "layerId(%d) change to main profile because cabac is enabled", iLayer);
149+ }
150+ } else {
151+ if ((uiProfileIdc != PRO_SCALABLE_BASELINE) && (uiProfileIdc != PRO_SCALABLE_HIGH)) {
152+ pLayerInfo->uiProfileIdc = PRO_SCALABLE_BASELINE;
153+ WelsLog (pLogCtx, WELS_LOG_WARNING, "layerId(%d) doesn't support profile(%d), change to scalable baseline profile",
154+ iLayer, uiProfileIdc);
155+ }
156+ if (pParam->iEntropyCodingModeFlag && (pLayerInfo->uiProfileIdc == PRO_SCALABLE_BASELINE)) {
157+ pLayerInfo->uiProfileIdc = PRO_SCALABLE_HIGH;
158+ WelsLog (pLogCtx, WELS_LOG_WARNING, "layerId(%d) change to scalable hight profile because cabac is enabled", iLayer);
146159 }
147160 }
148161 }
149162 }
150163 void CheckLevelSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iLayer, ELevelIdc uiLevelIdc) {
151164 SSpatialLayerConfig* pLayerInfo = &pParam->sSpatialLayers[iLayer];
152− pLayerInfo->uiLevelIdc = uiLevelIdc;
153− if (uiLevelIdc > LEVEL_5_2) {
154− WelsLog (pLogCtx, WELS_LOG_INFO, "change unexpected levelidc(%d) setting to LEVEL_UNKNOWN", pLayerInfo->uiLevelIdc);
155− pLayerInfo->uiLevelIdc = LEVEL_UNKNOWN;
165+ pLayerInfo->uiLevelIdc = LEVEL_UNKNOWN;
166+ int32_t iLevelIdx = LEVEL_NUMBER - 1;
167+ do {
168+ if (g_ksLevelLimits[iLevelIdx].uiLevelIdc == uiLevelIdc) {
169+ pLayerInfo->uiLevelIdc = uiLevelIdc;
170+ break;
171+ }
172+ iLevelIdx--;
173+ } while (iLevelIdx >= 0);
174+ if (pLayerInfo->uiLevelIdc == LEVEL_UNKNOWN) {
175+ WelsLog (pLogCtx, WELS_LOG_INFO, "change unexpected levelidc(%d) setting to LEVEL_5_2", pLayerInfo->uiLevelIdc);
176+ pLayerInfo->uiLevelIdc = LEVEL_5_2;
156177 }
157178 }
158179 void CheckReferenceNumSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iNumRef) {
@@ -1626,8 +1647,11 @@ void GetMvMvdRange (SWelsSvcCodingParam* pParam, int32_t& iMvRange, int32_t& iMv · 1467 unmodified lines
16261647 if (pParam->sSpatialLayers[iLayer].uiLevelIdc < iMinLevelIdc)
16271648 iMinLevelIdc = pParam->sSpatialLayers[iLayer].uiLevelIdc;
16281649 }
1629− iMinMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMinVmv) >> 2;
1630− iMaxMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMaxVmv) >> 2;
1650+ const SLevelLimits* pLevelLimit = g_ksLevelLimits;
1651+ while ((pLevelLimit->uiLevelIdc != LEVEL_5_2) && (pLevelLimit->uiLevelIdc != iMinLevelIdc))
1652+ pLevelLimit++;
1653+ iMinMv = (pLevelLimit->iMinVmv) >> 2;
1654+ iMaxMv = (pLevelLimit->iMaxVmv) >> 2;
16311655
16321656 iMvRange = WELS_MIN (WELS_ABS (iMinMv), iMaxMv);
16331657
@@ -3990,9 +4014,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 2356 unmodified lines
39904014 iFrameSize += iLayerSize;
39914015 //check MinCr
39924016 {
3993− int32_t iImageSize = (pParam->iVideoWidth * pParam->iVideoHeight * 3) >> 1;
3994− int32_t iMinCr = g_ksLevelLimits[pParam->uiLevelIdc - 1].uiMinCR;
3995− if (iFrameSize > (iImageSize / iMinCr))
4017+ int32_t iMinCrFrameSize = (pParam->iVideoWidth * pParam->iVideoHeight * 3) >> 2; //MinCr = 2;
4018+ if (pParam->uiLevelIdc == LEVEL_3_1 || pParam->uiLevelIdc == LEVEL_3_2 || pParam->uiLevelIdc == LEVEL_4_0)
4019+ iMinCrFrameSize >>= 1; //MinCr = 4
4020+ if (iFrameSize > iMinCrFrameSize)
39964021 WelsLog (pLogCtx, WELS_LOG_WARNING,
39974022 "WelsEncoderEncodeExt()MinCr Checking,codec bitstream size is larger than Level limitation");
39984023 }

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