From b769bf8cc635403683623a2e26689fd7b6adc18c Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 31 Oct 2022 13:48:16 +0100 Subject: [PATCH 1/9] formatting --- lib_dec/ivas_spar_md_dec.c | 13 +++---------- lib_enc/ivas_spar_encoder.c | 8 ++------ lib_enc/ivas_spar_md_enc.c | 3 +-- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 5d39aee9a0..4b9dbc5347 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -444,8 +444,7 @@ ivas_error ivas_spar_md_dec_init( hMdDec->spar_md.num_bands = ( hMdDec->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); - ivas_spar_set_bitrate_config( &hMdDec->spar_md_cfg, hMdDec->table_idx, - hMdDec->spar_md.num_bands ); + ivas_spar_set_bitrate_config( &hMdDec->spar_md_cfg, hMdDec->table_idx, hMdDec->spar_md.num_bands ); nchan_transport = hMdDec->spar_md_cfg.nchan_transport; @@ -2758,10 +2757,7 @@ void ivas_spar_to_dirac( /* DirAC MD averaged over 4 subframes and converted to SPAR format similar to encoder processing */ if ( hMdDec->spar_md_cfg.nchan_transport > 1 ) { - ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, - end_band, num_bands_out, - ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, - dtx_vad, NULL ); + ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL ); /* temporarily copy frame-wise prediction coefficients in DirAC bands*/ for ( pred_idx = 0; pred_idx < FOA_CHANNELS - 1; pred_idx++ ) @@ -2773,10 +2769,7 @@ void ivas_spar_to_dirac( } } - ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, MAX_PARAM_SPATIAL_SUBFRAMES, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, - end_band, num_bands_out, - ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, - dtx_vad, NULL ); + ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, MAX_PARAM_SPATIAL_SUBFRAMES, NULL, &hMdDec->spar_md, &hMdDec->spar_md_cfg, end_band, num_bands_out, ( hMdDec->spar_hoa_md_flag ) ? 1 : sba_order_internal, dtx_vad, NULL ); /* expand DirAC TC 20ms MD for residual channels to all subframes*/ for ( block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 7e2d49310f..d84bee262e 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -549,8 +549,7 @@ static ivas_error ivas_spar_enc_process( if ( hSpar->hMdEnc->table_idx != table_idx ) { hSpar->hMdEnc->table_idx = table_idx; - ivas_spar_set_bitrate_config( &hSpar->hMdEnc->spar_md_cfg, table_idx, - ( hSpar->hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND ); + ivas_spar_set_bitrate_config( &hSpar->hMdEnc->spar_md_cfg, table_idx, ( hSpar->hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND ); } nchan_transport = st_ivas->nchan_transport; @@ -603,10 +602,7 @@ static ivas_error ivas_spar_enc_process( Wscale_d[b] = min( 2.0f, max( Wscale_d[b], 1.0f ) ); } - ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, hSpar->hMdEnc->mixer_mat, &hSpar->hMdEnc->spar_md, &hSpar->hMdEnc->spar_md_cfg, - d_start_band, d_end_band, - ( hSpar->hMdEnc->spar_hoa_md_flag ) ? 1 : sba_order, - dtx_vad, Wscale_d ); + ivas_get_spar_md_from_dirac( azi_dirac, ele_dirac, diffuseness, 1, hSpar->hMdEnc->mixer_mat, &hSpar->hMdEnc->spar_md, &hSpar->hMdEnc->spar_md_cfg, d_start_band, d_end_band, ( hSpar->hMdEnc->spar_hoa_md_flag ) ? 1 : sba_order, dtx_vad, Wscale_d ); } if ( hSpar->hMdEnc->spar_hoa_md_flag ) diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 4bd23dee47..508742c4ea 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -322,8 +322,7 @@ static ivas_error ivas_spar_md_enc_init( table_idx = ivas_get_spar_table_idx( hEncoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL ); hMdEnc->spar_md_cfg.gen_bs = 1; - ivas_spar_set_bitrate_config( &hMdEnc->spar_md_cfg, table_idx, - ( hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND ); + ivas_spar_set_bitrate_config( &hMdEnc->spar_md_cfg, table_idx, ( hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND ); /* get FB coefficients */ for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) -- GitLab From d8c0f7d9889a712579f5ccc9f1f08eeaf68d8340 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 31 Oct 2022 13:49:32 +0100 Subject: [PATCH 2/9] remove 'fb_ducking_flag ' parameter which was always == 0 --- lib_dec/ivas_spar_md_dec.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 4b9dbc5347..72022dba61 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -1344,7 +1344,6 @@ void ivas_spar_dec_gen_umx_mat( ) { int16_t i, j, b, i_ts, num_out_ch; - int16_t fb_ducking_flag = 0; // VE2DB: always 0 - can it be removed? num_out_ch = hMdDec->spar_md_cfg.num_umx_chs; @@ -1373,11 +1372,6 @@ void ivas_spar_dec_gen_umx_mat( } } } - - if ( fb_ducking_flag ) - { - assert( 0 ); /* fb_ducking_flag not supported */ - } } else { -- GitLab From d8e5c770c738d41132e023cbc1ac98fa0d0aca2d Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 31 Oct 2022 13:51:02 +0100 Subject: [PATCH 3/9] remove 'dtx_silence_mode' parameter which was always == 0 --- lib_enc/ivas_spar_md_enc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 508742c4ea..d19299c562 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -82,11 +82,14 @@ static void ivas_select_next_strat( ivas_strats_t prior_strat, ivas_strats_t cs[ static void ivas_store_prior_coeffs( ivas_spar_md_enc_state_t *hMdEnc, const int16_t num_bands, const int16_t bands_bw, const int16_t strat, const int16_t dtx_vad, const int16_t qsi ); -static void ivas_write_spar_md_bitstream( ivas_spar_md_enc_state_t *hMdEnc, const int16_t nB, const int16_t bands_bw, BSTR_ENC_HANDLE hMetaData, const int32_t ivas_total_brate, const int16_t dtx_silence_mode, const int16_t strat, const int16_t qsi, const int16_t planarCP ); +static void ivas_write_spar_md_bitstream( ivas_spar_md_enc_state_t *hMdEnc, const int16_t nB, const int16_t bands_bw, BSTR_ENC_HANDLE hMetaData, const int32_t ivas_total_brate, const int16_t strat, const int16_t qsi, const int16_t planarCP ); static ivas_error ivas_spar_md_enc_init( ivas_spar_md_enc_state_t *hMdEnc, const ENCODER_CONFIG_HANDLE hEncoderConfig, const int16_t sba_order ); + static void ivas_spar_quant_pred_coeffs_dtx( ivas_spar_md_t *pSpar_md, const float *pValues, const int16_t ndm, int16_t *pIndex, const int16_t dim1, float *pQuant ); + static void ivas_quant_p_per_band_dtx( float *pP_mat, const int16_t num_dec, const int16_t num_dmx, int16_t *ppIdx_pd, float *pP_out, const int16_t num_ch ); + static void ivas_write_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, BSTR_ENC_HANDLE hMetaData, int16_t *num_dmx, int16_t *num_dec, const int16_t num_bands ); static void ivas_quant_p_per_band( ivas_band_coeffs_t *pband_coeffs, ivas_band_coeffs_ind_t *pBand_coeffs_idx, ivas_quant_strat_t *pQs, const int16_t num_ch ); @@ -902,7 +905,7 @@ ivas_error ivas_spar_md_enc_process( { reset_indices_enc( &hMetaData_tmp, MAX_BITS_METADATA ); - ivas_write_spar_md_bitstream( hMdEnc, num_bands, bands_bw, &hMetaData_tmp, hEncoderConfig->ivas_total_brate, 0, strat, qsi, planarCP ); + ivas_write_spar_md_bitstream( hMdEnc, num_bands, bands_bw, &hMetaData_tmp, hEncoderConfig->ivas_total_brate, strat, qsi, planarCP ); if ( hMetaData->nb_bits_tot == bit_pos_start || hMetaData_tmp.nb_bits_tot < ( hMetaData->nb_bits_tot - bit_pos_start ) ) { @@ -1178,7 +1181,6 @@ static void ivas_write_spar_md_bitstream( const int16_t bands_bw, BSTR_ENC_HANDLE hMetaData, const int32_t ivas_total_brate, - const int16_t dtx_silence_mode, // VE2DB: it is always 0 -> remove it? const int16_t strat, const int16_t qsi, const int16_t planarCP ) @@ -1192,7 +1194,7 @@ static void ivas_write_spar_md_bitstream( } /* write quant strat */ - if ( dtx_silence_mode == 0 && ivas_total_brate >= BRATE_SPAR_Q_STRAT ) + if ( ivas_total_brate >= BRATE_SPAR_Q_STRAT ) { push_next_indice( hMetaData, qsi >> 1, hMdEnc->spar_md_cfg.quant_strat_bits - 1 ); } -- GitLab From c01aeaf76c546a4abe81ba552de47af0182a5047 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 1 Nov 2022 09:12:35 +0100 Subject: [PATCH 4/9] remove 'gen_bs' SPAR MD parameter + improve formatting --- lib_com/ivas_spar_com.c | 17 +- lib_com/ivas_stat_com.h | 1 - lib_dec/ivas_spar_md_dec.c | 338 ++++++++++++++++++------------------- lib_enc/ivas_spar_md_enc.c | 24 +-- 4 files changed, 170 insertions(+), 210 deletions(-) diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index fa5e65460e..c9204291bc 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -2109,17 +2109,7 @@ void ivas_spar_set_bitrate_config( pSpar_md_cfg->agc_bits_ch_idx = ivas_spar_br_table_consts[table_idx].agc_bits_ch_idx; ivas_spar_get_uniform_quant_strat( pSpar_md_cfg, table_idx ); - if ( pSpar_md_cfg->quant_strat->C.q_levels[0] == 0 || pSpar_md_cfg->quant_strat->C.q_levels[1] == 0 || pSpar_md_cfg->quant_strat->PR.q_levels[0] == 0 || pSpar_md_cfg->quant_strat->PR.q_levels[1] == 0 || pSpar_md_cfg->quant_strat->P_c.q_levels[0] == 0 || pSpar_md_cfg->quant_strat->P_c.q_levels[1] == 0 || pSpar_md_cfg->quant_strat->P_r.q_levels[0] == 0 || pSpar_md_cfg->quant_strat->P_r.q_levels[1] == 0 ) - { - pSpar_md_cfg->gen_bs = 0; - } - else - { - if ( 0 != pSpar_md_cfg->gen_bs ) - { - pSpar_md_cfg->quant_strat_bits = ivas_get_bits_to_encode( MAX_QUANT_STRATS ); - } - } + pSpar_md_cfg->quant_strat_bits = ivas_get_bits_to_encode( MAX_QUANT_STRATS ); /* BLOCK: getEntropyCoderModels */ @@ -2138,11 +2128,12 @@ void ivas_spar_set_bitrate_config( total_bits += (int16_t) ( ivas_spar_br_table_consts[table_idx].core_brs[i][0] / FRAMES_PER_SEC ); max_bits += (int16_t) ( ivas_spar_br_table_consts[table_idx].core_brs[i][1] / FRAMES_PER_SEC ); } - pSpar_md_cfg->tgt_bits_per_blk = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - SBA_PLANAR_BITS - SBA_ORDER_BITS - length - total_bits; + pSpar_md_cfg->tgt_bits_per_blk = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - SBA_PLANAR_BITS - SBA_ORDER_BITS - length - total_bits; pSpar_md_cfg->max_bits_per_blk = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - SBA_PLANAR_BITS - SBA_ORDER_BITS - length - max_bits; md_coding_bits_header = SPAR_NUM_CODING_STRAT_BITS + pSpar_md_cfg->quant_strat_bits; + pSpar_md_cfg->tgt_bits_per_blk -= md_coding_bits_header; pSpar_md_cfg->max_bits_per_blk -= md_coding_bits_header; @@ -2151,9 +2142,11 @@ void ivas_spar_set_bitrate_config( pSpar_md_cfg->tgt_bits_per_blk += md_coding_bits_header; pSpar_md_cfg->max_bits_per_blk += md_coding_bits_header; + return; } + #ifdef FIX_I1_113 /*-----------------------------------------------------------------------------------------* * Function ivas_spar_bitrate_dist() diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index b275d2d6eb..8dd59f1d18 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -229,7 +229,6 @@ typedef struct ivas_spar_md_com_cfg int16_t active_w; int16_t remix_unmix_order; ivas_quant_strat_t quant_strat[MAX_QUANT_STRATS]; - int16_t gen_bs; int16_t quant_strat_bits; int16_t nchan_transport; int16_t num_quant_strats; diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 72022dba61..846ec04778 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -82,7 +82,9 @@ static void ivas_spar_md_fill_invalid_bands( ivas_spar_dec_matrices_t *pSpar_coe static ivas_error ivas_spar_set_dec_config( ivas_spar_md_dec_state_t *hMdDec, const int16_t nchan_transport, float *pFC ); static void ivas_parse_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, Decoder_State *st, const int16_t bw, const int16_t num_bands, int16_t *num_dmx_per_band, int16_t *num_dec_per_band ); + static ivas_error ivas_deindex_real_index( const int16_t *index, const int16_t q_levels, const float min_value, const float max_value, float *quant, const int16_t num_ch_dim2 ); + static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, int16_t *nB, int16_t *bands_bw, int16_t *dtx_vad, const int32_t ivas_total_brate, const int16_t use_planar_coeff, const int16_t sba_inactive_mode ); @@ -440,8 +442,6 @@ ivas_error ivas_spar_md_dec_init( int16_t nchan_transport; float pFC[IVAS_MAX_NUM_BANDS], PR_minmax[2]; - hMdDec->spar_md_cfg.gen_bs = 1; // VE2DB : always 1 - can it be removed? - hMdDec->spar_md.num_bands = ( hMdDec->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); ivas_spar_set_bitrate_config( &hMdDec->spar_md_cfg, hMdDec->table_idx, hMdDec->spar_md.num_bands ); @@ -1431,226 +1431,220 @@ static void ivas_spar_dec_parse_md_bs( const int16_t sba_inactive_mode ) { int16_t i, j, k, num_bands; + int16_t ii, jj, ndec, ndm, b, idx; uint16_t qsi; ivas_quant_strat_t qs; int16_t strat, freq_diff, no_ec; int16_t do_diff[IVAS_MAX_NUM_BANDS]; - int16_t planarCP = 0; + int16_t planarCP; + float quant[IVAS_SPAR_MAX_C_COEFF]; *dtx_vad = 1; *bands_bw = 1; qsi = 0; num_bands = hMdDec->spar_md.num_bands; - if ( hMdDec->spar_md_cfg.gen_bs == 1 ) + if ( ivas_total_brate > IVAS_SID_5k2 ) { - if ( ivas_total_brate > IVAS_SID_5k2 ) + if ( hMdDec->spar_md_cfg.quant_strat_bits > 0 ) { - if ( hMdDec->spar_md_cfg.quant_strat_bits > 0 ) + if ( ivas_total_brate >= BRATE_SPAR_Q_STRAT ) { - if ( ivas_total_brate >= BRATE_SPAR_Q_STRAT ) - { - /*only one bit written for quantization strategy to indicate either a fixed quantization strategy or dtx_vad==0 */ - qsi = get_next_indice( st0, 1 ); - if ( qsi == 1 ) - { - *dtx_vad = 0; - } - } - else + /*only one bit written for quantization strategy to indicate either a fixed quantization strategy or dtx_vad==0 */ + qsi = get_next_indice( st0, 1 ); + if ( qsi == 1 ) { - if ( sba_inactive_mode == 1 ) - { - *dtx_vad = 0; - qsi = hMdDec->spar_md_cfg.quant_strat_bits + 1; - } - else - { - qsi = get_next_indice( st0, hMdDec->spar_md_cfg.quant_strat_bits ); - } + *dtx_vad = 0; } } else { - qsi = 0; + if ( sba_inactive_mode == 1 ) + { + *dtx_vad = 0; + qsi = hMdDec->spar_md_cfg.quant_strat_bits + 1; + } + else + { + qsi = get_next_indice( st0, hMdDec->spar_md_cfg.quant_strat_bits ); + } } } else { - *dtx_vad = 0; + qsi = 0; } + } + else + { + *dtx_vad = 0; + } - hMdDec->dtx_vad = *dtx_vad; + hMdDec->dtx_vad = *dtx_vad; - if ( *dtx_vad == 0 ) - { - *nB = SPAR_DTX_BANDS; - *bands_bw = num_bands / *nB; + if ( *dtx_vad == 0 ) + { + *nB = SPAR_DTX_BANDS; + *bands_bw = num_bands / *nB; - for ( i = 0; i < *nB; i++ ) + for ( i = 0; i < *nB; i++ ) + { + for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ ) { - for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ ) - { - hMdDec->spar_md.band_coeffs[i].pred_re[j] = 0; - hMdDec->spar_md.band_coeffs[i].P_re[j] = 0; - } - hMdDec->valid_bands[i] = 1; + hMdDec->spar_md.band_coeffs[i].pred_re[j] = 0; + hMdDec->spar_md.band_coeffs[i].P_re[j] = 0; } - for ( i = 0; i < num_bands; i++ ) + hMdDec->valid_bands[i] = 1; + } + + for ( i = 0; i < num_bands; i++ ) + { + for ( j = 0; j < ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ); j++ ) { - for ( j = 0; j < ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ); j++ ) + for ( k = 0; k < ( IVAS_SPAR_MAX_DMX_CHS - 1 ); k++ ) { - for ( k = 0; k < ( IVAS_SPAR_MAX_DMX_CHS - 1 ); k++ ) - { - hMdDec->spar_md.band_coeffs[i].C_re[j][k] = 0; - } + hMdDec->spar_md.band_coeffs[i].C_re[j][k] = 0; } } + } + + ivas_parse_parameter_bitstream_dtx( &hMdDec->spar_md, st0, *bands_bw, *nB, hMdDec->spar_md_cfg.num_dmx_chans_per_band, hMdDec->spar_md_cfg.num_decorr_per_band ); + + for ( i = *nB - 1; i >= 0; i-- ) + { + ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i]; - ivas_parse_parameter_bitstream_dtx( &hMdDec->spar_md, st0, *bands_bw, *nB, - hMdDec->spar_md_cfg.num_dmx_chans_per_band, hMdDec->spar_md_cfg.num_decorr_per_band ); + for ( b = *bands_bw - 1; b >= 0; b-- ) { - int16_t ndec, b, idx; - for ( i = *nB - 1; i >= 0; i-- ) + idx = i * *bands_bw + b; + for ( j = 0; j < FOA_CHANNELS - 1; j++ ) { - ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i]; - - for ( b = *bands_bw - 1; b >= 0; b-- ) - { - idx = i * *bands_bw + b; - for ( j = 0; j < FOA_CHANNELS - 1; j++ ) - { - hMdDec->spar_md.band_coeffs[idx].pred_re[j] = hMdDec->spar_md.band_coeffs[i].pred_re[j]; - } - for ( j = 0; j < ndec; j++ ) - { - hMdDec->spar_md.band_coeffs[idx].P_re[j] = hMdDec->spar_md.band_coeffs[i].P_re[j]; - } - hMdDec->valid_bands[idx] = 1; - } + hMdDec->spar_md.band_coeffs[idx].pred_re[j] = hMdDec->spar_md.band_coeffs[i].pred_re[j]; } - *nB = num_bands; - *bands_bw = 1; + for ( j = 0; j < ndec; j++ ) + { + hMdDec->spar_md.band_coeffs[idx].P_re[j] = hMdDec->spar_md.band_coeffs[i].P_re[j]; + } + hMdDec->valid_bands[idx] = 1; } - - return; } - qs = hMdDec->spar_md_cfg.quant_strat[qsi]; - if ( ( qsi == 2 ) && ( use_planar_coeff ) ) - { - planarCP = 1; + *nB = num_bands; + *bands_bw = 1; + + return; + } + + qs = hMdDec->spar_md_cfg.quant_strat[qsi]; + + planarCP = 0; + if ( ( qsi == 2 ) && ( use_planar_coeff ) ) + { + planarCP = 1; #ifdef SPAR_HOA_DBG - fprintf( stdout, "planarCP = 1\n" ); + fprintf( stdout, "planarCP = 1\n" ); #endif - } - strat = get_next_indice( st0, 3 ); + } + strat = get_next_indice( st0, 3 ); + #ifdef SPAR_HOA_DBG - /*fprintf(stdout, "\n\n no_ec = %d, strat = %d\n", no_ec, strat);*/ + /*fprintf(stdout, "\n\n no_ec = %d, strat = %d\n", no_ec, strat);*/ #endif - freq_diff = 0; - no_ec = 0; + freq_diff = 0; + no_ec = 0; - if ( strat < 2 ) + if ( strat < 2 ) + { + *bands_bw = strat + 1; + *nB = num_bands / *bands_bw; + for ( i = 0; i < *nB; i++ ) { - *bands_bw = strat + 1; - *nB = num_bands / *bands_bw; - for ( i = 0; i < *nB; i++ ) - { - do_diff[i] = 0; - } + do_diff[i] = 0; } - else if ( strat < 4 ) + } + else if ( strat < 4 ) + { + *bands_bw = strat - 1; + *nB = num_bands / *bands_bw; + for ( i = 0; i < *nB; i++ ) { - *bands_bw = strat - 1; - *nB = num_bands / *bands_bw; - for ( i = 0; i < *nB; i++ ) - { - do_diff[i] = 0; - } - no_ec = 1; + do_diff[i] = 0; } - else - { - *bands_bw = 1; - *nB = num_bands; - - for ( i = 0; i < *nB; i++ ) - { - do_diff[i] = ( ( ( i + 1 ) & 3 ) != strat - 4 ); - } + no_ec = 1; + } + else + { + *bands_bw = 1; + *nB = num_bands; - ivas_map_prior_coeffs_quant( &hMdDec->spar_md_prev, &hMdDec->spar_md_cfg, qsi, *nB ); + for ( i = 0; i < *nB; i++ ) + { + do_diff[i] = ( ( ( i + 1 ) & 3 ) != strat - 4 ); } + + ivas_map_prior_coeffs_quant( &hMdDec->spar_md_prev, &hMdDec->spar_md_cfg, qsi, *nB ); + } #ifdef SPAR_HOA_DBG - fprintf( stdout, "\n\n no_ec = %d, strat = %d\n", no_ec, strat ); + fprintf( stdout, "\n\n no_ec = %d, strat = %d\n", no_ec, strat ); #endif - hMdDec->spar_md_cfg.prev_quant_idx = qsi; + hMdDec->spar_md_cfg.prev_quant_idx = qsi; - if ( no_ec == 0 ) - { - ivas_decode_arith_bs( hMdDec, st0, qsi, *nB, *bands_bw, do_diff, freq_diff, planarCP ); - } - else - { - ivas_decode_huffman_bs( hMdDec, st0, qsi, *nB, *bands_bw, planarCP ); - } + if ( no_ec == 0 ) + { + ivas_decode_arith_bs( hMdDec, st0, qsi, *nB, *bands_bw, do_diff, freq_diff, planarCP ); + } + else + { + ivas_decode_huffman_bs( hMdDec, st0, qsi, *nB, *bands_bw, planarCP ); + } - for ( i = 0; i < *nB; i++ ) - { - int16_t ii, jj; - int16_t ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i]; - int16_t ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * i]; - float quant[IVAS_SPAR_MAX_C_COEFF]; - ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].pred_index_re, qs.PR.q_levels[0], qs.PR.min, qs.PR.max, hMdDec->spar_md.band_coeffs[i].pred_re, ndm + ndec - 1 ); + for ( i = 0; i < *nB; i++ ) + { + ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i]; + ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * i]; - j = 0; - for ( ii = 0; ii < ndec; ii++ ) - { - for ( jj = 0; jj < ndm - 1; jj++ ) - { - quant[j] = hMdDec->spar_md.band_coeffs[i].C_re[ii][jj]; - j++; - } - } - ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].drct_index_re, qs.C.q_levels[0], qs.C.min, qs.C.max, quant, ndec * ( ndm - 1 ) ); - j = 0; - for ( ii = 0; ii < ndec; ii++ ) - { - for ( jj = 0; jj < ndm - 1; jj++ ) - { - hMdDec->spar_md.band_coeffs[i].C_re[ii][jj] = quant[j]; - j++; - } - } - ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].decd_index_re, qs.P_r.q_levels[0], qs.P_r.min, qs.P_r.max, hMdDec->spar_md.band_coeffs[i].P_re, ndm + ndec - 1 ); - /* Store prior coefficient indices */ - for ( j = 0; j < ndm + ndec - 1; j++ ) - { - hMdDec->spar_md_prev.band_coeffs_idx[i].pred_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j]; - } - for ( j = 0; j < ndec * ( ndm - 1 ); j++ ) + ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].pred_index_re, qs.PR.q_levels[0], qs.PR.min, qs.PR.max, hMdDec->spar_md.band_coeffs[i].pred_re, ndm + ndec - 1 ); + + j = 0; + for ( ii = 0; ii < ndec; ii++ ) + { + for ( jj = 0; jj < ndm - 1; jj++ ) { - hMdDec->spar_md_prev.band_coeffs_idx[i].drct_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j]; + quant[j] = hMdDec->spar_md.band_coeffs[i].C_re[ii][jj]; + j++; } - for ( j = 0; j < ndec; j++ ) + } + + ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].drct_index_re, qs.C.q_levels[0], qs.C.min, qs.C.max, quant, ndec * ( ndm - 1 ) ); + + j = 0; + for ( ii = 0; ii < ndec; ii++ ) + { + for ( jj = 0; jj < ndm - 1; jj++ ) { - hMdDec->spar_md_prev.band_coeffs_idx[i].decd_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j]; + hMdDec->spar_md.band_coeffs[i].C_re[ii][jj] = quant[j]; + j++; } - hMdDec->valid_bands[i] |= ( do_diff[i] == 0 ) ? 1 : 0; } - } - else - { - *dtx_vad = hMdDec->spar_md.dtx_vad; - *nB = num_bands; - *bands_bw = num_bands / *nB; - for ( i = 0; i < *nB; i++ ) + ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].decd_index_re, qs.P_r.q_levels[0], qs.P_r.min, qs.P_r.max, hMdDec->spar_md.band_coeffs[i].P_re, ndm + ndec - 1 ); + + /* Store prior coefficient indices */ + for ( j = 0; j < ndm + ndec - 1; j++ ) { - hMdDec->valid_bands[i] = 1; + hMdDec->spar_md_prev.band_coeffs_idx[i].pred_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j]; } + for ( j = 0; j < ndec * ( ndm - 1 ); j++ ) + { + hMdDec->spar_md_prev.band_coeffs_idx[i].drct_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j]; + } + for ( j = 0; j < ndec; j++ ) + { + hMdDec->spar_md_prev.band_coeffs_idx[i].decd_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j]; + } + hMdDec->valid_bands[i] |= ( do_diff[i] == 0 ) ? 1 : 0; } + #ifdef SPAR_HOA_DBG int16_t b; b = 0; @@ -1743,14 +1737,14 @@ static void ivas_decode_arith_bs( const int16_t freq_diff, const int16_t planarCP ) { - int16_t i, ndm, ndec; + int16_t i, j, ndm, ndec; ivas_cell_dim_t pred_cell_dims[IVAS_MAX_NUM_BANDS]; ivas_cell_dim_t drct_cell_dims[IVAS_MAX_NUM_BANDS]; ivas_cell_dim_t decd_cell_dims[IVAS_MAX_NUM_BANDS]; ivas_cell_dim_t decx_cell_dims[IVAS_MAX_NUM_BANDS]; int16_t symbol_arr_re[IVAS_MAX_INPUT_LEN]; int16_t symbol_arr_old_re[IVAS_MAX_INPUT_LEN]; - int16_t any_diff = 0; + int16_t any_diff; for ( i = 0; i < nB; i++ ) { @@ -1774,6 +1768,7 @@ static void ivas_decode_arith_bs( decx_cell_dims[i].dim2 = 1; } + any_diff = 0; for ( i = 0; i < nB; i++ ) { if ( pDo_diff[i] != 0 ) @@ -1787,7 +1782,6 @@ static void ivas_decode_arith_bs( { if ( hMdDec->spar_hoa_md_flag ) { - int16_t j; for ( i = 0; i < nB; i++ ) { if ( i >= SPAR_DIRAC_SPLIT_START_BAND ) @@ -1810,7 +1804,6 @@ static void ivas_decode_arith_bs( if ( hMdDec->spar_hoa_md_flag ) { - int16_t j; for ( i = 0; i < nB; i++ ) { if ( i >= SPAR_DIRAC_SPLIT_START_BAND ) @@ -2063,12 +2056,11 @@ static void ivas_decode_huffman_bs( const int16_t planarCP ) { int16_t i, j; + int16_t ndm, ndec; + int16_t pred_dim, drct_dim, decd_dim, pred_offset; for ( i = 0; i < nB; i++ ) { - int16_t ndm, ndec; - int16_t pred_dim, drct_dim, decd_dim, pred_offset; - ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[bands_bw * i]; ndec = hMdDec->spar_md_cfg.num_decorr_per_band[bands_bw * i]; @@ -2086,8 +2078,7 @@ static void ivas_decode_huffman_bs( for ( j = pred_offset; j < pred_dim; j++ ) { - ivas_huffman_decode( &hMdDec->huff_coeffs.pred_huff_re[qsi], st0, - &hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] ); + ivas_huffman_decode( &hMdDec->huff_coeffs.pred_huff_re[qsi], st0, &hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] ); } if ( hMdDec->spar_hoa_md_flag ) @@ -2109,8 +2100,7 @@ static void ivas_decode_huffman_bs( } else { - ivas_huffman_decode( &hMdDec->huff_coeffs.drct_huff_re[qsi], st0, - &hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j] ); + ivas_huffman_decode( &hMdDec->huff_coeffs.drct_huff_re[qsi], st0, &hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j] ); } } @@ -2122,8 +2112,7 @@ static void ivas_decode_huffman_bs( } else { - ivas_huffman_decode( &hMdDec->huff_coeffs.decd_huff_re[qsi], st0, - &hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j] ); + ivas_huffman_decode( &hMdDec->huff_coeffs.decd_huff_re[qsi], st0, &hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j] ); } } } @@ -2347,6 +2336,7 @@ static void ivas_spar_unquant_dtx_indicies( pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; + for ( b = 0; b < nB; b++ ) { for ( i = 0; i < FOA_CHANNELS - 1; i++ ) @@ -2384,7 +2374,7 @@ static void ivas_parse_parameter_bitstream_dtx( int16_t *num_dmx_per_band, int16_t *num_dec_per_band ) { - int16_t i, j; + int16_t i, j, ndec, ndm; float val; int16_t idx; float pr_min_max[2]; @@ -2397,8 +2387,8 @@ static void ivas_parse_parameter_bitstream_dtx( for ( i = 0; i < num_bands; i++ ) { - int16_t ndec = num_dec_per_band[bw * i]; - int16_t ndm = num_dmx_per_band[bw * i]; + ndec = num_dec_per_band[bw * i]; + ndm = num_dmx_per_band[bw * i]; for ( j = 0; j < FOA_CHANNELS - 1; j++ ) { diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index d19299c562..1fafdbd4e6 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -324,7 +324,6 @@ static ivas_error ivas_spar_md_enc_init( table_idx = ivas_get_spar_table_idx( hEncoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL ); - hMdEnc->spar_md_cfg.gen_bs = 1; ivas_spar_set_bitrate_config( &hMdEnc->spar_md_cfg, table_idx, ( hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND ); /* get FB coefficients */ @@ -334,19 +333,6 @@ static ivas_error ivas_spar_md_enc_init( } ivas_spar_set_enc_config( hMdEnc, hMdEnc->spar_md_cfg.max_freq_per_chan, hMdEnc->spar_md_cfg.nchan_transport, pFC, num_channels ); - /* - if(hMdEnc->spar_md_cfg.quant_strat[0].C.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].C.q_levels[1] == 0 - || hMdEnc->spar_md_cfg.quant_strat[0].PR.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].PR.q_levels[1] == 0 - || hMdEnc->spar_md_cfg.quant_strat[0].P_c.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].P_c.q_levels[1] == 0 - || hMdEnc->spar_md_cfg.quant_strat[0].P_r.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].P_r.q_levels[1] == 0) - { - hMdEnc->spar_md_cfg.gen_bs = 0; - } - else if(0 != hMdEnc->spar_md_cfg.gen_bs) - { - hMdEnc->spar_md_cfg.quant_strat_bits = ivas_get_bits_to_encode(MAX_QUANT_STRATS); - } -*/ if ( hMdEnc->spar_md_cfg.nchan_transport != 2 && ( ( hMdEnc->spar_md_cfg.remix_unmix_order == 1 ) || ( hMdEnc->spar_md_cfg.remix_unmix_order == 2 ) ) ) { @@ -885,11 +871,6 @@ ivas_error ivas_spar_md_enc_process( ivas_band_mixing( hMdEnc, num_ch, num_bands, nchan_transport, num_bands_full ); } - if ( hMdEnc->spar_md_cfg.gen_bs == 0 ) - { - break; - } - if ( dtx_vad == 0 ) { ivas_write_parameter_bitstream_dtx( &hMdEnc->spar_md, hMetaData, hMdEnc->spar_md_cfg.num_dmx_chans_per_band, hMdEnc->spar_md_cfg.num_decorr_per_band, num_bands ); @@ -1110,10 +1091,7 @@ ivas_error ivas_spar_md_enc_process( fclose( fp ); #endif - if ( hMdEnc->spar_md_cfg.gen_bs == 1 ) - { - ivas_store_prior_coeffs( hMdEnc, num_bands, bands_bw, code_strat, dtx_vad, qsi ); - } + ivas_store_prior_coeffs( hMdEnc, num_bands, bands_bw, code_strat, dtx_vad, qsi ); hMdEnc->spar_md.dtx_vad = dtx_vad; hMdEnc->spar_md.num_bands = num_bands; -- GitLab From 1f55fb65b518fa54f16d9aef9945684905033215 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 2 Nov 2022 08:04:44 +0100 Subject: [PATCH 5/9] data type change int32_t -> int16_t --- lib_dec/ivas_stat_dec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index b2e8940b8c..edbb0bed62 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -870,7 +870,7 @@ typedef struct ivas_spar_dec_lib_t int16_t dirac_to_spar_md_bands[DIRAC_MAX_NBANDS]; int16_t enc_param_start_band; int32_t core_nominal_brate; /* Nominal bitrate for core coding */ - int32_t i_subframe; + int16_t i_subframe; #ifdef DEBUG_SBA_AUDIO_DUMP int16_t numOutChannels; -- GitLab From efa08a98bb76136c5c1fc11811b03bfb341c77a0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 2 Nov 2022 10:47:22 +0100 Subject: [PATCH 6/9] replace magic numbers, e.g. 2 * order + 2, by a function call + formatting --- lib_com/ivas_spar_com.c | 7 ++++--- lib_dec/ivas_spar_md_dec.c | 2 +- lib_enc/ivas_spar_md_enc.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index c9204291bc..ceab9dd42c 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -1667,8 +1667,8 @@ void ivas_get_spar_md_from_dirac( remix_order = remix_order_set[hSpar_md_cfg->remix_unmix_order]; - num_ch = 2 * order + 2; - hoa2_ch = 6; + num_ch = ivas_sba_get_nchan_metadata( order ); + hoa2_ch = ivas_sba_get_nchan_metadata( 2 ); foa_ch = FOA_CHANNELS; diff_norm_order1 = 3.0f; diff_norm_order2 = 5.0f; @@ -1687,6 +1687,7 @@ void ivas_get_spar_md_from_dirac( { float P_norm[3]; int16_t idx; + ndm = hSpar_md_cfg->num_dmx_chans_per_band[start_band - 1]; P_norm[0] = 0.0f; for ( i = 0; i < max( 0, foa_ch - ndm ); i++ ) @@ -1754,7 +1755,7 @@ void ivas_get_spar_md_from_dirac( int16_t num_ch_order, hoa2_ch_order; num_ch_order = ivas_sba_get_nchan( order, 0 ); - hoa2_ch_order = 9; + hoa2_ch_order = ivas_sba_get_nchan( 2, 0 ); for ( ch = 0; ch < num_ch_order; ch++ ) { diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 846ec04778..609239f9cc 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -627,7 +627,7 @@ void ivas_spar_md_dec_process( char f_name[100]; int16_t num_bands = nB; int16_t num_subframes = 1, num_block_groups = 1, num_elements = 1, byte_size = sizeof( float ); - int16_t num_ch = 2 * sba_order + 2; + int16_t num_ch = ivas_sba_get_nchan_metadata( sba_order ); for ( b = 0; b < num_bands; b++ ) { sprintf( f_name, "spar_band_pred_coeffs_dec.bin" ); diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 1fafdbd4e6..b740eb36fc 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -122,7 +122,7 @@ ivas_error ivas_spar_md_enc_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR MD encoder" ); } - num_channels = 2 * sba_order + 2; + num_channels = ivas_sba_get_nchan_metadata( sba_order ); hMdEnc->spar_hoa_md_flag = ivas_sba_get_spar_hoa_md_flag( sba_order, hEncoderConfig->ivas_total_brate ); -- GitLab From be159dcade473b21f76361d4c1ba4a5fcf53fbb8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 2 Nov 2022 11:11:53 +0100 Subject: [PATCH 7/9] replace two identical assignments by one --- lib_dec/ivas_spar_decoder.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 444a14457e..9720f3c16a 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1012,14 +1012,11 @@ void ivas_spar_dec_upmixer( { mvr2r( pPcm_tmp[hSpar->hTdDecorr->num_apd_outputs - 1 - i], output[nchan_internal - 1 - i], output_frame ); } - - hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest; - } - else - { - hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest; } + hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest; + + /*---------------------------------------------------------------------* * Prepare CLDFB buffers *---------------------------------------------------------------------*/ -- GitLab From 487815fe7ae4228641a3242b29701e242cf22b92 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 2 Nov 2022 11:18:28 +0100 Subject: [PATCH 8/9] replace "st_ivas->hDecoderConfig" with "hDecoderConfig" --- lib_dec/ivas_spar_decoder.c | 16 +++++++--------- lib_enc/ivas_spar_encoder.c | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 9720f3c16a..76956c7c07 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -89,8 +89,7 @@ ivas_error ivas_spar_dec_open( } /* MD handle */ - if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, - sba_order_internal ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, num_channels_internal, sba_order_internal ) ) != IVAS_ERR_OK ) { return error; } @@ -1022,7 +1021,7 @@ void ivas_spar_dec_upmixer( *---------------------------------------------------------------------*/ /* set-up pointers */ - if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) + if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) { /* at this point, output channels are used as intermediate procesing buffers */ for ( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS; in_ch++ ) @@ -1063,7 +1062,7 @@ void ivas_spar_dec_upmixer( /* determine if we can skip certain data */ ivas_spar_get_skip_mat( hSpar, numch_out, numch_in, num_spar_bands, b_skip_mat ); /* this can be precomputed based on bitrate and format*/ - numch_out_dirac = st_ivas->hDecoderConfig->nchan_out; + numch_out_dirac = hDecoderConfig->nchan_out; for ( int16_t i_sf = 0; i_sf < MAX_PARAM_SPATIAL_SUBFRAMES; i_sf++ ) { @@ -1084,7 +1083,7 @@ void ivas_spar_dec_upmixer( for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { /* determine SPAR parameters for this time slots */ - ivas_spar_get_parameters( hSpar, st_ivas->hDecoderConfig, ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES, numch_out, numch_in, num_spar_bands, mixer_mat ); + ivas_spar_get_parameters( hSpar, hDecoderConfig, ts + i_sf * MAX_PARAM_SPATIAL_SUBFRAMES, numch_out, numch_in, num_spar_bands, mixer_mat ); for ( cldfb_band = 0; cldfb_band < num_cldfb_bands; cldfb_band++ ) { @@ -1133,9 +1132,9 @@ void ivas_spar_dec_upmixer( } } - if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_FOA + if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA #ifdef SPAR_STEREO_NO_DIRAC - && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO + && hDecoderConfig->output_config != AUDIO_CONFIG_STEREO && hDecoderConfig->output_config != AUDIO_CONFIG_MONO #endif ) { @@ -1162,8 +1161,7 @@ void ivas_spar_dec_upmixer( } else { - if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_FOA || - !( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM ) ) + if ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA || !( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM ) ) { for ( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index eaecc8fe30..acdd88ee73 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -161,11 +161,11 @@ ivas_error ivas_spar_enc_open( if ( st_ivas->nchan_transport == 1 ) { - st_ivas->hEncoderConfig->element_mode_init = IVAS_SCE; + hEncoderConfig->element_mode_init = IVAS_SCE; } else { - st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; + hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; } /*-----------------------------------------------------------------* @@ -297,7 +297,7 @@ ivas_error ivas_spar_enc( hEncoderConfig = st_ivas->hEncoderConfig; /* front VAD */ - if ( ( error = front_vad_spar( st_ivas->hSpar, data_f[0], st_ivas->hEncoderConfig, input_frame ) ) != IVAS_ERR_OK ) + if ( ( error = front_vad_spar( st_ivas->hSpar, data_f[0], hEncoderConfig, input_frame ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 50c4a1ab9618a28890769a2e4373f4aa9dcee6c3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 3 Nov 2022 11:40:23 +0100 Subject: [PATCH 9/9] Introduce SBA order constants: #define SBA_FOA_ORDER 1 #define SBA_HOA2_ORDER 2 #define SBA_HOA3_ORDER 3 --- lib_com/ivas_cnst.h | 5 +++++ lib_com/ivas_rom_com.c | 32 ++++++++++++++++---------------- lib_com/ivas_sba_config.c | 10 +++++----- lib_com/ivas_spar_com.c | 4 ++-- lib_dec/ivas_dirac_dec.c | 6 +++--- lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_output_init.c | 6 +++--- lib_enc/ivas_spar_encoder.c | 2 +- lib_enc/ivas_spar_md_enc.c | 8 ++++---- lib_enc/lib_enc.c | 2 +- 10 files changed, 41 insertions(+), 36 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index dbaf718348..7051caf9a5 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -831,8 +831,13 @@ typedef enum { * SBA Constants *----------------------------------------------------------------------------------*/ +#define SBA_FOA_ORDER 1 +#define SBA_HOA2_ORDER 2 +#define SBA_HOA3_ORDER 3 + #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_rom_com.c b/lib_com/ivas_rom_com.c index 4169e4ee92..c843d5ddc4 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -903,57 +903,57 @@ const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] = { /* When AGC is ON additional (AGC_BITS_PER_CH+1) bits may be taken from each core-coder channel so minimum core-coder bitrate per channel can be min core-coder bitrates as per the table - AGC_BITS_PER_CH */ - { 24400, 0, 1, FB, 24000, 1, WYXZ, 1, 0,{ { 16400, 14850, 24350 } }, + { 24400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0,{ { 16400, 14850, 24350 } }, { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, - { 32000, 0, 1, FB, 24000, 1, WYXZ, 1, 0,{ { 24000, 20450, 31950 } }, + { 32000, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0,{ { 24000, 20450, 31950 } }, { { 21, 1, 5, 1 },{ 15, 1, 5, 1 },{ 15, 1, 3, 1 } }, 0, 0, 0 }, - { 48000, 0, 1, FB, 24000, 2, WYXZ, 0, 0,{ { 24000, 21000, 31950 },{ 16000, 15000, 20400 } }, + { 48000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0,{ { 24000, 21000, 31950 },{ 16000, 15000, 20400 } }, { { 15, 7, 5, 1 },{ 15, 7, 3, 1 },{ 7, 7, 3, 1 } }, 1, 0, 0 }, - { 64000, 0, 1, FB, 24000, 2, WYXZ, 0, 0,{ { 38000, 34050, 56000 },{ 16000, 15600, 20400 } },{ { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 1, 0 }, + { 64000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0,{ { 38000, 34050, 56000 },{ 16000, 15600, 20400 } },{ { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 1, 0 }, - { 80000, 0, 1, FB, 24000, 2, WYXZ, 0, 0,{ { 46000, 43000, 56000 },{ 24000, 23000, 31950 } }, + { 80000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0,{ { 46000, 43000, 56000 },{ 24000, 23000, 31950 } }, { { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 0, 0 }, - { 96000, 0, 1, FB, 24000, 3, WYXZ, 0, 0,{ { 47000, 42600, 56000 },{ 23000, 22600, 31950 },{ 16000, 15600, 20400 } }, + { 96000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 47000, 42600, 56000 },{ 23000, 22600, 31950 },{ 16000, 15600, 20400 } }, { { 21, 9, 9, 1 },{ 21, 7, 5, 1 },{ 21, 7, 5, 1 } }, 1, 0, 0 }, - { 128000, 0, 1, FB, 24000, 3, WYXZ, 0, 0,{ { 55000, 50000, 56000 },{ 36000, 36000, 56000 },{ 27000, 27000, 31950 } }, + { 128000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 55000, 50000, 56000 },{ 36000, 36000, 56000 },{ 27000, 27000, 31950 } }, { { 21, 11, 9, 1 },{ 21, 9, 7, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 }, - { 160000, 0, 1, FB, 24000, 3, WYXZ, 0, 0,{ { 74000, 70900, 112000 },{ 41000, 40050, 56000 },{ 35000, 34050, 56000 } }, + { 160000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 74000, 70900, 112000 },{ 41000, 40050, 56000 },{ 35000, 34050, 56000 } }, { { 21, 11, 11, 1 },{ 21, 9, 9, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 }, - { 192000, 0, 1, FB, 24000, 3, WYXZ, 0, 0,{ { 90000, 87900, 112000 },{ 50000, 48050, 56000 },{ 42000, 41050, 56000 } }, + { 192000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 90000, 87900, 112000 },{ 50000, 48050, 56000 },{ 42000, 41050, 56000 } }, { { 21, 11, 11, 1 },{ 21, 9, 9, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 }, - { 256000, 0, 1, FB, 24000, 4, WYXZ, 0, 0,{ { 90000, 85000, 112000 },{ 70000, 69000, 112000 },{ 50000, 48950, 56000 },{ 36400, 35600, 56000 } }, + { 256000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 90000, 85000, 112000 },{ 70000, 69000, 112000 },{ 50000, 48950, 56000 },{ 36400, 35600, 56000 } }, { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 256000, 0, 2, FB, 24000, 4, WYXZ, 0, 0,{ { 84650, 83000, 112000 },{ 65850, 64550, 56000 },{ 47000, 46100, 48000 },{ 28200, 27650, 40000 } }, + { 256000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 84650, 83000, 112000 },{ 65850, 64550, 56000 },{ 47000, 46100, 48000 },{ 28200, 27650, 40000 } }, { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 256000, 0, 3, FB, 24000, 4, WYXZ, 0, 0,{ { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } }, + { 256000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } }, { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 31, 1, 1, 1 } }, 1, 2, 0 }, { 384000, 0, 1, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 100000, 100000, 128000 },{ 79850, 79850, 104000 },{ 66600, 66600, 104000 } }, // not yet optimized { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 384000, 0, 2, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, // just added as a place holder, not necessarily operational + { 384000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, // just added as a place holder, not necessarily operational { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 384000, 0, 3, FB, 24000, 4, WYXZ, 0, 0,{ { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } }, // just added as a place holder, not necessarily operational + { 384000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } }, // just added as a place holder, not necessarily operational { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, { 512000, 0, 1, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 }, {118450, 118450, 128000 } }, // not yet optimized { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 512000, 0, 2, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 97700, 93300, 128000 } }, // not yet optimized + { 512000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 97700, 93300, 128000 } }, // not yet optimized { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 512000, 0, 3, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 127200, 122550, 128000 },{ 76300, 73550, 128000 } }, // not yet optimized + { 512000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 127200, 122550, 128000 },{ 76300, 73550, 128000 } }, // not yet optimized { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, }; diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 29c0ca6617..d94341c985 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -194,7 +194,7 @@ int16_t ivas_sba_get_analysis_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; + sba_analysis_order = SBA_FOA_ORDER; } return sba_analysis_order; @@ -213,15 +213,15 @@ int16_t ivas_sba_get_order_transport( { int16_t sba_order; - sba_order = 1; + sba_order = SBA_FOA_ORDER; if ( nchan_transport > 6 ) { - sba_order = 3; + sba_order = SBA_HOA3_ORDER; } else if ( nchan_transport > 4 ) { - sba_order = 2; + sba_order = SBA_HOA2_ORDER; } return ( sba_order ); @@ -268,7 +268,7 @@ int16_t ivas_sba_get_nchan_metadata( { int16_t nb_channels; - if ( sba_order == 1 ) + if ( sba_order == SBA_FOA_ORDER ) { nb_channels = FOA_CHANNELS; } diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index ceab9dd42c..e704feb049 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -1668,7 +1668,7 @@ void ivas_get_spar_md_from_dirac( remix_order = remix_order_set[hSpar_md_cfg->remix_unmix_order]; num_ch = ivas_sba_get_nchan_metadata( order ); - hoa2_ch = ivas_sba_get_nchan_metadata( 2 ); + hoa2_ch = ivas_sba_get_nchan_metadata( SBA_HOA2_ORDER ); foa_ch = FOA_CHANNELS; diff_norm_order1 = 3.0f; diff_norm_order2 = 5.0f; @@ -1755,7 +1755,7 @@ void ivas_get_spar_md_from_dirac( int16_t num_ch_order, hoa2_ch_order; num_ch_order = ivas_sba_get_nchan( order, 0 ); - hoa2_ch_order = ivas_sba_get_nchan( 2, 0 ); + hoa2_ch_order = ivas_sba_get_nchan( SBA_HOA2_ORDER, 0 ); for ( ch = 0; ch < num_ch_order; ch++ ) { diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index ec9a712065..d7feb33256 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -234,13 +234,13 @@ ivas_error ivas_dirac_dec_config( if ( hDirAC->hOutSetup.ambisonics_order == -1 ) { - hDirAC->hOutSetup.ambisonics_order = 3; /* Order 3 is used by default in DirAC for SHD processing */ + hDirAC->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; /* Order 3 is used by default in DirAC for SHD processing */ if ( hDirAC->hOutSetup.output_config == AUDIO_CONFIG_MONO || hDirAC->hOutSetup.output_config == AUDIO_CONFIG_STEREO ) { - hDirAC->hOutSetup.ambisonics_order = 1; + hDirAC->hOutSetup.ambisonics_order = SBA_FOA_ORDER; } } - else if ( hDirAC->hOutSetup.ambisonics_order >= 1 ) + else if ( hDirAC->hOutSetup.ambisonics_order >= SBA_FOA_ORDER ) { mvr2r( ls_azimuth_4d4, ls_azimuth, DIRAC_HOA_RENDERING_NUM_VIRT_DECORR_LS ); mvr2r( ls_elevation_4d4, ls_elevation, DIRAC_HOA_RENDERING_NUM_VIRT_DECORR_LS ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 30b96a25c8..9f05b74e34 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -410,7 +410,7 @@ static ivas_error ivas_read_format( // TBD: needs more work for HOA if ( st_ivas->sba_analysis_order == 0 ) { - st_ivas->sba_analysis_order = 1; + st_ivas->sba_analysis_order = SBA_FOA_ORDER; } if ( idx == 1 ) { diff --git a/lib_dec/ivas_output_init.c b/lib_dec/ivas_output_init.c index 3b65756ad6..005db1d4ac 100644 --- a/lib_dec/ivas_output_init.c +++ b/lib_dec/ivas_output_init.c @@ -171,13 +171,13 @@ void ivas_output_init( hOutSetup->ls_elevation = ls_elevation_CICP2; break; case AUDIO_CONFIG_FOA: - hOutSetup->ambisonics_order = 1; + hOutSetup->ambisonics_order = SBA_FOA_ORDER; break; case AUDIO_CONFIG_HOA2: - hOutSetup->ambisonics_order = 2; + hOutSetup->ambisonics_order = SBA_HOA2_ORDER; break; case AUDIO_CONFIG_HOA3: - hOutSetup->ambisonics_order = 3; + hOutSetup->ambisonics_order = SBA_HOA3_ORDER; break; case AUDIO_CONFIG_5_1: hOutSetup->num_lfe = 1; diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index acdd88ee73..00d185fe08 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -684,7 +684,7 @@ static ivas_error ivas_spar_enc_process( } else { - if ( ivas_total_brate == PCA_BRATE && sba_order == 1 ) + if ( ivas_total_brate == PCA_BRATE && sba_order == SBA_FOA_ORDER ) { /* write PCA bypass bit */ push_next_indice( hMetaData, PCA_MODE_INACTIVE, 1 ); diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index b740eb36fc..a3d9daac4e 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -611,7 +611,7 @@ ivas_error ivas_spar_md_enc_process( } } - if ( hEncoderConfig->ivas_total_brate == BRATE_SPAR_Q_STRAT && sba_order == 1 ) + if ( hEncoderConfig->ivas_total_brate == BRATE_SPAR_Q_STRAT && sba_order == SBA_FOA_ORDER ) { /* make sure that qsi is always 0 (temporary bits are '00') */ num_quant_strats = 1; @@ -893,7 +893,7 @@ ivas_error ivas_spar_md_enc_process( write_metadata_buffer( &hMetaData_tmp, hMetaData, bit_pos_start, next_ind_start, last_ind_start ); code_strat = strat; } - if ( hMetaData->nb_bits_tot - bit_pos_start + ( ( ( hEncoderConfig->ivas_total_brate == IVAS_256k ) && ( sba_order == 1 ) ) ? 1 : 0 ) <= hMdEnc->spar_md_cfg.tgt_bits_per_blk ) + if ( hMetaData->nb_bits_tot - bit_pos_start + ( ( ( hEncoderConfig->ivas_total_brate == IVAS_256k ) && ( sba_order == SBA_FOA_ORDER ) ) ? 1 : 0 ) <= hMdEnc->spar_md_cfg.tgt_bits_per_blk ) { packed_ok = 1; break; @@ -906,7 +906,7 @@ ivas_error ivas_spar_md_enc_process( break; } - if ( hMetaData->nb_bits_tot - bit_pos_start + ( ( ( hEncoderConfig->ivas_total_brate == IVAS_256k ) && ( sba_order == 1 ) ) ? 1 : 0 ) <= hMdEnc->spar_md_cfg.max_bits_per_blk ) + if ( hMetaData->nb_bits_tot - bit_pos_start + ( ( ( hEncoderConfig->ivas_total_brate == IVAS_256k ) && ( sba_order == SBA_FOA_ORDER ) ) ? 1 : 0 ) <= hMdEnc->spar_md_cfg.max_bits_per_blk ) { break; } @@ -1084,7 +1084,7 @@ ivas_error ivas_spar_md_enc_process( } #endif #ifdef DEBUG_SPAR_MD_TARGET_TUNING - int16_t md_bits = hMetaData->nb_bits_tot - bit_pos_start + ( ( ( hEncoderConfig->ivas_total_brate == IVAS_256k ) && ( sba_order == 1 ) ) ? 1 : 0 ); + int16_t md_bits = hMetaData->nb_bits_tot - bit_pos_start + ( ( ( hEncoderConfig->ivas_total_brate == IVAS_256k ) && ( sba_order == SBA_FOA_ORDER ) ) ? 1 : 0 ); FILE *fp = fopen( "spar_md_bitrate.txt", "a" ); fprintf( fp, "%d\t %d \t %d\n", md_bits, qsi, code_strat ); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index e25afc9fd8..61ad0586f2 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -901,7 +901,7 @@ static ivas_error configureEncoder( #endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ - if ( hEncoderConfig->Opt_PCA_ON && !( hEncoderConfig->ivas_format == SBA_FORMAT && hEncoderConfig->ivas_total_brate == PCA_BRATE && hEncoderConfig->sba_order == 1 ) ) + if ( hEncoderConfig->Opt_PCA_ON && !( hEncoderConfig->ivas_format == SBA_FORMAT && hEncoderConfig->ivas_total_brate == PCA_BRATE && hEncoderConfig->sba_order == SBA_FOA_ORDER ) ) { return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "PCA supported at SBA FOA 256 kbps only." ); } -- GitLab