Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rsanchez87 committed Jul 22, 2024
1 parent 5118c14 commit bd4ac1a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 88 deletions.
74 changes: 37 additions & 37 deletions fluster/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,43 +141,6 @@ def normalize_path(path: str) -> str:
return path


def _linux_user_data_dir(appname: str) -> str:
"""Return data directory tied to the user"""
path = os.environ.get("XDG_DATA_HOME", "")
if not path.strip():
path = os.path.expanduser("~/.local/share")
return os.path.join(path, appname)


def _linux_site_data_dirs(appname: str) -> List[str]:
"""Return data directory shared by users"""
path = os.environ.get("XDG_DATA_DIRS", "")
if not path.strip():
path = "/usr/local/share:/usr/share"
paths = path.split(os.pathsep)
return [os.path.join(p, appname) for p in paths]


def _win_user_data_dir(appname: str) -> str:
"""Return data directory"""
path = os.path.expanduser(r"~\AppData\Local")
return os.path.join(path, appname)


def _win_site_data_dirs(appname: str) -> List[str]:
"""Return data directory shared by users"""
# On Windows always user_data_dir
return [_win_user_data_dir(appname)]


if sys.platform == "win32":
site_data_dirs = _win_site_data_dirs
user_data_dir = _win_user_data_dir
else:
site_data_dirs = _linux_site_data_dirs
user_data_dir = _linux_user_data_dir


