Skip to content

Commit

Permalink
[Encode] add csc copy for misaligned surface
Browse files Browse the repository at this point in the history
add csc copy for misaligned surface.
  • Loading branch information
bai-isaac authored and intel-mediadev committed Dec 28, 2023
1 parent eb578c2 commit df10dc4
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
11 changes: 11 additions & 0 deletions media_driver/agnostic/common/codec/hal/codechal_encode_csc_ds.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,17 @@ class CodechalEncodeCscDs
//!
MOS_STATUS RawSurfaceMediaCopy(MOS_FORMAT format);

//!
//! \brief Surface Need Extra Copy
//!
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
virtual MOS_STATUS SurfaceNeedsExtraCopy()
{
return MOS_STATUS_SUCCESS;
}

protected:
//!
//! \brief CSC kernel supported color format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,13 +858,29 @@ MOS_STATUS CodechalEncodeCscDsG12::InitSfcState()
return MOS_STATUS_SUCCESS;
}

MOS_STATUS CodechalEncodeCscDsG12::SurfaceNeedsExtraCopy()
{
m_needsExtraCopy = true;
return MOS_STATUS_SUCCESS;
}

MOS_STATUS CodechalEncodeCscDsG12::CheckRawSurfaceAlignment(MOS_SURFACE surface)
{
if (m_cscEnableCopy && m_needsExtraCopy)
{
if (surface.Format == Format_A8R8G8B8) // not touch NV12 logic.
{
m_colorRawSurface = cscColorARGB;
m_cscRequireCopy = 1;
}
}

if (m_cscEnableCopy && (surface.dwWidth % m_rawSurfAlignment || surface.dwHeight % m_rawSurfAlignment) &&
m_colorRawSurface != cscColorNv12TileY)
{
m_cscRequireCopy = 1;
}

return MOS_STATUS_SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class CodechalEncodeCscDsG12 : public CodechalEncodeCscDs
virtual MOS_STATUS SetKernelParamsCsc(KernelParams* params) override;
virtual MOS_STATUS InitKernelStateCsc() override;
virtual MOS_STATUS CheckRawColorFormat(MOS_FORMAT format, MOS_TILE_TYPE tileType) override;
virtual MOS_STATUS SurfaceNeedsExtraCopy() override;

private:
//!
Expand Down Expand Up @@ -367,6 +368,8 @@ class CodechalEncodeCscDsG12 : public CodechalEncodeCscDs
virtual MOS_STATUS SendSurfaceCsc(PMOS_COMMAND_BUFFER cmdBuffer) override;
virtual MOS_STATUS InitSfcState() override;
virtual MOS_STATUS CheckRawSurfaceAlignment(MOS_SURFACE surface) override;

bool m_needsExtraCopy = false;
};

#endif // __CodechalEncodeCscDsG12__
19 changes: 19 additions & 0 deletions media_driver/agnostic/gen12/codec/hal/codechal_vdenc_avc_g12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,25 @@ MOS_STATUS CodechalVdencAvcStateG12::InitMmcState()
return MOS_STATUS_SUCCESS;
}

MOS_STATUS CodechalVdencAvcStateG12::CheckResChangeAndCsc()
{
CODECHAL_ENCODE_FUNCTION_ENTER;

if (m_cscDsState && m_rawSurface.Format == Format_A8R8G8B8)
{
uint64_t alignedSize = MOS_MAX((uint64_t)m_picWidthInMb * CODECHAL_MACROBLOCK_WIDTH * 4, (uint64_t)m_rawSurface.dwPitch) *
((uint64_t)m_picHeightInMb * CODECHAL_MACROBLOCK_HEIGHT);

if (m_rawSurface.OsResource.iSize < alignedSize)
{
CODECHAL_ENCODE_CHK_STATUS_RETURN(m_cscDsState->SurfaceNeedsExtraCopy());
}
}

CODECHAL_ENCODE_CHK_STATUS_RETURN(CodechalEncoderState::CheckResChangeAndCsc());
return MOS_STATUS_SUCCESS;
}

void CodechalVdencAvcStateG12::SetMfxAvcImgStateParams(MHW_VDBOX_AVC_IMG_PARAMS& param)
{
CodechalVdencAvcState::SetMfxAvcImgStateParams(param);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class CodechalVdencAvcStateG12 : public CodechalVdencAvcState

MOS_STATUS InitMmcState() override;

virtual MOS_STATUS CheckResChangeAndCsc() override;

//!
//! \brief Create MHW_VDBOX_STATE_CMDSIZE_PARAMS
//!
Expand Down

0 comments on commit df10dc4

Please sign in to comment.