From 75cd89fcee70f82f42b30c9cc21975347236e482 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 8 Aug 2025 10:54:09 +0200 Subject: [PATCH 1/3] port MR --- lib_com/options.h | 1 + lib_enc/swb_tbe_enc.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 31f712963..95117a1f7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -198,6 +198,7 @@ #define FIX_1082_INSTRUM_FAILED_LC3PLUS /* VoiceAge: issue 1082: fix ambiguous syntax in LC3Plus code leading to fails of instrumented builds */ #define NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR /* Nok: issue 1074 fixing number of objects signaling in OMASA low rate */ #define FIX_1222_OMASA_DEC_CHANNEL_BUFFERS /* VA: issue 1222: Reduction of the number of channel buffers in OMASA decoder */ +#define NONBE_FIX_1130_DIV_ZERO_LEV_DUR /* VA: issue 1130: avoid div by zero in L-D by thresholding R[0] to a min value of 100.0 */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index f748e8cdf..ff13c4cd3 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -280,6 +280,15 @@ void wb_tbe_enc( } autocorr( hb_old_speech, R, LPC_SHB_ORDER_WB + 1, ( NS2SA( INT_FS_12k8, 5000000L ) + L_SUBFR + L_FRAME ) * 5 / 16, win_lpc_hb_wb, 0, 1, 1 ); + +#ifdef NONBE_FIX_1130_DIV_ZERO_LEV_DUR + if ( st->element_mode > EVS_MONO ) + { + /* Ensure R[0] isn't zero when entering Levinson-Durbin */ + R[0] = max( R[0], 1.0e-8f ); + } +#endif + lev_dur( lpc_wb_temp, R, LPC_SHB_ORDER_WB, ervec_temp ); a2lsp( lsp_wb_temp, lpc_wb_temp, LPC_SHB_ORDER_WB ); lsp_spacing = 0.5f; -- GitLab From d46c5621899acedc5d46498a6fa6300b7d4314ce Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 8 Aug 2025 12:57:36 +0200 Subject: [PATCH 2/3] Revert "port MR" This reverts commit 75cd89fcee70f82f42b30c9cc21975347236e482. --- lib_com/options.h | 1 - lib_enc/swb_tbe_enc.c | 9 --------- 2 files changed, 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 95117a1f7..31f712963 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -198,7 +198,6 @@ #define FIX_1082_INSTRUM_FAILED_LC3PLUS /* VoiceAge: issue 1082: fix ambiguous syntax in LC3Plus code leading to fails of instrumented builds */ #define NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR /* Nok: issue 1074 fixing number of objects signaling in OMASA low rate */ #define FIX_1222_OMASA_DEC_CHANNEL_BUFFERS /* VA: issue 1222: Reduction of the number of channel buffers in OMASA decoder */ -#define NONBE_FIX_1130_DIV_ZERO_LEV_DUR /* VA: issue 1130: avoid div by zero in L-D by thresholding R[0] to a min value of 100.0 */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index ff13c4cd3..f748e8cdf 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -280,15 +280,6 @@ void wb_tbe_enc( } autocorr( hb_old_speech, R, LPC_SHB_ORDER_WB + 1, ( NS2SA( INT_FS_12k8, 5000000L ) + L_SUBFR + L_FRAME ) * 5 / 16, win_lpc_hb_wb, 0, 1, 1 ); - -#ifdef NONBE_FIX_1130_DIV_ZERO_LEV_DUR - if ( st->element_mode > EVS_MONO ) - { - /* Ensure R[0] isn't zero when entering Levinson-Durbin */ - R[0] = max( R[0], 1.0e-8f ); - } -#endif - lev_dur( lpc_wb_temp, R, LPC_SHB_ORDER_WB, ervec_temp ); a2lsp( lsp_wb_temp, lpc_wb_temp, LPC_SHB_ORDER_WB ); lsp_spacing = 0.5f; -- GitLab From 0611308d17e2e9080e9459a611fd31b5e3cefac3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 11 Aug 2025 11:23:44 +0200 Subject: [PATCH 3/3] port MR --- lib_com/ivas_prot.h | 10 ++++++++-- lib_com/ivas_sba_config.c | 4 ++-- lib_com/options.h | 1 + lib_dec/ivas_dirac_dec.c | 4 ++-- lib_dec/ivas_init_dec.c | 22 +++++++++++++++++++--- lib_dec/ivas_output_config.c | 8 ++++++++ lib_dec/ivas_spar_decoder.c | 13 +++++++++++++ lib_enc/ivas_cpe_enc.c | 4 ++++ lib_enc/ivas_init_enc.c | 19 ++++++++++++++++++- lib_enc/ivas_ism_enc.c | 4 ++++ lib_enc/ivas_sce_enc.c | 4 ++++ 11 files changed, 83 insertions(+), 10 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9d2384043..ad03fab66 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -84,7 +84,13 @@ void ivas_write_format( void ivas_write_format_sid( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t element_mode, /* i : element bitrate */ +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const int16_t sba_order, /* i : Ambisonic (SBA) order */ + const int16_t sba_planar /* i : SBA planar flag */ +#else BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ +#endif ); ivas_error create_sce_enc( @@ -3529,9 +3535,9 @@ int16_t ivas_sba_get_nchan_metadata( ); #ifdef NONBE_FIX_1052_SBA_EXT -/*! r: number of bits in SPAR SID frame */ +/*! r: number of bits in SBA SID frame */ int16_t ivas_sba_spar_sid_bitlen( - const int16_t nchan_transport /* i : number of transport channels */ + const int16_t nchan_transport /* i : number of transport channels */ ); #endif diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 91e4e9179..a324343a5 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -163,10 +163,10 @@ int16_t ivas_sba_get_nchan( /*-------------------------------------------------------------------* * ivas_sba_spar_sid_bitlen() * - * Get number of bits in SPAR SID frame + * Get number of bits in SBA SID frame *-------------------------------------------------------------------*/ -/*! r: number of bits in SPAR SID frame */ +/*! r: number of bits in SBA SID frame */ int16_t ivas_sba_spar_sid_bitlen( const int16_t nchan_transport /* i : number of transport channels */ ) diff --git a/lib_com/options.h b/lib_com/options.h index 2128f5987..218c6a4ab 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -204,6 +204,7 @@ #define FIX_1138_SBA_EXT_ERROR_PRINTOUT /* VA: issue 1138: Fix SBA EXT output call of audioCfg2channels() */ #define NONBE_FIX_981_PARAMBIN_DEFAULT_EARLY_PART /* Nokia: Set default early part energy correction to unity for BINAURAL_ROOM_REVERB */ #define NONBE_FIX_1174_MCMASA_LBR_LOOP_ERROR /* Nokia: Fix issue 1174 by removing the unnecessary inner loop causing problems. */ +#define NONBE_FIX_1052_SBA_EXT_FIX /* VA: SBA external output support fix - do not overwrite "output_config" parameter */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index fde2f4a6d..56990605b 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -978,7 +978,7 @@ void ivas_dirac_dec_read_BS( const int16_t last_bit_pos, /* i : last read bitstream position */ const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ #ifdef NONBE_FIX_1052_SBA_EXT - const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nchan_transport, /* i : number of transport channels */ #endif int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) @@ -1065,12 +1065,12 @@ void ivas_dirac_dec_read_BS( next_bit_pos_orig = st->next_bit_pos; /* subtract mode signaling bits, since bitstream was moved after mode reading */ - #ifdef NONBE_FIX_1052_SBA_EXT st->next_bit_pos = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC - 1 - SID_FORMAT_NBITS - SBA_PLANAR_BITS - SBA_ORDER_BITS ); #else st->next_bit_pos = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC - 1 - SID_FORMAT_NBITS ); #endif + /* 1 bit flag for signaling metadata to read */ b = st->bit_stream[( st->next_bit_pos )--]; ( *nb_bits )++; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 199d22c53..7011a09f9 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -368,6 +368,7 @@ ivas_error ivas_dec_setup( st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; +#ifndef NONBE_FIX_1052_SBA_EXT_FIX #ifdef NONBE_FIX_1052_SBA_EXT if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { @@ -379,7 +380,7 @@ ivas_error ivas_dec_setup( st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config ); } #endif - +#endif num_bits_read += SBA_ORDER_BITS; if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) { @@ -639,7 +640,7 @@ ivas_error ivas_dec_setup( break; } - +#ifndef NONBE_FIX_1052_SBA_EXT_FIX #ifdef NONBE_FIX_1052_SBA_EXT if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { @@ -651,7 +652,7 @@ ivas_error ivas_dec_setup( st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config ); } #endif - +#endif if ( st_ivas->ini_frame > 0 && st_ivas->ivas_format == SBA_FORMAT ) { int16_t nchan_transport_old, nchan_transport; @@ -1035,6 +1036,9 @@ ivas_error ivas_init_decoder_front( st_ivas->nSCE = 0; st_ivas->nCPE = 0; +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + st_ivas->nchan_ism = 0; +#endif st_ivas->nchan_transport = -1; st_ivas->ism_mode = ISM_MODE_NONE; @@ -1205,7 +1209,11 @@ ivas_error ivas_init_decoder( { hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->transport_config ); } +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ivas_format == SBA_FORMAT ) +#else else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) +#endif #else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) #endif @@ -1246,7 +1254,11 @@ ivas_error ivas_init_decoder( st_ivas->intern_config = st_ivas->transport_config; } #ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && ( st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ivas_format == SBA_FORMAT ) ) +#else else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->ivas_format == SBA_ISM_FORMAT ) +#endif { st_ivas->intern_config = ivas_set_audio_config_from_sba_order( st_ivas->sba_order ); ivas_output_init( &( st_ivas->hOutSetup ), st_ivas->intern_config ); @@ -1476,7 +1488,11 @@ ivas_error ivas_init_decoder( return error; } +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && !( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA ) ) +#else if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) +#endif { if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index bb7ee68de..3c969b612 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -322,7 +322,15 @@ void ivas_renderer_select( if ( ivas_format == SBA_FORMAT && ( output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO ) ) { +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + /* 'internal_config' was already set in ivas_set_audio_config_from_sba_order() */ + } + else if ( output_config == IVAS_AUDIO_CONFIG_HOA2 || output_config == IVAS_AUDIO_CONFIG_FOA ) +#else if ( output_config == IVAS_AUDIO_CONFIG_HOA2 || output_config == IVAS_AUDIO_CONFIG_FOA ) +#endif { *internal_config = output_config; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 66f3128f7..ae43ad1e5 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1569,7 +1569,11 @@ void ivas_spar_dec_upmixer_sf( } } +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + if ( hDecoderConfig->ivas_total_brate < IVAS_24k4 && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) +#else if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) +#endif { ivas_spar_calc_smooth_facs( cldfb_in_ts_re[0], cldfb_in_ts_im[0], num_spar_bands, hSpar->subframe_nbslots[hSpar->subframes_rendered], hSpar->subframes_rendered == 0, &hSpar->hFbMixer->pFb->fb_bin_to_band, hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_buf ); } @@ -1578,7 +1582,12 @@ void ivas_spar_dec_upmixer_sf( { md_idx = hSpar->render_to_md_map[ts + slot_idx_start]; ivas_spar_get_parameters( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat ); + +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + if ( hDecoderConfig->ivas_total_brate < IVAS_24k4 && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) +#else if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) +#endif { for ( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) { @@ -1667,7 +1676,11 @@ void ivas_spar_dec_upmixer_sf( } } +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && !( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA ) ) +#else if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) +#endif { ivas_dirac_dec_render_sf( st_ivas, output, nchan_internal, cldfb_in_ts_re, cldfb_in_ts_im ); } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 29209a04c..50f2c5a18 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -632,6 +632,9 @@ ivas_error ivas_cpe_enc( if ( sts[0]->core_brate == SID_2k40 ) { +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + ivas_write_format_sid( ivas_format, hCPE->element_mode, sts[0]->hBstr, hEncoderConfig->sba_order, hEncoderConfig->sba_planar ); +#else ivas_write_format_sid( ivas_format, hCPE->element_mode, sts[0]->hBstr ); #ifdef NONBE_FIX_1052_SBA_EXT if ( ivas_format == SBA_FORMAT ) @@ -642,6 +645,7 @@ ivas_error ivas_cpe_enc( /* Write SBA order */ push_indice( sts[0]->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_order, SBA_ORDER_BITS ); } +#endif #endif } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 8dede71f3..ff67c675b 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -138,7 +138,13 @@ void ivas_write_format( void ivas_write_format_sid( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t element_mode, /* i : element bitrate */ - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const int16_t sba_order, /* i : Ambisonic (SBA) order */ + const int16_t sba_planar /* i : SBA planar flag */ +#else + BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ +#endif ) { int16_t ind = 0; /* to avoid compilation warning */ @@ -196,6 +202,17 @@ void ivas_write_format_sid( push_indice( hBstr, IND_IVAS_FORMAT, ind, SID_FORMAT_NBITS ); +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + if ( ivas_format == SBA_FORMAT ) + { + /* Write SBA planar flag */ + push_indice( hBstr, IND_SMODE, sba_planar, SBA_PLANAR_BITS ); + + /* Write SBA order */ + push_indice( hBstr, IND_SMODE, sba_order, SBA_ORDER_BITS ); + } +#endif + return; } diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 5267ce0b9..a69541346 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -292,7 +292,11 @@ ivas_error ivas_ism_enc( if ( sid_flag ) { +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + ivas_write_format_sid( st_ivas->hEncoderConfig->ivas_format, IVAS_SCE, st->hBstr, -1, -1 ); +#else ivas_write_format_sid( st_ivas->hEncoderConfig->ivas_format, IVAS_SCE, st->hBstr ); +#endif } /*only metadata encoding is needed for this case*/ diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index ad7f4bf6b..1abcc780a 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -230,6 +230,9 @@ ivas_error ivas_sce_enc( if ( st->core_brate == SID_2k40 ) { +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + ivas_write_format_sid( ivas_format, IVAS_SCE, st->hBstr, st_ivas->hEncoderConfig->sba_order, st_ivas->hEncoderConfig->sba_planar ); +#else ivas_write_format_sid( ivas_format, IVAS_SCE, st->hBstr ); #ifdef NONBE_FIX_1052_SBA_EXT if ( ivas_format == SBA_FORMAT ) @@ -240,6 +243,7 @@ ivas_error ivas_sce_enc( /* Write SBA order */ push_indice( st->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_order, SBA_ORDER_BITS ); } +#endif #endif } -- GitLab