Skip to content

Commit f1e2328

Browse files
committed
better name
1 parent bca6af3 commit f1e2328

7 files changed

+15
-12
lines changed

test/test_io.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def temp_video(num_frames, height, width, fps, lossless=False, video_codec=None,
6363

6464

6565
@pytest.mark.skipif(
66-
get_video_backend() != "pyav" and not io._HAS_VIDEO_OPT, reason="video_reader backend not available"
66+
get_video_backend() != "pyav" and not io._HAS_CPU_VIDEO_DECODER, reason="video_reader backend not available"
6767
)
6868
@pytest.mark.skipif(av is None, reason="PyAV unavailable")
6969
class TestVideo:
@@ -77,14 +77,14 @@ def test_write_read_video(self):
7777
assert_equal(data, lv)
7878
assert info["video_fps"] == 5
7979

80-
@pytest.mark.skipif(not io._HAS_VIDEO_OPT, reason="video_reader backend is not chosen")
80+
@pytest.mark.skipif(not io._HAS_CPU_VIDEO_DECODER, reason="video_reader backend is not chosen")
8181
def test_probe_video_from_file(self):
8282
with temp_video(10, 300, 300, 5) as (f_name, data):
8383
video_info = io._probe_video_from_file(f_name)
8484
assert pytest.approx(2, rel=0.0, abs=0.1) == video_info.video_duration
8585
assert pytest.approx(5, rel=0.0, abs=0.1) == video_info.video_fps
8686

87-
@pytest.mark.skipif(not io._HAS_VIDEO_OPT, reason="video_reader backend is not chosen")
87+
@pytest.mark.skipif(not io._HAS_CPU_VIDEO_DECODER, reason="video_reader backend is not chosen")
8888
def test_probe_video_from_memory(self):
8989
with temp_video(10, 300, 300, 5) as (f_name, data):
9090
with open(f_name, "rb") as fp:

test/test_video_reader.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from numpy.random import randint
1212
from pytest import approx
1313
from torchvision import set_video_backend
14-
from torchvision.io import _HAS_VIDEO_OPT
14+
from torchvision.io import _HAS_CPU_VIDEO_DECODER
1515

1616

1717
try:
@@ -263,7 +263,7 @@ def _get_video_tensor(video_dir, video_file):
263263

264264

265265
@pytest.mark.skipif(av is None, reason="PyAV unavailable")
266-
@pytest.mark.skipif(_HAS_VIDEO_OPT is False, reason="Didn't compile with ffmpeg")
266+
@pytest.mark.skipif(_HAS_CPU_VIDEO_DECODER is False, reason="Didn't compile with ffmpeg")
267267
class TestVideoReader:
268268
def check_separate_decoding_result(self, tv_result, config):
269269
"""check the decoding results from TorchVision decoder"""

test/test_videoapi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import torchvision
88
from pytest import approx
99
from torchvision.datasets.utils import download_url
10-
from torchvision.io import _HAS_VIDEO_OPT, VideoReader
10+
from torchvision.io import _HAS_CPU_VIDEO_DECODER, VideoReader
1111

1212

1313
# WARNING: these tests have been skipped forever on the CI because the video ops
@@ -62,7 +62,7 @@ def fate(name, path="."):
6262
}
6363

6464

65-
@pytest.mark.skipif(_HAS_VIDEO_OPT is False, reason="Didn't compile with ffmpeg")
65+
@pytest.mark.skipif(_HAS_CPU_VIDEO_DECODER is False, reason="Didn't compile with ffmpeg")
6666
class TestVideoApi:
6767
@pytest.mark.skipif(av is None, reason="PyAV unavailable")
6868
@pytest.mark.parametrize("test_video", test_videos.keys())

torchvision/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def set_video_backend(backend):
7272
global _video_backend
7373
if backend not in ["pyav", "video_reader", "cuda"]:
7474
raise ValueError("Invalid video backend '%s'. Options are 'pyav', 'video_reader' and 'cuda'" % backend)
75-
if backend == "video_reader" and not io._HAS_VIDEO_OPT:
75+
if backend == "video_reader" and not io._HAS_CPU_VIDEO_DECODER:
7676
# TODO: better messages
7777
message = "video_reader video backend is not available. Please compile torchvision from source and try again"
7878
raise RuntimeError(message)

torchvision/io/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
_HAS_GPU_VIDEO_DECODER = False
1111

1212
from ._video_opt import (
13+
_HAS_CPU_VIDEO_DECODER,
1314
_HAS_VIDEO_OPT,
1415
_probe_video_from_file,
1516
_probe_video_from_memory,
@@ -49,6 +50,7 @@
4950
"_read_video_from_memory",
5051
"_read_video_timestamps_from_memory",
5152
"_probe_video_from_memory",
53+
"_HAS_CPU_VIDEO_DECODER",
5254
"_HAS_VIDEO_OPT",
5355
"_HAS_GPU_VIDEO_DECODER",
5456
"_read_video_clip_from_memory",

torchvision/io/_video_opt.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010

1111
try:
1212
_load_library("video_reader")
13-
_HAS_VIDEO_OPT = True
13+
_HAS_CPU_VIDEO_DECODER = True
1414
except (ImportError, OSError):
15-
_HAS_VIDEO_OPT = False
15+
_HAS_CPU_VIDEO_DECODER = False
1616

17+
_HAS_VIDEO_OPT = _HAS_CPU_VIDEO_DECODER # For BC
1718
default_timebase = Fraction(0, 1)
1819

1920

torchvision/io/video_reader.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
from ..utils import _log_api_usage_once
99

10-
from ._video_opt import _HAS_VIDEO_OPT
10+
from ._video_opt import _HAS_CPU_VIDEO_DECODER
1111

12-
if _HAS_VIDEO_OPT:
12+
if _HAS_CPU_VIDEO_DECODER:
1313

1414
def _has_video_opt() -> bool:
1515
return True

0 commit comments

Comments
 (0)