Skip to content

Commit

Permalink
Fix bug that skips the first source frame when creating output frames
Browse files Browse the repository at this point in the history
  • Loading branch information
CrendKing committed Dec 22, 2020
1 parent 7c5852a commit c451fe3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions avisynth_filter/src/frame_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ auto FrameHandler::AddInputSample(IMediaSample *inSample) -> HRESULT {
return VFW_E_SAMPLE_REJECTED;
}

if (_nextOutputFrameStartTime == 0) {
if (_nextOutputFrameStartTime == -1) {
_nextOutputFrameStartTime = srcFrameInfo.startTime;
}
if (_frameRateCheckpointInputSampleStartTime == -1) {
_frameRateCheckpointInputSampleStartTime = srcFrameInfo.startTime;
}
if (_frameRateCheckpointOutputFrameStartTime == -1) {
_frameRateCheckpointOutputFrameStartTime = srcFrameInfo.startTime;
}

RefreshInputFrameRates(srcFrameInfo);

Expand Down Expand Up @@ -294,12 +300,12 @@ auto FrameHandler::Reset() -> void {
_nextSourceFrameNb = 0;
_nextOutputFrameNb = 0;
_nextDeliverFrameNb = 0;
_nextOutputFrameStartTime = 0;
_nextOutputFrameStartTime = -1;

_frameRateCheckpointInputSampleNb = 0;
_frameRateCheckpointInputSampleStartTime = 0;
_frameRateCheckpointInputSampleStartTime = -1;
_frameRateCheckpointOutputFrameNb = 0;
_frameRateCheckpointOutputFrameStartTime = 0;
_frameRateCheckpointOutputFrameStartTime = -1;
_currentInputFrameRate = 0;
_currentOutputFrameRate = 0;
}
Expand Down Expand Up @@ -414,6 +420,8 @@ auto FrameHandler::GarbageCollect(int srcFrameNb) -> void {

const size_t dbgPreSize = _sourceFrames.size();

// search for all previous zero-ref frames in case of some source frames are never used
// this could happen by plugins that decrease frame rate
auto iter = _sourceFrames.begin();
do {
if (iter->first == srcFrameNb) {
Expand Down

0 comments on commit c451fe3

Please sign in to comment.