mem mem decstatictis time change time change set decTime=0
Showing the changes to test/decoder/DecUT_DecExt.cpp (1 of 9 files). Show all
Unified · Split
| @@ -30,6 +30,8 @@ class DecoderInterfaceTest : public ::testing::Test { · 29 unmodified lines | ||
| 30 | 30 | void Uninit(); |
| 31 | 31 | //Mock input data for test |
| 32 | 32 | void MockPacketType (const EWelsNalUnitType eNalUnitType, const int iPacketLength); |
| 33 | + //Decoder real bitstream | |
| 34 | + void DecoderBs (const char* sFileName); | |
| 33 | 35 | //Test Initialize/Uninitialize |
| 34 | 36 | void TestInitUninit(); |
| 35 | 37 | //DECODER_OPTION_DATAFORMAT |
| @@ -56,6 +58,8 @@ class DecoderInterfaceTest : public ::testing::Test { · 20 unmodified lines | ||
| 56 | 58 | void TestTraceCallback(); |
| 57 | 59 | //DECODER_OPTION_TRACE_CALLBACK_CONTEXT |
| 58 | 60 | void TestTraceCallbackContext(); |
| 61 | + //DECODER_OPTION_GET_DECODER_STATICTIS | |
| 62 | + void TestGetDecStatistics(); | |
| 59 | 63 | //Do whole tests here |
| 60 | 64 | void DecoderInterfaceAll(); |
| 61 | 65 | |
| @@ -104,6 +108,58 @@ void DecoderInterfaceTest::Uninit() { · 42 unmodified lines | ||
| 104 | 108 | m_iBufLength = 0; |
| 105 | 109 | } |
| 106 | 110 | |
| 111 | +void DecoderInterfaceTest::DecoderBs (const char* sFileName) { | |
| 112 | + | |
| 113 | + uint8_t* pBuf = NULL; | |
| 114 | + int32_t iBufPos = 0; | |
| 115 | + int32_t iFileSize; | |
| 116 | + int32_t i = 0; | |
| 117 | + int32_t iSliceSize; | |
| 118 | + int32_t iSliceIndex = 0; | |
| 119 | + int32_t iEndOfStreamFlag = 0; | |
| 120 | + FILE* pH264File; | |
| 121 | + uint8_t uiStartCode[4] = {0, 0, 0, 1}; | |
| 122 | + | |
| 123 | +#if defined(ANDROID_NDK) | |
| 124 | + std::string filename = std::string ("/sdcard/") + sFileName; | |
| 125 | + ASSERT_TRUE (pH264File = fopen (filename.c_str())); | |
| 126 | +#else | |
| 127 | + ASSERT_TRUE (pH264File = fopen (sFileName, "rb")); | |
| 128 | +#endif | |
| 129 | + fseek (pH264File, 0L, SEEK_END); | |
| 130 | + iFileSize = (int32_t) ftell (pH264File); | |
| 131 | + fseek (pH264File, 0L, SEEK_SET); | |
| 132 | + pBuf = new uint8_t[iFileSize + 4]; | |
| 133 | + fread (pBuf, 1, iFileSize, pH264File); | |
| 134 | + memcpy (pBuf + iFileSize, &uiStartCode[0], 4); //confirmed_safe_unsafe_usage | |
| 135 | + while (true) { | |
| 136 | + if (iBufPos >= iFileSize) { | |
| 137 | + iEndOfStreamFlag = true; | |
| 138 | + if (iEndOfStreamFlag) | |
| 139 | + m_pDec->SetOption (DECODER_OPTION_END_OF_STREAM, (void*)&iEndOfStreamFlag); | |
| 140 | + break; | |
| 141 | + } | |
| 142 | + for (i = 0; i < iFileSize; i++) { | |
| 143 | + if ((pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 0 && pBuf[iBufPos + i + 3] == 1 | |
| 144 | + && i > 0)) { | |
| 145 | + break; | |
| 146 | + } | |
| 147 | + } | |
| 148 | + iSliceSize = i; | |
| 149 | + m_pDec->DecodeFrame2 (pBuf + iBufPos, iSliceSize, m_pData, &m_sBufferInfo); | |
| 150 | + m_pDec->DecodeFrame2 (NULL, 0, m_pData, &m_sBufferInfo); | |
| 151 | + iBufPos += iSliceSize; | |
| 152 | + ++ iSliceIndex; | |
| 153 | + } | |
| 154 | + | |
| 155 | + fclose (pH264File); | |
| 156 | + if (pBuf) { | |
| 157 | + delete[] pBuf; | |
| 158 | + pBuf = NULL; | |
| 159 | + } | |
| 160 | + | |
| 161 | + | |
| 162 | +} | |
| 107 | 163 | //Mock input data for test |
| 108 | 164 | void DecoderInterfaceTest::MockPacketType (const EWelsNalUnitType eNalUnitType, const int iPacketLength) { |
| 109 | 165 | switch (eNalUnitType) { |
| @@ -340,7 +396,89 @@ void DecoderInterfaceTest::TestTraceCallbackContext() { · 230 unmodified lines | ||
| 340 | 396 | //TODO |
| 341 | 397 | } |
| 342 | 398 | |
| 399 | +//DECODER_OPTION_GET_STATISTICS | |
| 400 | +void DecoderInterfaceTest::TestGetDecStatistics() { | |
| 401 | + CM_RETURN eRet; | |
| 402 | + SDecoderStatistics sDecStatic; | |
| 403 | + int32_t iError = 0; | |
| 343 | 404 | |
| 405 | + Init(); | |
| 406 | + // setoption not support, | |
| 407 | + eRet = (CM_RETURN)m_pDec->SetOption (DECODER_OPTION_GET_STATISTICS, NULL); | |
| 408 | + EXPECT_EQ (eRet, cmInitParaError); | |
| 409 | + //EC on UT | |
| 410 | + iError = 2; | |
| 411 | + m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError); | |
| 412 | + //Decoder error bs | |
| 413 | + DecoderBs ("res/Error_I_P.264"); | |
| 414 | + m_pDec->GetOption (DECODER_OPTION_GET_STATISTICS, &sDecStatic); | |
| 415 | + EXPECT_EQ (57, sDecStatic.uiAvgEcRatio); | |
| 416 | + EXPECT_EQ (5, sDecStatic.uiDecodedFrameCount); | |
| 417 | + EXPECT_EQ (288, sDecStatic.uiHeight); | |
| 418 | + EXPECT_EQ (1, sDecStatic.uiIDRRecvNum); | |
| 419 | + EXPECT_EQ (3, sDecStatic.uiResolutionChangeTimes); | |
| 420 | + EXPECT_EQ (352, sDecStatic.uiWidth); | |
| 421 | + EXPECT_EQ (4, sDecStatic.uiEcFrameNum); | |
| 422 | + EXPECT_EQ (2, sDecStatic.uiEcIDRNum); | |
| 423 | + EXPECT_EQ (0, sDecStatic.uiIDRLostNum); | |
| 424 | + Uninit(); | |
| 425 | + | |
| 426 | + //Decoder error bs when the first IDR lost | |
| 427 | + Init(); | |
| 428 | + iError = 2; | |
| 429 | + m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError); | |
| 430 | + DecoderBs ("res/BA_MW_D_IDR_LOST.264"); | |
| 431 | + m_pDec->GetOption (DECODER_OPTION_GET_STATISTICS, &sDecStatic); | |
| 432 | + EXPECT_EQ (0, sDecStatic.uiAvgEcRatio); | |
| 433 | + EXPECT_EQ (97, sDecStatic.uiDecodedFrameCount); | |
| 434 | + EXPECT_EQ (144, sDecStatic.uiHeight); | |
| 435 | + EXPECT_EQ (3, sDecStatic.uiIDRRecvNum); | |
| 436 | + EXPECT_EQ (0, sDecStatic.uiEcIDRNum); | |
| 437 | + EXPECT_EQ (1, sDecStatic.uiResolutionChangeTimes); | |
| 438 | + EXPECT_EQ (176, sDecStatic.uiWidth); | |
| 439 | + EXPECT_EQ (27, sDecStatic.uiEcFrameNum); | |
| 440 | + EXPECT_EQ (1, sDecStatic.uiIDRLostNum); | |
| 441 | + Uninit(); | |
| 442 | + | |
| 443 | + //ecoder error bs when the first P lost | |
| 444 | + Init(); | |
| 445 | + iError = 2; | |
| 446 | + m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError); | |
| 447 | + | |
| 448 | + DecoderBs ("res/BA_MW_D_P_LOST.264"); | |
| 449 | + | |
| 450 | + m_pDec->GetOption (DECODER_OPTION_GET_STATISTICS, &sDecStatic); | |
| 451 | + EXPECT_EQ (0, sDecStatic.uiAvgEcRatio); | |
| 452 | + EXPECT_EQ (99, sDecStatic.uiDecodedFrameCount); | |
| 453 | + EXPECT_EQ (144, sDecStatic.uiHeight); | |
| 454 | + EXPECT_EQ (4, sDecStatic.uiIDRRecvNum); | |
| 455 | + EXPECT_EQ (0, sDecStatic.uiEcIDRNum); | |
| 456 | + EXPECT_EQ (1, sDecStatic.uiResolutionChangeTimes); | |
| 457 | + EXPECT_EQ (176, sDecStatic.uiWidth); | |
| 458 | + EXPECT_EQ (28, sDecStatic.uiEcFrameNum); | |
| 459 | + EXPECT_EQ (0, sDecStatic.uiIDRLostNum); | |
| 460 | + Uninit(); | |
| 461 | + //EC enable | |
| 462 | + | |
| 463 | + //EC Off UT just correc bitstream | |
| 464 | + Init(); | |
| 465 | + iError = 0; | |
| 466 | + m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError); | |
| 467 | + DecoderBs ("res/test_vd_1d.264"); | |
| 468 | + | |
| 469 | + m_pDec->GetOption (DECODER_OPTION_GET_STATISTICS, &sDecStatic); | |
| 470 | + | |
| 471 | + EXPECT_EQ (0, sDecStatic.uiAvgEcRatio); | |
| 472 | + EXPECT_EQ (9, sDecStatic.uiDecodedFrameCount); | |
| 473 | + EXPECT_EQ (192, sDecStatic.uiHeight); | |
| 474 | + EXPECT_EQ (1, sDecStatic.uiIDRRecvNum); | |
| 475 | + EXPECT_EQ (1, sDecStatic.uiResolutionChangeTimes); | |
| 476 | + EXPECT_EQ (320, sDecStatic.uiWidth); | |
| 477 | + EXPECT_EQ (0, sDecStatic.uiEcFrameNum); | |
| 478 | + EXPECT_EQ (0, sDecStatic.uiIDRLostNum); | |
| 479 | + Uninit(); | |
| 480 | + | |
| 481 | +} | |
| 344 | 482 | //TEST here for whole tests |
| 345 | 483 | TEST_F (DecoderInterfaceTest, DecoderInterfaceAll) { |
| 346 | 484 | |
| @@ -370,6 +508,8 @@ TEST_F (DecoderInterfaceTest, DecoderInterfaceAll) { · 23 unmodified lines | ||
| 370 | 508 | TestTraceCallback(); |
| 371 | 509 | //DECODER_OPTION_TRACE_CALLBACK_CONTEXT |
| 372 | 510 | TestTraceCallbackContext(); |
| 511 | + //DECODER_OPTION_GET_STATISTICS | |
| 512 | + TestGetDecStatistics(); | |
| 373 | 513 | } |
| 374 | 514 | |
| 375 | 515 | |