From f52942aa7b0c1dca59248d14841bcbc0e0782e4f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 31 Oct 2023 14:53:40 +0100 Subject: [PATCH 1/5] reduce maximum number of DirAC metadata bits to 101 at 24.4 kbps --- lib_com/ivas_dirac_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 22b726f314..c97a0ff61d 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -334,7 +334,7 @@ void ivas_get_dirac_sba_max_md_bits( else if ( sba_total_brate <= IVAS_24k4 ) { *bits_frame_nominal = ACELP_16k40 / FRAMES_PER_SEC; - *metadata_max_bits = 103; + *metadata_max_bits = 101; } else if ( sba_total_brate <= IVAS_32k ) { -- GitLab From 8c3006b9d586c3e82a3a9b2d661b1525c71211f3 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 31 Oct 2023 15:11:09 +0100 Subject: [PATCH 2/5] doc: wrap changes into the new switch NONBE_FIX_871_ACELP_CRASH_IN_OSBA --- lib_com/ivas_dirac_com.c | 4 ++++ lib_com/options.h | 1 + 2 files changed, 5 insertions(+) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index c97a0ff61d..aaf9e7a338 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -334,7 +334,11 @@ void ivas_get_dirac_sba_max_md_bits( else if ( sba_total_brate <= IVAS_24k4 ) { *bits_frame_nominal = ACELP_16k40 / FRAMES_PER_SEC; +#ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA *metadata_max_bits = 101; +#else + *metadata_max_bits = 103; +#endif } else if ( sba_total_brate <= IVAS_32k ) { diff --git a/lib_com/options.h b/lib_com/options.h index 6da0523307..3eafa173c5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -169,6 +169,7 @@ #define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ #define NONBE_FIX_836_PARAMUPMIX_HEADROT /* Dlb: issue #836: Resolve "ParamUpmix MC to SBA conversion done on the already binaurlized output" */ #define NONBE_FIX_874_OMASA_BRSW_2TD /* Nokia: issue 874: Fixes the crashes with the long test vectors that prompted switching to TD*/ +#define NONBE_FIX_871_ACELP_CRASH_IN_OSBA /* FhG: isse 871: crash in ACELP core encoder with OSBA */ /* ##################### End NON-BE switches ########################### */ -- GitLab From 40113398dfea9125b7d4e7f97875977f718a8f0c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 2 Nov 2023 09:58:30 +0100 Subject: [PATCH 3/5] restore SBA bitexactness --- lib_com/ivas_dirac_com.c | 41 ++++++++++++++++++++++++++++++---------- lib_com/ivas_prot.h | 8 ++++++++ lib_dec/ivas_init_dec.c | 12 ++++++++++-- lib_dec/ivas_sba_dec.c | 6 +++++- lib_enc/ivas_osba_enc.c | 2 +- 5 files changed, 55 insertions(+), 14 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index aaf9e7a338..0165e91a11 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -162,7 +162,11 @@ ivas_error ivas_dirac_config( hConfig->dec_param_estim = FALSE; if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) /* skip for MASA decoder */ { - if ( ( error = ivas_dirac_sba_config( hQMetaData, element_mode, ivas_total_brate, sba_order, hConfig->nbands - spar_dirac_split_band ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_sba_config( hQMetaData, element_mode, ivas_total_brate, sba_order, hConfig->nbands - spar_dirac_split_band +#ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA + ,ivas_format +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -194,11 +198,11 @@ ivas_error ivas_dirac_config( if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) { - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft ); + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, ( int16_t )( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft ); } else { - ivas_dirac_config_bands( band_grouping, hConfig->nbands, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), NULL, 0, 0, hFbMdft ); + ivas_dirac_config_bands( band_grouping, hConfig->nbands, ( int16_t )( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), NULL, 0, 0, hFbMdft ); } return error; @@ -319,7 +323,12 @@ void ivas_get_dirac_sba_max_md_bits( int16_t *bits_frame_nominal, int16_t *metadata_max_bits, int16_t *qmetadata_max_bit_req, - const int16_t nbands ) + const int16_t nbands +#ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA + , + IVAS_FORMAT ivas_format +#endif +) { if ( sba_total_brate <= IVAS_13k2 ) { @@ -334,10 +343,13 @@ void ivas_get_dirac_sba_max_md_bits( else if ( sba_total_brate <= IVAS_24k4 ) { *bits_frame_nominal = ACELP_16k40 / FRAMES_PER_SEC; -#ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA - *metadata_max_bits = 101; -#else *metadata_max_bits = 103; +#ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA + /* OSBA needs an additional 2-bits safety margin to avoid acelp crashes */ + if( ivas_format == SBA_ISM_FORMAT) + { + ( *metadata_max_bits ) -= 2; + } #endif } else if ( sba_total_brate <= IVAS_32k ) @@ -372,7 +384,7 @@ void ivas_get_dirac_sba_max_md_bits( } else { - *bits_frame_nominal = (int16_t) ( sba_total_brate / FRAMES_PER_SEC ); + *bits_frame_nominal = ( int16_t )( sba_total_brate / FRAMES_PER_SEC ); *metadata_max_bits = MAX16B; /* no limit */ } *metadata_max_bits = (int16_t) min( (float) MAX16B, ceilf( (float) *metadata_max_bits * nbands / 5 ) ); @@ -394,6 +406,10 @@ ivas_error ivas_dirac_sba_config( int32_t sba_total_brate, /* i : SBA total bitrate */ const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int16_t nbands /* i : number of frequency bands */ +#ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA + , + IVAS_FORMAT ivas_format +#endif ) { int16_t nbands_coded; @@ -429,7 +445,7 @@ ivas_error ivas_dirac_sba_config( } nbands_coded = nbands; - if ( sba_total_brate <= (int32_t) ( (float) IVAS_192k / (float) SPAR_DIRAC_SPLIT_START_BAND ) ) + if ( sba_total_brate <= ( int32_t )( (float) IVAS_192k / (float) SPAR_DIRAC_SPLIT_START_BAND ) ) { hQMetaData->useLowerBandRes = 1; nbands_coded = nbands / 2 + nbands % 2; @@ -456,7 +472,12 @@ ivas_error ivas_dirac_sba_config( } } - ivas_get_dirac_sba_max_md_bits( sba_total_brate, &hQMetaData->bits_frame_nominal, &hQMetaData->metadata_max_bits, &hQMetaData->qmetadata_max_bit_req, hQMetaData->q_direction[0].cfg.nbands ); + ivas_get_dirac_sba_max_md_bits( sba_total_brate, &hQMetaData->bits_frame_nominal, &hQMetaData->metadata_max_bits, &hQMetaData->qmetadata_max_bit_req, hQMetaData->q_direction[0].cfg.nbands +#ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA + , + ivas_format +#endif + ); return error; } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index b37a31268c..c512990491 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3647,6 +3647,10 @@ void ivas_get_dirac_sba_max_md_bits( int16_t *metadata_max_bits, int16_t *qmetadata_max_bit_req, const int16_t nbands +#ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA + , + IVAS_FORMAT ivas_format +#endif ); ivas_error ivas_dirac_sba_config( @@ -3655,6 +3659,10 @@ ivas_error ivas_dirac_sba_config( int32_t sba_total_brate, /* i : SBA total bitrate */ const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int16_t nbands /* i : number of frequency bands */ +#ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA + , + IVAS_FORMAT ivas_format +#endif ); ivas_error ivas_dirac_dec_config( diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 7ed132c87b..e40e30b7f6 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1363,7 +1363,11 @@ ivas_error ivas_init_decoder( } } - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) +#ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA + ,st_ivas->ivas_format +#endif + ) ) != IVAS_ERR_OK ) { return error; } @@ -1516,7 +1520,11 @@ ivas_error ivas_init_decoder( } } - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) +#ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA + ,st_ivas->ivas_format +#endif + ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 82ca41a271..18b2446f25 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -392,7 +392,11 @@ ivas_error ivas_sba_dec_reconfigure( ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); } - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) +#ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA + , st_ivas->ivas_format +#endif + ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_osba_enc.c b/lib_enc/ivas_osba_enc.c index 83841795f7..675b89c6d6 100644 --- a/lib_enc/ivas_osba_enc.c +++ b/lib_enc/ivas_osba_enc.c @@ -72,7 +72,7 @@ static void ivas_merge_sba_transports( { for ( j = 0; j < input_frame; j++ ) { - data_out_f[i][j] = data_in_f1[i][j] + data_in_f2[i][j]; + data_out_f[i][j] = ( data_in_f1[i][j] + data_in_f2[i][j] ); } } -- GitLab From 173a94b376d2425c66e14f3c392a1e1fb1f2daa6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 2 Nov 2023 10:27:59 +0100 Subject: [PATCH 4/5] fix formatting --- lib_com/ivas_dirac_com.c | 29 +++++++++++++++-------------- lib_dec/ivas_init_dec.c | 12 +++++++----- lib_dec/ivas_sba_dec.c | 5 +++-- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 0165e91a11..6ea49c45c4 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -164,9 +164,10 @@ ivas_error ivas_dirac_config( { if ( ( error = ivas_dirac_sba_config( hQMetaData, element_mode, ivas_total_brate, sba_order, hConfig->nbands - spar_dirac_split_band #ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA - ,ivas_format + , + ivas_format #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { return error; } @@ -198,11 +199,11 @@ ivas_error ivas_dirac_config( if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) { - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, ( int16_t )( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft ); + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), dirac_to_spar_md_bands, hQMetaData->useLowerBandRes, hConfig->enc_param_start_band, hFbMdft ); } else { - ivas_dirac_config_bands( band_grouping, hConfig->nbands, ( int16_t )( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), NULL, 0, 0, hFbMdft ); + ivas_dirac_config_bands( band_grouping, hConfig->nbands, (int16_t) ( Fs * INV_CLDFB_BANDWIDTH + 0.5f ), NULL, 0, 0, hFbMdft ); } return error; @@ -323,10 +324,10 @@ void ivas_get_dirac_sba_max_md_bits( int16_t *bits_frame_nominal, int16_t *metadata_max_bits, int16_t *qmetadata_max_bit_req, - const int16_t nbands + const int16_t nbands #ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA - , - IVAS_FORMAT ivas_format + , + IVAS_FORMAT ivas_format #endif ) { @@ -346,10 +347,10 @@ void ivas_get_dirac_sba_max_md_bits( *metadata_max_bits = 103; #ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA /* OSBA needs an additional 2-bits safety margin to avoid acelp crashes */ - if( ivas_format == SBA_ISM_FORMAT) - { - ( *metadata_max_bits ) -= 2; - } + if ( ivas_format == SBA_ISM_FORMAT ) + { + ( *metadata_max_bits ) -= 2; + } #endif } else if ( sba_total_brate <= IVAS_32k ) @@ -384,7 +385,7 @@ void ivas_get_dirac_sba_max_md_bits( } else { - *bits_frame_nominal = ( int16_t )( sba_total_brate / FRAMES_PER_SEC ); + *bits_frame_nominal = (int16_t) ( sba_total_brate / FRAMES_PER_SEC ); *metadata_max_bits = MAX16B; /* no limit */ } *metadata_max_bits = (int16_t) min( (float) MAX16B, ceilf( (float) *metadata_max_bits * nbands / 5 ) ); @@ -445,7 +446,7 @@ ivas_error ivas_dirac_sba_config( } nbands_coded = nbands; - if ( sba_total_brate <= ( int32_t )( (float) IVAS_192k / (float) SPAR_DIRAC_SPLIT_START_BAND ) ) + if ( sba_total_brate <= (int32_t) ( (float) IVAS_192k / (float) SPAR_DIRAC_SPLIT_START_BAND ) ) { hQMetaData->useLowerBandRes = 1; nbands_coded = nbands / 2 + nbands % 2; @@ -477,7 +478,7 @@ ivas_error ivas_dirac_sba_config( , ivas_format #endif - ); + ); return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index e40e30b7f6..d9e32229c8 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1363,11 +1363,12 @@ ivas_error ivas_init_decoder( } } - if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) + if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) #ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA - ,st_ivas->ivas_format + , + st_ivas->ivas_format #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { return error; } @@ -1522,9 +1523,10 @@ ivas_error ivas_init_decoder( if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) #ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA - ,st_ivas->ivas_format + , + st_ivas->ivas_format #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 18b2446f25..88c545ad6a 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -394,9 +394,10 @@ ivas_error ivas_sba_dec_reconfigure( if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) #ifdef NONBE_FIX_871_ACELP_CRASH_IN_OSBA - , st_ivas->ivas_format + , + st_ivas->ivas_format #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 18db5791b50fc071a14d4d607b7633dcc388b940 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 7 Nov 2023 12:56:56 +0100 Subject: [PATCH 5/5] reduce number of DirAC MD bits by one more --- lib_com/ivas_dirac_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index 6ea49c45c4..bcf502033a 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -349,7 +349,7 @@ void ivas_get_dirac_sba_max_md_bits( /* OSBA needs an additional 2-bits safety margin to avoid acelp crashes */ if ( ivas_format == SBA_ISM_FORMAT ) { - ( *metadata_max_bits ) -= 2; + ( *metadata_max_bits ) -= 3; } #endif } -- GitLab