From 41a897bdbe3509c193f256a7cc883b6444679b47 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Thu, 17 Aug 2023 14:49:15 +0200 Subject: [PATCH 1/3] fix ACELP problems with extreme OMASA items. switch: CR_FIX_694_OMASA_ACELP --- lib_com/bits_alloc.c | 7 +++++++ lib_com/ivas_stereo_td_bit_alloc.c | 11 +++++++++++ lib_com/options.h | 1 + 3 files changed, 19 insertions(+) diff --git a/lib_com/bits_alloc.c b/lib_com/bits_alloc.c index ff840a9a63..b507f7dbf2 100644 --- a/lib_com/bits_alloc.c +++ b/lib_com/bits_alloc.c @@ -476,6 +476,10 @@ static ivas_error acelp_FCB_allocator( } /* try to increase the FCB of the first subframe in cases when the next step is lower than the current step */ +#ifdef CR_FIX_694_OMASA_ACELP + if ( fixed_cdk_index[sfr] < ACELP_FIXED_CDK_NB - 1 ) + { +#endif step = fcb_table( fixed_cdk_index[sfr] + 1, L_subfr ) - fcb_table( fixed_cdk_index[sfr], L_subfr ); if ( *nBits >= step && cdbk >= 0 ) { @@ -489,6 +493,9 @@ static ivas_error acelp_FCB_allocator( *nBits -= step; } } +#ifdef CR_FIX_694_OMASA_ACELP + } +#endif } /* TRANSITION coding: allocate highest FCBQ bit-budget to the subframe with the glottal-shape codebook */ if ( tc_subfr >= L_SUBFR ) diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index 8282cb9dbd..8bb3c42cb4 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -308,7 +308,18 @@ void tdm_bit_alloc( { *total_brate_sec = min( *total_brate_sec, element_brate_wo_meta - ( 5900 + BWE_brate ) ); +#ifdef CR_FIX_694_OMASA_ACELP + if (coder_type == INACTIVE ) + { + *total_brate_sec = max( *total_brate_sec, tdm_bit_allc_tbl[0][0] ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */ + } + else + { + *total_brate_sec = max( *total_brate_sec, 3500 ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */ + } +#else *total_brate_sec = max( *total_brate_sec, tdm_bit_allc_tbl[idx][coder_type] ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */ +#endif } /* Secondary channel bitrate adjusment */ diff --git a/lib_com/options.h b/lib_com/options.h index 6040e4ed85..c94feeea32 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -172,6 +172,7 @@ #define CR_FIX_586_BPF_DFT_MEM /* FhG: issue 586: set input memory of DFT analysis of BPF signal to zero for HQ core to fix issue with PLC and bitrate switching */ #define CR_FIX_ISM_DTX_INFINITE_CNG_ON_TRAILING_SILENCE /* FhG: fix for cng in ISM DTX on sudden silence periods */ #define CR_FIX_698_SBA_MSAN /* Dlb: issue 698: Uninitialized memory read in SBA init */ +#define CR_FIX_694_OMASA_ACELP /* Nokia: Issue #694: OMASA crash in ACELP with extreme item */ /* ##################### End NON-BE CR switches ########################### */ -- GitLab From 517883e6361d76e337319bee014ec5b541a77198 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Thu, 17 Aug 2023 15:11:26 +0200 Subject: [PATCH 2/3] clang formatting --- lib_com/bits_alloc.c | 18 +++++++++--------- lib_com/ivas_stereo_td_bit_alloc.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_com/bits_alloc.c b/lib_com/bits_alloc.c index b507f7dbf2..c4ff56921a 100644 --- a/lib_com/bits_alloc.c +++ b/lib_com/bits_alloc.c @@ -480,19 +480,19 @@ static ivas_error acelp_FCB_allocator( if ( fixed_cdk_index[sfr] < ACELP_FIXED_CDK_NB - 1 ) { #endif - step = fcb_table( fixed_cdk_index[sfr] + 1, L_subfr ) - fcb_table( fixed_cdk_index[sfr], L_subfr ); - if ( *nBits >= step && cdbk >= 0 ) - { - fixed_cdk_index[sfr]++; - *nBits -= step; - - if ( *nBits >= step && fixed_cdk_index[sfr + 1] == fixed_cdk_index[sfr] - 1 ) + step = fcb_table( fixed_cdk_index[sfr] + 1, L_subfr ) - fcb_table( fixed_cdk_index[sfr], L_subfr ); + if ( *nBits >= step && cdbk >= 0 ) { - sfr++; fixed_cdk_index[sfr]++; *nBits -= step; + + if ( *nBits >= step && fixed_cdk_index[sfr + 1] == fixed_cdk_index[sfr] - 1 ) + { + sfr++; + fixed_cdk_index[sfr]++; + *nBits -= step; + } } - } #ifdef CR_FIX_694_OMASA_ACELP } #endif diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index 8bb3c42cb4..fd3a73c8ff 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -309,7 +309,7 @@ void tdm_bit_alloc( *total_brate_sec = min( *total_brate_sec, element_brate_wo_meta - ( 5900 + BWE_brate ) ); #ifdef CR_FIX_694_OMASA_ACELP - if (coder_type == INACTIVE ) + if ( coder_type == INACTIVE ) { *total_brate_sec = max( *total_brate_sec, tdm_bit_allc_tbl[0][0] ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */ } -- GitLab From 81dde35bf31e921166a12932dfcd7f7c2530c749 Mon Sep 17 00:00:00 2001 From: advasila Date: Tue, 5 Sep 2023 12:41:07 +0300 Subject: [PATCH 3/3] correct switch name for 694 --- lib_com/bits_alloc.c | 4 ++-- lib_com/ivas_stereo_td_bit_alloc.c | 2 +- lib_com/options.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/bits_alloc.c b/lib_com/bits_alloc.c index c4ff56921a..3e3faf9564 100644 --- a/lib_com/bits_alloc.c +++ b/lib_com/bits_alloc.c @@ -476,7 +476,7 @@ static ivas_error acelp_FCB_allocator( } /* try to increase the FCB of the first subframe in cases when the next step is lower than the current step */ -#ifdef CR_FIX_694_OMASA_ACELP +#ifdef NONBE_FIX_694_OMASA_ACELP if ( fixed_cdk_index[sfr] < ACELP_FIXED_CDK_NB - 1 ) { #endif @@ -493,7 +493,7 @@ static ivas_error acelp_FCB_allocator( *nBits -= step; } } -#ifdef CR_FIX_694_OMASA_ACELP +#ifdef NONBE_FIX_694_OMASA_ACELP } #endif } diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index fd3a73c8ff..5dfb2b0e3d 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -308,7 +308,7 @@ void tdm_bit_alloc( { *total_brate_sec = min( *total_brate_sec, element_brate_wo_meta - ( 5900 + BWE_brate ) ); -#ifdef CR_FIX_694_OMASA_ACELP +#ifdef NONBE_FIX_694_OMASA_ACELP if ( coder_type == INACTIVE ) { *total_brate_sec = max( *total_brate_sec, tdm_bit_allc_tbl[0][0] ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */ diff --git a/lib_com/options.h b/lib_com/options.h index 7510ed3998..dce7bdb8a7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -167,7 +167,7 @@ #define NONBE_FIX_736_FOA_BR_SWITCH /* FhG/Dlb : Issue 736: FOA bitrate switching decoding crashes in in ivas_spar_to_dirac */ #define NONBE_FIX_746_NONDIEGETIC_MD /* Eri: Issue 746: The non-diegetic panning flag affects the encoder bitstream even if extended metadata is not enabled. Crashes the decoder.*/ -#define CR_FIX_694_OMASA_ACELP /* Nokia: Issue #694: OMASA crash in ACELP with extreme item */ +#define NONBE_FIX_694_OMASA_ACELP /* Nokia: Issue #694: OMASA crash in ACELP with extreme item */ /* ##################### End NON-BE switches ############################# */ -- GitLab