Showing the changes to test/encoder/EncUT_EncoderExt.cpp (1 of 3 files). Show all
Unified · Split
| @@ -64,6 +64,7 @@ class EncoderInterfaceTest : public ::testing::Test { · 63 unmodified lines | ||
| 64 | 64 | void EncodeOneFrame (SEncParamBase* pEncParamBase); |
| 65 | 65 | void PrepareOneSrcFrame(); |
| 66 | 66 | void EncodeOneIDRandP (ISVCEncoder* pPtrEnc); |
| 67 | + void ChangeResolutionAndCheckStatistics (const SEncParamBase& sEncParamBase, SEncoderStatistics* pEncoderStatistics); | |
| 67 | 68 | |
| 68 | 69 | public: |
| 69 | 70 | ISVCEncoder* pPtrEnc; |
| @@ -662,6 +663,46 @@ TEST_F (EncoderInterfaceTest, BasicReturnTypeTest) { · 592 unmodified lines | ||
| 662 | 663 | //TODO |
| 663 | 664 | } |
| 664 | 665 | |
| 666 | +void EncoderInterfaceTest::ChangeResolutionAndCheckStatistics (const SEncParamBase& sEncParamBase, | |
| 667 | + SEncoderStatistics* pEncoderStatistics) { | |
| 668 | + unsigned int uiExistingFrameCount = pEncoderStatistics->uiInputFrameCount; | |
| 669 | + unsigned int uiExistingIDR = pEncoderStatistics->uiIDRSentNum; | |
| 670 | + unsigned int uiExistingResolutionChange = pEncoderStatistics->uiResolutionChangeTimes; | |
| 671 | + | |
| 672 | + // 1, get the existing param | |
| 673 | + int iResult = pPtrEnc->GetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, pParamExt); | |
| 674 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 675 | + | |
| 676 | + // 2, change setting | |
| 677 | + unsigned int uiKnownResolutionChangeTimes = uiExistingResolutionChange; | |
| 678 | + bool bCheckIDR = false; | |
| 679 | + if (pParamExt->iPicWidth != sEncParamBase.iPicWidth || pParamExt->iPicHeight != sEncParamBase.iPicHeight) { | |
| 680 | + uiKnownResolutionChangeTimes += 1; | |
| 681 | + bCheckIDR = true; | |
| 682 | + } | |
| 683 | + pParamExt->iPicWidth = pParamExt->sSpatialLayers[0].iVideoWidth = sEncParamBase.iPicWidth; | |
| 684 | + pParamExt->iPicHeight = pParamExt->sSpatialLayers[0].iVideoHeight = sEncParamBase.iPicHeight; | |
| 685 | + pPtrEnc->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, pParamExt); | |
| 686 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 687 | + | |
| 688 | + // 3, code one frame | |
| 689 | + PrepareOneSrcFrame(); | |
| 690 | + iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | |
| 691 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 692 | + iResult = pPtrEnc->GetOption (ENCODER_OPTION_GET_STATISTICS, pEncoderStatistics); | |
| 693 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 694 | + | |
| 695 | + EXPECT_EQ (pEncoderStatistics->uiInputFrameCount, uiExistingFrameCount + 1); | |
| 696 | + EXPECT_EQ (pEncoderStatistics->uiResolutionChangeTimes, uiKnownResolutionChangeTimes); | |
| 697 | + if (bCheckIDR) { | |
| 698 | + EXPECT_EQ (pEncoderStatistics->uiIDRSentNum, uiExistingIDR + 1); | |
| 699 | + } | |
| 700 | + | |
| 701 | + EXPECT_EQ (pEncoderStatistics->uiWidth, static_cast<unsigned int> (sEncParamBase.iPicWidth)); | |
| 702 | + EXPECT_EQ (pEncoderStatistics->uiHeight, static_cast<unsigned int> (sEncParamBase.iPicHeight)); | |
| 703 | +} | |
| 704 | + | |
| 705 | + | |
| 665 | 706 | TEST_F (EncoderInterfaceTest, GetStatistics) { |
| 666 | 707 | SEncParamBase sEncParamBase; |
| 667 | 708 | GetValidEncParamBase (&sEncParamBase); |
| @@ -682,41 +723,20 @@ TEST_F (EncoderInterfaceTest, GetStatistics) { · 14 unmodified lines | ||
| 682 | 723 | iResult = pPtrEnc->GetOption (ENCODER_OPTION_GET_STATISTICS, &sEncoderStatistics); |
| 683 | 724 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 684 | 725 | EXPECT_EQ (sEncoderStatistics.uiInputFrameCount, static_cast<unsigned int> (2)); |
| 685 | − EXPECT_EQ (sEncoderStatistics.uIDRSentNum, static_cast<unsigned int> (1)); | |
| 726 | + EXPECT_EQ (sEncoderStatistics.uiIDRSentNum, static_cast<unsigned int> (1)); | |
| 686 | 727 | EXPECT_EQ (sEncoderStatistics.uiResolutionChangeTimes, static_cast<unsigned int> (0)); |
| 687 | 728 | |
| 688 | − EXPECT_EQ (sEncoderStatistics.uWidth, static_cast<unsigned int> (sEncParamBase.iPicWidth)); | |
| 689 | − EXPECT_EQ (sEncoderStatistics.uHeight, static_cast<unsigned int> (sEncParamBase.iPicHeight)); | |
| 729 | + EXPECT_EQ (sEncoderStatistics.uiWidth, static_cast<unsigned int> (sEncParamBase.iPicWidth)); | |
| 730 | + EXPECT_EQ (sEncoderStatistics.uiHeight, static_cast<unsigned int> (sEncParamBase.iPicHeight)); | |
| 690 | 731 | |
| 691 | 732 | // try param change |
| 692 | − // 1, get the existing | |
| 693 | − pPtrEnc->GetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, pParamExt); | |
| 694 | − EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 695 | − | |
| 696 | − // 2, change the reoslution | |
| 697 | 733 | GetValidEncParamBase (&sEncParamBase); |
| 698 | − int32_t knownResolutionChangeTimes = 0; | |
| 699 | − if (pParamExt->iPicWidth != sEncParamBase.iPicWidth || pParamExt->iPicHeight != sEncParamBase.iPicHeight) { | |
| 700 | − knownResolutionChangeTimes = 1; | |
| 701 | − } | |
| 702 | − pParamExt->iPicWidth = pParamExt->sSpatialLayers[0].iVideoWidth = sEncParamBase.iPicWidth; | |
| 703 | − pParamExt->iPicHeight = pParamExt->sSpatialLayers[0].iVideoHeight = sEncParamBase.iPicHeight; | |
| 704 | − pPtrEnc->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, pParamExt); | |
| 705 | − EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 734 | + ChangeResolutionAndCheckStatistics (sEncParamBase, &sEncoderStatistics); | |
| 706 | 735 | |
| 707 | − // 3, code one frame | |
| 708 | − PrepareOneSrcFrame(); | |
| 709 | − iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | |
| 710 | − EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 711 | − iResult = pPtrEnc->GetOption (ENCODER_OPTION_GET_STATISTICS, &sEncoderStatistics); | |
| 712 | − EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 713 | − | |
| 714 | − EXPECT_EQ (sEncoderStatistics.uiInputFrameCount, static_cast<unsigned int> (3)); | |
| 715 | − EXPECT_EQ (sEncoderStatistics.uIDRSentNum, static_cast<unsigned int> (2)); | |
| 716 | − EXPECT_EQ (sEncoderStatistics.uiResolutionChangeTimes, static_cast<unsigned int> (knownResolutionChangeTimes)); | |
| 717 | − | |
| 718 | − EXPECT_EQ (sEncoderStatistics.uWidth, static_cast<unsigned int> (sEncParamBase.iPicWidth)); | |
| 719 | − EXPECT_EQ (sEncoderStatistics.uHeight, static_cast<unsigned int> (sEncParamBase.iPicHeight)); | |
| 736 | + GetValidEncParamBase (&sEncParamBase); | |
| 737 | + sEncParamBase.iPicWidth = (sEncParamBase.iPicWidth % 16) + 1; //try 1~16 | |
| 738 | + sEncParamBase.iPicHeight = (sEncParamBase.iPicHeight % 16) + 1; //try 1~16 | |
| 739 | + ChangeResolutionAndCheckStatistics (sEncParamBase, &sEncoderStatistics); | |
| 720 | 740 | |
| 721 | 741 | // 4, change log interval |
| 722 | 742 | int32_t iInterval = 0; |