43
43
SINE_MONO_S32 ,
44
44
SINE_MONO_S32_44100 ,
45
45
SINE_MONO_S32_8000 ,
46
+ supports_approximate_mode ,
46
47
TEST_SRC_2_720P ,
47
48
TEST_SRC_2_720P_H265 ,
49
+ TEST_SRC_2_720P_MPEG4 ,
50
+ TEST_SRC_2_720P_VP8 ,
51
+ TEST_SRC_2_720P_VP9 ,
48
52
unsplit_device_str ,
49
53
)
50
54
@@ -588,7 +592,7 @@ def test_get_frame_at_av1(self, device):
588
592
return
589
593
590
594
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" )
592
596
593
597
decoder = VideoDecoder (AV1_VIDEO .path , device = device )
594
598
device , _ = unsplit_device_str (device )
@@ -1432,15 +1436,20 @@ def test_get_frames_at_tensor_indices(self):
1432
1436
decoder .get_frames_played_at (torch .tensor ([0 , 1 ], dtype = torch .int ))
1433
1437
decoder .get_frames_played_at (torch .tensor ([0 , 1 ], dtype = torch .float ))
1434
1438
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.:
1437
1442
#
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)
1441
1446
#
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.
1444
1453
1445
1454
@needs_cuda
1446
1455
@pytest .mark .parametrize (
@@ -1451,15 +1460,18 @@ def test_get_frames_at_tensor_indices(self):
1451
1460
BT709_FULL_RANGE ,
1452
1461
TEST_SRC_2_720P_H265 ,
1453
1462
AV1_VIDEO ,
1463
+ TEST_SRC_2_720P_VP9 ,
1464
+ TEST_SRC_2_720P_VP8 ,
1465
+ TEST_SRC_2_720P_MPEG4 ,
1454
1466
),
1455
1467
)
1456
1468
@pytest .mark .parametrize ("contiguous_indices" , (True , False ))
1457
1469
@pytest .mark .parametrize ("seek_mode" , ("exact" , "approximate" ))
1458
1470
def test_beta_cuda_interface_get_frame_at (
1459
1471
self , asset , contiguous_indices , seek_mode
1460
1472
):
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" )
1463
1475
1464
1476
ref_decoder = VideoDecoder (asset .path , device = "cuda" , seek_mode = seek_mode )
1465
1477
beta_decoder = VideoDecoder (
@@ -1476,7 +1488,8 @@ def test_beta_cuda_interface_get_frame_at(
1476
1488
for frame_index in indices :
1477
1489
ref_frame = ref_decoder .get_frame_at (frame_index )
1478
1490
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 :
1480
1493
torch .testing .assert_close (
1481
1494
beta_frame .data , ref_frame .data , rtol = 0 , atol = 0
1482
1495
)
@@ -1493,15 +1506,18 @@ def test_beta_cuda_interface_get_frame_at(
1493
1506
BT709_FULL_RANGE ,
1494
1507
TEST_SRC_2_720P_H265 ,
1495
1508
AV1_VIDEO ,
1509
+ TEST_SRC_2_720P_VP9 ,
1510
+ TEST_SRC_2_720P_VP8 ,
1511
+ TEST_SRC_2_720P_MPEG4 ,
1496
1512
),
1497
1513
)
1498
1514
@pytest .mark .parametrize ("contiguous_indices" , (True , False ))
1499
1515
@pytest .mark .parametrize ("seek_mode" , ("exact" , "approximate" ))
1500
1516
def test_beta_cuda_interface_get_frames_at (
1501
1517
self , asset , contiguous_indices , seek_mode
1502
1518
):
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" )
1505
1521
1506
1522
ref_decoder = VideoDecoder (asset .path , device = "cuda" , seek_mode = seek_mode )
1507
1523
beta_decoder = VideoDecoder (
@@ -1518,7 +1534,8 @@ def test_beta_cuda_interface_get_frames_at(
1518
1534
1519
1535
ref_frames = ref_decoder .get_frames_at (indices )
1520
1536
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 :
1522
1539
torch .testing .assert_close (
1523
1540
beta_frames .data , ref_frames .data , rtol = 0 , atol = 0
1524
1541
)
@@ -1536,12 +1553,15 @@ def test_beta_cuda_interface_get_frames_at(
1536
1553
BT709_FULL_RANGE ,
1537
1554
TEST_SRC_2_720P_H265 ,
1538
1555
AV1_VIDEO ,
1556
+ TEST_SRC_2_720P_VP9 ,
1557
+ TEST_SRC_2_720P_VP8 ,
1558
+ TEST_SRC_2_720P_MPEG4 ,
1539
1559
),
1540
1560
)
1541
1561
@pytest .mark .parametrize ("seek_mode" , ("exact" , "approximate" ))
1542
1562
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" )
1545
1565
1546
1566
ref_decoder = VideoDecoder (asset .path , device = "cuda" , seek_mode = seek_mode )
1547
1567
beta_decoder = VideoDecoder (
@@ -1556,7 +1576,8 @@ def test_beta_cuda_interface_get_frame_played_at(self, asset, seek_mode):
1556
1576
for pts in timestamps :
1557
1577
ref_frame = ref_decoder .get_frame_played_at (pts )
1558
1578
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 :
1560
1581
torch .testing .assert_close (
1561
1582
beta_frame .data , ref_frame .data , rtol = 0 , atol = 0
1562
1583
)
@@ -1573,12 +1594,15 @@ def test_beta_cuda_interface_get_frame_played_at(self, asset, seek_mode):
1573
1594
BT709_FULL_RANGE ,
1574
1595
TEST_SRC_2_720P_H265 ,
1575
1596
AV1_VIDEO ,
1597
+ TEST_SRC_2_720P_VP9 ,
1598
+ TEST_SRC_2_720P_VP8 ,
1599
+ TEST_SRC_2_720P_MPEG4 ,
1576
1600
),
1577
1601
)
1578
1602
@pytest .mark .parametrize ("seek_mode" , ("exact" , "approximate" ))
1579
1603
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" )
1582
1606
1583
1607
ref_decoder = VideoDecoder (asset .path , device = "cuda" , seek_mode = seek_mode )
1584
1608
beta_decoder = VideoDecoder (
@@ -1593,7 +1617,8 @@ def test_beta_cuda_interface_get_frames_played_at(self, asset, seek_mode):
1593
1617
1594
1618
ref_frames = ref_decoder .get_frames_played_at (timestamps )
1595
1619
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 :
1597
1622
torch .testing .assert_close (
1598
1623
beta_frames .data , ref_frames .data , rtol = 0 , atol = 0
1599
1624
)
@@ -1611,12 +1636,15 @@ def test_beta_cuda_interface_get_frames_played_at(self, asset, seek_mode):
1611
1636
BT709_FULL_RANGE ,
1612
1637
TEST_SRC_2_720P_H265 ,
1613
1638
AV1_VIDEO ,
1639
+ TEST_SRC_2_720P_VP9 ,
1640
+ TEST_SRC_2_720P_VP8 ,
1641
+ TEST_SRC_2_720P_MPEG4 ,
1614
1642
),
1615
1643
)
1616
1644
@pytest .mark .parametrize ("seek_mode" , ("exact" , "approximate" ))
1617
1645
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" )
1620
1648
1621
1649
ref_decoder = VideoDecoder (asset .path , device = "cuda" , seek_mode = seek_mode )
1622
1650
beta_decoder = VideoDecoder (
@@ -1635,7 +1663,8 @@ def test_beta_cuda_interface_backwards(self, asset, seek_mode):
1635
1663
1636
1664
ref_frame = ref_decoder .get_frame_at (frame_index )
1637
1665
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 :
1639
1668
torch .testing .assert_close (
1640
1669
beta_frame .data , ref_frame .data , rtol = 0 , atol = 0
1641
1670
)
0 commit comments