diff --git a/apps/decoder.c b/apps/decoder.c index 54a4c1dfe970f29f9dc79f83cd87a2993e56b7fa..20cef71ab9280d5f8f8e1c9d5ae8ca2bdc14a886 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -490,7 +490,13 @@ int main( fprintf( stderr, "\nError in reading Custom loudspeaker file %s: %s\n\n", arg.customLsSetupFilename, CustomLoudspeakerLayout_getError( lsCustomError ) ); goto cleanup; } - +#ifdef IVAS_FLOAT_FIXED + for ( int i = 0; i < IVAS_MAX_OUTPUT_CHANNELS; i++ ) + { + hLsCustomData.azimuth_fx[i] = (Word32) ( hLsCustomData.azimuth[i] * ( 1u << 22 ) ); + hLsCustomData.elevation_fx[i] = (Word32) ( hLsCustomData.elevation[i] * ( 1u << 22 ) ); + } +#endif if ( ( error = IVAS_DEC_FeedCustomLsData( hIvasDec, hLsCustomData ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedCustomLsData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); diff --git a/apps/renderer.c b/apps/renderer.c index fcc1a04b785a036a6582e84b14a4a3fa845c30db..6b30c44402c812c290c41d34cb02f7c954f8394b 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -442,8 +442,8 @@ static IVAS_REND_ReadOnlyAudioBuffer getReadOnlySubBuffer( subBuffer.config = buffer.config; subBuffer.config.numChannels = numChannels; - subBuffer.data = buffer.data + subBuffer.config.numSamplesPerChannel * chBeginIdx; - subBuffer.data_fx = buffer.data_fx + subBuffer.config.numSamplesPerChannel * chBeginIdx; + move16(); + subBuffer.data_fx = buffer.data_fx + imult1616( subBuffer.config.numSamplesPerChannel, chBeginIdx ); return subBuffer; } @@ -912,6 +912,10 @@ int main( /* Set up output custom layout configuration */ if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { +#ifdef IVAS_FLOAT_FIXED + floatToFixed_arrL( args.outConfig.outSetupCustom.azimuth, args.outConfig.outSetupCustom.azimuth_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); + floatToFixed_arrL( args.outConfig.outSetupCustom.elevation, args.outConfig.outSetupCustom.elevation_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); +#endif if ( ( error = IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( hIvasRend, args.outConfig.outSetupCustom ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in IVAS_REND_ConfigureCustomOutputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); @@ -1022,6 +1026,10 @@ int main( if ( args.inConfig.multiChannelBuses[i].audioConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { +#ifdef IVAS_FLOAT_FIXED + floatToFixed_arrL( args.inConfig.inSetupCustom.azimuth, args.inConfig.inSetupCustom.azimuth_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); + floatToFixed_arrL( args.inConfig.inSetupCustom.elevation, args.inConfig.inSetupCustom.elevation_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); +#endif if ( ( error = IVAS_REND_ConfigureCustomInputLoudspeakerLayout( hIvasRend, mcIds[i], args.inConfig.inSetupCustom ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in IVAS_REND_ConfigureCustomInputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); @@ -1265,11 +1273,15 @@ int main( inBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; inBuffer.config.numChannels = (int16_t) totalNumInChannels; +#ifndef IVAS_FLOAT_FIXED inBuffer.data = inFloatBuffer; +#endif // IVAS_FLOAT_FIXED outBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; outBuffer.config.numChannels = (int16_t) numOutChannels; +#ifndef IVAS_FLOAT_FIXED outBuffer.data = outFloatBuffer; +#endif #ifdef IVAS_FLOAT_FIXED outBuffer.data_fx = outInt32Buffer; inBuffer.data_fx = inInt32Buffer; @@ -1523,11 +1535,19 @@ int main( } IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.masaBuses[i].inputChannelIndex, numChannels ); +#ifdef IVAS_FLOAT_FIXED + IF( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, masaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); + exit( -1 ); + } +#else if ( ( error = IVAS_REND_FeedInputAudio( hIvasRend, masaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); exit( -1 ); } +#endif if ( isCurrentFrameMultipleOf20ms ) { diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index e81ab78ec78cfad53252bc9594f31ddfb953b0b5..844cf88877e8d89228982e443d6c57f9e1e272e6 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1731,7 +1731,7 @@ ivas_error openCldfb_ivas_fx( // configureCldfb_ivas( hs, sampling_rate ); configureCldfb_ivas_fx( hs, sampling_rate ); - hs->memory_flt = NULL; + hs->memory32 = NULL; hs->FilterStates = NULL; hs->memory_length = 0; move16(); @@ -1770,62 +1770,6 @@ ivas_error openCldfb_ivas_fx( return IVAS_ERR_OK; } -ivas_error openCldfb_ivas( - HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ - CLDFB_TYPE type, /* i : analysis or synthesis */ - const int32_t sampling_rate, /* i : sampling rate */ - CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ -) -{ - HANDLE_CLDFB_FILTER_BANK hs; - int16_t buf_len; - - if ( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); - } - - hs->type = type; - hs->prototype = prototype; - - configureCldfb_ivas( hs, sampling_rate ); - - hs->memory_flt = NULL; - hs->memory_length = 0; - - if ( type == CLDFB_ANALYSIS ) - { - buf_len = hs->p_filter_length - hs->no_channels; - } - else - { - buf_len = hs->p_filter_length; - } - - if ( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); - } - set_f( hs->cldfb_state, 0.0f, buf_len ); -#ifdef IVAS_FLOAT_FIXED - if ( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); - } - hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer - move16(); - hs->cldfb_size = buf_len; /*for having original size at intermediatery conversion, will be removed on removing conversion*/ - move16(); - set32_fx( hs->cldfb_state_fx, 0, buf_len ); - hs->Q_cldfb_state = Q11; - move16(); -#endif // IVAS_FLOAT_FIXED - - - *h_cldfb = hs; - - return IVAS_ERR_OK; -} #else ivas_error openCldfb_ivas( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ @@ -2202,6 +2146,239 @@ void deleteCldfb_ivas_fx( * Initializes rom pointer *--------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static void cldfb_init_proto_and_twiddles( + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ +) +{ + /*find appropriate set of rotVecs*/ + SWITCH( hs->no_channels ) + { + case 10: + hs->rot_vec_ana_re_fx = rot_vec_ana_re_L10_fx; + hs->rot_vec_ana_im_fx = rot_vec_ana_im_L10_fx; + hs->rot_vec_syn_re_fx = rot_vec_syn_re_L10_fx; + hs->rot_vec_syn_im_fx = rot_vec_syn_im_L10_fx; + IF( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) + { + hs->ds = 10; + hs->da = 10; + hs->rot_vec_ana_delay_re_fx = NULL; + hs->rot_vec_ana_delay_im_fx = NULL; + hs->rot_vec_syn_delay_im_fx = NULL; + hs->rot_vec_syn_delay_re_fx = NULL; + hs->p_filter_sf = (Word16) 17036; + hs->p_filter = CLDFB80_10_fx; + hs->scale = CLDFB80_10_SCALE_FX_Q8; + } + ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) + { + hs->ds = 40; + hs->da = -20; + hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->p_filter_sf = (Word16) 15388; + hs->p_filter = LDQMF_10_fx; + hs->scale = LDQMF_10_SCALE_FX_Q8; + } + BREAK; + + case 16: + hs->rot_vec_ana_re_fx = rot_vec_ana_re_L16_fx; + hs->rot_vec_ana_im_fx = rot_vec_ana_im_L16_fx; + hs->rot_vec_syn_re_fx = rot_vec_syn_re_L16_fx; + hs->rot_vec_syn_im_fx = rot_vec_syn_im_L16_fx; + IF( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) + { + hs->ds = 20; + hs->da = 20; + hs->rot_vec_ana_delay_re_fx = NULL; + hs->rot_vec_ana_delay_im_fx = NULL; + hs->rot_vec_syn_delay_im_fx = NULL; + hs->rot_vec_syn_delay_re_fx = NULL; + hs->p_filter_sf = (Word16) 17051; + hs->p_filter = CLDFB80_16_fx; + hs->scale = CLDFB80_16_SCALE_FX_Q8; + } + ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) + { + hs->ds = 80; + hs->da = -40; + hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->p_filter_sf = (Word16) 15388; + hs->p_filter = LDQMF_16_fx; + hs->scale = LDQMF_16_SCALE_FX_Q8; + } + BREAK; + + case 20: + hs->rot_vec_ana_re_fx = rot_vec_ana_re_L20_fx; + hs->rot_vec_ana_im_fx = rot_vec_ana_im_L20_fx; + hs->rot_vec_syn_re_fx = rot_vec_syn_re_L20_fx; + hs->rot_vec_syn_im_fx = rot_vec_syn_im_L20_fx; + IF( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) + { + hs->ds = 20; + hs->da = 20; + hs->rot_vec_ana_delay_re_fx = NULL; + hs->rot_vec_ana_delay_im_fx = NULL; + hs->rot_vec_syn_delay_im_fx = NULL; + hs->rot_vec_syn_delay_re_fx = NULL; + hs->p_filter_sf = (Word16) 17050; + hs->p_filter = CLDFB80_20_fx; + hs->scale = CLDFB80_20_SCALE_FX_Q8; + } + ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) + { + hs->ds = 80; + hs->da = -40; + hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->p_filter_sf = (Word16) 15390; + hs->p_filter = LDQMF_20_fx; + hs->scale = LDQMF_20_SCALE_FX_Q8; + } + BREAK; + + case 30: + hs->rot_vec_ana_re_fx = rot_vec_ana_re_L30_fx; + hs->rot_vec_ana_im_fx = rot_vec_ana_im_L30_fx; + hs->rot_vec_syn_re_fx = rot_vec_syn_re_L30_fx; + hs->rot_vec_syn_im_fx = rot_vec_syn_im_L30_fx; + IF( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) + { + hs->ds = 30; + hs->da = 30; + hs->rot_vec_ana_delay_re_fx = NULL; + hs->rot_vec_ana_delay_im_fx = NULL; + hs->rot_vec_syn_delay_im_fx = NULL; + hs->rot_vec_syn_delay_re_fx = NULL; + hs->p_filter_sf = (Word16) 17051; + hs->p_filter = CLDFB80_30_fx; + hs->scale = CLDFB80_30_SCALE_FX_Q8; + } + ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) + { + hs->ds = 120; + hs->da = -60; + hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->p_filter_sf = (Word16) 15388; + hs->p_filter = LDQMF_30_fx; + hs->scale = LDQMF_30_SCALE_FX_Q8; + } + BREAK; + + case 32: + hs->rot_vec_ana_re_fx = rot_vec_ana_re_L32_fx; + hs->rot_vec_ana_im_fx = rot_vec_ana_im_L32_fx; + hs->rot_vec_syn_re_fx = rot_vec_syn_re_L32_fx; + hs->rot_vec_syn_im_fx = rot_vec_syn_im_L32_fx; + IF( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) + { + hs->ds = 32; + hs->da = 32; + hs->rot_vec_ana_delay_re_fx = NULL; + hs->rot_vec_ana_delay_im_fx = NULL; + hs->rot_vec_syn_delay_im_fx = NULL; + hs->rot_vec_syn_delay_re_fx = NULL; + hs->p_filter_sf = (Word16) 17050; + hs->p_filter = CLDFB80_32_fx; + hs->scale = CLDFB80_32_SCALE_FX_Q8; + } + ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) + { + hs->ds = 160; + hs->da = -80; + hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->p_filter_sf = (Word16) 15392; + hs->p_filter = LDQMF_32_fx; + hs->scale = LDQMF_32_SCALE_FX_Q8; + } + BREAK; + + case 40: + hs->rot_vec_ana_re_fx = rot_vec_ana_re_L40_fx; + hs->rot_vec_ana_im_fx = rot_vec_ana_im_L40_fx; + hs->rot_vec_syn_re_fx = rot_vec_syn_re_L40_fx; + hs->rot_vec_syn_im_fx = rot_vec_syn_im_L40_fx; + IF( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) + { + hs->ds = 40; + hs->da = 40; + hs->rot_vec_ana_delay_re_fx = NULL; + hs->rot_vec_ana_delay_im_fx = NULL; + hs->rot_vec_syn_delay_im_fx = NULL; + hs->rot_vec_syn_delay_re_fx = NULL; + hs->p_filter_sf = (Word16) 17051; + hs->p_filter = CLDFB80_40_fx; + hs->scale = CLDFB80_40_SCALE_FX_Q8; + } + ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) + { + hs->ds = 160; + hs->da = -80; + hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->p_filter_sf = (Word16) 15391; + hs->p_filter = LDQMF_40_fx; + hs->scale = LDQMF_40_SCALE_FX_Q8; + } + BREAK; + + case 60: + hs->rot_vec_ana_re_fx = rot_vec_ana_re_L60_fx; + hs->rot_vec_ana_im_fx = rot_vec_ana_im_L60_fx; + hs->rot_vec_syn_re_fx = rot_vec_syn_re_L60_fx; + hs->rot_vec_syn_im_fx = rot_vec_syn_im_L60_fx; + IF( hs->prototype == CLDFB_PROTOTYPE_1_25MS ) + { + hs->ds = 60; + hs->da = 60; + hs->rot_vec_ana_delay_re_fx = NULL; + hs->rot_vec_ana_delay_im_fx = NULL; + hs->rot_vec_syn_delay_re_fx = NULL; + hs->rot_vec_syn_delay_im_fx = NULL; + hs->p_filter_sf = (Word16) 17051; + hs->p_filter = CLDFB80_60_fx; + hs->scale = CLDFB80_60_SCALE_FX_Q8; + } + ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) + { + hs->ds = 240; + hs->da = -120; + hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; + hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; + hs->p_filter_sf = (Word16) 15391; + hs->p_filter = LDQMF_60_fx; + hs->scale = LDQMF_60_SCALE_FX_Q8; + } + BREAK; + } + move16(); + move16(); + move16(); + move16(); + + return; +} +#else static void cldfb_init_proto_and_twiddles( HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ ) @@ -2583,6 +2760,7 @@ static void cldfb_init_proto_and_twiddles( return; } +#endif // IVAS_FLOAT_FIXED static void cldfb_init_proto_and_twiddles_enc( HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ @@ -3006,7 +3184,7 @@ ivas_error cldfb_save_memory_ivas_fx( { UWord16 offset = sub( hs->p_filter_length, hs->no_channels ); - IF( hs->memory_flt != NULL || ( hs->memory_length != 0 ) ) + IF( hs->memory32 != NULL || ( hs->memory_length != 0 ) ) { /* memory already stored; Free memory first */ return IVAS_ERR_OK; @@ -3022,12 +3200,6 @@ ivas_error cldfb_save_memory_ivas_fx( hs->memory_length = hs->p_filter_length; move16(); } -#if 1 /*Floating point memory allocation: To be removed later*/ - IF( ( hs->memory_flt = (float *) malloc( hs->memory_length * sizeof( float ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" ); - } -#endif IF( ( hs->memory32 = (Word32 *) malloc( hs->memory_length * sizeof( Word32 ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" ); @@ -3084,7 +3256,7 @@ void cldfb_restore_memory_ivas_fx( UWord16 offset = sub( hs->p_filter_length, hs->no_channels ); UWord16 size; test(); - IF( hs->memory_flt == NULL || EQ_16( hs->memory_length, 0 ) ) + IF( hs->memory32 == NULL || EQ_16( hs->memory_length, 0 ) ) { /* memory not allocated */ return; @@ -3113,10 +3285,6 @@ void cldfb_restore_memory_ivas_fx( move16(); hs->memory_length = 0; move16(); -#if 1 // Remove later - free( hs->memory_flt ); - hs->memory_flt = NULL; -#endif free( hs->memory32 ); hs->memory32 = NULL; diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index ed0cfa5c2ccb155b2abe09c438eddd4e429b86a1..3e8a963cd9823787b22c1fdbc20b13d197c0a3e4 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -110,9 +110,9 @@ typedef enum _IVAS_ENC_FEC_INDICATOR typedef struct _IVAS_ENC_CHANNEL_AWARE_CONFIG { - Word16 channelAwareModeEnabled; + int16_t channelAwareModeEnabled; IVAS_ENC_FEC_INDICATOR fec_indicator; - Word16 fec_offset; + int16_t fec_offset; } IVAS_ENC_CHANNEL_AWARE_CONFIG; @@ -194,6 +194,10 @@ typedef struct _IVAS_LS_CUSTOM_LAYOUT int16_t num_spk; float azimuth[IVAS_MAX_OUTPUT_CHANNELS]; float elevation[IVAS_MAX_OUTPUT_CHANNELS]; +#ifdef IVAS_FLOAT_FIXED + Word32 azimuth_fx[IVAS_MAX_OUTPUT_CHANNELS]; + Word32 elevation_fx[IVAS_MAX_OUTPUT_CHANNELS]; +#endif int16_t num_lfe; int16_t lfe_idx[IVAS_MAX_OUTPUT_CHANNELS]; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 80cdef0de6b716f2b10f53bc9d421ef990fad39c..cb4ea8b34e1fef83f70f5901b5f9c80955e2c0f2 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1475,12 +1475,14 @@ void ivas_param_ism_dec_digest_tc( ); #endif // IVAS_FLOAT_FIXED +#ifndef IVAS_FLOAT_FIXED void ivas_ism_param_dec_tc_gain_ajust( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamples, /* i : number of samples to be compensate */ const uint16_t nFadeLength, /* i : length of the crossfade in samples */ float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); +#endif void ivas_param_ism_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ @@ -5398,6 +5400,7 @@ void ivas_dirac_dec_output_synthesis_cov_close( DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */ ); +#ifndef IVAS_FLOAT_FIXED void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( float *RealBuffer, /* i : input channel filter bank samples (real part) */ float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ @@ -5406,6 +5409,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( PARAM_MC_DEC_HANDLE hParamMC, /* i : handle to Parametric MC state */ const int16_t nchan_in /* i : number of input channels */ ); +#endif void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( float *Cldfb_RealBuffer_in, /* i : input channel filter bank samples (real part) */ diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 0b7519f441694e1336280dc1b428773d2a1ba7e8..a4337b805a52fa768c08d01069a0e2ceb5ae4f67 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -867,12 +867,13 @@ typedef struct ivas_fb_mixer_state_structure int16_t prior_input_length; int16_t windowed_fr_offset; - float cldfb_cross_fade[CLDFB_NO_COL_MAX]; #ifdef IVAS_FLOAT_FIXED const Word16 *pFilterbank_cross_fade_fx; Word16 cldfb_cross_fade_fx[CLDFB_NO_COL_MAX]; Word16 cldfb_cross_fade_q; const Word16 *pAna_window_fx; +#else + float cldfb_cross_fade[CLDFB_NO_COL_MAX]; #endif // IVAS_FLOAT_FIXED int16_t cldfb_cross_fade_start; int16_t cldfb_cross_fade_end; diff --git a/lib_dec/LD_music_post_filter.c b/lib_dec/LD_music_post_filter.c index cffd1a42ef6fb427af4589c3b51f1edd827a6ed6..e3817e69f4bb687b3bce4daca2a813c84d789f8d 100644 --- a/lib_dec/LD_music_post_filter.c +++ b/lib_dec/LD_music_post_filter.c @@ -638,6 +638,7 @@ void find_enr_dct( * Performs the steps needed to do the music post processing *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void Prep_music_postP( float exc_buffer_in[], /* i/o: excitation buffer */ float dct_buffer_out[], /* o : DCT output buffer */ @@ -700,6 +701,7 @@ void Prep_music_postP( return; } +#endif /*------------------------------------------------------------------------* * Post_music_postP() @@ -708,6 +710,7 @@ void Prep_music_postP( * to retreive the aligned excitation and redo the synthesis *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void Post_music_postP( float dct_buffer_in[], /* i/o: excitation buffer */ float exc_buffer_out[], /* o : DCT output buffer */ @@ -728,6 +731,7 @@ void Post_music_postP( return; } +#endif /*-------------------------------------------------------------------* @@ -735,82 +739,7 @@ void Post_music_postP( * * Initialize LD music postfilter state structure *-------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED - -void music_postfilt_init_flt( - MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ -) -{ - int16_t i; - #ifndef IVAS_FLOAT_FIXED - set_f( hMusicPF->dct_post_old_exc, 0, DCT_L_POST - OFFSET2 ); -#endif -#ifdef IVAS_FLOAT_FIXED - set16_fx( hMusicPF->dct_post_old_exc_fx, 0, DCT_L_POST - OFFSET2 ); -#endif - -#ifndef IVAS_FLOAT_FIXED - hMusicPF->LDm_enh_min_ns_gain = (float) pow( 10.0f, -12 / 20.0f ); -#endif -#ifdef IVAS_FLOAT_FIXED - hMusicPF->LDm_enh_min_ns_gain_fx = (Word16) ( 0x2027 ); -#endif - hMusicPF->LDm_last_music_flag = 0; -#ifndef IVAS_FLOAT_FIXED - set_f( hMusicPF->LDm_lt_diff_etot, 0, MAX_LT ); - hMusicPF->LDm_thres[0] = TH_0_MIN; - hMusicPF->LDm_thres[1] = TH_1_MIN; - hMusicPF->LDm_thres[2] = TH_2_MIN; - hMusicPF->LDm_thres[3] = TH_3_MIN; -#endif -#ifdef IVAS_FLOAT_FIXED - set16_fx( hMusicPF->LDm_lt_diff_etot_fx, 0, MAX_LT ); - hMusicPF->LDm_thres_fx[0] = TH_0_MIN_FX << 1; - hMusicPF->LDm_thres_fx[1] = TH_1_MIN_FX << 1; - hMusicPF->LDm_thres_fx[2] = TH_2_MIN_FX << 1; - hMusicPF->LDm_thres_fx[3] = TH_3_MIN_FX << 1; - -#endif - hMusicPF->LDm_nb_thr_1 = 0; - hMusicPF->LDm_nb_thr_3 = 0; -#ifndef IVAS_FLOAT_FIXED - hMusicPF->LDm_mem_etot = 0.0f; -#endif -#ifdef IVAS_FLOAT_FIXED - hMusicPF->LDm_mem_etot_fx = 0; -#endif - - for ( i = 0; i < VOIC_BINS_HR; i++ ) - { -#ifndef IVAS_FLOAT_FIXED - hMusicPF->LDm_enh_lp_gbin[i] = 1.0f; - hMusicPF->LDm_enh_lf_EO[i] = 0.01f; -#endif -#ifdef IVAS_FLOAT_FIXED - hMusicPF->LDm_enh_lp_gbin_fx[i] = ONE_IN_Q14; - hMusicPF->LDm_enh_lf_EO_fx[i] = 10; -#endif - } - - for ( i = 0; i < MBANDS_GN_LD; i++ ) - { -#ifndef IVAS_FLOAT_FIXED - hMusicPF->LDm_bckr_noise[i] = E_MIN; -#endif -#ifdef IVAS_FLOAT_FIXED - hMusicPF->LDm_bckr_noise_fx[i] = E_MIN_Q15; -#endif - } - - // set_f( hMusicPF->filt_lfE, 1.0f, DCT_L_POST ); - hMusicPF->last_nonfull_music = 0; -#ifdef IVAS_FLOAT_FIXED - hMusicPF->Old_ener_Q = 0; -#endif - return; -} -#else void music_postfilt_init_flt( MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ ) diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 6062659416cd1230efab6461e4506f9da3c4022d..4d91463d85707cacd558120c8a88f74fdc8f384b 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -371,14 +371,14 @@ ivas_error acelp_core_switch_dec_bfi_fx( Word16 FEC_pitch; /* FEC pitch */ Word16 old_bwe_exc[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ Word16 *bwe_exc; /* Excitation for SWB TBE */ - Word16 tmp_float[NBPSF_PIT_MAX]; - Word16 tmp_float2[M]; - Word16 tmp_float3; - Word16 tmp_float4[L_TRACK_HIST]; - Word16 tmp_float5[L_TRACK_HIST]; - Word16 tmp_float6[L_TRACK_HIST]; - Word16 tmp_float7; - Word32 tmp_float32; + Word16 tmp1[NBPSF_PIT_MAX]; + Word16 tmp2[M]; + Word16 tmp3; + Word16 tmp4[L_TRACK_HIST]; + Word16 tmp5[L_TRACK_HIST]; + Word16 tmp6[L_TRACK_HIST]; + Word16 tmp7; + Word32 tmp8; Word16 voice_factors[NB_SUBFR16k]; Word16 pitch_buf[NB_SUBFR16k]; Word16 Q_exc; @@ -449,8 +449,8 @@ ivas_error acelp_core_switch_dec_bfi_fx( move16(); } - Copy( st_fx->mem_AR_fx, tmp_float, M ); - Copy( st_fx->mem_MA_fx, tmp_float2, M ); + Copy( st_fx->mem_AR_fx, tmp1, M ); + Copy( st_fx->mem_MA_fx, tmp2, M ); /* LSF estimation and A(z) calculation */ lsf_dec_bfi( MODE1, lsf_new, st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, NULL, st_fx->mem_MA_fx, st_fx->mem_AR_fx, @@ -459,8 +459,8 @@ ivas_error acelp_core_switch_dec_bfi_fx( FEC_lsf2lsp_interp( st_fx, st_fx->L_frame, Aq, lsf_new, lsp_new ); - Copy( tmp_float, st_fx->mem_AR_fx, M ); - Copy( tmp_float2, st_fx->mem_MA_fx, M ); + Copy( tmp1, st_fx->mem_AR_fx, M ); + Copy( tmp2, st_fx->mem_MA_fx, M ); /*----------------------------------------------------------------* * Excitation decoding @@ -482,17 +482,17 @@ ivas_error acelp_core_switch_dec_bfi_fx( } ELSE { - tmp_float[0] = st_fx->bfi_pitch_fx; + tmp1[0] = st_fx->bfi_pitch_fx; move16(); - tmp_float[1] = st_fx->bfi_pitch_frame; + tmp1[1] = st_fx->bfi_pitch_frame; move16(); - tmp_float[2] = st_fx->lp_gainp_fx; + tmp1[2] = st_fx->lp_gainp_fx; move16(); - tmp_float[3] = st_fx->lp_gainc_fx; + tmp1[3] = st_fx->lp_gainc_fx; move16(); - tmp_float[4] = st_fx->upd_cnt; + tmp1[4] = st_fx->upd_cnt; move16(); - tmp_float[5] = st_fx->seed; + tmp1[5] = st_fx->seed; move16(); /* calculation of excitation signal */ @@ -500,17 +500,17 @@ ivas_error acelp_core_switch_dec_bfi_fx( Rescale_exc( NULL, exc, bwe_exc, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, L_FRAME32k, (Word32) 0, &Q_exc, st_fx->Q_subfr, exc2, st_fx->L_frame, st_fx->last_coder_type ); - st_fx->seed = tmp_float[5]; + st_fx->seed = tmp1[5]; move16(); - st_fx->bfi_pitch_fx = tmp_float[0]; + st_fx->bfi_pitch_fx = tmp1[0]; move16(); - st_fx->bfi_pitch_frame = tmp_float[1]; + st_fx->bfi_pitch_frame = tmp1[1]; move16(); - st_fx->lp_gainp_fx = tmp_float[2]; + st_fx->lp_gainp_fx = tmp1[2]; move16(); - st_fx->lp_gainc_fx = tmp_float[3]; + st_fx->lp_gainc_fx = tmp1[3]; move16(); - st_fx->upd_cnt = tmp_float[4]; + st_fx->upd_cnt = tmp1[4]; move16(); } @@ -520,27 +520,27 @@ ivas_error acelp_core_switch_dec_bfi_fx( Rescale_mem( Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, 0, NULL ); - Copy( st_fx->mem_syn2_fx, tmp_float, M ); - syn_12k8_fx( st_fx->L_frame, Aq, exc2, syn, tmp_float, 1, Q_exc, st_fx->Q_syn ); + Copy( st_fx->mem_syn2_fx, tmp1, M ); + syn_12k8_fx( st_fx->L_frame, Aq, exc2, syn, tmp1, 1, Q_exc, st_fx->Q_syn ); - tmp_float32 = st_fx->enr_old_fx; + tmp8 = st_fx->enr_old_fx; move32(); - frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn, shr( add( FEC_pitch, 32 ), 6 ), &tmp_float32, st_fx->L_frame, st_fx->Q_syn, 3, 0 ); + frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn, shr( add( FEC_pitch, 32 ), 6 ), &tmp8, st_fx->L_frame, st_fx->Q_syn, 3, 0 ); /*------------------------------------------------------------------* * Perform fixed deemphasis through 1/(1 - g*z^-1) *-----------------------------------------------------------------*/ - tmp_float[0] = st_fx->mem_deemph_fx; + tmp1[0] = st_fx->mem_deemph_fx; move16(); /*if in acelp_core_dec_fx deemph_fx is used*/ - /*tmp_float = shr(st_fx->mem_deemph_fx, sub(st_fx->Q_syn,1)); if in acelp_core_dec_fx Deemph2 is used*/ + /*tmp1 = shr(st_fx->mem_deemph_fx, sub(st_fx->Q_syn,1)); if in acelp_core_dec_fx Deemph2 is used*/ IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { - deemph_fx( syn, PREEMPH_FAC, L_FRAME, &tmp_float[0] ); /*Q0*/ + deemph_fx( syn, PREEMPH_FAC, L_FRAME, &tmp1[0] ); /*Q0*/ } ELSE { - deemph_fx( syn, PREEMPH_FAC_16k, L_FRAME16k, &tmp_float[0] ); /*Q0*/ + deemph_fx( syn, PREEMPH_FAC_16k, L_FRAME16k, &tmp1[0] ); /*Q0*/ } /*----------------------------------------------------------------* @@ -549,24 +549,24 @@ ivas_error acelp_core_switch_dec_bfi_fx( st_fx->bpf_off = 1; move16(); - Copy( hBPF->pst_old_syn_fx, tmp_float, NBPSF_PIT_MAX ); + Copy( hBPF->pst_old_syn_fx, tmp1, NBPSF_PIT_MAX ); - tmp_float3 = st_fx->stab_fac_smooth_fx; + tmp3 = st_fx->stab_fac_smooth_fx; move16(); - Copy( hBPF->mem_mean_pit_fx, tmp_float4, L_TRACK_HIST ); - Copy( hBPF->Track_on_hist, tmp_float5, L_TRACK_HIST ); - Copy( hBPF->vibrato_hist, tmp_float6, L_TRACK_HIST ); - tmp_float7 = hBPF->psf_att_fx; + Copy( hBPF->mem_mean_pit_fx, tmp4, L_TRACK_HIST ); + Copy( hBPF->Track_on_hist, tmp5, L_TRACK_HIST ); + Copy( hBPF->vibrato_hist, tmp6, L_TRACK_HIST ); + tmp7 = hBPF->psf_att_fx; move16(); bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn, st_fx->L_frame, pitch_buf, - st_fx->bpf_off, st_fx->stab_fac_fx, &tmp_float3, coder_type, st_fx->Q_syn, old_exc /* tmp buffer*/ ); + st_fx->bpf_off, st_fx->stab_fac_fx, &tmp3, coder_type, st_fx->Q_syn, old_exc /* tmp buffer*/ ); - Copy( tmp_float, hBPF->pst_old_syn_fx, NBPSF_PIT_MAX ); - Copy( tmp_float4, hBPF->mem_mean_pit_fx, L_TRACK_HIST ); - Copy( tmp_float5, hBPF->Track_on_hist, L_TRACK_HIST ); - Copy( tmp_float6, hBPF->vibrato_hist, L_TRACK_HIST ); - hBPF->psf_att_fx = tmp_float7; + Copy( tmp1, hBPF->pst_old_syn_fx, NBPSF_PIT_MAX ); + Copy( tmp4, hBPF->mem_mean_pit_fx, L_TRACK_HIST ); + Copy( tmp5, hBPF->Track_on_hist, L_TRACK_HIST ); + Copy( tmp6, hBPF->vibrato_hist, L_TRACK_HIST ); + hBPF->psf_att_fx = tmp7; move16(); /*----------------------------------------------------------------* * Resamping to the output sampling frequency @@ -617,14 +617,14 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( Word16 FEC_pitch; /* FEC pitch */ Word16 old_bwe_exc[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ Word16 *bwe_exc; /* Excitation for SWB TBE */ - Word16 tmp_float[NBPSF_PIT_MAX]; - Word16 tmp_float2[M]; - Word16 tmp_float3; - Word16 tmp_float4[L_TRACK_HIST]; - Word16 tmp_float5[L_TRACK_HIST]; - Word16 tmp_float6[L_TRACK_HIST]; - Word16 tmp_float7; - Word32 tmp_float32; + Word16 tmp1[NBPSF_PIT_MAX]; + Word16 tmp2[M]; + Word16 tmp3; + Word16 tmp4[L_TRACK_HIST]; + Word16 tmp5[L_TRACK_HIST]; + Word16 tmp6[L_TRACK_HIST]; + Word16 tmp7; + Word32 tmp8; Word16 voice_factors[NB_SUBFR16k]; Word16 pitch_buf[NB_SUBFR16k]; Word16 Q_exc, Qtmp; @@ -696,8 +696,8 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( move16(); } - Copy( st_fx->mem_AR_fx, tmp_float, M ); - Copy( st_fx->mem_MA_fx, tmp_float2, M ); + Copy( st_fx->mem_AR_fx, tmp1, M ); + Copy( st_fx->mem_MA_fx, tmp2, M ); /* LSF estimation and A(z) calculation */ lsf_dec_bfi( MODE1, lsf_new, st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, NULL, st_fx->mem_MA_fx, st_fx->mem_AR_fx, @@ -706,8 +706,8 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( FEC_lsf2lsp_interp( st_fx, st_fx->L_frame, Aq, lsf_new, lsp_new ); - Copy( tmp_float, st_fx->mem_AR_fx, M ); - Copy( tmp_float2, st_fx->mem_MA_fx, M ); + Copy( tmp1, st_fx->mem_AR_fx, M ); + Copy( tmp2, st_fx->mem_MA_fx, M ); /*----------------------------------------------------------------* * Excitation decoding @@ -729,17 +729,17 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( } ELSE { - tmp_float[0] = st_fx->bfi_pitch_fx; + tmp1[0] = st_fx->bfi_pitch_fx; move16(); - tmp_float[1] = st_fx->bfi_pitch_frame; + tmp1[1] = st_fx->bfi_pitch_frame; move16(); - tmp_float[2] = st_fx->lp_gainp_fx; + tmp1[2] = st_fx->lp_gainp_fx; move16(); - tmp_float[3] = st_fx->lp_gainc_fx; + tmp1[3] = st_fx->lp_gainc_fx; move16(); - tmp_float[4] = st_fx->upd_cnt; + tmp1[4] = st_fx->upd_cnt; move16(); - tmp_float[5] = st_fx->seed; + tmp1[5] = st_fx->seed; move16(); /* calculation of excitation signal */ @@ -747,17 +747,17 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( Rescale_exc( NULL, exc, bwe_exc, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, L_FRAME32k, (Word32) 0, &Q_exc, st_fx->Q_subfr, exc2, st_fx->L_frame, st_fx->last_coder_type ); - st_fx->seed = tmp_float[5]; + st_fx->seed = tmp1[5]; move16(); - st_fx->bfi_pitch_fx = tmp_float[0]; + st_fx->bfi_pitch_fx = tmp1[0]; move16(); - st_fx->bfi_pitch_frame = tmp_float[1]; + st_fx->bfi_pitch_frame = tmp1[1]; move16(); - st_fx->lp_gainp_fx = tmp_float[2]; + st_fx->lp_gainp_fx = tmp1[2]; move16(); - st_fx->lp_gainc_fx = tmp_float[3]; + st_fx->lp_gainc_fx = tmp1[3]; move16(); - st_fx->upd_cnt = tmp_float[4]; + st_fx->upd_cnt = tmp1[4]; move16(); } @@ -767,27 +767,27 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( Rescale_mem( Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, 0, NULL ); - Copy( st_fx->mem_syn2_fx, tmp_float, M ); - syn_12k8_fx( st_fx->L_frame, Aq, exc2, syn, tmp_float, 1, Q_exc, st_fx->Q_syn ); + Copy( st_fx->mem_syn2_fx, tmp1, M ); + syn_12k8_fx( st_fx->L_frame, Aq, exc2, syn, tmp1, 1, Q_exc, st_fx->Q_syn ); - tmp_float32 = st_fx->enr_old_fx; + tmp8 = st_fx->enr_old_fx; move32(); - frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn, shr( add( FEC_pitch, 32 ), 6 ), &tmp_float32, st_fx->L_frame, st_fx->Q_syn, 3, 0 ); + frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn, shr( add( FEC_pitch, 32 ), 6 ), &tmp8, st_fx->L_frame, st_fx->Q_syn, 3, 0 ); /*------------------------------------------------------------------* * Perform fixed deemphasis through 1/(1 - g*z^-1) *-----------------------------------------------------------------*/ - tmp_float[0] = st_fx->mem_deemph_fx; + tmp1[0] = st_fx->mem_deemph_fx; move16(); /*if in acelp_core_dec_fx deemph_fx is used*/ - /*tmp_float = shr(st_fx->mem_deemph_fx, sub(st_fx->Q_syn,1)); if in acelp_core_dec_fx Deemph2 is used*/ + /*tmp1 = shr(st_fx->mem_deemph_fx, sub(st_fx->Q_syn,1)); if in acelp_core_dec_fx Deemph2 is used*/ IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { - deemph_fx( syn, PREEMPH_FAC, L_FRAME, &tmp_float[0] ); /*Q0*/ + deemph_fx( syn, PREEMPH_FAC, L_FRAME, &tmp1[0] ); /*Q0*/ } ELSE { - deemph_fx( syn, PREEMPH_FAC_16k, L_FRAME16k, &tmp_float[0] ); /*Q0*/ + deemph_fx( syn, PREEMPH_FAC_16k, L_FRAME16k, &tmp1[0] ); /*Q0*/ } /*----------------------------------------------------------------* @@ -796,24 +796,24 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( st_fx->bpf_off = 1; move16(); - Copy( hBPF->pst_old_syn_fx, tmp_float, NBPSF_PIT_MAX ); + Copy( hBPF->pst_old_syn_fx, tmp1, NBPSF_PIT_MAX ); - tmp_float3 = st_fx->stab_fac_smooth_fx; + tmp3 = st_fx->stab_fac_smooth_fx; move16(); - Copy( hBPF->mem_mean_pit_fx, tmp_float4, L_TRACK_HIST ); - Copy( hBPF->Track_on_hist, tmp_float5, L_TRACK_HIST ); - Copy( hBPF->vibrato_hist, tmp_float6, L_TRACK_HIST ); - tmp_float7 = hBPF->psf_att_fx; + Copy( hBPF->mem_mean_pit_fx, tmp4, L_TRACK_HIST ); + Copy( hBPF->Track_on_hist, tmp5, L_TRACK_HIST ); + Copy( hBPF->vibrato_hist, tmp6, L_TRACK_HIST ); + tmp7 = hBPF->psf_att_fx; move16(); bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn, st_fx->L_frame, pitch_buf, - st_fx->bpf_off, st_fx->stab_fac_fx, &tmp_float3, coder_type, st_fx->Q_syn, old_exc /* tmp buffer*/ ); + st_fx->bpf_off, st_fx->stab_fac_fx, &tmp3, coder_type, st_fx->Q_syn, old_exc /* tmp buffer*/ ); - Copy( tmp_float, hBPF->pst_old_syn_fx, NBPSF_PIT_MAX ); - Copy( tmp_float4, hBPF->mem_mean_pit_fx, L_TRACK_HIST ); - Copy( tmp_float5, hBPF->Track_on_hist, L_TRACK_HIST ); - Copy( tmp_float6, hBPF->vibrato_hist, L_TRACK_HIST ); - hBPF->psf_att_fx = tmp_float7; + Copy( tmp1, hBPF->pst_old_syn_fx, NBPSF_PIT_MAX ); + Copy( tmp4, hBPF->mem_mean_pit_fx, L_TRACK_HIST ); + Copy( tmp5, hBPF->Track_on_hist, L_TRACK_HIST ); + Copy( tmp6, hBPF->vibrato_hist, L_TRACK_HIST ); + hBPF->psf_att_fx = tmp7; /*----------------------------------------------------------------* * Resamping to the output sampling frequency *----------------------------------------------------------------*/ diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 7f1545e8d9ca9a71f55954ddcf619403a11154c1..db8611ecec3d2c841cb4c70ba1d362989bb76874 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -3603,7 +3603,6 @@ void IGFDecApplyStereo( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateDataL, hPrivateDataR; H_IGF_GRID hGrid; Word16 i, whiteningLevel; - float igf_specL[IGF_MAX_GRANULE_LEN], igf_specR[IGF_MAX_GRANULE_LEN]; Word32 igf_specL_fx[IGF_MAX_GRANULE_LEN]; Word32 igf_specR_fx[IGF_MAX_GRANULE_LEN]; Word16 igf_specL_e[IGF_MAX_TILES]; @@ -3616,9 +3615,6 @@ void IGFDecApplyStereo( Word16 v_len; Word16 s_l; - set_f( igf_specL, 0.f, IGF_MAX_GRANULE_LEN ); - set_f( igf_specR, 0.f, IGF_MAX_GRANULE_LEN ); - set32_fx( igf_specL_fx, 0, IGF_MAX_GRANULE_LEN ); set32_fx( igf_specR_fx, 0, IGF_MAX_GRANULE_LEN ); set16_fx( igf_specL_e, 0, IGF_MAX_TILES ); @@ -3843,15 +3839,6 @@ void IGFDecApplyStereo( igf_specR_e_arr, igf_specR_e ); - // Fixed to float - FOR( i = 0; i < hGrid->nTiles; i++ ) - { - Word16 start = hGrid->tile[i]; - Word16 stop = hGrid->tile[i + 1]; - me2f_buf( igf_specL_fx + start, igf_specL_e[i], igf_specL + start, stop - start ); - me2f_buf( igf_specR_fx + start, igf_specR_e[i], igf_specR + start, stop - start ); - } - IGF_calc_ivas( hPrivateDataL, igfGridIdx, spectrumL_fx, diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ab66ecf6437f84de9ffc54f5084b781fdd207e18..9565fe6b3cedd0e81a294c4123ca41a4d9a2391d 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1857,6 +1857,7 @@ ivas_error ivas_dirac_dec_config_fx( } } st_ivas->hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + move16(); } } } diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 10660be2da70d3f5c6291bb9fc9bc4cb8b4c20ad..30d982aaaa8d411e1126a55ba355f0b5d4971ec4 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -53,9 +53,6 @@ #include "ivas_prot_fx.h" #endif -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED - - /*-------------------------------------------------------------------* * ivas_dirac_dec_output_synthesis_cov_open() * @@ -639,6 +636,7 @@ void ivas_dirac_dec_output_synthesis_cov_close( * collect the multi channel input covariance for one filter bank time slot *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( float *RealBuffer, /* i : input channel filter bank samples (real part) */ float *ImagBuffer, /* i : input channel filter bank samples (imaginary part */ @@ -727,8 +725,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( return; } - -#ifdef IVAS_FLOAT_FIXED +#else /*-------------------------------------------------------------------* * ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot() * @@ -1834,32 +1831,23 @@ Word16 computeMixingMatrices_fx( { mat2svdMat_fx( mat_mult_buffer1_fx, svd_in_buffer_fx, lengthCx, lengthCy, 1 ); -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - /*FOR ( Word32 g = 0; g < lengthCy; g++ ) - { - me2f_buf( ( svd_in_buffer_fx[g] ), mat_mult_buffer1_e, ( svd_in_buffer[g] ), lengthCx ); - }*/ - nL = lengthCy; move16(); nC = lengthCx; move16(); svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_v_buffer_fx, svd_s_buffer_fx, svd_u_buffer_fx, &svd_s_buffer_fx_e, nL, nC ); -#endif } ELSE { mat2svdMat_fx( mat_mult_buffer1_fx, svd_in_buffer_fx, lengthCx, lengthCy, 0 ); -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED nL = lengthCx; move16(); nC = lengthCy; move16(); svd_fx( svd_in_buffer_fx, mat_mult_buffer1_e, svd_u_buffer_fx, svd_s_buffer_fx, svd_v_buffer_fx, &svd_s_buffer_fx_e, nL, nC ); -#endif } /* Actually Processing P */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index f17a8ccb7780fcb4ae2015cbfac763ece0774b8d..64b4810c61b33033152096da9d73571a7c6637fa 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1499,10 +1499,6 @@ ivas_error ivas_init_decoder_front( { IF( EQ_32( ( error = ivas_ls_custom_open_fx( &( st_ivas->hLsSetupCustom ) ) ), IVAS_ERR_OK ) ) { -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - set_zero( ( st_ivas->hLsSetupCustom )->ls_azimuth, MAX_OUTPUT_CHANNELS ); - set_zero( ( st_ivas->hLsSetupCustom )->ls_elevation, MAX_OUTPUT_CHANNELS ); -#endif set_zero_fx( ( st_ivas->hLsSetupCustom )->ls_azimuth_fx, MAX_OUTPUT_CHANNELS ); set_zero_fx( ( st_ivas->hLsSetupCustom )->ls_elevation_fx, MAX_OUTPUT_CHANNELS ); } @@ -1617,14 +1613,6 @@ ivas_error ivas_init_decoder_front( { return error; } - -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - /*FLOAT CODE*/ - IF( NE_32( ( error = ivas_render_config_init_from_rom( &st_ivas->hRenderConfig ) ), IVAS_ERR_OK ) ) - { - return error; - } -#endif } return error; @@ -2043,7 +2031,6 @@ ivas_error ivas_init_decoder_fx( return error; } #ifdef MSAN_FIX - set_f( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, 0.f, CLDFB_NO_COL_MAX ); set16_fx( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 0, CLDFB_NO_COL_MAX ); #endif test(); @@ -2471,10 +2458,6 @@ ivas_error ivas_init_decoder_fx( /* init EFAP for custom LS setup */ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { - /*float2fix block: to be removed*/ - floatToFixed_arrL( st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_azimuth_fx, Q22, st_ivas->hLsSetupCustom->num_spk ); - floatToFixed_arrL( st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->ls_elevation_fx, Q22, st_ivas->hLsSetupCustom->num_spk ); - /*float2fix block end*/ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) { return error; @@ -2514,10 +2497,6 @@ ivas_error ivas_init_decoder_fx( /* init EFAP for custom LS setup */ IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) { - /*float2fix block: to be removed*/ - floatToFixed_arrL( st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_azimuth_fx, Q22, st_ivas->hLsSetupCustom->num_spk ); - floatToFixed_arrL( st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->ls_elevation_fx, Q22, st_ivas->hLsSetupCustom->num_spk ); - /*float2fix block end*/ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hLsSetupCustom->ls_azimuth_fx, st_ivas->hLsSetupCustom->ls_elevation_fx, st_ivas->hLsSetupCustom->num_spk, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) { return error; @@ -3070,20 +3049,10 @@ ivas_error ivas_init_decoder_fx( test(); IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !st_ivas->sba_dirac_stereo_flag && NE_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) { -#ifdef IVAS_FLOAT_FIXED -#if 1 Word16 Q_cldfbSynDec = Q11; move16(); -#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 -#endif ivas_spar_get_cldfb_gains_fx( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig ); -#if 1 + FOR( i = 0; i < st_ivas->cldfbAnaDec[0]->cldfb_state_length; i++ ) { st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i], 16 ); // Scaling down from 27 to 11 @@ -3098,14 +3067,6 @@ ivas_error ivas_init_decoder_fx( } st_ivas->cldfbSynDec[0]->Q_cldfb_state = Q11; move16(); - IF( st_ivas->hSpar ) - { - fixedToFloat_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, st_ivas->hSpar->hFbMixer->cldfb_cross_fade, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q, 16 ); - } -#endif -#else - ivas_spar_get_cldfb_gains( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig ); -#endif } /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index e50db18afcf419dc5743bafcf1763229782f20f2..0a9a873fecd595966bc3b0db98403c509ec2f098 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1886,7 +1886,7 @@ void ivas_ism_dec_digest_tc_fx( move16(); FOR( i = 1; i < interpolator_length; i++ ) { - Word16 tmp = div_s( 1, interpolator_length - 1 ); + Word16 tmp = div_s( 1, sub( interpolator_length, 1 ) ); st_ivas->hIsmRendererData->interpolator_fx[i] = add( st_ivas->hIsmRendererData->interpolator_fx[i - 1], tmp ); // Q15 move16(); } @@ -1902,7 +1902,7 @@ void ivas_ism_dec_digest_tc_fx( } ELSE { - ivas_jbm_dec_get_adapted_linear_interpolator_fx( (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator_fx ); + ivas_jbm_dec_get_adapted_linear_interpolator_fx( (Word16) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ), st_ivas->hTcBuffer->n_samples_available, st_ivas->hIsmRendererData->interpolator_fx ); move16(); } @@ -1928,6 +1928,8 @@ void ivas_ism_dec_digest_tc_fx( azimuth_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->azimuth_fx, 2097152 ), Q22 ); elevation_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->elevation_fx, 2097152 ), Q22 ); + test(); + test(); test(); test(); test(); @@ -1936,7 +1938,7 @@ void ivas_ism_dec_digest_tc_fx( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) && st_ivas->hCombinedOrientationData == NULL ) { - IF( st_ivas->hIntSetup.is_planar_setup ) + if ( st_ivas->hIntSetup.is_planar_setup ) { /* If no elevation support in output format, then rendering should be done with zero elevation */ elevation_fx = 0; @@ -2277,17 +2279,10 @@ void ivas_param_ism_dec_digest_tc_fx( } } /* Obtain Mixing Matrix on a frame-level */ -#if 1 /*To avoid garbage values(garbage values giving wrong exponent in jbm_dec_render)*/ FOR( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ ) { set32_fx( hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx[bin_idx], 0, PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX ); } -#else - FOR( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ ) - { - set32_fx( hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx[bin_idx], 0, nchan_transport * nchan_out_woLFE ); - } -#endif /* Compute mixing matrix */ ivas_param_ism_compute_mixing_matrix_fx( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response_fx, nchan_transport, nchan_out_woLFE, cx_diag_fx, exp_cx_diag, ref_power_fx, exp_ref_power, @@ -2464,6 +2459,7 @@ void ivas_param_ism_dec_digest_tc( * *-------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_ism_param_dec_tc_gain_ajust( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint16_t nSamples, /* i : number of samples to be compensate */ @@ -2516,8 +2512,7 @@ void ivas_ism_param_dec_tc_gain_ajust( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void ivas_ism_param_dec_tc_gain_ajust_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamples, /* i : number of samples to be compensate */ @@ -2689,7 +2684,7 @@ static void ivas_ism_param_dec_render_sf_fx( Word32 *output_f_fx[], Word16 Q_output[] ) { - int16_t ch, slot_idx, i, index_slot; + Word16 ch, slot_idx, i, index_slot; /* CLDFB Output Buffers */ Word32 Cldfb_RealBuffer_fx[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 3e8ff12c1af4083849430ad67092e42904385b0d..1b0a1d9f63c773e6723a4c546fd54f8437665200 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -140,7 +140,7 @@ ivas_error ivas_jbm_dec_tc_fx( } } - IF( EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 0 ) ) + IF( st_ivas->hDecoderConfig->Opt_tsm == 0 ) { FOR( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) { @@ -159,7 +159,9 @@ ivas_error ivas_jbm_dec_tc_fx( * Decoding + pre-rendering *----------------------------------------------------------------*/ - IF( NE_16( st_ivas->bfi, 0 ) && EQ_16( st_ivas->ini_frame, 0 ) ) + test(); + test(); + IF( st_ivas->bfi != 0 && st_ivas->ini_frame == 0 ) { /* zero output when first frame(s) is lost */ FOR( n = 0; n < nchan_out; n++ ) @@ -167,9 +169,10 @@ ivas_error ivas_jbm_dec_tc_fx( set32_fx( p_output_fx[n], 0, output_frame ); } } - ELSE IF( st_ivas->ivas_format == STEREO_FORMAT ) + ELSE IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) ) { st_ivas->hCPE[0]->element_brate = ivas_total_brate; + move32(); Word16 q_output = 11; move16(); set32_fx( &p_output_fx[0][0], 0, L_FRAME48k ); @@ -191,36 +194,37 @@ ivas_error ivas_jbm_dec_tc_fx( } /* HP filtering */ - FOR( n = 0; n < min( nchan_out, st_ivas->nchan_transport ); n++ ) + FOR( n = 0; n < s_min( nchan_out, st_ivas->nchan_transport ); n++ ) { hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) { - s = sub( Q16, Q11 ); + s = Q16 - Q11; s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); - FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { Scale_sig32( p_output_fx[i], output_frame, s ); } ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); - FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } } } - ELSE IF( st_ivas->ivas_format == ISM_FORMAT ) + ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) { /* Metadata decoding and configuration */ + test(); IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) { ivas_ism_dtx_dec_fx( st_ivas, nb_bits_metadata ); set32_fx( p_output_fx[st_ivas->hISMDTX.sce_id_dtx], 0, L_FRAME48k ); - IF( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output_fx[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, st_ivas->hISMDTX.sce_id_dtx, &p_output_fx[st_ivas->hISMDTX.sce_id_dtx], output_frame, nb_bits_metadata[st_ivas->hISMDTX.sce_id_dtx] ) ), IVAS_ERR_OK ) ) { return error; } @@ -237,20 +241,22 @@ ivas_error ivas_jbm_dec_tc_fx( scale_sig32( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); Q_cngNoiseLevel[ch] = sub( 31, st_ivas->hSCE[ch]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); + move16(); + move16(); } } ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport, Q_cngNoiseLevel ); } - ELSE IF( st_ivas->ism_mode == ISM_MODE_PARAM ) + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { - IF( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hParamIsmDec->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hParamIsmDec->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) ) { return error; } } ELSE /* ISM_MODE_DISC */ { - IF( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_ism_metadata_dec_fx( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hSCE[0]->hCoreCoder[0] ) ), IVAS_ERR_OK ) ) { return error; } @@ -259,11 +265,13 @@ ivas_error ivas_jbm_dec_tc_fx( FOR( n = 0; n < st_ivas->nchan_transport; n++ ) { /* for DTX frames, dominant object has already been decoded before */ - IF( !( ( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) && n == st_ivas->hISMDTX.sce_id_dtx ) ) + test(); + test(); + IF( !( ( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) && EQ_16( n, st_ivas->hISMDTX.sce_id_dtx ) ) ) { set32_fx( p_output_fx[n], 0, L_FRAME48k ); - IF( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[n], output_frame, nb_bits_metadata[n] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[n], output_frame, nb_bits_metadata[n] ) ), IVAS_ERR_OK ) ) { return error; } @@ -273,13 +281,16 @@ ivas_error ivas_jbm_dec_tc_fx( hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } - IF( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + test(); + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { ivas_mono_downmix_render_passive_fx( st_ivas, p_output_fx, output_frame ); Scale_sig32( p_output_fx[0], L_FRAME48k, 3 ); } - ELSE IF( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) ) + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) ) { /* loudness correction */ ivas_dirac_dec_binaural_sba_gain_fx( p_output_fx, st_ivas->nchan_transport, output_frame ); /*returns Q-1*/ @@ -290,34 +301,45 @@ ivas_error ivas_jbm_dec_tc_fx( } } } - ELSE IF( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { set16_fx( nb_bits_metadata, 0, MAX_SCE ); /* read parameters from the bitstream */ - IF( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hQMetaData != NULL ) + test(); + IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->hQMetaData != NULL ) { - st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; + // st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; + + IF( st_ivas->nSCE > 0 ) + { + st = st_ivas->hSCE[0]->hCoreCoder[0]; + } + ELSE + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; + } - IF( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } - IF( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); } } - ELSE IF( st_ivas->ivas_format == SBA_FORMAT ) + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) { - IF( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) ) { return error; } } + test(); IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) ) { st_ivas->hCPE[0]->brate_surplus = 0; @@ -328,11 +350,12 @@ ivas_error ivas_jbm_dec_tc_fx( /* core-decoding of transport channels */ Word16 q_output = Q11; + move16(); IF( EQ_16( st_ivas->nSCE, 1 ) ) { set32_fx( p_output_fx[0], 0, L_FRAME48k ); - IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } @@ -359,7 +382,7 @@ ivas_error ivas_jbm_dec_tc_fx( } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { - IF( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } @@ -367,6 +390,13 @@ ivas_error ivas_jbm_dec_tc_fx( /* TCs remapping */ nchan_remapped = st_ivas->nchan_transport; + move16(); + + test(); + test(); + test(); + test(); + test(); IF( st_ivas->sba_dirac_stereo_flag ) { nchan_remapped = nchan_out; @@ -376,11 +406,12 @@ ivas_error ivas_jbm_dec_tc_fx( { FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) { - Scale_sig32( p_output_fx[i], output_frame, sub( Q14, Q11 ) ); + Scale_sig32( p_output_fx[i], output_frame, Q14 - Q11 ); } SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 nchan_transport; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + move16(); nchan_out = nchan_transport; move16(); hSpar->hMdDec->Q_mixer_mat = 31; @@ -409,7 +440,7 @@ ivas_error ivas_jbm_dec_tc_fx( { Scale_sig32( p_output_fx[i], L_FRAME48k, s ); } - hCPE->hStereoDft->q_dft = Q11 + s; + hCPE->hStereoDft->q_dft = add( Q11, s ); IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; @@ -430,6 +461,7 @@ ivas_error ivas_jbm_dec_tc_fx( Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; + move16(); } IF( hCPE->hStereoDft != NULL ) { @@ -437,8 +469,21 @@ ivas_error ivas_jbm_dec_tc_fx( IF( LE_16( st_ivas->nchan_transport, 1 ) ) { st = hCPE->hCoreCoder[0]; - 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 ) ) ) { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); 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 ) || ( st_ivas->sba_dirac_stereo_flag && st->cng_type == FD_CNG ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( hCPE->hCoreCoder[0]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); @@ -453,9 +498,15 @@ ivas_error ivas_jbm_dec_tc_fx( } ELSE /* ACELP core */ { - IF( st->last_core == TCX_20_CORE || st->last_core == TCX_10_CORE || st->last_core == HQ_CORE ) /* TCX/HQ -> ACELP */ + test(); + test(); + 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 ) || ( st_ivas->sba_dirac_stereo_flag && st->core_brate == SID_2k40 && st->cng_type == FD_CNG ) ) + test(); + test(); + test(); + test(); + IF( ( LE_16( st->last_L_frame, L_FRAME16k ) && LE_16( st->L_frame, L_FRAME16k ) ) || ( st_ivas->sba_dirac_stereo_flag && EQ_32( st->core_brate, SID_2k40 ) && EQ_16( st->cng_type, FD_CNG ) ) ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( hCPE->hCoreCoder[0]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); } @@ -467,6 +518,7 @@ ivas_error ivas_jbm_dec_tc_fx( #endif scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; + move16(); } IF( hSCE != NULL ) @@ -477,6 +529,7 @@ ivas_error ivas_jbm_dec_tc_fx( hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; } st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; + move16(); FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); @@ -524,8 +577,20 @@ ivas_error ivas_jbm_dec_tc_fx( IF( LE_16( st_ivas->nchan_transport, 1 ) ) { st = hCPE->hCoreCoder[0]; - 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 ) ) ) { + test(); + test(); + test(); + test(); + test(); + test(); + test(); 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 ) || ( st_ivas->sba_dirac_stereo_flag && st->cng_type == FD_CNG ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( hCPE->hCoreCoder[0]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); @@ -540,8 +605,12 @@ ivas_error ivas_jbm_dec_tc_fx( } ELSE /* ACELP core */ { + test(); + test(); IF( st->last_core == TCX_20_CORE || st->last_core == TCX_10_CORE || st->last_core == HQ_CORE ) /* TCX/HQ -> ACELP */ { + test(); + test(); IF( ( st->last_L_frame <= L_FRAME16k && st->L_frame <= L_FRAME16k ) || ( st_ivas->sba_dirac_stereo_flag && st->core_brate == SID_2k40 && st->cng_type == FD_CNG ) ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( hCPE->hCoreCoder[0]->L_frame * FRAMES_PER_SEC, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); @@ -554,8 +623,10 @@ ivas_error ivas_jbm_dec_tc_fx( #endif scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + test(); } st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; + test(); FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); @@ -563,9 +634,10 @@ ivas_error ivas_jbm_dec_tc_fx( } } } - ELSE IF( st_ivas->ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE && ( ivas_total_brate > IVAS_SID_5k2 || ( ivas_total_brate <= IVAS_SID_5k2 && st_ivas->nCPE > 0 && st_ivas->hCPE[0]->nchan_out == 1 ) ) ) + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) || ( LE_32( ivas_total_brate, IVAS_SID_5k2 ) && st_ivas->nCPE > 0 && EQ_16( st_ivas->hCPE[0]->nchan_out, 1 ) ) ) ) { nchan_remapped = 1; /* Only one channel transported */ + test(); } /* HP filtering */ @@ -574,10 +646,11 @@ ivas_error ivas_jbm_dec_tc_fx( hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } - IF( st_ivas->ivas_format == SBA_FORMAT ) + IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) { nchan_remapped = ivas_sba_remapTCs_fx( p_output_fx, st_ivas, output_frame ); + test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); @@ -616,21 +689,24 @@ ivas_error ivas_jbm_dec_tc_fx( Scale_sig32( p_output_fx[c], output_frame, 11 ); } } - ELSE IF( st_ivas->renderer_type != RENDERER_DISABLE ) + ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) ) { Word16 size = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; - IF( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport == 3 ) + move16(); + IF( EQ_16( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, 3 ) ) size = add( size, 1 ); FOR( i = 0; i < size; i++ ) { - Scale_sig32( p_output_fx[i], output_frame, sub( Q14, Q11 ) ); + Scale_sig32( p_output_fx[i], output_frame, Q14 - Q11 ); } ivas_spar_dec_agc_pca_fx( st_ivas, p_output_fx, output_frame ); } } + test(); + test(); IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { Word16 q_shift = 0; @@ -651,7 +727,7 @@ ivas_error ivas_jbm_dec_tc_fx( } } } - ELSE IF( st_ivas->ivas_format == MASA_ISM_FORMAT ) + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { Word16 nchan_ism, nchan_transport_ism; Word16 dirac_bs_md_write_idx; @@ -665,7 +741,8 @@ ivas_error ivas_jbm_dec_tc_fx( { st_ivas->hSpatParamRendCom->numIsmDirections = 0; move16(); - IF( st_ivas->ism_mode != ISM_MASA_MODE_DISC && st_ivas->ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) + test(); + IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && NE_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { st_ivas->hSpatParamRendCom->numIsmDirections = st_ivas->nchan_ism; move16(); @@ -681,12 +758,12 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); // NOTE: the following is done to calculate the number of hIsmMetaData indices Word16 tmp_nchan_ism; - IF( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { tmp_nchan_ism = 1; move16(); } - ELSE IF( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { tmp_nchan_ism = 0; move16(); @@ -703,7 +780,7 @@ ivas_error ivas_jbm_dec_tc_fx( } /* MASA metadata decoding */ - IF( ( error = ivas_masa_decode_fx( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } @@ -713,14 +790,14 @@ ivas_error ivas_jbm_dec_tc_fx( st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream = &( st_ivas->bit_stream[( ism_total_brate / FRAMES_PER_SEC )] ); - IF( ( error = ivas_omasa_ism_metadata_dec_fx( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_omasa_ism_metadata_dec_fx( st_ivas, ism_total_brate, &nchan_ism, &nchan_transport_ism, dirac_bs_md_write_idx, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) { return error; } FOR( n = 0; n < nchan_transport_ism; n++ ) { - IF( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, n, &p_output_fx[st_ivas->nchan_transport + n], output_frame, nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) { return error; } @@ -739,9 +816,9 @@ ivas_error ivas_jbm_dec_tc_fx( /* shifting both the channels from variable q_output to constant Q-factor (Q11) */ FOR( Word16 k = 0; k < output_frame; k++ ) { - p_output_fx[0][k] = L_shr( p_output_fx[0][k], 11 - q_output ); + p_output_fx[0][k] = L_shr( p_output_fx[0][k], sub( Q11, q_output ) ); move32(); - p_output_fx[1][k] = L_shr( p_output_fx[1][k], 11 - q_output ); + p_output_fx[1][k] = L_shr( p_output_fx[1][k], sub( Q11, q_output ) ); move32(); } @@ -757,14 +834,14 @@ ivas_error ivas_jbm_dec_tc_fx( Word16 output_q = 11; move16(); - IF( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) { ivas_mono_downmix_render_passive_fx( st_ivas, p_output_fx, output_frame ); output_q = 8; move16(); } - ELSE IF( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { /* sanity check in case of bitrate switching */ IF( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) @@ -787,36 +864,39 @@ ivas_error ivas_jbm_dec_tc_fx( } } } - ELSE IF( st_ivas->ivas_format == SBA_ISM_FORMAT ) + ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { Word16 nchan_ism, sba_ch_idx; set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 ); nchan_ism = st_ivas->nchan_ism; - IF( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { /* set ISM parameters and decode ISM metadata in OSBA format */ - IF( ( error = ivas_osba_ism_metadata_dec_fx( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_osba_ism_metadata_dec_fx( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) { return error; } sba_ch_idx = st_ivas->nchan_ism; + move16(); } ELSE { - nb_bits_metadata[1] += NO_BITS_MASA_ISM_NO_OBJ; + nb_bits_metadata[1] = add( nb_bits_metadata[1], NO_BITS_MASA_ISM_NO_OBJ ); sba_ch_idx = 0; } /* SBA metadata decoding */ - IF( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) ) { return error; } + test(); IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) ) { st_ivas->hCPE[0]->element_brate = ivas_total_brate; + move32(); } /* core-decoding of transport channels */ @@ -827,7 +907,7 @@ ivas_error ivas_jbm_dec_tc_fx( { set32_fx( p_output_fx[0], 0, L_FRAME48k ); - IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) { return error; } @@ -852,7 +932,7 @@ ivas_error ivas_jbm_dec_tc_fx( } ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { - IF( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) { return error; } @@ -862,7 +942,7 @@ ivas_error ivas_jbm_dec_tc_fx( { FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) { - Scale_sig32( p_output_fx[i + sba_ch_idx], output_frame, sub( Q14, Q11 ) ); + Scale_sig32( p_output_fx[i + sba_ch_idx], output_frame, Q14 - Q11 ); } SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 nchan_transport; @@ -893,11 +973,13 @@ ivas_error ivas_jbm_dec_tc_fx( { Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, s ); } - hCPE->hStereoDft->q_dft = Q11 + s; + hCPE->hStereoDft->q_dft = add( Q11, s ); IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; + move16(); + move16(); } q = hCPE->hStereoDft->q_dft; @@ -910,8 +992,8 @@ ivas_error ivas_jbm_dec_tc_fx( } IF( hCPE->hCoreCoder[0] != NULL ) { - Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); - Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); + Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); + Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; } IF( hCPE->hStereoDft != NULL ) @@ -921,18 +1003,22 @@ ivas_error ivas_jbm_dec_tc_fx( hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; } st_ivas->hSpar->hMdDec->Q_mixer_mat = Q30; + move32(); IF( hSCE != NULL ) { Scale_sig32( &hSCE->save_hb_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; + move16(); Scale_sig32( &hSCE->save_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; + move16(); } FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; + move16(); } #ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) @@ -948,7 +1034,7 @@ ivas_error ivas_jbm_dec_tc_fx( #ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), 11 - hCPE->q_prev_synth_fx ); + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); #endif @@ -964,19 +1050,22 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB - q ); - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda - q ); + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); } IF( hCPE->hStereoDft != NULL ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + move16(); } st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; - FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) + move16(); + FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); hCPE->q_output_mem_fx[ii] = Q11; + move16(); } } } @@ -989,20 +1078,26 @@ ivas_error ivas_jbm_dec_tc_fx( nchan_remapped = ivas_sba_remapTCs_fx( &p_output_fx[sba_ch_idx], st_ivas, output_frame ); - IF( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 Q_p_output = 14; + move16(); Word16 nchan_transport; // num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + move16(); nchan_out = nchan_transport; + move16(); FOR( ch = 0; ch < nchan_transport; ch++ ) { Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, sub( Q_p_output, Q11 ) ); } hSpar->hMdDec->Q_mixer_mat = 31; + move16(); ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, &p_output_fx[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames, sub( Q_p_output, Q11 ) ); FOR( Word16 c = 0; c < nchan_transport; c++ ) @@ -1010,11 +1105,13 @@ ivas_error ivas_jbm_dec_tc_fx( Scale_sig32( p_output_fx[sba_ch_idx + c], output_frame, Q11 ); } } - ELSE IF( st_ivas->renderer_type != RENDERER_DISABLE && EQ_16( st_ivas->sba_dirac_stereo_flag, 0 ) ) + ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && st_ivas->sba_dirac_stereo_flag == 0 ) { Word16 size = st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport + sba_ch_idx; IF( EQ_16( size, 3 ) ) - size += 1; + { + size = add( size, 1 ); + } FOR( i = sba_ch_idx; i < size; i++ ) { @@ -1024,7 +1121,9 @@ ivas_error ivas_jbm_dec_tc_fx( ivas_spar_dec_agc_pca_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); } - IF( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { /* loudness correction */ ivas_dirac_dec_binaural_sba_gain_fx( &p_output_fx[sba_ch_idx], nchan_remapped, output_frame ); /*returns Q-1*/ @@ -1034,30 +1133,39 @@ ivas_error ivas_jbm_dec_tc_fx( Scale_sig32( p_output_fx[i], output_frame, 1 ); } } - ELSE IF( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { ivas_mono_downmix_render_passive_fx( st_ivas, p_output_fx, output_frame ); - Scale_sig32( p_output_fx[0], L_FRAME48k, sub( Q11, Q8 ) ); + Scale_sig32( p_output_fx[0], L_FRAME48k, Q11 - Q8 ); /* add W */ FOR( n = 0; n < nchan_out; n++ ) { - v_add_32( p_output_fx[n], p_output_fx[n + max( nchan_out, nchan_ism )], p_output_fx[n], output_frame ); + v_add_32( p_output_fx[n], p_output_fx[n + s_max( nchan_out, nchan_ism )], p_output_fx[n], output_frame ); } } } - ELSE IF( st_ivas->ivas_format == MC_FORMAT ) + ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) { - st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; - IF( st_ivas->mc_mode == MC_MODE_MCT ) + // st = (st_ivas->nSCE > 0) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; + IF( st_ivas->nSCE > 0 ) + { + st = st_ivas->hSCE[0]->hCoreCoder[0]; + } + ELSE + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; + } + + IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) { /* LFE channel decoder */ ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); - Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, sub( Q11, Q9 ) ); - IF( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ) != IVAS_ERR_OK ) + Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ), IVAS_ERR_OK ) ) { return error; } @@ -1070,7 +1178,10 @@ ivas_error ivas_jbm_dec_tc_fx( } } - IF( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) + test(); + test(); + test(); + IF( NE_32( st_ivas->transport_config, st_ivas->intern_config ) && ( NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) { IF( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) { @@ -1078,38 +1189,40 @@ ivas_error ivas_jbm_dec_tc_fx( } } - IF( ( st_ivas->renderer_type == RENDERER_MC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) && GE_16( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ), ( st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ) ) ) + test(); + test(); + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_MC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) ) { - IF( st_ivas->renderer_type == RENDERER_MC ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { - s = sub( Q16, Q11 ); + s = Q16 - Q11; s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); - FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { Scale_sig32( p_output_fx[i], output_frame, s ); } ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); - FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } } - ELSE IF( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hOutSetup.ambisonics_order, 0 ); } } } - ELSE IF( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { /* LFE channel decoder */ ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); - Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, sub( Q11, Q9 ) ); + Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); - IF( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } @@ -1123,7 +1236,9 @@ ivas_error ivas_jbm_dec_tc_fx( } /* Rendering */ - IF( st_ivas->renderer_type == RENDERER_MC && ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) ) + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) { /* Compensate loudness for not doing full upmix */ FOR( n = 4; n < 8; n++ ) @@ -1131,25 +1246,27 @@ ivas_error ivas_jbm_dec_tc_fx( Scale_sig32( p_output_fx[n], output_frame, 1 ); } - IF( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) + test(); + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { - s = sub( Q16, Q11 ); + s = Q16 - Q11; + move16(); Word16 nchan_transport; nchan_transport = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ); - s = s - find_guarded_bits_fx( nchan_transport ); - FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) + s = sub( s, find_guarded_bits_fx( nchan_transport ) ); + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) { Scale_sig32( p_output_fx[i], output_frame, s ); } ivas_ls_setup_conversion_fx( st_ivas, nchan_transport, output_frame, p_output_fx, p_output_fx ); - FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) { Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } } } } - ELSE IF( st_ivas->mc_mode == MC_MODE_PARAMMC ) + ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { /* read Parametric MC parameters from the bitstream */ ivas_param_mc_dec_read_BS_fx( ivas_total_brate, st, st_ivas->hParamMC, &nb_bits_metadata[0] ); @@ -1157,6 +1274,7 @@ ivas_error ivas_jbm_dec_tc_fx( IF( EQ_16( st_ivas->nCPE, 1 ) ) { Word16 q_output = 11; + move16(); #ifndef FIX_826_PRECISION_LOST_AND_COMPL IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0], &q_output ) ) != IVAS_ERR_OK ) @@ -1172,9 +1290,9 @@ ivas_error ivas_jbm_dec_tc_fx( Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); } } - ELSE IF( st_ivas->nCPE > 1 ) + ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) { - IF( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } @@ -1187,22 +1305,24 @@ ivas_error ivas_jbm_dec_tc_fx( } /* Rendering */ - IF( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) + test(); + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { - s = sub( Q16, Q11 ); + s = Q16 - Q11; + move16(); s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); - FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { Scale_sig32( p_output_fx[i], output_frame, s ); } ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); - FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } } } - ELSE IF( st_ivas->mc_mode == MC_MODE_MCMASA ) + ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { IF( st_ivas->hOutSetup.separateChannelEnabled ) { @@ -1211,16 +1331,16 @@ ivas_error ivas_jbm_dec_tc_fx( /* read McMASA parameters from the bitstream */ - IF( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } - // Fixed to float conversion ends here. IF( st_ivas->hOutSetup.separateChannelEnabled ) { /* Decode the transport audio signals */ Word16 q_output = 11; + move16(); #ifndef FIX_826_PRECISION_LOST_AND_COMPL IF( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0], &q_output ) ) != IVAS_ERR_OK ) @@ -1243,18 +1363,25 @@ ivas_error ivas_jbm_dec_tc_fx( set32_fx( p_output_fx[n], 0, L_FRAME48k ); - IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ), IVAS_ERR_OK ) ) { return error; } + test(); + test(); + test(); + test(); + test(); + test(); + test(); /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */ - IF( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 || - output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 || - output_config == IVAS_AUDIO_CONFIG_5_1_2 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) ) { ivas_lfe_synth_with_filters_fx( st_ivas->hMasa->hMasaLfeSynth, p_output_fx, output_frame, n, LFE_CHANNEL ); } - ELSE IF( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && EQ_16( st_ivas->hOutSetup.num_lfe, 0 ) ) + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe == 0 ) { /* Delay the separated channel to sync with the DirAC rendering */ delay_signal_fx( p_output_fx[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); @@ -1268,7 +1395,7 @@ ivas_error ivas_jbm_dec_tc_fx( { set32_fx( p_output_fx[0], 0, L_FRAME48k ); - IF( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } @@ -1292,7 +1419,7 @@ ivas_error ivas_jbm_dec_tc_fx( } } - IF( NE_16( st_ivas->sba_dirac_stereo_flag, 0 ) ) /* use the flag to trigger the DFT upmix */ + IF( st_ivas->sba_dirac_stereo_flag != 0 ) /* use the flag to trigger the DFT upmix */ { Word16 q; hCPE = st_ivas->hCPE[0]; @@ -1307,14 +1434,19 @@ ivas_error ivas_jbm_dec_tc_fx( { Scale_sig32( p_output_fx[i], L_FRAME48k, s ); } - hCPE->hStereoDft->q_dft = Q11 + s; + hCPE->hStereoDft->q_dft = add( Q11, s ); IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; + + move16(); + move16(); } q = hCPE->hStereoDft->q_dft; + move16(); + scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) { @@ -1327,33 +1459,39 @@ ivas_error ivas_jbm_dec_tc_fx( Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; + move16(); } IF( hCPE->hStereoDft != NULL ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; + move16(); } IF( st_ivas->hSpar != NULL ) { st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; + move16(); } IF( hSCE != NULL ) { Scale_sig32( &hSCE->save_hb_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; + move16(); Scale_sig32( &hSCE->save_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; + move16(); } FOR( Word16 ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; + move16(); } #ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), hCPE->q_prev_synth_fx - 11 ); + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, 11 ) ); #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), hCPE->q_prev_synth_fx - 11 ); #endif @@ -1364,7 +1502,7 @@ ivas_error ivas_jbm_dec_tc_fx( } #ifdef MSAN_FIX FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), 11 - hCPE->q_prev_synth_fx ); + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); #else Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); #endif // MSAN_FIX @@ -1386,6 +1524,7 @@ ivas_error ivas_jbm_dec_tc_fx( scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + move16(); } IF( st_ivas->hSpar != NULL ) { @@ -1406,7 +1545,7 @@ ivas_error ivas_jbm_dec_tc_fx( hp20_fix32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } - IF( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) ) { ivas_mono_stereo_downmix_mcmasa_fx( st_ivas, p_output_fx, output_frame ); } @@ -1437,19 +1576,27 @@ ivas_error ivas_jbm_dec_tc_fx( st_ivas->hDecoderConfig->last_ivas_total_brate = ivas_total_brate; move32(); st_ivas->last_active_ivas_total_brate = ( ivas_total_brate <= IVAS_SID_5k2 ) ? st_ivas->last_active_ivas_total_brate : ivas_total_brate; + move32(); } - IF( st_ivas->ini_frame < MAX_FRAME_COUNTER && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */ + test(); + test(); + IF( LT_16( st_ivas->ini_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */ { st_ivas->ini_frame = add( st_ivas->ini_frame, 1 ); + move16(); } - IF( st_ivas->ini_active_frame < MAX_FRAME_COUNTER && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && ivas_total_brate > IVAS_SID_5k2 ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */ + test(); + test(); + IF( LT_16( st_ivas->ini_active_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */ { st_ivas->ini_active_frame = add( st_ivas->ini_active_frame, 1 ); + move16(); } st_ivas->last_ivas_format = st_ivas->ivas_format; + move32(); pop_wmops(); return IVAS_ERR_OK; @@ -2377,11 +2524,11 @@ void ivas_jbm_dec_feed_tc_to_renderer( in_q = max_e; Word16 nchan_transport = st_ivas->nchan_transport; - Word16 nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); Word16 nchan_out_cov; IF( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { - nchan_out_cov = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); } ELSE IF( st_ivas->hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB ) { @@ -2612,6 +2759,7 @@ ivas_error ivas_jbm_dec_render_fx( Word32 *p_tc_fx[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS]; Word16 subframe_len, gd_bits, exp, nchan_in, i, j; const Word16 output_q_factor = Q11; + move16(); SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; push_wmops( "ivas_dec_render" ); @@ -2698,6 +2846,7 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + move16(); ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx ); } @@ -3017,6 +3166,7 @@ ivas_error ivas_jbm_dec_render_fx( Word16 crendInPlaceRotation = FALSE; move16(); *nSamplesRendered = s_min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + move16(); test(); test(); @@ -3041,11 +3191,11 @@ ivas_error ivas_jbm_dec_render_fx( gd_bits = find_guarded_bits_fx( subframe_len ); exp = 13; move16(); - IF( ( error = getAudioConfigNumChannels( st_ivas->intern_config, &nchan_in ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->intern_config, &nchan_in ) ), IVAS_ERR_OK ) ) { return error; } - IF( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) ) { return error; } @@ -3061,8 +3211,9 @@ ivas_error ivas_jbm_dec_render_fx( scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); } } - IF( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs ) ), + IVAS_ERR_OK ) ) { return error; } @@ -3099,7 +3250,7 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { - IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, *nSamplesRendered ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, *nSamplesRendered ) ), IVAS_ERR_OK ) ) { return error; } @@ -3128,23 +3279,7 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { -#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED - Word16 num_subframes = (Word16) ( ( *nSamplesRendered * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) / output_Fs ); - FOR( Word16 subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++ ) - { - Word16 idx = subframe_idx; - Word16 pos_q = Q25; - - IF( st_ivas->hCombinedOrientationData->listenerPos != NULL ) - { - st_ivas->hCombinedOrientationData->listenerPos[idx].x_fx = (Word32) float_to_fix( st_ivas->hCombinedOrientationData->listenerPos[idx].x, pos_q ); - st_ivas->hCombinedOrientationData->listenerPos[idx].y_fx = (Word32) float_to_fix( st_ivas->hCombinedOrientationData->listenerPos[idx].y, pos_q ); - st_ivas->hCombinedOrientationData->listenerPos[idx].z_fx = (Word32) float_to_fix( st_ivas->hCombinedOrientationData->listenerPos[idx].z, pos_q ); - st_ivas->hCombinedOrientationData->listenerPos[idx].q_fact = Q25; - } - } -#endif - IF( ( error = ivas_td_binaural_renderer_fx( st_ivas, p_output_fx, *nSamplesRendered ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_td_binaural_renderer_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) { return error; } @@ -3154,15 +3289,15 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { -#if 1 // ftf changes Word16 channel_active_fx[MAX_OUTPUT_CHANNELS]; Word16 nchan_out_cov; Word16 nchan_out_cldfb = 0; + move16(); set16_fx( channel_active_fx, 0, MAX_CICP_CHANNELS ); Word16 nchan_transport_tmp = st_ivas->nchan_transport; output_Fs = st_ivas->hDecoderConfig->output_Fs; - Word16 nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); test(); test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) @@ -3195,7 +3330,7 @@ ivas_error ivas_jbm_dec_render_fx( } // ftf for ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx // ftf changes - IF( GT_16( st_ivas->hParamMC->max_band_decorr, 0 ) ) + IF( st_ivas->hParamMC->max_band_decorr > 0 ) { // ftf for param_mc_protoSignalComputation_fx FOR( Word16 x = 0; x < st_ivas->hParamMC->diff_proto_info->num_protos_diff; x++ ) @@ -3203,14 +3338,16 @@ ivas_error ivas_jbm_dec_render_fx( Word16 num_source_ch = st_ivas->hParamMC->diff_proto_info->num_source_chan_diff[x]; move16(); - floatToFixed_arrL( st_ivas->hParamMC->diff_proto_info->proto_fac[x], st_ivas->hParamMC->diff_proto_info->proto_fac_fx[x], Q30, num_source_ch ); + Scale_sig32( st_ivas->hParamMC->diff_proto_info->proto_fac_fx[x], num_source_ch, Q30 - st_ivas->hParamMC->diff_proto_info->Q_proto_fac ); + st_ivas->hParamMC->diff_proto_info->Q_proto_fac = Q30; + move16(); } // ftf for ivas_dirac_dec_decorr_process_fx Word16 tmp; tmp = L_norm_arr( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len ); scale_sig32( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_fx, st_ivas->hParamMC->h_freq_domain_decorr_ap_state->decorr_buffer_len, tmp ); - st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer += tmp; + st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer = add( st_ivas->hParamMC->h_freq_domain_decorr_ap_state->q_decorr_buffer, tmp ); } /* CLDFB synthesis */ FOR( Word16 ch = 0; ch < nchan_out_cldfb; ch++ ) @@ -3229,22 +3366,24 @@ ivas_error ivas_jbm_dec_render_fx( tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], nchan_transport * nchan_out_cov ); scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[param_band_idx], nchan_transport * nchan_out_cov, tempp ); st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[param_band_idx], tempp ); + move16(); IF( st_ivas->hParamMC->band_grouping[param_band_idx] < st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) { tempp = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], nchan_transport * nchan_out_cov ); scale_sig32( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[param_band_idx], nchan_transport * nchan_out_cov, tempp ); st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx] = sub( st_ivas->hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[param_band_idx], tempp ); + move16(); } } -#endif ivas_param_mc_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, channel_active_fx ); FOR( int ch = 0; ch < nchan_out_cldfb; ch++ ) { IF( 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(); } } IF( EQ_16( st_ivas->hParamMC->slots_rendered, st_ivas->hParamMC->num_slots ) ) @@ -3336,17 +3475,20 @@ ivas_error ivas_jbm_dec_render_fx( st_ivas->hTcBuffer->n_samples_available = sub( st_ivas->hTcBuffer->n_samples_available, *nSamplesRendered ); st_ivas->hTcBuffer->n_samples_rendered = add( st_ivas->hTcBuffer->n_samples_rendered, *nSamplesRendered ); + move16(); + move16(); /* update global combined orientation start index */ ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered ); - IF( GT_16( st_ivas->hTcBuffer->n_samples_discard, 0 ) ) + IF( st_ivas->hTcBuffer->n_samples_discard > 0 ) { FOR( n = 0; n < s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); n++ ) { p_output_fx[n] += st_ivas->hTcBuffer->n_samples_discard; } *nSamplesRendered = sub( (Word16) *nSamplesRendered, st_ivas->hTcBuffer->n_samples_discard ); + move16(); st_ivas->hTcBuffer->n_samples_discard = 0; move16(); } @@ -3869,6 +4011,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Word32 *p_output_fx[MAX_CICP_CHANNELS]; Word16 nchan_in, nchan_out; const Word16 output_q_factor = Q11; + move16(); IF( !st_ivas->hDecoderConfig->Opt_tsm ) { return IVAS_ERR_OK; @@ -3884,6 +4027,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( *nSamplesRendered = imult1616( n_slots_still_available, tc_granularity_new ); n_samples_to_render = *nSamplesRendered; move16(); + move16(); n_samples_still_available = sub( n_samples_still_available, n_samples_to_render ); assert( n_samples_still_available < tc_granularity_new ); @@ -3930,6 +4074,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( p_output_fx[ch_idx] = output_fx[ch_idx]; } + test(); IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { IF( EQ_16( ism_mode_old, ISM_MODE_DISC ) ) @@ -3937,7 +4082,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( /* Binaural rendering */ IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) ) { - IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, hTcBuffer->n_samples_granularity ) ), IVAS_ERR_OK ) ) { return error; } @@ -3953,8 +4098,9 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); - IF( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, - NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, + NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ), + IVAS_ERR_OK ) ) { return error; } @@ -3969,22 +4115,24 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { IF( EQ_16( mc_mode_old, MC_MODE_MCT ) ) { + test(); IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { /*TODO :To be tested : no stream entering*/ st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; - IF( ( error = getAudioConfigNumChannels( intern_config_old, &nchan_in ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = getAudioConfigNumChannels( intern_config_old, &nchan_in ) ), IVAS_ERR_OK ) ) { return error; } - IF( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) ) { return error; } *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); - IF( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ), + IVAS_ERR_OK ) ) { return error; } @@ -3993,7 +4141,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( } ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { - IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, hTcBuffer->n_samples_granularity ) ), IVAS_ERR_OK ) ) { return error; } @@ -4018,9 +4166,9 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Copy32( st_ivas->hMasaIsmData->delayBuffer_fx[ch_idx], tc_local_fx[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size ); /*Q11*/ } - IF( GT_16( st_ivas->nchan_ism, 0 ) ) + IF( st_ivas->nchan_ism > 0 ) { - IF( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, output_q_factor, hTcBuffer->n_samples_granularity ) ), IVAS_ERR_OK ) ) { return error; } @@ -4033,6 +4181,8 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( } st_ivas->hTcBuffer->slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, 1 ); st_ivas->hTcBuffer->subframes_rendered = add( st_ivas->hTcBuffer->subframes_rendered, 1 ); + move16(); + move16(); } } } @@ -4043,8 +4193,8 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Word16 last_dirac_md_idx; UWord16 nSamplesAvailableNext; - last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1]; - last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1]; + last_spar_md_idx = st_ivas->hSpar->render_to_md_map[sub( st_ivas->hSpar->slots_rendered, 1 )]; + last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[sub( st_ivas->hSpatParamRendCom->slots_rendered, 1 )]; move16(); move16(); /* copy from ISM delay buffer to the correct place in tcs */ @@ -4081,7 +4231,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( set16_fx( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available ); /* render the last subframe */ - IF( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output_fx, output_q_factor, L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_osba_dirac_td_binaural_jbm_fx( st_ivas, (UWord16) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output_fx, output_q_factor, L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES ) ), IVAS_ERR_OK ) ) { return error; } @@ -4106,6 +4256,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { #ifndef DISABLE_LIMITER Word16 ch_idx, exp = 11; + move16(); FOR( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) { p_output_fx[ch_idx] = output_fx[ch_idx]; @@ -4367,12 +4518,14 @@ ivas_error ivas_jbm_dec_set_discard_samples( /* render first frame with front zero padding and discarding those samples */ nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; - nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] ); - IF( GT_16( nSlotsInFirstSubframe, 0 ) ) + nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[sub( st_ivas->hTcBuffer->nb_subframes, 1 )] ); + IF( nSlotsInFirstSubframe > 0 ) { - st_ivas->hTcBuffer->n_samples_discard = sub( nMaxSlotsPerSubframe, nSlotsInFirstSubframe ) * st_ivas->hTcBuffer->n_samples_granularity; + st_ivas->hTcBuffer->n_samples_discard = imult1616( sub( nMaxSlotsPerSubframe, nSlotsInFirstSubframe ), st_ivas->hTcBuffer->n_samples_granularity ); /* set last subframes number to max to ensure correct continuation */ - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe; + st_ivas->hTcBuffer->subframe_nbslots[sub( st_ivas->hTcBuffer->nb_subframes, 1 )] = nMaxSlotsPerSubframe; + move16(); + move16(); } return IVAS_ERR_OK; @@ -4445,7 +4598,7 @@ void ivas_jbm_dec_get_adapted_linear_interpolator_fx( Word16 jbm_segment_len, idx; Word16 dec_fx; - jbm_segment_len = ( default_interp_length >> 1 ); + jbm_segment_len = shr( default_interp_length, 1 ); dec_fx = 32767 / default_interp_length; move16(); @@ -4494,7 +4647,7 @@ void ivas_jbm_dec_get_adapted_subframes( nSlotsInFirstSubframe = ( sub( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, subframe_nbslots[*nb_subframes - 1] ) ); *nb_subframes = 0; move16(); - IF( GT_16( nSlotsInFirstSubframe, 0 ) ) + IF( nSlotsInFirstSubframe > 0 ) { *nb_subframes = 1; move16(); @@ -4502,18 +4655,19 @@ void ivas_jbm_dec_get_adapted_subframes( } *nb_subframes = add( *nb_subframes, ( nCldfbSlotsLocal + PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - 1 ) / PARAM_MC_MAX_NSLOTS_IN_SUBFRAME ); + move16(); nSlotsInLastSubframe = nCldfbSlotsLocal % PARAM_MC_MAX_NSLOTS_IN_SUBFRAME; set16_fx( subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set16_fx( subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, *nb_subframes ); - IF( GT_16( nSlotsInFirstSubframe, 0 ) ) + IF( nSlotsInFirstSubframe > 0 ) { subframe_nbslots[0] = nSlotsInFirstSubframe; move16(); } - IF( GT_16( nSlotsInLastSubframe, 0 ) ) + IF( nSlotsInLastSubframe > 0 ) { subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe; move16(); @@ -4579,12 +4733,12 @@ void ivas_jbm_dec_get_md_map( Word16 jbm_segment_len, map_idx, src_idx, src_idx_map; Word32 dec_fx, src_idx_fx; - jbm_segment_len = ( default_len >> 1 ); + jbm_segment_len = shr( default_len, 1 ); // dec = 1.0f / default_len; FOR( ( map_idx = len - 1, src_idx = default_len - 1 ); map_idx >= jbm_segment_len; ( map_idx--, src_idx-- ) ) { - src_idx_map = max( 0, src_idx / subframe_len ); + src_idx_map = s_max( 0, src_idx / subframe_len ); map[map_idx] = ( offset + src_idx_map ) % buf_len; } @@ -4596,7 +4750,7 @@ void ivas_jbm_dec_get_md_map( src_idx_fx = L_shl( src_idx + 1, 16 ) - dec_fx; FOR( ; map_idx >= 0; map_idx-- ) { - src_idx = max( 0, round_fx( src_idx_fx ) / subframe_len ); + src_idx = s_max( 0, round_fx( src_idx_fx ) / subframe_len ); map[map_idx] = ( offset + src_idx ) % buf_len; src_idx_fx -= dec_fx; } @@ -4684,7 +4838,7 @@ void ivas_jbm_dec_get_md_map_even_spacing( ELSE { /* uneven subframes */ - decimal_fx = ( L_shl( len, 16 ) / subframe_len ) - L_shl( sf_length, 16 ); + decimal_fx = L_sub( ( L_shl( len, 16 ) / subframe_len ), L_shl( sf_length, 16 ) ); decimal_sum_fx = decimal_fx; eps_fx = 65; FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) @@ -4693,15 +4847,17 @@ void ivas_jbm_dec_get_md_map_even_spacing( subframe_map_length[sf_idx] = sf_length + increment; IF( increment > 0 ) { - decimal_sum_fx -= ( 1 << 16 ); + decimal_sum_fx = L_sub( decimal_sum_fx, ( 1 << 16 ) ); } - decimal_sum_fx += decimal_fx; + decimal_sum_fx = L_add( decimal_sum_fx, decimal_fx ); } } /* map slots to subframes */ sf_idx = 0; subframes_written = 0; + move16(); + move16(); FOR( map_idx = 0; map_idx < len; map_idx++ ) { map[map_idx] = ( offset + sf_idx ) % buf_len; @@ -4974,6 +5130,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( test(); test(); test(); + test(); IF( st_ivas->sba_dirac_stereo_flag ) { num_tc = CPE_CHANNELS; @@ -4989,7 +5146,6 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( test(); test(); test(); - test(); IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) && EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_16( st_ivas->nchan_transport, 2 ) && LT_32( st_ivas->hDecoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && GT_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) { num_tc = CPE_CHANNELS; @@ -5027,6 +5183,7 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( num_tc = CPE_CHANNELS; move16(); } + test(); IF( ( st_ivas->sba_planar && GE_16( num_tc, 3 ) ) || EQ_16( num_tc, 3 ) ) { num_tc = add( num_tc, 1 ); @@ -5079,9 +5236,15 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( { num_tc = add( num_tc, 1 ); } + test(); + test(); + test(); + test(); + test(); + test(); IF( st_ivas->hOutSetup.separateChannelEnabled && ( EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || - EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && GT_16( st_ivas->hOutSetup.num_lfe, 0 ) ) ) ) + EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) ) ) { /* LFE is synthesized in TD with the TCs*/ num_tc = add( num_tc, 1 ); @@ -5124,6 +5287,7 @@ static void ivas_jbm_dec_copy_tc( hTcBuffer->n_samples_buffered = add( add( n_samples_still_available, nSamplesForRendering ), hTcBuffer->n_samples_discard ); hTcBuffer->n_samples_available = i_mult( hTcBuffer->n_samples_granularity, idiv1616( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_granularity ) ); *nSamplesResidual = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_available ); + move16(); n_ch_full_copy = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); n_ch_res_copy = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); @@ -5137,7 +5301,7 @@ static void ivas_jbm_dec_copy_tc( } } - IF( GT_16( n_ch_res_copy, 0 ) ) + IF( n_ch_res_copy > 0 ) { FOR( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) { @@ -5274,6 +5438,7 @@ Word16 ivas_jbm_dec_get_render_granularity( { render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS ); } + move16(); return render_granularity; } @@ -5501,7 +5666,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( nsamp_to_allocate = mult0( hTcBuffer->nchan_buffer_full, n_samp_full ); nsamp_to_allocate = add( nsamp_to_allocate, mult0( nchan_residual, n_samp_residual ) ); - IF( EQ_16( nsamp_to_allocate, 0 ) ) + IF( nsamp_to_allocate == 0 ) { hTcBuffer->tc_buffer_fx = NULL; @@ -5514,9 +5679,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( { IF( st_ivas->hDecoderConfig->Opt_tsm ) { -#if 1 /* TODO: remove float memory allocation */ - hTcBuffer->tc_buff_len = nsamp_to_allocate; -#endif IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); @@ -5696,10 +5858,13 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( { hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = hTcBuffer->n_samples_flushed / n_samples_granularity; hTcBuffer->n_samples_flushed = 0; + move16(); + move16(); } ELSE { hTcBuffer->subframe_nbslots[hTcBuffer->subframes_rendered - 1] = nMaxSlotsPerSubframeNew; + move16(); } } @@ -5736,7 +5901,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate = add( nsamp_to_allocate, nchan_residual * n_samp_residual ); - IF( EQ_16( nsamp_to_allocate, 0 ) ) + IF( nsamp_to_allocate == 0 ) { hTcBuffer->tc_buffer_fx = NULL; FOR( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) @@ -5772,11 +5937,6 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( hTcBuffer->tc_fx[ch_idx] = NULL; } - /* TODO: remove the floating point dependency */ - // IF( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) - { - // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory FOR JBM TC Buffer\n" ) ); - } hTcBuffer->tc_buff_len = nsamp_to_allocate; // set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); @@ -5792,17 +5952,10 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( // hTcBuffer->tc[ch_idx] = &hTcBuffer->tc_buffer[offset]; offset = add( offset, n_samp_residual ); } - FOR( ; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) - { - // hTcBuffer->tc[ch_idx] = NULL; - } } ELSE { hTcBuffer->tc_buffer_fx = NULL; - - /* TODO: remove floating point dependency */ - // hTcBuffer->tc_buffer = NULL; } } @@ -5861,6 +6014,7 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( Word16 ch_idx, slot_size, slots_to_render, first_sf, last_sf, tmp, e; 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 */ tmp = BASOP_Util_Divide1616_Scale( nSamplesAsked, slot_size, &e ); @@ -5870,8 +6024,12 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( *nSamplesRendered = (UWord16) L_mult0( slots_to_render, slot_size ); first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; + move16(); + move16(); + move16(); + move16(); - WHILE( GT_16( slots_to_render, 0 ) ) + WHILE( slots_to_render > 0 ) { slots_to_render = sub( slots_to_render, st_ivas->hTcBuffer->subframe_nbslots[last_sf] ); last_sf = add( last_sf, 1 ); @@ -5883,6 +6041,7 @@ static void ivas_jbm_dec_tc_buffer_playout_fx( } st_ivas->hTcBuffer->subframes_rendered = last_sf; + move16(); return; } @@ -5966,16 +6125,17 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( /* nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; */ tmp = extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) ); tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &exp ); - nMaxSlotsPerSubframe = shr( tmp, ( 15 - exp ) ); + nMaxSlotsPerSubframe = shr( tmp, sub( 15, exp ) ); /* nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; */ tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &exp ); - nSlotsAvailable = shr( tmp, ( 15 - exp ) ); + nSlotsAvailable = shr( tmp, sub( 15, exp ) ); st_ivas->hTcBuffer->num_slots = nSlotsAvailable; move16(); /* st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; */ st_ivas->hTcBuffer->n_samples_available = i_mult( nSlotsAvailable, st_ivas->hTcBuffer->n_samples_granularity ); + move16(); nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] ); st_ivas->hTcBuffer->nb_subframes = 0; move16(); @@ -5983,17 +6143,18 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( IF( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->nb_subframes = 1; - nSlotsAvailable -= nSlotsInFirstSubframe; + move16(); + nSlotsAvailable = sub( nSlotsAvailable, nSlotsInFirstSubframe ); } - s1 = norm_s( nSlotsAvailable ) - 1; + s1 = sub( norm_s( nSlotsAvailable ), 1 ); s2 = norm_s( nMaxSlotsPerSubframe ); tmp1 = shl( nSlotsAvailable, s1 ); tmp2 = shl( nMaxSlotsPerSubframe, s2 ); tmp = div_s( tmp1, tmp2 ); - st_ivas->hTcBuffer->nb_subframes = add( st_ivas->hTcBuffer->nb_subframes, ceil_fx16( tmp, ( 15 - ( s2 - s1 ) ) ) ); + st_ivas->hTcBuffer->nb_subframes = add( st_ivas->hTcBuffer->nb_subframes, ceil_fx16( tmp, sub( 15, sub( s2, s1 ) ) ) ); nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe; set16_fx( st_ivas->hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); @@ -6276,13 +6437,7 @@ void ivas_jbm_dec_copy_tc_no_tsm( { for ( ch_idx = 0; ch_idx < n_ch_full_copy; ch_idx++ ) { -#ifdef IVAS_FLOAT_FIXED - Word32 tc_fx[960]; - floatToFixed_arrL( tc[ch_idx], tc_fx, Q11, hTcBuffer->n_samples_buffered ); - Copy32( tc_fx, st_ivas->hTcBuffer->tc_fx[ch_idx], hTcBuffer->n_samples_buffered ); -#else mvr2r( tc[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], hTcBuffer->n_samples_buffered ); -#endif } } ch_idx = 0; @@ -6347,10 +6502,13 @@ void ivas_jbm_dec_copy_tc_no_tsm_fx( hTcBuffer = st_ivas->hTcBuffer; hTcBuffer->n_samples_buffered = output_frame; hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; + move16(); + move16(); n_ch_full_copy = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); n_ch_cldfb = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); Q_tc = 11; /*tc buffer is at Q11*/ + move16(); /* copy full tcs*/ IF( st_ivas->hDecoderConfig->Opt_tsm ) { @@ -6363,7 +6521,7 @@ void ivas_jbm_dec_copy_tc_no_tsm_fx( move16(); /* CLDFB ana for ParamMC/ParamISM */ - IF( GT_16( n_ch_cldfb, 0 ) ) + IF( n_ch_cldfb > 0 ) { Word32 *cldfb_real_buffer_fx; Word32 *cldfb_imag_buffer_fx; @@ -6384,8 +6542,8 @@ void ivas_jbm_dec_copy_tc_no_tsm_fx( num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; ivas_ism_param_dec_tc_gain_ajust_fx( st_ivas, output_frame, output_frame / 2, tc_fx, &Q_tc ); - Scale_sig32( tc_fx[0], output_frame, 11 - Q_tc ); /*keepeing tc_fx at Q11*/ - Scale_sig32( tc_fx[1], output_frame, 11 - Q_tc ); /*keepeing tc_fx at Q11*/ + Scale_sig32( tc_fx[0], output_frame, sub( Q11, Q_tc ) ); /*keepeing tc_fx at Q11*/ + Scale_sig32( tc_fx[1], output_frame, sub( Q11, Q_tc ) ); /*keepeing tc_fx at Q11*/ } ELSE IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) MC_FORMAT ) ) { @@ -6500,17 +6658,22 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( hJbmMetadata->directionIndexBuffer[dir][write_idx][band] = extOutMeta->directionIndex[dir][sf][band]; move16(); hJbmMetadata->directToTotalRatioBuffer[dir][write_idx][band] = extOutMeta->directToTotalRatio[dir][sf][band]; + move16(); hJbmMetadata->spreadCoherenceBuffer[dir][write_idx][band] = extOutMeta->spreadCoherence[dir][sf][band]; + move16(); } } FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { hJbmMetadata->diffuseToTotalRatioBuffer[write_idx][band] = extOutMeta->diffuseToTotalRatio[sf][band]; + move16(); hJbmMetadata->surroundCoherenceBuffer[write_idx][band] = extOutMeta->surroundCoherence[sf][band]; + move16(); } hJbmMetadata->numberOfDirections[write_idx] = extOutMeta->descriptiveMeta.numberOfDirections; + move16(); } return; @@ -6677,19 +6840,24 @@ void ivas_jbm_masa_sf_to_sf_map( extOutMeta->directionIndex[dir][sf_idx][band] = hJbmMetadata->directionIndexBuffer[dir][sf_read_idx][band]; move16(); extOutMeta->directToTotalRatio[dir][sf_idx][band] = hJbmMetadata->directToTotalRatioBuffer[dir][sf_read_idx][band]; + move16(); extOutMeta->spreadCoherence[dir][sf_idx][band] = hJbmMetadata->spreadCoherenceBuffer[dir][sf_read_idx][band]; + move16(); } } FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { extOutMeta->diffuseToTotalRatio[sf_idx][band] = hJbmMetadata->diffuseToTotalRatioBuffer[sf_read_idx][band]; + move16(); extOutMeta->surroundCoherence[sf_idx][band] = hJbmMetadata->surroundCoherenceBuffer[sf_read_idx][band]; + move16(); } } /* Determine the number of directions for the frame to be written */ numberOfDirections = 0; + move16(); FOR( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { sf_read_idx = sf_to_sf_map[sf_idx]; @@ -6698,11 +6866,13 @@ void ivas_jbm_masa_sf_to_sf_map( IF( hJbmMetadata->numberOfDirections[sf_read_idx] == 1 ) { numberOfDirections = 1; + move16(); BREAK; } } extOutMeta->descriptiveMeta.numberOfDirections = numberOfDirections; + move16(); return; } diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 78aa9867bd6e2a2ce5200ce43373c70c391be0cc..ded33dcec8a7984a67ce4e0ed3e3736384c36fa4 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -3129,6 +3129,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( { /* regularization factor is bitrate-dependent */ st_ivas->hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); + move16(); } test(); @@ -3148,25 +3149,16 @@ ivas_error ivas_masa_dec_reconfigure_fx( /*-----------------------------------------------------------------* * CLDFB instances *-----------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED - IF( ( error = ivas_cldfb_dec_reconfig( st_ivas, st_ivas->nchan_transport, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) - { - return error; - } -#else -#if 1 - // Float to fix conversions for ivas_cldfb_dec_reconfig_fx 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 ); + Word16 Q_tmp = getScaleFactor16( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 16 ); + Scale_sig( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 16, Q_tmp - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q ); + st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_tmp; } -#endif if ( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, st_ivas->nchan_transport, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) ) { return error; } -#endif } /*-----------------------------------------------------------------* @@ -3204,7 +3196,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( TC_BUFFER_MODE buffer_mode_new; Word16 n_samples_granularity; - n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); move16(); buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); @@ -3231,7 +3223,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { - n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ + n_samples_granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); /* Use the same granularity as tdrend */ IF( GT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) { if ( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) ) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index c57261bbf57ad5e2186ae3fdb08beba2418a6187..7a49db66745c9d7028995c4c120ec8dbfaf4524e 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -254,10 +254,6 @@ ivas_error ivas_param_mc_dec_open_fx( { 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; -#endif st_ivas->hIntSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx; st_ivas->hIntSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx; } @@ -269,9 +265,6 @@ ivas_error ivas_param_mc_dec_open_fx( } } -#if 0 /*TODO: To be removed later*/ - hParamMC->ls_conv_dmx_matrix = NULL; -#endif hParamMC->ls_conv_dmx_matrix_fx = NULL; test(); @@ -403,12 +396,6 @@ ivas_error ivas_param_mc_dec_open_fx( 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 ) - { - 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" ) ); @@ -1066,7 +1053,7 @@ static void ivas_param_mc_get_param_band_mapping( } } norm_fac_fx = div_s( 1, source_band_cnt_total ); /*Q15*/ - for ( source_band_idx = 0; source_band_idx < source_band_in_target_band_cnt; source_band_idx++ ) + 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(); @@ -1458,16 +1445,6 @@ ivas_error ivas_param_mc_dec_reconfig_fx( /* deallocate diffuse prototype info */ IF( hParamMC->diff_proto_info ) { -#if 1 /*To be removed later*/ - FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - free( hParamMC->diff_proto_info->proto_fac[i] ); - hParamMC->diff_proto_info->proto_fac[i] = NULL; - } - - free( hParamMC->diff_proto_info->proto_fac ); - hParamMC->diff_proto_info->proto_fac = NULL; -#endif FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) { free( hParamMC->diff_proto_info->source_chan_idx[i] ); @@ -1583,14 +1560,14 @@ ivas_error ivas_param_mc_dec_reconfig_fx( FOR( source_param_idx = 0; source_param_idx < parameter_band_mapping.n_source_bands[new_param_band_idx]; source_param_idx++ ) { /* Cx */ - v_multc_fixed_16( cov_state_old.cx_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx], tmp_buf_fx, nchan_transport_old * nchan_transport_old ); - v_add_fixed_me( tmp_buf_fx, cov_state_old.cx_old_e[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], hParamMC->h_output_synthesis_cov_state.cx_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cx_old_e[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cx_old_fx[new_param_band_idx], &hParamMC->h_output_synthesis_cov_state.cx_old_e[new_param_band_idx], nchan_transport_old * nchan_transport_old, 0 ); + v_multc_fixed_16( cov_state_old.cx_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx], tmp_buf_fx, imult1616( nchan_transport_old, nchan_transport_old ) ); + v_add_fixed_me( tmp_buf_fx, cov_state_old.cx_old_e[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], hParamMC->h_output_synthesis_cov_state.cx_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cx_old_e[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cx_old_fx[new_param_band_idx], &hParamMC->h_output_synthesis_cov_state.cx_old_e[new_param_band_idx], imult1616( nchan_transport_old, nchan_transport_old ), 0 ); /* Cy */ - v_multc_fixed_16( cov_state_old.cy_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx], tmp_buf_fx, nchan_out_cov * nchan_out_cov ); - v_add_fixed_me( tmp_buf_fx, cov_state_old.cy_old_e[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], hParamMC->h_output_synthesis_cov_state.cy_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cy_old_e[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cy_old_fx[new_param_band_idx], &hParamMC->h_output_synthesis_cov_state.cy_old_e[new_param_band_idx], nchan_out_cov * nchan_out_cov, 0 ); + v_multc_fixed_16( cov_state_old.cy_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx], tmp_buf_fx, imult1616( nchan_out_cov, nchan_out_cov ) ); + v_add_fixed_me( tmp_buf_fx, cov_state_old.cy_old_e[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], hParamMC->h_output_synthesis_cov_state.cy_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cy_old_e[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cy_old_fx[new_param_band_idx], &hParamMC->h_output_synthesis_cov_state.cy_old_e[new_param_band_idx], imult1616( nchan_out_cov, nchan_out_cov ), 0 ); /* mixing matrix*/ - v_multc_fixed_16( cov_state_old.mixing_matrix_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx], tmp_buf_fx, nchan_transport_old * nchan_out_cov ); - v_add_fx( tmp_buf_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[new_param_band_idx], nchan_transport_old * nchan_out_cov ); + v_multc_fixed_16( cov_state_old.mixing_matrix_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx], tmp_buf_fx, imult1616( nchan_transport_old, nchan_out_cov ) ); + v_add_fx( tmp_buf_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[new_param_band_idx], imult1616( nchan_transport_old, nchan_out_cov ) ); } } FOR( new_param_band_idx = 0; new_param_band_idx < max_param_band_residual; new_param_band_idx++ ) @@ -1598,8 +1575,8 @@ ivas_error ivas_param_mc_dec_reconfig_fx( FOR( source_param_idx = 0; source_param_idx < parameter_band_mapping.n_source_bands[new_param_band_idx]; source_param_idx++ ) { /* residual mixing matrix*/ - v_multc_fixed_16( cov_state_old.mixing_matrix_res_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx], tmp_buf_fx, nchan_out_cov * nchan_out_cov ); - v_add_fx( tmp_buf_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[new_param_band_idx], nchan_out_cov * nchan_out_cov ); + v_multc_fixed_16( cov_state_old.mixing_matrix_res_old_fx[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor_fx[new_param_band_idx][source_param_idx], tmp_buf_fx, imult1616( nchan_out_cov, nchan_out_cov ) ); + v_add_fx( tmp_buf_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[new_param_band_idx], imult1616( nchan_out_cov, nchan_out_cov ) ); } } } @@ -2288,16 +2265,6 @@ void ivas_param_mc_dec_close_fx( free( hParamMC->diff_proto_info->proto_fac_fx[i] ); hParamMC->diff_proto_info->proto_fac_fx[i] = NULL; } -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED /*TODO: To be removed later(Floating point memory dealloc)------------------------------- */ - FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - free( hParamMC->diff_proto_info->proto_fac[i] ); - hParamMC->diff_proto_info->proto_fac[i] = NULL; - } - - free( hParamMC->diff_proto_info->proto_fac ); - hParamMC->diff_proto_info->proto_fac = NULL; -#endif /***********************************ends here************************************************/ free( hParamMC->diff_proto_info->source_chan_idx ); hParamMC->diff_proto_info->source_chan_idx = NULL; @@ -3068,11 +3035,6 @@ void ivas_param_mc_dec_digest_tc_fx( move16(); // cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; move16(); - // IF (st_ivas->hDecoderConfig->Opt_tsm) - //{ - // cldfb_slots = MAX_JBM_CLDFB_TIMESLOTS; - // move16(); - // } /* slot loop for gathering the input data */ FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) @@ -3191,15 +3153,9 @@ void ivas_param_mc_dec_digest_tc_fx( } } - IF( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) + IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { - // streams not entering into this block - // ivas_param_mc_get_mono_stereo_mixing_matrices( hParamMC, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, nchan_transport, nchan_out_cov ); - } - ELSE - { - /* generate mixing matrices */ ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_fx, cx_e, 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_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov ); } @@ -3457,9 +3413,6 @@ void ivas_param_mc_dec_render_fx( /* 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 #ifdef MSAN_FIX FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) #else @@ -4238,9 +4191,6 @@ static void ivas_param_mc_dec_init( { set_zero( hParamMC->proto_frame_f, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands ); set_zero( hParamMC->proto_frame_dec_f, 2 * nchan_cov * hParamMC->num_freq_bands ); -#ifdef IVAS_FLOAT_FIXED - set32_fx( hParamMC->proto_frame_dec_f_fx, 0, 2 * nchan_cov * hParamMC->num_freq_bands ); -#endif } return; @@ -4918,47 +4868,6 @@ static void ivas_param_mc_get_mixing_matrices( } } -#ifdef IVAS_FLOAT_FIXED - Word16 matSize = MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS; - Word16 *icld_q_fx; - Word16 *icc_q_fx; - Word32 *Cx_state_fx; - Word16 Cx_state_e; - Word32 *Cproto_fx; - Word16 Cproto_e; - Word32 *Cy_state_fx; - Word16 Cy_state_e; - - icld_q_fx = (Word16 *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe * sizeof( Word16 ) ); - icc_q_fx = (Word16 *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe * sizeof( Word16 ) ); - - Cx_state_fx = (Word32 *) malloc( PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS * sizeof( Word32 ) ); - Cproto_fx = (Word32 *) malloc( MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS * sizeof( Word32 ) ); - Cy_state_fx = (Word32 *) malloc( MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS * sizeof( Word32 ) ); - - f2me_buf( Cx_state, Cx_state_fx, &Cx_state_e, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS ); - f2me_buf( Cproto, Cproto_fx, &Cproto_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); - - set32_fx( Cy_state_fx, 0, matSize ); - Cy_state_e = 0; - - ivas_param_mc_dequantize_cov_fx( hParamMC, - icld_q_fx + param_band_idx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe, - icc_q_fx + param_band_idx * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe, - param_band_idx, nY_cov, - synth_config, - nY_intern, - nX, Cx_state_fx, Cx_state_e, Cproto_fx, Cproto_e, Cy_state_fx, &Cy_state_e ); - - me2f_buf( Cy_state_fx, Cy_state_e, Cy_state, nY_intern * nY_intern ); - // dbgwrite2_txt(Cy_state_fx,nY_intern*nY_intern,"../cy_state_fx.txt"); - - free( icld_q_fx ); - free( icc_q_fx ); - free( Cx_state_fx ); - free( Cproto_fx ); - free( Cy_state_fx ); -#else ivas_param_mc_dequantize_cov( hParamMC, hParamMC->icld_q + param_band_idx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe, hParamMC->icc_q + param_band_idx * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe, @@ -4966,8 +4875,6 @@ static void ivas_param_mc_get_mixing_matrices( synth_config, nY_intern, nX, Cx_state, Cproto, Cy_state ); - // dbgwrite2_txt(Cy_state_fx,nY_intern*nY_intern,"../cy_state.txt"); -#endif /* Smoothing: Sum over two buffers */ if ( hParamMC->hMetadataPMC->bAttackPresent ) @@ -4990,24 +4897,7 @@ static void ivas_param_mc_get_mixing_matrices( /* remove LFE if necessary */ if ( remove_lfe ) { -#ifdef IVAS_FLOAT_FIXED - Word32 *Cy_full_fx = (Word32 *) malloc( MAX_CICP_CHANNELS * MAX_CICP_CHANNELS * sizeof( Word32 ) ); - Word16 Cy_full_e; - Word32 *Cy_fx = (Word32 *) malloc( MAX_CICP_CHANNELS * MAX_CICP_CHANNELS * sizeof( Word32 ) ); - Word16 Cy_e; - - f2me_buf( Cy_full, Cy_full_fx, &Cy_full_e, nY_cov * nY_cov ); - Cy_e = Cy_full_e; - - remove_lfe_from_cy_fx( nY_cov, lfe_indices, hSynthesisOutputSetup->num_lfe, Cy_full_fx, Cy_fx ); - - me2f_buf( Cy_fx, Cy_e, Cy, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); - - free( Cy_full_fx ); - free( Cy_fx ); -#else remove_lfe_from_cy( nY_cov, lfe_indices, hSynthesisOutputSetup->num_lfe, Cy_full, Cy ); -#endif } else { @@ -5015,45 +4905,7 @@ static void ivas_param_mc_get_mixing_matrices( } matrix_product( proto_matrix_ptr, nY_band, nX, 0, Cx, nX, nX, 0, mat_mult_buffer1 ); - -#ifdef IVAS_FLOAT_FIXED - Word32 mat_mult_buffer1_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - Word32 proto_matrix_ptr_fx[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; - Word32 Cproto_diag_fx[MAX_CICP_CHANNELS]; - Word16 mat_mult_buffer1_e, proto_matrix_ptr_e, Cproto_diag_e; - - Word16 guard_bits = find_guarded_bits_fx( nY_band + 1 ); - - f2me_buf( mat_mult_buffer1, mat_mult_buffer1_fx, &mat_mult_buffer1_e, nY_band * nX ); - f2me_buf( proto_matrix_ptr, proto_matrix_ptr_fx, &proto_matrix_ptr_e, nY_band * nX ); - - for ( i = 0; i < nY_band * nX; ++i ) - { - if ( mat_mult_buffer1_e > proto_matrix_ptr_e ) - { - proto_matrix_ptr_fx[i] = L_shr( proto_matrix_ptr_fx[i], guard_bits ); - } - else - { - mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], guard_bits ); - } - } - - if ( mat_mult_buffer1_e > proto_matrix_ptr_e ) - { - proto_matrix_ptr_e += guard_bits; - } - else - { - 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 ); - - me2f_buf( Cproto_diag_fx, Cproto_diag_e, Cproto_diag, nY_band ); -#else matrix_product_diag( mat_mult_buffer1, nY_band, nX, 0, proto_matrix_ptr, nY_band, nX, 1, Cproto_diag ); -#endif /* make sure we have no negative entries in Cproto_diag due to rounding errors */ for ( ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++ ) @@ -5116,20 +4968,7 @@ static void ivas_param_mc_get_mixing_matrices( Cy_diag[i] = sqrtf( Cy_diag[i] / ( Cproto_diag[i] + EPSILON ) ); } -#ifdef IVAS_FLOAT_FIXED - Word32 Cy_diag_fx[MAX_OUTPUT_CHANNELS]; - Word32 mixing_matrix_local_fx[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; - Word16 Cy_diag_e, mixing_matrix_local_e; - - f2me_buf( Cy_diag, Cy_diag_fx, &Cy_diag_e, nY_band ); - f2me_buf( proto_matrix_ptr, proto_matrix_ptr_fx, &proto_matrix_ptr_e, nY_band * nX ); - - 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 ); - - me2f_buf( mixing_matrix_local_fx, mixing_matrix_local_e, mixing_matrix_local, nY_band * nX ); -#else diag_matrix_product( Cy_diag, nY_band, proto_matrix_ptr, nY_band, nX, 0, mixing_matrix_local ); -#endif } if ( remove_lfe ) { @@ -5645,14 +5484,6 @@ static void ivas_param_mc_get_mono_stereo_mixing_matrices( int16_t nY_band; float proto_matrix[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; uint16_t i; -#ifdef IVAS_FLOAT_FIXED - Word32 Cy_diag_fx[MAX_OUTPUT_CHANNELS]; - Word32 proto_matrix_fx[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; - Word32 mixing_matrix_woLFE_fx[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; - Word32 mat_mult_buffer1_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - Word32 Cproto_diag_fx[MAX_CICP_CHANNELS]; - Word16 Cy_diag_e, proto_matrix_e, mixing_matrix_woLFE_e, mat_mult_buffer1_e, Cproto_diag_e; -#endif set_zero( Cproto, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); set_zero( mat_mult_buffer1, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); @@ -5723,41 +5554,7 @@ static void ivas_param_mc_get_mono_stereo_mixing_matrices( matrix_product( proto_matrix, nY_band, nX, 0, Cx, nX, nX, 0, mat_mult_buffer1 ); - -#ifdef IVAS_FLOAT_FIXED - Word16 guard_bits = find_guarded_bits_fx( nY_band + 1 ); - - f2me_buf( mat_mult_buffer1, mat_mult_buffer1_fx, &mat_mult_buffer1_e, nY_band * nX ); - f2me_buf( proto_matrix, proto_matrix_fx, &proto_matrix_e, nY_band * nX ); - - for ( i = 0; i < nY_band * nX; ++i ) - { - if ( mat_mult_buffer1_e > proto_matrix_e ) - { - proto_matrix_fx[i] = L_shr( proto_matrix_fx[i], guard_bits ); - } - else - { - mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], guard_bits ); - } - } - - if ( mat_mult_buffer1_e > proto_matrix_e ) - { - proto_matrix_e += guard_bits; - } - else - { - mat_mult_buffer1_e += guard_bits; - } - - matrix_product_diag_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, nY_band, nX, 0, proto_matrix_fx, proto_matrix_e, nY_band, nX, 1, Cproto_diag_fx, &Cproto_diag_e ); - - me2f_buf( Cproto_diag_fx, Cproto_diag_e, Cproto_diag, nY_band ); -#else matrix_product_diag( mat_mult_buffer1, nY_band, nX, 0, proto_matrix, nY_band, nX, 1, Cproto_diag ); -#endif - /* Computing the mixing matrices */ for ( i = 0; i < nY_band; i++ ) { @@ -5765,16 +5562,7 @@ static void ivas_param_mc_get_mono_stereo_mixing_matrices( Cy_diag[i] = sqrtf( Cy_diag[i] / ( Cproto_diag[i] + EPSILON ) ); } -#ifdef IVAS_FLOAT_FIXED - f2me_buf( Cy_diag, Cy_diag_fx, &Cy_diag_e, nY_band ); - f2me_buf( proto_matrix, proto_matrix_fx, &proto_matrix_e, nY_band * nX ); - - diag_matrix_product_fx( Cy_diag_fx, Cy_diag_e, nY_band, proto_matrix_fx, proto_matrix_e, nY_band, nX, 0, mixing_matrix_woLFE_fx, &mixing_matrix_woLFE_e ); - - me2f_buf( mixing_matrix_woLFE_fx, mixing_matrix_woLFE_e, mixing_matrix_woLFE, nY_band * nX ); -#else diag_matrix_product( Cy_diag, nY_band, proto_matrix, nY_band, nX, 0, mixing_matrix_woLFE ); -#endif mvr2r( mixing_matrix_woLFE, mixing_matrix[param_band_idx], nY_cov * nX ); if ( hParamMC->band_grouping[param_band_idx] < hParamMC->h_output_synthesis_params.max_band_decorr ) @@ -6474,7 +6262,6 @@ static void param_mc_set_num_synth_bands( * calculated the diffuse prototype information *-------------------------------------------------------------------------*/ -#define FLT_ENABLE 0 #ifdef IVAS_FLOAT_FIXED static ivas_error param_mc_get_diff_proto_info_fx( const Word32 *proto_mtx, /* i : protoype matrix for the synthesis */ @@ -6483,9 +6270,6 @@ static ivas_error param_mc_get_diff_proto_info_fx( PARAM_MC_DIFF_PROTO_INFO *p_diff_proto_info, /* o : generated diffuse prototype info */ Word16 Q_proto_mtx ) { -#if FLT_ENABLE - float proto_fac[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; -#endif Word32 proto_fac_fx[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; UWord16 cur_out_ch; UWord16 cur_diff_proto; @@ -6495,9 +6279,6 @@ static ivas_error param_mc_get_diff_proto_info_fx( /* 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 = (Word16 *) malloc( nchan_out_cov * sizeof( Word16 ) ) ) == NULL ) { @@ -6514,9 +6295,6 @@ 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(); @@ -6529,33 +6307,19 @@ static ivas_error param_mc_get_diff_proto_info_fx( FOR( cur_diff_proto = 0; cur_diff_proto < p_diff_proto_info->num_protos_diff; cur_diff_proto++ ) { -#if FLT_ENABLE - float diff = 0; - float *proto_fac_ptr = proto_fac + cur_diff_proto; - // 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++ ) { -#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_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; } /* we already have this prototype, save the index */ -#if FLT_ENABLE - if ( diff < 0.1f ) -#else IF( LT_64( W_mult0_32_32( diff_fx, 10 ), L_shl_sat( 1, Q_proto_mtx ) ) ) -#endif { found = 1; move16(); @@ -6568,31 +6332,24 @@ static ivas_error param_mc_get_diff_proto_info_fx( /* new distinct prototype, add it */ 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 Word16 cur_num_src_chan; cur_num_src_chan = 0; move16(); FOR( cur_transport_ch = 0; cur_transport_ch < nchan_transport; cur_transport_ch++ ) { - IF( GT_32( *proto_mtx_ptr, 0 /*EPSILON*/ ) ) + if ( GT_32( *proto_mtx_ptr, 0 /*EPSILON*/ ) ) { cur_num_src_chan = add( cur_num_src_chan, 1 ); } proto_mtx_ptr += nchan_out_cov; } - -#if FLT_ENABLE - mvr2r_inc( proto_mtx + cur_out_ch, nchan_out_cov, proto_fac + p_diff_proto_info->num_protos_diff, nchan_out_cov, nchan_transport ); -#else 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; + move16(); p_diff_proto_info->num_protos_diff = add( p_diff_proto_info->num_protos_diff, 1 ); + move16(); max_num_src_chan = s_max( max_num_src_chan, cur_num_src_chan ); } } @@ -6602,33 +6359,18 @@ 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" ) ); } -#if 1 /*To be removed later*/ - if ( ( p_diff_proto_info->proto_fac = (float **) malloc( p_diff_proto_info->num_protos_diff * 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 = (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++ ) { -#if FLT_ENABLE - float *proto_fac_ptr; -#endif Word32 *proto_fac_ptr; 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 ) - { - 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 ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); @@ -6644,6 +6386,7 @@ static ivas_error param_mc_get_diff_proto_info_fx( p_diff_proto_info->proto_fac_fx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = *proto_fac_ptr; 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 ); + move16(); } proto_fac_ptr += nchan_out_cov; } @@ -6651,7 +6394,6 @@ static ivas_error param_mc_get_diff_proto_info_fx( return IVAS_ERR_OK; } #endif -#undef FLT_ENABLE #ifndef IVAS_FLOAT_FIXED static ivas_error param_mc_get_diff_proto_info( @@ -6747,19 +6489,7 @@ static ivas_error param_mc_get_diff_proto_info( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } -#ifdef IVAS_FLOAT_FIXED - 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" ) ); - } -#endif -#ifdef IVAS_FLOAT_FIXED - 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" ) ); - } -#endif for ( cur_diff_proto = 0; cur_diff_proto < p_diff_proto_info->num_protos_diff; cur_diff_proto++ ) { float *proto_fac_ptr; @@ -6772,20 +6502,6 @@ static ivas_error param_mc_get_diff_proto_info( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } -#ifdef IVAS_FLOAT_FIXED - 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" ) ); - } -#endif // IVAS_FLOAT_FIXED - -#ifdef IVAS_FLOAT_FIXED - 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" ) ); - } -#endif - proto_fac_ptr = proto_fac + cur_diff_proto; for ( cur_transport_ch = 0; cur_transport_ch < nchan_transport; cur_transport_ch++ ) { diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index f750f3c9929057907b7f326a7bbc456ddfabf980..543f05ade9bc21907aa7aed264be726f8879305a 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1867,18 +1867,6 @@ 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 ) - st->hIGFDec->virtualSpec_float = &st->hIGFDec->virtualSpecBuf[0]; - st->hIGFDec->igfData.pSpecFlat_float = &st->hIGFDec->igfData.pSpecFlatBuf[0]; - 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] = (UWord8) st->hIGFDec->infoTCXNoise_evs[l]; - move16(); - } -#endif } IF( st->hHQ_core == NULL ) @@ -2262,12 +2250,6 @@ IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_bu { 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 diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index bc136eb1a8586a8be89073c19a800161ba8355da..ba2476750a941ca80fc434dc29eb0e90859f2cfe 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -547,7 +547,7 @@ ivas_error ivas_omasa_dec_config_fx( { return error; } -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED +#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED 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; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 7186d031a0c96af22b7d67fb857cef7304861ee1..e46846114ccba162e87dc9cd619e5974f684c136 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -3205,7 +3205,9 @@ void ivas_spar_dec_upmixer_sf_fx( { md_idx = hSpar->render_to_md_map[add( ts, slot_idx_start )]; move16(); - floatToFixed_arr( hSpar->hFbMixer->cldfb_cross_fade, hSpar->hFbMixer->cldfb_cross_fade_fx, Q15, CLDFB_NO_COL_MAX ); + Scale_sig( hSpar->hFbMixer->cldfb_cross_fade_fx, CLDFB_NO_COL_MAX, Q15 - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q ); + st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q15; + move16(); ivas_spar_get_parameters_fx( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat_fx ); test(); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 1542469a438d974e0aaa5f2707e4b607753d9898..437178df4fc7bd9645dbce0d4bfe49920d01f4b1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -821,9 +821,11 @@ typedef struct ivas_param_mc_diff_proto_info_structure int16_t *proto_index_diff; int16_t *num_source_chan_diff; int16_t **source_chan_idx; - float **proto_fac; #ifdef IVAS_FLOAT_FIXED Word32 **proto_fac_fx; + Word16 Q_proto_fac; +#else + float **proto_fac; #endif // IVAS_FLOAT_FIXED } PARAM_MC_DIFF_PROTO_INFO; diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 6ec395ccc3799bab7da70e3035c3f061c5d64699..c9543e648bc2cd154130deadbc58d3a50ac80adb 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -253,9 +253,6 @@ static ivas_error allocate_CoreCoder( } Init_post_filter_ivas( st->hPFstat ); -#ifdef IVAS_FLOAT_FIXED - Init_post_filter_fx( st->hPFstat ); -#endif // IVAS_FLOAT_FIXED st->psf_lp_noise = 0.0f; } @@ -338,11 +335,6 @@ static ivas_error allocate_CoreCoder_fx( Init_post_filter_fx( st->hPFstat ); st->psf_lp_noise_fx = 0; move16(); - -#ifndef IVAS_FLOAT_FIXED - Init_post_filter_ivas( st->hPFstat ); - st->psf_lp_noise = 0.0f; -#endif } IF( st->hMusicPF == NULL ) @@ -353,10 +345,6 @@ static ivas_error allocate_CoreCoder_fx( } music_postfilt_init( st->hMusicPF ); - -#if 1 // TODO: To be removed later - music_postfilt_init_flt( st->hMusicPF ); -#endif } IF( st->hBPF == NULL ) diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index f6d7f1b0a2c8d1650ad011fc526d174337d19afc..ce7a654bd69592f4e46d05d44a2a5f44cef9ff97 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -493,13 +493,8 @@ ivas_error IVAS_DEC_FeedRefRotData( /*! r: error code */ ivas_error IVAS_DEC_FeedRefVectorData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ -#ifndef IVAS_FLOAT_FIXED - const IVAS_VECTOR3 listenerPos, /* i : Listener position */ - const IVAS_VECTOR3 refPos /* i : Reference position */ -#else IVAS_VECTOR3 listenerPos, /* i : Listener position */ IVAS_VECTOR3 refPos /* i : Reference position */ -#endif ); /*! r: error code */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7e740a311eefc6aa04853edf336ecadef069406c..df292ea6da7af15b5c1364a6b07615cb35bc2a41 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -78,7 +78,7 @@ struct IVAS_DEC Word16 tsm_scale; /* scale for TSM operation */ Word16 tsm_max_scaling; float tsm_quality; - float *apaExecBuffer; /* Buffer for APA scaling */ + float *apaExecBuffer; /* Buffer for APA scaling */ // dependency for apa_exec function #ifdef IVAS_FLOAT_FIXED Word32 *apaExecBuffer_fx; /* Buffer for APA scaling */ @@ -863,37 +863,10 @@ ivas_error IVAS_DEC_FeedFrame_Serial( * In IVAS mode, initialization is done in ivas_dec(). */ IF( EQ_16( hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) { -#ifdef IVAS_FLOAT_FIXED - - DECODER_CONFIG_HANDLE hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; - AUDIO_CONFIG output_config = hDecoderConfig->output_config; - test(); - IF( ( EQ_16( hIvasDec->st_ivas->ivas_format, MC_FORMAT ) ) && ( EQ_16( hIvasDec->st_ivas->mc_mode, MC_MODE_PARAMMC ) ) ) - { - IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - /*float2fix block: to be removed*/ - floatToFixed_arrL( hIvasDec->st_ivas->hLsSetupCustom->ls_azimuth, hIvasDec->st_ivas->hLsSetupCustom->ls_azimuth_fx, Q22, hIvasDec->st_ivas->hLsSetupCustom->num_spk ); - floatToFixed_arrL( hIvasDec->st_ivas->hLsSetupCustom->ls_elevation, hIvasDec->st_ivas->hLsSetupCustom->ls_elevation_fx, Q22, hIvasDec->st_ivas->hLsSetupCustom->num_spk ); - } - } - - IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - FOR( Word16 ind = 0; ind < MAX_OUTPUT_CHANNELS; ind++ ) - { - hIvasDec->st_ivas->hLsSetupCustom->ls_azimuth_fx[ind] = (Word32) ( hIvasDec->st_ivas->hLsSetupCustom->ls_azimuth[ind] * ( 1 << 22 ) ); - hIvasDec->st_ivas->hLsSetupCustom->ls_elevation_fx[ind] = (Word32) ( hIvasDec->st_ivas->hLsSetupCustom->ls_elevation[ind] * ( 1 << 22 ) ); - } - } IF( NE_32( ( error = ivas_init_decoder_fx( hIvasDec->st_ivas ) ), IVAS_ERR_OK ) ) -#else - IF( ( error = ivas_init_decoder( hIvasDec->st_ivas ) ) != IVAS_ERR_OK ) -#endif { return error; } -#ifdef IVAS_FLOAT_FIXED Word32 ivas_total_brate = hIvasDec->st_ivas->hDecoderConfig->ivas_total_brate; move32(); test(); @@ -902,18 +875,13 @@ ivas_error IVAS_DEC_FeedFrame_Serial( PARAM_MC_DEC_HANDLE hParamMC; hParamMC = hIvasDec->st_ivas->hParamMC; MC_LS_SETUP mc_ls_setup; - Word16 i; mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup_fx( hIvasDec->st_ivas->transport_config ); hIvasDec->st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); IF( hParamMC ) { - FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - fixedToFloat_arrL( hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); - } + hParamMC->diff_proto_info->Q_proto_fac = Q26; } } -#endif test(); IF( hIvasDec->hVoIP != NULL && hIvasDec->hVoIP->hCurrentDataUnit != NULL ) @@ -1250,82 +1218,27 @@ static ivas_error IVAS_DEC_Setup( IF( st_ivas->bfi == 0 ) { - -#if 1 // flt to fix - Word16 n_samples_granularity; - - n_samples_granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); - DECODER_CONFIG_HANDLE hDecoderConfig = NULL; Word32 ivas_total_brate; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; Word16 num_src = 0; - Word16 i; - IF( EQ_16( is_DTXrate( ivas_total_brate ), 0 ) && ( !( EQ_16( st_ivas->ini_active_frame, 0 ) && NE_32( ivas_total_brate, FRAME_NO_DATA ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && EQ_16( st_ivas->nCPE, 1 ) ) ) && st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 1] && st_ivas->ivas_format == MASA_FORMAT && st_ivas->last_ivas_format == MASA_FORMAT && ( ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) || EQ_16( st_ivas->ini_active_frame, 0 ) ) ) - { - 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( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) - { - IF( LT_16( n_samples_granularity, st_ivas->hTcBuffer->n_samples_granularity ) ) - { - IF( st_ivas->hSbaIsmData ) - { - FOR( Word16 ch_idx = 0; ch_idx < st_ivas->hSbaIsmData->delayBuffer_nchan; ch_idx++ ) - { - // floatToFixed_arr32(st_ivas->hSbaIsmData->delayBuffer[ch_idx], st_ivas->hSbaIsmData->delayBuffer_fx[ch_idx], Q11, st_ivas->hSbaIsmData->delayBuffer_size); - } - } - Word16 n_tc; - IF( st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) - n_tc = st_ivas->nchan_ism; - ELSE - n_tc = st_ivas->hTcBuffer->nchan_transport_internal; - FOR( Word16 ch = 0; ch < n_tc; ch++ ) - { - // floatToFixed_arrL(st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k); - } - } - } - } - } - IF( EQ_16( is_DTXrate( ivas_total_brate ), 0 ) && ( !( EQ_16( st_ivas->ini_active_frame, 0 ) && NE_32( ivas_total_brate, FRAME_NO_DATA ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) && EQ_16( st_ivas->nCPE, 1 ) ) ) && st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 1] && st_ivas->ivas_format == MASA_FORMAT && st_ivas->last_ivas_format != MASA_FORMAT && ( ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) && EQ_16( st_ivas->ini_active_frame, 0 ) ) ) { - // Float to fix conversions for ivas_td_binaural_open_fx - IF( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - FOR( i = 0; i < 4; i++ ) - { - st_ivas->hRenderConfig->directivity_fx[i * 3] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 1] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 1], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 2], 15 ); - } - } - // Float to fix conversions for ivas_cldfb_dec_reconfig_fx 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 ); + Word16 Q_tmp = getScaleFactor16( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 16 ); + Scale_sig( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 16, Q_tmp - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q ); + st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_tmp; } } IF( EQ_16( is_DTXrate( ivas_total_brate ), 0 ) && st_ivas->ivas_format == MASA_ISM_FORMAT && GT_16( st_ivas->ini_frame, 0 ) && ( GT_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_32( ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) && EQ_16( st_ivas->ini_active_frame, 0 ) ) { - IF( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - FOR( i = 0; i < 4; i++ ) - { - st_ivas->hRenderConfig->directivity_fx[i * 3] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 1] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 1], 6 ); - st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 2], 15 ); - } - } - // Float to fix conversions for ivas_cldfb_dec_reconfig_fx 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 ); + Word16 Q_tmp = getScaleFactor16( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 16 ); + Scale_sig( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, 16, Q_tmp - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q ); + st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q_tmp; } } @@ -1337,41 +1250,15 @@ static ivas_error IVAS_DEC_Setup( { IF( st_ivas->hParamMC->diff_proto_info ) { - FOR( i = 0; i < st_ivas->hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - floatToFixed_arrL( st_ivas->hParamMC->diff_proto_info->proto_fac[i], st_ivas->hParamMC->diff_proto_info->proto_fac_fx[i], Q26, st_ivas->hParamMC->diff_proto_info->num_source_chan_diff[i] ); - } + st_ivas->hParamMC->diff_proto_info->Q_proto_fac = Q26; } } } } - - hDecoderConfig = st_ivas->hDecoderConfig; - AUDIO_CONFIG output_config = hDecoderConfig->output_config; - IF( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMMC ) ) - { - IF( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) - { - /*float2fix block: to be removed*/ - floatToFixed_arrL( st_ivas->hLsSetupCustom->ls_azimuth, st_ivas->hLsSetupCustom->ls_azimuth_fx, Q22, st_ivas->hLsSetupCustom->num_spk ); - floatToFixed_arrL( st_ivas->hLsSetupCustom->ls_elevation, st_ivas->hLsSetupCustom->ls_elevation_fx, Q22, st_ivas->hLsSetupCustom->num_spk ); - } - } - - IF( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) - { - FOR( Word16 ind = 0; ind < MAX_OUTPUT_CHANNELS; ind++ ) - { - st_ivas->hLsSetupCustom->ls_azimuth_fx[ind] = (Word32) ( st_ivas->hLsSetupCustom->ls_azimuth[ind] * ( 1 << 22 ) ); - st_ivas->hLsSetupCustom->ls_elevation_fx[ind] = (Word32) ( st_ivas->hLsSetupCustom->ls_elevation[ind] * ( 1 << 22 ) ); - } - } -#endif IF( NE_32( ( error = ivas_dec_setup( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) { return error; } -#if 1 // fix to float IF( ( st_ivas->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_PARAMMC ) ) { PARAM_MC_DEC_HANDLE hParamMC; @@ -1383,10 +1270,7 @@ static ivas_error IVAS_DEC_Setup( { IF( st_ivas->hParamMC->diff_proto_info ) { - FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - fixedToFloat_arrL( hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); - } + hParamMC->diff_proto_info->Q_proto_fac = Q26; } } } @@ -1442,18 +1326,13 @@ static ivas_error IVAS_DEC_Setup( { IF( st_ivas->hParamMC ) { - // fixedToFloat_arrL( st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix, 26, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_len ); IF( st_ivas->hParamMC->diff_proto_info ) { - FOR( i = 0; i < st_ivas->hParamMC->diff_proto_info->num_protos_diff; i++ ) - { - fixedToFloat_arrL( st_ivas->hParamMC->diff_proto_info->proto_fac_fx[i], st_ivas->hParamMC->diff_proto_info->proto_fac[i], 26, st_ivas->hParamMC->diff_proto_info->num_source_chan_diff[i] ); - } + st_ivas->hParamMC->diff_proto_info->Q_proto_fac = Q26; } } } } -#endif } *nTransportChannels = (UWord8) st_ivas->hTcBuffer->nchan_transport_jbm; @@ -1522,7 +1401,6 @@ static ivas_error IVAS_DEC_GetTcSamples( { FOR( n = 0; n < ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) { - set_zero( st_ivas->p_output_f[n], L_FRAME48k ); set32_fx( st_ivas->p_output_fx[n], 0, L_FRAME48k ); st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; } @@ -1607,14 +1485,6 @@ static ivas_error IVAS_DEC_GetTcSamples( fixedToFloat_arrL( pcmBuf_fx, pcmBuf, 11, (Word16) ( st_ivas->hTcBuffer->nchan_transport_jbm * st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ) ); } - FOR( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) - { - IF( st_ivas->p_output_f[n] != NULL ) - { - fixedToFloat_arrL( st_ivas->p_output_fx[n], st_ivas->p_output_f[n], 11, L_FRAME48k ); - } - } - IF( NE_16( st_ivas->hDecoderConfig->Opt_tsm, 1 ) ) { IF( st_ivas->ivas_format == ISM_FORMAT ) @@ -2238,13 +2108,8 @@ ivas_error IVAS_DEC_FeedRefRotData( ivas_error IVAS_DEC_FeedRefVectorData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ -#ifndef IVAS_FLOAT_FIXED - const IVAS_VECTOR3 listenerPos, /* i : Listener position */ - const IVAS_VECTOR3 refPos /* i : Reference position */ -#else IVAS_VECTOR3 listenerPos, /* i : Listener position */ IVAS_VECTOR3 refPos /* i : Reference position */ -#endif ) { ivas_orient_trk_state_t *pOtr; @@ -2262,29 +2127,10 @@ ivas_error IVAS_DEC_FeedRefVectorData( hIvasDec->updateOrientation = true; move16(); -#ifdef IVAS_FLOAT_FIXED - listenerPos.q_fact = Q27; - refPos.q_fact = Q27; - move16(); - move16(); - listenerPos.x_fx = float_to_fix( listenerPos.x, listenerPos.q_fact ); - listenerPos.y_fx = float_to_fix( listenerPos.y, listenerPos.q_fact ); - listenerPos.z_fx = float_to_fix( listenerPos.z, listenerPos.q_fact ); - refPos.x_fx = float_to_fix( refPos.x, refPos.q_fact ); - refPos.y_fx = float_to_fix( refPos.y, refPos.q_fact ); - refPos.z_fx = float_to_fix( refPos.z, refPos.q_fact ); ivas_error error_fx = ivas_orient_trk_SetReferenceVector_fx( pOtr, listenerPos, refPos ); - pOtr->refRot.w = me2f( pOtr->refRot.w_fx, 31 - pOtr->refRot.q_fact ); - pOtr->refRot.x = me2f( pOtr->refRot.x_fx, 31 - pOtr->refRot.q_fact ); - pOtr->refRot.y = me2f( pOtr->refRot.y_fx, 31 - pOtr->refRot.q_fact ); - pOtr->refRot.z = me2f( pOtr->refRot.z_fx, 31 - pOtr->refRot.q_fact ); return error_fx; -#else - return ivas_orient_trk_SetReferenceVector( pOtr, listenerPos, refPos ); -#endif } - /*---------------------------------------------------------------------* * IVAS_DEC_FeedExternalOrientationData( ) * @@ -2314,29 +2160,11 @@ ivas_error IVAS_DEC_FeedExternalOrientationData( { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - -#ifdef IVAS_FLOAT_FIXED - IVAS_QUATERNION orientation_fx = { 0 }; - orientation_fx.q_fact = Q29; + // IVAS_QUATERNION orientation_fx = { 0 }; + orientation.q_fact = Q29; move16(); - orientation_fx.w_fx = float_to_fix( orientation.w, orientation_fx.q_fact ); - orientation_fx.x_fx = float_to_fix( orientation.x, orientation_fx.q_fact ); - orientation_fx.y_fx = float_to_fix( orientation.y, orientation_fx.q_fact ); - orientation_fx.z_fx = float_to_fix( orientation.z, orientation_fx.q_fact ); /* Move external orientation data to the decoder handle (invert orientations) */ - QuaternionInverse_fx( orientation_fx, &hExternalOrientationData->Quaternions[subframe_idx] ); - hExternalOrientationData->Quaternions[subframe_idx].w = me2f( hExternalOrientationData->Quaternions[subframe_idx].w_fx, - 31 - hExternalOrientationData->Quaternions[subframe_idx].q_fact ); - hExternalOrientationData->Quaternions[subframe_idx].x = me2f( hExternalOrientationData->Quaternions[subframe_idx].x_fx, - 31 - hExternalOrientationData->Quaternions[subframe_idx].q_fact ); - hExternalOrientationData->Quaternions[subframe_idx].y = me2f( hExternalOrientationData->Quaternions[subframe_idx].y_fx, - 31 - hExternalOrientationData->Quaternions[subframe_idx].q_fact ); - hExternalOrientationData->Quaternions[subframe_idx].z = me2f( hExternalOrientationData->Quaternions[subframe_idx].z_fx, - 31 - hExternalOrientationData->Quaternions[subframe_idx].q_fact ); -#else - /* Move external orientation data to the decoder handle (invert orientations) */ - QuaternionInverse( orientation, &hExternalOrientationData->Quaternions[subframe_idx] ); -#endif + QuaternionInverse_fx( orientation, &hExternalOrientationData->Quaternions[subframe_idx] ); hExternalOrientationData->enableHeadRotation[subframe_idx] = enableHeadRotation; hExternalOrientationData->enableExternalOrientation[subframe_idx] = enableExternalOrientation; @@ -2388,15 +2216,15 @@ ivas_error IVAS_DEC_FeedCustomLsData( hLsSetupCustom->num_spk = hLsCustomData.num_spk; move16(); - mvr2r( hLsCustomData.azimuth, hLsSetupCustom->ls_azimuth, hLsCustomData.num_spk ); - mvr2r( hLsCustomData.elevation, hLsSetupCustom->ls_elevation, hLsCustomData.num_spk ); + Copy32( hLsCustomData.azimuth_fx, hLsSetupCustom->ls_azimuth_fx, hLsCustomData.num_spk ); + Copy32( hLsCustomData.elevation_fx, hLsSetupCustom->ls_elevation_fx, hLsCustomData.num_spk ); /* Set planar flag */ is_planar = 1; move16(); FOR( i = 0; i < hLsCustomData.num_spk; i++ ) { - IF( is_planar && hLsSetupCustom->ls_elevation[i] != 0.0f ) + IF( is_planar && hLsSetupCustom->ls_elevation_fx[i] != 0 ) { is_planar = 0; move16(); @@ -2542,9 +2370,6 @@ static ivas_error copyRendererConfigStruct( move32(); move32(); move32(); -#if 1 // To be removed - mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS ); -#endif return IVAS_ERR_OK; } @@ -2580,19 +2405,10 @@ ivas_error IVAS_DEC_GetDefaultRenderConfig( RENDER_CONFIG_DATA RCin; RENDER_CONFIG_HANDLE hRCin = &RCin; ivas_error error; -#ifdef IVAS_FLOAT_FIXED IF( NE_32( ( error = ivas_render_config_init_from_rom_fx( &hRCin ) ), IVAS_ERR_OK ) ) { return error; } -#endif - - /*FLOAT CODE*/ - IF( NE_32( ( error = ivas_render_config_init_from_rom( &hRCin ) ), IVAS_ERR_OK ) ) - { - return error; - } - /*--------- */ return copyRendererConfigStruct( hRCin, hRCout ); } @@ -2647,9 +2463,6 @@ ivas_error IVAS_DEC_FeedRenderConfig( Copy32( renderConfig.roomAcoustics.pAcoustic_dsr_fx, hRenderConfig->roomAcoustics.pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); Copy( renderConfig.directivity_fx, hRenderConfig->directivity_fx, 3 * MAX_NUM_OBJECTS ); -#if 1 // To be removed - mvr2r( renderConfig.directivity, hRenderConfig->directivity, 3 * MAX_NUM_OBJECTS ); -#endif return IVAS_ERR_OK; } @@ -3991,14 +3804,12 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); -#ifdef IVAS_FLOAT_FIXED IF( ( hIvasDec->apaExecBuffer_fx = malloc( sizeof( Word32 ) * imult1616( apa_buffer_size, (Word16) nTransportChannels ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } set_zero_fx( hIvasDec->apaExecBuffer_fx, imult1616( apa_buffer_size, (Word16) nTransportChannels ) ); -#endif } } ELSE @@ -4018,14 +3829,12 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( } set_zero( hIvasDec->apaExecBuffer, apa_buffer_size * nTransportChannels ); -#ifdef IVAS_FLOAT_FIXED free( hIvasDec->apaExecBuffer_fx ); IF( ( hIvasDec->apaExecBuffer_fx = malloc( sizeof( Word32 ) * imult1616( apa_buffer_size, (Word16) nTransportChannels ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } set_zero_fx( hIvasDec->apaExecBuffer_fx, imult1616( apa_buffer_size, (Word16) nTransportChannels ) ); -#endif } /* realloc apa_exe_buffer */ } diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 1f7907ae84b77cc6d3a6fe1c8fb5cf420b89d7b7..c50055f33110dd7c3d9b399f9f121183ac1a7ec5 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -68,7 +68,7 @@ typedef struct _IVAS_ENC_DTX_CONFIG { bool enabled; bool variable_SID_rate; - Word16 SID_interval; + int16_t SID_interval; } IVAS_ENC_DTX_CONFIG; typedef enum _IVAS_ENC_SBA_ORDER @@ -207,8 +207,8 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( ivas_error IVAS_ENC_ConfigureForAmbisonics_fx( IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const Word32 inputFs, /* i : input sampling frequency */ - const Word32 bitrate, /* i : requested bitrate of the output bitstream */ + const int32_t inputFs, /* i : input sampling frequency */ + const int32_t bitrate, /* i : requested bitrate of the output bitstream */ const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index d248df0d2116586d13242f0d2b6ad0b32a7d3274..8e1a0ea4201189f2b685de33791df7cd8876e6bb 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -1534,14 +1534,14 @@ static void ivas_dirac_dec_binaural_internal_fx( { hDiracDecBin->hDiffuseDist = &diffuseDistData; ivas_spar_param_to_masa_param_mapping_fx( st_ivas, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_cldfb, subframe ); -#ifndef INTER_FLT_2_FIX - floatToFixed_arr( st_ivas->hSpar->hFbMixer->cldfb_cross_fade, st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, Q15, CLDFB_NO_COL_MAX ); + Scale_sig( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, CLDFB_NO_COL_MAX, Q15 - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q ); + st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q15; + move16(); FOR( int idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { Scale_sig32( st_ivas->hSpar->hFbMixer->pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[idx], IVAS_MAX_NUM_FB_BANDS, Q31 - Q22 ); } -#endif ivas_sba_prototype_renderer_fx( st_ivas, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_cldfb, subframe ); FOR( int idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -1657,7 +1657,6 @@ static void ivas_dirac_dec_binaural_internal_fx( ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_fx, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); -#if 1 q_inp = Q6; move16(); FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) @@ -1665,7 +1664,6 @@ static void ivas_dirac_dec_binaural_internal_fx( st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; move16(); } -#endif q_mat = hDiracDecBin->q_processMtx; move16(); diff --git a/lib_rend/ivas_dirac_rend.c b/lib_rend/ivas_dirac_rend.c index a96e1cf5f9fefbe24ca6b48bc0b147722fef7559..bd89b50bde3508f179bec91f6128d2884cc5a88a 100644 --- a/lib_rend/ivas_dirac_rend.c +++ b/lib_rend/ivas_dirac_rend.c @@ -451,8 +451,11 @@ ivas_error ivas_spat_hSpatParamRendCom_config_fx( } ELSE { - Word16 num_slots_in_subfr, tmp = 1; + Word16 num_slots_in_subfr, tmp; + tmp = 1; + move16(); num_slots_in_subfr = dec_param_estim_flag ? CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES : 1; + move16(); hSpatParamRendCom->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_DIRAC_PARAM_DEC_SFR; move16(); hSpatParamRendCom->dirac_bs_md_write_idx = DELAY_DIRAC_PARAM_DEC_SFR; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 78ee3d424d5081124f52cf4a45546e0e25a8924c..206700c49f1d385778cbccf1c15d48be88f25ff1 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -2549,11 +2549,11 @@ void ivas_render_config_close( ivas_error ivas_render_config_init_from_rom_fx( RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ ); -#endif - +#else ivas_error ivas_render_config_init_from_rom( RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ ); +#endif /*----------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index c7161061b9496018382d84ff361dec075a1e6173..0f7db93391797eb8de1cde0b5af12aa6a607841d 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -161,26 +161,25 @@ ivas_error ivas_render_config_init_from_rom_fx( Copy32( ivas_reverb_default_RT60_fx, ( *hRenderConfig )->roomAcoustics.pAcoustic_rt60_fx, IVAS_REVERB_DEFAULT_N_BANDS ); Copy32( ivas_reverb_default_DSR_fx, ( *hRenderConfig )->roomAcoustics.pAcoustic_dsr_fx, IVAS_REVERB_DEFAULT_N_BANDS ); - /*Q6*/ FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) { - ( *hRenderConfig )->directivity_fx[i_mult( i, 3 )] = 23040; /* Front cone */ + ( *hRenderConfig )->directivity_fx[i_mult( i, 3 )] = 23040; /* Front cone */ /*Q6*/ move16(); - ( *hRenderConfig )->directivity_fx[add( i_mult( i, 3 ), 1 )] = 23040; /* Back cone */ + ( *hRenderConfig )->directivity_fx[add( i_mult( i, 3 ), 1 )] = 23040; /* Back cone */ /*Q6*/ move16(); - ( *hRenderConfig )->directivity_fx[add( i_mult( i, 3 ), 2 )] = 64; /* Back attenuation */ + ( *hRenderConfig )->directivity_fx[add( i_mult( i, 3 ), 2 )] = 32767 /*1.0f in Q15*/; /* Back attenuation */ move16(); } return IVAS_ERR_OK; } -#endif - +#else ivas_error ivas_render_config_init_from_rom( RENDER_CONFIG_HANDLE *hRenderConfig /* i/o: Renderer config handle */ ) { int16_t i; + if ( hRenderConfig == NULL || *hRenderConfig == NULL ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Unexpected null pointer while attempting to fill renderer configuration from ROM" ); @@ -207,3 +206,4 @@ ivas_error ivas_render_config_init_from_rom( return IVAS_ERR_OK; } +#endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 869fd98bd13b768813871890d665c38634b3b5ce..d5d23e49c19a93e00a16a96ae7f6f431d7b9cd2b 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -2350,8 +2350,6 @@ typedef struct ivas_LS_setup_custom { Word16 is_planar_setup; /* flag to indicate if setup is planar or not */ Word16 num_spk; /* number of custom loudspeakers */ - float ls_azimuth[MAX_OUTPUT_CHANNELS]; /* custom loudspeaker azimuths */ - float ls_elevation[MAX_OUTPUT_CHANNELS]; /* custom loudspeaker elevations */ Word32 ls_azimuth_fx[MAX_OUTPUT_CHANNELS]; /* custom loudspeaker azimuths */ Word32 ls_elevation_fx[MAX_OUTPUT_CHANNELS]; /* custom loudspeaker elevations */ Word16 num_lfe; /* number of LFE channels */ diff --git a/lib_rend/ivas_vbap.c b/lib_rend/ivas_vbap.c index c6524aeed35ec344c1a99dc53fc6df24e28ce31b..ec9a7f45077dbad2a580bd711b29b38d9627efea 100644 --- a/lib_rend/ivas_vbap.c +++ b/lib_rend/ivas_vbap.c @@ -1565,9 +1565,9 @@ static void determine_virtual_speaker_node_division_gains_fx( } ELSE { - Word32 tmp32 = L_deposit_h( virtual_node_division_gains_fx[ch] ); // q is 15-final_exp// ldep -> 31-final_exp (q) - tmp_1 = L_add( BASOP_Util_Log2( tmp32 ), L_shl( ( 31 - ( 31 - final_exp ) ), 25 ) ); // Q25 - tmp_2 = Mpy_32_32( float_to_fix( 0.8f, Q25 ), tmp_1 ); + Word32 tmp32 = L_deposit_h( virtual_node_division_gains_fx[ch] ); // q is 15-final_exp// ldep -> 31-final_exp (q) + tmp_1 = L_add( BASOP_Util_Log2( tmp32 ), L_shl( ( sub( 31, sub( 31, final_exp ) ) ), 25 ) ); // Q25 + tmp_2 = Mpy_32_32( 26843546 /*0.8f in Q25*/, tmp_1 ); tmp_3 = BASOP_util_Pow2( tmp_2, Q31 - Q19, &res_exp ); exp_virtual_node_division_gains[ch] = res_exp; move16(); diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index e0bc60311cc89460f7eceb792915c4f69eec5a05..55efe1826f6f52c896b0586e6d4a853c65b10b4c 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -318,8 +318,9 @@ typedef struct bool metadataHasBeenFed; #ifdef IVAS_FLOAT_FIXED Word32 *bufferData_fx; -#endif // IVAS_FLOAT_FIXED +#else float *bufferData; +#endif // IVAS_FLOAT_FIXED MASA_EXT_REND_HANDLE hMasaExtRend; MASA_PREREND_HANDLE hMasaPrerend; } input_masa; @@ -405,7 +406,7 @@ static ivas_error allocateInputBaseBufferData_fx( return IVAS_ERR_OK; } -#endif +#else static ivas_error allocateInputBaseBufferData( float **data, const int16_t data_size ) @@ -418,6 +419,7 @@ static ivas_error allocateInputBaseBufferData( return IVAS_ERR_OK; } +#endif #ifdef IVAS_FLOAT_FIXED static void freeInputBaseBufferData_fx( Word32 **data ) @@ -430,7 +432,7 @@ static void freeInputBaseBufferData_fx( return; } -#endif +#else static void freeInputBaseBufferData( float **data ) { @@ -442,6 +444,7 @@ static void freeInputBaseBufferData( return; } +#endif #ifdef IVAS_FLOAT_FIXED static ivas_error allocateMcLfeDelayBuffer_fx( Word32 **lfeDelayBuffer, @@ -1161,18 +1164,8 @@ static LSSETUP_CUSTOM_STRUCT defaultCustomLs( ls.num_spk = 1; move16(); move16(); - -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - set_zero( ls.ls_azimuth, MAX_OUTPUT_CHANNELS ); -#endif - - set32_fx( ls.ls_azimuth_fx, 0, MAX_OUTPUT_CHANNELS ); - -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - set_zero( ls.ls_elevation, MAX_OUTPUT_CHANNELS ); -#endif - - set32_fx( ls.ls_elevation_fx, 0, MAX_OUTPUT_CHANNELS ); + set_val_Word32( ls.ls_azimuth_fx, 0, MAX_OUTPUT_CHANNELS ); + set_val_Word32( ls.ls_elevation_fx, 0, MAX_OUTPUT_CHANNELS ); ls.num_lfe = 0; move16(); set16_fx( ls.lfe_idx, 0, MAX_OUTPUT_CHANNELS ); @@ -5278,15 +5271,9 @@ static ivas_error setRendInputActiveMasa( { return error; } -#if 1 /*To be removed later:(contains malloc for inputMasa->bufferData)*/ - IF( NE_32( ( error = allocateInputBaseBufferData( &inputMasa->bufferData, MAX_BUFFER_LENGTH ) ), IVAS_ERR_OK ) ) - { - return error; - } -#endif initRendInputBase_fx( &inputMasa->base, inConfig, id, rendCtx, inputMasa->bufferData_fx, MAX_BUFFER_LENGTH ); - IF( NE_32( ( error = getAudioConfigNumChannels( inConfig, &numInChannels ) ), IVAS_ERR_OK ) ) + IF( ( error = getAudioConfigNumChannels( inConfig, &numInChannels ) ) != IVAS_ERR_OK ) { return error; } @@ -5305,24 +5292,21 @@ static ivas_error setRendInputActiveMasa( temp = 2; } move16(); - IF( NE_32( ( error = masaPrerendOpen_fx( &inputMasa->hMasaPrerend, temp, *( inputMasa->base.ctx.pOutSampleRate ) ) ), IVAS_ERR_OK ) ) + IF( ( error = masaPrerendOpen_fx( &inputMasa->hMasaPrerend, temp, *( inputMasa->base.ctx.pOutSampleRate ) ) ) != IVAS_ERR_OK ) { return error; } } ELSE { - IF( NE_32( ( error = initMasaExtRenderer( inputMasa, outConfig ) ), IVAS_ERR_OK ) ) + IF( ( error = initMasaExtRenderer( inputMasa, outConfig ) ) != IVAS_ERR_OK ) { return error; } inputMasa->metadataHasBeenFed = false; + move16(); } -#if 1 /*TODO: To be removed later(fixed to float)*/ - inputMasa->base.inputBuffer.data = inputMasa->bufferData; - fixedToFloat_arrL( inputMasa->base.inputBuffer.data_fx, inputMasa->base.inputBuffer.data, 0, MAX_BUFFER_LENGTH ); /*fixed to float only for set zero(that's why q0)*/ -#endif return IVAS_ERR_OK; } #endif // IVAS_FLOAT_FIXED @@ -5335,7 +5319,7 @@ static void clearInputMasa( rendCtx = inputMasa->base.ctx; - freeInputBaseBufferData( &inputMasa->bufferData ); + freeInputBaseBufferData_fx( &inputMasa->bufferData_fx ); masaPrerendClose_fx( &inputMasa->hMasaPrerend ); @@ -5506,7 +5490,7 @@ ivas_error IVAS_REND_Open( initRendInputBase_fx( &hIvasRend->inputsMasa[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); hIvasRend->inputsMasa[i].metadataHasBeenFed = false; - hIvasRend->inputsMasa[i].bufferData = NULL; + hIvasRend->inputsMasa[i].bufferData_fx = NULL; hIvasRend->inputsMasa[i].hMasaPrerend = NULL; hIvasRend->inputsMasa[i].hMasaExtRend = NULL; move16(); @@ -5669,9 +5653,8 @@ static LSSETUP_CUSTOM_STRUCT makeCustomLsSetup( customLs.ls_azimuth_fx[i] = (Word32) ( rendCustomLsLayout.azimuth[i] * ONE_IN_Q22 ); customLs.ls_elevation_fx[i] = (Word32) ( rendCustomLsLayout.elevation[i] * ONE_IN_Q22 ); } - mvr2r( rendCustomLsLayout.azimuth, customLs.ls_azimuth, rendCustomLsLayout.num_spk ); - mvr2r( rendCustomLsLayout.elevation, customLs.ls_elevation, rendCustomLsLayout.num_spk ); - + Copy32( rendCustomLsLayout.azimuth_fx, customLs.ls_azimuth_fx, rendCustomLsLayout.num_spk ); + Copy32( rendCustomLsLayout.elevation_fx, customLs.ls_elevation_fx, rendCustomLsLayout.num_spk ); customLs.is_planar_setup = 1; move16(); FOR( i = 0; i < rendCustomLsLayout.num_spk; ++i ) @@ -7305,7 +7288,7 @@ ivas_error IVAS_REND_FeedInputAudio_fx( /* Validate function arguments */ test(); - IF( hIvasRend == NULL || inputAudio.data == NULL ) + IF( hIvasRend == NULL || inputAudio.data_fx == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -7362,7 +7345,7 @@ ivas_error IVAS_REND_FeedInputAudio_fx( return IVAS_ERR_OK; } -#endif +#else /*-------------------------------------------------------------------* * IVAS_REND_FeedInputAudio() * @@ -7439,7 +7422,7 @@ ivas_error IVAS_REND_FeedInputAudio( return IVAS_ERR_OK; } - +#endif /*-------------------------------------------------------------------* * IVAS_REND_FeedInputObjectMetadata() @@ -7537,8 +7520,8 @@ ivas_error IVAS_REND_FeedInputObjectMetadataToOMasa( } /* Set position to OMasa struct */ - hIvasRend->inputsIsm->hOMasa->ism_azimuth_fx[inputIndex] = floatToFixed( objectPosition.azimuth, Q22 ); - hIvasRend->inputsIsm->hOMasa->ism_elevation_fx[inputIndex] = floatToFixed( objectPosition.elevation, Q22 ); + hIvasRend->inputsIsm->hOMasa->ism_azimuth_fx[inputIndex] = objectPosition.azimuth_fx; + hIvasRend->inputsIsm->hOMasa->ism_elevation_fx[inputIndex] = objectPosition.elevation_fx; return IVAS_ERR_OK; } @@ -13176,7 +13159,7 @@ static ivas_error getSamplesInternal( Word16 numOutChannels; /* Validate function arguments */ test(); - IF( hIvasRend == NULL || outAudio.data == NULL ) + IF( hIvasRend == NULL || outAudio.data_fx == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -13280,8 +13263,7 @@ static ivas_error getSamplesInternal( } /* Clear original output buffer */ - set_zero( outAudio.data, imult1616( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ) ); - set32_fx( outAudio.data_fx, 0, imult1616( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ) ); + set_val_Word32( outAudio.data_fx, 0, imult1616( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ) ); IF( NE_32( ( error = renderActiveInputsIsm( hIvasRend, outAudio ) ), IVAS_ERR_OK ) ) { diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index af6e6d766273deaa349dedbf10c974c55bda530a..12ec67502c80cf9273485733e71b9bf9766e8bbd 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -82,7 +82,6 @@ typedef struct IVAS_REND_AudioBufferConfig config; Word16 q_factor; Word16 *pq_fact; - float *data; Word32 *data_fx; Word16 Q_data; } IVAS_REND_AudioBuffer; @@ -93,7 +92,6 @@ typedef struct typedef struct { IVAS_REND_AudioBufferConfig config; - const float *data; const Word32 *data_fx; } IVAS_REND_ReadOnlyAudioBuffer; #else diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index e8bbe3653bccd9541d4ad1225e01e6934a6d0f2a..0fe9ed71dc88e2a8031d3f9e457d6be8cc4bd063 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -253,7 +253,7 @@ static void LoadBSplineBinaryITD( FILE *f_hrtf /* i : HR filter data file handle */ ) { - Word16 tmp; + Word16 tmp, i; fread( &modelITD->N, sizeof( Word16 ), 1, f_hrtf ); fread( &modelITD->elevDim2, sizeof( Word16 ), 1, f_hrtf ); fread( &modelITD->elevDim3, sizeof( Word16 ), 1, f_hrtf ); @@ -262,7 +262,7 @@ static void LoadBSplineBinaryITD( fread( elevKSeq_dyn_local, sizeof( float ), modelITD->elevDim3 - 2, f_hrtf ); modelITD->elevKSeq_dyn_fx = (Word32 *) malloc( sizeof( Word32 ) * ( modelITD->elevDim3 - 2 ) ); - FOR( int i = 0; i < modelITD->elevDim3 - 2; i++ ) + FOR( i = 0; i < modelITD->elevDim3 - 2; i++ ) { modelITD->elevKSeq_dyn_fx[i] = float_to_fix( elevKSeq_dyn_local[i], Q22 ); } @@ -274,7 +274,7 @@ static void LoadBSplineBinaryITD( float *azimKSeq_dyn_local = (float *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( float ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ fread( azimKSeq_dyn_local, sizeof( float ), ( modelITD->azimDim3 + 1 ) / 2 - 2, f_hrtf ); modelITD->azimKSeq_dyn_fx = (Word32 *) malloc( ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ) * sizeof( Word32 ) ); /* basis functions are flipped around 180 deg, number of basis functions above/below is (N+1)/2 */ - FOR( int i = 0; i < ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ); i++ ) + FOR( i = 0; i < ( ( modelITD->azimDim3 + 1 ) / 2 - 2 ); i++ ) { modelITD->azimKSeq_dyn_fx[i] = float_to_fix( azimKSeq_dyn_local[i], Q22 ); } @@ -298,7 +298,7 @@ static void LoadBSplineBinaryITD( fread( azimBsShape_dyn_local, sizeof( float ), tmp, f_hrtf ); modelITD->azimBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); - FOR( int i = 0; i < tmp; i++ ) + FOR( i = 0; i < tmp; i++ ) { modelITD->azimBsShape_dyn_fx[i] = float_to_fix( azimBsShape_dyn_local[i], Q30 ); } @@ -316,7 +316,7 @@ static void LoadBSplineBinaryITD( fread( elevBsShape_dyn_local, sizeof( float ), tmp, f_hrtf ); modelITD->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); - FOR( int i = 0; i < tmp; i++ ) + FOR( i = 0; i < tmp; i++ ) { modelITD->elevBsShape_dyn_fx[i] = float_to_fix( elevBsShape_dyn_local[i], Q30 ); } @@ -465,6 +465,222 @@ static void LoadBSplineBinaryITD( * Loads the B Spline HR filter model data from file. --------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static ivas_error LoadBSplineBinary( + IVAS_DEC_HRTF_HANDLE HrFiltSet_p, /* i/o: HR filter model parameter structure */ + FILE *f_hrtf /* i : HR filter data file handle */ +) +{ + ModelParams_t *model; + Word16 i, j, tmp; + + + float f_tmp_latency_s; + float f_tmp_lr_energy_and_iac_dyn[LR_IAC_LENGTH_NR_FC]; + + fread( &f_tmp_latency_s, sizeof( float ), 1, f_hrtf ); + HrFiltSet_p->latency_s_fx = float_to_fix( f_tmp_latency_s, Q31 ); + + model = &( HrFiltSet_p->ModelParams ); + + /* Set ROM flag for correct deallocation */ + model->modelROM = FALSE; + + fread( &model->UseItdModel, sizeof( Word16 ), 1, f_hrtf ); /* Indicates if ITD model is active */ + fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); + + SWITCH( tmp ) + { + case 16: + HrFiltSet_p->SampleRate = 16000; + if ( HrFiltSet_p->ModelParams.UseItdModel ) + { + HrFiltSet_p->ModelParamsITD.resamp_factor_fx = RESAMPLE_FACTOR_16_48_FX; + } + BREAK; + case 32: + HrFiltSet_p->SampleRate = 32000; + if ( HrFiltSet_p->ModelParams.UseItdModel ) + { + HrFiltSet_p->ModelParamsITD.resamp_factor_fx = RESAMPLE_FACTOR_32_48_FX; + } + BREAK; + case 48: + HrFiltSet_p->SampleRate = 48000; + if ( HrFiltSet_p->ModelParams.UseItdModel ) + { + HrFiltSet_p->ModelParamsITD.resamp_factor_fx = ONE_IN_Q14; + } + BREAK; + default: + return IVAS_ERROR( IVAS_ERR_INVALID_HRTF, "Error: HR filter file had an unsupported sampling rate (%d kHz)", tmp ); + } + move32(); + move16(); + + fread( &model->SplineDegree, sizeof( Word16 ), 1, f_hrtf ); + fread( &model->K, sizeof( Word16 ), 1, f_hrtf ); + + fread( &model->elevDim2, sizeof( Word16 ), 1, f_hrtf ); + fread( &model->elevDim3, sizeof( Word16 ), 1, f_hrtf ); + + float *elevKSeq_dyn_local = (float *) malloc( ( model->elevDim3 - 2 ) * sizeof( float ) ); + fread( elevKSeq_dyn_local, sizeof( float ), model->elevDim3 - 2, f_hrtf ); + model->elevKSeq_dyn_fx = (Word32 *) malloc( ( model->elevDim3 - 2 ) * sizeof( Word32 ) ); + FOR( i = 0; i < ( model->elevDim3 - 2 ); i++ ) + { + model->elevKSeq_dyn_fx[i] = float_to_fix( elevKSeq_dyn_local[i], Q22 ); + } + free( elevKSeq_dyn_local ); + + model->azimDim2_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); + model->azimDim3_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); + model->azim_start_idx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); + + float **azimKSeq_local = (float **) malloc( model->elevDim3 * sizeof( float * ) ); + model->azimKSeq_fx = (Word32 **) malloc( model->elevDim3 * sizeof( Word32 * ) ); + + FOR( i = 0; i < model->elevDim3; i++ ) + { + fread( &model->azimDim2_dyn[i], sizeof( Word16 ), 1, f_hrtf ); + fread( &model->azimDim3_dyn[i], sizeof( Word16 ), 1, f_hrtf ); + fread( &model->azim_start_idx_dyn[i], sizeof( Word16 ), 1, f_hrtf ); + + azimKSeq_local[i] = (float *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( float ) ); + fread( azimKSeq_local[i], sizeof( float ), ( model->azimDim3_dyn[i] + 1 ), f_hrtf ); + model->azimKSeq_fx[i] = (Word32 *) malloc( ( model->azimDim3_dyn[i] + 1 ) * sizeof( Word32 ) ); + FOR( j = 0; j < ( model->azimDim3_dyn[i] + 1 ); j++ ) + { + model->azimKSeq_fx[i][j] = float_to_fix( azimKSeq_local[i][j], Q22 ); + } + free( azimKSeq_local[i] ); + } + free( azimKSeq_local ); + + fread( &model->AlphaN, sizeof( Word16 ), 1, f_hrtf ); + + float *AlphaL_dyn_local = (float *) malloc( model->AlphaN * model->K * sizeof( float ) ); + fread( AlphaL_dyn_local, sizeof( float ), model->AlphaN * model->K, f_hrtf ); + + model->AlphaL_dyn_fx = (Word32 *) malloc( model->AlphaN * model->K * sizeof( Word32 ) ); + f2me_buf( AlphaL_dyn_local, model->AlphaL_dyn_fx, &model->AlphaL_dyn_e, model->AlphaN * model->K ); + free( AlphaL_dyn_local ); + + + float *AlphaR_dyn_local = (float *) malloc( model->AlphaN * model->K * sizeof( float ) ); + fread( AlphaR_dyn_local, sizeof( float ), model->AlphaN * model->K, f_hrtf ); + + model->AlphaR_dyn_fx = (Word32 *) malloc( model->AlphaN * model->K * sizeof( Word32 ) ); + f2me_buf( AlphaR_dyn_local, model->AlphaR_dyn_fx, &model->AlphaR_dyn_e, model->AlphaN * model->K ); + free( AlphaR_dyn_local ); + + /* azimuth */ + fread( &model->num_unique_azim_splines, sizeof( Word16 ), 1, f_hrtf ); + + model->azimBsShape_fx = (const Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) ); + model->azimBsShape_dyn_fx = (Word32 **) malloc( model->num_unique_azim_splines * sizeof( Word32 * ) ); + float **azimBsShape_dyn_local = (float **) malloc( model->num_unique_azim_splines * sizeof( float * ) ); + + model->azimSegSamples_dyn = (Word16 *) malloc( model->num_unique_azim_splines * sizeof( Word16 ) ); + FOR( i = 0; i < model->num_unique_azim_splines; i++ ) + { + fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); + + azimBsShape_dyn_local[i] = (float *) malloc( tmp * sizeof( float ) ); + fread( azimBsShape_dyn_local[i], sizeof( float ), tmp, f_hrtf ); + model->azimBsShape_dyn_fx[i] = (Word32 *) malloc( tmp * sizeof( Word32 ) ); + FOR( j = 0; j < tmp; j++ ) + { + model->azimBsShape_dyn_fx[i][j] = float_to_fix( azimBsShape_dyn_local[i][j], Q30 ); + } + free( azimBsShape_dyn_local[i] ); + + fread( &model->azimSegSamples_dyn[i], sizeof( Word16 ), 1, f_hrtf ); + } + free( azimBsShape_dyn_local ); + + model->azimShapeIdx_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); + fread( model->azimShapeIdx_dyn, sizeof( Word16 ), model->elevDim3, f_hrtf ); + model->azimShapeSampFactor_dyn = (Word16 *) malloc( model->elevDim3 * sizeof( Word16 ) ); + fread( model->azimShapeSampFactor_dyn, sizeof( Word16 ), model->elevDim3, f_hrtf ); + + /* elevation */ + fread( model->elevBsLen, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); + fread( model->elevBsStart, sizeof( Word16 ), HRTF_MODEL_BSPLINE_NUM_COEFFS, f_hrtf ); + fread( &tmp, sizeof( Word16 ), 1, f_hrtf ); + + float *elevBsShape_dyn_local = (float *) malloc( tmp * sizeof( float ) ); + fread( elevBsShape_dyn_local, sizeof( float ), tmp, f_hrtf ); + model->elevBsShape_dyn_fx = (Word32 *) malloc( tmp * sizeof( Word32 ) ); + FOR( i = 0; i < tmp; i++ ) + { + model->elevBsShape_dyn_fx[i] = float_to_fix( elevBsShape_dyn_local[i], Q30 ); + } + free( elevBsShape_dyn_local ); + + fread( &model->elevSegSamples, sizeof( Word16 ), 1, f_hrtf ); + + /* Set const pointers */ + model->AlphaL_fx = model->AlphaL_dyn_fx; + model->AlphaL_e = model->AlphaL_dyn_e; + move16(); + model->AlphaR_fx = model->AlphaR_dyn_fx; + model->AlphaR_e = model->AlphaR_dyn_e; + move16(); + model->EL_fx = model->EL_dyn_fx; + model->EL_e = model->EL_dyn_e; + move16(); + model->ER_fx = model->ER_dyn_fx; + model->ER_e = model->ER_dyn_e; + move16(); + + model->elevBsShape_fx = (const Word32 *) model->elevBsShape_dyn_fx; + model->elevKSeq_fx = (const Word32 *) model->elevKSeq_dyn_fx; + + model->azimDim2 = (const Word16 *) model->azimDim2_dyn; + model->azimDim3 = (const Word16 *) model->azimDim3_dyn; + model->azim_start_idx = (const Word16 *) model->azim_start_idx_dyn; + model->azimSegSamples = (const Word16 *) model->azimSegSamples_dyn; + model->azimShapeIdx = (const Word16 *) model->azimShapeIdx_dyn; + model->azimShapeSampFactor = (const Word16 *) model->azimShapeSampFactor_dyn; + + FOR( i = 0; i < model->num_unique_azim_splines; i++ ) + { + model->azimBsShape_fx[i] = (const Word32 *) model->azimBsShape_dyn_fx[i]; + } + + HRTF_model_precalc( model ); + HRTF_energy_sections_precalc( model ); + HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; + move16(); + + HrFiltSet_p->ModelEval.hrfModL_fx = (Word32 *) malloc( model->K * sizeof( Word32 ) ); + HrFiltSet_p->ModelEval.hrfModR_fx = (Word32 *) malloc( model->K * sizeof( Word32 ) ); + + IF( HrFiltSet_p->ModelParams.UseItdModel ) + { + LoadBSplineBinaryITD( &HrFiltSet_p->ModelParamsITD, f_hrtf ); + } + + /* left/right energy and interaural coherence for late reverb */ + FOR( i = 0; i < 3; i++ ) + { + fread( f_tmp_lr_energy_and_iac_dyn, sizeof( const float ), LR_IAC_LENGTH_NR_FC, f_hrtf ); + HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + IF( i == 2 ) + { + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q27, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + } + ELSE + { + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ + } + HrFiltSet_p->lr_energy_and_iac_fx[i] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[i]; + } + + return IVAS_ERR_OK; +} +#else static ivas_error LoadBSplineBinary( IVAS_DEC_HRTF_HANDLE HrFiltSet_p, /* i/o: HR filter model parameter structure */ FILE *f_hrtf /* i : HR filter data file handle */ @@ -749,6 +965,7 @@ static ivas_error LoadBSplineBinary( return IVAS_ERR_OK; } +#endif // IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index 47ba31fb8775a2f2916fc321acccb7ccceac77cb..b110e2f4507a3b8dd94b4fd12e30e42cbc242447 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -192,10 +192,21 @@ ivas_error ExternalOrientationFileReading( ( externalOrientationReader->frameCounter )++; +#ifdef IVAS_FLOAT_FIXED + pQuaternion->w_fx = float_to_fix( w, Q29 ); + pQuaternion->x_fx = float_to_fix( x, Q29 ); + pQuaternion->y_fx = float_to_fix( y, Q29 ); + pQuaternion->z_fx = float_to_fix( z, Q29 ); + move32(); + move32(); + move32(); + move32(); +#else pQuaternion->w = w; pQuaternion->x = x; pQuaternion->y = y; pQuaternion->z = z; +#endif *enableHeadRotation = (int8_t) headRotFlag; *enableExternalOrientation = (int8_t) extOrientationFlag; *enableRotationInterpolation = (int8_t) rotInterpolationFlag;