History

add UT for cavlc_b not support case

huili2 committed 8 years ago

Commit 5364be41 parent 4c1642a1 file · +39 −21Browse files

Showing the changes to test/decoder/DecUT_ParseSyntax.cpp (1 of 1 file). Show all

Unified · Split

test/decoder/DecUT_ParseSyntax.cpp+39−21
@@ -10,13 +10,19 @@ · 9 unmodified lines
1010 using namespace WelsDec;
1111
1212 #define BUF_SIZE 100
13+typedef enum DecCase {
14+ CorrectDec = 0,
15+ ErrorDec = 1,
16+ CorrectParseOnly = 2,
17+ ErrorParseOnly = 3,
18+ RESERVED,
19+} EDecCase;
1320
1421 DECODING_STATE DecodeFrame (const unsigned char* kpSrc,
1522 const int kiSrcLen,
1623 unsigned char** ppDst,
1724 SBufferInfo* pDstInfo,
1825 PWelsDecoderContext pCtx) {
19−
2026 PWelsDecoderContext m_pDecContext = pCtx;
2127 if (CheckBsBuffer (m_pDecContext, kiSrcLen)) {
2228 return dsOutOfMemory;
@@ -55,7 +61,7 @@ DECODING_STATE DecodeFrame (const unsigned char* kpSrc, · 32 unmodified lines
5561 pDstInfo, NULL); //iErrorCode has been modified in this function
5662 m_pDecContext->bInstantDecFlag = false; //reset no-delay flag
5763
58− return dsErrorFree;
64+ return (DECODING_STATE) m_pDecContext->iErrorCode;
5965 }
6066
6167 void UninitDecoder (PWelsDecoderContext& pCtx) {
@@ -132,13 +138,14 @@ class DecoderParseSyntaxTest : public ::testing::Test { · 70 unmodified lines
132138 //Uninit members
133139 void Uninit();
134140 //Decoder real bitstream
135− bool DecodeBs (const char* sFileName);
141+ bool DecodeBs (const char* sFileName, EDecCase eDecCase);
136142 //Parse real bitstream
137− bool ParseBs (const char* sFileName);
143+ bool ParseBs (const char* sFileName, EDecCase eDecCase);
138144 //Scalinglist
139145 void TestScalingList();
140146 //specific bitstream test
141147 void TestSpecificBs();
148+ void TestSpecificBsError();
142149 //Do whole tests here
143150 void DecoderParseSyntaxTestAll();
144151
@@ -204,17 +211,17 @@ void DecoderParseSyntaxTest::Uninit() { · 59 unmodified lines
204211 m_iBufLength = 0;
205212 }
206213
207−bool DecoderParseSyntaxTest::DecodeBs (const char* sFileName) {
214+bool DecoderParseSyntaxTest::DecodeBs (const char* sFileName, EDecCase eDecCase) {
208215
209216 uint8_t* pBuf = NULL;
210217 int32_t iBufPos = 0;
211218 int32_t iFileSize;
212219 int32_t i = 0;
213220 int32_t iSliceSize;
214− int32_t iSliceIndex = 0;
215221 int32_t iEndOfStreamFlag = 0;
216222 FILE* pH264File;
217223 uint8_t uiStartCode[4] = {0, 0, 0, 1};
224+ int iRet = 0;
218225
219226 #if defined(ANDROID_NDK)
220227 std::string filename = std::string ("/sdcard/") + sFileName;
@@ -255,12 +262,13 @@ bool DecoderParseSyntaxTest::DecodeBs (const char* sFileName) { · 34 unmodified lines
255262 }
256263 }
257264 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);
259266 iBufPos += iSliceSize;
260− ++ iSliceIndex;
261− if (iSliceIndex == 4)
262− break;
263267 }
268+ if (eDecCase == CorrectDec)
269+ EXPECT_TRUE (iRet == dsErrorFree);
270+ else if (eDecCase == ErrorDec)
271+ EXPECT_TRUE ((iRet & (dsBitstreamError | dsRefLost | dsDataErrorConcealed)) != 0) << "iRet = " << iRet;
264272
265273 fclose (pH264File);
266274 if (pBuf) {
@@ -270,7 +278,7 @@ bool DecoderParseSyntaxTest::DecodeBs (const char* sFileName) { · 3 unmodified lines
270278
271279 return true;
272280 }
273−bool DecoderParseSyntaxTest::ParseBs (const char* sFileName) {
281+bool DecoderParseSyntaxTest::ParseBs (const char* sFileName, EDecCase eDecCase) {
274282
275283 uint8_t* pBuf = NULL;
276284 int32_t iBufPos = 0;
@@ -281,7 +289,7 @@ bool DecoderParseSyntaxTest::ParseBs (const char* sFileName) { · 4 unmodified lines
281289 int32_t iEndOfStreamFlag = 0;
282290 FILE* pH264File;
283291 uint8_t uiStartCode[4] = { 0, 0, 0, 1 };
284− int iRet;
292+ int iRet = 0;
285293
286294 #if defined(ANDROID_NDK)
287295 std::string filename = std::string ("/sdcard/") + sFileName;
@@ -323,15 +331,17 @@ bool DecoderParseSyntaxTest::ParseBs (const char* sFileName) { · 35 unmodified lines
323331 }
324332 iSliceSize = i;
325333 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);
330338 iBufPos += iSliceSize;
331339 ++iSliceIndex;
332340 if (iSliceIndex == 4)
333341 break;
334342 }
343+ if (eDecCase == ErrorDec)
344+ EXPECT_TRUE ((iRet & (dsBitstreamError | dsRefLost | dsDataErrorConcealed)) != 0) << iRet;
335345
336346 fclose (pH264File);
337347 if (pBuf) {
@@ -366,7 +376,7 @@ void DecoderParseSyntaxTest::TestScalingList() { · 28 unmodified lines
366376 int32_t iRet = ERR_NONE;
367377 iRet = Init();
368378 ASSERT_EQ (iRet, ERR_NONE);
369− ASSERT_TRUE (DecodeBs ("res/BA_MW_D.264"));
379+ ASSERT_TRUE (DecodeBs ("res/BA_MW_D.264", CorrectDec));
370380 ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag == false);
371381 EXPECT_EQ (0, memcmp (iScalingListZero, m_pCtx->sSpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
372382 ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == false);
@@ -375,7 +385,7 @@ void DecoderParseSyntaxTest::TestScalingList() { · 2 unmodified lines
375385 //Scalinglist value just written into sps and pps
376386 iRet = Init();
377387 ASSERT_EQ (iRet, ERR_NONE);
378− ASSERT_TRUE (DecodeBs ("res/test_scalinglist_jm.264"));
388+ ASSERT_TRUE (DecodeBs ("res/test_scalinglist_jm.264", CorrectDec));
379389 ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag);
380390 for (int i = 0; i < 6; i++) {
381391 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
390400
391401 void DecoderParseSyntaxTest::TestSpecificBs() {
392402 int32_t iRet = ERR_NONE;
393− Uninit();
394403 m_sDecParam.bParseOnly = true;
395404 m_sDecParam.eEcActiveIdc = ERROR_CON_DISABLE;
396405 iRet = m_pDec->Initialize (&m_sDecParam);
397406 ASSERT_EQ (iRet, ERR_NONE);
398− ASSERT_TRUE (ParseBs ("res/jm_1080p_allslice.264"));
407+ ASSERT_TRUE (ParseBs ("res/jm_1080p_allslice.264", CorrectParseOnly));
399408 m_pDec->Uninitialize();
400− //Uninit();
401409 }
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+
402419 //TEST here for whole tests
403420 TEST_F (DecoderParseSyntaxTest, DecoderParseSyntaxTestAll) {
404421
405422 TestScalingList();
406423 TestSpecificBs();
424+ TestSpecificBsError();
407425 }
408426
409427

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t