From 9649dad5232f5eabca597721934243e9890435ca Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Apr 2023 12:29:34 +0200 Subject: [PATCH 1/9] fix build when MASA_AND_OBJECTS is disabled --- lib_com/options.h | 10 +++++----- lib_dec/ivas_cpe_dec.c | 2 ++ lib_dec/ivas_sce_dec.c | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8bd854e1b4..f5f9f9d214 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -58,13 +58,13 @@ #ifdef DEBUGGING -#define DEBUG_MODE_INFO /* output most important parameters to the subdirectory "res/" */ +/*#define DEBUG_MODE_INFO*/ /* output most important parameters to the subdirectory "res/" */ #ifdef DEBUG_MODE_INFO -#define DEBUG_MODE_ACELP /* output most important ACELP core parameters to the subdirectory "res/" */ +/*#define DEBUG_MODE_ACELP*/ /* output most important ACELP core parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_TCX*/ /* output most important TCX core parameters to the subdirectory "res/" */ -/*#define DEBUG_MODE_DFT */ /* output most important DFT stereo parameters to the subdirectory "res/" */ -#define DEBUG_MODE_TD /* output most important TD stereo parameters to the subdirectory "res/ */ -//#define DEBUG_MODE_DIRAC /* output most important DIRAC parameters to the subdirectory "res/" */ +/*#define DEBUG_MODE_DFT */ /* output most important DFT stereo parameters to the subdirectory "res/" */ +/*#define DEBUG_MODE_TD*/ /* output most important TD stereo parameters to the subdirectory "res/ */ +/*#define DEBUG_MODE_DIRAC*/ /* output most important DIRAC parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_MDCT*/ /* output most important MDCT parameters to the subdirectory "res/" */ /*#define DEBUG_MODE_PARAM_MC */ /* output Parametric MC paramters to the subdirectory "res/" */ /*#define DEBUG_MODE_PARAM_ISM*/ /* output Parametric ISM paramters to the subdirectory "res/" */ diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index f78f5f08c8..12bcab4584 100755 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -597,12 +597,14 @@ ivas_error ivas_cpe_dec( dbgwrite( output[j], sizeof( float ), output_frame, 1, fname( debug_dir, "output.cpe", j, cpe_id, DEC ) ); } +#ifdef MASA_AND_OBJECTS if ( st_ivas->ivas_format != MASA_ISM_FORMAT ) { tmpF = 0; dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.sce", 0, cpe_id, DEC ) ); dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.mct", 0, cpe_id, DEC ) ); } +#endif } } #endif diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index ccb5fcca89..dc44097d9d 100755 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -326,12 +326,14 @@ ivas_error ivas_sce_dec( dbgwrite( output, sizeof( float ), output_frame, 1, fname( debug_dir, "output.sce", 0, sce_id, DEC ) ); +#ifdef MASA_AND_OBJECTS if ( st_ivas->ivas_format != MASA_ISM_FORMAT ) { tmpF = 0; dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.cpe", 0, sce_id, DEC ) ); dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "output.mct", 0, sce_id, DEC ) ); } +#endif } } #endif -- GitLab From 8d38e91d2277806687070c44d9c38cfbdb70307e Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Apr 2023 12:32:04 +0200 Subject: [PATCH 2/9] fix in tdm_configure_dec() within MASA_AND_OBJECTS --- lib_dec/ivas_stereo_td_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index e613e8ea2e..fbfa270727 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -291,7 +291,7 @@ void tdm_configure_dec( /* set the BW of the secondary channel */ #ifdef MASA_AND_OBJECTS - if ( hStereoTD->tdm_LRTD_flag && sts[1]->bits_frame_channel > IVAS_16k4 / FRAMES_PER_SEC ) + if ( hStereoTD->tdm_LRTD_flag && sts[1]->bits_frame_channel >= IVAS_16k4 / FRAMES_PER_SEC ) #else if ( hStereoTD->tdm_LRTD_flag && hCPE->element_brate > IVAS_13k2 ) #endif -- GitLab From d5025ce2109d4e1934b148b311443a2b3690c4e2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Apr 2023 12:34:40 +0200 Subject: [PATCH 3/9] clang-format --- lib_dec/ivas_dirac_dec.c | 82 ++++++++++++++++----------------- lib_dec/ivas_ism_metadata_dec.c | 12 ++--- lib_dec/ivas_ism_renderer.c | 6 +-- lib_enc/ivas_cpe_enc.c | 4 +- lib_enc/ivas_enc.c | 4 +- lib_enc/ivas_stereo_td_enc.c | 4 +- 6 files changed, 56 insertions(+), 56 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index e471738ca3..e2bf03e4fb 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -321,7 +321,7 @@ ivas_error ivas_dirac_dec_config( if ( ( hDirAC->masa_stereo_type_detect = (MASA_STEREO_TYPE_DETECT *) malloc( sizeof( MASA_STEREO_TYPE_DETECT ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } + } } ivas_masa_init_stereotype_detection( hDirAC->masa_stereo_type_detect ); } @@ -401,7 +401,7 @@ ivas_error ivas_dirac_dec_config( if ( ( hDirAC->proto_index_diff = (int16_t *) malloc( sizeof( int16_t ) * hDirAC->num_outputs_diff ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } + } } if ( hDirAC->num_outputs_dir != num_outputs_dir_old && flag_config == DIRAC_RECONFIGURE ) @@ -410,7 +410,7 @@ ivas_error ivas_dirac_dec_config( if ( ( hDirAC->proto_index_dir = (int16_t *) malloc( sizeof( int16_t ) * hDirAC->num_outputs_dir ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } + } } set_s( hDirAC->proto_index_dir, 0, hDirAC->num_outputs_dir ); @@ -420,7 +420,7 @@ ivas_error ivas_dirac_dec_config( if ( ( hDirAC->proto_index_diff = (int16_t *) malloc( sizeof( int16_t ) * hDirAC->num_outputs_diff ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } + } } set_s( hDirAC->proto_index_diff, 0, hDirAC->num_outputs_diff ); @@ -543,7 +543,7 @@ ivas_error ivas_dirac_dec_config( if ( ( hDirAC->diffuse_response_function = (float *) malloc( sizeof( float ) * hDirAC->num_outputs_dir ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } + } } /* reallocate static memory */ else if ( flag_config == DIRAC_RECONFIGURE && hDirAC->num_outputs_dir != num_outputs_dir_old ) @@ -553,7 +553,7 @@ ivas_error ivas_dirac_dec_config( if ( ( hDirAC->diffuse_response_function = (float *) malloc( sizeof( float ) * hDirAC->num_outputs_dir ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } + } } if ( ( hDirAC->synthesisConf == DIRAC_SYNTHESIS_PSD_LS ) || ( hDirAC->synthesisConf == DIRAC_SYNTHESIS_PSD_SHD ) || ( hDirAC->synthesisConf == DIRAC_SYNTHESIS_MONO ) ) @@ -574,7 +574,7 @@ ivas_error ivas_dirac_dec_config( if ( ( hDirAC->hoa_encoder = (float *) malloc( nchan_out_woLFE * hDirAC->num_outputs_diff * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } + } } else if ( flag_config == DIRAC_RECONFIGURE && hDirAC->hoa_encoder && ( hDirAC->num_outputs_diff != num_outputs_diff_old ) ) { @@ -583,7 +583,7 @@ ivas_error ivas_dirac_dec_config( if ( ( hDirAC->hoa_encoder = (float *) malloc( nchan_out_woLFE * hDirAC->num_outputs_diff * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } + } } set_f( hDirAC->hoa_encoder, 0.0f, nchan_out_woLFE * hDirAC->num_outputs_diff ); compute_hoa_encoder_mtx( ls_azimuth, ls_elevation, hDirAC->hoa_encoder, hDirAC->num_outputs_diff, hDirAC->hOutSetup.ambisonics_order ); @@ -673,17 +673,17 @@ ivas_error ivas_dirac_dec_config( if ( ( flag_config == DIRAC_OPEN && hDirAC->proto_signal_decorr_on ) || ( flag_config == DIRAC_RECONFIGURE && ( hDirAC->proto_signal_decorr_on && !proto_signal_decorr_on_old ) ) ) { 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, + &( 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; - } + } } else if ( flag_config == DIRAC_RECONFIGURE && ( !hDirAC->proto_signal_decorr_on && proto_signal_decorr_on_old ) ) { @@ -697,19 +697,19 @@ ivas_error ivas_dirac_dec_config( 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, + &( 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; + } } } - } /* output synthesis */ if ( flag_config == DIRAC_OPEN ) @@ -755,7 +755,7 @@ ivas_error ivas_dirac_dec_config( if ( ( hDirAC->proto_frame_f = (float *) malloc( sizeof( float ) * 2 * hDirAC->num_protos_diff * hDirAC->num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } + } } else if ( flag_config == DIRAC_RECONFIGURE && ( hDirAC->num_protos_diff != num_protos_diff_old ) ) { @@ -764,9 +764,9 @@ ivas_error ivas_dirac_dec_config( if ( ( hDirAC->proto_frame_f = (float *) malloc( sizeof( float ) * 2 * hDirAC->num_protos_diff * hDirAC->num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); + } } } - } if ( flag_config == DIRAC_OPEN ) @@ -793,7 +793,7 @@ ivas_error ivas_dirac_dec_config( if ( ( hDirAC->buffer_energy = (float *) malloc( DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC\n" ) ); - } + } } set_f( hDirAC->buffer_energy, 0.0f, DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX ); } @@ -1329,9 +1329,9 @@ static ivas_error ivas_dirac_alloc_mem( if ( ( hDirAC_mem->frame_dec_f = (float *) malloc( sizeof( float ) * 2 * num_outputs_diff * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } } } - } hDirAC->h_output_synthesis_psd_state.proto_power_smooth = hDirAC_mem->proto_power_smooth; hDirAC->h_output_synthesis_psd_state.proto_power_diff_smooth = hDirAC_mem->proto_power_diff_smooth; hDirAC->h_output_synthesis_psd_state.cy_auto_dir_smooth = hDirAC_mem->cy_auto_dir_smooth; @@ -1388,17 +1388,17 @@ static ivas_error ivas_dirac_alloc_mem( if ( ( hDirAC_mem->proto_diffuse_buffer_f = (float *) malloc( sizeof( float ) * 2 * MAX_PARAM_SPATIAL_SUBFRAMES * size ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); - } + } } else { if ( ( hDirAC_mem->proto_diffuse_buffer_f = (float *) malloc( sizeof( float ) * 2 * MAX_PARAM_SPATIAL_SUBFRAMES * num_outputs_diff * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } } } } - } hDirAC->h_output_synthesis_psd_state.proto_direct_buffer_f = hDirAC_mem->proto_direct_buffer_f; hDirAC->h_output_synthesis_psd_state.proto_diffuse_buffer_f = hDirAC_mem->proto_diffuse_buffer_f; @@ -1410,7 +1410,7 @@ static ivas_error ivas_dirac_alloc_mem( if ( ( hDirAC_mem->direct_power_factor = (float *) malloc( sizeof( float ) * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); - } + } if ( ( hDirAC_mem->diffuse_power_factor = (float *) malloc( sizeof( float ) * num_freq_bands ) ) == NULL ) { @@ -1435,10 +1435,10 @@ static ivas_error ivas_dirac_alloc_mem( if ( ( hDirAC_mem->onset_filter = (float *) malloc( sizeof( float ) * num_outputs_diff * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } } } } - } else { if ( num_protos_dir > 2 ) @@ -1446,7 +1446,7 @@ static ivas_error ivas_dirac_alloc_mem( if ( ( hDirAC_mem->reference_power = (float *) malloc( sizeof( float ) * 5 * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); - } + } } if ( hDirAC->proto_signal_decorr_on ) @@ -1454,9 +1454,9 @@ static ivas_error ivas_dirac_alloc_mem( if ( ( hDirAC_mem->onset_filter = (float *) malloc( sizeof( float ) * 2 * num_freq_bands ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate stack memory for DirAC\n" ) ); + } } } - } return IVAS_ERR_OK; } @@ -1755,10 +1755,10 @@ void ivas_qmetadata_to_dirac( { meta_write_index = ( hDirAC->dirac_bs_md_write_idx + block ) % hDirAC->dirac_md_buffer_length; - for ( band = 0; band < hMasa->config.numCodingBands; ++band ) - { - for ( b = MASA_band_grouping_24[band_mapping[band]]; b < MASA_band_grouping_24[band_mapping[band + 1]]; ++b ) + for ( band = 0; band < hMasa->config.numCodingBands; ++band ) { + for ( b = MASA_band_grouping_24[band_mapping[band]]; b < MASA_band_grouping_24[band_mapping[band + 1]]; ++b ) + { hDirAC->azimuth[meta_write_index][b] = (int16_t) q_direction->band_data[band].azimuth[block]; hDirAC->elevation[meta_write_index][b] = (int16_t) q_direction->band_data[band].elevation[block]; hDirAC->energy_ratio1[meta_write_index][b] = q_direction->band_data[band].energy_ratio[block]; @@ -1827,10 +1827,10 @@ void ivas_qmetadata_to_dirac( { meta_write_index = ( hDirAC->dirac_bs_md_write_idx + block ) % hDirAC->dirac_md_buffer_length; - for ( band = 0; band < hMasa->config.numCodingBands; ++band ) - { - for ( b = MASA_band_grouping_24[band_mapping[band]]; b < MASA_band_grouping_24[band_mapping[band + 1]]; ++b ) + for ( band = 0; band < hMasa->config.numCodingBands; ++band ) { + for ( b = MASA_band_grouping_24[band_mapping[band]]; b < MASA_band_grouping_24[band_mapping[band + 1]]; ++b ) + { hDirAC->azimuth2[meta_write_index][b] = (int16_t) q_direction->band_data[band].azimuth[block]; hDirAC->elevation2[meta_write_index][b] = (int16_t) q_direction->band_data[band].elevation[block]; hDirAC->energy_ratio2[meta_write_index][b] = q_direction->band_data[band].energy_ratio[block]; @@ -1883,7 +1883,7 @@ void ivas_qmetadata_to_dirac( set_s( hDirAC->elevation2[meta_write_index], 0, hDirAC->num_freq_bands ); set_zero( hDirAC->energy_ratio2[meta_write_index], hDirAC->num_freq_bands ); set_zero( hDirAC->spreadCoherence2[meta_write_index], hDirAC->num_freq_bands ); - } + } } #endif } diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 1cc7028c55..0565447847 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -396,8 +396,8 @@ ivas_error ivas_ism_metadata_dec( if ( ism_metadata_flag_global ) { /*----------------------------------------------------------------* - * Metadata decoding and dequantization, loop over all objects - *----------------------------------------------------------------*/ + * Metadata decoding and dequantization, loop over all objects + *----------------------------------------------------------------*/ int16_t total_bits_metadata = 0, bits_metadata_ism = 0; int16_t nb_bits_objcod_read; @@ -732,8 +732,8 @@ ivas_error ivas_ism_metadata_dec( } /*----------------------------------------------------------------* - * Set bitsream pointers - *----------------------------------------------------------------*/ + * Set bitsream pointers + *----------------------------------------------------------------*/ /* set the bitstream pointer to its original position */ st0->bit_stream = bstr_orig; @@ -747,8 +747,8 @@ ivas_error ivas_ism_metadata_dec( #ifdef DISCRETE_ISM_DTX_CNG /*----------------------------------------------------------------* - * Updates - *----------------------------------------------------------------*/ + * Updates + *----------------------------------------------------------------*/ set_s( md_diff_flag, 1, nchan_ism ); diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 00d93d15b6..119845d462 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -256,8 +256,8 @@ void ivas_ism_get_stereo_gains( #ifdef MASA_AND_OBJECTS /*-------------------------------------------------------------------------* -* ivas_masa_ism_separate_object_renderer_open() -* + * ivas_masa_ism_separate_object_renderer_open() + * * Open structures, reserve memory, and init values. *-------------------------------------------------------------------------*/ @@ -348,7 +348,7 @@ void ivas_masa_ism_separate_object_render( lfe_index = st_ivas->hDirAC->hOutSetup.index_lfe[0]; #ifdef OMASA_UPDATES - if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) #else if ( st_ivas->ism_mode == ISM_MASA_MODE_ONE_OBJ ) #endif diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 490cd41d1e..bfa7d86756 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -820,7 +820,7 @@ ivas_error ivas_cpe_enc( dbgwrite( &n, 2, 1, input_frame, "res/TCA_idx_NCShift" ); dbgwrite( &n, 2, 1, input_frame, "res/TCA_idx_ica_gD" ); n = -1; - //dbgwrite( &n, 2, 1, input_frame, "res/tdm_ratio_idx.enc" ); + // dbgwrite( &n, 2, 1, input_frame, "res/tdm_ratio_idx.enc" ); } else if ( hCPE->element_mode == IVAS_CPE_TD ) { @@ -837,7 +837,7 @@ ivas_error ivas_cpe_enc( else if ( hCPE->element_mode == IVAS_CPE_MDCT ) { n = -2; - //dbgwrite( &n, 2, 1, input_frame, "res/tdm_ratio_idx.enc" ); + // dbgwrite( &n, 2, 1, input_frame, "res/tdm_ratio_idx.enc" ); } { diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 5d329701cb..920193c999 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -249,7 +249,7 @@ ivas_error ivas_enc( ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1 #ifdef MASA_AND_OBJECTS , - ISM_MODE_NONE, -1, NULL, -1, NULL, 0 + ISM_MODE_NONE, -1, NULL, -1, NULL, 0 #endif ) ) != IVAS_ERR_OK ) { @@ -459,7 +459,7 @@ ivas_error ivas_enc( if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1 #ifdef MASA_AND_OBJECTS , - ISM_MODE_NONE, -1, NULL, -1, NULL, 0 + ISM_MODE_NONE, -1, NULL, -1, NULL, 0 #endif ) ) != IVAS_ERR_OK ) { diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 82e3f4bdfd..7c0649c5ab 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -283,8 +283,8 @@ ivas_error stereo_set_tdm( dbgwrite( &tmp, 2, 1, 320, "res/inst_ratio_L" ); dbgwrite( &ftmp, 4, 1, 320, "res/ratio_L" ); dbgwrite( &tmp, 2, 1, 320, "res/tdm_low_rate_mode" ); - //dbgwrite( &tmp, 2, 1, 320, "res/tdm_lp_reuse_flag" ); - //dbgwrite( &tmp, 2, 1, 320, "res/mod_ct.enx" ); + // dbgwrite( &tmp, 2, 1, 320, "res/tdm_lp_reuse_flag" ); + // dbgwrite( &tmp, 2, 1, 320, "res/mod_ct.enx" ); } #endif hCPE->hCoreCoder[0]->tdm_LRTD_flag = 0; -- GitLab From b12b6b9a5cd566d1778323c0c7f1d148f8f2f4cc Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Apr 2023 12:37:50 +0200 Subject: [PATCH 4/9] build warnings --- lib_enc/ivas_masa_enc.c | 4 ++-- lib_enc/ivas_omasa_enc.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 5e81132ced..c62fc4b3bf 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -71,7 +71,7 @@ static void quantize_ratio_ism_vector( const float *ratio_ism, int16_t *idx, con static int16_t index_slice_enum( const int16_t *ratio_ism_idx, const int16_t nchan_ism ); -static int16_t encode_ratio_ism_subframe( const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t numCodingBands, const int16_t sf, const int16_t ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], BSTR_ENC_HANDLE hMetaData, const float *masa_to_total_energy_ratio, const int16_t shift_one, const int16_t idx_sep_obj ); +static int16_t encode_ratio_ism_subframe( const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const uint8_t numCodingBands, const int16_t sf, const int16_t ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], BSTR_ENC_HANDLE hMetaData, const float *masa_to_total_energy_ratio, const int16_t shift_one, const int16_t idx_sep_obj ); static void transform_index_and_GR_encode( int16_t *diff_idx, const int16_t len, const int16_t GR_order, BSTR_ENC_HANDLE hMetaData ); @@ -3064,7 +3064,7 @@ static void estimate_bits_subband_ism_ratio( static int16_t encode_ratio_ism_subframe( const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, - const int16_t numCodingBands, + const uint8_t numCodingBands, const int16_t sf, const int16_t ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], BSTR_ENC_HANDLE hMetaData, diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index 86b5cbe90f..ac89c528a6 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -228,13 +228,11 @@ ivas_error ivas_omasa_enc_config( { int16_t k, sce_id, nSCE_old; int32_t ivas_total_brate, ism_total_brate; - ISM_MODE ism_mode_old; ENCODER_CONFIG_HANDLE hEncoderConfig; ivas_error error; hEncoderConfig = st_ivas->hEncoderConfig; ivas_total_brate = hEncoderConfig->ivas_total_brate; - ism_mode_old = st_ivas->ism_mode; nSCE_old = st_ivas->nSCE; st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, hEncoderConfig->nchan_ism ); -- GitLab From a0fdc85f356f42c6c7383d8cdddc33912839b683 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Apr 2023 13:12:25 +0200 Subject: [PATCH 5/9] build warnings --- lib_enc/ivas_masa_enc.c | 45 +++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index c62fc4b3bf..67c935d187 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -67,20 +67,6 @@ static void reduce_metadata_further( MASA_ENCODER_HANDLE hMasa, IVAS_QMETADATA_H #endif ); -static void quantize_ratio_ism_vector( const float *ratio_ism, int16_t *idx, const int16_t nchan_ism, const float masa_to_total_energy_ratio, const int16_t idx_sep_object ); - -static int16_t index_slice_enum( const int16_t *ratio_ism_idx, const int16_t nchan_ism ); - -static int16_t encode_ratio_ism_subframe( const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const uint8_t numCodingBands, const int16_t sf, const int16_t ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], BSTR_ENC_HANDLE hMetaData, const float *masa_to_total_energy_ratio, const int16_t shift_one, const int16_t idx_sep_obj ); - -static void transform_index_and_GR_encode( int16_t *diff_idx, const int16_t len, const int16_t GR_order, BSTR_ENC_HANDLE hMetaData ); - -static void transform_difference_index( const int16_t *diff_idx, int16_t *idx, const int16_t len ); - -static void independent_coding_ratio_ism_idx( const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const float *masa_to_total_energy_ratio, const int16_t nchan_ism, const int16_t numCodingBands, const int16_t bits_index, BSTR_ENC_HANDLE hMetaData ); - -static void remove_sep_obj( int16_t *diff_idx, const int16_t nchan_ism, const int16_t idx_sep_obj ); - #else static void reduce_metadata_further( MASA_ENCODER_HANDLE hMasa, IVAS_QMETADATA_HANDLE hqmetadata, const IVAS_FORMAT ivas_format ); #endif @@ -764,6 +750,7 @@ ivas_error ivas_masa_enc_config( { #ifdef FIX_382_MASA_META_FRAMING_ASYNC detect_framing_async( hMasa ); /* detect the offset, set 1sf/4sf mode based on this. potentially also shift the metadata using a history buffer */ + if ( hMasa->data.sync_state.frame_mode == MASA_FRAME_1SF && hMasa->data.sync_state.prev_offset != 0 ) { /* average over sub-frames */ @@ -2871,7 +2858,7 @@ static void transform_index_and_GR_encode( int16_t *diff_idx, /* i : differenc eindex to encode */ const int16_t len, /* i : input length */ const int16_t GR_order, /* i : GR order */ - BSTR_ENC_HANDLE hMetaData /* i/o: bitstream */ + BSTR_ENC_HANDLE hMetaData /* i/o: metadata bitstream handle */ ) { int16_t i; @@ -2893,7 +2880,7 @@ static void transform_index_and_GR_encode( static int16_t try_differential( const int16_t numCodingBands, const float *masa_to_total_energy_ratio, - const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], + int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t bits_index, int16_t *p_b_signif ) @@ -2945,7 +2932,7 @@ static void differential_coding_first_subframe( BSTR_ENC_HANDLE hMetaData, const float *masa_to_total_energy_ratio, const int16_t b_signif, - const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], + int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const int16_t numCodingBands, const int16_t bits_index ) @@ -2982,12 +2969,12 @@ static void differential_coding_first_subframe( static void independent_coding_ratio_ism_idx( - const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], /* i : ISM ratios */ - const float *masa_to_total_energy_ratio, /* i : MASA to total ratios */ - const int16_t nchan_ism, /* i : number of objects */ - const int16_t numCodingBands, /* i : number of subbands */ - const int16_t bits_index, /* i : number of bits per index */ - BSTR_ENC_HANDLE hMetaData /* i/o: bitstream */ + int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], /* i : ISM ratios */ + const float *masa_to_total_energy_ratio, /* i : MASA to total ratios */ + const int16_t nchan_ism, /* i : number of objects */ + const int16_t numCodingBands, /* i : number of subbands */ + const int16_t bits_index, /* i : number of bits per index */ + BSTR_ENC_HANDLE hMetaData /* i/o: metadata bitstream handle */ ) { int16_t b, index; @@ -3040,14 +3027,16 @@ static void estimate_bits_subband_ism_ratio( /* take difference with respect to previous subframe */ v_sub_s( ratio_ism_idx, ratio_ism_idx_ref, diff_idx, nchan_ism ); + if ( shift_one ) { remove_sep_obj( diff_idx, nchan_ism, idx_sep_obj ); } + /* transform difference index into positive */ transform_difference_index( diff_idx, diff_idx, nchan_ism - 1 - shift_one ); - /* GR encoding */ + /* GR encoding */ for ( i = 0; i < nchan_ism - 1 - shift_one; i++ ) { nbits0 += ivas_qmetadata_encode_extended_gr_length( diff_idx[i], 100, 0 ); @@ -3062,11 +3051,11 @@ static void estimate_bits_subband_ism_ratio( static int16_t encode_ratio_ism_subframe( - const int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], + int16_t ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], const int16_t nchan_ism, const uint8_t numCodingBands, const int16_t sf, - const int16_t ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], + int16_t ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], BSTR_ENC_HANDLE hMetaData, const float *masa_to_total_energy_ratio, const int16_t shift_one, @@ -3289,6 +3278,7 @@ static int16_t encode_ratio_ism_subframe( { /* take difference with respect to previous subframe */ v_sub_s( ratio_ism_idx[0], ratio_ism_idx_prev_sf[0], diff_idx, nchan_ism ); + if ( shift_one ) { remove_sep_obj( diff_idx, nchan_ism, idx_sep_obj_local ); @@ -3478,8 +3468,10 @@ static void ivas_encode_masaism_metadata( assert( ( hMasa->data.energy_ratio_ism[sf][band][obj] >= 0 ) && ( hMasa->data.energy_ratio_ism[sf][band][obj] <= 1 ) ); ratio_ism[band][obj] = hMasa->data.energy_ratio_ism[sf][band][obj]; } + /* Quantize ISM ratios */ quantize_ratio_ism_vector( ratio_ism[band], ratio_ism_idx[band], hMasa->data.nchan_ism, hQMetaData->masa_to_total_energy_ratio[sf][band], idx_separated_object ); + if ( n_ism_tmp == numCodingBands && ratio_ism_idx[band][idx_separated_object] != 0 && hQMetaData->masa_to_total_energy_ratio[sf][band] < MASA2TOTAL_THR ) { i = 0; @@ -3553,7 +3545,6 @@ static void ivas_encode_masaism_metadata( encode_ratio_ism_subframe( ratio_ism_idx, hMasa->data.nchan_ism, numCodingBands, sf, ratio_ism_idx_prev_sf, hMetaData, hQMetaData->masa_to_total_energy_ratio[sf], 0, idx_separated_object ); } - /* calculate quantized ISM ratios */ /* save previous subframe indexes */ for ( band = 0; band < numCodingBands; band++ ) -- GitLab From ea30c7e221bfe2cbb1395943c3730e0aa591e7c4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Apr 2023 13:21:46 +0200 Subject: [PATCH 6/9] attempt to fix error: "MemorySanitizer: use-of-uninitialized-value" --- lib_dec/ivas_dirac_output_synthesis_dec.c | 1 + lib_dec/ivas_masa_dec.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib_dec/ivas_dirac_output_synthesis_dec.c b/lib_dec/ivas_dirac_output_synthesis_dec.c index 40883784bd..461ce67274 100644 --- a/lib_dec/ivas_dirac_output_synthesis_dec.c +++ b/lib_dec/ivas_dirac_output_synthesis_dec.c @@ -1526,6 +1526,7 @@ void ivas_dirac_dec_compute_directional_responses( num_channels_dir = hDirAC->num_outputs_dir; azimuth = hDirAC->azimuth[hDirAC->dirac_read_idx]; elevation = hDirAC->elevation[hDirAC->dirac_read_idx]; + #ifdef MASA_AND_OBJECTS if ( hDirAC->numParametricDirections == 2 ) #else diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 959300ca74..99c9cdaf60 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1523,6 +1523,9 @@ void ivas_spar_param_to_masa_param_mapping( /* Set values */ hDirAC = st_ivas->hDirAC; +#ifdef MASA_AND_OBJECTS + hDirAC->numParametricDirections = 1; +#endif hDirAC->numSimultaneousDirections = 1; hDiffuseDist = st_ivas->hDirAC->hDiffuseDist; nchan_transport = st_ivas->nchan_transport; -- GitLab From fce075b35370a055aba597f2f02241c34672b1e9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Apr 2023 13:38:19 +0200 Subject: [PATCH 7/9] attempt to fix error: "MemorySanitizer: use-of-uninitialized-value" --- lib_rend/lib_rend.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 3d2420632d..4249b4790e 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -5312,6 +5312,9 @@ static void copyMasaMetadataToDiracRenderer( int16_t meta_write_index; #endif +#ifdef MASA_AND_OBJECTS + hDirAC->numParametricDirections = meta->descriptive_meta.numberOfDirections; +#endif hDirAC->numSimultaneousDirections = meta->descriptive_meta.numberOfDirections + 1; for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) -- GitLab From d9037ac9e13d6d893f7afbbe1bd00859bb6aaa98 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Apr 2023 14:21:34 +0200 Subject: [PATCH 8/9] updates within OMASA_TUNING_TD_STEREO --- lib_com/ivas_prot.h | 26 +++++++++++++------------- lib_com/ivas_stereo_td_bit_alloc.c | 9 ++++----- lib_dec/ivas_cpe_dec.c | 7 +++---- lib_dec/ivas_stereo_td_dec.c | 22 ++++++++++------------ lib_enc/ivas_cpe_enc.c | 14 ++++++-------- lib_enc/ivas_stereo_td_analysis.c | 10 +++++----- lib_enc/ivas_stereo_td_enc.c | 20 +++++++++----------- 7 files changed, 50 insertions(+), 58 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 1bc5b19ea4..3ca21a13d1 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1826,14 +1826,15 @@ void stereo_tdm_prep_dwnmx ( const float *input1, /* i : right channel input */ const int16_t input_frame /* i : frame lenght */ ); + int16_t stereo_tdm_ener_analysis( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif CPE_ENC_HANDLE hCPE, /* i : CPE structure */ const int16_t input_frame, /* i : Number of samples */ int16_t *tdm_SM_or_LRTD_Pri, /* o : channel combination scheme flag in TD stereo OR LRTD primary channel */ int16_t *tdm_ratio_idx_SM /* o : TDM ratio index for SM mode */ -#ifdef OMASA_TUNING_TD_STEREO - ,const int16_t isOmasa /* i : flag that indicates OMASA format */ -#endif ); void stereo_tdm_downmix( @@ -1852,13 +1853,12 @@ void stereo_td_init_dec( ); void tdm_configure_dec( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ int16_t *tdm_ratio_idx, /* o : ratio index */ const int16_t nb_bits_metadata /* i : number of metadata bits */ -#ifdef OMASA_TUNING_TD_STEREO - ,const int16_t IsOmasa /* i : flag that indicates OMASA format */ -#endif - ); void tdm_upmix_plain( @@ -1905,6 +1905,9 @@ void tdm_ol_pitch_comparison( ); void tdm_configure_enc( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ const float Etot_last[CPE_CHANNELS], /* i/o: Energy of last frame */ const int16_t tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */ @@ -1912,9 +1915,6 @@ void tdm_configure_enc( const int16_t tdm_ratio_idx_SM, /* i : ratio index in SM mode */ const int16_t attack_flag, /* i : Primary channel attack flag */ const int16_t nb_bits_metadata /* i : number of metadata bits */ -#ifdef OMASA_TUNING_TD_STEREO - ,const int16_t IsOmasa /* i : flag that indicates OMASA format */ -#endif ); ivas_error signaling_enc_secondary( @@ -1924,6 +1924,9 @@ ivas_error signaling_enc_secondary( ); void tdm_bit_alloc( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif const int32_t element_brate_wo_meta, /* i : element bitrate without metadata */ const int16_t tdm_lp_reuse_flag, /* i : LPC reusage flag */ int32_t *total_brate_pri, /* o : Allocated primary channel bitrate */ @@ -1938,9 +1941,6 @@ void tdm_bit_alloc( const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ const int16_t coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */ const int16_t tdm_inst_ratio_idx /* i : instantaneous correlation ratio index */ -#ifdef OMASA_TUNING_TD_STEREO - ,const int16_t IsOmasa /* i : flag that indicates OMASA format */ -#endif ); void td_stereo_param_updt( diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index ac56cd6537..48c5eaf8ae 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -74,6 +74,9 @@ *-------------------------------------------------------------------*/ void tdm_bit_alloc( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif const int32_t element_brate_wo_meta, /* i : element bitrate without metadata */ const int16_t tdm_lp_reuse_flag, /* i : LPC reusage flag */ int32_t *total_brate_pri, /* o : Allocated primary channel bitrate */ @@ -88,10 +91,6 @@ void tdm_bit_alloc( const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ const int16_t coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */ const int16_t tdm_inst_ratio_idx_ref /* i : instantaneous correlation ratio idx */ -#ifdef OMASA_TUNING_TD_STEREO - , - const int16_t IsOmasa /* i : flag that indicates OMASA format */ -#endif ) { int16_t idx, four_subfr_fcb, two_subfr_fcb; @@ -141,7 +140,7 @@ void tdm_bit_alloc( /* secondary channel bitrate allocation based on the energy scaling ratio */ #ifdef OMASA_TUNING_TD_STEREO - if ( ( IsOmasa == 0 && ( ( coder_type != UNVOICED ) || tdm_LRTD_flag == 1 ) ) || ( IsOmasa == 1 && coder_type > UNVOICED ) ) + if ( ( ivas_format != MASA_ISM_FORMAT && ( ( coder_type != UNVOICED ) || tdm_LRTD_flag == 1 ) ) || ( ivas_format == MASA_ISM_FORMAT && coder_type > UNVOICED ) ) #else if ( ( coder_type != UNVOICED ) || tdm_LRTD_flag == 1 ) #endif diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 12bcab4584..74f22590ad 100755 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -413,12 +413,11 @@ ivas_error ivas_cpe_dec( { if ( !st_ivas->bfi ) { - tdm_configure_dec( hCPE, &tdm_ratio_idx, nb_bits_metadata + tdm_configure_dec( #ifdef OMASA_TUNING_TD_STEREO - , - ( st_ivas->ivas_format == MASA_ISM_FORMAT || ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->ivas_total_brate == IVAS_24k4 ) ) + st_ivas->ivas_format, #endif - ); + hCPE, &tdm_ratio_idx, nb_bits_metadata ); sts[1]->bit_stream = sts[0]->bit_stream + ( sts[0]->total_brate / FRAMES_PER_SEC ); } diff --git a/lib_dec/ivas_stereo_td_dec.c b/lib_dec/ivas_stereo_td_dec.c index fbfa270727..d8e817638a 100644 --- a/lib_dec/ivas_stereo_td_dec.c +++ b/lib_dec/ivas_stereo_td_dec.c @@ -84,14 +84,12 @@ void stereo_td_init_dec( *-------------------------------------------------------------------*/ void tdm_configure_dec( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ int16_t *tdm_ratio_idx, /* o : ratio index */ const int16_t nb_bits_metadata /* i : number of metadata bits */ -#ifdef OMASA_TUNING_TD_STEREO - , - const int16_t IsOmasa /* i : flag that indicates OMASA format*/ -#endif - ) { STEREO_TD_DEC_DATA_HANDLE hStereoTD; @@ -310,15 +308,15 @@ void tdm_configure_dec( *----------------------------------------------------------------*/ #ifdef MASA_AND_OBJECTS - tdm_bit_alloc( hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, - hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), - &hStereoTD->tdm_low_rate_mode, sts[1]->coder_type, *tdm_ratio_idx, hStereoTD->tdm_Pitch_reuse_flag, - sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, tdm_inst_ratio_idx + tdm_bit_alloc( #ifdef OMASA_TUNING_TD_STEREO - , - IsOmasa + ivas_format, #endif - ); + + hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, + hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), + &hStereoTD->tdm_low_rate_mode, sts[1]->coder_type, *tdm_ratio_idx, hStereoTD->tdm_Pitch_reuse_flag, + sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, tdm_inst_ratio_idx ); #else tdm_bit_alloc( hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC, hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), &hStereoTD->tdm_low_rate_mode, sts[1]->coder_type, *tdm_ratio_idx, hStereoTD->tdm_Pitch_reuse_flag, sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, tdm_inst_ratio_idx ); #endif diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index bfa7d86756..48a343bec1 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -435,12 +435,11 @@ ivas_error ivas_cpe_enc( else if ( hCPE->element_mode == IVAS_CPE_TD ) { /* Determine the energy ratio between the 2 channels */ - tdm_ratio_idx = stereo_tdm_ener_analysis( hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM + tdm_ratio_idx = stereo_tdm_ener_analysis( #ifdef OMASA_TUNING_TD_STEREO - , - st_ivas->hOMasa != NULL + ivas_format, #endif - ); + hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Compute the downmix signal based on the ratio index */ stereo_tdm_downmix( hCPE->hStereoTD, sts[0]->input, sts[1]->input, input_frame, tdm_ratio_idx, ( ( hCPE->hStereoTD->tdm_LRTD_flag == 0 ) ? tdm_SM_or_LRTD_Pri : 0 ), tdm_ratio_idx_SM ); @@ -606,12 +605,11 @@ ivas_error ivas_cpe_enc( { tdm_ol_pitch_comparison( hCPE, pitch_fr, voicing_fr ); - tdm_configure_enc( hCPE, Etot_last, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata + tdm_configure_enc( #ifdef OMASA_TUNING_TD_STEREO - , - st_ivas->hOMasa != NULL + ivas_format, #endif - ); + hCPE, Etot_last, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata ); if ( hEncoderConfig->Opt_DTX_ON ) { diff --git a/lib_enc/ivas_stereo_td_analysis.c b/lib_enc/ivas_stereo_td_analysis.c index 5ef8001b7a..ee07ae2f52 100644 --- a/lib_enc/ivas_stereo_td_analysis.c +++ b/lib_enc/ivas_stereo_td_analysis.c @@ -111,14 +111,13 @@ static float Comp_diff_lt_corr( CPE_ENC_HANDLE hCPE, const int16_t IsSideMono, c *-------------------------------------------------------------------*/ int16_t stereo_tdm_ener_analysis( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif CPE_ENC_HANDLE hCPE, /* i : CPE structure */ const int16_t input_frame, /* i : Number of samples */ int16_t *tdm_SM_or_LRTD_Pri, /* o : channel combination scheme flag in TD stereo OR LRTD primary channel */ int16_t *tdm_ratio_idx_SM /* o : TDM ratio index for SM mode */ -#ifdef OMASA_TUNING_TD_STEREO - , - const int16_t isOmasa /* i : flag that indicates OMASA format */ -#endif ) { float rms_R, rms_L; @@ -200,7 +199,7 @@ int16_t stereo_tdm_ener_analysis( *----------------------------------------------------------------*/ #ifdef OMASA_TUNING_TD_STEREO - if ( isOmasa ) + if ( ivas_format == MASA_ISM_FORMAT ) { if ( ( hCPE->hStereoClassif->lrtd_mode == 1 || hCPE->hStereoTD->prev_fr_LRTD_TD_dec == 1 ) && ( hCPE->element_brate - 50 * FRAMES_PER_SEC + hCPE->brate_surplus + hCPE->brate_surplus < 15000 ) ) @@ -209,6 +208,7 @@ int16_t stereo_tdm_ener_analysis( } } #endif + rms_thd = RMS_MIN; if ( hCPE->hStereoClassif->lrtd_mode == 1 ) { diff --git a/lib_enc/ivas_stereo_td_enc.c b/lib_enc/ivas_stereo_td_enc.c index 7c0649c5ab..d8c8086562 100644 --- a/lib_enc/ivas_stereo_td_enc.c +++ b/lib_enc/ivas_stereo_td_enc.c @@ -302,6 +302,9 @@ ivas_error stereo_set_tdm( *-------------------------------------------------------------------*/ void tdm_configure_enc( +#ifdef OMASA_TUNING_TD_STEREO + const int16_t ivas_format, /* i : IVAS format */ +#endif CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ const float Etot_last[CPE_CHANNELS], /* i/o: Energy of last frame */ const int16_t tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */ @@ -309,10 +312,6 @@ void tdm_configure_enc( const int16_t tdm_ratio_idx_SM, /* i : ratio index in SM mode */ const int16_t attack_flag, /* i : Primary channel attack flag */ const int16_t nb_bits_metadata /* i : number of metadata bits */ -#ifdef OMASA_TUNING_TD_STEREO - , - const int16_t IsOmasa /* i : flag that indicates OMASA format */ -#endif ) { int16_t tdm_ratio_bit_alloc_idx, mod_ct; @@ -485,15 +484,14 @@ void tdm_configure_enc( *----------------------------------------------------------------*/ #ifdef MASA_AND_OBJECTS - tdm_bit_alloc( hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, - hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), - &( hStereoTD->tdm_low_rate_mode ), sts[1]->coder_type, tdm_ratio_bit_alloc_idx, hStereoTD->tdm_Pitch_reuse_flag, - sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, hStereoTD->tdm_inst_ratio_idx + tdm_bit_alloc( #ifdef OMASA_TUNING_TD_STEREO - , - IsOmasa + ivas_format, #endif - ); + hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC + hCPE->brate_surplus, + hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), + &( hStereoTD->tdm_low_rate_mode ), sts[1]->coder_type, tdm_ratio_bit_alloc_idx, hStereoTD->tdm_Pitch_reuse_flag, + sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, hStereoTD->tdm_inst_ratio_idx ); #else tdm_bit_alloc( hCPE->element_brate - nb_bits_metadata * FRAMES_PER_SEC, hStereoTD->tdm_lp_reuse_flag, &( sts[0]->total_brate ), &( sts[1]->total_brate ), &( hStereoTD->tdm_low_rate_mode ), sts[1]->coder_type, tdm_ratio_bit_alloc_idx, hStereoTD->tdm_Pitch_reuse_flag, sts[0]->bwidth, sts[1]->bwidth, sts[0]->flag_ACELP16k, hStereoTD->tdm_LRTD_flag, mod_ct, hStereoTD->tdm_inst_ratio_idx ); #endif -- GitLab From b2357112fb13c7c59f7068381e480a47529a5cd3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 26 Apr 2023 08:50:46 +0200 Subject: [PATCH 9/9] MSVC compilation warnings --- lib_dec/ivas_masa_dec.c | 2 ++ lib_enc/ivas_omasa_enc.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 75dfcbe9b0..20bd5c18f9 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -119,6 +119,8 @@ ivas_error ivas_masa_decode( int16_t i, ch, ism_imp; #ifdef FIX_OMASA_DELAY_COMP int16_t dirac_bs_md_write_idx; + + dirac_bs_md_write_idx = 0; #endif ism_imp = 0; #endif diff --git a/lib_enc/ivas_omasa_enc.c b/lib_enc/ivas_omasa_enc.c index bcd73cc42a..677558db09 100644 --- a/lib_enc/ivas_omasa_enc.c +++ b/lib_enc/ivas_omasa_enc.c @@ -72,7 +72,9 @@ ivas_error ivas_omasa_enc_open( ) { int16_t i, j; +#ifndef FIX_OMASA_DELAY_COMP float tmp_f; +#endif OMASA_ENC_HANDLE hOMasa; int16_t numAnalysisChannels; int16_t input_frame; -- GitLab