Skip to content

Commit

Permalink
[torchcodec] remove redundant initialization check in simple video de…
Browse files Browse the repository at this point in the history
…coder (#86)

Summary:
Pull Request resolved: #86

We had a redundant check on `num_frames_computed` from a previous refactoring. This diff eliminates it and cleans up the validation function a little.

Reviewed By: ahmadsharif1

Differential Revision: D59928866

fbshipit-source-id: 1317d1c0d5f8ac128c3bc56ea5c01f283637d1ee
  • Loading branch information
scotts authored and facebook-github-bot committed Jul 19, 2024
1 parent fcf2d33 commit b9c61b4
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/torchcodec/decoders/_simple_video_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,11 @@ def _get_and_validate_stream_metadata(
) -> Tuple[core.StreamMetadata, int]:
video_metadata = core.get_video_metadata(decoder)

if video_metadata.best_video_stream_index is None:
best_stream_index = video_metadata.best_video_stream_index
if best_stream_index is None:
raise ValueError(
"The best video stream is unknown. " + _ERROR_REPORTING_INSTRUCTIONS
)

best_stream_metadata = video_metadata.streams[
video_metadata.best_video_stream_index
]
if best_stream_metadata.num_frames_computed is None:
raise ValueError(
"The number of frames is unknown. " + _ERROR_REPORTING_INSTRUCTIONS
)

return (best_stream_metadata, video_metadata.best_video_stream_index)
best_stream_metadata = video_metadata.streams[best_stream_index]
return (best_stream_metadata, best_stream_index)

0 comments on commit b9c61b4

Please sign in to comment.