Loading scripts/get_loudness_data.py +3 −1 Original line number Diff line number Diff line Loading @@ -280,6 +280,8 @@ def main(args): f for f in output_folder.glob("*.dec.*.wav") if f.stem.startswith(infile.stem) # avoid prefix matches to the glob by ensuring the pattern matches and re.search(pattern, f.stem) ] for outfile in output_files: Loading Loading @@ -322,7 +324,7 @@ def main(args): progressbar_update(0, total, width=50) with ProcessPoolExecutor(16) as executor: with ProcessPoolExecutor() as executor: # Submit all tasks futures = { executor.submit(process_output_file, *task): task[0] for task in tasks Loading scripts/parse_loudness_data.py +61 −33 Original line number Diff line number Diff line #!/usr/bin/env python3 import os import sys from concurrent.futures import ProcessPoolExecutor, as_completed from pathlib import Path import matplotlib matplotlib.use("Agg") # Use non-interactive backend for parallel processing import matplotlib.pyplot as plt import numpy as np import pandas as pd Loading Loading @@ -48,12 +52,6 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): if in_fmt is not None: filtered_df = filtered_df[filtered_df["format"] == in_fmt] # get input loudness if not filtered_df.empty: input_loudness = filtered_df["input_loudness"].iloc[0] else: input_loudness = None y_min, y_max = -36, -16 y_ticks = np.arange(y_min, y_max + 5, 5) Loading @@ -76,6 +74,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): ax = axes[idx] bw_data = filtered_df[filtered_df["bandwidth"] == bw] input_loudness = float(bw_data["input_loudness"].unique()[0]) if input_loudness is not None: # highlight ±1 LKFS green ax.axhspan( Loading Loading @@ -261,6 +260,25 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): plt.close() def process_format_pair(args): """Worker function to process a single input/output format pair.""" df, in_fmt, out_fmt, plots_dir = args # create dir for out format passthru = plots_dir.joinpath("passthrough") out_dir = ( passthru if in_fmt.casefold() == out_fmt.casefold() else plots_dir.joinpath(out_fmt.upper()) ) out_dir.mkdir(exist_ok=True, parents=True) plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir) return (in_fmt, out_fmt) if __name__ == "__main__": df = pd.read_csv(LOUDNESS_DATA_FILENAME) df = df[df["bitrate"].isin(VALID_BITRATES_IVAS)] Loading @@ -268,23 +286,33 @@ df = df[df["bitrate"].isin(VALID_BITRATES_IVAS)] plots_dir = Path(__file__).parent.parent.joinpath("plots") plots_dir.mkdir(parents=True, exist_ok=True) passthru = plots_dir.joinpath("passthrough") passthru.mkdir(exist_ok=True) # prepare all tasks tasks = [] for in_fmt in df["format"].unique(): out_fmts = df[df["format"] == in_fmt]["outformat"].unique() print(f"Processing {in_fmt}: ") progressbar_update(0, len(out_fmts), width=50) for idx, out_fmt in enumerate(out_fmts): # create dir for out format out_dir = ( passthru if in_fmt.casefold() == out_fmt.casefold() else plots_dir.joinpath(out_fmt.upper()) ) out_dir.mkdir(exist_ok=True) plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir) progressbar_update(idx + 1, len(out_fmts), width=50) print() for out_fmt in out_fmts: tasks.append((df, in_fmt, out_fmt, plots_dir)) total_tasks = len(tasks) print(f"Processing {total_tasks} format combinations...") # process in parallel completed = 0 progressbar_update(0, total_tasks, width=50) with ProcessPoolExecutor() as executor: futures = {executor.submit(process_format_pair, task): task for task in tasks} for future in as_completed(futures): try: in_fmt, out_fmt = future.result() completed += 1 progressbar_update(completed, total_tasks, width=50) except Exception as e: task = futures[future] print(f"\nError processing {task[1]} -> {task[2]}: {e}") completed += 1 progressbar_update(completed, total_tasks, width=50) print(f"✅ Processed {len(tasks)} format pairs successfully") Loading
scripts/get_loudness_data.py +3 −1 Original line number Diff line number Diff line Loading @@ -280,6 +280,8 @@ def main(args): f for f in output_folder.glob("*.dec.*.wav") if f.stem.startswith(infile.stem) # avoid prefix matches to the glob by ensuring the pattern matches and re.search(pattern, f.stem) ] for outfile in output_files: Loading Loading @@ -322,7 +324,7 @@ def main(args): progressbar_update(0, total, width=50) with ProcessPoolExecutor(16) as executor: with ProcessPoolExecutor() as executor: # Submit all tasks futures = { executor.submit(process_output_file, *task): task[0] for task in tasks Loading
scripts/parse_loudness_data.py +61 −33 Original line number Diff line number Diff line #!/usr/bin/env python3 import os import sys from concurrent.futures import ProcessPoolExecutor, as_completed from pathlib import Path import matplotlib matplotlib.use("Agg") # Use non-interactive backend for parallel processing import matplotlib.pyplot as plt import numpy as np import pandas as pd Loading Loading @@ -48,12 +52,6 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): if in_fmt is not None: filtered_df = filtered_df[filtered_df["format"] == in_fmt] # get input loudness if not filtered_df.empty: input_loudness = filtered_df["input_loudness"].iloc[0] else: input_loudness = None y_min, y_max = -36, -16 y_ticks = np.arange(y_min, y_max + 5, 5) Loading @@ -76,6 +74,7 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): ax = axes[idx] bw_data = filtered_df[filtered_df["bandwidth"] == bw] input_loudness = float(bw_data["input_loudness"].unique()[0]) if input_loudness is not None: # highlight ±1 LKFS green ax.axhspan( Loading Loading @@ -261,6 +260,25 @@ def plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir): plt.close() def process_format_pair(args): """Worker function to process a single input/output format pair.""" df, in_fmt, out_fmt, plots_dir = args # create dir for out format passthru = plots_dir.joinpath("passthrough") out_dir = ( passthru if in_fmt.casefold() == out_fmt.casefold() else plots_dir.joinpath(out_fmt.upper()) ) out_dir.mkdir(exist_ok=True, parents=True) plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir) return (in_fmt, out_fmt) if __name__ == "__main__": df = pd.read_csv(LOUDNESS_DATA_FILENAME) df = df[df["bitrate"].isin(VALID_BITRATES_IVAS)] Loading @@ -268,23 +286,33 @@ df = df[df["bitrate"].isin(VALID_BITRATES_IVAS)] plots_dir = Path(__file__).parent.parent.joinpath("plots") plots_dir.mkdir(parents=True, exist_ok=True) passthru = plots_dir.joinpath("passthrough") passthru.mkdir(exist_ok=True) # prepare all tasks tasks = [] for in_fmt in df["format"].unique(): out_fmts = df[df["format"] == in_fmt]["outformat"].unique() print(f"Processing {in_fmt}: ") progressbar_update(0, len(out_fmts), width=50) for idx, out_fmt in enumerate(out_fmts): # create dir for out format out_dir = ( passthru if in_fmt.casefold() == out_fmt.casefold() else plots_dir.joinpath(out_fmt.upper()) ) out_dir.mkdir(exist_ok=True) plot_loudness_by_bandwidth(df, in_fmt, out_fmt, out_dir) progressbar_update(idx + 1, len(out_fmts), width=50) print() for out_fmt in out_fmts: tasks.append((df, in_fmt, out_fmt, plots_dir)) total_tasks = len(tasks) print(f"Processing {total_tasks} format combinations...") # process in parallel completed = 0 progressbar_update(0, total_tasks, width=50) with ProcessPoolExecutor() as executor: futures = {executor.submit(process_format_pair, task): task for task in tasks} for future in as_completed(futures): try: in_fmt, out_fmt = future.result() completed += 1 progressbar_update(completed, total_tasks, width=50) except Exception as e: task = futures[future] print(f"\nError processing {task[1]} -> {task[2]}: {e}") completed += 1 progressbar_update(completed, total_tasks, width=50) print(f"✅ Processed {len(tasks)} format pairs successfully")