From 98760145aa7fb9a7f31c2e485f6e5b5233fe647b Mon Sep 17 00:00:00 2001 From: Wang_PengX Date: Fri, 30 Aug 2024 17:11:49 +0800 Subject: [PATCH] [VP] fix sfc2pass tdr issue make the intermedia surface aligned. --- .../vp/hal/feature_manager/sw_filter.cpp | 7 +++++++ .../common/vp/hal/feature_manager/sw_filter.h | 2 ++ .../vp/hal/features/vp_scaling_filter.cpp | 19 ++++++++++++++----- .../vp/hal/features/vp_scaling_filter.h | 4 ++-- .../agnostic/common/vp/hal/pipeline/vp_base.h | 3 ++- .../vp/hal/pipeline/vp_pipeline_common.h | 3 +-- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/media_softlet/agnostic/common/vp/hal/feature_manager/sw_filter.cpp b/media_softlet/agnostic/common/vp/hal/feature_manager/sw_filter.cpp index 08c2b3ddc2..ab760eb0fc 100644 --- a/media_softlet/agnostic/common/vp/hal/feature_manager/sw_filter.cpp +++ b/media_softlet/agnostic/common/vp/hal/feature_manager/sw_filter.cpp @@ -135,6 +135,13 @@ void SwFilter::DestroySwFilter(SwFilter* p) } } +VP_MHWINTERFACE *SwFilter::GetHwInterface() +{ + VP_FUNC_CALL(); + + return m_vpInterface.GetHwInterface(); +} + /****************************************************************************************************/ /* SwFilterCsc */ /****************************************************************************************************/ diff --git a/media_softlet/agnostic/common/vp/hal/feature_manager/sw_filter.h b/media_softlet/agnostic/common/vp/hal/feature_manager/sw_filter.h index b40087063b..5ae7de8525 100644 --- a/media_softlet/agnostic/common/vp/hal/feature_manager/sw_filter.h +++ b/media_softlet/agnostic/common/vp/hal/feature_manager/sw_filter.h @@ -374,6 +374,8 @@ class SwFilter m_isInExePipe = isInExePipe; } + VP_MHWINTERFACE* GetHwInterface(); + protected: VpInterface &m_vpInterface; FeatureType m_type = FeatureTypeInvalid; 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 3e980e0caf..4cf73e68fc 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 @@ -844,7 +844,7 @@ HwFilterParameter *PolicySfcScalingHandler::CreateHwFilterParam(VP_EXECUTE_CAPS } } -uint32_t PolicySfcScalingHandler::Get1stPassScaledSize(uint32_t input, uint32_t output, bool is2PassNeeded) +uint32_t PolicySfcScalingHandler::Get1stPassScaledSize(uint32_t input, uint32_t output, bool is2PassNeeded, uint32_t alignUnit) { VP_FUNC_CALL(); @@ -859,16 +859,18 @@ uint32_t PolicySfcScalingHandler::Get1stPassScaledSize(uint32_t input, uint32_t float ratioFor1stPass = 0; uint32_t scaledSize = 0; + // make sure the scaled Width/Height was aligned in sfc2pass case if (input >= output) { ratioFor1stPass = m_hwCaps.m_rules.sfcMultiPassSupport.scaling.downScaling.ratioFor1stPass; - scaledSize = MOS_MAX(output, (uint32_t)(input * ratioFor1stPass)); + scaledSize = MOS_ALIGN_FLOOR(MOS_MAX(output, (uint32_t)(input * ratioFor1stPass)), alignUnit); } else { ratioFor1stPass = m_hwCaps.m_rules.sfcMultiPassSupport.scaling.upScaling.ratioFor1stPass; - scaledSize = MOS_MIN(output, (uint32_t)(input * ratioFor1stPass)); + scaledSize = MOS_ALIGN_CEIL(MOS_MIN(output, (uint32_t)(input * ratioFor1stPass)), alignUnit); } + return scaledSize; } @@ -881,6 +883,13 @@ MOS_STATUS PolicySfcScalingHandler::UpdateFeaturePipe(VP_EXECUTE_CAPS caps, SwFi if (caps.b1stPassOfSfc2PassScaling) { + uint32_t widthAlignUnit = 0; + uint32_t heightAlignUnit = 0; + PVP_MHWINTERFACE hwInterface = featureScaling->GetHwInterface(); + VP_PUBLIC_CHK_NULL_RETURN(hwInterface); + VP_PUBLIC_CHK_NULL_RETURN(hwInterface->m_vpPlatformInterface); + hwInterface->m_vpPlatformInterface->GetInputFrameWidthHeightAlignUnit(hwInterface, widthAlignUnit, heightAlignUnit, false, CODECHAL_STANDARD_MAX, jpegYUV400); + SwFilterScaling *filter2ndPass = featureScaling; SwFilterScaling *filter1ndPass = (SwFilterScaling *)feature.Clone(); @@ -898,8 +907,8 @@ MOS_STATUS PolicySfcScalingHandler::UpdateFeaturePipe(VP_EXECUTE_CAPS caps, SwFi uint32_t outputWidth = params1stPass.input.rcDst.right - params1stPass.input.rcDst.left; uint32_t outputHeight = params1stPass.input.rcDst.bottom - params1stPass.input.rcDst.top; - uint32_t scaledWidth = Get1stPassScaledSize(inputWidth, outputWidth, filter1ndPass->GetFilterEngineCaps().sfc2PassScalingNeededX); - uint32_t scaledHeight = Get1stPassScaledSize(inputHeight, outputHeight, filter1ndPass->GetFilterEngineCaps().sfc2PassScalingNeededY); + uint32_t scaledWidth = Get1stPassScaledSize(inputWidth, outputWidth, filter1ndPass->GetFilterEngineCaps().sfc2PassScalingNeededX, widthAlignUnit); + uint32_t scaledHeight = Get1stPassScaledSize(inputHeight, outputHeight, filter1ndPass->GetFilterEngineCaps().sfc2PassScalingNeededY, heightAlignUnit); VP_PUBLIC_NORMALMESSAGE("2 pass sfc scaling setting: (%dx%d)->(%dx%d)->(%dx%d)", inputWidth, inputHeight, scaledWidth, scaledHeight, outputWidth, outputHeight); diff --git a/media_softlet/agnostic/common/vp/hal/features/vp_scaling_filter.h b/media_softlet/agnostic/common/vp/hal/features/vp_scaling_filter.h index 17c3e8e5a8..5c175b49c6 100644 --- a/media_softlet/agnostic/common/vp/hal/features/vp_scaling_filter.h +++ b/media_softlet/agnostic/common/vp/hal/features/vp_scaling_filter.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2018-2021, 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"), @@ -224,7 +224,7 @@ class PolicySfcScalingHandler : public PolicyFeatureHandler private: - uint32_t Get1stPassScaledSize(uint32_t input, uint32_t output, bool is2PassNeeded); + uint32_t Get1stPassScaledSize(uint32_t input, uint32_t output, bool is2PassNeeded, uint32_t alignUnit); PacketParamFactory m_PacketParamFactory; diff --git a/media_softlet/agnostic/common/vp/hal/pipeline/vp_base.h b/media_softlet/agnostic/common/vp/hal/pipeline/vp_base.h index 419d510f9f..7e2f01fce8 100644 --- a/media_softlet/agnostic/common/vp/hal/pipeline/vp_base.h +++ b/media_softlet/agnostic/common/vp/hal/pipeline/vp_base.h @@ -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"), @@ -131,6 +131,7 @@ struct _VP_MHWINTERFACE }; using VP_MHWINTERFACE = _VP_MHWINTERFACE; +using PVP_MHWINTERFACE = VP_MHWINTERFACE *; class VpBase { diff --git a/media_softlet/agnostic/common/vp/hal/pipeline/vp_pipeline_common.h b/media_softlet/agnostic/common/vp/hal/pipeline/vp_pipeline_common.h index 6a370d646d..bfcfe54958 100644 --- a/media_softlet/agnostic/common/vp/hal/pipeline/vp_pipeline_common.h +++ b/media_softlet/agnostic/common/vp/hal/pipeline/vp_pipeline_common.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2018-2022, 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"), @@ -293,7 +293,6 @@ union RESOURCE_ASSIGNMENT_HINT uint32_t value[RESOURCE_ASSIGNMENT_HINT_SIZE]; }; -using PVP_MHWINTERFACE = VP_MHWINTERFACE * ; using VP_EXECUTE_CAPS = _VP_EXECUTE_CAPS; using VP_PACKET_ENGINE = _VP_PACKET_ENGINE; using PVP_SURFACE = VP_SURFACE*;