Showing the changes to test/api/encode_options_test.cpp (1 of 1 file). Show all
Unified · Split
| @@ -2058,3 +2058,61 @@ TEST_F (EncodeDecodeTestAPI, ProfileLevelSetting) { · 2057 unmodified lines | ||
| 2058 | 2058 | rv = encoder_->Uninitialize(); |
| 2059 | 2059 | ASSERT_TRUE (rv == cmResultSuccess) << "rv = " << rv; |
| 2060 | 2060 | } |
| 2061 | + | |
| 2062 | +TEST_F (EncodeDecodeTestAPI, AVCSVCExtensionCheck) { | |
| 2063 | + int iWidth = 640; | |
| 2064 | + int iHeight = 360; | |
| 2065 | + float fFrameRate = rand() % 30 + 0.5f; | |
| 2066 | + int iTotalFrame = 10; //total test enc frame num | |
| 2067 | + int iSliceNum = 1; | |
| 2068 | + | |
| 2069 | + int iRet; | |
| 2070 | + int iSpatialLayerNumList[] = {1, 3}; | |
| 2071 | + int iLoopNum = 5; | |
| 2072 | + for (int i = 0; i < iLoopNum; ++i) { | |
| 2073 | + // prepare params | |
| 2074 | + SEncParamExt sParam; | |
| 2075 | + encoder_->GetDefaultParams (&sParam); | |
| 2076 | + int iCurrSpatialLayerNum = iSpatialLayerNumList[rand() % 2]; | |
| 2077 | + prepareParamDefault (iCurrSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam); | |
| 2078 | + sParam.bSimulcastAVC = rand() & 1; //0 or 1 | |
| 2079 | + sParam.iRCMode = RC_TIMESTAMP_MODE; | |
| 2080 | + sParam.iNumRefFrame = 1; | |
| 2081 | + sParam.fMaxFrameRate = fFrameRate; | |
| 2082 | + sParam.sSpatialLayers[0].iSpatialBitrate = sParam.iTargetBitrate = 500; | |
| 2083 | + sParam.sSpatialLayers[1].iSpatialBitrate = sParam.iTargetBitrate = 1000; | |
| 2084 | + sParam.sSpatialLayers[2].iSpatialBitrate = sParam.iTargetBitrate = 2200; | |
| 2085 | + sParam.iTargetBitrate = 4000; | |
| 2086 | + //int TraceLevel = WELS_LOG_DEBUG; | |
| 2087 | + //encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &TraceLevel); | |
| 2088 | + //decoder_->SetOption (DECODER_OPTION_TRACE_LEVEL, &TraceLevel); | |
| 2089 | + iRet = encoder_->InitializeExt (&sParam); | |
| 2090 | + ASSERT_TRUE (iRet == cmResultSuccess) << "InitializeExt: iRet = " << iRet << " at " << sParam.iPicWidth << "x" << | |
| 2091 | + sParam.iPicHeight; | |
| 2092 | + ASSERT_TRUE (InitialEncDec (iWidth, iHeight)); | |
| 2093 | + int iLen = 0; | |
| 2094 | + for (int j = 0; j < iTotalFrame; ++j) { | |
| 2095 | + EncodeOneFrame (0); | |
| 2096 | + encToDecData (info, iLen); | |
| 2097 | + uint8_t cTypeByte; | |
| 2098 | + for (int iLayer = 0; iLayer < info.iLayerNum; ++iLayer) { | |
| 2099 | + SLayerBSInfo* pLayerBsInfo = &info.sLayerInfo[iLayer]; | |
| 2100 | + for (int iPacketNum = 0; iPacketNum < pLayerBsInfo->iNalCount; ++iPacketNum) { | |
| 2101 | + cTypeByte = (* (pLayerBsInfo->pBsBuf + 4)) & 0x1f; | |
| 2102 | + if (sParam.bSimulcastAVC) { | |
| 2103 | + EXPECT_TRUE (cTypeByte <= 8) << "simulcastAVC, spatial_id = " << pLayerBsInfo->uiSpatialId << ", typeByte = " << | |
| 2104 | + cTypeByte; | |
| 2105 | + } else { | |
| 2106 | + if (pLayerBsInfo->uiSpatialId == 0) | |
| 2107 | + EXPECT_TRUE (cTypeByte <= 8 || cTypeByte == 14) << "simulcastSVC, spatial_id = 0, typeByte = " << cTypeByte; | |
| 2108 | + else | |
| 2109 | + EXPECT_TRUE (cTypeByte >= 14) << "simulcastSVC, spatial_id = " << pLayerBsInfo->uiSpatialId << ", typeByte = " << | |
| 2110 | + cTypeByte;; | |
| 2111 | + } | |
| 2112 | + } | |
| 2113 | + } | |
| 2114 | + } | |
| 2115 | + iRet = encoder_->Uninitialize(); | |
| 2116 | + ASSERT_TRUE (iRet == cmResultSuccess) << "rv = " << iRet; | |
| 2117 | + } | |
| 2118 | +} | |