diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 721a6befdb453cc3a444dff3168d5d9d5d76a76b..091215ac632ff1560211c90ebb952e3e2b4e28a5 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -199,7 +199,9 @@ ivas_error ivas_dirac_config( } hConfig->enc_param_start_band = 0; hConfig->dec_param_estim = FALSE; +#ifndef FIX_393_459_460_SBA_MD hConfig->dec_param_estim_old = hConfig->dec_param_estim; +#endif if ( ivas_format == SBA_FORMAT ) /* skip for MASA decoder */ { #ifndef SBA_MODE_CLEAN_UP diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 669aff0912f9faedc20c4985c30c5d9905082cef..f455c552a5d039a93848d74ceffbe6811b7ea141 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3881,8 +3881,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( #endif const float *onset_filter , +#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 */ ); @@ -3892,8 +3896,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 diff_md_idx, /* i : md slot idx of diffuseness to use */ + const int16_t nbslots, /* i : number of slots to process */ +#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 d7239087d9ae121b5e521dcc679fac7bf210e2d2..cc0fbf89b308e4917456c4a9331fccb17eaec61d 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -180,7 +180,9 @@ 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 int16_t dec_param_estim_old; +#endif int16_t nbands; } DIRAC_CONFIG_DATA, *DIRAC_CONFIG_DATA_HANDLE; diff --git a/lib_com/options.h b/lib_com/options.h index 209a8575bcad7b8193a9d26b2c522947b6268b24..42d6a6a471ab5435d1a3a9f231170ff625e39eeb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -200,6 +200,7 @@ #define FIX_462_HRTF_FILE_BR_SWITCH_MEM_ERR /* Eri: Fix for issue 462: Use-of-uninitialized memory in external HRTF deallocation in decoder together with BR switching */ #define FIX_487_LOWRATE_SBA_TUNING_FIX /* Dlb: TUning fix for low bitrate cases to match theoretical longest SPAR MD bitstream */ #define FIX_490_MASA_2TC_LBR_DTX /* Nokia: Fixes issue 490 by correcting condition. */ +#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 */ #define FIX_163_SBA_TD_DECORR_OPT /* Dlb : Issue 163 : TD decorr state optimization in SBA for certain output formats */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 01ed888fb4067a4575b5e60776da887f0b80812c..502420781f29ae7d824d85c65ffc51eb2d26752a 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1028,7 +1028,9 @@ 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 hDirAC->hConfig->dec_param_estim_old = hDirAC->hConfig->dec_param_estim; +#endif if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { hDirAC->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES; @@ -1062,7 +1064,11 @@ ivas_error ivas_dirac_dec_config( #ifndef SBA_MODE_CLEAN_UP 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; @@ -1071,9 +1077,15 @@ ivas_error ivas_dirac_dec_config( else { #endif - 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; +#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; #ifndef SBA_MODE_CLEAN_UP @@ -1082,9 +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 ); +#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 } @@ -1114,6 +1134,7 @@ ivas_error ivas_dirac_dec_config( hDirAC->dithering_seed = DIRAC_DITH_SEED; st_ivas->hDirAC = hDirAC; } +#ifndef FIX_393_459_460_SBA_MD else if ( hDirAC->hConfig->dec_param_estim_old != hDirAC->hConfig->dec_param_estim ) { int16_t num_slots_in_subfr; @@ -1140,7 +1161,7 @@ ivas_error ivas_dirac_dec_config( } } } - +#endif #ifdef JBM_TSM_ON_TCS /* allocate transport channels*/ if ( flag_config == DIRAC_OPEN ) @@ -1963,7 +1984,10 @@ 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; +#endif + int16_t b, ele, azi; float azimuth, elevation; IVAS_QDIRECTION *q_direction; int16_t *band_mapping; @@ -2060,13 +2084,16 @@ 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; float diffuseness_sec = 0.f; +#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; @@ -2126,8 +2153,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++ ) { @@ -2138,8 +2167,10 @@ void ivas_qmetadata_to_dirac( 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; @@ -2148,6 +2179,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 { @@ -2164,6 +2196,7 @@ void ivas_qmetadata_to_dirac( tmp_write_idx_band = ( tmp_write_idx_band + 1 ) % hDirAC->dirac_md_buffer_length; } } +#endif #endif } } @@ -2209,8 +2242,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 ); @@ -2273,8 +2308,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; @@ -2299,6 +2336,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 { @@ -2310,9 +2348,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 = ...) */ @@ -2329,15 +2371,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; @@ -2347,6 +2393,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 { @@ -2363,20 +2410,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; } @@ -2404,14 +2455,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 ); @@ -2656,9 +2711,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; @@ -2775,7 +2836,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++ ) @@ -2794,7 +2866,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 ) @@ -2823,22 +2895,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 ) @@ -2857,7 +2935,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 @@ -2921,8 +3003,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, @@ -2936,8 +3023,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, @@ -3124,6 +3216,16 @@ 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 ); + 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 + hDirAC->index_buffer_intensity = ( hDirAC->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ) + 1; /* averaging_length = 32 */ index = hDirAC->index_buffer_intensity; @@ -3141,8 +3243,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] @@ -3155,12 +3262,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 @@ -3317,9 +3429,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, @@ -3335,9 +3453,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, @@ -3349,6 +3473,14 @@ void ivas_dirac_dec_render_sf( } #endif +#ifdef FIX_393_459_460_SBA_MD + if ( hDirAC->hConfig->dec_param_estim ) + { + 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 + if ( hDirAC->synthesisConf != DIRAC_SYNTHESIS_GAIN_SHD ) { v_add( reference_power, reference_power_smooth, reference_power_smooth, hDirAC->num_freq_bands ); @@ -3371,6 +3503,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]; @@ -3379,7 +3512,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*/ @@ -3406,6 +3541,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 ) @@ -3418,8 +3554,12 @@ void ivas_dirac_dec_render_sf( hDirAC->subframe_nbslots[subframe_idx], #endif p_onset_filter, +#ifdef FIX_393_459_460_SBA_MD + diffuseness_vector, +#else #ifdef JBM_TSM_ON_TCS - md_idx, + md_idx, +#endif #endif hodirac_flag ); } @@ -3435,7 +3575,8 @@ void ivas_dirac_dec_render_sf( } #ifdef JBM_TSM_ON_TCS - /* ToDo: Workaround for BE (should be gone when #393 is adressed) */ +#ifndef FIX_393_459_460_SBA_MD + /* Workaround for BE (should be gone when #393 is adressed) */ if ( hDirAC->hConfig->dec_param_estim == 1 ) { num_freq_bands = hDirAC->band_grouping[hDirAC->hConfig->enc_param_start_band]; @@ -3446,7 +3587,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, @@ -3454,7 +3595,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 old mode 100644 new mode 100755 index 1ad87d6618dc729bc86c982f5034136c3d142aa9..33004c540c55f0bf162793198d51e79b192b40a4 --- a/lib_dec/ivas_dirac_output_synthesis_dec.c +++ b/lib_dec/ivas_dirac_output_synthesis_dec.c @@ -835,8 +835,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( const int16_t nbslots, /* i : number of slots to process */ #endif const float *onset_filter, +#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 */ ) @@ -860,7 +864,9 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( int16_t ch_idx_diff; 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 /* collect some often used parameters */ h_dirac_output_synthesis_params = hDirAC->h_output_synthesis_psd_params; @@ -874,10 +880,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd( num_channels_diff = hDirAC->num_outputs_diff; nchan_transport_foa = min( 4, nchan_transport ); +#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 /*-----------------------------------------------------------------* @@ -1293,8 +1301,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 ) @@ -1424,8 +1436,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