From 3e336076bb70a311eae8fd68c9788760a7a5934c Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Fri, 5 Aug 2022 12:00:46 +0200 Subject: [PATCH 01/15] Move prox mixing to the decoder. --- Workspace_msvc/lib_dec.vcxproj | 2 + Workspace_msvc/lib_dec.vcxproj.filters | 6 + lib_com/options.h | 4 + lib_dec/ivas_mono_dmx_renderer.c | 52 +++++ .../crend => lib_dec}/ivas_prox_mix.c | 10 +- .../crend => lib_dec}/ivas_prox_mix.h | 6 +- lib_dec/ivas_stat_dec.h | 5 + .../unit_tests/crend/ivas_crend_io_parse.h | 2 - .../unit_tests/crend/ivas_crend_public.h | 2 - .../unit_tests/crend/ivas_crend_unit_test.c | 149 ------------- .../crend/ivas_crend_unit_test.vcxproj | 2 - .../unit_tests/crend/ivas_crend_utest_utils.c | 211 +----------------- 12 files changed, 78 insertions(+), 373 deletions(-) rename {scripts/ivas_pytests/tests/unit_tests/crend => lib_dec}/ivas_prox_mix.c (98%) rename {scripts/ivas_pytests/tests/unit_tests/crend => lib_dec}/ivas_prox_mix.h (93%) diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 3bde19ca47..36b79679c5 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -307,6 +307,7 @@ + @@ -392,6 +393,7 @@ + diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index 155b8dfc45..304a7f34c9 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -581,6 +581,9 @@ dec_ivas_c + + dec_ivas_c + @@ -629,6 +632,9 @@ dec_h + + dec_h + diff --git a/lib_com/options.h b/lib_com/options.h index 3ce2968c02..6c7ecc994e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -58,6 +58,8 @@ #ifdef DEBUGGING +#define DEBUG_PROX_MIX_INFO + /*#define MEM_COUNT_DETAILS*/ /* RAM counting tool: print per sub-structure details */ /*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */ @@ -132,6 +134,8 @@ /* ################# Start DEVELOPMENT switches ######################## */ +/* #define ENABLE_PROX_BASED_MIXING */ /* Enable proximity-based mixing */ + #define BASOP_NOGLOB /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */ #define BITSTREAM_INDICES_MEMORY /* Don't count memory for bitstream Indice at the encoder - it is a temporary solution for development only */ diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 468b0215b0..77aad285aa 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -39,6 +39,9 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" +#ifdef ENABLE_PROX_BASED_MIXING +#include "ivas_prox_mix.h" +#endif /* ENABLE_PROX_BASED_MIXING */ #include "wmops.h" @@ -50,6 +53,10 @@ #define DOWNMIX_MAX_GAIN 4.0f /* Maximum allowed gain */ #define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4 +#ifdef ENABLE_PROX_BASED_MIXING +#define PROXIMITY_USER_ID ( 0 ) +const uint8_t bitstream[] = { 0x00, 0x01, 0x80, 0x02, 0x80 }; +#endif /* ENABLE_PROX_BASED_MIXING */ /*------------------------------------------------------------------------- * ivas_mono_dmx_renderer_open() @@ -73,6 +80,22 @@ ivas_error ivas_mono_dmx_renderer_open( st_ivas->hMonoDmxRenderer = hDownmix; +#ifdef ENABLE_PROX_BASED_MIXING + set_zero( hDownmix->powvec, MAX_INPUT_CHANNELS ); + set_zero( hDownmix->Smixer, MAX_INPUT_CHANNELS ); + set_s( hDownmix->userLoc, 0, MAX_INPUT_CHANNELS ); + + /* using bitstream information fill in the location in the userLoc vector */ + get_users_locations( bitstream, sizeof( bitstream ), hDownmix->userLoc ); + +#ifdef DEBUG_PROX_MIX_INFO + for(int i = 0 ; i < MAX_INPUT_CHANNELS; i++) + { + printf("\n i = %d, userLoc = %d \n", i, hDownmix->userLoc[i] ); + } +#endif /* DEBUG_PROX_MIX_INFO */ +#endif /* ENABLE_PROX_BASED_MIXING */ + return IVAS_ERR_OK; } @@ -97,11 +120,36 @@ void ivas_mono_downmix_render_passive( hDownmix = st_ivas->hMonoDmxRenderer; set_zero( proto_signal, output_frame ); +#ifdef ENABLE_PROX_BASED_MIXING + /* get the mixing matrix.. */ + get_prox_downmix_mixer( ( int16_t )PROXIMITY_USER_ID, hDownmix->Smixer, hDownmix->userLoc, numInputChannels, output_f, output_frame, hDownmix->powvec ); + +#ifdef DEBUG_PROX_MIX_INFO + printf("\n\n hDownmix->Smixer = "); + for(int i = 0; i < numInputChannels; i++) + printf( "%.8f ", hDownmix->Smixer[i] ); + + printf("\n hDownmix->powvec = "); + for(int i = 0; i < numInputChannels; i++) + printf( "%.6e ", hDownmix->powvec[i] ); + + printf("\n"); +#endif /* DEBUG_PROX_MIX_INFO */ + + /* Compute the Proto Signal */ + for ( i = 0; i < numInputChannels; i++ ) + { + float temp[L_FRAME48k]; + v_multc( output_f[i], hDownmix->Smixer[i], temp, output_frame ); + v_add( temp, proto_signal, proto_signal, output_frame ); + } +#else /* ENABLE_PROX_BASED_MIXING */ /* Compute the Proto Signal */ for ( i = 0; i < numInputChannels; i++ ) { v_add( output_f[i], proto_signal, proto_signal, output_frame ); } +#endif /* ENABLE_PROX_BASED_MIXING */ /* compute the input energy, proto energy after smoothing */ hDownmix->inputEnergy[0] *= DOWNMIX_ALPHA; @@ -111,7 +159,11 @@ void ivas_mono_downmix_render_passive( hDownmix->protoEnergy[0] += proto_signal[i] * proto_signal[i]; for ( j = 0; j < numInputChannels; j++ ) { +#ifndef ENABLE_PROX_BASED_MIXING hDownmix->inputEnergy[0] += ( output_f[j][i] * output_f[j][i] ); +#else + hDownmix->inputEnergy[0] += ( output_f[j][i] * output_f[j][i] * hDownmix->Smixer[j] * hDownmix->Smixer[j] ); +#endif } } diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.c b/lib_dec/ivas_prox_mix.c similarity index 98% rename from scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.c rename to lib_dec/ivas_prox_mix.c index 2bf19080e5..b2780753dd 100644 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.c +++ b/lib_dec/ivas_prox_mix.c @@ -80,8 +80,8 @@ static float get_block_power( float *vec, int32_t frame_len ); * *-----------------------------------------------------------------------------------------*/ -ivas_result_t get_users_locations( - uint8_t *bitstream, +ivas_error get_users_locations( + const uint8_t *bitstream, int32_t len, int16_t *userLoc ) { @@ -103,11 +103,11 @@ ivas_result_t get_users_locations( } } - return IVAS_SUCCESS; + return IVAS_ERR_OK; } -ivas_result_t get_prox_downmix_mixer( +ivas_error get_prox_downmix_mixer( int16_t userID, float *sMixer, int16_t *userLoc, @@ -209,7 +209,7 @@ ivas_result_t get_prox_downmix_mixer( } free( pow ); - return IVAS_SUCCESS; + return IVAS_ERR_OK; } diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.h b/lib_dec/ivas_prox_mix.h similarity index 93% rename from scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.h rename to lib_dec/ivas_prox_mix.h index 8aa4b57130..3caca280c4 100644 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_prox_mix.h +++ b/lib_dec/ivas_prox_mix.h @@ -47,7 +47,7 @@ #include "stdlib.h" #include "string.h" #include "ivas_stat_dec.h" -#include "ivas_result_t.h" +#include "ivas_error.h" /*------------------------------------------------------------------------------------------* * PreProcessor @@ -65,7 +65,7 @@ /*------------------------------------------------------------------------------------------* * function declarations *------------------------------------------------------------------------------------------*/ -ivas_result_t get_users_locations( uint8_t *bitstream, int32_t len, int16_t *userLoc ); -ivas_result_t get_prox_downmix_mixer( int16_t userID, float *pMixer, int16_t *userLoc, int32_t nChan, float ppPcm_in[][L_FRAME48k], int32_t frame_len, float *powvec ); +ivas_error get_users_locations( const uint8_t *bitstream, int32_t len, int16_t *userLoc ); +ivas_error get_prox_downmix_mixer( int16_t userID, float *pMixer, int16_t *userLoc, int32_t nChan, float ppPcm_in[][L_FRAME48k], int32_t frame_len, float *powvec ); #endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 18fc4b4741..f78c20d9cb 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1146,6 +1146,11 @@ typedef struct ivas_mono_downmix_renderer_struct { float inputEnergy[CLDFB_NO_CHANNELS_MAX]; float protoEnergy[CLDFB_NO_CHANNELS_MAX]; +#ifdef ENABLE_PROX_BASED_MIXING + float Smixer[MAX_INPUT_CHANNELS]; + float powvec[MAX_INPUT_CHANNELS]; + int16_t userLoc[MAX_INPUT_CHANNELS]; +#endif /* ENABLE_PROX_BASED_MIXING */ } MONO_DOWNMIX_RENDERER_STRUCT, *MONO_DOWNMIX_RENDERER_HANDLE; diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_io_parse.h b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_io_parse.h index 21b59ad06f..651de9408d 100644 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_io_parse.h +++ b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_io_parse.h @@ -76,7 +76,6 @@ typedef enum test_types FASTCONV_BIN_TEST, PARAM_BIN_TEST, TD_BIN_TEST, - CREND_ACOUSTIC_PROXIMITY, CREND_TEST_NO_DIEGETIC, CREND_NUM_TESTS } test_types; @@ -106,7 +105,6 @@ typedef struct ivas_crend_io_params_t char ref_path[IVAS_MAX_PATH_LEN]; char in_path[IVAS_MAX_PATH_LEN]; char out_path[IVAS_MAX_PATH_LEN]; - char prox_path[IVAS_MAX_PATH_LEN]; char csv_path[IVAS_MAX_PATH_LEN]; float latency_s; int32_t use_brir; diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_public.h b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_public.h index 057cfba10a..6406d047fd 100644 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_public.h +++ b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_public.h @@ -78,8 +78,6 @@ int32_t ivas_wrapper_get_frame_len( int32_t sample_rate ); ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, float *mixer ); -ivas_result_t ivas_object_mixer_renderer( ivas_crend_io_params_t *pIo_params, int16_t *userLoc ); - ivas_result_t ivas_wav_header_skip( FILE *in_file ); #endif /* IVAS_CREND_PUBLIC_H */ diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.c b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.c index b2a24534c0..7b124c9890 100644 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.c +++ b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.c @@ -48,7 +48,6 @@ #include "ivas_crend_public.h" #include "ivas_crend_unit_test.h" #include "ivas_stat_dec.h" -#include "ivas_prox_mix.h" #include "prot.h" #include "ivas_prot.h" @@ -242,151 +241,7 @@ static ivas_result_t ivas_crend_reverb_test( ivas_crend_io_params_t *pIo_params return IVAS_SUCCESS; } -/*-----------------------------------------------------------------------------------------* - * Function description - - * common function call for ivas_crend_proximity_test which tests the proximity mixer - * - * Inputs - - * ivas_crend_io_params_t io_params - * - * Outputs - - * - *-----------------------------------------------------------------------------------------*/ -static ivas_result_t ivas_crend_proximity_test( ivas_crend_io_params_t *pIo_params ) -{ - int16_t *userLoc; - int32_t in_ch; -#ifdef USE_PCM_OUT - size_t num; -#else - int16_t num; -#endif - int16_t out = 0, test = PASS; - int16_t ref; - - float out_0f, acc_0f; - - uint8_t bitstream[MAX_BITSTREAM_LEN]; - - assert( pIo_params->in_fmt == OBA ); - assert( pIo_params->out_fmt == MONO_1 ); - - in_ch = ivas_get_num_channels( pIo_params->in_fmt ); - - /* allocate up to in_ch users to userLoc array */ - userLoc = (int16_t *) calloc( in_ch, sizeof( int16_t ) ); - - /* load bitstream data */ - num = (int16_t)fread( bitstream, sizeof( uint8_t ), MAX_BITSTREAM_LEN, pIo_params->fProx ); - - /* using bitstream information fill in the location in the userLoc vector */ - get_users_locations( bitstream, num, userLoc ); - - /* call the object mixer-renderer */ - ivas_object_mixer_renderer( pIo_params, userLoc ); - - free( userLoc ); - -#ifdef USE_PCM_OUT - int32_t i; - for (i = 0; i < in_ch; i++) - { - fseek(pIo_params->fRef, 0, SEEK_SET); - ivas_wav_header_skip(pIo_params->fRef); - } -#endif -#ifdef USE_PCM_OUT - if ( pIo_params->fRef ) - { - fseek( pIo_params->fRef, 0, SEEK_SET ); - fseek( pIo_params->fOut, 0, SEEK_SET ); - if ( strstr( pIo_params->ref_path, ".wav" ) != NULL ) - { - ivas_wav_header_skip( pIo_params->fRef ); - } - while ( 1 ) - { - acc_0f = 0.0f; - /* read reference channel correspnding to the given user in USER_ID */ - if ( fread( &ref, sizeof( int16_t ), 1, pIo_params->fRef ) <= 0 ) - { - printf( "Ref file finished\n" ); - goto DONE; - } - acc_0f = (float) ( ref ) * ( 1.0 / PCM16_TO_FLT_FAC ); - - /* compare to output from object mixer-renderer call above */ - if ( fread( &out, sizeof( int16_t ), 1, pIo_params->fOut ) <= 0 ) - { - printf( "Output file finished\n" ); - goto DONE; - } - out_0f = (float) ( out ) * ( 1.0 / PCM16_TO_FLT_FAC ); - /* check if much different.. */ - if ( fabs( out_0f - acc_0f ) > TC_TOL ) - { - test = FAIL; - } - } - } -#else - if ( pIo_params->fRef ) - { - int16_t numRead; - AudioFileReader_close( &pIo_params->fRef ); - AudioFileWriter_close( &pIo_params->fOut ); - AudioFileReader *fRef, *fOut; - AudioFileReader_open( &fOut, pIo_params->out_path, pIo_params->sample_rate ); - AudioFileReader_open( &fRef, pIo_params->ref_path, pIo_params->sample_rate ); - while ( 1 ) - { - acc_0f = 0.0f; - /* read reference channel correspnding to the given user in USER_ID */ - if ( (AudioFileReader_read( fRef , &ref, 1, &numRead ) != IVAS_ERR_OK) || (numRead == 0) ) - { - printf( "Ref file finished\n" ); - goto DONE; - } - acc_0f = (float) ( ref ) * ( 1.0 / PCM16_TO_FLT_FAC ); - - /* compare to output from object mixer-renderer call above */ - if ( ( AudioFileReader_read( fOut, &out, 1, &numRead ) != IVAS_ERR_OK ) || ( numRead == 0 ) ) - { - printf( "Output file finished\n" ); - goto DONE; - } - out_0f = (float) ( out ) * ( 1.0 / PCM16_TO_FLT_FAC ); - - /* check if much different.. */ - if ( fabs( out_0f - acc_0f ) > TC_TOL ) - { - test = FAIL; - } - } - AudioFileReader_close( &fOut ); - AudioFileReader_close( &fRef ); - } - - - -#endif -DONE: - if ( test == PASS ) - { - printf( "%s PASSED\n\n", "CREND_PROXIMITY" ); - } - else - { - printf( "%s FAILED\n\n", "CREND_PROXIMITY" ); - exit( -1 ); - } - if ( pIo_params->fProx ) - { - fclose( pIo_params->fProx ); - } - return IVAS_SUCCESS; -} /*-----------------------------------------------------------------------------------------* * Function description - * function call for ivas_crend_binaural_test @@ -686,7 +541,6 @@ int main( int argc, char **argv ) if ( io_params.in_path[0] != '\0' ) { if ( - io_params.test == CREND_ACOUSTIC_PROXIMITY || io_params.test == CREND_BIN_TEST || io_params.test == FASTCONV_BIN_TEST || io_params.test == PARAM_BIN_TEST || @@ -698,9 +552,6 @@ int main( int argc, char **argv ) } switch ( io_params.test ) { - case CREND_ACOUSTIC_PROXIMITY: - ivas_crend_proximity_test( &io_params ); - break; case CREND_BIN_TEST: case FASTCONV_BIN_TEST: case PARAM_BIN_TEST: diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.vcxproj b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.vcxproj index 3d8e7ab07f..2be2a1b762 100644 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.vcxproj +++ b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_unit_test.vcxproj @@ -27,13 +27,11 @@ - - {32354377-ACA7-40F9-9A0E-87FC956F0B78} diff --git a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c index d993405b11..bf75f093c6 100644 --- a/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c +++ b/scripts/ivas_pytests/tests/unit_tests/crend/ivas_crend_utest_utils.c @@ -49,7 +49,6 @@ #include "ivas_dec_parse_io.h" #include "ivas_crend_public.h" #include "ivas_stat_dec.h" -#include "ivas_prox_mix.h" #include "prot.h" #include "ivas_prot.h" #include "cmdl_tools.h" @@ -476,17 +475,6 @@ void ivas_open_files_crend( ivas_crend_io_params_t *pIo_params ) } }*/ - - if ( pIo_params->test == CREND_ACOUSTIC_PROXIMITY ) - { - /* open proximity bitstream file */ - if ( ( pIo_params->fProx = fopen( pIo_params->prox_path, "rb" ) ) == NULL ) - { - fprintf( stderr, "Error: LocSharing bitstream file %s could not be opened\n\n", pIo_params->prox_path ); - ivas_crend_unit_test_usage(); - } - } - fprintf( stdout, "prox file or path: %s\n", pIo_params->prox_path ); } /*-----------------------------------------------------------------------------------------* @@ -599,25 +587,6 @@ ivas_result_t ivas_crend_parse_io_params( int argc, char **argv, ivas_crend_io_p mandatory_args++; } - /*-----------------------------------------------------------------* - * Proximity file - *------------------------------------------------------------------*/ - else if ( strcmp( to_upper( argv[i] ), "-PROX" ) == 0 ) - { - if ( strlen( argv[++i] ) > IVAS_MAX_PATH_LEN ) - { - fprintf( stderr, "Error: input proximity path %s too big\n\n", argv[i] ); - ivas_crend_unit_test_usage(); - } - strcpy( pIo_params->prox_path, argv[i] ); - if ( pIo_params->prox_path[0] == '\0' ) - { - fprintf( stderr, "Error: input proximity folder %s could not be opened\n\n", argv[i] ); - ivas_crend_unit_test_usage(); - } - i++; - optional_args++; - } /*-----------------------------------------------------------------* * Input csv file *-----------------------------------------------------------------*/ @@ -861,7 +830,7 @@ static ivas_result_t ivas_wrapper_get_in_buf( ivas_crend_io_params_t *pIo_params int16_t tmp, read = 0; num_in_ch = ivas_get_num_channels( pIo_params->in_fmt ); - if ( pIo_params->test == CREND_BIN_TEST || pIo_params->test == FASTCONV_BIN_TEST || pIo_params->test == PARAM_BIN_TEST || pIo_params->test == TD_BIN_TEST || pIo_params->test == CREND_ACOUSTIC_PROXIMITY) + if ( pIo_params->test == CREND_BIN_TEST || pIo_params->test == FASTCONV_BIN_TEST || pIo_params->test == PARAM_BIN_TEST || pIo_params->test == TD_BIN_TEST ) { /* Read in PCM */ for ( j = 0; j < input_frame_len; j++ ) @@ -1635,181 +1604,3 @@ ivas_result_t ivas_common_mixer_renderer( ivas_crend_io_params_t *pIo_params, fl return IVAS_SUCCESS; } - -/*-----------------------------------------------------------------------------------------* - * Function description - - * Object mixer renderer block - * - * Inputs - - * ivas_enc_io_params_t io_params - * - * Outputs - - * - *-----------------------------------------------------------------------------------------*/ -ivas_result_t ivas_object_mixer_renderer( ivas_crend_io_params_t *pIo_params, int16_t *userLoc ) -{ - ivas_result_t result = IVAS_SUCCESS; - - float ppPcm_in[IVAS_MAX_NUM_CH][L_FRAME48k]; - float ppPcm_out[IVAS_MAX_NUM_CH][L_FRAME48k]; - DECODER_CONFIG decoder_config; - Decoder_Struct st_ivas; - - memset( &st_ivas, 0, sizeof( Decoder_Struct ) ); - - st_ivas.hDecoderConfig = &decoder_config; - memset( st_ivas.hDecoderConfig, 0, sizeof( DECODER_CONFIG ) ); - - int64_t frame_count = 0; - - int32_t i = 0, j = 0; - int32_t frame_len = 0; - - float *Smixer; - float *powvec; - ivas_dec_io_params_t dec_io_params = { 0 }; - int16_t in_format; - int16_t lfe_ch_idx; - - ivas_dec_default_io_params( &dec_io_params ); - ivas_copy_io_params_to_dec_io_params( pIo_params, &dec_io_params ); - - frame_len = ivas_wrapper_get_frame_len( pIo_params->sample_rate ); - -#ifdef USE_PCM_OUT - /* skip WAV header */ - for ( i = 0; i < IVAS_MAX_NUM_CH; i++ ) - { - if ( pIo_params->fIn[i] != NULL ) - { - result = ivas_wav_header_skip( pIo_params->fIn[i] ); - - if ( IVAS_SUCCESS != result ) - { - fprintf( stderr, "WAV header skip failed\n" ); - ivas_crend_close( &st_ivas ); - exit( -1 ); - } - } - } -#endif - - result = ivas_crend_set_config_params( &decoder_config, &dec_io_params, &in_format, &lfe_ch_idx ); - - st_ivas.transport_config = ivas_crend_map_out_fmt( in_format ); - - - if ( IVAS_SUCCESS != result ) - { - fprintf( stderr, "Crend configuration parameters setting failed\n" ); - ivas_crend_close( &st_ivas ); - exit( -1 ); - } - - /*------------------------------------------------------------------------------------------* - * State memory allocation for Common renderer - *------------------------------------------------------------------------------------------*/ - decoder_config.Opt_Headrotation = 0; - ivas_crend_open( &st_ivas ); - - /*------------------------------------------------------------------------------------------* - * In/out buffer memory allocation for encoder - *------------------------------------------------------------------------------------------*/ - int32_t in_ch = ivas_get_num_channels( pIo_params->in_fmt ); - int32_t out_ch = ivas_get_num_channels( pIo_params->out_fmt ); - - Smixer = (float *) calloc( in_ch, sizeof( float ) ); - powvec = (float *) calloc( in_ch, sizeof( float ) ); - - /* init - ignore FLC */ - for ( i = 0; i < in_ch; i++ ) - { - powvec[i] = 0.0f; - } - - /*------------------------------------------------------------------------------------------* - * Loop for every frame of input data - * - Read the input data - * - Run the Common renderer - * - Write the parameters into output bitstream file - *------------------------------------------------------------------------------------------*/ - -#define _FIND_MAX_ -#ifdef _FIND_MAX_ - float valMax = 0; - float valEner = 0; -#endif - - while ( ( ( result = ivas_wrapper_get_in_buf( pIo_params, ppPcm_in ) ) == IVAS_SUCCESS ) ) /* process loop */ - { -#ifdef USE_PCM_OUT - int16_t pcm; -#else - int16_t pcm[MAX_OUTPUT_CHANNELS]; -#endif - result = IVAS_SUCCESS; - - /* get the mixing matrix.. */ - get_prox_downmix_mixer( (int16_t) PROXIMITY_USER_ID, Smixer, userLoc, in_ch, ppPcm_in, frame_len, powvec ); - - result = ivas_crend_mixer( ppPcm_in, ppPcm_out, in_ch, out_ch, Smixer, frame_len ); - - if ( IVAS_SUCCESS != result ) - { - fprintf( stderr, "Error: ivas_crend_process failed with %d \n\n", (int32_t) result ); - ivas_crend_close( &st_ivas ); - exit( -1 ); - } - - float valMaxLoc = 0; - - for ( j = 0; j < frame_len; j++ ) - { - - for ( i = 0; i < out_ch; i++ ) - { - - float temp = roundf( ppPcm_out[i][j] * PCM16_TO_FLT_FAC ); -#ifdef _FIND_MAX_ - - valMaxLoc = ( ppPcm_out[i][j] > valMaxLoc ) ? ppPcm_out[i][j] : ( ppPcm_out[i][j] < -valMaxLoc ) ? -ppPcm_out[i][j] - : valMaxLoc; - /* if (valMaxLoc > 1.0) printf("Saturation valMax = %f at frame_len = %ld sample = %ld \n", valMaxLoc, frame_len, i); */ - - if ( valMax < valMaxLoc ) - { - valMax = valMaxLoc; - } - valEner += ppPcm_out[i][j] * ppPcm_out[i][j]; -#endif - -#ifdef USE_PCM_OUT - pcm = ( temp > MAX16B_FLT ) ? MAX16B : ( temp < MIN16B_FLT ) ? MIN16B - : (short) temp; - fwrite( &pcm, sizeof( int16_t ), 1, pIo_params->fOut ); -#else - pcm[i] = ( temp > MAX16B_FLT ) ? MAX16B : ( temp < MIN16B_FLT ) ? MIN16B - : (short) temp; - -#endif - } -#ifndef USE_PCM_OUT - AudioFileWriter_write( pIo_params->fOut, pcm, out_ch ); -#endif - } - - frame_count++; - } - free( powvec ); - free( Smixer ); - -#ifdef _FIND_MAX_ - valEner = sqrt( valEner / ( frame_count * frame_len ) ); - printf( "valMax = %f valEner = %f \n", 20.f * log10( valMax ), 20.f * log10( valEner ) ); -#endif - printf( "Total Frames Processed : %lld\n", (long long int) frame_count ); - - ivas_crend_close( &st_ivas ); - - return IVAS_SUCCESS; -} -- GitLab From 7300a7f8bf009d968185ab0fa47e00d5bedd1fc5 Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Tue, 9 Aug 2022 11:05:20 +0200 Subject: [PATCH 02/15] Update / clean up code. --- lib_dec/ivas_mono_dmx_renderer.c | 6 +++--- lib_dec/ivas_prox_mix.c | 30 +++++++++++++++--------------- lib_dec/ivas_prox_mix.h | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 77aad285aa..2d1f1b94a4 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -54,7 +54,7 @@ #define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4 #ifdef ENABLE_PROX_BASED_MIXING -#define PROXIMITY_USER_ID ( 0 ) +#define PROXIMITY_USER_ID ( 2 ) const uint8_t bitstream[] = { 0x00, 0x01, 0x80, 0x02, 0x80 }; #endif /* ENABLE_PROX_BASED_MIXING */ @@ -126,11 +126,11 @@ void ivas_mono_downmix_render_passive( #ifdef DEBUG_PROX_MIX_INFO printf("\n\n hDownmix->Smixer = "); - for(int i = 0; i < numInputChannels; i++) + for( i = 0; i < numInputChannels; i++) printf( "%.8f ", hDownmix->Smixer[i] ); printf("\n hDownmix->powvec = "); - for(int i = 0; i < numInputChannels; i++) + for( i = 0; i < numInputChannels; i++) printf( "%.6e ", hDownmix->powvec[i] ); printf("\n"); diff --git a/lib_dec/ivas_prox_mix.c b/lib_dec/ivas_prox_mix.c index b2780753dd..d5e8faea70 100644 --- a/lib_dec/ivas_prox_mix.c +++ b/lib_dec/ivas_prox_mix.c @@ -59,7 +59,7 @@ * Static functions declaration *------------------------------------------------------------------------------------------*/ -static float get_block_power( float *vec, int32_t frame_len ); +static float get_block_power( float *vec, int16_t frame_len ); /*------------------------------------------------------------------------------------------* * function definitions @@ -82,12 +82,12 @@ static float get_block_power( float *vec, int32_t frame_len ); ivas_error get_users_locations( const uint8_t *bitstream, - int32_t len, + int16_t len, int16_t *userLoc ) { /* userID = channelID starting from index=0 */ - int16_t nrLoc = 1; - int32_t i; + int16_t nrLoc, i; + nrLoc = 1; /* enter user location depending on position in userLoc array */ for ( i = 0; i < len; i++ ) @@ -111,19 +111,19 @@ ivas_error get_prox_downmix_mixer( int16_t userID, float *sMixer, int16_t *userLoc, - int32_t nChan, + int16_t nChan, float ppPcm_in[][L_FRAME48k], - int32_t frame_len, + int16_t frame_len, float *powvec ) { /* userID = channelID starting from index=0 */ - int16_t nrUsers = 0, nrLoc = 0; - int32_t i, j; - int16_t locIdx = 0; + int16_t nrUsers, nrLoc, i, j, locIdx; float pow_1, pow_2; - float *pow; + float pow[MAX_INPUT_CHANNELS]; - pow = (float *) calloc( nChan, sizeof( float ) ); + nrUsers = 0; + nrLoc = 0; + locIdx = 0; /* init */ for ( i = 0; i < nChan; i++ ) @@ -207,7 +207,6 @@ ivas_error get_prox_downmix_mixer( sMixer[i] = sMixer[i] / (float) nrUsers; } } - free( pow ); return IVAS_ERR_OK; } @@ -215,10 +214,11 @@ ivas_error get_prox_downmix_mixer( static float get_block_power( float *vec, - int32_t frame_len ) + int16_t frame_len ) { - int32_t i; - float pow = 0.0f; + int16_t i; + float pow; + pow = 0.0f; for ( i = 0; i < frame_len; i++ ) { diff --git a/lib_dec/ivas_prox_mix.h b/lib_dec/ivas_prox_mix.h index 3caca280c4..6982453371 100644 --- a/lib_dec/ivas_prox_mix.h +++ b/lib_dec/ivas_prox_mix.h @@ -65,7 +65,7 @@ /*------------------------------------------------------------------------------------------* * function declarations *------------------------------------------------------------------------------------------*/ -ivas_error get_users_locations( const uint8_t *bitstream, int32_t len, int16_t *userLoc ); -ivas_error get_prox_downmix_mixer( int16_t userID, float *pMixer, int16_t *userLoc, int32_t nChan, float ppPcm_in[][L_FRAME48k], int32_t frame_len, float *powvec ); +ivas_error get_users_locations( const uint8_t *bitstream, int16_t len, int16_t *userLoc ); +ivas_error get_prox_downmix_mixer( int16_t userID, float *pMixer, int16_t *userLoc, int16_t nChan, float ppPcm_in[][L_FRAME48k], int16_t frame_len, float *powvec ); #endif -- GitLab From b3e3f296e894fc2731b27b8d81eb3e4957e57311 Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Wed, 17 Aug 2022 11:04:55 +0200 Subject: [PATCH 03/15] Update proximity-based mixing code. --- apps/decoder.c | 8 ++ lib_com/common_api_types.h | 3 + lib_com/ivas_prot.h | 7 ++ lib_com/options.h | 3 +- lib_dec/ivas_init_dec.c | 9 +++ lib_dec/ivas_mono_dmx_renderer.c | 127 ++++++++++++++++++++++--------- lib_dec/ivas_prox_mix.c | 89 ++++++---------------- lib_dec/ivas_prox_mix.h | 3 +- lib_dec/ivas_render_config.c | 3 + lib_dec/ivas_stat_dec.h | 11 ++- lib_dec/lib_dec.c | 6 ++ lib_util/render_config_reader.c | 9 +++ 12 files changed, 168 insertions(+), 110 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index cb81edc24b..f64a6bd3e3 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -425,11 +425,19 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ +#ifndef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) { fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n" ); goto cleanup; } +#else + if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_MONO ) + { + fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM or MONO is used as output. Exiting. \n" ); + goto cleanup; + } +#endif if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK ) { diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index c27b7bc628..1841da56c6 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -101,6 +101,9 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG int16_t override; int16_t use_brir; int16_t late_reverb_on; +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + int16_t do_proximity_mixing; +#endif int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ float pAcoustic_rt60[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 1abe8462cc..ca91561b08 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4753,9 +4753,16 @@ void computeReferencePower_enc( ); +#ifndef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER ivas_error ivas_mono_dmx_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#else /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ +ivas_error ivas_mono_dmx_renderer_open( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t do_proximity_mixing /* i : flag to enable proximity-based mixing */ +); +#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ void ivas_mono_downmix_render_passive( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ diff --git a/lib_com/options.h b/lib_com/options.h index a7ef3b293a..c1295c7e93 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -134,8 +134,6 @@ /* ################# Start DEVELOPMENT switches ######################## */ -/* #define ENABLE_PROX_BASED_MIXING */ /* Enable proximity-based mixing */ - #define BASOP_NOGLOB /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */ #define BITSTREAM_INDICES_MEMORY /* Don't count memory for bitstream Indice at the encoder - it is a temporary solution for development only */ @@ -150,6 +148,7 @@ /*#define FIX_IVAS_185_MDCT_ST_PLC_FADEOUT*/ /* IVAS-185 fix bug in TCX-PLC fadeout for MDCT-Stereo and improve fadeout by fading to background noise instead of white noise */ /*#define FIX_I1_113*/ /* under review : MCT bit distribution optimization for SBA high bitrates*/ +#define I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER /* Implement proximity-based mixing in ISM decoder/renderer */ #define DIRAC_DRCT_GAIN_TUNING /* issue 64: tuning of DirAC energy-compensation gains */ #define MDFT_ROM_OPTIMIZE /*Optimise ROM tables for MDFT/iMDFT*/ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a682cd3c58..3ba09abbe9 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -584,7 +584,12 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Binaural Renderer configuration handle *--------------------------------------------------------------------*/ +#ifndef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) +#else + if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM || + st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) +#endif { if ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) { @@ -1244,7 +1249,11 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { +#ifndef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_mono_dmx_renderer_open( st_ivas, st_ivas->hRenderConfig->roomAcoustics.do_proximity_mixing ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 2d1f1b94a4..5a9d1f21a8 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -39,9 +39,9 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" -#ifdef ENABLE_PROX_BASED_MIXING +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER #include "ivas_prox_mix.h" -#endif /* ENABLE_PROX_BASED_MIXING */ +#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ #include "wmops.h" @@ -53,10 +53,10 @@ #define DOWNMIX_MAX_GAIN 4.0f /* Maximum allowed gain */ #define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4 -#ifdef ENABLE_PROX_BASED_MIXING +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER #define PROXIMITY_USER_ID ( 2 ) -const uint8_t bitstream[] = { 0x00, 0x01, 0x80, 0x02, 0x80 }; -#endif /* ENABLE_PROX_BASED_MIXING */ +const int16_t userLoc_prox_mix_test_const[MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS] = { 1, 1, 2, 0 }; +#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ /*------------------------------------------------------------------------- * ivas_mono_dmx_renderer_open() @@ -64,11 +64,21 @@ const uint8_t bitstream[] = { 0x00, 0x01, 0x80, 0x02, 0x80 }; * Open decoder downmix handle *-------------------------------------------------------------------------*/ +#ifndef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER ivas_error ivas_mono_dmx_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) +#else /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ +ivas_error ivas_mono_dmx_renderer_open( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t do_proximity_mixing /* i : flag to enable proximity-based mixing */ +) +#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ { MONO_DOWNMIX_RENDERER_HANDLE hDownmix; +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + int16_t channel_idx; +#endif if ( ( hDownmix = (MONO_DOWNMIX_RENDERER_HANDLE) count_malloc( sizeof( MONO_DOWNMIX_RENDERER_STRUCT ) ) ) == NULL ) { @@ -80,21 +90,24 @@ ivas_error ivas_mono_dmx_renderer_open( st_ivas->hMonoDmxRenderer = hDownmix; -#ifdef ENABLE_PROX_BASED_MIXING - set_zero( hDownmix->powvec, MAX_INPUT_CHANNELS ); - set_zero( hDownmix->Smixer, MAX_INPUT_CHANNELS ); - set_s( hDownmix->userLoc, 0, MAX_INPUT_CHANNELS ); - - /* using bitstream information fill in the location in the userLoc vector */ - get_users_locations( bitstream, sizeof( bitstream ), hDownmix->userLoc ); +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + hDownmix->do_proximity_mixing = do_proximity_mixing; + if ( do_proximity_mixing ) + { + set_zero( hDownmix->powvec, MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS ); + for ( channel_idx = 0 ; channel_idx < MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS; channel_idx++ ) + { + hDownmix->userLoc[channel_idx] = userLoc_prox_mix_test_const[channel_idx]; + } #ifdef DEBUG_PROX_MIX_INFO - for(int i = 0 ; i < MAX_INPUT_CHANNELS; i++) - { - printf("\n i = %d, userLoc = %d \n", i, hDownmix->userLoc[i] ); - } + for ( channel_idx = 0 ; channel_idx < MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS; channel_idx++ ) + { + printf("\n channel_idx = %d, userLoc = %d \n", channel_idx, hDownmix->userLoc[channel_idx] ); + } #endif /* DEBUG_PROX_MIX_INFO */ -#endif /* ENABLE_PROX_BASED_MIXING */ + } +#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ return IVAS_ERR_OK; } @@ -120,52 +133,90 @@ void ivas_mono_downmix_render_passive( hDownmix = st_ivas->hMonoDmxRenderer; set_zero( proto_signal, output_frame ); -#ifdef ENABLE_PROX_BASED_MIXING - /* get the mixing matrix.. */ - get_prox_downmix_mixer( ( int16_t )PROXIMITY_USER_ID, hDownmix->Smixer, hDownmix->userLoc, numInputChannels, output_f, output_frame, hDownmix->powvec ); +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + float prox_mixer_gains[MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS]; + if ( hDownmix->do_proximity_mixing ) + { + /* get the mixing matrix.. */ + ivas_prox_mixer_compute_gains( ( int16_t )PROXIMITY_USER_ID, prox_mixer_gains, hDownmix->userLoc, numInputChannels, output_f, output_frame, hDownmix->powvec ); #ifdef DEBUG_PROX_MIX_INFO - printf("\n\n hDownmix->Smixer = "); - for( i = 0; i < numInputChannels; i++) - printf( "%.8f ", hDownmix->Smixer[i] ); + printf("\n\n prox_mixer_gains = "); + for ( i = 0; i < numInputChannels; i++ ) + printf( "%.8f ", prox_mixer_gains[i] ); - printf("\n hDownmix->powvec = "); - for( i = 0; i < numInputChannels; i++) - printf( "%.6e ", hDownmix->powvec[i] ); + printf("\n hDownmix->powvec = "); + for ( i = 0; i < numInputChannels; i++ ) + printf( "%.6e ", hDownmix->powvec[i] ); - printf("\n"); + printf("\n"); #endif /* DEBUG_PROX_MIX_INFO */ - /* Compute the Proto Signal */ - for ( i = 0; i < numInputChannels; i++ ) + /* Compute the Proto Signal */ + for ( i = 0; i < numInputChannels; i++ ) + { + v_multc_acc( output_f[i], prox_mixer_gains[i], proto_signal, output_frame ); + } + } + else { - float temp[L_FRAME48k]; - v_multc( output_f[i], hDownmix->Smixer[i], temp, output_frame ); - v_add( temp, proto_signal, proto_signal, output_frame ); + /* Compute the Proto Signal */ + for ( i = 0; i < numInputChannels; i++ ) + { + v_add( output_f[i], proto_signal, proto_signal, output_frame ); + } } -#else /* ENABLE_PROX_BASED_MIXING */ +#else /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ /* Compute the Proto Signal */ for ( i = 0; i < numInputChannels; i++ ) { v_add( output_f[i], proto_signal, proto_signal, output_frame ); } -#endif /* ENABLE_PROX_BASED_MIXING */ +#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ /* compute the input energy, proto energy after smoothing */ hDownmix->inputEnergy[0] *= DOWNMIX_ALPHA; hDownmix->protoEnergy[0] *= DOWNMIX_ALPHA; +#ifndef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER for ( i = 0; i < output_frame; i++ ) { hDownmix->protoEnergy[0] += proto_signal[i] * proto_signal[i]; for ( j = 0; j < numInputChannels; j++ ) { -#ifndef ENABLE_PROX_BASED_MIXING hDownmix->inputEnergy[0] += ( output_f[j][i] * output_f[j][i] ); -#else - hDownmix->inputEnergy[0] += ( output_f[j][i] * output_f[j][i] * hDownmix->Smixer[j] * hDownmix->Smixer[j] ); -#endif } } +#else /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ + if ( hDownmix->do_proximity_mixing ) + { + for ( i = 0; i < output_frame; i++ ) + { + hDownmix->protoEnergy[0] += proto_signal[i] * proto_signal[i]; + } + for ( j = 0; j < numInputChannels; j++ ) + { + const float mixer_gain_pow2 = prox_mixer_gains[j] * prox_mixer_gains[j]; + if ( mixer_gain_pow2 > 0.0f ) + { + for ( i = 0; i < output_frame; i++ ) + { + hDownmix->inputEnergy[0] += output_f[j][i] * output_f[j][i] * mixer_gain_pow2; + } + } + } + } + else + { + for ( i = 0; i < output_frame; i++ ) + { + hDownmix->protoEnergy[0] += proto_signal[i] * proto_signal[i]; + for ( j = 0; j < numInputChannels; j++ ) + { + hDownmix->inputEnergy[0] += ( output_f[j][i] * output_f[j][i] ); + } + } + } +#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ /* compute the eq factor */ eq = min( DOWNMIX_MAX_GAIN, sqrtf( hDownmix->inputEnergy[0] / ( EPSILON + hDownmix->protoEnergy[0] ) ) ); diff --git a/lib_dec/ivas_prox_mix.c b/lib_dec/ivas_prox_mix.c index d5e8faea70..c0fab42138 100644 --- a/lib_dec/ivas_prox_mix.c +++ b/lib_dec/ivas_prox_mix.c @@ -55,65 +55,43 @@ * Global variables *------------------------------------------------------------------------------------------*/ -/*------------------------------------------------------------------------------------------* - * Static functions declaration - *------------------------------------------------------------------------------------------*/ - -static float get_block_power( float *vec, int16_t frame_len ); - /*------------------------------------------------------------------------------------------* * function definitions *------------------------------------------------------------------------------------------*/ -/*-----------------------------------------------------------------------------------------* - * Function description - Returns mixer to combine uplink signals in an intelligent way to - * prevent unnecessary reproduction of certain signals and prevent acoustic feedback. - * - * Inputs - - * userID: a given user ID - * bitstream: float of bitstream data containing co-located user IDs - * pMixer: a 1-d mixer to be used in ivas_crend to combine the multichannel audio data into - * a single Mono signal. - * Outputs - + /*------------------------------------------------------------------------- + * ivas_prox_mixer_get_block_power() * - * - * - *-----------------------------------------------------------------------------------------*/ - -ivas_error get_users_locations( - const uint8_t *bitstream, - int16_t len, - int16_t *userLoc ) + * Compute the total power of the signal block + *------------------------------------------------------------------------*/ +static float ivas_prox_mixer_get_block_power( + const float *vec, + int16_t frame_len ) { - /* userID = channelID starting from index=0 */ - int16_t nrLoc, i; - nrLoc = 1; + int16_t i; + float pow; + pow = 0.0f; - /* enter user location depending on position in userLoc array */ - for ( i = 0; i < len; i++ ) + for ( i = 0; i < frame_len; i++ ) { - - if ( bitstream[i] == LOC_BITSTREAM_DELIMITER ) - { - nrLoc++; - } - else - { - userLoc[bitstream[i]] = nrLoc; - } + pow = pow + vec[i] * vec[i]; } - return IVAS_ERR_OK; + return pow; } - -ivas_error get_prox_downmix_mixer( - int16_t userID, +/*------------------------------------------------------------------------- + * ivas_prox_mixer_compute_gains() + * + * Compute mixing gains for proximity-based mixing functionality + *------------------------------------------------------------------------*/ +ivas_error ivas_prox_mixer_compute_gains( + const int16_t userID, float *sMixer, - int16_t *userLoc, - int16_t nChan, - float ppPcm_in[][L_FRAME48k], - int16_t frame_len, + const int16_t *userLoc, + const int16_t nChan, + const float ppPcm_in[][L_FRAME48k], + const int16_t frame_len, float *powvec ) { /* userID = channelID starting from index=0 */ @@ -128,7 +106,7 @@ ivas_error get_prox_downmix_mixer( /* init */ for ( i = 0; i < nChan; i++ ) { - pow[i] = get_block_power( ppPcm_in[i], frame_len ); + pow[i] = ivas_prox_mixer_get_block_power( ppPcm_in[i], frame_len ); if ( pow[i] >= powvec[i] ) { @@ -210,20 +188,3 @@ ivas_error get_prox_downmix_mixer( return IVAS_ERR_OK; } - - -static float get_block_power( - float *vec, - int16_t frame_len ) -{ - int16_t i; - float pow; - pow = 0.0f; - - for ( i = 0; i < frame_len; i++ ) - { - pow = pow + vec[i] * vec[i]; - } - - return pow; -} diff --git a/lib_dec/ivas_prox_mix.h b/lib_dec/ivas_prox_mix.h index 6982453371..f54c8e706a 100644 --- a/lib_dec/ivas_prox_mix.h +++ b/lib_dec/ivas_prox_mix.h @@ -65,7 +65,6 @@ /*------------------------------------------------------------------------------------------* * function declarations *------------------------------------------------------------------------------------------*/ -ivas_error get_users_locations( const uint8_t *bitstream, int16_t len, int16_t *userLoc ); -ivas_error get_prox_downmix_mixer( int16_t userID, float *pMixer, int16_t *userLoc, int16_t nChan, float ppPcm_in[][L_FRAME48k], int16_t frame_len, float *powvec ); +ivas_error ivas_prox_mixer_compute_gains( const int16_t userID, float *pMixer, const int16_t *userLoc, const int16_t nChan, const float ppPcm_in[][L_FRAME48k], const int16_t frame_len, float *powvec ); #endif diff --git a/lib_dec/ivas_render_config.c b/lib_dec/ivas_render_config.c index d03ce0fa75..02c1e06dc9 100644 --- a/lib_dec/ivas_render_config.c +++ b/lib_dec/ivas_render_config.c @@ -103,6 +103,9 @@ ivas_error ivas_render_config_init_from_rom( #ifdef DEBUGGING ( *hRenderConfig )->renderer_type_override = RENDER_TYPE_OVERRIDE_NONE; +#endif +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + ( *hRenderConfig )->roomAcoustics.do_proximity_mixing = false; #endif ( *hRenderConfig )->roomAcoustics.override = false; ( *hRenderConfig )->roomAcoustics.use_brir = room_flag_on; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 76e10ad4f0..a076c8467d 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1144,11 +1144,11 @@ typedef struct ivas_mono_downmix_renderer_struct { float inputEnergy[CLDFB_NO_CHANNELS_MAX]; float protoEnergy[CLDFB_NO_CHANNELS_MAX]; -#ifdef ENABLE_PROX_BASED_MIXING - float Smixer[MAX_INPUT_CHANNELS]; - float powvec[MAX_INPUT_CHANNELS]; +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + int16_t do_proximity_mixing; int16_t userLoc[MAX_INPUT_CHANNELS]; -#endif /* ENABLE_PROX_BASED_MIXING */ + float powvec[MAX_INPUT_CHANNELS]; +#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ } MONO_DOWNMIX_RENDERER_STRUCT, *MONO_DOWNMIX_RENDERER_HANDLE; @@ -1711,6 +1711,9 @@ typedef struct ivas_roomAcoustics_t int16_t override; int16_t use_brir; int16_t late_reverb_on; +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + int16_t do_proximity_mixing; +#endif int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ float pFc_input[CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ float pAcoustic_rt60[CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index fd27442c37..0082d0da05 100755 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -982,6 +982,9 @@ ivas_error IVAS_DEC_GetRenderConfig( hRCout->room_acoustics.override = hRCin->roomAcoustics.override; hRCout->room_acoustics.use_brir = hRCin->roomAcoustics.use_brir; hRCout->room_acoustics.late_reverb_on = hRCin->roomAcoustics.late_reverb_on; +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + hRCout->room_acoustics.do_proximity_mixing = hRCin->roomAcoustics.do_proximity_mixing; +#endif hRCout->room_acoustics.nBands = hRCin->roomAcoustics.nBands; hRCout->room_acoustics.acousticPreDelay = hRCin->roomAcoustics.acousticPreDelay; hRCout->room_acoustics.inputPreDelay = hRCin->roomAcoustics.inputPreDelay; @@ -1027,6 +1030,9 @@ ivas_error IVAS_DEC_FeedRenderConfig( hRenderConfig->roomAcoustics.override = renderConfig.room_acoustics.override; hRenderConfig->roomAcoustics.use_brir = renderConfig.room_acoustics.use_brir; hRenderConfig->roomAcoustics.late_reverb_on = renderConfig.room_acoustics.late_reverb_on; +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + hRenderConfig->roomAcoustics.do_proximity_mixing = renderConfig.room_acoustics.do_proximity_mixing; +#endif hRenderConfig->roomAcoustics.nBands = renderConfig.room_acoustics.nBands; hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.room_acoustics.acousticPreDelay; hRenderConfig->roomAcoustics.inputPreDelay = renderConfig.room_acoustics.inputPreDelay; diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 58e0eee286..6c4bcaa51c 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -437,6 +437,15 @@ ivas_error RenderConfigReader_read( errorHandler( item, ERROR_VALUE_INVALID ); } } +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + else if ( strcmp( item, "PROXIMITY_MIXING" ) == 0 ) + { + if ( read_bool( pValue, &hRenderConfig->room_acoustics.do_proximity_mixing ) ) + { + errorHandler(item, ERROR_VALUE_INVALID); + } + } +#endif else if ( strcmp( item, "NBANDS" ) == 0 ) { if ( !sscanf( pValue, "%hd", &hRenderConfig->room_acoustics.nBands ) || -- GitLab From 407875bde4afb9420b0607ecc1a653a9f29d39ff Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Wed, 17 Aug 2022 11:13:34 +0200 Subject: [PATCH 04/15] Add new config (turns on proximity-based mixing). --- scripts/testv/prox_mixing_on.cfg | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 scripts/testv/prox_mixing_on.cfg diff --git a/scripts/testv/prox_mixing_on.cfg b/scripts/testv/prox_mixing_on.cfg new file mode 100644 index 0000000000..40380963d4 --- /dev/null +++ b/scripts/testv/prox_mixing_on.cfg @@ -0,0 +1,2 @@ +[roomAcoustics] +proximity_mixing = true; -- GitLab From 67be0ea670fa095f7301c233fd3a1e705345e41e Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Thu, 18 Aug 2022 13:03:27 +0200 Subject: [PATCH 05/15] Update implementation. Move function declaration to ivas_prot.h, remove extra header file. --- Workspace_msvc/lib_dec.vcxproj | 1 - Workspace_msvc/lib_dec.vcxproj.filters | 3 -- lib_com/ivas_prot.h | 14 ++++++ lib_dec/ivas_mono_dmx_renderer.c | 3 -- lib_dec/ivas_prox_mix.c | 5 +- lib_dec/ivas_prox_mix.h | 70 -------------------------- 6 files changed, 18 insertions(+), 78 deletions(-) delete mode 100644 lib_dec/ivas_prox_mix.h diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 36b79679c5..1241f11e30 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -393,7 +393,6 @@ - diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index 304a7f34c9..96ebc5c6d6 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -632,9 +632,6 @@ dec_h - - dec_h - diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index ca91561b08..a0e57dbdb4 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5401,6 +5401,20 @@ void ivas_reverb_get_hrtf_set_properties( ); +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER +/* Proximity-based mixing */ +ivas_error ivas_prox_mixer_compute_gains( + const int16_t userID, + float *pMixer, + const int16_t *userLoc, + const int16_t nChan, + const float ppPcm_in[][L_FRAME48k], + const int16_t frame_len, + float *powvec +); +#endif + + /* Orientation tracking */ void ivas_orient_trk_Init( ivas_orient_trk_state_t *pOTR diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 5a9d1f21a8..0c808e2d8b 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -39,9 +39,6 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" -#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER -#include "ivas_prox_mix.h" -#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ #include "wmops.h" diff --git a/lib_dec/ivas_prox_mix.c b/lib_dec/ivas_prox_mix.c index c0fab42138..5b897bc68c 100644 --- a/lib_dec/ivas_prox_mix.c +++ b/lib_dec/ivas_prox_mix.c @@ -44,12 +44,15 @@ #ifdef DEBUGGING #include "debug.h" #endif -#include "ivas_prox_mix.h" +#include "ivas_prot.h" #include "wmops.h" /*------------------------------------------------------------------------------------------* * PreProcessor *------------------------------------------------------------------------------------------*/ +#define POWER_FACT ( 1.0f ) +#define POWER_SMOOTH_HI ( 0.8f ) +#define POWER_SMOOTH_LO ( 0.95f ) /*------------------------------------------------------------------------------------------* * Global variables diff --git a/lib_dec/ivas_prox_mix.h b/lib_dec/ivas_prox_mix.h deleted file mode 100644 index f54c8e706a..0000000000 --- a/lib_dec/ivas_prox_mix.h +++ /dev/null @@ -1,70 +0,0 @@ -/****************************************************************************************************** - - (C) 2022 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. - -*******************************************************************************************************/ - - -#ifndef IVAS_PROX_MIX_H -#define IVAS_PROX_MIX_H - -/**************************************************************************** -* File description - -* This header file contains declarations which are common between IVAS -* spatial decoding tools -****************************************************************************/ - -/*------------------------------------------------------------------------------------------* -* include header files -*------------------------------------------------------------------------------------------*/ -#include "stdio.h" -#include "stdlib.h" -#include "string.h" -#include "ivas_stat_dec.h" -#include "ivas_error.h" - -/*------------------------------------------------------------------------------------------* -* PreProcessor -*------------------------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------------------------* - * Global variables - *------------------------------------------------------------------------------------------*/ -#define LOC_BITSTREAM_DELIMITER ( 128 ) -#define MAX_BITSTREAM_LEN ( 128 ) -#define POWER_FACT ( 1.2f ) -#define POWER_SMOOTH_HI ( 0.8f ) -#define POWER_SMOOTH_LO ( 0.95f ) - -/*------------------------------------------------------------------------------------------* - * function declarations - *------------------------------------------------------------------------------------------*/ -ivas_error ivas_prox_mixer_compute_gains( const int16_t userID, float *pMixer, const int16_t *userLoc, const int16_t nChan, const float ppPcm_in[][L_FRAME48k], const int16_t frame_len, float *powvec ); - -#endif -- GitLab From 511ff228e92a604b2f0c9f61487b8c6352b0e775 Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Fri, 19 Aug 2022 09:36:55 +0200 Subject: [PATCH 06/15] Try to fix linux build warning. --- lib_com/ivas_prot.h | 2 +- lib_dec/ivas_prox_mix.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index a0e57dbdb4..fed1b4c40b 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5408,7 +5408,7 @@ ivas_error ivas_prox_mixer_compute_gains( float *pMixer, const int16_t *userLoc, const int16_t nChan, - const float ppPcm_in[][L_FRAME48k], + float ppPcm_in[][L_FRAME48k], const int16_t frame_len, float *powvec ); diff --git a/lib_dec/ivas_prox_mix.c b/lib_dec/ivas_prox_mix.c index 5b897bc68c..9688f2924c 100644 --- a/lib_dec/ivas_prox_mix.c +++ b/lib_dec/ivas_prox_mix.c @@ -93,7 +93,7 @@ ivas_error ivas_prox_mixer_compute_gains( float *sMixer, const int16_t *userLoc, const int16_t nChan, - const float ppPcm_in[][L_FRAME48k], + float ppPcm_in[][L_FRAME48k], const int16_t frame_len, float *powvec ) { -- GitLab From 6cea5d3bb005efe6339f667a430311acfd7851a3 Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Fri, 19 Aug 2022 09:54:47 +0200 Subject: [PATCH 07/15] Move variable declaration. --- lib_dec/ivas_mono_dmx_renderer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 0c808e2d8b..6fce7a5ac8 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -125,13 +125,15 @@ void ivas_mono_downmix_render_passive( int16_t i, j, numInputChannels; float proto_signal[L_FRAME48k], eq; MONO_DOWNMIX_RENDERER_HANDLE hDownmix; +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + float prox_mixer_gains[MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS]; +#endif numInputChannels = st_ivas->nSCE; hDownmix = st_ivas->hMonoDmxRenderer; set_zero( proto_signal, output_frame ); #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - float prox_mixer_gains[MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS]; if ( hDownmix->do_proximity_mixing ) { /* get the mixing matrix.. */ -- GitLab From f32e0c87b7381924363dbb7712ede8c1bf2e463a Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Wed, 24 Aug 2022 11:20:29 +0200 Subject: [PATCH 08/15] Use preferably ifdef. --- apps/decoder.c | 10 +++++----- lib_com/ivas_prot.h | 8 ++++---- lib_dec/ivas_init_dec.c | 12 ++++++------ lib_dec/ivas_mono_dmx_renderer.c | 29 +++++++++++++++-------------- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index f64a6bd3e3..2e3816b411 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -425,16 +425,16 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ -#ifndef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_MONO ) { - fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n" ); + fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM or MONO is used as output. Exiting. \n" ); goto cleanup; } #else - if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_MONO ) + if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM ) { - fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM or MONO is used as output. Exiting. \n" ); + fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n" ); goto cleanup; } #endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 5e93c4e9ee..c0584b1070 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4768,14 +4768,14 @@ void computeReferencePower_enc( ); -#ifndef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER ivas_error ivas_mono_dmx_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t do_proximity_mixing /* i : flag to enable proximity-based mixing */ ); #else /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ ivas_error ivas_mono_dmx_renderer_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t do_proximity_mixing /* i : flag to enable proximity-based mixing */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 3ba09abbe9..4f4c6e528e 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -584,11 +584,11 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Binaural Renderer configuration handle *--------------------------------------------------------------------*/ -#ifndef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) -#else +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) +#else + if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) #endif { if ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) @@ -1249,10 +1249,10 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { -#ifndef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) -#else +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER if ( ( error = ivas_mono_dmx_renderer_open( st_ivas, st_ivas->hRenderConfig->roomAcoustics.do_proximity_mixing ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) #endif { return error; diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 6fce7a5ac8..a2ba2f57b5 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -61,14 +61,14 @@ const int16_t userLoc_prox_mix_test_const[MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS] * Open decoder downmix handle *-------------------------------------------------------------------------*/ -#ifndef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER ivas_error ivas_mono_dmx_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t do_proximity_mixing /* i : flag to enable proximity-based mixing */ ) #else /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ ivas_error ivas_mono_dmx_renderer_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t do_proximity_mixing /* i : flag to enable proximity-based mixing */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) #endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ { @@ -176,16 +176,8 @@ void ivas_mono_downmix_render_passive( /* compute the input energy, proto energy after smoothing */ hDownmix->inputEnergy[0] *= DOWNMIX_ALPHA; hDownmix->protoEnergy[0] *= DOWNMIX_ALPHA; -#ifndef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - for ( i = 0; i < output_frame; i++ ) - { - hDownmix->protoEnergy[0] += proto_signal[i] * proto_signal[i]; - for ( j = 0; j < numInputChannels; j++ ) - { - hDownmix->inputEnergy[0] += ( output_f[j][i] * output_f[j][i] ); - } - } -#else /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ + +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER if ( hDownmix->do_proximity_mixing ) { for ( i = 0; i < output_frame; i++ ) @@ -215,6 +207,15 @@ void ivas_mono_downmix_render_passive( } } } +#else /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ + for ( i = 0; i < output_frame; i++ ) + { + hDownmix->protoEnergy[0] += proto_signal[i] * proto_signal[i]; + for ( j = 0; j < numInputChannels; j++ ) + { + hDownmix->inputEnergy[0] += ( output_f[j][i] * output_f[j][i] ); + } + } #endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ /* compute the eq factor */ -- GitLab From aee5f1b4e9d2917db1ab798a92963b2f53210936 Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Thu, 25 Aug 2022 15:57:09 +0200 Subject: [PATCH 09/15] Add sample test cases for proximity mixing. Note: input sample files will be made available later. --- scripts/config/self_test.prm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index ffafdb3776..7cbfc5b894 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -392,6 +392,14 @@ ../IVAS_cod -ism 4 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 256000 48 testv/stv4ISM48s.pcm bit ../IVAS_dec -t testv/headrot_case03_3000_q.csv BINAURAL 48 bit testv/stv4ISM48s.pcm_256000_48-48_TDHR.tst +// 3 ISm with metadata at 256 kbps, 48 kHz in, 48 kHz out, MONO out, prox_mix_test +../IVAS_cod -ism 3 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv 256000 48 testv/stv3ISM48_prox_mix.pcm bit +../IVAS_dec -render_config testv/prox_mixing_on.cfg MONO 48 bit testv/stv3ISM48_prox_mix.pcm_256000_48-48_MONO.tst + +// 4 ISm with metadata at 256 kbps, 48 kHz in, 48 kHz out, MONO out, prox_mix_test +../IVAS_cod -ism 4 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 256000 48 testv/stv4ISM48_prox_mix.pcm bit +../IVAS_dec -render_config testv/prox_mixing_on.cfg MONO 48 bit testv/stv4ISM48_prox_mix.pcm_256000_48-48_MONO.tst + // SBA at 13.2 kbps, 32kHz in, 32kHz out, HOA3 out ../IVAS_cod -sba 3 13200 32 testv/stv3OA32c.pcm bit -- GitLab From 10b552ced58afac31cad0c3e87ffdf663a9a972b Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Thu, 25 Aug 2022 16:17:05 +0200 Subject: [PATCH 10/15] Add dummy (silent) test vectors for proximity mixing (temporarily). --- scripts/testv/stv3ISM48_prox_mix.pcm | 3 +++ scripts/testv/stv4ISM48_prox_mix.pcm | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 scripts/testv/stv3ISM48_prox_mix.pcm create mode 100644 scripts/testv/stv4ISM48_prox_mix.pcm diff --git a/scripts/testv/stv3ISM48_prox_mix.pcm b/scripts/testv/stv3ISM48_prox_mix.pcm new file mode 100644 index 0000000000..4ee80363f5 --- /dev/null +++ b/scripts/testv/stv3ISM48_prox_mix.pcm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f33699cad6a46913c29a7283899a1e54105fbf96eac9ce0bca56ed37a59e5a63 +size 4465434 diff --git a/scripts/testv/stv4ISM48_prox_mix.pcm b/scripts/testv/stv4ISM48_prox_mix.pcm new file mode 100644 index 0000000000..8a53707e3a --- /dev/null +++ b/scripts/testv/stv4ISM48_prox_mix.pcm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:da83e46a5c6df3c8513331e7902a80fe43a53940c78a7c2dfd039c9ba26c837f +size 5953912 -- GitLab From 50870a0d5034f26cf3ee9e515b9b1c02c3e43f53 Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Fri, 26 Aug 2022 14:53:37 +0200 Subject: [PATCH 11/15] Replace dummy test vectors with teleconf samples, adjust some parameters. --- lib_dec/ivas_mono_dmx_renderer.c | 2 +- lib_dec/ivas_prox_mix.c | 4 ++-- scripts/testv/stv3ISM48_prox_mix.pcm | 4 ++-- scripts/testv/stv4ISM48_prox_mix.pcm | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index a2ba2f57b5..7d2935b7b7 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -51,7 +51,7 @@ #define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4 #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER -#define PROXIMITY_USER_ID ( 2 ) +#define PROXIMITY_USER_ID ( 3 ) const int16_t userLoc_prox_mix_test_const[MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS] = { 1, 1, 2, 0 }; #endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ diff --git a/lib_dec/ivas_prox_mix.c b/lib_dec/ivas_prox_mix.c index 9688f2924c..b12ae16b3f 100644 --- a/lib_dec/ivas_prox_mix.c +++ b/lib_dec/ivas_prox_mix.c @@ -51,8 +51,8 @@ * PreProcessor *------------------------------------------------------------------------------------------*/ #define POWER_FACT ( 1.0f ) -#define POWER_SMOOTH_HI ( 0.8f ) -#define POWER_SMOOTH_LO ( 0.95f ) +#define POWER_SMOOTH_HI ( 0.6f ) +#define POWER_SMOOTH_LO ( 0.9f ) /*------------------------------------------------------------------------------------------* * Global variables diff --git a/scripts/testv/stv3ISM48_prox_mix.pcm b/scripts/testv/stv3ISM48_prox_mix.pcm index 4ee80363f5..7f06f33cde 100644 --- a/scripts/testv/stv3ISM48_prox_mix.pcm +++ b/scripts/testv/stv3ISM48_prox_mix.pcm @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f33699cad6a46913c29a7283899a1e54105fbf96eac9ce0bca56ed37a59e5a63 -size 4465434 +oid sha256:d5a67ac509ddc07812a9d7e710e5fb7cc3e475d40b52a298c51dd0c6e233330a +size 5534490 diff --git a/scripts/testv/stv4ISM48_prox_mix.pcm b/scripts/testv/stv4ISM48_prox_mix.pcm index 8a53707e3a..f9f667c546 100644 --- a/scripts/testv/stv4ISM48_prox_mix.pcm +++ b/scripts/testv/stv4ISM48_prox_mix.pcm @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:da83e46a5c6df3c8513331e7902a80fe43a53940c78a7c2dfd039c9ba26c837f -size 5953912 +oid sha256:6fd80116f953bcb95ddc3c49f511d556ca30e7a22027723aa534c01d430ae35e +size 7379320 -- GitLab From b45c17916b38c7e3676fed338d80d0992945af15 Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Fri, 26 Aug 2022 15:34:05 +0200 Subject: [PATCH 12/15] Fix total power scaling issue. --- lib_dec/ivas_mono_dmx_renderer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 7d2935b7b7..0f4d5e9a1a 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -191,7 +191,7 @@ void ivas_mono_downmix_render_passive( { for ( i = 0; i < output_frame; i++ ) { - hDownmix->inputEnergy[0] += output_f[j][i] * output_f[j][i] * mixer_gain_pow2; + hDownmix->inputEnergy[0] += output_f[j][i] * output_f[j][i]; } } } -- GitLab From e20fd7ec247adaaa0b413b6a3400ee607cf3260a Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Mon, 29 Aug 2022 16:45:26 +0200 Subject: [PATCH 13/15] Use config instead of const/define for use locations in proximity mixing. --- lib_com/common_api_types.h | 17 +++++---- lib_com/ivas_prot.h | 4 +- lib_dec/ivas_init_dec.c | 3 +- lib_dec/ivas_mono_dmx_renderer.c | 15 ++++---- lib_dec/ivas_render_config.c | 2 + lib_dec/ivas_stat_dec.h | 17 +++++---- lib_dec/lib_dec.c | 4 ++ lib_util/render_config_reader.c | 63 +++++++++++++++++++++++++++++++- scripts/testv/prox_mixing_on.cfg | 2 + 9 files changed, 102 insertions(+), 25 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 1841da56c6..86d64e9774 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -46,6 +46,7 @@ #define IVAS_MAX_BITS_PER_FRAME ( 512000 / 50 ) #define IVAS_MAX_NUM_OBJECTS 4 #define IVAS_MAX_OUTPUT_CHANNELS 16 +#define IVAS_MAX_INPUT_CHANNELS 16 #define IVAS_CLDFB_NO_CHANNELS_MAX ( 60 ) /*----------------------------------------------------------------------------------* @@ -102,14 +103,16 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG int16_t use_brir; int16_t late_reverb_on; #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - int16_t do_proximity_mixing; + int16_t do_proximity_mixing; /* Flag to turn ON proximity-based mixing */ + int16_t prox_mix_user_locations[IVAS_MAX_INPUT_CHANNELS]; /* user locations array for proximity-based mixing */ + int16_t prox_mix_listener_location; /* listener location for proximity-based mixing */ #endif - int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ - float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ - float pAcoustic_rt60[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ - float pAcoustic_dsr[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ - float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */ - float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ + int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ + float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ + float pAcoustic_rt60[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ + float pAcoustic_dsr[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ + float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */ + float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ } IVAS_ROOM_ACOUSTICS_CONFIG_DATA; typedef struct _IVAS_RENDER_CONFIG diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c0584b1070..d73fa6d6da 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4771,7 +4771,9 @@ void computeReferencePower_enc( #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER ivas_error ivas_mono_dmx_renderer_open( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t do_proximity_mixing /* i : flag to enable proximity-based mixing */ + const int16_t do_proximity_mixing, /* i : flag to enable proximity-based mixing */ + const int16_t *prox_mix_user_locations, /* i : user locations array for proximity-based mixing */ + const int16_t prox_mix_listener_location /* i : listener location for proximity-based mixing */ ); #else /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ ivas_error ivas_mono_dmx_renderer_open( diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 4f4c6e528e..0192da78ef 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1250,7 +1250,8 @@ ivas_error ivas_init_decoder( else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - if ( ( error = ivas_mono_dmx_renderer_open( st_ivas, st_ivas->hRenderConfig->roomAcoustics.do_proximity_mixing ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mono_dmx_renderer_open( st_ivas, st_ivas->hRenderConfig->roomAcoustics.do_proximity_mixing, + st_ivas->hRenderConfig->roomAcoustics.prox_mix_user_locations, st_ivas->hRenderConfig->roomAcoustics.prox_mix_listener_location) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 0f4d5e9a1a..f6d13b531d 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -50,10 +50,6 @@ #define DOWNMIX_MAX_GAIN 4.0f /* Maximum allowed gain */ #define MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS 4 -#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER -#define PROXIMITY_USER_ID ( 3 ) -const int16_t userLoc_prox_mix_test_const[MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS] = { 1, 1, 2, 0 }; -#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ /*------------------------------------------------------------------------- * ivas_mono_dmx_renderer_open() @@ -63,8 +59,10 @@ const int16_t userLoc_prox_mix_test_const[MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS] #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER ivas_error ivas_mono_dmx_renderer_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t do_proximity_mixing /* i : flag to enable proximity-based mixing */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t do_proximity_mixing, /* i : flag to enable proximity-based mixing */ + const int16_t *prox_mix_user_locations, /* i : user locations array for proximity-based mixing */ + const int16_t prox_mix_listener_location /* i : listener location for proximity-based mixing */ ) #else /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ ivas_error ivas_mono_dmx_renderer_open( @@ -94,8 +92,9 @@ ivas_error ivas_mono_dmx_renderer_open( set_zero( hDownmix->powvec, MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS ); for ( channel_idx = 0 ; channel_idx < MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS; channel_idx++ ) { - hDownmix->userLoc[channel_idx] = userLoc_prox_mix_test_const[channel_idx]; + hDownmix->userLoc[channel_idx] = prox_mix_user_locations[channel_idx]; } + hDownmix->listenerLoc = prox_mix_listener_location; #ifdef DEBUG_PROX_MIX_INFO for ( channel_idx = 0 ; channel_idx < MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS; channel_idx++ ) @@ -137,7 +136,7 @@ void ivas_mono_downmix_render_passive( if ( hDownmix->do_proximity_mixing ) { /* get the mixing matrix.. */ - ivas_prox_mixer_compute_gains( ( int16_t )PROXIMITY_USER_ID, prox_mixer_gains, hDownmix->userLoc, numInputChannels, output_f, output_frame, hDownmix->powvec ); + ivas_prox_mixer_compute_gains( hDownmix->listenerLoc, prox_mixer_gains, hDownmix->userLoc, numInputChannels, output_f, output_frame, hDownmix->powvec ); #ifdef DEBUG_PROX_MIX_INFO printf("\n\n prox_mixer_gains = "); diff --git a/lib_dec/ivas_render_config.c b/lib_dec/ivas_render_config.c index 02c1e06dc9..154814bd0d 100644 --- a/lib_dec/ivas_render_config.c +++ b/lib_dec/ivas_render_config.c @@ -106,6 +106,8 @@ ivas_error ivas_render_config_init_from_rom( #endif #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER ( *hRenderConfig )->roomAcoustics.do_proximity_mixing = false; + set_s( ( *hRenderConfig )->roomAcoustics.prox_mix_user_locations, 0, MAX_INPUT_CHANNELS ); + ( *hRenderConfig )->roomAcoustics.prox_mix_listener_location = 0; #endif ( *hRenderConfig )->roomAcoustics.override = false; ( *hRenderConfig )->roomAcoustics.use_brir = room_flag_on; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 93a76a77f1..591ecf69a8 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1149,6 +1149,7 @@ typedef struct ivas_mono_downmix_renderer_struct float protoEnergy[CLDFB_NO_CHANNELS_MAX]; #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER int16_t do_proximity_mixing; + int16_t listenerLoc; int16_t userLoc[MAX_INPUT_CHANNELS]; float powvec[MAX_INPUT_CHANNELS]; #endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ @@ -1715,14 +1716,16 @@ typedef struct ivas_roomAcoustics_t int16_t use_brir; int16_t late_reverb_on; #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - int16_t do_proximity_mixing; + int16_t do_proximity_mixing; /* Flag to turn ON proximity-based mixing */ + int16_t prox_mix_user_locations[MAX_INPUT_CHANNELS]; /* user locations array for proximity-based mixing */ + int16_t prox_mix_listener_location; /* listener location for proximity-based mixing */ #endif - int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ - float pFc_input[CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ - float pAcoustic_rt60[CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ - float pAcoustic_dsr[CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ - float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */ - float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ + int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ + float pFc_input[CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ + float pAcoustic_rt60[CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ + float pAcoustic_dsr[CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ + float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */ + float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ } ivas_roomAcoustics_t; typedef struct ivas_render_config_t diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 0082d0da05..88e7195fd1 100755 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -984,6 +984,8 @@ ivas_error IVAS_DEC_GetRenderConfig( hRCout->room_acoustics.late_reverb_on = hRCin->roomAcoustics.late_reverb_on; #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER hRCout->room_acoustics.do_proximity_mixing = hRCin->roomAcoustics.do_proximity_mixing; + hRCout->room_acoustics.prox_mix_listener_location = hRCin->roomAcoustics.prox_mix_listener_location; + mvs2s( hRCin->roomAcoustics.prox_mix_user_locations, hRCout->room_acoustics.prox_mix_user_locations, MAX_INPUT_CHANNELS ); #endif hRCout->room_acoustics.nBands = hRCin->roomAcoustics.nBands; hRCout->room_acoustics.acousticPreDelay = hRCin->roomAcoustics.acousticPreDelay; @@ -1032,6 +1034,8 @@ ivas_error IVAS_DEC_FeedRenderConfig( hRenderConfig->roomAcoustics.late_reverb_on = renderConfig.room_acoustics.late_reverb_on; #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER hRenderConfig->roomAcoustics.do_proximity_mixing = renderConfig.room_acoustics.do_proximity_mixing; + hRenderConfig->roomAcoustics.prox_mix_listener_location = renderConfig.room_acoustics.prox_mix_listener_location; + mvs2s( renderConfig.room_acoustics.prox_mix_user_locations, hRenderConfig->roomAcoustics.prox_mix_user_locations, MAX_INPUT_CHANNELS ); #endif hRenderConfig->roomAcoustics.nBands = renderConfig.room_acoustics.nBands; hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.room_acoustics.acousticPreDelay; diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 6c4bcaa51c..25cbce1fb3 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -161,6 +161,52 @@ static int16_t read_vector( } +/*-----------------------------------------------------------------------------------------* + * Function read_vector_short_int() + * + * Reads a short integer (16 bit) vector from a line + *-----------------------------------------------------------------------------------------*/ + +static int16_t read_vector_short_int( + char *pLine, /* i : String to read from */ + int16_t *pTarget /* o : Output vector pointer */ +) +{ + char *tmp; + int16_t n; + int16_t count; + + n = (int16_t) sscanf( pLine, "[%s", pLine ); + if ( n == 0 ) + { + return true; + } + + /* Additional comma to make parsing easier */ + pLine[strlen( pLine ) - 1] = ','; + + tmp = pLine; + /* Count # of commas to determine vector length */ + for ( n = 0; tmp[n]; tmp[n] == ',' ? n++ : *tmp++ ) + ; + + count = n; + tmp = pLine; + + for ( n = 0; n < count; n++ ) + { + if ( (int16_t) sscanf( tmp, "%hd,", &pTarget[n] ) != 1 ) + { + return true; + } + + tmp = strchr( tmp, ',' ) + 1; + } + + return false; +} + + /*-----------------------------------------------------------------------------------------* * Function strip_spaces_upper() * @@ -445,7 +491,22 @@ ivas_error RenderConfigReader_read( errorHandler(item, ERROR_VALUE_INVALID); } } -#endif + else if ( strcmp( item, "PROX_MIX_USER_LOC" ) == 0 ) + { + set_s( hRenderConfig->room_acoustics.prox_mix_user_locations, 0, IVAS_MAX_INPUT_CHANNELS ); + if ( read_vector_short_int( pValue, hRenderConfig->room_acoustics.prox_mix_user_locations ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "PROX_MIX_LISTENER_LOC" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->room_acoustics.prox_mix_listener_location ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } +#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ else if ( strcmp( item, "NBANDS" ) == 0 ) { if ( !sscanf( pValue, "%hd", &hRenderConfig->room_acoustics.nBands ) || diff --git a/scripts/testv/prox_mixing_on.cfg b/scripts/testv/prox_mixing_on.cfg index 40380963d4..1a7b06385f 100644 --- a/scripts/testv/prox_mixing_on.cfg +++ b/scripts/testv/prox_mixing_on.cfg @@ -1,2 +1,4 @@ [roomAcoustics] proximity_mixing = true; +prox_mix_user_loc = [1, 1, 2, 0]; +prox_mix_listener_loc = 3; -- GitLab From f384c6117063070ab3f5853bc91c86cd4fab8d13 Mon Sep 17 00:00:00 2001 From: "CODE1\\320120260" Date: Mon, 29 Aug 2022 17:11:54 +0200 Subject: [PATCH 14/15] Minor improvements. --- lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_mono_dmx_renderer.c | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 0192da78ef..f9edf752e8 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1251,7 +1251,7 @@ ivas_error ivas_init_decoder( { #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER if ( ( error = ivas_mono_dmx_renderer_open( st_ivas, st_ivas->hRenderConfig->roomAcoustics.do_proximity_mixing, - st_ivas->hRenderConfig->roomAcoustics.prox_mix_user_locations, st_ivas->hRenderConfig->roomAcoustics.prox_mix_listener_location) ) != IVAS_ERR_OK ) + st_ivas->hRenderConfig->roomAcoustics.prox_mix_user_locations, st_ivas->hRenderConfig->roomAcoustics.prox_mix_listener_location ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index f6d13b531d..d7387a24ce 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -71,9 +71,6 @@ ivas_error ivas_mono_dmx_renderer_open( #endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ { MONO_DOWNMIX_RENDERER_HANDLE hDownmix; -#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - int16_t channel_idx; -#endif if ( ( hDownmix = (MONO_DOWNMIX_RENDERER_HANDLE) count_malloc( sizeof( MONO_DOWNMIX_RENDERER_STRUCT ) ) ) == NULL ) { @@ -90,13 +87,11 @@ ivas_error ivas_mono_dmx_renderer_open( if ( do_proximity_mixing ) { set_zero( hDownmix->powvec, MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS ); - for ( channel_idx = 0 ; channel_idx < MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS; channel_idx++ ) - { - hDownmix->userLoc[channel_idx] = prox_mix_user_locations[channel_idx]; - } + mvs2s( prox_mix_user_locations, hDownmix->userLoc, MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS ); hDownmix->listenerLoc = prox_mix_listener_location; #ifdef DEBUG_PROX_MIX_INFO + int16_t channel_idx; for ( channel_idx = 0 ; channel_idx < MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS; channel_idx++ ) { printf("\n channel_idx = %d, userLoc = %d \n", channel_idx, hDownmix->userLoc[channel_idx] ); -- GitLab From a11a9bad4c47ecd5e0d19acd5c0e2f4e6fc335e4 Mon Sep 17 00:00:00 2001 From: szczerba Date: Thu, 1 Sep 2022 09:51:18 +0200 Subject: [PATCH 15/15] Config-file based proximity mixing update --- lib_com/common_api_types.h | 27 +++++++++------ lib_com/ivas_prot.h | 10 ------ lib_dec/ivas_init_dec.c | 5 --- lib_dec/ivas_mono_dmx_renderer.c | 17 +++------ lib_dec/ivas_prox_mix.c | 5 +-- lib_dec/ivas_render_config.c | 6 ++-- lib_dec/ivas_stat_dec.h | 27 +++++++++------ lib_dec/lib_dec.c | 21 ++++++------ lib_util/render_config_reader.c | 59 +++++++++++++++++++------------- scripts/testv/prox_mixing_on.cfg | 8 ++--- 10 files changed, 92 insertions(+), 93 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 86d64e9774..3f64942320 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -102,18 +102,22 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG int16_t override; int16_t use_brir; int16_t late_reverb_on; + int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ + float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ + float pAcoustic_rt60[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ + float pAcoustic_dsr[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ + float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */ + float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ +} IVAS_ROOM_ACOUSTICS_CONFIG_DATA; + #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - int16_t do_proximity_mixing; /* Flag to turn ON proximity-based mixing */ - int16_t prox_mix_user_locations[IVAS_MAX_INPUT_CHANNELS]; /* user locations array for proximity-based mixing */ - int16_t prox_mix_listener_location; /* listener location for proximity-based mixing */ +typedef struct IVAS_PROXIMITY_CONFIG +{ + int16_t active; /* Flag to turn ON proximity-based mixing */ + int16_t object_locations[IVAS_MAX_INPUT_CHANNELS]; /* user locations array for proximity-based mixing */ + int16_t listener_location; /* listener location for proximity-based mixing */ +} IVAS_PROXIMITY_CONFIG; #endif - int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ - float pFc_input[IVAS_CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ - float pAcoustic_rt60[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ - float pAcoustic_dsr[IVAS_CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ - float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */ - float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ -} IVAS_ROOM_ACOUSTICS_CONFIG_DATA; typedef struct _IVAS_RENDER_CONFIG { @@ -121,6 +125,9 @@ typedef struct _IVAS_RENDER_CONFIG IVAS_RENDER_TYPE_OVERRIDE renderer_type_override; #endif IVAS_ROOM_ACOUSTICS_CONFIG_DATA room_acoustics; +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + IVAS_PROXIMITY_CONFIG proxMix; +#endif } IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE; typedef struct _IVAS_LS_CUSTOM_LAYOUT diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index a87ac68f82..46233123a7 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4777,19 +4777,9 @@ void computeReferencePower_enc( const int16_t num_freq_bands /* i : Number of frequency bands */ ); - -#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER -ivas_error ivas_mono_dmx_renderer_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t do_proximity_mixing, /* i : flag to enable proximity-based mixing */ - const int16_t *prox_mix_user_locations, /* i : user locations array for proximity-based mixing */ - const int16_t prox_mix_listener_location /* i : listener location for proximity-based mixing */ -); -#else /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ ivas_error ivas_mono_dmx_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); -#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ void ivas_mono_downmix_render_passive( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index c88d2413fa..ea0378c036 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1273,12 +1273,7 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) { -#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - if ( ( error = ivas_mono_dmx_renderer_open( st_ivas, st_ivas->hRenderConfig->roomAcoustics.do_proximity_mixing, - st_ivas->hRenderConfig->roomAcoustics.prox_mix_user_locations, st_ivas->hRenderConfig->roomAcoustics.prox_mix_listener_location ) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index d7387a24ce..0c492510d8 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -57,18 +57,9 @@ * Open decoder downmix handle *-------------------------------------------------------------------------*/ -#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER -ivas_error ivas_mono_dmx_renderer_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t do_proximity_mixing, /* i : flag to enable proximity-based mixing */ - const int16_t *prox_mix_user_locations, /* i : user locations array for proximity-based mixing */ - const int16_t prox_mix_listener_location /* i : listener location for proximity-based mixing */ -) -#else /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ ivas_error ivas_mono_dmx_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) -#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ { MONO_DOWNMIX_RENDERER_HANDLE hDownmix; @@ -83,12 +74,12 @@ ivas_error ivas_mono_dmx_renderer_open( st_ivas->hMonoDmxRenderer = hDownmix; #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - hDownmix->do_proximity_mixing = do_proximity_mixing; - if ( do_proximity_mixing ) + hDownmix->do_proximity_mixing = st_ivas->hRenderConfig->proxMix.active; + if ( hDownmix->do_proximity_mixing ) { set_zero( hDownmix->powvec, MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS ); - mvs2s( prox_mix_user_locations, hDownmix->userLoc, MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS ); - hDownmix->listenerLoc = prox_mix_listener_location; + mvs2s( st_ivas->hRenderConfig->proxMix.objectLocations, hDownmix->userLoc, MONO_DOWNMIX_RENDERER_MAX_INPUT_CHANS ); + hDownmix->listenerLoc = st_ivas->hRenderConfig->proxMix.listenerLocation; #ifdef DEBUG_PROX_MIX_INFO int16_t channel_idx; diff --git a/lib_dec/ivas_prox_mix.c b/lib_dec/ivas_prox_mix.c index b12ae16b3f..67f4999e43 100644 --- a/lib_dec/ivas_prox_mix.c +++ b/lib_dec/ivas_prox_mix.c @@ -163,10 +163,7 @@ ivas_error ivas_prox_mixer_compute_gains( sMixer[i] = 0.0f; break; } - else - { - sMixer[j] = 0.0f; - } + sMixer[j] = 0.0f; } } } diff --git a/lib_dec/ivas_render_config.c b/lib_dec/ivas_render_config.c index 154814bd0d..03704cdd7d 100644 --- a/lib_dec/ivas_render_config.c +++ b/lib_dec/ivas_render_config.c @@ -105,9 +105,9 @@ ivas_error ivas_render_config_init_from_rom( ( *hRenderConfig )->renderer_type_override = RENDER_TYPE_OVERRIDE_NONE; #endif #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - ( *hRenderConfig )->roomAcoustics.do_proximity_mixing = false; - set_s( ( *hRenderConfig )->roomAcoustics.prox_mix_user_locations, 0, MAX_INPUT_CHANNELS ); - ( *hRenderConfig )->roomAcoustics.prox_mix_listener_location = 0; + ( *hRenderConfig )->proxMix.active = false; + set_s( ( *hRenderConfig )->proxMix.objectLocations, 0, MAX_INPUT_CHANNELS ); + ( *hRenderConfig )->proxMix.listenerLocation = 0; #endif ( *hRenderConfig )->roomAcoustics.override = false; ( *hRenderConfig )->roomAcoustics.use_brir = room_flag_on; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 05185c2109..fef908404f 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1713,18 +1713,22 @@ typedef struct ivas_roomAcoustics_t int16_t override; int16_t use_brir; int16_t late_reverb_on; + int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ + float pFc_input[CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ + float pAcoustic_rt60[CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ + float pAcoustic_dsr[CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ + float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */ + float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ +} ivas_roomAcoustics_t; + #ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - int16_t do_proximity_mixing; /* Flag to turn ON proximity-based mixing */ - int16_t prox_mix_user_locations[MAX_INPUT_CHANNELS]; /* user locations array for proximity-based mixing */ - int16_t prox_mix_listener_location; /* listener location for proximity-based mixing */ +typedef struct ivas_proximity_t +{ + int16_t active; /* Flag to turn ON proximity-based mixing */ + int16_t objectLocations[MAX_INPUT_CHANNELS]; /* user locations array for proximity-based mixing */ + int16_t listenerLocation; /* listener location for proximity-based mixing */ +} ivas_proximity_t; #endif - int16_t nBands; /* Number of frequency bands for which reverb properties are provided, integer, range [2..256] */ - float pFc_input[CLDFB_NO_CHANNELS_MAX]; /* Center frequencies for which following values are provided: */ - float pAcoustic_rt60[CLDFB_NO_CHANNELS_MAX]; /* - The room's T60 per center frequency */ - float pAcoustic_dsr[CLDFB_NO_CHANNELS_MAX]; /* - The room's Diffuse to Source Ratio per center frequency */ - float acousticPreDelay; /* Time elapsed between input signal and late reverberation start, float, range [0.001..10] */ - float inputPreDelay; /* Offset in seconds from where DSR is computed in the RIR (0 = at source), float, range [0.001..10] */ -} ivas_roomAcoustics_t; typedef struct ivas_render_config_t { @@ -1732,6 +1736,9 @@ typedef struct ivas_render_config_t ivas_renderTypeOverride renderer_type_override; #endif ivas_roomAcoustics_t roomAcoustics; +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + ivas_proximity_t proxMix; +#endif } RENDER_CONFIG_DATA, *RENDER_CONFIG_HANDLE; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 4432444acd..0bb14d5bff 100755 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -986,11 +986,6 @@ ivas_error IVAS_DEC_GetRenderConfig( hRCout->room_acoustics.override = hRCin->roomAcoustics.override; hRCout->room_acoustics.use_brir = hRCin->roomAcoustics.use_brir; hRCout->room_acoustics.late_reverb_on = hRCin->roomAcoustics.late_reverb_on; -#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - hRCout->room_acoustics.do_proximity_mixing = hRCin->roomAcoustics.do_proximity_mixing; - hRCout->room_acoustics.prox_mix_listener_location = hRCin->roomAcoustics.prox_mix_listener_location; - mvs2s( hRCin->roomAcoustics.prox_mix_user_locations, hRCout->room_acoustics.prox_mix_user_locations, MAX_INPUT_CHANNELS ); -#endif hRCout->room_acoustics.nBands = hRCin->roomAcoustics.nBands; hRCout->room_acoustics.acousticPreDelay = hRCin->roomAcoustics.acousticPreDelay; hRCout->room_acoustics.inputPreDelay = hRCin->roomAcoustics.inputPreDelay; @@ -999,6 +994,11 @@ ivas_error IVAS_DEC_GetRenderConfig( mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->room_acoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->room_acoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + hRCout->proxMix.active = hRCin->proxMix.active; + hRCout->proxMix.listener_location = hRCin->proxMix.listenerLocation; + mvs2s( hRCin->proxMix.objectLocations, hRCout->proxMix.object_locations, MAX_INPUT_CHANNELS ); +#endif return IVAS_ERR_OK; } @@ -1036,11 +1036,6 @@ ivas_error IVAS_DEC_FeedRenderConfig( hRenderConfig->roomAcoustics.override = renderConfig.room_acoustics.override; hRenderConfig->roomAcoustics.use_brir = renderConfig.room_acoustics.use_brir; hRenderConfig->roomAcoustics.late_reverb_on = renderConfig.room_acoustics.late_reverb_on; -#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - hRenderConfig->roomAcoustics.do_proximity_mixing = renderConfig.room_acoustics.do_proximity_mixing; - hRenderConfig->roomAcoustics.prox_mix_listener_location = renderConfig.room_acoustics.prox_mix_listener_location; - mvs2s( renderConfig.room_acoustics.prox_mix_user_locations, hRenderConfig->roomAcoustics.prox_mix_user_locations, MAX_INPUT_CHANNELS ); -#endif hRenderConfig->roomAcoustics.nBands = renderConfig.room_acoustics.nBands; hRenderConfig->roomAcoustics.acousticPreDelay = renderConfig.room_acoustics.acousticPreDelay; hRenderConfig->roomAcoustics.inputPreDelay = renderConfig.room_acoustics.inputPreDelay; @@ -1048,6 +1043,12 @@ ivas_error IVAS_DEC_FeedRenderConfig( mvr2r( renderConfig.room_acoustics.pAcoustic_rt60, hRenderConfig->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( renderConfig.room_acoustics.pAcoustic_dsr, hRenderConfig->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + hRenderConfig->proxMix.active = renderConfig.proxMix.active; + hRenderConfig->proxMix.listenerLocation = renderConfig.proxMix.listener_location; + mvs2s( renderConfig.proxMix.object_locations, hRenderConfig->proxMix.objectLocations, MAX_INPUT_CHANNELS ); +#endif + return IVAS_ERR_OK; } diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 25cbce1fb3..51e54df9b0 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -483,30 +483,6 @@ ivas_error RenderConfigReader_read( errorHandler( item, ERROR_VALUE_INVALID ); } } -#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER - else if ( strcmp( item, "PROXIMITY_MIXING" ) == 0 ) - { - if ( read_bool( pValue, &hRenderConfig->room_acoustics.do_proximity_mixing ) ) - { - errorHandler(item, ERROR_VALUE_INVALID); - } - } - else if ( strcmp( item, "PROX_MIX_USER_LOC" ) == 0 ) - { - set_s( hRenderConfig->room_acoustics.prox_mix_user_locations, 0, IVAS_MAX_INPUT_CHANNELS ); - if ( read_vector_short_int( pValue, hRenderConfig->room_acoustics.prox_mix_user_locations ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - } - } - else if ( strcmp( item, "PROX_MIX_LISTENER_LOC" ) == 0 ) - { - if ( !sscanf( pValue, "%hd", &hRenderConfig->room_acoustics.prox_mix_listener_location ) ) - { - errorHandler( item, ERROR_VALUE_INVALID ); - } - } -#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ else if ( strcmp( item, "NBANDS" ) == 0 ) { if ( !sscanf( pValue, "%hd", &hRenderConfig->room_acoustics.nBands ) || @@ -569,6 +545,41 @@ ivas_error RenderConfigReader_read( fprintf( stderr, "Reverb config: number of bands changed but configuration vectors missing\n" ); } } +#ifdef I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER + else if ( strcmp( chapter, "OBJECTPROXIMITY" ) == 0 ) + { + params_idx = 0; + pValue = (char *) calloc( strlen( pParams ), sizeof( char ) ); + while ( sscanf( pParams + params_idx, "%64[^=]=%[^;];", item, pValue ) == 2 ) + { + params_idx += strlen( item ) + strlen( pValue ) + 2; + fprintf( stderr, " PARAM: %s -> %s\n", item, pValue ); + + if ( strcmp( item, "PROXIMITYMIXING" ) == 0 ) + { + if ( read_bool( pValue, &hRenderConfig->proxMix.active ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "OBJECTLOCATIONS" ) == 0 ) + { + set_s( hRenderConfig->proxMix.object_locations, 0, IVAS_MAX_INPUT_CHANNELS ); + if ( read_vector_short_int( pValue, hRenderConfig->proxMix.object_locations ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + else if ( strcmp( item, "LISTENERLOCATION" ) == 0 ) + { + if ( !sscanf( pValue, "%hd", &hRenderConfig->proxMix.listener_location ) ) + { + errorHandler( item, ERROR_VALUE_INVALID ); + } + } + } +#endif /* I15_IMPLEMENT_PROX_MIXING_FOR_ISM_DECODER */ + } #ifdef DEBUGGING else if ( strcmp( chapter, "GENERAL" ) == 0 && strlen( pParams ) != 0 ) { diff --git a/scripts/testv/prox_mixing_on.cfg b/scripts/testv/prox_mixing_on.cfg index 1a7b06385f..35b767fbe5 100644 --- a/scripts/testv/prox_mixing_on.cfg +++ b/scripts/testv/prox_mixing_on.cfg @@ -1,4 +1,4 @@ -[roomAcoustics] -proximity_mixing = true; -prox_mix_user_loc = [1, 1, 2, 0]; -prox_mix_listener_loc = 3; +[objectProximity] +proximityMixing = true; +objectLocations = [1, 1, 2, 0]; +listenerLocation= 3; -- GitLab