Commit 85747dc6 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch 'main' of forge.3gpp.org:ivas-codec-pc/ivas-codec into...

Merge branch 'main' of forge.3gpp.org:ivas-codec-pc/ivas-codec into 935-msan-error-in-sba-decoding-to-binaural_room_reverb
parents e7aca5a2 4e02d750
Loading
Loading
Loading
Loading
Loading
+31 −20
Original line number Diff line number Diff line
@@ -515,7 +515,8 @@ renderer-smoke-test:
  stage: test
  script:
    - make -j IVAS_rend
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py
    - testcase_timeout=60
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout
  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results"
    expire_in: 1 week
@@ -537,7 +538,8 @@ renderer-asan:
  script:
    - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true
    - cmake --build cmake-build -- -j
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py
    - testcase_timeout=180
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout

  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results"
@@ -560,7 +562,8 @@ renderer-msan:
  script:
    - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=msan  -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true
    - cmake --build cmake-build -- -j
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py
    - testcase_timeout=180
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout

  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results"
@@ -583,7 +586,8 @@ renderer-usan:
  script:
    - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=usan  -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true
    - cmake --build cmake-build -- -j
    - UBSAN_OPTIONS=suppressions=scripts/ubsan.supp,report_error_type=1,log_path=usan_log_catchall python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py
    - testcase_timeout=180
    - UBSAN_OPTIONS=suppressions=scripts/ubsan.supp,report_error_type=1,log_path=usan_log_catchall python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout
    - grep_exit_code=0
    - touch usan_log_empty # Creates an empty file, this is to avoid "grep: usan_log_*: No such file or directory" in case no USAN failures are reported from pytest
    - grep UndefinedBehaviorSanitizer usan_log_* || grep_exit_code=$?
@@ -625,13 +629,14 @@ renderer-pytest-on-merge-request:
    - if [ $ref_using_main == 0 ]; then git checkout $source_branch_commit_sha; fi

    - exit_code=0
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_ref || exit_code=$?
    - testcase_timeout=60
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$?

    ### Run test using branch scripts and input
    - if [ $ref_using_main == 1 ]; then git checkout $source_branch_commit_sha; fi

    # run test
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer_.py --create_cut || exit_code=$?
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer_.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$?
    - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true

    - *merge-request-comparison-check
@@ -661,7 +666,8 @@ split-rendering-smoke-test:
  script:
    - *enable-split-rendering
    - make -j INCLUDE_SPLIT=1
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py
    - testcase_timeout=10
    - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --testcase_timeout=$testcase_timeout
  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results"
    expire_in: 1 week
