Commit 15857716 authored by Fabian Müller's avatar Fabian Müller
Browse files

Merge branch 'mullerfa/basop-smoke-test-fixes' into...

Merge branch 'mullerfa/basop-smoke-test-fixes' into mullerfa/python-improvements-basop-fixes-temp-branch
parents fb6d3fe4 a5c4bb90
Loading
Loading
Loading
Loading
+130 −4
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@ import argparse
import sys
import os
import pathlib
import re
import xml.etree.ElementTree as ET
from typing import Tuple


# set positive threshold for "lower is better" metrics, negative for "higher is better"
@@ -48,8 +51,16 @@ COLS_2_THRESHOLDS = {
OUTFILE_CRASHES = "changes_crashes.csv"
OUTFILE_SCORES = "changes_{}.csv"

PATTERN_ENC = r"... encoder command:\s*(.*)\s*... encoder stdout:"
PATTERN_DEC = r"... decoder command:\s*(.*)\s*... decoder stdout:"
PATTERN_EID = r"eid-xor command:\s*(.*)\s*"
PATTERN_NETSIM = r"netsim command:\s*(.*)\s*"

PATTERNS = [PATTERN_ENC, PATTERN_DEC, PATTERN_EID, PATTERN_NETSIM]


def main(args):
    xml_report = args.xml_report
    df_curr = pd.read_csv(args.csv_current, sep=";")
    df_prev = pd.read_csv(args.csv_previous, sep=";")
    df_merged = pd.merge(df_curr, df_prev, on="testcase", suffixes=["-curr", "-prev"])
@@ -77,7 +88,6 @@ def main(args):
    df_crashes_introduced = df_merged[mask_crash_introduced][display_cols].reset_index(
        drop=True
    )
    df_crashes_introduced.to_csv(OUTFILE_CRASHES, sep=";")

    if sum(mask_crash_introduced) > 0:
        regressions_found = True
@@ -85,15 +95,32 @@ def main(args):
        print(df_crashes_introduced)
        print()

        if xml_report is not None:
            cmdlines_crashes_introduced = get_command_lines_for_testcases(
                df_crashes_introduced["testcase"], xml_report, args.inject_cwd
            )
            df_crashes_introduced = pd.merge(
                df_crashes_introduced, cmdlines_crashes_introduced, on="testcase"
            )
    df_crashes_introduced.to_csv(OUTFILE_CRASHES, sep=";")

    if args.show_improvements and sum(mask_crash_fixed) > 0:
        df_crashes_fixed = df_merged[mask_crash_fixed][display_cols].reset_index(
            drop=True
        )
        df_crashes_fixed.to_csv(OUTFILE_CRASHES, mode="a", sep=";")
        print("---------------Testcases that fixed crashes---------------")
        print(df_crashes_fixed)
        print()

        if xml_report is not None:
            cmdlines_crashes_fixed = get_command_lines_for_testcases(
                df_crashes_fixed["testcase"], xml_report, args.inject_cwd
            )
            df_crashes_fixed = pd.merge(
                df_crashes_fixed, cmdlines_crashes_fixed, on="testcase"
            )
        df_crashes_fixed.to_csv(OUTFILE_CRASHES, mode="a", sep=";")

    # remove columns with ERRORs in any of the csv files before comparing the numerical columns
    mask_no_errors = (df_merged[col_curr] != "ERROR") & (df_merged[col_prev] != "ERROR")
    df_merged = df_merged[mask_no_errors].reset_index(drop=True)
@@ -115,7 +142,6 @@ def main(args):
        display_cols = ["testcase", col_curr, col_prev, col_diff]
        outfile = OUTFILE_SCORES.format(col.replace(" ", "_"))
        df_worse = df_merged[mask_worse][display_cols].reset_index(drop=True)
        df_worse.to_csv(outfile, sep=";")
        if sum(mask_worse) > 0:
            regressions_found = True
            print(
@@ -124,18 +150,107 @@ def main(args):
            print(df_worse)
            print()

            if xml_report is not None:
                cmdlines_worse = get_command_lines_for_testcases(
                    df_worse["testcase"], xml_report, args.inject_cwd
                )
                df_worse = pd.merge(df_worse, cmdlines_worse, on="testcase")
        df_worse.to_csv(outfile, sep=";")

        if args.show_improvements and sum(mask_better) > 0:
            df_better = df_merged[mask_better][display_cols].reset_index(drop=True)
            df_better.to_csv(outfile, mode="a", sep=";")
            print(
                f"---------------Testcases that got better wrt to {col}---------------"
            )
            print(df_better)
            print()

            if xml_report is not None:
                cmdlines_better = get_command_lines_for_testcases(
                    df_better["testcase"], xml_report, args.inject_cwd
                )
                df_better = pd.merge(df_better, cmdlines_better, on="testcase")
            df_better.to_csv(outfile, mode="a", sep=";")

    return int(regressions_found)


def get_command_lines_for_testcases(
    testcases: pd.Series, xml_report: pathlib.Path, cwd: pathlib.Path
) -> pd.DataFrame:
    testcase_elems = [
        e
        for _, e in ET.iterparse(xml_report)
        if e.tag == "testcase" and e.attrib["name"] in testcases.values
    ]

    cmdlines = {
        "testcase": [],
        "enc_cmd": [],
        "dec_cmd": [],
        "eid-xor_cmd": [],
        "netsim_cmd": [],
    }
    for elem in testcase_elems:
        testcase_name = elem.attrib["name"]
        enc_cmd = ""
        dec_cmd = ""
        eid_cmd = ""
        netsim_cmd = ""
        if (system_out := elem.find("system-out")) is not None:
            (
                enc_cmd,
                dec_cmd,
                eid_cmd,
                netsim_cmd,
            ) = extract_cmdlines(system_out.text, cwd)

        cmdlines["testcase"].append(testcase_name)
        cmdlines["enc_cmd"].append(enc_cmd)
        cmdlines["dec_cmd"].append(dec_cmd)
        cmdlines["eid-xor_cmd"].append(eid_cmd)
        cmdlines["netsim_cmd"].append(netsim_cmd)

    return pd.DataFrame(cmdlines)


def extract_cmdlines(text: str, cwd: pathlib.Path) -> list[str]:
    cmdlines = []
    for p in PATTERNS:
        m = re.search(p, text)
        if m is not None:
            cmdline = postprocess_cmdline(m.group(1), cwd)
            cmdlines.append(cmdline)
        else:
            cmdlines.append("")

    return cmdlines


def postprocess_cmdline(cmdline: str, cwd: pathlib.Path) -> str:
    cmdline_split = cmdline.split()
    cmdline_proc = []

    # change absolute paths into relative ones
    # remove the "quite" flag
    # for output and bitstream files only keep the filename
    for elem in cmdline_split:
        if elem == "-q":
            continue
        elif (elem_as_path := pathlib.Path(elem)).is_absolute():
            if elem_as_path.suffix == ".192" or (
                elem_as_path.suffix == ".wav"
                and cmdline_split.index(elem) == len(cmdline_split) - 1
            ):
                cmdline_proc.append(elem_as_path.name)
            else:
                cmdline_proc.append(str(elem_as_path.relative_to(cwd)))
        else:
            cmdline_proc.append(elem)

    return " ".join(cmdline_proc)


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("csv_current")
@@ -147,6 +262,17 @@ if __name__ == "__main__":
        default=COLS_2_THRESHOLDS.keys(),
    )
    parser.add_argument("--show_improvements", action="store_true")
    parser.add_argument(
        "--xml_report",
        help="XMLxml_report report file from pytest run. Pass to add command lines to the output files.",
        default=None,
    )
    parser.add_argument(
        "--inject_cwd",
        help="Use this as cwd when pruning the long paths in the command lines. Debug option for testing.",
        default=pathlib.Path(os.getcwd()).absolute(),
        type=pathlib.Path,
    )

    args = parser.parse_args()
    sys.exit(main(args))
+10 −3
Original line number Diff line number Diff line
@@ -27,8 +27,8 @@
   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.
-->
# Modeling tool for all IVAS binaural renderers
# Allows to convert SOFA file(s) to ROM tables files (*.c|h) or binaural binary file(s)
# Modeling tool for all IVAS binaural renderer
# Allows to convert SOFA file(s) to rom tables files (*.c|h) or binaural binary file(s)

## Requirements
- MATLAB >= R2017b
@@ -55,7 +55,7 @@
     ```
   - `generate_crend_ivas_tables` executable shall be in folder [`../../scripts/binauralRenderer_interface`](../../scripts/binauralRenderer_interface)  
   - On Windows this executable requires DLL from MATLAB, you need to add to your path `*/matlab/version/bin/win64`
   - For more details on `generate_crend_ivas_tables` see [`ivas_crend_sofa_to_rom_table_converter_readme.txt`](ivas_crend_sofa_to_rom_table_converter_readme.txt).
   - For more details on `generate_crend_ivas_tables` see [`mixer_conv_sofa_to_rom_table_converter_readme.txt`](mixer_conv_sofa_to_rom_table_converter_readme.txt).
   - On Apple Silicon Mac with Intel MATLAB, it is necessary to add `SET(CMAKE_OSX_ARCHITECTURES "x86_64")` in the `CMakeLists.txt` near the top of the file. This forces the compilation to use Intel architecture instead ofo the native one.
   - if find_package do not find matlab, at the beginning of the cmakelists.txt file you can set the search path with the folowing line set(Matlab_ROOT_DIR matlab_path), for example on linux set(Matlab_ROOT_DIR ~/MATLAB/R2023b) on mac set(Matlab_ROOT_DIR /Applications/MATLAB_R2023b.app) 	 

@@ -109,4 +109,11 @@ See [`scripts/ThirdPartyLegalNotices`](../../scripts/ThirdPartyLegalNotices) for
→ Generated files are in folder [`binaural_renderers_hrtf_data`](binaural_renderers_hrtf_data)
- Generated files :
 - `ivas_binaural_*kHz.bin`: file containing all tables values for all IVAS binaural renderers for one sample rate.
 - `ivas_binaural_td_*kHz.bin`: file containing tables values for IVAS td binaural renderer for one sample rate.
 - `ivas_binaural_reverb_*kHz.bin`: file containing tables values for IVAS td reverberation process for one sample rate.
 - `ivas_binaural_fastconv_*kHz.bin`: file containing tables values for IVAS fastconv binaural renderers. Files for all sampling rate files are the same.
 - `ivas_binaural_parambin_*kHz.bin`: file containing tables values for IVAS prametric binaural renderers. Files for all sampling rate files are the same.
 - `ivas_binaural_td_*kHz.bin`: file containing tables values for IVAS td binaural renderers for one sample rate.
 - `ivas_binaural_mixconv_hrir_*kHz.bin`: file containing tables values for IVAS mixer conv binaural renderer for HRIR for one sample rate.
 - `ivas_binaural_mixconv_brir_*kHz.bin`: file containing tables values for IVAS mixer conv binaural renderer for BRIR for one sample rate.
+15 −0
Original line number Diff line number Diff line
@@ -73,6 +73,21 @@ const HRTF_READER_RENDERER_TYPE rend_types[IVAS_NB_RENDERER_TYPE] = {
    HRTF_READER_RENDERER_BINAURAL_REVERB_ALL
};

#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM
typedef enum
{
    BINAURAL_INPUT_AUDIO_CONFIG_INVALID,
    BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, /* 5_1, 5_1_2, 5_1_4, 7_1, 7_1_4 */
    BINAURAL_INPUT_AUDIO_CONFIG_HOA3,     /* HOA3 */
    BINAURAL_INPUT_AUDIO_CONFIG_HOA2,     /* HOA2 */
    BINAURAL_INPUT_AUDIO_CONFIG_FOA,      /* FOA */
    BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED /* Not used */

} BINAURAL_INPUT_AUDIO_CONFIG;

#endif


const BINAURAL_INPUT_AUDIO_CONFIG input_cfgs[IVAS_NB_AUDIO_CONFIG] = {
    BINAURAL_INPUT_AUDIO_CONFIG_COMBINED,
    BINAURAL_INPUT_AUDIO_CONFIG_HOA3,
Loading