Skip to content

Commit

Permalink
[VP] Added time stamp for AI VFI
Browse files Browse the repository at this point in the history
  • Loading branch information
FurongZhang authored and gfxVPLsdm committed Nov 4, 2024
1 parent ad8c18f commit 41a0168
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
7 changes: 7 additions & 0 deletions _studio/mfx_lib/vpp/include/mfx_vpp_ai_frame_interpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ class MFXVideoFrameInterpolation
// second timestamp
using task = std::pair<mfxU32, mfxU16>;
std::queue<task> m_taskQueue;

// To calculate the time stamp in mfxFrameData
// The starting time of input frame n for frame [n, n+1] interpolation in units of 90KHz. Divide TimeStamp by 90,000 (90 KHz) to obtain the time in seconds
// The value of MFX_TIMESTAMP_UNKNOWN indicates that there is no time stamp
mfxU64 m_time_stamp_start;
// The time interval of two interpolated frames [n, n+1] in units of 90KHz. Divide TimeStamp by 90,000 (90 KHz) to obtain the time in seconds
mfxU64 m_time_stamp_interval;
};

#endif
56 changes: 39 additions & 17 deletions _studio/mfx_lib/vpp/src/mfx_vpp_ai_frame_interpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ MFXVideoFrameInterpolation::MFXVideoFrameInterpolation() :
m_rgbSurfForFiIn(),
m_rgbSurfArray(),
m_outSurfForFi(),
m_fiOut()
m_fiOut(),
m_time_stamp_start(0),
m_time_stamp_interval(0)
{
}

Expand Down Expand Up @@ -107,6 +109,16 @@ mfxStatus MFXVideoFrameInterpolation::ConfigureFrameRate(
m_outStamp = 0;
m_outTick = (mfxU16)m_ratio;

m_time_stamp_start = (mfxU64)MFX_TIMESTAMP_UNKNOWN;
// Default to 30fps
m_time_stamp_interval = (mfxU64)((mfxF64) MFX_TIME_STAMP_FREQUENCY / (mfxF64)30);

if (m_frcRational[VPP_OUT].FrameRateExtN != 0)
{
// Specify the frame rate: FrameRateExtN / FrameRateExtD.
m_time_stamp_interval = (mfxU64)(MFX_TIME_STAMP_FREQUENCY * (((mfxF64)m_frcRational[VPP_OUT].FrameRateExtD / (mfxF64)m_frcRational[VPP_OUT].FrameRateExtN)));
}

return MFX_ERR_NONE;
}

Expand Down Expand Up @@ -369,33 +381,43 @@ mfxStatus MFXVideoFrameInterpolation::UpdateTsAndGetStatus(
mfxFrameSurface1* output,
mfxStatus* intSts)
{
mfxStatus sts = MFX_ERR_NONE;

if (nullptr == input)
{
// nullptr == input means input sequence reaches its end
if (m_sequenceEnd)
{
return MFX_ERR_MORE_DATA;
}
if (m_outStamp == (m_ratio - 1)) m_sequenceEnd = true;
return MFX_ERR_NONE;
}
mfxStatus sts = MFX_ERR_NONE;

if (m_outStamp == 0)
{
m_inputBkwd.Info = output->Info;
}
else if (m_outStamp == 1)
{
m_inputFwd.Info = output->Info;

*intSts = MFX_ERR_MORE_SURFACE;
else
{
if (m_outStamp == (m_ratio - 1)) m_sequenceEnd = true;
sts = MFX_ERR_NONE;
}
}
else
{
*intSts = MFX_ERR_MORE_SURFACE;
}
if (m_outStamp == 0)
{
// record the time stamp of input frame [n, n+1]
m_time_stamp_start = input->Data.TimeStamp;
m_inputBkwd.Info = output->Info;
}
else if (m_outStamp == 1)
{
m_inputFwd.Info = output->Info;

*intSts = MFX_ERR_MORE_SURFACE;
}
else
{
*intSts = MFX_ERR_MORE_SURFACE;
}
}

output->Data.TimeStamp = m_time_stamp_start + m_outStamp * m_time_stamp_interval;

MFX_RETURN(sts);
}

Expand Down

0 comments on commit 41a0168

Please sign in to comment.