@@ -711,7 +717,8 @@ split-rendering-pytest-on-merge-request:
    - if [ $ref_using_main == 0 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts
    - if [ $ref_using_main == 0 ]; then git checkout $source_branch_commit_sha; fi
    - exit_code=0
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_ref || exit_code=$?
    - testcase_timeout=60
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$?

    # back to source branch
    - git restore lib_com/options.h # Revert changes back before checking out another branch to avoid conflicts
@@ -725,7 +732,7 @@ split-rendering-pytest-on-merge-request:
    - if [ $ref_using_main == 1 ]; then git checkout $source_branch_commit_sha; fi

    # run test
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_cut || exit_code=$?
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$?
    - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true

    - *merge-request-comparison-check
@@ -780,7 +787,8 @@ ivas-pytest-on-merge-request:

    ### run pytest
    - exit_code=0
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml || exit_code=$?
    - testcase_timeout=60
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout || exit_code=$?
    - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true

    - *merge-request-comparison-check
@@ -880,14 +888,15 @@ evs-pytest-on-merge-request:

    ### prepare pytest
    # create references
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --update_ref 1 -m create_ref --param_file scripts/config/self_test_evs.prm
    - testcase_timeout=60
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --update_ref 1 -m create_ref --param_file scripts/config/self_test_evs.prm --testcase_timeout=$testcase_timeout

    ### Run test using branch scripts and input
    - if [ $ref_using_main == 1 ]; then git checkout $source_branch_commit_sha; fi

    ### run pytest for EVS cases
    - exit_code=0
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --param_file scripts/config/self_test_evs.prm --html=report.html --self-contained-html --junit-xml=report-junit-evs.xml || exit_code=$?
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --param_file scripts/config/self_test_evs.prm --html=report.html --self-contained-html --junit-xml=report-junit-evs.xml --testcase_timeout=$testcase_timeout || exit_code=$?
    - zero_errors=$(cat report-junit-evs.xml | grep -c 'errors="0"') || true

    - *merge-request-comparison-check
@@ -989,11 +998,11 @@ check-first-frame-is-sid:
    # run all modes and cut bitstream to start with an SID. Use stereo output to limit runtime, test is only about decoding
    - ism_md_cmd="--ism_metadata_files /usr/local/ltv/ltvISM1.csv /usr/local/ltv/ltvISM2.csv /usr/local/ltv/ltvISM3.csv /usr/local/ltv/ltvISM4.csv"
    - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep -vE "FOA|HOA" )
    - scripts/runIvasCodec.py -z console -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 200 -U 0:20 --oc stereo $ism_md_cmd || exit_code_no_sba=$?
    - scripts/runIvasCodec.py -z console -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 200 -U 0:20 --oc stereo $ism_md_cmd --timeout 10 || exit_code_no_sba=$?
    - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep -E "HOA")
    - scripts/runIvasCodec.py -z console -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 100 -U 70:80 --oc stereo || exit_code_hoa=$?
    - scripts/runIvasCodec.py -z console -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 100 -U 70:80 --oc stereo --timeout 10 || exit_code_hoa=$?
    - modes=$(scripts/runIvasCodec.py -l | grep dtx | grep "FOA")
    - scripts/runIvasCodec.py -z console -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 100 -U 75:110 --oc stereo || exit_code_foa=$?
    - scripts/runIvasCodec.py -z console -p scripts/config/ci_linux_sidstart_test.json -m $modes -s --bs_length 100 -U 75:110 --oc stereo timeout 10 || exit_code_foa=$?

    - if [ $exit_code_no_sba -ne 0 ] || [ $exit_code_hoa -ne 0 ] || [ $exit_code_hoa -ne 0 ]; then exit 1; fi
  artifacts:
@@ -1129,15 +1138,16 @@ codec-comparison-on-main-push:
    - mv IVAS_cod_test IVAS_cod
    - mv IVAS_dec_test IVAS_dec
    # create references
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -m create_ref
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -m create_ref_part2
    - testcase_timeout=60
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -m create_ref --testcase_timeout=$testcase_timeout
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -m create_ref_part2 --testcase_timeout=$testcase_timeout

    ### re-checkout the latest commit here, if ref_using_main is set
    - if [ $ref_using_main -eq 1 ]; then git checkout $latest_commit;fi

    ### run pytest
    - exit_code=0
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml || exit_code=$?
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout || exit_code=$?
    - if [ $exit_code -eq 1 ] && [ $non_be_flag == 0 ]; then echo "pytest run had failures and non-BE flag not present"; exit $EXIT_CODE_FAIL; fi
    - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true
    - if [ $exit_code -eq 1 ] && [ $zero_errors == 1 ]; then echo "pytest run had failures, but no errors and non-BE flag present"; exit $EXIT_CODE_NON_BE; fi
@@ -1231,11 +1241,12 @@ test-long-self-test:

    # create references
    - exit_code_ref=0
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --update_ref 1 -m create_ref --param_file scripts/config/self_test_ltv.prm || exit_code_ref=$?
    - testcase_timeout=300
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --update_ref 1 -m create_ref --param_file scripts/config/self_test_ltv.prm --testcase_timeout=$testcase_timeout || exit_code_ref=$?

    ### run pytest self-test using long test vectors
    - exit_code=0
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --param_file scripts/config/self_test_ltv.prm --html=report-ltv.html --self-contained-html --junit-xml=report-junit-ltv.xml || exit_code=$?
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v --param_file scripts/config/self_test_ltv.prm --html=report-ltv.html --self-contained-html --junit-xml=report-junit-ltv.xml --testcase_timeout=$testcase_timeout || exit_code=$?
    - zero_errors=$(cat report-junit-ltv.xml | grep -c 'errors="0"') || true

    - if [ $zero_errors != 1 ]; then echo "Run errors encountered!"; exit $EXIT_CODE_FAIL; fi
