Commit 7d35bc51 authored by hongbolv's avatar hongbolv Committed by Oleg Nabiullin

Reorder the time stamp when the input frame is in encoded order.

(cherry picked from commit dca3b5ae)
parent 14467db1
......@@ -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
......
......@@ -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);
......@@ -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)
{
......@@ -2291,6 +2310,7 @@ mfxStatus ImplementationAvc::AsyncRoutine(mfxBitstream * bs)
AssignFrameTypes(newTask);
}
m_timeStamps.push_back(newTask.m_timeStamp);
m_frameOrder++;
}
else
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment