Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Commit

Permalink
Reorder the time stamp when the input frame is in encoded order.
Browse files Browse the repository at this point in the history
(cherry picked from commit dca3b5a)
  • Loading branch information
hongbolv authored and Oleg Nabiullin committed Jan 28, 2019
1 parent 14467db commit 7d35bc5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,8 @@ namespace MfxHwH264Encode
DdiTask & newTask);
void AssignDecodeTimeStamp(
DdiTask & task);

void PreserveTimeStamp(
mfxU64 timeStamp);
mfxStatus UpdateBitstream(
DdiTask & task,
mfxU32 fid); // 0 - top/progressive, 1 - bottom
Expand Down
24 changes: 23 additions & 1 deletion _studio/mfx_lib/encode_hw/h264/src/mfx_h264_encode_hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2198,6 +2198,26 @@ mfxU32 GetMaxFrameSize(DdiTask const & task, MfxVideoParam const &video, Hrd con
std::min(maxFrameSize_hrd,maxFrameSize):
std::max(maxFrameSize_hrd,maxFrameSize);
}

void ImplementationAvc::PreserveTimeStamp(mfxU64 timeStamp)
{
// insert the unknown time stamp in the list end.
if (timeStamp == static_cast<mfxU64>(MFX_TIMESTAMP_UNKNOWN))
{
m_timeStamps.push_back(timeStamp);
return;
}
// insert the valid time stamp in the increasing order.
auto it = std::find_if(std::begin(m_timeStamps), std::end(m_timeStamps),
[timeStamp](mfxU64 currTimeStamp)
{
return (currTimeStamp != static_cast<mfxU64>(MFX_TIMESTAMP_UNKNOWN))
&& (static_cast<mfxI64>(currTimeStamp) > static_cast<mfxI64>(timeStamp));
});

m_timeStamps.insert(it, timeStamp);
}

void ImplementationAvc::AssignDecodeTimeStamp(DdiTask & task)
{
mfxU8 numReorderFrames = GetNumReorderFrames(m_video);
Expand Down Expand Up @@ -2254,7 +2274,6 @@ mfxStatus ImplementationAvc::AsyncRoutine(mfxBitstream * bs)
{
MFX_AUTO_LTRACE(MFX_TRACE_LEVEL_HOTSPOTS, "Avc::STG_BIT_ACCEPT_FRAME");
DdiTask & newTask = m_incoming.front();
m_timeStamps.push_back(newTask.m_timeStamp);

if (m_video.mfx.RateControlMethod == MFX_RATECONTROL_LA_EXT)
{
Expand Down Expand Up @@ -2291,6 +2310,7 @@ mfxStatus ImplementationAvc::AsyncRoutine(mfxBitstream * bs)
AssignFrameTypes(newTask);
}

m_timeStamps.push_back(newTask.m_timeStamp);
m_frameOrder++;
}
else
Expand All @@ -2302,6 +2322,8 @@ mfxStatus ImplementationAvc::AsyncRoutine(mfxBitstream * bs)

if (newTask.m_picStruct[ENC] == MFX_PICSTRUCT_FIELD_BFF)
std::swap(newTask.m_type.top, newTask.m_type.bot);

PreserveTimeStamp(newTask.m_timeStamp);
}

// move task to reordering queue
Expand Down

0 comments on commit 7d35bc5

Please sign in to comment.