Loading lib_com/common_api_types.h +2 −0 Original line number Diff line number Diff line Loading @@ -222,6 +222,8 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG 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] */ /* early reflections */ #ifdef EARLY_REFLECTIONS int16_t use_er; /* ER activation flag */ int32_t lowComplexity; /* Low complexity ER flag */ Loading lib_com/ivas_cnst.h +1 −0 Original line number Diff line number Diff line Loading @@ -1884,6 +1884,7 @@ typedef enum /*----------------------------------------------------------------------------------* * Early Reflection constants *----------------------------------------------------------------------------------*/ #define ER_ABS_COEFF 6 #define ER_MAX_SOURCES 25 #define ER_REF_ORDER 1 Loading lib_rend/ivas_crend.c +16 −13 Original line number Diff line number Diff line Loading @@ -892,6 +892,7 @@ static ivas_error ivas_rend_initCrend( return IVAS_ERR_OK; } #ifdef EARLY_REFLECTIONS /*------------------------------------------------------------------------- * ivas_shoebox_data_init() Loading Loading @@ -922,6 +923,7 @@ static ivas_error ivas_shoebox_data_init( return IVAS_ERR_OK; } /*------------------------------------------------------------------------- * ivas_shoebox_output_init() * Loading @@ -948,13 +950,14 @@ static ivas_error ivas_shoebox_output_init( return IVAS_ERR_OK; } /*------------------------------------------------------------------------- * ivas_shoebox_config_init() * * Initialize shoebox_config_t handle *------------------------------------------------------------------------*/ static ivas_error ivas_shoebox_config_init( static ivas_error ivas_shoebox_config_init_params( shoebox_config_t *hShoeboxConfig /* i/o: shoebox_config_t handle */ ) { Loading @@ -981,6 +984,7 @@ static ivas_error ivas_shoebox_config_init( return IVAS_ERR_OK; } /*------------------------------------------------------------------------- * ivas_shoebox_obj_init() * Loading Loading @@ -1025,18 +1029,19 @@ static ivas_error ivas_shoebox_obj_init( hShoeboxObj->soundspeed = 0.0f; hShoeboxObj->air_coeff = 0.0f; ivas_shoebox_config_init( &hShoeboxObj->cal ); ivas_shoebox_config_init_params( &hShoeboxObj->cal ); return IVAS_ERR_OK; } /*------------------------------------------------------------------------- * ivas_er_init() * ivas_er_init_handle() * * Initialize early reflections handle *------------------------------------------------------------------------*/ static ivas_error ivas_er_init( static ivas_error ivas_er_init_handle( er_struct_t *reflections /* i/o: early reflections handle */ ) { Loading Loading @@ -1081,6 +1086,7 @@ static ivas_error ivas_er_init( } #endif /*------------------------------------------------------------------------- * ivas_rend_initCrendWrapper() * Loading Loading @@ -1331,7 +1337,7 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); } ivas_er_init( hCrend->reflections ); ivas_er_init_handle( hCrend->reflections ); hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er; hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; Loading @@ -1340,10 +1346,10 @@ ivas_error ivas_rend_openCrend( hCrend->reflections->max_frame_size = (int16_t) ( output_Fs / FRAMES_PER_SEC ); /* Init Shoebox */ shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); ivas_shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); /* Init and compute Reflections */ if ( ( error = er_init( hCrend->reflections, inConfig ) ) != IVAS_ERR_OK ) if ( ( error = ivas_er_init( hCrend->reflections, inConfig ) ) != IVAS_ERR_OK ) { return error; }; Loading @@ -1367,6 +1373,7 @@ ivas_error ivas_rend_openCrend( ( *pCrend )->hCrend = hCrend; #endif } return IVAS_ERR_OK; } Loading Loading @@ -1745,11 +1752,7 @@ ivas_error ivas_rend_crendProcess( { if ( hCrend->reflections->use_er == 1 && hCrend->reflections->is_ready == 1 ) { if ( ( error = er_process( hCrend->reflections, subframe_len, subframe_idx, output, inConfig ) ) != IVAS_ERR_OK ) if ( ( error = ivas_er_process( hCrend->reflections, subframe_len, subframe_idx, output, inConfig ) ) != IVAS_ERR_OK ) { return error; } Loading Loading @@ -1920,7 +1923,7 @@ ivas_error ivas_rend_crendProcessSubframe( { if ( hCrend->reflections->use_er == 1 && hCrend->reflections->is_ready == 1 ) { if ( ( error = er_process( hCrend->reflections, subframe_len, subframe_idx, output, inConfig ) ) != IVAS_ERR_OK ) if ( ( error = ivas_er_process( hCrend->reflections, subframe_len, subframe_idx, output, inConfig ) ) != IVAS_ERR_OK ) { return error; } Loading lib_rend/ivas_prot_rend.h +27 −29 Original line number Diff line number Diff line Loading @@ -1203,60 +1203,54 @@ void ivas_reverb_get_hrtf_set_properties( * Shoebox Prototypes *-----------------------------------------------------------------------------------*/ void shoebox_config_init( void ivas_shoebox_config_init( shoebox_config_t *cal, RENDER_CONFIG_HANDLE pConfig ); void shoebox_get_config( const shoebox_obj_t *obj, shoebox_config_t *s ); void shoebox_init( void ivas_shoebox_init( shoebox_obj_t *obj, shoebox_config_t *cal ); void shoebox_set_scene ( void ivas_shoebox_set_scene ( shoebox_obj_t *obj, shoebox_output_t *ER_PARAMS, const float list_pos[3], const float src_pos_data[], uint16_t isCartesian, uint16_t isRelative const uint16_t isCartesian, const uint16_t isRelative ); #endif #ifdef EARLY_REFLECTIONS /*---------------------------------------------------------------------------------* * Reflections compute and process Prototypes * Early reflections prototypes *-----------------------------------------------------------------------------------*/ ivas_error er_init( ivas_error ivas_er_init( er_struct_t *reflections, AUDIO_CONFIG inConfig const AUDIO_CONFIG inConfig ); ivas_error er_set_reflections_mode( ivas_error ivas_er_set_reflections_mode( er_struct_t *reflections, AUDIO_CONFIG mode const AUDIO_CONFIG inConfig ); ivas_error er_compute_reflections( ivas_error ivas_er_compute_reflections( er_struct_t *reflections ); ivas_error er_encoder_init( ivas_error ivas_er_encoder_init( er_struct_t *reflections ); ivas_error er_process( ivas_error ivas_er_process( er_struct_t *reflections, int16_t frame_size, int16_t subframe_idx, const int16_t frame_size, const int16_t subframe_idx, float **io, AUDIO_CONFIG inConfig const AUDIO_CONFIG inConfig ); #endif Loading @@ -1280,10 +1274,14 @@ void Euler2Quat( IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ ); float deg2rad( float degrees ); float deg2rad( float degrees ); #ifdef EARLY_REFLECTIONS float rad2deg( float radians ); float rad2deg( float radians ); #endif void QuatToRotMat( Loading lib_rend/ivas_reflections.c +58 −58 Original line number Diff line number Diff line Loading @@ -31,10 +31,8 @@ *******************************************************************************************************/ #include "options.h" #ifdef EARLY_REFLECTIONS #include <stdio.h> #include <stdint.h> #include <math.h> #include "prot.h" #include "rom_dec.h" Loading @@ -49,22 +47,31 @@ #include "debug.h" #endif uint16_t LC_mixing_5_1[5] = { 0, 1, 2, 0, 1 }; uint16_t LC_mixing_7_1[7] = { 0, 1, 2, 3, 4, 3, 4 }; uint16_t LC_mixing_5_1_2[7] = { 0, 1, 2, 3, 4, 0, 1 }; uint16_t LC_mixing_5_1_4[9] = { 0, 1, 2, 3, 4, 0, 1, 2, 3 }; uint16_t LC_mixing_7_1_4[11] = { 0, 1, 2, 3, 4, 3, 4, 0, 1, 2, 3 }; /*-----------------------------------------------------------------------------------------* * Function er_init * Local constants/tabels *-----------------------------------------------------------------------------------------*/ static uint16_t LC_mixing_5_1[5] = { 0, 1, 2, 0, 1 }; static uint16_t LC_mixing_7_1[7] = { 0, 1, 2, 3, 4, 3, 4 }; static uint16_t LC_mixing_5_1_2[7] = { 0, 1, 2, 3, 4, 0, 1 }; static uint16_t LC_mixing_5_1_4[9] = { 0, 1, 2, 3, 4, 0, 1, 2, 3 }; static uint16_t LC_mixing_7_1_4[11] = { 0, 1, 2, 3, 4, 3, 4, 0, 1, 2, 3 }; /*-----------------------------------------------------------------------------------------* * Function ivas_er_init() * * Initializes the reflections data structure according to the requested input config. *-----------------------------------------------------------------------------------------*/ ivas_error er_init( ivas_error ivas_er_init( er_struct_t *reflections, AUDIO_CONFIG mode ) const AUDIO_CONFIG inConfig ) { ivas_error error; uint8_t i; Loading @@ -86,22 +93,21 @@ ivas_error er_init( } /* Init Shoebox */ shoebox_init( &reflections->shoebox_lib, &reflections->shoebox_lib.cal ); ivas_shoebox_init( &reflections->shoebox_lib, &reflections->shoebox_lib.cal ); /* Set mode */ if ( ( error = er_set_reflections_mode( reflections, mode ) ) != IVAS_ERR_OK ) if ( ( error = ivas_er_set_reflections_mode( reflections, inConfig ) ) != IVAS_ERR_OK ) { return error; } /* Compute the static reflections (first frame) */ if ( ( error = er_compute_reflections( reflections ) ) != IVAS_ERR_OK ) if ( ( error = ivas_er_compute_reflections( reflections ) ) != IVAS_ERR_OK ) { return error; } reflections->closest_ch_idx = (uint16_t *) malloc( reflections->n_total_reflections * sizeof( uint16_t ) ); if ( !reflections->closest_ch_idx ) if ( ( reflections->closest_ch_idx = (uint16_t *) malloc( reflections->n_total_reflections * sizeof( uint16_t ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } Loading @@ -113,7 +119,7 @@ ivas_error er_init( } /* Initialize Encoder */ if ( ( error = er_encoder_init( reflections ) ) != IVAS_ERR_OK ) if ( ( error = ivas_er_encoder_init( reflections ) ) != IVAS_ERR_OK ) { return error; } Loading @@ -126,26 +132,26 @@ ivas_error er_init( /*-----------------------------------------------------------------------------------------* Function er_set_reflections_mode Function ivas_er_set_reflections_mode() Function sets the ER source positions based on the audio config *-----------------------------------------------------------------------------------------*/ ivas_error er_set_reflections_mode( ivas_error ivas_er_set_reflections_mode( er_struct_t *reflections, AUDIO_CONFIG mode ) const AUDIO_CONFIG inConfig ) { ivas_error error; uint16_t ch; error = IVAS_ERR_OK; if ( reflections->mode == mode ) if ( reflections->mode == inConfig ) { return error; } reflections->is_ready = 0; reflections->mode = mode; reflections->mode = inConfig; switch ( reflections->mode ) { Loading Loading @@ -242,12 +248,12 @@ ivas_error er_set_reflections_mode( /*-----------------------------------------------------------------------------------------* Function er_encoder_init Function ivas_er_encoder_init() Function that initializes the er encoder *-----------------------------------------------------------------------------------------*/ ivas_error er_encoder_init( ivas_error ivas_er_encoder_init( er_struct_t *reflections ) { ivas_error error = IVAS_ERR_OK; Loading @@ -260,8 +266,7 @@ ivas_error er_encoder_init( if ( !reflections ) { error = IVAS_ERR_FAILED_ALLOC; return error; return IVAS_ERR_FAILED_ALLOC; } if ( getAudioConfigType( reflections->mode ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) Loading Loading @@ -317,13 +322,13 @@ ivas_error er_encoder_init( /*-----------------------------------------------------------------------------------------* Function er_compute_reflections Function ivas_er_compute_reflections() Function computes reflections using the shoebox library and sets up the circular buffers structure for the early reflections process *-----------------------------------------------------------------------------------------*/ ivas_error er_compute_reflections( ivas_error ivas_er_compute_reflections( er_struct_t *reflections ) { ivas_error error = IVAS_ERR_OK; Loading @@ -339,7 +344,7 @@ ivas_error er_compute_reflections( } /* Run shoebox with current reflection parameters */ shoebox_set_scene( &( reflections->shoebox_lib ), &( reflections->shoebox_data ), ivas_shoebox_set_scene( &( reflections->shoebox_lib ), &( reflections->shoebox_data ), reflections->shoebox_lib.cal.list_orig, reflections->source_positions, reflections->is_cartesian, reflections->is_relative ); Loading @@ -349,9 +354,9 @@ ivas_error er_compute_reflections( { for ( j = 0; j < reflections->shoebox_data.n_ref; j++ ) { tmp = reflections->shoebox_data.times.data[j + ( i * (int) reflections->shoebox_data.n_ref )]; tmp = reflections->shoebox_data.times.data[j + ( i * (int16_t) reflections->shoebox_data.n_ref )]; tmp = (float) round( tmp * reflections->output_Fs ); reflections->shoebox_data.times.data[j + ( i * (int) reflections->shoebox_data.n_ref )] = tmp; reflections->shoebox_data.times.data[j + ( i * (int16_t) reflections->shoebox_data.n_ref )] = tmp; circ_len = ( (uint16_t) tmp > circ_len ) ? (uint16_t) tmp : circ_len; } } Loading @@ -376,27 +381,24 @@ ivas_error er_compute_reflections( /* circ buffers exist but size is different */ reflections->circ_len = circ_len; free( reflections->circ_buffers ); reflections->circ_buffers = (float *) malloc( reflections->shoebox_data.n_sources * reflections->circ_len * sizeof( float ) ); set_f( reflections->circ_buffers, 0.0f, reflections->shoebox_data.n_sources * reflections->circ_len ); if ( ( reflections->circ_buffers = (float *) malloc( reflections->shoebox_data.n_sources * reflections->circ_len * sizeof( float ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections buffers" ); } set_f( reflections->circ_buffers, 0.0f, reflections->shoebox_data.n_sources * reflections->circ_len ); } } else { /* circ buffers do not exist */ reflections->circ_len = circ_len; reflections->circ_buffers = (float *) malloc( reflections->shoebox_data.n_sources * reflections->circ_len * sizeof( float ) ); set_f( reflections->circ_buffers, 0.0f, reflections->shoebox_data.n_sources * reflections->circ_len ); } /* Check that circ buffers were allocated */ if ( !reflections->circ_buffers ) if ( ( reflections->circ_buffers = (float *) malloc( reflections->shoebox_data.n_sources * reflections->circ_len * sizeof( float ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections buffers" ); } set_f( reflections->circ_buffers, 0.0f, reflections->shoebox_data.n_sources * reflections->circ_len ); } /* Initialize circular buffer insertion point */ reflections->circ_insert = reflections->circ_len - (uint16_t) reflections->max_frame_size; Loading @@ -413,20 +415,21 @@ ivas_error er_compute_reflections( return error; } /*-----------------------------------------------------------------------------------------* Function er_process Function ivas_er_process() Takes a buffer of N channels, returns a buffer of N*6 channels containing the early reflections (one per wall). The process is a delay line architecture *-----------------------------------------------------------------------------------------*/ ivas_error er_process( ivas_error ivas_er_process( er_struct_t *reflections, int16_t subframe_size, int16_t subframe_idx, const int16_t subframe_size, const int16_t subframe_idx, float **io, AUDIO_CONFIG inConfig ) const AUDIO_CONFIG inConfig ) { ivas_error error = IVAS_ERR_OK; uint16_t i, j, k, subframe_offset; Loading @@ -448,8 +451,7 @@ ivas_error er_process( } /* Ensure all reflection memory is allocated */ if ( !reflections->circ_buffers || !reflections->is_ready ) if ( !reflections->circ_buffers || !reflections->is_ready ) { return IVAS_ERR_INIT_ERROR; } Loading Loading @@ -522,10 +524,10 @@ ivas_error er_process( /* Determine start idx of reflection in circ buffer based on current insert idx and reflection delay */ samp_idx = (int) reflections->circ_insert - ref_delay; samp_idx = (int16_t) reflections->circ_insert - ref_delay; if ( samp_idx < 0 ) { samp_idx = (int) reflections->circ_len + samp_idx; samp_idx = (int16_t) reflections->circ_len + samp_idx; } /* Pull reflection from circ buffer and apply gain */ Loading @@ -542,6 +544,4 @@ ivas_error er_process( return error; } #endif Loading
lib_com/common_api_types.h +2 −0 Original line number Diff line number Diff line Loading @@ -222,6 +222,8 @@ typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG 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] */ /* early reflections */ #ifdef EARLY_REFLECTIONS int16_t use_er; /* ER activation flag */ int32_t lowComplexity; /* Low complexity ER flag */ Loading
lib_com/ivas_cnst.h +1 −0 Original line number Diff line number Diff line Loading @@ -1884,6 +1884,7 @@ typedef enum /*----------------------------------------------------------------------------------* * Early Reflection constants *----------------------------------------------------------------------------------*/ #define ER_ABS_COEFF 6 #define ER_MAX_SOURCES 25 #define ER_REF_ORDER 1 Loading
lib_rend/ivas_crend.c +16 −13 Original line number Diff line number Diff line Loading @@ -892,6 +892,7 @@ static ivas_error ivas_rend_initCrend( return IVAS_ERR_OK; } #ifdef EARLY_REFLECTIONS /*------------------------------------------------------------------------- * ivas_shoebox_data_init() Loading Loading @@ -922,6 +923,7 @@ static ivas_error ivas_shoebox_data_init( return IVAS_ERR_OK; } /*------------------------------------------------------------------------- * ivas_shoebox_output_init() * Loading @@ -948,13 +950,14 @@ static ivas_error ivas_shoebox_output_init( return IVAS_ERR_OK; } /*------------------------------------------------------------------------- * ivas_shoebox_config_init() * * Initialize shoebox_config_t handle *------------------------------------------------------------------------*/ static ivas_error ivas_shoebox_config_init( static ivas_error ivas_shoebox_config_init_params( shoebox_config_t *hShoeboxConfig /* i/o: shoebox_config_t handle */ ) { Loading @@ -981,6 +984,7 @@ static ivas_error ivas_shoebox_config_init( return IVAS_ERR_OK; } /*------------------------------------------------------------------------- * ivas_shoebox_obj_init() * Loading Loading @@ -1025,18 +1029,19 @@ static ivas_error ivas_shoebox_obj_init( hShoeboxObj->soundspeed = 0.0f; hShoeboxObj->air_coeff = 0.0f; ivas_shoebox_config_init( &hShoeboxObj->cal ); ivas_shoebox_config_init_params( &hShoeboxObj->cal ); return IVAS_ERR_OK; } /*------------------------------------------------------------------------- * ivas_er_init() * ivas_er_init_handle() * * Initialize early reflections handle *------------------------------------------------------------------------*/ static ivas_error ivas_er_init( static ivas_error ivas_er_init_handle( er_struct_t *reflections /* i/o: early reflections handle */ ) { Loading Loading @@ -1081,6 +1086,7 @@ static ivas_error ivas_er_init( } #endif /*------------------------------------------------------------------------- * ivas_rend_initCrendWrapper() * Loading Loading @@ -1331,7 +1337,7 @@ ivas_error ivas_rend_openCrend( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); } ivas_er_init( hCrend->reflections ); ivas_er_init_handle( hCrend->reflections ); hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er; hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; Loading @@ -1340,10 +1346,10 @@ ivas_error ivas_rend_openCrend( hCrend->reflections->max_frame_size = (int16_t) ( output_Fs / FRAMES_PER_SEC ); /* Init Shoebox */ shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); ivas_shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); /* Init and compute Reflections */ if ( ( error = er_init( hCrend->reflections, inConfig ) ) != IVAS_ERR_OK ) if ( ( error = ivas_er_init( hCrend->reflections, inConfig ) ) != IVAS_ERR_OK ) { return error; }; Loading @@ -1367,6 +1373,7 @@ ivas_error ivas_rend_openCrend( ( *pCrend )->hCrend = hCrend; #endif } return IVAS_ERR_OK; } Loading Loading @@ -1745,11 +1752,7 @@ ivas_error ivas_rend_crendProcess( { if ( hCrend->reflections->use_er == 1 && hCrend->reflections->is_ready == 1 ) { if ( ( error = er_process( hCrend->reflections, subframe_len, subframe_idx, output, inConfig ) ) != IVAS_ERR_OK ) if ( ( error = ivas_er_process( hCrend->reflections, subframe_len, subframe_idx, output, inConfig ) ) != IVAS_ERR_OK ) { return error; } Loading Loading @@ -1920,7 +1923,7 @@ ivas_error ivas_rend_crendProcessSubframe( { if ( hCrend->reflections->use_er == 1 && hCrend->reflections->is_ready == 1 ) { if ( ( error = er_process( hCrend->reflections, subframe_len, subframe_idx, output, inConfig ) ) != IVAS_ERR_OK ) if ( ( error = ivas_er_process( hCrend->reflections, subframe_len, subframe_idx, output, inConfig ) ) != IVAS_ERR_OK ) { return error; } Loading
lib_rend/ivas_prot_rend.h +27 −29 Original line number Diff line number Diff line Loading @@ -1203,60 +1203,54 @@ void ivas_reverb_get_hrtf_set_properties( * Shoebox Prototypes *-----------------------------------------------------------------------------------*/ void shoebox_config_init( void ivas_shoebox_config_init( shoebox_config_t *cal, RENDER_CONFIG_HANDLE pConfig ); void shoebox_get_config( const shoebox_obj_t *obj, shoebox_config_t *s ); void shoebox_init( void ivas_shoebox_init( shoebox_obj_t *obj, shoebox_config_t *cal ); void shoebox_set_scene ( void ivas_shoebox_set_scene ( shoebox_obj_t *obj, shoebox_output_t *ER_PARAMS, const float list_pos[3], const float src_pos_data[], uint16_t isCartesian, uint16_t isRelative const uint16_t isCartesian, const uint16_t isRelative ); #endif #ifdef EARLY_REFLECTIONS /*---------------------------------------------------------------------------------* * Reflections compute and process Prototypes * Early reflections prototypes *-----------------------------------------------------------------------------------*/ ivas_error er_init( ivas_error ivas_er_init( er_struct_t *reflections, AUDIO_CONFIG inConfig const AUDIO_CONFIG inConfig ); ivas_error er_set_reflections_mode( ivas_error ivas_er_set_reflections_mode( er_struct_t *reflections, AUDIO_CONFIG mode const AUDIO_CONFIG inConfig ); ivas_error er_compute_reflections( ivas_error ivas_er_compute_reflections( er_struct_t *reflections ); ivas_error er_encoder_init( ivas_error ivas_er_encoder_init( er_struct_t *reflections ); ivas_error er_process( ivas_error ivas_er_process( er_struct_t *reflections, int16_t frame_size, int16_t subframe_idx, const int16_t frame_size, const int16_t subframe_idx, float **io, AUDIO_CONFIG inConfig const AUDIO_CONFIG inConfig ); #endif Loading @@ -1280,10 +1274,14 @@ void Euler2Quat( IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ ); float deg2rad( float degrees ); float deg2rad( float degrees ); #ifdef EARLY_REFLECTIONS float rad2deg( float radians ); float rad2deg( float radians ); #endif void QuatToRotMat( Loading
lib_rend/ivas_reflections.c +58 −58 Original line number Diff line number Diff line Loading @@ -31,10 +31,8 @@ *******************************************************************************************************/ #include "options.h" #ifdef EARLY_REFLECTIONS #include <stdio.h> #include <stdint.h> #include <math.h> #include "prot.h" #include "rom_dec.h" Loading @@ -49,22 +47,31 @@ #include "debug.h" #endif uint16_t LC_mixing_5_1[5] = { 0, 1, 2, 0, 1 }; uint16_t LC_mixing_7_1[7] = { 0, 1, 2, 3, 4, 3, 4 }; uint16_t LC_mixing_5_1_2[7] = { 0, 1, 2, 3, 4, 0, 1 }; uint16_t LC_mixing_5_1_4[9] = { 0, 1, 2, 3, 4, 0, 1, 2, 3 }; uint16_t LC_mixing_7_1_4[11] = { 0, 1, 2, 3, 4, 3, 4, 0, 1, 2, 3 }; /*-----------------------------------------------------------------------------------------* * Function er_init * Local constants/tabels *-----------------------------------------------------------------------------------------*/ static uint16_t LC_mixing_5_1[5] = { 0, 1, 2, 0, 1 }; static uint16_t LC_mixing_7_1[7] = { 0, 1, 2, 3, 4, 3, 4 }; static uint16_t LC_mixing_5_1_2[7] = { 0, 1, 2, 3, 4, 0, 1 }; static uint16_t LC_mixing_5_1_4[9] = { 0, 1, 2, 3, 4, 0, 1, 2, 3 }; static uint16_t LC_mixing_7_1_4[11] = { 0, 1, 2, 3, 4, 3, 4, 0, 1, 2, 3 }; /*-----------------------------------------------------------------------------------------* * Function ivas_er_init() * * Initializes the reflections data structure according to the requested input config. *-----------------------------------------------------------------------------------------*/ ivas_error er_init( ivas_error ivas_er_init( er_struct_t *reflections, AUDIO_CONFIG mode ) const AUDIO_CONFIG inConfig ) { ivas_error error; uint8_t i; Loading @@ -86,22 +93,21 @@ ivas_error er_init( } /* Init Shoebox */ shoebox_init( &reflections->shoebox_lib, &reflections->shoebox_lib.cal ); ivas_shoebox_init( &reflections->shoebox_lib, &reflections->shoebox_lib.cal ); /* Set mode */ if ( ( error = er_set_reflections_mode( reflections, mode ) ) != IVAS_ERR_OK ) if ( ( error = ivas_er_set_reflections_mode( reflections, inConfig ) ) != IVAS_ERR_OK ) { return error; } /* Compute the static reflections (first frame) */ if ( ( error = er_compute_reflections( reflections ) ) != IVAS_ERR_OK ) if ( ( error = ivas_er_compute_reflections( reflections ) ) != IVAS_ERR_OK ) { return error; } reflections->closest_ch_idx = (uint16_t *) malloc( reflections->n_total_reflections * sizeof( uint16_t ) ); if ( !reflections->closest_ch_idx ) if ( ( reflections->closest_ch_idx = (uint16_t *) malloc( reflections->n_total_reflections * sizeof( uint16_t ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } Loading @@ -113,7 +119,7 @@ ivas_error er_init( } /* Initialize Encoder */ if ( ( error = er_encoder_init( reflections ) ) != IVAS_ERR_OK ) if ( ( error = ivas_er_encoder_init( reflections ) ) != IVAS_ERR_OK ) { return error; } Loading @@ -126,26 +132,26 @@ ivas_error er_init( /*-----------------------------------------------------------------------------------------* Function er_set_reflections_mode Function ivas_er_set_reflections_mode() Function sets the ER source positions based on the audio config *-----------------------------------------------------------------------------------------*/ ivas_error er_set_reflections_mode( ivas_error ivas_er_set_reflections_mode( er_struct_t *reflections, AUDIO_CONFIG mode ) const AUDIO_CONFIG inConfig ) { ivas_error error; uint16_t ch; error = IVAS_ERR_OK; if ( reflections->mode == mode ) if ( reflections->mode == inConfig ) { return error; } reflections->is_ready = 0; reflections->mode = mode; reflections->mode = inConfig; switch ( reflections->mode ) { Loading Loading @@ -242,12 +248,12 @@ ivas_error er_set_reflections_mode( /*-----------------------------------------------------------------------------------------* Function er_encoder_init Function ivas_er_encoder_init() Function that initializes the er encoder *-----------------------------------------------------------------------------------------*/ ivas_error er_encoder_init( ivas_error ivas_er_encoder_init( er_struct_t *reflections ) { ivas_error error = IVAS_ERR_OK; Loading @@ -260,8 +266,7 @@ ivas_error er_encoder_init( if ( !reflections ) { error = IVAS_ERR_FAILED_ALLOC; return error; return IVAS_ERR_FAILED_ALLOC; } if ( getAudioConfigType( reflections->mode ) == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) Loading Loading @@ -317,13 +322,13 @@ ivas_error er_encoder_init( /*-----------------------------------------------------------------------------------------* Function er_compute_reflections Function ivas_er_compute_reflections() Function computes reflections using the shoebox library and sets up the circular buffers structure for the early reflections process *-----------------------------------------------------------------------------------------*/ ivas_error er_compute_reflections( ivas_error ivas_er_compute_reflections( er_struct_t *reflections ) { ivas_error error = IVAS_ERR_OK; Loading @@ -339,7 +344,7 @@ ivas_error er_compute_reflections( } /* Run shoebox with current reflection parameters */ shoebox_set_scene( &( reflections->shoebox_lib ), &( reflections->shoebox_data ), ivas_shoebox_set_scene( &( reflections->shoebox_lib ), &( reflections->shoebox_data ), reflections->shoebox_lib.cal.list_orig, reflections->source_positions, reflections->is_cartesian, reflections->is_relative ); Loading @@ -349,9 +354,9 @@ ivas_error er_compute_reflections( { for ( j = 0; j < reflections->shoebox_data.n_ref; j++ ) { tmp = reflections->shoebox_data.times.data[j + ( i * (int) reflections->shoebox_data.n_ref )]; tmp = reflections->shoebox_data.times.data[j + ( i * (int16_t) reflections->shoebox_data.n_ref )]; tmp = (float) round( tmp * reflections->output_Fs ); reflections->shoebox_data.times.data[j + ( i * (int) reflections->shoebox_data.n_ref )] = tmp; reflections->shoebox_data.times.data[j + ( i * (int16_t) reflections->shoebox_data.n_ref )] = tmp; circ_len = ( (uint16_t) tmp > circ_len ) ? (uint16_t) tmp : circ_len; } } Loading @@ -376,27 +381,24 @@ ivas_error er_compute_reflections( /* circ buffers exist but size is different */ reflections->circ_len = circ_len; free( reflections->circ_buffers ); reflections->circ_buffers = (float *) malloc( reflections->shoebox_data.n_sources * reflections->circ_len * sizeof( float ) ); set_f( reflections->circ_buffers, 0.0f, reflections->shoebox_data.n_sources * reflections->circ_len ); if ( ( reflections->circ_buffers = (float *) malloc( reflections->shoebox_data.n_sources * reflections->circ_len * sizeof( float ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections buffers" ); } set_f( reflections->circ_buffers, 0.0f, reflections->shoebox_data.n_sources * reflections->circ_len ); } } else { /* circ buffers do not exist */ reflections->circ_len = circ_len; reflections->circ_buffers = (float *) malloc( reflections->shoebox_data.n_sources * reflections->circ_len * sizeof( float ) ); set_f( reflections->circ_buffers, 0.0f, reflections->shoebox_data.n_sources * reflections->circ_len ); } /* Check that circ buffers were allocated */ if ( !reflections->circ_buffers ) if ( ( reflections->circ_buffers = (float *) malloc( reflections->shoebox_data.n_sources * reflections->circ_len * sizeof( float ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections buffers" ); } set_f( reflections->circ_buffers, 0.0f, reflections->shoebox_data.n_sources * reflections->circ_len ); } /* Initialize circular buffer insertion point */ reflections->circ_insert = reflections->circ_len - (uint16_t) reflections->max_frame_size; Loading @@ -413,20 +415,21 @@ ivas_error er_compute_reflections( return error; } /*-----------------------------------------------------------------------------------------* Function er_process Function ivas_er_process() Takes a buffer of N channels, returns a buffer of N*6 channels containing the early reflections (one per wall). The process is a delay line architecture *-----------------------------------------------------------------------------------------*/ ivas_error er_process( ivas_error ivas_er_process( er_struct_t *reflections, int16_t subframe_size, int16_t subframe_idx, const int16_t subframe_size, const int16_t subframe_idx, float **io, AUDIO_CONFIG inConfig ) const AUDIO_CONFIG inConfig ) { ivas_error error = IVAS_ERR_OK; uint16_t i, j, k, subframe_offset; Loading @@ -448,8 +451,7 @@ ivas_error er_process( } /* Ensure all reflection memory is allocated */ if ( !reflections->circ_buffers || !reflections->is_ready ) if ( !reflections->circ_buffers || !reflections->is_ready ) { return IVAS_ERR_INIT_ERROR; } Loading Loading @@ -522,10 +524,10 @@ ivas_error er_process( /* Determine start idx of reflection in circ buffer based on current insert idx and reflection delay */ samp_idx = (int) reflections->circ_insert - ref_delay; samp_idx = (int16_t) reflections->circ_insert - ref_delay; if ( samp_idx < 0 ) { samp_idx = (int) reflections->circ_len + samp_idx; samp_idx = (int16_t) reflections->circ_len + samp_idx; } /* Pull reflection from circ buffer and apply gain */ Loading @@ -542,6 +544,4 @@ ivas_error er_process( return error; } #endif