Skip to content

Commit

Permalink
[VP] fix sfc2pass tdr issue
Browse files Browse the repository at this point in the history
make the intermedia surface aligned.
  • Loading branch information
pengwan1 authored and intel-mediadev committed Aug 30, 2024
1 parent f685786 commit 9876014
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ void SwFilter::DestroySwFilter(SwFilter* p)
}
}

VP_MHWINTERFACE *SwFilter::GetHwInterface()
{
VP_FUNC_CALL();

return m_vpInterface.GetHwInterface();
}

/****************************************************************************************************/
/* SwFilterCsc */
/****************************************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ class SwFilter
m_isInExePipe = isInExePipe;
}

VP_MHWINTERFACE* GetHwInterface();

protected:
VpInterface &m_vpInterface;
FeatureType m_type = FeatureTypeInvalid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
}

Expand All @@ -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();

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down Expand Up @@ -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<VpSfcScalingParameter> m_PacketParamFactory;

Expand Down
3 changes: 2 additions & 1 deletion media_softlet/agnostic/common/vp/hal/pipeline/vp_base.h
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down Expand Up @@ -131,6 +131,7 @@ struct _VP_MHWINTERFACE
};

using VP_MHWINTERFACE = _VP_MHWINTERFACE;
using PVP_MHWINTERFACE = VP_MHWINTERFACE *;

class VpBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down Expand Up @@ -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*;
Expand Down

0 comments on commit 9876014

Please sign in to comment.