+3 −0
Original line number Diff line number Diff line
@@ -148,6 +148,9 @@ def run_check(in_format: str, out_formats: list, tests: list, run_fec: bool = Tr
        *md_file_command,
        "--usan_supp_file",
        USAN_SUPP_FILE,
        # timeout of 15 minutes per en/decoding to safeguard against endless loops
        "--timeout",
        60 * 15,
    ]

    print(
+9 −8
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ dly_profile=./scripts/dly_error_profiles/dly_error_profile_10.dat
ism_md_cmd="--ism_metadata_files /usr/local/ltv/ltvISM1.csv /usr/local/ltv/ltvISM2.csv /usr/local/ltv/ltvISM3.csv /usr/local/ltv/ltvISM4.csv"
duration_arg="-U 1:2"
verbosity_cmd="-z console"
timeout_cmd="--timeout 5"
ep_file="ci/complexity_measurements/ep_10pct_fer.g192"

if [ $BUILD -eq 1 ];then
@@ -84,21 +85,21 @@ echo "\n======================= 0. preparing combined format test inputs =======
ism_modes=$(./scripts/runIvasCodec.py -l | grep ^ISM)
non_ism_modes=$(./scripts/runIvasCodec.py -l | grep -v ^ISM)
echo "\n======================= 1. non-ism modes no FEC =======================\n\n"
./scripts/runIvasCodec.py $verbosity_cmd -m $non_ism_modes -p $cfg $duration_arg | tee smoke_test_output.txt
./scripts/runIvasCodec.py $verbosity_cmd -m $non_ism_modes -p $cfg $duration_arg $timeout_cmd | tee smoke_test_output.txt
echo "\n======================= 2. ism modes no FEC =======================\n\n"
./scripts/runIvasCodec.py $verbosity_cmd -m $ism_modes -p $cfg $duration_arg $ism_md_cmd | tee smoke_test_output.txt
./scripts/runIvasCodec.py $verbosity_cmd -m $ism_modes -p $cfg $duration_arg $ism_md_cmd $timeout_cmd | tee smoke_test_output.txt
# run the decoding again, but with 15% frame loss
echo "\n======================= 3. all modes with FEC =======================\n\n"
./scripts/runIvasCodec.py $verbosity_cmd -p $cfg $duration_arg -f="$ep_file" --decoder_only | tee smoke_test_output_plc.txt
./scripts/runIvasCodec.py $verbosity_cmd -p $cfg $duration_arg -f="$ep_file" --decoder_only $timeout_cmd | tee smoke_test_output_plc.txt

# run JBM modes - EXT is excluded as not supported yet
# OMASA disabled for now
modes_with_no_ext_out=$(./scripts/runIvasCodec.py -l | grep -v ^MASA | grep -v ^ISM | grep -v OMASA)
modes_with_ext_out=$(./scripts/runIvasCodec.py -l | grep 'MASA\|ISM' | grep -v ^ISM+ | grep -v OMASA)
echo "\n======================= 4. JBM, modes with no EXT =======================\n\n"
./scripts/runIvasCodec.py $verbosity_cmd -m $modes_with_no_ext_out -p $cfg $duration_arg --decoder_only --jbm_file $dly_profile | tee smoke_test_output_jbm_noEXT.txt
./scripts/runIvasCodec.py $verbosity_cmd -m $modes_with_no_ext_out -p $cfg $duration_arg --decoder_only --jbm_file $dly_profile $timeout_cmd | tee smoke_test_output_jbm_noEXT.txt
echo "\n======================= 5. JBM, modes with EXT =======================\n\n"
./scripts/runIvasCodec.py  $verbosity_cmd -m $modes_with_ext_out -p $cfg $duration_arg --decoder_only --jbm_file $dly_profile --oc BINAURAL BINAURAL_ROOM_IR mono stereo FOA HOA3 5_1 7_1_4 | tee -a smoke_test_output_jbm_noEXT.txt
./scripts/runIvasCodec.py  $verbosity_cmd -m $modes_with_ext_out -p $cfg $duration_arg --decoder_only --jbm_file $dly_profile --oc BINAURAL BINAURAL_ROOM_IR mono stereo FOA HOA3 5_1 7_1_4 $timeout_cmd | tee -a smoke_test_output_jbm_noEXT.txt

# run all modes with binaural output using external files
modes_with_bin_out="FOA HOA2 HOA3 PlanarFOA PlanarHOA2 PlanarHOA3 MASA MC ISM1 ISM2 ISM3 ISM4"
@@ -107,14 +108,14 @@ bin_out_modes="BINAURAL BINAURAL_ROOM_IR"
echo "\n======================= 6. binaural out with HRTF files - WB =======================\n\n"
wb_modes=$(./scripts/runIvasCodec.py -l -C $modes_with_bin_out | grep _wb_)
hrtf_wb="../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_16kHz.bin"
./scripts/runIvasCodec.py $verbosity_cmd -p $cfg -m $wb_modes $duration_arg -D="-hrtf ${hrtf_wb}" --decoder_only --oc $bin_out_modes | tee -a smoke_test_output_hrtf.txt
./scripts/runIvasCodec.py $verbosity_cmd -p $cfg -m $wb_modes $duration_arg -D="-hrtf ${hrtf_wb}" --decoder_only --oc $bin_out_modes $timeout_cmd | tee -a smoke_test_output_hrtf.txt

echo "\n======================= 7. binaural out with HRTF files - SWB =======================\n\n"
swb_modes=$(./scripts/runIvasCodec.py -l -C $modes_with_bin_out | grep _swb_)
hrtf_swb="../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_32kHz.bin"
./scripts/runIvasCodec.py $verbosity_cmd -p $cfg -m $swb_modes $duration_arg -D="-hrtf ${hrtf_swb}" --decoder_only --oc $bin_out_modes | tee -a smoke_test_output_hrtf.txt
./scripts/runIvasCodec.py $verbosity_cmd -p $cfg -m $swb_modes $duration_arg -D="-hrtf ${hrtf_swb}" --decoder_only --oc $bin_out_modes $timeout_cmd | tee -a smoke_test_output_hrtf.txt

echo "\n======================= 8. binaural out with HRTF files - FB =======================\n\n"
fb_modes=$(./scripts/runIvasCodec.py -l -C $modes_with_bin_out | grep _fb_)
hrtf_fb="../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin"
./scripts/runIvasCodec.py $verbosity_cmd -p $cfg -m $fb_modes $duration_arg -D="-hrtf ${hrtf_fb}" --decoder_only --oc $bin_out_modes | tee -a smoke_test_output_hrtf.txt
./scripts/runIvasCodec.py $verbosity_cmd -p $cfg -m $fb_modes $duration_arg -D="-hrtf ${hrtf_fb}" --decoder_only --oc $bin_out_modes $timeout_cmd | tee -a smoke_test_output_hrtf.txt
+64 −32
Original line number Diff line number Diff line
@@ -33,40 +33,52 @@
import argparse
import concurrent.futures
import os
import pathlib
import re
import shutil
import subprocess
import sys
import threading
from itertools import repeat
from pyaudio3dtools.audiofile import readfile
from pyaudio3dtools.audioarray import compare

FILES_EQUAL = "File A = File B"
SNR_EXPR = r"SNR\s+=(.+)dB\s*\(File B Gain = (.+)\)"
SNR_EXPR = r"SNR\s+=(.+)dB\s*\(.+= (.+)\)"
SEG_SNR_EXPR = r"Seg. SNR\s+=(.+)dB"
DIFF_EXPR = r"Max Diff\s+=\s+(\d+)"
DIFF_STR = {
    "CompAudio": "{label} Max. diff (PCM) for file {f}: {diff}",
    "mld": "{label} MLD diff for file {f}: {diff}",
}


def main(args):

    if shutil.which("CompAudio") is None:
        print("CompAudio not in PATH - abort.")
    tool = args.tool
    if shutil.which(tool) is None:
        print(f"{tool} not in PATH - abort.")
        sys.exit(-1)

    num_files_diff = 0

    with OutFileManager(args.out_file) as out_file:
        if args.diffs_only:
            print("Only printing differing files!", file=out_file)
            print("Only printing differing files!")

        fol1, fol2 = os.path.normpath(args.folder1), os.path.normpath(args.folder2)
        common_files = get_common_files(fol1, fol2)
        diff_files = get_diff_files(fol1, fol2)
        num_files_diff = len(diff_files)

        print(f"Comparing {len(common_files)} files...", file=out_file)
        print(f"Comparing {len(common_files)} files...")

        outputs = dict()
        if args.num_threads > 1:
        if args.num_threads == 1:
            # if only one thread is passed, do everything in the main thread
            # to allow for meaningful debugging if needed
            for f in common_files:
                compare_files(f, fol1, fol2, outputs, tool)
        else:
            with concurrent.futures.ThreadPoolExecutor(
                max_workers=args.num_threads
            ) as exc:
@@ -76,20 +88,26 @@ def main(args):
                    repeat(fol1),
                    repeat(fol2),
                    repeat(outputs),
                    repeat(tool),
                )
        else:
            # if only one thread is passed, do everything in the main thread
            # to allow for meaningful debugging if needed
            for f in common_files:
                compare_files(f, fol1, fol2, outputs)

        if args.sort:
            out = dict(sorted(outputs.items(), key=lambda item: item[1]))
        else:
            out = outputs

        for f, output_tuple in out.items():
            diff, snr, gain, seg_snr = output_tuple
        # write csv header
        if out_file is not None:
            if tool == "CompAudio":
                out_file.write("filename,diff\n")
            elif tool == "mld":
                out_file.write("filename,mld\n")

        for f, tool_output in out.items():
            if tool == "CompAudio":
                diff, snr, gain, seg_snr = tool_output
            elif tool == "mld":
                diff = tool_output

            if diff > 0:
                num_files_diff = num_files_diff + 1
