From 4cbac086ed8fa1ad4c1f03024ac4e04a3adf92ed Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 14 Oct 2024 07:28:08 +0200 Subject: [PATCH] Add --diff option to create_histogram_summary.py for comparison to input --- scripts/create_histogram_summary.py | 32 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/scripts/create_histogram_summary.py b/scripts/create_histogram_summary.py index ae5ead4260..3e403a69a4 100644 --- a/scripts/create_histogram_summary.py +++ b/scripts/create_histogram_summary.py @@ -50,6 +50,13 @@ if __name__ == "__main__": "--evs", action="store_true", help="Parse using EVS 26.444 formats", + default=False, + ) + parser.add_argument( + "--diff", + action="store_true", + help="Use limits for diff scores", + default=False, ) args = parser.parse_args() csv_report = args.csv_report @@ -62,13 +69,20 @@ if __name__ == "__main__": else: FORMATS = IVAS_FORMATS CATEGORIES = IVAS_CATEGORIES - - limits_per_measure = { - "MLD": ("MLD", [0, 5, 10, math.inf]), - "DIFF": ("MAXIMUM ABS DIFF", [0, 1024, 16384, 32769]), - "SSNR": ("MIN_SSNR", [-math.inf, 0, 20, 40, 60, 100]), - "ODG": ("MIN_ODG", [-5, -4, -3, -2, -1, 0]), - } + if args.diff: + limits_per_measure = { + "MLD": ("MLD", [-math.inf, 0, 0.1, 0.2, 0.3, 0.4, math.inf]), + "DIFF": ("MAXIMUM ABS DIFF", [-32768, 0, 128, 256, 512, 32767]), + "SSNR": ("MIN_SSNR", [-math.inf, -0.4, -0.3, -0.2, -0.1, 0, math.inf]), + "ODG": ("MIN_ODG", [-5.0, -0.3, -0.2, -0.1, 0, math.inf]), + } + else: + limits_per_measure = { + "MLD": ("MLD", [0, 5, 10, math.inf]), + "DIFF": ("MAXIMUM ABS DIFF", [0, 1024, 16384, 32769]), + "SSNR": ("MIN_SSNR", [-math.inf, 0, 20, 40, 60, 100]), + "ODG": ("MIN_ODG", [-5, -4, -3, -2, -1, 0]), + } (measure_label, limits) = limits_per_measure[measure] # Load CSV report @@ -89,7 +103,7 @@ if __name__ == "__main__": f"{str(a)} -- {str(b)}" for (a, b) in zip(limits[0:-1], limits[1:]) ] + ["None"] # Zero difference is treated as a special category for MLD and MAXIMUM ABS DIFF - if measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF": + if (measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF") and not args.diff: limits_labels = ["0"] + limits_labels headerline = f"Format;Category;" + ";".join(limits_labels) + "\n" fp.write(headerline) @@ -107,7 +121,7 @@ if __name__ == "__main__": ] ] # Zero difference is treated as a special category for MLD and MAXIMUM ABS DIFF - if measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF": + if (measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF") and not args.diff: val = [ float(x) for x in values if x != "None" and x != "0" and x != "" ] -- GitLab