From e8cd4496cce2e1140fd2a77c9f4db84d9db0297b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 16 May 2023 11:42:55 +0200 Subject: [PATCH 1/2] fix decoder crash with stereo output from SBA at 512 kbps --- lib_com/ivas_prot.h | 8 +++++ lib_com/options.h | 2 ++ lib_dec/ivas_cpe_dec.c | 7 ++++- lib_dec/ivas_sba_dirac_stereo_dec.c | 27 ++++++++++++++-- lib_dec/ivas_stereo_dft_dec.c | 49 +++++++++++++++++------------ 5 files changed, 69 insertions(+), 24 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 672b5a7441..88ddd63edc 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1322,6 +1322,10 @@ void stereo_dft_dec( const int16_t cross_fade_start_offset, /* i : SPAR mixer delay compensation */ const int32_t output_Fs, /* i : Fs for delay calculation */ const int16_t nchan_transport /* i : number of transpor channels */ +#ifdef FIX_STEREO_474 + , + const int16_t num_md_sub_frames /* i: number of MD subframes */ +#endif ); void stereo_dft_res_ecu( @@ -3561,6 +3565,10 @@ void ivas_sba_dirac_stereo_smooth_parameters( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */ const int16_t cross_fade_start_offset, /* i : SPAR mixer delay compensation */ const int32_t output_Fs /* i : Fs for delay calculation */ +#ifdef FIX_STEREO_474 + , + const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */ +#endif ); void ivas_sba2mc_cldfb( diff --git a/lib_com/options.h b/lib_com/options.h index 09e65fa5ab..d7362b0749 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -209,6 +209,8 @@ #define FIX_DTX_428 /* FhG: fix for issue 428, crash with DTX and bitrate switching */ +#define FIX_STEREO_474 /* FhG fix for issue 574, crash with SBA to stereo output at 512 kbps */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 186d1c4c7d..350251df70 100755 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -405,7 +405,12 @@ ivas_error ivas_cpe_dec( } else { - stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0 ); + stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0 +#ifdef FIX_STEREO_474 + , + MAX_PARAM_SPATIAL_SUBFRAMES +#endif + ); } /* synthesis iFFT */ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 0894920480..61f67cca0a 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -147,7 +147,7 @@ static int16_t ivas_sba_dirac_stereo_band_config( nbands = 5; } - num_cldfb_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); + num_cldfb_bands = ( int16_t )( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); bins_per_cldfb_band = NFFT / ( 2 * num_cldfb_bands ); @@ -693,6 +693,10 @@ void ivas_sba_dirac_stereo_smooth_parameters( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */ const int16_t cross_fade_start_offset, /* i : SPAR mixer delay compensation */ const int32_t output_Fs /* i : Fs for delay calculation */ +#ifdef FIX_STEREO_474 + , + const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */ +#endif ) { int16_t i, j, k, i_sf; @@ -732,9 +736,12 @@ void ivas_sba_dirac_stereo_smooth_parameters( float xfade_start_ns; int16_t xfade_delay_subframes; int16_t i_hist; +#ifdef FIX_STEREO_474 + int16_t md_sf; +#endif xfade_start_ns = cross_fade_start_offset / (float) output_Fs * 1000000000.f - IVAS_FB_ENC_DELAY_NS; - xfade_delay_subframes = (int16_t) ( xfade_start_ns / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) ); + xfade_delay_subframes = ( int16_t )( xfade_start_ns / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) ); i_hist = 4 - xfade_delay_subframes; @@ -742,6 +749,11 @@ void ivas_sba_dirac_stereo_smooth_parameters( { for ( i_sf = k * 2; i_sf < ( k + 1 ) * 2; i_sf++ ) { + +#ifdef FIX_STEREO_474 + md_sf = ( num_md_sub_frames == MAX_PARAM_SPATIAL_SUBFRAMES ) ? i_sf : 0; +#endif + if ( hStereoDft->first_frame ) { for ( i = 0; i < 2; i++ ) @@ -786,7 +798,11 @@ void ivas_sba_dirac_stereo_smooth_parameters( { for ( b = 0; b < hStereoDft->nbands; b++ ) { +#ifdef FIX_STEREO_474 + hMdDec->mixer_mat_prev[4][i][j][b] = hMdDec->mixer_mat[i][j][b + md_sf * IVAS_MAX_NUM_BANDS]; +#else hMdDec->mixer_mat_prev[4][i][j][b] = hMdDec->mixer_mat[i][j][b + i_sf * IVAS_MAX_NUM_BANDS]; +#endif } } } @@ -881,7 +897,12 @@ void ivas_sba_dirac_stereo_dec( stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, - st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport ); + st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport +#ifdef FIX_STEREO_474 + , + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate ) +#endif + ); /* DFT synthesis */ stereo_dft_dec_synthesize( hCPE, DFT, 0, output[0], output_frame ); diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 08ca989f3d..6719fff8a7 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -316,21 +316,21 @@ static void stereo_dft_dec_open( ) { /*Sizes*/ - hStereoDft->N = (int16_t) ( STEREO_DFT_HOP_MAX * output_Fs / 48000 ); + hStereoDft->N = ( int16_t )( STEREO_DFT_HOP_MAX * output_Fs / 48000 ); /*Init. DFT sizes*/ - hStereoDft->NFFT = (int16_t) ( STEREO_DFT32MS_N_MAX * output_Fs / 48000 ); + hStereoDft->NFFT = ( int16_t )( STEREO_DFT32MS_N_MAX * output_Fs / 48000 ); hStereoDft->dft_trigo_8k = dft_trigo_32k; hStereoDft->dft_trigo_12k8 = dft_trigo_12k8; hStereoDft->dft_trigo_16k = dft_trigo_32k; - hStereoDft->dft32ms_ovl = (int16_t) ( ( STEREO_DFT32MS_OVL_MAX * output_Fs ) / 48000 ); + hStereoDft->dft32ms_ovl = ( int16_t )( ( STEREO_DFT32MS_OVL_MAX * output_Fs ) / 48000 ); hStereoDft->win232ms_8k = dft_win232ms_8k; hStereoDft->win232ms_12k8 = dft_win232ms_12k8; hStereoDft->win232ms_16k = dft_win232ms_16k; - hStereoDft->dft32ms_ovl2 = (int16_t) ( ( STEREO_DFT32MS_OVL2_MAX * output_Fs ) / 48000 ); + hStereoDft->dft32ms_ovl2 = ( int16_t )( ( STEREO_DFT32MS_OVL2_MAX * output_Fs ) / 48000 ); hStereoDft->win32ms_8k = dft_win232ms_8k + 1; hStereoDft->win32ms_12k8 = dft_win232ms_12k8 + 1; hStereoDft->win32ms_16k = dft_win232ms_16k + 1; @@ -825,7 +825,7 @@ void stereo_dft_dec_analyze( pInput = pInput_buff + offset; for ( i = 0; i < 2 * N; i++ ) { - tmp[i] = (int16_t) ( pInput[i] + 0.5f ); + tmp[i] = ( int16_t )( pInput[i] + 0.5f ); } if ( ana_type != DFT_STEREO_DEC_ANA_BPF ) { @@ -1012,7 +1012,7 @@ void stereo_dft_dec_synthesize( if ( hCPE->stereo_switching_counter == 0 ) { /* Set the level of dispersion */ - hCPE->NbFrameMod = (int16_t) ( 12.0f * max( -0.1f, min( 0.4, hCPE->lt_es_em ) ) + 1.2f + 0.5f ); /* -0.1: -0.4 ; -0.1 -> 0, 0.4 -> 6*/ + hCPE->NbFrameMod = ( int16_t )( 12.0f * max( -0.1f, min( 0.4, hCPE->lt_es_em ) ) + 1.2f + 0.5f ); /* -0.1: -0.4 ; -0.1 -> 0, 0.4 -> 6*/ } moffset = max( 0, 6 - hCPE->NbFrameMod ); @@ -1101,7 +1101,7 @@ void stereo_dft_dec_synthesize( for ( i = 0; i < output_frame; i++ ) { - tmp[i] = (int16_t) ( output[i] + 0.5f ); + tmp[i] = ( int16_t )( output[i] + 0.5f ); } sprintf( file_name, "./res/stereo_dft_ch%d_output.pcm", chan ); dbgwrite( tmp, sizeof( int16_t ), output_frame, 1, file_name ); @@ -1131,6 +1131,10 @@ void stereo_dft_dec( const int16_t cross_fade_start_offset, /* i : SPAR mixer delay compensation */ const int32_t output_Fs, /* i : Fs for delay calculation */ const int16_t nchan_transport /* i : number of transpor channels */ +#ifdef FIX_STEREO_474 + , + const int16_t num_md_sub_frames /* i: number of MD subframes */ +#endif ) { int16_t i, k, b, N_div, stop; @@ -1164,7 +1168,7 @@ void stereo_dft_dec( float DFT_W, DFT_Y; - output_frame = (int16_t) ( st0->output_Fs / FRAMES_PER_SEC ); + output_frame = ( int16_t )( st0->output_Fs / FRAMES_PER_SEC ); /*------------------------------------------------------------------* * Initialization @@ -1181,10 +1185,10 @@ void stereo_dft_dec( #ifdef DEBUG_MODE_DFT { int16_t tmps; - int16_t tmp_output_frame = (int16_t) ( st0->output_Fs / FRAMES_PER_SEC ); + int16_t tmp_output_frame = ( int16_t )( st0->output_Fs / FRAMES_PER_SEC ); dbgwrite( &( hStereoDft->attackPresent ), sizeof( int16_t ), 1, tmp_output_frame, "res/stereo_attack.pcm" ); dbgwrite( &( hStereoDft->trans ), sizeof( int16_t ), 1, tmp_output_frame, "res/stereo_trans.pcm" ); - tmps = (int16_t) ( 100.f * ( st0->stab_fac ) + 0.5f ); + tmps = ( int16_t )( 100.f * ( st0->stab_fac ) + 0.5f ); dbgwrite( &tmps, sizeof( int16_t ), 1, tmp_output_frame, "res/stereo_stab.pcm" ); } #endif @@ -1208,7 +1212,12 @@ void stereo_dft_dec( ivas_sba_dirac_stereo_smooth_parameters( hStereoDft, hMdDec, cross_fade_start_offset, - output_Fs ); + output_Fs +#ifdef FIX_STEREO_474 + , + num_md_sub_frames +#endif + ); } else { @@ -1821,7 +1830,7 @@ void stereo_dft_dec_res( for ( i = 0; i < L_FRAME8k; i++ ) { - tmp[i] = (int16_t) ( win[i] ); + tmp[i] = ( int16_t )( win[i] ); } dbgwrite( tmp, sizeof( int16_t ), L_FRAME8k, 1, "./res/stereo_dft_dec_res_decoded.pcm" ); } @@ -2054,7 +2063,7 @@ void stereo_dft_dec_read_BS( } hStereoDft->res_cod_band_max = dft_band_res_cod[hStereoDft->band_res[k_offset]][hStereoDft->res_cod_mode[k_offset]]; - hStereoDft->res_cod_line_max = (int16_t) ( 0.5f + ( hStereoDft->band_limits[hStereoDft->res_cod_band_max] - 1 ) * 2.f * output_frame / (float) ( hStereoDft->NFFT ) ); + hStereoDft->res_cod_line_max = ( int16_t )( 0.5f + ( hStereoDft->band_limits[hStereoDft->res_cod_band_max] - 1 ) * 2.f * output_frame / (float) ( hStereoDft->NFFT ) ); hStereoDft->res_cod_line_max = 8 * ( hStereoDft->res_cod_line_max / 8 ); hStereoDft->res_pred_band_min = max( STEREO_DFT_RES_PRED_BAND_MIN, hStereoDft->res_cod_band_max ); @@ -2454,7 +2463,7 @@ void stereo_dft_dec_read_BS( if ( ivas_total_brate == IVAS_SID_5k2 && ivas_format != MASA_FORMAT ) { - *nb_bits = (int16_t) ( ( element_brate - SID_2k40 ) / FRAMES_PER_SEC ); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; */ + *nb_bits = ( int16_t )( ( element_brate - SID_2k40 ) / FRAMES_PER_SEC ); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; */ } { *total_brate = element_brate - ( *nb_bits * FRAMES_PER_SEC ); @@ -2503,7 +2512,7 @@ static void stereo_dft_compute_td_stefi_params( return; } - bin0 = (int16_t) ( samp_ratio * hStereoDft->NFFT / 2 + .5 ); + bin0 = ( int16_t )( samp_ratio * hStereoDft->NFFT / 2 + .5 ); bin0 = min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); b = hStereoDft->nbands; while ( hStereoDft->band_limits[b] > bin0 ) @@ -2607,7 +2616,7 @@ void stereo_dft_generate_res_pred( /* In ACELP mode the downmix signal is not available in bandwidth extension area. * * Therefore, the downmix energy in the corresponding subbands is estimated. */ - bin0 = (int16_t) ( samp_ratio * hStereoDft->NFFT / 2 + .5 ); + bin0 = ( int16_t )( samp_ratio * hStereoDft->NFFT / 2 + .5 ); bin0 = min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); b = hStereoDft->nbands; while ( hStereoDft->band_limits[b] >= bin0 ) @@ -2677,7 +2686,7 @@ void stereo_dft_generate_res_pred( for ( b = lb_stefi_start_band; b <= band0; b++ ) { d_short_ind = STEREO_DFT_PAST_MAX - STEREO_DFT_STEFFI_DELAY_SHORT + b % 2; - d_long_ind = max( 4, (int16_t) ( ( STEREO_DFT_PAST_MAX + 4 - 1 ) * ( (float) b / ( hStereoDft->nbands - 1 ) ) + 0.5f ) ) - 4; + d_long_ind = max( 4, ( int16_t )( ( STEREO_DFT_PAST_MAX + 4 - 1 ) * ( (float) b / ( hStereoDft->nbands - 1 ) ) + 0.5f ) ) - 4; /* make sure d_short really corresponds to a shorter or equally long delay than d_long (e.g. not always the case for * STEREO_DFT_STEFFI_DELAY_SHORT=3 and STEREO_DFT_STEFFI_DELAY_LONG=4)*/ d_short_ind = max( d_short_ind, d_long_ind ); @@ -2825,7 +2834,7 @@ void stereo_dft_generate_res_pred( { /* TCX/HQ core -> TCX/HQ core: business as usual */ d_short_ind = STEREO_DFT_PAST_MAX - STEREO_DFT_STEFFI_DELAY_SHORT + b % 2; - d_long_ind = max( 4, (int16_t) ( ( STEREO_DFT_PAST_MAX + 4 - 1 ) * ( (float) b / ( hStereoDft->nbands - 1 ) ) + 0.5f ) ) - 4; + d_long_ind = max( 4, ( int16_t )( ( STEREO_DFT_PAST_MAX + 4 - 1 ) * ( (float) b / ( hStereoDft->nbands - 1 ) ) + 0.5f ) ) - 4; /* make sure d_short really corresponds to a shorter or equally long delay than d_long (e.g. not always the case for * STEREO_DFT_STEFFI_DELAY_SHORT=3 and STEREO_DFT_STEFFI_DELAY_LONG=4)*/ d_short_ind = max( d_short_ind, d_long_ind ); @@ -3105,8 +3114,8 @@ void stereo_dft_dec_smooth_parameters( hStereoDft->res_gains_ind[0][b] = hStereoDft->res_gains_ind[0][b + STEREO_DFT_BAND_MAX]; /*stereo_dft_dequantize_res_gains_f(&hStereoDft->res_gains_ind[0][b], &hStereoDft->res_gains_ind[1][b+STEREO_DFT_BAND_MAX],hStereoDft->side_gain+(k+k_offset)*STEREO_DFT_BAND_MAX+b, hStereoDft->res_pred_gain+(k+k_offset)*STEREO_DFT_BAND_MAX+b, 1);*/ - tmps1 = (int16_t) ( hStereoDft->res_gains_ind[0][b] ); - tmps2 = (int16_t) ( hStereoDft->res_gains_ind[1][b + STEREO_DFT_BAND_MAX] ); + tmps1 = ( int16_t )( hStereoDft->res_gains_ind[0][b] ); + tmps2 = ( int16_t )( hStereoDft->res_gains_ind[1][b + STEREO_DFT_BAND_MAX] ); stereo_dft_dequantize_res_gains( &tmps1, &tmps2, hStereoDft->side_gain + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, hStereoDft->res_pred_gain + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, 1 ); if ( hStereoDft->attackPresent ) -- GitLab From 96e608103dab3ced40d630a863276e3d5fcb1f08 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 16 May 2023 12:42:19 +0200 Subject: [PATCH 2/2] fix formatting --- lib_dec/ivas_cpe_dec.c | 8 +++--- lib_dec/ivas_sba_dirac_stereo_dec.c | 14 +++++----- lib_dec/ivas_stereo_dft_dec.c | 40 ++++++++++++++--------------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 350251df70..3717501c83 100755 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -405,12 +405,12 @@ ivas_error ivas_cpe_dec( } else { - stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0 + stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0 #ifdef FIX_STEREO_474 - , - MAX_PARAM_SPATIAL_SUBFRAMES + , + MAX_PARAM_SPATIAL_SUBFRAMES #endif - ); + ); } /* synthesis iFFT */ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 61f67cca0a..3ae5461932 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -147,7 +147,7 @@ static int16_t ivas_sba_dirac_stereo_band_config( nbands = 5; } - num_cldfb_bands = ( int16_t )( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); + num_cldfb_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); bins_per_cldfb_band = NFFT / ( 2 * num_cldfb_bands ); @@ -741,7 +741,7 @@ void ivas_sba_dirac_stereo_smooth_parameters( #endif xfade_start_ns = cross_fade_start_offset / (float) output_Fs * 1000000000.f - IVAS_FB_ENC_DELAY_NS; - xfade_delay_subframes = ( int16_t )( xfade_start_ns / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) ); + xfade_delay_subframes = (int16_t) ( xfade_start_ns / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) ); i_hist = 4 - xfade_delay_subframes; @@ -799,7 +799,7 @@ void ivas_sba_dirac_stereo_smooth_parameters( for ( b = 0; b < hStereoDft->nbands; b++ ) { #ifdef FIX_STEREO_474 - hMdDec->mixer_mat_prev[4][i][j][b] = hMdDec->mixer_mat[i][j][b + md_sf * IVAS_MAX_NUM_BANDS]; + hMdDec->mixer_mat_prev[4][i][j][b] = hMdDec->mixer_mat[i][j][b + md_sf * IVAS_MAX_NUM_BANDS]; #else hMdDec->mixer_mat_prev[4][i][j][b] = hMdDec->mixer_mat[i][j][b + i_sf * IVAS_MAX_NUM_BANDS]; #endif @@ -897,12 +897,12 @@ void ivas_sba_dirac_stereo_dec( stereo_dft_dec( hStereoDft, hCPE->hCoreCoder[0], DFT, NULL, NULL, 1 /*st_ivas->sba_dirac_stereo_flag*/, sba_mono_flag, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hMdDec : NULL, ( st_ivas->hSpar != NULL && !mcmasa ) ? st_ivas->hSpar->hFbMixer->cross_fade_start_offset : 0, - st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport + st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport #ifdef FIX_STEREO_474 - , - ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate ) + , + ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate ) #endif - ); + ); /* DFT synthesis */ stereo_dft_dec_synthesize( hCPE, DFT, 0, output[0], output_frame ); diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 6719fff8a7..cf5542f1e0 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -316,21 +316,21 @@ static void stereo_dft_dec_open( ) { /*Sizes*/ - hStereoDft->N = ( int16_t )( STEREO_DFT_HOP_MAX * output_Fs / 48000 ); + hStereoDft->N = (int16_t) ( STEREO_DFT_HOP_MAX * output_Fs / 48000 ); /*Init. DFT sizes*/ - hStereoDft->NFFT = ( int16_t )( STEREO_DFT32MS_N_MAX * output_Fs / 48000 ); + hStereoDft->NFFT = (int16_t) ( STEREO_DFT32MS_N_MAX * output_Fs / 48000 ); hStereoDft->dft_trigo_8k = dft_trigo_32k; hStereoDft->dft_trigo_12k8 = dft_trigo_12k8; hStereoDft->dft_trigo_16k = dft_trigo_32k; - hStereoDft->dft32ms_ovl = ( int16_t )( ( STEREO_DFT32MS_OVL_MAX * output_Fs ) / 48000 ); + hStereoDft->dft32ms_ovl = (int16_t) ( ( STEREO_DFT32MS_OVL_MAX * output_Fs ) / 48000 ); hStereoDft->win232ms_8k = dft_win232ms_8k; hStereoDft->win232ms_12k8 = dft_win232ms_12k8; hStereoDft->win232ms_16k = dft_win232ms_16k; - hStereoDft->dft32ms_ovl2 = ( int16_t )( ( STEREO_DFT32MS_OVL2_MAX * output_Fs ) / 48000 ); + hStereoDft->dft32ms_ovl2 = (int16_t) ( ( STEREO_DFT32MS_OVL2_MAX * output_Fs ) / 48000 ); hStereoDft->win32ms_8k = dft_win232ms_8k + 1; hStereoDft->win32ms_12k8 = dft_win232ms_12k8 + 1; hStereoDft->win32ms_16k = dft_win232ms_16k + 1; @@ -825,7 +825,7 @@ void stereo_dft_dec_analyze( pInput = pInput_buff + offset; for ( i = 0; i < 2 * N; i++ ) { - tmp[i] = ( int16_t )( pInput[i] + 0.5f ); + tmp[i] = (int16_t) ( pInput[i] + 0.5f ); } if ( ana_type != DFT_STEREO_DEC_ANA_BPF ) { @@ -1012,7 +1012,7 @@ void stereo_dft_dec_synthesize( if ( hCPE->stereo_switching_counter == 0 ) { /* Set the level of dispersion */ - hCPE->NbFrameMod = ( int16_t )( 12.0f * max( -0.1f, min( 0.4, hCPE->lt_es_em ) ) + 1.2f + 0.5f ); /* -0.1: -0.4 ; -0.1 -> 0, 0.4 -> 6*/ + hCPE->NbFrameMod = (int16_t) ( 12.0f * max( -0.1f, min( 0.4, hCPE->lt_es_em ) ) + 1.2f + 0.5f ); /* -0.1: -0.4 ; -0.1 -> 0, 0.4 -> 6*/ } moffset = max( 0, 6 - hCPE->NbFrameMod ); @@ -1101,7 +1101,7 @@ void stereo_dft_dec_synthesize( for ( i = 0; i < output_frame; i++ ) { - tmp[i] = ( int16_t )( output[i] + 0.5f ); + tmp[i] = (int16_t) ( output[i] + 0.5f ); } sprintf( file_name, "./res/stereo_dft_ch%d_output.pcm", chan ); dbgwrite( tmp, sizeof( int16_t ), output_frame, 1, file_name ); @@ -1133,7 +1133,7 @@ void stereo_dft_dec( const int16_t nchan_transport /* i : number of transpor channels */ #ifdef FIX_STEREO_474 , - const int16_t num_md_sub_frames /* i: number of MD subframes */ + const int16_t num_md_sub_frames /* i: number of MD subframes */ #endif ) { @@ -1168,7 +1168,7 @@ void stereo_dft_dec( float DFT_W, DFT_Y; - output_frame = ( int16_t )( st0->output_Fs / FRAMES_PER_SEC ); + output_frame = (int16_t) ( st0->output_Fs / FRAMES_PER_SEC ); /*------------------------------------------------------------------* * Initialization @@ -1185,10 +1185,10 @@ void stereo_dft_dec( #ifdef DEBUG_MODE_DFT { int16_t tmps; - int16_t tmp_output_frame = ( int16_t )( st0->output_Fs / FRAMES_PER_SEC ); + int16_t tmp_output_frame = (int16_t) ( st0->output_Fs / FRAMES_PER_SEC ); dbgwrite( &( hStereoDft->attackPresent ), sizeof( int16_t ), 1, tmp_output_frame, "res/stereo_attack.pcm" ); dbgwrite( &( hStereoDft->trans ), sizeof( int16_t ), 1, tmp_output_frame, "res/stereo_trans.pcm" ); - tmps = ( int16_t )( 100.f * ( st0->stab_fac ) + 0.5f ); + tmps = (int16_t) ( 100.f * ( st0->stab_fac ) + 0.5f ); dbgwrite( &tmps, sizeof( int16_t ), 1, tmp_output_frame, "res/stereo_stab.pcm" ); } #endif @@ -1830,7 +1830,7 @@ void stereo_dft_dec_res( for ( i = 0; i < L_FRAME8k; i++ ) { - tmp[i] = ( int16_t )( win[i] ); + tmp[i] = (int16_t) ( win[i] ); } dbgwrite( tmp, sizeof( int16_t ), L_FRAME8k, 1, "./res/stereo_dft_dec_res_decoded.pcm" ); } @@ -2063,7 +2063,7 @@ void stereo_dft_dec_read_BS( } hStereoDft->res_cod_band_max = dft_band_res_cod[hStereoDft->band_res[k_offset]][hStereoDft->res_cod_mode[k_offset]]; - hStereoDft->res_cod_line_max = ( int16_t )( 0.5f + ( hStereoDft->band_limits[hStereoDft->res_cod_band_max] - 1 ) * 2.f * output_frame / (float) ( hStereoDft->NFFT ) ); + hStereoDft->res_cod_line_max = (int16_t) ( 0.5f + ( hStereoDft->band_limits[hStereoDft->res_cod_band_max] - 1 ) * 2.f * output_frame / (float) ( hStereoDft->NFFT ) ); hStereoDft->res_cod_line_max = 8 * ( hStereoDft->res_cod_line_max / 8 ); hStereoDft->res_pred_band_min = max( STEREO_DFT_RES_PRED_BAND_MIN, hStereoDft->res_cod_band_max ); @@ -2463,7 +2463,7 @@ void stereo_dft_dec_read_BS( if ( ivas_total_brate == IVAS_SID_5k2 && ivas_format != MASA_FORMAT ) { - *nb_bits = ( int16_t )( ( element_brate - SID_2k40 ) / FRAMES_PER_SEC ); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; */ + *nb_bits = (int16_t) ( ( element_brate - SID_2k40 ) / FRAMES_PER_SEC ); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; */ } { *total_brate = element_brate - ( *nb_bits * FRAMES_PER_SEC ); @@ -2512,7 +2512,7 @@ static void stereo_dft_compute_td_stefi_params( return; } - bin0 = ( int16_t )( samp_ratio * hStereoDft->NFFT / 2 + .5 ); + bin0 = (int16_t) ( samp_ratio * hStereoDft->NFFT / 2 + .5 ); bin0 = min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); b = hStereoDft->nbands; while ( hStereoDft->band_limits[b] > bin0 ) @@ -2616,7 +2616,7 @@ void stereo_dft_generate_res_pred( /* In ACELP mode the downmix signal is not available in bandwidth extension area. * * Therefore, the downmix energy in the corresponding subbands is estimated. */ - bin0 = ( int16_t )( samp_ratio * hStereoDft->NFFT / 2 + .5 ); + bin0 = (int16_t) ( samp_ratio * hStereoDft->NFFT / 2 + .5 ); bin0 = min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); b = hStereoDft->nbands; while ( hStereoDft->band_limits[b] >= bin0 ) @@ -2686,7 +2686,7 @@ void stereo_dft_generate_res_pred( for ( b = lb_stefi_start_band; b <= band0; b++ ) { d_short_ind = STEREO_DFT_PAST_MAX - STEREO_DFT_STEFFI_DELAY_SHORT + b % 2; - d_long_ind = max( 4, ( int16_t )( ( STEREO_DFT_PAST_MAX + 4 - 1 ) * ( (float) b / ( hStereoDft->nbands - 1 ) ) + 0.5f ) ) - 4; + d_long_ind = max( 4, (int16_t) ( ( STEREO_DFT_PAST_MAX + 4 - 1 ) * ( (float) b / ( hStereoDft->nbands - 1 ) ) + 0.5f ) ) - 4; /* make sure d_short really corresponds to a shorter or equally long delay than d_long (e.g. not always the case for * STEREO_DFT_STEFFI_DELAY_SHORT=3 and STEREO_DFT_STEFFI_DELAY_LONG=4)*/ d_short_ind = max( d_short_ind, d_long_ind ); @@ -2834,7 +2834,7 @@ void stereo_dft_generate_res_pred( { /* TCX/HQ core -> TCX/HQ core: business as usual */ d_short_ind = STEREO_DFT_PAST_MAX - STEREO_DFT_STEFFI_DELAY_SHORT + b % 2; - d_long_ind = max( 4, ( int16_t )( ( STEREO_DFT_PAST_MAX + 4 - 1 ) * ( (float) b / ( hStereoDft->nbands - 1 ) ) + 0.5f ) ) - 4; + d_long_ind = max( 4, (int16_t) ( ( STEREO_DFT_PAST_MAX + 4 - 1 ) * ( (float) b / ( hStereoDft->nbands - 1 ) ) + 0.5f ) ) - 4; /* make sure d_short really corresponds to a shorter or equally long delay than d_long (e.g. not always the case for * STEREO_DFT_STEFFI_DELAY_SHORT=3 and STEREO_DFT_STEFFI_DELAY_LONG=4)*/ d_short_ind = max( d_short_ind, d_long_ind ); @@ -3114,8 +3114,8 @@ void stereo_dft_dec_smooth_parameters( hStereoDft->res_gains_ind[0][b] = hStereoDft->res_gains_ind[0][b + STEREO_DFT_BAND_MAX]; /*stereo_dft_dequantize_res_gains_f(&hStereoDft->res_gains_ind[0][b], &hStereoDft->res_gains_ind[1][b+STEREO_DFT_BAND_MAX],hStereoDft->side_gain+(k+k_offset)*STEREO_DFT_BAND_MAX+b, hStereoDft->res_pred_gain+(k+k_offset)*STEREO_DFT_BAND_MAX+b, 1);*/ - tmps1 = ( int16_t )( hStereoDft->res_gains_ind[0][b] ); - tmps2 = ( int16_t )( hStereoDft->res_gains_ind[1][b + STEREO_DFT_BAND_MAX] ); + tmps1 = (int16_t) ( hStereoDft->res_gains_ind[0][b] ); + tmps2 = (int16_t) ( hStereoDft->res_gains_ind[1][b + STEREO_DFT_BAND_MAX] ); stereo_dft_dequantize_res_gains( &tmps1, &tmps2, hStereoDft->side_gain + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, hStereoDft->res_pred_gain + ( k + k_offset ) * STEREO_DFT_BAND_MAX + b, 1 ); if ( hStereoDft->attackPresent ) -- GitLab