Skip to content

Commit 8ce445b

Browse files
committed
Add VP8 support
1 parent 9b36a5d commit 8ce445b

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

src/torchcodec/_core/BetaCudaDeviceInterface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,10 @@ cudaVideoCodec validateCodecSupport(AVCodecID codecId) {
152152
return cudaVideoCodec_AV1;
153153
case AV_CODEC_ID_VP9:
154154
return cudaVideoCodec_VP9;
155+
case AV_CODEC_ID_VP8:
156+
return cudaVideoCodec_VP8;
155157
// TODONVDEC P0: support more codecs
156158
// case AV_CODEC_ID_MPEG4: return cudaVideoCodec_MPEG4;
157-
// case AV_CODEC_ID_VP8: return cudaVideoCodec_VP8;
158159
// case AV_CODEC_ID_MJPEG: return cudaVideoCodec_JPEG;
159160
default: {
160161
TORCH_CHECK(false, "Unsupported codec type: ", avcodec_get_name(codecId));

test/resources/testsrc2_vp8.webm

141 KB
Binary file not shown.

test/test_decoders.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
SINE_MONO_S32_8000,
4646
TEST_SRC_2_720P,
4747
TEST_SRC_2_720P_H265,
48+
TEST_SRC_2_720P_VP8,
4849
TEST_SRC_2_720P_VP9,
4950
unsplit_device_str,
5051
)
@@ -1453,14 +1454,18 @@ def test_get_frames_at_tensor_indices(self):
14531454
TEST_SRC_2_720P_H265,
14541455
AV1_VIDEO,
14551456
TEST_SRC_2_720P_VP9,
1457+
TEST_SRC_2_720P_VP8,
14561458
),
14571459
)
14581460
@pytest.mark.parametrize("contiguous_indices", (True, False))
14591461
@pytest.mark.parametrize("seek_mode", ("exact", "approximate"))
14601462
def test_beta_cuda_interface_get_frame_at(
14611463
self, asset, contiguous_indices, seek_mode
14621464
):
1463-
if asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9) and seek_mode == "approximate":
1465+
if (
1466+
asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9, TEST_SRC_2_720P_VP8)
1467+
and seek_mode == "approximate"
1468+
):
14641469
pytest.skip("asset doesn't work with approximate mode")
14651470

14661471
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
@@ -1496,14 +1501,18 @@ def test_beta_cuda_interface_get_frame_at(
14961501
TEST_SRC_2_720P_H265,
14971502
AV1_VIDEO,
14981503
TEST_SRC_2_720P_VP9,
1504+
TEST_SRC_2_720P_VP8,
14991505
),
15001506
)
15011507
@pytest.mark.parametrize("contiguous_indices", (True, False))
15021508
@pytest.mark.parametrize("seek_mode", ("exact", "approximate"))
15031509
def test_beta_cuda_interface_get_frames_at(
15041510
self, asset, contiguous_indices, seek_mode
15051511
):
1506-
if asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9) and seek_mode == "approximate":
1512+
if (
1513+
asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9, TEST_SRC_2_720P_VP8)
1514+
and seek_mode == "approximate"
1515+
):
15071516
pytest.skip("asset doesn't work with approximate mode")
15081517

15091518
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
@@ -1540,11 +1549,15 @@ def test_beta_cuda_interface_get_frames_at(
15401549
TEST_SRC_2_720P_H265,
15411550
AV1_VIDEO,
15421551
TEST_SRC_2_720P_VP9,
1552+
TEST_SRC_2_720P_VP8,
15431553
),
15441554
)
15451555
@pytest.mark.parametrize("seek_mode", ("exact", "approximate"))
15461556
def test_beta_cuda_interface_get_frame_played_at(self, asset, seek_mode):
1547-
if asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9) and seek_mode == "approximate":
1557+
if (
1558+
asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9, TEST_SRC_2_720P_VP8)
1559+
and seek_mode == "approximate"
1560+
):
15481561
pytest.skip("asset doesn't work with approximate mode")
15491562

15501563
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
@@ -1577,12 +1590,16 @@ def test_beta_cuda_interface_get_frame_played_at(self, asset, seek_mode):
15771590
BT709_FULL_RANGE,
15781591
TEST_SRC_2_720P_H265,
15791592
TEST_SRC_2_720P_VP9,
1593+
TEST_SRC_2_720P_VP8,
15801594
AV1_VIDEO,
15811595
),
15821596
)
15831597
@pytest.mark.parametrize("seek_mode", ("exact", "approximate"))
15841598
def test_beta_cuda_interface_get_frames_played_at(self, asset, seek_mode):
1585-
if asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9) and seek_mode == "approximate":
1599+
if (
1600+
asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9, TEST_SRC_2_720P_VP8)
1601+
and seek_mode == "approximate"
1602+
):
15861603
pytest.skip("asset doesn't work with approximate mode")
15871604

15881605
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
@@ -1617,11 +1634,15 @@ def test_beta_cuda_interface_get_frames_played_at(self, asset, seek_mode):
16171634
TEST_SRC_2_720P_H265,
16181635
AV1_VIDEO,
16191636
TEST_SRC_2_720P_VP9,
1637+
TEST_SRC_2_720P_VP8,
16201638
),
16211639
)
16221640
@pytest.mark.parametrize("seek_mode", ("exact", "approximate"))
16231641
def test_beta_cuda_interface_backwards(self, asset, seek_mode):
1624-
if asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9) and seek_mode == "approximate":
1642+
if (
1643+
asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9, TEST_SRC_2_720P_VP8)
1644+
and seek_mode == "approximate"
1645+
):
16251646
pytest.skip("asset doesn't work with approximate mode")
16261647

16271648
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)

test/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,3 +727,13 @@ def sample_format(self) -> str:
727727
},
728728
frames={0: {}}, # Not needed for now
729729
)
730+
731+
# ffmpeg -f lavfi -i testsrc2=size=1280x720:rate=30:duration=1 -c:v libvpx -b:v 1M output_vp8.webm
732+
TEST_SRC_2_720P_VP8 = TestVideo(
733+
filename="testsrc2_vp8.webm",
734+
default_stream_index=0,
735+
stream_infos={
736+
0: TestVideoStreamInfo(width=1280, height=720, num_color_channels=3),
737+
},
738+
frames={0: {}}, # Not needed for now
739+
)

0 commit comments

Comments
 (0)