Skip to content

Commit

Permalink
generate JVT-SVC_V1.json by L..., last changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rsanchez87 committed Jul 18, 2024
1 parent b3e80c0 commit 5118c14
Show file tree
Hide file tree
Showing 3 changed files with 1,047 additions and 119 deletions.
12 changes: 6 additions & 6 deletions scripts/gen_jvet_jctvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def handle_starttag(self, tag, attrs):
self.links.append(base_url + value)


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

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

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

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

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

generator = JVET_JCTVTGenerator(
generator = JVETJCTVTGenerator(
'draft6',
'JVET-VVC_draft6',
Codec.H266,
Expand Down
44 changes: 38 additions & 6 deletions scripts/gen_jvt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# License along with this library. If not, see <https://www.gnu.org/licenses/>.

import argparse
import copy
import re
from html.parser import HTMLParser
import os
import sys
Expand Down Expand Up @@ -93,6 +95,7 @@ def __init__(

def generate(self, download, jobs):
"""Generates the test suite and saves it to a file"""
new_test_vectors = []
output_filepath = os.path.join(self.suite_name + ".json")
test_suite = TestSuite(
output_filepath,
Expand Down Expand Up @@ -188,7 +191,9 @@ def generate(self, download, jobs):

if self.name != "Professional_profiles": # result md5 generated from h264_reference_decoder
if self.name == "SVC": # result md5 generated for different Lines (L0, L1...)
self._fill_checksum_h264_multiple(test_vector, dest_dir)
new_vectors = self._fill_checksum_h264_multiple(test_vector, dest_dir)
new_test_vectors.extend(new_vectors)
test_suite.test_vectors = {vector.name: vector for vector in new_test_vectors}
else:
self._fill_checksum_h264(test_vector, dest_dir)

Expand All @@ -204,11 +209,38 @@ def _fill_checksum_h264(test_vector, dest_dir):

@staticmethod
def _fill_checksum_h264_multiple(test_vector, dest_dir):
raw_files = utils.find_by_ext_multiple(dest_dir, RAW_EXTS)
if not raw_files:
raise Exception(f"RAW file not found in {dest_dir}")
for raw_file in raw_files:
test_vector.result = utils.file_checksum(raw_file)
def remove_r1_from_path(path):
parts = path.split('/')
if len(parts) >= 2:
parts[-2] = re.sub(r'-r1', '', parts[-2])
parts[-1] = re.sub(r'-r1', '', parts[-1])
return '/'.join(parts)

new_test_vectors = []

for suffix in [f"-L{i}" for i in range(8)]: # L0 ... L7
new_vector = copy.deepcopy(test_vector)
new_vector.name = test_vector.name + suffix

input_file_path = os.path.join(dest_dir, test_vector.name, f"{test_vector.name}{suffix}.264")
result_file_path = os.path.join(dest_dir, test_vector.name, f"{test_vector.name}{suffix}.yuv")

corrected_input_path = remove_r1_from_path(input_file_path)
corrected_result_path = remove_r1_from_path(result_file_path)

if os.path.exists(corrected_input_path) and os.path.exists(corrected_result_path):
new_vector.input_file = os.path.relpath(corrected_input_path, dest_dir)
new_vector.result = utils.file_checksum(corrected_result_path)

new_test_vectors.append(new_vector)

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__":
Expand Down
Loading

0 comments on commit 5118c14

Please sign in to comment.