History

modify UT low memory cases

huili2 committed 9 years ago

Commit f7239b61 parent 2081df82 files · +68 −37Browse files

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

Unified · Split

test/decoder/DecUT_ParseSyntax.cpp+47−16
@@ -132,9 +132,9 @@ class DecoderParseSyntaxTest : public ::testing::Test { · 131 unmodified lines
132 //Uninit members132 //Uninit members
133 void Uninit();133 void Uninit();
134 //Decoder real bitstream134 //Decoder real bitstream
135 void DecodeBs (const char* sFileName);135 bool DecodeBs (const char* sFileName);
136 //Parse real bitstream136 //Parse real bitstream
137 void ParseBs (const char* sFileName);137 bool ParseBs (const char* sFileName);
138 //Scalinglist138 //Scalinglist
139 void TestScalingList();139 void TestScalingList();
140 //specific bitstream test140 //specific bitstream test
@@ -175,11 +175,16 @@ int32_t DecoderParseSyntaxTest::Init() { · 34 unmodified lines
175 m_iBufLength = 4;175 m_iBufLength = 4;
176 //176 //
177 m_pCtx = (PWelsDecoderContext)malloc (sizeof (SWelsDecoderContext));177 m_pCtx = (PWelsDecoderContext)malloc (sizeof (SWelsDecoderContext));
178 178 if (m_pCtx == NULL)
179 return ERR_MALLOC_FAILED;
179 memset (m_pCtx, 0, sizeof (SWelsDecoderContext));180 memset (m_pCtx, 0, sizeof (SWelsDecoderContext));
180 m_pWelsTrace = new welsCodecTrace();181 m_pWelsTrace = new welsCodecTrace();
181 if (m_pWelsTrace != NULL) {182 if (m_pWelsTrace != NULL) {
182 m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR);183 m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR);
184 } else {
185 free (m_pCtx);
186 m_pCtx = NULL;
187 return ERR_MALLOC_FAILED;
183 }188 }
184 CM_RETURN eRet = (CM_RETURN)Initialize (&m_sDecParam, m_pCtx, &m_pWelsTrace->m_sLogCtx);189 CM_RETURN eRet = (CM_RETURN)Initialize (&m_sDecParam, m_pCtx, &m_pWelsTrace->m_sLogCtx);
185 return (int32_t)eRet;190 return (int32_t)eRet;
@@ -199,7 +204,7 @@ void DecoderParseSyntaxTest::Uninit() { · 13 unmodified lines
199 m_iBufLength = 0;204 m_iBufLength = 0;
200}205}
201 206
202void DecoderParseSyntaxTest::DecodeBs (const char* sFileName) {207bool DecoderParseSyntaxTest::DecodeBs (const char* sFileName) {
203 208
204 uint8_t* pBuf = NULL;209 uint8_t* pBuf = NULL;
205 int32_t iBufPos = 0;210 int32_t iBufPos = 0;
@@ -213,15 +218,28 @@ void DecoderParseSyntaxTest::DecodeBs (const char* sFileName) { · 7 unmodified lines
213 218
214#if defined(ANDROID_NDK)219#if defined(ANDROID_NDK)
215 std::string filename = std::string ("/sdcard/") + sFileName;220 std::string filename = std::string ("/sdcard/") + sFileName;
216 ASSERT_TRUE ((pH264File = fopen (filename.c_str(), "rb")) != NULL);221 if ((pH264File = fopen (filename.c_str(), "rb")) == NULL)
222 return false;
217#else223#else
218 ASSERT_TRUE ((pH264File = fopen (sFileName, "rb")) != NULL);224 if ((pH264File = fopen (sFileName, "rb")) == NULL)
225 return false;
219#endif226#endif
220 fseek (pH264File, 0L, SEEK_END);227 fseek (pH264File, 0L, SEEK_END);
221 iFileSize = (int32_t) ftell (pH264File);228 iFileSize = (int32_t) ftell (pH264File);
222 fseek (pH264File, 0L, SEEK_SET);229 fseek (pH264File, 0L, SEEK_SET);
223 pBuf = new uint8_t[iFileSize + 4];230 pBuf = new uint8_t[iFileSize + 4];
224 ASSERT_EQ (fread (pBuf, 1, iFileSize, pH264File), (unsigned int) iFileSize);231 if (pBuf == NULL) {
232 fclose (pH264File);
233 return false;
234 }
235 if ((fread (pBuf, 1, iFileSize, pH264File) != (unsigned int) iFileSize)) {
236 fclose (pH264File);
237 if (pBuf) {
238 delete[] pBuf;
239 pBuf = NULL;
240 }
241 return false;
242 }
225 memcpy (pBuf + iFileSize, &uiStartCode[0], 4); //confirmed_safe_unsafe_usage243 memcpy (pBuf + iFileSize, &uiStartCode[0], 4); //confirmed_safe_unsafe_usage
226 while (true) {244 while (true) {
227 if (iBufPos >= iFileSize) {245 if (iBufPos >= iFileSize) {
@@ -250,9 +268,9 @@ void DecoderParseSyntaxTest::DecodeBs (const char* sFileName) { · 22 unmodified lines
250 pBuf = NULL;268 pBuf = NULL;
251 }269 }
252 270
253 271 return true;
254}272}
255void DecoderParseSyntaxTest::ParseBs (const char* sFileName) {273bool DecoderParseSyntaxTest::ParseBs (const char* sFileName) {
256 274
257 uint8_t* pBuf = NULL;275 uint8_t* pBuf = NULL;
258 int32_t iBufPos = 0;276 int32_t iBufPos = 0;
@@ -267,15 +285,28 @@ void DecoderParseSyntaxTest::ParseBs (const char* sFileName) { · 8 unmodified lines
267 285
268#if defined(ANDROID_NDK)286#if defined(ANDROID_NDK)
269 std::string filename = std::string ("/sdcard/") + sFileName;287 std::string filename = std::string ("/sdcard/") + sFileName;
270 ASSERT_TRUE ((pH264File = fopen (filename.c_str(), "rb")) != NULL);288 if ((pH264File = fopen (filename.c_str(), "rb")) == NULL)
289 return false;
271#else290#else
272 ASSERT_TRUE ((pH264File = fopen (sFileName, "rb")) != NULL);291 if ((pH264File = fopen (sFileName, "rb")) == NULL)
292 return false;
273#endif293#endif
274 fseek (pH264File, 0L, SEEK_END);294 fseek (pH264File, 0L, SEEK_END);
275 iFileSize = (int32_t)ftell (pH264File);295 iFileSize = (int32_t)ftell (pH264File);
276 fseek (pH264File, 0L, SEEK_SET);296 fseek (pH264File, 0L, SEEK_SET);
277 pBuf = new uint8_t[iFileSize + 4];297 pBuf = new uint8_t[iFileSize + 4];
278 ASSERT_EQ (fread (pBuf, 1, iFileSize, pH264File), (unsigned int)iFileSize);298 if (pBuf == NULL) {
299 fclose (pH264File);
300 return false;
301 }
302 if (fread (pBuf, 1, iFileSize, pH264File) != (unsigned int)iFileSize) {
303 fclose (pH264File);
304 if (pBuf) {
305 delete[] pBuf;
306 pBuf = NULL;
307 }
308 return false;
309 }
279 memcpy (pBuf + iFileSize, &uiStartCode[0], 4); //confirmed_safe_unsafe_usage310 memcpy (pBuf + iFileSize, &uiStartCode[0], 4); //confirmed_safe_unsafe_usage
280 while (true) {311 while (true) {
281 if (iBufPos >= iFileSize) {312 if (iBufPos >= iFileSize) {
@@ -308,7 +339,7 @@ void DecoderParseSyntaxTest::ParseBs (const char* sFileName) { · 26 unmodified lines
308 pBuf = NULL;339 pBuf = NULL;
309 }340 }
310 341
311 342 return true;
312}343}
313 344
314 345
@@ -335,7 +366,7 @@ void DecoderParseSyntaxTest::TestScalingList() { · 20 unmodified lines
335 int32_t iRet = ERR_NONE;366 int32_t iRet = ERR_NONE;
336 iRet = Init();367 iRet = Init();
337 ASSERT_EQ (iRet, ERR_NONE);368 ASSERT_EQ (iRet, ERR_NONE);
338 DecodeBs ("res/BA_MW_D.264");369 ASSERT_TRUE (DecodeBs ("res/BA_MW_D.264"));
339 ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag == false);370 ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag == false);
340 EXPECT_EQ (0, memcmp (iScalingListZero, m_pCtx->sSpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));371 EXPECT_EQ (0, memcmp (iScalingListZero, m_pCtx->sSpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
341 ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == false);372 ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == false);
@@ -344,7 +375,7 @@ void DecoderParseSyntaxTest::TestScalingList() { · 2 unmodified lines
344 //Scalinglist value just written into sps and pps375 //Scalinglist value just written into sps and pps
345 iRet = Init();376 iRet = Init();
346 ASSERT_EQ (iRet, ERR_NONE);377 ASSERT_EQ (iRet, ERR_NONE);
347 DecodeBs ("res/test_scalinglist_jm.264");378 ASSERT_TRUE (DecodeBs ("res/test_scalinglist_jm.264"));
348 ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag);379 ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag);
349 for (int i = 0; i < 6; i++) {380 for (int i = 0; i < 6; i++) {
350 EXPECT_EQ (0, memcmp (iScalingList[i], m_pCtx->sSpsBuffer[0].iScalingList4x4[i], 16 * sizeof (uint8_t)));381 EXPECT_EQ (0, memcmp (iScalingList[i], m_pCtx->sSpsBuffer[0].iScalingList4x4[i], 16 * sizeof (uint8_t)));
@@ -364,7 +395,7 @@ void DecoderParseSyntaxTest::TestSpecificBs() { · 13 unmodified lines
364 m_sDecParam.eEcActiveIdc = ERROR_CON_DISABLE;395 m_sDecParam.eEcActiveIdc = ERROR_CON_DISABLE;
365 iRet = m_pDec->Initialize (&m_sDecParam);396 iRet = m_pDec->Initialize (&m_sDecParam);
366 ASSERT_EQ (iRet, ERR_NONE);397 ASSERT_EQ (iRet, ERR_NONE);
367 ParseBs ("res/jm_1080p_allslice.264");398 ASSERT_TRUE (ParseBs ("res/jm_1080p_allslice.264"));
368 m_pDec->Uninitialize();399 m_pDec->Uninitialize();
369 //Uninit();400 //Uninit();
370}401}

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