Showing the changes to test/encoder/EncUT_InterfaceTest.cpp (1 of 4 files). Show all
Unified · Split
| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | #include <gtest/gtest.h> |
| 2 | 2 | #include "codec_def.h" |
| 3 | 3 | #include "codec_api.h" |
| 4 | +#include "utils/BufferedData.h" | |
| 5 | +#include "utils/FileInputStream.h" | |
| 4 | 6 | #include "BaseEncoderTest.h" |
| 5 | 7 | |
| 6 | 8 | class EncInterfaceCallTest : public ::testing::Test, public BaseEncoderTest { |
| @@ -12,6 +14,9 @@ class EncInterfaceCallTest : public ::testing::Test, public BaseEncoderTest { · 5 unmodified lines | ||
| 12 | 14 | BaseEncoderTest::TearDown(); |
| 13 | 15 | }; |
| 14 | 16 | |
| 17 | + virtual void onEncodeFrame (const SFrameBSInfo& frameInfo) { | |
| 18 | + //nothing | |
| 19 | + } | |
| 15 | 20 | //testing case |
| 16 | 21 | |
| 17 | 22 | }; |
| @@ -34,3 +39,67 @@ TEST_F (EncInterfaceCallTest, BaseParameterVerify) { · 16 unmodified lines | ||
| 34 | 39 | uiTraceLevel = WELS_LOG_ERROR; |
| 35 | 40 | encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &uiTraceLevel); |
| 36 | 41 | } |
| 42 | + | |
| 43 | +void outputData() { | |
| 44 | + | |
| 45 | +} | |
| 46 | + | |
| 47 | +TEST_F (EncInterfaceCallTest, SetOptionLTR) { | |
| 48 | + | |
| 49 | + int iTotalFrameNum = 100; | |
| 50 | + int iFrameNum = 0; | |
| 51 | + int frameSize = 0; | |
| 52 | + int ret = cmResultSuccess; | |
| 53 | + int width = 320; | |
| 54 | + int height = 192; | |
| 55 | + | |
| 56 | + | |
| 57 | + SEncParamBase baseparam; | |
| 58 | + memset (&baseparam, 0, sizeof (SEncParamBase)); | |
| 59 | + | |
| 60 | + baseparam.iUsageType = CAMERA_VIDEO_REAL_TIME; | |
| 61 | + baseparam.fMaxFrameRate = 12; | |
| 62 | + baseparam.iPicWidth = width; | |
| 63 | + baseparam.iPicHeight = height; | |
| 64 | + baseparam.iTargetBitrate = 5000000; | |
| 65 | + encoder_->Initialize (&baseparam); | |
| 66 | + | |
| 67 | + frameSize = width * height * 3 / 2; | |
| 68 | + | |
| 69 | + BufferedData buf; | |
| 70 | + buf.SetLength (frameSize); | |
| 71 | + ASSERT_TRUE (buf.Length() == (size_t)frameSize); | |
| 72 | + | |
| 73 | + SFrameBSInfo info; | |
| 74 | + memset (&info, 0, sizeof (SFrameBSInfo)); | |
| 75 | + | |
| 76 | + SSourcePicture pic; | |
| 77 | + memset (&pic, 0, sizeof (SSourcePicture)); | |
| 78 | + pic.iPicWidth = width; | |
| 79 | + pic.iPicHeight = height; | |
| 80 | + pic.iColorFormat = videoFormatI420; | |
| 81 | + pic.iStride[0] = pic.iPicWidth; | |
| 82 | + pic.iStride[1] = pic.iStride[2] = pic.iPicWidth >> 1; | |
| 83 | + pic.pData[0] = buf.data(); | |
| 84 | + pic.pData[1] = pic.pData[0] + width * height; | |
| 85 | + pic.pData[2] = pic.pData[1] + (width * height >> 2); | |
| 86 | + | |
| 87 | + SLTRConfig config; | |
| 88 | + config.bEnableLongTermReference = true; | |
| 89 | + config.iLTRRefNum = rand() % 4; | |
| 90 | + encoder_->SetOption (ENCODER_OPTION_LTR, &config); | |
| 91 | + do { | |
| 92 | + FileInputStream fileStream; | |
| 93 | + ASSERT_TRUE (fileStream.Open ("res/CiscoVT2people_320x192_12fps.yuv")); | |
| 94 | + | |
| 95 | + while (fileStream.read (buf.data(), frameSize) == frameSize) { | |
| 96 | + ret = encoder_->EncodeFrame (&pic, &info); | |
| 97 | + ASSERT_TRUE (ret == cmResultSuccess); | |
| 98 | + if (info.eFrameType != videoFrameTypeSkip && this != NULL) { | |
| 99 | + this->onEncodeFrame (info); | |
| 100 | + iFrameNum++; | |
| 101 | + } | |
| 102 | + } | |
| 103 | + } while (iFrameNum < iTotalFrameNum); | |
| 104 | + | |
| 105 | +} | |