Commit 0cf4adca authored by vaclav's avatar vaclav
Browse files

Merge remote-tracking branch 'remotes/origin/sba-ext' into sba-ext-fix

parents d5c9b782 047f66a2
Loading
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -587,7 +587,6 @@ pytest-compare-20ms-and-5ms-rendering:
  script:
    - *print-common-info
    - *disable-limiter
    - *copy-ltv-files-to-testv-dir
    - make clean
    - make -j
    ### prepare pytest
@@ -957,7 +956,6 @@ ivas-interop-on-merge-request:
    - *get-commits-behind-count
    - *check-commits-behind-count-in-compare-jobs
    - *merge-request-comparison-setup-codec
    - *copy-ltv-files-to-testv-dir
    # the next line is dependent on ref-using-main flag in the other tests, but here the flag does not make sense
    - git checkout $source_branch_commit_sha

@@ -1255,7 +1253,6 @@ codec-comparison-on-main-push:
    - *get-previous-merge-commit-sha # Stored in previous_merge_commit shell variable now
    - echo "Comparing changes from $previous_merge_commit to $latest_commit"
    - git --no-pager diff --stat $previous_merge_commit..$latest_commit
    - *copy-ltv-files-to-testv-dir

    # Rest is more or less placeholder adapted from MR self test. This should be replaced with more complex tests.

@@ -1372,7 +1369,6 @@ ivas-conformance:
      - 123
  script:
    - *print-common-info-windows
    - *copy-ltv-files-to-testv-dir
    - python .\scripts\strip_split_rendering.py
    - MSBuild.exe -maxcpucount .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug    
    - cp -force IVAS_cod.exe IVAS_cod_ref.exe
+13 −0
Original line number Diff line number Diff line
@@ -1767,3 +1767,16 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_10pct.g
// OSBA planar 2OA 4ISM at 512 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM REVERB (Model from file) out
../IVAS_cod -ism_sba 4 -2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 512000 48 testv/stvOSBA_4ISM_2OA48c.wav bit
../IVAS_dec -hrtf ../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin BINAURAL_ROOM_REVERB 48 bit testv/stvOSBA_4ISM_p3OA48c.wav_BINAURAL_ROOM_REVERB_512000_48-48.tst

// SBA FOA bitrate switching from 13.2 kbps to 192 kbps, 32kHz in, 32kHz out, DTX on, EXT out
../IVAS_cod -dtx -sba 1 ../scripts/switchPaths/sw_13k2_192k_50fr.bin 32 testv/stvFOA32c.wav bit
../IVAS_dec EXT 32 bit testv/stvFOA32c.wav_sw_32-32_DTX_EXT.tst

// SBA 3OA bitrate switching from 13.2 kbps to 128 kbps, 32kHz in, 32kHz out, DTX on, EXT out
../IVAS_cod -dtx -sba 3 ../scripts/switchPaths/sw_13k2_to_128k_10fr.bin 32 testv/stv3OA32c.wav bit
../IVAS_dec EXT 32 bit testv/stv3OA32c.wav_sw_32-32_DTX_EXT.tst

// SBA 2OA bitrate switching from 13.2 kbps to 128 kbps, 48kHz in, 48kHz out, EXT out, random FER at 5%, DTX on
../IVAS_cod -dtx -sba 3 ../scripts/switchPaths/sw_13k2_to_128k_10fr.bin 48 testv/stv3OA48c.wav bit
eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error
../IVAS_dec EXT 48 bit_error testv/stv3OA48c.wav_sw_48-48_EXT_FER5.tst
+0 −159
Original line number Diff line number Diff line
__copyright__ = """
    (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
    contributors to this repository. All Rights Reserved.

    This software is protected by copyright law and by international treaties.
    The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
    Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
    Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
    Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
    contributors to this repository retain full ownership rights in their respective contributions in
    the software. This notice grants no license of any kind, including but not limited to patent
    license, nor is any license granted by implication, estoppel or otherwise.

    Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
    contributions.

    This software is provided "AS IS", without any express or implied warranties. The software is in the
    development stage. It is intended exclusively for experts who have experience with such software and
    solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
    and fitness for a particular purpose are hereby disclaimed and excluded.

    Any dispute, controversy or claim arising under or in relation to providing this software shall be
    submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
    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.
    """

__doc__ = """
    Test decoding SBA bitstreams for external output. Bitstreams
    """
import os

import pytest
from tests.conftest import DecoderFrontend, EncoderFrontend
from cut_bs import cut_from_start
from tests.cmp_pcm import cmp_pcm

# params
# test vector file names are of the format ltv48_<FOA|HOA2|HOA3>.wav
sba_orders = ["FOA", "HOA2", "HOA3"]
bitrate_list = [13200, 16400, 24400, 32000, 48000, 64000,80000, 96000, 128000, 160000, 192000, 256000, 384000, 512000]

