fix crash issue that temporal layer changs cause memory issue
Showing the changes to test/api/encode_options_test.cpp (1 of 2 files). Show all
Unified · Split
| @@ -2202,3 +2202,66 @@ TEST_F (EncodeDecodeTestAPI, ScreenContent_LosslessLink0_EnableLongTermReferenc · 2201 unmodified lines | |||
| 2202 | ASSERT_TRUE (iRet == cmResultSuccess) << "rv = " << iRet; | 2202 | ASSERT_TRUE (iRet == cmResultSuccess) << "rv = " << iRet; |
| 2203 | 2203 | ||
| 2204 | } | 2204 | } |
| 2205 | |||
| 2206 | |||
| 2207 | TEST_F (EncodeDecodeTestAPI, TemporalLayerChangeDuringEncoding) { | ||
| 2208 | int iWidth = 320; | ||
| 2209 | int iHeight = 192; | ||
| 2210 | float fFrameRate = 15; | ||
| 2211 | int iSliceNum = 1; | ||
| 2212 | int iRet = 0; | ||
| 2213 | int iTotalFrame = 20; //total test enc frame num | ||
| 2214 | int iFrameNum = 0; | ||
| 2215 | SEncParamExt sParam; | ||
| 2216 | encoder_->GetDefaultParams (&sParam); | ||
| 2217 | prepareParamDefault (1, iSliceNum, iWidth, iHeight, fFrameRate, &sParam); | ||
| 2218 | sParam.iTemporalLayerNum = 2; | ||
| 2219 | |||
| 2220 | //int TraceLevel = WELS_LOG_DEBUG; | ||
| 2221 | //encoder_->SetOption (ENCODER_OPTION_TRACE_LEVEL, &TraceLevel); | ||
| 2222 | iRet = encoder_->InitializeExt (&sParam); | ||
| 2223 | ASSERT_TRUE (iRet == cmResultSuccess) << "InitializeExt: iRet = " << iRet << " at " << sParam.iPicWidth << "x" << | ||
| 2224 | sParam.iPicHeight; | ||
| 2225 | |||
| 2226 | ASSERT_TRUE (InitialEncDec (iWidth, iHeight)); | ||
| 2227 | |||
| 2228 | int frameSize = EncPic.iPicWidth * EncPic.iPicHeight * 3 / 2; | ||
| 2229 | do { | ||
| 2230 | FileInputStream fileStream; | ||
| 2231 | ASSERT_TRUE (fileStream.Open ("res/CiscoVT2people_320x192_12fps.yuv")); | ||
| 2232 | |||
| 2233 | while (fileStream.read (buf_.data(), frameSize) == frameSize) { | ||
| 2234 | iRet = encoder_->EncodeFrame (&EncPic, &info); | ||
| 2235 | ASSERT_TRUE (iRet == cmResultSuccess) << "rv = " << iRet; | ||
| 2236 | if (iFrameNum == 5) { | ||
| 2237 | sParam.iTemporalLayerNum = 3; | ||
| 2238 | sParam.iTargetBitrate = 1500000; | ||
| 2239 | sParam.sSpatialLayers[0].iSpatialBitrate = 1500000; | ||
| 2240 | sParam.fMaxFrameRate = 30; | ||
| 2241 | //sSvcParam.sSpatialLayers[0].fFrameRate = 30; | ||
| 2242 | encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam); | ||
| 2243 | } else if (iFrameNum == 10) { | ||
| 2244 | sParam.iTemporalLayerNum = 1; | ||
| 2245 | sParam.iTargetBitrate = 500000; | ||
| 2246 | sParam.sSpatialLayers[0].iSpatialBitrate = 500000; | ||
| 2247 | sParam.fMaxFrameRate = 7.5; | ||
| 2248 | //sSvcParam.sSpatialLayers[0].fFrameRate = 7.5; | ||
| 2249 | encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam); | ||
| 2250 | } else if (iFrameNum == 15) { | ||
| 2251 | sParam.iTemporalLayerNum = 2; | ||
| 2252 | sParam.iTargetBitrate = 1000000; | ||
| 2253 | sParam.sSpatialLayers[0].iSpatialBitrate = 1000000; | ||
| 2254 | sParam.fMaxFrameRate = 15; | ||
| 2255 | //sSvcParam.sSpatialLayers[0].fFrameRate = 15; | ||
| 2256 | encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam); | ||
| 2257 | } | ||
| 2258 | |||
| 2259 | |||
| 2260 | } | ||
| 2261 | iFrameNum++; | ||
| 2262 | } while (iFrameNum < iTotalFrame); | ||
| 2263 | |||
| 2264 | iRet = encoder_->Uninitialize(); | ||
| 2265 | ASSERT_TRUE (iRet == cmResultSuccess) << "rv = " << iRet; | ||
| 2266 | |||
| 2267 | } | ||