diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 9d2384043c00faae0de4fc20bfb3b190d9ab87f3..ad03fab6669cc8c00c172f75adb7de9214c41b71 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 91e4e9179db327e1ae9f2208df63878eb6df7a96..a324343a5288ef4450215c618250c05f90af609d 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 2128f59873027c81e54f79c108c243d5a32965e7..218c6a4ab35e7ef0a390012fe5e50b9495d1d220 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 fde2f4a6d3b05ad43d96122347a6112862ccc6b8..56990605bb47e6b4d2dc5e2502fc3d30baaad687 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 199d22c537ed5d9d39ef4ae39f0a4b7c856bbdca..7011a09f958e0b0e1a9617c32ed6eaeb1458c9b6 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 bb7ee68dead3a35a55081621b18b3c96a4fc23b5..3c969b612f37336b01fc508e38b883eb639d883c 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 66f3128f7b3478e4b75d77f17dd0efe379b9f116..ae43ad1e5e7de69c95f136a199f57a16910789af 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 29209a04c003f7c7f1c241c1c565703ee5ab48b7..50f2c5a18b35196bc7fc216a31a8f31f2c782b9c 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 8dede71f3f6618a3e80c6f655b2e383c00689f1f..ff67c675b5b9c22f1ccd3c94d155d235da073bf7 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 5267ce0b943e65834781b0085062ec5e11980371..a69541346cd753f920579df1dbde5ced6470a7b1 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 ad7f4bf6be55324255bbf5fdb766aa0cb8c9cca2..1abcc780ad98e96078c4a0de3ab42218e8a8818c 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 }