From c949b2f5afbf743c1fb49dd99c2e390140a30b93 Mon Sep 17 00:00:00 2001 From: Crend King <975235+CrendKing@users.noreply.github.com> Date: Thu, 24 Jun 2021 16:29:22 -0700 Subject: [PATCH] Use our own output frame start time, fix issue 56 Bump version --- filter_common/src/version.h | 2 +- vapoursynth_filter/src/frame_handler.cpp | 10 +++++++++- vapoursynth_filter/src/frame_handler.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/filter_common/src/version.h b/filter_common/src/version.h index fff85d1..3a36597 100644 --- a/filter_common/src/version.h +++ b/filter_common/src/version.h @@ -29,7 +29,7 @@ namespace SynthFilter { #define FILTER_NAME_WIDE WIDEN(FILTER_NAME_BASE) #define FILTER_VERSION_MAJOR 1 #define FILTER_VERSION_MINOR 1 -#define FILTER_VERSION_PATCH 2 +#define FILTER_VERSION_PATCH 3 #define FILTER_VERSION_STRING STRINGIZE(FILTER_VERSION_MAJOR) "." STRINGIZE(FILTER_VERSION_MINOR) "." STRINGIZE(FILTER_VERSION_PATCH) FILTER_VARIANT " # " FILTER_GIT_HASH } diff --git a/vapoursynth_filter/src/frame_handler.cpp b/vapoursynth_filter/src/frame_handler.cpp index d5acf1a..b29dae3 100644 --- a/vapoursynth_filter/src/frame_handler.cpp +++ b/vapoursynth_filter/src/frame_handler.cpp @@ -294,8 +294,15 @@ auto FrameHandler::PrepareOutputSample(ATL::CComPtr &sample, int f frameDuration = MainFrameServer::GetInstance().GetScriptAvgFrameDuration(); } - REFERENCE_TIME frameStartTime = static_cast(AVSF_VS_API->propGetFloat(frameProps, VS_PROP_NAME_ABS_TIME, 0, &propGetError) * UNITS); + if (_nextOutputFrameStartTime == 0) { + _nextOutputFrameStartTime = static_cast(AVSF_VS_API->propGetFloat(frameProps, VS_PROP_NAME_ABS_TIME, 0, &propGetError) * UNITS); + } + + REFERENCE_TIME frameStartTime = _nextOutputFrameStartTime; REFERENCE_TIME frameStopTime = frameStartTime + frameDuration; + _nextOutputFrameStartTime = frameStopTime; + + Environment::GetInstance().Log(L"Output frame: frameNb %6i startTime %10lli stopTime %10lli duration %10lli", frameNb, frameStartTime, frameStopTime, frameDuration); if (FAILED(_filter.m_pOutput->GetDeliveryBuffer(&sample, &frameStartTime, &frameStopTime, 0))) { // avoid releasing the invalid pointer in case the function change it to some random invalid address @@ -347,6 +354,7 @@ auto FrameHandler::PrepareOutputSample(ATL::CComPtr &sample, int f auto FrameHandler::WorkerProc() -> void { const auto ResetOutput = [this]() -> void { + _nextOutputFrameStartTime = 0; _nextDeliveryFrameNb = 0; _frameRateCheckpointOutputFrameNb = 0; diff --git a/vapoursynth_filter/src/frame_handler.h b/vapoursynth_filter/src/frame_handler.h index 14501cf..1880248 100644 --- a/vapoursynth_filter/src/frame_handler.h +++ b/vapoursynth_filter/src/frame_handler.h @@ -81,6 +81,7 @@ class FrameHandler { int _nextSourceFrameNb; int _nextProcessSourceFrameNb; int _nextOutputFrameNb; + REFERENCE_TIME _nextOutputFrameStartTime; std::atomic _lastUsedSourceFrameNb; bool _notifyChangedOutputMediaType = false; int _nextDeliveryFrameNb;