Skip to content

Commit 8e7e90d

Browse files
committed
feat: extend the parsing of yuv extension types, default to 8bit when bitdepth is missing
1 parent 9c2041c commit 8e7e90d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compressai/datasets/rawvideo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ def get_raw_video_file_info(filename: str) -> Dict[str, Any]:
143143
framerate_pattern = r"(?P<framerate>[\d\.]+)(?:Hz|fps)"
144144
bitdepth_pattern = r"(?P<bitdepth>\d+)bit"
145145
formats = "|".join(video_formats.keys())
146-
format_pattern = (
147-
rf"(?P<format>{formats})(?:[p_]?(?P<bitdepth2>\d+)(?P<endianness>LE|BE))?"
148-
)
146+
format_pattern = rf"(?P<format>{formats})(?:[p_]?(?:(?P<bitdepth2>\d+)|(?P<chroma_sub>\d{3}[p]))?(?P<endianness>LE|BE))?"
149147
extension_pattern = rf"(?P<extension>{'|'.join(file_extensions)})"
150148
cut_pattern = "([0-9]+)-([0-9]+)"
151149

@@ -166,6 +164,9 @@ def get_raw_video_file_info(filename: str) -> Dict[str, Any]:
166164
if not info:
167165
return {}
168166

167+
if "bitdepth" not in info:
168+
info["bitdepth"] = "8"
169+
169170
if info["bitdepth"] and info["bitdepth2"] and info["bitdepth"] != info["bitdepth2"]:
170171
raise ValueError(f'Filename "{filename}" specifies bit-depth twice.')
171172

0 commit comments

Comments
 (0)