diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 4e81fc916600ac0eb6218b65f1be09233c89f037..a186c3f41fc9fbad31104ea5b3a55b63e56f5b3b 100755 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -1978,21 +1978,13 @@ ivas_error preview_indices( /* Read SBA planar flag and SBA order */ st_ivas->sba_planar = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA] == 1 ); -#ifndef SBA_ORDER_BITSTREAM st_ivas->sba_order = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA + 2] == 1 ); st_ivas->sba_order += 2 * ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA + 1] == 1 ); -#else - st_ivas->hDecoderConfig->sba_order = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA + 2] == 1 ); - st_ivas->hDecoderConfig->sba_order += 2 * ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA + 1] == 1 ); - st_ivas->sba_analysis_order = st_ivas->hDecoderConfig->sba_order; -#endif + #ifdef SBA_ORDER_BITSTREAM - /*Hard coding the the sba_oder as 1 as higher not supported below 256k bitrate*/ - if ( total_brate < IVAS_256k ) - { - st_ivas->sba_analysis_order = 1; - } + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( total_brate, st_ivas->sba_order ); #endif + #ifdef SBA_ORDER_BITSTREAM ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ), st_ivas->sba_mode ); #else diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 0a9aad902075e6ce409324a28aabf38896926067..6cfb9fb3053fb67be98c7b08e5814522ed70b84b 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -831,6 +831,7 @@ typedef enum { #define SBA_PLANAR_BITS 1 #define SBA_ORDER_BITS 2 +#define SBA_MIN_BRATE_HOA IVAS_256k #define SBA_NHARM_HOA3 16 #define SBA_T_DESIGN_11_SIZE 70 diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c44bd4b97551496d90c9cac0a0d00174014cab81..9c3cd6710c709fd9d87257482b9fd72fb0973af3 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3033,15 +3033,25 @@ void ivas_init_dec_get_num_cldfb_instances( int16_t *numCldfbSyntheses /* o : number of CLDFB synthesis instances */ ); +/*! r: Ambisonic (SBA) order */ int16_t ivas_sba_get_order( const int16_t nb_channels, /* i : Number of ambisonic channels */ const int16_t sba_planar /* i : SBA planar flag */ ); +#ifdef SBA_ORDER_BITSTREAM +/*! r: Ambisonic (SBA) order used for analysis and coding */ +int16_t ivas_sba_get_analysis_order( + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ +); +#endif + int16_t ivas_sba_get_order_transport( const int16_t nchan_transport /* i : Number of transport channels */ ); +/*!r: number of Ambisonic channels */ int16_t ivas_sba_get_nchan( const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int16_t sba_planar /* i : SBA planar flag */ @@ -3858,7 +3868,7 @@ ivas_error ivas_spar_md_enc_open( const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */ #ifdef SBA_ORDER_BITSTREAM , - int16_t sba_order + const int16_t sba_order /* i : Ambisonic (SBA) order */ #endif ); @@ -3874,7 +3884,7 @@ ivas_error ivas_spar_md_enc_process( const int16_t dtx_silence_mode #ifdef SBA_ORDER_BITSTREAM , - int16_t sba_order + const int16_t sba_order /* i : Ambisonic (SBA) order */ #endif ); diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 28a66df68f65ee9848c21fa973add36335894a30..313c025eb6ecb8c0905a408ac693e60e86aed1fb 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -158,6 +158,7 @@ void ivas_sba_config( * Get Ambisonic order from number of ambisonic channels *-------------------------------------------------------------------*/ +/*! r: Ambisonic (SBA) order */ int16_t ivas_sba_get_order( const int16_t nb_channels, /* i : Number of ambisonic channels */ const int16_t sba_planar /* i : SBA Planar flag */ @@ -182,6 +183,34 @@ int16_t ivas_sba_get_order( } +#ifdef SBA_ORDER_BITSTREAM +/*-------------------------------------------------------------------* + * ivas_sba_get_analysis_order() + * + * Get Ambisonic order used for analysis and coding + *-------------------------------------------------------------------*/ + +/*! r: Ambisonic (SBA) order used for analysis and coding */ +int16_t ivas_sba_get_analysis_order( + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ +) +{ + int16_t sba_analysis_order; + + sba_analysis_order = sba_order; + + if ( ivas_total_brate < SBA_MIN_BRATE_HOA ) + { + /* Hard coding the sba_analysis_order as 1 as higher not supported below SBA_MIN_BRATE_HOA bitrate */ + sba_analysis_order = 1; + } + + return sba_analysis_order; +} +#endif + + /*-------------------------------------------------------------------* * ivas_sba_get_order_transport() * @@ -215,6 +244,7 @@ int16_t ivas_sba_get_order_transport( * Get number of Ambisonic channels *-------------------------------------------------------------------*/ +/*!r: number of Ambisonic channels */ int16_t ivas_sba_get_nchan( const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int16_t sba_planar /* i : SBA planar flag */ diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 074f635133026cd2659072afb2b9bf781b0f1e01..8cf0d025c0e8def9e49792af80231f5989aa8a87 100755 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -192,6 +192,7 @@ ivas_error ivas_dirac_dec_config( st_ivas->nchan_transport = ivas_sba_get_nchan_metadata( st_ivas->sba_order ); #endif } + nchan_transport = st_ivas->nchan_transport; if ( st_ivas->ivas_format == MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE && ivas_total_brate > IVAS_SID_4k4 ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index b12aa28e404b97de0df6aa4b792b9925bf15adc7..a7692c279169d1fbb071fdc04ea9c27cfa0d458f 100755 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -119,18 +119,14 @@ ivas_error ivas_dec_setup( num_bits_read += SBA_PLANAR_BITS; /* read Ambisonic (SBA) order */ -#ifndef SBA_ORDER_BITSTREAM st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; -#else - st_ivas->hDecoderConfig->sba_order = st_ivas->bit_stream[num_bits_read + 1]; - st_ivas->hDecoderConfig->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; - st_ivas->sba_analysis_order = st_ivas->hDecoderConfig->sba_order; - if ( ivas_total_brate < IVAS_256k ) - { - st_ivas->sba_analysis_order = 1; - } + +#ifdef SBA_ORDER_BITSTREAM + /* set Ambisonic (SBA) order used for analysis and coding */ + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); #endif + num_bits_read += SBA_ORDER_BITS; if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate && ivas_total_brate > IVAS_SID_4k4 ) { @@ -421,6 +417,7 @@ static ivas_error ivas_read_format( int16_t tc_mode_offset; tc_mode_offset = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC - 1 ); idx = st_ivas->bit_stream[tc_mode_offset]; + // TBD: needs more work for HOA #ifndef SBA_ORDER_BITSTREAM if ( st_ivas->sba_order == 0 ) @@ -433,6 +430,7 @@ static ivas_error ivas_read_format( st_ivas->sba_analysis_order = 1; } #endif + if ( idx == 0 ) { st_ivas->sid_format = SID_SBA_1TC; @@ -873,6 +871,7 @@ ivas_error ivas_init_decoder( return error; } } + #ifndef SBA_ORDER_BITSTREAM if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_order, st_ivas->sba_planar, st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK ) @@ -883,6 +882,7 @@ ivas_error ivas_init_decoder( { return error; } + if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) { if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -901,14 +901,8 @@ ivas_error ivas_init_decoder( st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); - 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 ); + 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 ); } } else diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 96ebc693f5e97b9b3c01f4faaa7da4980777282d..e3b35c0d82ecd3b7da1582540c607ee945c59e16 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -485,11 +485,15 @@ ivas_error ivas_sba_dec_reconfigure( numCldfbAnalyses = 0; sba_total_brate = ivas_total_brate; - nSCE_old = st_ivas->nSCE; nCPE_old = st_ivas->nCPE; nchan_transport_old = st_ivas->nchan_transport; sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; + +#ifdef SBA_ORDER_BITSTREAM + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); +#endif + #ifndef SBA_ORDER_BITSTREAM ivas_sba_config( sba_total_brate, st_ivas->sba_order, -1, &nchan_transport, st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, st_ivas->sba_mode ); #else @@ -522,12 +526,14 @@ ivas_error ivas_sba_dec_reconfigure( else { int16_t sba_order_internal; + #ifndef SBA_ORDER_BITSTREAM sba_order_internal = min( st_ivas->sba_order, IVAS_MAX_SBA_ORDER ); #else sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); #endif ivas_spar_config( st_ivas->hDecoderConfig->ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, st_ivas->sid_format ); + #ifndef SBA_ORDER_BITSTREAM if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->sba_order, st_ivas->sba_planar, st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK ) diff --git a/lib_dec/ivas_sba_rendering.c b/lib_dec/ivas_sba_rendering.c index 7f5a3a289bb9bd6f270deff433621bbd38e05f75..5552c26a50f20ae1596834c35c2b4422f034ed47 100755 --- a/lib_dec/ivas_sba_rendering.c +++ b/lib_dec/ivas_sba_rendering.c @@ -214,6 +214,7 @@ void ivas_sba_upmixer_renderer( int16_t nchan_internal; wmops_sub_start( "ivas_sba_upmixer_renderer" ); + #ifndef SBA_ORDER_BITSTREAM nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_order ); #else diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index cc625f26057172ec9037cf8861bb9eca59ce3053..f2b8f4926a477947e324ef808f2354636f732018 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -623,6 +623,7 @@ static void ivas_spar_dec_MD( /*---------------------------------------------------------------------* * Initialization *---------------------------------------------------------------------*/ + #ifndef SBA_ORDER_BITSTREAM sba_order = min( st_ivas->sba_order, IVAS_MAX_SBA_ORDER ); #else diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index be1b3fcb10e2883f6477b68c027504c1d0744c40..712801661dcf710074a4aaff0b9cbd22d7345fed 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -2577,6 +2577,7 @@ void ivas_spar_to_dirac( int16_t pred_idx; int16_t *dirac_to_spar_md_bands; int16_t enc_param_start_band; + #ifndef SBA_ORDER_BITSTREAM sba_order_internal = min( st_ivas->sba_order, IVAS_MAX_SBA_ORDER ); #else diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 740050928930d28ed84cb17f76b0241790d34b51..9b51b1299a393b838eb25214909a471cd3a7bcad 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1906,9 +1906,6 @@ typedef struct decoder_config_structure int32_t output_Fs; /* output signal sampling frequency in Hz */ int16_t nchan_out; /* number of output audio channels */ AUDIO_CONFIG output_config; /* output audio configuration */ -#ifdef SBA_ORDER_BITSTREAM - int16_t sba_order; -#endif int16_t Opt_LsCustom; /* indicates whether loudspeaker custom setup is used */ int16_t Opt_HRTF_binary; /* indicates whether HRTF binary file is used */ int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ @@ -1981,12 +1978,11 @@ typedef struct Decoder_Struct ISM_MODE ism_mode; /* ISM format mode */ SBA_MODE sba_mode; /* SBA format mode */ MC_MODE mc_mode; /* MC format mode */ -#ifdef SBA_ORDER_BITSTREAM - int16_t sba_analysis_order; /* Ambisonic (SBA) order */ -#else int16_t sba_order; /* Ambisonic (SBA) order */ -#endif int16_t sba_planar; /* Ambisonic (SBA) planar flag */ +#ifdef SBA_ORDER_BITSTREAM + int16_t sba_analysis_order; /* Ambisonic (SBA) order used for analysis and coding */ +#endif int16_t sba_dirac_stereo_flag; /* flag indicating stereo output for SBA DirAC modes with 1 TC */ /* rendering modules */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index c12a356146cc88363c13cb86dbfd3076e5051f3d..036cab190d3f0edd86a5f34830d64befcceb12f5 100755 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -169,12 +169,6 @@ ivas_error IVAS_DEC_Open( hIvasDec->st_ivas->ini_frame = 0; hIvasDec->st_ivas->ini_active_frame = 0; hIvasDec->st_ivas->writeFECoffset = 0; -#ifndef SBA_ORDER_BITSTREAM - hIvasDec->st_ivas->sba_order = 0; -#else - hIvasDec->st_ivas->sba_analysis_order = 0; -#endif - hIvasDec->st_ivas->sba_planar = 0; /*initialize pointers*/ ivas_initialize_handles_dec( hIvasDec->st_ivas ); @@ -183,6 +177,12 @@ ivas_error IVAS_DEC_Open( hIvasDec->st_ivas->sba_mode = SBA_MODE_NONE; hIvasDec->st_ivas->mc_mode = MC_MODE_NONE; + hIvasDec->st_ivas->sba_order = 0; + hIvasDec->st_ivas->sba_planar = 0; +#ifdef SBA_ORDER_BITSTREAM + hIvasDec->st_ivas->sba_analysis_order = 0; +#endif + return IVAS_ERR_OK; } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 21a7eb839f7d76c9007341d83a719e4941ca1478..d3fc621c1a66a342e03a5f0b6177d4aee02df914 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -423,6 +423,10 @@ ivas_error ivas_init_encoder( { st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); +#ifdef SBA_ORDER_BITSTREAM + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); +#endif + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { if ( ( error = ivas_spar_enc_open( st_ivas ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index b267cd2e6661fce1bd94da1a6f38907dbed826db..856a02e4dc2518b88e9f87e690b45dd61ffabf5b 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -48,6 +48,7 @@ /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ + static void ivas_sba_dmx_enc( float sba_data[][L_FRAME48k], const int16_t nchan_transport, const int16_t input_frame ); /*-------------------------------------------------------------------* @@ -67,6 +68,7 @@ void ivas_sba_getTCs( #else ivas_sba_zero_vert_comp( sba_data, st_ivas->sba_analysis_order, st_ivas->hEncoderConfig->sba_planar, input_frame ); #endif + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { #ifndef SBA_ORDER_BITSTREAM @@ -249,6 +251,10 @@ ivas_error ivas_sba_enc_reconfigure( nSCE_old = st_ivas->nSCE; ind_list_metadata = NULL; +#ifdef SBA_ORDER_BITSTREAM + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); +#endif + ivas_dirac_enc_reconfigure( st_ivas ); ntransport = st_ivas->nchan_transport; diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 03e16833e389beed615e9f2997e91e21d40938b0..0e4fd817c74556bbedb6375829a61a4b737ec827 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -149,6 +149,7 @@ ivas_error ivas_spar_enc_open( /*-----------------------------------------------------------------* * Configuration - set SPAR high-level parameters *-----------------------------------------------------------------*/ + #ifdef SBA_ORDER_BITSTREAM ivas_spar_config( hEncoderConfig->ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, -1 ); @@ -705,6 +706,7 @@ static ivas_error ivas_spar_enc_process( #else ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, &md_in_buf, hMetaData, dtx_silence_mode, sba_order ); #endif + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { float azi_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES]; diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index dc7c3677ddef6d3cb97ef0011b9846d054f90c9a..37245affc39295963c2f1845b492e125916f5ae7 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -87,7 +87,7 @@ static void ivas_write_parameter_bitstream( ivas_spar_md_enc_state_t *hMdEnc, co static ivas_error ivas_spar_md_enc_init( ivas_spar_md_enc_state_t *pState, const ENCODER_CONFIG_HANDLE hEncoderConfig #ifdef SBA_ORDER_BITSTREAM , - int16_t sba_order + const int16_t sba_order #endif ); @@ -115,7 +115,7 @@ ivas_error ivas_spar_md_enc_open( const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */ #ifdef SBA_ORDER_BITSTREAM , - int16_t sba_order + const int16_t sba_order /* i : Ambisonic (SBA) order */ #endif ) { @@ -126,6 +126,7 @@ ivas_error ivas_spar_md_enc_open( #else int16_t num_channels, i, j; #endif + #ifndef SBA_ORDER_BITSTREAM order = min( hEncoderConfig->sba_order, IVAS_MAX_SBA_ORDER ); #endif @@ -135,11 +136,13 @@ ivas_error ivas_spar_md_enc_open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD encoder" ); } + #ifndef SBA_ORDER_BITSTREAM num_channels = 2 * order + 2; #else num_channels = 2 * sba_order + 2; #endif + if ( ( hMdEnc->spar_md.band_coeffs = (ivas_band_coeffs_t *) count_malloc( IVAS_MAX_NUM_BANDS * sizeof( ivas_band_coeffs_t ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for band_coeffs in SPAR MD" ); @@ -219,6 +222,7 @@ ivas_error ivas_spar_md_enc_open( } } } + #ifndef SBA_ORDER_BITSTREAM if ( ( error = ivas_spar_md_enc_init( hMdEnc, hEncoderConfig ) ) != IVAS_ERR_OK ) #else @@ -331,7 +335,7 @@ static ivas_error ivas_spar_md_enc_init( const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */ #ifdef SBA_ORDER_BITSTREAM , - int16_t sba_order + const int16_t sba_order /* i : Ambisonic (SBA) order */ #endif ) { @@ -342,6 +346,7 @@ static ivas_error ivas_spar_md_enc_init( int16_t sba_order; #endif int16_t num_channels, i, j, k; + #ifndef SBA_ORDER_BITSTREAM sba_order = min( hEncoderConfig->sba_order, IVAS_MAX_SBA_ORDER ); #endif @@ -587,7 +592,7 @@ ivas_error ivas_spar_md_enc_process( const int16_t dtx_silence_mode #ifdef SBA_ORDER_BITSTREAM , - int16_t sba_order + const int16_t sba_order /* i : Ambisonic (SBA) order */ #endif ) { @@ -612,6 +617,7 @@ ivas_error ivas_spar_md_enc_process( float Wscale[IVAS_MAX_NUM_BANDS]; ivas_spar_md_enc_state_t *pState = hMdEnc; int16_t num_quant_strats = pState->spar_md_cfg.num_quant_strats; + #ifndef SBA_ORDER_BITSTREAM sba_order = min( hEncoderConfig->sba_order, IVAS_MAX_SBA_ORDER ); #endif diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 58b6970d58af865040c487a26283312db6f326d9..f3f74c002eaaff1f7ed7449c2ec331b4b532cde0 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1041,7 +1041,7 @@ typedef struct /* high-level encoder parameters */ int16_t nchan_transport; /* number of transport channels */ #ifdef SBA_ORDER_BITSTREAM - int16_t sba_analysis_order; /*Ambisonic(SBA) order*/ + int16_t sba_analysis_order; /* Ambisonic (SBA) order used for analysis and coding */ #endif int16_t codec_mode; /* Mode1 or Mode2 of core codec */ int16_t last_codec_mode; /* previous frame Mode 1 or 2 */ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index b9d4dde0325e17c2b54055f9b70b6792dec227b9..1ffe8007f4b6b26a092e200b38c4622d331fb3fd 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -158,6 +158,9 @@ ivas_error IVAS_ENC_Open( st_ivas->mc_mode = MC_MODE_NONE; st_ivas->ism_mode = ISM_MODE_NONE; st_ivas->sba_mode = SBA_MODE_NONE; +#ifdef SBA_ORDER_BITSTREAM + st_ivas->sba_analysis_order = 0; +#endif init_encoder_config( st_ivas->hEncoderConfig ); @@ -639,9 +642,7 @@ static ivas_error configureEncoder( st_ivas = hIvasEnc->st_ivas; hEncoderConfig = st_ivas->hEncoderConfig; -#ifdef SBA_ORDER_BITSTREAM - st_ivas->sba_analysis_order = hEncoderConfig->sba_order; -#endif + /*-----------------------------------------------------------------* * Bandwidth limitation *-----------------------------------------------------------------*/ @@ -772,16 +773,7 @@ static ivas_error configureEncoder( } else if ( hEncoderConfig->ivas_format == SBA_FORMAT ) { - if ( hEncoderConfig->ivas_total_brate < IVAS_256k ) - { - /* set SBA order to 1 for bit rates below 256kbps for correct handling of input with higher order */ - /* IVAS_fmToDo: needs more work in case of bitrate switching */ -#ifndef SBA_ORDER_BITSTREAM - hEncoderConfig->sba_order = 1; -#else - st_ivas->sba_analysis_order = 1; -#endif - } + /* nothing */ } else if ( hEncoderConfig->ivas_format == MASA_FORMAT ) { @@ -886,11 +878,8 @@ static ivas_error configureEncoder( { return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "AGC supported in SBA format at bitrates >= 24.4 kbps only." ); } -#ifndef SBA_ORDER_BITSTREAM + if ( hEncoderConfig->Opt_PCA_ON && !( hEncoderConfig->ivas_format == SBA_FORMAT && hEncoderConfig->ivas_total_brate == PCA_BRATE && hEncoderConfig->sba_order == 1 ) ) -#else - if ( hEncoderConfig->Opt_PCA_ON && !( hEncoderConfig->ivas_format == SBA_FORMAT && hEncoderConfig->ivas_total_brate == PCA_BRATE && st_ivas->sba_analysis_order == 1 ) ) -#endif { return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "PCA supported at SBA FOA 256 kbps only." ); }