From da2a0d29aef66c65ce78a6aae9a0994d060031b5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 09:36:00 +0200 Subject: [PATCH 01/52] maintenance --- apps/decoder.c | 20 ++- lib_com/delay_comp.c | 2 +- lib_com/ivas_cnst.h | 39 ++---- lib_com/ivas_entropy_coder_common.c | 9 +- lib_com/ivas_ism_com.c | 10 +- lib_com/ivas_pca_tools.c | 8 ++ lib_com/ivas_prot.h | 33 +---- lib_com/prot.h | 11 +- lib_dec/ivas_binRenderer_internal.c | 8 +- lib_dec/ivas_dec.c | 18 ++- lib_dec/ivas_dirac_dec.c | 17 ++- lib_dec/ivas_init_dec.c | 46 +------ lib_dec/ivas_ism_dec.c | 24 ++-- lib_dec/ivas_ism_param_dec.c | 25 ++-- lib_dec/ivas_jbm_dec.c | 108 ++++++++-------- lib_dec/ivas_masa_dec.c | 1 + lib_dec/ivas_mc_param_dec.c | 10 +- lib_dec/ivas_mc_paramupmix_dec.c | 6 - lib_dec/ivas_mct_dec.c | 14 +- lib_dec/ivas_mono_dmx_renderer.c | 2 +- lib_dec/ivas_omasa_dec.c | 10 +- lib_dec/ivas_output_config.c | 23 ++-- lib_dec/ivas_sba_dec.c | 6 +- lib_dec/ivas_spar_decoder.c | 6 +- lib_dec/lib_dec.c | 12 +- lib_enc/ivas_cpe_enc.c | 5 +- lib_enc/ivas_ism_param_enc.c | 19 +-- lib_enc/ivas_masa_enc.c | 1 + lib_enc/ivas_pca_enc.c | 5 + lib_enc/ivas_stereo_classifier.c | 2 +- lib_enc/q_gain2p.c | 14 +- lib_rend/ivas_crend.c | 73 +++++------ lib_rend/ivas_dirac_dec_binaural_functions.c | 46 ++----- lib_rend/ivas_dirac_decorr_dec.c | 6 - lib_rend/ivas_dirac_rend.c | 21 +-- lib_rend/ivas_lcld_prot.h | 2 + lib_rend/ivas_objectRenderer.c | 35 ++--- lib_rend/ivas_objectRenderer_sources.c | 44 +++---- lib_rend/ivas_orient_trk.c | 3 +- lib_rend/ivas_prot_rend.h | 129 +++++++++---------- lib_rend/ivas_reflections.c | 34 ++--- lib_rend/ivas_rotation.c | 55 ++++---- lib_rend/ivas_shoebox.c | 36 +++--- lib_rend/ivas_splitRendererPost.c | 4 +- lib_rend/ivas_splitRendererPre.c | 49 +------ lib_rend/ivas_stat_rend.h | 3 - lib_rend/lib_rend.c | 36 ++---- lib_rend/lib_rend.h | 6 +- lib_util/audio_file_reader.c | 2 +- lib_util/audio_file_writer.c | 1 - lib_util/hrtf_file_reader.c | 20 ++- lib_util/masa_file_reader.c | 1 - lib_util/masa_file_writer.c | 2 - lib_util/mime_io.c | 2 +- lib_util/render_config_reader.c | 111 ++++++++++------ lib_util/rotation_file_reader.c | 2 +- lib_util/split_rend_bfi_file_reader.c | 10 +- lib_util/split_render_file_read_write.c | 10 +- lib_util/vector3_pair_file_reader.c | 6 +- 59 files changed, 542 insertions(+), 721 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 9b5619ceac..3d67a39264 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3166,12 +3166,11 @@ static ivas_error decodeVoIP( for ( i = 0; i < num_subframes; i++ ) { - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i #ifdef SPLIT_REND_WITH_HEAD_ROT - , - DEFAULT_AXIS + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -3189,14 +3188,13 @@ static ivas_error decodeVoIP( for ( i = 0; i < num_subframes; i++ ) { - if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternions[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError %s while reading external orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), - RotationFileReader_getFilePath( externalOrientationFileReader ) ); + fprintf( stderr, "\nError %s while reading external orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( externalOrientationFileReader ) ); goto cleanup; } } + for ( i = 0; i < num_subframes; i++ ) { if ( ( error = IVAS_DEC_FeedExternalOrientationData( hIvasDec, Quaternions[i], enableHeadRotation[i], enableExternalOrientation[i], enableRotationInterpolation[i], numFramesToTargetOrientation[i], i ) ) != IVAS_ERR_OK ) @@ -3230,13 +3228,12 @@ static ivas_error decodeVoIP( else { auPtr = au; /* might have been set to RTP packet in prev call */ - rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, - &nextPacketRcvTime_ms, - &isAMRWB_IOmode, &frameTypeIndex, &qBit, - &auPtr, (uint16_t *) &auSize ); + rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, + &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSize ); /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */ rtpTimeStamp = rtpTimeStamp / 16; } + if ( error == IVAS_ERR_END_OF_FILE || rtpdumpDepackerError == EVS_RTPDUMP_DEPACKER_EOF ) { /* finished reading */ @@ -3259,7 +3256,6 @@ static ivas_error decodeVoIP( /* decode and get samples */ - #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 9826da2474..d2c647af46 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -56,7 +56,7 @@ int32_t get_delay( const IVAS_FORMAT ivas_format, /* i : IVAS format */ #ifdef SPLIT_REND_WITH_HEAD_ROT HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ - const AUDIO_CONFIG output_config /* i : decoder output config */ + const AUDIO_CONFIG output_config /* i : decoder output config */ #else HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ #endif diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index e9173e6e93..969eda234f 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -986,15 +986,13 @@ typedef enum #define SPAR_CONFIG_BW FB #define IVAS_SPAR_MAX_CH ((( IVAS_MAX_SBA_ORDER ) * ( IVAS_MAX_SBA_ORDER )) + 2) /* HOA2 + pHOA3*/ -#define IVAS_HBR_MAX_DECOR_CHS (2) +#define IVAS_HBR_MAX_DECOR_CHS 2 #define IVAS_SPAR_MAX_FB_IN_CHAN 11 #define IVAS_SPAR_P_LOWERTRI ((IVAS_SPAR_MAX_CH - 1) * (IVAS_SPAR_MAX_CH - 2)) >> 1 #define IVAS_SPAR_MAX_C_COEFF (IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS) * ( IVAS_SPAR_MAX_DMX_CHS - 1) -#define IVAS_SPAR_HOA3_NP_CHS 8 /* number of higher order non-planar channels */ - #define SPAR_NUM_CODING_STRAT_BITS 3 /* AGC constants */ @@ -1009,8 +1007,8 @@ typedef enum #define IVAS_ACTIVEW_DM_F_SCALE_VLBR 0.25f #define IVAS_SPAR_FOA_DFLT_FREQ_PER_CHAN 24000 -#define IVAS_SPAR_DYN_ACTIVEW_THRESH (0.0039f) -#define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH (32.0f) +#define IVAS_SPAR_DYN_ACTIVEW_THRESH 0.0039f +#define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH 32.0f #define MAX_QUANT_STRATS 3 #define MAX_CODING_STRATS 3 @@ -1069,21 +1067,13 @@ enum #define IVAS_DECORR_PARM_APD_TAU 20e-3f /* IVAS SBA PCA */ -#define IVAS_PCA_NB_SUBR 20 /* 80 -> 0.25 ms, 40 -> 0.5 ms... */ -#define IVAS_PCA_COV_THRES 3e-5f -#define IVAS_PCA_QUAT_EPS 1e-7f #define IVAS_PCA_QBITS 19 #define IVAS_PCA_N1 91 -#define IVAS_PCA_N1_EQ ( (IVAS_PCA_N1-1)/2 ) -#define IVAS_PCA_BIT_LEN ( 1 + ( IVAS_PCA_QBITS - 1 + IVAS_PCA_QBITS ) ) #define IVAS_PCA_INTERP 4 #define IVAS_PCA_N_SLOTS 40 #define IVAS_PCA_LEN_INTERP_Q ( IVAS_PCA_INTERP * IVAS_PCA_N_SLOTS ) #define IVAS_PCA_DELAY_CMP 24 #define IVAS_PCA_LEN_INTERP_EIG_DEC ( (IVAS_PCA_N_SLOTS+IVAS_PCA_DELAY_CMP)*16) -#define IVAS_PCA_THRES_MIN_DOT 0.8f -#define IVAS_PCA_THRES_MIN_DOT2 0.0f -#define IVAS_PCA_THRES_DIST_ALT 6.0f typedef enum { @@ -1216,7 +1206,6 @@ enum #define OMASA_STEREO_SW_CNT_MAX 100 #define MASA_BIT_REDUCT_PARAM 10 #define MASA_MAXIMUM_TWO_DIR_BANDS 24 -#define NBITS_HR_COH 4 #define MASA_JBM_RINGBUFFER_FRAMES 3 @@ -1540,9 +1529,14 @@ typedef enum * Split Binaural Rendering Constants *----------------------------------------------------------------------------------*/ -#ifdef SPLIT_REND_WITH_HEAD_ROT +#define SPLIT_REND_256k 256000 +#define SPLIT_REND_320k 320000 +#define SPLIT_REND_384k 384000 +#define SPLIT_REND_512k 512000 +#define SPLIT_REND_768k 768000 +#define SPLIT_REND_MAX_BRATE SPLIT_REND_768k + #define CLDFB_PLC_XF 2 /* Length of cross-fade into first good frame after frame loss in CLDFB cols. */ -#endif #define SPLIT_REND_DECOR_ALPHA 0.25f @@ -1796,19 +1790,6 @@ typedef enum #define QUANT_STRAT_0 0 #define QUANT_STRAT_2 2 -#ifdef SPLIT_REND_WITH_HEAD_ROT -/*----------------------------------------------------------------------------------* - * Split rendering bitrate constants - *----------------------------------------------------------------------------------*/ - -#define SPLIT_REND_256k 256000 -#define SPLIT_REND_320k 320000 -#define SPLIT_REND_384k 384000 -#define SPLIT_REND_512k 512000 -#define SPLIT_REND_768k 768000 -#define SPLIT_REND_MAX_BRATE SPLIT_REND_768k - -#endif /*----------------------------------------------------------------------------------* * Limiter constants diff --git a/lib_com/ivas_entropy_coder_common.c b/lib_com/ivas_entropy_coder_common.c index a2fa26cad9..1d42c5f6a1 100644 --- a/lib_com/ivas_entropy_coder_common.c +++ b/lib_com/ivas_entropy_coder_common.c @@ -78,7 +78,7 @@ void ivas_wrap_arround( * get cumulative frequency model *-----------------------------------------------------------------------------------------*/ -void ivas_get_cum_freq_model( +static void ivas_get_cum_freq_model( const int16_t *pFreq_model, const int16_t length, int16_t *pCum_freq_model ) @@ -102,7 +102,7 @@ void ivas_get_cum_freq_model( * Map the ivas_arith_pred_r_consts and ivas_huff_pred_r_consts tables *-----------------------------------------------------------------------------------------*/ -int16_t ivas_map_num_pred_r_to_idx( +static int16_t ivas_map_num_pred_r_to_idx( const int16_t num_quant_points_pred_r, const int16_t active_w_flag ) { @@ -160,7 +160,7 @@ int16_t ivas_map_num_pred_r_to_idx( * Map the ivas_arith_drct_r_consts and ivas_huff_drct_r_consts tables *-----------------------------------------------------------------------------------------*/ -int16_t ivas_map_num_drct_r_to_idx( +static int16_t ivas_map_num_drct_r_to_idx( const int16_t num_quant_points_drct_r ) { int16_t drct_r_to_idx = -1; @@ -182,6 +182,7 @@ int16_t ivas_map_num_drct_r_to_idx( assert( !"Forbidden value for DRCT quantization strategy index" ); break; } + return drct_r_to_idx; } @@ -192,7 +193,7 @@ int16_t ivas_map_num_drct_r_to_idx( * Map the ivas_arith_decd_r_consts and ivas_huff_decd_r_consts tables *-----------------------------------------------------------------------------------------*/ -int16_t ivas_map_num_decd_r_to_idx( +static int16_t ivas_map_num_decd_r_to_idx( const int16_t num_quant_points_decd_r ) { int16_t decd_r_to_idx = -1; diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index 3ec4656a9e..678effe501 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -491,11 +491,11 @@ int16_t ism_quant_meta( /*! r: dequantized value */ float ism_dequant_meta( - const int16_t idx, /* i : quantizer index */ - const float borders[], /* i : level borders */ - const float q_step, /* i : quantization step */ - const float q_step_border, /* i : quantization step at the border */ - const int16_t cbsize /* i : codebook size */ + const int16_t idx, /* i : quantizer index */ + const float borders[], /* i : level borders */ + const float q_step, /* i : quantization step */ + const float q_step_border, /* i : quantization step at the border */ + const int16_t cbsize /* i : codebook size */ ) { int16_t idx_start; diff --git a/lib_com/ivas_pca_tools.c b/lib_com/ivas_pca_tools.c index a1f8efd629..8ae62d98e4 100644 --- a/lib_com/ivas_pca_tools.c +++ b/lib_com/ivas_pca_tools.c @@ -44,6 +44,14 @@ #include "prot.h" +/*-----------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------*/ + +#define IVAS_PCA_QUAT_EPS 1e-7f +#define IVAS_PCA_N1_EQ ( ( IVAS_PCA_N1 - 1 ) / 2 ) + + /*---------------------------------------------------------------------* * eye_matrix() * diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 1cbac362b6..73cd09d20d 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -248,7 +248,7 @@ ivas_error ivas_compute_core_buffers( /*! r: number of clipped samples */ uint32_t ivas_syn_output( - float *synth[], /* i/o: float synthesis signal */ + float *synth[], /* i/o: float synthesis signal */ const int16_t output_frame, /* i : output frame length (one channel) */ const int16_t n_channels, /* i : number of output channels */ int16_t *synth_out /* o : integer 16 bits synthesis signal */ @@ -1057,7 +1057,7 @@ void ivas_param_ism_enc_close( ); void ivas_ism_metadata_close( - ISM_METADATA_HANDLE hIsmMetaData[], /* i/o : object metadata handles */ + ISM_METADATA_HANDLE hIsmMetaData[], /* i/o: object metadata handles */ const int16_t first_idx /* i : index of first handle to deallocate */ ); @@ -3657,7 +3657,7 @@ ivas_error ivas_dirac_sba_config( ivas_error ivas_dirac_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_configopen /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + const DIRAC_CONFIG_FLAG flag_configopen /* i : Flag determining if we open or reconfigure the DirAC decoder */ ); void ivas_dirac_dec_close( @@ -4159,7 +4159,7 @@ ivas_error ivas_sba_linear_renderer( float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t output_frame, /* i : output frame length per channel */ const int16_t nchan_in, /* i : number of input ambisonics channels */ - const int16_t nchan_ism, /* i : number of objects */ + const int16_t nchan_ism, /* i : number of objects */ const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup /* i : output format setup */ ); @@ -4276,7 +4276,7 @@ int16_t ivas_get_sba_num_TCs( void ivas_spar_set_bitrate_config( ivas_spar_md_com_cfg *pSpar_md_cfg, /* i/o: SPAR MD config. handle */ const int16_t table_idx, /* i : config. table index */ - const int16_t num_bands, /* i : number of bands */ + const int16_t num_bands, /* i : number of bands */ const int16_t dirac2spar_md_flag, const int16_t enc_flag, const int16_t pca_flag, @@ -4575,7 +4575,7 @@ ivas_error ivas_spar_covar_enc_open( const int32_t input_Fs, /* i : input sampling rate */ const int16_t nchan_inp, /* i : number of input channels */ const COV_SMOOTHING_TYPE smooth_mode, /* i : Smooth covariance for SPAR or MC */ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); void ivas_spar_covar_enc_close( @@ -4902,25 +4902,6 @@ void ivas_wrap_arround( const int16_t length ); -void ivas_get_cum_freq_model( - const int16_t *pFreq_model, - const int16_t length, - int16_t *pCum_freq_model -); - -int16_t ivas_map_num_pred_r_to_idx( - const int16_t num_quant_points_pred_r, - const int16_t active_w_flag -); - -int16_t ivas_map_num_drct_r_to_idx( - const int16_t num_quant_points_drct_r -); - -int16_t ivas_map_num_decd_r_to_idx( - const int16_t num_quant_points_decd_r -); - /* Quantization utilities */ void ivas_quantise_real_values( const float *values, @@ -5566,7 +5547,7 @@ ivas_error ivas_mono_dmx_renderer_open( void ivas_mono_dmx_renderer_close( - MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ + MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/o: Mono downmix structure */ ); void ivas_mono_downmix_render_passive( diff --git a/lib_com/prot.h b/lib_com/prot.h index d3884cbf4f..97204f8b9a 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -717,13 +717,14 @@ int16_t lev_dur( /*! r: delay value in ns */ int32_t get_delay( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t io_fs, /* i : input/output sampling frequency */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ + const int16_t enc_dec, /* i : encoder/decoder flag */ + const int32_t io_fs, /* i : input/output sampling frequency */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ #ifdef SPLIT_REND_WITH_HEAD_ROT - , + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ const AUDIO_CONFIG output_config /* i : decoder output config */ +#else + HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ #endif ); diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 05c81f91ed..29d5be3278 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -42,10 +42,6 @@ #include "ivas_rom_dec.h" #include "ivas_rom_com.h" #include "ivas_rom_binauralRenderer.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT -#include "ivas_rom_dec.h" -#include "lib_rend.h" -#endif #ifdef DEBUGGING #include "debug.h" #endif @@ -369,7 +365,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } } -#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif /* set memories */ for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) @@ -1832,7 +1828,6 @@ void ivas_binaural_cldfb_sf( idx_in++; } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hSplitBinRend.hCldfbDataOut != NULL ) { for ( ch = 0; ch < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ); ch++ ) @@ -1842,7 +1837,6 @@ void ivas_binaural_cldfb_sf( } st_ivas->hSplitBinRend.hCldfbDataOut->config = st_ivas->hIntSetup.output_config; } -#endif } #endif } diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index bef9fa9b8d..5feb94b490 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -52,12 +52,12 @@ *--------------------------------------------------------------------------*/ ivas_error ivas_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef SPLIT_REND_WITH_HEAD_ROT const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ) { @@ -1090,17 +1090,10 @@ ivas_error ivas_dec( switch ( pcm_resolution ) { case PCM_INT16: -#endif #ifdef DEBUGGING st_ivas->noClipping += #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_syn_output( p_output, output_frame, nchan_out_syn_output, (int16_t *) data ); -#else - ivas_syn_output( p_output, output_frame, nchan_out, data ); -#endif - -#ifdef SPLIT_REND_WITH_HEAD_ROT break; case PCM_FLOAT32: ivas_syn_output_f( p_output, output_frame, nchan_out_syn_output, (float *) data ); @@ -1109,6 +1102,11 @@ ivas_error ivas_dec( error = IVAS_ERR_UNKNOWN; break; } +#else +#ifdef DEBUGGING + st_ivas->noClipping += +#endif + ivas_syn_output( p_output, output_frame, nchan_out, data ); #endif /*----------------------------------------------------------------* diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 876ae9130d..fb9879ede8 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -52,8 +52,8 @@ *-----------------------------------------------------------------------*/ static ivas_error ivas_dirac_dec_config_internal( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_config_inp /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const DIRAC_CONFIG_FLAG flag_config_inp /* i : Flag determining if we open or reconfigure the DirAC decoder */ ) { DIRAC_DEC_HANDLE hDirAC; @@ -109,8 +109,8 @@ static ivas_error ivas_dirac_dec_config_internal( static ivas_error ivas_dirac_rend_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const DIRAC_CONFIG_FLAG flag_config_inp, /* i : Flag determining if we open or reconfigure the DirAC decoder */ const int16_t dec_param_estim_old ) { DIRAC_DEC_HANDLE hDirAC; @@ -749,8 +749,8 @@ static ivas_error ivas_dirac_rend_config( *-------------------------------------------------------------------------*/ ivas_error ivas_dirac_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_config_inp /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const DIRAC_CONFIG_FLAG flag_config_inp /* i : Flag determining if we open or reconfigure the DirAC decoder */ ) { ivas_error error; @@ -925,11 +925,10 @@ ivas_error ivas_dirac_dec_config( ivas_dirac_dec_get_frequency_axis( frequency_axis, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSpatParamRendCom->num_freq_bands ); #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, + if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, DIRAC_SYNTHESIS_PSD_LS, frequency_axis, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, + if ( ( error = ivas_dirac_dec_decorr_open( &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, DIRAC_SYNTHESIS_PSD_LS, frequency_axis, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif - DIRAC_SYNTHESIS_PSD_LS, frequency_axis, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 7ed132c87b..cdba09af5b 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -37,9 +37,6 @@ #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "prot.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT -#include "common_api_types.h" -#endif #include #include #include @@ -74,9 +71,6 @@ static ivas_error ivas_dec_reconfig_split_rend( ivas_error error; int16_t cldfb_in_flag, num_ch, ch, isCldfbNeeded, i, pcm_out_flag; SPLIT_REND_WRAPPER *hSplitRendWrapper; -#ifndef SPLIT_REND_WITH_HEAD_ROT - CLDFB_TYPE cldfbMode; -#endif hSplitRendWrapper = &st_ivas->hSplitBinRend.splitrend; pcm_out_flag = ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0; @@ -92,38 +86,25 @@ static ivas_error ivas_dec_reconfig_split_rend( ivas_renderSplitGetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &hSplitRendWrapper->multiBinPoseData, st_ivas->hHeadTrackData->sr_pose_pred_axis ); - isCldfbNeeded = 0; -#ifndef SPLIT_REND_WITH_HEAD_ROT - cldfbMode = CLDFB_ANALYSIS; -#else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) { cldfb_in_flag = 0; } -#endif + isCldfbNeeded = 0; if ( st_ivas->renderer_type != RENDERER_DISABLE ) { if ( cldfb_in_flag == 0 ) { isCldfbNeeded = 1; -#ifndef SPLIT_REND_WITH_HEAD_ROT - cldfbMode = CLDFB_ANALYSIS; -#endif } else if ( st_ivas->hRenderConfig->split_rend_config.codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) { isCldfbNeeded = 1; -#ifndef SPLIT_REND_WITH_HEAD_ROT - cldfbMode = CLDFB_SYNTHESIS; -#endif } else if ( pcm_out_flag && cldfb_in_flag ) { isCldfbNeeded = 1; -#ifndef SPLIT_REND_WITH_HEAD_ROT - cldfbMode = CLDFB_SYNTHESIS; -#endif } } @@ -144,18 +125,13 @@ static ivas_error ivas_dec_reconfig_split_rend( for ( ch = 0; ch < num_ch; ch++ ) { -#ifndef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), cldfbMode, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) -#else if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) -#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not open CLDFB handles\n" ) ); } } -#ifdef SPLIT_REND_WITH_HEAD_ROT for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) @@ -163,7 +139,6 @@ static ivas_error ivas_dec_reconfig_split_rend( return error; } } -#endif } else if ( isCldfbNeeded == 0 && hSplitRendWrapper->hCldfbHandles != NULL ) { @@ -177,7 +152,6 @@ static ivas_error ivas_dec_reconfig_split_rend( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { if ( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] != NULL ) @@ -186,18 +160,12 @@ static ivas_error ivas_dec_reconfig_split_rend( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; } } -#endif free( hSplitRendWrapper->hCldfbHandles ); hSplitRendWrapper->hCldfbHandles = NULL; } -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) && - ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) ) -#else - if ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) -#endif + if ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV || st_ivas->ivas_format != SBA_ISM_FORMAT ) ) { for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { @@ -252,12 +220,10 @@ static ivas_error ivas_dec_init_split_rend( return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ivas_format == SBA_ISM_FORMAT ) { cldfb_in_flag = 0; } -#endif #ifdef NONBE_UNIFIED_DECODING_PATHS error = ivas_split_renderer_open( &st_ivas->hSplitBinRend.splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_framesize == IVAS_RENDER_FRAMESIZE_5MS ); @@ -410,7 +376,6 @@ ivas_error ivas_dec_setup( } else { - #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) #else @@ -1086,11 +1051,11 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Binaural Renderer configuration handle *--------------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif - ) { if ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) { @@ -1949,7 +1914,6 @@ ivas_error ivas_init_decoder( return error; } } - /* ParamISM is handled separately from other common config */ else if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) { diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 7d22eb50ba..0064df713c 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -183,11 +183,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* Deallocate the ParamISM struct */ ivas_param_ism_dec_close( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); - if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif - ) { /* close the parametric binaural renderer */ #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -254,11 +254,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( return error; } - if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif - ) { /* open the parametric binaural renderer */ if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) @@ -444,11 +444,11 @@ ivas_error ivas_ism_dec_config( { if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) { - if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } @@ -471,11 +471,11 @@ ivas_error ivas_ism_dec_config( /* ISM mode switching */ if ( st_ivas->ism_mode != last_ism_mode ) { - if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, #ifdef SPLIT_REND_WITH_HEAD_ROT - pcm_resolution, + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - data ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index d355798f6d..9932d3083e 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -50,8 +50,8 @@ *-----------------------------------------------------------------------*/ static void ivas_param_ism_dec_dequant_DOA( - PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ - const int16_t nchan_ism /* i : number of ISM channels */ + PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ + const int16_t nchan_ism /* i : number of ISM channels */ ) { int16_t i; @@ -149,7 +149,6 @@ static void ivas_ism_get_proto_matrix( } break; } - default: assert( 0 && "Error: number of transport channels not supported" ); } @@ -191,9 +190,9 @@ static void ivas_param_ism_collect_slot( static void ivas_param_ism_compute_mixing_matrix( - const int16_t nchan_ism, /* i : number of ISM channels */ - PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ - ISM_DTX_DATA_DEC hISMDTX, /* i : ISM DTX handle */ + const int16_t nchan_ism, /* i : number of ISM channels */ + PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ + ISM_DTX_DATA_DEC hISMDTX, /* i : ISM DTX handle */ float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN], const int16_t nchan_transport, const int16_t nchan_out_woLFE, @@ -454,7 +453,6 @@ ivas_error ivas_param_ism_dec_open( ivas_error error; error = IVAS_ERR_OK; - push_wmops( "ivas_param_ism_dec_open" ); /*-----------------------------------------------------------------* @@ -776,7 +774,6 @@ void ivas_param_ism_dec( PARAM_ISM_DEC_HANDLE hParamIsmDec; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - IVAS_OUTPUT_SETUP hSetup; /* Initialization */ @@ -804,9 +801,7 @@ void ivas_param_ism_dec( } ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - hSetup = st_ivas->hIntSetup; - push_wmops( "ivas_param_ism_dec" ); /* set buffers to zero */ @@ -924,8 +919,7 @@ void ivas_param_ism_dec( /* Compute bandwise rendering to target LS using covariance rendering */ ivas_param_ism_rendering( hParamIsmDec, hSpatParamRendCom, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, - Cldfb_RealBuffer, Cldfb_ImagBuffer, mixing_matrix, slot_idx, index_slot, - nchan_out_woLFE, nchan_transport ); + Cldfb_RealBuffer, Cldfb_ImagBuffer, mixing_matrix, slot_idx, index_slot, nchan_out_woLFE, nchan_transport ); } /* CLDFB Synthesis */ @@ -1135,7 +1129,6 @@ void ivas_param_ism_dec_digest_tc( } push_wmops( "ivas_param_ism_dec" ); - /* general setup */ ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator ); @@ -1232,7 +1225,6 @@ void ivas_param_ism_dec_digest_tc( if ( st_ivas->hDecoderConfig->Opt_tsm ) #endif { - float RealBuffer[CLDFB_NO_CHANNELS_MAX]; float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; @@ -1255,7 +1247,6 @@ void ivas_param_ism_dec_digest_tc( ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin ); pop_wmops(); - return; } @@ -1272,7 +1263,6 @@ void ivas_ism_param_dec_tc_gain_ajust( const uint16_t nFadeLength, /* i : length of the crossfade in samples */ float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ ) - { int16_t i; float gain, ene_tc, ene_sum, grad; @@ -1288,10 +1278,12 @@ void ivas_ism_param_dec_tc_gain_ajust( ene_sum += ( transport_channels_f[0][i] + transport_channels_f[1][i] ) * ( transport_channels_f[0][i] + transport_channels_f[1][i] ); /* (L+R)*(L+R) */ } gain = sqrtf( ene_tc / ( ene_sum + EPSILON ) ); + if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 ) { /* Smoothing */ gain = 0.75f * gain + 0.25f * last_gain; + /* 10ms ramp */ grad = ( gain - last_gain ) / (float) nFadeLength; /* slope between two consecutive gains, 480 samples length */ for ( i = 0; i < ( nFadeLength ); i++ ) @@ -1540,7 +1532,6 @@ void ivas_param_ism_params_to_masa_param_mapping( hParamIsmDec = st_ivas->hParamIsmDec; hSpatParamRendCom = st_ivas->hSpatParamRendCom; nBins = hSpatParamRendCom->num_freq_bands; - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; if ( !( ivas_total_brate == IVAS_SID_5k2 || ivas_total_brate == FRAME_NO_DATA ) ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 3e91dce044..72ef52eb1f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -844,9 +844,9 @@ void ivas_jbm_dec_feed_tc_to_renderer( ( #endif st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL #ifdef SPLIT_REND_WITH_HEAD_ROT ) && @@ -1068,9 +1068,9 @@ ivas_error ivas_jbm_dec_render( { if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { - return error; - } + return error; } + } else { #endif @@ -1298,7 +1298,7 @@ ivas_error ivas_jbm_dec_render( #endif #if ( defined NONBE_UNIFIED_DECODING_PATHS && defined SPLIT_REND_WITH_HEAD_ROT ) - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, @@ -1306,13 +1306,13 @@ ivas_error ivas_jbm_dec_render( #endif - { - return error; - } + { + return error; + } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); #ifdef SPLIT_REND_WITH_HEAD_ROT - } + } #endif } else if ( st_ivas->renderer_type == RENDERER_MC ) @@ -1331,8 +1331,8 @@ ivas_error ivas_jbm_dec_render( { if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { - return error; - } + return error; + } } else { @@ -1342,11 +1342,11 @@ ivas_error ivas_jbm_dec_render( return error; } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); #ifdef SPLIT_REND_WITH_HEAD_ROT - } -#endif } +#endif + } } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { @@ -1384,8 +1384,8 @@ ivas_error ivas_jbm_dec_render( { if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { - return error; - } + return error; + } } else { @@ -1395,11 +1395,11 @@ ivas_error ivas_jbm_dec_render( return error; } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); #ifdef SPLIT_REND_WITH_HEAD_ROT - } -#endif } +#endif + } } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { @@ -1504,17 +1504,10 @@ ivas_error ivas_jbm_dec_render( switch ( pcm_resolution ) { case PCM_INT16: -#endif #ifdef DEBUGGING st_ivas->noClipping += #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_syn_output( p_output, *nSamplesRendered, nchan_out_syn_output, (int16_t *) data ); -#else - ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); -#endif - -#ifdef SPLIT_REND_WITH_HEAD_ROT break; case PCM_FLOAT32: ivas_syn_output_f( p_output, *nSamplesRendered, nchan_out_syn_output, (float *) data ); @@ -1523,6 +1516,11 @@ ivas_error ivas_jbm_dec_render( error = IVAS_ERR_UNKNOWN; break; } +#else +#ifdef DEBUGGING + st_ivas->noClipping += +#endif + ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); #endif *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; @@ -1788,17 +1786,10 @@ ivas_error ivas_jbm_dec_flush_renderer( switch ( pcm_resolution ) { case PCM_INT16: -#endif #ifdef DEBUGGING st_ivas->noClipping += #endif - ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, -#ifdef SPLIT_REND_WITH_HEAD_ROT - (int16_t *) -#endif - data ); - -#ifdef SPLIT_REND_WITH_HEAD_ROT + ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) data ); break; case PCM_FLOAT32: ivas_syn_output_f( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (float *) data ); @@ -1807,6 +1798,11 @@ ivas_error ivas_jbm_dec_flush_renderer( error = IVAS_ERR_UNKNOWN; break; } +#else +#ifdef DEBUGGING + st_ivas->noClipping += +#endif + ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, data ); #endif return IVAS_ERR_OK; @@ -2501,27 +2497,27 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( else { #endif - if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); - } - set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } + set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); - offset = 0; - for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_full; - } - for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_residual; - } - for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = NULL; - } + offset = 0; + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_full; + } + for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_residual; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } #ifdef NONBE_UNIFIED_DECODING_PATHS } #endif diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index a160275ea9..93a11500f1 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1411,6 +1411,7 @@ ivas_error ivas_masa_dec_reconfigure( /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDiracDecBin[0] != NULL ) #else diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index d11e846a84..ed3d99e690 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -33,9 +33,6 @@ #include #include "options.h" #include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" @@ -46,11 +43,8 @@ #ifdef DEBUGGING #include "debug.h" #endif -#ifdef DEBUG_PLOT -#include "deb_out.h" -#endif #include "wmc_auto.h" -#include "rom_dec.h" + /*-----------------------------------------------------------------------* * Local constants @@ -974,7 +968,6 @@ ivas_error ivas_param_mc_dec_reconfig( set_zero( hParamMC->proto_frame_f, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands ); } - #ifdef NONBE_UNIFIED_DECODING_PATHS if ( nchan_transport_old != nchan_transport ) { @@ -1043,6 +1036,7 @@ ivas_error ivas_param_mc_dec_reconfig( } } #endif + return error; } diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index fe93a65ee7..f27e803ced 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -33,14 +33,12 @@ #include #include "options.h" #include -#include "cnst.h" #include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" -#include "math.h" #ifdef DEBUGGING #include "debug.h" #endif @@ -48,7 +46,6 @@ #include "deb_out.h" #endif #include "wmc_auto.h" -#include "rom_dec.h" /*-----------------------------------------------------------------------* @@ -332,8 +329,6 @@ void ivas_mc_paramupmix_dec( /*LFE handling for split rendering cases*/ if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { - -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hSplitBinRend.hCldfbDataOut != NULL ) { for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) @@ -346,7 +341,6 @@ void ivas_mc_paramupmix_dec( } st_ivas->hSplitBinRend.hCldfbDataOut->config = st_ivas->hIntSetup.output_config; } -#endif } #endif diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 167d8b6727..934b1184bb 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -708,13 +708,13 @@ ivas_error ivas_mc_dec_config( *-------------------------------------------------------------------------*/ static ivas_error ivas_mc_dec_reconfig( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t *nSamplesRendered, /* o : number of samples flushed from the last frame (JBM) */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ) { @@ -1186,11 +1186,11 @@ static ivas_error ivas_mc_dec_reconfig( output_config = st_ivas->hDecoderConfig->output_config; /* binaural renderers*/ - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif - ) { /* remove unneeded binaural renderers */ if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) ) diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 0936209639..bad46026c0 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -83,7 +83,7 @@ ivas_error ivas_mono_dmx_renderer_open( *-------------------------------------------------------------------------*/ void ivas_mono_dmx_renderer_close( - MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ + MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/o: Mono downmix structure */ ) { if ( hMonoDmxRenderer == NULL || *hMonoDmxRenderer == NULL ) diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 16f7462ef7..009b336534 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -150,13 +150,13 @@ void ivas_omasa_data_close( *--------------------------------------------------------------------------*/ ivas_error ivas_omasa_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ - void *data /* o : output synthesis signal */ + const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */ + void *data /* o : output synthesis signal */ #else - int16_t *data /* o : output synthesis signal */ + int16_t *data /* o : output synthesis signal */ #endif ) { diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 15d185efa0..48833eb0f6 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -34,9 +34,6 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT -#include "ivas_prot_rend.h" -#endif #include "ivas_stat_dec.h" #ifdef DEBUGGING #include "debug.h" @@ -59,7 +56,6 @@ void ivas_renderer_select( AUDIO_CONFIG *internal_config; AUDIO_CONFIG output_config; AUDIO_CONFIG transport_config; - int16_t nchan_internal; renderer_type = &( st_ivas->renderer_type ); @@ -79,11 +75,11 @@ void ivas_renderer_select( st_ivas->hCombinedOrientationData->shd_rot_max_order = -1; } - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif - ) { if ( st_ivas->ivas_format == ISM_FORMAT ) { @@ -104,11 +100,11 @@ void ivas_renderer_select( } else /* ISM_MODE_DISC */ { - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif - ) { #ifdef DEBUGGING if ( st_ivas->hDecoderConfig->force_rend == FORCE_CLDFB_RENDERER ) @@ -160,11 +156,11 @@ void ivas_renderer_select( { *internal_config = IVAS_AUDIO_CONFIG_HOA3; - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif - ) { *renderer_type = RENDERER_BINAURAL_FASTCONV; } @@ -180,7 +176,6 @@ void ivas_renderer_select( if ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { - nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); if ( nchan_internal == 2 ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 82ca41a271..9108dc19ee 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -204,11 +204,11 @@ ivas_error ivas_sba_dec_reconfigure( } else { - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif - ) { renderer_type_new = RENDERER_BINAURAL_FASTCONV; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 0237a059a5..4d1d98b3a7 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1806,11 +1806,11 @@ void ivas_spar_dec_upmixer_sf( } else { - if ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) && +#else + if ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && #endif - ) ) && !( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) { for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 5abb39cd86..f609470a96 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -960,16 +960,16 @@ static ivas_error _GetSamples( #endif ivas_error IVAS_DEC_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf, /* o : output synthesis signal */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ #else 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 */ #endif - int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ - bool *needNewFrame /* o :indication that the decoder needs a new frame */ + int16_t *nOutSamples, /* o : number of samples per channel written to output buffer */ + bool *needNewFrame /* o : indication that the decoder needs a new frame */ ) { ivas_error error; diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 38508a70f0..815bbe65ed 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -206,7 +206,6 @@ ivas_error ivas_cpe_enc( return error; } - /*----------------------------------------------------------------* * Set TD stereo parameters *----------------------------------------------------------------*/ @@ -393,9 +392,7 @@ ivas_error ivas_cpe_enc( else if ( hCPE->element_mode == IVAS_CPE_TD ) { /* Determine the energy ratio between the 2 channels */ - tdm_ratio_idx = stereo_tdm_ener_analysis( - ivas_format, - hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); + tdm_ratio_idx = stereo_tdm_ener_analysis( ivas_format, hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Compute the downmix signal based on the ratio index */ stereo_tdm_downmix( hCPE->hStereoTD, sts[0]->input, sts[1]->input, input_frame, tdm_ratio_idx, ( ( hCPE->hStereoTD->tdm_LRTD_flag == 0 ) ? tdm_SM_or_LRTD_Pri : 0 ), tdm_ratio_idx_SM ); diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 6492c537ad..56e5506ce0 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -176,7 +176,7 @@ static void ivas_param_ism_compute_obj_parameters( static void ivas_param_ism_enc_quantize_DOA( - const int16_t nchan_ism, /* i : number of ISM channels */ + const int16_t nchan_ism, /* i : number of ISM channels */ ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS], /* i : ISM metadata */ PARAM_ISM_CONFIG_HANDLE hParamIsm /* i/o: Param ISM encoder handle */ ) @@ -184,7 +184,6 @@ static void ivas_param_ism_enc_quantize_DOA( int16_t i, azi_idx, ele_idx; float valQ; - /* Loop over objects */ for ( i = 0; i < nchan_ism; i++ ) { @@ -226,7 +225,6 @@ void ivas_param_ism_stereo_dmx( float last_dmx_gain; float last_cardioid_left; ISM_METADATA_HANDLE hIsmMetaData; - push_wmops( "ivas_param_ism_st_dmx" ); /*Initialization*/ @@ -297,10 +295,13 @@ void ivas_param_ism_stereo_dmx( ene_dmx += stereo_dmx[0][j] * stereo_dmx[0][j] + stereo_dmx[1][j] * stereo_dmx[1][j]; } dmx_gain = sqrtf( ene_data / ( ene_dmx + EPSILON ) ); + /* Smoothing */ if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 ) { + /* Smoothing */ dmx_gain = 0.75f * dmx_gain + 0.25f * last_dmx_gain; + /* 10ms ramp */ grad = ( dmx_gain - last_dmx_gain ) * 2.0f / (float) input_frame; /* slope between two consecutive gains, 480 samples length */ for ( i = 0; i < ( input_frame / 2 ); i++ ) @@ -329,7 +330,6 @@ void ivas_param_ism_stereo_dmx( mvr2r( stereo_dmx[1], data[1], input_frame ); pop_wmops(); - return; } @@ -351,9 +351,6 @@ ivas_error ivas_param_ism_enc_open( int32_t input_Fs; ivas_error error; - error = IVAS_ERR_OK; - - /* Assign memory to Param Object handle */ if ( ( hParamIsm = (PARAM_ISM_CONFIG_HANDLE) malloc( sizeof( PARAM_ISM_CONFIG_DATA ) ) ) == NULL ) { @@ -362,7 +359,6 @@ ivas_error ivas_param_ism_enc_open( input_Fs = st_ivas->hEncoderConfig->input_Fs; - /* set FB config. */ if ( ( error = ivas_fb_set_cfg( &fb_cfg, ISM_FORMAT, st_ivas->hEncoderConfig->nchan_inp, 0, 0, input_Fs, 0 ) ) != IVAS_ERR_OK ) { @@ -394,7 +390,7 @@ ivas_error ivas_param_ism_enc_open( st_ivas->hParamIsm = hParamIsm; - return error; + return IVAS_ERR_OK; } @@ -405,8 +401,8 @@ ivas_error ivas_param_ism_enc_open( *-------------------------------------------------------------------------*/ void ivas_param_ism_enc_close( - PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */ - const int32_t input_Fs /* i : input sampling_rate */ + PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */ + const int32_t input_Fs /* i : input sampling_rate */ ) { if ( hParamIsm == NULL || *hParamIsm == NULL ) @@ -448,7 +444,6 @@ void ivas_param_ism_enc( nchan_ism = st_ivas->hEncoderConfig->nchan_ism; hParamIsm = st_ivas->hParamIsm; - push_wmops( "ivas_param_ism_enc" ); l_ts = input_frame / PARAM_ISM_MDFT_NO_SLOTS; diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index feff99a7d2..6f1b14162c 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -1983,6 +1983,7 @@ void ivas_masa_enc_reconfigure( copy_encoder_config( st_ivas, st_ivas->hCPE[cpe_id]->hCoreCoder[n], 0 ); st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ } + #ifdef FIX_863_REMOVE_REDUNDANCIES_OMASA if ( ivas_total_brate - ism_total_brate < MIN_BRATE_MDCT_STEREO ) #else diff --git a/lib_enc/ivas_pca_enc.c b/lib_enc/ivas_pca_enc.c index f8b4c8e9a6..84b5b6d72a 100644 --- a/lib_enc/ivas_pca_enc.c +++ b/lib_enc/ivas_pca_enc.c @@ -47,6 +47,11 @@ * Local constants *-----------------------------------------------------------------------*/ +#define IVAS_PCA_COV_THRES 3e-5f +#define IVAS_PCA_THRES_MIN_DOT 0.8f +#define IVAS_PCA_THRES_MIN_DOT2 0.0f +#define IVAS_PCA_THRES_DIST_ALT 6.0f + #define IVAS_PCA_SM_FAC 0.0234375f #define IVAS_PCA_N_ITER_QR 10 diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index 5f77e70cbd..ade50059c5 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -124,6 +124,7 @@ int16_t select_stereo_mode( { stereo_switching_flag = 0; } + #ifdef FIX_863_REMOVE_REDUNDANCIES_OMASA if ( hCPE->element_brate >= MIN_BRATE_MDCT_STEREO ) #else @@ -139,7 +140,6 @@ int16_t select_stereo_mode( hStereoClassif->lrtd_mode = 0; element_mode = IVAS_CPE_DFT; - #ifdef NONBE_FIX_861_MASA_CRASH_STEREO_SWITCHING if ( stereo_switching_flag == 1 && hCPE->element_brate > IVAS_13k2 && hCPE->hCoreCoder[0]->hSpMusClas->past_dlp[0] < 1.0f && hCPE->hCoreCoder[0]->hSpMusClas->wdlp_xtalk < -0.01f && hCPE->hCoreCoder[0]->vad_flag == 1 && ( hCPE->hStereoMdct->sw_uncorr || hStereoClassif->xtalk_decision ) ) #else diff --git a/lib_enc/q_gain2p.c b/lib_enc/q_gain2p.c index 9c89b44c87..bfffbef707 100644 --- a/lib_enc/q_gain2p.c +++ b/lib_enc/q_gain2p.c @@ -237,13 +237,13 @@ int16_t Mode2_gain_enc_mless( *---------------------------------------------------------------------*/ static int16_t gain_enc_uv( - const float *code, /* i : algebraic excitation */ - const int16_t lcode, /* i ) : Subframe size */ - float *gain_pit, /* o : quantized pitch gain */ - float *gain_code, /* o : quantized codebook gain */ - ACELP_CbkCorr *coeff, /* i/o : correlations , -2,, -2 and 2 */ - float *past_gcode, /* i/o : past gain of code */ - float *gain_inov /* o : unscaled innovation gain */ + const float *code, /* i : algebraic excitation */ + const int16_t lcode, /* i : Subframe size */ + float *gain_pit, /* o : quantized pitch gain */ + float *gain_code, /* o : quantized codebook gain */ + ACELP_CbkCorr *coeff, /* i/o: correlations , -2,, -2 and 2 */ + float *past_gcode, /* i/o: past gain of code */ + float *gain_inov /* o : unscaled innovation gain */ ) { int16_t index; diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 582056fb78..20e2fde4ad 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -179,11 +179,11 @@ static ivas_error ivas_rend_initCrend( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Encountered unsupported input config in Crend" ); } - if ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM + if ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#else + if ( outConfig != IVAS_AUDIO_CONFIG_BINAURAL && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && outConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif - ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Encountered unsupported output type in Crend" ); } @@ -1126,10 +1126,10 @@ static ivas_error ivas_er_init_handle( ivas_error ivas_rend_initCrendWrapper( #ifdef SPLIT_REND_WITH_HEAD_ROT - CREND_WRAPPER_HANDLE *pCrend, - const int16_t num_poses + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const int16_t num_poses /* i : number of poses */ #else - CREND_WRAPPER_HANDLE *pCrend + CREND_WRAPPER_HANDLE *pCrend /* i/o: Crend wrapper handle */ #endif ) { @@ -1211,18 +1211,7 @@ ivas_error ivas_rend_openMultiBinCrend( const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, const int32_t output_Fs ) { - ivas_error error; - -#ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs ) ) != IVAS_ERR_OK ) -#endif - { - return error; - } - - return error; + return ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs, pMultiBinPoseData->num_poses ); } #endif @@ -1234,16 +1223,16 @@ ivas_error ivas_rend_openMultiBinCrend( *------------------------------------------------------------------------*/ ivas_error ivas_rend_openCrend( - CREND_WRAPPER_HANDLE *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - RENDER_CONFIG_DATA *hRendCfg, - HRTFS_CREND_HANDLE hSetOfHRTF, + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const RENDER_CONFIG_HANDLE hRendCfg, /* i : Renderer configuration handle */ + const HRTFS_CREND_HANDLE hSetOfHRTF, /* i : Set of HRTF handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const int32_t output_Fs, - const int16_t num_poses + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t num_poses /* i : number of poses */ #else - const int32_t output_Fs + const int32_t output_Fs /* i : output sampling rate */ #endif ) { @@ -1256,8 +1245,6 @@ ivas_error ivas_rend_openCrend( int16_t pos_idx; #endif - error = IVAS_ERR_OK; - #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_initCrendWrapper( pCrend, num_poses ) ) != IVAS_ERR_OK ) #else @@ -1421,10 +1408,10 @@ ivas_error ivas_rend_openCrend( void ivas_rend_closeCrend( #ifdef SPLIT_REND_WITH_HEAD_ROT - CREND_WRAPPER_HANDLE *pCrend, - const int16_t num_poses + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const int16_t num_poses /* i : number of poses */ #else - CREND_WRAPPER_HANDLE *pCrend + CREND_WRAPPER_HANDLE *pCrend /* i/o: Crend wrapper handle */ #endif ) { @@ -1746,18 +1733,18 @@ static ivas_error ivas_rend_crendConvolver( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_rend_crendProcess( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - float *output[], /* i/o: input/output audio channels */ - const int32_t output_Fs, + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + float *output[], /* i/o: input/output audio channels */ + const int32_t output_Fs, /* i : output sampling rate */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const int16_t num_subframes /* i : number of subframes to render */, - const int16_t pos_idx + const int16_t num_subframes, /* i : number of subframes to render */ + const int16_t pos_idx /* i : pose index */ #else const int16_t num_subframes /* i : number of subframes to render */ #endif @@ -1906,7 +1893,7 @@ ivas_error ivas_rend_crendProcessSubframe( #ifdef NONBE_UNIFIED_DECODING_PATHS #ifdef SPLIT_REND_WITH_HEAD_ROT , - const int16_t pos_idx + const int16_t pos_idx /* i : pose index */ #endif #endif ) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 0edeee6e38..e1959a846f 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -41,7 +41,6 @@ #include "ivas_rom_binauralRenderer.h" #include "ivas_rom_rend.h" #include "ivas_rom_com.h" - #ifdef DEBUGGING #include "debug.h" #endif @@ -100,6 +99,7 @@ static void ivas_dirac_dec_decorrelate_slot( DIRAC_DEC_BIN_HANDLE hDiracDecBin, #ifdef SPLIT_REND_WITH_HEAD_ROT static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t subframe, float *subFrameTotalEne, float *IIReneLimiter ); + static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const float *subFrameTotalEne, const float *IIReneLimiter, const MASA_ISM_DATA_HANDLE hMasaIsmData ); #else static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Rmat[3][3], const int16_t subframe, const int16_t isHeadtracked, const MASA_ISM_DATA_HANDLE hMasaIsmData ); @@ -196,7 +196,6 @@ ivas_error ivas_dirac_dec_init_binaural_data( set_zero( hDiracDecBin->ChCrossImOutPrev, nBins ); hDiracDecBin->renderStereoOutputInsteadOfBinaural = 0; - for ( bin = 0; bin < nBins; bin++ ) { binCenterFreq = ( (float) bin + CLDFB_HALF_BIN_FREQUENCY_OFFSET ) / (float) nBins * ( (float) output_Fs / 2.0f ); @@ -259,10 +258,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( hDiracDecBin->useTdDecorr = 0; } - if ( hDiracDecBin->h_freq_domain_decorr_ap_params != NULL ) - { - ivas_dirac_dec_decorr_close( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); - } + ivas_dirac_dec_decorr_close( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); #ifdef SPLIT_REND_WITH_HEAD_ROT if ( pos_idx == 0 ) /* open decorrelator only for the main direction */ @@ -276,15 +272,9 @@ ivas_error ivas_dirac_dec_init_binaural_data( if ( !hDiracDecBin->useTdDecorr && !( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) ) { ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, nBins ); - if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), - &( hDiracDecBin->h_freq_domain_decorr_ap_state ), - nBins, - BINAURAL_CHANNELS, - BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, - frequency_axis, - BINAURAL_CHANNELS, - output_Fs ) ) != IVAS_ERR_OK ) + + if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), &( hDiracDecBin->h_freq_domain_decorr_ap_state ), + nBins, BINAURAL_CHANNELS, BINAURAL_CHANNELS, DIRAC_SYNTHESIS_PSD_LS, frequency_axis, BINAURAL_CHANNELS, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -361,33 +351,22 @@ void ivas_dirac_dec_close_binaural_data( { if ( hBinaural[pos_idx] != NULL ) { - if ( hBinaural[pos_idx]->hReverb != NULL ) - { - ivas_binaural_reverb_close( &( hBinaural[pos_idx]->hReverb ) ); - } + ivas_binaural_reverb_close( &( hBinaural[pos_idx]->hReverb ) ); ivas_td_decorr_dec_close( &( hBinaural[pos_idx]->hTdDecorr ) ); - if ( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params != NULL ) - { - ivas_dirac_dec_decorr_close( &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params ), &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_state ) ); - } + ivas_dirac_dec_decorr_close( &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params ), &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_state ) ); free( hBinaural[pos_idx] ); hBinaural[pos_idx] = NULL; } } #else - if ( ( *hBinaural )->hReverb != NULL ) - { - ivas_binaural_reverb_close( &( ( *hBinaural )->hReverb ) ); - } + ivas_binaural_reverb_close( &( ( *hBinaural )->hReverb ) ); ivas_td_decorr_dec_close( &( ( *hBinaural )->hTdDecorr ) ); - if ( ( *hBinaural )->h_freq_domain_decorr_ap_params != NULL ) - { - ivas_dirac_dec_decorr_close( &( *hBinaural )->h_freq_domain_decorr_ap_params, &( *hBinaural )->h_freq_domain_decorr_ap_state ); - } + + ivas_dirac_dec_decorr_close( &( *hBinaural )->h_freq_domain_decorr_ap_params, &( *hBinaural )->h_freq_domain_decorr_ap_state ); free( *hBinaural ); *hBinaural = NULL; @@ -408,6 +387,7 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( ) { int16_t i, j; + if ( hHrtfParambin != NULL && *hHrtfParambin != NULL ) { /* Tables already loaded from file */ @@ -904,8 +884,8 @@ static void ivas_dirac_dec_binaural_internal( #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, - subFrameTotalEne, IIReneLimiter ); + ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, subFrameTotalEne, IIReneLimiter ); + ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, subFrameTotalEne, IIReneLimiter, st_ivas->hMasaIsmData ); diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec.c index e831188881..d60dee3d5a 100644 --- a/lib_rend/ivas_dirac_decorr_dec.c +++ b/lib_rend/ivas_dirac_decorr_dec.c @@ -633,17 +633,11 @@ void ivas_dirac_dec_decorr_close( if ( ph_freq_domain_decorr_ap_params == NULL || ph_freq_domain_decorr_ap_state == NULL ) { -#ifdef DEBUGGING - assert( 0 && "Error: Closing decorrelation synthesis failed." ); -#endif return; } if ( *ph_freq_domain_decorr_ap_params == NULL || *ph_freq_domain_decorr_ap_state == NULL ) { -#ifdef DEBUGGING - assert( 0 && "Error: Closing decorrelation synthesis failed." ); -#endif return; } diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 148f11e82c..491e9c36b6 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -191,8 +191,8 @@ ivas_error ivas_dirac_allocate_parameters( *-------------------------------------------------------------------------*/ ivas_error ivas_spat_hSpatParamRendCom_config( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data handle */ + const DIRAC_CONFIG_FLAG flag_config_inp, /* i : Flag determining if we open or reconfigure the DirAC decoder */ const int16_t dec_param_estim_flag, const IVAS_FORMAT ivas_format, const MC_MODE mc_mode, @@ -334,18 +334,19 @@ ivas_error ivas_spat_hSpatParamRendCom_config( *-------------------------------------------------------------------------*/ void ivas_spat_hSpatParamRendCom_close( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out ) + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom /* i/o: common spatial renderer data handle */ +) { - if ( hSpatParamRendCom_out == NULL || *hSpatParamRendCom_out == NULL ) + if ( hSpatParamRendCom == NULL || *hSpatParamRendCom == NULL ) { return; } - ivas_dirac_deallocate_parameters( *hSpatParamRendCom_out, 1 ); - ivas_dirac_deallocate_parameters( *hSpatParamRendCom_out, 2 ); + ivas_dirac_deallocate_parameters( *hSpatParamRendCom, 1 ); + ivas_dirac_deallocate_parameters( *hSpatParamRendCom, 2 ); - free( *hSpatParamRendCom_out ); - *hSpatParamRendCom_out = NULL; + free( *hSpatParamRendCom ); + *hSpatParamRendCom = NULL; return; } @@ -358,7 +359,8 @@ void ivas_spat_hSpatParamRendCom_close( *-------------------------------------------------------------------------*/ void ivas_dirac_rend_close( - DIRAC_REND_HANDLE *hDirACRend_out ) + DIRAC_REND_HANDLE *hDirACRend_out /* i/o: DirAC renderer handle */ +) { int16_t i, j; DIRAC_REND_HANDLE hDirACRend; @@ -1031,6 +1033,7 @@ void initDiffuseResponses( diffuse_response_function[i] = 0.f; } } + /* Diffuse only to horizontal plane if enough loudspeakers */ if ( num_horizontal_speakers > 2 ) { diff --git a/lib_rend/ivas_lcld_prot.h b/lib_rend/ivas_lcld_prot.h index ad35e50f00..92673a0c43 100644 --- a/lib_rend/ivas_lcld_prot.h +++ b/lib_rend/ivas_lcld_prot.h @@ -37,6 +37,8 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT #include "lib_rend.h" #include "ivas_lcld_rom_tables.h" +#include "ivas_lc3plus_enc.h" +#include "ivas_lc3plus_dec.h" /* clang-format off */ diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index a1e686020a..afb87d2a5e 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -36,9 +36,6 @@ #include "prot.h" #include "ivas_prot.h" #include "ivas_prot_rend.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT -#include "ivas_prot.h" -#endif #include #include "ivas_rom_com.h" #ifdef DEBUGGING @@ -85,8 +82,6 @@ ivas_error ivas_td_binaural_open_unwrap( int16_t nchan_rend; ivas_error error; - error = IVAS_ERR_OK; - if ( ( pBinRendTd = malloc( sizeof( BINAURAL_TD_OBJECT_RENDERER ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD renderer\n" ) ); @@ -242,7 +237,7 @@ ivas_error ivas_td_binaural_open_unwrap( *binaural_latency_ns = (int32_t) ( ( *hBinRendererTd )->HrFiltSet_p->latency_s * 1000000000.f ); } - return error; + return IVAS_ERR_OK; } @@ -645,11 +640,12 @@ ivas_error TDREND_Update_listener_orientation( *---------------------------------------------------------------------*/ ivas_error ivas_td_binaural_open_ext( - TDREND_WRAPPER *pTDRend, - AUDIO_CONFIG inConfig, - RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ - LSSETUP_CUSTOM_STRUCT *customLsInput, - const int32_t outFs ) + TDREND_WRAPPER_HANDLE pTDRend, /* o : TD Renderer wrapper structure */ + const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ + const RENDER_CONFIG_HANDLE hRendCfg, /* i : Renderer configuration */ + const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ + const int32_t output_Fs /* i : output sampling rate */ +) { int16_t nchan_transport; AUDIO_CONFIG transport_config; @@ -688,7 +684,7 @@ ivas_error ivas_td_binaural_open_ext( directivity = hRendCfg->directivity; } - return ivas_td_binaural_open_unwrap( &pTDRend->hHrtfTD, outFs, nchan_transport, ivas_format, transport_config, directivity, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns ); + return ivas_td_binaural_open_unwrap( &pTDRend->hHrtfTD, output_Fs, nchan_transport, ivas_format, transport_config, directivity, hTransSetup, &pTDRend->hBinRendererTd, &pTDRend->binaural_latency_ns ); } @@ -702,7 +698,7 @@ ivas_error ivas_td_binaural_open_ext( ivas_error ivas_td_binaural_renderer_ext( const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ - const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ + const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* i : Combined head and external orientations */ const IVAS_ISM_METADATA *currentPos, /* i : Object position */ const REVERB_HANDLE hReverb, /* i : Reverberator handle */ @@ -729,7 +725,6 @@ ivas_error ivas_td_binaural_renderer_ext( } push_wmops( "ivas_td_binaural_renderer_ext" ); - inConfigType = getAudioConfigType( inConfig ); lfe_idx = LFE_CHANNEL; hIsmMetaData[0] = NULL; @@ -781,7 +776,6 @@ ivas_error ivas_td_binaural_renderer_ext( } pop_wmops(); - return IVAS_ERR_OK; } @@ -820,15 +814,8 @@ ivas_error ObjRenderIvasFrame_splitBinaural( continue; } - if ( ( error = ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, - st_ivas->hDecoderConfig->output_Fs, - st_ivas->nchan_transport, - st_ivas->ivas_format, - st_ivas->transport_config, - st_ivas->hRenderConfig->directivity, - st_ivas->hTransSetup, - &st_ivas->hSplitBinRend.splitrend.hTdRendHandles[i], - &st_ivas->binaural_latency_ns ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, st_ivas->ivas_format, st_ivas->transport_config, + st_ivas->hRenderConfig->directivity, st_ivas->hTransSetup, &st_ivas->hSplitBinRend.splitrend.hTdRendHandles[i], &st_ivas->binaural_latency_ns ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 2706a9c5c8..756ca82a68 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -45,20 +45,12 @@ * Local function prototypes *---------------------------------------------------------------------*/ -static void TDREND_SRC_SPATIAL_Dealloc( TDREND_SRC_SPATIAL_t *SrcSpatial_p ); - -static void TDREND_SRC_SPATIAL_Init( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_PosType_t PosType ); - static void TDREND_SRC_SPATIAL_SetDirAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DirAtten_t *DirAtten_p ); static float TDREND_SRC_SPATIAL_GetDirGain( const TDREND_DirAtten_t *DirAtten_p, const float *Front_p, const float *RelPos_p ); static float TDREND_SRC_SPATIAL_GetDistGain( const TDREND_DistAtten_t *DistAtten_p, const float Dist ); -static ivas_error TDREND_SRC_REND_Alloc( TDREND_SRC_REND_t **SrcRend_pp ); - -static void TDREND_SRC_REND_Init( TDREND_SRC_REND_t *SrcRend_p ); - /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetPos() @@ -100,7 +92,7 @@ ivas_error TDREND_MIX_SRC_SetPos( --------------------------------------------------------------------*/ ivas_error TDREND_MIX_SRC_SetDir( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ const float *Vec_p /* i : Direction vector */ ) @@ -134,7 +126,7 @@ ivas_error TDREND_MIX_SRC_SetDir( --------------------------------------------------------------------*/ ivas_error TDREND_MIX_SRC_SetDirAtten( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ const TDREND_DirAtten_t *DirAtten_p /* i : Directional attenuation specifier */ ) @@ -161,7 +153,7 @@ ivas_error TDREND_MIX_SRC_SetDirAtten( --------------------------------------------------------------------*/ ivas_error TDREND_MIX_SRC_SetPlayState( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ const TDREND_PlayStatus_t PlayStatus /* i : Play state */ ) @@ -247,19 +239,20 @@ static void TDREND_SRC_REND_Init( --------------------------------------------------------------------*/ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ - TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ - float *hrf_left_prev, /* o : Left filter */ - float *hrf_right_prev, /* o : Right filter */ - float *hrf_left_delta, /* o : Left filter interpolation delta */ - float *hrf_right_delta, /* o : Right filter interpolation delta */ - int16_t *intp_count, /* o : Interpolation count */ - int16_t *filterlength, /* o : Length of filters */ - int16_t *itd, /* o : ITD value */ - float *Gain, /* o : Gain value */ - TDREND_SRC_t *Src_p, /* i/o: Source pointer */ - const int16_t subframe_update_flag ) + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ + TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ + float *hrf_left_prev, /* o : Left filter */ + float *hrf_right_prev, /* o : Right filter */ + float *hrf_left_delta, /* o : Left filter interpolation delta */ + float *hrf_right_delta, /* o : Right filter interpolation delta */ + int16_t *intp_count, /* o : Interpolation count */ + int16_t *filterlength, /* o : Length of filters */ + int16_t *itd, /* o : ITD value */ + float *Gain, /* o : Gain value */ + TDREND_SRC_t *Src_p, /* i/o: Source pointer */ + const int16_t subframe_update_flag /* i : Flag to determine update subframe idx*/ +) { TDREND_MIX_Listener_t *Listener_p; TDREND_HRFILT_FiltSet_t *HrFiltSet_p; @@ -627,7 +620,8 @@ ivas_error TDREND_SRC_Alloc( --------------------------------------------------------------------*/ void TDREND_SRC_Dealloc( - TDREND_SRC_t *Src_p ) + TDREND_SRC_t *Src_p /* i/o: Source to deallocate */ +) { if ( Src_p == NULL ) { diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index ff24510c58..8359c64267 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -40,7 +40,6 @@ #include "debug.h" #endif #include -#include #include "wmc_auto.h" @@ -378,7 +377,7 @@ static void VectorRotationToQuaternion( *-------------------------------------------------------------------*/ ivas_error ivas_orient_trk_Init( - ivas_orient_trk_state_t *pOTR ) /* i/o : orientation tracker handle */ + ivas_orient_trk_state_t *pOTR ) /* i/o: orientation tracker handle */ { IVAS_QUATERNION identity; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 4f2044ad50..75fcdfa041 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -92,8 +92,7 @@ void ivas_limiter_close( IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */ ); -void ivas_limiter_dec -( +void ivas_limiter_dec( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ const int16_t num_channels, /* i : number of channels to be processed */ @@ -503,8 +502,8 @@ void ivas_dirac_dec_get_frequency_axis( ); ivas_error ivas_spat_hSpatParamRendCom_config( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, - const DIRAC_CONFIG_FLAG flag_config_inp, /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data handle */ + const DIRAC_CONFIG_FLAG flag_config_inp, /* i : Flag determining if we open or reconfigure the DirAC decoder */ const int16_t dec_param_estim_flag, const IVAS_FORMAT ivas_format, const MC_MODE mc_mode, @@ -513,21 +512,21 @@ ivas_error ivas_spat_hSpatParamRendCom_config( ); void ivas_spat_hSpatParamRendCom_close( - SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom /* i/o: common spatial renderer data handle */ ); void ivas_dirac_rend_close( - DIRAC_REND_HANDLE *hDirACRend_out + DIRAC_REND_HANDLE *hDirACRend_out /* i/o: DirAC renderer handle */ ); ivas_error ivas_dirac_allocate_parameters( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ + const int16_t params_flag /* i : set of parameters flag */ ); void ivas_dirac_deallocate_parameters( - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ + const int16_t params_flag /* i : set of parameters flag */ ); @@ -596,7 +595,7 @@ ivas_error ivas_td_binaural_renderer_unwrap( ivas_error ivas_td_binaural_renderer_ext( const TDREND_WRAPPER *pTDRend, /* i : TD Renderer wrapper structure */ const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ - const LSSETUP_CUSTOM_STRUCT *customLsInput, /* i : Input custom loudspeaker layout */ + const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData,/* i : Combined head and external orientations */ const IVAS_ISM_METADATA *currentPos, /* i : Object position */ const REVERB_HANDLE hReverb, /* i : Reverberator handle */ @@ -619,11 +618,11 @@ ivas_error ivas_td_binaural_open_unwrap( ); ivas_error ivas_td_binaural_open_ext( - TDREND_WRAPPER *pTDRend, - const AUDIO_CONFIG inConfig, - RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration */ - LSSETUP_CUSTOM_STRUCT *customLsInput, - const int32_t output_Fs + TDREND_WRAPPER_HANDLE pTDRend, /* o : TD Renderer wrapper structure */ + const AUDIO_CONFIG inConfig, /* i : Input audio configuration */ + const RENDER_CONFIG_HANDLE hRendCfg, /* i : Renderer configuration */ + const LSSETUP_CUSTOM_HANDLE customLsInput, /* i : Input custom loudspeaker layout */ + const int32_t output_Fs /* i : output sampling rate */ ); void ivas_td_binaural_close( @@ -720,7 +719,7 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( int16_t *filterlength, /* o : Length of filters */ int16_t *itd, /* o : ITD value */ float *Gain, /* o : Gain value */ - TDREND_SRC_t *Src_p, + TDREND_SRC_t *Src_p, /* i/o: Source pointer */ const int16_t subframe_update_flag /* i : Flag to determine update subframe idx */ ); @@ -840,51 +839,51 @@ void TDREND_firfilt( *----------------------------------------------------------------------------------*/ ivas_error ivas_rend_openCrend( - CREND_WRAPPER_HANDLE *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - RENDER_CONFIG_DATA *hRendCfg, - HRTFS_CREND_HANDLE hSetOfHRTF, + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const RENDER_CONFIG_HANDLE hRendCfg, /* i : Renderer configuration handle */ + const HRTFS_CREND_HANDLE hSetOfHRTF, /* i : Set of HRTF handle */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const int32_t output_Fs, - const int16_t num_poses + const int32_t output_Fs, /* i : output sampling rate */ + const int16_t num_poses /* i : number of poses */ #else - const int32_t output_Fs + const int32_t output_Fs /* i : output sampling rate */ #endif ); void ivas_rend_closeCrend( #ifdef SPLIT_REND_WITH_HEAD_ROT - CREND_WRAPPER_HANDLE *pCrend , - const int16_t num_poses + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const int16_t num_poses /* i : number of poses */ #else - CREND_WRAPPER_HANDLE *pCrend + CREND_WRAPPER_HANDLE *pCrend /* i/o: Crend wrapper handle */ #endif ); ivas_error ivas_hrtf_init( - HRTFS_DATA *hHrtf /* i/o: HRTF handle */ + HRTFS_DATA *hHrtf /* i/o: HRTF handle */ ); ivas_error ivas_rend_initCrendWrapper( #ifdef SPLIT_REND_WITH_HEAD_ROT - CREND_WRAPPER_HANDLE *pCrend, - const int16_t num_poses + CREND_WRAPPER_HANDLE *pCrend, /* i/o: Crend wrapper handle */ + const int16_t num_poses /* i : number of poses */ #else - CREND_WRAPPER_HANDLE *pCrend + CREND_WRAPPER_HANDLE *pCrend /* i/o: Crend wrapper handle */ #endif ); ivas_error ivas_rend_crendProcess( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ float *output[], /* i/o: input/output audio channels */ - const int32_t output_Fs, + const int32_t output_Fs, /* i : output sampling rate */ #ifdef SPLIT_REND_WITH_HEAD_ROT const int16_t num_subframes, /* i : number of subframes to render */ const int16_t pos_idx /* i : pose index */ @@ -909,7 +908,7 @@ ivas_error ivas_rend_crendProcessSubframe( #ifdef NONBE_UNIFIED_DECODING_PATHS #ifdef SPLIT_REND_WITH_HEAD_ROT , - const int16_t pos_idx + const int16_t pos_idx /* i : pose index */ #endif #endif ); @@ -1153,16 +1152,16 @@ void ivas_reverb_get_hrtf_set_properties( *-----------------------------------------------------------------------------------*/ void ivas_shoebox_config_init( - shoebox_config_t *cal, - RENDER_CONFIG_HANDLE pConfig + shoebox_config_t *cal, /* i/o: shoebox_config_t handle */ + const RENDER_CONFIG_HANDLE hRendCfg /* i : Renderer configuration handle */ ); void ivas_shoebox_init( - shoebox_obj_t *obj, - shoebox_config_t *cal + shoebox_obj_t *obj, /* i/o: shoebox_obj_t handle */ + const shoebox_config_t *cal /* i : shoebox_config_t handle */ ); -void ivas_shoebox_set_scene ( +void ivas_shoebox_set_scene( shoebox_obj_t *obj, shoebox_output_t *ER_PARAMS, const float list_pos[3], @@ -1176,29 +1175,29 @@ void ivas_shoebox_set_scene ( *-----------------------------------------------------------------------------------*/ ivas_error ivas_er_init( - er_struct_t *reflections, - const AUDIO_CONFIG inConfig + er_struct_t *reflections, /* i/o: early reflections handle */ + const AUDIO_CONFIG inConfig /* i : Input config */ ); ivas_error ivas_er_set_reflections_mode( - er_struct_t *reflections, - const AUDIO_CONFIG inConfig + er_struct_t *reflections, /* i/o: early reflections handle */ + const AUDIO_CONFIG inConfig /* i : Input config */ ); ivas_error ivas_er_compute_reflections( - er_struct_t *reflections + er_struct_t *reflections /* i/o: early reflections handle */ ); ivas_error ivas_er_encoder_init( - er_struct_t *reflections + er_struct_t *reflections /* i/o: early reflections handle */ ); ivas_error ivas_er_process( - er_struct_t *reflections, - const int16_t frame_size, - const int16_t subframe_idx, - float **io, - const AUDIO_CONFIG inConfig + er_struct_t *reflections, /* i/o: early reflections handle */ + const int16_t subframe_size, /* i : subframe length */ + const int16_t subframe_idx, /* i : subframe index */ + float *output[], /* i/o: input/output buffer */ + const AUDIO_CONFIG inConfig /* i : Input config */ ); @@ -1207,18 +1206,18 @@ ivas_error ivas_er_process( *-----------------------------------------------------------------------------------*/ ivas_error ivas_headTrack_open( - HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ ); void ivas_headTrack_close( - HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ); void Euler2Quat( - const float yaw, /* i : yaw (x) */ - const float pitch, /* i : pitch (y) */ - const float roll, /* i : roll (z) */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ + const float yaw, /* i : yaw (x) */ + const float pitch, /* i : pitch (y) */ + const float roll, /* i : roll (z) */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ ); float deg2rad( @@ -1644,8 +1643,8 @@ void ivas_SplitRenderer_GetRotMd( void ivas_SplitRenderer_PostRenderer( BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - float Cldfb_RealBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ - float Cldfb_ImagBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + float Cldfb_RealBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Reference/out Binaural signals */ + float Cldfb_ImagBuffer_Ref_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Reference/out Binaural signals */ const IVAS_QUATERNION Quaternion_act ); diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index 47143e20c3..fd49d9a39d 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -71,8 +71,9 @@ static uint16_t LC_mixing_7_1_4[11] = { 0, 1, 2, 3, 4, 3, 4, 0, 1, 2, 3 }; *-----------------------------------------------------------------------------------------*/ ivas_error ivas_er_init( - er_struct_t *reflections, - const AUDIO_CONFIG inConfig ) + er_struct_t *reflections, /* i/o: early reflections handle */ + const AUDIO_CONFIG inConfig /* i : Input config */ +) { ivas_error error; uint8_t i; @@ -139,8 +140,9 @@ ivas_error ivas_er_init( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_er_set_reflections_mode( - er_struct_t *reflections, - const AUDIO_CONFIG inConfig ) + er_struct_t *reflections, /* i/o: early reflections handle */ + const AUDIO_CONFIG inConfig /* i : Input config */ +) { ivas_error error; uint16_t ch; @@ -255,7 +257,8 @@ ivas_error ivas_er_set_reflections_mode( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_er_encoder_init( - er_struct_t *reflections ) + er_struct_t *reflections /* i/o: early reflections handle */ +) { ivas_error error = IVAS_ERR_OK; uint16_t i, j, src_idx; @@ -330,7 +333,8 @@ ivas_error ivas_er_encoder_init( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_er_compute_reflections( - er_struct_t *reflections ) + er_struct_t *reflections /* i/o: early reflections handle */ +) { ivas_error error = IVAS_ERR_OK; uint16_t circ_len, i, j; @@ -422,13 +426,13 @@ Takes a buffer of N channels, returns a buffer of N*6 channels containing the ea reflections (one per wall). The process is a delay line architecture *-----------------------------------------------------------------------------------------*/ - ivas_error ivas_er_process( - er_struct_t *reflections, - const int16_t subframe_size, - const int16_t subframe_idx, - float **io, - const AUDIO_CONFIG inConfig ) + er_struct_t *reflections, /* i/o: early reflections handle */ + const int16_t subframe_size, /* i : subframe length */ + const int16_t subframe_idx, /* i : subframe index */ + float *output[], /* i/o: input/output buffer */ + const AUDIO_CONFIG inConfig /* i : Input config */ +) { ivas_error error = IVAS_ERR_OK; uint16_t i, j, k, subframe_offset; @@ -487,7 +491,7 @@ ivas_error ivas_er_process( { for ( j = 0; j < subframe_size; j++ ) { - buffer_ch[samp_idx++] = io[in_ch_idx][j + subframe_offset]; + buffer_ch[samp_idx++] = output[in_ch_idx][j + subframe_offset]; samp_idx = samp_idx % reflections->circ_len; } } @@ -496,7 +500,7 @@ ivas_error ivas_er_process( { for ( j = 0; j < subframe_size; j++ ) { - buffer_ch[samp_idx++] += io[in_ch_idx][j + subframe_offset]; + buffer_ch[samp_idx++] += output[in_ch_idx][j + subframe_offset]; samp_idx = samp_idx % reflections->circ_len; } } @@ -532,7 +536,7 @@ ivas_error ivas_er_process( /* Pull reflection from circ buffer and apply gain */ for ( k = 0; k < subframe_size; k++ ) { - io[ref_out_idx][k + subframe_offset] += buffer_ch[samp_idx++] * ref_gain; + output[ref_out_idx][k + subframe_offset] += buffer_ch[samp_idx++] * ref_gain; samp_idx = samp_idx % reflections->circ_len; } } diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 7c4bdd94b6..a47e0fb6e2 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -48,19 +48,13 @@ * Local funtion declarations *-----------------------------------------------------------------------*/ -static ivas_error combine_external_and_head_orientations( - IVAS_QUATERNION *headRotQuaternions, - IVAS_VECTOR3 *listenerPos, #ifdef SPLIT_REND_WITH_HEAD_ROT - IVAS_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis*/ +static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, IVAS_VECTOR3 *listenerPos, IVAS_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); +#else +static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, IVAS_VECTOR3 *listenerPos, EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); #endif - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); -static void external_target_interpolation( - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, - const int16_t i ); +static void external_target_interpolation( EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, const int16_t i ); static bool are_orientations_same( const IVAS_QUATERNION *orientation1, const IVAS_QUATERNION *orientation2 ); @@ -365,7 +359,6 @@ void rotateFrame_shd( int16_t i, l, n, m; int16_t m1, m2; int16_t shd_rot_max_order; - float tmp; float tmpRot[2 * HEADROT_ORDER + 1]; float SHrotmat_prev[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM]; @@ -451,18 +444,19 @@ void rotateFrame_shd( /* move Rmat to Rmat_prev */ for ( i = 0; i < 3; i++ ) { - mvr2r( #ifdef NONBE_UNIFIED_DECODING_PATHS - hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], +#ifdef SPLIT_REND_WITH_HEAD_ROT + mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], hCombinedOrientationData->Rmat_prev[0][i], 3 ); #else - hCombinedOrientationData->Rmat[subframe_idx][i], + mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], hCombinedOrientationData->Rmat_prev[i], 3 ); #endif +#else #ifdef SPLIT_REND_WITH_HEAD_ROT - hCombinedOrientationData->Rmat_prev[0][i], + mvr2r( hCombinedOrientationData->Rmat[subframe_idx][i], hCombinedOrientationData->Rmat_prev[0][i], 3 ); #else - hCombinedOrientationData->Rmat_prev[i], + mvr2r( hCombinedOrientationData->Rmat[subframe_idx][i], hCombinedOrientationData->Rmat_prev[i], 3 ); +#endif #endif - 3 ); } return; @@ -488,7 +482,6 @@ void rotateFrame_sd( int16_t nchan, index_lfe; int16_t ch_in, ch_in_woLFE, ch_out, ch_out_woLFE; int16_t azimuth, elevation; - float tmp; float tmp_gains[MAX_CICP_CHANNELS - 1]; float gains[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; @@ -594,18 +587,19 @@ void rotateFrame_sd( /* move Rmat to Rmat_prev */ for ( i = 0; i < 3; i++ ) { - mvr2r( #ifdef NONBE_UNIFIED_DECODING_PATHS - hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], +#ifdef SPLIT_REND_WITH_HEAD_ROT + mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], hCombinedOrientationData->Rmat_prev[0][i], 3 ); #else - hCombinedOrientationData->Rmat[subframe_idx][i], + mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], hCombinedOrientationData->Rmat_prev[i], 3 ); #endif +#else #ifdef SPLIT_REND_WITH_HEAD_ROT - hCombinedOrientationData->Rmat_prev[0][i], + mvr2r( hCombinedOrientationData->Rmat[subframe_idx][i], hCombinedOrientationData->Rmat_prev[0][i], 3 ); #else - hCombinedOrientationData->Rmat_prev[i], + mvr2r( hCombinedOrientationData->Rmat[subframe_idx][i], hCombinedOrientationData->Rmat_prev[i], 3 ); +#endif #endif - 3 ); } /* copy to output */ @@ -832,7 +826,6 @@ ivas_error ivas_external_orientation_open( const int16_t num_subframes /* i : number of subframes */ ) { - int16_t i; IVAS_QUATERNION identity; @@ -1044,11 +1037,11 @@ ivas_error combine_external_and_head_orientations_dec( } #endif - return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, #ifdef SPLIT_REND_WITH_HEAD_ROT - sr_pose_pred_axis, + return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, sr_pose_pred_axis, hExtOrientationData, hCombinedOrientationData ); +#else + return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, hExtOrientationData, hCombinedOrientationData ); #endif - hExtOrientationData, hCombinedOrientationData ); } @@ -1097,11 +1090,11 @@ ivas_error combine_external_and_head_orientations_rend( } } - return combine_external_and_head_orientations( headRotQuaternions, listenerPos, #ifdef SPLIT_REND_WITH_HEAD_ROT - sr_pose_pred_axis, + return combine_external_and_head_orientations( headRotQuaternions, listenerPos, sr_pose_pred_axis, hExtOrientationData, hCombinedOrientationData ); +#else + return combine_external_and_head_orientations( headRotQuaternions, listenerPos, hExtOrientationData, hCombinedOrientationData ); #endif - hExtOrientationData, hCombinedOrientationData ); } diff --git a/lib_rend/ivas_shoebox.c b/lib_rend/ivas_shoebox.c index 12368f5fde..5d76f8254b 100644 --- a/lib_rend/ivas_shoebox.c +++ b/lib_rend/ivas_shoebox.c @@ -60,8 +60,8 @@ *-----------------------------------------------------------------------------------------*/ void ivas_shoebox_config_init( - shoebox_config_t *cal, - RENDER_CONFIG_HANDLE hRenderConfig /* i : Renderer configuration handle */ + shoebox_config_t *cal, /* i/o: shoebox_config_t handle */ + const RENDER_CONFIG_HANDLE hRenderConfig /* i : Renderer configuration handle */ ) { int16_t wall_idx; @@ -94,8 +94,9 @@ void ivas_shoebox_config_init( *-----------------------------------------------------------------------------------------*/ void ivas_shoebox_init( - shoebox_obj_t *obj, - shoebox_config_t *cal ) + shoebox_obj_t *obj, /* i/o: shoebox_obj_t handle */ + const shoebox_config_t *cal /* i : shoebox_config_t handle */ +) { uint16_t i; @@ -358,9 +359,11 @@ void ivas_shoebox_set_scene( float out_tmp; int32_t i, j, k, n; int32_t loop_ub; + /* ------------- SET FLAGS ------------- */ obj->isCartesian = isCartesian; obj->isRelative = isRelative; + /* ------------- CHECK DIMENSIONS ------------- */ if ( ER_PARAMS->n_sources > obj->MAX_SOURCES ) { @@ -370,11 +373,13 @@ void ivas_shoebox_set_scene( { obj->nSrc = ER_PARAMS->n_sources; } + /* ---------- RESET DATA HOLDERS ---------- */ set_f( &obj->src_pos[0], 0.0f, 75U ); obj->list_pos[0] = list_pos[0]; obj->list_pos[1] = list_pos[1]; obj->list_pos[2] = list_pos[2]; + /* ---------- ADJUST LISTENER ------------- */ if ( obj->isZHeight != 0 ) { @@ -439,13 +444,16 @@ void ivas_shoebox_set_scene( { float im_pos[3]; float path_dist; + /* Retrieve coordinate and surface sign */ coord = ( (int32_t) ceilf( ( ( (float) loop_ub ) + 1.0f ) / 2.0f ) ) - 1; rcoselev = ( ( (float) loop_ub ) + 1.0f ) + ( ER_PARAMS->n_ref * ( ( ( (float) j ) + 1.0f ) - 1.0f ) ); + /* Initialize image position coordinates */ im_pos[0] = tmp_pos[0]; im_pos[1] = tmp_pos[1]; im_pos[2] = tmp_pos[2]; + /* Calculate image projection coordinate based on current surface axis */ if ( ( loop_ub + 1 ) < 3 ) { @@ -459,31 +467,29 @@ void ivas_shoebox_set_scene( { scale = obj->cal.room_H; } - im_pos[coord] = - tmp_pos[coord] + - ( 2.0f * ( ( ( ( -( 1.0f - ( fmodf( ( (float) loop_ub ) + 1.0f, 2.0f ) * 2.0f ) ) ) * scale ) / 2.0f ) - tmp_pos[coord] ) ); + + im_pos[coord] = tmp_pos[coord] + ( 2.0f * ( ( ( ( -( 1.0f - ( fmodf( ( (float) loop_ub ) + 1.0f, 2.0f ) * 2.0f ) ) ) * scale ) / 2.0f ) - tmp_pos[coord] ) ); + /* 0. Get euclidean distance from IMAGE SOURCE [N,W] to LIST */ scale = ER_EUCLIDEAN_SCALE; path_dist = shoebox_get_euclidian_distance_internal( obj, im_pos, &scale ); path_dist = scale * sqrtf( path_dist ); + /* 1. Compute time-of arrival (TOA) */ ER_PARAMS->times.data[( (int32_t) rcoselev ) - 1] = path_dist / obj->soundspeed; + /* 2./3. DOA */ - ER_PARAMS->az_angle.data[( (int32_t) rcoselev ) - 1] = - rad2deg( - atan2f( im_pos[1] - obj->list_pos[1], im_pos[0] - obj->list_pos[0] ) ); - ER_PARAMS->el_angle.data[( (int32_t) rcoselev ) - 1] = - rad2deg( - asinf( ( im_pos[2] - obj->list_pos[2] ) / path_dist ) ); + ER_PARAMS->az_angle.data[( (int32_t) rcoselev ) - 1] = rad2deg( atan2f( im_pos[1] - obj->list_pos[1], im_pos[0] - obj->list_pos[0] ) ); + ER_PARAMS->el_angle.data[( (int32_t) rcoselev ) - 1] = rad2deg( asinf( ( im_pos[2] - obj->list_pos[2] ) / path_dist ) ); + /* 4. Compute gain taking into account air and surface absorption */ /* and propagation loss */ if ( path_dist < out_tmp ) { path_dist = out_tmp; } - ER_PARAMS->gains.data[( (int32_t) rcoselev ) - 1] = - ( ( 1.0f - obj->cal.abs_coeff[loop_ub] ) * ( out_tmp / path_dist ) ) - ( path_dist * obj->air_coeff ); + ER_PARAMS->gains.data[( (int32_t) rcoselev ) - 1] = ( ( 1.0f - obj->cal.abs_coeff[loop_ub] ) * ( out_tmp / path_dist ) ) - ( path_dist * obj->air_coeff ); } } diff --git a/lib_rend/ivas_splitRendererPost.c b/lib_rend/ivas_splitRendererPost.c index 8eb542892e..daf9927a62 100644 --- a/lib_rend/ivas_splitRendererPost.c +++ b/lib_rend/ivas_splitRendererPost.c @@ -1437,8 +1437,8 @@ static void interpolate_rend_md( void ivas_SplitRenderer_PostRenderer( BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ - float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Reference/out Binaural signals */ + float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Reference/out Binaural signals */ const IVAS_QUATERNION Quaternion_act ) { int16_t pos_idx, b, brange[2], ch_idx1; diff --git a/lib_rend/ivas_splitRendererPre.c b/lib_rend/ivas_splitRendererPre.c index 700117931f..c5c069aac3 100644 --- a/lib_rend/ivas_splitRendererPre.c +++ b/lib_rend/ivas_splitRendererPre.c @@ -1840,13 +1840,7 @@ ivas_error ivas_split_renderer_open( const int16_t is_5ms_frame ) { ivas_error error, ch, num_ch; -#ifndef SPLIT_REND_WITH_HEAD_ROT - CLDFB_TYPE cldfbMode; -#endif uint8_t isCldfbNeeded = 0; -#ifndef SPLIT_REND_WITH_HEAD_ROT - cldfbMode = CLDFB_ANALYSIS; -#endif if ( ( error = ivas_split_rend_validate_config( pSplitRendConfig, pcm_out_flag ) ) != IVAS_ERR_OK ) { @@ -1856,27 +1850,14 @@ ivas_error ivas_split_renderer_open( if ( cldfb_in_flag == 0 ) { isCldfbNeeded = 1; -#ifndef SPLIT_REND_WITH_HEAD_ROT - cldfbMode = CLDFB_ANALYSIS; -#endif } else if ( pSplitRendConfig->codec == IVAS_SPLIT_REND_CODEC_LC3PLUS && cldfb_in_flag ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT isCldfbNeeded = 1; -#else - isCldfbNeeded = 1; - cldfbMode = CLDFB_SYNTHESIS; -#endif } else if ( pcm_out_flag && cldfb_in_flag ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - isCldfbNeeded = 1; -#else isCldfbNeeded = 1; - cldfbMode = CLDFB_SYNTHESIS; -#endif } hSplitRendWrapper->hCldfbHandles = NULL; @@ -1893,30 +1874,21 @@ ivas_error ivas_split_renderer_open( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] = NULL; } -#ifdef SPLIT_REND_WITH_HEAD_ROT for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] = NULL; } -#endif num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; for ( ch = 0; ch < num_ch; ch++ ) { - if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), -#ifndef SPLIT_REND_WITH_HEAD_ROT - cldfbMode, -#else - CLDFB_ANALYSIS, -#endif - OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) + if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), CLDFB_ANALYSIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) { return error; } } -#ifdef SPLIT_REND_WITH_HEAD_ROT for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { if ( ( error = openCldfb( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK ) @@ -1924,17 +1896,15 @@ ivas_error ivas_split_renderer_open( return error; } } -#endif } if ( pSplitRendConfig->poseCorrectionMode == IVAS_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { - if ( ( error = ivas_splitBinPreRendOpen( &hSplitRendWrapper->hBinHrSplitPreRend, &hSplitRendWrapper->multiBinPoseData #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - , - OutSampleRate + if ( ( error = ivas_splitBinPreRendOpen( &hSplitRendWrapper->hBinHrSplitPreRend, &hSplitRendWrapper->multiBinPoseData, OutSampleRate ) ) != IVAS_ERR_OK ) +#else + if ( ( error = ivas_splitBinPreRendOpen( &hSplitRendWrapper->hBinHrSplitPreRend, &hSplitRendWrapper->multiBinPoseData ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -1996,7 +1966,6 @@ void ivas_split_renderer_close( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { if ( hSplitBinRend->hCldfbHandles->cldfbSyn[ch] != NULL ) @@ -2005,7 +1974,6 @@ void ivas_split_renderer_close( hSplitBinRend->hCldfbHandles->cldfbSyn[ch] = NULL; } } -#endif free( hSplitBinRend->hCldfbHandles ); hSplitBinRend->hCldfbHandles = NULL; @@ -2404,11 +2372,8 @@ ivas_error ivas_renderMultiBinToSplitBinaural( Cldfb_In_BinReal_p[slot_idx] = Cldfb_In_BinReal[ch][slot_idx]; Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx]; } -#ifndef SPLIT_REND_WITH_HEAD_ROT - cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, output[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] ); -#else + cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, output[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); -#endif } if ( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, output ) ) != IVAS_ERR_OK ) @@ -2432,11 +2397,7 @@ ivas_error ivas_renderMultiBinToSplitBinaural( Cldfb_In_BinImag_p[slot_idx] = Cldfb_In_BinImag[ch][slot_idx]; } -#ifndef SPLIT_REND_WITH_HEAD_ROT - cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, output[ch], hSplitBin->hCldfbHandles->cldfbAna[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbAna[ch] ); -#else cldfbSynthesis( Cldfb_In_BinReal_p, Cldfb_In_BinImag_p, output[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); -#endif } pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 1f6dfe5079..86b4ed2adb 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -40,10 +40,7 @@ #include "stat_com.h" /* Note: Currently needed for CLDFB. */ #include "common_api_types.h" #ifdef SPLIT_REND_WITH_HEAD_ROT -#include "stat_com.h" #include "ivas_lcld_prot.h" -#include "ivas_lc3plus_enc.h" -#include "ivas_lc3plus_dec.h" #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index d754ffa4b1..adb0ceb7d6 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2883,7 +2883,7 @@ static void clearInputSplitRend( return; } -#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif static void clearInputSba( @@ -3715,9 +3715,7 @@ ivas_error IVAS_REND_Open( ivas_init_split_post_rend_handles( &hIvasRend->inputsSplitPost[i].splitPostRendWrapper ); -#ifdef SPLIT_REND_WITH_HEAD_ROT hIvasRend->splitRendBFI = 0; -#endif hIvasRend->inputsSplitPost[i].bufferData = NULL; } #endif @@ -5250,9 +5248,15 @@ ivas_error IVAS_REND_DisableHeadRotation( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_SetSplitRendBFI( - IVAS_REND_HANDLE hIvasRend, - const int16_t bfi ) + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const int16_t bfi /* i : Bad Frame Indicator */ +) { + if ( hIvasRend == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + hIvasRend->splitRendBFI = bfi; return IVAS_ERR_OK; @@ -5728,7 +5732,6 @@ static ivas_error rotateFrameSba( const float *crossfade; int16_t num_subframes; int16_t subframe_idx, subframe_len; - float *writePtr; rotation_matrix Rmat; float tmpRot[2 * HEADROT_ORDER + 1]; @@ -5738,7 +5741,6 @@ static ivas_error rotateFrameSba( float val, cf, oneminuscf; push_wmops( "rotateFrameSba" ); - if ( ( error = chooseCrossfade( headRotData, &crossfade ) ) != IVAS_ERR_OK ) { return error; @@ -5823,7 +5825,6 @@ static ivas_error rotateFrameSba( } pop_wmops(); - return IVAS_ERR_OK; } @@ -5850,7 +5851,6 @@ static ivas_error renderIsmToBinaural( accumulate2dArrayToBuffer( tmpTDRendBuffer, &outAudio ); pop_wmops(); - return IVAS_ERR_OK; } @@ -5907,7 +5907,6 @@ static ivas_error renderIsmToBinauralRoom( } push_wmops( "renderIsmToBinauralRoom" ); - rotatedPosPrev = defaultObjectPosition(); rotatedPos = defaultObjectPosition(); @@ -5986,10 +5985,7 @@ static ivas_error renderIsmToBinauralRoom( /* compute gains only if position changed */ if ( position_changed ) { - if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper, - rotatedPos.azimuth, - rotatedPos.elevation, - currentPanGains ) ) != IVAS_ERR_OK ) + if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper, rotatedPos.azimuth, rotatedPos.elevation, currentPanGains ) ) != IVAS_ERR_OK ) { return error; } @@ -6007,10 +6003,7 @@ static ivas_error renderIsmToBinauralRoom( tmpMcBuffer.data = malloc( tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels * sizeof( float ) ); set_zero( tmpMcBuffer.data, tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels ); - renderBufferChannelLerp( ismInput->base.inputBuffer, 0, - position_changed ? currentPanGains : ismInput->prev_pan_gains, - position_changed ? ismInput->prev_pan_gains : NULL, - tmpMcBuffer ); + renderBufferChannelLerp( ismInput->base.inputBuffer, 0, position_changed ? currentPanGains : ismInput->prev_pan_gains, position_changed ? ismInput->prev_pan_gains : NULL, tmpMcBuffer ); copyBufferTo2dArray( tmpMcBuffer, tmpRendBuffer ); @@ -6044,8 +6037,8 @@ static ivas_error renderIsmToBinauralRoom( accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); free( tmpMcBuffer.data ); - pop_wmops(); + pop_wmops(); return IVAS_ERR_OK; } @@ -6235,7 +6228,6 @@ static ivas_error renderIsmToSplitBinaural( int16_t ism_md_subframe_update_ext; push_wmops( "renderIsmToSplitBinaural" ); - pSplitRendWrapper = ismInput->base.ctx.pSplitRendWrapper; pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; @@ -6327,7 +6319,6 @@ static void renderIsmToMasa( float tmpRendBuffer[MAX_NUM_OBJECTS][L_FRAME48k]; push_wmops( "renderIsmToMasa" ); - copyBufferTo2dArray( ismInput->base.inputBuffer, tmpRendBuffer ); ivas_omasa_ana( ismInput->hOMasa, tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, ismInput->base.inputBuffer.config.numChannels ); @@ -6335,7 +6326,6 @@ static void renderIsmToMasa( accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); pop_wmops(); - return; } @@ -8819,7 +8809,7 @@ static ivas_error getSamplesInternal( convertBitsBufferToInternalBitsBuff( *hBits, &bits ); if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 6df2ff3f40..241939cb8a 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -81,6 +81,7 @@ typedef struct IVAS_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; int16_t codec_frame_size_ms; } IVAS_REND_BitstreamBufferConfig; + typedef struct { IVAS_REND_BitstreamBufferConfig config; @@ -301,8 +302,9 @@ ivas_error IVAS_REND_SetReferenceVector( #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error IVAS_REND_SetSplitRendBFI( - IVAS_REND_HANDLE hIvasRend, - const int16_t bfi); + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const int16_t bfi /* i : Bad Frame Indicator */ +); #endif ivas_error IVAS_REND_SetExternalOrientation( diff --git a/lib_util/audio_file_reader.c b/lib_util/audio_file_reader.c index 4f6bd0c34d..72aefd39ea 100644 --- a/lib_util/audio_file_reader.c +++ b/lib_util/audio_file_reader.c @@ -34,7 +34,7 @@ #include "tinywavein_c.h" #include #include -#include "wmc_auto.h" + struct AudioFileReader { diff --git a/lib_util/audio_file_writer.c b/lib_util/audio_file_writer.c index 0ed64d02c5..2f2bce5bd8 100644 --- a/lib_util/audio_file_writer.c +++ b/lib_util/audio_file_writer.c @@ -34,7 +34,6 @@ #include "tinywaveout_c.h" #include #include -#include "wmc_auto.h" struct AudioFileWriter { diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 6507684579..4f5cf46d0f 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -31,12 +31,13 @@ *******************************************************************************************************/ #include "hrtf_file_reader.h" +#include #include -#include "prot.h" +#include #include "ivas_prot_rend.h" - #include "ivas_prot.h" + /*---------------------------------------------------------------------* * Local structures *---------------------------------------------------------------------*/ @@ -916,16 +917,21 @@ static ivas_error create_HRTF_from_rawdata( static ivas_error create_fastconv_HRTF_from_rawdata( - HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ - char *hrtf_data, /* i : pointer to binary file */ - RENDERER_TYPE rend_type, /* i : Renderer type */ - BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ + HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ + char *hrtf_data, /* i : pointer to binary file */ + RENDERER_TYPE rend_type, /* i : Renderer type */ + BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ ) { int16_t i, j; char *hrtf_data_rptr; + ivas_error error; + ( *hHRTF )->allocate_init_flag = 0; - ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, rend_type, ( *hHRTF )->allocate_init_flag ); + if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, rend_type, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) + { + return error; + } hrtf_data_rptr = hrtf_data; diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 5fda0fcc3c..1aeb500558 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -32,7 +32,6 @@ #include "masa_file_reader.h" #include "ivas_prot.h" -#include "ivas_stat_com.h" #include #include diff --git a/lib_util/masa_file_writer.c b/lib_util/masa_file_writer.c index 8b063fe282..aa07093a3e 100644 --- a/lib_util/masa_file_writer.c +++ b/lib_util/masa_file_writer.c @@ -31,9 +31,7 @@ *******************************************************************************************************/ #include "masa_file_writer.h" -#include "ivas_stat_com.h" #include "ivas_stat_dec.h" -#include "ivas_cnst.h" #include #include #include diff --git a/lib_util/mime_io.c b/lib_util/mime_io.c index b5c257bb49..cb70839b08 100644 --- a/lib_util/mime_io.c +++ b/lib_util/mime_io.c @@ -33,9 +33,9 @@ #include "mime_io.h" #include "mime.h" #include "prot.h" -#include "string.h" #include #include +#include #include diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index a1d778980d..56f9daf8e9 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -45,7 +45,6 @@ *------------------------------------------------------------------------------------------*/ #define MAX_ITEM_LENGTH ( 64 ) -#define N_ABS_COEFFS ( 6 ) #define SHORTEST_REV_DEL_LINE ( 0.015f ) #define N_BANDS_MIN ( 2 ) @@ -89,11 +88,11 @@ typedef enum _FREQ_GRID_MODE typedef struct { - uint16_t use_er; /* Activation Flag */ - IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ - float pAbsCoeff[N_ABS_COEFFS]; /* Absorption coeffs table */ - IVAS_VECTOR3 *pListenerOrigin; /* Listener origin */ - uint32_t lowComplexity; /* Low complexity mode flag */ + uint16_t use_er; /* Activation Flag */ + IVAS_VECTOR3 dimensions; /* Room dimensions [m] */ + float pAbsCoeff[IVAS_ROOM_ABS_COEFF]; /* Absorption coeffs table */ + IVAS_VECTOR3 *pListenerOrigin; /* Listener origin */ + uint32_t lowComplexity; /* Low complexity mode flag */ } EarlyReflectionsConfig; typedef struct @@ -408,14 +407,17 @@ const float defaultFrequencyGrid_8[] = { 5800.0f, 7000.0f, 8500.0f, 10500.0f, 13500.0f }; + /*-----------------------------------------------------------------------------------------* * Function read_bin_bits() + * * Reads a given number of bits from the bitstream *-----------------------------------------------------------------------------------------*/ + static ivas_error read_bin_bits( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - uint32_t *pTarget, /* o : Target read data pointer */ - const size_t nBits /* i : Number of bits to read */ + RenderConfigReader *this, /* i/o: Renderer config reader handle */ + uint32_t *pTarget, /* o : Target read data pointer */ + const size_t nBits /* i : Number of bits to read */ ) { uint8_t n; @@ -445,25 +447,31 @@ static ivas_error read_bin_bits( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function read_bin_bool() + * * Reads a boolean value from a bitstream *-----------------------------------------------------------------------------------------*/ + static ivas_error read_bin_bool( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - uint32_t *pResult /* o : Target read data pointer */ + RenderConfigReader *this, /* i/o: Renderer config reader handle */ + uint32_t *pResult /* o : Target read data pointer */ ) { return read_bin_bits( this, pResult, 1 ); } + /*-----------------------------------------------------------------------------------------* * Function get_bin_id() + * * Reads an ID from a bitstream *-----------------------------------------------------------------------------------------*/ + static ivas_error get_bin_id( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - uint32_t *pResult /* o : Target read data pointer */ + RenderConfigReader *this, /* i/o: Renderer config reader handle */ + uint32_t *pResult /* o : Target read data pointer */ ) { ivas_error error; @@ -496,14 +504,17 @@ static ivas_error get_bin_id( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function read_bin_code_word() + * * Reads a code word from a LUT *-----------------------------------------------------------------------------------------*/ + static ivas_error read_bin_code_word( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - const RC_LUT table, /* i : Table enum */ - float *pResult /* o : Code value */ + RenderConfigReader *this, /* i/o: Renderer config reader handle */ + const RC_LUT table, /* i : Table enum */ + float *pResult /* o : Code value */ ) { ivas_error error; @@ -648,13 +659,16 @@ static ivas_error read_bin_code_word( return IVAS_ERR_INVALID_RENDER_CONFIG; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_count_or_index() + * * Gets a count or index *-----------------------------------------------------------------------------------------*/ + static ivas_error get_bin_count_or_index( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - uint32_t *pResult /* o : Count or index value */ + RenderConfigReader *this, /* i/o: Renderer config reader handle */ + uint32_t *pResult /* o : Count or index value */ ) { ivas_error error; @@ -689,13 +703,16 @@ static ivas_error get_bin_count_or_index( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_duration() + * * Gets a duration value *-----------------------------------------------------------------------------------------*/ + static ivas_error get_bin_duration( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - float *pResult /* o : Duration value */ + RenderConfigReader *this, /* i/o: Renderer config reader handle */ + float *pResult /* o : Duration value */ ) { ivas_error error; @@ -760,13 +777,16 @@ static ivas_error get_bin_duration( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_frequency() + * * Gets a frequency value *-----------------------------------------------------------------------------------------*/ + static ivas_error get_bin_frequency( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - float *pResult /* o : Frequency value */ + RenderConfigReader *this, /* i/o: Renderer config reader handle */ + float *pResult /* o : Frequency value */ ) { ivas_error error; @@ -795,16 +815,20 @@ static ivas_error get_bin_frequency( *pResult *= powf( 2.0f, ( (float) refine + 1.0f ) / 51.0f ); } + return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_dsr() + * * Gets a DSR value *-----------------------------------------------------------------------------------------*/ + static ivas_error get_bin_dsr( - RenderConfigReader *this, /* i/o : Renderer config reader handle */ - float *pResult /* o : DSR value */ + RenderConfigReader *this, /* i/o: Renderer config reader handle */ + float *pResult /* o : DSR value */ ) { ivas_error error; @@ -819,15 +843,17 @@ static ivas_error get_bin_dsr( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_distance() + * * Gets a distance value (in meters) *-----------------------------------------------------------------------------------------*/ static ivas_error get_bin_distance( - RenderConfigReader *this, /* i/o : Render config reader handle */ - uint16_t isSmall, /* i : Flag indicating a small distance */ - float *pResult /* o : Distance value */ + RenderConfigReader *this, /* i/o: Render config reader handle */ + uint16_t isSmall, /* i : Flag indicating a small distance */ + float *pResult /* o : Distance value */ ) { ivas_error error; @@ -898,14 +924,16 @@ static ivas_error get_bin_distance( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_absorption() + * * Gets an absorption value *-----------------------------------------------------------------------------------------*/ static ivas_error get_bin_absorption( - RenderConfigReader *this, /* i/o : Render config reader handle */ - float *pResult /* o : Absorption value */ + RenderConfigReader *this, /* i/o: Render config reader handle */ + float *pResult /* o : Absorption value */ ) { ivas_error error; @@ -918,10 +946,13 @@ static ivas_error get_bin_absorption( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function read_txt_bool() + * * Reads a boolean value from a line *-----------------------------------------------------------------------------------------*/ + static ivas_error read_txt_bool( const char *pLine, /* i : String to read from */ uint32_t *pTarget /* o : Output pointer */ @@ -944,16 +975,20 @@ static ivas_error read_txt_bool( *pTarget = FALSE; return IVAS_ERR_OK; } + return IVAS_ERR_INVALID_RENDER_CONFIG; } + + /*-----------------------------------------------------------------------------------------* * Function get_bin_angle() + * * Gets an angle value in degrees [0,360] *-----------------------------------------------------------------------------------------*/ static ivas_error get_bin_angle( - RenderConfigReader *this, /* i/o : Render config reader handle */ - float *pResult /* o : Angle value */ + RenderConfigReader *this, /* i/o: Render config reader handle */ + float *pResult /* o : Angle value */ ) { ivas_error error; @@ -969,14 +1004,16 @@ static ivas_error get_bin_angle( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_outer_attenuation () + * * Gets an outer attenuation value [3.1623e-05,1.0], or in dB: [-90,0] *-----------------------------------------------------------------------------------------*/ static ivas_error get_bin_outer_attenuation( - RenderConfigReader *this, /* i/o : Render config reader handle */ - float *pResult /* o : Attenuation value */ + RenderConfigReader *this, /* i/o: Render config reader handle */ + float *pResult /* o : Attenuation value */ ) { ivas_error error; @@ -1669,7 +1706,7 @@ static ivas_error RenderConfigReader_readBinary( return error; } - for ( k = 0; k < N_ABS_COEFFS; k++ ) + for ( k = 0; k < IVAS_ROOM_ABS_COEFF; k++ ) { if ( ( error = get_bin_absorption( pRenderConfigReader, &pRenderConfigReader->pAE[n].pEarlyReflections->pAbsCoeff[k] ) ) != IVAS_ERR_OK ) { @@ -1840,7 +1877,7 @@ ivas_error RenderConfigReader_read( uint32_t acIdx; uint32_t defGridId, defGridLen, defGridOffset, defGridNrBands; const float *pDefGrid; - float erTemp[N_ABS_COEFFS]; + float erTemp[IVAS_ROOM_ABS_COEFF]; uint32_t roomAcHasFgCount, roomAcHasAcEnvCount; uint32_t fgHasMethod, fgHasNBands, fgHasFreqs, fgHasDefaultGrid, fgHasStartFreq, fgHasFreqHop; uint32_t aeHasFgIdx, aeHasPredelay, aeHasRt60, aeHasDsr; @@ -2351,12 +2388,12 @@ ivas_error RenderConfigReader_read( #endif return IVAS_ERR_INVALID_RENDER_CONFIG; } - if ( read_txt_vector( pValue, N_ABS_COEFFS, erTemp ) ) + if ( read_txt_vector( pValue, IVAS_ROOM_ABS_COEFF, erTemp ) ) { errorHandler( item, ERROR_VALUE_INVALID ); return IVAS_ERR_INVALID_RENDER_CONFIG; } - for ( i = 0; i < N_ABS_COEFFS; i++ ) + for ( i = 0; i < IVAS_ROOM_ABS_COEFF; i++ ) { pRenderConfigReader->pAE[acIdx].pEarlyReflections->pAbsCoeff[i] = erTemp[i]; } diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index 19721f49ba..17252af2b6 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -34,7 +34,7 @@ #include #include #include -#include "prot.h" +#include struct RotFileReader diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index 66f0a17ece..b8932525da 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -30,14 +30,12 @@ *******************************************************************************************************/ -#include -#include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "split_rend_bfi_file_reader.h" -#include +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include #include -#include -#include "prot.h" +#include + struct SplitRendBFIFileReader { diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 1a08a69297..7415c34288 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -30,17 +30,13 @@ *******************************************************************************************************/ -#include -#include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "split_render_file_read_write.h" -#include +#ifdef SPLIT_REND_WITH_HEAD_ROT +#include #include #include #include -#include "cmdl_tools.h" -#include "prot.h" -#include "ivas_cnst.h" +#include "ivas_error_utils.h" /*------------------------------------------------------------------------------------------* diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c index 9e03358b91..b26d586943 100644 --- a/lib_util/vector3_pair_file_reader.c +++ b/lib_util/vector3_pair_file_reader.c @@ -35,8 +35,6 @@ #include #include #include -#include "prot.h" -#include "options.h" /* only included to get access to the feature-defines */ struct Vector3PairFileReader @@ -52,8 +50,8 @@ struct Vector3PairFileReader *-----------------------------------------------------------------------*/ ivas_error Vector3PairFileReader_open( - const char *trajFilePath, /* i : trajectory file name */ - Vector3PairFileReader **vector3PairReader /* o : Vector3PairFileReader handle */ + const char *trajFilePath, /* i : trajectory file name */ + Vector3PairFileReader **vector3PairReader /* o : Vector3PairFileReader handle */ ) { Vector3PairFileReader *self; -- GitLab From c3483e2b33ce36df5f4ab749a60a18b443ee8bca Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 09:43:39 +0200 Subject: [PATCH 02/52] clang-format --- lib_dec/ivas_jbm_dec.c | 82 +++++++++++++++++++++--------------------- lib_rend/lib_rend.c | 2 +- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 72ef52eb1f..aabfbedffe 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -844,9 +844,9 @@ void ivas_jbm_dec_feed_tc_to_renderer( ( #endif st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + st_ivas->renderer_type == RENDERER_OSBA_AMBI || + st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL #ifdef SPLIT_REND_WITH_HEAD_ROT ) && @@ -1068,9 +1068,9 @@ ivas_error ivas_jbm_dec_render( { if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { - return error; + return error; + } } - } else { #endif @@ -1298,7 +1298,7 @@ ivas_error ivas_jbm_dec_render( #endif #if ( defined NONBE_UNIFIED_DECODING_PATHS && defined SPLIT_REND_WITH_HEAD_ROT ) - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, @@ -1306,13 +1306,13 @@ ivas_error ivas_jbm_dec_render( #endif - { - return error; - } + { + return error; + } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); #ifdef SPLIT_REND_WITH_HEAD_ROT - } + } #endif } else if ( st_ivas->renderer_type == RENDERER_MC ) @@ -1331,8 +1331,8 @@ ivas_error ivas_jbm_dec_render( { if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { - return error; - } + return error; + } } else { @@ -1342,11 +1342,11 @@ ivas_error ivas_jbm_dec_render( return error; } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output ); #ifdef SPLIT_REND_WITH_HEAD_ROT - } + } #endif - } + } } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { @@ -1384,8 +1384,8 @@ ivas_error ivas_jbm_dec_render( { if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) { - return error; - } + return error; + } } else { @@ -1395,11 +1395,11 @@ ivas_error ivas_jbm_dec_render( return error; } - ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output ); #ifdef SPLIT_REND_WITH_HEAD_ROT - } + } #endif - } + } } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { @@ -2497,27 +2497,27 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( else { #endif - if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); - } - set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } + set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); - offset = 0; - for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_full; - } - for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; - offset += n_samp_residual; - } - for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = NULL; - } + offset = 0; + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_full; + } + for ( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; + offset += n_samp_residual; + } + for ( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + { + hTcBuffer->tc[ch_idx] = NULL; + } #ifdef NONBE_UNIFIED_DECODING_PATHS } #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index adb0ceb7d6..4cb3daee59 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8809,7 +8809,7 @@ static ivas_error getSamplesInternal( convertBitsBufferToInternalBitsBuff( *hBits, &bits ); if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 62e6961831fca4d3ebee1916fd72faf9cf57f558 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 10:17:12 +0200 Subject: [PATCH 03/52] fix SR build --- lib_rend/ivas_lcld_prot.h | 2 -- lib_rend/ivas_stat_rend.h | 2 ++ lib_util/split_rend_bfi_file_reader.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_lcld_prot.h b/lib_rend/ivas_lcld_prot.h index 92673a0c43..ad35e50f00 100644 --- a/lib_rend/ivas_lcld_prot.h +++ b/lib_rend/ivas_lcld_prot.h @@ -37,8 +37,6 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT #include "lib_rend.h" #include "ivas_lcld_rom_tables.h" -#include "ivas_lc3plus_enc.h" -#include "ivas_lc3plus_dec.h" /* clang-format off */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 86b4ed2adb..24259bd2ce 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -41,6 +41,8 @@ #include "common_api_types.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include "ivas_lcld_prot.h" +#include "ivas_lc3plus_enc.h" +#include "ivas_lc3plus_dec.h" #endif diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index b8932525da..20edee4d43 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -34,6 +34,7 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT #include #include +#include #include -- GitLab From 2d1d917e9cbe4e0e6134efd1d54b2435347f593e Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 10:58:02 +0200 Subject: [PATCH 04/52] fix Cmake build warnings --- lib_rend/ivas_lc3plus_common.c | 3 +-- lib_rend/ivas_lc3plus_dec.c | 8 ++++---- lib_rend/ivas_lc3plus_enc.c | 4 ++-- lib_util/split_rend_bfi_file_reader.c | 2 +- lib_util/split_render_file_read_write.c | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib_rend/ivas_lc3plus_common.c b/lib_rend/ivas_lc3plus_common.c index db33f9861f..458e6afd44 100644 --- a/lib_rend/ivas_lc3plus_common.c +++ b/lib_rend/ivas_lc3plus_common.c @@ -30,10 +30,9 @@ *******************************************************************************************************/ +#include #include "options.h" #include "ivas_lc3plus_common.h" -#include "ivas_error.h" -#include "lc3.h" #ifdef SPLIT_REND_WITH_HEAD_ROT /*-----------------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_lc3plus_dec.c b/lib_rend/ivas_lc3plus_dec.c index 5dfdb9cec7..26880b24ce 100644 --- a/lib_rend/ivas_lc3plus_dec.c +++ b/lib_rend/ivas_lc3plus_dec.c @@ -35,8 +35,6 @@ #include "prot.h" #include "ivas_prot.h" #include "ivas_lc3plus_dec.h" -#include "ivas_lc3plus_common.h" -#include "lc3.h" #include "ivas_error_utils.h" #include "wmc_auto.h" @@ -49,8 +47,8 @@ *------------------------------------------------------------------------*/ ivas_error IVAS_LC3PLUS_DEC_Open( - const LC3PLUS_CONFIG config, /* i : LC3plus decoder configuration */ - IVAS_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ + const LC3PLUS_CONFIG config, /* i : LC3plus decoder configuration */ + IVAS_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ ) { LC3PLUS_Error err; @@ -612,9 +610,11 @@ static ivas_error IVAS_LC3PLUS_DEC_Decode_or_Conceal_internal( { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "bitstream_cache_capacity is too low for LC3plus frame size\n" ); } + /* store bit rate of cached frame */ mvc2c( bitstream_in_iter, handle->bitstream_caches[iDec]->bitstream_cache, (int16_t) bitstreamOffsetPerCoder ); handle->bitstream_caches[iDec]->bitstream_cache_size = bitstreamOffsetPerCoder; + /* log that this instance has skipped a frame and must decode twice once reactivated */ handle->selective_decoding_states[iDec]->has_skipped_a_frame = 1; break; diff --git a/lib_rend/ivas_lc3plus_enc.c b/lib_rend/ivas_lc3plus_enc.c index 8751d3dacc..9caaddbac7 100644 --- a/lib_rend/ivas_lc3plus_enc.c +++ b/lib_rend/ivas_lc3plus_enc.c @@ -30,9 +30,9 @@ *******************************************************************************************************/ +#include +#include "options.h" #include "ivas_lc3plus_enc.h" -#include "ivas_lc3plus_common.h" -#include "lc3.h" #include "ivas_error_utils.h" #include "prot.h" #include "wmc_auto.h" diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index 20edee4d43..031d22e931 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -31,12 +31,12 @@ *******************************************************************************************************/ #include "split_rend_bfi_file_reader.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #include #include #include +#ifdef SPLIT_REND_WITH_HEAD_ROT struct SplitRendBFIFileReader { diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 7415c34288..6350cbcd96 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -31,13 +31,13 @@ *******************************************************************************************************/ #include "split_render_file_read_write.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #include #include #include #include "ivas_error_utils.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT /*------------------------------------------------------------------------------------------* * PreProc Macros -- GitLab From 6bcac89518c0978b9d9df1a2b09942bdc917a336 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 15:28:05 +0200 Subject: [PATCH 05/52] formatting --- lib_dec/ivas_jbm_dec.c | 3 -- lib_dec/ivas_mc_paramupmix_dec.c | 50 +++++++++++++++----------------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index aabfbedffe..9c6786740d 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1296,16 +1296,13 @@ ivas_error ivas_jbm_dec_render( else { #endif - #if ( defined NONBE_UNIFIED_DECODING_PATHS && defined SPLIT_REND_WITH_HEAD_ROT ) if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) - #endif - { return error; } diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index f27e803ced..0c83e5b0d2 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -508,7 +508,6 @@ void ivas_mc_paramupmix_dec_render( hMCParamUpmix = st_ivas->hMCParamUpmix; assert( hMCParamUpmix ); - push_wmops( "ivas_mc_paramupmix_dec_render" ); for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) @@ -537,44 +536,43 @@ void ivas_mc_paramupmix_dec_render( #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif - { - for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) - { - mvr2r( hMCParamUpmix->alpha_prev[ch], hMCParamUpmix->alpha_sf[ch], IVAS_MAX_NUM_BANDS ); - mvr2r( hMCParamUpmix->beta_prev[ch], hMCParamUpmix->beta_sf[ch], IVAS_MAX_NUM_BANDS ); - } + for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) + { + mvr2r( hMCParamUpmix->alpha_prev[ch], hMCParamUpmix->alpha_sf[ch], IVAS_MAX_NUM_BANDS ); + mvr2r( hMCParamUpmix->beta_prev[ch], hMCParamUpmix->beta_sf[ch], IVAS_MAX_NUM_BANDS ); + } #ifdef SPLIT_REND_WITH_HEAD_ROT - slot_index_start = 0; + slot_index_start = 0; #endif - for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) - { - int16_t n_samples_sf = slot_size * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]; + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) + { + int16_t n_samples_sf = slot_size * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]; #ifdef SPLIT_REND_WITH_HEAD_ROT - ivas_mc_paramupmix_dec_sf( st_ivas, output_f_local, slot_index_start ); + ivas_mc_paramupmix_dec_sf( st_ivas, output_f_local, slot_index_start ); - slot_index_start += st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]; + slot_index_start += st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]; #else - ivas_mc_paramupmix_dec_sf( st_ivas, output_f_local ); + ivas_mc_paramupmix_dec_sf( st_ivas, output_f_local ); #endif - for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) - { - output_f_local[ch] += n_samples_sf; - } + + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + { + output_f_local[ch] += n_samples_sf; + } #ifdef NONBE_UNIFIED_DECODING_PATHS - /* update combined orientation access index */ - ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); + /* update combined orientation access index */ + ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); #endif - } + } - for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) - { - mvr2r( hMCParamUpmix->alphas[ch], hMCParamUpmix->alpha_prev[ch], IVAS_MAX_NUM_BANDS ); - mvr2r( hMCParamUpmix->betas[ch], hMCParamUpmix->beta_prev[ch], IVAS_MAX_NUM_BANDS ); - } + for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) + { + mvr2r( hMCParamUpmix->alphas[ch], hMCParamUpmix->alpha_prev[ch], IVAS_MAX_NUM_BANDS ); + mvr2r( hMCParamUpmix->betas[ch], hMCParamUpmix->beta_prev[ch], IVAS_MAX_NUM_BANDS ); } *nSamplesAvailable = ( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered ) * slot_size; -- GitLab From de87027054bcdc20fdd8335dfce46084d0eeec07 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 15:28:21 +0200 Subject: [PATCH 06/52] formatting --- lib_dec/ivas_jbm_dec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 9c6786740d..f44c19eb90 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1349,7 +1349,6 @@ ivas_error ivas_jbm_dec_render( { ivas_mc_paramupmix_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_tc, p_output ); - if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) { ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, *nSamplesRendered, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); -- GitLab From 1977e37dbad236a03859f09bcae8bc8ebd94b476 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 16:27:23 +0200 Subject: [PATCH 07/52] formatting, comments --- apps/renderer.c | 1 + lib_com/ivas_prot.h | 42 ++--- lib_dec/ivas_dirac_dec.c | 156 ++++--------------- lib_dec/ivas_init_dec.c | 7 +- lib_dec/ivas_ism_dec.c | 6 +- lib_dec/ivas_ism_param_dec.c | 10 +- lib_dec/ivas_jbm_dec.c | 9 +- lib_dec/ivas_mc_param_dec.c | 10 +- lib_dec/ivas_mc_paramupmix_dec.c | 6 +- lib_dec/ivas_mct_dec.c | 2 +- lib_dec/ivas_objectRenderer_internal.c | 11 +- lib_dec/ivas_omasa_dec.c | 2 +- lib_dec/ivas_osba_dec.c | 11 +- lib_dec/ivas_sba_dec.c | 12 +- lib_dec/ivas_stat_dec.h | 6 +- lib_dec/lib_dec.c | 25 ++- lib_dec/lib_dec.h | 36 ++--- lib_rend/ivas_dirac_dec_binaural_functions.c | 14 +- lib_rend/ivas_dirac_rend.c | 2 +- lib_rend/ivas_output_init.c | 2 +- lib_rend/ivas_prot_rend.h | 59 +++---- lib_rend/ivas_rotation.c | 6 +- lib_rend/ivas_stat_rend.h | 1 + lib_rend/lib_rend.c | 11 +- 24 files changed, 177 insertions(+), 270 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 7f5af747d5..d1b7193cca 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1014,6 +1014,7 @@ int main( #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif + #ifdef NONBE_UNIFIED_DECODING_PATHS const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); #else diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 73cd09d20d..91ef7a3a5d 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -788,9 +788,9 @@ ivas_error ivas_jbm_dec_tc( float *data /* o : output synthesis signals */ ); -ivas_error ivas_jbm_dec_render( +ivas_error ivas_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of samples wanted */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -826,7 +826,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( ); ivas_error ivas_jbm_dec_set_discard_samples( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ + Decoder_Struct *st_ivas /* i/o: main IVAS decoder structure */ ); void ivas_jbm_dec_get_adapted_linear_interpolator( @@ -1122,9 +1122,9 @@ void ivas_ism_param_dec_tc_gain_ajust( void ivas_param_ism_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *output_f[] /* o : rendered time signal */ ); @@ -3698,9 +3698,9 @@ void ivas_dirac_dec( void ivas_dirac_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of sampels rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *output_f[] /* o : rendered time signal */ ); @@ -3813,9 +3813,9 @@ void ivas_mc_paramupmix_dec_digest_tc( void ivas_mc_paramupmix_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *input_f[], /* i : core-coder transport channels */ float *output_f[] /* i/o: synthesized core-coder transport channels */ ); @@ -3895,9 +3895,9 @@ void ivas_param_mc_dec_digest_tc( void ivas_param_mc_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of sampes requested */ + uint16_t *nSamplesRendered, /* o : number of sampes rendered */ + uint16_t *nSamplesAvailable, /* o : number of sampes still to render */ float *output_f[] /* o : rendered time signal */ ); @@ -4371,9 +4371,9 @@ void ivas_sba_dec_digest_tc( ivas_error ivas_sba_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *output_f[] /* o : rendered time signal */ ); @@ -5695,9 +5695,9 @@ ivas_error ivas_osba_data_open( ivas_error ivas_osba_dirac_td_binaural_jbm( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *output_f[] /* o : rendered time signal */ ); diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index fb9879ede8..baba7f061f 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -951,11 +951,7 @@ ivas_error ivas_dirac_dec_config( /* Allocate transport channel buffers for SBA format when in JBM */ if ( dec_config_flag == DIRAC_OPEN ) { -#ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_5ms && st_ivas->hTcBuffer == NULL ) -#else - if ( st_ivas->hTcBuffer == NULL ) -#endif { if ( st_ivas->ivas_format == SBA_FORMAT ) { @@ -1678,12 +1674,12 @@ void ivas_dirac_dec( *------------------------------------------------------------------------*/ void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -1802,7 +1798,6 @@ void ivas_dirac_dec_render_sf( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; push_wmops( "ivas_dirac_dec_render" ); - /* Initialize aux buffers */ hDirAC = st_ivas->hDirAC; hDirACRend = st_ivas->hDirACRend; @@ -1841,8 +1836,8 @@ void ivas_dirac_dec_render_sf( sprintf( file_name, "./res/ivas_dirac_dec_DMX%d.%d.pcm", nchan_transport, (int16_t) ( output_frame * 0.05 ) ); dbgwrite( tmp, sizeof( int16_t ), nchan_transport * output_frame, 1, file_name ); } -#endif +#endif /* Subframe loop */ slot_idx_start = hSpatParamRendCom->slots_rendered; slot_idx_start_cldfb_synth = 0; @@ -1958,33 +1953,13 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 1 ) #endif { - ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, - hDirACRend, - st_ivas->hVBAPdata, - st_ivas->hMasa, - st_ivas->hMasaIsmData, - azimuth, - elevation, - md_idx, - surCohRatio, - st_ivas->hCombinedOrientationData->shd_rot_max_order, - p_Rmat, - hodirac_flag ); + ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, hDirACRend, st_ivas->hVBAPdata, st_ivas->hMasa, st_ivas->hMasaIsmData, azimuth, elevation, + md_idx, surCohRatio, st_ivas->hCombinedOrientationData->shd_rot_max_order, p_Rmat, hodirac_flag ); } else { - ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, - hDirACRend, - st_ivas->hVBAPdata, - st_ivas->hMasa, - st_ivas->hMasaIsmData, - azimuth, - elevation, - md_idx, - surCohRatio, - 0, - NULL, - hodirac_flag ); + ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, hDirACRend, st_ivas->hVBAPdata, st_ivas->hMasa, st_ivas->hMasaIsmData, azimuth, elevation, + md_idx, surCohRatio, 0, NULL, hodirac_flag ); } } @@ -1998,10 +1973,7 @@ void ivas_dirac_dec_render_sf( for ( ch = 0; ch < nchan_transport; ch++ ) { cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ), - Cldfb_RealBuffer_Temp[ch][slot_idx], - Cldfb_ImagBuffer_Temp[ch][slot_idx], - hSpatParamRendCom->num_freq_bands, - st_ivas->cldfbAnaDec[ch] ); + Cldfb_RealBuffer_Temp[ch][slot_idx], Cldfb_ImagBuffer_Temp[ch][slot_idx], hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); } } @@ -2022,6 +1994,7 @@ void ivas_dirac_dec_render_sf( { md_idx = hSpatParamRendCom->render_to_md_map[subframe_idx]; } + if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { for ( ch = 0; ch < nchan_transport; ch++ ) @@ -2044,10 +2017,7 @@ void ivas_dirac_dec_render_sf( for ( ch = 0; ch < nchan_transport; ch++ ) { cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ), - Cldfb_RealBuffer[ch][0], - Cldfb_ImagBuffer[ch][0], - hSpatParamRendCom->num_freq_bands, - st_ivas->cldfbAnaDec[ch] ); + Cldfb_RealBuffer[ch][0], Cldfb_ImagBuffer[ch][0], hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); } } @@ -2056,25 +2026,14 @@ void ivas_dirac_dec_render_sf( { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - generate_masking_noise_dirac( st->hFdCngDec->hFdCngCom, - st_ivas->cldfbAnaDec[1], - st_ivas->hTcBuffer->tc[1], - Cldfb_RealBuffer[1][0], - Cldfb_ImagBuffer[1][0], - index_slot, - st->cna_dirac_flag && st->flag_cna, - ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && st->cng_type == FD_CNG && st->cng_sba_flag ); + generate_masking_noise_dirac( st->hFdCngDec->hFdCngCom, st_ivas->cldfbAnaDec[1], st_ivas->hTcBuffer->tc[1], Cldfb_RealBuffer[1][0], Cldfb_ImagBuffer[1][0], + index_slot, st->cna_dirac_flag && st->flag_cna, ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && st->cng_type == FD_CNG && st->cng_sba_flag ); } /* LFE synthesis */ if ( st_ivas->mc_mode == MC_MODE_MCMASA && !hDirACRend->hOutSetup.separateChannelEnabled && !( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && hDirACRend->hOutSetup.num_lfe == 0 ) ) { - ivas_lfe_synth_with_cldfb( st_ivas->hMasa->hMasaLfeSynth, - Cldfb_RealBuffer, Cldfb_ImagBuffer, - Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1], Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1], - slot_idx, - md_idx, - nchan_transport ); + ivas_lfe_synth_with_cldfb( st_ivas->hMasa->hMasaLfeSynth, Cldfb_RealBuffer, Cldfb_ImagBuffer, Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1], Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1], slot_idx, md_idx, nchan_transport ); } /*-----------------------------------------------------------------* @@ -2089,30 +2048,20 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) #endif { - protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, - hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, - reference_power, slot_idx, nchan_transport, - hDirACRend->num_outputs_diff, - hSpatParamRendCom->num_freq_bands, - p_Rmat ); + protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, + reference_power, slot_idx, nchan_transport, hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands, p_Rmat ); } else { protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, - reference_power, slot_idx, nchan_transport, - hDirACRend->num_outputs_diff, - hSpatParamRendCom->num_freq_bands, - 0 ); + reference_power, slot_idx, nchan_transport, hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands, 0 ); } } else if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_MONO ) { - protoSignalComputation2( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->proto_frame_f, - hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, - reference_power, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, + protoSignalComputation2( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->proto_frame_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, reference_power, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, 0, slot_idx, hSpatParamRendCom->num_freq_bands, hDirACRend->masa_stereo_type_detect ); } else @@ -2247,7 +2196,6 @@ void ivas_dirac_dec_render_sf( } } #endif - /*-----------------------------------------------------------------* * frequency domain decorrelation *-----------------------------------------------------------------*/ @@ -2325,39 +2273,13 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) #endif { - ivas_dirac_dec_output_synthesis_process_slot( reference_power, - p_onset_filter, - azimuth, - elevation, - hSpatParamRendCom->diffuseness_vector[md_idx], - hSpatParamRendCom, - hDirACRend, - st_ivas->hCombinedOrientationData->shd_rot_max_order, - p_Rmat, - st_ivas->hVBAPdata, - hDirACRend->hOutSetup, - nchan_transport, - md_idx, - hodirac_flag, - hDirAC->hConfig->dec_param_estim ); + ivas_dirac_dec_output_synthesis_process_slot( reference_power, p_onset_filter, azimuth, elevation, hSpatParamRendCom->diffuseness_vector[md_idx], hSpatParamRendCom, hDirACRend, st_ivas->hCombinedOrientationData->shd_rot_max_order, + p_Rmat, st_ivas->hVBAPdata, hDirACRend->hOutSetup, nchan_transport, md_idx, hodirac_flag, hDirAC->hConfig->dec_param_estim ); } else { - ivas_dirac_dec_output_synthesis_process_slot( reference_power, - p_onset_filter, - azimuth, - elevation, - hSpatParamRendCom->diffuseness_vector[md_idx], - hSpatParamRendCom, - hDirACRend, - 0, - 0, - st_ivas->hVBAPdata, - hDirACRend->hOutSetup, - nchan_transport, - md_idx, - hodirac_flag, - hDirAC->hConfig->dec_param_estim ); + ivas_dirac_dec_output_synthesis_process_slot( reference_power, p_onset_filter, azimuth, elevation, hSpatParamRendCom->diffuseness_vector[md_idx], hSpatParamRendCom, hDirACRend, + 0, 0, st_ivas->hVBAPdata, hDirACRend->hOutSetup, nchan_transport, md_idx, hodirac_flag, hDirAC->hConfig->dec_param_estim ); } if ( hDirAC->hConfig->dec_param_estim ) @@ -2374,19 +2296,10 @@ void ivas_dirac_dec_render_sf( ivas_dirac_dec_output_synthesis_get_interpolator( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); - if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( Cldfb_RealBuffer, - Cldfb_ImagBuffer, - hSpatParamRendCom, - hDirACRend, - nchan_transport, - hSpatParamRendCom->subframe_nbslots[subframe_idx], - p_onset_filter, - diffuseness_vector, - hodirac_flag, - hDirAC->hConfig->dec_param_estim ); + ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, hSpatParamRendCom, hDirACRend, nchan_transport, + hSpatParamRendCom->subframe_nbslots[subframe_idx], p_onset_filter, diffuseness_vector, hodirac_flag, hDirAC->hConfig->dec_param_estim ); } else { @@ -2399,15 +2312,8 @@ void ivas_dirac_dec_render_sf( qualityBasedSmFactor *= qualityBasedSmFactor; } - ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( Cldfb_RealBuffer, - Cldfb_ImagBuffer, - hSpatParamRendCom, - hDirACRend, - hSpatParamRendCom->subframe_nbslots[subframe_idx], - diffuseness_vector, - reference_power_smooth, - qualityBasedSmFactor, - hDirAC->hConfig->enc_param_start_band ); + ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( Cldfb_RealBuffer, Cldfb_ImagBuffer, hSpatParamRendCom, hDirACRend, hSpatParamRendCom->subframe_nbslots[subframe_idx], + diffuseness_vector, reference_power_smooth, qualityBasedSmFactor, hDirAC->hConfig->enc_param_start_band ); } /*-----------------------------------------------------------------* @@ -2524,7 +2430,6 @@ void ivas_dirac_dec_render_sf( #ifdef SPLIT_REND_WITH_HEAD_ROT &st_ivas->hSplitBinRend.splitrend.multiBinPoseData, #endif - st_ivas->hCombinedOrientationData, #ifndef NONBE_UNIFIED_DECODING_PATHS subframe_idx, @@ -2534,6 +2439,7 @@ void ivas_dirac_dec_render_sf( NULL, #endif Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, Cldfb_RealBuffer, Cldfb_ImagBuffer ); + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { @@ -2702,10 +2608,10 @@ void ivas_dirac_dec_render_sf( } } } + hSpatParamRendCom->slots_rendered += hSpatParamRendCom->subframe_nbslots[subframe_idx]; hSpatParamRendCom->subframes_rendered++; pop_wmops(); - return; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index cdba09af5b..32cb144fe7 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2173,7 +2173,6 @@ ivas_error ivas_init_decoder( #else if ( st_ivas->hTcBuffer == NULL ) #endif - { /* no module has yet open the TC buffer, open a default one */ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); @@ -2205,7 +2204,7 @@ ivas_error ivas_init_decoder( } /*-----------------------------------------------------------------* - * Allocate floating-point output audio buffers + * Allocate 'float' output audio buffers *-----------------------------------------------------------------*/ #ifndef NONBE_UNIFIED_DECODING_PATHS @@ -2482,7 +2481,7 @@ void ivas_initialize_handles_dec( st_ivas->hTcBuffer = NULL; st_ivas->hJbmMetadata = NULL; - /* floating-point output audio buffers */ + /* 'float' output audio buffers */ for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { st_ivas->p_output_f[i] = NULL; @@ -2720,7 +2719,7 @@ void ivas_destroy_dec( st_ivas->hJbmMetadata = NULL; } - /* floating-point output audio buffers */ + /* 'float' output audio buffers */ for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { if ( st_ivas->p_output_f[i] != NULL ) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 0064df713c..baf5dc8258 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -321,20 +321,22 @@ static ivas_error ivas_ism_bitrate_switching_dec( } /*-----------------------------------------------------------------* - * floating-point output audio buffers + * 'float' output audio buffers *-----------------------------------------------------------------*/ #ifndef NONBE_UNIFIED_DECODING_PATHS if ( !st_ivas->hDecoderConfig->Opt_5ms ) -#endif { +#endif nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) { return error; } +#ifndef NONBE_UNIFIED_DECODING_PATHS } +#endif /*-----------------------------------------------------------------* * JBM TC buffers diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 9932d3083e..114e45f6bc 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1415,11 +1415,11 @@ static void ivas_ism_param_dec_render_sf( *-------------------------------------------------------------------------*/ void ivas_param_ism_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t ch, slots_to_render, first_sf, last_sf, subframe_idx; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index f44c19eb90..a1c6bf386f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -778,7 +778,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( p_data_f[n] = &data_f[n][0]; } - #ifndef NONBE_UNIFIED_DECODING_PATHS if ( st_ivas->hDecoderConfig->Opt_tsm || !st_ivas->hDecoderConfig->Opt_5ms ) #else @@ -917,12 +916,12 @@ void ivas_jbm_dec_feed_tc_to_renderer( /*--------------------------------------------------------------------------* * ivas_dec_render() * - * Principal IVAS JBM rendering routine + * Principal IVAS rendering routine *--------------------------------------------------------------------------*/ -ivas_error ivas_jbm_dec_render( +ivas_error ivas_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of samples wanted */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1812,7 +1811,7 @@ ivas_error ivas_jbm_dec_flush_renderer( *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_set_discard_samples( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ + Decoder_Struct *st_ivas /* i/o: main IVAS decoder structure */ ) { int16_t nMaxSlotsPerSubframe, nSlotsInFirstSubframe; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index ed3d99e690..24a3e3f3c9 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1580,11 +1580,11 @@ void ivas_param_mc_dec_digest_tc( *------------------------------------------------------------------------*/ void ivas_param_mc_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still to render */ + float *output_f[] /* o : rendered time signal */ ) { PARAM_MC_DEC_HANDLE hParamMC; diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 0c83e5b0d2..c3072aa43f 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -491,9 +491,9 @@ void ivas_mc_paramupmix_dec_digest_tc( void ivas_mc_paramupmix_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *input_f[], /* i : core-coder transport channels */ float *output_f[] /* i/o: synthesized core-coder transport channels */ ) diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 934b1184bb..9c15e4094a 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1392,7 +1392,7 @@ static ivas_error ivas_mc_dec_reconfig( /*-----------------------------------------------------------------* - * floating-point output audio buffers + * 'float' output audio buffers *-----------------------------------------------------------------*/ #ifndef NONBE_UNIFIED_DECODING_PATHS diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index ce71f1307a..dec09459db 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -321,15 +321,8 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( continue; } - if ( ( error = ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, - st_ivas->hDecoderConfig->output_Fs, - st_ivas->nchan_transport, - st_ivas->ivas_format, - st_ivas->transport_config, - st_ivas->hRenderConfig->directivity, - st_ivas->hTransSetup, - &st_ivas->hSplitBinRend.splitrend.hTdRendHandles[i], - &st_ivas->binaural_latency_ns ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, st_ivas->ivas_format, st_ivas->transport_config, + st_ivas->hRenderConfig->directivity, st_ivas->hTransSetup, &st_ivas->hSplitBinRend.splitrend.hTdRendHandles[i], &st_ivas->binaural_latency_ns ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 009b336534..3257b424a4 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -397,7 +397,7 @@ ivas_error ivas_omasa_dec_config( } /*-----------------------------------------------------------------* - * floating-point output audio buffers + * 'float' output audio buffers *-----------------------------------------------------------------*/ #ifndef NONBE_UNIFIED_DECODING_PATHS diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 9c8f2a5b86..5123c8b085 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -125,11 +125,11 @@ void ivas_osba_data_close( *--------------------------------------------------------------------------*/ ivas_error ivas_osba_dirac_td_binaural_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t n; @@ -140,7 +140,6 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( return error; } - #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 9108dc19ee..e52556ea79 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -671,7 +671,7 @@ ivas_error ivas_sba_dec_reconfigure( } /*-----------------------------------------------------------------* - * floating-point output audio buffers + * 'float' output audio buffers *-----------------------------------------------------------------*/ #ifndef NONBE_UNIFIED_DECODING_PATHS @@ -787,11 +787,11 @@ void ivas_sba_dec_digest_tc( *-------------------------------------------------------------------*/ ivas_error ivas_sba_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4b0135f3af..e58d4a05d1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1010,12 +1010,12 @@ typedef struct decoder_config_structure /* temp. development parameters */ int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ #endif - int16_t Opt_tsm; + int16_t Opt_tsm; /* indicates whether tami scaling is active */ #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t Opt_Limiter; #endif #ifdef NONBE_UNIFIED_DECODING_PATHS - IVAS_RENDER_FRAMESIZE render_framesize; + IVAS_RENDER_FRAMESIZE render_framesize; /* rendering frame size */ #else int16_t Opt_5ms; #endif @@ -1061,7 +1061,7 @@ typedef struct Decoder_Struct float **mem_hp20_out; /* output signals HP filter memories */ IVAS_LIMITER_HANDLE hLimiter; /* Limiter handle */ - float *p_output_f[MAX_OUTPUT_CHANNELS+MAX_NUM_OBJECTS]; /* floating-point output audio buffers */ + float *p_output_f[MAX_OUTPUT_CHANNELS+MAX_NUM_OBJECTS]; /* 'floating' output audio buffers */ /* core-decoder modules */ int16_t nSCE; /* number of total SCEs */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index f609470a96..19d9de4bd8 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -961,7 +961,7 @@ static ivas_error _GetSamples( ivas_error IVAS_DEC_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ + const int16_t nSamplesAsked, /* i : number of samples requested */ #ifdef SPLIT_REND_WITH_HEAD_ROT const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ void *pcmBuf, /* o : output synthesis signal */ @@ -1486,7 +1486,7 @@ static ivas_error IVAS_DEC_GetTcSamples( static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ + const int16_t nSamplesForRendering, /* i : number of TC samples requested from the renderer */ int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call */ float *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 */ ) @@ -1515,7 +1515,7 @@ static ivas_error IVAS_DEC_RendererFeedTcSamples( static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ + const uint16_t nSamplesForRendering, /* i : number of TC samples requested from the renderer */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renerer pipeline */ #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1538,9 +1538,9 @@ static ivas_error IVAS_DEC_GetRenderedSamples( /* run the main IVAS decoding routine */ #ifdef SPLIT_REND_WITH_HEAD_ROT - error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); + error = ivas_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); #else - error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcmBuf ); + error = ivas_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcmBuf ); #endif return error; @@ -2560,8 +2560,8 @@ 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 */ #ifdef SPLIT_REND_WITH_HEAD_ROT - IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf, + IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* i/o: buffer for decoded PCM output. */ #else 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 */ #endif @@ -2758,8 +2758,8 @@ ivas_error IVAS_DEC_Flush( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf, + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* i/o: buffer for decoded PCM output. */ #else 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 */ #endif @@ -2771,11 +2771,9 @@ ivas_error IVAS_DEC_Flush( uint16_t nSamplesFlushedLocal; *nSamplesFlushed = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); - nSamplesToRender = (uint16_t) *nSamplesFlushed; /* render IVAS frames */ - #ifdef SPLIT_REND_WITH_HEAD_ROT error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); #else @@ -2793,8 +2791,9 @@ ivas_error IVAS_DEC_Flush( *---------------------------------------------------------------------*/ bool IVAS_DEC_VoIP_IsEmpty( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked ) + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesAsked /* i : number of samples requested */ +) { return ( ( JB4_bufferedDataUnits( hIvasDec->hVoIP->hJBM ) == 0 ) && ( hIvasDec->nSamplesAvailableNext < nSamplesAsked ) ); } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 11aa3917ef..65d43e0742 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -161,7 +161,7 @@ ivas_error IVAS_DEC_FeedFrame_Serial( /*! r: decoder error code */ ivas_error IVAS_DEC_GetSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ + const int16_t nSamplesAsked, /* i : number of samples requested */ #ifdef SPLIT_REND_WITH_HEAD_ROT const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ void *pcmBuf, /* o : output synthesis signal */ @@ -271,8 +271,8 @@ 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 */ #ifdef SPLIT_REND_WITH_HEAD_ROT - IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf, + IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* i/o: buffer for decoded PCM output. */ #else 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 */ #endif @@ -287,8 +287,8 @@ ivas_error IVAS_DEC_Flush( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ #ifdef SPLIT_REND_WITH_HEAD_ROT - const IVAS_DEC_PCM_TYPE pcmType, - void *pcmBuf, + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* i/o: buffer for decoded PCM output. */ #else 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 */ #endif @@ -323,33 +323,33 @@ ivas_error IVAS_DEC_Get5msFlag( ); #else ivas_error IVAS_DEC_SetRenderFramesize( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_RENDER_FRAMESIZE render_framesize /* i : render framesize */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_FRAMESIZE render_framesize/* i : render framesize */ ); ivas_error IVAS_DEC_GetRenderFramesize( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */ ); ivas_error IVAS_DEC_GetRenderFramesizeSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *render_framesize /* o : render framesize in samples */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *render_framesize /* o : render framesize in samples */ ); ivas_error IVAS_DEC_GetReferencesUpdateFrequency( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *update_frequency /* o : update frequency */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *update_frequency /* o : update frequency */ ); ivas_error IVAS_DEC_GetNumOrientationSubframes( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *num_subframes /* o : render framesize */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *num_subframes /* o : render framesize */ ); ivas_error IVAS_DEC_GetRenderFramesizeMs( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint32_t *render_framesize /* o : render framesize in samples */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint32_t *render_framesize /* o : render framesize in samples */ ); #endif @@ -476,7 +476,7 @@ ivas_error IVAS_DEC_GetPcmFrameSize( /*! r: true if decoder has no data in VoIP jitter buffer */ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesAsked + const int16_t nSamplesAsked /* i : number of samples requested */ ); ivas_error IVAS_DEC_VoIP_Get_CA_offset( diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index e1959a846f..0112a9383d 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -323,6 +323,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } + return IVAS_ERR_OK; } @@ -430,12 +431,12 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( *------------------------------------------------------------------------*/ void ivas_dirac_dec_binaural_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - const int16_t nchan_transport, /* i : number of transport channels */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -622,6 +623,7 @@ void ivas_dirac_dec_binaural( } #ifdef NONBE_UNIFIED_DECODING_PATHS + /* update combined orientation access index */ ivas_combined_orientation_update_index( hCombinedOrientationData, n_samples_sf ); #endif diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 491e9c36b6..c5cb14a97e 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -54,7 +54,7 @@ ivas_error ivas_dirac_allocate_parameters( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering */ - const int16_t params_flag /* i : set of parameters flag */ + const int16_t params_flag /* i : set of parameters flag */ ) { int16_t i; diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 7f4301cc2e..30e4bd9f88 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -412,7 +412,7 @@ int16_t ivas_get_nchan_buffers_dec( /*-------------------------------------------------------------------* * ivas_output_buff_dec() * - * Allocate/reallocate output audio buffers + * Allocate/reallocate 'float' output audio buffers *-------------------------------------------------------------------*/ ivas_error ivas_output_buff_dec( diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 75fcdfa041..c12051c048 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -46,13 +46,14 @@ * General renderer declarations *----------------------------------------------------------------------------------*/ +/*! r: audio configuration type */ IVAS_REND_AudioConfigType getAudioConfigType( - const AUDIO_CONFIG config + const AUDIO_CONFIG config /* i : audio configuration */ ); ivas_error getAudioConfigNumChannels( - const AUDIO_CONFIG config, - int16_t *numChannels + const AUDIO_CONFIG config, /* i : audio configuration */ + int16_t *numChannels /* o : number of audio channels */ ); @@ -77,19 +78,19 @@ int16_t ivas_get_nchan_buffers_dec( const int32_t ivas_total_brate /* i : total IVAS bitrate */ ); + /*----------------------------------------------------------------------------------* * Limiter prototypes *----------------------------------------------------------------------------------*/ - ivas_error ivas_limiter_open( - IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ - const int16_t num_channels, /* i : number of I/O channels */ - const int32_t sampling_rate /* i : sampling rate for processing */ + IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ + const int16_t num_channels, /* i : number of I/O channels */ + const int32_t sampling_rate /* i : sampling rate for processing */ ); void ivas_limiter_close( - IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */ + IVAS_LIMITER_HANDLE* phLimiter /* i/o: pointer to limiter handle, can be NULL */ ); void ivas_limiter_dec( @@ -132,6 +133,7 @@ void efap_determine_gains( const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ const int16_t efap_mode /* i : indicates whether EFAP or EFIP is used */ ); + #ifdef FIX_866_MOVE_VBAP /*----------------------------------------------------------------------------------* @@ -157,6 +159,7 @@ void vbap_determine_gains( const int16_t ele_deg, /* i : elevation in degrees for panning direction (positive up) */ const int16_t use_object_mode /* i : select between object mode panning and spatial mode panning */ ); + #endif /*----------------------------------------------------------------------------------* @@ -164,16 +167,16 @@ void vbap_determine_gains( *----------------------------------------------------------------------------------*/ void ivas_sba_prototype_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ - const int16_t subframe /* i : Subframe to render */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ + float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ + float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ + const int16_t subframe /* i : Subframe to render */ ); ivas_error ivas_sba_get_hoa_dec_matrix( - const IVAS_OUTPUT_SETUP hOutSetup, /* i : target output setup */ - float **hoa_dec_mtx, /* o : ALLRAD decoder matrix */ - const int16_t ambisonics_order /* i : Ambisonics order */ + const IVAS_OUTPUT_SETUP hOutSetup, /* i : target output setup */ + float **hoa_dec_mtx, /* o : ALLRAD decoder matrix */ + const int16_t ambisonics_order /* i : Ambisonics order */ ); void ivas_dirac_dec_binaural_sba_gain( @@ -187,35 +190,35 @@ void ivas_dirac_dec_binaural( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t num_subframes /* i : number of subframes to render */ + const int16_t num_subframes /* i : number of subframes to render */ ); void ivas_dirac_dec_binaural_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - const int16_t nchan_transport, /* i : number of transport channels */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ); ivas_error ivas_dirac_dec_init_binaural_data( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : HRTF structure for rendering */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : HRTF structure for rendering */ ); void ivas_dirac_dec_close_binaural_data( - DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */ + DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */ ); ivas_error ivas_dirac_dec_binaural_copy_hrtfs( - HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ + HRTFS_PARAMBIN_HANDLE *hHrtfParambin /* i/o: HRTF structure for rendering */ ); /*! r: Configured reqularization factor value */ float configure_reqularization_factor( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int32_t ivas_total_brate /* i : total IVAS bitrate */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const int32_t ivas_total_brate /* i : total IVAS bitrate */ ); ivas_error ivas_dirac_alloc_mem( diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index a47e0fb6e2..1376fa59ac 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -1723,11 +1723,11 @@ void ivas_combined_orientation_update_index( { if ( hCombinedOrientationData != NULL ) { - if ( hCombinedOrientationData->num_subframes == 1 #ifdef SPLIT_REND_WITH_HEAD_ROT - || hCombinedOrientationData->sr_low_res_flag + if ( hCombinedOrientationData->num_subframes == 1 || hCombinedOrientationData->sr_low_res_flag ) +#else + if ( hCombinedOrientationData->num_subframes == 1 ) #endif - ) { /* only one orientation available anyway or split rendering with low resolution*/ hCombinedOrientationData->subframe_idx = 0; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 24259bd2ce..97e0440a0d 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -716,6 +716,7 @@ typedef struct ivas_combined_orientation_struct int16_t subframe_idx_start; int16_t cur_subframe_samples_rendered_start; #endif + } COMBINED_ORIENTATION_DATA, *COMBINED_ORIENTATION_HANDLE; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 4cb3daee59..2c8d944d0f 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -576,8 +576,10 @@ static ivas_error validateOutputAudioConfig( * *-------------------------------------------------------------------*/ +/*! r: audio configuration type */ IVAS_REND_AudioConfigType getAudioConfigType( - const AUDIO_CONFIG config ) + const AUDIO_CONFIG config /* i : audio configuration */ +) { IVAS_REND_AudioConfigType type; @@ -658,8 +660,9 @@ static ivas_error validateOutputSampleRate( *-------------------------------------------------------------------*/ ivas_error getAudioConfigNumChannels( - const AUDIO_CONFIG config, - int16_t *numChannels ) + const AUDIO_CONFIG config, /* i : audio configuration */ + int16_t *numChannels /* o : number of audio channels */ +) { switch ( config ) { @@ -8809,7 +8812,7 @@ static ivas_error getSamplesInternal( convertBitsBufferToInternalBitsBuff( *hBits, &bits ); if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 523b22415a8127b709fdd570039e57e338381ed3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 20 Oct 2023 16:36:49 +0200 Subject: [PATCH 08/52] clang-format --- lib_rend/lib_rend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 2c8d944d0f..9065357941 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8812,7 +8812,7 @@ static ivas_error getSamplesInternal( convertBitsBufferToInternalBitsBuff( *hBits, &bits ); if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 6ddfcd20358d03701d8e7391cd936a77d7d1b852 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 3 Nov 2023 15:13:51 +0100 Subject: [PATCH 09/52] correct comments --- lib_dec/ivas_cpe_dec.c | 2 +- lib_dec/ivas_sce_dec.c | 4 ++-- lib_enc/ivas_cpe_enc.c | 5 ++++- lib_enc/ivas_front_vad.c | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index d8b5ec4713..c550323dcc 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -497,7 +497,7 @@ ivas_error ivas_cpe_dec( stereo_cna_update_params( hCPE, output, output_frame, tdm_ratio_idx ); /*----------------------------------------------------------------* - * Synthesis synchronization between CPE modes + * Synthesis synchronization between coding tools and CPE modes *----------------------------------------------------------------*/ if ( !st_ivas->sba_dirac_stereo_flag ) diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 36ec1386ab..7d79699afd 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -257,13 +257,13 @@ ivas_error ivas_sce_dec( output_Fs = st_ivas->hDecoderConfig->output_Fs; /*----------------------------------------------------------------* - * LB synthesis synchronization between IVAS formats + * LB synthesis synchronization between coding tools *----------------------------------------------------------------*/ delay_signal( output[0], output_frame, st->prev_synth_buffer, NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ) ); /*----------------------------------------------------------------* - * HB synthesis synchronization between IVAS formats + * HB synthesis synchronization between coding tools *----------------------------------------------------------------*/ delay_signal( outputHB[0], output_frame, hSCE->prev_hb_synth, NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) ); diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 1306e92627..9e4d5ed7c4 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -171,7 +171,6 @@ ivas_error ivas_cpe_enc( /*----------------------------------------------------------------* * Stereo technology selection - * Front-VAD on input L and R channels *----------------------------------------------------------------*/ if ( sts[0]->ini_frame > 0 && st_ivas->hMCT == NULL ) @@ -185,6 +184,10 @@ ivas_error ivas_cpe_enc( stereo_mode_combined_format_enc( st_ivas, hCPE ); + /*----------------------------------------------------------------* + * Front-VAD on input L and R channels + *----------------------------------------------------------------*/ + if ( ( error = front_vad( hCPE, NULL, hEncoderConfig, &hCPE->hFrontVad[0], st_ivas->hMCT != NULL, input_frame, vad_flag_dtx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, vad_hover_flag, band_energies_LR, NULL, NULL ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 52c3b8cd45..21613d23a0 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -144,7 +144,7 @@ ivas_error front_vad( } } - /* Only run VAD if DTX is on and TD stereo or unified stereo is selected */ + /* Only run VAD if DTX is on and Unified stereo is selected */ if ( hFrontVads[0] != NULL && element_mode != IVAS_CPE_MDCT ) { #ifdef DEBUGGING -- GitLab From c0facb9a1295dee3f07f18bdf7e81674c05c912c Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 9 Nov 2023 15:58:13 +0100 Subject: [PATCH 10/52] Restored a few local function prototypes in lib_rend/ivas_objectRenderer_sources.c --- lib_rend/ivas_objectRenderer_sources.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 756ca82a68..83d9616a97 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -45,12 +45,20 @@ * Local function prototypes *---------------------------------------------------------------------*/ +static void TDREND_SRC_SPATIAL_Dealloc( TDREND_SRC_SPATIAL_t *SrcSpatial_p ); + +static void TDREND_SRC_SPATIAL_Init( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_PosType_t PosType ); + static void TDREND_SRC_SPATIAL_SetDirAtten( TDREND_SRC_SPATIAL_t *SrcSpatial_p, const TDREND_DirAtten_t *DirAtten_p ); static float TDREND_SRC_SPATIAL_GetDirGain( const TDREND_DirAtten_t *DirAtten_p, const float *Front_p, const float *RelPos_p ); static float TDREND_SRC_SPATIAL_GetDistGain( const TDREND_DistAtten_t *DistAtten_p, const float Dist ); +static ivas_error TDREND_SRC_REND_Alloc( TDREND_SRC_REND_t **SrcRend_pp ); + +static void TDREND_SRC_REND_Init( TDREND_SRC_REND_t *SrcRend_p ); + /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetPos() -- GitLab From 6efe2ec194eca90a35fe774486c723b5be269f49 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Nov 2023 10:54:57 +0100 Subject: [PATCH 11/52] remove empty lines --- lib_dec/ivas_ism_dec.c | 12 +++++------- lib_dec/ivas_ism_dtx_dec.c | 2 -- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index baf5dc8258..6cf1bfdc31 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -443,17 +443,15 @@ ivas_error ivas_ism_dec_config( if ( st_ivas->ini_active_frame != 0 ) { /* ISM bit-rate switching */ + if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) { - if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) - { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - { - return error; - } + { + return error; } } } diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index 8899696bec..a4ae16e36c 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -61,8 +61,6 @@ ivas_error ivas_ism_dtx_dec( Decoder_State *st; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - - nchan_ism_prev = st_ivas->nchan_ism; if ( !st_ivas->bfi && ivas_total_brate == IVAS_SID_5k2 ) -- GitLab From a9dc78998bbd8a7842b6bbb43e45c9e340a95998 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 13 Nov 2023 14:36:05 +0100 Subject: [PATCH 12/52] formatting, correct comments --- apps/renderer.c | 24 +++---- lib_dec/ivas_dirac_dec.c | 2 +- lib_dec/ivas_jbm_dec.c | 11 +-- lib_dec/ivas_rom_dec.c | 5 +- lib_enc/ivas_spar_encoder.c | 2 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 19 ++++- lib_rend/lib_rend.c | 73 +++++++++----------- 7 files changed, 69 insertions(+), 67 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 88b627fe61..5614aefeb2 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -875,6 +875,7 @@ int main( convert_backslash( args.splitRendBFIFilePath ); SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); } + #endif if ( !isEmptyString( args.externalOrientationFilePath ) ) { @@ -1062,9 +1063,8 @@ int main( fprintf( stderr, "\nExternal Renderer Config is only supported for binaural output configurations. Exiting. \n" ); exit( -1 ); } -#endif - +#endif if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK ) { #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1108,8 +1108,8 @@ int main( #endif exit( -1 ); } - #ifdef SPLIT_REND_WITH_HEAD_ROT + if ( !is_split_post_rend_mode( &args ) ) { CLDFBframeSize_smpls = frameSize_smpls * 2; @@ -1420,8 +1420,8 @@ int main( exit( -1 ); } } -#endif +#endif if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); @@ -1788,6 +1788,7 @@ int main( fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } + IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.masaBuses[i].inputChannelIndex, numChannels ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, masaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) @@ -1830,7 +1831,6 @@ int main( #endif } - #ifdef SPLIT_REND_WITH_HEAD_ROT for ( i = 0; i < args.inConfig.numBinBuses; ++i ) { @@ -1856,9 +1856,7 @@ int main( } } } -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( args.inConfig.numBinBuses != 0 ) { if ( ( error = IVAS_REND_GetSplitBinauralSamples( hIvasRend, outBuffer, &splitBinNeedsNewFrame ) ) != IVAS_ERR_OK ) @@ -1987,6 +1985,7 @@ int main( numInputFormats++; inputType1 = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS; } + if ( args.inConfig.numMultiChannelBuses > 0 ) { numInputFormats++; @@ -1995,6 +1994,7 @@ int main( inputType1 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED; } } + if ( args.inConfig.numMasaBuses > 0 ) { numInputFormats++; @@ -2003,6 +2003,7 @@ int main( inputType1 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA; } } + if ( args.inConfig.numAudioObjects > 0 ) { numInputFormats++; @@ -2097,7 +2098,6 @@ int main( } #endif - if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { fprintf( stdout, "\n\nMetadata delayed %d subframes\n\n", (int16_t) round( args.syncMdDelay / ( 1000 / IVAS_NUM_FRAMES_PER_SEC / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); @@ -2391,7 +2391,6 @@ static bool parseDiegeticPan( return true; } - #ifdef NONBE_UNIFIED_DECODING_PATHS static bool parseRenderFramesize( char *value, @@ -2422,8 +2421,8 @@ static bool parseRenderFramesize( return true; } -#endif +#endif static bool parseOrientationTracking( char *value, int8_t *orientation_tracking ) @@ -3400,7 +3399,6 @@ static void parseObjectPosition( int16_t read_values; float meta_prm[8] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f }; - readNextMetadataChunk( line, "," ); *positionDuration = (uint16_t) strtol( line, &endptr, 10 ); readNextMetadataChunk( line, "\n" ); @@ -3801,7 +3799,8 @@ static void parseSceneDescriptionFile( return; } -static void printSupportedAudioConfigs( void ) +static void printSupportedAudioConfigs( + void ) { uint16_t i; const char *supportedFormats[] = { @@ -3997,6 +3996,7 @@ static void convertInputBuffer( return; } + /*--------------------------------------------------------------------------* * convertOutputBuffer() * diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 66dd7c5f47..54c2a27d31 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -843,13 +843,13 @@ ivas_error ivas_dirac_dec_config( if ( !sparfoa_flag ) { common_rend_config_flag = st_ivas->hSpatParamRendCom == NULL ? DIRAC_OPEN : flag_config_inp; + #ifdef NONBE_FIX_225_MASA_EXT_REND if ( ( error = ivas_spat_hSpatParamRendCom_config( &st_ivas->hSpatParamRendCom, common_rend_config_flag, dec_param_estim_new, st_ivas->ivas_format, st_ivas->mc_mode, output_Fs, hodirac_flag, 0 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_spat_hSpatParamRendCom_config( &st_ivas->hSpatParamRendCom, common_rend_config_flag, dec_param_estim_new, st_ivas->ivas_format, st_ivas->mc_mode, output_Fs, hodirac_flag ) ) != IVAS_ERR_OK ) - #endif { return error; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 8182512b68..104e476d69 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1523,7 +1523,7 @@ ivas_error ivas_dec_render( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_dec_flush_renderer() + * ivas_jbm_dec_flush_renderer() * * Flush samples if renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ @@ -1917,7 +1917,7 @@ void ivas_jbm_dec_get_adapted_subframes( /*--------------------------------------------------------------------------* - * ivas_jbm_dec_get_adapted_linear_interpolator() + * ivas_jbm_dec_get_md_map() * * Get an meta data map adapted to a time scale modified IVAS frame *--------------------------------------------------------------------------*/ @@ -2156,6 +2156,7 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc++; } + if ( st_ivas->hOutSetup.separateChannelEnabled && ( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || output_config == IVAS_AUDIO_CONFIG_5_1_2 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) ) @@ -2242,8 +2243,8 @@ static void ivas_jbm_dec_copy_tc( /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, /* i : renderer type */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const MC_MODE mc_mode, /* i : MC mode */ const int32_t output_Fs /* i : sampling rate */ ) { @@ -2789,8 +2790,8 @@ void ivas_jbm_dec_copy_tc_no_tsm( assert( 0 && "Residual (direct CLDFB transport channels) only possible for ParamMC/ParamISM!" ); } #endif - /* CLDFB Analysis*/ + /* CLDFB Analysis*/ for ( cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch_idx++ ) { for ( slot_idx = 0; slot_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; slot_idx++ ) diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 26846d6254..3a142397a9 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -378,8 +378,8 @@ const uint16_t * const sym_freq_ECSQ_tab_abs_lsbs[1 + 4] = /*----------------------------------------------------------------------------------* * DirAC ROM tables *----------------------------------------------------------------------------------*/ - #ifndef NONBE_FIX_225_MASA_EXT_REND + const float ls_azimuth_4d4[8] = { 45.0f, -45.0f, 135.0f, -135.0f, 45.0f, -45.0f, 135.0f, -135.0f }; const float ls_elevation_4d4[8] = { 0.0f, 0.0f, 0.0f, 0.0f, 35.0f, 35.0f, 35.0f, 35.0f }; @@ -389,7 +389,6 @@ const float diffuse_response_CICP6[5] = { 0.4219f, 0.4219f, 0.3704f, 0.5034f, 0. const float diffuse_response_CICP14[7] = { 0.3817f, 0.3817f, 0.2819f, 0.5399f, 0.5399f, 0.1519f, 0.1519f }; const float diffuse_response_CICP16[9] = { 0.3456f, 0.3456f, 0.3035f, 0.4124f, 0.4124f, 0.2702f, 0.2702f, 0.3023f, 0.3023f }; - #endif const float dirac_dithering_azi_scale[DIRAC_DIFFUSE_LEVELS] = @@ -532,8 +531,8 @@ const int16_t sba_map_tc_512[11] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15 }; - #endif + /*----------------------------------------------------------------------------------* * FASTCONV and PARAMETRIC binaural renderer ROM tables *----------------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index ec31fe9c67..3e8f8283c5 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -354,7 +354,7 @@ ivas_error ivas_spar_enc( /* Write SBA planar flag */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); - /* hack to indicate OSBA bitstream at VLBR */ + /* hack to indicate OSBA bitstream at lowest bitrates */ push_indice( st0->hBstr, IND_SMODE, 0, SBA_ORDER_BITS ); } else diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 7fe6f54b29..aa0296a689 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -2305,9 +2305,8 @@ static void ivas_dirac_dec_binaural_process_output( const int16_t max_band_decorr, const int16_t numInChannels, const int16_t processReverb, - const int16_t subframe #ifdef SPLIT_REND_WITH_HEAD_ROT - , + const int16_t subframe, float outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], @@ -2315,6 +2314,8 @@ static void ivas_dirac_dec_binaural_process_output( float decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const uint8_t recompute +#else + const int16_t subframe #endif ) { @@ -3462,6 +3463,12 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects( #ifdef NONBE_FIX_225_MASA_EXT_REND +/*-------------------------------------------------------------------* + * ivas_masa_ext_rend_parambin_internal() + * + * + *-------------------------------------------------------------------*/ + static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, @@ -3602,10 +3609,10 @@ static void ivas_masa_ext_rend_parambin_internal( /* Always using CLDFB decorrelation in MASA EXT renderer */ max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; - #ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, subFrameTotalEne, IIReneLimiter ); + ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, subFrameTotalEne, IIReneLimiter, NULL ); @@ -3723,6 +3730,12 @@ static void ivas_masa_ext_rend_parambin_internal( } +/*-------------------------------------------------------------------* + * ivas_masa_ext_rend_parambin_render() + * + * + *-------------------------------------------------------------------*/ + void ivas_masa_ext_rend_parambin_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 3d25fb1cd3..c9cddec445 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -2349,7 +2349,6 @@ static lfe_routing defaultLfeRouting( lfe_routing routing; /* Set all output gains to zero, then route each input LFE consecutively to the next available output LFE. */ - for ( i = 0; i < RENDERER_MAX_INPUT_LFE_CHANNELS; ++i ) { set_zero( routing.lfePanMtx[i], IVAS_MAX_OUTPUT_CHANNELS ); @@ -2628,8 +2627,8 @@ static ivas_error initSbaPanGainsForSbaOut( return error; } - #ifdef SPLIT_REND_WITH_HEAD_ROT + static ivas_error updateSplitPostRendPanGains( input_split_post_rend *inputSplitPostRend, const AUDIO_CONFIG outConfig, @@ -2655,8 +2654,8 @@ static ivas_error updateSplitPostRendPanGains( return IVAS_ERR_OK; } -#endif +#endif static ivas_error updateSbaPanGains( input_sba *inputSba, @@ -2767,8 +2766,8 @@ static ivas_error updateSbaPanGains( return IVAS_ERR_OK; } - #ifdef SPLIT_REND_WITH_HEAD_ROT + static ivas_error setRendInputActiveSplitPostRend( void *input, const AUDIO_CONFIG inConfig, @@ -2799,8 +2798,8 @@ static ivas_error setRendInputActiveSplitPostRend( return IVAS_ERR_OK; } -#endif +#endif static ivas_error initSbaMasaRendering( input_sba *inputSba, @@ -2891,8 +2890,8 @@ static ivas_error setRendInputActiveSba( return error; } - #ifdef SPLIT_REND_WITH_HEAD_ROT + static void clearInputSplitRend( input_split_post_rend *inputSplitRend ) { @@ -2921,8 +2920,8 @@ static void clearInputSplitRend( return; } -#endif +#endif static void clearInputSba( input_sba *inputSba ) @@ -4167,8 +4166,8 @@ static ivas_error findFreeInputSlot( return IVAS_ERR_OK; } - #ifdef SPLIT_REND_WITH_HEAD_ROT + static int16_t getCldfbRendFlag( IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ const IVAS_REND_AudioConfigType new_configType ) @@ -4228,8 +4227,8 @@ static void closeSplitRend( return; } -#endif +#endif /*-------------------------------------------------------------------* * IVAS_REND_AddInput() @@ -4990,6 +4989,7 @@ ivas_error IVAS_REND_InitConfig( { return error; } + if ( ( error = ivas_render_config_init_from_rom( &hIvasRend->hRendererConfig ) ) != IVAS_ERR_OK ) { return error; @@ -5148,8 +5148,8 @@ int16_t IVAS_REND_FeedRenderConfig( return IVAS_ERR_OK; } - #ifdef SPLIT_REND_WITH_HEAD_ROT + /*-------------------------------------------------------------------* * IVAS_REND_FeedSplitBinauralBitstream() * @@ -5182,8 +5182,8 @@ ivas_error IVAS_REND_FeedSplitBinauralBitstream( return IVAS_ERR_OK; } -#endif +#endif /*-------------------------------------------------------------------* * IVAS_REND_SetHeadRotation() @@ -5296,8 +5296,8 @@ ivas_error IVAS_REND_DisableHeadRotation( return IVAS_ERR_OK; } - #ifdef SPLIT_REND_WITH_HEAD_ROT + /*-------------------------------------------------------------------* * IVAS_REND_SetSplitRendBFI() * @@ -5318,8 +5318,8 @@ ivas_error IVAS_REND_SetSplitRendBFI( return IVAS_ERR_OK; } -#endif +#endif /*-------------------------------------------------------------------* * IVAS_REND_SetOrientationTrackingMode() @@ -5689,7 +5689,6 @@ static ivas_error rotateFrameMc( } /* subframe loop */ - subframe_len = inAudio.config.numSamplesPerChannel / num_subframes; for ( subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++ ) { @@ -6075,7 +6074,6 @@ static ivas_error renderIsmToBinauralRoom( mvr2r( currentPanGains, ismInput->prev_pan_gains, MAX_OUTPUT_CHANNELS ); } - /* render 7_1_4 with BRIRs */ #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcess( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, @@ -6109,7 +6107,6 @@ static ivas_error renderIsmToBinauralReverb( int16_t ism_md_subframe_update_ext; push_wmops( "renderIsmToBinauralRoom" ); - /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ ism_md_subframe_update_ext = (int16_t) roundf( ismInput->ism_metadata_delay_ms / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); @@ -6137,7 +6134,6 @@ static ivas_error renderIsmToMc( ivas_error error; push_wmops( "renderIsmToMc" ); - position_changed = !ismInput->firstFrameRendered || checkObjectPositionChanged( &ismInput->currentPos, &ismInput->previousPos ); if ( *ismInput->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_STEREO ) { @@ -6199,7 +6195,6 @@ static ivas_error renderIsmToMc( } pop_wmops(); - return IVAS_ERR_OK; } @@ -6217,7 +6212,6 @@ static ivas_error renderIsmToSba( error = IVAS_ERR_OK; push_wmops( "renderIsmToSba" ); - if ( ( error = getAudioConfigNumChannels( outConfig, &numOutChannels ) ) != IVAS_ERR_OK ) { return error; @@ -6266,8 +6260,8 @@ static ivas_error renderIsmToSba( return error; } - #ifdef SPLIT_REND_WITH_HEAD_ROT + static ivas_error renderIsmToSplitBinaural( input_ism *ismInput, const IVAS_REND_AudioBuffer outAudio ) @@ -6366,8 +6360,8 @@ static ivas_error renderIsmToSplitBinaural( /* Encoding to split rendering bitstream done at a higher level */ return IVAS_ERR_OK; } -#endif +#endif static void renderIsmToMasa( input_ism *ismInput, @@ -6566,17 +6560,16 @@ static ivas_error renderLfeToBinaural( v_add( writePtr, tmpLfeBuffer, writePtr, frame_size ); } } -#else /* SPLIT_REND_WITH_HEAD_ROT */ +#else /* Copy LFE to left and right ears */ for ( ear_idx = 0; ear_idx < BINAURAL_CHANNELS; ++ear_idx ) { writePtr = getSmplPtr( outAudio, ear_idx, 0 ); v_add( writePtr, tmpLfeBuffer, writePtr, frame_size ); } -#endif /* SPLIT_REND_WITH_HEAD_ROT */ +#endif pop_wmops(); - return IVAS_ERR_OK; } @@ -6956,8 +6949,8 @@ static void renderMcToMasa( return; } - #ifdef SPLIT_REND_WITH_HEAD_ROT + static ivas_error renderMcToSplitBinaural( input_mc *mcInput, const AUDIO_CONFIG outConfig, @@ -7114,8 +7107,8 @@ static ivas_error renderMcToSplitBinaural( pop_wmops(); return IVAS_ERR_OK; } -#endif +#endif static ivas_error renderInputMc( input_mc *mcInput, @@ -7126,7 +7119,6 @@ static ivas_error renderInputMc( IVAS_REND_AudioBuffer inAudio; error = IVAS_ERR_OK; - inAudio = mcInput->base.inputBuffer; if ( mcInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) @@ -7141,8 +7133,8 @@ static ivas_error renderInputMc( #ifdef NONBE_UNIFIED_DECODING_PATHS /* set combined orientation subframe info to start info */ ivas_combined_orientation_set_to_start_index( *( mcInput->base.ctx.pCombinedOrientationData ) ); -#endif +#endif switch ( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: @@ -7348,8 +7340,7 @@ static ivas_error renderSplitBinauralWithPostRot( config.channels = BINAURAL_CHANNELS; config.samplerate = *splitBinInput->base.ctx.pOutSampleRate; - if ( ( error = IVAS_LC3PLUS_DEC_Open( config, - &splitBinInput->splitPostRendWrapper.hLc3plusDec ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_LC3PLUS_DEC_Open( config, &splitBinInput->splitPostRendWrapper.hLc3plusDec ) ) != IVAS_ERR_OK ) { return error; } @@ -7682,7 +7673,6 @@ static ivas_error renderSbaToSplitBinaural( int16_t low_res_pre_rend_rot; low_res_pre_rend_rot = 1; - push_wmops( "renderSbaToSplitBinaural" ); error = IVAS_ERR_OK; @@ -7859,14 +7849,13 @@ static ivas_error renderSbaToBinauralRoom( /* copy input for in-place rotation */ mvr2r( sbaInput->base.inputBuffer.data, tmpRotBuffer.data, tmpRotBuffer.config.numChannels * tmpRotBuffer.config.numSamplesPerChannel ); - if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, - sbaInput->base.ctx.pCombinedOrientationData, #ifdef SPLIT_REND_WITH_HEAD_ROT - sbaInput->rot_gains_prev[0], + if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev[0], tmpRotBuffer ) ) != IVAS_ERR_OK ) #else - sbaInput->rot_gains_prev, + if ( ( error = rotateFrameSba( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, + sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev, tmpRotBuffer ) ) != IVAS_ERR_OK ) #endif - tmpRotBuffer ) ) != IVAS_ERR_OK ) { return error; } @@ -8970,7 +8959,7 @@ static ivas_error getSamplesInternal( convertBitsBufferToInternalBitsBuff( *hBits, &bits ); if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -8985,8 +8974,8 @@ static ivas_error getSamplesInternal( accumulate2dArrayToBuffer( tmpBinaural_buff, &outAudio ); } } -#endif +#endif #ifdef NONBE_UNIFIED_DECODING_PATHS /* update global cominbed orientation start index */ ivas_combined_orientation_update_start_index( hIvasRend->hCombinedOrientationData, outAudio.config.numSamplesPerChannel ); @@ -9015,8 +9004,8 @@ ivas_error IVAS_REND_GetSamples( #endif } - #ifdef SPLIT_REND_WITH_HEAD_ROT + /*-------------------------------------------------------------------* * IVAS_REND_GetSplitBinauralBitstream() * @@ -9058,8 +9047,8 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( *-------------------------------------------------------------------*/ ivas_error IVAS_REND_GetSplitBinauralSamples( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + IVAS_REND_AudioBuffer outAudio, /* i/o: buffer for output audio */ bool *needNewFrame ) { ivas_error error; @@ -9801,6 +9790,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( return error; } + static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig ) @@ -9999,7 +9989,6 @@ static void freeMasaExtRenderer( ivas_dirac_dec_close_binaural_data( &hMasaExtRend->hDiracDecBin[i] ); } } - #else if ( hMasaExtRend->hDiracDecBin != NULL ) { -- GitLab From db19834b329972389664e3503db26df4cd816002 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 14 Nov 2023 08:00:19 +0100 Subject: [PATCH 13/52] remove empty lines --- lib_com/ivas_prot.h | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f00bd50904..f5abeb89c9 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -709,8 +709,8 @@ void output_debug_mode_info_dec( const int16_t output_frame, float pitch_buf[CPE_CHANNELS][NB_SUBFR16k] ); -#endif +#endif /*! r: flag indicating a valid bitrate */ int16_t is_IVAS_bitrate( const int32_t ivas_total_brate /* i : IVAS total bitrate */ @@ -874,10 +874,10 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( /*! r: render granularity */ int16_t ivas_jbm_dec_get_render_granularity( - const RENDERER_TYPE rendererType, /* i : renderer type */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int32_t output_Fs /* i : sampling rate */ + const RENDERER_TYPE rendererType, /* i : renderer type */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const MC_MODE mc_mode, /* i : MC mode */ + const int32_t output_Fs /* i : sampling rate */ ); ivas_error ivas_jbm_dec_tc_buffer_open( @@ -2934,7 +2934,6 @@ ivas_error stereo_memory_enc( float *tdm_last_ratio, /* o : TD stereo last ratio */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t nchan_transport /* i : number transport chans */ - ); ivas_error stereo_memory_dec( @@ -3448,8 +3447,7 @@ void ivas_dirac_param_est_enc( const int16_t nchan_fb_in, int16_t *mono_frame_count, int16_t *dirac_mono_flag - ); - +); void ivas_sba_config( const int32_t sba_total_brate, /* i : SBA total bitrate */ @@ -3750,7 +3748,6 @@ void computeDiffuseness( float *diffuseness ); - void ivas_dirac_dec_get_response( const int16_t azimuth, const int16_t elevation, @@ -5182,7 +5179,7 @@ void ivas_binaural_hrtf_close( ); void ivas_init_binaural_hrtf( - HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ + HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ ); ivas_error ivas_allocate_binaural_hrtf( @@ -5339,7 +5336,6 @@ void ivas_ls_setup_conversion_close( LSSETUP_CONVERSION_HANDLE *hLsSetUpConversion /* i/o: LS converter handle */ ); - void ivas_ls_setup_conversion( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ const int16_t input_chans, /* i : number of input channels to the renderer */ @@ -5490,7 +5486,6 @@ ivas_error ivas_mono_dmx_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); - void ivas_mono_dmx_renderer_close( MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/o: Mono downmix structure */ ); @@ -5991,7 +5986,6 @@ int16_t ivas_get_num_bands_from_bw_idx( const int16_t bwidth /* i : audio bandwidth */ ); - /* clang-format on */ #endif /* IVAS_PROT_H */ -- GitLab From e1884be042fa81b412f5f3137a2f34de348bd1be Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 15 Nov 2023 10:55:31 +0100 Subject: [PATCH 14/52] revert some formatting changes --- lib_dec/ivas_dirac_dec.c | 2 ++ lib_dec/ivas_ism_param_dec.c | 5 +++++ lib_dec/ivas_jbm_dec.c | 2 ++ lib_dec/ivas_mc_paramupmix_dec.c | 1 + lib_enc/ivas_ism_param_enc.c | 2 ++ lib_rend/ivas_dirac_rend.c | 2 ++ lib_rend/ivas_objectRenderer.c | 2 ++ lib_rend/lib_rend.c | 7 ++++++- 8 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 54c2a27d31..1c48162ec1 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1805,6 +1805,7 @@ void ivas_dirac_dec_render_sf( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; push_wmops( "ivas_dirac_dec_render" ); + /* Initialize aux buffers */ hDirAC = st_ivas->hDirAC; hDirACRend = st_ivas->hDirACRend; @@ -2648,5 +2649,6 @@ void ivas_dirac_dec_render_sf( hSpatParamRendCom->subframes_rendered++; pop_wmops(); + return; } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 114e45f6bc..337257fb66 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -453,6 +453,7 @@ ivas_error ivas_param_ism_dec_open( ivas_error error; error = IVAS_ERR_OK; + push_wmops( "ivas_param_ism_dec_open" ); /*-----------------------------------------------------------------* @@ -660,6 +661,7 @@ ivas_error ivas_param_ism_dec_open( #endif pop_wmops(); + return error; } @@ -802,6 +804,7 @@ void ivas_param_ism_dec( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; hSetup = st_ivas->hIntSetup; + push_wmops( "ivas_param_ism_dec" ); /* set buffers to zero */ @@ -1129,6 +1132,7 @@ void ivas_param_ism_dec_digest_tc( } push_wmops( "ivas_param_ism_dec" ); + /* general setup */ ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator ); @@ -1247,6 +1251,7 @@ void ivas_param_ism_dec_digest_tc( ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin ); pop_wmops(); + return; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index b7b18b280e..d503598e45 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -83,6 +83,7 @@ ivas_error ivas_jbm_dec_tc( int32_t ism_total_brate; push_wmops( "ivas_jbm_dec_tc" ); + /*----------------------------------------------------------------* * Initialization of local vars after struct has been set *----------------------------------------------------------------*/ @@ -754,6 +755,7 @@ ivas_error ivas_jbm_dec_tc( #endif pop_wmops(); + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index c3072aa43f..38f1834fbb 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -508,6 +508,7 @@ void ivas_mc_paramupmix_dec_render( hMCParamUpmix = st_ivas->hMCParamUpmix; assert( hMCParamUpmix ); + push_wmops( "ivas_mc_paramupmix_dec_render" ); for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 56e5506ce0..2b5704329b 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -225,6 +225,7 @@ void ivas_param_ism_stereo_dmx( float last_dmx_gain; float last_cardioid_left; ISM_METADATA_HANDLE hIsmMetaData; + push_wmops( "ivas_param_ism_st_dmx" ); /*Initialization*/ @@ -330,6 +331,7 @@ void ivas_param_ism_stereo_dmx( mvr2r( stereo_dmx[1], data[1], input_frame ); pop_wmops(); + return; } diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index 579b524856..6f74e8364b 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -2142,6 +2142,7 @@ static void ivas_masa_ext_dirac_render_sf( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; push_wmops( "ivas_masa_ext_dirac_render_sf" ); + /* Initialize aux buffers */ hDirACRend = hMasaExtRend->hDirACRend; hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; @@ -2488,6 +2489,7 @@ static void ivas_masa_ext_dirac_render_sf( hSpatParamRendCom->subframes_rendered++; pop_wmops(); + return; } diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index afb87d2a5e..7b5110c7f2 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -725,6 +725,7 @@ ivas_error ivas_td_binaural_renderer_ext( } push_wmops( "ivas_td_binaural_renderer_ext" ); + inConfigType = getAudioConfigType( inConfig ); lfe_idx = LFE_CHANNEL; hIsmMetaData[0] = NULL; @@ -776,6 +777,7 @@ ivas_error ivas_td_binaural_renderer_ext( } pop_wmops(); + return IVAS_ERR_OK; } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index c9cddec445..1b7dbc08a3 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -5963,6 +5963,7 @@ static ivas_error renderIsmToBinauralRoom( } push_wmops( "renderIsmToBinauralRoom" ); + rotatedPosPrev = defaultObjectPosition(); rotatedPos = defaultObjectPosition(); @@ -6094,6 +6095,7 @@ static ivas_error renderIsmToBinauralRoom( free( tmpMcBuffer.data ); pop_wmops(); + return IVAS_ERR_OK; } @@ -6279,6 +6281,7 @@ static ivas_error renderIsmToSplitBinaural( int16_t ism_md_subframe_update_ext; push_wmops( "renderIsmToSplitBinaural" ); + pSplitRendWrapper = ismInput->base.ctx.pSplitRendWrapper; pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; @@ -6370,6 +6373,7 @@ static void renderIsmToMasa( float tmpRendBuffer[MAX_NUM_OBJECTS][L_FRAME48k]; push_wmops( "renderIsmToMasa" ); + copyBufferTo2dArray( ismInput->base.inputBuffer, tmpRendBuffer ); ivas_omasa_ana( ismInput->hOMasa, tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, ismInput->base.inputBuffer.config.numChannels ); @@ -6377,6 +6381,7 @@ static void renderIsmToMasa( accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); pop_wmops(); + return; } @@ -8959,7 +8964,7 @@ static ivas_error getSamplesInternal( convertBitsBufferToInternalBitsBuff( *hBits, &bits ); if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 60407004abba98cdfcb0dbdc9afbe3311e296f68 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 15 Nov 2023 11:00:36 +0100 Subject: [PATCH 15/52] maintenance around FIX_899_VARIABLE_SPEED_DECODING --- apps/decoder.c | 2 ++ lib_com/options.h | 4 ++-- lib_dec/lib_dec.c | 9 ++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 54062011b2..2bef2e4685 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2387,6 +2387,7 @@ static ivas_error decodeG192( fprintf( stderr, "\nError: input bitstream file couldn't be read: %s \n\n", arg.inputBitstreamFilename ); goto cleanup; } + #ifdef FIX_899_VARIABLE_SPEED_DECODING int16_t maxScaling; /* max scaling as abs diff to the normal frame size in samples */ @@ -2466,6 +2467,7 @@ static ivas_error decodeG192( #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif + #ifdef FIX_899_VARIABLE_SPEED_DECODING if ( needNewFrame ) { diff --git a/lib_com/options.h b/lib_com/options.h index a4eab8337d..2a501bea93 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -151,15 +151,15 @@ /*#define SPLIT_REND_WITH_HEAD_ROT */ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #define FIX_643_PCA_OPTION /* VA: issue 643: rename PCA bypass command-line option */ +#define FIX_899_VARIABLE_SPEED_DECODING /* FhG: Fix variable speed decoding */ + /* #################### End BE switches ################################## */ -#define FIX_899_VARIABLE_SPEED_DECODING /* FhG: Fix variable speed decoding */ /* #################### Start NON-BE switches ############################ */ /* any switch which is non-be wrt selection floating point code */ /* all switches in this category should start with "NONBE_" */ - #define NONBE_FIX_788_SBA_DTX_BR_SWITCHING /* VA: issue 787: fix Msan error in SBA BR switching with dtx in FOA encoding */ #define NONBE_FIX_856_TCX_LTP_SYNTH_FILTER /* FhG: issue 856: correct filtering length for tcx-ltp synth filtering*/ #define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 75be2d1729..3b2ab2b66b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2573,11 +2573,7 @@ ivas_error IVAS_DEC_TSM_SetQuality( const float quality /* i : target TSM quality */ ) { - ivas_error error; - - error = IVAS_ERR_OK; - - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false ) + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == FALSE ) { return IVAS_ERR_TSM_NOT_ENABLED; } @@ -2586,9 +2582,8 @@ ivas_error IVAS_DEC_TSM_SetQuality( hIvasDec->tsm_quality = quality; } - return error; + return IVAS_ERR_OK; } - #endif -- GitLab From cf1a0f5a3ac4de8480988dc0bef19a6cf18e9223 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 16 Nov 2023 09:46:35 +0100 Subject: [PATCH 16/52] revert some changes --- apps/decoder.c | 4 ++-- apps/renderer.c | 1 - lib_com/ivas_cnst.h | 6 +++--- lib_com/ivas_prot.h | 2 +- lib_dec/ivas_jbm_dec.c | 8 ++++---- lib_dec/lib_dec.c | 4 ++-- lib_enc/ivas_enc.c | 2 -- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 2bef2e4685..1a6c606998 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3299,8 +3299,8 @@ static ivas_error decodeVoIP( else { auPtr = au; /* might have been set to RTP packet in prev call */ - rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, - &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSize ); + rtpdumpDepackerError = EVS_RTPDUMP_DEPACKER_readNextFrame( &rtpdumpDepacker, &rtpSequenceNumber, &rtpTimeStamp, &nextPacketRcvTime_ms, &isAMRWB_IOmode, &frameTypeIndex, &qBit, &auPtr, (uint16_t *) &auSize ); + /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */ rtpTimeStamp = rtpTimeStamp / 16; } diff --git a/apps/renderer.c b/apps/renderer.c index 5614aefeb2..b85925cf9f 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -3996,7 +3996,6 @@ static void convertInputBuffer( return; } - /*--------------------------------------------------------------------------* * convertOutputBuffer() * diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 969eda234f..a1886d753a 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -986,7 +986,7 @@ typedef enum #define SPAR_CONFIG_BW FB #define IVAS_SPAR_MAX_CH ((( IVAS_MAX_SBA_ORDER ) * ( IVAS_MAX_SBA_ORDER )) + 2) /* HOA2 + pHOA3*/ -#define IVAS_HBR_MAX_DECOR_CHS 2 +#define IVAS_HBR_MAX_DECOR_CHS (2) #define IVAS_SPAR_MAX_FB_IN_CHAN 11 @@ -1007,8 +1007,8 @@ typedef enum #define IVAS_ACTIVEW_DM_F_SCALE_VLBR 0.25f #define IVAS_SPAR_FOA_DFLT_FREQ_PER_CHAN 24000 -#define IVAS_SPAR_DYN_ACTIVEW_THRESH 0.0039f -#define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH 32.0f +#define IVAS_SPAR_DYN_ACTIVEW_THRESH (0.0039f) +#define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH (32.0f) #define MAX_QUANT_STRATS 3 #define MAX_CODING_STRATS 3 diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 22b8c675f9..5fb7124c46 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -791,7 +791,7 @@ ivas_error ivas_jbm_dec_tc( float *data /* o : output synthesis signals */ ); -ivas_error ivas_dec_render( +ivas_error ivas_jbm_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesAsked, /* i : number of samples requested */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index d503598e45..73e461fe7f 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -919,12 +919,12 @@ void ivas_jbm_dec_feed_tc_to_renderer( /*--------------------------------------------------------------------------* - * ivas_dec_render() + * ivas_jbm_dec_render() * - * Principal IVAS rendering routine + * Principal IVAS JBM rendering routine *--------------------------------------------------------------------------*/ -ivas_error ivas_dec_render( +ivas_error ivas_jbm_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesAsked, /* i : number of samples requested */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ @@ -952,7 +952,7 @@ ivas_error ivas_dec_render( int16_t nchan_out_syn_output; #endif - push_wmops( "ivas_dec_render" ); + push_wmops( "ivas_jbm_dec_render" ); /*----------------------------------------------------------------* * Initialization of local vars after struct has been set *----------------------------------------------------------------*/ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 3b2ab2b66b..afee398eb5 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1550,9 +1550,9 @@ static ivas_error IVAS_DEC_GetRenderedSamples( /* run the main IVAS decoding routine */ #ifdef SPLIT_REND_WITH_HEAD_ROT - error = ivas_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); + error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcm_type_API_to_internal( pcmType ), pcmBuf ); #else - error = ivas_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcmBuf ); + error = ivas_jbm_dec_render( st_ivas, nSamplesForRendering, nSamplesRendered, nSamplesAvailableNext, pcmBuf ); #endif return error; diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index c52a722c20..2cf50b2272 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -275,7 +275,6 @@ ivas_error ivas_enc( else if ( ivas_format == MASA_ISM_FORMAT ) { float *data_separated_object; - int16_t idx_separated_object; int16_t flag_omasa_ener_brate; @@ -298,7 +297,6 @@ ivas_error ivas_enc( set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); idx_separated_object = 0; - data_separated_object = data_f[hEncoderConfig->nchan_ism + CPE_CHANNELS]; /* put audio object data in SCE's */ -- GitLab From dd49314e475bcc8cbbae2945c284aa13f0ad1b6a Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 24 Nov 2023 09:38:03 +0100 Subject: [PATCH 17/52] add missing SPLIT_REND_WITH_HEAD_ROT defines --- lib_com/common_api_types.h | 28 +++++++++++++++------------- lib_dec/ivas_spar_decoder.c | 2 +- lib_rend/lib_rend.c | 4 +++- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 4f1a452c61..501fa4f757 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -64,21 +64,23 @@ typedef enum _IVAS_AUDIO_CONFIG { IVAS_AUDIO_CONFIG_INVALID, - IVAS_AUDIO_CONFIG_MONO, /* mono output */ - IVAS_AUDIO_CONFIG_STEREO, /* stereo output */ - IVAS_AUDIO_CONFIG_5_1, /* 5.1 speakers layout CICP6 */ - IVAS_AUDIO_CONFIG_7_1, /* 7.1 speakers layout CICP12 */ - IVAS_AUDIO_CONFIG_5_1_2, /* 5.1+2 speakers layout CICP14 */ - IVAS_AUDIO_CONFIG_5_1_4, /* 5.1+4 speakers layout CICP16 */ - IVAS_AUDIO_CONFIG_7_1_4, /* 7.1+4 speakers layout CICP19 */ - IVAS_AUDIO_CONFIG_LS_CUSTOM, /* custom loudspeaker layout */ - IVAS_AUDIO_CONFIG_FOA, /* ambisonics, order 1 */ - IVAS_AUDIO_CONFIG_HOA2, /* ambisonics, order 2 */ - IVAS_AUDIO_CONFIG_HOA3, /* ambisonics, order 3 */ - IVAS_AUDIO_CONFIG_OBA, /* object based audio */ - IVAS_AUDIO_CONFIG_BINAURAL, /* binaural with HRIR */ + IVAS_AUDIO_CONFIG_MONO, /* mono output */ + IVAS_AUDIO_CONFIG_STEREO, /* stereo output */ + IVAS_AUDIO_CONFIG_5_1, /* 5.1 speakers layout CICP6 */ + IVAS_AUDIO_CONFIG_7_1, /* 7.1 speakers layout CICP12 */ + IVAS_AUDIO_CONFIG_5_1_2, /* 5.1+2 speakers layout CICP14 */ + IVAS_AUDIO_CONFIG_5_1_4, /* 5.1+4 speakers layout CICP16 */ + IVAS_AUDIO_CONFIG_7_1_4, /* 7.1+4 speakers layout CICP19 */ + IVAS_AUDIO_CONFIG_LS_CUSTOM, /* custom loudspeaker layout */ + IVAS_AUDIO_CONFIG_FOA, /* ambisonics, order 1 */ + IVAS_AUDIO_CONFIG_HOA2, /* ambisonics, order 2 */ + IVAS_AUDIO_CONFIG_HOA3, /* ambisonics, order 3 */ + IVAS_AUDIO_CONFIG_OBA, /* object based audio */ + IVAS_AUDIO_CONFIG_BINAURAL, /* binaural with HRIR */ +#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED, /* split binaural with CLDFB coded output */ IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, /* split binaural with PCM coded output */ +#endif IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, /* binaural with BRIR */ IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB, /* binaural with HRIR + reverb */ IVAS_AUDIO_CONFIG_ISM1, /* ISM1 */ diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 4d1d98b3a7..77794fd5be 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1806,7 +1806,7 @@ void ivas_spar_dec_upmixer_sf( } else { -#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifndef SPLIT_REND_WITH_HEAD_ROT if ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) && #else if ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 1b7dbc08a3..5bee3462c3 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -628,8 +628,10 @@ IVAS_REND_AudioConfigType getAudioConfigType( case IVAS_AUDIO_CONFIG_BINAURAL: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: +#ifdef SPLIT_REND_WITH_HEAD_ROT case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: +#endif type = IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL; break; case IVAS_AUDIO_CONFIG_MASA1: @@ -8964,7 +8966,7 @@ static ivas_error getSamplesInternal( convertBitsBufferToInternalBitsBuff( *hBits, &bits ); if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0 ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 9366da1791091a84a0b97939119e1d4d5e19293c Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 24 Nov 2023 09:38:16 +0100 Subject: [PATCH 18/52] correct comment --- lib_enc/ivas_core_pre_proc_front.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 65e1b4ddba..58d34bcbfc 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -408,7 +408,7 @@ ivas_error pre_proc_front_ivas( dummy = st->mem_preemph; preemph( new_inp_12k8 - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy ); } - else /* IVAS_SCE or IVAS_CPE_MDCT */ + else /* IVAS_SCE */ { preemph( new_inp_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph ); dummy = st->mem_preemph; -- GitLab From 03e16b0e43bd36aa5896a0c7a882e077d47b2bb1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 24 Nov 2023 13:39:53 +0100 Subject: [PATCH 19/52] fix merging issue --- lib_dec/ivas_mc_paramupmix_dec.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 9e93e8bc93..6adc29683a 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -586,11 +586,6 @@ void ivas_mc_paramupmix_dec_render( output_f_local[ch] += n_samples_sf; } - for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) - { - output_f_local[ch] += n_samples_sf; - } - #ifdef NONBE_UNIFIED_DECODING_PATHS /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); -- GitLab From a0dd9b56e51fc83519bce34c01117e930a61ae61 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Dec 2023 17:44:26 +0100 Subject: [PATCH 20/52] correction --- lib_dec/ivas_jbm_dec.c | 2 -- lib_rend/ivas_crend.c | 1 - lib_rend/ivas_rotation.c | 15 +++++---------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6da41f2082..0f98bd1a99 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1287,8 +1287,6 @@ ivas_error ivas_jbm_dec_render( } else { -#endif -#if defined SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index f2c4544e43..498ce062e5 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2026,7 +2026,6 @@ ivas_error ivas_rend_crendProcessSubframe( if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0, pos_idx ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local, p_pcm_tmp, output_Fs, 0 ) ) != IVAS_ERR_OK ) - #endif { return error; diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 1a5ff39f5c..7775a3938c 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -82,6 +82,7 @@ ivas_error ivas_headTrack_open( ( *hHeadTrackData )->lrSwitchInterpVal = 0.0f; ( *hHeadTrackData )->lrSwitchedCurrent = 0; ( *hHeadTrackData )->lrSwitchedNext = 0; + if ( ( ( *hHeadTrackData )->OrientationTracker = (ivas_orient_trk_state_t *) malloc( sizeof( ivas_orient_trk_state_t ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Orientation tracking" ); @@ -440,14 +441,10 @@ void rotateFrame_shd( /* move Rmat to Rmat_prev */ for ( i = 0; i < 3; i++ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT - mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], hCombinedOrientationData->Rmat_prev[0][i], 3 ); -#else #ifdef SPLIT_REND_WITH_HEAD_ROT mvr2r( hCombinedOrientationData->Rmat[subframe_idx][i], hCombinedOrientationData->Rmat_prev[0][i], 3 ); #else mvr2r( hCombinedOrientationData->Rmat[subframe_idx][i], hCombinedOrientationData->Rmat_prev[i], 3 ); -#endif #endif } @@ -578,11 +575,7 @@ void rotateFrame_sd( #ifdef SPLIT_REND_WITH_HEAD_ROT mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], hCombinedOrientationData->Rmat_prev[0][i], 3 ); #else -#ifdef SPLIT_REND_WITH_HEAD_ROT - mvr2r( hCombinedOrientationData->Rmat[subframe_idx][i], hCombinedOrientationData->Rmat_prev[0][i], 3 ); -#else - mvr2r( hCombinedOrientationData->Rmat[subframe_idx][i], hCombinedOrientationData->Rmat_prev[i], 3 ); -#endif + mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], hCombinedOrientationData->Rmat_prev[i], 3 ); #endif } @@ -821,7 +814,9 @@ ivas_error ivas_external_orientation_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for external orientation memory\n" ) ); } + ( *hExtOrientationData )->num_subframes = num_subframes; + /* Enable head rotation and disable external orientation as default */ for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { @@ -831,6 +826,7 @@ ivas_error ivas_external_orientation_open( ( *hExtOrientationData )->numFramesToTargetOrientation[i] = 0; ( *hExtOrientationData )->Quaternions[i] = identity; } + return IVAS_ERR_OK; } @@ -943,7 +939,6 @@ ivas_error ivas_combined_orientation_open( ( *hCombinedOrientationData )->Quaternion_frozen_ext = identity; ( *hCombinedOrientationData )->Quaternion_frozen_head = identity; - set_zero( ( *hCombinedOrientationData )->chEneIIR[0], MASA_FREQUENCY_BANDS ); set_zero( ( *hCombinedOrientationData )->chEneIIR[1], MASA_FREQUENCY_BANDS ); set_zero( ( *hCombinedOrientationData )->procChEneIIR[0], MASA_FREQUENCY_BANDS ); -- GitLab From 76e7f173864b322724f7ef822fcf18ded2c82500 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Dec 2023 19:47:56 +0100 Subject: [PATCH 21/52] correction --- lib_rend/ivas_rotation.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 7775a3938c..2efb800306 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -442,9 +442,9 @@ void rotateFrame_shd( for ( i = 0; i < 3; i++ ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - mvr2r( hCombinedOrientationData->Rmat[subframe_idx][i], hCombinedOrientationData->Rmat_prev[0][i], 3 ); + mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], hCombinedOrientationData->Rmat_prev[0][i], 3 ); #else - mvr2r( hCombinedOrientationData->Rmat[subframe_idx][i], hCombinedOrientationData->Rmat_prev[i], 3 ); + mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], hCombinedOrientationData->Rmat_prev[i], 3 ); #endif } -- GitLab From 57e9331c4085846795233cfdc437fb195cfe8d4c Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 11 Mar 2024 16:39:03 +0100 Subject: [PATCH 22/52] clang-format --- lib_rend/ivas_rom_rend.h | 1 - lib_rend/lib_rend.c | 2 +- lib_util/hrtf_file_reader.h | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index 91aec914be..f53c25cf42 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -99,7 +99,6 @@ extern const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS]; extern const float SincTable[321]; - /*----------------------------------------------------------------------------------* * t-design and SN3D normalization table *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 9fa20f8c06..2aba4f6a15 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -8353,7 +8353,7 @@ static ivas_error getSamplesInternal( } if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index ab3254806f..f778bbd435 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -52,7 +52,7 @@ typedef enum typedef struct ivas_hrtfs_header_t { - int32_t rend_type; + HRTF_READER_RENDERER_TYPE rend_type; int32_t input_cfg; int32_t frequency; uint32_t data_size; -- GitLab From 2d0cf14f0e64c10f2560216463f9dd9dd2ddaa36 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 11 Mar 2024 16:45:25 +0100 Subject: [PATCH 23/52] remove 'const' --- lib_util/hrtf_file_reader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 77ffe883a8..77e1da7d6c 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1051,10 +1051,10 @@ static ivas_error create_HRTF_from_rawdata( static ivas_error create_fastconv_HRTF_from_rawdata( - HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ - char *hrtf_data, /* i : pointer to binary file */ - const HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ - const BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ + HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ + char *hrtf_data, /* i : pointer to binary file */ + const HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ + BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ ) { int16_t i, j; -- GitLab From d7a966c751740dae7030faac4ce5573908a606be Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 11 Mar 2024 16:51:24 +0100 Subject: [PATCH 24/52] remove 'const' --- lib_util/hrtf_file_reader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 77e1da7d6c..c3b65948f8 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1051,10 +1051,10 @@ static ivas_error create_HRTF_from_rawdata( static ivas_error create_fastconv_HRTF_from_rawdata( - HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ - char *hrtf_data, /* i : pointer to binary file */ - const HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ - BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ + HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ + char *hrtf_data, /* i : pointer to binary file */ + HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ + BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ ) { int16_t i, j; -- GitLab From 7ac12a0e7f22b73f4f21f170380153394473829e Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 11 Mar 2024 16:59:19 +0100 Subject: [PATCH 25/52] fix merge issue --- lib_util/hrtf_file_reader.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index c3b65948f8..5f68a0c2a5 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1051,10 +1051,10 @@ static ivas_error create_HRTF_from_rawdata( static ivas_error create_fastconv_HRTF_from_rawdata( - HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ - char *hrtf_data, /* i : pointer to binary file */ - HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ - BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ + HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ + char *hrtf_data, /* i : pointer to binary file */ + const HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ + const BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ ) { int16_t i, j; @@ -1062,10 +1062,6 @@ static ivas_error create_fastconv_HRTF_from_rawdata( ivas_error error; ( *hHRTF )->allocate_init_flag = 0; - if ( ( error = ivas_allocate_binaural_hrtf( *hHRTF, 0, input_cfg, rend_type, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) - { - return error; - } if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) { -- GitLab From bb9d0c381ce8102fbaed1a660b5019932c9ee1b2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 11 Mar 2024 17:50:51 +0100 Subject: [PATCH 26/52] fix merge issue --- lib_dec/ivas_output_config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 4f6f6dc058..ad663779b6 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -157,9 +157,9 @@ void ivas_renderer_select( *internal_config = IVAS_AUDIO_CONFIG_HOA3; #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #else - if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL ) #endif { *renderer_type = RENDERER_BINAURAL_FASTCONV; -- GitLab From dce38c533f0e721ca0c81eeffbe104e065d694e7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 11 Mar 2024 18:48:43 +0100 Subject: [PATCH 27/52] fix merge issue --- lib_dec/ivas_dirac_dec.c | 1 + lib_dec/ivas_sba_dec.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 1576917686..8e0dd63d34 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1840,6 +1840,7 @@ void ivas_dirac_dec_render_sf( set_zero( surCohRatio, hSpatParamRendCom->num_freq_bands ); } } + ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, hDirACRend, st_ivas->hVBAPdata, diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 6e9a23b9a6..029570e860 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -195,9 +195,9 @@ ivas_error ivas_sba_dec_reconfigure( else { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #else - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL ) #endif { renderer_type_new = RENDERER_BINAURAL_FASTCONV; -- GitLab From e11a76656569f5c16cb14f0b22bbc696f0e413a4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 11 Mar 2024 19:32:21 +0100 Subject: [PATCH 28/52] recycle parameters --- lib_dec/ivas_jbm_dec.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index e9f971e239..a87e49ae00 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -105,7 +105,7 @@ ivas_error ivas_jbm_dec_tc( if ( !st_ivas->hDecoderConfig->Opt_tsm ) { - for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) + for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); n++ ) { st_ivas->hTcBuffer->tc[n] = st_ivas->p_output_f[n]; } @@ -312,7 +312,7 @@ ivas_error ivas_jbm_dec_tc( ivas_masa_prerender( st_ivas, p_output, output_frame, nchan_remapped ); /* external output */ - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { @@ -476,10 +476,10 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->hSpar->hPCA != NULL ) { - ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output[sba_ch_idx] ); + ivas_pca_dec( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output[sba_ch_idx] ); } - ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); + ivas_spar_dec_gen_umx_mat( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); ivas_sba_dirac_stereo_dec( st_ivas, &p_output[sba_ch_idx], output_frame, 0 ); } @@ -508,7 +508,7 @@ ivas_error ivas_jbm_dec_tc( #endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); ivas_sba_mix_matrix_determiner( st_ivas->hSpar, &p_output[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); } @@ -847,7 +847,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { ivas_ism_dec_digest_tc( st_ivas ); @@ -1245,7 +1244,7 @@ ivas_error ivas_jbm_dec_render( return error; } } - else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ + else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/ { if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output[st_ivas->nchan_ism] ) ) != IVAS_ERR_OK ) { @@ -1276,7 +1275,7 @@ ivas_error ivas_jbm_dec_render( return error; } - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { #ifdef DEBUGGING assert( st_ivas->ism_mode == ISM_MODE_NONE ); @@ -1303,6 +1302,7 @@ ivas_error ivas_jbm_dec_render( { int16_t crendInPlaceRotation = FALSE; *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) { if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) @@ -1406,6 +1406,7 @@ ivas_error ivas_jbm_dec_render( { int16_t offset = hSpatParamRendCom->slots_rendered * hSpatParamRendCom->slot_size; nchan_remapped = st_ivas->nchan_transport; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ); @@ -1752,6 +1753,7 @@ ivas_error ivas_jbm_dec_flush_renderer( { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" ); } + hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity; } @@ -2044,7 +2046,6 @@ int16_t ivas_jbm_dec_get_num_tc_channels( int32_t ivas_total_brate; AUDIO_CONFIG output_config; - if ( st_ivas->renderer_type == RENDERER_DISABLE ) { num_tc = st_ivas->hDecoderConfig->nchan_out; @@ -2083,7 +2084,7 @@ int16_t ivas_jbm_dec_get_num_tc_channels( num_tc = 1; /* Only one channel transported */ } - if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->nchan_transport == 2 && st_ivas->hDecoderConfig->ivas_total_brate < MASA_STEREO_MIN_BITRATE && st_ivas->hDecoderConfig->ivas_total_brate > IVAS_SID_5k2 ) + if ( st_ivas->ivas_format == MASA_FORMAT && output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->nchan_transport == 2 && ivas_total_brate < MASA_STEREO_MIN_BITRATE && ivas_total_brate > IVAS_SID_5k2 ) { num_tc = CPE_CHANNELS; } @@ -2098,7 +2099,7 @@ int16_t ivas_jbm_dec_get_num_tc_channels( } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { - if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) + if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { @@ -2127,11 +2128,11 @@ int16_t ivas_jbm_dec_get_num_tc_channels( } else if ( st_ivas->ivas_format == MC_FORMAT ) { - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + if ( output_config == IVAS_AUDIO_CONFIG_MONO ) { num_tc = 1; } - else if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) + else if ( output_config == IVAS_AUDIO_CONFIG_STEREO ) { num_tc = 2; } -- GitLab From 88209779fc3ba44c4ec7fcaefdc41a4efe445df0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 11 Mar 2024 19:33:35 +0100 Subject: [PATCH 29/52] remove "VE2SB" comments --- lib_dec/ivas_dirac_dec.c | 2 +- lib_dec/ivas_objectRenderer_internal.c | 2 +- lib_dec/ivas_osba_dec.c | 2 +- lib_dec/ivas_sba_rendering_internal.c | 2 +- lib_dec/ivas_stat_dec.h | 20 ++++++++++---------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 8e0dd63d34..5c03f7f0e4 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1579,7 +1579,7 @@ void ivas_dirac_dec_render( uint16_t slot_size, n_samples_sf, ch, nchan_intern; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; float *output_f_local[MAX_OUTPUT_CHANNELS]; - float output_f_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; // VE2SB: TBV + float output_f_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; hSpatParamRendCom = st_ivas->hSpatParamRendCom; diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index e0992e01d8..55df048bd5 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -253,7 +253,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( int16_t original_subframes_rendered; int16_t original_slots_rendered; float *p_bin_output[BINAURAL_CHANNELS]; - float output_local[MAX_OUTPUT_CHANNELS][L_FRAME48k]; // VE2SB: TBV + float output_local[MAX_OUTPUT_CHANNELS][L_FRAME48k]; push_wmops( "ivas_td_binaural_renderer_sf_splitBinaural" ); pMultiBinPoseData = &st_ivas->hSplitBinRend.splitrend.multiBinPoseData; diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 56e6af0dd2..2d9117f329 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -134,7 +134,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm( { int16_t n; ivas_error error; - float output_separated_objects[BINAURAL_CHANNELS][L_FRAME48k]; // VE2SB: TBV + float output_separated_objects[BINAURAL_CHANNELS][L_FRAME48k]; float *p_sepobj[BINAURAL_CHANNELS]; int16_t channel_offset; diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 63f03f468b..bd1782c2a8 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -354,7 +354,7 @@ void ivas_ism2sba_sf( { int16_t i, j, k; float g1, *g2, *tc, *out, gain, prev_gain; - float buffer_tmp[HOA3_CHANNELS][L_FRAME48k]; // VE2SB: TBV + float buffer_tmp[HOA3_CHANNELS][L_FRAME48k]; int16_t sba_num_chans; assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 3bd997e9a8..8af97e5dcd 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -926,16 +926,16 @@ typedef struct ivas_masa_ism_data_structure typedef struct decoder_tc_buffer_structure { - float *tc_buffer; /* the buffer itself */ - float *tc[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc */ // VE2SB: TBV - TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ - int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ - int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ - int16_t nchan_buffer_full; /* number of channels to be fully buffered */ - int16_t n_samples_available; /* samples still available for rendering in the current frame */ - int16_t n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ - int16_t n_samples_rendered; /* samples already rendered in the current frame */ - int16_t n_samples_granularity; /* render granularity */ + float *tc_buffer; /* the buffer itself */ + float *tc[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each TC */ + TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ + int16_t nchan_transport_jbm; /* number of TCs after TC decoding */ + int16_t nchan_transport_internal; /* total number of TC buffer channels, can include e.g. TD decorr data */ + int16_t nchan_buffer_full; /* number of channels to be fully buffered */ + int16_t n_samples_available; /* samples still available for rendering in the current frame */ + int16_t n_samples_buffered; /* full number of samples in the buffer (including spill to next frame) */ + int16_t n_samples_rendered; /* samples already rendered in the current frame */ + int16_t n_samples_granularity; /* render granularity */ int16_t n_samples_flushed; int16_t subframe_nbslots[MAX_JBM_SUBFRAMES_5MS]; int16_t nb_subframes; -- GitLab From 1dc20dc15f6f8b05fcf69b440bf70c5f0b7372a8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 11 Mar 2024 19:51:14 +0100 Subject: [PATCH 30/52] maintenance --- lib_dec/ivas_cpe_dec.c | 9 +-- lib_dec/ivas_ism_dec.c | 2 +- lib_dec/ivas_masa_dec.c | 136 +++++++++++++++++++++------------------- lib_dec/ivas_mct_dec.c | 103 +++++++++++++++--------------- lib_dec/ivas_sce_dec.c | 12 ++-- lib_enc/ivas_cpe_enc.c | 9 +-- lib_enc/ivas_sce_enc.c | 8 +-- 7 files changed, 132 insertions(+), 147 deletions(-) diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index ee63837882..c682ae7de3 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -82,8 +82,6 @@ ivas_error ivas_cpe_dec( int32_t cpe_brate; int32_t element_brate_ref; - error = IVAS_ERR_OK; - push_wmops( "ivas_cpe_dec" ); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -181,7 +179,6 @@ ivas_error ivas_cpe_dec( } else { - /* Note: This only works for stereo operation. If DTX would be applied for multiple CPEs a different bitrate signaling is needed */ if ( ivas_total_brate <= IVAS_SID_5k2 ) { stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); @@ -591,7 +588,7 @@ ivas_error ivas_cpe_dec( #endif pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -614,8 +611,6 @@ ivas_error create_cpe_dec( ivas_error error; int32_t cpe_brate; - error = IVAS_ERR_OK; - /*-----------------------------------------------------------------* * Allocate CPE handle *-----------------------------------------------------------------*/ @@ -891,7 +886,7 @@ ivas_error create_cpe_dec( st_ivas->hCPE[cpe_id] = hCPE; - return error; + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 26a021a046..57d0434594 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -423,7 +423,7 @@ ivas_error ivas_ism_dec_config( if ( st_ivas->ini_active_frame != 0 ) { /* ISM bit-rate switching */ - if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) + if ( ( st_ivas->ism_mode != last_ism_mode ) || ( ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) { #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index ad7b1a10ee..44990bcfaa 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1370,9 +1370,11 @@ ivas_error ivas_masa_dec_reconfigure( { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ } + sts = st_ivas->hCPE[cpe_id]->hCoreCoder; sts[0]->bit_stream = bit_stream + num_bits; num_bits += (int16_t) ( st_ivas->hCPE[cpe_id]->element_brate / FRAMES_PER_SEC ); + if ( ( ivas_total_brate < MASA_STEREO_MIN_BITRATE && last_ivas_total_brate >= MASA_STEREO_MIN_BITRATE ) || ( ivas_total_brate < MASA_STEREO_MIN_BITRATE && last_ivas_total_brate == FRAME_NO_DATA ) ) { @@ -1419,10 +1421,10 @@ ivas_error ivas_masa_dec_reconfigure( #endif /* regularization factor is bitrate-dependent */ #ifdef SPLIT_REND_WITH_HEAD_ROT - st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, ivas_total_brate ); } #else - st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, ivas_total_brate ); #endif } @@ -1439,9 +1441,9 @@ ivas_error ivas_masa_dec_reconfigure( #endif { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) #endif { return error; @@ -1484,87 +1486,91 @@ ivas_error ivas_masa_dec_reconfigure( st_ivas->ism_mode = ISM_MODE_NONE; } - { - int16_t tc_nchan_to_allocate; - int16_t tc_nchan_transport; - TC_BUFFER_MODE buffer_mode_new; - int16_t n_samples_granularity; + /*-----------------------------------------------------------------* + * JBM TC buffers + *-----------------------------------------------------------------*/ + + int16_t tc_nchan_to_allocate; + int16_t tc_nchan_transport; + TC_BUFFER_MODE buffer_mode_new; + int16_t n_samples_granularity; - n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); - buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); - tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - tc_nchan_to_allocate = tc_nchan_transport; - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + tc_nchan_to_allocate = tc_nchan_transport; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { - if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) - { - tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS + 2; - } - else - { - tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; - } - if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS + 2; + } + else + { + tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; + } + + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ + + if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity ) { - n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ - if ( n_samples_granularity > st_ivas->hTcBuffer->n_samples_granularity ) + if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } } - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) + } + else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode != ISM_MASA_MODE_DISC ) + { + if ( n_samples_granularity < st_ivas->hTcBuffer->n_samples_granularity ) { - if ( n_samples_granularity < st_ivas->hTcBuffer->n_samples_granularity ) - { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, pcm_resolution, data ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, n_samples_granularity, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, MC_MODE_NONE, ISM_MASA_MODE_DISC, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif - { - return error; - } + { + return error; } } } - else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) - { - /* addtl channel for CNG */ - tc_nchan_to_allocate++; - } - else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT ) ) - { - tc_nchan_transport = st_ivas->nchan_transport + st_ivas->nchan_ism; - tc_nchan_to_allocate = st_ivas->nchan_transport + st_ivas->nchan_ism; - } + } + else if ( st_ivas->nchan_transport == 1 && ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + /* addtl channel for CNG */ + tc_nchan_to_allocate++; + } + else if ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT ) ) + { + tc_nchan_transport = st_ivas->nchan_transport + st_ivas->nchan_ism; + tc_nchan_to_allocate = st_ivas->nchan_transport + st_ivas->nchan_ism; + } - if ( tc_nchan_transport != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || buffer_mode_new != st_ivas->hTcBuffer->tc_buffer_mode ) + if ( tc_nchan_transport != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || buffer_mode_new != st_ivas->hTcBuffer->tc_buffer_mode ) + { + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, n_samples_granularity ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + } - if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) - { - mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); - st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; - } + if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) + { + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + } - if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size; + if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + { + int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size; - for ( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ ) - { - st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier; - } + for ( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ ) + { + st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier; } } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 31222e92eb..6ee0de1078 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1320,69 +1320,66 @@ static ivas_error ivas_mc_dec_reconfig( * JBM TC buffers *-----------------------------------------------------------------*/ - { - int16_t tc_nchan_full_new; - DECODER_TC_BUFFER_HANDLE hTcBuffer; - - hTcBuffer = st_ivas->hTcBuffer; - tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); - tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); - tc_nchan_allocate_new = tc_nchan_tc_new; - tc_nchan_full_new = tc_nchan_tc_new; + int16_t tc_nchan_full_new; + DECODER_TC_BUFFER_HANDLE hTcBuffer; - if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) - { - tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; - tc_nchan_full_new = tc_nchan_allocate_new; - } + hTcBuffer = st_ivas->hTcBuffer; + tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + tc_nchan_allocate_new = tc_nchan_tc_new; + tc_nchan_full_new = tc_nchan_tc_new; - if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) - { - tc_nchan_full_new = 0; - } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) - { - tc_nchan_allocate_new = MC_PARAMUPMIX_MAX_INPUT_CHANS; - tc_buffer_mode_new = TC_BUFFER_MODE_RENDERER; - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) - { - tc_buffer_mode_new = TC_BUFFER_MODE_BUFFER; - tc_nchan_tc_new = st_ivas->hDecoderConfig->nchan_out; - tc_nchan_allocate_new = tc_nchan_tc_new; - } - tc_nchan_full_new = tc_nchan_allocate_new; - } + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + { + tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; + tc_nchan_full_new = tc_nchan_allocate_new; + } - /* reconfigure buffer */ - if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || - hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new || - tc_granularity_new != hTcBuffer->n_samples_granularity ) + if ( st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) + { + tc_nchan_full_new = 0; + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { + tc_nchan_allocate_new = MC_PARAMUPMIX_MAX_INPUT_CHANS; + tc_buffer_mode_new = TC_BUFFER_MODE_RENDERER; + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) { - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK ) - { - return error; - } + tc_buffer_mode_new = TC_BUFFER_MODE_BUFFER; + tc_nchan_tc_new = st_ivas->hDecoderConfig->nchan_out; + tc_nchan_allocate_new = tc_nchan_tc_new; } + tc_nchan_full_new = tc_nchan_allocate_new; + } - /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ - if ( st_ivas->hSpatParamRendCom != NULL ) - { - st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; - st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots; - st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered; - mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); - } - else if ( st_ivas->hParamMC != NULL ) + /* reconfigure buffer */ + if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || + hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new || + tc_granularity_new != hTcBuffer->n_samples_granularity ) + { + if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK ) { - st_ivas->hParamMC->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hParamMC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; - st_ivas->hParamMC->num_slots = st_ivas->hTcBuffer->num_slots; - st_ivas->hParamMC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; - mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + return error; } } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ + if ( st_ivas->hSpatParamRendCom != NULL ) + { + st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots; + st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } + else if ( st_ivas->hParamMC != NULL ) + { + st_ivas->hParamMC->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hParamMC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + st_ivas->hParamMC->num_slots = st_ivas->hTcBuffer->num_slots; + st_ivas->hParamMC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } /*-----------------------------------------------------------------* * 'float' output audio buffers diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index ec4a5d5d26..e20ec40412 100644 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -62,11 +62,9 @@ ivas_error ivas_sce_dec( float outputHB[1][L_FRAME48k]; /* 'float' buffer for output HB synthesis, one channel */ SCE_DEC_HANDLE hSCE; Decoder_State *st; - int32_t ivas_total_brate, last_ivas_total_brate; + int32_t ivas_total_brate; ivas_error error; - error = IVAS_ERR_OK; - push_wmops( "ivas_sce_dec" ); hSCE = st_ivas->hSCE[sce_id]; @@ -75,7 +73,6 @@ ivas_error ivas_sce_dec( st->BER_detect |= st_ivas->BER_detect; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; if ( st_ivas->ivas_format == ISM_FORMAT ) { @@ -101,7 +98,7 @@ ivas_error ivas_sce_dec( { st->total_brate = FRAME_NO_DATA; } - else if ( !st_ivas->bfi && st_ivas->ivas_format != ISM_FORMAT && last_ivas_total_brate <= IVAS_SID_5k2 ) + else if ( !st_ivas->bfi && st_ivas->ivas_format != ISM_FORMAT && st_ivas->hDecoderConfig->last_ivas_total_brate <= IVAS_SID_5k2 ) { st->total_brate = hSCE->element_brate - nb_bits_metadata * FRAMES_PER_SEC; } @@ -314,7 +311,7 @@ ivas_error ivas_sce_dec( pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -335,7 +332,6 @@ ivas_error create_sce_dec( ivas_error error; int16_t output_frame; - error = IVAS_ERR_OK; output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); /*-----------------------------------------------------------------* @@ -430,7 +426,7 @@ ivas_error create_sce_dec( hSCE->hCoreCoder[0] = st; st_ivas->hSCE[sce_id] = hSCE; - return error; + return IVAS_ERR_OK; } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 5da3e6a207..66c0bcbc2f 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -112,7 +112,6 @@ ivas_error ivas_cpe_enc( int32_t element_brate_ref; int16_t last_bits_frame_nominal; /* last_bits_frame_nominal for M or PCh channel */ - error = IVAS_ERR_OK; push_wmops( "ivas_cpe_enc" ); hCPE = st_ivas->hCPE[cpe_id]; @@ -281,7 +280,6 @@ ivas_error ivas_cpe_enc( sts[n]->element_mode = hCPE->element_mode; } - if ( hCPE->element_mode != IVAS_CPE_MDCT && ( hCPE->element_brate != hCPE->last_element_brate || hCPE->last_element_mode != hCPE->element_mode || sts[0]->ini_frame == 0 || ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */ { @@ -298,7 +296,6 @@ ivas_error ivas_cpe_enc( } else { - /* note; "bits_frame_nominal" needed in TD stereo as well */ stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal ); } } @@ -791,7 +788,7 @@ ivas_error ivas_cpe_enc( #endif pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -815,8 +812,6 @@ ivas_error create_cpe_enc( ENCODER_CONFIG_HANDLE hEncoderConfig; ivas_error error; - error = IVAS_ERR_OK; - hEncoderConfig = st_ivas->hEncoderConfig; ivas_format = hEncoderConfig->ivas_format; @@ -1054,7 +1049,7 @@ ivas_error create_cpe_enc( st_ivas->hCPE[cpe_id] = hCPE; - return error; + return IVAS_ERR_OK; } diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 215b977f25..1acc9263f1 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -92,8 +92,6 @@ ivas_error ivas_sce_enc( push_wmops( "ivas_sce_enc" ); - error = IVAS_ERR_OK; - hSCE = st_ivas->hSCE[sce_id]; st = hSCE->hCoreCoder[0]; ivas_format = st_ivas->hEncoderConfig->ivas_format; @@ -288,7 +286,7 @@ ivas_error ivas_sce_enc( pop_wmops(); - return error; + return IVAS_ERR_OK; } @@ -308,8 +306,6 @@ ivas_error create_sce_enc( Encoder_State *st; ivas_error error; - error = IVAS_ERR_OK; - /*-----------------------------------------------------------------* * Allocate SCE handle *-----------------------------------------------------------------*/ @@ -371,7 +367,7 @@ ivas_error create_sce_enc( st_ivas->hSCE[sce_id] = hSCE; - return error; + return IVAS_ERR_OK; } -- GitLab From 8d778169045079a79371c4a632437f7c696b12f7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 20 Mar 2024 07:58:09 +0100 Subject: [PATCH 31/52] error returns, formatting --- lib_dec/lib_dec.c | 4 +++- lib_rend/lib_rend.c | 37 +++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7a088b0569..11aa98ee96 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -157,7 +157,9 @@ ivas_error IVAS_DEC_Open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder handle" ); } + hIvasDec = *phIvasDec; + hIvasDec->hVoIP = NULL; hIvasDec->apaExecBuffer = NULL; hIvasDec->hTimeScaler = NULL; @@ -205,7 +207,7 @@ ivas_error IVAS_DEC_Open( st_ivas = hIvasDec->st_ivas; /* initialize Decoder Config. handle */ - init_decoder_config( hIvasDec->st_ivas->hDecoderConfig ); + init_decoder_config( st_ivas->hDecoderConfig ); /* initialize pointers to handles to NULL */ ivas_initialize_handles_dec( st_ivas ); diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 2aba4f6a15..64a66278c7 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -51,19 +51,16 @@ /* Maximum buffer length (per channel) in samples. * Keep this separate from L_FRAME48k in case we want to support different size later */ #define MAX_BUFFER_LENGTH_PER_CHANNEL ( L_FRAME48k ) -#ifdef SPLIT_REND_WITH_HEAD_ROT -#define MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL ( MAX_BUFFER_LENGTH_PER_CHANNEL * 2 ) -#endif /* Maximum buffer length (total) in samples. */ -/* Maximum buffer length (total) in samples. */ -#ifdef SPLIT_REND_WITH_HEAD_ROT -#define MAX_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) -#define MAX_CLDFB_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) -#define MAX_BIN_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS ) -#define MAX_CLDFB_BIN_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS ) -#else #define MAX_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) + +#ifdef SPLIT_REND_WITH_HEAD_ROT +/* Split rendering buffer lengths */ +#define MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL ( MAX_BUFFER_LENGTH_PER_CHANNEL * 2 ) +#define MAX_CLDFB_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) +#define MAX_BIN_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS ) +#define MAX_CLDFB_BIN_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS ) #endif #define MAX_BIN_DELAY_SAMPLES 150 /* Maximum supported rendering latency for binaural IRs */ @@ -210,9 +207,8 @@ typedef struct int16_t numCachedSamples; /* Number of decoded samples in bufferData that have not yet been played out */ IVAS_REND_BitstreamBuffer *hBits; } input_split_post_rend; -#endif - +#endif typedef struct { input_base base; @@ -282,6 +278,7 @@ static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG static void freeMasaExtRenderer( MASA_EXT_REND_HANDLE *hMasaExtRendOut ); + /*-------------------------------------------------------------------* * Local functions *-------------------------------------------------------------------*/ @@ -495,6 +492,7 @@ static void accumulate2dArrayToBuffer( return; } + /*-------------------------------------------------------------------* * limitRendererOutput() * @@ -548,6 +546,7 @@ static int32_t limitRendererOutput( } #endif + /*-------------------------------------------------------------------* * validateOutputAudioConfig() * @@ -2059,6 +2058,7 @@ static ivas_error updateMcPanGainsForAmbiOut( { ++ch_out; } + ivas_dirac_dec_get_response( (int16_t) spkAzi[ch_in], (int16_t) spkEle[ch_in], inputMc->panGains[ch_out], outAmbiOrder ); } } @@ -2135,6 +2135,7 @@ static ivas_error updateMcPanGains( default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; } + /* Check error here to keep switch statement more compact */ if ( error != IVAS_ERR_OK ) { @@ -3285,6 +3286,7 @@ ivas_error IVAS_REND_Open( hIvasRend->hHrtfs.hHrtfTD = NULL; hIvasRend->hHrtfs.hSetOfHRTF = NULL; hIvasRend->hHrtfs.hHrtfStatistics = NULL; + if ( asHrtfBinary ) { if ( ( error = ivas_HRTF_binary_open( &( hIvasRend->hHrtfs.hHrtfTD ) ) ) != IVAS_ERR_OK ) @@ -5671,6 +5673,7 @@ static ivas_error renderIsmToMc( push_wmops( "renderIsmToMc" ); position_changed = !ismInput->firstFrameRendered || checkObjectPositionChanged( &ismInput->currentPos, &ismInput->previousPos ); + if ( *ismInput->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_STEREO ) { if ( ismInput->nonDiegeticPan ) @@ -8353,7 +8356,7 @@ static ivas_error getSamplesInternal( } if ( ( error = ivas_renderMultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) { return error; } @@ -8814,7 +8817,6 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( DIRAC_REND_HANDLE hDirACRend; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - error = IVAS_ERR_OK; hDirACRend = NULL; output_Fs = *( inputMasa->base.ctx.pOutSampleRate ); @@ -9108,7 +9110,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( } /* output synthesis */ - if ( ( ivas_dirac_dec_output_synthesis_open( hSpatParamRendCom, hDirACRend, RENDERER_DIRAC, nchan_transport, output_Fs, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_output_synthesis_open( hSpatParamRendCom, hDirACRend, RENDERER_DIRAC, nchan_transport, output_Fs, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -9156,7 +9158,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( inputMasa->hMasaExtRend->hDirACRend = hDirACRend; - return error; + return IVAS_ERR_OK; } @@ -9179,7 +9181,6 @@ static ivas_error ivas_masa_ext_rend_parambin_init( int16_t pos_idx; #endif - error = IVAS_ERR_OK; phHrtfParambin = inputMasa->hMasaExtRend->hHrtfParambin; /* Set common variables and defaults */ @@ -9309,7 +9310,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( inputMasa->hMasaExtRend->hDiracDecBin = hDiracDecBin; #endif - return error; + return IVAS_ERR_OK; } -- GitLab From 15a36a5849c5c9fdc9c21e6e231d20731022f0c5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 20 Mar 2024 08:03:42 +0100 Subject: [PATCH 32/52] remove obsolete 8 kHz output form ParamMC --- lib_dec/ivas_mc_param_dec.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 9801d01459..ec50a34966 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -2792,9 +2792,6 @@ static void param_mc_set_num_synth_bands( switch ( output_Fs ) { - case 8000: - max_param_band_synth = param_mc_bands_coded[NB]; - break; case 16000: max_param_band_synth = param_mc_bands_coded[WB]; break; -- GitLab From bbcc28cff5b9f37cd69706647b8978ef8afcad89 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 20 Mar 2024 08:43:04 +0100 Subject: [PATCH 33/52] returns --- lib_rend/ivas_prot_rend.h | 2 +- lib_rend/ivas_reverb.c | 9 +++++---- lib_rend/ivas_reverb_utils.c | 12 ++++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 7b51823870..5148e03bda 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1139,7 +1139,7 @@ void ivas_reverb_calc_color_levels( float *pTarget_color_R ); -ivas_error ivas_reverb_prepare_cldfb_params( +void ivas_reverb_prepare_cldfb_params( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_STATISTICS_HANDLE hHrtfStatistics, const int32_t output_Fs, diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 1f791df39c..b309bcc58a 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1829,12 +1829,14 @@ static ivas_error ivas_binaural_reverb_open( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * ivas_binaural_reverb_init() * * Allocate and initialize binaural room reverberator handle * for CLDFB renderers *------------------------------------------------------------------------*/ + ivas_error ivas_binaural_reverb_init( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ @@ -1860,10 +1862,8 @@ ivas_error ivas_binaural_reverb_init( revTimes = t60; revEne = ene; - if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60, ene ) ) != IVAS_ERR_OK ) - { - return error; - } + ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60, ene ); + preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); } else @@ -1878,6 +1878,7 @@ ivas_error ivas_binaural_reverb_init( return error; } + /*------------------------------------------------------------------------- * ivas_binaural_reverb_close() * diff --git a/lib_rend/ivas_reverb_utils.c b/lib_rend/ivas_reverb_utils.c index 6b1b362059..f85be2fdf7 100644 --- a/lib_rend/ivas_reverb_utils.c +++ b/lib_rend/ivas_reverb_utils.c @@ -51,7 +51,6 @@ #define CLDFB_CONVOLVER_NTAPS_MAX ( 16 ) #define FFT_SPECTRUM_SIZE ( 1 + ( RV_FILTER_MAX_FFT_SIZE / 2 ) ) -#define N_INITIAL_IGNORED_FRAMES 4 /*-----------------------------------------------------------------------------------------* * Local function prototypes @@ -69,13 +68,14 @@ typedef struct cldfb_convolver_state static void ivas_reverb_set_energies( const float *avg_pwr_l, const float *avg_pwr_r, const int32_t sampling_rate, float *avg_pwr_l_out, float *avg_pwr_r_out ); + /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_prepare_cldfb_params() * * Prepares reverb parameters for CLDFB-based reverberator *-----------------------------------------------------------------------------------------*/ -ivas_error ivas_reverb_prepare_cldfb_params( +void ivas_reverb_prepare_cldfb_params( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_STATISTICS_HANDLE hHrtfStatistics, const int32_t output_Fs, @@ -116,7 +116,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( pOutput_ene[idx] *= 0.5f * ( avg_pwr_left[idx] + avg_pwr_right[idx] ) * dmx_gain_2; } - return IVAS_ERR_OK; + return; } @@ -138,7 +138,9 @@ static void ivas_reverb_set_energies( const int16_t cldfb_freq_halfstep = MAX_SAMPLING_RATE / ( 4 * CLDFB_NO_CHANNELS_MAX ); float input_fc[FFT_SPECTRUM_SIZE]; float output_fc[CLDFB_NO_CHANNELS_MAX]; - const int16_t avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; + int16_t avg_pwr_len; + + avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; for ( freq_idx = 0; freq_idx < avg_pwr_len; freq_idx++ ) { @@ -151,4 +153,6 @@ static void ivas_reverb_set_energies( } ivas_reverb_interpolate_acoustic_data( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); + + return; } -- GitLab From a2c6b24064d55c6a6c02fa3c19d111aef01d7d15 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 20 Mar 2024 12:07:57 +0100 Subject: [PATCH 34/52] MASA constants --- lib_com/ivas_cnst.h | 9 --------- lib_com/ivas_masa_com.c | 10 ++++++++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index a3fd118548..a2989de0c0 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1132,7 +1132,6 @@ enum #define MASA_MAXIMUM_DIRECTIONS 2 #define MASA_MAX_TRANSPORT_CHANNELS 2 - #define MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS 5 #define MASA_DELTA_AZI_DCT0 30 @@ -1178,8 +1177,6 @@ enum #define HR_MASA_ER_LEVELS 16 #define MAX_REDUCED_NBANDS 18 /* max number of subbands that is less than the default value 24 */ -#define LIMIT_ER_ELEVATION_ENC 4 -#define LIMIT_ER_SIMPLE_ENC 6 #define LIMIT_USE_COMMON 3 #define MASA_COHERENCE_TOLERANCE 0.1f @@ -1199,12 +1196,6 @@ enum #define MASA_LIMIT_IDX_AVG_AZI 4 #define MASA_NO_POINTS_EQUATOR 430 -#define MASA_NO_CIRCLES 121 -#define MASA_ASIN_OFFSET 0.0064471690266724975f -#define MASA_NTOT2_FAC 32768.00566947353f -#define MASA_ANGLE_AT_EQUATOR 0.012894427382667f -#define MASA_ANGLE_AT_EQUATOR_DEG 0.738796268264740f -#define MASA_INV_ANGLE_AT_EQUATOR_DEG 1.353553128183453f #define MASA_STEREO_MIN_BITRATE IVAS_24k4 #define MAXIMUM_OMASA_FREQ_BANDS 8 /* Corresponds to maximum number of coding bands at 32 kbps */ #define OMASA_STEREO_SW_CNT_MAX 100 diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 91b548f4db..280531f2d4 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -49,8 +49,14 @@ *---------------------------------------------------------------*/ #define MASA_EXTRA_BAND_META_BITS 40 - -#define MASA_SMALL_INC_META_BITS 10 +#define MASA_SMALL_INC_META_BITS 10 + +#define MASA_NO_CIRCLES 121 +#define MASA_ASIN_OFFSET 0.0064471690266724975f +#define MASA_NTOT2_FAC 32768.00566947353f +#define MASA_ANGLE_AT_EQUATOR 0.012894427382667f +#define MASA_ANGLE_AT_EQUATOR_DEG 0.738796268264740f +#define MASA_INV_ANGLE_AT_EQUATOR_DEG 1.353553128183453f /*--------------------------------------------------------------- -- GitLab From da96089101d91abccfae999cdbfee2079a11a09c Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 24 Apr 2024 13:05:28 +0200 Subject: [PATCH 35/52] update with main --- lib_enc/ivas_ism_metadata_enc.c | 12 ++++++------ lib_rend/ivas_prot_rend.h | 14 +++++++------- lib_rend/lib_rend.c | 1 + lib_rend/lib_rend.h | 12 +++++------- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index c7b991e2f6..cfeff3ca47 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -874,12 +874,12 @@ ivas_error ivas_ism_metadata_enc_create( *-------------------------------------------------------------------------*/ static void encode_radius( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - int16_t *last_radius_idx, /* i/o: last radius index */ - int16_t *radius_diff_cnt, /* i/o: radius diff coding counter */ - const int16_t last_ism_metadata_flag, /* last frame ism_metadata_flag */ - const int16_t idx_radius_abs, /* i : Azimuth index */ - int16_t *flag_abs_radius /* o : Radius encoding mode */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + int16_t *last_radius_idx, /* i/o: last radius index */ + int16_t *radius_diff_cnt, /* i/o: radius diff coding counter */ + const int16_t last_ism_metadata_flag, /* i : last frame ism_metadata_flag */ + const int16_t idx_radius_abs, /* i : Azimuth index */ + int16_t *flag_abs_radius /* o : Radius encoding mode */ ) { int16_t idx_radius, nbits_diff_radius, diff; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 5148e03bda..4272e8be8f 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1334,19 +1334,19 @@ ivas_error ivas_combined_orientation_open( ); void ivas_combined_orientation_close( - COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* i/o: combined orientation handle */ + COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* i/o: combined orientation handle */ ); ivas_error combine_external_and_head_orientations_dec( - HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ + HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ + EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ); ivas_error combine_external_and_head_orientations_rend( - IVAS_REND_HeadRotData *hHeadTrackData, /* i : head track handle */ - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ + IVAS_REND_HeadRotData *hHeadTrackData, /* i : head track handle */ + EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ); /*----------------------------------------------------------------------------------* diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 64a66278c7..3558ebc992 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -3382,6 +3382,7 @@ static ivas_error validateCustomLsLayout( * IVAS_REND_ConfigureCustomOutputLoudspeakerLayout() * * + * Note: this will reset custom LFE routings set for any MC input *-------------------------------------------------------------------*/ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index f8d176167f..dcb73f99c4 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -135,7 +135,6 @@ ivas_error IVAS_REND_Open( const int16_t num_subframes /* i : number of subframes */ ); -/* Note: this will reset custom LFE routings set for any MC input */ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_CUSTOM_LS_DATA layout /* i : custom loudspeaker layout for renderer output */ @@ -155,7 +154,6 @@ ivas_error IVAS_REND_AddInput( IVAS_REND_InputId *inputId /* o : ID of the new input */ ); -/* Note: this will reset any custom LFE routing set for the input */ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_REND_InputId inputId, /* i : ID of the input */ @@ -355,16 +353,16 @@ ivas_error IVAS_REND_GetCombinedOrientation( ); ivas_error IVAS_REND_GetMasaMetadata( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to analyzed MASA metadata */ - const IVAS_REND_AudioConfigType inputType /* i : Input type */ + const IVAS_REND_AudioConfigType inputType /* i : Input type */ ); ivas_error IVAS_REND_MergeMasaMetadata( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to merged metadata */ - const IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ - const IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ + const IVAS_REND_AudioConfigType inputType1, /* i : Input type 1 */ + const IVAS_REND_AudioConfigType inputType2 /* i : Input type 2 */ ); ivas_error IVAS_REND_SetTotalNumberOfObjects( -- GitLab From 4fdaa656ab3b8c2789fa8235d32b6b0b520c17c4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 2 May 2024 09:34:51 +0200 Subject: [PATCH 36/52] clang-format --- apps/decoder.c | 4 +++- apps/renderer.c | 2 ++ lib_dec/ivas_binRenderer_internal.c | 3 ++- lib_dec/ivas_rom_dec.h | 1 - lib_enc/ivas_mct_core_enc.c | 2 +- lib_rend/lib_rend.c | 5 ++++- lib_util/render_config_reader.c | 2 ++ 7 files changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 04a35db8ff..65c3d9a91f 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -927,6 +927,7 @@ cleanup: free( arg.aeSequence.pValidity ); } #endif + #ifdef DEBUG_SBA_AUDIO_DUMP IVAS_DEC_GetSbaDebugParams( hIvasDec, &numOutChannels, &numTransportChannels, &pca_ingest_channels ); @@ -1142,6 +1143,7 @@ static bool parseCmdlIVAS_dec( arg->tsmScaleFileName = NULL; #endif #endif + #ifdef FIX_1053_REVERB_RECONFIGURATION arg->aeSequence.count = 0; arg->aeSequence.pID = NULL; @@ -2293,6 +2295,7 @@ static ivas_error decodeG192( } } #endif + for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { ismWriters[i] = NULL; @@ -2301,7 +2304,6 @@ static ivas_error decodeG192( /* we always start with needing a new frame */ needNewFrame = true; - if ( !arg.quietModeEnabled ) { fprintf( stdout, "\n------ Running the decoder ------\n\n" ); diff --git a/apps/renderer.c b/apps/renderer.c index 2b1b5cce5b..50d4f75fcb 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -2036,12 +2036,14 @@ cleanup: free( bitsBufferData ); } #endif + #ifdef FIX_1053_REVERB_RECONFIGURATION if ( args.aeSequence.count > 0 ) { free( args.aeSequence.pID ); free( args.aeSequence.pValidity ); } + #endif for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) { diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index f3cab219ee..b707064027 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -54,8 +54,9 @@ *------------------------------------------------------------------------*/ #define REVERB_INPUT_DOWNMIX_CHANNELS ( 11 ) + /* Downmix table for sparse frequency domain reverberator */ -const float dmxmtx_table[BINAURAL_CHANNELS][REVERB_INPUT_DOWNMIX_CHANNELS] = { +static const float dmxmtx_table[BINAURAL_CHANNELS][REVERB_INPUT_DOWNMIX_CHANNELS] = { { 1.0f, 0.0f, 0.70709997f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.70709997f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f }, }; diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index 9b1b4ab9e1..3044bb06af 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -103,7 +103,6 @@ extern const float dirac_dithering_ele_scale[DIRAC_DIFFUSE_LEVELS]; extern const float dmxmtx_table[BINAURAL_CHANNELS][11]; #endif - /*----------------------------------------------------------------------* * MC ParamUpmix ROM tables *-----------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index d4aad15afa..02c6fc3865 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -499,7 +499,7 @@ void ivas_mct_core_enc( nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B - /*MCT is used at bitrates > 80 kbps and additional 1 bit is present at these bitrates*/ + /* MCT is used at bitrates > 80 kbps and additional 1 bit is present at these bitrates */ if ( ivas_format == SBA_ISM_FORMAT ) { nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index edf2115d5f..1e5788daea 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4463,6 +4463,7 @@ int16_t IVAS_REND_FeedRenderConfig( /* Skip inactive inputs */ continue; } + if ( pIsmInput->hReverb != NULL ) { if ( ( error = ivas_reverb_open( &pIsmInput->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pIsmInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) @@ -4470,6 +4471,7 @@ int16_t IVAS_REND_FeedRenderConfig( return error; } } + if ( pIsmInput->crendWrapper != NULL && pIsmInput->crendWrapper->hCrend[0] != NULL ) { #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -4540,6 +4542,7 @@ int16_t IVAS_REND_FeedRenderConfig( return error; } } + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( pMcInput->crendWrapper != NULL && pMcInput->crendWrapper->hCrend[0] && pMcInput->crendWrapper->hCrend[0]->hReverb != NULL ) { @@ -7855,7 +7858,7 @@ static ivas_error getSamplesInternal( } if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 75d756571e..1b2ac5d96f 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2864,9 +2864,11 @@ ivas_error RenderConfigReader_getAcousticEnvironment( pAcEnv->use_er = false; } #endif + return IVAS_ERR_OK; } } + return IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING; } -- GitLab From f7433f7979bbe5d822f34904ee4796e651fe8cf6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 21 May 2024 11:13:22 +0200 Subject: [PATCH 37/52] maintenance --- apps/decoder.c | 5 ++- lib_com/ivas_prot.h | 8 ++--- lib_com/ivas_sba_config.c | 2 ++ lib_dec/ivas_dirac_dec.c | 4 ++- lib_dec/ivas_dirac_output_synthesis_cov.c | 1 + lib_dec/ivas_init_dec.c | 23 +++++------- lib_dec/ivas_jbm_dec.c | 5 +-- lib_dec/ivas_masa_dec.c | 2 ++ lib_dec/ivas_mct_dec.c | 2 +- lib_dec/ivas_mdct_core_dec.c | 1 - lib_dec/ivas_sba_dec.c | 1 + lib_dec/lib_dec.c | 10 +++--- lib_dec/lib_dec.h | 16 ++++----- lib_enc/ivas_dirac_enc.c | 2 +- lib_enc/ivas_init_enc.c | 10 ++---- lib_enc/ivas_masa_enc.c | 2 ++ lib_enc/ivas_osba_enc.c | 14 ++++---- lib_enc/ivas_qmetadata_enc.c | 2 +- lib_enc/ivas_spar_encoder.c | 1 - lib_enc/ivas_spar_md_enc.c | 1 + lib_rend/ivas_objectRenderer.c | 4 ++- lib_rend/ivas_objectRenderer_mix.c | 2 ++ lib_rend/ivas_prot_rend.h | 2 ++ lib_rend/ivas_render_config.c | 2 ++ lib_rend/ivas_reverb.c | 1 + lib_util/hrtf_file_reader.c | 43 ++++++++++++++++++----- lib_util/render_config_reader.c | 19 ++++++++-- 27 files changed, 118 insertions(+), 67 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 39126a49a1..bdb700fdbb 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -664,6 +664,7 @@ int main( fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] ); goto cleanup; } + #ifdef CONF_DISTATT if ( ( error = RenderConfigReader_getDistanceAttenuation( renderConfigReader, renderConfig.distAtt ) ) != IVAS_ERR_OK ) { @@ -671,6 +672,7 @@ int main( goto cleanup; } #endif + #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) @@ -723,6 +725,7 @@ int main( } renderConfig.roomAcoustics.override = true; } + #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* ISAR frame size is set from command line, not renderer config file. @@ -1166,6 +1169,7 @@ static bool parseCmdlIVAS_dec( #else arg->acousticEnvironmentId = 65535; #endif + for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { arg->directivityPatternId[i] = 65535; @@ -2341,7 +2345,6 @@ static ivas_error decodeG192( #ifdef SPLIT_REND_WITH_HEAD_ROT SplitFileReadWrite *splitRendWriter = NULL; #endif - #ifdef FIX_1053_REVERB_RECONFIGURATION IVAS_RENDER_CONFIG_DATA renderConfig; RenderConfigReader *renderConfigReader = NULL; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 31cb982c48..4ef31fce85 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3207,7 +3207,7 @@ void ivas_qmetadata_enc_sid_encode( IVAS_QMETADATA *q_metadata, /* i/o: metadata handle */ const int16_t masa_sid_descriptor, /* i : description of MASA SID coding structure*/ #ifdef NONBE_FIX_1052_SBA_EXT - const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nchan_transport, /* i : number of transport channels */ #endif const int16_t ivas_format /* i : ivas format */ ); @@ -3519,7 +3519,7 @@ int16_t ivas_sba_get_nchan_metadata( #ifdef NONBE_FIX_1052_SBA_EXT /*! r: number of bits in SPAR SID frame */ int16_t ivas_sba_spar_sid_bitlen( - const int16_t nchan_transport /* i : number of transport channels */ + const int16_t nchan_transport /* i : number of transport channels */ ); #endif @@ -3625,7 +3625,7 @@ ivas_error ivas_dirac_enc( const int16_t dtx_vad, /* i : DTX vad flag */ const IVAS_FORMAT ivas_format, /* i : ivas format */ #ifdef NONBE_FIX_1052_SBA_EXT - const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nchan_transport, /* i : number of transport channels */ #endif const int16_t hodirac_flag /* i : hodirac flag */ ); @@ -3683,7 +3683,7 @@ void ivas_dirac_dec_read_BS( const int16_t last_bit_pos, /* i : last read bitstream position */ const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ #ifdef NONBE_FIX_1052_SBA_EXT - const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nchan_transport, /* i : number of transport channels */ #endif int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ); diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index a622d8f88f..28769c7fc5 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -158,6 +158,7 @@ int16_t ivas_sba_get_nchan( return ( nb_channels ); } + #ifdef NONBE_FIX_1052_SBA_EXT /*-------------------------------------------------------------------* * ivas_sba_spar_sid_bitlen() @@ -182,6 +183,7 @@ int16_t ivas_sba_spar_sid_bitlen( } #endif + /*-------------------------------------------------------------------* * ivas_sba_get_nchan_metadata() * diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 0a2aeefa0d..f60eb78217 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1014,7 +1014,7 @@ void ivas_dirac_dec_read_BS( const int16_t last_bit_pos, /* i : last read bitstream position */ const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ #ifdef NONBE_FIX_1052_SBA_EXT - const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nchan_transport, /* i : number of transport channels */ #endif int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) @@ -1107,6 +1107,7 @@ void ivas_dirac_dec_read_BS( #else st->next_bit_pos = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC - 1 - SID_FORMAT_NBITS ); #endif + /* 1 bit flag for signaling metadata to read */ b = st->bit_stream[( st->next_bit_pos )--]; ( *nb_bits )++; @@ -1131,6 +1132,7 @@ void ivas_dirac_dec_read_BS( #else *nb_bits += ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), 0, NULL, SBA_FORMAT ); #endif + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth[i] = hQMetaData->q_direction[0].band_data[1].azimuth[0]; diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 00d7b2b776..6e84e63910 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -589,6 +589,7 @@ int16_t computeMixingMatrices( #else limit = limit * reg_Sx + EPSILON; #endif + for ( i = 0; i < lengthCx; ++i ) { svd_s_buffer[i] = ( ( svd_s_buffer[i] > limit ) ? svd_s_buffer[i] : limit ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 6da12ffff4..bdb0c479b1 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -247,7 +247,8 @@ static ivas_error ivas_dec_init_split_rend( #endif #ifdef NONBE_FIX_1052_SBA_EXT -static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ) +static AUDIO_CONFIG ivas_set_output_config_from_sba_order( + const int16_t sba_order ) { AUDIO_CONFIG output_config; output_config = IVAS_AUDIO_CONFIG_HOA3; @@ -286,7 +287,7 @@ ivas_error ivas_dec_setup( #endif ) { - int16_t k, idx, num_bits_read; + int16_t k, n, idx, num_bits_read; int16_t nchan_ism, element_mode_flag; Decoder_State *st; int32_t ivas_total_brate; @@ -415,6 +416,7 @@ ivas_error ivas_dec_setup( { st_ivas->nchan_ism = 1; } + /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/ #else /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ @@ -534,17 +536,14 @@ ivas_error ivas_dec_setup( if ( st_ivas->ini_frame > 0 && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { #ifdef NONBE_FIX_ISM_XOVER_BR - { - int16_t n; - - n = st_ivas->nchan_transport + st_ivas->nchan_ism; - st_ivas->nCPE = ( n + 1 ) >> 1; - } + n = st_ivas->nchan_transport + st_ivas->nchan_ism; + st_ivas->nCPE = ( n + 1 ) >> 1; #else st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; #endif } } + #ifdef NONBE_FIX_ISM_XOVER_BR if ( ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ) == ISM_SBA_MODE_DISC ) #else @@ -1666,12 +1665,8 @@ ivas_error ivas_init_decoder( if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { #ifdef NONBE_FIX_ISM_XOVER_BR - { - int16_t n_all; - - n_all = st_ivas->nchan_transport + st_ivas->nchan_ism; - st_ivas->nCPE = ( n_all + 1 ) >> 1; - } + n = st_ivas->nchan_transport + st_ivas->nchan_ism; + st_ivas->nCPE = ( n + 1 ) >> 1; #else st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index e75d0c9430..580a58fdf3 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -1674,10 +1674,11 @@ ivas_error ivas_jbm_dec_flush_renderer( } } #endif + if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV || renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { #ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : st_ivas->hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) #else @@ -1686,7 +1687,7 @@ ivas_error ivas_jbm_dec_flush_renderer( #endif #else -#if defined SPLIT_REND_WITH_HEAD_ROT +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) #else diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index d43b29cb88..14539b40e4 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -157,6 +157,7 @@ ivas_error ivas_masa_decode( /* re-read the number of objects, needed in case of bad frame */ st_ivas->nchan_ism = 5 - ( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 3] + 2 * st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 2] ); } + if ( ivas_format == MASA_FORMAT && st_ivas->nchan_ism != 5 ) { /* there was OMASA in the input */ @@ -175,6 +176,7 @@ ivas_error ivas_masa_decode( byteBuffer = st->bit_stream[( st->next_bit_pos )--]; byteBuffer = st->bit_stream[( st->next_bit_pos )--]; *nb_bits_read += MASA_HEADER_BITS; + /* read number of directions */ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; ( *nb_bits_read )++; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 71859dab42..ec10e21af5 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -334,7 +334,6 @@ ivas_error ivas_mct_dec( dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.cpe", 0, cpe_id, DEC ) ); } #endif - pop_wmops(); return error; } @@ -1255,6 +1254,7 @@ static ivas_error ivas_mc_dec_reconfig( if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) ) { ivas_binRenderer_close( &st_ivas->hBinRenderer ); + #ifdef FIX_1068_ASAN_IN_MC_2_BINAURAL_ROOM_IR if ( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) { diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 3f8ff738c7..6c072b0103 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -969,7 +969,6 @@ void ivas_mdct_core_reconstruct( } } #endif - /* updates */ st->last_voice_factor = 0.0f; st->last_coder_type = st->coder_type; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 136857015c..83a55f646a 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -462,6 +462,7 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef NONBE_FIX_ISM_XOVER_BR nchan_transport = st_ivas->nchan_transport; #endif + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 6329ea08d0..9021d8f09d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3863,13 +3863,13 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ - ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ + int16_t *pIsar_frame_size_ms, /* o : pointer to isar frame size setting */ #endif - int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ + int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , int16_t *pLc3plusHighRes diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 37d77ef45d..51675b4026 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -179,16 +179,16 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( /*! r: decoder error code */ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ - ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + ISAR_SPLIT_REND_CODEC *pCodec, /* o : pointer to codec setting */ + ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o : pointer to pose correction mode */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS - int16_t *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ + int16_t *pIsar_frame_size_ms, /* o : pointer to isar frame size setting */ #endif - int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ + int16_t *pCodec_frame_size_ms /* o : pointer to codec frame size setting */ #ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , - int16_t *pLc3plusHighRes /* o: pointer to LC3plus High-Res setting */ + int16_t *pLc3plusHighRes /* o : pointer to LC3plus High-Res setting */ #endif ); @@ -202,10 +202,10 @@ ivas_error IVAS_DEC_GetCldfbSamples( ); int16_t IVAS_DEC_is_split_rendering_enabled( - IVAS_DEC_HANDLE hIvasDec /* i: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec /* i : IVAS decoder handle */ ); int16_t IVAS_DEC_is_split_rendering_coded_out( - IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ); #endif diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index cd4dbe6438..3b96bff79f 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -292,7 +292,7 @@ ivas_error ivas_dirac_enc( const int16_t dtx_vad, /* i : DTX vad flag */ const IVAS_FORMAT ivas_format, /* i : ivas format */ #ifdef NONBE_FIX_1052_SBA_EXT - const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nchan_transport, /* i : number of transport channels */ #endif const int16_t hodirac_flag /* i : hodirac flag */ ) diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 0371378d73..09cf0abb8f 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -736,17 +736,13 @@ ivas_error ivas_init_encoder( else { /* allocate and initialize MCT core coder */ - #ifdef NONBE_FIX_ISM_XOVER_BR - { - int16_t n_all; - - n_all = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; - st_ivas->nCPE = ( n_all + 1 ) >> 1; - } + int16_t n_all = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; + st_ivas->nCPE = ( n_all + 1 ) >> 1; #else st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; #endif + for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 2c5e2bb5b2..851baa166f 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -481,6 +481,7 @@ ivas_error ivas_masa_encode( push_next_indice( hMetaData, 0, MASA_HEADER_BITS ); hQMetaData->metadata_max_bits -= MASA_HEADER_BITS; } + #ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR if ( !( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MODE_NONE && nchan_ism > 2 ) ) { @@ -491,6 +492,7 @@ ivas_error ivas_masa_encode( #ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR } #endif + /* write subframe mode */ push_next_indice( hMetaData, hQMetaData->q_direction[0].cfg.nblocks == 1 ? 1 : 0, MASA_SUBFRAME_BITS ); hQMetaData->metadata_max_bits -= MASA_SUBFRAME_BITS; diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 8415e02e5c..9716d288c3 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -181,14 +181,13 @@ ivas_error ivas_osba_enc_reconfig( int32_t ivas_total_brate; ivas_error error; ENCODER_CONFIG_HANDLE hEncoderConfig; - +#ifdef NONBE_FIX_ISM_XOVER_BR + int16_t nchan_transport; +#endif error = IVAS_ERR_OK; hEncoderConfig = st_ivas->hEncoderConfig; ivas_total_brate = hEncoderConfig->ivas_total_brate; -#ifdef NONBE_FIX_ISM_XOVER_BR - int16_t nchan_transport; -#endif if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) { @@ -346,13 +345,12 @@ ivas_error ivas_osba_enc_reconfig( #ifdef NONBE_FIX_ISM_XOVER_BR nchan_transport = st_ivas->nchan_transport; #endif + if ( old_ism_mode == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { #ifdef NONBE_FIX_ISM_XOVER_BR - { - nchan_transport = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; - st_ivas->nCPE = ( nchan_transport + 1 ) >> 1; - } + nchan_transport = st_ivas->nchan_transport + st_ivas->hEncoderConfig->nchan_ism; + st_ivas->nCPE = ( nchan_transport + 1 ) >> 1; #else st_ivas->nCPE += ( st_ivas->hEncoderConfig->nchan_ism + 1 ) >> 1; #endif diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index dc4806ed19..56759b07fa 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -956,7 +956,7 @@ void ivas_qmetadata_enc_sid_encode( IVAS_QMETADATA *q_metadata, /* i/o: metadata handle */ const int16_t masa_sid_descriptor, /* i : description of MASA SID coding structure */ #ifdef NONBE_FIX_1052_SBA_EXT - const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nchan_transport, /* i : number of transport channels */ #endif const int16_t ivas_format /* i : IVAS format */ ) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 0a6f44b1d0..dd0a268bad 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -707,7 +707,6 @@ static ivas_error ivas_spar_enc_process( } #endif - /* Set Energy Ratio to 0.0 if the mono flag has been set */ if ( hQMetaData->dirac_mono_flag ) { diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 83ff86b68b..121bea1983 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -1719,6 +1719,7 @@ static void ivas_write_parameter_bitstream_dtx( #ifdef NONBE_FIX_1052_SBA_EXT int16_t sba_spar_bitlen; #endif + sid_bits_len = hMetaData->nb_bits_tot; pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 0c1d5ff582..64ffa92808 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -241,6 +241,7 @@ ivas_error ivas_td_binaural_open_unwrap( DirAtten_p->ConeOuterAngle = directivity[nS * 3 + 1]; DirAtten_p->ConeOuterGain = directivity[nS * 3 + 2]; } + #ifdef CONF_DISTATT if ( NULL == distAtt ) { @@ -257,10 +258,12 @@ ivas_error ivas_td_binaural_open_unwrap( DistAtten.RollOffFactor = distAtt[2]; } #endif + if ( ( error = TDREND_MIX_SRC_SetDirAtten( pBinRendTd, nS, DirAtten_p ) ) != IVAS_ERR_OK ) { return error; } + #ifdef CONF_DISTATT if ( ( error = TDREND_MIX_SRC_SetDistAtten( pBinRendTd, nS, &DistAtten ) ) != IVAS_ERR_OK ) { @@ -676,7 +679,6 @@ ivas_error ivas_td_binaural_open_ext( IVAS_FORMAT ivas_format; IVAS_OUTPUT_SETUP hTransSetup; ivas_error error; - #ifdef CONF_DISTATT float *distAtt = NULL; #endif diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index b2492324c9..2da2e7c918 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -445,6 +445,7 @@ static ivas_error DefaultBSplineModel( } model->azimBsShape[0] = (const float *) defaultHRIR_rom_azimBsShape; + #ifdef FIX_989_TD_REND_ROM if ( ( model->azimKSeq = (float **) malloc( model->elevDim3 * sizeof( float * ) ) ) == NULL ) #else @@ -453,6 +454,7 @@ static ivas_error DefaultBSplineModel( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); } + #ifdef FIX_989_TD_REND_ROM for ( i = 0; i < model->elevDim3; i++ ) { diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 445ab13b9a..6b6bbcf8e4 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -728,6 +728,7 @@ ivas_error TDREND_MIX_SRC_SetDirAtten( const int16_t SrcInd, /* i : Source index */ const TDREND_DirAtten_t *DirAtten_p /* i : Directional attenuation specifier */ ); + #ifdef CONF_DISTATT ivas_error TDREND_MIX_SRC_SetDistAtten( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ @@ -735,6 +736,7 @@ ivas_error TDREND_MIX_SRC_SetDistAtten( const TDREND_DistAtten_t *DistAtten_p /* i : Distance attenuation specifier */ ); #endif + ivas_error TDREND_MIX_SRC_SetPlayState( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index 4583d65fd6..e9918f162c 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -131,11 +131,13 @@ ivas_error ivas_render_config_init_from_rom( ( *hRenderConfig )->directivity[i * 3 + 1] = 360.0f; /* Back cone */ ( *hRenderConfig )->directivity[i * 3 + 2] = 1.0f; /* Back attenuation */ } + #ifdef CONF_DISTATT ( *hRenderConfig )->distAtt[0] = 15.75f; /* Default max dist */ ( *hRenderConfig )->distAtt[1] = 1.0f; /* Default ref dist */ ( *hRenderConfig )->distAtt[2] = 1.0f; /* Default rolloff factor */ #endif + #ifdef SPLIT_REND_WITH_HEAD_ROT ( *hRenderConfig )->split_rend_config.splitRendBitRate = SPLIT_REND_768k; ( *hRenderConfig )->split_rend_config.dof = 3; diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index 372d832e81..97b97038ed 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -982,6 +982,7 @@ static ivas_error setup_FDN_branches( #ifndef FIX_1053_REVERB_RECONFIGURATION float *pCoef_a, *pCoef_b; #endif + error = IVAS_ERR_OK; /* initialize feedback branches */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 25b9153750..3a9307de5c 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -67,9 +67,11 @@ typedef struct ivas_hrtfs_file_header_t #define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f ) #define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f ) + #ifdef FLOAT_FIX_POINT_HRTF_FILE_FORMAT #define DEFAULT_BIN_FILE_FX_FLAG 0x1000 #endif + /*---------------------------------------------------------------------* * Local function declarations *---------------------------------------------------------------------*/ @@ -236,13 +238,15 @@ static ivas_error read_hrtf_binary_header( FILE *f_hrtf ) { /* HRTF Header */ - /* Renderer type (4 bytes) : See "HRTF_READER_RENDERER_TYPE" */ + /* Renderer type (4 bytes) : See "HRTF_READER_RENDERER_TYPE" */ /* Input configuration (4 bytes) : See "BINAURAL_INPUT_AUDIO_CONFIG" */ /* Sampling Frequency (4 bytes) */ /* Raw data size (4 bytes) */ + #ifdef FLOAT_FIX_POINT_HRTF_FILE_FORMAT *is_fix_point = 0; #endif + if ( ( fread( &( hrtf_header->rend_type ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->input_cfg ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->frequency ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) && ( fread( &( hrtf_header->data_size ), sizeof( int32_t ), 1, f_hrtf ) == 1 ) ) { #ifdef FLOAT_FIX_POINT_HRTF_FILE_FORMAT @@ -517,9 +521,9 @@ static ivas_error LoadBSplineBinary( --------------------------------------------------------------------*/ static ivas_error load_reverb_from_binary( - IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ - int32_t sampleRate, /* i : sample rate */ - FILE *f_hrtf /* i : HR filter data file handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ + int32_t sampleRate, /* i : sample rate */ + FILE *f_hrtf /* i : HR filter data file handle */ ) { bool is_reverb; @@ -613,6 +617,7 @@ static ivas_error load_reverb_from_binary( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } + #ifdef FLOAT_FIX_POINT_HRTF_FILE_FORMAT if ( is_fx ) { @@ -789,6 +794,7 @@ static ivas_error TDREND_MIX_LoadHRTF( { return IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA; } + return header_check_result; } @@ -813,6 +819,7 @@ ivas_error load_HRTF_binary( return error; } + /*---------------------------------------------------------------------* * HRTF_energy_sections_precalc() * @@ -1190,6 +1197,7 @@ static ivas_error create_HRTF_from_rawdata( return IVAS_ERR_OK; } + #ifdef FLOAT_FIX_POINT_HRTF_FILE_FORMAT /*---------------------------------------------------------------------* * create_HRTF_from_rawdata_fx() @@ -1458,6 +1466,13 @@ static ivas_error create_HRTF_from_rawdata_fx( return IVAS_ERR_OK; } + +/*---------------------------------------------------------------------* + * create_fastconv_HRTF_from_rawdata_fx() + * + * + *---------------------------------------------------------------------*/ + static ivas_error create_fastconv_HRTF_from_rawdata_fx( HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ char *hrtf_data, /* i : pointer to binary file */ @@ -1936,6 +1951,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * create_parambin_HRTF_from_rawdata_fx() * @@ -1943,8 +1959,8 @@ static ivas_error create_fastconv_HRTF_from_rawdata_fx( *---------------------------------------------------------------------*/ static ivas_error create_parambin_HRTF_from_rawdata_fx( - HRTFS_PARAMBIN_HANDLE *hHRTF, /* i/o: Parametric binauralizer HRTF handle */ - char *hrtf_data /* i : pointer to binary file */ + HRTFS_PARAMBIN_HANDLE *hHRTF, /* i/o: Parametric binauralizer HRTF handle */ + char *hrtf_data /* i : pointer to binary file */ ) { int16_t i, j, k; @@ -2045,6 +2061,12 @@ static ivas_error create_parambin_HRTF_from_rawdata_fx( #endif +/*---------------------------------------------------------------------* + * create_fastconv_HRTF_from_rawdata() + * + * + *---------------------------------------------------------------------*/ + static ivas_error create_fastconv_HRTF_from_rawdata( HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ char *hrtf_data, /* i : pointer to binary file */ @@ -2494,8 +2516,8 @@ ivas_error load_fastconv_HRTF_from_binary( *---------------------------------------------------------------------*/ static ivas_error create_parambin_HRTF_from_rawdata( - HRTFS_PARAMBIN_HANDLE *hHRTF, /* i/o: Parametric binauralizer HRTF handle */ - char *hrtf_data /* i : pointer to binary file */ + HRTFS_PARAMBIN_HANDLE *hHRTF, /* i/o: Parametric binauralizer HRTF handle */ + char *hrtf_data /* i : pointer to binary file */ ) { int16_t i, j; @@ -2665,6 +2687,7 @@ ivas_error load_parambin_HRTF_from_binary( } } + /*---------------------------------------------------------------------* * create_SetOfHRTF_from_binary() * @@ -2913,6 +2936,8 @@ void destroy_parambin_hrtf( return; } + + /*---------------------------------------------------------------------* * destroy_hrtf_statistics() * @@ -2929,6 +2954,8 @@ ivas_error destroy_hrtf_statistics( free( ( *hHrtfStatistics )->average_energy_r ); free( ( *hHrtfStatistics )->inter_aural_coherence ); } + ivas_HRTF_statistics_close( hHrtfStatistics ); + return IVAS_ERR_OK; } diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 09b3911366..44f473eb55 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1037,6 +1037,7 @@ static ivas_error get_bin_outer_attenuation( } #ifdef CONF_DISTATT + /*-----------------------------------------------------------------------------------------* * Function get_bin_max_dist () * Gets a Maximum Distance value [1.0, 64.0] @@ -1060,6 +1061,7 @@ static ivas_error get_bin_max_dist( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_ref_dist () * Gets a Reference Distance value [0.1, 6.4] @@ -1083,6 +1085,7 @@ static ivas_error get_bin_ref_dist( return IVAS_ERR_OK; } + /*-----------------------------------------------------------------------------------------* * Function get_bin_rolloff () * Gets a Rollof Factor [0.0, 4.0] @@ -1243,7 +1246,6 @@ ivas_error RenderConfigReader_checkValues( int16_t i; #endif - /* Verify the number of frequency bands in the config input data */ if ( ( pRoom_acoustics->nBands > N_BANDS_MAX ) || ( pRoom_acoustics->nBands < N_BANDS_MIN ) ) { @@ -1377,7 +1379,6 @@ ivas_error RenderConfigReader_checkValues( #endif } - return IVAS_ERR_OK; } @@ -1939,6 +1940,7 @@ static ivas_error RenderConfigReader_readBinary( } } } + #ifdef CONF_DISTATT /**********************************/ /* Read the distance attenuation */ @@ -1969,7 +1971,6 @@ static ivas_error RenderConfigReader_readBinary( } #endif - /* Cleanup */ free( pRenderConfigReader->pBitstream ); @@ -1977,6 +1978,12 @@ static ivas_error RenderConfigReader_readBinary( } +/*------------------------------------------------------------------------------------------* + * RenderConfigReader_read() + * + * + *------------------------------------------------------------------------------------------*/ + ivas_error RenderConfigReader_read( RenderConfigReader *pRenderConfigReader, /* i : RenderConfigReader handle */ const char *pRenderConfigPath, /* i : Renderer configuration file path */ @@ -2979,6 +2986,7 @@ ivas_error RenderConfigReader_read( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------------------------* * RenderConfigReader_getEnvironment() * @@ -3132,6 +3140,7 @@ ivas_error RenderConfigReader_getDirectivity( } #ifdef CONF_DISTATT + /*------------------------------------------------------------------------------------------* * RenderConfigReader_getDistanceAttenuation() * @@ -3158,6 +3167,7 @@ ivas_error RenderConfigReader_getDistanceAttenuation( return IVAS_ERR_OK; } + #endif /*------------------------------------------------------------------------------------------* @@ -3196,13 +3206,16 @@ void RenderConfigReader_close( free( ( *ppRenderConfigReader )->pFG[n].pFc ); } free( ( *ppRenderConfigReader )->pFG ); + /* Free the directivity patterns */ for ( n = 0; n < ( *ppRenderConfigReader )->nDP; n++ ) { free( ( *ppRenderConfigReader )->pDP[n].pDirectivity ); } + free( ( *ppRenderConfigReader )->pDP ); fclose( ( *ppRenderConfigReader )->pConfigFile ); + free( *ppRenderConfigReader ); return; -- GitLab From a42390a73898daceb18efedfd5d3d59e8a9d636f Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 30 May 2024 11:04:30 +0200 Subject: [PATCH 38/52] simplify dereferencing + comments --- lib_com/ivas_prot.h | 2 +- lib_com/ivas_rom_com.c | 2 +- lib_com/ivas_sba_config.c | 8 +- lib_dec/ivas_jbm_dec.c | 209 ++++++++++++++++++++------------------ lib_dec/ivas_sba_dec.c | 87 ++++++++-------- 5 files changed, 160 insertions(+), 148 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 4ef31fce85..5a4ad9cd42 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3526,7 +3526,7 @@ int16_t ivas_sba_spar_sid_bitlen( void ivas_sba_get_spar_hoa_ch_ind( const int16_t num_md_chs, /* i : number of MD channels */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] + int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] /* o : channel indexes */ ); /*! r: flag indicating to code SPAR HOA MD for all bands */ diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index c0c8de6ad5..0146b44814 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -1467,7 +1467,7 @@ const int16_t remix_order_set[1][DIRAC_MAX_ANA_CHANS] = { /* WYZX --> WYXZ... */ const int16_t HOA_keep_ind[IVAS_SPAR_MAX_FB_IN_CHAN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15}; const int16_t HOA_keep_ind_spar[IVAS_SPAR_MAX_CH] = {0, 1, 2, 3, 4, 8, 9, 10, 10, 10, 10}; -const int16_t HOA_keep_ind_spar512[IVAS_SPAR_MAX_CH] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; +const int16_t HOA_keep_ind_spar512[IVAS_SPAR_MAX_CH] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; /*----------------------------------------------------------------------* diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 28769c7fc5..899c0623c2 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -226,11 +226,11 @@ int16_t ivas_sba_get_nchan_metadata( * *-------------------------------------------------------------------*/ -/*! r: flag indicating to code SPAR HOA MD for all bands */ void ivas_sba_get_spar_hoa_ch_ind( - const int16_t num_md_chs, /* i : number of MD channels */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] ) + const int16_t num_md_chs, /* i : number of MD channels */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] /* o : channel indexes */ +) { int16_t ch; const int16_t *hoa_ind; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 580a58fdf3..0d44064cfb 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -773,8 +773,8 @@ ivas_error ivas_jbm_dec_tc( float tmpF = ivas_total_brate / 1000.0f; dbgwrite( &tmpF, sizeof( float ), 1, output_frame, "res/ivas_total_brate.dec" ); } -#endif +#endif pop_wmops(); return IVAS_ERR_OK; @@ -797,8 +797,12 @@ void ivas_jbm_dec_feed_tc_to_renderer( float data_f[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* 'float' buffer for transport channels that will be directly converted with the CLDFB */ float *p_data_f[MAX_CLDFB_DIGEST_CHANNELS]; int16_t n, n_render_timeslots; + DECODER_TC_BUFFER_HANDLE hTcBuffer; push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); + + hTcBuffer = st_ivas->hTcBuffer; + for ( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) { p_data_f[n] = &data_f[n][0]; @@ -812,9 +816,9 @@ void ivas_jbm_dec_feed_tc_to_renderer( { *nSamplesResidual = 0; } - n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; + n_render_timeslots = hTcBuffer->n_samples_available / hTcBuffer->n_samples_granularity; - if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) + if ( hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); @@ -850,7 +854,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, hTcBuffer->n_samples_available ); } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -876,7 +880,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { - delay_signal( st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); + delay_signal( hTcBuffer->tc[n], hTcBuffer->n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); } } @@ -884,17 +888,17 @@ void ivas_jbm_dec_feed_tc_to_renderer( { if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { - n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + n_render_timeslots *= ( hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); } - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, hTcBuffer->n_samples_available ); } } else { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, hTcBuffer->n_samples_available ); } } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) @@ -912,10 +916,10 @@ void ivas_jbm_dec_feed_tc_to_renderer( { if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); + n_render_timeslots *= ( hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); } - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, hTcBuffer->n_samples_available ); if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { @@ -939,13 +943,13 @@ void ivas_jbm_dec_feed_tc_to_renderer( { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { - v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); + v_multc( hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, hTcBuffer->tc[CPE_CHANNELS + n], hTcBuffer->n_samples_available ); } #ifdef SPLIT_REND_WITH_HEAD_ROT if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { #endif - delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); + delay_signal( hTcBuffer->tc[CPE_CHANNELS + n], hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); #ifdef SPLIT_REND_WITH_HEAD_ROT } #endif @@ -961,7 +965,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) { - ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, hTcBuffer->n_samples_available ); } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { @@ -969,7 +973,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { - ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, hTcBuffer->n_samples_available ); } } @@ -1006,6 +1010,7 @@ ivas_error ivas_jbm_dec_render( ivas_error error; float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; float *p_tc[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; + DECODER_TC_BUFFER_HANDLE hTcBuffer; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; #ifdef SPLIT_REND_WITH_HEAD_ROT int16_t nchan_out_syn_output; @@ -1016,12 +1021,13 @@ ivas_error ivas_jbm_dec_render( * Initialization of local vars after struct has been set *----------------------------------------------------------------*/ + hTcBuffer = st_ivas->hTcBuffer; hSpatParamRendCom = st_ivas->hSpatParamRendCom; output_Fs = st_ivas->hDecoderConfig->output_Fs; nchan_out = st_ivas->hDecoderConfig->nchan_out; - nchan_transport = st_ivas->hTcBuffer->nchan_transport_jbm; + nchan_transport = hTcBuffer->nchan_transport_jbm; output_config = st_ivas->hDecoderConfig->output_config; - nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; + nSamplesAskedLocal = nSamplesAsked + hTcBuffer->n_samples_discard; for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { @@ -1030,21 +1036,21 @@ ivas_error ivas_jbm_dec_render( if ( !st_ivas->hDecoderConfig->Opt_tsm ) { - for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) + for ( n = 0; n < hTcBuffer->nchan_buffer_full; n++ ) { - p_tc[n] = &p_output[n][st_ivas->hTcBuffer->n_samples_rendered]; + p_tc[n] = &p_output[n][hTcBuffer->n_samples_rendered]; } for ( n = 0; n < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { - st_ivas->hTcBuffer->tc[n] = p_output[n]; + hTcBuffer->tc[n] = p_output[n]; } } else { - for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) + for ( n = 0; n < hTcBuffer->nchan_buffer_full; n++ ) { - p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered]; + p_tc[n] = &hTcBuffer->tc[n][hTcBuffer->n_samples_rendered]; } } @@ -1055,7 +1061,7 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->hCombinedOrientationData != NULL ) { /* take the discard samples into account here to make sure head rotation stays on the correct 5ms grid */ - st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start -= st_ivas->hTcBuffer->n_samples_discard; + st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start -= hTcBuffer->n_samples_discard; ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); } @@ -1068,7 +1074,7 @@ ivas_error ivas_jbm_dec_render( { assert( 0 ); } - else if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) + else if ( hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER ) { ivas_jbm_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output ); } @@ -1077,7 +1083,7 @@ ivas_error ivas_jbm_dec_render( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_MC ) { - *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + *nSamplesRendered = min( hTcBuffer->n_samples_available, nSamplesAskedLocal ); ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc, p_output ); } } @@ -1103,7 +1109,7 @@ ivas_error ivas_jbm_dec_render( } else /* ISM_MODE_DISC */ { - *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + *nSamplesRendered = min( hTcBuffer->n_samples_available, nSamplesAskedLocal ); /* Loudspeaker or Ambisonics rendering */ if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) @@ -1122,7 +1128,7 @@ ivas_error ivas_jbm_dec_render( #endif { /* Convert to Ambisonics */ - ivas_ism2sba_sf( st_ivas->hTcBuffer->tc, p_output, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order ); + ivas_ism2sba_sf( hTcBuffer->tc, p_output, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order ); } /* Binaural rendering */ @@ -1151,9 +1157,9 @@ ivas_error ivas_jbm_dec_render( { #if defined SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, - NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) + NULL, NULL, hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) #endif { return error; @@ -1162,7 +1168,7 @@ ivas_error ivas_jbm_dec_render( #ifdef DEBUGGING else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { - ivas_binaural_cldfb_sf( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->nb_subframes, p_output ); + ivas_binaural_cldfb_sf( st_ivas, *nSamplesRendered, hTcBuffer->nb_subframes, p_output ); } #endif } @@ -1235,7 +1241,7 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_OSBA_STEREO ) { - *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + *nSamplesRendered = min( hTcBuffer->n_samples_available, nSamplesAskedLocal ); /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case and non-TSM unified channel memory*/ if ( st_ivas->nchan_ism == 1 && st_ivas->hDecoderConfig->Opt_tsm == 0 ) @@ -1271,7 +1277,7 @@ ivas_error ivas_jbm_dec_render( for ( n = 0; n < st_ivas->nchan_ism; n++ ) { - mvr2r( st_ivas->hTcBuffer->tc[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); + mvr2r( hTcBuffer->tc[n] + hTcBuffer->n_samples_rendered, p_output[n], *nSamplesRendered ); } } else @@ -1311,15 +1317,15 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->ivas_format == MC_FORMAT ) { - for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) + for ( n = 0; n < hTcBuffer->nchan_buffer_full; n++ ) { - p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered]; + p_tc[n] = &hTcBuffer->tc[n][hTcBuffer->n_samples_rendered]; } if ( st_ivas->mc_mode == MC_MODE_MCT ) { int16_t crendInPlaceRotation = FALSE; - *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + *nSamplesRendered = min( hTcBuffer->n_samples_available, nSamplesAskedLocal ); if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) { @@ -1337,7 +1343,7 @@ ivas_error ivas_jbm_dec_render( if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + &st_ivas->hIntSetup, st_ivas->hEFAPdata, hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -1345,10 +1351,10 @@ ivas_error ivas_jbm_dec_render( else { if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) + &st_ivas->hIntSetup, st_ivas->hEFAPdata, hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + &st_ivas->hIntSetup, st_ivas->hEFAPdata, hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) #endif { return error; @@ -1361,7 +1367,7 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_MC ) { - *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + *nSamplesRendered = min( hTcBuffer->n_samples_available, nSamplesAskedLocal ); ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc, p_output ); } else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) @@ -1438,7 +1444,7 @@ ivas_error ivas_jbm_dec_render( /* we still need to copy the separate channel if available */ if ( st_ivas->hOutSetup.separateChannelEnabled ) { - mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); + mvr2r( hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); } ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); @@ -1459,13 +1465,13 @@ ivas_error ivas_jbm_dec_render( output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || output_config == IVAS_AUDIO_CONFIG_5_1_2 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) { - mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL] + offset, p_output[LFE_CHANNEL], *nSamplesRendered ); - mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); + mvr2r( hTcBuffer->tc[LFE_CHANNEL] + offset, p_output[LFE_CHANNEL], *nSamplesRendered ); + mvr2r( hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); } else if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ - mvr2r( st_ivas->hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); + mvr2r( hTcBuffer->tc[LFE_CHANNEL - 1] + offset, p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); } } } @@ -1477,20 +1483,20 @@ ivas_error ivas_jbm_dec_render( * - float to integer conversion *----------------------------------------------------------------*/ - st_ivas->hTcBuffer->n_samples_available -= *nSamplesRendered; - st_ivas->hTcBuffer->n_samples_rendered += *nSamplesRendered; + hTcBuffer->n_samples_available -= *nSamplesRendered; + hTcBuffer->n_samples_rendered += *nSamplesRendered; /* update global combined orientation start index */ ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); - if ( st_ivas->hTcBuffer->n_samples_discard > 0 ) + if ( hTcBuffer->n_samples_discard > 0 ) { for ( n = 0; n < min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); n++ ) { - p_output[n] += st_ivas->hTcBuffer->n_samples_discard; + p_output[n] += hTcBuffer->n_samples_discard; } - *nSamplesRendered -= st_ivas->hTcBuffer->n_samples_discard; - st_ivas->hTcBuffer->n_samples_discard = 0; + *nSamplesRendered -= hTcBuffer->n_samples_discard; + hTcBuffer->n_samples_discard = 0; } #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -1537,7 +1543,7 @@ ivas_error ivas_jbm_dec_render( ivas_syn_output( p_output, *nSamplesRendered, nchan_out, data ); #endif - *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; + *nSamplesAvailableNext = hTcBuffer->n_samples_available; pop_wmops(); return IVAS_ERR_OK; @@ -1643,10 +1649,10 @@ ivas_error ivas_jbm_dec_flush_renderer( #if defined SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, - NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) + NULL, NULL, hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, - NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + NULL, NULL, hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif { return error; @@ -1680,26 +1686,26 @@ ivas_error ivas_jbm_dec_flush_renderer( #ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : st_ivas->hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) + hIntSetupOld, st_ivas->hEFAPdata, hTcBuffer, crendInPlaceRotation ? p_output : hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : st_ivas->hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + hIntSetupOld, st_ivas->hEFAPdata, hTcBuffer, crendInPlaceRotation ? p_output : hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif #else #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) + hIntSetupOld, st_ivas->hEFAPdata, hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + hIntSetupOld, st_ivas->hEFAPdata, hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif #endif { return error; } - ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, hTcBuffer->tc, p_output ); } else if ( renderer_type_old == RENDERER_BINAURAL_OBJECTS_TD ) { @@ -1708,7 +1714,7 @@ ivas_error ivas_jbm_dec_flush_renderer( return error; } - ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, hTcBuffer->tc, p_output ); } else { @@ -1728,7 +1734,7 @@ ivas_error ivas_jbm_dec_flush_renderer( for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) { - tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered]; + tc_local[ch_idx] = &hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered]; mvr2r( st_ivas->hMasaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size ); } @@ -1745,8 +1751,8 @@ ivas_error ivas_jbm_dec_flush_renderer( { set_zero( p_output[ch_idx], (int16_t) ( *nSamplesRendered ) ); } - st_ivas->hTcBuffer->slots_rendered += 1; - st_ivas->hTcBuffer->subframes_rendered += 1; + hTcBuffer->slots_rendered += 1; + hTcBuffer->subframes_rendered += 1; } } } @@ -1765,7 +1771,7 @@ ivas_error ivas_jbm_dec_flush_renderer( /* copy from ISM delay buffer to the correct place in tcs */ for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ ) { - tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered]; + tc_local[ch_idx] = &hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered]; mvr2r( st_ivas->hSbaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size ); } @@ -1855,15 +1861,20 @@ ivas_error ivas_jbm_dec_set_discard_samples( ) { int16_t nMaxSlotsPerSubframe, nSlotsInFirstSubframe; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + + hTcBuffer = st_ivas->hTcBuffer; /* render first frame with front zero padding and discarding those samples */ - nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; - nSlotsInFirstSubframe = nMaxSlotsPerSubframe - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; + nSlotsInFirstSubframe = nMaxSlotsPerSubframe - hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1]; + if ( nSlotsInFirstSubframe > 0 ) { - st_ivas->hTcBuffer->n_samples_discard = ( nMaxSlotsPerSubframe - nSlotsInFirstSubframe ) * st_ivas->hTcBuffer->n_samples_granularity; + hTcBuffer->n_samples_discard = ( nMaxSlotsPerSubframe - nSlotsInFirstSubframe ) * hTcBuffer->n_samples_granularity; + /* set last subframes number to max to ensure correct continuation */ - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe; + hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe; } return IVAS_ERR_OK; @@ -2096,8 +2107,8 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc = st_ivas->nchan_transport; } - output_config = st_ivas->hDecoderConfig->output_config; + output_config = st_ivas->hDecoderConfig->output_config; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; if ( st_ivas->ivas_format == MONO_FORMAT ) @@ -2130,13 +2141,10 @@ int16_t ivas_jbm_dec_get_num_tc_channels( { num_tc = CPE_CHANNELS; } - if ( st_ivas->ivas_format == SBA_FORMAT ) - { - if ( num_tc == 3 ) - { - num_tc++; - } + if ( st_ivas->ivas_format == SBA_FORMAT && num_tc == 3 ) + { + num_tc++; } } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) @@ -2257,7 +2265,7 @@ static void ivas_jbm_dec_copy_tc( mvr2r( hTcBuffer->tc[ch] + hTcBuffer->n_samples_rendered, hTcBuffer->tc[ch] + hTcBuffer->n_samples_discard, n_samples_still_available ); for ( m = 0; m < nSamplesForRendering; m++ ) { - hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_jbm + ch]; + hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * hTcBuffer->nchan_transport_jbm + ch]; } } @@ -2268,7 +2276,7 @@ static void ivas_jbm_dec_copy_tc( mvr2r( hTcBuffer->tc[ch], tc_digest_f[ch], n_samples_still_available ); for ( m = 0; m < nSamplesForRendering; m++ ) { - tc_digest_f[ch][n_samples_still_available + m] = data[m * st_ivas->hTcBuffer->nchan_transport_jbm + ch]; + tc_digest_f[ch][n_samples_still_available + m] = data[m * hTcBuffer->nchan_transport_jbm + ch]; } mvr2r( tc_digest_f[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc[ch], *nSamplesResidual ); } @@ -2486,7 +2494,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; #ifdef DEBUGGING - nMaxSlotsPerSubframeOld = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; + nMaxSlotsPerSubframeOld = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; assert( hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] == nMaxSlotsPerSubframeOld ); if ( n_samples_granularity < hTcBuffer->n_samples_granularity ) { @@ -2602,31 +2610,33 @@ static void ivas_jbm_dec_tc_buffer_playout( float *output[] ) { int16_t ch_idx, slot_size, slots_to_render, first_sf, last_sf; + DECODER_TC_BUFFER_HANDLE hTcBuffer; - slot_size = st_ivas->hTcBuffer->n_samples_granularity; + hTcBuffer = st_ivas->hTcBuffer; + slot_size = hTcBuffer->n_samples_granularity; /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, nSamplesAsked / slot_size ); - st_ivas->hTcBuffer->slots_rendered += slots_to_render; + slots_to_render = min( hTcBuffer->num_slots - hTcBuffer->slots_rendered, nSamplesAsked / slot_size ); + hTcBuffer->slots_rendered += slots_to_render; *nSamplesRendered = (uint16_t) slots_to_render * slot_size; - first_sf = st_ivas->hTcBuffer->subframes_rendered; + first_sf = hTcBuffer->subframes_rendered; last_sf = first_sf; while ( slots_to_render > 0 ) { - slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; + slots_to_render -= hTcBuffer->subframe_nbslots[last_sf]; last_sf++; } #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif - for ( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) + for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_transport_jbm; ch_idx++ ) { - mvr2r( st_ivas->hTcBuffer->tc[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered, output[ch_idx], *nSamplesRendered ); + mvr2r( hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_rendered, output[ch_idx], *nSamplesRendered ); } - st_ivas->hTcBuffer->subframes_rendered = last_sf; + hTcBuffer->subframes_rendered = last_sf; return; } @@ -2677,36 +2687,39 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( { int16_t nMaxSlotsPerSubframe, nSlotsAvailable; uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + + hTcBuffer = st_ivas->hTcBuffer; - nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; - nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; - st_ivas->hTcBuffer->num_slots = nSlotsAvailable; - st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; - nSlotsInFirstSubframe = nMaxSlotsPerSubframe - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; - st_ivas->hTcBuffer->nb_subframes = 0; + nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity; + nSlotsAvailable = hTcBuffer->n_samples_available / hTcBuffer->n_samples_granularity; + hTcBuffer->num_slots = nSlotsAvailable; + hTcBuffer->n_samples_available = nSlotsAvailable * hTcBuffer->n_samples_granularity; + nSlotsInFirstSubframe = nMaxSlotsPerSubframe - hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1]; + hTcBuffer->nb_subframes = 0; if ( nSlotsInFirstSubframe > 0 ) { - st_ivas->hTcBuffer->nb_subframes = 1; + hTcBuffer->nb_subframes = 1; nSlotsAvailable -= nSlotsInFirstSubframe; } - st_ivas->hTcBuffer->nb_subframes += (int16_t) ceilf( (float) nSlotsAvailable / (float) nMaxSlotsPerSubframe ); + hTcBuffer->nb_subframes += (int16_t) ceilf( (float) nSlotsAvailable / (float) nMaxSlotsPerSubframe ); nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe; - set_s( st_ivas->hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); - set_s( st_ivas->hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, st_ivas->hTcBuffer->nb_subframes ); + set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); + set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, hTcBuffer->nb_subframes ); if ( nSlotsInFirstSubframe > 0 ) { - st_ivas->hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe; + hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe; } if ( nSlotsInLastSubframe > 0 ) { - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe; + hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe; } - st_ivas->hTcBuffer->slots_rendered = 0; - st_ivas->hTcBuffer->subframes_rendered = 0; + hTcBuffer->slots_rendered = 0; + hTcBuffer->subframes_rendered = 0; return; } @@ -2835,7 +2848,7 @@ void ivas_jbm_dec_copy_tc_no_tsm( { for ( ch_idx = 0; ch_idx < n_ch_full_copy; ch_idx++ ) { - mvr2r( tc[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], hTcBuffer->n_samples_buffered ); + mvr2r( tc[ch_idx], hTcBuffer->tc[ch_idx], hTcBuffer->n_samples_buffered ); } } ch_idx = 0; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 83a55f646a..f25e882339 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -117,6 +117,7 @@ ivas_error ivas_sba_dec_reconfigure( { int16_t nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; AUDIO_CONFIG intern_config_old; + int16_t sba_order_internal; int16_t numCldfbAnalyses_old, numCldfbSyntheses_old; int16_t sba_dirac_stereo_flag_old; int32_t ivas_total_brate; @@ -128,10 +129,14 @@ ivas_error ivas_sba_dec_reconfigure( ivas_error error; ISM_MODE ism_mode_old; int16_t granularity_new; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + SPAR_DEC_HANDLE hSpar; #ifdef NONBE_FIX_ISM_XOVER_BR int16_t nchan_transport; #endif + hTcBuffer = st_ivas->hTcBuffer; + hSpar = st_ivas->hSpar; ism_mode_old = st_ivas->ism_mode; hDecoderConfig = st_ivas->hDecoderConfig; ivas_total_brate = hDecoderConfig->ivas_total_brate; @@ -176,13 +181,12 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); *nSamplesFlushed = 0; - granularity_new = st_ivas->hTcBuffer->n_samples_granularity; + granularity_new = hTcBuffer->n_samples_granularity; /* we may need to flush only for binaural and OSBA and TSM */ if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { RENDERER_TYPE renderer_type_new; - int16_t sba_order_internal; sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); @@ -229,7 +233,7 @@ ivas_error ivas_sba_dec_reconfigure( } /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ - if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) + if ( granularity_new < hTcBuffer->n_samples_granularity ) { /* write back info for correct rendering of the flushable samples */ st_ivas->sba_analysis_order = sba_analysis_order_old_flush; @@ -248,7 +252,7 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; } - else if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) + else if ( granularity_new > hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) { @@ -258,30 +262,30 @@ ivas_error ivas_sba_dec_reconfigure( /* make sure the changed number of slots in the last subframe is not lost in the following steps */ if ( st_ivas->hSpatParamRendCom != NULL ) { - st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1]; } - st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + hSpar->subframe_nbslots[hSpar->nb_subframes - 1] = hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1]; } } /* save old */ - if ( ism_mode_old != ISM_SBA_MODE_DISC && st_ivas->hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER ) + if ( ism_mode_old != ISM_SBA_MODE_DISC && hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER ) { - if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) + if ( st_ivas->hDirAC == NULL && hSpar != NULL ) { - st_ivas->hTcBuffer->num_slots = st_ivas->hSpar->num_slots; - st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpar->nb_subframes; - st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpar->slots_rendered; - st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpar->subframes_rendered; - mvs2s( st_ivas->hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + hTcBuffer->num_slots = hSpar->num_slots; + hTcBuffer->nb_subframes = hSpar->nb_subframes; + hTcBuffer->slots_rendered = hSpar->slots_rendered; + hTcBuffer->subframes_rendered = hSpar->subframes_rendered; + mvs2s( hSpar->subframe_nbslots, hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } else if ( st_ivas->hSpatParamRendCom != NULL ) { - st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; - st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; - st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; - st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; - mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; + hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; + hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; + hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; + mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } } @@ -289,23 +293,19 @@ ivas_error ivas_sba_dec_reconfigure( * Allocate, initialize, and configure SBA handles *-----------------------------------------------------------------*/ - int16_t sba_order_internal; - SPAR_DEC_HANDLE hSpar; - hSpar = st_ivas->hSpar; - sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); if ( hSpar != NULL ) { if ( ( hSpar->hPCA != NULL ) && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE ) || ( st_ivas->sba_order != 1 ) ) ) { - free( st_ivas->hSpar->hPCA ); + free( hSpar->hPCA ); hSpar->hPCA = NULL; } if ( nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) || ( last_ivas_total_brate >= IVAS_512k && ivas_total_brate < IVAS_512k ) || ( last_ivas_total_brate < IVAS_512k && ivas_total_brate >= IVAS_512k ) ) { - ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 ); + ivas_spar_dec_close( &hSpar, hDecoderConfig->output_Fs, 1 ); if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK ) { @@ -314,11 +314,11 @@ ivas_error ivas_sba_dec_reconfigure( } else if ( last_ivas_total_brate < IVAS_24k4 && ivas_total_brate >= IVAS_24k4 ) { - num_channels = st_ivas->hSpar->hMdDec->spar_md_cfg.num_umx_chs; - ivas_spar_md_dec_matrix_close( st_ivas->hSpar->hMdDec, num_channels ); + num_channels = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + ivas_spar_md_dec_matrix_close( hSpar->hMdDec, num_channels ); num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - if ( ( error = ivas_spar_md_dec_matrix_open( st_ivas->hSpar->hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_matrix_open( hSpar->hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK ) { return error; } @@ -344,7 +344,6 @@ ivas_error ivas_sba_dec_reconfigure( } } - hSpar = st_ivas->hSpar; st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); if ( st_ivas->nchan_transport == 1 ) @@ -424,21 +423,21 @@ ivas_error ivas_sba_dec_reconfigure( { int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; - st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); + hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); if ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) { - st_ivas->hSpar->enc_param_start_band = 0; + hSpar->enc_param_start_band = 0; set_c( (int8_t *) st_ivas->hQMetaData->twoDirBands, (int8_t) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), - st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); + hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); if ( st_ivas->hDirAC ) { - st_ivas->hDirAC->hConfig->enc_param_start_band = st_ivas->hSpar->enc_param_start_band; + st_ivas->hDirAC->hConfig->enc_param_start_band = hSpar->enc_param_start_band; } } @@ -452,7 +451,7 @@ ivas_error ivas_sba_dec_reconfigure( if ( st_ivas->hDirAC != NULL ) { - st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; + hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; } /*-----------------------------------------------------------------* @@ -666,7 +665,7 @@ ivas_error ivas_sba_dec_reconfigure( } } - if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode || granularity_new != st_ivas->hTcBuffer->n_samples_granularity ) + if ( tc_nchan_tc != hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != hTcBuffer->nchan_transport_internal || tc_buffer_mode != hTcBuffer->tc_buffer_mode || granularity_new != hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ) != IVAS_ERR_OK ) { @@ -676,24 +675,24 @@ ivas_error ivas_sba_dec_reconfigure( } /* resync SPAR and DirAC JBM info from TC Buffer */ - if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) + if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == hTcBuffer->n_samples_granularity ) { - mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); - st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + mvs2s( hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + st_ivas->hSpatParamRendCom->nb_subframes = hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->subframes_rendered = hTcBuffer->subframes_rendered; } - mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); - st_ivas->hSpar->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + mvs2s( hTcBuffer->subframe_nbslots, hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + hSpar->nb_subframes = hTcBuffer->nb_subframes; + hSpar->subframes_rendered = hTcBuffer->subframes_rendered; if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size; + int16_t granularityMultiplier = hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size; int16_t n; for ( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ ) { - st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier; - st_ivas->hSpar->subframe_nbslots[n] = st_ivas->hSpatParamRendCom->subframe_nbslots[n]; + st_ivas->hSpatParamRendCom->subframe_nbslots[n] = hTcBuffer->subframe_nbslots[n] * granularityMultiplier; + hSpar->subframe_nbslots[n] = st_ivas->hSpatParamRendCom->subframe_nbslots[n]; } } -- GitLab From feb30a0ba460778cd6715cc94c0b373c57804b52 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Jun 2024 17:32:44 +0200 Subject: [PATCH 39/52] clang-format; MSVC filters update --- Workspace_msvc/lib_com.vcxproj.filters | 9 +++++-- lib_com/ivas_limiter.c | 2 +- lib_com/ivas_rotation_com.c | 2 ++ lib_dec/ivas_stat_dec.h | 2 +- lib_rend/ivas_prot_rend.h | 34 +++++++++++++------------- lib_rend/lib_rend.c | 2 +- 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index b7c9cc3bdb..97f4794314 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -472,7 +472,12 @@ common_ivas_c - + + common_ivas_c + + + common_ivas_c + @@ -552,4 +557,4 @@ {b95b7bed-a666-4a00-9332-2b528638503e} - + \ No newline at end of file diff --git a/lib_com/ivas_limiter.c b/lib_com/ivas_limiter.c index 657e41683f..6db3940566 100644 --- a/lib_com/ivas_limiter.c +++ b/lib_com/ivas_limiter.c @@ -127,6 +127,7 @@ ivas_error ivas_limiter_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Limiter handle\n" ) ); } + hLimiter->sampling_rate = sampling_rate; hLimiter->gain = 1.f; hLimiter->release_heuristic = 0.f; @@ -337,7 +338,6 @@ void limiter_process( if ( apply_limiting ) { - /* 99% time constants of the gain curve * * The denominator of the second argument determines after how many diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index 8497a871f6..9ce04bb938 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -62,6 +62,7 @@ void Euler2Quat( float sp = sinf( pitch * 0.5f ); float cy = cosf( yaw * 0.5f ); float sy = sinf( yaw * 0.5f ); + quat->w = cr * cp * cy + sr * sp * sy; quat->x = sr * cp * cy - cr * sp * sy; quat->y = sr * cp * sy + cr * sp * cy; @@ -88,6 +89,7 @@ void Quat2EulerDegree( if ( quat.w != -3.0 ) { float p; + *yaw = atan2f( 2 * ( quat.w * quat.x + quat.y * quat.z ), 1 - 2 * ( quat.x * quat.x + quat.y * quat.y ) ); p = 2 * ( quat.w * quat.y - quat.z * quat.x ); p = max( -1.0f, min( 1.0f, p ) ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index e5bd4d05ed..560f66caa6 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1024,7 +1024,7 @@ typedef struct decoder_config_structure /* temp. development parameters */ int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ #endif - int16_t Opt_tsm; /* indicates whether time scaling modification is activated */ + int16_t Opt_tsm; /* indicates whether time scaling modification is activated */ IVAS_RENDER_FRAMESIZE render_framesize; /* rendering frame size */ int16_t Opt_delay_comp; /* flag indicating delay compensation active */ diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index b3e5682f4b..d02f68b525 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1300,14 +1300,13 @@ void rotateFrame_sd_cldfb( ); ivas_error ivas_external_orientation_open( - EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData, /* o : external orientation handle */ - const int16_t num_subframes /* i : number of subframes */ + EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData, /* o : external orientation handle */ + const int16_t num_subframes /* i : number of subframes */ ); void ivas_external_orientation_close( - EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData /* i/o: external orientation handle */ + EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData /* i/o: external orientation handle */ ); - ivas_error ivas_combined_orientation_open( COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* o : combined orientation handle */ const int32_t fs, /* i : sampling rate */ @@ -1325,11 +1324,12 @@ ivas_error combine_external_and_head_orientations_dec( ); ivas_error combine_external_and_head_orientations_rend( - IVAS_REND_HeadRotData *hHeadTrackData, /* i : head track handle */ - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ + IVAS_REND_HeadRotData *hHeadTrackData, /* i : head track handle */ + EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ); + /*----------------------------------------------------------------------------------* * Renderer configuration *----------------------------------------------------------------------------------*/ @@ -1453,19 +1453,19 @@ void ivas_omasa_ana_close( ); void computeIntensityVector_ana( - const int16_t *band_grouping, /* i : Band grouping for estimation */ - float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ - float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ - const int16_t num_frequency_bands, /* i : Number of frequency bands */ - float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity vector */ + const int16_t *band_grouping, /* i : Band grouping for estimation */ + float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX],/* i : Real part of input signal */ + float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX],/* i : Imag part of input signal */ + const int16_t num_frequency_bands, /* i : Number of frequency bands */ + float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity vector */ ); void computeReferencePower_ana( - const int16_t *band_grouping, /* i : Band grouping for estimation */ - float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ - float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ - float *reference_power, /* o : Estimated power */ - const int16_t num_freq_bands /* i : Number of frequency bands */ + const int16_t *band_grouping, /* i : Band grouping for estimation */ + float Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX],/* i : Real part of input signal */ + float Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX],/* i : Imag part of input signal */ + float *reference_power, /* o : Estimated power */ + const int16_t num_freq_bands /* i : Number of frequency bands */ ); void ivas_create_masa_out_meta( diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 00da51278a..19a2c1848e 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7859,7 +7859,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, -- GitLab From c94ee1c5382ae712f5e1c35d8fc6e8107e734008 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 5 Jun 2024 17:47:31 +0200 Subject: [PATCH 40/52] fix merge issue --- lib_com/prot.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/prot.h b/lib_com/prot.h index f5a99656b3..fe72bcf7a9 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -728,8 +728,8 @@ int32_t get_delay( const int32_t io_fs, /* i : input/output sampling frequency */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ #ifdef SPLIT_REND_WITH_HEAD_ROT - HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ - const AUDIO_CONFIG output_config /* i : decoder output config */ + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ + const int16_t flag_binaural_split_coded /* i : split rendering on/off flag */ #else HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ #endif -- GitLab From 9924941645de3a8bffa00ddc4a02b69587e8b29f Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 6 Jun 2024 11:25:07 +0200 Subject: [PATCH 41/52] formatting; remove unused constant; fix typos --- apps/decoder.c | 33 ++++++++++++++++++--------------- apps/encoder.c | 4 +--- lib_com/ivas_ism_com.c | 2 +- lib_dec/ivas_ism_metadata_dec.c | 6 +++++- lib_dec/lib_dec.c | 2 +- lib_enc/ivas_ism_metadata_enc.c | 8 ++++---- lib_enc/ivas_masa_enc.c | 2 +- 7 files changed, 31 insertions(+), 26 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 5878bcfe23..80cf473ad6 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -767,7 +767,6 @@ int main( } } - if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -1471,6 +1470,7 @@ static bool parseCmdlIVAS_dec( strncpy( argv_to_upper, argv[i], sizeof( argv_to_upper ) - 1 ); argv_to_upper[sizeof( argv_to_upper ) - 1] = '\0'; to_upper( argv_to_upper ); + if ( ( strcmp( argv_to_upper, "CENTER" ) == 0 ) || ( strchr( argv_to_upper, 'C' ) != NULL ) ) { arg->non_diegetic_pan_gain = 0.f; @@ -1605,6 +1605,7 @@ static bool parseCmdlIVAS_dec( /*-----------------------------------------------------------------* * Option not recognized *-----------------------------------------------------------------*/ + else { fprintf( stderr, "Error: Unknown option %s or wrong number of parameters!\n\n", argv[i] ); @@ -2185,6 +2186,7 @@ static ivas_error initOnFirstGoodFrame( fprintf( stderr, "\nError getting render frame size in samples\n" ); return error; } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, vec_pos_len ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); @@ -2288,7 +2290,6 @@ static ivas_error decodeG192( } } - for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { ismWriters[i] = NULL; @@ -2361,9 +2362,9 @@ static ivas_error decodeG192( goto cleanup; } } -#endif #endif +#endif /*------------------------------------------------------------------------------------------* * Loop for every packet (frame) of bitstream data * - Read the bitstream packet @@ -2682,7 +2683,7 @@ static ivas_error decodeG192( #endif } - /* Write ISm metadata to external file(s) */ + /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM ) @@ -2722,6 +2723,7 @@ static ivas_error decodeG192( { fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2756,8 +2758,6 @@ static ivas_error decodeG192( { int16_t nSamplesFlushed; - /* Feed into decoder */ - /* reference vector */ if ( arg.enableReferenceVectorTracking ) { @@ -2813,7 +2813,7 @@ static ivas_error decodeG192( } } - /* decode and get samples */ + /* flush remaining audio */ #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) #else @@ -2831,7 +2831,7 @@ static ivas_error decodeG192( goto cleanup; } - /* Write ISm metadata to external file(s) */ + /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM ) @@ -2870,6 +2870,7 @@ static ivas_error decodeG192( { fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -3164,11 +3165,13 @@ static ivas_error decodeVoIP( fprintf( stderr, "\nError getting render frame size in samples\n" ); return error; } + if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nOutSamples ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); return error; } + if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, &vec_pos_len ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError getting render frame size in samples\n" ); @@ -3210,7 +3213,6 @@ static ivas_error decodeVoIP( goto cleanup; } - #ifdef SUPPORT_JBM_TRACEFILE if ( arg.jbmTraceFilename != NULL ) { @@ -3247,6 +3249,7 @@ static ivas_error decodeVoIP( /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */ rtpTimeStamp = rtpTimeStamp / 16; } + if ( error != IVAS_ERR_OK || rtpdumpDepackerError != EVS_RTPDUMP_DEPACKER_NO_ERROR ) { fprintf( stderr, "failed to read first RTP packet\n" ); @@ -3274,7 +3277,6 @@ static ivas_error decodeVoIP( while ( 1 ) { - /* reference vector */ if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 ) { @@ -3315,7 +3317,6 @@ static ivas_error decodeVoIP( goto cleanup; } - /* Head-tracking input simulation */ /* Head-tracking input simulation */ if ( arg.enableHeadRotation ) { @@ -3430,7 +3431,6 @@ static ivas_error decodeVoIP( break; } - /* decode and get samples */ #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SUPPORT_JBM_TRACEFILE @@ -3556,6 +3556,7 @@ static ivas_error decodeVoIP( { fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 1 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -3576,8 +3577,9 @@ static ivas_error decodeVoIP( { fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame ); } - vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; frame++; + + vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; if ( vec_pos_update == 0 ) { systemTime_ms += vec_pos_len * systemTimeInc_ms; @@ -3592,7 +3594,7 @@ static ivas_error decodeVoIP( int16_t nSamplesFlushed = 0; - /* decode and get samples */ + /* flush remaining audio */ #ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) #else @@ -3612,7 +3614,7 @@ static ivas_error decodeVoIP( goto cleanup; } - /* Write ISm metadata to external file(s) */ + /* Write ISM metadata to external file(s) */ if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) { if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM ) @@ -3652,6 +3654,7 @@ static ivas_error decodeVoIP( { fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); diff --git a/apps/encoder.c b/apps/encoder.c index b00f4f75fd..cb1717d8ca 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -556,8 +556,8 @@ int main( goto cleanup; } } -#endif +#endif /*------------------------------------------------------------------------------------------* * Allocate input data buffer *------------------------------------------------------------------------------------------*/ @@ -870,8 +870,6 @@ cleanup: * Local functions *-------------------------------------------------------------------*/ -#define IVAS_DEFAULT_AGC ( 0 ) - static void initArgStruct( EncArguments *arg ) { /* Set default values here */ diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index 2b2e2c3eec..62bd704a89 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -148,7 +148,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 ) { nb_bits_metadata[0] += n_ISms * ISM_METADATA_FLAG_BITS + nchan_ism; diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 4525b21e10..f1101d9230 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -205,6 +205,7 @@ ivas_error ivas_ism_metadata_dec( /*----------------------------------------------------------------* * Read ISM common signaling *----------------------------------------------------------------*/ + if ( ism_mode == ISM_SBA_MODE_DISC ) { /* number of objects was read in ivas_dec_setup() */ @@ -448,6 +449,7 @@ ivas_error ivas_ism_metadata_dec( hIsmMetaData->last_true_elevation = hIsmMetaData->elevation; } } + /* save number of metadata bits read */ if ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC || ism_mode == ISM_MASA_MODE_DISC || ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) { @@ -787,6 +789,7 @@ static void decode_angle_indices( nbits_diff_angle1++; } } + idx_angle1 = angle->last_angle1_idx + sgn * diff; } @@ -935,6 +938,7 @@ static int16_t decode_radius( nbits_diff_radius++; } } + idx_radius = *last_radius_idx + sgn * diff; } @@ -1006,7 +1010,7 @@ void ivas_ism_metadata_sid_dec( if ( !bfi ) { /*----------------------------------------------------------------* - * ISm common signaling + * ISM common signaling *----------------------------------------------------------------*/ /* number of objects was already read in ivas_ism_get_dtx_dec() */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index c8781a6dde..0c4fe9402e 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2888,7 +2888,7 @@ static void update_voip_rendered20ms( /*---------------------------------------------------------------------* - * IVAS_DEC_VoIP_Flush( ) + * IVAS_DEC_Flush( ) * * Function to flush remaining audio in VoIP *---------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index cfeff3ca47..57258e4eaf 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -255,14 +255,12 @@ ivas_error ivas_ism_metadata_enc( if ( ( fabsf( hIsmMeta[ch]->azimuth - hIsmMeta[ch]->last_true_azimuth ) > ISM_MD_FEC_DIFF ) || ( fabsf( hIsmMeta[ch]->elevation - hIsmMeta[ch]->last_true_elevation ) > ISM_MD_FEC_DIFF ) || ( fabsf( hIsmMeta[ch]->radius - hIsmMeta[ch]->last_true_radius ) > ISM_MD_RAD_FEC_DIFF ) ) { - lowrate_metadata_flag[ch] = 1; hIsmMeta[ch]->ism_md_inc_diff_cnt = 0; } else if ( hIsmMeta[ch]->ism_md_inc_diff_cnt < ISM_MD_INC_DIFF_CNT_MAX ) { - lowrate_metadata_flag[ch] = 1; if ( hIsmMeta[ch]->ism_md_inc_diff_cnt % 2 == 0 ) @@ -449,6 +447,7 @@ ivas_error ivas_ism_metadata_enc( /*----------------------------------------------------------------* * Quantize and encode radius, yaw, and pitch *----------------------------------------------------------------*/ + if ( ( ism_mode == ISM_MODE_DISC || ism_mode == ISM_SBA_MODE_DISC ) && ism_extended_metadata_flag ) { idx_angle1_abs = ism_quant_meta( hIsmMetaData->yaw, &valQ, ism_azimuth_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_AZIMUTH_NBITS ); @@ -570,9 +569,10 @@ ivas_error ivas_ism_metadata_enc( pop_wmops(); return error; } + if ( ism_mode == ISM_MODE_PARAM ) { - /* Keep the metdata transmission as is during active parts */ + /* Keep the metadata transmission as is during active parts */ /* But send the flag with 1 bit */ push_next_indice( hBstr, hParamIsm->flag_noisy_speech, 1 ); @@ -1249,7 +1249,7 @@ void ivas_ism_metadata_sid_enc( nBits_start = hBstr->nb_bits_tot; /*----------------------------------------------------------------* - * Write ISm common signaling + * Write ISM common signaling *----------------------------------------------------------------*/ /* write number of objects - unary coding */ diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index a12907b1b1..6b8661d580 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -2140,7 +2140,7 @@ static void average_masa_metadata( *-------------------------------------------------------------------*/ static void copy_masa_metadata_subframe( - const MASA_METADATA_HANDLE hMetaFrom, /* i : MASA frame metdata to be copied */ + const MASA_METADATA_HANDLE hMetaFrom, /* i : MASA frame metadata to be copied */ const uint8_t sfFrom, /* i : subframe index of the copy source */ MASA_METADATA_HANDLE hMetaTo, /* o : MASA frame metadata copy destination */ const uint8_t sfTo /* i : subframe index of the copy target */ -- GitLab From f4d9e24563c523d9ccfaa8a43ad20a8697b61eb9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 10 Jun 2024 14:17:13 +0200 Subject: [PATCH 42/52] remove obsolete includes --- lib_rend/ivas_crend.c | 1 - lib_rend/ivas_masa_merge.c | 1 - lib_rend/ivas_reflections.c | 1 - 3 files changed, 3 deletions(-) diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 387bdb9185..698d3af7a1 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -40,7 +40,6 @@ #include #include "ivas_rom_binaural_crend_head.h" #include "ivas_stat_rend.h" -#include "lib_rend.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_rend/ivas_masa_merge.c b/lib_rend/ivas_masa_merge.c index ac6d7b9652..7262d8ca90 100644 --- a/lib_rend/ivas_masa_merge.c +++ b/lib_rend/ivas_masa_merge.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "lib_rend.h" #include "ivas_prot_rend.h" #include "ivas_prot.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index c15d776d29..acb1456d2a 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -35,7 +35,6 @@ #include #include "prot.h" #include "rom_dec.h" -#include "lib_rend.h" #include "ivas_prot_rend.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" -- GitLab From cab9e78516e0a22bc9b6fb7ac5b28d5069ac4070 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 10 Jun 2024 15:04:21 +0200 Subject: [PATCH 43/52] formatting --- lib_com/ivas_cnst.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 47321a5a24..24dae619fb 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -672,7 +672,7 @@ enum #define ECLVQ_GLOBAL_GAIN_FACTOR ( 20.0f * 127.0f / 90.0f ) #define ECLVQ_INV_GLOBAL_GAIN_FACTOR ( 1.0f / ( 20.0f * 127.0f / 90.0f ) ) -/* the currently defined configuration indexes are: +/* the defined configuration indexes are: 0: un-optimized using uniform 4 bit parameters (reserved) 1: optimized for 32 kbps target SNR 2: optimized for 32 kbps target bits @@ -960,12 +960,12 @@ typedef enum #define DIRAC_SLOT_NS 1250000L /* time duration of a time slot, 1.25ms (==DELAY_RENERER_NS/MAX_PARAM_SPATIAL_SUBFRAMES) */ #define DIRAC_SLOT_ENC_NS 5000000L -#define DIRAC_MONO_THRESH_SILENCE 3e4f -#define DIRAC_MONO_NORM_FACTOR 1e13f -#define DIRAC_MONO_ONE_ON_NORM_FACTOR (1.f / 1e13f) -#define DIRAC_MONO_MAX_THRESH 1e6f -#define DIRAC_MONO_MIN_THRESH 1e2f -#define DIRAC_MONO_FRAME_THRESH 15 /* 30ms */ +#define DIRAC_MONO_THRESH_SILENCE 3e4f +#define DIRAC_MONO_NORM_FACTOR 1e13f +#define DIRAC_MONO_ONE_ON_NORM_FACTOR (1.f / 1e13f) +#define DIRAC_MONO_MAX_THRESH 1e6f +#define DIRAC_MONO_MIN_THRESH 1e2f +#define DIRAC_MONO_FRAME_THRESH 15 /* 30ms */ typedef enum { @@ -1291,12 +1291,12 @@ typedef enum * MC Param-Upmix Mode Constants *----------------------------------------------------------------------------------*/ -#define MC_PARAMUPMIX_MAX_TRANSPORT_CHANS 8 -#define MC_PARAMUPMIX_MAX_INPUT_CHANS 12 -#define MC_PARAMUPMIX_MAX_BITS 1024 /* Maximum number of bits for the MC Param-Upmix metadata */ -#define MC_PARAMUPMIX_COMBINATIONS 4 /* number of sets of 2 channels combined */ -#define MC_PARAMUPMIX_NCH 2 /* number of channels to combine into 1 */ -#define MC_PARAMUPMIX_MIN_CLDFB 8 +#define MC_PARAMUPMIX_MAX_TRANSPORT_CHANS 8 +#define MC_PARAMUPMIX_MAX_INPUT_CHANS 12 +#define MC_PARAMUPMIX_MAX_BITS 1024 /* Maximum number of bits for the MC Param-Upmix metadata */ +#define MC_PARAMUPMIX_COMBINATIONS 4 /* number of sets of 2 channels combined */ +#define MC_PARAMUPMIX_NCH 2 /* number of channels to combine into 1 */ +#define MC_PARAMUPMIX_MIN_CLDFB 8 typedef enum _COV_SMOOTHING_TYPE { @@ -1336,6 +1336,7 @@ typedef struct const int16_t (*beta)[2]; } HUFF_NODE_TABLE; + /*----------------------------------------------------------------------------------* * Parametric MC Constants *----------------------------------------------------------------------------------*/ -- GitLab From 0f781cdc7c990d199168c598df4b8b69cdfd603e Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 24 Jun 2024 13:48:31 +0200 Subject: [PATCH 44/52] fix build warning --- lib_dec/lib_dec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index dab038afca..9f5452c1dd 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2812,6 +2812,8 @@ ivas_error IVAS_DEC_Flush( uint16_t nSamplesToRender; uint16_t nSamplesFlushedLocal; + ivas_error = IVAS_ERR_OK; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -2830,7 +2832,7 @@ ivas_error IVAS_DEC_Flush( *nSamplesFlushed = 0; } - return IVAS_ERR_OK; + return error; } -- GitLab From f166fa043a7451f16dadfdcf416021fa95c620bb Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 24 Jun 2024 13:49:04 +0200 Subject: [PATCH 45/52] fix build warning --- lib_dec/lib_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 9f5452c1dd..6f9b4922f8 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2812,7 +2812,7 @@ ivas_error IVAS_DEC_Flush( uint16_t nSamplesToRender; uint16_t nSamplesFlushedLocal; - ivas_error = IVAS_ERR_OK; + error = IVAS_ERR_OK; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -2822,7 +2822,7 @@ ivas_error IVAS_DEC_Flush( *nSamplesFlushed = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); nSamplesToRender = (uint16_t) *nSamplesFlushed; - /* render IVAS frames */ + /* render IVAS frames */ if ( nSamplesToRender > 0 && hIvasDec->st_ivas->ivas_format != MONO_FORMAT ) { error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmType, pcmBuf ); -- GitLab From cf473bd01a4ca5f5f3d90e242148c42a7e7f8c43 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 6 Nov 2024 09:26:32 +0100 Subject: [PATCH 46/52] comment typo --- lib_dec/lib_dec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 2c6b1a7666..4c59f309ed 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1935,7 +1935,6 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( *needNewFrame = false; hSplitBinRend = st_ivas->hSplitBinRend; - #ifndef OBJ_EDITING_API if ( ( error = isar_set_split_rend_setup( hSplitBinRend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) { @@ -1946,7 +1945,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; #ifdef OBJ_EDITING_API - /* init flush buffer for rate switch if not already initizalized */ + /* init flush buffer for rate switch if not already initialized */ if ( hIvasDec->flushbuffer == NULL ) { hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); -- GitLab From 3f489e388e32a3f4cfe3b510ce0cbc373bbb910e Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 6 Nov 2024 12:59:49 +0100 Subject: [PATCH 47/52] maintenance --- apps/decoder.c | 1 - lib_dec/ivas_binRenderer_internal.c | 6 ++-- lib_dec/ivas_masa_dec.c | 1 + lib_dec/ivas_stat_dec.h | 5 ++- lib_dec/lib_dec.c | 3 +- lib_rend/ivas_prot_rend.h | 3 +- lib_rend/ivas_reverb.c | 3 +- lib_rend/lib_rend.c | 48 ++++++++++++++++------------- lib_rend/lib_rend.h | 20 ++++++------ 9 files changed, 45 insertions(+), 45 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index e497e011ed..5f4fa8ce74 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2329,7 +2329,6 @@ static ivas_error decodeG192( } } #endif - #endif /*------------------------------------------------------------------------------------------* * Loop for every packet (frame) of bitstream data diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index a1db553c88..2e6fa5a3b5 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1233,9 +1233,8 @@ ivas_error ivas_binRenderer_open( pRoomAcoustics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes, - st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections + st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections, #ifdef FIX_1139_REV_COLORATION_SHORT_T60 - , hBinRenderer->earlyPartEneCorrection #endif ) ) != IVAS_ERR_OK ) @@ -1247,9 +1246,8 @@ ivas_error ivas_binRenderer_open( &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes, - st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections + st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections, #ifdef FIX_1139_REV_COLORATION_SHORT_T60 - , hBinRenderer->earlyPartEneCorrection #endif ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 4f3b58d290..1525c691ea 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -302,6 +302,7 @@ ivas_error ivas_masa_decode( ( *nb_bits_read ) += ISM_METADATA_INACTIVE_FLAG_BITS; } } + st_ivas->flag_omasa_brate = 0; if ( st_ivas->nchan_ism >= 3 && ivas_total_brate == IVAS_128k ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 78439f22fc..80787c0afe 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1108,6 +1108,7 @@ typedef struct Decoder_Struct int16_t sba_planar; /* Ambisonic (SBA) planar flag */ int16_t sba_analysis_order; /* Ambisonic (SBA) order used for analysis and coding */ int16_t sba_dirac_stereo_flag; /* flag indicating stereo output for SBA DirAC modes with 1 TC */ + int16_t flag_omasa_brate; /* OMASA bitrate adjustment flag */ /* rendering modules */ RENDERER_TYPE renderer_type; /* renderer type */ @@ -1137,9 +1138,7 @@ typedef struct Decoder_Struct DIRAC_REND_HANDLE hDirACRend; /* DirAC renderer handle */ SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; /* Spatial parametric (DirAC rend, ParamBin, ParamISM) rendering common data handle. */ MASA_ISM_DATA_HANDLE hMasaIsmData; /* OMASA rendering handle */ - SBA_ISM_DATA_HANDLE hSbaIsmData; /* OSBA rendering handle */ - - int16_t flag_omasa_brate; + SBA_ISM_DATA_HANDLE hSbaIsmData; /* OSBA rendering handle */ ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; /* ISAR split binaural rendering handle */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1]; /* TD object renderer handles */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 4c59f309ed..3da45a9586 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1833,6 +1833,7 @@ ivas_error IVAS_DEC_GetSamples( #else nOutChannels = (uint8_t) hIvasDec->st_ivas->hDecoderConfig->nchan_out; hIvasDec->hasBeenFedFrame = false; + /* check for possible flushed samples from a rate switch */ if ( hIvasDec->nSamplesFlushed > 0 ) { @@ -2127,12 +2128,12 @@ static ivas_error IVAS_DEC_Setup( ivas_error error; Decoder_Struct *st_ivas; -#ifndef FIX_HRTF_LOAD if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifndef FIX_HRTF_LOAD *nSamplesRendered = 0; #endif if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index eed5944065..765e02f5e2 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -942,9 +942,8 @@ ivas_error ivas_binaural_reverb_init( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ const int32_t sampling_rate, /* i : sampling rate */ const float *defaultTimes, /* i : default reverberation times */ - const float *defaultEne /* i : default reverberation energies */ + const float *defaultEne, /* i : default reverberation energies */ #ifdef FIX_1139_REV_COLORATION_SHORT_T60 - , float *earlyEne /* i/o: Early part energies to be modified */ #endif ); diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index de9384bd0d..f094f885e0 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -1883,9 +1883,8 @@ ivas_error ivas_binaural_reverb_init( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ const int32_t sampling_rate, /* i : sampling rate */ const float *defaultTimes, /* i : default reverberation times */ - const float *defaultEne /* i : default reverberation energies */ + const float *defaultEne, /* i : default reverberation energies */ #ifdef FIX_1139_REV_COLORATION_SHORT_T60 - , float *earlyEne /* i/o: Early part energies to be modified */ #endif ) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 90df5a1ce4..69e4293356 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4331,6 +4331,7 @@ ivas_error IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend->hDiracDecBin[0] != NULL && pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb != NULL ) { ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb ); + if ( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, @@ -4352,6 +4353,7 @@ ivas_error IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend->hReverb != NULL ) { ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hReverb ); + if ( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, @@ -4639,8 +4641,8 @@ ivas_error IVAS_REND_SetReferenceRotation( *-------------------------------------------------------------------*/ // ToDo: not used ivas_error IVAS_REND_GetMainOrientation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer for main orientation */ + const IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_QUATERNION *pOrientation /* o : Quaternion pointer for main orientation */ ) { ivas_error error; @@ -4666,8 +4668,8 @@ ivas_error IVAS_REND_GetMainOrientation( *-------------------------------------------------------------------*/ // ToDo: not used ivas_error IVAS_REND_GetTrackedRotation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *pRotation /* i/o: Quaternion pointer processed rotation */ + const IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_QUATERNION *pRotation /* o : Quaternion pointer processed rotation */ ) { ivas_error error; @@ -4715,13 +4717,13 @@ ivas_error IVAS_REND_SetReferenceVector( *---------------------------------------------------------------------*/ ivas_error IVAS_REND_SetExternalOrientation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *orientation, /* i : external orientation data */ - int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ - int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ - int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ - int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ - const int16_t sf_idx /* i : subframe index */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_QUATERNION *orientation, /* i : external orientation data */ + const int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ + const int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ + const int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ + const int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const int16_t sf_idx /* i : subframe index */ ) { /* Validate function arguments */ @@ -4774,8 +4776,8 @@ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( *---------------------------------------------------------------------*/ // ToDo: not used ivas_error IVAS_REND_GetCombinedOrientation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer processed orientation */ + const IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer processed orientation */ ) { int16_t i; @@ -5709,7 +5711,7 @@ static ivas_error renderInputIsm( static ivas_error renderActiveInputsIsm( - IVAS_REND_HANDLE hIvasRend, + const IVAS_REND_HANDLE hIvasRend, IVAS_REND_AudioBuffer outAudio ) { int16_t i; @@ -6311,6 +6313,7 @@ static ivas_error renderMcToSplitBinaural( return IVAS_ERR_OK; } + static ivas_error renderInputMc( input_mc *mcInput, const AUDIO_CONFIG outConfig, @@ -7353,7 +7356,7 @@ ivas_error IVAS_REND_SetTotalNumberOfObjects( *---------------------------------------------------------------------*/ ivas_error IVAS_REND_SetIsmMetadataDelay( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ const float sync_md_delay /* i : ISM Metadata Delay in ms to sync with audio delay */ ) { @@ -7544,7 +7547,7 @@ static ivas_error getSamplesInternal( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, @@ -7564,6 +7567,7 @@ static ivas_error getSamplesInternal( accumulate2dArrayToBuffer( tmpBinaural_buff, &outAudio ); } } + if ( outAudio.config.is_cldfb == 0 ) { #ifndef DISABLE_LIMITER @@ -7862,8 +7866,8 @@ void IVAS_REND_cldfbSynthesis_wrapper( return; } - #ifdef DEBUGGING + /*-------------------------------------------------------------------* * IVAS_REND_GetNoCLipping() * @@ -7886,8 +7890,8 @@ int32_t IVAS_REND_GetCntFramesLimited( return hIvasRend->hLimiter->cnt_frames_limited; } -#endif +#endif /*---------------------------------------------------------------------* * IVAS_REND_GetHrtfHandle( ) @@ -7976,6 +7980,7 @@ ivas_error IVAS_REND_GetHrtfParamBinHandle( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_REND_GetHrtfStatisticsHandle( ) * @@ -7997,6 +8002,7 @@ ivas_error IVAS_REND_GetHrtfStatisticsHandle( return IVAS_ERR_OK; } + static ivas_error ivas_masa_ext_rend_dirac_rend_init( input_masa *inputMasa ) { @@ -8473,9 +8479,8 @@ static ivas_error ivas_masa_ext_rend_parambin_init( pRoomAcoustics, output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, - ( *phHrtfParambin )->parametricReverberationEneCorrections + ( *phHrtfParambin )->parametricReverberationEneCorrections, #ifdef FIX_1139_REV_COLORATION_SHORT_T60 - , hDiracDecBin->earlyPartEneCorrection #endif ) ) != IVAS_ERR_OK ) @@ -8487,9 +8492,8 @@ static ivas_error ivas_masa_ext_rend_parambin_init( &( hRendCfg->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, - ( *phHrtfParambin )->parametricReverberationEneCorrections + ( *phHrtfParambin )->parametricReverberationEneCorrections, #ifdef FIX_1139_REV_COLORATION_SHORT_T60 - , hDiracDecBin->earlyPartEneCorrection #endif ) ) != IVAS_ERR_OK ) diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 97914cba5c..6ef42efbf6 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -299,13 +299,13 @@ ivas_error IVAS_REND_SetReferenceRotation( ); ivas_error IVAS_REND_GetMainOrientation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer for main orientation */ + const IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_QUATERNION *pOrientation /* o : Quaternion pointer for main orientation */ ); ivas_error IVAS_REND_GetTrackedRotation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *pRotation /* i/o: Quaternion pointer for processed rotation */ + const IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ + IVAS_QUATERNION *pRotation /* o : Quaternion pointer for processed rotation */ ); ivas_error IVAS_REND_SetReferenceVector( @@ -321,11 +321,11 @@ ivas_error IVAS_REND_SetSplitRendBFI( ivas_error IVAS_REND_SetExternalOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - IVAS_QUATERNION *orientation, /* i : external orientation data */ - int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ - int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ - int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ - int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ + const IVAS_QUATERNION *orientation, /* i : external orientation data */ + const int8_t enableHeadRotation, /* i : flag to enable head rotation for this frame */ + const int8_t enableExternalOrientation, /* i : flag to enable external orientation for this frame */ + const int8_t enableRotationInterpolation, /* i : flag to interpolate rotations from current and previous frames */ + const int16_t numFramesToTargetOrientation, /* i : number of frames until target orientation is reached */ const int16_t sf_idx /* i : subframe index */ ); @@ -334,7 +334,7 @@ ivas_error IVAS_REND_CombineHeadAndExternalOrientation( ); ivas_error IVAS_REND_GetCombinedOrientation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ IVAS_QUATERNION *pOrientation /* i/o: Quaternion pointer processed orientation */ ); -- GitLab From f8bc547d6fb80cd639de32b4b61c180b429574ce Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 15 Nov 2024 12:19:21 +0100 Subject: [PATCH 48/52] fix build --- lib_dec/lib_dec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 8b150bff80..c8347aea5e 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3742,6 +3742,8 @@ ivas_error IVAS_DEC_Flush( uint16_t nSamplesToRender; uint16_t nSamplesFlushedLocal; + error = IVAS_ERR_OK; + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3760,7 +3762,7 @@ ivas_error IVAS_DEC_Flush( *nSamplesFlushed = 0; } - return IVAS_ERR_OK; + return error; } -- GitLab From 00f8f73cc381cf47d0be0ccae2423ff13c97b771 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 15 Nov 2024 13:04:23 +0100 Subject: [PATCH 49/52] remove empty line --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index d23b9b824f..356e84c929 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -165,7 +165,6 @@ #define FIX_1209_SID_SIGNALING /* VA: issue 1209: remove dead code in IVAS SID signaling */ - /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ -- GitLab From 8f3bb1fa45ace38559c9e7e31fc1a34e0fef3fd6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 15 Nov 2024 13:54:52 +0100 Subject: [PATCH 50/52] fix merge issue --- apps/decoder.c | 8 ++++---- apps/isar_post_rend.c | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 692a36debd..2a3a791d52 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2408,7 +2408,7 @@ static ivas_error decodeG192( } } - /* decode transport channels, do TSM and feed to renderer */ + /* Decode transport channels, do TSM and feed to renderer */ if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) { return error; @@ -2461,11 +2461,11 @@ static ivas_error decodeG192( fprintf( stderr, "\nError in IVAS_DEC_GetSamplesRenderer(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - - nSamplesRendered += nSamplesRendered_loop; - nSamplesToRender -= nSamplesRendered_loop; } + nSamplesRendered += nSamplesRendered_loop; + nSamplesToRender -= nSamplesRendered_loop; + if ( needNewFrame ) { frame++; diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 752618406c..95e93db083 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -31,8 +31,6 @@ *******************************************************************************************************/ #include "lib_isar_post_rend.h" - - #include #include #include -- GitLab From 32356edf50d286460e65fe0e13603b66eab4da5a Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 10 May 2025 17:45:30 +0200 Subject: [PATCH 51/52] update --- apps/decoder.c | 18 +-- apps/encoder.c | 2 +- apps/isar_post_rend.c | 2 + apps/renderer.c | 39 ++---- lib_com/ivas_cnst.h | 20 +-- lib_com/ivas_ism_com.c | 2 +- lib_com/ivas_limiter.c | 2 +- lib_com/ivas_mc_com.c | 6 +- lib_com/ivas_omasa_com.c | 2 +- lib_com/ivas_osba_com.c | 2 +- lib_com/ivas_prot.h | 130 ++++++++++--------- lib_com/ivas_rotation_com.c | 2 - lib_com/ivas_sba_config.c | 1 - lib_com/prot.h | 6 +- lib_dec/ivas_binRenderer_internal.c | 2 + lib_dec/ivas_cpe_dec.c | 2 +- lib_dec/ivas_dec.c | 2 +- lib_dec/ivas_dirac_dec.c | 90 ++++++++++--- lib_dec/ivas_dirac_output_synthesis_cov.c | 1 - lib_dec/ivas_init_dec.c | 17 ++- lib_dec/ivas_ism_param_dec.c | 4 +- lib_dec/ivas_mc_paramupmix_dec.c | 1 - lib_dec/ivas_mct_dec.c | 4 +- lib_dec/ivas_mdct_core_dec.c | 1 + lib_dec/ivas_objectRenderer_internal.c | 12 +- lib_dec/ivas_omasa_dec.c | 2 +- lib_dec/ivas_sba_dec.c | 6 +- lib_dec/ivas_stat_dec.h | 2 +- lib_enc/ivas_enc.c | 1 + lib_enc/ivas_ism_param_enc.c | 2 +- lib_enc/ivas_mct_core_enc.c | 2 +- lib_isar/isar_lcld_prot.h | 43 +++--- lib_isar/isar_splitRendererPost.c | 4 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 53 ++++++-- lib_rend/ivas_dirac_decorr_dec.c | 6 + lib_rend/ivas_output_init.c | 2 +- lib_rend/ivas_prot_rend.h | 12 +- lib_rend/ivas_reflections.c | 8 +- lib_rend/ivas_rom_rend.c | 1 - lib_rend/ivas_rotation.c | 11 +- lib_rend/lib_rend.c | 95 +++++++++----- lib_rend/lib_rend.h | 1 + lib_util/audio_file_reader.c | 1 - lib_util/ls_custom_file_reader.c | 4 +- lib_util/ls_custom_file_reader.h | 2 +- 45 files changed, 365 insertions(+), 263 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 4aebb1016f..ae7675cd78 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -216,7 +216,9 @@ int main( #ifdef DEBUG_SBA_AUDIO_DUMP int16_t numOutChannels, numTransportChannels, pca_ingest_channels; #endif +#endif +#ifdef DEBUGGING dbgargs( &argc, argv ); #endif #ifdef WMOPS @@ -690,7 +692,8 @@ int main( } } - /* ISAR frame size is set from command line, not renderer config file. This will be ignored if output format is not split rendering. */ + /* ISAR frame size is set from command line, not renderer config file. + * This will be ignored if output format is not split rendering. */ renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.renderFramesize /* given in number of 5ms subframes */ * 5; if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) @@ -1025,7 +1028,6 @@ static bool parseCmdlIVAS_dec( arg->aeSequence.pValidity = NULL; arg->aeSequence.selected = 0; arg->aeSequence.frameCounter = 0; - for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { arg->directivityPatternId[i] = 65535; @@ -2237,6 +2239,7 @@ static ivas_error decodeG192( } #endif #endif + /*------------------------------------------------------------------------------------------* * Loop for every packet (frame) of bitstream data * - Read the bitstream packet @@ -2334,7 +2337,6 @@ static ivas_error decodeG192( goto cleanup; } } - for ( i = 0; i < num_subframes; i++ ) { if ( ( error = IVAS_DEC_FeedExternalOrientationData( hIvasDec, Quaternions[i], enableHeadRotation[i], enableExternalOrientation[i], enableRotationInterpolation[i], numFramesToTargetOrientation[i], i ) ) != IVAS_ERR_OK ) @@ -2361,9 +2363,7 @@ static ivas_error decodeG192( { arg.aeSequence.selected = 0; } - arg.aeSequence.frameCounter = 0; - if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, arg.aeSequence.pID[arg.aeSequence.selected], &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) @@ -2377,7 +2377,6 @@ static ivas_error decodeG192( fprintf( stderr, "Failed to get acoustic environment with ID %d\n\n", arg.aeSequence.pID[arg.aeSequence.selected] ); goto cleanup; } - if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2394,7 +2393,6 @@ static ivas_error decodeG192( fprintf( stderr, "\nError (%s) when reading TSM data from %s \n\n", arg.inputBitstreamFilename, TsmScaleFileReader_getFilePath( tsmScaleFileReader ) ); goto cleanup; } - int16_t maxScaling; /* max scaling as abs diff to the normal frame size in samples */ maxScaling = (int16_t) ceilf( (float) abs( arg.tsmScale - 100 ) / 100.0f * (float) ( nOutSamples * vec_pos_len ) ); @@ -2459,7 +2457,7 @@ static ivas_error decodeG192( } } - /* Decode transport channels, do TSM and feed to renderer */ + /* decode transport channels, do TSM and feed to renderer */ if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) { return error; @@ -2657,7 +2655,6 @@ static ivas_error decodeG192( } vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; - #ifdef WMOPS if ( vec_pos_update == 0 ) { @@ -3277,7 +3274,6 @@ static ivas_error decodeVoIP( goto cleanup; } } - for ( i = 0; i < num_subframes; i++ ) { if ( ( error = IVAS_DEC_FeedExternalOrientationData( hIvasDec, Quaternions[i], enableHeadRotation[i], enableExternalOrientation[i], enableRotationInterpolation[i], numFramesToTargetOrientation[i], i ) ) != IVAS_ERR_OK ) @@ -3525,8 +3521,6 @@ static ivas_error decodeVoIP( } } - frame++; - vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; if ( vec_pos_update == 0 ) { diff --git a/apps/encoder.c b/apps/encoder.c index aea797e3bc..2841683bba 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -555,8 +555,8 @@ int main( goto cleanup; } } - #endif + /*------------------------------------------------------------------------------------------* * Allocate input data buffer *------------------------------------------------------------------------------------------*/ diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index aefae6ec30..aa004c4cc3 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -31,6 +31,8 @@ *******************************************************************************************************/ #include "lib_isar_post_rend.h" + + #include #include #include diff --git a/apps/renderer.c b/apps/renderer.c index fe4ad83092..1fb83acc5a 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1396,6 +1396,7 @@ int main( goto cleanup; } } + if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { fprintf( stderr, "\nFailed to open file: %s\n", args.outputFilePath ); @@ -1476,9 +1477,8 @@ int main( while ( 1 ) { int16_t num_in_channels; - const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_framesize ) == 0; - num_in_channels = inBuffer.config.numChannels; + const bool isCurrentFrameMultipleOf20ms = frame % ( 4 / args.render_framesize ) == 0; if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && renderConfigReader != NULL && args.aeSequence.count > 0 && args.aeSequence.pValidity[args.aeSequence.selected] != 0 ) @@ -1489,9 +1489,7 @@ int main( { args.aeSequence.selected = 0; } - args.aeSequence.frameCounter = 0; - if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, args.aeSequence.pID[args.aeSequence.selected], &renderConfig.roomAcoustics ) ) == IVAS_ERR_OK ) { if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) @@ -1505,7 +1503,6 @@ int main( fprintf( stderr, "\nFailed to get acoustic environment with ID %d\n\n", args.aeSequence.pID[args.aeSequence.selected] ); goto cleanup; } - if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedRenderConfig failed: %s\n\n", ivas_error_to_string( error ) ); @@ -1546,14 +1543,12 @@ int main( fprintf( stderr, "\nVector3PairFileReader_read failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; } - if ( ( error = IVAS_REND_SetReferenceVector( hIvasRend, listenerPos, refPos ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_SetReferenceVector failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; } } - /* Read from reference rotation trajectory file if specified */ if ( referenceRotReader != NULL ) { @@ -1613,7 +1608,6 @@ int main( int8_t enableExternalOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; int8_t enableRotationInterpolation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; int16_t numFramesToTargetOrientation[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; - for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) { if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &quatBuffer[sf_idx], &enableHeadRotation[sf_idx], &enableExternalOrientation[sf_idx], &enableRotationInterpolation[sf_idx], &numFramesToTargetOrientation[sf_idx] ) ) != IVAS_ERR_OK ) @@ -1622,7 +1616,6 @@ int main( goto cleanup; } } - for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) { if ( ( error = IVAS_REND_SetExternalOrientation( hIvasRend, &quatBuffer[sf_idx], enableHeadRotation[sf_idx], enableExternalOrientation[sf_idx], enableRotationInterpolation[sf_idx], numFramesToTargetOrientation[sf_idx], sf_idx ) ) != IVAS_ERR_OK ) @@ -1634,14 +1627,13 @@ int main( } /* Combine external orientations and head rotation */ + if ( ( error = IVAS_REND_CombineHeadAndExternalOrientation( hIvasRend ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError combining external and head orientations: %s\n", ivas_error_to_string( error ) ); goto cleanup; } - IVAS_REND_ReadOnlyAudioBuffer tmpBuffer; - for ( i = 0; i < args.inConfig.numMultiChannelBuses; ++i ) { if ( ( error = IVAS_REND_GetInputNumChannels( hIvasRend, mcIds[i], &numChannels ) ) != IVAS_ERR_OK ) @@ -1649,8 +1641,7 @@ int main( fprintf( stderr, "\nIVAS_REND_GetInputNumChannels failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; } - - tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.multiChannelBuses[i].inputChannelIndex, numChannels ); + IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.multiChannelBuses[i].inputChannelIndex, numChannels ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, mcIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) { @@ -1665,7 +1656,7 @@ int main( { if ( i == 0 ) { - tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, args.inConfig.numAudioObjects ); + IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, args.inConfig.numAudioObjects ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, ismIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) { @@ -1682,7 +1673,7 @@ int main( } else { - tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, 1 ); + IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, 1 ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, ismIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) { @@ -1705,8 +1696,7 @@ int main( fprintf( stderr, "\nIVAS_REND_GetInputNumChannels failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; } - - tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.ambisonicsBuses[i].inputChannelIndex, numChannels ); + IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.ambisonicsBuses[i].inputChannelIndex, numChannels ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, sbaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) { @@ -1722,8 +1712,7 @@ int main( fprintf( stderr, "IVAS_REND_GetInputNumChannels failed: %s\n", ivas_error_to_string( error ) ); goto cleanup; } - - tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.masaBuses[i].inputChannelIndex, numChannels ); + IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.masaBuses[i].inputChannelIndex, numChannels ); if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, masaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) { @@ -1796,7 +1785,8 @@ int main( if ( is_split_pre_rend_mode( &args ) ) { - if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, &bitsBuffer.config.bitsWritten ) != IVAS_ERR_OK ) + if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, + &bitsBuffer.config.bitsWritten ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to write to bitstream file!\n" ); goto cleanup; @@ -1841,7 +1831,6 @@ int main( numInputFormats++; inputType1 = IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS; } - if ( args.inConfig.numMultiChannelBuses > 0 ) { numInputFormats++; @@ -1850,7 +1839,6 @@ int main( inputType1 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED; } } - if ( args.inConfig.numMasaBuses > 0 ) { numInputFormats++; @@ -1859,7 +1847,6 @@ int main( inputType1 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA; } } - if ( args.inConfig.numAudioObjects > 0 ) { numInputFormats++; @@ -2248,6 +2235,7 @@ static bool parseDiegeticPan( return true; } + static bool parseRenderFramesize( char *value, IVAS_RENDER_FRAMESIZE *render_framesize ) @@ -2277,6 +2265,7 @@ static bool parseRenderFramesize( return true; } + static bool parseOrientationTracking( char *value, IVAS_HEAD_ORIENT_TRK_T *orientation_tracking ) @@ -3273,6 +3262,7 @@ static void parseObjectPosition( int16_t read_values; float meta_prm[8] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f }; + readNextMetadataChunk( line, "," ); *positionDuration = (uint16_t) strtol( line, &endptr, 10 ); readNextMetadataChunk( line, "\n" ); @@ -3708,8 +3698,7 @@ static void parseSceneDescriptionFile( return; } -static void printSupportedAudioConfigs( - void ) +static void printSupportedAudioConfigs( void ) { uint16_t i; const char *supportedFormats[] = { diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 1ddd8f6f8c..04992e76b1 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1006,8 +1006,8 @@ typedef enum #define IVAS_ACTIVEW_DM_F_SCALE_VLBR 0.25f #define IVAS_SPAR_FOA_DFLT_FREQ_PER_CHAN 24000 -#define IVAS_SPAR_DYN_ACTIVEW_THRESH (0.0039f) -#define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH (32.0f) +#define IVAS_SPAR_DYN_ACTIVEW_THRESH (0.0039f) +#define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH (32.0f) #define MAX_QUANT_STRATS 3 #define MAX_CODING_STRATS 3 @@ -1114,6 +1114,7 @@ enum TOTAL_DECD_QUANT_STRATS }; + /*----------------------------------------------------------------------------------* * MASA constants *----------------------------------------------------------------------------------*/ @@ -1271,6 +1272,7 @@ typedef enum #define MCMASA_MIN_SPEAKERS_SEPARATE_CENTER 4 + /*----------------------------------------------------------------------------------* * MCT constants *----------------------------------------------------------------------------------*/ @@ -1297,12 +1299,12 @@ typedef enum * MC Param-Upmix Mode Constants *----------------------------------------------------------------------------------*/ -#define MC_PARAMUPMIX_MAX_TRANSPORT_CHANS 8 -#define MC_PARAMUPMIX_MAX_INPUT_CHANS 12 -#define MC_PARAMUPMIX_MAX_BITS 1024 /* Maximum number of bits for the MC Param-Upmix metadata */ -#define MC_PARAMUPMIX_COMBINATIONS 4 /* number of sets of 2 channels combined */ -#define MC_PARAMUPMIX_NCH 2 /* number of channels to combine into 1 */ -#define MC_PARAMUPMIX_MIN_CLDFB 8 +#define MC_PARAMUPMIX_MAX_TRANSPORT_CHANS 8 +#define MC_PARAMUPMIX_MAX_INPUT_CHANS 12 +#define MC_PARAMUPMIX_MAX_BITS 1024 /* Maximum number of bits for the MC Param-Upmix metadata */ +#define MC_PARAMUPMIX_COMBINATIONS 4 /* number of sets of 2 channels combined */ +#define MC_PARAMUPMIX_NCH 2 /* number of channels to combine into 1 */ +#define MC_PARAMUPMIX_MIN_CLDFB 8 typedef enum _COV_SMOOTHING_TYPE { @@ -1394,6 +1396,7 @@ typedef enum #define PARAM_MC_MDFT_NO_SLOTS 8 #define PARAM_MC_CLDFB_TO_MDFT_FAC 2 + /*----------------------------------------------------------------------------------* * LFE Coding Constants *----------------------------------------------------------------------------------*/ @@ -1551,7 +1554,6 @@ typedef enum } SFX_OpMode_t; - /*----------------------------------------------------------------------------------* * Reverberator constants *----------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index 5c20279058..fcc79ffefc 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -577,7 +577,7 @@ void ivas_param_ism_config( * selects the ISM mode base on bitrate and number of objects * ---------------------------------------------------------------*/ -/*! r: ISM format mode */ +/*! r : ISM format mode */ ISM_MODE ivas_ism_mode_select( const int16_t nchan_inp, /* i : number of input objects */ const int32_t ivas_total_brate /* i : IVAS total bitrate */ diff --git a/lib_com/ivas_limiter.c b/lib_com/ivas_limiter.c index ce2ef8367a..3f5217ed99 100644 --- a/lib_com/ivas_limiter.c +++ b/lib_com/ivas_limiter.c @@ -100,7 +100,7 @@ static int16_t detect_strong_saturations( * Allocate and initialize limiter struct *-------------------------------------------------------------------*/ -/*! r: limiter struct handle */ +/*! r : limiter struct handle */ ivas_error ivas_limiter_open( IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ const int16_t max_num_channels, /* i : maximum number of I/O channels to be processed */ diff --git a/lib_com/ivas_mc_com.c b/lib_com/ivas_mc_com.c index 7662313b36..8534ef0e70 100644 --- a/lib_com/ivas_mc_com.c +++ b/lib_com/ivas_mc_com.c @@ -48,7 +48,7 @@ * selects the multichannel mode base on bitrate and LS setup * ---------------------------------------------------------------*/ -/*! r: MC format mode */ +/*! r : MC format mode */ MC_MODE ivas_mc_mode_select( const MC_LS_SETUP mc_ls_setup, /* i : MC loudspeaker setup */ const int32_t total_brate /* i : IVAS total bitrate */ @@ -126,7 +126,7 @@ MC_MODE ivas_mc_mode_select( * returns the number of channels (including the LFE) for a MC LS setup * ---------------------------------------------------------------*/ -/*! r: number of loudspeaker channels */ +/*! r : number of loudspeaker channels */ int16_t ivas_mc_ls_setup_get_num_channels( const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup */ ) @@ -166,7 +166,7 @@ int16_t ivas_mc_ls_setup_get_num_channels( * maps output configuration multi channel loudspeaker setup * ---------------------------------------------------------------*/ -/*! r: multi channel loudspeaker setup */ +/*! r : multi channel loudspeaker setup */ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( const AUDIO_CONFIG output_config /* i : output audio configuration */ ) diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com.c index 6741f7cea3..9c5d183e31 100644 --- a/lib_com/ivas_omasa_com.c +++ b/lib_com/ivas_omasa_com.c @@ -69,7 +69,7 @@ * the number of objects in the combined ISM MASA format mode * ---------------------------------------------------------------*/ -/*! r: ISM format mode */ +/*! r : ISM format mode */ ISM_MODE ivas_omasa_ism_mode_select( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t nchan_ism /* i : number of input ISM's */ diff --git a/lib_com/ivas_osba_com.c b/lib_com/ivas_osba_com.c index 0992a17d25..70065e8777 100644 --- a/lib_com/ivas_osba_com.c +++ b/lib_com/ivas_osba_com.c @@ -39,7 +39,7 @@ #include "debug.h" #endif -/*! r: ISM format mode */ +/*! r : ISM format mode */ ISM_MODE ivas_osba_ism_mode_select( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t nchan_ism /* i : number of input ISM's */ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 166415664d..2d8948fe5c 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -637,9 +637,9 @@ void set_transient_stereo( /*! r: preliminary flag to force ACELP */ int16_t transient_analysis( - TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */ - const float cor_map_LT[], /* i : LT correlation map */ - const float multi_harm_limit /* i : multi harminic threshold */ + TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */ + const float cor_map_LT[], /* i : LT correlation map */ + const float multi_harm_limit /* i : multi harminic threshold */ ); void ivas_post_proc( @@ -760,29 +760,31 @@ int16_t get_igf_startline( ); float rand_triangular_signed( - int16_t *seed ); + int16_t *seed +); + Word16 matrix_product_fx( - const Word32 *X_fx, /* i : left hand matrix Qx*/ - const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ - const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ - const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ - const Word32 *Y_fx, /* i : right hand matrix Qy*/ - const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ - const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ - const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ - Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Qx + Qy - 31*/ + const Word32 *X_fx, /* i : left hand matrix Qx*/ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y_fx, /* i : right hand matrix Qy*/ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Qx + Qy - 31*/ ); Word16 matrix_product_q30_fx( - const Word32 *X_fx, /* i : left hand matrix Q31*/ - const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ - const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ - const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ - const Word32 *Y_fx, /* i : right hand matrix Q25*/ - const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ - const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ - const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ - Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Q30*/ + const Word32 *X_fx, /* i : left hand matrix Q31*/ + const Word16 rowsX, /* i : number of rows of the left hand matrix Q0*/ + const Word16 colsX, /* i : number of columns of the left hand matrix Q0*/ + const Word16 transpX, /* i : flag indicating the transposition of the left hand matrix prior to the multiplication Q0*/ + const Word32 *Y_fx, /* i : right hand matrix Q25*/ + const Word16 rowsY, /* i : number of rows of the right hand matrix Q0*/ + const Word16 colsY, /* i : number of columns of the right hand matrix Q0*/ + const Word16 transpY, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication Q0*/ + Word32 *Z_fx /* o : resulting matrix after the matrix multiplication Q30*/ ); @@ -1009,7 +1011,7 @@ void ivas_ism_reset_metadata_handle_dec( ivas_error ivas_ism_enc( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *data[], /* i : input signal [channels][samples] */ + float *data[], /* i : input signal [channels][samples] */ const int16_t input_frame, /* i : input frame length per channel */ int16_t *nb_bits_metadata, /* i : number of metadata bits */ const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ @@ -3346,7 +3348,7 @@ int16_t quantize_direction2D( const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ ); -/*! r: companded azimuth value */ +/*! r :companded azimuth value */ float companding_azimuth( const float azi, /* i : input azimuth value */ const MC_LS_SETUP mc_format, /* i : input channel format */ @@ -3668,7 +3670,7 @@ ivas_error ivas_dirac_sba_config( int32_t sba_total_brate, /* i : SBA total bitrate */ const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int16_t nbands, /* i : number of frequency bands */ - const IVAS_FORMAT ivas_format /* i : IVAS format */ + const IVAS_FORMAT ivas_format /* i : IVAS format */ ); ivas_error ivas_dirac_dec_config( @@ -3884,9 +3886,9 @@ void ivas_param_mc_dec_prepare_renderer( void ivas_param_mc_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of sampes requested */ - uint16_t *nSamplesRendered, /* o : number of sampes rendered */ - uint16_t *nSamplesAvailable, /* o : number of sampes still to render */ + const uint16_t nSamplesAsked, /* i : number of samples requested */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailable, /* o : number of samples still to render */ float *output_f[] /* o : rendered time signal */ ); @@ -3993,24 +3995,24 @@ int16_t computeMixingMatricesResidual( /*! r: error or success */ int16_t svd( - float InputMatrix[][MAX_OUTPUT_CHANNELS], /* i : matrix to be decomposed (M) */ - float singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* o : left singular vectors (U) */ - float singularValues[MAX_OUTPUT_CHANNELS], /* o : singular values vector (S) */ - float singularVectors_Right[][MAX_OUTPUT_CHANNELS], /* o : right singular vectors (V) */ - const int16_t nChannelsL, /* i : number of rows in the matrix to be decomposed */ - const int16_t nChannelsC /* i : number of columns in the matrix to be decomposed */ + float InputMatrix[][MAX_OUTPUT_CHANNELS], /* i : matrix to be decomposed (M) */ + float singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* o : left singular vectors (U) */ + float singularValues[MAX_OUTPUT_CHANNELS], /* o : singular values vector (S) */ + float singularVectors_Right[][MAX_OUTPUT_CHANNELS], /* o : right singular vectors (V) */ + const int16_t nChannelsL, /* i : number of rows in the matrix to be decomposed */ + const int16_t nChannelsC /* i : number of columns in the matrix to be decomposed */ ); ivas_error ivas_dirac_dec_output_synthesis_cov_open( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: handle for the covariance synthesis state */ - const int16_t max_band_decorr, /* i : uppermost frequency band where decorrelation is applied */ - const int16_t interp_length, /* i : length for interpolating the mixing matrices in time slots */ - const int16_t num_param_bands, /* i : number of parameter bands */ - const int16_t num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ - const int16_t nchan_in, /* i : number of input (transport) channels */ - const int16_t nchan_out, /* i : number of output channels */ - const float *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */ + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ + DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: handle for the covariance synthesis state */ + const int16_t max_band_decorr, /* i : uppermost frequency band where decorrelation is applied */ + const int16_t interp_length, /* i : length for interpolating the mixing matrices in time slots */ + const int16_t num_param_bands, /* i : number of parameter bands */ + const int16_t num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation) */ + const int16_t nchan_in, /* i : number of input (transport) channels */ + const int16_t nchan_out, /* i : number of output channels */ + const float *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */ ); void ivas_dirac_dec_output_synthesis_get_interpolator( @@ -4019,33 +4021,33 @@ void ivas_dirac_dec_output_synthesis_get_interpolator( ); void ivas_dirac_dec_output_synthesis_cov_init( - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: pointer to the state of the covariance synthesis */ - const int16_t nchan_in, /* i : number of input (tranport) channels */ - const int16_t nchan_out, /* i : number of output channels */ - const int16_t n_param_bands, /* i : number of total parameter bands */ - const int16_t n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ + DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: pointer to the state of the covariance synthesis */ + const int16_t nchan_in, /* i : number of input (tranport) channels */ + const int16_t nchan_out, /* i : number of output channels */ + const int16_t n_param_bands, /* i : number of total parameter bands */ + const int16_t n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ ); void ivas_dirac_dec_output_synthesis_cov_close( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i : handle for the covariance synthesis parameters */ - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */ + DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i : handle for the covariance synthesis parameters */ + DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */ ); void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( - float *RealBuffer, /* i : input channel filter bank samples (real part) */ - float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ - float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (real part) */ - float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (imaginary part) */ - const int16_t param_band, /* i : parameter band */ - PARAM_MC_DEC_HANDLE hParamMC, /* i : handle to Parametric MC state */ - const int16_t nchan_in /* i : number of input channels */ + float *RealBuffer, /* i : input channel filter bank samples (real part) */ + float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ + float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (real part) */ + float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* o : accumulated input covariance (imaginary part) */ + const int16_t param_band, /* i : parameter band */ + PARAM_MC_DEC_HANDLE hParamMC, /* i : handle to Parametric MC state */ + const int16_t nchan_in /* i : number of input channels */ ); void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( float *Cldfb_RealBuffer_in, /* i : input channel filter bank samples (real part) */ float *Cldfb_ImagBuffer_in, /* i : input channel filter bank samples (imaginary part) */ - float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (real part) */ - float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (imaginary part) */ + float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (real part) */ + float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (imaginary part)*/ float *mixing_matrix[], /* i : parameter band wise mixing matrices (direct part) */ float *mixing_matrix_res[], /* i : parameter band wise mixing matrices (residual part) */ const uint16_t slot_idx_sfr, /* i : time slot index for the current slot within the current subframe */ @@ -5018,7 +5020,7 @@ void ivas_masa_combine_directions( MASA_ENCODER_HANDLE hMasa /* i/o: MASA encoder handle */ ); -/*! r: number of bits for ISM ratio index */ +/*!r : number of bits for ISM ratio index */ int16_t bits_index_ism_ratio( const int16_t nchan_ism /* i : number of objects */ ); @@ -5091,7 +5093,7 @@ void masa_sample_rate_band_correction( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ const uint8_t maxBand, /* i : max band */ uint8_t is_encoder, /* i : signals if called at encoder */ - MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ + MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ ); void invdct4_transform( @@ -5226,7 +5228,7 @@ void ivas_param_mc_mc2sba_cldfb( float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ const int16_t nBands, /* i : number of synth CLDFB bands */ - const float gain_lfe /* i : gain applied to LFE */ + const float gain_lfe /* i : gain applied to LFE */ ); void ivas_ism2sba_sf( @@ -5404,8 +5406,8 @@ void lls_interp_n( void computeReferencePower_enc( const int16_t *band_grouping, /* i : Band grouping for estimation */ - float Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */ - float Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */ + float Cldfb_RealBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Real part of input signal */ + float Cldfb_ImagBuffer[][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */ float *reference_power, /* o : Estimated power */ const int16_t enc_param_start_band, /* i : first band to process */ const int16_t num_freq_bands, /* i : Number of frequency bands */ diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index ca90e23a58..4dbf7e828e 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -62,7 +62,6 @@ void Euler2Quat( float sp = sinf( pitch * 0.5f ); float cy = cosf( yaw * 0.5f ); float sy = sinf( yaw * 0.5f ); - quat->w = cr * cp * cy + sr * sp * sy; quat->x = sr * cp * cy - cr * sp * sy; quat->y = sr * cp * sy + cr * sp * cy; @@ -88,7 +87,6 @@ void Quat2EulerDegree( if ( quat.w != -3.0 ) { float p; - *yaw = atan2f( 2 * ( quat.w * quat.x + quat.y * quat.z ), 1 - 2 * ( quat.x * quat.x + quat.y * quat.y ) ); p = 2 * ( quat.w * quat.y - quat.z * quat.x ); p = max( -1.0f, min( 1.0f, p ) ); diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 451aae85cf..fc7f40ce29 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -181,7 +181,6 @@ int16_t ivas_sba_spar_sid_bitlen( return num_bits; } - /*-------------------------------------------------------------------* * ivas_sba_get_nchan_metadata() * diff --git a/lib_com/prot.h b/lib_com/prot.h index 90f8d1265f..afb0594efc 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -735,9 +735,9 @@ int16_t lev_dur( /*! r: delay value in ns */ int32_t get_delay( - const int16_t enc_dec, /* i : encoder/decoder flag */ - const int32_t io_fs, /* i : input/output sampling frequency */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const int16_t enc_dec, /* i : encoder/decoder flag */ + const int32_t io_fs, /* i : input/output sampling frequency */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ const int16_t flag_binaural_split_coded /* i : split rendering on/off flag */ ); diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 1c310a9fce..716aa5284e 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1284,6 +1284,7 @@ void ivas_binaural_add_LFE( return; } + #ifdef DEBUGGING /*-------------------------------------------------------------------------* * ivas_binaural_cldfb() @@ -1570,6 +1571,7 @@ void ivas_binaural_cldfb_sf( } #endif + /*------------------------------------------------------------------------- * ivas_binRenderer() * diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index b570be7775..bfa29f727b 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -512,7 +512,7 @@ ivas_error ivas_cpe_dec( stereo_cna_update_params( hCPE, output, output_frame, tdm_ratio_idx ); /*----------------------------------------------------------------* - * Synthesis synchronization between coding tools and CPE modes + * Synthesis synchronization between CPE modes *----------------------------------------------------------------*/ if ( !st_ivas->sba_dirac_stereo_flag ) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 1b7bfda7d5..dc5a821671 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -52,7 +52,7 @@ *--------------------------------------------------------------------------*/ ivas_error ivas_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ int16_t *data /* o : output synthesis signal */ ) { diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 22197b9a86..7765d49a28 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -844,7 +844,6 @@ ivas_error ivas_dirac_dec_config( if ( !sparfoa_flag ) { common_rend_config_flag = st_ivas->hSpatParamRendCom == NULL ? DIRAC_OPEN : flag_config_inp; - if ( ( error = ivas_spat_hSpatParamRendCom_config( &st_ivas->hSpatParamRendCom, common_rend_config_flag, dec_param_estim_new, st_ivas->ivas_format, st_ivas->mc_mode, output_Fs, hodirac_flag, 0 ) ) != IVAS_ERR_OK ) { @@ -1708,8 +1707,8 @@ void ivas_dirac_dec_render_sf( sprintf( file_name, "./res/ivas_dirac_dec_DMX%d.%d.pcm", nchan_transport, (int16_t) ( output_frame * 0.05 ) ); dbgwrite( tmp, sizeof( int16_t ), nchan_transport * output_frame, 1, file_name ); } - #endif + /* Subframe loop */ slot_idx_start = hSpatParamRendCom->slots_rendered; slot_idx_start_cldfb_synth = 0; @@ -1810,7 +1809,6 @@ void ivas_dirac_dec_render_sf( set_zero( surCohRatio, hSpatParamRendCom->num_freq_bands ); } } - ivas_dirac_dec_compute_directional_responses( hSpatParamRendCom, hDirACRend, st_ivas->hVBAPdata, @@ -1833,7 +1831,10 @@ void ivas_dirac_dec_render_sf( for ( ch = 0; ch < nchan_transport; ch++ ) { cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ), - Cldfb_RealBuffer_Temp[ch][slot_idx], Cldfb_ImagBuffer_Temp[ch][slot_idx], hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); + Cldfb_RealBuffer_Temp[ch][slot_idx], + Cldfb_ImagBuffer_Temp[ch][slot_idx], + hSpatParamRendCom->num_freq_bands, + st_ivas->cldfbAnaDec[ch] ); } } @@ -1854,7 +1855,6 @@ void ivas_dirac_dec_render_sf( { md_idx = hSpatParamRendCom->render_to_md_map[subframe_idx]; } - if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { for ( ch = 0; ch < nchan_transport; ch++ ) @@ -1877,7 +1877,10 @@ void ivas_dirac_dec_render_sf( for ( ch = 0; ch < nchan_transport; ch++ ) { cldfbAnalysis_ts( &( st_ivas->hTcBuffer->tc[hDirACRend->sba_map_tc[ch]][hSpatParamRendCom->num_freq_bands * index_slot] ), - Cldfb_RealBuffer[ch][0], Cldfb_ImagBuffer[ch][0], hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch] ); + Cldfb_RealBuffer[ch][0], + Cldfb_ImagBuffer[ch][0], + hSpatParamRendCom->num_freq_bands, + st_ivas->cldfbAnaDec[ch] ); } } @@ -1886,14 +1889,25 @@ void ivas_dirac_dec_render_sf( { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - generate_masking_noise_dirac( st->hFdCngDec->hFdCngCom, st_ivas->cldfbAnaDec[1], &st_ivas->hTcBuffer->tc[1][hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->slots_rendered], - Cldfb_RealBuffer[1][0], Cldfb_ImagBuffer[1][0], slot_idx, st->cna_dirac_flag && st->flag_cna, ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && st->cng_type == FD_CNG && st->cng_sba_flag ); + generate_masking_noise_dirac( st->hFdCngDec->hFdCngCom, + st_ivas->cldfbAnaDec[1], + &st_ivas->hTcBuffer->tc[1][hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->slots_rendered], + Cldfb_RealBuffer[1][0], + Cldfb_ImagBuffer[1][0], + slot_idx, + st->cna_dirac_flag && st->flag_cna, + ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && st->cng_type == FD_CNG && st->cng_sba_flag ); } /* LFE synthesis */ if ( st_ivas->mc_mode == MC_MODE_MCMASA && !hDirACRend->hOutSetup.separateChannelEnabled && !( hDirACRend->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && hDirACRend->hOutSetup.num_lfe == 0 ) ) { - ivas_lfe_synth_with_cldfb( st_ivas->hMasa->hMasaLfeSynth, Cldfb_RealBuffer, Cldfb_ImagBuffer, Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1], Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1], slot_idx, md_idx, nchan_transport ); + ivas_lfe_synth_with_cldfb( st_ivas->hMasa->hMasaLfeSynth, + Cldfb_RealBuffer, Cldfb_ImagBuffer, + Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1], Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1], + slot_idx, + md_idx, + nchan_transport ); } /*-----------------------------------------------------------------* @@ -1904,20 +1918,30 @@ void ivas_dirac_dec_render_sf( { if ( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order == 0 ) { - protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, - reference_power, slot_idx, nchan_transport, hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands, p_Rmat ); + protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, + hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, + reference_power, slot_idx, nchan_transport, + hDirACRend->num_outputs_diff, + hSpatParamRendCom->num_freq_bands, + p_Rmat ); } else { protoSignalComputation_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f, - reference_power, slot_idx, nchan_transport, hDirACRend->num_outputs_diff, hSpatParamRendCom->num_freq_bands, 0 ); + reference_power, slot_idx, nchan_transport, + hDirACRend->num_outputs_diff, + hSpatParamRendCom->num_freq_bands, + 0 ); } } else if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_MONO ) { - protoSignalComputation2( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->proto_frame_f, hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, reference_power, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, + protoSignalComputation2( Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirACRend->proto_frame_f, + hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f, + reference_power, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, 0, slot_idx, hSpatParamRendCom->num_freq_bands, hDirACRend->masa_stereo_type_detect ); } else @@ -2052,6 +2076,7 @@ void ivas_dirac_dec_render_sf( } } #endif + /*-----------------------------------------------------------------* * frequency domain decorrelation *-----------------------------------------------------------------*/ @@ -2123,8 +2148,19 @@ void ivas_dirac_dec_render_sf( } /*Compute PSDs*/ - ivas_dirac_dec_output_synthesis_process_slot( reference_power, p_onset_filter, azimuth, elevation, hSpatParamRendCom->diffuseness_vector[md_idx], hSpatParamRendCom, - hDirACRend, st_ivas->hVBAPdata, hDirACRend->hOutSetup, nchan_transport, md_idx, hodirac_flag, hDirAC->hConfig->dec_param_estim ); + ivas_dirac_dec_output_synthesis_process_slot( reference_power, + p_onset_filter, + azimuth, + elevation, + hSpatParamRendCom->diffuseness_vector[md_idx], + hSpatParamRendCom, + hDirACRend, + st_ivas->hVBAPdata, + hDirACRend->hOutSetup, + nchan_transport, + md_idx, + hodirac_flag, + hDirAC->hConfig->dec_param_estim ); if ( hDirAC->hConfig->dec_param_estim ) { @@ -2140,10 +2176,19 @@ void ivas_dirac_dec_render_sf( ivas_dirac_dec_output_synthesis_get_interpolator( &hDirACRend->h_output_synthesis_psd_params, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) { - ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( Cldfb_RealBuffer, Cldfb_ImagBuffer, hSpatParamRendCom, hDirACRend, nchan_transport, - hSpatParamRendCom->subframe_nbslots[subframe_idx], p_onset_filter, diffuseness_vector, hodirac_flag, hDirAC->hConfig->dec_param_estim ); + ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( Cldfb_RealBuffer, + Cldfb_ImagBuffer, + hSpatParamRendCom, + hDirACRend, + nchan_transport, + hSpatParamRendCom->subframe_nbslots[subframe_idx], + p_onset_filter, + diffuseness_vector, + hodirac_flag, + hDirAC->hConfig->dec_param_estim ); } else { @@ -2156,8 +2201,15 @@ void ivas_dirac_dec_render_sf( qualityBasedSmFactor *= qualityBasedSmFactor; } - ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( Cldfb_RealBuffer, Cldfb_ImagBuffer, hSpatParamRendCom, hDirACRend, hSpatParamRendCom->subframe_nbslots[subframe_idx], - diffuseness_vector, reference_power_smooth, qualityBasedSmFactor, hDirAC->hConfig->enc_param_start_band ); + ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( Cldfb_RealBuffer, + Cldfb_ImagBuffer, + hSpatParamRendCom, + hDirACRend, + hSpatParamRendCom->subframe_nbslots[subframe_idx], + diffuseness_vector, + reference_power_smooth, + qualityBasedSmFactor, + hDirAC->hConfig->enc_param_start_band ); } /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 229188224d..68f7f9ed25 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -582,7 +582,6 @@ int16_t computeMixingMatrices( maximum( svd_s_buffer, lengthCx, &limit ); limit = (float) max( limit * reg_Sx, SQRT_EPSILON ); - for ( i = 0; i < lengthCx; ++i ) { svd_s_buffer[i] = ( ( svd_s_buffer[i] > limit ) ? svd_s_buffer[i] : limit ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 95b4cbf3b4..03cba849d4 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1217,8 +1217,7 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Binaural Renderer configuration handle *--------------------------------------------------------------------*/ - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) ) { if ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) @@ -1507,7 +1506,9 @@ ivas_error ivas_init_decoder( return error; } - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, + ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), + st_ivas->ivas_format ) ) != IVAS_ERR_OK ) { return error; } @@ -1654,7 +1655,9 @@ ivas_error ivas_init_decoder( return error; } - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, + ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), + st_ivas->ivas_format ) ) != IVAS_ERR_OK ) { return error; } @@ -2365,7 +2368,7 @@ ivas_error ivas_init_decoder( } /*-----------------------------------------------------------------* - * Allocate 'float' output audio buffers + * Allocate floating-point output audio buffers *-----------------------------------------------------------------*/ for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) @@ -2624,7 +2627,7 @@ void ivas_initialize_handles_dec( st_ivas->hTcBuffer = NULL; st_ivas->hJbmMetadata = NULL; - /* 'float' output audio buffers */ + /* floating-point output audio buffers */ for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { st_ivas->p_output_f[i] = NULL; @@ -2851,7 +2854,7 @@ void ivas_destroy_dec( st_ivas->hJbmMetadata = NULL; } - /* 'float' output audio buffers */ + /* floating-point output audio buffers */ for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { if ( st_ivas->p_output_f[i] != NULL ) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 814e86a747..62c0fed1cc 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -157,6 +157,7 @@ static void ivas_ism_get_proto_matrix( } break; } + default: assert( 0 && "Error: number of transport channels not supported" ); } @@ -562,7 +563,7 @@ ivas_error ivas_param_ism_dec_open( else { int16_t n_slots_to_alloc; - if ( st_ivas->hDecoderConfig->Opt_tsm ) + if ( st_ivas->hDecoderConfig->Opt_tsm == 1 ) { n_slots_to_alloc = MAX_JBM_CLDFB_TIMESLOTS; } @@ -608,7 +609,6 @@ ivas_error ivas_param_ism_dec_open( } pop_wmops(); - return error; } diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index bddd2de7bd..2493c17581 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -636,7 +636,6 @@ static void ps_pred_process_sf( return; } - static void ivas_mc_paramupmix_dec_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *output_f[MAX_OUTPUT_CHANNELS] /* i/o: synthesized core-coder transport channels */ diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index ee23e15494..561bce7605 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -658,7 +658,7 @@ void ivas_mct_dec_close( * - reconfigure the MC format decoder *-------------------------------------------------------------------------*/ -/*! r: MC format mode */ +/*! r : MC format mode */ ivas_error ivas_mc_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t idx /* i : LS config. index */ @@ -1330,7 +1330,7 @@ static ivas_error ivas_mc_dec_reconfig( } /*-----------------------------------------------------------------* - * 'float' output audio buffers + * floating-point output audio buffers *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index c9b8eac818..dd0bfac76d 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -976,6 +976,7 @@ void ivas_mdct_core_reconstruct( } } #endif + /* updates */ st->last_voice_factor = 0.0f; st->last_coder_type = st->coder_type; diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 6d5df16afb..e2f501a971 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -306,8 +306,16 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( continue; } - if ( ( error = ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, st_ivas->ivas_format, st_ivas->transport_config, st_ivas->hRenderConfig->directivity, - st_ivas->hRenderConfig->distAtt, st_ivas->hTransSetup, &st_ivas->hTdRendHandles[i], &st_ivas->binaural_latency_ns ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_td_binaural_open_unwrap( &st_ivas->hHrtfTD, + st_ivas->hDecoderConfig->output_Fs, + st_ivas->nchan_transport, + st_ivas->ivas_format, + st_ivas->transport_config, + st_ivas->hRenderConfig->directivity, + st_ivas->hRenderConfig->distAtt, + st_ivas->hTransSetup, + &st_ivas->hTdRendHandles[i], + &st_ivas->binaural_latency_ns ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 89905c7173..feca940952 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -466,7 +466,7 @@ ivas_error ivas_omasa_dec_config( } /*-----------------------------------------------------------------* - * 'float' output audio buffers + * floating-point output audio buffers *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 6acffee951..28304399ec 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -313,7 +313,9 @@ ivas_error ivas_sba_dec_reconfigure( ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); } - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, + ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), + st_ivas->ivas_format ) ) != IVAS_ERR_OK ) { return error; } @@ -586,7 +588,7 @@ ivas_error ivas_sba_dec_reconfigure( } /*-----------------------------------------------------------------* - * 'float' output audio buffers + * floating-point output audio buffers *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 2b93345dc3..76ed22f4da 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1056,7 +1056,7 @@ typedef struct Decoder_Struct float **mem_hp20_out; /* output signals HP filter memories */ IVAS_LIMITER_HANDLE hLimiter; /* Limiter handle */ - float *p_output_f[MAX_OUTPUT_CHANNELS+MAX_NUM_OBJECTS]; /* 'floating' output audio buffers */ + float *p_output_f[MAX_OUTPUT_CHANNELS+MAX_NUM_OBJECTS]; /* floating-point output audio buffers */ /* core-decoder modules */ int16_t nSCE; /* number of total SCEs */ diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index b8024ce5bb..3177a2a2a5 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -297,6 +297,7 @@ ivas_error ivas_enc( set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); idx_separated_object = 0; + data_separated_object = data_f[hEncoderConfig->nchan_ism + CPE_CHANNELS]; /* put audio object data in SCE's */ diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 5dd4611279..1daa9b3a00 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -300,7 +300,6 @@ void ivas_param_ism_stereo_dmx( /* Smoothing */ if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 ) { - /* Smoothing */ dmx_gain = 0.75f * dmx_gain + 0.25f * last_dmx_gain; /* 10ms ramp */ @@ -446,6 +445,7 @@ void ivas_param_ism_enc( nchan_ism = st_ivas->hEncoderConfig->nchan_ism; hParamIsm = st_ivas->hParamIsm; + push_wmops( "ivas_param_ism_enc" ); l_ts = input_frame / PARAM_ISM_MDFT_NO_SLOTS; diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 7c0118812f..27f1a0ad3c 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -517,7 +517,7 @@ void ivas_mct_core_enc( nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; - /* MCT is used at bitrates > 80 kbps and additional 1 bit is present at these bitrates */ + /*MCT is used at bitrates > 80 kbps and additional 1 bit is present at these bitrates*/ if ( ivas_format == SBA_ISM_FORMAT ) { nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index fa3d6c7c3d..3e9c0527a9 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -50,7 +50,7 @@ ivas_error CreateLCLDEncoder( const int16_t iNumBlocks, const int16_t iNumSubSets, const int32_t iRealOnlyOut -); + ); void DeleteLCLDEncoder( LCLDEncoder *psLCLDEncoder @@ -62,8 +62,7 @@ int32_t EncodeLCLDFrame( float ***pppfLCLDImag, int32_t *piNumiBites, const int32_t available_bits, - ISAR_SPLIT_REND_BITS_HANDLE pBits -); + ISAR_SPLIT_REND_BITS_HANDLE pBits ); typedef struct LCLD_DECODER LCLDDecoder; @@ -73,8 +72,7 @@ ivas_error CreateLCLDDecoder( const int32_t iSampleRate, const int32_t iChannels, const int32_t iNumBlocks, - const int32_t iRealOnlyOut -); + const int32_t iRealOnlyOut); void DeleteLCLDDecoder( LCLDDecoder *psLCLDDecoder @@ -103,6 +101,7 @@ void cplxmult_lcld( const float i2 ); + int32_t requantPhase( int32_t phaseQ ); @@ -270,6 +269,7 @@ void ComputePredictors( float ***pppfImag ); + int32_t WritePredictors( PredictionEncoder *psPredictionEncoder, ISAR_SPLIT_REND_BITS_HANDLE pBits @@ -321,48 +321,37 @@ int16_t ReadPredictors( /* PLC_IMPROVEMENT */ void UpdatePredictionSubSetId( - PredictionEncoder *psPredictionEncoder -); + PredictionEncoder *psPredictionEncoder); void SetDecodingUnresolved( - LCLDDecoder *psLCLDDecoder -); + LCLDDecoder *psLCLDDecoder); int16_t AnyDecodingFailedPrev( - LCLDDecoder *psLCLDDecoder -); + LCLDDecoder *psLCLDDecoder); int16_t AnyDecodingFailed( - LCLDDecoder *psLCLDDecoder -); + LCLDDecoder *psLCLDDecoder); int32_t **GetDecodingFailedStatus( - LCLDDecoder *psLCLDDecoder -); + LCLDDecoder *psLCLDDecoder); int16_t GetNumSubSets( - LCLDDecoder *psLCLDDecoder -); + LCLDDecoder *psLCLDDecoder); int32_t **GetDecodingFailedPrevStatus( - LCLDDecoder *psLCLDDecoder -); + LCLDDecoder *psLCLDDecoder); void SetDecodingPassed( - PredictionDecoder *psPredictionDecoder -); + PredictionDecoder *psPredictionDecoder); void UpdateDecodingUnresolved( - PredictionDecoder *psPredictionDecoder -); + PredictionDecoder *psPredictionDecoder); void UpdateDecodingFailedStatus( - PredictionDecoder *psPredictionDecoder -); + PredictionDecoder *psPredictionDecoder); int32_t AnyDecodingUnresolved( - PredictionDecoder *psPredictionDecoder -); + PredictionDecoder *psPredictionDecoder); void ApplyInversePredictors( PredictionDecoder *psPredictionDecoder, diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 83afc78906..b452ec90f1 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -1400,8 +1400,8 @@ static void interpolate_rend_md( static void isar_SplitRenderer_PostRenderer( ISAR_BIN_HR_SPLIT_POST_REND_HANDLE hBinPostRenderer, /* i/o: binaural renderer handle */ MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, /* i/o: pose correction data handle */ - float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Reference/out Binaural signals */ - float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Reference/out Binaural signals */ + float Cldfb_RealBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ + float Cldfb_ImagBuffer_Ref_Binaural[][CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o : Reference/out Binaural signals */ const IVAS_QUATERNION Quaternion_act ) { int16_t pos_idx, b, brange[2], ch_idx1; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index b69d990470..a13449b6b4 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -268,7 +268,10 @@ ivas_error ivas_dirac_dec_init_binaural_data( hDiracDecBin->useTdDecorr = 0; } - ivas_dirac_dec_decorr_close( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); + if ( hDiracDecBin->h_freq_domain_decorr_ap_params != NULL ) + { + ivas_dirac_dec_decorr_close( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); + } if ( pos_idx == 0 ) /* open decorrelator only for the main direction */ { @@ -281,8 +284,15 @@ ivas_error ivas_dirac_dec_init_binaural_data( { ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, nBins ); - if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), &( hDiracDecBin->h_freq_domain_decorr_ap_state ), - nBins, BINAURAL_CHANNELS, BINAURAL_CHANNELS, DIRAC_SYNTHESIS_PSD_LS, frequency_axis, BINAURAL_CHANNELS, output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), + &( hDiracDecBin->h_freq_domain_decorr_ap_state ), + nBins, + BINAURAL_CHANNELS, + BINAURAL_CHANNELS, + DIRAC_SYNTHESIS_PSD_LS, + frequency_axis, + BINAURAL_CHANNELS, + output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -345,11 +355,17 @@ void ivas_dirac_dec_close_binaural_data( { if ( hBinaural[pos_idx] != NULL ) { - ivas_binaural_reverb_close( &( hBinaural[pos_idx]->hReverb ) ); + if ( hBinaural[pos_idx]->hReverb != NULL ) + { + ivas_binaural_reverb_close( &( hBinaural[pos_idx]->hReverb ) ); + } ivas_td_decorr_dec_close( &( hBinaural[pos_idx]->hTdDecorr ) ); - ivas_dirac_dec_decorr_close( &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params ), &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_state ) ); + if ( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params != NULL ) + { + ivas_dirac_dec_decorr_close( &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_params ), &( hBinaural[pos_idx]->h_freq_domain_decorr_ap_state ) ); + } free( hBinaural[pos_idx] ); hBinaural[pos_idx] = NULL; @@ -372,7 +388,6 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( { int16_t i, j; - if ( hHrtfParambin != NULL && *hHrtfParambin != NULL ) { /* Tables already loaded from file */ @@ -383,7 +398,6 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( /* Initialise tables from ROM */ HRTFS_PARAMBIN *hrtfParambin; - if ( ( hrtfParambin = (HRTFS_PARAMBIN *) malloc( sizeof( HRTFS_PARAMBIN ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for parametric binauralizer HRTF tables" ); @@ -634,11 +648,21 @@ static void ivas_dirac_dec_binaural_internal( numCoreBands = st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->numCoreBands; - generate_masking_noise_dirac( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom, st_ivas->cldfbAnaDec[1], &st_ivas->hTcBuffer->tc[nchan_transport][hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->slots_rendered], Cldfb_RealBuffer_in[2][slot], Cldfb_ImagBuffer_in[2][slot], slot, - st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->hSCE[0]->hCoreCoder[0]->flag_cna, ( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ); - - generate_masking_noise_dirac( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom, st_ivas->cldfbAnaDec[1], /*nothing will be analyzed, just get cnst*/ NULL, Cldfb_RealBuffer_in[1][slot], Cldfb_ImagBuffer_in[1][slot], slot, - st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->hSCE[0]->hCoreCoder[0]->flag_cna, ( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ); + generate_masking_noise_dirac( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom, + st_ivas->cldfbAnaDec[1], + &st_ivas->hTcBuffer->tc[nchan_transport][hSpatParamRendCom->num_freq_bands * hSpatParamRendCom->slots_rendered], + Cldfb_RealBuffer_in[2][slot], Cldfb_ImagBuffer_in[2][slot], + slot, + st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->hSCE[0]->hCoreCoder[0]->flag_cna, + ( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ); + + generate_masking_noise_dirac( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom, + st_ivas->cldfbAnaDec[1], /*nothing will be analyzed, just get cnst*/ + NULL, + Cldfb_RealBuffer_in[1][slot], Cldfb_ImagBuffer_in[1][slot], + slot, + st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->hSCE[0]->hCoreCoder[0]->flag_cna, + ( st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == FRAME_NO_DATA || st_ivas->hSCE[0]->hCoreCoder[0]->core_brate == SID_2k40 ) && ( st_ivas->hSCE[0]->hCoreCoder[0]->cng_type == FD_CNG ) && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ); /* LB: Copy first channel + LB-CNG to first and second channels with same scaling (dual-mono)*/ for ( b = 0; b < numCoreBands; b++ ) @@ -738,11 +762,12 @@ static void ivas_dirac_dec_binaural_internal( max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; } - ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, subFrameTotalEne, IIReneLimiter ); - + ivas_dirac_dec_binaural_formulate_input_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, subframe, + subFrameTotalEne, IIReneLimiter ); ivas_dirac_dec_binaural_formulate_target_covariance_matrices( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, subFrameTotalEne, IIReneLimiter, st_ivas->hMasaIsmData ); + nchanSeparateChannels = 0; if ( config_data.separateCenterChannelRendering || ( st_ivas->ivas_format == MASA_ISM_FORMAT && ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) ) ) { diff --git a/lib_rend/ivas_dirac_decorr_dec.c b/lib_rend/ivas_dirac_decorr_dec.c index 79b1abd6c0..f119ff64e4 100644 --- a/lib_rend/ivas_dirac_decorr_dec.c +++ b/lib_rend/ivas_dirac_decorr_dec.c @@ -632,11 +632,17 @@ void ivas_dirac_dec_decorr_close( if ( ph_freq_domain_decorr_ap_params == NULL || ph_freq_domain_decorr_ap_state == NULL ) { +#ifdef DEBUGGING + assert( 0 && "Error: Closing decorrelation synthesis failed." ); +#endif return; } if ( *ph_freq_domain_decorr_ap_params == NULL || *ph_freq_domain_decorr_ap_state == NULL ) { +#ifdef DEBUGGING + assert( 0 && "Error: Closing decorrelation synthesis failed." ); +#endif return; } diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index b556f308e3..1487181715 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -420,7 +420,7 @@ int16_t ivas_get_nchan_buffers_dec( /*-------------------------------------------------------------------* * ivas_output_buff_dec() * - * Allocate/reallocate 'float' output audio buffers + * Allocate/reallocate output audio buffers *-------------------------------------------------------------------*/ ivas_error ivas_output_buff_dec( diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 3ecc05792e..016876fa51 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -221,8 +221,8 @@ void ivas_masa_ext_rend_parambin_render( ); ivas_error ivas_dirac_dec_init_binaural_data( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - HRTFS_PARAMBIN_HANDLE *phHrtfParambin /* i : HRTF structure for rendering */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + HRTFS_PARAMBIN_HANDLE *phHrtfParambin /* i : HRTF structure for rendering */ ); void ivas_dirac_dec_close_binaural_data( @@ -672,10 +672,10 @@ void ivas_td_binaural_close( ); ivas_error TDREND_GetMix( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ float *output[], /* 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 */ + const int16_t subframe_length, /* i/o: subframe length */ + const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ ); ivas_error TDREND_Update_listener_orientation( @@ -1197,7 +1197,7 @@ ivas_error ivas_er_process( er_struct_t *reflections, /* i/o: early reflections handle */ const int16_t subframe_size, /* i : subframe length */ const int16_t subframe_idx, /* i : subframe index */ - float *output[], /* i/o: input/output buffer */ + float *in[], /* i/o: input/output buffer */ const AUDIO_CONFIG inConfig /* i : Input config */ ); diff --git a/lib_rend/ivas_reflections.c b/lib_rend/ivas_reflections.c index b0beed688c..eb384dc86a 100644 --- a/lib_rend/ivas_reflections.c +++ b/lib_rend/ivas_reflections.c @@ -428,7 +428,7 @@ ivas_error ivas_er_process( er_struct_t *reflections, /* i/o: early reflections handle */ const int16_t subframe_size, /* i : subframe length */ const int16_t subframe_idx, /* i : subframe index */ - float *output[], /* i/o: input/output buffer */ + float *in[], /* i/o: input/output buffer */ const AUDIO_CONFIG inConfig /* i : Input config */ ) { @@ -489,7 +489,7 @@ ivas_error ivas_er_process( { for ( j = 0; j < subframe_size; j++ ) { - buffer_ch[samp_idx++] = output[in_ch_idx][j + subframe_offset]; + buffer_ch[samp_idx++] = in[in_ch_idx][j + subframe_offset]; samp_idx = samp_idx % reflections->circ_len; } } @@ -498,7 +498,7 @@ ivas_error ivas_er_process( { for ( j = 0; j < subframe_size; j++ ) { - buffer_ch[samp_idx++] += output[in_ch_idx][j + subframe_offset]; + buffer_ch[samp_idx++] += in[in_ch_idx][j + subframe_offset]; samp_idx = samp_idx % reflections->circ_len; } } @@ -534,7 +534,7 @@ ivas_error ivas_er_process( /* Pull reflection from circ buffer and apply gain */ for ( k = 0; k < subframe_size; k++ ) { - output[ref_out_idx][k + subframe_offset] += buffer_ch[samp_idx++] * ref_gain; + in[ref_out_idx][k + subframe_offset] += buffer_ch[samp_idx++] * ref_gain; samp_idx = samp_idx % reflections->circ_len; } } diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index 426a4ffa6c..bf6776ab04 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -182,7 +182,6 @@ const int16_t sba_map_tc_512[11] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15 }; - /*----------------------------------------------------------------------------------* * FASTCONV and PARAMETRIC binaural renderer ROM tables *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index dd4512bb03..b05efa9ba9 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -56,6 +56,7 @@ static void external_target_interpolation( EXTERNAL_ORIENTATION_HANDLE hExtOrien static bool are_orientations_same( const IVAS_QUATERNION *orientation1, const IVAS_QUATERNION *orientation2 ); + /*-----------------------------------------------------------------------* * ivas_headTrack_open() * @@ -334,7 +335,10 @@ void rotateFrame_shd( /* move Rmat to Rmat_prev */ for ( i = 0; i < 3; i++ ) { - mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], hCombinedOrientationData->Rmat_prev[0][i], 3 ); + mvr2r( + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], + hCombinedOrientationData->Rmat_prev[0][i], + 3 ); } return; @@ -457,7 +461,10 @@ void rotateFrame_sd( /* move Rmat to Rmat_prev */ for ( i = 0; i < 3; i++ ) { - mvr2r( hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], hCombinedOrientationData->Rmat_prev[0][i], 3 ); + mvr2r( + hCombinedOrientationData->Rmat[hCombinedOrientationData->subframe_idx][i], + hCombinedOrientationData->Rmat_prev[0][i], + 3 ); } /* copy to output */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 17cd06922b..08b409940b 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -439,7 +439,6 @@ static void accumulate2dArrayToBuffer( return; } - /*-------------------------------------------------------------------* * limitRendererOutput() * @@ -484,8 +483,8 @@ static int32_t limitRendererOutput( { ++numClipping; } - #endif + output[i] = min( max( INT16_MIN, output[i] ), INT16_MAX ); } @@ -493,7 +492,6 @@ static int32_t limitRendererOutput( } #endif - /*-------------------------------------------------------------------* * validateOutputAudioConfig() * @@ -842,7 +840,6 @@ static int16_t getNumLfeChannels( return 0; } - static ivas_error getNumNonLfeChannelsInSpeakerLayout( const AUDIO_CONFIG config, int16_t *numNonLfeChannels ) @@ -875,7 +872,6 @@ static ivas_error getNumNonLfeChannelsInSpeakerLayout( return IVAS_ERR_OK; } - static ivas_error getMcConfigValues( const AUDIO_CONFIG inConfig, const LSSETUP_CUSTOM_STRUCT *pInCustomLs, @@ -1112,7 +1108,6 @@ static ivas_error initHeadRotation( return IVAS_ERR_OK; } - static void closeHeadRotation( IVAS_REND_HANDLE hIvasRend ) { @@ -1752,7 +1747,6 @@ static bool configsAreEqual( return false; } } - for ( i = 0; i < customLsA.num_lfe; ++i ) { if ( customLsA.lfe_idx[i] != customLsB.lfe_idx[i] ) @@ -1948,7 +1942,6 @@ static ivas_error updateMcPanGainsForAmbiOut( { ++ch_out; } - ivas_dirac_dec_get_response( (int16_t) spkAzi[ch_in], (int16_t) spkEle[ch_in], inputMc->panGains[ch_out], outAmbiOrder ); } } @@ -2023,7 +2016,6 @@ static ivas_error updateMcPanGains( default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; } - /* Check error here to keep switch statement more compact */ if ( error != IVAS_ERR_OK ) { @@ -2522,7 +2514,7 @@ static ivas_error updateSbaPanGains( { if ( hRendCfg->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV ) { - assert( *rendCtx.pOutSampleRate == 48000 && "split binaural fastconv mode is currently supported with 48k sampling rate only" ); + assert( *rendCtx.pOutSampleRate == 48000 && "split binaural fast conv mode is currently supported with 48k sampling rate only" ); if ( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, &rendCtx.pSplitRendWrapper->multiBinPoseData, *rendCtx.pOutSampleRate ) ) != IVAS_ERR_OK ) { return error; @@ -2586,13 +2578,21 @@ static ivas_error updateSbaPanGains( return IVAS_ERR_OK; } + static ivas_error initSbaMasaRendering( input_sba *inputSba, const int32_t inSampleRate ) { + ivas_error error; + ivas_rend_closeCrend( &inputSba->crendWrapper, inputSba->base.ctx.pSplitRendWrapper != NULL ? inputSba->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ); - return ivas_dirac_ana_open( &inputSba->hDirAC, inSampleRate ); + if ( ( error = ivas_dirac_ana_open( &inputSba->hDirAC, inSampleRate ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; } @@ -2932,7 +2932,6 @@ ivas_error IVAS_REND_Open( hIvasRend->hHrtfs.hHrtfTD = NULL; hIvasRend->hHrtfs.hSetOfHRTF = NULL; hIvasRend->hHrtfs.hHrtfStatistics = NULL; - if ( asHrtfBinary ) { if ( ( error = ivas_HRTF_binary_open( &( hIvasRend->hHrtfs.hHrtfTD ) ) ) != IVAS_ERR_OK ) @@ -3031,7 +3030,6 @@ static ivas_error validateCustomLsLayout( * IVAS_REND_ConfigureCustomOutputLoudspeakerLayout() * * - * Note: this will reset custom LFE routings set for any MC input *-------------------------------------------------------------------*/ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( @@ -3387,7 +3385,6 @@ static int16_t getCldfbRendFlag( return isCldfbRend; } - /*------------------------------------------------------------------------- * Function ivas_pre_rend_init() * @@ -3583,7 +3580,13 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( if ( getAudioConfigType( hIvasRend->outputConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) { - if ( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, hIvasRend->hHrtfs.hHrtfStatistics, FALSE ) ) != IVAS_ERR_OK ) + if ( ( error = initMcBinauralRendering( inputMc, + inputMc->base.inConfig, + hIvasRend->outputConfig, + hIvasRend->hRendererConfig, + hIvasRend->hHrtfs.hSetOfHRTF, + hIvasRend->hHrtfs.hHrtfStatistics, + FALSE ) ) != IVAS_ERR_OK ) { return error; } @@ -4145,7 +4148,6 @@ ivas_error IVAS_REND_InitConfig( { return error; } - if ( ( error = ivas_render_config_init_from_rom( &hIvasRend->hRendererConfig ) ) != IVAS_ERR_OK ) { return error; @@ -4278,7 +4280,6 @@ ivas_error IVAS_REND_FeedRenderConfig( /* Skip inactive inputs */ continue; } - if ( pIsmInput->hReverb != NULL ) { if ( ( error = ivas_reverb_open( &pIsmInput->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, hRenderConfig, *pIsmInput->base.ctx.pOutSampleRate ) ) != IVAS_ERR_OK ) @@ -4309,7 +4310,6 @@ ivas_error IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend->hDiracDecBin[0] != NULL && pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb != NULL ) { ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb ); - if ( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, @@ -4327,7 +4327,6 @@ ivas_error IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend->hReverb != NULL ) { ivas_binaural_reverb_close( &pMasaInput->hMasaExtRend->hReverb ); - if ( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, @@ -4464,7 +4463,13 @@ ivas_error IVAS_REND_SetHeadRotation( { if ( hIvasRend->inputsMc[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { - if ( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, hIvasRend->hHrtfs.hHrtfStatistics, TRUE ) ) != IVAS_ERR_OK ) + if ( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], + hIvasRend->inputsMc[i].base.inConfig, + hIvasRend->outputConfig, + hIvasRend->hRendererConfig, + hIvasRend->hHrtfs.hSetOfHRTF, + hIvasRend->hHrtfs.hHrtfStatistics, + TRUE ) ) != IVAS_ERR_OK ) { return error; } @@ -4522,7 +4527,13 @@ ivas_error IVAS_REND_DisableHeadRotation( { if ( hIvasRend->inputsMc[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) { - if ( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, hIvasRend->hHrtfs.hHrtfStatistics, TRUE ) ) != IVAS_ERR_OK ) + if ( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], + hIvasRend->inputsMc[i].base.inConfig, + hIvasRend->outputConfig, + hIvasRend->hRendererConfig, + hIvasRend->hHrtfs.hSetOfHRTF, + hIvasRend->hHrtfs.hHrtfStatistics, + TRUE ) ) != IVAS_ERR_OK ) { return error; } @@ -4869,7 +4880,6 @@ static ivas_error chooseCrossfade( return IVAS_ERR_OK; } - static ivas_error rotateFrameMc( IVAS_REND_AudioBuffer inAudio, /* i : Input Audio buffer */ AUDIO_CONFIG inConfig, /* i : Input Audio config */ @@ -4930,6 +4940,7 @@ static ivas_error rotateFrameMc( } /* subframe loop */ + subframe_len = inAudio.config.numSamplesPerChannel / num_subframes; for ( subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++ ) { @@ -5029,6 +5040,7 @@ static ivas_error rotateFrameSba( const float *crossfade; int16_t num_subframes; int16_t subframe_idx, subframe_len; + float *writePtr; rotation_matrix Rmat; float tmpRot[2 * HEADROT_ORDER + 1]; @@ -5038,6 +5050,7 @@ static ivas_error rotateFrameSba( float val, cf, oneminuscf; push_wmops( "rotateFrameSba" ); + if ( ( error = chooseCrossfade( headRotData, &crossfade ) ) != IVAS_ERR_OK ) { return error; @@ -5122,6 +5135,7 @@ static ivas_error rotateFrameSba( } pop_wmops(); + return IVAS_ERR_OK; } @@ -5148,6 +5162,7 @@ static ivas_error renderIsmToBinaural( accumulate2dArrayToBuffer( tmpTDRendBuffer, &outAudio ); pop_wmops(); + return IVAS_ERR_OK; } @@ -5273,7 +5288,10 @@ static ivas_error renderIsmToBinauralRoom( /* compute gains only if position changed */ if ( position_changed ) { - if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper, rotatedPos.azimuth, rotatedPos.elevation, currentPanGains ) ) != IVAS_ERR_OK ) + if ( ( error = getEfapGains( *ismInput->base.ctx.pEfapOutWrapper, + rotatedPos.azimuth, + rotatedPos.elevation, + currentPanGains ) ) != IVAS_ERR_OK ) { return error; } @@ -5294,7 +5312,10 @@ static ivas_error renderIsmToBinauralRoom( } set_zero( tmpMcBuffer.data, tmpMcBuffer.config.numSamplesPerChannel * tmpMcBuffer.config.numChannels ); - renderBufferChannelLerp( ismInput->base.inputBuffer, 0, position_changed ? currentPanGains : ismInput->prev_pan_gains, position_changed ? ismInput->prev_pan_gains : NULL, tmpMcBuffer ); + renderBufferChannelLerp( ismInput->base.inputBuffer, 0, + position_changed ? currentPanGains : ismInput->prev_pan_gains, + position_changed ? ismInput->prev_pan_gains : NULL, + tmpMcBuffer ); copyBufferTo2dArray( tmpMcBuffer, tmpRendBuffer ); @@ -5319,7 +5340,6 @@ static ivas_error renderIsmToBinauralRoom( accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); free( tmpMcBuffer.data ); - pop_wmops(); return IVAS_ERR_OK; @@ -5335,6 +5355,7 @@ static ivas_error renderIsmToBinauralReverb( int16_t ism_md_subframe_update_ext; push_wmops( "renderIsmToBinauralRoom" ); + /* Metadata Delay to sync with audio delay converted from ms to 5ms (1000/50/4) subframe index */ ism_md_subframe_update_ext = (int16_t) roundf( ismInput->ism_metadata_delay_ms / ( 1000 / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES ) ); @@ -5362,8 +5383,8 @@ static ivas_error renderIsmToMc( ivas_error error; push_wmops( "renderIsmToMc" ); - position_changed = !ismInput->firstFrameRendered || checkObjectPositionChanged( &ismInput->currentPos, &ismInput->previousPos ); + position_changed = !ismInput->firstFrameRendered || checkObjectPositionChanged( &ismInput->currentPos, &ismInput->previousPos ); if ( *ismInput->base.ctx.pOutConfig == IVAS_AUDIO_CONFIG_STEREO ) { if ( ismInput->nonDiegeticPan ) @@ -5424,6 +5445,7 @@ static ivas_error renderIsmToMc( } pop_wmops(); + return IVAS_ERR_OK; } @@ -5440,6 +5462,7 @@ static ivas_error renderIsmToSba( ivas_error error; push_wmops( "renderIsmToSba" ); + if ( ( error = getAudioConfigNumChannels( outConfig, &numOutChannels ) ) != IVAS_ERR_OK ) { return error; @@ -5778,6 +5801,7 @@ static ivas_error renderLfeToBinaural( } pop_wmops(); + return IVAS_ERR_OK; } @@ -6293,6 +6317,7 @@ static ivas_error renderInputMc( IVAS_REND_AudioBuffer inAudio; error = IVAS_ERR_OK; + inAudio = mcInput->base.inputBuffer; if ( mcInput->base.numNewSamplesPerChannel != outAudio.config.numSamplesPerChannel ) @@ -6306,6 +6331,7 @@ static ivas_error renderInputMc( /* set combined orientation subframe info to start info */ ivas_combined_orientation_set_to_start_index( *( mcInput->base.ctx.pCombinedOrientationData ) ); + switch ( getAudioConfigType( outConfig ) ) { case IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED: @@ -6762,12 +6788,10 @@ static void renderSbaToMasa( IVAS_REND_AudioBuffer outAudio ) { float tmpRendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - push_wmops( "renderMcToMasa" ); + push_wmops( "renderMcToMasa" ); copyBufferTo2dArray( sbaInput->base.inputBuffer, tmpRendBuffer ); - ivas_dirac_ana( sbaInput->hDirAC, tmpRendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels ); - accumulate2dArrayToBuffer( tmpRendBuffer, &outAudio ); pop_wmops(); @@ -7595,7 +7619,8 @@ ivas_error IVAS_REND_GetSplitBinauralBitstream( hIvasRend->splitRendEncBuffer.config.numSamplesPerChannel *= cldfb_in_flag ? 2 : 1; - /* hIvasRend->splitRendEncBuffer used for BINAURAL_SPLIT_CODED output outAudio used for BINAURAL_SPLIT_PCM output */ + /* hIvasRend->splitRendEncBuffer used for BINAURAL_SPLIT_CODED output + outAudio used for BINAURAL_SPLIT_PCM output */ return getSamplesInternal( hIvasRend, outAudio, hBits ); } @@ -7829,8 +7854,8 @@ void IVAS_REND_cldfbSynthesis_wrapper( return; } -#ifdef DEBUGGING +#ifdef DEBUGGING /*-------------------------------------------------------------------* * IVAS_REND_GetNoCLipping() * @@ -7853,9 +7878,9 @@ int32_t IVAS_REND_GetCntFramesLimited( return hIvasRend->hLimiter->cnt_frames_limited; } - #endif + /*---------------------------------------------------------------------* * IVAS_REND_GetHrtfHandle( ) * @@ -7965,7 +7990,6 @@ ivas_error IVAS_REND_GetHrtfStatisticsHandle( return IVAS_ERR_OK; } - static ivas_error ivas_masa_ext_rend_dirac_rend_init( input_masa *inputMasa ) { @@ -8299,6 +8323,7 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( } } + hDirACRend->buffer_energy = NULL; for ( i = 0; i < DIRAC_NUM_DIMS; i++ ) @@ -8323,7 +8348,6 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( return IVAS_ERR_OK; } - static ivas_error ivas_masa_ext_rend_parambin_init( input_masa *inputMasa, /* i/o: MASA external renderer structure */ const RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration data handle */ @@ -8457,7 +8481,6 @@ static ivas_error ivas_masa_ext_rend_parambin_init( { /* Always open frequency domain decorrelator */ ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, nBins ); - if ( ( error = ivas_dirac_dec_decorr_open( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), &( hDiracDecBin->h_freq_domain_decorr_ap_state ), nBins, @@ -8483,7 +8506,6 @@ static ivas_error ivas_masa_ext_rend_parambin_init( return IVAS_ERR_OK; } - static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, @@ -8678,6 +8700,7 @@ static void freeMasaExtRenderer( } } + if ( hMasaExtRend->hReverb != NULL ) { ivas_binaural_reverb_close( &hMasaExtRend->hReverb ); diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index d9d5334a3e..e20b6ee31b 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -142,6 +142,7 @@ ivas_error IVAS_REND_AddInput( IVAS_REND_InputId *inputId /* o : ID of the new input */ ); +/* Note: this will reset any custom LFE routing set for the input */ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_REND_InputId inputId, /* i : ID of the input */ diff --git a/lib_util/audio_file_reader.c b/lib_util/audio_file_reader.c index fe5669fa56..1b52daaa77 100644 --- a/lib_util/audio_file_reader.c +++ b/lib_util/audio_file_reader.c @@ -33,7 +33,6 @@ #include "audio_file_reader.h" #include "tinywavein_c.h" - struct AudioFileReader { FILE *rawFile; diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c index a86b742f5a..270d4a84fe 100644 --- a/lib_util/ls_custom_file_reader.c +++ b/lib_util/ls_custom_file_reader.c @@ -51,7 +51,7 @@ struct LsCustomFileReader ivas_error CustomLsReader_open( const char *LsFilePath, /* i : LS custom layout file name */ - LsCustomFileReader **hLsCustomReader /* o : LsCustomFileReader handle */ + LsCustomFileReader **hLsCustomReader /* o : LsCustomFileReader handle */ ) { LsCustomFileReader *self; @@ -234,7 +234,7 @@ static void CustomLoudspeakerLayout_print_info( *-------------------------------------------------------------------------*/ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading( - LsCustomFileReader *hLsCustomReader, /* i/o: LsCustomFileReader handle */ + LsCustomFileReader *hLsCustomReader, /* i/o: LsCustomFileReader handle */ IVAS_CUSTOM_LS_DATA *hLsCustomData /* o : Custom loudspeaker setup data */ ) { diff --git a/lib_util/ls_custom_file_reader.h b/lib_util/ls_custom_file_reader.h index 403f8c18de..cb484ebe51 100644 --- a/lib_util/ls_custom_file_reader.h +++ b/lib_util/ls_custom_file_reader.h @@ -94,7 +94,7 @@ LS_CUSTOM_FILEREADER_ERROR CustomLsFileReading( * Retrun error message for custom loudspeaker setup error *-------------------------------------------------------------------------*/ -/*! r: custom LS error message */ +/*!r : custom LS error message */ const char *CustomLoudspeakerLayout_getError( LS_CUSTOM_FILEREADER_ERROR error /* i : custom LS error */ ); -- GitLab From 66a80f5740e28e58fa5f20461366f297f58b659d Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 10 May 2025 18:29:39 +0200 Subject: [PATCH 52/52] clang-format --- lib_dec/ivas_mct_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 561bce7605..a3b42f1930 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1269,7 +1269,7 @@ static ivas_error ivas_mc_dec_reconfig( int16_t tc_nchan_full_new; DECODER_TC_BUFFER_HANDLE hTcBuffer; - tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, RENDERER_DISABLE, st_ivas->hDecoderConfig->output_Fs ); hTcBuffer = st_ivas->hTcBuffer; tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); -- GitLab