Showing the changes to test/api/encode_options_test.cpp (1 of 2 files). Show all
Unified · Split
| @@ -34,7 +34,6 @@ void EncodeDecodeTestAPIBase::InitialEncDec (int iWidth, int iHeight) { · 33 unmodified lines | ||
| 34 | 34 | //set a fixed random value |
| 35 | 35 | iRandValue = rand() % 256; |
| 36 | 36 | } |
| 37 | − | |
| 38 | 37 | void EncodeDecodeTestAPIBase::RandomParamExtCombination() { |
| 39 | 38 | |
| 40 | 39 | param_.iPicWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 2, MAX_WIDTH); |
| @@ -340,6 +339,51 @@ TEST_F (EncodeDecodeTestAPI, SetOptionEncParamExt) { · 299 unmodified lines | ||
| 340 | 339 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); |
| 341 | 340 | } |
| 342 | 341 | |
| 342 | + | |
| 343 | +TEST_F (EncodeDecodeTestAPI, SetOptionEncParamBase) { | |
| 344 | + int iSpatialLayerNum = 4; | |
| 345 | + int iWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 1 << iSpatialLayerNum, MAX_WIDTH); | |
| 346 | + int iHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 1 << iSpatialLayerNum, MAX_HEIGHT); | |
| 347 | + float fFrameRate = rand() + 0.5f; | |
| 348 | + int iEncFrameNum = WelsClip3 ((rand() % ENCODE_FRAME_NUM) + 1, 1, ENCODE_FRAME_NUM); | |
| 349 | + int iSliceNum = 1; | |
| 350 | + encoder_->GetDefaultParams (¶m_); | |
| 351 | + prepareParamDefault (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, ¶m_); | |
| 352 | + | |
| 353 | + int rv = encoder_->InitializeExt (¶m_); | |
| 354 | + ASSERT_TRUE (rv == cmResultSuccess); | |
| 355 | + | |
| 356 | + int iTraceLevel = WELS_LOG_QUIET; | |
| 357 | + rv = encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); | |
| 358 | + ASSERT_TRUE (rv == cmResultSuccess); | |
| 359 | + | |
| 360 | + for (int i = 0; i < iEncFrameNum; i++) { | |
| 361 | + int iResult; | |
| 362 | + int len = 0; | |
| 363 | + unsigned char* pData[3] = { NULL }; | |
| 364 | + | |
| 365 | + param_.iTargetBitrate = rand() % BIT_RATE_RANGE; | |
| 366 | + iResult = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_BASE, ¶m_); | |
| 367 | + | |
| 368 | + if (cmResultSuccess == iResult) { | |
| 369 | + InitialEncDec (param_.iPicWidth, param_.iPicHeight); | |
| 370 | + EncodeOneFrame (0); | |
| 371 | + encToDecData (info, len); | |
| 372 | + pData[0] = pData[1] = pData[2] = 0; | |
| 373 | + memset (&dstBufInfo_, 0, sizeof (SBufferInfo)); | |
| 374 | + | |
| 375 | + iResult = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf, len, pData, &dstBufInfo_); | |
| 376 | + ASSERT_TRUE (iResult == cmResultSuccess); | |
| 377 | + iResult = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); | |
| 378 | + ASSERT_TRUE (iResult == cmResultSuccess); | |
| 379 | + EXPECT_EQ (dstBufInfo_.iBufferStatus, 1); | |
| 380 | + } | |
| 381 | + } | |
| 382 | + | |
| 383 | + iTraceLevel = WELS_LOG_ERROR; | |
| 384 | + encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); | |
| 385 | +} | |
| 386 | + | |
| 343 | 387 | struct EncodeDecodeParamBase { |
| 344 | 388 | int width; |
| 345 | 389 | int height; |