diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 78faac5ae33a581f823d347612ec786ad09c6675..0066805b9f56788bea9d1867b1a3af375505b714 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2221,4 +2221,8 @@ void ivas_lfe_window_init_fx( const Word32 sampling_rate, /* i : sampling rate */ const Word16 frame_len /* i : frame length in samples */ ); + +Word16 param_mc_get_num_cldfb_syntheses_fx( + Decoder_Struct *st_ivas /* i : Parametric MC handle */ +); #endif diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index a702332e8b4c151bb9746bcea559c40899703eb6..48b316cabcacc75312b596cffa4d5c493a4b2dac 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -5051,7 +5051,7 @@ void ivas_init_dec_get_num_cldfb_instances( } ELSE { - *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses( st_ivas ); + *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_fx( st_ivas ); } BREAK; case RENDERER_PARAM_ISM: @@ -5118,7 +5118,7 @@ void ivas_init_dec_get_num_cldfb_instances( case RENDERER_SBA_LINEAR_ENC: IF ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { - *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses( st_ivas ); + *numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_fx( st_ivas ); } ELSE IF ( st_ivas->ism_mode == ISM_MODE_PARAM ) { diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index c3c7c05fd21b750fc6fc20fbf538c0a09c024746..9ffc349345a640686c6adffd6b72787946762d2d 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -3613,35 +3613,20 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { -#ifdef IVAS_FLOAT_FIXED_s +#ifdef IVAS_FLOAT_FIXED //Word32 output_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; //Word32 *p_output_fx[MAX_OUTPUT_CHANNELS]; +#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++) { - floatToFixed_arrL(p_output[i], p_output_fx[i], Q7, L_FRAME48k); + floatToFixed_arrL(p_output[i], p_output_fx[i], Q11, L_FRAME48k); p_output_fx[i] = p_output_fx[i]; } - Word16 subframe_length; Word16 num_subframes = (int16_t)((*nSamplesRendered * FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) / output_Fs); - subframe_length = (*nSamplesRendered) / num_subframes; -#if 1 for (Word16 subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++) { Word16 idx = subframe_idx; - - IF(st_ivas->hCombinedOrientationData->Quaternions) { - float max_val = 0; - max_val = (float)max(max_val, fabs(st_ivas->hCombinedOrientationData->Quaternions[idx].w)); - max_val = (float)max(max_val, fabs(st_ivas->hCombinedOrientationData->Quaternions[idx].x)); - max_val = (float)max(max_val, fabs(st_ivas->hCombinedOrientationData->Quaternions[idx].y)); - max_val = (float)max(max_val, fabs(st_ivas->hCombinedOrientationData->Quaternions[idx].z)); - Word16 quat_q = Q_factor_L(max_val); - st_ivas->hCombinedOrientationData->Quaternions[idx].w_fx = float_to_fix(st_ivas->hCombinedOrientationData->Quaternions[idx].w, quat_q); - st_ivas->hCombinedOrientationData->Quaternions[idx].x_fx = float_to_fix(st_ivas->hCombinedOrientationData->Quaternions[idx].x, quat_q); - st_ivas->hCombinedOrientationData->Quaternions[idx].y_fx = float_to_fix(st_ivas->hCombinedOrientationData->Quaternions[idx].y, quat_q); - st_ivas->hCombinedOrientationData->Quaternions[idx].z_fx = float_to_fix(st_ivas->hCombinedOrientationData->Quaternions[idx].z, quat_q); - } Word16 pos_q = Q25; IF(st_ivas->hCombinedOrientationData->listenerPos != NULL) @@ -3649,64 +3634,18 @@ ivas_error ivas_jbm_dec_render( 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; } - FOR( i = 0; i < 3; i++) - { - st_ivas->hBinRendererTd->Listener_p->Front_fx[i] = float_to_fix(st_ivas->hBinRendererTd->Listener_p->Front[i], Q30); - st_ivas->hBinRendererTd->Listener_p->Up_fx[i] = float_to_fix(st_ivas->hBinRendererTd->Listener_p->Up[i], Q30); - st_ivas->hBinRendererTd->Listener_p->Right_fx[i] = float_to_fix(st_ivas->hBinRendererTd->Listener_p->Right[i], Q30); - st_ivas->hBinRendererTd->Listener_p->Pos_q = pos_q; - st_ivas->hBinRendererTd->Listener_p->Pos_fx[i] = float_to_fix(st_ivas->hBinRendererTd->Listener_p->Pos[i], st_ivas->hBinRendererTd->Listener_p->Pos_q); - } - } #endif if ((error = ivas_td_binaural_renderer_fx(st_ivas, p_output_fx, *nSamplesRendered)) != IVAS_ERR_OK) { return error; } -#if 1 - for ( i = 0; i < 3; i++) - { - st_ivas->hBinRendererTd->Listener_p->Front[i] = fix_to_float(st_ivas->hBinRendererTd->Listener_p->Front_fx[i], Q30); - st_ivas->hBinRendererTd->Listener_p->Up[i] = fix_to_float(st_ivas->hBinRendererTd->Listener_p->Up_fx[i], Q30); - st_ivas->hBinRendererTd->Listener_p->Right[i] = fix_to_float(st_ivas->hBinRendererTd->Listener_p->Right_fx[i], Q30); - st_ivas->hBinRendererTd->Listener_p->Pos[i] = fix_to_float(st_ivas->hBinRendererTd->Listener_p->Pos_fx[i], st_ivas->hBinRendererTd->Listener_p->Pos_q); - } - - Word16 ism_md_subframe_update_ext = 0; - Word16 nchan_transport_tmp = (st_ivas->ism_mode == ISM_MASA_MODE_DISC || st_ivas->ism_mode == ISM_SBA_MODE_DISC) ? st_ivas->nchan_ism : st_ivas->nchan_transport; - - if (st_ivas->hDecoderConfig->Opt_delay_comp) - { - ism_md_subframe_update_ext = 1; - } - else - { - ism_md_subframe_update_ext = 2; - } - - if (st_ivas->ivas_format == MASA_ISM_FORMAT) - { - ism_md_subframe_update_ext = 2; - } - - for (Word16 subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++) - { - if (subframe_idx == ism_md_subframe_update_ext) - { - for(Word16 ns = 0; ns < nchan_transport_tmp - 1; ns++) - { - fixedToFloat_arrL(st_ivas->hBinRendererTd->Sources[ns]->SrcSpatial_p->Front_p_fx, st_ivas->hBinRendererTd->Sources[ns]->SrcSpatial_p->Front_p, Q30, 3 * SPAT_BIN_MAX_INPUT_CHANNELS); - fixedToFloat_arrL(st_ivas->hBinRendererTd->Sources[ns]->SrcSpatial_p->Pos_p_fx, st_ivas->hBinRendererTd->Sources[ns]->SrcSpatial_p->Pos_p, Q25, 3 * SPAT_BIN_MAX_INPUT_CHANNELS); - } - } - } - - +#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++) { - fixedToFloat_arrL(p_output_fx[i], p_output[i], Q7, L_FRAME48k); + fixedToFloat_arrL(p_output_fx[i], p_output[i], Q11, L_FRAME48k); } #endif @@ -3833,14 +3772,6 @@ ivas_error ivas_jbm_dec_render( #endif ivas_param_mc_dec_render_fx(st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output_fx, channel_active_fx); #if 1//ftf changes - if (st_ivas->hParamMC->max_band_decorr > 0) - { - // ftf for param_mc_protoSignalComputation_fx - fixedToFloat_arrL(st_ivas->hParamMC->proto_frame_f_fx, st_ivas->hParamMC->proto_frame_f, Q11, 2 * st_ivas->hParamMC->diff_proto_info->num_protos_diff * st_ivas->hParamMC->num_freq_bands); - - // ftf for ivas_dirac_dec_decorr_process_fx - fixedToFloat_arrL32(st_ivas->hParamMC->proto_frame_dec_f_fx, st_ivas->hParamMC->proto_frame_dec_f, Q11, nchan_out_cov * 2 * st_ivas->hParamMC->num_freq_bands); - } for (int ch = 0; ch < nchan_out_cldfb; ch++) { if (channel_active_fx[ch]) { diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index f200a854596dc73e035771e053a5da432a62d811..5d84f451234f4fc62937a80d384aca13afd0bf30 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -166,6 +166,7 @@ static void param_mc_protoSignalComputation_fx(Word32 *RealBuffer_fx, Word32 *Im * * Open Parametric MC decoder handle *-------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED ivas_error ivas_param_mc_dec_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ @@ -509,21 +510,10 @@ ivas_error ivas_param_mc_dec_open_fx( IF ( GT_16(hParamMC->max_band_decorr , 0) ) { -#if 1/*TODO: To be removed later(floating point malloc)*/ - IF ( ( hParamMC->proto_frame_f = (float *) malloc( 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); - } - IF ( ( hParamMC->proto_frame_dec_f = (float *) malloc( 2 * nchan_out_cov * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); - } -#endif IF ( ( hParamMC->proto_frame_f_fx = (Word32 *) malloc( 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } - hParamMC->proto_frame_f_len = 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands; IF ( ( hParamMC->proto_frame_dec_f_fx = (Word32 *) malloc( 2 * nchan_out_cov * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); @@ -531,10 +521,6 @@ ivas_error ivas_param_mc_dec_open_fx( } ELSE { -#if 1/*TODO: To be removed later*/ - hParamMC->proto_frame_f = NULL; - hParamMC->proto_frame_dec_f = NULL; -#endif hParamMC->proto_frame_f_fx = NULL; hParamMC->proto_frame_dec_f_fx = NULL; } @@ -613,9 +599,6 @@ ivas_error ivas_param_mc_dec_open( #endif int16_t nchan_out_transport; int16_t nchan_out_cov; -#ifdef IVAS_FLOAT_FIXED - Word32 proto_matrix_fx[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; -#endif // IVAS_FLOAT_FIXED float proto_matrix[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; float proto_mtx_norm; int16_t max_param_band_residual; @@ -681,11 +664,8 @@ ivas_error ivas_param_mc_dec_open( hParamMC->synthesis_conf = PARAM_MC_SYNTH_LS_CONV_CLDFB; } } -#ifndef IVAS_FLOAT_FIXED + hParamMC->ls_conv_dmx_matrix = NULL; -#else - hParamMC->ls_conv_dmx_matrix_fx = NULL; -#endif // IVAS_FLOAT_FIXED if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) { @@ -734,12 +714,6 @@ ivas_error ivas_param_mc_dec_open( #endif /* init arrays for quantized parameters */ -#ifdef IVAS_FLOAT_FIXED - if ( ( hParamMC->icc_q_fx = (Word16 *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe * sizeof(Word16) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); - } -#endif if ( ( hParamMC->icc_q = (float *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); @@ -748,12 +722,6 @@ ivas_error ivas_param_mc_dec_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } -#ifdef IVAS_FLOAT_FIXED - if ( ( hParamMC->icld_q_fx = (Word16 *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe * sizeof( Word16 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); - } -#endif // IVAS_FLOAT_FIXED set_f( hParamMC->icld_q, PARAM_MC_DEFAULT_MIN_ILD, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); set_f( hParamMC->icc_q, 0.0f, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ); @@ -792,43 +760,22 @@ ivas_error ivas_param_mc_dec_open( if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB || hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) { -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#else if ( ( error = ivas_ls_setup_conversion_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } -#endif /* convert the ls conv dmx matrix into column order matrix format (nchan_out_cldfb x nchan_out) */ if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) { -#ifndef IVAS_FLOAT_FIXED 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" ) ); } -#else - 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" ) ); - } -#endif for ( k = 0; k < nchan_out_transport; k++ ) { -#ifdef IVAS_FLOAT_FIXED -#if 1 //To be removed when hParamMC->ls_conv_dmx_matrix is removed - -#endif - Copy32( st_ivas->hLsSetUpConversion->dmxMtx_fx[k], &hParamMC->ls_conv_dmx_matrix_fx[k * nchan_out_cov], nchan_out_cov ); -#else mvr2r( st_ivas->hLsSetUpConversion->dmxMtx[k], &hParamMC->ls_conv_dmx_matrix[k * nchan_out_cov], nchan_out_cov ); -#endif } /* convert ParamMC parameter bands to SFB */ @@ -843,20 +790,10 @@ ivas_error ivas_param_mc_dec_open( else { /* close the ls conversion handle immediately, it was only needed to get the DMX matrix in case of DMX in the covariance domain */ -#ifdef IVAS_FLOAT_FIXED - ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); -#else ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); -#endif } } } -#ifdef IVAS_FLOAT_FIXED - if ( ( hParamMC->proto_matrix_int_fx = (Word32 *) malloc( nchan_out_transport * nchan_transport * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); - } -#endif // IVAS_FLOAT_FIXED if ( ( hParamMC->proto_matrix_int = (float *) malloc( nchan_out_transport * nchan_transport * sizeof( float ) ) ) == NULL ) { @@ -918,30 +855,13 @@ ivas_error ivas_param_mc_dec_open( hParamMC->h_freq_domain_decorr_ap_params = NULL; hParamMC->h_freq_domain_decorr_ap_state = NULL; -#ifdef IVAS_FLOAT_FIXED - Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; - ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, output_Fs, hParamMC->num_freq_bands ); - - for ( int i = 0; i < hParamMC->num_freq_bands; i++ ) - { - frequency_axis[i] = (float) frequency_axis_fx[i]; - } - - IF( ( error = ivas_dirac_dec_decorr_open_fx( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, hParamMC->diff_proto_info->num_protos_diff, - DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis_fx, nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } -#else ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, hParamMC->num_freq_bands ); - if ((error = ivas_dirac_dec_decorr_open(&(hParamMC->h_freq_domain_decorr_ap_params), &(hParamMC->h_freq_domain_decorr_ap_state), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, hParamMC->diff_proto_info->num_protos_diff, - DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis, nchan_transport, output_Fs)) != IVAS_ERR_OK) + + if ( ( error = ivas_dirac_dec_decorr_open( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, hParamMC->diff_proto_info->num_protos_diff, + DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis, nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) { return error; } -#endif - - hParamMC->h_output_synthesis_params.use_onset_filters = 0; hParamMC->max_band_decorr = hParamMC->h_freq_domain_decorr_ap_params->max_band_decorr; @@ -960,20 +880,11 @@ ivas_error ivas_param_mc_dec_open( } /* output synthesis */ -#ifdef IVAS_FLOAT_FIXED - floatToFixed_arrL( proto_matrix, proto_matrix_fx, Q26, MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS ); - if ( ( error = ivas_dirac_dec_output_synthesis_cov_open_fx( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix_fx ) ) != IVAS_ERR_OK ) - { - return error; - } - fixedToFloat_arrL( hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, Q26, nchan_transport * nchan_out_cov ); -#else if ( ( error = ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix ) ) != IVAS_ERR_OK ) { return error; } -#endif // IVAS_FLOAT_FIXED ivas_param_mc_dec_compute_interpolator( 0, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hParamMC->h_output_synthesis_params.interpolator ); @@ -993,14 +904,6 @@ ivas_error ivas_param_mc_dec_open( if ( hParamMC->max_band_decorr > 0 ) { -#ifdef IVAS_FLOAT_FIXED - IF ((hParamMC->proto_frame_f_fx = (Word32 *)malloc(2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands * sizeof(Word32))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n")); - } - hParamMC->proto_frame_f_len = 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands; - hParamMC->proto_frame_dec_f_len = 2 * nchan_out_cov * hParamMC->num_freq_bands; -#endif if ( ( hParamMC->proto_frame_f = (float *) malloc( 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); @@ -1010,30 +913,11 @@ ivas_error ivas_param_mc_dec_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } -#ifdef IVAS_FLOAT_FIXED - hParamMC->proto_frame_f_len = 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands; - hParamMC->proto_frame_dec_f_len = 2 * nchan_out_cov * hParamMC->num_freq_bands; - if ((hParamMC->proto_frame_dec_f_fx = (Word32 *)malloc(2 * nchan_out_cov * hParamMC->num_freq_bands * sizeof(Word32))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n")); - } - - if ( ( hParamMC->proto_frame_f_fx = (Word32 *) malloc( 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); - } - -#endif } else { hParamMC->proto_frame_f = NULL; hParamMC->proto_frame_dec_f = NULL; - -#ifdef IVAS_FLOAT_FIXED - hParamMC->proto_frame_dec_f_fx = NULL; - hParamMC->proto_frame_f_fx = NULL; -#endif } ivas_param_mc_dec_init( hParamMC, nchan_transport, nchan_out_cov ); @@ -1053,36 +937,15 @@ ivas_error ivas_param_mc_dec_open( } set_zero( hParamMC->Cldfb_RealBuffer_tc, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); -#ifdef IVAS_FLOAT_FIXED - hParamMC->sz = n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands; - IF ( ( hParamMC->Cldfb_RealBuffer_tc_fx = (Word32 *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); - } - set32_fx( hParamMC->Cldfb_RealBuffer_tc_fx, 0, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); -#endif - if ( ( hParamMC->Cldfb_ImagBuffer_tc = (float *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } set_zero( hParamMC->Cldfb_ImagBuffer_tc, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); -#ifdef IVAS_FLOAT_FIXED - IF ( ( hParamMC->Cldfb_ImagBuffer_tc_fx = (Word32 *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); - } - set32_fx( hParamMC->Cldfb_ImagBuffer_tc_fx, 0, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); -#endif - if ( st_ivas->hTcBuffer == NULL ) { -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1092,11 +955,6 @@ ivas_error ivas_param_mc_dec_open( { hParamMC->Cldfb_RealBuffer_tc = NULL; hParamMC->Cldfb_ImagBuffer_tc = NULL; - -#ifdef IVAS_FLOAT_FIXED - hParamMC->Cldfb_RealBuffer_tc_fx = NULL; - hParamMC->Cldfb_ImagBuffer_tc_fx = NULL; -#endif } hParamMC->subframes_rendered = 0; @@ -1108,6 +966,7 @@ ivas_error ivas_param_mc_dec_open( } #endif + /*------------------------------------------------------------------------- * ivas_param_mc_get_param_band_mapping() * @@ -1224,6 +1083,7 @@ static void ivas_param_mc_get_param_band_mapping( * * Reconfiguration of ParamMC decoder *-------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED ivas_error ivas_param_mc_dec_reconfig_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ @@ -1662,16 +1522,6 @@ ivas_error ivas_param_mc_dec_reconfig_fx( IF ( GT_16(hParamMC->max_band_decorr , 0) && NE_16(nchan_transport_old , nchan_transport) ) { -#ifdef IVAS_FLOAT_FIXED /*To be removed later:floating point memory alocations*/ - free( hParamMC->proto_frame_f ); - hParamMC->proto_frame_f_len = 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands; - IF ( ( hParamMC->proto_frame_f = (float *) malloc( 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); - } - - set_zero( hParamMC->proto_frame_f, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands ); -#endif free( hParamMC->proto_frame_f_fx ); IF ( ( hParamMC->proto_frame_f_fx = (Word32 *) malloc( 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands * sizeof(Word32) ) ) == NULL ) { @@ -1768,7 +1618,6 @@ ivas_error ivas_param_mc_dec_reconfig_fx( return error; } #else // IVAS_FLOAT_FIXED - ivas_error ivas_param_mc_dec_reconfig( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -1859,7 +1708,6 @@ ivas_error ivas_param_mc_dec_reconfig( hParamMC->hMetadataPMC->icc_map_full[k] = NULL; } } - #endif mvs2s( hParamMC->band_grouping, band_grouping_old, hParamMC->hMetadataPMC->num_parameter_bands + 1 ); @@ -1904,12 +1752,6 @@ ivas_error ivas_param_mc_dec_reconfig( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } -#ifdef IVAS_FLOAT_FIXED - if ( ( hParamMC->icld_q_fx = (Word16 *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe * sizeof(Word16) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); - } -#endif // IVAS_FLOAT_FIXED set_f( hParamMC->icld_q, PARAM_MC_DEFAULT_MIN_ILD, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); set_f( hParamMC->icc_q, 0.0f, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ); @@ -1975,17 +1817,6 @@ ivas_error ivas_param_mc_dec_reconfig( { if ( nchan_transport_old != nchan_transport ) { -#ifdef IVAS_FLOAT_FIXED - if ( st_ivas->hLsSetUpConversion != NULL ) - { - ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); - } - - if ( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } -#else if ( st_ivas->hLsSetUpConversion != NULL ) { ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); @@ -1995,7 +1826,6 @@ ivas_error ivas_param_mc_dec_reconfig( { return error; } -#endif /* convert the ls conv dmx matrix into column order matrix format (nchan_out_cldfb x nchan_out) */ free( hParamMC->ls_conv_dmx_matrix ); @@ -2112,29 +1942,14 @@ ivas_error ivas_param_mc_dec_reconfig( hParamMC->h_freq_domain_decorr_ap_params = NULL; hParamMC->h_freq_domain_decorr_ap_state = NULL; -#ifdef IVAS_FLOAT_FIXED - Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; - ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, output_Fs, hParamMC->num_freq_bands ); - - FOR( i = 0; i < hParamMC->num_freq_bands; i++ ) - { - frequency_axis[i] = (float) frequency_axis_fx[i]; - } - - IF( ( error = ivas_dirac_dec_decorr_open_fx( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, - hParamMC->diff_proto_info->num_protos_diff, DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis_fx, nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } -#else ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, hParamMC->num_freq_bands ); - if ((error = ivas_dirac_dec_decorr_open(&(hParamMC->h_freq_domain_decorr_ap_params), &(hParamMC->h_freq_domain_decorr_ap_state), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, - hParamMC->diff_proto_info->num_protos_diff, DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis, nchan_transport, output_Fs)) != IVAS_ERR_OK) + if ( ( error = ivas_dirac_dec_decorr_open( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, + hParamMC->diff_proto_info->num_protos_diff, DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis, nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) { return error; } -#endif + hParamMC->h_output_synthesis_params.use_onset_filters = 0; hParamMC->max_band_decorr = hParamMC->h_freq_domain_decorr_ap_params->max_band_decorr; /* init decorrelation */ @@ -2212,11 +2027,7 @@ ivas_error ivas_param_mc_dec_reconfig( } } -#ifdef IVAS_FLOAT_FIXED - ivas_dirac_dec_output_synthesis_cov_close_fx( ¶ms_old, &cov_state_old ); -#else ivas_dirac_dec_output_synthesis_cov_close( ¶ms_old, &cov_state_old ); -#endif } /*-----------------------------------------------------------------* @@ -2231,16 +2042,6 @@ ivas_error ivas_param_mc_dec_reconfig( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } set_zero( hParamMC->proto_frame_f, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands ); - -#ifdef IVAS_FLOAT_FIXED - free(hParamMC->proto_frame_f_fx); - hParamMC->proto_frame_f_len = 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands; - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n")); - } - - set_zero_fx(hParamMC->proto_frame_f_fx, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands); -#endif } @@ -2277,7 +2078,6 @@ ivas_error ivas_param_mc_dec_reconfig( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } set_zero( hParamMC->Cldfb_ImagBuffer_tc, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); - } else { @@ -2291,13 +2091,13 @@ ivas_error ivas_param_mc_dec_reconfig( free( hParamMC->Cldfb_ImagBuffer_tc ); hParamMC->Cldfb_ImagBuffer_tc = NULL; } - } } return error; } #endif + /*------------------------------------------------------------------------- * param_mc_get_num_cldfb_syntheses() * @@ -2305,6 +2105,40 @@ ivas_error ivas_param_mc_dec_reconfig( *------------------------------------------------------------------------*/ /*! r: number of cldfb synthesis instances */ +#ifdef IVAS_FLOAT_FIXED +Word16 param_mc_get_num_cldfb_syntheses_fx( + Decoder_Struct *st_ivas /* i : Parametric MC handle */ +) +{ + Word16 num_cldfb_syntheses; + + num_cldfb_syntheses = 0; + move16(); + + /* sanity check*/ + IF( st_ivas->hParamMC == NULL ) + { + assert( 0 && "ParamMC handle does not exist!\n" ); + } + + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + num_cldfb_syntheses = 2; + move16(); + } + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + { + num_cldfb_syntheses = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); + } + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) ) + { + num_cldfb_syntheses = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); + } + + return num_cldfb_syntheses; +} +#else int16_t param_mc_get_num_cldfb_syntheses( Decoder_Struct *st_ivas /* i : Parametric MC handle */ ) @@ -2334,6 +2168,7 @@ int16_t param_mc_get_num_cldfb_syntheses( return num_cldfb_syntheses; } +#endif /*------------------------------------------------------------------------- @@ -2341,6 +2176,7 @@ int16_t param_mc_get_num_cldfb_syntheses( * * Close Parametric MC memories *------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED void ivas_param_mc_dec_close_fx( PARAM_MC_DEC_HANDLE *hParamMC_out /* i/o: Parametric MC decoder handle */ @@ -2462,16 +2298,6 @@ void ivas_param_mc_dec_close_fx( hParamMC->Cldfb_ImagBuffer_tc_fx = NULL; } #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED /*TODO: To be removed later(Floating point memory dealloc)------------------------------- */ - IF( hParamMC->proto_frame_f != NULL ) - { - free( hParamMC->proto_frame_f ); - hParamMC->proto_frame_f = NULL; - } - IF( hParamMC->proto_frame_dec_f != NULL ) - { - free( hParamMC->proto_frame_dec_f ); - hParamMC->proto_frame_dec_f = NULL; - } IF( hParamMC->hoa_encoder != NULL ) { free( hParamMC->hoa_encoder ); @@ -2617,6 +2443,7 @@ void ivas_param_mc_dec_close( } #endif + /*------------------------------------------------------------------------- * ivas_param_mc_dec_read_BS() * @@ -3059,6 +2886,7 @@ void ivas_param_mc_dec_read_BS( * * *------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED void ivas_param_mc_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ @@ -3293,7 +3121,6 @@ void ivas_param_mc_dec_digest_tc_fx( return; } #else - void ivas_param_mc_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ @@ -3537,13 +3364,12 @@ void ivas_param_mc_dec_digest_tc( #ifdef IVAS_FLOAT_FIXED void ivas_param_mc_dec_render_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - Word32 *output_f_fx[], /* o : rendered time signal */ - Word16 channel_active_fx[MAX_OUTPUT_CHANNELS] -) + Word32 *output_f_fx[], /* o : rendered time signal */ + Word16 channel_active_fx[MAX_OUTPUT_CHANNELS] ) { PARAM_MC_DEC_HANDLE hParamMC; Word16 i, ch; @@ -3560,7 +3386,7 @@ void ivas_param_mc_dec_render_fx( Word32 *p_output_f_fx[MAX_OUTPUT_CHANNELS]; FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { - p_output_f_fx[i] = output_f_fx[i]; + p_output_f_fx[i] = output_f_fx[i]; } /*Decorrelator*/ Word32 onset_filter_fx[MAX_CICP_CHANNELS * CLDFB_NO_CHANNELS_MAX]; @@ -3572,6 +3398,7 @@ void ivas_param_mc_dec_render_fx( UWord16 nchan_out_init, nbands_to_zero; #endif UWord32 output_Fs; + Word16 tmp_q = 0; hParamMC = st_ivas->hParamMC; assert( hParamMC ); @@ -3585,85 +3412,85 @@ void ivas_param_mc_dec_render_fx( nchan_out_init = nchan_out_transport; #endif output_Fs = st_ivas->hDecoderConfig->output_Fs; - IF ( EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV )|| EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV_ROOM) ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - nchan_out_cldfb = BINAURAL_CHANNELS; - set_s( channel_active, 1, nchan_out_cldfb ); + nchan_out_cldfb = BINAURAL_CHANNELS; + set_s( channel_active, 1, nchan_out_cldfb ); #ifndef MSAN_FIX - IF ( st_ivas->hCombinedOrientationData ) - { + IF( st_ivas->hCombinedOrientationData ) + { nchan_out_init = MAX_INTERN_CHANNELS; - } + } #endif - nchan_out_cov = add(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 ( EQ_16(hParamMC->synthesis_conf , PARAM_MC_SYNTH_LS_CONV_CLDFB )) + ELSE IF( EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) ) { - nchan_out_cov = nchan_out_transport; - nchan_out_cldfb = add(st_ivas->hOutSetup.nchan_out_woLFE , st_ivas->hOutSetup.num_lfe); + nchan_out_cov = nchan_out_transport; + nchan_out_cldfb = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); } - ELSE IF ( EQ_16(hParamMC->synthesis_conf , PARAM_MC_SYNTH_LS_CONV_COV )|| EQ_16(hParamMC->synthesis_conf , PARAM_MC_SYNTH_MONO_STEREO) ) + ELSE IF( EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { - nchan_out_cov = add(st_ivas->hOutSetup.nchan_out_woLFE , st_ivas->hOutSetup.num_lfe); - nchan_out_cldfb = nchan_out_cov; - set_s( channel_active, 1, nchan_out_cov ); + nchan_out_cov = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); + nchan_out_cldfb = nchan_out_cov; + set_s( channel_active, 1, nchan_out_cov ); } ELSE { - nchan_out_cov = nchan_out_transport; - nchan_out_cldfb = nchan_out_transport; - set_s( channel_active, 1, nchan_out_cov ); + nchan_out_cov = nchan_out_transport; + nchan_out_cldfb = nchan_out_transport; + set_s( channel_active, 1, nchan_out_cov ); } /* set everything to zero that will not be decoded */ nband_synth = hParamMC->band_grouping[hParamMC->num_param_bands_synth]; #ifndef IVAS_FLOAT_FIXED - nbands_to_zero = sub(hParamMC->num_freq_bands , nband_synth); + nbands_to_zero = sub( hParamMC->num_freq_bands, nband_synth ); #endif #ifdef MSAN_FIX - FOR ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) + FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) #else - FOR ( ch = 0; ch < nchan_out_init; ch++ ) + FOR( ch = 0; ch < nchan_out_init; ch++ ) #endif { - FOR ( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ ) - { + FOR( slot_idx = 0; slot_idx < JBM_CLDFB_SLOTS_IN_SUBFRAME; slot_idx++ ) + { #ifdef MSAN_FIX - set32_fx( &( Cldfb_RealBuffer_fx[ch][slot_idx][0] ), 0, CLDFB_NO_CHANNELS_MAX); - set32_fx( &( Cldfb_ImagBuffer_fx[ch][slot_idx][0] ), 0, CLDFB_NO_CHANNELS_MAX); + set32_fx( &( Cldfb_RealBuffer_fx[ch][slot_idx][0] ), 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( &( Cldfb_ImagBuffer_fx[ch][slot_idx][0] ), 0, CLDFB_NO_CHANNELS_MAX ); #else set32_fx( &( Cldfb_RealBuffer_fx[ch][slot_idx][nband_synth] ), 0, nbands_to_zero ); set32_fx( &( Cldfb_ImagBuffer_fx[ch][slot_idx][nband_synth] ), 0, nbands_to_zero ); #endif - } + } } /* loop FOR synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = min( sub(hParamMC->num_slots , hParamMC->slots_rendered), nSamplesAsked / NS2SA( output_Fs, CLDFB_SLOT_NS ) ); + slots_to_render = min( sub( hParamMC->num_slots, hParamMC->slots_rendered ), nSamplesAsked / NS2SA( output_Fs, CLDFB_SLOT_NS ) ); *nSamplesRendered = slots_to_render * NS2SA( output_Fs, CLDFB_SLOT_NS ); Word16 j, k; first_sf = hParamMC->subframes_rendered; last_sf = first_sf; - WHILE ( GT_16(slots_to_render , 0 )) + WHILE( GT_16( slots_to_render, 0 ) ) { - slots_to_render = sub(slots_to_render, hParamMC->subframe_nbslots[last_sf]); - last_sf = add(last_sf, 1); + slots_to_render = sub( slots_to_render, hParamMC->subframe_nbslots[last_sf] ); + last_sf = add( last_sf, 1 ); } - IF ( EQ_16(st_ivas->renderer_type , RENDERER_SBA_LINEAR_ENC )) + IF( EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { - FOR ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) - { - slots_to_render = add(slots_to_render, hParamMC->subframe_nbslots[subframe_idx]); - } + FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) + { + slots_to_render = add( slots_to_render, hParamMC->subframe_nbslots[subframe_idx] ); + } } slot_idx_start = hParamMC->slots_rendered; slot_idx_start_cldfb_synth = 0; - FOR ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) + FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { - for ( slot_idx = 0; slot_idx < hParamMC->subframe_nbslots[subframe_idx]; slot_idx++, hParamMC->slots_rendered++ ) - { - IF ( GT_16(hParamMC->max_band_decorr , 0 )) + FOR( slot_idx = 0; slot_idx < hParamMC->subframe_nbslots[subframe_idx]; ( slot_idx++, hParamMC->slots_rendered++ ) ) + { + IF( GT_16( hParamMC->max_band_decorr, 0 ) ) { /*-----------------------------------------------------------------* * protoype signal computation @@ -3672,7 +3499,7 @@ void ivas_param_mc_dec_render_fx( &hParamMC->Cldfb_ImagBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], hParamMC->proto_frame_f_fx, hParamMC->diff_proto_info, hParamMC->num_freq_bands ); - Scale_sig32(hParamMC->proto_frame_f_fx, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands, Q11 - Q5); + Scale_sig32( hParamMC->proto_frame_f_fx, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands, Q11 - Q5 ); /*-----------------------------------------------------------------* * frequency domain decorrelation *-----------------------------------------------------------------*/ @@ -3688,7 +3515,7 @@ void ivas_param_mc_dec_render_fx( hParamMC->diff_proto_info->num_protos_diff, hParamMC->diff_proto_info->proto_index_diff, hParamMC->proto_frame_dec_f_fx, // output - &hParamMC->exp_proto_frame_dec_f, + &tmp_q, onset_filter_fx, hParamMC->h_freq_domain_decorr_ap_params, hParamMC->h_freq_domain_decorr_ap_state ); @@ -3701,8 +3528,8 @@ void ivas_param_mc_dec_render_fx( { FOR( int l = 0; l < hParamMC->h_output_synthesis_params.max_band_decorr; l++ ) { - Cldfb_RealBuffer_fx[k][slot_idx][l] = L_shl( Cldfb_RealBuffer_fx[k][slot_idx][l], 6 - ( 31 - hParamMC->exp_proto_frame_dec_f ) ); - Cldfb_ImagBuffer_fx[k][slot_idx][l] = L_shl( Cldfb_ImagBuffer_fx[k][slot_idx][l], 6 - ( 31 - hParamMC->exp_proto_frame_dec_f ) ); + Cldfb_RealBuffer_fx[k][slot_idx][l] = L_shl( Cldfb_RealBuffer_fx[k][slot_idx][l], 6 - tmp_q ); + Cldfb_ImagBuffer_fx[k][slot_idx][l] = L_shl( Cldfb_ImagBuffer_fx[k][slot_idx][l], 6 - tmp_q ); } } } @@ -3715,28 +3542,28 @@ void ivas_param_mc_dec_render_fx( &hParamMC->Cldfb_ImagBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, slot_idx, slot_idx + slot_idx_start, nchan_transport, nchan_out_cov, hParamMC ); - IF ( ( EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV ) || EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV_ROOM) ) ) + IF( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { - IF ( st_ivas->hCombinedOrientationData && EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV) ) + IF( st_ivas->hCombinedOrientationData && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { Word16 Q_Cldfb_ImagBuffer, Q_Cldfb_RealBuffer; - Q_Cldfb_ImagBuffer = sub(Q6 , 5); /*max value =MAX_INTERN_CHANNELS(=16)*Cldfb_ImagBuffer_fx*/ - Q_Cldfb_RealBuffer = sub(Q6 , 5); - FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + Q_Cldfb_ImagBuffer = sub( Q6, 5 ); /*max value =MAX_INTERN_CHANNELS(=16)*Cldfb_ImagBuffer_fx*/ + Q_Cldfb_RealBuffer = sub( Q6, 5 ); + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { - FOR ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - Scale_sig32( Cldfb_RealBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub(Q_Cldfb_ImagBuffer , Q6 )); - Scale_sig32( Cldfb_ImagBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub(Q_Cldfb_RealBuffer , Q6 )); + Scale_sig32( Cldfb_RealBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( Q_Cldfb_ImagBuffer, Q6 ) ); + Scale_sig32( Cldfb_ImagBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( Q_Cldfb_RealBuffer, Q6 ) ); } } ivas_param_mc_mc2sba_cldfb_fx( st_ivas->hTransSetup, hParamMC->hoa_encoder_fx, slot_idx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, nband_synth, GAIN_LFE_FX ); - FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { - FOR ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - Scale_sig32( Cldfb_RealBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub(Q6 , Q_Cldfb_ImagBuffer) ); - Scale_sig32( Cldfb_ImagBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub(Q6 , Q_Cldfb_RealBuffer) ); + Scale_sig32( Cldfb_RealBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( Q6, Q_Cldfb_ImagBuffer ) ); + Scale_sig32( Cldfb_ImagBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( Q6, Q_Cldfb_RealBuffer ) ); } } } @@ -3749,12 +3576,12 @@ void ivas_param_mc_dec_render_fx( hLsSetup = st_ivas->hTransSetup; /* If LFE should be rendered, add it to other channels before removing */ - IF ( st_ivas->hBinRenderer->render_lfe ) + IF( st_ivas->hBinRenderer->render_lfe ) { Word16 tmp_exp = 0; Word16 tmp = BASOP_Util_Divide1616_Scale( GAIN_LFE_FX, hLsSetup.nchan_out_woLFE, &tmp_exp ); tmp_exp = tmp_exp + ( 1 - 15 ); - FOR ( idx_lfe = 0; idx_lfe < hLsSetup.num_lfe; idx_lfe++ ) + FOR( idx_lfe = 0; idx_lfe < hLsSetup.num_lfe; idx_lfe++ ) { /* Copy just the first band of LFE*/ v_multc_fixed_16( Cldfb_RealBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], tmp, Cldfb_RealBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], 1 ); @@ -3762,9 +3589,9 @@ void ivas_param_mc_dec_render_fx( Scale_sig32( Cldfb_RealBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], 1, tmp_exp ); Scale_sig32( Cldfb_ImagBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], 1, tmp_exp ); - FOR ( ch = 0; ch < ( hLsSetup.nchan_out_woLFE + hLsSetup.num_lfe ); ch++ ) + FOR( ch = 0; ch < ( hLsSetup.nchan_out_woLFE + hLsSetup.num_lfe ); ch++ ) { - IF ( hLsSetup.index_lfe[idx_lfe] != ch ) + IF( hLsSetup.index_lfe[idx_lfe] != ch ) { v_add_fixed( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_RealBuffer_fx[ch][slot_idx], 1, 0 ); v_add_fixed( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], 1, 0 ); @@ -3776,32 +3603,32 @@ void ivas_param_mc_dec_render_fx( idx_out = 0; idx_lfe = 0; - FOR ( ch = 0; ch < ( hLsSetup.nchan_out_woLFE + hLsSetup.num_lfe ); ch++ ) + FOR( ch = 0; ch < ( hLsSetup.nchan_out_woLFE + hLsSetup.num_lfe ); ch++ ) { - IF ( (GT_16( hLsSetup.num_lfe , 0 )) && ( EQ_16(hLsSetup.index_lfe[idx_lfe] , ch )) ) + IF( ( GT_16( hLsSetup.num_lfe, 0 ) ) && ( EQ_16( hLsSetup.index_lfe[idx_lfe], ch ) ) ) { - IF ( LT_16(idx_lfe , ( sub(hLsSetup.num_lfe , 1) )) ) + IF( LT_16( idx_lfe, ( sub( hLsSetup.num_lfe, 1 ) ) ) ) { - idx_lfe = add(idx_lfe, 1); + idx_lfe = add( idx_lfe, 1 ); } } - ELSE IF ( NE_16(ch , idx_out) ) + ELSE IF( NE_16( ch, idx_out ) ) { Copy32( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer_fx[idx_out][slot_idx], nband_synth ); Copy32( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[idx_out][slot_idx], nband_synth ); - idx_out = add(idx_out, 1); + idx_out = add( idx_out, 1 ); } ELSE { - idx_out = add(idx_out, 1); + idx_out = add( idx_out, 1 ); } } } } - } + } - IF ( EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV ) || EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV_ROOM) ) - { + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { Word16 input_q = 6; /* Implement binaural rendering */ ivas_binRenderer_fx( st_ivas->hBinRenderer, @@ -3811,48 +3638,48 @@ void ivas_param_mc_dec_render_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); - FOR ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { - FOR ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - FOR ( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) + FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) { - Cldfb_RealBuffer_fx[i][j][k] = L_shl( Cldfb_RealBuffer_fx[i][j][k], sub(Q6 , input_q) ); - Cldfb_ImagBuffer_fx[i][j][k] = L_shl( Cldfb_ImagBuffer_fx[i][j][k], sub(Q6 , input_q) ); + Cldfb_RealBuffer_fx[i][j][k] = L_shl( Cldfb_RealBuffer_fx[i][j][k], sub( Q6, input_q ) ); + Cldfb_ImagBuffer_fx[i][j][k] = L_shl( Cldfb_ImagBuffer_fx[i][j][k], sub( Q6, input_q ) ); } } } - FOR ( int idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) + FOR( int idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) { - FOR ( int idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) + FOR( int idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) { - Scale_sig32( Cldfb_RealBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub(Q6 , input_q )); - Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub(Q6 , input_q )); + Scale_sig32( Cldfb_RealBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); + Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); } } /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); - } - ELSE IF ( EQ_16(hParamMC->synthesis_conf , PARAM_MC_SYNTH_LS_CONV_CLDFB )) - { + } + ELSE IF( EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_CLDFB ) ) + { /* format conversion*/ ivas_lssetupconversion_process_param_mc_fx( st_ivas, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, channel_active ); - } + } - /* CLDFB synthesis */ - FOR ( ch = 0; ch < nchan_out_cldfb; ch++ ) - { + /* CLDFB synthesis */ + FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) + { Word32 *RealBuffer_fx[16]; Word32 *ImagBuffer_fx[16]; - IF ( channel_active[ch] ) + IF( channel_active[ch] ) { /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands FOR 48kHz */ - FOR ( i = 0; i < hParamMC->subframe_nbslots[subframe_idx]; i++ ) + FOR( i = 0; i < hParamMC->subframe_nbslots[subframe_idx]; i++ ) { - IF ( EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV )|| EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV_ROOM) ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[ch][i]; ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[ch][i]; @@ -3875,21 +3702,21 @@ void ivas_param_mc_dec_render_fx( { set32_fx( &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), 0, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); } - } - slot_idx_start = add(slot_idx_start, hParamMC->subframe_nbslots[subframe_idx]); - slot_idx_start_cldfb_synth = add(slot_idx_start_cldfb_synth, hParamMC->subframe_nbslots[subframe_idx]); + } + slot_idx_start = add( slot_idx_start, hParamMC->subframe_nbslots[subframe_idx] ); + slot_idx_start_cldfb_synth = add( slot_idx_start_cldfb_synth, hParamMC->subframe_nbslots[subframe_idx] ); } - IF ( EQ_16(st_ivas->renderer_type , RENDERER_SBA_LINEAR_ENC )) + IF( EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { - ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_f_fx, p_output_f_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); + ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_f_fx, p_output_f_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); } /* update */ - IF ( EQ_16(hParamMC->slots_rendered , hParamMC->num_slots) ) + IF( EQ_16( hParamMC->slots_rendered, hParamMC->num_slots ) ) { - hParamMC->hMetadataPMC->last_coded_bwidth = hParamMC->hMetadataPMC->coded_bwidth; - param_mc_update_mixing_matrices_fx( hParamMC, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_transport, nchan_out_cov ); + hParamMC->hMetadataPMC->last_coded_bwidth = hParamMC->hMetadataPMC->coded_bwidth; + param_mc_update_mixing_matrices_fx( hParamMC, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_transport, nchan_out_cov ); } @@ -4192,6 +4019,7 @@ void ivas_param_mc_dec_render( * * Parametric MC decoding process *------------------------------------------------------------------------*/ + #if 0 //NO Calling location void ivas_param_mc_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ @@ -4225,11 +4053,13 @@ void ivas_param_mc_dec( } #endif + /*------------------------------------------------------------------------- * param_mc_dec_init() * * Parametric MC decoding initialization *------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED static void ivas_param_mc_dec_init_fx( PARAM_MC_DEC_HANDLE hParamMC, /* i/o: decoder DirAC handle */ @@ -4275,10 +4105,6 @@ static void ivas_param_mc_dec_init_fx( IF ( GT_16(hParamMC->max_band_decorr , 0) ) { -#if 1/*TODO: To be removed later*/ - 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 ); -#endif set_zero_fx( hParamMC->proto_frame_f_fx, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands ); set32_fx( hParamMC->proto_frame_dec_f_fx, 0, 2 * nchan_cov * hParamMC->num_freq_bands ); } @@ -4340,6 +4166,7 @@ static void ivas_param_mc_dec_init( } #endif + /*------------------------------------------------------------------------- * Local functions *-------------------------------------------------------------------------*/ @@ -4391,9 +4218,7 @@ static void param_mc_protoSignalComputation( return; } -#endif - -#ifdef IVAS_FLOAT_FIXED +#else static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, /* i : CLDFB samples of the transport channels (real part) */ Word32 *ImagBuffer_fx, /* i : CLDFB samples of the transport channels (imaginary part) */ @@ -4459,6 +4284,7 @@ static void param_mc_protoSignalComputation_fx( * Transfer decorrelated signals back from the decorrelator buffer to * the buffers used in the final synthesis *------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED static void ivas_param_mc_dec_copy_diffuse_proto( PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ @@ -4573,9 +4399,7 @@ static Word16 ivas_param_mc_uniform_decoder_fx( return n_bits; } -#endif // IVAS_FLOAT_FIXED - -#ifndef IVAS_FLOAT_FIXED +#else static int16_t ivas_param_mc_uniform_decoder( float *seq, /* o : decoded sequence of float values */ const int16_t sz_seq, /* i : number of values to decode */ @@ -4677,44 +4501,38 @@ static Word16 ivas_param_mc_range_decoder_LC( * * compute the interpolator used in the final synthesis *------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED static void ivas_param_mc_dec_compute_interpolator_fx( const UWord16 bAttackPresent, /* i : flag indicating if we have a transient in the current frame */ const UWord16 attackPos, /* i : position of the transient */ const UWord16 interp_length, /* i : number of interpolation values to be calculated */ - Word16 *interpolator /* o : interpolator */ + Word16 *interpolator /* o : interpolator */ ) { Word16 idx; - IF ( bAttackPresent ) + IF( bAttackPresent ) { - FOR ( idx = 0; idx < 2 * attackPos; idx++ ) + FOR( idx = 0; idx < 2 * attackPos; idx++ ) { interpolator[idx] = 0; move16(); } - FOR ( ; idx < interp_length; idx++ ) + FOR( ; idx < interp_length; idx++ ) { - interpolator[idx] = 32767;/*1.0f Q15*/ + interpolator[idx] = 32767; /* 1.0f Q15 */ move16(); } } ELSE { -#ifdef IVAS_FLOAT_FIXED ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, interp_length, interpolator ); -#else - ivas_jbm_dec_get_adapted_linear_interpolator( DEFAULT_JBM_CLDFB_TIMESLOTS, interp_length, interpolator ); -#endif // IVAS_FLOAT_FIXED - } return; } -#endif // IVAS_FLOAT_FIXED - -#ifndef IVAS_FLOAT_FIXED +#else static void ivas_param_mc_dec_compute_interpolator( const uint16_t bAttackPresent, /* i : flag indicating if we have a transient in the current frame */ const uint16_t attackPos, /* i : position of the transient */ @@ -4786,9 +4604,7 @@ static void remove_lfe_from_cy( return; } -#endif - -#ifdef IVAS_FLOAT_FIXED +#else static void remove_lfe_from_cy_fx( const Word16 nY, /* i : dimension of the covariance matrix */ Word16 lfe_indices[PARAM_MC_LOCAL_SZ_LFE_MAP], /* i : LFE index */ @@ -4973,11 +4789,6 @@ static void ivas_param_mc_get_mixing_matrices( set32_fx( Cy_state_fx, 0, matSize ); Cy_state_e = 0; - //if ( synth_config == PARAM_MC_SYNTH_LS_CONV_COV ) - //{ - // f2me_buf( hParamMC->ls_conv_dmx_matrix, hParamMC->ls_conv_dmx_matrix_fx, &hParamMC->ls_conv_dmx_e, nY_cov * nY_intern ); - //} - 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, @@ -5875,6 +5686,7 @@ static void param_mc_update_mixing_matrices_fx( * * generate the target covariance matrix *------------------------------------------------------------------------*/ + #ifndef IVAS_FLOAT_FIXED static void ivas_param_mc_dequantize_cov( PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index d4c0132a1c212300433afd89ecba8ccdf4c7993c..3186bead671868677fab4b0af8afb23a164a19cf 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -87,12 +87,14 @@ ivas_error ivas_td_binaural_open( } #endif // IVAS_FLOAT_FIXED + /*---------------------------------------------------------------------* * ivas_td_binaural_renderer() * * Receives the current frames for the object streams, updates metadata * and renders the current frame. *---------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED ivas_error ivas_td_binaural_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -121,8 +123,7 @@ ivas_error ivas_td_binaural_renderer_fx( return ivas_td_binaural_renderer_unwrap_fx(st_ivas->hReverb, st_ivas->transport_config, st_ivas->hBinRendererTd, nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, st_ivas->hCombinedOrientationData, ism_md_subframe_update, output, output_frame, MAX_PARAM_SPATIAL_SUBFRAMES); } -#endif - +#else ivas_error ivas_td_binaural_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output[], /* i/o: SCE channels / Binaural synthesis */ @@ -150,6 +151,9 @@ ivas_error ivas_td_binaural_renderer( return ivas_td_binaural_renderer_unwrap( st_ivas->hReverb, st_ivas->transport_config, st_ivas->hBinRendererTd, nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, st_ivas->hCombinedOrientationData, ism_md_subframe_update, output, output_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); } +#endif + + /*---------------------------------------------------------------------* * ivas_td_binaural_renderer_sf() * @@ -165,6 +169,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx( const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ) { + UNUSED_PARAM( q_factor ); Word16 first_sf, last_sf, subframe_idx; Word32 *output_fx_local[BINAURAL_CHANNELS]; Word32 reverb_signal_fx[BINAURAL_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -273,8 +278,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx( { IF( !( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( nS, LFE_CHANNEL ) ) ) /* Skip LFE for MC */ { - st_ivas->hBinRendererTd->Sources[c_indx]->InputFrame_p_fx = tc_local_fx[nS]; - st_ivas->hBinRendererTd->Sources[c_indx]->InputFrame_p_q = q_factor; + st_ivas->hBinRendererTd->Sources[c_indx]->InputFrame_p_fx = tc_local_fx[nS]; /* Q11 */ st_ivas->hBinRendererTd->Sources[c_indx]->SrcRend_p->InputAvailable = TRUE; move16(); c_indx = add( c_indx, 1 ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index ba4ff1d583ea9175b626494bd11f99812277ea27..86c3f8c7f31063120f9ad2422e1a224fde5116d1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -858,15 +858,12 @@ typedef struct ivas_param_mc_dec_data_structure /* Decorrelator options */ int16_t max_band_decorr; /*Decoder states=memories*/ +#ifndef IVAS_FLOAT_FIXED float *proto_frame_f; float *proto_frame_dec_f; -#ifdef IVAS_FLOAT_FIXED - Word32 *proto_frame_dec_f_fx; - Word16 exp_proto_frame_dec_f; - - Word32 *proto_frame_f_fx; // Q11 - Word16 proto_frame_f_len; - Word16 proto_frame_dec_f_len; +#else + Word32 *proto_frame_f_fx; /* Q11 */ + Word32 *proto_frame_dec_f_fx; /* Q11 */ #endif DIRAC_OUTPUT_SYNTHESIS_COV_STATE h_output_synthesis_cov_state; @@ -887,8 +884,7 @@ typedef struct ivas_param_mc_dec_data_structure #endif #ifdef IVAS_FLOAT_FIXED Word16 q_proto_frame_f; - Word32 *ls_conv_dmx_matrix_fx; - Word16 ls_conv_dmx_e; + Word32 *ls_conv_dmx_matrix_fx; /* Q30 */ Word32 *proto_matrix_int_fx; Word16 proto_matrix_int_len; Word16 proto_matrix_int_e; diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index e205df6e022ffe9a7fd00e462cd152da023fdbd9..09878f6e433ca3e246a2eed2be7194176c7019a3 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -548,6 +548,7 @@ void ivas_td_binaural_close( * * Call ivas_td_binaural_renderer() without st_ivas. *---------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED ivas_error ivas_td_binaural_renderer_unwrap_fx( const REVERB_HANDLE hReverb, /* i : Reverberator handle */ @@ -599,8 +600,7 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( { IF(!(ivas_format == MC_FORMAT && nS == lfe_idx)) /* Skip LFE for MC */ { - hBinRendererTd->Sources[c_indx]->InputFrame_p_fx = output_fx[nS]; - hBinRendererTd->Sources[c_indx]->InputFrame_p_q = Q11; move16(); + hBinRendererTd->Sources[c_indx]->InputFrame_p_fx = output_fx[nS]; /* Q11 */ hBinRendererTd->Sources[c_indx]->SrcRend_p->InputAvailable = TRUE; move16(); c_indx = add(c_indx, 1); } @@ -686,8 +686,7 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( return IVAS_ERR_OK; } -#endif - +#else ivas_error ivas_td_binaural_renderer_unwrap( const REVERB_HANDLE hReverb, /* i : Reverberator handle */ const AUDIO_CONFIG transport_config, /* i : Transport configuration */ @@ -731,29 +730,12 @@ ivas_error ivas_td_binaural_renderer_unwrap( subframe_length = output_frame / num_subframes; -#ifdef IVAS_FLOAT_FIXED - Word32 output_fx_buf[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - Word32 *output_fx[MAX_OUTPUT_CHANNELS]; - for (int i = 0; i < MAX_OUTPUT_CHANNELS; i++) - { - output_fx[i] = output_fx_buf[i]; - for (int j = 0; j < L_FRAME48k; j++) - { - output_fx[i][j] = floatToFixed(output[i][j], Q11); - } - } -#endif - c_indx = 0; for ( nS = 0; nS < num_src; nS++ ) { if ( !( ivas_format == MC_FORMAT && nS == lfe_idx ) ) /* Skip LFE for MC */ { hBinRendererTd->Sources[c_indx]->InputFrame_p = output[nS]; -#ifdef IVAS_FLOAT_FIXED - hBinRendererTd->Sources[c_indx]->InputFrame_p_fx = output_fx[nS]; - hBinRendererTd->Sources[c_indx]->InputFrame_p_q = Q11; -#endif hBinRendererTd->Sources[c_indx]->SrcRend_p->InputAvailable = TRUE; c_indx++; } @@ -764,155 +746,31 @@ ivas_error ivas_td_binaural_renderer_unwrap( if ( subframe_idx == ism_md_subframe_update ) { /* Update object position(s) */ -#ifdef IVAS_FLOAT_FIXED - FOR( Word16 i = 0; i < num_src; i++ ) - { - FOR( int j = 0; j < 3; j++ ) - { - IF( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT || ivas_format == SBA_ISM_FORMAT ) - hBinRendererTd->Sources[i]->SrcSpatial_p->Pos_p_fx[j] = L_shr( hBinRendererTd->Sources[i]->SrcSpatial_p->Pos_p_fx[j], hBinRendererTd->Sources[i]->SrcSpatial_p->q_Pos_p - Q25 ); - } - IF( ivas_format == ISM_FORMAT || ivas_format == MASA_ISM_FORMAT || ivas_format == SBA_ISM_FORMAT ) - hBinRendererTd->Sources[i]->SrcSpatial_p->q_Pos_p = 25; - } - IF ( ( error = TDREND_Update_object_positions_fx( hBinRendererTd, num_src, ivas_format, hIsmMetaData ) ) != IVAS_ERR_OK ) - { - return error; - } -#else if ( ( error = TDREND_Update_object_positions( hBinRendererTd, num_src, ivas_format, hIsmMetaData ) ) != IVAS_ERR_OK ) { return error; } -#endif // IVAS_FLOAT_FIXED } /* Update the listener's location/orientation */ -#ifdef IVAS_FLOAT_FIXED - Word16 tmp_headRotEnabled; - IVAS_QUATERNION* tmp_Quaternions; - IVAS_VECTOR3* tmp_Pos; - - tmp_headRotEnabled = 0; - move16(); - tmp_Quaternions = NULL; - tmp_Pos = NULL; - - IF(enableCombinedOrientation != NULL) - { - tmp_headRotEnabled = enableCombinedOrientation[hCombinedOrientationData->subframe_idx]; - move16(); - } - IF(Quaternions != NULL) - { - tmp_Quaternions = &Quaternions[hCombinedOrientationData->subframe_idx]; - } - IF(Pos != NULL) - { - tmp_Pos = &Pos[hCombinedOrientationData->subframe_idx]; - } - - Word16 pos_q = Q25; - tmp_Pos->x_fx = L_shr( tmp_Pos->x_fx, sub(tmp_Pos->q_fact, pos_q) ); - tmp_Pos->y_fx = L_shr( tmp_Pos->y_fx, sub( tmp_Pos->q_fact, pos_q ) ); - tmp_Pos->z_fx = L_shr( tmp_Pos->z_fx, sub( tmp_Pos->q_fact, pos_q ) ); - tmp_Pos->q_fact = pos_q; - // end float to fix - - IF ( ( error = TDREND_Update_listener_orientation_fx( hBinRendererTd, tmp_headRotEnabled, tmp_Quaternions, tmp_Pos ) ) != IVAS_ERR_OK ) - { - return error; - } - - // fix to float -#else if ( ( error = TDREND_Update_listener_orientation( hBinRendererTd, ( enableCombinedOrientation != NULL ) ? enableCombinedOrientation[hCombinedOrientationData->subframe_idx] : 0, ( Quaternions != NULL ) ? &Quaternions[hCombinedOrientationData->subframe_idx] : NULL, ( Pos != NULL ) ? &Pos[hCombinedOrientationData->subframe_idx] : NULL ) ) != IVAS_ERR_OK ) { return error; } -#endif if ( hReverb != NULL ) { -#ifdef IVAS_FLOAT_FIXED - Word16 i, j, exp; - Word32 pcm_in_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - Word32 pcm_out_buff[BINAURAL_CHANNELS][L_FRAME48k]; - Word32 *pcm_in_fx[MAX_OUTPUT_CHANNELS]; - Word32 *pcm_out_fx[BINAURAL_CHANNELS]; - Word16 nchan_transport = audioCfg2channels( transport_config ); - exp = Q7; - for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) - { - pcm_in_fx[i] = pcm_in_buff[i]; - } - for ( i = 0; i < nchan_transport; i++ ) - { - - for ( j = 0; j < ( ( subframe_idx + 1 ) * hReverb->full_block_size ); j++ ) - { - - pcm_in_fx[i][j] = (Word32) float_to_fixed( output[i][j], exp ); - } - } - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - pcm_out_fx[i] = pcm_out_buff[i]; - } - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - - for ( j = 0; j < ( hReverb->full_block_size ); j++ ) - { - pcm_out_fx[i][j] = (Word32) float_to_fixed( p_reverb_signal[i][j], ( exp ) ); - } - } - if ( ( error = ivas_reverb_process_fx( hReverb, transport_config, 0, pcm_in_fx, pcm_out_fx, subframe_idx) ) != IVAS_ERR_OK ) -#else if ( ( error = ivas_reverb_process( hReverb, transport_config, 0, output, p_reverb_signal, subframe_idx ) ) != IVAS_ERR_OK ) - -#endif { return error; } -#ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - - for ( j = 0; j < ( hReverb->full_block_size ); j++ ) - { - - p_reverb_signal[i][subframe_idx * hReverb->full_block_size + j] = fixed_to_float( pcm_out_fx[i][subframe_idx * hReverb->full_block_size + j], (exp - 2) ); - } - } -#endif } /* Render subframe */ -#ifdef IVAS_FLOAT_FIXED - ////// Float to fix ///// - FOR( Word16 i = 0; i < hBinRendererTd->NumOfSrcs; i++ ) - { - FOR( int j = 0; j < 3; j++ ) - { - - hBinRendererTd->Sources[i]->SrcSpatial_p->Pos_p_fx[j] = L_shr( hBinRendererTd->Sources[i]->SrcSpatial_p->Pos_p_fx[j], hBinRendererTd->Sources[i]->SrcSpatial_p->q_Pos_p - Q25 ); - } - hBinRendererTd->Sources[i]->SrcSpatial_p->q_Pos_p = 25; - } - IF ( ( error = TDREND_GetMix_fx( hBinRendererTd, output_fx, subframe_length, subframe_idx, ism_md_subframe_update ) ) != IVAS_ERR_OK ) - { - return error; - } - /////// Fix to float //////// - me2f_buf(output_fx[0], 31 - Q11, output[0], (subframe_idx + 1)*subframe_length); - me2f_buf(output_fx[1], 31 - Q11, output[1], (subframe_idx + 1)*subframe_length); -#else if ( ( error = TDREND_GetMix( hBinRendererTd, output, subframe_length, subframe_idx, ism_md_subframe_update ) ) != IVAS_ERR_OK ) { return error; } -#endif /* Advance subframe pointer */ c_indx = 0; @@ -921,9 +779,6 @@ ivas_error ivas_td_binaural_renderer_unwrap( if ( !( ivas_format == MC_FORMAT && nS == lfe_idx ) ) /* Skip LFE for MC */ { hBinRendererTd->Sources[c_indx]->InputFrame_p += subframe_length; -#ifdef IVAS_FLOAT_FIXED - hBinRendererTd->Sources[c_indx]->InputFrame_p_fx += subframe_length; -#endif c_indx++; } } @@ -937,16 +792,12 @@ ivas_error ivas_td_binaural_renderer_unwrap( /* add reverb to rendered signals */ v_add( reverb_signal[0], output[0], output[0], output_frame ); v_add( reverb_signal[1], output[1], output[1], output_frame ); -#ifdef IVAS_FLOAT_FIXED - for (int i = 0; i < output_frame; i++) - { - output_fx[0][i] = float_to_fix(output[0][i], Q11); - } -#endif } return IVAS_ERR_OK; } +#endif + /*---------------------------------------------------------------------* * TDREND_GetMix() diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 718f453aa31e5794c04e70124986b8701704adfa..ca4989a8b436cf80175a5baae399fa4f9da43b67 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1872,10 +1872,10 @@ typedef struct typedef struct { +#ifndef IVAS_FLOAT_FIXED float *InputFrame_p; /* Input frame pointer */ -#ifdef IVAS_FLOAT_FIXED - Word32 *InputFrame_p_fx; /* Input frame pointer */ /* Q(InputFrame_p_q) */ - Word16 InputFrame_p_q; +#else + Word32 *InputFrame_p_fx; /* Input frame pointer */ /* Q11 */ #endif TDREND_SRC_SPATIAL_t *SrcSpatial_p; TDREND_SRC_REND_t *SrcRend_p; @@ -1883,7 +1883,7 @@ typedef struct int16_t previtd; int16_t filterlength; #ifdef IVAS_FLOAT_FIXED - Word32 mem_itd_fx[ITD_MEM_LEN]; + Word32 mem_itd_fx[ITD_MEM_LEN]; /* Q11 */ Word32 mem_hrf_left_fx[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1]; Word32 mem_hrf_right_fx[SFX_SPAT_BIN_MAX_FILTER_LENGTH - 1]; Word32 hrf_left_prev_fx[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; @@ -1892,7 +1892,7 @@ typedef struct Word16 hrf_right_prev_e; Word32 azim_prev_fx; Word32 elev_prev_fx; - Word16 Gain_fx; // Q14 + Word16 Gain_fx; // Q14 Word16 prevGain_fx; // Q14 #else float mem_itd[ITD_MEM_LEN];