Showing the changes to test/encoder/EncUT_EncoderExt.cpp (1 of 5 files). Show all
Unified · Split
| @@ -274,128 +274,128 @@ TEST_F (EncoderInterfaceTest, EncoderOptionSetTest) { · 273 unmodified lines | |||
| 274 | pPtrEnc->SetOption (ENCODER_OPTION_TRACE_LEVEL, &uiTraceLevel); | 274 | pPtrEnc->SetOption (ENCODER_OPTION_TRACE_LEVEL, &uiTraceLevel); |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | TEST_F (EncoderInterfaceTest, TemporalLayerSettingTest) { | 277 | //TEST_F (EncoderInterfaceTest, TemporalLayerSettingTest) { |
| 278 | 278 | // | |
| 279 | pParamExt->iPicWidth = 1280; | 279 | // pParamExt->iPicWidth = 1280; |
| 280 | pParamExt->iPicHeight = 720; | 280 | // pParamExt->iPicHeight = 720; |
| 281 | m_iWidth = pParamExt->iPicWidth; | 281 | // m_iWidth = pParamExt->iPicWidth; |
| 282 | m_iHeight = pParamExt->iPicHeight; | 282 | // m_iHeight = pParamExt->iPicHeight; |
| 283 | pParamExt->iTargetBitrate = 60000; | 283 | // pParamExt->iTargetBitrate = 60000; |
| 284 | pParamExt->sSpatialLayers[0].iVideoHeight = pParamExt->iPicHeight; | 284 | // pParamExt->sSpatialLayers[0].iVideoHeight = pParamExt->iPicHeight; |
| 285 | pParamExt->sSpatialLayers[0].iVideoWidth = pParamExt->iPicWidth; | 285 | // pParamExt->sSpatialLayers[0].iVideoWidth = pParamExt->iPicWidth; |
| 286 | pParamExt->sSpatialLayers[0].iSpatialBitrate = 50000; | 286 | // pParamExt->sSpatialLayers[0].iSpatialBitrate = 50000; |
| 287 | pParamExt->iTemporalLayerNum = 1; | 287 | // pParamExt->iTemporalLayerNum = 1; |
| 288 | pParamExt->iSpatialLayerNum = 1; | 288 | // pParamExt->iSpatialLayerNum = 1; |
| 289 | pParamExt->iNumRefFrame = AUTO_REF_PIC_COUNT; | 289 | // pParamExt->iNumRefFrame = AUTO_REF_PIC_COUNT; |
| 290 | 290 | // | |
| 291 | for (int i = 0; i < 2; i++) { | 291 | // for (int i = 0; i < 2; i++) { |
| 292 | pParamExt->iUsageType = ((i == 0) ? SCREEN_CONTENT_REAL_TIME : CAMERA_VIDEO_REAL_TIME); | 292 | // pParamExt->iUsageType = ((i == 0) ? SCREEN_CONTENT_REAL_TIME : CAMERA_VIDEO_REAL_TIME); |
| 293 | int iResult = pPtrEnc->InitializeExt (pParamExt); | 293 | // int iResult = pPtrEnc->InitializeExt (pParamExt); |
| 294 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 294 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 295 | 295 | // | |
| 296 | PrepareOneSrcFrame(); | 296 | // PrepareOneSrcFrame(); |
| 297 | 297 | // | |
| 298 | iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | 298 | // iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); |
| 299 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 299 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 300 | EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR)); | 300 | // EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR)); |
| 301 | 301 | // | |
| 302 | pSrcPic->uiTimeStamp = 30; | 302 | // pSrcPic->uiTimeStamp = 30; |
| 303 | iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | 303 | // iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); |
| 304 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 304 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 305 | EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeP)); | 305 | // EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeP)); |
| 306 | 306 | // | |
| 307 | ENCODER_OPTION eOptionId = ENCODER_OPTION_SVC_ENCODE_PARAM_EXT; | 307 | // ENCODER_OPTION eOptionId = ENCODER_OPTION_SVC_ENCODE_PARAM_EXT; |
| 308 | iResult = pPtrEnc->GetOption (eOptionId, pOption); | 308 | // iResult = pPtrEnc->GetOption (eOptionId, pOption); |
| 309 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 309 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 310 | pOption ->iTemporalLayerNum = 4; | 310 | // pOption ->iTemporalLayerNum = 4; |
| 311 | 311 | // | |
| 312 | iResult = pPtrEnc->SetOption (eOptionId, pOption); | 312 | // iResult = pPtrEnc->SetOption (eOptionId, pOption); |
| 313 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 313 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 314 | 314 | // | |
| 315 | pSrcPic->uiTimeStamp = 60; | 315 | // pSrcPic->uiTimeStamp = 60; |
| 316 | iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | 316 | // iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); |
| 317 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 317 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 318 | EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR)); | 318 | // EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR)); |
| 319 | 319 | // | |
| 320 | pOption ->iTemporalLayerNum = 2; | 320 | // pOption ->iTemporalLayerNum = 2; |
| 321 | iResult = pPtrEnc->SetOption (eOptionId, pOption); | 321 | // iResult = pPtrEnc->SetOption (eOptionId, pOption); |
| 322 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 322 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 323 | pSrcPic->uiTimeStamp = 90; | 323 | // pSrcPic->uiTimeStamp = 90; |
| 324 | iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | 324 | // iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); |
| 325 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 325 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 326 | EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeP)); | 326 | // EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeP)); |
| 327 | 327 | // | |
| 328 | pOption ->iTemporalLayerNum = 4; | 328 | // pOption ->iTemporalLayerNum = 4; |
| 329 | iResult = pPtrEnc->SetOption (eOptionId, pOption); | 329 | // iResult = pPtrEnc->SetOption (eOptionId, pOption); |
| 330 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 330 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 331 | pSrcPic->uiTimeStamp = 120; | 331 | // pSrcPic->uiTimeStamp = 120; |
| 332 | iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | 332 | // iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); |
| 333 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 333 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 334 | EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeP)); | 334 | // EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeP)); |
| 335 | 335 | // | |
| 336 | //change backgrouddetection and qp | 336 | // //change backgrouddetection and qp |
| 337 | pOption ->bEnableBackgroundDetection = !pOption ->bEnableBackgroundDetection; | 337 | // pOption ->bEnableBackgroundDetection = !pOption ->bEnableBackgroundDetection; |
| 338 | iResult = pPtrEnc->SetOption (eOptionId, pOption); | 338 | // iResult = pPtrEnc->SetOption (eOptionId, pOption); |
| 339 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 339 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 340 | pSrcPic->uiTimeStamp = 150; | 340 | // pSrcPic->uiTimeStamp = 150; |
| 341 | iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | 341 | // iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); |
| 342 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 342 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 343 | 343 | // | |
| 344 | pOption ->bEnableAdaptiveQuant = !pOption ->bEnableAdaptiveQuant; | 344 | // pOption ->bEnableAdaptiveQuant = !pOption ->bEnableAdaptiveQuant; |
| 345 | iResult = pPtrEnc->SetOption (eOptionId, pOption); | 345 | // iResult = pPtrEnc->SetOption (eOptionId, pOption); |
| 346 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 346 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 347 | pSrcPic->uiTimeStamp = 180; | 347 | // pSrcPic->uiTimeStamp = 180; |
| 348 | iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | 348 | // iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); |
| 349 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 349 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 350 | 350 | // | |
| 351 | iResult = pPtrEnc->Uninitialize(); | 351 | // iResult = pPtrEnc->Uninitialize(); |
| 352 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 352 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 353 | } | 353 | // } |
| 354 | 354 | // | |
| 355 | InitializeParamExt(); | 355 | // InitializeParamExt(); |
| 356 | pParamExt->iUsageType = (rand() % 2) ? SCREEN_CONTENT_REAL_TIME : CAMERA_VIDEO_REAL_TIME; | 356 | // pParamExt->iUsageType = (rand() % 2) ? SCREEN_CONTENT_REAL_TIME : CAMERA_VIDEO_REAL_TIME; |
| 357 | pParamExt->iRCMode = (rand() % 2) ? RC_BITRATE_MODE : RC_QUALITY_MODE; | 357 | // pParamExt->iRCMode = (rand() % 2) ? RC_BITRATE_MODE : RC_QUALITY_MODE; |
| 358 | 358 | // | |
| 359 | int iResult = pPtrEnc->InitializeExt (pParamExt); | 359 | // int iResult = pPtrEnc->InitializeExt (pParamExt); |
| 360 | const int kiFrameNumber = TEST_FRAMES; | 360 | // const int kiFrameNumber = TEST_FRAMES; |
| 361 | 361 | // | |
| 362 | m_iWidth = pParamExt->iPicWidth; | 362 | // m_iWidth = pParamExt->iPicWidth; |
| 363 | m_iHeight = pParamExt->iPicHeight; | 363 | // m_iHeight = pParamExt->iPicHeight; |
| 364 | m_iPicResSize = m_iWidth * m_iHeight * 3 >> 1; | 364 | // m_iPicResSize = m_iWidth * m_iHeight * 3 >> 1; |
| 365 | delete []pYUV; | 365 | // delete []pYUV; |
| 366 | pYUV = new unsigned char [m_iPicResSize]; | 366 | // pYUV = new unsigned char [m_iPicResSize]; |
| 367 | ASSERT_TRUE (pYUV != NULL); | 367 | // ASSERT_TRUE (pYUV != NULL); |
| 368 | PrepareOneSrcFrame(); | 368 | // PrepareOneSrcFrame(); |
| 369 | 369 | // | |
| 370 | ENCODER_OPTION eOptionId = ENCODER_OPTION_SVC_ENCODE_PARAM_EXT; | 370 | // ENCODER_OPTION eOptionId = ENCODER_OPTION_SVC_ENCODE_PARAM_EXT; |
| 371 | memcpy (pOption, pParamExt, sizeof (SEncParamExt)); | 371 | // memcpy (pOption, pParamExt, sizeof (SEncParamExt)); |
| 372 | 372 | // | |
| 373 | for (int i = 0; i < kiFrameNumber; i ++) { | 373 | // for (int i = 0; i < kiFrameNumber; i ++) { |
| 374 | if ((i % 7) == 0) { | 374 | // if ((i % 7) == 0) { |
| 375 | if (pOption->iTemporalLayerNum < 4) { | 375 | // if (pOption->iTemporalLayerNum < 4) { |
| 376 | pOption->iTemporalLayerNum++; | 376 | // pOption->iTemporalLayerNum++; |
| 377 | } else { | 377 | // } else { |
| 378 | pOption->iTemporalLayerNum--; | 378 | // pOption->iTemporalLayerNum--; |
| 379 | } | 379 | // } |
| 380 | iResult = pPtrEnc->SetOption (eOptionId, pOption); | 380 | // iResult = pPtrEnc->SetOption (eOptionId, pOption); |
| 381 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 381 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 382 | pSrcPic->uiTimeStamp += 30; | 382 | // pSrcPic->uiTimeStamp += 30; |
| 383 | } | 383 | // } |
| 384 | 384 | // | |
| 385 | int iStartX = rand() % (m_iPicResSize >> 1); | 385 | // int iStartX = rand() % (m_iPicResSize >> 1); |
| 386 | int iEndX = (iStartX + (rand() % MEM_VARY_SIZE)) % m_iPicResSize; | 386 | // int iEndX = (iStartX + (rand() % MEM_VARY_SIZE)) % m_iPicResSize; |
| 387 | for (int j = iStartX; j < iEndX; j++) | 387 | // for (int j = iStartX; j < iEndX; j++) |
| 388 | pYUV[j] = rand() % 256; | 388 | // pYUV[j] = rand() % 256; |
| 389 | 389 | // | |
| 390 | iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); | 390 | // iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi); |
| 391 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 391 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 392 | pSrcPic->uiTimeStamp += 30; | 392 | // pSrcPic->uiTimeStamp += 30; |
| 393 | } | 393 | // } |
| 394 | 394 | // | |
| 395 | iResult = pPtrEnc->Uninitialize(); | 395 | // iResult = pPtrEnc->Uninitialize(); |
| 396 | EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); | 396 | // EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess)); |
| 397 | 397 | // | |
| 398 | } | 398 | //} |
| 399 | 399 | ||
| 400 | TEST_F (EncoderInterfaceTest, MemoryCheckTest) { | 400 | TEST_F (EncoderInterfaceTest, MemoryCheckTest) { |
| 401 | 401 | ||