From a00fc3e5233ee776db809e1be3c53db66a6ada9e Mon Sep 17 00:00:00 2001 From: hmund Date: Thu, 20 Apr 2023 10:08:20 +0200 Subject: [PATCH 1/3] add code under SBA_TD_RESIDUAL --- lib_com/ivas_fb_mixer.c | 14 +++++++++ lib_com/options.h | 2 +- lib_enc/ivas_spar_encoder.c | 57 ++++++++++++++++++++++++++++++++++++- 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 3e0d68049a..9f36c63083 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -219,7 +219,11 @@ ivas_error ivas_FB_mixer_open( } else { +#ifdef SBA_TD_RESIDUAL + num_chs_alloc = 1; /* only W channel processed for predicting YZX */ +#else num_chs_alloc = fb_cfg->num_out_chans; +#endif } for ( i = 0; i < num_chs_alloc; i++ ) @@ -382,7 +386,11 @@ void ivas_FB_mixer_close( } else { +#ifdef SBA_TD_RESIDUAL + num_chs_alloc = 1; /* only W channel processed for predicting YZX */ +#else num_chs_alloc = fb_cfg->num_out_chans; +#endif } if ( hFbMixer != NULL ) @@ -498,7 +506,11 @@ void ivas_fb_mixer_pcm_ingest( } else { +#ifdef SBA_TD_RESIDUAL + num_chs_ingest = 1; /* forward Filterbank MDFT only on W */ +#else num_chs_ingest = fb_cfg->num_out_chans; +#endif } for ( i = 0; i < fb_cfg->num_in_chans; i++ ) @@ -764,7 +776,9 @@ void ivas_fb_mixer_get_in_out_mapping( for ( i = 1; i < fb_cfg->num_out_chans; i++ ) { in_out_mixer_map[i][0] = 1; +#ifndef SBA_TD_RESIDUAL in_out_mixer_map[i][order[i]] = 1; +#endif } } } diff --git a/lib_com/options.h b/lib_com/options.h index d4ea004209..97ea1c8986 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,7 +171,7 @@ #define FIX_401_DIRAC_RENDERER_META_READ_INDICES /* Nokia: Issue 401: Fix metadata reading indices in DirAC renderer. */ #define FIX_406_IVAS_POSITION /* Eri: Issue 406: Unify IVAS_POSITION to use IVAS_VECTOR3 instead */ - +#define SBA_TD_RESIDUAL /* DLB : SBA ancoder complexity optimization. Avoid forward MDFTs. */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index c659979d2b..96c113075b 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -405,7 +405,11 @@ static ivas_error ivas_spar_enc_process( IVAS_QMETADATA_HANDLE hQMetaData = st_ivas->hQMetaData; int16_t ts, l_ts, orig_dirac_bands, num_del_samples; float *ppIn_FR_real[IVAS_SPAR_MAX_CH], *ppIn_FR_imag[IVAS_SPAR_MAX_CH]; +#ifdef SBA_TD_RESIDUAL + float wyzx_del_buf[FOA_CHANNELS][IVAS_FB_1MS_48K_SAMP]; +#else float w_del_buf[IVAS_FB_1MS_48K_SAMP]; +#endif float dir[3], avg_dir[3]; float energySum, vecLen; @@ -443,7 +447,19 @@ static ivas_error ivas_spar_enc_process( /* store previous input samples for W in local buffer */ assert( num_del_samples <= IVAS_FB_1MS_48K_SAMP ); +#ifdef SBA_TD_RESIDUAL + if (hSpar->hFbMixer->fb_cfg->active_w_mixing == 0) + { + /* fill delay (1 ms) buffer for all Transport channels */ + for ( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) + { + int idx = hSpar->hFbMixer->fb_cfg->remix_order[i]; + mvr2r( &hSpar->hFbMixer->ppFilterbank_prior_input[idx][hSpar->hFbMixer->fb_cfg->prior_input_length - num_del_samples], wyzx_del_buf[idx], num_del_samples ); + } + } +#else mvr2r( &hSpar->hFbMixer->ppFilterbank_prior_input[0][hSpar->hFbMixer->fb_cfg->prior_input_length - num_del_samples], w_del_buf, num_del_samples ); +#endif /*-----------------------------------------------------------------------------------------* * FB mixer ingest @@ -718,14 +734,53 @@ static ivas_error ivas_spar_enc_process( #ifdef DEBUG_SBA_AUDIO_DUMP ivas_spar_dump_signal_wav( input_frame, p_pcm_tmp, NULL, nchan_transport, spar_foa_enc_wav[1], "ivas_fb_mixer_process()" ); #endif +#ifdef SBA_TD_RESIDUAL + if ( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ) + { + /* delayed W */ + mvr2r( wyzx_del_buf[0], p_pcm_tmp[0], num_del_samples); + mvr2r( data_f[0], p_pcm_tmp[0] + num_del_samples, input_frame - num_del_samples); + for ( i = 1; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) + { + int idx = hSpar->hFbMixer->fb_cfg->remix_order[i]; + + /* delayed, reorderd and accumulated with (negative) prediction from W */ + v_add( wyzx_del_buf[idx], p_pcm_tmp[i], p_pcm_tmp[i], num_del_samples ); + v_add( data_f[idx], p_pcm_tmp[i] + num_del_samples, p_pcm_tmp[i] + num_del_samples, input_frame - num_del_samples); + } + } +#else /* move delayed W into output buffer unless activeW operation*/ if ( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ) { mvr2r( w_del_buf, p_pcm_tmp[0], num_del_samples ); mvr2r( data_f[0], p_pcm_tmp[0] + num_del_samples, input_frame - num_del_samples ); } - +#endif +#if 0 /* SBA_TD_RESIDUAL */ + { + static FILE *fid = 0; + static int samplesWritten = 0; + int s; + if (!fid) + { + fid = fopen("enc_pcm.txt", "wt"); + } + if (samplesWritten < 8 * 48000) + { + for (s = 0; s < input_frame; s++) + { + for (i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++) + { + fprintf(fid, "%.8f ", p_pcm_tmp[i][s]); + } + fprintf(fid, "\n"); + } + samplesWritten += input_frame; + } + } +#endif /*-----------------------------------------------------------------------------------------* * PCA encoder *-----------------------------------------------------------------------------------------*/ -- GitLab From 1b764a8d596eb1d4dfb40aa023e6a0215e1240f1 Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 5 May 2023 16:29:10 +1000 Subject: [PATCH 2/3] clang format fix --- lib_enc/ivas_spar_encoder.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 483d28918c..b13bb4f20d 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -452,14 +452,14 @@ static ivas_error ivas_spar_enc_process( /* store previous input samples for W in local buffer */ assert( num_del_samples <= IVAS_FB_1MS_48K_SAMP ); #ifdef SBA_TD_RESIDUAL - if (hSpar->hFbMixer->fb_cfg->active_w_mixing == 0) + if ( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ) { - /* fill delay (1 ms) buffer for all Transport channels */ - for ( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) - { - int idx = hSpar->hFbMixer->fb_cfg->remix_order[i]; - mvr2r( &hSpar->hFbMixer->ppFilterbank_prior_input[idx][hSpar->hFbMixer->fb_cfg->prior_input_length - num_del_samples], wyzx_del_buf[idx], num_del_samples ); - } + /* fill delay (1 ms) buffer for all Transport channels */ + for ( i = 0; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) + { + int idx = hSpar->hFbMixer->fb_cfg->remix_order[i]; + mvr2r( &hSpar->hFbMixer->ppFilterbank_prior_input[idx][hSpar->hFbMixer->fb_cfg->prior_input_length - num_del_samples], wyzx_del_buf[idx], num_del_samples ); + } } #else mvr2r( &hSpar->hFbMixer->ppFilterbank_prior_input[0][hSpar->hFbMixer->fb_cfg->prior_input_length - num_del_samples], w_del_buf, num_del_samples ); @@ -808,18 +808,18 @@ static ivas_error ivas_spar_enc_process( #ifdef SBA_TD_RESIDUAL if ( hSpar->hFbMixer->fb_cfg->active_w_mixing == 0 ) { - /* delayed W */ - mvr2r( wyzx_del_buf[0], p_pcm_tmp[0], num_del_samples); - mvr2r( data_f[0], p_pcm_tmp[0] + num_del_samples, input_frame - num_del_samples); + /* delayed W */ + mvr2r( wyzx_del_buf[0], p_pcm_tmp[0], num_del_samples ); + mvr2r( data_f[0], p_pcm_tmp[0] + num_del_samples, input_frame - num_del_samples ); - for ( i = 1; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) - { - int idx = hSpar->hFbMixer->fb_cfg->remix_order[i]; + for ( i = 1; i < hSpar->hFbMixer->fb_cfg->num_out_chans; i++ ) + { + int idx = hSpar->hFbMixer->fb_cfg->remix_order[i]; - /* delayed, reorderd and accumulated with (negative) prediction from W */ - v_add( wyzx_del_buf[idx], p_pcm_tmp[i], p_pcm_tmp[i], num_del_samples ); - v_add( data_f[idx], p_pcm_tmp[i] + num_del_samples, p_pcm_tmp[i] + num_del_samples, input_frame - num_del_samples); - } + /* delayed, reorderd and accumulated with (negative) prediction from W */ + v_add( wyzx_del_buf[idx], p_pcm_tmp[i], p_pcm_tmp[i], num_del_samples ); + v_add( data_f[idx], p_pcm_tmp[i] + num_del_samples, p_pcm_tmp[i] + num_del_samples, input_frame - num_del_samples ); + } } #else /* move delayed W into output buffer unless activeW operation*/ -- GitLab From 5bc2007f4228ab96b705d09370ce2870818e7985 Mon Sep 17 00:00:00 2001 From: hmund Date: Wed, 10 May 2023 11:54:08 +0200 Subject: [PATCH 3/3] improve comment for SBA_TD_RESIDUAL --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index cd82b3f38a..c3bb417993 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -173,7 +173,7 @@ #define EUALER2QUAT_FIX /* Dlb :fix for issue 430 issue in euler2quat, sign of quat y is inverted */ #define HR_METADATA /* Nok: encode directional MASA metadata with more bits at 384k and 512k */ -#define SBA_TD_RESIDUAL /*Dlb : SBA encoder FB mixer optimization*/ +#define SBA_TD_RESIDUAL /* Dlb : Issue 426: SBA encoder complexity optimization */ #define FIX_357_DTX_32K /* Eri: issue 357 - Forced LP-CNG at 32k */ #define FIX_435_ISM_MERGE_BUG /* Eri: Merge bug fix for ISM NULL metadata and tcx_only cases */ -- GitLab