Commit ac148bea authored by Jan Kiene's avatar Jan Kiene
Browse files

fix dmx comparison + add MLD and SSNR for dmx

- combine multi-mono dmx signals into multichannel signal b4 comparison
parent 844f99d4
Loading
Loading
Loading
Loading
+41 −16
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import os
import platform
from pathlib import Path
from subprocess import run
from tempfile import NamedTemporaryFile
import pytest
import re
import sys
@@ -57,6 +58,8 @@ from tests.constants import (
    SCRIPTS_DIR,
    MAX_ENC_DIFF,
    DMX_DIFF,
    DMX_MLD,
    DMX_SSNR,
)
from tests.renderer.utils import check_and_makedir, binauralize_input_and_output

@@ -499,24 +502,46 @@ def run_test(

    if update_ref in [0, 2]:
        if compare_enc_dmx:
            dut_dmx_files = Path(
                f"{dut_base_path}/param_file/enc/{bitstream_file}"
            ).parent.glob(f"{Path(bitstream_file).stem}.dmx.ch*.pcm")

            for dut_dmx_file in dut_dmx_files:
                ref_dmx_file = str(dut_dmx_file).replace(dut_base_path, reference_path)
                testv_sig, _ = pyaudio3dtools.audiofile.readfile(testv_file)
                nchannels = testv_sig.shape[1]
            dut_dmx_files = sorted(
                Path(f"{dut_base_path}/param_file/enc/{bitstream_file}").parent.glob(
                    f"{Path(bitstream_file).stem}.dmx.ch*.pcm"
                )
            )
            ref_dmx_files = [
                str(f).replace(dut_base_path, reference_path) for f in dut_dmx_files
            ]

            nchannels = len(dut_dmx_files)
            with NamedTemporaryFile(suffix=".ref_dmx.pcm") as dmx_file_ref_tmp:
                with NamedTemporaryFile(suffix=".dut_dmx.pcm") as dmx_file_dut_tmp:
                    pyaudio3dtools.audiofile.combinefiles(
                        ref_dmx_files,
                        dmx_file_ref_tmp.name,
                        out_nchans=nchannels,
                        in_fs=in_sr,
                    )
                    pyaudio3dtools.audiofile.combinefiles(
                        dut_dmx_files,
                        dmx_file_dut_tmp.name,
                        out_nchans=nchannels,
                        in_fs=in_sr,
                    )

                    dmx_differs, reason = cmp_pcm(
                    ref_dmx_file,
                    dut_dmx_file,
                        dmx_file_ref_tmp.name,
                        dmx_file_dut_tmp.name,
                        nchannels,
                        in_sr,
                        get_mld=True,
                        get_ssnr=True,
                        quiet=True,
                    )

                prop = parse_properties(reason, dmx_differs, [DMX_DIFF])
                dut_decoder_frontend.record_property(DMX_DIFF, prop[DMX_DIFF])
            dmx_props = [DMX_DIFF, DMX_MLD, DMX_SSNR]
            pytest.set_trace()
            prop_results = parse_properties(reason, dmx_differs, dmx_props)
            for prop in dmx_props:
                dut_decoder_frontend.record_property(prop, prop_results[prop])

        # Output file names for comparison
        dut_output_file = f"{dut_base_path}/param_file/dec/{output_file}"
+8 −4
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@ import numpy as np
from .constants import (
    # MAX_ENC_DIFF_NAME_PATTERN,
    DMX_DIFF,
    DMX_MLD,
    DMX_SSNR,
    MAX_ENC_DIFF_PARAM_NAME,
    MLD_PATTERN,
    MAX_DIFF_PATTERN,
@@ -1129,7 +1131,7 @@ def parse_properties(text_to_parse: str, output_differs: bool, props_to_record:
    props = dict()

    for prop in props_to_record:
        if prop == MLD:
        if prop == MLD or prop == DMX_MLD:
            mld = float(re.search(MLD_PATTERN, text_to_parse).groups(1)[0])
            props[prop] = mld
        elif prop == MAX_ABS_DIFF or prop == DMX_DIFF:
@@ -1140,12 +1142,14 @@ def parse_properties(text_to_parse: str, output_differs: bool, props_to_record:
                else:
                    raise MaxDiffPatternNotFound()
            props[prop] = max_diff
        elif prop == SSNR:
        elif prop == SSNR or prop == DMX_SSNR:
            ssnrs = re.findall(SSNR_PATTERN, text_to_parse)
            min_ssnr = min(ssnrs)
            min_ssnr_channel = ssnrs.index(min_ssnr)
            props["MIN_SSNR"] = min_ssnr
            props["MIN_SSNR_CHANNEL"] = min_ssnr_channel

            prefix = "MIN" if prop == SSNR else "DMX"
            props[f"{prefix}_SSNR"] = min_ssnr
            props[f"{prefix}_SSNR_CHANNEL"] = min_ssnr_channel
        elif prop == ODG:
            odgs = re.findall(ODG_PATTERN, text_to_parse)
            min_odg = min(odgs)
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ ENC_CORE_OVL = "ENC_CORE_OVL"
MAX_OVL = "MAX_OVL"
MIN_OVL = "MIN_OVL"
DMX_DIFF = "DMX MAXIMUM ABS DIFF"
DMX_MLD = "DMX MLD"
DMX_SSNR = "DMX_SSNR"

# regex patterns for parsing the output from comparisons -> mainly for BASOP ci
MLD_PATTERN = r"MLD: ([\d\.]*)"