Skip to content

Commit

Permalink
[Decode] ETW for Decode RT API (#2928)
Browse files Browse the repository at this point in the history
Adding Event Trace Log for Decode

Co-authored-by: chuanli1 <[email protected]>
  • Loading branch information
gfxVPLsdm and chuanli1 authored Jun 9, 2022
1 parent 5f49795 commit e0d2754
Show file tree
Hide file tree
Showing 25 changed files with 1,695 additions and 15 deletions.
23 changes: 23 additions & 0 deletions _studio/mfx_lib/decode/av1/src/mfx_av1_dec_decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
#include "libmfx_core_interface.h"


#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
#include "mfx_unified_av1d_logging.h"
#endif

namespace MFX_VPX_Utility
{
inline
Expand Down Expand Up @@ -824,6 +828,16 @@ mfxStatus VideoDECODEAV1::DecodeFrame(mfxFrameSurface1 *surface_out, AV1DecoderF
UMC::FrameMemID id = frame->GetFrameData()->GetFrameMID();
mfxStatus sts = m_surface_source->PrepareToOutput(surface_out, id, &m_video_par);
frame->Displayed(true);
#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
if (EtwLogConfig == ETW_INFO || EtwLogConfig == ETW_API_INFO || EtwLogConfig == ETW_INFO_BUFFER || EtwLogConfig == ETW_ALL)
{
DECODE_EVENTDATA_OUTPUTFRAME_AV1 eventData;
eventData.MemID = id;
eventData.wasDisplayed = frame->Displayed();
eventData.wasOutputted = frame->Outputted();
TRACE_EVENT(MFX_TRACE_API_AV1_DISPLAYINFO_TASK, 0, make_event_data(eventData), [&]() { return make_event_data(UMC::UMC_OK); });
}
#endif
return sts;
}

Expand Down Expand Up @@ -1305,6 +1319,15 @@ mfxStatus VideoDECODEAV1::FillOutputSurface(mfxFrameSurface1** surf_out, mfxFram
surface_out->Info.FrameRateExtD = isShouldUpdate ? m_init_par.mfx.FrameInfo.FrameRateExtD : m_first_par.mfx.FrameInfo.FrameRateExtD;
surface_out->Info.FrameRateExtN = isShouldUpdate ? m_init_par.mfx.FrameInfo.FrameRateExtN : m_first_par.mfx.FrameInfo.FrameRateExtN;

#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
if (EtwLogConfig == ETW_INFO || EtwLogConfig == ETW_API_INFO || EtwLogConfig == ETW_INFO_BUFFER || EtwLogConfig == ETW_ALL)
{
DECODE_EVENTDATA_SURFACEOUT_AV1 eventData;
DecodeEventDataAV1SurfaceOutparam(&eventData, surface_out);
TRACE_EVENT(MFX_TRACE_API_AV1_OUTPUTINFO_TASK, 0, make_event_data(eventData), [&]() { return make_event_data(UMC::UMC_OK); });
}
#endif

return MFX_ERR_NONE;
}

Expand Down
25 changes: 25 additions & 0 deletions _studio/mfx_lib/decode/h264/src/mfx_h264_dec_decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@

#include "mfx_utils.h"

#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
#include "mfx_unified_h264d_logging.h"
#endif

inline bool IsNeedToUseHWBuffering(eMFXHWType /*type*/)
{
return false;
Expand Down Expand Up @@ -1560,6 +1564,15 @@ void VideoDECODEH264::FillOutputSurface(mfxFrameSurface1 **surf_out, mfxFrameSur

surface_out->Data.DataFlag = (mfxU16)(pFrame->m_isOriginalPTS ? MFX_FRAMEDATA_ORIGINAL_TIMESTAMP : 0);

#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
if (EtwLogConfig == ETW_INFO || EtwLogConfig == ETW_API_INFO || EtwLogConfig == ETW_INFO_BUFFER || EtwLogConfig == ETW_ALL)
{
DECODE_EVENTDATA_SURFACEOUT_AVC eventData;
DecodeEventDataAVCSurfaceOutparam(&eventData, surface_out, pFrame);
TRACE_EVENT(MFX_TRACE_API_AVC_OUTPUTINFO_TASK, 0, make_event_data(eventData), [&]() { return make_event_data(UMC::UMC_OK); });
}
#endif

UMC::SEI_Storer * storer = m_pH264VideoDecoder->GetSEIStorer();
if (storer)
storer->SetTimestamp(pFrame);
Expand Down Expand Up @@ -1616,6 +1629,18 @@ mfxStatus VideoDECODEH264::DecodeFrame(mfxFrameSurface1 *surface_out, UMC::H264D

UMC::AutomaticUMCMutex guard(m_mGuard);
pFrame->setWasDisplayed();
#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
if (EtwLogConfig == ETW_INFO || EtwLogConfig == ETW_API_INFO || EtwLogConfig == ETW_INFO_BUFFER || EtwLogConfig == ETW_ALL)
{
DECODE_EVENTDATA_OUTPUTFRAME_h264 eventData;
eventData.PicOrderCnt[0] = pFrame->m_PicOrderCnt[0];
eventData.PicOrderCnt[1] = pFrame->m_PicOrderCnt[1];
eventData.frameNum = pFrame->FrameNum();
eventData.wasDisplayed = pFrame->wasDisplayed();
eventData.wasOutputted = pFrame->wasOutputted();
TRACE_EVENT(MFX_TRACE_API_AVC_DISPLAYINFO_TASK, 0, make_event_data(eventData), [&]() { return make_event_data(UMC::UMC_OK); });
}
#endif
return sts;
}

Expand Down
24 changes: 22 additions & 2 deletions _studio/mfx_lib/decode/h265/src/mfx_h265_dec_decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@

using namespace UMC_HEVC_DECODER;

#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
#include "mfx_unified_h265d_logging.h"
#endif

inline
bool IsNeedToUseHWBuffering(eMFXHWType /*type*/)
{
Expand Down Expand Up @@ -1266,7 +1270,14 @@ void VideoDECODEH265::FillOutputSurface(mfxFrameSurface1 **surf_out, mfxFrameSur
surface_out->Data.FrameOrder = (mfxU32)MFX_FRAMEORDER_UNKNOWN;

surface_out->Data.DataFlag = (mfxU16)(pFrame->m_isOriginalPTS ? MFX_FRAMEDATA_ORIGINAL_TIMESTAMP : 0);

#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
if (EtwLogConfig == ETW_INFO || EtwLogConfig == ETW_API_INFO || EtwLogConfig == ETW_INFO_BUFFER || EtwLogConfig == ETW_ALL)
{
DECODE_EVENTDATA_SURFACEOUT_HEVC eventData;
DecodeEventDataHEVCSurfaceOutparam(&eventData, surface_out, pFrame);
TRACE_EVENT(MFX_TRACE_API_HEVC_OUTPUTINFO_TASK, 0, make_event_data(eventData), [&]() { return make_event_data(UMC::UMC_OK); });
}
#endif
SEI_Storer_H265 * storer = m_pH265VideoDecoder->GetSEIStorer();
if (storer)
storer->SetTimestamp(pFrame);
Expand Down Expand Up @@ -1376,7 +1387,16 @@ mfxStatus VideoDECODEH265::DecodeFrame(mfxFrameSurface1 *surface_out, H265Decode
mfxStatus sts = m_surface_source->PrepareToOutput(surface_out, index, &m_vPar);

pFrame->setWasDisplayed();

#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
if (EtwLogConfig == ETW_INFO || EtwLogConfig == ETW_API_INFO || EtwLogConfig == ETW_INFO_BUFFER || EtwLogConfig == ETW_ALL)
{
DECODE_EVENTDATA_outputFrame_h265 eventData;
eventData.PicOrderCnt = pFrame->m_PicOrderCnt;
eventData.wasDisplayed = pFrame->wasDisplayed();
eventData.wasOutputted = pFrame->wasOutputted();
TRACE_EVENT(MFX_TRACE_API_HEVC_DISPLAYINFO_TASK, 0, make_event_data(eventData), [&]() { return make_event_data(UMC::UMC_OK); });
}
#endif
return sts;
}

Expand Down
44 changes: 43 additions & 1 deletion _studio/mfx_lib/decode/vp9/src/mfx_vp9_dec_decode_hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
#include "libmfx_core_interface.h"
using namespace UMC_VP9_DECODER;

#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
#include "mfx_unified_vp9d_logging.h"
#endif

static bool IsSameVideoParam(mfxVideoParam *newPar, mfxVideoParam *oldPar);

// function checks hardware support with IsGuidSupported function and GUIDs
Expand Down Expand Up @@ -246,6 +250,17 @@ class FrameStorage
VP9_CHECK_AND_THROW((find_it == m_submittedFrames.end()), MFX_ERR_UNKNOWN);

m_submittedFrames.push_back(frame);
#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
if (EtwLogConfig == ETW_BUFFER || EtwLogConfig == ETW_API_BUFFER || EtwLogConfig == ETW_INFO_BUFFER || EtwLogConfig == ETW_ALL)
{
DECODE_EVENTDATA_DPBINFO_VP9 eventDpbData;
if (!m_submittedFrames.empty())
{
DecodeEventVP9DpbInfo(&eventDpbData, m_submittedFrames);
TRACE_EVENT(MFX_TRACE_API_VP9_DPBPARAMETER_TASK, 0, make_event_data(eventDpbData), [&]() { return make_event_data(UMC::UMC_OK); });
}
}
#endif
}

void DecodeFrame(UMC::FrameMemID frameId)
Expand All @@ -257,6 +272,15 @@ class FrameStorage
{
find_it->isDecoded = true;
}
#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
if (EtwLogConfig == ETW_INFO || EtwLogConfig == ETW_API_INFO || EtwLogConfig == ETW_INFO_BUFFER || EtwLogConfig == ETW_ALL)
{
DECODE_EVENTDATA_OUTPUTFRAME_VP9 eventData;
eventData.MemID = find_it->currFrame;
eventData.wasDisplayed = find_it->isDecoded;
TRACE_EVENT(MFX_TRACE_API_VP9_DISPLAYINFO_TASK, 0, make_event_data(eventData), [&]() { return make_event_data(UMC::UMC_OK); });
}
#endif
}

void CompleteFrames()
Expand Down Expand Up @@ -858,7 +882,17 @@ mfxStatus MFX_CDECL VP9DECODERoutine(void *p_state, void * /* pp_param */, mfxU3
{
VideoDECODEVP9_HW::VP9DECODERoutineData& data = *(VideoDECODEVP9_HW::VP9DECODERoutineData*)p_state;
VideoDECODEVP9_HW& decoder = *data.decoder;

#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
if (EtwLogConfig == ETW_INFO || EtwLogConfig == ETW_API_INFO || EtwLogConfig == ETW_INFO_BUFFER || EtwLogConfig == ETW_ALL)
{
DECODE_EVENTDATA_SYNC_VP9 eventData;
eventData.copyFromFrame = data.copyFromFrame;
eventData.currFrameId = data.currFrameId;
eventData.index = data.index;
eventData.showFrame = data.showFrame;
TRACE_EVENT(MFX_TRACE_API_VP9_SYNCINFO_TASK, 0, make_event_data(eventData), [&]() { return make_event_data(UMC::UMC_OK); });
}
#endif
if (data.copyFromFrame != UMC::FRAME_MID_INVALID)
{
MFX_CHECK(data.surface_work, MFX_ERR_UNDEFINED_BEHAVIOR);
Expand Down Expand Up @@ -1233,6 +1267,14 @@ mfxStatus VideoDECODEVP9_HW::DecodeFrameCheck(mfxBitstream *bs, mfxFrameSurface1

m_frameOrder++;
sts = MFX_ERR_NONE;
#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
if (EtwLogConfig == ETW_INFO || EtwLogConfig == ETW_API_INFO || EtwLogConfig == ETW_INFO_BUFFER || EtwLogConfig == ETW_ALL)
{
DECODE_EVENTDATA_SURFACEOUT_VP9 eventData;
DecodeEventVP9DataSurfaceOutparam(&eventData, surface_out);
TRACE_EVENT(MFX_TRACE_API_VP9_OUTPUTINFO_TASK, 0, make_event_data(eventData), [&]() { return make_event_data(sts); });
}
#endif
}
else
{
Expand Down
9 changes: 8 additions & 1 deletion _studio/mfx_lib/shared/src/libmfxsw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include "libmfx_core_interface.h"
#include "mfx_platform_caps.h"

#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
#include "mfx_unified_decode_logging.h"
#endif

mfxStatus MFXInit(mfxIMPL implParam, mfxVersion *ver, mfxSession *session)
{
mfxInitParam par = {};
Expand Down Expand Up @@ -249,7 +253,6 @@ mfxStatus MFXClose(mfxSession session)
// since it inserts class variable on stack which calls to trace library in the
// destructor.
MFX_AUTO_LTRACE(MFX_TRACE_LEVEL_API, "MFXClose");
PERF_EVENT(MFX_TRACE_API_MFX_CLOSE_TASK, 0, make_event_data(session), [&](){ return make_event_data(mfxRes);});

// parent session can't be closed,
// because there is no way to let children know about parent's death.
Expand All @@ -258,6 +261,10 @@ mfxStatus MFXClose(mfxSession session)
if (session->IsChildSession())
{
mfxRes = MFXDisjoinSession(session);
#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
if (EtwLogConfig == ETW_API || EtwLogConfig == ETW_API_BUFFER || EtwLogConfig == ETW_API_INFO || EtwLogConfig == ETW_ALL)
TRACE_EVENT(MFX_TRACE_API_MFX_CLOSE_TASK, 0, make_event_data(session), [&]() { return make_event_data(mfxRes); });
#endif
if (MFX_ERR_NONE != mfxRes)
{
return mfxRes;
Expand Down
9 changes: 8 additions & 1 deletion _studio/mfx_lib/shared/src/libmfxsw_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
#include "libmfx_core_interface.h"


#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
#include "mfx_unified_decode_logging.h"
#endif

mfxStatus MFXVideoCORE_SyncOperation(mfxSession session, mfxSyncPoint syncp, mfxU32 wait)
{
mfxStatus mfxRes = MFX_ERR_NONE;

MFX_AUTO_LTRACE(MFX_TRACE_LEVEL_API, "MFXVideoCORE_SyncOperation");
PERF_EVENT(MFX_TRACE_API_SYNC_OPERATION_TASK, 0, make_event_data(session, syncp, wait), [&](){ return make_event_data(mfxRes, syncp);});
MFX_CHECK(session, MFX_ERR_INVALID_HANDLE);
MFX_CHECK(syncp, MFX_ERR_NULL_PTR);

Expand All @@ -41,6 +44,10 @@ mfxStatus MFXVideoCORE_SyncOperation(mfxSession session, mfxSyncPoint syncp, mfx
// call the function
mfxRes = session->m_pScheduler->Synchronize(syncp, wait);
}
#ifdef MFX_EVENT_TRACE_DUMP_SUPPORTED
if (EtwLogConfig == ETW_API || EtwLogConfig == ETW_API_BUFFER || EtwLogConfig == ETW_API_INFO || EtwLogConfig == ETW_ALL)
TRACE_EVENT(MFX_TRACE_API_SYNC_OPERATION_TASK, 0, make_event_data(session, syncp, wait), [&]() { return make_event_data(mfxRes, syncp); });
#endif
} catch(...) {
// set the default error value
mfxRes = MFX_ERR_ABORTED;
Expand Down
Loading

0 comments on commit e0d2754

Please sign in to comment.