From 388e78fcc3ead120095111b7061436e41bbe8dea Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 28 May 2025 13:16:04 +0200 Subject: [PATCH 1/4] port float MR 1501 --- lib_com/ivas_dirac_com_fx.c | 5 +++++ lib_com/options.h | 1 + lib_dec/ivas_init_dec_fx.c | 17 ++++++++++++++++- lib_enc/ivas_mct_core_enc_fx.c | 8 ++++++++ lib_enc/ivas_spar_encoder_fx.c | 11 ++++++++++- 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 0c913499b..d45183798 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -399,8 +399,13 @@ void ivas_get_dirac_sba_max_md_bits_fx( /* OSBA needs an additional 2-bits safety margin to avoid acelp crashes */ IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) ) { +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_B + ( *metadata_max_bits ) = sub((*metadata_max_bits), 7); + move16(); +#else ( *metadata_max_bits ) = sub( ( *metadata_max_bits ), 3 ); move16(); +#endif } } ELSE IF( LE_32( sba_total_brate, IVAS_32k ) ) diff --git a/lib_com/options.h b/lib_com/options.h index 73a8f082f..2a3208de8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -135,6 +135,7 @@ #define FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN /* FhG: fix for #1003: fix USAN caused by ParamISM reconfig */ #define FIX_1001_ARI_HM_OVERFLOW /* FhG: (no changes needed in BASOP) fix for undef behaviour in in the harmonic TCX model arithmetic coder */ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ +#define NONBE_FIX_SBA_SIGNALING_BITS_B /* FhG: issue 1061: option B: signal sba order additionally in OSBA */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index fea9c5b97..dfff9de0c 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -466,14 +466,19 @@ ivas_error ivas_dec_setup( move16(); test(); +#ifndef NONBE_FIX_SBA_SIGNALING_BITS_B IF( LT_32( ivas_total_brate, IVAS_24k4 ) || GE_32( ivas_total_brate, IVAS_256k ) ) { +#endif /* read Ambisonic (SBA) planar flag */ st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; move16(); num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); - } +#ifndef NONBE_FIX_SBA_SIGNALING_BITS_B + } +#endif + /* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; move16(); st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); @@ -481,11 +486,21 @@ ivas_error ivas_dec_setup( num_bits_read = add( num_bits_read, SBA_ORDER_BITS ); /* read Ambisonic (SBA) order */ +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_B + /* read the real Ambisonic order when the above bits are used to signal OSBA format */ + if (ivas_total_brate < IVAS_24k4) + { + st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; + st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; + num_bits_read += SBA_ORDER_BITS; + } +#else if ( LT_32( ivas_total_brate, IVAS_256k ) ) { st_ivas->sba_order = 3; move16(); } +#endif test(); IF( st_ivas->ini_frame > 0 && NE_32( ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ) diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index 71890120b..f71580964 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -700,10 +700,18 @@ void ivas_mct_core_enc_fx( nAvailBits = sub( nAvailBits, IVAS_FORMAT_SIGNALING_NBITS_EXTENDED ); nAvailBits = sub( nAvailBits, SBA_ORDER_BITS + SBA_PLANAR_BITS ); test(); +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_B + /*MCT is used at bitrates > 80 kbps and additional 1 bit is present at these bitrates*/ + if (ivas_format == SBA_ISM_FORMAT) + { + nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; + } +#else if ( EQ_32( ivas_format, SBA_ISM_FORMAT ) && GT_16( nChannels, 4 ) ) { nAvailBits = sub( nAvailBits, IVAS_COMBINED_FORMAT_SIGNALLING_BITS ); } +#endif } FOR( ( cpe_id = 0, i = 0 ); cpe_id < nCPE; cpe_id++ ) diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index 3b380f2eb..77e3136a5 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -371,9 +371,18 @@ ivas_error ivas_spar_enc_fx( /* hack to indicate OSBA bitstream at VLBR */ push_indice( st0->hBstr, IND_SMODE, 0, SBA_ORDER_BITS ); - } +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_B + + /* additionally code the real SBA order */ + push_indice(st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS); +#endif + } ELSE { +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_B + /* Write SBA planar flag */ + push_indice(st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS); +#endif /* Write SBA order */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); } -- GitLab From 05c2088b93e25dd70cf5654ef1ab83f7246698e3 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 28 May 2025 13:23:51 +0200 Subject: [PATCH 2/4] fix formatting --- lib_com/ivas_dirac_com_fx.c | 4 ++-- lib_dec/ivas_init_dec_fx.c | 18 +++++++++--------- lib_enc/ivas_mct_core_enc_fx.c | 10 +++++----- lib_enc/ivas_spar_encoder_fx.c | 10 +++++----- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index d45183798..2094d539f 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -400,8 +400,8 @@ void ivas_get_dirac_sba_max_md_bits_fx( IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) ) { #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B - ( *metadata_max_bits ) = sub((*metadata_max_bits), 7); - move16(); + ( *metadata_max_bits ) = sub( ( *metadata_max_bits ), 7 ); + move16(); #else ( *metadata_max_bits ) = sub( ( *metadata_max_bits ), 3 ); move16(); diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index dfff9de0c..248fbdb2e 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -475,10 +475,10 @@ ivas_error ivas_dec_setup( move16(); num_bits_read = add( num_bits_read, SBA_PLANAR_BITS ); #ifndef NONBE_FIX_SBA_SIGNALING_BITS_B - } + } #endif - /* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ + /* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; move16(); st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) ); @@ -487,13 +487,13 @@ ivas_error ivas_dec_setup( /* read Ambisonic (SBA) order */ #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B - /* read the real Ambisonic order when the above bits are used to signal OSBA format */ - if (ivas_total_brate < IVAS_24k4) - { - st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; - st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; - num_bits_read += SBA_ORDER_BITS; - } + /* read the real Ambisonic order when the above bits are used to signal OSBA format */ + if ( ivas_total_brate < IVAS_24k4 ) + { + st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; + st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; + num_bits_read += SBA_ORDER_BITS; + } #else if ( LT_32( ivas_total_brate, IVAS_256k ) ) { diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index f71580964..04ec6eb23 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -701,11 +701,11 @@ void ivas_mct_core_enc_fx( nAvailBits = sub( nAvailBits, SBA_ORDER_BITS + SBA_PLANAR_BITS ); test(); #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B - /*MCT is used at bitrates > 80 kbps and additional 1 bit is present at these bitrates*/ - if (ivas_format == SBA_ISM_FORMAT) - { - nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; - } + /*MCT is used at bitrates > 80 kbps and additional 1 bit is present at these bitrates*/ + if ( ivas_format == SBA_ISM_FORMAT ) + { + nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; + } #else if ( EQ_32( ivas_format, SBA_ISM_FORMAT ) && GT_16( nChannels, 4 ) ) { diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index 77e3136a5..be83c9427 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -373,15 +373,15 @@ ivas_error ivas_spar_enc_fx( push_indice( st0->hBstr, IND_SMODE, 0, SBA_ORDER_BITS ); #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B - /* additionally code the real SBA order */ - push_indice(st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS); + /* additionally code the real SBA order */ + push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); #endif - } + } ELSE { #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B - /* Write SBA planar flag */ - push_indice(st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS); + /* Write SBA planar flag */ + push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); #endif /* Write SBA order */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); -- GitLab From d7f80c4801e3c5707432b31540afe01fb769c8f5 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 1 Aug 2025 13:52:12 +0200 Subject: [PATCH 3/4] do the new comparisons with BASOPs --- lib_dec/ivas_init_dec_fx.c | 2 +- lib_enc/ivas_mct_core_enc_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index c1c66bb5d..71f74efa6 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -499,7 +499,7 @@ ivas_error ivas_dec_setup( /* read Ambisonic (SBA) order */ #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B /* read the real Ambisonic order when the above bits are used to signal OSBA format */ - if ( ivas_total_brate < IVAS_24k4 ) + if ( LT_32(ivas_total_brate, IVAS_24k4) ) { st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index 04ec6eb23..4eacd287b 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -702,7 +702,7 @@ void ivas_mct_core_enc_fx( test(); #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B /*MCT is used at bitrates > 80 kbps and additional 1 bit is present at these bitrates*/ - if ( ivas_format == SBA_ISM_FORMAT ) + if ( EQ_32( ivas_format, SBA_ISM_FORMAT ) ) { nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; } -- GitLab From 69ae4bd800b6f953cce94f6680e317024427eec9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 1 Aug 2025 14:00:39 +0200 Subject: [PATCH 4/4] fix formatting --- lib_dec/ivas_init_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 71f74efa6..daa1c3e54 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -499,7 +499,7 @@ ivas_error ivas_dec_setup( /* read Ambisonic (SBA) order */ #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B /* read the real Ambisonic order when the above bits are used to signal OSBA format */ - if ( LT_32(ivas_total_brate, IVAS_24k4) ) + if ( LT_32( ivas_total_brate, IVAS_24k4 ) ) { st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; -- GitLab