diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index fda8732d93be4811df6adb736649824be67bcb3b..363237d9cfdb44a5ac608fc098ab1231b672e160 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -491,9 +491,15 @@ void destroy_core_dec( DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ ); +#ifndef IVAS_FLOAT_FIXED void ivas_destroy_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#else +void ivas_destroy_dec_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); +#endif void ivas_initialize_handles_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ @@ -4614,9 +4620,9 @@ void ivas_mc_paramupmix_dec_digest_tc( #ifdef IVAS_FLOAT_FIXED void ivas_mc_paramupmix_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ + UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ + UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ Word32 *input_fx[], /* i : core-coder transport channels */ Word32 *output_fx[] /* i/o: synthesized core-coder transport channels */ ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index eb526f1f5a9e8ee43cefcebaa330850af7ecf0ba..214c004fae34f64d1d853761bb31e26b678c28fa 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -4479,7 +4479,7 @@ void ivas_initialize_handles_dec( *-------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -void ivas_destroy_dec( +void ivas_destroy_dec_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ) { @@ -4624,13 +4624,13 @@ void ivas_destroy_dec( /* OMASA structure */ ivas_omasa_data_close_fx( &st_ivas->hMasaIsmData ); /* Head track data handle */ - ivas_headTrack_close( &st_ivas->hHeadTrackData ); + ivas_headTrack_close_fx( &st_ivas->hHeadTrackData ); /* External orientation data handle */ - ivas_external_orientation_close( &st_ivas->hExtOrientationData ); + ivas_external_orientation_close_fx( &st_ivas->hExtOrientationData ); /* Combined orientation data handle */ - ivas_combined_orientation_close( &st_ivas->hCombinedOrientationData ); + ivas_combined_orientation_close_fx( &st_ivas->hCombinedOrientationData ); /* Time Domain binaural renderer handle */ IF( st_ivas->hBinRendererTd != NULL ) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 8e38d958b5e1a9548bd43f8c68a766cedc44fcb7..d25fff5f886ffb672a70bafc522e4c34d091a79a 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -93,7 +93,11 @@ static void ivas_param_mc_dec_copy_diffuse_proto( PARAM_MC_DEC_HANDLE hParamMC, #else static void ivas_param_mc_dec_copy_diffuse_proto( PARAM_MC_DEC_HANDLE hParamMC, float Cldfb_buffer_real[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Cldfb_buffer_imag[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nY, const int16_t slot_idx ); #endif -static Word16 ivas_param_mc_range_decoder_LC( UWord16 *bit_buffer, Word16 *x, Word16 *BER_detect, const Word16 sz_seq, const Word16 sz_alphabet, const UWord16 *cft, const UWord16 *sft, const Word16 tot_shift, const Word16 nbbits ); +#ifdef IVAS_FLOAT_FIXED +static Word16 ivas_param_mc_range_decoder_LC_fx( UWord16 *bit_buffer, Word16 *x, Word16 *BER_detect, const Word16 sz_seq, const Word16 sz_alphabet, const UWord16 *cft, const UWord16 *sft, const Word16 tot_shift, const Word16 nbbits ); +#else +static int16_t ivas_param_mc_range_decoder_LC( uint16_t *bit_buffer, int16_t *x, int16_t *BER_detect, const int16_t sz_seq, const int16_t sz_alphabet, const uint16_t *cft, const uint16_t *sft, const int16_t tot_shift, const int16_t nbbits ); +#endif #ifndef IVAS_FLOAT_FIXED static int16_t ivas_param_mc_uniform_decoder( float *seq, const int16_t sz_seq, const float *alphabet, const int16_t N, uint16_t bit_buffer[PARAM_MC_MAX_BITS] ); @@ -190,51 +194,67 @@ ivas_error ivas_param_mc_dec_open_fx( ivas_error error; error = IVAS_ERR_OK; + move32(); /*-----------------------------------------------------------------* * prepare library opening *-----------------------------------------------------------------*/ - if ( ( hParamMC = (PARAM_MC_DEC_HANDLE) malloc( sizeof( PARAM_MC_DEC_DATA ) ) ) == NULL ) + IF( ( hParamMC = (PARAM_MC_DEC_HANDLE) malloc( sizeof( PARAM_MC_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } - if ( ( hParamMC->hMetadataPMC = (HANDLE_IVAS_PARAM_MC_METADATA) malloc( sizeof( IVAS_PARAM_MC_METADATA ) ) ) == NULL ) + IF( ( hParamMC->hMetadataPMC = (HANDLE_IVAS_PARAM_MC_METADATA) malloc( sizeof( IVAS_PARAM_MC_METADATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC metadata \n" ) ); } output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); output_config = st_ivas->hDecoderConfig->output_config; + move32(); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + move32(); #ifndef FIX_901_PARAMMC_DEAD_CODE hTransportSetup = st_ivas->hTransSetup; #endif mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ); - nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); hParamMC->hoa_encoder_fx = NULL; /* determine the synthesis config */ - if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->transport_config == output_config ) + test(); + test(); + test(); + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || EQ_32( st_ivas->transport_config, output_config ) ) { hParamMC->synthesis_conf = PARAM_MC_SYNTH_DIRECT; + move32(); } - else if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { hParamMC->synthesis_conf = PARAM_MC_SYNTH_MONO_STEREO; + move32(); } - else if ( st_ivas->transport_config != output_config ) + ELSE IF( NE_32( st_ivas->transport_config, output_config ) ) { - if ( ( output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && nchan_out_transport > audioCfg2channels( output_config ) ) || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && nchan_out_transport > st_ivas->hOutSetup.nchan_out_woLFE ) ) + test(); + test(); + IF( ( NE_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && GT_16( nchan_out_transport, audioCfg2channels( output_config ) ) ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && GT_16( nchan_out_transport, st_ivas->hOutSetup.nchan_out_woLFE ) ) ) { hParamMC->synthesis_conf = PARAM_MC_SYNTH_LS_CONV_COV; + move32(); /* need to reset the intern config */ st_ivas->intern_config = output_config; + move32(); ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); - if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hLsSetupCustom->num_spk; + move32(); #if 0 /*TODO: To be removed later*/ st_ivas->hIntSetup.ls_azimuth = st_ivas->hLsSetupCustom->ls_azimuth; st_ivas->hIntSetup.ls_elevation = st_ivas->hLsSetupCustom->ls_elevation; @@ -243,9 +263,10 @@ ivas_error ivas_param_mc_dec_open_fx( st_ivas->hIntSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx; } } - else + ELSE { hParamMC->synthesis_conf = PARAM_MC_SYNTH_LS_CONV_CLDFB; + move32(); } } @@ -254,46 +275,67 @@ ivas_error ivas_param_mc_dec_open_fx( #endif hParamMC->ls_conv_dmx_matrix_fx = NULL; - if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + test(); + IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { - nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); } - else + ELSE { nchan_out_cov = nchan_out_transport; + move16(); } st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); + move16(); config_index = ivas_param_mc_get_configuration_index( mc_ls_setup, ivas_total_brate ); nchan_transport = st_ivas->nchan_transport; + move16(); - switch ( nchan_transport ) + SWITCH( nchan_transport ) { case 4: case 3: st_ivas->nCPE = 2; + move16(); st_ivas->nSCE = 0; + move16(); st_ivas->element_mode_init = IVAS_CPE_MDCT; - break; + move16(); + BREAK; case 2: st_ivas->nCPE = 1; + move16(); st_ivas->nSCE = 0; + move16(); st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); - break; + BREAK; } /*-----------------------------------------------------------------* * set input parameters *-----------------------------------------------------------------*/ - hParamMC->slot_size = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX; - set_s( hParamMC->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); - set_s( hParamMC->subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS ); + // hParamMC->slot_size = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX; + Word16 temp_e; + Word16 temp = BASOP_Util_Divide3232_Scale( output_Fs, FRAMES_PER_SEC, &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); + temp = BASOP_Util_Divide1616_Scale( temp, CLDFB_NO_COL_MAX, &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); + hParamMC->slot_size = temp; + move16(); + set16_fx( hParamMC->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); + set16_fx( hParamMC->subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS ); hParamMC->nb_subframes = DEFAULT_JBM_SUBFRAMES_5MS; + move16(); - hParamMC->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); + // hParamMC->num_freq_bands = (int16_t)(output_Fs * INV_CLDFB_BANDWIDTH + 0.5f); + hParamMC->num_freq_bands = extract_l( Mpy_32_32_r( output_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ); + move16(); hParamMC->max_band_energy_compensation = hParamMC->num_freq_bands; + move16(); #ifndef FIX_901_PARAMMC_DEAD_CODE ivas_param_mc_metadata_open( mc_ls_setup, hTransportSetup.index_lfe[0], ivas_total_brate, hParamMC->hMetadataPMC ); #else @@ -302,42 +344,45 @@ ivas_error ivas_param_mc_dec_open_fx( /* init arrays for quantized parameters */ - if ( ( hParamMC->icc_q_fx = (Word16 *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe * sizeof( Word16 ) ) ) == NULL ) + IF( ( hParamMC->icc_q_fx = (Word16 *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } - if ( ( hParamMC->icld_q_fx = (Word16 *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe * sizeof( Word16 ) ) ) == NULL ) + IF( ( hParamMC->icld_q_fx = (Word16 *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } - set16_fx( hParamMC->icld_q_fx, PARAM_MC_DEFAULT_MIN_ILD_FX, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); - set16_fx( hParamMC->icc_q_fx, 0, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ); + set16_fx( hParamMC->icld_q_fx, PARAM_MC_DEFAULT_MIN_ILD_FX, imult1616( hParamMC->hMetadataPMC->num_parameter_bands, hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ) ); + set16_fx( hParamMC->icc_q_fx, 0, imult1616( hParamMC->hMetadataPMC->num_parameter_bands, hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ) ); param_mc_set_num_synth_bands( output_Fs, hParamMC ); /* Band Grouping */ - if ( hParamMC->hMetadataPMC->num_parameter_bands == 20 ) + IF( EQ_16( hParamMC->hMetadataPMC->num_parameter_bands, 20 ) ) { - mvs2s( param_mc_band_grouping_20, hParamMC->band_grouping, 20 + 1 ); + Copy( param_mc_band_grouping_20, hParamMC->band_grouping, 20 + 1 ); } - else if ( hParamMC->hMetadataPMC->num_parameter_bands == 14 ) + ELSE IF( EQ_16( hParamMC->hMetadataPMC->num_parameter_bands, 14 ) ) { - mvs2s( param_mc_band_grouping_14, hParamMC->band_grouping, 14 + 1 ); + Copy( param_mc_band_grouping_14, hParamMC->band_grouping, 14 + 1 ); } - else if ( hParamMC->hMetadataPMC->num_parameter_bands == 10 ) + ELSE IF( EQ_16( hParamMC->hMetadataPMC->num_parameter_bands, 10 ) ) { - mvs2s( param_mc_band_grouping_10, hParamMC->band_grouping, 10 + 1 ); + Copy( param_mc_band_grouping_10, hParamMC->band_grouping, 10 + 1 ); } - else + ELSE { assert( 0 && "nbands must be 20, 14, or 10!" ); } /* set max parameter band for abs cov */ k = 0; - while ( hParamMC->band_grouping[k] <= PARAM_MC_MAX_BAND_ABS_COV_DEC ) + move16(); + WHILE( LE_16( hParamMC->band_grouping[k], PARAM_MC_MAX_BAND_ABS_COV_DEC ) ) { - hParamMC->max_param_band_abs_cov = ( k++ ); + hParamMC->max_param_band_abs_cov = k; + move16(); + k = add( k, 1 ); } /*-----------------------------------------------------------------* @@ -346,15 +391,18 @@ ivas_error ivas_param_mc_dec_open_fx( /* prototype signal computation */ - if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB || hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + test(); + test(); + IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { - if ( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } /* convert the ls conv dmx matrix into column order matrix format (nchan_out_cldfb x nchan_out) */ - if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + test(); + IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { #if 0 /*TODO: To be removed later (floating point malloc)*/ if ( ( hParamMC->ls_conv_dmx_matrix = (float *) malloc( nchan_out_transport * nchan_out_cov * sizeof( float ) ) ) == NULL ) @@ -367,84 +415,93 @@ ivas_error ivas_param_mc_dec_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } - for ( k = 0; k < nchan_out_transport; k++ ) + FOR( k = 0; k < nchan_out_transport; k++ ) { - Copy32( st_ivas->hLsSetUpConversion->dmxMtx_fx[k], &hParamMC->ls_conv_dmx_matrix_fx[k * nchan_out_cov], nchan_out_cov ); /*Q30*/ + Copy32( st_ivas->hLsSetUpConversion->dmxMtx_fx[k], &hParamMC->ls_conv_dmx_matrix_fx[L_mult0( k, nchan_out_cov )], nchan_out_cov ); /*Q30*/ } /* convert ParamMC parameter bands to SFB */ - if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { st_ivas->hLsSetUpConversion->sfbCnt = hParamMC->num_param_bands_synth; - for ( k = 0; k <= hParamMC->num_param_bands_synth; k++ ) + move16(); + FOR( k = 0; k <= hParamMC->num_param_bands_synth; k++ ) { - st_ivas->hLsSetUpConversion->sfbOffset[k] = PARAM_MC_BAND_TO_MDCT_BAND_RATIO * hParamMC->band_grouping[k]; + st_ivas->hLsSetUpConversion->sfbOffset[k] = imult1616( PARAM_MC_BAND_TO_MDCT_BAND_RATIO, hParamMC->band_grouping[k] ); + move16(); } } - else + ELSE { /* close the ls conversion handle immediately, it was only needed to get the DMX matrix in case of DMX in the covariance domain */ ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); } } } - if ( ( hParamMC->proto_matrix_int_fx = (Word32 *) malloc( nchan_out_transport * nchan_transport * sizeof( Word32 ) ) ) == NULL ) + IF( ( hParamMC->proto_matrix_int_fx = (Word32 *) malloc( nchan_out_transport * nchan_transport * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } - Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, hParamMC->proto_matrix_int_fx, nchan_transport * nchan_out_transport ); /*Q31*/ + Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, hParamMC->proto_matrix_int_fx, imult1616( nchan_transport, nchan_out_transport ) ); /*Q31*/ - hParamMC->proto_matrix_int_len = nchan_out_transport * nchan_transport; + hParamMC->proto_matrix_int_len = imult1616( nchan_out_transport, nchan_transport ); move16(); - if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + test(); + IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { - Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, nchan_out_transport * nchan_out_cov, -4 ); /*Q.26*/ + Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, imult1616( nchan_out_transport, nchan_out_cov ), -4 ); /*Q.26*/ matrix_product_fx( hParamMC->ls_conv_dmx_matrix_fx, nchan_out_cov, nchan_out_transport, 0, ivas_param_mc_conf[config_index].dmx_fac_fx, nchan_out_transport, nchan_transport, 0, proto_matrix_fx ); /*Q.26*/ - Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, nchan_out_transport * nchan_out_cov, 4 ); /*Q.26*/ - if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, imult1616( nchan_out_transport, nchan_out_cov ), 4 ); /*Q.26*/ + IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { proto_mtx_norm_fx = ONE_IN_Q26; /*Q26*/ - for ( k = 0; k < nchan_transport * nchan_out_cov; k++ ) + move32(); + FOR( k = 0; k < imult1616( nchan_transport, nchan_out_cov ); k++ ) { proto_mtx_norm_fx = L_max( L_abs( proto_mtx_norm_fx ), L_abs( proto_matrix_fx[k] ) ); /*Q.26*/ } proto_mtx_norm_fx = divide3232( ONE_IN_Q26, proto_mtx_norm_fx ); /*Q15*/ /* transfer flattened proto_matrix to 2D in hLsSetupConversion->dmxMtx */ - for ( k = 0; k < nchan_transport; k++ ) + FOR( k = 0; k < nchan_transport; k++ ) { - for ( int16_t i = 0; i < nchan_out_cov; i++ ) + FOR( Word16 i = 0; i < nchan_out_cov; i++ ) { - st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i] = L_shl( Mult_32_16( proto_matrix_fx[k * nchan_out_cov + i], extract_l( proto_mtx_norm_fx ) ), 4 ); /*Q.30*/ + st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i] = L_shl( Mult_32_16( proto_matrix_fx[add( imult1616( k, nchan_out_cov ), i )], extract_l( proto_mtx_norm_fx ) ), 4 ); /*Q.30*/ + move32(); } } } } - else + ELSE { - Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, proto_matrix_fx, nchan_out_transport * nchan_transport ); /*Q.31*/ - Scale_sig32( proto_matrix_fx, nchan_out_transport * nchan_transport, -5 ); /*Scaling down to 26*/ + Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, proto_matrix_fx, imult1616( nchan_out_transport, nchan_transport ) ); /*Q.31*/ + Scale_sig32( proto_matrix_fx, imult1616( nchan_out_transport, nchan_transport ), -5 ); /*Scaling down to 26*/ } - if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { hParamMC->num_outputs_diff = 0; + move16(); hParamMC->diff_proto_info = NULL; hParamMC->h_output_synthesis_params.use_onset_filters = 0; + move16(); hParamMC->max_band_decorr = 0; + move16(); hParamMC->h_freq_domain_decorr_ap_params = NULL; hParamMC->h_freq_domain_decorr_ap_state = NULL; } - else + ELSE { hParamMC->num_outputs_diff = nchan_out_cov; - if ( ( hParamMC->diff_proto_info = (PARAM_MC_DIFF_PROTO_INFO *) malloc( sizeof( PARAM_MC_DIFF_PROTO_INFO ) ) ) == NULL ) + move16(); + IF( ( hParamMC->diff_proto_info = (PARAM_MC_DIFF_PROTO_INFO *) malloc( sizeof( PARAM_MC_DIFF_PROTO_INFO ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } - if ( ( error = param_mc_get_diff_proto_info_fx( proto_matrix_fx, nchan_transport, nchan_out_cov, hParamMC->diff_proto_info, Q26 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = param_mc_get_diff_proto_info_fx( proto_matrix_fx, nchan_transport, nchan_out_cov, hParamMC->diff_proto_info, Q26 ) ), IVAS_ERR_OK ) ) { return error; } @@ -455,30 +512,36 @@ ivas_error ivas_param_mc_dec_open_fx( ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, output_Fs, hParamMC->num_freq_bands ); - IF( ( error = ivas_dirac_dec_decorr_open_fx( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, hParamMC->diff_proto_info->num_protos_diff, - DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis_fx, nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, + hParamMC->diff_proto_info->num_protos_diff, DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis_fx, nchan_transport, output_Fs ) ), + IVAS_ERR_OK ) ) { return error; } hParamMC->h_output_synthesis_params.use_onset_filters = 0; + move16(); hParamMC->max_band_decorr = hParamMC->h_freq_domain_decorr_ap_params->max_band_decorr; + move16(); } hParamMC->max_band_energy_compensation = hParamMC->band_grouping[hParamMC->hMetadataPMC->nbands_coded]; + move16(); max_param_band_residual = 0; + move16(); - for ( k = hParamMC->hMetadataPMC->num_parameter_bands; k >= 0; k-- ) + FOR( k = hParamMC->hMetadataPMC->num_parameter_bands; k >= 0; k-- ) { - if ( hParamMC->band_grouping[k] <= hParamMC->max_band_decorr ) + IF( LE_16( hParamMC->band_grouping[k], hParamMC->max_band_decorr ) ) { max_param_band_residual = k; + move16(); assert( hParamMC->band_grouping[k] == hParamMC->max_band_decorr ); break; } } /* output synthesis */ - if ( ( error = ivas_dirac_dec_output_synthesis_cov_open_fx( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix_fx ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_dec_output_synthesis_cov_open_fx( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix_fx ) ), IVAS_ERR_OK ) ) { return error; } @@ -486,7 +549,10 @@ ivas_error ivas_param_mc_dec_open_fx( ivas_param_mc_dec_compute_interpolator_fx( 0, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hParamMC->h_output_synthesis_params.interpolator_fx ); /* Head or external rotation */ - if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + test(); + test(); + test(); + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) { IF( ( hParamMC->hoa_encoder_fx = (Word32 *) malloc( st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS * sizeof( Word32 ) ) ) == NULL ) { @@ -499,7 +565,7 @@ ivas_error ivas_param_mc_dec_open_fx( * memory allocation *-----------------------------------------------------------------*/ - IF( GT_16( hParamMC->max_band_decorr, 0 ) ) + IF( hParamMC->max_band_decorr > 0 ) { IF( ( hParamMC->proto_frame_f_fx = (Word32 *) malloc( 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) { @@ -518,32 +584,36 @@ ivas_error ivas_param_mc_dec_open_fx( ivas_param_mc_dec_init_fx( hParamMC, nchan_transport, nchan_out_cov ); - IF( hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) + IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { Word16 n_cldfb_slots; n_cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; + move16(); IF( st_ivas->hDecoderConfig->Opt_tsm ) { n_cldfb_slots = MAX_JBM_CLDFB_TIMESLOTS; + move16(); } - IF( ( hParamMC->Cldfb_RealBuffer_tc_fx = (Word32 *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) + Word16 cldfb_buf_size = imult1616( imult1616( n_cldfb_slots, nchan_transport ), hParamMC->num_freq_bands ); + IF( ( hParamMC->Cldfb_RealBuffer_tc_fx = (Word32 *) malloc( cldfb_buf_size * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } - set32_fx( hParamMC->Cldfb_RealBuffer_tc_fx, 0, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); - IF( ( hParamMC->Cldfb_ImagBuffer_tc_fx = (Word32 *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) + set32_fx( hParamMC->Cldfb_RealBuffer_tc_fx, 0, cldfb_buf_size ); + IF( ( hParamMC->Cldfb_ImagBuffer_tc_fx = (Word32 *) malloc( cldfb_buf_size * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } - set32_fx( hParamMC->Cldfb_ImagBuffer_tc_fx, 0, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); + set32_fx( hParamMC->Cldfb_ImagBuffer_tc_fx, 0, cldfb_buf_size ); - hParamMC->sz = n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands; + hParamMC->sz = imult1616( imult1616( n_cldfb_slots, nchan_transport ), hParamMC->num_freq_bands ); + move16(); IF( st_ivas->hTcBuffer == NULL ) { - IF( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { return error; } @@ -556,7 +626,9 @@ ivas_error ivas_param_mc_dec_open_fx( } hParamMC->subframes_rendered = 0; + move16(); hParamMC->slots_rendered = 0; + move16(); st_ivas->hParamMC = hParamMC; return error; @@ -974,6 +1046,7 @@ static void ivas_param_mc_get_param_band_mapping( FOR( source_band_idx = 0; source_band_idx < n_source_bands; source_band_idx++ ) { /* find lowest corresponding source band*/ + test(); IF( LE_16( source_band_grouping[source_band_idx], lower ) && GE_16( source_band_grouping[source_band_idx + 1], lower ) ) { DO @@ -997,6 +1070,7 @@ static void ivas_param_mc_get_param_band_mapping( for ( source_band_idx = 0; source_band_idx < source_band_in_target_band_cnt; source_band_idx++ ) { parameter_band_mapping->source_band_factor_fx[target_band_idx][source_band_idx] = shl_sat( mult( parameter_band_mapping->source_band_factor_fx[target_band_idx][source_band_idx], norm_fac_fx ) /*Q10*/, 5 ); /*Q15*/ + move16(); } parameter_band_mapping->n_source_bands[target_band_idx] = source_band_in_target_band_cnt; move16(); @@ -1087,22 +1161,28 @@ ivas_error ivas_param_mc_dec_reconfig_fx( hParamMC = st_ivas->hParamMC; error = IVAS_ERR_OK; + move32(); /* save important config information from the previous state */ nchan_transport_old = st_ivas->nchan_transport; + move32(); num_param_bands_old = hParamMC->hMetadataPMC->num_parameter_bands; + move32(); /*-----------------------------------------------------------------* * prepare library opening *-----------------------------------------------------------------*/ output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + move32(); #ifndef FIX_901_PARAMMC_DEAD_CODE hTransportSetup = st_ivas->hTransSetup; #endif mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ); nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); + test(); IF( EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); @@ -1110,24 +1190,33 @@ ivas_error ivas_param_mc_dec_reconfig_fx( ELSE { nchan_out_cov = nchan_out_transport; + move16(); } st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); + move16(); config_index = ivas_param_mc_get_configuration_index( mc_ls_setup, ivas_total_brate ); nchan_transport = st_ivas->nchan_transport; + move16(); SWITCH( nchan_transport ) { case 4: case 3: st_ivas->nCPE = 2; + move16(); st_ivas->nSCE = 0; + move16(); st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); BREAK; case 2: st_ivas->nCPE = 1; + move16(); st_ivas->nSCE = 0; + move16(); st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); BREAK; } @@ -1136,7 +1225,9 @@ ivas_error ivas_param_mc_dec_reconfig_fx( * set input parameters *-----------------------------------------------------------------*/ hParamMC->num_freq_bands = shr( add( (Word16) Mpy_32_32( output_Fs, INV_CLDFB_BANDWIDTH_Q31 << 1 ), 1 ), 1 ); + move16(); hParamMC->max_band_energy_compensation = hParamMC->num_freq_bands; + move16(); #ifndef FIX_901_PARAMMC_DEAD_CODE /* deallocate the full icc map, gets newly allocated in the metadata open function */ @@ -1176,6 +1267,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( ivas_param_mc_get_param_band_mapping( hParamMC->hMetadataPMC->num_parameter_bands, hParamMC->band_grouping, num_param_bands_old, band_grouping_old, ¶meter_band_mapping ); + test(); IF( NE_16( nchan_transport_old, nchan_transport ) || NE_16( num_param_bands_old, hParamMC->hMetadataPMC->num_parameter_bands ) ) { Word16 *ild_q_old_fx = hParamMC->icld_q_fx; @@ -1193,6 +1285,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( set16_fx( hParamMC->icc_q_fx, 0, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ); /*Q15*/ /* map old to new parameter banding, only for same number of TCs, needs some more thought for a changing number of TCs */ + test(); IF( NE_16( num_param_bands_old, hParamMC->hMetadataPMC->num_parameter_bands ) && EQ_16( nchan_transport_old, nchan_transport ) ) { Word16 new_param_band_idx, param_idx, source_param_idx; @@ -1200,18 +1293,22 @@ ivas_error ivas_param_mc_dec_reconfig_fx( Word16 *p_icc_new_fx = hParamMC->icc_q_fx; Word16 *p_ild_new_fx = hParamMC->icld_q_fx; Word16 p_ild_new_e = 23; + move16(); Word16 p_ild_new_tmp; /* ICC */ num_param_lfe = hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe; + move16(); FOR( new_param_band_idx = 0; new_param_band_idx < hParamMC->hMetadataPMC->num_parameter_bands; new_param_band_idx++ ) { FOR( param_idx = 0; param_idx < num_param_lfe; param_idx++ ) { *p_icc_new_fx = 0; + move16(); FOR( source_param_idx = 0; source_param_idx < parameter_band_mapping.n_source_bands[new_param_band_idx]; source_param_idx++ ) { *p_icc_new_fx = add( *p_icc_new_fx, mult( icc_q_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx] * num_param_lfe + param_idx], parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx] ) ); /*Q15*/ + move16(); } p_icc_new_fx++; } @@ -1219,17 +1316,21 @@ ivas_error ivas_param_mc_dec_reconfig_fx( /* ILD */ num_param_lfe = hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe; + move16(); FOR( new_param_band_idx = 0; new_param_band_idx < hParamMC->hMetadataPMC->num_parameter_bands; new_param_band_idx++ ) { FOR( param_idx = 0; param_idx < num_param_lfe; param_idx++ ) { *p_ild_new_fx = 0; + move16(); FOR( source_param_idx = 0; source_param_idx < parameter_band_mapping.n_source_bands[new_param_band_idx]; source_param_idx++ ) { p_ild_new_tmp = extract_h( BASOP_util_Pow2( L_mult0( 10885 /*log2(10)/10*2^15*/, ild_q_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx] * num_param_lfe + param_idx] ), 8, &p_ild_new_e ) ); *p_ild_new_fx = add( *p_ild_new_fx, mult( p_ild_new_tmp, parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx] ) ); + move16(); } *p_ild_new_fx = extract_l( L_shr( Mpy_32_16_1( L_add( BASOP_Util_Log2( *p_ild_new_fx ), L_add( 16 << Q25, p_ild_new_e << 25 ) ), 24660 ), 15 ) ); + move16(); p_ild_new_fx++; } } @@ -1242,9 +1343,12 @@ ivas_error ivas_param_mc_dec_reconfig_fx( /* set max parameter band for abs cov */ k = 0; + move16(); WHILE( LE_16( hParamMC->band_grouping[k], PARAM_MC_MAX_BAND_ABS_COV_DEC ) ) { - hParamMC->max_param_band_abs_cov = ( k++ ); + hParamMC->max_param_band_abs_cov = k; + move16(); + k = add( k, 1 ); } /*-----------------------------------------------------------------* @@ -1262,22 +1366,14 @@ ivas_error ivas_param_mc_dec_reconfig_fx( ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); } - IF( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } /* convert the ls conv dmx matrix into column order matrix format (nchan_out_cldfb x nchan_out) */ -#if 0 /*To be removed later*/ - free( hParamMC->ls_conv_dmx_matrix ); -#endif free( hParamMC->ls_conv_dmx_matrix_fx ); -#if 0 - IF ( ( hParamMC->ls_conv_dmx_matrix = (float *) malloc( nchan_out_transport * nchan_out_cov * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); - } -#endif + IF( ( hParamMC->ls_conv_dmx_matrix_fx = (Word32 *) malloc( nchan_out_transport * nchan_out_cov * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); @@ -1290,13 +1386,16 @@ ivas_error ivas_param_mc_dec_reconfig_fx( /* convert ParamMC parameter bands to SFB */ st_ivas->hLsSetUpConversion->sfbCnt = hParamMC->num_param_bands_synth; + move16(); FOR( k = 0; k <= hParamMC->num_param_bands_synth; k++ ) { - st_ivas->hLsSetUpConversion->sfbOffset[k] = PARAM_MC_BAND_TO_MDCT_BAND_RATIO * hParamMC->band_grouping[k]; + st_ivas->hLsSetUpConversion->sfbOffset[k] = imult1616( PARAM_MC_BAND_TO_MDCT_BAND_RATIO, hParamMC->band_grouping[k] ); + move16(); } FOR( ; k < MAX_SFB + 2; k++ ) { st_ivas->hLsSetUpConversion->sfbOffset[k] = 0; + move16(); } } @@ -1307,23 +1406,25 @@ ivas_error ivas_param_mc_dec_reconfig_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } - hParamMC->proto_matrix_int_len = nchan_out_transport * nchan_transport; + hParamMC->proto_matrix_int_len = imult1616( nchan_out_transport, nchan_transport ); move16(); - Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, hParamMC->proto_matrix_int_fx, nchan_transport * nchan_out_transport ); /*Q31*/ + Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, hParamMC->proto_matrix_int_fx, hParamMC->proto_matrix_int_len ); /*Q31*/ } + test(); IF( EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { - Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, nchan_out_transport * nchan_out_cov, -4 ); + Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, imult1616( nchan_out_transport, nchan_out_cov ), -4 ); matrix_product_fx( hParamMC->ls_conv_dmx_matrix_fx, nchan_out_cov, nchan_out_transport, 0, ivas_param_mc_conf[config_index].dmx_fac_fx, nchan_out_transport, nchan_transport, 0, proto_matrix_fx /*Q26*/ ); - Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, nchan_out_transport * nchan_out_cov, 4 ); + Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, imult1616( nchan_out_transport, nchan_out_cov ), 4 ); IF( EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { proto_mtx_norm_fx = ONE_IN_Q26; - FOR( k = 0; k < nchan_transport * nchan_out_cov; k++ ) + move32(); + FOR( k = 0; k < imult1616( nchan_transport, nchan_out_cov ); k++ ) { proto_mtx_norm_fx = L_max( L_abs( proto_mtx_norm_fx ), L_abs( proto_matrix_fx[k] ) ); } @@ -1335,16 +1436,18 @@ ivas_error ivas_param_mc_dec_reconfig_fx( FOR( Word16 i = 0; i < nchan_out_cov; i++ ) { st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i] = L_shl( Mpy_32_16_1( proto_matrix_fx[k * nchan_out_cov + i], (Word16) proto_mtx_norm_fx ), 4 ); + move32(); } } } } ELSE { - Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, proto_matrix_fx, nchan_out_transport * nchan_transport ); - Scale_sig32( proto_matrix_fx, nchan_out_transport * nchan_transport, -5 ); + Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, proto_matrix_fx, imult1616( nchan_out_transport, nchan_transport ) ); + Scale_sig32( proto_matrix_fx, imult1616( nchan_out_transport, nchan_transport ), -5 ); } + test(); IF( NE_16( nchan_transport_old, nchan_transport ) && NE_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { Word16 i; @@ -1392,6 +1495,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( } hParamMC->num_outputs_diff = nchan_out_cov; + move16(); IF( ( hParamMC->diff_proto_info = (PARAM_MC_DIFF_PROTO_INFO *) malloc( sizeof( PARAM_MC_DIFF_PROTO_INFO ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); @@ -1408,38 +1512,46 @@ ivas_error ivas_param_mc_dec_reconfig_fx( Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, output_Fs, hParamMC->num_freq_bands ); - IF( ( error = ivas_dirac_dec_decorr_open_fx( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, - hParamMC->diff_proto_info->num_protos_diff, DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis_fx, nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, + hParamMC->diff_proto_info->num_protos_diff, DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis_fx, nchan_transport, output_Fs ) ), + IVAS_ERR_OK ) ) { return error; } hParamMC->h_output_synthesis_params.use_onset_filters = 0; + move16(); hParamMC->max_band_decorr = hParamMC->h_freq_domain_decorr_ap_params->max_band_decorr; + move16(); /* init decorrelation */ - IF( GT_16( hParamMC->max_band_decorr, 0 ) ) + IF( hParamMC->max_band_decorr > 0 ) { - len = hParamMC->diff_proto_info->num_protos_diff * hParamMC->h_freq_domain_decorr_ap_params->h_onset_detection_power_params.max_band_decorr; + len = imult1616( hParamMC->diff_proto_info->num_protos_diff, hParamMC->h_freq_domain_decorr_ap_params->h_onset_detection_power_params.max_band_decorr ); /* init onsetDetectionPower */ set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx, len ); set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx, len ); hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.q_onset_detector = Q31; + move16(); } } hParamMC->max_band_energy_compensation = hParamMC->band_grouping[hParamMC->hMetadataPMC->nbands_coded]; + move16(); max_param_band_residual = 0; + move16(); FOR( k = hParamMC->hMetadataPMC->num_parameter_bands; k >= 0; k-- ) { IF( LE_16( hParamMC->band_grouping[k], hParamMC->max_band_decorr ) ) { max_param_band_residual = k; + move16(); assert( hParamMC->band_grouping[k] == hParamMC->max_band_decorr ); - break; + BREAK; } } + test(); IF( NE_16( nchan_transport_old, nchan_transport ) || NE_16( num_param_bands_old, hParamMC->hMetadataPMC->num_parameter_bands ) ) { DIRAC_OUTPUT_SYNTHESIS_COV_STATE cov_state_old = hParamMC->h_output_synthesis_cov_state; @@ -1450,8 +1562,9 @@ ivas_error ivas_param_mc_dec_reconfig_fx( set_zero_fx( tmp_buf_fx, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); /* output synthesis */ - IF( ( error = ivas_dirac_dec_output_synthesis_cov_open_fx( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, - hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix_fx ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_dec_output_synthesis_cov_open_fx( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, + hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix_fx ) ), + IVAS_ERR_OK ) ) { return error; } @@ -1461,6 +1574,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( ivas_dirac_dec_output_synthesis_cov_init_fx( &( hParamMC->h_output_synthesis_cov_state ), nchan_transport, nchan_out_cov, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual ); /* map old to new parameter banding, only for same number of TCs, needs some more thought for changing number of TCs */ + test(); IF( NE_16( num_param_bands_old, hParamMC->hMetadataPMC->num_parameter_bands ) && EQ_16( nchan_transport_old, nchan_transport ) ) { Word16 new_param_band_idx, source_param_idx; @@ -1497,14 +1611,15 @@ ivas_error ivas_param_mc_dec_reconfig_fx( * memory allocation *-----------------------------------------------------------------*/ - IF( GT_16( hParamMC->max_band_decorr, 0 ) && NE_16( nchan_transport_old, nchan_transport ) ) + test(); + IF( ( hParamMC->max_band_decorr > 0 ) && NE_16( nchan_transport_old, nchan_transport ) ) { free( hParamMC->proto_frame_f_fx ); IF( ( hParamMC->proto_frame_f_fx = (Word32 *) malloc( 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } - set_zero_fx( hParamMC->proto_frame_f_fx, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands ); + set_zero_fx( hParamMC->proto_frame_f_fx, shl( imult1616( hParamMC->diff_proto_info->num_protos_diff, hParamMC->num_freq_bands ), 1 ) ); } @@ -1525,21 +1640,24 @@ ivas_error ivas_param_mc_dec_reconfig_fx( } n_cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; + move16(); IF( st_ivas->hDecoderConfig->Opt_tsm ) { n_cldfb_slots = MAX_JBM_CLDFB_TIMESLOTS; + move16(); } - IF( ( hParamMC->Cldfb_RealBuffer_tc_fx = (Word32 *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) + Word16 cldfb_size = imult1616( imult1616( n_cldfb_slots, nchan_transport ), hParamMC->num_freq_bands ); + IF( ( hParamMC->Cldfb_RealBuffer_tc_fx = (Word32 *) malloc( cldfb_size * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } - set_zero_fx( hParamMC->Cldfb_RealBuffer_tc_fx, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); + set_zero_fx( hParamMC->Cldfb_RealBuffer_tc_fx, cldfb_size ); - IF( ( hParamMC->Cldfb_ImagBuffer_tc_fx = (Word32 *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) + IF( ( hParamMC->Cldfb_ImagBuffer_tc_fx = (Word32 *) malloc( cldfb_size * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } - set_zero_fx( hParamMC->Cldfb_ImagBuffer_tc_fx, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); + set_zero_fx( hParamMC->Cldfb_ImagBuffer_tc_fx, cldfb_size ); } ELSE { @@ -2416,13 +2534,18 @@ void ivas_param_mc_dec_read_BS_fx( IF( !st->bfi ) { - metadata_bit_pos = extract_l( ivas_total_brate / FRAMES_PER_SEC - 1 ); - bits_to_copy = s_min( extract_l( ivas_total_brate / FRAMES_PER_SEC ), PARAM_MC_MAX_BITS ); + /*metadata_bit_pos = extract_l(ivas_total_brate / FRAMES_PER_SEC - 1); + bits_to_copy = s_min(extract_l(ivas_total_brate / FRAMES_PER_SEC), PARAM_MC_MAX_BITS);*/ + Word16 temp = extract_l( Mpy_32_32_r( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + metadata_bit_pos = sub( temp, 1 ); + bits_to_copy = s_min( temp, PARAM_MC_MAX_BITS ); /* copy and reverse metadata */ FOR( bit_pos = 0; bit_pos < bits_to_copy; bit_pos++ ) { - bit_buffer[bit_pos] = st->bit_stream[metadata_bit_pos--]; + bit_buffer[bit_pos] = st->bit_stream[metadata_bit_pos]; + move16(); + metadata_bit_pos = sub( metadata_bit_pos, 1 ); move16(); } @@ -2480,8 +2603,37 @@ void ivas_param_mc_dec_read_BS_fx( band_step = PARAM_MC_TRANSIENT_BAND_STEP; move16(); - num_lfe_bands = add( PARAM_MC_MAX_BAND_LFE / band_step, ( PARAM_MC_MAX_BAND_LFE % band_step ) ? 1 : 0 ); - num_param_bands = add( hMetadataPMC->nbands_coded / band_step, ( ( hMetadataPMC->nbands_coded % band_step ) ? 1 : 0 ) ); + + /*num_lfe_bands = add(PARAM_MC_MAX_BAND_LFE / band_step, (PARAM_MC_MAX_BAND_LFE % band_step) ? 1 : 0); + num_param_bands = add(hMetadataPMC->nbands_coded / band_step, ((hMetadataPMC->nbands_coded % band_step) ? 1 : 0));*/ + Word16 temp_e; + temp = BASOP_Util_Divide3232_Scale( PARAM_MC_MAX_BAND_LFE, band_step, &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); + Word16 temp1; + IF( PARAM_MC_MAX_BAND_LFE % band_step ) + { + temp1 = 1; + } + ELSE + { + temp1 = 0; + } + move16(); + num_lfe_bands = add( temp, temp1 ); + + temp = BASOP_Util_Divide3232_Scale( hMetadataPMC->nbands_coded, band_step, &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); + Word16 temp2; + IF( hMetadataPMC->nbands_coded % band_step ) + { + temp2 = 1; + } + ELSE + { + temp2 = 0; + } + move16(); + num_param_bands = add( temp, temp2 ); } ELSE { @@ -2490,7 +2642,8 @@ void ivas_param_mc_dec_read_BS_fx( IF( EQ_16( param_frame_idx, hMetadataPMC->coding_band_mapping[j] ) ) { /* LFE ICC is always the last ICC in coding band 0 */ - num_lfe_bands++; + num_lfe_bands = add( num_lfe_bands, 1 ); + move16(); } } } @@ -2573,11 +2726,11 @@ void ivas_param_mc_dec_read_BS_fx( /* set LFE ILD and ICC to zero above PARAM_MC_MAX_BAND_LFE for attack frames */ IF( hMetadataPMC->bAttackPresent ) { - FOR( k = PARAM_MC_MAX_BAND_LFE; k < band_step * num_lfe_bands; k++ ) + FOR( k = PARAM_MC_MAX_BAND_LFE; k < imult1616( band_step, num_lfe_bands ); k++ ) { - hParamMC->icc_q_fx[( k + 1 ) * icc_map_size - 1] = 32767; /* 1.0f in Q15 */ + hParamMC->icc_q_fx[L_sub( L_mult0( add( k, 1 ), icc_map_size ), 1 )] = 32767; /* 1.0f in Q15 */ move16(); - hParamMC->icld_q_fx[( k + 1 ) * ild_map_size - 1] = PARAM_MC_DEFAULT_MIN_ILD_FX; /* -92.0f in Q8 */ + hParamMC->icld_q_fx[L_sub( L_mult0( add( k, 1 ), ild_map_size ), 1 )] = PARAM_MC_DEFAULT_MIN_ILD_FX; /* -92.0f in Q8 */ move16(); } } @@ -2844,31 +2997,34 @@ void ivas_param_mc_dec_digest_tc_fx( push_wmops( "param_mc_dec_digest_tc" ); - set_s( channel_active, 0, MAX_CICP_CHANNELS ); + set16_fx( channel_active, 0, MAX_CICP_CHANNELS ); nchan_transport = st_ivas->nchan_transport; - nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + move16(); + nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); - IF( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { nchan_out_cldfb = BINAURAL_CHANNELS; move16(); - set_s( channel_active, 1, nchan_out_cldfb ); - nchan_out_cov = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + set16_fx( channel_active, 1, nchan_out_cldfb ); + nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); hSynthesisOutputSetup = &st_ivas->hTransSetup; } - ELSE IF( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) + ELSE IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) ) { nchan_out_cov = nchan_out_transport; move16(); - nchan_out_cldfb = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + nchan_out_cldfb = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); hSynthesisOutputSetup = &st_ivas->hTransSetup; } - ELSE IF( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + ELSE IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { - nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); nchan_out_cldfb = nchan_out_cov; move16(); - set_s( channel_active, 1, nchan_out_cov ); + set16_fx( channel_active, 1, nchan_out_cov ); hSynthesisOutputSetup = &st_ivas->hOutSetup; } ELSE @@ -2877,14 +3033,15 @@ void ivas_param_mc_dec_digest_tc_fx( move16(); nchan_out_cldfb = nchan_out_transport; move16(); - set_s( channel_active, 1, nchan_out_cov ); + set16_fx( channel_active, 1, nchan_out_cov ); hSynthesisOutputSetup = &st_ivas->hTransSetup; } /* adapt transient position */ IF( hParamMC->hMetadataPMC->bAttackPresent ) { - hParamMC->hMetadataPMC->attackIndex = (int16_t) max( 0, hParamMC->hMetadataPMC->attackIndex + ( ( nCldfbSlots - DEFAULT_JBM_CLDFB_TIMESLOTS ) / 2 ) ); + hParamMC->hMetadataPMC->attackIndex = s_max( 0, add( hParamMC->hMetadataPMC->attackIndex, shr( sub( nCldfbSlots, DEFAULT_JBM_CLDFB_TIMESLOTS ), 1 ) ) ); + move16(); } /* adapt subframes */ hParamMC->num_slots = nCldfbSlots; @@ -2895,7 +3052,8 @@ void ivas_param_mc_dec_digest_tc_fx( move16(); ivas_jbm_dec_get_adapted_subframes( nCldfbSlots, hParamMC->subframe_nbslots, &hParamMC->nb_subframes ); st_ivas->hTcBuffer->nb_subframes = hParamMC->nb_subframes; - mvs2s( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); + move16(); + Copy( hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hParamMC->nb_subframes ); ivas_param_mc_dec_compute_interpolator_fx( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator_fx ); @@ -2932,18 +3090,18 @@ void ivas_param_mc_dec_digest_tc_fx( move16(); cldfbAnalysis_ts_fx_fixed_q( &( transport_channels_f_fx[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch], &qout ); - Copy32( RealBuffer_fx, &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); - Copy32( ImagBuffer_fx, &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); + Copy32( RealBuffer_fx, &hParamMC->Cldfb_RealBuffer_tc_fx[L_add( L_mult0( imult1616( slot_idx, hParamMC->num_freq_bands ), nchan_transport ), L_mult0( ch, hParamMC->num_freq_bands ) )], hParamMC->num_freq_bands ); + Copy32( ImagBuffer_fx, &hParamMC->Cldfb_ImagBuffer_tc_fx[L_add( L_mult0( imult1616( slot_idx, hParamMC->num_freq_bands ), nchan_transport ), L_mult0( ch, hParamMC->num_freq_bands ) )], hParamMC->num_freq_bands ); } hParamMC->Cldfb_ImagBuffer_tc_e = qout; move16(); } - IF( slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex ) + IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) ) { - ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[L_mult0( imult1616( slot_idx, hParamMC->num_freq_bands ), nchan_transport )], /*hParamMC->Cldfb_RealBuffer_tc_e*/ Q31 - Q6, - &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], + &hParamMC->Cldfb_ImagBuffer_tc_fx[L_mult0( imult1616( slot_idx, hParamMC->num_freq_bands ), nchan_transport )], /*hParamMC->Cldfb_ImagBuffer_tc_e*/ Q31 - Q6, cx_fx, &cx_e, @@ -2959,11 +3117,13 @@ void ivas_param_mc_dec_digest_tc_fx( FOR( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) { /* Cx for transport channels */ - FOR( i = 0; i < nchan_transport * nchan_transport; i++ ) + FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) { real_part_fx = cx_fx[param_band_idx][i]; + move16(); imag_part_fx = cx_imag_fx[param_band_idx][i]; + move16(); cx_buff_e[param_band_idx][i] = cx_e; move16(); @@ -2972,8 +3132,9 @@ void ivas_param_mc_dec_digest_tc_fx( { L_tmp1 = Mpy_32_32( real_part_fx, real_part_fx ); L_tmp2 = Mpy_32_32( imag_part_fx, imag_part_fx ); - L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp1, cx_e + cx_e, L_tmp2, cx_imag_e + cx_imag_e, &tmp_e ); + L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp1, add( cx_e, cx_e ), L_tmp2, add( cx_imag_e, cx_imag_e ), &tmp_e ); cx_fx[param_band_idx][i] = Sqrt32( L_tmp1, &tmp_e ); + move32(); cx_buff_e[param_band_idx][i] = tmp_e; move16(); } @@ -2993,21 +3154,24 @@ void ivas_param_mc_dec_digest_tc_fx( FOR( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) { /* Cx for transport channels */ - FOR( i = 0; i < nchan_transport * nchan_transport; i++ ) + FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) { - IF( max_e < cx_buff_e[param_band_idx][i] ) - max_e = cx_buff_e[param_band_idx][i]; + IF( LT_16( max_e, cx_buff_e[param_band_idx][i] ) ) + { + max_e = cx_buff_e[param_band_idx][i]; + } } } FOR( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) { /* Cx for transport channels */ - FOR( i = 0; i < nchan_transport * nchan_transport; i++ ) + FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ ) { - cx_fx[param_band_idx][i] = L_shr( cx_fx[param_band_idx][i], max_e - cx_buff_e[param_band_idx][i] ); + cx_fx[param_band_idx][i] = L_shr( cx_fx[param_band_idx][i], sub( max_e, cx_buff_e[param_band_idx][i] ) ); + move32(); } } @@ -3017,12 +3181,14 @@ void ivas_param_mc_dec_digest_tc_fx( /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ + test(); + test(); IF( hParamMC->hMetadataPMC->bAttackPresent && ( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) ) { FOR( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) { - v_add_fx( cx_fx[param_band_idx], cx_fx[param_band_idx + 1], cx_fx[param_band_idx], nchan_transport * nchan_transport ); - Copy32( cx_fx[param_band_idx], cx_fx[param_band_idx + 1], nchan_transport * nchan_transport ); + v_add_fx( cx_fx[param_band_idx], cx_fx[add( param_band_idx, 1 )], cx_fx[param_band_idx], imult1616( nchan_transport, nchan_transport ) ); + Copy32( cx_fx[param_band_idx], cx_fx[add( param_band_idx, 1 )], imult1616( nchan_transport, nchan_transport ) ); } } @@ -3321,23 +3487,30 @@ void ivas_param_mc_dec_render_fx( #endif UWord32 output_Fs; Word16 tmp_q = 0; + move16(); hParamMC = st_ivas->hParamMC; assert( hParamMC ); push_wmops( "param_mc_dec_render" ); - set_s( channel_active, 0, MAX_CICP_CHANNELS ); + set16_fx( channel_active, 0, MAX_CICP_CHANNELS ); nchan_transport = st_ivas->nchan_transport; - nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + move16(); + nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); #ifndef MSAN_FIX nchan_out_init = nchan_out_transport; + move16(); #endif output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); + + test(); + test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { nchan_out_cldfb = BINAURAL_CHANNELS; - set_s( channel_active, 1, nchan_out_cldfb ); + set16_fx( channel_active, 1, nchan_out_cldfb ); #ifndef MSAN_FIX IF( st_ivas->hCombinedOrientationData ) { @@ -3349,23 +3522,28 @@ void ivas_param_mc_dec_render_fx( ELSE IF( EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) ) { nchan_out_cov = nchan_out_transport; + move16(); nchan_out_cldfb = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); } ELSE IF( EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); nchan_out_cldfb = nchan_out_cov; - set_s( channel_active, 1, nchan_out_cov ); + move16(); + set16_fx( channel_active, 1, nchan_out_cov ); } ELSE { nchan_out_cov = nchan_out_transport; + move16(); nchan_out_cldfb = nchan_out_transport; - set_s( channel_active, 1, nchan_out_cov ); + move16(); + set16_fx( channel_active, 1, nchan_out_cov ); } /* set everything to zero that will not be decoded */ nband_synth = hParamMC->band_grouping[hParamMC->num_param_bands_synth]; + move16(); #ifndef IVAS_FLOAT_FIXED nbands_to_zero = sub( hParamMC->num_freq_bands, nband_synth ); #endif @@ -3388,12 +3566,20 @@ void ivas_param_mc_dec_render_fx( } /* loop FOR synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = min( sub( hParamMC->num_slots, hParamMC->slots_rendered ), nSamplesAsked / NS2SA( output_Fs, CLDFB_SLOT_NS ) ); - *nSamplesRendered = slots_to_render * NS2SA( output_Fs, CLDFB_SLOT_NS ); + /*slots_to_render = min(sub(hParamMC->num_slots, hParamMC->slots_rendered), nSamplesAsked / NS2SA(output_Fs, CLDFB_SLOT_NS)); + *nSamplesRendered = slots_to_render * NS2SA(output_Fs, CLDFB_SLOT_NS);*/ + Word16 temp_e; + Word16 temp = BASOP_Util_Divide1616_Scale( nSamplesAsked, NS2SA( output_Fs, CLDFB_SLOT_NS ), &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); + slots_to_render = s_min( sub( hParamMC->num_slots, hParamMC->slots_rendered ), temp ); + *nSamplesRendered = imult1616( slots_to_render, NS2SA( output_Fs, CLDFB_SLOT_NS ) ); + move16(); Word16 j, k; first_sf = hParamMC->subframes_rendered; + move16(); last_sf = first_sf; - WHILE( GT_16( slots_to_render, 0 ) ) + move16(); + WHILE( slots_to_render > 0 ) { slots_to_render = sub( slots_to_render, hParamMC->subframe_nbslots[last_sf] ); last_sf = add( last_sf, 1 ); @@ -3406,17 +3592,19 @@ void ivas_param_mc_dec_render_fx( } } slot_idx_start = hParamMC->slots_rendered; + move16(); slot_idx_start_cldfb_synth = 0; + move16(); Flag is_zero = 1; - move16(); + move32(); FOR( j = 0; j < st_ivas->hParamMC->hMetadataPMC->nbands_coded; j++ ) { is_zero = 1; move16(); FOR( i = 0; i < hParamMC->h_output_synthesis_cov_state.mixing_matrix_len; i++ ) { - IF( NE_32( hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[j][i], 0 ) ) + IF( hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[j][i] != 0 ) { is_zero = 0; move16(); @@ -3429,7 +3617,7 @@ void ivas_param_mc_dec_render_fx( } is_zero = 1; move16(); - IF( st_ivas->hParamMC->band_grouping[j] < st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) + IF( LT_16( st_ivas->hParamMC->band_grouping[j], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) ) { FOR( i = 0; i < hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len; i++ ) { @@ -3451,7 +3639,7 @@ void ivas_param_mc_dec_render_fx( { FOR( slot_idx = 0; slot_idx < hParamMC->subframe_nbslots[subframe_idx]; ( slot_idx++, hParamMC->slots_rendered++ ) ) { - IF( GT_16( hParamMC->max_band_decorr, 0 ) ) + IF( hParamMC->max_band_decorr > 0 ) { /*-----------------------------------------------------------------* * protoype signal computation @@ -3460,7 +3648,7 @@ void ivas_param_mc_dec_render_fx( &hParamMC->Cldfb_ImagBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], hParamMC->proto_frame_f_fx, hParamMC->diff_proto_info, hParamMC->num_freq_bands ); - Scale_sig32( hParamMC->proto_frame_f_fx, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands, Q11 - Q5 ); + Scale_sig32( hParamMC->proto_frame_f_fx, shl( imult1616( hParamMC->diff_proto_info->num_protos_diff, hParamMC->num_freq_bands ), 1 ), Q11 - Q5 ); /*-----------------------------------------------------------------* * frequency domain decorrelation *-----------------------------------------------------------------*/ @@ -3487,10 +3675,12 @@ void ivas_param_mc_dec_render_fx( FOR( k = 0; k < nchan_out_cov; k++ ) { - FOR( int l = 0; l < hParamMC->h_output_synthesis_params.max_band_decorr; l++ ) + FOR( Word16 l = 0; l < hParamMC->h_output_synthesis_params.max_band_decorr; l++ ) { - Cldfb_RealBuffer_fx[k][slot_idx][l] = L_shl( Cldfb_RealBuffer_fx[k][slot_idx][l], 6 - tmp_q ); - Cldfb_ImagBuffer_fx[k][slot_idx][l] = L_shl( Cldfb_ImagBuffer_fx[k][slot_idx][l], 6 - tmp_q ); + Cldfb_RealBuffer_fx[k][slot_idx][l] = L_shl( Cldfb_RealBuffer_fx[k][slot_idx][l], sub( 6, tmp_q ) ); + move32(); + Cldfb_ImagBuffer_fx[k][slot_idx][l] = L_shl( Cldfb_ImagBuffer_fx[k][slot_idx][l], sub( 6, tmp_q ) ); + move32(); } } } @@ -3499,17 +3689,21 @@ void ivas_param_mc_dec_render_fx( * output synthesis *-----------------------------------------------------------------*/ ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( - &hParamMC->Cldfb_RealBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], - &hParamMC->Cldfb_ImagBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, slot_idx, slot_idx + slot_idx_start, + &hParamMC->Cldfb_RealBuffer_tc_fx[L_mult0( imult1616( hParamMC->slots_rendered, nchan_transport ), hParamMC->num_freq_bands )], + &hParamMC->Cldfb_ImagBuffer_tc_fx[L_mult0( imult1616( hParamMC->slots_rendered, nchan_transport ), hParamMC->num_freq_bands )], Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, slot_idx, add( slot_idx, slot_idx_start ), nchan_transport, nchan_out_cov, hParamMC ); + test(); IF( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { + test(); IF( st_ivas->hCombinedOrientationData && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { Word16 Q_Cldfb_ImagBuffer, Q_Cldfb_RealBuffer; - Q_Cldfb_ImagBuffer = sub( Q6, 5 ); /*max value =MAX_INTERN_CHANNELS(=16)*Cldfb_ImagBuffer_fx*/ - Q_Cldfb_RealBuffer = sub( Q6, 5 ); + Q_Cldfb_ImagBuffer = Q6 - 5; /*max value =MAX_INTERN_CHANNELS(=16)*Cldfb_ImagBuffer_fx*/ + move16(); + Q_Cldfb_RealBuffer = Q6 - 5; + move16(); FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) @@ -3540,8 +3734,9 @@ void ivas_param_mc_dec_render_fx( IF( st_ivas->hBinRenderer->render_lfe ) { Word16 tmp_exp = 0; + move16(); Word16 tmp = BASOP_Util_Divide1616_Scale( GAIN_LFE_FX, hLsSetup.nchan_out_woLFE, &tmp_exp ); - tmp_exp = tmp_exp + ( 1 - 15 ); + tmp_exp = add( tmp_exp, ( 1 - 15 ) ); FOR( idx_lfe = 0; idx_lfe < hLsSetup.num_lfe; idx_lfe++ ) { /* Copy just the first band of LFE*/ @@ -3562,11 +3757,14 @@ void ivas_param_mc_dec_render_fx( } idx_out = 0; + move16(); idx_lfe = 0; + move16(); FOR( ch = 0; ch < ( hLsSetup.nchan_out_woLFE + hLsSetup.num_lfe ); ch++ ) { - IF( ( GT_16( hLsSetup.num_lfe, 0 ) ) && ( EQ_16( hLsSetup.index_lfe[idx_lfe], ch ) ) ) + test(); + IF( ( hLsSetup.num_lfe > 0 ) && EQ_16( hLsSetup.index_lfe[idx_lfe], ch ) ) { IF( LT_16( idx_lfe, ( sub( hLsSetup.num_lfe, 1 ) ) ) ) { @@ -3588,9 +3786,11 @@ void ivas_param_mc_dec_render_fx( } } + test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { Word16 input_q = 6; + move16(); /* Implement binaural rendering */ ivas_binRenderer_fx( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, @@ -3611,9 +3811,9 @@ void ivas_param_mc_dec_render_fx( } } - FOR( int idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) + FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) { - FOR( int idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) + FOR( Word16 idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) { Scale_sig32( Cldfb_RealBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); @@ -3652,16 +3852,16 @@ void ivas_param_mc_dec_render_fx( } } - Word16 len = slot_idx_start_cldfb_synth * hParamMC->num_freq_bands + hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx]; + Word16 len = add( imult1616( slot_idx_start_cldfb_synth, hParamMC->num_freq_bands ), imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ) ); scale_sig32( output_f_fx[ch], len, 5 - 11 ); - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), - hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][L_mult0( slot_idx_start_cldfb_synth, hParamMC->num_freq_bands )] ), + imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), st_ivas->cldfbSynDec[ch] ); scale_sig32( output_f_fx[ch], len, 11 - 5 ); } ELSE { - set32_fx( &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), 0, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); + set32_fx( &( output_f_fx[ch][L_mult0( slot_idx_start_cldfb_synth, hParamMC->num_freq_bands )] ), 0, imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ) ); } } slot_idx_start = add( slot_idx_start, hParamMC->subframe_nbslots[subframe_idx] ); @@ -3677,16 +3877,20 @@ void ivas_param_mc_dec_render_fx( IF( EQ_16( hParamMC->slots_rendered, hParamMC->num_slots ) ) { hParamMC->hMetadataPMC->last_coded_bwidth = hParamMC->hMetadataPMC->coded_bwidth; + move16(); param_mc_update_mixing_matrices_fx( hParamMC, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_transport, nchan_out_cov ); } hParamMC->subframes_rendered = last_sf; - *nSamplesAvailableNext = ( hParamMC->num_slots - hParamMC->slots_rendered ) * NS2SA( output_Fs, CLDFB_SLOT_NS ); + move16(); + *nSamplesAvailableNext = imult1616( sub( hParamMC->num_slots, hParamMC->slots_rendered ), NS2SA( output_Fs, CLDFB_SLOT_NS ) ); + move16(); FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { channel_active_fx[i] = channel_active[i]; + move16(); } pop_wmops(); @@ -4036,17 +4240,19 @@ static void ivas_param_mc_dec_init_fx( *-----------------------------------------------------------------*/ /* decorrelation */ - IF( GT_16( hParamMC->max_band_decorr, 0 ) ) + IF( hParamMC->max_band_decorr > 0 ) { - len = hParamMC->diff_proto_info->num_protos_diff * hParamMC->h_freq_domain_decorr_ap_params->h_onset_detection_power_params.max_band_decorr; + len = imult1616( hParamMC->diff_proto_info->num_protos_diff, hParamMC->h_freq_domain_decorr_ap_params->h_onset_detection_power_params.max_band_decorr ); /* init onsetDetectionPower */ set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx, len ); set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx, len ); hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.q_onset_detector = Q31; + move16(); } max_param_band_residual = 0; + move16(); /* output synthesis */ FOR( k = hParamMC->hMetadataPMC->num_parameter_bands; k >= 0; k-- ) @@ -4054,7 +4260,8 @@ static void ivas_param_mc_dec_init_fx( IF( LE_16( hParamMC->band_grouping[k], hParamMC->max_band_decorr ) ) { max_param_band_residual = k; - break; + move16(); + BREAK; } } @@ -4064,10 +4271,10 @@ static void ivas_param_mc_dec_init_fx( * init proto frames *-----------------------------------------------------------------*/ - IF( GT_16( hParamMC->max_band_decorr, 0 ) ) + IF( hParamMC->max_band_decorr > 0 ) { - set_zero_fx( hParamMC->proto_frame_f_fx, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands ); - set32_fx( hParamMC->proto_frame_dec_f_fx, 0, 2 * nchan_cov * hParamMC->num_freq_bands ); + set_zero_fx( hParamMC->proto_frame_f_fx, shl( imult1616( hParamMC->diff_proto_info->num_protos_diff, hParamMC->num_freq_bands ), 1 ) ); + set32_fx( hParamMC->proto_frame_dec_f_fx, 0, shl( imult1616( nchan_cov, hParamMC->num_freq_bands ), 1 ) ); } return; @@ -4195,7 +4402,7 @@ static void param_mc_protoSignalComputation_fx( Word32 *p_real_buffer_fx; // Q12 Word32 *p_imag_buffer_fx; // Q12 - set32_fx( proto_frame_f_fx, 0, 2 * num_freq_bands * diff_proto_info->num_protos_diff ); + set32_fx( proto_frame_f_fx, 0, shl( imult1616( num_freq_bands, diff_proto_info->num_protos_diff ), 1 ) ); FOR( proto_ch_idx = 0; proto_ch_idx < diff_proto_info->num_protos_diff; proto_ch_idx++ ) @@ -4212,9 +4419,9 @@ static void param_mc_protoSignalComputation_fx( Word16 source_ch_idx = diff_proto_info->source_chan_idx[proto_ch_idx][source_ch_cnt]; move16(); - p_proto_frame_fx = &proto_frame_f_fx[proto_ch_idx * num_freq_bands * 2]; - p_real_buffer_fx = &RealBuffer_fx[source_ch_idx * num_freq_bands]; - p_imag_buffer_fx = &ImagBuffer_fx[source_ch_idx * num_freq_bands]; + p_proto_frame_fx = &proto_frame_f_fx[shl( imult1616( proto_ch_idx, num_freq_bands ), 1 )]; + p_real_buffer_fx = &RealBuffer_fx[imult1616( source_ch_idx, num_freq_bands )]; + p_imag_buffer_fx = &ImagBuffer_fx[imult1616( source_ch_idx, num_freq_bands )]; FOR( band = 0; band < num_freq_bands; band++ ) { @@ -4258,7 +4465,9 @@ static void ivas_param_mc_dec_copy_diffuse_proto( Word16 num_freq_bands, num_freq_bands_diff; Word32 *p_proto_diff_fx; num_freq_bands = hParamMC->num_freq_bands; + move16(); num_freq_bands_diff = hParamMC->h_output_synthesis_params.max_band_decorr; + move16(); FOR( k = 0; k < nY; k++ ) { @@ -4267,7 +4476,9 @@ static void ivas_param_mc_dec_copy_diffuse_proto( FOR( l = 0; l < num_freq_bands_diff; l++ ) { Cldfb_buffer_real_fx[k][slot_idx][l] = *( p_proto_diff_fx++ ); + move32(); Cldfb_buffer_imag_fx[k][slot_idx][l] = *( p_proto_diff_fx++ ); + move32(); } } @@ -4309,6 +4520,26 @@ static void ivas_param_mc_dec_copy_diffuse_proto( * decode a number of bits to an integer *------------------------------------------------------------------------*/ /* r : decoded integer */ +#ifdef IVAS_FLOAT_FIXED +static Word16 ivas_param_mc_bin2dec_fx( + UWord16 bits[PARAM_MC_MAX_BITS], /* i : bit buffer */ + const Word16 N /* i : number of bits to decode */ +) +{ + Word16 i; + Word16 out; + + assert( N <= 16 ); + out = 0; + move16(); + FOR( i = 0; i < N; i++ ) + { + out = add( out, shl( bits[i], sub( sub( N, 1 ), i ) ) ); + } + + return out; +} +#else static int16_t ivas_param_mc_bin2dec( uint16_t bits[PARAM_MC_MAX_BITS], /* i : bit buffer */ const int16_t N /* i : number of bits to decode */ @@ -4326,7 +4557,7 @@ static int16_t ivas_param_mc_bin2dec( return out; } - +#endif /*------------------------------------------------------------------------- * ivas_param_mc_uniform_decoder() @@ -4347,12 +4578,14 @@ static Word16 ivas_param_mc_uniform_decoder_fx( Word16 n_bits; n_bits = 0; + move16(); assert( N * sz_seq < PARAM_MC_MAX_BITS ); FOR( i = 0; i < sz_seq; ++i ) { - idx = ivas_param_mc_bin2dec( &bit_buffer[i * N], N ); + idx = ivas_param_mc_bin2dec_fx( &bit_buffer[i * N], N ); seq[i] = alphabet[idx]; + move16(); } n_bits = imult1616( N, sz_seq ); @@ -4393,8 +4626,8 @@ static int16_t ivas_param_mc_uniform_decoder( * * decode a sequency of inidices coded with a range coder *------------------------------------------------------------------------*/ - -static Word16 ivas_param_mc_range_decoder_LC( +#ifdef IVAS_FLOAT_FIXED +static Word16 ivas_param_mc_range_decoder_LC_fx( UWord16 *bit_buffer, /* i : bit buffer to read from */ Word16 *x, /* o : decoded indices */ Word16 *BER_detect, /* o : flag for indicating a bit error */ @@ -4414,28 +4647,75 @@ static Word16 ivas_param_mc_range_decoder_LC( /* Start Decoding */ /* Initialize range decoder */ cur_bit_pos = 0; -#ifdef IVAS_FLOAT_FIXED - rc_uni_dec_init_fx( &rc_st_dec, bit_buffer, nbbits - 32 ); /* (nbbits + 30) entries are read by the decoder */ -#else - rc_uni_dec_init( &rc_st_dec, bit_buffer, nbbits - 32 ); /* (nbbits + 30) entries are read by the decoder */ -#endif // IVAS_FLOAT_FIXED + move16(); + rc_uni_dec_init_fx( &rc_st_dec, bit_buffer, sub( nbbits, 32 ) ); /* (nbbits + 30) entries are read by the decoder */ /* Main Loop through the indices */ FOR( k = 0; k < sz_seq; k++ ) { -#ifdef IVAS_FLOAT_FIXED r = rc_uni_dec_read_symbol_fastS_fx( &rc_st_dec, cft, sft, sz_alphabet, tot_shift ); /*Alphabet size = 17 (2^4 = 16 MSB symbols + 1 ESC symbol) */ /* r is the symbol read, the possible values are {0,1,....alphabet_size - 1} */ + + /* Update bitstream pointer */ + cur_bit_pos = rc_uni_dec_virtual_finish( &rc_st_dec ); + + /* Confirm that there is no overflow */ + IF( GT_16( cur_bit_pos, nbbits ) ) + { + *BER_detect = s_or( *BER_detect, 1 ); + move16(); + } + + x[k] = r; + move16(); + } + + /* We don't need to finish because virtual_finish() already does the same */ + /*st->next_bit_pos = rc_uni_dec_finish(&rc_st_dec);*/ + + /* Check for bitstream errors */ + IF( rc_st_dec.bit_error_detected != 0 ) + { + *BER_detect = s_or( *BER_detect, 1 ); + move16(); + } + + return cur_bit_pos; +} #else +static int16_t ivas_param_mc_range_decoder_LC( + uint16_t *bit_buffer, /* i : bit buffer to read from */ + int16_t *x, /* o : decoded indices */ + int16_t *BER_detect, /* o : flag for indicating a bit error */ + const int16_t sz_seq, /* i : size of the sequence to be decoded */ + const int16_t sz_alphabet, /* i : size of the alphabet */ + const uint16_t *cft, /* i : cumulative frequency table */ + const uint16_t *sft, /* i : symbol frequency table */ + const int16_t tot_shift, /* i : total frequency as a power of 2 */ + const int16_t nbbits /* i : maximum bit budget */ +) +{ + RangeUniDecState rc_st_dec; /* State of the range decoder */ + int16_t cur_bit_pos; + int16_t k; + int16_t r; + + /* Start Decoding */ + /* Initialize range decoder */ + cur_bit_pos = 0; + rc_uni_dec_init( &rc_st_dec, bit_buffer, nbbits - 32 ); /* (nbbits + 30) entries are read by the decoder */ + + /* Main Loop through the indices */ + for ( k = 0; k < sz_seq; k++ ) + { r = rc_uni_dec_read_symbol_fastS( &rc_st_dec, cft, sft, sz_alphabet, tot_shift ); /*Alphabet size = 17 (2^4 = 16 MSB symbols + 1 ESC symbol) */ /* r is the symbol read, the possible values are {0,1,....alphabet_size - 1} */ -#endif // IVAS_FLOAT_FIXED /* Update bitstream pointer */ cur_bit_pos = rc_uni_dec_virtual_finish( &rc_st_dec ); /* Confirm that there is no overflow */ - IF( cur_bit_pos > nbbits ) + if ( cur_bit_pos > nbbits ) { *BER_detect |= 1; } @@ -4447,14 +4727,14 @@ static Word16 ivas_param_mc_range_decoder_LC( /*st->next_bit_pos = rc_uni_dec_finish(&rc_st_dec);*/ /* Check for bitstream errors */ - IF( rc_st_dec.bit_error_detected != 0 ) + if ( rc_st_dec.bit_error_detected != 0 ) { *BER_detect |= 1; } return cur_bit_pos; } - +#endif /*------------------------------------------------------------------------- * param_mc_compute_interpolator() @@ -4474,7 +4754,7 @@ static void ivas_param_mc_dec_compute_interpolator_fx( IF( bAttackPresent ) { - FOR( idx = 0; idx < 2 * attackPos; idx++ ) + FOR( idx = 0; idx < shl( attackPos, 1 ); idx++ ) { interpolator[idx] = 0; move16(); @@ -4581,11 +4861,11 @@ static void remove_lfe_from_cy_fx( ptrCy = cy; ptrCy_out = cy_woLFE; - FOR( lfe_idx1 = 0; lfe_idx1 < num_lfe + 1; lfe_idx1++ ) + FOR( lfe_idx1 = 0; lfe_idx1 < add( num_lfe, 1 ); lfe_idx1++ ) { FOR( ch_idx1 = lfe_indices[lfe_idx1] + 1; ch_idx1 < lfe_indices[lfe_idx1 + 1]; ch_idx1++ ) { - FOR( lfe_idx2 = 0; lfe_idx2 < num_lfe + 1; lfe_idx2++ ) + FOR( lfe_idx2 = 0; lfe_idx2 < add( num_lfe, 1 ); lfe_idx2++ ) { FOR( ch_idx2 = lfe_indices[lfe_idx2] + 1; ch_idx2 < lfe_indices[lfe_idx2 + 1]; ch_idx2++ ) { @@ -4991,10 +5271,6 @@ static void ivas_param_mc_get_mixing_matrices_fx( Word16 remove_lfe; Word16 lfe_indices[PARAM_MC_LOCAL_SZ_LFE_MAP]; - nY_band = nY_cov; - num_lfe_bands = 0; - remove_lfe = 0; - Word32 Cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; Word32 Cy_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; @@ -5021,6 +5297,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( Word16 tmp_e, tmp; Word16 proto_matrix_e = hParamMC->h_output_synthesis_params.proto_matrix_e; + move16(); Word32 proto_matrix_noLFE_fx[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; Word32 mat_mult_buffer1_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; @@ -5041,6 +5318,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( set_zero_fx( mixing_matrix_res_local_fx, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); #endif Word16 proto_matrix_noLFE_e = 0; + move16(); Word16 guard_bit_cx = find_guarded_bits_fx( nY_intern + 1 ); Word16 guard_bit_cy = find_guarded_bits_fx( nY_cov * nY_cov ); @@ -5051,18 +5329,23 @@ static void ivas_param_mc_get_mixing_matrices_fx( Copy32( Cx_in_fixed[i], Cx_in_fx[i], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); nY_band = nY_cov; + move16(); num_lfe_bands = 0; + move16(); remove_lfe = 0; + move16(); - set_s( lfe_indices, -1, PARAM_MC_LOCAL_SZ_LFE_MAP ); + set16_fx( lfe_indices, -1, PARAM_MC_LOCAL_SZ_LFE_MAP ); IF( hSynthesisOutputSetup->num_lfe ) { Word32 *proto_matrix_ptr_in_fx; FOR( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe; lfe_idx1++ ) { lfe_indices[lfe_idx1 + 1] = hSynthesisOutputSetup->index_lfe[lfe_idx1]; + move16(); } - lfe_indices[hSynthesisOutputSetup->num_lfe + 1] = nY_cov; + lfe_indices[add( hSynthesisOutputSetup->num_lfe, 1 )] = nY_cov; + move16(); proto_matrix_ptr_fx = &proto_matrix_noLFE_fx[0]; proto_matrix_ptr_in_fx = &hParamMC->h_output_synthesis_params.proto_matrix_fx[0]; proto_matrix_noLFE_e = proto_matrix_e; @@ -5072,11 +5355,12 @@ static void ivas_param_mc_get_mixing_matrices_fx( FOR( ch_idx1 = 0; ch_idx1 < nX; ch_idx1++ ) { - FOR( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) + FOR( lfe_idx1 = 0; lfe_idx1 < add( hSynthesisOutputSetup->num_lfe, 1 ); lfe_idx1++ ) { - FOR( ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++ ) + FOR( ch_idx2 = add( lfe_indices[lfe_idx1], 1 ); ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++ ) { *( proto_matrix_ptr_fx++ ) = *( proto_matrix_ptr_in_fx++ ); + move32(); } proto_matrix_ptr_in_fx++; } @@ -5087,9 +5371,10 @@ static void ivas_param_mc_get_mixing_matrices_fx( move16(); } - IF( hParamMC->hMetadataPMC->lfe_on ) + if ( hParamMC->hMetadataPMC->lfe_on ) { num_lfe_bands = PARAM_MC_MAX_BAND_LFE; + move16(); } FOR( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ ) @@ -5098,7 +5383,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( { remove_lfe = 1; move16(); - nY_band = nY_cov - hSynthesisOutputSetup->num_lfe; + nY_band = sub( nY_cov, hSynthesisOutputSetup->num_lfe ); proto_matrix_ptr_fx = proto_matrix_noLFE_fx; proto_matrix_ptr_e = proto_matrix_noLFE_e; move16(); @@ -5126,18 +5411,16 @@ static void ivas_param_mc_get_mixing_matrices_fx( Cx_state_e = Cx_in_e; move16(); matrix_product_fx( hParamMC->proto_matrix_int_fx, nY_intern, nX, 0, Cx_state_fx, nX, nX, 0, mat_mult_buffer1_fx ); - mat_mult_buffer1_e = hParamMC->proto_matrix_int_e + Cx_in_e; + mat_mult_buffer1_e = add( hParamMC->proto_matrix_int_e, Cx_in_e ); matrix_product_fx( mat_mult_buffer1_fx, nY_intern, nX, 0, hParamMC->proto_matrix_int_fx, nY_intern, nX, 1, Cproto_fx ); - Cproto_e = mat_mult_buffer1_e + hParamMC->proto_matrix_int_e; - move16(); - + Cproto_e = add( mat_mult_buffer1_e, hParamMC->proto_matrix_int_e ); FOR( ch_idx1 = 0; ch_idx1 < nY_intern; ch_idx1++ ) { - IF( BASOP_Util_Cmp_Mant32Exp( Cproto_fx[ch_idx1 + ch_idx1 * nY_intern], Cproto_e, 0, 0 ) < 0 ) + IF( BASOP_Util_Cmp_Mant32Exp( Cproto_fx[L_add( ch_idx1, L_mult0( ch_idx1, nY_intern ) )], Cproto_e, 0, 0 ) < 0 ) { - Cproto_fx[ch_idx1 + ch_idx1 * nY_intern] = 0; + Cproto_fx[L_add( ch_idx1, L_mult0( ch_idx1, nY_intern ) )] = 0; move32(); } } @@ -5147,8 +5430,8 @@ static void ivas_param_mc_get_mixing_matrices_fx( move16(); ivas_param_mc_dequantize_cov_fx( hParamMC, - hParamMC->icld_q_fx + param_band_idx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe, - hParamMC->icc_q_fx + param_band_idx * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe, + hParamMC->icld_q_fx + L_mult0( param_band_idx, hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ), + hParamMC->icc_q_fx + L_mult0( param_band_idx, hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ), param_band_idx, nY_cov, synth_config, nY_intern, @@ -5160,8 +5443,8 @@ static void ivas_param_mc_get_mixing_matrices_fx( IF( hParamMC->hMetadataPMC->bAttackPresent ) { /* no smoothing on attacks */ - Copy32( Cx_state_fx, Cx_fx, nX * nX ); - Copy32( Cy_state_fx, Cy_full_fx, nY_cov * nY_cov ); + Copy32( Cx_state_fx, Cx_fx, imult1616( nX, nX ) ); + Copy32( Cy_state_fx, Cy_full_fx, imult1616( nY_cov, nY_cov ) ); Cy_full_e = Cy_state_e; move16(); Cx_e = Cx_state_e; @@ -5172,29 +5455,34 @@ static void ivas_param_mc_get_mixing_matrices_fx( /* smoothing gains are now identical to one, simply add up */ // v_add( Cy_state, Cy_old_state, Cy_full, nY_cov * nY_cov ); - tmp_e = max( hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], Cx_state_e ) + guard_bit_cx; + tmp_e = add( s_max( hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], Cx_state_e ), guard_bit_cx ); FOR( i = 0; i < nX * nX; i++ ) { - Cx_old_state_fx[i] = L_shr( Cx_old_state_fx[i], tmp_e - hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] ); - Cx_state_fx[i] = L_shr( Cx_state_fx[i], tmp_e - Cx_state_e ); + Cx_old_state_fx[i] = L_shr( Cx_old_state_fx[i], sub( tmp_e, hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] ) ); + move32(); + Cx_state_fx[i] = L_shr( Cx_state_fx[i], sub( tmp_e, Cx_state_e ) ); + move32(); } hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] = tmp_e; + move16(); Cx_state_e = tmp_e; move16(); - tmp_e = max( hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], Cy_state_e ) + guard_bit_cy; - FOR( i = 0; i < nY_cov * nY_cov; i++ ) + tmp_e = add( s_max( hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], Cy_state_e ), guard_bit_cy ); + FOR( i = 0; i < imult1616( nY_cov, nY_cov ); i++ ) { - Cy_old_state_fx[i] = L_shr( Cy_old_state_fx[i], tmp_e - hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] ); - Cy_state_fx[i] = L_shr( Cy_state_fx[i], tmp_e - Cy_state_e ); + Cy_old_state_fx[i] = L_shr( Cy_old_state_fx[i], sub( tmp_e, hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] ) ); + move32(); + Cy_state_fx[i] = L_shr( Cy_state_fx[i], sub( tmp_e, Cy_state_e ) ); + move32(); } hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = tmp_e; Cy_state_e = tmp_e; move16(); - v_add_32( Cx_state_fx, Cx_old_state_fx, Cx_fx, nX * nX ); - v_add_32( Cy_state_fx, Cy_old_state_fx, Cy_full_fx, nY_cov * nY_cov ); + v_add_32( Cx_state_fx, Cx_old_state_fx, Cx_fx, imult1616( nX, nX ) ); + v_add_32( Cy_state_fx, Cy_old_state_fx, Cy_full_fx, imult1616( nY_cov, nY_cov ) ); Cy_full_e = Cy_state_e; move16(); @@ -5202,21 +5490,21 @@ static void ivas_param_mc_get_mixing_matrices_fx( move16(); } - Copy32( Cx_state_fx, Cx_old_state_fx, nX * nX ); + Copy32( Cx_state_fx, Cx_old_state_fx, imult1616( nX, nX ) ); - Copy32( Cy_state_fx, Cy_old_state_fx, nY_cov * nY_cov ); + Copy32( Cy_state_fx, Cy_old_state_fx, imult1616( nY_cov, nY_cov ) ); Word16 new_e = 0; - + move16(); hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] = Cx_state_e; move16(); hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = Cy_state_e; move16(); - FOR( i = 0; i < nX * nX; i++ ) + FOR( i = 0; i < imult1616( nX, nX ); i++ ) { - IF( NE_32( Cx_old_state_fx[i], 0 ) ) + if ( Cx_old_state_fx[i] != 0 ) { new_e = hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx]; move16(); @@ -5229,9 +5517,9 @@ static void ivas_param_mc_get_mixing_matrices_fx( new_e = 0; move16(); - FOR( i = 0; i < nY_cov * nY_cov; i++ ) + FOR( i = 0; i < imult1616( nY_cov, nY_cov ); i++ ) { - IF( NE_32( Cy_old_state_fx[i], 0 ) ) + if ( Cy_old_state_fx[i] != 0 ) { new_e = hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx]; move16(); @@ -5250,41 +5538,45 @@ static void ivas_param_mc_get_mixing_matrices_fx( } ELSE { - Copy32( Cy_full_fx, Cy_fx, nY_band * nY_band ); + Copy32( Cy_full_fx, Cy_fx, imult1616( nY_band, nY_band ) ); Cy_e = Cy_full_e; move16(); } matrix_product_fx( proto_matrix_ptr_fx, nY_band, nX, 0, Cx_fx, nX, nX, 0, mat_mult_buffer1_fx ); - mat_mult_buffer1_e = proto_matrix_ptr_e + Cx_e; + mat_mult_buffer1_e = add( proto_matrix_ptr_e, Cx_e ); - Word16 guard_bits = find_guarded_bits_fx( nY_band + 1 ); + Word16 guard_bits = find_guarded_bits_fx( add( nY_band, 1 ) ); - FOR( i = 0; i < nY_band * nX; ++i ) + FOR( i = 0; i < imult1616( nY_band, nX ); ++i ) { proto_matrix_ptr_fx[i] = L_shr( proto_matrix_ptr_fx[i], guard_bits ); + move32(); mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], guard_bits ); + move32(); } - proto_matrix_ptr_e += guard_bits; - mat_mult_buffer1_e += guard_bits; + proto_matrix_ptr_e = add( proto_matrix_ptr_e, guard_bits ); + mat_mult_buffer1_e = add( mat_mult_buffer1_e, guard_bits ); matrix_product_diag_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, nY_band, nX, 0, proto_matrix_ptr_fx, proto_matrix_ptr_e, nY_band, nX, 1, Cproto_diag_fx, &Cproto_diag_e ); - FOR( i = 0; i < nY_band * nX; ++i ) + FOR( i = 0; i < imult1616( nY_band, nX ); ++i ) { proto_matrix_ptr_fx[i] = L_shl( proto_matrix_ptr_fx[i], guard_bits ); + move32(); mat_mult_buffer1_fx[i] = L_shl( mat_mult_buffer1_fx[i], guard_bits ); + move32(); } - proto_matrix_ptr_e -= guard_bits; - mat_mult_buffer1_e -= guard_bits; + proto_matrix_ptr_e = sub( proto_matrix_ptr_e, guard_bits ); + mat_mult_buffer1_e = sub( mat_mult_buffer1_e, guard_bits ); /* make sure we have no negative entries in Cproto_diag due to rounding errors */ FOR( ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++ ) { - IF( BASOP_Util_Cmp_Mant32Exp( Cproto_diag_fx[ch_idx1], Cproto_diag_e, 0, 0 ) < 0 ) + if ( BASOP_Util_Cmp_Mant32Exp( Cproto_diag_fx[ch_idx1], Cproto_diag_e, 0, 0 ) < 0 ) { Cproto_diag_fx[ch_idx1] = 0; move16(); @@ -5295,7 +5587,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( /* Computing the mixing matrices */ /* bands with decorr */ - IF( brange[0] < hParamMC->h_output_synthesis_params.max_band_decorr ) + IF( LT_16( brange[0], hParamMC->h_output_synthesis_params.max_band_decorr ) ) { computeMixingMatrices_fx( nX, nY_band, Cx_fx, Cx_e, Cy_fx, Cy_e, proto_matrix_ptr_fx, proto_matrix_ptr_e, 0, PARAM_MC_REG_SX_FX, 0, PARAM_MC_REG_GHAT_FX, 0, mixing_matrix_local_fx, &mixing_matrix_local_e, Cr_fx, &Cr_e ); /* Compute mixing matrix FOR residual */ @@ -5303,19 +5595,20 @@ static void ivas_param_mc_get_mixing_matrices_fx( IF( remove_lfe ) { - set_zero_fx( mixing_matrix_res_fx[param_band_idx], nY_cov * nY_cov ); + set_zero_fx( mixing_matrix_res_fx[param_band_idx], imult1616( nY_cov, nY_cov ) ); ptrMM_fx = mixing_matrix_res_local_fx; ptrMM_out_fx = mixing_matrix_res_fx[param_band_idx]; - FOR( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) + FOR( lfe_idx1 = 0; lfe_idx1 < add( hSynthesisOutputSetup->num_lfe, 1 ); lfe_idx1++ ) { - FOR( ch_idx1 = lfe_indices[lfe_idx1] + 1; ch_idx1 < lfe_indices[lfe_idx1 + 1]; ch_idx1++ ) + FOR( ch_idx1 = add( lfe_indices[lfe_idx1], 1 ); ch_idx1 < lfe_indices[lfe_idx1 + 1]; ch_idx1++ ) { - FOR( lfe_idx2 = 0; lfe_idx2 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx2++ ) + FOR( lfe_idx2 = 0; lfe_idx2 < add( hSynthesisOutputSetup->num_lfe, 1 ); lfe_idx2++ ) { - FOR( ch_idx2 = lfe_indices[lfe_idx2] + 1; ch_idx2 < lfe_indices[lfe_idx2 + 1]; ch_idx2++ ) + FOR( ch_idx2 = add( lfe_indices[lfe_idx2], 1 ); ch_idx2 < lfe_indices[lfe_idx2 + 1]; ch_idx2++ ) { *( ptrMM_out_fx++ ) = *( ptrMM_fx++ ); + move32(); } ptrMM_out_fx++; } @@ -5328,7 +5621,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( } ELSE { - Copy32( mixing_matrix_res_local_fx, mixing_matrix_res_fx[param_band_idx], nY_cov * nY_cov ); + Copy32( mixing_matrix_res_local_fx, mixing_matrix_res_fx[param_band_idx], imult1616( nY_cov, nY_cov ) ); mixing_matrix_res_e[param_band_idx] = mixing_matrix_res_local_e; move16(); } @@ -5344,7 +5637,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( FOR( i = 0; i < nY_band; i++ ) { tmp = BASOP_Util_Divide3232_Scale( Cy_fx[i], L_add( Cproto_diag_fx[i], EPSILON_FX ), &tmp_e ); - tmp_e = Cy_diag_e + Cproto_diag_e; + tmp_e = add( Cy_diag_e, Cproto_diag_e ); L_tmp = Sqrt32( L_deposit_h( tmp ), &tmp_e ); Cy_diag_fx[i] = L_tmp; move32(); @@ -5358,13 +5651,17 @@ static void ivas_param_mc_get_mixing_matrices_fx( FOR( i = 1; i < nY_band; i++ ) { - IF( Cy_diag_e < Cy_diag_buff_e[i] ) - Cy_diag_e = Cy_diag_buff_e[i]; + if ( LT_16( Cy_diag_e, Cy_diag_buff_e[i] ) ) + { + Cy_diag_e = Cy_diag_buff_e[i]; + move16(); + } } FOR( i = 0; i < nY_band; i++ ) { - Cy_diag_fx[i] = L_shr( Cy_diag_fx[i], Cy_diag_e - Cy_diag_buff_e[i] ); + Cy_diag_fx[i] = L_shr( Cy_diag_fx[i], sub( Cy_diag_e, Cy_diag_buff_e[i] ) ); + move32(); } diag_matrix_product_fx( Cy_diag_fx, Cy_diag_e, nY_band, proto_matrix_ptr_fx, proto_matrix_ptr_e, nY_band, nX, 0, mixing_matrix_local_fx, &mixing_matrix_local_e ); @@ -5372,16 +5669,17 @@ static void ivas_param_mc_get_mixing_matrices_fx( IF( remove_lfe ) { - set_zero_fx( mixing_matrix_fx[param_band_idx], nX * nY_cov ); + set_zero_fx( mixing_matrix_fx[param_band_idx], imult1616( nX, nY_cov ) ); ptrMM_fx = mixing_matrix_local_fx; ptrMM_out_fx = mixing_matrix_fx[param_band_idx]; FOR( ch_idx1 = 0; ch_idx1 < nX; ch_idx1++ ) { - FOR( lfe_idx1 = 0; lfe_idx1 < hSynthesisOutputSetup->num_lfe + 1; lfe_idx1++ ) + FOR( lfe_idx1 = 0; lfe_idx1 < add( hSynthesisOutputSetup->num_lfe, 1 ); lfe_idx1++ ) { - FOR( ch_idx2 = lfe_indices[lfe_idx1] + 1; ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++ ) + FOR( ch_idx2 = add( lfe_indices[lfe_idx1], 1 ); ch_idx2 < lfe_indices[lfe_idx1 + 1]; ch_idx2++ ) { *( ptrMM_out_fx++ ) = *( ptrMM_fx++ ); + move32(); } ptrMM_out_fx++; } @@ -5393,7 +5691,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( } ELSE { - Copy32( mixing_matrix_local_fx, mixing_matrix_fx[param_band_idx], nY_cov * nX ); + Copy32( mixing_matrix_local_fx, mixing_matrix_fx[param_band_idx], imult1616( nY_cov, nX ) ); mixing_matrix_e[param_band_idx] = mixing_matrix_local_e; move16(); } @@ -5626,15 +5924,19 @@ static void param_mc_update_mixing_matrices_fx( Word16 brange[2]; brange[0] = hParamMC->band_grouping[param_band_idx]; - brange[1] = hParamMC->band_grouping[param_band_idx + 1]; + move16(); + brange[1] = hParamMC->band_grouping[add( param_band_idx, 1 )]; + move16(); - Copy32( mixing_matrix[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[param_band_idx], nX * nY ); + Copy32( mixing_matrix[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[param_band_idx], imult1616( nX, nY ) ); hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_exp[param_band_idx] = mixing_matrix_exp[param_band_idx]; + move16(); - IF( brange[0] < hParamMC->h_output_synthesis_params.max_band_decorr ) + IF( LT_16( brange[0], hParamMC->h_output_synthesis_params.max_band_decorr ) ) { - Copy32( mixing_matrix_res[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[param_band_idx], nY * nY ); + Copy32( mixing_matrix_res[param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[param_band_idx], imult1616( nY, nY ) ); hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_exp[param_band_idx] = mixing_matrix_res_exp[param_band_idx]; + move16(); } } @@ -5869,18 +6171,23 @@ static void ivas_param_mc_dequantize_cov_fx( /*get back Nrg*/ tmp = 0; + move16(); FOR( k = 0; k < nY_int; k++ ) { Word32 ref_ener_fx = 0; + move32(); Word16 ref_ener_e = 0; + move16(); Word16 ref_channel_cnt; Word16 ref_channel_idx; FOR( ref_channel_cnt = 0; ref_channel_cnt < h_ild_mapping->num_ref_channels[k]; ref_channel_cnt++ ) { ref_channel_idx = h_ild_mapping->ref_channel_idx[k][ref_channel_cnt]; - ref_ener_fx = BASOP_Util_Add_Mant32Exp( Cx_state_fx[ref_channel_idx + ref_channel_idx * nX], Cx_state_e, ref_ener_fx, ref_ener_e, &ref_ener_e ); + move16(); + ref_ener_fx = BASOP_Util_Add_Mant32Exp( Cx_state_fx[add( ref_channel_idx, imult1616( ref_channel_idx, nX ) )], Cx_state_e, ref_ener_fx, ref_ener_e, &ref_ener_e ); + move32(); } L_tmp = Mpy_32_16_1( 713378626, ild_q_fx[k] ); /*Q24 : L_tmp Q31 for log2(10)/10 -> 713378626 */ @@ -5898,12 +6205,12 @@ static void ivas_param_mc_dequantize_cov_fx( FOR( k = 0; k < nY_int; k++ ) { // a_fx[k] = 1.f / ( sqrtf( Cproto_fx[k + nY_int * k] ) + EPSILON ); - tmp_e = Cp_buf_e[k + nY_int * k]; + tmp_e = Cp_buf_e[add( k, imult1616( nY_int, k ) )]; move16(); - IF( NE_32( Cproto_fx[k + nY_int * k], 0 ) ) + IF( NE_32( Cproto_fx[add( k, imult1616( nY_int, k ) )], 0 ) ) { - L_tmp = ISqrt32( Cproto_fx[k + nY_int * k], &tmp_e ); + L_tmp = ISqrt32( Cproto_fx[add( k, imult1616( nY_int, k ) )], &tmp_e ); } ELSE { @@ -5919,9 +6226,9 @@ static void ivas_param_mc_dequantize_cov_fx( FOR( l = 0; l < nY_int; l++ ) { - Cy_state_int_fx[k * nY_int + l] = Mpy_32_32( Cproto_fx[k * nY_int + l], a_fx[k] ); + Cy_state_int_fx[add( imult1616( k, nY_int ), l )] = Mpy_32_32( Cproto_fx[add( imult1616( k, nY_int ), l )], a_fx[k] ); move32(); - Cy_state_int_e[k * nY_int + l] = add( Cp_buf_e[k * nY_int + l], a_e[k] ); + Cy_state_int_e[add( imult1616( k, nY_int ), l )] = add( Cp_buf_e[add( imult1616( k, nY_int ), l )], a_e[k] ); move16(); } } @@ -5938,7 +6245,9 @@ static void ivas_param_mc_dequantize_cov_fx( FOR( l = 0; l < nY_int; l++ ) { ( *Cyp_fx ) = Mpy_32_32( *Cyp_fx, ap_fx ); + move32(); *Cyp_e = add( *Cyp_e, ap_e ); + move16(); Cyp_fx += nY_int; Cyp_e += nY_int; @@ -5972,18 +6281,17 @@ static void ivas_param_mc_dequantize_cov_fx( } test(); - test(); - IF( GE_16( param_band_index, PARAM_MC_MAX_BAND_LFE ) || EQ_16( hParamMC->hMetadataPMC->lfe_on, 0 ) ) + IF( GE_16( param_band_index, PARAM_MC_MAX_BAND_LFE ) || ( hParamMC->hMetadataPMC->lfe_on == 0 ) ) { FOR( k = 0; k < nY_int; k++ ) { - Cy_state_int_fx[k + 3 * nY_int] = ONE_IN_Q31; + Cy_state_int_fx[add( k, imult1616( 3, nY_int ) )] = ONE_IN_Q31; move32(); - Cy_state_int_e[k + 3 * nY_int] = 0; + Cy_state_int_e[add( k, imult1616( 3, nY_int ) )] = 0; move16(); - Cy_state_int_fx[3 + k * nY_int] = ONE_IN_Q31; + Cy_state_int_fx[add( 3, imult1616( k, nY_int ) )] = ONE_IN_Q31; move32(); - Cy_state_int_e[3 + k * nY_int] = 0; + Cy_state_int_e[add( 3, imult1616( k, nY_int ) )] = 0; move16(); } Nrqq_fx[3] = 0; @@ -6003,9 +6311,9 @@ static void ivas_param_mc_dequantize_cov_fx( /* v_multc( Cy_state_int_fx + k * nY_int, a_fx[k], Cy_state_int_fx + k * nY_int, nY_int ) */ FOR( l = 0; l < nY_int; l++ ) { - Cy_state_int_fx[k * nY_int + l] = Mpy_32_32( Cy_state_int_fx[k * nY_int + l], a_fx[k] ); + Cy_state_int_fx[add( imult1616( k, nY_int ), l )] = Mpy_32_32( Cy_state_int_fx[add( imult1616( k, nY_int ), l )], a_fx[k] ); move32(); - Cy_state_int_e[k * nY_int + l] = add( Cy_state_int_e[k * nY_int + l], a_e[k] ); + Cy_state_int_e[add( imult1616( k, nY_int ), l )] = add( Cy_state_int_e[add( imult1616( k, nY_int ), l )], a_e[k] ); move16(); } } @@ -6022,7 +6330,9 @@ static void ivas_param_mc_dequantize_cov_fx( FOR( l = 0; l < nY_int; l++ ) { ( *Cyp_fx ) = Mpy_32_32( *Cyp_fx, ap_fx ); + move32(); ( *Cyp_e ) = add( *Cyp_e, ap_e ); + move16(); Cyp_fx += nY_int; Cyp_e += nY_int; @@ -6057,8 +6367,8 @@ static void ivas_param_mc_dequantize_cov_fx( { FOR( l = 0; l < nY_int; l++ ) { - L_tmp = Mpy_32_32( hParamMC->ls_conv_dmx_matrix_fx[k + l * nY_cov], Nrqq_fx[l] ); - tmp_e = add( ls_conv_dmx_matrix_e[k + l * nY_cov], Nrqq_e[l] ); + L_tmp = Mpy_32_32( hParamMC->ls_conv_dmx_matrix_fx[add( k, imult1616( l, nY_cov ) )], Nrqq_fx[l] ); + tmp_e = add( ls_conv_dmx_matrix_e[add( k, imult1616( l, nY_cov ) )], Nrqq_e[l] ); L_tmp = BASOP_Util_Add_Mant32Exp( target_ch_ener_fx[k], target_ch_ener_e[k], L_tmp, tmp_e, &tmp_e ); target_ch_ener_fx[k] = L_tmp; move32(); @@ -6066,12 +6376,12 @@ static void ivas_param_mc_dequantize_cov_fx( move16(); } - dmx_ch_ener_fx[k] = Cy_state_fx[k + nY_cov * k]; + dmx_ch_ener_fx[k] = Cy_state_fx[add( k, imult1616( nY_cov, k ) )]; move32(); - IF( dmx_ch_ener_fx[k] < 0.0f ) + IF( dmx_ch_ener_fx[k] < 0 ) { - Cy_state_fx[k + nY_cov * k] = L_negate( Cy_state_fx[k + nY_cov * k] ); + Cy_state_fx[add( k, imult1616( nY_cov, k ) )] = L_negate( Cy_state_fx[add( k, imult1616( nY_cov, k ) )] ); move32(); dmx_ch_ener_fx[k] = L_negate( dmx_ch_ener_fx[k] ); move32(); @@ -6086,7 +6396,7 @@ static void ivas_param_mc_dequantize_cov_fx( } ELSE { - BASOP_Util_Divide_MantExp( extract_h( target_ch_ener_fx[k] ), target_ch_ener_e[k], extract_h( dmx_ch_ener_fx[k] ), Cy_buf_e[k + nY_cov * k], &tmp, &tmp_e ); + BASOP_Util_Divide_MantExp( extract_h( target_ch_ener_fx[k] ), target_ch_ener_e[k], extract_h( dmx_ch_ener_fx[k] ), Cy_buf_e[add( k, imult1616( nY_cov, k ) )], &tmp, &tmp_e ); tmp = Sqrt16( tmp, &tmp_e ); target_ch_ener_fx[k] = L_deposit_h( tmp ); move32(); @@ -6096,9 +6406,9 @@ static void ivas_param_mc_dequantize_cov_fx( FOR( l = 0; l < nY_cov; l++ ) { - Cy_state_fx[k * nY_cov + l] = Mpy_32_32( target_ch_ener_fx[k], Cy_state_fx[k * nY_cov + l] ); + Cy_state_fx[add( imult1616( k, nY_cov ), l )] = Mpy_32_32( target_ch_ener_fx[k], Cy_state_fx[add( imult1616( k, nY_cov ), l )] ); move32(); - Cy_buf_e[k * nY_cov + l] = add( target_ch_ener_e[k], Cy_buf_e[k * nY_cov + l] ); + Cy_buf_e[add( imult1616( k, nY_cov ), l )] = add( target_ch_ener_e[k], Cy_buf_e[add( imult1616( k, nY_cov ), l )] ); move16(); } @@ -6111,7 +6421,9 @@ static void ivas_param_mc_dequantize_cov_fx( FOR( l = 0; l < nY_cov; l++ ) { ( *Cyp_fx ) = Mpy_32_32( *Cyp_fx, ap_fx ); + move32(); *Cyp_e = add( *Cyp_e, ap_e ); + move16(); Cyp_fx += nY_cov; Cyp_e += nY_cov; @@ -6120,21 +6432,21 @@ static void ivas_param_mc_dequantize_cov_fx( } ELSE { - Copy32( Cy_state_int_fx, Cy_state_fx, nY_int * nY_int ); - Copy( Cy_state_int_e, Cy_buf_e, nY_int * nY_int ); + Copy32( Cy_state_int_fx, Cy_state_fx, imult1616( nY_int, nY_int ) ); + Copy( Cy_state_int_e, Cy_buf_e, imult1616( nY_int, nY_int ) ); } /*normalize output matrix to a common exponent*/ tmp = 0; - FOR( k = 0; k < nY_int * nY_int; k++ ) + FOR( k = 0; k < imult1616( nY_int, nY_int ); k++ ) { Cy_state_fx[k] = BASOP_Util_Add_Mant32Exp( Cy_state_fx[k], Cy_buf_e[k], 0, 0, &Cy_buf_e[k] ); move32(); tmp = s_max( tmp, Cy_buf_e[k] ); } - FOR( k = 0; k < nY_int * nY_int; k++ ) + FOR( k = 0; k < imult1616( nY_int, nY_int ); k++ ) { - L_tmp = L_shr( Cy_state_fx[k], tmp - Cy_buf_e[k] ); + L_tmp = L_shr( Cy_state_fx[k], sub( tmp, Cy_buf_e[k] ) ); Cy_state_fx[k] = L_tmp; move32(); } @@ -6192,6 +6504,7 @@ static void param_mc_set_num_synth_bands( } move16(); hParamMC->num_param_bands_synth = s_min( hParamMC->hMetadataPMC->nbands_coded, max_param_band_synth ); + move16(); return; } @@ -6261,24 +6574,25 @@ static ivas_error param_mc_get_diff_proto_info_fx( float proto_fac[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; #endif Word32 proto_fac_fx[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; - uint16_t cur_out_ch; - uint16_t cur_diff_proto; - uint16_t cur_transport_ch; - uint16_t max_num_src_chan; + UWord16 cur_out_ch; + UWord16 cur_diff_proto; + UWord16 cur_transport_ch; + UWord16 max_num_src_chan; /* Initializations */ max_num_src_chan = 0; + move16(); #if FLT_ENABLE set_zero( proto_fac, MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS ); #endif set_zero_fx( proto_fac_fx, MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS ); - if ( ( p_diff_proto_info->proto_index_diff = (int16_t *) malloc( nchan_out_cov * sizeof( int16_t ) ) ) == NULL ) + IF( ( p_diff_proto_info->proto_index_diff = (Word16 *) malloc( nchan_out_cov * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } set16_fx( p_diff_proto_info->proto_index_diff, 0, nchan_out_cov ); - if ( ( p_diff_proto_info->num_source_chan_diff = (int16_t *) malloc( nchan_out_cov * sizeof( int16_t ) ) ) == NULL ) + IF( ( p_diff_proto_info->num_source_chan_diff = (Word16 *) malloc( nchan_out_cov * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } @@ -6286,18 +6600,21 @@ static ivas_error param_mc_get_diff_proto_info_fx( /* we have at least one prototype, copy the first one */ p_diff_proto_info->num_protos_diff = 1; + move16(); #if FLT_ENABLE mvr2r_inc( proto_mtx, nchan_out_cov, proto_fac, nchan_out_cov, nchan_transport ); #endif mvr2r_inc_fixed( proto_mtx, nchan_out_cov, proto_fac_fx, nchan_out_cov, nchan_transport ); p_diff_proto_info->proto_index_diff[0] = 0; + move16(); /* search for distinct prototypes */ - for ( cur_out_ch = 1; cur_out_ch < nchan_out_cov; cur_out_ch++ ) + FOR( cur_out_ch = 1; cur_out_ch < nchan_out_cov; cur_out_ch++ ) { - uint16_t found = 0; + UWord16 found = 0; + move16(); - for ( cur_diff_proto = 0; cur_diff_proto < p_diff_proto_info->num_protos_diff; cur_diff_proto++ ) + FOR( cur_diff_proto = 0; cur_diff_proto < p_diff_proto_info->num_protos_diff; cur_diff_proto++ ) { #if FLT_ENABLE float diff = 0; @@ -6305,16 +6622,17 @@ static ivas_error param_mc_get_diff_proto_info_fx( // const float *proto_mtx_ptr = proto_mtx + cur_out_ch; #endif Word32 diff_fx = 0; + move32(); Word32 *proto_fac_ptr_fx = proto_fac_fx + cur_diff_proto; const Word32 *proto_mtx_ptr = proto_mtx + cur_out_ch; - for ( cur_transport_ch = 0; cur_transport_ch < nchan_transport; cur_transport_ch++ ) + FOR( cur_transport_ch = 0; cur_transport_ch < nchan_transport; cur_transport_ch++ ) { #if FLT_ENABLE diff += fabsf( *proto_fac_ptr - *proto_mtx_ptr ); proto_fac_ptr += nchan_out_cov; proto_mtx_ptr += nchan_out_cov; #endif - diff_fx += L_abs( *proto_fac_ptr_fx - *proto_mtx_ptr ); + diff_fx = L_add( diff_fx, L_abs( L_sub( *proto_fac_ptr_fx, *proto_mtx_ptr ) ) ); proto_fac_ptr_fx += nchan_out_cov; proto_mtx_ptr += nchan_out_cov; } @@ -6323,31 +6641,34 @@ static ivas_error param_mc_get_diff_proto_info_fx( #if FLT_ENABLE if ( diff < 0.1f ) #else - if ( LT_64( diff_fx * 10, L_shl_sat( 1, Q_proto_mtx ) ) ) + IF( LT_64( W_mult0_32_32( diff_fx, 10 ), L_shl_sat( 1, Q_proto_mtx ) ) ) #endif { found = 1; + move16(); p_diff_proto_info->proto_index_diff[cur_out_ch] = cur_diff_proto; - break; + move16(); + BREAK; } } /* new distinct prototype, add it */ - if ( found == 0 ) + IF( found == 0 ) { #if FLT_ENABLE const float *proto_mtx_ptr = proto_mtx + cur_out_ch; #else const Word32 *proto_mtx_ptr = proto_mtx + cur_out_ch; #endif - int16_t cur_num_src_chan; + Word16 cur_num_src_chan; cur_num_src_chan = 0; - for ( cur_transport_ch = 0; cur_transport_ch < nchan_transport; cur_transport_ch++ ) + move16(); + FOR( cur_transport_ch = 0; cur_transport_ch < nchan_transport; cur_transport_ch++ ) { - if ( *proto_mtx_ptr > EPSILON ) + IF( GT_32( *proto_mtx_ptr, 0 /*EPSILON*/ ) ) { - cur_num_src_chan++; + cur_num_src_chan = add( cur_num_src_chan, 1 ); } proto_mtx_ptr += nchan_out_cov; } @@ -6358,13 +6679,13 @@ static ivas_error param_mc_get_diff_proto_info_fx( mvr2r_inc_fixed( proto_mtx + cur_out_ch, nchan_out_cov, proto_fac_fx + p_diff_proto_info->num_protos_diff, nchan_out_cov, nchan_transport ); #endif p_diff_proto_info->proto_index_diff[cur_out_ch] = p_diff_proto_info->num_protos_diff; - p_diff_proto_info->num_protos_diff++; + p_diff_proto_info->num_protos_diff = add( p_diff_proto_info->num_protos_diff, 1 ); max_num_src_chan = s_max( max_num_src_chan, cur_num_src_chan ); } } /* set up the prototype info struct */ - if ( ( p_diff_proto_info->source_chan_idx = (int16_t **) malloc( p_diff_proto_info->num_protos_diff * sizeof( int16_t * ) ) ) == NULL ) + IF( ( p_diff_proto_info->source_chan_idx = (Word16 **) malloc( p_diff_proto_info->num_protos_diff * sizeof( Word16 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } @@ -6374,40 +6695,42 @@ static ivas_error param_mc_get_diff_proto_info_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } #endif - if ( ( p_diff_proto_info->proto_fac_fx = (Word32 **) malloc( p_diff_proto_info->num_protos_diff * sizeof( Word32 * ) ) ) == NULL ) + IF( ( p_diff_proto_info->proto_fac_fx = (Word32 **) malloc( p_diff_proto_info->num_protos_diff * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } - for ( cur_diff_proto = 0; cur_diff_proto < p_diff_proto_info->num_protos_diff; cur_diff_proto++ ) + FOR( cur_diff_proto = 0; cur_diff_proto < p_diff_proto_info->num_protos_diff; cur_diff_proto++ ) { #if FLT_ENABLE float *proto_fac_ptr; #endif Word32 *proto_fac_ptr; - if ( ( p_diff_proto_info->source_chan_idx[cur_diff_proto] = (int16_t *) malloc( max_num_src_chan * sizeof( int16_t ) ) ) == NULL ) + IF( ( p_diff_proto_info->source_chan_idx[cur_diff_proto] = (Word16 *) malloc( max_num_src_chan * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } #if 1 /*To be removed later*/ - if ( ( p_diff_proto_info->proto_fac[cur_diff_proto] = (float *) malloc( max_num_src_chan * sizeof( float ) ) ) == NULL ) + IF( ( p_diff_proto_info->proto_fac[cur_diff_proto] = (float *) malloc( max_num_src_chan * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } #endif - if ( ( p_diff_proto_info->proto_fac_fx[cur_diff_proto] = (Word32 *) malloc( max_num_src_chan * sizeof( Word32 ) ) ) == NULL ) + IF( ( p_diff_proto_info->proto_fac_fx[cur_diff_proto] = (Word32 *) malloc( max_num_src_chan * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } proto_fac_ptr = proto_fac_fx + cur_diff_proto; - for ( cur_transport_ch = 0; cur_transport_ch < nchan_transport; cur_transport_ch++ ) + FOR( cur_transport_ch = 0; cur_transport_ch < nchan_transport; cur_transport_ch++ ) { - if ( *proto_fac_ptr > EPSILON_FX_SMALL ) + IF( GT_32( *proto_fac_ptr, EPSILON_FX_SMALL ) ) { p_diff_proto_info->source_chan_idx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = cur_transport_ch; + move16(); p_diff_proto_info->proto_fac_fx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = *proto_fac_ptr; - p_diff_proto_info->num_source_chan_diff[cur_diff_proto]++; + move16(); + p_diff_proto_info->num_source_chan_diff[cur_diff_proto] = add( p_diff_proto_info->num_source_chan_diff[cur_diff_proto], 1 ); } proto_fac_ptr += nchan_out_cov; } @@ -6602,18 +6925,24 @@ static void ivas_param_mc_bs_decode_parameter_values_fx( Word16 dequant_ordered_fx[PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE]; Word16 n_lfe_idx; - range_coding = bit_buffer[( *bit_pos )++]; + range_coding = bit_buffer[*bit_pos]; + move16(); + *bit_pos = add( *bit_pos, 1 ); + move16(); /* Decoding the sequence */ n_lfe_idx = sub( map_size, map_size_wo_lfe ); sz_seq = add( imult1616( num_param_bands, map_size_wo_lfe ), imult1616( num_lfe_bands, n_lfe_idx ) ); - set_s( idx, 0, PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE ); + set16_fx( idx, 0, PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE ); set16_fx( dequant_ordered_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE ); set16_fx( dequant_seq_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE ); IF( range_coding ) { - delta_coding = bit_buffer[( *bit_pos )++]; + delta_coding = bit_buffer[*bit_pos]; + move16(); + *bit_pos = add( *bit_pos, 1 ); + move16(); IF( delta_coding ) { @@ -6622,28 +6951,33 @@ static void ivas_param_mc_bs_decode_parameter_values_fx( idx_offset = sub( hParamCodingInfo->quantizer_size, 1 ); /* read range coded delta ICC indices */ - *bit_pos = add( *bit_pos, ivas_param_mc_range_decoder_LC( &bit_buffer[*bit_pos], delta_idx, BER_detect, sz_seq, sz_alphabet, - hParamCodingInfo->cum_freq_delta, hParamCodingInfo->sym_freq_delta, PARAM_MC_RANGE_CODER_TOT_SHIFT, max_bits - *bit_pos ) ); + *bit_pos = add( *bit_pos, ivas_param_mc_range_decoder_LC_fx( &bit_buffer[*bit_pos], delta_idx, BER_detect, sz_seq, sz_alphabet, + hParamCodingInfo->cum_freq_delta, hParamCodingInfo->sym_freq_delta, PARAM_MC_RANGE_CODER_TOT_SHIFT, sub( max_bits, *bit_pos ) ) ); + move16(); /* delta index to absolute index */ FOR( j = 0; j < sz_seq; j++ ) { idx[j] = add( idx_prev, sub( delta_idx[j], idx_offset ) ); idx_prev = idx[j]; + move16(); } } ELSE { /* read range coded absolute ICC indices */ sz_alphabet = hParamCodingInfo->quantizer_size; - *bit_pos = add( *bit_pos, ivas_param_mc_range_decoder_LC( &bit_buffer[*bit_pos], idx, BER_detect, sz_seq, sz_alphabet, - hParamCodingInfo->cum_freq, hParamCodingInfo->sym_freq, PARAM_MC_RANGE_CODER_TOT_SHIFT, max_bits - *bit_pos ) ); + move16(); + *bit_pos = add( *bit_pos, ivas_param_mc_range_decoder_LC_fx( &bit_buffer[*bit_pos], idx, BER_detect, sz_seq, sz_alphabet, + hParamCodingInfo->cum_freq, hParamCodingInfo->sym_freq, PARAM_MC_RANGE_CODER_TOT_SHIFT, sub( max_bits, *bit_pos ) ) ); + move16(); } /* dequantize */ FOR( j = 0; j < sz_seq; j++ ) { dequant_seq_fx[j] = hParamCodingInfo->quantizer_fx[idx[j]]; + move16(); } } ELSE @@ -6651,6 +6985,7 @@ static void ivas_param_mc_bs_decode_parameter_values_fx( set16_fx( dequant_seq_fx, 0, PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_VAL_MAP_SIZE ); /* read uniformly coded ICCs */ *bit_pos = add( *bit_pos, ivas_param_mc_uniform_decoder_fx( dequant_seq_fx, sz_seq, hParamCodingInfo->quantizer_fx, hParamCodingInfo->uni_bits, &bit_buffer[*bit_pos] ) ); + move16(); } /* reorder from sequential to parameter-band-wise */ @@ -6659,7 +6994,9 @@ static void ivas_param_mc_bs_decode_parameter_values_fx( { FOR( i = 0; i < num_param_bands; ++i ) { - dequant_ordered_fx[j + i * map_size] = dequant_seq_fx[k++]; + dequant_ordered_fx[add( j, imult1616( i, map_size ) )] = dequant_seq_fx[k]; + move16(); + k = add( k, 1 ); } } @@ -6667,7 +7004,9 @@ static void ivas_param_mc_bs_decode_parameter_values_fx( { FOR( j = 0; j < n_lfe_idx; j++ ) { - dequant_ordered_fx[map_size - n_lfe_idx + j + i * map_size] = dequant_seq_fx[k++]; + dequant_ordered_fx[add( add( sub( map_size, n_lfe_idx ), j ), imult1616( i, map_size ) )] = dequant_seq_fx[k]; + move16(); + k = add( k, 1 ); } } @@ -6676,14 +7015,15 @@ static void ivas_param_mc_bs_decode_parameter_values_fx( j = 0; FOR( k = 0; k < hMetadataPMC->nbands_coded; k += band_step ) { + test(); IF( hMetadataPMC->bAttackPresent || EQ_16( hMetadataPMC->param_frame_idx, hMetadataPMC->coding_band_mapping[k] ) ) { - Copy( dequant_ordered_fx + j * map_size, value_buffer + k * map_size, map_size ); + Copy( dequant_ordered_fx + imult1616( j, map_size ), value_buffer + imult1616( k, map_size ), map_size ); j++; } IF( hMetadataPMC->bAttackPresent && k + 1 < hMetadataPMC->nbands_coded ) { - Copy( value_buffer + k * map_size, value_buffer + ( k + 1 ) * map_size, map_size ); + Copy( value_buffer + imult1616( k, map_size ), value_buffer + imult1616( add( k, 1 ), map_size ), map_size ); } } } diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 43dfffa4e71fe66fd51df9f8b576fa95da526e40..b8d3fac665c03af8dcb19ba140227b4acbd2c496 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -56,21 +56,21 @@ *-----------------------------------------------------------------------*/ /* boxes = { 0 1 2 3 [4 6] [5 7] [8 10] [9 11] }; */ -const int16_t MC_PARAMUPMIX_CHIDX1[MC_PARAMUPMIX_COMBINATIONS] = { 0, 1, 4, 5 }; -const int16_t MC_PARAMUPMIX_CHIDX2[MC_PARAMUPMIX_COMBINATIONS] = { 2, 3, 6, 7 }; +const Word16 MC_PARAMUPMIX_CHIDX1[MC_PARAMUPMIX_COMBINATIONS] = { 0, 1, 4, 5 }; +const Word16 MC_PARAMUPMIX_CHIDX2[MC_PARAMUPMIX_COMBINATIONS] = { 2, 3, 6, 7 }; /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ -static void ps_pred_process_sf( MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, DECODER_TC_BUFFER_HANDLE hTcBuffer, Word32 qmf_mod_re_fx[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 qmf_mod_im_fx[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 qmf_side_re_fx[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 qmf_side_im_fx[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word16 *param_interpol_fx, const int16_t ch, const int16_t slots_rendered ); +static void ps_pred_process_sf( MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, DECODER_TC_BUFFER_HANDLE hTcBuffer, Word32 qmf_mod_re_fx[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 qmf_mod_im_fx[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 qmf_side_re_fx[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 qmf_side_im_fx[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word16 *param_interpol_fx, const Word16 ch, const Word16 slots_rendered ); static void ivas_mc_paramupmix_dec_sf( Decoder_Struct *st_ivas, Word32 *output_fx[MAX_OUTPUT_CHANNELS] ); -static void ivas_param_upmix_dec_decorr_subframes( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering ); +static void ivas_param_upmix_dec_decorr_subframes( Decoder_Struct *st_ivas, const Word16 nSamplesForRendering ); -static int16_t huff_read( Decoder_State *st, const int16_t ( *ht )[2] ); +static Word16 huff_read( Decoder_State *st, const Word16 ( *ht )[2] ); static void huffman_decode( Decoder_State *st, const PAR_TYPE parType, Word32 *vq ); @@ -102,6 +102,7 @@ void ivas_mc_paramupmix_dec_read_BS( push_wmops( "mc_paramupmix_read_bs" ); *nb_bits = 0; + move16(); IF( st0->bfi ) { @@ -111,16 +112,22 @@ void ivas_mc_paramupmix_dec_read_BS( { hMCParamUpmix->alphas_fx[i][k] = hMCParamUpmix->alpha_prev_fx[i][k]; hMCParamUpmix->betas_fx[i][k] = hMCParamUpmix->beta_prev_fx[i][k]; + move32(); + move32(); } } hMCParamUpmix->first_frame = 1; + move16(); } ELSE /* IF (!st->bfi) */ { bit_stream_orig = st0->bit_stream; next_bit_pos_orig = st0->next_bit_pos; - last_bit_pos = (Word16) L_sub( ( st_ivas->hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ), 1 ); + move16(); + Word32 L_temp = Mpy_32_32( st_ivas->hDecoderConfig->ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ); + last_bit_pos = extract_l( L_sub( L_temp, 1 ) ); nb_bits_read_orig = 0; + move16(); last_bit_pos = sub( last_bit_pos, nb_bits_read_orig ); /* reverse the bitstream for easier reading of indices */ FOR( i = 0; i < s_min( MAX_BITS_METADATA, last_bit_pos ); i++ ) { @@ -128,8 +135,11 @@ void ivas_mc_paramupmix_dec_read_BS( } st0->bit_stream = bstr_meta; st0->next_bit_pos = 0; + move16(); st0->bits_frame = s_min( MAX_BITS_METADATA, add( last_bit_pos, 1 ) ); + move16(); st0->total_brate = st_ivas->hDecoderConfig->ivas_total_brate; /* to avoid BER detect */ + move32(); FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { @@ -138,8 +148,10 @@ void ivas_mc_paramupmix_dec_read_BS( get_ec_data( st0, BETA, hMCParamUpmix->beta_quant[i], alpha_quant, hMCParamUpmix->betas_fx[i] ); } *nb_bits = add( *nb_bits, st0->next_bit_pos ); + move16(); st0->bit_stream = bit_stream_orig; st0->next_bit_pos = next_bit_pos_orig; + move16(); IF( hMCParamUpmix->first_frame ) { @@ -149,6 +161,7 @@ void ivas_mc_paramupmix_dec_read_BS( Copy32( hMCParamUpmix->betas_fx[i], hMCParamUpmix->beta_prev_fx[i], IVAS_MAX_NUM_BANDS ); } hMCParamUpmix->first_frame = 0; + move16(); } } @@ -193,16 +206,16 @@ void ivas_mc_paramupmix_dec_digest_tc( *------------------------------------------------------------------------*/ void ivas_mc_paramupmix_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - Word32 *input_fx[], /* i : core-coder transport channels */ - Word32 *output_fx[] /* i/o: synthesized core-coder transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ + UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ + UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + Word32 *input_fx[], /* i : core-coder transport channels */ + Word32 *output_fx[] /* i/o: synthesized core-coder transport channels */ ) { - int16_t slots_to_render, first_sf, last_sf, subframe_idx; - uint16_t slot_size, ch; + Word16 slots_to_render, first_sf, last_sf, subframe_idx; + UWord16 slot_size, ch; Word32 *output_local_fx[MAX_OUTPUT_CHANNELS]; MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; @@ -211,44 +224,48 @@ void ivas_mc_paramupmix_dec_render( push_wmops( "ivas_mc_paramupmix_dec_render" ); - for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { output_local_fx[ch] = output_fx[ch]; } slot_size = st_ivas->hTcBuffer->n_samples_granularity; + move16(); /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, nSamplesAsked / slot_size ); - *nSamplesRendered = slots_to_render * slot_size; + slots_to_render = s_min( sub( st_ivas->hTcBuffer->num_slots, st_ivas->hTcBuffer->slots_rendered ), idiv1616( nSamplesAsked, slot_size ) ); + *nSamplesRendered = imult1616( slots_to_render, (Word16) slot_size ); + move16(); first_sf = st_ivas->hTcBuffer->subframes_rendered; + move16(); last_sf = first_sf; + move16(); - for ( ch = 0; ch < MAX_TRANSPORT_CHANNELS; ch++ ) + FOR( ch = 0; ch < MAX_TRANSPORT_CHANNELS; ch++ ) { Copy32( input_fx[ch], output_local_fx[ch], *nSamplesRendered ); } - while ( slots_to_render > 0 ) + WHILE( slots_to_render > 0 ) { - slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; - last_sf++; + slots_to_render = sub( slots_to_render, st_ivas->hTcBuffer->subframe_nbslots[last_sf] ); + last_sf = add( last_sf, 1 ); } { - for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) + FOR( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) { Copy32( hMCParamUpmix->alpha_prev_fx[ch], hMCParamUpmix->alpha_sf_fx[ch], IVAS_MAX_NUM_BANDS ); Copy32( hMCParamUpmix->beta_prev_fx[ch], hMCParamUpmix->beta_sf_fx[ch], IVAS_MAX_NUM_BANDS ); } - for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) + FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { - int16_t n_samples_sf = slot_size * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]; + Word16 n_samples_sf = imult1616( (Word16) slot_size, st_ivas->hTcBuffer->subframe_nbslots[subframe_idx] ); ivas_mc_paramupmix_dec_sf( st_ivas, output_local_fx ); - for ( ch = 0; ch < min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) ); ch++ ) + FOR( ch = 0; ch < s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) ); ch++ ) { output_local_fx[ch] += n_samples_sf; } @@ -256,14 +273,15 @@ void ivas_mc_paramupmix_dec_render( /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); } - for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) + FOR( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) { Copy32( hMCParamUpmix->alphas_fx[ch], hMCParamUpmix->alpha_prev_fx[ch], IVAS_MAX_NUM_BANDS ); Copy32( hMCParamUpmix->betas_fx[ch], hMCParamUpmix->beta_prev_fx[ch], IVAS_MAX_NUM_BANDS ); } } - *nSamplesAvailable = ( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered ) * slot_size; + *nSamplesAvailable = imult1616( sub( st_ivas->hTcBuffer->num_slots, st_ivas->hTcBuffer->slots_rendered ), (Word16) slot_size ); + move16(); pop_wmops(); return; @@ -287,7 +305,7 @@ ivas_error ivas_mc_paramupmix_dec_open( ivas_error error; error = IVAS_ERR_OK; - + move32(); /*-----------------------------------------------------------------* * prepare library opening @@ -298,16 +316,23 @@ ivas_error ivas_mc_paramupmix_dec_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param-Upmix MC\n" ) ); } output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); hMCParamUpmix->first_frame = 1; + move16(); st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; + move16(); nchan_transport = st_ivas->nchan_transport; + move16(); SWITCH( nchan_transport ) { case 8: st_ivas->nCPE = 4; + move16(); st_ivas->nSCE = 0; + move16(); st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); BREAK; } @@ -317,9 +342,9 @@ ivas_error ivas_mc_paramupmix_dec_open( * set input parameters *-----------------------------------------------------------------*/ - hMCParamUpmix->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); + hMCParamUpmix->num_freq_bands = (Word16) Mpy_32_32_r( output_Fs, INV_CLDFB_BANDWIDTH_Q31 ); - for ( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) + FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { ivas_td_decorr_dec_open_fx( &( hMCParamUpmix->hTdDecorr[i] ), output_Fs, 2, 1 ); } @@ -347,16 +372,18 @@ ivas_error ivas_mc_paramupmix_dec_open( /* allocate transport channels*/ hMCParamUpmix->free_param_interpolator = 0; + move16(); IF( ( hMCParamUpmix->param_interpolator_fx = (Word16 *) malloc( MAX_JBM_CLDFB_TIMESLOTS * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) ); } hMCParamUpmix->free_param_interpolator = 1; + move16(); ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, DEFAULT_JBM_CLDFB_TIMESLOTS, hMCParamUpmix->param_interpolator_fx ); - if ( st_ivas->hTcBuffer == NULL ) + IF( st_ivas->hTcBuffer == NULL ) { int16_t nchan_to_allocate; int16_t nchan_tc; @@ -365,19 +392,27 @@ ivas_error ivas_mc_paramupmix_dec_open( buffer_mode = TC_BUFFER_MODE_RENDERER; nchan_tc = ivas_jbm_dec_get_num_tc_channels( st_ivas ); nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS; + move16(); - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) + test(); + test(); + test(); + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) ) { buffer_mode = TC_BUFFER_MODE_BUFFER; + move32(); nchan_tc = st_ivas->hDecoderConfig->nchan_out; + move16(); nchan_to_allocate = nchan_tc; + move16(); } - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { nchan_to_allocate = MC_PARAMUPMIX_MAX_INPUT_CHANS; + move16(); } - if ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { return error; } @@ -398,31 +433,31 @@ void ivas_mc_paramupmix_dec_close( MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix /* i/o: Parametric MC decoder handle */ ) { - int16_t i; + Word16 i; - if ( hMCParamUpmix == NULL || *hMCParamUpmix == NULL ) + IF( hMCParamUpmix == NULL || *hMCParamUpmix == NULL ) { return; } - for ( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) + FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { ivas_td_decorr_dec_close( &( ( *hMCParamUpmix )->hTdDecorr[i] ) ); } - for ( i = 0; i < MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; i++ ) + FOR( i = 0; i < MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; i++ ) { IF( ( *hMCParamUpmix )->pcm_delay_fx[i] != NULL ) { free( ( *hMCParamUpmix )->pcm_delay_fx[i] ); } } - if ( ( *hMCParamUpmix )->param_interpolator_fx != NULL ) + IF( ( *hMCParamUpmix )->param_interpolator_fx != NULL ) { - if ( ( *hMCParamUpmix )->free_param_interpolator == 1 ) + IF( EQ_16( ( *hMCParamUpmix )->free_param_interpolator, 1 ) ) { free( ( *hMCParamUpmix )->param_interpolator_fx ); } } - if ( ( *hMCParamUpmix )->hoa_encoder_fx != NULL ) + IF( ( *hMCParamUpmix )->hoa_encoder_fx != NULL ) { free( ( *hMCParamUpmix )->hoa_encoder_fx ); ( *hMCParamUpmix )->hoa_encoder_fx = NULL; @@ -446,18 +481,18 @@ static void paramupmix_td_decorr_process_jbm_fx( Word32 *pcm_in[], /* i : input audio channels */ Word32 **pp_out_pcm, /* o : output audio channels */ const Word16 output_frame, /* i : output frame length */ - Word32 *q_format ) + Word16 *q_format ) { Word16 j, k; Word16 offset; Word32 in_duck_gain[L_FRAME48k], out_duck_gain[L_FRAME48k]; - offset = (Word16) ( output_frame / 10 ); + offset = idiv1616( output_frame, 10 ); /* Look-ahead delay */ FOR( k = 0; k < MC_PARAMUPMIX_COMBINATIONS; k++ ) { - mvl2l( pcm_in[k], pp_out_pcm[k], output_frame ); + Copy32( pcm_in[k], pp_out_pcm[k], output_frame ); delay_signal_fx( pp_out_pcm[k], output_frame, hTdDecorr[k]->look_ahead_buf, offset ); /* In ducking gains */ @@ -468,8 +503,10 @@ static void paramupmix_td_decorr_process_jbm_fx( FOR( j = 0; j < output_frame; j++ ) { pp_out_pcm[k][j] = Mpy_32_32( pp_out_pcm[k][j], in_duck_gain[j] ); + move16(); } - q_format[k] -= Q1; + q_format[k] = sub( q_format[k], Q1 ); + move16(); } /* All pass delay section */ @@ -481,8 +518,10 @@ static void paramupmix_td_decorr_process_jbm_fx( FOR( j = 0; j < output_frame; j++ ) { pp_out_pcm[k][j] = Mpy_32_32( pp_out_pcm[k][j], out_duck_gain[j] ); + move32(); } - q_format[k] -= Q1; + q_format[k] = sub( q_format[k], Q1 ); + move16(); } } @@ -498,13 +537,13 @@ static void paramupmix_td_decorr_process_jbm_fx( static void ivas_param_upmix_dec_decorr_subframes( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nSamplesForRendering ) + const Word16 nSamplesForRendering ) { MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; Word32 *pPcm_tmp_fx[MC_PARAMUPMIX_COMBINATIONS]; Word32 *p_tc_fx[MC_PARAMUPMIX_COMBINATIONS]; - int16_t nchan_internal, ch; - int16_t nSamplesLeftForTD, default_frame; + Word16 nchan_internal, ch; + Word16 nSamplesLeftForTD, default_frame; hMCParamUpmix = st_ivas->hMCParamUpmix; assert( hMCParamUpmix ); @@ -512,41 +551,44 @@ static void ivas_param_upmix_dec_decorr_subframes( push_wmops( "ivas_param_upmix_dec_decorr_subframes" ); /* TD decorrelator */ - default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + default_frame = extract_l( Mpy_32_32( st_ivas->hDecoderConfig->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); nSamplesLeftForTD = nSamplesForRendering; + move16(); nchan_internal = MC_PARAMUPMIX_COMBINATIONS; + move16(); - for ( ch = 0; ch < nchan_internal; ch++ ) + FOR( ch = 0; ch < nchan_internal; ch++ ) { - pPcm_tmp_fx[ch] = st_ivas->hTcBuffer->tc_fx[ch + 8]; - p_tc_fx[ch] = st_ivas->hTcBuffer->tc_fx[ch + 4]; + pPcm_tmp_fx[ch] = st_ivas->hTcBuffer->tc_fx[add( ch, 8 )]; + p_tc_fx[ch] = st_ivas->hTcBuffer->tc_fx[add( ch, 4 )]; } - while ( nSamplesLeftForTD ) + WHILE( nSamplesLeftForTD ) { - int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); + Word16 nSamplesToDecorr = s_min( nSamplesLeftForTD, default_frame ); { - Word32 i, q_format[MC_PARAMUPMIX_COMBINATIONS]; + Word16 i, q_format[MC_PARAMUPMIX_COMBINATIONS]; FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { q_format[i] = Q11; + move16(); } paramupmix_td_decorr_process_jbm_fx( hMCParamUpmix->hTdDecorr, p_tc_fx, pPcm_tmp_fx, nSamplesToDecorr, q_format ); FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { - Scale_sig32( pPcm_tmp_fx[i], nSamplesToDecorr, Q11 - extract_l( q_format[i] ) ); + Scale_sig32( pPcm_tmp_fx[i], nSamplesToDecorr, sub( Q11, q_format[i] ) ); } } - for ( ch = 0; ch < nchan_internal; ch++ ) + FOR( ch = 0; ch < nchan_internal; ch++ ) { p_tc_fx[ch] += nSamplesToDecorr; } - nSamplesLeftForTD -= nSamplesToDecorr; + nSamplesLeftForTD = sub( nSamplesLeftForTD, nSamplesToDecorr ); } pop_wmops(); @@ -566,11 +608,11 @@ static void ps_pred_process_sf( Word32 qmf_side_re_fx[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* in/out */ Word32 qmf_side_im_fx[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word16 *param_interpol_fx, - const int16_t ch, - const int16_t slots_rendered ) + const Word16 ch, + const Word16 slots_rendered ) { Word32 vmre_fx, vmim_fx, vsre_fx, vsim_fx; - int16_t iqmf, ipar, ismp, iismp; + Word16 iqmf, ipar, ismp, iismp; Word32 alpha_smp_fx, beta_smp_fx; Word32 *alpha1_fx, *alpha2_fx; Word32 *beta1_fx, *beta2_fx; @@ -582,7 +624,7 @@ static void ps_pred_process_sf( Word16 ifac_fx; Word32 alpha_start_fx[IVAS_MAX_NUM_BANDS], beta_start_fx[IVAS_MAX_NUM_BANDS]; Word32 res_a, res_b; - const int16_t qmf_to_par_band[] = { + const Word16 qmf_to_par_band[] = { 0, 1, 2, 3, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, @@ -593,27 +635,33 @@ static void ps_pred_process_sf( Copy32( alpha_sf_fx, alpha_start_fx, IVAS_MAX_NUM_BANDS ); Copy32( beta_sf_fx, beta_start_fx, IVAS_MAX_NUM_BANDS ); - for ( iqmf = 0; iqmf < CLDFB_NO_CHANNELS_MAX; iqmf++ ) + FOR( iqmf = 0; iqmf < CLDFB_NO_CHANNELS_MAX; iqmf++ ) { ipar = qmf_to_par_band[iqmf]; + move16(); alpha1_fx = alpha_prev_fx; + move16(); beta1_fx = beta_prev_fx; + move16(); ismp = 0; alpha2_fx = hMCParamUpmix->alphas_fx[ch]; beta2_fx = hMCParamUpmix->betas_fx[ch]; alpha_smp_fx = alpha_start_fx[ipar]; + move32(); beta_smp_fx = beta_start_fx[ipar]; + move32(); - for ( iismp = 0; iismp < hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered]; iismp++ ) + FOR( iismp = 0; iismp < hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered]; iismp++ ) { - if ( ( slots_rendered == 0 ) && ( iismp == 0 ) ) + IF( ( slots_rendered == 0 ) && ( iismp == 0 ) ) { ifac_fx = param_interpol_fx[iismp]; + move16(); } - else + ELSE { - ifac_fx = sub( param_interpol_fx[iismp], param_interpol_fx[iismp - 1] ); + ifac_fx = sub( param_interpol_fx[iismp], param_interpol_fx[sub( iismp, 1 )] ); } dalpha_fx = Mpy_32_16_1( L_sub( alpha2_fx[ipar], alpha1_fx[ipar] ), ifac_fx ); dbeta_fx = Mpy_32_16_1( L_sub( beta2_fx[ipar], beta1_fx[ipar] ), ifac_fx ); @@ -622,9 +670,13 @@ static void ps_pred_process_sf( beta_smp_fx = L_add( dbeta_fx, beta_smp_fx ); vmre_fx = qmf_mod_re_fx[ismp][iqmf]; + move32(); vmim_fx = qmf_mod_im_fx[ismp][iqmf]; + move32(); vsre_fx = qmf_side_re_fx[ismp][iqmf]; + move32(); vsim_fx = qmf_side_im_fx[ismp][iqmf]; + move32(); res_a = L_shl_sat( Mpy_32_32( alpha_smp_fx, vmre_fx ), Q31 - Q28 ); res_b = L_shl_sat( Mpy_32_32( beta_smp_fx, vsre_fx ), Q31 - Q28 ); @@ -634,10 +686,12 @@ static void ps_pred_process_sf( res_b = L_shl_sat( Mpy_32_32( beta_smp_fx, vsim_fx ), Q31 - Q28 ); qmf_side_re_fx[ismp][iqmf] = L_add_sat( res_a, res_b ); - ismp++; + ismp = add( ismp, 1 ); } alpha_sf_fx[ipar] = alpha_smp_fx; + move32(); beta_sf_fx[ipar] = beta_smp_fx; + move32(); } return; @@ -649,15 +703,15 @@ static void ivas_mc_paramupmix_dec_sf( Word32 *output_fx[MAX_OUTPUT_CHANNELS] /* i/o: synthesized core-coder transport channels */ ) { - int16_t i, ch, slot_idx, k; + Word16 i, ch, slot_idx, k; Word32 *pPcm_temp_fx[MC_PARAMUPMIX_COMBINATIONS * 2]; /* decorrelated and undecorrelated*/ /*CLDFB*/ Word32 Cldfb_RealBuffer_fx[MC_PARAMUPMIX_MAX_TRANSPORT_CHANS][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX] = { 0 }; Word32 Cldfb_ImagBuffer_fx[MC_PARAMUPMIX_MAX_TRANSPORT_CHANS][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX] = { 0 }; - int16_t noparamupmix_delay, n_samples_rendered; + Word16 noparamupmix_delay, n_samples_rendered; MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; - int16_t subframeIdx, idx_in, maxBand; + Word16 subframeIdx, idx_in, maxBand; #ifdef MSAN_FIX Word32 Cldfb_RealBuffer_subfr_fx[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] = { 0 }; Word32 Cldfb_ImagBuffer_subfr_fx[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] = { 0 }; @@ -672,96 +726,110 @@ static void ivas_mc_paramupmix_dec_sf( assert( hMCParamUpmix ); push_wmops( "ivas_mc_paramupmix_dec_sf" ); - for ( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) + FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { pPcm_temp_fx[2 * i] = output_fx[i + 4]; /* un-decorrelated */ pPcm_temp_fx[2 * i + 1] = output_fx[i + 8]; /* decorrelated */ } /* CLDFB Analysis*/ - for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS * 2; ch++ ) + FOR( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS * 2; ch++ ) { /* slot loop for gathering the input data */ - for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) + FOR( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) { Word16 q_cldfb = 11; - cldfbAnalysis_ts_fx_fixed_q( &( pPcm_temp_fx[ch][hMCParamUpmix->num_freq_bands * slot_idx] ), Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], hMCParamUpmix->num_freq_bands, st_ivas->cldfbAnaDec[ch], &q_cldfb ); + move16(); + cldfbAnalysis_ts_fx_fixed_q( &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ), Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], hMCParamUpmix->num_freq_bands, st_ivas->cldfbAnaDec[ch], &q_cldfb ); } } - for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) + FOR( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) { ps_pred_process_sf( hMCParamUpmix, st_ivas->hTcBuffer, - Cldfb_RealBuffer_fx[2 * ch], /* in/out */ - Cldfb_ImagBuffer_fx[2 * ch], - Cldfb_RealBuffer_fx[2 * ch + 1], /* in/out decorr */ - Cldfb_ImagBuffer_fx[2 * ch + 1], + Cldfb_RealBuffer_fx[shl( ch, 1 )], /* in/out */ + Cldfb_ImagBuffer_fx[shl( ch, 1 )], + Cldfb_RealBuffer_fx[add( shl( ch, 1 ), 1 )], /* in/out decorr */ + Cldfb_ImagBuffer_fx[add( shl( ch, 1 ), 1 )], &hMCParamUpmix->param_interpolator_fx[st_ivas->hTcBuffer->slots_rendered], ch, st_ivas->hTcBuffer->slots_rendered ); /*-- m, s -> l, r ----------------------------*/ - for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) + FOR( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) { - for ( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) { Word32 qlre_fx = Cldfb_RealBuffer_fx[2 * ch][slot_idx][k]; Word32 qlim_fx = Cldfb_ImagBuffer_fx[2 * ch][slot_idx][k]; Word32 qrre_fx = Cldfb_RealBuffer_fx[2 * ch + 1][slot_idx][k]; Word32 qrim_fx = Cldfb_ImagBuffer_fx[2 * ch + 1][slot_idx][k]; - - Cldfb_RealBuffer_fx[2 * ch][slot_idx][k] = L_add_sat( qlre_fx, qrre_fx ); - Cldfb_ImagBuffer_fx[2 * ch][slot_idx][k] = L_add_sat( qlim_fx, qrim_fx ); - Cldfb_RealBuffer_fx[2 * ch + 1][slot_idx][k] = L_sub_sat( qlre_fx, qrre_fx ); - Cldfb_ImagBuffer_fx[2 * ch + 1][slot_idx][k] = L_sub_sat( qlim_fx, qrim_fx ); + move32(); + move32(); + move32(); + move32(); + + Cldfb_RealBuffer_fx[shl( ch, 1 )][slot_idx][k] = L_add_sat( qlre_fx, qrre_fx ); + Cldfb_ImagBuffer_fx[shl( ch, 1 )][slot_idx][k] = L_add_sat( qlim_fx, qrim_fx ); + Cldfb_RealBuffer_fx[add( shl( ch, 1 ), 1 )][slot_idx][k] = L_sub_sat( qlre_fx, qrre_fx ); + Cldfb_ImagBuffer_fx[add( shl( ch, 1 ), 1 )][slot_idx][k] = L_sub_sat( qlim_fx, qrim_fx ); + move32(); + move32(); + move32(); + move32(); } } } - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); + Word16 temp_e; + maxBand = BASOP_Util_Divide3232_Scale( (Word32) W_mult0_32_32( CLDFB_NO_CHANNELS_MAX, st_ivas->hDecoderConfig->output_Fs ), 48000, &temp_e ); + maxBand = shr( maxBand, sub( 15, temp_e ) ); subframeIdx = st_ivas->hTcBuffer->subframes_rendered; + move16(); /* fastconv binaural rendering and CLDFB synthesis */ /* cldfb analysis of non-coupled, non-LFE channels */ idx_in = 0; - for ( ch = 0; ch < MC_PARAMUPMIX_MAX_INPUT_CHANS - 2 * MC_PARAMUPMIX_COMBINATIONS; ch++ ) + move16(); + FOR( ch = 0; ch < MC_PARAMUPMIX_MAX_INPUT_CHANS - 2 * MC_PARAMUPMIX_COMBINATIONS; ch++ ) { - if ( st_ivas->hIntSetup.index_lfe[0] != ch ) + IF( st_ivas->hIntSetup.index_lfe[0] != ch ) { pPcm_temp_fx[ch] = output_fx[ch]; /* slot loop for gathering the input data */ - for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) + FOR( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) { Word16 q_cldfb = 11; + move16(); - cldfbAnalysis_ts_fx_fixed_q( &( pPcm_temp_fx[ch][hMCParamUpmix->num_freq_bands * slot_idx] ), + cldfbAnalysis_ts_fx_fixed_q( &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ), Cldfb_RealBuffer_subfr_fx[idx_in][slot_idx], Cldfb_ImagBuffer_subfr_fx[idx_in][slot_idx], - maxBand, st_ivas->cldfbAnaDec[2 * MC_PARAMUPMIX_COMBINATIONS + idx_in], &q_cldfb ); + maxBand, st_ivas->cldfbAnaDec[add( MC_PARAMUPMIX_COMBINATIONS * 2, idx_in )], &q_cldfb ); } - idx_in++; + idx_in = add( idx_in, 1 ); } } /* copy and reorder cldfb analysis of coupled channels */ - for ( ch = 0; ch < MAX_PARAM_SPATIAL_SUBFRAMES; ch++ ) + FOR( ch = 0; ch < MAX_PARAM_SPATIAL_SUBFRAMES; ch++ ) { - for ( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) + FOR( slot_idx = 0; slot_idx < MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { Copy32( Cldfb_RealBuffer_fx[MC_PARAMUPMIX_CHIDX1[ch]][slot_idx], Cldfb_RealBuffer_subfr_fx[idx_in][slot_idx], CLDFB_NO_CHANNELS_MAX ); Copy32( Cldfb_ImagBuffer_fx[MC_PARAMUPMIX_CHIDX1[ch]][slot_idx], Cldfb_ImagBuffer_subfr_fx[idx_in][slot_idx], CLDFB_NO_CHANNELS_MAX ); Copy32( Cldfb_RealBuffer_fx[MC_PARAMUPMIX_CHIDX2[ch]][slot_idx], Cldfb_RealBuffer_subfr_fx[idx_in + 1][slot_idx], CLDFB_NO_CHANNELS_MAX ); Copy32( Cldfb_ImagBuffer_fx[MC_PARAMUPMIX_CHIDX2[ch]][slot_idx], Cldfb_ImagBuffer_subfr_fx[idx_in + 1][slot_idx], CLDFB_NO_CHANNELS_MAX ); } - idx_in += 2; + idx_in = add( idx_in, 2 ); } - if ( st_ivas->hCombinedOrientationData && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + IF( st_ivas->hCombinedOrientationData && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { - for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) + FOR( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) { ivas_param_mc_mc2sba_cldfb_fx( st_ivas->hTransSetup, hMCParamUpmix->hoa_encoder_fx, slot_idx, Cldfb_RealBuffer_subfr_fx, Cldfb_ImagBuffer_subfr_fx, maxBand, GAIN_LFE_FX ); } @@ -770,6 +838,7 @@ static void ivas_mc_paramupmix_dec_sf( /* Implement binaural rendering */ Word16 input_q = 6; + move16(); /* Implement binaural rendering */ ivas_binRenderer_fx( st_ivas->hBinRenderer, st_ivas->hCombinedOrientationData, @@ -778,37 +847,39 @@ static void ivas_mc_paramupmix_dec_sf( Cldfb_RealBuffer_subfr_fx, Cldfb_ImagBuffer_subfr_fx, &input_q ); - for ( int idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) + FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) { - for ( int idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ ) + FOR( Word16 idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ ) { - Scale_sig32( Cldfb_RealBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, 6 - input_q ); - Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, 6 - input_q ); + Scale_sig32( Cldfb_RealBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); + Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); } } /* Implement CLDFB synthesis */ - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { Word32 *RealBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; - for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) + FOR( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) { RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch][slot_idx]; ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch][slot_idx]; } - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, sub( Q5, Q11 ) ); + scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q5 - Q11 ); st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q5; + move16(); cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], st_ivas->cldfbSynDec[ch] ); - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, sub( Q11, Q5 ) ); + scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q11 - Q5 ); st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; + move16(); } - for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - Scale_sig32( output_fx[ch], maxBand * st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], 6 ); + Scale_sig32( output_fx[ch], imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 6 ); } } - else + ELSE { /* boxes = { 0 1 2 3 [4 6] [5 7] [8 10] [9 11] }; */ pPcm_temp_fx[0] = output_fx[4]; @@ -821,57 +892,59 @@ static void ivas_mc_paramupmix_dec_sf( pPcm_temp_fx[7] = output_fx[11]; /* CLDFB synthesis */ - for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS * 2; ch++ ) + FOR( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS * 2; ch++ ) { scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, sub( Q5, st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q5; - for ( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) + move16(); + FOR( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; slot_idx++ ) { Word32 *ptr_im_fx[1], *ptr_re_fx[1]; ptr_re_fx[0] = Cldfb_RealBuffer_fx[ch][slot_idx]; ptr_im_fx[0] = Cldfb_ImagBuffer_fx[ch][slot_idx]; - cldfbSynthesis_ivas_fx( ptr_re_fx, ptr_im_fx, &( pPcm_temp_fx[ch][hMCParamUpmix->num_freq_bands * slot_idx] ), + cldfbSynthesis_ivas_fx( ptr_re_fx, ptr_im_fx, &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ), hMCParamUpmix->num_freq_bands, st_ivas->cldfbSynDec[ch] ); } scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; + move16(); } // Done to keep entire buffer in q11 - for ( ch = 4; ch < 12; ch++ ) + FOR( ch = 4; ch < 12; ch++ ) { - Scale_sig32( output_fx[ch], hMCParamUpmix->num_freq_bands * st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered], 6 ); + Scale_sig32( output_fx[ch], imult1616( hMCParamUpmix->num_freq_bands, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered] ), 6 ); } /* adjust delay of other channels */ noparamupmix_delay = NS2SA( st_ivas->hDecoderConfig->output_Fs, IVAS_FB_DEC_DELAY_NS ); - n_samples_rendered = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered] * hMCParamUpmix->num_freq_bands; - if ( n_samples_rendered > noparamupmix_delay ) + n_samples_rendered = imult1616( st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered], hMCParamUpmix->num_freq_bands ); + IF( n_samples_rendered > noparamupmix_delay ) { - for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) + FOR( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) { Word32 tmp_buf_fx[L_SUBFRAME5MS_48k]; - Copy32( &output_fx[ch][n_samples_rendered - noparamupmix_delay], tmp_buf_fx, noparamupmix_delay ); - Copy32( output_fx[ch], &output_fx[ch][noparamupmix_delay], n_samples_rendered - noparamupmix_delay ); + Copy32( &output_fx[ch][sub( n_samples_rendered, noparamupmix_delay )], tmp_buf_fx, noparamupmix_delay ); + Copy32( output_fx[ch], &output_fx[ch][noparamupmix_delay], sub( n_samples_rendered, noparamupmix_delay ) ); Copy32( hMCParamUpmix->pcm_delay_fx[ch], output_fx[ch], noparamupmix_delay ); Copy32( tmp_buf_fx, hMCParamUpmix->pcm_delay_fx[ch], noparamupmix_delay ); } } - else + ELSE { - for ( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) + FOR( ch = 0; ch < MC_PARAMUPMIX_COMBINATIONS; ch++ ) { Word32 tmp_buf_fx[L_SUBFRAME5MS_48k]; Copy32( &output_fx[ch][0], tmp_buf_fx, n_samples_rendered ); Copy32( hMCParamUpmix->pcm_delay_fx[ch], output_fx[ch], n_samples_rendered ); - Copy32( &hMCParamUpmix->pcm_delay_fx[ch][n_samples_rendered], &hMCParamUpmix->pcm_delay_fx[ch][0], noparamupmix_delay - n_samples_rendered ); - Copy32( tmp_buf_fx, &hMCParamUpmix->pcm_delay_fx[ch][noparamupmix_delay - n_samples_rendered], n_samples_rendered ); + Copy32( &hMCParamUpmix->pcm_delay_fx[ch][n_samples_rendered], &hMCParamUpmix->pcm_delay_fx[ch][0], sub( noparamupmix_delay, n_samples_rendered ) ); + Copy32( tmp_buf_fx, &hMCParamUpmix->pcm_delay_fx[ch][sub( noparamupmix_delay, n_samples_rendered )], n_samples_rendered ); } } } - st_ivas->hTcBuffer->slots_rendered += st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered]; - st_ivas->hTcBuffer->subframes_rendered++; + st_ivas->hTcBuffer->slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->subframes_rendered] ); + st_ivas->hTcBuffer->subframes_rendered = add( st_ivas->hTcBuffer->subframes_rendered, 1 ); pop_wmops(); return; @@ -888,10 +961,13 @@ static Word16 huff_read( DO { next_bit = st->bit_stream[st->next_bit_pos]; - st->next_bit_pos++; + move16(); + st->next_bit_pos = add( st->next_bit_pos, 1 ); + move16(); node = ht[node][next_bit]; + move16(); } - WHILE( GT_16( node, 0 ) ); + WHILE( node > 0 ); return negate( add( node, 1 ) ); } @@ -906,13 +982,16 @@ static void huffman_decode( Word16 iv, nquant, offset; nquant = 0; + move16(); SWITCH( parType ) { case ALPHA: nquant = ivas_mc_paramupmix_alpha_quant_table_fx.nquant; + move16(); BREAK; case BETA: nquant = ivas_mc_paramupmix_beta_quant_table_fx[0].nquant; + move16(); BREAK; default: assert( 0 ); @@ -950,6 +1029,7 @@ static void huffman_decode( FOR( iv = 1; iv < IVAS_MAX_NUM_BANDS; iv++ ) { vq[iv] = L_sub( L_add( huff_read( st, huff_node_table ), vq[sub( iv, 1 )] ), offset ); + move32(); } return; @@ -966,6 +1046,7 @@ static void dequant_alpha( FOR( iv = 0; iv < IVAS_MAX_NUM_BANDS; iv++ ) { v[iv] = quant_table->data[vq[iv]]; + move32(); } return; @@ -984,6 +1065,7 @@ static void dequant_beta( { quant_table = &ivas_mc_paramupmix_beta_quant_table_fx[ivas_param_upmx_mx_qmap[aq[iv]]]; beta[iv] = quant_table->data[bq[iv]]; + move32(); } return; @@ -1002,7 +1084,7 @@ static void get_ec_data( IF( EQ_32( parType, ALPHA ) ) { dequant_alpha( parQ, ab ); - mvl2l( parQ, alphaQEnv, (Word16) IVAS_MAX_NUM_BANDS ); + Copy32( parQ, alphaQEnv, (Word16) IVAS_MAX_NUM_BANDS ); } ELSE { diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 3e11870eb439bf0e678bf8102cfb424b1448f6cd..235543277fee39a3951e2ed040d8b8e88a21de3e 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -330,13 +330,17 @@ ivas_error ivas_mct_dec_fx( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; move32(); + test(); + test(); + test(); + test(); IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && ( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) ) { /* save LFE channel */ - mvl2l( output_fx[LFE_CHANNEL], output_lfe_ch_fx, output_frame ); + Copy32( output_fx[LFE_CHANNEL], output_lfe_ch_fx, output_frame ); } - IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) && EQ_16( st_ivas->bfi, 0 ) ) + IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) && ( st_ivas->bfi == 0 ) ) { /* get the number of channels from the signalled MC LS setup */ n = ivas_mc_ls_setup_get_num_channels_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ) ); @@ -353,24 +357,24 @@ ivas_error ivas_mct_dec_fx( /*initialize param_lpc buffer*/ FOR( n = 0; n < CPE_CHANNELS; n++ ) { - set_s( param_lpc[cpe_id][n], 0, NPRM_LPC_NEW ); + set16_fx( param_lpc[cpe_id][n], 0, NPRM_LPC_NEW ); } set32_fx( &output_fx[0][0], 0, L_FRAME48k ); set32_fx( &output_fx[1][0], 0, L_FRAME48k ); - IF( ( error = ivas_cpe_dec_fx( st_ivas, cpe_id, &output_fx[0], output_frame, 0, &q_output ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, cpe_id, &output_fx[0], output_frame, 0, &q_output ) ), IVAS_ERR_OK ) ) { return error; } - IF( EQ_16( cpe_id, 0 ) ) + if ( cpe_id == 0 ) { st_ivas->hCPE[0]->hCoreCoder[0]->total_brate = ivas_total_brate; /* set high enough to read the whole side-info; total_brate is rewritten later in ivas_mdct_core_invQ() */ move32(); } - IF( EQ_16( st_ivas->bfi, 0 ) ) + IF( st_ivas->bfi == 0 ) { ivas_mdct_dec_side_bits_frame_channel_fx( st_ivas->hCPE[cpe_id], param_lpc[cpe_id], p_param[cpe_id], st_ivas->hCPE[0]->hCoreCoder[0], nTnsBitsTCX10[cpe_id], param[cpe_id], 1, (Word16) GT_16( i_mult( add( cpe_id, 1 ), CPE_CHANNELS ), hMCT->nchan_out_woLFE ) ); @@ -394,15 +398,15 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - x_fx[n][0] = output_fx[n + cpe_id * CPE_CHANNELS]; + x_fx[n][0] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )]; x_e[n][0] = 20; - x_fx[n][1] = output_fx[n + cpe_id * CPE_CHANNELS] + shr( L_FRAME48k, 1 ); - x_e[n][1] = 20; move16(); + x_fx[n][1] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )] + ( L_FRAME48k / 2 ); + x_e[n][1] = 20; move16(); - set32_fx( x_fx[n][0], 0, shr( L_FRAME48k, 1 ) ); - set32_fx( x_fx[n][1], 0, shr( L_FRAME48k, 1 ) ); + set32_fx( x_fx[n][0], 0, L_FRAME48k / 2 ); + set32_fx( x_fx[n][1], 0, L_FRAME48k / 2 ); } ivas_mdct_core_invQ_fx( st_ivas->hCPE[cpe_id], nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id], @@ -410,16 +414,27 @@ ivas_error ivas_mct_dec_fx( FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - Word16 subFrames = ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_10_CORE ) ? NB_DIV : 1; + Word16 subFrames; + IF( EQ_16( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core, TCX_10_CORE ) ) + { + subFrames = NB_DIV; + } + ELSE + { + subFrames = 1; + } + move16(); FOR( k = 0; k < subFrames; ++k ) { - Scale_sig32( x_fx[ch][k], shr( L_FRAME48k, subFrames - 1 ), sub( x_e[ch][k], 20 ) ); + Scale_sig32( x_fx[ch][k], shr( L_FRAME48k, sub( subFrames, 1 ) ), sub( x_e[ch][k], 20 ) ); } } st_ivas->BER_detect = s_or( st_ivas->BER_detect, st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect ); + move16(); test(); st_ivas->BER_detect = s_or( st_ivas->BER_detect, st_ivas->hCPE[cpe_id]->hCoreCoder[1]->BER_detect ); + move16(); test(); } @@ -441,7 +456,8 @@ ivas_error ivas_mct_dec_fx( /* for sba to stereo output disable any further processing for TCs > 2 as it is not needed*/ - IF( NE_16( st_ivas->sba_dirac_stereo_flag, 0 ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + test(); + IF( ( st_ivas->sba_dirac_stereo_flag != 0 ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { FOR( cpe_id = 1; cpe_id < nCPE; cpe_id++ ) { @@ -460,9 +476,9 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - Copy_Scale_sig_16_32( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, sub( Q16, Q12 ) ); - x_fx[n][0] = output_fx[n + cpe_id * CPE_CHANNELS]; - x_fx[n][1] = output_fx[n + cpe_id * CPE_CHANNELS] + ( L_FRAME48k / 2 ); + Copy_Scale_sig_16_32( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); + x_fx[n][0] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )]; + x_fx[n][1] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )] + ( L_FRAME48k / 2 ); x_e[n][0] = 20; move16(); x_e[n][1] = 20; @@ -473,9 +489,18 @@ ivas_error ivas_mct_dec_fx( FOR( Word16 ind = 0; ind < 2; ind++ ) { - Word16 nSubFrames = EQ_16( hCPE->hCoreCoder[ind]->core, TCX_20_CORE ) ? 1 : NB_DIV; + Word16 nSubFrames; + IF( EQ_16( hCPE->hCoreCoder[ind]->core, TCX_20_CORE ) ) + { + nSubFrames = 1; + } + ELSE + { + nSubFrames = NB_DIV; + } + move16(); Scale_sig32( x_fx[ind][0], shr( L_FRAME48k, sub( nSubFrames, 1 ) ), sub( x_e[ind][0], 20 ) ); - IF( nSubFrames == 2 ) + IF( EQ_16( nSubFrames, 2 ) ) { Scale_sig32( x_fx[ind][1], shr( L_FRAME48k, 1 ), sub( x_e[ind][1], 20 ) ); } @@ -483,6 +508,8 @@ ivas_error ivas_mct_dec_fx( } + test(); + test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_MC ) ) { /* Equalization in MDCT Domain */ @@ -496,11 +523,11 @@ ivas_error ivas_mct_dec_fx( { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - x_all_fx[n + cpe_id * CPE_CHANNELS][0] = output_fx[n + cpe_id * CPE_CHANNELS]; - x_all_fx[n + cpe_id * CPE_CHANNELS][1] = output_fx[n + cpe_id * CPE_CHANNELS] + ( L_FRAME48k / 2 ); - x_all_e[n + cpe_id * CPE_CHANNELS][1] = 20; + x_all_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][0] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )]; + x_all_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][1] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )] + ( L_FRAME48k / 2 ); + x_all_e[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][1] = 20; move16(); - x_all_e[n + cpe_id * CPE_CHANNELS][0] = 20; + x_all_e[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][0] = 20; move16(); } } @@ -511,8 +538,8 @@ ivas_error ivas_mct_dec_fx( { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - Scale_sig32( x_all_fx[n + cpe_id * CPE_CHANNELS][0], shr( L_FRAME48k, 1 ), sub( x_all_e[n + cpe_id * CPE_CHANNELS][0], 20 ) ); - Scale_sig32( x_all_fx[n + cpe_id * CPE_CHANNELS][1], shr( L_FRAME48k, 1 ), sub( x_all_e[n + cpe_id * CPE_CHANNELS][1], 20 ) ); + Scale_sig32( x_all_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][0], ( L_FRAME48k / 2 ), sub( x_all_e[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][0], 20 ) ); + Scale_sig32( x_all_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][1], ( L_FRAME48k / 2 ), sub( x_all_e[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][1], 20 ) ); } } } @@ -524,35 +551,36 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - x_fx[n][0] = output_fx[n + cpe_id * CPE_CHANNELS]; - x_fx[n][1] = output_fx[n + cpe_id * CPE_CHANNELS] + ( L_FRAME48k / 2 ); + x_fx[n][0] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )]; + x_fx[n][1] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )] + ( L_FRAME48k / 2 ); } FOR( n = 0; n < CPE_CHANNELS; n++ ) { - IF( NE_16( hCPE->hCoreCoder[n]->Q_syn, 0 ) ) + IF( hCPE->hCoreCoder[n]->Q_syn != 0 ) { Scale_sig( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[n]->Q_syn ); } if ( sts[n]->hTcxDec && sts[n]->hTcxDec->conCngLevelBackgroundTrace_e < 0 ) { sts[n]->hTcxDec->conCngLevelBackgroundTrace_e = 0; + move16(); } } - Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, M + 1, ( 28 - norm_s( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0] - 1 ) ) ); - Copy_Scale_sig_16_32( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, M + 1, ( 28 - norm_s( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0] - 1 ) ) ); + Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ); + Copy_Scale_sig_16_32( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ); ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, q_output, 15 ); FOR( n = 0; n < CPE_CHANNELS; n++ ) { - IF( NE_16( hCPE->hCoreCoder[n]->Q_syn, 0 ) ) + IF( hCPE->hCoreCoder[n]->Q_syn != 0 ) { Scale_sig( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, L_FRAME48k, negate( hCPE->hCoreCoder[n]->Q_syn ) ); } IF( hCPE->hCoreCoder[n]->hBPF ) { - hCPE->hCoreCoder[n]->hBPF->pst_mem_deemp_err_fx = extract_l( L_shr( hCPE->hCoreCoder[n]->mem_error, sub( Q16, hCPE->hCoreCoder[n]->Q_syn2 - 1 ) ) ); - Scale_sig( hCPE->hCoreCoder[n]->hBPF->pst_old_syn_fx, NBPSF_PIT_MAX, hCPE->hCoreCoder[n]->Q_syn2 - 1 ); + hCPE->hCoreCoder[n]->hBPF->pst_mem_deemp_err_fx = extract_l( L_shr( hCPE->hCoreCoder[n]->mem_error, sub( Q16, sub( hCPE->hCoreCoder[n]->Q_syn2, 1 ) ) ) ); + Scale_sig( hCPE->hCoreCoder[n]->hBPF->pst_old_syn_fx, NBPSF_PIT_MAX, sub( hCPE->hCoreCoder[n]->Q_syn2, 1 ) ); } IF( hCPE->hCoreCoder[n]->hTcxDec ) { @@ -572,16 +600,18 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - IF( NE_16( st_ivas->sba_dirac_stereo_flag, 0 ) && ( NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) || GE_16( cpe_id, sub( nCPE, 2 ) ) ) ) + test(); + test(); + IF( ( st_ivas->sba_dirac_stereo_flag != 0 ) && ( NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) || GE_16( cpe_id, sub( nCPE, 2 ) ) ) ) { - Copy_Scale_sig_16_32( synth_fx[n], synth_fx_32[n], L_FRAME48k, sub( Q11, 0 ) ); + Copy_Scale_sig_16_32( synth_fx[n], synth_fx_32[n], L_FRAME48k, Q11 - 0 ); Copy_Scale_sig_16_32( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, hCPE->hCoreCoder[n]->hHQ_core->oldOut_fx, output_frame, Q11 ); ivas_post_proc_fx( NULL, hCPE, n, synth_fx_32[n], NULL, output_frame, 1 ); #ifdef MSAN_FIX - Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], output_frame, sub( 0, Q11 ) ); + Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], output_frame, 0 - Q11 ); #else - Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], L_FRAME48k, sub( 0, Q11 ) ); + Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], L_FRAME48k, 0 - Q11 ); #endif } @@ -589,7 +619,7 @@ ivas_error ivas_mct_dec_fx( Word16 output_mem_fx[L_FRAME48k]; IF( hCPE->output_mem_fx[1] != NULL ) { - Copy_Scale_sig_32_16( hCPE->output_mem_fx[1], output_mem_fx, NS2SA( sts[n]->output_Fs, 3125000 ), sub( 0, Q11 ) ); + Copy_Scale_sig_32_16( hCPE->output_mem_fx[1], output_mem_fx, NS2SA( sts[n]->output_Fs, 3125000 ), 0 - Q11 ); } ELSE { @@ -597,25 +627,37 @@ ivas_error ivas_mct_dec_fx( } Word16 Q_synth = 0; + move16(); - IF( ( error = core_switching_post_dec_ivas_fx( sts[n], synth_fx[n], output_fx[cpe_id * CPE_CHANNELS + n], output_mem_fx, st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, ( st_ivas->ivas_format != SBA_ISM_FORMAT || cpe_id >= nCPE - 2 ) ? st_ivas->sba_dirac_stereo_flag : 0, -1, hCPE->last_element_mode, &Q_synth ) ) != IVAS_ERR_OK ) + Word16 dirac_stereo_flag; + test(); + IF( NE_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) || GE_16( cpe_id, sub( nCPE, 2 ) ) ) + { + dirac_stereo_flag = st_ivas->sba_dirac_stereo_flag; + } + ELSE + { + dirac_stereo_flag = 0; + } + IF( NE_32( ( error = core_switching_post_dec_ivas_fx( sts[n], synth_fx[n], output_fx[add( shl( cpe_id, 1 /* * CPE_CHANNELS*/ ), n )], output_mem_fx, st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) { return error; } - Copy_Scale_sig_16_32( synth_fx[n], output_fx[cpe_id * CPE_CHANNELS + n], output_frame, sub( Q11, Q_synth ) ); + Copy_Scale_sig_16_32( synth_fx[n], output_fx[add( shl( cpe_id, 1 /* * CPE_CHANNELS*/ ), n )], output_frame, sub( Q11, Q_synth ) ); /* Save synthesis for HQ FEC */ Word32 output_fx_[L_FRAME48k]; - mvl2l( output_fx[cpe_id * CPE_CHANNELS + n], output_fx_, L_FRAME48k ); - Scale_sig32( output_fx_, L_FRAME48k, sub( Q16, Q11 ) ); + mvl2l( output_fx[add( shl( cpe_id, 1 /* * CPE_CHANNELS*/ ), n )], output_fx_, L_FRAME48k ); + Scale_sig32( output_fx_, L_FRAME48k, Q16 - Q11 ); Copy_Scale_sig32_16( sts[n]->prev_synth_buffer32_fx, sts[n]->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); sts[n]->q_prev_synth_buffer_fx = 0; + move16(); save_synthesis_hq_fec_fx( sts[n], output_fx_, output_frame, hCPE ); /* CoreCoder common updates */ - ivas_updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, output_fx[cpe_id * CPE_CHANNELS + n], 11 ); + ivas_updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, output_fx[add( shl( cpe_id, 1 /* * CPE_CHANNELS*/ ), n )], 11 ); } /* n_channels loop */ @@ -628,28 +670,32 @@ ivas_error ivas_mct_dec_fx( } /* synthesis synchronization between stereo modes */ - IF( EQ_16( st_ivas->sba_dirac_stereo_flag, 0 ) || ( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && LT_16( cpe_id, sub( nCPE, 2 ) ) ) ) + test(); + test(); + IF( ( st_ivas->sba_dirac_stereo_flag == 0 ) || ( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && LT_16( cpe_id, sub( nCPE, 2 ) ) ) ) { - synchro_synthesis_fx( ivas_total_brate, hCPE, output_fx + cpe_id * CPE_CHANNELS, output_frame, 0 ); + synchro_synthesis_fx( ivas_total_brate, hCPE, output_fx + imult1616( cpe_id, CPE_CHANNELS ), output_frame, 0 ); } } /* move channels after LFE to correct output for multi-channel MCT */ + test(); + test(); IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && ( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) ) { Word32 tmp[L_FRAME48k]; /*save center channel output*/ - mvl2l( output_fx[hMCT->nchan_out_woLFE - 1], tmp, output_frame ); + Copy32( output_fx[sub( hMCT->nchan_out_woLFE, 1 )], tmp, output_frame ); - FOR( n = hMCT->nchan_out_woLFE - 1; n >= LFE_CHANNEL; n-- ) + FOR( n = sub( hMCT->nchan_out_woLFE, 1 ); n >= LFE_CHANNEL; n-- ) { - mvl2l( output_fx[n - 1], output_fx[n + 1], output_frame ); + Copy32( output_fx[sub( n, 1 )], output_fx[add( n, 1 )], output_frame ); } - mvl2l( tmp, output_fx[LFE_CHANNEL - 1], output_frame ); + Copy32( tmp, output_fx[sub( LFE_CHANNEL, 1 )], output_frame ); /* save LFE channel */ - mvl2l( output_lfe_ch_fx, output_fx[LFE_CHANNEL], output_frame ); + Copy32( output_lfe_ch_fx, output_fx[LFE_CHANNEL], output_frame ); } pop_wmops(); @@ -688,21 +734,29 @@ ivas_error create_mct_dec_fx( *-----------------------------------------------------------------*/ /* Determine active channels */ + test(); + test(); + test(); + test(); IF( ( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) || EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { hMCT->nchan_out_woLFE = st_ivas->nchan_transport; + move16(); IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { hMCT->nchan_out_woLFE = add( hMCT->nchan_out_woLFE, st_ivas->nchan_ism ); + move16(); } } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) ) { hMCT->nchan_out_woLFE = sub( st_ivas->nchan_transport, st_ivas->hTransSetup.num_lfe ); + move16(); } ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { hMCT->nchan_out_woLFE = sub( st_ivas->nchan_transport, st_ivas->hTransSetup.num_lfe ); + move16(); } ELSE { @@ -722,13 +776,15 @@ ivas_error create_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; + move32(); } } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ IF( hMCT->nchan_out_woLFE % 2 ) { - st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; + st_ivas->hCPE[sub( st_ivas->nCPE, 1 )]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; + move32(); } /*Initialize MCT block data */ @@ -744,7 +800,8 @@ ivas_error create_mct_dec_fx( /*Initialize all parameters to zero*/ hMCT->hBlockData[n]->ch1 = 0; hMCT->hBlockData[n]->ch2 = 0; - + move16(); + move16(); /*-----------------------------------------------------------------* * MDCT stereo initialization *-----------------------------------------------------------------*/ @@ -757,7 +814,10 @@ ivas_error create_mct_dec_fx( initMdctStereoDecData_fx( hMCT->hBlockData[n]->hStereoMdct, st_ivas->hCPE[0]->hCoreCoder[0]->igf, st_ivas->hCPE[0]->hCoreCoder[0]->hIGFDec->igfData.igfInfo.grid, cp_bitrate, SWB ); hMCT->hBlockData[n]->hStereoMdct->use_itd = 0; hMCT->hBlockData[n]->hStereoMdct->reverse_dmx = 0; + move16(); + move16(); hMCT->hBlockData[n]->hStereoMdct->smooth_ratio_fx = ONE_IN_Q26; + move32(); } FOR( ; n < MCT_MAX_BLOCKS; n++ ) { @@ -769,10 +829,11 @@ ivas_error create_mct_dec_fx( *-----------------------------------------------------------------*/ hMCT->currBlockDataCnt = 0; + move16(); /*Initialize bits required to signal channel-pair index*/ // hMCT->bitsChannelPairIndex = max( 1, (Word16) ( floorf( ( logf( (float) hMCT->nchan_out_woLFE * ( hMCT->nchan_out_woLFE - 1 ) / 2 - 1 ) * INV_LOG_2 ) ) + 1 ) ); - hMCT->bitsChannelPairIndex = s_max( 1, floor_log_2( (Word32) hMCT->nchan_out_woLFE * ( (Word32) hMCT->nchan_out_woLFE - 1 ) / 2 - 1 ) + 1 ); + hMCT->bitsChannelPairIndex = s_max( 1, add( floor_log_2( sub( shr( imult1616( hMCT->nchan_out_woLFE, sub( hMCT->nchan_out_woLFE, 1 ) ), 1 ), 1 ) ), 1 ) ); set16_fx( hMCT->chBitRatios, 0, MCT_MAX_CHANNELS ); set16_fx( hMCT->lowE_ch, 0, MCT_MAX_CHANNELS ); @@ -938,15 +999,18 @@ ivas_error mct_dec_reconfigure_fx( IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { hMCT->nchan_out_woLFE = add( hMCT->nchan_out_woLFE, st_ivas->nchan_ism ); + move16(); } } ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) { hMCT->nchan_out_woLFE = sub( st_ivas->nchan_transport, st_ivas->hTransSetup.num_lfe ); + move16(); } ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { hMCT->nchan_out_woLFE = sub( st_ivas->nchan_transport, st_ivas->hTransSetup.num_lfe ); + move16(); } ELSE { @@ -960,6 +1024,7 @@ ivas_error mct_dec_reconfigure_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; + move32(); } } @@ -967,15 +1032,16 @@ ivas_error mct_dec_reconfigure_fx( IF( hMCT->nchan_out_woLFE % 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; + move32(); } tmp = BASOP_Util_Divide3216_Scale( st_ivas->hDecoderConfig->ivas_total_brate, hMCT->nchan_out_woLFE, &tmp_exp ); - cp_bitrate = L_shl( tmp, tmp_exp + 2 ); + cp_bitrate = L_shl( tmp, add( tmp_exp, 2 ) ); IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { tmp = BASOP_Util_Divide3216_Scale( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, &tmp_exp ); - cp_bitrate = L_shl( tmp, tmp_exp + 2 ); + cp_bitrate = L_shl( tmp, add( tmp_exp, 2 ) ); } /* set correct nominal bitrates and igf config already here, otherwise we @@ -994,8 +1060,10 @@ ivas_error mct_dec_reconfigure_fx( IF( NE_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { tmp = BASOP_Util_Divide3232_Scale( st_ivas->hCPE[cpe_id]->element_brate, FRAMES_PER_SEC, &tmp_exp ); - st->bits_frame_nominal = shr( tmp, 15 - tmp_exp ); + st->bits_frame_nominal = shr( tmp, sub( 15, tmp_exp ) ); + move16(); st->igf = getIgfPresent_fx( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag ); // no floating point so directly pluggable + move16(); IF( st->igf ) { @@ -1007,7 +1075,7 @@ ivas_error mct_dec_reconfigure_fx( /*Initialize MCT block data */ tmp = BASOP_Util_Divide1616_Scale( hMCT->nchan_out_woLFE, CPE_CHANNELS, &tmp_exp ); - max_blocks = shr( tmp, 15 - tmp_exp ); + max_blocks = shr( tmp, sub( 15, tmp_exp ) ); FOR( n = 0; n < max_blocks; n++ ) { @@ -1071,16 +1139,16 @@ ivas_error mct_dec_reconfigure_fx( L_tmp = L_sub( L_shr( L_mult0( hMCT->nchan_out_woLFE, sub( hMCT->nchan_out_woLFE, 1 ) ), 1 ), 1 ); tmp_exp = norm_l( L_tmp ); L_tmp = L_shl( L_tmp, tmp_exp ); - log_tmp = BASOP_Util_Log2( L_tmp ); // ( 31 - tmp_exp ) - log_tmp = L_add( log_tmp, L_shl( ( Q31 - tmp_exp ), Q25 ) ); // Q25 + log_tmp = BASOP_Util_Log2( L_tmp ); // ( 31 - tmp_exp ) + log_tmp = L_add( log_tmp, L_shl( sub( Q31, tmp_exp ), Q25 ) ); // Q25 // scale down from Q25 to Q0 tmp = extract_l( L_shr( log_tmp, Q25 ) ); tmp = add( tmp, 1 ); hMCT->bitsChannelPairIndex = s_max( 1, tmp ); - set_s( hMCT->chBitRatios, 0, MCT_MAX_CHANNELS ); - set_s( hMCT->lowE_ch, 0, MCT_MAX_CHANNELS ); + set16_fx( hMCT->chBitRatios, 0, MCT_MAX_CHANNELS ); + set16_fx( hMCT->lowE_ch, 0, MCT_MAX_CHANNELS ); } return IVAS_ERR_OK; @@ -1250,6 +1318,7 @@ void ivas_mct_dec_close( { Word16 n, maxBlocks; + test(); IF( hMCT == NULL || *hMCT == NULL ) { return; @@ -1335,32 +1404,36 @@ ivas_error ivas_mc_dec_config_fx( /* store last frame MC mode */ last_mc_mode = st_ivas->mc_mode; - IF( EQ_16( st_ivas->bfi, 0 ) ) + IF( st_ivas->bfi == 0 ) { /* set transported MC LS setup */ signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx ); - IF( EQ_16( st_ivas->ini_frame, 0 ) ) + if ( st_ivas->ini_frame == 0 ) { st_ivas->transport_config = signaled_config; + move32(); } /* select MC format mode */ st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), st_ivas->hDecoderConfig->ivas_total_brate ); + move32(); /* MC format switching */ IF( st_ivas->ini_frame != 0 ) { + test(); IF( NE_32( st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->hDecoderConfig->ivas_total_brate ) || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode ) { IF( st_ivas->hRenderConfig ) { FOR( Word16 i = 0; i < 4; i++ ) { - st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = shl_sat( st_ivas->hRenderConfig->directivity_fx[i * 3 + 2], 9 ); + st_ivas->hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 2 )] = shl_sat( st_ivas->hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 2 )], 9 ); + move16(); } } - IF( ( error = ivas_mc_dec_reconfig_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mc_dec_reconfig_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) { return error; } @@ -1368,13 +1441,15 @@ ivas_error ivas_mc_dec_config_fx( { FOR( Word16 i = 0; i < 4; i++ ) { - st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = shr( st_ivas->hRenderConfig->directivity_fx[i * 3 + 2], 9 ); + st_ivas->hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 2 )] = shr( st_ivas->hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 2 )], 9 ); + move16(); } } } } st_ivas->transport_config = signaled_config; + move32(); } return IVAS_ERR_OK; @@ -1457,22 +1532,31 @@ static ivas_error ivas_mc_dec_reconfig_fx( Word16 nchan_out_buff_old, nchan_out_buff; error = IVAS_ERR_OK; + move32(); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + move32(); nchan_transport_old = st_ivas->nchan_transport; + move16(); nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); last_mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */ /* temporally set the current mc_mode back to the previous one to make sure the following call to ivas_init_dec_get_num_cldfb_instances() returns the correct counts */ mc_mode = st_ivas->mc_mode; + move32(); st_ivas->mc_mode = last_mc_mode; + move32(); ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); st_ivas->mc_mode = mc_mode; + move32(); nSCE_old = st_ivas->nSCE; + move16(); nCPE_old = st_ivas->nCPE; + move16(); sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; + move16(); /* special handling needed for the hp20 buffers for McMASA */ IF( EQ_16( last_mc_mode, MC_MODE_MCMASA ) ) @@ -1482,45 +1566,60 @@ static ivas_error ivas_mc_dec_reconfig_fx( ELSE { nchan_hp20_old = nchan_transport_old; + move16(); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); + move16(); /* save old IntSetup, might be needed for JBM flushing...*/ intern_config_old = st_ivas->intern_config; + move32(); hIntSetupOld = st_ivas->hIntSetup; tc_granularity_new = 1; + move16(); /* renderer might have changed, reselect */ renderer_type_old = st_ivas->renderer_type; + move32(); ivas_renderer_select( st_ivas ); /* side effect of the renderer selection can be a changed internal config */ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); /* transfer subframe info from DirAC or ParamMC to central tc buffer */ + test(); IF( EQ_16( last_mc_mode, MC_MODE_PARAMMC ) ) { st_ivas->hTcBuffer->nb_subframes = st_ivas->hParamMC->nb_subframes; + move16(); st_ivas->hTcBuffer->subframes_rendered = st_ivas->hParamMC->subframes_rendered; + move16(); st_ivas->hTcBuffer->num_slots = st_ivas->hParamMC->num_slots; + move16(); st_ivas->hTcBuffer->slots_rendered = st_ivas->hParamMC->slots_rendered; + move16(); Copy( st_ivas->hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } ELSE IF( EQ_16( last_mc_mode, MC_MODE_MCMASA ) && st_ivas->hSpatParamRendCom != NULL ) { st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; + move16(); st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; + move16(); st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; + move16(); st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; + move16(); Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + move16(); IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { - IF( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) { return error; } @@ -1528,7 +1627,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { - IF( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -1536,8 +1635,11 @@ static ivas_error ivas_mc_dec_reconfig_fx( IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) ) { st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ) ); + move16(); st_ivas->nSCE = 0; - st_ivas->nCPE = st_ivas->nchan_transport / 2; + move16(); + st_ivas->nCPE = shr( st_ivas->nchan_transport, 1 ); + move16(); IF( NE_16( last_mc_mode, MC_MODE_MCT ) ) { @@ -1569,9 +1671,10 @@ static ivas_error ivas_mc_dec_reconfig_fx( } /* init LS conversion if the renderer type asks for it */ + test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_MC ) && st_ivas->hLsSetUpConversion == NULL ) { - if ( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -1581,8 +1684,11 @@ static ivas_error ivas_mc_dec_reconfig_fx( ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { st_ivas->nSCE = 0; + move16(); st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / 2; + move16(); st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; + move16(); IF( NE_16( last_mc_mode, MC_MODE_PARAMUPMIX ) ) { @@ -1599,15 +1705,16 @@ static ivas_error ivas_mc_dec_reconfig_fx( ivas_qmetadata_close( &st_ivas->hQMetaData ); /* init LS conversion if the renderer type asks for it */ + test(); IF( ( EQ_16( st_ivas->renderer_type, RENDERER_MC ) ) && st_ivas->hLsSetUpConversion == NULL ) { - IF( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } } - IF( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -1618,19 +1725,20 @@ static ivas_error ivas_mc_dec_reconfig_fx( IF( NE_16( last_mc_mode, MC_MODE_PARAMMC ) ) { /* remove old ls conversion for MCT if open, gets reopened correctly within ivas_param_mc_dec_open when needed */ + test(); IF( EQ_16( renderer_type_old, RENDERER_MC ) && st_ivas->hLsSetUpConversion != NULL ) { ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); } - IF( ( error = ivas_param_mc_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_param_mc_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } } ELSE { - IF( ( error = ivas_param_mc_dec_reconfig_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_param_mc_dec_reconfig_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -1650,6 +1758,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( IF( EQ_16( last_mc_mode, MC_MODE_MCT ) ) { + test(); IF( st_ivas->hMCT != NULL && LE_16( st_ivas->nchan_transport, CPE_CHANNELS ) ) { ivas_mct_dec_close( &st_ivas->hMCT ); @@ -1669,13 +1778,13 @@ static ivas_error ivas_mc_dec_reconfig_fx( IF( NE_16( last_mc_mode, MC_MODE_MCMASA ) ) { - IF( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) ) { return error; } } - IF( ( error = ivas_mcmasa_dec_reconfig( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mcmasa_dec_reconfig( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -1713,6 +1822,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( { st_ivas->element_mode_init = IVAS_CPE_MDCT; } + move16(); } /*-----------------------------------------------------------------* @@ -1722,11 +1832,13 @@ static ivas_error ivas_mc_dec_reconfig_fx( /* special case: MCT->ParamMC with more than 2 TC, CPE 1 stays, but has the wrong mct_chan_mode in channel 1 and might have IGF static memory not allocated and the bit stream index list not set, set correct mct_chan_mode and init missing static mem (IGF, HQ) and some config (TNS) do it here since it is _very_ MC specific */ + test(); + test(); IF( EQ_16( last_mc_mode, MC_MODE_MCT ) && EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) && GT_16( st_ivas->nchan_transport, CPE_CHANNELS ) ) { st = st_ivas->hCPE[1]->hCoreCoder[1]; - IF( st_ivas->nchan_transport == 3 ) + IF( EQ_16( st_ivas->nchan_transport, 3 ) ) { st->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } @@ -1734,6 +1846,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( { st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; } + move32(); IF( st->hIGFDec == NULL ) { @@ -1743,6 +1856,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( } st->igf = 0; + move16(); init_igf_dec( st->hIGFDec ); #if 1 /*TODO: To be removed later(floating point initialization)*/ #if ( defined EVS_FLOAT ) || !( defined IVAS_FLOAT_FIXED ) @@ -1751,7 +1865,10 @@ static ivas_error ivas_mc_dec_reconfig_fx( set_f( st->hIGFDec->igfData.pSpecFlatBuf, 0, IGF_START_MX ); #endif FOR( Word16 l = 0; l < IGF_START_MX; l++ ) - st->hIGFDec->infoTCXNoise_evs[l] = (uint8_t) st->hIGFDec->infoTCXNoise_evs[l]; + { + st->hIGFDec->infoTCXNoise_evs[l] = (UWord8) st->hIGFDec->infoTCXNoise_evs[l]; + move16(); + } #endif } @@ -1776,31 +1893,46 @@ static ivas_error ivas_mc_dec_reconfig_fx( } st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( ivas_total_brate, st->igf, st->element_mode ); + move16(); } IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { - uint8_t separateChannelEnabled; - int16_t separateChannelIndex; + UWord8 separateChannelEnabled; + Word16 separateChannelIndex; ivas_mcmasa_set_separate_channel_mode_fx( &separateChannelEnabled, &separateChannelIndex, ivas_total_brate ); ivas_mcmasa_split_brate_fx( separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) ) { new_brate_SCE = 0; - new_brate_CPE = ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) ) * CPE_CHANNELS; + move32(); + Word16 temp_e; + Word32 L_temp = BASOP_Util_Divide3232_Scale_cadence( ivas_total_brate, sub( st_ivas->nchan_transport, 1 ), &temp_e ); + L_temp = L_shr( L_temp, sub( 31, temp_e ) ); + new_brate_CPE = L_shl( L_temp, 1 ) /*CPE_CHANNELS*/; } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { new_brate_SCE = 0; - new_brate_CPE = ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) ) * CPE_CHANNELS; + move32(); + Word16 temp_e; + Word32 L_temp = BASOP_Util_Divide3232_Scale_cadence( ivas_total_brate, sub( st_ivas->nchan_transport, 1 ), &temp_e ); + L_temp = L_shr( L_temp, sub( 31, temp_e ) ); + new_brate_CPE = L_shl( L_temp, 1 ) /*CPE_CHANNELS*/; } ELSE { new_brate_SCE = 0; /* ivas_total_brate / st_ivas->nchan_transport;*/ - new_brate_CPE = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; + move32(); + Word16 temp_e; + Word32 L_temp = BASOP_Util_Divide3232_Scale_cadence( ivas_total_brate, st_ivas->nchan_transport, &temp_e ); + L_temp = L_shr( L_temp, sub( 31, temp_e ) ); + new_brate_CPE = L_shl( L_temp, 1 ) /*CPE_CHANNELS*/; } - IF( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, new_brate_SCE, new_brate_CPE ) ) != IVAS_ERR_OK ) + test(); + test(); + IF( NE_32( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, new_brate_SCE, new_brate_CPE ) ), IVAS_ERR_OK ) ) { return error; } @@ -1822,7 +1954,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( /*-----------------------------------------------------------------* * re-configure HP20 memories *-----------------------------------------------------------------*/ - IF( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ), IVAS_ERR_OK ) ) { return error; } @@ -1830,23 +1962,27 @@ static ivas_error ivas_mc_dec_reconfig_fx( * Allocate the LFE handle that is coded separately after the allocation of the core coders *-----------------------------------------------------------------*/ + test(); + test(); IF( ( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) && st_ivas->hLFE == NULL ) { Word32 binauralization_delay_ns = st_ivas->binaural_latency_ns; + move32(); IF( st_ivas->hBinRenderer != NULL ) { IF( st_ivas->hBinRenderer->render_lfe ) { /* Account for filterbank delay */ - binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS; + binauralization_delay_ns = L_add( binauralization_delay_ns, IVAS_FB_DEC_DELAY_NS ); } - else + ELSE { binauralization_delay_ns = 0; + move32(); } } - IF( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ), IVAS_ERR_OK ) ) { return error; } @@ -1861,12 +1997,14 @@ static ivas_error ivas_mc_dec_reconfig_fx( IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { + test(); + test(); IF( ( NE_16( st_ivas->renderer_type, RENDERER_DISABLE ) ) && ( NE_16( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) ) ) { IF( st_ivas->hDirAC != NULL ) { /* reconfigure existing DirAC dec */ - IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) { return error; } @@ -1874,7 +2012,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( ELSE { /* init a new DirAC dec */ - IF( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) ) { return error; } @@ -1894,185 +2032,235 @@ static ivas_error ivas_mc_dec_reconfig_fx( AUDIO_CONFIG output_config; output_config = st_ivas->hDecoderConfig->output_config; + move32(); /* binaural renderers*/ + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); 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 ) ) { /* remove unneeded binaural renderers */ + test(); + test(); IF( st_ivas->hBinRenderer != NULL && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { ivas_binRenderer_close_fx( &st_ivas->hBinRenderer ); } + test(); + test(); + test(); + test(); + test(); IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend != NULL ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || NE_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) ) { ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); } - IF( st_ivas->hBinRendererTd != NULL && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) ) - { + test(); + IF( st_ivas->hBinRendererTd != NULL && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) ){ #ifdef FIX_1033_MEMORY_LEAK_OMASA - if ( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE ) - { + IF( EQ_16( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM, TRUE ) ){ #endif ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); - st_ivas->hHrtfTD = NULL; + st_ivas->hHrtfTD = NULL; #ifdef FIX_1033_MEMORY_LEAK_OMASA - } -#endif - } - - IF( st_ivas->hDiracDecBin != NULL ) - { - IF( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) && NE_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) - { - ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); - } - } - - /* init necessary new renderers */ - IF( st_ivas->hBinRenderer == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) - { - IF( ( error = ivas_binRenderer_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE IF( st_ivas->hBinRendererTd == NULL && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) - { - IF( ( error = ivas_td_binaural_open_fx( st_ivas, &st_ivas->SrcInd[0], &st_ivas->num_src ) ) != IVAS_ERR_OK ) - { - return error; - } - IF( EQ_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) - { - IF( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); - } - - st_ivas->hCrendWrapper->hCrend = NULL; - st_ivas->hCrendWrapper->hHrtfCrend = NULL; - IF( ( st_ivas->hCrendWrapper->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); - } - } - } - ELSE IF( st_ivas->hCrendWrapper == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) ) - { - IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; - } - } - /* mono/stereo */ - ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) - { - /* nothing should happen here... */ - } - /* LS */ - ELSE IF( 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 ) ) - { } +#endif } - /*-----------------------------------------------------------------* - * CLDFB instances - *-----------------------------------------------------------------*/ - IF( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) + IF( st_ivas->hDiracDecBin != NULL ) { - return error; + test(); + test(); + IF( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) && NE_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) + { + ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); + } } - /*-----------------------------------------------------------------* - * JBM TC buffers - *-----------------------------------------------------------------*/ - + /* init necessary new renderers */ + test(); + test(); + test(); + test(); + test(); + IF( st_ivas->hBinRenderer == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { - Word16 tc_nchan_full_new; - DECODER_TC_BUFFER_HANDLE hTcBuffer; - - hTcBuffer = st_ivas->hTcBuffer; - tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); - tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); - tc_nchan_allocate_new = tc_nchan_tc_new; - tc_nchan_full_new = tc_nchan_tc_new; - - IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) + IF( ( error = ivas_binRenderer_open_fx( st_ivas ) ) != IVAS_ERR_OK ) { - tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; - tc_nchan_full_new = tc_nchan_allocate_new; + return error; } - - IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) + } + ELSE IF( st_ivas->hBinRendererTd == NULL && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) + { + IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, &st_ivas->SrcInd[0], &st_ivas->num_src ) ), IVAS_ERR_OK ) ) { - tc_nchan_full_new = 0; + return error; } - ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) + IF( EQ_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - tc_nchan_allocate_new = MC_PARAMUPMIX_MAX_INPUT_CHANS; - tc_buffer_mode_new = TC_BUFFER_MODE_RENDERER; - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) ) + IF( NE_32( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ), IVAS_ERR_OK ) ) { - tc_buffer_mode_new = TC_BUFFER_MODE_BUFFER; - tc_nchan_tc_new = st_ivas->hDecoderConfig->nchan_out; - tc_nchan_allocate_new = tc_nchan_tc_new; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); } - tc_nchan_full_new = tc_nchan_allocate_new; - } - /* reconfigure buffer */ - IF( NE_16( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_jbm, tc_nchan_tc_new ) || - NE_16( hTcBuffer->nchan_buffer_full, tc_nchan_full_new ) || NE_16( hTcBuffer->nchan_transport_internal, tc_nchan_allocate_new ) || - NE_16( tc_granularity_new, hTcBuffer->n_samples_granularity ) ) - { - IF( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK ) + st_ivas->hCrendWrapper->hCrend = NULL; + st_ivas->hCrendWrapper->hHrtfCrend = NULL; + IF( ( st_ivas->hCrendWrapper->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) { - return error; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); } } - /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ - IF( st_ivas->hSpatParamRendCom != NULL ) - { - st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; - st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots; - st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered; - Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); - } - ELSE IF( st_ivas->hParamMC != NULL ) + } + ELSE IF( st_ivas->hCrendWrapper == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) ) + { + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) { - st_ivas->hParamMC->nb_subframes = st_ivas->hTcBuffer->nb_subframes; - st_ivas->hParamMC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; - st_ivas->hParamMC->num_slots = st_ivas->hTcBuffer->num_slots; - st_ivas->hParamMC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; - Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + return error; } + st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; + move32(); } +} +/* mono/stereo */ +ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) +{ + /* nothing should happen here... */ +} +/* LS */ +ELSE IF( 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 ) ) +{ +} +} +/*-----------------------------------------------------------------* + * CLDFB instances + *-----------------------------------------------------------------*/ +IF( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) ) +{ + return error; +} - /*-----------------------------------------------------------------* - * floating-point output audio buffers - *-----------------------------------------------------------------*/ +/*-----------------------------------------------------------------* + * JBM TC buffers + *-----------------------------------------------------------------*/ + +{ + Word16 tc_nchan_full_new; + DECODER_TC_BUFFER_HANDLE hTcBuffer; - nchan_out_buff = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 ); + hTcBuffer = st_ivas->hTcBuffer; + tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); + tc_nchan_allocate_new = tc_nchan_tc_new; + move16(); + tc_nchan_full_new = tc_nchan_tc_new; + move16(); - IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) + test(); + test(); + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { - return error; + tc_nchan_allocate_new = BINAURAL_CHANNELS * 2; + move16(); + tc_nchan_full_new = tc_nchan_allocate_new; + move16(); } -#if 1 /*TODO: To be removed later*/ - if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) + + test(); + test(); + IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { - return error; + tc_nchan_full_new = 0; + move16(); } -#endif + ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) + { + tc_nchan_allocate_new = MC_PARAMUPMIX_MAX_INPUT_CHANS; + move16(); + tc_buffer_mode_new = TC_BUFFER_MODE_RENDERER; + move32(); + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) ) + { + tc_buffer_mode_new = TC_BUFFER_MODE_BUFFER; + move32(); + tc_nchan_tc_new = st_ivas->hDecoderConfig->nchan_out; + move16(); + tc_nchan_allocate_new = tc_nchan_tc_new; + move16(); + } + tc_nchan_full_new = tc_nchan_allocate_new; + move16(); + } + + /* reconfigure buffer */ + test(); + test(); + test(); + test(); + IF( NE_16( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_jbm, tc_nchan_tc_new ) || + NE_16( hTcBuffer->nchan_buffer_full, tc_nchan_full_new ) || NE_16( hTcBuffer->nchan_transport_internal, tc_nchan_allocate_new ) || + NE_16( tc_granularity_new, hTcBuffer->n_samples_granularity ) ) + { + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ + IF( st_ivas->hSpatParamRendCom != NULL ) + { + st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + move16(); + st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + move16(); + st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots; + move16(); + st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + move16(); + Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } + ELSE IF( st_ivas->hParamMC != NULL ) + { + st_ivas->hParamMC->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + move16(); + st_ivas->hParamMC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + move16(); + st_ivas->hParamMC->num_slots = st_ivas->hTcBuffer->num_slots; + move16(); + st_ivas->hParamMC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + move16(); + Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } +} + + +/*-----------------------------------------------------------------* + * floating-point output audio buffers + *-----------------------------------------------------------------*/ + +nchan_out_buff = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 ); + +IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) +{ return error; } +#if 1 /*TODO: To be removed later*/ +if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) +{ + return error; +} +#endif +return error; +} #else static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ diff --git a/lib_dec/ivas_mct_dec_mct_fx.c b/lib_dec/ivas_mct_dec_mct_fx.c index a91acad66e4b078bd40ef62716fb3c0eb845b214..9c3dced3353eb41da9cc277be6c9c8673e0bc1a9 100644 --- a/lib_dec/ivas_mct_dec_mct_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx.c @@ -56,6 +56,7 @@ static void indexToChannelPair_fx( { Word16 ch1, ch2; Word16 tmpIdx = 0; + move16(); FOR( ch2 = 1; ch2 < nChannels; ch2++ ) { @@ -97,6 +98,7 @@ void ivas_mct_dec_mct_fx( MCT_DEC_BLOCK_DATA_HANDLE hBlock; Decoder_State *p_st[CPE_CHANNELS]; Word16 nchan_active = 0; + move16(); hMCT->currBlockDataCnt = get_next_indice_fx( sts[0], MCT_NUM_BLOCK_DATA_BITS ); move16(); @@ -121,8 +123,7 @@ void ivas_mct_dec_mct_fx( { FOR( ch = 0; ch < nchan; ch++ ) { - IF( - NE_16( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + IF( NE_16( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { hMCT->lowE_ch[ch] = get_next_indice_fx( sts[0], 1 ); move16(); @@ -132,9 +133,9 @@ void ivas_mct_dec_mct_fx( FOR( ch = 0; ch < nchan; ch++ ) { - IF( NE_16( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) + if ( NE_16( sts[ch]->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { - nchan_active++; + nchan_active = add( nchan_active, 1 ); } } @@ -177,11 +178,18 @@ static void applyGlobalILD_fx( Word16 q_qratio; Word16 tmp, tmp_e; - FOR( ch = 0; ch < ( hMCT->nchan_out_woLFE ); - ch++ ) + FOR( ch = 0; ch < ( hMCT->nchan_out_woLFE ); ch++ ) { - nSubframes = ( EQ_16( sts[ch]->core, TCX_20_CORE ) ) ? 1 : NB_DIV; - move16(); + IF( EQ_16( sts[ch]->core, TCX_20_CORE ) ) + { + nSubframes = 1; + move16(); + } + ELSE + { + nSubframes = NB_DIV; + move16(); + } tmp = BASOP_Util_Divide1616_Scale( sts[ch]->hTcxDec->L_frameTCX, nSubframes, &tmp_e ); L_subframeTCX = shr( tmp, add( 15, negate( tmp_e ) ) ); @@ -189,7 +197,7 @@ static void applyGlobalILD_fx( { IF( hMCT->lowE_ch[ch] ) { - tmp = BASOP_Util_Divide3216_Scale( (Word32) hMCT->mc_global_ild[ch] << Q26, SMDCT_ILD_RANGE, &tmp_e ); // Q26 + tmp = BASOP_Util_Divide3216_Scale( L_shl( hMCT->mc_global_ild[ch], Q26 ), SMDCT_ILD_RANGE, &tmp_e ); // Q26 qratio = L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) ); } ELSE @@ -204,7 +212,7 @@ static void applyGlobalILD_fx( { v_multc_fixed( x[ch][k], qratio, x[ch][k], L_subframeTCX ); // Qx - 5 + q_qratio } - q_x[ch] = q_x[ch] - 5 + q_qratio; + q_x[ch] = add( sub( q_x[ch], 5 ), q_qratio ); move16(); } ELSE @@ -311,6 +319,7 @@ void mctStereoIGF_dec_fx( { tmp = BASOP_Util_Divide1616_Scale( sts[0]->hTcxCfg->tcx_coded_lines, nSubframes, &tmp_e ); L_spec[0] = shr( tmp, add( 15, negate( tmp_e ) ) ); + move16(); tmp = BASOP_Util_Divide1616_Scale( sts[0]->L_frame, nSubframes, &tmp_e ); L_frame_nSubframe = shr( tmp, add( 15, negate( tmp_e ) ) ); @@ -321,18 +330,20 @@ void mctStereoIGF_dec_fx( init_tcx_info_fx( sts[0], L_frame_nSubframe, L_frameTCX_nSubframe, k, bfi, &tcx_offset[0], &tcx_offsetFB[0], &L_frame[0], &L_frameTCX[0], &left_rect[0], &L_spec[0] ); /* stereo IGF decoding */ - assert( ( EQ_16( sts[0]->core, sts[1]->core ) ) || ( EQ_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[0], SMDCT_DUAL_MONO ) ) ); + assert( ( EQ_16( sts[0]->core, sts[1]->core ) ) || ( ( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[0] == SMDCT_DUAL_MONO ) ) ); decoder_tcx_IGF_stereo_fx( sts, hMCT->hBlockData[b]->hStereoMdct, hMCT->hBlockData[b]->mask, p_x, p_x_e, p_x_len, L_frame[0], left_rect[0], k, bfi, 1 /* MCT_flag */ ); // Shifting output with variable exponent back to Q12 FOR( Word16 i = 0; i < p_x_len[0][k]; i++ ) { - p_x[0][k][i] = L_shr( p_x[0][k][i], 31 - Q12 - p_x_e[0][k] ); + p_x[0][k][i] = L_shr( p_x[0][k][i], sub( 31 - Q12, p_x_e[0][k] ) ); + move32(); } FOR( Word16 i = 0; i < p_x_len[1][k]; i++ ) { - p_x[1][k][i] = L_shr( p_x[1][k][i], 31 - Q12 - p_x_e[1][k] ); + p_x[1][k][i] = L_shr( p_x[1][k][i], sub( 31 - Q12, p_x_e[1][k] ) ); + move32(); } } ELSE @@ -343,7 +354,7 @@ void mctStereoIGF_dec_fx( st = sts[ch]; test(); - IF( bfi && EQ_16( st->core, ACELP_CORE ) ) /*no igf processing needed*/ + IF( bfi && ( st->core == ACELP_CORE ) ) /*no igf processing needed*/ { CONTINUE; } @@ -376,7 +387,7 @@ void mctStereoIGF_dec_fx( } } - IF( NE_16( sum16_fx( singleChEle, ( hMCT->nchan_out_woLFE ) ), 0 ) ) + IF( sum16_fx( singleChEle, ( hMCT->nchan_out_woLFE ) ) != 0 ) { FOR( ch = 0; ch < ( hMCT->nchan_out_woLFE ); ch++ ) { @@ -384,7 +395,7 @@ void mctStereoIGF_dec_fx( { st = stm[ch]; test(); - IF( bfi && EQ_16( st->core, ACELP_CORE ) ) /*no igf processing needed*/ + IF( bfi && ( st->core == ACELP_CORE ) ) /*no igf processing needed*/ { CONTINUE; } @@ -392,7 +403,15 @@ void mctStereoIGF_dec_fx( { CONTINUE; } - nSubframes = ( EQ_16( st->core, TCX_10_CORE ) ) ? NB_DIV : 1; + + IF( EQ_16( st->core, TCX_10_CORE ) ) + { + nSubframes = NB_DIV; + } + ELSE + { + nSubframes = 1; + } move16(); FOR( k = 0; k < nSubframes; k++ ) diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index ad6f0f9c1c948c2cc6975466c19fae0590dd90c2..60f3f81580c673743f0dc80c52e491de03e3a666 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -76,25 +76,29 @@ static void ivas_lssetupconversion_computeEQFactor_fx( Word32 *EQ ) { - IF( L_shr( *outputEnergy, 3 ) > Mpy_32_32( LS_OUT_CONV_CLIP_FACTOR_MAX_SQ_Q28, *inputEnergy ) ) + IF( GT_32( L_shr( *outputEnergy, 3 ), Mpy_32_32( LS_OUT_CONV_CLIP_FACTOR_MAX_SQ_Q28, *inputEnergy ) ) ) { *EQ = L_shl_sat( LS_OUT_CONV_CLIP_FACTOR_MAX_Q29, 1 ); + move32(); return; } - IF( L_shr( *outputEnergy, 3 ) < Mpy_32_32( LS_OUT_CONV_CLIP_FACTOR_MIN_SQ_Q28, *inputEnergy ) ) + IF( LT_32( L_shr( *outputEnergy, 3 ), Mpy_32_32( LS_OUT_CONV_CLIP_FACTOR_MIN_SQ_Q28, *inputEnergy ) ) ) { *EQ = L_shl_sat( LS_OUT_CONV_CLIP_FACTOR_MIN_Q29, 1 ); + move32(); return; } - IF( *outputEnergy == 0 && *inputEnergy == 0 ) + test(); + IF( ( *outputEnergy == 0 ) && ( *inputEnergy == 0 ) ) { *EQ = ONE_IN_Q30; + move32(); return; } /* Compute the Equalization Gain */ Word16 tmp_e; - Word16 tmp = BASOP_Util_Divide3232_Scale( *outputEnergy, ( EPSILON_FX + *inputEnergy ), &tmp_e ); + Word16 tmp = BASOP_Util_Divide3232_Scale( *outputEnergy, L_add( EPSILON_FX, *inputEnergy ), &tmp_e ); Word32 tmp_32 = L_shl( (Word32) tmp, 16 ); tmp_32 = Sqrt32( tmp_32, &tmp_e ); *EQ = L_shr( tmp_32, 1 - tmp_e ); @@ -133,7 +137,16 @@ static void ivas_lssetupconversion_mdct_init_bands_fx( Word16 i, cnt, specStartOffset, L_frameTCX; const UWord8 *sfbWidths; - L_frameTCX = ( EQ_16( tcx_mode, TCX_20_CORE ) ) ? output_frame : ( shr( output_frame, 1 ) ); + IF( EQ_16( tcx_mode, TCX_20_CORE ) ) + { + L_frameTCX = output_frame; + move16(); + } + ELSE + { + L_frameTCX = shr( output_frame, 1 ); + } + SWITCH( output_frame ) { @@ -152,9 +165,18 @@ static void ivas_lssetupconversion_mdct_init_bands_fx( return; } - sfbWidths = ( EQ_16( tcx_mode, TCX_20_CORE ) ? lpcBndsParam->bandLengthsTCX20 : lpcBndsParam->bandLengthsTCX10 ); - cnt = ( EQ_16( tcx_mode, TCX_20_CORE ) ? 64 : 32 ); - move16(); + IF( EQ_16( tcx_mode, TCX_20_CORE ) ) + { + sfbWidths = lpcBndsParam->bandLengthsTCX20; + cnt = 64; + move16(); + } + ELSE + { + sfbWidths = lpcBndsParam->bandLengthsTCX10; + cnt = 32; + move16(); + } /* calc sfb offsets */ specStartOffset = 0; @@ -162,10 +184,9 @@ static void ivas_lssetupconversion_mdct_init_bands_fx( FOR( i = 0; i < cnt; i++ ) { - sfbOffset[i] = min( specStartOffset, L_frameTCX ); + sfbOffset[i] = s_min( specStartOffset, L_frameTCX ); move16(); specStartOffset = add( specStartOffset, sfbWidths[i] ); - move16(); IF( GE_16( sfbOffset[i], L_frameTCX ) ) { @@ -175,7 +196,7 @@ static void ivas_lssetupconversion_mdct_init_bands_fx( *sfbCnt = i; move16(); - sfbOffset[*sfbCnt] = min( specStartOffset, L_frameTCX ); + sfbOffset[*sfbCnt] = s_min( specStartOffset, L_frameTCX ); move16(); IF( LT_16( sfbOffset[*sfbCnt], L_frameTCX ) ) @@ -184,7 +205,8 @@ static void ivas_lssetupconversion_mdct_init_bands_fx( IF( LT_16( shr( (Word16) sfbWidths[i], 1 ), nMissingBins ) ) { - ( *sfbCnt )++; + ( *sfbCnt ) = add( ( *sfbCnt ), 1 ); + move16(); } sfbOffset[*sfbCnt] = L_frameTCX; move16(); @@ -274,7 +296,6 @@ static void get_custom_ls_conversion_matrix_fx( Word16 lfe_in_idx, lfe_out_idx; Word32 dmxCoeff_LFE; - /* TODO: remove the floating point dependency */ Word32 tmp_gains[MAX_OUTPUT_CHANNELS]; lfe_in_idx = -1; @@ -286,12 +307,12 @@ static void get_custom_ls_conversion_matrix_fx( nchan_out = add( hLsSetupCustom->num_spk, hLsSetupCustom->num_lfe ); /* The below code will need to be restructured in case additional LFEs must be supported */ - IF( GT_16( hTransSetup.num_lfe, 0 ) ) + if ( hTransSetup.num_lfe > 0 ) { lfe_in_idx = hTransSetup.index_lfe[0]; move16(); } - IF( GT_16( hLsSetupCustom->num_lfe, 0 ) ) + if ( hLsSetupCustom->num_lfe > 0 ) { lfe_out_idx = hLsSetupCustom->lfe_idx[0]; move16(); @@ -323,7 +344,7 @@ static void get_custom_ls_conversion_matrix_fx( set32_fx( hLsSetUpConversion->dmxMtx_fx[ch_in], dmxCoeff_LFE, nchan_out ); } - ch_in_woLFE--; + ch_in_woLFE = sub( ch_in_woLFE, 1 ); } ELSE IF( NE_16( lfe_out_idx, ch_in ) ) { @@ -335,7 +356,7 @@ static void get_custom_ls_conversion_matrix_fx( { IF( EQ_16( lfe_out_idx, ch_out ) ) { - ch_out_woLFE--; + ch_out_woLFE = sub( ch_out_woLFE, 1 ); } ELSE { @@ -502,7 +523,15 @@ static ivas_error get_ls_conversion_matrix_fx( value = conversion_matrix_fx[k].value; move16(); - ch_in = index / nchan_out; + IF( index != 0 ) + { + ch_in = idiv1616( index, nchan_out ); + } + ELSE + { + ch_in = 0; + move16(); + } ch_out = index % nchan_out; hLsSetUpConversion->dmxMtx_fx[ch_in][ch_out] = value; @@ -652,40 +681,28 @@ ivas_error ivas_ls_setup_conversion_open_fx( IF( EQ_32( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) ) { inChannels = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); - hLsSetUpConversion->sfbCnt = (Word16) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); + hLsSetUpConversion->sfbCnt = (Word16) ( L_add( output_Fs, 400 ) / CLDFB_BANDWIDTH ); FOR( chIdx = 0; chIdx < outChannels; chIdx++ ) { - IF( ( hLsSetUpConversion->targetEnergyPrev_fx[chIdx] = (Word32 *) malloc( ( hLsSetUpConversion->sfbCnt ) * sizeof( Word32 ) ) ) == NULL ) + IF( ( hLsSetUpConversion->targetEnergyPrev_fx[chIdx] = (Word32 *) malloc( hLsSetUpConversion->sfbCnt * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); } - IF( ( hLsSetUpConversion->dmxEnergyPrev_fx[chIdx] = (Word32 *) malloc( ( hLsSetUpConversion->sfbCnt ) * sizeof( Word32 ) ) ) == NULL ) + IF( ( hLsSetUpConversion->dmxEnergyPrev_fx[chIdx] = (Word32 *) malloc( hLsSetUpConversion->sfbCnt * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); } set32_fx( hLsSetUpConversion->targetEnergyPrev_fx[chIdx], 0, hLsSetUpConversion->sfbCnt ); hLsSetUpConversion->te_prev_exp = 0; + move16(); set32_fx( hLsSetUpConversion->dmxEnergyPrev_fx[chIdx], 0, hLsSetUpConversion->sfbCnt ); hLsSetUpConversion->dmx_prev_exp = 0; - /* TODO: remove the floating point dependency */ - // IF( ( hLsSetUpConversion->targetEnergyPrev[chIdx] = (float *) malloc( ( hLsSetUpConversion->sfbCnt ) * sizeof( float ) ) ) == NULL ) - //{ - // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); - // } - // IF( ( hLsSetUpConversion->dmxEnergyPrev[chIdx] = (float *) malloc( ( hLsSetUpConversion->sfbCnt ) * sizeof( float ) ) ) == NULL ) - //{ - // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); - // } - // set_f( hLsSetUpConversion->targetEnergyPrev[chIdx], 0.0f, hLsSetUpConversion->sfbCnt ); - // set_f( hLsSetUpConversion->dmxEnergyPrev[chIdx], 0.0f, hLsSetUpConversion->sfbCnt ); + move16(); } FOR( ; chIdx < MAX_CICP_CHANNELS; chIdx++ ) { hLsSetUpConversion->targetEnergyPrev_fx[chIdx] = NULL; hLsSetUpConversion->dmxEnergyPrev_fx[chIdx] = NULL; - /* TODO: remove the floating point dependency */ - // hLsSetUpConversion->targetEnergyPrev[chIdx] = NULL; - // hLsSetUpConversion->dmxEnergyPrev[chIdx] = NULL; } } ELSE @@ -718,29 +735,14 @@ ivas_error ivas_ls_setup_conversion_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); } - /* TODO: remove the floating point dependency */ - // IF( ( hLsSetUpConversion->targetEnergyPrev[0] = (float *) malloc( ( MAX_SFB + 2 ) * sizeof( float ) ) ) == NULL ) - //{ - // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); - // } - // IF( ( hLsSetUpConversion->dmxEnergyPrev[0] = (float *) malloc( ( MAX_SFB + 2 ) * sizeof( float ) ) ) == NULL ) - //{ - // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); - // } FOR( chIdx = 1; chIdx < MAX_CICP_CHANNELS; chIdx++ ) { hLsSetUpConversion->targetEnergyPrev_fx[chIdx] = NULL; hLsSetUpConversion->dmxEnergyPrev_fx[chIdx] = NULL; - /* TODO: remove the floating point dependency */ - // hLsSetUpConversion->targetEnergyPrev[chIdx] = NULL; - // hLsSetUpConversion->dmxEnergyPrev[chIdx] = NULL; } set32_fx( hLsSetUpConversion->targetEnergyPrev_fx[0], 0, MAX_SFB + 2 ); set32_fx( hLsSetUpConversion->dmxEnergyPrev_fx[0], 0, MAX_SFB + 2 ); - /* TODO: remove the floating point dependency */ - // set_f( hLsSetUpConversion->targetEnergyPrev[0], 0.0f, MAX_SFB + 2 ); - // set_f( hLsSetUpConversion->dmxEnergyPrev[0], 0.0f, MAX_SFB + 2 ); } /* Initialize the DMX conversion matrix */ @@ -752,21 +754,11 @@ ivas_error ivas_ls_setup_conversion_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for temp dmx matrix \n" ) ); } set32_fx( hLsSetUpConversion->dmxMtx_fx[chIdx], 0, outChannels ); - - /* TODO: remove the floating point dependency */ - /* Allocate memory depending on the number of output channels */ - // IF( ( hLsSetUpConversion->dmxMtx[chIdx] = (float *) malloc( outChannels * sizeof( float ) ) ) == NULL ) - //{ - // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory FOR temp dmx matrix \n" ) ); - // } - // set_zero( hLsSetUpConversion->dmxMtx[chIdx], outChannels ); } FOR( ; chIdx < MAX_CICP_CHANNELS; chIdx++ ) { hLsSetUpConversion->dmxMtx_fx[chIdx] = NULL; - /* TODO: remove the floating point dependency */ - // hLsSetUpConversion->dmxMtx[chIdx] = NULL; } IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) @@ -792,15 +784,6 @@ ivas_error ivas_ls_setup_conversion_open_fx( } } - /* TODO: remove the floating point dependency */ - FOR( Word16 i = 0; i < inChannels; ++i ) - { - FOR( Word16 j = 0; j < outChannels; ++j ) - { - // hLsSetUpConversion->dmxMtx[i][j] = fix_to_float( hLsSetUpConversion->dmxMtx_fx[i][j], Q30 ); - } - } - st_ivas->hLsSetUpConversion = hLsSetUpConversion; return IVAS_ERR_OK; @@ -958,7 +941,7 @@ void ivas_ls_setup_conversion_close_fx( ) { Word16 idx; - + test(); IF( hLsSetUpConversion == NULL || *hLsSetUpConversion == NULL ) { return; @@ -983,25 +966,6 @@ void ivas_ls_setup_conversion_close_fx( free( ( *hLsSetUpConversion )->dmxEnergyPrev_fx[idx] ); ( *hLsSetUpConversion )->dmxEnergyPrev_fx[idx] = NULL; } - - /* TODO: remove the floating point dependency */ - // IF( ( *hLsSetUpConversion )->dmxMtx[idx] != NULL ) - //{ - // free( ( *hLsSetUpConversion )->dmxMtx[idx] ); - // ( *hLsSetUpConversion )->dmxMtx[idx] = NULL; - // } - - // IF( ( *hLsSetUpConversion )->targetEnergyPrev[idx] != NULL ) - //{ - // free( ( *hLsSetUpConversion )->targetEnergyPrev[idx] ); - // ( *hLsSetUpConversion )->targetEnergyPrev[idx] = NULL; - // } - - // IF( ( *hLsSetUpConversion )->dmxEnergyPrev[idx] != NULL ) - //{ - // free( ( *hLsSetUpConversion )->dmxEnergyPrev[idx] ); - // ( *hLsSetUpConversion )->dmxEnergyPrev[idx] = NULL; - // } } free( *hLsSetUpConversion ); @@ -1083,7 +1047,7 @@ void ivas_ls_setup_conversion_fx( dmxCoeff = hLsSetUpConversion->dmxMtx_fx[chInIdx][chOutIdx]; move32(); - IF( EQ_32( dmxCoeff, 0 ) ) + IF( dmxCoeff == 0 ) { CONTINUE; } @@ -1222,6 +1186,7 @@ void ivas_ls_setup_conversion_process_mdct_fx( // Scale the array Word16 q_output = 31; + move16(); FOR( i = 0; i < inChannels; ++i ) { q_output = s_min( q_output, L_norm_arr( output[i], L_FRAME48k ) ); @@ -1243,7 +1208,7 @@ void ivas_ls_setup_conversion_process_mdct_fx( FOR( chInIdx = 0; chInIdx < inChannels; chInIdx++ ) { x[chInIdx][0] = output[chInIdx]; - x[chInIdx][1] = output[chInIdx] + ( L_FRAME48k / 2 ); + x[chInIdx][1] = output[chInIdx] + L_FRAME48k / 2; } /* Assign all the declared handles*/ @@ -1300,8 +1265,10 @@ void ivas_ls_setup_conversion_process_mdct_fx( /* Convert the signal resolution to TCX20 */ /* initially, set pointers to input; if conversion occurs in (sub)frame, set to convertRes */ - sig[0] = pTmp[0] = x[chInIdx][0]; - sig[1] = pTmp[1] = x[chInIdx][1]; + pTmp[0] = x[chInIdx][0]; + sig[0] = pTmp[0]; + pTmp[1] = x[chInIdx][1]; + sig[1] = pTmp[1]; /* convert (sub)frames to higher frequency resolution */ IF( NE_16( transform_type[chInIdx][0], TCX_20 ) ) @@ -1311,8 +1278,9 @@ void ivas_ls_setup_conversion_process_mdct_fx( IF( EQ_16( transform_type[chInIdx][subFrameIdx], TCX_5 ) ) { /* subframe is TCX5, but TCX10 or TCX20 in other channel -> convert channel with TCX5 to TCX10 resolution */ - pTmp[subFrameIdx] = sig[subFrameIdx] = convertRes + subFrameIdx * frameSize / 2; - convert_coeffs_to_higher_res_fx( x[chInIdx][subFrameIdx], x[chInIdx][subFrameIdx] + frameSize / 4, pTmp[subFrameIdx], frameSize / 4 ); + sig[subFrameIdx] = convertRes + L_shr( L_mult0( subFrameIdx, frameSize ), 1 ); + pTmp[subFrameIdx] = sig[subFrameIdx]; + convert_coeffs_to_higher_res_fx( x[chInIdx][subFrameIdx], x[chInIdx][subFrameIdx] + shr( frameSize, 2 ), pTmp[subFrameIdx], shr( frameSize, 2 ) ); } } @@ -1389,16 +1357,18 @@ void ivas_ls_setup_conversion_process_mdct_fx( /* Step 3: Peform energy smoothing */ FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { - targetEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy[bandIdx] ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] ) ); + targetEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy[bandIdx] ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] ) ); move32(); - dmxEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy[bandIdx] ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] ) ); + dmxEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy[bandIdx] ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] ) ); move32(); hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] = targetEnergy[bandIdx]; move32(); hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] = dmxEnergy[bandIdx]; move32(); hLsSetUpConversion->te_prev_exp = 31; + move16(); hLsSetUpConversion->dmx_prev_exp = 31; + move16(); } FOR( i = 0; i < inChannels; ++i ) @@ -1406,6 +1376,7 @@ void ivas_ls_setup_conversion_process_mdct_fx( FOR( j = 0; j < L_FRAME48k; ++j ) { output[i][j] = L_shr( output[i][j], q_output ); + move32(); } } @@ -1797,16 +1768,20 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( FOR( idx = 0; idx < CPE_CHANNELS; idx++ ) { /* get the channel index */ - chInIdx = add( imult1616( cpe_idx, CPE_CHANNELS ), idx ); + chInIdx = add( cpe_idx * CPE_CHANNELS, idx ); assert( chInIdx <= nchan_transport ); transform_type[chInIdx][0] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[0]; + move16(); transform_type[chInIdx][1] = hCPE[cpe_idx]->hCoreCoder[idx]->transform_type[1]; + move16(); mct_chan_mode[chInIdx] = hCPE[cpe_idx]->hCoreCoder[idx]->mct_chan_mode; + move16(); } } /* set overall frequency resolution of (sub)frame to maximum of (sub)frame, requires conversion if both channels are not the same */ frameSize = hLsSetUpConversion->sfbOffset[hLsSetUpConversion->sfbCnt]; + move16(); set_zero_fx( targetEnergy_fx, MAX_SFB + 2 ); set_zero_fx( dmxEnergy_fx, MAX_SFB + 2 ); @@ -1825,7 +1800,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( IF( EQ_16( transform_type[chInIdx][subFrameIdx], TCX_5 ) ) { /* subframe is TCX5, but TCX10 or TCX20 in other channel -> convert channel with TCX5 to TCX10 resolution */ - pTmp_fx[subFrameIdx] = sig_fx[chInIdx][subFrameIdx] = convertRes_fx[chInIdx] + subFrameIdx * frameSize / 2; + pTmp_fx[subFrameIdx] = sig_fx[chInIdx][subFrameIdx] = convertRes_fx[chInIdx] + L_mult0( subFrameIdx, frameSize ) / 2; convert_coeffs_to_higher_res_fx( x_fx[chInIdx][subFrameIdx], x_fx[chInIdx][subFrameIdx] + frameSize / 4, pTmp_fx[subFrameIdx], frameSize / 4 ); /*Q=31-x_e[chInIdx][subFrameIdx]*/ } } @@ -1839,6 +1814,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( } } Word16 input_exp, output_exp = 0; + move16(); /* precalculate MDST estimate */ FOR( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ ) @@ -1846,9 +1822,11 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( IF( NE_16( mct_chan_mode[chInIdx], MCT_CHAN_MODE_IGNORE ) ) { mdst_fx[chInIdx][0] = mdst_fx[chInIdx][frameSize - 1] = 0; + move32(); FOR( i = 1; i < frameSize - 1; i++ ) { mdst_fx[chInIdx][i] = L_sub( sig_fx[chInIdx][0][i + 1], sig_fx[chInIdx][0][i - 1] ); /*Q=31-x_e[chInIdx][0]*/ + move32(); } } } @@ -1862,6 +1840,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( set_zero_fx( Nrqq_fx, MAX_OUTPUT_CHANNELS ); set_zero_fx( target_ch_ener_fx, MAX_OUTPUT_CHANNELS ); Word16 max_e = 0; + move16(); FOR( idx = 0; idx < nchan_transport; idx++ ) { IF( NE_16( mct_chan_mode[idx], MCT_CHAN_MODE_IGNORE ) ) @@ -1877,34 +1856,43 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( set_zero_fx( imag_buffer_fx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); start = hLsSetUpConversion->sfbOffset[bandIdx]; + move16(); stop = hLsSetUpConversion->sfbOffset[bandIdx + 1]; + move16(); num_bands = sub( stop, start ); FOR( i = 0; i < num_bands; i++ ) { - band = start + i; + band = add( start, i ); FOR( idx = 0; idx < nchan_transport; idx++ ) { - IF( mct_chan_mode[idx] != MCT_CHAN_MODE_IGNORE ) + IF( NE_16( mct_chan_mode[idx], MCT_CHAN_MODE_IGNORE ) ) { - real_in_buffer_fx[i + num_bands * idx] = L_shr( sig_fx[idx][0][band], max_e - x_e[idx][0] ); /*Setting the exponent to max_e*/ - imag_in_buffer_fx[i + num_bands * idx] = L_shr( mdst_fx[idx][band], max_e - x_e[idx][0] ); /*Setting the exponent to max_e*/ + real_in_buffer_fx[add( i, i_mult( num_bands, idx ) )] = L_shr( sig_fx[idx][0][band], sub( max_e, x_e[idx][0] ) ); /*Setting the exponent to max_e*/ + imag_in_buffer_fx[add( i, i_mult( num_bands, idx ) )] = L_shr( mdst_fx[idx][band], sub( max_e, x_e[idx][0] ) ); /*Setting the exponent to max_e*/ + move32(); + move32(); } } } Word16 shift = 1; - FOR( i = 0; i < num_bands * nchan_transport; ++i ) + FOR( i = 0; i < i_mult( num_bands, nchan_transport ); ++i ) { real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], shift ); + move32(); imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], shift ); + move32(); } input_exp = max_e; + move16(); input_exp = add( input_exp, shift ); cmplx_matrix_square_fx( real_in_buffer_fx, imag_in_buffer_fx, num_bands, nchan_transport, real_buffer_fx, imag_buffer_fx, input_exp, &output_exp ); - v_add_32( cx_fx[bandIdx], real_buffer_fx, cx_fx[bandIdx], nchan_transport * nchan_transport ); /*Q=Q_real_buffer=Q_imag_buffer=output_exp*/ - v_add_32( cx_imag_fx[bandIdx], imag_buffer_fx, cx_imag_fx[bandIdx], nchan_transport * nchan_transport ); /*Q=Q_real_buffer=Q_imag_buffer=output_exp*/ + v_add_32( cx_fx[bandIdx], real_buffer_fx, cx_fx[bandIdx], i_mult( nchan_transport, nchan_transport ) ); /*Q=Q_real_buffer=Q_imag_buffer=output_exp*/ + v_add_32( cx_imag_fx[bandIdx], imag_buffer_fx, cx_imag_fx[bandIdx], i_mult( nchan_transport, nchan_transport ) ); /*Q=Q_real_buffer=Q_imag_buffer=output_exp*/ } Word16 exp_in = 10, exp_out = 0; + move16(); + move16(); FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { DMXEne_fx = 0; @@ -1916,17 +1904,20 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( FOR( chInIdx = 0; chInIdx < nchan_transport_format; chInIdx++ ) { Word32 ref_ener_fx = 0; + move32(); Word16 ref_channel_cnt; Word16 ref_channel_idx; FOR( ref_channel_cnt = 0; ref_channel_cnt < hParamMC->hMetadataPMC->ild_mapping_conf->num_ref_channels[chInIdx]; ref_channel_cnt++ ) { ref_channel_idx = hParamMC->hMetadataPMC->ild_mapping_conf->ref_channel_idx[chInIdx][ref_channel_cnt]; - ref_ener_fx = L_add( ref_ener_fx, cx_fx[bandIdx][ref_channel_idx + ref_channel_idx * nchan_transport] ); /*Exponent=output_exp*/ + move16(); + ref_ener_fx = L_add( ref_ener_fx, cx_fx[bandIdx][add( ref_channel_idx, i_mult( ref_channel_idx, nchan_transport ) )] ); /*Exponent=output_exp*/ } Word32 temp; temp = BASOP_util_Pow2( L_mult0( ild_q_fx[chInIdx], 2721 /*log2(10)*(2^13)/10*/ ), exp_in, &exp_out ); - Nrqq_fx[hParamMC->hMetadataPMC->ild_mapping_conf->ild_index[chInIdx]] = L_shr( Mpy_32_16_1( ref_ener_fx, (Word16) Mpy_32_32( temp, hParamMC->hMetadataPMC->ild_factors_fx[chInIdx] ) ), 2 - exp_out ); /*exp=output_exp*/ + Nrqq_fx[hParamMC->hMetadataPMC->ild_mapping_conf->ild_index[chInIdx]] = L_shr( Mpy_32_16_1( ref_ener_fx, extract_l( Mpy_32_32( temp, hParamMC->hMetadataPMC->ild_factors_fx[chInIdx] ) ) ), sub( 2, exp_out ) ); /*exp=output_exp*/ + move32(); } /* Step 1.3 get target Cy like in ivas_param_mc_get_mono_stereo_mixing_matrices() (with dmx matrix from CICPX to MONO/STEREO saved in hParamMC) */ @@ -1934,22 +1925,25 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( { FOR( i = 0; i < nchan_transport_format; i++ ) { - IF( EQ_32( hParamMC->ls_conv_dmx_matrix_fx[chOutIdx + i * nchan_out], 32768 ) ) - hParamMC->ls_conv_dmx_matrix_fx[chOutIdx + i * nchan_out] = 32767; - target_ch_ener_fx[chOutIdx] = L_add( target_ch_ener_fx[chOutIdx], Mpy_32_16_1( Nrqq_fx[i], (Word16) hParamMC->ls_conv_dmx_matrix_fx[chOutIdx + i * nchan_out] ) ); /*output_exp + 2*/ + target_ch_ener_fx[chOutIdx] = L_add( target_ch_ener_fx[chOutIdx], L_shl( Mpy_32_32( Nrqq_fx[i], hParamMC->ls_conv_dmx_matrix_fx[add( chOutIdx, i_mult( i, nchan_out ) )] ), 1 ) ); /*output_exp + 2*/ + move32(); } - cy_fx[chOutIdx + nchan_out * chOutIdx] = target_ch_ener_fx[chOutIdx]; + cy_fx[add( chOutIdx, i_mult( nchan_out, chOutIdx ) )] = target_ch_ener_fx[chOutIdx]; + move32(); } /* Step 1.4 final target energy for the band would then be the sum over the diagonal of Cy*/ FOR( chOutIdx = 0; chOutIdx < nchan_out; chOutIdx++ ) { - targetEnergy_fx[bandIdx] = L_add( targetEnergy_fx[bandIdx], cy_fx[chOutIdx + nchan_out * chOutIdx] ); /*exp=output_exp+2*/ + targetEnergy_fx[bandIdx] = L_add( targetEnergy_fx[bandIdx], cy_fx[add( chOutIdx, i_mult( nchan_out, chOutIdx ) )] ); /*exp=output_exp+2*/ + move32(); } /* Step 2: Calculate DMX ener */ start = hLsSetUpConversion->sfbOffset[bandIdx]; + move16(); stop = hLsSetUpConversion->sfbOffset[bandIdx + 1]; + move16(); FOR( chOutIdx = 0; chOutIdx < nchan_out; chOutIdx++ ) { @@ -1965,17 +1959,20 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( /* Loop over all the bins in the band */ FOR( binIdx = start; binIdx < stop; binIdx++ ) { - tmpDMXSig_fx = Mult_32_32( dmxCoeff_fx, L_shr( sig_fx[chInIdx][0][binIdx], max_e - x_e[chInIdx][0] ) ); /*max_e+1*/ + tmpDMXSig_fx = Mult_32_32( dmxCoeff_fx, L_shr( sig_fx[chInIdx][0][binIdx], sub( max_e, x_e[chInIdx][0] ) ) ); /*max_e+1*/ dmxSignalReal_fx[binIdx] = L_add( dmxSignalReal_fx[binIdx], tmpDMXSig_fx ); + move32(); - tmpDMXSig_fx = Mult_32_32( dmxCoeff_fx, L_shr( mdst_fx[chInIdx][binIdx], max_e - x_e[chInIdx][0] ) ); /*max_e+1*/ + tmpDMXSig_fx = Mult_32_32( dmxCoeff_fx, L_shr( mdst_fx[chInIdx][binIdx], sub( max_e, x_e[chInIdx][0] ) ) ); /*max_e+1*/ dmxSignalImag_fx[binIdx] = L_add( dmxSignalImag_fx[binIdx], tmpDMXSig_fx ); + move32(); } } } } /* Loop over all the bins in the band */ DMXEne_fx = 0; + move32(); FOR( binIdx = start; binIdx < stop; binIdx++ ) { tmpReal_fx = L_shr( dmxSignalReal_fx[binIdx], 1 ); @@ -1986,18 +1983,25 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( } dmxEnergy_fx[bandIdx] = DMXEne_fx; /*2*(max_e+2)*/ + move32(); } /* Step 3: Peform energy smoothing */ FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { - targetEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx], output_exp + 2 - hLsSetUpConversion->te_prev_exp ) ) ); /*output_exp + 2*/ - dmxEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], 2 * ( max_e + 2 ) - hLsSetUpConversion->dmx_prev_exp ) ) ); /*2 * (max_e + 2)*/ + targetEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx], add( output_exp, sub( 2, hLsSetUpConversion->te_prev_exp ) ) ) ) ); /*output_exp + 2*/ + move32(); + dmxEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], sub( shl( add( max_e, 2 ), 1 ), hLsSetUpConversion->dmx_prev_exp ) ) ) ); /*2 * (max_e + 2)*/ + move32(); hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] = targetEnergy_fx[bandIdx]; + move32(); hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] = dmxEnergy_fx[bandIdx]; + move32(); } - hLsSetUpConversion->te_prev_exp = output_exp + 2; - hLsSetUpConversion->dmx_prev_exp = 2 * ( max_e + 2 ); + hLsSetUpConversion->te_prev_exp = add( output_exp, 2 ); + move16(); + hLsSetUpConversion->dmx_prev_exp = shl( add( max_e, 2 ), 1 ); + move16(); /* Step 4: Perform equalization */ FOR( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ ) { @@ -2009,7 +2013,9 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { start = hLsSetUpConversion->sfbOffset[bandIdx]; + move16(); stop = hLsSetUpConversion->sfbOffset[bandIdx + 1]; + move16(); /*Compute Eq gains */ ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], &dmxEnergy_fx[bandIdx], &eqGain_fx ); @@ -2023,10 +2029,11 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( ELSE { stop_tcx5 = 0; + move16(); FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { - start = hLsSetUpConversion->sfbOffset[bandIdx] / 2; - stop = hLsSetUpConversion->sfbOffset[bandIdx + 1] / 2; + start = shr( hLsSetUpConversion->sfbOffset[bandIdx], 1 ); + stop = shr( hLsSetUpConversion->sfbOffset[bandIdx + 1], 1 ); /*Compute Eq gains */ ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], &dmxEnergy_fx[bandIdx], &eqGain_fx ); @@ -2040,21 +2047,25 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( FOR( binIdx = start; binIdx < stop; binIdx++ ) { x_fx[chInIdx][subFrameIdx][binIdx] = L_shl( Mult_32_32( x_fx[chInIdx][subFrameIdx][binIdx], eqGain_fx ), 1 ); + move32(); } } ELSE { /* TCX5*/ start_tcx5 = stop_tcx5; - stop_tcx5 = ( stop + 1 ) / 2; + move16(); + stop_tcx5 = shr( add( stop, 1 ), 1 ); FOR( binIdx = start_tcx5; binIdx < stop_tcx5; binIdx++ ) { x_fx[chInIdx][subFrameIdx][binIdx] = L_shl( Mult_32_32( x_fx[chInIdx][subFrameIdx][binIdx], eqGain_fx ), 1 ); + move32(); } FOR( binIdx = start_tcx5; binIdx < stop_tcx5; binIdx++ ) { - x_fx[chInIdx][subFrameIdx][binIdx + ( frameSize >> 2 )] = L_shl( Mult_32_32( x_fx[chInIdx][subFrameIdx][binIdx + ( frameSize >> 2 )], eqGain_fx ), 1 ); + x_fx[chInIdx][subFrameIdx][add( binIdx, shr( frameSize, 2 ) )] = L_shl( Mult_32_32( x_fx[chInIdx][subFrameIdx][add( binIdx, shr( frameSize, 2 ) )], eqGain_fx ), 1 ); + move32(); } } } @@ -2463,9 +2474,9 @@ void ivas_lssetupconversion_process_param_mc_fx( push_wmops( "LS_Renderer_Process_Param_MC" ); /* inits */ - inChannels = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + inChannels = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); move16(); - outChannels = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + outChannels = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); move16(); hLsSetUpConversion = st_ivas->hLsSetUpConversion; @@ -2519,7 +2530,7 @@ void ivas_lssetupconversion_process_param_mc_fx( { dmxCoeff = hLsSetUpConversion->dmxMtx_fx[chInIdx][chOutIdx]; move32(); - IF( EQ_32( dmxCoeff, 0 ) ) + IF( dmxCoeff == 0 ) { CONTINUE; } @@ -2578,7 +2589,9 @@ void ivas_lssetupconversion_process_param_mc_fx( hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx][bandIdx] = dmxEnergy[chOutIdx][bandIdx]; move32(); hLsSetUpConversion->te_prev_exp = 31; + move16(); hLsSetUpConversion->dmx_prev_exp = 31; + move16(); } } } diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c index 58aa5d04d01d805879db6232098d04f996e9ff1b..40052469b6fd0d01719718c35de10cfc0c8f8fb7 100644 --- a/lib_dec/ivas_pca_dec_fx.c +++ b/lib_dec/ivas_pca_dec_fx.c @@ -52,10 +52,10 @@ static Word32 ivas_bitstream_read_int32_fx( Word32 val; /* MSB */ - val = get_next_indice_fx( st0, bits - 16 ) << 16; + val = L_shl( get_next_indice_fx( st0, sub( bits, 16 ) ), 16 ); /* + LSB */ - val += get_next_indice_fx( st0, 16 ); + val = L_add( val, get_next_indice_fx( st0, 16 ) ); return val; } @@ -65,10 +65,10 @@ static void pca_dec_reset_dquat_fx( Word16 *qr_fx ) { set16_fx( ql_fx, 0, IVAS_PCA_INTERP ); - ql_fx[0] = 32767; + ql_fx[0] = MAX_16; move16(); set16_fx( qr_fx, 0, IVAS_PCA_INTERP ); - qr_fx[0] = 32767; + qr_fx[0] = MAX_16; move16(); return; } @@ -81,7 +81,7 @@ static void pca_dec_reset_mem_eigvec_fx( FOR( i = 0; i < shr( IVAS_PCA_LEN_INTERP_EIG_DEC, 4 ); i++ ) { - eye_matrix_fx( &hPCA->mem_eigVec_interp_fx[16 * i], FOA_CHANNELS, 32767 ); + eye_matrix_fx( &hPCA->mem_eigVec_interp_fx[i_mult( 16, i )], FOA_CHANNELS, MAX_16 ); } return; @@ -103,19 +103,20 @@ static void pca_inv_transform_sub_fx( { FOR( k = 0; k < n_channels; k++ ) { - buffer_data[k] = transformed_data[k][j + start]; + buffer_data[k] = transformed_data[k][add( j, start )]; move32(); } FOR( k = 0; k < n_channels; k++ ) { temp = 0; + move32(); FOR( i = 0; i < n_channels; i++ ) { - temp2 = Mpy_32_16_1( buffer_data[i], eigVec[k * IVAS_PCA_INTERP + i] ); + temp2 = Mpy_32_16_1( buffer_data[i], eigVec[add( k * IVAS_PCA_INTERP, i )] ); temp = L_add( temp, temp2 ); } - transformed_data[k][j + start] = temp; + transformed_data[k][add( j, start )] = temp; move32(); } } @@ -140,12 +141,12 @@ static void pca_dec_inv_transform_fx( pca_interp_preproc_fx( hPCA->prev_ql_fx, hPCA->prev_qr_fx, ql_fx, qr_fx, IVAS_PCA_N_SLOTS, ql_interp_fx, qr_interp_fx ); - slot_len = (Word16) ( n_samples / IVAS_PCA_N_SLOTS ); - move16(); - for ( j = 0; j < IVAS_PCA_N_SLOTS; j++ ) + slot_len = idiv1616( n_samples, IVAS_PCA_N_SLOTS ); + + FOR( j = 0; j < IVAS_PCA_N_SLOTS; j++ ) { /* convert from double quaternion to 4D matrix */ - dquat2mat_fx( &ql_interp_fx[4 * j], &qr_interp_fx[4 * j], &hPCA->mem_eigVec_interp_fx[16 * j + IVAS_PCA_DELAY_CMP * 16] ); + dquat2mat_fx( &ql_interp_fx[4 * j], &qr_interp_fx[4 * j], &hPCA->mem_eigVec_interp_fx[add( 16 * j, IVAS_PCA_DELAY_CMP * 16 )] ); pca_inv_transform_sub_fx( &hPCA->mem_eigVec_interp_fx[16 * j], decoded_data, slot_len * j, slot_len, n_channels ); } @@ -235,11 +236,15 @@ void ivas_pca_dec_fx( /* @@@TODO: check how ivas_total_brate is set if bfi == 1 */ // ToDo: and what happens in DTX where "ivas_total_brate" can be close to zero? /* handle bit rate switching */ + test(); + test(); IF( NE_32( ivas_total_brate, PCA_BRATE ) || ( EQ_32( ivas_total_brate, PCA_BRATE ) && GT_16( n_channels, FOA_CHANNELS ) ) ) { /* set PCA by-pass mode in current frame and interpolate transform as previous frame used PCA */ pca_dec_reset_dquat_fx( ql_fx, qr_fx ); + test(); + test(); IF( ( NE_32( last_ivas_total_brate, PCA_BRATE ) ) || ( EQ_32( last_ivas_total_brate, PCA_BRATE ) && GT_16( hPCA->prev_pca_bypass, 1 ) ) ) { pca_dec_reset_mem_eigvec_fx( hPCA ); @@ -253,7 +258,7 @@ void ivas_pca_dec_fx( hPCA->prev_pca_bypass = add( hPCA->prev_pca_bypass, 1 ); move16(); - IF( GT_16( hPCA->prev_pca_bypass, 2 ) ) + if ( GT_16( hPCA->prev_pca_bypass, 2 ) ) { hPCA->prev_pca_bypass = 2; move16(); @@ -262,7 +267,7 @@ void ivas_pca_dec_fx( return; } - IF( !bfi ) + IF( bfi == 0 ) { /* set PCA by-pass mode indicator */ pca_bypass = hPCA->pca_bypass; @@ -291,12 +296,13 @@ void ivas_pca_dec_fx( pca_dec_update_dquat_fx( hPCA, ql_fx, qr_fx ); hPCA->prev_pca_bypass = add( hPCA->prev_pca_bypass, 1 ); - hPCA->prev_pca_bypass = min( hPCA->prev_pca_bypass, 2 ); + move16(); + hPCA->prev_pca_bypass = s_min( hPCA->prev_pca_bypass, 2 ); move16(); return; // exit happens here } - IF( !bfi ) + IF( bfi == 0 ) { pca_dec_s3_fx( hPCA->index[0], ql_fx ); pca_dec_s3_fx( hPCA->index[1], qr_fx ); diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index 29770837548e723f33164d4e8336b8d6ad50d2ed..694bc53201e4d7faee0fa1d3ddf552b1f9e94375 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -177,13 +177,20 @@ void ivas_post_proc_fx( } output_Fs = sts[0]->output_Fs; + move32(); + test(); + test(); + test(); + test(); + test(); IF( ( NE_16( sts[n]->element_mode, IVAS_CPE_DFT ) && !( sba_dirac_stereo_flag && NE_16( sts[n]->element_mode, IVAS_CPE_MDCT ) ) ) || ( EQ_16( sts[n]->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) ) { IF( sts[n]->hTcxLtpDec != NULL ) { hTcxLtpDec = sts[n]->hTcxLtpDec; + test(); IF( NE_16( sts[n]->core, TCX_20_CORE ) && NE_16( sts[n]->core, TCX_10_CORE ) ) { /* TCX-LTP Postfilter: used in Mode 1 to update memories and to avoid discontinuities when the past frame was TCX */ @@ -193,19 +200,25 @@ void ivas_post_proc_fx( { /* set delay */ delay_comp = NS2SA_fx2( output_Fs, DELAY_CLDFB_NS ); + move16(); - IF( !( EQ_16( sts[n]->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ) ) && NE_16( sts[n]->element_mode, IVAS_CPE_MDCT ) ) + test(); + test(); + test(); + test(); + IF( EQ_16( EQ_16( sts[n]->element_mode, IVAS_CPE_DFT ) && EQ_16( hCPE->nchan_out, 1 ) && EQ_16( hCPE->hStereoDft->hConfig->res_cod_mode, STEREO_DFT_RES_COD_OFF ), 0 ) && NE_16( sts[n]->element_mode, IVAS_CPE_MDCT ) ) { // mvr2r( sts[n]->prev_synth_buffer32_fx, sts[n]->hTcxDec->FBTCXdelayBuf_32, 0 ); - Copy32( sts[n]->delay_buf_out32_fx, sts[n]->hTcxDec->FBTCXdelayBuf_32 + 0, delay_comp ); + Copy32( sts[n]->delay_buf_out32_fx, sts[n]->hTcxDec->FBTCXdelayBuf_32, delay_comp ); } ELSE IF( sba_dirac_stereo_flag && EQ_16( sts[n]->element_mode, IVAS_CPE_MDCT ) ) { Word16 numZeros = (Word16) ( NS2SA_fx2( output_Fs, N_ZERO_MDCT_NS ) ); + move16(); Copy32( sts[n]->hHQ_core->oldOut_fx + numZeros, sts[n]->hTcxDec->FBTCXdelayBuf_32, delay_comp ); } - tcx_ltp_post32( sts[n], hTcxLtpDec, sts[n]->core, output_frame, NS2SA_fx2( output_Fs, ACELP_LOOK_NS ) + delay_comp, synth, sts[n]->hTcxDec->FBTCXdelayBuf_32 ); + tcx_ltp_post32( sts[n], hTcxLtpDec, sts[n]->core, output_frame, add( NS2SA_fx2( output_Fs, ACELP_LOOK_NS ), delay_comp ), synth, sts[n]->hTcxDec->FBTCXdelayBuf_32 ); } } } @@ -214,9 +227,10 @@ void ivas_post_proc_fx( Word16 pit_res_max_past_tmp; pit_res_max_past_tmp = sts[0]->pit_res_max_past; + move16(); FOR( k = 0; k < hCPE->nchan_out; k++ ) { - IF( EQ_16( k, 0 ) ) + IF( k == 0 ) { hTcxLtpDec = sts[0]->hTcxLtpDec; } @@ -225,11 +239,16 @@ void ivas_post_proc_fx( hTcxLtpDec = hCPE->hStereoDft->hTcxLtpDec; /* copy LTP side-info of downmix channel also to right channel struct */ hTcxLtpDec->tcxltp = sts[0]->hTcxLtpDec->tcxltp; + move16(); hTcxLtpDec->tcxltp_gain = sts[0]->hTcxLtpDec->tcxltp_gain; + move16(); hTcxLtpDec->tcxltp_pitch_int = sts[0]->hTcxLtpDec->tcxltp_pitch_int; + move16(); hTcxLtpDec->tcxltp_pitch_fr = sts[0]->hTcxLtpDec->tcxltp_pitch_fr; + move16(); /* revert update of pit_res_max_past to have correct value also in right channel */ sts[0]->pit_res_max_past = pit_res_max_past_tmp; + move16(); } /*TCX-LTP*/ @@ -286,19 +305,25 @@ void stereo_dft_dec_core_switching_fx( st = hCPE->hCoreCoder[0]; /* in DFT stereo, only M channel is decoded by the CoreCoder */ output_Fs = st->output_Fs; + move32(); L_frameTCX = st->hTcxDec->L_frameTCX; + move16(); /*TBE*/ delay_tdbwe = NS2SA( output_Fs, DELAY_BWE_TOTAL_NS ); + move16(); delay_dft_dec = NS2SA( output_Fs, STEREO_DFT_DELAY_DEC_BWE_NS ); - delay_dft_dec_lb = NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT_DELAY_DEC_BWE_NS ); + move16(); + delay_dft_dec_lb = NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT_DELAY_DEC_BWE_NS ); + move16(); /* TCX/ACELP/HQ-CORE->TCX */ - tmps = NS2SA( output_Fs, DELAY_BWE_TOTAL_NS ); /*cross-fading size @ FB*/ - delay_comp = NS2SA( st->L_frame * FRAMES_PER_SEC, DELAY_BWE_TOTAL_NS ); /*cross-fading size @ LB*/ + tmps = NS2SA( output_Fs, DELAY_BWE_TOTAL_NS ); /*cross-fading size @ FB*/ + move16(); + delay_comp = NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), DELAY_BWE_TOTAL_NS ); /*cross-fading size @ LB*/ + move16(); - calc_inv = 1; - calc_inv = calc_inv << 31; + calc_inv = W_shl( 1, 31 ); // Memory Tables ////////////////////////////////////////////////////////////////////////////// @@ -306,17 +331,22 @@ void stereo_dft_dec_core_switching_fx( Word32 delay_comp_inv_tbl[] = { 2147483647, 306783378, 153391689, 97612893, 74051160, 58040098, 48806446, 42107522, 36398027, 32537631, 29020049 }; /////////////////////////////////////////////////////////////////////////////////////////////// - IF( st->last_L_frame != st->L_frame && st->last_L_frame <= L_FRAME16k && st->L_frame <= L_FRAME16k ) + test(); + test(); + IF( NE_16( st->last_L_frame, st->L_frame ) && LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) { - L_lerp_fx_q11( hCPE->input_mem_LB_fx[0], hCPE->input_mem_LB_fx[0], NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), NS2SA( st->last_L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); - L_lerp_fx_q11( hCPE->input_mem_BPF_fx[0], hCPE->input_mem_BPF_fx[0], NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), NS2SA( st->last_L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); + L_lerp_fx_q11( hCPE->input_mem_LB_fx[0], hCPE->input_mem_LB_fx[0], NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA( L_mult0( st->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); + L_lerp_fx_q11( hCPE->input_mem_BPF_fx[0], hCPE->input_mem_BPF_fx[0], NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA( L_mult0( st->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); } - IF( st->prev_bfi && !( st->last_core_bfi == ACELP_CORE && st->last_con_tcx == 1 ) ) + test(); + test(); + if ( ( st->prev_bfi != 0 ) && EQ_16( EQ_16( st->last_core_bfi, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ), 0 ) ) { /* last_core needed FOR correctly decoding ACELP->TCX/HQ switching frames in ivas_core_dec(). In the following steps the decoder needs to consider IF the core was changed due to a lost frame to apply the correct transition */ st->last_core = st->last_core_bfi; + move16(); } #ifndef MSAN_FIX @@ -326,15 +356,28 @@ void stereo_dft_dec_core_switching_fx( } #endif - IF( st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE || ( st->bfi == 1 && st->core == ACELP_CORE && st->con_tcx == 1 ) ) + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) ) { - IF( ( ( st->last_core != ACELP_CORE || ( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) && st->last_core != AMR_WB_CORE ) || ( sba_dirac_stereo_dtx_flag && st->cng_type == FD_CNG ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( ( NE_16( st->last_core, ACELP_CORE ) || ( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) && NE_16( st->last_core, AMR_WB_CORE ) ) || ( sba_dirac_stereo_dtx_flag && EQ_16( st->cng_type, FD_CNG ) ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ { /* In case of a TCX to ACELP switch next frame */ - Copy32( &output_fx[st->L_frame - NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); + Copy32( &output_fx[st->L_frame - NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /* BPF */ - IF( st->p_bpf_noise_buf_32 && st->core != HQ_CORE ) + test(); + test(); + IF( st->p_bpf_noise_buf_32 && NE_16( st->core, HQ_CORE ) ) { #ifdef MSAN_FIX Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( *q, Q11 ) ); @@ -342,7 +385,7 @@ void stereo_dft_dec_core_switching_fx( stereo_dft_dec_analyze_fx( hCPE, st->p_bpf_noise_buf_32, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_BPF, 2, 0, q, q_DFT ); } /* st->p_bpf_noise_buf not updated FOR HQ core -> skip analysis and set input memory to zero */ - ELSE IF( st->p_bpf_noise_buf_32 && st->core == HQ_CORE ) + ELSE IF( st->p_bpf_noise_buf_32 && EQ_16( st->core, HQ_CORE ) ) { set32_fx( hCPE->input_mem_BPF_fx[0], 0, STEREO_DFT32MS_OVL_16k ); } @@ -350,25 +393,31 @@ void stereo_dft_dec_core_switching_fx( /* TCX */ stereo_dft_dec_analyze_fx( hCPE, synth_fx, DFT_fx, 0, L_frameTCX, output_frame, DFT_STEREO_DEC_ANA_FB, 0, 0, q, q_DFT ); } - ELSE IF( st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE ) /* ACELP -> TCX/HQ */ + ELSE IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) ) /* ACELP -> TCX/HQ */ { - IF( st->last_core_brate <= SID_2k40 && st->element_mode == IVAS_SCE ) + test(); + IF( LE_32( st->last_core_brate, SID_2k40 ) && LE_16( st->element_mode, IVAS_SCE ) ) { - Word32 mem_len = NS2SA( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ); - Word32 mem_len_inv = mem_len_inv_tbl[mem_len / 25]; + Word16 mem_len = NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); + move16(); + Word32 mem_len_inv = mem_len_inv_tbl[idiv1616( mem_len, 25 )]; + move32(); Word16 qmem_len = norm_l( mem_len ); Word32 mem_len_fx = L_shl( mem_len, qmem_len ); FOR( i = 0; i < mem_len; i++ ) { - hCPE->input_mem_fx[0][i] = Mpy_32_32( hCPE->input_mem_fx[0][i], mem_len_fx - i * ( 1 << qmem_len ) ); - hCPE->input_mem_fx[0][i] = L_shl( Mpy_32_32( hCPE->input_mem_fx[0][i], mem_len_inv ), 31 - qmem_len ); + hCPE->input_mem_fx[0][i] = Mpy_32_32( hCPE->input_mem_fx[0][i], L_sub( mem_len_fx, L_shl( i, qmem_len ) ) ); + move32(); + hCPE->input_mem_fx[0][i] = L_shl( Mpy_32_32( hCPE->input_mem_fx[0][i], mem_len_inv ), sub( Q31, qmem_len ) ); + move32(); } /* Update FB input buff with hb synth FOR last delay_tdbwe sampled */ FOR( i = 0; i < delay_tdbwe; i++ ) { - hCPE->input_mem_fx[0][NS2SA( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe + i] = - L_add( hCPE->input_mem_fx[0][NS2SA( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe + i], hb_synth_fx[i] ); + hCPE->input_mem_fx[0][add( sub( NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_tdbwe ), i )] = + L_add( hCPE->input_mem_fx[0][NS2SA( L_add( L_sub( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_tdbwe ), i )], hb_synth_fx[i] ); + move32(); } } ELSE @@ -376,7 +425,8 @@ void stereo_dft_dec_core_switching_fx( /* Update FB input buff with hb synth FOR last delay_tdbwe sampled */ FOR( i = 0; i < delay_tdbwe; i++ ) { - hCPE->input_mem_fx[0][NS2SA( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_tdbwe + i] = hb_synth_fx[i]; + hCPE->input_mem_fx[0][add( sub( NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_tdbwe ), i )] = hb_synth_fx[i]; + move32(); } } @@ -387,40 +437,46 @@ void stereo_dft_dec_core_switching_fx( Word32 tmps_inv = (Word32) ( calc_inv / tmps ); FOR( i = 0; i < tmps; i++ ) { - synth_tmp_fx[i] = L_add( Mpy_32_32( hb_synth_fx[i + delay_tdbwe], tmps_fx - i * ( 1 << qtmps ) ), Mpy_32_32( synth_fx[i], i * ( 1 << qtmps ) ) ); - synth_tmp_fx[i] = L_shl( Mpy_32_32( synth_tmp_fx[i], tmps_inv ), 31 - qtmps ); + synth_tmp_fx[i] = L_add( Mpy_32_32( hb_synth_fx[add( i, delay_tdbwe )], L_sub( tmps_fx, L_shl( i, qtmps ) ) ), Mpy_32_32( synth_fx[i], L_shl( i, qtmps ) ) ); + move32(); + synth_tmp_fx[i] = L_shl( Mpy_32_32( synth_tmp_fx[i], tmps_inv ), sub( 31, qtmps ) ); + move32(); } /* FB-TCX */ stereo_dft_dec_analyze_fx( hCPE, synth_tmp_fx, DFT_fx, 0, L_frameTCX, output_frame, DFT_STEREO_DEC_ANA_FB, 0, 0, q, q_DFT ); - IF( !st->tcxonly ) + IF( st->tcxonly == 0 ) { - IF( hCPE->hStereoDft->hConfig->res_pred_mode == STEREO_DFT_RESPRED_ESF ) + IF( EQ_16( hCPE->hStereoDft->hConfig->res_pred_mode, STEREO_DFT_RESPRED_ESF ) ) { Copy32( output_fx, tcx_core_buf_fx, L_FRAME16k ); } /* fading-out LB-TCX/ACELP */ Word16 qdelay_comp = norm_l( delay_comp ); - Word32 delay_comp_inv = delay_comp_inv_tbl[delay_comp / 7]; + Word32 delay_comp_inv = delay_comp_inv_tbl[idiv1616( delay_comp, 7 )]; + move32(); Word32 delay_comp_fx = L_shl( delay_comp, qdelay_comp ); FOR( i = 0; i < delay_comp; i++ ) { - output_fx[i] = Mpy_32_32( output_fx[i], delay_comp_fx - i * ( 1 << qdelay_comp ) ); - output_fx[i] = L_shl( Mpy_32_32( output_fx[i], delay_comp_inv ), 31 - qdelay_comp ); + output_fx[i] = Mpy_32_32( output_fx[i], L_sub( delay_comp_fx, L_shl( i, qdelay_comp ) ) ); + move32(); + output_fx[i] = L_shl( Mpy_32_32( output_fx[i], delay_comp_inv ), sub( Q31, qdelay_comp ) ); + move32(); } /* In case of TCX frames, output LB TCX is zeroed out until the end but in case of an TCX->ACELP switch, this memory is needed, hence it is backed up */ /* Unlike the case when DFT32MS is disabled, there is only 1 DFT analysis window, hence in the TCX frame we don't want to do a DFT analysis FOR LB TCX but in a potential ACELP frame, we want the memories of the LB TCX FOR the last OLA samples so that HB analysis can be skipped */ - Copy32( &output_fx[st->L_frame - NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); + Copy32( &output_fx[st->L_frame - NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS )], hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /*zero the rest FOR avoiding adding contribution except the last samples which are not considered in DFT analysis (potentially used in next ACELP frame)*/ - IF( st->last_core_brate > SID_2k40 ) + IF( GT_32( st->last_core_brate, SID_2k40 ) ) { FOR( ; i < st->L_frame; i++ ) { output_fx[i] = 0; + move32(); } stereo_dft_dec_analyze_fx( hCPE, output_fx, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_LB_ADD, 1, 0, q, q_DFT ); @@ -428,7 +484,7 @@ void stereo_dft_dec_core_switching_fx( /* BPF */ IF( st->p_bpf_noise_buf_32 ) { - set32_fx( hCPE->input_mem_BPF_fx[0], 0, NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hCPE->input_mem_BPF_fx[0], 0, NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); } } } @@ -436,40 +492,49 @@ void stereo_dft_dec_core_switching_fx( } ELSE /* ACELP core */ { - IF( st->core_brate <= SID_2k40 && !( sba_dirac_stereo_dtx_flag ) ) + test(); + test(); + test(); + IF( LE_32( st->core_brate, SID_2k40 ) && !sba_dirac_stereo_dtx_flag ) { - set32_fx( hCPE->input_mem_fx[0], 0, NS2SA( st->hTcxDec->L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); - set32_fx( hCPE->input_mem_LB_fx[0], 0, NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hCPE->input_mem_fx[0], 0, NS2SA( L_mult0( st->hTcxDec->L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); + set32_fx( hCPE->input_mem_LB_fx[0], 0, NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); /* CNG generated in ivas_cpe_dec() */ } - ELSE IF( st->last_core == TCX_20_CORE || st->last_core == TCX_10_CORE || st->last_core == HQ_CORE ) /* TCX/HQ -> ACELP */ + ELSE IF( EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || EQ_16( st->last_core, HQ_CORE ) ) /* TCX/HQ -> ACELP */ { - IF( ( st->last_L_frame <= L_FRAME16k && st->L_frame <= L_FRAME16k ) || ( sba_dirac_stereo_dtx_flag && st->core_brate == SID_2k40 && st->cng_type == FD_CNG ) ) + IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( sba_dirac_stereo_dtx_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) { /* In case of a TCX to ACELP switch, retrieve the LB-TCX memories FOR the first STEREO_DFT32MS_OVL_NS NS of OLA */ - L_lerp_fx_q11( hCPE->hStereoDft->buff_LBTCX_mem_fx, hCPE->input_mem_LB_fx[0], NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), NS2SA( st->last_L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); + L_lerp_fx_q11( hCPE->hStereoDft->buff_LBTCX_mem_fx, hCPE->input_mem_LB_fx[0], NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA( L_mult0( st->last_L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); } - IF( sba_dirac_stereo_dtx_flag && st->core_brate == SID_2k40 && st->cng_type == FD_CNG ) + IF( sba_dirac_stereo_dtx_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) { Word16 nZeros; nZeros = (Word16) ( NS2SA( st->output_Fs, N_ZERO_MDCT_NS ) ); + move16(); delay_comp = NS2SA( st->output_Fs, DELAY_CLDFB_NS ); + move16(); - Copy32( &st->hHQ_core->oldOut_fx[nZeros - delay_comp - NS2SA( output_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS )], hCPE->input_mem_fx[0], NS2SA( output_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); + Copy32( &st->hHQ_core->oldOut_fx[sub( nZeros, add( delay_comp, NS2SA( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ) )], hCPE->input_mem_fx[0], NS2SA( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); Copy32( synth_fx, synth_tmp_fx, output_frame ); Word16 mem_len; - mem_len = NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ); + mem_len = NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ); + move16(); Word16 qmem_len = norm_l( mem_len ); Word32 mem_len_fx = L_shl( mem_len, qmem_len ); Word32 mem_len_inv = (Word32) ( calc_inv / tmps ); + move32(); FOR( i = 0; i < mem_len; i++ ) { - hCPE->input_mem_LB_fx[0][i] = Mpy_32_32( hCPE->input_mem_LB_fx[0][i], mem_len_fx - ( i * ( 1 << qmem_len ) ) ); - hCPE->input_mem_LB_fx[0][i] = L_shl( Mpy_32_32( hCPE->input_mem_LB_fx[0][i], mem_len_inv ), 31 - qmem_len ); + hCPE->input_mem_LB_fx[0][i] = Mpy_32_32( hCPE->input_mem_LB_fx[0][i], L_sub( mem_len_fx, L_shl( i, qmem_len ) ) ); + move32(); + hCPE->input_mem_LB_fx[0][i] = L_shl( Mpy_32_32( hCPE->input_mem_LB_fx[0][i], mem_len_inv ), sub( Q31, qmem_len ) ); + move32(); } set32_fx( output_fx, 0, st->L_frame ); @@ -487,19 +552,22 @@ void stereo_dft_dec_core_switching_fx( ELSE { /* ACELP */ - FOR( i = 0; i < ( NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ); i++ ) + FOR( i = 0; i < ( NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb ); i++ ) { hCPE->input_mem_LB_fx[0][i] = 0; + move32(); } /* ACELP fading-in*/ Word16 qdelay_dft_dec_lb = norm_l( delay_dft_dec_lb ); Word32 delay_dft_dec_lb_inv = (Word32) ( calc_inv / delay_dft_dec_lb ); FOR( i = 0; i < delay_dft_dec_lb; i++ ) { - hCPE->input_mem_LB_fx[0][NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb + i] = - Mpy_32_32( hCPE->input_mem_LB_fx[0][NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb + i], i * ( 1 << qdelay_dft_dec_lb ) ); - hCPE->input_mem_LB_fx[0][NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb + i] = - L_shl( Mpy_32_32( hCPE->input_mem_LB_fx[0][NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec_lb + i], delay_dft_dec_lb_inv ), 31 - qdelay_dft_dec_lb ); + hCPE->input_mem_LB_fx[0][add( sub( NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec_lb ), i )] = + Mpy_32_32( hCPE->input_mem_LB_fx[0][add( sub( NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec_lb ), i )], L_shl( i, qdelay_dft_dec_lb ) ); + move32(); + hCPE->input_mem_LB_fx[0][add( sub( NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec_lb ), i )] = + L_shl( Mpy_32_32( hCPE->input_mem_LB_fx[0][add( sub( NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec_lb ), i )], delay_dft_dec_lb_inv ), sub( Q31, qdelay_dft_dec_lb ) ); + move32(); } stereo_dft_dec_analyze_fx( hCPE, output_fx, DFT_fx, 0, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_LB, 0, 0, q, q_DFT ); @@ -514,29 +582,34 @@ void stereo_dft_dec_core_switching_fx( /* Fading-in TD-BWE, Fading-out FB-TCX*/ Copy32( synth_fx, synth_tmp_fx, output_frame ); - IF( hCPE->last_element_mode != IVAS_CPE_MDCT ) + IF( NE_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) ) { Word16 qdelay_dft_dec = norm_l( delay_dft_dec ); Word32 delay_dft_dec_inv = (Word32) ( calc_inv / delay_dft_dec ); Word32 delay_dft_dec_fx = L_shl( delay_dft_dec, qdelay_dft_dec ); FOR( i = 0; i < delay_dft_dec; i++ ) /* 1.25 ms of hb_synth fade-in and TCX fade-out */ { - hCPE->input_mem_fx[0][NS2SA( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec + i] = L_add( - Mpy_32_32( hb_synth_fx[delay_tdbwe - delay_dft_dec + i], i * ( 1 << qdelay_dft_dec ) ), - Mpy_32_32( hCPE->input_mem_fx[0][NS2SA( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec + i], delay_dft_dec_fx - i * ( 1 << qdelay_dft_dec ) ) ); - hCPE->input_mem_fx[0][NS2SA( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec + i] = L_shl( - Mpy_32_32( hCPE->input_mem_fx[0][NS2SA( L_frameTCX * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) - delay_dft_dec + i], delay_dft_dec_inv ), - 31 - qdelay_dft_dec ); + hCPE->input_mem_fx[0][add( sub( NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec ), i )] = L_add( + Mpy_32_32( hb_synth_fx[add( sub( delay_tdbwe, delay_dft_dec ), i )], L_shl( i, qdelay_dft_dec ) ), + Mpy_32_32( hCPE->input_mem_fx[0][add( sub( NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec ), i )], L_sub( delay_dft_dec_fx, L_shl( i, qdelay_dft_dec ) ) ) ); + move32(); + hCPE->input_mem_fx[0][add( sub( NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec ), i )] = L_shl( + Mpy_32_32( hCPE->input_mem_fx[0][add( sub( NS2SA( L_mult0( L_frameTCX, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), delay_dft_dec ), i )], delay_dft_dec_inv ), + sub( Q31, qdelay_dft_dec ) ); + move32(); } FOR( i = 0; i < delay_dft_dec; i++ ) /* 1.25 ms of hb_synth fade out. ICBWE fade in performed in time domain here */ { - synth_tmp_fx[i] = Mpy_32_32( hb_synth_fx[delay_tdbwe - delay_dft_dec + i], delay_dft_dec_fx - i * ( 1 << qdelay_dft_dec ) ); - synth_tmp_fx[i] = L_shl( Mpy_32_32( synth_tmp_fx[i], delay_dft_dec_inv ), 31 - qdelay_dft_dec ); + synth_tmp_fx[i] = Mpy_32_32( hb_synth_fx[add( sub( delay_tdbwe, delay_dft_dec ), i )], L_sub( delay_dft_dec_fx, L_shl( i, qdelay_dft_dec ) ) ); + move32(); + synth_tmp_fx[i] = L_shl( Mpy_32_32( synth_tmp_fx[i], delay_dft_dec_inv ), sub( Q31, qdelay_dft_dec ) ); + move32(); } FOR( ; i < output_frame; i++ ) { synth_tmp_fx[i] = 0; + move32(); } } } @@ -546,7 +619,7 @@ void stereo_dft_dec_core_switching_fx( { stereo_dft_dec_analyze_fx( hCPE, synth_tmp_fx, DFT_fx, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_FB_ADD, 0, 0, q, q_DFT ); } - ELSE IF( hCPE->last_element_mode == IVAS_CPE_MDCT ) + ELSE IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) ) { stereo_dft_dec_analyze_fx( hCPE, synth_tmp_fx, DFT_fx, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_HB_ADD, 1, 0, q, q_DFT ); } @@ -557,14 +630,18 @@ void stereo_dft_dec_core_switching_fx( } ELSE /* ACELP -> ACELP */ { - IF( sba_dirac_stereo_dtx_flag && st->core_brate <= SID_2k40 && st->cng_type == FD_CNG ) + test(); + test(); + test(); + test(); + IF( sba_dirac_stereo_dtx_flag && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) { set32_fx( output_fx, 0, st->L_frame ); } /* this needs an indication FOR sba2stereo in general */ - ELSE IF( hCPE->element_mode == IVAS_SCE && st->last_core_brate <= SID_2k40 && st->cng_type == FD_CNG ) + ELSE IF( EQ_16( hCPE->element_mode, IVAS_SCE ) && LE_32( st->last_core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) { - L_lerp_fx_q11( hCPE->input_mem_fx[0], hCPE->input_mem_LB_fx[0], NS2SA( st->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), NS2SA( output_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ) ); + L_lerp_fx_q11( hCPE->input_mem_fx[0], hCPE->input_mem_LB_fx[0], NS2SA( L_mult0( st->L_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ), NS2SA( L_mult0( output_frame, FRAMES_PER_SEC ), STEREO_DFT32MS_OVL_NS ) ); } /* ACELP synthesis @ internal sampling rate */ @@ -581,13 +658,17 @@ void stereo_dft_dec_core_switching_fx( } /* BWE */ - IF( sba_dirac_stereo_dtx_flag && st->core_brate <= SID_2k40 && st->cng_type == FD_CNG ) + test(); + test(); + test(); + test(); + IF( sba_dirac_stereo_dtx_flag && LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) { stereo_dft_dec_analyze_fx( hCPE, synth_fx, DFT_fx, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_FB_ADD, 0, 0, q, q_DFT ); } - ELSE IF( st->extl != -1 || ( st->bws_cnt > 0 && st->core == ACELP_CORE ) ) + ELSE IF( NE_16( st->extl, -1 ) || ( ( st->bws_cnt > 0 ) && EQ_16( st->core, ACELP_CORE ) ) ) { - stereo_dft_dec_analyze_fx( hCPE, hb_synth_fx, DFT_fx, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_FB_ADD, 2, -delay_tdbwe, q, q_DFT ); + stereo_dft_dec_analyze_fx( hCPE, hb_synth_fx, DFT_fx, 0, output_frame, output_frame, DFT_STEREO_DEC_ANA_FB_ADD, 2, negate( delay_tdbwe ), q, q_DFT ); } } } @@ -596,30 +677,46 @@ void stereo_dft_dec_core_switching_fx( * enhanced stereo filling: allpass filter *----------------------------------------------------------------*/ - IF( hCPE->hStereoDft->hConfig->res_pred_mode == STEREO_DFT_RESPRED_ESF ) + IF( EQ_16( hCPE->hStereoDft->hConfig->res_pred_mode, STEREO_DFT_RESPRED_ESF ) ) { - IF( st->sr_core == INT_FS_12k8 ) + IF( EQ_32( st->sr_core, INT_FS_12k8 ) ) { ap_fade_len = STEREO_DFT_ALLPASS_FADELEN_12k8; + move16(); + ap_fade_len_inv = 67108864; + move32(); } ELSE { ap_fade_len = STEREO_DFT_ALLPASS_FADELEN_16k; + move16(); + ap_fade_len_inv = 53687091; + move32(); } qap_fade_len = norm_l( ap_fade_len ); ap_fade_len_fx = L_shl( ap_fade_len, qap_fade_len ); - ap_fade_len_inv = ap_fade_len == 32 ? 67108864 : 53687091; - IF( st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE || ( st->bfi == 1 && st->core == ACELP_CORE && st->con_tcx == 1 ) ) + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) ) { Word16 numZeros = (Word16) ( NS2SA( st->sr_core, N_ZERO_MDCT_NS ) ); Word32 tmp_fade_fx[max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )]; Copy32( st->hHQ_core->old_outLB_fx + numZeros, hCPE->hStereoDft->ap_fade_mem_fx, ap_fade_len ); hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->q_old_outLB_fx; - - IF( st->last_core == ACELP_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) && !st->tcxonly ) + move16(); + + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st->last_core, ACELP_CORE ) && !( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) && !st->tcxonly ) { Copy32( tcx_core_buf_fx, pAp_input_fx, st->L_frame ); } @@ -628,34 +725,39 @@ void stereo_dft_dec_core_switching_fx( Copy32( output_fx, pAp_input_fx, st->L_frame ); } - IF( st->last_core == ACELP_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) && !st->tcxonly ) /* ACELP -> TCX/HQ-Core */ + IF( EQ_16( st->last_core, ACELP_CORE ) && EQ_16( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ), 0 ) && !st->tcxonly ) /* ACELP -> TCX/HQ-Core */ { Copy32( tcx_core_buf_fx, tmp_fade_fx, ap_fade_len ); FOR( i = 0; i < ap_fade_len; i++ ) { pAp_input_fx[i] = L_add( - Mpy_32_32( pAp_input_fx[i], i * ( 1 << qap_fade_len ) ), - Mpy_32_32( tmp_fade_fx[i], ap_fade_len_fx - i * ( 1 << qap_fade_len ) ) ); - pAp_input_fx[i] = L_shl( Mpy_32_32( pAp_input_fx[i], ap_fade_len_inv ), 31 - qap_fade_len ); + Mpy_32_32( pAp_input_fx[i], L_shl( i, qap_fade_len ) ), + Mpy_32_32( tmp_fade_fx[i], L_sub( ap_fade_len_fx, L_shl( i, qap_fade_len ) ) ) ); + move32(); + pAp_input_fx[i] = L_shl( Mpy_32_32( pAp_input_fx[i], ap_fade_len_inv ), sub( Q31, qap_fade_len ) ); + move32(); } } } ELSE { Copy32( output_fx, pAp_input_fx, st->L_frame ); - IF( st->last_core != ACELP_CORE ) /* TCX/HQ-Core -> ACELP */ + IF( NE_16( st->last_core, ACELP_CORE ) ) /* TCX/HQ-Core -> ACELP */ { Word16 shift = sub( hCPE->hStereoDft->q_ap_fade_mem_fx, q_DFT[0] ); FOR( i = 0; i < ap_fade_len; i++ ) { pAp_input_fx[i] = L_add( - Mpy_32_32( pAp_input_fx[i], i * ( 1 << qap_fade_len ) ), - Mpy_32_32( L_shr( hCPE->hStereoDft->ap_fade_mem_fx[i], shift ), ap_fade_len_fx - i * ( 1 << qap_fade_len ) ) ); - pAp_input_fx[i] = L_shl( Mpy_32_32( pAp_input_fx[i], ap_fade_len_inv ), 31 - qap_fade_len ); + Mpy_32_32( pAp_input_fx[i], L_shl( i, qap_fade_len ) ), + Mpy_32_32( L_shr( hCPE->hStereoDft->ap_fade_mem_fx[i], shift ), L_sub( ap_fade_len_fx, L_shl( i, qap_fade_len ) ) ) ); + move32(); + pAp_input_fx[i] = L_shl( Mpy_32_32( pAp_input_fx[i], ap_fade_len_inv ), sub( Q31, qap_fade_len ) ); + move32(); } } } predelay = NS2SA( st->sr_core, DELAY_BWE_TOTAL_NS ); + move16(); /* apply predelay to have same overall filter delay FOR all cases */ @@ -672,21 +774,27 @@ void stereo_dft_dec_core_switching_fx( { FOR( i = 0; i < ap_fade_len; i++ ) { - pAp_input_fx[i] = Mpy_32_32( pAp_input_fx[i], ap_fade_len_fx - i * ( 1 << qap_fade_len ) ); - pAp_input_fx[i] = L_shl( Mpy_32_32( pAp_input_fx[i], ap_fade_len_inv ), 31 - qap_fade_len ); + pAp_input_fx[i] = Mpy_32_32( pAp_input_fx[i], L_sub( ap_fade_len_fx, L_shl( i, qap_fade_len ) ) ); + move32(); + pAp_input_fx[i] = L_shl( Mpy_32_32( pAp_input_fx[i], ap_fade_len_inv ), sub( Q31, qap_fade_len ) ); + move32(); } } set32_fx( pAp_input_fx + ap_fade_len, 0, st->L_frame - ap_fade_len ); hCPE->hStereoDft->ap_wasTransient = 1; + move16(); } ELSE IF( hCPE->hStereoDft->ap_wasTransient ) { FOR( i = 0; i < ap_fade_len; i++ ) { - pAp_input_fx[i] = Mpy_32_32( pAp_input_fx[i], i * ( 1 << qap_fade_len ) ); - pAp_input_fx[i] = L_shl( Mpy_32_32( pAp_input_fx[i], ap_fade_len_inv ), 31 - qap_fade_len ); + pAp_input_fx[i] = Mpy_32_32( pAp_input_fx[i], L_shl( i, qap_fade_len ) ); + move32(); + pAp_input_fx[i] = L_shl( Mpy_32_32( pAp_input_fx[i], ap_fade_len_inv ), sub( Q31, qap_fade_len ) ); + move32(); } hCPE->hStereoDft->ap_wasTransient = 0; + move16(); } /* apply 5-stage allpass, each stage consisting of a nested allpass pair */ @@ -697,15 +805,21 @@ void stereo_dft_dec_core_switching_fx( /* apply DFT to allpass-filtered signal */ stereo_dft_dec_analyze_fx( hCPE, pAp_input_fx, DFT_fx, 1, st->L_frame, output_frame, DFT_STEREO_DEC_ANA_FB, 0, 0, q, q_DFT ); hCPE->hStereoDft->q_ap_delay_mem_fx = *q; + move16(); } - IF( st->core == ACELP_CORE ) + IF( EQ_16( st->core, ACELP_CORE ) ) { IF( !use_cldfb_for_dft ) /* Skip this FOR DFT Stereo mono output at non-residual bitrates */ { L_lerp_fx_q11( output_fx, synth_fx, output_frame, hCPE->hCoreCoder[0]->L_frame ); /* Dirty resampling, but should be good enough FOR ECU analysis */ } - IF( !use_cldfb_for_dft || ( ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) && st->cng_type == LP_CNG && st->extl == SWB_CNG && hCPE->nchan_out == 1 ) ) + test(); + test(); + test(); + test(); + test(); + IF( !use_cldfb_for_dft || ( ( EQ_32( st->core_brate, FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && EQ_16( st->cng_type, LP_CNG ) && EQ_16( st->extl, SWB_CNG ) && EQ_16( hCPE->nchan_out, 1 ) ) ) { v_add_fx( synth_fx, hb_synth_fx, synth_fx, output_frame ); /* Use one channel TD-BWE FOR ECU analysis buffer */ } diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index c830e1b789b3632eb840332df812a22652f50b62..cb1460ea2e7fa06db32ad8f707ffc697ea656f6a 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -165,6 +165,7 @@ Word16 ivas_qmetadata_dec_decode( move16(); all_coherence_zero = 1; move16(); + IF( hQMetaData->coherence_flag ) { /* read if coherence is zero */ @@ -188,12 +189,15 @@ Word16 ivas_qmetadata_dec_decode( p[0] = dif_p[0]; move16(); hQMetaData->twoDirBands[p[0]] = 1; + move16(); FOR( b = 1; b < hQMetaData->numTwoDirBands; b++ ) { dif_p[b] = ivas_qmetadata_DecodeExtendedGR( bitstream, index, MASA_MAXIMUM_CODING_SUBBANDS, 0 ); move16(); p[b] = add( add( p[b - 1], dif_p[b] ), 1 ); + move16(); hQMetaData->twoDirBands[p[b]] = 1; + move16(); } bits_no_dirs_coh = add( bits_no_dirs_coh, sub( d, *index ) ); } @@ -215,7 +219,7 @@ Word16 ivas_qmetadata_dec_decode( { dfRatio_bits[dir2band] = ivas_get_df_ratio_bits_hodirac( hQMetaData->q_direction[0].band_data[b].energy_ratio_index[0] ); move16(); - dir2band++; + dir2band = add( dir2band, 1 ); } } @@ -235,7 +239,7 @@ Word16 ivas_qmetadata_dec_decode( { dfRatio_bits[dir2band] = ivas_get_df_ratio_bits( hQMetaData->q_direction[0].band_data[b].energy_ratio_index[0] ); move16(); - dir2band++; + dir2band = add( dir2band, 1 ); } } @@ -308,7 +312,7 @@ Word16 ivas_qmetadata_dec_decode( move16(); } - dir2band++; + dir2band = add( dir2band, 1 ); } ELSE { @@ -349,6 +353,7 @@ Word16 ivas_qmetadata_dec_decode( bits_dir_raw_pre[1] = 0; move16(); dir2band = 0; + move16(); FOR( b = hQMetaData->q_direction[0].cfg.start_band; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) { test(); @@ -383,7 +388,7 @@ Word16 ivas_qmetadata_dec_decode( move16(); } - dir2band++; + dir2band = add( dir2band, 1 ); } ELSE { @@ -404,7 +409,7 @@ Word16 ivas_qmetadata_dec_decode( no_TF = add( i_mult2( hQMetaData->q_direction[0].cfg.nbands, hQMetaData->q_direction[0].cfg.nblocks ), i_mult2( hQMetaData->q_direction[1].cfg.nbands, hQMetaData->q_direction[1].cfg.nblocks ) ); tmp32 = L_sub( L_deposit_h( sub( sub( hQMetaData->metadata_max_bits, bits_no_dirs_coh ), bits_diff_sum ) ), L_mult0( 17612 /* 4.2998046875f in Q12 */, shl( no_TF, 4 ) ) ); test(); - IF( EQ_32( all_coherence_zero, 0 ) && GE_32( tmp32, L_deposit_h( MASA_MIN_BITS_SURR_COH ) ) ) + IF( !all_coherence_zero && GE_32( tmp32, L_deposit_h( MASA_MIN_BITS_SURR_COH ) ) ) { bits_sur_coherence = read_surround_coherence( bitstream, index, hQMetaData ); } @@ -429,7 +434,7 @@ Word16 ivas_qmetadata_dec_decode( no_TF = i_mult2( hQMetaData->q_direction[0].cfg.nbands, hQMetaData->q_direction[0].cfg.nblocks ); tmp32 = L_sub( L_deposit_h( sub( sub( hQMetaData->metadata_max_bits, bits_no_dirs_coh ), bits_diff_sum ) ), L_mult0( 17612 /* 4.2998046875f in Q12 */, shl( no_TF, 4 ) ) ); test(); - IF( EQ_32( all_coherence_zero, 0 ) && GE_32( tmp32, L_deposit_h( MASA_MIN_BITS_SURR_COH ) ) ) + IF( !all_coherence_zero && GE_32( tmp32, L_deposit_h( MASA_MIN_BITS_SURR_COH ) ) ) { bits_sur_coherence = read_surround_coherence( bitstream, index, hQMetaData ); } @@ -468,7 +473,7 @@ Word16 ivas_qmetadata_dec_decode( diffuseness_index_max_ec_frame = diffuseness_index_max_ec_frame_pre[0]; move16(); - IF( EQ_16( d, 0 ) ) + IF( d == 0 ) { bits_diff = bits_diff_sum; move16(); @@ -485,7 +490,7 @@ Word16 ivas_qmetadata_dec_decode( bits_coherence = 0; move16(); - IF( EQ_32( all_coherence_zero, 0 ) ) + IF( all_coherence_zero == 0 ) { bits_coherence = read_coherence_data_fx( bitstream, index, hQMetaData, d, 0 ); } @@ -517,30 +522,32 @@ Word16 ivas_qmetadata_dec_decode( move16(); IF( LE_16( add( total_bits_1dir, bits_sur_coherence ), hQMetaData->qmetadata_max_bit_req ) ) { - ec_flag = bitstream[( *index )--]; + ec_flag = bitstream[( *index )]; move16(); - signal_bits++; + ( *index ) = sub( ( *index ), 1 ); + move16(); + signal_bits = add( signal_bits, 1 ); IF( GT_16( nblocks, 1 ) ) { IF( ec_flag ) { ec_flag = add( ec_flag, (Word16) bitstream[( *index )--] ); - signal_bits++; + signal_bits = add( signal_bits, 1 ); } } } /* Decode quantized directions frame-wise */ test(); - IF( EQ_16( ec_flag, 0 ) ) /* EC 1*/ + IF( !ec_flag ) /* EC 1*/ { bits_dir = 0; move16(); raw_flag[0] = bitstream[( *index )--]; move16(); - bits_dir++; + bits_dir = add( bits_dir, 1 ); - IF( EQ_16( raw_flag[0], 0 ) ) + IF( !raw_flag[0] ) { bits_dir = add( bits_dir, ivas_qmetadata_entropy_decode_dir_fx( q_direction, bitstream, index, diffuseness_index_max_ec_frame, nbands, start_band, 0 ) ); } @@ -558,7 +565,7 @@ Word16 ivas_qmetadata_dec_decode( { raw_flag[b] = bitstream[( *index )--]; move16(); - bits_dir++; + bits_dir = add( bits_dir, 1 ); } /* Read EC bits*/ @@ -566,7 +573,7 @@ Word16 ivas_qmetadata_dec_decode( FOR( b = start_band; b < nbands; b++ ) { - IF( EQ_16( raw_flag[b], 0 ) ) + IF( !raw_flag[b] ) { bits_dir = add( bits_dir, ivas_qmetadata_entropy_decode_dir_fx( q_direction, bitstream, index, diffuseness_index_max_ec_frame, b + 1, b, 0 ) ); } @@ -578,7 +585,7 @@ Word16 ivas_qmetadata_dec_decode( diff_bits = add( diff_bits, bits_dir ); /* Small requantization?*/ - IF( GT_16( q_direction->not_in_2D, 0 ) ) + IF( q_direction->not_in_2D > 0 ) { /* This is not an ideal solution but mirrors better encoder */ Word16 i, j; @@ -621,7 +628,7 @@ Word16 ivas_qmetadata_dec_decode( ec_flag = 2; move16(); - IF( EQ_16( hQMetaData->is_masa_ivas_format, 0 ) ) + IF( hQMetaData->is_masa_ivas_format == 0 ) { reduce_bits = sub( bits_dir_raw, sub( sub( sub( total_bits_1dir, bits_diff ), bits_coherence ), signal_bits ) ); ind_order[0] = -1; @@ -643,7 +650,7 @@ Word16 ivas_qmetadata_dec_decode( bits_dir = read_directions_fx( q_direction, (UWord8) nbands, (UWord8) nblocks, bitstream, index, ind_order ); } - IF( GT_16( bits_coherence, 0 ) ) + IF( bits_coherence > 0 ) { IF( GT_16( nblocks, 1 ) ) { @@ -660,7 +667,7 @@ Word16 ivas_qmetadata_dec_decode( } } } - IF( EQ_16( d, 0 ) ) + IF( d == 0 ) { total_bits_1dir = sub( hQMetaData->metadata_max_bits, sub( start_index_0, *index ) ); } @@ -673,6 +680,7 @@ Word16 ivas_qmetadata_dec_decode( { d = sub( hQMetaData->q_direction[1].cfg.nbands, 1 ); nblocks = hQMetaData->q_direction[0].cfg.nblocks; + move16(); FOR( b = hQMetaData->q_direction[0].cfg.nbands - 1; b >= 0; b-- ) { @@ -712,7 +720,7 @@ Word16 ivas_qmetadata_dec_decode( { mvc2c( hQMetaData->q_direction[1].coherence_band_data[d].spread_coherence, hQMetaData->q_direction[1].coherence_band_data[b].spread_coherence, nblocks ); } - d--; + d = sub( d, 1 ); } ELSE { @@ -728,7 +736,7 @@ Word16 ivas_qmetadata_dec_decode( } /* Scale energy ratios that sum to over one */ - IF( !hodirac_flag ) + IF( hodirac_flag == 0 ) { FOR( b = 0; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) { @@ -1339,6 +1347,7 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( Word16 p[MASA_MAXIMUM_CODING_SUBBANDS], dif_p[MASA_MAXIMUM_CODING_SUBBANDS]; Word16 codedBands, sf_nbands0, sf_nbands1; sf_nbands1 = 1; + move16(); Word64 W_nrg_ratio[2][MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES]; start_index_0 = *index; @@ -1371,6 +1380,7 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( IF( hQMetaData->coherence_flag && hQMetaData->q_direction[0].coherence_band_data != NULL ) { hQMetaData->q_direction[0].coherence_band_data[b].spread_coherence[m] = 0u; + move16(); } IF( EQ_32( hQMetaData->no_directions, 2 ) ) @@ -1389,6 +1399,7 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( IF( hQMetaData->coherence_flag && hQMetaData->q_direction[1].coherence_band_data != NULL ) { hQMetaData->q_direction[1].coherence_band_data[b].spread_coherence[m] = 0u; + move16(); } } @@ -1396,12 +1407,14 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( IF( hQMetaData->coherence_flag && hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[b].surround_coherence[m] = 0u; + move16(); } } IF( EQ_32( hQMetaData->no_directions, 2 ) ) { hQMetaData->twoDirBands[b] = 0; + move16(); } } sf_nbands0 = hQMetaData->q_direction[0].cfg.nbands; @@ -1435,7 +1448,7 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( move16(); sf_nbands1 = hQMetaData->q_direction[1].cfg.nbands; move16(); - IF( GT_16( hQMetaData->q_direction[1].cfg.nbands, codedBands ) ) + if ( GT_16( hQMetaData->q_direction[1].cfg.nbands, codedBands ) ) { hQMetaData->q_direction[1].cfg.nbands = codedBands; move16(); @@ -1448,6 +1461,7 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( p[0] = dif_p[0]; move16(); hQMetaData->twoDirBands[p[0]] = 1; + move16(); FOR( b = 1; b < hQMetaData->q_direction[1].cfg.nbands; b++ ) { dif_p[b] = ivas_qmetadata_DecodeExtendedGR( bitstream, index, MASA_MAXIMUM_CODING_SUBBANDS, 0 ); @@ -1455,6 +1469,7 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( p[b] = add( add( p[b - 1], dif_p[b] ), 1 ); move16(); hQMetaData->twoDirBands[p[b]] = 1; + move16(); } } @@ -1521,7 +1536,7 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( { pos_2dir_band[d] = b; move16(); - d++; + d = add( d, 1 ); } ELSE { @@ -1576,7 +1591,7 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( } } - IF( EQ_32( all_coherence_zero, 0 ) ) + IF( !all_coherence_zero ) { read_surround_coherence_hr_fx( bitstream, index, hQMetaData, W_nrg_ratio ); } @@ -1601,7 +1616,7 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( move16(); /* Read coherence, IF any */ - IF( EQ_32( all_coherence_zero, 0 ) ) + IF( !all_coherence_zero ) { read_coherence_data_hr_512_fx( bitstream, index, hQMetaData, d, bits_sp_coh ); } @@ -1651,7 +1666,7 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( { mvc2c( hQMetaData->q_direction[1].coherence_band_data[d].spread_coherence, hQMetaData->q_direction[1].coherence_band_data[b].spread_coherence, nblocks ); } - d--; + d = sub( d, 1 ); } ELSE { @@ -2102,10 +2117,12 @@ Word16 ivas_qmetadata_dec_sid_decode( IF( EQ_16( ivas_format, SBA_FORMAT ) ) { metadata_sid_bits = (Word16) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - 2 - SID_FORMAT_NBITS; /* -1 for inactive mode header bit*/ + move16(); } ELSE { metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; + move16(); } start_index = *index; @@ -2166,7 +2183,7 @@ Word16 ivas_qmetadata_dec_sid_decode( /* Decode diffuseness*/ FOR( b = start_band; b < nbands; b++ ) { - diffuseness_index[b] = (UWord16) L_add( ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS - 4 ), 4 ); + diffuseness_index[b] = (UWord16) L_add( ivas_qmetadata_DecodeQuasiUniform( bitstream, index, sub( DIRAC_DIFFUSE_LEVELS, 4 ) ), 4 ); move16(); q_direction->band_data[b].energy_ratio_index[0] = diffuseness_index[b]; move16(); @@ -2179,21 +2196,22 @@ Word16 ivas_qmetadata_dec_sid_decode( bits_delta = sub( sub( metadata_sid_bits, sub( start_index, *index ) ), bits_dir ); /* bit_diff is already read */ - IF( GT_16( bits_delta, 0 ) ) + IF( bits_delta > 0 ) { - WHILE( GT_16( bits_delta, 0 ) ) + WHILE( bits_delta > 0 ) { FOR( b = start_band; b < nbands && ( bits_delta > 0 ); b++ ) { IF( LT_32( q_direction->band_data[b].bits_sph_idx[0], 11 ) ) { bits_delta = sub( bits_delta, 1 ); - q_direction->band_data[b].bits_sph_idx[0]++; + q_direction->band_data[b].bits_sph_idx[0] = add( q_direction->band_data[b].bits_sph_idx[0], 1 ); + move16(); } } } - IF( EQ_16( q_direction->not_in_2D, 0 ) ) + IF( q_direction->not_in_2D == 0 ) { FOR( b = start_band; b < nbands; b++ ) { @@ -2204,18 +2222,19 @@ Word16 ivas_qmetadata_dec_sid_decode( } ELSE { - WHILE( LT_16( bits_delta, 0 ) ) + WHILE( bits_delta < 0 ) { FOR( b = nbands - 1; b >= start_band && ( bits_delta < 0 ); b-- ) { IF( GE_32( q_direction->band_data[b].bits_sph_idx[0], 4 ) ) { bits_delta = add( bits_delta, 1 ); - q_direction->band_data[b].bits_sph_idx[0]--; + q_direction->band_data[b].bits_sph_idx[0] = sub( q_direction->band_data[b].bits_sph_idx[0], 1 ); + move16(); } } - IF( EQ_16( q_direction->not_in_2D, 0 ) ) + IF( q_direction->not_in_2D == 0 ) { FOR( b = start_band; b < nbands; b++ ) { @@ -2254,7 +2273,7 @@ Word16 ivas_qmetadata_dec_sid_decode( } /* Decoder DOAs*/ - IF( GT_16( q_direction->not_in_2D, 0 ) ) + IF( q_direction->not_in_2D > 0 ) { FOR( b = start_band; b < nbands; b++ ) { @@ -2300,7 +2319,7 @@ Word16 ivas_qmetadata_dec_sid_decode( q_direction->band_data[b].azimuth_index[0] = add( ivas_qmetadata_dereorder_generic( q_direction->band_data[b].azimuth_index[0] ), shr( q_direction->band_data[b].azimuth_m_alphabet[0], 1 ) ); move16(); - temp_result = div_s( ( q_direction->band_data[b].azimuth_index[0] << 6 ), ( q_direction->band_data[b].azimuth_m_alphabet[0] << 6 ) ); + temp_result = div_s( ( shl( q_direction->band_data[b].azimuth_index[0], 6 ) ), ( shl( q_direction->band_data[b].azimuth_m_alphabet[0], 6 ) ) ); temp_result = Mpy_32_16_1( DEGREE_360_Q_22, (Word16) temp_result ); avg_azimuth_fx = L_sub( temp_result, DEGREE_180_Q_22 ); @@ -2315,9 +2334,9 @@ Word16 ivas_qmetadata_dec_sid_decode( FOR( m = 0; m < nblocks - 1; m++ ) { v_add_32( direction_vector_fx, avg_direction_vector_fx, direction_vector_fx, 3 ); - ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( direction_vector_fx, sub( 30, 5 ), &q_direction->band_data[b].azimuth_fx[m], &q_direction->band_data[b].elevation_fx[m] ); + ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( direction_vector_fx, 30 - 5, &q_direction->band_data[b].azimuth_fx[m], &q_direction->band_data[b].elevation_fx[m] ); } - ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( avg_direction_vector_fx, sub( 30, 5 ), &q_direction->band_data[b].azimuth_fx[nblocks - 1], &q_direction->band_data[b].elevation_fx[nblocks - 1] ); + ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( avg_direction_vector_fx, 30 - 5, &q_direction->band_data[b].azimuth_fx[nblocks - 1], &q_direction->band_data[b].elevation_fx[nblocks - 1] ); FOR( i = 0; i < nblocks; i++ ) { @@ -2576,11 +2595,12 @@ static Word16 ivas_diffuseness_huff_ec_decode_fx( Word16 val; val = 0; - WHILE( val <= DIFF_EC_HUFF_GR0_LIMIT ) + move16(); + WHILE( LE_16( val, DIFF_EC_HUFF_GR0_LIMIT ) ) { - IF( bitstream[( *index )--] == 1 ) + IF( EQ_16( bitstream[( *index )--], 1 ) ) { - val++; + val = add( val, 1 ); } ELSE { @@ -2588,21 +2608,19 @@ static Word16 ivas_diffuseness_huff_ec_decode_fx( } } - IF( val == DIFF_EC_HUFF_GR0_LIMIT + 1 ) + IF( EQ_16( val, DIFF_EC_HUFF_GR0_LIMIT + 1 ) ) { - val += 2 * bitstream[( *index )]; - ( *index )--; - val += bitstream[( *index )]; - ( *index )--; + val = add( val, shl( bitstream[( *index )--], 1 ) ); + val = add( val, bitstream[( *index )--] ); } IF( val % 2 == 0 ) { - return -( val / 2 ) + av; + return add( negate( shr( val, 1 ) ), av ); } ELSE { - return ( val + 1 ) / 2 + av; + return add( shr( add( val, 1 ), 1 ), av ); } } #else @@ -2679,6 +2697,7 @@ static Word16 ivas_qmetadata_entropy_decode_diffuseness( FOR( b = 0; b < MASA_BITS_ER; b++ ) { q_direction->band_data[0].energy_ratio_index[0] = (UWord16) L_add( L_shl( q_direction->band_data[0].energy_ratio_index[0], 1 ), bitstream[( *index )--] ); + move16(); } *diffuseness_index_max_ec_frame = 5; move16(); @@ -2686,12 +2705,12 @@ static Word16 ivas_qmetadata_entropy_decode_diffuseness( return MASA_BITS_ER; } - IF( EQ_32( bitstream[( *index )--], 0 ) ) /* dif_use_raw_coding */ + IF( bitstream[( *index )--] == 0 ) /* dif_use_raw_coding */ { /* Decode with similarity strategy with low band count. On higher band counts, decode with Huffman-coding strategy. */ IF( LT_16( nbands, DIFF_EC_HUFF_BAND_LIMIT ) ) { - IF( NE_32( bitstream[( *index )--], 0 ) ) /* dif_have_unique_value */ + IF( bitstream[( *index )--] ) /* dif_have_unique_value */ { dif_min = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS ); /* dif_unique_value */ @@ -2732,6 +2751,7 @@ static Word16 ivas_qmetadata_entropy_decode_diffuseness( q_direction->band_data[b].energy_ratio_index[0] = ivas_diffuseness_huff_ec_decode_fx( bitstream, index, av ); move16(); dif_min = (UWord16) L_min( dif_min, q_direction->band_data[b].energy_ratio_index[0] ); + move16(); } } } @@ -2745,15 +2765,17 @@ static Word16 ivas_qmetadata_entropy_decode_diffuseness( q_direction->band_data[b].energy_ratio_index[0] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS ); move16(); dif_min = (UWord16) L_min( dif_min, q_direction->band_data[b].energy_ratio_index[0] ); + move16(); } } *diffuseness_index_max_ec_frame = 5; move16(); /* adaptively select the diffuseness_index_max_ec threshold */ - IF( GT_32( dif_min, 5 ) ) + if ( GT_32( dif_min, 5 ) ) { - *diffuseness_index_max_ec_frame = (UWord16) sub( DIRAC_DIFFUSE_LEVELS, 1 ); + *diffuseness_index_max_ec_frame = (UWord16) DIRAC_DIFFUSE_LEVELS - 1; + move16(); } return sub( index_start, *index ); @@ -2990,6 +3012,7 @@ static Word16 ivas_qmetadata_entropy_decode_df_ratio( { // q_direction->band_data[0].energy_ratio_index[0] = ( q_direction->band_data[0].energy_ratio_index[0] << 1 ) + bitstream[( *index )--]; q_direction->band_data[0].energy_ratio_index[0] = (UWord16) L_add( L_shl( q_direction->band_data[0].energy_ratio_index[0], 1 ), bitstream[( *index )--] ); + move16(); } return dfRatio_bits[0]; } @@ -3028,7 +3051,7 @@ static Word16 ivas_qmetadata_entropy_decode_df_ratio( move16(); IF( EQ_16( ec_mode, 1 ) ) { - IF( EQ_32( bitstream[( *index )--], 0 ) ) + if ( bitstream[( *index )--] == 0 ) { dec_mode = 1; /* Switch to one value EC coding */ move16(); @@ -3036,9 +3059,9 @@ static Word16 ivas_qmetadata_entropy_decode_df_ratio( } ELSE IF( EQ_16( ec_mode, 2 ) ) { - IF( EQ_32( bitstream[( *index )--], 0 ) ) + IF( bitstream[( *index )--] == 0 ) { - IF( EQ_32( bitstream[( *index )--], 0 ) ) + IF( bitstream[( *index )--] == 0 ) { dec_mode = 1; /* Switch to one value EC coding */ move16(); @@ -3269,7 +3292,7 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( bands_entropic[b] = 0; move16(); - IF( GT_16( q_direction->not_in_2D, 0 ) ) + IF( q_direction->not_in_2D > 0 ) { decode_fixed_rate_fx( q_direction, bitstream, index, b, nblocks ); } @@ -3302,7 +3325,7 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( /*EC for the low diffuseness*/ /*Elevation only if not 2D */ - IF( GT_16( q_direction->not_in_2D, 0 ) ) + IF( q_direction->not_in_2D > 0 ) { IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { @@ -3334,6 +3357,7 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( ELSE { diff_idx = q_direction->band_data[b].energy_ratio_index_mod[0]; + move16(); } IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) @@ -3346,13 +3370,13 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( /*reorder elevation indexing*/ tmp_index = sub( avg_elevation_index_projected, shr( elev_alph[b], 1 ) ); - IF( LT_16( tmp_index, 0 ) ) + IF( tmp_index < 0 ) { - tmp_index = negate( shl( tmp_index, 1 ) ); + tmp_index = negate( tmp_index * 2 ); } - ELSE IF( GT_16( tmp_index, 0 ) ) + ELSE IF( tmp_index > 0 ) { - tmp_index = sub( shl( tmp_index, 1 ), 1 ); + tmp_index = sub( ( tmp_index * 2 ), 1 ); } avg_elevation_index_projected = tmp_index; move16(); @@ -3429,12 +3453,12 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( tmp_index = ivas_qmetadata_ReorderElevationDecoded( tmp_index, avg_elevation_index_projected, elev_alph[b] ); /*reorder elevation indexing*/ - tmp_index = sub( tmp_index, shr( elev_alph[b], 1 ) ); - IF( LT_16( tmp_index, 0 ) ) + tmp_index = sub( tmp_index, elev_alph[b] / 2 ); + IF( tmp_index < 0 ) { tmp_index = negate( shl( tmp_index, 1 ) ); } - ELSE IF( GT_16( tmp_index, 0 ) ) + ELSE IF( tmp_index > 0 ) { tmp_index = sub( shl( tmp_index, 1 ), 1 ); } @@ -3484,7 +3508,7 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( } ELSE { - azith_alph[b][m] = no_phi_masa[sub( bits_direction_masa[diff_idx], 1 )][extract_l( L_shr( L_add( q_direction->band_data[b].elevation_index[m], 1 ), 1 ) )]; + azith_alph[b][m] = no_phi_masa[sub( bits_direction_masa[diff_idx], 1 )][add( q_direction->band_data[b].elevation_index[m], 1 ) / 2]; move16(); } @@ -3547,7 +3571,8 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( { use_adapt_avg = bitstream[*index]; move16(); - ( *index )--; + ( *index ) = sub( *index, 1 ); + move16(); } avg_azimuth_index_projected = ivas_dirac_project_azimuth_index( avg_azimuth_index, avg_azimuth_alphabet, azith_alph[b][m] ); q_direction->band_data[b].azimuth_index[m] = ivas_qmetadata_DecodeExtendedGR( bitstream, index, azith_alph[b][m], gr_param_azith ); @@ -3565,6 +3590,8 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( q_direction->band_data[b].azimuth_fx[m] = deindex_azimuth_fx( q_direction->band_data[b].azimuth_index[m], q_direction->band_data[b].bits_sph_idx[m], q_direction->band_data[b].elevation_index[m], 0, q_direction->cfg.mc_ls_setup ); move32(); } + + test(); IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) && GT_16( nblocks, 1 ) ) { IF( LT_16( idx, MASA_LIMIT_IDX_AVG_AZI ) ) @@ -3577,7 +3604,7 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( { IF( EQ_16( use_adapt_avg, 1 ) ) { - IF( EQ_16( m, 0 ) ) + IF( m == 0 ) { FOR( Word16 l = 0; l < 3; l++ ) { @@ -3593,7 +3620,7 @@ static Word16 ivas_qmetadata_entropy_decode_dir_fx( avg_azimuth_index = quantize_phi_fx( L_add( avg_azimuth_fx, DEGREE_180_Q_22 ), 0, &avg_azimuth_fx, avg_azimuth_alphabet ); } } - idx++; + idx = add( idx, 1 ); } } } @@ -4070,7 +4097,7 @@ static Word16 ivas_qmetadata_raw_decode_dir_fx( FOR( b = start_band; b < nbands; b++ ) { - IF( GT_16( q_direction->not_in_2D, 0 ) ) + IF( q_direction->not_in_2D > 0 ) { decode_fixed_rate_fx( q_direction, bitstream, index, b, nblocks ); } @@ -4093,7 +4120,7 @@ static Word16 ivas_qmetadata_raw_decode_dir_fx( move32(); q_direction->band_data[b].elevation_index[m] = 0; move16(); - azith_alph = no_phi_masa[sub( bits_direction_masa[diff_idx], 1 )][0]; + azith_alph = no_phi_masa[bits_direction_masa[diff_idx] - 1][0]; move16(); q_direction->band_data[b].azimuth_index[m] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, azith_alph ); move16(); @@ -4255,10 +4282,13 @@ Word16 ivas_qmetadata_DecodeExtendedGR( { msb = 0; move16(); - WHILE( LT_16( msb, sub( msb_size, 1 ) ) && NE_32( bitstream[*index], 0 ) ) + test(); + WHILE( LT_16( msb, sub( msb_size, 1 ) ) && bitstream[*index] ) { - msb++; - ( *index )--; + test(); + msb = add( msb, 1 ); + ( *index ) = sub( ( *index ), 1 ); + move16(); } IF( EQ_16( msb, sub( msb_size, 1 ) ) ) @@ -4267,7 +4297,8 @@ Word16 ivas_qmetadata_DecodeExtendedGR( } ELSE { - ( *index )--; + ( *index ) = sub( ( *index ), 1 ); + move16(); lsb = 0; move16(); FOR( i = 0; i < gr_param; i++ ) @@ -4348,7 +4379,7 @@ static Word16 ivas_qmetadata_ReorderElevationDecoded( dist_reorder = ivas_qmetadata_dereorder_generic( elev_dist ); elev_index_reorder = add( elev_avg, dist_reorder ); - IF( LT_16( elev_index_reorder, 0 ) ) + IF( elev_index_reorder < 0 ) { elev_index_reorder = add( elev_index_reorder, elev_alph ); } @@ -4428,7 +4459,7 @@ static Word16 read_directions_fx( allowed_bits = extract_l( L_add( allowed_bits, q_direction->band_data[j].bits_sph_idx[k] ) ); } - last_j = sub( j, (Word16) EQ_16( allowed_bits, 0 ) ); + last_j = sub( j, (Word16) ( allowed_bits == 0 ) ); FOR( j = 0; j < last_j; j++ ) { @@ -4464,7 +4495,7 @@ static Word16 read_directions_fx( { byteBuffer = 0; move16(); - IF( LE_16( use_vq, 1 ) ) + if ( LE_16( use_vq, 1 ) ) { byteBuffer = 1; move16(); @@ -4489,12 +4520,12 @@ static Word16 read_directions_fx( { IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { - q_direction->band_data[i].elevation_m_alphabet[k] = no_theta_masa[sub( bits_dir0[k], 3 )]; + q_direction->band_data[i].elevation_m_alphabet[k] = no_theta_masa[bits_dir0[k] - 3]; move16(); } ELSE { - q_direction->band_data[i].elevation_m_alphabet[k] = sub( shl( no_theta_masa[sub( bits_dir0[k], 3 )], 1 ), 1 ); + q_direction->band_data[i].elevation_m_alphabet[k] = shl( no_theta_masa[bits_dir0[k] - 3], 1 ) - 1; move16(); } } @@ -4505,7 +4536,7 @@ static Word16 read_directions_fx( } } - IF( GT_16( allowed_bits, 0 ) ) + IF( allowed_bits > 0 ) { IF( EQ_32( byteBuffer, 1 ) ) { @@ -4574,13 +4605,13 @@ static Word16 read_directions_fx( move16(); allowed_bits = sum16_fx( bits_dir0, q_direction->cfg.nblocks ); test(); - IF( GT_16( allowed_bits, 0 ) && EQ_16( masa_subframes, 1 ) ) + IF( allowed_bits > 0 && EQ_16( masa_subframes, 1 ) ) { nbits = add( nbits, decode_fixed_rate_fx( q_direction, bitstream, &bit_pos, i, masa_subframes ) ); } ELSE { - IF( GT_16( allowed_bits, 0 ) ) + IF( allowed_bits > 0 ) { use_vq = 0; move16(); @@ -4612,7 +4643,7 @@ static Word16 read_directions_fx( move16(); } - IF( GT_16( allowed_bits, 0 ) ) + IF( allowed_bits > 0 ) { test(); IF( EQ_32( byteBuffer, 1 ) || LE_16( use_vq, 1 ) ) @@ -4920,7 +4951,7 @@ static Word16 decode_azimuth_fx( { IF( LT_32( q_direction->band_data[idx_subband].azimuth_index[k], MASA_NO_INDEX ) ) { - j_az++; + j_az = add( j_az, 1 ); } ELSE { @@ -4929,19 +4960,19 @@ static Word16 decode_azimuth_fx( } } - IF( EQ_16( j_az, 0 ) ) + IF( !j_az ) { return nbits; } - IF( EQ_32( byteBuffer, 0 ) ) + IF( !byteBuffer ) { /* use context */ use_context = 0; move16(); FOR( k = 0; k < masa_subframes; k++ ) { - IF( LE_32( q_direction->band_data[idx_subband].bits_sph_idx[k], 1 ) ) + if ( LE_32( q_direction->band_data[idx_subband].bits_sph_idx[k], 1 ) ) { use_context = 1; move16(); @@ -4952,7 +4983,7 @@ static Word16 decode_azimuth_fx( { FOR( k = 0; k < masa_subframes; k++ ) { - IF( EQ_32( q_direction->band_data[idx_subband].bits_sph_idx[k], 0 ) ) + IF( q_direction->band_data[idx_subband].bits_sph_idx[k] == 0 ) { q_direction->band_data[idx_subband].azimuth_index[k] = 0; move16(); @@ -4968,7 +4999,7 @@ static Word16 decode_azimuth_fx( q_direction->band_data[idx_subband].azimuth_index[k] = byteBuffer; move16(); - q_direction->band_data[idx_subband].azimuth_fx[k] = L_shl( q_direction->band_data[idx_subband].azimuth_index[k] * ( -180 ), Q22 ); + q_direction->band_data[idx_subband].azimuth_fx[k] = L_shl( L_mult0( q_direction->band_data[idx_subband].azimuth_index[k], -180 ), Q22 ); move32(); } ELSE @@ -4985,18 +5016,20 @@ static Word16 decode_azimuth_fx( ELSE { /* read bit to check if min removed encoding */ - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; move16(); - IF( EQ_32( byteBuffer, 0 ) ) /* regular GR coding5 */ + bit_pos = sub( bit_pos, 1 ); + IF( byteBuffer == 0 ) /* regular GR coding5 */ { /* read GR_order */ - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; move16(); + bit_pos = sub( bit_pos, 1 ); nbits = add( nbits, 1 ); FOR( k = 0; k < masa_subframes; k++ ) { - IF( GT_32( q_direction->band_data[idx_subband].bits_sph_idx[k], 0 ) ) + IF( q_direction->band_data[idx_subband].bits_sph_idx[k] > 0 ) { IF( GT_16( no_phi_masa[L_sub( q_direction->band_data[idx_subband].bits_sph_idx[k], 1 )][q_direction->band_data[idx_subband].elevation_index[k]], 1 ) ) { @@ -5026,19 +5059,20 @@ static Word16 decode_azimuth_fx( { /* min removed GR coding */ /* read GR_order */ - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; move16(); + bit_pos = sub( bit_pos, 1 ); /* read min index value */ maximum_s( q_direction->band_data[idx_subband].azimuth_m_alphabet, masa_subframes, &max_val ); min_idx = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, max_val, MASA_GR_ORD_AZ ); FOR( k = 0; k < masa_subframes; k++ ) { - IF( GT_32( q_direction->band_data[idx_subband].bits_sph_idx[k], 0 ) ) + IF( q_direction->band_data[idx_subband].bits_sph_idx[k] > 0 ) { - IF( GT_16( no_phi_masa[sub( q_direction->band_data[idx_subband].bits_sph_idx[k], 1 )][q_direction->band_data[idx_subband].elevation_index[k]], 1 ) ) + IF( GT_16( no_phi_masa[q_direction->band_data[idx_subband].bits_sph_idx[k] - 1][q_direction->band_data[idx_subband].elevation_index[k]], 1 ) ) { - q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], extract_l( L_sub( L_sub( MASA_GR_ORD_AZ, 1 ), byteBuffer ) ) ); + q_direction->band_data[idx_subband].azimuth_index[k] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, q_direction->band_data[idx_subband].azimuth_m_alphabet[k], extract_l( L_sub( MASA_GR_ORD_AZ - 1, byteBuffer ) ) ); move16(); q_direction->band_data[idx_subband].azimuth_index[k] = (UWord16) L_add( q_direction->band_data[idx_subband].azimuth_index[k], min_idx ); move16(); @@ -5260,7 +5294,7 @@ static Word16 decode_elevation_fx( q_direction->band_data[j].elevation_fx[k] = 0; move32(); - IF( GT_32( q_direction->band_data[j].bits_sph_idx[k], 0 ) ) + IF( q_direction->band_data[j].bits_sph_idx[k] > 0 ) { IF( LE_32( q_direction->band_data[j].bits_sph_idx[k], 2 ) ) { @@ -5276,19 +5310,19 @@ static Word16 decode_elevation_fx( { IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { - q_direction->band_data[j].elevation_m_alphabet[k] = no_theta_masa[sub( q_direction->band_data[j].bits_sph_idx[k], 3 )]; + q_direction->band_data[j].elevation_m_alphabet[k] = no_theta_masa[q_direction->band_data[j].bits_sph_idx[k] - 3]; move16(); } ELSE { - q_direction->band_data[j].elevation_m_alphabet[k] = sub( shl( no_theta_masa[sub( q_direction->band_data[j].bits_sph_idx[k], 3 )], 1 ), 1 ); + q_direction->band_data[j].elevation_m_alphabet[k] = shl( no_theta_masa[q_direction->band_data[j].bits_sph_idx[k] - 3], 1 ) - 1; move16(); } } } ELSE { - nr_NO_INDEX++; + nr_NO_INDEX = add( nr_NO_INDEX, 1 ); } } @@ -5296,14 +5330,18 @@ static Word16 decode_elevation_fx( { { /* read if same or not */ - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; move16(); + bit_pos = sub( bit_pos, 1 ); IF( EQ_32( byteBuffer, 1 ) ) /* same value */ { /* read value */ - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; + move16(); + bit_pos = sub( bit_pos, 1 ); + byteBuffer = (UWord16) L_add( L_shl( byteBuffer, 1 ), bitstream[bit_pos] ); move16(); - byteBuffer = (UWord16) L_add( L_shl( byteBuffer, 1 ), bitstream[bit_pos--] ); + bit_pos = sub( bit_pos, 1 ); same_idx = byteBuffer; move16(); @@ -5321,7 +5359,8 @@ static Word16 decode_elevation_fx( ELSE { /* not same; decode mean removed GR */ - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; + bit_pos = sub( bit_pos, 1 ); move16(); GR_ord_elevation = extract_l( L_sub( MASA_GR_ORD_EL, byteBuffer ) ); @@ -5518,6 +5557,7 @@ static Word16 decode_fixed_rate_fx( FOR( i = 0; i < q_direction->band_data[b].bits_sph_idx[m]; i++ ) { value = (UWord16) L_add( L_shl( value, 1 ), bitstream[( *pbit_pos )--] ); + move16(); } q_direction->band_data[b].spherical_index[m] = value; @@ -5599,7 +5639,7 @@ static Word16 decode_azimuth2D_fx( bits_dir0 = (Word16 *) q_direction->band_data[j].bits_sph_idx; allowed_bits = sum16_fx( bits_dir0, no_frames ); - IF( GT_16( allowed_bits, 0 ) ) + IF( allowed_bits > 0 ) { use_vq = 0; move16(); @@ -5625,7 +5665,9 @@ static Word16 decode_azimuth2D_fx( set32_fx( q_direction->band_data[j].azimuth_fx, 0, no_frames ); FOR( k = 0; k < s_min( allowed_bits, no_frames ); k++ ) { - q_direction->band_data[j].azimuth_fx[k] = L_shl( -180 * bitstream[bit_pos--], Q22 ); + q_direction->band_data[j].azimuth_fx[k] = L_shl( L_mult0( -180, bitstream[bit_pos] ), Q22 ); + move32(); + bit_pos = sub( bit_pos, 1 ); nbits = add( nbits, 1 ); } } @@ -5642,22 +5684,23 @@ static Word16 decode_azimuth2D_fx( move16(); FOR( i = 0; i < bits_dir0[k]; i++ ) { - Buffer = (UWord16) L_add( L_shl( Buffer, 1 ), bitstream[bit_pos--] ); + Buffer = (UWord16) L_add( L_shl( Buffer, 1 ), bitstream[bit_pos] ); + bit_pos = sub( bit_pos, 1 ); } nbits = add( nbits, bits_dir0[k] ); IF( NE_32( q_direction->cfg.mc_ls_setup, MC_LS_SETUP_INVALID ) ) { - q_direction->band_data[j].azimuth_fx[k] = L_shl( 360, Q22 - bits_dir0[k] ) * Buffer - L_shl( 180, Q22 ); + q_direction->band_data[j].azimuth_fx[k] = L_sub( L_shl( 360, sub( Q22, bits_dir0[k] ) ) * Buffer, L_shl( 180, Q22 ) ); move32(); q_direction->band_data[j].azimuth_fx[k] = companding_azimuth_fx( q_direction->band_data[j].azimuth_fx[k], q_direction->cfg.mc_ls_setup, - ( q_direction->band_data[j].elevation_fx[k] > MC_MASA_THR_ELEVATION * ( 1 << 22 ) ), -1 ); + (Word16) GT_32( q_direction->band_data[j].elevation_fx[k], L_shl( MC_MASA_THR_ELEVATION, 22 ) ), -1 ); move32(); } ELSE { - q_direction->band_data[j].azimuth_fx[k] = L_shl( 360, Q22 - bits_dir0[k] ) * Buffer - L_shl( 180, Q22 ); + q_direction->band_data[j].azimuth_fx[k] = L_shl( 360, sub( Q22, bits_dir0[k] ) ) * Buffer - L_shl( 180, Q22 ); move32(); } } @@ -5840,17 +5883,17 @@ static Word16 read_truncGR_azimuth_fx( { FOR( i = 0; i < min( allowed_bits, no_subframes ); i++ ) { - IF( EQ_32( bitstream[( *pbit_pos )--], 0 ) ) + IF( bitstream[( *pbit_pos )--] == 0 ) { q_direction->band_data[j].azimuth_fx[i] = 0; move32(); } ELSE { - q_direction->band_data[j].azimuth_fx[i] = L_shl( -180, 22 ); + q_direction->band_data[j].azimuth_fx[i] = ( -180 * ONE_IN_Q22 ); move32(); } - nbits++; + nbits = add( nbits, 1 ); } return nbits; @@ -5881,7 +5924,7 @@ static Word16 read_truncGR_azimuth_fx( { q_direction->band_data[j].azimuth_fx[i] = cb_azi_chan_fx[(UWord16) L_shr( (UWord16) L_add( idx, 1 ), 1 )]; move32(); - IF( GT_32( L_and( idx, 1 ), 0 ) ) + IF( L_and( idx, 1 ) > 0 ) { q_direction->band_data[j].azimuth_fx[i] = L_negate( q_direction->band_data[j].azimuth_fx[i] ); move32(); @@ -5997,7 +6040,7 @@ static Word16 read_common_direction_fx( move16(); set_zero_direction_fx( q_direction, j, no_subframes ); - IF( EQ_16( bits_total, 0 ) ) + IF( !bits_total ) { return nbits; } @@ -6021,8 +6064,9 @@ static Word16 read_common_direction_fx( } - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; move16(); + bit_pos = sub( bit_pos, 1 ); bits_el = 1; move16(); nbits = add( nbits, 1 ); @@ -6033,7 +6077,7 @@ static Word16 read_common_direction_fx( move16(); bits_el = add( bits_el, 1 ); nbits = add( nbits, 1 ); - IF( EQ_32( byteBuffer, 0 ) ) + IF( byteBuffer == 0 ) { FOR( i = 0; i < no_subframes; i++ ) { @@ -6047,7 +6091,7 @@ static Word16 read_common_direction_fx( move16(); bits_el = add( bits_el, 1 ); nbits = add( nbits, 1 ); - IF( EQ_32( byteBuffer, 0 ) ) + IF( byteBuffer == 0 ) { FOR( i = 0; i < no_subframes; i++ ) { @@ -6061,14 +6105,14 @@ static Word16 read_common_direction_fx( byteBuffer = bitstream[bit_pos--]; move16(); nbits = add( nbits, 1 ); - IF( EQ_32( byteBuffer, 0 ) ) + IF( byteBuffer == 0 ) { - set32_fx( q_direction->band_data[j].elevation_fx, L_shl( 90, Q22 ), no_subframes ); + set32_fx( q_direction->band_data[j].elevation_fx, ( 90 * ONE_IN_Q22 ), no_subframes ); set32_fx( q_direction->band_data[j].azimuth_fx, 0, no_subframes ); } ELSE { - set32_fx( q_direction->band_data[j].elevation_fx, L_shl( -90, Q22 ), no_subframes ); + set32_fx( q_direction->band_data[j].elevation_fx, ( -90 * ONE_IN_Q22 ), no_subframes ); set32_fx( q_direction->band_data[j].azimuth_fx, 0, no_subframes ); } *pbit_pos = bit_pos; @@ -6086,8 +6130,9 @@ static Word16 read_common_direction_fx( nbits = add( nbits, s_min( no_subframes, bits_el ) ); FOR( i = 0; i < s_min( no_subframes, bits_el ); i++ ) { - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; move16(); + bit_pos = sub( bit_pos, 1 ); /*qdirection->azimuth_index[j][i] = (uint16_t) byteBuffer; */ q_direction->band_data[j].azimuth_fx[i] = azimuth_cb_fx[byteBuffer]; move32(); @@ -6281,8 +6326,9 @@ static void decode_spread_coherence_fx( { IF( EQ_16( hQMetaData->twoDirBands[j], 1 ) ) { - two_dir_band[d++] = j; + two_dir_band[d] = j; move16(); + d = add( d, 1 ); } } } @@ -6321,13 +6367,13 @@ static void decode_spread_coherence_fx( IF( LT_16( coding_subbands, coding_subbands_0 ) ) { - assert( idx_d == 1 ); - dct_coh_fx[i][1] = coherence_cb1_masa_fx[MASA_grouping[two_dir_band[i]] * MASA_NO_CV_COH1 + q_direction->coherence_band_data[i].spread_coherence_dct1_index]; + assert( EQ_16( idx_d, 1 ) ); + dct_coh_fx[i][1] = coherence_cb1_masa_fx[L_add( L_mult0( MASA_grouping[two_dir_band[i]], MASA_NO_CV_COH1 ), q_direction->coherence_band_data[i].spread_coherence_dct1_index )]; move32(); } ELSE { - dct_coh_fx[i][1] = coherence_cb1_masa_fx[MASA_grouping[i] * MASA_NO_CV_COH1 + q_direction->coherence_band_data[i].spread_coherence_dct1_index]; + dct_coh_fx[i][1] = coherence_cb1_masa_fx[L_add( L_mult0( MASA_grouping[i], MASA_NO_CV_COH1 ), q_direction->coherence_band_data[i].spread_coherence_dct1_index )]; move32(); } @@ -6474,6 +6520,7 @@ static ivas_error read_huf( ) { Word16 done = 0, end_pos; + move16(); UWord16 ByteBuffer; Word16 nbits, val; UWord16 i; @@ -6484,11 +6531,11 @@ static ivas_error read_huf( move16(); val = 0; move16(); - WHILE( EQ_16( done, 0 ) && LT_16( nbits, max_len ) ) + WHILE( !done && LT_16( nbits, max_len ) ) { ByteBuffer = bitstream[end_pos--]; move16(); - val = add( shl( val, 1 ), (Word16) L_and( ByteBuffer, 1 ) ); + val = add( shl( val, 1 ), ByteBuffer & 1 ); nbits = add( nbits, 1 ); FOR( i = 0; i < len; i++ ) { @@ -6574,8 +6621,9 @@ static Word16 read_GR_min_removed_data( move16(); /* read GR order */ - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; move16(); + bit_pos = sub( bit_pos, 1 ); nbits = 1; move16(); @@ -6731,6 +6779,7 @@ static Word16 decode_fixed_rate_composed_index_coherence_fx( FOR( j = 0; j < half_no_bands; j++ ) { no_cb *= no_cv_vec[j]; + move16(); } no_bits_vec = (Word16) ceil_log_2( no_cb ); no_cb = 1; @@ -6738,6 +6787,7 @@ static Word16 decode_fixed_rate_composed_index_coherence_fx( FOR( j = half_no_bands; j < no_bands; j++ ) { no_cb *= no_cv_vec[j]; + move16(); } no_bits_vec1 = (Word16) ceil_log_2( no_cb ); } @@ -6748,12 +6798,13 @@ static Word16 decode_fixed_rate_composed_index_coherence_fx( FOR( j = 0; j < no_bands; j++ ) { no_cb *= no_cv_vec[j]; + move16(); } no_bits_vec = (Word16) ceil_log_2( no_cb ); no_bits_vec1 = 0; move16(); } - IF( GT_16( no_bits_vec1, 0 ) ) + IF( no_bits_vec1 > 0 ) { idx_fr = 0; move64(); @@ -6951,10 +7002,14 @@ static Word16 read_coherence_data_hr_512_fx( move16(); FOR( i = 0; i < nbits_coh; i++ ) { - min_index = add( shl( min_index, 1 ), bitstream[( *p_bit_pos )--] ); + min_index = add( shl( min_index, 1 ), bitstream[( *p_bit_pos )] ); + ( *p_bit_pos ) = sub( ( *p_bit_pos ), 1 ); + move16(); } /* read GR param */ - GR_param = bitstream[( *p_bit_pos )--]; + GR_param = bitstream[( *p_bit_pos )]; + move16(); + ( *p_bit_pos ) = sub( ( *p_bit_pos ), 1 ); move16(); FOR( j = 0; j < nbands; j++ ) { @@ -6969,6 +7024,7 @@ static Word16 read_coherence_data_hr_512_fx( } decoded_idx_fx = L_shl( decoded_idx, 9 ); hQMetaData->q_direction[idx_dir].coherence_band_data[j].spread_coherence[k] = (UWord8) L_add( Mpy_32_32( decoded_idx_fx, delta_fx ), L_shr( delta_fx, 23 ) ); + move16(); } } ELSE @@ -6978,17 +7034,22 @@ static Word16 read_coherence_data_hr_512_fx( move16(); FOR( i = 0; i < nbits_coh; i++ ) { - min_index = add( shl( min_index, 1 ), bitstream[( *p_bit_pos )--] ); + min_index = add( shl( min_index, 1 ), bitstream[( *p_bit_pos )] ); + ( *p_bit_pos ) = sub( ( *p_bit_pos ), 1 ); + move16(); } /* read GR param */ - GR_param = bitstream[( *p_bit_pos )--]; + GR_param = bitstream[( *p_bit_pos )]; + move16(); + ( *p_bit_pos ) = sub( ( *p_bit_pos ), 1 ); move16(); FOR( j = 0; j < nbands; j++ ) { decoded_idx = add( ivas_qmetadata_DecodeExtendedGR( bitstream, p_bit_pos, cb_size - min_index, GR_param ), min_index ); decoded_idx_fx = L_shl( decoded_idx, 9 ); hQMetaData->q_direction[idx_dir].coherence_band_data[j].spread_coherence[k] = (UWord8) L_add( Mpy_32_32( decoded_idx_fx, delta_fx ), L_shr( delta_fx, 23 ) ); + move16(); } } } @@ -7109,7 +7170,7 @@ static Word16 read_coherence_data_fx( coding_subbands = hQMetaData->q_direction[idx_dir].cfg.nbands; move16(); - extra_cv = (Word16) ( coding_subbands / MASA_FACTOR_CV_COH ); + extra_cv = idiv1616( coding_subbands, MASA_FACTOR_CV_COH ); move16(); q_direction = &( hQMetaData->q_direction[idx_dir] ); bit_pos = *p_bit_pos; @@ -7142,8 +7203,9 @@ static Word16 read_coherence_data_fx( return 0; } - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; move16(); + bit_pos = sub( bit_pos, 1 ); nbits = add( nbits, 1 ); IF( L_and( byteBuffer, 1 ) ) @@ -7163,10 +7225,12 @@ static Word16 read_coherence_data_fx( q_res = add( sub( 15, q_den ), q_num ); res = L_shl( res, sub( 16, q_res ) ); q_direction->coherence_band_data[j].spread_coherence[0] = (UWord8) ( round_fx( res ) ); + move16(); } ELSE { q_direction->coherence_band_data[j].spread_coherence[0] = 0; + move16(); } } } @@ -7188,10 +7252,12 @@ static Word16 read_coherence_data_fx( q_res = add( sub( 15, q_den ), q_num ); res = L_shl( res, sub( 16, q_res ) ); q_direction->coherence_band_data[j].spread_coherence[0] = (UWord8) ( round_fx( res ) ); + move16(); } ELSE { q_direction->coherence_band_data[j].spread_coherence[0] = 0; + move16(); } } } @@ -7219,7 +7285,7 @@ static Word16 read_coherence_data_fx( no_cb = 1; move64(); - FOR( j = 0; j < coding_subbands / 2; j++ ) + FOR( j = 0; j < shr( coding_subbands, 1 ); j++ ) { no_cb *= no_cv_vec[j]; move64(); @@ -7793,7 +7859,7 @@ static Word16 read_surround_coherence( error_ratio_surr = L_sub( ONE_IN_Q30, q_direction[0].band_data[j].energy_ratio_fx[0] ); } - IF( LE_32( error_ratio_surr, 0 ) ) + IF( error_ratio_surr <= 0 ) { error_ratio_surr = 0; move32(); @@ -7818,9 +7884,10 @@ static Word16 read_surround_coherence( { FOR( k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) { - IF( hQMetaData->surcoh_band_data != NULL ) + if ( hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[j].surround_coherence[k] = 0; + move16(); } } } @@ -7829,7 +7896,8 @@ static Word16 read_surround_coherence( } /* read how the surround coherence is encoded */ - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; + bit_pos = sub( bit_pos, 1 ); move16(); bits_sur_coherence = add( bits_sur_coherence, 1 ); @@ -7837,8 +7905,8 @@ static Word16 read_surround_coherence( { /* GR decoding */ /* read GR order */ - byteBuffer = bitstream[bit_pos--]; - move16(); + byteBuffer = bitstream[bit_pos]; + bit_pos = sub( bit_pos, 1 ); bits_sur_coherence = add( bits_sur_coherence, 1 ); /* read min index */ @@ -7855,7 +7923,7 @@ static Word16 read_surround_coherence( /* decoding for min removed */ IF( GT_16( no_cv_vec[j], 1 ) ) { - idx_sur_coh[j] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, no_cv_vec[j] - min_index, ( byteBuffer & 1 ) ); + idx_sur_coh[j] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, sub( no_cv_vec[j], min_index ), ( byteBuffer & 1 ) ); move16(); bits_sur_coherence = add( bits_sur_coherence, sub( bits_GR, bit_pos ) ); } @@ -7880,6 +7948,7 @@ static Word16 read_surround_coherence( } hQMetaData->surcoh_band_data[j].surround_coherence[0] = sur_coherence_cb_masa[add( shl( idx_cb_sur_coh_masa[idx_ER[j]], 3 ), hQMetaData->surcoh_band_data[j].sur_coherence_index )]; + move16(); } } ELSE @@ -7902,10 +7971,12 @@ static Word16 read_surround_coherence( IF( GT_16( no_cv_vec[j], 1 ) ) { hQMetaData->surcoh_band_data[j].surround_coherence[0] = sur_coherence_cb_masa[add( shl( idx_cb_sur_coh_masa[idx_ER[j]], 3 ), hQMetaData->surcoh_band_data[j].sur_coherence_index )]; + move16(); } ELSE { hQMetaData->surcoh_band_data[j].surround_coherence[0] = 0; + move16(); } } } @@ -7915,6 +7986,7 @@ static Word16 read_surround_coherence( FOR( k = 1; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) { hQMetaData->surcoh_band_data[j].surround_coherence[k] = hQMetaData->surcoh_band_data[j].surround_coherence[0]; + move16(); } } @@ -8120,11 +8192,14 @@ static Word16 read_surround_coherence_hr_fx( // q_direction = hQMetaData->q_direction; bits_sur_coherence = 0; + move16(); bit_pos = *p_bit_pos; + move16(); FOR( sf = 0; sf < hQMetaData->q_direction[0].cfg.nblocks; sf++ ) { d = 0; + move16(); FOR( j = 0; j < coding_subbands; j++ ) { @@ -8145,8 +8220,11 @@ static Word16 read_surround_coherence_hr_fx( IF( LE_64( error_ratio_surr_fx, ( 461168601842 ) ) ) // 1e-7 in Q62 { error_ratio_surr_fx = 0; + move64(); no_cv_vec[j] = 1; + move16(); idx_ER[j] = 0; + move16(); } ELSE { @@ -8165,6 +8243,7 @@ static Word16 read_surround_coherence_hr_fx( IF( hQMetaData->surcoh_band_data != NULL ) { hQMetaData->surcoh_band_data[j].surround_coherence[k] = 0; + move16(); } } } @@ -8172,14 +8251,18 @@ static Word16 read_surround_coherence_hr_fx( ELSE { /* read how the surround coherence is encoded */ - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; + move16(); + bit_pos = sub( bit_pos, 1 ); bits_sur_coherence = add( bits_sur_coherence, 1 ); IF( byteBuffer & 1 ) { /* GR decoding */ /* read GR order */ - byteBuffer = bitstream[bit_pos--]; + byteBuffer = bitstream[bit_pos]; + move16(); + bit_pos = sub( bit_pos, 1 ); bits_sur_coherence = add( bits_sur_coherence, 1 ); /* read min index */ @@ -8191,15 +8274,18 @@ static Word16 read_surround_coherence_hr_fx( FOR( j = 0; j < coding_subbands; j++ ) { bits_GR = bit_pos; + move16(); /* decoding for min removed */ IF( GT_16( no_cv_vec[j], 1 ) ) { - idx_sur_coh[j] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, no_cv_vec[j] - min_index, ( byteBuffer & 1 ) ); + idx_sur_coh[j] = ivas_qmetadata_DecodeExtendedGR( bitstream, &bit_pos, sub( no_cv_vec[j], min_index ), ( byteBuffer & 1 ) ); + move16(); bits_sur_coherence = add( bits_sur_coherence, sub( bits_GR, bit_pos ) ); } ELSE { idx_sur_coh[j] = 0; + move16(); } } @@ -8208,12 +8294,16 @@ static Word16 read_surround_coherence_hr_fx( IF( GT_16( no_cv_vec[j], 1 ) ) { hQMetaData->surcoh_band_data[j].sur_coherence_index = (UWord16) L_add( (Word32) idx_sur_coh[j], L_deposit_l( min_index ) ); - hQMetaData->surcoh_band_data[j].surround_coherence[sf] = sur_coherence_cb_masa[idx_cb_sur_coh_masa[idx_ER[j]] * MASA_MAX_NO_CV_SUR_COH + hQMetaData->surcoh_band_data[j].sur_coherence_index]; + move16(); + hQMetaData->surcoh_band_data[j].surround_coherence[sf] = sur_coherence_cb_masa[L_add( L_mult0( idx_cb_sur_coh_masa[idx_ER[j]], MASA_MAX_NO_CV_SUR_COH ), hQMetaData->surcoh_band_data[j].sur_coherence_index )]; + move16(); } ELSE { hQMetaData->surcoh_band_data[j].sur_coherence_index = idx_sur_coh[j]; + move16(); hQMetaData->surcoh_band_data[j].surround_coherence[sf] = 0; + move16(); } } } @@ -8228,6 +8318,7 @@ static Word16 read_surround_coherence_hr_fx( FOR( j = 0; j < coding_subbands; j++ ) { hQMetaData->surcoh_band_data[j].sur_coherence_index = sur_coh_temp_index[j]; + move16(); } /* deindex surround coherence */ @@ -8235,11 +8326,13 @@ static Word16 read_surround_coherence_hr_fx( { IF( GT_16( no_cv_vec[j], 1 ) ) { - hQMetaData->surcoh_band_data[j].surround_coherence[sf] = sur_coherence_cb_masa[idx_cb_sur_coh_masa[idx_ER[j]] * MASA_MAX_NO_CV_SUR_COH + hQMetaData->surcoh_band_data[j].sur_coherence_index]; + hQMetaData->surcoh_band_data[j].surround_coherence[sf] = sur_coherence_cb_masa[L_add( L_mult0( idx_cb_sur_coh_masa[idx_ER[j]], MASA_MAX_NO_CV_SUR_COH ), hQMetaData->surcoh_band_data[j].sur_coherence_index )]; + move16(); } ELSE { hQMetaData->surcoh_band_data[j].surround_coherence[sf] = 0; + move16(); } } } @@ -8249,6 +8342,7 @@ static Word16 read_surround_coherence_hr_fx( /* Replace return value with the actual read bits. bits_sur_coherence might show wrong count at this point. */ bits_sur_coherence = sub( *p_bit_pos, bit_pos ); *p_bit_pos = bit_pos; + move16(); return bits_sur_coherence; } @@ -8273,6 +8367,7 @@ static void decode_combined_index_fx( UWord64 base[MASA_MAXIMUM_CODING_SUBBANDS + 1]; base[0] = 1; + move64(); FOR( i = 1; i < len; i++ ) { base[i] = base[i - 1] * no_cv_vec[i - 1]; @@ -8285,6 +8380,7 @@ static void decode_combined_index_fx( } index[0] = (UWord16) comb_index; + move16(); return; } @@ -8339,17 +8435,17 @@ static void read_stream_dct_coeffs_omasa_fx( move16(); sign = 1; move16(); - IF( EQ_16( first_line, 0 ) ) + IF( !first_line ) { /* read sign */ sign = bit_stream[( *index )--]; move16(); - IF( EQ_16( sign, 0 ) ) + IF( !sign ) { sign = -1; move16(); } - nbits++; + nbits = add( nbits, 1 ); } set16_fx( q_idx, 0, len_stream ); @@ -8362,7 +8458,7 @@ static void read_stream_dct_coeffs_omasa_fx( q_idx[0] = i_mult( q_idx[0], sign ); move16(); - IF( NE_16( q_idx[0], 0 ) ) + IF( q_idx[0] != 0 ) { IF( GE_16( len_stream, 8 ) ) { @@ -8404,7 +8500,9 @@ static void read_stream_dct_coeffs_omasa_fx( ELSE { /* read GR order (only one) */ - GR1 = bit_stream[( *index )--]; + GR1 = bit_stream[( *index )]; + move16(); + ( *index ) = sub( ( *index ), 1 ); move16(); FOR( i = 1; i < len_stream; i++ ) { @@ -8419,7 +8517,7 @@ static void read_stream_dct_coeffs_omasa_fx( move32(); FOR( i = 1; i < len_stream; i++ ) { - IF( EQ_16( s_and( q_idx[i], 1 ), 0 ) ) + IF( s_and( q_idx[i], 1 ) == 0 ) { q_dct_data_fx[i] = L_shl( Mpy_32_16_1( step, negate( shl( q_idx[i], 6 ) ) ), 2 ); move32(); @@ -8567,7 +8665,7 @@ void ivas_omasa_decode_masa_to_total_fx( set16_fx( q_idx, 0, i_mult( nbands, nblocks ) ); FOR( i = 0; i < n_streams; i++ ) { - read_stream_dct_coeffs_omasa_fx( &q_idx[i * len_stream], &q_dct_data_fx[i * len_stream], len_stream, bit_stream, index, i == 0 ); + read_stream_dct_coeffs_omasa_fx( &q_idx[L_mult0( i, len_stream )], &q_dct_data_fx[L_mult0( i, len_stream )], len_stream, bit_stream, index, i == 0 ); } /* inverse DCT2 transform */ @@ -8611,7 +8709,7 @@ void ivas_omasa_decode_masa_to_total_fx( move32(); masa_to_total_energy_ratio_fx[i][j] = L_min( ONE_IN_Q30, masa_to_total_energy_ratio_fx[i][j] ); move32(); - k++; + k = add( k, 1 ); } } diff --git a/lib_dec/ivas_qspherical_dec.c b/lib_dec/ivas_qspherical_dec.c index 332f4952fb520d078db2aa32710258ba7bcf2d4f..40fdbdc5e110950185f986581d140ea2319d10fc 100644 --- a/lib_dec/ivas_qspherical_dec.c +++ b/lib_dec/ivas_qspherical_dec.c @@ -119,30 +119,35 @@ Word32 deindex_elevation_fx( theta_hat_fx = L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[sub( no_bits, 3 )] ), sub( 31, q_id_th ) ); IF( GT_32( theta_hat_fx, L_shl( 90, Q22 ) ) ) { - theta_hat_fx = L_shl( 90, Q22 ); + theta_hat_fx = 90 * ONE_IN_Q22; + move32(); } } ELSE { - IF( EQ_32( L_and( *id_th, 1 ), 0 ) ) + IF( L_and( *id_th, 1 ) == 0 ) { /* theta is negative */ *id_th = (UWord16) L_shr( *id_th, 1 ); + move16(); id_th_fx = L_shr( id_th_fx, 1 ); theta_hat_fx = L_negate( L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[sub( no_bits, 3 )] ), sub( 31, q_id_th ) ) ); - IF( LT_32( theta_hat_fx, L_shl( -90, Q22 ) ) ) + IF( LT_32( theta_hat_fx, -90 * ONE_IN_Q22 ) ) { - theta_hat_fx = L_shl( -90, Q22 ); + theta_hat_fx = -90 * ONE_IN_Q22; + move32(); } } ELSE { *id_th = (UWord16) L_shr( L_add( *id_th, 1 ), 1 ); + move16(); id_th_fx = L_shr( L_add( id_th_fx, L_shl( 1, q_id_th ) ), 1 ); theta_hat_fx = L_shl( Mpy_32_32( id_th_fx, delta_theta_masa_fx[sub( no_bits, 3 )] ), sub( 31, q_id_th ) ); - IF( GT_32( theta_hat_fx, L_shl( 90, Q22 ) ) ) + IF( GT_32( theta_hat_fx, 90 * ONE_IN_Q22 ) ) { - theta_hat_fx = L_shl( 90, Q22 ); + theta_hat_fx = 90 * ONE_IN_Q22; + move32(); } } } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 9da244a346174559b4978b8a58fa2843dfcb7463..5dda982b86d99a50798f59bda2126aceaba47a6b 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -55,24 +55,33 @@ void ivas_sba_set_cna_cng_flag( ) { Word16 n, cpe_id; - - IF( st_ivas->ivas_format == SBA_FORMAT && st_ivas->nchan_transport == 1 ) + test(); + test(); + test(); + test(); + test(); + test(); + IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && EQ_16( st_ivas->nchan_transport, 1 ) ) { /* skip as done in init function */ /* st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 0; */ /* st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 0; */ } - ELSE IF( st_ivas->nchan_transport == 1 && ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) || ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) ) + ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && ( ( EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) && EQ_16( st_ivas->hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) || ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) ) ) { st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag = 1; + move16(); st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag = 1; + move16(); } - ELSE IF( st_ivas->nchan_transport == 2 ) + ELSE IF( EQ_16( st_ivas->nchan_transport, 2 ) ) { FOR( n = 0; n < CPE_CHANNELS; n++ ) { st_ivas->hCPE[0]->hCoreCoder[n]->cna_dirac_flag = 0; + move16(); st_ivas->hCPE[0]->hCoreCoder[n]->cng_sba_flag = 1; + move16(); } } ELSE @@ -82,7 +91,9 @@ void ivas_sba_set_cna_cng_flag( FOR( n = 0; n < CPE_CHANNELS; n++ ) { st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cna_dirac_flag = 0; + move16(); st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 0; + move16(); } } } @@ -746,30 +757,33 @@ ivas_error ivas_sba_dec_reconfigure( *-------------------------------------------------------------------*/ ivas_error ivas_sba_dec_reconfigure_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesFlushed, /* o : number of samples flushed */ - int16_t *data /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + UWord16 *nSamplesFlushed, /* o : number of samples flushed */ + Word16 *data /* o : output synthesis signal */ ) { - int16_t nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; + Word16 nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; AUDIO_CONFIG intern_config_old; - int16_t numCldfbAnalyses_old, numCldfbSyntheses_old; - int16_t sba_dirac_stereo_flag_old; - int32_t ivas_total_brate; - int32_t last_ivas_total_brate; - int16_t num_channels, num_md_sub_frames; - int16_t nchan_out_buff, nchan_out_buff_old; - int16_t sba_analysis_order_old_flush; + Word16 numCldfbAnalyses_old, numCldfbSyntheses_old; + Word16 sba_dirac_stereo_flag_old; + Word32 ivas_total_brate; + Word32 last_ivas_total_brate; + Word16 num_channels, num_md_sub_frames; + Word16 nchan_out_buff, nchan_out_buff_old; + Word16 sba_analysis_order_old_flush; DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; ISM_MODE ism_mode_old; - int16_t granularity_new; + Word16 granularity_new; ism_mode_old = st_ivas->ism_mode; hDecoderConfig = st_ivas->hDecoderConfig; ivas_total_brate = hDecoderConfig->ivas_total_brate; + move32(); last_ivas_total_brate = st_ivas->last_active_ivas_total_brate; + move32(); sba_analysis_order_old_flush = st_ivas->sba_analysis_order; + move16(); /*-----------------------------------------------------------------* * Set SBA high-level parameters @@ -781,157 +795,157 @@ ivas_error ivas_sba_dec_reconfigure_fx( ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); nchan_hp20_old = getNumChanSynthesis( st_ivas ); - if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - if ( ivas_total_brate >= IVAS_256k ) + IF( GE_32( ivas_total_brate, IVAS_256k ) ) { st_ivas->ism_mode = ISM_SBA_MODE_DISC; + move16(); } - else + ELSE { st_ivas->ism_mode = ISM_MODE_NONE; + move16(); } } - else + ELSE { st_ivas->ism_mode = ISM_MODE_NONE; + move16(); } nSCE_old = st_ivas->nSCE; + move16(); nCPE_old = st_ivas->nCPE; + move16(); nchan_transport_old = st_ivas->nchan_transport; + move16(); sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; + move16(); st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order ); *nSamplesFlushed = 0; + move16(); granularity_new = st_ivas->hTcBuffer->n_samples_granularity; + move16(); /* we may need to flush only for binaural and OSBA and TSM */ - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + test(); + test(); + test(); + IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) { RENDERER_TYPE renderer_type_new; - int16_t sba_order_internal; + Word16 sba_order_internal; - sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); + sba_order_internal = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); /* get new renderer type */ /* copy the logic from ivas_renderer_select(), because calling this function has too many side effects that would affect the flushing */ - if ( ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) <= 2 ) + IF( LE_16( ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ), 2 ) ) { - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL ) + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) { renderer_type_new = RENDERER_BINAURAL_PARAMETRIC; + move16(); } - else + ELSE { renderer_type_new = RENDERER_BINAURAL_PARAMETRIC_ROOM; + move16(); } } - else + ELSE { - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + test(); + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { renderer_type_new = RENDERER_BINAURAL_FASTCONV; + move16(); } - else + ELSE { renderer_type_new = RENDERER_BINAURAL_FASTCONV_ROOM; + move16(); } } /* determine new granularity */ granularity_new = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + move16(); /* this will change anyway only with binaural */ - if ( renderer_type_new == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + test(); + IF( EQ_16( renderer_type_new, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - granularity_new *= JBM_CLDFB_SLOTS_IN_SUBFRAME; + granularity_new = i_mult( granularity_new, JBM_CLDFB_SLOTS_IN_SUBFRAME ); } /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ - if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) + IF( LT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { /* write back info for correct rendering of the flushable samples */ st_ivas->sba_analysis_order = sba_analysis_order_old_flush; + move16(); st_ivas->hDecoderConfig->ivas_total_brate = last_ivas_total_brate; + move32(); -#ifdef IVAS_FLOAT_FIXED -#if 1 /*Float to fixed conversion*/ - if ( st_ivas->hIsmRendererData ) - { - FOR( Word16 ind1 = 0; ind1 < st_ivas->hIsmRendererData->interpolator_len; ind1++ ) - { - st_ivas->hIsmRendererData->interpolator_fx[ind1] = (Word16) L_min( 32767, floatToFixed( st_ivas->hIsmRendererData->interpolator_fx[ind1], 15 ) ); - } - } - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - if ( st_ivas->hIsmMetaData[ind1] ) - { - st_ivas->hIsmMetaData[ind1]->azimuth_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->azimuth * ( 1 << 22 ) ); - st_ivas->hIsmMetaData[ind1]->elevation_fx = (Word32) ( st_ivas->hIsmMetaData[ind1]->elevation * ( 1 << 22 ) ); - } - } -#endif - if ( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, data ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, data ) ), IVAS_ERR_OK ) ) { return error; } -#if 1 /*Fixed to float */ - FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) - { - if ( st_ivas->hIsmMetaData[ind1] ) - { - st_ivas->hIsmMetaData[ind1]->azimuth = (float) ( st_ivas->hIsmMetaData[ind1]->azimuth_fx ) / (float) ( 1 << 22 ); - st_ivas->hIsmMetaData[ind1]->elevation = (float) ( st_ivas->hIsmMetaData[ind1]->elevation_fx ) / (float) ( 1 << 22 ); - } - } -#endif -#else - if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, data ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif // IVAS_FLOAT_FIXED /* restore correct values for the current frame*/ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order ); + move16(); st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; + move32(); } - else if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity ) + ELSE IF( GT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { - if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } /* make sure the changed number of slots in the last subframe is not lost in the following steps */ - if ( st_ivas->hSpatParamRendCom != NULL ) + IF( st_ivas->hSpatParamRendCom != NULL ) { st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + move32(); } st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + move32(); } } /* save old */ - if ( ism_mode_old != ISM_SBA_MODE_DISC ) + IF( NE_16( ism_mode_old, ISM_SBA_MODE_DISC ) ) { - if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) + test(); + IF( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) { st_ivas->hTcBuffer->num_slots = st_ivas->hSpar->num_slots; + move16(); st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpar->nb_subframes; + move16(); st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpar->slots_rendered; + move16(); st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpar->subframes_rendered; + move16(); mvs2s( st_ivas->hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } - else if ( st_ivas->hSpatParamRendCom != NULL ) + ELSE IF( st_ivas->hSpatParamRendCom != NULL ) { st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; + move16(); st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; + move16(); st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; + move16(); st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; + move16(); mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } } @@ -940,59 +954,67 @@ ivas_error ivas_sba_dec_reconfigure_fx( * Allocate, initialize, and configure SBA handles *-----------------------------------------------------------------*/ - int16_t sba_order_internal; + Word16 sba_order_internal; SPAR_DEC_HANDLE hSpar; hSpar = st_ivas->hSpar; - sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); + sba_order_internal = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); - if ( hSpar != NULL ) + IF( hSpar != NULL ) { - if ( ( hSpar->hPCA != NULL ) && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE ) || ( st_ivas->sba_order != 1 ) ) ) + test(); + test(); + IF( ( hSpar->hPCA != NULL ) && ( NE_32( hDecoderConfig->ivas_total_brate, PCA_BRATE ) || NE_16( st_ivas->sba_order, 1 ) ) ) { free( st_ivas->hSpar->hPCA ); hSpar->hPCA = NULL; } - if ( nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) || ( last_ivas_total_brate >= IVAS_512k && ivas_total_brate < IVAS_512k ) || ( last_ivas_total_brate < IVAS_512k && ivas_total_brate >= IVAS_512k ) ) + test(); + test(); + test(); + test(); + test(); + IF( NE_16( nchan_transport_old, ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) ) || ( GE_32( last_ivas_total_brate, IVAS_512k ) && LT_32( ivas_total_brate, IVAS_512k ) ) || ( LT_32( last_ivas_total_brate, IVAS_512k ) && GE_32( ivas_total_brate, IVAS_512k ) ) ) { ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 ); - if ( ( error = ivas_spar_dec_open_fx( st_ivas, 1 ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_spar_dec_open_fx( st_ivas, 1 ) ), IVAS_ERR_OK ) ) { return error; } } - else if ( last_ivas_total_brate < IVAS_24k4 && ivas_total_brate >= IVAS_24k4 ) + ELSE IF( LT_32( last_ivas_total_brate, IVAS_24k4 ) && GE_32( ivas_total_brate, IVAS_24k4 ) ) { num_channels = st_ivas->hSpar->hMdDec->spar_md_cfg.num_umx_chs; + move16(); ivas_spar_md_dec_matrix_close_fx( st_ivas->hSpar->hMdDec, num_channels ); num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - if ( ( error = ivas_spar_md_dec_matrix_open_fx( st_ivas->hSpar->hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_spar_md_dec_matrix_open_fx( st_ivas->hSpar->hMdDec, num_channels, num_md_sub_frames ) ), IVAS_ERR_OK ) ) { return error; } } - if ( hSpar->hPCA == NULL && st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && st_ivas->sba_order == 1 && st_ivas->ivas_format == SBA_FORMAT ) + test(); + test(); + test(); + IF( hSpar->hPCA == NULL && EQ_32( st_ivas->hDecoderConfig->ivas_total_brate, PCA_BRATE ) && EQ_16( st_ivas->sba_order, 1 ) && EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) { - if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) + IF( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" ); } - // ivas_pca_dec_init( hSpar->hPCA ); -#ifdef IVAS_FLOAT_FIXED ivas_pca_dec_init_fx( hSpar->hPCA ); -#endif } ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format ); } - else + ELSE { - if ( ( error = ivas_spar_dec_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_spar_dec_open_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) ) { return error; } @@ -1000,14 +1022,17 @@ ivas_error ivas_sba_dec_reconfigure_fx( hSpar = st_ivas->hSpar; st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); + move16(); - if ( st_ivas->nchan_transport == 1 ) + IF( EQ_16( st_ivas->nchan_transport, 1 ) ) { st_ivas->element_mode_init = IVAS_SCE; + move16(); } - else + ELSE { st_ivas->element_mode_init = IVAS_CPE_MDCT; + move16(); } /*-----------------------------------------------------------------* @@ -1016,10 +1041,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( /* renderer might have changed */ intern_config_old = st_ivas->intern_config; + move16(); ivas_renderer_select( st_ivas ); /* side effect of the renderer selection can be a changed internal config */ - if ( st_ivas->intern_config != intern_config_old ) + IF( NE_16( st_ivas->intern_config, intern_config_old ) ) { ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); } @@ -1028,47 +1054,44 @@ ivas_error ivas_sba_dec_reconfigure_fx( * Reallocate and initialize binaural rendering handles *--------------------------------------------------------------------*/ - if ( st_ivas->hBinRenderer == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) + test(); + test(); + test(); + test(); + IF( st_ivas->hBinRenderer == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { - /*float2fix block: to be removed*/ - /* if (st_ivas->hIntSetup.ls_azimuth && st_ivas->hIntSetup.ls_azimuth_fx) { - floatToFixed_arrL((float *)st_ivas->hIntSetup.ls_azimuth, (Word32 *)st_ivas->hIntSetup.ls_azimuth_fx, Q22, st_ivas->hIntSetup.nchan_out_woLFE); - } - if (st_ivas->hIntSetup.ls_elevation && st_ivas->hIntSetup.ls_elevation_fx) { - floatToFixed_arrL((float *)st_ivas->hIntSetup.ls_elevation, (Word32 *)st_ivas->hIntSetup.ls_elevation_fx, Q22, st_ivas->hIntSetup.nchan_out_woLFE); - }*/ - /*float2fix block end*/ /* open fastconv binaural renderer */ - if ( ( error = ivas_binRenderer_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_binRenderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } } - else if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) ) + ELSE IF( st_ivas->hBinRenderer != NULL && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { ivas_binRenderer_close_fx( &st_ivas->hBinRenderer ); } - if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->hMonoDmxRenderer == NULL ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && st_ivas->hMonoDmxRenderer == NULL ) { - if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } } - if ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX ) + IF( NE_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); } - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), - st_ivas->ivas_format ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), + st_ivas->ivas_format ) ), + IVAS_ERR_OK ) ) { return error; } - if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) ) ) + IF( ( ( NE_16( st_ivas->renderer_type, RENDERER_DISABLE ) ) && ( NE_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) ) ) || ( ( NE_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) ) && ( NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) && ( NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) ) ) ) { DIRAC_CONFIG_FLAG flag_config; @@ -1078,162 +1101,134 @@ ivas_error ivas_sba_dec_reconfigure_fx( flag_config = DIRAC_RECONFIGURE_MODE; } -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_dirac_dec_config_fx( st_ivas, flag_config ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_dirac_dec_config( st_ivas, flag_config ) ) != IVAS_ERR_OK ) -#endif + IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, flag_config ) ), IVAS_ERR_OK ) ) { return error; } } - else + ELSE { - int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1]; + Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1]; - st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); - if ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) + st_ivas->hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); + move16(); + IF( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ) { st_ivas->hSpar->enc_param_start_band = 0; + move16(); - set_c( (int8_t *) st_ivas->hQMetaData->twoDirBands, (int8_t) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); - st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; + set_c( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); + st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands; + move16(); } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (Word16) ( L_add( st_ivas->hDecoderConfig->output_Fs, 400 ) / CLDFB_BANDWIDTH ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); if ( st_ivas->hDirAC ) { st_ivas->hDirAC->hConfig->enc_param_start_band = st_ivas->hSpar->enc_param_start_band; + move16(); } } - if ( st_ivas->renderer_type == RENDERER_DISABLE ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) ) { -#ifdef IVAS_FLOAT_FIXED ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) ); ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) ); ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) ); vbap_free_data_fx( &( st_ivas->hVBAPdata ) ); -#else - ivas_dirac_rend_close( &( st_ivas->hDirACRend ) ); - ivas_spat_hSpatParamRendCom_close( &( st_ivas->hSpatParamRendCom ) ); - ivas_dirac_dec_close( &( st_ivas->hDirAC ) ); - vbap_free_data( &( st_ivas->hVBAPdata ) ); -#endif } if ( st_ivas->hDirAC != NULL ) { st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band; + move16(); } /*-----------------------------------------------------------------* * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ - if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) + IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + test(); + test(); + IF( EQ_16( ism_mode_old, ISM_MODE_NONE ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - int32_t temp_brate[MAX_SCE]; + Word32 temp_brate[MAX_SCE]; st_ivas->ism_mode = ISM_SBA_MODE_DISC; -#ifdef IVAS_FLOAT_FIXED - IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_ism_metadata_dec_create( st_ivas, st_ivas->nchan_ism, temp_brate ) ) != IVAS_ERR_OK ) -#endif + move16(); + + IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, temp_brate ) ), IVAS_ERR_OK ) ) { return error; } - if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || - st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX || - st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || - st_ivas->renderer_type == RENDERER_OSBA_STEREO || - st_ivas->renderer_type == RENDERER_OSBA_AMBI || - st_ivas->renderer_type == RENDERER_OSBA_LS || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + IF( ( EQ_16( st_ivas->renderer_type, RENDERER_TD_PANNING ) || + EQ_16( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) || + EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) || + EQ_16( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) || + EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || + EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) || + 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_BINAURAL_MIXER_CONV_ROOM ) ) ) { -#ifdef IVAS_FLOAT_FIXED - IF( ( error = ivas_ism_renderer_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#else - if ( ( error = ivas_ism_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ism_renderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } -#endif } - if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { - if ( st_ivas->hMonoDmxRenderer == NULL ) + IF( st_ivas->hMonoDmxRenderer == NULL ) { - if ( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } } } - else + ELSE { ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); } - if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { /* Allocate TD renderer for the objects in DISC mode */ - if ( st_ivas->hBinRendererTd == NULL ) + IF( st_ivas->hBinRendererTd == NULL ) { -#ifdef IVAS_FLOAT_FIXED Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; Word16 num_src; - IF( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ) != IVAS_ERR_OK ) - { - return error; - } -#if 1 // Cleanup changes for ivas_td_binaural_open: fixed to float - Word16 nchan_rend = num_src; - IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && NE_16( st_ivas->transport_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_rend--; /* Skip LFE channel -- added to the others */ - } - FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) - { - TDREND_SRC_t *Src_p = st_ivas->hBinRendererTd->Sources[SrcInd[nS]]; - IF( Src_p->SrcSpatial_p != NULL ) - { - Src_p->SrcSpatial_p->q_Pos_p = Q31; - } - TDREND_SRC_SPATIAL_t *SrcSpatial_p = st_ivas->hBinRendererTd->Sources[nS]->SrcSpatial_p; - SrcSpatial_p->q_Pos_p = Q31; - } -#endif -#else - if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) { return error; } -#endif } } /* Allocate memory for OSBA delay buffer */ - if ( ( error = ivas_osba_data_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_osba_data_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } - st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; + st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) ); + move16(); } - else if ( ism_mode_old == ISM_SBA_MODE_DISC && st_ivas->ism_mode == ISM_MODE_NONE ) + ELSE IF( EQ_16( ism_mode_old, ISM_SBA_MODE_DISC ) && EQ_16( st_ivas->ism_mode, ISM_MODE_NONE ) ) { /* ISM renderer handle */ ivas_ism_renderer_close( &st_ivas->hIsmRendererData ); @@ -1241,59 +1236,50 @@ ivas_error ivas_sba_dec_reconfigure_fx( ivas_osba_data_close_fx( &st_ivas->hSbaIsmData ); /* Time Domain binaural renderer handle */ - if ( st_ivas->hBinRendererTd != NULL ) + IF( st_ivas->hBinRendererTd != NULL ) { - if ( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE ) + IF( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE ) { ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); st_ivas->hHrtfTD = NULL; } } - nchan_transport_old += st_ivas->nchan_ism; + nchan_transport_old = add( nchan_transport_old, st_ivas->nchan_ism ); st_ivas->ism_mode = ISM_MODE_NONE; + move16(); } - else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + ELSE IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - st_ivas->nCPE += ( st_ivas->nchan_ism + 1 ) >> 1; + st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) ); + move16(); nCPE_old = st_ivas->nCPE; + move16(); nchan_transport_old = st_ivas->nchan_transport; - nchan_transport_old += st_ivas->nchan_ism; + move16(); + nchan_transport_old = add( nchan_transport_old, st_ivas->nchan_ism ); } } -#ifdef IVAS_FLOAT_FIXED - IF( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) - { - return error; - } -#else - if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ), IVAS_ERR_OK ) ) { return error; } -#endif /*-----------------------------------------------------------------* * HP20 memories *-----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ), IVAS_ERR_OK ) ) { return error; } -#else - if ( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif + /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ - if ( st_ivas->hDiracDecBin != NULL ) + IF( st_ivas->hDiracDecBin != NULL ) { - if ( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) { return error; } @@ -1302,78 +1288,80 @@ ivas_error ivas_sba_dec_reconfigure_fx( /*-----------------------------------------------------------------* * CLDFB instances *-----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED -#if 1 - // Float to fix conversions for ivas_cldfb_dec_reconfig_fx -#ifndef MSAN_FIX - IF( st_ivas->hSpar ) - { - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_factor_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, 16 ); - floatToFixed_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q, 16 ); - } -#endif // MSAN_FIX -#endif - if ( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) - { - return error; - } -#else - if ( ( error = ivas_cldfb_dec_reconfig( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) ) { return error; } -#endif /*-----------------------------------------------------------------* * JBM TC buffers *-----------------------------------------------------------------*/ { - int16_t tc_nchan_to_allocate; - int16_t tc_nchan_tc; + Word16 tc_nchan_to_allocate; + Word16 tc_nchan_tc; TC_BUFFER_MODE tc_buffer_mode; tc_buffer_mode = TC_BUFFER_MODE_RENDERER; + move16(); tc_nchan_tc = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_to_allocate = tc_nchan_tc; - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_MONO ) - { - if ( ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO ) ) + move16(); + test(); + test(); + test(); + test(); + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) ) + { + test(); + test(); + IF( ( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) { - tc_nchan_tc = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism; + tc_nchan_tc = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); tc_nchan_to_allocate = tc_nchan_tc; + move16(); } - else + ELSE { tc_buffer_mode = TC_BUFFER_MODE_BUFFER; + move16(); tc_nchan_tc = st_ivas->hDecoderConfig->nchan_out; + move16(); tc_nchan_to_allocate = tc_nchan_tc; + move16(); } } - else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) + ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { - tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; + tc_nchan_to_allocate = shl( BINAURAL_CHANNELS, 1 ); } - else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) + ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { tc_nchan_to_allocate = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - tc_nchan_to_allocate += st_ivas->nchan_ism; + tc_nchan_to_allocate = add( tc_nchan_to_allocate, st_ivas->nchan_ism ); } } - else + ELSE { - if ( st_ivas->nchan_transport == 1 && ( ( st_ivas->renderer_type == RENDERER_DIRAC && st_ivas->hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) || ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) + test(); + test(); + test(); + test(); + IF( EQ_16( st_ivas->nchan_transport, 1 ) && ( ( EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) && EQ_16( st_ivas->hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) || ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) ) { tc_nchan_to_allocate++; /* we need a channel for the CNG in this case*/ } } - if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode || granularity_new != st_ivas->hTcBuffer->n_samples_granularity ) + test(); + test(); + test(); + IF( NE_16( tc_nchan_tc, st_ivas->hTcBuffer->nchan_transport_jbm ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( tc_buffer_mode, st_ivas->hTcBuffer->tc_buffer_mode ) || NE_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { - if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ), IVAS_ERR_OK ) ) { return error; } @@ -1381,24 +1369,33 @@ ivas_error ivas_sba_dec_reconfigure_fx( } /* resync SPAR and DirAC JBM info from TC Buffer */ - if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity ) + test(); + IF( st_ivas->hSpatParamRendCom != NULL && EQ_16( st_ivas->hSpatParamRendCom->slot_size, st_ivas->hTcBuffer->n_samples_granularity ) ) { mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + move16(); st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + move16(); } mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); st_ivas->hSpar->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + move16(); st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + move16(); - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + test(); + test(); + IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size; - int16_t n; - for ( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ ) + Word16 granularityMultiplier = idiv1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ); + Word16 n; + FOR( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ ) { - st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier; + st_ivas->hSpatParamRendCom->subframe_nbslots[n] = i_mult( st_ivas->hTcBuffer->subframe_nbslots[n], granularityMultiplier ); + move16(); st_ivas->hSpar->subframe_nbslots[n] = st_ivas->hSpatParamRendCom->subframe_nbslots[n]; + move16(); } } @@ -1408,12 +1405,12 @@ ivas_error ivas_sba_dec_reconfigure_fx( nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) { return error; } #ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) { return error; } @@ -1746,13 +1743,16 @@ void ivas_sba_dec_digest_tc_fx( Word32 *decorr_signal[BINAURAL_CHANNELS]; Word32 *p_tc[2 * BINAURAL_CHANNELS]; Word16 q_format = 14; - default_frame = (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + Word16 exp = 0; + move16(); + default_frame = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC, &exp ); + default_frame = shr( default_frame, sub( Q15, exp ) ); nSamplesLeftForTD = nSamplesForRendering; move16(); FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { - decorr_signal[ch_idx] = st_ivas->hTcBuffer->tc_fx[ch_idx + BINAURAL_CHANNELS]; + decorr_signal[ch_idx] = st_ivas->hTcBuffer->tc_fx[add( ch_idx, BINAURAL_CHANNELS )]; move32(); p_tc[ch_idx] = st_ivas->hTcBuffer->tc_fx[ch_idx]; move32(); @@ -1785,7 +1785,7 @@ void ivas_sba_dec_digest_tc_fx( test(); test(); test(); - IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( st_ivas->hDecoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) && GT_16( st_ivas->nCPE, 0 ) && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) ) + if ( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( st_ivas->hDecoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) && st_ivas->nCPE > 0 && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) ) { nchan_transport = 1; move16(); /* Only one channel transported */ @@ -1806,7 +1806,7 @@ void ivas_sba_dec_digest_tc_fx( ( ( EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) && ( EQ_16( nchan_transport, 1 ) && NE_16( st_ivas->nchan_transport, 2 ) && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] - 1 ) - 2 ); + Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( sub( st->hFdCngDec->hFdCngCom->A_cng[0], 1 ) ), 2 ) ); generate_masking_noise_lb_dirac_fx( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc_fx[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna ); } @@ -1853,18 +1853,20 @@ ivas_error ivas_sba_dec_render_fx( } slot_size = NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + move16(); /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = s_min( sub( hSpar->num_slots, hSpar->slots_rendered ), nSamplesAsked / slot_size ); + slots_to_render = s_min( sub( hSpar->num_slots, hSpar->slots_rendered ), idiv1616( nSamplesAsked, slot_size ) ); *nSamplesRendered = imult1616( slots_to_render, slot_size ); + move16(); first_sf = hSpar->subframes_rendered; last_sf = first_sf; move16(); move16(); - WHILE( GT_16( slots_to_render, 0 ) ) + WHILE( slots_to_render > 0 ) { slots_to_render = sub( slots_to_render, hSpar->subframe_nbslots[last_sf] ); - last_sf++; + last_sf = add( last_sf, 1 ); } FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) @@ -1884,7 +1886,7 @@ ivas_error ivas_sba_dec_render_fx( IF( EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_DEC ) ) { - IF( ( error = ivas_sba_linear_renderer_fx( output_fx, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, 0, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup ) ) != IVAS_ERR_OK ) + if ( NE_32( ( error = ivas_sba_linear_renderer_fx( output_fx, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, 0, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup ) ), IVAS_ERR_OK ) ) { return error; } @@ -1895,15 +1897,18 @@ ivas_error ivas_sba_dec_render_fx( IF( EQ_16( st_ivas->hDirAC->hConfig->dec_param_estim, 1 ) ) { hSpatParamRendCom->dirac_read_idx = add( hSpatParamRendCom->dirac_read_idx, DEFAULT_JBM_CLDFB_TIMESLOTS ) % hSpatParamRendCom->dirac_md_buffer_length; + move16(); } ELSE { hSpatParamRendCom->dirac_read_idx = add( hSpatParamRendCom->dirac_read_idx, DEFAULT_JBM_SUBFRAMES_5MS ) % hSpatParamRendCom->dirac_md_buffer_length; + move16(); } move16(); } *nSamplesAvailableNext = imult1616( sub( hSpar->num_slots, hSpar->slots_rendered ), slot_size ); + move16(); return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index aaa838a2cbe09f5ec0f6349872379544061f43b5..2ad1c081be820629d4cf4f70e67a010578aaf974 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -69,7 +69,7 @@ Word16 ivas_get_sba_dirac_stereo_flag( { IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) ) { - IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) || ( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) && EQ_16( st_ivas->nchan_transport, 1 ) ) ) + if ( EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) || ( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) && EQ_16( st_ivas->nchan_transport, 1 ) ) ) { sba_dirac_stereo_flag = 1; move16(); @@ -77,7 +77,7 @@ Word16 ivas_get_sba_dirac_stereo_flag( } ELSE { - IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) + if ( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { sba_dirac_stereo_flag = 1; move16(); @@ -86,7 +86,7 @@ Word16 ivas_get_sba_dirac_stereo_flag( } ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) + if ( EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { sba_dirac_stereo_flag = 1; move16(); @@ -219,7 +219,7 @@ static Word16 ivas_sba_dirac_stereo_band_config( static Word16 get_panning_tangent_gain( const Word16 sinAngleMapped ) { - Word16 tbl_len = sizeof( ivas_sine_panning_tbl_fx ) / sizeof( ivas_sine_panning_tbl_fx[0] ); + Word16 tbl_len = sizeof( ivas_sine_panning_tbl_fx ) / sizeof( ivas_sine_panning_tbl_fx[0] ); // Not using BASOP because size can be calculted at compile-time. move16(); Word16 idx = shr( tbl_len, 1 ); move16(); @@ -236,7 +236,7 @@ static Word16 get_panning_tangent_gain( { return ptr_tan[tbl_len - 1]; } - ELSE IF( LE_16( idx, 0 ) ) + ELSE IF( idx <= 0 ) { return ptr_tan[0]; } @@ -267,12 +267,10 @@ static Word16 get_panning_tangent_gain( ELSE IF( GT_16( sinAngleMapped, ptr_sin[idx] ) ) { lim_l = add( idx, 1 ); - move16(); } ELSE IF( LT_16( sinAngleMapped, ptr_sin[idx] ) ) { lim_r = sub( idx, 1 ); - move16(); } } } @@ -288,25 +286,21 @@ static Word16 get_panning( Word16 azSubEl = aziDeg - eleDeg; move16(); const Word16 *ptr_sin_az = &ivas_sin_az_fx[180]; - while ( azAddEl > 180 ) + WHILE( GT_16( azAddEl, 180 ) ) { - azAddEl = azAddEl - 360; - move16(); + azAddEl = sub( azAddEl, 360 ); } - while ( azAddEl < -180 ) + WHILE( LT_16( azAddEl, negate( 180 ) ) ) { - azAddEl = azAddEl + 360; - move16(); + azAddEl = add( azAddEl, 360 ); } - while ( azSubEl > 180 ) + WHILE( GT_16( azSubEl, 180 ) ) { - azSubEl = azSubEl - 360; - move16(); + azSubEl = sub( azSubEl, 360 ); } - while ( azSubEl < -180 ) + WHILE( LT_16( azSubEl, negate( 180 ) ) ) { - azSubEl = azSubEl + 360; - move16(); + azSubEl = add( azSubEl, 360 ); } /*sin(az)cos(el) = 0.5 * (sin(az + el) + sin(az - el)) */ Word16 sin_az_cos_el = add( shr( ptr_sin_az[azAddEl], 1 ), shr( ptr_sin_az[azSubEl], 1 ) ); @@ -393,16 +387,18 @@ static void map_params_dirac_to_stereo( FOR( i = hStereoDft->band_limits[b]; i < hStereoDft->band_limits[b + 1]; i++ ) { tmp64 = W_add( tmp64, W_add( W_mult0_32_32( pDFT[2 * i], pDFT[2 * i] ), - W_mult0_32_32( pDFT[2 * i + 1], pDFT[2 * i + 1] ) ) ); - move32(); + W_mult0_32_32( pDFT[add( 2 * i, 1 )], pDFT[add( 2 * i, 1 )] ) ) ); + move64(); } subframe_band_nrg[k][b] = W_extract_h( W_shl( tmp64, 1 ) ); + move32(); q_nrg = sub( Q31, sub( shl( hStereoDft->q_dft, 1 ), Q31 ) ); subframe_band_nrg[k][b] = Sqrt32( subframe_band_nrg[k][b], &q_nrg ); move32(); IF( NE_16( sub( Q31, q_nrg ), hStereoDft->q_smooth_buf_fx ) ) { subframe_band_nrg[k][b] = L_shl( subframe_band_nrg[k][b], sub( hStereoDft->q_smooth_buf_fx, sub( Q31, q_nrg ) ) ); + move32(); } hStereoDft->smooth_buf_fx[b][NB_DIV - 1 - k] = subframe_band_nrg[k][b]; move32(); @@ -413,7 +409,7 @@ static void map_params_dirac_to_stereo( smooth_long_avg[k][b] = 0; move32(); /* Multiplying and adding avoids overflow */ - FOR( i = sub( NB_DIV - 1, k ); i < add( SBA_DIRAC_NRG_SMOOTH_SHORT + NB_DIV - 1, k ); i++ ) + FOR( i = sub( sub( NB_DIV, 1 ), k ); i < add( sub( add( SBA_DIRAC_NRG_SMOOTH_SHORT, NB_DIV ), 1 ), k ); i++ ) { smooth_short_avg[k][b] = Madd_32_16( smooth_short_avg[k][b], hStereoDft->smooth_buf_fx[b][i], (Word16) 0x2AAB ); /* 1/ 3 in Q15*/ move32(); @@ -421,7 +417,7 @@ static void map_params_dirac_to_stereo( move32(); } - FOR( i = sub( NB_DIV - 1 + SBA_DIRAC_NRG_SMOOTH_SHORT, k ); i < sub( SBA_DIRAC_NRG_SMOOTH_LONG + NB_DIV - 1, k ); i++ ) + FOR( i = sub( add( sub( NB_DIV, 1 ), SBA_DIRAC_NRG_SMOOTH_SHORT ), k ); i < sub( sub( add( SBA_DIRAC_NRG_SMOOTH_LONG, NB_DIV ), 1 ), k ); i++ ) { smooth_long_avg[k][b] = Madd_32_16( smooth_long_avg[k][b], hStereoDft->smooth_buf_fx[b][i], (Word16) 0x0CCD ); move32(); @@ -429,7 +425,7 @@ static void map_params_dirac_to_stereo( /* calculate smoothing factor based on energy averages */ /* reduce factor for higher short-term energy */ - IF( NE_32( smooth_long_avg[k][b], 0 ) ) + IF( smooth_long_avg[k][b] ) { hStereoDft->smooth_fac_fx[k][b] = extract_l( s_min( MAX_16, BASOP_Util_Divide3232_Scale( smooth_long_avg[k][b], smooth_short_avg[k][b], &q_div ) ) ); move32(); @@ -506,36 +502,9 @@ static void map_params_dirac_to_stereo( } pSynth += block_len; } -#if 0 - /* - * block_nrg array's q-format will be q_synth at this point in the control flow. - * So unity used for division numerator should also be in the same Q - q_synth. - */ - nrg_norm1 = L_deposit_l(BASOP_Util_Divide3232_Scale(L_shl(1, q_synth), L_add(block_nrg[0] , L_add(block_nrg[1] , EPSILON_FIX) ), &q_div1)); - IF (NE_16(q_div1, 0) && NE_32(block_nrg[0], 0) && NE_32(block_nrg[1], 0)) - { - /* - nrg_norm1 obtained in the previous step will be in Q15 - q_div1 format. - Below step converts and stores nrg_norm1 in Q31 format. - */ - nrg_norm1 = L_shl(nrg_norm1, add(Q16, q_div1)); - q_div1 = 0; - } - nrg_norm2 = L_deposit_l(BASOP_Util_Divide3232_Scale(L_shl(1, q_synth), L_add(block_nrg[2] , L_add(block_nrg[3] , EPSILON_FIX) ), &q_div2)); - IF (NE_16(q_div2, 0) && NE_32(block_nrg[2], 0) && NE_32(block_nrg[3], 0)) - { - /* - nrg_norm2 obtained in the previous step will be in Q15 - q_div2 format. - Below step converts and stores nrg_norm2 in Q31 format. - */ - nrg_norm2 = L_shl(nrg_norm2, add(Q16, q_div2)); - q_div2 = 0; - } -#else nrg_norm1 = L_add( block_nrg[0], L_add( block_nrg[1], EPSILON_FIX ) ); nrg_norm2 = L_add( block_nrg[2], L_add( block_nrg[3], EPSILON_FIX ) ); -#endif /* extract DirAC parameters from metadata */ FOR( b = 0; b < nbands; b++ ) @@ -567,7 +536,7 @@ static void map_params_dirac_to_stereo( block_metadata = block; move16(); } - IF( LT_32( q_direction->band_data[b].azimuth_fx[block_metadata], 0 ) ) + IF( q_direction->band_data[b].azimuth_fx[block_metadata] < 0 ) { q_direction->band_data[b].azimuth_fx[block_metadata] = L_add( (Word32) 0x5A000000, q_direction->band_data[b].azimuth_fx[block_metadata] ); move16(); @@ -592,19 +561,6 @@ static void map_params_dirac_to_stereo( move32(); FOR( block = 0; block < shr( nBlocks, 1 ); block++ ) { -#if 0 - IF ( EQ_16(b_wide_panning, 1) ) - { - /* panning between left and ride, saturate at the stereo ls positions (+/- 30deg azi) */ - side_gain[b] = Madd_32_32(side_gain[b], nrg_norm1, Mpy_32_16_1(block_nrg[block] , get_panning( azimuth[block][b], elevation[block][b]) )); - move32(); - } - ELSE - { - side_gain[b] = Madd_32_32(side_gain[b], nrg_norm1, Mpy_32_16_1(block_nrg[block] , mult(ptr_sin_az[azimuth[block][b]] , ptr_cos_el[elevation[block][b]]))); - move32(); - } -#else /* * The floating point version of the code computes * nrg_norm1 = 1 / (block_nrg[0] + block_nrg[1]); and then computes @@ -613,7 +569,7 @@ static void map_params_dirac_to_stereo( IF( EQ_16( b_wide_panning, 1 ) ) { Word32 temp = L_mult( BASOP_Util_Divide3232_Scale( block_nrg[block], nrg_norm1, &q_div1 ), get_panning( azimuth[block][b], elevation[block][b] ) ); - IF( NE_16( q_div1, 0 ) ) + IF( q_div1 ) { temp = L_shl_sat( temp, q_div1 ); } @@ -624,14 +580,13 @@ static void map_params_dirac_to_stereo( ELSE { Word32 temp = L_mult( BASOP_Util_Divide3232_Scale( block_nrg[block], nrg_norm1, &q_div1 ), mult( ptr_sin_az[azimuth[block][b]], ptr_cos_el[elevation[block][b]] ) ); - IF( NE_16( q_div1, 0 ) ) + IF( q_div1 ) { temp = L_shl_sat( temp, q_div1 ); } side_gain[b] = L_add_sat( side_gain[b], temp ); move32(); } -#endif } /* combine angles of last 2 blocks to side gain of second subframe */ @@ -639,23 +594,10 @@ static void map_params_dirac_to_stereo( move32(); FOR( block = shr( nBlocks, 1 ); block < nBlocks; block++ ) { -#if 0 - IF ( EQ_16(b_wide_panning, 1) ) - { - /* panning between left and ride, saturate at the stereo ls positions (+/- 30deg azi) */ - side_gain[b + STEREO_DFT_BAND_MAX] = Madd_32_32(side_gain[b + STEREO_DFT_BAND_MAX], nrg_norm2 , Mpy_32_16_1(block_nrg[block] , get_panning( azimuth[block][b], elevation[block][b]))); - move32(); - } - ELSE - { - side_gain[b + STEREO_DFT_BAND_MAX] = Madd_32_32(side_gain[b + STEREO_DFT_BAND_MAX], nrg_norm2 , Mpy_32_16_1(block_nrg[block] , mult( ptr_sin_az[azimuth[block][b]] , ptr_cos_el[elevation[block][b]]))); - move32(); - } -#else IF( EQ_16( b_wide_panning, 1 ) ) { Word32 temp = L_mult( BASOP_Util_Divide3232_Scale( block_nrg[block], nrg_norm2, &q_div1 ), get_panning( azimuth[block][b], elevation[block][b] ) ); - IF( NE_16( q_div1, 0 ) ) + IF( q_div1 ) { temp = L_shl_sat( temp, q_div1 ); } @@ -666,29 +608,31 @@ static void map_params_dirac_to_stereo( ELSE { Word32 temp = L_mult( BASOP_Util_Divide3232_Scale( block_nrg[block], nrg_norm2, &q_div1 ), mult( ptr_sin_az[azimuth[block][b]], ptr_cos_el[elevation[block][b]] ) ); - IF( NE_16( q_div1, 0 ) ) + IF( q_div1 ) { temp = L_shl_sat( temp, q_div1 ); } side_gain[b + STEREO_DFT_BAND_MAX] = L_add_sat( side_gain[b + STEREO_DFT_BAND_MAX], temp ); move32(); } -#endif } q_sqrt = 0; + move16(); side_gain[b] = Mpy_32_32( side_gain[b], Sqrt32( L_sub( MAX_32, diffuseness[b] ), &q_sqrt ) ); move32(); - IF( NE_16( q_sqrt, 0 ) ) + IF( q_sqrt ) { side_gain[b] = L_shl( side_gain[b], q_sqrt ); q_sqrt = 0; + move16(); } side_gain[b + STEREO_DFT_BAND_MAX] = Mpy_32_32( side_gain[b + STEREO_DFT_BAND_MAX], Sqrt32( L_sub( MAX_32, diffuseness[b] ), &q_sqrt ) ); move32(); - IF( NE_16( q_sqrt, 0 ) ) + IF( q_sqrt ) { side_gain[b + STEREO_DFT_BAND_MAX] = L_shl( side_gain[b], q_sqrt ); q_sqrt = 0; + move16(); } res_pred_gain[b] = Mpy_32_16_1( diffuseness[b], sub( MAX_16, surrCoh[b] ) ); move32(); @@ -728,7 +672,9 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( Word32 hb_nrg2 = EPSILON_FIX; move32(); - IF( ( EQ_16( core, ACELP_CORE ) && EQ_16( fd_cng_flag, 0 ) ) || EQ_16( hStereoDft->core_hist[1], ACELP_CORE ) ) + test(); + test(); + IF( ( EQ_16( core, ACELP_CORE ) && !fd_cng_flag ) || EQ_16( hStereoDft->core_hist[1], ACELP_CORE ) ) { FOR( i = 0; i < shr( output_frame, 2 ); i++ ) { @@ -736,9 +682,11 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( } hStereoDft->hb_nrg_subr_fx[0] = hb_nrg2; + move32(); hStereoDft->q_hb_nrg_subr = sub( shl( q_hb_synth, 1 ), 31 ); move32(); hb_nrg = L_add( hb_nrg, hb_nrg2 ); + move32(); hb_nrg2 = EPSILON_FIX; move32(); @@ -759,8 +707,9 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( { IF( GT_16( hStereoDft->q_hb_stefi_sig_fx, q_hb_synth ) ) { - v_shr( hStereoDft->hb_stefi_sig_fx, sub( hStereoDft->q_hb_stefi_sig_fx, q_hb_synth ), hStereoDft->hb_stefi_sig_fx, sizeof( hStereoDft->hb_stefi_sig_fx ) / sizeof( hStereoDft->hb_stefi_sig_fx[0] ) ); + v_shr( hStereoDft->hb_stefi_sig_fx, sub( hStereoDft->q_hb_stefi_sig_fx, q_hb_synth ), hStereoDft->hb_stefi_sig_fx, idiv1616( sizeof( hStereoDft->hb_stefi_sig_fx ), sizeof( hStereoDft->hb_stefi_sig_fx[0] ) ) ); hStereoDft->q_hb_stefi_sig_fx = q_hb_synth; + move16(); Copy32( hb_synth, hStereoDft->hb_stefi_sig_fx + hStereoDft->hb_stefi_delay, output_frame ); } ELSE @@ -774,7 +723,9 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( set_val_Word32( hStereoDft->hb_stefi_sig_fx + hStereoDft->hb_stefi_delay, 0, output_frame ); #ifdef MSAN_FIX hStereoDft->hb_nrg_subr_fx[0] = 0; + move32(); hStereoDft->hb_nrg_subr_fx[1] = 0; + move32(); #endif // MSAN_FIX } hStereoDft->hb_nrg_subr_fx[0] = hStereoDft->hb_nrg_subr_fx[0]; // imult3216(hStereoDft->hb_nrg_subr_fx[0] , shr(hStereoDft->NFFT, 1)); @@ -785,8 +736,14 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( move32(); hStereoDft->td_gain_fx[0] = 0; move32(); - hStereoDft->core_hist[0] = ( fd_cng_flag ) ? TCX_20_CORE : core; /* full signal available for DTX with FD-CNG, thus apply stereo filling on full spectrum like in TCX */ + hStereoDft->core_hist[0] = core; /* full signal available for DTX with FD-CNG, thus apply stereo filling on full spectrum like in TCX */ move16(); + + if ( fd_cng_flag ) + { + hStereoDft->core_hist[0] = TCX_20_CORE; + move16(); + } return; } @@ -808,9 +765,9 @@ static void ivas_sba_dirac_stereo_compute_hb_gain( move16(); /* last band covers whole HB range, no averaging needed */ - hb_gain[0] = hStereoDft->side_gain_fx[k_offset * STEREO_DFT_BAND_MAX + hStereoDft->nbands - 1]; + hb_gain[0] = hStereoDft->side_gain_fx[sub( add( i_mult( k_offset, STEREO_DFT_BAND_MAX ), hStereoDft->nbands ), 1 )]; move32(); - hb_gain[1] = hStereoDft->side_gain_fx[( k_offset + 1 ) * STEREO_DFT_BAND_MAX + hStereoDft->nbands - 1]; + hb_gain[1] = hStereoDft->side_gain_fx[sub( add( i_mult( add( k_offset, 1 ), STEREO_DFT_BAND_MAX ), hStereoDft->nbands ), 1 )]; move32(); return; @@ -838,10 +795,16 @@ static void ivas_sba_dirac_stereo_upmix_hb( Word32 gp, gm; Word16 gain_fac; - IF( EQ_16( mcmasa, 0 ) ) + IF( !mcmasa ) { - gain_fac = ( bwidth == FB ) ? (Word32) 0x2000 : (Word32) 0x2A3D; /* last matrix element not used for SWB, divide by 3 instead of 4*/ + gain_fac = (Word32) 0x2A3D; /* last matrix element not used for SWB, divide by 3 instead of 4*/ move16(); + if ( EQ_16( bwidth, FB ) ) + { + gain_fac = (Word32) 0x2000; + move16(); + } + IF( sba_mono_flag ) { gp = L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][8], gain_fac ), @@ -851,11 +814,13 @@ static void ivas_sba_dirac_stereo_upmix_hb( { gp = Madd_32_16( gp, hStereoDft->mixer_mat_smooth_fx[0][0][11], gain_fac ); } + FOR( i = 0; i < shr( output_frame, 1 ); i++ ) { hb_stereo_synth[0][i] = Mpy_32_32( hb_synth[i], gp ); move32(); } + gp = L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][8 + IVAS_MAX_NUM_BANDS], gain_fac ), Madd_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][9 + IVAS_MAX_NUM_BANDS], gain_fac ), hStereoDft->mixer_mat_smooth_fx[0][0][10 + IVAS_MAX_NUM_BANDS], gain_fac ) ); @@ -863,6 +828,7 @@ static void ivas_sba_dirac_stereo_upmix_hb( { gp = Madd_32_16( gp, hStereoDft->mixer_mat_smooth_fx[0][0][11 + IVAS_MAX_NUM_BANDS], gain_fac ); } + FOR( i = shr( output_frame, 1 ); i < output_frame; i++ ) { hb_stereo_synth[0][i] = Mpy_32_32( hb_synth[i], gp ); @@ -1164,9 +1130,16 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx( move16(); FOR( k = 0; k < 2; k++ ) { - FOR( i_sf = k * 2; i_sf < ( k + 1 ) * 2; i_sf++ ) + FOR( i_sf = shl( k, 1 ); i_sf < shl( add( k, 1 ), 1 ); i_sf++ ) { - md_sf = (Word16) ( EQ_16( num_md_sub_frames, MAX_PARAM_SPATIAL_SUBFRAMES ) ? i_sf : 0 ); + md_sf = 0; + move16(); + + IF( EQ_16( num_md_sub_frames, MAX_PARAM_SPATIAL_SUBFRAMES ) ) + { + md_sf = i_sf; + move16(); + } IF( hStereoDft->first_frame ) { FOR( i = 0; i < 2; i++ ) @@ -1176,12 +1149,12 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx( FOR( b = 0; b < hStereoDft->nbands; b++ ) { // The Q format of mixer_mat_fx is Q30 so applying the left shift. - hStereoDft->mixer_mat_smooth_fx[i][j][b + k * IVAS_MAX_NUM_BANDS] = L_shl_sat( hMdDec->mixer_mat_fx[i][j][b], 1 ); + hStereoDft->mixer_mat_smooth_fx[i][j][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )] = L_shl_sat( hMdDec->mixer_mat_fx[i][j][b], 1 ); move32(); } FOR( ; b < IVAS_MAX_NUM_BANDS; b++ ) { - hStereoDft->mixer_mat_smooth_fx[i][j][b + k * IVAS_MAX_NUM_BANDS] = 0; + hStereoDft->mixer_mat_smooth_fx[i][j][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )] = 0; move32(); } } @@ -1199,7 +1172,7 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx( move16(); // The Q format of mixer_mat_prev_fx is Q30 so applying the left shift. hStereoDft->mixer_mat_smooth_fx[i][j][b + k * IVAS_MAX_NUM_BANDS] = - L_add_sat( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[i][j][b + k * IVAS_MAX_NUM_BANDS], beta ), + L_add_sat( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[i][j][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], beta ), L_shl_sat( Mpy_32_16_1( hMdDec->mixer_mat_prev_fx[i_hist][i][j][b], sub( (Word16) 0x7FFF, beta ) ), Q1 ) ); move32(); } @@ -1218,7 +1191,7 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx( { FOR( b = 0; b < hStereoDft->nbands; b++ ) { - hMdDec->mixer_mat_prev_fx[4][i][j][b] = hMdDec->mixer_mat_fx[i][j][b + md_sf * IVAS_MAX_NUM_BANDS]; + hMdDec->mixer_mat_prev_fx[4][i][j][b] = hMdDec->mixer_mat_fx[i][j][add( b, i_mult( md_sf, IVAS_MAX_NUM_BANDS ) )]; move32(); } } @@ -1265,25 +1238,30 @@ void ivas_sba_dirac_stereo_dec_fx( hCPE = st_ivas->hCPE[0]; hStereoDft = hCPE->hStereoDft; q = hCPE->hStereoDft->q_dft; + move16(); q_dft[0] = hCPE->hStereoDft->q_dft; + move16(); q_dft[1] = hCPE->hStereoDft->q_dft; + move16(); #ifdef MSAN_FIX - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), -( Q11 - hCPE->hStereoDft->q_dft ) ); + Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); #else Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_fx2( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), -( Q11 - hCPE->hStereoDft->q_dft ) ); #endif IF( hSCE != NULL ) { #ifdef MSAN_FIX - Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), -( Q11 - hCPE->hStereoDft->q_dft ) ); + Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); #else Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_fx2( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), -( Q11 - hCPE->hStereoDft->q_dft ) ); #endif // MSAN_FIX hSCE->q_prev_hb_synth_fx = hCPE->hStereoDft->q_dft; + move16(); } - IF( GT_16( st_ivas->nchan_transport, 1 ) && EQ_16( mcmasa, 0 ) ) + test(); + IF( GT_16( st_ivas->nchan_transport, 1 ) && !mcmasa ) { dtx_flag = 0; move16(); @@ -1293,14 +1271,21 @@ void ivas_sba_dirac_stereo_dec_fx( ELSE { dtx_flag = (Word16) LE_32( hSCE->hCoreCoder[0]->core_brate, SID_2k40 ); + move16(); + test(); fd_cng_flag = ( dtx_flag && EQ_16( hSCE->hCoreCoder[0]->cng_type, FD_CNG ) ); + move16(); } sba_mono_flag = (Word16) EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ); + move16(); - memOffset = NS2SA( L_mult0( output_frame, FRAMES_PER_SEC ), L_sub( IVAS_DEC_DELAY_NS, DELAY_BWE_TOTAL_NS ) ); + memOffset = NS2SA( L_mult0( output_frame, FRAMES_PER_SEC ), IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ); + move16(); ivas_sba_dirac_stereo_config( hStereoDft->hConfig ); - hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) ); + test(); + test(); + hStereoDft->nbands = ivas_sba_dirac_stereo_band_config( hStereoDft->band_limits, st_ivas->hDecoderConfig->output_Fs, hStereoDft->NFFT, ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) ); stereo_dft_dec_update_fx( hStereoDft, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); IF( GT_16( st_ivas->nchan_transport, 1 ) ) { @@ -1323,9 +1308,13 @@ void ivas_sba_dirac_stereo_dec_fx( } /* mapping of DirAC parameters (azimuth, elevation, diffuseness) to DFT Stereo parameters (side gain, prediction gain) */ + test(); + test(); + test(); + test(); map_params_dirac_to_stereo( hStereoDft, st_ivas->hQMetaData, tmp_synth, DFT[0], st_ivas->ivas_format == MC_FORMAT, - ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame, - ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ), hSCE != NULL ? hSCE->q_save_synth_fx : 0 ); + ( ( NE_16( st_ivas->ivas_format, SBA_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame, + ( ( NE_16( st_ivas->ivas_format, SBA_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || mcmasa ), hSCE != NULL ? hSCE->q_save_synth_fx : 0 ); IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) { @@ -1333,12 +1322,12 @@ void ivas_sba_dirac_stereo_dec_fx( } /* DFT Stereo upmix */ - stereo_dft_dec_fx( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, + stereo_dft_dec_fx( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && ( !mcmasa ) ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); /* DFT synthesis */ stereo_dft_dec_synthesize_fx( hCPE, DFT, 0, output[0], output_frame ); - IF( EQ_16( sba_mono_flag, 0 ) ) + IF( !sba_mono_flag ) { stereo_dft_dec_synthesize_fx( hCPE, DFT, 1, output[1], output_frame ); } @@ -1346,7 +1335,7 @@ void ivas_sba_dirac_stereo_dec_fx( synchro_synthesis_fx( st_ivas->hDecoderConfig->ivas_total_brate, hCPE, output, output_frame, 1 /*st_ivas->sba_dirac_stereo_flag*/ ); /* output scaling */ - IF( EQ_16( sba_mono_flag, 0 ) ) + IF( !sba_mono_flag ) { v_shr( output[0], 1, output[0], output_frame ); v_shr( output[1], 1, output[1], output_frame ); @@ -1356,26 +1345,33 @@ void ivas_sba_dirac_stereo_dec_fx( IF( EQ_16( st_ivas->nchan_transport, 1 ) ) { Copy32( hSCE->save_hb_synth_fx + output_frame - memOffset, tmp_buf, memOffset ); - Copy32( hSCE->save_hb_synth_fx, hSCE->save_hb_synth_fx + memOffset, output_frame - memOffset ); + Copy32( hSCE->save_hb_synth_fx, hSCE->save_hb_synth_fx + memOffset, sub( output_frame, memOffset ) ); Copy32( hSCE->prev_hb_synth_fx, hSCE->save_hb_synth_fx, memOffset ); v_shr( tmp_buf, sub( hSCE->q_prev_hb_synth_fx, hSCE->q_save_hb_synth_fx ), hSCE->prev_hb_synth_fx, memOffset ); } - IF( ( EQ_16( hCPE->hCoreCoder[0]->core, ACELP_CORE ) || EQ_16( hCPE->hCoreCoder[0]->last_core, ACELP_CORE ) ) && EQ_16( fd_cng_flag, 0 ) && EQ_16( st_ivas->nchan_transport, 1 ) ) + test(); + test(); + test(); + IF( ( EQ_16( hCPE->hCoreCoder[0]->core, ACELP_CORE ) || EQ_16( hCPE->hCoreCoder[0]->last_core, ACELP_CORE ) ) && !fd_cng_flag && EQ_16( st_ivas->nchan_transport, 1 ) ) { /* upmix ACELP BWE */ ivas_sba_dirac_stereo_compute_hb_gain( hStereoDft, hb_gain ); - ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth_fx, hb_gain, output_frame, ( ( st_ivas->ivas_format != SBA_FORMAT && st_ivas->ivas_format != SBA_ISM_FORMAT ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); + test(); + test(); + ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth_fx, hb_gain, output_frame, ( ( NE_16( st_ivas->ivas_format, SBA_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); /* add HB to ACELP core */ v_add_fx( output[0], hb_synth_stereo[0], output[0], output_frame ); - IF( EQ_16( sba_mono_flag, 0 ) ) + IF( !sba_mono_flag ) { v_add_fx( output[1], hb_synth_stereo[1], output[1], output_frame ); /* apply TD Stereo Filling as is done in ICBWE */ - ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) && !mcmasa ) ); + test(); + test(); + ivas_sba_dirac_stereo_apply_td_stefi( hStereoDft, output, output_frame, ( ( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) ); } } @@ -1386,18 +1382,19 @@ void ivas_sba_dirac_stereo_dec_fx( } #ifdef MSAN_FIX - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), ( Q11 - hCPE->hStereoDft->q_dft ) ); + Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); #else Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_fx2( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), ( Q11 - hCPE->hStereoDft->q_dft ) ); #endif IF( hSCE != NULL ) { #ifdef MSAN_FIX - Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), ( Q11 - hCPE->hStereoDft->q_dft ) ); + Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); #else Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_fx2( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), ( Q11 - hCPE->hStereoDft->q_dft ) ); #endif // MSAN_FIX hSCE->q_prev_hb_synth_fx = Q11; + move16(); } return; diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 86da344d9f6a1df1b72dd0c8638a22c3b89154ca..03b5eb85c4615f727f07f89c3adfb9537f275d2a 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -132,24 +132,25 @@ void ivas_sba2mc_cldfb_fixed( const Word32 *hoa_dec_mtx /* i : HOA decoding mtx */ ) { - int16_t iBlock, iBand, n, m; + Word16 iBlock, iBand, n, m; Word32 realOut_fx[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX], imagOut_fx[16][MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX]; Word32 g_fx; Word32 *p_real_fx, *p_imag_fx, *p_realOut_fx, *p_imagOut_fx; - int16_t nb_channels_in; + Word16 nb_channels_in; push_wmops( "ivas_sba2mc_cldfb_fixed" ); nb_channels_in = hInSetup.nchan_out_woLFE; - assert( ( nb_channels_in == 16 ) && ( nb_channels_out == 11 ) && "ivas_sba2mc_cldfb_fixed; only HOA3 to CICP19 is for now supported!" ); + move16(); + assert( EQ_16( nb_channels_in, 16 ) && EQ_16( nb_channels_out, 11 ) && "ivas_sba2mc_cldfb_fixed; only HOA3 to CICP19 is for now supported!" ); FOR( n = 0; n < nb_channels_out; n++ ) { - set_l( realOut_fx[n], 0, MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands ); - set_l( imagOut_fx[n], 0, MAX_PARAM_SPATIAL_SUBFRAMES * nb_bands ); + set_l( realOut_fx[n], 0, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, nb_bands ) ); + set_l( imagOut_fx[n], 0, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, nb_bands ) ); FOR( m = 0; m < nb_channels_in; m++ ) { - g_fx = hoa_dec_mtx[SBA_NHARM_HOA3 * n + m]; // Q29 + g_fx = hoa_dec_mtx[add( SBA_NHARM_HOA3 * n, m )]; // Q29 p_realOut_fx = realOut_fx[n]; p_imagOut_fx = imagOut_fx[n]; @@ -159,8 +160,10 @@ void ivas_sba2mc_cldfb_fixed( p_imag_fx = ImagBuffer[m][iBlock]; FOR( iBand = 0; iBand < nb_bands; iBand++ ) { - *p_realOut_fx = *p_realOut_fx + Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_real_fx++ ) ); // Q_real - *p_imagOut_fx = *p_imagOut_fx + Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_imag_fx++ ) ); // Q_imag + *p_realOut_fx = L_add( *p_realOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_real_fx++ ) ) ); // Q_real + move32(); + *p_imagOut_fx = L_add( *p_imagOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_imag_fx++ ) ) ); // Q_imag + move32(); p_realOut_fx++; p_imagOut_fx++; } @@ -180,7 +183,9 @@ void ivas_sba2mc_cldfb_fixed( FOR( iBand = 0; iBand < nb_bands; iBand++ ) { *( p_real_fx++ ) = *p_realOut_fx++; + move32(); *( p_imag_fx++ ) = *p_imagOut_fx++; + move32(); } } } @@ -228,27 +233,30 @@ void ivas_mc2sba_fx( move16(); FOR( i = 0; i < add( hIntSetup.nchan_out_woLFE, hIntSetup.num_lfe ); i++ ) { - IF( GT_16( hIntSetup.num_lfe, 0 ) && EQ_16( i, hIntSetup.index_lfe[idx_lfe] ) ) + IF( ( hIntSetup.num_lfe > 0 ) && EQ_16( i, hIntSetup.index_lfe[idx_lfe] ) ) { - IF( GT_16( gain_lfe_fx, 0 ) ) + IF( gain_lfe_fx > 0 ) { /* Add LFE to omni W with gain*/ FOR( k = 0; k < output_frame; k++ ) { buffer_tmp_fx[0][k] = L_add( buffer_tmp_fx[0][k], L_shl( Mult_32_16( in_buffer_td_fx[i][k], gain_lfe_fx ), 1 ) ); /*Q+14-15+1==Q*/ + move32(); } } IF( LT_16( idx_lfe, sub( hIntSetup.num_lfe, 1 ) ) ) { - idx_lfe++; + idx_lfe = add( idx_lfe, 1 ); } } ELSE { azimuth = (Word16) L_shr( hIntSetup.ls_azimuth_fx[idx_in], 22 ); + move16(); elevation = (Word16) L_shr( hIntSetup.ls_elevation_fx[idx_in], 22 ); - idx_in++; + move16(); + idx_in = add( idx_in, 1 ); ivas_dirac_dec_get_response_fx( azimuth, elevation, @@ -262,6 +270,7 @@ void ivas_mc2sba_fx( FOR( k = 0; k < output_frame; k++ ) { buffer_tmp_fx[j][k] = L_add( buffer_tmp_fx[j][k], L_shl( Mult_32_32( in_buffer_td_fx[i][k], gains_fx[j] ), 2 ) ); /*Q+29-31+2==Q*/ + move32(); } } } @@ -393,18 +402,20 @@ void ivas_param_mc_mc2sba_cldfb_fx( FOR( idx_ch = 0; idx_ch < add( hTransSetup.nchan_out_woLFE, hTransSetup.num_lfe ); idx_ch++ ) { - IF( GT_16( hTransSetup.num_lfe, 0 ) && EQ_16( idx_ch, hTransSetup.index_lfe[idx_lfe] ) ) + IF( ( hTransSetup.num_lfe > 0 ) && EQ_16( idx_ch, hTransSetup.index_lfe[idx_lfe] ) ) { - IF( GT_32( gain_lfe_fx, 0 ) ) + IF( gain_lfe_fx > 0 ) { /* Add LFE to Omni Channel i.e. W (Just first Band) */ Cldfb_RealBuffer_tmp_fx[0][0] = L_add_sat( Cldfb_RealBuffer_tmp_fx[0][0], Mult_32_16( L_shl( Cldfb_RealBuffer_fx[idx_ch][slot_idx][0], 1 ), gain_lfe_fx ) ); + move32(); Cldfb_ImagBuffer_tmp_fx[0][0] = L_add_sat( Cldfb_ImagBuffer_tmp_fx[0][0], Mult_32_16( L_shl( Cldfb_ImagBuffer_fx[idx_ch][slot_idx][0], 1 ), gain_lfe_fx ) ); + move32(); } IF( LT_16( idx_lfe, sub( hTransSetup.num_lfe, 1 ) ) ) { - idx_lfe++; + idx_lfe = add( idx_lfe, 1 ); } } ELSE @@ -415,11 +426,13 @@ void ivas_param_mc_mc2sba_cldfb_fx( FOR( idx_band = 0; idx_band < nBands; idx_band++ ) { Cldfb_RealBuffer_tmp_fx[idx_out][idx_band] = L_add( Cldfb_RealBuffer_tmp_fx[idx_out][idx_band], Mult_32_32( ( *gains_fx ), Cldfb_RealBuffer_fx[idx_ch][slot_idx][idx_band] ) ); + move32(); Cldfb_ImagBuffer_tmp_fx[idx_out][idx_band] = L_add( Cldfb_ImagBuffer_tmp_fx[idx_out][idx_band], Mult_32_32( ( *gains_fx ), Cldfb_ImagBuffer_fx[idx_ch][slot_idx][idx_band] ) ); + move32(); } gains_fx++; } - idx_in++; + idx_in = add( idx_in, 1 ); } } FOR( idx_ch = 0; idx_ch < sba_num_chans; idx_ch++ ) @@ -521,7 +534,7 @@ Word16 ivas_sba_remapTCs_fx( move16(); IF( EQ_16( nchan_remapped, 3 ) ) { - nchan_remapped++; + nchan_remapped = add( nchan_remapped, 1 ); IF( EQ_16( nchan_remapped, 4 ) ) { Copy32( sba_data_fx[2], sba_data_fx[3], output_frame ); @@ -542,7 +555,8 @@ Word16 ivas_sba_remapTCs_fx( move32(); sba_data_fx[3][i] = temp_fx; move32(); - IF( EQ_16( st_ivas->nchan_transport, 3 ) ) + + if ( EQ_16( st_ivas->nchan_transport, 3 ) ) { sba_data_fx[2][i] = 0; move32(); @@ -619,7 +633,7 @@ void ivas_ism2sba_sf_fx( Word32 *tc_fx, *out_fx, gain_fx, prev_gain_fx; Word16 sba_num_chans; - assert( ( sba_order <= 3 ) && "Only order up to 3 is supported!" ); + assert( LE_16( sba_order, 3 ) && "Only order up to 3 is supported!" ); assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" ); /* Init*/ sba_num_chans = imult1616( add( sba_order, 1 ), add( sba_order, 1 ) ); @@ -641,7 +655,8 @@ void ivas_ism2sba_sf_fx( FOR( k = 0; k < n_samples_to_render; k++ ) { g1_fx = sub( 32767, *g2_fx ); - *( out_fx ) += Mult_32_32( ( Mult_32_16( gain_fx, ( *( g2_fx ) ) ) + Mult_32_16( prev_gain_fx, g1_fx ) ), ( *( tc_fx ) ) ); /*Q_buffer_in + 29 - 31*/ + *( out_fx ) = L_add( *( out_fx ), Mult_32_32( ( Mult_32_16( gain_fx, ( *( g2_fx ) ) ) + Mult_32_16( prev_gain_fx, g1_fx ) ), ( *( tc_fx ) ) ) ); /*Q_buffer_in + 29 - 31*/ + move32(); g2_fx++; tc_fx++; out_fx++; @@ -865,9 +880,9 @@ void ivas_sba_mix_matrix_determiner_fx( temp_fx = MAX16B; move32(); } - ELSE IF( LT_32( temp_fx, ( -1 * PCM16_TO_FLT_FAC_FX ) ) ) + ELSE IF( LT_32( temp_fx, L_negate( PCM16_TO_FLT_FAC_FX ) ) ) { - temp_fx = ( -1 * PCM16_TO_FLT_FAC_FX ); + temp_fx = L_negate( PCM16_TO_FLT_FAC_FX ); move32(); } temp_fx = Mult_32_32( MAX_32 / PCM16_TO_FLT_FAC_FX, L_shl( temp_fx, Q_p_output ) ); @@ -900,109 +915,6 @@ void ivas_sba_mix_matrix_determiner_fx( ivas_spar_dec_gen_umx_mat_fx( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, num_md_sub_frames ); return; } -#endif // IVAS_FLOAT_FIXED - -#ifdef IVAS_FLOAT_FIXED - -void ivas_sba_mix_matrix_determiner( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - float *output[], /* i/o: transport/output audio channels */ - const int16_t bfi, /* i : BFI flag */ - const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ - const int16_t output_frame, /* i : output frame length */ - const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix*/ -) -{ - int16_t i, ch; - float temp; - int16_t num_bands_out, nchan_transport, nchan_out; - - /* Convert numeric range */ - for ( ch = 0; ch < nchan_remapped; ch++ ) - { - for ( i = 0; i < output_frame; i++ ) - { - temp = output[ch][i]; - temp = floorf( temp + 0.5f ); - - if ( temp > MAX16B_FLT ) - { - temp = MAX16B_FLT; - } - else if ( temp < ( -1.0f * PCM16_TO_FLT_FAC ) ) - { - temp = ( -1.0f * PCM16_TO_FLT_FAC ); - } - temp *= ( 1.0f / PCM16_TO_FLT_FAC ); - output[ch][i] = temp; - } - } - - /* AGC */ - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - nchan_out = nchan_transport; -#ifndef IVAS_FLOAT_FIXED - ivas_agc_dec_process( hSpar->hAgcDec, output, output, nchan_transport, output_frame ); -#ifdef DUMPS_ENABLED - dbgwrite_txt( &output[0][0], output_frame, "flt_ivas_agc_dec_process_output.txt", NULL ); -#endif // DUMPS_ENABLED -#else - Word32 *output_fx[20]; - FOR( Word16 c = 0; c < nchan_transport; c++ ) - { - output_fx[c] = malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ); - FOR( Word16 j = 0; j < output_frame; j++ ) - { - output_fx[c][j] = (Word32) ( output[c][j] * ONE_IN_Q14 ); - } - } - - ivas_agc_dec_process_fx( hSpar->hAgcDec, ( output_fx ), ( output_fx ), nchan_transport, output_frame ); - - FOR( Word16 c = 0; c < nchan_transport; c++ ) - { - FOR( Word16 j = 0; j < output_frame; j++ ) - { - output[c][j] = (float) output_fx[c][j] / ONE_IN_Q11; - } - } - -#ifdef DUMPS_ENABLED - dbgwrite_txt( &output[0][0], output_frame, "fix_ivas_agc_dec_process_output.txt", NULL ); -#endif // DUMPS_ENABLED - - FOR( Word16 c = 0; c < nchan_transport; c++ ) - { - free( output_fx[c] ); - } -#endif // !IVAS_FLOAT_FIXED - - /* Convert numeric range back */ - for ( ch = 0; ch < nchan_out; ch++ ) - { - for ( i = 0; i < output_frame; i++ ) - { - output[ch][i] = output[ch][i] * PCM16_TO_FLT_FAC; - } - } - - /* Mixing matrix determiner */ - num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; -#ifdef IVAS_FLOAT_FIXED -#if 1 /*Float to fixed changes */ - // Word16 num_out_ch; - // num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - hSpar->hMdDec->Q_mixer_mat = 31; - // Word16 num_in_ch; - // num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#endif - ivas_spar_dec_gen_umx_mat_fx( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, num_md_sub_frames ); -#else - ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, num_md_sub_frames ); -#endif // IVAS_FLOAT_FIXED - - return; -} #else diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index 6c183fc07d96c369aa4a6b274ae743e32e47ec52..78ce1a71ab3f75504ae36c46a077ba6c724a0d5b 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -73,13 +73,17 @@ ivas_error ivas_sce_dec_fx( st = hSCE->hCoreCoder[0]; st->BER_detect = s_or( st->BER_detect, st_ivas->BER_detect ); + move16(); ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + move32(); last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; + move32(); IF( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) ) { st->cng_type = FD_CNG; + move16(); } /*------------------------------------------------------------------* @@ -87,52 +91,70 @@ ivas_error ivas_sce_dec_fx( *-----------------------------------------------------------------*/ /* set total_brate - needed in DTX */ + test(); + test(); + test(); + test(); IF( !st_ivas->bfi && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) { st->total_brate = L_sub( ivas_total_brate, L_shr( L_mult( nb_bits_metadata, FRAMES_PER_SEC ), 1 ) ); + move16(); + test(); assert( EQ_32( st->total_brate, SID_2k40 ) && "SCE SID must be 2.4kbps!" ); + test(); IF( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && NE_16( st_ivas->hISMDTX.sce_id_dtx, sce_id ) ) { st->total_brate = FRAME_NO_DATA; + move32(); } } ELSE IF( !st_ivas->bfi && EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) { st->total_brate = FRAME_NO_DATA; + move32(); } ELSE IF( !st_ivas->bfi && NE_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && LE_32( last_ivas_total_brate, IVAS_SID_5k2 ) ) { st->total_brate = L_sub( hSCE->element_brate, L_shr( L_mult( nb_bits_metadata, FRAMES_PER_SEC ), 1 ) ); + move32(); } /* read the bandwidth */ + test(); IF( st_ivas->bfi || LE_32( st->total_brate, SID_2k40 ) ) { /* BFI or SID/NO_DATA frame -> do nothing */ } ELSE { + test(); + test(); + test(); IF( st->low_rate_mode ) { /* ISM Low-rate mode -> always WB */ st->bwidth = WB; + move16(); } ELSE IF( LT_32( hSCE->element_brate, MIN_BRATE_SWB_SCE ) ) { /* only WB is supported */ st->bwidth = WB; + move16(); } ELSE IF( ( LT_32( hSCE->element_brate, MIN_BRATE_FB_STEREO ) && !st->is_ism_format ) || ( LT_32( hSCE->element_brate, MIN_BRATE_FB_ISM ) && st->is_ism_format ) ) { /* WB and SWB are supported */ st->bwidth = add( get_next_indice( st, 1 ), WB ); + move16(); } ELSE { /* WB, SWB and FB are supported */ st->bwidth = get_next_indice( st, NBITS_BWIDTH ); + move16(); } } @@ -141,59 +163,80 @@ ivas_error ivas_sce_dec_fx( *-----------------------------------------------------------------*/ st->idchan = 0; + move16(); st->element_mode = IVAS_SCE; + move16(); /* Force to MODE1 in IVAS */ st->codec_mode = MODE1; + move16(); /* set "bits_frame_nominal" */ + test(); IF( ( st_ivas->hQMetaData != NULL ) && NE_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) ) { + test(); + test(); + test(); + test(); IF( EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { st->bits_frame_nominal = extract_l( L_sub( Mpy_32_16_1( hSCE->element_brate, INV_FRAME_PER_SEC_Q15 ), ISM_NB_BITS_METADATA_NOMINAL ) ); + move16(); } ELSE IF( ( EQ_16( (Word16) st_ivas->mc_mode, MC_MODE_MCMASA ) && GE_32( ivas_total_brate, MCMASA_SEPARATE_BRATE ) ) || ( EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) ) { st->bits_frame_nominal = extract_l( Mpy_32_16_1( hSCE->element_brate, INV_FRAME_PER_SEC_Q15 ) ); + move16(); } ELSE IF( EQ_16( (Word16) st_ivas->ism_mode, ISM_MODE_NONE ) && EQ_16( (Word16) st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { st->bits_frame_nominal = extract_l( Mpy_32_16_1( st_ivas->hSpar->core_nominal_brate, INV_FRAME_PER_SEC_Q15 ) ); + move16(); } ELSE { st->bits_frame_nominal = st_ivas->hQMetaData->bits_frame_nominal; + move16(); } } ELSE IF( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) ) { st->bits_frame_nominal = extract_l( Mpy_32_16_1( st_ivas->hSpar->core_nominal_brate, INV_FRAME_PER_SEC_Q15 ) ); + move16(); } ELSE { st->bits_frame_nominal = extract_l( L_sub( Mpy_32_16_1( hSCE->element_brate, INV_FRAME_PER_SEC_Q15 ), ISM_NB_BITS_METADATA_NOMINAL ) ); + move16(); } /* set "total_brate" */ + test(); + test(); + test(); + test(); IF( !st_ivas->bfi && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) { st->total_brate = L_sub( ivas_total_brate, L_shr( L_mult( nb_bits_metadata, FRAMES_PER_SEC ), 1 ) ); - IF( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && NE_16( st_ivas->hISMDTX.sce_id_dtx, sce_id ) ) + if ( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && NE_16( st_ivas->hISMDTX.sce_id_dtx, sce_id ) ) { st->total_brate = FRAME_NO_DATA; + move32(); } } ELSE IF( !st_ivas->bfi && EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) { st->total_brate = ivas_total_brate; + move32(); } ELSE IF( !st_ivas->bfi && NE_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && NE_16( (Word16) st_ivas->ivas_format, MASA_ISM_FORMAT ) ) /* note: in ISMs, total_brate[] is set in ivas_ism_config() */ { st->total_brate = L_sub( hSCE->element_brate, L_shr( L_mult( nb_bits_metadata, FRAMES_PER_SEC ), 1 ) ); + move32(); } /*----------------------------------------------------------------* @@ -201,36 +244,52 @@ ivas_error ivas_sce_dec_fx( *----------------------------------------------------------------*/ /* set ACELP12k8 / ACELP16k flag for flexible ACELP core */ + test(); + test(); + test(); + test(); + test(); IF( ( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) || EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) && st->low_rate_mode && !( EQ_32( st->total_brate, SID_2k40 ) || EQ_32( st->total_brate, FRAME_NO_DATA ) ) ) { st->flag_ACELP16k = 0; + move16(); } ELSE { st->flag_ACELP16k = set_ACELP_flag_IVAS( IVAS_SCE, hSCE->element_brate, st->total_brate, 0, 0, -1, -1 ); + move16(); } IF( is_DTXrate( ivas_total_brate ) ) { st->VAD = 0; + move16(); } ELSE { st->VAD = 1; + move16(); } + + test(); + test(); + test(); IF( st->VAD && LE_32( hSCE->element_brate, CNA_MAX_BRATE ) ) { st->flag_cna = 1; + move16(); } ELSE IF( ( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( (Word16) st_ivas->ivas_format, MASA_FORMAT ) ) && LE_32( hSCE->element_brate, ACELP_32k ) ) { st->flag_cna = 1; + move16(); } ELSE { st->flag_cna = 0; + move16(); } /*----------------------------------------------------------------* @@ -239,7 +298,7 @@ ivas_error ivas_sce_dec_fx( set32_fx( output[0], 0, L_FRAME48k ); - IF( ( error = ivas_core_dec( st_ivas, hSCE, NULL, NULL, 1, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_core_dec( st_ivas, hSCE, NULL, NULL, 1, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ), IVAS_ERR_OK ) ) { return error; } @@ -249,12 +308,14 @@ ivas_error ivas_sce_dec_fx( /* skip addition of ACELP BWE for now, will be done after upmix */ Copy32( outputHB[0], hSCE->save_hb_synth_fx, output_frame ); hSCE->q_save_hb_synth_fx = Q11; + move16(); } ELSE IF( !st_ivas->sba_dirac_stereo_flag ) { Word32 output_Fs; output_Fs = st_ivas->hDecoderConfig->output_Fs; + move32(); /*----------------------------------------------------------------* * LB synthesis synchronization between IVAS formats @@ -280,8 +341,10 @@ ivas_error ivas_sce_dec_fx( *----------------------------------------------------------------*/ hSCE->last_element_brate = hSCE->element_brate; + move32(); st_ivas->BER_detect = s_or( st_ivas->BER_detect, st->BER_detect ); + move16(); pop_wmops(); @@ -307,6 +370,7 @@ ivas_error create_sce_dec( Word16 output_frame; error = IVAS_ERR_OK; + move16(); output_frame = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); /*-----------------------------------------------------------------* @@ -323,9 +387,11 @@ ivas_error create_sce_dec( *-----------------------------------------------------------------*/ hSCE->sce_id = sce_id; + move16(); hSCE->element_brate = element_brate; + move32(); - set32_fx( hSCE->prev_hb_synth_fx, 0, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, L_sub( IVAS_DEC_DELAY_NS, DELAY_BWE_TOTAL_NS ) ) ); + set32_fx( hSCE->prev_hb_synth_fx, 0, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) ); /*-----------------------------------------------------------------* * Core Coder, 1 instance: allocate and initialize @@ -340,39 +406,42 @@ ivas_error create_sce_dec( copy_decoder_config( st_ivas, st ); st->total_brate = hSCE->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */ + move32(); st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; + move16(); st->is_ism_format = 0; + move16(); st->ivas_format = st_ivas->ivas_format; - IF( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) || EQ_16( (Word16) st_ivas->ivas_format, MASA_ISM_FORMAT ) ) + move16(); + + test(); + if ( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) || EQ_16( (Word16) st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { st->is_ism_format = 1; + move16(); } // if (st_ivas->mode == IVAS_DEC_MODE_EVS) - if ( st->element_mode == EVS_MONO ) + IF( EQ_16( st->element_mode, EVS_MONO ) ) { error = init_decoder_fx( st, EVS_MONO ); - if ( error ) + IF( error ) { - { - return error; - } + return error; } } - else + ELSE { error = init_decoder_ivas_fx( st, 0, st_ivas->mc_mode ); - if ( error ) + IF( error ) { - { - return error; - } + return error; } } IF( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && EQ_16( st_ivas->nchan_transport, 1 ) ) ) ) { - IF( ( error = openCldfb_ivas_fx( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = openCldfb_ivas_fx( &st->cldfbSynHB, CLDFB_SYNTHESIS, st->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ), IVAS_ERR_OK ) ) { return error; } @@ -383,7 +452,7 @@ ivas_error create_sce_dec( } /* allocate and initialize "hTdCngDec" - needed in DTX */ - IF( EQ_16( sce_id, 0 ) && st->hTdCngDec == NULL ) + IF( ( sce_id == 0 ) && st->hTdCngDec == NULL ) { IF( ( st->hTdCngDec = (TD_CNG_DEC_HANDLE) malloc( sizeof( TD_CNG_DEC_DATA ) ) ) == NULL ) { @@ -405,6 +474,7 @@ ivas_error create_sce_dec( } set_zero_fx( hSCE->save_synth_fx, output_frame ); hSCE->q_save_synth_fx = 0; + move16(); IF( ( hSCE->save_hb_synth_fx = (Word32 *) malloc( sizeof( *( hSCE->save_hb_synth_fx ) ) * output_frame ) ) == NULL ) { @@ -412,6 +482,7 @@ ivas_error create_sce_dec( } set_zero_fx( hSCE->save_hb_synth_fx, output_frame ); hSCE->q_save_hb_synth_fx = 0; + move16(); } ELSE { diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index 342808ee27410c9509e32205a313dd36e44affad..8d5e1f007c38105182f43ccffccef6b68ee6a970 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -50,17 +50,19 @@ *-------------------------------------------------------------------*/ static void sns_1st_dec_fx( - const int16_t index, /* i : codebook index */ - const int16_t core, - const int16_t L_frame, + const Word16 index, /* i : codebook index */ + const Word16 core, + const Word16 L_frame, Word32 *snsq_fx /* i/o: i:prediction o:quantized sns */ ) { Word16 i; const Word16 *p_dico, *means; - const Word16 cdbk_fix = 8; // 1.f / powf( 2, SNS_CDBKS_BITS_4_FRAC ) in Q15 + const Word16 cdbk_fix = 8; // 1.f / powf( 2, SNS_CDBKS_BITS_4_FRAC ) in Q15 + move16(); const Word16 means_fix = 2; // 1.f / powf( 2, SNS_MEANS_BITS_4_FRAC ) in Q15 + move16(); means = NULL; SWITCH( L_frame ) @@ -79,18 +81,20 @@ static void sns_1st_dec_fx( } - p_dico = &sns_1st_cdbk[0][core - 1][0] + ( index % 32 ) * ( M / 2 ); + p_dico = &sns_1st_cdbk[0][core - 1][0] + i_mult( index % 32, ( M / 2 ) ); FOR( i = 0; i < M / 2; i++ ) { snsq_fx[i] = L_add( L_mult( ( *p_dico++ ), cdbk_fix ), L_mult( means[i], means_fix ) ); // Q16 + move32(); } - p_dico = &sns_1st_cdbk[1][core - 1][0] + ( index >> 5 ) * ( M / 2 ); + p_dico = &sns_1st_cdbk[1][sub( core, 1 )][0] + i_mult( shr( index, 5 ), ( M / 2 ) ); FOR( i = M / 2; i < M; i++ ) { snsq_fx[i] = L_add( L_mult( ( *p_dico++ ), cdbk_fix ), L_mult( means[i], means_fix ) ); + move32(); } return; @@ -109,28 +113,34 @@ static void sns_2st_dec_fx( { Word16 i; Word16 xq_fx[M]; - Word16 scale_fx = float_to_fix16( 0.400000006f, 15 ); + Word16 scale_fx = 13107; + move16(); /* quantize */ AVQ_dec_lpc( indx, xq_fx, 2 ); Word32 tmp = 0; + move32(); Word16 snsq_dIFf = 0; + move16(); Word32 tmp1; FOR( i = 0; i < M; i++ ) { tmp = L_mult( scale_fx, xq_fx[i] ); // q16 - IF( *q_snsq >= 16 ) + IF( GE_16( *q_snsq, 16 ) ) { - snsq_dIFf = *q_snsq - 16; + snsq_dIFf = sub( *q_snsq, 16 ); tmp1 = L_shr( snsq_fx[i], snsq_dIFf ); snsq_fx[i] = L_add( tmp1, tmp ); + move32(); *q_snsq = 16; + move16(); } ELSE { - snsq_dIFf = 16 - *q_snsq; + snsq_dIFf = sub( 16, *q_snsq ); tmp1 = L_shr( tmp, snsq_dIFf ); snsq_fx[i] = L_add( snsq_fx[i], tmp1 ); + move32(); } } return; @@ -142,45 +152,49 @@ static void sns_2st_dec_fx( *-------------------------------------------------------------------*/ void sns_avq_dec_fx( - int16_t *index, /* i : Quantization indices */ + Word16 *index, /* i : Quantization indices */ Word32 SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */ Word16 *q_snsq, - const int16_t L_frame, /* i : frame length */ - const int16_t numlpc /* i : Number of sets of lpc */ + const Word16 L_frame, /* i : frame length */ + const Word16 numlpc /* i : Number of sets of lpc */ ) { Word16 i, nbi, last; Word16 q_type; /* go from one-based indexing to zero-based indexing */ - last = numlpc - 1; + last = sub( numlpc, 1 ); index++; /* Decode last LPC */ sns_1st_dec_fx( *index++, numlpc, L_frame, SNS_Q[last] ); // Q16 *q_snsq = 16; + move16(); sns_2st_dec_fx( SNS_Q[last], q_snsq, index ); - nbi = 2 + index[0] + index[1]; + nbi = add( add( 2, index[0] ), index[1] ); index += nbi; /* Decode intermediate LPC (512 framing) */ - IF( numlpc == 2 ) + IF( EQ_16( numlpc, 2 ) ) { q_type = *index++; + move16(); IF( q_type == 0 ) { sns_1st_dec_fx( *index++, numlpc, L_frame, SNS_Q[0] ); *q_snsq = 16; + move16(); sns_2st_dec_fx( SNS_Q[0], q_snsq, index ); } - ELSE IF( q_type == 1 ) + ELSE IF( EQ_16( q_type, 1 ) ) { FOR( i = 0; i < M; i++ ) { SNS_Q[0][i] = SNS_Q[1][i]; + move32(); } sns_2st_dec_fx( SNS_Q[0], q_snsq, index ); } @@ -208,48 +222,69 @@ void sns_avq_dec_stereo_fx( Word32 mid_q_fx[M], side_q_fx[M]; stereo_mode = *indexl++; + move16(); + indexr++; Word16 tmp1 = 0, tmp2 = 0, q_mid = 0, q_side = 0; Word16 tmp_dIFf_q = 0; - IF( stereo_mode == 2 ) + move16(); + move16(); + move16(); + move16(); + move16(); + + IF( EQ_16( stereo_mode, 2 ) ) { /* MS coding */ tmp1 = *indexl++; + move16(); sns_1st_dec_fx( tmp1, TCX_20_CORE, L_frame, mid_q_fx ); q_mid = 16; + move16(); sns_2st_dec_fx( mid_q_fx, &q_mid, indexl ); FOR( i = 0; i < M; i++ ) { side_q_fx[i] = 0; + move32(); q_side = 31; + move16(); } - IF( *indexr++ == -1 ) + IF( EQ_16( *indexr++, -1 ) ) { sns_2st_dec_fx( side_q_fx, &q_side, indexr ); } Word32 tmp_c = 0; + move32(); FOR( i = 0; i < M; i++ ) { tmp_c = L_shr( side_q_fx[i], 1 ); // q_side - IF( q_mid >= q_side ) + IF( GE_16( q_mid, q_side ) ) { - tmp_dIFf_q = q_mid - q_side; + tmp_dIFf_q = sub( q_mid, q_side ); SNS_Ql[i] = L_add( L_shr( mid_q_fx[i], tmp_dIFf_q ), tmp_c ); // q_side + move32(); SNS_Qr[i] = L_sub( L_shr( mid_q_fx[i], tmp_dIFf_q ), tmp_c ); // q_side + move32(); *q_r = q_side; + move16(); *q_l = *q_r; + move16(); } ELSE { - tmp_dIFf_q = q_side - q_mid; + tmp_dIFf_q = sub( q_side, q_mid ); SNS_Ql[i] = L_add( mid_q_fx[i], L_shr( tmp_c, tmp_dIFf_q ) ); // q_mid + move32(); SNS_Qr[i] = L_sub( mid_q_fx[i], L_shr( tmp_c, tmp_dIFf_q ) ); // q_mid + move32(); *q_r = q_mid; + move16(); *q_l = *q_r; + move16(); } } } @@ -257,13 +292,17 @@ void sns_avq_dec_stereo_fx( { /* LR decoding */ tmp1 = *indexl++; + move16(); tmp2 = *indexr++; + move16(); sns_1st_dec_fx( tmp1, TCX_20_CORE, L_frame, SNS_Ql ); *q_l = 16; + move16(); sns_2st_dec_fx( SNS_Ql, q_l, indexl ); sns_1st_dec_fx( tmp2, TCX_20_CORE, L_frame, SNS_Qr ); *q_r = 16; + move16(); sns_2st_dec_fx( SNS_Qr, q_r, indexr ); } @@ -287,30 +326,50 @@ void dequantize_sns_fx( Decoder_State *st; sns_stereo_mode[0] = indices[0][0]; + move16(); sns_stereo_mode[1] = indices[0][1]; + move16(); zero_side_flag[0] = indices[0][2]; + move16(); zero_side_flag[1] = indices[0][3]; + move16(); FOR( ch = 0; ch < CPE_CHANNELS; ++ch ) { Word16 idxIndices; st = sts[ch]; - nSubframes = ( st->core == TCX_20_CORE ) ? 1 : NB_DIV; + nSubframes = NB_DIV; + move16(); + if ( EQ_16( st->core, TCX_20_CORE ) ) + { + nSubframes = 1; + move16(); + } + idxIndices = 0; + move16(); FOR( k = 0; k < nSubframes; ++k ) { - const Word16 is_side = ch == 1 && sns_stereo_mode[k] == SNS_STEREO_MODE_MS; + const Word16 is_side = EQ_16( ch, 1 ) && EQ_16( sns_stereo_mode[k], SNS_STEREO_MODE_MS ); + + const Word16 *const *cdbks_fx = EQ_16( nSubframes, 1 ) ? ivas_sns_cdbks_tcx20_fx : ivas_sns_cdbks_tcx10_fx; - const Word16 *const *cdbks_fx = ( nSubframes == 1 ) ? ivas_sns_cdbks_tcx20_fx : ivas_sns_cdbks_tcx10_fx; + Word16 nStages = SNS_MSVQ_NSTAGES_TCX10; + move16(); + + if ( EQ_16( nSubframes, 1 ) ) + { + nStages = SNS_MSVQ_NSTAGES_TCX20; + move16(); + } - Word16 nStages = ( ( nSubframes == 1 ) ? SNS_MSVQ_NSTAGES_TCX20 : SNS_MSVQ_NSTAGES_TCX10 ); Word32 *snsQ_fx = snsQ_out_fx[ch][k]; IF( is_side ) { - const Word16 *const *side_cdbks_fx = ( st->core == TCX_20_CORE ) ? ivas_sns_cdbks_side_tcx20_fx : ivas_sns_cdbks_side_tcx10_fx; + const Word16 *const *side_cdbks_fx = EQ_16( st->core, TCX_20_CORE ) ? ivas_sns_cdbks_side_tcx20_fx : ivas_sns_cdbks_side_tcx10_fx; IF( zero_side_flag[k] ) { @@ -319,19 +378,26 @@ void dequantize_sns_fx( } nStages = SNS_MSVQ_NSTAGES_SIDE; - msvq_dec_fx( side_cdbks_fx, NULL, NULL, nStages, M, M, &indices[ch][idxIndices + SNS_STEREO_MODE_OFFSET_INDICES], 0, NULL, snsQ_fx, NULL, 15 ); // always 15 + move16(); + msvq_dec_fx( side_cdbks_fx, NULL, NULL, nStages, M, M, &indices[ch][add( idxIndices, SNS_STEREO_MODE_OFFSET_INDICES )], 0, NULL, snsQ_fx, NULL, 15 ); // always 15 } ELSE { - msvq_dec_fx( cdbks_fx, NULL, NULL, nStages, M, M, &indices[ch][idxIndices + SNS_STEREO_MODE_OFFSET_INDICES], 0, NULL, snsQ_fx, NULL, 12 ); + msvq_dec_fx( cdbks_fx, NULL, NULL, nStages, M, M, &indices[ch][add( idxIndices, SNS_STEREO_MODE_OFFSET_INDICES )], 0, NULL, snsQ_fx, NULL, 12 ); } - idxIndices += nStages; + idxIndices = add( idxIndices, nStages ); } } - IF( sns_stereo_mode[0] == SNS_STEREO_MODE_MS || sns_stereo_mode[1] == SNS_STEREO_MODE_MS ) + IF( EQ_16( sns_stereo_mode[0], SNS_STEREO_MODE_MS ) || EQ_16( sns_stereo_mode[1], SNS_STEREO_MODE_MS ) ) { - nSubframes = ( sts[0]->core == TCX_20_CORE ) ? 1 : NB_DIV; + nSubframes = NB_DIV; + move16(); + if ( EQ_16( sts[0]->core, TCX_20_CORE ) ) + { + nSubframes = 1; + move16(); + } FOR( k = 0; k < nSubframes; ++k ) { IF( sns_stereo_mode[k] == SNS_STEREO_MODE_MS ) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7ca71ffb217879070d5b1c48f7892e8ea295286a..62b92ebb79b5e3de84eaf36b11355724b7f828d6 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -294,7 +294,7 @@ void IVAS_DEC_Close( IF( ( *phIvasDec )->st_ivas ) { - ivas_destroy_dec( ( *phIvasDec )->st_ivas ); + ivas_destroy_dec_fx( ( *phIvasDec )->st_ivas ); ( *phIvasDec )->st_ivas = NULL; } diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index 8289708dfdf41001570836fbad75bfea76227047..a094559538449474145f5ffc5b414047ffc4a132 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -51,8 +51,9 @@ * Local function prototypes *---------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void sincResample( const float *input, float *output, const int16_t length_in, const int16_t length_out ); -#ifdef IVAS_FLOAT_FIXED +#else static void sincResample_fx( const Word32 *input_fx, Word32 *output_fx, const Word16 length_in, const Word16 length_out ); #endif @@ -61,6 +62,7 @@ static void sincResample_fx( const Word32 *input_fx, Word32 *output_fx, const Wo * * Apply ITD by delaying late channel *---------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void TDREND_Apply_ITD( float *input, /* i : Input subframe to be time adjusted */ float *out_left, /* o : Output left channel with ITD applied */ @@ -161,7 +163,7 @@ void TDREND_Apply_ITD( return; } -#ifdef IVAS_FLOAT_FIXED +#else void TDREND_Apply_ITD_fx( Word32 *input_fx, /* i : Input subframe to be time adjusted Qx */ Word32 *out_left_fx, /* o : Output left channel with ITD applied Qx */ @@ -283,6 +285,7 @@ void TDREND_Apply_ITD_fx( * The sinc resampling reads SFX_SPAT_BIN_SINC_M (5) samples outside of * the target frame. *---------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED static void sincResample( const float *input, /*i : Input signal */ float *output, /*o : Output signal */ @@ -347,7 +350,7 @@ static void sincResample( return; } -#ifdef IVAS_FLOAT_FIXED +#else static void sincResample_fx( const Word32 *input_fx, /*i : Input signal Qx */ Word32 *output_fx, /*o : Output signal Qx */ diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 0df7c7b7bfe266157d1612988347ab7742cb65a6..0334bdc33e52ba22179c127a813a1a452114ef49 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -2274,9 +2274,15 @@ ivas_error ivas_headTrack_open( ); #endif +#ifndef IVAS_FLOAT_FIXED void ivas_headTrack_close( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ); +#else +void ivas_headTrack_close_fx( + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ +); +#endif void Euler2Quat( const float yaw, /* i : yaw (x) */ @@ -2471,21 +2477,29 @@ ivas_error ivas_external_orientation_open( EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData, /* o : external orientation handle */ const int16_t num_subframes /* i : number of subframes */ ); - +#ifndef IVAS_FLOAT_FIXED void ivas_external_orientation_close( EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData /* i/o: external orientation handle */ ); - +#else +void ivas_external_orientation_close_fx( + EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData /* i/o: external orientation handle */ +); +#endif ivas_error ivas_combined_orientation_open( COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* o : combined orientation handle */ const int32_t fs, /* i : sampling rate */ const int16_t num_subframes /* i : number of subframes */ ); - +#ifndef IVAS_FLOAT_FIXED void ivas_combined_orientation_close( COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* i/o: combined orientation handle */ ); - +#else +void ivas_combined_orientation_close_fx( + COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* i/o: combined orientation handle */ +); +#endif ivas_error combine_external_and_head_orientations_dec( HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ diff --git a/lib_rend/ivas_rom_binaural_crend_head.c b/lib_rend/ivas_rom_binaural_crend_head.c index efb3c568c694d1ef48c7d58db4dd7e80af378480..a34162e4919cc87244f19e09a8a7fa475ab1a5c6 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.c +++ b/lib_rend/ivas_rom_binaural_crend_head.c @@ -53,9 +53,9 @@ /********************** CRendBin_Combined_HRIR **********************/ +#ifndef IVAS_FLOAT_FIXED const float CRendBin_Combined_HRIR_latency_s = 0.000020834f; - -#ifdef IVAS_FLOAT_FIXED +#else const Word32 CRendBin_Combined_HRIR_latency_s_fx = 44741;/*Q-31*/ #endif // IVAS_FLOAT_FIXED /* Sample Rate = 48000 */ @@ -65,11 +65,13 @@ const uint16_t CRendBin_Combined_HRIR_num_iterations_48kHz[15][BINAURAL_CHANNELS const uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; const uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz = 0; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz[15]={0, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; -#ifdef IVAS_FLOAT_FIXED +#else const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz_fx[15]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; #endif const uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_Combined_HRIR_coeff_re_48kHz[15][BINAURAL_CHANNELS][240]={ { {1.101488f, 1.121686f, 1.165024f, 1.224338f, 1.257855f, 1.220486f, 1.149240f, 1.140890f, 1.185728f, 1.128055f, 0.902355f, 0.707875f, 0.788108f, 1.099541f, 1.375119f, 1.484928f, 1.549978f, 1.695559f, 1.876431f, 1.995635f, 2.041427f, 2.028898f, 1.921455f, 1.700966f, 1.448293f, 1.277519f, 1.224020f, 1.244684f, 1.297952f, 1.382592f, 1.515360f, 1.701068f, 1.918656f, 2.122718f, 2.265994f, 2.329628f, 2.329558f, 2.294332f, 2.241762f, 2.173492f, 2.084598f, 1.978110f, 1.871591f, 1.786593f, 1.731800f, 1.700143f, 1.679095f, 1.656899f, 1.622424f, 1.569381f, 1.502234f, 1.432448f, 1.368773f, 1.314020f, 1.268340f, 1.231321f, 1.202278f, 1.180534f, 1.163747f, 1.146145f, 1.121645f, 1.087903f, 1.043613f, 0.983612f, 0.901864f, 0.798972f, 0.683390f, 0.566766f, 0.461005f, 0.376682f, 0.319308f, 0.287365f, 0.275856f, 0.280196f, 0.295624f, 0.315889f, 0.334947f, 0.349113f, 0.357350f, 0.360958f, 0.362742f, 0.364984f, 0.368682f, 0.375343f, 0.387569f, 0.406700f, 0.431922f, 0.462716f, 0.499762f, 0.542220f, 0.586337f, 0.627805f, 0.663761f, 0.692071f, 0.710593f, 0.717887f, @@ -316,7 +318,7 @@ const float CRendBin_Combined_HRIR_coeff_im_48kHz[15][BINAURAL_CHANNELS][240]={ }; const float *CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float *CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; #endif @@ -327,11 +329,13 @@ const uint16_t CRendBin_Combined_HRIR_num_iterations_32kHz[15][BINAURAL_CHANNELS const uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; const uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz = 0; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz[15]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; -#ifdef IVAS_FLOAT_FIXED +#else const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz_fx[15]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; #endif const uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_Combined_HRIR_coeff_re_32kHz[15][BINAURAL_CHANNELS][160]={ { {1.274160f, 1.294020f, 1.337410f, 1.397007f, 1.430345f, 1.392644f, 1.321540f, 1.313359f, 1.357865f, 1.299918f, 1.074412f, 0.879944f, 0.959736f, 1.270988f, 1.546758f, 1.656396f, 1.720956f, 1.866458f, 2.047459f, 2.166309f, 2.211621f, 2.199100f, 2.091661f, 1.870665f, 1.617573f, 1.446851f, 1.393188f, 1.413236f, 1.466179f, 1.550859f, 1.683267f, 1.868310f, 2.085674f, 2.289697f, 2.432421f, 2.495403f, 2.495189f, 2.459782f, 2.406497f, 2.337636f, 2.248632f, 2.141773f, 2.034425f, 1.948929f, 1.893998f, 1.861756f, 1.839825f, 1.817228f, 1.782513f, 1.728672f, 1.660650f, 1.590534f, 1.526449f, 1.470717f, 1.424223f, 1.386891f, 1.357216f, 1.334362f, 1.316849f, 1.298879f, 1.273497f, 1.238579f, 1.193651f, 1.133144f, 1.050266f, 0.946198f, 0.830030f, 0.712686f, 0.605579f, 0.520129f, 0.462158f, 0.429220f, 0.416204f, 0.419491f, 0.434223f, 0.453184f, 0.470641f, 0.483821f, 0.491166f, 0.493159f, 0.493315f, 0.494589f, 0.497104f, 0.501870f, 0.512491f, 0.530588f, 0.554259f, 0.582935f, 0.618415f, 0.659661f, 0.701812f, 0.741007f, 0.775413f, 0.802205f, 0.818331f, 0.823262f, @@ -518,7 +522,7 @@ const float CRendBin_Combined_HRIR_coeff_im_32kHz[15][BINAURAL_CHANNELS][160]={ }; const float *CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float *CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; #endif @@ -529,11 +533,13 @@ const uint16_t CRendBin_Combined_HRIR_num_iterations_16kHz[15][BINAURAL_CHANNELS const uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; const uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz = 0; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz[15]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; -#ifdef IVAS_FLOAT_FIXED +#else const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz_fx[15]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; #endif const uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_Combined_HRIR_coeff_re_16kHz[15][BINAURAL_CHANNELS][80]={ { { 1.239183f, 1.256884f, 1.300573f, 1.362041f, 1.394364f, 1.354510f, 1.284249f, 1.277360f, 1.319933f, 1.260104f, 1.035831f, 0.841818f, 0.918943f, 1.228789f, 1.505938f, 1.615001f, 1.676409f, 1.821102f, 2.003314f, 2.120456f, 2.162423f, 2.149697f, 2.042953f, 1.819108f, 1.562774f, 1.392343f, 1.338502f, 1.354661f, 1.404734f, 1.489962f, 1.620994f, 1.801308f, 2.016368f, 2.220843f, 2.360726f, 2.418417f, 2.416549f, 2.381039f, 2.323273f, 2.248889f, 2.158818f, 2.050759f, 1.937222f, 1.846306f, 1.790643f, 1.755504f, 1.725726f, 1.698099f, 1.662521f, 1.603450f, 1.526080f, 1.451493f, 1.385684f, 1.321724f, 1.264611f, 1.223329f, 1.190008f, 1.155210f, 1.126054f, 1.104272f, 1.071790f, 1.020334f, 0.962879f, 0.897728f, 0.801926f, 0.675382f, 0.545582f, 0.420598f, 0.290433f, 0.173783f, 0.099765f, 0.050651f, -0.006501f, -0.051832f, -0.062025f, -0.095855f, -0.220501f, -0.379318f, -0.456547f, -0.451019f}, @@ -660,7 +666,7 @@ const float CRendBin_Combined_HRIR_coeff_im_16kHz[15][BINAURAL_CHANNELS][80]={ }; const float *CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; #endif @@ -669,8 +675,9 @@ const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS /********************** CRendBin_FOA_HRIR **********************/ +#ifndef IVAS_FLOAT_FIXED const float CRendBin_FOA_HRIR_latency_s = 0.000020834f; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 CRendBin_FOA_HRIR_latency_s_fx = 44741; #endif // IVAS_FLOAT_FIXED @@ -681,11 +688,13 @@ const uint16_t CRendBin_FOA_HRIR_num_iterations_48kHz[4][BINAURAL_CHANNELS]={{1, const uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[4][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; const uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz = 0; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz[4]={0.000000f, 0.000000f, 0.000000f, 0.000000f}; -#ifdef IVAS_FLOAT_FIXED +#else const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz_fx[4]={0, 0, 0, 0}; #endif const uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_FOA_HRIR_coeff_re_48kHz[4][BINAURAL_CHANNELS][240]={ { {0.966218f, 0.733332f, 0.371154f, 0.013886f, -0.255271f, -0.429740f, -0.543550f, -0.621345f, -0.659916f, -0.644001f, -0.568080f, -0.442479f, -0.285885f, -0.117060f, 0.048289f, 0.198155f, 0.325513f, 0.429363f, 0.513050f, 0.580002f, 0.630568f, 0.663334f, 0.679201f, 0.682684f, 0.678369f, 0.667227f, 0.647704f, 0.619700f, 0.585896f, 0.549425f, 0.511893f, 0.474018f, 0.436790f, 0.401079f, 0.366792f, 0.333238f, 0.300207f, 0.268253f, 0.237980f, 0.209327f, 0.181631f, 0.154220f, 0.126862f, 0.099653f, 0.072728f, 0.046213f, 0.020311f, -0.004833f, -0.029303f, -0.053269f, -0.076722f, -0.099506f, -0.121536f, -0.142793f, -0.163190f, -0.182595f, -0.200971f, -0.218400f, -0.234976f, -0.250747f, -0.265719f, -0.279920f, -0.293435f, -0.306316f, -0.318471f, -0.329791f, -0.340363f, -0.350414f, -0.360064f, -0.369343f, -0.378409f, -0.387487f, -0.396622f, -0.405768f, -0.415062f, -0.424742f, -0.434871f, -0.445428f, -0.456546f, -0.468369f, -0.480767f, -0.493503f, -0.506517f, -0.519763f, -0.532917f, -0.545542f, -0.557444f, -0.568682f, -0.579373f, -0.589605f, -0.599351f, -0.608366f, -0.616332f, -0.623173f, -0.629056f, -0.634137f, @@ -756,7 +765,7 @@ const float CRendBin_FOA_HRIR_coeff_im_48kHz[4][BINAURAL_CHANNELS][240]={ }; const float *CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float *CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; #endif @@ -767,11 +776,13 @@ const uint16_t CRendBin_FOA_HRIR_num_iterations_32kHz[4][BINAURAL_CHANNELS]={{1, const uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[4][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; const uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz = 0; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz[4]={0.000000f, 0.000000f, 0.000000f, 0.000000f}; -#ifdef IVAS_FLOAT_FIXED +#else const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz_fx[4]={0, 0, 0, 0}; #endif const uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_FOA_HRIR_coeff_re_32kHz[4][BINAURAL_CHANNELS][160]={ { {1.009979f, 0.777112f, 0.414923f, 0.057622f, -0.211538f, -0.386004f, -0.499848f, -0.577684f, -0.616265f, -0.600367f, -0.524501f, -0.398947f, -0.242372f, -0.073587f, 0.091690f, 0.241505f, 0.368831f, 0.472616f, 0.556219f, 0.623114f, 0.673631f, 0.706309f, 0.722082f, 0.725502f, 0.721116f, 0.709865f, 0.690241f, 0.662164f, 0.628264f, 0.591665f, 0.554026f, 0.516064f, 0.478714f, 0.442859f, 0.408459f, 0.374798f, 0.341619f, 0.309511f, 0.279115f, 0.250331f, 0.222462f, 0.194888f, 0.167394f, 0.140026f, 0.112906f, 0.086220f, 0.060166f, 0.034831f, 0.010148f, -0.013999f, -0.037628f, -0.060633f, -0.082892f, -0.104342f, -0.124944f, -0.144600f, -0.163218f, -0.180856f, -0.197673f, -0.213722f, -0.228947f, -0.243382f, -0.257175f, -0.270358f, -0.282781f, -0.294366f, -0.305254f, -0.315630f, -0.325566f, -0.335147f, -0.344568f, -0.353990f, -0.363436f, -0.372929f, -0.382614f, -0.392659f, -0.403132f, -0.414084f, -0.425629f, -0.437840f, -0.450624f, -0.463808f, -0.477282f, -0.490945f, -0.504537f, -0.517665f, -0.530059f, -0.541752f, -0.552944f, -0.563732f, -0.574004f, -0.583524f, -0.592061f, -0.599512f, -0.605962f, -0.611610f, @@ -826,7 +837,7 @@ const float CRendBin_FOA_HRIR_coeff_im_32kHz[4][BINAURAL_CHANNELS][160]={ }; const float *CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float *CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; #endif @@ -837,11 +848,13 @@ const uint16_t CRendBin_FOA_HRIR_num_iterations_16kHz[4][BINAURAL_CHANNELS]={{1, const uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[4][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; const uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz = 0; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz[4]={0.000000f, 0.000000f, 0.000000f, 0.000000f}; -#ifdef IVAS_FLOAT_FIXED +#else const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz_fx[4]={0, 0, 0, 0}; #endif const uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_FOA_HRIR_coeff_re_16kHz[4][BINAURAL_CHANNELS][80]={ { { 1.066299f, 0.831753f, 0.469820f, 0.113997f, -0.155945f, -0.332046f, -0.445167f, -0.521969f, -0.562027f, -0.547501f, -0.470580f, -0.344643f, -0.190080f, -0.022238f, 0.144217f, 0.293618f, 0.418613f, 0.521970f, 0.606614f, 0.672232f, 0.720345f, 0.753099f, 0.769493f, 0.770796f, 0.764174f, 0.753391f, 0.733696f, 0.702773f, 0.667010f, 0.631061f, 0.592423f, 0.551074f, 0.512366f, 0.477047f, 0.440550f, 0.403206f, 0.369206f, 0.337153f, 0.303479f, 0.270983f, 0.242735f, 0.214328f, 0.182386f, 0.151528f, 0.124233f, 0.095401f, 0.063829f, 0.035419f, 0.010359f, -0.017668f, -0.047701f, -0.073299f, -0.096723f, -0.124198f, -0.151868f, -0.173748f, -0.195138f, -0.221363f, -0.245696f, -0.264016f, -0.284769f, -0.310840f, -0.332497f, -0.348925f, -0.371386f, -0.398406f, -0.417735f, -0.434354f, -0.462032f, -0.492418f, -0.512100f, -0.536134f, -0.579084f, -0.619428f, -0.648156f, -0.709398f, -0.814740f, -0.869114f, -0.792023f, -0.672661f}, @@ -880,7 +893,7 @@ const float CRendBin_FOA_HRIR_coeff_im_16kHz[4][BINAURAL_CHANNELS][80]={ }; const float *CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float *CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; #endif @@ -888,8 +901,9 @@ const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NU /********************** CRendBin_HOA2_HRIR **********************/ +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA2_HRIR_latency_s = 0.000020834f; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 CRendBin_HOA2_HRIR_latency_s_fx = 44741; #endif // IVAS_FLOAT_FIXED @@ -900,11 +914,13 @@ const uint16_t CRendBin_HOA2_HRIR_num_iterations_48kHz[9][BINAURAL_CHANNELS]={{1 const uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[9][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; const uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz = 0; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz[9]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; -#ifdef IVAS_FLOAT_FIXED +#else const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz_fx[9]={0, 0, 0, 0, 0, 0, 0, 0, 0}; #endif const uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA2_HRIR_coeff_re_48kHz[9][BINAURAL_CHANNELS][240]={ { {0.955467f, 0.635681f, 0.166653f, -0.248686f, -0.508651f, -0.626077f, -0.650285f, -0.604530f, -0.488417f, -0.308510f, -0.090053f, 0.133390f, 0.331939f, 0.484574f, 0.581273f, 0.623235f, 0.619217f, 0.579562f, 0.512138f, 0.422298f, 0.315745f, 0.200824f, 0.086720f, -0.021278f, -0.123379f, -0.220908f, -0.311538f, -0.390400f, -0.454756f, -0.505495f, -0.544554f, -0.573087f, -0.592353f, -0.604514f, -0.611652f, -0.614839f, -0.614702f, -0.612258f, -0.608712f, -0.604725f, -0.600146f, -0.594359f, -0.586798f, -0.577264f, -0.565860f, -0.552745f, -0.538040f, -0.521885f, -0.504388f, -0.485535f, -0.465319f, -0.443966f, -0.421881f, -0.399382f, -0.376688f, -0.354132f, -0.332145f, -0.310934f, -0.290358f, -0.270218f, -0.250519f, -0.231307f, -0.212442f, -0.193768f, -0.175388f, -0.157519f, -0.140147f, -0.123115f, -0.106462f, -0.090326f, -0.074575f, -0.058912f, -0.043292f, -0.027843f, -0.012429f, 0.003258f, 0.019199f, 0.035158f, 0.051271f, 0.067966f, 0.085226f, 0.102477f, 0.119366f, 0.136149f, 0.153084f, 0.169846f, 0.185867f, 0.201051f, 0.215857f, 0.230656f, 0.245156f, 0.258620f, 0.270655f, 0.281594f, 0.291923f, 0.301545f, @@ -1055,7 +1071,7 @@ const float CRendBin_HOA2_HRIR_coeff_im_48kHz[9][BINAURAL_CHANNELS][240]={ }; const float *CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float *CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; #endif @@ -1066,11 +1082,13 @@ const uint16_t CRendBin_HOA2_HRIR_num_iterations_32kHz[9][BINAURAL_CHANNELS]={{1 const uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[9][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; const uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz = 0; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz[9]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; -#ifdef IVAS_FLOAT_FIXED +#else const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz_fx[9]={0, 0, 0, 0, 0, 0, 0, 0, 0}; #endif const uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA2_HRIR_coeff_re_32kHz[9][BINAURAL_CHANNELS][160]={ { {0.897602f, 0.577826f, 0.108806f, -0.306523f, -0.566468f, -0.683867f, -0.708050f, -0.662267f, -0.546112f, -0.366162f, -0.147663f, 0.075830f, 0.274439f, 0.427135f, 0.523893f, 0.565927f, 0.561989f, 0.522411f, 0.455067f, 0.365320f, 0.258865f, 0.144039f, 0.030037f, -0.077847f, -0.179832f, -0.277247f, -0.367752f, -0.446478f, -0.510700f, -0.561304f, -0.600215f, -0.628591f, -0.647703f, -0.659706f, -0.666671f, -0.669681f, -0.669369f, -0.666740f, -0.662997f, -0.658812f, -0.654035f, -0.648036f, -0.640253f, -0.630498f, -0.618870f, -0.605516f, -0.590564f, -0.574163f, -0.556413f, -0.537291f, -0.516802f, -0.495178f, -0.472808f, -0.450009f, -0.427015f, -0.404157f, -0.381849f, -0.360307f, -0.339403f, -0.318926f, -0.298870f, -0.279294f, -0.260068f, -0.241018f, -0.222243f, -0.203976f, -0.186205f, -0.168754f, -0.151665f, -0.135094f, -0.118902f, -0.102773f, -0.086674f, -0.070750f, -0.054844f, -0.038640f, -0.022176f, -0.005693f, 0.010967f, 0.028233f, 0.046067f, 0.063897f, 0.081395f, 0.098808f, 0.116372f, 0.133779f, 0.150477f, 0.166354f, 0.181854f, 0.197372f, 0.212626f, 0.226853f, 0.239657f, 0.251401f, 0.262567f, 0.273031f, @@ -1185,7 +1203,7 @@ const float CRendBin_HOA2_HRIR_coeff_im_32kHz[9][BINAURAL_CHANNELS][160]={ }; const float *CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float *CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; #endif @@ -1196,11 +1214,13 @@ const uint16_t CRendBin_HOA2_HRIR_num_iterations_16kHz[9][BINAURAL_CHANNELS]={{1 const uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[9][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; const uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz = 0; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz[9]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; -#ifdef IVAS_FLOAT_FIXED +#else const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz_fx[9]={0, 0, 0, 0, 0, 0, 0, 0, 0}; #endif const uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA2_HRIR_coeff_re_16kHz[9][BINAURAL_CHANNELS][80]={ { { 0.854113f, 0.536451f, 0.067092f, -0.350133f, -0.609131f, -0.724504f, -0.749647f, -0.705240f, -0.587299f, -0.405686f, -0.188603f, 0.034290f, 0.235326f, 0.389114f, 0.484257f, 0.526650f, 0.525509f, 0.486339f, 0.417501f, 0.329156f, 0.225561f, 0.110464f, -0.004565f, -0.110029f, -0.209397f, -0.307633f, -0.398358f, -0.473786f, -0.535896f, -0.587622f, -0.625653f, -0.650087f, -0.667773f, -0.680841f, -0.685616f, -0.684346f, -0.683354f, -0.681293f, -0.673940f, -0.665480f, -0.660678f, -0.654254f, -0.641454f, -0.627762f, -0.616498f, -0.601208f, -0.579959f, -0.560224f, -0.542768f, -0.519685f, -0.491848f, -0.467631f, -0.444806f, -0.415518f, -0.384419f, -0.359637f, -0.335182f, -0.304116f, -0.274642f, -0.252517f, -0.227297f, -0.194558f, -0.166484f, -0.145123f, -0.116152f, -0.080136f, -0.053083f, -0.030604f, 0.005387f, 0.046361f, 0.073460f, 0.102702f, 0.155814f, 0.209408f, 0.244378f, 0.309617f, 0.442675f, 0.565949f, 0.579052f, 0.523768f}, @@ -1279,7 +1299,7 @@ const float CRendBin_HOA2_HRIR_coeff_im_16kHz[9][BINAURAL_CHANNELS][80]={ }; const float *CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float *CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; #endif @@ -1287,9 +1307,9 @@ const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={N /********************** CRendBin_HOA3_HRIR **********************/ +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA3_HRIR_latency_s = 0.000020834f; - -#ifdef IVAS_FLOAT_FIXED +#else const Word32 CRendBin_HOA3_HRIR_latency_s_fx = 44741;/*Q-31*/ #endif /* Sample Rate = 48000 */ @@ -1299,11 +1319,13 @@ const uint16_t CRendBin_HOA3_HRIR_num_iterations_48kHz[16][BINAURAL_CHANNELS]={{ const uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[16][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; const uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz = 0; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[16]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; -#ifdef IVAS_FLOAT_FIXED +#else const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz_fx[16]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; #endif const uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA3_HRIR_coeff_re_48kHz[16][BINAURAL_CHANNELS][240]={ { {0.975460f, 0.823508f, 0.578722f, 0.311394f, 0.071393f, -0.117298f, -0.265803f, -0.406443f, -0.536876f, -0.603591f, -0.568995f, -0.446021f, -0.232011f, 0.098533f, 0.446049f, 0.539124f, 0.219489f, -0.255318f, -0.399037f, -0.041354f, 0.472264f, 0.693368f, 0.533266f, 0.219305f, -0.059008f, -0.291241f, -0.505715f, -0.670083f, -0.755827f, -0.790827f, -0.808813f, -0.807132f, -0.777516f, -0.733727f, -0.690346f, -0.645074f, -0.594162f, -0.543258f, -0.496359f, -0.450603f, -0.404959f, -0.361817f, -0.320310f, -0.277796f, -0.235759f, -0.196817f, -0.159540f, -0.122007f, -0.085990f, -0.053099f, -0.021484f, 0.010278f, 0.040672f, 0.068775f, 0.095789f, 0.121856f, 0.145524f, 0.166807f, 0.187076f, 0.206251f, 0.223418f, 0.239269f, 0.254992f, 0.270072f, 0.283633f, 0.296367f, 0.309129f, 0.321380f, 0.332609f, 0.343518f, 0.354653f, 0.365577f, 0.376080f, 0.386687f, 0.397603f, 0.408487f, 0.419268f, 0.430118f, 0.440990f, 0.451887f, 0.462914f, 0.473622f, 0.483318f, 0.492236f, 0.501131f, 0.509707f, 0.516930f, 0.522835f, 0.528471f, 0.534052f, 0.538627f, 0.541575f, 0.543261f, 0.544286f, 0.544970f, 0.545324f, @@ -1566,7 +1588,7 @@ const float CRendBin_HOA3_HRIR_coeff_im_48kHz[16][BINAURAL_CHANNELS][240]={ }; const float *CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float *CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; #endif @@ -1577,11 +1599,13 @@ const uint16_t CRendBin_HOA3_HRIR_num_iterations_32kHz[16][BINAURAL_CHANNELS]={{ const uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; const uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[16][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; const uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz = 0; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[16]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; -#ifdef IVAS_FLOAT_FIXED +#else const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz_fx[16]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; #endif const uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA3_HRIR_coeff_re_32kHz[16][BINAURAL_CHANNELS][160]={ { {0.931532f, 0.779586f, 0.534806f, 0.267486f, 0.027500f, -0.161171f, -0.309658f, -0.450275f, -0.580679f, -0.647362f, -0.612734f, -0.489723f, -0.275668f, 0.054919f, 0.402480f, 0.495609f, 0.176032f, -0.298719f, -0.442377f, -0.084625f, 0.429064f, 0.650237f, 0.490213f, 0.176336f, -0.101893f, -0.334041f, -0.548421f, -0.712689f, -0.798336f, -0.833235f, -0.851109f, -0.849315f, -0.819587f, -0.775679f, -0.732168f, -0.686769f, -0.635729f, -0.584686f, -0.537641f, -0.491741f, -0.445951f, -0.402650f, -0.360980f, -0.318308f, -0.276103f, -0.236981f, -0.199525f, -0.161814f, -0.125607f, -0.092516f, -0.060704f, -0.028744f, 0.001865f, 0.030189f, 0.057418f, 0.083709f, 0.107616f, 0.129141f, 0.149647f, 0.169072f, 0.186505f, 0.202619f, 0.218604f, 0.233964f, 0.247817f, 0.260837f, 0.273890f, 0.286455f, 0.298003f, 0.309223f, 0.320684f, 0.331955f, 0.342805f, 0.353754f, 0.365034f, 0.376301f, 0.387457f, 0.398686f, 0.409965f, 0.421281f, 0.432717f, 0.443847f, 0.453997f, 0.463372f, 0.472714f, 0.481764f, 0.489489f, 0.495891f, 0.502022f, 0.508134f, 0.513263f, 0.516755f, 0.518993f, 0.520614f, 0.521907f, 0.522857f, @@ -1780,7 +1804,7 @@ const float CRendBin_HOA3_HRIR_coeff_im_32kHz[16][BINAURAL_CHANNELS][160]={ }; const float *CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float *CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; #endif @@ -1796,6 +1820,7 @@ const float CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[16]={0.000000f, 0.000000 const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz_fx[16]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; #endif const uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA3_HRIR_coeff_re_16kHz[16][BINAURAL_CHANNELS][80]={ { { 0.883857f, 0.733415f, 0.488407f, 0.219765f, -0.019522f, -0.206727f, -0.355857f, -0.497398f, -0.626479f, -0.691928f, -0.658239f, -0.535571f, -0.319712f, 0.011730f, 0.358242f, 0.451741f, 0.134258f, -0.340096f, -0.484683f, -0.125786f, 0.390069f, 0.611189f, 0.450608f, 0.138633f, -0.137573f, -0.370128f, -0.584446f, -0.746152f, -0.830104f, -0.865577f, -0.882556f, -0.877705f, -0.846732f, -0.803300f, -0.757904f, -0.709171f, -0.657369f, -0.606374f, -0.556373f, -0.507104f, -0.460955f, -0.416905f, -0.371212f, -0.325363f, -0.282989f, -0.241932f, -0.199475f, -0.158957f, -0.122405f, -0.085805f, -0.048176f, -0.013848f, 0.017815f, 0.051603f, 0.085261f, 0.113579f, 0.139998f, 0.169326f, 0.196673f, 0.218159f, 0.240616f, 0.267320f, 0.290455f, 0.308757f, 0.331756f, 0.358830f, 0.379533f, 0.397779f, 0.425526f, 0.455662f, 0.476389f, 0.501029f, 0.542486f, 0.581357f, 0.609875f, 0.668286f, 0.765750f, 0.813077f, 0.736556f, 0.621909f}, @@ -1930,7 +1955,7 @@ const float CRendBin_HOA3_HRIR_coeff_im_16kHz[16][BINAURAL_CHANNELS][80]={ }; const float *CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const float *CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; #endif @@ -1938,9 +1963,9 @@ const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={N /********************** CRendBin_Combined_BRIR **********************/ +#ifndef IVAS_FLOAT_FIXED const float CRendBin_Combined_BRIR_latency_s = 0.000145834f; - -#ifdef IVAS_FLOAT_FIXED +#else const Word32 CRendBin_Combined_BRIR_latency_s_fx = 313176;/*Q-31*/ #endif /* Sample Rate = 48000 */ @@ -1955,6 +1980,7 @@ const float CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[15]={0.224183f, 0.22 const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz_fx[15]={7346, 7453, 7924, 6788, 7146, 7305, 7607, 8133, 8167, 8571, 8069, 9147, 9361, 8602, 8907,}; #endif const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98},{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98}}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_Combined_BRIR_coeff_re_48kHz[15][BINAURAL_CHANNELS][2955]={ { {-0.009093f, 0.009357f, -0.003453f, 0.000012f, 0.008747f, -0.004985f, 0.003413f, -0.000634f, 0.001224f, -0.005937f, -0.012436f, -0.002558f, 0.004885f, -0.003188f, 0.002971f, 0.004317f, 0.003658f, -0.002726f, 0.002070f, -0.007687f, -0.001416f, 0.001935f, 0.003177f, -0.000251f, -0.000183f, 0.000966f, 0.001890f, -0.006432f, -0.005361f, 0.002269f, 0.004446f, -0.002213f, 0.004654f, 0.008920f, -0.011982f, 0.001718f, -0.005741f, -0.003864f, 0.002657f, -0.001469f, 0.007339f, -0.002261f, 0.006608f, 0.003502f, 0.001066f, -0.000452f, 0.003522f, 0.000236f, -0.000743f, -0.003707f, 0.010716f, -0.007427f, -0.002282f, 0.003802f, 0.004147f, -0.000158f, -0.003653f, 0.002094f, -0.004039f, 0.004196f, 0.000776f, 0.001549f, -0.000111f, -0.001391f, -0.001353f, 0.005598f, -0.014358f, 0.003399f, -0.001873f, -0.008279f, -0.001439f, 0.007045f, 0.003361f, 0.004391f, -0.006305f, 0.005087f, -0.002217f, 0.003215f, 0.001901f, 0.002512f, -0.002684f, 0.001092f, 0.003738f, -0.002456f, -0.005636f, 0.002331f, -0.005235f, 0.001052f, 0.003778f, 0.000046f, -0.001918f, -0.002121f, 0.000983f, 0.002093f, -0.000885f, 0.002506f, @@ -3981,7 +4007,7 @@ const float CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS][288 -0.000127f, 0.000656f, 0.000958f, -0.021049f, -0.074011f, -0.030558f, -0.060400f, -0.013558f, -0.021114f, -0.008540f, 0.005511f, -0.019813f, -0.023982f, -0.038366f, -0.030493f, 0.027259f, -0.004844f, -0.024409f, -0.025928f, 0.005871f, -0.034505f, -0.048697f, 0.008047f, -0.011337f, -0.010427f, -0.010467f, 0.009378f, -0.029024f, 0.030558f, -0.017759f, 0.020760f, -0.014447f, -0.013858f, 0.000338f, 0.016772f, -0.023665f, -0.022591f, 0.012137f, -0.004260f, 0.033434f, -0.014631f, 0.019165f, 0.028836f, 0.013706f, -0.010477f, -0.004783f, -0.002989f, 0.023649f, -0.008272f, 0.015882f, 0.031926f, -0.026792f, -0.046736f, -0.018402f, 0.015888f, 0.019470f, -0.022037f, 0.036317f, -0.011659f, -0.013109f, -0.004357f, -0.003960f, -0.011213f, -0.029378f, -0.012396f, -0.030354f, -0.029055f, -0.018001f, 0.021498f, 0.005089f, -0.005130f, 0.001988f, 0.033225f, 0.031204f, 0.002242f, -0.014392f, 0.005985f, -0.003233f, 0.013707f, 0.004324f, -0.005912f, -0.013698f, -0.001190f, -0.002712f, -0.021764f, -0.005600f, 0.008350f, 0.022686f, -0.010079f, 0.000076f, 0.008688f, -0.012663f, -0.000348f, -0.000824f, 0.000437f, -0.006566f, 0.008540f, 0.000569f, 0.002267f, -0.000988f, 0.001342f} }; - +#endif /* Sample Rate = 32000 */ const int16_t CRendBin_Combined_BRIR_max_num_iterations_32kHz = 22; @@ -3994,6 +4020,7 @@ const float CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[15]={0.224190f, 0.22 const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz_fx[15]={7346, 7452, 7924, 6787, 7147, 7305, 7606, 8132, 8167, 8571, 8071, 9147, 9364, 8602, 8907,}; #endif const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 63, 63, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97},{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 63, 63, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97}}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_Combined_BRIR_coeff_re_32kHz[15][BINAURAL_CHANNELS][2819]={ { {-0.009097f, 0.009352f, -0.003456f, 0.000006f, 0.008745f, -0.004992f, 0.003412f, -0.000642f, 0.001223f, -0.005946f, -0.012435f, -0.002568f, 0.004887f, -0.003199f, 0.002973f, 0.004305f, 0.003661f, -0.002738f, 0.002074f, -0.007701f, -0.001411f, 0.001920f, 0.003183f, -0.000267f, -0.000175f, 0.000950f, 0.001899f, -0.006450f, -0.005352f, 0.002251f, 0.004456f, -0.002233f, 0.004665f, 0.008899f, -0.011970f, 0.001696f, -0.005728f, -0.003886f, 0.002671f, -0.001493f, 0.007354f, -0.002285f, 0.006623f, 0.003476f, 0.001083f, -0.000478f, 0.003540f, 0.000208f, -0.000724f, -0.003736f, 0.010735f, -0.007457f, -0.002261f, 0.003771f, 0.004169f, -0.000190f, -0.003631f, 0.002061f, -0.004016f, 0.004162f, 0.000801f, 0.001514f, -0.000085f, -0.001427f, -0.001326f, 0.005561f, -0.014330f, 0.003361f, -0.001844f, -0.008319f, -0.001409f, 0.007005f, 0.003391f, 0.004349f, -0.006273f, 0.005044f, -0.002184f, 0.003171f, 0.001934f, 0.002467f, -0.002649f, 0.001045f, 0.003774f, -0.002504f, -0.005599f, 0.002282f, -0.005197f, 0.001002f, 0.003817f, -0.000006f, -0.001878f, -0.002174f, 0.001025f, 0.002039f, -0.000843f, 0.002450f, @@ -5944,7 +5971,7 @@ const float CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS][287 0.031458f, -0.028595f, 0.018366f, 0.005588f, 0.025444f, 0.023474f, 0.015827f, 0.002536f, -0.016093f, -0.013878f, 0.033029f, -0.014058f, -0.001464f, 0.008051f, 0.028131f, 0.040762f, -0.001287f, 0.027841f, -0.022859f, -0.023842f, 0.002646f, -0.008821f, 0.013114f, 0.008322f, -0.020389f, 0.002753f, 0.012887f, 0.033517f, 0.011396f, 0.013723f, 0.012570f, 0.014979f, 0.003823f, -0.001202f, 0.021244f, 0.003721f, 0.016982f, 0.027236f, 0.005652f, -0.011237f, -0.009558f, 0.024547f, 0.006403f, 0.050382f, 0.011733f, 0.019842f, -0.020594f, -0.032353f, -0.003144f, -0.037770f, -0.024221f, -0.008633f, -0.012941f, 0.001391f, -0.001955f, 0.000276f, 0.000488f, -0.028253f, -0.023404f, -0.012371f, -0.024166f, 0.008796f, 0.009562f, -0.007331f, -0.001898f, -0.022425f, -0.003544f, 0.006580f, -0.006407f, -0.001948f, 0.002266f, -0.014163f, 0.005888f, -0.004370f, 0.001670f, 0.002484f, 0.000065f, 0.000944f, 0.003053f, -0.003401f, 0.000513f, 0.003267f, -0.000142f, 0.000763f, 0.000945f, -0.021037f, -0.074026f, -0.030548f, -0.060417f, -0.013550f, -0.021133f, -0.008534f, 0.005490f, -0.019809f, -0.024006f, -0.038365f, -0.030519f, 0.027258f, -0.004872f, -0.024412f, -0.025958f, 0.005865f, -0.034537f, -0.048705f, 0.008013f, -0.011347f, -0.010463f, -0.010480f, 0.009340f, -0.029039f, 0.030517f, -0.017776f, 0.020717f, -0.014466f, -0.013902f, 0.000316f, 0.016725f, -0.023690f, -0.022640f, 0.012110f, -0.004311f, 0.033404f, -0.014684f, 0.019133f, 0.028780f, 0.013672f, -0.010535f, -0.004820f, -0.003049f, 0.023610f, -0.008334f, 0.015840f, 0.031862f, -0.026837f, -0.046802f, -0.018449f, 0.015820f, 0.019420f, -0.022107f, 0.036264f, -0.011732f, -0.013165f, -0.004432f, -0.004019f, -0.011290f, -0.029439f, -0.012475f, -0.030418f, -0.029136f, -0.018067f, 0.021415f, 0.005020f, -0.005215f, 0.001915f, 0.033137f, 0.031128f, 0.002152f, -0.014470f, 0.005893f, -0.003315f, 0.013612f, 0.004239f, -0.006009f, -0.013786f, -0.001289f, -0.002803f, -0.021865f, -0.005694f, 0.008246f, 0.022588f, -0.010185f, -0.000025f, 0.008581f, -0.012767f, -0.000458f, -0.000932f, 0.000324f, -0.006676f, 0.008426f, 0.000455f, 0.002150f, -0.001106f} }; - +#endif /* Sample Rate = 16000 */ const int16_t CRendBin_Combined_BRIR_max_num_iterations_16kHz = 23; @@ -5957,6 +5984,7 @@ const float CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[15]={0.223532f, 0.22 const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz_fx[15]={7346, 7452, 7924, 6787, 7147, 7305, 7606, 8132, 8167, 8571, 8071, 9147, 9364, 8602, 8907}; #endif const uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]={{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 55, 55, 61, 61, 61, 65, 67, 67, 67, 67, 67, 67, 69, 72, 72, 72, 73, 73, 75, 75, 75, 75, 75, 75, 75, 75, 75, 77},{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 55, 55, 61, 61, 61, 65, 67, 67, 67, 67, 67, 67, 69, 72, 72, 72, 73, 73, 75, 75, 75, 75, 75, 75, 75, 75, 75, 77}}; +#ifndef IVAS_FLOAT_FIXED const float CRendBin_Combined_BRIR_coeff_re_16kHz[15][BINAURAL_CHANNELS][1774]={ { {0.010832f, 0.002712f, -0.004173f, 0.000188f, -0.002118f, 0.002726f, 0.010885f, -0.000914f, -0.007116f, -0.010756f, 0.001174f, -0.008083f, -0.002332f, -0.002440f, 0.001864f, 0.005777f, -0.008313f, -0.004040f, -0.002553f, 0.000455f, -0.004910f, -0.008631f, -0.003371f, -0.007258f, -0.003869f, 0.001568f, -0.000354f, -0.003350f, -0.000643f, -0.000920f, 0.000933f, -0.007724f, -0.001925f, 0.003126f, 0.006652f, 0.003422f, -0.000986f, -0.000941f, 0.000320f, -0.007324f, -0.004978f, 0.001622f, 0.000486f, 0.001950f, -0.001956f, 0.001611f, -0.001588f, 0.002919f, -0.001525f, 0.005462f, 0.005550f, -0.000510f, -0.000125f, 0.004259f, 0.001657f, -0.000296f, 0.000411f, -0.008943f, -0.005621f, -0.001358f, 0.003347f, -0.003679f, -0.007892f, -0.004968f, -0.003761f, -0.005550f, 0.003359f, -0.010204f, 0.003130f, 0.010428f, -0.005504f, -0.002617f, -0.005058f, 0.005816f, -0.002310f, -0.006421f, 0.001701f, -0.009205f, 0.009235f, -0.003556f, -0.000119f, 0.008653f, -0.005126f, 0.003328f, -0.000784f, 0.001148f, -0.006096f, -0.012503f, -0.002727f, 0.004827f, -0.003367f, 0.002923f, 0.004129f, 0.003619f, -0.002924f, 0.002040f, @@ -7271,6 +7299,7 @@ const float CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS][252 0.018358f, -0.020195f, 0.012285f, -0.036205f, -0.000230f, -0.019486f, 0.021761f, -0.002862f, 0.002417f, -0.003265f, -0.021068f, -0.000886f, 0.017137f, 0.047554f, 0.002807f, 0.003558f, 0.009315f, 0.016659f, -0.003390f, -0.003905f, 0.000798f, -0.000180f, 0.040620f, -0.003109f, 0.005685f, 0.017226f, -0.016770f, -0.026851f, -0.000591f, -0.028399f, -0.004244f, -0.014234f, -0.011375f, -0.005117f, -0.012932f, 0.007654f, 0.009595f, -0.016141f, 0.020769f, 0.018611f, -0.003081f, -0.003444f, -0.017888f, 0.013329f, 0.004146f, 0.044256f, 0.048210f, 0.000359f, -0.014792f, -0.011865f, 0.040392f, -0.026530f, -0.030252f, 0.031509f, -0.028569f, 0.018427f, 0.005621f, 0.025515f, 0.023514f, 0.015908f, 0.002584f, -0.016001f, -0.013823f, 0.033133f, -0.013996f, -0.001348f, 0.008121f, 0.028260f, 0.040839f, -0.001144f, 0.027926f, -0.022702f, -0.023750f, 0.002818f, -0.008721f, 0.013302f, 0.008430f, -0.020183f, 0.002868f, 0.013112f, 0.033640f, 0.011641f, 0.013855f, 0.012837f, 0.015118f, 0.004113f, -0.001054f, 0.021560f, 0.003879f, 0.017326f, 0.027403f, 0.006026f, -0.011061f, -0.009150f, 0.024733f, 0.006850f, 0.050578f, 0.012222f, 0.020049f, -0.020057f, -0.032135f, -0.002553f, -0.037541f, -0.023567f, -0.008392f, -0.012215f, 0.001644f, -0.001142f, 0.000540f, 0.001404f, -0.027979f, -0.022362f, -0.012091f, -0.022963f, 0.009075f, 0.010977f, -0.007069f, -0.000183f, -0.022228f, -0.001348f, 0.006548f, -0.003034f} }; +#endif #ifdef IVAS_FLOAT_FIXED //BRIR and HRIR coeff tables in Q29 const Word32 CRendBin_Combined_BRIR_coeff_re_48kHz_fx[15][BINAURAL_CHANNELS][2955] ={ diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index ef5f09c832df4a24a6875104cbeda4802d040e63..cc0f735718fa6e857a3b21d58b540423f3003949 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -54,8 +54,9 @@ extern Word32 cosine_table_Q31 [181]; #endif /********************** CRendBin_Combined_HRIR **********************/ +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_HRIR_latency_s; -#ifdef IVAS_FLOAT_FIXED +#else extern Word32 CRendBin_Combined_HRIR_latency_s_fx; #endif // IVAS_FLOAT_FIXED @@ -66,21 +67,23 @@ extern uint16_t CRendBin_Combined_HRIR_num_iterations_48kHz[15][BINAURAL_CHANNEL extern uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz[15]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz_fx[15]; #endif extern uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_HRIR_coeff_re_48kHz[15][BINAURAL_CHANNELS][240]; extern float CRendBin_Combined_HRIR_coeff_im_48kHz[15][BINAURAL_CHANNELS][240]; -#ifdef IVAS_FLOAT_FIXED +extern float *CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS]; +extern float *CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS]; +#else extern Word32 CRendBin_Combined_HRIR_coeff_re_48kHz_fx[15][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_Combined_HRIR_coeff_im_48kHz_fx[15][BINAURAL_CHANNELS][240]; extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; #endif -extern float *CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS]; -extern float *CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ @@ -89,21 +92,23 @@ extern uint16_t CRendBin_Combined_HRIR_num_iterations_32kHz[15][BINAURAL_CHANNEL extern uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz[15]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz_fx[15]; #endif extern uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_HRIR_coeff_re_32kHz[15][BINAURAL_CHANNELS][160]; extern float CRendBin_Combined_HRIR_coeff_im_32kHz[15][BINAURAL_CHANNELS][160]; -#ifdef IVAS_FLOAT_FIXED +extern float *CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS]; +extern float *CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS]; +#else extern Word32 CRendBin_Combined_HRIR_coeff_re_32kHz_fx[15][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_Combined_HRIR_coeff_im_32kHz_fx[15][BINAURAL_CHANNELS][160]; extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; #endif -extern float *CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS]; -extern float *CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS]; /* Sample Rate = 16000 */ @@ -112,29 +117,32 @@ extern uint16_t CRendBin_Combined_HRIR_num_iterations_16kHz[15][BINAURAL_CHANNEL extern uint16_t CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz[15]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz_fx[15]; #endif extern uint16_t *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_HRIR_coeff_re_16kHz[15][BINAURAL_CHANNELS][80]; extern float CRendBin_Combined_HRIR_coeff_im_16kHz[15][BINAURAL_CHANNELS][80]; -#ifdef IVAS_FLOAT_FIXED +extern float *CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS]; +extern float *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]; +#else extern Word32 CRendBin_Combined_HRIR_coeff_re_16kHz_fx[15][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_Combined_HRIR_coeff_im_16kHz_fx[15][BINAURAL_CHANNELS][80]; extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; extern Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]; #endif -extern float *CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS]; -extern float *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]; /********************** CRendBin_FOA_HRIR **********************/ +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_FOA_HRIR_latency_s; -#ifdef IVAS_FLOAT_FIXED +#else extern Word32 CRendBin_FOA_HRIR_latency_s_fx; #endif // IVAS_FLOAT_FIXED @@ -145,21 +153,23 @@ extern uint16_t CRendBin_FOA_HRIR_num_iterations_48kHz[4][BINAURAL_CHANNELS]; extern uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[4][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz[4]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz_fx[4]; #endif extern uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_FOA_HRIR_coeff_re_48kHz[4][BINAURAL_CHANNELS][240]; extern float CRendBin_FOA_HRIR_coeff_im_48kHz[4][BINAURAL_CHANNELS][240]; -#ifdef IVAS_FLOAT_FIXED +extern float *CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS]; +extern float *CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS]; +#else extern Word32 CRendBin_FOA_HRIR_coeff_re_48kHz_fx[4][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_FOA_HRIR_coeff_im_48kHz_fx[4][BINAURAL_CHANNELS][240]; extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; #endif -extern float *CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS]; -extern float *CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ @@ -168,21 +178,23 @@ extern uint16_t CRendBin_FOA_HRIR_num_iterations_32kHz[4][BINAURAL_CHANNELS]; extern uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[4][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz[4]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz_fx[4]; #endif extern uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_FOA_HRIR_coeff_re_32kHz[4][BINAURAL_CHANNELS][160]; extern float CRendBin_FOA_HRIR_coeff_im_32kHz[4][BINAURAL_CHANNELS][160]; -#ifdef IVAS_FLOAT_FIXED +extern float *CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS]; +extern float *CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS]; +#else extern Word32 CRendBin_FOA_HRIR_coeff_re_32kHz_fx[4][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_FOA_HRIR_coeff_im_32kHz_fx[4][BINAURAL_CHANNELS][160]; extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; #endif -extern float *CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS]; -extern float *CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS]; /* Sample Rate = 16000 */ @@ -191,28 +203,31 @@ extern uint16_t CRendBin_FOA_HRIR_num_iterations_16kHz[4][BINAURAL_CHANNELS]; extern uint16_t CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[4][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz[4]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz_fx[4]; #endif extern uint16_t *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_FOA_HRIR_coeff_re_16kHz[4][BINAURAL_CHANNELS][80]; extern float CRendBin_FOA_HRIR_coeff_im_16kHz[4][BINAURAL_CHANNELS][80]; -#ifdef IVAS_FLOAT_FIXED +extern float *CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS]; +extern float *CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]; +#else extern Word32 CRendBin_FOA_HRIR_coeff_re_16kHz_fx[4][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_FOA_HRIR_coeff_im_16kHz_fx[4][BINAURAL_CHANNELS][80]; extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; extern Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]; #endif -extern float *CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS]; -extern float *CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]; /********************** CRendBin_HOA2_HRIR **********************/ +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA2_HRIR_latency_s; -#ifdef IVAS_FLOAT_FIXED +#else extern Word32 CRendBin_HOA2_HRIR_latency_s_fx; #endif // IVAS_FLOAT_FIXED @@ -223,21 +238,23 @@ extern uint16_t CRendBin_HOA2_HRIR_num_iterations_48kHz[9][BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[9][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz[9]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz_fx[9]; #endif extern uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA2_HRIR_coeff_re_48kHz[9][BINAURAL_CHANNELS][240]; extern float CRendBin_HOA2_HRIR_coeff_im_48kHz[9][BINAURAL_CHANNELS][240]; -#ifdef IVAS_FLOAT_FIXED +extern float *CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS]; +extern float *CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS]; +#else extern Word32 CRendBin_HOA2_HRIR_coeff_re_48kHz_fx[9][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_HOA2_HRIR_coeff_im_48kHz_fx[9][BINAURAL_CHANNELS][240]; extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; #endif -extern float *CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS]; -extern float *CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ @@ -246,21 +263,23 @@ extern uint16_t CRendBin_HOA2_HRIR_num_iterations_32kHz[9][BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[9][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz[9]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz_fx[9]; #endif extern uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA2_HRIR_coeff_re_32kHz[9][BINAURAL_CHANNELS][160]; extern float CRendBin_HOA2_HRIR_coeff_im_32kHz[9][BINAURAL_CHANNELS][160]; -#ifdef IVAS_FLOAT_FIXED +extern float *CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS]; +extern float *CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS]; +#else extern Word32 CRendBin_HOA2_HRIR_coeff_re_32kHz_fx[9][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_HOA2_HRIR_coeff_im_32kHz_fx[9][BINAURAL_CHANNELS][160]; extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; #endif -extern float *CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS]; -extern float *CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS]; /* Sample Rate = 16000 */ @@ -269,28 +288,29 @@ extern uint16_t CRendBin_HOA2_HRIR_num_iterations_16kHz[9][BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[9][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz[9]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz_fx[9]; #endif extern uint16_t *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA2_HRIR_coeff_re_16kHz[9][BINAURAL_CHANNELS][80]; extern float CRendBin_HOA2_HRIR_coeff_im_16kHz[9][BINAURAL_CHANNELS][80]; -#ifdef IVAS_FLOAT_FIXED -extern Word32 CRendBin_HOA2_HRIR_coeff_re_16kHz_fx[9][BINAURAL_CHANNELS][80]; -extern Word32 CRendBin_HOA2_HRIR_coeff_im_16kHz_fx[9][BINAURAL_CHANNELS][80]; -#endif extern float *CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS]; extern float *CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]; -#ifdef IVAS_FLOAT_FIXED +#else +extern Word32 CRendBin_HOA2_HRIR_coeff_re_16kHz_fx[9][BINAURAL_CHANNELS][80]; +extern Word32 CRendBin_HOA2_HRIR_coeff_im_16kHz_fx[9][BINAURAL_CHANNELS][80]; extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; extern Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]; #endif /********************** CRendBin_HOA3_HRIR **********************/ +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA3_HRIR_latency_s; -#ifdef IVAS_FLOAT_FIXED +#else extern Word32 CRendBin_HOA3_HRIR_latency_s_fx; #endif // IVAS_FLOAT_FIXED @@ -302,21 +322,23 @@ extern uint16_t CRendBin_HOA3_HRIR_num_iterations_48kHz[16][BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[16][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz[16]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz_fx[16]; #endif extern uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA3_HRIR_coeff_re_48kHz[16][BINAURAL_CHANNELS][240]; extern float CRendBin_HOA3_HRIR_coeff_im_48kHz[16][BINAURAL_CHANNELS][240]; -#ifdef IVAS_FLOAT_FIXED +extern float *CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS]; +extern float *CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS]; +#else extern Word32 CRendBin_HOA3_HRIR_coeff_re_48kHz_fx[16][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_HOA3_HRIR_coeff_im_48kHz_fx[16][BINAURAL_CHANNELS][240]; extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]; extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]; #endif -extern float *CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS]; -extern float *CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS]; /* Sample Rate = 32000 */ @@ -325,21 +347,23 @@ extern uint16_t CRendBin_HOA3_HRIR_num_iterations_32kHz[16][BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[16][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz[16]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz_fx[16]; #endif extern uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA3_HRIR_coeff_re_32kHz[16][BINAURAL_CHANNELS][160]; extern float CRendBin_HOA3_HRIR_coeff_im_32kHz[16][BINAURAL_CHANNELS][160]; -#ifdef IVAS_FLOAT_FIXED +extern float *CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS]; +extern float *CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS]; +#else extern Word32 CRendBin_HOA3_HRIR_coeff_re_32kHz_fx[16][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_HOA3_HRIR_coeff_im_32kHz_fx[16][BINAURAL_CHANNELS][160]; extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]; extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]; #endif -extern float *CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS]; -extern float *CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS]; /* Sample Rate = 16000 */ @@ -348,28 +372,31 @@ extern uint16_t CRendBin_HOA3_HRIR_num_iterations_16kHz[16][BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[16][BINAURAL_CHANNELS][1]; extern uint16_t CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[16]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz_fx[16]; #endif extern uint16_t *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_HOA3_HRIR_coeff_re_16kHz[16][BINAURAL_CHANNELS][80]; extern float CRendBin_HOA3_HRIR_coeff_im_16kHz[16][BINAURAL_CHANNELS][80]; -#ifdef IVAS_FLOAT_FIXED +extern float *CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS]; +extern float *CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]; +#else extern Word32 CRendBin_HOA3_HRIR_coeff_re_16kHz_fx[16][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_HOA3_HRIR_coeff_im_16kHz_fx[16][BINAURAL_CHANNELS][80]; extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]; extern Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]; #endif -extern float *CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS]; -extern float *CRendBin_HOA3_HRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS]; /********************** CRendBin_Combined_BRIR **********************/ +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_BRIR_latency_s; -#ifdef IVAS_FLOAT_FIXED +#else extern Word32 CRendBin_Combined_BRIR_latency_s_fx; #endif // IVAS_FLOAT_FIXED @@ -380,21 +407,23 @@ extern uint16_t CRendBin_Combined_BRIR_num_iterations_48kHz[15][BINAURAL_CHANNEL extern uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[15][BINAURAL_CHANNELS][22]; extern uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[15]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz_fx[15]; #endif extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_BRIR_coeff_re_48kHz[15][BINAURAL_CHANNELS][2955]; extern float CRendBin_Combined_BRIR_coeff_im_48kHz[15][BINAURAL_CHANNELS][2955]; -#ifdef IVAS_FLOAT_FIXED +extern float CRendBin_Combined_BRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS][2885]; +extern float CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS][2885]; +#else extern Word32 CRendBin_Combined_BRIR_coeff_re_48kHz_fx[15][BINAURAL_CHANNELS][2955]; extern Word32 CRendBin_Combined_BRIR_coeff_im_48kHz_fx[15][BINAURAL_CHANNELS][2955]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS][2885]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS][2885]; #endif -extern float CRendBin_Combined_BRIR_coeff_diffuse_re_48kHz[BINAURAL_CHANNELS][2885]; -extern float CRendBin_Combined_BRIR_coeff_diffuse_im_48kHz[BINAURAL_CHANNELS][2885]; /* Sample Rate = 32000 */ @@ -403,21 +432,23 @@ extern uint16_t CRendBin_Combined_BRIR_num_iterations_32kHz[15][BINAURAL_CHANNEL extern uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[15][BINAURAL_CHANNELS][22]; extern uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[15]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz_fx[15]; #endif extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_BRIR_coeff_re_32kHz[15][BINAURAL_CHANNELS][2819]; extern float CRendBin_Combined_BRIR_coeff_im_32kHz[15][BINAURAL_CHANNELS][2819]; -#ifdef IVAS_FLOAT_FIXED +extern float CRendBin_Combined_BRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS][2870]; +extern float CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS][2870]; +#else extern Word32 CRendBin_Combined_BRIR_coeff_re_32kHz_fx[15][BINAURAL_CHANNELS][2819]; extern Word32 CRendBin_Combined_BRIR_coeff_im_32kHz_fx[15][BINAURAL_CHANNELS][2819]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS][2870]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS][2870]; #endif -extern float CRendBin_Combined_BRIR_coeff_diffuse_re_32kHz[BINAURAL_CHANNELS][2870]; -extern float CRendBin_Combined_BRIR_coeff_diffuse_im_32kHz[BINAURAL_CHANNELS][2870]; /* Sample Rate = 16000 */ @@ -426,19 +457,21 @@ extern uint16_t CRendBin_Combined_BRIR_num_iterations_16kHz[15][BINAURAL_CHANNEL extern uint16_t CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[15][BINAURAL_CHANNELS][23]; extern uint16_t CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[15]; -#ifdef IVAS_FLOAT_FIXED +#else extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz_fx[15]; #endif extern uint16_t CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]; +#ifndef IVAS_FLOAT_FIXED extern float CRendBin_Combined_BRIR_coeff_re_16kHz[15][BINAURAL_CHANNELS][1774]; extern float CRendBin_Combined_BRIR_coeff_im_16kHz[15][BINAURAL_CHANNELS][1774]; -#ifdef IVAS_FLOAT_FIXED +extern float CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS][2522]; +extern float CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS][2522]; +#else extern Word32 CRendBin_Combined_BRIR_coeff_re_16kHz_fx[15][BINAURAL_CHANNELS][1774]; extern Word32 CRendBin_Combined_BRIR_coeff_im_16kHz_fx[15][BINAURAL_CHANNELS][1774]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS][2522]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS][2522]; #endif -extern float CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz[BINAURAL_CHANNELS][2522]; -extern float CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz[BINAURAL_CHANNELS][2522]; #endif /* _IVAS_ROM_BINAURAL_CREND_HEAD_ */ diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index dab91ad0a4a414d592a6c62c1c17b478e4533896..b78c6fba1d17349b54b9e0dc741a08c464e53708 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -50,7 +50,7 @@ const Word16 diffuse_response_CICP6_fx[5] = { 13824, 13824, 12137, 16495, 16495 const Word16 diffuse_response_CICP14_fx[7] = { 12507, 12507, 9237, 17691, 17691, 4977, 4977 };//Q15 const Word16 diffuse_response_CICP16_fx[9] = { 11324, 11324, 9945, 13513, 13513, 8853, 8853, 9905, 9905 };//Q15 -#endif +#else const float ls_azimuth_4d4[8] = { 45.0f, -45.0f, 135.0f, -135.0f, 45.0f, -45.0f, 135.0f, -135.0f }; @@ -61,11 +61,12 @@ const float diffuse_response_CICP6[5] = { 0.4219f, 0.4219f, 0.3704f, 0.5034f, 0. const float diffuse_response_CICP14[7] = { 0.3817f, 0.3817f, 0.2819f, 0.5399f, 0.5399f, 0.1519f, 0.1519f }; const float diffuse_response_CICP16[9] = { 0.3456f, 0.3456f, 0.3035f, 0.4124f, 0.4124f, 0.2702f, 0.2702f, 0.3023f, 0.3023f }; - +#endif const int16_t ap_pre_delay[DIRAC_DECORR_NUM_SPLIT_BANDS] = { 7, 2, 1 }; const int16_t ap_filter_length[DIRAC_DECORR_NUM_SPLIT_BANDS] = { 15, 6, 3 }; +#ifndef IVAS_FLOAT_FIXED const float ap_lattice_delta_phi[DIRAC_MAX_NUM_DECORR_FILTERS*DIRAC_MAX_DECORR_FILTER_LEN] = { 1.802519f, 0.922986f, 1.813685f, 1.272828f, 0.856928f, 0.366571f, 1.531249f, 1.318158f, 0.123812f, 0.897173f, 0.958696f, 1.256384f, 0.179677f, 0.668918f, 1.440292f, 1.573058f, 1.396481f, 1.191463f, 0.444143f, 1.666942f, @@ -91,8 +92,7 @@ const float ap_lattice_delta_phi[DIRAC_MAX_NUM_DECORR_FILTERS*DIRAC_MAX_DECORR_F 0.669967f, 1.535929f, 1.841878f, 0.979127f, 0.614002f, 1.879218f, 0.512531f, 1.167061f, 0.081697f, 1.773427f, 1.535668f, 0.757729f, 0.220395f, 1.538243f, 1.281162f, 0.302159f, 0.889871f, 0.798522f, 1.476288f, 1.665941f, 0.915365f, 1.394094f, 0.757041f, 0.350064f, 1.199679f, 1.319499f, 1.128405f, 0.632337f, 0.790673f, 0.461582f, 1.693343f, 1.537442f, 0.346527f, 0.433782f, 1.754552f, 0.550903f, 0.686724f, 0.764433f, 1.792750f, 1.489998f }; - -#ifdef IVAS_FLOAT_FIXED +#else const Word16 ap_lattice_delta_phi_fx[DIRAC_MAX_NUM_DECORR_FILTERS*DIRAC_MAX_DECORR_FILTER_LEN] /*Q14*/ = { 29532 , 15122 , 29715 , 20854 , 14040 , 6006 , 25088 , 21597 , 2029 , 14699 , 15707 , 20585 , 2944 , 10960 , 23598 , 25773 , 22880 , 19521 , 7277 , 27311 , 20872 , 28626 , 23074 , @@ -117,7 +117,7 @@ const Word16 ap_lattice_delta_phi_fx[DIRAC_MAX_NUM_DECORR_FILTERS*DIRAC_MAX_DECO 27295 , 14997 , 22841 , 12403 , 5735 , 19656 , 21619 , 18488 , 10360 , 12954 , 7563 , 27744 , 25189 , 5677 , 7107 , 28747 , 9026 , 11251 , 12524 , 29372 , 24412 }; #endif - +#ifndef IVAS_FLOAT_FIXED const float ap_lattice_coeffs_1[DIRAC_DECORR_FILTER_LEN_1*DIRAC_MAX_NUM_DECORR_FILTERS] = { 0.795329f, 0.502700f, 0.204456f, 0.416566f, 0.459648f, 0.270454f, -0.201944f, 0.027997f, 0.067811f, -0.052627f, -0.038779f, -0.057387f, 0.020480f, 0.367697f, -0.593705f, @@ -203,7 +203,7 @@ const float * const ap_lattice_coeffs[DIRAC_DECORR_NUM_SPLIT_BANDS] = &ap_lattice_coeffs_3[0], }; -#ifdef IVAS_FLOAT_FIXED +#else const Word16 ap_lattice_coeffs_1_fx[330] = { 26061, 16472, 6699, 13650, 15061, 8862, -6617, 917, 2222, -1724, -1270, -1880, 671, 12048, -19454, 17487, 6635, -63, 6392, -6044, -7663, 7474, -10790, -11098, -2611, 1716, -310, 5859, 6253, -15691, 1442, 25837, 4375, -5690, 17871, 22329, 10907, 9656, 10658, 1560, 5157, 3810, 7175, -6201, -10400, -24696, 25309, -16625, 9076, -22700, 7612, -11624, -511, -7309, 10174, -1147, 2810, -16383, 7053, 6599, -16238, -9884, 6439, 10687, -19476, 10319, 21911, 2511, 1497, -4089, -6660, -9738, 4122, -5881, -6611, 5279, 12977, 8745, 11684, 15995, -1843, 4563, -9712, -3697, 1225, -12039, -7087, -9088, 12760, 3772, -7879, -8880, 13982, -362, 4974, 8306, 7397, 16341, -4468, 14516, -9994, -1025, -352, 5581, 16268, -4583, -7929, -3435, 9645, -2219, -16128, -15978, 1192, 3584, 12981, -11562, -6747, -2719, -15172, -10135, 848, -3029, -4100, -5115, -160, 5847, 2935, 1468, 7805, -10227, -12802, -5850, 14890, 12681, -12742, -6481, 1164, 14922, -1782, 12452, 9534, 1599, 2576, 7265, -7128, 3974, -12998, -7159, -4170, -8831, -11279, -15238, -13808, -852, 7259, 11861, -11411, 9666, 11998, 2315, -2819, 8261, 5113, -2057, 13401, 7944, -9888, -2167, 12735, -15146, -5206, 7562, -3053, 1542, 2405, -10977, 751, 11619, 2372, 638, 11039, -15746, 5579, 8508, -12896, -11422, -3570, 9137, 12631, 11870, -10444, 11872, 9467, 9542, -9110, -14722, -9453, -13565, -13280, -9671, -8031, 82, 9433, 11410, -5844, -6767, 11504, -15800, 699, -16128, 1593, 14853, 3576, 7621, -15524, 4603, 11551, -3231, 4822, -1828, 3530, -7570, 11708, 11404, 7615, -10642, 5324, 1888, -1990, -319, -7346, -9252, -2144, 2119, 9187, -9335, -15417, 638, -14493, 12360, 14659, -9519, 11322, 12130, -10260, 3918, 9830, 13336, -9106, 14648, 6383, 5167, -7320, -4822, 12421, -7089, 4520, -13014, 2421, -8949, -14517, -5515, 11346, 1230, 2142, 5370, -4014, 11975, -10365, 3842, -9872, 5558, -11025, 8844, -13767, -10855, 16335, -12878, -15144, -10587, 15432, -11778, 8661, 7104, 16167, 4963, -10539, 15217, -11654, 13775, 6039, -9900, 4474, -8285, 6353, 9790, 7825, -12658, -5963, -2533, 4090, -8630, 12766, 147, 11134, 13605, 12378, 13114, 11548, -124, -6046, 14199, -7784, 4839, 13343, 2215, -8169, -11600, 10516, 13959, 10144, -6215, -6863, 5209, -2684, 12675, 5851, -13341, 7280, -4885, }; const Word16 ap_lattice_coeffs_2_fx[132] = { 20764, 22321, -1619, 9395, 4784, 4436, -13439, -6775, -21527, -3334, 14296, 11135, -4305, -25354, -9883, 10733, 10886, 6745, 23514, -18100, -4919, 1787, 7848, -21249, -23653, 6205, 2234, 203, 2523, 1267, 13874, -3560, 14157, -13586, 9104, 13712, 2549, -9275, -11698, 151, -14504, -12200, 13216, 7963, 10301, 14565, 11387, 16254, 3552, 15380, -5579, 10692, 5641, 14428, 1914, 11130, -6388, 16096, -9217, -1412, -15810, -10977, -11015, 6437, -5394, 14499, -4429, -11612, 14815, -10198, -11391, 16329, -9469, 12334, -5830, 6407, 10940, -5003, 1744, 15000, 14499, 7708, -11310, -9374, 5093, 13283, 7113, -3537, 350, 12090, -16330, -16246, -7060, -3075, 10494, -453, 16036, 15427, -2157, 11366, 893, 4918, 15860, -16298, 5531, -16182, -5686, 10966, 8658, -13914, -10319, 8293, 13021, -16107, -14867, -15183, -626, 11, 10336, 15477, 3117, 9285, -7375, -3924, -15626, 1229, 11041, 16204, -2051, 5821, 15200, 16032, }; const Word16 ap_lattice_coeffs_3_fx[66] = { 621, -6953, 13851, -13128, -3502, -805, 4587, 9161, 1060, 20726, 18957, -24071, 563, 433, -908, -11578, -15799, -16097, 14975, 5410, 15391, -6412, 14421, -15642, 11802, -16074, 15880, -5694, 247, 9115, 14234, 1977, -6347, -1104, 16260, 96, -15756, -3589, -760, 10639, -9570, -11670, -12012, 12481, -9887, 3614, 12575, 9960, -16373, -11455, 10969, -662, -14092, -5069, -12161, 10947, 11367, -5465, -7506, 3865, 11183, 16071, 16176, -12049, 13976, -1499, }; @@ -216,12 +216,12 @@ const Word16 * const ap_lattice_coeffs_fx[DIRAC_DECORR_NUM_SPLIT_BANDS] = }; #endif +#ifndef IVAS_FLOAT_FIXED const float ap_split_frequencies[DIRAC_DECORR_NUM_SPLIT_BANDS + 1] = { 0.0f, 0.125f, 0.375f, 1.0f }; - -#ifdef IVAS_FLOAT_FIXED +#else const Word16 ap_split_frequencies_fx[DIRAC_DECORR_NUM_SPLIT_BANDS + 1]/*Q14*/ = { 0 , 2048, 6144, 16384 }; @@ -263,48 +263,52 @@ const int16_t channelIndex_CICP14[7] = { 0, 1, 2, 5, 6, 9, 10 }; const int16_t channelIndex_CICP16[9] = { 0, 1, 2, 5, 6, 9, 10, 11, 12 }; const int16_t channelIndex_CICP19[11] = { 0, 1, 2, 3, 4, 7, 8, 9, 10, 13, 14 }; - +#ifndef IVAS_FLOAT_FIXED const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = { 3.0903f, 2.0053f, 1.0860f, 0.8072f, 0.7079f }; - +#else const Word16 surCohEne_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = { 25315, 16427, 8896, 6612, 5799 }; - +#endif +#ifndef IVAS_FLOAT_FIXED const float spreadCohEne05[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = { 2.3988f, 1.7783f, 1.1220f, 1.1220f, 1.1220f }; - +#else const Word16 spreadCohEne05_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = /* Q13 */ { 19650, 14567, 9191, 9191, 9191 }; - +#endif +#ifndef IVAS_FLOAT_FIXED const float spreadCohEne1[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = { 1.5975f, 1.1220f, 1.1220f, 1.1220f, 1.1220f }; - +#else const Word16 spreadCohEne1_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = /* Q14 */ { 26173, 18382, 18382, 18382, 18382 }; - +#endif +#ifndef IVAS_FLOAT_FIXED const float lowBitRateBinauralEQ[LOW_BIT_RATE_BINAURAL_EQ_BINS] = { 0.979f, 0.893f, 0.762f, 0.615f, 0.52f, 0.48f, 0.477f, 0.477f, 0.48f, 0.501f, 0.546f, 0.602f, 0.652f, 0.664f, 0.652f, 0.639f, 0.635f }; - +#else const Word32 lowBitRateBinauralEQ_fx[LOW_BIT_RATE_BINAURAL_EQ_BINS] = { 2102386432, 1917702912, 1636382592, 1320702464, 1116691456, 1030792128, 1024349696, 1024349696, 1030792128, 1075889280, 1172526080, 1292785152, 1400159360, 1425929088, 1400159360, 1372242048, 1363652096 }; - +#endif +#ifndef IVAS_FLOAT_FIXED const float diffuseFieldCoherenceDifferenceX[BINAURAL_COHERENCE_DIFFERENCE_BINS] = { 0.047421f, 0.19773f, 0.22582f, 0.10637f, 0.0087111f, 0.012028f, 0.031972f, 0.019668f, 0.0079928f @@ -319,7 +323,7 @@ const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS] { 0.048207f, 0.10796f, 0.11845f, 0.047886f, 0.035917f, 0.045196f, 0.018863f, 0.015547f, 0.014157f }; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 diffuseFieldCoherenceDifferenceX_fx[BINAURAL_COHERENCE_DIFFERENCE_BINS] = { /* Q31 */ 101835824, 424621952, 484944768, 228427840, 18706944, 25829934, 68659344, 42236708, 17164408, }; @@ -342,6 +346,7 @@ const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS] = 13, 12, 11 }; +#ifndef IVAS_FLOAT_FIXED const float SincTable[321] = { 1.00000000f, 0.99957629f, 0.99830587f, 0.99619078f, 0.99323448f, 0.98944177f, 0.98481881f, 0.97937311f, @@ -387,7 +392,7 @@ const float SincTable[321] = 0.00000000f }; -#ifdef IVAS_FLOAT_FIXED +#else const Word32 SincTable_fx[321] /*Q31*/ = { 2147483647, 2146573696, 2143845504, 2139303424, 2132954752, 2124809984, 2114882304, 2103187712, 2089745280, 2074576896, 2057706880, 2039162624, 2018973952, 1997173632, 1973796608, 1948880384, @@ -431,7 +436,7 @@ const Word32 SincTable_fx[321] /*Q31*/ = { 4368840, 3818118, 3267783, 2718370, 2170290, 1624034, 1079948, 538481, }; #endif - +#ifndef IVAS_FLOAT_FIXED const float defaultHRIR_coherence_48kHz[LR_IAC_LENGTH_NR_FC] = { 0.983003f, 0.933450f, 0.789276f, 0.574420f, 0.340710f, 0.144220f, 0.018803f, 0.000000f, 0.000000f, 0.000000f, 0.011939f, 0.035489f, 0.043188f, 0.042460f, 0.041788f, 0.038562f, 0.028911f, 0.017162f, @@ -719,7 +724,7 @@ 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 +#else const Word32 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { 131936432,125285536,105934832,77097344,45729324,19356880,2523696,0,0, 0,1602425,4763253,5796595,5698884,5608690,5175704,3880368,2303444, @@ -1154,16 +1159,18 @@ const float ivas_reverb_default_DSR[IVAS_REVERB_DEFAULT_N_BANDS] = * Renderer SBA & MC enc/dec matrices *----------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED /* CICP1 - Mono */ const float ls_azimuth_CICP1[1] = { 0.0f }; const float ls_elevation_CICP1[1] = { 0.0f }; - +#endif /*----------------------------------------------------------------------------------* * LS Renderer ROM tables *----------------------------------------------------------------------------------*/ - + /* All matrices are stored with dimensions nchan_in x nchan_out */ + /* Downmix matrices */ #ifdef IVAS_FLOAT_FIXED /* All matrices are stored with dimensions nchan_in x nchan_out */ /* Downmix matrices */ @@ -1512,9 +1519,7 @@ const LS_CONVERSION_MAPPING_FX ls_conversion_mapping_fx[LS_SETUP_CONVERSION_NUM_ {IVAS_AUDIO_CONFIG_5_1_4, IVAS_AUDIO_CONFIG_7_1_4, ls_conversion_cicp16_cicp19_fx}, }; -#endif - /* All matrices are stored with dimensions nchan_in x nchan_out */ - /* Downmix matrices */ +#else const float ls_conversion_cicpX_mono[12][1] = { {1.00000000f}, @@ -1546,7 +1551,6 @@ const float ls_conversion_cicpX_stereo[12][2] = {0.849999964f, 0.000000000f}, {0.000000000f, 0.849999964f} }; -#ifndef IVAS_FLOAT_FIXED const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[] = { /* First row indicates the number of non-zero elements and the number of matrix columns */ diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index 720fc2c80a64b3725aa3a26ebdfb440c71038f60..06590cee18298ec12ebdcb5a522a26751bd7cd4a 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -42,12 +42,13 @@ * DirAC renderer ROM tables *----------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED extern const float ls_azimuth_4d4[8]; extern const float ls_elevation_4d4[8]; extern const float diffuse_response_CICP6[5]; extern const float diffuse_response_CICP14[7]; extern const float diffuse_response_CICP16[9]; -#ifdef IVAS_FLOAT_FIXED +#else extern const Word32 ls_azimuth_4d4_fx[8]; extern const Word32 ls_elevation_4d4_fx[8]; extern const Word16 diffuse_response_CICP6_fx[5]; @@ -57,16 +58,20 @@ extern const Word16 diffuse_response_CICP16_fx[9]; extern const int16_t ap_pre_delay[DIRAC_DECORR_NUM_SPLIT_BANDS]; extern const int16_t ap_filter_length[DIRAC_DECORR_NUM_SPLIT_BANDS]; +#ifndef IVAS_FLOAT_FIXED extern const float ap_lattice_delta_phi[DIRAC_MAX_NUM_DECORR_FILTERS * DIRAC_MAX_DECORR_FILTER_LEN]; extern const float ap_lattice_coeffs_1[DIRAC_DECORR_FILTER_LEN_1 * DIRAC_MAX_NUM_DECORR_FILTERS]; extern const float ap_lattice_coeffs_2[DIRAC_DECORR_FILTER_LEN_2 * DIRAC_MAX_NUM_DECORR_FILTERS]; extern const float ap_lattice_coeffs_3[DIRAC_DECORR_FILTER_LEN_3 * DIRAC_MAX_NUM_DECORR_FILTERS]; extern const float *const ap_lattice_coeffs[DIRAC_DECORR_NUM_SPLIT_BANDS]; -extern const Word16 *const ap_lattice_coeffs_fx[DIRAC_DECORR_NUM_SPLIT_BANDS]; extern const float ap_split_frequencies[DIRAC_DECORR_NUM_SPLIT_BANDS + 1]; -#ifdef IVAS_FLOAT_FIXED -extern const Word16 ap_split_frequencies_fx[DIRAC_DECORR_NUM_SPLIT_BANDS + 1]; +#else extern const Word16 ap_lattice_delta_phi_fx[DIRAC_MAX_NUM_DECORR_FILTERS * DIRAC_MAX_DECORR_FILTER_LEN]; +extern const Word16 ap_lattice_coeffs_1_fx[DIRAC_DECORR_FILTER_LEN_1 * DIRAC_MAX_NUM_DECORR_FILTERS]; +extern const Word16 ap_lattice_coeffs_2_fx[DIRAC_DECORR_FILTER_LEN_2 * DIRAC_MAX_NUM_DECORR_FILTERS]; +extern const Word16 ap_lattice_coeffs_3_fx[DIRAC_DECORR_FILTER_LEN_3 * DIRAC_MAX_NUM_DECORR_FILTERS]; +extern const Word16 *const ap_lattice_coeffs_fx[DIRAC_DECORR_NUM_SPLIT_BANDS]; +extern const Word16 ap_split_frequencies_fx[DIRAC_DECORR_NUM_SPLIT_BANDS + 1]; #endif extern const int16_t sba_map_tc[11]; @@ -82,24 +87,31 @@ extern const int16_t channelIndex_CICP14[7]; extern const int16_t channelIndex_CICP16[9]; extern const int16_t channelIndex_CICP19[11]; +#ifndef IVAS_FLOAT_FIXED /* These are equalization values for spread and surround coherent sounds, approximating the spectrum * for such sounds at anechoic multichannel listening. */ extern const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; -extern const Word16 surCohEne_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; extern const float spreadCohEne05[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; -extern const Word16 spreadCohEne05_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; extern const float spreadCohEne1[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; -extern const Word16 spreadCohEne1_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; /* Values for low-bit-rate equalization */ extern const float lowBitRateBinauralEQ[LOW_BIT_RATE_BINAURAL_EQ_BINS]; -extern const Word32 lowBitRateBinauralEQ_fx[LOW_BIT_RATE_BINAURAL_EQ_BINS]; /* Diffuse field binaural coherence directional adjustment values */ extern const float diffuseFieldCoherenceDifferenceX[BINAURAL_COHERENCE_DIFFERENCE_BINS]; extern const float diffuseFieldCoherenceDifferenceY[BINAURAL_COHERENCE_DIFFERENCE_BINS]; extern const float diffuseFieldCoherenceDifferenceZ[BINAURAL_COHERENCE_DIFFERENCE_BINS]; -#ifdef IVAS_FLOAT_FIXED +#else +/* These are equalization values for spread and surround coherent sounds, approximating the spectrum + * for such sounds at anechoic multichannel listening. */ +extern const Word16 surCohEne_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; +extern const Word16 spreadCohEne05_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; +extern const Word16 spreadCohEne1_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS]; + +/* Values for low-bit-rate equalization */ +extern const Word32 lowBitRateBinauralEQ_fx[LOW_BIT_RATE_BINAURAL_EQ_BINS]; + +/* Diffuse field binaural coherence directional adjustment values */ extern const Word32 diffuseFieldCoherenceDifferenceX_fx[BINAURAL_COHERENCE_DIFFERENCE_BINS]; extern const Word32 diffuseFieldCoherenceDifferenceY_fx[BINAURAL_COHERENCE_DIFFERENCE_BINS]; extern const Word32 diffuseFieldCoherenceDifferenceZ_fx[BINAURAL_COHERENCE_DIFFERENCE_BINS]; @@ -112,10 +124,8 @@ extern const Word32 diffuseFieldCoherenceDifferenceZ_fx[BINAURAL_COHERENCE_DIFFE extern const int16_t HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS]; +#ifndef IVAS_FLOAT_FIXED extern const float SincTable[321]; -#ifdef IVAS_FLOAT_FIXED -extern const Word32 SincTable_fx[321]; -#endif extern const float defaultHRIR_coherence_48kHz[LR_IAC_LENGTH_NR_FC]; extern const float defaultHRIR_left_avg_power_48kHz[LR_IAC_LENGTH_NR_FC]; @@ -129,7 +139,9 @@ 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 +#else +extern const Word32 SincTable_fx[321]; + extern const Word32 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ extern const Word32 defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ extern const Word32 defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ @@ -141,7 +153,7 @@ extern const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; / extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ extern const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -#endif // IVAS_FLOAT_FIXED +#endif // IVAS_FLOAT_FIXED /*----------------------------------------------------------------------------------* * t-design and SN3D normalization table *----------------------------------------------------------------------------------*/ @@ -177,27 +189,27 @@ extern const float ivas_reverb_default_DSR[]; /*----------------------------------------------------------------------------------* * Renderer SBA & MC enc/dec matrices *----------------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED extern const float ls_azimuth_CICP1[1]; extern const float ls_elevation_CICP1[1]; - +#endif /*----------------------------------------------------------------------------------* * LS Configuration Converter ROM tables *----------------------------------------------------------------------------------*/ /* Downmix matrices */ +#ifndef IVAS_FLOAT_FIXED extern const float ls_conversion_cicpX_mono[12][1]; extern const float ls_conversion_cicpX_stereo[12][2]; -#ifdef IVAS_FLOAT_FIXED -extern const Word32 ls_conversion_cicpX_mono_fx[12][1]; -extern const Word32 ls_conversion_cicpX_stereo_fx[12][2]; -#endif /* Mapping table of input config : output config with corresponding matrix */ -#ifndef IVAS_FLOAT_FIXED extern const LS_CONVERSION_MAPPING ls_conversion_mapping[]; #else +extern const Word32 ls_conversion_cicpX_mono_fx[12][1]; +extern const Word32 ls_conversion_cicpX_stereo_fx[12][2]; + +/* Mapping table of input config : output config with corresponding matrix */ extern const LS_CONVERSION_MAPPING_FX ls_conversion_mapping_fx[]; #endif diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index be96d186f7f3f3b7066d72dadf67451847eba28f..9bb102e1d7f27e193688e8d8b5848f0a521ba772 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -47,11 +47,10 @@ #include "ivas_prot_fx.h" #include "debug.h" #include "ivas_rom_binaural_crend_head.h" -#define float_to_fixed( n, factor ) ( round( n * ( 1 << factor ) ) ) Word16 square_root16_table[] = { 0, 0x4000, 0x5A82 }; // Q14 Word16 square_root30_q12[31] = { - // Q10 + // Q12 0, 4096, 5793, @@ -94,12 +93,17 @@ static ivas_error combine_external_and_head_orientations( IVAS_VECTOR3 *listenerPos, EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); - +#ifndef IVAS_FLOAT_FIXED static void external_target_interpolation( EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, const int16_t i ); - +#else +static void external_target_interpolation_fx( + EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, + const Word16 i ); +#endif #ifndef IVAS_FLOAT_FIXED static bool are_orientations_same( const IVAS_QUATERNION *orientation1, const IVAS_QUATERNION *orientation2 ); #endif @@ -129,7 +133,7 @@ ivas_error ivas_headTrack_open_fx( } /* Initialization */ - ( *hHeadTrackData )->lrSwitchInterpVal_fx = 0; + ( *hHeadTrackData )->lrSwitchInterpVal_fx = 0; // Q30 move32(); ( *hHeadTrackData )->lrSwitchedCurrent = 0; move32(); @@ -140,7 +144,7 @@ ivas_error ivas_headTrack_open_fx( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Orientation tracking" ); } - IF( ( error = ivas_orient_trk_Init_fx( ( *hHeadTrackData )->OrientationTracker ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_orient_trk_Init_fx( ( *hHeadTrackData )->OrientationTracker ) ), IVAS_ERR_OK ) ) { return error; } @@ -149,7 +153,7 @@ ivas_error ivas_headTrack_open_fx( FOR( i = 0; i < 3; i++ ) { set32_fx( ( *hHeadTrackData )->Rmat_prev_fx[i], 0, 3 ); - ( *hHeadTrackData )->Rmat_prev_fx[i][i] = ONE_IN_Q31; + ( *hHeadTrackData )->Rmat_prev_fx[i][i] = ONE_IN_Q31; // Q31 move32(); } @@ -212,11 +216,12 @@ ivas_error ivas_headTrack_open( * * Deallocate Head-Tracking handle *-----------------------------------------------------------------------*/ - -void ivas_headTrack_close( +#ifdef IVAS_FLOAT_FIXED +void ivas_headTrack_close_fx( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ) { + test(); IF( hHeadTrackData == NULL || *hHeadTrackData == NULL ) { return; @@ -233,7 +238,28 @@ void ivas_headTrack_close( return; } +#else +void ivas_headTrack_close( + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ +) +{ + if ( hHeadTrackData == NULL || *hHeadTrackData == NULL ) + { + return; + } + + if ( ( *hHeadTrackData )->OrientationTracker != NULL ) + { + free( ( *hHeadTrackData )->OrientationTracker ); + ( *hHeadTrackData )->OrientationTracker = NULL; + } + free( ( *hHeadTrackData ) ); + *hHeadTrackData = NULL; + + return; +} +#endif /*---------------------------------------------------------------------------------- * QuatToRotMat() @@ -259,25 +285,18 @@ void QuatToRotMat_fx( // Adding a guard bit to squared terms since 2*x is not being done in those // statements (R[0][0], R[1][1], R[2][2]). This is done to avoid L_shl. Word32 ww = L_shr( Mpy_32_32( w, w ), 1 ); // 2 * Qx - 31 - 1 = 2*Qx-32 - move32(); Word32 xx = L_shr( Mpy_32_32( x, x ), 1 ); - move32(); Word32 yy = L_shr( Mpy_32_32( y, y ), 1 ); - move32(); Word32 zz = L_shr( Mpy_32_32( z, z ), 1 ); - move32(); + Word32 wx = Mpy_32_32( w, x ); - move32(); Word32 wz = Mpy_32_32( w, z ); - move32(); Word32 wy = Mpy_32_32( w, y ); - move32(); + Word32 xy = Mpy_32_32( x, y ); - move32(); Word32 xz = Mpy_32_32( x, z ); - move32(); + Word32 yz = Mpy_32_32( y, z ); - move32(); Rmat[0][0] = L_sub( L_sub( L_add( ww, xx ), yy ), zz ); move32(); @@ -302,8 +321,7 @@ void QuatToRotMat_fx( return; } -#endif - +#else void QuatToRotMat( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ @@ -323,6 +341,7 @@ void QuatToRotMat( return; } +#endif #ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- @@ -366,10 +385,14 @@ void Euler2Quat_fx( Word16 sp = getSinWord16( extract_l( L_shr_r( pitch, 10 ) ) ); Word16 cy = getCosWord16( extract_l( L_shr_r( yaw, 10 ) ) ); Word16 sy = getSinWord16( extract_l( L_shr_r( yaw, 10 ) ) ); - quat->w_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( cr, cp ), cy ), Mpy_32_16_1( L_mult0( sr, sp ), sy ) ), 5 ); - quat->x_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( sr, cp ), cy ), Mpy_32_16_1( L_mult0( cr, sp ), sy ) ), 5 ); - quat->y_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( sr, cp ), sy ), Mpy_32_16_1( L_mult0( cr, sp ), cy ) ), 5 ); - quat->z_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( cr, cp ), sy ), Mpy_32_16_1( L_mult0( sr, sp ), cy ) ), 5 ); + quat->w_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( cr, cp ), cy ), Mpy_32_16_1( L_mult0( sr, sp ), sy ) ), 5 ); // Q19 + move32(); + quat->x_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( sr, cp ), cy ), Mpy_32_16_1( L_mult0( cr, sp ), sy ) ), 5 ); // Q19 + move32(); + quat->y_fx = L_shr_r( L_add( Mpy_32_16_1( L_mult0( sr, cp ), sy ), Mpy_32_16_1( L_mult0( cr, sp ), cy ) ), 5 ); // Q19 + move32(); + quat->z_fx = L_shr_r( L_sub( Mpy_32_16_1( L_mult0( cr, cp ), sy ), Mpy_32_16_1( L_mult0( sr, sp ), cy ) ), 5 ); // Q19 + move32(); return; } @@ -381,7 +404,7 @@ void Euler2Quat_fx( * * Converts degrees to normalized radians *------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED float deg2rad( float degrees ) { @@ -396,9 +419,10 @@ float deg2rad( return PI_OVER_180 * degrees; } -#ifdef IVAS_FLOAT_FIXED +#else Word32 deg2rad_fx( - Word32 degrees ) + Word32 degrees // Q23 +) { WHILE( GE_32( degrees, DEGREE_180 ) ) { @@ -409,7 +433,7 @@ Word32 deg2rad_fx( degrees = L_add( degrees, DEGREE_360 ); } - return Mpy_32_32( PI_OVER_180_FX, degrees ); + return Mpy_32_32( PI_OVER_180_FX, degrees ); // Q23 } #endif @@ -418,7 +442,7 @@ Word32 deg2rad_fx( * * Converts normalized radians to degrees *------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED float rad2deg( float radians ) { @@ -433,9 +457,10 @@ float rad2deg( return _180_OVER_PI * radians; } -#ifdef IVAS_FLOAT_FIXED +#else Word32 rad2deg_fx( - Word32 radians ) + Word32 radians // Q13 +) { WHILE( GE_32( radians, EVS_PI_FX ) ) @@ -447,7 +472,7 @@ Word32 rad2deg_fx( radians = L_add( radians, EVS_PI_FX ); } - return ( radians * _180_OVER_PI_FX ); + return W_extract_l( W_mult0_32_32( radians, _180_OVER_PI_FX ) ); // Q23 } #endif #ifdef IVAS_FLOAT_FIXED @@ -458,11 +483,11 @@ Word32 rad2deg_fx( *------------------------------------------------------------------------*/ void rotateAziEle_fx( - Word16 azi_in, /* i : output elevation */ - Word16 ele_in, /* i : input elevation */ - Word16 *azi, /* o : rotated azimuth */ - Word16 *ele, /* o : rotated elevation */ - Word32 Rmat_fx[3][3], /* i : real-space rotation matrix */ + Word16 azi_in, /* i : output elevation Q0 */ + Word16 ele_in, /* i : input elevation Q0 */ + Word16 *azi, /* o : rotated azimuth Q0 */ + Word16 *ele, /* o : rotated elevation Q0 */ + Word32 Rmat_fx[3][3], /* i : real-space rotation matrix Q30*/ const Word16 isPlanar /* i : is rotation planar and elevation meaningless? */ ) { @@ -476,7 +501,14 @@ void rotateAziEle_fx( /*Conversion spherical to cartesian coordinates*/ IF( GT_16( abs_s( azi_in ), 180 ) ) { - azi_in = GT_16( azi_in, 0 ) ? sub( azi_in, 360 ) : add( azi_in, 360 ); + IF( azi_in > 0 ) + { + azi_in = sub( azi_in, 360 ); + } + ELSE + { + azi_in = add( azi_in, 360 ); + } } temp_16 = ele_in; move16(); @@ -497,8 +529,9 @@ void rotateAziEle_fx( /*Rotation mtx multiplication*/ FOR( n = 0; n < 3; n++ ) { - temp = L_add( Mpy_32_32( dv_fx[0], Rmat_fx[n][0] ), Mpy_32_32( dv_fx[1], Rmat_fx[n][1] ) ); - dv_r_fx[n] = L_add( Mpy_32_32( dv_fx[2], Rmat_fx[n][2] ), temp ); // Q30 + temp = L_add( Mpy_32_32( dv_fx[0], Rmat_fx[n][0] ), Mpy_32_32( dv_fx[1], Rmat_fx[n][1] ) ); // Q30 + dv_r_fx[n] = L_add( Mpy_32_32( dv_fx[2], Rmat_fx[n][2] ), temp ); // Q30 + move32(); } /*Conversion cartesian to spherical coordinates*/ @@ -507,21 +540,28 @@ void rotateAziEle_fx( x = dv_r_fx[0]; move32(); radian = atan2_fx( L_abs( L_shr( y, 15 ) ), L_abs( L_shr( x, 15 ) ) ); - radian = y > 0 ? radian : -radian; - IF( LT_32( x, 0 ) ) + if ( y <= 0 ) { - IF( LT_32( radian, 0 ) ) + radian = negate( radian ); + } + + IF( x < 0 ) + { + IF( radian < 0 ) { - angle = -add( 180, extract_l( L_shr( Mpy_32_16_1( _180_OVER_PI_Q25, radian ), ( 24 ) ) ) ); + angle = negate( add( 180, extract_l( L_shr( Mpy_32_16_1( _180_OVER_PI_Q25, radian ), ( 24 ) ) ) ) ); } ELSE { angle = sub( 180, extract_l( L_shr( Mpy_32_16_1( _180_OVER_PI_Q25, radian ), ( 24 ) ) ) ); } - IF( EQ_16( radian, 0 ) ) + IF( radian == 0 ) { - angle = GE_32( y, 0 ) ? angle : -angle; + if ( y < 0 ) + { + angle = negate( angle ); + } } } ELSE @@ -529,29 +569,38 @@ void rotateAziEle_fx( angle = extract_l( L_shr( Mpy_32_16_1( _180_OVER_PI_Q25, radian ), 24 ) ); } - *azi = (Word16) ( s_max( -180, min( 180, angle ) ) ); + *azi = s_max( -180, min( 180, angle ) ); + move16(); - IF( EQ_16( isPlanar, 0 ) ) + IF( isPlanar == 0 ) { sqrt_fx = L_Frac_sqrtQ31( L_add( Mpy_32_32( dv_r_fx[0], dv_r_fx[0] ), Mpy_32_32( dv_r_fx[1], dv_r_fx[1] ) ) ); y = dv_r_fx[2]; + move32(); x = sqrt_fx; + move32(); radian = atan2_fx( L_abs( L_shr( y, 15 ) ), L_abs( L_shr( x, 15 ) ) ); - radian = y > 0 ? radian : -radian; + if ( y <= 0 ) + { + radian = negate( radian ); + } - IF( LT_32( x, 0 ) ) + IF( x < 0 ) { - IF( LT_16( radian, 0 ) ) + IF( radian < 0 ) { - angle = -add( 180, extract_l( L_shr( Mpy_32_16_r( _180_OVER_PI_Q25, radian ), ( 24 ) ) ) ); + angle = negate( add( 180, extract_l( L_shr( Mpy_32_16_r( _180_OVER_PI_Q25, radian ), ( 24 ) ) ) ) ); } ELSE { angle = sub( 180, extract_l( L_shr( Mpy_32_16_r( _180_OVER_PI_Q25, radian ), ( 24 ) ) ) ); } - IF( EQ_16( radian, 0 ) ) + IF( radian == 0 ) { - angle = y >= 0 ? angle : -angle; + if ( y < 0 ) + { + angle = negate( angle ); + } } } ELSE @@ -559,7 +608,8 @@ void rotateAziEle_fx( angle = extract_l( L_shr( Mpy_32_16_r( _180_OVER_PI_Q25, radian ), ( 24 ) ) ); } - *ele = (Word16) ( s_max( -90, s_min( 90, angle ) ) ); + *ele = s_max( -90, s_min( 90, angle ) ); + move16(); } ELSE { @@ -576,11 +626,11 @@ void rotateAziEle_fx( * Apply rotation to direction parameters azimuth and elevation *------------------------------------------------------------------------*/ void rotateAziEle_fx_frac_az_el( - Word32 azi_in, /* i : output elevation */ - Word32 ele_in, /* i : input elevation */ - Word32 *azi, /* o : rotated azimuth */ - Word32 *ele, /* o : rotated elevation */ - Word32 Rmat_fx[3][3], /* i : real-space rotation matrix */ + Word32 azi_in, /* i : output elevation Q22 */ + Word32 ele_in, /* i : input elevation Q22 */ + Word32 *azi, /* o : rotated azimuth Q22 */ + Word32 *ele, /* o : rotated elevation Q22 */ + Word32 Rmat_fx[3][3], /* i : real-space rotation matrix Q30 */ const Word16 isPlanar /* i : is rotation planar and elevation meaningless? */ ) { @@ -594,13 +644,20 @@ void rotateAziEle_fx_frac_az_el( /*Conversion spherical to cartesian coordinates*/ IF( GT_32( abs( azi_in ), _180_IN_Q22 ) ) { - azi_in = GT_32( azi_in, 0 ) ? ( azi_in - _360_IN_Q22 ) : ( azi_in + _360_IN_Q22 ); - move32(); + IF( azi_in > 0 ) + { + azi_in = L_sub( azi_in, _360_IN_Q22 ); + } + ELSE + { + azi_in = L_add( azi_in, _360_IN_Q22 ); + } } - azi_in_q13 = (Word16) L_shr( Mpy_32_32( azi_in, PI_OVER_180_FX ), Q9 ); - ele_in_q13 = (Word16) L_shr( Mpy_32_32( ele_in, PI_OVER_180_FX ), Q9 ); + azi_in_q13 = extract_l( L_shr( Mpy_32_32( azi_in, PI_OVER_180_FX ), Q9 ) ); + ele_in_q13 = extract_l( L_shr( Mpy_32_32( ele_in, PI_OVER_180_FX ), Q9 ) ); w_fx = getCosWord16( ele_in_q13 ); // Q14 dv_fx[0] = L_mult( w_fx, getCosWord16( azi_in_q13 ) ); + move32(); IF( EQ_32( dv_fx[0], ONE_IN_Q29 ) ) { move32(); @@ -609,8 +666,10 @@ void rotateAziEle_fx_frac_az_el( ELSE { dv_fx[0] = L_shl( dv_fx[0], 2 ); + move32(); } dv_fx[1] = L_mult( w_fx, getSinWord16( azi_in_q13 ) ); + move32(); IF( EQ_32( dv_fx[1], ONE_IN_Q30 ) ) { move32(); @@ -619,8 +678,10 @@ void rotateAziEle_fx_frac_az_el( ELSE { dv_fx[1] = L_shl( dv_fx[1], 1 ); + move32(); } - dv_fx[2] = (Word32) getSinWord16( ele_in_q13 ); + dv_fx[2] = L_deposit_l( getSinWord16( ele_in_q13 ) ); + move32(); IF( EQ_32( dv_fx[2], ONE_IN_Q15 ) ) { move32(); @@ -629,6 +690,7 @@ void rotateAziEle_fx_frac_az_el( ELSE { dv_fx[2] = L_shl( dv_fx[2], 16 ); + move32(); } /*Rotation mtx multiplication*/ @@ -636,6 +698,7 @@ void rotateAziEle_fx_frac_az_el( { temp = L_add( Mpy_32_32( dv_fx[0], Rmat_fx[n][0] ), Mpy_32_32( dv_fx[1], Rmat_fx[n][1] ) ); dv_r_fx[n] = L_add( Mpy_32_32( dv_fx[2], Rmat_fx[n][2] ), temp ); // Q30 + move32(); } /*Conversion cartesian to spherical coordinates*/ @@ -645,17 +708,19 @@ void rotateAziEle_fx_frac_az_el( x = dv_r_fx[0]; radian = BASOP_util_atan2( y, x, 0 ); // Q13 - angle = ( Mpy_32_16_1( _180_OVER_PI_Q25, radian ) >> 1 ); // Q22 + angle = L_shr( Mpy_32_16_1( _180_OVER_PI_Q25, radian ), 1 ); // Q22 - *azi = (Word32) ( max( L_shl( -180, 22 ), min( L_shl( 180, 22 ), angle ) ) ); // Q22 - *azi = ( L_add( *azi, ONE_IN_Q21 ) >> Q22 ) << Q22; - IF( LT_32( abs( *azi ), ONE_IN_Q22 ) ) + *azi = L_max( L_shl( -180, 22 ), L_min( L_shl( 180, 22 ), angle ) ); // Q22 + move32(); + *azi = L_shl( L_shr( L_add( *azi, ONE_IN_Q21 ), Q22 ), Q22 ); + move32(); + if ( LT_32( abs( *azi ), ONE_IN_Q22 ) ) { move32(); *azi = 0; } - IF( EQ_16( isPlanar, 0 ) ) + IF( isPlanar == 0 ) { sqrt_fx = L_Frac_sqrtQ31( L_add( Mpy_32_32( dv_r_fx[0], dv_r_fx[0] ), Mpy_32_32( dv_r_fx[1], dv_r_fx[1] ) ) ); y = dv_r_fx[2]; @@ -664,12 +729,14 @@ void rotateAziEle_fx_frac_az_el( move32(); radian = BASOP_util_atan2( y, x, 0 ); - angle = ( Mpy_32_16_1( _180_OVER_PI_Q25, radian ) >> 1 ); // Q22 + angle = L_shr( Mpy_32_16_1( _180_OVER_PI_Q25, radian ), 1 ); // Q22 - *ele = (Word32) ( max( L_shl( -90, 22 ), min( L_shl( 90, 22 ), angle ) ) ); // Q22 - *ele = ( L_add( *ele, ONE_IN_Q21 ) >> Q22 ) << Q22; - IF( LT_32( abs( *ele ), ONE_IN_Q22 ) ) + *ele = L_max( L_shl( -90, 22 ), L_min( L_shl( 90, 22 ), angle ) ); // Q22 + move32(); + *ele = L_shl( L_shr( L_add( *ele, ONE_IN_Q21 ), Q22 ), Q22 ); + move32(); + if ( LT_32( abs( *ele ), ONE_IN_Q22 ) ) { *ele = 0; move32(); @@ -691,11 +758,11 @@ void rotateAziEle_fx_frac_az_el( *------------------------------------------------------------------------*/ void rotateAziEle_fixed( - Word16 azi_in, /* i : output elevation */ - Word16 ele_in, /* i : input elevation */ - Word32 *azi, /* o : rotated azimuth */ - Word32 *ele, /* o : rotated elevation */ - Word32 Rmat_fx[3][3], /* i : real-space rotation matrix */ + Word16 azi_in, /* i : output elevation Q0 */ + Word16 ele_in, /* i : input elevation Q0 */ + Word32 *azi, /* o : rotated azimuth Q22 */ + Word32 *ele, /* o : rotated elevation Q22 */ + Word32 Rmat_fx[3][3], /* i : real-space rotation matrix Q30 */ const Word16 isPlanar /* i : is rotation planar and elevation meaningless? */ ) { @@ -708,7 +775,14 @@ void rotateAziEle_fixed( /*Conversion spherical to cartesian coordinates*/ IF( GT_16( abs_s( azi_in ), 180 ) ) { - azi_in = ( azi_in > 0 ) ? sub( azi_in, 360 ) : add( azi_in, 360 ); + IF( azi_in > 0 ) + { + azi_in = sub( azi_in, 360 ); + } + ELSE + { + azi_in = add( azi_in, 360 ); + } } temp_16 = ele_in; move16(); @@ -731,6 +805,7 @@ void rotateAziEle_fixed( { temp = L_add( Mpy_32_32( dv_fx[0], Rmat_fx[n][0] ), Mpy_32_32( dv_fx[1], Rmat_fx[n][1] ) ); dv_r_fx[n] = L_add( Mpy_32_32( dv_fx[2], Rmat_fx[n][2] ), temp ); // Q30 + move32(); } /*Conversion cartesian to spherical coordinates*/ @@ -742,25 +817,27 @@ void rotateAziEle_fixed( angle = L_shr( Mpy_32_16_1( _180_OVER_PI_Q25, radian ), 1 ); // Q22 - - *azi = (Word32) ( L_max( L_shl( -180, 22 ), L_min( L_shl( 180, 22 ), angle ) ) ); // Q22 - IF( LE_32( L_abs( *azi ), ONE_IN_Q22 ) ) + *azi = L_max( L_shl( -180, 22 ), L_min( L_shl( 180, 22 ), angle ) ); // Q22 + move32(); + if ( LE_32( L_abs( *azi ), ONE_IN_Q22 ) ) { *azi = 0; move32(); } - IF( EQ_16( isPlanar, 0 ) ) + IF( isPlanar == 0 ) { sqrt_fx = L_Frac_sqrtQ31( L_add( Mpy_32_32( dv_r_fx[0], dv_r_fx[0] ), Mpy_32_32( dv_r_fx[1], dv_r_fx[1] ) ) ); y = dv_r_fx[2]; + move32(); x = sqrt_fx; + move32(); radian = BASOP_util_atan2( y, x, 0 ); angle = L_shr( Mpy_32_16_1( _180_OVER_PI_Q25, radian ), 1 ); // Q22 - - *ele = (Word32) ( L_max( L_shl( -90, 22 ), L_min( L_shl( 90, 22 ), angle ) ) ); // Q22 - IF( LT_32( L_abs( *ele ), ONE_IN_Q22 ) ) + *ele = L_max( L_shl( -90, 22 ), L_min( L_shl( 90, 22 ), angle ) ); // Q22 + move32(); + if ( LT_32( L_abs( *ele ), ONE_IN_Q22 ) ) { *ele = 0; move32(); @@ -775,6 +852,7 @@ void rotateAziEle_fixed( return; } #endif +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- * rotateAziEle() * @@ -822,6 +900,7 @@ void rotateAziEle( return; } +#endif #ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- @@ -832,45 +911,52 @@ void rotateAziEle( void rotateFrame_shd( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : head and external orientation combined handle */ - Word32 *output[], /* i/o: unrotated HOA3 signal buffer in TD */ + Word32 *output[], /* i/o: unrotated HOA3 signal buffer in TD Q11 */ const Word16 subframe_len, /* i : subframe length per channel */ const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ const Word16 subframe_idx /* i : subframe index */ ) { // Not yet tested, no test cases entering the function. - Word16 i, l, n, m; + Word16 i, l, n, m, offset; Word16 m1, m2; Word16 shd_rot_max_order; Word32 tmp = Q31_BY_SUB_FRAME_240; + move32(); Word32 tmpRot[2 * HEADROT_ORDER + 1]; Word16 SHrotmat_prev[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM]; Word16 SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM]; Word32 cross_fade[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; shd_rot_max_order = hTransSetup.ambisonics_order; + move16(); + offset = imult1616( subframe_idx, subframe_len ); SWITCH( subframe_len ) { case L_SUBFRAME_48k: tmp = Q31_BY_SUB_FRAME_240; + move32(); BREAK; case L_SUBFRAME_32k: tmp = Q31_BY_SUB_FRAME_180; + move32(); BREAK; case L_SUBFRAME_16k: tmp = Q31_BY_SUB_FRAME_80; + move32(); BREAK; case L_SUBFRAME_8k: tmp = Q31_BY_SUB_FRAME_40; + move32(); BREAK; default: BREAK; } - move32(); FOR( i = 0; i < subframe_len; i++ ) { - cross_fade[i] = UL_Mpy_32_32( i, tmp ); + cross_fade[i] = UL_Mpy_32_32( i, tmp ); // Q31 + move32(); } /* initialize rotation matrices with zeros */ FOR( i = 0; i < HEADROT_SHMAT_DIM; i++ ) @@ -882,7 +968,7 @@ void rotateFrame_shd( /* calculate ambisonics rotation matrices for the previous and current frames */ SHrotmatgen_fx( SHrotmat_prev, hCombinedOrientationData->Rmat_prev_fx, shd_rot_max_order ); - SHrotmatgen_fx( SHrotmat, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], shd_rot_max_order ); + SHrotmatgen_fx( SHrotmat /*Q14*/, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], shd_rot_max_order ); FOR( i = 0; i < subframe_len; i++ ) { @@ -904,15 +990,16 @@ void rotateFrame_shd( FOR( m = m1; m < m2; m++ ) { /* crossfade with previous rotation gains */ - tmp = L_add( Mpy_32_32( Mpy_32_16_r( cross_fade[i], SHrotmat[n][m] ), output[m][subframe_idx * subframe_len + i] ), Mpy_32_32( Mpy_32_16_r( L_sub( ONE_IN_Q31, cross_fade[i] ), SHrotmat_prev[n][m] ), output[m][subframe_idx * subframe_len + i] ) ); - tmpRot[n - m1] = L_add( L_shl( tmp, 1 ), tmpRot[n - m1] ); + tmp = L_add( Mpy_32_32( Mpy_32_16_r( cross_fade[i], SHrotmat[n][m] ) /*Q30*/, output[m][add( offset, i )] /*Q11*/ ), Mpy_32_32( Mpy_32_16_r( L_sub( ONE_IN_Q31, cross_fade[i] ), SHrotmat_prev[n][m] ) /*Q30*/, output[m][add( offset, i )] /*Q11*/ ) ); + tmpRot[n - m1] = L_add( L_shl( tmp, 1 ), tmpRot[n - m1] ); // Q11 } } /* write back the result */ FOR( n = m1; n < m2; n++ ) { - output[n][subframe_idx * subframe_len + i] = (Word32) tmpRot[n - m1]; + output[n][add( offset, i )] = tmpRot[n - m1]; // Q11 + move32(); } m1 = m2; move16(); @@ -1062,19 +1149,19 @@ void rotateFrame_shd( *------------------------------------------------------------------------*/ void rotateFrame_sd( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : head and external orientation combined handle */ - Word32 *output[], /* i/o: unrotated SD signal buffer in TD */ + Word32 *output[], /* i/o: unrotated SD signal buffer in TD Q11 */ const Word16 subframe_len, /* i : subframe length per channel */ const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ const Word16 subframe_idx /* i : subframe index */ ) { - Word16 i, j; + Word16 i, j, offset; Word16 nchan, index_lfe; Word16 ch_in, ch_in_woLFE, ch_out, ch_out_woLFE; Word16 azimuth, elevation; Word32 azimuth_fx, elevation_fx; - Word32 tmp = Q31_BY_SUB_FRAME_240; + Word32 tmp = Q31_BY_SUB_FRAME_240; // Q31 move32(); Word32 out_temp; Word32 tmp_gains_fx[MAX_CICP_CHANNELS - 1]; @@ -1086,33 +1173,39 @@ void rotateFrame_sd( nchan = add( hTransSetup.nchan_out_woLFE, hTransSetup.num_lfe ); index_lfe = hTransSetup.index_lfe[0]; move16(); + offset = imult1616( subframe_idx, subframe_len ); SWITCH( subframe_len ) { case L_SUBFRAME_48k: tmp = Q31_BY_SUB_FRAME_240; + move32(); BREAK; case L_SUBFRAME_32k: tmp = Q31_BY_SUB_FRAME_180; + move32(); BREAK; case L_SUBFRAME_16k: tmp = Q31_BY_SUB_FRAME_80; + move32(); BREAK; case L_SUBFRAME_8k: tmp = Q31_BY_SUB_FRAME_40; + move32(); BREAK; default: BREAK; } - move32(); + FOR( i = 0; i < subframe_len; i++ ) { - cross_fade_fx[i] = UL_Mpy_32_32( i, tmp ); + cross_fade_fx[i] = UL_Mpy_32_32( i, tmp ); // Q31 + move32(); } FOR( ch_in = 0; ch_in < nchan; ch_in++ ) { /* zero output and gain buffers */ - set_val_Word32( &output_tmp_fx[ch_in][subframe_idx * subframe_len], 0, subframe_len ); + set_val_Word32( &output_tmp_fx[ch_in][offset], 0, subframe_len ); set_val_Word32( gains_prev_fx[ch_in], 0, nchan ); set_val_Word32( gains_fx[ch_in], 0, nchan ); /* set gains to passthrough by default */ @@ -1127,17 +1220,25 @@ void rotateFrame_sd( } /* input channel index without LFE */ - ch_in_woLFE = ( ch_in >= index_lfe ) ? sub( ch_in, 1 ) : ch_in; + IF( GE_16( ch_in, index_lfe ) ) + { + ch_in_woLFE = sub( ch_in, 1 ); + } + ELSE + { + ch_in_woLFE = ch_in; + move16(); + } /* gains for previous subframe rotation */ - rotateAziEle_fx( (Word16) L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ), (Word16) L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ), &azimuth, &elevation, hCombinedOrientationData->Rmat_prev_fx, hTransSetup.is_planar_setup ); + rotateAziEle_fx( extract_l( L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ) ), extract_l( L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ) ), &azimuth, &elevation, hCombinedOrientationData->Rmat_prev_fx, hTransSetup.is_planar_setup ); test(); test(); - IF( hEFAPdata != NULL && ( (Word16) L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ) != azimuth || (Word16) L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ) != elevation ) ) + IF( hEFAPdata != NULL && ( NE_16( extract_l( L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ) ), azimuth ) || NE_16( extract_l( L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ) ), elevation ) ) ) { - azimuth_fx = L_shl( (Word32) azimuth, Q22 ); - elevation_fx = L_shl( (Word32) elevation, Q22 ); + azimuth_fx = L_shl( L_deposit_l( azimuth ), Q22 ); + elevation_fx = L_shl( L_deposit_l( elevation ), Q22 ); efap_determine_gains_fx( hEFAPdata, tmp_gains_fx, azimuth_fx, elevation_fx, EFAP_MODE_EFAP ); @@ -1150,19 +1251,29 @@ void rotateFrame_sd( } /* output channel index without LFE */ - ch_out_woLFE = ( ch_out >= index_lfe ) ? sub( ch_out, 1 ) : ch_out; + IF( GE_16( ch_out, index_lfe ) ) + { + ch_out_woLFE = sub( ch_out, 1 ); + } + ELSE + { + ch_out_woLFE = ch_out; + move16(); + } gains_prev_fx[ch_in][ch_out] = tmp_gains_fx[ch_out_woLFE]; // Q30 + move32(); } } /* gains for current subframe rotation */ - rotateAziEle_fx( (Word16) L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ), (Word16) L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ), &azimuth, &elevation, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hTransSetup.is_planar_setup ); - - IF( hEFAPdata != NULL && ( (Word16) L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ) != azimuth || (Word16) L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ) != elevation ) ) + rotateAziEle_fx( extract_l( L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ) ), extract_l( L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ) ), &azimuth, &elevation, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], hTransSetup.is_planar_setup ); + test(); + test(); + IF( hEFAPdata != NULL && ( NE_16( extract_l( L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ) ), azimuth ) || NE_16( extract_l( L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ) ), elevation ) ) ) { - azimuth_fx = L_shl( (Word32) azimuth, Q22 ); - elevation_fx = L_shl( (Word32) elevation, Q22 ); + azimuth_fx = L_shl( L_deposit_l( azimuth ), Q22 ); + elevation_fx = L_shl( L_deposit_l( elevation ), Q22 ); efap_determine_gains_fx( hEFAPdata, tmp_gains_fx, azimuth_fx, elevation_fx, EFAP_MODE_EFAP ); FOR( ch_out = 0; ch_out < nchan; ch_out++ ) @@ -1174,9 +1285,18 @@ void rotateFrame_sd( } /* output channel index without LFE */ - ch_out_woLFE = ( ch_out >= index_lfe ) ? sub( ch_out, 1 ) : ch_out; + IF( GE_16( ch_out, index_lfe ) ) + { + ch_out_woLFE = sub( ch_out, 1 ); + } + ELSE + { + ch_out_woLFE = ch_out; + move16(); + } gains_fx[ch_in][ch_out] = tmp_gains_fx[ch_out_woLFE]; // Q30 + move32(); } } } @@ -1192,10 +1312,11 @@ void rotateFrame_sd( { out_temp = output[ch_in][i]; move32(); - Word32 temp = Mpy_32_32( Mpy_32_32( ( cross_fade_fx[j] ), gains_fx[ch_in][ch_out] ), out_temp ); - Word32 temp1 = Mpy_32_32( Mpy_32_32( L_sub( ONE_IN_Q31, cross_fade_fx[j] ), gains_prev_fx[ch_in][ch_out] ), out_temp ); - output_tmp_fx[ch_out][i] = L_add( L_shl( L_add( temp, temp1 ), 1 ), output_tmp_fx[ch_out][i] ); - j++; + Word32 temp = Mpy_32_32( Mpy_32_32( ( cross_fade_fx[j] ), gains_fx[ch_in][ch_out] ), out_temp ); // Q10 + Word32 temp1 = Mpy_32_32( Mpy_32_32( L_sub( ONE_IN_Q31, cross_fade_fx[j] ), gains_prev_fx[ch_in][ch_out] ), out_temp ); // Q10 + output_tmp_fx[ch_out][i] = L_add( L_shl( L_add( temp, temp1 ), 1 ), output_tmp_fx[ch_out][i] ); // Q11 + move32(); + j = add( j, 1 ); } } } @@ -1211,7 +1332,7 @@ void rotateFrame_sd( /* copy to output */ FOR( ch_out = 0; ch_out < nchan; ch_out++ ) { - mvr2r_Word32( &output_tmp_fx[ch_out][subframe_idx * subframe_len], &output[ch_out][subframe_idx * subframe_len], subframe_len ); + mvr2r_Word32( &output_tmp_fx[ch_out][offset], &output[ch_out][offset], subframe_len ); } pop_wmops(); @@ -1358,12 +1479,12 @@ void rotateFrame_sd( * Apply rotation to signals in Spherical Harmonic Domain and in CLDFB *------------------------------------------------------------------------*/ void rotateFrame_shd_cldfb( - Word32 Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */ - Word32 Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ - Word32 Rmat[3][3], /* i : real-space rotation matrix */ - const Word16 nInChannels, /* i : number of channels */ - const Word16 numTimeSlots, /* i : number of time slots to process */ - const Word16 shd_rot_max_order /* i : split-order rotation method */ + Word32 Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part Qx -> Qx-1 */ + Word32 Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part Qx -> Qx-1 */ + Word32 Rmat[3][3], /* i : real-space rotation matrix Q30 */ + const Word16 nInChannels, /* i : number of channels */ + const Word16 numTimeSlots, /* i : number of time slots to process */ + const Word16 shd_rot_max_order /* i : split-order rotation method */ ) { Word16 n = 0; @@ -1374,6 +1495,15 @@ void rotateFrame_shd_cldfb( Word32 realRot[2 * HEADROT_ORDER + 1], imagRot[2 * HEADROT_ORDER + 1]; Word16 SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM]; Word32 temp1, temp2; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); assert( nInChannels == HEADROT_SHMAT_DIM && "Number of channels must be 16!" ); /* initialize rotation matrices with zeros */ @@ -1414,16 +1544,18 @@ void rotateFrame_shd_cldfb( { temp1 = Mpy_32_16_r( Cldfb_RealBuffer[m][i][iBand], SHrotmat[n][m] ); temp2 = Mpy_32_16_r( Cldfb_ImagBuffer[m][i][iBand], SHrotmat[n][m] ); - realRot[n - m1] = L_add( temp1, realRot[n - m1] ); // Q(exp_real + 14 - 15) - imagRot[n - m1] = L_add( temp2, imagRot[n - m1] ); // Q(exp_im + 14 - 15) + realRot[n - m1] = L_add( temp1, realRot[n - m1] ); // Q(x + 14 - 15) + move32(); + imagRot[n - m1] = L_add( temp2, imagRot[n - m1] ); // Q(x + 14 - 15) + move32(); } } /* write back the result */ FOR( n = m1; n < m2; n++ ) { - Cldfb_RealBuffer[n][i][iBand] = realRot[n - m1]; + Cldfb_RealBuffer[n][i][iBand] = realRot[n - m1]; // Qx - 1 move32(); - Cldfb_ImagBuffer[n][i][iBand] = imagRot[n - m1]; + Cldfb_ImagBuffer[n][i][iBand] = imagRot[n - m1]; // Qx - 1 move32(); } m1 = m2; @@ -1456,8 +1588,10 @@ void rotateFrame_shd_cldfb( { FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) { - Cldfb_RealBuffer[0][j][k] = L_shr( Cldfb_RealBuffer[0][j][k], 1 ); - Cldfb_ImagBuffer[0][j][k] = L_shr( Cldfb_ImagBuffer[0][j][k], 1 ); + Cldfb_RealBuffer[0][j][k] = L_shr( Cldfb_RealBuffer[0][j][k], 1 ); // Qx - 1 + move32(); + Cldfb_ImagBuffer[0][j][k] = L_shr( Cldfb_ImagBuffer[0][j][k], 1 ); // Qx - 1 + move32(); } } return; @@ -1671,13 +1805,13 @@ void rotateFrame_sd_cldfb( *------------------------------------------------------------------------*/ void rotateFrame_sd_cldfb_fixed( - Word32 Rmat_fx[3][3], /* i : real-space rotation matrix (Q30) */ - Word32 Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part */ - Word32 Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ - const IVAS_OUTPUT_SETUP_HANDLE hOutputSetup, /* i : output format setup number of channels */ - const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ - const Word16 numTimeSlots, /* i : number of time slots to process */ - const Word16 nb_band /* i : number of CLDFB bands to process */ + Word32 Rmat_fx[3][3], /* i : real-space rotation matrix (Q30) */ + Word32 Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain real part Qx */ + Word32 Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part Qx */ + const IVAS_OUTPUT_SETUP_HANDLE hOutputSetup, /* i : output format setup number of channels */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ + const Word16 numTimeSlots, /* i : number of time slots to process */ + const Word16 nb_band /* i : number of CLDFB bands to process */ ) { Word16 iBlock, iBand, m, n; @@ -1693,12 +1827,15 @@ void rotateFrame_sd_cldfb_fixed( push_wmops( "rotateFrame_sd_cldfb" ); nInChannels = hOutputSetup->nchan_out_woLFE; + move16(); isPlanar = 1; + move16(); FOR( n = 0; n < nInChannels; n++ ) { IF( hOutputSetup->ls_elevation_fx[n] != 0 ) { isPlanar = 0; + move16(); BREAK; } } @@ -1706,16 +1843,17 @@ void rotateFrame_sd_cldfb_fixed( /* rotation of Euler angles */ FOR( n = 0; n < nInChannels; n++ ) { - rotateAziEle_fx( (Word16) L_shr( hOutputSetup->ls_azimuth_fx[n], Q22 ), (Word16) L_shr( hOutputSetup->ls_elevation_fx[n], Q22 ), &azimuth, &elevation, Rmat_fx, isPlanar ); - IF( hEFAPdata != NULL && ( (Word16) L_shr( hOutputSetup->ls_azimuth_fx[n], Q22 ) != azimuth || (Word16) L_shr( hOutputSetup->ls_elevation_fx[n], Q22 ) != elevation ) ) + rotateAziEle_fx( extract_l( L_shr( hOutputSetup->ls_azimuth_fx[n], Q22 ) ), extract_l( L_shr( hOutputSetup->ls_elevation_fx[n], Q22 ) ), &azimuth, &elevation, Rmat_fx, isPlanar ); + test(); + test(); + IF( hEFAPdata != NULL && ( NE_16( extract_l( L_shr( hOutputSetup->ls_azimuth_fx[n], Q22 ) ), azimuth ) || NE_16( extract_l( L_shr( hOutputSetup->ls_elevation_fx[n], Q22 ) ), elevation ) ) ) { - // efap_determine_gains( hEFAPdata, gains[n], azimuth, elevation, EFAP_MODE_EFAP ); efap_determine_gains_fx( hEFAPdata, gains_fx[n], L_shl( azimuth, Q22 ), L_shl( elevation, Q22 ), EFAP_MODE_EFAP ); } ELSE { set_l( gains_fx[n], 0, nInChannels ); - gains_fx[n][n] = 0x7fffffff; + gains_fx[n][n] = 0x7fffffff; // Q31 move32(); } } @@ -1730,22 +1868,20 @@ void rotateFrame_sd_cldfb_fixed( g1_fx = gains_fx[m][n]; move32(); p_realRot_fx = realRot_fx[n]; - move32(); p_imagRot_fx = imagRot_fx[n]; - move32(); - IF( GT_32( g1_fx, 0 ) ) + + IF( g1_fx > 0 ) { FOR( iBlock = 0; iBlock < numTimeSlots; iBlock++ ) { p_real_fx = Cldfb_RealBuffer[m][iBlock]; - move32(); p_imag_fx = Cldfb_ImagBuffer[m][iBlock]; - move32(); + FOR( iBand = 0; iBand < nb_band; iBand++ ) { - *( p_realRot_fx ) = L_add( *p_realRot_fx, Mpy_32_32( g1_fx, *( p_real_fx++ ) ) ); + *( p_realRot_fx ) = L_add( *p_realRot_fx, Mpy_32_32( g1_fx, *( p_real_fx++ ) ) ); // Qx move32(); - *( p_imagRot_fx ) = L_add( *p_imagRot_fx, Mpy_32_32( g1_fx, *( p_imag_fx++ ) ) ); + *( p_imagRot_fx ) = L_add( *p_imagRot_fx, Mpy_32_32( g1_fx, *( p_imag_fx++ ) ) ); // Qx move32(); p_realRot_fx++; p_imagRot_fx++; @@ -1758,15 +1894,13 @@ void rotateFrame_sd_cldfb_fixed( FOR( n = 0; n < nInChannels; n++ ) { p_realRot_fx = realRot_fx[n]; - move32(); p_imagRot_fx = imagRot_fx[n]; - move32(); + FOR( iBlock = 0; iBlock < numTimeSlots; iBlock++ ) { p_real_fx = Cldfb_RealBuffer[n][iBlock]; - move32(); p_imag_fx = Cldfb_ImagBuffer[n][iBlock]; - move32(); + FOR( iBand = 0; iBand < nb_band; iBand++ ) { *( p_real_fx++ ) = *( p_realRot_fx++ ); @@ -1819,14 +1953,19 @@ ivas_error ivas_external_orientation_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for external orientation memory\n" ) ); } ( *hExtOrientationData )->num_subframes = num_subframes; + move16(); /* Enable head rotation and disable external orientation as default */ FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { ( *hExtOrientationData )->enableHeadRotation[i] = 1; + move16(); ( *hExtOrientationData )->enableExternalOrientation[i] = 0; + move16(); ( *hExtOrientationData )->enableRotationInterpolation[i] = 0; + move16(); ( *hExtOrientationData )->numFramesToTargetOrientation[i] = 0; move16(); + ( *hExtOrientationData )->Quaternions[i] = identity; } return IVAS_ERR_OK; @@ -1870,7 +2009,7 @@ ivas_error ivas_external_orientation_open( * Deallocate external orientation handle *-----------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -void ivas_external_orientation_close( +void ivas_external_orientation_close_fx( EXTERNAL_ORIENTATION_HANDLE *hExtOrientationData /* i/o: external orientation handle */ ) { @@ -1918,6 +2057,7 @@ ivas_error ivas_combined_orientation_open( Word16 i; Word16 j; Word16 tmp_e = 0, tmp; + move16(); IVAS_QUATERNION identity; IVAS_VECTOR3 origo; identity.w_fx = ONE_IN_Q31; @@ -1947,9 +2087,9 @@ ivas_error ivas_combined_orientation_open( /* Initialization */ ( *hCombinedOrientationData )->num_subframes = num_subframes; move16(); - ( *hCombinedOrientationData )->interpolationCoefficient_fx = ONE_IN_Q30; + ( *hCombinedOrientationData )->interpolationCoefficient_fx = ONE_IN_Q30; // Q30 move32(); - ( *hCombinedOrientationData )->interpolationIncrement_fx = ONE_IN_Q30; + ( *hCombinedOrientationData )->interpolationIncrement_fx = ONE_IN_Q30; // Q30 move32(); IF( EQ_16( num_subframes, 1 ) ) { @@ -1962,10 +2102,14 @@ ivas_error ivas_combined_orientation_open( move16(); } ( *hCombinedOrientationData )->lrSwitchedNext = 0; + move16(); ( *hCombinedOrientationData )->lrSwitchedCurrent = 0; + move16(); ( *hCombinedOrientationData )->lrSwitchInterpVal_fx = 0; + move32(); ( *hCombinedOrientationData )->isInterpolationOngoing = FALSE; + move16(); ( *hCombinedOrientationData )->Quaternions_ext_interpolation_start = identity; ( *hCombinedOrientationData )->Quaternions_ext_interpolation_target = identity; @@ -1980,7 +2124,7 @@ ivas_error ivas_combined_orientation_open( FOR( j = 0; j < 3; j++ ) { set32_fx( ( *hCombinedOrientationData )->Rmat_fx[i][j], 0, 3 ); - ( *hCombinedOrientationData )->Rmat_fx[i][j][j] = ONE_IN_Q30; + ( *hCombinedOrientationData )->Rmat_fx[i][j][j] = ONE_IN_Q30; // Q30 move32(); } } @@ -2003,14 +2147,18 @@ ivas_error ivas_combined_orientation_open( ( *hCombinedOrientationData )->q_procChEneIIR = Q31; move16(); ( *hCombinedOrientationData )->isExtOrientationFrozen = 0; + move16(); ( *hCombinedOrientationData )->isHeadRotationFrozen = 0; + move16(); ( *hCombinedOrientationData )->subframe_idx = 0; move16(); tmp = BASOP_Util_Divide3232_Scale( fs, MAX_PARAM_SPATIAL_SUB_FRAMES_PER_SEC, &tmp_e ); ( *hCombinedOrientationData )->subframe_size = shr( tmp, sub( 15, tmp_e ) ); + move16(); // ( *hCombinedOrientationData )->subframe_size = (int16_t) ( fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); ( *hCombinedOrientationData )->cur_subframe_samples_rendered = 0; + move16(); return IVAS_ERR_OK; } @@ -2102,7 +2250,7 @@ ivas_error ivas_combined_orientation_open( *-----------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -void ivas_combined_orientation_close( +void ivas_combined_orientation_close_fx( COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* i/o: combined orientation handle */ ) { @@ -2189,9 +2337,10 @@ ivas_error combine_external_and_head_orientations_rend( /* Head rotation data not available, use the freezed value or disable */ FOR( i = 0; i < hExtOrientationData->num_subframes; i++ ) { - IF( hExtOrientationData->enableHeadRotation[i] != 2 ) + IF( NE_16( hExtOrientationData->enableHeadRotation[i], 2 ) ) { hExtOrientationData->enableHeadRotation[i] = 0; + move16(); } } } @@ -2239,6 +2388,8 @@ ivas_error combine_external_and_head_orientations( move16(); /* Form combined orientations or return if no data available */ + test(); + test(); IF( hCombinedOrientationData == NULL ) { test(); @@ -2255,6 +2406,7 @@ ivas_error combine_external_and_head_orientations( { /* Reset the combined orientations and rotations */ hCombinedOrientationData->isInterpolationOngoing = FALSE; + move16(); hCombinedOrientationData->interpolationCoefficient_fx = ONE_IN_Q30; move32(); hCombinedOrientationData->interpolationIncrement_fx = ONE_IN_Q30; @@ -2264,6 +2416,7 @@ ivas_error combine_external_and_head_orientations( FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) { hCombinedOrientationData->enableCombinedOrientation[i] = 0; + move16(); hCombinedOrientationData->Quaternions[i] = identity; hCombinedOrientationData->listenerPos[i] = origo; @@ -2290,35 +2443,46 @@ ivas_error combine_external_and_head_orientations( FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) { /* Check for frozen external orientation */ - IF( hExtOrientationData->enableExternalOrientation[i] == 2 ) + IF( EQ_16( hExtOrientationData->enableExternalOrientation[i], 2 ) ) { - IF( hCombinedOrientationData->isExtOrientationFrozen != 1 ) + IF( NE_16( hCombinedOrientationData->isExtOrientationFrozen, 1 ) ) { hCombinedOrientationData->Quaternion_frozen_ext = hExtOrientationData->Quaternions[i]; hCombinedOrientationData->isExtOrientationFrozen = 1; + move16(); } } ELSE { hCombinedOrientationData->Quaternion_frozen_ext = identity; hCombinedOrientationData->isExtOrientationFrozen = 0; + move16(); } test(); - IF( hExtOrientationData->enableRotationInterpolation[i] == 1 && hExtOrientationData->enableExternalOrientation[i] > 0 ) + IF( EQ_16( hExtOrientationData->enableRotationInterpolation[i], 1 ) && hExtOrientationData->enableExternalOrientation[i] > 0 ) { test(); - IF( hCombinedOrientationData->isInterpolationOngoing == true && hCombinedOrientationData->interpolationCoefficient_fx <= ONE_IN_Q30 && are_orientations_same_fx( &hCombinedOrientationData->Quaternions_ext_interpolation_target, &hExtOrientationData->Quaternions[i] ) == true ) + test(); + IF( EQ_16( hCombinedOrientationData->isInterpolationOngoing, true ) && LE_32( hCombinedOrientationData->interpolationCoefficient_fx, ONE_IN_Q30 ) && EQ_16( are_orientations_same_fx( &hCombinedOrientationData->Quaternions_ext_interpolation_target, &hExtOrientationData->Quaternions[i] ), true ) ) { /* Continue interpolation */ - hCombinedOrientationData->Quaternions_ext_interpolation_start.w_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.w_fx, hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact - Q29 ); - hCombinedOrientationData->Quaternions_ext_interpolation_start.x_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.x_fx, hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact - Q29 ); - hCombinedOrientationData->Quaternions_ext_interpolation_start.y_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.y_fx, hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact - Q29 ); - hCombinedOrientationData->Quaternions_ext_interpolation_start.z_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.z_fx, hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact - Q29 ); + hCombinedOrientationData->Quaternions_ext_interpolation_start.w_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.w_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact, Q29 ) ); // Q29 + move32(); + hCombinedOrientationData->Quaternions_ext_interpolation_start.x_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.x_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact, Q29 ) ); // Q29 + move32(); + hCombinedOrientationData->Quaternions_ext_interpolation_start.y_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.y_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact, Q29 ) ); // Q29 + move32(); + hCombinedOrientationData->Quaternions_ext_interpolation_start.z_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.z_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact, Q29 ) ); // Q29 + move32(); - hCombinedOrientationData->Quaternions_ext_interpolation_target.w_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.w_fx, hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact - Q29 ); - hCombinedOrientationData->Quaternions_ext_interpolation_target.x_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.x_fx, hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact - Q29 ); - hCombinedOrientationData->Quaternions_ext_interpolation_target.y_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.y_fx, hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact - Q29 ); - hCombinedOrientationData->Quaternions_ext_interpolation_target.z_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.z_fx, hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact - Q29 ); + hCombinedOrientationData->Quaternions_ext_interpolation_target.w_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.w_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact, Q29 ) ); // Q29 + move32(); + hCombinedOrientationData->Quaternions_ext_interpolation_target.x_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.x_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact, Q29 ) ); // Q29 + move32(); + hCombinedOrientationData->Quaternions_ext_interpolation_target.y_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.y_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact, Q29 ) ); // Q29 + move32(); + hCombinedOrientationData->Quaternions_ext_interpolation_target.z_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.z_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact, Q29 ) ); // Q29 + move32(); hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact = Q29; move16(); @@ -2326,24 +2490,31 @@ ivas_error combine_external_and_head_orientations( move16(); QuaternionSlerp_fx( hCombinedOrientationData->Quaternions_ext_interpolation_start, hCombinedOrientationData->Quaternions_ext_interpolation_target, hCombinedOrientationData->interpolationCoefficient_fx, &hCombinedOrientationData->Quaternions[i] ); hCombinedOrientationData->interpolationCoefficient_fx = L_add( hCombinedOrientationData->interpolationIncrement_fx, hCombinedOrientationData->interpolationCoefficient_fx ); + move32(); } ELSE { /* Stop interpolation or check for new interpolation */ hCombinedOrientationData->isInterpolationOngoing = FALSE; + move16(); hCombinedOrientationData->interpolationCoefficient_fx = ONE_IN_Q30; move32(); hCombinedOrientationData->interpolationIncrement_fx = ONE_IN_Q30; move32(); - external_target_interpolation( hExtOrientationData, hCombinedOrientationData, i ); + external_target_interpolation_fx( hExtOrientationData, hCombinedOrientationData, i ); Word16 l_shift = 0; move16(); l_shift = s_min( s_min( Q_factor_L_32( hCombinedOrientationData->Quaternions[i].w_fx ), Q_factor_L_32( hCombinedOrientationData->Quaternions[i].x_fx ) ), s_min( Q_factor_L_32( hCombinedOrientationData->Quaternions[i].y_fx ), Q_factor_L_32( hCombinedOrientationData->Quaternions[i].z_fx ) ) ); hCombinedOrientationData->Quaternions[i].w_fx = L_shl( hCombinedOrientationData->Quaternions[i].w_fx, l_shift ); + move32(); hCombinedOrientationData->Quaternions[i].x_fx = L_shl( hCombinedOrientationData->Quaternions[i].x_fx, l_shift ); + move32(); hCombinedOrientationData->Quaternions[i].y_fx = L_shl( hCombinedOrientationData->Quaternions[i].y_fx, l_shift ); + move32(); hCombinedOrientationData->Quaternions[i].z_fx = L_shl( hCombinedOrientationData->Quaternions[i].z_fx, l_shift ); + move32(); hCombinedOrientationData->Quaternions[i].q_fact = add( hCombinedOrientationData->Quaternions[i].q_fact, l_shift ); + move16(); } } ELSE @@ -2351,40 +2522,42 @@ ivas_error combine_external_and_head_orientations( /* Interpolation disabled, use the current orientation values */ /* Use the most recent external orientation */ - IF( hExtOrientationData->enableExternalOrientation[i] == 1 ) + IF( EQ_16( hExtOrientationData->enableExternalOrientation[i], 1 ) ) { hCombinedOrientationData->Quaternions[i] = hExtOrientationData->Quaternions[i]; } /* Use the freezed external orientation */ - ELSE IF( hExtOrientationData->enableExternalOrientation[i] == 2 ) + ELSE IF( EQ_16( hExtOrientationData->enableExternalOrientation[i], 2 ) ) { hCombinedOrientationData->Quaternions[i] = hCombinedOrientationData->Quaternion_frozen_ext; } } } } - + test(); IF( hExtOrientationData != NULL && headRotQuaternions != NULL ) { /* Combine head and external orientations */ FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) { /* Check for frozen head rotation */ - IF( hExtOrientationData->enableHeadRotation[i] == 2 ) + IF( EQ_16( hExtOrientationData->enableHeadRotation[i], 2 ) ) { - IF( hCombinedOrientationData->isHeadRotationFrozen != 1 ) + IF( NE_16( hCombinedOrientationData->isHeadRotationFrozen, 1 ) ) { hCombinedOrientationData->Quaternion_frozen_head = headRotQuaternions[i]; hCombinedOrientationData->isHeadRotationFrozen = 1; + move16(); } } ELSE { hCombinedOrientationData->Quaternion_frozen_head = identity; hCombinedOrientationData->isHeadRotationFrozen = 0; + move16(); } /* Use the most recent head rotation */ - IF( hExtOrientationData->enableHeadRotation[i] == 1 ) + IF( EQ_16( hExtOrientationData->enableHeadRotation[i], 1 ) ) { IF( hExtOrientationData->enableExternalOrientation[i] > 0 ) { @@ -2396,7 +2569,7 @@ ivas_error combine_external_and_head_orientations( } } /* Use the freezed head rotation */ - ELSE IF( hExtOrientationData->enableHeadRotation[i] == 2 ) + ELSE IF( EQ_16( hExtOrientationData->enableHeadRotation[i], 2 ) ) { IF( hExtOrientationData->enableExternalOrientation[i] > 0 ) { @@ -2407,15 +2580,15 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->Quaternions[i] = hCombinedOrientationData->Quaternion_frozen_head; } } - /* Reset the combined orientations to identity */ - IF( hExtOrientationData->enableHeadRotation[i] == 0 && hExtOrientationData->enableExternalOrientation[i] == 0 ) + test(); + if ( hExtOrientationData->enableHeadRotation[i] == 0 && hExtOrientationData->enableExternalOrientation[i] == 0 ) { hCombinedOrientationData->Quaternions[i] = identity; } } } - + test(); IF( headRotQuaternions != NULL || hExtOrientationData != NULL ) { /* Calculate the combined rotation matrix */ @@ -2428,9 +2601,9 @@ ivas_error combine_external_and_head_orientations( /* Save the current orientations */ IF( hExtOrientationData != NULL ) { - IF( hExtOrientationData->enableExternalOrientation[hExtOrientationData->num_subframes - 1] > 0 ) + IF( hExtOrientationData->enableExternalOrientation[sub( hExtOrientationData->num_subframes, 1 )] > 0 ) { - hCombinedOrientationData->Quaternion_prev_extOrientation = hExtOrientationData->Quaternions[hExtOrientationData->num_subframes - 1]; + hCombinedOrientationData->Quaternion_prev_extOrientation = hExtOrientationData->Quaternions[sub( hExtOrientationData->num_subframes, 1 )]; } ELSE { @@ -2444,13 +2617,16 @@ ivas_error combine_external_and_head_orientations( hCombinedOrientationData->listenerPos[i] = listenerPos[i]; } } - /* Check if combined orientation is enabled */ + test(); + test(); + test(); IF( headRotQuaternions != NULL && hExtOrientationData == NULL ) { FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) { hCombinedOrientationData->enableCombinedOrientation[i] = 1; + move16(); } } ELSE IF( headRotQuaternions == NULL && hExtOrientationData != NULL ) @@ -2460,10 +2636,12 @@ ivas_error combine_external_and_head_orientations( IF( hExtOrientationData->enableExternalOrientation[i] > 0 ) { hCombinedOrientationData->enableCombinedOrientation[i] = 1; + move16(); } ELSE { hCombinedOrientationData->enableCombinedOrientation[i] = 0; + move16(); } } } @@ -2471,13 +2649,16 @@ ivas_error combine_external_and_head_orientations( { FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) { + test(); IF( hExtOrientationData->enableExternalOrientation[i] > 0 || ( hExtOrientationData->enableHeadRotation[i] > 0 ) ) { hCombinedOrientationData->enableCombinedOrientation[i] = 1; + move16(); } ELSE { hCombinedOrientationData->enableCombinedOrientation[i] = 0; + move16(); } } } @@ -2486,6 +2667,7 @@ ivas_error combine_external_and_head_orientations( FOR( i = 0; i < hCombinedOrientationData->num_subframes; i++ ) { hCombinedOrientationData->enableCombinedOrientation[i] = 0; + move16(); } } @@ -2504,6 +2686,7 @@ ivas_error combine_external_and_head_orientations( FOR( Word16 k = 0; k < 3; k++ ) { hCombinedOrientationData->Rmat_fx[i][j][k] = L_shl( hCombinedOrientationData->Rmat_fx[i][j][k], sub( 62, shl( hCombinedOrientationData->Quaternions[i].q_fact, 1 ) ) ); // Q30 + move32(); } } } @@ -2514,10 +2697,15 @@ ivas_error combine_external_and_head_orientations( { l_shift = s_min( s_min( Q_factor_L_32( hCombinedOrientationData->Quaternions[i].w_fx ), Q_factor_L_32( hCombinedOrientationData->Quaternions[i].x_fx ) ), s_min( Q_factor_L_32( hCombinedOrientationData->Quaternions[i].y_fx ), Q_factor_L_32( hCombinedOrientationData->Quaternions[i].z_fx ) ) ); hCombinedOrientationData->Quaternions[i].w_fx = L_shl( hCombinedOrientationData->Quaternions[i].w_fx, l_shift ); + move32(); hCombinedOrientationData->Quaternions[i].x_fx = L_shl( hCombinedOrientationData->Quaternions[i].x_fx, l_shift ); + move32(); hCombinedOrientationData->Quaternions[i].y_fx = L_shl( hCombinedOrientationData->Quaternions[i].y_fx, l_shift ); + move32(); hCombinedOrientationData->Quaternions[i].z_fx = L_shl( hCombinedOrientationData->Quaternions[i].z_fx, l_shift ); + move32(); hCombinedOrientationData->Quaternions[i].q_fact = add( hCombinedOrientationData->Quaternions[i].q_fact, l_shift ); + move16(); } return IVAS_ERR_OK; } @@ -2774,7 +2962,7 @@ ivas_error combine_external_and_head_orientations( * *------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -static void external_target_interpolation( +static void external_target_interpolation_fx( EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ const Word16 i /* i : subframe index */ @@ -2782,12 +2970,14 @@ static void external_target_interpolation( { /* Sanity check for number of frames */ hExtOrientationData->numFramesToTargetOrientation[i] = s_min( hExtOrientationData->numFramesToTargetOrientation[i], hCombinedOrientationData->maximumFramesToTargetOrientation ); + move16(); hExtOrientationData->numFramesToTargetOrientation[i] = s_max( hExtOrientationData->numFramesToTargetOrientation[i], 0 ); + move16(); /* Interpolate from the current orientation to the target orientation */ IF( hExtOrientationData->numFramesToTargetOrientation[i] > 0 ) { - IF( are_orientations_same_fx( &hCombinedOrientationData->Quaternions_ext_interpolation_target, &hExtOrientationData->Quaternions[i] ) == false ) + IF( EQ_16( are_orientations_same_fx( &hCombinedOrientationData->Quaternions_ext_interpolation_target, &hExtOrientationData->Quaternions[i] ), false ) ) { /* Target orientation is different from the previous target, update the values */ @@ -2795,11 +2985,11 @@ static void external_target_interpolation( hCombinedOrientationData->Quaternions_ext_interpolation_target = hExtOrientationData->Quaternions[i]; /* Use the most recent external orientation as the starting orientation */ - IF( hExtOrientationData->enableExternalOrientation[i] == 1 ) + IF( EQ_16( hExtOrientationData->enableExternalOrientation[i], 1 ) ) { - IF( GT_16( i, 0 ) ) + IF( i > 0 ) { - IF( hExtOrientationData->enableExternalOrientation[i - 1] == 0 ) + IF( hExtOrientationData->enableExternalOrientation[sub( i, 1 )] == 0 ) { IVAS_QUATERNION identity; identity.w_fx = ONE_IN_Q31; @@ -2812,13 +3002,13 @@ static void external_target_interpolation( move16(); hCombinedOrientationData->Quaternions_ext_interpolation_start = identity; } - ELSE IF( hExtOrientationData->enableExternalOrientation[i - 1] == 2 ) + ELSE IF( EQ_16( hExtOrientationData->enableExternalOrientation[sub( i, 1 )], 2 ) ) { hCombinedOrientationData->Quaternions_ext_interpolation_start = hCombinedOrientationData->Quaternion_frozen_ext; } ELSE { - hCombinedOrientationData->Quaternions_ext_interpolation_start = hExtOrientationData->Quaternions[i - 1]; + hCombinedOrientationData->Quaternions_ext_interpolation_start = hExtOrientationData->Quaternions[sub( i, 1 )]; } } ELSE @@ -2826,7 +3016,7 @@ static void external_target_interpolation( hCombinedOrientationData->Quaternions_ext_interpolation_start = hCombinedOrientationData->Quaternion_prev_extOrientation; } } - ELSE IF( hExtOrientationData->enableExternalOrientation[i] == 2 ) + ELSE IF( EQ_16( hExtOrientationData->enableExternalOrientation[i], 2 ) ) { hCombinedOrientationData->Quaternions_ext_interpolation_start = hCombinedOrientationData->Quaternion_frozen_ext; } @@ -2836,21 +3026,31 @@ static void external_target_interpolation( /* Calculate the interpolation increment and coefficient */ tmp = BASOP_Util_Divide3232_Scale_cadence( ONE_IN_Q30, L_shl( L_deposit_l( hExtOrientationData->numFramesToTargetOrientation[i] ), 2 ), &tmp_e ); hCombinedOrientationData->interpolationIncrement_fx = L_shl( tmp, sub( tmp_e, 31 ) ); /* Q30 */ + move32(); hCombinedOrientationData->interpolationCoefficient_fx = hCombinedOrientationData->interpolationIncrement_fx; move32(); } /* Interpolate */ hCombinedOrientationData->isInterpolationOngoing = TRUE; - hCombinedOrientationData->Quaternions_ext_interpolation_start.w_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.w_fx, hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact - Q29 ); - hCombinedOrientationData->Quaternions_ext_interpolation_start.x_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.x_fx, hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact - Q29 ); - hCombinedOrientationData->Quaternions_ext_interpolation_start.y_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.y_fx, hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact - Q29 ); - hCombinedOrientationData->Quaternions_ext_interpolation_start.z_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.z_fx, hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact - Q29 ); + move16(); + hCombinedOrientationData->Quaternions_ext_interpolation_start.w_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.w_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact, Q29 ) ); // Q29 + move32(); + hCombinedOrientationData->Quaternions_ext_interpolation_start.x_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.x_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact, Q29 ) ); // Q29 + move32(); + hCombinedOrientationData->Quaternions_ext_interpolation_start.y_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.y_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact, Q29 ) ); // Q29 + move32(); + hCombinedOrientationData->Quaternions_ext_interpolation_start.z_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_start.z_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact, Q29 ) ); // Q29 + move32(); - hCombinedOrientationData->Quaternions_ext_interpolation_target.w_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.w_fx, hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact - Q29 ); - hCombinedOrientationData->Quaternions_ext_interpolation_target.x_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.x_fx, hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact - Q29 ); - hCombinedOrientationData->Quaternions_ext_interpolation_target.y_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.y_fx, hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact - Q29 ); - hCombinedOrientationData->Quaternions_ext_interpolation_target.z_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.z_fx, hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact - Q29 ); + hCombinedOrientationData->Quaternions_ext_interpolation_target.w_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.w_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact, Q29 ) ); // Q29 + move32(); + hCombinedOrientationData->Quaternions_ext_interpolation_target.x_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.x_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact, Q29 ) ); // Q29 + move32(); + hCombinedOrientationData->Quaternions_ext_interpolation_target.y_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.y_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact, Q29 ) ); // Q29 + move32(); + hCombinedOrientationData->Quaternions_ext_interpolation_target.z_fx = L_shr( hCombinedOrientationData->Quaternions_ext_interpolation_target.z_fx, sub( hCombinedOrientationData->Quaternions_ext_interpolation_target.q_fact, Q29 ) ); // Q29 + move32(); hCombinedOrientationData->Quaternions_ext_interpolation_start.q_fact = Q29; move16(); @@ -2858,11 +3058,13 @@ static void external_target_interpolation( move16(); QuaternionSlerp_fx( hCombinedOrientationData->Quaternions_ext_interpolation_start, hCombinedOrientationData->Quaternions_ext_interpolation_target, hCombinedOrientationData->interpolationCoefficient_fx, &hCombinedOrientationData->Quaternions[i] ); hCombinedOrientationData->interpolationCoefficient_fx = L_add_sat( hCombinedOrientationData->interpolationCoefficient_fx, hCombinedOrientationData->interpolationIncrement_fx ); + move32(); } ELSE { /* Use the target orientation immediately */ hCombinedOrientationData->isInterpolationOngoing = FALSE; + move16(); hCombinedOrientationData->interpolationCoefficient_fx = ONE_IN_Q30; move32(); hCombinedOrientationData->interpolationIncrement_fx = ONE_IN_Q30; @@ -2958,6 +3160,7 @@ static bool are_orientations_same_fx( const IVAS_QUATERNION *orientation2 ) { bool orientationsAreSame = true; + move16(); Word32 error_margin_fx = 107374182; // 0.05f in Q31 move32(); Word16 error_margin_e = 0; @@ -2966,7 +3169,12 @@ static bool are_orientations_same_fx( move16(); move16(); move16(); + move16(); Word32 w_result = 0, x_result = 0, y_result = 0, z_result = 0; + move32(); + move32(); + move32(); + move32(); w_result = L_abs( BASOP_Util_Add_Mant32Exp( orientation1->w_fx, sub( 31, orientation1->q_fact ), L_negate( orientation2->w_fx ), sub( 31, orientation2->q_fact ), &w_e ) ); x_result = L_abs( BASOP_Util_Add_Mant32Exp( orientation1->x_fx, sub( 31, orientation1->q_fact ), L_negate( orientation2->x_fx ), sub( 31, orientation2->q_fact ), &x_e ) ); y_result = L_abs( BASOP_Util_Add_Mant32Exp( orientation1->y_fx, sub( 31, orientation1->q_fact ), L_negate( orientation2->y_fx ), sub( 31, orientation2->q_fact ), &y_e ) ); @@ -2975,12 +3183,17 @@ static bool are_orientations_same_fx( Word16 Flag_2 = BASOP_Util_Cmp_Mant32Exp( x_result, x_e, error_margin_fx, error_margin_e ); Word16 Flag_3 = BASOP_Util_Cmp_Mant32Exp( y_result, y_e, error_margin_fx, error_margin_e ); Word16 Flag_4 = BASOP_Util_Cmp_Mant32Exp( z_result, z_e, error_margin_fx, error_margin_e ); + + test(); + test(); + test(); IF( EQ_16( Flag_1, 1 ) || EQ_16( Flag_2, 1 ) || EQ_16( Flag_3, 1 ) || EQ_16( Flag_4, 1 ) ) { orientationsAreSame = false; + move16(); } return orientationsAreSame; @@ -3035,18 +3248,18 @@ static Word32 SHrot_p_fx( Word32 p = 0; move32(); - ri1 = SHrotmat[i + 1 + 1][1 + 1 + 1]; + ri1 = SHrotmat[add( add( i, 1 ), 1 )][add( add( 1, 1 ), 1 )]; move16(); - rim1 = SHrotmat[i + 1 + 1][-1 + 1 + 1]; + rim1 = SHrotmat[add( add( i, 1 ), 1 )][add( add( -1, 1 ), 1 )]; move16(); - ri0 = SHrotmat[i + 1 + 1][0 + 1 + 1]; + ri0 = SHrotmat[add( add( i, 1 ), 1 )][add( 1, 1 )]; move16(); IF( EQ_16( b, -l ) ) { - R_lm1_1 = R_lm1[a + l - 1][0]; + R_lm1_1 = R_lm1[sub( add( a, l ), 1 )][0]; move16(); - R_lm1_2 = R_lm1[a + l - 1][2 * l - 2]; + R_lm1_2 = R_lm1[sub( add( a, l ), 1 )][sub( shl( l, 1 ), 2 )]; move16(); p = L_mac0( L_mult0( ri1, R_lm1_1 ), rim1, R_lm1_2 ); } @@ -3054,13 +3267,13 @@ static Word32 SHrot_p_fx( { IF( EQ_16( b, l ) ) { - R_lm1_1 = R_lm1[a + l - 1][sub( shl( l, 1 ), 2 )]; - R_lm1_2 = R_lm1[a + l - 1][0]; + R_lm1_1 = R_lm1[sub( add( a, l ), 1 )][sub( shl( l, 1 ), 2 )]; + R_lm1_2 = R_lm1[sub( add( a, l ), 1 )][0]; p = L_msu0( L_mult0( ri1, R_lm1_1 ), rim1, R_lm1_2 ); } ELSE { - R_lm1_1 = R_lm1[a + l - 1][b + l - 1]; + R_lm1_1 = R_lm1[sub( add( a, l ), 1 )][sub( add( b, l ), 1 )]; move16(); p = L_mult0( ri0, R_lm1_1 ); } @@ -3200,8 +3413,9 @@ static Word32 SHrot_u_fx( const Word16 l, const Word16 m, const Word16 n, - Word16 SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM], - Word16 R_lm1[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM] ) + Word16 SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM], // Q14 + Word16 R_lm1[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM] // Q14 +) { return SHrot_p_fx( 0, l, m, n, SHrotmat, R_lm1 ); } @@ -3210,15 +3424,16 @@ static Word32 SHrot_v_fx( const Word16 l, const Word16 m, const Word16 n, - Word16 SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM], - Word16 R_lm1[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM] ) + Word16 SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM], // Q14 + Word16 R_lm1[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM] // Q14 +) { Word32 result; Word32 p0, p1; Word16 d; - IF( EQ_16( m, 0 ) ) + IF( m == 0 ) { p0 = SHrot_p_fx( 1, l, 1, n, SHrotmat, R_lm1 ); // Q28 p1 = SHrot_p_fx( -1, l, -1, n, SHrotmat, R_lm1 ); // Q28 @@ -3226,19 +3441,31 @@ static Word32 SHrot_v_fx( } ELSE { - IF( GT_16( m, 0 ) ) + IF( m > 0 ) { - d = ( m == 1 ) ? 1 : 0; - p0 = (Word32) SHrot_p_fx( 1, l, m - 1, n, SHrotmat, R_lm1 ); - p1 = (Word32) SHrot_p_fx( -1, l, -m + 1, n, SHrotmat, R_lm1 ); - result = Msub_32_16_r( Mpy_32_16_r( p0, square_root16_table[1 + d] ), p1, shl( sub( 1, d ), 14 ) ); // Q27 + d = 0; + move16(); + if ( EQ_16( m, 1 ) ) + { + d = 1; + move16(); + } + p0 = SHrot_p_fx( 1, l, sub( m, 1 ), n, SHrotmat, R_lm1 ); + p1 = SHrot_p_fx( -1, l, add( negate( m ), 1 ), n, SHrotmat, R_lm1 ); + result = Msub_32_16_r( Mpy_32_16_r( p0, square_root16_table[add( 1, d )] ), p1, shl( sub( 1, d ), 14 ) ); // Q27 } ELSE { - d = ( m == -1 ) ? 1 : 0; - p0 = (Word32) SHrot_p_fx( 1, l, m + 1, n, SHrotmat, R_lm1 ); - p1 = (Word32) SHrot_p_fx( -1, l, -m - 1, n, SHrotmat, R_lm1 ); - result = Madd_32_16_r( Mpy_32_16_r( p0, shl( sub( 1, d ), 14 ) ), p1, square_root16_table[1 + d] ); // Q27 + d = 0; + move16(); + if ( EQ_16( m, -1 ) ) + { + d = 1; + move16(); + } + p0 = SHrot_p_fx( 1, l, add( m, 1 ), n, SHrotmat, R_lm1 ); + p1 = SHrot_p_fx( -1, l, negate( add( m, 1 ) ), n, SHrotmat, R_lm1 ); + result = Madd_32_16_r( Mpy_32_16_r( p0, shl( sub( 1, d ), 14 ) ), p1, square_root16_table[add( 1, d )] ); // Q27 } } return result; // Q27 @@ -3248,28 +3475,29 @@ static Word32 SHrot_w_fx( const Word16 l, const Word16 m, const Word16 n, - Word16 SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM], - Word16 R_lm1[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM] ) + Word16 SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM], // Q14 + Word16 R_lm1[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM] // Q14 +) { Word32 result, p0, p1; - IF( EQ_16( m, 0 ) ) + IF( m == 0 ) { printf( "ERROR should not be called\n" ); return 0; } ELSE { - IF( GT_16( m, 0 ) ) + IF( m > 0 ) { - p0 = SHrot_p_fx( 1, l, m + 1, n, SHrotmat, R_lm1 ); - p1 = SHrot_p_fx( -1, l, -m - 1, n, SHrotmat, R_lm1 ); + p0 = SHrot_p_fx( 1, l, add( m, 1 ), n, SHrotmat, R_lm1 ); + p1 = SHrot_p_fx( -1, l, negate( add( m, 1 ) ), n, SHrotmat, R_lm1 ); result = L_add( p0, p1 ); } ELSE { - p0 = SHrot_p_fx( 1, l, m - 1, n, SHrotmat, R_lm1 ); - p1 = SHrot_p_fx( -1, l, -m + 1, n, SHrotmat, R_lm1 ); + p0 = SHrot_p_fx( 1, l, sub( m, 1 ), n, SHrotmat, R_lm1 ); + p1 = SHrot_p_fx( -1, l, sub( 1, m ), n, SHrotmat, R_lm1 ); result = L_sub( p0, p1 ); } } @@ -3287,9 +3515,9 @@ static Word32 SHrot_w_fx( *------------------------------------------------------------------------*/ void SHrotmatgen_fx( - Word16 SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM], /* o : rotation matrix in SHD */ - Word32 Rmat[3][3], /* i : real-space rotation matrix */ - const Word16 order /* i : ambisonics order */ + Word16 SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM], /* o : rotation matrix in SHD Q14 */ + Word32 Rmat[3][3], /* i : real-space rotation matrix Q30 */ + const Word16 order /* i : ambisonics order */ ) { Word16 d = 0; @@ -3307,6 +3535,7 @@ void SHrotmatgen_fx( move16(); move16(); move16(); + move16(); Word32 u32_fx = 0, v32_fx = 0, w32_fx = 0; move32(); @@ -3327,16 +3556,25 @@ void SHrotmatgen_fx( move16(); SHrotmat[1][1] = extract_h( Rmat[1][1] ); + move16(); SHrotmat[1][2] = extract_h( Rmat[1][2] ); + move16(); SHrotmat[1][3] = extract_h( Rmat[1][0] ); + move16(); SHrotmat[2][1] = extract_h( Rmat[2][1] ); + move16(); SHrotmat[2][2] = extract_h( Rmat[2][2] ); + move16(); SHrotmat[2][3] = extract_h( Rmat[2][0] ); + move16(); SHrotmat[3][1] = extract_h( Rmat[0][1] ); + move16(); SHrotmat[3][2] = extract_h( Rmat[0][2] ); + move16(); SHrotmat[3][3] = extract_h( Rmat[0][0] ); + move16(); FOR( i = 0; i < 2 * 1 + 1; i++ ) { @@ -3353,22 +3591,33 @@ void SHrotmatgen_fx( set_val_Word16( &R_l[0][0], 0, HEADROT_SHMAT_DIM2 ); FOR( m = -l; m <= l; m++ ) { - d = ( m == 0 ) ? 1 : 0; - absm = (Word16) abs( m ); + d = 0; + move16(); + if ( m == 0 ) + { + d = 1; + move16(); + } + absm = extract_l( abs( m ) ); sql2mm2 = square_root30_q12[sub( imult1616( l, l ), imult1616( m, m ) )]; + move16(); sqdabsm = square_root30_q12[imult1616( add( 1, d ), imult1616( sub( add( l, absm ), 1 ), add( l, absm ) ) )]; + move16(); sqlabsm = square_root30_q12[imult1616( sub( l, add( absm, 1 ) ), sub( l, absm ) )]; + move16(); FOR( n = -l; n <= l; n++ ) { IF( EQ_16( abs_s( n ), l ) ) { sqdenom = square_root30_q12[imult1616( shl( l, 1 ), sub( shl( l, 1 ), 1 ) )]; + move16(); } ELSE { sqdenom = square_root30_q12[sub( imult1616( l, l ), imult1616( n, n ) )]; + move16(); } @@ -3376,23 +3625,24 @@ void SHrotmatgen_fx( v = imult1616( div_l( L_shl( (Word32) sqdabsm, 14 ), sqdenom ), sub( 1, shl( d, 1 ) ) ); // Q14 w = imult1616( div_l( L_shl( (Word32) sqlabsm, 14 ), sqdenom ), negate( sub( 1, d ) ) ); // Q14 - IF( NE_16( u, 0 ) ) + IF( u != 0 ) { result = SHrot_u_fx( l, m, n, SHrotmat, R_lm1 ); // Q28 u32_fx = Mpy_32_16_r( result, u ); // Q27 } - IF( NE_16( v, 0 ) ) + IF( v != 0 ) { result = SHrot_v_fx( l, m, n, SHrotmat, R_lm1 ); v32_fx = Mpy_32_16_r( result, v ); // Q26 } - IF( NE_16( w, 0 ) ) + IF( w != 0 ) { result = SHrot_w_fx( l, m, n, SHrotmat, R_lm1 ); w32_fx = Mpy_32_16_r( result, w ); // Q27 } // Addind and converting to 16 bit integer of Q14 - R_l[m + l][n + l] = extract_h( L_add( L_add( L_shr( u32_fx, 1 ), v32_fx ), L_shr( w32_fx, 1 ) ) * L_shl( 1, 4 ) ); // Q14 + R_l[add( m, l )][add( n, l )] = extract_h( L_shl( L_add( L_add( L_shr( u32_fx, 1 ), v32_fx ), L_shr( w32_fx, 1 ) ), 4 ) ); // Q14 + move16(); } } @@ -3400,7 +3650,7 @@ void SHrotmatgen_fx( { FOR( j = 0; j < 2 * l + 1; j++ ) { - SHrotmat[band_idx + i][band_idx + j] = R_l[i][j]; + SHrotmat[add( band_idx, i )][add( band_idx, j )] = R_l[i][j]; move16(); } } @@ -3580,11 +3830,14 @@ void ivas_combined_orientation_update_index( ELSE { hCombinedOrientationData->cur_subframe_samples_rendered = add( hCombinedOrientationData->cur_subframe_samples_rendered, samples_rendered ); + move16(); div_result = BASOP_Util_Divide3216_Scale( hCombinedOrientationData->cur_subframe_samples_rendered, hCombinedOrientationData->subframe_size, &exp ); hCombinedOrientationData->subframe_idx = add( hCombinedOrientationData->subframe_idx, shl( div_result, exp + 1 ) ); + move16(); hCombinedOrientationData->cur_subframe_samples_rendered = hCombinedOrientationData->cur_subframe_samples_rendered % hCombinedOrientationData->subframe_size; move16(); - hCombinedOrientationData->subframe_idx = s_min( hCombinedOrientationData->subframe_idx, hCombinedOrientationData->num_subframes - 1 ); + hCombinedOrientationData->subframe_idx = s_min( hCombinedOrientationData->subframe_idx, sub( hCombinedOrientationData->num_subframes, 1 ) ); + move16(); } } @@ -3658,9 +3911,13 @@ void ivas_combined_orientation_update_start_index( ELSE { hCombinedOrientationData->cur_subframe_samples_rendered_start = add( hCombinedOrientationData->cur_subframe_samples_rendered_start, samples_rendered ); + move16(); hCombinedOrientationData->subframe_idx_start = add( hCombinedOrientationData->subframe_idx_start, mult( hCombinedOrientationData->cur_subframe_samples_rendered, div_s( 1, hCombinedOrientationData->subframe_size ) ) ); + move16(); hCombinedOrientationData->cur_subframe_samples_rendered_start = hCombinedOrientationData->cur_subframe_samples_rendered % hCombinedOrientationData->subframe_size; /* No operator to calculate modulo*/ + move16(); hCombinedOrientationData->subframe_idx_start = s_min( hCombinedOrientationData->subframe_idx, sub( hCombinedOrientationData->num_subframes, 1 ) ); + move16(); } } diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index 6a71233a3196170fc81211a8c0183a7e0a2d33eb..c2aeaef5d038b8b674d78bd6260ef2c2b4468244 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -50,8 +50,8 @@ #ifdef IVAS_FLOAT_FIXED void ivas_sba_prototype_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ + Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real Q(q_cldfb[][])*/ + Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag Q(q_cldfb[][])*/ Word16 q_cldfb[6][CLDFB_SLOTS_PER_SUBFRAME], const Word16 subframe /* i : Subframe to render */ ) @@ -75,14 +75,20 @@ void ivas_sba_prototype_renderer_fx( hSpar = st_ivas->hSpar; hDecoderConfig = st_ivas->hDecoderConfig; num_spar_bands = hSpar->hFbMixer->pFb->filterbank_num_bands; + move16(); num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands; + move16(); numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; + move16(); numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; + move16(); slot_idx_start = hSpar->slots_rendered; + move16(); - ///////scaling////////////// + /* Scaling up the real and imaginary buffers */ Word16 norm_q = 31; // to handle overflow + move16(); FOR( Word16 i = 0; i < 6; i++ ) { @@ -91,13 +97,14 @@ void ivas_sba_prototype_renderer_fx( norm_q = s_min( q_cldfb[i][j], norm_q ); } } - norm_q = 31 - norm_q - 2; // to handle overflow + norm_q = sub( sub( 31, norm_q ), 2 ); // to handle overflow Word16 q_inp[6][CLDFB_SLOTS_PER_SUBFRAME]; FOR( Word16 i = 0; i < 6; i++ ) { FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) { q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX ) ); + move16(); norm_q = s_min( q_inp[i][j], norm_q ); } } @@ -105,19 +112,23 @@ void ivas_sba_prototype_renderer_fx( { FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) { - // q_inp[i][j] = s_min(L_norm_arr(inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX), L_norm_arr(inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX)); - scale_sig32( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, norm_q - 2 ); - scale_sig32( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, norm_q - 2 ); - q_cldfb[i][j] = q_cldfb[i][j] + norm_q - 2; + scale_sig32( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); + scale_sig32( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); + q_cldfb[i][j] = sub( add( q_cldfb[i][j], norm_q ), 2 ); + move16(); } } - /////////////////// - IF( st_ivas->nchan_transport == 1 ) + + IF( EQ_16( st_ivas->nchan_transport, 1 ) ) { firstInCh = 0; inChEnd = 1; firstOutCh = 0; outChEnd = 1; + move16(); + move16(); + move16(); + move16(); } ELSE /* 2 TC */ { @@ -125,6 +136,10 @@ void ivas_sba_prototype_renderer_fx( inChEnd = 2; firstOutCh = 1; outChEnd = 2; + move16(); + move16(); + move16(); + move16(); } /* Apply mixing matrix */ @@ -132,8 +147,7 @@ void ivas_sba_prototype_renderer_fx( { /* determine SPAR parameters FOR this time slot */ md_idx = hSpar->render_to_md_map[ts + slot_idx_start]; - // delete below - // floatToFixed_arr( hSpar->hFbMixer->cldfb_cross_fade, hSpar->hFbMixer->cldfb_cross_fade_fx, Q15, CLDFB_NO_COL_MAX ); + move16(); ivas_spar_get_parameters_fx( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat_fx ); @@ -144,26 +158,26 @@ void ivas_sba_prototype_renderer_fx( Word32 cldfb_par_fx; ivas_fb_bin_to_band_data_t *bin2band = &hSpar->hFbMixer->pFb->fb_bin_to_band; - // delete below - // FOR( int idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) - //{ - // floatToFixed_arrL( bin2band->pp_cldfb_weights_per_spar_band[idx], bin2band->pp_cldfb_weights_per_spar_band_fx[idx], Q31, IVAS_MAX_NUM_FB_BANDS ); - //} FOR( out_ch = firstOutCh; out_ch < outChEnd; out_ch++ ) { out_re_fx[out_ch] = 0; + move32(); out_im_fx[out_ch] = 0; + move32(); FOR( in_ch = firstInCh; in_ch < inChEnd; in_ch++ ) { - IF( cldfb_band < CLDFB_PAR_WEIGHT_START_BAND ) /* tuning parameter, depends on how much SPAR Filters overlap FOR the CLDFB bands */ + IF( LT_16( cldfb_band, CLDFB_PAR_WEIGHT_START_BAND ) ) /* tuning parameter, depends on how much SPAR Filters overlap FOR the CLDFB bands */ { spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band]; + move16(); cldfb_par_fx = mixer_mat_fx[out_ch][in_ch][spar_band]; // q30 + move32(); } ELSE { cldfb_par_fx = 0; + move32(); FOR( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ ) { /* accumulate contributions from all SPAR bands */ @@ -173,6 +187,8 @@ void ivas_sba_prototype_renderer_fx( out_re_fx[out_ch] = L_add_sat( out_re_fx[out_ch], Mpy_32_32( inRe_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // q30+q_cldfb[i][j]; out_im_fx[out_ch] = L_add_sat( out_im_fx[out_ch], Mpy_32_32( inIm_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // q30+q_cldfb[i][j + move32(); + move32(); } } @@ -181,17 +197,26 @@ void ivas_sba_prototype_renderer_fx( { inRe_fx[out_ch][ts][cldfb_band] = L_shl_sat( out_re_fx[out_ch], 1 ); // q30+q_cldfb[i][j]; + q1 //to keep constat q to entire buffer inIm_fx[out_ch][ts][cldfb_band] = L_shl_sat( out_im_fx[out_ch], 1 ); + move32(); + move32(); } } /* Update mixing matrices */ - IF( ( ( slot_idx_start + ts + 1 ) == hSpar->num_slots ) || ( ( md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME ) != ( hSpar->render_to_md_map[ts + slot_idx_start + 1] / JBM_CLDFB_SLOTS_IN_SUBFRAME ) ) ) + test(); + IF( EQ_16( add( add( slot_idx_start, ts ), 1 ), hSpar->num_slots ) || NE_16( shr( md_idx, 2 ), shr( hSpar->render_to_md_map[add( add( ts, slot_idx_start ), 1 )], 2 ) ) ) // shr is used in place of division by JBM_CLDFB_SLOTS_IN_SUBFRAME, ( ( md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME ) != ( hSpar->render_to_md_map[ts + slot_idx_start + 1] / JBM_CLDFB_SLOTS_IN_SUBFRAME ) ) { /* we have crossed an unadapted parameter sf border, update previous mixing matrices */ - Word16 md_sf = md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME; - md_sf = ( num_md_sub_frames == MAX_PARAM_SPATIAL_SUBFRAMES ) ? md_sf : 0; - hSpar->i_subframe++; - hSpar->i_subframe = min( hSpar->i_subframe, MAX_PARAM_SPATIAL_SUBFRAMES ); + Word16 md_sf = shr( md_idx, 2 ); // md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME + if ( NE_16( num_md_sub_frames, MAX_PARAM_SPATIAL_SUBFRAMES ) ) + { + md_sf = 0; + move16(); + } + hSpar->i_subframe = add( hSpar->i_subframe, 1 ); + move16(); + hSpar->i_subframe = s_min( hSpar->i_subframe, MAX_PARAM_SPATIAL_SUBFRAMES ); + move16(); Copy32( hSpar->hMdDec->mixer_mat_prev_fx[1][0][0], hSpar->hMdDec->mixer_mat_prev_fx[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); Copy32( hSpar->hMdDec->mixer_mat_prev_fx[2][0][0], hSpar->hMdDec->mixer_mat_prev_fx[1][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); Copy32( hSpar->hMdDec->mixer_mat_prev_fx[3][0][0], hSpar->hMdDec->mixer_mat_prev_fx[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); @@ -203,7 +228,8 @@ void ivas_sba_prototype_renderer_fx( { FOR( b = 0; b < num_spar_bands; b++ ) { - hSpar->hMdDec->mixer_mat_prev_fx[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][b + md_sf * IVAS_MAX_NUM_BANDS]; + hSpar->hMdDec->mixer_mat_prev_fx[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][add( b, imult1616( md_sf, IVAS_MAX_NUM_BANDS ) )]; + move32(); } } } @@ -212,37 +238,46 @@ void ivas_sba_prototype_renderer_fx( /* Create prototypes */ - IF( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { FOR( ts = 0; ts < hSpar->subframe_nbslots[subframe]; ts++ ) { - IF( st_ivas->nchan_transport == 1 ) /* Dual mono */ + IF( EQ_16( st_ivas->nchan_transport, 1 ) ) /* Dual mono */ { Copy32( inRe_fx[0][ts], inRe_fx[1][ts], CLDFB_NO_CHANNELS_MAX ); Copy32( inIm_fx[0][ts], inIm_fx[1][ts], CLDFB_NO_CHANNELS_MAX ); } - ELSE IF( st_ivas->nchan_transport == 2 ) /* Opposing cardioids */ + ELSE IF( EQ_16( st_ivas->nchan_transport, 2 ) ) /* Opposing cardioids */ { Word32 temp_signal_fx[CLDFB_NO_CHANNELS_MAX]; FOR( int idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { temp_signal_fx[idx] = L_add( L_shr( inRe_fx[0][ts][idx], 1 ), L_shr( inRe_fx[1][ts][idx], 1 ) ); + move32(); inRe_fx[1][ts][idx] = L_sub( L_shr( inRe_fx[0][ts][idx], 1 ), L_shr( inRe_fx[1][ts][idx], 1 ) ); + move32(); inRe_fx[0][ts][idx] = temp_signal_fx[idx]; + move32(); } FOR( int idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { temp_signal_fx[idx] = L_add( L_shr( inIm_fx[0][ts][idx], 1 ), L_shr( inIm_fx[1][ts][idx], 1 ) ); + move32(); inIm_fx[1][ts][idx] = L_sub( L_shr( inIm_fx[0][ts][idx], 1 ), L_shr( inIm_fx[1][ts][idx], 1 ) ); + move32(); inIm_fx[0][ts][idx] = temp_signal_fx[idx]; + move32(); } } } } - hSpar->subframes_rendered++; - hSpar->slots_rendered += hSpar->subframe_nbslots[subframe]; + hSpar->subframes_rendered = add( hSpar->subframes_rendered, 1 ); + move16(); + hSpar->slots_rendered = add( hSpar->slots_rendered, hSpar->subframe_nbslots[subframe] ); + move16(); pop_wmops(); return; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 221c47a33b1b15b8f7b3b5a14853e030c429b9f8..ed870930133d12bf38665950b8490f546336fffa 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -13124,8 +13124,8 @@ void IVAS_REND_Close( closeHeadRotation( hIvasRend ); - ivas_external_orientation_close( &hIvasRend->hExternalOrientationData ); - ivas_combined_orientation_close( &hIvasRend->hCombinedOrientationData ); + ivas_external_orientation_close_fx( &hIvasRend->hExternalOrientationData ); + ivas_combined_orientation_close_fx( &hIvasRend->hCombinedOrientationData ); free( hIvasRend ); *phIvasRend = NULL;