diff --git a/lib_com/ivas_omasa_com.c b/lib_com/ivas_omasa_com.c index 14236c919d4333b73e8e9100a0fb7ccb9b89b347..cbf15dde4f88ddd050575f348677a057cfc7c36a 100644 --- a/lib_com/ivas_omasa_com.c +++ b/lib_com/ivas_omasa_com.c @@ -335,11 +335,22 @@ int32_t ivas_interformat_brate( void ivas_combined_format_brate_sanity( const int32_t element_brate, /* i : element bitrate */ const int16_t core, /* i : core */ - int32_t *core_brate, /* i/o: core bitrate */ - int16_t *diff_nBits /* o : number of differential bits */ +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + const int32_t total_brate, /* i : total bitrate */ +#endif + int32_t *core_brate, /* i/o: core bitrate */ +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + int16_t *inactive_coder_type_flag, /* o : inactive coder_type flag */ +#endif + int16_t *diff_nBits /* o : number of differential bits */ ) { int16_t limit_high, nBits; +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + int32_t brate_diff; + + brate_diff = total_brate - *core_brate; +#endif /* sanity check: at lowest IVAS bit-rates and one ISM channel coded by low-rate core-coder mode, it can happen that the CPE (MASA) bit-budget @@ -364,6 +375,21 @@ void ivas_combined_format_brate_sanity( } } +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + /*-----------------------------------------------------------------* + * set inactive coder_type flag in ACELP core + *-----------------------------------------------------------------*/ + + if ( core == ACELP_CORE ) + { + *inactive_coder_type_flag = 0; /* AVQ by default */ + if ( *core_brate + brate_diff <= MAX_GSC_INACTIVE_BRATE ) + { + *inactive_coder_type_flag = 1; /* GSC */ + } + } +#endif + return; } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 1188eb8e3b8de9e6daa81b64e29b60d421ec2a29..624494d24a3f11147f03ecb7c75c0c530d82a77f 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5827,7 +5827,13 @@ int32_t ivas_interformat_brate( void ivas_combined_format_brate_sanity( const int32_t element_brate, /* i : element bitrate */ const int16_t core, /* i : core */ +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + const int32_t total_brate, /* i : total bitrate */ +#endif int32_t *core_brate, /* i/o: core bitrate */ +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + int16_t *inactive_coder_type_flag, /* o : inactive coder_type flag */ +#endif int16_t *diff_nBits /* o : number of differential bits */ ); diff --git a/lib_com/options.h b/lib_com/options.h index b777de1c0040dc3dfb8b25f9e1e42a970c696542..f00d747592bbf5c693d4fb71ed4704bb6ec56bc1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -199,10 +199,11 @@ #define NONBE_FIX_722_MEMORY_LEAK_IN_PARAMUPMIX /* Dlb : issue 722: memory leak fix in MC param upmix mode with BR switching*/ #define NONBE_FIX_780_ISM_STARTS_WITH_SID /* VA: issue 780: fix Crash in ISM decoding when bitstream starts with an SID and output_config is not EXT */ #define NONBE_FIX_ISM_DTX_INFINITE_CNG_ON_TRAILING_SILENCE /* FhG: fix for cng in ISM DTX on sudden silence periods - JBM addon (issue 552) */ -#define NONBE_FIX_738_SBA_BR_SW_ASAN /* FhG: issue 738: fixes bug when switching to an MCT bitrate and previous frame was ACELP */ -#define NONBE_CR_FIX_735_SBA_HP20_BRATE_SWITCHING /* VA: Issue 735: Resolve "HP20 filtering bug in SBA/OSBA bitrate switching" */ +#define NONBE_FIX_738_SBA_BR_SW_ASAN /* FhG: issue 738: fixes bug when switching to an MCT bitrate and previous frame was ACELP */ +#define NONBE_CR_FIX_735_SBA_HP20_BRATE_SWITCHING /* VA: Issue 735: Resolve "HP20 filtering bug in SBA/OSBA bitrate switching" */ #define NONBE_FIX_588_UPDATE_FASTCONV_SD /* FhG: issue 588: update FastConv SD HRTFs in CLDFB domain with new conversion method */ #define NONBE_FIX_778_TNS_UNFIED_STEREO_MSAN /* FhG: Issue 778: MSAN error due to uninitialized TNS configuration */ +#define NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ /* VA: issue 797: fix of crash when the separated object is inactive and the MASA metadata is using very few bits */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index f686381d547b0d08fa8dc536f87c09261e49aea7..fb2d6277e749a1c600dae7d1fd20397be9003312 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -803,7 +803,11 @@ ivas_error acelp_core_dec( { decod_tran( st, st->L_frame, tc_subfr, Aq, Es_pred, pitch_buf, voice_factors, exc, exc2, bwe_exc, unbits, sharpFlag, gain_buf ); } +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + else if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) +#else else if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->total_brate <= MAX_GSC_INACTIVE_BRATE ) ) +#endif { /* AUDIO and INACTIVE frames (coded by GSC technology) */ decod_audio( st, dct_exc_tmp, Aq, &tmp_noise, pitch_buf, voice_factors, exc, exc2, bwe_exc, lsf_new, gain_buf, tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf ); diff --git a/lib_dec/decision_matrix_dec.c b/lib_dec/decision_matrix_dec.c index 84e6e9573e20eb5f2df4788a644e6e4bc1903a45..5f4bcb9812f7febaadf3975e744043d91ad0e4dd 100644 --- a/lib_dec/decision_matrix_dec.c +++ b/lib_dec/decision_matrix_dec.c @@ -406,7 +406,6 @@ void decision_matrix_dec( /* set core bitrate */ st->core_brate = st->total_brate - st->extl_brate; - /*-----------------------------------------------------------------* * Read HQ signaling bits from the bitstream * Set HQ core type @@ -559,5 +558,17 @@ void decision_matrix_dec( st->last_extl = st->extl; } +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + /*-----------------------------------------------------------------* + * set inactive coder_type flag in ACELP core + *-----------------------------------------------------------------*/ + + st->inactive_coder_type_flag = 0; /* AVQ by default */ + if ( st->total_brate <= MAX_GSC_INACTIVE_BRATE ) + { + st->inactive_coder_type_flag = 1; /* GSC */ + } +#endif + return; } diff --git a/lib_dec/init_dec.c b/lib_dec/init_dec.c index 86944e55f21c8b85e80b1b8f0839d6440534a6d7..299cecbc08a228ea654680956a71ee9aad506ccb 100644 --- a/lib_dec/init_dec.c +++ b/lib_dec/init_dec.c @@ -85,6 +85,9 @@ ivas_error init_decoder( st->coder_type = GENERIC; st->last_coder_type = GENERIC; +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + st->inactive_coder_type_flag = 0; +#endif st->last_L_frame = st->L_frame; st->last_core_brate = st->core_brate; st->last_core = -1; diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index e15cb85d1b6fd3453b131e89d77c4540db9c0d70..de5e6dd6d98510d30d6adce80512986232a4195a 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -279,7 +279,11 @@ ivas_error ivas_core_dec( if ( hCPE != NULL && hCPE->element_mode == IVAS_CPE_DFT && hCPE->brate_surplus > 0 ) { +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &tmps ); +#else ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, &( sts[0]->core_brate ), &tmps ); +#endif } /*------------------------------------------------------------------* diff --git a/lib_dec/ivas_decision_matrix_dec.c b/lib_dec/ivas_decision_matrix_dec.c index fcbff7f0ed3ddfd242d1872e5b5f989584b0ec98..a30ca065a1463f4aee3a025625b75e4d535f3575 100644 --- a/lib_dec/ivas_decision_matrix_dec.c +++ b/lib_dec/ivas_decision_matrix_dec.c @@ -433,6 +433,18 @@ void ivas_decision_matrix_dec( st->nb_subfr = NB_SUBFR; } +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + /*-----------------------------------------------------------------* + * set inactive coder_type flag in ACELP core + *-----------------------------------------------------------------*/ + + st->inactive_coder_type_flag = 0; /* AVQ by default */ + if ( st->total_brate <= MAX_GSC_INACTIVE_BRATE ) + { + st->inactive_coder_type_flag = 1; /* GSC */ + } +#endif + /*-----------------------------------------------------------------* * Reconfigure in case when output_Fs < input_Fs *-----------------------------------------------------------------*/ diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 1201d9a30470bf9f5c1a68a60b47692256b1e3e5..52cc3217901c25d569590c8d2af6a24c1c93a984 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -936,6 +936,9 @@ typedef struct Decoder_State int16_t prev_coder_type; /* coding type of last frame */ int16_t low_rate_mode; /* low-rate mode flag */ int16_t last_low_rate_mode; /* previous frame low-rate mode flag */ +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + int16_t inactive_coder_type_flag; /* inactive coder type flag (0 = AVQ / 1 = GSC) */ +#endif /*----------------------------------------------------------------------------------* * ACELP core parameters diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index 42c5907229646475b2b52a8261fc05be1c49fcb6..d18ef939b2b61c28b50816b7769bf000f4eb168c 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -563,7 +563,11 @@ ivas_error acelp_core_enc( encod_gen_voic( st, inp, Aw, Aq, Es_pred, res, syn, exc, exc2, pitch_buf, voice_factors, bwe_exc, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); } } +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + else if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) +#else else if ( st->coder_type == AUDIO || ( st->coder_type == INACTIVE && st->total_brate <= MAX_GSC_INACTIVE_BRATE ) ) +#endif { /* AUDIO and INACTIVE frames (coded by GSC technology) */ encod_audio( st, inp, Aw, Aq, res, syn, exc, pitch_buf, voice_factors, bwe_exc, attack_flag, lsf_new, &tmp_noise, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); diff --git a/lib_enc/decision_matrix_enc.c b/lib_enc/decision_matrix_enc.c index 9fc2bd17c9840e8671d5a472a6615596298023e5..d21fa934f1a4f655774c73c3a480e030280f1ba4 100644 --- a/lib_enc/decision_matrix_enc.c +++ b/lib_enc/decision_matrix_enc.c @@ -156,7 +156,6 @@ void decision_matrix_enc( } else if ( ( ( st->coder_type == UNVOICED || st->coder_type == TRANSITION ) && !st->sp_aud_decision1 ) || st->bwidth != NB ) { - if ( st->coder_type == UNVOICED && st->vad_flag == 1 && ( ( st->last_bwidth >= SWB && st->last_Opt_SC_VBR ) || st->last_bwidth < SWB ) && ( st->last_core != HQ_CORE || st->bwidth != NB ) ) { /* NELP mode */ @@ -171,6 +170,11 @@ void decision_matrix_enc( } } +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + /* set inactive coder_type flag in ACELP core to GSC */ + st->inactive_coder_type_flag = 1; +#endif + return; } @@ -327,9 +331,22 @@ void decision_matrix_enc( st->last_extl = st->extl; } +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + /*-----------------------------------------------------------------* + * set inactive coder_type flag in ACELP core + *-----------------------------------------------------------------*/ + + st->inactive_coder_type_flag = 0; /* AVQ by default */ + if ( st->total_brate <= MAX_GSC_INACTIVE_BRATE ) + { + st->inactive_coder_type_flag = 1; /* GSC */ + } +#endif + return; } + /*---------------------------------------------------------------------* * signaling_mode1_tcx20_enc() * diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index c40c7aa59b69ce9f354cd0568c6ea84b9011387f..ccbcf00dce75f59a1d4fdef92071064b3e79f8ac 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -104,6 +104,9 @@ ivas_error init_encoder( st->clas = UNVOICED_CLAS; st->low_rate_mode = 0; st->ini_frame = 0; +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + st->inactive_coder_type_flag = 0; +#endif st->coder_type_raw = VOICED; st->last_coder_type_raw = st->coder_type_raw; diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 3fdb704672ce3702de794eef9829a6a96397b87f..fec16a8a9e2440c163cf3244331029f95476f8c4 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -196,7 +196,11 @@ ivas_error ivas_core_enc( diff_nBits = 0; if ( hCPE != NULL && hCPE->element_mode == IVAS_CPE_DFT && hCPE->brate_surplus > 0 ) { +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, sts[0]->total_brate, &( sts[0]->core_brate ), &( sts[0]->inactive_coder_type_flag ), &diff_nBits ); +#else ivas_combined_format_brate_sanity( hCPE->element_brate, sts[0]->core, &( sts[0]->core_brate ), &diff_nBits ); +#endif } /*---------------------------------------------------------------------* diff --git a/lib_enc/ivas_decision_matrix_enc.c b/lib_enc/ivas_decision_matrix_enc.c index e4447a15566ee50b975f24500b1b7daa708efe39..9ceab1b5af7227a31ed51886ef3343c11ea62a70 100644 --- a/lib_enc/ivas_decision_matrix_enc.c +++ b/lib_enc/ivas_decision_matrix_enc.c @@ -364,6 +364,18 @@ void ivas_decision_matrix_enc( st->last_extl = st->extl; } +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + /*-----------------------------------------------------------------* + * set inactive coder_type flag in ACELP core + *-----------------------------------------------------------------*/ + + st->inactive_coder_type_flag = 0; /* AVQ by default */ + if ( st->total_brate <= MAX_GSC_INACTIVE_BRATE ) + { + st->inactive_coder_type_flag = 1; /* GSC */ + } +#endif + return; } diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 0b1772ec9bff63fb85c4bdb475e74e1646327f44..c2b2e4c611c52c05c90f0b49741e639665f0f66c 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1167,6 +1167,9 @@ typedef struct enc_core_structure int16_t Opt_SC_VBR; /* flag indicating SC-VBR mode */ int16_t last_Opt_SC_VBR; /* flag indicating prev frame's SC-VBR mode */ int16_t low_rate_mode; /* low-rate mode flag */ +#ifdef NONBE_FIX_797_OMASA_INACTIVE_SEP_OBJ + int16_t inactive_coder_type_flag; /* inactive coder type flag (0 = AVQ / 1 = GSC) */ +#endif #ifdef DEBUGGING int16_t force; /* flag indicating specific signal type (0 = speech, 1 = music, -1 = N/A) */ #endif