Skip to content

Commit 1b2c887

Browse files
committed
Put back const qualifiers
1 parent 5ac1523 commit 1b2c887

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -845,9 +845,8 @@ I P P P I P P P I P P I P P I P
845845
846846
(2) is more efficient than (1) if there is an I frame between x and y.
847847
*/
848-
bool VideoDecoder::canWeAvoidSeekingForStream(
849-
int64_t currentPts,
850-
int64_t targetPts) {
848+
bool VideoDecoder::canWeAvoidSeeking(int64_t currentPts, int64_t targetPts)
849+
const {
851850
if (targetPts < currentPts) {
852851
// We can never skip a seek if we are seeking backwards.
853852
return false;
@@ -880,7 +879,7 @@ void VideoDecoder::maybeSeekToBeforeDesiredPts() {
880879
decodeStats_.numSeeksAttempted++;
881880

882881
int64_t desiredPtsForStream = *desiredPtsSeconds_ * streamInfo.timeBase.den;
883-
if (canWeAvoidSeekingForStream(streamInfo.currentPts, desiredPtsForStream)) {
882+
if (canWeAvoidSeeking(streamInfo.currentPts, desiredPtsForStream)) {
884883
decodeStats_.numSeeksSkipped++;
885884
return;
886885
}
@@ -1472,8 +1471,8 @@ void VideoDecoder::createSwsContext(
14721471
// PTS <-> INDEX CONVERSIONS
14731472
// --------------------------------------------------------------------------
14741473

1475-
int VideoDecoder::getKeyFrameIndexForPts(int64_t pts) {
1476-
const StreamInfo& streamInfo = streamInfos_[activeStreamIndex_];
1474+
int VideoDecoder::getKeyFrameIndexForPts(int64_t pts) const {
1475+
const StreamInfo& streamInfo = streamInfos_.at(activeStreamIndex_);
14771476
if (streamInfo.keyFrames.empty()) {
14781477
return av_index_search_timestamp(
14791478
streamInfo.stream, pts, AVSEEK_FLAG_BACKWARD);
@@ -1484,7 +1483,7 @@ int VideoDecoder::getKeyFrameIndexForPts(int64_t pts) {
14841483

14851484
int VideoDecoder::getKeyFrameIndexForPtsUsingScannedIndex(
14861485
const std::vector<VideoDecoder::FrameInfo>& keyFrames,
1487-
int64_t pts) {
1486+
int64_t pts) const {
14881487
auto upperBound = std::upper_bound(
14891488
keyFrames.begin(),
14901489
keyFrames.end(),

src/torchcodec/decoders/_core/VideoDecoder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ class VideoDecoder {
361361
// DECODING APIS AND RELATED UTILS
362362
// --------------------------------------------------------------------------
363363

364-
bool canWeAvoidSeekingForStream(int64_t currentPts, int64_t targetPts);
364+
bool canWeAvoidSeeking(int64_t currentPts, int64_t targetPts) const;
365365

366366
void maybeSeekToBeforeDesiredPts();
367367

@@ -405,14 +405,14 @@ class VideoDecoder {
405405
// PTS <-> INDEX CONVERSIONS
406406
// --------------------------------------------------------------------------
407407

408-
int getKeyFrameIndexForPts(int64_t pts);
408+
int getKeyFrameIndexForPts(int64_t pts) const;
409409

410410
// Returns the key frame index of the presentation timestamp using our index.
411411
// We build this index by scanning the file in
412412
// scanFileAndUpdateMetadataAndIndex
413413
int getKeyFrameIndexForPtsUsingScannedIndex(
414414
const std::vector<VideoDecoder::FrameInfo>& keyFrames,
415-
int64_t pts);
415+
int64_t pts) const;
416416

417417
int64_t secondsToIndexLowerBound(
418418
double seconds,

0 commit comments

Comments
 (0)