Skip to content

Commit

Permalink
Generate a test suite in fluster for H265 SHVC functionality set (#184)
Browse files Browse the repository at this point in the history
* Generate a test suite in fluster for H265 SHVC functionality set

* fixup! Add TODO comment in gen_jct_vc.py script.
  • Loading branch information
rsanchez87 authored Jul 30, 2024
1 parent cc9fb13 commit 56fc23e
Show file tree
Hide file tree
Showing 4 changed files with 605 additions and 19 deletions.
13 changes: 10 additions & 3 deletions fluster/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def find_by_ext(
) -> Optional[str]:
"""Return name by file extension"""
excludes = excludes or []
candidates = []

# Respect the priority for extensions
for ext in exts:
for subdir, _, files in os.walk(dest_dir):
for filename in files:
Expand All @@ -160,8 +160,15 @@ def find_by_ext(
excluded = True
break
if not excluded:
return filepath
return None
candidates.append(filepath)

# Prioritize files with 'L0' in the name only for JCT-VC-SHVC
for candidate in candidates:
if "L0" in candidate.upper():
return candidate

# If no file with 'L0' is found, return the first candidate
return candidates[0] if candidates else None


def find_by_ext_multiple(
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@ packages = ["fluster", "fluster.decoders"]
]
"share/fluster/test_suites/h264" = [
"test_suites/h264/JVT-AVC_V1.json",
"test_suites/h264/JVT-FR-EXT.json"
"test_suites/h264/JVT-FR-EXT.json",
"test_suites/h264/JVT-Professional_profiles_V1.json",
"test_suites/h264/JVT-SVC_V1.json"
]
"share/fluster/test_suites/h265" = [
"test_suites/h265/JCT-VC-3D-HEVC.json",
"test_suites/h265/JCT-VC-HEVC-V1.json",
"test_suites/h265/JCT-VC-MV-HEVC.json",
"test_suites/h265/JCT-VC-RExt.json",
"test_suites/h265/JCT-VC-SCC.json"
"test_suites/h265/JCT-VC-SCC.json",
"test_suites/h265/JCT-VC-SHVC.json"
]
"share/fluster/test_suites/h266" = [
"test_suites/h266/JVET-VVC_draft6.json",
Expand Down
44 changes: 30 additions & 14 deletions scripts/gen_jct_vc.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
".bin",
".bit",
)
MD5_EXTS = ("yuv_2.md5", "yuv.md5", ".md5", "md5.txt", "md5sum.txt")
MD5_EXTS = ("yuv_2.md5", "yuv.md5", ".md5", ".MD5", "md5.txt", "md5sum.txt")
MD5_EXCLUDES = (".bin.md5", "bit.md5")
RAW_EXTS = ("nogray.yuv", ".yuv", ".qcif")

Expand Down Expand Up @@ -123,6 +123,12 @@ def generate(self, download, jobs):
keep_file=True,
)

if "SHVC" in test_suite.name:
for test_vector in test_suite.test_vectors.values():
if "8layers" in test_vector.name.lower(): # 8LAYERS_QUALCOMM_1 not used in SHVC test suite
test_suite.test_vectors.pop(test_vector.name, None)
break

for test_vector in test_suite.test_vectors.values():
dest_dir = os.path.join(
test_suite.resources_dir, test_suite.name, test_vector.name
Expand Down Expand Up @@ -208,26 +214,26 @@ def _fill_checksum_h265(self, test_vector, dest_dir):
# f3e914fccdb820eac85f46642ea0e168 CCP_8bit_RExt_QCOM.gbr
regex = re.compile(r"([a-fA-F0-9]{{32,}}).*\.(yuv|rgb|gbr)")
lines = checksum_file.readlines()
# If we have a line like examples 4,5,6 anywhere in the file, prefer
# that.
if any((match := regex.match(line)) for line in lines):
test_vector.result = match.group(1)[:32].lower()
elif self.name == "RExt" or self.name == "MV-HEVC" or self.name == "SCC":
# If we can't match with the regex, note that these usually come
# with the checksum at the end
test_vector.result = lines[-1].split(" ")[0].split("\n")[0].lower()
# Filter out empty lines and lines that start with "#"
filtered_lines = [line.strip() for line in lines if line.strip() and not line.strip().startswith("#")]
# Prefer lines matching the regex pattern
match = next((regex.match(line) for line in filtered_lines if regex.match(line)), None)
if match:
test_vector.result = match.group(1).lower()
elif self.name in {"RExt", "MV-HEVC", "SCC", "SHVC"}:
# Handle special cases where checksum is at the end
test_vector.result = filtered_lines[-1].split(" ")[0].strip().lower()
else:
for line in lines:
if line.startswith(("#", "\n")):
continue
for line in filtered_lines:
if "=" in line:
test_vector.result = line.split("=")[-1].strip().lower()
else:
test_vector.result = line.split(" ")[0].split("\n")[0].lower()
test_vector.result = line.split(" ")[0].strip().lower()
break
# Assert that we have extracted a valid MD5 from the file
assert len(test_vector.result) == 32 and re.search(
r"^[a-fA-F0-9]{32}$", test_vector.result) is not None, f"{test_vector.result} is not a valid MD5 hash"
r"^[a-fA-F0-9]{32}$",
test_vector.result) is not None, f"{test_vector.result} is not a valid MD5 hash"


if __name__ == "__main__":
Expand Down Expand Up @@ -294,3 +300,13 @@ def _fill_checksum_h265(self, test_vector, dest_dir):
True
)
generator.generate(not args.skip_download, args.jobs)

# TODO see comment (https://fluendo.atlassian.net/browse/COM-10938?focusedCommentId=86998)
generator = JCTVCGenerator(
"SHVC",
"JCT-VC-SHVC",
Codec.H265,
"JCT-VC HEVC Scalable High Efficiency Video Coding Extension",
H265_URL,
)
generator.generate(not args.skip_download, args.jobs)
Loading

0 comments on commit 56fc23e

Please sign in to comment.