From bd5d3355ffe4164b1ff591ffc5e198a1f6ff8743 Mon Sep 17 00:00:00 2001 From: Wang_PengX Date: Thu, 25 Jul 2024 15:26:32 +0800 Subject: [PATCH] [VP] fix sfc line buffer reallocation long latency issue fix sfc line buffer reallocation long latency issue. --- .../hal/packet/vp_render_sfc_base_legacy.cpp | 109 +++++++++++---- .../m12/vp/hal/packet/vp_render_sfc_m12.cpp | 18 ++- .../hal/packet/vp_render_sfc_xe2_lpm_base.cpp | 10 +- .../packet/vp_render_sfc_xe_lpm_plus_base.cpp | 12 +- .../common/vp/hal/features/vp_filter.h | 1 + .../vp/hal/features/vp_scaling_filter.cpp | 2 + .../vp/hal/packet/vp_render_sfc_base.cpp | 130 +++++++++++++----- .../common/vp/hal/packet/vp_render_sfc_base.h | 17 +-- .../common/vp/hal/packet/vp_sfc_common.h | 4 +- 9 files changed, 221 insertions(+), 82 deletions(-) diff --git a/media_driver/media_softlet/agnostic/common/vp/hal/packet/vp_render_sfc_base_legacy.cpp b/media_driver/media_softlet/agnostic/common/vp/hal/packet/vp_render_sfc_base_legacy.cpp index 20d4d6fd604..f8a754ff2d4 100644 --- a/media_driver/media_softlet/agnostic/common/vp/hal/packet/vp_render_sfc_base_legacy.cpp +++ b/media_driver/media_softlet/agnostic/common/vp/hal/packet/vp_render_sfc_base_legacy.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2018-2023, Intel Corporation +* Copyright (c) 2018-2024, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -505,8 +505,16 @@ MOS_STATUS SfcRenderBaseLegacy::SetupSfcState(PVP_SURFACE targetSurface) m_renderDataLegacy.sfcStateParams->pOsResOutputSurface = &targetSurface->osSurface->OsResource; - VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderDataLegacy.sfcStateParams->pOsResAVSLineBuffer, m_AVSLineBufferSurfaceArray[m_scalabilityParams.curPipe])); - VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderDataLegacy.sfcStateParams->pOsResIEFLineBuffer, m_IEFLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + if (m_renderData.b1stPassOfSfc2PassScaling) + { + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderDataLegacy.sfcStateParams->pOsResAVSLineBuffer, m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass[m_scalabilityParams.curPipe])); + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderDataLegacy.sfcStateParams->pOsResIEFLineBuffer, m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass[m_scalabilityParams.curPipe])); + } + else + { + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderDataLegacy.sfcStateParams->pOsResAVSLineBuffer, m_AVSLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderDataLegacy.sfcStateParams->pOsResIEFLineBuffer, m_IEFLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + } VP_RENDER_CHK_STATUS_RETURN(SetupScalabilityParams()); @@ -1166,39 +1174,80 @@ MOS_STATUS SfcRenderBaseLegacy::AllocateResources() sfcStateParams = m_renderDataLegacy.sfcStateParams; - if (m_scalabilityParams.numPipe > m_lineBufferAllocatedInArray || - nullptr == m_AVSLineBufferSurfaceArray || - nullptr == m_IEFLineBufferSurfaceArray || - nullptr == m_SFDLineBufferSurfaceArray) + // for 1st pass of Sfc 2Pass case, use the standalone line buffer array to avoid line buffer reallocation + if (m_renderDataLegacy.b1stPassOfSfc2PassScaling) { - DestroyLineBufferArray(m_AVSLineBufferSurfaceArray); - DestroyLineBufferArray(m_IEFLineBufferSurfaceArray); - DestroyLineBufferArray(m_SFDLineBufferSurfaceArray); - m_lineBufferAllocatedInArray = m_scalabilityParams.numPipe; - m_AVSLineBufferSurfaceArray = MOS_NewArray(VP_SURFACE *, m_lineBufferAllocatedInArray); - VP_RENDER_CHK_NULL_RETURN(m_AVSLineBufferSurfaceArray); - m_IEFLineBufferSurfaceArray = MOS_NewArray(VP_SURFACE *, m_lineBufferAllocatedInArray); - VP_RENDER_CHK_NULL_RETURN(m_IEFLineBufferSurfaceArray); - m_SFDLineBufferSurfaceArray = MOS_NewArray(VP_SURFACE *, m_lineBufferAllocatedInArray); - VP_RENDER_CHK_NULL_RETURN(m_SFDLineBufferSurfaceArray); - } + if (m_scalabilityParams.numPipe > m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass || + nullptr == m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass || + nullptr == m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass || + nullptr == m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass) + { + DestroyLineBufferArray(m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + DestroyLineBufferArray(m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + DestroyLineBufferArray(m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass = m_scalabilityParams.numPipe; + m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass = MOS_NewArray(VP_SURFACE *, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + VP_RENDER_CHK_NULL_RETURN(m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass); + m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass = MOS_NewArray(VP_SURFACE *, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + VP_RENDER_CHK_NULL_RETURN(m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass); + m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass = MOS_NewArray(VP_SURFACE *, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + VP_RENDER_CHK_NULL_RETURN(m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass); + } - // for AVSLineBuffer, IEFLineBuffer and SFDLineBuffer, they are only needed when surface allocation bigger than 4150. - // for AVSLineTileBuffer, IEFLineTileBuffer and SFDLineTileBuffer, they are only needed for VdBox SFC scalability case and not needed for VeBox SFC case. + // for AVSLineBuffer, IEFLineBuffer and SFDLineBuffer, they are only needed when surface allocation bigger than 4150. + // for AVSLineTileBuffer, IEFLineTileBuffer and SFDLineTileBuffer, they are only needed for VdBox SFC scalability case and not needed for VeBox SFC case. - // Allocate AVS Line Buffer surface---------------------------------------------- - size = GetAvsLineBufferSize(false, sfcStateParams->b8tapChromafiltering, sfcStateParams->dwInputFrameWidth, sfcStateParams->dwInputFrameHeight); - VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_AVSLineBufferSurfaceArray, size, "SfcAVSLineBufferSurface")); + // Allocate AVS Line Buffer surface---------------------------------------------- + size = GetAvsLineBufferSize(false, sfcStateParams->b8tapChromafiltering, sfcStateParams->dwInputFrameWidth, sfcStateParams->dwInputFrameHeight); + VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass, size, "SfcAVSLineBufferSurfacefor1stPassofSfc2Pass")); - // Allocate IEF Line Buffer surface---------------------------------------------- - size = GetIefLineBufferSize(false, sfcStateParams->dwScaledRegionHeight); - VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_IEFLineBufferSurfaceArray, size, "SfcIEFLineBufferSurface")); + // Allocate IEF Line Buffer surface---------------------------------------------- + size = GetIefLineBufferSize(false, sfcStateParams->dwScaledRegionHeight); + VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass, size, "SfcIEFLineBufferSurfacefor1stPassofSfc2Pass")); - if (sfcStateParams->dwScaledRegionHeight > SFC_LINEBUFEER_SIZE_LIMITED) + if (sfcStateParams->dwScaledRegionHeight > SFC_LINEBUFEER_SIZE_LIMITED) + { + // Allocate SFD Line Buffer surface + size = GetSfdLineBufferSize(false, sfcStateParams->OutputFrameFormat, sfcStateParams->dwScaledRegionWidth, sfcStateParams->dwScaledRegionHeight); + VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass, size, "SfcSFDLineBufferSurfacefor1stPassofSfc2Pass")); + } + } + else { - // Allocate SFD Line Buffer surface - size = GetSfdLineBufferSize(false, sfcStateParams->OutputFrameFormat, sfcStateParams->dwScaledRegionWidth, sfcStateParams->dwScaledRegionHeight); - VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_SFDLineBufferSurfaceArray, size, "SfcSFDLineBufferSurface")); + if (m_scalabilityParams.numPipe > m_lineBufferAllocatedInArray || + nullptr == m_AVSLineBufferSurfaceArray || + nullptr == m_IEFLineBufferSurfaceArray || + nullptr == m_SFDLineBufferSurfaceArray) + { + DestroyLineBufferArray(m_AVSLineBufferSurfaceArray, m_lineBufferAllocatedInArray); + DestroyLineBufferArray(m_IEFLineBufferSurfaceArray, m_lineBufferAllocatedInArray); + DestroyLineBufferArray(m_SFDLineBufferSurfaceArray, m_lineBufferAllocatedInArray); + m_lineBufferAllocatedInArray = m_scalabilityParams.numPipe; + m_AVSLineBufferSurfaceArray = MOS_NewArray(VP_SURFACE *, m_lineBufferAllocatedInArray); + VP_RENDER_CHK_NULL_RETURN(m_AVSLineBufferSurfaceArray); + m_IEFLineBufferSurfaceArray = MOS_NewArray(VP_SURFACE *, m_lineBufferAllocatedInArray); + VP_RENDER_CHK_NULL_RETURN(m_IEFLineBufferSurfaceArray); + m_SFDLineBufferSurfaceArray = MOS_NewArray(VP_SURFACE *, m_lineBufferAllocatedInArray); + VP_RENDER_CHK_NULL_RETURN(m_SFDLineBufferSurfaceArray); + } + + // for AVSLineBuffer, IEFLineBuffer and SFDLineBuffer, they are only needed when surface allocation bigger than 4150. + // for AVSLineTileBuffer, IEFLineTileBuffer and SFDLineTileBuffer, they are only needed for VdBox SFC scalability case and not needed for VeBox SFC case. + + // Allocate AVS Line Buffer surface---------------------------------------------- + size = GetAvsLineBufferSize(false, sfcStateParams->b8tapChromafiltering, sfcStateParams->dwInputFrameWidth, sfcStateParams->dwInputFrameHeight); + VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_AVSLineBufferSurfaceArray, size, "SfcAVSLineBufferSurface")); + + // Allocate IEF Line Buffer surface---------------------------------------------- + size = GetIefLineBufferSize(false, sfcStateParams->dwScaledRegionHeight); + VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_IEFLineBufferSurfaceArray, size, "SfcIEFLineBufferSurface")); + + if (sfcStateParams->dwScaledRegionHeight > SFC_LINEBUFEER_SIZE_LIMITED) + { + // Allocate SFD Line Buffer surface + size = GetSfdLineBufferSize(false, sfcStateParams->OutputFrameFormat, sfcStateParams->dwScaledRegionWidth, sfcStateParams->dwScaledRegionHeight); + VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_SFDLineBufferSurfaceArray, size, "SfcSFDLineBufferSurface")); + } } if (m_bVdboxToSfc) diff --git a/media_driver/media_softlet/agnostic/m12/m12/vp/hal/packet/vp_render_sfc_m12.cpp b/media_driver/media_softlet/agnostic/m12/m12/vp/hal/packet/vp_render_sfc_m12.cpp index 3f359d72986..de725c5152f 100644 --- a/media_driver/media_softlet/agnostic/m12/m12/vp/hal/packet/vp_render_sfc_m12.cpp +++ b/media_driver/media_softlet/agnostic/m12/m12/vp/hal/packet/vp_render_sfc_m12.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2020, Intel Corporation +* Copyright (c) 2020-2024, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -61,9 +61,19 @@ MOS_STATUS SfcRenderM12::SetupSfcState( sfcStateParamsM12 = static_cast(m_renderDataLegacy.sfcStateParams); VP_RENDER_CHK_NULL_RETURN(sfcStateParamsM12); - VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(sfcStateParamsM12->resAvsLineBuffer, m_AVSLineBufferSurfaceArray[m_scalabilityParams.curPipe])); - VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(sfcStateParamsM12->resIefLineBuffer, m_IEFLineBufferSurfaceArray[m_scalabilityParams.curPipe])); - VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(sfcStateParamsM12->resSfdLineBuffer, m_SFDLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + if (m_renderData.b1stPassOfSfc2PassScaling) + { + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(sfcStateParamsM12->resAvsLineBuffer, m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass[m_scalabilityParams.curPipe])); + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(sfcStateParamsM12->resIefLineBuffer, m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass[m_scalabilityParams.curPipe])); + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(sfcStateParamsM12->resSfdLineBuffer, m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass[m_scalabilityParams.curPipe])); + } + else + { + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(sfcStateParamsM12->resAvsLineBuffer, m_AVSLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(sfcStateParamsM12->resIefLineBuffer, m_IEFLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(sfcStateParamsM12->resSfdLineBuffer, m_SFDLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + } + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(sfcStateParamsM12->resAvsLineTileBuffer, m_AVSLineTileBufferSurface)); VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(sfcStateParamsM12->resIefLineTileBuffer, m_IEFLineTileBufferSurface)); VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(sfcStateParamsM12->resSfdLineTileBuffer, m_SFDLineTileBufferSurface)); diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/vp/hal/packet/vp_render_sfc_xe2_lpm_base.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/vp/hal/packet/vp_render_sfc_xe2_lpm_base.cpp index 12a3fd89887..ad08f27a4c7 100644 --- a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/vp/hal/packet/vp_render_sfc_xe2_lpm_base.cpp +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/vp/hal/packet/vp_render_sfc_xe2_lpm_base.cpp @@ -58,8 +58,14 @@ MOS_STATUS SfcRenderXe2_Lpm_Base::SetupSfcState( //Set SFD Line Buffer VP_RENDER_CHK_NULL_RETURN(m_renderData.sfcStateParams); - - VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->resSfdLineBuffer, m_SFDLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + if (m_renderData.b1stPassOfSfc2PassScaling) + { + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->resSfdLineBuffer, m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass[m_scalabilityParams.curPipe])); + } + else + { + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->resSfdLineBuffer, m_SFDLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + } VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->resAvsLineTileBuffer, m_AVSLineTileBufferSurface)); VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->resIefLineTileBuffer, m_IEFLineTileBufferSurface)); VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->resSfdLineTileBuffer, m_SFDLineTileBufferSurface)); diff --git a/media_softlet/agnostic/Xe_M_plus/Xe_LPM_plus_base/vp/hal/packet/vp_render_sfc_xe_lpm_plus_base.cpp b/media_softlet/agnostic/Xe_M_plus/Xe_LPM_plus_base/vp/hal/packet/vp_render_sfc_xe_lpm_plus_base.cpp index 5a88a3abc7e..6768901b03d 100644 --- a/media_softlet/agnostic/Xe_M_plus/Xe_LPM_plus_base/vp/hal/packet/vp_render_sfc_xe_lpm_plus_base.cpp +++ b/media_softlet/agnostic/Xe_M_plus/Xe_LPM_plus_base/vp/hal/packet/vp_render_sfc_xe_lpm_plus_base.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2022, Intel Corporation +* Copyright (c) 2022-2024, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -58,7 +58,15 @@ MOS_STATUS SfcRenderXe_Lpm_Plus_Base::SetupSfcState( //Set SFD Line Buffer VP_RENDER_CHK_NULL_RETURN(m_renderData.sfcStateParams); - VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->resSfdLineBuffer, m_SFDLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + if (m_renderData.b1stPassOfSfc2PassScaling) + { + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->resSfdLineBuffer, m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass[m_scalabilityParams.curPipe])); + } + else + { + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->resSfdLineBuffer, m_SFDLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + } + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->resAvsLineTileBuffer, m_AVSLineTileBufferSurface)); VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->resIefLineTileBuffer, m_IEFLineTileBufferSurface)); VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->resSfdLineTileBuffer, m_SFDLineTileBufferSurface)); diff --git a/media_softlet/agnostic/common/vp/hal/features/vp_filter.h b/media_softlet/agnostic/common/vp/hal/features/vp_filter.h index 4d82132f177..1ea6502e2c4 100644 --- a/media_softlet/agnostic/common/vp/hal/features/vp_filter.h +++ b/media_softlet/agnostic/common/vp/hal/features/vp_filter.h @@ -162,6 +162,7 @@ struct _SFC_SCALING_PARAMS VPHAL_SAMPLE_TYPE srcSampleType; VPHAL_SAMPLE_TYPE dstSampleType; bool isDemosaicNeeded; // 0: demosaic is not needed; 1: demosaic is needed + bool b1stPassOfSfc2PassScaling; // 1st Pass of Sfc 2Pass Scaling }; struct _SFC_CSC_PARAMS diff --git a/media_softlet/agnostic/common/vp/hal/features/vp_scaling_filter.cpp b/media_softlet/agnostic/common/vp/hal/features/vp_scaling_filter.cpp index 69a5fa298c1..3e980e0cafc 100644 --- a/media_softlet/agnostic/common/vp/hal/features/vp_scaling_filter.cpp +++ b/media_softlet/agnostic/common/vp/hal/features/vp_scaling_filter.cpp @@ -637,6 +637,8 @@ MOS_STATUS VpScalingFilter::CalculateEngineParams() m_sfcScalingParams->isDemosaicNeeded = m_executeCaps.bDemosaicInUse; VP_RENDER_CHK_STATUS_RETURN(SetColorFillParams()); + + m_sfcScalingParams->b1stPassOfSfc2PassScaling = m_executeCaps.b1stPassOfSfc2PassScaling; } // Need add support for Render engine else diff --git a/media_softlet/agnostic/common/vp/hal/packet/vp_render_sfc_base.cpp b/media_softlet/agnostic/common/vp/hal/packet/vp_render_sfc_base.cpp index 5bd21296188..edc59d9d420 100644 --- a/media_softlet/agnostic/common/vp/hal/packet/vp_render_sfc_base.cpp +++ b/media_softlet/agnostic/common/vp/hal/packet/vp_render_sfc_base.cpp @@ -581,8 +581,16 @@ MOS_STATUS SfcRenderBase::SetupSfcState(PVP_SURFACE targetSurface) m_renderData.sfcStateParams->pOsResOutputSurface = &targetSurface->osSurface->OsResource; - VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->pOsResAVSLineBuffer, m_AVSLineBufferSurfaceArray[m_scalabilityParams.curPipe])); - VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->pOsResIEFLineBuffer, m_IEFLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + if (m_renderData.b1stPassOfSfc2PassScaling) + { + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->pOsResAVSLineBuffer, m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass[m_scalabilityParams.curPipe])); + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->pOsResIEFLineBuffer, m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass[m_scalabilityParams.curPipe])); + } + else + { + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->pOsResAVSLineBuffer, m_AVSLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + VP_RENDER_CHK_STATUS_RETURN(SetLineBuffer(m_renderData.sfcStateParams->pOsResIEFLineBuffer, m_IEFLineBufferSurfaceArray[m_scalabilityParams.curPipe])); + } VP_RENDER_CHK_STATUS_RETURN(SetupScalabilityParams()); @@ -676,6 +684,8 @@ MOS_STATUS SfcRenderBase::SetScalingParams(PSFC_SCALING_PARAMS scalingParams) VP_PUBLIC_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER); } + m_renderData.b1stPassOfSfc2PassScaling = scalingParams->b1stPassOfSfc2PassScaling; + VP_RENDER_NORMALMESSAGE("fScaleX %f, fScaleY %f, bScaling %d, SfcScalingMode %d, SfcInputFormat %d, bRectangleEnabled", m_renderData.fScaleX, m_renderData.fScaleY, (m_renderData.bScaling ? 1 : 0), @@ -1419,39 +1429,80 @@ MOS_STATUS SfcRenderBase::AllocateResources() VP_RENDER_CHK_NULL_RETURN(m_allocator); VP_RENDER_CHK_NULL_RETURN(m_renderData.sfcStateParams); - if (m_scalabilityParams.numPipe > m_lineBufferAllocatedInArray || - nullptr == m_AVSLineBufferSurfaceArray || - nullptr == m_IEFLineBufferSurfaceArray || - nullptr == m_SFDLineBufferSurfaceArray) + // for 1st pass of Sfc 2Pass case, use the standalone line buffer array to avoid line buffer reallocation + if (m_renderData.b1stPassOfSfc2PassScaling) { - DestroyLineBufferArray(m_AVSLineBufferSurfaceArray); - DestroyLineBufferArray(m_IEFLineBufferSurfaceArray); - DestroyLineBufferArray(m_SFDLineBufferSurfaceArray); - m_lineBufferAllocatedInArray = m_scalabilityParams.numPipe; - m_AVSLineBufferSurfaceArray = MOS_NewArray(VP_SURFACE*, m_lineBufferAllocatedInArray); - VP_RENDER_CHK_NULL_RETURN(m_AVSLineBufferSurfaceArray); - m_IEFLineBufferSurfaceArray = MOS_NewArray(VP_SURFACE*, m_lineBufferAllocatedInArray); - VP_RENDER_CHK_NULL_RETURN(m_IEFLineBufferSurfaceArray); - m_SFDLineBufferSurfaceArray = MOS_NewArray(VP_SURFACE*, m_lineBufferAllocatedInArray); - VP_RENDER_CHK_NULL_RETURN(m_SFDLineBufferSurfaceArray); - } + if (m_scalabilityParams.numPipe > m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass || + nullptr == m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass || + nullptr == m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass || + nullptr == m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass) + { + DestroyLineBufferArray(m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + DestroyLineBufferArray(m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + DestroyLineBufferArray(m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass = m_scalabilityParams.numPipe; + m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass = MOS_NewArray(VP_SURFACE*, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + VP_RENDER_CHK_NULL_RETURN(m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass); + m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass = MOS_NewArray(VP_SURFACE*, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + VP_RENDER_CHK_NULL_RETURN(m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass); + m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass = MOS_NewArray(VP_SURFACE*, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + VP_RENDER_CHK_NULL_RETURN(m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass); + } - // for AVSLineBuffer, IEFLineBuffer and SFDLineBuffer, they are only needed when surface allocation bigger than 4150. - // for AVSLineTileBuffer, IEFLineTileBuffer and SFDLineTileBuffer, they are only needed for VdBox SFC scalability case and not needed for VeBox SFC case. + // for AVSLineBuffer, IEFLineBuffer and SFDLineBuffer, they are only needed when surface allocation bigger than 4150. + // for AVSLineTileBuffer, IEFLineTileBuffer and SFDLineTileBuffer, they are only needed for VdBox SFC scalability case and not needed for VeBox SFC case. - // Allocate AVS Line Buffer surface---------------------------------------------- - size = GetAvsLineBufferSize(false, m_renderData.sfcStateParams->b8tapChromafiltering, m_renderData.sfcStateParams->dwInputFrameWidth, m_renderData.sfcStateParams->dwInputFrameHeight); - VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_AVSLineBufferSurfaceArray, size, "SfcAVSLineBufferSurface")); + // Allocate AVS Line Buffer surface---------------------------------------------- + size = GetAvsLineBufferSize(false, m_renderData.sfcStateParams->b8tapChromafiltering, m_renderData.sfcStateParams->dwInputFrameWidth, m_renderData.sfcStateParams->dwInputFrameHeight); + VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass, size, "SfcAVSLineBufferSurfacefor1stPassofSfc2Pass")); - // Allocate IEF Line Buffer surface---------------------------------------------- - size = GetIefLineBufferSize(false, m_renderData.sfcStateParams->dwScaledRegionHeight); - VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_IEFLineBufferSurfaceArray, size, "SfcIEFLineBufferSurface")); + // Allocate IEF Line Buffer surface---------------------------------------------- + size = GetIefLineBufferSize(false, m_renderData.sfcStateParams->dwScaledRegionHeight); + VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass, size, "SfcIEFLineBufferSurfacefor1stPassofSfc2Pass")); - if (m_bVdboxToSfc || m_renderData.sfcStateParams->dwScaledRegionHeight > SFC_LINEBUFEER_SIZE_LIMITED) + if (m_bVdboxToSfc || m_renderData.sfcStateParams->dwScaledRegionHeight > SFC_LINEBUFEER_SIZE_LIMITED) + { + // Allocate SFD Line Buffer surface + size = GetSfdLineBufferSize(false, m_renderData.sfcStateParams->OutputFrameFormat, m_renderData.sfcStateParams->dwScaledRegionWidth, m_renderData.sfcStateParams->dwScaledRegionHeight); + VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass, size, "SfcSFDLineBufferSurfacefor1stPassofSfc2Pass")); + } + } + else { - // Allocate SFD Line Buffer surface - size = GetSfdLineBufferSize(false, m_renderData.sfcStateParams->OutputFrameFormat, m_renderData.sfcStateParams->dwScaledRegionWidth, m_renderData.sfcStateParams->dwScaledRegionHeight); - VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_SFDLineBufferSurfaceArray, size, "SfcSFDLineBufferSurface")); + if (m_scalabilityParams.numPipe > m_lineBufferAllocatedInArray || + nullptr == m_AVSLineBufferSurfaceArray || + nullptr == m_IEFLineBufferSurfaceArray || + nullptr == m_SFDLineBufferSurfaceArray) + { + DestroyLineBufferArray(m_AVSLineBufferSurfaceArray, m_lineBufferAllocatedInArray); + DestroyLineBufferArray(m_IEFLineBufferSurfaceArray, m_lineBufferAllocatedInArray); + DestroyLineBufferArray(m_SFDLineBufferSurfaceArray, m_lineBufferAllocatedInArray); + m_lineBufferAllocatedInArray = m_scalabilityParams.numPipe; + m_AVSLineBufferSurfaceArray = MOS_NewArray(VP_SURFACE*, m_lineBufferAllocatedInArray); + VP_RENDER_CHK_NULL_RETURN(m_AVSLineBufferSurfaceArray); + m_IEFLineBufferSurfaceArray = MOS_NewArray(VP_SURFACE*, m_lineBufferAllocatedInArray); + VP_RENDER_CHK_NULL_RETURN(m_IEFLineBufferSurfaceArray); + m_SFDLineBufferSurfaceArray = MOS_NewArray(VP_SURFACE*, m_lineBufferAllocatedInArray); + VP_RENDER_CHK_NULL_RETURN(m_SFDLineBufferSurfaceArray); + } + + // for AVSLineBuffer, IEFLineBuffer and SFDLineBuffer, they are only needed when surface allocation bigger than 4150. + // for AVSLineTileBuffer, IEFLineTileBuffer and SFDLineTileBuffer, they are only needed for VdBox SFC scalability case and not needed for VeBox SFC case. + + // Allocate AVS Line Buffer surface---------------------------------------------- + size = GetAvsLineBufferSize(false, m_renderData.sfcStateParams->b8tapChromafiltering, m_renderData.sfcStateParams->dwInputFrameWidth, m_renderData.sfcStateParams->dwInputFrameHeight); + VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_AVSLineBufferSurfaceArray, size, "SfcAVSLineBufferSurface")); + + // Allocate IEF Line Buffer surface---------------------------------------------- + size = GetIefLineBufferSize(false, m_renderData.sfcStateParams->dwScaledRegionHeight); + VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_IEFLineBufferSurfaceArray, size, "SfcIEFLineBufferSurface")); + + if (m_bVdboxToSfc || m_renderData.sfcStateParams->dwScaledRegionHeight > SFC_LINEBUFEER_SIZE_LIMITED) + { + // Allocate SFD Line Buffer surface + size = GetSfdLineBufferSize(false, m_renderData.sfcStateParams->OutputFrameFormat, m_renderData.sfcStateParams->dwScaledRegionWidth, m_renderData.sfcStateParams->dwScaledRegionHeight); + VP_RENDER_CHK_STATUS_RETURN(AllocateLineBufferArray(m_SFDLineBufferSurfaceArray, size, "SfcSFDLineBufferSurface")); + } } if (m_bVdboxToSfc) @@ -1471,7 +1522,7 @@ MOS_STATUS SfcRenderBase::AllocateResources() return MOS_STATUS_SUCCESS; } -MOS_STATUS SfcRenderBase::DestroyLineBufferArray(VP_SURFACE **&lineBufferArray) +MOS_STATUS SfcRenderBase::DestroyLineBufferArray(VP_SURFACE **&lineBufferArray, int32_t count) { VP_FUNC_CALL(); @@ -1479,8 +1530,8 @@ MOS_STATUS SfcRenderBase::DestroyLineBufferArray(VP_SURFACE **&lineBufferArray) { return MOS_STATUS_SUCCESS; } - // Use m_lineBufferAllocatedInArray instead of numPipe to destroy all surfaces. - for (int32_t i = 0; i < m_lineBufferAllocatedInArray; ++i) + // Use count instead of numPipe to destroy all surfaces. + for (int32_t i = 0; i < count; ++i) { if (lineBufferArray[i]) { @@ -1497,13 +1548,13 @@ MOS_STATUS SfcRenderBase::FreeResources() VP_RENDER_CHK_NULL_RETURN(m_allocator); // Free AVS Line Buffer surface for SFC - DestroyLineBufferArray(m_AVSLineBufferSurfaceArray); + DestroyLineBufferArray(m_AVSLineBufferSurfaceArray, m_lineBufferAllocatedInArray); // Free IEF Line Buffer surface for SFC - DestroyLineBufferArray(m_IEFLineBufferSurfaceArray); + DestroyLineBufferArray(m_IEFLineBufferSurfaceArray, m_lineBufferAllocatedInArray); // Free SFD Line Buffer surface for SFC - DestroyLineBufferArray(m_SFDLineBufferSurfaceArray); + DestroyLineBufferArray(m_SFDLineBufferSurfaceArray, m_lineBufferAllocatedInArray); // Free AVS Line Tile Buffer surface for SFC m_allocator->DestroyVpSurface(m_AVSLineTileBufferSurface); @@ -1514,6 +1565,15 @@ MOS_STATUS SfcRenderBase::FreeResources() // Free SFD Line Tile Buffer surface for SFC m_allocator->DestroyVpSurface(m_SFDLineTileBufferSurface); + // Free AVS Line Buffer surface for SFC 1st Pass of Sfc 2Pass + DestroyLineBufferArray(m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + + // Free IEF Line Buffer surface for SFC 1st Pass of Sfc 2Pass + DestroyLineBufferArray(m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + + // Free SFD Line Buffer surface for SFC 1st Pass of Sfc 2Pass + DestroyLineBufferArray(m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass, m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass); + return MOS_STATUS_SUCCESS; } diff --git a/media_softlet/agnostic/common/vp/hal/packet/vp_render_sfc_base.h b/media_softlet/agnostic/common/vp/hal/packet/vp_render_sfc_base.h index 21cbc5ffe52..da6c1baae6d 100644 --- a/media_softlet/agnostic/common/vp/hal/packet/vp_render_sfc_base.h +++ b/media_softlet/agnostic/common/vp/hal/packet/vp_render_sfc_base.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2022, Intel Corporation +/* Copyright (c) 2022-2024, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -441,16 +441,12 @@ class SfcRenderBase //! \details Allocate line buffer //! \param [in/out] lineBufferArray //! pointer to line buffer. - //! \param [in] numPipe - //! size of pipe. - //! \param [in] size - //! size of line buffer. - //! \param [in] bufName - //! name of line buffer. + //! \param [in] count + //! count of line buffer. //! \return MOS_STATUS //! Return MOS_STATUS_SUCCESS if successful, otherwise failed //! - MOS_STATUS DestroyLineBufferArray(VP_SURFACE **&lineBufferArray); + MOS_STATUS DestroyLineBufferArray(VP_SURFACE **&lineBufferArray, int32_t count); //! //! \brief Allocate Resources for SFC Pipe @@ -579,6 +575,11 @@ class SfcRenderBase bool m_disableSfcDithering = false; + VP_SURFACE **m_AVSLineBufferSurfaceArrayfor1stPassofSfc2Pass = nullptr; //!< AVS Line Buffer Surface for SFC 1st Pass of Sfc 2Pass + VP_SURFACE **m_IEFLineBufferSurfaceArrayfor1stPassofSfc2Pass = nullptr; //!< IEF Line Buffer Surface for SFC 1st Pass of Sfc 2Pass + VP_SURFACE **m_SFDLineBufferSurfaceArrayfor1stPassofSfc2Pass = nullptr; //!< SFD Line Buffer Surface for SFC 1st Pass of Sfc 2Pass + int m_lineBufferAllocatedInArrayfor1stPassofSfc2Pass = 1; //!< Line buffer allocated in array for SFC 1st Pass of Sfc 2Pass + MEDIA_CLASS_DEFINE_END(vp__SfcRenderBase) }; diff --git a/media_softlet/agnostic/common/vp/hal/packet/vp_sfc_common.h b/media_softlet/agnostic/common/vp/hal/packet/vp_sfc_common.h index a3f1499e7d4..e830bf6ea23 100644 --- a/media_softlet/agnostic/common/vp/hal/packet/vp_sfc_common.h +++ b/media_softlet/agnostic/common/vp/hal/packet/vp_sfc_common.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2018, Intel Corporation +* Copyright (c) 2018-2024, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -80,6 +80,7 @@ typedef struct _VPHAL_SFC_RENDER_DATA PVP_SURFACE pSfcPipeOutSurface; //!< SFC Pipe output surface bool bForcePolyPhaseCoefs; //!< SFC AVS force polyphase coef + bool b1stPassOfSfc2PassScaling; //!< 1st Pass of Sfc 2Pass Scaling } VP_SFC_RENDER_DATA, *PVP_SFC_RENDER_DATA; @@ -110,6 +111,7 @@ typedef struct _VPHAL_SFC_RENDER_DATA_LEGACY PVP_SURFACE pSfcPipeOutSurface; //!< SFC Pipe output surface bool bForcePolyPhaseCoefs; //!< SFC AVS force polyphase coef + bool b1stPassOfSfc2PassScaling; //!< 1st Pass of Sfc 2Pass Scaling } VP_SFC_RENDER_DATA_LEGACY, * PVP_SFC_RENDER_DATA_LEGACY;