Showing the changes to test/encoder/EncUT_EncoderExt.cpp (1 of 2 files). Show all
Unified · Split
| @@ -8,6 +8,16 @@ class EncoderInterfaceTest : public ::testing::Test { · 7 unmodified lines | ||
| 8 | 8 | #define MB_SIZE (16) |
| 9 | 9 | #define MAX_WIDTH (3840) |
| 10 | 10 | #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 | + | |
| 11 | 21 | public: |
| 12 | 22 | virtual void SetUp() { |
| 13 | 23 | int rv = WelsCreateSVCEncoder (&pPtrEnc); |
| @@ -172,8 +182,10 @@ TEST_F (EncoderInterfaceTest, TestTemporalLayerSetting) { · 158 unmodified lines | ||
| 172 | 182 | |
| 173 | 183 | void GetValidEncParamBase (SEncParamBase* pEncParamBase) { |
| 174 | 184 | 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); | |
| 177 | 189 | pEncParamBase->iTargetBitrate = rand() + 1; //!=0 |
| 178 | 190 | pEncParamBase->iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2 |
| 179 | 191 | pEncParamBase->fMaxFrameRate = rand() + 0.5f; //!=0 |
| @@ -288,7 +300,6 @@ TEST_F (EncoderInterfaceTest, BasicInitializeTestAutoAdjustment) { · 108 unmodified lines | ||
| 288 | 300 | EXPECT_GE (sEncParamBase.fMaxFrameRate, 1.0); |
| 289 | 301 | } |
| 290 | 302 | |
| 291 | − | |
| 292 | 303 | TEST_F (EncoderInterfaceTest, ForceIntraFrame) { |
| 293 | 304 | SEncParamBase sEncParamBase; |
| 294 | 305 | GetValidEncParamBase (&sEncParamBase); |
| @@ -354,3 +365,51 @@ TEST_F (EncoderInterfaceTest, ForceIntraFrameWithTemporal) { · 59 unmodified lines | ||
| 354 | 365 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 355 | 366 | } |
| 356 | 367 | |
| 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 | + | |