Skip to content

Commit

Permalink
Fix timestamp precision loss in onevpl
Browse files Browse the repository at this point in the history
In widevine L3 stream play test, the timestamps between Load and Decode
have gaps.

Tracked-On: OAM-124689
Signed-off-by: Nana Zhang <[email protected]>
  • Loading branch information
nanazhan committed Oct 24, 2024
1 parent cebb891 commit 1a0e31e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 5 additions & 2 deletions c2_components/src/mfx_c2_decoder_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2550,7 +2550,7 @@ void MfxC2DecoderComponent::WaitWork(MfxC2FrameOut&& frame_out, mfxSyncPoint syn
}
}

decltype(C2WorkOrdinalStruct::timestamp) ready_timestamp{mfx_surface->Data.TimeStamp};
uint64_t ready_timestamp = mfx_surface->Data.TimeStamp;

std::unique_ptr<C2Work> work;
std::unique_ptr<C2ReadView> read_view;
Expand All @@ -2559,7 +2559,10 @@ void MfxC2DecoderComponent::WaitWork(MfxC2FrameOut&& frame_out, mfxSyncPoint syn
std::lock_guard<std::mutex> lock(m_pendingWorksMutex);

auto it = find_if(m_pendingWorks.begin(), m_pendingWorks.end(), [ready_timestamp] (const auto &item) {
return item.second->input.ordinal.timestamp == ready_timestamp;
// In some cases, operations in oneVPL may result in timestamp gaps.
// To ensure that we correctly identify the work, we replicate the same operations as performed in oneVPL.
return item.second->input.ordinal.timestamp.peeku() == ready_timestamp ||
GetMfxTimeStamp(GetUmcTimeStamp(item.second->input.ordinal.timestamp.peeku())) == ready_timestamp;
});

if (it != m_pendingWorks.end()) {
Expand Down
14 changes: 13 additions & 1 deletion c2_utils/include/mfx_c2_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,21 @@

c2_status_t MfxStatusToC2(mfxStatus mfx_status);

static const mfxU32 MFX_TIME_STAMP_FREQUENCY = 90000;

inline mfxF64 GetUmcTimeStamp(mfxU64 ts)
{
return ts / (mfxF64)MFX_TIME_STAMP_FREQUENCY;
}

inline mfxU64 GetMfxTimeStamp(mfxF64 ts)
{
return (mfxU64)(ts * MFX_TIME_STAMP_FREQUENCY + .5);
}

inline mfxU64 TimestampC2ToMfx(uint64_t timestamp)
{
return timestamp * 90000 / MFX_SECOND_NS;
return timestamp * MFX_TIME_STAMP_FREQUENCY / MFX_SECOND_NS;
}

c2_status_t GetC2ConstGraphicBlock(
Expand Down

0 comments on commit 1a0e31e

Please sign in to comment.