Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/torchcodec/_core/SingleStreamDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,11 @@ FrameOutput SingleStreamDecoder::convertAVFrameToFrameOutput(
formatContext_->streams[activeStreamIndex_]->time_base);
if (streamInfo.avMediaType == AVMEDIA_TYPE_AUDIO) {
convertAudioAVFrameToFrameOutputOnCPU(avFrame, frameOutput);
} else if (deviceInterface_) {
} else {
TORCH_CHECK(
deviceInterface_ != nullptr,
"No device interface available for video decoding. This ",
"shouldn't happen, please report.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new TORCH_CHECK is important but just as important is the change of the else if into a simple else

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add TORCH_CHECK(streamInfo.avMediaType == AVMEDIA_TYPE_VIDEO)? I believe that is also assumed.

Copy link
Contributor Author

@NicolasHug NicolasHug Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true that this is assumed but I think we can skip the check in the function, because this is heavily validated upstream in all callers, e.g. by calling validateActiveStream(...);

No strong opinion, I can add the check in a follow-up if you think it's good to validate it here as well.

deviceInterface_->convertAVFrameToFrameOutput(
streamInfo.videoStreamOptions,
streamInfo.timeBase,
Expand Down
Loading