Skip to content

Commit

Permalink
[Encode] Reference surface dump Enable in AV1
Browse files Browse the repository at this point in the history
* [Encode] Reference surface dump Enable in AV1

1. dump reference frames before submit encode
2. move rawsurface dump timing before encode
  • Loading branch information
qiangpan1 authored and intel-mediadev committed Nov 30, 2023
1 parent 462728f commit 4d72c1e
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ namespace encode
#endif
#if USE_CODECHAL_DEBUG_TOOL
ENCODE_CHK_STATUS_RETURN(DumpStatistics());
ENCODE_CHK_STATUS_RETURN(Av1VdencPkt::DumpInput());
#endif // USE_CODECHAL_DEBUG_TOOL
return MOS_STATUS_SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ MOS_STATUS Av1VdencPktXe_Lpm_Plus_Base::Submit(
ENCODE_CHK_STATUS_RETURN(Mos_Solo_PostProcessEncode(m_osInterface, &m_basicFeature->m_resBitstreamBuffer, &m_basicFeature->m_reconSurface));
#if USE_CODECHAL_DEBUG_TOOL
ENCODE_CHK_STATUS_RETURN(DumpStatistics());
ENCODE_CHK_STATUS_RETURN(Av1VdencPkt::DumpInput());
#endif // USE_CODECHAL_DEBUG_TOOL
return MOS_STATUS_SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ namespace encode{
{
ENCODE_CHK_NULL_RETURN(m_basicFeature->m_av1SeqParams);
statusReportData->qpY = (uint8_t)(((uint32_t)encodeStatusMfx->qpStatusCount.avpCumulativeQP) / (frameWidthInSb * frameHeightInSb));
ENCODE_VERBOSEMESSAGE("statusReportData->qpY: %d\n", statusReportData->qpY);
}

CODECHAL_DEBUG_TOOL(
Expand Down Expand Up @@ -1777,6 +1778,28 @@ namespace encode{
}

#if USE_CODECHAL_DEBUG_TOOL
MOS_STATUS Av1VdencPkt::DumpInput()
{
ENCODE_FUNC_CALL();
ENCODE_CHK_NULL_RETURN(m_pipeline);
ENCODE_CHK_NULL_RETURN(m_basicFeature);

CodechalDebugInterface *debugInterface = m_pipeline->GetDebugInterface();
ENCODE_CHK_NULL_RETURN(debugInterface);

debugInterface->m_DumpInputNum = m_basicFeature->m_frameNum - 1;

ENCODE_CHK_NULL_RETURN(m_basicFeature->m_ref.GetCurrRefList());
CODEC_REF_LIST currRefList = *((CODEC_REF_LIST *)m_basicFeature->m_ref.GetCurrRefList());

ENCODE_CHK_STATUS_RETURN(debugInterface->DumpYUVSurface(
&currRefList.sRefRawBuffer,
CodechalDbgAttr::attrEncodeRawInputSurface,
"SrcSurf"));
ENCODE_CHK_STATUS_RETURN(m_basicFeature->m_ref.DumpInput(m_pipeline));

return MOS_STATUS_SUCCESS;
}
MOS_STATUS Av1VdencPkt::DumpResources(EncodeStatusMfx *encodeStatusMfx, EncodeStatusReportData *statusReportData)
{
ENCODE_FUNC_CALL();
Expand All @@ -1794,7 +1817,7 @@ namespace encode{
currRefList.RefPic = statusReportData->currOriginalPic;

debugInterface->m_currPic = statusReportData->currOriginalPic;
debugInterface->m_bufferDumpFrameNum = m_basicFeature->m_frameNum - 1;
debugInterface->m_bufferDumpFrameNum = m_statusReport->GetReportedCount();
debugInterface->m_frameType = encodeStatusMfx->pictureCodingType;

if (m_resVDEncPakObjCmdStreamOutBuffer != nullptr)
Expand Down Expand Up @@ -1891,11 +1914,6 @@ namespace encode{
m_basicFeature->m_frameHeight))
}

ENCODE_CHK_STATUS_RETURN(debugInterface->DumpYUVSurface(
&currRefList.sRefRawBuffer,
CodechalDbgAttr::attrEncodeRawInputSurface,
"SrcSurf"))

return MOS_STATUS_SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ class Av1VdencPkt : public CmdPacket, public MediaStatusReportObserver, public m
}

protected:
#if USE_CODECHAL_DEBUG_TOOL
//!
//! \brief Dump input resources or infomation before submit
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
virtual MOS_STATUS DumpInput();
#endif

virtual MOS_STATUS AllocateResources();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "encode_utils.h"
#include "encode_av1_reference_frames.h"
#include "codec_def_encode_av1.h"
#include "codechal_debug.h"
#include "encode_av1_vdenc_pipeline.h"

namespace encode
{
Expand All @@ -51,7 +53,71 @@ Av1ReferenceFrames::~Av1ReferenceFrames()

EncodeFreeDataList(m_refList, CODEC_AV1_NUM_UNCOMPRESSED_SURFACE);
}
#if USE_CODECHAL_DEBUG_TOOL
MOS_STATUS Av1ReferenceFrames::DumpInput(Av1VdencPipeline *pipeline)
{
ENCODE_FUNC_CALL();

CodechalDebugInterface *debugInterface = pipeline->GetDebugInterface();
ENCODE_CHK_NULL_RETURN(debugInterface);

std::stringstream pipeIdxStrStream("");
pipeIdxStrStream << "_" << (int)pipeline->GetCurrentPipe();
std::string surfacePassName = "Pass" + std::to_string((uint32_t)pipeline->GetCurrentPass());
surfacePassName += pipeIdxStrStream.str() + "_input";

if (m_refFrameFlags == 0)
{
ENCODE_VERBOSEMESSAGE("Ref list is empty!.Only keyframe is expected.");
return MOS_STATUS_SUCCESS;
}
//Dump surface
{
std::string reflagName;
for (auto i = 0; i < av1NumInterRefFrames; i++)
{
if (m_refFrameFlags & (AV1_ENCODE_GET_REF_FALG(i)))
{
switch (i+1) {
case lastFrame:
reflagName = "_LastRefSurf";
break;
case last2Frame:
reflagName = "_Last2RefSurf";
break;
case last3Frame:
reflagName = "_Last3RefSurf";
break;
case bwdRefFrame:
reflagName = "_BWDRefSurf";
break;
case goldenFrame:
reflagName = "_GoldenRefSurf";
break;
case altRef2Frame:
reflagName = "_Alt2RefSurf";
break;
case altRefFrame:
reflagName = "_AltRefSurf";
break;
default:
reflagName = "";
break;
}
if (reflagName == "")
{
continue;
}
ENCODE_CHK_STATUS_RETURN(debugInterface->DumpYUVSurface(
m_currRefPic[i],
CodechalDbgAttr::attrReferenceSurfaces,
(surfacePassName + reflagName).data()));
}
}
}
return MOS_STATUS_SUCCESS;
}
#endif
static bool MmcEnabled(MOS_MEMCOMP_STATE state)
{
return state == MOS_MEMCOMP_RC || state == MOS_MEMCOMP_MC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace encode
#define AV1_ENCODE_GET_REF_FALG(i) (0x1 << i)

class Av1BasicFeature;
class Av1VdencPipeline;

class Av1ReferenceFrames : public mhw::vdbox::vdenc::Itf::ParSetting, public mhw::vdbox::avp::Itf::ParSetting
{
Expand Down Expand Up @@ -179,6 +180,13 @@ class Av1ReferenceFrames : public mhw::vdbox::vdenc::Itf::ParSetting, public mhw
bool CheckSegmentForPrimeFrame();
uint8_t RefFrameL0L1(CODEC_Ref_Frame_Ctrl_AV1 const &ref_frame_ctrl) const;

//!
//! \brief Dump input resources or infomation before submit
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
MOS_STATUS DumpInput(Av1VdencPipeline *pipeline);

MHW_SETPAR_DECL_HDR(VDENC_PIPE_BUF_ADDR_STATE);

MHW_SETPAR_DECL_HDR(VDENC_CMD2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ namespace encode

#if USE_CODECHAL_DEBUG_TOOL && _ENCODE_RESERVED
m_hevcParDump->SetParFile();
ENCODE_CHK_STATUS_RETURN(DumpInput());
#endif

return MOS_STATUS_SUCCESS;
Expand Down Expand Up @@ -2668,6 +2669,26 @@ MOS_STATUS HevcVdencPkt::AddAllCmds_HCP_PAK_INSERT_OBJECT_BRC(PMOS_COMMAND_BUFFE
}

#if USE_CODECHAL_DEBUG_TOOL
MOS_STATUS HevcVdencPkt::DumpInput()
{
ENCODE_FUNC_CALL();
ENCODE_CHK_NULL_RETURN(m_pipeline);
ENCODE_CHK_NULL_RETURN(m_basicFeature);

CodechalDebugInterface *debugInterface = m_pipeline->GetDebugInterface();
ENCODE_CHK_NULL_RETURN(debugInterface);

debugInterface->m_DumpInputNum = m_basicFeature->m_frameNum - 1;

ENCODE_CHK_NULL_RETURN(m_basicFeature->m_ref.GetCurrRefList());
CODEC_REF_LIST currRefList = *((CODEC_REF_LIST *)m_basicFeature->m_ref.GetCurrRefList());

ENCODE_CHK_STATUS_RETURN(debugInterface->DumpYUVSurface(
&currRefList.sRefRawBuffer,
CodechalDbgAttr::attrEncodeRawInputSurface,
"SrcSurf"))
return MOS_STATUS_SUCCESS;
}

MOS_STATUS HevcVdencPkt::DumpResources(
EncodeStatusMfx * encodeStatusMfx,
Expand Down Expand Up @@ -2815,10 +2836,6 @@ MOS_STATUS HevcVdencPkt::AddAllCmds_HCP_PAK_INSERT_OBJECT_BRC(PMOS_COMMAND_BUFFE
ENCODE_CHK_STATUS_RETURN(debugInterface->DumpBltOutput(
&currRefList.sRefRawBuffer,
CodechalDbgAttr::attrDecodeBltOutput));
ENCODE_CHK_STATUS_RETURN(debugInterface->DumpYUVSurface(
&currRefList.sRefRawBuffer,
CodechalDbgAttr::attrEncodeRawInputSurface,
"SrcSurf"))

return MOS_STATUS_SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ namespace encode
MOS_STATUS PrepareHWMetaData(MOS_COMMAND_BUFFER *cmdBuffer);

protected:
#if USE_CODECHAL_DEBUG_TOOL
//!
//! \brief Dump input resources or infomation before submit
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
virtual MOS_STATUS DumpInput();
#endif
//!
//! \brief get SliceStatesSize and SlicePatchListSize,
//!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class MediaDebugInterface
bool m_swCRC = false;
uint16_t m_preIndex = 0;
uint16_t m_refIndex = 0;
size_t m_DumpInputNum = 0;
size_t m_bufferDumpFrameNum = 0;
uint32_t m_decodeSurfDumpFrameNum = 0;
uint32_t m_streamId = 0;
Expand Down

0 comments on commit 4d72c1e

Please sign in to comment.