* SingleLayerPreprocess: down sampling if applicable * @return: exact number of spatial layers need to encoder indeed */
| 344 | * @return: exact number of spatial layers need to encoder indeed |
| 345 | */ |
| 346 | int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSourcePicture* kpSrc, |
| 347 | Scaled_Picture* pScaledPicture) { |
| 348 | SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam; |
| 349 | int8_t iDependencyId = pSvcParam->iSpatialLayerNum - 1; |
| 350 | |
| 351 | SPicture* pSrcPic = NULL; // large |
| 352 | SPicture* pDstPic = NULL; // small |
| 353 | SSpatialLayerConfig* pDlayerParam = NULL; |
| 354 | SSpatialLayerInternal* pDlayerParamInternal = NULL; |
| 355 | int32_t iSpatialNum = 0; |
| 356 | int32_t iSrcWidth = 0; |
| 357 | int32_t iSrcHeight = 0; |
| 358 | int32_t iTargetWidth = 0; |
| 359 | int32_t iTargetHeight = 0; |
| 360 | int32_t iTemporalId = 0; |
| 361 | int32_t iClosestDid = iDependencyId; |
| 362 | pDlayerParamInternal = &pSvcParam->sDependencyLayers[iDependencyId]; |
| 363 | pDlayerParam = &pSvcParam->sSpatialLayers[iDependencyId]; |
| 364 | iTargetWidth = pDlayerParam->iVideoWidth; |
| 365 | iTargetHeight = pDlayerParam->iVideoHeight; |
| 366 | |
| 367 | iSrcWidth = pSvcParam->SUsedPicRect.iWidth; |
| 368 | iSrcHeight = pSvcParam->SUsedPicRect.iHeight; |
| 369 | if (pSvcParam->uiIntraPeriod) { |
| 370 | pCtx->pVaa->bIdrPeriodFlag = (1 + pDlayerParamInternal->iFrameIndex >= (int32_t)pSvcParam->uiIntraPeriod) ? true : |
| 371 | false; |
| 372 | if (pCtx->pVaa->bIdrPeriodFlag) { |
| 373 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, |
| 374 | "pSvcParam->uiIntraPeriod=%d, pCtx->pVaa->bIdrPeriodFlag=%d", |
| 375 | pSvcParam->uiIntraPeriod, |
| 376 | pCtx->pVaa->bIdrPeriodFlag); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | pSrcPic = pScaledPicture->pScaledInputPicture ? pScaledPicture->pScaledInputPicture : GetCurrentOrigFrame ( |
| 381 | iDependencyId); |
| 382 | |
| 383 | WelsMoveMemoryWrapper (pSvcParam, pSrcPic, kpSrc, iSrcWidth, iSrcHeight); |
| 384 | |
| 385 | if (pSvcParam->bEnableDenoise) |
| 386 | BilateralDenoising (pSrcPic, iSrcWidth, iSrcHeight); |
| 387 | |
| 388 | // different scaling in between input picture and dst highest spatial picture. |
| 389 | int32_t iShrinkWidth = iSrcWidth; |
| 390 | int32_t iShrinkHeight = iSrcHeight; |
| 391 | pDstPic = pSrcPic; |
| 392 | if (pScaledPicture->pScaledInputPicture) { |
| 393 | // for highest downsampling |
| 394 | pDstPic = GetCurrentOrigFrame (iDependencyId); |
| 395 | iShrinkWidth = pScaledPicture->iScaledWidth[iDependencyId]; |
| 396 | iShrinkHeight = pScaledPicture->iScaledHeight[iDependencyId]; |
| 397 | } |
| 398 | DownsamplePadding (pSrcPic, pDstPic, iSrcWidth, iSrcHeight, iShrinkWidth, iShrinkHeight, iTargetWidth, iTargetHeight, |
| 399 | false); |
| 400 | |
| 401 | if (pSvcParam->bEnableSceneChangeDetect && !pCtx->pVaa->bIdrPeriodFlag) { |
| 402 | if (pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) { |
| 403 | pCtx->pVaa->eSceneChangeIdc = (pDlayerParamInternal->bEncCurFrmAsIdrFlag ? LARGE_CHANGED_SCENE : |
nothing calls this directly
no test coverage detected