From 08bf4f25dbeed035de4ce06d8ca2065b2493ff5d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 25 Jan 2024 09:53:46 +0530 Subject: [PATCH] Fixed point conversion of ism_dec and sub-funcs [x] Few funcs in ism_dec, mc_param_dec converted to fixed point. [x] BASOP updates in few files. --- Workspace_msvc/lib_dec.vcxproj | 2 + Workspace_msvc/lib_dec.vcxproj.filters | 4 + Workspace_msvc/lib_rend.vcxproj | 1 + Workspace_msvc/lib_rend.vcxproj.filters | 3 + lib_com/ivas_prot.h | 11 +- lib_com/ivas_prot_fx.h | 12 + lib_com/ivas_rom_com.c | 14 + lib_com/ivas_rom_com.h | 14 + lib_com/ivas_sba_config.c | 8 +- lib_com/ivas_tools.c | 18 ++ lib_com/prot.h | 8 + lib_dec/ivas_init_dec_fx.c | 210 +++++++++++++ lib_dec/ivas_ism_dec.c | 113 +++++++ lib_dec/ivas_ism_param_dec.c | 131 ++++++++ lib_dec/ivas_mc_param_dec_fx.c | 33 ++ lib_dec/ivas_output_config.c | 400 ++++++++++++++++++++++++ lib_dec/ivas_stat_dec.h | 6 + lib_rend/ivas_objectRenderer_hrFilt.c | 23 ++ lib_rend/ivas_objectRenderer_mix.c | 307 +++++++++++++++++- lib_rend/ivas_output_init.c | 185 +++++++++-- lib_rend/ivas_output_init_fx.c | 148 +++++++++ lib_rend/ivas_prot_rend.h | 14 + lib_rend/ivas_rom_TdBinauralRenderer.c | 14 + lib_rend/ivas_rom_TdBinauralRenderer.h | 8 + lib_rend/ivas_rom_rend.c | 142 +++++++++ lib_rend/ivas_rom_rend.h | 13 + lib_rend/ivas_stat_rend.h | 28 ++ 27 files changed, 1845 insertions(+), 25 deletions(-) create mode 100644 lib_dec/ivas_init_dec_fx.c create mode 100644 lib_dec/ivas_mc_param_dec_fx.c create mode 100644 lib_rend/ivas_output_init_fx.c diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index d8676806d..1c79d4b21 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -286,6 +286,7 @@ + @@ -303,6 +304,7 @@ + diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index ea00c940e..eb880863d 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -825,6 +825,10 @@ decoder_ivas_c + + decoder_ivas_c + + decoder_ivas_c diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index ee40123a8..fa11b23be 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -142,6 +142,7 @@ + diff --git a/Workspace_msvc/lib_rend.vcxproj.filters b/Workspace_msvc/lib_rend.vcxproj.filters index 170a82f88..01f3dfb74 100644 --- a/Workspace_msvc/lib_rend.vcxproj.filters +++ b/Workspace_msvc/lib_rend.vcxproj.filters @@ -119,6 +119,9 @@ rend_c + + rend_c + diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index def5e7935..a77946813 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1102,6 +1102,14 @@ void ivas_param_ism_config( ivas_error ivas_ism_enc_config( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_ism_dec_config( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ + UWord16 *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ + Word16 *data /* o : output synthesis signal */ +); +#else ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -1109,6 +1117,7 @@ ivas_error ivas_ism_dec_config( uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change*/ int16_t *data /* o : output synthesis signal */ ); +#endif // IVAS_FLOAT_FIXED ivas_error ivas_param_ism_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ @@ -4774,7 +4783,6 @@ void ivas_transient_det_close( ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */ ); -#ifndef IVAS_FLOAT_FIXED void ivas_transient_det_process( ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ float *pIn_pcm, /* i : input audio channels */ @@ -4790,7 +4798,6 @@ void ivas_td_decorr_get_ducking_gains( const int16_t frame_len, const int16_t tdet_flag ); -#endif #define IVAS_CMULT_FLOAT( in1_re, in1_im, in2_re, in2_im, out1_re, out1_im ) \ out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); MAC(1); MULT(1); \ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 2f1e3f98b..c15fbcde6 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -443,6 +443,18 @@ Word16 read_flag_EC_DFT( const UWord16 *bit_stream, /* i : bitstream */ Word16 *flag /* o : flag value */ ); +#ifdef IVAS_FLOAT_FIXED +/*file : ivas_mc_param_dec_fx.c*/ +Word16 param_mc_get_num_cldfb_syntheses_ivas_fx( + Decoder_Struct *st_ivas /* i : Parametric MC handle */ +); +#endif +/*file:ivas_init_dec_fx.c*/ +void ivas_init_dec_get_num_cldfb_instances_ivas_fx( + Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ + Word16 *numCldfbAnalyses, /* o : number of needed CLDFB analysis instances */ + Word16 *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */ +); #endif Word16 masa_sq_fx( diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 9ce55d69c..7fd4e9f80 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -2891,6 +2891,20 @@ const uint8_t masa_twodir_bands_joined[IVAS_NUM_ACTIVE_BRATES] = /*----------------------------------------------------------------------------------* * Multi-channel LS setups *----------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +const Word16 ls_azimuth_CICP2_fx[2] = { 30, -30 };/*Q-0*/ +const Word16 ls_elevation_CICP2_fx[2] = { 0, 0 };/*Q-0*/ +const Word16 ls_azimuth_CICP6_fx[5] = { 30, -30, 0, 110, -110 };/*Q-0*/ +const Word16 ls_elevation_CICP6_fx[5] = { 0, 0, 0, 0, 0 };/*Q-0*/ +const Word16 ls_azimuth_CICP12_fx[7] = { 30, -30, 0, 110, -110, 135, -135 };/*Q-0*/ +const Word16 ls_elevation_CICP12_fx[7] = { 0, 0, 0, 0, 0, 0, 0 };/*Q-0*/ +const Word16 ls_azimuth_CICP14_fx[7] = { 30, -30, 0, 110, -110, 30, -30 };/*Q-0*/ +const Word16 ls_elevation_CICP14_fx[7] = { 0, 0, 0, 0, 0, 35, 35 };/*Q-0*/ +const Word16 ls_azimuth_CICP16_fx[9] = { 30, -30, 0, 110, -110, 30, -30, 110, -110 };/*Q-0*/ +const Word16 ls_elevation_CICP16_fx[9] = { 0, 0, 0, 0, 0, 35, 35, 35, 35 };/*Q-0*/ +const Word16 ls_azimuth_CICP19_fx[11] = { 30, -30, 0, 135, -135, 90, -90, 30, -30, 135, -135 };/*Q-0*/ +const Word16 ls_elevation_CICP19_fx[11] = { 0, 0, 0, 0, 0, 0, 0, 35, 35, 35, 35 };/*Q-0*/ +#endif // IVAS_FLOAT_FIXED const float ls_azimuth_CICP2[2] = { 30.0f, -30.0f }; const float ls_elevation_CICP2[2] = { 0.0f, 0.0f }; diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index e2f1b564e..e1f312ca8 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -313,6 +313,20 @@ extern const float diffuseness_reconstructions_hr[HR_MASA_ER_LEVELS]; extern const float diffuseness_thresholds_hr[HR_MASA_ER_LEVELS + 1]; extern const Word64 diffuseness_reconstructions_hr_fx[HR_MASA_ER_LEVELS]; extern const Word32 diffuseness_thresholds_hr_fx[HR_MASA_ER_LEVELS + 1]; +#ifdef IVAS_FLOAT_FIXED +extern const Word16 ls_azimuth_CICP2_fx[2]; +extern const Word16 ls_elevation_CICP2_fx[2]; +extern const Word16 ls_azimuth_CICP6_fx[5]; +extern const Word16 ls_elevation_CICP6_fx[5]; +extern const Word16 ls_azimuth_CICP12_fx[7]; +extern const Word16 ls_elevation_CICP12_fx[7]; +extern const Word16 ls_azimuth_CICP14_fx[7]; +extern const Word16 ls_elevation_CICP14_fx[7]; +extern const Word16 ls_azimuth_CICP16_fx[9]; +extern const Word16 ls_elevation_CICP16_fx[9]; +extern const Word16 ls_azimuth_CICP19_fx[11]; +extern const Word16 ls_elevation_CICP19_fx[11]; +#endif // IVAS_FLOAT_FIXED /* Multi-channel input and output setups */ extern const float ls_azimuth_CICP2[2]; diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 4f9ca5484..33f009c5a 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -322,21 +322,21 @@ Word16 ivas_sba_get_nchan_metadata( { Word16 nb_channels; - IF ( sba_order == SBA_FOA_ORDER ) + IF ( EQ_16(sba_order , SBA_FOA_ORDER) ) { nb_channels = FOA_CHANNELS; } ELSE { - IF ( ivas_total_brate >= IVAS_512k ) + IF ( GE_32(ivas_total_brate , IVAS_512k) ) { nb_channels = IVAS_SPAR_MAX_CH; - nb_channels = min( nb_channels, ( sba_order + 1 ) * ( sba_order + 1 ) ); + nb_channels = s_min( nb_channels, imult1616(add( sba_order , 1 ) , add( sba_order , 1 )) ); } ELSE { /* FOA + planar HOA */ - nb_channels = FOA_CHANNELS + 2 * ( sba_order - 1 ); + nb_channels = add(FOA_CHANNELS , shl( sub( sba_order , 1 ),1)); } } diff --git a/lib_com/ivas_tools.c b/lib_com/ivas_tools.c index 29b612680..170a7dc7b 100644 --- a/lib_com/ivas_tools.c +++ b/lib_com/ivas_tools.c @@ -370,6 +370,24 @@ void v_sqrt( * Subtraction of two vectors *-------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void v_sub_s16_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ +) +{ + Word16 i; + + FOR( i = 0; LT_16( i, N ); i++ ) + { + y[i] = sub( x1[i], x2[i] ); + } + + return; +} +#endif // IVAS_FLOAT_FIXED void v_sub_s( const int16_t x1[], /* i : Input vector 1 */ const int16_t x2[], /* i : Input vector 2 */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 4e1a189b6..a22d96bf5 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -337,6 +337,14 @@ void v_sub_s( int16_t y[], /* o : Output vector that contains vector 1 - vector 2 */ const int16_t N /* i : Vector length */ ); +#ifdef IVAS_FLOAT_FIXED +void v_sub_s16_fx( + const Word16 x1[], /* i : Input vector 1 */ + const Word16 x2[], /* i : Input vector 2 */ + Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */ + const Word16 N /* i : Vector length */ +); +#endif // IVAS_FLOAT_FIXED /*! r: index of the winning codeword */ int16_t squant( diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c new file mode 100644 index 000000000..389d4212e --- /dev/null +++ b/lib_dec/ivas_init_dec_fx.c @@ -0,0 +1,210 @@ +#include "ivas_prot_fx.h" +#ifdef IVAS_FLOAT_FIXED +void ivas_init_dec_get_num_cldfb_instances_ivas_fx( + Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ + Word16 *numCldfbAnalyses, /* o : number of needed CLDFB analysis instances */ + Word16 *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */ +) +{ + IVAS_FORMAT ivas_format; + *numCldfbAnalyses = st_ivas->nchan_transport; + *numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out; + + ivas_format = st_ivas->ivas_format; + IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MODE_NONE ) ) + { + ivas_format = SBA_FORMAT; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ + } + + SWITCH( st_ivas->renderer_type ) + { + case RENDERER_BINAURAL_PARAMETRIC: + case RENDERER_BINAURAL_PARAMETRIC_ROOM: + case RENDERER_STEREO_PARAMETRIC: + IF( EQ_16( st_ivas->nchan_transport, 1 ) ) + { + *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 ); + } + + IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->hOutSetup.separateChannelEnabled ) + { + *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 ); + } + + IF( EQ_16( ivas_format, SBA_ISM_FORMAT ) ) + { + IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + { + *numCldfbAnalyses = add( *numCldfbAnalyses, st_ivas->nchan_ism ); + } + } + + IF( EQ_16( ivas_format, MASA_ISM_FORMAT ) ) + { + IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + { + *numCldfbAnalyses = add( *numCldfbAnalyses, st_ivas->nchan_ism ); + } + ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + { + *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 ); + } + } + IF( st_ivas->hDiracDecBin->useTdDecorr ) + { + *numCldfbAnalyses = add( *numCldfbAnalyses, 2 ); + } + BREAK; + case RENDERER_NON_DIEGETIC_DOWNMIX: + case RENDERER_MONO_DOWNMIX: + IF( EQ_16( ivas_format, ISM_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) + { + /* CLDFB not used in rendering */ + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + } + BREAK; + case RENDERER_DIRAC: + IF( EQ_16( ivas_format, SBA_FORMAT ) ) + { + *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; + + IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) ) + { + *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE; + } + ELSE IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans; + } + ELSE + { + *numCldfbSyntheses = MAX_OUTPUT_CHANNELS; + } + } + IF( NE_16( ivas_format, SBA_FORMAT ) ) + { + IF( GT_16( st_ivas->nchan_transport, 2 ) && NE_16( st_ivas->sba_planar, 0 ) ) + { + *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 ); + } + ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( st_ivas->hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) + { + *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 ); + } + } + BREAK; + case RENDERER_MC_PARAMMC: + IF( LE_16( st_ivas->hDecoderConfig->nchan_out, 2 ) ) + { + /* CLDFB not used in rendering */ + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + } + ELSE + { + *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_ivas_fx( st_ivas ); + } + BREAK; + case RENDERER_PARAM_ISM: + /* Already correct with no exception */ + BREAK; + case RENDERER_DISABLE: + /* CLDFB not used */ + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + BREAK; + case RENDERER_MC: + case RENDERER_SBA_LINEAR_DEC: + case RENDERER_TD_PANNING: + case RENDERER_BINAURAL_OBJECTS_TD: + case RENDERER_MCMASA_MONO_STEREO: + case RENDERER_BINAURAL_MIXER_CONV: + case RENDERER_BINAURAL_MIXER_CONV_ROOM: + case RENDERER_BINAURAL_FASTCONV: + case RENDERER_BINAURAL_FASTCONV_ROOM: + case RENDERER_OSBA_STEREO: + case RENDERER_OSBA_AMBI: + case RENDERER_OSBA_LS: + IF( EQ_16( ivas_format, SBA_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) + { + IF( NE_16( st_ivas->sba_dirac_stereo_flag, 0 ) ) + { + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + } + ELSE + { + *numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans; + + IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) ) + { + *numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE; + } + ELSE IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + *numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans; + } + ELSE + { + *numCldfbSyntheses = MAX_OUTPUT_CHANNELS; + } + + IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + *numCldfbAnalyses = add( st_ivas->nchan_ism, st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans ); + } + } + } + ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) + { + /* do nothing for ParamMC */ + } + ELSE + { + /* CLDFB not used in rendering */ + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + } + BREAK; + case RENDERER_SBA_LINEAR_ENC: + IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) + { + *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_ivas_fx( st_ivas ); + } + ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) + { + *numCldfbSyntheses = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); + } + ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) + { + *numCldfbAnalyses = st_ivas->nchan_transport; + *numCldfbSyntheses = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); + } + ELSE + { + /* CLDFB not used in rendering */ + *numCldfbAnalyses = 0; + *numCldfbSyntheses = 0; + } + BREAK; + default: + assert( 0 && "Renderer not handled for CLDFB reservation." ); + } + + IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) + { + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) + { + *numCldfbAnalyses = s_max( MC_PARAMUPMIX_MAX_INPUT_CHANS, *numCldfbAnalyses ); + } + ELSE + { + *numCldfbAnalyses = s_max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbAnalyses ); + } + *numCldfbSyntheses = s_max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbSyntheses ); + } + + return; +} +#endif // IVAS_FLOAT_FIXED \ No newline at end of file diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index d784324e9..da6b5a07f 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -36,6 +36,9 @@ #include "ivas_prot.h" #include "ivas_prot_rend.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif // IVAS_FLOAT_FIXED /*-------------------------------------------------------------------------* * ivas_ism_bitrate_switching_dec() @@ -71,9 +74,17 @@ static ivas_error ivas_ism_bitrate_switching_dec( /* temporarily set the ism mode back to the old one, otherwise this can give wrong results*/ ism_mode = st_ivas->ism_mode; st_ivas->ism_mode = last_ism_mode; +#ifdef IVAS_FLOAT_FIXED + ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); +#else ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); +#endif // IVAS_FLOAT_FIXED st_ivas->ism_mode = ism_mode; +#ifdef IVAS_FLOAT_FIXED + nchan_out_buff_old = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 ); +#else nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); +#endif // IVAS_FLOAT_FIXED if ( ( error = ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ) != IVAS_ERR_OK ) { @@ -353,6 +364,106 @@ static ivas_error ivas_ism_bitrate_switching_dec( * - reconfigure the ISM format decoder *-------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_ism_dec_config( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ + UWord16 *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ + Word16 *data /* o : output synthesis signal */ +) +{ + Word32 ivas_total_brate; + ivas_error error; + Word16 nchan_transport_old; + + error = IVAS_ERR_OK; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + + /* Assumes that num of input objects are constant */ + nchan_transport_old = st_ivas->nchan_ism; + + IF( EQ_16( last_ism_mode, ISM_MODE_PARAM ) ) + { + nchan_transport_old = MAX_PARAM_ISM_WAVE; + } + + IF( !st_ivas->bfi && NE_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, FRAME_NO_DATA ) ) + { + /* select ISM format mode */ + st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->nchan_ism, ivas_total_brate ); + + st_ivas->nchan_transport = st_ivas->nchan_ism; + IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) + { + st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + st_ivas->hDecoderConfig->nchan_out = st_ivas->nchan_ism; + } + } + + IF( NE_16( st_ivas->ini_active_frame, 0 ) ) + { + /* ISM bit-rate switching */ + { + IF( ( NE_16( st_ivas->ism_mode, last_ism_mode ) ) || ( NE_32( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) ) + { + IF( NE_16( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, + data ) ), + IVAS_ERR_OK ) ) + { + return error; + } + } + } + } + } + ELSE IF( !st_ivas->bfi && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) + { + st_ivas->nchan_transport = st_ivas->nchan_ism; + IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) + { + st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE; + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + st_ivas->hDecoderConfig->nchan_out = st_ivas->nchan_ism; + } + } + + /* ISM mode switching */ + IF( NE_16( st_ivas->ism_mode, last_ism_mode ) ) + { + IF( NE_16( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, + data ) ), + IVAS_ERR_OK ) ) + { + return error; + } + } + } + + SWITCH( st_ivas->nchan_ism ) + { + case 1: + st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM1; + BREAK; + case 2: + st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM2; + BREAK; + case 3: + st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM3; + BREAK; + case 4: + st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM4; + BREAK; + default: + st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID; + BREAK; + } + + return error; +} +#else ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const ISM_MODE last_ism_mode, /* i/o: last ISM mode */ @@ -449,3 +560,5 @@ ivas_error ivas_ism_dec_config( return error; } + +#endif \ No newline at end of file diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 8e11418b1..112d32ce6 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -382,11 +382,23 @@ static ivas_error ivas_param_ism_rendering_init( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for proto matrix\n" ) ); } +#ifdef IVAS_FLOAT_FIXED + IF( ( hParamIsmRendering->proto_matrix_fx = (Word16 *) malloc( hOutSetup.nchan_out_woLFE * nchan_transport * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for proto matrix\n" ) ); + } +#endif // IVAS_FLOAT_FIXED if ( ( hParamIsmRendering->interpolator = (float *) malloc( subframe_nbslots * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) ); } +#ifdef IVAS_FLOAT_FIXED + IF( ( hParamIsmRendering->interpolator_fx = (Word16 *) malloc( subframe_nbslots * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) ); + } +#endif // IVAS_FLOAT_FIXED if ( !( output_config == IVAS_AUDIO_CONFIG_EXTERNAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { /* computation of proto matrix */ @@ -599,6 +611,10 @@ ivas_error ivas_param_ism_dec_open( nchan_full = nchan_transport; hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc = NULL; hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc = NULL; +#ifdef IVAS_FLOAT_FIXED + hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx = NULL; + hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx = NULL; +#endif // IVAS_FLOAT_FIXED } else { @@ -623,6 +639,19 @@ ivas_error ivas_param_ism_dec_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) ); } set_zero( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc, n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands ); +#ifdef IVAS_FLOAT_FIXED + IF( ( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx = (Word16 *) malloc( n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) ); + } + set16_fx( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx, 0, n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands ); + + IF( ( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx = (Word16 *) malloc( n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) ); + } + set16_fx( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx, 0, n_slots_to_alloc * nchan_transport * hSpatParamRendCom->num_freq_bands ); +#endif // IVAS_FLOAT_FIXED } if ( st_ivas->hTcBuffer == NULL ) @@ -637,6 +666,10 @@ ivas_error ivas_param_ism_dec_open( { hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc = NULL; hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc = NULL; +#ifdef IVAS_FLOAT_FIXED + hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx = NULL; + hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx = NULL; +#endif // IVAS_FLOAT_FIXED if ( st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate = st_ivas->hDecoderConfig->nchan_out; @@ -658,6 +691,103 @@ ivas_error ivas_param_ism_dec_open( * Close Param ISM handle *-------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_param_ism_dec_close( + PARAM_ISM_DEC_HANDLE *hParamIsmDec_out, /* i/o: decoder DirAC handle */ + SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data */ + AUDIO_CONFIG output_config /* i : output audio configuration */ +) +{ + IF( hParamIsmDec_out != NULL && *hParamIsmDec_out != NULL ) + { + PARAM_ISM_DEC_HANDLE hParamIsmDec; + hParamIsmDec = *hParamIsmDec_out; + + /* Config & CLDFB */ + IF( hParamIsmDec->hParamIsm != NULL ) + { + free( hParamIsmDec->hParamIsm ); + hParamIsmDec->hParamIsm = NULL; + } + + IF( !( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) + { + /* Param ISM Rendering */ + // To be removed later: Freeing memory allocated to float pointers + IF( hParamIsmDec->hParamIsmRendering->interpolator != NULL ) + { + free( hParamIsmDec->hParamIsmRendering->interpolator ); + hParamIsmDec->hParamIsmRendering->interpolator = NULL; + } + IF( hParamIsmDec->hParamIsmRendering->proto_matrix != NULL ) + { + free( hParamIsmDec->hParamIsmRendering->proto_matrix ); + hParamIsmDec->hParamIsmRendering->proto_matrix = NULL; + } + //------------------------------------------------------------ + IF( hParamIsmDec->hParamIsmRendering->interpolator_fx != NULL ) + { + free( hParamIsmDec->hParamIsmRendering->interpolator_fx ); + hParamIsmDec->hParamIsmRendering->interpolator_fx = NULL; + } + IF( hParamIsmDec->hParamIsmRendering->proto_matrix_fx != NULL ) + { + free( hParamIsmDec->hParamIsmRendering->proto_matrix_fx ); + hParamIsmDec->hParamIsmRendering->proto_matrix_fx = NULL; + } + } + // To be removed later: Freeing memory allocated to float pointers + IF( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc != NULL ) + { + free( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc ); + hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc = NULL; + } + IF( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc != NULL ) + { + free( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc ); + hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc = NULL; + } + //----------------------------------------------------------------- + IF( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx != NULL ) + { + free( hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx ); + hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx = NULL; + } + IF( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx != NULL ) + { + free( hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx ); + hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx = NULL; + } + IF( hParamIsmDec->hParamIsmRendering != NULL ) + { + free( hParamIsmDec->hParamIsmRendering ); + hParamIsmDec->hParamIsmRendering = NULL; + } + + free( *hParamIsmDec_out ); + *hParamIsmDec_out = NULL; + } + + IF( hSpatParamRendCom_out != NULL && *hSpatParamRendCom_out != NULL ) + { + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { +#ifdef IVAS_FLOAT_FIXED + ivas_dirac_deallocate_parameters_fx( *hSpatParamRendCom_out, 1 ); + ivas_dirac_deallocate_parameters_fx( *hSpatParamRendCom_out, 2 ); +#else + ivas_dirac_deallocate_parameters( *hSpatParamRendCom_out, 1 ); + ivas_dirac_deallocate_parameters( *hSpatParamRendCom_out, 2 ); +#endif + } + + free( *hSpatParamRendCom_out ); + *hSpatParamRendCom_out = NULL; + } + + return; +} +#else // IVAS_FLOAT_FIXED void ivas_param_ism_dec_close( PARAM_ISM_DEC_HANDLE *hParamIsmDec_out, /* i/o: decoder DirAC handle */ SPAT_PARAM_REND_COMMON_DATA_HANDLE *hSpatParamRendCom_out, /* i/o: common spatial renderer data */ @@ -732,6 +862,7 @@ void ivas_param_ism_dec_close( return; } +#endif /*-------------------------------------------------------------------------* * ivas_param_ism_dec() diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c new file mode 100644 index 000000000..18c338bb7 --- /dev/null +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -0,0 +1,33 @@ +#include "ivas_prot_fx.h" + +#ifdef IVAS_FLOAT_FIXED +Word16 param_mc_get_num_cldfb_syntheses_ivas_fx( + Decoder_Struct *st_ivas /* i : Parametric MC handle */ +) +{ + Word16 num_cldfb_syntheses; + + num_cldfb_syntheses = 0; + + /* sanity check*/ + IF( st_ivas->hParamMC == NULL ) + { + assert( 0 && "ParamMC handle does not exist!\n" ); + } + + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + num_cldfb_syntheses = 2; + } + ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + { + num_cldfb_syntheses = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); + } + ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) ) + { + num_cldfb_syntheses = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); + } + + return num_cldfb_syntheses; +} +#endif // IVAS_FLOAT_FIXED \ No newline at end of file diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 94bf27274..906795ced 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -43,6 +43,405 @@ * * Select and configure IVAS renderer parameters *-------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_renderer_select( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + RENDERER_TYPE *renderer_type; + AUDIO_CONFIG *internal_config; + AUDIO_CONFIG output_config; + AUDIO_CONFIG transport_config; + + Word16 nchan_internal; + + renderer_type = &( st_ivas->renderer_type ); + internal_config = &( st_ivas->intern_config ); + output_config = st_ivas->hDecoderConfig->output_config; + transport_config = st_ivas->transport_config; + + /* disabled rendering by default */ + *renderer_type = RENDERER_DISABLE; + + /*-----------------------------------------------------------------* + * Binaural rendering configurations + *-----------------------------------------------------------------*/ + + IF ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) + { + st_ivas->hCombinedOrientationData->shd_rot_max_order = -1; + } + + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) || EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR) || EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) + { + IF ( EQ_16(st_ivas->ivas_format , ISM_FORMAT) ) + { + IF ( EQ_16(st_ivas->ism_mode , ISM_MODE_PARAM) ) + { + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) ) + { + *renderer_type = RENDERER_BINAURAL_PARAMETRIC; + } + ELSE + { + *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; + } + } + ELSE /* ISM_MODE_DISC */ + { + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) || EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) + { + *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; + *internal_config = output_config; + } + ELSE + { + *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM; + *internal_config = IVAS_AUDIO_CONFIG_7_1_4; + } + } + } + ELSE IF ( EQ_16(st_ivas->ivas_format , MASA_FORMAT) || EQ_16(st_ivas->ivas_format , MASA_ISM_FORMAT) || ( ( EQ_16(st_ivas->ivas_format , SBA_FORMAT) || EQ_16(st_ivas->ivas_format , SBA_ISM_FORMAT) ) && LE_16(st_ivas->nchan_transport , 2) ) ) + { + *internal_config = output_config; + + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) ) + { + *renderer_type = RENDERER_BINAURAL_PARAMETRIC; + } + ELSE + { + *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; + } + } + ELSE IF ( EQ_16(st_ivas->ivas_format , SBA_FORMAT) || EQ_16(st_ivas->ivas_format , SBA_ISM_FORMAT) ) + { + *internal_config = IVAS_AUDIO_CONFIG_HOA3; + + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) || EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) + { + *renderer_type = RENDERER_BINAURAL_FASTCONV; + } + ELSE + { + *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; + } + + IF ( EQ_16(st_ivas->ivas_format , SBA_ISM_FORMAT) && EQ_16(*renderer_type , RENDERER_BINAURAL_FASTCONV_ROOM) ) + { + *internal_config = IVAS_AUDIO_CONFIG_7_1_4; + } + + 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 ( EQ_16(nchan_internal , 2) ) + { + st_ivas->hCombinedOrientationData->shd_rot_max_order = 1; + } + ELSE IF ( EQ_16(nchan_internal , 4) || EQ_16(nchan_internal , 3) ) + { + st_ivas->hCombinedOrientationData->shd_rot_max_order = 0; + } + ELSE IF ( EQ_16(nchan_internal , 6) || EQ_16(nchan_internal , 5) ) + { + st_ivas->hCombinedOrientationData->shd_rot_max_order = 2; + } + ELSE IF ( EQ_16(nchan_internal , 8) || EQ_16(nchan_internal , 7) ) + { + st_ivas->hCombinedOrientationData->shd_rot_max_order = 3; + } + } + } + ELSE IF ( EQ_16(st_ivas->ivas_format , MC_FORMAT) ) + { + IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCMASA) ) + { + *internal_config = output_config; + + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) ) + { + *renderer_type = RENDERER_BINAURAL_PARAMETRIC; + } + ELSE + { + *renderer_type = RENDERER_BINAURAL_PARAMETRIC_ROOM; + } + } + ELSE + { + *internal_config = transport_config; + + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) || EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) + { + IF ( ( EQ_16(st_ivas->transport_config , IVAS_AUDIO_CONFIG_5_1) || EQ_16(st_ivas->transport_config , IVAS_AUDIO_CONFIG_7_1) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && ( EQ_16(st_ivas->mc_mode , MC_MODE_MCT) || EQ_16(st_ivas->mc_mode , MC_MODE_PARAMUPMIX) ) ) + { + *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; + } + ELSE + { + IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCT) ) + { + *renderer_type = RENDERER_BINAURAL_MIXER_CONV; + } + ELSE + { + *renderer_type = RENDERER_BINAURAL_FASTCONV; + } + +#if 0 // def DEBUGGING /*temp disabling this as paramMC crashes with CREND*/ + IF( EQ_16( st_ivas->hRenderConfig->renderer_type_override, IVAS_RENDER_TYPE_OVERRIDE_CREND ) ) + { + *renderer_type = RENDERER_BINAURAL_MIXER_CONV; + } + ELSE IF( EQ_16( st_ivas->hRenderConfig->renderer_type_override, IVAS_RENDER_TYPE_OVERRIDE_FASTCONV ) ) + { + *renderer_type = RENDERER_BINAURAL_FASTCONV; + } +#endif + IF ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) + { + /* force HOA3 domain for rotation*/ + *internal_config = IVAS_AUDIO_CONFIG_HOA3; + } + } + } + ELSE + { + IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCT) ) + { + *renderer_type = RENDERER_BINAURAL_MIXER_CONV_ROOM; + } + ELSE + { + *renderer_type = RENDERER_BINAURAL_FASTCONV_ROOM; + } + } + } + } + } + + /*-----------------------------------------------------------------* + * Non-binaural rendering configurations + *-----------------------------------------------------------------*/ + + ELSE IF ( EQ_16(st_ivas->ivas_format , MONO_FORMAT) ) + { + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + { + *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; + } + } + ELSE IF ( EQ_16(st_ivas->ivas_format , STEREO_FORMAT) ) + { + IF ( NE_16(output_config , IVAS_AUDIO_CONFIG_STEREO) && NE_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) + { + *renderer_type = RENDERER_MC; + } + } + ELSE IF ( EQ_16(st_ivas->ivas_format , ISM_FORMAT) ) + { + IF ( ( EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) && ( st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) ) + { + *renderer_type = RENDERER_NON_DIEGETIC_DOWNMIX; + } + ELSE + { + IF ( EQ_16(st_ivas->ism_mode , ISM_MODE_PARAM) ) + { + *renderer_type = RENDERER_PARAM_ISM; + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) + { + *renderer_type = RENDERER_MONO_DOWNMIX; + } + ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + { + *renderer_type = RENDERER_DISABLE; + } + ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_FOA) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + *internal_config = IVAS_AUDIO_CONFIG_7_1_4; + } + } + ELSE /* ISM_MODE_DISC */ + { + *renderer_type = RENDERER_TD_PANNING; + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) + { + *renderer_type = RENDERER_MONO_DOWNMIX; + } + ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_FOA) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + } + ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_EXTERNAL) ) + { + *renderer_type = RENDERER_DISABLE; + } + } + } + } + ELSE IF ( EQ_16(st_ivas->ivas_format , MASA_FORMAT) || EQ_16(st_ivas->ivas_format , SBA_FORMAT) || EQ_16(st_ivas->ivas_format , SBA_ISM_FORMAT) ) + { + IVAS_FORMAT ivas_format; + *renderer_type = RENDERER_DIRAC; + ivas_format = ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_NONE ) ? SBA_FORMAT : st_ivas->ivas_format; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */ + + IF ( EQ_16(ivas_format , SBA_FORMAT) && ( NE_16(output_config , IVAS_AUDIO_CONFIG_5_1) && NE_16(output_config , IVAS_AUDIO_CONFIG_5_1_2) && NE_16(output_config , IVAS_AUDIO_CONFIG_5_1_4) && NE_16(output_config , IVAS_AUDIO_CONFIG_7_1) && NE_16(output_config , IVAS_AUDIO_CONFIG_7_1_4) && NE_16(output_config , IVAS_AUDIO_CONFIG_LS_CUSTOM) && NE_16(output_config , IVAS_AUDIO_CONFIG_MONO) && NE_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) ) + { + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_FOA) ) + { + *internal_config = output_config; + } + ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) || EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + { + *internal_config = IVAS_AUDIO_CONFIG_FOA; + } + ELSE + { + *internal_config = IVAS_AUDIO_CONFIG_HOA3; + } + st_ivas->renderer_type = RENDERER_SBA_LINEAR_DEC; + } + ELSE IF ( ( EQ_16(ivas_format , MASA_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) && EQ_16(st_ivas->nchan_transport , 1) ) || + ( EQ_16(ivas_format , SBA_FORMAT) && ( EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) || EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) ) ) + { + *renderer_type = RENDERER_DISABLE; + } + ELSE IF ( ( EQ_16(ivas_format , MASA_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) && LT_32(st_ivas->hDecoderConfig->ivas_total_brate , MASA_STEREO_MIN_BITRATE) && GT_32(st_ivas->hDecoderConfig->ivas_total_brate , IVAS_SID_5k2) ) ) + { + *renderer_type = RENDERER_DISABLE; + } + ELSE IF ( EQ_16(ivas_format , MASA_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + { + *renderer_type = RENDERER_STEREO_PARAMETRIC; + } + ELSE IF ( EQ_16(ivas_format , MASA_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_EXTERNAL) ) + { + *renderer_type = RENDERER_DISABLE; + } + ELSE IF ( EQ_16(ivas_format , SBA_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) + { + *renderer_type = RENDERER_SBA_LINEAR_DEC; + } + ELSE IF ( EQ_16(ivas_format , SBA_ISM_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + { + *renderer_type = RENDERER_OSBA_STEREO; + } + ELSE IF ( EQ_16(ivas_format , SBA_ISM_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) + { + *renderer_type = RENDERER_MONO_DOWNMIX; + } + ELSE IF ( EQ_16(ivas_format , SBA_ISM_FORMAT) && ( EQ_16(output_config , IVAS_AUDIO_CONFIG_FOA) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) ) + { + *renderer_type = RENDERER_OSBA_AMBI; + } + ELSE IF ( EQ_16(ivas_format , SBA_ISM_FORMAT) && ( EQ_16(output_config , IVAS_AUDIO_CONFIG_5_1) || EQ_16(output_config , IVAS_AUDIO_CONFIG_5_1_2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_5_1_4) || EQ_16(output_config , IVAS_AUDIO_CONFIG_7_1) || EQ_16(output_config , IVAS_AUDIO_CONFIG_7_1_4) || EQ_16(output_config , IVAS_AUDIO_CONFIG_LS_CUSTOM) ) ) + { + *renderer_type = RENDERER_OSBA_LS; + } + ELSE IF ( EQ_16(ivas_format , SBA_ISM_FORMAT) && EQ_16(output_config , IVAS_AUDIO_CONFIG_EXTERNAL) ) + { + *renderer_type = RENDERER_SBA_LINEAR_DEC; + } + } + ELSE IF ( EQ_16(st_ivas->ivas_format , MASA_ISM_FORMAT) ) + { + *renderer_type = RENDERER_DIRAC; + + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) ) + { + *renderer_type = RENDERER_MONO_DOWNMIX; + } + ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + { + *renderer_type = RENDERER_STEREO_PARAMETRIC; + } + ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_EXTERNAL) ) + { + *renderer_type = RENDERER_DISABLE; + } + } + ELSE IF ( EQ_16(st_ivas->ivas_format , MC_FORMAT) ) + { + *internal_config = transport_config; + IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCT) && NE_16(*internal_config , output_config) ) + { + IF ( NE_16(output_config , IVAS_AUDIO_CONFIG_FOA) && NE_16(output_config , IVAS_AUDIO_CONFIG_HOA2) && NE_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) + { + *renderer_type = RENDERER_MC; + } + ELSE + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + } + } + ELSE IF ( EQ_16(st_ivas->mc_mode , MC_MODE_PARAMUPMIX) ) + { + *internal_config = transport_config; + IF ( NE_16(*internal_config , output_config) ) + { + IF ( NE_16(output_config , IVAS_AUDIO_CONFIG_FOA) && NE_16(output_config , IVAS_AUDIO_CONFIG_HOA2) && NE_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) + { + *renderer_type = RENDERER_MC; + } + ELSE + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + } + } + } + ELSE IF ( EQ_16(st_ivas->mc_mode , MC_MODE_PARAMMC) ) + { + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_FOA) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + } + ELSE + { + *renderer_type = RENDERER_MC_PARAMMC; + } + } + ELSE IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCMASA) ) + { + *internal_config = output_config; + + /* No rendering for 1TC to Mono or Stereo and 2TC to Stereo */ + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) || EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + { + IF ( EQ_16(st_ivas->nchan_transport , 1) ) + { + *renderer_type = RENDERER_DISABLE; + } + ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) && EQ_16(st_ivas->nchan_transport , 2) && !st_ivas->hOutSetup.separateChannelEnabled ) + { + *renderer_type = RENDERER_DISABLE; + } + ELSE + { + *renderer_type = RENDERER_MCMASA_MONO_STEREO; + } + } + ELSE + { + *renderer_type = RENDERER_DIRAC; + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_FOA) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_HOA3) ) + { + *renderer_type = RENDERER_SBA_LINEAR_ENC; + *internal_config = transport_config; + } + ELSE IF ( EQ_16(transport_config , IVAS_AUDIO_CONFIG_5_1) && ( EQ_16(output_config , IVAS_AUDIO_CONFIG_7_1) || EQ_16(output_config , IVAS_AUDIO_CONFIG_5_1_4) ) ) + { + *internal_config = transport_config; + } + } + } + } + return; +} +#else // IVAS_FLOAT_FIXED void ivas_renderer_select( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ @@ -445,3 +844,4 @@ void ivas_renderer_select( return; } +#endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 85fd592f6..692603a1a 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -445,6 +445,12 @@ typedef struct typedef struct param_ism_rendering { +#ifdef IVAS_FLOAT_FIXED + Word16 *proto_matrix_fx; + Word16 *interpolator_fx; + Word16 *Cldfb_RealBuffer_tc_fx; + Word16 *Cldfb_ImagBuffer_tc_fx; +#endif // IVAS_FLOAT_FIXED float *proto_matrix; float *interpolator; float mixing_matrix_lin_old[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX]; diff --git a/lib_rend/ivas_objectRenderer_hrFilt.c b/lib_rend/ivas_objectRenderer_hrFilt.c index ef7966f6b..fbb2ad253 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt.c +++ b/lib_rend/ivas_objectRenderer_hrFilt.c @@ -40,6 +40,7 @@ #include "ivas_cnst.h" #include "wmc_auto.h" +#include "prot_fx1.h" /*---------------------------------------------------------------------* * Local function prototypes @@ -475,6 +476,27 @@ static void getStandardBSplineSampVec( * Set precalculated parameters for HRTF model --------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void HRTF_model_precalc( + ModelParams_t *model /* i/o: HRTF model parameters */ +) +{ + Word16 sec_length; + Word16 i; + sec_length = mult(model->K,10923); /*10923 == 2 ^ 15 / 3*/ + FOR ( i = 0; i < HRTF_MODEL_N_SECTIONS; i++ ) + { + model->iSecFirst[i] = imult1616(i , sec_length); + } + FOR ( i = 0; i < HRTF_MODEL_N_SECTIONS - 1; i++ ) + { + model->iSecLast[i] = sub(imult1616(add( i , 1 ) , sec_length) , 1); + } + model->iSecLast[HRTF_MODEL_N_SECTIONS - 1] = sub(model->K , 1); /* Final section is longer if (K % nSec) > 0 */ + maximum_fx( model->azimDim3, model->elevDim3, &model->azimDim3Max ); + return; +} +#else void HRTF_model_precalc( ModelParams_t *model /* i/o: HRTF model parameters */ ) @@ -498,6 +520,7 @@ void HRTF_model_precalc( return; } +#endif // IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* diff --git a/lib_rend/ivas_objectRenderer_mix.c b/lib_rend/ivas_objectRenderer_mix.c index cf1dba8b2..20c0b152a 100644 --- a/lib_rend/ivas_objectRenderer_mix.c +++ b/lib_rend/ivas_objectRenderer_mix.c @@ -47,12 +47,14 @@ #define RESAMPLE_FACTOR_16_48 ( 16.0f / 48.0f ) #define RESAMPLE_FACTOR_32_48 ( 32.0f / 48.0f ) +#define RESAMPLE_FACTOR_32_48_FX 21845 /*Q_15*/ +#define RESAMPLE_FACTOR_16_48_FX 10923 /*Q_15*/ /*------------------------------------------------------------------------- * Local functions *-------------------------------------------------------------------------*/ -static ivas_error DefaultBSplineModel( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, const int32_t output_Fs ); +static ivas_error DefaultBSplineModel( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, const Word32 output_Fs ); /*-------------------------------------------------------------------* @@ -342,6 +344,34 @@ ivas_error TDREND_MIX_AddSrc( * Allocate the B Spline HR Filter model. --------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static ivas_error BSplineModelEvalAlloc( + ModelParams_t *model, /* i : Model parameters */ + ModelEval_t *modelEval /* i/o: Model evaluation structure */ +) +{ + IF((modelEval->hrfModL_fx = (Word16 *)malloc(model->K * sizeof(Word16))) == NULL) + { + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n")); + } + + IF((modelEval->hrfModR_fx = (Word16 *)malloc(model->K * sizeof(Word16))) == NULL) + { + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n")); + } + /*To be removed later: floating pointer memory allocation*/ + IF((modelEval->hrfModL = (float *)malloc(model->K * sizeof(float))) == NULL) + { + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n")); + } + IF((modelEval->hrfModR = (float *)malloc(model->K * sizeof(float))) == NULL) + { + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n")); + } + /*---------------------------------------------ends-here*/ + return IVAS_ERR_OK; +} +#else static ivas_error BSplineModelEvalAlloc( ModelParams_t *model, /* i : Model parameters */ ModelEval_t *modelEval /* i/o: Model evaluation structure */ @@ -359,6 +389,7 @@ static ivas_error BSplineModelEvalAlloc( return IVAS_ERR_OK; } +#endif // IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* @@ -367,6 +398,279 @@ static ivas_error BSplineModelEvalAlloc( * Init default HRTF model --------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static ivas_error DefaultBSplineModel( + TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o : Loaded HR filter set */ + const Word32 output_Fs /* i : Output sampling rate */ +) +{ + ModelParams_t *model; + ModelParamsITD_t *modelITD; + Word16 i, j; + ivas_error error; + HrFiltSet_p->FilterMethod = TDREND_HRFILT_Method_BSplineModel; + model = &( HrFiltSet_p->ModelParams ); + modelITD = &( HrFiltSet_p->ModelParamsITD ); + + SWITCH( output_Fs ) + { + case 48000: +#if 1/*To be removed later : floating point pointer initialization*/ + HrFiltSet_p->lr_energy_and_iac[0] = defaultHRIR_left_avg_power_48kHz; + HrFiltSet_p->lr_energy_and_iac[1] = defaultHRIR_right_avg_power_48kHz; + HrFiltSet_p->lr_energy_and_iac[2] = defaultHRIR_coherence_48kHz; +#endif + HrFiltSet_p->lr_energy_and_iac_fx[0] = defaultHRIR_left_avg_power_48kHz_fx; + HrFiltSet_p->lr_energy_and_iac_fx[1] = defaultHRIR_right_avg_power_48kHz_fx; + HrFiltSet_p->lr_energy_and_iac_fx[2] = defaultHRIR_coherence_48kHz_fx; + BREAK; + case 32000: +#if 1/*To be removed later : floating point pointer initialization*/ + HrFiltSet_p->lr_energy_and_iac[0] = defaultHRIR_left_avg_power_32kHz; + HrFiltSet_p->lr_energy_and_iac[1] = defaultHRIR_right_avg_power_32kHz; + HrFiltSet_p->lr_energy_and_iac[2] = defaultHRIR_coherence_32kHz; +#endif + HrFiltSet_p->lr_energy_and_iac_fx[0] = defaultHRIR_left_avg_power_32kHz_fx; + HrFiltSet_p->lr_energy_and_iac_fx[1] = defaultHRIR_right_avg_power_32kHz_fx; + HrFiltSet_p->lr_energy_and_iac_fx[2] = defaultHRIR_coherence_32kHz_fx; + BREAK; + case 16000: +#if 1/*To be removed later : floating point pointer initialization*/ + HrFiltSet_p->lr_energy_and_iac[0] = defaultHRIR_left_avg_power_16kHz; + HrFiltSet_p->lr_energy_and_iac[1] = defaultHRIR_right_avg_power_16kHz; + HrFiltSet_p->lr_energy_and_iac[2] = defaultHRIR_coherence_16kHz; +#endif + HrFiltSet_p->lr_energy_and_iac_fx[0] = defaultHRIR_left_avg_power_16kHz_fx; + HrFiltSet_p->lr_energy_and_iac_fx[1] = defaultHRIR_right_avg_power_16kHz_fx; + HrFiltSet_p->lr_energy_and_iac_fx[2] = defaultHRIR_coherence_16kHz_fx; + BREAK; + } + + /* Set ROM flag for correct deallocation */ + model->modelROM = TRUE; + + /* int16_t parameters */ + model->UseItdModel = 1; + model->SplineDegree = 4; + model->elevDim2 = 17; + model->elevDim3 = 15; + model->AlphaN = 470; + model->num_unique_azim_splines = 1; + model->elevSegSamples = 4; + model->elevBsLen[0] = 5; + model->elevBsLen[1] = 9; + model->elevBsLen[2] = 13; + model->elevBsLen[3] = 9; + model->elevBsStart[0] = 0; + model->elevBsStart[1] = 5; + model->elevBsStart[2] = 14; + model->elevBsStart[3] = 27; + + model->azimDim2 = defaultHRIR_rom_azimDim2; + model->azimDim3 = defaultHRIR_rom_azimDim3; + model->azim_start_idx = defaultHRIR_rom_azim_start_idx; + model->azimSegSamples = defaultHRIR_rom_azimSegSamples; + model->azimShapeIdx = defaultHRIR_rom_azimShapeIdx; + model->azimShapeSampFactor = defaultHRIR_rom_azimShapeSampFactor; + + /* float parameters */ +#if 1 /*To be removed later Floating point initializations */ + model->elevKSeq = (const float *) defaultHRIR_rom_elevKSeq; + model->elevBsShape = (const float *) defaultHRIR_rom_elevBsShape; +#endif // 1 + model->elevKSeq_fx = defaultHRIR_rom_elevKSeq_fx; + model->elevBsShape_fx = defaultHRIR_rom_elevBsShape; +#if 1 /*To be removed later : Floating point memory allocation*/ + IF ( ( model->azimBsShape = (const float **) malloc( model->num_unique_azim_splines * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); + } + model->azimBsShape[0] = (const float *)defaultHRIR_rom_azimBsShape; + IF ( ( model->azimKSeq = (float **) malloc( 18 * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); + } + IF( ( model->azimKSeq[0] = (float *) malloc( 2 * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); + } + IF( ( model->azimKSeq[model->elevDim3 - 1] = (float *) malloc( 2 * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); + } + model->azimKSeq[0][0] = 0.0f; + model->azimKSeq[model->elevDim3 - 1][0] = 0.0f; + model->azimKSeq[0][1] = 360.0f; + model->azimKSeq[model->elevDim3 - 1][1] = 360.0f; +#endif + IF ( ( model->azimBsShape_fx = (const UWord32 **) malloc( model->num_unique_azim_splines * sizeof(UWord32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); + } + model->azimBsShape_fx[0] = defaultHRIR_rom_azimBsShape; + IF ( ( model->azimKSeq_fx = (Word32 **) malloc( 18 * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); + } + IF ( ( model->azimKSeq_fx[0] = (Word32 *) malloc( 2 * sizeof(Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); + } + IF ( ( model->azimKSeq_fx[model->elevDim3 - 1] = (Word32 *) malloc( 2 * sizeof(Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); + } + model->azimKSeq_fx[0][0] = 0; + model->azimKSeq_fx[model->elevDim3 - 1][0] = 0; + model->azimKSeq_fx[0][1] = 360; + model->azimKSeq_fx[model->elevDim3 - 1][1] = 360; + + FOR ( i = 1; i < model->elevDim3 - 1; i++ ) + { +#if 1 /*To be removed later : Floating point initialization*/ + IF ( ( model->azimKSeq[i] = (float *) malloc( model->azimDim2[i] * sizeof( float * ) ) ) == NULL ) /* azimDim2[i] = 91, i=2..15 */ + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); + } + FOR ( j = 0; j < model->azimDim2[i]; j++ ) + { + model->azimKSeq[i][j] = (float) defaultHRIR_rom_azimSegSamples[0] * j; + } +#endif + IF( ( model->azimKSeq_fx[i] = (Word32 *) malloc( model->azimDim2[i] * sizeof( Word32 * ) ) ) == NULL ) /* azimDim2[i] = 91, i=2..15 */ + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural TD renderer\n" ) ); + } + FOR( j = 0; j < model->azimDim2[i]; j++ ) + { + model->azimKSeq_fx[i][j] = L_mult0(defaultHRIR_rom_azimSegSamples[0] , j); + } + } + + SWITCH ( output_Fs ) + { + case 48000: +#if 1/*To be removed later : floating point pointer initialization*/ + model->AlphaL = (const float *) defaultHRIR_rom_AlphaL48; + model->AlphaR = (const float *) defaultHRIR_rom_AlphaR48; + model->EL = (const float *) defaultHRIR_rom_EL48; + model->ER = (const float *) defaultHRIR_rom_ER48; + IF ( HrFiltSet_p->ModelParams.UseItdModel ) + { + modelITD->resamp_factor = 1.0f; + } +#endif + model->AlphaL_fx = defaultHRIR_rom_AlphaL48; + model->AlphaR_fx = defaultHRIR_rom_AlphaR48; + model->EL_fx = defaultHRIR_rom_EL48; + model->ER_fx = defaultHRIR_rom_ER48; + model->K = 128; + IF( HrFiltSet_p->ModelParams.UseItdModel ) + { + modelITD->resamp_factor_fx = 32767;/*Q-15*/ + } + BREAK; + case 32000: +#if 1/*To be removed later : floating point pointer initialization*/ + model->AlphaL = (const float *) defaultHRIR_rom_AlphaL32; + model->AlphaR = (const float *) defaultHRIR_rom_AlphaR32; + model->EL = (const float *) defaultHRIR_rom_EL32; + model->ER = (const float *) defaultHRIR_rom_ER32; + IF ( HrFiltSet_p->ModelParams.UseItdModel ) + { + modelITD->resamp_factor = RESAMPLE_FACTOR_32_48; + } +#endif + model->AlphaL_fx = defaultHRIR_rom_AlphaL32; + model->AlphaR_fx = defaultHRIR_rom_AlphaR32; + model->EL_fx = defaultHRIR_rom_EL32; + model->ER_fx = defaultHRIR_rom_ER32; + model->K = 86; + IF( HrFiltSet_p->ModelParams.UseItdModel ) + { + modelITD->resamp_factor_fx = RESAMPLE_FACTOR_32_48_FX; + } + BREAK; + case 16000: +#if 1/*To be removed later : floating point pointer initialization*/ + model->AlphaL = (const float *) defaultHRIR_rom_AlphaL16; + model->AlphaR = (const float *) defaultHRIR_rom_AlphaR16; + model->EL = (const float *) defaultHRIR_rom_EL16; + model->ER = (const float *) defaultHRIR_rom_ER16; + IF ( HrFiltSet_p->ModelParams.UseItdModel ) + { + modelITD->resamp_factor = RESAMPLE_FACTOR_16_48; + } +#endif + model->AlphaL_fx = defaultHRIR_rom_AlphaL16; + model->AlphaR_fx = defaultHRIR_rom_AlphaR16; + model->EL_fx = defaultHRIR_rom_EL16; + model->ER_fx = defaultHRIR_rom_ER16; + model->K = 43; + IF( HrFiltSet_p->ModelParams.UseItdModel ) + { + modelITD->resamp_factor_fx = RESAMPLE_FACTOR_16_48_FX; + } + BREAK; + default: + BREAK; + } + + modelITD->N = 4; + modelITD->elevDim2 = 20; + modelITD->elevDim3 = 18; + modelITD->azimDim2 = 41; + modelITD->azimDim3 = 41; + modelITD->elevSegSamples = 3; + modelITD->elevBsLen[0] = 4; + modelITD->elevBsLen[1] = 7; + modelITD->elevBsLen[2] = 10; + modelITD->elevBsLen[3] = 7; + modelITD->elevBsStart[0] = 0; + modelITD->elevBsStart[1] = 4; + modelITD->elevBsStart[2] = 11; + modelITD->elevBsStart[3] = 21; +#if 1/*To be removed later : floating point pointer initialization*/ + modelITD->elevKSeq = defaultHRIR_rom_ITD_elevKSeq; +#endif + modelITD->elevKSeq_fx = defaultHRIR_rom_ITD_elevKSeq_fx; + + modelITD->azimBsLen[0] = 11; + modelITD->azimBsLen[1] = 21; + modelITD->azimBsLen[2] = 31; + modelITD->azimBsLen[3] = 21; + modelITD->azimBsStart[0] = 0; + modelITD->azimBsStart[1] = 11; + modelITD->azimBsStart[2] = 32; + modelITD->azimBsStart[3] = 63; + + modelITD->azimSegSamples = 10; +#if 1/*To be removed later : floating point pointer initialization*/ + modelITD->azimKSeq = defaultHRIR_rom_ITD_azimKSeq; + modelITD->W = (const float *) defaultHRIR_rom_ITD_W; + modelITD->azimBsShape = (const float *) defaultHRIR_rom_ITD_azimBsShape; + modelITD->elevBsShape = (const float *) defaultHRIR_rom_ITD_elevBsShape; +#endif + modelITD->azimKSeq_fx = defaultHRIR_rom_ITD_azimKSeq_fx; + modelITD->W_fx = defaultHRIR_rom_ITD_W; + modelITD->azimBsShape_fx = defaultHRIR_rom_ITD_azimBsShape; + modelITD->elevBsShape_fx = defaultHRIR_rom_ITD_elevBsShape; + HRTF_model_precalc( model ); +#if 1/*To be removed later : floating point initialization*/ + HrFiltSet_p->latency_s = defaultHRIR_rom_latency_s; +#endif + HrFiltSet_p->latency_s_fx = defaultHRIR_rom_latency_s_fx; + HrFiltSet_p->SampleRate = output_Fs; + HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; + + IF ( ( error = BSplineModelEvalAlloc( &HrFiltSet_p->ModelParams, &HrFiltSet_p->ModelEval ) ) != IVAS_ERR_OK ) + { + return error; + } + + return IVAS_ERR_OK; +} +#else static ivas_error DefaultBSplineModel( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o : Loaded HR filter set */ const int32_t output_Fs /* i : Output sampling rate */ @@ -551,3 +855,4 @@ static ivas_error DefaultBSplineModel( return IVAS_ERR_OK; } +#endif // IVAS_FLOAT_FIXED diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index 0841d7770..6c4dfecfa 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -52,62 +52,62 @@ Word16 audioCfg2channels( { Word16 nchan_out; - switch ( output_config ) + SWITCH ( output_config ) { case IVAS_AUDIO_CONFIG_MONO: nchan_out = 1; - break; + BREAK; case IVAS_AUDIO_CONFIG_STEREO: nchan_out = 2; - break; + BREAK; case IVAS_AUDIO_CONFIG_5_1: nchan_out = 6; - break; + BREAK; case IVAS_AUDIO_CONFIG_7_1: nchan_out = 8; - break; + BREAK; case IVAS_AUDIO_CONFIG_5_1_2: nchan_out = 8; - break; + BREAK; case IVAS_AUDIO_CONFIG_5_1_4: nchan_out = 10; - break; + BREAK; case IVAS_AUDIO_CONFIG_7_1_4: nchan_out = 12; - break; + BREAK; case IVAS_AUDIO_CONFIG_FOA: nchan_out = 4; - break; + BREAK; case IVAS_AUDIO_CONFIG_HOA2: nchan_out = 9; - break; + BREAK; case IVAS_AUDIO_CONFIG_HOA3: nchan_out = 16; - break; + BREAK; case IVAS_AUDIO_CONFIG_OBA: nchan_out = 8; - break; + BREAK; case IVAS_AUDIO_CONFIG_BINAURAL: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: nchan_out = 2; - break; + BREAK; case IVAS_AUDIO_CONFIG_ISM1: nchan_out = 1; - break; + BREAK; case IVAS_AUDIO_CONFIG_ISM2: nchan_out = 2; - break; + BREAK; case IVAS_AUDIO_CONFIG_ISM3: nchan_out = 3; - break; + BREAK; case IVAS_AUDIO_CONFIG_ISM4: nchan_out = 4; - break; + BREAK; default: IVAS_ERROR( IVAS_ERR_INTERNAL, "Error: illegal output configuration\n" ); nchan_out = -1; - break; + BREAK; } return ( nchan_out ); @@ -193,6 +193,154 @@ int16_t audioCfg2channels( * * Initialize and configure IVAS output parameters *-------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_output_init( + IVAS_OUTPUT_SETUP *hOutSetup, /* o : IVAS output setup structure */ + const AUDIO_CONFIG output_config /* i : output audio configuration */ +) +{ + Word16 nchan_out; + + /* set general default values */ + hOutSetup->output_config = output_config; + hOutSetup->is_loudspeaker_setup = 0; + hOutSetup->is_binaural_setup = 0; + hOutSetup->ambisonics_order = -1; + hOutSetup->separateChannelEnabled = 0; + hOutSetup->separateChannelIndex = 0; + + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + hOutSetup->is_loudspeaker_setup = 1; + /* set in ivas_init_decoder: */ + /* hOutSetup->ls_azimuth */ + /* hOutSetup->ls_elevation */ + /* hOutSetup->num_lfe */ + /* hOutSetup->index_lfe[0] */ + /* hOutSetup->is_planar_setup */ + } + ELSE + { + /* Set default values for all other than custom LS setup */ + // To be removed later:->Floating-point pointer assignments-------- + hOutSetup->ls_azimuth = NULL; + hOutSetup->ls_elevation = NULL; + //--------------------------------------------------------ends here + hOutSetup->ls_azimuth_fx = NULL; + hOutSetup->ls_elevation_fx = NULL; + hOutSetup->num_lfe = 0; + hOutSetup->index_lfe[0] = -1; + hOutSetup->is_planar_setup = 0; + + /* set output setup specific values */ + SWITCH( output_config ) + { + case IVAS_AUDIO_CONFIG_MONO: + hOutSetup->is_loudspeaker_setup = 1; + BREAK; + case IVAS_AUDIO_CONFIG_STEREO: + hOutSetup->is_loudspeaker_setup = 1; + // To be removed later:->Floating-point pointer assignments-------- + hOutSetup->ls_azimuth = ls_azimuth_CICP2; + hOutSetup->ls_elevation = ls_elevation_CICP2; + //---------------------------------------------------------ends here + hOutSetup->ls_azimuth_fx = ls_azimuth_CICP2_fx; + hOutSetup->ls_elevation_fx = ls_elevation_CICP2_fx; + BREAK; + case IVAS_AUDIO_CONFIG_FOA: + hOutSetup->ambisonics_order = SBA_FOA_ORDER; + BREAK; + case IVAS_AUDIO_CONFIG_HOA2: + hOutSetup->ambisonics_order = SBA_HOA2_ORDER; + BREAK; + case IVAS_AUDIO_CONFIG_HOA3: + hOutSetup->ambisonics_order = SBA_HOA3_ORDER; + BREAK; + case IVAS_AUDIO_CONFIG_5_1: + hOutSetup->num_lfe = 1; + hOutSetup->index_lfe[0] = 3; + hOutSetup->is_loudspeaker_setup = 1; + // To be removed later:->Floating-point pointer assignments-------- + hOutSetup->ls_azimuth = ls_azimuth_CICP6; + hOutSetup->ls_elevation = ls_elevation_CICP6; + //---------------------------------------------------------ends here + hOutSetup->ls_azimuth_fx = ls_azimuth_CICP6_fx; + hOutSetup->ls_elevation_fx = ls_elevation_CICP6_fx; + hOutSetup->is_planar_setup = 1; + BREAK; + case IVAS_AUDIO_CONFIG_7_1: + hOutSetup->num_lfe = 1; + hOutSetup->index_lfe[0] = 3; + hOutSetup->is_loudspeaker_setup = 1; + // To be removed later:->Floating-point pointer assignments-------- + hOutSetup->ls_azimuth = ls_azimuth_CICP12; + hOutSetup->ls_elevation = ls_elevation_CICP12; + //---------------------------------------------------------ends here + hOutSetup->ls_azimuth_fx = ls_azimuth_CICP12_fx; + hOutSetup->ls_elevation_fx = ls_elevation_CICP12_fx; + hOutSetup->is_planar_setup = 1; + BREAK; + case IVAS_AUDIO_CONFIG_5_1_2: + hOutSetup->num_lfe = 1; + hOutSetup->index_lfe[0] = 3; + hOutSetup->is_loudspeaker_setup = 1; + // To be removed later:->Floating-point pointer assignments-------- + hOutSetup->ls_azimuth = ls_azimuth_CICP14; + hOutSetup->ls_elevation = ls_elevation_CICP14; + //---------------------------------------------------------ends here + hOutSetup->ls_azimuth_fx = ls_azimuth_CICP14_fx; + hOutSetup->ls_elevation_fx = ls_elevation_CICP14_fx; + hOutSetup->is_planar_setup = 0; + BREAK; + case IVAS_AUDIO_CONFIG_5_1_4: + hOutSetup->num_lfe = 1; + hOutSetup->index_lfe[0] = 3; + hOutSetup->is_loudspeaker_setup = 1; + // To be removed later:->Floating-point pointer assignments-------- + hOutSetup->ls_azimuth = ls_azimuth_CICP16; + hOutSetup->ls_elevation = ls_elevation_CICP16; + //---------------------------------------------------------ends here + hOutSetup->ls_azimuth_fx = ls_azimuth_CICP16_fx; + hOutSetup->ls_elevation_fx = ls_elevation_CICP16_fx; + hOutSetup->is_planar_setup = 0; + BREAK; + case IVAS_AUDIO_CONFIG_7_1_4: + hOutSetup->num_lfe = 1; + hOutSetup->index_lfe[0] = 3; + hOutSetup->is_loudspeaker_setup = 1; + // To be removed later:->Floating-point pointer assignments-------- + hOutSetup->ls_azimuth = ls_azimuth_CICP19; + hOutSetup->ls_elevation = ls_elevation_CICP19; + //---------------------------------------------------------ends here + hOutSetup->ls_azimuth_fx = ls_azimuth_CICP19_fx; + hOutSetup->ls_elevation_fx = ls_elevation_CICP19_fx; + hOutSetup->is_planar_setup = 0; + BREAK; + case IVAS_AUDIO_CONFIG_BINAURAL: + case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: + case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: + case IVAS_AUDIO_CONFIG_ISM1: + case IVAS_AUDIO_CONFIG_ISM2: + case IVAS_AUDIO_CONFIG_ISM3: + case IVAS_AUDIO_CONFIG_ISM4: + hOutSetup->is_binaural_setup = 1; + case IVAS_AUDIO_CONFIG_EXTERNAL: + /* Default values are used */ + BREAK; + default: + return; + } + } + + IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && NE_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_out = audioCfg2channels( output_config ); + hOutSetup->nchan_out_woLFE = sub( nchan_out, hOutSetup->num_lfe ); + } + + return; +} +#else void ivas_output_init( IVAS_OUTPUT_SETUP *hOutSetup, /* o : IVAS output setup structure */ @@ -312,6 +460,7 @@ void ivas_output_init( return; } +#endif // IVAS_FLOAT_FIXED /*-----------------------------------------------------------------* diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c new file mode 100644 index 000000000..ddd83f441 --- /dev/null +++ b/lib_rend/ivas_output_init_fx.c @@ -0,0 +1,148 @@ + +#include "ivas_prot_fx.h" +#include "ivas_prot.h" +#include "ivas_prot_rend.h" +#ifdef IVAS_FLOAT_FIXED +Word16 ivas_get_nchan_buffers_dec_ivas_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word16 sba_analysis_order, /* i : SBA order evaluated in SBA decoder */ + const Word32 ivas_total_brate /* i : total IVAS bitrate */ +) +{ + Word16 nchan_out_buff; + AUDIO_CONFIG output_config; + + output_config = st_ivas->hDecoderConfig->output_config; + + nchan_out_buff = MAX_OUTPUT_CHANNELS; + + IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) ) + { + nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; + } + ELSE IF( EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) ) + { + nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, CPE_CHANNELS ); + } + ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) + { + nchan_out_buff = st_ivas->nchan_ism; + + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); + } + ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); + } + } + ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) ) + { + Word16 nchan_internal; + nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); + nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; + + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); + } + ELSE + { + nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); + } + nchan_out_buff = s_max( nchan_out_buff, nchan_internal ); + } + ELSE IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) ) + { + nchan_out_buff = CPE_CHANNELS; + + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); + } + ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + nchan_out_buff = 2 * CPE_CHANNELS; + } + ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); + } + } + ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + { + nchan_out_buff = add( st_ivas->nchan_ism, CPE_CHANNELS ); + + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); + } + ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); + } + } + ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + { + Word16 nchan_internal; + nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate ); + nchan_out_buff = add( st_ivas->nchan_ism, st_ivas->nchan_transport ); + + IF( st_ivas->hMCT != NULL ) + { + nchan_out_buff = shl( shr( add( nchan_out_buff, 1 ), 1 ), 1 ); /* ensure odd number of channels in MCT */ + } + + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); + } + ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); + + IF( EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) ) + { + nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */ + } + ELSE + { + nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_spar_dec_upmixer_sf() which is based on 'nchan_out' */ + } + } + ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + nchan_out_buff = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); /*take into account sba_ch_idx' in ivas_dec() */ + } + + IF( !( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) + { + nchan_out_buff = s_max( nchan_out_buff, add( nchan_internal, st_ivas->nchan_ism ) ); + } + nchan_out_buff = s_min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); + } + ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) ) + { + nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; + + IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); + } + ELSE + { + nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); + } + } + + + return nchan_out_buff; +} +#endif // IVAS_FLOAT_FIXED \ No newline at end of file diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index e19ab76f3..93535b0d5 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -66,9 +66,15 @@ ivas_error getAudioConfigNumChannels( *----------------------------------------------------------------------------------*/ /*! r: number of output channels */ +#ifdef IVAS_FLOAT_FIXED +Word16 audioCfg2channels( + const AUDIO_CONFIG output_config /* i : output audio configuration */ +); +#else int16_t audioCfg2channels( const AUDIO_CONFIG output_config /* i : output audio configuration */ ); +#endif // IVAS_FLOAT_FIXED void ivas_output_init( IVAS_OUTPUT_SETUP *hOutSetup, /* o : output setup structure */ @@ -82,6 +88,14 @@ int16_t ivas_get_nchan_buffers_dec( const int32_t ivas_total_brate /* i : total IVAS bitrate */ ); +#ifdef IVAS_FLOAT_FIXED +Word16 ivas_get_nchan_buffers_dec_ivas_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word16 sba_analysis_order, /* i : SBA order evaluated in SBA decoder */ + const Word32 ivas_total_brate /* i : total IVAS bitrate */ +); +#endif // IVAS_FLOAT_FIXED + /*----------------------------------------------------------------------------------* * Limiter prototypes *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.c b/lib_rend/ivas_rom_TdBinauralRenderer.c index a84f26198..0a20880dc 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.c +++ b/lib_rend/ivas_rom_TdBinauralRenderer.c @@ -45,6 +45,7 @@ *------------------------------------------------------------------------*/ /* TD renderer default HRIR model */ const float defaultHRIR_rom_latency_s = 0.000020834f; +const Word32 defaultHRIR_rom_latency_s_fx = 44741;/*Q-31*/ const int16_t defaultHRIR_rom_azimDim2[15] = { 1, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 1, }; @@ -66,6 +67,11 @@ const int16_t defaultHRIR_rom_azimShapeSampFactor[15] = { const float defaultHRIR_rom_elevKSeq[13] = { -90.000000f, -75.000000f, -60.000000f, -45.000000f, -30.000000f, -15.000000f, 0.000000f, 15.000000f, 30.000000f, 45.000000f, 60.000000f, 75.000000f, 90.000000f, }; +#ifdef IVAS_FLOAT_FIXED +const Word16 defaultHRIR_rom_elevKSeq_fx[13]/*Q-0*/ = { +-90, -75, -60, -45, -30, -15, 0, 15, 30, 45, 60, 75, 90, +}; +#endif // IVAS_FLOAT_FIXED const uint32_t defaultHRIR_rom_elevBsShape[36] = { 0x3f800000,0x3ed80000,0x3e000000,0x3c800000,0x00000000,0xaa000000,0x3efe0000,0x3f180000,0x3eea0000,0x3e800000,0x3dd80000,0x3d000000,0x3b800000,0x00000000,0x29800000,0x3da2aaab,0x3e855555,0x3eea0000,0x3f155555,0x3f13aaab,0x3ef00000,0x3ea0aaab,0x3e2aaaab,0x3d900000,0x3caaaaab,0x3b2aaaab,0x27800000,0xa9000000,0x3b2aaaab,0x3caaaaab,0x3d900000,0x3e2aaaab,0x3ea15555,0x3ef55555,0x3f1caaab,0x3f2aaaab, }; @@ -10149,6 +10155,11 @@ const uint32_t defaultHRIR_rom_ITD_azimBsShape[84] = { const float defaultHRIR_rom_ITD_azimKSeq[19] = { 0.000000f, 10.000000f, 20.000000f, 30.000000f, 40.000000f, 50.000000f, 60.000000f, 70.000000f, 80.000000f, 90.000000f, 100.000000f, 110.000000f, 120.000000f, 130.000000f, 140.000000f, 150.000000f, 160.000000f, 170.000000f, 180.000000f, }; +#ifdef IVAS_FLOAT_FIXED +const Word32 defaultHRIR_rom_ITD_azimKSeq_fx[19]/*Q-0*/ = { + 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, +}; +#endif // IVAS_FLOAT_FIXED const uint32_t defaultHRIR_rom_ITD_elevBsShape[28] = { 0x3f800000,0x3e97b426,0x3d17b426,0x00000000,0x00000000,0x3f1097b4,0x3f04bda1,0x3e800000,0x3d97b426,0x3c17b426,0x00000000,0x00000000,0x3e07e6b7,0x3eca4588,0x3f155555,0x3f0ca458,0x3ebc0ca4,0x3e2aaaab,0x3d4a4588,0x3bca4588,0x00000000,0x00000000,0x3bca4588,0x3d4a4588,0x3e2aaaab, 0x3ebda12f,0x3f12f685,0x3f2aaaab, @@ -10157,6 +10168,9 @@ const float defaultHRIR_rom_ITD_elevKSeq[16] = { -90.000000f, -78.000000f, -66.000000f, -54.000000f, -42.000000f, -30.000000f, -18.000000f, -6.000000f, 6.000000f, 18.000000f, 30.000000f, 42.000000f, 54.000000f, 66.000000f, 78.000000f, 90.000000f, }; +const Word16 defaultHRIR_rom_ITD_elevKSeq_fx[16] /*Q-0*/= { +-90, -78, -66, -54, -42, -30, -18, -6, 6, 18, 30, 42, 54, 66, 78, 90, +}; #undef WMC_TOOL_SKIP /* clang-format on */ diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.h b/lib_rend/ivas_rom_TdBinauralRenderer.h index 8e113b040..f1fd8bd8f 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.h +++ b/lib_rend/ivas_rom_TdBinauralRenderer.h @@ -40,6 +40,7 @@ *------------------------------------------------------------------------*/ /* TD renderer default HRIR model */ extern const float defaultHRIR_rom_latency_s; +extern const Word32 defaultHRIR_rom_latency_s_fx; extern const int16_t defaultHRIR_rom_azimDim2[15]; extern const int16_t defaultHRIR_rom_azimDim3[15]; extern const int16_t defaultHRIR_rom_azim_start_idx[15]; @@ -47,6 +48,9 @@ extern const int16_t defaultHRIR_rom_azimSegSamples[1]; extern const int16_t defaultHRIR_rom_azimShapeIdx[15]; extern const int16_t defaultHRIR_rom_azimShapeSampFactor[15]; extern const float defaultHRIR_rom_elevKSeq[13]; +#ifdef IVAS_FLOAT_FIXED +extern const Word16 defaultHRIR_rom_elevKSeq_fx[13]; +#endif // IVAS_FLOAT_FIXED extern const uint32_t defaultHRIR_rom_AlphaL48[470 * 128]; extern const uint32_t defaultHRIR_rom_AlphaR48[470 * 128]; extern const uint32_t defaultHRIR_rom_AlphaL32[470 * 86]; @@ -66,3 +70,7 @@ extern const uint32_t defaultHRIR_rom_ITD_azimBsShape[84]; extern const float defaultHRIR_rom_ITD_azimKSeq[19]; extern const uint32_t defaultHRIR_rom_ITD_elevBsShape[28]; extern const float defaultHRIR_rom_ITD_elevKSeq[16]; +#ifdef IVAS_FLOAT_FIXED +extern const Word16 defaultHRIR_rom_ITD_elevKSeq_fx[16];/*Q-0*/ +extern const Word32 defaultHRIR_rom_ITD_azimKSeq_fx[19]; +#endif // IVAS_FLOAT_FIXED diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index caecfd54f..abddd6399 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -584,6 +584,148 @@ const float defaultHRIR_right_avg_power_16kHz[LR_IAC_LENGTH_NR_FC] = { 0.485566f, 0.481405f, 0.471746f, 0.440098f, 0.408450f, 0.376802f, 0.330743f, 0.284685f, 0.238626f, 0.203638f, 0.171419f, 0.139199f, 0.126311f, 0.126311f }; +#ifdef IVAS_FLOAT_FIXED +const UWord16 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-15*/ = { + 32211, 30587, 25862, 18822, 11164, 4725, 616, 0, 0, 0, 391, 1162, 1415, 1391, 1369, 1263, 947, 562, 379, + 464, 649, 805, 956, 1092, 1095, 970, 900, 898, 824, 639, 482, 465, 528, 533, 431, 283, 164, 85, 34, 6, + 0, 0, 0, 36, 130, 229, 312, 377, 406, 378, 300, 203, 116, 45, 0, 0, 0, 0, 1, 30, 69, 100, 117, 123, 120, + 101, 67, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 31, 59, 76, 79, 68, 50, 29, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 27, 42, 50, 50, 43, 31, 17, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 20, 31, 41, 52, 62, + 71, 79, 88, 96, 103, 110, 117, 123, 128, 130, 130, 128, 123, 114, 103, 91, 76, 59, 41, 23, 6, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 25, 17, 0, 55, 108, 53, 0, 52, 247, 19, 0, 66, 338, 70, 0, 115, 303, 168, 0, 74, 212, 193, 0, 28, 149, + 134, 0, 0, 106, 50, 8, 6, 44, 28, 0 +}; +const UWord16 defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-15*/ = { + 32069, 31863, 31445, 31191, 31222, 31295, 31151, 30899, 30926, 31400, 31932, 32143, 32002, 31737, 31524, + 31367, 31210, 31068, 30981, 30907, 30745, 30482, 30254, 30187, 30217, 30173, 30053, 29970, 29954, 29932, + 29873, 29838, 29891, 30001, 30076, 30074, 30038, 30029, 30042, 30022, 29950, 29863, 29802, 29756, 29693, + 29603, 29511, 29442, 29391, 29324, 29224, 29114, 29030, 28968, 28887, 28768, 28652, 28590, 28555, 28503, + 28437, 28401, 28413, 28449, 28472, 28486, 28529, 28624, 28747, 28864, 28979, 29136, 29356, 29598, 29813, + 30015, 30241, 30484, 30697, 30848, 30956, 31056, 31153, 31207, 31186, 31110, 31025, 30937, 30804, 30595, + 30363, 30154, 29951, 29709, 29421, 29127, 28860, 28604, 28325, 28020, 27731, 27496, 27304, 27123, 26956, + 26860, 26860, 26920, 27001, 27101, 27250, 27451, 27663, 27848, 28006, 28173, 28359, 28531, 28649, 28726, + 28810, 28905, 28960, 28948, 28898, 28847, 28793, 28702, 28560, 28396, 28248, 28119, 27978, 27806, 27630, + 27493, 27388, 27261, 27097, 26941, 26821, 26713, 26579, 26421, 26276, 26169, 26084, 25993, 25898, 25835, + 25828, 25856, 25879, 25896, 25949, 26049, 26160, 26243, 26305, 26382, 26482, 26570, 26614, 26627, 26654, + 26703, 26734, 26717, 26681, 26679, 26697, 26694, 26661, 26630, 26630, 26654, 26670, 26664, 26659, 26688, + 26748, 26798, 26811, 26824, 26895, 27002, 27062, 27084, 27145, 27265, 27379, 27439, 27491, 27599, 27746, + 27852, 27897, 27955, 28057, 28091, 27925, 27603, 27238, 26740, 25949, 24880, 23702, 22488, 21123, 19491, + 17693, 15981, 14436, 12776, 10592, 7813, 4890, 2543, 1069, 348, 80, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; +const UWord16 defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-15*/ = { + 32069, 31863, 31445, 31191, 31222, 31295, 31151, 30899, 30926, 31400, 31932, 32143, 32002, 31737, 31524, + 31367, 31210, 31068, 30980, 30907, 30745, 30482, 30254, 30187, 30217, 30173, 30053, 29970, 29954, 29932, + 29873, 29838, 29891, 30001, 30076, 30074, 30038, 30029, 30042, 30022, 29950, 29863, 29802, 29756, 29693, + 29603, 29511, 29442, 29391, 29324, 29224, 29114, 29030, 28968, 28887, 28768, 28652, 28590, 28555, 28503, + 28437, 28401, 28413, 28449, 28472, 28486, 28529, 28624, 28747, 28864, 28979, 29136, 29356, 29598, 29813, + 30015, 30241, 30484, 30697, 30848, 30956, 31056, 31153, 31207, 31186, 31110, 31025, 30937, 30804, 30595, + 30364, 30154, 29951, 29709, 29421, 29127, 28860, 28604, 28325, 28020, 27731, 27496, 27304, 27123, 26956, + 26860, 26860, 26920, 27001, 27101, 27250, 27451, 27663, 27848, 28006, 28173, 28359, 28531, 28649, 28726, + 28810, 28905, 28960, 28948, 28897, 28847, 28793, 28702, 28560, 28396, 28248, 28119, 27978, 27806, 27630, + 27493, 27388, 27261, 27097, 26941, 26821, 26713, 26579, 26421, 26276, 26169, 26084, 25993, 25898, 25835, + 25828, 25856, 25879, 25896, 25949, 26049, 26160, 26243, 26305, 26382, 26482, 26570, 26614, 26627, 26654, + 26703, 26734, 26717, 26681, 26679, 26697, 26694, 26661, 26630, 26630, 26654, 26670, 26664, 26659, 26688, + 26748, 26798, 26811, 26824, 26895, 27002, 27062, 27084, 27145, 27265, 27379, 27439, 27491, 27599, 27746, + 27852, 27897, 27955, 28057, 28090, 27925, 27603, 27238, 26739, 25949, 24880, 23702, 22488, 21123, 19491, + 17693, 15981, 14436, 12776, 10592, 7813, 4890, 2543, 1069, 348, 80, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; +const UWord16 defaultHRIR_coherence_32kHz_fx[257] /*Q-15*/ = { + 32012,31549,29232,25671,21280,16002,11011,6448,3083,552,157,0,0,0,88,309,807,1275,1355,1353,1297,1279, + 1213,1075,806,522,304,230,254,387,509,615,715,813,905,940,938,856,788,744,737,725,657,543,399,318,287, + 328,374,403,358,280,179,96,34,5,0,0,0,0,0,0,0,0,0,7,45,98,162,212,256,293,300,291,246,189,123,63,20,3, + 0,0,0,0,0,0,0,0,0,0,0,8,23,31,36,38,34,25,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,11,18,23,19,10,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,11,19,25,28,27,24,16,8,1,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,5,9,15,21,28,35,41,48,55,62,68,74, + 79,83,87,91,94,98,102,106,111,119,127,136,145,155,166,177,189,200,210,219,226,232,237,239,239,233,224, + 211,193,174,149,123,97,83,77,81,82 +}; +const UWord16 defaultHRIR_left_avg_power_32kHz_fx[257] /*Q-15*/ = { + 34171,34113,33819,33565,33338,33397,33493,33645,33642,33572,33391,33314,33308,33603,33918,34267,34419, + 34473,34327,34162,33984,33890,33804,33727,33619,33507,33410,33339,33285,33182,33038,32833,32634,32464, + 32400,32383,32399,32360,32296,32193,32118,32060,32045,32018,31983,31916,31868,31850,31897,31963,32035, + 32067,32073,32036,32005,31984,31979,31972,31946,31895,31826,31744,31668,31604,31546,31486,31409,31316, + 31212,31114,31026,30953,30880,30801,30697,30581,30458,30352,30254,30168,30071,29965,29838,29714,29591, + 29503,29422,29352,29272,29187,29096,29020,28956,28928,28903,28879,28839,28796,28758,28744,28748,28783, + 28816,28846,28871,28902,28959,29045,29150,29266,29375,29471,29564,29659,29772,29887,30006,30089,30153, + 30190,30215,30237,30263,30280,30290,30248,30187,30098,30003,29907,29813,29701,29576,29403,29225,29037, + 28868,28704,28543,28361,28165,27941,27724,27516,27327,27141,26948,26738,26518,26298,26093,25910,25750, + 25598,25449,25305,25163,25065,24991,24954,24947,24948,24954,24967,24985,25043,25113,25202,25280,25350, + 25397,25443,25489,25556,25622,25686,25720,25741,25741,25745,25752,25765,25767,25752,25703,25641,25562, + 25486,25413,25336,25245,25135,25000,24859,24722,24599,24486,24373,24250,24112,23969,23831,23716,23612, + 23515,23401,23277,23139,23004,22873,22757,22637,22515,22365,22208,22039,21877,21720,21576,21432,21287, + 21125,20963,20801,20668,20550,20461,20370,20278,20176,20089,20024,20008,20007,20017,20019,20014,20051, + 20122,20243,20403,20584,20814,21138,21523,21921,22069,21841,20583,18845,16215,13564,10899,9201,7926,7286, + 7157 +}; +const UWord16 defaultHRIR_right_avg_power_32kHz_fx[257] /*Q-15*/ = { + 34171,34113,33819,33565,33338,33397,33493,33645,33642,33572,33391,33314,33308,33603,33918,34267,34419, + 34473,34327,34162,33984,33890,33804,33727,33619,33507,33410,33339,33285,33182,33038,32833,32634,32464, + 32400,32383,32399,32360,32296,32193,32118,32060,32045,32018,31983,31916,31868,31850,31897,31963,32035, + 32067,32074,32036,32005,31984,31979,31972,31946,31895,31826,31744,31668,31604,31546,31486,31409,31316, + 31212,31114,31026,30953,30880,30801,30697,30581,30458,30352,30254,30168,30071,29965,29838,29714,29591, + 29503,29422,29352,29272,29187,29096,29020,28956,28928,28902,28879,28839,28796,28758,28744,28748,28783, + 28816,28846,28871,28902,28959,29045,29150,29266,29375,29471,29564,29659,29772,29888,30006,30089,30153, + 30190,30214,30236,30263,30280,30290,30248,30187,30098,30003,29907,29813,29701,29576,29403,29225,29037, + 28868,28704,28543,28361,28165,27941,27724,27516,27327,27142,26948,26738,26518,26298,26093,25910,25750, + 25598,25449,25305,25163,25065,24991,24954,24947,24948,24954,24967,24985,25043,25113,25202,25280,25350, + 25396,25443,25489,25556,25622,25686,25720,25741,25741,25745,25752,25764,25767,25752,25703,25641,25562, + 25486,25413,25336,25246,25136,25000,24859,24722,24599,24486,24373,24250,24112,23969,23831,23716,23612, + 23515,23401,23277,23139,23004,22873,22757,22637,22515,22365,22208,22039,21877,21720,21576,21432,21287, + 21125,20963,20801,20668,20550,20461,20370,20278,20176,20089,20024,20008,20007,20017,20019,20015,20051, + 20122,20243,20403,20584,20814,21138,21524,21922,22069,21841,20583,18845,16215,13564,10899,9201,7926,7286, + 7157 +}; +const UWord16 defaultHRIR_coherence_16kHz_fx[257] /*Q-15*/ = { + 31768,31768,31304,30146,28987,27616,25398,23180,20962,18325,15689,13052,10721,8465,6210,4393,2867,1342, + 374,240,106,0,0,0,0,0,0,0,83,188,293,489,745,1001,1166,1193,1220,1236,1212,1188,1164,1163,1162,1162,1115, + 1057,998,893,756,620,497,395,294,214,223,232,241,301,360,420,466,510,553,592,628,664,698,729,761,785,779, + 773,767,729,691,653,630,611,592,585,586,587,575,543,511,471,403,334,265,225,185,145,152,170,189,208,228, + 249,250,223,196,163,109,54,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,7,13,19,42,64,86, + 102,116,130,134,132,130,118,92,66,42,28,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,24,63,103,157,235,312,398,518,638,758,937,1117,1296,1533,1784,2035,2136,2136 +}; +const UWord16 defaultHRIR_left_avg_power_16kHz_fx[257] /*Q-15*/ = { + 36465,36465,36392,36209,36026,35860,35762,35664,35565,35651,35736,35821,35904,35987,36069,36071,36020, + 35969,35903,35814,35725,35656,35663,35671,35678,35800,35921,36043,36201,36368,36535,36661,36759,36857, + 36895,36841,36788,36718,36578,36439,36299,36213,36127,36041,35999,35967,35935,35873,35790,35707,35610, + 35492,35373,35268,35212,35157,35101,35062,35022,34983,34867,34732,34598,34449,34292,34135,34026,33990, + 33954,33930,33953,33977,34000,33932,33864,33795,33687,33568,33449,33373,33325,33278,33241,33219,33197, + 33162,33074,32986,32897,32811,32725,32639,32623,32626,32628,32639,32657,32675,32669,32627,32585,32543, + 32497,32452,32407,32390,32374,32357,32309,32252,32195,32114,32017,31919,31838,31779,31721,31665,31621, + 31578,31534,31418,31302,31186,31052,30914,30775,30679,30610,30542,30474,30406,30339,30253,30093,29934, + 29774,29612,29450,29287,29196,29122,29048,28966,28879,28792,28665,28481,28296,28115,27946,27777,27607, + 27525,27443,27361,27255,27143,27031,26870,26675,26481,26303,26149,25995,25854,25769,25684,25599,25461, + 25323,25185,25006,24816,24627,24481,24364,24246,24144,24065,23985,23888,23724,23559,23395,23214,23033, + 22852,22754,22677,22600,22522,22443,22365,22239,22044,21848,21657,21487,21316,21146,21109,21073,21036, + 20964,20883,20801,20633,20407,20181,19982,19825,19668,19541,19536,19530,19524,19411,19299,19186,18934, + 18647,18360,18149,17988,17828,17735,17744,17753,17722,17532,17342,17152,16740,16328,15915,15723,15586, + 15449,15527,15748,15969,16047,15911,15774,15458,14421,13384,12347,10837,9328,7819,6672,5617,4561,4138, + 4138 +}; +const UWord16 defaultHRIR_right_avg_power_16kHz_fx[257] /*Q-15*/ = { + 36465,36465,36392,36209,36026,35860,35762,35664,35565,35651,35736,35821,35904,35987,36069,36071,36020, + 35969,35903,35814,35725,35656,35663,35670,35678,35800,35921,36043,36201,36368,36535,36660,36759,36857, + 36895,36841,36788,36718,36578,36439,36299,36213,36127,36041,35999,35967,35935,35873,35790,35707,35610, + 35492,35373,35268,35212,35157,35101,35062,35022,34983,34867,34732,34598,34449,34292,34135,34026,33990, + 33954,33930,33953,33977,34000,33932,33864,33795,33687,33568,33449,33373,33325,33278,33241,33219,33197, + 33162,33074,32986,32897,32811,32725,32639,32623,32625,32628,32639,32657,32675,32669,32627,32585,32543, + 32497,32452,32407,32390,32374,32357,32309,32252,32195,32114,32017,31919,31838,31779,31721,31665,31622, + 31578,31534,31418,31302,31186,31052,30913,30775,30679,30610,30542,30474,30406,30339,30253,30093,29934, + 29774,29612,29450,29287,29196,29122,29048,28966,28879,28792,28665,28481,28296,28115,27946,27777,27607, + 27525,27443,27361,27255,27143,27031,26870,26675,26481,26303,26149,25995,25854,25769,25684,25599,25461, + 25323,25185,25006,24816,24627,24481,24364,24246,24144,24065,23985,23888,23724,23559,23395,23214,23033, + 22852,22754,22677,22600,22522,22443,22365,22239,22044,21848,21657,21487,21316,21146,21109,21073,21037, + 20964,20883,20801,20633,20407,20181,19982,19825,19668,19541,19536,19530,19524,19411,19299,19186,18934, + 18647,18360,18149,17988,17828,17735,17744,17753,17722,17532,17342,17152,16740,16328,15915,15723,15586, + 15449,15527,15748,15969,16047,15911,15774,15458,14421,13384,12347,10837,9328,7819,6672,5617,4561,4138, + 4138 +}; +#endif // IVAS_FLOAT_FIXED /*----------------------------------------------------------------------------------* * t-design and SN3D normalization table *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index 78da6567b..08427af9e 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -105,6 +105,19 @@ extern const float defaultHRIR_coherence_16kHz[LR_IAC_LENGTH_NR_FC]; extern const float defaultHRIR_left_avg_power_16kHz[LR_IAC_LENGTH_NR_FC]; extern const float defaultHRIR_right_avg_power_16kHz[LR_IAC_LENGTH_NR_FC]; +#ifdef IVAS_FLOAT_FIXED +extern const UWord16 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC];/*Q-15*/ +extern const UWord16 defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC];/*Q-15*/ +extern const UWord16 defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC];/*Q-15*/ + +extern const UWord16 defaultHRIR_coherence_32kHz_fx[LR_IAC_LENGTH_NR_FC];/*Q-15*/ +extern const UWord16 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC];/*Q-15*/ +extern const UWord16 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC];/*Q-15*/ + +extern const UWord16 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC];/*Q-15*/ +extern const UWord16 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC];/*Q-15*/ +extern const UWord16 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC];/*Q-15*/ +#endif // IVAS_FLOAT_FIXED /*----------------------------------------------------------------------------------* * t-design and SN3D normalization table *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 8062670b2..4e33a019e 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -58,8 +58,10 @@ typedef struct ivas_output_setup_structure Word16 num_lfe; Word16 index_lfe[1]; + const Word16 *ls_azimuth_fx; const float *ls_azimuth; const float *ls_elevation; + const Word16 *ls_elevation_fx; UWord8 separateChannelEnabled; Word16 separateChannelIndex; @@ -1185,6 +1187,16 @@ typedef struct const int16_t *azimShapeSampFactor; const float *elevKSeq; /* Array, N x elevDim2 x elevDim3 */ +#ifdef IVAS_FLOAT_FIXED + const Word16 *elevKSeq_fx; /* Array, N x elevDim2 x elevDim3 */ + const UWord32 *elevBsShape_fx; + const UWord32 **azimBsShape_fx; + Word32 **azimKSeq_fx; /* Array, length azimDim3+1 */ + const UWord32 *AlphaL_fx; /* Array, size AlphaN x K */ + const UWord32 *AlphaR_fx; /* Array, size AlphaN x K */ + const UWord32 *EL_fx; /* Array, size (AlphaN*HRTF_MODEL_N_SECTIONS) */ + const UWord32 *ER_fx; /* Array, size (AlphaN*HRTF_MODEL_N_SECTIONS) */ +#endif // IVAS_FLOAT_FIXED const float *AlphaL; /* Array, size AlphaN x K */ const float *AlphaR; /* Array, size AlphaN x K */ const float *elevBsShape; @@ -1236,6 +1248,14 @@ typedef struct const float *elevBsShape; int16_t elevSegSamples; float resamp_factor; +#ifdef IVAS_FLOAT_FIXED + Word16 resamp_factor_fx;/*Q-15*/ + const Word16 *elevKSeq_fx; /* Array, length elevDim3-2 */ + const Word32 *azimKSeq_fx; /* Array, length azimDim3-2 */ + const UWord32 *W_fx; /* Array, size (elevDim3*azimDim3) x K */ + const UWord32 *azimBsShape_fx; + const UWord32 *elevBsShape_fx; +#endif // IVAS_FLOAT_FIXED /* Pointers for allocation of dynamic memory */ float *elevKSeq_dyn; @@ -1256,6 +1276,10 @@ typedef struct /* Shared memory for use when evaluating BSpline HR filter model*/ typedef struct { +#ifdef IVAS_FLOAT_FIXED + Word16 *hrfModL_fx; + Word16 *hrfModR_fx; +#endif float BM[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ]; ValueIndex_t BMEnergiesL[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ]; ValueIndex_t BMEnergiesR[HRTF_MODEL_BSPLINE_NUM_COEFFS_SQ]; @@ -1306,6 +1330,10 @@ typedef struct TDREND_HRFILT_FiltSet_struct TDREND_HRFILT_Method_t FilterMethod; /* HR filtering method */ float latency_s; const float *lr_energy_and_iac[3]; /* left/right energy and interaural coherence for late reverb */ +#ifdef IVAS_FLOAT_FIXED + const UWord16 *lr_energy_and_iac_fx[3]; /* left/right energy and interaural coherence for late reverb *//*Q-15*/ + Word32 latency_s_fx;/*Q-31*/ +#endif // IVAS_FLOAT_FIXED float *lr_energy_and_iac_dyn[3]; } TDREND_HRFILT_FiltSet_t; -- GitLab