@@ -1092,13 +1092,6 @@ bool SingleStreamDecoder::canWeAvoidSeeking() const {
10921092 // Returns true if we can avoid seeking in the AVFormatContext based on
10931093 // heuristics that rely on the target cursor_ and the last decoded frame.
10941094 // Seeking is expensive, so we try to avoid it when possible.
1095- // Note that this function itself isn't always that cheap to call: in
1096- // particular the calls to getKeyFrameIndexForPts below in approximate mode
1097- // are sometimes slow.
1098- // TODO we should understand why (is it because it reads the file?) and
1099- // potentially optimize it. E.g. we may not want to ever seek, or even *check*
1100- // if we need to seek in some cases, like if we're going to decode 80% of the
1101- // frames anyway.
11021095 const StreamInfo& streamInfo = streamInfos_.at (activeStreamIndex_);
11031096 if (streamInfo.avMediaType == AVMEDIA_TYPE_AUDIO) {
11041097 // For audio, we only need to seek if a backwards seek was requested
@@ -1145,10 +1138,10 @@ bool SingleStreamDecoder::canWeAvoidSeeking() const {
11451138 // I P P P I P P P I P P I P
11461139 // x j y
11471140 // (2) is only more efficient than (1) if there is an I frame between x and y.
1148- int lastKeyFrameIndex = getKeyFrameIndexForPts (lastDecodedAvFramePts_);
1149- int targetKeyFrameIndex = getKeyFrameIndexForPts (cursor_);
1150- return lastKeyFrameIndex >= 0 && targetKeyFrameIndex >= 0 &&
1151- lastKeyFrameIndex == targetKeyFrameIndex ;
1141+ int lastKeyFrame = getKeyFrameIdentifier (lastDecodedAvFramePts_);
1142+ int targetKeyFrame = getKeyFrameIdentifier (cursor_);
1143+ return lastKeyFrame >= 0 && targetKeyFrame >= 0 &&
1144+ lastKeyFrame == targetKeyFrame ;
11521145}
11531146
11541147// This method looks at currentPts and desiredPts and seeks in the
0 commit comments