Showing the changes to test/api/encode_decode_api_test.cpp (1 of 2 files). Show all
Unified · Split
| @@ -2465,3 +2465,63 @@ TEST_F (DecodeParseAPI, ParseOnly_General) { · 2464 unmodified lines | ||
| 2465 | 2465 | #endif |
| 2466 | 2466 | } |
| 2467 | 2467 | |
| 2468 | +//This case is for one layer only, for incomplete frame input | |
| 2469 | +//First slice is loss for random one picture with 2 slices per pic | |
| 2470 | +TEST_F (DecodeParseAPI, ParseOnly_SpecSliceLoss) { | |
| 2471 | + int32_t iLayerNum = 1; | |
| 2472 | + int32_t iSliceNum = 2; | |
| 2473 | + EncodeDecodeFileParamBase p; | |
| 2474 | + p.width = iWidth_; | |
| 2475 | + p.height = iHeight_; | |
| 2476 | + p.frameRate = kiFrameRate; | |
| 2477 | + p.numframes = 5; | |
| 2478 | + prepareParam (iLayerNum, iSliceNum, p.width, p.height, p.frameRate); | |
| 2479 | + param_.iSpatialLayerNum = iLayerNum; | |
| 2480 | + encoder_->Uninitialize(); | |
| 2481 | + int rv = encoder_->InitializeExt (¶m_); | |
| 2482 | + ASSERT_TRUE (rv == 0); | |
| 2483 | + int32_t iTraceLevel = WELS_LOG_QUIET; | |
| 2484 | + encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &iTraceLevel); | |
| 2485 | + decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &iTraceLevel); | |
| 2486 | + | |
| 2487 | + int32_t iMissedPicNum = rand() % (p.numframes - 1) + 1; //IDR no loss | |
| 2488 | + //Start for enc | |
| 2489 | + int iLen = 0; | |
| 2490 | + uint32_t uiGet; | |
| 2491 | + prepareEncDecParam (p); | |
| 2492 | + int iFrame = 0; | |
| 2493 | + | |
| 2494 | + while (iFrame < p.numframes) { | |
| 2495 | + //encode | |
| 2496 | + EncodeOneFrame (iFrame); | |
| 2497 | + //parseonly | |
| 2498 | + if (iFrame == iMissedPicNum) { //make current frame partly missing | |
| 2499 | + //Frame: P, first slice loss | |
| 2500 | + int32_t iTotalSliceSize = 0; | |
| 2501 | + encToDecSliceData (0, 0, info, iTotalSliceSize); //slice 1 lost | |
| 2502 | + encToDecSliceData (0, 1, info, iLen); //slice 2 | |
| 2503 | + decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet); | |
| 2504 | + EXPECT_EQ (uiGet, (uint32_t) ERROR_CON_DISABLE); | |
| 2505 | + rv = decoder_->DecodeParser (info.sLayerInfo[0].pBsBuf + iTotalSliceSize, iLen, &BsInfo_); | |
| 2506 | + EXPECT_TRUE (rv == 0); | |
| 2507 | + EXPECT_TRUE (BsInfo_.iNalNum == 0); | |
| 2508 | + rv = decoder_->DecodeParser (NULL, 0, &BsInfo_); | |
| 2509 | + EXPECT_TRUE (rv != 0); | |
| 2510 | + } else { //normal frame, complete | |
| 2511 | + encToDecData (info, iLen); | |
| 2512 | + rv = decoder_->DecodeParser (info.sLayerInfo[0].pBsBuf, iLen, &BsInfo_); | |
| 2513 | + EXPECT_TRUE (rv == 0); //parse correct | |
| 2514 | + EXPECT_TRUE (BsInfo_.iNalNum == 0); | |
| 2515 | + rv = decoder_->DecodeParser (NULL, 0, &BsInfo_); | |
| 2516 | + if (iFrame < iMissedPicNum) { //correct frames, all OK with output | |
| 2517 | + EXPECT_TRUE (rv == 0); | |
| 2518 | + EXPECT_TRUE (BsInfo_.iNalNum != 0); | |
| 2519 | + } else { //(iFrame > iMissedPicNum), should output nothing as error | |
| 2520 | + EXPECT_TRUE (rv != 0); | |
| 2521 | + EXPECT_TRUE (BsInfo_.iNalNum == 0); | |
| 2522 | + } | |
| 2523 | + } | |
| 2524 | + iFrame++; | |
| 2525 | + } //while | |
| 2526 | +} | |
| 2527 | + | |