From 561caa3ecd054fefbee6ec62cacce38c456d802b Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 7 May 2024 11:41:07 +0200 Subject: [PATCH 1/6] define NONBE_FIX_1052_SBA_EXT_FIX --- lib_com/options.h | 1 + lib_dec/ivas_init_dec.c | 75 +++++++++++++++++++++++++++++++++++- lib_dec/ivas_output_config.c | 8 ++++ lib_dec/ivas_spar_decoder.c | 13 +++++++ 4 files changed, 96 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2795bd4d11..3b7bb8813c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -176,6 +176,7 @@ #define NONBE_FIX_SBA_SIGNALING_BITS_B /* FhG: issue 1061: option B: signal sba order additionally in OSBA */ #define NONBE_FIX_1052_SBA_EXT /* Dlb: SBA external output support */ +#define NONBE_FIX_1052_SBA_EXT_FIX /* VA: SBA external output support fix - do not overwrite "output_config" parameter */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 33f6932ffc..7b1fd1603f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -60,8 +60,12 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_r static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); #ifdef NONBE_FIX_1052_SBA_EXT +#ifdef NONBE_FIX_1052_SBA_EXT_FIX +static AUDIO_CONFIG ivas_set_audio_config_from_sba_order( const int16_t sba_order ); +#else static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ); #endif +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); @@ -245,6 +249,7 @@ static ivas_error ivas_dec_init_split_rend( #endif #ifdef NONBE_FIX_1052_SBA_EXT +#ifndef NONBE_FIX_1052_SBA_EXT_FIX static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ) { AUDIO_CONFIG output_config; @@ -265,6 +270,8 @@ static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_ord } return output_config; } + +#endif #endif /*-------------------------------------------------------------------* @@ -353,12 +360,14 @@ ivas_error ivas_dec_setup( /* read Ambisonic (SBA) order */ 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 ) { st_ivas->hDecoderConfig->output_config = ivas_set_output_config_from_sba_order( st_ivas->sba_order ); st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config ); } +#endif #endif num_bits_read += SBA_ORDER_BITS; @@ -630,6 +639,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 ) { @@ -637,7 +647,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; @@ -1190,7 +1200,15 @@ ivas_error ivas_init_decoder( if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + if ( st_ivas->ivas_format == SBA_FORMAT ) + { + hDecoderConfig->nchan_out = audioCfg2channels( ivas_set_audio_config_from_sba_order( st_ivas->sba_order ) ); + } + else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) +#else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) +#endif { hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); hDecoderConfig->nchan_out += st_ivas->nchan_ism; @@ -1213,7 +1231,24 @@ ivas_error ivas_init_decoder( st_ivas->intern_config = output_config; +#ifdef NONBE_FIX_1052_SBA_EXT_FIX + if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->ivas_format == MC_FORMAT ) + { + ivas_output_init( &( st_ivas->hOutSetup ), st_ivas->transport_config ); + st_ivas->intern_config = st_ivas->transport_config; + } + else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->ivas_format == SBA_FORMAT ) + { + 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 ); + } + else + { + ivas_output_init( &( st_ivas->hOutSetup ), output_config ); + } +#else ivas_output_init( &( st_ivas->hOutSetup ), output_config ); +#endif if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { @@ -1436,7 +1471,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 ) { @@ -3230,3 +3269,37 @@ static ivas_error doSanityChecks_IVAS( return IVAS_ERR_OK; } + + +#ifdef NONBE_FIX_1052_SBA_EXT_FIX +/*-------------------------------------------------------------------* + * ivas_set_audio_config_from_sba_order() + * + * + *-------------------------------------------------------------------*/ + +/*! r: audio configuration */ +static AUDIO_CONFIG ivas_set_audio_config_from_sba_order( + const int16_t sba_order /* i : Ambisonic (SBA) order */ +) +{ + AUDIO_CONFIG audio_config; + + switch ( sba_order ) + { + case SBA_FOA_ORDER: + audio_config = IVAS_AUDIO_CONFIG_FOA; + break; + case SBA_HOA2_ORDER: + audio_config = IVAS_AUDIO_CONFIG_HOA2; + break; + case SBA_HOA3_ORDER: + audio_config = IVAS_AUDIO_CONFIG_HOA3; + break; + default: + audio_config = IVAS_AUDIO_CONFIG_INVALID; + } + + return audio_config; +} +#endif diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 84672f3583..c68cac9681 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -346,7 +346,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 ff1de629d0..92d6925262 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1568,7 +1568,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 ); } @@ -1577,7 +1581,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++ ) { @@ -1666,7 +1675,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 ); } -- GitLab From d5c9b782f1e54ed7235f664fe943b91d2c937aee Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 May 2024 08:46:34 +0200 Subject: [PATCH 2/6] formatting --- lib_com/ivas_prot.h | 12 ++++++------ lib_com/ivas_sba_config.c | 6 ++++-- lib_dec/ivas_dirac_dec.c | 4 +++- lib_dec/ivas_spar_md_dec.c | 1 + lib_enc/ivas_dirac_enc.c | 2 +- lib_enc/ivas_qmetadata_enc.c | 2 +- lib_enc/ivas_spar_encoder.c | 1 - lib_enc/ivas_spar_md_enc.c | 2 ++ 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c2bf977774..9b9377b2df 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3208,7 +3208,7 @@ void ivas_qmetadata_enc_sid_encode( IVAS_QMETADATA *q_metadata, /* i/o: metadata handle */ const int16_t masa_sid_descriptor, /* i : description of MASA SID coding structure*/ #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 const int16_t ivas_format /* i : ivas format */ ); @@ -3519,9 +3519,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 SPAR 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 @@ -3627,7 +3627,7 @@ ivas_error ivas_dirac_enc( const int16_t dtx_vad, /* i : DTX vad flag */ const IVAS_FORMAT ivas_format, /* i : ivas format */ #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 const int16_t hodirac_flag /* i : hodirac flag */ ); @@ -3684,8 +3684,8 @@ void ivas_dirac_dec_read_BS( int16_t *nb_bits, /* o : number of bits read */ 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 */ +#ifdef NONBE_FIX_1052_SBA_EXT + const int16_t nchan_transport, /* i : number of transport channels */ #endif int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ); diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index a622d8f88f..00f33e00be 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -159,13 +159,14 @@ int16_t ivas_sba_get_nchan( } #ifdef NONBE_FIX_1052_SBA_EXT + /*-------------------------------------------------------------------* * ivas_sba_spar_sid_bitlen() * - * Get number of bits in SPAR SID frame + * Get number of bits in SBA SPAR SID frame *-------------------------------------------------------------------*/ -/*! r: number of bits in SPAR SID frame */ +/*! r: number of bits in SBA SPAR SID frame */ int16_t ivas_sba_spar_sid_bitlen( const int16_t nchan_transport /* i : number of transport channels */ ) @@ -180,6 +181,7 @@ int16_t ivas_sba_spar_sid_bitlen( return num_bits; } + #endif /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 89c6e059ac..7ca57cc083 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1003,7 +1003,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 */ ) @@ -1096,6 +1096,7 @@ void ivas_dirac_dec_read_BS( #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 )++; @@ -1120,6 +1121,7 @@ void ivas_dirac_dec_read_BS( #else *nb_bits += ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), 0, NULL, SBA_FORMAT ); #endif + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth[i] = hQMetaData->q_direction[0].band_data[1].azimuth[0]; diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 02f3ead632..5f8aa35c67 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -2452,6 +2452,7 @@ static void ivas_parse_parameter_bitstream_dtx( #else zero_pad_bits = ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - sid_bits_len; #endif + assert( zero_pad_bits >= 0 ); if ( num_dmx_per_band[0] == 2 ) { diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index cd4dbe6438..3b96bff79f 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -292,7 +292,7 @@ ivas_error ivas_dirac_enc( const int16_t dtx_vad, /* i : DTX vad flag */ const IVAS_FORMAT ivas_format, /* i : ivas format */ #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 const int16_t hodirac_flag /* i : hodirac flag */ ) diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index dc4806ed19..56759b07fa 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -956,7 +956,7 @@ void ivas_qmetadata_enc_sid_encode( IVAS_QMETADATA *q_metadata, /* i/o: metadata handle */ const int16_t masa_sid_descriptor, /* i : description of MASA SID coding structure */ #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 const int16_t ivas_format /* i : IVAS format */ ) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index d7d3dadc13..1e3998feb6 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -711,7 +711,6 @@ static ivas_error ivas_spar_enc_process( } #endif - /* Set Energy Ratio to 0.0 if the mono flag has been set */ if ( hQMetaData->dirac_mono_flag ) { diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 83ff86b68b..cc13276b13 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -1719,6 +1719,7 @@ static void ivas_write_parameter_bitstream_dtx( #ifdef NONBE_FIX_1052_SBA_EXT int16_t sba_spar_bitlen; #endif + sid_bits_len = hMetaData->nb_bits_tot; pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; @@ -1780,6 +1781,7 @@ static void ivas_write_parameter_bitstream_dtx( #else zero_pad_bits = ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - sid_bits_len; #endif + assert( zero_pad_bits >= 0 ); if ( num_dmx[0] == 2 ) { -- GitLab From d2df58e3c84a630fe37fa6b971185cb6c0fe4b39 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 May 2024 11:36:02 +0200 Subject: [PATCH 3/6] write SBA order and planar flag at one common place --- lib_com/ivas_prot.h | 6 ++++++ lib_enc/ivas_cpe_enc.c | 12 +++--------- lib_enc/ivas_init_enc.c | 19 ++++++++++++++++++- lib_enc/ivas_ism_enc.c | 4 ++++ lib_enc/ivas_sce_enc.c | 12 +++--------- 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9b9377b2df..7d3dc77206 100755 --- 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 + 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( diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 3fdf6e9f5e..8a1c12a42a 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -599,16 +599,10 @@ ivas_error ivas_cpe_enc( if ( sts[0]->core_brate == SID_2k40 ) { - ivas_write_format_sid( ivas_format, hCPE->element_mode, sts[0]->hBstr ); #ifdef NONBE_FIX_1052_SBA_EXT - if ( ivas_format == SBA_FORMAT ) - { - /* Write SBA planar flag */ - push_indice( sts[0]->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); - - /* Write SBA order */ - push_indice( sts[0]->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_order, SBA_ORDER_BITS ); - } + 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 ); #endif } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 0371378d73..3ea122ba9c 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -135,7 +135,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 + 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 */ @@ -193,6 +199,17 @@ void ivas_write_format_sid( push_indice( hBstr, IND_IVAS_FORMAT, ind, SID_FORMAT_NBITS ); +#ifdef NONBE_FIX_1052_SBA_EXT + 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 3b9e16f78e..bd9612bc6a 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -280,7 +280,11 @@ ivas_error ivas_ism_enc( if ( sid_flag ) { +#ifdef NONBE_FIX_1052_SBA_EXT + 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 b831961811..6b3e803b60 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -223,16 +223,10 @@ ivas_error ivas_sce_enc( if ( st->core_brate == SID_2k40 ) { - ivas_write_format_sid( ivas_format, IVAS_SCE, st->hBstr ); #ifdef NONBE_FIX_1052_SBA_EXT - if ( ivas_format == SBA_FORMAT ) - { - /* Write SBA planar flag */ - push_indice( st->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); - - /* Write SBA order */ - push_indice( st->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_order, SBA_ORDER_BITS ); - } + 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 ); #endif } -- GitLab From 5959e9300c5932dba7122b21b7dbf201eaf51a8d Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Jun 2024 12:06:07 +0200 Subject: [PATCH 4/6] fix compilation switch names --- lib_com/ivas_prot.h | 2 +- lib_enc/ivas_cpe_enc.c | 2 +- lib_enc/ivas_init_enc.c | 2 +- lib_enc/ivas_ism_enc.c | 2 +- lib_enc/ivas_sce_enc.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 7d3dc77206..641750fe5e 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -84,7 +84,7 @@ 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 +#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 */ diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 8a1c12a42a..fc219ee890 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -599,7 +599,7 @@ ivas_error ivas_cpe_enc( if ( sts[0]->core_brate == SID_2k40 ) { -#ifdef NONBE_FIX_1052_SBA_EXT +#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 ); diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 3ea122ba9c..aa9ea4ee4b 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -135,7 +135,7 @@ 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 +#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 */ diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index bd9612bc6a..88713e7409 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -280,7 +280,7 @@ ivas_error ivas_ism_enc( if ( sid_flag ) { -#ifdef NONBE_FIX_1052_SBA_EXT +#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 ); diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 6b3e803b60..60d97195dc 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -223,7 +223,7 @@ ivas_error ivas_sce_enc( if ( st->core_brate == SID_2k40 ) { -#ifdef NONBE_FIX_1052_SBA_EXT +#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 ); -- GitLab From 64cdc5721c9168868cfe18dc12be43e74c169e03 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Jun 2024 12:54:57 +0200 Subject: [PATCH 5/6] simplification --- lib_dec/ivas_init_dec.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index fab8f7eaaf..20dc818370 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -782,6 +782,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; @@ -943,17 +946,15 @@ ivas_error ivas_init_decoder( { hDecoderConfig->nchan_out = CPE_CHANNELS; } -#ifdef NONBE_FIX_1052_SBA_EXT_FIX - else if ( st_ivas->ivas_format == SBA_FORMAT ) - { - hDecoderConfig->nchan_out = audioCfg2channels( ivas_set_audio_config_from_sba_order( st_ivas->sba_order ) ); - } -#endif else if ( st_ivas->ivas_format == MC_FORMAT ) { 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 { hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); hDecoderConfig->nchan_out += st_ivas->nchan_ism; -- GitLab From b00423d6466a862e58dcd1c3b0c36d3db472f2fc Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 25 Jun 2024 16:39:15 +0200 Subject: [PATCH 6/6] revert some formal changes --- lib_dec/ivas_init_dec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 35b9bea5e6..8548689f64 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -54,6 +54,7 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_r static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); + #ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER /*-------------------------------------------------------------------* * ivas_set_audio_config_from_sba_order() @@ -67,6 +68,9 @@ static AUDIO_CONFIG ivas_set_audio_config_from_sba_order( ) #else static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ); + + +static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ) #endif { AUDIO_CONFIG output_config; @@ -435,6 +439,7 @@ ivas_error ivas_dec_setup( #endif st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config ); } + #endif if ( st_ivas->ini_frame > 0 && st_ivas->ivas_format == SBA_FORMAT ) { -- GitLab