Skip to content

Commit d791d2a

Browse files
committed
Simplify
1 parent 3d955c1 commit d791d2a

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -864,12 +864,10 @@ torch::Tensor VideoDecoder::getFramesPlayedInRangeAudio(
864864
// We should remove it and seek back to the stream's beginning when needed.
865865
// See test_multiple_calls
866866
TORCH_CHECK(
867-
(streamInfo.lastDecodedAvFramePts == 0 &&
868-
streamInfo.lastDecodedAvFrameDuration == 0) ||
869-
(streamInfo.lastDecodedAvFramePts +
870-
streamInfo.lastDecodedAvFrameDuration <=
871-
secondsToClosestPts(startSeconds, streamInfo.timeBase)),
872-
"The previous call's stop_seconds is larger than the current calls's start_seconds (roughly)");
867+
streamInfo.lastDecodedAvFramePts +
868+
streamInfo.lastDecodedAvFrameDuration <=
869+
secondsToClosestPts(startSeconds, streamInfo.timeBase),
870+
"Audio decoder cannot seek backwards, or start from the last decoded frame.");
873871

874872
setCursorPtsInSeconds(startSeconds);
875873

test/decoders/test_ops.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -782,27 +782,19 @@ def get_reference_frames(start_seconds, stop_seconds):
782782
)
783783

784784
# but starting immediately on the same frame raises
785-
with pytest.raises(
786-
RuntimeError,
787-
match="The previous call's stop_seconds is larger than the current calls's start_seconds",
788-
):
785+
expected_match = "Audio decoder cannot seek backwards"
786+
with pytest.raises(RuntimeError, match=expected_match):
789787
get_frames_by_pts_in_range_audio(
790788
decoder, start_seconds=stop_seconds, stop_seconds=6
791789
)
792790

793-
with pytest.raises(
794-
RuntimeError,
795-
match="The previous call's stop_seconds is larger than the current calls's start_seconds",
796-
):
791+
with pytest.raises(RuntimeError, match=expected_match):
797792
get_frames_by_pts_in_range_audio(
798793
decoder, start_seconds=stop_seconds + 1e-4, stop_seconds=6
799794
)
800795

801796
# and seeking backwards doesn't work either
802-
with pytest.raises(
803-
RuntimeError,
804-
match="The previous call's stop_seconds is larger than the current calls's start_seconds",
805-
):
797+
with pytest.raises(RuntimeError, match=expected_match):
806798
frames = get_frames_by_pts_in_range_audio(
807799
decoder, start_seconds=0, stop_seconds=2
808800
)

0 commit comments

Comments
 (0)