Showing the changes to test/api/encode_decode_api_test.cpp (1 of 15 files). Show all
Unified · Split
| @@ -3727,4 +3727,71 @@ TEST_F (EncodeDecodeTestAPI, SimulcastAVCDiffFps) { · 3726 unmodified lines | ||
| 3727 | 3727 | #endif |
| 3728 | 3728 | } |
| 3729 | 3729 | |
| 3730 | +TEST_F (EncodeDecodeTestAPI, DiffSlicingInDlayer) { | |
| 3731 | + int iSpatialLayerNum = 3; | |
| 3732 | + int iWidth = WelsClip3 ((((rand() % MAX_WIDTH) >> 1) + 1) << 1, (64 << 2), MAX_WIDTH); | |
| 3733 | + int iHeight = WelsClip3 ((((rand() % MAX_HEIGHT) >> 1) + 1) << 1, (64 << 2), 2240);//TODO: use MAX_HEIGHT after the limit is removed | |
| 3734 | + float fFrameRate = rand() + 0.5f; | |
| 3735 | + int iEncFrameNum = WelsClip3 ((rand() % ENCODE_FRAME_NUM) + 1, 1, ENCODE_FRAME_NUM); | |
| 3736 | + | |
| 3737 | + // prepare params | |
| 3738 | + SEncParamExt sParam; | |
| 3739 | + encoder_->GetDefaultParams (&sParam); | |
| 3740 | + prepareParamDefault (iSpatialLayerNum, 1, iWidth, iHeight, fFrameRate, &sParam); | |
| 3741 | + sParam.iMultipleThreadIdc = (rand()%4) + 1; | |
| 3742 | + sParam.bSimulcastAVC = 1; | |
| 3743 | + sParam.sSpatialLayers[0].iVideoWidth = (iWidth >> 2); | |
| 3744 | + sParam.sSpatialLayers[0].iVideoHeight = (iHeight >> 2); | |
| 3745 | + sParam.sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_ROWMB_SLICE; | |
| 3746 | + | |
| 3747 | + sParam.sSpatialLayers[1].iVideoWidth = (iWidth >> 1); | |
| 3748 | + sParam.sSpatialLayers[1].iVideoHeight = (iHeight >> 1); | |
| 3749 | + sParam.sSpatialLayers[1].sSliceCfg.uiSliceMode = SM_RASTER_SLICE; | |
| 3750 | + sParam.sSpatialLayers[1].sSliceCfg.sSliceArgument.uiSliceMbNum[0] = 30; | |
| 3751 | + sParam.sSpatialLayers[1].sSliceCfg.sSliceArgument.uiSliceMbNum[1] = 32; | |
| 3752 | + | |
| 3753 | + sParam.sSpatialLayers[2].iVideoWidth = iWidth; | |
| 3754 | + sParam.sSpatialLayers[2].iVideoHeight = iHeight; | |
| 3755 | + sParam.sSpatialLayers[2].sSliceCfg.uiSliceMode = SM_FIXEDSLCNUM_SLICE; | |
| 3756 | + sParam.sSpatialLayers[2].sSliceCfg.sSliceArgument.uiSliceNum = 4; | |
| 3757 | + | |
| 3758 | + int rv = encoder_->InitializeExt (&sParam); | |
| 3759 | + ASSERT_TRUE (rv == cmResultSuccess) << "Init Failed sParam: rv = " << rv;; | |
| 3760 | + | |
| 3761 | + unsigned char* pBsBuf[MAX_SPATIAL_LAYER_NUM]; | |
| 3762 | + ISVCDecoder* decoder[MAX_SPATIAL_LAYER_NUM]; | |
| 3763 | + | |
| 3764 | + int iIdx = 0; | |
| 3765 | + | |
| 3766 | + //create decoder | |
| 3767 | + for (iIdx = 0; iIdx < iSpatialLayerNum; iIdx++) { | |
| 3768 | + pBsBuf[iIdx] = static_cast<unsigned char*> (malloc (iWidth * iHeight * 3 * sizeof (unsigned char) / 2)); | |
| 3769 | + EXPECT_TRUE (pBsBuf[iIdx] != NULL); | |
| 3770 | + | |
| 3771 | + long rv = WelsCreateDecoder (&decoder[iIdx]); | |
| 3772 | + ASSERT_EQ (0, rv); | |
| 3773 | + EXPECT_TRUE (decoder[iIdx] != NULL); | |
| 3774 | + | |
| 3775 | + SDecodingParam decParam; | |
| 3776 | + memset (&decParam, 0, sizeof (SDecodingParam)); | |
| 3777 | + decParam.eOutputColorFormat = videoFormatI420; | |
| 3778 | + decParam.uiTargetDqLayer = UCHAR_MAX; | |
| 3779 | + decParam.eEcActiveIdc = ERROR_CON_SLICE_COPY; | |
| 3780 | + decParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; | |
| 3781 | + | |
| 3782 | + rv = decoder[iIdx]->Initialize (&decParam); | |
| 3783 | + ASSERT_EQ (0, rv); | |
| 3784 | + } | |
| 3785 | + | |
| 3786 | + TestOneSimulcastAVC (&sParam, decoder, pBsBuf, iSpatialLayerNum, iEncFrameNum, 0); | |
| 3730 | 3787 | |
| 3788 | + for (iIdx = 0; iIdx < iSpatialLayerNum; iIdx++) { | |
| 3789 | + free (pBsBuf[iIdx]); | |
| 3790 | + | |
| 3791 | + if (decoder[iIdx] != NULL) { | |
| 3792 | + decoder[iIdx]->Uninitialize(); | |
| 3793 | + WelsDestroyDecoder (decoder[iIdx]); | |
| 3794 | + } | |
| 3795 | + | |
| 3796 | + } | |
| 3797 | +} | |