Showing the changes to test/encoder/EncUT_EncoderExt.cpp (1 of 11 files). Show all
Unified · Split
| @@ -206,9 +206,13 @@ TEST_F (EncoderInterfaceTest, EncoderAdditionalOptionSetTest) { · 205 unmodified lines | |||
| 206 | sInfo.iBitrate = rand() % 100000 - 100; | 206 | sInfo.iBitrate = rand() % 100000 - 100; |
| 207 | sInfo.iLayer = static_cast<LAYER_NUM> (pParamExt->iSpatialLayerNum); | 207 | sInfo.iLayer = static_cast<LAYER_NUM> (pParamExt->iSpatialLayerNum); |
| 208 | iResult = pPtrEnc->SetOption (eOptionId, &sInfo); | 208 | iResult = pPtrEnc->SetOption (eOptionId, &sInfo); |
| 209 | pPtrEnc->GetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, pParamExt); | ||
| 209 | if (sInfo.iBitrate <= 0) | 210 | if (sInfo.iBitrate <= 0) |
| 210 | EXPECT_EQ (iResult, static_cast<int> (cmInitParaError)); | 211 | EXPECT_EQ (iResult, static_cast<int> (cmInitParaError)); |
| 211 | else { | 212 | else if (pParamExt->sSpatialLayers[sInfo.iLayer].iSpatialBitrate > |
| 213 | pParamExt->sSpatialLayers[sInfo.iLayer].iMaxSpatialBitrate) { | ||
| 214 | EXPECT_EQ (iResult, static_cast<int> (cmInitParaError)); | ||
| 215 | } else { | ||
| 212 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 216 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 213 | sReturn.iLayer = static_cast<LAYER_NUM> (pParamExt->iSpatialLayerNum); | 217 | sReturn.iLayer = static_cast<LAYER_NUM> (pParamExt->iSpatialLayerNum); |
| 214 | iResult = pPtrEnc->GetOption (eOptionId, &sReturn); | 218 | iResult = pPtrEnc->GetOption (eOptionId, &sReturn); |
| @@ -224,9 +228,13 @@ TEST_F (EncoderInterfaceTest, EncoderAdditionalOptionSetTest) { · 9 unmodified lines | |||
| 224 | sInfo.iBitrate = rand() % 100000 - 100; | 228 | sInfo.iBitrate = rand() % 100000 - 100; |
| 225 | sInfo.iLayer = static_cast<LAYER_NUM> (pParamExt->iSpatialLayerNum); | 229 | sInfo.iLayer = static_cast<LAYER_NUM> (pParamExt->iSpatialLayerNum); |
| 226 | iResult = pPtrEnc->SetOption (eOptionId, &sInfo); | 230 | iResult = pPtrEnc->SetOption (eOptionId, &sInfo); |
| 231 | pPtrEnc->GetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, pParamExt); | ||
| 227 | if (sInfo.iBitrate <= 0) | 232 | if (sInfo.iBitrate <= 0) |
| 228 | EXPECT_EQ (iResult, static_cast<int> (cmInitParaError)); | 233 | EXPECT_EQ (iResult, static_cast<int> (cmInitParaError)); |
| 229 | else { | 234 | else if (pParamExt->sSpatialLayers[sInfo.iLayer].iSpatialBitrate > |
| 235 | pParamExt->sSpatialLayers[sInfo.iLayer].iMaxSpatialBitrate) { | ||
| 236 | EXPECT_EQ (iResult, static_cast<int> (cmInitParaError)); | ||
| 237 | } else { | ||
| 230 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 238 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 231 | sReturn.iLayer = static_cast<LAYER_NUM> (pParamExt->iSpatialLayerNum); | 239 | sReturn.iLayer = static_cast<LAYER_NUM> (pParamExt->iSpatialLayerNum); |
| 232 | iResult = pPtrEnc->GetOption (eOptionId, &sReturn); | 240 | iResult = pPtrEnc->GetOption (eOptionId, &sReturn); |
| @@ -438,6 +446,9 @@ void GetValidEncParamBase (SEncParamBase* pEncParamBase) { · 205 unmodified lines | |||
| 438 | pEncParamBase->iPicWidth = VALID_SIZE (pEncParamBase->iPicWidth); | 446 | pEncParamBase->iPicWidth = VALID_SIZE (pEncParamBase->iPicWidth); |
| 439 | pEncParamBase->iPicHeight = VALID_SIZE (pEncParamBase->iPicHeight); | 447 | pEncParamBase->iPicHeight = VALID_SIZE (pEncParamBase->iPicHeight); |
| 440 | pEncParamBase->iTargetBitrate = rand() + 1; //!=0 | 448 | pEncParamBase->iTargetBitrate = rand() + 1; //!=0 |
| 449 | int32_t iLevelMaxBitrate = WelsCommon::g_ksLevelLimits[LEVEL_5_0 - 1].uiMaxBR * CpbBrNalFactor; | ||
| 450 | if (pEncParamBase->iTargetBitrate > iLevelMaxBitrate) | ||
| 451 | pEncParamBase->iTargetBitrate = iLevelMaxBitrate; | ||
| 441 | pEncParamBase->iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2 | 452 | pEncParamBase->iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2 |
| 442 | pEncParamBase->fMaxFrameRate = rand() + 0.5f; //!=0 | 453 | pEncParamBase->fMaxFrameRate = rand() + 0.5f; //!=0 |
| 443 | } | 454 | } |
| @@ -584,12 +595,14 @@ TEST_F (EncoderInterfaceTest, ForceIntraFrameWithTemporal) { · 140 unmodified lines | |||
| 584 | sEncParamExt.iPicWidth = MB_SIZE + abs ((rand() * 2) % (MAX_WIDTH - MB_SIZE)); | 595 | sEncParamExt.iPicWidth = MB_SIZE + abs ((rand() * 2) % (MAX_WIDTH - MB_SIZE)); |
| 585 | sEncParamExt.iPicHeight = MB_SIZE + abs ((rand() * 2) % (MAX_HEIGHT - MB_SIZE)); | 596 | sEncParamExt.iPicHeight = MB_SIZE + abs ((rand() * 2) % (MAX_HEIGHT - MB_SIZE)); |
| 586 | sEncParamExt.iTargetBitrate = rand() + 1; //!=0 | 597 | sEncParamExt.iTargetBitrate = rand() + 1; //!=0 |
| 598 | int32_t iLevelMaxBitrate = WelsCommon::g_ksLevelLimits[LEVEL_5_0 - 1].uiMaxBR * CpbBrNalFactor; | ||
| 599 | if (sEncParamExt.iTargetBitrate > iLevelMaxBitrate) | ||
| 600 | sEncParamExt.iTargetBitrate = iLevelMaxBitrate; | ||
| 587 | sEncParamExt.iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2 | 601 | sEncParamExt.iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2 |
| 588 | sEncParamExt.fMaxFrameRate = rand() + 0.5f; //!=0 | 602 | sEncParamExt.fMaxFrameRate = rand() + 0.5f; //!=0 |
| 589 | sEncParamExt.sSpatialLayers[0].iVideoWidth = sEncParamExt.iPicWidth; | 603 | sEncParamExt.sSpatialLayers[0].iVideoWidth = sEncParamExt.iPicWidth; |
| 590 | sEncParamExt.sSpatialLayers[0].iVideoHeight = sEncParamExt.iPicHeight; | 604 | sEncParamExt.sSpatialLayers[0].iVideoHeight = sEncParamExt.iPicHeight; |
| 591 | sEncParamExt.sSpatialLayers[0].iSpatialBitrate = sEncParamExt.iTargetBitrate; | 605 | sEncParamExt.sSpatialLayers[0].iSpatialBitrate = sEncParamExt.iTargetBitrate; |
| 592 | |||
| 593 | int iTargetTemporalLayerNum = rand() % MAX_TEMPORAL_LAYER_NUM; | 606 | int iTargetTemporalLayerNum = rand() % MAX_TEMPORAL_LAYER_NUM; |
| 594 | sEncParamExt.iTemporalLayerNum = (iTargetTemporalLayerNum > 2) ? iTargetTemporalLayerNum : 2; | 607 | sEncParamExt.iTemporalLayerNum = (iTargetTemporalLayerNum > 2) ? iTargetTemporalLayerNum : 2; |
| 595 | 608 | ||