From 990860594ddda904b5a26401745197596ba1ecc8 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 22 May 2023 14:53:10 +0200 Subject: [PATCH 1/4] Fix #393, #459. #460, #494, all related to the DirAC metadata buffers and the read index used to access them. Non-BE, under define FIX_393_459_460_SBA_MD, active --- lib_com/ivas_dirac_com.c | 2 + lib_com/ivas_prot.h | 10 +- lib_com/ivas_stat_com.h | 2 + lib_com/options.h | 1 + lib_dec/ivas_dirac_dec.c | 177 ++++++++++++++++++++-- lib_dec/ivas_dirac_output_synthesis_dec.c | 18 ++- 6 files changed, 194 insertions(+), 16 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index d0b4c5a4db..60269cf841 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -173,8 +173,10 @@ ivas_error ivas_dirac_config( } hConfig->enc_param_start_band = 0; hConfig->dec_param_estim = FALSE; +#ifndef FIX_393_459_460_SBA_MD #ifdef FIX_391_SBA hConfig->dec_param_estim_old = hConfig->dec_param_estim; +#endif #endif if ( ivas_format == SBA_FORMAT ) /* skip for MASA decoder */ { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 672b5a7441..228f5d4252 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3878,8 +3878,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( const float *onset_filter #ifdef HODIRAC , +#ifdef FIX_393_459_460_SBA_MD + float *diffuseness, +#else #ifdef JBM_TSM_ON_TCS const int16_t md_idx, +#endif #endif const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ #endif @@ -3891,7 +3895,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( DIRAC_DEC_HANDLE hDirAC, /* i/o: DirAC handle */ #ifdef JBM_TSM_ON_TCS const int16_t nbslots, /* i : number of slots to process */ - const int16_t diff_md_idx, /* i : md slot idx of diffuseness to use */ +#ifdef FIX_393_459_460_SBA_MD + float *diffuseness_vector, /* i : diffuseness (needed for direction smoothing)*/ +#else + const int16_t diff_md_idx, /* i : md slot idx of diffuseness to use */ +#endif #endif float *reference_power_smooth, float qualityBasedSmFactor diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index e2f2e0f1f2..e4070f9419 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -185,8 +185,10 @@ typedef struct ivas_dirac_config_data_struct { int16_t enc_param_start_band; int16_t dec_param_estim; +#ifndef FIX_393_459_460_SBA_MD #ifdef FIX_391_SBA int16_t dec_param_estim_old; +#endif #endif int16_t nbands; diff --git a/lib_com/options.h b/lib_com/options.h index de0967fc1a..26680b3fd9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -210,6 +210,7 @@ #define JBM_TSM_ON_TCS /* FhG: run the TSM part of JBM on the TCs instead of the final output pcm waveforms */ #define FIX_DTX_428 /* FhG: fix for issue 428, crash with DTX and bitrate switching */ +#define FIX_393_459_460_SBA_MD /* FhG: fix issues 393, 459, 460, 494 all related to MD buffers and the read index for accessing them */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index c5485119ba..8bad981b06 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1123,8 +1123,10 @@ ivas_error ivas_dirac_dec_config( hDirAC->dirac_bs_md_write_idx = 0; hDirAC->dirac_read_idx = 0; hDirAC->spar_to_dirac_write_idx = 0; +#ifndef FIX_393_459_460_SBA_MD #ifdef FIX_391_SBA hDirAC->hConfig->dec_param_estim_old = hDirAC->hConfig->dec_param_estim; +#endif #endif if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { @@ -1162,7 +1164,11 @@ ivas_error ivas_dirac_dec_config( if ( st_ivas->sba_mode == SBA_MODE_DIRAC ) { +#ifdef FIX_393_459_460_SBA_MD + hDirAC->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES; +#else hDirAC->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES * num_slots_in_subfr; +#endif hDirAC->dirac_bs_md_write_idx = 0; hDirAC->spar_to_dirac_write_idx = 0; hDirAC->dirac_read_idx = 0; @@ -1170,9 +1176,15 @@ ivas_error ivas_dirac_dec_config( } else { +#ifdef FIX_393_459_460_SBA_MD + hDirAC->dirac_md_buffer_length = ( MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_DIRAC_PARAM_DEC_SFR ); + hDirAC->dirac_bs_md_write_idx = DELAY_DIRAC_PARAM_DEC_SFR; + hDirAC->spar_to_dirac_write_idx = DELAY_DIRAC_PARAM_DEC_SFR; +#else hDirAC->dirac_md_buffer_length = ( MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_DIRAC_PARAM_DEC_SFR ) * num_slots_in_subfr; hDirAC->dirac_bs_md_write_idx = DELAY_DIRAC_PARAM_DEC_SFR * num_slots_in_subfr; hDirAC->spar_to_dirac_write_idx = DELAY_DIRAC_PARAM_DEC_SFR * num_slots_in_subfr; +#endif hDirAC->dirac_read_idx = 0; hDirAC->dirac_estimator_idx = 0; } @@ -1180,9 +1192,17 @@ ivas_error ivas_dirac_dec_config( { int16_t map_idx; set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); +#ifdef FIX_393_459_460_SBA_MD + for ( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS * num_slots_in_subfr; map_idx++ ) +#else for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) +#endif { +#ifdef FIX_393_459_460_SBA_MD + hDirAC->render_to_md_map[map_idx] = hDirAC->dirac_read_idx + map_idx / num_slots_in_subfr; +#else hDirAC->render_to_md_map[map_idx] = hDirAC->dirac_read_idx + map_idx * num_slots_in_subfr / JBM_CLDFB_SLOTS_IN_SUBFRAME; +#endif } } #endif @@ -1337,6 +1357,7 @@ ivas_error ivas_dirac_dec_config( hDirAC->dithering_seed = DIRAC_DITH_SEED; st_ivas->hDirAC = hDirAC; } +#ifndef FIX_393_459_460_SBA_MD #ifdef FIX_391_SBA else if ( hDirAC->hConfig->dec_param_estim_old != hDirAC->hConfig->dec_param_estim ) { @@ -1497,6 +1518,7 @@ ivas_error ivas_dirac_dec_config( } } #endif +#endif #ifdef JBM_TSM_ON_TCS /* allocate transport channels*/ if ( flag_config == DIRAC_OPEN ) @@ -2462,7 +2484,11 @@ void ivas_qmetadata_to_dirac( int16_t *seed_ptr; int16_t band_start, band_end, diff_idx; float diffuseness; - int16_t ts_start, ts_end, ts, b, ele, azi; +#ifndef FIX_393_459_460_SBA_MD + int16_t ts_start, ts_end, ts; +#else + int16_t b, ele, azi; +#endif float azimuth, elevation; IVAS_QDIRECTION *q_direction; int16_t *band_mapping; @@ -2561,15 +2587,18 @@ void ivas_qmetadata_to_dirac( } else /* SBA mode/SID/Zero frame*/ { +#ifndef FIX_393_459_460_SBA_MD int16_t num_slots_in_subfr; +#endif int16_t tmp_write_idx_param_band; int16_t tmp_write_idx_band; #ifdef HODIRAC float diffuseness_sec = 0.f; #endif +#ifndef FIX_393_459_460_SBA_MD num_slots_in_subfr = hDirAC->hConfig->dec_param_estim ? CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES : 1; - +#endif /* ungroup */ seed_ptr = &hDirAC->dithering_seed; nblocks = q_direction->cfg.nblocks; @@ -2624,8 +2653,10 @@ void ivas_qmetadata_to_dirac( #endif { #ifdef JBM_TSM_ON_TCS +#ifndef FIX_393_459_460_SBA_MD ts_start = hDirAC->block_grouping[block]; ts_end = hDirAC->block_grouping[block + 1]; +#endif #endif for ( b = band_start; b < band_end; b++ ) { @@ -2635,8 +2666,10 @@ void ivas_qmetadata_to_dirac( hDirAC->spreadCoherence[block][b] = 0.0f; hDirAC->surroundingCoherence[block][b] = 0.0f; #ifdef JBM_TSM_ON_TCS +#ifndef FIX_393_459_460_SBA_MD if ( hDirAC->hConfig->dec_param_estim == FALSE ) { +#endif hDirAC->elevation[tmp_write_idx_band][b] = 0; hDirAC->azimuth[tmp_write_idx_band][b] = 0; hDirAC->diffuseness_vector[tmp_write_idx_band][b] = 0.f; @@ -2645,6 +2678,7 @@ void ivas_qmetadata_to_dirac( hDirAC->surroundingCoherence[tmp_write_idx_band][b] = 0.0f; hDirAC->energy_ratio1[tmp_write_idx_band][b] = 0; tmp_write_idx_band = ( tmp_write_idx_band + 1 ) % hDirAC->dirac_md_buffer_length; +#ifndef FIX_393_459_460_SBA_MD } else { @@ -2661,6 +2695,7 @@ void ivas_qmetadata_to_dirac( tmp_write_idx_band = ( tmp_write_idx_band + 1 ) % hDirAC->dirac_md_buffer_length; } } +#endif #endif } } @@ -2704,8 +2739,10 @@ void ivas_qmetadata_to_dirac( { int16_t block_qmetadata; +#ifndef FIX_393_459_460_SBA_MD ts_start = hDirAC->block_grouping[block]; ts_end = hDirAC->block_grouping[block + 1]; +#endif block_qmetadata = min( block, nblocks - 1 ); block_qmetadata = max( block_qmetadata, 0 ); @@ -2779,8 +2816,10 @@ void ivas_qmetadata_to_dirac( hDirAC->energy_ratio1[tmp_write_idx_band][b] = q_direction->band_data[qBand_idx].energy_ratio[0]; +#ifndef FIX_393_459_460_SBA_MD if ( hDirAC->hConfig->dec_param_estim == FALSE ) { +#endif hDirAC->diffuseness_vector[tmp_write_idx_band][b] = diffuseness; @@ -2807,6 +2846,7 @@ void ivas_qmetadata_to_dirac( hDirAC->elevation[tmp_write_idx_band][b] = ele; hDirAC->azimuth[tmp_write_idx_band][b] = azi; } +#ifndef FIX_393_459_460_SBA_MD } else { @@ -2818,9 +2858,13 @@ void ivas_qmetadata_to_dirac( tmp_write_idx_band = ( tmp_write_idx_band + 1 ) % hDirAC->dirac_md_buffer_length; } } +#endif } - +#ifdef FIX_393_459_460_SBA_MD + tmp_write_idx_param_band = ( tmp_write_idx_param_band + 1 ) % hDirAC->dirac_md_buffer_length; +#else tmp_write_idx_param_band = ( tmp_write_idx_param_band + num_slots_in_subfr ) % hDirAC->dirac_md_buffer_length; +#endif } /* for ( block =...) */ } /* for ( band = ...) */ @@ -2836,15 +2880,19 @@ void ivas_qmetadata_to_dirac( for ( block = 0; block < hDirAC->nb_subframes; block++ ) #endif { +#ifndef FIX_393_459_460_SBA_MD ts_start = hDirAC->block_grouping[block]; ts_end = hDirAC->block_grouping[block + 1]; +#endif hDirAC->spreadCoherence[block][b] = 0.0f; hDirAC->surroundingCoherence[block][b] = 0.0f; hDirAC->energy_ratio1[block][b] = 0; +#ifndef FIX_393_459_460_SBA_MD if ( hDirAC->hConfig->dec_param_estim == FALSE ) { +#endif hDirAC->elevation[tmp_write_idx_band][b] = 0; hDirAC->azimuth[tmp_write_idx_band][b] = 0; hDirAC->diffuseness_vector[tmp_write_idx_band][b] = 0.f; @@ -2854,6 +2902,7 @@ void ivas_qmetadata_to_dirac( hDirAC->energy_ratio1[tmp_write_idx_band][b] = 0; #endif tmp_write_idx_band = ( tmp_write_idx_band + 1 ) % hDirAC->dirac_md_buffer_length; +#ifndef FIX_393_459_460_SBA_MD } else { @@ -2870,20 +2919,24 @@ void ivas_qmetadata_to_dirac( tmp_write_idx_band = ( tmp_write_idx_band + 1 ) % hDirAC->dirac_md_buffer_length; } } +#endif } } } - /* update buffer write index */ +/* update buffer write index */ +#ifndef FIX_393_459_460_SBA_MD if ( hDirAC->hConfig->dec_param_estim == FALSE ) { +#endif hDirAC->dirac_bs_md_write_idx = ( hDirAC->dirac_bs_md_write_idx + MAX_PARAM_SPATIAL_SUBFRAMES ) % hDirAC->dirac_md_buffer_length; +#ifndef FIX_393_459_460_SBA_MD } else { hDirAC->dirac_bs_md_write_idx = ( hDirAC->dirac_bs_md_write_idx + CLDFB_NO_COL_MAX ) % hDirAC->dirac_md_buffer_length; } - +#endif return; } @@ -2909,14 +2962,18 @@ void ivas_dirac_dec_set_md_map( /* adapt subframes */ hDirAC->num_slots = nCldfbTs; hDirAC->slots_rendered = 0; +#ifndef FIX_393_459_460_SBA_MD if ( hDirAC->hParamIsm != NULL || hDirAC->hConfig->dec_param_estim == 0 ) { +#endif num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; +#ifndef FIX_393_459_460_SBA_MD } else { num_slots_in_subfr = 1; } +#endif hDirAC->subframes_rendered = 0; ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hDirAC->subframe_nbslots, &hDirAC->nb_subframes ); @@ -3090,9 +3147,9 @@ void ivas_dirac_dec( #else void ivas_dirac_dec_render_sf( #endif - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ #else float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ #endif @@ -3132,9 +3189,15 @@ void ivas_dirac_dec_render_sf( #ifdef JBM_TSM_ON_TCS /* local copies of azi, ele, diffuseness */ +#ifdef FIX_393_459_460_SBA_MD + int16_t azimuth[CLDFB_NO_CHANNELS_MAX]; + int16_t elevation[CLDFB_NO_CHANNELS_MAX]; + float diffuseness_vector[CLDFB_NO_CHANNELS_MAX]; +#else int16_t azimuth[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; int16_t elevation[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; float diffuseness_vector[JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; +#endif #endif DIRAC_DEC_STACK_MEM DirAC_mem; @@ -3249,7 +3312,18 @@ void ivas_dirac_dec_render_sf( #endif /* copy parameters into local buffers*/ - +#ifdef FIX_393_459_460_SBA_MD + if ( hDirAC->hConfig->dec_param_estim == FALSE ) + { + mvs2s( hDirAC->azimuth[hDirAC->render_to_md_map[subframe_idx]], azimuth, hDirAC->num_freq_bands ); + mvs2s( hDirAC->elevation[hDirAC->render_to_md_map[subframe_idx]], elevation, hDirAC->num_freq_bands ); + mvr2r( hDirAC->diffuseness_vector[hDirAC->render_to_md_map[subframe_idx]], diffuseness_vector, hDirAC->num_freq_bands ); + } + else + { + set_zero( diffuseness_vector, hDirAC->num_freq_bands ); + } +#else if ( hDirAC->hConfig->dec_param_estim == TRUE ) { for ( slot_idx = 0; slot_idx < hDirAC->subframe_nbslots[subframe_idx]; slot_idx++ ) @@ -3268,7 +3342,7 @@ void ivas_dirac_dec_render_sf( mvr2r( hDirAC->diffuseness_vector[hDirAC->render_to_md_map[subframe_idx]], diffuseness_vector[slot_idx], hDirAC->num_freq_bands ); } } - +#endif #endif if ( hDirAC->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) @@ -3297,21 +3371,28 @@ void ivas_dirac_dec_render_sf( if ( st_ivas->hHeadTrackData->shd_rot_max_order == 0 ) { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; +#ifdef FIX_393_459_460_SBA_MD + if ( hDirAC->hConfig->dec_param_estim == FALSE ) + { + rotateAziEle_DirAC( azimuth, elevation, num_freq_bands, hDirAC->num_freq_bands, p_Rmat ); + } +#else #ifdef JBM_TSM_ON_TCS - for ( slot_idx = 0; slot_idx < hDirAC->subframe_nbslots[subframe_idx]; slot_idx++ ) + for ( slot_idx = 0; slot_idx < hDirAC->subframe_nbslots[subframe_idx]; slot_idx++ ) #else for ( slot_idx = 0; slot_idx < hDirAC->subframe_nbslots; slot_idx++ ) #endif - { + { #ifdef JBM_TSM_ON_TCS - rotateAziEle_DirAC( azimuth[slot_idx], elevation[slot_idx], num_freq_bands, hDirAC->num_freq_bands, p_Rmat ); + rotateAziEle_DirAC( azimuth[slot_idx], elevation[slot_idx], num_freq_bands, hDirAC->num_freq_bands, p_Rmat ); #else /* note, this seems wrong since it does not take the dirac read ptr into account */ index_slot = subframe_idx * hDirAC->subframe_nbslots + slot_idx; /* Todo: This access to azimuth & elevation may use wrong indices as access should probably be based on hDirAC->dirac_read_idx */ rotateAziEle_DirAC( hDirAC->azimuth[index_slot], hDirAC->elevation[index_slot], num_freq_bands, hDirAC->num_freq_bands, p_Rmat ); #endif - } + } +#endif } } #if defined( JBM_TSM_ON_TCS ) & !defined( FIX_642 ) @@ -3331,7 +3412,11 @@ void ivas_dirac_dec_render_sf( { ivas_dirac_dec_compute_power_factors( hDirAC->num_freq_bands, #ifdef JBM_TSM_ON_TCS +#ifdef FIX_393_459_460_SBA_MD + diffuseness_vector, +#else diffuseness_vector[0], +#endif #else hDirAC->diffuseness_vector[hDirAC->dirac_read_idx], #endif @@ -3396,8 +3481,13 @@ void ivas_dirac_dec_render_sf( st_ivas->hVBAPdata, st_ivas->hMasa, #ifdef JBM_TSM_ON_TCS +#ifdef FIX_393_459_460_SBA_MD + azimuth, + elevation, +#else hDirAC->azimuth[md_idx], hDirAC->elevation[md_idx], +#endif md_idx, #endif surCohRatio, @@ -3415,8 +3505,13 @@ void ivas_dirac_dec_render_sf( st_ivas->hVBAPdata, st_ivas->hMasa, #ifdef JBM_TSM_ON_TCS +#ifdef FIX_393_459_460_SBA_MD + azimuth, + elevation, +#else hDirAC->azimuth[md_idx], hDirAC->elevation[md_idx], +#endif md_idx, #endif surCohRatio, @@ -3623,6 +3718,18 @@ void ivas_dirac_dec_render_sf( if ( hDirAC->hConfig->dec_param_estim == TRUE ) { +#ifdef FIX_393_459_460_SBA_MD + mvs2s( &hDirAC->azimuth[md_idx][hDirAC->hConfig->enc_param_start_band], &azimuth[hDirAC->hConfig->enc_param_start_band], hDirAC->num_freq_bands - hDirAC->hConfig->enc_param_start_band ); + mvs2s( &hDirAC->elevation[md_idx][hDirAC->hConfig->enc_param_start_band], &elevation[hDirAC->hConfig->enc_param_start_band], hDirAC->num_freq_bands - hDirAC->hConfig->enc_param_start_band ); +#ifdef FIX_393_459_460_SBA_MD + if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData->shd_rot_max_order == 0 ) + { + num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; + rotateAziEle_DirAC( azimuth, elevation, num_freq_bands, hDirAC->num_freq_bands, p_Rmat ); + } +#endif +#endif + hDirAC->index_buffer_intensity = ( hDirAC->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ) + 1; /* averaging_length = 32 */ index = hDirAC->index_buffer_intensity; @@ -3640,8 +3747,13 @@ void ivas_dirac_dec_render_sf( hDirAC->buffer_intensity_real[2][index - 1], num_freq_bands, #ifdef JBM_TSM_ON_TCS +#ifdef FIX_393_459_460_SBA_MD + azimuth, + elevation +#else azimuth[slot_idx], elevation[slot_idx] +#endif #else hDirAC->azimuth[hDirAC->dirac_estimator_idx], hDirAC->elevation[hDirAC->dirac_estimator_idx] @@ -3654,12 +3766,17 @@ void ivas_dirac_dec_render_sf( hDirAC->buffer_energy, num_freq_bands, #ifdef JBM_TSM_ON_TCS +#ifdef FIX_393_459_460_SBA_MD + hDirAC->diffuseness_vector[md_idx] +#else diffuseness_vector[slot_idx] +#endif #else hDirAC->diffuseness_vector[hDirAC->dirac_estimator_idx] #endif ); + #ifndef JBM_TSM_ON_TCS hDirAC->dirac_estimator_idx = ( hDirAC->dirac_estimator_idx + 1 ) % hDirAC->dirac_md_buffer_length; #endif @@ -3831,9 +3948,15 @@ void ivas_dirac_dec_render_sf( { ivas_dirac_dec_output_synthesis_process_slot( reference_power, p_onset_filter, +#ifdef FIX_393_459_460_SBA_MD + azimuth, + elevation, + hDirAC->diffuseness_vector[md_idx], +#else azimuth[slot_idx], elevation[slot_idx], diffuseness_vector[slot_idx], +#endif hDirAC, st_ivas->hHeadTrackData->shd_rot_max_order, p_Rmat, @@ -3851,9 +3974,15 @@ void ivas_dirac_dec_render_sf( { ivas_dirac_dec_output_synthesis_process_slot( reference_power, p_onset_filter, +#ifdef FIX_393_459_460_SBA_MD + azimuth, + elevation, + hDirAC->diffuseness_vector[md_idx], +#else azimuth[slot_idx], elevation[slot_idx], diffuseness_vector[slot_idx], +#endif hDirAC, 0, 0, @@ -3868,6 +3997,13 @@ void ivas_dirac_dec_render_sf( } #endif +#ifdef FIX_393_459_460_SBA_MD + if ( hDirAC->hConfig->dec_param_estim ) + { + v_multc_acc( hDirAC->diffuseness_vector[md_idx], 0.25f, diffuseness_vector, hDirAC->num_freq_bands ); + } +#endif + if ( hDirAC->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { v_add( reference_power, reference_power_smooth, reference_power_smooth, hDirAC->num_freq_bands ); @@ -3889,6 +4025,7 @@ void ivas_dirac_dec_render_sf( #ifdef JBM_TSM_ON_TCS ivas_dirac_dec_output_synthesis_get_interpolator( &hDirAC->h_output_synthesis_psd_params, hDirAC->subframe_nbslots[subframe_idx] ); +#ifndef FIX_393_459_460_SBA_MD if ( hDirAC->hConfig->dec_param_estim == FALSE ) { md_idx = hDirAC->render_to_md_map[subframe_idx]; @@ -3897,7 +4034,9 @@ void ivas_dirac_dec_render_sf( { md_idx = hDirAC->render_to_md_map[slot_idx_start]; } +#endif +#ifndef FIX_393_459_460_SBA_MD /* Workaround for BE (should be gone when #393 is adressed and diffuseness index in the gain SHD renderer with HO-DirAC is fixed) */ /* :TODO: remove */ /* get the correct md index for the diffuseness in direction smoothing and HO-DirAC, it is always the first slot of the next subframe*/ @@ -3924,6 +4063,7 @@ void ivas_dirac_dec_render_sf( md_idx = hDirAC->render_to_md_map[subframe_idx + 1]; } } +#endif #endif if ( hDirAC->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD ) @@ -3938,8 +4078,12 @@ void ivas_dirac_dec_render_sf( p_onset_filter #ifdef HODIRAC , +#ifdef FIX_393_459_460_SBA_MD + diffuseness_vector, +#else #ifdef JBM_TSM_ON_TCS md_idx, +#endif #endif hodirac_flag #endif @@ -3956,6 +4100,7 @@ void ivas_dirac_dec_render_sf( qualityBasedSmFactor *= qualityBasedSmFactor; } #ifdef JBM_TSM_ON_TCS +#ifndef FIX_393_459_460_SBA_MD /* Workaround for BE (should be gone when #393 is adressed) */ if ( hDirAC->hConfig->dec_param_estim == 1 ) { @@ -3967,7 +4112,7 @@ void ivas_dirac_dec_render_sf( mvr2r( diffuseness_vector[slot_idx], hDirAC->diffuseness_vector[hDirAC->render_to_md_map[slot_idx + slot_idx_start]], num_freq_bands ); } } - +#endif #endif ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( Cldfb_RealBuffer, @@ -3975,7 +4120,11 @@ void ivas_dirac_dec_render_sf( hDirAC, #ifdef JBM_TSM_ON_TCS hDirAC->subframe_nbslots[subframe_idx], +#ifdef FIX_393_459_460_SBA_MD + diffuseness_vector, +#else md_idx, +#endif #endif reference_power_smooth, qualityBasedSmFactor ); diff --git a/lib_dec/ivas_dirac_output_synthesis_dec.c b/lib_dec/ivas_dirac_output_synthesis_dec.c index f88b5f5f3a..7b11b7dcac 100755 --- a/lib_dec/ivas_dirac_output_synthesis_dec.c +++ b/lib_dec/ivas_dirac_output_synthesis_dec.c @@ -875,8 +875,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( const float *onset_filter #ifdef HODIRAC , +#ifdef FIX_393_459_460_SBA_MD + float *diffuseness, +#else #ifdef JBM_TSM_ON_TCS const int16_t md_idx, +#endif #endif const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ #endif @@ -902,7 +906,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( #ifdef HODIRAC float aux_buf[CLDFB_NO_CHANNELS_MAX]; float ratio[DIRAC_HO_NUMSECTORS * CLDFB_NO_CHANNELS_MAX]; +#ifndef FIX_393_459_460_SBA_MD const float *diffuseness; +#endif #endif /* collect some often used parameters */ @@ -918,11 +924,13 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( nchan_transport_foa = min( 4, nchan_transport ); #ifdef HODIRAC +#ifndef FIX_393_459_460_SBA_MD #ifdef JBM_TSM_ON_TCS diffuseness = hDirAC->diffuseness_vector[md_idx]; #else diffuseness = hDirAC->diffuseness_vector[hDirAC->dirac_read_idx]; #endif +#endif #endif /*-----------------------------------------------------------------* @@ -1356,8 +1364,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ DIRAC_DEC_HANDLE hDirAC, /* i/o: DirAC handle */ #ifdef JBM_TSM_ON_TCS - const int16_t nbslots, /* i : number of slots to process */ + const int16_t nbslots, /* i : number of slots to process */ +#ifdef FIX_393_459_460_SBA_MD + float *diffuseness_vector, +#else const int16_t diff_md_idx, /* i : md slot idx of diffuseness to use */ +#endif #endif float *reference_power_smooth, float qualityBasedSmFactor ) @@ -1487,8 +1499,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( /* TODO: check this, seems buggy in the case of parame estim on the decoder side, because the pointer here points already to the following subframe, ist this intended?*/ #ifdef JBM_TSM_ON_TCS +#ifdef FIX_393_459_460_SBA_MD + instDirectionSmoothness = 1.0f - diffuseness_vector[l]; +#else /* Workaround for BE */ instDirectionSmoothness = 1.0f - hDirAC->diffuseness_vector[diff_md_idx][l]; /* Currently, all subframes have same energy ratio value. */ +#endif #else instDirectionSmoothness = 1.0f - hDirAC->diffuseness_vector[hDirAC->dirac_read_idx][l]; /* Currently, all subframes have same energy ratio value. */ #endif -- GitLab From 8fa7546eb4346e25e3e57ae1eff08ecb25ef1f96 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 23 May 2023 09:11:12 +0200 Subject: [PATCH 2/4] remove double define, fix diffuseness averaging --- lib_dec/ivas_dirac_dec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 79d5d5373b..7db7286f2f 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -3115,13 +3115,11 @@ void ivas_dirac_dec_render_sf( #ifdef FIX_393_459_460_SBA_MD mvs2s( &hDirAC->azimuth[md_idx][hDirAC->hConfig->enc_param_start_band], &azimuth[hDirAC->hConfig->enc_param_start_band], hDirAC->num_freq_bands - hDirAC->hConfig->enc_param_start_band ); mvs2s( &hDirAC->elevation[md_idx][hDirAC->hConfig->enc_param_start_band], &elevation[hDirAC->hConfig->enc_param_start_band], hDirAC->num_freq_bands - hDirAC->hConfig->enc_param_start_band ); -#ifdef FIX_393_459_460_SBA_MD if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData->shd_rot_max_order == 0 ) { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; rotateAziEle_DirAC( azimuth, elevation, num_freq_bands, hDirAC->num_freq_bands, p_Rmat ); } -#endif #endif hDirAC->index_buffer_intensity = ( hDirAC->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ) + 1; /* averaging_length = 32 */ @@ -3374,7 +3372,8 @@ void ivas_dirac_dec_render_sf( #ifdef FIX_393_459_460_SBA_MD if ( hDirAC->hConfig->dec_param_estim ) { - v_multc_acc( hDirAC->diffuseness_vector[md_idx], 0.25f, diffuseness_vector, hDirAC->num_freq_bands ); + float fac = 1.0f / (float) hDirAC->subframe_nbslots[subframe_idx]; + v_multc_acc( hDirAC->diffuseness_vector[md_idx], fac, diffuseness_vector, hDirAC->num_freq_bands ); } #endif -- GitLab From 45269717dee8e963810536bb10f5e0503adfeaf7 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Tue, 23 May 2023 14:38:46 +0200 Subject: [PATCH 3/4] fix compile problem with wrong bracketing of a FIX_393_459_460_SBA_MD occurence when it is inactive --- lib_dec/ivas_dirac_dec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 7db7286f2f..1126311cee 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1937,9 +1937,8 @@ void ivas_qmetadata_to_dirac( float diffuseness; #ifndef FIX_393_459_460_SBA_MD int16_t ts_start, ts_end, ts; -#else - int16_t b, ele, azi; #endif + int16_t b, ele, azi; float azimuth, elevation; IVAS_QDIRECTION *q_direction; int16_t *band_mapping; -- GitLab From b43760e8ea9389a133c1419ed160b2dfc8465b98 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Thu, 1 Jun 2023 09:28:28 +0200 Subject: [PATCH 4/4] fix infinte loop caused by the previous merge from main --- lib_dec/ivas_dirac_dec.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ba3874ddd3..502420781f 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1094,21 +1094,17 @@ ivas_error ivas_dirac_dec_config( #ifdef JBM_TSM_ON_TCS set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) - { - set_s( hDirAC->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); #ifdef FIX_393_459_460_SBA_MD - for ( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS * num_slots_in_subfr; map_idx++ ) + for ( map_idx = 0; map_idx < DEFAULT_JBM_SUBFRAMES_5MS * num_slots_in_subfr; map_idx++ ) #else - for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) + for ( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) #endif - { + { #ifdef FIX_393_459_460_SBA_MD - hDirAC->render_to_md_map[map_idx] = hDirAC->dirac_read_idx + map_idx / num_slots_in_subfr; + hDirAC->render_to_md_map[map_idx] = hDirAC->dirac_read_idx + map_idx / num_slots_in_subfr; #else - hDirAC->render_to_md_map[map_idx] = hDirAC->dirac_read_idx + map_idx * num_slots_in_subfr / JBM_CLDFB_SLOTS_IN_SUBFRAME; + hDirAC->render_to_md_map[map_idx] = hDirAC->dirac_read_idx + map_idx * num_slots_in_subfr / JBM_CLDFB_SLOTS_IN_SUBFRAME; #endif - } } #endif } -- GitLab