History

add new UT for ENCODER_OPTION_IDR_INTERVAL and enhance error log output

sijchen@cisco.com committed 8 years ago

Commit 30a49621 parent cb346fe3 files · +54 −4Browse files

Showing the changes to test/api/encode_options_test.cpp (1 of 3 files). Show all

Unified · Split

test/api/encode_options_test.cpp+45−0
@@ -2332,3 +2332,48 @@ TEST_F (EncodeDecodeTestAPI, TemporalLayerChangeDuringEncoding_Specific) { · 2331 unmodified lines
23322332
23332333 }
23342334
2335+TEST_F (EncodeDecodeTestAPI, ENCODER_OPTION_IDR_INTERVAL) {
2336+ int iSpatialLayerNum = 1;
2337+ int iWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 1 << iSpatialLayerNum, MAX_WIDTH);
2338+ int iHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 1 << iSpatialLayerNum, MAX_HEIGHT);
2339+ float fFrameRate = rand() + 0.5f;
2340+ int iSliceNum = 1;
2341+ encoder_->GetDefaultParams (&param_);
2342+ prepareParamDefault (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &param_);
2343+ param_.iTemporalLayerNum = 1;
2344+
2345+ int iTraceLevel = WELS_LOG_QUIET;
2346+ int rv = encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
2347+ EXPECT_TRUE (rv == cmResultSuccess);
2348+
2349+ rv = encoder_->InitializeExt (&param_);
2350+ ASSERT_TRUE (rv == cmResultSuccess);
2351+
2352+ InitialEncDec (param_.iPicWidth, param_.iPicHeight);
2353+ EncodeOneFrame (0);
2354+ EXPECT_TRUE (info.eFrameType == videoFrameTypeIDR);
2355+
2356+ int iLastIdrIdx = 0;
2357+ int iFrame = 1;
2358+ int iTtlAttempt = (rand() % 5) + 2;
2359+ for (int iAtt = 0; iAtt < iTtlAttempt; iAtt++) {
2360+ int kiTargetIntraPeriod = WelsClip3 ((rand() % ENCODE_FRAME_NUM) - 1, -1, ENCODE_FRAME_NUM);
2361+ rv = encoder_->SetOption (ENCODER_OPTION_IDR_INTERVAL, &kiTargetIntraPeriod);
2362+ EXPECT_TRUE (rv == cmResultSuccess);
2363+
2364+ int iEncFrameNum = kiTargetIntraPeriod * 3;
2365+ for (int i = 0; i < iEncFrameNum; i++) {
2366+ EncodeOneFrame (0);
2367+
2368+ if ((kiTargetIntraPeriod <= 0) || (((iFrame - iLastIdrIdx) % kiTargetIntraPeriod) == 0)) {
2369+ EXPECT_TRUE (info.eFrameType == videoFrameTypeIDR) << "kiTargetIntraPeriod " << kiTargetIntraPeriod <<
2370+ " info.eFrameType " << info.eFrameType << " Frame " << i;
2371+ iLastIdrIdx = iFrame;
2372+ } else {
2373+ EXPECT_FALSE (info.eFrameType == videoFrameTypeIDR);
2374+ }
2375+
2376+ iFrame ++;
2377+ }
2378+ }
2379+}

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