Loading scripts/get_loudness_data.py +14 −12 Original line number Diff line number Diff line #!/usr/bin/env python3 import argparse import pandas as pd import json import logging import os import platform import re import sys import json import platform from pathlib import Path import warnings from concurrent.futures import ProcessPoolExecutor, as_completed from pathlib import Path import pandas as pd sys.path.append("./ivas-processing-scripts") from ivas_processing_scripts.audiotools.wrappers.bs1770 import get_loudness from ivas_processing_scripts.audiotools.audio import fromfile from ivas_processing_scripts.audiotools.wrappers.bs1770 import get_loudness from ivas_processing_scripts.utils import progressbar_update logging.basicConfig(level=logging.WARNING) warnings.filterwarnings("ignore", category=UserWarning) if os.environ.get("CI") or not sys.stdout.isatty(): sys.stdout.reconfigure(line_buffering=True) Loading Loading @@ -73,6 +77,9 @@ def get_metadata_from_outfile_name(outfile, infile_stem): match = re.search(PATTERN_BITRATE, mode_string) assert match is not None bitrate_str, dtx, bandwidth = match.groups() if bitrate_str == "all": bitrate = 132_512 # special value, will be replaced in plots else: bitrate = float(bitrate_str.replace("_", ".")) return outformat, bitrate, dtx is not None, bandwidth Loading Loading @@ -109,9 +116,7 @@ def process_output_file(outfile, infile, format, input_loudness, input_loudness_ "-g", str(scale_factor), "-o", str( outfile.with_stem(f"{outfile.stem}_scaled_{scale_factor:3.2f}") ), str(outfile.with_stem(f"{outfile.stem}_scaled_{scale_factor:3.2f}")), ] ) Loading Loading @@ -203,9 +208,6 @@ def main(args): if f.stem.startswith(infile.stem) ] print(f"Directory {output_folder}") print(f"Found output files {' '.join([str(f) for f in output_files])}") for outfile in output_files: tasks.append( (outfile, infile, format, input_loudness, input_loudness_format) Loading scripts/parse_loudness_data.py +25 −18 Original line number Diff line number Diff line #!/usr/bin/env python3 import matplotlib.pyplot as plt import pandas as pd import numpy as np import os import sys from pathlib import Path sys.path.append("./ivas-processing-scripts") import matplotlib.pyplot as plt import numpy as np import pandas as pd from ivas_processing_scripts.utils import progressbar_update if os.environ.get("CI") or not sys.stdout.isatty(): Loading @@ -27,6 +27,7 @@ VALID_BITRATES_IVAS = [ 256, 384, 512, 132_512, # ratesw "ball" ] LOUDNESS_DATA_FILENAME = "loudness.csv" Loading Loading @@ -57,6 +58,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): # bandwidth values bandwidths = filtered_df["bandwidth"].unique() bandwidths = sorted(bandwidths, reverse=True) # check for DTX dtx_values = filtered_df["dtx"].unique() Loading @@ -74,8 +76,8 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): ax.axhspan( input_loudness - 1, input_loudness + 1, color="xkcd:palegreen", alpha=0.2, color="xkcd:green", alpha=0.1, zorder=0, ) Loading @@ -84,14 +86,14 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): input_loudness + 1, input_loudness + 3, color="xkcd:yellow", alpha=0.2, alpha=0.1, zorder=0, ) ax.axhspan( input_loudness - 3, input_loudness - 1, color="xkcd:yellow", alpha=0.2, alpha=0.1, zorder=0, ) Loading @@ -100,23 +102,23 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): input_loudness + 3, input_loudness + 6, color="xkcd:orange", alpha=0.2, alpha=0.1, zorder=0, ) ax.axhspan( input_loudness - 6, input_loudness - 3, color="xkcd:orange", alpha=0.2, alpha=0.1, zorder=0, ) # red beyond ±6 LKFS ax.axhspan( input_loudness + 6, y_max, color="xkcd:crimson", alpha=0.2, zorder=0 input_loudness + 6, y_max, color="xkcd:crimson", alpha=0.1, zorder=0 ) ax.axhspan( y_min, input_loudness - 6, color="xkcd:crimson", alpha=0.2, zorder=0 y_min, input_loudness - 6, color="xkcd:crimson", alpha=0.1, zorder=0 ) legend_added = {True: False, False: False} Loading @@ -135,7 +137,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): if y_val > y_max: ax.scatter( x_pos, y_max - 0.3, y_max - 0.75, marker="^", s=150, color="red", Loading @@ -146,7 +148,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): ) ax.text( x_pos, y_max - 0.8, y_max - 1.5, f"{y_val:.1f}", ha="center", va="top", Loading @@ -162,7 +164,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): elif y_val < y_min: ax.scatter( x_pos, y_min + 0.3, y_min + 0.75, marker="v", s=150, color="red", Loading @@ -173,7 +175,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): ) ax.text( x_pos, y_min + 0.8, y_min + 1.5, f"{y_val:.1f}", ha="center", va="bottom", Loading @@ -188,6 +190,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): ) else: marker = "x" if dtx_val else "o" color = "tab:orange" if dtx_val else "tab:blue" label = None if show_legend and not legend_added[dtx_val]: label = f"dtx={dtx_val}" Loading @@ -198,6 +201,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): y_val, label=label, marker=marker, color=color, s=80, alpha=0.7, zorder=3, Loading @@ -208,7 +212,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): label_input = "Input Loudness" if show_legend else None ax.axhline( y=input_loudness, color="red", color="xkcd:grey", linestyle="--", linewidth=2, alpha=0.7, Loading @@ -218,7 +222,10 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): ax.set_xticks(range(len(bitrates))) ax.set_xticklabels( [int(br) if br == int(br) else round(br, 2) for br in bitrates], [ "ratesw all" if br == 132512 else int(br) if br == int(br) else round(br, 2) for br in bitrates ], rotation=45, ha="right", ) Loading Loading
scripts/get_loudness_data.py +14 −12 Original line number Diff line number Diff line #!/usr/bin/env python3 import argparse import pandas as pd import json import logging import os import platform import re import sys import json import platform from pathlib import Path import warnings from concurrent.futures import ProcessPoolExecutor, as_completed from pathlib import Path import pandas as pd sys.path.append("./ivas-processing-scripts") from ivas_processing_scripts.audiotools.wrappers.bs1770 import get_loudness from ivas_processing_scripts.audiotools.audio import fromfile from ivas_processing_scripts.audiotools.wrappers.bs1770 import get_loudness from ivas_processing_scripts.utils import progressbar_update logging.basicConfig(level=logging.WARNING) warnings.filterwarnings("ignore", category=UserWarning) if os.environ.get("CI") or not sys.stdout.isatty(): sys.stdout.reconfigure(line_buffering=True) Loading Loading @@ -73,6 +77,9 @@ def get_metadata_from_outfile_name(outfile, infile_stem): match = re.search(PATTERN_BITRATE, mode_string) assert match is not None bitrate_str, dtx, bandwidth = match.groups() if bitrate_str == "all": bitrate = 132_512 # special value, will be replaced in plots else: bitrate = float(bitrate_str.replace("_", ".")) return outformat, bitrate, dtx is not None, bandwidth Loading Loading @@ -109,9 +116,7 @@ def process_output_file(outfile, infile, format, input_loudness, input_loudness_ "-g", str(scale_factor), "-o", str( outfile.with_stem(f"{outfile.stem}_scaled_{scale_factor:3.2f}") ), str(outfile.with_stem(f"{outfile.stem}_scaled_{scale_factor:3.2f}")), ] ) Loading Loading @@ -203,9 +208,6 @@ def main(args): if f.stem.startswith(infile.stem) ] print(f"Directory {output_folder}") print(f"Found output files {' '.join([str(f) for f in output_files])}") for outfile in output_files: tasks.append( (outfile, infile, format, input_loudness, input_loudness_format) Loading
scripts/parse_loudness_data.py +25 −18 Original line number Diff line number Diff line #!/usr/bin/env python3 import matplotlib.pyplot as plt import pandas as pd import numpy as np import os import sys from pathlib import Path sys.path.append("./ivas-processing-scripts") import matplotlib.pyplot as plt import numpy as np import pandas as pd from ivas_processing_scripts.utils import progressbar_update if os.environ.get("CI") or not sys.stdout.isatty(): Loading @@ -27,6 +27,7 @@ VALID_BITRATES_IVAS = [ 256, 384, 512, 132_512, # ratesw "ball" ] LOUDNESS_DATA_FILENAME = "loudness.csv" Loading Loading @@ -57,6 +58,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): # bandwidth values bandwidths = filtered_df["bandwidth"].unique() bandwidths = sorted(bandwidths, reverse=True) # check for DTX dtx_values = filtered_df["dtx"].unique() Loading @@ -74,8 +76,8 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): ax.axhspan( input_loudness - 1, input_loudness + 1, color="xkcd:palegreen", alpha=0.2, color="xkcd:green", alpha=0.1, zorder=0, ) Loading @@ -84,14 +86,14 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): input_loudness + 1, input_loudness + 3, color="xkcd:yellow", alpha=0.2, alpha=0.1, zorder=0, ) ax.axhspan( input_loudness - 3, input_loudness - 1, color="xkcd:yellow", alpha=0.2, alpha=0.1, zorder=0, ) Loading @@ -100,23 +102,23 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): input_loudness + 3, input_loudness + 6, color="xkcd:orange", alpha=0.2, alpha=0.1, zorder=0, ) ax.axhspan( input_loudness - 6, input_loudness - 3, color="xkcd:orange", alpha=0.2, alpha=0.1, zorder=0, ) # red beyond ±6 LKFS ax.axhspan( input_loudness + 6, y_max, color="xkcd:crimson", alpha=0.2, zorder=0 input_loudness + 6, y_max, color="xkcd:crimson", alpha=0.1, zorder=0 ) ax.axhspan( y_min, input_loudness - 6, color="xkcd:crimson", alpha=0.2, zorder=0 y_min, input_loudness - 6, color="xkcd:crimson", alpha=0.1, zorder=0 ) legend_added = {True: False, False: False} Loading @@ -135,7 +137,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): if y_val > y_max: ax.scatter( x_pos, y_max - 0.3, y_max - 0.75, marker="^", s=150, color="red", Loading @@ -146,7 +148,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): ) ax.text( x_pos, y_max - 0.8, y_max - 1.5, f"{y_val:.1f}", ha="center", va="top", Loading @@ -162,7 +164,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): elif y_val < y_min: ax.scatter( x_pos, y_min + 0.3, y_min + 0.75, marker="v", s=150, color="red", Loading @@ -173,7 +175,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): ) ax.text( x_pos, y_min + 0.8, y_min + 1.5, f"{y_val:.1f}", ha="center", va="bottom", Loading @@ -188,6 +190,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): ) else: marker = "x" if dtx_val else "o" color = "tab:orange" if dtx_val else "tab:blue" label = None if show_legend and not legend_added[dtx_val]: label = f"dtx={dtx_val}" Loading @@ -198,6 +201,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): y_val, label=label, marker=marker, color=color, s=80, alpha=0.7, zorder=3, Loading @@ -208,7 +212,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): label_input = "Input Loudness" if show_legend else None ax.axhline( y=input_loudness, color="red", color="xkcd:grey", linestyle="--", linewidth=2, alpha=0.7, Loading @@ -218,7 +222,10 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): ax.set_xticks(range(len(bitrates))) ax.set_xticklabels( [int(br) if br == int(br) else round(br, 2) for br in bitrates], [ "ratesw all" if br == 132512 else int(br) if br == int(br) else round(br, 2) for br in bitrates ], rotation=45, ha="right", ) Loading