Skip to content

Commit 8d00238

Browse files
committed
Minor refac
1 parent 7cc11c1 commit 8d00238

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

test/test_decoders.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
SINE_MONO_S32,
4444
SINE_MONO_S32_44100,
4545
SINE_MONO_S32_8000,
46+
supports_approximate_mode,
4647
TEST_SRC_2_720P,
4748
TEST_SRC_2_720P_H265,
4849
TEST_SRC_2_720P_MPEG4,
@@ -1469,10 +1470,7 @@ def test_get_frames_at_tensor_indices(self):
14691470
def test_beta_cuda_interface_get_frame_at(
14701471
self, asset, contiguous_indices, seek_mode
14711472
):
1472-
if (
1473-
asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9, TEST_SRC_2_720P_VP8)
1474-
and seek_mode == "approximate"
1475-
):
1473+
if seek_mode == "approximate" and not supports_approximate_mode(asset):
14761474
pytest.skip("asset doesn't work with approximate mode")
14771475

14781476
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
@@ -1518,10 +1516,7 @@ def test_beta_cuda_interface_get_frame_at(
15181516
def test_beta_cuda_interface_get_frames_at(
15191517
self, asset, contiguous_indices, seek_mode
15201518
):
1521-
if (
1522-
asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9, TEST_SRC_2_720P_VP8)
1523-
and seek_mode == "approximate"
1524-
):
1519+
if seek_mode == "approximate" and not supports_approximate_mode(asset):
15251520
pytest.skip("asset doesn't work with approximate mode")
15261521

15271522
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
@@ -1565,10 +1560,7 @@ def test_beta_cuda_interface_get_frames_at(
15651560
)
15661561
@pytest.mark.parametrize("seek_mode", ("exact", "approximate"))
15671562
def test_beta_cuda_interface_get_frame_played_at(self, asset, seek_mode):
1568-
if (
1569-
asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9, TEST_SRC_2_720P_VP8)
1570-
and seek_mode == "approximate"
1571-
):
1563+
if seek_mode == "approximate" and not supports_approximate_mode(asset):
15721564
pytest.skip("asset doesn't work with approximate mode")
15731565

15741566
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
@@ -1609,10 +1601,7 @@ def test_beta_cuda_interface_get_frame_played_at(self, asset, seek_mode):
16091601
)
16101602
@pytest.mark.parametrize("seek_mode", ("exact", "approximate"))
16111603
def test_beta_cuda_interface_get_frames_played_at(self, asset, seek_mode):
1612-
if (
1613-
asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9, TEST_SRC_2_720P_VP8)
1614-
and seek_mode == "approximate"
1615-
):
1604+
if seek_mode == "approximate" and not supports_approximate_mode(asset):
16161605
pytest.skip("asset doesn't work with approximate mode")
16171606

16181607
ref_decoder = VideoDecoder(asset.path, device="cuda", seek_mode=seek_mode)
@@ -1654,10 +1643,7 @@ def test_beta_cuda_interface_get_frames_played_at(self, asset, seek_mode):
16541643
)
16551644
@pytest.mark.parametrize("seek_mode", ("exact", "approximate"))
16561645
def test_beta_cuda_interface_backwards(self, asset, seek_mode):
1657-
if (
1658-
asset in (AV1_VIDEO, TEST_SRC_2_720P_VP9, TEST_SRC_2_720P_VP8)
1659-
and seek_mode == "approximate"
1660-
):
1646+
if seek_mode == "approximate" and not supports_approximate_mode(asset):
16611647
pytest.skip("asset doesn't work with approximate mode")
16621648

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

test/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,3 +747,10 @@ def sample_format(self) -> str:
747747
},
748748
frames={0: {}}, # Not needed for now
749749
)
750+
751+
752+
def supports_approximate_mode(asset: TestVideo) -> bool:
753+
# TODONVDEC P2: open an issue about his. That's actually not related to
754+
# NVDEC at all, those don't support approximate mode because they don't set
755+
# a duration. CPU decoder fails too!
756+
return asset not in (AV1_VIDEO, TEST_SRC_2_720P_VP9, TEST_SRC_2_720P_VP8)

0 commit comments

Comments
 (0)