|
23 | 23 | ) |
24 | 24 | from torchcodec.decoders._decoder_utils import _get_cuda_backend |
25 | 25 | from torchcodec.decoders._wav_decoder import WavDecoder |
| 26 | +from torchcodec.encoders import VideoEncoder |
26 | 27 | from torchcodec.transforms import CenterCrop, RandomCrop, Resize |
27 | 28 |
|
28 | 29 | from .utils import ( |
@@ -2032,6 +2033,25 @@ def test_nvdec_cuda_interface_cpu_fallback(self): |
2032 | 2033 |
|
2033 | 2034 | assert psnr(ref_frame.data, nvdec_frame.data) > 25 |
2034 | 2035 |
|
| 2036 | + @needs_cuda |
| 2037 | + def test_nvdec_cpu_fallback_yuv444(self, tmp_path): |
| 2038 | + # Non-regression test for https://github.com/meta-pytorch/torchcodec/issues/1414 |
| 2039 | + num_frames = 5 |
| 2040 | + frames = torch.randint(0, 256, size=(num_frames, 3, 64, 64), dtype=torch.uint8) |
| 2041 | + path = str(tmp_path / "yuv444.mp4") |
| 2042 | + VideoEncoder(frames=frames, frame_rate=30).to_file( |
| 2043 | + path, pixel_format="yuv444p", crf=0 |
| 2044 | + ) |
| 2045 | + |
| 2046 | + cpu_decoder = VideoDecoder(path, device="cpu") |
| 2047 | + cuda_decoder = VideoDecoder(path, device="cuda") |
| 2048 | + assert cuda_decoder.cpu_fallback |
| 2049 | + |
| 2050 | + cpu_frames = cpu_decoder.get_frames_in_range(start=0, stop=num_frames).data |
| 2051 | + cuda_frames = cuda_decoder.get_frames_in_range(start=0, stop=num_frames).data |
| 2052 | + |
| 2053 | + torch.testing.assert_close(cpu_frames, cuda_frames.cpu(), rtol=0, atol=0) |
| 2054 | + |
2035 | 2055 | @needs_cuda |
2036 | 2056 | def test_nvdec_cuda_interface_error(self): |
2037 | 2057 | with pytest.raises(RuntimeError, match="torch_parse_device_string"): |
|
0 commit comments