@@ -859,10 +859,10 @@ bool VideoDecoder::canWeAvoidSeeking(int64_t targetPts) const {
859859 // We are seeking forwards.
860860 // We can only skip a seek if both lastDecodedAvFramePts and targetPts share
861861 // the same keyframe.
862- int currentKeyFrameIndex = getKeyFrameIndexForPts (lastDecodedAvFramePts);
862+ int lastDecodedAvFrameIndex = getKeyFrameIndexForPts (lastDecodedAvFramePts);
863863 int targetKeyFrameIndex = getKeyFrameIndexForPts (targetPts);
864- return currentKeyFrameIndex >= 0 && targetKeyFrameIndex >= 0 &&
865- currentKeyFrameIndex == targetKeyFrameIndex;
864+ return lastDecodedAvFrameIndex >= 0 && targetKeyFrameIndex >= 0 &&
865+ lastDecodedAvFrameIndex == targetKeyFrameIndex;
866866}
867867
868868// This method looks at currentPts and desiredPts and seeks in the
@@ -871,18 +871,16 @@ bool VideoDecoder::canWeAvoidSeeking(int64_t targetPts) const {
871871void VideoDecoder::maybeSeekToBeforeDesiredPts () {
872872 validateActiveStream ();
873873 StreamInfo& streamInfo = streamInfos_[activeStreamIndex_];
874- streamInfo.discardFramesBeforePts =
874+
875+ int64_t desiredPts =
875876 secondsToClosestPts (*desiredPtsSeconds_, streamInfo.timeBase );
877+ streamInfo.discardFramesBeforePts = desiredPts;
876878
877879 decodeStats_.numSeeksAttempted ++;
878-
879- int64_t desiredPtsForStream = *desiredPtsSeconds_ * streamInfo.timeBase .den ;
880- if (canWeAvoidSeeking (desiredPtsForStream)) {
880+ if (canWeAvoidSeeking (desiredPts)) {
881881 decodeStats_.numSeeksSkipped ++;
882882 return ;
883883 }
884- int64_t desiredPts =
885- secondsToClosestPts (*desiredPtsSeconds_, streamInfo.timeBase );
886884
887885 // For some encodings like H265, FFMPEG sometimes seeks past the point we
888886 // set as the max_ts. So we use our own index to give it the exact pts of
0 commit comments