diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index dfedb974a1c42ea781884a8854052e0f6c006730..80f49f95fb1718ac92b6d7314b9380754ab803f1 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 ) { +#ifdef NONBE_FIX_SBA_SIGNALING_BITS_B + ( *metadata_max_bits ) -= 7; +#else ( *metadata_max_bits ) -= 3; +#endif } } else if ( sba_total_brate <= IVAS_32k ) diff --git a/lib_com/options.h b/lib_com/options.h index fa19719a5f1761b2b1641fe4cd5e72cc57dd4a83..eabcfa0239963ba95d4ed63a945787e41e7a4ddb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -173,6 +173,8 @@ #define NONBE_FIX_1065_ISM_MD_HANDLE /* VA: issue 1065: Allocate only the necessary number of ISM MD decoder handles. */ #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 */ + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 1b83a06596c008991eebadea66e04fd0816534f9..db95801840d2b3637edd9c373557a5997613035a 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -444,22 +444,36 @@ 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 ) { +#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 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; - /* 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 ) { @@ -777,7 +791,6 @@ static ivas_error ivas_read_format( st_ivas->ivas_format = MASA_ISM_FORMAT; } } - ( *num_bits_read )++; } break; diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 8705d94c64ab5562916c9ce9cdf7c63b27919ac6..d4aad15afaee54f0bc6d84d5821ffe1e2f8a4520 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -497,10 +497,19 @@ void ivas_mct_core_enc( { nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_EXTENDED; nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; + +#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 ( ivas_format == SBA_ISM_FORMAT && nChannels > 4 ) { nAvailBits -= IVAS_COMBINED_FORMAT_SIGNALLING_BITS; } +#endif } for ( cpe_id = 0, i = 0; cpe_id < nCPE; cpe_id++ ) @@ -574,7 +583,13 @@ 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_B + 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 d3ff38062aa496c10ea462c3b966f7b876a9276e..25b8e845833be10fd51cbff3e74edca7b47f799a 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -354,11 +354,21 @@ 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 } 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 ); }