History

add interface UT for WelsEncoderEncodeParameterSets and fix previous value

Sijia Chen committed 12 years ago

Commit b6698011 parent 3a375862 files · +64 −3Browse files

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

Unified · Split

test/encoder/EncUT_EncoderExt.cpp+62−3
@@ -8,6 +8,16 @@ class EncoderInterfaceTest : public ::testing::Test { · 7 unmodified lines
88 #define MB_SIZE (16)
99 #define MAX_WIDTH (3840)
1010 #define MAX_HEIGHT (2160)
11+#define VALID_SIZE(iSize) (((iSize)>1)?(iSize):1)
12+
13+#define NAL_HEADER_BYTES (4)
14+#define NAL_TYPE (0x0F)
15+#define SPS_NAL_TYPE (7)
16+#define PPS_NAL_TYPE (8)
17+#define SUBSETSPS_NAL_TYPE (15)
18+#define GET_NAL_TYPE(pNalStart) (*(pNalStart+NAL_HEADER_BYTES) & NAL_TYPE)
19+#define IS_PARASET(iNalType) ((iNalType==SPS_NAL_TYPE) || (iNalType==PPS_NAL_TYPE) || (iNalType==SUBSETSPS_NAL_TYPE))
20+
1121 public:
1222 virtual void SetUp() {
1323 int rv = WelsCreateSVCEncoder (&pPtrEnc);
@@ -172,8 +182,10 @@ TEST_F (EncoderInterfaceTest, TestTemporalLayerSetting) { · 158 unmodified lines
172182
173183 void GetValidEncParamBase (SEncParamBase* pEncParamBase) {
174184 pEncParamBase->iUsageType = CAMERA_VIDEO_REAL_TIME;
175− pEncParamBase->iPicWidth = abs ((rand() * 2) + MB_SIZE) % (MAX_WIDTH + 1);
176− pEncParamBase->iPicHeight = abs ((rand() * 2) + MB_SIZE) % (MAX_HEIGHT + 1);
185+ pEncParamBase->iPicWidth = ((rand() * 2) % (MAX_WIDTH));
186+ pEncParamBase->iPicHeight = ((rand() * 2) % (MAX_HEIGHT));
187+ pEncParamBase->iPicWidth = VALID_SIZE(pEncParamBase->iPicWidth);
188+ pEncParamBase->iPicHeight = VALID_SIZE(pEncParamBase->iPicHeight);
177189 pEncParamBase->iTargetBitrate = rand() + 1; //!=0
178190 pEncParamBase->iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2
179191 pEncParamBase->fMaxFrameRate = rand() + 0.5f; //!=0
@@ -288,7 +300,6 @@ TEST_F (EncoderInterfaceTest, BasicInitializeTestAutoAdjustment) { · 108 unmodified lines
288300 EXPECT_GE (sEncParamBase.fMaxFrameRate, 1.0);
289301 }
290302
291−
292303 TEST_F (EncoderInterfaceTest, ForceIntraFrame) {
293304 SEncParamBase sEncParamBase;
294305 GetValidEncParamBase (&sEncParamBase);
@@ -354,3 +365,51 @@ TEST_F (EncoderInterfaceTest, ForceIntraFrameWithTemporal) { · 59 unmodified lines
354365 EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
355366 }
356367
368+TEST_F (EncoderInterfaceTest, EncodeParameterSets) {
369+ SEncParamBase sEncParamBase;
370+ GetValidEncParamBase (&sEncParamBase);
371+
372+ int iResult = pPtrEnc->Initialize (&sEncParamBase);
373+ EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
374+ if (iResult != cmResultSuccess) {
375+ fprintf (stderr, "Unexpected ParamBase? \
376+ iUsageType=%d, Pic=%dx%d, TargetBitrate=%d, iRCMode=%d, fMaxFrameRate=%.1f\n",
377+ sEncParamBase.iUsageType, sEncParamBase.iPicWidth, sEncParamBase.iPicHeight,
378+ sEncParamBase.iTargetBitrate, sEncParamBase.iRCMode, sEncParamBase.fMaxFrameRate);
379+ }
380+ PrepareOneSrcFrame();
381+ EncodeOneIDRandP (pPtrEnc);
382+
383+ //try EncodeParameterSets
384+ pPtrEnc->EncodeParameterSets (&sFbi);
385+ EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
386+ EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeInvalid));
387+
388+ //check the result
389+ int iNalType = 0;
390+ SLayerBSInfo* pLayerBsInfo;
391+ for (int i = 0; i < sFbi.iLayerNum; i++) {
392+ pLayerBsInfo = & (sFbi.sLayerInfo[i]);
393+ EXPECT_EQ (pLayerBsInfo->uiLayerType , static_cast<int> (NON_VIDEO_CODING_LAYER));
394+
395+ iNalType = GET_NAL_TYPE (pLayerBsInfo->pBsBuf);
396+ EXPECT_EQ (true, IS_PARASET (iNalType));
397+ for (int j = 0; j < (pLayerBsInfo->iNalCount - 1); j++) {
398+ iNalType = GET_NAL_TYPE (pLayerBsInfo->pBsBuf + pLayerBsInfo->pNalLengthInByte[j]);
399+ EXPECT_EQ (true, IS_PARASET (iNalType));
400+ }
401+ }
402+
403+ //try another P to make sure no impact on succeeding frames
404+ iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
405+ EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
406+ EXPECT_NE (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR));
407+
408+ pPtrEnc->Uninitialize();
409+ EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
410+}
411+
412+TEST_F (EncoderInterfaceTest, BasicReturnTypeTest) {
413+ //TODO
414+}
415+

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