Commit 403be1d9 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

Merge branch 'main' into...

Merge branch 'main' into 1132-improper-output-with-floating-point-ivas-decoder-for-10db-test_sba_plc_system-1-32
parents 29cdc9dd 461b000d
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ COLUMNS = [
    "MLD",
    "MAXIMUM ABS DIFF",
    "MIN_SSNR",
    "MIN_ODG",
]
COLUMNS_GLOBAL = COLUMNS[:1]
COLUMNS_DIFFERENTIAL = COLUMNS[3:]
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ from xml.etree import ElementTree
Parse a junit report and create a summary report.
"""

PROPERTIES = ["MLD", "MAXIMUM ABS DIFF", "MIN_SSNR"]
PROPERTIES = ["MLD", "MAXIMUM ABS DIFF", "MIN_SSNR", "MIN_ODG"]

FORMATS = {
    "Stereo": r"stereo",
+44 −2
Original line number Diff line number Diff line
@@ -3,6 +3,11 @@
import argparse
import os
import sys
import tempfile
import re
import subprocess
from pathlib import Path
from typing import Optional

THIS_PATH = os.path.join(os.getcwd(), __file__)
sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts"))
@@ -10,6 +15,7 @@ sys.path.append(os.path.join(os.path.dirname(THIS_PATH), "../scripts"))
import numpy as np
import pyaudio3dtools
import pyivastest
from .constants import ODG_PATTERN_PQEVALAUDIO


def cmp_pcm(
@@ -22,6 +28,7 @@ def cmp_pcm(
    mld_lim=0,
    abs_tol=0,
    get_ssnr=False,
    get_odg=False,
) -> (int, str):
    """
    Compare 2 PCM files for bitexactness
@@ -102,15 +109,50 @@ def cmp_pcm(
            reason += f" > {mld_lim}"

    if get_ssnr:
        reason += "\n"
        for i, s in enumerate(cmp_result["SSNR"], start=1):
            msg = f"Channel {i} SSNR: {s}"
            reason += msg + "\n"
            reason += " - " + msg
            print(msg)

    if get_odg:
        for n in range(nchannels):
            pqeval_output = pqevalaudio_wrapper(s1[:, n], s2[:, n], fs)

            match_odg = re.search(ODG_PATTERN_PQEVALAUDIO, pqeval_output)
            odg = float(match_odg.groups()[0])
            msg = f"Channel {n} ODG: {odg}"
            reason += " - " + msg
            print(msg)

    return output_differs, reason


def pqevalaudio_wrapper(
        ref_sig: np.ndarray,
        eval_sig: np.ndarray,
        fs: int,
        ) -> str:
    with tempfile.TemporaryDirectory() as tmp_dir:
        tmp_dir = Path(tmp_dir)
        tmp_file_ref = str(tmp_dir.joinpath("ref.wav"))
        tmp_file_eval = str(tmp_dir.joinpath("eval.wav"))

        # PQevalAudio neeeds 48 kHz sampling rate
        r48 = np.clip( pyaudio3dtools.audioarray.resample(ref_sig.astype(float), fs, 48000), -32768, 32767 ).astype(np.int16)
        t48 = np.clip( pyaudio3dtools.audioarray.resample(eval_sig.astype(float), fs, 48000), -32768, 32767 ).astype(np.int16)

        pyaudio3dtools.audiofile.writefile(tmp_file_ref, r48, 48000)
        pyaudio3dtools.audiofile.writefile(tmp_file_eval, t48, 48000)

        cmd = ["PQevalAudio", tmp_file_ref, tmp_file_eval]

        result = subprocess.run(cmd, capture_output=True)
        if result.returncode != 0:
            raise RuntimeError(f"Error running PQevalaudio: {result.stderr}")

        return result.stdout.decode("utf8")


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("ref_file", type=str)
+2 −1
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ from tests.cmp_pcm import cmp_pcm
from tests.conftest import DecoderFrontend, EncoderFrontend, parse_properties
from tests.testconfig import PARAM_FILE


VALID_DEC_OUTPUT_CONF = [
    "MONO",
    "STEREO",
@@ -153,6 +152,7 @@ def test_param_file_tests(
    get_mld_lim,
    abs_tol,
    get_ssnr,
    get_odg,
):
    enc_opts, dec_opts, sim_opts, eid_opts = param_file_test_dict[test_tag]

@@ -351,6 +351,7 @@ def test_param_file_tests(
            abs_tol=abs_tol,
            allow_differing_lengths=allow_differing_lengths,
            get_ssnr=get_ssnr,
            get_odg=get_odg,
        )
        md_out_files = get_expected_md_files(ref_output_file, enc_split, output_config)

+4 −0
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ def test_sba_plc_system(
    get_mld_lim,
    abs_tol,
    get_ssnr,
    get_odg
):
    SID = 0
    if dtx == "1" and ivas_br not in ["13200", "16400", "24400", "32000", "64000"]:
@@ -135,6 +136,7 @@ def test_sba_plc_system(
        get_mld_lim=get_mld_lim,
        abs_tol=abs_tol,
        get_ssnr=get_ssnr,
        get_odg=get_odg,
    )


@@ -161,6 +163,7 @@ def sba_dec_plc(
    get_mld_lim=0,
    abs_tol=0,
    get_ssnr=False,
    get_odg=False,
):
    # ------------  run cmd  ------------

@@ -219,6 +222,7 @@ def sba_dec_plc(
            mld_lim=get_mld_lim,
            abs_tol=abs_tol,
            get_ssnr=get_ssnr,
            get_odg=get_odg,
        )

        props = parse_properties(reason, cmp_result!=0, props_to_record)
Loading