Commit 52118eee authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch '744_step3_code_changes' of...

Merge branch '744_step3_code_changes' of forge.3gpp.org:ivas-codec-pc/ivas-codec into 744_step4_hrtf_binary_tests
parents 5a049722 8a5f643a
Loading
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -797,6 +797,18 @@ int main(
#ifdef NONBE_FIX_BINARY_BINAURAL_READING
        if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK )
        {
#ifdef FIX_OLD_BINARY_FORMAT
            cleanup_SetOfHRTF( hSetOfHRTF );
            hrtfFileReader_close( &hrtfReader );
            strcat( arg.hrtfFileName, "new" );

            if ( hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName );
                goto cleanup;
            }
            if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK )
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName );
@@ -807,6 +819,18 @@ int main(
                    destroy_SetOfHRTF( hSetOfHRTF );
                }
            }
#else
            if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
            {
                fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName );
                goto cleanup;
            }
            else
            {
                destroy_SetOfHRTF( hSetOfHRTF );
            }
#endif
        }
#else
        if ( ( error = create_SetOfHRTF_from_binary( hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK )
        {
+35 −12
Original line number Diff line number Diff line
@@ -1036,7 +1036,7 @@ int main(
        {
            if ( ( error = IVAS_REND_GetHrtfHandle( hIvasRend, &hHrtfTD ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_REND_GetHrtfHandle failed\n\n" );
                fprintf( stderr, "\nIVAS_REND_GetHrtfHandle failed: %s\n\n", ivas_error_to_string( error ) );
                goto cleanup;
            }

@@ -1049,14 +1049,14 @@ int main(
                    strcat( args.customHrtfFilePath, "new" );
                    if ( hrtfFileReader_open( args.customHrtfFilePath, &hrtfFileReader ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", args.customHrtfFilePath );
                        fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                        goto cleanup;
                    }
                    if ( ( error = load_HRTF_binary( *hHrtfTD, hrtfFileReader ) ) != IVAS_ERR_OK )
                    {
                        if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                        {
                            fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", args.customHrtfFilePath );
                            fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                            goto cleanup;
                        }
                        else
@@ -1065,7 +1065,7 @@ int main(
                        }
                    }
#else
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", args.customHrtfFilePath );
                    fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                    goto cleanup;
#endif
                }
@@ -1080,7 +1080,7 @@ int main(
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", args.customHrtfFilePath );
                    fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                    goto cleanup;
                }
            }
@@ -1088,26 +1088,49 @@ int main(

            if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_Rend_GetHrtfCRendHandle failed\n\n" );
                fprintf( stderr, "\nIVAS_Rend_GetHrtfCRendHandle failed: %s\n\n", ivas_error_to_string( error ) );
                goto cleanup;
            }

            if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfFileReader, args.sampleRate ) ) != IVAS_ERR_OK )
            {
#ifdef FIX_OLD_BINARY_FORMAT
                cleanup_SetOfHRTF( hSetOfHRTF );
                hrtfFileReader_close( &hrtfFileReader );
                strcat( args.customHrtfFilePath, "new" );
                if ( hrtfFileReader_open( args.customHrtfFilePath, &hrtfFileReader ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                    goto cleanup;
                }
                if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfFileReader, args.sampleRate ) ) != IVAS_ERR_OK )
                {
                    if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                    {
                        fprintf( stderr, "\nError in loading HRTF binary file %s:%s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                        goto cleanup;
                    }
                    else
                    {
                        destroy_SetOfHRTF( hSetOfHRTF );
                    }
                }
#else
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", args.customHrtfFilePath );
                    fprintf( stderr, "\nError in loading HRTF binary file %s:%s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                    goto cleanup;
                }
                else
                {
                    destroy_SetOfHRTF( hSetOfHRTF );
                }
#endif
            }

            if ( ( error = IVAS_REND_GetHrtfFastConvHandle( hIvasRend, &hHrtfFastConv ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_REND_GetHrtfFastConvHandle failed\n\n" );
                fprintf( stderr, "\nIVAS_REND_GetHrtfFastConvHandle failed: %s\n\n", ivas_error_to_string( error ) );
                goto cleanup;
            }

@@ -1115,7 +1138,7 @@ int main(
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", args.customHrtfFilePath );
                    fprintf( stderr, "\nError in loading HRTF binary file %s:%s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                    goto cleanup;
                }
                else
@@ -1126,7 +1149,7 @@ int main(

            if ( ( error = IVAS_REND_GetHrtfParamBinHandle( hIvasRend, &hHrtfParambin ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_GetHrtfParamBinHandle failed\n\n" );
                fprintf( stderr, "\nIVAS_DEC_GetHrtfParamBinHandle failed: %s\n\n", ivas_error_to_string( error ) );
                goto cleanup;
            }

@@ -1134,7 +1157,7 @@ int main(
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", args.customHrtfFilePath );
                    fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) );
                    goto cleanup;
                }
                else
@@ -1151,7 +1174,7 @@ int main(
    /* === Configure === */
    if ( ( error = IVAS_REND_InitConfig( hIvasRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "Error in Renderer Config Init\n" );
        fprintf( stderr, "Error in Renderer Config Init: %s\n", ivas_error_to_string( error ) );
        exit( -1 );
    }

+70 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
"""
   (C) 2022-2023 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.
"""

import argparse
import numpy as np


ERR_MAGIC_NUM_DLY_PROF = -1
ERR_MAGIC_NUM_G192 = 27424


def combine_error_profiles(genpatt_file, jbm_dly_profile, output_file):
    ep = np.fromfile(genpatt_file, dtype="int16")
    with open(jbm_dly_profile) as f:
        dly = np.asarray([int(l.strip()) for l in f.readlines()])

    # if one wants to differently-sized files, add wraparound/shorten logic here
    # in ci, file lengths will match
    assert len(ep) == len(dly)

    # remove lost frames already in the dly profile
    # replace with no delay (not there in the profile files, except the all-zero one)
    err_idx = np.where(dly == ERR_MAGIC_NUM_DLY_PROF)[0]
    dly[err_idx] = 0

    # insert lost frames based on .g192 file
    err_idx = np.where(ep == ERR_MAGIC_NUM_G192)[0]
    dly[err_idx] = -1
    
    with open(output_file, "w") as f:
        for d in dly:
            f.write(f"{int(d)}\n")


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("genpatt_file")
    parser.add_argument("jbm_dly_profile")
    parser.add_argument("output_file")
    args = parser.parse_args()

    combine_error_profiles(**vars(args))
+9 −6
Original line number Diff line number Diff line
@@ -40,19 +40,21 @@ from collect_artifacts import (
    find_failed_files_for_sanitizer_test,
    collect_for_sanitizer_test,
)
from combine_genpatt_and_jbm_profile import combine_error_profiles


SCRIPT_DIR = pathlib.Path("./scripts").resolve()
DURATION = "120"
CFG = "ci_linux_ltv.json"
SUPPORTED_TESTS = ["CLANG1", "CLANG2", "CLANG3", "VALGRIND"]
EP_FILE = "ep_015.g192"
GENPATT_CMD = f"gen-patt -tailstat -fer -g192 -gamma 0 -rate 0.15 -tol 0.001 -reset -n {int(DURATION) * 50} {EP_FILE}"
EIDXOR_CMD = "eid-xor -vbr -fer {bitstream} {ep_file} {out_file}"
DLY_PROFILE_IN = SCRIPT_DIR.joinpath("dly_error_profiles/dly_error_profile_5.dat")
DLY_PROFILE_OUT = "dly_profile.dat"
N_FRAMES_DLY_PROFILE = 7500
GENPATT_CMD = f"gen-patt -tailstat -fer -g192 -gamma 0 -rate 0.15 -tol 0.001 -reset -n {N_FRAMES_DLY_PROFILE} {EP_FILE}"
MC_MODES = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"]
AMBISONICS_MODES = ["HOA3", "HOA2", "FOA", "PlanarHOA3", "PlanarHOA2", "PlanarFOA"]

SCRIPT_DIR = pathlib.Path("./scripts").resolve()

CONSOLE_OUT_FILE = "output_san.txt"


@@ -186,6 +188,7 @@ def run_check(in_format: str, out_formats: list, tests: list, run_fec: bool = Tr

    # generate error pattern
    subprocess.call(GENPATT_CMD.split())
    combine_error_profiles(EP_FILE, DLY_PROFILE_IN, DLY_PROFILE_OUT)

    # cleanup to avoid script errors
    # we want "logs" and "dec" subfolders to be empty -> delete "dec" and rename "log"
@@ -203,10 +206,10 @@ def run_check(in_format: str, out_formats: list, tests: list, run_fec: bool = Tr
            # need empty log folder to avoid crashes
            path.mkdir()

    cmd_fec = cmd_no_fec + ["--decoder_only", "-f", EP_FILE]
    cmd_fec = cmd_no_fec + ["--decoder_only", "-J", DLY_PROFILE_OUT]
    print(
        "======== Script command line WITH plc: ========\n{}".format(
            " ".join(cmd_no_fec)
            " ".join(cmd_fec)
        )
    )

+7 −0
Original line number Diff line number Diff line
@@ -328,6 +328,10 @@ typedef enum
#define ISM_Q_STEP                              2.5f
#define ISM_Q_STEP_BORDER                       5.0f

#ifdef NONBE_FIX_944_FEC_OMASA_1SEP_OBJ_MASA
#define ISM_FEC_MAX                             10
#endif

#define ISM_RADIUS_NBITS                        6 
#define ISM_RADIUS_MIN                          0.0f
#define ISM_RADIUS_DELTA                        0.25f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */
@@ -1552,6 +1556,9 @@ typedef enum
#define MAX_SPLIT_MD_SUBFRAMES                  1
#define COMPLEX_MD_BAND_THRESH                  MAX_SPLIT_REND_MD_BANDS
#define COMPLEX_MD_BAND_THRESH_LOW              5
#ifdef SPLIT_REND_HF_TUNING
#define SPLIT_REND_RO_MD_BAND_THRESH            4
#endif

#define IVAS_SPLIT_REND_NUM_QUANT_STRATS        4
#define IVAS_SPLIT_REND_PRED_63QUANT_PNTS       63
Loading