From 08c58c06e89793c4136eb3637b9250eda8de521b Mon Sep 17 00:00:00 2001 From: Tyagi Date: Tue, 5 Aug 2025 23:06:18 +1000 Subject: [PATCH 1/2] float ref changes for float MR 1517 --- lib_com/ivas_cnst.h | 2 ++ lib_com/ivas_filters.c | 6 +++++ lib_com/ivas_lfe_com.c | 2 ++ lib_com/ivas_prot.h | 4 ++++ lib_com/ivas_rom_com.c | 2 ++ lib_com/ivas_rom_com.h | 2 ++ lib_com/options.h | 1 + lib_dec/ivas_init_dec.c | 49 ++++++++++++++++++++++++++++++++++++++++- lib_dec/ivas_lfe_dec.c | 39 ++++++++++++++++++++++++++++++++ lib_dec/ivas_mct_dec.c | 25 +++++++++++++++++++++ 10 files changed, 131 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 6e21e9caf..1f34a2274 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1421,7 +1421,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 46f878a2d..82d4f5a00 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 4a44ceadf..af6026ae6 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 e7379aca0..f7a0b5a9f 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5498,7 +5498,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 3b0c10581..443e6190a 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -3120,6 +3120,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 @@ -3134,6 +3135,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 = { diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 6cce7f9ec..c73fbf38d 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -352,9 +352,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 47398d087..5b1079e3f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,6 +145,7 @@ #define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */ #define NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT /* FhG: apply correct TCX5 grouping/interleaving when input_fs != output_fs */ +#define NONBE_FIX_MC_LFE_LPF /* Dlb: Adding the LFE LPF filter back for MC content. */ /* #################### End FIXES switches ############################ */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 7c0c19873..0607dda2e 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -836,7 +836,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; @@ -1808,8 +1812,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 ) @@ -1838,6 +1843,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 @@ -1875,6 +1881,47 @@ 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 ) + { + if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + { + /* 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 2f0f79f5e..156fd25c0 100644 --- a/lib_dec/ivas_lfe_dec.c +++ b/lib_dec/ivas_lfe_dec.c @@ -252,6 +252,27 @@ 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 +371,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 +430,14 @@ 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 +446,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 d184fb890..5caa6e431 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1112,21 +1112,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; } -- GitLab From 0b34e96c88af34ca8a1626ffe967b9d884d9b29c Mon Sep 17 00:00:00 2001 From: Tyagi Date: Tue, 5 Aug 2025 23:14:28 +1000 Subject: [PATCH 2/2] clang format fix --- lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_lfe_dec.c | 2 +- lib_dec/ivas_mct_dec.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 0607dda2e..c473f182f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1843,7 +1843,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 +#endif /*-----------------------------------------------------------------* * CLDFB handles for rendering diff --git a/lib_dec/ivas_lfe_dec.c b/lib_dec/ivas_lfe_dec.c index 156fd25c0..9079fff27 100644 --- a/lib_dec/ivas_lfe_dec.c +++ b/lib_dec/ivas_lfe_dec.c @@ -437,7 +437,7 @@ ivas_error ivas_create_lfe_dec( 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 +#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 ); diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 5caa6e431..9900c2a1d 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1145,7 +1145,7 @@ static ivas_error ivas_mc_dec_reconfig( delay_ns += IVAS_FB_DEC_DELAY_NS; } } -#endif +#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 ) -- GitLab