History

fix low memory crash issue

huili2 committed 9 years ago

Commit d1c0a931 parent 48c2fe116 files · +401 −386Browse files

Showing the changes to test/api/decode_api_test.cpp (1 of 16 files). Show all

Unified · Split

test/api/decode_api_test.cpp+16−40
@@ -27,7 +27,7 @@ TEST_P (EncodeDecodeTestAPI, DecoderVclNal) { · 26 unmodified lines
27 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);27 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
28 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);28 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
29 29
30 InitialEncDec (p.width, p.height);30 ASSERT_TRUE (InitialEncDec (p.width, p.height));
31 31
32 int iIdx = 0;32 int iIdx = 0;
33 while (iIdx <= p.numframes) {33 while (iIdx <= p.numframes) {
@@ -63,7 +63,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionFramenum) { · 29 unmodified lines
63 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);63 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
64 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);64 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
65 65
66 InitialEncDec (p.width, p.height);66 ASSERT_TRUE (InitialEncDec (p.width, p.height));
67 67
68 int32_t iEncFrameNum = -1;68 int32_t iEncFrameNum = -1;
69 int32_t iDecFrameNum;69 int32_t iDecFrameNum;
@@ -102,7 +102,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionIDR) { · 32 unmodified lines
102 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);102 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
103 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);103 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
104 104
105 InitialEncDec (p.width, p.height);105 ASSERT_TRUE (InitialEncDec (p.width, p.height));
106 106
107 int32_t iEncCurIdrPicId = 0;107 int32_t iEncCurIdrPicId = 0;
108 int32_t iDecCurIdrPicId;108 int32_t iDecCurIdrPicId;
@@ -146,7 +146,7 @@ TEST_P (EncodeDecodeTestAPI, InOutTimeStamp) { · 37 unmodified lines
146 int rv = encoder_->InitializeExt (&param_);146 int rv = encoder_->InitializeExt (&param_);
147 ASSERT_TRUE (rv == cmResultSuccess);147 ASSERT_TRUE (rv == cmResultSuccess);
148 148
149 InitialEncDec (p.width, p.height);149 ASSERT_TRUE (InitialEncDec (p.width, p.height));
150 int32_t iTraceLevel = WELS_LOG_QUIET;150 int32_t iTraceLevel = WELS_LOG_QUIET;
151 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);151 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
152 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);152 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
@@ -200,7 +200,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_AVC_NOPREFIX) { · 47 unmodified lines
200 int rv = encoder_->InitializeExt (&param_);200 int rv = encoder_->InitializeExt (&param_);
201 ASSERT_TRUE (rv == cmResultSuccess);201 ASSERT_TRUE (rv == cmResultSuccess);
202 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;202 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
203 InitialEncDec (p.width, p.height);203 ASSERT_TRUE (InitialEncDec (p.width, p.height));
204 int32_t iTraceLevel = WELS_LOG_QUIET;204 int32_t iTraceLevel = WELS_LOG_QUIET;
205 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);205 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
206 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);206 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
@@ -273,7 +273,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_AVC_WITH_PREFIX_NOLOSS) { · 66 unmodified lines
273 ASSERT_TRUE (rv == cmResultSuccess);273 ASSERT_TRUE (rv == cmResultSuccess);
274 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;274 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
275 275
276 InitialEncDec (p.width, p.height);276 ASSERT_TRUE (InitialEncDec (p.width, p.height));
277 int32_t iTraceLevel = WELS_LOG_QUIET;277 int32_t iTraceLevel = WELS_LOG_QUIET;
278 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);278 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
279 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);279 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
@@ -329,7 +329,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_SVC_L1_NOLOSS) { · 49 unmodified lines
329 ASSERT_TRUE (rv == cmResultSuccess);329 ASSERT_TRUE (rv == cmResultSuccess);
330 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;330 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
331 331
332 InitialEncDec (p.width, p.height);332 ASSERT_TRUE (InitialEncDec (p.width, p.height));
333 int32_t iTraceLevel = WELS_LOG_QUIET;333 int32_t iTraceLevel = WELS_LOG_QUIET;
334 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);334 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
335 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);335 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
@@ -386,7 +386,7 @@ TEST_P (EncodeDecodeTestAPI, SetOption_Trace) { · 50 unmodified lines
386 ASSERT_TRUE (rv == cmResultSuccess);386 ASSERT_TRUE (rv == cmResultSuccess);
387 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;387 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
388 388
389 InitialEncDec (p.width, p.height);389 ASSERT_TRUE (InitialEncDec (p.width, p.height));
390 int32_t iTraceLevel = WELS_LOG_QUIET;390 int32_t iTraceLevel = WELS_LOG_QUIET;
391 pFunc = TestOutPutTrace;391 pFunc = TestOutPutTrace;
392 pTraceInfo = &sTrace;392 pTraceInfo = &sTrace;
@@ -451,7 +451,7 @@ TEST_P (EncodeDecodeTestAPI, SetOption_Trace_NULL) { · 58 unmodified lines
451 ASSERT_TRUE (rv == cmResultSuccess);451 ASSERT_TRUE (rv == cmResultSuccess);
452 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;452 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
453 453
454 InitialEncDec (p.width, p.height);454 ASSERT_TRUE (InitialEncDec (p.width, p.height));
455 455
456 int32_t iTraceLevel = WELS_LOG_QUIET;456 int32_t iTraceLevel = WELS_LOG_QUIET;
457 pFunc = NULL;457 pFunc = NULL;
@@ -529,7 +529,6 @@ class DecodeCrashTestAPI : public ::testing::TestWithParam<EncodeDecodeFileParam · 71 unmodified lines
529 EncodeDecodeTestBase::prepareParam (iLayerNum, iSliceNum, width, height, framerate, pParam);529 EncodeDecodeTestBase::prepareParam (iLayerNum, iSliceNum, width, height, framerate, pParam);
530 }530 }
531 531
532 void prepareEncDecParam (const EncodeDecodeFileParamBase EncDecFileParam);
533 void EncodeOneFrame() {532 void EncodeOneFrame() {
534 int frameSize = EncPic.iPicWidth * EncPic.iPicHeight * 3 / 2;533 int frameSize = EncPic.iPicWidth * EncPic.iPicHeight * 3 / 2;
535 memset (buf_.data(), iRandValue, (frameSize >> 2));534 memset (buf_.data(), iRandValue, (frameSize >> 2));
@@ -541,31 +540,6 @@ class DecodeCrashTestAPI : public ::testing::TestWithParam<EncodeDecodeFileParam · 5 unmodified lines
541 unsigned char* ucBuf_;540 unsigned char* ucBuf_;
542};541};
543 542
544void DecodeCrashTestAPI::prepareEncDecParam (const EncodeDecodeFileParamBase EncDecFileParam) {
545 // for encoder
546 // I420: 1(Y) + 1/4(U) + 1/4(V)
547 int frameSize = EncDecFileParam.width * EncDecFileParam.height * 3 / 2;
548
549 buf_.SetLength (frameSize);
550 ASSERT_TRUE (buf_.Length() == (size_t)frameSize);
551
552 memset (&EncPic, 0, sizeof (SSourcePicture));
553 EncPic.iPicWidth = EncDecFileParam.width;
554 EncPic.iPicHeight = EncDecFileParam.height;
555 EncPic.iColorFormat = videoFormatI420;
556 EncPic.iStride[0] = EncPic.iPicWidth;
557 EncPic.iStride[1] = EncPic.iStride[2] = EncPic.iPicWidth >> 1;
558 EncPic.pData[0] = buf_.data();
559 EncPic.pData[1] = EncPic.pData[0] + EncDecFileParam.width * EncDecFileParam.height;
560 EncPic.pData[2] = EncPic.pData[1] + (EncDecFileParam.width * EncDecFileParam.height >> 2);
561
562 //for decoder
563 memset (&info, 0, sizeof (SFrameBSInfo));
564
565 //set a fixed random value
566 iRandValue = rand() % 256;
567}
568
569struct EncodeDecodeParamBase {543struct EncodeDecodeParamBase {
570 int width;544 int width;
571 int height;545 int height;
@@ -668,7 +642,7 @@ TEST_F (DecodeCrashTestAPI, DecoderCrashTest) { · 96 unmodified lines
668 pInput.width = p.width;642 pInput.width = p.width;
669 pInput.height = p.height;643 pInput.height = p.height;
670 pInput.frameRate = p.frameRate;644 pInput.frameRate = p.frameRate;
671 prepareEncDecParam (pInput);645 ASSERT_TRUE (prepareEncDecParam (pInput));
672 while (iIdx++ < iTotalFrameNum) { // loop in frame646 while (iIdx++ < iTotalFrameNum) { // loop in frame
673 EncodeOneFrame();647 EncodeOneFrame();
674#ifdef DEBUG_FILE_SAVE_CRA648#ifdef DEBUG_FILE_SAVE_CRA
@@ -819,11 +793,13 @@ class DecodeParseAPI : public ::testing::TestWithParam<EncodeDecodeFileParamBase · 144 unmodified lines
819 }793 }
820 }794 }
821 795
822 void prepareEncDecParam (const EncodeDecodeFileParamBase p) {796 bool prepareEncDecParam (const EncodeDecodeFileParamBase p) {
823 EncodeDecodeTestBase::prepareEncDecParam (p);797 if (!EncodeDecodeTestBase::prepareEncDecParam (p))
798 return false;
824 unsigned char* pTmpPtr = BsInfo_.pDstBuff; //store for restore799 unsigned char* pTmpPtr = BsInfo_.pDstBuff; //store for restore
825 memset (&BsInfo_, 0, sizeof (SParserBsInfo));800 memset (&BsInfo_, 0, sizeof (SParserBsInfo));
826 BsInfo_.pDstBuff = pTmpPtr;801 BsInfo_.pDstBuff = pTmpPtr;
802 return true;
827 }803 }
828 804
829 void MockInputData (uint8_t* pData, int32_t iSize) {805 void MockInputData (uint8_t* pData, int32_t iSize) {
@@ -886,7 +862,7 @@ TEST_F (DecodeParseAPI, ParseOnly_General) { · 56 unmodified lines
886 if (uiTargetLayerId < kiTotalLayer) { //should always be true862 if (uiTargetLayerId < kiTotalLayer) { //should always be true
887 //Start for enc863 //Start for enc
888 int iLen = 0;864 int iLen = 0;
889 prepareEncDecParam (p);865 ASSERT_TRUE (prepareEncDecParam (p));
890 int iFrame = 0;866 int iFrame = 0;
891 867
892 while (iFrame < p.numframes) {868 while (iFrame < p.numframes) {
@@ -959,7 +935,7 @@ TEST_F (DecodeParseAPI, ParseOnly_SpecSliceLoss) { · 66 unmodified lines
959 //Start for enc935 //Start for enc
960 int iLen = 0;936 int iLen = 0;
961 uint32_t uiGet;937 uint32_t uiGet;
962 prepareEncDecParam (p);938 ASSERT_TRUE (prepareEncDecParam (p));
963 int iFrame = 0;939 int iFrame = 0;
964 940
965 while (iFrame < p.numframes) {941 while (iFrame < p.numframes) {

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