Showing the changes to test/decoder (1 of 1 file). Show all
Unified · Split
| @@ -10,13 +10,19 @@ · 9 unmodified lines | ||
| 10 | 10 | using namespace WelsDec; |
| 11 | 11 | |
| 12 | 12 | #define BUF_SIZE 100 |
| 13 | +typedef enum DecCase { | |
| 14 | + CorrectDec = 0, | |
| 15 | + ErrorDec = 1, | |
| 16 | + CorrectParseOnly = 2, | |
| 17 | + ErrorParseOnly = 3, | |
| 18 | + RESERVED, | |
| 19 | +} EDecCase; | |
| 13 | 20 | |
| 14 | 21 | DECODING_STATE DecodeFrame (const unsigned char* kpSrc, |
| 15 | 22 | const int kiSrcLen, |
| 16 | 23 | unsigned char** ppDst, |
| 17 | 24 | SBufferInfo* pDstInfo, |
| 18 | 25 | PWelsDecoderContext pCtx) { |
| 19 | − | |
| 20 | 26 | PWelsDecoderContext m_pDecContext = pCtx; |
| 21 | 27 | if (CheckBsBuffer (m_pDecContext, kiSrcLen)) { |
| 22 | 28 | return dsOutOfMemory; |
| @@ -55,7 +61,7 @@ DECODING_STATE DecodeFrame (const unsigned char* kpSrc, · 32 unmodified lines | ||
| 55 | 61 | pDstInfo, NULL); //iErrorCode has been modified in this function |
| 56 | 62 | m_pDecContext->bInstantDecFlag = false; //reset no-delay flag |
| 57 | 63 | |
| 58 | − return dsErrorFree; | |
| 64 | + return (DECODING_STATE) m_pDecContext->iErrorCode; | |
| 59 | 65 | } |
| 60 | 66 | |
| 61 | 67 | void UninitDecoder (PWelsDecoderContext& pCtx) { |
| @@ -132,13 +138,14 @@ class DecoderParseSyntaxTest : public ::testing::Test { · 70 unmodified lines | ||
| 132 | 138 | //Uninit members |
| 133 | 139 | void Uninit(); |
| 134 | 140 | //Decoder real bitstream |
| 135 | − bool DecodeBs (const char* sFileName); | |
| 141 | + bool DecodeBs (const char* sFileName, EDecCase eDecCase); | |
| 136 | 142 | //Parse real bitstream |
| 137 | − bool ParseBs (const char* sFileName); | |
| 143 | + bool ParseBs (const char* sFileName, EDecCase eDecCase); | |
| 138 | 144 | //Scalinglist |
| 139 | 145 | void TestScalingList(); |
| 140 | 146 | //specific bitstream test |
| 141 | 147 | void TestSpecificBs(); |
| 148 | + void TestSpecificBsError(); | |
| 142 | 149 | //Do whole tests here |
| 143 | 150 | void DecoderParseSyntaxTestAll(); |
| 144 | 151 | |
| @@ -204,17 +211,17 @@ void DecoderParseSyntaxTest::Uninit() { · 59 unmodified lines | ||
| 204 | 211 | m_iBufLength = 0; |
| 205 | 212 | } |
| 206 | 213 | |
| 207 | −bool DecoderParseSyntaxTest::DecodeBs (const char* sFileName) { | |
| 214 | +bool DecoderParseSyntaxTest::DecodeBs (const char* sFileName, EDecCase eDecCase) { | |
| 208 | 215 | |
| 209 | 216 | uint8_t* pBuf = NULL; |
| 210 | 217 | int32_t iBufPos = 0; |
| 211 | 218 | int32_t iFileSize; |
| 212 | 219 | int32_t i = 0; |
| 213 | 220 | int32_t iSliceSize; |
| 214 | − int32_t iSliceIndex = 0; | |
| 215 | 221 | int32_t iEndOfStreamFlag = 0; |
| 216 | 222 | FILE* pH264File; |
| 217 | 223 | uint8_t uiStartCode[4] = {0, 0, 0, 1}; |
| 224 | + int iRet = 0; | |
| 218 | 225 | |
| 219 | 226 | #if defined(ANDROID_NDK) |
| 220 | 227 | std::string filename = std::string ("/sdcard/") + sFileName; |
| @@ -255,12 +262,13 @@ bool DecoderParseSyntaxTest::DecodeBs (const char* sFileName) { · 34 unmodified lines | ||
| 255 | 262 | } |
| 256 | 263 | } |
| 257 | 264 | iSliceSize = i; |
| 258 | − DecodeFrame (pBuf + iBufPos, iSliceSize, m_pData, &m_sBufferInfo, m_pCtx); | |
| 265 | + iRet |= DecodeFrame (pBuf + iBufPos, iSliceSize, m_pData, &m_sBufferInfo, m_pCtx); | |
| 259 | 266 | iBufPos += iSliceSize; |
| 260 | − ++ iSliceIndex; | |
| 261 | − if (iSliceIndex == 4) | |
| 262 | − break; | |
| 263 | 267 | } |
| 268 | + if (eDecCase == CorrectDec) | |
| 269 | + EXPECT_TRUE (iRet == dsErrorFree); | |
| 270 | + else if (eDecCase == ErrorDec) | |
| 271 | + EXPECT_TRUE ((iRet & (dsBitstreamError | dsRefLost | dsDataErrorConcealed)) != 0) << "iRet = " << iRet; | |
| 264 | 272 | |
| 265 | 273 | fclose (pH264File); |
| 266 | 274 | if (pBuf) { |
| @@ -270,7 +278,7 @@ bool DecoderParseSyntaxTest::DecodeBs (const char* sFileName) { · 3 unmodified lines | ||
| 270 | 278 | |
| 271 | 279 | return true; |
| 272 | 280 | } |
| 273 | −bool DecoderParseSyntaxTest::ParseBs (const char* sFileName) { | |
| 281 | +bool DecoderParseSyntaxTest::ParseBs (const char* sFileName, EDecCase eDecCase) { | |
| 274 | 282 | |
| 275 | 283 | uint8_t* pBuf = NULL; |
| 276 | 284 | int32_t iBufPos = 0; |
| @@ -281,7 +289,7 @@ bool DecoderParseSyntaxTest::ParseBs (const char* sFileName) { · 4 unmodified lines | ||
| 281 | 289 | int32_t iEndOfStreamFlag = 0; |
| 282 | 290 | FILE* pH264File; |
| 283 | 291 | uint8_t uiStartCode[4] = { 0, 0, 0, 1 }; |
| 284 | − int iRet; | |
| 292 | + int iRet = 0; | |
| 285 | 293 | |
| 286 | 294 | #if defined(ANDROID_NDK) |
| 287 | 295 | std::string filename = std::string ("/sdcard/") + sFileName; |
| @@ -323,15 +331,17 @@ bool DecoderParseSyntaxTest::ParseBs (const char* sFileName) { · 35 unmodified lines | ||
| 323 | 331 | } |
| 324 | 332 | iSliceSize = i; |
| 325 | 333 | memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo)); |
| 326 | − iRet = m_pDec->DecodeParser (pBuf + iBufPos, iSliceSize, &m_sParserBsInfo); | |
| 327 | − EXPECT_TRUE (iRet == dsErrorFree || iRet == dsFramePending); | |
| 328 | − iRet = m_pDec->DecodeParser (NULL, 0, &m_sParserBsInfo); | |
| 329 | − EXPECT_TRUE (iRet == dsErrorFree || iRet == dsFramePending); | |
| 334 | + iRet |= m_pDec->DecodeParser (pBuf + iBufPos, iSliceSize, &m_sParserBsInfo); | |
| 335 | + iRet |= m_pDec->DecodeParser (NULL, 0, &m_sParserBsInfo); | |
| 336 | + if (eDecCase == CorrectParseOnly) | |
| 337 | + EXPECT_TRUE (iRet == dsErrorFree || iRet == dsFramePending); | |
| 330 | 338 | iBufPos += iSliceSize; |
| 331 | 339 | ++iSliceIndex; |
| 332 | 340 | if (iSliceIndex == 4) |
| 333 | 341 | break; |
| 334 | 342 | } |
| 343 | + if (eDecCase == ErrorDec) | |
| 344 | + EXPECT_TRUE ((iRet & (dsBitstreamError | dsRefLost | dsDataErrorConcealed)) != 0) << iRet; | |
| 335 | 345 | |
| 336 | 346 | fclose (pH264File); |
| 337 | 347 | if (pBuf) { |
| @@ -366,7 +376,7 @@ void DecoderParseSyntaxTest::TestScalingList() { · 28 unmodified lines | ||
| 366 | 376 | int32_t iRet = ERR_NONE; |
| 367 | 377 | iRet = Init(); |
| 368 | 378 | ASSERT_EQ (iRet, ERR_NONE); |
| 369 | − ASSERT_TRUE (DecodeBs ("res/BA_MW_D.264")); | |
| 379 | + ASSERT_TRUE (DecodeBs ("res/BA_MW_D.264", CorrectDec)); | |
| 370 | 380 | ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag == false); |
| 371 | 381 | EXPECT_EQ (0, memcmp (iScalingListZero, m_pCtx->sSpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t))); |
| 372 | 382 | ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == false); |
| @@ -375,7 +385,7 @@ void DecoderParseSyntaxTest::TestScalingList() { · 2 unmodified lines | ||
| 375 | 385 | //Scalinglist value just written into sps and pps |
| 376 | 386 | iRet = Init(); |
| 377 | 387 | ASSERT_EQ (iRet, ERR_NONE); |
| 378 | − ASSERT_TRUE (DecodeBs ("res/test_scalinglist_jm.264")); | |
| 388 | + ASSERT_TRUE (DecodeBs ("res/test_scalinglist_jm.264", CorrectDec)); | |
| 379 | 389 | ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag); |
| 380 | 390 | for (int i = 0; i < 6; i++) { |
| 381 | 391 | EXPECT_EQ (0, memcmp (iScalingList[i], m_pCtx->sSpsBuffer[0].iScalingList4x4[i], 16 * sizeof (uint8_t))); |
| @@ -390,20 +400,28 @@ void DecoderParseSyntaxTest::TestScalingList() { · 8 unmodified lines | ||
| 390 | 400 | |
| 391 | 401 | void DecoderParseSyntaxTest::TestSpecificBs() { |
| 392 | 402 | int32_t iRet = ERR_NONE; |
| 393 | − Uninit(); | |
| 394 | 403 | m_sDecParam.bParseOnly = true; |
| 395 | 404 | m_sDecParam.eEcActiveIdc = ERROR_CON_DISABLE; |
| 396 | 405 | iRet = m_pDec->Initialize (&m_sDecParam); |
| 397 | 406 | ASSERT_EQ (iRet, ERR_NONE); |
| 398 | − ASSERT_TRUE (ParseBs ("res/jm_1080p_allslice.264")); | |
| 407 | + ASSERT_TRUE (ParseBs ("res/jm_1080p_allslice.264", CorrectParseOnly)); | |
| 399 | 408 | m_pDec->Uninitialize(); |
| 400 | − //Uninit(); | |
| 401 | 409 | } |
| 410 | + | |
| 411 | +void DecoderParseSyntaxTest::TestSpecificBsError() { | |
| 412 | + int32_t iRet = ERR_NONE; | |
| 413 | + Init(); | |
| 414 | + ASSERT_EQ (iRet, ERR_NONE); | |
| 415 | + ASSERT_TRUE (DecodeBs ("res/Cisco_Men_whisper_640x320_CAVLC_Bframe_9.264", ErrorDec)); | |
| 416 | + Uninit(); | |
| 417 | +} | |
| 418 | + | |
| 402 | 419 | //TEST here for whole tests |
| 403 | 420 | TEST_F (DecoderParseSyntaxTest, DecoderParseSyntaxTestAll) { |
| 404 | 421 | |
| 405 | 422 | TestScalingList(); |
| 406 | 423 | TestSpecificBs(); |
| 424 | + TestSpecificBsError(); | |
| 407 | 425 | } |
| 408 | 426 | |
| 409 | 427 | |