-
Notifications
You must be signed in to change notification settings - Fork 51
Avoid silently wrong results on 10bit CUDA #777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a9b6d46
0ea6f40
31575b3
ce12ecb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,12 +26,15 @@ | |
AV1_VIDEO, | ||
cpu_and_cuda, | ||
get_ffmpeg_major_version, | ||
H264_10BITS, | ||
H265_10BITS, | ||
H265_VIDEO, | ||
in_fbcode, | ||
NASA_AUDIO, | ||
NASA_AUDIO_MP3, | ||
NASA_AUDIO_MP3_44100, | ||
NASA_VIDEO, | ||
needs_cuda, | ||
SINE_MONO_S16, | ||
SINE_MONO_S32, | ||
SINE_MONO_S32_44100, | ||
|
@@ -1138,6 +1141,31 @@ def test_pts_to_dts_fallback(self, seek_mode): | |
with pytest.raises(AssertionError, match="not equal"): | ||
torch.testing.assert_close(decoder[0], decoder[10]) | ||
|
||
@needs_cuda | ||
@pytest.mark.parametrize("asset", (H264_10BITS, H265_10BITS)) | ||
def test_10bit_videos_cuda(self, asset): | ||
# Assert that we raise proper error on different kinds of 10bit videos. | ||
|
||
# TODO we should investigate how to support 10bit videos on GPU. | ||
# See https://github.com/pytorch/torchcodec/issues/776 | ||
|
||
decoder = VideoDecoder(asset.path, device="cuda") | ||
|
||
if asset is H265_10BITS: | ||
match = "The AVFrame is p010le, but we expected AV_PIX_FMT_NV12." | ||
else: | ||
match = "Expected format to be AV_PIX_FMT_CUDA, got yuv420p10le." | ||
with pytest.raises(RuntimeError, match=match): | ||
decoder.get_frame_at(0) | ||
|
||
@pytest.mark.parametrize("asset", (H264_10BITS, H265_10BITS)) | ||
def test_10bit_videos_cpu(self, asset): | ||
# This just validates that we can decode 10-bit videos on CPU. | ||
# TODO validate against the ref that the decoded frames are correct | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is required to test that the decoded frames are correct? It seems we would need to check in additional png files from each 10-bit video to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, we'd have to check in a few reference frames to compare against. We usually store those as raw |
||
|
||
decoder = VideoDecoder(asset.path) | ||
decoder.get_frame_at(10) | ||
|
||
|
||
class TestAudioDecoder: | ||
@pytest.mark.parametrize("asset", (NASA_AUDIO, NASA_AUDIO_MP3, SINE_MONO_S32)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create an issue to track.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following up in #776