diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index d8901eec0f56498ebc89dddf8a0fa21e59590841..9d842f9b37eba0ba9ac5e8dd640e0bccd524bbf2 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1424,7 +1424,9 @@ typedef enum typedef enum { IVAS_FILTER_ORDER_1 = 1, +#ifndef NONBE_FIX_MC_LFE_LPF IVAS_FILTER_ORDER_2 = 2, +#endif IVAS_FILTER_ORDER_4 = 4, } ivas_filter_order; diff --git a/lib_com/ivas_filters.c b/lib_com/ivas_filters.c index fcb871ff348fefb8e7be0d8cdb625e1790e03c7f..2c60e8743dfd7ab77e6d9c5c45e9ae0ac6488381 100644 --- a/lib_com/ivas_filters.c +++ b/lib_com/ivas_filters.c @@ -62,7 +62,11 @@ void ivas_filters_init( int16_t i; filter_state->order = order; +#ifdef NONBE_FIX_MC_LFE_LPF + if ( order == IVAS_FILTER_ORDER_1 ) +#else if ( order == IVAS_FILTER_ORDER_2 || order == IVAS_FILTER_ORDER_1 ) +#endif { filter_state->filt_len = order + 1; @@ -116,7 +120,9 @@ void ivas_filter_process( switch ( filter_state->order ) { case IVAS_FILTER_ORDER_1: +#ifndef NONBE_FIX_MC_LFE_LPF case IVAS_FILTER_ORDER_2: +#endif ivas_iir_2_filter( filter_state, pIn_Out, length, IVAS_FILTER_STAGE_0 ); break; case IVAS_FILTER_ORDER_4: diff --git a/lib_com/ivas_lfe_com.c b/lib_com/ivas_lfe_com.c index 83c94551e09a41e2b90bf035f8a8ba52f2475cb3..34e3a9925c2134f988b55752d398c346e6add446 100644 --- a/lib_com/ivas_lfe_com.c +++ b/lib_com/ivas_lfe_com.c @@ -60,6 +60,7 @@ void ivas_lfe_lpf_select_filt_coeff( { switch ( order ) { +#ifndef NONBE_FIX_MC_LFE_LPF case IVAS_FILTER_ORDER_2: switch ( sampling_rate ) { @@ -76,6 +77,7 @@ void ivas_lfe_lpf_select_filt_coeff( break; } break; +#endif case IVAS_FILTER_ORDER_4: switch ( sampling_rate ) { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 202ccf3dd9237dc534cf3a0aceda5901f6e9e738..75255089fae044cd474e18dbc68768db15afdf16 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5501,7 +5501,11 @@ void ivas_lfe_enc( ivas_error ivas_create_lfe_dec( LFE_DEC_HANDLE *hLFE_out, /* o : IVAS LFE decoder structure */ const int32_t output_Fs, /* i : output sampling rate */ +#ifdef NONBE_FIX_MC_LFE_LPF + const int32_t delay_ns /* i : additional LFE delay to sync other channel outputs */ +#else const int32_t binauralization_delay_ns /* i : additional LFE delay to sync with binaural renderer */ +#endif ); void ivas_lfe_dec_close( diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 68169f10d49b4a1cc4bc5e5ca279438ae06d6571..c0c8de6ad5141392f4e4f3966c6899ca9165fc78 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -3079,6 +3079,7 @@ const float ivas_lpf_4_butter_48k_sos[IVAS_BIQUAD_FILT_LEN << 2] = 1.00000000471366f, 1.f , -1.98677297369091f, 0.987060670205863f }; +#ifndef NONBE_FIX_MC_LFE_LPF const float ivas_lpf_2_butter_16k[IVAS_BIQUAD_FILT_LEN << 1] = { 0.000628720643081143f, 0.00125744128616229f, 0.000628720643081143f, 1.f, -1.92783286977036f, 0.930347752342683f @@ -3093,7 +3094,7 @@ const float ivas_lpf_2_butter_48k[IVAS_BIQUAD_FILT_LEN << 1] = { 7.15317998432330e-05f, 0.000143063599686466f, 7.15317998432330e-05f, 1.f, -1.97593552482925f, 0.976221652028620f }; - +#endif const ivas_lfe_freq_models ivas_str_lfe_freq_models = { { 16384, 14924, 13463, 12003, 10542, 9082, 7622, 6161, diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 2cfecaefb345635cb19786a5be26e4a62c9b0bf0..a87d186465c880a6ddcb0e15cedd4ee4f1fba317 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -348,9 +348,11 @@ extern const int16_t Param_ISM_band_grouping[MAX_PARAM_ISM_NBANDS + 1]; extern const float ivas_lpf_4_butter_16k_sos[IVAS_BIQUAD_FILT_LEN << 2]; extern const float ivas_lpf_4_butter_32k_sos[IVAS_BIQUAD_FILT_LEN << 2]; extern const float ivas_lpf_4_butter_48k_sos[IVAS_BIQUAD_FILT_LEN << 2]; +#ifndef NONBE_FIX_MC_LFE_LPF extern const float ivas_lpf_2_butter_16k[IVAS_BIQUAD_FILT_LEN << 1]; extern const float ivas_lpf_2_butter_32k[IVAS_BIQUAD_FILT_LEN << 1]; extern const float ivas_lpf_2_butter_48k[IVAS_BIQUAD_FILT_LEN << 1]; +#endif extern const float ivas_lfe_window_coeff_48k[IVAS_LFE_FADE_LEN_48K]; extern const float ivas_lfe_window_coeff_32k[IVAS_LFE_FADE_LEN_32K]; diff --git a/lib_com/options.h b/lib_com/options.h index 3e149ee2ff5b75fbdfd7f4fce1bc81365ca6476d..54ae56fbe83956e29fa13df906562452c8a31c5b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -175,6 +175,8 @@ #define NONBE_FIX_1028_1DB_TCX_LEVEL_DROP /* VA: Harmonize the logic setting LP weighting factor between TCX encoder and TCX decoder */ #define NONBE_FIX_SBA_SIGNALING_BITS_B /* FhG: issue 1061: option B: signal sba order additionally in OSBA */ +#define NONBE_FIX_MC_LFE_LPF /* Dlb: Adding the LFE LPF filter back for MC content. */ + /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 34e876b22a3b2d780831d0edf6b8ca22da6e876d..1bc65f8e29a87bb7504b6660d0b0c4dd26081782 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1117,7 +1117,11 @@ ivas_error ivas_init_decoder( int16_t numCldfbAnalyses, numCldfbSyntheses; int16_t granularity, n_channels_transport_jbm; int32_t output_Fs, ivas_total_brate; +#ifdef NONBE_FIX_MC_LFE_LPF + int32_t delay_ns; +#else int32_t binauralization_delay_ns; +#endif AUDIO_CONFIG output_config; DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; @@ -2175,8 +2179,9 @@ ivas_error ivas_init_decoder( } } +#ifndef NONBE_FIX_MC_LFE_LPF /*-----------------------------------------------------------------* - * LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay + * LFE handles for rendering after rendering to adjust LFE delay to filter delay *-----------------------------------------------------------------*/ if ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) @@ -2208,7 +2213,7 @@ ivas_error ivas_init_decoder( set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN ); set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k ); } - +#endif /*-----------------------------------------------------------------* * CLDFB handles for rendering *-----------------------------------------------------------------*/ @@ -2245,6 +2250,49 @@ ivas_error ivas_init_decoder( ivas_spar_get_cldfb_gains( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig ); } +#ifdef NONBE_FIX_MC_LFE_LPF + /*-----------------------------------------------------------------* + * LFE handles for rendering after rendering to adjust LFE delay to filter delay + *-----------------------------------------------------------------*/ + + if ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { + delay_ns = st_ivas->binaural_latency_ns; + if ( st_ivas->hBinRenderer != NULL ) + { + if ( st_ivas->hBinRenderer->render_lfe ) + { +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) +#endif + { + /* Account for filterbank delay */ + delay_ns += IVAS_FB_DEC_DELAY_NS; + } + } + else + { + delay_ns = 0; + } + } + else + { + if ( ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && ( st_ivas->cldfbSynDec[0] != NULL ) ) + { + delay_ns += IVAS_FB_DEC_DELAY_NS; + } + } + + if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, output_Fs, delay_ns ) ) != IVAS_ERR_OK ) + { + return error; + } + + set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN ); + set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k ); + } +#endif + /*-----------------------------------------------------------------* * Allocate and initialize limiter struct *-----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_lfe_dec.c b/lib_dec/ivas_lfe_dec.c index 83b196190730ff0f18693f872607393e88b75f47..f672fe75ec292a085238bda5db82b31ebf93dc83 100644 --- a/lib_dec/ivas_lfe_dec.c +++ b/lib_dec/ivas_lfe_dec.c @@ -252,6 +252,28 @@ static int16_t ivas_lfe_dec_dequant( } +#ifdef NONBE_FIX_MC_LFE_LPF +/*------------------------------------------------------------------------- + * ivas_create_lfe_lpf_dec() + * + * Create, allocate and initialize IVAS decoder LFE low pass filter state handle + *-------------------------------------------------------------------------*/ + +static void ivas_create_lfe_lpf_dec( + ivas_filters_process_state_t *hLfeLpf, /* o : LFE LPF handle */ + const int32_t input_Fs /* i : input sampling rate */ +) +{ + const float *filt_coeff; + + ivas_lfe_lpf_select_filt_coeff( input_Fs, IVAS_FILTER_ORDER_4, &filt_coeff ); + ivas_filters_init( hLfeLpf, filt_coeff, IVAS_FILTER_ORDER_4 ); + + return; +} +#endif + + /*-----------------------------------------------------------------------------------------* * Function ivas_lfe_dec() * @@ -350,9 +372,15 @@ void ivas_lfe_dec( *-------------------------------------------------------------------------*/ ivas_error ivas_create_lfe_dec( +#ifdef NONBE_FIX_MC_LFE_LPF + LFE_DEC_HANDLE *hLFE_out, /* o : IVAS LFE decoder structure */ + const int32_t output_Fs, /* i : output sampling rate */ + const int32_t delay_ns /* i : additional LFE delay to sync other channel outputs */ +#else LFE_DEC_HANDLE *hLFE_out, /* o : IVAS LFE decoder structure */ const int32_t output_Fs, /* i : output sampling rate */ const int32_t binauralization_delay_ns /* i : additional LFE delay to sync with binaural renderer */ +#endif ) { float low_pass_delay_dec_out, block_offset_s; @@ -403,6 +431,15 @@ ivas_error ivas_create_lfe_dec( block_offset_s = BLOCK_OFFSET_MS * 0.001f; filt_order = 0; low_pass_delay_dec_out = 0; +#ifdef NONBE_FIX_MC_LFE_LPF + if ( ( delay_ns / 1000000000.f ) > ivas_lfe_lpf_delay[IVAS_FILTER_ORDER_4 - 3] ) + { + filt_order = 4; + low_pass_delay_dec_out = ivas_lfe_lpf_delay[IVAS_FILTER_ORDER_4 - 3] * 1000000000.f; + ivas_create_lfe_lpf_dec( &( hLFE->filter_state ), output_Fs ); + } +#endif + hLFE->filter_state.order = filt_order; hLFE->lfe_block_delay_s = hLFE->lfe_block_delay_s + low_pass_delay_dec_out; hLFE->lfe_prior_buf_len = NS2SA( output_Fs, IVAS_LFE_FADE_NS ); @@ -411,7 +448,11 @@ ivas_error ivas_create_lfe_dec( lfe_addl_delay_s = block_offset_s - hLFE->lfe_block_delay_s; lfe_addl_delay_s = max( 0.0f, lfe_addl_delay_s ); +#ifdef NONBE_FIX_MC_LFE_LPF + add_delay_sa = (int16_t) roundf( (float) delay_ns * output_Fs / 1000000000.f ); +#else add_delay_sa = (int16_t) roundf( (float) binauralization_delay_ns * output_Fs / 1000000000.f ); +#endif hLFE->lfe_addl_delay = (int16_t) ( lfe_addl_delay_s * output_Fs ) + add_delay_sa; hLFE->lfe_block_delay_s += lfe_addl_delay_s + add_delay_sa / output_Fs; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index b49069a6b36a56d27fbd880c8bc158c30e9ca6a3..76eaf7d09b695695ca7f930a5bf1d6751f6ac3b7 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1117,21 +1117,46 @@ static ivas_error ivas_mc_dec_reconfig( if ( ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && st_ivas->hLFE == NULL ) { +#ifdef NONBE_FIX_MC_LFE_LPF + int32_t delay_ns = st_ivas->binaural_latency_ns; +#else int32_t binauralization_delay_ns = st_ivas->binaural_latency_ns; +#endif if ( st_ivas->hBinRenderer != NULL ) { if ( st_ivas->hBinRenderer->render_lfe ) { /* Account for filterbank delay */ +#ifdef NONBE_FIX_MC_LFE_LPF + delay_ns += IVAS_FB_DEC_DELAY_NS; +#else binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS; +#endif } else { +#ifdef NONBE_FIX_MC_LFE_LPF + delay_ns = 0; +#else binauralization_delay_ns = 0; +#endif + } + } +#ifdef NONBE_FIX_MC_LFE_LPF + else + { + if ( ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) && ( st_ivas->cldfbSynDec[0] != NULL ) ) + { + delay_ns += IVAS_FB_DEC_DELAY_NS; } } +#endif +#ifdef NONBE_FIX_MC_LFE_LPF + if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, delay_ns ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK ) +#endif { return error; }