AbsTol = "0"


def check_and_makedir(dir_path):
    if not os.path.exists(dir_path):
        try:
            os.makedirs(dir_path)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise  # raises the error again

@pytest.mark.create_ref
@pytest.mark.parametrize("sba_order", sba_orders)
@pytest.mark.parametrize("bitrate", bitrate_list)
def test_sba_ext_ctx(
    ref_encoder_frontend: EncoderFrontend,
    ref_decoder_frontend: DecoderFrontend,
    dut_decoder_frontend: DecoderFrontend,
    sba_order,
    bitrate,
    test_vector_path,
    reference_path,
    dut_base_path,
    update_ref,
    keep_files
):
    core_sba_ext_test_func(ref_encoder_frontend, ref_decoder_frontend, dut_decoder_frontend,
                           sba_order, bitrate, False, False,
                           test_vector_path, reference_path, dut_base_path,update_ref, keep_files)

@pytest.mark.create_ref
@pytest.mark.parametrize("sba_order", sba_orders)
@pytest.mark.parametrize("sid_first", [True, False])
@pytest.mark.parametrize("bitrate", [r for r in bitrate_list if r < 96000]) # dtx is not supported above 80kbps
def test_sba_ext_dtx(
    ref_encoder_frontend: EncoderFrontend,
    ref_decoder_frontend: DecoderFrontend,
    dut_decoder_frontend: DecoderFrontend,
    sba_order,
    bitrate,
    sid_first,
    test_vector_path,
    reference_path,
    dut_base_path,
    update_ref,
    keep_files
):
    core_sba_ext_test_func(ref_encoder_frontend, ref_decoder_frontend, dut_decoder_frontend,
                           sba_order, bitrate, True, sid_first,
                           test_vector_path, reference_path, dut_base_path,update_ref, keep_files)

def core_sba_ext_test_func(
    ref_encoder_frontend: EncoderFrontend,
    ref_decoder_frontend: DecoderFrontend,
    dut_decoder_frontend: DecoderFrontend,
    sba_order,
    bitrate,
    dtx,
    sid_first,
    test_vector_path,
    reference_path,
    dut_base_path,
    update_ref,
    keep_files
):
    dec_in_dir = f"{reference_path}/sba_ext/pkt"
    check_and_makedir(dec_in_dir)
    ref_wav_dir = dec_in_dir.replace("pkt", "raw")
    check_and_makedir(ref_wav_dir)
    dut_wav_dir = ref_wav_dir.replace(reference_path, dut_base_path)
    check_and_makedir(dut_wav_dir)
    fn_core = f"ltv48_{sba_order}_{bitrate}"
    if dtx:
        fn_core += "_dtx"
        if sid_first:
            fn_core += "_sidfirst_cut"
    dec_in_path = f"{dec_in_dir}/{fn_core}.g192"
    dut_wav_path = dec_in_path.replace(dec_in_dir, dut_wav_dir).replace(".g192", ".wav")
    ref_wav_path = dut_wav_path.replace(dut_wav_dir, ref_wav_dir)
    print(ref_wav_path)
    out_config = ""
    enc_sba_order = ""
    match sba_order:
        case "FOA":
            enc_sba_order = "+1"
            out_config = "FOA"
        case "HOA2":
            enc_sba_order = "+2"
            out_config = "HOA2"
        case "HOA3":
            enc_sba_order = "+3"
            out_config = "HOA3"
        case _:
            print(f"Unsupported SBA order: {sba_order}")
            assert(False)
    if update_ref == 1:
        input_path = f"{test_vector_path}/ltv48_{sba_order}.wav"
        enc_out_path = dec_in_path.replace('_cut', '')
        ref_encoder_frontend.run(bitrate, 48, input_path, enc_out_path, enc_sba_order, dtx_mode=dtx)
        if sid_first:
            with open(enc_out_path, "rb") as fp_in:
                with open(dec_in_path, "wb") as fp_out:
                    fr_cnt, cut_cnt = cut_from_start(fp_in, fp_out, 0, True)
                    assert fr_cnt > cut_cnt
            if keep_files == 0:
                os.remove(enc_out_path)
        ref_decoder_frontend.run(out_config, 48, dec_in_path, ref_wav_path)
    else:
        dut_decoder_frontend.run("EXT", 48, dec_in_path, dut_wav_path)
        cmp_result, reason = cmp_pcm(ref_wav_path, dut_wav_path, out_config, 48000, abs_tol=AbsTol)
        assert(cmp_result == 0)
        assert(True)
        if keep_files == 0:
            os.remove(dut_wav_path)