diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 1e36dbb5356f410db142417f730da72d32bbdb07..3a45884a07c154a14c744fc2d39fab76ee9e3ccd 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -1975,19 +1975,22 @@ ivas_error preview_indices( } else if ( st_ivas->ivas_format == SBA_FORMAT ) { +#ifndef ORDER_BITS_ADDITION if ( ( st_ivas->sba_mode != SBA_MODE_SPAR ) || ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && ( total_brate >= IVAS_256k ) ) ) { +#endif /* Read SBA planar flag and SBA order */ st_ivas->sba_planar = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA] == 1 ); 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 ); +#ifndef ORDER_BITS_ADDITION } else { st_ivas->sba_planar = 0; st_ivas->sba_order = 1; } - +#endif ivas_sba_config( total_brate, st_ivas->sba_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 ); } } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index a3da7466ca74b87d3b0400f22c3ce361be3b30f0..5f71528a197a20b6ca6bb18d46068c0be1cd8cff 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2586,8 +2586,11 @@ void ivas_mct_core_enc( const int16_t nChannels, /* i : number of channels to be coded */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t switch_bw, /* i : flag bandwidth switch occurance */ - const int16_t lfe_bits, /* i : bits spent for LFE */ + const int16_t lfe_bits /* i : bits spent for LFE */ +#ifndef ORDER_BITS_ADDITION + , const SBA_MODE sba_mode /* i : SBA mode */ +#endif #ifdef FIX_I1_113 , const int16_t sba_order diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index b6a4f15889c9718e0e347520f29ce2119856a169..28d8b93a97bd4e8abc066b96b387001feedb0840 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -903,7 +903,12 @@ 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 EVS channel so minimum EVS bitrate per channel can be min EVS bitrates as per the table - AGC_BITS_PER_CH */ - { 24400, 0, 1, FB, 24000, 1, WYXZ, 1, 0,{ { 16400, 15200, 24350 } }, + { 24400, 0, 1, FB, 24000, 1, WYXZ, 1, 0, +#ifndef ORDER_BITS_ADDITION + { { 16400, 15200, 24350 } }, +#else + { { 16400, 14850, 24350 } }, +#endif { { 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 }},{ { 21, 1, 5, 1 },{ 15, 1, 5, 1 },{ 15, 1, 3, 1 } }, 0, 0, 0 }, diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index 88f39f713b3c6d0aa82e616166fa7ff3b2c93f44..ac941e6ec363bba43c7d7c1f655d8cb82d0452e4 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -2148,13 +2148,14 @@ void ivas_spar_set_bitrate_config( total_bits += ( int16_t )( ivas_spar_br_table_consts[table_idx].evs_brs[i][0] / FRAMES_PER_SEC ); max_bits += ( int16_t )( ivas_spar_br_table_consts[table_idx].evs_brs[i][1] / FRAMES_PER_SEC ); } +#ifndef ORDER_BITS_ADDITION if ( ivas_total_brate >= IVAS_256k ) { - 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; +#endif + 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; + 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; - // TODO : do this for lower bitrates as well once order/planar bits are added 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; @@ -2164,17 +2165,18 @@ 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; +#ifndef ORDER_BITS_ADDITION } else { - pSpar_md_cfg->tgt_bits_per_blk = ( int16_t )( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - length - total_bits; + pSpar_md_cfg->tgt_bits_per_blk = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - length - total_bits; - pSpar_md_cfg->max_bits_per_blk = ( int16_t )( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - length - max_bits; + pSpar_md_cfg->max_bits_per_blk = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - length - max_bits; pSpar_md_cfg->tgt_bits_per_blk = (int16_t) ceilf( ( 1.0f * pSpar_md_cfg->tgt_bits_per_blk * num_bands ) / IVAS_MAX_NUM_BANDS ); pSpar_md_cfg->max_bits_per_blk = (int16_t) ceilf( ( 1.0f * pSpar_md_cfg->max_bits_per_blk * num_bands ) / IVAS_MAX_NUM_BANDS ); } - +#endif return; } diff --git a/lib_com/options.h b/lib_com/options.h index 3ce2968c0203337401a226c47be53f49f6981018..37e5b758c02019357016899e2c90f22b088554b8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -151,6 +151,8 @@ #define SIMPLIFY_SBA_RENDERING_LOGIC /* SBA rendering maintenance related to ticket #45 */ #define SBA_CLEANING /* SBA maintenance related to ticket #45 */ +#define ORDER_BITS_ADDITION /* Adding order and planar bits to more spar bitrates */ + #define DIRAC_DRCT_GAIN_TUNING #define FIX_34 /* Nokia: Fix bug in MASA format EXT output spherical indexing */ #define FIX_I68_MC_REVERB_FOR_514 /* Fix HRTF processing for Jot reverb in case of 5.1.4 input format */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index fcacf77e9bdd4e6f8622e4a79decd433b052bb22..827223620c205752de585f018ec30990415b46bd 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -114,8 +114,10 @@ ivas_error ivas_dec_setup( } else if ( st_ivas->ivas_format == SBA_FORMAT ) { +#ifndef ORDER_BITS_ADDITION if ( st_ivas->sba_mode == SBA_MODE_DIRAC || ivas_total_brate >= IVAS_256k ) { +#endif /* read Ambisonic (SBA) planar flag */ st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read]; num_bits_read += SBA_PLANAR_BITS; @@ -124,13 +126,14 @@ 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]; num_bits_read += SBA_ORDER_BITS; +#ifndef ORDER_BITS_ADDITION } else { st_ivas->sba_planar = 0; st_ivas->sba_order = 1; } - +#endif if ( st_ivas->ini_frame > 0 && ( ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) && ( ivas_total_brate > IVAS_SID_4k4 ) ) { if ( ( error = ivas_sba_dec_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 5003dbec9df18ee2cf731ffb5b6b7470dbf2249c..83178316482bfd1dd69db81d109b60457aafaf41 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -196,9 +196,10 @@ ivas_error ivas_enc( return error; } } - +#ifndef ORDER_BITS_ADDITION if ( !( st_ivas->sba_mode == SBA_MODE_SPAR && ivas_total_brate < IVAS_256k ) ) { +#endif st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; /* Write SBA planar flag */ @@ -206,7 +207,9 @@ ivas_error ivas_enc( /* Write SBA order */ push_indice( st->hBstr, IND_SMODE, hEncoderConfig->sba_order, SBA_ORDER_BITS ); +#ifndef ORDER_BITS_ADDITION } +#endif } else { diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index de513c770e28b56819fa4b27e1e41803fe66e9c5..95290dfe9d90dd357241597b5b514b2f2707e570 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -200,8 +200,11 @@ void ivas_mct_core_enc( const int16_t nChannels, /* i : number of channels to be coded */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t switch_bw, /* i : flag bandwidth switch occurance */ - const int16_t lfe_bits, /* i : bits spent for LFE */ + const int16_t lfe_bits /* i : bits spent for LFE */ +#ifndef ORDER_BITS_ADDITION + , const SBA_MODE sba_mode /* i : SBA mode */ +#endif #ifdef FIX_I1_113 , const int16_t sba_order @@ -491,10 +494,14 @@ void ivas_mct_core_enc( else if ( ivas_format == SBA_FORMAT ) { nAvailBits -= IVAS_FORMAT_SIGNALING_NBITS_SBA; +#ifndef ORDER_BITS_ADDITION if ( sba_mode != SBA_MODE_SPAR || ivas_total_brate >= IVAS_256k ) { +#endif nAvailBits -= SBA_ORDER_BITS + SBA_PLANAR_BITS; +#ifndef ORDER_BITS_ADDITION } +#endif } for ( cpe_id = 0, i = 0; cpe_id < nCPE; cpe_id++ ) @@ -572,15 +579,18 @@ void ivas_mct_core_enc( } #ifdef DEBUGGING +#ifndef ORDER_BITS_ADDITION if ( ivas_format == SBA_FORMAT && sba_mode == SBA_MODE_SPAR && ivas_total_brate < IVAS_256k ) { format_bits = IVAS_FORMAT_SIGNALING_NBITS_SBA; } else { +#endif format_bits = ( ivas_format == MC_FORMAT ? IVAS_FORMAT_SIGNALING_NBITS + MC_LS_SETUP_BITS : IVAS_FORMAT_SIGNALING_NBITS_SBA + SBA_ORDER_BITS + SBA_PLANAR_BITS ); +#ifndef ORDER_BITS_ADDITION } - +#endif mct_bits += hMCT->nBitsMCT + ( hMCT->num_lfe ? 1 : 0 ) + hMCT->nchan_out_woLFE; assert( ( total_brate + ( NBITS_BWIDTH + format_bits + mct_bits + sba_meta + lfe_bits ) * FRAMES_PER_SEC ) == ivas_total_brate ); #endif diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 85c3ed0afcf3651dd918bb125c642f533c324d09..7e7bc0e0fc9784a9b4b098374a67eb1f9ef652de 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -127,7 +127,11 @@ ivas_error ivas_mct_enc( /* joint MCT encoding */ ivas_mct_core_enc( ivas_format, hMCT, st_ivas->hCPE, hMCT->nchan_out_woLFE + hMCT->num_lfe, ivas_total_brate, switch_bw, - ivas_format == MC_FORMAT ? (int16_t) st_ivas->hLFE->lfe_bits : 0, st_ivas->sba_mode + ivas_format == MC_FORMAT ? (int16_t) st_ivas->hLFE->lfe_bits : 0 +#ifndef ORDER_BITS_ADDITION + , + st_ivas->sba_mode +#endif #ifdef FIX_I1_113 , st_ivas->hEncoderConfig->sba_order diff --git a/scripts/ivas_pytests/tests/system_tests/test_spar_foa_bs_dec_plc.py b/scripts/ivas_pytests/tests/system_tests/test_spar_foa_bs_dec_plc.py index 7b9a2b245d3790ebaaf4d10e08faf000bbe36db2..fa17fd1d802ddec3e6bb05251fc5b12b3686679d 100644 --- a/scripts/ivas_pytests/tests/system_tests/test_spar_foa_bs_dec_plc.py +++ b/scripts/ivas_pytests/tests/system_tests/test_spar_foa_bs_dec_plc.py @@ -127,6 +127,7 @@ def spar_foa_dec_plc( plc_file = f"{test_vector_path}/{plc_pattern}.g192" ref_in_pkt = f"{reference_path}/spar_foa_bs/pkt/{tag_out}.pkt" + ref_in_pkt_dutenc = f"{reference_path}/spar_foa_bs/pkt/{tag_out}_dutenc.pkt" if ref_decoder_path: ref_decoder = DecoderFrontend(ref_decoder_path, "REF") @@ -148,7 +149,7 @@ def spar_foa_dec_plc( decoder_frontend.run( "FOA", sampling_rate, - ref_in_pkt, + ref_in_pkt_dutenc, f"{dut_out_dir}/out.raw", plc_file=plc_file, ) diff --git a/scripts/ivas_pytests/tests/system_tests/test_spar_foa_bs_enc.py b/scripts/ivas_pytests/tests/system_tests/test_spar_foa_bs_enc.py index 25bcfe7f3be2243b572bc7a7f4c16517537ca7bb..d8ed5ac83f8665082575eaf1a31076f67fc959db 100644 --- a/scripts/ivas_pytests/tests/system_tests/test_spar_foa_bs_enc.py +++ b/scripts/ivas_pytests/tests/system_tests/test_spar_foa_bs_enc.py @@ -191,7 +191,8 @@ def test_spar_foa_enc_system( agc, sba_order, update_ref, - cut_gain=cut_gain + cut_gain=cut_gain, + create_dutenc=True ) # dec @@ -418,7 +419,8 @@ def spar_foa_enc( sba_order, update_ref, in_extension = '.pcm', - cut_gain = '1.0' + cut_gain = '1.0', + create_dutenc = False ): ######### run cmd ##################################### @@ -446,6 +448,7 @@ def spar_foa_enc( long_tag_ext = f"_AGC{agc}_pca{bypass}" dut_pkt_file = f"{dut_out_dir}/{tag_out}{long_tag_ext}.pkt" ref_pkt_file = f"{ref_out_dir}/{tag_out}{short_tag_ext}.pkt" + ref_pkt_file_dutenc = f"{ref_out_dir}/{tag_out}{short_tag_ext}_dutenc.pkt" input_path = f"{test_vector_path}/{tag_in}{in_extension}" agc_op = agc if agc >= 0 else None @@ -480,6 +483,19 @@ def spar_foa_enc( bypass_mode=bypass_mode, dtx_mode=dtx_mode, ) + if create_dutenc: + # for PLC decoder tests, create bitstream using DUT encoder + encoder_frontend.run( + ivas_br, + sampling_rate, + input_path, + ref_pkt_file_dutenc, + sba_order=sba_order, + max_band=ivas_max_bw, + agc_op=agc_op, + bypass_mode=bypass_mode, + dtx_mode=dtx_mode, + ) if update_ref == 0: # call DUT encoder