From 7d56ec798fbc0b13ae061919ac7d6e64d975edb1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Jun 2023 12:25:45 +0200 Subject: [PATCH 01/12] formatting --- lib_com/core_com_config.c | 17 +- lib_com/ivas_dirac_com.c | 4 +- lib_com/ivas_masa_com.c | 13 +- lib_com/ivas_prot.h | 6 +- lib_com/ivas_spar_com.c | 84 +++++----- lib_com/prot.h | 17 +- lib_dec/ivas_cpe_dec.c | 3 +- lib_dec/ivas_dirac_dec.c | 69 +++----- lib_dec/ivas_dirac_output_synthesis_dec.c | 191 +++++++++++----------- lib_dec/ivas_init_dec.c | 8 +- lib_dec/ivas_masa_dec.c | 18 +- lib_dec/ivas_qmetadata_dec.c | 29 ++-- lib_dec/ivas_sba_dec.c | 7 +- lib_dec/ivas_sce_dec.c | 2 +- lib_dec/lsf_dec.c | 4 +- lib_dec/tonalMDCTconcealment.c | 6 +- lib_enc/ivas_decision_matrix_enc.c | 3 +- lib_enc/ivas_masa_enc.c | 18 +- lib_enc/ivas_qmetadata_enc.c | 64 ++++---- lib_enc/lib_enc.c | 5 +- 20 files changed, 253 insertions(+), 315 deletions(-) diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index 49ca422052..0ee9b40ae0 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -165,9 +165,9 @@ int16_t get_codec_mode( int16_t getTcxonly( const int16_t element_mode, /* i : IVAS element mode */ const int32_t total_brate, /* i : total bitrate */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ - , - const int16_t is_ism_format ) + const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const int16_t is_ism_format /* i : flag indicating ISM format */ +) { int16_t tcxonly = 0; @@ -353,12 +353,11 @@ int16_t sr2fscale( *-------------------------------------------------------------------*/ int32_t getCoreSamplerateMode2( - const int16_t element_mode, /* i : IVAS element mode */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */ - const int16_t rf_mode /* i : flag to signal the RF mode */ - , + const int16_t element_mode, /* i : IVAS element mode */ + const int32_t total_brate, /* i : total bitrate */ + const int16_t bwidth, /* i : audio bandwidth */ + const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */ + const int16_t rf_mode, /* i : flag to signal the RF mode */ const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ ) { diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 85370e3596..20f4b24953 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -94,10 +94,8 @@ ivas_error ivas_dirac_config( ivas_error error; int16_t spar_dirac_split_band; IVAS_FB_MIXER_HANDLE hFbMdft; - int16_t *dirac_to_spar_md_bands; - error = IVAS_ERR_OK; if ( enc_dec == ENC ) @@ -176,7 +174,6 @@ ivas_error ivas_dirac_config( hConfig->enc_param_start_band = hQMetaData->q_direction[0].cfg.start_band + spar_dirac_split_band; } - hConfig->dec_param_estim = TRUE; if ( hConfig->dec_param_estim == TRUE ) { @@ -452,6 +449,7 @@ ivas_error ivas_dirac_sba_config( return error; } } + ivas_get_dirac_sba_max_md_bits( sba_total_brate, &hQMetaData->bits_frame_nominal, &hQMetaData->metadata_max_bits, &hQMetaData->qmetadata_max_bit_req, hQMetaData->q_direction[0].cfg.nbands ); return error; diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 8c821d99fd..b1a6c256d2 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -324,7 +324,7 @@ void masa_sample_rate_band_correction( int16_t *band_mapping, /* i/o: Band mapping used and modified */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ const uint8_t maxBand, /* i : max band */ - uint8_t is_encoder, /* i: signals if called at encoder */ + uint8_t is_encoder, /* i : signals if called at encoder */ MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ ) { @@ -332,7 +332,6 @@ void masa_sample_rate_band_correction( int16_t highBand; uint8_t numBands48k; - numBands48k = config->numCodingBands; for ( band = 1; band < config->numCodingBands + 1; band++ ) @@ -343,6 +342,7 @@ void masa_sample_rate_band_correction( { config->numCodingBands = band; hQMetaData->numCodingBands = band; + if ( is_encoder ) { if ( hQMetaData->q_direction->cfg.nbands > band ) @@ -354,7 +354,9 @@ void masa_sample_rate_band_correction( hQMetaData->q_direction[1].cfg.nbands = band; } } + band_mapping[band] = maxBand; + break; } } @@ -396,6 +398,7 @@ void masa_sample_rate_band_correction( hQMetaData->twoDirBands[band] = 0; } } + if ( hExtOutMeta != NULL ) { /* in decoder, zero the EXT out MASA meta buffer */ @@ -637,11 +640,7 @@ void deindex_sph_idx( int16_t id_phi; int16_t no_th = gridData->no_theta; const int16_t *n = gridData->no_phi; - const float ba[3] = { - 2.137991118026424e+02f, - 1.244854404591542e+02f, - 1.228408647140870e+02f, - }; + const float ba[3] = { 2.137991118026424e+02f, 1.244854404591542e+02f, 1.228408647140870e+02f }; const float del[3] = { 7.998262115303199e+05f, 1.300883976959332e+06f, 1.424072242426373e+06f }; const float div[3] = { -0.237662341081474f, -0.100938185496887f, -0.092050209205032f }; const float a4[3] = { -8.415300425381099f, -19.814106922515204f, -21.727272727270197f }; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 646d025ec3..d6b28dfe71 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3130,7 +3130,7 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */ uint16_t *bitstream, /* i : bitstream */ int16_t *index, /* i/o: bitstream position */ - const SPHERICAL_GRID_DATA *sph_grid16, /* i: spherical grid for deindexing */ + const SPHERICAL_GRID_DATA *sph_grid16, /* i : spherical grid for deindexing */ const int16_t bits_sph_idx, const int16_t bits_sp_coh, const uint8_t ncoding_bands_config @@ -3152,7 +3152,7 @@ void ivas_qmetadata_to_dirac( MASA_DECODER_HANDLE hMasa, /* i : MASA decoder structure */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ + const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ); @@ -5087,7 +5087,7 @@ void masa_sample_rate_band_correction( int16_t *band_mapping, /* i/o: Band mapping used and modified */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ const uint8_t maxBand, /* i : max band */ - uint8_t is_encoder, /* i: signals if called at encoder */ + uint8_t is_encoder, /* i : signals if called at encoder */ MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ ); diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index c56421103d..ebc9c89466 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -1675,18 +1675,15 @@ void ivas_get_spar_md_from_dirac( float **ppMixer_mat[IVAS_MAX_FB_MIXER_OUT_CH]; float *pMixer_mat[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH]; float en_ratio_fac, diff_norm_order1, diff_norm_order2, diff_norm_order3; - int16_t ndm, foa_ch, hoa2_ch; float P_dir_fact[IVAS_SPAR_MAX_CH - 1]; const int16_t *remix_order; remix_order = remix_order_set[hSpar_md_cfg->remix_unmix_order]; - num_ch = ivas_sba_get_nchan_metadata( order, IVAS_256k /*dummy value as order is always 1 in this function*/ - ); + num_ch = ivas_sba_get_nchan_metadata( order, IVAS_256k /*dummy value as order is always 1 in this function*/ ); - hoa2_ch = ivas_sba_get_nchan_metadata( SBA_HOA2_ORDER, IVAS_256k /*dummy value as order is always 1 in this function*/ - ); + hoa2_ch = ivas_sba_get_nchan_metadata( SBA_HOA2_ORDER, IVAS_256k /*dummy value as order is always 1 in this function*/ ); foa_ch = FOA_CHANNELS; diff_norm_order1 = 3.0f; @@ -1835,67 +1832,66 @@ void ivas_get_spar_md_from_dirac( en_ratio_fac = ( 1.0f - diffuseness[band] ); + + for ( i = 0; i < num_ch; i++ ) { - for ( i = 0; i < num_ch; i++ ) + for ( j = 0; j < num_ch; j++ ) { - for ( j = 0; j < num_ch; j++ ) + if ( i == j ) { - if ( i == j ) + if ( i == 0 ) { - if ( i == 0 ) - { - cov_real_dirac[i][i][band] = 1.0f; - } - else + cov_real_dirac[i][i][band] = 1.0f; + } + else + { + cov_real_dirac[i][j][band] = en_ratio_fac * response_avg[i] * response_avg[j]; + + if ( hSpar_md_cfg->nchan_transport <= 2 ) { - cov_real_dirac[i][j][band] = en_ratio_fac * response_avg[i] * response_avg[j]; - if ( hSpar_md_cfg->nchan_transport <= 2 ) + cov_real_dirac[i][j][band] *= en_ratio_fac; + if ( ( i >= ndm ) && ( dtx_vad == 1 ) ) { - - cov_real_dirac[i][j][band] *= en_ratio_fac; - if ( ( i >= ndm ) && ( dtx_vad == 1 ) ) - { - cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) * P_dir_fact[i - ndm]; - } - else - { - if ( i < foa_ch ) - { - cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) / diff_norm_order1; - } - else if ( i < hoa2_ch ) - { - cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) / diff_norm_order2; - } - else - { - cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) / diff_norm_order3; - } - } + cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) * P_dir_fact[i - ndm]; } else { if ( i < foa_ch ) { - cov_real_dirac[i][j][band] += ( 1.0f - en_ratio_fac ) / diff_norm_order1; + cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) / diff_norm_order1; } else if ( i < hoa2_ch ) { - cov_real_dirac[i][j][band] += ( 1.0f - en_ratio_fac ) / diff_norm_order2; + cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) / diff_norm_order2; } else { - cov_real_dirac[i][j][band] += ( 1.0f - en_ratio_fac ) / diff_norm_order3; + cov_real_dirac[i][j][band] += ( 1.0f - ( en_ratio_fac * en_ratio_fac ) ) / diff_norm_order3; } } } - } - else - { - cov_real_dirac[i][j][band] = en_ratio_fac * response_avg[i] * response_avg[j]; + else + { + if ( i < foa_ch ) + { + cov_real_dirac[i][j][band] += ( 1.0f - en_ratio_fac ) / diff_norm_order1; + } + else if ( i < hoa2_ch ) + { + cov_real_dirac[i][j][band] += ( 1.0f - en_ratio_fac ) / diff_norm_order2; + } + else + { + cov_real_dirac[i][j][band] += ( 1.0f - en_ratio_fac ) / diff_norm_order3; + } + } } } + else + { + cov_real_dirac[i][j][band] = en_ratio_fac * response_avg[i] * response_avg[j]; + } } } } @@ -2138,7 +2134,6 @@ void ivas_spar_set_bitrate_config( int16_t quant_strat; int16_t bands_bw; - pSpar_md_cfg->nchan_transport = ivas_spar_br_table_consts[table_idx].nchan_transport; for ( i = 0; i < pSpar_md_cfg->nchan_transport; i++ ) @@ -2257,6 +2252,7 @@ void ivas_spar_set_bitrate_config( { pca_bits = 0; } + pSpar_md_cfg->max_md_bits_spar = pSpar_md_cfg->max_bits_per_blk + agc_bits + pca_bits; } diff --git a/lib_com/prot.h b/lib_com/prot.h index 6cfbf0855d..4a16cde9a9 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -9765,9 +9765,9 @@ int16_t get_codec_mode( int16_t getTcxonly( const int16_t element_mode, /* i : IVAS element mode */ const int32_t total_brate, /* i : total bitrate */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/ - , - const int16_t is_ism_format ); + const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const int16_t is_ism_format /* i : flag indicating ISM format */ +); int16_t getTnsAllowed( const int32_t total_brate, /* i : total bitrate */ @@ -9799,12 +9799,11 @@ int16_t sr2fscale( ); int32_t getCoreSamplerateMode2( - const int16_t element_mode, /* i : IVAS element mode */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t bwidth, /* i : audio bandwidth */ - const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */ - const int16_t rf_mode /* i : flag to signal the RF mode */ - , + const int16_t element_mode, /* i : IVAS element mode */ + const int32_t total_brate, /* i : total bitrate */ + const int16_t bwidth, /* i : audio bandwidth */ + const int16_t flag_ACELP16k, /* i : ACELP@16kHz flag */ + const int16_t rf_mode, /* i : flag to signal the RF mode */ const IVAS_FORMAT is_ism_format /* i : flag indicating ISM format */ ); diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index a2683860df..6ca33fcf5e 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -405,8 +405,7 @@ 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, - MAX_PARAM_SPATIAL_SUBFRAMES ); + stereo_dft_dec( hCPE->hStereoDft, sts[0], DFT, hCPE->input_mem[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); } /* synthesis iFFT */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 521baa405f..de955b81be 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -851,15 +851,8 @@ ivas_error ivas_dirac_dec_config( /* close and reopen the decorrelator */ ivas_dirac_dec_decorr_close( &hDirAC->h_freq_domain_decorr_ap_params, &hDirAC->h_freq_domain_decorr_ap_state ); - if ( ( error = ivas_dirac_dec_decorr_open( &( hDirAC->h_freq_domain_decorr_ap_params ), - &( hDirAC->h_freq_domain_decorr_ap_state ), - hDirAC->num_freq_bands, - hDirAC->num_outputs_diff, - hDirAC->num_protos_diff, - hDirAC->synthesisConf, - hDirAC->frequency_axis, - nchan_transport > 2 ? 4 : nchan_transport, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_dec_decorr_open( &( hDirAC->h_freq_domain_decorr_ap_params ), &( hDirAC->h_freq_domain_decorr_ap_state ), hDirAC->num_freq_bands, hDirAC->num_outputs_diff, + hDirAC->num_protos_diff, hDirAC->synthesisConf, hDirAC->frequency_axis, nchan_transport > 2 ? 4 : nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -869,8 +862,7 @@ ivas_error ivas_dirac_dec_config( /* output synthesis */ if ( flag_config == DIRAC_OPEN ) { - if ( ( ivas_dirac_dec_output_synthesis_open( hDirAC, st_ivas->renderer_type, nchan_transport, output_Fs, - hodirac_flag ) ) != IVAS_ERR_OK ) + if ( ( ivas_dirac_dec_output_synthesis_open( hDirAC, st_ivas->renderer_type, nchan_transport, output_Fs, hodirac_flag ) ) != IVAS_ERR_OK ) { return error; } @@ -880,8 +872,7 @@ ivas_error ivas_dirac_dec_config( { ivas_dirac_dec_output_synthesis_close( hDirAC ); - if ( ( ivas_dirac_dec_output_synthesis_open( hDirAC, st_ivas->renderer_type, nchan_transport, output_Fs, - hodirac_flag ) ) != IVAS_ERR_OK ) + if ( ( ivas_dirac_dec_output_synthesis_open( hDirAC, st_ivas->renderer_type, nchan_transport, output_Fs, hodirac_flag ) ) != IVAS_ERR_OK ) { return error; } @@ -975,16 +966,14 @@ ivas_error ivas_dirac_dec_config( } /* output synthesis */ - ivas_dirac_dec_output_synthesis_init( hDirAC, nchan_out_woLFE, - hodirac_flag ); + ivas_dirac_dec_output_synthesis_init( hDirAC, nchan_out_woLFE, hodirac_flag ); /* Allocate stack memory */ if ( flag_config != DIRAC_OPEN ) { ivas_dirac_free_mem( &( hDirAC->stack_mem ) ); } - if ( ( error = ivas_dirac_alloc_mem( hDirAC, st_ivas->renderer_type, &( hDirAC->stack_mem ), - hodirac_flag ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_alloc_mem( hDirAC, st_ivas->renderer_type, &( hDirAC->stack_mem ), hodirac_flag ) ) != IVAS_ERR_OK ) { return error; } @@ -1060,6 +1049,7 @@ ivas_error ivas_dirac_dec_config( hDirAC->dithering_seed = DIRAC_DITH_SEED; st_ivas->hDirAC = hDirAC; } + /* allocate transport channels*/ if ( flag_config == DIRAC_OPEN ) { @@ -1160,7 +1150,6 @@ void ivas_dirac_dec_close( hDirAC->proto_index_dir = NULL; } - /* States */ /* free prototype signal buffers */ @@ -1720,8 +1709,7 @@ void ivas_dirac_dec_read_BS( hQMetaData->q_direction[0].cfg.nblocks = MAX_PARAM_SPATIAL_SUBFRAMES; } - *nb_bits += ivas_qmetadata_dec_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), - hodirac_flag ); + *nb_bits += ivas_qmetadata_dec_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), hodirac_flag ); } #ifdef DEBUGGING @@ -1736,6 +1724,7 @@ void ivas_dirac_dec_read_BS( /* subtract mode signaling bits, since bitstream was moved after mode reading */ st->next_bit_pos = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC - 1 - SID_FORMAT_NBITS ); + /* 1 bit flag for SPAR/DirAC, already read in read format function */ b = st->bit_stream[( st->next_bit_pos )--]; ( *nb_bits )++; @@ -1779,9 +1768,7 @@ void ivas_dirac_dec_read_BS( if ( hDirAC != NULL ) { - ivas_qmetadata_to_dirac( hQMetaData, hDirAC, NULL, ivas_total_brate, SBA_FORMAT, - hodirac_flag, - dirac_to_spar_md_bands ); + ivas_qmetadata_to_dirac( hQMetaData, hDirAC, NULL, ivas_total_brate, SBA_FORMAT, hodirac_flag, dirac_to_spar_md_bands ); } return; @@ -1795,13 +1782,13 @@ void ivas_dirac_dec_read_BS( *-----------------------------------------------------------------------*/ void ivas_qmetadata_to_dirac( - const IVAS_QMETADATA_HANDLE hQMetaData, /* i : frame of MASA q_metadata */ - DIRAC_DEC_HANDLE hDirAC, /* o : DirAC decoder structure */ - MASA_DECODER_HANDLE hMasa, /* i : MASA decoder structure */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ + const IVAS_QMETADATA_HANDLE hQMetaData, /* i : frame of MASA q_metadata */ + DIRAC_DEC_HANDLE hDirAC, /* o : DirAC decoder structure */ + MASA_DECODER_HANDLE hMasa, /* i : MASA decoder structure */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ + int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) { int16_t block, band; @@ -1935,8 +1922,7 @@ void ivas_qmetadata_to_dirac( hDirAC->hConfig->nbands = q_direction->cfg.nbands; } - ivas_dirac_config_bands( hDirAC->band_grouping, hDirAC->hConfig->nbands, nbands, - dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hDirAC->hConfig->enc_param_start_band, hDirAC->hFbMdft ); + ivas_dirac_config_bands( hDirAC->band_grouping, hDirAC->hConfig->nbands, nbands, dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hDirAC->hConfig->enc_param_start_band, hDirAC->hFbMdft ); nbands = hDirAC->hConfig->nbands; if ( hQMetaData->q_direction[0].cfg.nblocks == 0 ) @@ -2005,7 +1991,6 @@ void ivas_qmetadata_to_dirac( { int16_t block_qmetadata; - block_qmetadata = min( block, nblocks - 1 ); block_qmetadata = max( block_qmetadata, 0 ); @@ -2046,7 +2031,6 @@ void ivas_qmetadata_to_dirac( ele = max( -90, ele ); } - if ( ivas_total_brate > IVAS_SID_5k2 && q_direction->coherence_band_data != NULL ) { hDirAC->spreadCoherence[tmp_write_idx_band][b] = q_direction->coherence_band_data[qBand_idx].spread_coherence[block] / 255.0f; @@ -2067,7 +2051,6 @@ void ivas_qmetadata_to_dirac( hDirAC->energy_ratio1[tmp_write_idx_band][b] = q_direction->band_data[qBand_idx].energy_ratio[0]; - hDirAC->diffuseness_vector[tmp_write_idx_band][b] = diffuseness; if ( hodirac_flag ) @@ -2123,6 +2106,7 @@ void ivas_qmetadata_to_dirac( /* update buffer write index */ hDirAC->dirac_bs_md_write_idx = ( hDirAC->dirac_bs_md_write_idx + MAX_PARAM_SPATIAL_SUBFRAMES ) % hDirAC->dirac_md_buffer_length; + return; } @@ -2247,10 +2231,12 @@ void ivas_dirac_dec( { st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } + for ( n = 0; n < nchan_transport; n++ ) { st_ivas->hTcBuffer->tc[n] = NULL; } + if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->ivas_format != SBA_FORMAT ) { st_ivas->hTcBuffer->tc[nchan_transport] = NULL; @@ -2316,6 +2302,7 @@ void ivas_dirac_dec_render( output_f_local[ch] += n_samples_sf; } } + if ( hDirAC->slots_rendered == hDirAC->num_slots ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -2429,7 +2416,7 @@ void ivas_dirac_dec_render_sf( { md_idx = hDirAC->render_to_md_map[slot_idx_start]; } - /* Another workaround for self test BE */ + /* ToDo: Another workaround for self test BE */ /* copy parameters into local buffers*/ if ( hDirAC->hConfig->dec_param_estim == FALSE ) @@ -2711,6 +2698,7 @@ void ivas_dirac_dec_render_sf( hDirAC->buffer_intensity_real[0][index - 1], hDirAC->buffer_intensity_real[1][index - 1], hDirAC->buffer_intensity_real[2][index - 1] ); + computeDirectionAngles( hDirAC->buffer_intensity_real[0][index - 1], hDirAC->buffer_intensity_real[1][index - 1], hDirAC->buffer_intensity_real[2][index - 1], @@ -2720,10 +2708,7 @@ void ivas_dirac_dec_render_sf( mvr2r( reference_power, &( hDirAC->buffer_energy[( index - 1 ) * num_freq_bands] ), num_freq_bands ); - computeDiffuseness( hDirAC->buffer_intensity_real, - hDirAC->buffer_energy, - num_freq_bands, - hDirAC->diffuseness_vector[md_idx] ); + computeDiffuseness( hDirAC->buffer_intensity_real, hDirAC->buffer_energy, num_freq_bands, hDirAC->diffuseness_vector[md_idx] ); } #ifdef DEBUG_MODE_DIRAC @@ -2859,9 +2844,7 @@ void ivas_dirac_dec_render_sf( hDirAC->hOutSetup, nchan_transport, md_idx, - hodirac_flag - - ); + hodirac_flag ); } else { diff --git a/lib_dec/ivas_dirac_output_synthesis_dec.c b/lib_dec/ivas_dirac_output_synthesis_dec.c index f1a5597175..084fd7b96e 100755 --- a/lib_dec/ivas_dirac_output_synthesis_dec.c +++ b/lib_dec/ivas_dirac_output_synthesis_dec.c @@ -622,116 +622,116 @@ void ivas_dirac_dec_output_synthesis_process_slot( } else // ( hDirAC->hConfig->dec_param_estim == TRUE ) if ( hDirAC->hConfig->dec_param_estim == TRUE ) - { + { - /* compute direct responses */ - ivas_dirac_dec_compute_directional_responses( hDirAC, - hVBAPdata, - NULL, - azimuth, - elevation, - md_idx, - NULL, - sh_rot_max_order, - p_Rmat, - hodirac_flag ); + /* compute direct responses */ + ivas_dirac_dec_compute_directional_responses( hDirAC, + hVBAPdata, + NULL, + azimuth, + elevation, + md_idx, + NULL, + sh_rot_max_order, + p_Rmat, + hodirac_flag ); - if ( hDirAC->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - ivas_dirac_dec_compute_gain_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); + if ( hDirAC->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + ivas_dirac_dec_compute_gain_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); - v_multc( h_dirac_output_synthesis_state->direct_power_factor, - 0.25f, - h_dirac_output_synthesis_state->direct_power_factor, - num_freq_bands ); - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - 0.25f, - h_dirac_output_synthesis_state->diffuse_power_factor, - num_freq_bands ); + v_multc( h_dirac_output_synthesis_state->direct_power_factor, + 0.25f, + h_dirac_output_synthesis_state->direct_power_factor, + num_freq_bands ); + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + 0.25f, + h_dirac_output_synthesis_state->diffuse_power_factor, + num_freq_bands ); - /*Direct gain*/ - for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) + /*Direct gain*/ + for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) + { + int16_t k; + if ( ch_idx != 0 ) { - int16_t k; - if ( ch_idx != 0 ) - { - float a, b, c; + float a, b, c; - /*Directonal sound gain nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) - { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); - } - for ( ; k < num_freq_bands; k++ ) - { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); - } + /*Directonal sound gain nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); } - else + for ( ; k < num_freq_bands; k++ ) { - /*Diffuseness modellling nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); - } - for ( ; k < num_freq_bands; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); - } + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); } } - - /*Directional gain (panning)*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) - { - v_mult( h_dirac_output_synthesis_state->direct_power_factor, - &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], - aux_buf, - num_freq_bands ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - num_freq_bands ); - } - - /*Diffuse gain*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) + else { - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - hDirAC->diffuse_response_function[ch_idx], - aux_buf, - num_freq_bands_diff ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - num_freq_bands_diff ); + /*Diffuseness modellling nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); + } + for ( ; k < num_freq_bands; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); + } } + } - return; + /*Directional gain (panning)*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) + { + v_mult( h_dirac_output_synthesis_state->direct_power_factor, + &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], + aux_buf, + num_freq_bands ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + num_freq_bands ); } - else + + /*Diffuse gain*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) { - /* compute reference and diffuse power factor for this frame */ - ivas_dirac_dec_compute_power_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + hDirAC->diffuse_response_function[ch_idx], + aux_buf, + num_freq_bands_diff ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + num_freq_bands_diff ); } + + return; } + else + { + /* compute reference and diffuse power factor for this frame */ + ivas_dirac_dec_compute_power_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); + } + } diff_start_band = 0; if ( h_dirac_output_synthesis_params->use_onset_filters ) @@ -1134,9 +1134,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( * Copy output or HOA decoder *-----------------------------------------------------------------*/ - if ( hDirAC->hOutSetup.is_loudspeaker_setup && hDirAC->hoa_decoder != NULL - - ) + if ( hDirAC->hOutSetup.is_loudspeaker_setup && hDirAC->hoa_decoder != NULL ) { float *p_real, *p_imag; const float *hoa_decoder; @@ -1266,6 +1264,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( /*-----------------------------------------------------------------* * compute target PSDs *-----------------------------------------------------------------*/ + if ( hDirAC->hConfig->enc_param_start_band == 0 ) { diff_start_band = h_dirac_output_synthesis_params->use_onset_filters == 1 ? h_dirac_output_synthesis_params->max_band_decorr : 0; @@ -1293,6 +1292,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( h_dirac_output_synthesis_state->diffuse_responses_square, h_dirac_output_synthesis_state->cy_auto_diff_smooth ); } + /*-----------------------------------------------------------------* * compute variables for stereo transport signal type detection *-----------------------------------------------------------------*/ @@ -1491,6 +1491,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( /*-----------------------------------------------------------------* * gain interpolation and output streams *-----------------------------------------------------------------*/ + for ( buf_idx = 0; buf_idx < nbslots; ++buf_idx ) { g1 = h_dirac_output_synthesis_params->interpolator[buf_idx]; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index b746baf47b..dcb644695d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -889,12 +889,7 @@ ivas_error ivas_init_decoder( } } - if ( ( error = ivas_dirac_sba_config( - st_ivas->hQMetaData, - &st_ivas->element_mode_init, - ivas_total_brate, - st_ivas->sba_analysis_order, - ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) { return error; } @@ -2026,6 +2021,7 @@ void ivas_init_dec_get_num_cldfb_instances( default: assert( 0 && "Renderer not handled for CLDFB reservation." ); } + if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) { *numCldfbAnalyses = max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbAnalyses ); diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 45f56875ff..0576fe8121 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -133,6 +133,7 @@ ivas_error ivas_masa_decode( /* the number of MASA transport channels was read in ivas_dec_setup() */ st->next_bit_pos -= MASA_TRANSP_BITS; *nb_bits_read += MASA_TRANSP_BITS; + /* Placeholder for descriptive metadata content */ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; byteBuffer += st->bit_stream[( st->next_bit_pos )--]; @@ -195,19 +196,16 @@ ivas_error ivas_masa_decode( { if ( ivas_total_brate >= IVAS_512k ) { - *nb_bits_read += ivas_qmetadata_dec_decode_hr_384_512( hQMetaData, st->bit_stream, &st->next_bit_pos, hMasa->data.sph_grid16, 16, 4, - hMasa->config.numCodingBands ); + *nb_bits_read += ivas_qmetadata_dec_decode_hr_384_512( hQMetaData, st->bit_stream, &st->next_bit_pos, hMasa->data.sph_grid16, 16, 4, hMasa->config.numCodingBands ); } else { - *nb_bits_read += ivas_qmetadata_dec_decode_hr_384_512( hQMetaData, st->bit_stream, &st->next_bit_pos, hMasa->data.sph_grid16, 11, 3, - hMasa->config.numCodingBands ); + *nb_bits_read += ivas_qmetadata_dec_decode_hr_384_512( hQMetaData, st->bit_stream, &st->next_bit_pos, hMasa->data.sph_grid16, 11, 3, hMasa->config.numCodingBands ); } } else { - *nb_bits_read += ivas_qmetadata_dec_decode( hQMetaData, st->bit_stream, &st->next_bit_pos, - 0 ); + *nb_bits_read += ivas_qmetadata_dec_decode( hQMetaData, st->bit_stream, &st->next_bit_pos, 0 ); } /* Get direction decoding quality. EC 1 and 2 are handled by the default value. */ @@ -243,8 +241,7 @@ ivas_error ivas_masa_decode( return error; } - ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, - hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE ); + ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE ); hQMetaData->metadata_max_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC; @@ -290,10 +287,7 @@ ivas_error ivas_masa_decode( } if ( st_ivas->hDirAC != NULL ) { - ivas_qmetadata_to_dirac( hQMetaData, st_ivas->hDirAC, hMasa, ivas_total_brate, - ivas_format, - 0, - 0 ); + ivas_qmetadata_to_dirac( hQMetaData, st_ivas->hDirAC, hMasa, ivas_total_brate, ivas_format, 0, 0 ); } st->next_bit_pos = next_bit_pos_orig; diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index a9fc4693f0..d8572c5bef 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -270,7 +270,6 @@ int16_t ivas_qmetadata_dec_decode( dir2ratio = ( 1.0f - diffRatio ) - dir1ratio; } - /* Requantize the 1 - dirRatio separately for each direction to obtain inverted dirRatio index. These are used in further decoding. */ hQMetaData->q_direction[0].band_data[b].energy_ratio_index[0] = masa_sq( 1.0f - dir1ratio, diffuseness_thresholds, DIRAC_DIFFUSE_LEVELS ); if ( hodirac_flag ) @@ -337,8 +336,7 @@ int16_t ivas_qmetadata_dec_decode( index_dirRatio1Inv = hQMetaData->q_direction[0].band_data[b].energy_ratio_index[0]; index_dirRatio2Inv = hQMetaData->q_direction[1].band_data[dir2band].energy_ratio_index[0]; - masa_compensate_two_dir_energy_ratio_index( index_dirRatio1Inv, index_dirRatio2Inv, &index_dirRatio1Inv_mod, &index_dirRatio2Inv_mod, - hodirac_flag ); + masa_compensate_two_dir_energy_ratio_index( index_dirRatio1Inv, index_dirRatio2Inv, &index_dirRatio1Inv_mod, &index_dirRatio2Inv_mod, hodirac_flag ); for ( m = 0; m < hQMetaData->q_direction[0].cfg.nblocks; m++ ) { @@ -439,8 +437,7 @@ int16_t ivas_qmetadata_dec_decode( if ( all_coherence_zero == 0 ) { - bits_coherence = read_coherence_data( bitstream, index, hQMetaData, d, - 0 ); + bits_coherence = read_coherence_data( bitstream, index, hQMetaData, d, 0 ); } else { @@ -488,13 +485,11 @@ int16_t ivas_qmetadata_dec_decode( if ( raw_flag[0] == 0 ) { - bits_dir += ivas_qmetadata_entropy_decode_dir( q_direction, bitstream, index, diffuseness_index_max_ec_frame, nbands, start_band, - 0 ); + bits_dir += ivas_qmetadata_entropy_decode_dir( q_direction, bitstream, index, diffuseness_index_max_ec_frame, nbands, start_band, 0 ); } else { - bits_dir += ivas_qmetadata_raw_decode_dir( q_direction, bitstream, index, nbands, start_band, - 0 ); + bits_dir += ivas_qmetadata_raw_decode_dir( q_direction, bitstream, index, nbands, start_band, 0 ); } } /* Decode quantized directions band-wise */ @@ -514,8 +509,7 @@ int16_t ivas_qmetadata_dec_decode( { if ( raw_flag[b] == 0 ) { - bits_dir += ivas_qmetadata_entropy_decode_dir( q_direction, bitstream, index, diffuseness_index_max_ec_frame, b + 1, b, - 0 ); + bits_dir += ivas_qmetadata_entropy_decode_dir( q_direction, bitstream, index, diffuseness_index_max_ec_frame, b + 1, b, 0 ); } else { @@ -559,8 +553,7 @@ int16_t ivas_qmetadata_dec_decode( { if ( raw_flag[b] ) { - bits_dir += ivas_qmetadata_raw_decode_dir( q_direction, bitstream, index, b + 1, b, - 0 ); + bits_dir += ivas_qmetadata_raw_decode_dir( q_direction, bitstream, index, b + 1, b, 0 ); } } } @@ -594,8 +587,7 @@ int16_t ivas_qmetadata_dec_decode( { if ( nblocks > 1 ) { - decode_spread_coherence( hQMetaData, d, nblocks, - 0 ); + decode_spread_coherence( hQMetaData, d, nblocks, 0 ); } } else @@ -3235,8 +3227,7 @@ static void decode_spread_coherence( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: quantized metadata structure */ int16_t idx_d, /* i : direction index */ const int16_t no_frames, /* i : number of time subframes */ - - const int16_t hrmasa_flag /* i : flag indicating high-rate MASA MD coding */ + const int16_t hrmasa_flag /* i : flag indicating high-rate MASA MD coding */ ) { int16_t i, j; @@ -3918,6 +3909,7 @@ static int16_t read_surround_coherence( uint16_t idx_sur_coh[MASA_MAXIMUM_CODING_SUBBANDS]; IVAS_QDIRECTION *q_direction; int16_t min_index; + coding_subbands = hQMetaData->q_direction[0].cfg.nbands; q_direction = hQMetaData->q_direction; @@ -3966,6 +3958,7 @@ static int16_t read_surround_coherence( } } } + return bits_sur_coherence; } @@ -4011,6 +4004,7 @@ static int16_t read_surround_coherence( { hQMetaData->surcoh_band_data[j].sur_coherence_index = idx_sur_coh[j]; } + hQMetaData->surcoh_band_data[j].surround_coherence[0] = sur_coherence_cb_masa[idx_cb_sur_coh_masa[idx_ER[j]] * MASA_MAX_NO_CV_SUR_COH + hQMetaData->surcoh_band_data[j].sur_coherence_index]; } } @@ -4104,7 +4098,6 @@ static int16_t read_surround_coherence_hr( error_ratio_surr = 1.0f - q_direction[0].band_data[j].energy_ratio[sf]; } - if ( error_ratio_surr <= 0 ) { error_ratio_surr = 0; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 429916d17e..22258a9365 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -288,12 +288,7 @@ ivas_error ivas_sba_dec_reconfigure( mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hDirAC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } - if ( ( error = ivas_dirac_sba_config( - st_ivas->hQMetaData, - &st_ivas->element_mode_init, - ivas_total_brate, - st_ivas->sba_analysis_order, - ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index e1472d2a37..af9d98248d 100755 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -243,8 +243,8 @@ ivas_error ivas_sce_dec( { int32_t output_Fs; - output_Fs = st_ivas->hDecoderConfig->output_Fs; + /*----------------------------------------------------------------* * LB synthesis synchronization between IVAS formats *----------------------------------------------------------------*/ diff --git a/lib_dec/lsf_dec.c b/lib_dec/lsf_dec.c index 9db7119aa2..119cf7ecf2 100644 --- a/lib_dec/lsf_dec.c +++ b/lib_dec/lsf_dec.c @@ -286,9 +286,9 @@ void lsf_end_dec( nBits = nBits_in; *nb_indices = 0; - if ( coder_type_org == GENERIC && st->sr_core == INT_FS_16k && st->codec_mode == MODE1 && ( st->idchan == 0 ) /* this bit is used only for primary channel or mono */ - ) + if ( coder_type_org == GENERIC && st->sr_core == INT_FS_16k && st->codec_mode == MODE1 && st->idchan == 0 ) { + /* this bit is used only for primary channel or mono */ coder_type = get_next_indice( st, 1 ); coder_type += 2; if ( coder_type == GENERIC || ( coder_type == VOICED && flag_1bit_gran == 1 ) ) diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 041e3a3d2f..86340ab181 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -421,10 +421,10 @@ void TonalMDCTConceal_Detect( int16_t nBands; nSamples = hTonalMDCTConc->nSamples; - if ( hTonalMDCTConc->lastBlockData.blockIsValid && hTonalMDCTConc->secondLastBlockData.blockIsValid && ( hTonalMDCTConc->lastBlockData.nSamples == nSamples ) && ( hTonalMDCTConc->secondLastBlockData.nSamples == nSamples ) && ( !hTonalMDCTConc->secondLastBlockData.blockIsConcealed || hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive || ( pitchLag != 0 ) ) - /* Safety if the second last frame was concealed and tonal concealment was inactive */ - ) + if ( hTonalMDCTConc->lastBlockData.blockIsValid && hTonalMDCTConc->secondLastBlockData.blockIsValid && ( hTonalMDCTConc->lastBlockData.nSamples == nSamples ) && ( hTonalMDCTConc->secondLastBlockData.nSamples == nSamples ) && ( !hTonalMDCTConc->secondLastBlockData.blockIsConcealed || hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive || ( pitchLag != 0 ) ) ) { + /* Safety if the second last frame was concealed and tonal concealment was inactive */ + if ( !hTonalMDCTConc->lastBlockData.blockIsConcealed ) { if ( !hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index 8f3a9de2f1..18cd1ab806 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -277,8 +277,7 @@ void ivas_decision_matrix_enc( if ( st->total_brate >= MIN_BRATE_SWB_BWE /*&& (*coder_type != AUDIO || st->total_brate >= (MIN_BWE_PRI_BRATE+600))*/ || ( st->total_brate >= MIN_MIN_BRATE_LRTD_SWB_BWE && st->element_mode == IVAS_CPE_TD && st->bwidth == SWB && st->tdm_LRTD_flag ) || ( element_brate < IVAS_16k4 && st->total_brate >= MIN_MIN_BRATE_LRTD_SWB_BWE && st->element_mode == IVAS_CPE_TD && st->bwidth == SWB ) ) { - if ( ( ( ( st->sp_aud_decision1 == 1 && st->sp_aud_decision2 == 0 ) || st->coder_type == INACTIVE ) && !st->GSC_noisy_speech ) /* Note: SWB BWE is not used for GSC noisy speech */ - ) + if ( ( ( ( st->sp_aud_decision1 == 1 && st->sp_aud_decision2 == 0 ) || st->coder_type == INACTIVE ) && !st->GSC_noisy_speech ) /* Note: SWB BWE is not used for GSC noisy speech */ ) { st->extl = SWB_BWE; st->extl_brate = SWB_BWE_1k6; diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 802654c02c..ec8c22bcd9 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -73,6 +73,7 @@ static void detect_framing_async( MASA_ENCODER_HANDLE hMasa ); static void masa_metadata_direction_alignment( MASA_ENCODER_HANDLE hMasa ); + /*-----------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------*/ @@ -125,8 +126,7 @@ ivas_error ivas_masa_enc_open( } } - ivas_masa_set_elements( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, - st_ivas->hQMetaData, &hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE ); + ivas_masa_set_elements( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, st_ivas->hQMetaData, &hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE ); mvs2s( DirAC_block_grouping, hMasa->config.block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); mvs2s( MASA_band_grouping_24, hMasa->config.band_grouping, MASA_FREQUENCY_BANDS + 1 ); @@ -176,7 +176,6 @@ void ivas_masa_enc_close( deleteCldfb( &( ( *hMasa )->data.cldfbAnaEnc[i] ) ); } - free( ( *hMasa ) ); ( *hMasa ) = NULL; @@ -327,8 +326,7 @@ ivas_error ivas_masa_encode( } else { - ivas_qmetadata_enc_encode( hMetaData, hQMetaData, - 0 ); + ivas_qmetadata_enc_encode( hMetaData, hQMetaData, 0 ); } *nb_bits_metadata = hMetaData->nb_bits_tot; @@ -463,7 +461,6 @@ void ivas_masa_estimate_energy( } } - return; } @@ -497,8 +494,7 @@ ivas_error ivas_masa_enc_config( ivas_format = st_ivas->hEncoderConfig->ivas_format; ivas_total_brate = st_ivas->hEncoderConfig->ivas_total_brate; - ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, - hQMetaData, &st_ivas->hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE ); + ivas_masa_set_elements( ivas_total_brate, st_ivas->mc_mode, st_ivas->nchan_transport, hQMetaData, &st_ivas->hEncoderConfig->element_mode_init, &st_ivas->nSCE, &st_ivas->nCPE ); hQMetaData->is_masa_ivas_format = 1; if ( ivas_format == MASA_FORMAT ) @@ -509,11 +505,8 @@ ivas_error ivas_masa_enc_config( if ( hMasa->data.sync_state.frame_mode == MASA_FRAME_1SF && hMasa->data.sync_state.prev_offset != 0 ) { - /* average over sub-frames */ - average_masa_metadata( &( hMasa->masaMetadata ), hMasa->data.energy, - &( hMasa->data.Sph_Grid16 ), - ivas_total_brate == IVAS_512k ? TRUE : FALSE ); + average_masa_metadata( &( hMasa->masaMetadata ), hMasa->data.energy, &( hMasa->data.Sph_Grid16 ), ivas_total_brate == IVAS_512k ? TRUE : FALSE ); } /* Inspect metadata for parameter changes that affect coding. */ @@ -2184,7 +2177,6 @@ static void masa_metadata_direction_alignment( ) { uint8_t band, n_dirs; - MASA_DIR_ALIGN_HANDLE hAlignState; MASA_METADATA_HANDLE hMeta; diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index ad34d810c1..17b6e5c841 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -51,7 +51,6 @@ static float direction_distance( float elevation[DIRAC_MAX_NBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], float azimuth[DIRAC_MAX_NBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], IVAS_QDIRECTION *q_direction, const int16_t dim1, const int16_t dim2, float mat_dist[DIRAC_MAX_NBANDS][MAX_PARAM_SPATIAL_SUBFRAMES] ); #endif - static void ivas_qmetadata_quantize_diffuseness_nrg_ratios( IVAS_QMETADATA_HANDLE hQMetaData, int16_t *needed_bits, int16_t *nbits_diff, int16_t *dfRatioBits, const int16_t hodirac_flag ); static int16_t ivas_qmetadata_entropy_encode_diffuseness( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, uint16_t *diffuseness_index_max_ec_frame ); @@ -138,9 +137,9 @@ static int16_t ivas_qmetadata_quantize_coherence_hr_512( IVAS_QMETADATA *hQMetaD *-----------------------------------------------------------------------*/ ivas_error ivas_qmetadata_enc_encode( - BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ - IVAS_QMETADATA *hQMetaData, /* i/o: metadata handle */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode*/ + BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ + IVAS_QMETADATA *hQMetaData, /* i/o: metadata handle */ + const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ ) { int16_t i, bit_pos_start, bit_pos_start_coh; @@ -265,8 +264,7 @@ ivas_error ivas_qmetadata_enc_encode( } /*Quantization of the Diffuseness */ - ivas_qmetadata_quantize_diffuseness_nrg_ratios( hQMetaData, bits_dir_raw_pre, bits_diff, dfRatio_bits, - hodirac_flag ); + ivas_qmetadata_quantize_diffuseness_nrg_ratios( hQMetaData, bits_dir_raw_pre, bits_diff, dfRatio_bits, hodirac_flag ); bits_diff_sum = 0; bits_diff[0] = ivas_qmetadata_entropy_encode_diffuseness( hMetaData, &( hQMetaData->q_direction[0] ), &diffuseness_index_max_ec_frame_pre[0] ); @@ -405,8 +403,7 @@ ivas_error ivas_qmetadata_enc_encode( if ( all_coherence_zero == 0 ) { - bits_coherence[d] = ivas_qmetadata_quantize_coherence( hQMetaData, d, all_coherence_zero, hMetaData, 0, &indice_coherence, - 0 ); + bits_coherence[d] = ivas_qmetadata_quantize_coherence( hQMetaData, d, all_coherence_zero, hMetaData, 0, &indice_coherence, 0 ); } if ( q_direction->cfg.mc_ls_setup == MC_LS_SETUP_5_1 || q_direction->cfg.mc_ls_setup == MC_LS_SETUP_7_1 ) @@ -418,8 +415,7 @@ ivas_error ivas_qmetadata_enc_encode( else { /* Quantize directions*/ - quantize_direction_frame( q_direction, azimuth_orig, elevation_orig, - 0 ); + quantize_direction_frame( q_direction, azimuth_orig, elevation_orig, 0 ); } /* Signalling 2D*/ @@ -452,9 +448,7 @@ ivas_error ivas_qmetadata_enc_encode( bits_dir_bands[0] = ivas_qmetadata_raw_encode_dir( NULL, q_direction, q_direction->cfg.nbands, q_direction->cfg.start_band ); reduce_bits = hQMetaData->is_masa_ivas_format ? ( total_bits_1dir - ( bits_diff[d] + bits_coherence[d] + bits_signaling[d] ) - 1 ) : MASA_MAX_BITS; - bits_ec = ivas_qmetadata_entropy_encode_dir( hMetaData, q_direction, diffuseness_index_max_ec_frame, - q_direction->cfg.nbands, q_direction->cfg.start_band, bits_dir_bands[0], reduce_bits, - 0 ); + bits_ec = ivas_qmetadata_entropy_encode_dir( hMetaData, q_direction, diffuseness_index_max_ec_frame, q_direction->cfg.nbands, q_direction->cfg.start_band, bits_dir_bands[0], reduce_bits, 0 ); if ( bits_ec < 0 ) { @@ -508,8 +502,7 @@ ivas_error ivas_qmetadata_enc_encode( bits_dir_bands[i] = ivas_qmetadata_raw_encode_dir( NULL, q_direction, i + 1, i ); /* Write ec bits */ - bits_ec = ivas_qmetadata_entropy_encode_dir( hMetaData, q_direction, diffuseness_index_max_ec_frame, i + 1, i, bits_dir_bands[i], MASA_MAX_BITS, - 0 ); + bits_ec = ivas_qmetadata_entropy_encode_dir( hMetaData, q_direction, diffuseness_index_max_ec_frame, i + 1, i, bits_dir_bands[i], MASA_MAX_BITS, 0 ); if ( bits_ec >= 0 ) { @@ -612,8 +605,7 @@ ivas_error ivas_qmetadata_enc_encode( { bit_pos_start = hMetaData->nb_bits_tot; hMetaData->nb_bits_tot = bit_pos_start_coh; - ivas_qmetadata_quantize_coherence( hQMetaData, d, all_coherence_zero, hMetaData, 1, &indice_coherence, - 0 ); + ivas_qmetadata_quantize_coherence( hQMetaData, d, all_coherence_zero, hMetaData, 1, &indice_coherence, 0 ); hMetaData->nb_bits_tot = bit_pos_start; } @@ -946,6 +938,7 @@ ivas_error ivas_qmetadata_enc_encode_hr_384_512( } } } + if ( hQMetaData->q_direction->cfg.inactiveBands > 0 ) { hQMetaData->q_direction[0].cfg.nbands += hQMetaData->q_direction->cfg.inactiveBands; @@ -954,6 +947,7 @@ ivas_error ivas_qmetadata_enc_encode_hr_384_512( hQMetaData->q_direction[1].cfg.nbands += hQMetaData->q_direction->cfg.inactiveBands; } } + return error; } @@ -1186,6 +1180,7 @@ void ivas_qmetadata_enc_sid_encode( return; } + /*------------------------------------------------------------------------- * reset_metadata_spatial() * @@ -1205,7 +1200,6 @@ void reset_metadata_spatial( #ifdef IND_LIST_DYN int16_t j; #endif - int16_t metadata_sid_bits; if ( core_brate == SID_2k40 || core_brate == FRAME_NO_DATA ) @@ -1441,8 +1435,7 @@ static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr( * fact that with 2dir data, it is harder to achieve separate high direct-to-total ratio values * which are assumed by the direction quantization system. In practice, this improves direction * accuracy when it is perceptual meaningful. */ - masa_compensate_two_dir_energy_ratio_index( index_dirRatio1Inv, index_dirRatio2Inv, &index_dirRatio1Inv_mod, &index_dirRatio2Inv_mod, - 0 ); + masa_compensate_two_dir_energy_ratio_index( index_dirRatio1Inv, index_dirRatio2Inv, &index_dirRatio1Inv_mod, &index_dirRatio2Inv_mod, 0 ); for ( k = 0; k < hQMetaData->q_direction[0].cfg.nblocks; k++ ) { @@ -1770,8 +1763,7 @@ static void ivas_qmetadata_quantize_diffuseness_nrg_ratios( * fact that with 2dir data, it is harder to achieve separate high direct-to-total ratio values * which are assumed by the direction quantization system. In practice, this improves direction * accuracy when it is perceptual meaningful. */ - masa_compensate_two_dir_energy_ratio_index( index_dirRatio1Inv, index_dirRatio2Inv, &index_dirRatio1Inv_mod, &index_dirRatio2Inv_mod, - hodirac_flag ); + masa_compensate_two_dir_energy_ratio_index( index_dirRatio1Inv, index_dirRatio2Inv, &index_dirRatio1Inv_mod, &index_dirRatio2Inv_mod, hodirac_flag ); for ( k = 0; k < hQMetaData->q_direction[0].cfg.nblocks; k++ ) { @@ -2538,8 +2530,7 @@ static int16_t ivas_qmetadata_entropy_encode_dir( { for ( j = 0; j < nblocks; j++ ) { - direction_bits_ec += ivas_qmetadata_encode_quasi_uniform_length( - q_direction->band_data[i].azimuth_index[j], q_direction->band_data[i].azimuth_m_alphabet[j] ); + direction_bits_ec += ivas_qmetadata_encode_quasi_uniform_length( q_direction->band_data[i].azimuth_index[j], q_direction->band_data[i].azimuth_m_alphabet[j] ); } } } @@ -2617,7 +2608,6 @@ static int16_t ivas_qmetadata_entropy_encode_dir( avg_elevation_index_best = -1; /* out of range value */ gr_param_elevation_best = -1; /* out of range value */ - for ( avg_elevation_offset = 0; avg_elevation_offset < q_direction->cfg.search_effort; avg_elevation_offset++ ) { if ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) @@ -3575,6 +3565,7 @@ static int16_t common_direction( return 0; } + if ( bits_allowed <= len + 1 ) { set_f( q_direction->band_data[band_idx].elevation, 0.0f, len ); @@ -5445,10 +5436,10 @@ static void dct4_transform( *-------------------------------------------------------------------*/ static int16_t ivas_qmetadata_quantize_coherence_hr_512( - IVAS_QMETADATA *hQMetaData, /* i/o: quantized metadata */ - const int16_t idx_d, /* i : current direction index */ - const int16_t all_coherence_zero, /* i : all coherence is zero - flag */ - BSTR_ENC_HANDLE hMetaData, /* i : metadata handle */ + IVAS_QMETADATA *hQMetaData, /* i/o: quantized metadata */ + const int16_t idx_d, /* i : current direction index */ + const int16_t all_coherence_zero, /* i : all coherence is zero - flag */ + BSTR_ENC_HANDLE hMetaData, /* i : metadata handle */ const int16_t bits_coh ) { int16_t j, k; @@ -5489,7 +5480,6 @@ static int16_t ivas_qmetadata_quantize_coherence_hr_512( } } - nbits0 = 0; nbits1 = 0; for ( j = 0; j < nbands; j++ ) @@ -5507,6 +5497,7 @@ static int16_t ivas_qmetadata_quantize_coherence_hr_512( { GR_param = 1; } + GR_param_av = 1; nbits_av = mean_removed_GR_new( idx_coh, cbsize, nbands, 1, &GR_param_av, &av, mr_idx ); @@ -5514,12 +5505,16 @@ static int16_t ivas_qmetadata_quantize_coherence_hr_512( { nbits1 = nbits_av; GR_param = GR_param_av; + /* use average removed */ push_next_indice( hMetaData, 1, 1 ); + /* write average */ push_next_indice( hMetaData, av, bits_coh ); + /* write GR param */ push_next_indice( hMetaData, GR_param, 1 ); + for ( j = 0; j < nbands; j++ ) { ivas_qmetadata_encode_extended_gr( hMetaData, mr_idx[j], 2 * cbsize, GR_param ); @@ -5529,10 +5524,13 @@ static int16_t ivas_qmetadata_quantize_coherence_hr_512( { /* use min removed */ push_next_indice( hMetaData, 0, 1 ); + /* write min index */ push_next_indice( hMetaData, min_idx, bits_coh ); + /* write GR param */ push_next_indice( hMetaData, GR_param, 1 ); + for ( j = 0; j < nbands; j++ ) { ivas_qmetadata_encode_extended_gr( hMetaData, idx_coh[j], cbsize - min_idx, GR_param ); @@ -5587,8 +5585,7 @@ static int16_t ivas_qmetadata_quantize_coherence( if ( hQMetaData->q_direction[idx_d].cfg.nblocks == 1 ) { - nbits = encode_spread_coherence_1sf( hQMetaData, idx_d, hMetaData, - hrmasa_flag ); + nbits = encode_spread_coherence_1sf( hQMetaData, idx_d, hMetaData, hrmasa_flag ); return nbits; } @@ -5657,8 +5654,7 @@ static int16_t ivas_qmetadata_quantize_coherence( if ( write_flag ) { /* quantize first DCT parameter */ - dct_coh[j][0] = quantize_DCT_0_coh( dct_coh[j][0], j, coherence_cb0_masa, MASA_DELTA_AZI_DCT0, MASA_NO_CV_COH, q_direction, &idx_dct[k], &no_cb_vec[j], - hrmasa_flag ); + dct_coh[j][0] = quantize_DCT_0_coh( dct_coh[j][0], j, coherence_cb0_masa, MASA_DELTA_AZI_DCT0, MASA_NO_CV_COH, q_direction, &idx_dct[k], &no_cb_vec[j], hrmasa_flag ); } if ( coding_subbands < coding_subbands_0 ) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index bb8eeadc5f..244ebd22a4 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -897,9 +897,8 @@ static ivas_error configureEncoder( } if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_format != MONO_FORMAT && - ( ( hEncoderConfig->ivas_format == SBA_FORMAT && ivas_get_sba_num_TCs( hEncoderConfig->ivas_total_brate, 1 ) > 2 ) || // ToDo: support for 3+ TCs to be done - hEncoderConfig->ivas_format == MC_FORMAT // ToDo: TBD - ) ) + ( ( hEncoderConfig->ivas_format == SBA_FORMAT && ivas_get_sba_num_TCs( hEncoderConfig->ivas_total_brate, 1 ) > 2 ) || + hEncoderConfig->ivas_format == MC_FORMAT ) ) { return IVAS_ERROR( IVAS_ERR_DTX_NOT_SUPPORTED, "DTX is not supported in this IVAS format and element mode." ); } -- GitLab From 33637e4214971160dd0ed290fc08a1c24fcfb0bf Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Jun 2023 13:29:43 +0200 Subject: [PATCH 02/12] clang-format --- lib_dec/ivas_dirac_output_synthesis_dec.c | 184 +++++++++++----------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/lib_dec/ivas_dirac_output_synthesis_dec.c b/lib_dec/ivas_dirac_output_synthesis_dec.c index 084fd7b96e..4f25d5a465 100755 --- a/lib_dec/ivas_dirac_output_synthesis_dec.c +++ b/lib_dec/ivas_dirac_output_synthesis_dec.c @@ -622,116 +622,116 @@ void ivas_dirac_dec_output_synthesis_process_slot( } else // ( hDirAC->hConfig->dec_param_estim == TRUE ) if ( hDirAC->hConfig->dec_param_estim == TRUE ) - { + { - /* compute direct responses */ - ivas_dirac_dec_compute_directional_responses( hDirAC, - hVBAPdata, - NULL, - azimuth, - elevation, - md_idx, - NULL, - sh_rot_max_order, - p_Rmat, - hodirac_flag ); + /* compute direct responses */ + ivas_dirac_dec_compute_directional_responses( hDirAC, + hVBAPdata, + NULL, + azimuth, + elevation, + md_idx, + NULL, + sh_rot_max_order, + p_Rmat, + hodirac_flag ); - if ( hDirAC->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) - { - ivas_dirac_dec_compute_gain_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); + if ( hDirAC->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) + { + ivas_dirac_dec_compute_gain_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); - v_multc( h_dirac_output_synthesis_state->direct_power_factor, - 0.25f, - h_dirac_output_synthesis_state->direct_power_factor, - num_freq_bands ); - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - 0.25f, - h_dirac_output_synthesis_state->diffuse_power_factor, - num_freq_bands ); + v_multc( h_dirac_output_synthesis_state->direct_power_factor, + 0.25f, + h_dirac_output_synthesis_state->direct_power_factor, + num_freq_bands ); + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + 0.25f, + h_dirac_output_synthesis_state->diffuse_power_factor, + num_freq_bands ); - /*Direct gain*/ - for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) - { - int16_t k; - if ( ch_idx != 0 ) + /*Direct gain*/ + for ( ch_idx = 0; ch_idx < min( 4, nchan_transport ); ch_idx++ ) { - float a, b, c; - - /*Directonal sound gain nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) + int16_t k; + if ( ch_idx != 0 ) { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); + float a, b, c; + + /*Directonal sound gain nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); + } + for ( ; k < num_freq_bands; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; + b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); + c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); + } } - for ( ; k < num_freq_bands; k++ ) + else { - a = h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands + k]; - b = reference_power[k + num_freq_bands] / ( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] + EPSILON ); - c = 1.f + ( 1.f / 6.f ) * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ); /*Diffuseness modellling nrg compensation*/ - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( diffuseness[k] * c + ( ( 1.f - diffuseness[k] ) * a * a * b ) ); + /*Diffuseness modellling nrg compensation*/ + for ( k = 0; k < num_freq_bands_diff; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); + } + for ( ; k < num_freq_bands; k++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); + } } } - else + + /*Directional gain (panning)*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) { - /*Diffuseness modellling nrg compensation*/ - for ( k = 0; k < num_freq_bands_diff; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) ); - } - for ( ; k < num_freq_bands; k++ ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands + k] += 0.25f * sqrtf( 1.0f + diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor - 1.f ) ); - } + v_mult( h_dirac_output_synthesis_state->direct_power_factor, + &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], + aux_buf, + num_freq_bands ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], + num_freq_bands ); } - } - /*Directional gain (panning)*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) - { - v_mult( h_dirac_output_synthesis_state->direct_power_factor, - &h_dirac_output_synthesis_state->direct_responses[ch_idx * num_freq_bands], - aux_buf, - num_freq_bands ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - &h_dirac_output_synthesis_state->cy_cross_dir_smooth[ch_idx * num_freq_bands], - num_freq_bands ); - } + /*Diffuse gain*/ + for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) + { + v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, + hDirAC->diffuse_response_function[ch_idx], + aux_buf, + num_freq_bands_diff ); + + v_add( aux_buf, + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], + num_freq_bands_diff ); + } - /*Diffuse gain*/ - for ( ch_idx = min( 4, nchan_transport ); ch_idx < num_channels_diff; ch_idx++ ) + return; + } + else { - v_multc( h_dirac_output_synthesis_state->diffuse_power_factor, - hDirAC->diffuse_response_function[ch_idx], - aux_buf, - num_freq_bands_diff ); - - v_add( aux_buf, - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - &h_dirac_output_synthesis_state->cy_auto_diff_smooth[ch_idx * num_freq_bands_diff], - num_freq_bands_diff ); + /* compute reference and diffuse power factor for this frame */ + ivas_dirac_dec_compute_power_factors( num_freq_bands, + diffuseness, + h_dirac_output_synthesis_params->max_band_decorr, + h_dirac_output_synthesis_state->direct_power_factor, + h_dirac_output_synthesis_state->diffuse_power_factor ); } - - return; - } - else - { - /* compute reference and diffuse power factor for this frame */ - ivas_dirac_dec_compute_power_factors( num_freq_bands, - diffuseness, - h_dirac_output_synthesis_params->max_band_decorr, - h_dirac_output_synthesis_state->direct_power_factor, - h_dirac_output_synthesis_state->diffuse_power_factor ); } - } diff_start_band = 0; if ( h_dirac_output_synthesis_params->use_onset_filters ) -- GitLab From a1e7c1b6eb13817e48b075688a72d8f8d9b4ddb9 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 15 Jun 2023 22:47:27 +0200 Subject: [PATCH 03/12] formatting of if condition --- lib_enc/ivas_mdct_core_enc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 4239973c25..e749b2c803 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -361,7 +361,7 @@ static void applyStereoPreProcessingCplx( dmxR1 = valR1 * factDe + sign * valR2 * factIn; /* cross */ dmxR2 = valR2 * factDe + sign * valR1 * factIn; /* -talk */ - if ( fabsf( dmxR1 ) < absR1 + absR2 ) /* avoid destructive summations */ + if ( fabsf( dmxR1 ) < absR1 + absR2 ) /* avoid destructive summations */ { if ( absR1 * factDe < absR2 * factIn ) { @@ -882,8 +882,7 @@ void ivas_mdct_core_whitening_enc( } /* MCT: detect whether there are silent channels and set mct_chan_mode accordingly */ - if ( - mct_on ) + if ( mct_on ) { chE_tot = sum_f( chE, NB_DIV ); -- GitLab From b78134782b0468421d29ac6a8248836310fd7718 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jun 2023 10:33:37 +0200 Subject: [PATCH 04/12] formatting --- lib_dec/core_dec_init.c | 6 ++---- lib_dec/core_dec_switch.c | 3 +-- lib_dec/ivas_mct_core_dec.c | 3 +-- lib_dec/ivas_mct_dec.c | 28 +++++++++++++--------------- lib_dec/ivas_tcx_core_dec.c | 6 ++---- lib_enc/core_enc_init.c | 6 ++---- lib_enc/core_enc_switch.c | 9 +++------ lib_enc/ivas_core_pre_proc.c | 3 +-- lib_enc/ivas_mct_core_enc.c | 15 +++++---------- lib_enc/ivas_mct_enc.c | 13 +++++++------ lib_enc/ivas_tcx_core_enc.c | 3 +-- 11 files changed, 38 insertions(+), 57 deletions(-) diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index 9b29ba03ab..3ceee9a2f4 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -74,8 +74,7 @@ void open_decoder_LPD( st->fscale_old = st->fscale; } - st->sr_core = getCoreSamplerateMode2( st->element_mode, total_brate, bwidth, st->flag_ACELP16k, st->rf_flag, - st->is_ism_format ); + st->sr_core = getCoreSamplerateMode2( st->element_mode, total_brate, bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format ); st->fscale = sr2fscale( st->sr_core ); fscaleFB = sr2fscale( st->output_Fs ); @@ -94,8 +93,7 @@ void open_decoder_LPD( } } - st->tcxonly = getTcxonly( st->element_mode, total_brate, MCT_flag, - st->is_ism_format ); + st->tcxonly = getTcxonly( st->element_mode, total_brate, MCT_flag, st->is_ism_format ); /* the TD TCX PLC in MODE1 still runs with 80ms subframes */ if ( ( st->element_mode == EVS_MONO && st->L_frame == L_FRAME16k && total_brate <= ACELP_32k ) || ( st->element_mode > EVS_MONO && st->L_frame == L_FRAME16k && total_brate <= MAX_ACELP_BRATE ) || ( st->tcxonly && ( st->sr_core == 32000 || st->sr_core == 16000 ) ) ) diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index 60859a20fb..16519aec47 100644 --- a/lib_dec/core_dec_switch.c +++ b/lib_dec/core_dec_switch.c @@ -72,8 +72,7 @@ void mode_switch_decoder_LPD( { bSwitchFromAmrwbIO = 1; } - sr_core = getCoreSamplerateMode2( st->element_mode, total_brate, bwidth, st->flag_ACELP16k, st->rf_flag, - st->is_ism_format ); + sr_core = getCoreSamplerateMode2( st->element_mode, total_brate, bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format ); fscale = sr2fscale( sr_core ); /* set number of coded lines */ diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index 6c5e6575a6..8309c9874d 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -233,8 +233,7 @@ void ivas_mct_core_dec( { st = sts[ch]; - if ( - sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) /*indicates LFE */ + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) /*indicates LFE */ { continue; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index c37bd78125..51d6856987 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -358,9 +358,9 @@ ivas_error create_mct_dec( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR; } } + /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - if ( ( hMCT->nchan_out_woLFE ) % - 2 ) + if ( hMCT->nchan_out_woLFE % 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } @@ -403,6 +403,7 @@ ivas_error create_mct_dec( *-----------------------------------------------------------------*/ hMCT->currBlockDataCnt = 0; + /*Initialize bits required to signal channel-pair index*/ hMCT->bitsChannelPairIndex = max( 1, (int16_t) ( floor( ( log( hMCT->nchan_out_woLFE * ( hMCT->nchan_out_woLFE - 1 ) / 2 - 1 ) / log( 2. ) ) ) + 1 ) ); @@ -468,13 +469,13 @@ ivas_error mct_dec_reconfigure( } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - if ( ( hMCT->nchan_out_woLFE ) % - 2 ) + if ( hMCT->nchan_out_woLFE % 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } cp_bitrate = st_ivas->hDecoderConfig->ivas_total_brate / hMCT->nchan_out_woLFE * CPE_CHANNELS; + /* set correct nominal bitrates and igf config already here, otherwise we * run into a number of problems */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) @@ -486,8 +487,7 @@ ivas_error mct_dec_reconfigure( st->total_brate = st_ivas->hCPE[cpe_id]->element_brate; - if ( !( - ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) ) + if ( st->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { st->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[cpe_id]->element_brate / FRAMES_PER_SEC ); st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag ); @@ -524,6 +524,7 @@ ivas_error mct_dec_reconfigure( } } } + initMdctStereoDecData( hMCT->hBlockData[n]->hStereoMdct, st_ivas->hCPE[0]->hCoreCoder[0]->igf, st_ivas->hCPE[0]->hCoreCoder[0]->hIGFDec->igfData.igfInfo.grid, cp_bitrate, st_ivas->hCPE[0]->hCoreCoder[0]->bwidth ); hMCT->hBlockData[n]->hStereoMdct->use_itd = 0; } @@ -744,6 +745,7 @@ static ivas_error ivas_mc_dec_reconfig( st_ivas->hTcBuffer->slots_rendered = st_ivas->hDirAC->slots_rendered; mvs2s( st_ivas->hDirAC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } + /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->hDecoderConfig->output_Fs ); @@ -815,7 +817,6 @@ static ivas_error ivas_mc_dec_reconfig( st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; if ( last_mc_mode != MC_MODE_PARAMUPMIX ) - /* This should always be the case, only supporting one bitrate currently */ { /*De-allocate handles for other MC modes*/ if ( st_ivas->hParamMC != NULL ) @@ -843,10 +844,12 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } +#ifdef DEBUGGING else { assert( 0 ); } +#endif } else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { @@ -910,7 +913,7 @@ static ivas_error ivas_mc_dec_reconfig( return error; } - /* ls conversion */ + /* LS conversion */ if ( st_ivas->hLsSetUpConversion != NULL ) { ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion ); @@ -1077,7 +1080,6 @@ static ivas_error ivas_mc_dec_reconfig( return error; } - set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN ); set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k ); } @@ -1129,6 +1131,7 @@ static ivas_error ivas_mc_dec_reconfig( { ivas_binRenderer_close( &st_ivas->hBinRenderer ); } + if ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend != NULL ) && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hIntSetup.output_config != AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) { ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); @@ -1203,12 +1206,7 @@ static ivas_error ivas_mc_dec_reconfig( } else if ( st_ivas->hCrendWrapper == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), - st_ivas->intern_config, - st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, - st_ivas->hSetOfHRTF, - st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 2617be5f2a..b5b61c2f1c 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -73,8 +73,7 @@ void stereo_tcx_init_dec( st->core_brate = st->total_brate; /*sampling rate*/ - st->sr_core = getCoreSamplerateMode2( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->flag_ACELP16k, st->rf_flag, - st->is_ism_format ); + st->sr_core = getCoreSamplerateMode2( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format ); st->fscale = sr2fscale( st->sr_core ); /*frame size*/ @@ -108,8 +107,7 @@ void stereo_tcx_init_dec( if ( st->element_mode == IVAS_SCE ) { - st->tcxonly = getTcxonly( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, MCT_flag, - st->is_ism_format ); + st->tcxonly = getTcxonly( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, MCT_flag, st->is_ism_format ); /* LPC quantization */ if ( st->sr_core <= INT_FS_16k && st->tcxonly == 0 ) diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index e3faed3d7a..b307e0361d 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -72,12 +72,10 @@ void init_coder_ace_plus( int16_t L_subfr; /* Bitrate */ - st->tcxonly = getTcxonly( st->element_mode, st->total_brate, MCT_flag, - st->is_ism_format ); + st->tcxonly = getTcxonly( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); /* Core Sampling Rate */ - st->sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, - st->is_ism_format ); + st->sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); st->fscale = sr2fscale( st->sr_core ); /* Narrowband? */ diff --git a/lib_enc/core_enc_switch.c b/lib_enc/core_enc_switch.c index e6433bc89a..44952cc1da 100644 --- a/lib_enc/core_enc_switch.c +++ b/lib_enc/core_enc_switch.c @@ -69,8 +69,7 @@ void core_coder_mode_switch( } /* force active frame for the first frame when switching from high bitrates when DTX is enabled*/ - sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, - st->is_ism_format ); + sr_core = getCoreSamplerateMode2( st->element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); fscale = sr2fscale( sr_core ); @@ -80,8 +79,7 @@ void core_coder_mode_switch( switchWB = 1; /*force init when coming from MODE1*/ } - tcxonly_tmp = getTcxonly( st->element_mode, st->total_brate, MCT_flag, - st->is_ism_format ); + tcxonly_tmp = getTcxonly( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); if ( tcxonly_tmp != st->tcxonly ) { @@ -93,8 +91,7 @@ void core_coder_mode_switch( st->sr_core = sr_core; st->L_frame = (int16_t) ( sr_core / FRAMES_PER_SEC ); - st->tcxonly = getTcxonly( st->element_mode, st->total_brate, MCT_flag, - st->is_ism_format ); + st->tcxonly = getTcxonly( st->element_mode, st->total_brate, MCT_flag, st->is_ism_format ); st->bits_frame_nominal = (int16_t) ( (float) st->L_frame / (float) st->fscale * (float) FSCALE_DENOM / 128.0f * (float) st->total_brate / 100.0f + 0.49f ); diff --git a/lib_enc/ivas_core_pre_proc.c b/lib_enc/ivas_core_pre_proc.c index 1e536f8026..eab1934fd5 100644 --- a/lib_enc/ivas_core_pre_proc.c +++ b/lib_enc/ivas_core_pre_proc.c @@ -241,8 +241,7 @@ ivas_error pre_proc_ivas( st->total_brate = st->bits_frame_nominal * FRAMES_PER_SEC; SetModeIndex( st, st->last_bits_frame_nominal * FRAMES_PER_SEC, last_element_mode, MCT_flag ); - st->sr_core = getCoreSamplerateMode2( element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, - st->is_ism_format ); + st->sr_core = getCoreSamplerateMode2( element_mode, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); st->total_brate = total_brate_tmp; st->L_frame = (int16_t) ( st->sr_core / FRAMES_PER_SEC ); diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 5298e39f39..94f6173092 100755 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -303,8 +303,7 @@ void ivas_mct_core_enc( { st = sts[ch]; - if ( - st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -382,8 +381,7 @@ void ivas_mct_core_enc( for ( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - if ( - sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -459,8 +457,7 @@ void ivas_mct_core_enc( { st = sts[ch]; - if ( - sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -475,8 +472,7 @@ void ivas_mct_core_enc( write_mct_bitstream( sts, hMCT, nChannels ); - FindChannelRatio( - sts, chBitRatios, nChannels ); + FindChannelRatio( sts, chBitRatios, nChannels ); nAvailBits = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - NBITS_BWIDTH - hMCT->nBitsMCT - lfe_bits ); @@ -525,8 +521,7 @@ void ivas_mct_core_enc( for ( ch = 0; ch < nChannels; ch++ ) { - if ( - sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 5fb0561797..16a7d7b1ac 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -226,6 +226,7 @@ ivas_error ivas_mct_enc( /*for MC and MCT remove pointer to LFE input that has been processed seperately */ map_input_to_cpe_channels( st_ivas, pdata, data ); + /* pre-processing */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { @@ -337,7 +338,7 @@ ivas_error create_mct_enc( } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - if ( ( hMCT->nchan_out_woLFE ) % 2 ) + if ( hMCT->nchan_out_woLFE % 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } @@ -453,8 +454,7 @@ ivas_error mct_enc_reconfigure( } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - if ( ( hMCT->nchan_out_woLFE ) % - 2 ) + if ( hMCT->nchan_out_woLFE % 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } @@ -471,8 +471,7 @@ ivas_error mct_enc_reconfigure( st->total_brate = st_ivas->hCPE[cpe_id]->element_brate; - if ( !( - ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) ) + if ( st->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { st->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[cpe_id]->element_brate / FRAMES_PER_SEC ); st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_mode ); @@ -670,6 +669,7 @@ static ivas_error ivas_mc_enc_reconfig( /* LFE handle */ ivas_lfe_enc_close( &( st_ivas->hLFE ) ); } + /* create LFE handle */ if ( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) { @@ -710,17 +710,18 @@ static ivas_error ivas_mc_enc_reconfig( } if ( last_mc_mode != MC_MODE_PARAMUPMIX ) - /* This should always be the case, only supporting one bitrate currently */ { if ( ( error = ivas_mc_paramupmix_enc_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } } +#ifdef DEBUGGING else { assert( 0 ); } +#endif /*De-allocate handles for other MC modes*/ ivas_param_mc_enc_close( &st_ivas->hParamMC, st_ivas->hEncoderConfig->input_Fs ); diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index fa21a17943..7bcd80301a 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -79,8 +79,7 @@ void stereo_tcx_init_enc( } /*sampling rate*/ - st->sr_core = getCoreSamplerateMode2( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->flag_ACELP16k, st->rf_mode, - st->is_ism_format ); + st->sr_core = getCoreSamplerateMode2( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->flag_ACELP16k, st->rf_mode, st->is_ism_format ); st->fscale = sr2fscale( st->sr_core ); /*frame size*/ -- GitLab From 2a633994383370ac9a3b37ed3aee697d2ccc96e4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jun 2023 10:37:35 +0200 Subject: [PATCH 05/12] formatting --- lib_enc/ivas_cpe_enc.c | 5 +---- lib_enc/pre_proc.c | 3 +-- lib_enc/updt_enc.c | 3 +-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index f00e8187ce..5533dee943 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -384,10 +384,7 @@ ivas_error ivas_cpe_enc( { int32_t internal_Fs; - internal_Fs = getTcxonly( IVAS_CPE_MDCT, sts[0]->bits_frame_nominal * FRAMES_PER_SEC, 0, - sts[0]->is_ism_format ) == 0 - ? INT_FS_16k - : max( INT_FS_16k, sts[0]->sr_core ); + internal_Fs = getTcxonly( IVAS_CPE_MDCT, sts[0]->bits_frame_nominal * FRAMES_PER_SEC, 0, 0 ); /* iDFT at input sampling rate */ stereo_dft_enc_synthesize( hCPE->hStereoDft, sts[0]->input, 0, input_Fs, input_Fs, 0 ); diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index a0ce860506..cd492b8d4c 100644 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -603,8 +603,7 @@ void pre_proc( else { SetModeIndex( st, st->last_total_brate, EVS_MONO, 0 ); - st->sr_core = getCoreSamplerateMode2( EVS_MONO, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, - 0 ); + st->sr_core = getCoreSamplerateMode2( EVS_MONO, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, 0 ); st->L_frame = (int16_t) ( st->sr_core / FRAMES_PER_SEC ); st->encoderLookahead_enc = NS2SA( st->sr_core, ACELP_LOOK_NS ); st->encoderPastSamples_enc = ( st->L_frame * 9 ) >> 4; diff --git a/lib_enc/updt_enc.c b/lib_enc/updt_enc.c index b958d544f4..5cc66667fe 100644 --- a/lib_enc/updt_enc.c +++ b/lib_enc/updt_enc.c @@ -393,8 +393,7 @@ void updt_enc_common( { st->codec_mode = MODE2; - st->sr_core = getCoreSamplerateMode2( EVS_MONO, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, - 0 ); + st->sr_core = getCoreSamplerateMode2( EVS_MONO, st->total_brate, st->bwidth, st->flag_ACELP16k, st->rf_mode, 0 ); st->L_frame = (int16_t) ( st->sr_core / FRAMES_PER_SEC ); -- GitLab From e1dd90a2522b63b5f7e900719e63e5fd8b024fa0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jun 2023 13:12:33 +0200 Subject: [PATCH 06/12] revert accidentally removed condition --- lib_enc/ivas_cpe_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 5533dee943..9887372ee7 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -384,7 +384,7 @@ ivas_error ivas_cpe_enc( { int32_t internal_Fs; - internal_Fs = getTcxonly( IVAS_CPE_MDCT, sts[0]->bits_frame_nominal * FRAMES_PER_SEC, 0, 0 ); + internal_Fs = getTcxonly( IVAS_CPE_MDCT, sts[0]->bits_frame_nominal * FRAMES_PER_SEC, 0, sts[0]->is_ism_format ) == 0 ? INT_FS_16k : max( INT_FS_16k, sts[0]->sr_core ); /* iDFT at input sampling rate */ stereo_dft_enc_synthesize( hCPE->hStereoDft, sts[0]->input, 0, input_Fs, input_Fs, 0 ); -- GitLab From 34339d5b4413088fd681224578c7d936d8d1caa5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Jun 2023 13:55:53 +0200 Subject: [PATCH 07/12] clang-format --- lib_enc/ivas_mdct_core_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index e749b2c803..87d330f2f0 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -361,7 +361,7 @@ static void applyStereoPreProcessingCplx( dmxR1 = valR1 * factDe + sign * valR2 * factIn; /* cross */ dmxR2 = valR2 * factDe + sign * valR1 * factIn; /* -talk */ - if ( fabsf( dmxR1 ) < absR1 + absR2 ) /* avoid destructive summations */ + if ( fabsf( dmxR1 ) < absR1 + absR2 ) /* avoid destructive summations */ { if ( absR1 * factDe < absR2 * factIn ) { -- GitLab From 933087033cd8fe557e9377bec610d7508a28a408 Mon Sep 17 00:00:00 2001 From: vaclav Date: Sat, 17 Jun 2023 13:44:19 +0200 Subject: [PATCH 08/12] formatting --- lib_dec/dec_tcx.c | 21 +++++++++------------ lib_dec/ivas_mdct_core_dec.c | 9 +++++---- lib_dec/ivas_spar_decoder.c | 3 +-- lib_dec/ivas_stereo_mdct_core_dec.c | 3 ++- lib_dec/ivas_stereo_mdct_stereo_dec.c | 2 +- lib_enc/ivas_core_enc.c | 3 +-- lib_enc/ivas_stereo_mdct_core_enc.c | 25 +++++++++++-------------- 7 files changed, 30 insertions(+), 36 deletions(-) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 78ce952276..35bdc6041f 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -107,8 +107,7 @@ void decoder_tcx( decoder_tcx_tns( st, L_frame_glob, L_spec, L_frame, L_frameTCX, &x[0], fUseTns, &tnsData, bfi, frame_cnt, 0 ); decoder_tcx_imdct( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x[0], &xn_buf[0], MDCT_IV, - fUseTns, &synth[0], &synthFB[0], bfi, frame_cnt, - sba_dirac_stereo_flag ); + fUseTns, &synth[0], &synthFB[0], bfi, frame_cnt, sba_dirac_stereo_flag ); return; } @@ -286,6 +285,7 @@ void decoder_tcx_post( return; } + /*-------------------------------------------------------------------* * IMDCT() * @@ -336,8 +336,7 @@ void IMDCT( v_multc( old_syn_overl, hTcxDec->conceal_eof_gain * st->last_concealed_gain_syn_deemph, old_syn_overl, overlap ); } - if ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 ) && - ( st->tcxonly ) ) + if ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 ) && st->tcxonly ) { /* Mode decision in PLC @@ -374,7 +373,9 @@ void IMDCT( TCX_MDXT_Inverse( x + w * L_spec_TCX5, win, L_ola, L_win - L_ola, L_ola, kernel_type ); } else + { TCX_MDCT_Inverse( x + w * L_spec_TCX5, win, L_ola, L_win - L_ola, L_ola, st->element_mode ); + } tcx_windowing_synthesis_current_frame( win, tcx_aldo_window_2, tcx_mdct_window_half, tcx_mdct_window_minimum, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, ( w > 0 ) ? 0 : left_rect, ( w > 0 ) || ( w == 0 && index == 2 ) ? MIN_OVERLAP : hTcxCfg->tcx_last_overlap_mode, acelp_zir, hTcxDec->old_syn_Overl, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, L_win, tcx_offset < 0 ? -tcx_offset : 0, ( w > 0 ) || ( frame_cnt > 0 ) ? 1 : st->last_core_bfi, ( w > 0 ) || ( frame_cnt > 0 ) ? 0 : st->last_is_cng, fullbandScale ); @@ -554,8 +555,7 @@ void IMDCT( /* Window and overlap-add past frame if past frame is TCX */ if ( ( frame_cnt != 0 ) || ( st->last_core_bfi > ACELP_CORE ) ) { - if ( ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 ) && - ( st->tcxonly ) ) || + if ( ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 ) && ( st->tcxonly ) ) || ( hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) ) { if ( !bfi && ( frame_cnt > 0 ) && ( index == 0 ) && ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) && ( st->last_core != ACELP_CORE ) ) @@ -723,7 +723,6 @@ void decoder_tcx_invQ( TCX_DEC_HANDLE hTcxDec = st->hTcxDec; TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; - tnsSize = 0; prm_target = NULL; /* just to suppress MSVC warnigs */ @@ -1692,9 +1691,7 @@ void decoder_tcx_imdct( if ( st->element_mode != IVAS_CPE_DFT && !sba_dirac_stereo_flag ) { - IMDCT( xn_bufFB, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf, - hTcxCfg->tcx_aldo_window_1_trunc, - hTcxCfg->tcx_aldo_window_2, + IMDCT( xn_bufFB, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_outLB, 0, st, 0, acelp_zir ); } @@ -1715,8 +1712,7 @@ void decoder_tcx_imdct( if ( st->element_mode != EVS_MONO ) { - IMDCT( x_tmp, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB, - hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, + IMDCT( x_tmp, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, max( L_frameTCX, L_spec ) >> 1, L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out, 1, st, FSCALE_DENOM * L_frameTCX_glob / L_frame_glob, acelp_zir ); } @@ -1948,6 +1944,7 @@ void decoder_tcx_IGF_stereo( { sfbConf = &hStereoMdct->stbParamsTCX20afterACELP; } + /* create line wise ms mask for the core bands */ set_s( coreMsMask, 0, N_MAX ); diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index becf11e070..deb6294066 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -328,6 +328,7 @@ void ivas_mdct_dec_side_bits_frame_channel( { continue; } + st = sts[ch]; if ( MCT_flag ) { @@ -421,6 +422,7 @@ void ivas_mdct_dec_side_bits_frame_channel( nStages = SNS_MSVQ_NSTAGES_SIDE; bits = ( nSubframes == 1 ) ? ivas_sns_cdbks_side_tcx20_bits : ivas_sns_cdbks_side_tcx10_bits; } + for ( int16_t j = 0; j < nStages; ++j ) { /* plus one in index for stereo mode storage! */ @@ -661,6 +663,7 @@ void ivas_mdct_core_invQ( sts[1]->core = sts[1]->last_core; } } + mvr2r( tmp_ms_sig[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0] ); mvr2r( tmp_ms_sig[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0] ); } @@ -854,11 +857,9 @@ void ivas_mdct_core_reconstruct( if ( !skip_decoding ) { - decoder_tcx_imdct( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], - tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], &x[ch][k][0], xn_buf, + decoder_tcx_imdct( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], &x[ch][k][0], xn_buf, ( ( hCPE->nchan_out == 1 && st->hTcxDec->kernel_type[k] == MDST_IV ) || st->hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) ? MDCT_IV : st->hTcxDec->kernel_type[k], - fUseTns[ch][k], &synth[k * L_frame[ch]], &synthFB[k * L_frameTCX[ch]], bfi, k, - 0 ); + fUseTns[ch][k], &synth[k * L_frame[ch]], &synthFB[k * L_frameTCX[ch]], bfi, k, 0 ); } else { diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index b80cc08684..9d4d67393f 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -321,8 +321,7 @@ ivas_error ivas_spar_dec( if ( st_ivas->hQMetaData != NULL ) { ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hQMetaData, nb_bits_read, - ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), - st_ivas->hSpar->dirac_to_spar_md_bands ); + ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands ); } last_bit_pos = (int16_t) ( ( hDecoderConfig->ivas_total_brate / FRAMES_PER_SEC ) - 1 ); diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index 9508a53982..1019868229 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -126,7 +126,6 @@ static void stereo_mdct_dec_stereo( sts[0]->bits_frame_channel += sts[0]->core * SMDCT_MINIMUM_ARITH_BITS; sts[1]->bits_frame_channel += sts[1]->core * SMDCT_MINIMUM_ARITH_BITS; - sts[1]->bit_stream = &sts[0]->bit_stream[sts[0]->next_bit_pos + sts[0]->bits_frame_channel + sts[0]->core * NF_GAIN_BITS]; return; @@ -513,6 +512,7 @@ static void apply_dmx_weights( } } } + /* apply weights to channels with their original frequency resolutions */ for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -571,6 +571,7 @@ static void apply_dmx_weights( return; } + /*-------------------------------------------------------------------* * run_min_stats() * diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index efc9ebe845..76f740d6c6 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -139,7 +139,6 @@ void parse_stereo_from_bitstream( if ( st0->igf ) { - mdct_stereo_mode = get_next_indice( st0, 1 ); if ( mdct_stereo_mode ) { @@ -469,6 +468,7 @@ ivas_error initMdctStereoDtxData( /* Init FD-CNG */ initFdCngDec( st ); } + if ( st->first_CNG == 0 ) { if ( ch == 1 && st->cng_sba_flag ) diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 6536ee333e..f8c33ea62d 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -279,8 +279,7 @@ ivas_error ivas_core_enc( if ( MCT_flag ) { ivas_mdct_core_whitening_enc( hCPE, old_inp_16k, old_wsp, pitch_buf, hMCT->p_mdst_spectrum_long[cpe_id], hMCT->tnsBits[cpe_id], hMCT->p_orig_spectrum_long[cpe_id], - hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], hMCT->hBstr, - 1, hMCT->nchan_out_woLFE ); + hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], hMCT->hBstr, 1, hMCT->nchan_out_woLFE ); } else { diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index 3c274b149e..46bc5fbf9a 100755 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -72,9 +72,8 @@ static void sync_tcx_mode( } } - if ( - ( prevAccNrg0 * 25.0f > prevAccNrg1 ) && ( prevAccNrg1 * 25.0f > prevAccNrg0 ) && /* 14 dB */ - ( lastAccNrg0 * 16.0f > lastAccNrg1 ) && ( lastAccNrg1 * 16.0f > lastAccNrg0 ) ) /* 12 dB */ + if ( ( prevAccNrg0 * 25.0f > prevAccNrg1 ) && ( prevAccNrg1 * 25.0f > prevAccNrg0 ) && /* 14 dB */ + ( lastAccNrg0 * 16.0f > lastAccNrg1 ) && ( lastAccNrg1 * 16.0f > lastAccNrg0 ) ) /* 12 dB */ { st[0]->hTcxEnc->tcxMode = st[1]->hTcxEnc->tcxMode = max( st[0]->hTcxEnc->tcxMode, st[1]->hTcxEnc->tcxMode ); /* synchronize TCX mode of both channels */ @@ -167,7 +166,6 @@ void stereo_mdct_core_enc( meta_bits = hCPE->hMetaData->nb_bits_tot; signal_bits = hBstr->nb_bits_tot; - /*--------------------------------------------------------------* * Initialization *---------------------------------------------------------------*/ @@ -199,6 +197,7 @@ void stereo_mdct_core_enc( #ifdef DEBUGGING hCPE->hStereoMdct->mdct_stereo_mode_cmdl = orig_mdct_stereo_mode_cmdl; #endif + stereo_mdct_init_igf_start_band( &( hCPE->hStereoMdct->stbParamsTCX20 ), 1.0f, hCPE->hCoreCoder[0]->bwidth, hCPE->element_brate ); stereo_mdct_init_igf_start_band( &( hCPE->hStereoMdct->stbParamsTCX10 ), 0.5f, hCPE->hCoreCoder[0]->bwidth, hCPE->element_brate ); stereo_mdct_init_igf_start_band( &( hCPE->hStereoMdct->stbParamsTCX20afterACELP ), 1.25f, hCPE->hCoreCoder[0]->bwidth, hCPE->element_brate ); @@ -227,7 +226,6 @@ void stereo_mdct_core_enc( sts[ch]->hTcxEnc->tns_ms_flag[1] = 0; } - /*--------------------------------------------------------------* * MDCT core preprocessing: * - initialization @@ -237,8 +235,7 @@ void stereo_mdct_core_enc( *---------------------------------------------------------------*/ ivas_mdct_core_whitening_enc( hCPE, new_samples, old_wsp, pitch_buf, p_mdst_spectrum_long, - tnsBits, p_orig_spectrum_long, tnsSize, p_param, hBstr, - 0, CPE_CHANNELS ); + tnsBits, p_orig_spectrum_long, tnsSize, p_param, hBstr, 0, CPE_CHANNELS ); for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -257,6 +254,7 @@ void stereo_mdct_core_enc( /*--------------------------------------------------------------* * Stereo Processing *---------------------------------------------------------------*/ + if ( !hStereoMdct->isSBAStereoMode ) { stereo_coder_tcx( hStereoMdct, sts, ms_mask, mdst_spectrum, inv_spectrum, inv_mdst_spectrum, 0 ); @@ -335,8 +333,7 @@ void stereo_mdct_core_enc( *-----------------------------------------------------------*/ ComputeSpectrumNoiseMeasure( powerSpec[ch], L_subframeTCX, st->hTcxEnc->nmStartLine * ( L_subframeTCX / st->hTcxEnc->L_frameTCX ), - ( st->L_frame * st->last_sr_core != st->L_frame_past * st->sr_core ) || ( st->last_core != TCX_20_CORE ), - st->hTcxEnc->memQuantZeros, L_subframeTCX ); + ( st->L_frame * st->last_sr_core != st->L_frame_past * st->sr_core ) || ( st->last_core != TCX_20_CORE ), st->hTcxEnc->memQuantZeros, L_subframeTCX ); } st->hTcxEnc->measuredBwRatio = 1.f; /* No bandwidth limit for the noise filling */ @@ -354,9 +351,7 @@ void stereo_mdct_core_enc( nSubframes = ( sts[0]->hTcxEnc->tcxMode == TCX_20 || sts[1]->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; for ( n = 0; n < nSubframes; n++ ) { - if ( ( hStereoMdct->mdct_stereo_mode[n] != hStereoMdct->IGFStereoMode[n] || - hStereoMdct->mdct_stereo_mode[n] == SMDCT_BW_MS ) && - !hStereoMdct->isSBAStereoMode ) + if ( ( hStereoMdct->mdct_stereo_mode[n] != hStereoMdct->IGFStereoMode[n] || hStereoMdct->mdct_stereo_mode[n] == SMDCT_BW_MS ) && !hStereoMdct->isSBAStereoMode ) { p_powerSpec[0] = powerSpec[0]; p_powerSpec[1] = powerSpec[1]; @@ -384,6 +379,7 @@ void stereo_mdct_core_enc( for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { st = sts[ch]; + #ifdef IND_LIST_DYN /* update the pointer to the buffer of indices of the second channel */ if ( ch == 1 ) @@ -391,6 +387,7 @@ void stereo_mdct_core_enc( st->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot; } #endif + nSubframes = ( st->hTcxEnc->tcxMode == TCX_20 ) ? 1 : NB_DIV; if ( st->igf ) { @@ -427,6 +424,7 @@ void stereo_mdct_core_enc( { stereo_bits = 0; } + /*--------------------------------------------------------------* * Split available bits between channels *---------------------------------------------------------------*/ @@ -468,8 +466,7 @@ void stereo_mdct_core_enc( } #endif - ivas_mdct_quant_coder( hCPE, - tnsBits, tnsSize, p_param, 0 ); + ivas_mdct_quant_coder( hCPE, tnsBits, tnsSize, p_param, 0 ); pop_wmops(); -- GitLab From c23d256a34b766b4cf60c684d3faf65d6be64a49 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jun 2023 09:54:04 +0200 Subject: [PATCH 09/12] formatting comments --- lib_com/ivas_fb_mixer.c | 6 +- lib_com/ivas_prot.h | 10 +- lib_com/lsf_tools.c | 2 +- lib_dec/ivas_binRenderer_internal.c | 16 +- lib_dec/ivas_lfe_plc.c | 2 +- lib_dec/ivas_stat_dec.h | 4 +- lib_dec/ivas_svd_dec.c | 2 +- lib_dec/lib_dec.c | 14 +- lib_enc/ivas_mcmasa_enc.c | 2 +- lib_enc/ivas_mct_enc.c | 8 +- lib_enc/ivas_stereo_dft_enc.c | 20 +-- lib_enc/ivas_stereo_dft_td_itd.c | 8 +- lib_enc/lsf_msvq_ma_enc.c | 156 +++++++++---------- lib_rend/ivas_dirac_ana.c | 2 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 25 +-- lib_rend/ivas_masa_merge.c | 134 ++++++++++------ lib_rend/ivas_mcmasa_ana.c | 47 ++++-- lib_rend/ivas_objectRenderer.c | 5 +- lib_rend/ivas_objectRenderer_sfx.c | 14 +- lib_rend/ivas_objectRenderer_sources.c | 24 +-- lib_rend/ivas_omasa_ana.c | 4 +- lib_rend/ivas_prot_rend.h | 153 ++++++++---------- lib_rend/ivas_reverb_delay_line.c | 2 +- lib_rend/ivas_reverb_fft_filter.c | 2 +- lib_rend/ivas_rotation.c | 76 +++++---- lib_rend/lib_rend.h | 8 +- lib_util/hrtf_file_reader.c | 4 +- lib_util/hrtf_file_reader.h | 10 +- lib_util/render_config_reader.c | 9 +- 29 files changed, 394 insertions(+), 375 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 80247804b0..40a86d08f2 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -64,7 +64,7 @@ static ivas_error ivas_fb_mixer_get_window( const int16_t fade_len, const int32_ * Get number of bands from BW index *-----------------------------------------------------------------------------------------*/ -/* !r: number of spectral bands */ +/*! r: number of spectral bands */ int16_t ivas_get_num_bands_from_bw_idx( const int16_t bwidth /* i : audio bandwidth */ ) @@ -829,8 +829,8 @@ static int16_t ivas_calculate_abs_fr( float short_stride_nrg = 0.0f; float cldfb_nrg = 0.0f; int16_t short_stride = pFb->fb_bin_to_band.short_stride; - const int16_t num_bins_per_short_stride_bin = ( const int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); - const int16_t num_bins_per_cldfb_band = ( const int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / pFb->fb_bin_to_band.num_cldfb_bands ); + const int16_t num_bins_per_short_stride_bin = (const int16_t) ( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); + const int16_t num_bins_per_cldfb_band = (const int16_t) ( ( sampling_rate / FRAMES_PER_SEC ) / pFb->fb_bin_to_band.num_cldfb_bands ); float short_stride_max_per_spar_band = 1e-9f; /*loop over all stored Filter Bank Response MDFT coefficients*/ diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 5fa9993f1f..17a8ed98f7 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1192,8 +1192,8 @@ float stereo_dft_enc_synthesize( void stereo_dft_enc_process( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ - const int16_t vad_hover_flag[], /* i: VAD hangover flags */ + const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ + const int16_t vad_hover_flag[], /* i : VAD hangover flags */ const int16_t input_frame /* i : input frame length */ ); @@ -2114,8 +2114,8 @@ void deindex_lvq_SHB( void stereo_td_itd_mdct_stereo( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ - const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ - const int16_t vad_hover_flag[], /* i: VAD hangover flags */ + const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ + const int16_t vad_hover_flag[], /* i : VAD hangover flags */ const int16_t input_frame /* i : frame length */ ); @@ -5152,7 +5152,7 @@ void ivas_binRenderer( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ int16_t subframe_idx, /* i : subframe index */ - const int16_t numTimeSlots, /* i: : number of time slots to process */ + const int16_t numTimeSlots, /* i : number of time slots to process */ float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ float Cldfb_ImagBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 4f40b83015..2f22dafa61 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -2107,7 +2107,7 @@ void msvq_dec( const int16_t maxN, /* i : Codebook dimension */ const int16_t Idx[], /* i : Indices */ const int16_t applyIDCT_flag, /* i : applyIDCT flag */ - const float *invTrfMatrix, /* i: matrix for IDCT synthesis */ + const float *invTrfMatrix, /* i : matrix for IDCT synthesis */ float *uq, /* o : quantized vector */ Word16 *uq_ind /* o : quantized vector (fixed point) */ ) diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 9061f3f39c..5bd09236e0 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1120,14 +1120,14 @@ void ivas_binaural_cldfb_sf( *-------------------------------------------------------------------------*/ void ivas_binRenderer( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ - int16_t subframe_idx, /* i : subframe index */ - const int16_t numTimeSlots, /* i : number of time slots to render*/ - float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - float Cldfb_ImagBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] /* i : LS signals */ + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ + int16_t subframe_idx, /* i : subframe index */ + const int16_t numTimeSlots, /* i : number of time slots to render */ + float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ + float Cldfb_ImagBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ + float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ + float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] /* i : LS signals */ ) { int16_t chIdx, k; diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 7e63c2d539..e89453686f 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -167,7 +167,7 @@ static void d_autocorr( * of input signal *---------------------------------------------------------------------*/ -/* !r: energy of prediction error */ +/*! r: energy of prediction error */ static int16_t d_lev_dur( double *a, /* o : LP coefficients (a[0] = 1.0) */ const double *r, /* i : vector of autocorrelations */ diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 27375db6fa..f0b3a3847a 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1297,8 +1297,8 @@ typedef struct Decoder_Struct EFAP_HANDLE hEFAPdata; /* EFAP structure */ VBAP_HANDLE hVBAPdata; /* VBAP structure */ MONO_DOWNMIX_RENDERER_HANDLE hMonoDmxRenderer; /* Mono downmix structure */ - CREND_WRAPPER_HANDLE hCrendWrapper; - REVERB_HANDLE hReverb; /* Reverb handle */ + CREND_WRAPPER_HANDLE hCrendWrapper; /* Crend handle */ + REVERB_HANDLE hReverb; /* Reverb handle */ HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */ diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index e1105bce9d..37af3fb124 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -171,7 +171,7 @@ void svdMat2mat( * perform a singular value decomposition X=USV of a matrix X *-------------------------------------------------------------------------*/ -/* !r: error or success */ +/*! r: error or success */ int16_t svd( float InputMatrix[][MAX_OUTPUT_CHANNELS], /* i : matrix to be decomposed (M) */ float singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* o : left singular vectors (U) */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index e46fe70028..7eb7324f62 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -871,9 +871,9 @@ ivas_error IVAS_DEC_GetTcSamples( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_RendererFeedTcSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o : IVAS decoder handle */ - const int16_t nSamplesForRendering, /* i: : number of TC samples wanted from the renderer */ - int16_t *nSamplesResidual, /* o: : number of samples not fitting into the renderer grid and buffer for the next call*/ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call */ float *pcmBuf /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ ) { @@ -906,10 +906,10 @@ ivas_error IVAS_DEC_RendererFeedTcSamples( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_GetRenderedSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o : IVAS decoder handle */ - const uint16_t nSamplesForRendering, /* i: : number of TC samples wanted from the renderer */ - uint16_t *nSamplesRendered, /* o : number of samples rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renerer pipeline */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the renerer pipeline */ int16_t *pcmBuf /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ ) { diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 3bafe7ceab..9dbdbcab15 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -1458,7 +1458,7 @@ static void computeIntensityVector_enc( const int16_t *band_grouping, float Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], float Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], - const int16_t enc_param_start_band, /* i: first band to process */ + const int16_t enc_param_start_band, /* i : first band to process */ const int16_t num_frequency_bands, float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] ) { diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 16a7d7b1ac..89ddfd0ceb 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -104,8 +104,8 @@ static void set_mct_enc_params( static void map_input_to_cpe_channels( const Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *pdata[MAX_INPUT_CHANNELS], /* o: mapped input pointers */ - float data[MCT_MAX_CHANNELS][L_FRAME48k] /* i: input channel data */ + float *pdata[MAX_INPUT_CHANNELS], /* o : mapped input pointers */ + float data[MCT_MAX_CHANNELS][L_FRAME48k] /* i : input channel data */ ) { int16_t i, n; @@ -637,8 +637,8 @@ ivas_error ivas_mc_enc_config( *-------------------------------------------------------------------------*/ static ivas_error ivas_mc_enc_reconfig( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t last_mc_mode /* i: last frame mc mode */ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + const int16_t last_mc_mode /* i : last frame mc mode */ ) { int16_t nchan_transport_old, nSCE_old, nCPE_old; diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index 014f23ed9f..dfa4118b09 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -1237,10 +1237,10 @@ float stereo_dft_enc_synthesize( *-------------------------------------------------------------------------*/ void stereo_dft_enc_process( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ - const int16_t vad_hover_flag[], /* i: VAD hangover flags */ - const int16_t input_frame /* i : input frame length */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ + const int16_t vad_hover_flag[], /* i : VAD hangover flags */ + const int16_t input_frame /* i : input frame length */ ) { int16_t i, j, b; @@ -3246,7 +3246,7 @@ static void res_pred_gain_mode_decision( *------------------------------------------------------------------------*/ static float stereo_dft_calc_mean_bipd( - float *pIpd, /* i: current bandwise IPD */ + float *pIpd, /* i : current bandwise IPD */ float ipd_buf[STEREO_DFT_IPD_BUF_LEN] /* i/o: previous bandwise IPDs */ ) { @@ -3311,9 +3311,9 @@ static float stereo_dft_calc_mean_bipd( *------------------------------------------------------------------------*/ static float stereo_dft_calc_mean_ipd_change( - float *pIpd, /* i: bandwise IPDs */ - float *ipd_smooth, /* i: mean of previous bandwise IPDs */ - int16_t gipd_band_max /* i: number of IPD bands */ + float *pIpd, /* i : bandwise IPDs */ + float *ipd_smooth, /* i : mean of previous bandwise IPDs */ + int16_t gipd_band_max /* i : number of IPD bands */ ) { int16_t b; @@ -3349,8 +3349,8 @@ static float stereo_dft_calc_mean_ipd_change( static void stereo_dft_gipd_stabilization( float *pgIpd, /* i/o: global IPD to be stabilized */ - float prev_gipd, /* i: previous global IPD */ - float ipd_mean_change /* i: mean of previous bandwise IPDs */ + float prev_gipd, /* i : previous global IPD */ + float ipd_mean_change /* i : mean of previous bandwise IPDs */ ) { float diff_gipd; diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd.c index 613fd33424..9fbe5e273a 100644 --- a/lib_enc/ivas_stereo_dft_td_itd.c +++ b/lib_enc/ivas_stereo_dft_td_itd.c @@ -388,10 +388,10 @@ void stereo_td_itd( * ---------------------------------------------------------------*/ void stereo_td_itd_mdct_stereo( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ - const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ - const int16_t vad_hover_flag[], /* i: VAD hangover flags */ - const int16_t input_frame /* i : frame length */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ + const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ + const int16_t vad_hover_flag[], /* i : VAD hangover flags */ + const int16_t input_frame /* i : frame length */ ) { int16_t i; diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 47d9d83a8a..a70b85013c 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -439,24 +439,9 @@ void msvq_enc( assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB ); /* 21 and 24 allowed */ assert( maxC == 2 * FDCNG_VQ_DCT_NSEGM ); - p_max = msvq_stage1_dct_search( u, FDCNG_VQ_MAX_LEN, maxC, - DCT_T2_24_XX, - FDCNG_VQ_DCT_MAXTRUNC, - invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ - cdk1r_tr_midQ_truncQ, /* i: midQ vector */ - fdcng_dct_invScaleF, /* i: global inv scale factors*/ - fdcng_dct_scaleF, /* i: global scale factors*/ - FDCNG_VQ_DCT_NSEGM, /* i: number of segments */ - cdk1_ivas_cols_per_segment, /* i: remaining length per segment */ - cdk1_ivas_trunc_dct_cols_per_segment, /* i: trunc length per segment */ - cdk1_ivas_entries_per_segment, /* i: number of rows per segment */ - cdk1_ivas_cum_entries_per_segment, /* i: number of cumulative entries */ - cdk_37bits_ivas_stage1_W8Qx_dct_sections, /*i: Word8(byte) segment table ptrs */ - stage1_dct_col_syn_shift, /*i: columnwise syn shift tables */ - cdk1_ivas_segm_neighbour_fwd, /*i: circular neighbour list fwd */ - cdk1_ivas_segm_neighbour_rev, /*i: circular neighbour list reverse */ - FDCNG_VQ_DCT_NPOST, /*i: number of circ. neigbours to post check */ - st1_mse_ptr, indices_st1_local, st1_syn_vec_ptr, dist[1] ); + p_max = msvq_stage1_dct_search( u, FDCNG_VQ_MAX_LEN, maxC, DCT_T2_24_XX, FDCNG_VQ_DCT_MAXTRUNC, invTrfMatrix, cdk1r_tr_midQ_truncQ, fdcng_dct_invScaleF, fdcng_dct_scaleF, FDCNG_VQ_DCT_NSEGM, + cdk1_ivas_cols_per_segment, cdk1_ivas_trunc_dct_cols_per_segment, cdk1_ivas_entries_per_segment, cdk1_ivas_cum_entries_per_segment, cdk_37bits_ivas_stage1_W8Qx_dct_sections, + stage1_dct_col_syn_shift, cdk1_ivas_segm_neighbour_fwd, cdk1_ivas_segm_neighbour_rev, FDCNG_VQ_DCT_NPOST, st1_mse_ptr, indices_st1_local, st1_syn_vec_ptr, dist[1] ); /* move established stage#1 indices to the global MSVQ list structure */ @@ -468,37 +453,85 @@ void msvq_enc( else /* non-DCT Stage #1 code below */ if ( !s ) /* means: m==1 */ + { + /* This loop is identical to the one below, except, that the inner loop over c=0..m is hardcoded to c=0, since m=1. */ + /* dist[0][0] */ + for ( j = 0; j < levels[s]; j++ ) { - /* This loop is identical to the one below, except, that the inner - loop over c=0..m is hardcoded to c=0, since m=1. */ - /* dist[0][0] */ - for ( j = 0; j < levels[s]; j++ ) + en = 0.0f; + /* w,Tmp */ + /* Compute weighted codebook element and its energy */ + for ( c2 = 0; c2 < n; c2++ ) + { + Tmp[start + c2] = w[start + c2] * cbp[c2]; + en += cbp[c2] * Tmp[start + c2]; + } + cbp += maxn; /* pointer is incremented */ + + pTmp = &resid[0][0]; + /* Tmp */ + tmp = ( *pTmp++ ) * Tmp[0]; + for ( c2 = 1; c2 < N; c2++ ) + { + tmp += ( *pTmp++ ) * Tmp[c2]; + } + tmp = en - 2.0f * tmp; + tmp += dist[0][0]; + if ( tmp < dist[1][p_max] ) { - en = 0.0f; - /* w,Tmp */ - /* Compute weighted codebook element and its energy */ - for ( c2 = 0; c2 < n; c2++ ) + /* Replace worst */ + dist[1][p_max] = tmp; + indices[1][p_max * stages] = j; + parents[p_max] = 0; + + p_max = 0; + for ( c2 = 1; c2 < maxC; c2++ ) { - Tmp[start + c2] = w[start + c2] * cbp[c2]; - en += cbp[c2] * Tmp[start + c2]; + if ( dist[1][c2] > dist[1][p_max] ) + { + p_max = c2; + } } - cbp += maxn; /* pointer is incremented */ + } /* if (tmp <= dist[1][p_max]) */ + } /* for (j=0; j dist[1][p_max] ) - { - p_max = c2; - } - } - } /* if (tmp <= dist[1][p_max]) */ - } /* for(c=0; cdirectionIndex[0][sf][band] = inMeta->directionIndex[0][sf][band]; @@ -94,9 +88,16 @@ void copy_masa_meta_tile( return; } + +/*---------------------------------------------------------------------* + * copy_masa_descriptive_meta() + * + * + *---------------------------------------------------------------------*/ + void copy_masa_descriptive_meta( - MASA_DECRIPTIVE_META *outMeta, /* o: metadata to be written */ - MASA_DECRIPTIVE_META *inMeta /* i: input metadata */ + MASA_DECRIPTIVE_META *outMeta, /* o : metadata to be written */ + MASA_DECRIPTIVE_META *inMeta /* i : input metadata */ ) { uint8_t char_idx; @@ -111,14 +112,23 @@ void copy_masa_descriptive_meta( outMeta->channelAngle = inMeta->channelAngle; outMeta->channelDistance = inMeta->channelDistance; outMeta->channelLayout = inMeta->channelLayout; + + return; } + +/*---------------------------------------------------------------------* + * diffuse_meta_merge_1x1() + * + * + *---------------------------------------------------------------------*/ + void diffuse_meta_merge_1x1( - MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o: Merged metadata output */ - MASA_DECODER_EXT_OUT_META_HANDLE inMeta, /* i: Input metadata 1 */ - float inEne[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i: TF-energy of input 1 */ - MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, /* i: Input metadata 2 */ - float inEneISM[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i: TF-energy of input 2 */ + MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta, /* i : Input metadata 1 */ + float inEne[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 */ + MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, /* i : Input metadata 2 */ + float inEneISM[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 */ ) { int8_t sf, band; @@ -186,12 +196,19 @@ void diffuse_meta_merge_1x1( return; } + +/*---------------------------------------------------------------------* + * full_stream_merge() + * + * + *---------------------------------------------------------------------*/ + void full_stream_merge( - MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o: Merged metadata output */ - MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i: Input metadata 1 */ - float inEne1[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ - MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i: Input metadata 2 */ - float inEne2[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i: TF-energy of input 2 */ + MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ + float inEne1[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ + float inEne2[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 */ ) { float dir_nrg_1, dir_nrg_2; @@ -251,14 +268,21 @@ void full_stream_merge( return; } + +/*---------------------------------------------------------------------* + * ivas_prerend_merge_masa_metadata() + * + * + *---------------------------------------------------------------------*/ + void ivas_prerend_merge_masa_metadata( - MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o: Merged metadata output */ - MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i: Input metadata 1 */ - IVAS_REND_AudioConfigType inType1, /* i: Type of input 1 */ - float inEne1[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ - MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i: Input metadata 2 */ - IVAS_REND_AudioConfigType inType2, /* i: Type of input 2 */ - float inEne2[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i: TF-energy of input 2 */ + MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ + IVAS_REND_AudioConfigType inType1, /* i : Type of input 1 */ + float inEne1[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ + IVAS_REND_AudioConfigType inType2, /* i : Type of input 2 */ + float inEne2[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 */ ) { /* mixing ISMs with non-ISM use different merge */ @@ -280,10 +304,17 @@ void ivas_prerend_merge_masa_metadata( return; } + +/*---------------------------------------------------------------------* + * masaPrerendOpen() + * + * + *---------------------------------------------------------------------*/ + ivas_error masaPrerendOpen( - MASA_PREREND_HANDLE *hMasaPrerendPtr, /* o: handle to the opened prerenderer */ - int16_t numTransports, /* i: number of transport channels */ - int32_t input_Fs /* i: signal sampling rate */ + MASA_PREREND_HANDLE *hMasaPrerendPtr, /* o : handle to the opened prerenderer */ + int16_t numTransports, /* i : number of transport channels */ + int32_t input_Fs /* i : signal sampling rate */ ) { MASA_PREREND_HANDLE hMasaPrerend; @@ -330,6 +361,13 @@ ivas_error masaPrerendOpen( return error; } + +/*---------------------------------------------------------------------* + * masaPrerendClose() + * + * + *---------------------------------------------------------------------*/ + void masaPrerendClose( MASA_PREREND_HANDLE *hMasaPrerendPtr /* i/o: prerenderer handle to be closed */ ) diff --git a/lib_rend/ivas_mcmasa_ana.c b/lib_rend/ivas_mcmasa_ana.c index ba5380a09d..b90b02ed14 100644 --- a/lib_rend/ivas_mcmasa_ana.c +++ b/lib_rend/ivas_mcmasa_ana.c @@ -84,8 +84,8 @@ static void computeEvenLayout( const float *ls_azimuth, float *ls_azimuth_even, ivas_error ivas_mcmasa_ana_open( MCMASA_ANA_HANDLE *hMcMasaPtr, /* i/o: McMASA data handle pointer */ - const IVAS_REND_AudioConfig inConfig, /* i: Input config */ - int32_t input_Fs /* i: Sampling frequency */ + const IVAS_REND_AudioConfig inConfig, /* i : Input config */ + int32_t input_Fs /* i : Sampling frequency */ ) { int16_t i, j; @@ -179,11 +179,17 @@ ivas_error ivas_mcmasa_ana_open( /* intensity 3-dim */ for ( i = 0; i < DIRAC_NUM_DIMS; i++ ) { - hMcMasa->direction_vector_m[i] = (float **) malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float * ) ); + if ( ( hMcMasa->direction_vector_m[i] = (float **) malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); + } for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - hMcMasa->direction_vector_m[i][j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ); + if ( ( hMcMasa->direction_vector_m[i][j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); + } set_zero( hMcMasa->direction_vector_m[i][j], MASA_FREQUENCY_BANDS ); } } @@ -192,20 +198,27 @@ ivas_error ivas_mcmasa_ana_open( { for ( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { - hMcMasa->buffer_intensity_real[i][j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ); + if ( ( hMcMasa->buffer_intensity_real[i][j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); + } set_zero( hMcMasa->buffer_intensity_real[i][j], MASA_FREQUENCY_BANDS ); } } for ( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { - hMcMasa->buffer_intensity_real_vert[j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ); + if ( ( hMcMasa->buffer_intensity_real_vert[j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); + } set_zero( hMcMasa->buffer_intensity_real_vert[j], MASA_FREQUENCY_BANDS ); } set_zero( hMcMasa->buffer_energy, DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS ); computeEvenLayout( ls_azimuth, ls_azimuth_even, hMcMasa->numHorizontalChannels ); + if ( !hMcMasa->isHorizontalSetup ) { computeEvenLayout( &ls_azimuth[hMcMasa->numHorizontalChannels], &ls_azimuth_even[hMcMasa->numHorizontalChannels], numAnalysisChannels - hMcMasa->numHorizontalChannels ); @@ -1035,15 +1048,22 @@ static void computeEvenLayout( return; } + +/*------------------------------------------------------------------------- + * ivas_create_masa_out_meta() + * + * + *------------------------------------------------------------------------*/ + void ivas_create_masa_out_meta( MASA_DECODER_EXT_OUT_META_HANDLE extOutMeta, /* i/o: MASA metadata handle */ - SPHERICAL_GRID_DATA *Sph_Grid16, /* i: Spherical grid */ - const int16_t nchan_transport, /* i: Number of transport channels */ - float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i: Estimated elevation */ - float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i: Estimated azimuth */ - float energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i: Estimated direct-to-total ratio */ - float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i: Estimated spread coherence */ - float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i: Estimated surround coherence */ + SPHERICAL_GRID_DATA *Sph_Grid16, /* i : Spherical grid */ + const int16_t nchan_transport, /* i : Number of transport channels */ + float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated elevation */ + float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated azimuth */ + float energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated direct-to-total ratio */ + float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated spread coherence */ + float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : Estimated surround coherence */ ) { const uint8_t ivasmasaFormatDescriptor[8] = { 0x49, 0x56, 0x41, 0x53, 0x4D, 0x41, 0x53, 0x41 }; /* "IVASMASA" */ @@ -1052,7 +1072,6 @@ void ivas_create_masa_out_meta( uint8_t numDirections; uint16_t spherical_index; - numDirections = 1; numFrequencyBands = MASA_FREQUENCY_BANDS; diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 86ec0125d5..2ba225b2f1 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -48,7 +48,6 @@ * Local function prototypes *---------------------------------------------------------------------*/ - static void TDREND_Clear_Update_flags( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd ); static void angles_to_vec( const float radius, const float azimuth, const float elevation, float *vec ); @@ -263,8 +262,8 @@ ivas_error ivas_td_binaural_renderer_unwrap( const int16_t *enableCombinedOrientation, /* i : Combined orientation flag */ const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ - const int16_t ism_md_subframe_update, /* i: Number of subframes to delay ism metadata to sync with audio */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t ism_md_subframe_update, /* i : Number of subframes to delay ism metadata to sync with audio */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ const int16_t output_frame /* i : output frame length */ ) { diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index d988ad53d2..679887b3ec 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -57,13 +57,13 @@ static void sincResample( const float *input, float *output, const int16_t lengt * Apply ITD by delaying late channel *---------------------------------------------------------------------*/ void TDREND_Apply_ITD( - float *input, /* i: Input subframe to be time adjusted */ - float *out_left, /* o: Output left channel with ITD applied */ - float *out_right, /* o: Output right channel with ITD applied */ - int16_t *previtd, /*i/o: Previous ITD value */ - const int16_t itd, /* i: Current subframe ITD value */ - float *mem_itd, /*i/o: ITD buffer memory */ - const int16_t length /* i: Subframe length */ + float *input, /* i : Input subframe to be time adjusted */ + float *out_left, /* o : Output left channel with ITD applied */ + float *out_right, /* o : Output right channel with ITD applied */ + int16_t *previtd, /* i/o: Previous ITD value */ + const int16_t itd, /* i : Current subframe ITD value */ + float *mem_itd, /* i/o: ITD buffer memory */ + const int16_t length /* i : Subframe length */ ) { int16_t transition_len; diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 456b406b1d..8debd6619b 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -247,18 +247,18 @@ static void TDREND_SRC_REND_Init( --------------------------------------------------------------------*/ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ - TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ - float *hrf_left_prev, /* o: Left filter */ - float *hrf_right_prev, /* o: Right filter */ - float *hrf_left_delta, /* o: Left filter interpolation delta */ - float *hrf_right_delta, /* o: Right filter interpolation delta */ - int16_t *intp_count, /* o: Interpolation count */ - int16_t *filterlength, /* o: Length of filters */ - int16_t *itd, /* o: ITD value */ - float *Gain, /* o: Gain value */ - TDREND_SRC_t *Src_p, /* i/o: Source pointer */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ + TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ + float *hrf_left_prev, /* o : Left filter */ + float *hrf_right_prev, /* o : Right filter */ + float *hrf_left_delta, /* o : Left filter interpolation delta */ + float *hrf_right_delta, /* o : Right filter interpolation delta */ + int16_t *intp_count, /* o : Interpolation count */ + int16_t *filterlength, /* o : Length of filters */ + int16_t *itd, /* o : ITD value */ + float *Gain, /* o : Gain value */ + TDREND_SRC_t *Src_p, /* i/o: Source pointer */ const int16_t subframe_update_flag ) { TDREND_MIX_Listener_t *Listener_p; diff --git a/lib_rend/ivas_omasa_ana.c b/lib_rend/ivas_omasa_ana.c index c13815be3c..eeed6a8253 100644 --- a/lib_rend/ivas_omasa_ana.c +++ b/lib_rend/ivas_omasa_ana.c @@ -62,8 +62,8 @@ static void ivas_omasa_dmx( float data_in_f[][L_FRAME48k], const int16_t input_f ivas_error ivas_omasa_ana_open( OMASA_ANA_HANDLE *hOMasaPtr, /* i/o: OMASA data handle pointer */ - int32_t input_Fs, /* i: Sampling frequency */ - uint16_t total_num_objects /* i: Number of objects */ + int32_t input_Fs, /* i : Sampling frequency */ + uint16_t total_num_objects /* i : Number of objects */ ) { int16_t i, j; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 4ea5cb4484..edaf1fda6b 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -316,9 +316,9 @@ void HRTF_model_precalc( ivas_error TDREND_REND_RenderSourceHRFilt( TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */ - const float *hrf_left_delta, /* i: Left filter interpolation delta */ - const float *hrf_right_delta, /* i: Right filter interpolation delta */ - const int16_t intp_count, /* i: Interpolation count */ + const float *hrf_left_delta, /* i : Left filter interpolation delta */ + const float *hrf_right_delta, /* i : Right filter interpolation delta */ + const int16_t intp_count, /* i : Interpolation count */ float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */ const int16_t subframe_length /* i : Subframe length in use */ ); @@ -353,14 +353,14 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ - float *hrf_left_prev, /* o: Left filter */ - float *hrf_right_prev, /* o: Right filter */ - float *hrf_left_delta, /* o: Left filter interpolation delta */ - float *hrf_right_delta, /* o: Right filter interpolation delta */ - int16_t *intp_count, /* o: Interpolation count */ - int16_t *filterlength, /* o: Length of filters */ - int16_t *itd, /* o: ITD value */ - float *Gain, /* o: Gain value */ + float *hrf_left_prev, /* o : Left filter */ + float *hrf_right_prev, /* o : Right filter */ + float *hrf_left_delta, /* o : Left filter interpolation delta */ + float *hrf_right_delta, /* o : Right filter interpolation delta */ + int16_t *intp_count, /* o : Interpolation count */ + int16_t *filterlength, /* o : Length of filters */ + int16_t *itd, /* o : ITD value */ + float *Gain, /* o : Gain value */ TDREND_SRC_t *Src_p, const int16_t subframe_update_flag /* i : Flag to determine update subframe idx */ ); @@ -454,13 +454,13 @@ ivas_error TDREND_MIX_Init( /* ----- Object renderer - sfx ----- */ void TDREND_Apply_ITD( - float *input, /* i: Input SCE subframe to be time adjusted */ - float *out_left, /* o: Output left channels with ITD applied */ - float *out_right, /* o: Output right channels with ITD applied */ - int16_t *previtd, /*i/o: Previous ITD value */ - const int16_t itd, /* i: Current subframe ITD value */ - float *mem_itd, /*i/o: ITD buffer memory */ - const int16_t length /* i: Subframe length */ + float *input, /* i : Input SCE subframe to be time adjusted */ + float *out_left, /* o : Output left channels with ITD applied */ + float *out_right, /* o : Output right channels with ITD applied */ + int16_t *previtd, /* i/o: Previous ITD value */ + const int16_t itd, /* i : Current subframe ITD value */ + float *mem_itd, /* i/o: ITD buffer memory */ + const int16_t length /* i : Subframe length */ ); void TDREND_firfilt( @@ -553,7 +553,6 @@ void ivas_binaural_reverb_processSubframe( float outImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* o : output CLDFB data imag */ ); - ivas_error ivas_reverb_open( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ @@ -582,7 +581,7 @@ void ivas_rev_delay_line_init( const uint16_t maxdelay /* i : maximum delay to be supported */ ); -/* !r: sample gotten out of delay line, and amplified by set gain */ +/*! r: sample gotten out of delay line, and amplified by set gain */ float ivas_rev_delay_line_get_sample( ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ ); @@ -794,7 +793,7 @@ void SHrotmatgen( void rotateFrame_shd( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : head and external orientation combined handle */ - float *output[], /* i/o: unrotated HOA3 signal buffer in TD */ + float *output[], /* i/o: unrotated HOA3 signal buffer in TD */ const int16_t subframe_len, /* i : subframe length per channel */ const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ const int16_t subframe_idx /* i : subframe index */ @@ -851,31 +850,11 @@ ivas_error combine_external_and_head_orientations_dec( ); ivas_error combine_external_and_head_orientations_rend( - IVAS_REND_HeadRotData *hHeadTrackData, /* i : head track handle */ - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ -); - -ivas_error combine_external_and_head_orientations( - IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ - IVAS_VECTOR3 *listenerPos, /* i : listener position */ - int16_t numHeadRotQuaternions, /* i : number of head rotation quaternions */ - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ + IVAS_REND_HeadRotData *hHeadTrackData, /* i : head track handle */ + EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ); -void external_target_interpolation( - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ - const int16_t i -); - -bool are_orientations_same( - const IVAS_QUATERNION *orientation1, - const IVAS_QUATERNION *orientation2 -); - - /*----------------------------------------------------------------------------------* * Renderer configuration *----------------------------------------------------------------------------------*/ @@ -962,39 +941,39 @@ ivas_error ivas_orient_trk_Process( *----------------------------------------------------------------------------------*/ ivas_error ivas_mcmasa_ana_open( - MCMASA_ANA_HANDLE *hMcMasaPtr, /* i/o: McMASA data handle pointer */ - const IVAS_REND_AudioConfig inConfig, /* i: Input config */ - int32_t input_Fs /* i: Sampling frequency */ + MCMASA_ANA_HANDLE *hMcMasaPtr, /* i/o: McMASA data handle pointer */ + const IVAS_REND_AudioConfig inConfig, /* i : Input config */ + int32_t input_Fs /* i : Sampling frequency */ ); void ivas_mcmasa_ana( - MCMASA_ANA_HANDLE hMcMasa, /* i/o: McMASA encoder handle */ - float data_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t nchan_transport, /* i : Number of transport channels */ - const int16_t nchan_inp /* i : Number of input channels */ + MCMASA_ANA_HANDLE hMcMasa, /* i/o: McMASA encoder handle */ + float data_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ + const int16_t input_frame, /* i : Input frame size */ + const int16_t nchan_transport, /* i : Number of transport channels */ + const int16_t nchan_inp /* i : Number of input channels */ ); void ivas_mcmasa_ana_close( - MCMASA_ANA_HANDLE *hMcMasa /* i/o: analysis McMASA handle */ + MCMASA_ANA_HANDLE *hMcMasa /* i/o: analysis McMASA handle */ ); ivas_error ivas_omasa_ana_open( - OMASA_ANA_HANDLE *hOMasaPtr, /* i/o: OMASA data handle pointer */ - int32_t input_Fs, /* i: Sampling frequency */ - uint16_t total_num_objects /* i: Number of objects */ + OMASA_ANA_HANDLE *hOMasaPtr, /* i/o: OMASA data handle pointer */ + int32_t input_Fs, /* i : Sampling frequency */ + uint16_t total_num_objects /* i : Number of objects */ ); void ivas_omasa_ana( - OMASA_ANA_HANDLE hOMasa, /* i/o: OMASA analysis handle */ - float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t nchan_transport, /* i : Number of transport channels */ - const int16_t nchan_ism /* i : Number of objects for parameter analysis */ + OMASA_ANA_HANDLE hOMasa, /* i/o: OMASA analysis handle */ + float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ + const int16_t input_frame, /* i : Input frame size */ + const int16_t nchan_transport, /* i : Number of transport channels */ + const int16_t nchan_ism /* i : Number of objects for parameter analysis*/ ); void ivas_omasa_ana_close( - OMASA_ANA_HANDLE *hOMasa /* i/o: analysis OMASA handle */ + OMASA_ANA_HANDLE *hOMasa /* i/o: analysis OMASA handle */ ); void computeIntensityVector_ana( @@ -1015,50 +994,50 @@ void computeReferencePower_ana( void ivas_create_masa_out_meta( MASA_DECODER_EXT_OUT_META_HANDLE extOutMeta, /* i/o: MASA metadata handle */ - SPHERICAL_GRID_DATA *Sph_Grid16, /* i: Spherical grid */ - const int16_t nchan_transport, /* i: Number of transport channels */ - float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i: Estimated elevation */ - float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i: Estimated azimuth */ - float energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i: Estimated direct-to-total ratio */ - float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i: Estimated spread coherence */ - float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i: Estimated surround coherence */ + SPHERICAL_GRID_DATA *Sph_Grid16, /* i : Spherical grid */ + const int16_t nchan_transport, /* i : Number of transport channels */ + float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated elevation */ + float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated azimuth */ + float energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated direct-to-total ratio */ + float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated spread coherence */ + float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : Estimated surround coherence */ ); ivas_error ivas_dirac_ana_open( - DIRAC_ANA_HANDLE *hDirACPtr, /* i/o: DIRAC data handle pointer */ + DIRAC_ANA_HANDLE *hDirACPtr, /* i/o: DIRAC data handle pointer */ int32_t input_Fs ); void ivas_dirac_ana( - DIRAC_ANA_HANDLE hDirAC, /* i/o: DIRAC analysis handle */ - float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t nchan_transport /* i : Number of transport channels */ + DIRAC_ANA_HANDLE hDirAC, /* i/o: DIRAC analysis handle */ + float data_in_f[][L_FRAME48k], /* i/o: Input / transport audio signals */ + const int16_t input_frame, /* i : Input frame size */ + const int16_t nchan_transport /* i : Number of transport channels */ ); void ivas_dirac_ana_close( - DIRAC_ANA_HANDLE ( *hDirAC ) /* i/o: analysis DIRAC handle */ + DIRAC_ANA_HANDLE ( *hDirAC ) /* i/o: analysis DIRAC handle */ ); void ivas_prerend_merge_masa_metadata( - MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o: Merged metadata output */ - MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i: Input metadata 1 */ - IVAS_REND_AudioConfigType inType1, /* i: Type of input 1 */ - float inEne1[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ - MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i: Input metadata 2 */ - IVAS_REND_AudioConfigType inType2, /* i: Type of input 2 */ - float inEne2[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i: TF-energy of input 2 */ + MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ + IVAS_REND_AudioConfigType inType1, /* i : Type of input 1 */ + float inEne1[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ + IVAS_REND_AudioConfigType inType2, /* i : Type of input 2 */ + float inEne2[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 */ ); void copy_masa_descriptive_meta( - MASA_DECRIPTIVE_META *outMeta, /* o: metadata to be written */ - MASA_DECRIPTIVE_META *inMeta /* i: input metadata */ + MASA_DECRIPTIVE_META *outMeta, /* o : metadata to be written */ + MASA_DECRIPTIVE_META *inMeta /* i : input metadata */ ); ivas_error masaPrerendOpen( - MASA_PREREND_HANDLE *hMasaPrerendPtr, /* o: handle to the opened prerenderer */ - int16_t numTransports, /* i: number of transport channels */ - int32_t input_Fs /* i: signal sampling rate */ + MASA_PREREND_HANDLE *hMasaPrerendPtr, /* o : handle to the opened prerenderer */ + int16_t numTransports, /* i : number of transport channels */ + int32_t input_Fs /* i : signal sampling rate */ ); void masaPrerendClose( diff --git a/lib_rend/ivas_reverb_delay_line.c b/lib_rend/ivas_reverb_delay_line.c index 892a0d21c9..a91551f71d 100644 --- a/lib_rend/ivas_reverb_delay_line.c +++ b/lib_rend/ivas_reverb_delay_line.c @@ -160,7 +160,7 @@ void ivas_rev_delay_line_feed_sample_blk( * NOTE: get a sample out of the line before feeding the next *-----------------------------------------------------------------------------------------*/ -/* !r: sample gotten out of delay line, and amplified by set gain */ +/*! r: sample gotten out of delay line, and amplified by set gain */ float ivas_rev_delay_line_get_sample( ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ ) diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter.c index 725f5e6bc1..8b14d2d41e 100644 --- a/lib_rend/ivas_reverb_fft_filter.c +++ b/lib_rend/ivas_reverb_fft_filter.c @@ -58,7 +58,7 @@ static void ifft_wrapper_2ch( float *buffer_L, float *buffer_R, const int16_t ff * NOT valid for integers thar are NOT a power of 2 *-----------------------------------------------------------------------------------------*/ -/* !r: integer log2 */ +/*! r: integer log2 */ uint16_t int_log2( uint32_t powerOf2 ) { diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index f1677def68..2cd2744b5a 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -44,6 +44,17 @@ #include "wmc_auto.h" +/*-----------------------------------------------------------------------* + * Local funtion declarations + *-----------------------------------------------------------------------*/ + +static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, IVAS_VECTOR3 *listenerPos, int16_t numHeadRotQuaternions, EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); + +static void external_target_interpolation( EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, const int16_t i ); + +static bool are_orientations_same( const IVAS_QUATERNION *orientation1, const IVAS_QUATERNION *orientation2 ); + + /*-----------------------------------------------------------------------* * ivas_headTrack_open() * @@ -208,7 +219,7 @@ void rotateAziEle( int16_t *azi, /* o : rotated azimuth */ int16_t *ele, /* o : rotated elevation */ float Rmat[3][3], /* i : real-space rotation matrix */ - const int16_t isPlanar /* i : is rotation planar and elevation meaningless? */ + const int16_t isPlanar /* i : is rotation planar and elevation meaningless? */ ) { int16_t n; @@ -249,11 +260,11 @@ void rotateAziEle( *------------------------------------------------------------------------*/ void rotateFrame_shd( - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : head and external orientation combined handle */ - float *output[], /* i/o: unrotated HOA3 signal buffer in TD */ - const int16_t subframe_len, /* i : subframe length per channel */ - const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ - const int16_t subframe_idx /* i : subframe index */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : head and external orientation combined handle */ + float *output[], /* i/o: unrotated HOA3 signal buffer in TD */ + const int16_t subframe_len, /* i : subframe length per channel */ + const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ + const int16_t subframe_idx /* i : subframe index */ ) { int16_t i, l, n, m; @@ -350,12 +361,12 @@ void rotateFrame_shd( *------------------------------------------------------------------------*/ void rotateFrame_sd( - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : head and external orientation combined handle */ - float *output[], /* i/o: unrotated SD signal buffer in TD */ - const int16_t subframe_len, /* i : subframe length per channel */ - const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ - const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ - const int16_t subframe_idx /* i : subframe index */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : head and external orientation combined handle */ + float *output[], /* i/o: unrotated SD signal buffer in TD */ + const int16_t subframe_len, /* i : subframe length per channel */ + const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ + const int16_t subframe_idx /* i : subframe index */ ) { int16_t i, j; @@ -582,7 +593,7 @@ void rotateFrame_sd_cldfb( float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: unrotated HOA3 signal buffer in cldfb domain imag part */ const IVAS_OUTPUT_SETUP_HANDLE hOutputSetup, /* i : output format setup number of channels */ const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */ - const int16_t numTimeSlots, /* i : number of time slots to process */ + const int16_t numTimeSlots, /* i : number of time slots to process */ const int16_t nb_band /* i : number of CLDFB bands to process */ ) { @@ -745,7 +756,7 @@ void ivas_external_orientation_close( *-----------------------------------------------------------------------*/ ivas_error ivas_combined_orientation_open( - COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* o : combined orientation handle */ + COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* o : combined orientation handle */ ) { int16_t i, j; @@ -811,7 +822,7 @@ ivas_error ivas_combined_orientation_open( *-----------------------------------------------------------------------*/ void ivas_combined_orientation_close( - COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* i/o: combined orientation handle */ + COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData /* i/o: combined orientation handle */ ) { if ( hCombinedOrientationData == NULL || *hCombinedOrientationData == NULL ) @@ -833,9 +844,9 @@ void ivas_combined_orientation_close( *------------------------------------------------------------------------*/ ivas_error combine_external_and_head_orientations_dec( - HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ + HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ + EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) { IVAS_QUATERNION *headRotQuaternions = NULL; @@ -863,9 +874,9 @@ ivas_error combine_external_and_head_orientations_dec( *------------------------------------------------------------------------*/ ivas_error combine_external_and_head_orientations_rend( - IVAS_REND_HeadRotData *hHeadTrackData, /* i : head track handle */ - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ + IVAS_REND_HeadRotData *hHeadTrackData, /* i : head track handle */ + EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) { IVAS_QUATERNION *headRotQuaternions = NULL; @@ -904,12 +915,12 @@ ivas_error combine_external_and_head_orientations_rend( * NOTE that the external orientations are inversed. *------------------------------------------------------------------------*/ -ivas_error combine_external_and_head_orientations( - IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ - IVAS_VECTOR3 *listenerPos, /* i : listener position */ - int16_t numHeadRotQuaternions, /* i : number of head rotation quaternions */ - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ +static ivas_error combine_external_and_head_orientations( + IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ + IVAS_VECTOR3 *listenerPos, /* i : listener position */ + int16_t numHeadRotQuaternions, /* i : number of head rotation quaternions */ + EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) { int16_t i, j; @@ -1158,9 +1169,9 @@ ivas_error combine_external_and_head_orientations( * *------------------------------------------------------------------------*/ -void external_target_interpolation( - EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ +static void external_target_interpolation( + EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i/o: combined orientation handle */ const int16_t i ) { /* Sanity check for number of frames */ @@ -1198,6 +1209,8 @@ void external_target_interpolation( hCombinedOrientationData->interpolationIncrement = 1.0f; hCombinedOrientationData->Quaternions[i] = hExtOrientationData->Quaternions[i]; } + + return; } @@ -1207,12 +1220,13 @@ void external_target_interpolation( * *------------------------------------------------------------------------*/ -bool are_orientations_same( +static bool are_orientations_same( const IVAS_QUATERNION *orientation1, const IVAS_QUATERNION *orientation2 ) { bool orientationsAreSame = true; float error_margin = 0.05f; + if ( fabsf( orientation1->w - orientation2->w ) > error_margin || fabsf( orientation1->x - orientation2->x ) > error_margin || fabsf( orientation1->y - orientation2->y ) > error_margin || diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index d8d6127b20..88e96d2916 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -309,13 +309,13 @@ ivas_error IVAS_REND_MergeMasaMetadata( ); ivas_error IVAS_REND_SetTotalNumberOfObjects( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ - const uint16_t total_num_objects /* i: total number of objects */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + const uint16_t total_num_objects /* i : total number of objects */ ); ivas_error IVAS_REND_GetNumAllObjects( - IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ - int16_t *numChannels /* o : number of all objects */ + IVAS_REND_CONST_HANDLE hIvasRend, /* i : Renderer handle */ + int16_t *numChannels /* o : number of all objects */ ); ivas_error IVAS_REND_GetSamples( diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index eadcc9e1da..e2181ca6e1 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -727,8 +727,8 @@ static ivas_error ivas_hrtf_init( *---------------------------------------------------------------------*/ static ivas_error create_HRTF_from_rawdata( - HRTFS_HANDLE *hHRTF, /* i/o: HRTF CRend handle */ - char *hrtf_data /* i: pointer to binary file */ + HRTFS_HANDLE *hHRTF, /* i/o: HRTF CRend handle */ + char *hrtf_data /* i : pointer to binary file */ ) { int16_t i, j, k; diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 2b59c3150b..a731416570 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -86,9 +86,9 @@ ivas_error load_HRTF_binary( *---------------------------------------------------------------------*/ ivas_error create_SetOfHRTF_from_binary( - IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: Set of HRTF CRend handle */ - const hrtfFileReader *hrtfReader, /* i: pointer to hrtfFileReader handle */ - int32_t output_Fs /* i: Output sampling frequency */ + IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: Set of HRTF CRend handle */ + const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */ + int32_t output_Fs /* i : Output sampling frequency */ ); @@ -110,7 +110,7 @@ ivas_error destroy_SetOfHRTF( *---------------------------------------------------------------------*/ ivas_error load_fastconv_HRTF_from_binary( - IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ + IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv, /* i/o: FastConv HRTF handle */ const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ); @@ -122,7 +122,7 @@ ivas_error load_fastconv_HRTF_from_binary( *---------------------------------------------------------------------*/ ivas_error load_parambin_HRTF_from_binary( - IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin, /* i/o: Parambin HRTF handle */ + IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin, /* i/o: Parambin HRTF handle */ const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ); diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index d9477ad9dc..a3b04563e4 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -40,7 +40,7 @@ /*------------------------------------------------------------------------------------------* - * PreProc Macros + * PreProc Local Macros *------------------------------------------------------------------------------------------*/ #define MAX_LINE_LENGTH ( 1024 ) @@ -65,7 +65,7 @@ #define INPUTPREDELAY_MAX ( 1.0e+2f ) /*------------------------------------------------------------------------------------------* - * Type definitions + * Local Type definitions *------------------------------------------------------------------------------------------*/ struct RenderConfigReader @@ -76,10 +76,11 @@ struct RenderConfigReader /*-----------------------------------------------------------------------------------------* * Function read_bool() + * * Reads a boolean value from a line *-----------------------------------------------------------------------------------------*/ -/* !r: false on success, true on failure */ +/*! r: false on success, true on failure */ static int16_t read_bool( const char *pLine, /* i : String to read from */ int16_t *pTarget /* o : Output pointer (int16_t type used instead of bool because of coding rules/specs) */ @@ -193,7 +194,7 @@ static void strip_spaces_upper( * Prints error message and exits *-----------------------------------------------------------------------------------------*/ -/* !r: error accumulation */ +/*! r: error accumulation */ static int32_t errorHandler( const char *badStr, /* i : String to complain about */ const ERROR_CODES_t error ) -- GitLab From eede2327597f16e0f4445e3803df3a5f9c33ad43 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jun 2023 10:30:15 +0200 Subject: [PATCH 10/12] clang-format --- lib_com/ivas_fb_mixer.c | 4 +- lib_enc/lsf_msvq_ma_enc.c | 134 +++++++++++++++++++------------------- 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 40a86d08f2..b95de4327a 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -829,8 +829,8 @@ static int16_t ivas_calculate_abs_fr( float short_stride_nrg = 0.0f; float cldfb_nrg = 0.0f; int16_t short_stride = pFb->fb_bin_to_band.short_stride; - const int16_t num_bins_per_short_stride_bin = (const int16_t) ( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); - const int16_t num_bins_per_cldfb_band = (const int16_t) ( ( sampling_rate / FRAMES_PER_SEC ) / pFb->fb_bin_to_band.num_cldfb_bands ); + const int16_t num_bins_per_short_stride_bin = ( const int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / short_stride ); + const int16_t num_bins_per_cldfb_band = ( const int16_t )( ( sampling_rate / FRAMES_PER_SEC ) / pFb->fb_bin_to_band.num_cldfb_bands ); float short_stride_max_per_spar_band = 1e-9f; /*loop over all stored Filter Bank Response MDFT coefficients*/ diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index a70b85013c..349fb4f60f 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -453,85 +453,36 @@ void msvq_enc( else /* non-DCT Stage #1 code below */ if ( !s ) /* means: m==1 */ - { - /* This loop is identical to the one below, except, that the inner loop over c=0..m is hardcoded to c=0, since m=1. */ - /* dist[0][0] */ - for ( j = 0; j < levels[s]; j++ ) { - en = 0.0f; - /* w,Tmp */ - /* Compute weighted codebook element and its energy */ - for ( c2 = 0; c2 < n; c2++ ) - { - Tmp[start + c2] = w[start + c2] * cbp[c2]; - en += cbp[c2] * Tmp[start + c2]; - } - cbp += maxn; /* pointer is incremented */ - - pTmp = &resid[0][0]; - /* Tmp */ - tmp = ( *pTmp++ ) * Tmp[0]; - for ( c2 = 1; c2 < N; c2++ ) - { - tmp += ( *pTmp++ ) * Tmp[c2]; - } - tmp = en - 2.0f * tmp; - tmp += dist[0][0]; - if ( tmp < dist[1][p_max] ) + /* This loop is identical to the one below, except, that the inner loop over c=0..m is hardcoded to c=0, since m=1. */ + /* dist[0][0] */ + for ( j = 0; j < levels[s]; j++ ) { - /* Replace worst */ - dist[1][p_max] = tmp; - indices[1][p_max * stages] = j; - parents[p_max] = 0; - - p_max = 0; - for ( c2 = 1; c2 < maxC; c2++ ) + en = 0.0f; + /* w,Tmp */ + /* Compute weighted codebook element and its energy */ + for ( c2 = 0; c2 < n; c2++ ) { - if ( dist[1][c2] > dist[1][p_max] ) - { - p_max = c2; - } + Tmp[start + c2] = w[start + c2] * cbp[c2]; + en += cbp[c2] * Tmp[start + c2]; } - } /* if (tmp <= dist[1][p_max]) */ - } /* for (j=0; j dist[1][p_max] ) + { + p_max = c2; + } + } + } /* if (tmp <= dist[1][p_max]) */ + } /* for(c=0; c Date: Mon, 19 Jun 2023 10:32:46 +0200 Subject: [PATCH 11/12] comments: // ... -> /* ... */ --- lib_enc/ivas_stereo_dmx_evs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs.c index 0db97b28d1..63e7f3e656 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -175,7 +175,7 @@ void estimate_itd_wnd_fft( static void calc_poc( STEREO_DMX_EVS_POC_HANDLE hPOC, /* i/o: phase only correlation structure */ - STEREO_DMX_EVS_PHA_HANDLE hPHA, /* i/o : correlation filter structure */ + STEREO_DMX_EVS_PHA_HANDLE hPHA, /* i/o : correlation filter structure */ const float wnd[], /* i : window coef */ const float rfft_coef[], /* i : RFFT coef */ const float specLr[], /* i : Lch real-part spectra */ @@ -390,7 +390,7 @@ static void calc_poc( freq_8k = L_FRAME16k / 2; freq_ipd_max = (int16_t) ( freq_8k * 5000.0f / ( 8000.0f * STEREO_DMX_EVS_SUBBAND_SIZE ) ); - // Memorize the filters N-1 + /* Memorize the filters N-1 */ for ( n = 0; n < CPE_CHANNELS; n++ ) { if ( hPHA->p_curr_taps[n] ) @@ -877,7 +877,7 @@ static float find_poc_peak( static ivas_error estimate_itd( float *corr, /* o : correlation */ STEREO_DMX_EVS_POC_HANDLE hPOC, /* i/o: phase only correlation structure */ - STEREO_DMX_EVS_PHA_HANDLE hPHA, /* i/o : correlation filter structure */ + STEREO_DMX_EVS_PHA_HANDLE hPHA, /* i/o: correlation filter structure */ const float srcL[], /* i : Lch input signal */ const float srcR[], /* i : Rch input signal */ float itd[], /* o : estimated itd */ @@ -1113,9 +1113,9 @@ static void create_M_signal( *-------------------------------------------------------------------*/ void stereo_dmx_evs_enc( - STEREO_DMX_EVS_ENC_HANDLE hStereoDmxEVS, /* i/o: Stereo downmix for EVS encoder handle */ - const int32_t input_Fs, /* i : input sampling rate */ - int16_t data[CPE_CHANNELS * L_FRAME48k], /* i/o: input signal */ + STEREO_DMX_EVS_ENC_HANDLE hStereoDmxEVS, /* i/o: Stereo downmix for EVS encoder handle */ + const int32_t input_Fs, /* i : input sampling rate */ + int16_t data[CPE_CHANNELS * L_FRAME48k], /* i/o: input signal */ const int16_t n_samples, /* i : number of input samples */ const bool is_binaural /* i : indication that input is binaural audio */ ) -- GitLab From 8a184b804d8b96f36dfe8d71281570dcf675d0a6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 19 Jun 2023 10:37:43 +0200 Subject: [PATCH 12/12] comments: // ... -> /* ... */ --- lib_dec/fd_cng_dec.c | 2 +- lib_enc/ivas_stereo_dmx_evs.c | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 45ab2e3435..5e36f024f8 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -1360,7 +1360,7 @@ void generate_comfort_noise_dec_hf( { seed2 = &( hFdCngCom->seed3 ); - c1 = (float) sqrt( hFdCngCom->coherence ); // VE!!!!! all occurences of "(float) sqrt()" should be replaced by "sqrtf()" + c1 = (float) sqrt( hFdCngCom->coherence ); c2 = (float) sqrt( 1 - hFdCngCom->coherence ); } diff --git a/lib_enc/ivas_stereo_dmx_evs.c b/lib_enc/ivas_stereo_dmx_evs.c index 63e7f3e656..46014fded0 100644 --- a/lib_enc/ivas_stereo_dmx_evs.c +++ b/lib_enc/ivas_stereo_dmx_evs.c @@ -404,7 +404,7 @@ static void calc_poc( } } - // ISD + /* ISD */ isd_cnt_l = 0; isd_cnt_h = 0; for ( i = 1; i <= freq_8k; i++ ) @@ -484,17 +484,17 @@ static void calc_poc( for ( j = 0; j < STEREO_DMX_EVS_SUBBAND_SIZE; j++, i++ ) { - // Energy + /* Energy */ tEl[n] += specLr[i] * specLr[i] + specLi[i] * specLi[i]; tEr[n] += specRr[i] * specRr[i] + specRi[i] * specRi[i]; - // IPD + /* IPD */ IPDr = specLr[i] * specRr[i] + specLi[i] * specRi[i]; IPDi = specLi[i] * specRr[i] - specLr[i] * specRi[i]; tPr += IPDr; tPi += IPDi; - // ICCr + /* ICCr */ Pn = (float) inv_sqrt( ( IPDr * IPDr + IPDi * IPDi ) + EPSILON ); IPDr *= Pn; IPDi *= Pn; @@ -575,7 +575,7 @@ static void calc_poc( { if ( ( hPHA->iccr_s < STEREO_DMX_EVS_ICCR_HYST_L ) || ( ( hPHA->iccr_s < STEREO_DMX_EVS_ICCR_HYST_H ) && ( hPHA->p_curr_taps[0] != NULL ) ) ) { - // IPDn + /* IPDn */ set_f( &( Pr[freq_ipd_max] ), 1.0f, ( nsbd - freq_ipd_max ) ); set_f( &( Pi[freq_ipd_max] ), 0.0f, ( nsbd - freq_ipd_max ) ); @@ -625,7 +625,7 @@ static void calc_poc( rfft( rfft_pha_buf, hPHA->rfft_ipd_coef, input_frame_pha, +1 ); mvr2r( rfft_pha_buf, hPHA->p_curr_taps[1], hPHA->pha_len ); - // PHA L2R + /* PHA L2R */ p_curr_taps = hPHA->p_curr_taps[0]; p_curr_taps[0] = rfft_pha_buf[0]; for ( i = 1; i < hPHA->pha_len; i++ ) @@ -1195,7 +1195,7 @@ void stereo_dmx_evs_enc( estimate_itd( &corr, hStereoDmxEVS->hPOC, hStereoDmxEVS->hPHA, data_f[0], data_f[1], &hStereoDmxEVS->itd, input_frame ); - // poc + /* poc */ if ( hStereoDmxEVS->itd ) { @@ -1209,7 +1209,7 @@ void stereo_dmx_evs_enc( create_M_signal( data_f[0], data_f[1], dmx_poc_data, dmx_weight, input_frame, hStereoDmxEVS->s_wnd, hStereoDmxEVS->dmx_weight, hStereoDmxEVS->pre_dmx_energy, hStereoDmxEVS->aux_dmx_energy ); - // pha + /* pha */ pha_len = hStereoDmxEVS->hPHA->pha_len; fad_len = hStereoDmxEVS->hPHA->fad_len; @@ -1273,7 +1273,7 @@ void stereo_dmx_evs_enc( dmx_pha_data[n] += ( mem_prev[n] ) * fad_g[m]; } - // prc switch + /* prc switch */ curr_prc = hStereoDmxEVS->hPHA->curr_prc; if ( abs( (int16_t) hStereoDmxEVS->itd ) > hStereoDmxEVS->hPHA->prc_thres ) @@ -1543,10 +1543,10 @@ ivas_error stereo_dmx_evs_init_encoder( hStereoDmxEVS->hPHA->prev_pha = STEREO_DMX_EVS_PHA_IPD; hStereoDmxEVS->hPHA->pha_hys_cnt = 0; - // Compute the forgetting factor + /* Compute the forgetting factor */ a_min = 0.8576958985908941f; a_max = 0.9440608762859234f; - itrh = (int16_t) ( ( 3000 * input_frame ) / ( input_Fs * STEREO_DMX_EVS_SUBBAND_SIZE ) ); // 3kHz + itrh = (int16_t) ( ( 3000 * input_frame ) / ( input_Fs * STEREO_DMX_EVS_SUBBAND_SIZE ) ); /* 3kHz */ n0 = L_FRAME16k / ( 2 * STEREO_DMX_EVS_SUBBAND_SIZE ); a_step = ( a_min - a_max ) / ( n0 + 1 - itrh ); ipd_ff = hStereoDmxEVS->hPHA->ipd_ff; @@ -1554,7 +1554,7 @@ ivas_error stereo_dmx_evs_init_encoder( { ipd_ff[n] = a_max; } - for ( ; n < ( n0 + 1 ); n++ ) // 8kHz + for ( ; n < ( n0 + 1 ); n++ ) /* 8kHz */ { ipd_ff[n] = a_max + ( n - itrh ) * a_step; } -- GitLab