Showing the changes to test/api/encode_options_test.cpp (1 of 2 files). Show all
Unified · Split
| @@ -347,6 +347,119 @@ struct EncodeDecodeParamBase { · 346 unmodified lines | |||
| 347 | int iTarBitrate; | 347 | int iTarBitrate; |
| 348 | }; | 348 | }; |
| 349 | 349 | ||
| 350 | //#define DEBUG_FILE_SAVE_INCREASING_ID | ||
| 351 | TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_INCREASING_ID) { | ||
| 352 | |||
| 353 | int iWidth = GetRandWidth(); | ||
| 354 | int iHeight = GetRandHeight(); | ||
| 355 | float fFrameRate = rand() + 0.5f; | ||
| 356 | int iEncFrameNum = 0; | ||
| 357 | int iSpatialLayerNum = 1; | ||
| 358 | int iSliceNum = 1; | ||
| 359 | |||
| 360 | // prepare params | ||
| 361 | SEncParamExt sParam1; | ||
| 362 | SEncParamExt sParam2; | ||
| 363 | SEncParamExt sParam3; | ||
| 364 | encoder_->GetDefaultParams (&sParam1); | ||
| 365 | prepareParamDefault (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1); | ||
| 366 | sParam1.bSimulcastAVC = 1; | ||
| 367 | sParam1.eSpsPpsIdStrategy = INCREASING_ID; | ||
| 368 | //prepare param2 | ||
| 369 | memcpy (&sParam2, &sParam1, sizeof (SEncParamExt)); | ||
| 370 | while (GET_MB_WIDTH (sParam2.iPicWidth) == GET_MB_WIDTH (sParam1.iPicWidth)) { | ||
| 371 | sParam2.iPicWidth = GetRandWidth(); | ||
| 372 | } | ||
| 373 | prepareParamDefault (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2); | ||
| 374 | sParam2.bSimulcastAVC = 1; | ||
| 375 | sParam2.eSpsPpsIdStrategy = INCREASING_ID; | ||
| 376 | //prepare param3 | ||
| 377 | memcpy (&sParam3, &sParam1, sizeof (SEncParamExt)); | ||
| 378 | while (GET_MB_WIDTH (sParam3.iPicHeight) == GET_MB_WIDTH (sParam1.iPicHeight)) { | ||
| 379 | sParam3.iPicHeight = GetRandHeight(); | ||
| 380 | } | ||
| 381 | prepareParamDefault (iSpatialLayerNum, iSliceNum, sParam3.iPicWidth, sParam3.iPicHeight, fFrameRate, &sParam3); | ||
| 382 | sParam3.bSimulcastAVC = 1; | ||
| 383 | sParam3.eSpsPpsIdStrategy = INCREASING_ID; | ||
| 384 | |||
| 385 | //prepare output if needed | ||
| 386 | FILE* fEnc = NULL; | ||
| 387 | #ifdef DEBUG_FILE_SAVE_INCREASING_ID | ||
| 388 | fEnc = fopen ("enc_i.264", "wb"); | ||
| 389 | #endif | ||
| 390 | |||
| 391 | // Test part#1 | ||
| 392 | // step#1: pParam1 | ||
| 393 | //int TraceLevel = WELS_LOG_INFO; | ||
| 394 | //encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &TraceLevel); | ||
| 395 | int rv = encoder_->InitializeExt (&sParam1); | ||
| 396 | ASSERT_TRUE (rv == cmResultSuccess) << "InitializeExt: rv = " << rv << " at " << sParam1.iPicWidth << "x" << | ||
| 397 | sParam1.iPicHeight; | ||
| 398 | EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | ||
| 399 | |||
| 400 | // new IDR | ||
| 401 | rv = encoder_->ForceIntraFrame (true); | ||
| 402 | ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | ||
| 403 | EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | ||
| 404 | |||
| 405 | // step#2: pParam2 | ||
| 406 | rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2); | ||
| 407 | ASSERT_TRUE (rv == cmResultSuccess) << "SetOption: rv = " << rv << " at " << sParam2.iPicWidth << "x" << | ||
| 408 | sParam2.iPicHeight; | ||
| 409 | EncDecOneFrame (sParam2.iPicWidth, sParam2.iPicHeight, iEncFrameNum++, fEnc); | ||
| 410 | |||
| 411 | // new IDR | ||
| 412 | rv = encoder_->ForceIntraFrame (true); | ||
| 413 | ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | ||
| 414 | EncDecOneFrame (sParam2.iPicWidth, sParam2.iPicHeight, iEncFrameNum++, fEnc); | ||
| 415 | |||
| 416 | // step#3: back to pParam1 | ||
| 417 | rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam1); | ||
| 418 | ASSERT_TRUE (rv == cmResultSuccess) << "SetOption: rv = " << rv << " at " << sParam1.iPicWidth << "x" << | ||
| 419 | sParam1.iPicHeight; | ||
| 420 | EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | ||
| 421 | |||
| 422 | // step#4: back to pParam2 | ||
| 423 | rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2); | ||
| 424 | ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv << sParam2.iPicWidth << sParam2.iPicHeight; | ||
| 425 | EncDecOneFrame (sParam2.iPicWidth, sParam2.iPicHeight, iEncFrameNum++, fEnc); | ||
| 426 | |||
| 427 | #ifdef DEBUG_FILE_SAVE_INCREASING_ID | ||
| 428 | fclose (fEnc); | ||
| 429 | #endif | ||
| 430 | rv = encoder_->Uninitialize(); | ||
| 431 | ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | ||
| 432 | |||
| 433 | // Test part#2 | ||
| 434 | // step#1: pParam1 | ||
| 435 | rv = encoder_->InitializeExt (&sParam1); | ||
| 436 | ASSERT_TRUE (rv == cmResultSuccess) << "InitializeExt Failed: rv = " << rv; | ||
| 437 | rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2); | ||
| 438 | ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam2: rv = " << rv; | ||
| 439 | rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam3); | ||
| 440 | ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam3: rv = " << rv; | ||
| 441 | |||
| 442 | #ifdef DEBUG_FILE_SAVE_INCREASING_ID | ||
| 443 | fEnc = fopen ("enc3.264", "wb"); | ||
| 444 | #endif | ||
| 445 | iEncFrameNum = 0; | ||
| 446 | EncDecOneFrame (sParam3.iPicWidth, sParam3.iPicHeight, iEncFrameNum++, fEnc); | ||
| 447 | |||
| 448 | rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2); | ||
| 449 | ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam2: rv = " << rv; | ||
| 450 | EncDecOneFrame (sParam2.iPicWidth, sParam2.iPicHeight, iEncFrameNum++, fEnc); | ||
| 451 | |||
| 452 | rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam1); | ||
| 453 | ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam2: rv = " << rv; | ||
| 454 | EncDecOneFrame (sParam1.iPicWidth, sParam1.iPicHeight, iEncFrameNum++, fEnc); | ||
| 455 | |||
| 456 | #ifdef DEBUG_FILE_SAVE_INCREASING_ID | ||
| 457 | fclose (fEnc); | ||
| 458 | #endif | ||
| 459 | rv = encoder_->Uninitialize(); | ||
| 460 | ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; | ||
| 461 | } | ||
| 462 | |||
| 350 | //#define DEBUG_FILE_SAVE2 | 463 | //#define DEBUG_FILE_SAVE2 |
| 351 | TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_LISTING_AND_PPS_INCREASING1) { | 464 | TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_LISTING_AND_PPS_INCREASING1) { |
| 352 | 465 | ||