Commit 8acb9b22 authored by sagnowski's avatar sagnowski
Browse files

Add test for LC3plus framing reconfiguration

parent 24b215da
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -82,6 +82,9 @@ RENDERER_CONFIGS_FASTCONV_RENDERER = [
RENDERER_CONFIGS_FRAMING = [
    str(cfg.stem) for cfg in RENDER_FRAMING_CFG_DIR.glob("framing*.txt")
]
RENDERER_CONFIGS_FRAMING_LC3PLUS = [
    str(cfg.stem) for cfg in RENDER_FRAMING_CFG_DIR.glob("framing_lc3plus*.txt")
]

RENDERER_CONFIGS_TO_TEST_AMBI = (
    RENDERER_CONFIGS_DEFAULT_CODEC + RENDERER_CONFIGS_LC3PLUS_CODEC
+35 −0
Original line number Diff line number Diff line
@@ -740,3 +740,38 @@ def test_framing_combinations_full_chain_split(
        get_odg_bin=get_odg_bin,
        delay_profile=SCRIPTS_DIR / "dly_error_profiles" / f"{delay_profile}.dat" if delay_profile else None,
    )


"""
Tests cases where the transport codec framing information is incorrect and the LC3plus decoder needs
to reconfigure on the first frame. Required for RTP use cases.
"""
@pytest.mark.parametrize("render_config", RENDERER_CONFIGS_FRAMING_LC3PLUS)
@pytest.mark.parametrize("pre_rend_fr", SPLIT_RENDERER_PRE_FRAMINGS)
@pytest.mark.parametrize("post_rend_fr", SPLIT_RENDERER_POST_FRAMINGS)
@pytest.mark.parametrize("patch_codec_frame_size_ms", [5, 10])
def test_lc3plus_framing_reconfiguration(
    record_property,
    props_to_record,
    test_info,
    render_config,
    post_rend_fr,
    pre_rend_fr,
    patch_codec_frame_size_ms,
):
    post_trajectory = HR_TRAJECTORY_DIR.joinpath("rotate_euler_quaternion_30s.csv")
    pre_trajectory = post_trajectory.with_stem(f"{post_trajectory.stem}_delayed")

    run_external_split_rendering(
        record_property,
        props_to_record,
        test_info,
        in_fmt="5_1",
        render_config=RENDER_FRAMING_CFG_DIR.joinpath(f"{render_config}.txt"),
        pre_trajectory=pre_trajectory,
        post_trajectory=post_trajectory,
        binary_suffix=EXE_SUFFIX,
        post_rend_fr=post_rend_fr,
        pre_rend_fr=pre_rend_fr,
        patch_codec_frame_size_ms=patch_codec_frame_size_ms
    )
+27 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ from ..conftest import parse_properties

sys.path.append(SCRIPTS_DIR)
from pyaudio3dtools.audiofile import readfile, writefile
from split_rendering.isar_bstool import IsarBitstream


def lc3plus_used(test_info, in_fmt, render_config):
@@ -345,6 +346,7 @@ def run_external_split_rendering(
    get_ssnr=False,
    get_odg=False,
    get_odg_bin=False,
    patch_codec_frame_size_ms: int | None = None,
) -> Tuple[np.ndarray, int]:
    """
    Runs the exeternal split rendering chain consisting of
@@ -362,6 +364,9 @@ def run_external_split_rendering(
        if plc_error_pattern:
            filename_base += f"_plc_{plc_error_pattern.stem}"

        if patch_codec_frame_size_ms:
            filename_base += f"_tcfrmod_{patch_codec_frame_size_ms}ms"

        split_bitstream_stem = f"{filename_base}.splt.bit"
        if renderer_fmt == "BINAURAL_SPLIT_PCM":
            split_md_file_stem = f"{filename_base}.spltmd.bit"
@@ -415,6 +420,14 @@ def run_external_split_rendering(

        run_isar_ext_rend_cmd(split_pre_cmd, test_info=test_info)

        # If patch_codec_frame_size_ms is set, overwrite the frame size in the split bitstream
        # header with the provided value. This tests LC3plus framing reconfiguration.
        if patch_codec_frame_size_ms:
            isar_bs = IsarBitstream(split_bitstream)
            isar_bs.header.codec_frame_size_ms = patch_codec_frame_size_ms
            split_bitstream_mod = split_bitstream.with_stem(split_bitstream.stem + f"_patched")
            isar_bs.write(split_bitstream_mod)

        # run ISAR post-renderer
        split_post_cmd = SPLIT_POST_REND_CMD[:]

@@ -435,6 +448,20 @@ def run_external_split_rendering(

        run_isar_ext_rend_cmd(split_post_cmd, test_info=test_info)

        if patch_codec_frame_size_ms:
            split_post_cmd[4] = str(split_bitstream_mod)
            out_file_mod = out_file.with_stem(out_file.stem + f"_patched")
            split_post_cmd[8] = str(out_file_mod)
            run_isar_ext_rend_cmd(split_post_cmd, test_info=test_info)
            output_differs, reason = cmp_pcm(
                out_file,
                out_file_mod,
                2,  # is always "BINAURAL",
                48000,  # currently only 48 kHz tests
            )
            if output_differs[0]:
                pytest.fail(f"ISAR output differs when codec frame size in bitstream is patched: ({reason[0]})")

    if test_info.config.option.create_cut:
        # CUT creation mode will run a comparison with REF
        out_file_ref = OUTPUT_PATH_REF.joinpath(out_file_stem)