[Encoder UT] Interface: EncoderEncodeParameterSets
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 | #define MB_SIZE (16) | 8 | #define MB_SIZE (16) |
| 9 | #define MAX_WIDTH (3840) | 9 | #define MAX_WIDTH (3840) |
| 10 | #define MAX_HEIGHT (2160) | 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 | public: | 21 | public: |
| 12 | virtual void SetUp() { | 22 | virtual void SetUp() { |
| 13 | int rv = WelsCreateSVCEncoder (&pPtrEnc); | 23 | int rv = WelsCreateSVCEncoder (&pPtrEnc); |
| @@ -172,8 +182,10 @@ TEST_F (EncoderInterfaceTest, TestTemporalLayerSetting) { · 158 unmodified lines | |||
| 172 | 182 | ||
| 173 | void GetValidEncParamBase (SEncParamBase* pEncParamBase) { | 183 | void GetValidEncParamBase (SEncParamBase* pEncParamBase) { |
| 174 | pEncParamBase->iUsageType = CAMERA_VIDEO_REAL_TIME; | 184 | pEncParamBase->iUsageType = CAMERA_VIDEO_REAL_TIME; |
| 175 | pEncParamBase->iPicWidth = abs ((rand() * 2) + MB_SIZE) % (MAX_WIDTH + 1); | 185 | pEncParamBase->iPicWidth = ((rand() * 2) % (MAX_WIDTH)); |
| 176 | pEncParamBase->iPicHeight = abs ((rand() * 2) + MB_SIZE) % (MAX_HEIGHT + 1); | 186 | pEncParamBase->iPicHeight = ((rand() * 2) % (MAX_HEIGHT)); |
| 187 | pEncParamBase->iPicWidth = VALID_SIZE(pEncParamBase->iPicWidth); | ||
| 188 | pEncParamBase->iPicHeight = VALID_SIZE(pEncParamBase->iPicHeight); | ||
| 177 | pEncParamBase->iTargetBitrate = rand() + 1; //!=0 | 189 | pEncParamBase->iTargetBitrate = rand() + 1; //!=0 |
| 178 | pEncParamBase->iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2 | 190 | pEncParamBase->iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2 |
| 179 | pEncParamBase->fMaxFrameRate = rand() + 0.5f; //!=0 | 191 | pEncParamBase->fMaxFrameRate = rand() + 0.5f; //!=0 |
| @@ -293,7 +305,6 @@ TEST_F (EncoderInterfaceTest, BasicInitializeTestAutoAdjustment) { · 113 unmodified lines | |||
| 293 | EXPECT_GE (sEncParamBase.fMaxFrameRate, 1.0); | 305 | EXPECT_GE (sEncParamBase.fMaxFrameRate, 1.0); |
| 294 | } | 306 | } |
| 295 | 307 | ||
| 296 | |||
| 297 | TEST_F (EncoderInterfaceTest, ForceIntraFrame) { | 308 | TEST_F (EncoderInterfaceTest, ForceIntraFrame) { |
| 298 | SEncParamBase sEncParamBase; | 309 | SEncParamBase sEncParamBase; |
| 299 | GetValidEncParamBase (&sEncParamBase); | 310 | GetValidEncParamBase (&sEncParamBase); |
| @@ -359,3 +370,51 @@ TEST_F (EncoderInterfaceTest, ForceIntraFrameWithTemporal) { · 59 unmodified lines | |||
| 359 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 370 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 360 | } | 371 | } |
| 361 | 372 | ||
| 373 | TEST_F (EncoderInterfaceTest, EncodeParameterSets) { | ||
| 374 | SEncParamBase sEncParamBase; | ||
| 375 | GetValidEncParamBase (&sEncParamBase); | ||
| 376 | |||
| 377 | int iResult = pPtrEnc->Initialize (&sEncParamBase); | ||
| 378 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | ||
| 379 | if (iResult != cmResultSuccess) { | ||
| 380 | fprintf (stderr, "Unexpected ParamBase? \ | ||
| 381 | iUsageType=%d, Pic=%dx%d, TargetBitrate=%d, iRCMode=%d, fMaxFrameRate=%.1f\n", | ||
| 382 | sEncParamBase.iUsageType, sEncParamBase.iPicWidth, sEncParamBase.iPicHeight, | ||
| 383 | sEncParamBase.iTargetBitrate, sEncParamBase.iRCMode, sEncParamBase.fMaxFrameRate); | ||
| 384 | } | ||
| 385 | PrepareOneSrcFrame(); | ||
| 386 | EncodeOneIDRandP (pPtrEnc); | ||
| 387 | |||
| 388 | //try EncodeParameterSets | ||
| 389 | pPtrEnc->EncodeParameterSets (&sFbi); | ||
| 390 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | ||
| 391 | EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeInvalid)); | ||
| 392 | |||
| 393 | //check the result | ||
| 394 | int iNalType = 0; | ||
| 395 | SLayerBSInfo* pLayerBsInfo; | ||
| 396 | for (int i = 0; i < sFbi.iLayerNum; i++) { | ||
| 397 | pLayerBsInfo = & (sFbi.sLayerInfo[i]); | ||
| 398 | EXPECT_EQ (pLayerBsInfo->uiLayerType , static_cast<int> (NON_VIDEO_CODING_LAYER)); | ||
| 399 | |||
| 400 | iNalType = GET_NAL_TYPE (pLayerBsInfo->pBsBuf); | ||
| 401 | EXPECT_EQ (true, IS_PARASET (iNalType)); | ||
| 402 | for (int j = 0; j < (pLayerBsInfo->iNalCount - 1); j++) { | ||
| 403 | iNalType = GET_NAL_TYPE (pLayerBsInfo->pBsBuf + pLayerBsInfo->pNalLengthInByte[j]); | ||
| 404 | EXPECT_EQ (true, IS_PARASET (iNalType)); | ||
| 405 | } | ||
| 406 | } | ||
| 407 | |||
| 408 | //try another P to make sure no impact on succeeding frames | ||
| 409 | iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | ||
| 410 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | ||
| 411 | EXPECT_NE (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR)); | ||
| 412 | |||
| 413 | pPtrEnc->Uninitialize(); | ||
| 414 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | ||
| 415 | } | ||
| 416 | |||
| 417 | TEST_F (EncoderInterfaceTest, BasicReturnTypeTest) { | ||
| 418 | //TODO | ||
| 419 | } | ||
| 420 | |||