Skip to content

Commit

Permalink
[vpp] code refine
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroYY authored and gfxVPLsdm committed Nov 7, 2024
1 parent ab48dd4 commit f78c008
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
10 changes: 5 additions & 5 deletions _studio/mfx_lib/vpp/include/mfx_vpp_ai_frame_interpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,27 @@ class MFXVideoFrameInterpolation
class tsQueue
{
public:
// first taskIndex
// second timestamp

void Enqueue(Task t)
{
std::lock_guard<std::mutex> lock(m_mutex);
m_queue.push(t);
m_cv.notify_one();
}
void Dequeue(Task& t)
{
while (m_queue.empty()) {}
std::lock_guard<std::mutex> lock(m_mutex);
std::unique_lock<std::mutex> lock(m_mutex);
m_cv.wait(lock, [this] { return !m_queue.empty(); });
t = m_queue.front();
m_queue.pop();
}
private:
std::queue<Task> m_queue;
std::mutex m_mutex;
std::condition_variable m_cv;
} ;
tsQueue m_taskQueue;
mfxU32 m_taskIndex;
std::mutex m_mutex;

// 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
Expand Down
32 changes: 14 additions & 18 deletions _studio/mfx_lib/vpp/src/mfx_vpp_ai_frame_interpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ mfxStatus MFXVideoFrameInterpolation::UpdateTsAndGetStatus(
output->Data.TimeStamp = m_time_stamp_start + m_outStamp * m_time_stamp_interval;

AddTaskQueue(m_sequenceEnd);

MFX_RETURN(sts);
}

Expand Down Expand Up @@ -612,32 +612,28 @@ mfxStatus MFXVideoFrameInterpolation::ReturnSurface(mfxFrameSurface1* out, mfxMe
if (m_IOPattern & MFX_IOPATTERN_OUT_SYSTEM_MEMORY)
{
sts = m_core->DoFastCopyWrapper(out, MFX_MEMTYPE_SYSTEM_MEMORY, &m_rgbSurfArray[m_ratio], MFX_MEMTYPE_DXVA2_DECODER_TARGET);
MFX_CHECK_STS(sts);
}
else
{
if (!internalVidMemId)
MFX_CHECK(!internalVidMemId, MFX_ERR_UNDEFINED_BEHAVIOR);
if (m_vppForFi)
{
if (m_vppForFi)
{
MFX_CHECK_STS(m_vppAfterFi->Submit(&m_rgbSurfArray[m_ratio], &m_fiOut));
MFX_CHECK_STS(m_core->DoFastCopyWrapper(
out, MFX_MEMTYPE_DXVA2_DECODER_TARGET,
&m_fiOut, MFX_MEMTYPE_INTERNAL_FRAME | MFX_MEMTYPE_DXVA2_DECODER_TARGET));
}
else
{
MFX_CHECK_STS(m_core->DoFastCopyWrapper(
out, MFX_MEMTYPE_DXVA2_DECODER_TARGET,
&m_rgbSurfArray[m_ratio], MFX_MEMTYPE_INTERNAL_FRAME | MFX_MEMTYPE_DXVA2_DECODER_TARGET));
}
sts = m_vppAfterFi->Submit(&m_rgbSurfArray[m_ratio], &m_fiOut);
MFX_CHECK_STS(sts);
sts = m_core->DoFastCopyWrapper(
out, MFX_MEMTYPE_DXVA2_DECODER_TARGET,
&m_fiOut, MFX_MEMTYPE_INTERNAL_FRAME | MFX_MEMTYPE_DXVA2_DECODER_TARGET);
MFX_CHECK_STS(sts);
}
else
{
MFX_RETURN(MFX_ERR_UNDEFINED_BEHAVIOR);
sts = m_core->DoFastCopyWrapper(
out, MFX_MEMTYPE_DXVA2_DECODER_TARGET,
&m_rgbSurfArray[m_ratio], MFX_MEMTYPE_INTERNAL_FRAME | MFX_MEMTYPE_DXVA2_DECODER_TARGET);
MFX_CHECK_STS(sts);
}
}
MFX_CHECK_STS(sts);

}

MFX_RETURN(sts);
Expand Down

0 comments on commit f78c008

Please sign in to comment.