History

Add picture bIsComplete flag to reflect the status of decoder Modify the output error status and add some some judgement

Haibo Zhu committed 12 years ago

Commit 9d182ee1 parent 614e8989 files · +113 −59Browse files

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

Unified · Split

test/api/encode_decode_api_test.cpp+45−44
@@ -102,6 +102,8 @@ class EncodeDecodeTestBase : public ::testing::TestWithParam<EncodeDecodeFilePar · 101 unmodified lines
102102 };
103103
104104 class EncodeDecodeTestAPI : public EncodeDecodeTestBase {
105+ public:
106+ uint8_t iRandValue;
105107 public:
106108 void SetUp() {
107109 EncodeDecodeTestBase::SetUp();
@@ -115,17 +117,17 @@ class EncodeDecodeTestAPI : public EncodeDecodeTestBase { · 7 unmodified lines
115117 EncodeDecodeTestBase::prepareParam (width, height, framerate);
116118 }
117119
118− void prepareEncDecParam(const EncodeDecodeFileParamBase EncDecFileParam);
120+ void prepareEncDecParam (const EncodeDecodeFileParamBase EncDecFileParam);
119121 void EncodeOneFrame() {
120122 int frameSize = EncPic.iPicWidth * EncPic.iPicHeight * 3 / 2;
121− memset (buf_.data(), rand() % 256, frameSize);
123+ memset (buf_.data(), iRandValue, (frameSize >> 2));
124+ memset (buf_.data() + (frameSize >> 2), rand() % 256, (frameSize - (frameSize >> 2)));
122125 int rv = encoder_->EncodeFrame (&EncPic, &info);
123126 ASSERT_TRUE (rv == cmResultSuccess || rv == cmUnkonwReason);
124127 }
125128 };
126129
127−void EncodeDecodeTestAPI::prepareEncDecParam(const EncodeDecodeFileParamBase EncDecFileParam)
128−{
130+void EncodeDecodeTestAPI::prepareEncDecParam (const EncodeDecodeFileParamBase EncDecFileParam) {
129131 // for encoder
130132 // I420: 1(Y) + 1/4(U) + 1/4(V)
131133 int frameSize = EncDecFileParam.width * EncDecFileParam.height * 3 / 2;
@@ -145,6 +147,9 @@ void EncodeDecodeTestAPI::prepareEncDecParam(const EncodeDecodeFileParamBase Enc · 13 unmodified lines
145147
146148 //for decoder
147149 memset (&info, 0, sizeof (SFrameBSInfo));
150+
151+ //set a fixed random value
152+ iRandValue = rand() % 256;
148153 }
149154
150155
@@ -165,7 +170,7 @@ TEST_P (EncodeDecodeTestAPI, DecoderVclNal) { · 14 unmodified lines
165170 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
166171 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
167172
168− prepareEncDecParam(p);
173+ prepareEncDecParam (p);
169174
170175 int iIdx = 0;
171176 while (iIdx <= p.numframes) {
@@ -201,7 +206,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionFramenum) { · 29 unmodified lines
201206 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
202207 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
203208
204− prepareEncDecParam(p);
209+ prepareEncDecParam (p);
205210
206211 int32_t iEncFrameNum = -1;
207212 int32_t iDecFrameNum;
@@ -240,7 +245,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionIDR) { · 32 unmodified lines
240245 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
241246 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
242247
243− prepareEncDecParam(p);
248+ prepareEncDecParam (p);
244249
245250 int32_t iEncCurIdrPicId = 0;
246251 int32_t iDecCurIdrPicId;
@@ -479,7 +484,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionLTR_ALLIDR) { · 232 unmodified lines
479484 int rv = encoder_->InitializeExt (&param_);
480485 ASSERT_TRUE (rv == cmResultSuccess);
481486
482− prepareEncDecParam(p);
487+ prepareEncDecParam (p);
483488
484489 int32_t iTraceLevel = WELS_LOG_QUIET;
485490 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
@@ -574,7 +579,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionLTR_Engine) { · 88 unmodified lines
574579 ASSERT_TRUE (rv == cmResultSuccess);
575580 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
576581
577− prepareEncDecParam(p);
582+ prepareEncDecParam (p);
578583
579584 int32_t iTraceLevel = WELS_LOG_QUIET;
580585 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
@@ -593,7 +598,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionLTR_Engine) { · 12 unmodified lines
593598 int iLossIdx = 0;
594599 bool bVCLLoss = false;
595600 while (iIdx <= p.numframes) {
596− EncodeOneFrame();
601+ EncodeOneFrame();
597602 if (m_LTR_Recover_Request.uiFeedbackType == IDR_RECOVERY_REQUEST) {
598603 ASSERT_TRUE (info.eFrameType == videoFrameTypeIDR);
599604 }
@@ -639,7 +644,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECFlag_ERROR_CON_DISABLE) { · 39 unmodified lines
639644 ASSERT_EQ (0, rv);
640645 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
641646
642− prepareEncDecParam(p);
647+ prepareEncDecParam (p);
643648 int32_t iTraceLevel = WELS_LOG_QUIET;
644649 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
645650 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
@@ -695,7 +700,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECFlag_ERROR_CON_SLICE_COPY) { · 49 unmodified lines
695700 ASSERT_TRUE (rv == cmResultSuccess);
696701 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
697702
698− prepareEncDecParam(p);
703+ prepareEncDecParam (p);
699704 int32_t iTraceLevel = WELS_LOG_QUIET;
700705 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
701706 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
@@ -752,7 +757,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_AVC_NOPREFIX) { · 50 unmodified lines
752757 int rv = encoder_->InitializeExt (&param_);
753758 ASSERT_TRUE (rv == cmResultSuccess);
754759 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
755− prepareEncDecParam(p);
760+ prepareEncDecParam (p);
756761 int32_t iTraceLevel = WELS_LOG_QUIET;
757762 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
758763 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
@@ -825,7 +830,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_AVC_WITH_PREFIX_NOLOSS) { · 66 unmodified lines
825830 ASSERT_TRUE (rv == cmResultSuccess);
826831 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
827832
828− prepareEncDecParam(p);
833+ prepareEncDecParam (p);
829834 int32_t iTraceLevel = WELS_LOG_QUIET;
830835 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
831836 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
@@ -887,7 +892,7 @@ TEST_P (EncodeDecodeTestAPI, GetOptionTid_SVC_L1_NOLOSS) { · 55 unmodified lines
887892 ASSERT_TRUE (rv == cmResultSuccess);
888893 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
889894
890− prepareEncDecParam(p);
895+ prepareEncDecParam (p);
891896 int32_t iTraceLevel = WELS_LOG_QUIET;
892897 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
893898 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
@@ -944,7 +949,7 @@ TEST_P (EncodeDecodeTestAPI, SetOption_Trace) { · 50 unmodified lines
944949 ASSERT_TRUE (rv == cmResultSuccess);
945950 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
946951
947− prepareEncDecParam(p);
952+ prepareEncDecParam (p);
948953 int32_t iTraceLevel = WELS_LOG_QUIET;
949954 pFunc = TestOutPutTrace;
950955 pTraceInfo = &sTrace;
@@ -1009,7 +1014,7 @@ TEST_P (EncodeDecodeTestAPI, SetOption_Trace_NULL) { · 58 unmodified lines
10091014 ASSERT_TRUE (rv == cmResultSuccess);
10101015 m_LTR_Recover_Request.uiFeedbackType = NO_RECOVERY_REQUSET;
10111016
1012− prepareEncDecParam(p);
1017+ prepareEncDecParam (p);
10131018
10141019 int32_t iTraceLevel = WELS_LOG_QUIET;
10151020 pFunc = NULL;
@@ -1082,7 +1087,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECIDC_GeneralSliceChange) { · 66 unmodified lines
10821087
10831088 //Start for enc/dec
10841089
1085− prepareEncDecParam(p);
1090+ prepareEncDecParam (p);
10861091 int32_t iTraceLevel = WELS_LOG_QUIET;
10871092 encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel);
10881093 decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel);
@@ -1113,7 +1118,7 @@ TEST_P (EncodeDecodeTestAPI, SetOptionECIDC_GeneralSliceChange) { · 24 unmodified lines
11131118 rv = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf + iTotalSliceSize,
11141119 info.sLayerInfo[0].pNalLengthInByte[iPacketNum], pData, &dstBufInfo_);
11151120 if (uiEcIdc == ERROR_CON_DISABLE)
1116− EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
1121+ EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
11171122 }
11181123 //EC_IDC should not change till now
11191124 decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet);
@@ -1170,7 +1175,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificFrameChange) { · 50 unmodified lines
11701175 int len = 0;
11711176 unsigned char* pData[3] = { NULL };
11721177
1173− prepareEncDecParam(p);
1178+ prepareEncDecParam (p);
11741179 //Frame 0: IDR, EC_IDC=DISABLE, loss = 0
11751180 EncodeOneFrame();
11761181 encToDecData (info, len);
@@ -1241,10 +1246,9 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificFrameChange) { · 64 unmodified lines
12411246 EXPECT_EQ (rv, 0); //parse correct
12421247 EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //no output
12431248 rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction
1244− if (rv == 0) //TODO: should depend on if ref-frame is OK.
1245− EXPECT_EQ (dstBufInfo_.iBufferStatus, 1);
1246− else
1247− EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
1249+ //Ref picture is ECed, so current status is ECed, when EC disable, NO output
1250+ EXPECT_TRUE (rv & 32);
1251+ EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
12481252 iIdx++;
12491253
12501254 //Frame 5: P, EC_IDC=DISABLE, loss = 1
@@ -1269,7 +1273,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificFrameChange) { · 18 unmodified lines
12691273 pData[0] = pData[1] = pData[2] = 0;
12701274 memset (&dstBufInfo_, 0, sizeof (SBufferInfo));
12711275 rv = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf, len, pData, &dstBufInfo_);
1272− EXPECT_TRUE (rv != 0); //parse correct, but previous decoding error, ECed
1276+ EXPECT_TRUE (rv == 0); // Now the parse process is Error_None, and the reconstruction will has error return
12731277 EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //no output
12741278 rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction
12751279 EXPECT_TRUE (rv != 0); //not sure if previous data drop would be detected in construction
@@ -1306,7 +1310,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) { · 30 unmodified lines
13061310 unsigned char* pData[3] = { NULL };
13071311 int iTotalSliceSize = 0;
13081312
1309− prepareEncDecParam(p);
1313+ prepareEncDecParam (p);
13101314
13111315 //Frame 0: IDR, EC_IDC=2, loss = 2
13121316 EncodeOneFrame();
@@ -1325,7 +1329,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) { · 12 unmodified lines
13251329 rv = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf, iTotalSliceSize, pData, &dstBufInfo_);
13261330 EXPECT_EQ (rv, 0); //parse correct
13271331 rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction
1328− EXPECT_EQ (rv, 0); //parse correct
1332+ EXPECT_EQ (rv, 0); // Reconstruct first slice OK
13291333 EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //slice incomplete, no output
13301334 iIdx++;
13311335
@@ -1361,10 +1365,9 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) { · 29 unmodified lines
13611365 rv = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf, len, pData, &dstBufInfo_);
13621366 EXPECT_EQ (rv, 0); //parse correct
13631367 rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction
1364− if (rv == 0) //TODO: should depend on if ref-frame is OK.
1365− EXPECT_EQ (dstBufInfo_.iBufferStatus, 1);
1366− else
1367− EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
1368+ // Ref picture is ECed, so reconstructed picture is ECed
1369+ EXPECT_TRUE (rv & 32);
1370+ EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
13681371 iIdx++;
13691372
13701373 //set EC=SLICE_COPY
@@ -1381,7 +1384,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) { · 10 unmodified lines
13811384 decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet);
13821385 EXPECT_EQ (uiGet, (uint32_t) ERROR_CON_FRAME_COPY);
13831386 rv = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf + iTotalSliceSize, len, pData, &dstBufInfo_);
1384− EXPECT_TRUE (rv & 32);
1387+ EXPECT_EQ (rv, 0); //parse correct
13851388 EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
13861389 rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction
13871390 EXPECT_TRUE (rv & 32);
@@ -1402,10 +1405,10 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRLoss) { · 14 unmodified lines
14021405 EXPECT_EQ (uiGet, (uint32_t) ERROR_CON_DISABLE);
14031406 rv = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf, len, pData, &dstBufInfo_);
14041407 EXPECT_TRUE (rv != 0);
1405− EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //output previous pic
1408+ EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); // EC_IDC=0, previous picture slice lost, no output
14061409 rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction
14071410 EXPECT_TRUE (rv != 0);
1408− EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //output previous pic
1411+ EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); // No ref picture, no output
14091412 iIdx++;
14101413
14111414 }
@@ -1440,7 +1443,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 28 unmodified lines
14401443 unsigned char* pData[3] = { NULL };
14411444 int iTotalSliceSize = 0;
14421445
1443− prepareEncDecParam(p);
1446+ prepareEncDecParam (p);
14441447
14451448 //set EC=DISABLE
14461449 uiEcIdc = (uint32_t) (ERROR_CON_DISABLE);
@@ -1509,7 +1512,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 62 unmodified lines
15091512 decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet);
15101513 EXPECT_EQ (uiGet, (uint32_t) ERROR_CON_SLICE_COPY);
15111514 rv = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf, len, pData, &dstBufInfo_);
1512− EXPECT_TRUE (rv & 32); //ECed
1515+ EXPECT_TRUE (rv & 32); //parse OK but frame 2 ECed
15131516 EXPECT_EQ (dstBufInfo_.iBufferStatus, 1); //slice loss but ECed output Frame 2
15141517 rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction
15151518 EXPECT_TRUE (rv & 32);
@@ -1533,11 +1536,9 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 17 unmodified lines
15331536 EXPECT_TRUE (rv != 0); //previous slice not outputted, will return error due to incomplete frame
15341537 EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //output previous pic
15351538 rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction,
1536− //not sure if current frame can be correctly decoded
1537− if (rv == 0)
1538− EXPECT_EQ (dstBufInfo_.iBufferStatus, 1); //output previous pic
1539− else
1540− EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //output previous pic
1539+ // previous frame NOT output, no ref
1540+ EXPECT_TRUE (rv != 0);
1541+ EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //output previous pic
15411542 iIdx++;
15421543
15431544 //Frame 5: IDR, EC_IDC=2->0, loss = 0
@@ -1560,10 +1561,10 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 16 unmodified lines
15601561 pData[0] = pData[1] = pData[2] = 0;
15611562 memset (&dstBufInfo_, 0, sizeof (SBufferInfo));
15621563 rv = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf, iTotalSliceSize, pData, &dstBufInfo_);
1563− EXPECT_TRUE (rv != 0); //TODO: should be correct, now ECed status will return error
1564+ EXPECT_TRUE (rv == 0); // IDR status return error_free
15641565 EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //frame incomplete
15651566 rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction,
1566− EXPECT_TRUE (rv != 0); //TODO: as above
1567+ EXPECT_TRUE (rv == 0);
15671568 EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //output previous pic
15681569 //set EC=DISABLE for slice 2
15691570 encToDecSliceData (1, 1, info, len); //slice 1
@@ -1577,7 +1578,7 @@ TEST_F (EncodeDecodeTestAPI, SetOptionECIDC_SpecificSliceChange_IDRNoLoss) { · 7 unmodified lines
15771578 EXPECT_EQ (rv, 0); //Parse correct under no EC
15781579 EXPECT_EQ (dstBufInfo_.iBufferStatus, 0); //frame incomplete
15791580 rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction,
1580− EXPECT_EQ (rv, 0); //Parse correct under no EC
1581+ EXPECT_EQ (rv, 0);
15811582 EXPECT_EQ (dstBufInfo_.iBufferStatus, 1); //output previous pic
15821583 iIdx++;
15831584

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