@@ -863,10 +863,10 @@ bool VideoDecoder::canWeAvoidSeeking(int64_t targetPts) const {
863863 // We are seeking forwards.
864864 // We can only skip a seek if both lastDecodedAvFramePts and targetPts share
865865 // the same keyframe.
866- int currentKeyFrameIndex = getKeyFrameIndexForPts (lastDecodedAvFramePts);
866+ int lastDecodedAvFrameIndex = getKeyFrameIndexForPts (lastDecodedAvFramePts);
867867 int targetKeyFrameIndex = getKeyFrameIndexForPts (targetPts);
868- return currentKeyFrameIndex >= 0 && targetKeyFrameIndex >= 0 &&
869- currentKeyFrameIndex == targetKeyFrameIndex;
868+ return lastDecodedAvFrameIndex >= 0 && targetKeyFrameIndex >= 0 &&
869+ lastDecodedAvFrameIndex == targetKeyFrameIndex;
870870}
871871
872872// This method looks at currentPts and desiredPts and seeks in the
@@ -875,18 +875,16 @@ bool VideoDecoder::canWeAvoidSeeking(int64_t targetPts) const {
875875void VideoDecoder::maybeSeekToBeforeDesiredPts () {
876876 validateActiveStream ();
877877 StreamInfo& streamInfo = streamInfos_[activeStreamIndex_];
878- streamInfo.discardFramesBeforePts =
878+
879+ int64_t desiredPts =
879880 secondsToClosestPts (*desiredPtsSeconds_, streamInfo.timeBase );
881+ streamInfo.discardFramesBeforePts = desiredPts;
880882
881883 decodeStats_.numSeeksAttempted ++;
882-
883- int64_t desiredPtsForStream = *desiredPtsSeconds_ * streamInfo.timeBase .den ;
884- if (canWeAvoidSeeking (desiredPtsForStream)) {
884+ if (canWeAvoidSeeking (desiredPts)) {
885885 decodeStats_.numSeeksSkipped ++;
886886 return ;
887887 }
888- int64_t desiredPts =
889- secondsToClosestPts (*desiredPtsSeconds_, streamInfo.timeBase );
890888
891889 // For some encodings like H265, FFMPEG sometimes seeks past the point we
892890 // set as the max_ts. So we use our own index to give it the exact pts of
0 commit comments