diff --git a/media_driver/media_softlet/agnostic/Xe_M/Xe_M_base/codec/hal/enc/av1/packet/encode_av1_vdenc_packet_xe_m_base.cpp b/media_driver/media_softlet/agnostic/Xe_M/Xe_M_base/codec/hal/enc/av1/packet/encode_av1_vdenc_packet_xe_m_base.cpp index fa2584d60d6..375f4a427ac 100644 --- a/media_driver/media_softlet/agnostic/Xe_M/Xe_M_base/codec/hal/enc/av1/packet/encode_av1_vdenc_packet_xe_m_base.cpp +++ b/media_driver/media_softlet/agnostic/Xe_M/Xe_M_base/codec/hal/enc/av1/packet/encode_av1_vdenc_packet_xe_m_base.cpp @@ -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; } diff --git a/media_softlet/agnostic/Xe_M_plus/Xe_LPM_plus_base/codec/hal/enc/av1/packet/encode_av1_vdenc_packet_xe_lpm_plus_base.cpp b/media_softlet/agnostic/Xe_M_plus/Xe_LPM_plus_base/codec/hal/enc/av1/packet/encode_av1_vdenc_packet_xe_lpm_plus_base.cpp index 8c7e2e28920..e75552e4c55 100644 --- a/media_softlet/agnostic/Xe_M_plus/Xe_LPM_plus_base/codec/hal/enc/av1/packet/encode_av1_vdenc_packet_xe_lpm_plus_base.cpp +++ b/media_softlet/agnostic/Xe_M_plus/Xe_LPM_plus_base/codec/hal/enc/av1/packet/encode_av1_vdenc_packet_xe_lpm_plus_base.cpp @@ -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; } diff --git a/media_softlet/agnostic/common/codec/hal/enc/av1/packet/encode_av1_vdenc_packet.cpp b/media_softlet/agnostic/common/codec/hal/enc/av1/packet/encode_av1_vdenc_packet.cpp index cec4a51e35c..d1de6479ec3 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/av1/packet/encode_av1_vdenc_packet.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/av1/packet/encode_av1_vdenc_packet.cpp @@ -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( @@ -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(); @@ -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) @@ -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; } diff --git a/media_softlet/agnostic/common/codec/hal/enc/av1/packet/encode_av1_vdenc_packet.h b/media_softlet/agnostic/common/codec/hal/enc/av1/packet/encode_av1_vdenc_packet.h index 785d88d4873..078ac180078 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/av1/packet/encode_av1_vdenc_packet.h +++ b/media_softlet/agnostic/common/codec/hal/enc/av1/packet/encode_av1_vdenc_packet.h @@ -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(); diff --git a/media_softlet/agnostic/common/codec/hal/enc/av1/pipeline/encode_av1_reference_frames.cpp b/media_softlet/agnostic/common/codec/hal/enc/av1/pipeline/encode_av1_reference_frames.cpp index a23727ceb3f..6e08d36ce4b 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/av1/pipeline/encode_av1_reference_frames.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/av1/pipeline/encode_av1_reference_frames.cpp @@ -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 { @@ -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; diff --git a/media_softlet/agnostic/common/codec/hal/enc/av1/pipeline/encode_av1_reference_frames.h b/media_softlet/agnostic/common/codec/hal/enc/av1/pipeline/encode_av1_reference_frames.h index 5fab2ca0af9..c9595f287a2 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/av1/pipeline/encode_av1_reference_frames.h +++ b/media_softlet/agnostic/common/codec/hal/enc/av1/pipeline/encode_av1_reference_frames.h @@ -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 { @@ -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); diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.cpp b/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.cpp index fd1062cb623..02e6380653d 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.cpp @@ -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; @@ -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, @@ -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; } diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.h b/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.h index 4425fa5e074..a8d98284c9d 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.h +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.h @@ -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, //! diff --git a/media_softlet/agnostic/common/shared/media_debug_interface.h b/media_softlet/agnostic/common/shared/media_debug_interface.h index fd277ab1053..77e5918f5c7 100644 --- a/media_softlet/agnostic/common/shared/media_debug_interface.h +++ b/media_softlet/agnostic/common/shared/media_debug_interface.h @@ -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;