From 98486f6c11dba1167895bc77cee2f53926717d34 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 1 May 2024 16:42:25 +1000 Subject: [PATCH 01/13] bit exact: ext vs hoa3 --- lib_dec/ivas_init_dec.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 34e876b22a..57eae09612 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1148,6 +1148,28 @@ ivas_error ivas_init_decoder( { hDecoderConfig->nchan_out = st_ivas->nchan_transport + st_ivas->nchan_ism; } + else if (st_ivas->ivas_format == SBA_FORMAT) + { + printf("%s::%s:%d\n", __FILE__, __func__, __LINE__); + switch (st_ivas->sba_order) + { + case SBA_FOA_ORDER: + hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_FOA; + break; + case SBA_HOA2_ORDER: + hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_HOA2; + break; + case SBA_HOA3_ORDER: + hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_HOA3; + break; + default: + fprintf(stderr, "Unsupported SBA order %d\n", st_ivas->sba_order); + return IVAS_ERR_WRONG_PARAMS; // jhuo: correct error code? + break; + } + hDecoderConfig->nchan_out = audioCfg2channels(hDecoderConfig->output_config); + return ivas_init_decoder(st_ivas); + } else if ( !( st_ivas->ism_mode == ISM_MODE_PARAM ) ) { hDecoderConfig->nchan_out = st_ivas->nchan_transport; -- GitLab From e095169f1aa13192685220644f07a02fcf284748 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 1 May 2024 16:43:11 +1000 Subject: [PATCH 02/13] remove printf --- lib_dec/ivas_init_dec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 57eae09612..1480d1f4be 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1150,7 +1150,6 @@ ivas_error ivas_init_decoder( } else if (st_ivas->ivas_format == SBA_FORMAT) { - printf("%s::%s:%d\n", __FILE__, __func__, __LINE__); switch (st_ivas->sba_order) { case SBA_FOA_ORDER: -- GitLab From 7e712ec0b39cf623cb39aecec396455ba026f649 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Thu, 2 May 2024 10:05:16 +1000 Subject: [PATCH 03/13] modified to support bitrate switching;\n#define NONBE_FIX_1052_SBA_EXT in options.h --- lib_com/options.h | 2 ++ lib_dec/ivas_init_dec.c | 43 +++++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 43cb02520e..4b0dd56ec4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,6 +171,8 @@ #define NONBE_FIX_SBA_SIGNALING_BITS_B /* FhG: issue 1061: option B: signal sba order additionally in OSBA */ +#define NONBE_FIX_1052_SBA_EXT /* Dlb: SBA external output support */ + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 1480d1f4be..ea7f81936d 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -327,6 +327,28 @@ ivas_error ivas_dec_setup( /* read Ambisonic (SBA) order */ st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; +#ifdef NONBE_FIX_1052_SBA_EXT + if (st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL) + { + switch (st_ivas->sba_order) + { + case SBA_FOA_ORDER: + st_ivas->hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_FOA; + break; + case SBA_HOA2_ORDER: + st_ivas->hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_HOA2; + break; + case SBA_HOA3_ORDER: + st_ivas->hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_HOA3; + break; + default: + fprintf(stderr, "Unsupported SBA order %d\n", st_ivas->sba_order); + return IVAS_ERR_WRONG_PARAMS; + break; + } + st_ivas->hDecoderConfig->nchan_out = audioCfg2channels(st_ivas->hDecoderConfig->output_config); + } +#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 ) @@ -1148,27 +1170,6 @@ ivas_error ivas_init_decoder( { hDecoderConfig->nchan_out = st_ivas->nchan_transport + st_ivas->nchan_ism; } - else if (st_ivas->ivas_format == SBA_FORMAT) - { - switch (st_ivas->sba_order) - { - case SBA_FOA_ORDER: - hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_FOA; - break; - case SBA_HOA2_ORDER: - hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_HOA2; - break; - case SBA_HOA3_ORDER: - hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_HOA3; - break; - default: - fprintf(stderr, "Unsupported SBA order %d\n", st_ivas->sba_order); - return IVAS_ERR_WRONG_PARAMS; // jhuo: correct error code? - break; - } - hDecoderConfig->nchan_out = audioCfg2channels(hDecoderConfig->output_config); - return ivas_init_decoder(st_ivas); - } else if ( !( st_ivas->ism_mode == ISM_MODE_PARAM ) ) { hDecoderConfig->nchan_out = st_ivas->nchan_transport; -- GitLab From 45d3dfa44faa031b47541693a80d671055202b63 Mon Sep 17 00:00:00 2001 From: rtyag Date: Fri, 3 May 2024 18:43:08 +1000 Subject: [PATCH 04/13] adding planar and order bits to SID frame in SBA --- lib_dec/ivas_dirac_dec.c | 4 +++ lib_dec/ivas_init_dec.c | 65 ++++++++++++++++++++++++++---------- lib_dec/ivas_qmetadata_dec.c | 4 +++ lib_dec/ivas_spar_decoder.c | 8 +++++ lib_enc/ivas_cpe_enc.c | 10 ++++++ lib_enc/ivas_qmetadata_enc.c | 8 +++++ lib_enc/ivas_sce_enc.c | 10 ++++++ 7 files changed, 91 insertions(+), 18 deletions(-) diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 29d8cdb855..2bcf5b92f9 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1082,7 +1082,11 @@ 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 ea7f81936d..33f6932ffc 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -59,6 +59,10 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_r static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); +#ifdef NONBE_FIX_1052_SBA_EXT +static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ); +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); @@ -240,6 +244,28 @@ static ivas_error ivas_dec_init_split_rend( } #endif +#ifdef NONBE_FIX_1052_SBA_EXT +static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ) +{ + AUDIO_CONFIG output_config; + output_config = IVAS_AUDIO_CONFIG_HOA3; + switch ( sba_order ) + { + case SBA_FOA_ORDER: + output_config = IVAS_AUDIO_CONFIG_FOA; + break; + case SBA_HOA2_ORDER: + output_config = IVAS_AUDIO_CONFIG_HOA2; + break; + case SBA_HOA3_ORDER: + output_config = IVAS_AUDIO_CONFIG_HOA3; + break; + default: + assert( 0 ); + } + return output_config; +} +#endif /*-------------------------------------------------------------------* * ivas_dec_setup() @@ -328,25 +354,10 @@ 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]; #ifdef NONBE_FIX_1052_SBA_EXT - if (st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { - switch (st_ivas->sba_order) - { - case SBA_FOA_ORDER: - st_ivas->hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_FOA; - break; - case SBA_HOA2_ORDER: - st_ivas->hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_HOA2; - break; - case SBA_HOA3_ORDER: - st_ivas->hDecoderConfig->output_config = IVAS_AUDIO_CONFIG_HOA3; - break; - default: - fprintf(stderr, "Unsupported SBA order %d\n", st_ivas->sba_order); - return IVAS_ERR_WRONG_PARAMS; - break; - } - st_ivas->hDecoderConfig->nchan_out = audioCfg2channels(st_ivas->hDecoderConfig->output_config); + st_ivas->hDecoderConfig->output_config = ivas_set_output_config_from_sba_order( st_ivas->sba_order ); + st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config ); } #endif @@ -619,6 +630,14 @@ ivas_error ivas_dec_setup( break; } +#ifdef NONBE_FIX_1052_SBA_EXT + if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + st_ivas->hDecoderConfig->output_config = ivas_set_output_config_from_sba_order( st_ivas->sba_order ); + st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config ); + } +#endif + if ( st_ivas->ini_frame > 0 && st_ivas->ivas_format == SBA_FORMAT ) { int16_t nchan_transport_old, nchan_transport; @@ -895,6 +914,16 @@ static ivas_error ivas_read_format( if ( st_ivas->ivas_format == SBA_FORMAT ) { +#ifdef NONBE_FIX_1052_SBA_EXT + /* read Ambisonic (SBA) planar flag */ + st_ivas->sba_planar = st_ivas->bit_stream[*num_bits_read]; + *num_bits_read += SBA_PLANAR_BITS; + + /* read Ambisonic (SBA) order */ + st_ivas->sba_order = st_ivas->bit_stream[*num_bits_read + 1]; + st_ivas->sba_order += 2 * st_ivas->bit_stream[*num_bits_read]; + *num_bits_read += SBA_ORDER_BITS; +#endif if ( st_ivas->sba_analysis_order == 0 ) { st_ivas->sba_analysis_order = SBA_FOA_ORDER; diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index bc895de45c..259659ffbf 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -1221,7 +1221,11 @@ int16_t ivas_qmetadata_dec_sid_decode( if ( ivas_format == SBA_FORMAT ) { +#ifdef NONBE_FIX_1052_SBA_EXT + metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - SID_FORMAT_NBITS - SBA_ORDER_BITS - SBA_PLANAR_BITS - 1; /* -1 for inactive mode header bit*/ +#else metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - 2 - SID_FORMAT_NBITS; /* -1 for inactive mode header bit*/ +#endif } else { diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 2e0f4ae0eb..1e8fafd649 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -368,7 +368,11 @@ ivas_error ivas_spar_dec( if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 ) { +#ifdef NONBE_FIX_1052_SBA_EXT + last_bit_pos -= SID_FORMAT_NBITS - SBA_PLANAR_BITS - SBA_ORDER_BITS; +#else last_bit_pos -= SID_FORMAT_NBITS; +#endif } nb_bits_read_orig = *nb_bits_read; last_bit_pos -= nb_bits_read_orig; @@ -403,7 +407,11 @@ ivas_error ivas_spar_dec( if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 ) { int16_t zero_pad_bits; +#ifdef NONBE_FIX_1052_SBA_EXT + *nb_bits_read += SID_FORMAT_NBITS + SBA_PLANAR_BITS + SBA_ORDER_BITS; +#else *nb_bits_read += SID_FORMAT_NBITS; +#endif zero_pad_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - *nb_bits_read; assert( zero_pad_bits <= 1 ); *nb_bits_read += zero_pad_bits; diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index f971fcbe67..3fdf6e9f5e 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -600,6 +600,16 @@ ivas_error ivas_cpe_enc( if ( sts[0]->core_brate == SID_2k40 ) { ivas_write_format_sid( ivas_format, hCPE->element_mode, sts[0]->hBstr ); +#ifdef NONBE_FIX_1052_SBA_EXT + if ( ivas_format == SBA_FORMAT ) + { + /* Write SBA planar flag */ + push_indice( sts[0]->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); + + /* Write SBA order */ + push_indice( sts[0]->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_order, SBA_ORDER_BITS ); + } +#endif } /*----------------------------------------------------------------* diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index a875f14771..95e43097be 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -971,7 +971,11 @@ void ivas_qmetadata_enc_sid_encode( if ( ivas_format == SBA_FORMAT ) { +#ifdef NONBE_FIX_1052_SBA_EXT + metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - SID_FORMAT_NBITS - SBA_ORDER_BITS - SBA_PLANAR_BITS - 1; /* -1 for inactive mode header bit*/ +#else metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - 2 - SID_FORMAT_NBITS; /* -1 for inactive mode header bit*/ +#endif } else { @@ -1250,7 +1254,11 @@ void reset_metadata_spatial( assert( hMetaData->ind_list[0].nb_bits == 1 ); #endif hMetaData->ind_list[0].value = 1; +#ifdef NONBE_FIX_1052_SBA_EXT + metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS - SBA_PLANAR_BITS - SBA_ORDER_BITS; +#else metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; +#endif while ( hMetaData->nb_bits_tot < metadata_sid_bits ) { diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index 215b977f25..b831961811 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -224,6 +224,16 @@ ivas_error ivas_sce_enc( if ( st->core_brate == SID_2k40 ) { ivas_write_format_sid( ivas_format, IVAS_SCE, st->hBstr ); +#ifdef NONBE_FIX_1052_SBA_EXT + if ( ivas_format == SBA_FORMAT ) + { + /* Write SBA planar flag */ + push_indice( st->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); + + /* Write SBA order */ + push_indice( st->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_order, SBA_ORDER_BITS ); + } +#endif } /*----------------------------------------------------------------* -- GitLab From ebba4b0e745d0c841059545585faacbac9f79dca Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 7 May 2024 15:04:42 +1000 Subject: [PATCH 05/13] keep dirac SID bits same when num TC is 2 --- lib_com/ivas_prot.h | 20 ++++++++++++++++++-- lib_com/ivas_sba_config.c | 23 +++++++++++++++++++++++ lib_dec/ivas_dirac_dec.c | 14 +++++++++++++- lib_dec/ivas_qmetadata_dec.c | 6 +++++- lib_dec/ivas_spar_decoder.c | 4 ++++ lib_dec/ivas_spar_md_dec.c | 8 ++++++++ lib_enc/ivas_dirac_enc.c | 9 ++++++++- lib_enc/ivas_masa_enc.c | 4 ++++ lib_enc/ivas_qmetadata_enc.c | 11 +++++++++-- lib_enc/ivas_spar_encoder.c | 8 ++++++++ lib_enc/ivas_spar_md_enc.c | 8 ++++++++ 11 files changed, 108 insertions(+), 7 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 202ccf3dd9..ca418380e4 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3207,7 +3207,10 @@ void ivas_qmetadata_enc_sid_encode( BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ IVAS_QMETADATA *q_metadata, /* i/o: metadata handle */ const int16_t masa_sid_descriptor, /* i : description of MASA SID coding structure*/ - const int16_t ivas_format /* i : ivas format */ +#ifdef NONBE_FIX_1052_SBA_EXT + const int16_t nchan_transport, /* i : number of transport channels */ +#endif + const int16_t ivas_format /* i : ivas format */ ); /*! r: number of bits read */ @@ -3515,6 +3518,13 @@ int16_t ivas_sba_get_nchan_metadata( const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); +#ifdef NONBE_FIX_1052_SBA_EXT +/*! r: number of bits in SPAR SID frame */ +int16_t ivas_sba_spar_sid_bitlen( + const int16_t nchan_transport /* i : number of transport channels */ +); +#endif + void ivas_sba_get_spar_hoa_ch_ind( const int16_t num_md_chs, /* i : number of MD channels */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ @@ -3616,7 +3626,10 @@ ivas_error ivas_dirac_enc( const int16_t input_frame, /* i : input frame length */ const int16_t dtx_vad, /* i : DTX vad flag */ const IVAS_FORMAT ivas_format, /* i : ivas format */ - const int16_t hodirac_flag /* i : hodirac flag */ +#ifdef NONBE_FIX_1052_SBA_EXT + const int16_t nchan_transport, /* i : number of transport channels */ +#endif + const int16_t hodirac_flag /* i : hodirac flag */ ); ivas_error ivas_dirac_config( @@ -3671,6 +3684,9 @@ void ivas_dirac_dec_read_BS( int16_t *nb_bits, /* o : number of bits read */ const int16_t last_bit_pos, /* i : last read bitstream position */ const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ + #ifdef NONBE_FIX_1052_SBA_EXT + const int16_t nchan_transport, /* i : number of transport channels */ +#endif int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ); diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index cb573d7f28..a622d8f88f 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -158,6 +158,29 @@ int16_t ivas_sba_get_nchan( return ( nb_channels ); } +#ifdef NONBE_FIX_1052_SBA_EXT +/*-------------------------------------------------------------------* + * ivas_sba_spar_sid_bitlen() + * + * Get number of bits in SPAR SID frame + *-------------------------------------------------------------------*/ + +/*! r: number of bits in SPAR SID frame */ +int16_t ivas_sba_spar_sid_bitlen( + const int16_t nchan_transport /* i : number of transport channels */ +) +{ + int16_t num_bits; + + num_bits = SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND; + if ( nchan_transport > 1 ) + { + num_bits -= 2; + } + + return num_bits; +} +#endif /*-------------------------------------------------------------------* * ivas_sba_get_nchan_metadata() diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index 2bcf5b92f9..43713ffc45 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1001,7 +1001,10 @@ void ivas_dirac_dec_read_BS( int16_t *nb_bits, /* o : number of bits read */ const int16_t last_bit_pos, /* i : last read bitstream position */ const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ +#ifdef NONBE_FIX_1052_SBA_EXT + const int16_t nchan_transport, /* i : number of transport channels */ +#endif + int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) { int16_t i, j, b, dir, orig_dirac_bands; @@ -1034,7 +1037,12 @@ void ivas_dirac_dec_read_BS( } } +#ifdef NONBE_FIX_1052_SBA_EXT + *nb_bits += ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), nchan_transport, NULL, SBA_FORMAT ); +#else *nb_bits += ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), 0, NULL, SBA_FORMAT ); +#endif + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth[i] = hQMetaData->q_direction[0].band_data[1].azimuth[0]; @@ -1106,7 +1114,11 @@ void ivas_dirac_dec_read_BS( } } +#ifdef NONBE_FIX_1052_SBA_EXT + *nb_bits += ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), nchan_transport, NULL, SBA_FORMAT ); +#else *nb_bits += ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), 0, NULL, SBA_FORMAT ); +#endif for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth[i] = hQMetaData->q_direction[0].band_data[1].azimuth[0]; diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 259659ffbf..dd3316daae 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -1203,6 +1203,9 @@ int16_t ivas_qmetadata_dec_sid_decode( float direction_vector[3]; int16_t metadata_sid_bits; /* bits allocated to SID for metadata */ int16_t bits_delta, bits_dir; +#ifdef NONBE_FIX_1052_SBA_EXT + int16_t sba_spar_bitlen; +#endif #ifdef DEBUG_MODE_QMETADATA static FILE *pF = NULL; static FILE *pF_azi = NULL; @@ -1222,7 +1225,8 @@ int16_t ivas_qmetadata_dec_sid_decode( if ( ivas_format == SBA_FORMAT ) { #ifdef NONBE_FIX_1052_SBA_EXT - metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - SID_FORMAT_NBITS - SBA_ORDER_BITS - SBA_PLANAR_BITS - 1; /* -1 for inactive mode header bit*/ + sba_spar_bitlen = ivas_sba_spar_sid_bitlen( nchan_transport ); + metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - sba_spar_bitlen - SID_FORMAT_NBITS - SBA_ORDER_BITS - SBA_PLANAR_BITS - 1; /* -1 for inactive mode header bit*/ #else metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - 2 - SID_FORMAT_NBITS; /* -1 for inactive mode header bit*/ #endif diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 1e8fafd649..b2a3c0ccf1 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -354,7 +354,11 @@ ivas_error ivas_spar_dec( /* read DirAC bitstream */ if ( st_ivas->hQMetaData != NULL ) { +#ifdef NONBE_FIX_1052_SBA_EXT + ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hSpatParamRendCom, st_ivas->hQMetaData, nb_bits_read, last_bit_pos, ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->nchan_transport, st_ivas->hSpar->dirac_to_spar_md_bands ); +#else ivas_dirac_dec_read_BS( hDecoderConfig->ivas_total_brate, st0, st_ivas->hDirAC, st_ivas->hSpatParamRendCom, st_ivas->hQMetaData, nb_bits_read, last_bit_pos, ivas_get_hodirac_flag( hDecoderConfig->ivas_total_brate, st_ivas->sba_analysis_order ), st_ivas->hSpar->dirac_to_spar_md_bands ); +#endif } if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 5e312dadb5..02f3ead632 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -2385,6 +2385,9 @@ static void ivas_parse_parameter_bitstream_dtx( float pr_min_max[2]; int16_t pr_q_lvls, pr, pd, pd_q_lvls, pr_pd_bits; int16_t zero_pad_bits, sid_bits_len; +#ifdef NONBE_FIX_1052_SBA_EXT + int16_t sba_spar_bitlen; +#endif sid_bits_len = st0->next_bit_pos; pr_min_max[0] = pSpar_md->min_max[0]; @@ -2443,7 +2446,12 @@ static void ivas_parse_parameter_bitstream_dtx( } sid_bits_len = st0->next_bit_pos - sid_bits_len; +#ifdef NONBE_FIX_1052_SBA_EXT + sba_spar_bitlen = ivas_sba_spar_sid_bitlen( num_dmx_per_band[0] ); + zero_pad_bits = sba_spar_bitlen - sid_bits_len; +#else zero_pad_bits = ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - sid_bits_len; +#endif assert( zero_pad_bits >= 0 ); if ( num_dmx_per_band[0] == 2 ) { diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 3146d8ad9b..cd4dbe6438 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -291,7 +291,10 @@ ivas_error ivas_dirac_enc( const int16_t input_frame, /* i : input frame length */ const int16_t dtx_vad, /* i : DTX vad flag */ const IVAS_FORMAT ivas_format, /* i : ivas format */ - const int16_t hodirac_flag /* i : hodirac flag */ +#ifdef NONBE_FIX_1052_SBA_EXT + const int16_t nchan_transport, /* i : number of transport channels */ +#endif + const int16_t hodirac_flag /* i : hodirac flag */ ) { int16_t orig_dirac_bands; @@ -367,7 +370,11 @@ ivas_error ivas_dirac_enc( push_next_indice( hMetaData, 1, 1 ); /* encode SID parameters */ +#ifdef NONBE_FIX_1052_SBA_EXT + ivas_qmetadata_enc_sid_encode( hMetaData, hQMetaData, -1, nchan_transport, SBA_FORMAT ); +#else ivas_qmetadata_enc_sid_encode( hMetaData, hQMetaData, -1, SBA_FORMAT ); +#endif } for ( b = hQMetaData->q_direction->cfg.start_band; b < hQMetaData->q_direction->cfg.nbands; b++ ) diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index e4b536dbee..cbca7dee0e 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -596,7 +596,11 @@ ivas_error ivas_masa_encode( free( h_orig_metadata ); +#ifdef NONBE_FIX_1052_SBA_EXT + ivas_qmetadata_enc_sid_encode( hMetaData, hQMetaData, masa_sid_descriptor, 0, ivas_format ); +#else ivas_qmetadata_enc_sid_encode( hMetaData, hQMetaData, masa_sid_descriptor, ivas_format ); +#endif /* restore old values */ hMasa->config.numCodingBands = numCodingBands; diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index 95e43097be..dc4806ed19 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -955,7 +955,10 @@ void ivas_qmetadata_enc_sid_encode( BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ IVAS_QMETADATA *q_metadata, /* i/o: metadata handle */ const int16_t masa_sid_descriptor, /* i : description of MASA SID coding structure */ - const int16_t ivas_format /* i : IVAS format */ +#ifdef NONBE_FIX_1052_SBA_EXT + const int16_t nchan_transport, /* i : number of transport channels */ +#endif + const int16_t ivas_format /* i : IVAS format */ ) { int16_t b, m; @@ -968,11 +971,15 @@ void ivas_qmetadata_enc_sid_encode( float avg_elevation[MASA_MAXIMUM_CODING_SUBBANDS]; int16_t bits_dir, bits_diff, bits_delta; int16_t metadata_sid_bits; /* bits allocated to SID for metadata */ +#ifdef NONBE_FIX_1052_SBA_EXT + int16_t sba_spar_bitlen; +#endif if ( ivas_format == SBA_FORMAT ) { #ifdef NONBE_FIX_1052_SBA_EXT - metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - SID_FORMAT_NBITS - SBA_ORDER_BITS - SBA_PLANAR_BITS - 1; /* -1 for inactive mode header bit*/ + sba_spar_bitlen = ivas_sba_spar_sid_bitlen( nchan_transport ); + metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - sba_spar_bitlen - SID_FORMAT_NBITS - SBA_ORDER_BITS - SBA_PLANAR_BITS - 1; /* -1 for inactive mode header bit*/ #else metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - 2 - SID_FORMAT_NBITS; /* -1 for inactive mode header bit*/ #endif diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 25b8e84583..d7d3dadc13 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -699,10 +699,18 @@ static ivas_error ivas_spar_enc_process( hodirac_flag = ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ); +#ifdef NONBE_FIX_1052_SBA_EXT + if ( ( error = ivas_dirac_enc( st_ivas->hDirAC, hQMetaData, hMetaData, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, dtx_vad, hEncoderConfig->ivas_format, nchan_transport, hodirac_flag ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( ( error = ivas_dirac_enc( st_ivas->hDirAC, hQMetaData, hMetaData, data_f, ppIn_FR_real, ppIn_FR_imag, input_frame, dtx_vad, hEncoderConfig->ivas_format, hodirac_flag ) ) != IVAS_ERR_OK ) { return error; } +#endif + /* Set Energy Ratio to 0.0 if the mono flag has been set */ if ( hQMetaData->dirac_mono_flag ) diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index cb44858d7d..83ff86b68b 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -1716,6 +1716,9 @@ static void ivas_write_parameter_bitstream_dtx( int16_t idx; float pr_min_max[2]; int16_t zero_pad_bits, sid_bits_len; +#ifdef NONBE_FIX_1052_SBA_EXT + int16_t sba_spar_bitlen; +#endif sid_bits_len = hMetaData->nb_bits_tot; pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; @@ -1771,7 +1774,12 @@ static void ivas_write_parameter_bitstream_dtx( } sid_bits_len = hMetaData->nb_bits_tot - sid_bits_len; +#ifdef NONBE_FIX_1052_SBA_EXT + sba_spar_bitlen = ivas_sba_spar_sid_bitlen( num_dmx[0] ); + zero_pad_bits = sba_spar_bitlen - sid_bits_len; +#else zero_pad_bits = ( SPAR_DTX_BANDS * SPAR_SID_BITS_TAR_PER_BAND ) - sid_bits_len; +#endif assert( zero_pad_bits >= 0 ); if ( num_dmx[0] == 2 ) { -- GitLab From c84ba57e228c829ee2e7446ce843e1ffa943781b Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 7 May 2024 15:23:04 +1000 Subject: [PATCH 06/13] fix in computing residual bits in spar decoder --- lib_dec/ivas_spar_decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index b2a3c0ccf1..ff1de629d0 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -373,7 +373,7 @@ ivas_error ivas_spar_dec( if ( !st0->bfi && hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 ) { #ifdef NONBE_FIX_1052_SBA_EXT - last_bit_pos -= SID_FORMAT_NBITS - SBA_PLANAR_BITS - SBA_ORDER_BITS; + last_bit_pos -= ( SID_FORMAT_NBITS + SBA_PLANAR_BITS + SBA_ORDER_BITS ); #else last_bit_pos -= SID_FORMAT_NBITS; #endif -- GitLab From d2d8311fbfab66c50c281feb3dfdf28b697d98ce Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Tue, 7 May 2024 17:08:03 +1000 Subject: [PATCH 07/13] add test for SBA-EXT feature --- .gitlab-ci.yml | 1 + .../test_sba_ext.py | 159 ++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 tests/codec_be_on_mr_nonselection/test_sba_ext.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ebc7588a40..66aaf874c5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1357,6 +1357,7 @@ ivas-conformance: - 123 script: - *print-common-info-windows + - *copy-ltv-files-to-testv-dir - python .\scripts\strip_split_rendering.py - MSBuild.exe -maxcpucount .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug - cp -force IVAS_cod.exe IVAS_cod_ref.exe diff --git a/tests/codec_be_on_mr_nonselection/test_sba_ext.py b/tests/codec_be_on_mr_nonselection/test_sba_ext.py new file mode 100644 index 0000000000..d64ace4399 --- /dev/null +++ b/tests/codec_be_on_mr_nonselection/test_sba_ext.py @@ -0,0 +1,159 @@ +__copyright__ = """ + (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + """ + +__doc__ = """ + Test decoding SBA bitstreams for external output. Bitstreams + """ +import os + +import pytest +from tests.conftest import DecoderFrontend, EncoderFrontend +from cut_bs import cut_from_start +from tests.cmp_pcm import cmp_pcm + +# params +# test vector file names are of the format ltv48_.wav +sba_orders = ["FOA", "HOA2", "HOA3"] +bitrate_list = [13200, 16400, 24400, 32000, 48000, 64000,80000, 96000, 128000, 160000, 192000, 256000, 384000, 512000] + +AbsTol = "0" + + +def check_and_makedir(dir_path): + if not os.path.exists(dir_path): + try: + os.makedirs(dir_path) + except OSError as e: + if e.errno != errno.EEXIST: + raise # raises the error again + +@pytest.mark.create_ref +@pytest.mark.parametrize("sba_order", sba_orders) +@pytest.mark.parametrize("bitrate", bitrate_list) +def test_sba_ext_ctx( + ref_encoder_frontend: EncoderFrontend, + ref_decoder_frontend: DecoderFrontend, + dut_decoder_frontend: DecoderFrontend, + sba_order, + bitrate, + test_vector_path, + reference_path, + dut_base_path, + update_ref, + keep_files +): + core_sba_ext_test_func(ref_encoder_frontend, ref_decoder_frontend, dut_decoder_frontend, + sba_order, bitrate, False, False, + test_vector_path, reference_path, dut_base_path,update_ref, keep_files) + +@pytest.mark.create_ref +@pytest.mark.parametrize("sba_order", sba_orders) +@pytest.mark.parametrize("sid_first", [True, False]) +@pytest.mark.parametrize("bitrate", [r for r in bitrate_list if r < 96000]) # dtx is not supported above 80kbps +def test_sba_ext_dtx( + ref_encoder_frontend: EncoderFrontend, + ref_decoder_frontend: DecoderFrontend, + dut_decoder_frontend: DecoderFrontend, + sba_order, + bitrate, + sid_first, + test_vector_path, + reference_path, + dut_base_path, + update_ref, + keep_files +): + core_sba_ext_test_func(ref_encoder_frontend, ref_decoder_frontend, dut_decoder_frontend, + sba_order, bitrate, True, sid_first, + test_vector_path, reference_path, dut_base_path,update_ref, keep_files) + +def core_sba_ext_test_func( + ref_encoder_frontend: EncoderFrontend, + ref_decoder_frontend: DecoderFrontend, + dut_decoder_frontend: DecoderFrontend, + sba_order, + bitrate, + dtx, + sid_first, + test_vector_path, + reference_path, + dut_base_path, + update_ref, + keep_files +): + dec_in_dir = f"{reference_path}/sba_ext/pkt" + check_and_makedir(dec_in_dir) + ref_wav_dir = dec_in_dir.replace("pkt", "raw") + check_and_makedir(ref_wav_dir) + dut_wav_dir = ref_wav_dir.replace(reference_path, dut_base_path) + check_and_makedir(dut_wav_dir) + fn_core = f"ltv48_{sba_order}_{bitrate}" + if dtx: + fn_core += "_dtx" + if sid_first: + fn_core += "_sidfirst_cut" + dec_in_path = f"{dec_in_dir}/{fn_core}.g192" + dut_wav_path = dec_in_path.replace(dec_in_dir, dut_wav_dir).replace(".g192", ".wav") + ref_wav_path = dut_wav_path.replace(dut_wav_dir, ref_wav_dir) + print(ref_wav_path) + out_config = "" + enc_sba_order = "" + match sba_order: + case "FOA": + enc_sba_order = "+1" + out_config = "FOA" + case "HOA2": + enc_sba_order = "+2" + out_config = "HOA2" + case "HOA3": + enc_sba_order = "+3" + out_config = "HOA3" + case _: + print(f"Unsupported SBA order: {sba_order}") + assert(False) + if update_ref == 1: + input_path = f"{test_vector_path}/ltv48_{sba_order}.wav" + enc_out_path = dec_in_path.replace('_cut', '') + ref_encoder_frontend.run(bitrate, 48, input_path, enc_out_path, enc_sba_order, dtx_mode=dtx) + if sid_first: + with open(enc_out_path, "rb") as fp_in: + with open(dec_in_path, "wb") as fp_out: + fr_cnt, cut_cnt = cut_from_start(fp_in, fp_out, 0, True) + assert fr_cnt > cut_cnt + if keep_files == 0: + os.remove(enc_out_path) + ref_decoder_frontend.run(out_config, 48, dec_in_path, ref_wav_path) + else: + dut_decoder_frontend.run("EXT", 48, dec_in_path, dut_wav_path) + cmp_result, reason = cmp_pcm(ref_wav_path, dut_wav_path, out_config, 48000, abs_tol=AbsTol) + assert(cmp_result == 0) + assert(True) + if keep_files == 0: + os.remove(dut_wav_path) -- GitLab From 8dbfff75c9fd25871c65d39fa66ee1f90aad2f69 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Tue, 7 May 2024 18:59:28 +1000 Subject: [PATCH 08/13] add copy ltv files to relevant tests --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 66aaf874c5..0afc89ccf0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -587,6 +587,7 @@ pytest-compare-20ms-and-5ms-rendering: script: - *print-common-info - *disable-limiter + - *copy-ltv-files-to-testv-dir - make clean - make -j ### prepare pytest @@ -944,6 +945,7 @@ ivas-interop-on-merge-request: - *get-commits-behind-count - *check-commits-behind-count-in-compare-jobs - *merge-request-comparison-setup-codec + - *copy-ltv-files-to-testv-dir # the next line is dependent on ref-using-main flag in the other tests, but here the flag does not make sense - git checkout $source_branch_commit_sha @@ -1241,6 +1243,7 @@ codec-comparison-on-main-push: - *get-previous-merge-commit-sha # Stored in previous_merge_commit shell variable now - echo "Comparing changes from $previous_merge_commit to $latest_commit" - git --no-pager diff --stat $previous_merge_commit..$latest_commit + - *copy-ltv-files-to-testv-dir # Rest is more or less placeholder adapted from MR self test. This should be replaced with more complex tests. -- GitLab From 53fcf6eeb79e11567ba4cf8e432e09a615cab7db Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 8 May 2024 11:47:56 +1000 Subject: [PATCH 09/13] Revert "add test for SBA-EXT feature" This reverts commit d2d8311fbfab66c50c281feb3dfdf28b697d98ce. --- .gitlab-ci.yml | 1 - .../test_sba_ext.py | 159 ------------------ 2 files changed, 160 deletions(-) delete mode 100644 tests/codec_be_on_mr_nonselection/test_sba_ext.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0afc89ccf0..51f55e2f9e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1360,7 +1360,6 @@ ivas-conformance: - 123 script: - *print-common-info-windows - - *copy-ltv-files-to-testv-dir - python .\scripts\strip_split_rendering.py - MSBuild.exe -maxcpucount .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug - cp -force IVAS_cod.exe IVAS_cod_ref.exe diff --git a/tests/codec_be_on_mr_nonselection/test_sba_ext.py b/tests/codec_be_on_mr_nonselection/test_sba_ext.py deleted file mode 100644 index d64ace4399..0000000000 --- a/tests/codec_be_on_mr_nonselection/test_sba_ext.py +++ /dev/null @@ -1,159 +0,0 @@ -__copyright__ = """ - (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - """ - -__doc__ = """ - Test decoding SBA bitstreams for external output. Bitstreams - """ -import os - -import pytest -from tests.conftest import DecoderFrontend, EncoderFrontend -from cut_bs import cut_from_start -from tests.cmp_pcm import cmp_pcm - -# params -# test vector file names are of the format ltv48_.wav -sba_orders = ["FOA", "HOA2", "HOA3"] -bitrate_list = [13200, 16400, 24400, 32000, 48000, 64000,80000, 96000, 128000, 160000, 192000, 256000, 384000, 512000] - -AbsTol = "0" - - -def check_and_makedir(dir_path): - if not os.path.exists(dir_path): - try: - os.makedirs(dir_path) - except OSError as e: - if e.errno != errno.EEXIST: - raise # raises the error again - -@pytest.mark.create_ref -@pytest.mark.parametrize("sba_order", sba_orders) -@pytest.mark.parametrize("bitrate", bitrate_list) -def test_sba_ext_ctx( - ref_encoder_frontend: EncoderFrontend, - ref_decoder_frontend: DecoderFrontend, - dut_decoder_frontend: DecoderFrontend, - sba_order, - bitrate, - test_vector_path, - reference_path, - dut_base_path, - update_ref, - keep_files -): - core_sba_ext_test_func(ref_encoder_frontend, ref_decoder_frontend, dut_decoder_frontend, - sba_order, bitrate, False, False, - test_vector_path, reference_path, dut_base_path,update_ref, keep_files) - -@pytest.mark.create_ref -@pytest.mark.parametrize("sba_order", sba_orders) -@pytest.mark.parametrize("sid_first", [True, False]) -@pytest.mark.parametrize("bitrate", [r for r in bitrate_list if r < 96000]) # dtx is not supported above 80kbps -def test_sba_ext_dtx( - ref_encoder_frontend: EncoderFrontend, - ref_decoder_frontend: DecoderFrontend, - dut_decoder_frontend: DecoderFrontend, - sba_order, - bitrate, - sid_first, - test_vector_path, - reference_path, - dut_base_path, - update_ref, - keep_files -): - core_sba_ext_test_func(ref_encoder_frontend, ref_decoder_frontend, dut_decoder_frontend, - sba_order, bitrate, True, sid_first, - test_vector_path, reference_path, dut_base_path,update_ref, keep_files) - -def core_sba_ext_test_func( - ref_encoder_frontend: EncoderFrontend, - ref_decoder_frontend: DecoderFrontend, - dut_decoder_frontend: DecoderFrontend, - sba_order, - bitrate, - dtx, - sid_first, - test_vector_path, - reference_path, - dut_base_path, - update_ref, - keep_files -): - dec_in_dir = f"{reference_path}/sba_ext/pkt" - check_and_makedir(dec_in_dir) - ref_wav_dir = dec_in_dir.replace("pkt", "raw") - check_and_makedir(ref_wav_dir) - dut_wav_dir = ref_wav_dir.replace(reference_path, dut_base_path) - check_and_makedir(dut_wav_dir) - fn_core = f"ltv48_{sba_order}_{bitrate}" - if dtx: - fn_core += "_dtx" - if sid_first: - fn_core += "_sidfirst_cut" - dec_in_path = f"{dec_in_dir}/{fn_core}.g192" - dut_wav_path = dec_in_path.replace(dec_in_dir, dut_wav_dir).replace(".g192", ".wav") - ref_wav_path = dut_wav_path.replace(dut_wav_dir, ref_wav_dir) - print(ref_wav_path) - out_config = "" - enc_sba_order = "" - match sba_order: - case "FOA": - enc_sba_order = "+1" - out_config = "FOA" - case "HOA2": - enc_sba_order = "+2" - out_config = "HOA2" - case "HOA3": - enc_sba_order = "+3" - out_config = "HOA3" - case _: - print(f"Unsupported SBA order: {sba_order}") - assert(False) - if update_ref == 1: - input_path = f"{test_vector_path}/ltv48_{sba_order}.wav" - enc_out_path = dec_in_path.replace('_cut', '') - ref_encoder_frontend.run(bitrate, 48, input_path, enc_out_path, enc_sba_order, dtx_mode=dtx) - if sid_first: - with open(enc_out_path, "rb") as fp_in: - with open(dec_in_path, "wb") as fp_out: - fr_cnt, cut_cnt = cut_from_start(fp_in, fp_out, 0, True) - assert fr_cnt > cut_cnt - if keep_files == 0: - os.remove(enc_out_path) - ref_decoder_frontend.run(out_config, 48, dec_in_path, ref_wav_path) - else: - dut_decoder_frontend.run("EXT", 48, dec_in_path, dut_wav_path) - cmp_result, reason = cmp_pcm(ref_wav_path, dut_wav_path, out_config, 48000, abs_tol=AbsTol) - assert(cmp_result == 0) - assert(True) - if keep_files == 0: - os.remove(dut_wav_path) -- GitLab From ee60abb51d246054b39b9437dbb0ee20bb464bd7 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 8 May 2024 11:48:07 +1000 Subject: [PATCH 10/13] Revert "add copy ltv files to relevant tests" This reverts commit 8dbfff75c9fd25871c65d39fa66ee1f90aad2f69. --- .gitlab-ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 51f55e2f9e..ebc7588a40 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -587,7 +587,6 @@ pytest-compare-20ms-and-5ms-rendering: script: - *print-common-info - *disable-limiter - - *copy-ltv-files-to-testv-dir - make clean - make -j ### prepare pytest @@ -945,7 +944,6 @@ ivas-interop-on-merge-request: - *get-commits-behind-count - *check-commits-behind-count-in-compare-jobs - *merge-request-comparison-setup-codec - - *copy-ltv-files-to-testv-dir # the next line is dependent on ref-using-main flag in the other tests, but here the flag does not make sense - git checkout $source_branch_commit_sha @@ -1243,7 +1241,6 @@ codec-comparison-on-main-push: - *get-previous-merge-commit-sha # Stored in previous_merge_commit shell variable now - echo "Comparing changes from $previous_merge_commit to $latest_commit" - git --no-pager diff --stat $previous_merge_commit..$latest_commit - - *copy-ltv-files-to-testv-dir # Rest is more or less placeholder adapted from MR self test. This should be replaced with more complex tests. -- GitLab From 8b9e26fd022a5d7efb3951ceb3746b2e769c0339 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 8 May 2024 13:22:35 +1000 Subject: [PATCH 11/13] Add sba-ext feature tests in self_test.prm --- scripts/config/self_test.prm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 2392f65c05..56eb3c07b7 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -1767,3 +1767,12 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_10pct.g // OSBA planar 2OA 4ISM at 512 kbps, 48 kHz in, 48 kHz out, BINAURAL ROOM REVERB (Model from file) out ../IVAS_cod -ism_sba 4 -2 testv/stvISM1.csv testv/stvISM2.csv testv/stvISM3.csv testv/stvISM4.csv 512000 48 testv/stvOSBA_4ISM_2OA48c.wav bit ../IVAS_dec -hrtf ../scripts/binauralRenderer_interface/binaural_renderers_hrtf_data/ivas_binaural_48kHz.bin BINAURAL_ROOM_REVERB 48 bit testv/stvOSBA_4ISM_p3OA48c.wav_BINAURAL_ROOM_REVERB_512000_48-48.tst + +// SBA FOA bitrate switching from 13.2 kbps to 192 kbps, 32kHz in, 32kHz out, DTX on, EXT out +../IVAS_cod -dtx -sba 1 ../scripts/switchPaths/sw_13k2_192k_50fr.bin 32 testv/stvFOA32c.wav bit +../IVAS_dec EXT 32 bit testv/stvFOA32c.wav_sw_32-32_DTX_EXT.tst + +// SBA 3OA bitrate switching from 13.2 kbps to 128 kbps, 32kHz in, 32kHz out, DTX on, EXT out +../IVAS_cod -dtx -sba 3 ../scripts/switchPaths/sw_13k2_to_128k_10fr.bin 32 testv/stv3OA32c.wav bit +../IVAS_dec EXT 32 bit testv/stv3OA32c.wav_sw_32-32_DTX_EXT.tst + -- GitLab From 9872c298f46be66b3f98644106f677177bd44351 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 8 May 2024 16:28:32 +1000 Subject: [PATCH 12/13] add sba-ext test for hoa2, bitrate switching, plc, dtx --- scripts/config/self_test.prm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 56eb3c07b7..abc1392c54 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -1776,3 +1776,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_10pct.g ../IVAS_cod -dtx -sba 3 ../scripts/switchPaths/sw_13k2_to_128k_10fr.bin 32 testv/stv3OA32c.wav bit ../IVAS_dec EXT 32 bit testv/stv3OA32c.wav_sw_32-32_DTX_EXT.tst +// SBA at 192 kbps, 48kHz in, 48kHz out, EXT out, random FER at 5%, DTX on +../IVAS_cod -dtx -sba 3 ../scripts/switchPaths/sw_13k2_to_128k_10fr.bin 48 testv/stv3OA48c.wav bit +eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error +../IVAS_dec EXT 48 bit_error testv/stv3OA48c.wav_sw_48-48_EXT_FER5.tst -- GitLab From 047f66a27a0bfd66d972c4f17759010352b89ec8 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 8 May 2024 16:58:58 +1000 Subject: [PATCH 13/13] update test tag --- scripts/config/self_test.prm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index abc1392c54..84d5a3feb2 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -1776,7 +1776,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_10pct.g ../IVAS_cod -dtx -sba 3 ../scripts/switchPaths/sw_13k2_to_128k_10fr.bin 32 testv/stv3OA32c.wav bit ../IVAS_dec EXT 32 bit testv/stv3OA32c.wav_sw_32-32_DTX_EXT.tst -// SBA at 192 kbps, 48kHz in, 48kHz out, EXT out, random FER at 5%, DTX on +// SBA 2OA bitrate switching from 13.2 kbps to 128 kbps, 48kHz in, 48kHz out, EXT out, random FER at 5%, DTX on ../IVAS_cod -dtx -sba 3 ../scripts/switchPaths/sw_13k2_to_128k_10fr.bin 48 testv/stv3OA48c.wav bit eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec EXT 48 bit_error testv/stv3OA48c.wav_sw_48-48_EXT_FER5.tst -- GitLab