Showing the changes to test/api/encode_decode_api_test.cpp (1 of 5 files). Show all
Unified · Split
| @@ -3363,6 +3363,12 @@ TEST_F (EncodeDecodeTestAPI, SimulcastAVC) { · 3362 unmodified lines | |||
| 3363 | WelsDestroyDecoder (decoder[iIdx]); | 3363 | WelsDestroyDecoder (decoder[iIdx]); |
| 3364 | } | 3364 | } |
| 3365 | } | 3365 | } |
| 3366 | #ifdef DEBUG_FILE_SAVE_SimulcastAVCDiffFps | ||
| 3367 | for (int i = 0; i <)MAX_SPATIAL_LAYER_NUM; | ||
| 3368 | i++) { | ||
| 3369 | fclose (fEnc[i]); | ||
| 3370 | } | ||
| 3371 | #endif | ||
| 3366 | } | 3372 | } |
| 3367 | 3373 | ||
| 3368 | TEST_F (EncodeDecodeTestAPI, SimulcastAVC_SPS_PPS_LISTING) { | 3374 | TEST_F (EncodeDecodeTestAPI, SimulcastAVC_SPS_PPS_LISTING) { |
| @@ -3587,3 +3593,135 @@ TEST_P (EncodeTestAPI, SetEncOptionSize) { · 218 unmodified lines | |||
| 3587 | } | 3593 | } |
| 3588 | } | 3594 | } |
| 3589 | 3595 | ||
| 3596 | |||
| 3597 | |||
| 3598 | TEST_F (EncodeDecodeTestAPI, SimulcastAVCDiffFps) { | ||
| 3599 | //#define DEBUG_FILE_SAVE3 | ||
| 3600 | int iSpatialLayerNum = WelsClip3 ((rand() % MAX_SPATIAL_LAYER_NUM), 2, MAX_SPATIAL_LAYER_NUM); | ||
| 3601 | int iWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, 1 << iSpatialLayerNum, MAX_WIDTH); | ||
| 3602 | int iHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, 1 << iSpatialLayerNum, MAX_HEIGHT); | ||
| 3603 | float fFrameRate = 30; | ||
| 3604 | int iEncFrameNum = WelsClip3 ((rand() % ENCODE_FRAME_NUM) + 1, 1, ENCODE_FRAME_NUM); | ||
| 3605 | int iSliceNum = 1; | ||
| 3606 | encoder_->GetDefaultParams (¶m_); | ||
| 3607 | prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, ¶m_); | ||
| 3608 | |||
| 3609 | //set flag of bSimulcastAVC | ||
| 3610 | param_.bSimulcastAVC = true; | ||
| 3611 | param_.iTemporalLayerNum = 3; | ||
| 3612 | |||
| 3613 | int rv = encoder_->InitializeExt (¶m_); | ||
| 3614 | ASSERT_TRUE (rv == cmResultSuccess); | ||
| 3615 | |||
| 3616 | unsigned char* pBsBuf[MAX_SPATIAL_LAYER_NUM]; | ||
| 3617 | int aLen[MAX_SPATIAL_LAYER_NUM] = {0}; | ||
| 3618 | ISVCDecoder* decoder[MAX_SPATIAL_LAYER_NUM]; | ||
| 3619 | |||
| 3620 | #ifdef DEBUG_FILE_SAVE_SimulcastAVCDiffFps | ||
| 3621 | FILE* fEnc[MAX_SPATIAL_LAYER_NUM]; | ||
| 3622 | fEnc[0] = fopen ("enc0.264", "wb"); | ||
| 3623 | fEnc[1] = fopen ("enc1.264", "wb"); | ||
| 3624 | fEnc[2] = fopen ("enc2.264", "wb"); | ||
| 3625 | fEnc[3] = fopen ("enc3.264", "wb"); | ||
| 3626 | #endif | ||
| 3627 | |||
| 3628 | int iIdx = 0; | ||
| 3629 | |||
| 3630 | //create decoder | ||
| 3631 | for (iIdx = 0; iIdx < iSpatialLayerNum; iIdx++) { | ||
| 3632 | pBsBuf[iIdx] = static_cast<unsigned char*> (malloc (iWidth * iHeight * 3 * sizeof (unsigned char) / 2)); | ||
| 3633 | EXPECT_TRUE (pBsBuf[iIdx] != NULL); | ||
| 3634 | aLen[iIdx] = 0; | ||
| 3635 | |||
| 3636 | long rv = WelsCreateDecoder (&decoder[iIdx]); | ||
| 3637 | ASSERT_EQ (0, rv); | ||
| 3638 | EXPECT_TRUE (decoder[iIdx] != NULL); | ||
| 3639 | |||
| 3640 | SDecodingParam decParam; | ||
| 3641 | memset (&decParam, 0, sizeof (SDecodingParam)); | ||
| 3642 | decParam.eOutputColorFormat = videoFormatI420; | ||
| 3643 | decParam.uiTargetDqLayer = UCHAR_MAX; | ||
| 3644 | decParam.eEcActiveIdc = ERROR_CON_SLICE_COPY; | ||
| 3645 | decParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; | ||
| 3646 | |||
| 3647 | rv = decoder[iIdx]->Initialize (&decParam); | ||
| 3648 | ASSERT_EQ (0, rv); | ||
| 3649 | } | ||
| 3650 | |||
| 3651 | #define PATTERN_NUM (16) | ||
| 3652 | const int32_t iTemporalPattern[PATTERN_NUM][MAX_SPATIAL_LAYER_NUM] = { {2, 1, 1, 1}, {2, 2, 2, 1}, {4, 1, 1, 1}, {4, 2, 1, 1}, | ||
| 3653 | {1, 2, 1, 1}, {1, 1, 2, 1}, {1, 4, 1, 1}, {2, 4, 2, 1}, {1, 4, 2, 1}, | ||
| 3654 | {1, 2, 2, 1}, {1, 2, 4, 1}, | ||
| 3655 | {1, 1, 1, 2}, {1, 2, 2, 2}, {1, 2, 2, 4}, {1, 2, 4, 2}, {1, 4, 4, 4}, | ||
| 3656 | }; | ||
| 3657 | for (int iPatternIdx = 0; iPatternIdx < PATTERN_NUM; iPatternIdx++) { | ||
| 3658 | for (int i = 0; i < iSpatialLayerNum; i++) { | ||
| 3659 | param_.sSpatialLayers[i].fFrameRate = (fFrameRate / iTemporalPattern[iPatternIdx][i]); | ||
| 3660 | } | ||
| 3661 | |||
| 3662 | iEncFrameNum = 10; | ||
| 3663 | for (int iFrame = 0; iFrame < iEncFrameNum; iFrame++) { | ||
| 3664 | int iResult; | ||
| 3665 | int iLayerLen = 0; | ||
| 3666 | unsigned char* pData[3] = { NULL }; | ||
| 3667 | |||
| 3668 | InitialEncDec (param_.iPicWidth, param_.iPicHeight); | ||
| 3669 | EncodeOneFrame (0); | ||
| 3670 | |||
| 3671 | // init | ||
| 3672 | for (iIdx = 0; iIdx < iSpatialLayerNum; iIdx++) { | ||
| 3673 | aLen[iIdx] = 0; | ||
| 3674 | } | ||
| 3675 | for (int iLayer = 0; iLayer < info.iLayerNum; ++iLayer) { | ||
| 3676 | iLayerLen = 0; | ||
| 3677 | const SLayerBSInfo& layerInfo = info.sLayerInfo[iLayer]; | ||
| 3678 | const int kiFirstNalType = ((* (layerInfo.pBsBuf + 4)) & 0x1f); | ||
| 3679 | ASSERT_TRUE ((kiFirstNalType == NAL_SPS) || (kiFirstNalType == NAL_PPS) || (kiFirstNalType == NAL_SLICE) | ||
| 3680 | || (kiFirstNalType == NAL_SLICE_IDR) || (kiFirstNalType == NAL_SEI)); | ||
| 3681 | for (int iNal = 0; iNal < layerInfo.iNalCount; ++iNal) { | ||
| 3682 | iLayerLen += layerInfo.pNalLengthInByte[iNal]; | ||
| 3683 | } | ||
| 3684 | |||
| 3685 | iIdx = layerInfo.uiSpatialId; | ||
| 3686 | EXPECT_TRUE (iIdx < iSpatialLayerNum); | ||
| 3687 | memcpy ((pBsBuf[iIdx] + aLen[iIdx]), layerInfo.pBsBuf, iLayerLen * sizeof (unsigned char)); | ||
| 3688 | aLen[iIdx] += iLayerLen; | ||
| 3689 | } | ||
| 3690 | |||
| 3691 | for (iIdx = 0; iIdx < iSpatialLayerNum; iIdx++) { | ||
| 3692 | pData[0] = pData[1] = pData[2] = 0; | ||
| 3693 | memset (&dstBufInfo_, 0, sizeof (SBufferInfo)); | ||
| 3694 | |||
| 3695 | if (aLen[iIdx] > 0) { | ||
| 3696 | #ifdef DEBUG_FILE_SAVE_SimulcastAVCDiffFps | ||
| 3697 | fwrite (pBsBuf[iIdx], aLen[iIdx], 1, fEnc[iIdx]); | ||
| 3698 | #endif | ||
| 3699 | iResult = decoder[iIdx]->DecodeFrame2 (pBsBuf[iIdx], aLen[iIdx], pData, &dstBufInfo_); | ||
| 3700 | EXPECT_TRUE (iResult == cmResultSuccess) << "iResult=" << iResult << "LayerIdx=" << iIdx; | ||
| 3701 | |||
| 3702 | iResult = decoder[iIdx]->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); | ||
| 3703 | EXPECT_TRUE (iResult == cmResultSuccess) << "iResult=" << iResult << "LayerIdx=" << iIdx; | ||
| 3704 | EXPECT_EQ (dstBufInfo_.iBufferStatus, 1) << "LayerIdx=" << iIdx; | ||
| 3705 | } | ||
| 3706 | } | ||
| 3707 | } | ||
| 3708 | } | ||
| 3709 | |||
| 3710 | for (iIdx = 0; iIdx < iSpatialLayerNum; iIdx++) { | ||
| 3711 | free (pBsBuf[iIdx]); | ||
| 3712 | |||
| 3713 | if (decoder[iIdx] != NULL) { | ||
| 3714 | decoder[iIdx]->Uninitialize(); | ||
| 3715 | WelsDestroyDecoder (decoder[iIdx]); | ||
| 3716 | } | ||
| 3717 | } | ||
| 3718 | #ifdef DEBUG_FILE_SAVE_SimulcastAVCDiffFps | ||
| 3719 | for (int i = 0; i <)MAX_SPATIAL_LAYER_NUM; | ||
| 3720 | i++) { | ||
| 3721 | fclose (fEnc[i]); | ||
| 3722 | } | ||
| 3723 | #endif | ||
| 3724 | } | ||
| 3725 | |||
| 3726 | |||
| 3727 | |||