Showing the changes to test/encoder/EncUT_EncoderExt.cpp (1 of 1 file). Show all
Unified · Split
| @@ -45,6 +45,7 @@ class EncoderInterfaceTest : public ::testing::Test { · 44 unmodified lines | ||
| 45 | 45 | void TemporalLayerSettingTest(); |
| 46 | 46 | void EncodeOneFrame (SEncParamBase* pEncParamBase); |
| 47 | 47 | void PrepareOneSrcFrame(); |
| 48 | + void EncodeOneIDRandP (ISVCEncoder* pPtrEnc); | |
| 48 | 49 | |
| 49 | 50 | public: |
| 50 | 51 | ISVCEncoder* pPtrEnc; |
| @@ -98,7 +99,17 @@ void EncoderInterfaceTest::EncodeOneFrame (SEncParamBase* pEncParamBase) { · 47 unmodified lines | ||
| 98 | 99 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 99 | 100 | } |
| 100 | 101 | |
| 102 | +void EncoderInterfaceTest::EncodeOneIDRandP (ISVCEncoder* pPtrEnc) { | |
| 103 | + int iResult; | |
| 104 | + | |
| 105 | + iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | |
| 106 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 107 | + EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR)); | |
| 101 | 108 | |
| 109 | + iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | |
| 110 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 111 | + EXPECT_NE (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR)); | |
| 112 | +} | |
| 102 | 113 | |
| 103 | 114 | void EncoderInterfaceTest::TemporalLayerSettingTest() { |
| 104 | 115 | |
| @@ -163,13 +174,14 @@ TEST_F (EncoderInterfaceTest, TestTemporalLayerSetting) { · 58 unmodified lines | ||
| 163 | 174 | |
| 164 | 175 | void GetValidEncParamBase (SEncParamBase* pEncParamBase) { |
| 165 | 176 | pEncParamBase->iUsageType = CAMERA_VIDEO_REAL_TIME; |
| 166 | − pEncParamBase->iPicWidth = abs ((rand() * 2) + MB_SIZE) % (MAX_WIDTH+1); | |
| 167 | − pEncParamBase->iPicHeight = abs ((rand() * 2) + MB_SIZE) % (MAX_HEIGHT+1); | |
| 177 | + pEncParamBase->iPicWidth = abs ((rand() * 2) + MB_SIZE) % (MAX_WIDTH + 1); | |
| 178 | + pEncParamBase->iPicHeight = abs ((rand() * 2) + MB_SIZE) % (MAX_HEIGHT + 1); | |
| 168 | 179 | pEncParamBase->iTargetBitrate = rand() + 1; //!=0 |
| 169 | 180 | pEncParamBase->iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2 |
| 170 | 181 | pEncParamBase->fMaxFrameRate = rand() + 0.5f; //!=0 |
| 171 | 182 | } |
| 172 | 183 | |
| 184 | + | |
| 173 | 185 | TEST_F (EncoderInterfaceTest, BasicInitializeTest) { |
| 174 | 186 | SEncParamBase sEncParamBase; |
| 175 | 187 | GetValidEncParamBase (&sEncParamBase); |
| @@ -178,7 +190,7 @@ TEST_F (EncoderInterfaceTest, BasicInitializeTest) { · 2 unmodified lines | ||
| 178 | 190 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 179 | 191 | if (iResult != cmResultSuccess) { |
| 180 | 192 | fprintf (stderr, "Unexpected ParamBase? \ |
| 181 | − iUsageType=%d, Pic=%dx%d, TargetBitrate=%d, iRCMode=%d, fMaxFrameRate=%.1f\n", | |
| 193 | + iUsageType=%d, Pic=%dx%d, TargetBitrate=%d, iRCMode=%d, fMaxFrameRate=%.1f\n", | |
| 182 | 194 | sEncParamBase.iUsageType, sEncParamBase.iPicWidth, sEncParamBase.iPicHeight, |
| 183 | 195 | sEncParamBase.iTargetBitrate, sEncParamBase.iRCMode, sEncParamBase.fMaxFrameRate); |
| 184 | 196 | } |
| @@ -193,8 +205,6 @@ TEST_F (EncoderInterfaceTest, BasicInitializeTest) { · 8 unmodified lines | ||
| 193 | 205 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 194 | 206 | } |
| 195 | 207 | |
| 196 | − | |
| 197 | − | |
| 198 | 208 | TEST_F (EncoderInterfaceTest, BasicInitializeTestFalse) { |
| 199 | 209 | int iResult; |
| 200 | 210 | SEncParamBase sEncParamBase; |
| @@ -280,3 +290,70 @@ TEST_F (EncoderInterfaceTest, BasicInitializeTestAutoAdjustment) { · 79 unmodified lines | ||
| 280 | 290 | EXPECT_LE (sEncParamBase.fMaxFrameRate, 30.0); |
| 281 | 291 | EXPECT_GE (sEncParamBase.fMaxFrameRate, 1.0); |
| 282 | 292 | } |
| 293 | + | |
| 294 | + | |
| 295 | +TEST_F (EncoderInterfaceTest, ForceIntraFrame) { | |
| 296 | + SEncParamBase sEncParamBase; | |
| 297 | + GetValidEncParamBase (&sEncParamBase); | |
| 298 | + | |
| 299 | + int iResult = pPtrEnc->Initialize (&sEncParamBase); | |
| 300 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 301 | + if (iResult != cmResultSuccess) { | |
| 302 | + fprintf (stderr, "Unexpected ParamBase? \ | |
| 303 | + iUsageType=%d, Pic=%dx%d, TargetBitrate=%d, iRCMode=%d, fMaxFrameRate=%.1f\n", | |
| 304 | + sEncParamBase.iUsageType, sEncParamBase.iPicWidth, sEncParamBase.iPicHeight, | |
| 305 | + sEncParamBase.iTargetBitrate, sEncParamBase.iRCMode, sEncParamBase.fMaxFrameRate); | |
| 306 | + } | |
| 307 | + | |
| 308 | + PrepareOneSrcFrame(); | |
| 309 | + | |
| 310 | + bool bIDR = true; | |
| 311 | + pPtrEnc->ForceIntraFrame (bIDR); | |
| 312 | + EncodeOneIDRandP (pPtrEnc); | |
| 313 | + | |
| 314 | + //call next frame to be IDR | |
| 315 | + pPtrEnc->ForceIntraFrame (bIDR); | |
| 316 | + EncodeOneIDRandP (pPtrEnc); | |
| 317 | + | |
| 318 | + pPtrEnc->Uninitialize(); | |
| 319 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 320 | +} | |
| 321 | + | |
| 322 | +TEST_F (EncoderInterfaceTest, ForceIntraFrameWithTemporal) { | |
| 323 | + SEncParamExt sEncParamExt; | |
| 324 | + pPtrEnc->GetDefaultParams (&sEncParamExt); | |
| 325 | + sEncParamExt.iUsageType = CAMERA_VIDEO_REAL_TIME; | |
| 326 | + sEncParamExt.iPicWidth = abs ((rand() * 2) + MB_SIZE) % (MAX_WIDTH + 1); | |
| 327 | + sEncParamExt.iPicHeight = abs ((rand() * 2) + MB_SIZE) % (MAX_HEIGHT + 1); | |
| 328 | + sEncParamExt.iTargetBitrate = rand() + 1; //!=0 | |
| 329 | + sEncParamExt.iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2 | |
| 330 | + sEncParamExt.fMaxFrameRate = rand() + 0.5f; //!=0 | |
| 331 | + sEncParamExt.sSpatialLayers[0].iVideoWidth = sEncParamExt.iPicWidth; | |
| 332 | + sEncParamExt.sSpatialLayers[0].iVideoHeight = sEncParamExt.iPicHeight; | |
| 333 | + sEncParamExt.sSpatialLayers[0].iSpatialBitrate = sEncParamExt.iTargetBitrate; | |
| 334 | + | |
| 335 | + int iTargetTemporalLayerNum = rand() % MAX_TEMPORAL_LAYER_NUM; | |
| 336 | + sEncParamExt.iTemporalLayerNum = (iTargetTemporalLayerNum > 2) ? iTargetTemporalLayerNum : 2; | |
| 337 | + | |
| 338 | + int iResult = pPtrEnc->InitializeExt (&sEncParamExt); | |
| 339 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 340 | + if (iResult != cmResultSuccess) { | |
| 341 | + fprintf (stderr, "Unexpected ParamBase? \ | |
| 342 | + iUsageType=%d, Pic=%dx%d, TargetBitrate=%d, iRCMode=%d, fMaxFrameRate=%.1f\n", | |
| 343 | + sEncParamExt.iUsageType, sEncParamExt.iPicWidth, sEncParamExt.iPicHeight, | |
| 344 | + sEncParamExt.iTargetBitrate, sEncParamExt.iRCMode, sEncParamExt.fMaxFrameRate); | |
| 345 | + } | |
| 346 | + | |
| 347 | + PrepareOneSrcFrame(); | |
| 348 | + | |
| 349 | + bool bIDR = true; | |
| 350 | + EncodeOneIDRandP (pPtrEnc); | |
| 351 | + | |
| 352 | + //call next frame to be IDR | |
| 353 | + pPtrEnc->ForceIntraFrame (bIDR); | |
| 354 | + EncodeOneIDRandP (pPtrEnc); | |
| 355 | + | |
| 356 | + pPtrEnc->Uninitialize(); | |
| 357 | + EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | |
| 358 | +} | |
| 359 | + | |