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 ,
49+ TEST_SRC_2_720P_MPEG4 ,
50+ TEST_SRC_2_720P_VP8 ,
51+ TEST_SRC_2_720P_VP9 ,
4852 unsplit_device_str ,
4953)
5054
@@ -588,7 +592,7 @@ def test_get_frame_at_av1(self, device):
588592 return
589593
590594 if device == "cuda" and in_fbcode ():
591- pytest .skip ("AV1 decoding on CUDA is not supported internally" )
595+ pytest .skip ("decoding on CUDA is not supported internally" )
592596
593597 decoder = VideoDecoder (AV1_VIDEO .path , device = device )
594598 device , _ = unsplit_device_str (device )
@@ -1432,15 +1436,20 @@ def test_get_frames_at_tensor_indices(self):
14321436 decoder .get_frames_played_at (torch .tensor ([0 , 1 ], dtype = torch .int ))
14331437 decoder .get_frames_played_at (torch .tensor ([0 , 1 ], dtype = torch .float ))
14341438
1435- # TODONVDEC P1 unskip equality assertion checks on FFMpeg4. The comparison
1436- # checks are failing on very few pixels, e.g.:
1439+ # TODONVDEC P1:
1440+ # - unskip equality assertion checks on FFMpeg4. The comparison
1441+ # checks are failing on very few pixels, e.g.:
14371442 #
1438- # E Mismatched elements: 648586 / 82944000 (0.8%)
1439- # E Greatest absolute difference: 164 at index (20, 2, 27, 96)
1440- # E Greatest relative difference: inf at index (5, 1, 112, 186)
1443+ # E Mismatched elements: 648586 / 82944000 (0.8%)
1444+ # E Greatest absolute difference: 164 at index (20, 2, 27, 96)
1445+ # E Greatest relative difference: inf at index (5, 1, 112, 186)
14411446 #
1442- # So we're skipping them to unblock for now, but we should call
1443- # assert_tensor_close_on_at_least or something like that.
1447+ # So we're skipping them to unblock for now, but we should call
1448+ # assert_tensor_close_on_at_least or something like that.
1449+ # - unskip equality assertion checks for MPEG4 asset. The frames are decoded
1450+ # fine, it's the color conversion that's different. The frame from the
1451+ # BETA interface is assumed to be 701 while the one from the default
1452+ # interface is 601.
14441453
14451454 @needs_cuda
14461455 @pytest .mark .parametrize (
@@ -1451,15 +1460,18 @@ def test_get_frames_at_tensor_indices(self):
14511460 BT709_FULL_RANGE ,
14521461 TEST_SRC_2_720P_H265 ,
14531462 AV1_VIDEO ,
1463+ TEST_SRC_2_720P_VP9 ,
1464+ TEST_SRC_2_720P_VP8 ,
1465+ TEST_SRC_2_720P_MPEG4 ,
14541466 ),
14551467 )
14561468 @pytest .mark .parametrize ("contiguous_indices" , (True , False ))
14571469 @pytest .mark .parametrize ("seek_mode" , ("exact" , "approximate" ))
14581470 def test_beta_cuda_interface_get_frame_at (
14591471 self , asset , contiguous_indices , seek_mode
14601472 ):
1461- if asset == AV1_VIDEO and seek_mode == "approximate" :
1462- pytest .skip ("AV1 asset doesn't work with approximate mode" )
1473+ if seek_mode == "approximate" and not supports_approximate_mode ( asset ) :
1474+ pytest .skip ("asset doesn't work with approximate mode" )
14631475
14641476 ref_decoder = VideoDecoder (asset .path , device = "cuda" , seek_mode = seek_mode )
14651477 beta_decoder = VideoDecoder (
@@ -1476,7 +1488,8 @@ def test_beta_cuda_interface_get_frame_at(
14761488 for frame_index in indices :
14771489 ref_frame = ref_decoder .get_frame_at (frame_index )
14781490 beta_frame = beta_decoder .get_frame_at (frame_index )
1479- if get_ffmpeg_major_version () > 4 : # TODONVDEC P1 see above
1491+ # TODONVDEC P1 see above
1492+ if get_ffmpeg_major_version () > 4 and asset is not TEST_SRC_2_720P_MPEG4 :
14801493 torch .testing .assert_close (
14811494 beta_frame .data , ref_frame .data , rtol = 0 , atol = 0
14821495 )
@@ -1493,15 +1506,18 @@ def test_beta_cuda_interface_get_frame_at(
14931506 BT709_FULL_RANGE ,
14941507 TEST_SRC_2_720P_H265 ,
14951508 AV1_VIDEO ,
1509+ TEST_SRC_2_720P_VP9 ,
1510+ TEST_SRC_2_720P_VP8 ,
1511+ TEST_SRC_2_720P_MPEG4 ,
14961512 ),
14971513 )
14981514 @pytest .mark .parametrize ("contiguous_indices" , (True , False ))
14991515 @pytest .mark .parametrize ("seek_mode" , ("exact" , "approximate" ))
15001516 def test_beta_cuda_interface_get_frames_at (
15011517 self , asset , contiguous_indices , seek_mode
15021518 ):
1503- if asset == AV1_VIDEO and seek_mode == "approximate" :
1504- pytest .skip ("AV1 asset doesn't work with approximate mode" )
1519+ if seek_mode == "approximate" and not supports_approximate_mode ( asset ) :
1520+ pytest .skip ("asset doesn't work with approximate mode" )
15051521
15061522 ref_decoder = VideoDecoder (asset .path , device = "cuda" , seek_mode = seek_mode )
15071523 beta_decoder = VideoDecoder (
@@ -1518,7 +1534,8 @@ def test_beta_cuda_interface_get_frames_at(
15181534
15191535 ref_frames = ref_decoder .get_frames_at (indices )
15201536 beta_frames = beta_decoder .get_frames_at (indices )
1521- if get_ffmpeg_major_version () > 4 : # TODONVDEC P1 see above
1537+ # TODONVDEC P1 see above
1538+ if get_ffmpeg_major_version () > 4 and asset is not TEST_SRC_2_720P_MPEG4 :
15221539 torch .testing .assert_close (
15231540 beta_frames .data , ref_frames .data , rtol = 0 , atol = 0
15241541 )
@@ -1536,12 +1553,15 @@ def test_beta_cuda_interface_get_frames_at(
15361553 BT709_FULL_RANGE ,
15371554 TEST_SRC_2_720P_H265 ,
15381555 AV1_VIDEO ,
1556+ TEST_SRC_2_720P_VP9 ,
1557+ TEST_SRC_2_720P_VP8 ,
1558+ TEST_SRC_2_720P_MPEG4 ,
15391559 ),
15401560 )
15411561 @pytest .mark .parametrize ("seek_mode" , ("exact" , "approximate" ))
15421562 def test_beta_cuda_interface_get_frame_played_at (self , asset , seek_mode ):
1543- if asset == AV1_VIDEO and seek_mode == "approximate" :
1544- pytest .skip ("AV1 asset doesn't work with approximate mode" )
1563+ if seek_mode == "approximate" and not supports_approximate_mode ( asset ) :
1564+ pytest .skip ("asset doesn't work with approximate mode" )
15451565
15461566 ref_decoder = VideoDecoder (asset .path , device = "cuda" , seek_mode = seek_mode )
15471567 beta_decoder = VideoDecoder (
@@ -1556,7 +1576,8 @@ def test_beta_cuda_interface_get_frame_played_at(self, asset, seek_mode):
15561576 for pts in timestamps :
15571577 ref_frame = ref_decoder .get_frame_played_at (pts )
15581578 beta_frame = beta_decoder .get_frame_played_at (pts )
1559- if get_ffmpeg_major_version () > 4 : # TODONVDEC P1 see above
1579+ # TODONVDEC P1 see above
1580+ if get_ffmpeg_major_version () > 4 and asset is not TEST_SRC_2_720P_MPEG4 :
15601581 torch .testing .assert_close (
15611582 beta_frame .data , ref_frame .data , rtol = 0 , atol = 0
15621583 )
@@ -1573,12 +1594,15 @@ def test_beta_cuda_interface_get_frame_played_at(self, asset, seek_mode):
15731594 BT709_FULL_RANGE ,
15741595 TEST_SRC_2_720P_H265 ,
15751596 AV1_VIDEO ,
1597+ TEST_SRC_2_720P_VP9 ,
1598+ TEST_SRC_2_720P_VP8 ,
1599+ TEST_SRC_2_720P_MPEG4 ,
15761600 ),
15771601 )
15781602 @pytest .mark .parametrize ("seek_mode" , ("exact" , "approximate" ))
15791603 def test_beta_cuda_interface_get_frames_played_at (self , asset , seek_mode ):
1580- if asset == AV1_VIDEO and seek_mode == "approximate" :
1581- pytest .skip ("AV1 asset doesn't work with approximate mode" )
1604+ if seek_mode == "approximate" and not supports_approximate_mode ( asset ) :
1605+ pytest .skip ("asset doesn't work with approximate mode" )
15821606
15831607 ref_decoder = VideoDecoder (asset .path , device = "cuda" , seek_mode = seek_mode )
15841608 beta_decoder = VideoDecoder (
@@ -1593,7 +1617,8 @@ def test_beta_cuda_interface_get_frames_played_at(self, asset, seek_mode):
15931617
15941618 ref_frames = ref_decoder .get_frames_played_at (timestamps )
15951619 beta_frames = beta_decoder .get_frames_played_at (timestamps )
1596- if get_ffmpeg_major_version () > 4 : # TODONVDEC P1 see above
1620+ # TODONVDEC P1 see above
1621+ if get_ffmpeg_major_version () > 4 and asset is not TEST_SRC_2_720P_MPEG4 :
15971622 torch .testing .assert_close (
15981623 beta_frames .data , ref_frames .data , rtol = 0 , atol = 0
15991624 )
@@ -1611,12 +1636,15 @@ def test_beta_cuda_interface_get_frames_played_at(self, asset, seek_mode):
16111636 BT709_FULL_RANGE ,
16121637 TEST_SRC_2_720P_H265 ,
16131638 AV1_VIDEO ,
1639+ TEST_SRC_2_720P_VP9 ,
1640+ TEST_SRC_2_720P_VP8 ,
1641+ TEST_SRC_2_720P_MPEG4 ,
16141642 ),
16151643 )
16161644 @pytest .mark .parametrize ("seek_mode" , ("exact" , "approximate" ))
16171645 def test_beta_cuda_interface_backwards (self , asset , seek_mode ):
1618- if asset == AV1_VIDEO and seek_mode == "approximate" :
1619- pytest .skip ("AV1 asset doesn't work with approximate mode" )
1646+ if seek_mode == "approximate" and not supports_approximate_mode ( asset ) :
1647+ pytest .skip ("asset doesn't work with approximate mode" )
16201648
16211649 ref_decoder = VideoDecoder (asset .path , device = "cuda" , seek_mode = seek_mode )
16221650 beta_decoder = VideoDecoder (
@@ -1635,7 +1663,8 @@ def test_beta_cuda_interface_backwards(self, asset, seek_mode):
16351663
16361664 ref_frame = ref_decoder .get_frame_at (frame_index )
16371665 beta_frame = beta_decoder .get_frame_at (frame_index )
1638- if get_ffmpeg_major_version () > 4 : # TODONVDEC P1 see above
1666+ # TODONVDEC P1 see above
1667+ if get_ffmpeg_major_version () > 4 and asset is not TEST_SRC_2_720P_MPEG4 :
16391668 torch .testing .assert_close (
16401669 beta_frame .data , ref_frame .data , rtol = 0 , atol = 0
16411670 )
0 commit comments