diff --git a/tools/ffmpeg.py b/tools/ffmpeg.py index 40a66c3..7fb96e3 100755 --- a/tools/ffmpeg.py +++ b/tools/ffmpeg.py @@ -73,19 +73,11 @@ def get_ref_md5(fn): class ConformanceRunner(TestRunner): def run(self): - if os.path.isfile(self.args.test_path): - self.__test_file() - else: - self.__test_dir() + self.__test_files(self.files) def add_args(self, parser): parser.add_argument("-t", "--threads", type=int, default=16) - def __test_file(self): - pss = self.__test(self.args.test_path) - print(basename(self.args.test_path) + " passed" if pss == PASSED else " failed") - return 0 - def __get_md5(self, input): cmd = self.args.ffmpeg_path + " -i " + input + " -vsync 0 -f md5 -" print(cmd) @@ -110,22 +102,22 @@ def __test(self, f): print("md5 mismatch ref = " + refmd5 + " md5 = " + md5) return FAILED - - def __submmit_files(self, executor, path): + def __submmit_files(self, executor, files): future_to_file = {} - file_list = sorted(self.list_files(path), key = lambda x: os.stat(x).st_size) - for f in file_list: + files = sorted(files, key=lambda x: os.stat(x).st_size) + for f in files: future_to_file[executor.submit(self.__test, f)] = f return future_to_file - - def __test_dir(self): + def __test_files(self, files): summary = [[], [], []] count = [0, 0, 0] - with concurrent.futures.ThreadPoolExecutor(max_workers=self.args.threads) as executor: - future_to_file = self.__submmit_files(executor, self.args.test_path) + with concurrent.futures.ThreadPoolExecutor( + max_workers=self.args.threads + ) as executor: + future_to_file = self.__submmit_files(executor, files) for future in concurrent.futures.as_completed(future_to_file): f = future_to_file[future] try: diff --git a/tools/perf.py b/tools/perf.py index c1e8f92..aceec37 100755 --- a/tools/perf.py +++ b/tools/perf.py @@ -31,8 +31,7 @@ class PerformanceRunner(TestRunner): def run(self): self.__app = self.__get_app() - files = self.list_files(self.args.test_path) - for f in files: + for f in self.files: self.__test(f) self.__print_summary() diff --git a/tools/threads.py b/tools/threads.py index ac8a471..1069ea1 100755 --- a/tools/threads.py +++ b/tools/threads.py @@ -31,8 +31,7 @@ class ThreadRunner(TestRunner): def run(self): self.__app = self.__get_app() - files = self.list_files(self.args.test_path) - for f in files: + for f in self.files: self.__test(f) self.__print_summary() diff --git a/tools/utils/runner.py b/tools/utils/runner.py index 7411fb2..6259657 100644 --- a/tools/utils/runner.py +++ b/tools/utils/runner.py @@ -27,7 +27,7 @@ class TestRunner: def check_input(self): parser = argparse.ArgumentParser(description="FFVVC test runner") - parser.add_argument("test_path", type=str) + parser.add_argument("test_path", type=str, nargs="+") parser.add_argument( "-f", "--ffmpeg-path", @@ -67,4 +67,11 @@ def list_files(path): fn = os.path.join(root, f) if TestRunner.is_candidiate(fn): l.append(fn) - return l \ No newline at end of file + return l + + @property + def files(self): + l = [] + for path in self.args.test_path: + l += TestRunner.list_files(path) + return l