def find_by_ext(
dest_dir: str, exts: List[str], excludes: Optional[List[str]] = None
) -> Optional[str]:
Expand Down Expand Up @@ -223,3 +186,40 @@ def find_by_ext_multiple(
if not excluded:
found_files.append(filepath)
return found_files


def _linux_user_data_dir(appname: str) -> str:
"""Return data directory tied to the user"""
path = os.environ.get("XDG_DATA_HOME", "")
if not path.strip():
path = os.path.expanduser("~/.local/share")
return os.path.join(path, appname)


def _linux_site_data_dirs(appname: str) -> List[str]:
"""Return data directory shared by users"""
path = os.environ.get("XDG_DATA_DIRS", "")
if not path.strip():
path = "/usr/local/share:/usr/share"
paths = path.split(os.pathsep)
return [os.path.join(p, appname) for p in paths]


def _win_user_data_dir(appname: str) -> str:
"""Return data directory"""
path = os.path.expanduser(r"~\AppData\Local")
return os.path.join(path, appname)


def _win_site_data_dirs(appname: str) -> List[str]:
"""Return data directory shared by users"""
# On Windows always user_data_dir
return [_win_user_data_dir(appname)]


if sys.platform == "win32":
site_data_dirs = _win_site_data_dirs
user_data_dir = _win_user_data_dir
else:
site_data_dirs = _linux_site_data_dirs
user_data_dir = _linux_user_data_dir
17 changes: 6 additions & 11 deletions scripts/gen_jvet_jctvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
BITSTREAM_EXTS = (
".bin",
".bit",
".jvc",
".jsv",
".jvt",
".avc",
".26l",
)
MD5_EXTS = ("yuv_2.md5", "yuv.md5", ".md5", "md5.txt", "md5sum.txt")
MD5_EXCLUDES = (".bin.md5", "bit.md5")
Expand Down Expand Up @@ -72,7 +67,7 @@ def handle_starttag(self, tag, attrs):
self.links.append(base_url + value)


class JVETJCTVTGenerator:
class JVETJCTVCGenerator:
"""Generates a test suite from the conformance bitstreams"""

def __init__(
Expand Down Expand Up @@ -255,7 +250,7 @@ def _fill_checksum_h265(self, test_vector, dest_dir):
default=2 * multiprocessing.cpu_count(),
)
args = parser.parse_args()
generator = JVETJCTVTGenerator(
generator = JVETJCTVCGenerator(
"HEVC_v1",
"JCT-VC-HEVC_V1",
Codec.H265,
Expand All @@ -264,7 +259,7 @@ def _fill_checksum_h265(self, test_vector, dest_dir):
)
generator.generate(not args.skip_download, args.jobs)

generator = JVETJCTVTGenerator(
generator = JVETJCTVCGenerator(
"RExt",
"JCT-VC-RExt",
Codec.H265,
Expand All @@ -274,7 +269,7 @@ def _fill_checksum_h265(self, test_vector, dest_dir):
)
generator.generate(not args.skip_download, args.jobs)

generator = JVETJCTVTGenerator(
generator = JVETJCTVCGenerator(
"SCC",
"JCT-VC-SCC",
Codec.H265,
Expand All @@ -284,7 +279,7 @@ def _fill_checksum_h265(self, test_vector, dest_dir):
)
generator.generate(not args.skip_download, args.jobs)

generator = JVETJCTVTGenerator(
generator = JVETJCTVCGenerator(
"MV-HEVC",
"JCT-VC-MV-HEVC",
Codec.H265,
Expand All @@ -294,7 +289,7 @@ def _fill_checksum_h265(self, test_vector, dest_dir):
)
generator.generate(not args.skip_download, args.jobs)

generator = JVETJCTVTGenerator(
generator = JVETJCTVCGenerator(
'draft6',
'JVET-VVC_draft6',
Codec.H266,
Expand Down
42 changes: 2 additions & 40 deletions scripts/gen_jvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
BASE_URL = "https://www.itu.int/"
H264_URL = BASE_URL + "wftp3/av-arch/jvt-site/draft_conformance/"
BITSTREAM_EXTS = (
".bin",
".bit",
".264",
".h264",
".jvc",
".jsv",
".jvt",
".avc",
Expand Down Expand Up @@ -116,9 +111,6 @@ def generate(self, download, jobs):
# The first item in the AVCv1 list is a readme file
if "00readme_H" in url:
continue
elif "replaced" in url:
# This is in HEVC-SHVC, we don't want that.
continue
file_url = os.path.basename(url)
name = os.path.splitext(file_url)[0]
file_input = f"{name}.bin"
Expand Down Expand Up @@ -151,9 +143,7 @@ def generate(self, download, jobs):
if not test_vector.input_file:
raise Exception(f"Bitstream file not found in {dest_dir}")
test_vector.source_checksum = utils.file_checksum(dest_path)
if "main10" in test_vector.name.lower():
test_vector.output_format = OutputFormat.YUV420P10LE
elif self.use_ffprobe:
if self.use_ffprobe:
ffprobe = utils.normalize_binary_cmd('ffprobe')
command = [ffprobe, '-v', 'error', '-select_streams', 'v:0',
'-show_entries', 'stream=pix_fmt', '-of',
Expand All @@ -165,29 +155,7 @@ def generate(self, download, jobs):
try:
test_vector.output_format = OutputFormat[pix_fmt.upper()]
except KeyError as e:
exceptions = {
# Feature: Test unequal luma and chroma bitdepth
# setting. The luma bitdepth is higher than the chroma
# bitdepth. Luma is 12bit, chroma is 8bit. Considering
# 12bit.
"Bitdepth_A_RExt_Sony_1": OutputFormat.YUV444P12LE,
# Same as above, but the chroma is 12bit and luma is 8bit.
"Bitdepth_B_RExt_Sony_1": OutputFormat.YUV444P12LE,
# Rest is taken by examining the error displayed by ffprobe, e.g.:
# The following bit-depths are currently specified: 8,
# 9, 10 and 12 bits, chroma_format_idc is 3, depth is 16
"EXTPREC_MAIN_444_16_INTRA_10BIT_RExt_Sony_1": OutputFormat.YUV444P16LE,
"EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_16BIT_RExt_Sony_1": OutputFormat.YUV444P16LE,
"EXTPREC_MAIN_444_16_INTRA_16BIT_RExt_Sony_1": OutputFormat.YUV444P16LE,
"GENERAL_16b_400_RExt_Sony_1": OutputFormat.GRAY16LE,
"GENERAL_16b_444_highThroughput_RExt_Sony_2": OutputFormat.YUV444P16LE,
"GENERAL_16b_444_RExt_Sony_2": OutputFormat.YUV444P16LE,
"WAVETILES_RExt_Sony_2": OutputFormat.YUV444P16LE
}
if test_vector.name in exceptions.keys():
test_vector.output_format = exceptions[test_vector.name]
else:
raise e
raise e

if self.name != "Professional_profiles": # result md5 generated from h264_reference_decoder
if self.name == "SVC": # result md5 generated for different Lines (L0, L1...)
Expand Down Expand Up @@ -236,12 +204,6 @@ def remove_r1_from_path(path):

return new_test_vectors

@staticmethod
def _check_path(path):
parts = path.split(os.sep)
unique_parts = parts[:3] + list(dict.fromkeys(parts[3:]))
return os.sep.join(unique_parts)


if __name__ == "__main__":
parser = argparse.ArgumentParser()
Expand Down

0 comments on commit bd4ac1a

Please sign in to comment.