From 1ba56e6aea73208f7e892da1bcf7345f757ee24d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 9 Apr 2024 17:00:14 +0200 Subject: [PATCH 01/14] improve format signaling for ISM and OSBA --- lib_com/options.h | 4 +++- lib_dec/ivas_init_dec.c | 17 ++++++++++++++--- lib_enc/ivas_init_enc.c | 16 ++++++++++++++++ lib_enc/ivas_ism_dtx_enc.c | 5 +++++ lib_enc/ivas_mct_core_enc.c | 9 +++++++++ lib_enc/ivas_spar_encoder.c | 4 ++++ 6 files changed, 51 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0799f2bf16..93c69f54c1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ########################### */ #ifndef RELEASE -/*#define DEBUGGING*/ /* Activate debugging part of the code */ +#define DEBUGGING /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ @@ -177,6 +177,8 @@ #define NONBE_FIX_1054_NEGATIVE_LVQ_INDEX /* Nokia: issue 1054: Input to decode_comb in deindex_lvq_SHB should be positive */ #define NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG /* VoiceAge: issue 1063: division by zero for angle_rot feature in the UNCLR classifier */ +#define NONBE_FIX_SBA_SIGNALING_BITS + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 4fb2f78a2e..c059fb78b2 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -467,8 +467,9 @@ ivas_error ivas_dec_setup( { /* the number of objects is written at the end of the bitstream, in the SBA metadata */ st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; - +#ifndef NONBE_FIX_SBA_SIGNALING_BITS if ( ivas_total_brate < IVAS_24k4 || ivas_total_brate >= IVAS_256k ) +#endif { /* read Ambisonic (SBA) planar flag */ st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; @@ -480,10 +481,12 @@ ivas_error ivas_dec_setup( num_bits_read += SBA_ORDER_BITS; /* read Ambisonic (SBA) order */ +#ifndef NONBE_FIX_SBA_SIGNALING_BITS if ( ivas_total_brate < IVAS_256k ) { st_ivas->sba_order = 3; } +#endif if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate ) { @@ -786,8 +789,9 @@ static ivas_error ivas_read_format( break; case 2: st_ivas->ivas_format = ISM_FORMAT; - +#ifndef NONBE_FIX_SBA_SIGNALING_BITS if ( ivas_total_brate >= IVAS_24k4 ) +#endif { if ( st_ivas->bit_stream[*num_bits_read] ) { @@ -801,7 +805,12 @@ static ivas_error ivas_read_format( st_ivas->ivas_format = MASA_ISM_FORMAT; } } - +#ifdef NONBE_FIX_SBA_SIGNALING_BITS + else + { + ( *num_bits_read )++; + } +#endif ( *num_bits_read )++; } break; @@ -819,10 +828,12 @@ static ivas_error ivas_read_format( /* read Ambisonic (SBA) order */ st_ivas->sba_order = st_ivas->bit_stream[( *num_bits_read ) + 2 + SBA_PLANAR_BITS]; st_ivas->sba_order += 2 * st_ivas->bit_stream[( *num_bits_read ) + 1 + SBA_PLANAR_BITS]; +#ifndef NONBE_FIX_SBA_SIGNALING_BITS if ( st_ivas->sba_order == 0 ) { st_ivas->ivas_format = SBA_ISM_FORMAT; } +#endif } ( *num_bits_read )++; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index a394f16090..cb79cb8ffd 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -67,10 +67,18 @@ void ivas_write_format( break; case ISM_FORMAT: ind = 2; +#ifndef NONBE_FIX_SBA_SIGNALING_BITS if ( st_ivas->hEncoderConfig->ivas_total_brate >= IVAS_24k4 ) +#endif { +#ifndef NONBE_FIX_SBA_SIGNALING_BITS ind = 4; nBits += extra_bits; +#else + ind = 8; + nBits += extra_bits; + nBits += IVAS_COMBINED_FORMAT_SIGNALLING_BITS; +#endif } break; case MC_FORMAT: @@ -83,12 +91,18 @@ void ivas_write_format( case MASA_FORMAT: ind = 7; nBits += extra_bits; +#if 0 + nBits += IVAS_COMBINED_FORMAT_SIGNALLING_BITS; +#endif break; case MASA_ISM_FORMAT: if ( st_ivas->ism_mode == ISM_MODE_NONE ) { ind = 7; /* send MASA format */ nBits += extra_bits; +#if 0 + nBits += IVAS_COMBINED_FORMAT_SIGNALLING_BITS; +#endif } else { @@ -97,12 +111,14 @@ void ivas_write_format( } break; case SBA_ISM_FORMAT: +#ifndef NONBE_FIX_SBA_SIGNALING_BITS if ( st_ivas->hEncoderConfig->ivas_total_brate < IVAS_24k4 ) { ind = 6; /* send SBA format */ nBits += extra_bits; } else +#endif { ind = 11; /* 1011 */ nBits += extra_bits + IVAS_COMBINED_FORMAT_SIGNALLING_BITS; diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index f253e335fc..2265c7f9ee 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -253,11 +253,16 @@ int16_t ivas_ism_dtx_enc( /* replicate ivas_write_format() */ int16_t ind = 2; nBits = IVAS_FORMAT_SIGNALING_NBITS; +#ifdef NONBE_FIX_SBA_SIGNALING_BITS + ind = 8; + nBits = IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS; +#else if ( ivas_total_brate >= IVAS_24k4 ) { ind = 4; nBits = IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; } +#endif push_indice( hSCE[0]->hCoreCoder[0]->hBstr, IND_IVAS_FORMAT, ind, nBits ); } diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 8705d94c64..e22bd85770 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -497,7 +497,11 @@ void ivas_mct_core_enc( { nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; +#ifdef NONBE_FIX_SBA_SIGNALING_BITS + if ( ivas_format == SBA_ISM_FORMAT ) +#else if ( ivas_format == SBA_ISM_FORMAT && nChannels > 4 ) +#endif { nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; } @@ -574,7 +578,12 @@ void ivas_mct_core_enc( #ifdef DEBUGGING format_bits = ( ivas_format == MC_FORMAT ? IVAS_FORMAT_SIGNALING_NBITS + MC_LS_SETUP_BITS : IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + SBA_ORDER_BITS + SBA_PLANAR_BITS ); + +#ifdef NONBE_FIX_SBA_SIGNALING_BITS + format_bits += ( ivas_format == SBA_ISM_FORMAT ); +#else format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS ); +#endif mct_bits += hMCT->nBitsMCT + hMCT->nchan_out_woLFE; assert( ( total_brate + ( NBITS_BWIDTH + format_bits + mct_bits + sba_meta + lfe_bits ) * FRAMES_PER_SEC ) == ivas_total_brate ); #endif diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index d3ff38062a..2395015b98 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -339,7 +339,9 @@ ivas_error ivas_spar_enc( st0 = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; /* Write SBA signaling bits */ +#ifndef NONBE_FIX_SBA_SIGNALING_BITS if ( hEncoderConfig->ivas_format == SBA_FORMAT || ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ) +#endif { /* Write SBA planar flag */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); @@ -347,6 +349,7 @@ ivas_error ivas_spar_enc( /* Write SBA order */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); } +#ifndef NONBE_FIX_SBA_SIGNALING_BITS else /* ism_mode == ISM_MODE_NONE */ { if ( hEncoderConfig->ivas_total_brate < IVAS_24k4 ) @@ -363,6 +366,7 @@ ivas_error ivas_spar_enc( push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); } } +#endif if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) { -- GitLab From 5e85b2949e94ca9aa12f275d881fafa23cff031a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 15 Apr 2024 10:42:11 +0200 Subject: [PATCH 02/14] rename NONBE_FIX_SBA_SIGNALING_BITS to NONBE_FIX_SBA_SIGNALING_BITS_A --- lib_com/options.h | 2 +- lib_dec/ivas_init_dec.c | 10 +++++----- lib_enc/ivas_init_enc.c | 6 +++--- lib_enc/ivas_ism_dtx_enc.c | 2 +- lib_enc/ivas_mct_core_enc.c | 4 ++-- lib_enc/ivas_spar_encoder.c | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 93c69f54c1..f604afea7d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -177,7 +177,7 @@ #define NONBE_FIX_1054_NEGATIVE_LVQ_INDEX /* Nokia: issue 1054: Input to decode_comb in deindex_lvq_SHB should be positive */ #define NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG /* VoiceAge: issue 1063: division by zero for angle_rot feature in the UNCLR classifier */ -#define NONBE_FIX_SBA_SIGNALING_BITS +#define NONBE_FIX_SBA_SIGNALING_BITS_A /* FhG: issue 1061: option A: clan up OSBA and ISM signaling using 4 bits all the time */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index c059fb78b2..de1525d28c 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -467,7 +467,7 @@ ivas_error ivas_dec_setup( { /* the number of objects is written at the end of the bitstream, in the SBA metadata */ st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; -#ifndef NONBE_FIX_SBA_SIGNALING_BITS +#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A if ( ivas_total_brate < IVAS_24k4 || ivas_total_brate >= IVAS_256k ) #endif { @@ -481,7 +481,7 @@ ivas_error ivas_dec_setup( num_bits_read += SBA_ORDER_BITS; /* read Ambisonic (SBA) order */ -#ifndef NONBE_FIX_SBA_SIGNALING_BITS +#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A if ( ivas_total_brate < IVAS_256k ) { st_ivas->sba_order = 3; @@ -789,7 +789,7 @@ static ivas_error ivas_read_format( break; case 2: st_ivas->ivas_format = ISM_FORMAT; -#ifndef NONBE_FIX_SBA_SIGNALING_BITS +#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A if ( ivas_total_brate >= IVAS_24k4 ) #endif { @@ -805,7 +805,7 @@ static ivas_error ivas_read_format( st_ivas->ivas_format = MASA_ISM_FORMAT; } } -#ifdef NONBE_FIX_SBA_SIGNALING_BITS +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_A else { ( *num_bits_read )++; @@ -828,7 +828,7 @@ static ivas_error ivas_read_format( /* read Ambisonic (SBA) order */ st_ivas->sba_order = st_ivas->bit_stream[( *num_bits_read ) + 2 + SBA_PLANAR_BITS]; st_ivas->sba_order += 2 * st_ivas->bit_stream[( *num_bits_read ) + 1 + SBA_PLANAR_BITS]; -#ifndef NONBE_FIX_SBA_SIGNALING_BITS +#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A if ( st_ivas->sba_order == 0 ) { st_ivas->ivas_format = SBA_ISM_FORMAT; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index cb79cb8ffd..927979d759 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -67,11 +67,11 @@ void ivas_write_format( break; case ISM_FORMAT: ind = 2; -#ifndef NONBE_FIX_SBA_SIGNALING_BITS +#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A if ( st_ivas->hEncoderConfig->ivas_total_brate >= IVAS_24k4 ) #endif { -#ifndef NONBE_FIX_SBA_SIGNALING_BITS +#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A ind = 4; nBits += extra_bits; #else @@ -111,7 +111,7 @@ void ivas_write_format( } break; case SBA_ISM_FORMAT: -#ifndef NONBE_FIX_SBA_SIGNALING_BITS +#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A if ( st_ivas->hEncoderConfig->ivas_total_brate < IVAS_24k4 ) { ind = 6; /* send SBA format */ diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index 2265c7f9ee..ff521156fe 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -253,7 +253,7 @@ int16_t ivas_ism_dtx_enc( /* replicate ivas_write_format() */ int16_t ind = 2; nBits = IVAS_FORMAT_SIGNALING_NBITS; -#ifdef NONBE_FIX_SBA_SIGNALING_BITS +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_A ind = 8; nBits = IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS; #else diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index e22bd85770..c6366228c1 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -497,7 +497,7 @@ void ivas_mct_core_enc( { nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; -#ifdef NONBE_FIX_SBA_SIGNALING_BITS +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_A if ( ivas_format == SBA_ISM_FORMAT ) #else if ( ivas_format == SBA_ISM_FORMAT && nChannels > 4 ) @@ -579,7 +579,7 @@ void ivas_mct_core_enc( #ifdef DEBUGGING format_bits = ( ivas_format == MC_FORMAT ? IVAS_FORMAT_SIGNALING_NBITS + MC_LS_SETUP_BITS : IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + SBA_ORDER_BITS + SBA_PLANAR_BITS ); -#ifdef NONBE_FIX_SBA_SIGNALING_BITS +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_A format_bits += ( ivas_format == SBA_ISM_FORMAT ); #else format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS ); diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 2395015b98..6e6d9b0632 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -339,7 +339,7 @@ ivas_error ivas_spar_enc( st0 = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; /* Write SBA signaling bits */ -#ifndef NONBE_FIX_SBA_SIGNALING_BITS +#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A if ( hEncoderConfig->ivas_format == SBA_FORMAT || ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ) #endif { @@ -349,7 +349,7 @@ ivas_error ivas_spar_enc( /* Write SBA order */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); } -#ifndef NONBE_FIX_SBA_SIGNALING_BITS +#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A else /* ism_mode == ISM_MODE_NONE */ { if ( hEncoderConfig->ivas_total_brate < IVAS_24k4 ) -- GitLab From 4ebaea4e082e8abb99be121adaedb2b4f9e0fee3 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 15 Apr 2024 11:19:44 +0200 Subject: [PATCH 03/14] signal planar and order bits at all OSBA bitrates under NONBE_FIX_SBA_SIGNALING_BITS_B --- lib_com/options.h | 3 ++- lib_dec/ivas_init_dec.c | 10 +++++++++- lib_enc/ivas_spar_encoder.c | 24 +++++++++++++++++++++--- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f604afea7d..9fd5e5d7ea 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -177,7 +177,8 @@ #define NONBE_FIX_1054_NEGATIVE_LVQ_INDEX /* Nokia: issue 1054: Input to decode_comb in deindex_lvq_SHB should be positive */ #define NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG /* VoiceAge: issue 1063: division by zero for angle_rot feature in the UNCLR classifier */ -#define NONBE_FIX_SBA_SIGNALING_BITS_A /* FhG: issue 1061: option A: clan up OSBA and ISM signaling using 4 bits all the time */ +/*#define NONBE_FIX_SBA_SIGNALING_BITS_A*/ /* FhG: issue 1061: option A: clean up OSBA and ISM signaling using 4 bits all the time */ +#define NONBE_FIX_SBA_SIGNALING_BITS_B /* FhG: issue 1061: option B: signal sba order additionally in OSBA */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index de1525d28c..617ff109a9 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -467,7 +467,7 @@ ivas_error ivas_dec_setup( { /* the number of objects is written at the end of the bitstream, in the SBA metadata */ st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; -#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A +#if !defined( NONBE_FIX_SBA_SIGNALING_BITS_A ) && !defined( NONBE_FIX_SBA_SIGNALING_BITS_B ) if ( ivas_total_brate < IVAS_24k4 || ivas_total_brate >= IVAS_256k ) #endif { @@ -487,6 +487,14 @@ ivas_error ivas_dec_setup( st_ivas->sba_order = 3; } #endif +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_B + 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; + } +#endif if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate ) { diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 6e6d9b0632..68255b5971 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -338,10 +338,17 @@ ivas_error ivas_spar_enc( hEncoderConfig = st_ivas->hEncoderConfig; st0 = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_A + { + /* Write SBA planar flag */ + push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); + + /* Write SBA order */ + push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); + } +#else /* Write SBA signaling bits */ -#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A if ( hEncoderConfig->ivas_format == SBA_FORMAT || ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ) -#endif { /* Write SBA planar flag */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); @@ -349,7 +356,6 @@ ivas_error ivas_spar_enc( /* Write SBA order */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); } -#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A else /* ism_mode == ISM_MODE_NONE */ { if ( hEncoderConfig->ivas_total_brate < IVAS_24k4 ) @@ -359,9 +365,21 @@ ivas_error ivas_spar_enc( /* 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 b1271beeda9134dddc7b5c9418eb7f3955dab3df Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 15 Apr 2024 11:45:49 +0200 Subject: [PATCH 04/14] fix formatting --- lib_dec/ivas_init_dec.c | 8 ++++---- lib_enc/ivas_spar_encoder.c | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 617ff109a9..427496d393 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -490,10 +490,10 @@ ivas_error ivas_dec_setup( #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B 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; - } + 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; + } #endif if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate ) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 68255b5971..639314cba7 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -339,7 +339,7 @@ ivas_error ivas_spar_enc( st0 = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; #ifdef NONBE_FIX_SBA_SIGNALING_BITS_A - { + { /* Write SBA planar flag */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); @@ -370,7 +370,6 @@ ivas_error ivas_spar_enc( /* additionally code the real SBA order */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); #endif - } else { -- GitLab From 07adea2a3e626bd96fcaaa66bffe6f98ec800168 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 15 Apr 2024 13:37:25 +0200 Subject: [PATCH 05/14] fix MCT bit budget in OSBA --- lib_enc/ivas_mct_core_enc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index c6366228c1..3b0384dcbb 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -505,6 +505,14 @@ void ivas_mct_core_enc( { nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; } + +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_B + if ( ivas_format == SBA_ISM_FORMAT && nChannels == 3) + { + nAvailBits -= SBA_PLANAR_BITS; + } +#endif + } for ( cpe_id = 0, i = 0; cpe_id < nCPE; cpe_id++ ) @@ -584,6 +592,11 @@ void ivas_mct_core_enc( #else format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS ); #endif + +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_B + format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels == 3 ) ? SBA_PLANAR_BITS : 0; +#endif + mct_bits += hMCT->nBitsMCT + hMCT->nchan_out_woLFE; assert( ( total_brate + ( NBITS_BWIDTH + format_bits + mct_bits + sba_meta + lfe_bits ) * FRAMES_PER_SEC ) == ivas_total_brate ); #endif -- GitLab From 2cdb4f2c3039d889d9d90f8ef5ff9807c6835f57 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 15 Apr 2024 14:32:42 +0200 Subject: [PATCH 06/14] fix formatting --- lib_enc/ivas_mct_core_enc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 3b0384dcbb..60c031cf1c 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -507,12 +507,11 @@ void ivas_mct_core_enc( } #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B - if ( ivas_format == SBA_ISM_FORMAT && nChannels == 3) + if ( ivas_format == SBA_ISM_FORMAT && nChannels == 3 ) { nAvailBits -= SBA_PLANAR_BITS; } -#endif - +#endif } for ( cpe_id = 0, i = 0; cpe_id < nCPE; cpe_id++ ) -- GitLab From e6cfec58f1fee1c31cd338d6579b7276ba0cae66 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 15 Apr 2024 15:50:37 +0200 Subject: [PATCH 07/14] update safety margin for ACELP core bits in OSBA --- lib_com/ivas_dirac_com.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index dfedb974a1..4d27012b9d 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -342,10 +342,14 @@ void ivas_get_dirac_sba_max_md_bits( { *bits_frame_nominal = ACELP_16k40 / FRAMES_PER_SEC; *metadata_max_bits = 103; - /* OSBA needs an additional 2-bits safety margin to avoid acelp crashes */ + /* OSBA needs an additional 5-bits safety margin to avoid acelp crashes */ if ( ivas_format == SBA_ISM_FORMAT ) { +#if defined( NONBE_FIX_SBA_SIGNALING_BITS_A ) || defined( NONBE_FIX_SBA_SIGNALING_BITS_B ) + ( *metadata_max_bits ) -= 5; +#else ( *metadata_max_bits ) -= 3; +#endif } } else if ( sba_total_brate <= IVAS_32k ) -- GitLab From f2a67a3544b5d45c44b5c501f74f36b6c317954d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 19 Apr 2024 12:57:17 +0200 Subject: [PATCH 08/14] delete define NONBE_FIX_SBA_SIGNALING_BITS_A --- lib_com/ivas_dirac_com.c | 2 +- lib_com/options.h | 1 - lib_dec/ivas_init_dec.c | 19 ++----------------- lib_enc/ivas_init_enc.c | 10 ---------- lib_enc/ivas_ism_dtx_enc.c | 6 ------ lib_enc/ivas_mct_core_enc.c | 8 -------- lib_enc/ivas_spar_encoder.c | 10 ---------- 7 files changed, 3 insertions(+), 53 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 4d27012b9d..06597ef185 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -345,7 +345,7 @@ void ivas_get_dirac_sba_max_md_bits( /* OSBA needs an additional 5-bits safety margin to avoid acelp crashes */ if ( ivas_format == SBA_ISM_FORMAT ) { -#if defined( NONBE_FIX_SBA_SIGNALING_BITS_A ) || defined( NONBE_FIX_SBA_SIGNALING_BITS_B ) +#if defined( NONBE_FIX_SBA_SIGNALING_BITS_B ) ( *metadata_max_bits ) -= 5; #else ( *metadata_max_bits ) -= 3; diff --git a/lib_com/options.h b/lib_com/options.h index 9fd5e5d7ea..a4b11a9fa2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -177,7 +177,6 @@ #define NONBE_FIX_1054_NEGATIVE_LVQ_INDEX /* Nokia: issue 1054: Input to decode_comb in deindex_lvq_SHB should be positive */ #define NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG /* VoiceAge: issue 1063: division by zero for angle_rot feature in the UNCLR classifier */ -/*#define NONBE_FIX_SBA_SIGNALING_BITS_A*/ /* FhG: issue 1061: option A: clean up OSBA and ISM signaling using 4 bits all the time */ #define NONBE_FIX_SBA_SIGNALING_BITS_B /* FhG: issue 1061: option B: signal sba order additionally in OSBA */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 427496d393..0ab3593638 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -467,7 +467,7 @@ ivas_error ivas_dec_setup( { /* the number of objects is written at the end of the bitstream, in the SBA metadata */ st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; -#if !defined( NONBE_FIX_SBA_SIGNALING_BITS_A ) && !defined( NONBE_FIX_SBA_SIGNALING_BITS_B ) +#if !defined( NONBE_FIX_SBA_SIGNALING_BITS_B ) if ( ivas_total_brate < IVAS_24k4 || ivas_total_brate >= IVAS_256k ) #endif { @@ -481,12 +481,7 @@ ivas_error ivas_dec_setup( num_bits_read += SBA_ORDER_BITS; /* read Ambisonic (SBA) order */ -#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A - if ( ivas_total_brate < IVAS_256k ) - { - st_ivas->sba_order = 3; - } -#endif + #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B if ( ivas_total_brate < IVAS_24k4 ) { @@ -797,9 +792,7 @@ static ivas_error ivas_read_format( break; case 2: st_ivas->ivas_format = ISM_FORMAT; -#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A if ( ivas_total_brate >= IVAS_24k4 ) -#endif { if ( st_ivas->bit_stream[*num_bits_read] ) { @@ -813,12 +806,6 @@ static ivas_error ivas_read_format( st_ivas->ivas_format = MASA_ISM_FORMAT; } } -#ifdef NONBE_FIX_SBA_SIGNALING_BITS_A - else - { - ( *num_bits_read )++; - } -#endif ( *num_bits_read )++; } break; @@ -836,12 +823,10 @@ static ivas_error ivas_read_format( /* read Ambisonic (SBA) order */ st_ivas->sba_order = st_ivas->bit_stream[( *num_bits_read ) + 2 + SBA_PLANAR_BITS]; st_ivas->sba_order += 2 * st_ivas->bit_stream[( *num_bits_read ) + 1 + SBA_PLANAR_BITS]; -#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A if ( st_ivas->sba_order == 0 ) { st_ivas->ivas_format = SBA_ISM_FORMAT; } -#endif } ( *num_bits_read )++; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 927979d759..689d3c7b8d 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -67,18 +67,10 @@ void ivas_write_format( break; case ISM_FORMAT: ind = 2; -#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A if ( st_ivas->hEncoderConfig->ivas_total_brate >= IVAS_24k4 ) -#endif { -#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A ind = 4; nBits += extra_bits; -#else - ind = 8; - nBits += extra_bits; - nBits += IVAS_COMBINED_FORMAT_SIGNALLING_BITS; -#endif } break; case MC_FORMAT: @@ -111,14 +103,12 @@ void ivas_write_format( } break; case SBA_ISM_FORMAT: -#ifndef NONBE_FIX_SBA_SIGNALING_BITS_A if ( st_ivas->hEncoderConfig->ivas_total_brate < IVAS_24k4 ) { ind = 6; /* send SBA format */ nBits += extra_bits; } else -#endif { ind = 11; /* 1011 */ nBits += extra_bits + IVAS_COMBINED_FORMAT_SIGNALLING_BITS; diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index ff521156fe..4547b32d7a 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -253,17 +253,11 @@ int16_t ivas_ism_dtx_enc( /* replicate ivas_write_format() */ int16_t ind = 2; nBits = IVAS_FORMAT_SIGNALING_NBITS; -#ifdef NONBE_FIX_SBA_SIGNALING_BITS_A - ind = 8; - nBits = IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + IVAS_COMBINED_FORMAT_SIGNALLING_BITS; -#else if ( ivas_total_brate >= IVAS_24k4 ) { ind = 4; nBits = IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; } -#endif - push_indice( hSCE[0]->hCoreCoder[0]->hBstr, IND_IVAS_FORMAT, ind, nBits ); } } diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 60c031cf1c..6bdbca8b18 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -497,11 +497,7 @@ void ivas_mct_core_enc( { nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; -#ifdef NONBE_FIX_SBA_SIGNALING_BITS_A - if ( ivas_format == SBA_ISM_FORMAT ) -#else if ( ivas_format == SBA_ISM_FORMAT && nChannels > 4 ) -#endif { nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; } @@ -586,11 +582,7 @@ void ivas_mct_core_enc( #ifdef DEBUGGING format_bits = ( ivas_format == MC_FORMAT ? IVAS_FORMAT_SIGNALING_NBITS + MC_LS_SETUP_BITS : IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + SBA_ORDER_BITS + SBA_PLANAR_BITS ); -#ifdef NONBE_FIX_SBA_SIGNALING_BITS_A - format_bits += ( ivas_format == SBA_ISM_FORMAT ); -#else format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS ); -#endif #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels == 3 ) ? SBA_PLANAR_BITS : 0; diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 639314cba7..db23de682c 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -338,15 +338,6 @@ ivas_error ivas_spar_enc( hEncoderConfig = st_ivas->hEncoderConfig; st0 = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; -#ifdef NONBE_FIX_SBA_SIGNALING_BITS_A - { - /* Write SBA planar flag */ - push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); - - /* Write SBA order */ - push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); - } -#else /* Write SBA signaling bits */ if ( hEncoderConfig->ivas_format == SBA_FORMAT || ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) ) { @@ -383,7 +374,6 @@ ivas_error ivas_spar_enc( push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); } } -#endif if ( hEncoderConfig->ivas_format == SBA_ISM_FORMAT ) { -- GitLab From 81c97a81a83277ac1a008f86799ed87cc3533541 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 24 Apr 2024 10:31:47 +0200 Subject: [PATCH 09/14] increase biut budget for acelp coder --- lib_com/ivas_dirac_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 06597ef185..9fb9fd3b86 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -346,7 +346,7 @@ void ivas_get_dirac_sba_max_md_bits( if ( ivas_format == SBA_ISM_FORMAT ) { #if defined( NONBE_FIX_SBA_SIGNALING_BITS_B ) - ( *metadata_max_bits ) -= 5; + ( *metadata_max_bits ) -= 7; #else ( *metadata_max_bits ) -= 3; #endif -- GitLab From 2608f215cca008c4a55b599520ed0e3884644545 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 24 Apr 2024 11:21:26 +0200 Subject: [PATCH 10/14] fix style and formatting issues --- lib_dec/ivas_init_dec.c | 26 +++++++++++++++++--------- lib_enc/ivas_init_enc.c | 6 ------ lib_enc/ivas_ism_dtx_enc.c | 1 + lib_enc/ivas_spar_encoder.c | 2 -- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index dd52ff1b59..7368f34d42 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -324,7 +324,7 @@ ivas_error ivas_dec_setup( /* read the number of objects */ st_ivas->nchan_transport = 1; nchan_ism = 1; - k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ); + k = ( int16_t )( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ); while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS ) { nchan_ism++; @@ -467,28 +467,35 @@ ivas_error ivas_dec_setup( { /* the number of objects is written at the end of the bitstream, in the SBA metadata */ st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; -#if !defined( NONBE_FIX_SBA_SIGNALING_BITS_B ) +#ifndef NONBE_FIX_SBA_SIGNALING_BITS_B if ( ivas_total_brate < IVAS_24k4 || ivas_total_brate >= IVAS_256k ) -#endif { +#endif /* read Ambisonic (SBA) planar flag */ st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; 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 BR)*/ 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 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 ( ivas_total_brate < IVAS_256k ) + { + st_ivas->sba_order = 3; + } #endif if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate ) @@ -652,7 +659,7 @@ ivas_error ivas_dec_setup( /* read the number of objects */ st_ivas->nchan_transport = 1; nchan_ism = 1; - k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS; + k = ( int16_t )( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS; while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS ) { nchan_ism++; @@ -673,7 +680,7 @@ ivas_error ivas_dec_setup( { k -= nchan_ism; /* SID metadata flags */ idx = st_ivas->bit_stream[k]; - st_ivas->ism_mode = (ISM_MODE) ( idx + 1 ); + st_ivas->ism_mode = ( ISM_MODE )( idx + 1 ); } if ( st_ivas->ini_frame == 0 ) @@ -792,6 +799,7 @@ static ivas_error ivas_read_format( break; case 2: st_ivas->ivas_format = ISM_FORMAT; + if ( ivas_total_brate >= IVAS_24k4 ) { if ( st_ivas->bit_stream[*num_bits_read] ) @@ -1424,7 +1432,7 @@ ivas_error ivas_init_decoder( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, ( int16_t )( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); @@ -1579,7 +1587,7 @@ ivas_error ivas_init_decoder( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, ( int16_t )( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 689d3c7b8d..a394f16090 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -83,18 +83,12 @@ void ivas_write_format( case MASA_FORMAT: ind = 7; nBits += extra_bits; -#if 0 - nBits += IVAS_COMBINED_FORMAT_SIGNALLING_BITS; -#endif break; case MASA_ISM_FORMAT: if ( st_ivas->ism_mode == ISM_MODE_NONE ) { ind = 7; /* send MASA format */ nBits += extra_bits; -#if 0 - nBits += IVAS_COMBINED_FORMAT_SIGNALLING_BITS; -#endif } else { diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index 4547b32d7a..f253e335fc 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -258,6 +258,7 @@ int16_t ivas_ism_dtx_enc( ind = 4; nBits = IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; } + push_indice( hSCE[0]->hCoreCoder[0]->hBstr, IND_IVAS_FORMAT, ind, nBits ); } } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index db23de682c..0f8d316e74 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -356,7 +356,6 @@ ivas_error ivas_spar_enc( /* 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 ); @@ -364,7 +363,6 @@ ivas_error ivas_spar_enc( } else { - #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B /* Write SBA planar flag */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); -- GitLab From 06b55cbc92c336a73f616e6eed93ea2954244d42 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 24 Apr 2024 11:55:11 +0200 Subject: [PATCH 11/14] fix formatting --- lib_dec/ivas_init_dec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 7368f34d42..4899017bb5 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -324,7 +324,7 @@ ivas_error ivas_dec_setup( /* read the number of objects */ st_ivas->nchan_transport = 1; nchan_ism = 1; - k = ( int16_t )( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ); + k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ); while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS ) { nchan_ism++; @@ -659,7 +659,7 @@ ivas_error ivas_dec_setup( /* read the number of objects */ st_ivas->nchan_transport = 1; nchan_ism = 1; - k = ( int16_t )( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS; + k = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - 1 ) - SID_FORMAT_NBITS; while ( st_ivas->bit_stream[k] && nchan_ism < MAX_NUM_OBJECTS ) { nchan_ism++; @@ -680,7 +680,7 @@ ivas_error ivas_dec_setup( { k -= nchan_ism; /* SID metadata flags */ idx = st_ivas->bit_stream[k]; - st_ivas->ism_mode = ( ISM_MODE )( idx + 1 ); + st_ivas->ism_mode = (ISM_MODE) ( idx + 1 ); } if ( st_ivas->ini_frame == 0 ) @@ -1432,7 +1432,7 @@ ivas_error ivas_init_decoder( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, ( int16_t )( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); @@ -1587,7 +1587,7 @@ ivas_error ivas_init_decoder( st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands; } - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, ( int16_t )( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); } -- GitLab From 98b072ed3e87e3c5462a8d93900971f096eb0fba Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 24 Apr 2024 12:39:31 +0200 Subject: [PATCH 12/14] improve formatting --- lib_com/ivas_dirac_com.c | 2 +- lib_dec/ivas_init_dec.c | 5 +++-- lib_enc/ivas_spar_encoder.c | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 9fb9fd3b86..80f49f95fb 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -345,7 +345,7 @@ void ivas_get_dirac_sba_max_md_bits( /* OSBA needs an additional 5-bits safety margin to avoid acelp crashes */ if ( ivas_format == SBA_ISM_FORMAT ) { -#if defined( NONBE_FIX_SBA_SIGNALING_BITS_B ) +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_B ( *metadata_max_bits ) -= 7; #else ( *metadata_max_bits ) -= 3; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 4899017bb5..59359e0e87 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -467,6 +467,7 @@ ivas_error ivas_dec_setup( { /* the number of objects is written at the end of the bitstream, in the SBA metadata */ st_ivas->nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1; + #ifndef NONBE_FIX_SBA_SIGNALING_BITS_B if ( ivas_total_brate < IVAS_24k4 || ivas_total_brate >= IVAS_256k ) { @@ -477,12 +478,12 @@ ivas_error ivas_dec_setup( #ifndef NONBE_FIX_SBA_SIGNALING_BITS_B } #endif - /* read Ambisonic (SBA) order (0 for signaling OSBA format at low BR)*/ + + /* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/ 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; - #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 ) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 0f8d316e74..25b8e84583 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -354,9 +354,10 @@ ivas_error ivas_spar_enc( /* Write SBA planar flag */ push_indice( st0->hBstr, IND_SMODE, hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); - /* hack to indicate OSBA bitstream at VLBR */ + /* hack to indicate OSBA format (SBA order = 0) at low bitrates */ 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 -- GitLab From 2c48d2e9dc2fd3d7aca9cacfec281ae46f2daef9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 24 Apr 2024 14:03:33 +0200 Subject: [PATCH 13/14] disable DEBUGGING --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4839e1c9ca..5b6032383e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ########################### */ #ifndef RELEASE -#define DEBUGGING /* Activate debugging part of the code */ +/*#define DEBUGGING*/ /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ -- GitLab From 9299b7c32f59b238f2ec037a229e3bcf9edeb296 Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 26 Apr 2024 10:37:03 +1000 Subject: [PATCH 14/14] fix in MCT enc --- lib_enc/ivas_mct_core_enc.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 6bdbca8b18..d4aad15afa 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -497,15 +497,17 @@ void ivas_mct_core_enc( { nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; - if ( ivas_format == SBA_ISM_FORMAT && nChannels > 4 ) + +#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; } - -#ifdef NONBE_FIX_SBA_SIGNALING_BITS_B - if ( ivas_format == SBA_ISM_FORMAT && nChannels == 3 ) +#else + if ( ivas_format == SBA_ISM_FORMAT && nChannels > 4 ) { - nAvailBits -= SBA_PLANAR_BITS; + nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; } #endif } @@ -582,10 +584,10 @@ void ivas_mct_core_enc( #ifdef DEBUGGING format_bits = ( ivas_format == MC_FORMAT ? IVAS_FORMAT_SIGNALING_NBITS + MC_LS_SETUP_BITS : IVAS_FORMAT_SIGNALING_NBITS_EXTENDED + SBA_ORDER_BITS + SBA_PLANAR_BITS ); - format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS ); - #ifdef NONBE_FIX_SBA_SIGNALING_BITS_B - format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels == 3 ) ? SBA_PLANAR_BITS : 0; + format_bits += ( ivas_format == SBA_ISM_FORMAT ); +#else + format_bits += ( ivas_format == SBA_ISM_FORMAT && nChannels > FOA_CHANNELS ); #endif mct_bits += hMCT->nBitsMCT + hMCT->nchan_out_woLFE; -- GitLab