Skip to content

Commit

Permalink
Revert "[Encode] Fix AVC quality drop for 16-unaligned height"
Browse files Browse the repository at this point in the history
This reverts commit intel-innersource/drivers.gpu.unified#4a2862af3
  • Loading branch information
luleilei1 authored and intel-mediadev committed Oct 31, 2023
1 parent 2d74664 commit 280ad77
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,68 +43,4 @@ MHW_SETPAR_DECL_SRC(VDENC_PIPE_MODE_SELECT, AvcBasicFeatureXe_Lpm_Plus_Base)
return MOS_STATUS_SUCCESS;
}

MHW_SETPAR_DECL_SRC(VDENC_SRC_SURFACE_STATE, AvcBasicFeatureXe_Lpm_Plus_Base)
{
AvcBasicFeature::MHW_SETPAR_F(VDENC_SRC_SURFACE_STATE)(params);

params.width = m_rawSurfaceToPak->dwWidth;
params.height = m_rawSurfaceToPak->dwHeight;

return MOS_STATUS_SUCCESS;
}

MHW_SETPAR_DECL_SRC(MFX_SURFACE_STATE, AvcBasicFeatureXe_Lpm_Plus_Base)
{
AvcBasicFeature::MHW_SETPAR_F(MFX_SURFACE_STATE)(params);

if (params.surfaceId == CODECHAL_MFX_SRC_SURFACE_ID)
{
params.height = m_rawSurfaceToPak->dwHeight - 1;
params.width = m_rawSurfaceToPak->dwWidth - 1;
}

return MOS_STATUS_SUCCESS;
}

bool AvcBasicFeatureXe_Lpm_Plus_Base::InputSurfaceNeedsExtraCopy(const MOS_SURFACE &input)
{
#if _DEBUG || _RELEASE_INTERNAL
static int8_t supported = -1;

if (supported == -1)
{
MediaUserSetting::Value outValue{};

ReadUserSettingForDebug(
m_userSettingPtr,
outValue,
"DisableInputSurfaceCopy",
MediaUserSetting::Group::Sequence);

supported = !outValue.Get<bool>();
}

if (!supported)
{
return false;
}
#endif

uint32_t alignedSize = 0;
switch (input.Format)
{
case Format_NV12:
alignedSize = (m_picWidthInMb * CODECHAL_MACROBLOCK_WIDTH) * (m_picHeightInMb * CODECHAL_MACROBLOCK_HEIGHT) * 3 / 2;
break;
case Format_A8R8G8B8:
alignedSize = (m_picWidthInMb * CODECHAL_MACROBLOCK_WIDTH) * (m_picHeightInMb * CODECHAL_MACROBLOCK_HEIGHT) * 4;
break;
default:
alignedSize = 0;
break;
}

return input.dwSize < alignedSize;
}

} // namespace encode
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ class AvcBasicFeatureXe_Lpm_Plus_Base : public AvcBasicFeature

virtual ~AvcBasicFeatureXe_Lpm_Plus_Base() {}

bool InputSurfaceNeedsExtraCopy(const MOS_SURFACE &input) override;

MHW_SETPAR_DECL_HDR(VDENC_PIPE_MODE_SELECT);
MHW_SETPAR_DECL_HDR(VDENC_SRC_SURFACE_STATE);
MHW_SETPAR_DECL_HDR(MFX_SURFACE_STATE);

MEDIA_CLASS_DEFINE_END(encode__AvcBasicFeatureXe_Lpm_Plus_Base)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,47 @@ MOS_STATUS AvcBasicFeature::PackPictureHeader()
return MOS_STATUS_SUCCESS;
}

bool AvcBasicFeature::InputSurfaceNeedsExtraCopy(const MOS_SURFACE &input)
{
#if _DEBUG || _RELEASE_INTERNAL
static int8_t supported = -1;

if (supported == -1)
{
MediaUserSetting::Value outValue{};

ReadUserSettingForDebug(
m_userSettingPtr,
outValue,
"DisableInputSurfaceCopy",
MediaUserSetting::Group::Sequence);

supported = !outValue.Get<bool>();
}

if (!supported)
{
return false;
}
#endif

uint32_t alignedSize = 0;
switch (input.Format)
{
case Format_NV12:
alignedSize = (m_picWidthInMb * CODECHAL_MACROBLOCK_WIDTH) * (m_picHeightInMb * CODECHAL_MACROBLOCK_HEIGHT) * 3 / 2;
break;
case Format_A8R8G8B8:
alignedSize = (m_picWidthInMb * CODECHAL_MACROBLOCK_WIDTH) * (m_picHeightInMb * CODECHAL_MACROBLOCK_HEIGHT) * 4;
break;
default:
alignedSize = 0;
break;
}

return input.dwSize < alignedSize;
}

MOS_STATUS AvcBasicFeature::UpdateTrackedBufferParameters()
{
uint32_t fieldNumMBs = (uint32_t)m_picWidthInMb * ((m_picHeightInMb + 1) >> 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class AvcBasicFeature : public EncodeBasicFeature,
MOS_STATUS SetSliceStructs();
void CheckResolutionChange();
MOS_STATUS PackPictureHeader();
virtual bool InputSurfaceNeedsExtraCopy(const MOS_SURFACE &input) { return false; };
bool InputSurfaceNeedsExtraCopy(const MOS_SURFACE& input);

virtual MOS_STATUS UpdateTrackedBufferParameters() override;
virtual MOS_STATUS GetTrackedBuffers() override;
Expand Down

0 comments on commit 280ad77

Please sign in to comment.