diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index f42e8bde74b034c7adea51658a258a5ca160ff98..511f6ed558cba165c2ff8bf555c45039ad6448b1 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -223,7 +223,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++ ) @@ -386,7 +390,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 ) @@ -502,7 +510,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++ ) @@ -768,7 +780,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 b01e74a7a7a5316057188a57e68ff5be2bde8a2e..997eacb7da7acf64456abcaea69bda5d031b55dd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -173,6 +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 : 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 */ diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 0484e2fb92dcdec73b6630aeb0b933a494207af7..b13bb4f20d0fd7aeb0d07d562bc1c3de74e2d3ed 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; @@ -447,7 +451,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 @@ -789,14 +805,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 *-----------------------------------------------------------------------------------------*/