diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index d55896b03c15d1abb812a1272349ca3bc434a20a..23aa2ae3f0b6722871f7f9d2c37b27e41f46862f 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -244,9 +244,9 @@ + - diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index baa170036182d9c8edf122cf87895890bff4348a..7b6854e7184cd0ec212f9819aa783944db688a6a 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -379,9 +379,6 @@ common_evs_c - - common_ivas_c - common_ivas_c @@ -466,6 +463,9 @@ common_ivas_c + + common_ivas_c + diff --git a/apps/decoder.c b/apps/decoder.c index 85db7548fdebd72b4218c9ee4bcca2b4abb978b3..2b7268854a7f570c4287a8ef5bd598c6d8808e24 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1731,7 +1731,7 @@ static ivas_error decodeG192( } } - /* Write ISm metadata to external file(s) */ + /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) { if ( bsFormat == IVAS_DEC_BS_OBJ ) diff --git a/apps/encoder.c b/apps/encoder.c index 17cec67a3405c9ad59ef08f66ed579c339d6e8f0..ff6f461838a5b73410129dde9f274f42f1e28bfe 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -706,7 +706,7 @@ int main( } #endif - /* Read ISm input metadata */ + /* Read ISM input metadata */ for ( i = 0; i < numIsmInputs; ++i ) { if ( ismReaders[i] == NULL ) diff --git a/apps/renderer.c b/apps/renderer.c index 46102c54b6f96b33de165a11f69026ea91aa8de4..5e8ca98e9c8295e360cec57e551dfa93f50568a4 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -761,7 +761,7 @@ int main( } #ifdef FIX_I109_ORIENTATION_TRACKING - if ( IVAS_REND_SetOrientationTrackingMode( hIvasRend, args.orientationTracking ) ) + if ( ( error = IVAS_REND_SetOrientationTrackingMode( hIvasRend, args.orientationTracking ) ) != IVAS_ERR_OK ) { return error; } @@ -988,17 +988,18 @@ int main( { IVAS_QUATERNION quaternion; #ifdef TD5 - if ( HeadRotationFileReading( referenceRotReader, &quaternion, NULL ) != IVAS_ERR_OK ) + if ( ( error = HeadRotationFileReading( referenceRotReader, &quaternion, NULL ) ) != IVAS_ERR_OK ) #else if ( HeadRotationFileReading( referenceRotReader, &quaternion ) != IVAS_ERR_OK ) #endif { - fprintf( stderr, "Error in Head Rotation File Reading.\r\n" ); + fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } - if ( IVAS_REND_SetReferenceRotation( hIvasRend, quaternion ) != IVAS_ERR_OK ) + + if ( ( error = IVAS_REND_SetReferenceRotation( hIvasRend, quaternion ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error setting Reference Rotation.\r\n" ); + fprintf( stderr, "Error setting Reference Rotation: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } } @@ -1008,16 +1009,17 @@ int main( if ( headRotReader != NULL ) { IVAS_QUATERNION quatBuffer[RENDERER_HEAD_POSITIONS_PER_FRAME]; + #ifdef FIX_I109_ORIENTATION_TRACKING for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; i++ ) { #ifdef TD5 - if ( HeadRotationFileReading( headRotReader, &quatBuffer[i], &Pos[i] ) != IVAS_ERR_OK ) + if ( ( error = HeadRotationFileReading( headRotReader, &quatBuffer[i], &Pos[i] ) ) != IVAS_ERR_OK ) #else if ( HeadRotationFileReading( headRotReader, &quatBuffer[i] ) != IVAS_ERR_OK ) #endif { - fprintf( stderr, "Error in Head Rotation File Reading.\r\n" ); + fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } } @@ -1029,24 +1031,24 @@ int main( #endif #endif #ifdef TD5 - if ( IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer, Pos ) != IVAS_ERR_OK ) + if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer, Pos ) ) != IVAS_ERR_OK ) #else if ( IVAS_REND_SetHeadRotation( hIvasRend, quatBuffer ) != IVAS_ERR_OK ) #endif { - fprintf( stderr, "Error setting Head Rotation\n" ); + fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } } else { #ifdef TD5 - if ( ( IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL ) != IVAS_ERR_OK ) && ( IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL ) != IVAS_ERR_INVALID_OUTPUT_FORMAT ) ) + if ( ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL ) ) != IVAS_ERR_OK ) && ( IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL ) != IVAS_ERR_INVALID_OUTPUT_FORMAT ) ) // VE: TBC #else if ( ( IVAS_REND_SetHeadRotation( hIvasRend, NULL ) != IVAS_ERR_OK ) && ( IVAS_REND_SetHeadRotation( hIvasRend, NULL ) != IVAS_ERR_INVALID_OUTPUT_FORMAT ) ) #endif { - fprintf( stderr, "Error setting Head Rotation\n" ); + fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } } @@ -1916,7 +1918,7 @@ void getMetadataFromFileReader( if ( ( error = IsmFileReader_readNextFrame( ismReader, &ismMetadata ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError (%s) while reading ism metadata from: %s\n\n", ivas_error_to_string( error ), IsmFileReader_getFilePath( ismReader ) ); + fprintf( stderr, "\nError (%s) while reading ISM metadata from: %s\n\n", ivas_error_to_string( error ), IsmFileReader_getFilePath( ismReader ) ); exit( -1 ); } diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index 931fbc723bbc90e7ff6a5fed7fc31c2943b5e887..1490703aeed53e88f6c690fa27b9118425d87ca0 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -883,16 +883,19 @@ void deleteCldfb( { HANDLE_CLDFB_FILTER_BANK hs = *h_cldfb; - if ( hs ) + if ( h_cldfb == NULL || *h_cldfb == NULL ) { - if ( hs->cldfb_state ) - { - free( hs->cldfb_state ); - } - free( hs ); - *h_cldfb = NULL; + return; } + if ( hs->cldfb_state ) + { + free( hs->cldfb_state ); + } + + free( hs ); + *h_cldfb = NULL; + return; } diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index a1716d0741016248b0733042a630799631912714..60c9b7fdc7f506dd7cbb729bac29c48ba14c704b 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -293,7 +293,7 @@ typedef enum /*----------------------------------------------------------------------------------* - * ISm Constants + * ISM Constants *----------------------------------------------------------------------------------*/ #define ISM_NB_BITS_METADATA_NOMINAL ( ( SCE_CORE_16k_LOW_LIMIT - ACELP_16k_LOW_LIMIT ) / FRAMES_PER_SEC ) /* nominal number of metadata bits - used for configuration of Core-Coder modules */ @@ -353,13 +353,13 @@ typedef enum } ISM_MODE; -/* ISm metadata bitstream */ +/* ISM metadata bitstream */ enum { IND_ISM_NUM_OBJECTS, #ifdef TD5 IND_ISM_EXTENDED_FLAG = IND_ISM_NUM_OBJECTS + MAX_NUM_OBJECTS, - IND_ISM_METADATA_FLAG = IND_ISM_EXTENDED_FLAG + MAX_NUM_OBJECTS, /* EN2VE: Is this not supposed to be in the loop part below, since it is one per ISm? */ + IND_ISM_METADATA_FLAG = IND_ISM_EXTENDED_FLAG + MAX_NUM_OBJECTS, /* EN2VE: Is this not supposed to be in the loop part below, since it is one per ISM? */ #else IND_ISM_METADATA_FLAG = IND_ISM_NUM_OBJECTS + MAX_NUM_OBJECTS, #endif diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 4543955cee0763017e24a1683f47cd9032573405..3e0d68049a882a32013c749048d986c11953b09f 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -174,9 +174,8 @@ ivas_error ivas_fb_set_cfg( ivas_error ivas_FB_mixer_open( IVAS_FB_MIXER_HANDLE *hFbMixer_out, /* i/o: FB mixer handle */ const int32_t sampling_rate, /* i : sampling rate */ - IVAS_FB_CFG *fb_cfg /* i : FB config. handle */ - , - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ + IVAS_FB_CFG *fb_cfg, /* i : FB config. handle */ + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ) { IVAS_FB_MIXER_HANDLE hFbMixer; @@ -361,9 +360,8 @@ ivas_error ivas_FB_mixer_open( void ivas_FB_mixer_close( IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle */ - const int32_t sampling_rate /* i : sampling rate in Hz */ - , - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ + const int32_t sampling_rate, /* i : sampling rate in Hz */ + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ) { IVAS_FB_MIXER_HANDLE hFbMixer; diff --git a/lib_com/ivas_ism_config.c b/lib_com/ivas_ism_com.c similarity index 92% rename from lib_com/ivas_ism_config.c rename to lib_com/ivas_ism_com.c index d6b0999f7ee17e8b52bcc538b6cb21887f71b36c..f8eaa8d05f0dc27fde7ed486add14a3f3b7e2805 100644 --- a/lib_com/ivas_ism_config.c +++ b/lib_com/ivas_ism_com.c @@ -37,6 +37,7 @@ #include "rom_com.h" #include "prot.h" #include "ivas_prot.h" +#include "ivas_stat_com.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" @@ -50,7 +51,7 @@ #define FRMS_PER_SECOND ( 1000000000 / FRAME_SIZE_NS ) -#define BRATE_ISM_INACTIVE 2450 /* CoreCoder bitrate in ISm inactive frames */ +#define BRATE_ISM_INACTIVE 2450 /* CoreCoder bitrate in ISM inactive frames */ #define BITS_ISM_INACTIVE ( BRATE_ISM_INACTIVE / FRMS_PER_SECOND ) #define BETA_ISM_LOW_IMP 0.6f @@ -87,15 +88,15 @@ static void bitbudget_to_brate( *-------------------------------------------------------------------*/ ivas_error ivas_ism_config( - const int32_t ism_total_brate, /* i : ISms total bitrate */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t num_obj, /* i : number of objects */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - const int16_t localVAD[MAX_NUM_OBJECTS], /* i : local VAD flag */ - const int16_t ism_imp[], /* i : ISM importance flags */ - int32_t element_brate[], /* o : element bitrate per object */ - int32_t total_brate[], /* o : total bitrate per object */ - int16_t nb_bits_metadata[] /* i/o: number of metadata bits */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t num_obj, /* i : number of objects */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ + const int16_t localVAD[MAX_NUM_OBJECTS], /* i : local VAD flag */ + const int16_t ism_imp[], /* i : ISM importance flags */ + int32_t element_brate[], /* o : element bitrate per object */ + int32_t total_brate[], /* o : total bitrate per object */ + int16_t nb_bits_metadata[] /* i/o: number of metadata bits */ ) { int16_t ch; @@ -128,7 +129,7 @@ ivas_error ivas_ism_config( bits_element[n_ISms - 1] += bits_ism % n_ISms; bitbudget_to_brate( bits_element, element_brate, n_ISms ); - /* count ISm common signaling bits */ + /* count ISM common signaling bits */ if ( hIsmMeta != NULL ) { #ifdef TD5 @@ -295,7 +296,7 @@ ivas_error ivas_ism_config( #ifdef DEBUGGING if ( bits_CoreCoder[ch] == SID_2k40 / FRAMES_PER_SEC ) { - printf( "\nWarning: ISm bitbudget equal to SID!\n" ); + printf( "\nWarning: ISM bitbudget equal to SID!\n" ); } #endif break; @@ -314,7 +315,7 @@ ivas_error ivas_ism_config( tmpL = sum_l( total_brate, n_ISms ) + bits_side * FRMS_PER_SECOND; if ( sum_l( element_brate, n_ISms ) != tmpL ) { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "\nError: Mismatch in ISm bit-budget distribution. Exiting!\n" ); + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "\nError: Mismatch in ISM bit-budget distribution. Exiting!\n" ); } } #endif @@ -326,7 +327,7 @@ ivas_error ivas_ism_config( /*-------------------------------------------------------------------* * ivas_ism_reset_metadata() * - * Reset ISm metadata parameters + * Reset ISM metadata parameters *-------------------------------------------------------------------*/ void ivas_ism_reset_metadata( @@ -340,14 +341,17 @@ void ivas_ism_reset_metadata( hIsmMeta->pitch = 0.0f; hIsmMeta->radius = 1.0f; #endif + return; } + /*-------------------------------------------------------------------* * ivas_ism_reset_metadata_API() * - * Reset ISm metadata parameters + * Reset ISM metadata parameters *-------------------------------------------------------------------*/ + void ivas_ism_reset_metadata_API( ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */ ) @@ -358,6 +362,7 @@ void ivas_ism_reset_metadata_API( return; } + /*-------------------------------------------------------------------* * ism_quant_meta() * @@ -500,3 +505,33 @@ ISM_MODE ivas_ism_mode_select( return ism_mode; } + + +/*--------------------------------------------------------------- + * ivas_ism_metadata_close() + * + * Deallocate ISM metadata handles + * ---------------------------------------------------------------*/ + +void ivas_ism_metadata_close( + ISM_METADATA_HANDLE hIsmMetaData[] /* i/o : object metadata handles */ +) +{ + int16_t n; + + if ( hIsmMetaData == NULL || hIsmMetaData == NULL ) + { + return; + } + + for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) + { + if ( hIsmMetaData[n] != NULL ) + { + free( hIsmMetaData[n] ); + hIsmMetaData[n] = NULL; + } + } + + return; +} diff --git a/lib_com/ivas_mc_param_com.c b/lib_com/ivas_mc_param_com.c index c6cfe0ed8f6f1760d356351405ea5e4d4c53f276..acf7a8eae2c97e5a2a5092ad5d970c734f126de7 100644 --- a/lib_com/ivas_mc_param_com.c +++ b/lib_com/ivas_mc_param_com.c @@ -141,7 +141,6 @@ void ivas_param_mc_metadata_open( ivas_param_mc_default_icc_map( hMetadataPMC->icc_mapping_conf, hMetadataPMC->icc_mapping[i] ); } - /* init remaining flags and indices */ hMetadataPMC->param_frame_idx = 0; hMetadataPMC->flag_use_adaptive_icc_map = 0; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index a0506e7473af7485cc2b837f1de4bb2e6954e632..bdbdf847eb5d05ddb2fc00f62ca38513d1689da9 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -124,7 +124,7 @@ void destroy_cpe_enc( ); void ivas_mct_enc_close( - MCT_ENC_HANDLE hMCT /* i/o: MCT encoder structure */ + MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */ ); ivas_error ivas_corecoder_enc_reconfig( @@ -289,7 +289,7 @@ ivas_error stereo_dmx_evs_init_encoder( ); void stereo_dmx_evs_close_encoder( - STEREO_DMX_EVS_ENC_HANDLE hStereoDmxEVS /* i/o: Stereo downmix for EVS encoder handle */ + STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS /* i/o: Stereo downmix for EVS encoder handle */ ); ivas_error ivas_dec( @@ -499,8 +499,7 @@ void stereo_tcx_core_dec( const int16_t last_element_mode, /* i : last element mode */ const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ - , + const int16_t nchan_out, /* i : number of output channels */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const ISM_MODE ism_mode /* i : ISM mode (only needed if format is ISM) */ ); @@ -740,11 +739,11 @@ void dtx_read_padding_bits( /*----------------------------------------------------------------------------------* - * ISm prototypes + * ISM prototypes *----------------------------------------------------------------------------------*/ ivas_error ivas_ism_config( - const int32_t ism_total_brate, /* i : ISms total bitrate */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ const int16_t num_trans_ch, /* i : number of trans channels */ const int16_t num_obj, /* i : number of objects */ ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ @@ -783,9 +782,9 @@ ivas_error ivas_set_ism_metadata( const float azimuth, /* i : azimuth value */ #ifdef TD5 const float elevation, /* i : elevation value */ - float radius_meta, /* i : radius */ - float yaw, /* i : yaw */ - float pitch /* i : pitch */ + const float radius_meta, /* i : radius */ + const float yaw, /* i : yaw */ + const float pitch /* i : pitch */ #else const float elevation /* i : elevation value */ #endif @@ -811,7 +810,7 @@ ivas_error ivas_ism_enc( ); ivas_error ivas_ism_metadata_enc( - const int32_t ism_total_brate, /* i : ISms total bitrate */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ const int16_t nchan_transport, /* i : number of transport channels */ ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ SCE_ENC_HANDLE hSCE[], /* i/o: SCE encoder handles */ @@ -828,7 +827,7 @@ ivas_error ivas_ism_metadata_enc( ); ivas_error ivas_ism_metadata_dec( - const int32_t ism_total_brate, /* i : ISms total bitrate */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ int16_t *nchan_transport, /* o : number of transport channels */ ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder handles */ @@ -860,10 +859,14 @@ void ivas_param_ism_enc( ); void ivas_param_ism_enc_close( - DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ + DIRAC_ENC_HANDLE *hDirAC, /* i/o: encoder DirAC handle */ const int32_t input_Fs /* i : input sampling_rate */ ); +void ivas_ism_metadata_close( + ISM_METADATA_HANDLE hIsmMetaData[] /* i/o : object metadata handles */ +); + void ivas_param_ism_stereo_dmx( Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ float data[MAX_NUM_OBJECTS][L_FRAME48k], /* i/o: input signal/stereo dmx */ @@ -888,7 +891,7 @@ ivas_error ivas_param_ism_dec_open( ); void ivas_param_ism_dec_close( - DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ + DIRAC_DEC_HANDLE *hDirAC, /* i/o: decoder DirAC handle */ const AUDIO_CONFIG output_config /* i : output audio configuration */ ); @@ -3244,7 +3247,7 @@ ivas_error ivas_dirac_enc_reconfigure( ); void ivas_dirac_enc_close( - DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ + DIRAC_ENC_HANDLE *hDirAC, /* i/o: encoder DirAC handle */ const int32_t input_Fs /* i : input sampling_rate */ ); @@ -3296,7 +3299,7 @@ ivas_error ivas_dirac_dec_config( ); void ivas_dirac_dec_close( - DIRAC_DEC_HANDLE hDirAC /* i/o: decoder DirAC handle */ + DIRAC_DEC_HANDLE *hDirAC /* i/o: decoder DirAC handle */ ); void ivas_dirac_dec_read_BS( @@ -3524,7 +3527,7 @@ ivas_error ivas_param_mc_enc_reconfig( ); void ivas_param_mc_enc_close( - PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ + PARAM_MC_ENC_HANDLE *hParamMC, /* i/o: Parametric MC encoder handle */ const int32_t input_Fs /* i : input sampling rate */ ); @@ -3758,10 +3761,10 @@ ivas_error ivas_spar_enc_open( ); void ivas_spar_enc_close( - SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder handle */ + SPAR_ENC_HANDLE *hSpar, /* i/o: SPAR encoder handle */ const int32_t input_Fs, /* i : input sampling rate */ - const int16_t nchan_inp /* i : number of input channels */ - ,const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ + const int16_t nchan_inp, /* i : number of input channels */ + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ); ivas_error ivas_spar_enc( @@ -3773,15 +3776,13 @@ ivas_error ivas_spar_enc( ); ivas_error ivas_spar_dec_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ - , + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ); void ivas_spar_dec_close( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - const int32_t output_Fs /* i : output sampling rate */ - , + SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */ + const int32_t output_Fs, /* i : output sampling rate */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ); @@ -4429,7 +4430,7 @@ ivas_error ivas_masa_dec_open( ); void ivas_masa_dec_close( - MASA_DECODER_HANDLE hMasa /* i/o: MASA metadata structure */ + MASA_DECODER_HANDLE *hMasa /* i/o: MASA metadata structure */ ); ivas_error ivas_masa_decode( @@ -4447,7 +4448,7 @@ ivas_error ivas_masa_enc_open( ); void ivas_masa_enc_close( - MASA_ENCODER_HANDLE hMasa /* i/o: MASA metadata structure */ + MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */ #ifndef FIX_350_MASA_DELAY_COMP , const int16_t nchan_transport, /* i : Number of transport channels */ @@ -4735,7 +4736,7 @@ ivas_error ivas_mcmasa_enc_open( ); void ivas_mcmasa_enc_close( - MCMASA_ENC_HANDLE hMcMasa, /* i/o: encoder McMASA handle */ + MCMASA_ENC_HANDLE *hMcMasa, /* i/o: encoder McMASA handle */ const int32_t input_Fs /* i : input sampling rate */ ); @@ -4858,7 +4859,7 @@ ivas_error ivas_create_lfe_enc( ); void ivas_lfe_enc_close( - LFE_ENC_HANDLE hLFE /* i/o: LFE encoder handle */ + LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */ ); void ivas_lfe_enc( @@ -4875,7 +4876,7 @@ ivas_error ivas_create_lfe_dec( ); void ivas_lfe_dec_close( - LFE_DEC_HANDLE hLFE /* i/o: LFE encoder handle */ + LFE_DEC_HANDLE *hLFE /* i/o: LFE encoder handle */ ); void ivas_lfe_dec( @@ -4950,15 +4951,13 @@ ivas_error ivas_fb_set_cfg( ivas_error ivas_FB_mixer_open( IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */ const int32_t sampling_rate, /* i : sampling rate */ - IVAS_FB_CFG *fb_cfg /* i : FB config. handle */ - , + IVAS_FB_CFG *fb_cfg, /* i : FB config. handle */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ); void ivas_FB_mixer_close( IVAS_FB_MIXER_HANDLE *hFbMixer, /* i/o: FB mixer handle */ - const int32_t sampling_rate /* i : sampling rate in Hz */ - , + const int32_t sampling_rate, /* i : sampling rate in Hz */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ); diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index f6a9cb6ef113c261b7a26b291ad84843870d791b..a095c9e4b48846d125154bbd3d6cba22e7a49549 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -317,9 +317,8 @@ extern const float McMASA_LFEGain_vectors[64]; extern const float ism_azimuth_borders[4]; extern const float ism_elevation_borders[4]; -#ifdef TD5 -extern const float ism_radius_borders[4]; -#endif // TD5 + + /*----------------------------------------------------------------------------------* * Param ISM ROM tables *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 244ba7ff768d6bdd2be5dfa1541f79626d5c29a9..7e3326af238c9c21788c130009fa0270a2c6acd6 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -41,8 +41,9 @@ /*----------------------------------------------------------------------------------* - * Declaration of ISm common (encoder & decoder) structure + * Declaration of ISM common (encoder & decoder) structure *----------------------------------------------------------------------------------*/ + #ifdef TD5 typedef struct { @@ -50,8 +51,10 @@ typedef struct int16_t azimuth_diff_cnt; /* FEC counter of consecutive differentially azimuth coded frames */ int16_t last_elevation_idx; /* last frame index of coded elevation */ int16_t elevation_diff_cnt; /* FEC counter of consecutive differentially elevation coded frames */ + } ISM_METADATA_ANGLE, *ISM_METADATA_ANGLE_HANDLE; #endif + /* ISM metadata handle (storage for one frame of read ISM metadata) */ typedef struct { @@ -73,6 +76,7 @@ typedef struct int16_t last_elevation_idx; /* last frame index of coded elevation */ int16_t elevation_diff_cnt; /* FEC counter of consecutive differentially elevation coded frames */ #endif + } ISM_METADATA_FRAME, *ISM_METADATA_HANDLE; diff --git a/lib_com/prot.h b/lib_com/prot.h index 69cc4e0d320bacbeb18b0d3cabcdad48c6bde35d..de6c521048fb8447092692f47dadcff654004420 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2228,16 +2228,15 @@ ivas_error init_encoder( const int16_t idchan, /* i : channel ID */ const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ const int16_t interval_SID, /* i : interval for SID update */ - const int16_t vad_only_flag /* i : flag to indicate front-VAD structure */ - , - const ISM_MODE ism_mode /* i : ISM mode */ + const int16_t vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode /* i : ISM mode */ ); void LPDmem_enc_init( LPD_state_HANDLE hLPDmem /* i/o: LP memories */ ); -void destroy_encoder( +void destroy_cldfb_encoder( Encoder_State *st /* i/o: state structure */ ); ivas_error evs_enc( @@ -5121,7 +5120,7 @@ ivas_error init_decoder( const MC_MODE mc_mode /* i : MC mode */ ); -void destroy_decoder( +void destroy_cldfb_decoder( Decoder_State *st /* o : Decoder static variables structure */ ); @@ -8519,11 +8518,10 @@ void generate_comfort_noise_dec( ); void generate_comfort_noise_dec_hf( - float **bufferReal, /* o : Real part of input bands */ - float **bufferImag, /* o : Imaginary part of input bands */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ - , - const int16_t cng_flag /*i : CNG Flag */ + float **bufferReal, /* o : Real part of input bands */ + float **bufferImag, /* o : Imaginary part of input bands */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const int16_t cng_flag /*i : CNG Flag */ ); void generate_masking_noise( diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 0620b09d5f9321a4126c794adf467481fc7618b0..1d4b2ccf905fd310a4db7cdc96b63f8b94939e8b 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1328,11 +1328,10 @@ void generate_comfort_noise_dec( *-------------------------------------------------------------------*/ void generate_comfort_noise_dec_hf( - float **bufferReal, /* o : Real part of input bands */ - float **bufferImag, /* o : Imaginary part of input bands */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ - , - const int16_t cng_coh_flag /* i : CNG Flag for coherence handling */ + float **bufferReal, /* o : Real part of input bands */ + float **bufferImag, /* o : Imaginary part of input bands */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + const int16_t cng_coh_flag /* i : CNG Flag for coherence handling */ ) { int16_t i, j; diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index ca3c88b8d1ce5d7a672fd3ec93d5ab7c96cfd5f9..a8c24a11f5ef8e1afd5723f012d208e64bb2134d 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -770,12 +770,12 @@ void reset_preecho_dec( /*----------------------------------------------------------------------* - * destroy_decoder() + * destroy_cldfb_decoder() * * Free memory which was allocated in init_decoder() *----------------------------------------------------------------------*/ -void destroy_decoder( +void destroy_cldfb_decoder( Decoder_State *st /* o : Decoder static variables structure */ ) { diff --git a/lib_dec/ivas_agc_dec.c b/lib_dec/ivas_agc_dec.c index 1397ce1111f4aadbcc1f3898e427cf742530bf95..72ae68a57b34d61132eee2944adf4b6f27e52a4f 100644 --- a/lib_dec/ivas_agc_dec.c +++ b/lib_dec/ivas_agc_dec.c @@ -142,22 +142,24 @@ void ivas_spar_agc_dec_close( { ivas_agc_dec_state_t *hAgc; + if ( hAgcDec == NULL || *hAgcDec == NULL ) + { + return; + } + hAgc = *hAgcDec; - if ( hAgc != NULL ) - { - free( hAgc->agc_com.winFunc ); - hAgc->agc_com.winFunc = NULL; + free( hAgc->agc_com.winFunc ); + hAgc->agc_com.winFunc = NULL; - free( hAgc->gain_state ); - hAgc->gain_state = NULL; + free( hAgc->gain_state ); + hAgc->gain_state = NULL; - free( hAgc->gain_data ); - hAgc->gain_data = NULL; + free( hAgc->gain_data ); + hAgc->gain_data = NULL; - free( hAgc ); - *hAgcDec = NULL; - } + free( *hAgcDec ); + *hAgcDec = NULL; return; } diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 492339d6d6d7b83e6316e4c5b6e00d7ccb633b3b..a066164da4dea999bdcbdcd92f064b4e941226e5 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -453,7 +453,6 @@ ivas_error ivas_cldfb_dec_reconfig( if ( st_ivas->ivas_format == SBA_FORMAT && nchan_transport_old == 1 && numCldfbAnalyses_old == 2 && st_ivas->nchan_transport > 1 ) { deleteCldfb( &( st_ivas->cldfbAnaDec[1] ) ); - st_ivas->cldfbAnaDec[1] = NULL; numCldfbAnalyses_old--; } @@ -473,7 +472,6 @@ ivas_error ivas_cldfb_dec_reconfig( for ( i = numCldfbAnalyses; i < numCldfbAnalyses_old; i++ ) { deleteCldfb( &( st_ivas->cldfbAnaDec[i] ) ); - st_ivas->cldfbAnaDec[i] = NULL; } } else if ( numCldfbAnalyses_old < numCldfbAnalyses ) @@ -495,7 +493,6 @@ ivas_error ivas_cldfb_dec_reconfig( for ( i = numCldfbSyntheses; i < numCldfbSyntheses_old; i++ ) { deleteCldfb( &( st_ivas->cldfbSynDec[i] ) ); - st_ivas->cldfbSynDec[i] = NULL; } } else if ( numCldfbSyntheses_old < numCldfbSyntheses ) diff --git a/lib_dec/ivas_decision_matrix_dec.c b/lib_dec/ivas_decision_matrix_dec.c index 2a99953d23d441566b52f8058d4aaf3194202dce..e5be65ae24dc7204e3eb20cf21e643f4f150f566 100644 --- a/lib_dec/ivas_decision_matrix_dec.c +++ b/lib_dec/ivas_decision_matrix_dec.c @@ -134,7 +134,7 @@ void ivas_decision_matrix_dec( } else if ( st->element_mode == IVAS_SCE && st->low_rate_mode ) { - /* ISm Low-rate mode -> always WB, ACELP core, IC coder_type */ + /* ISM Low-rate mode -> always WB, ACELP core, IC coder_type */ st->core = ACELP_CORE; } else if ( st->element_mode == IVAS_CPE_MDCT ) @@ -167,7 +167,7 @@ void ivas_decision_matrix_dec( { if ( st->element_mode == IVAS_SCE && st->low_rate_mode ) { - /* ISm Low-rate mode */ + /* ISM Low-rate mode */ st->bwidth = WB; st->coder_type = INACTIVE; *sharpFlag = 0; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 1f8de9cb38e7809b0d1b260087e6ee00eca2f963..4d3d1adb3c15e57eadfb683ec8e2a72eee0d25fe 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -593,10 +593,11 @@ ivas_error ivas_dirac_dec_config( if ( hDirAC->panningConf == DIRAC_PANNING_VBAP ) { - if ( flag_config == DIRAC_RECONFIGURE && st_ivas->hVBAPdata ) + if ( flag_config == DIRAC_RECONFIGURE && st_ivas->hVBAPdata != NULL ) { vbap_free_data( &( st_ivas->hVBAPdata ) ); } + if ( ( error = vbap_init_data( &( st_ivas->hVBAPdata ), ls_azimuth, ls_elevation, nchan_out_woLFE ) ) != IVAS_ERR_OK ) { return error; @@ -604,13 +605,13 @@ ivas_error ivas_dirac_dec_config( } else if ( hDirAC->synthesisConf == DIRAC_SYNTHESIS_MONO ) { - if ( flag_config == DIRAC_RECONFIGURE && st_ivas->hVBAPdata ) + if ( flag_config == DIRAC_RECONFIGURE && st_ivas->hVBAPdata != NULL ) { vbap_free_data( &( st_ivas->hVBAPdata ) ); } hDirAC->hoa_decoder = NULL; } - else if ( flag_config == DIRAC_RECONFIGURE && st_ivas->hVBAPdata ) + else if ( flag_config == DIRAC_RECONFIGURE && st_ivas->hVBAPdata != NULL ) { vbap_free_data( &( st_ivas->hVBAPdata ) ); } @@ -1002,10 +1003,18 @@ ivas_error ivas_dirac_dec_config( *------------------------------------------------------------------------*/ void ivas_dirac_dec_close( - DIRAC_DEC_HANDLE hDirAC /* i/o: decoder DirAC handle */ + DIRAC_DEC_HANDLE *hDirAC_out /* i/o: decoder DirAC handle */ ) { int16_t i, j; + DIRAC_DEC_HANDLE hDirAC; + + if ( hDirAC_out == NULL || *hDirAC_out == NULL ) + { + return; + } + + hDirAC = *hDirAC_out; /* Config & CLDFB */ if ( hDirAC->hConfig != NULL ) @@ -1225,7 +1234,8 @@ void ivas_dirac_dec_close( ivas_dirac_free_mem( &( hDirAC->stack_mem ) ); - free( hDirAC ); + free( *hDirAC_out ); + *hDirAC_out = NULL; return; } diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 6a79d4563a4a13e141bc0e64f80819dd4ab7af59..a2fc9ee8210be12378d3175c808075fd88ebcd8d 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -190,7 +190,6 @@ void ivas_dirac_dec_output_synthesis_cov_close( DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */ ) { - int16_t idx; /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a3a48030a9cce496b5d85b14b5575cb323c92866..aeddb3b1b08cb992a86208e341fc61a02a505177 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -753,28 +753,47 @@ ivas_error ivas_init_decoder( } #ifdef FIX_I109_ORIENTATION_TRACKING + /*-----------------------------------------------------------------* + * Set head/orientation tracking + *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->Opt_Headrotation ) { if ( st_ivas->hDecoderConfig->orientation_tracking == IVAS_ORIENT_TRK_NONE ) { - ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, OTR_TRACKING_NONE ); + if ( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, OTR_TRACKING_NONE ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( st_ivas->hDecoderConfig->orientation_tracking == IVAS_ORIENT_TRK_AVG ) { - ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, OTR_TRACKING_AVG_ORIENT ); + if ( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, OTR_TRACKING_AVG_ORIENT ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( st_ivas->hDecoderConfig->orientation_tracking == IVAS_ORIENT_TRK_REF ) { - ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, OTR_TRACKING_REF_ORIENT ); + if ( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, OTR_TRACKING_REF_ORIENT ) ) != IVAS_ERR_OK ) + { + return error; + } } #ifdef OTR_REFERENCE_VECTOR_TRACKING else if ( st_ivas->hDecoderConfig->orientation_tracking == IVAS_ORIENT_TRK_REF_VEC ) { - ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, OTR_TRACKING_REF_VEC ); + if ( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, OTR_TRACKING_REF_VEC ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( st_ivas->hDecoderConfig->orientation_tracking == IVAS_ORIENT_TRK_REF_VEC_LEV ) { - ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, OTR_TRACKING_REF_VEC_LEV ); + if ( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, OTR_TRACKING_REF_VEC_LEV ) ) != IVAS_ERR_OK ) + { + return error; + } } else { @@ -1401,7 +1420,7 @@ void destroy_core_dec( DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ ) { - destroy_decoder( hCoreCoder ); + destroy_cldfb_decoder( hCoreCoder ); if ( hCoreCoder->hGSCDec != NULL ) { @@ -1621,7 +1640,7 @@ void ivas_destroy_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) { - int16_t i, n; + int16_t i; /* CLDFB handles */ for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) @@ -1629,7 +1648,6 @@ void ivas_destroy_dec( if ( st_ivas->cldfbAnaDec[i] != NULL ) { deleteCldfb( &( st_ivas->cldfbAnaDec[i] ) ); - st_ivas->cldfbAnaDec[i] = NULL; } } @@ -1638,7 +1656,6 @@ void ivas_destroy_dec( if ( st_ivas->cldfbSynDec[i] != NULL ) { deleteCldfb( &( st_ivas->cldfbSynDec[i] ) ); - st_ivas->cldfbSynDec[i] = NULL; } } @@ -1668,13 +1685,6 @@ void ivas_destroy_dec( } } - /* LFE handle */ - if ( st_ivas->hLFE != NULL ) - { - ivas_lfe_dec_close( st_ivas->hLFE ); - st_ivas->hLFE = NULL; - } - /* HP20 filter handles */ if ( st_ivas->mem_hp20_out != NULL ) { @@ -1688,16 +1698,9 @@ void ivas_destroy_dec( } /* ISM metadata handles */ - for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) - { - if ( st_ivas->hIsmMetaData[n] != NULL ) - { - free( st_ivas->hIsmMetaData[n] ); - st_ivas->hIsmMetaData[n] = NULL; - } - } + ivas_ism_metadata_close( st_ivas->hIsmMetaData ); - /* ISm renderer handle */ + /* ISM renderer handle */ if ( st_ivas->hIsmRendererData != NULL ) { free( st_ivas->hIsmRendererData ); @@ -1705,26 +1708,18 @@ void ivas_destroy_dec( } /* DirAC handle */ - if ( st_ivas->hDirAC != NULL ) + if ( st_ivas->ivas_format == ISM_FORMAT ) { - if ( st_ivas->ivas_format == ISM_FORMAT ) - { - ivas_param_ism_dec_close( st_ivas->hDirAC, st_ivas->hDecoderConfig->output_config ); - } - else - { - ivas_dirac_dec_close( st_ivas->hDirAC ); - } - st_ivas->hDirAC = NULL; + ivas_param_ism_dec_close( &( st_ivas->hDirAC ), st_ivas->hDecoderConfig->output_config ); } - - /* Spar handle */ - if ( st_ivas->hSpar != NULL ) + else { - ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs, 0 ); - st_ivas->hSpar = NULL; + ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); } + /* SPAR handle */ + ivas_spar_dec_close( &( st_ivas->hSpar ), st_ivas->hDecoderConfig->output_Fs, 0 ); + /* HOA decoder matrix */ if ( st_ivas->hoa_dec_mtx != NULL ) { @@ -1732,12 +1727,18 @@ void ivas_destroy_dec( st_ivas->hoa_dec_mtx = NULL; } + /* MASA decoder structure */ + ivas_masa_dec_close( &( st_ivas->hMasa ) ); + /* Qmetadata handle */ ivas_qmetadata_close( &st_ivas->hQMetaData ); /* MCT handle */ ivas_mct_dec_close( &st_ivas->hMCT ); + /* LFE handle */ + ivas_lfe_dec_close( &( st_ivas->hLFE ) ); + /* Parametric MC handle */ ivas_param_mc_dec_close( &st_ivas->hParamMC ); @@ -1755,6 +1756,7 @@ void ivas_destroy_dec( /* Crend handle */ ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); + /* Reverb handle */ ivas_reverb_close( &st_ivas->hReverb ); @@ -1768,13 +1770,6 @@ void ivas_destroy_dec( st_ivas->hLsSetupCustom = NULL; } - /* MASA decoder structure */ - if ( st_ivas->hMasa != NULL ) - { - ivas_masa_dec_close( st_ivas->hMasa ); - st_ivas->hMasa = NULL; - } - /* Downmix structure */ if ( st_ivas->hMonoDmxRenderer != NULL ) { @@ -1783,15 +1778,15 @@ void ivas_destroy_dec( } /* Head track data handle */ - if ( st_ivas->hHeadTrackData != NULL ) - { #ifdef FIX_I109_ORIENTATION_TRACKING - ivas_headTrack_close( &st_ivas->hHeadTrackData ); + ivas_headTrack_close( &st_ivas->hHeadTrackData ); #else + if ( st_ivas->hHeadTrackData != NULL ) + { free( st_ivas->hHeadTrackData ); st_ivas->hHeadTrackData = NULL; -#endif } +#endif /* Time Domain binaural renderer handle */ if ( st_ivas->hBinRendererTd != NULL ) @@ -1806,22 +1801,13 @@ void ivas_destroy_dec( } /* CRend binaural renderer handle */ - if ( st_ivas->hSetOfHRTF != NULL ) - { - ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); - } + ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); /* Fastconv HRTF filters */ - if ( st_ivas->hHrtfFastConv != NULL ) - { - ivas_HRTF_fastconv_binary_close( &st_ivas->hHrtfFastConv ); - } + ivas_HRTF_fastconv_binary_close( &st_ivas->hHrtfFastConv ); /* Parametric binauralizer HRTF filters */ - if ( st_ivas->hHrtfParambin != NULL ) - { - ivas_HRTF_parambin_binary_close( &st_ivas->hHrtfParambin ); - } + ivas_HRTF_parambin_binary_close( &st_ivas->hHrtfParambin ); /* Config. Renderer */ ivas_render_config_close( &( st_ivas->hRenderConfig ) ); @@ -2052,7 +2038,7 @@ static ivas_error doSanityChecks_IVAS( /* Verify ISM output configuration */ if ( output_config == AUDIO_CONFIG_INVALID ) { - return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for ISm" ); + return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for ISM" ); } } else if ( st_ivas->ivas_format == SBA_FORMAT ) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 5fd1c879f14b49046dc3a1c7f46d8a2fc7fec264..51ea82bfe158df61f0d385f506bfbfc69019841b 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -113,11 +113,7 @@ static ivas_error ivas_ism_bitrate_switching( if ( st_ivas->ism_mode == ISM_MODE_DISC && last_ism_mode == ISM_MODE_PARAM ) { /* Deallocate the ParamISM struct */ - if ( st_ivas->hDirAC != NULL ) - { - ivas_param_ism_dec_close( st_ivas->hDirAC, st_ivas->hDecoderConfig->output_config ); - st_ivas->hDirAC = NULL; - } + ivas_param_ism_dec_close( &( st_ivas->hDirAC ), st_ivas->hDecoderConfig->output_config ); if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL ) { @@ -240,7 +236,6 @@ static ivas_error ivas_ism_bitrate_switching( * - reconfigure the ISM format decoder *-------------------------------------------------------------------------*/ -/*! r : ISM format mode */ ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t num_obj /* i : number of objects in the bitstream */ diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 7c8946fc437b46305b6467ecae21c12db52b6113..49161c5d44a606c0a775b0373822c039c09b861f 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -42,23 +42,25 @@ #endif #include "wmc_auto.h" -/* Local Functions */ + #ifdef TD5 /*-----------------------------------------------------------------------* * Local functions *-----------------------------------------------------------------------*/ + static void decode_angle_indices( DEC_CORE_HANDLE st0, ISM_METADATA_ANGLE_HANDLE angle, int16_t *flag_abs_azimuth ); -int16_t decode_radius( DEC_CORE_HANDLE st0, int16_t *last_radius_idx, int16_t *flag_abs_radius ); + +static int16_t decode_radius( DEC_CORE_HANDLE st0, int16_t *last_radius_idx, int16_t *flag_abs_radius ); #endif /*-------------------------------------------------------------------------* * ivas_ism_metadata_dec() * - * decode and dequantize ISm metadata + * decode and dequantize ISM metadata *-------------------------------------------------------------------------*/ ivas_error ivas_ism_metadata_dec( - const int32_t ism_total_brate, /* i : ISms total bitrate */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ int16_t *nchan_transport, /* o : number of transport channels */ ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder handles */ @@ -146,7 +148,7 @@ ivas_error ivas_ism_metadata_dec( if ( !bfi ) { /*----------------------------------------------------------------* - * Read ISm common signaling + * Read ISM common signaling *----------------------------------------------------------------*/ /* read number of objects */ @@ -172,13 +174,16 @@ ivas_error ivas_ism_metadata_dec( /* IVAS_fmToDo: more work needed when the number of transported objects is not constant */ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong number of objects signalled!" ); } + #ifdef TD5 + /* read extended metadata presence flag */ if ( ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) { ism_extended_metadata_flag = get_next_indice( st0, ISM_EXTENDED_METADATA_BITS ); } #endif - /* Read ISm present flags (one per object) */ + + /* Read ISM present flags (one per object) */ for ( ch = 0; ch < *nchan_transport; ch++ ) { ism_imp[ch] = get_next_indice( st0, ISM_METADATA_FLAG_BITS ); @@ -241,6 +246,7 @@ ivas_error ivas_ism_metadata_dec( flag_abs_orientation = 0; flag_abs_radius = 0; #endif + if ( hIsmMeta[ch]->ism_metadata_flag ) { #ifdef TD5 @@ -259,6 +265,7 @@ ivas_error ivas_ism_metadata_dec( hIsmMetaData->azimuth = ism_dequant_meta( idx_azimuth, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ); hIsmMetaData->elevation = ism_dequant_meta( idx_elevation, ism_elevation_borders, 1 << ISM_ELEVATION_NBITS ); + /* radius/raw/pitch dequantization */ if ( ism_extended_metadata_flag ) { decode_angle_indices( st0, &( hIsmMetaData->angle[1] ), &flag_abs_orientation ); @@ -568,7 +575,7 @@ ivas_error ivas_ism_metadata_dec( st0->bit_stream = bstr_orig; st0->next_bit_pos = next_bit_pos_orig; - /* set bitstream pointers for each ISm */ + /* set bitstream pointers for each ISM */ for ( ch = 1; ch < *nchan_transport; ch++ ) { hSCE[ch]->hCoreCoder[0]->bit_stream = hSCE[ch - 1]->hCoreCoder[0]->bit_stream + ( hSCE[ch - 1]->hCoreCoder[0]->total_brate / FRAMES_PER_SEC ); @@ -600,12 +607,12 @@ ivas_error ivas_ism_metadata_dec_create( int16_t ch; ivas_error error; - /* allocate ISm metadata handles */ + /* allocate ISM metadata handles */ for ( ch = 0; ch < MAX_NUM_OBJECTS; ch++ ) { if ( ( st_ivas->hIsmMetaData[ch] = (ISM_METADATA_HANDLE) malloc( sizeof( ISM_METADATA_FRAME ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISm MetaData\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISM MetaData\n" ) ); } st_ivas->hIsmMetaData[ch]->last_ism_metadata_flag = 0; @@ -631,18 +638,26 @@ ivas_error ivas_ism_metadata_dec_create( return IVAS_ERR_OK; } + #ifdef TD5 +/*------------------------------------------------------------------------- + * decode_angle_indices() + * + * Decoding of an angle + *-------------------------------------------------------------------------*/ + static void decode_angle_indices( DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ int16_t *flag_abs_azimuth /* o : Azimuth encoding mode */ ) { + int16_t idx_azimuth, nbits_diff_azimuth, diff, sgn; + int16_t idx_elevation, nbits_diff_elevation; + /*----------------------------------------------------------------* * Azimuth decoding and dequantization *----------------------------------------------------------------*/ - int16_t idx_azimuth, nbits_diff_azimuth, diff, sgn; - int16_t idx_elevation, nbits_diff_elevation; /* Decode azimuth index */ if ( get_next_indice( st0, 1 ) == 1 ) /* azimuth_abs_flag */ @@ -759,28 +774,32 @@ static void decode_angle_indices( { idx_elevation = angle->last_elevation_idx; } + /*----------------------------------------------------------------* * Final updates *----------------------------------------------------------------*/ - /* updates */ angle->last_azimuth_idx = idx_azimuth; angle->last_elevation_idx = idx_elevation; + return; } -int16_t decode_radius( + +/*------------------------------------------------------------------------- + * decode_radius() + * + * Radius decoding and dequantization + *-------------------------------------------------------------------------*/ + +static int16_t decode_radius( DEC_CORE_HANDLE st0, /* i/o: bitstream handle */ int16_t *last_radius_idx, /* i/o: last radius index */ int16_t *flag_abs_radius /* o : Radius encoding mode */ ) { - /*----------------------------------------------------------------* - * Radius decoding and dequantization - *----------------------------------------------------------------*/ int16_t idx_radius, nbits_diff_radius, diff, sgn; - /* Decode radius index */ if ( get_next_indice( st0, 1 ) == 1 ) /* elevation_abs_flag */ { @@ -829,12 +848,9 @@ int16_t decode_radius( idx_radius = *last_radius_idx; } - /*----------------------------------------------------------------* - * Final updates - *----------------------------------------------------------------*/ - - /* updates */ + /* Final updates */ *last_radius_idx = idx_radius; + return idx_radius; } #endif diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index f34aa023f695ae2175a5baa88c3519b7db3f0c4f..acf62ba1a718f259da0e54fa256a0880e8a387f9 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -621,11 +621,19 @@ ivas_error ivas_param_ism_dec_open( *-------------------------------------------------------------------------*/ void ivas_param_ism_dec_close( - DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ - AUDIO_CONFIG output_config /* i : output audio configuration */ + DIRAC_DEC_HANDLE *hDirAC_out, /* i/o: decoder DirAC handle */ + AUDIO_CONFIG output_config /* i : output audio configuration */ ) { int16_t i; + DIRAC_DEC_HANDLE hDirAC; + + if ( hDirAC_out == NULL || *hDirAC_out == NULL ) + { + return; + } + + hDirAC = *hDirAC_out; /* Config & CLDFB */ if ( hDirAC->hParamIsm != NULL ) @@ -782,7 +790,8 @@ void ivas_param_ism_dec_close( hDirAC->hParamIsmRendering = NULL; } - free( hDirAC ); + free( *hDirAC_out ); + *hDirAC_out = NULL; return; } diff --git a/lib_dec/ivas_lfe_dec.c b/lib_dec/ivas_lfe_dec.c index 55a68d892ba73518aaad01b8ba2e7c8ea9f569c1..5c250286eedfd2291b691c92b3587f71ea484674 100644 --- a/lib_dec/ivas_lfe_dec.c +++ b/lib_dec/ivas_lfe_dec.c @@ -477,19 +477,25 @@ ivas_error ivas_create_lfe_dec( *-------------------------------------------------------------------------*/ void ivas_lfe_dec_close( - LFE_DEC_HANDLE hLFE /* i/o: LFE decoder handle */ + LFE_DEC_HANDLE *hLFE /* i/o: LFE decoder handle */ ) { - free( hLFE->pWindow_state ); - hLFE->pWindow_state = NULL; + if ( hLFE == NULL || *hLFE == NULL ) + { + return; + } - if ( hLFE->lfe_delay_buf != NULL ) + free( ( *hLFE )->pWindow_state ); + ( *hLFE )->pWindow_state = NULL; + + if ( ( *hLFE )->lfe_delay_buf != NULL ) { - free( hLFE->lfe_delay_buf ); - hLFE->lfe_delay_buf = NULL; + free( ( *hLFE )->lfe_delay_buf ); + ( *hLFE )->lfe_delay_buf = NULL; } - free( hLFE ); + free( ( *hLFE ) ); + ( *hLFE ) = NULL; return; } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index b8b7b74ffc51647d6d466e68ea325f111014fd4b..e28b31740867ee7f478741e9efeece75ba8dea68 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -392,9 +392,18 @@ ivas_error ivas_masa_dec_open( *-----------------------------------------------------------------------*/ void ivas_masa_dec_close( - MASA_DECODER_HANDLE hMasa /* i/o: MASA metadata structure */ + MASA_DECODER_HANDLE *hMasa_out /* i/o: MASA metadata structure */ ) { + MASA_DECODER_HANDLE hMasa; + + if ( hMasa_out == NULL || *hMasa_out == NULL ) + { + return; + } + + hMasa = *hMasa_out; + /* Free spherical grid memory if in use */ if ( hMasa->data.sph_grid16 != NULL ) { @@ -436,8 +445,8 @@ void ivas_masa_dec_close( hMasa->hMasaLfeSynth = NULL; } - free( hMasa ); - hMasa = NULL; + free( *hMasa_out ); + *hMasa_out = NULL; return; } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 6bfddc78e64bc00e0462095141447baea2dc1637..a6637ed1f2d306d2cbd52ef130f7755d848582f9 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1124,8 +1124,8 @@ void ivas_param_mc_dec_close( hParamMC->hoa_encoder = NULL; } - free( hParamMC ); - hParamMC = NULL; + free( *hParamMC_out ); + *hParamMC_out = NULL; return; } diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c index f6d159083baa56a75cce8d2ae1d633d2dfc85979..3ef12f309478a30e2deec4c55970c6234dcb43cf 100644 --- a/lib_dec/ivas_mcmasa_dec.c +++ b/lib_dec/ivas_mcmasa_dec.c @@ -58,10 +58,7 @@ ivas_error ivas_mcmasa_dec_reconfig( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; /* close the old MASA instance */ - if ( st_ivas->hMasa != NULL ) - { - ivas_masa_dec_close( st_ivas->hMasa ); - } + ivas_masa_dec_close( &( st_ivas->hMasa ) ); /* get new McMASA settings */ ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 96a535f4278704fbb5c580ec379acf0813df5623..553cdf2a1bc37c43ba94d7f697d35f2530169ffd 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -728,24 +728,14 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hParamMC != NULL ) { ivas_param_mc_dec_close( &st_ivas->hParamMC ); - st_ivas->hParamMC = NULL; /* remove ls conversion if it was allocated by ParamMC */ ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); } /* De-allocate McMasa-related handles */ - if ( st_ivas->hMasa != NULL ) - { - ivas_masa_dec_close( st_ivas->hMasa ); - st_ivas->hMasa = NULL; - } - - if ( st_ivas->hQMetaData != NULL ) - { - ivas_qmetadata_close( &st_ivas->hQMetaData ); - st_ivas->hQMetaData = NULL; - } + ivas_masa_dec_close( &( st_ivas->hMasa ) ); + ivas_qmetadata_close( &st_ivas->hQMetaData ); /* init LS conversion if the renderer type asks for it */ if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hLsSetUpConversion == NULL ) @@ -781,32 +771,18 @@ static ivas_error ivas_mc_dec_reconfig( } /* De-allocate McMasa-related handles */ - if ( st_ivas->hMasa != NULL ) - { - ivas_masa_dec_close( st_ivas->hMasa ); - st_ivas->hMasa = NULL; - } - - if ( st_ivas->hQMetaData != NULL ) - { - ivas_qmetadata_close( &st_ivas->hQMetaData ); - st_ivas->hQMetaData = NULL; - } + ivas_masa_dec_close( &( st_ivas->hMasa ) ); + ivas_qmetadata_close( &st_ivas->hQMetaData ); if ( last_mc_mode == MC_MODE_MCT ) { if ( st_ivas->hMCT != NULL && st_ivas->nchan_transport <= CPE_CHANNELS ) { ivas_mct_dec_close( &st_ivas->hMCT ); - st_ivas->hMCT = NULL; } /* LFE handle */ - if ( st_ivas->hLFE != NULL ) - { - ivas_lfe_dec_close( st_ivas->hLFE ); - st_ivas->hLFE = NULL; - } + ivas_lfe_dec_close( &( st_ivas->hLFE ) ); } } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) @@ -840,18 +816,10 @@ static ivas_error ivas_mc_dec_reconfig( if ( last_mc_mode == MC_MODE_MCT ) { - if ( st_ivas->hMCT != NULL ) - { - ivas_mct_dec_close( &st_ivas->hMCT ); - st_ivas->hMCT = NULL; - } + ivas_mct_dec_close( &st_ivas->hMCT ); /* LFE handle */ - if ( st_ivas->hLFE != NULL ) - { - ivas_lfe_dec_close( st_ivas->hLFE ); - st_ivas->hLFE = NULL; - } + ivas_lfe_dec_close( &( st_ivas->hLFE ) ); } } @@ -1046,10 +1014,9 @@ static ivas_error ivas_mc_dec_reconfig( } } } - else if ( ( st_ivas->renderer_type == RENDERER_DISABLE ) && ( st_ivas->hDirAC != NULL ) ) + else if ( st_ivas->renderer_type == RENDERER_DISABLE && st_ivas->hDirAC != NULL ) { - ivas_dirac_dec_close( st_ivas->hDirAC ); - st_ivas->hDirAC = NULL; + ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); } } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 76ac3578f9eab5d3eea290d4ba459d5fda9cbe08..745ea1b9ba052106117ba064d3f3524f69570125 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -47,7 +47,7 @@ #include "wmc_auto.h" /*-------------------------------------------------------------------* - * ivas_sba_dec_decoder() + * ivas_sba_dec_reconfigure() * * Reconfigure IVAS SBA decoder *-------------------------------------------------------------------*/ @@ -110,8 +110,7 @@ ivas_error ivas_sba_dec_reconfigure( if ( st_ivas->sba_mode != SBA_MODE_SPAR ) { - ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs, 0 ); - st_ivas->hSpar = NULL; + ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 0 ); if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, -1 ) ) != IVAS_ERR_OK ) { @@ -138,13 +137,14 @@ ivas_error ivas_sba_dec_reconfigure( if ( nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) ) { - ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs, 1 ); + ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 ); if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK ) { return error; } } + ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); } else @@ -253,11 +253,7 @@ ivas_error ivas_sba_dec_reconfigure( if ( ( ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) && ( ( sba_mode_old != st_ivas->sba_mode ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) ) { - if ( st_ivas->hDirAC != NULL ) - { - ivas_dirac_dec_close( st_ivas->hDirAC ); - st_ivas->hDirAC = NULL; - } + ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); @@ -267,16 +263,9 @@ ivas_error ivas_sba_dec_reconfigure( else if ( st_ivas->renderer_type == RENDERER_DISABLE || ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode != SBA_MODE_SPAR ) ) { - if ( st_ivas->hDirAC != NULL ) - { - ivas_dirac_dec_close( st_ivas->hDirAC ); - st_ivas->hDirAC = NULL; - } + ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); - if ( st_ivas->hVBAPdata != NULL ) - { - vbap_free_data( &( st_ivas->hVBAPdata ) ); - } + vbap_free_data( &( st_ivas->hVBAPdata ) ); } if ( st_ivas->hDirAC != NULL && st_ivas->sba_mode == SBA_MODE_SPAR ) diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 228a6e7b3aeba421b73bcd7025ad25525fbe8b83..87a76599929caa2a2b2e9dbd5a7ab5acc00c24ab 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -114,7 +114,7 @@ ivas_error ivas_sce_dec( { if ( st->low_rate_mode ) { - /* ISm Low-rate mode -> always WB */ + /* ISM Low-rate mode -> always WB */ st->bwidth = WB; } else if ( hSCE->element_brate < MIN_BRATE_SWB_SCE ) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 53c60c3d3401d82898ef72a8464080c3186df47c..01e4db2ed40c3764b0b9d07e375cb255767d39c2 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -61,8 +61,7 @@ static void ivas_spar_dec_MD( Decoder_Struct *st_ivas, Decoder_State *st0 ); *------------------------------------------------------------------------*/ ivas_error ivas_spar_dec_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ - , + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ) { @@ -187,38 +186,39 @@ ivas_error ivas_spar_dec_open( *------------------------------------------------------------------------*/ void ivas_spar_dec_close( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - const int32_t output_Fs /* i : output sampling rate */ - , + SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */ + const int32_t output_Fs, /* i : output sampling rate */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ) { - if ( hSpar != NULL ) + if ( *hSpar == NULL || hSpar == NULL ) { - /* MD handle */ - ivas_spar_md_dec_close( &hSpar->hMdDec ); + return; + } - /* TD decorrelator handle */ - ivas_td_decorr_dec_close( &hSpar->hTdDecorr ); + /* MD handle */ + ivas_spar_md_dec_close( &( *hSpar )->hMdDec ); - /* FB mixer handle */ - ivas_FB_mixer_close( &hSpar->hFbMixer, output_Fs, spar_reconfig_flag ); + /* TD decorrelator handle */ + ivas_td_decorr_dec_close( &( *hSpar )->hTdDecorr ); - /* AGC */ - ivas_spar_agc_dec_close( &hSpar->hAgcDec ); + /* FB mixer handle */ + ivas_FB_mixer_close( &( *hSpar )->hFbMixer, output_Fs, spar_reconfig_flag ); - /* PCA */ - if ( hSpar->hPCA != NULL ) - { - free( hSpar->hPCA ); - hSpar->hPCA = NULL; - } + /* AGC */ + ivas_spar_agc_dec_close( &( *hSpar )->hAgcDec ); - if ( !spar_reconfig_flag ) - { - free( hSpar ); - hSpar = NULL; - } + /* PCA */ + if ( ( *hSpar )->hPCA != NULL ) + { + free( ( *hSpar )->hPCA ); + ( *hSpar )->hPCA = NULL; + } + + if ( !spar_reconfig_flag ) + { + free( ( *hSpar ) ); + ( *hSpar ) = NULL; } return; diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index ff6f858d3142e11d5c1e00179b0ff2cd4d1fe721..3b47d6500e1ab98d6a3bcdca8da23c7fcccbfb47 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -305,6 +305,7 @@ static void ivas_spar_md_dec_matrix_close( free( hMdDecoder->spar_md.band_coeffs ); hMdDecoder->spar_md.band_coeffs = NULL; } + if ( hMdDecoder->mixer_mat != NULL ) { for ( i = 0; i < num_channels; i++ ) @@ -418,11 +419,8 @@ void ivas_spar_md_dec_close( ivas_spar_md_dec_matrix_close( hMdDecoder, num_channels ); - if ( *hMdDec != NULL ) - { - free( *hMdDec ); - *hMdDec = NULL; - } + free( *hMdDec ); + *hMdDec = NULL; return; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 51d825c0fb63277c478e8c1ba0051bdf2e5125d2..d8c0f65349f6d52e2b9f414659ba3a82338b036f 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -805,6 +805,7 @@ typedef struct ivas_spar_md_dec_state_t int16_t table_idx; int16_t dtx_vad; int16_t spar_hoa_md_flag; + } ivas_spar_md_dec_state_t; @@ -1050,7 +1051,7 @@ typedef struct ivas_binaural_rendering_struct /* Convolution module structure */ BINRENDERER_CONV_MODULE_HANDLE hBinRenConvModule; - /* Variables related to reverb module */ + /* Variables related to reverberator module */ float earlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX]; REVERB_STRUCT_HANDLE hReverb; diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index b8d96233dbe4d44d311cc6e71a04e3b0c8d0decf..fc3e1db99d6d48b7d9f215d1b79b15339ea419eb 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -150,20 +150,19 @@ void stereo_tcx_init_dec( *-------------------------------------------------------------------*/ void stereo_tcx_core_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const FRAME_MODE frameMode, /* i : Decoder frame mode */ - float *signal_out, /* o : synthesis @internal_Fs */ - float *signal_outFB, /* o : synthesis @output_Fs */ - float pitch_buf[], /* o : floating pitch for each subframe */ - const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const int16_t last_element_mode, /* i : last element mode */ - const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ - , - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const ISM_MODE ism_mode /* i : ISM mode (only needed if format is ISM) */ + Decoder_State *st, /* i/o: decoder state structure */ + const FRAME_MODE frameMode, /* i : Decoder frame mode */ + float *signal_out, /* o : synthesis @internal_Fs */ + float *signal_outFB, /* o : synthesis @output_Fs */ + float pitch_buf[], /* o : floating pitch for each subframe */ + const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ + const int16_t last_element_mode, /* i : last element mode */ + const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ + const int16_t nchan_out, /* i : number of output channels */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const ISM_MODE ism_mode /* i : ISM mode (only needed if format is ISM)*/ ) { int16_t i, k; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index da9c6efae4d79165cbeeee6784bf1622abd1bd1b..61c9494e30bf2244b42a65534bc5e874149f330f 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -387,9 +387,8 @@ ivas_error IVAS_DEC_Configure( const IVAS_DEC_AUDIO_CONFIG outputFormat, /* i : output format */ const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ - const int16_t enableHeadRotation /* i : enable head rotation for binaural output */ - , - const int16_t renderConfigEnabled /* i : enable Renderer config. file for binaural output */ + const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ + const int16_t renderConfigEnabled /* i : enable Renderer config. file for binaural output */ ) { Decoder_Struct *st_ivas; @@ -890,10 +889,10 @@ ivas_error IVAS_DEC_GetMasaMetadata( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_FeedHeadTrackData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef TD5 IVAS_QUATERNION *orientation, /* i : head-tracking data, listener orientation */ - IVAS_POSITION *Pos /* i : listener position */ + IVAS_POSITION *Pos /* i : listener position */ #else IVAS_QUATERNION *orientation /* i : head-tracking data, listener orientation */ #endif diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index e115ecd1989773491b23185f65f91e02a77db492..a717e0002eead8416ddd194f2de72e256ed97c58 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -129,9 +129,8 @@ ivas_error IVAS_DEC_Configure( const IVAS_DEC_AUDIO_CONFIG outputFormat, /* i : output format */ const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ - const int16_t enableHeadRotation /* i : enable head rotation for binaural output */ - ,const int16_t renderConfigEnabled /* i : enable Renderer config. file for binaural output */ - + const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ + const int16_t renderConfigEnabled /* i : enable Renderer config. file for binaural output */ ); void IVAS_DEC_Close( @@ -215,7 +214,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( /*! r: error code */ ivas_error IVAS_DEC_VoIP_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ int16_t *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ const uint32_t systemTimestamp_ms /* i : current system timestamp */ #ifdef SUPPORT_JBM_TRACEFILE diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 7019beca8ea04742ef56a7e255f8b3f0aa0a836d..d3cc3f1743d561936a31b3a12961f1997d06c9a9 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -58,9 +58,8 @@ ivas_error init_encoder( const int16_t idchan, /* i : channel ID */ const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ const int16_t interval_SID, /* i : interval for SID update */ - const int16_t vad_only_flag /* i : flag to indicate front-VAD structure */ - , - const ISM_MODE ism_mode /* i : ISM mode */ + const int16_t vad_only_flag, /* i : flag to indicate front-VAD structure */ + const ISM_MODE ism_mode /* i : ISM mode */ ) { int16_t i; @@ -863,32 +862,22 @@ void LPDmem_enc_init( return; } + + /*-----------------------------------------------------------------------* - * destroy_encoder() + * destroy_cldfb_encoder() * * Free memory which was allocated in init_encoder() *-----------------------------------------------------------------------*/ -void destroy_encoder( +void destroy_cldfb_encoder( Encoder_State *st /* i/o: Encoder static variables structure */ ) { - if ( st->cldfbSynTd != NULL ) - { - deleteCldfb( &st->cldfbSynTd ); - } - - if ( st->cldfbAnaEnc != NULL ) - { - deleteCldfb( &st->cldfbAnaEnc ); - } - - if ( st->hFdCngEnc != NULL ) - { - deleteFdCngEnc( &st->hFdCngEnc ); - } + deleteCldfb( &st->cldfbSynTd ); + deleteCldfb( &st->cldfbAnaEnc ); - /* Close Core */ + deleteFdCngEnc( &st->hFdCngEnc ); return; } diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index f98c22b97e46d286c4a5be8e8df49c9c299d4c48..83dbdad1e183efb3bb5990657633b3c68323b389 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -195,22 +195,24 @@ void ivas_spar_agc_enc_close( { ivas_agc_enc_state_t *hAgc; + if ( hAgcEnc == NULL || *hAgcEnc == NULL ) + { + return; + } + hAgc = *hAgcEnc; - if ( hAgc != NULL ) - { - free( hAgc->agc_com.winFunc ); - hAgc->agc_com.winFunc = NULL; + free( hAgc->agc_com.winFunc ); + hAgc->agc_com.winFunc = NULL; - free( hAgc->gain_state ); - hAgc->gain_state = NULL; + free( hAgc->gain_state ); + hAgc->gain_state = NULL; - free( hAgc->gain_data ); - hAgc->gain_data = NULL; + free( hAgc->gain_data ); + hAgc->gain_data = NULL; - free( hAgc ); - hAgc = NULL; - } + free( *hAgcEnc ); + *hAgcEnc = NULL; return; } diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c index f419425104264631193decc419d5a668e5dafd3f..e9d6968f1b2d01f41523c1a7115509890251b28c 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig.c +++ b/lib_enc/ivas_corecoder_enc_reconfig.c @@ -221,8 +221,7 @@ ivas_error ivas_corecoder_enc_reconfig( if ( st_ivas->nCPE <= 1 && st_ivas->hMCT != NULL ) { - ivas_mct_enc_close( st_ivas->hMCT ); - st_ivas->hMCT = NULL; + ivas_mct_enc_close( &( st_ivas->hMCT ) ); } /* special case, if we have MCT now and had a single CPE before, remove the MDCT Stereo handles */ diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index 7b4685251f2466d24529b595dacdb60cb409bada..b8949329582e8684a9f1f185d86c71647ab7e807 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -114,7 +114,7 @@ void ivas_decision_matrix_enc( if ( st->element_mode == IVAS_SCE && st->low_rate_mode ) { - /* ISm low-rate mode */ + /* ISM low-rate mode */ st->core = ACELP_CORE; st->coder_type = INACTIVE; } @@ -391,7 +391,7 @@ void ivas_signaling_enc( } else if ( st->element_mode == IVAS_SCE && st->low_rate_mode ) { - /* ISm Low-rate mode -> do nothing -> always WB, ACELP core, IC coder_type */ + /* ISM Low-rate mode -> do nothing -> always WB, ACELP core, IC coder_type */ } else if ( ( st->element_mode == IVAS_CPE_MDCT && st->idchan == 1 ) || st->core_brate <= SID_2k40 ) { diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 61edd0b9a973a3b590c90216ae37fdda137fc55c..43bc94fb04c06e30858d5419907091bac7b4872a 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -245,15 +245,23 @@ ivas_error ivas_dirac_enc_reconfigure( /*------------------------------------------------------------------------- * ivas_dirac_enc_close() * - * Close DirAC + * Close DirAC encoder handle *------------------------------------------------------------------------*/ void ivas_dirac_enc_close( - DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ - const int32_t input_Fs /* i : input sampling rate */ + DIRAC_ENC_HANDLE *hDirAC_out, /* i/o: encoder DirAC handle */ + const int32_t input_Fs /* i : input sampling rate */ ) { int16_t i, j; + DIRAC_ENC_HANDLE hDirAC; + + if ( hDirAC_out == NULL || *hDirAC_out == NULL ) + { + return; + } + + hDirAC = *hDirAC_out; if ( hDirAC->hFbMixer != NULL ) { @@ -303,7 +311,8 @@ void ivas_dirac_enc_close( hDirAC->hConfig = NULL; } - free( hDirAC ); + free( *hDirAC_out ); + *hDirAC_out = NULL; return; } diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 23d0bdd0e59c253aad7756ce36fc77976dc1a94e..e117cfc5a55ba7e737c495d437a8c1fe282c91d9 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -117,17 +117,19 @@ void ivas_spar_covar_enc_close( { ivas_enc_cov_handler_state_t *hCovState; + if ( hCovEnc == NULL || *hCovEnc == NULL ) + { + return; + } + hCovState = *hCovEnc; - if ( hCovState != NULL ) - { - ivas_spar_covar_smooth_enc_close( &hCovState->pCov_state, nchan_inp ); + ivas_spar_covar_smooth_enc_close( &hCovState->pCov_state, nchan_inp ); - ivas_spar_covar_smooth_enc_close( &hCovState->pCov_dtx_state, nchan_inp ); + ivas_spar_covar_smooth_enc_close( &hCovState->pCov_dtx_state, nchan_inp ); - free( hCovState ); - hCovState = NULL; - } + free( *hCovEnc ); + *hCovEnc = NULL; return; } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 766caa1519443179cc46ca125ff0c395a9f333cf..83161e761f3de331b9bc05df570077d5134eb721 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -266,7 +266,7 @@ void ivas_initialize_handles_enc( st_ivas->mem_hp20_in = NULL; - /* ISm metadata handles */ + /* ISM metadata handles */ for ( i = 0; i < MAX_NUM_OBJECTS; i++ ) { st_ivas->hIsmMetaData[i] = NULL; @@ -725,7 +725,7 @@ void destroy_core_enc( ENC_CORE_HANDLE hCoreCoder /* i/o: core encoder structure */ ) { - destroy_encoder( hCoreCoder ); + destroy_cldfb_encoder( hCoreCoder ); if ( hCoreCoder->hSignalBuf != NULL ) { @@ -916,14 +916,7 @@ void ivas_destroy_enc( } /* ISM metadata handles */ - for ( n = 0; n < MAX_NUM_OBJECTS; n++ ) - { - if ( st_ivas->hIsmMetaData[n] != NULL ) - { - free( st_ivas->hIsmMetaData[n] ); - st_ivas->hIsmMetaData[n] = NULL; - } - } + ivas_ism_metadata_close( st_ivas->hIsmMetaData ); /* ISM DTX Handle */ if ( st_ivas->hISMDTX != NULL ) @@ -936,71 +929,39 @@ void ivas_destroy_enc( ivas_qmetadata_close( &( st_ivas->hQMetaData ) ); /* DirAC handle */ - if ( st_ivas->hDirAC != NULL ) + if ( ivas_format == ISM_FORMAT ) { - if ( ivas_format == ISM_FORMAT ) - { - ivas_param_ism_enc_close( st_ivas->hDirAC, st_ivas->hEncoderConfig->input_Fs ); - } - else - { - ivas_dirac_enc_close( st_ivas->hDirAC, st_ivas->hEncoderConfig->input_Fs ); - } - st_ivas->hDirAC = NULL; + ivas_param_ism_enc_close( &( st_ivas->hDirAC ), st_ivas->hEncoderConfig->input_Fs ); } - - /* SPAR handle */ - if ( st_ivas->hSpar != NULL ) + else { - ivas_spar_enc_close( st_ivas->hSpar, st_ivas->hEncoderConfig->input_Fs, nchan_inp, 0 ); - st_ivas->hSpar = NULL; + ivas_dirac_enc_close( &( st_ivas->hDirAC ), st_ivas->hEncoderConfig->input_Fs ); } + /* SPAR handle */ + ivas_spar_enc_close( &( st_ivas->hSpar ), st_ivas->hEncoderConfig->input_Fs, nchan_inp, 0 ); + /* MASA handle */ - if ( st_ivas->hMasa != NULL ) - { #ifdef FIX_350_MASA_DELAY_COMP - ivas_masa_enc_close( st_ivas->hMasa ); + ivas_masa_enc_close( &( st_ivas->hMasa ) ); #else - ivas_masa_enc_close( st_ivas->hMasa, st_ivas->nchan_transport, ivas_format ); + ivas_masa_enc_close( &( st_ivas->hMasa ), st_ivas->nchan_transport, ivas_format ); #endif - st_ivas->hMasa = NULL; - } /* MCT handle */ - if ( st_ivas->hMCT != NULL ) - { - ivas_mct_enc_close( st_ivas->hMCT ); - st_ivas->hMCT = NULL; - } + ivas_mct_enc_close( &( st_ivas->hMCT ) ); + + /* LFE handle */ + ivas_lfe_enc_close( &( st_ivas->hLFE ) ); /* Parametric MC handle */ - if ( st_ivas->hParamMC != NULL ) - { - ivas_param_mc_enc_close( st_ivas->hParamMC, st_ivas->hEncoderConfig->input_Fs ); - st_ivas->hParamMC = NULL; - } + ivas_param_mc_enc_close( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs ); /* Multi-channel MASA handle */ - if ( st_ivas->hMcMasa != NULL ) - { - ivas_mcmasa_enc_close( st_ivas->hMcMasa, st_ivas->hEncoderConfig->input_Fs ); - st_ivas->hMcMasa = NULL; - } + ivas_mcmasa_enc_close( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs ); /* Stereo downmix for EVS encoder handle */ - if ( st_ivas->hStereoDmxEVS != NULL ) - { - stereo_dmx_evs_close_encoder( st_ivas->hStereoDmxEVS ); - st_ivas->hStereoDmxEVS = NULL; - } - - /* LFE handle */ - if ( st_ivas->hLFE != NULL ) - { - ivas_lfe_enc_close( st_ivas->hLFE ); - st_ivas->hLFE = NULL; - } + stereo_dmx_evs_close_encoder( &( st_ivas->hStereoDmxEVS ) ); /* Encoder configuration handle */ if ( st_ivas->hEncoderConfig != NULL ) diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 42f877aa1730524c7cbf9b8bafcb4bcb06a0920a..ead873af0c148e40a814a06861c9133b3f6fec1c 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -331,7 +331,6 @@ ivas_error ivas_ism_enc( * - reconfigure the ISM format encoder *-------------------------------------------------------------------------*/ -/*! r : ISM format mode */ ivas_error ivas_ism_enc_config( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) @@ -391,8 +390,7 @@ ivas_error ivas_ism_enc_config( if ( st_ivas->ism_mode == ISM_MODE_DISC && last_ism_mode == ISM_MODE_PARAM ) { /* Deallocate the memory used by ParamISM when switch to Discrete ISM */ - ivas_param_ism_enc_close( st_ivas->hDirAC, st_ivas->hEncoderConfig->input_Fs ); - st_ivas->hDirAC = NULL; + ivas_param_ism_enc_close( &( st_ivas->hDirAC ), st_ivas->hEncoderConfig->input_Fs ); } } diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 3472de0c5a1fc3bafa98b8158edde9aa2e758e0c..7ce4132321f991659830c4b41358ec65146bac57 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -65,11 +65,14 @@ #define INTER_OBJECT_PARAM_CHECK ( ( ISM_FEC_MAX / 2 ) - 2 ) /* note: constant must be less than (ISM_FEC_MAX / number of coded parameters) */ + #ifdef TD5 /*-----------------------------------------------------------------------* - * Local functions + * Local function declarations *-----------------------------------------------------------------------*/ + static void encode_angle_indices( BSTR_ENC_HANDLE hBstr, ISM_METADATA_ANGLE_HANDLE angle, const int16_t last_ism_metadata_flag, const int16_t ini_frame, const int16_t idx_azimuth_abs, const int16_t idx_elevation_abs, int16_t *flag_abs_azimuth, int16_t *flag_abs_elevation ); + static void encode_radius( BSTR_ENC_HANDLE hBstr, int16_t *last_radius_idx, int16_t *radius_diff_cnt, const int16_t last_ism_metadata_flag, const int16_t idx_radius_abs, int16_t *flag_abs_radius ); #endif @@ -84,10 +87,10 @@ ivas_error ivas_set_ism_metadata( ISM_METADATA_HANDLE hIsmMeta, /* o : ISM metadata handle */ const float azimuth, /* i : azimuth value */ #ifdef TD5 - const float elevation, /* i : elevation */ - float radius_meta, /* i : radius */ - float yaw, /* i : yaw */ - float pitch /* i : pitch */ + const float elevation, /* i : elevation */ + const float radius_meta, /* i : radius */ + const float yaw, /* i : yaw */ + const float pitch /* i : pitch */ #else const float elevation /* i : elevation value */ #endif @@ -108,6 +111,7 @@ ivas_error ivas_set_ism_metadata( hIsmMeta->yaw = yaw; hIsmMeta->pitch = pitch; #endif + return IVAS_ERR_OK; } @@ -115,7 +119,7 @@ ivas_error ivas_set_ism_metadata( /*-------------------------------------------------------------------------* * rate_ism_importance() * - * Rate importance of particular ISm streams + * Rate importance of particular ISM streams *-------------------------------------------------------------------------*/ static void rate_ism_importance( @@ -172,7 +176,7 @@ static void rate_ism_importance( *-------------------------------------------------------------------------*/ ivas_error ivas_ism_metadata_enc( - const int32_t ism_total_brate, /* i : ISms total bitrate */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ const int16_t nchan_transport, /* i : number of transport channels */ ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ SCE_ENC_HANDLE hSCE[], /* i/o: SCE encoder handles */ @@ -246,7 +250,6 @@ ivas_error ivas_ism_metadata_enc( set_s( flag_abs_radius, 0, num_obj ); #endif - /*----------------------------------------------------------------* * Set Metadata presence / importance flag *----------------------------------------------------------------*/ @@ -316,7 +319,7 @@ ivas_error ivas_ism_metadata_enc( } /*----------------------------------------------------------------* - * Rate importance of particular ISm streams + * Rate importance of particular ISM streams *----------------------------------------------------------------*/ rate_ism_importance( nchan_transport, hIsmMeta, hSCE, ism_imp ); @@ -343,7 +346,7 @@ ivas_error ivas_ism_metadata_enc( } #endif /*----------------------------------------------------------------* - * Write ISm common signaling + * Write ISM common signaling *----------------------------------------------------------------*/ /* write number of objects - unary coding */ @@ -352,13 +355,16 @@ ivas_error ivas_ism_metadata_enc( push_indice( hBstr, IND_ISM_NUM_OBJECTS, 1, 1 ); } push_indice( hBstr, IND_ISM_NUM_OBJECTS, 0, 1 ); + #ifdef TD5 + /* write extended metadata presence flag */ if ( ism_total_brate >= ISM_EXTENDED_METADATA_BRATE ) { push_indice( hBstr, IND_ISM_EXTENDED_FLAG, ism_extended_metadata_flag, ISM_EXTENDED_METADATA_BITS ); } #endif - /* write ISm metadata flag (one per object) */ + + /* write ISM metadata flag (one per object) */ for ( ch = 0; ch < nchan_transport; ch++ ) { push_indice( hBstr, IND_ISM_METADATA_FLAG, ism_imp[ch], ISM_METADATA_FLAG_BITS ); @@ -406,11 +412,11 @@ ivas_error ivas_ism_metadata_enc( if ( hIsmMeta[ch]->ism_metadata_flag ) { - #ifdef TD5 /*----------------------------------------------------------------* - * Obtain quantizer indices for azimuth and elevation + * Quantize and encode azimuth and elevation *----------------------------------------------------------------*/ + if ( ism_mode == ISM_MODE_DISC ) { idx_azimuth_abs = ism_quant_meta( hIsmMetaData->azimuth, &valQ, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ); @@ -424,7 +430,10 @@ ivas_error ivas_ism_metadata_enc( encode_angle_indices( hBstr, &( hIsmMetaData->angle[0] ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_azimuth_abs, idx_elevation_abs, &flag_abs_azimuth[ch], &flag_abs_elevation[ch] ); - /* Encode orientation and radius, if above certain bit rate etc, discrete ISM */ + /*----------------------------------------------------------------* + * Quantize and encode radius, yaw, and pitch + *----------------------------------------------------------------*/ + if ( ism_mode == ISM_MODE_DISC && ism_extended_metadata_flag ) { idx_azimuth_abs = ism_quant_meta( hIsmMetaData->yaw, &valQ, ism_azimuth_borders, 1 << ISM_AZIMUTH_NBITS ); @@ -433,6 +442,7 @@ ivas_error ivas_ism_metadata_enc( encode_angle_indices( hBstr, &( hIsmMetaData->angle[1] ), hIsmMetaData->last_ism_metadata_flag, hSCE[0]->hCoreCoder[0]->ini_frame, idx_azimuth_abs, idx_elevation_abs, &flag_abs_azimuth_orientation[ch], &flag_abs_elevation[ch] ); encode_radius( hBstr, &hIsmMetaData->last_radius_idx, &hIsmMetaData->radius_diff_cnt, hIsmMetaData->last_ism_metadata_flag, idx_radius_abs, &flag_abs_radius[ch] ); } + /* save number of metadata bits written */ if ( ism_mode == ISM_MODE_DISC ) { @@ -860,6 +870,7 @@ ivas_error ivas_ism_metadata_enc( return error; } + /*------------------------------------------------------------------------- * ivas_ism_metadata_enc_create() * @@ -888,12 +899,12 @@ ivas_error ivas_ism_metadata_enc_create( st_ivas->nSCE = nchan_transport; st_ivas->nCPE = 0; - /* allocate ISm metadata handles */ + /* allocate ISM metadata handles */ for ( ch = 0; ch < n_ISms; ch++ ) { if ( ( st_ivas->hIsmMetaData[ch] = (ISM_METADATA_HANDLE) malloc( sizeof( ISM_METADATA_FRAME ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISm MetaData\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISM MetaData\n" ) ); } #ifdef TD5 @@ -926,7 +937,14 @@ ivas_error ivas_ism_metadata_enc_create( return IVAS_ERR_OK; } + #ifdef TD5 +/*------------------------------------------------------------------------- + * encode_radius() + * + * Radius index encoding + *-------------------------------------------------------------------------*/ + static void encode_radius( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ int16_t *last_radius_idx, /* i/o: last radius index */ @@ -938,14 +956,8 @@ static void encode_radius( { int16_t idx_radius, nbits_diff_radius, diff; - - /*----------------------------------------------------------------* - * Radius index encoding - *----------------------------------------------------------------*/ idx_radius = idx_radius_abs; - nbits_diff_radius = 0; - *flag_abs_radius = 0; /* differential coding by default */ if ( *radius_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */ @@ -1023,17 +1035,23 @@ static void encode_radius( push_indice( hBstr, IND_ISM_RADIUS, idx_radius, nbits_diff_radius ); } - /*----------------------------------------------------------------* - * Updates - *----------------------------------------------------------------*/ + /* Updates */ *last_radius_idx = idx_radius_abs; + return; } + +/*----------------------------------------------------------------* + * encode_angle_indices() + * + * Encoding of an angle + *----------------------------------------------------------------*/ + static void encode_angle_indices( BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ - const int16_t last_ism_metadata_flag, /* last frame ism_metadata_flag */ + const int16_t last_ism_metadata_flag, /* i : last frame ism_metadata_flag */ const int16_t ini_frame, /* i : initialization frames counter */ const int16_t idx_azimuth_abs, /* i : Azimuth index */ const int16_t idx_elevation_abs, /* i : Elevation index */ @@ -1044,7 +1062,6 @@ static void encode_angle_indices( int16_t idx_azimuth, nbits_diff_azimuth, diff; int16_t idx_elevation, nbits_diff_elevation; - /*----------------------------------------------------------------* * Azimuth index encoding *----------------------------------------------------------------*/ @@ -1145,10 +1162,9 @@ static void encode_angle_indices( /*----------------------------------------------------------------* * Elevation index encoding *----------------------------------------------------------------*/ - idx_elevation = idx_elevation_abs; + idx_elevation = idx_elevation_abs; nbits_diff_elevation = 0; - *flag_abs_elevation = 0; /* differential coding by default */ if ( angle->elevation_diff_cnt == ISM_FEC_MAX /* make differential encoding in ISM_FEC_MAX consecutive frames at maximum (in order to control the decoding in FEC) */ || last_ism_metadata_flag == 0 /* If last frame had no metadata coded, do not use differential coding */ diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index fb69537bc2e96e65aec85ba8a438b2f17c612efb..cde2327968bf85a5dc7869b96db8fb261317cbc9 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -312,23 +312,29 @@ ivas_error ivas_param_ism_enc_open( /*-------------------------------------------------------------------------* * ivas_param_ism_enc_close() * - * Close Param ISM handle + * Close Param ISM encoder handle *-------------------------------------------------------------------------*/ void ivas_param_ism_enc_close( - DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ - const int32_t input_Fs /* i : input sampling_rate */ + DIRAC_ENC_HANDLE *hDirAC, /* i/o: encoder DirAC handle */ + const int32_t input_Fs /* i : input sampling_rate */ ) { - ivas_FB_mixer_close( &hDirAC->hFbMixer, input_Fs, 0 ); + if ( hDirAC == NULL || *hDirAC == NULL ) + { + return; + } - if ( hDirAC->hParamIsm != NULL ) + ivas_FB_mixer_close( &( *hDirAC )->hFbMixer, input_Fs, 0 ); + + if ( ( *hDirAC )->hParamIsm != NULL ) { - free( hDirAC->hParamIsm ); - hDirAC->hParamIsm = NULL; + free( ( *hDirAC )->hParamIsm ); + ( *hDirAC )->hParamIsm = NULL; } - free( hDirAC ); + free( ( *hDirAC ) ); + ( *hDirAC ) = NULL; return; } @@ -388,6 +394,7 @@ void ivas_param_ism_enc( } } } + /* Quantize DOAs */ ivas_param_ism_enc_quantize_DOA( st_ivas->hIsmMetaData, hParamIsm ); @@ -465,10 +472,10 @@ static void ivas_param_ism_enc_quantize_DOA_dtx( *-------------------------------------------------------------------------*/ void ivas_param_ism_metadata_dtx_enc( - BSTR_ENC_HANDLE hBstr, /* i/o : bitstream handle */ - ISM_METADATA_HANDLE hIsmMeta[], /* i : ISM metadata handles */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + ISM_METADATA_HANDLE hIsmMeta[], /* i : ISM metadata handles */ ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ - PARAM_ISM_CONFIG_HANDLE hParamIsm /* i : Param ISM Enc Handle */ + PARAM_ISM_CONFIG_HANDLE hParamIsm /* i : Param ISM Enc Handle */ ) { int16_t i, nBits, nBits_unused; diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc.c index fc16c279ee62d40309caec961f91836c0ef5a5de..a14424774ffec7ed5270d26f8d46926c9568e53e 100644 --- a/lib_enc/ivas_lfe_enc.c +++ b/lib_enc/ivas_lfe_enc.c @@ -460,21 +460,27 @@ ivas_error ivas_create_lfe_enc( *-------------------------------------------------------------------------*/ void ivas_lfe_enc_close( - LFE_ENC_HANDLE hLFE /* i/o: LFE encoder handle */ + LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */ ) { - if ( hLFE->old_wtda_audio != NULL ) + if ( hLFE == NULL || *hLFE == NULL ) { - free( hLFE->old_wtda_audio ); - hLFE->old_wtda_audio = NULL; + return; } - if ( hLFE->pWindow_state ) + + if ( ( *hLFE )->old_wtda_audio != NULL ) + { + free( ( *hLFE )->old_wtda_audio ); + ( *hLFE )->old_wtda_audio = NULL; + } + if ( ( *hLFE )->pWindow_state ) { - free( hLFE->pWindow_state ); - hLFE->pWindow_state = NULL; + free( ( *hLFE )->pWindow_state ); + ( *hLFE )->pWindow_state = NULL; } - free( hLFE ); + free( ( *hLFE ) ); + ( *hLFE ) = NULL; return; } diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index dca9be401092af394f7a1b08ee95fd50100726cb..b930714017535bfa4cba73282edbf982958ab575 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -149,7 +149,7 @@ ivas_error ivas_masa_enc_open( *-----------------------------------------------------------------------*/ void ivas_masa_enc_close( - MASA_ENCODER_HANDLE hMasa /* i/o: MASA metadata structure */ + MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */ #ifndef FIX_350_MASA_DELAY_COMP , const int16_t nchan_transport, /* i : Number of transport channels */ @@ -159,9 +159,14 @@ void ivas_masa_enc_close( { int16_t i; - for ( i = 0; i < hMasa->data.num_Cldfb_instances; i++ ) + if ( hMasa == NULL || *hMasa == NULL ) + { + return; + } + + for ( i = 0; i < ( *hMasa )->data.num_Cldfb_instances; i++ ) { - deleteCldfb( &( hMasa->data.cldfbAnaEnc[i] ) ); + deleteCldfb( &( ( *hMasa )->data.cldfbAnaEnc[i] ) ); } #ifndef FIX_350_MASA_DELAY_COMP @@ -169,13 +174,14 @@ void ivas_masa_enc_close( { for ( i = 0; i < nchan_transport; i++ ) { - free( hMasa->data.delay_buffer[i] ); - hMasa->data.delay_buffer[i] = NULL; + free( ( *hMasa )->data.delay_buffer[i] ); + ( *hMasa )->data.delay_buffer[i] = NULL; } } #endif - free( hMasa ); + free( ( *hMasa ) ); + ( *hMasa ) = NULL; return; } diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index e51887d455a0ed719b7c51a78b91736e3f9a327f..db9945d0cec3cc358dcec3be5c7ddd917e750ad7 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -360,14 +360,20 @@ ivas_error ivas_param_mc_enc_reconfig( *------------------------------------------------------------------------*/ void ivas_param_mc_enc_close( - PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ + PARAM_MC_ENC_HANDLE *hParamMC, /* i/o: Parametric MC encoder handle */ const int32_t sampling_rate ) { - ivas_param_mc_metadata_close( &hParamMC->hMetadataPMC ); + if ( hParamMC == NULL || *hParamMC == NULL ) + { + return; + } + + ivas_param_mc_metadata_close( &( *hParamMC )->hMetadataPMC ); - ivas_FB_mixer_close( &hParamMC->hFbMixer, sampling_rate, 0 ); + ivas_FB_mixer_close( &( *hParamMC )->hFbMixer, sampling_rate, 0 ); - free( hParamMC ); + free( ( *hParamMC ) ); + ( *hParamMC ) = NULL; return; } @@ -380,10 +386,10 @@ void ivas_param_mc_enc_close( *------------------------------------------------------------------------*/ void ivas_param_mc_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ - float data_f[][L_FRAME48k], /* i/o: input: CICP6, CICP12, CICP14, CICP16 or CICP19 MC data */ - const int16_t input_frame /* i : input frame length */ + Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ + BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ + float data_f[][L_FRAME48k], /* i/o: input: CICP6, CICP12, CICP14, CICP16 or CICP19 MC data */ + const int16_t input_frame /* i : input frame length */ ) { int16_t k; diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index b79f4b62e4a068efb206ac752a2f9535add96ec3..866e4e176c9b0f915d58f87ff6d993486652c258 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -451,11 +451,11 @@ ivas_error ivas_mcmasa_enc_reconfig( /* brute-force solution: close McMASA and re-instantiate with new settings */ #ifdef FIX_350_MASA_DELAY_COMP - ivas_masa_enc_close( st_ivas->hMasa ); + ivas_masa_enc_close( &( st_ivas->hMasa ) ); #else - ivas_masa_enc_close( st_ivas->hMasa, st_ivas->nchan_transport, st_ivas->hEncoderConfig->ivas_format ); + ivas_masa_enc_close( &( st_ivas->hMasa ), st_ivas->nchan_transport, st_ivas->hEncoderConfig->ivas_format ); #endif - ivas_mcmasa_enc_close( st_ivas->hMcMasa, st_ivas->hEncoderConfig->input_Fs ); + ivas_mcmasa_enc_close( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs ); /* Determine if to separate some channels from the analysis */ ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->hEncoderConfig->element_mode_init ), ivas_total_brate ); @@ -483,28 +483,33 @@ ivas_error ivas_mcmasa_enc_reconfig( *--------------------------------------------------------------------------*/ void ivas_mcmasa_enc_close( - MCMASA_ENC_HANDLE hMcMasa, /* i/o: encoder McMASA handle */ - const int32_t input_Fs /* i : input sampling rate */ + MCMASA_ENC_HANDLE *hMcMasa, /* i/o: encoder McMASA handle */ + const int32_t input_Fs /* i : input sampling rate */ ) { int16_t i, j; - if ( hMcMasa->separateChannelEnabled ) + if ( hMcMasa == NULL || *hMcMasa == NULL ) { - free( hMcMasa->delay_buffer_lfe[0] ); - free( hMcMasa->delay_buffer_lfe[1] ); + return; + } + + if ( ( *hMcMasa )->separateChannelEnabled ) + { + free( ( *hMcMasa )->delay_buffer_lfe[0] ); + free( ( *hMcMasa )->delay_buffer_lfe[1] ); for ( i = 0; i < 2; i++ ) { - free( hMcMasa->lfeAnaRingBuffer[i] ); + free( ( *hMcMasa )->lfeAnaRingBuffer[i] ); } } - ivas_FB_mixer_close( &hMcMasa->hFbMixer, input_Fs, 0 ); + ivas_FB_mixer_close( &( *hMcMasa )->hFbMixer, input_Fs, 0 ); - if ( !hMcMasa->separateChannelEnabled ) + if ( !( *hMcMasa )->separateChannelEnabled ) { - ivas_FB_mixer_close( &hMcMasa->hFbMixerLfe, input_Fs, 0 ); + ivas_FB_mixer_close( &( *hMcMasa )->hFbMixerLfe, input_Fs, 0 ); } /* intensity 3-dim */ @@ -512,35 +517,36 @@ void ivas_mcmasa_enc_close( { for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - free( hMcMasa->direction_vector_m[i][j] ); - hMcMasa->direction_vector_m[i][j] = NULL; + free( ( *hMcMasa )->direction_vector_m[i][j] ); + ( *hMcMasa )->direction_vector_m[i][j] = NULL; } - for ( j = 0; j < hMcMasa->no_col_avg_diff; j++ ) + for ( j = 0; j < ( *hMcMasa )->no_col_avg_diff; j++ ) { - free( hMcMasa->buffer_intensity_real[i][j] ); - hMcMasa->buffer_intensity_real[i][j] = NULL; + free( ( *hMcMasa )->buffer_intensity_real[i][j] ); + ( *hMcMasa )->buffer_intensity_real[i][j] = NULL; } - free( hMcMasa->buffer_intensity_real[i] ); - hMcMasa->buffer_intensity_real[i] = NULL; + free( ( *hMcMasa )->buffer_intensity_real[i] ); + ( *hMcMasa )->buffer_intensity_real[i] = NULL; - free( hMcMasa->direction_vector_m[i] ); - hMcMasa->direction_vector_m[i] = NULL; + free( ( *hMcMasa )->direction_vector_m[i] ); + ( *hMcMasa )->direction_vector_m[i] = NULL; } - for ( j = 0; j < hMcMasa->no_col_avg_diff; j++ ) + for ( j = 0; j < ( *hMcMasa )->no_col_avg_diff; j++ ) { - free( hMcMasa->buffer_intensity_real_vert[j] ); - hMcMasa->buffer_intensity_real_vert[j] = NULL; + free( ( *hMcMasa )->buffer_intensity_real_vert[j] ); + ( *hMcMasa )->buffer_intensity_real_vert[j] = NULL; } - free( hMcMasa->buffer_intensity_real_vert ); - hMcMasa->buffer_intensity_real_vert = NULL; + free( ( *hMcMasa )->buffer_intensity_real_vert ); + ( *hMcMasa )->buffer_intensity_real_vert = NULL; - free( hMcMasa->buffer_energy ); - hMcMasa->buffer_energy = NULL; + free( ( *hMcMasa )->buffer_energy ); + ( *hMcMasa )->buffer_energy = NULL; - free( hMcMasa ); + free( ( *hMcMasa ) ); + ( *hMcMasa ) = NULL; return; } diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 707e74e32995ee9881271674e49351f991ce5928..a9ce8e3abadf881568199f415d8a55ea28fb7909 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -499,29 +499,35 @@ ivas_error mct_enc_reconfigure( *-------------------------------------------------------------------------*/ void ivas_mct_enc_close( - MCT_ENC_HANDLE hMCT /* i/o: MCT encoder structure */ + MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */ ) { int16_t n, maxBlocks; - maxBlocks = hMCT->nchan_out_woLFE / 2; + if ( hMCT == NULL || *hMCT == NULL ) + { + return; + } + + maxBlocks = ( *hMCT )->nchan_out_woLFE / 2; for ( n = 0; n < maxBlocks; n++ ) { - if ( hMCT->hBlockData[n] != NULL ) + if ( ( *hMCT )->hBlockData[n] != NULL ) { - if ( hMCT->hBlockData[n]->hStereoMdct != NULL ) + if ( ( *hMCT )->hBlockData[n]->hStereoMdct != NULL ) { - free( hMCT->hBlockData[n]->hStereoMdct ); - hMCT->hBlockData[n]->hStereoMdct = NULL; + free( ( *hMCT )->hBlockData[n]->hStereoMdct ); + ( *hMCT )->hBlockData[n]->hStereoMdct = NULL; } - free( hMCT->hBlockData[n] ); - hMCT->hBlockData[n] = NULL; + free( ( *hMCT )->hBlockData[n] ); + ( *hMCT )->hBlockData[n] = NULL; } } - free( hMCT ); + free( ( *hMCT ) ); + ( *hMCT ) = NULL; return; } @@ -608,34 +614,18 @@ static ivas_error ivas_mc_enc_reconfig( } /*De-allocate handles for other MC modes*/ - if ( st_ivas->hParamMC != NULL ) - { - ivas_param_mc_enc_close( st_ivas->hParamMC, st_ivas->hEncoderConfig->input_Fs ); - st_ivas->hParamMC = NULL; - } + ivas_param_mc_enc_close( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs ); /* De-allocate McMasa-related handles */ - if ( st_ivas->hMcMasa != NULL ) - { - ivas_mcmasa_enc_close( st_ivas->hMcMasa, st_ivas->hEncoderConfig->input_Fs ); - st_ivas->hMcMasa = NULL; - } + ivas_mcmasa_enc_close( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs ); - if ( st_ivas->hMasa != NULL ) - { #ifdef FIX_350_MASA_DELAY_COMP - ivas_masa_enc_close( st_ivas->hMasa ); + ivas_masa_enc_close( &( st_ivas->hMasa ) ); #else - ivas_masa_enc_close( st_ivas->hMasa, nchan_transport_old, MC_FORMAT ); + ivas_masa_enc_close( &( st_ivas->hMasa ), nchan_transport_old, MC_FORMAT ); #endif - st_ivas->hMasa = NULL; - } - if ( st_ivas->hQMetaData != NULL ) - { - ivas_qmetadata_close( &st_ivas->hQMetaData ); - st_ivas->hQMetaData = NULL; - } + ivas_qmetadata_close( &st_ivas->hQMetaData ); } } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) @@ -656,39 +646,30 @@ static ivas_error ivas_mc_enc_reconfig( } /* De-allocate McMasa-related handles */ - if ( st_ivas->hMcMasa != NULL ) - { - ivas_mcmasa_enc_close( st_ivas->hMcMasa, st_ivas->hEncoderConfig->input_Fs ); - st_ivas->hMcMasa = NULL; - } + ivas_mcmasa_enc_close( &( st_ivas->hMcMasa ), st_ivas->hEncoderConfig->input_Fs ); + if ( st_ivas->hMasa != NULL ) { #ifdef FIX_350_MASA_DELAY_COMP - ivas_masa_enc_close( st_ivas->hMasa ); + ivas_masa_enc_close( &( st_ivas->hMasa ) ); #else - ivas_masa_enc_close( st_ivas->hMasa, nchan_transport_old, MC_FORMAT ); + ivas_masa_enc_close( &( st_ivas->hMasa ), nchan_transport_old, MC_FORMAT ); #endif st_ivas->hMasa = NULL; } - if ( st_ivas->hQMetaData != NULL ) - { - ivas_qmetadata_close( &st_ivas->hQMetaData ); - st_ivas->hQMetaData = NULL; - } + ivas_qmetadata_close( &st_ivas->hQMetaData ); /* De-allocate MCT handle if last mode was MCT */ - if ( last_mc_mode == MC_MODE_MCT && st_ivas->hMCT != NULL && st_ivas->nchan_transport <= CPE_CHANNELS ) + if ( last_mc_mode == MC_MODE_MCT && st_ivas->nchan_transport <= CPE_CHANNELS ) { - ivas_mct_enc_close( st_ivas->hMCT ); - st_ivas->hMCT = NULL; + ivas_mct_enc_close( &( st_ivas->hMCT ) ); } if ( last_mc_mode == MC_MODE_MCT && st_ivas->hLFE != NULL ) { /* LFE handle */ - ivas_lfe_enc_close( st_ivas->hLFE ); - st_ivas->hLFE = NULL; + ivas_lfe_enc_close( &( st_ivas->hLFE ) ); } } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) @@ -721,26 +702,14 @@ static ivas_error ivas_mc_enc_reconfig( } } - if ( st_ivas->hParamMC != NULL ) - { - ivas_param_mc_enc_close( st_ivas->hParamMC, st_ivas->hEncoderConfig->input_Fs ); - st_ivas->hParamMC = NULL; - } + ivas_param_mc_enc_close( &( st_ivas->hParamMC ), st_ivas->hEncoderConfig->input_Fs ); if ( last_mc_mode == MC_MODE_MCT ) { /* LFE handle */ - if ( st_ivas->hLFE != NULL ) - { - ivas_lfe_enc_close( st_ivas->hLFE ); - st_ivas->hLFE = NULL; - } + ivas_lfe_enc_close( &( st_ivas->hLFE ) ); - if ( st_ivas->hMCT != NULL ) - { - ivas_mct_enc_close( st_ivas->hMCT ); - st_ivas->hMCT = NULL; - } + ivas_mct_enc_close( &( st_ivas->hMCT ) ); } } diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 11d9c3540fba8580532a28c980a379442aa10e4a..d3aab0a6e88b631f34c515061a8d9050da7d3345 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -225,9 +225,7 @@ ivas_error ivas_sba_enc_reconfigure( } else { - ivas_spar_enc_close( st_ivas->hSpar, hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); - - st_ivas->hSpar = NULL; + ivas_spar_enc_close( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); } hSpar = st_ivas->hSpar; @@ -255,7 +253,7 @@ ivas_error ivas_sba_enc_reconfigure( if ( sba_mode_old == SBA_MODE_SPAR ) { spar_reconfig_flag = 1; - ivas_spar_enc_close( st_ivas->hSpar, hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); + ivas_spar_enc_close( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag ); if ( ( error = ivas_spar_enc_open( st_ivas, spar_reconfig_flag ) ) != IVAS_ERR_OK ) { diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 7b2155d767e08ca68841147f9a84b72e5a155110..c659979d2b7be0b589bd697fe91870134f9bd355 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -58,8 +58,7 @@ static ivas_error ivas_spar_enc_process( Encoder_Struct *st_ivas, const ENCODER_ *------------------------------------------------------------------------*/ ivas_error ivas_spar_enc_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ - , + Encoder_Struct *st_ivas, /* i/o: IVAS encoder handle */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ) { @@ -232,65 +231,67 @@ ivas_error ivas_spar_enc_open( *------------------------------------------------------------------------*/ void ivas_spar_enc_close( - SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder handle */ - const int32_t input_Fs, /* i : input sampling rate */ - const int16_t nchan_inp /* i : number of input channels */ - , + SPAR_ENC_HANDLE *hSpar, /* i/o: SPAR encoder handle */ + const int32_t input_Fs, /* i : input sampling rate */ + const int16_t nchan_inp, /* i : number of input channels */ const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ) { int16_t num_chans; - if ( hSpar != NULL ) + if ( hSpar == NULL || *hSpar == NULL ) { - if ( !spar_reconfig_flag ) + return; + } + + if ( !spar_reconfig_flag ) + { + /* core-coder-VAD handle */ + if ( ( *hSpar )->hCoreCoderVAD != NULL ) { - /* core-coder-VAD handle */ - if ( hSpar->hCoreCoderVAD != NULL ) - { - destroy_core_enc( hSpar->hCoreCoderVAD ); - hSpar->hCoreCoderVAD = NULL; - } + destroy_core_enc( ( *hSpar )->hCoreCoderVAD ); + ( *hSpar )->hCoreCoderVAD = NULL; + } - /* front-VAD handle */ - if ( hSpar->hFrontVad != NULL ) - { - front_vad_destroy( &hSpar->hFrontVad ); - hSpar->hFrontVad = NULL; - } + /* front-VAD handle */ + if ( ( *hSpar )->hFrontVad != NULL ) + { + front_vad_destroy( &( *hSpar )->hFrontVad ); + ( *hSpar )->hFrontVad = NULL; } + } - num_chans = hSpar->hFbMixer->fb_cfg->num_in_chans; - assert( num_chans <= nchan_inp ); + num_chans = ( *hSpar )->hFbMixer->fb_cfg->num_in_chans; + assert( num_chans <= nchan_inp ); - /* MD handle */ - ivas_spar_md_enc_close( &hSpar->hMdEnc ); + /* MD handle */ + ivas_spar_md_enc_close( &( *hSpar )->hMdEnc ); - /* Covar. State handle */ - ivas_spar_covar_enc_close( &hSpar->hCovEnc, num_chans ); + /* Covar. State handle */ + ivas_spar_covar_enc_close( &( *hSpar )->hCovEnc, num_chans ); - /* FB mixer handle */ - ivas_FB_mixer_close( &hSpar->hFbMixer, input_Fs, spar_reconfig_flag ); + /* FB mixer handle */ + ivas_FB_mixer_close( &( *hSpar )->hFbMixer, input_Fs, spar_reconfig_flag ); - /* AGC */ - ivas_spar_agc_enc_close( &hSpar->hAgcEnc ); + /* AGC */ + ivas_spar_agc_enc_close( &( *hSpar )->hAgcEnc ); - /* PCA */ - if ( hSpar->hPCA != NULL ) - { - free( hSpar->hPCA ); - hSpar->hPCA = NULL; - } + /* PCA */ + if ( ( *hSpar )->hPCA != NULL ) + { + free( ( *hSpar )->hPCA ); + ( *hSpar )->hPCA = NULL; + } - if ( !spar_reconfig_flag ) - { - /* Trans Det handle */ - ivas_transient_det_close( &hSpar->hTranDet ); - free( hSpar ); - hSpar = NULL; - } + if ( !spar_reconfig_flag ) + { + /* Trans Det handle */ + ivas_transient_det_close( &( *hSpar )->hTranDet ); + free( ( *hSpar ) ); + ( *hSpar ) = NULL; } + return; } diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index bcc6718e9a60c513ead6780ac75f79bba2781c52..645f690ac0f8561aaccc1ea1fc050f03616d7aa7 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -225,6 +225,11 @@ void ivas_spar_md_enc_close( int16_t num_channels, i, j; ivas_spar_md_enc_state_t *hMdEnc; + if ( hMdEnc_in == NULL || *hMdEnc_in == NULL ) + { + return; + } + hMdEnc = *hMdEnc_in; num_channels = hMdEnc->num_umx_ch; @@ -250,7 +255,6 @@ void ivas_spar_md_enc_close( { for ( i = 0; i < num_channels; i++ ) { - for ( j = 0; j < num_channels; j++ ) { free( hMdEnc->cov_real[i][j] ); @@ -264,7 +268,6 @@ void ivas_spar_md_enc_close( { for ( i = 0; i < num_channels; i++ ) { - for ( j = 0; j < num_channels; j++ ) { free( hMdEnc->cov_dtx_real[i][j] ); @@ -288,11 +291,8 @@ void ivas_spar_md_enc_close( free( hMdEnc->mixer_mat_local ); } - if ( hMdEnc != NULL ) - { - free( hMdEnc ); - hMdEnc = NULL; - } + free( *hMdEnc_in ); + *hMdEnc_in = NULL; return; } diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 896dc0563b7c3137a98c11af442ff0ac982c12b3..1256955e87bb74866c910fdd4ec1d73ec08df9e4 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1013,6 +1013,9 @@ typedef struct encoder_config_structure int16_t sba_order; /* Ambisonic (SBA) order */ int16_t sba_planar; /* Ambisonic (SBA) planar flag */ MC_LS_SETUP mc_input_setup; /* multichannel input ls setup */ +#ifdef TD5 + int16_t ism_extended_metadata_flag; /* flag indicating extended metadata encoding, including radius and orientation (yaw, pitch) in ISM format */ +#endif int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ @@ -1027,10 +1030,6 @@ typedef struct encoder_config_structure int16_t Opt_SC_VBR; /* flag indicating SC-VBR mode */ int16_t last_Opt_SC_VBR; /* flag indicating prev frame's SC-VBR mode */ -#ifdef TD5 - int16_t ism_extended_metadata_flag; /* flag indicating whether extended metadata encoding, including radius and orientation (yaw, pitch) */ -#endif - /* temp. development parameters */ int16_t Opt_PCA_ON; /* flag indicating PCA operation in SBA */ diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs.c index 052970fa70c14831fb4768897e0e59ac17383095..a5c0fe147f0055724024771e5133507e08ccab36 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -946,16 +946,22 @@ ivas_error stereo_dmx_evs_init_encoder( *-------------------------------------------------------------------*/ void stereo_dmx_evs_close_encoder( - STEREO_DMX_EVS_ENC_HANDLE hStereoDmxEVS /* i/o: Stereo downmix for EVS encoder handle */ + STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS /* i/o: Stereo downmix for EVS encoder handle */ ) { - if ( hStereoDmxEVS->hPOC != NULL ) + if ( hStereoDmxEVS == NULL || *hStereoDmxEVS == NULL ) { - free( hStereoDmxEVS->hPOC ); - hStereoDmxEVS->hPOC = NULL; + return; } - free( hStereoDmxEVS ); + if ( ( *hStereoDmxEVS )->hPOC != NULL ) + { + free( ( *hStereoDmxEVS )->hPOC ); + ( *hStereoDmxEVS )->hPOC = NULL; + } + + free( ( *hStereoDmxEVS ) ); + ( *hStereoDmxEVS ) = NULL; return; } diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 3742dbcfdcc01d239eaed8465acd513e78370f09..a7b252c9d8f4e40d23823492b240afb2d2f80216 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1537,11 +1537,11 @@ static ivas_error printConfigInfo_enc( { if ( hEncoderConfig->ivas_total_brate <= ACELP_32k && hEncoderConfig->nchan_inp > 2 ) { - fprintf( stdout, "IVAS format: Param-ISm (%i streams)\n", hEncoderConfig->nchan_inp ); + fprintf( stdout, "IVAS format: Param-ISM (%i streams)\n", hEncoderConfig->nchan_inp ); } else { - fprintf( stdout, "IVAS format: ISm (%i streams)\n", hEncoderConfig->nchan_inp ); + fprintf( stdout, "IVAS format: ISM (%i streams)\n", hEncoderConfig->nchan_inp ); } } else if ( hEncoderConfig->ivas_format == SBA_FORMAT ) @@ -2013,6 +2013,7 @@ static ivas_error sanitizeBitrateISM( { return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too low bitrate for 4 ISM specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); } + #ifdef TD5 if ( hEncoderConfig->ivas_total_brate < ISM_EXTENDED_METADATA_BRATE && hEncoderConfig->ism_extended_metadata_flag == 1 ) { @@ -2277,6 +2278,9 @@ static void init_encoder_config( hEncoderConfig->stereo_dmx_evs = 0; hEncoderConfig->sba_order = 0; hEncoderConfig->sba_planar = 0; +#ifdef TD5 + hEncoderConfig->ism_extended_metadata_flag = 0; +#endif #ifdef DEBUGGING hEncoderConfig->stereo_mode_cmdl = 0; hEncoderConfig->force = -1; diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index f9673656f12d118749a8fbc44e36ecf641a72002..c4941b610c68b5f74414917c8d820683b748a1d1 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -831,11 +831,7 @@ ivas_error ivas_rend_openCrend( if ( ( hRendCfg != NULL ) && ( hRendCfg->roomAcoustics.late_reverb_on ) ) { - if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), - inConfig, - ( *pCrend )->hHrtfCrend, - hRendCfg, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, hRendCfg, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -853,6 +849,7 @@ ivas_error ivas_rend_openCrend( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * ivas_crend_close() * @@ -864,12 +861,7 @@ void ivas_rend_closeCrend( { int16_t i; - if ( pCrend == NULL ) - { - return; - } - - if ( *pCrend == NULL ) + if ( pCrend == NULL || *pCrend == NULL ) { return; } @@ -935,9 +927,11 @@ void ivas_rend_closeCrend( free( *pCrend ); *pCrend = NULL; } + return; } + /*-----------------------------------------------------------------------------------------* * Function ivas_crend_convolver() * diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index ebd7c737a212f4a969491a088145f76a716326a1..58de4819e8f1eb2453dc194dad8ed08edb1ff247 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -284,7 +284,7 @@ void ivas_dirac_dec_close_binaural_data( DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */ ) { - if ( *hBinaural == NULL ) + if ( hBinaural == NULL || *hBinaural == NULL ) { return; } diff --git a/lib_rend/ivas_hrtf.c b/lib_rend/ivas_hrtf.c index e411d3bbbfa1c220d5aa90db9aa72b2416ea8d7f..2b1f16d025cfb0c9166a5c5c80c6c5489e0ca305 100644 --- a/lib_rend/ivas_hrtf.c +++ b/lib_rend/ivas_hrtf.c @@ -116,7 +116,6 @@ void ivas_HRTF_CRend_binary_close( return; } - free( *hSetOfHRTF ); *hSetOfHRTF = NULL; diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 270da74b5c747566853933bf67bb9fad85d3379d..67b73db6a6faac8a17013ece700d3dad16ca6ee0 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -65,7 +65,7 @@ ivas_error ivas_td_binaural_open_unwrap( const IVAS_FORMAT ivas_format, /* i : IVAS format (ISM/MC) */ const AUDIO_CONFIG transport_config, /* i : Transport configuration */ #ifdef TD5 - const float *directivity, /* i : Directivity pattern (used for ISm) */ + const float *directivity, /* i : Directivity pattern (used for ISM) */ #endif const IVAS_OUTPUT_SETUP hTransSetup, /* i : Loudspeaker layout */ BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, /* o : TD renderer handle */ @@ -267,12 +267,12 @@ void ivas_td_binaural_close( *---------------------------------------------------------------------*/ ivas_error ivas_td_binaural_renderer_unwrap( - REVERB_HANDLE hReverb, /* i : reverb handle */ - AUDIO_CONFIG transport_config, /* i : Transport configuration */ + const REVERB_HANDLE hReverb, /* i : Reverberator handle */ + const AUDIO_CONFIG transport_config, /* i : Transport configuration */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD binaural object renderer handle */ - const int16_t nchan_transport, /* i : Transport channels (ISms) */ + const int16_t num_src, /* i : number of sources to render */ const int16_t lfe_idx, /* i : LFE channel index */ - IVAS_FORMAT ivas_format, /* i : IVAS format */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ ISM_METADATA_HANDLE *hIsmMetaData, /* i : ISM metadata handle */ const int16_t Opt_Headrotation, /* i : Head rotation flag */ const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ @@ -291,7 +291,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( subframe_length = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; /* Update object position(s) */ - TDREND_Update_object_positions( hBinRendererTd, nchan_transport, lfe_idx, ivas_format, hIsmMetaData, output ); + TDREND_Update_object_positions( hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, output ); for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { @@ -302,11 +302,9 @@ ivas_error ivas_td_binaural_renderer_unwrap( TDREND_Update_listener_orientation( hBinRendererTd, Opt_Headrotation, ( Quaternions != NULL ) ? &Quaternions[subframe_idx] : NULL ); #endif - if ( ( hReverb != NULL ) && ( hReverb->pConfig.roomAcoustics.late_reverb_on ) ) + if ( hReverb != NULL && hReverb->pConfig.roomAcoustics.late_reverb_on ) { - if ( ( error = ivas_reverb_process( - hReverb, - transport_config, 0, output, reverb_signal, subframe_idx ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_process( hReverb, transport_config, 0, output, reverb_signal, subframe_idx ) ) != IVAS_ERR_OK ) { return error; } @@ -320,7 +318,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( } - if ( ( hReverb != NULL ) && ( hReverb->pConfig.roomAcoustics.late_reverb_on ) ) + if ( hReverb != NULL && hReverb->pConfig.roomAcoustics.late_reverb_on ) { /* add reverb to rendered signals */ v_add( reverb_signal[0], output[0], output[0], output_frame ); @@ -339,7 +337,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - float output[][L_FRAME48k], /* i/o: ISm object synth / rendered output in 0,1 */ + float output[][L_FRAME48k], /* i/o: ISM object synth / rendered output in 0,1 */ const int16_t subframe_length, /* i/o: subframe length */ const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ ) @@ -428,7 +426,7 @@ static void TDREND_Clear_Update_flags( void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o : TD Renderer handle */ - const int16_t numSources, /* i : Number of sources to render */ + const int16_t num_src, /* i : number of sources to render */ const int16_t lfe_idx, /* i : Input LFE index */ const IVAS_FORMAT in_format, /* i : Format of input sources */ const ISM_METADATA_HANDLE *hIsmMetaData, /* i : Input metadata for ISM objects */ @@ -445,7 +443,7 @@ void TDREND_Update_object_positions( /* For each source, write the frame data to the source object*/ c_indx = 0; - for ( nS = 0; nS < numSources; nS++ ) + for ( nS = 0; nS < num_src; nS++ ) { if ( !( in_format == MC_FORMAT && nS == lfe_idx ) ) /* Skip LFE for MC */ { @@ -638,7 +636,7 @@ ivas_error ivas_td_binaural_renderer_ext( const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ - const REVERB_HANDLE reverb, /* i : reverb handle */ + const REVERB_HANDLE hReverb, /* i : Reverberator handle */ const int16_t output_frame, /* i : output frame length */ float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ) @@ -690,7 +688,7 @@ ivas_error ivas_td_binaural_renderer_ext( #endif } - if ( ( error = ivas_td_binaural_renderer_unwrap( reverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, headRotData->headRotEnabled, + if ( ( error = ivas_td_binaural_renderer_unwrap( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, headRotData->headRotEnabled, ( headRotData != NULL ) ? headRotData->headPositions : NULL, #ifdef TD5 ( headRotData != NULL ) ? headRotData->Pos : NULL, output, output_frame ) ) != IVAS_ERR_OK ) diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index 58ae7fd457d00322fe3f0ceb8d6aed2e8d3902cf..af71cbf543f84530a1bec434c20fd2662097f22b 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -50,9 +50,7 @@ #define MAX_TRACKED_ANGLE_AVG_ORIENT PI_OVER_2 #define MAX_TRACKED_ANGLE_REF_ORIENT EVS_PI - -/* TODO relate to frame rate - assumed here 50Hz, i.e. 20ms frame length */ -#define OTR_UPDATE_RATE ( 50.0f ) /* rate of the Process() calls [Hz]; 1x per IVAS frame */ +#define OTR_UPDATE_RATE (float) FRAMES_PER_SEC /* rate of the Process() calls [Hz]; 1x per IVAS frame */ /*------------------------------------------------------------------------------------------* @@ -60,94 +58,31 @@ *------------------------------------------------------------------------------------------*/ #ifdef FIX_I109_ORIENTATION_TRACKING - /*------------------------------------------------------------------------------------------* - * Declarations + * IdentityQuaternion() + * + * *------------------------------------------------------------------------------------------*/ -static IVAS_QUATERNION IdentityQuaternion( - void ); - -void QuaternionProduct( - const IVAS_QUATERNION q1, - const IVAS_QUATERNION q2, - IVAS_QUATERNION *const result ); - -float QuaternionDotProduct( - const IVAS_QUATERNION q1, - const IVAS_QUATERNION q2 ); - -void QuaternionDivision( - const IVAS_QUATERNION q, - const float d, - IVAS_QUATERNION *const result ); - -void QuaternionNormalize( - const IVAS_QUATERNION q, - IVAS_QUATERNION *const result ); - -void QuaternionSlerp( - const IVAS_QUATERNION q1, - const IVAS_QUATERNION q2, - const float t, - IVAS_QUATERNION *const result ); - -void QuaternionConjugate( - const IVAS_QUATERNION q, - IVAS_QUATERNION *const result ); - -float QuaternionAngle( - const IVAS_QUATERNION q1, - const IVAS_QUATERNION q2 ); - -void QuaternionInverse( - const IVAS_QUATERNION q, - IVAS_QUATERNION *const result ); - -#ifdef OTR_REFERENCE_VECTOR_TRACKING -float QuaternionLength( - const IVAS_QUATERNION q ); - -IVAS_VECTOR3 VectorSubtract( - const IVAS_VECTOR3 p1, - const IVAS_VECTOR3 p2 ); - -IVAS_VECTOR3 VectorCrossProduct( - const IVAS_VECTOR3 p1, - const IVAS_VECTOR3 p2 ); - -float VectorDotProduct( - const IVAS_VECTOR3 p1, - const IVAS_VECTOR3 p2 ); - -float VectorLength( - const IVAS_VECTOR3 p ); - -IVAS_VECTOR3 VectorNormalize( - const IVAS_VECTOR3 p ); - -void VectorRotationToQuaternion( - const IVAS_VECTOR3 p1, - const IVAS_VECTOR3 p2, - IVAS_QUATERNION *const result ); -#endif /* OTR_REFERENCE_VECTOR_TRACKING */ - -/*------------------------------------------------------------------------------------------* - * Quaternion product - *------------------------------------------------------------------------------------------*/ static IVAS_QUATERNION IdentityQuaternion( void ) { IVAS_QUATERNION q; + q.w = 1.0f; q.x = q.y = q.z = 0.0f; + return q; } + /*------------------------------------------------------------------------------------------* + * QuaternionProduct() + * * Quaternion product *------------------------------------------------------------------------------------------*/ -void QuaternionProduct( + +static void QuaternionProduct( const IVAS_QUATERNION q1, const IVAS_QUATERNION q2, IVAS_QUATERNION *const r ) @@ -159,22 +94,31 @@ void QuaternionProduct( tmp.z = q1.w * q2.z + q1.x * q2.y - q1.y * q2.x + q1.z * q2.w; *r = tmp; + + return; } /*------------------------------------------------------------------------------------------* + * QuaternionDotProduct() + * * Quaternion dot product *------------------------------------------------------------------------------------------*/ -float QuaternionDotProduct( + +static float QuaternionDotProduct( const IVAS_QUATERNION q1, const IVAS_QUATERNION q2 ) { return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; } + /*------------------------------------------------------------------------------------------* + * QuaternionDivision() + * * Divides a quaternion by a scalar *------------------------------------------------------------------------------------------*/ -void QuaternionDivision( + +static void QuaternionDivision( const IVAS_QUATERNION q, const float d, IVAS_QUATERNION *const r ) @@ -183,34 +127,49 @@ void QuaternionDivision( r->x = q.x / d; r->y = q.y / d; r->z = q.z / d; + + return; } + /*------------------------------------------------------------------------------------------* + * QuaternionNormalize() + * * Normalizes a quaternion *------------------------------------------------------------------------------------------*/ -void QuaternionNormalize( + +static void QuaternionNormalize( const IVAS_QUATERNION q, IVAS_QUATERNION *const r ) { QuaternionDivision( q, sqrtf( QuaternionDotProduct( q, q ) ), r ); + + return; } + /*------------------------------------------------------------------------------------------* + * QuaternionSlerp() + * * Computes a spherical linear interpolation between two quaternions *------------------------------------------------------------------------------------------*/ -void QuaternionSlerp( + +static void QuaternionSlerp( const IVAS_QUATERNION q1, const IVAS_QUATERNION q2, const float t, IVAS_QUATERNION *const r ) { float angle, denom, s, s2; + s = QuaternionDotProduct( q1, q2 ); + if ( fabsf( s ) >= 1.0f ) { *r = q2; return; } + angle = acosf( s ); denom = sinf( angle ); @@ -222,12 +181,18 @@ void QuaternionSlerp( r->w = ( q1.w * s + q2.w * s2 ) / denom; QuaternionNormalize( *r, r ); + + return; } + /*------------------------------------------------------------------------------------------* + * QuaternionConjugate() + * * Computes a quaternion conjugate *------------------------------------------------------------------------------------------*/ -void QuaternionConjugate( + +static void QuaternionConjugate( const IVAS_QUATERNION q, IVAS_QUATERNION *const r ) { @@ -235,27 +200,39 @@ void QuaternionConjugate( r->x = -q.x; r->y = -q.y; r->z = -q.z; + + return; } + /*------------------------------------------------------------------------------------------* + * QuaternionAngle() + * * Computes an angle between two quaternions *------------------------------------------------------------------------------------------*/ -float QuaternionAngle( + +static float QuaternionAngle( const IVAS_QUATERNION q1, const IVAS_QUATERNION q2 ) { IVAS_QUATERNION q12; float angle; + QuaternionConjugate( q1, &q12 ); QuaternionProduct( q12, q2, &q12 ); angle = 2.0f * atan2f( sqrtf( q12.x * q12.x + q12.y * q12.y + q12.z * q12.z ), q12.w ); + return angle; } + /*------------------------------------------------------------------------------------------* + * QuaternionInverse() + * * Computes an inverse quaternion *------------------------------------------------------------------------------------------*/ -void QuaternionInverse( + +static void QuaternionInverse( const IVAS_QUATERNION q, IVAS_QUATERNION *const r ) { @@ -264,36 +241,39 @@ void QuaternionInverse( dot_product = QuaternionDotProduct( q, q ); QuaternionConjugate( q, r ); QuaternionDivision( *r, dot_product, r ); -} -#ifdef OTR_REFERENCE_VECTOR_TRACKING -/*------------------------------------------------------------------------------------------* - * Computes the length of a quaternion - *------------------------------------------------------------------------------------------*/ -float QuaternionLength( - const IVAS_QUATERNION q ) -{ - return sqrtf( q.w * q.w + q.x * q.x + q.y * q.y + q.z * q.z ); + return; } + +#ifdef OTR_REFERENCE_VECTOR_TRACKING /*------------------------------------------------------------------------------------------* + * VectorSubtract() + * * Computes the difference of two vectors *------------------------------------------------------------------------------------------*/ -IVAS_VECTOR3 VectorSubtract( + +static IVAS_VECTOR3 VectorSubtract( const IVAS_VECTOR3 p1, const IVAS_VECTOR3 p2 ) { IVAS_VECTOR3 result; + result.x = p1.x - p2.x; result.y = p1.y - p2.y; result.z = p1.z - p2.z; + return result; } + /*------------------------------------------------------------------------------------------* + * VectorCrossProduct() + * * Computes the cross product of two vectors *------------------------------------------------------------------------------------------*/ -IVAS_VECTOR3 VectorCrossProduct( + +static IVAS_VECTOR3 VectorCrossProduct( const IVAS_VECTOR3 p1, const IVAS_VECTOR3 p2 ) { @@ -301,46 +281,66 @@ IVAS_VECTOR3 VectorCrossProduct( result.x = p1.y * p2.z - p1.z * p2.y; result.y = p1.z * p2.x - p1.x * p2.z; result.z = p1.x * p2.y - p1.y * p2.x; + return result; } + /*------------------------------------------------------------------------------------------* + * VectorDotProduct( + * * Computes the dot product of two vectors *------------------------------------------------------------------------------------------*/ -float VectorDotProduct( + +static float VectorDotProduct( const IVAS_VECTOR3 p1, const IVAS_VECTOR3 p2 ) { return p1.x * p2.x + p1.y * p2.y + p1.z * p2.z; } + /*------------------------------------------------------------------------------------------* + * VectorLength() + * * Computes the length of a vector *------------------------------------------------------------------------------------------*/ -float VectorLength( + +static float VectorLength( const IVAS_VECTOR3 p ) { return sqrtf( p.x * p.x + p.y * p.y + p.z * p.z ); } + /*------------------------------------------------------------------------------------------* + * VectorNormalize() + * * Normalizes a vector *------------------------------------------------------------------------------------------*/ -IVAS_VECTOR3 VectorNormalize( + +static IVAS_VECTOR3 VectorNormalize( const IVAS_VECTOR3 p ) { IVAS_VECTOR3 result; + const float length = VectorLength( p ); + result.x = p.x / length; result.y = p.y / length; result.z = p.z / length; + return result; } + /*------------------------------------------------------------------------------------------* + * VectorRotationToQuaternion() + * * Computes a quaternion representing the rotation from vector p1 to vector p2 *------------------------------------------------------------------------------------------*/ -void VectorRotationToQuaternion( + +static void VectorRotationToQuaternion( const IVAS_VECTOR3 p1, const IVAS_VECTOR3 p2, IVAS_QUATERNION *const r ) @@ -369,7 +369,10 @@ void VectorRotationToQuaternion( r->z = cross_product.z; r->w = 1.0f + dot_product; } + QuaternionNormalize( *r, r ); + + return; } #endif /* OTR_REFERENCE_VECTOR_TRACKING */ #else @@ -492,8 +495,9 @@ void ivas_orient_trk_Init( #ifdef FIX_I109_ORIENTATION_TRACKING ivas_error ivas_orient_trk_SetTrackingType( - ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ - const OTR_TRACKING_T trackingType ) /* i/o : orientation tracking type */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ + const OTR_TRACKING_T trackingType /* i/o: orientation tracking type */ +) { if ( pOTR == NULL ) { @@ -513,9 +517,16 @@ void ivas_orient_trk_SetTrackingType( #endif #ifdef FIX_I109_ORIENTATION_TRACKING +/*-------------------------------------------------------------------* + * ivas_orient_trk_SetReferenceRotation() + * + * + *-------------------------------------------------------------------*/ + ivas_error ivas_orient_trk_SetReferenceRotation( - ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ - IVAS_QUATERNION refRot ) /* i : reference rotation */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ + const IVAS_QUATERNION refRot /* i : reference rotation */ +) { if ( pOTR == NULL ) { @@ -535,9 +546,16 @@ ivas_error ivas_orient_trk_SetReferenceRotation( return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * ivas_orient_trk_GetMainOrientation() + * + * + *-------------------------------------------------------------------*/ + ivas_error ivas_orient_trk_GetMainOrientation( - ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ - IVAS_QUATERNION *pOrientation /* i/o : average/reference orientation */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ + IVAS_QUATERNION *pOrientation /* i/o: average/reference orientation */ ) { if ( pOTR == NULL || pOrientation == NULL ) @@ -560,12 +578,20 @@ ivas_error ivas_orient_trk_GetMainOrientation( *pOrientation = pOTR->absAvgRot; break; } + return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * ivas_orient_trk_GetTrackedRotation() + * + * + *-------------------------------------------------------------------*/ + ivas_error ivas_orient_trk_GetTrackedRotation( - ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ - IVAS_QUATERNION *pRotation /* i/o : processed rotation */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ + IVAS_QUATERNION *pRotation /* i/o: processed rotation */ ) { if ( pOTR == NULL || pRotation == NULL ) @@ -578,14 +604,22 @@ ivas_error ivas_orient_trk_GetTrackedRotation( return IVAS_ERR_OK; } + #ifdef OTR_REFERENCE_VECTOR_TRACKING +/*-------------------------------------------------------------------* + * ivas_orient_trk_SetReferenceVector() + * + * + *-------------------------------------------------------------------*/ + ivas_error ivas_orient_trk_SetReferenceVector( - ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ - const IVAS_VECTOR3 listenerPos, /* i : Listener position */ - const IVAS_VECTOR3 refPos /* i : Reference position */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ + const IVAS_VECTOR3 listenerPos, /* i : Listener position */ + const IVAS_VECTOR3 refPos /* i : Reference position */ ) { IVAS_VECTOR3 acousticFrontVector, ivasForwardVector; + IVAS_VECTOR3 listenerPosLevel, refPosLevel; float acousticFrontVectorLength; if ( pOTR == NULL ) @@ -602,8 +636,6 @@ ivas_error ivas_orient_trk_SetReferenceVector( acousticFrontVector = VectorSubtract( listenerPos, refPos ); break; case OTR_TRACKING_REF_VEC_LEV: - { - IVAS_VECTOR3 listenerPosLevel, refPosLevel; /* ignore the height difference between listener position and reference position */ listenerPosLevel.z = refPosLevel.z = listenerPos.z; listenerPosLevel.x = listenerPos.x; @@ -611,10 +643,13 @@ ivas_error ivas_orient_trk_SetReferenceVector( refPosLevel.x = refPos.x; refPosLevel.y = refPos.y; acousticFrontVector = VectorSubtract( listenerPosLevel, refPosLevel ); - } + break; + default: + return IVAS_ERR_WRONG_PARAMS; } acousticFrontVectorLength = VectorLength( acousticFrontVector ); + /* if the length is zero, the user has entered insensible listener and reference positions */ if ( acousticFrontVectorLength < 0.0001f ) { @@ -625,6 +660,7 @@ ivas_error ivas_orient_trk_SetReferenceVector( ivasForwardVector.y = 0.0f; ivasForwardVector.z = 0.0f; VectorRotationToQuaternion( ivasForwardVector, acousticFrontVector, &pOTR->refRot ); + return IVAS_ERR_OK; } #endif /* OTR_REFERENCE_VECTOR_TRACKING */ @@ -659,10 +695,11 @@ void ivas_orient_trk_SetAbsoluteOrientation( #ifdef FIX_I109_ORIENTATION_TRACKING ivas_error ivas_orient_trk_Process( - ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ - IVAS_QUATERNION absRot, /* i : absolute head rotation */ - float updateRate, /* i : rotation update rate [Hz] */ - IVAS_QUATERNION *pTrkRot ) /* o : tracked rotation */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ + IVAS_QUATERNION absRot, /* i : absolute head rotation */ + float updateRate, /* i : rotation update rate [Hz] */ + IVAS_QUATERNION *pTrkRot /* o : tracked rotation */ +) { float normalizedOrientation; float relativeOrientationRate; @@ -745,6 +782,7 @@ ivas_error ivas_orient_trk_Process( { *pTrkRot = pOTR->trkRot; } + return result; } #else diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 2b0e67e5f4597e0ade85a9eeff3a85154f2c50de..4c79280a8687e74fb02b89934bfc9447da717f08 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -212,12 +212,12 @@ void ivas_HRTF_CRend_binary_close( *----------------------------------------------------------------------------------*/ ivas_error ivas_td_binaural_renderer_unwrap( - REVERB_HANDLE hReverb, /* i : reverb handle */ - AUDIO_CONFIG transport_config, /* i : Transport configuration */ + const REVERB_HANDLE hReverb, /* i : Reverberator handle */ + const AUDIO_CONFIG transport_config, /* i : Transport configuration */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD binaural object renderer handle */ - const int16_t nchan_transport, /* i : Transport channels (ISms) */ + const int16_t num_src, /* i : number of sources to render */ const int16_t lfe_idx, /* i : LFE channel index */ - IVAS_FORMAT ivas_format, /* i : IVAS format */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ ISM_METADATA_HANDLE *hIsmMetaData, /* i : ISM metadata handle */ const int16_t Opt_Headrotation, /* i : Head rotation flag */ const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ @@ -234,7 +234,7 @@ ivas_error ivas_td_binaural_renderer_ext( const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ const IVAS_REND_HeadRotData *headRotData, /* i : Input head positions */ const IVAS_REND_AudioObjectPosition *currentPos, /* i : Object position */ - const REVERB_HANDLE reverb, /* i : reverb handle */ + const REVERB_HANDLE hReverb, /* i : Reverberator handle */ const int16_t output_frame, /* i : output frame length */ float output[][L_FRAME48k] /* i/o: SCE channels / Binaural synthesis */ ); @@ -246,7 +246,7 @@ ivas_error ivas_td_binaural_open_unwrap( const IVAS_FORMAT ivas_format, /* i : IVAS format (ISM/MC) */ const AUDIO_CONFIG transport_config, /* i : Transport configuration */ #ifdef TD5 - const float *directivity, /* i : Directivity pattern (used for ISm) */ + const float *directivity, /* i : Directivity pattern (used for ISM) */ #endif const IVAS_OUTPUT_SETUP hTransSetup, /* i : Loudspeaker layout */ BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd, /* o : TD renderer handle */ @@ -270,7 +270,7 @@ void ivas_td_binaural_close( ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - float output[][L_FRAME48k], /* i/o: ISm object synth / rendered output in 0,1 */ + float output[][L_FRAME48k], /* i/o: ISM object synth / rendered output in 0,1 */ const int16_t subframe_length, /* i/o: subframe length */ const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ ); @@ -288,7 +288,7 @@ void TDREND_Update_listener_orientation( void TDREND_Update_object_positions( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o : TD Renderer handle */ - const int16_t numSources, /* i : Number of sources to render */ + const int16_t num_src, /* i : number of sources to render */ const int16_t lfe_idx, /* i : Input LFE index */ const IVAS_FORMAT in_format, /* i : Format of input sources */ const ISM_METADATA_HANDLE *hIsmMetaData, /* i : Input metadata for ISM objects */ @@ -581,12 +581,12 @@ void ivas_reverb_close( ); ivas_error ivas_reverb_process( - REVERB_HANDLE hReverb, /* i/o: reverb state */ + const REVERB_HANDLE hReverb, /* i : Reverberator handle */ const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const int16_t mix_signals, /* i : add reverb to output signal */ float pcm_in[][L_FRAME48k], /* i : the PCM audio to apply reverb on */ float pcm_out[][L_FRAME48k], /* o : the PCM audio with reverb applied */ - const int16_t i_ts + const int16_t i_ts /* i : subframe index */ ); void ivas_rev_delay_line_init( @@ -877,7 +877,7 @@ ivas_error ivas_orient_trk_Init( #else void ivas_orient_trk_Init( #endif - ivas_orient_trk_state_t *pOTR /* i/o : orientation tracker handle */ + ivas_orient_trk_state_t *pOTR /* i/o: orientation tracker handle */ ); #ifdef FIX_I109_ORIENTATION_TRACKING @@ -885,41 +885,41 @@ ivas_error ivas_orient_trk_SetTrackingType( #else void ivas_orient_trk_SetTrackingType( #endif - ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ - const OTR_TRACKING_T trackingType /* i : orientation tracking type */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ + const OTR_TRACKING_T trackingType /* i : orientation tracking type */ ); #ifdef FIX_I109_ORIENTATION_TRACKING ivas_error ivas_orient_trk_SetReferenceRotation( - ivas_orient_trk_state_t *pOTR, /* i/o : orientatoin trakcer handle */ - IVAS_QUATERNION refRot /* i : reference rotation */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientatoin trakcer handle */ + const IVAS_QUATERNION refRot /* i : reference rotation */ ); #ifdef OTR_REFERENCE_VECTOR_TRACKING ivas_error ivas_orient_trk_SetReferenceVector( - ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ - const IVAS_VECTOR3 listenerPos, /* i : Listener position */ - const IVAS_VECTOR3 refPos /* i : Reference position */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ + const IVAS_VECTOR3 listenerPos, /* i : Listener position */ + const IVAS_VECTOR3 refPos /* i : Reference position */ ); #endif /* OTR_REFERENCE_VECTOR_TRACKING */ ivas_error ivas_orient_trk_GetMainOrientation( - ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ - IVAS_QUATERNION *pOrientation /* i/o : average/reference orientation */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ + IVAS_QUATERNION *pOrientation /* i/o: average/reference orientation */ ); ivas_error ivas_orient_trk_GetTrackedRotation( - ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ - IVAS_QUATERNION *pRotation /* i/o : processed rotation */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ + IVAS_QUATERNION *pRotation /* i/o: processed rotation */ ); #endif #ifdef FIX_I109_ORIENTATION_TRACKING ivas_error ivas_orient_trk_Process( - ivas_orient_trk_state_t *pOTR, /* i/o : orientation tracker handle */ - IVAS_QUATERNION absRot, /* i : absolute head rotation */ - float updateRate, /* i : rotation update rate [Hz] */ - IVAS_QUATERNION *pTrkRot /* o : tracked rotation */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ + IVAS_QUATERNION absRot, /* i : absolute head rotation */ + float updateRate, /* i : rotation update rate [Hz] */ + IVAS_QUATERNION *pTrkRot /* o : tracked rotation */ ); #else diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index ec5bd928d20031e172e23725aa5c1d26bef00afe..7dc05cff09b25f29368ce5e69109feaef40e721a 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -675,34 +675,34 @@ static ivas_error calc_jot_t60_coeffs( *-----------------------------------------------------------------------------------------*/ static ivas_error initialize_reverb_filters( - REVERB_HANDLE pState ) + REVERB_HANDLE hReverb ) { ivas_error error; error = IVAS_ERR_OK; /* init correlation and coloration filters */ - if ( ( error = ivas_reverb_t2f_f2t_init( &pState->fft_filter_ols, pState->fft_size, pState->fft_subblock_size ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_t2f_f2t_init( &hReverb->fft_filter_ols, hReverb->fft_size, hReverb->fft_subblock_size ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_reverb_fft_filter_init( &pState->fft_filter_correl_0, pState->fft_size ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_fft_filter_init( &hReverb->fft_filter_correl_0, hReverb->fft_size ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_reverb_fft_filter_init( &pState->fft_filter_correl_1, pState->fft_size ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_fft_filter_init( &hReverb->fft_filter_correl_1, hReverb->fft_size ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_reverb_fft_filter_init( &pState->fft_filter_color_0, pState->fft_size ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_fft_filter_init( &hReverb->fft_filter_color_0, hReverb->fft_size ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = ivas_reverb_fft_filter_init( &pState->fft_filter_color_1, pState->fft_size ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_fft_filter_init( &hReverb->fft_filter_color_1, hReverb->fft_size ) ) != IVAS_ERR_OK ) { return error; } @@ -718,13 +718,13 @@ static ivas_error initialize_reverb_filters( *-----------------------------------------------------------------------------------------*/ static ivas_error set_t60_filter( - REVERB_HANDLE pState, + REVERB_HANDLE hReverb, const uint16_t branch, const uint16_t nr_taps, const float coefA[], const float coefB[] ) { - if ( branch >= pState->nr_of_branches ) + if ( branch >= hReverb->nr_of_branches ) { return IVAS_ERR_INTERNAL; } @@ -734,7 +734,7 @@ static ivas_error set_t60_filter( return IVAS_ERR_INTERNAL; } - ivas_reverb_iir_filt_set( &( pState->t60[branch] ), nr_taps, coefA, coefB ); + ivas_reverb_iir_filt_set( &( hReverb->t60[branch] ), nr_taps, coefA, coefB ); return IVAS_ERR_OK; } @@ -747,16 +747,16 @@ static ivas_error set_t60_filter( *-----------------------------------------------------------------------------------------*/ static ivas_error set_feedback_delay( - REVERB_HANDLE pState, + REVERB_HANDLE hReverb, const uint16_t branch, const int16_t fb_delay ) { - if ( branch >= pState->nr_of_branches ) + if ( branch >= hReverb->nr_of_branches ) { return IVAS_ERR_INTERNAL; } - pState->delay_line[branch].Delay = fb_delay; + hReverb->delay_line[branch].Delay = fb_delay; return IVAS_ERR_OK; } @@ -769,19 +769,19 @@ static ivas_error set_feedback_delay( *-----------------------------------------------------------------------------------------*/ static ivas_error set_feedback_gain( - REVERB_HANDLE pState, + REVERB_HANDLE hReverb, const uint16_t branch, const float *pGain ) { uint16_t gain_idx; - if ( branch >= pState->nr_of_branches ) + if ( branch >= hReverb->nr_of_branches ) { return IVAS_ERR_INTERNAL; } - for ( gain_idx = 0; gain_idx < pState->nr_of_branches; gain_idx++ ) + for ( gain_idx = 0; gain_idx < hReverb->nr_of_branches; gain_idx++ ) { - pState->gain_matrix[branch][gain_idx] = pGain[gain_idx]; + hReverb->gain_matrix[branch][gain_idx] = pGain[gain_idx]; } return IVAS_ERR_OK; @@ -795,7 +795,7 @@ static ivas_error set_feedback_gain( *-----------------------------------------------------------------------------------------*/ static ivas_error set_correl_fft_filter( - REVERB_HANDLE pState, + REVERB_HANDLE hReverb, const uint16_t channel, rv_fftwf_type_complex *pSpectrum ) { @@ -806,11 +806,11 @@ static ivas_error set_correl_fft_filter( if ( channel == 0 ) { - ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( pSpectrum, pState->fft_filter_correl_0.fft_spectrum, pState->fft_filter_correl_0.fft_size ); + ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( pSpectrum, hReverb->fft_filter_correl_0.fft_spectrum, hReverb->fft_filter_correl_0.fft_size ); } else { - ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( pSpectrum, pState->fft_filter_correl_1.fft_spectrum, pState->fft_filter_correl_1.fft_size ); + ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( pSpectrum, hReverb->fft_filter_correl_1.fft_spectrum, hReverb->fft_filter_correl_1.fft_size ); } return IVAS_ERR_OK; @@ -824,7 +824,7 @@ static ivas_error set_correl_fft_filter( *-----------------------------------------------------------------------------------------*/ static ivas_error set_color_fft_filter( - REVERB_HANDLE pState, + REVERB_HANDLE hReverb, const uint16_t channel, rv_fftwf_type_complex *pSpectrum ) { @@ -835,11 +835,11 @@ static ivas_error set_color_fft_filter( if ( channel == 0 ) { - ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( pSpectrum, pState->fft_filter_color_0.fft_spectrum, pState->fft_filter_color_0.fft_size ); + ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( pSpectrum, hReverb->fft_filter_color_0.fft_spectrum, hReverb->fft_filter_color_0.fft_size ); } else { - ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( pSpectrum, pState->fft_filter_color_1.fft_spectrum, pState->fft_filter_color_1.fft_size ); + ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( pSpectrum, hReverb->fft_filter_color_1.fft_spectrum, hReverb->fft_filter_color_1.fft_size ); } return IVAS_ERR_OK; @@ -853,7 +853,7 @@ static ivas_error set_color_fft_filter( *-----------------------------------------------------------------------------------------*/ static ivas_error set_mixer_level( - REVERB_HANDLE pState, + REVERB_HANDLE hReverb, const uint16_t channel, const float level[] ) { @@ -863,9 +863,9 @@ static ivas_error set_mixer_level( return IVAS_ERR_INTERNAL; } - for ( branch_idx = 0; branch_idx < pState->nr_of_branches; branch_idx++ ) + for ( branch_idx = 0; branch_idx < hReverb->nr_of_branches; branch_idx++ ) { - pState->mixer[channel][branch_idx] = level[branch_idx]; + hReverb->mixer[channel][branch_idx] = level[branch_idx]; } return IVAS_ERR_OK; @@ -879,7 +879,7 @@ static ivas_error set_mixer_level( *-----------------------------------------------------------------------------------------*/ static void clear_buffers( - REVERB_HANDLE pState ) + REVERB_HANDLE hReverb ) { int16_t branch_idx; ivas_rev_iir_filter_t *iirFilter; @@ -887,15 +887,15 @@ static void clear_buffers( for ( branch_idx = 0; branch_idx < IVAS_REV_MAX_NR_BRANCHES; branch_idx++ ) { - delay_line = &( pState->delay_line[branch_idx] ); + delay_line = &( hReverb->delay_line[branch_idx] ); set_f( delay_line->pBuffer, 0, delay_line->MaxDelay ); delay_line->BufferPos = 0; - iirFilter = &( pState->t60[branch_idx] ); + iirFilter = &( hReverb->t60[branch_idx] ); set_f( iirFilter->pBuffer, 0, iirFilter->MaxTaps ); } - ivas_reverb_t2f_f2t_ClearHistory( &pState->fft_filter_ols ); + ivas_reverb_t2f_f2t_ClearHistory( &hReverb->fft_filter_ols ); return; } @@ -908,31 +908,31 @@ static void clear_buffers( *-----------------------------------------------------------------------------------------*/ static void set_fft_and_datablock_sizes( - REVERB_HANDLE pState, + REVERB_HANDLE hReverb, const int16_t subframe_len ) { - pState->full_block_size = subframe_len; + hReverb->full_block_size = subframe_len; if ( subframe_len == L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES ) { - pState->fft_size = IVAS_REVERB_FFT_SIZE_48K; - pState->num_fft_subblocks = IVAS_REVERB_FFT_N_SUBBLOCKS_48K; + hReverb->fft_size = IVAS_REVERB_FFT_SIZE_48K; + hReverb->num_fft_subblocks = IVAS_REVERB_FFT_N_SUBBLOCKS_48K; } else if ( subframe_len == L_FRAME32k / MAX_PARAM_SPATIAL_SUBFRAMES ) { - pState->fft_size = IVAS_REVERB_FFT_SIZE_32K; - pState->num_fft_subblocks = IVAS_REVERB_FFT_N_SUBBLOCKS_32K; + hReverb->fft_size = IVAS_REVERB_FFT_SIZE_32K; + hReverb->num_fft_subblocks = IVAS_REVERB_FFT_N_SUBBLOCKS_32K; } else if ( subframe_len == L_FRAME16k / MAX_PARAM_SPATIAL_SUBFRAMES ) { - pState->fft_size = IVAS_REVERB_FFT_SIZE_16K; - pState->num_fft_subblocks = IVAS_REVERB_FFT_N_SUBBLOCKS_16K; + hReverb->fft_size = IVAS_REVERB_FFT_SIZE_16K; + hReverb->num_fft_subblocks = IVAS_REVERB_FFT_N_SUBBLOCKS_16K; } else { assert( 0 ); /* unsupported block size */ } - pState->fft_subblock_size = subframe_len / pState->num_fft_subblocks; + hReverb->fft_subblock_size = subframe_len / hReverb->num_fft_subblocks; return; } @@ -1030,7 +1030,7 @@ static void set_reverb_acoustic_data( *-----------------------------------------------------------------------------------------*/ static ivas_error setup_FDN_branches( - REVERB_HANDLE pState, + REVERB_HANDLE hReverb, ivas_reverb_params_t *pParams ) { int16_t nr_coefs, branch_idx, channel_idx; @@ -1041,12 +1041,12 @@ static ivas_error setup_FDN_branches( /* initialize feedback branches */ for ( branch_idx = 0; branch_idx < IVAS_REV_MAX_NR_BRANCHES; branch_idx++ ) { - ivas_rev_delay_line_init( &( pState->delay_line[branch_idx] ), pState->loop_delay_buffer[branch_idx], init_loop_delay[branch_idx], pParams->pLoop_delays[branch_idx] ); - ivas_reverb_iir_filt_init( &( pState->t60[branch_idx] ), IVAS_REV_MAX_IIR_FILTER_LENGTH ); - pState->mixer[0][branch_idx] = 0.0f; - pState->mixer[1][branch_idx] = 0.0f; + ivas_rev_delay_line_init( &( hReverb->delay_line[branch_idx] ), hReverb->loop_delay_buffer[branch_idx], init_loop_delay[branch_idx], pParams->pLoop_delays[branch_idx] ); + ivas_reverb_iir_filt_init( &( hReverb->t60[branch_idx] ), IVAS_REV_MAX_IIR_FILTER_LENGTH ); + hReverb->mixer[0][branch_idx] = 0.0f; + hReverb->mixer[1][branch_idx] = 0.0f; } - clear_buffers( pState ); + clear_buffers( hReverb ); nr_coefs = pParams->t60_filter_order + 1; if ( IVAS_REV_MAX_IIR_FILTER_LENGTH < nr_coefs ) @@ -1060,17 +1060,17 @@ static ivas_error setup_FDN_branches( pCoef_a = &pParams->pT60_filter_coeff[2 * nr_coefs * branch_idx + nr_coefs]; pCoef_b = &pParams->pT60_filter_coeff[2 * nr_coefs * branch_idx]; - if ( ( error = set_t60_filter( pState, branch_idx, nr_coefs, pCoef_a, pCoef_b ) ) != IVAS_ERR_OK ) + if ( ( error = set_t60_filter( hReverb, branch_idx, nr_coefs, pCoef_a, pCoef_b ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = set_feedback_delay( pState, branch_idx, pParams->pLoop_delays[branch_idx] ) ) != IVAS_ERR_OK ) + if ( ( error = set_feedback_delay( hReverb, branch_idx, pParams->pLoop_delays[branch_idx] ) ) != IVAS_ERR_OK ) { return error; } - if ( ( error = set_feedback_gain( pState, branch_idx, &( pParams->pLoop_feedback_matrix[branch_idx * pParams->nr_loops] ) ) ) != IVAS_ERR_OK ) + if ( ( error = set_feedback_gain( hReverb, branch_idx, &( pParams->pLoop_feedback_matrix[branch_idx * pParams->nr_loops] ) ) ) != IVAS_ERR_OK ) { return error; } @@ -1079,7 +1079,7 @@ static ivas_error setup_FDN_branches( for ( channel_idx = 0; channel_idx < pParams->nr_outputs; channel_idx++ ) { - if ( ( error = set_mixer_level( pState, channel_idx, &( pParams->pLoop_extract_matrix[channel_idx * pParams->nr_loops] ) ) ) != IVAS_ERR_OK ) + if ( ( error = set_mixer_level( hReverb, channel_idx, &( pParams->pLoop_extract_matrix[channel_idx * pParams->nr_loops] ) ) ) != IVAS_ERR_OK ) { return error; } @@ -1310,27 +1310,27 @@ void ivas_reverb_close( *-----------------------------------------------------------------------------------------*/ static void post_fft_filter( - REVERB_HANDLE pState, + REVERB_HANDLE hReverb, float *p0, float *p1, float *pBuffer_0, float *pBuffer_1 ) { - if ( pState->do_corr_filter ) + if ( hReverb->do_corr_filter ) { - ivas_reverb_t2f_f2t_in( &pState->fft_filter_ols, p0, p1, pBuffer_0, pBuffer_1 ); - ivas_reverb_fft_filter_ComplexMul( &pState->fft_filter_correl_0, pBuffer_0 ); - ivas_reverb_fft_filter_ComplexMul( &pState->fft_filter_correl_1, pBuffer_1 ); - ivas_reverb_fft_filter_CrossMix( pBuffer_0, pBuffer_1, pState->fft_filter_correl_0.fft_size ); + ivas_reverb_t2f_f2t_in( &hReverb->fft_filter_ols, p0, p1, pBuffer_0, pBuffer_1 ); + ivas_reverb_fft_filter_ComplexMul( &hReverb->fft_filter_correl_0, pBuffer_0 ); + ivas_reverb_fft_filter_ComplexMul( &hReverb->fft_filter_correl_1, pBuffer_1 ); + ivas_reverb_fft_filter_CrossMix( pBuffer_0, pBuffer_1, hReverb->fft_filter_correl_0.fft_size ); } else { - ivas_reverb_t2f_f2t_in( &pState->fft_filter_ols, p0, p1, pBuffer_0, pBuffer_1 ); + ivas_reverb_t2f_f2t_in( &hReverb->fft_filter_ols, p0, p1, pBuffer_0, pBuffer_1 ); } - ivas_reverb_fft_filter_ComplexMul( &pState->fft_filter_color_0, pBuffer_0 ); - ivas_reverb_fft_filter_ComplexMul( &pState->fft_filter_color_1, pBuffer_1 ); - ivas_reverb_t2f_f2t_out( &pState->fft_filter_ols, pBuffer_0, pBuffer_1, p0, p1 ); + ivas_reverb_fft_filter_ComplexMul( &hReverb->fft_filter_color_0, pBuffer_0 ); + ivas_reverb_fft_filter_ComplexMul( &hReverb->fft_filter_color_1, pBuffer_1 ); + ivas_reverb_t2f_f2t_out( &hReverb->fft_filter_ols, pBuffer_0, pBuffer_1, p0, p1 ); return; } @@ -1343,14 +1343,14 @@ static void post_fft_filter( *-----------------------------------------------------------------------------------------*/ static void reverb_block( - REVERB_HANDLE pState, + REVERB_HANDLE hReverb, float *pInput, float *pOut0, float *pOut1 ) { - uint16_t nr_branches = pState->nr_of_branches; - uint16_t bsize = pState->full_block_size; + uint16_t nr_branches = hReverb->nr_of_branches; + uint16_t bsize = hReverb->full_block_size; uint16_t inner_bsize = INNER_BLK_SIZE; uint16_t i, j, k, ns, branch_idx, blk_idx, start_sample_idx; @@ -1382,12 +1382,12 @@ static void reverb_block( for ( i = 0; i < nr_branches; i++ ) { float *pOutput_i = &ppOutput[i][0]; - float mixer_0_i = pState->mixer[0][i]; - float mixer_1_i = pState->mixer[1][i]; + float mixer_0_i = hReverb->mixer[0][i]; + float mixer_1_i = hReverb->mixer[1][i]; /* output and feedback are same, get sample from delay line ... */ - ivas_rev_delay_line_get_sample_blk( &( pState->delay_line[i] ), inner_bsize, pTemp ); - ivas_reverb_iir_filt_2taps_feed_blk( &( pState->t60[i] ), inner_bsize, pTemp, ppOutput[i] ); + ivas_rev_delay_line_get_sample_blk( &( hReverb->delay_line[i] ), inner_bsize, pTemp ); + ivas_reverb_iir_filt_2taps_feed_blk( &( hReverb->t60[i] ), inner_bsize, pTemp, ppOutput[i] ); for ( ns = 0; ns < inner_bsize; ns++ ) { pO0[ns] += pOutput_i[ns] * mixer_0_i; /* mixer ch 0 */ @@ -1406,7 +1406,7 @@ static void reverb_block( for ( j = 0; j < nr_branches; j++ ) { - float gain_matrix_j_i = pState->gain_matrix[j][i]; + float gain_matrix_j_i = hReverb->gain_matrix[j][i]; float *pOutput = &ppOutput[j][0]; for ( ns = 0; ns < inner_bsize; ns++ ) { @@ -1414,15 +1414,15 @@ static void reverb_block( } } - ivas_rev_delay_line_feed_sample_blk( &( pState->delay_line[i] ), inner_bsize, pFeedback_input ); + ivas_rev_delay_line_feed_sample_blk( &( hReverb->delay_line[i] ), inner_bsize, pFeedback_input ); } } /* Applying FFT filter to each sub-frame */ - for ( blk_idx = 0; blk_idx < pState->num_fft_subblocks; blk_idx++ ) + for ( blk_idx = 0; blk_idx < hReverb->num_fft_subblocks; blk_idx++ ) { - start_sample_idx = blk_idx * pState->fft_subblock_size; - post_fft_filter( pState, pOut0 + start_sample_idx, pOut1 + start_sample_idx, pFFT_buf[0], pFFT_buf[1] ); + start_sample_idx = blk_idx * hReverb->fft_subblock_size; + post_fft_filter( hReverb, pOut0 + start_sample_idx, pOut1 + start_sample_idx, pFFT_buf[0], pFFT_buf[1] ); } return; @@ -1436,14 +1436,14 @@ static void reverb_block( *-----------------------------------------------------------------------------------------*/ static ivas_error downmix_input_block( - REVERB_HANDLE pState, + const REVERB_HANDLE hReverb, float pcm_in[][L_FRAME48k], const AUDIO_CONFIG input_audio_config, float *pPcm_out, const int16_t input_offset ) { int16_t i, s, nchan_transport; - float dmx_gain = pState->dmx_gain; + float dmx_gain = hReverb->dmx_gain; switch ( input_audio_config ) { @@ -1459,7 +1459,7 @@ static ivas_error downmix_input_block( case AUDIO_CONFIG_ISM4: { nchan_transport = audioCfg2channels( input_audio_config ); - for ( s = 0; s < pState->full_block_size; s++ ) + for ( s = 0; s < hReverb->full_block_size; s++ ) { float temp = pcm_in[0][input_offset + s]; for ( i = 1; i < nchan_transport; i++ ) @@ -1475,7 +1475,7 @@ static ivas_error downmix_input_block( case AUDIO_CONFIG_HOA2: case AUDIO_CONFIG_HOA3: { - for ( s = 0; s < pState->full_block_size; s++ ) + for ( s = 0; s < hReverb->full_block_size; s++ ) { pPcm_out[s] = dmx_gain * pcm_in[0][input_offset + s]; } @@ -1497,35 +1497,35 @@ static ivas_error downmix_input_block( *-----------------------------------------------------------------------------------------*/ static void predelay_block( - REVERB_HANDLE pState, + const REVERB_HANDLE hReverb, float *pInput, float *pOutput ) { uint16_t i, idx, n_samples, blk_size; - uint16_t max_blk_size = (uint16_t) pState->predelay_line.Delay; + uint16_t max_blk_size = (uint16_t) hReverb->predelay_line.Delay; if ( max_blk_size < 2 ) { if ( max_blk_size == 0 ) /* zero-length delay line: just copy the data from input to output */ { - for ( i = 0; i < pState->full_block_size; i++ ) + for ( i = 0; i < hReverb->full_block_size; i++ ) { pOutput[i] = pInput[i]; } } else /* 1-sample length delay line: feed the data sample-by-sample */ { - for ( i = 0; i < pState->full_block_size; i++ ) + for ( i = 0; i < hReverb->full_block_size; i++ ) { - pOutput[i] = ivas_rev_delay_line_get_sample( &( pState->predelay_line ) ); - ivas_rev_delay_line_feed_sample( &( pState->predelay_line ), pInput[i] ); + pOutput[i] = ivas_rev_delay_line_get_sample( &( hReverb->predelay_line ) ); + ivas_rev_delay_line_feed_sample( &( hReverb->predelay_line ), pInput[i] ); } } } else /* multiple-sample length delay line: use block processing */ { idx = 0; - n_samples = pState->full_block_size; + n_samples = hReverb->full_block_size; while ( n_samples > 0 ) { blk_size = n_samples; @@ -1533,8 +1533,8 @@ static void predelay_block( { blk_size = max_blk_size; } - ivas_rev_delay_line_get_sample_blk( &( pState->predelay_line ), blk_size, &pOutput[idx] ); - ivas_rev_delay_line_feed_sample_blk( &( pState->predelay_line ), blk_size, &pInput[idx] ); + ivas_rev_delay_line_get_sample_blk( &( hReverb->predelay_line ), blk_size, &pOutput[idx] ); + ivas_rev_delay_line_feed_sample_blk( &( hReverb->predelay_line ), blk_size, &pInput[idx] ); idx += blk_size; n_samples -= blk_size; } @@ -1551,7 +1551,7 @@ static void predelay_block( *-----------------------------------------------------------------------------------------*/ static void mix_output_block( - REVERB_HANDLE pState, + const REVERB_HANDLE hReverb, const float *pInL, const float *pInR, float *pOutL, @@ -1559,7 +1559,7 @@ static void mix_output_block( { uint16_t i; - for ( i = 0; i < pState->full_block_size; i++ ) + for ( i = 0; i < hReverb->full_block_size; i++ ) { pOutL[i] += pInL[i]; pOutR[i] += pInR[i]; @@ -1576,12 +1576,13 @@ static void mix_output_block( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_reverb_process( - REVERB_HANDLE hReverb, /* i/o: reverb state */ + const REVERB_HANDLE hReverb, /* i : Reverberator handle */ const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const int16_t mix_signals, /* i : add reverb to output signal */ float pcm_in[][L_FRAME48k], /* i : the PCM audio to apply reverb on */ float pcm_out[][L_FRAME48k], /* o : the PCM audio with reverb applied */ - const int16_t i_ts ) + const int16_t i_ts /* i : subframe index */ +) { float tmp0[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES], tmp1[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES], tmp2[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; ivas_error error; diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index 0dfdaf0d28083baaaa060515c382631ff7eb49b9..dd8ca99d80ee6cb990fa7f65db3db9539cd837f5 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -104,7 +104,7 @@ const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS] /*----------------------------------------------------------------------------------* - * TD ISm binaural renderer ROM tables + * TD ISM binaural renderer ROM tables *----------------------------------------------------------------------------------*/ const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS] = diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 0c991c79e75351365daa90afd91f3ef69f38315f..2a45c6d61acad2ed98edf822d82ba1aa892dbfbf 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -55,6 +55,7 @@ ivas_error ivas_headTrack_open( ) { int16_t i; + ivas_error error; /* Allocate Head-Tracking handle */ if ( ( *hHeadTrackData = (HEAD_TRACK_DATA_HANDLE) malloc( sizeof( HEAD_TRACK_DATA ) ) ) == NULL ) @@ -72,7 +73,11 @@ ivas_error ivas_headTrack_open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Orientation tracking" ); } - ivas_orient_trk_Init( ( *hHeadTrackData )->OrientationTracker ); + + if ( ( error = ivas_orient_trk_Init( ( *hHeadTrackData )->OrientationTracker ) ) != IVAS_ERR_OK ) + { + return error; + } #endif /* Initialise Rmat_prev to I, Rmat will be computed later */ @@ -85,6 +90,7 @@ ivas_error ivas_headTrack_open( return IVAS_ERR_OK; } + #ifdef FIX_I109_ORIENTATION_TRACKING /*-----------------------------------------------------------------------* * ivas_headTrack_close() @@ -96,18 +102,25 @@ void ivas_headTrack_close( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ) { - if ( hHeadTrackData != NULL ) + if ( hHeadTrackData == NULL || *hHeadTrackData == NULL ) { - if ( ( *hHeadTrackData )->OrientationTracker != NULL ) - { - free( ( *hHeadTrackData )->OrientationTracker ); - } - free( ( *hHeadTrackData ) ); - *hHeadTrackData = NULL; + return; } + + if ( ( *hHeadTrackData )->OrientationTracker != NULL ) + { + free( ( *hHeadTrackData )->OrientationTracker ); + ( *hHeadTrackData )->OrientationTracker = NULL; + } + + free( ( *hHeadTrackData ) ); + *hHeadTrackData = NULL; + + return; } #endif + /*---------------------------------------------------------------------------------- * QuatToRotMat() * diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 9dafb5fb65b3ea577bcb076e1e9eebc2a3cb8176..13c6084b2d8a05d06529888460ea7d65611032ec 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -336,6 +336,7 @@ typedef struct ivas_render_config_t #ifdef TD5 float directivity[3]; #endif + } RENDER_CONFIG_DATA, *RENDER_CONFIG_HANDLE; typedef struct ivas_rev_delay_line_t @@ -418,7 +419,7 @@ typedef struct ivas_reverb_state_t /*----------------------------------------------------------------------------------* - * TD ISm Object Renderer structure + * TD ISM Object Renderer structure *----------------------------------------------------------------------------------*/ typedef struct diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index a69393e10e5a5383fc7a2fd240290313444aaf5b..1dc1c1f9567bd4b4ac122e0f2aecedf8b0a499a6 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -116,7 +116,7 @@ typedef struct IVAS_REND_AudioObjectPosition previousPos; TDREND_WRAPPER tdRendWrapper; CREND_WRAPPER_HANDLE crendWrapper; - REVERB_HANDLE reverb; + REVERB_HANDLE hReverb; rotation_matrix rot_mat_prev; } input_ism; @@ -142,7 +142,7 @@ typedef struct EFAP_WRAPPER efapInWrapper; TDREND_WRAPPER tdRendWrapper; CREND_WRAPPER_HANDLE crendWrapper; - REVERB_HANDLE reverb; + REVERB_HANDLE hReverb; rotation_gains rot_gains_prev; lfe_routing lfeRouting; } input_mc; @@ -910,6 +910,7 @@ static void initHeadRotation( { int16_t i, crossfade_len; float tmp; + ivas_error error; /* Head rotation is enabled by default */ hIvasRend->headRotData.headRotEnabled = 1; @@ -933,7 +934,11 @@ static void initHeadRotation( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Orientation tracking" ); } - ivas_orient_trk_Init( hIvasRend->headRotData.hOrientationTracker ); + + if ( ( error = ivas_orient_trk_Init( hIvasRend->headRotData.hOrientationTracker ) ) != IVAS_ERR_OK ) + { + return error; + } return IVAS_ERR_OK; #else @@ -949,6 +954,8 @@ static void closeHeadRotation( { free( hIvasRend->headRotData.hOrientationTracker ); } + + return; } #endif @@ -1060,7 +1067,9 @@ static CREND_WRAPPER defaultCrendWrapper( return w; } -static bool isIoConfigPairSupported( IVAS_REND_AudioConfig inConfig, IVAS_REND_AudioConfig outConfig ) +static bool isIoConfigPairSupported( + IVAS_REND_AudioConfig inConfig, + IVAS_REND_AudioConfig outConfig ) { /* Rendering mono or stereo to binaural is not supported */ if ( ( inConfig == IVAS_REND_AUDIO_CONFIG_MONO || inConfig == IVAS_REND_AUDIO_CONFIG_STEREO ) && @@ -1098,7 +1107,7 @@ static ivas_error setRendInputActiveIsm( inputIsm->currentPos = defaultObjectPosition(); inputIsm->previousPos = defaultObjectPosition(); inputIsm->crendWrapper = NULL; - inputIsm->reverb = NULL; + inputIsm->hReverb = NULL; inputIsm->tdRendWrapper = defaultTdRendWrapper(); initRotMatrix( inputIsm->rot_mat_prev ); @@ -1127,16 +1136,14 @@ static ivas_error setRendInputActiveIsm( return error; } - if ( ( error = ivas_reverb_open( &( inputIsm->reverb ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &( inputIsm->hReverb ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, hRendCfg, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } } else { - if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, AUDIO_CONFIG_7_1_4, - getIvasAudioConfigFromRendAudioConfig( outConfig ), - hRendCfg, + if ( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), hRendCfg, #ifndef FIX_I109_ORIENTATION_TRACKING 0, #endif @@ -1160,15 +1167,10 @@ static void clearInputIsm( initRendInputBase( &inputIsm->base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, rendCtx ); /* Free input's internal handles */ - if ( inputIsm->crendWrapper != NULL ) - { - ivas_rend_closeCrend( &inputIsm->crendWrapper ); - } - if ( inputIsm->reverb != NULL ) - { - ivas_reverb_close( &inputIsm->reverb ); - } + ivas_rend_closeCrend( &inputIsm->crendWrapper ); + + ivas_reverb_close( &inputIsm->hReverb ); if ( inputIsm->tdRendWrapper.hBinRendererTd != NULL ) { @@ -1226,6 +1228,8 @@ static void fillIdentityPanMatrix( { panMatrix[i][i] = 1.0f; } + + return; } static ivas_error initMcPanGainsWithIdentMatrix( @@ -1250,8 +1254,7 @@ static ivas_error initMcPanGainsWithConversionMapping( * Stay with default panning matrix if conversion_matrix is NULL */ for ( i = 0; i < LS_SETUP_CONVERSION_NUM_MAPPINGS; ++i ) { - if ( ls_conversion_mapping[i].input_config == ivasConfigIn && - ls_conversion_mapping[i].output_config == ivasConfigOut ) + if ( ls_conversion_mapping[i].input_config == ivasConfigIn && ls_conversion_mapping[i].output_config == ivasConfigOut ) { /* Mapping found with valid matrix - copy */ if ( ls_conversion_mapping[i].conversion_matrix != NULL ) @@ -1807,15 +1810,9 @@ static ivas_error initMcBinauralRendering( inputMc->tdRendWrapper.hHrtfTD = NULL; } - if ( inputMc->crendWrapper != NULL ) - { - ivas_rend_closeCrend( &inputMc->crendWrapper ); - } + ivas_rend_closeCrend( &inputMc->crendWrapper ); - if ( inputMc->reverb != NULL ) - { - ivas_reverb_close( &inputMc->reverb ); - } + ivas_reverb_close( &inputMc->hReverb ); if ( inputMc->efapInWrapper.hEfap != NULL ) { @@ -1853,7 +1850,7 @@ static ivas_error initMcBinauralRendering( if ( hRendCfg != NULL && hRendCfg->roomAcoustics.use_brir == 0 && hRendCfg->roomAcoustics.late_reverb_on ) { - if ( ( error = ivas_reverb_open( &( inputMc->reverb ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_open( &( inputMc->hReverb ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, hRendCfg, outSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -1861,9 +1858,7 @@ static ivas_error initMcBinauralRendering( } { - if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, - ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) ? AUDIO_CONFIG_7_1_4 : getIvasAudioConfigFromRendAudioConfig( inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), - hRendCfg, + if ( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) ? AUDIO_CONFIG_7_1_4 : getIvasAudioConfigFromRendAudioConfig( inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), hRendCfg, #ifndef FIX_I109_ORIENTATION_TRACKING 0, #endif @@ -1891,7 +1886,7 @@ static lfe_routing defaultLfeRouting( const IVAS_REND_AudioConfig outConfig, const LSSETUP_CUSTOM_STRUCT customLsOut ) { - int32_t i; + int16_t i; lfe_routing routing; /* Set all output gains to zero, then route each input LFE consecutively to the next available output LFE. */ @@ -1968,7 +1963,7 @@ static ivas_error setRendInputActiveMc( inputMc->customLsInput = defaultCustomLs(); inputMc->tdRendWrapper = defaultTdRendWrapper(); inputMc->crendWrapper = NULL; - inputMc->reverb = NULL; + inputMc->hReverb = NULL; initRotGains( inputMc->rot_gains_prev ); inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut ); @@ -2003,15 +1998,9 @@ static void clearInputMc( efap_free_data( &inputMc->efapInWrapper.hEfap ); } - if ( inputMc->crendWrapper != NULL ) - { - ivas_rend_closeCrend( &inputMc->crendWrapper ); - } + ivas_rend_closeCrend( &inputMc->crendWrapper ); - if ( inputMc->reverb != NULL ) - { - ivas_reverb_close( &inputMc->reverb ); - } + ivas_reverb_close( &inputMc->hReverb ); if ( inputMc->tdRendWrapper.hBinRendererTd != NULL ) { @@ -2222,10 +2211,7 @@ static void clearInputSba( initRendInputBase( &inputSba->base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, rendCtx ); /* Free input's internal handles */ - if ( inputSba->crendWrapper != NULL ) - { - ivas_rend_closeCrend( &inputSba->crendWrapper ); - } + ivas_rend_closeCrend( &inputSba->crendWrapper ); return; } @@ -2492,7 +2478,7 @@ static DecoderDummy *initDecoderDummy( decDummy = malloc( sizeof( DecoderDummy ) ); decDummy->hDecoderConfig = malloc( sizeof( DECODER_CONFIG ) ); decDummy->hDecoderConfig->output_Fs = sampleRate; - decDummy->hDecoderConfig->nchan_out = (int16_t) numOutChannels; + decDummy->hDecoderConfig->nchan_out = numOutChannels; decDummy->hDecoderConfig->Opt_Headrotation = 0; decDummy->hBinRenderer = NULL; @@ -2576,7 +2562,7 @@ static ivas_error setRendInputActiveMasa( { return error; } - inputMasa->decDummy = initDecoderDummy( *rendCtx.pOutSampleRate, (int16_t) numInChannels, outConfig, 0 ); + inputMasa->decDummy = initDecoderDummy( *rendCtx.pOutSampleRate, numInChannels, outConfig, 0 ); inputMasa->metadataHasBeenFed = false; if ( ( error = updateMasaDummyDec( inputMasa, outConfig ) ) != IVAS_ERR_OK ) @@ -2603,6 +2589,7 @@ static void freeDecoderDummy( { free( pDecDummy->hDecoderConfig ); } + if ( pDecDummy->hHeadTrackData != NULL ) { #ifdef FIX_I109_ORIENTATION_TRACKING @@ -2621,7 +2608,6 @@ static void freeDecoderDummy( if ( pDecDummy->cldfbAnaDec[i] != NULL ) { deleteCldfb( &( pDecDummy->cldfbAnaDec[i] ) ); - pDecDummy->cldfbAnaDec[i] = NULL; } } @@ -2630,16 +2616,11 @@ static void freeDecoderDummy( if ( pDecDummy->cldfbSynDec[i] != NULL ) { deleteCldfb( &( pDecDummy->cldfbSynDec[i] ) ); - pDecDummy->cldfbSynDec[i] = NULL; } } /* DirAC handle */ - if ( pDecDummy->hDirAC != NULL ) - { - ivas_dirac_dec_close( pDecDummy->hDirAC ); - pDecDummy->hDirAC = NULL; - } + ivas_dirac_dec_close( &( pDecDummy->hDirAC ) ); /* Qmetadata handle */ ivas_qmetadata_close( &pDecDummy->hQMetaData ); @@ -2686,10 +2667,7 @@ ivas_error IVAS_REND_Open( ivas_error error; int16_t numOutChannels; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( phIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -2754,7 +2732,7 @@ ivas_error IVAS_REND_Open( { initRendInputBase( &hIvasRend->inputsIsm[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) ); hIvasRend->inputsIsm[i].crendWrapper = NULL; - hIvasRend->inputsIsm[i].reverb = NULL; + hIvasRend->inputsIsm[i].hReverb = NULL; hIvasRend->inputsIsm[i].tdRendWrapper.hBinRendererTd = NULL; } @@ -2763,7 +2741,7 @@ ivas_error IVAS_REND_Open( initRendInputBase( &hIvasRend->inputsMc[i].base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, getRendCtx( hIvasRend ) ); hIvasRend->inputsMc[i].efapInWrapper.hEfap = NULL; hIvasRend->inputsMc[i].crendWrapper = NULL; - hIvasRend->inputsMc[i].reverb = NULL; + hIvasRend->inputsMc[i].hReverb = NULL; hIvasRend->inputsMc[i].tdRendWrapper.hBinRendererTd = NULL; } @@ -2848,10 +2826,7 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( input_mc *inputMc; input_sba *inputSba; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -2933,10 +2908,7 @@ ivas_error IVAS_REND_NumOutChannels( { ivas_error error; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL || numOutChannels == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3159,10 +3131,7 @@ ivas_error IVAS_REND_AddInput( ivas_error ( *activateInput )( void *, IVAS_REND_AudioConfig, IVAS_REND_InputId, RENDER_CONFIG_DATA * ); int32_t inputIndex; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL || inputId == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3231,10 +3200,7 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( input_mc *inputMc; ivas_error error; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3300,10 +3266,7 @@ ivas_error IVAS_REND_SetInputGain( input_base *inputBase; ivas_error error; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3337,10 +3300,7 @@ ivas_error IVAS_REND_SetInputLfeMtx( input_mc *pInputMc; ivas_error error; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3391,10 +3351,7 @@ ivas_error IVAS_REND_SetInputLfePos( input_mc *pInputMc; ivas_error error; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3440,10 +3397,7 @@ ivas_error IVAS_REND_RemoveInput( ivas_error error; input_base *inputBase; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3491,10 +3445,7 @@ ivas_error IVAS_REND_GetInputNumChannels( ivas_error error; const input_base *pInput; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL || numChannels == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3533,10 +3484,7 @@ ivas_error IVAS_REND_GetDelay( int32_t latency_ns; int32_t max_latency_ns; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL || nSamples == NULL || timeScale == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3607,10 +3555,7 @@ ivas_error IVAS_REND_FeedInputAudio( input_base *inputBase; int16_t numInputChannels; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL || inputAudio.data == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3674,10 +3619,7 @@ ivas_error IVAS_REND_FeedInputObjectMetadata( input_ism *inputIsm; ivas_error error; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3718,10 +3660,7 @@ ivas_error IVAS_REND_FeedInputMasaMetadata( input_base *inputBase; input_masa *inputMasa; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3775,9 +3714,9 @@ ivas_error IVAS_REND_InitConfig( return error; } - if ( ivas_render_config_init_from_rom( &hIvasRend->hRendererConfig, hIvasRend->rendererConfigEnabled ) != IVAS_ERR_OK ) + if ( ( error = ivas_render_config_init_from_rom( &hIvasRend->hRendererConfig, hIvasRend->rendererConfigEnabled ) ) != IVAS_ERR_OK ) { - return IVAS_ERR_INTERNAL_FATAL; + return error; } } else @@ -3905,10 +3844,7 @@ ivas_error IVAS_REND_SetHeadRotation( IVAS_QUATERNION rotQuat; #endif - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3953,13 +3889,21 @@ ivas_error IVAS_REND_SetHeadRotation( return IVAS_ERR_OK; } + #ifdef FIX_I109_ORIENTATION_TRACKING +/*-------------------------------------------------------------------* + * IVAS_REND_SetOrientationTrackingMode() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_SetOrientationTrackingMode( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const uint8_t otrMode /* i : Orientation tracking mode */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const uint8_t otrMode /* i : Orientation tracking mode */ ) { OTR_TRACKING_T mode; + ivas_error error; if ( hIvasRend == NULL ) { @@ -3988,59 +3932,97 @@ ivas_error IVAS_REND_SetOrientationTrackingMode( break; } - ivas_orient_trk_SetTrackingType( hIvasRend->headRotData.hOrientationTracker, mode ); + if ( ( error = ivas_orient_trk_SetTrackingType( hIvasRend->headRotData.hOrientationTracker, mode ) ) != IVAS_ERR_OK ) + { + return error; + } return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_SetReferenceRotation() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_SetReferenceRotation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const IVAS_QUATERNION refRot /* i : Reference rotation */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_QUATERNION refRot /* i : Reference rotation */ ) { - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ + ivas_error error; + /* Validate function arguments */ if ( hIvasRend == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - ivas_orient_trk_SetReferenceRotation( hIvasRend->headRotData.hOrientationTracker, refRot ); + + if ( ( error = ivas_orient_trk_SetReferenceRotation( hIvasRend->headRotData.hOrientationTracker, refRot ) ) != IVAS_ERR_OK ) + { + return error; + } return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_GetMainOrientation() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetMainOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer for main orientation */ ) { + ivas_error error; + if ( hIvasRend == NULL || pOrientation == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - ivas_orient_trk_GetMainOrientation( hIvasRend->headRotData.hOrientationTracker, pOrientation ); + if ( ( error = ivas_orient_trk_GetMainOrientation( hIvasRend->headRotData.hOrientationTracker, pOrientation ) ) != IVAS_ERR_OK ) + { + return error; + } return IVAS_ERR_OK; } + +/*-------------------------------------------------------------------* + * IVAS_REND_GetTrackedRotation() + * + * + *-------------------------------------------------------------------*/ + ivas_error IVAS_REND_GetTrackedRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ IVAS_QUATERNION *pRotation /* i/o: Quaternion pointer processed rotation */ ) { + ivas_error error; + if ( hIvasRend == NULL || pRotation == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - ivas_orient_trk_GetTrackedRotation( hIvasRend->headRotData.hOrientationTracker, pRotation ); + if ( ( error = ivas_orient_trk_GetTrackedRotation( hIvasRend->headRotData.hOrientationTracker, pRotation ) ) != IVAS_ERR_OK ) + { + return error; + } return IVAS_ERR_OK; } + #ifdef OTR_REFERENCE_VECTOR_TRACKING /*---------------------------------------------------------------------* * IVAS_REND_SetReferenceVector( ) @@ -4050,9 +4032,9 @@ ivas_error IVAS_REND_GetTrackedRotation( *---------------------------------------------------------------------*/ ivas_error IVAS_REND_SetReferenceVector( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const IVAS_VECTOR3 listenerPos, /* i : Listener position */ - const IVAS_VECTOR3 refPos /* i : Reference position */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_VECTOR3 listenerPos, /* i : Listener position */ + const IVAS_VECTOR3 refPos /* i : Reference position */ ) { if ( hIvasRend == NULL || hIvasRend->headRotData.hOrientationTracker == NULL ) @@ -4202,7 +4184,7 @@ static ivas_error rotateFrameMc( /* initialize gains to passthrough */ for ( ch_in = 0; ch_in < nchan; ch_in++ ) { - set_zero( gains[ch_in], (int16_t) nchan ); + set_zero( gains[ch_in], nchan ); gains[ch_in][ch_in] = 1.f; } @@ -4408,7 +4390,7 @@ static ivas_error renderIsmToBinaural( NULL, ismInput->base.ctx.pHeadRotData, &ismInput->currentPos, - ismInput->reverb, + ismInput->hReverb, outAudio.config.numSamplesPerChannel, tmpTDRendBuffer ) ) != IVAS_ERR_OK ) { @@ -4445,7 +4427,7 @@ static ivas_error renderIsmToBinauralRoom( headRotData = ismInput->base.ctx.pHeadRotData; rotatedPos = defaultObjectPosition(); - if ( ismInput->reverb != NULL && ismInput->reverb->pConfig.roomAcoustics.use_brir == 0 && ismInput->reverb->pConfig.roomAcoustics.late_reverb_on == 1 && headRotData->headRotEnabled ) + if ( ismInput->hReverb != NULL && ismInput->hReverb->pConfig.roomAcoustics.use_brir == 0 && ismInput->hReverb->pConfig.roomAcoustics.late_reverb_on == 1 && headRotData->headRotEnabled ) { copyBufferTo2dArray( ismInput->base.inputBuffer, tmpRendBuffer ); @@ -4455,7 +4437,7 @@ static ivas_error renderIsmToBinauralRoom( NULL, ismInput->base.ctx.pHeadRotData, &ismInput->currentPos, - ismInput->reverb, + ismInput->hReverb, outAudio.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { @@ -4538,13 +4520,8 @@ static ivas_error renderIsmToBinauralRoom( copyBufferTo2dArray( tmpMcBuffer, tmpRendBuffer ); - - if ( ( error = ivas_rend_crendProcess( - ismInput->crendWrapper, - AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, - NULL, NULL, NULL, NULL, - tmpRendBuffer, - *ismInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, + NULL, NULL, NULL, NULL, tmpRendBuffer, *ismInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -4631,6 +4608,7 @@ static ivas_error renderIsmToSba( { return error; } + if ( ( error = getAmbisonicsOrder( outConfig, &ambiOrderOut ) ) != IVAS_ERR_OK ) { return error; @@ -4685,7 +4663,6 @@ static ivas_error renderInputIsm( /* Apply input gain to new audio */ v_multc( inAudio.data, ismInput->base.gain, inAudio.data, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); - switch ( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: @@ -4809,19 +4786,12 @@ static ivas_error renderMcToBinaural( headRotEnabled = mcInput->base.ctx.pHeadRotData->headRotEnabled; inConfig = mcInput->base.inConfig; - if ( ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) || - ( headRotEnabled && ( inConfig == IVAS_REND_AUDIO_CONFIG_5_1 || inConfig == IVAS_REND_AUDIO_CONFIG_7_1 ) ) ) + if ( ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) || ( headRotEnabled && ( inConfig == IVAS_REND_AUDIO_CONFIG_5_1 || inConfig == IVAS_REND_AUDIO_CONFIG_7_1 ) ) ) { copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); - if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, - mcInput->base.inConfig, - &mcInput->customLsInput, - mcInput->base.ctx.pHeadRotData, - NULL, - mcInput->reverb, - mcInput->base.inputBuffer.config.numSamplesPerChannel, - tmpRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, NULL, + mcInput->hReverb, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -4835,13 +4805,8 @@ static ivas_error renderMcToBinaural( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); - if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, - mcInput->base.inConfig, - mcInput->customLsInput, - mcInput->base.ctx.pHeadRotData, - mcInput->rot_gains_prev, - mcInput->efapInWrapper.hEfap, - tmpRotBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, + mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -4855,10 +4820,8 @@ static ivas_error renderMcToBinaural( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( - mcInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), - NULL, NULL, NULL, NULL, - tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), + NULL, NULL, NULL, NULL, tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -4893,25 +4856,18 @@ static ivas_error renderMcToBinauralRoom( headRotEnabled = mcInput->base.ctx.pHeadRotData->headRotEnabled; inConfig = mcInput->base.inConfig; - if ( ( mcInput->reverb != NULL && mcInput->reverb->pConfig.roomAcoustics.use_brir == 0 && mcInput->reverb->pConfig.roomAcoustics.late_reverb_on == 1 ) && ( ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) || ( headRotEnabled && ( inConfig == IVAS_REND_AUDIO_CONFIG_5_1 || inConfig == IVAS_REND_AUDIO_CONFIG_7_1 ) ) ) ) + if ( ( mcInput->hReverb != NULL && mcInput->hReverb->pConfig.roomAcoustics.use_brir == 0 && mcInput->hReverb->pConfig.roomAcoustics.late_reverb_on == 1 ) && ( ( inConfig == IVAS_REND_AUDIO_CONFIG_LS_CUSTOM ) || ( headRotEnabled && ( inConfig == IVAS_REND_AUDIO_CONFIG_5_1 || inConfig == IVAS_REND_AUDIO_CONFIG_7_1 ) ) ) ) { copyBufferTo2dArray( mcInput->base.inputBuffer, tmpRendBuffer ); - if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, - mcInput->base.inConfig, - &mcInput->customLsInput, - mcInput->base.ctx.pHeadRotData, - NULL, - mcInput->reverb, - mcInput->base.inputBuffer.config.numSamplesPerChannel, - tmpRendBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_renderer_ext( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, + NULL, mcInput->hReverb, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer ) ) != IVAS_ERR_OK ) { return error; } } else { - /* apply rotation */ if ( headRotEnabled ) { @@ -4919,13 +4875,8 @@ static ivas_error renderMcToBinauralRoom( tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) ); set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); - if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, - mcInput->base.inConfig, - mcInput->customLsInput, - mcInput->base.ctx.pHeadRotData, - mcInput->rot_gains_prev, - mcInput->efapInWrapper.hEfap, - tmpRotBuffer ) ) != IVAS_ERR_OK ) + if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, + mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -4939,17 +4890,14 @@ static ivas_error renderMcToBinauralRoom( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( - mcInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), - NULL, NULL, NULL, NULL, - tmpRendBuffer, - *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( mcInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), + NULL, NULL, NULL, NULL, tmpRendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } } - accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); + accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); /* TODO tmu : needs delay compensation */ if ( ( error = renderLfeToBinaural( mcInput, outAudio ) ) != IVAS_ERR_OK ) @@ -5003,7 +4951,7 @@ static ivas_error renderMcCustomLsToBinauralRoom( return error; } - tmpMcBuffer.config.numChannels = (int16_t) tmp; + tmpMcBuffer.config.numChannels = tmp; tmpMcBuffer.data = malloc( tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels * sizeof( float ) ); set_zero( tmpMcBuffer.data, tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels ); @@ -5015,9 +4963,8 @@ static ivas_error renderMcCustomLsToBinauralRoom( copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer ); /* call CREND */ - if ( ( error = ivas_rend_crendProcess( - mcInput->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, - tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcess( mcInput->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, + tmpCrendBuffer, *mcInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -5245,9 +5192,8 @@ static ivas_error renderSbaToBinaural( } /* call CREND */ - if ( ( error = ivas_rend_crendProcess( - sbaInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( sbaInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), NULL, NULL, NULL, NULL, - tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, getIvasAudioConfigFromRendAudioConfig( sbaInput->base.inConfig ), getIvasAudioConfigFromRendAudioConfig( outConfig ), + NULL, NULL, NULL, NULL, tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -5302,7 +5248,7 @@ static ivas_error renderSbaToBinauralRoom( return error; } - tmpMcBuffer.config.numChannels = (int16_t) tmp; + tmpMcBuffer.config.numChannels = tmp; tmpMcBuffer.data = malloc( tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels * sizeof( float ) ); set_zero( tmpMcBuffer.data, tmpMcBuffer.config.numChannels * tmpMcBuffer.config.numSamplesPerChannel ); @@ -5315,10 +5261,8 @@ static ivas_error renderSbaToBinauralRoom( copyBufferTo2dArray( tmpMcBuffer, tmpCrendBuffer ); /* call CREND */ - if ( ( error = ivas_rend_crendProcess( - sbaInput->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), - NULL, NULL, NULL, NULL, - tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcess( sbaInput->crendWrapper, AUDIO_CONFIG_7_1_4, getIvasAudioConfigFromRendAudioConfig( outConfig ), + NULL, NULL, NULL, NULL, tmpCrendBuffer, *sbaInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; } @@ -5566,7 +5510,7 @@ static ivas_error renderActiveInputsMasa( IVAS_REND_HANDLE hIvasRend, IVAS_REND_AudioBuffer outAudio ) { - int32_t i; + int16_t i; input_masa *pCurrentInput; ivas_error error; @@ -5602,10 +5546,7 @@ ivas_error IVAS_REND_GetSamples( ivas_error error; int16_t numOutChannels; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( hIvasRend == NULL || outAudio.data == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -5683,10 +5624,7 @@ void IVAS_REND_Close( uint16_t i; IVAS_REND_HANDLE hIvasRend; - /*-----------------------------------------------------------------* - * Validate function arguments - *-----------------------------------------------------------------*/ - + /* Validate function arguments */ if ( phIvasRend == NULL || *phIvasRend == NULL ) { return; diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c index b6166af95bd3fab2e471bec982ef9cc02c010d80..d60a7c1984be63283863b8298b01ebd333f5222d 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -59,7 +59,7 @@ struct IsmFileReader *---------------------------------------------------------------------*/ IsmFileReader *IsmFileReader_open( - const char *filePath /* i : path to ism metadata file */ + const char *filePath /* i : path to ISM metadata file */ ) { IsmFileReader *self; @@ -95,13 +95,13 @@ IsmFileReader *IsmFileReader_open( /*! r: error code */ ivas_error IsmFileReader_readNextFrame( IsmFileReader *self, /* i/o: IsmFileReader handle */ - IVAS_ISM_METADATA *ismMetadata /* o ISM : metadata read from the opened file */ + IVAS_ISM_METADATA *ismMetadata /* o : ISM metadata read from the opened file */ ) { char char_buff[META_LINE_LENGTH]; float meta_prm[NUM_ISM_METADATA_PER_LINE]; #ifdef TD5 - float meta_prm_default[NUM_ISM_METADATA_PER_LINE] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f }; + const float meta_prm_default[NUM_ISM_METADATA_PER_LINE] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f }; #endif char *char_ptr; int16_t i; diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index 7c9227a65ce1b56821ff24e9a0cf7f426e02b7a1..870cf335867073266763d2a454e6fc6b0a1fab14 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -56,7 +56,7 @@ struct IsmFileWriter /*! r: error code */ ivas_error IsmFileWriter_open( const char *filePathWav, /* i : path to output file */ - const int16_t obj_num, /* i : ISm number */ + const int16_t obj_num, /* i : number of ISM channels */ IsmFileWriter **ismWriter /* o : IsmFileWriter handle */ ) { diff --git a/lib_util/ism_file_writer.h b/lib_util/ism_file_writer.h index 24b4c58bd4d89d805212ece1250546ed925d8c27..d9f731e87e56b8f0b333d725d813047320d82a39 100644 --- a/lib_util/ism_file_writer.h +++ b/lib_util/ism_file_writer.h @@ -43,7 +43,7 @@ typedef struct IsmFileWriter IsmFileWriter; /*! r: error code */ ivas_error IsmFileWriter_open( const char *filePathWav, /* i : path to output file */ - const int16_t obj_num, /* i : ISm number */ + const int16_t obj_num, /* i : number of ISM channels */ IsmFileWriter **ismWriter /* o : IsmFileReader handle */ );