diff --git a/other/get_md5.ps1 b/other/attic/get_md5.ps1 similarity index 100% rename from other/get_md5.ps1 rename to other/attic/get_md5.ps1 diff --git a/other/get_md5.sh b/other/attic/get_md5.sh similarity index 100% rename from other/get_md5.sh rename to other/attic/get_md5.sh diff --git a/other/get_md5.py b/other/get_md5.py new file mode 100644 index 0000000000000000000000000000000000000000..e482dd3b3b1f51d71150d3f28a10e0df45c259c7 --- /dev/null +++ b/other/get_md5.py @@ -0,0 +1,78 @@ +#! /usr/bin/env python3 +# (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, +# Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., +# Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, +# Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other +# contributors to this repository. All Rights Reserved. + +# This software is protected by copyright law and by international treaties. +# The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, +# Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., +# Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, +# Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other +# contributors to this repository retain full ownership rights in their respective contributions in +# the software. This notice grants no license of any kind, including but not limited to patent +# license, nor is any license granted by implication, estoppel or otherwise. + +# Contributors are required to enter into the IVAS codec Public Collaboration agreement before making +# contributions. + +# This software is provided "AS IS", without any express or implied warranties. The software is in the +# development stage. It is intended exclusively for experts who have experience with such software and +# solely for the purpose of inspection. All implied warranties of non-infringement, merchantability +# and fitness for a particular purpose are hereby disclaimed and excluded. + +# Any dispute, controversy or claim arising under or in relation to providing this software shall be +# submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in +# accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and +# the United Nations Convention on Contracts on the International Sales of Goods. + +import argparse +from pathlib import Path +from hashlib import md5 +from collections import Counter + + +def get_hash_line_for_file(file: Path, experiment_dir: Path): + with open(file, "rb") as f: + hash = md5(f.read()).hexdigest() + + filepath = file.relative_to(experiment_dir) + # always print forward slashes even on windows to be able to diff the result files + hashline = f"{str(filepath.as_posix())} {hash}\n" + + return hashline + + +def main(experiment_dir, out_file): + wav_files = sorted(experiment_dir.glob("proc_output*/**/*c[0-9][0-9].wav")) + + hashlines = [get_hash_line_for_file(f, experiment_dir) for f in wav_files] + count = Counter([line.split()[-1] for line in hashlines]) + duplicates = [line for line in hashlines if count[line.split()[-1]] != 1] + + if len(duplicates) != 0: + print("Found duplicate hashes in these lines:") + for dup in duplicates: + print(dup) + + with open(out_file, "w") as f: + f.writelines(hashlines) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Cross-platform script for generating MD5 hashes of output files for the characterization testing experiments." + ) + parser.add_argument( + "experiment_dir", + type=Path, + help="Directory of the respective experiment (e.g. experiments/characterization/P800-12", + ) + parser.add_argument( + "out_file", type=Path, help="Output text file with filenames and Hashes" + ) + + args = parser.parse_args() + + main(args.experiment_dir, args.out_file)