@@ -99,38 +117,47 @@ def main(args):
                    label = "[OKAY]"
                else:
                    label = "[FAIL]"
                result = f"{label} Max. diff (PCM) for file {f}: {diff}"
                result = DIFF_STR[tool].format(label=label, f=f, diff=diff)

                if args.verbose and diff != 0.0:
                if tool == "CompAudio" and args.verbose and diff != 0.0:
                    result += f", SNR = {snr:4.2f} dB (File 2 Gain = {gain:4.3f})"
                    result += f", Seg. SNR = {seg_snr:4.2f} dB"

                print(result, file=out_file)
                print(result)

                if out_file is not None:
                    out_file.write(f"{f},{diff}\n")

        if num_files_diff > 0:
            print(f"{num_files_diff} files differ/don't exist", file=out_file)
            print(f"{num_files_diff} files differ/don't exist")
        else:
            print(f"All files are bitexact", file=out_file)
            print(f"All files are bitexact")


def compare_files(f, fol1, fol2, outputs_dict):
def compare_files(f, fol1, fol2, outputs_dict, tool):
    """
    Compare file f in both folders fol1 and fol2 using CompAudio and
    Compare file f in both folders fol1 and fol2 using the given tool and
    store the parsed difference in outputs_dict.
    """
    f1 = os.path.join(fol1, f)
    f2 = os.path.join(fol2, f)
    cmd = f"CompAudio {f1} {f2}"

    if tool == "CompAudio":
        cmd = f"{tool} {f1} {f2}"
        try:
            output = subprocess.check_output(cmd.split(" "))
        except subprocess.CalledProcessError:
        print("CompAudio returned a non-zero exit status. Check your files.")
            print(f"{tool} returned a non-zero exit status. Check your files.")
            sys.exit(-1)

    output_tuple = _parse_comp_audio(output)
        tool_output = _parse_comp_audio(output)
    elif tool == "mld":
        s1, fs1 = readfile(f1, outdtype="int16")
        s2, fs2 = readfile(f2, outdtype="int16")
        cmp_result = compare(s1, s2, fs1, per_frame=False, get_mld=True)
        tool_output = cmp_result["MLD"]

    with threading.Lock():
        outputs_dict.update({f: output_tuple})
        outputs_dict.update({f: tool_output})


def get_common_files(fol1, fol2):
@@ -220,7 +247,6 @@ class OutFileManager:


if __name__ == "__main__":

    parser = argparse.ArgumentParser(
        description="Compare .wav files in two folders using CompAudio"
    )
@@ -251,10 +277,16 @@ if __name__ == "__main__":
        "--out_file",
        type=str,
        default=None,
        help="If given, write output diffs to this file",
        help="If given, write output diffs to this file as comma-separated values (csv)",
    )
    parser.add_argument(
        "-t", "--num_threads", type=int, default=None, help="Number of threads to use"
    )
    parser.add_argument(
        "-t", "--num_threads", type=int, default=1, help="Number of threads to use"
        "--tool",
        choices=["mld", "CompAudio"],
        default="CompAudio",
        help="Compare tool to run",
    )
    args = parser.parse_args()

+32 −14

File changed.

Preview size limit exceeded, changes collapsed.

Loading