History

add UT for LTR setopton and fix crash issue

ruil2 committed 12 years ago

Commit 7e8cde01 parent cef43e34 files · +125 −56Browse files

Showing the changes to test/encoder/EncUT_InterfaceTest.cpp (1 of 4 files). Show all

Unified · Split

test/encoder/EncUT_InterfaceTest.cpp+69−0
@@ -1,6 +1,8 @@
11 #include <gtest/gtest.h>
22 #include "codec_def.h"
33 #include "codec_api.h"
4+#include "utils/BufferedData.h"
5+#include "utils/FileInputStream.h"
46 #include "BaseEncoderTest.h"
57
68 class EncInterfaceCallTest : public ::testing::Test, public BaseEncoderTest {
@@ -12,6 +14,9 @@ class EncInterfaceCallTest : public ::testing::Test, public BaseEncoderTest { · 5 unmodified lines
1214 BaseEncoderTest::TearDown();
1315 };
1416
17+ virtual void onEncodeFrame (const SFrameBSInfo& frameInfo) {
18+ //nothing
19+ }
1520 //testing case
1621
1722 };
@@ -34,3 +39,67 @@ TEST_F (EncInterfaceCallTest, BaseParameterVerify) { · 16 unmodified lines
3439 uiTraceLevel = WELS_LOG_ERROR;
3540 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &uiTraceLevel);
3641 }
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+}

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