Skip to content

Commit

Permalink
Use our own output frame start time, fix issue 56
Browse files Browse the repository at this point in the history
Bump version
  • Loading branch information
CrendKing committed Jun 25, 2021
1 parent 2b8c7ce commit c949b2f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion filter_common/src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
10 changes: 9 additions & 1 deletion vapoursynth_filter/src/frame_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,15 @@ auto FrameHandler::PrepareOutputSample(ATL::CComPtr<IMediaSample> &sample, int f
frameDuration = MainFrameServer::GetInstance().GetScriptAvgFrameDuration();
}

REFERENCE_TIME frameStartTime = static_cast<REFERENCE_TIME>(AVSF_VS_API->propGetFloat(frameProps, VS_PROP_NAME_ABS_TIME, 0, &propGetError) * UNITS);
if (_nextOutputFrameStartTime == 0) {
_nextOutputFrameStartTime = static_cast<REFERENCE_TIME>(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
Expand Down Expand Up @@ -347,6 +354,7 @@ auto FrameHandler::PrepareOutputSample(ATL::CComPtr<IMediaSample> &sample, int f

auto FrameHandler::WorkerProc() -> void {
const auto ResetOutput = [this]() -> void {
_nextOutputFrameStartTime = 0;
_nextDeliveryFrameNb = 0;

_frameRateCheckpointOutputFrameNb = 0;
Expand Down
1 change: 1 addition & 0 deletions vapoursynth_filter/src/frame_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class FrameHandler {
int _nextSourceFrameNb;
int _nextProcessSourceFrameNb;
int _nextOutputFrameNb;
REFERENCE_TIME _nextOutputFrameStartTime;
std::atomic<int> _lastUsedSourceFrameNb;
bool _notifyChangedOutputMediaType = false;
int _nextDeliveryFrameNb;
Expand Down

0 comments on commit c949b2f

Please sign in to comment.