Commit 911a29a5 authored by vaclav's avatar vaclav
Browse files

Merge branch '861-masa-br-switching-crashes-with-instrumented-code' into 'main'

[Non-BE] Resolve "MASA BR switching crashes with instrumented code"

See merge request !1166
parents 084e3e7f b6a55d4b
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -172,8 +172,9 @@
#define BE_FIX_832_ASAN_ERROR_EFAP_OSBA                       /* FhG: issue #832: fix ASAN error caused by re-allocating EFAP memories in OSBA*/
#define NONBE_FIX_819_DOUBLE_PREC_COMB_FORMATS                /* VA: issue 820: Double precision arithmetic in combined formats */
#define NONBE_FIX_849_OMASA_BFI_CRASH                         /* VA: issue 849: fix OMASA 2TC and FEC crashes */

#define NONBE_UNIFIED_DECODING_PATHS                          /* FhG: unify decoding paths   */
#define NONBE_FIX_861_MASA_CRASH_STEREO_SWITCHING             /* VA: issue 861: fix MASA 2TC crash when switching from MDCT stereo to TD/DFT stereo */


/* ##################### End NON-BE switches ########################### */

+14 −4
Original line number Diff line number Diff line
@@ -111,7 +111,12 @@ int16_t select_stereo_mode(
    hStereoClassif->lrtd_mode = ( ( hStereoClassif->unclr_decision | hStereoClassif->xtalk_decision ) && is_speech );

    stereo_switching_flag = 1;

#ifdef NONBE_FIX_861_MASA_CRASH_STEREO_SWITCHING
    if ( hCPE->element_brate >= MIN_BRATE_MDCT_STEREO || ( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && ivas_total_brate < MASA_STEREO_MIN_BITRATE )
#else
    if ( hCPE->element_brate >= MIN_BRATE_MDCT_STEREO || ( ivas_format >= MASA_FORMAT && ivas_total_brate < MASA_STEREO_MIN_BITRATE )
#endif
#ifdef DEBUGGING
         || ( hCPE->stereo_mode_cmdl == IVAS_CPE_DFT || hCPE->stereo_mode_cmdl == IVAS_CPE_TD )
#endif
@@ -131,7 +136,12 @@ int16_t select_stereo_mode(
        hStereoClassif->lrtd_mode = 0;
        element_mode = IVAS_CPE_DFT;


#ifdef NONBE_FIX_861_MASA_CRASH_STEREO_SWITCHING
        if ( stereo_switching_flag == 1 && hCPE->element_brate > IVAS_13k2 && hCPE->hCoreCoder[0]->hSpMusClas->past_dlp[0] < 1.0f && hCPE->hCoreCoder[0]->hSpMusClas->wdlp_xtalk < -0.01f && hCPE->hCoreCoder[0]->vad_flag == 1 && ( hCPE->hStereoMdct->sw_uncorr || hStereoClassif->xtalk_decision ) )
#else
        if ( hCPE->element_brate > IVAS_13k2 && hCPE->hCoreCoder[0]->hSpMusClas->past_dlp[0] < 1.0f && hCPE->hCoreCoder[0]->hSpMusClas->wdlp_xtalk < -0.01f && hCPE->hCoreCoder[0]->vad_flag == 1 && ( hCPE->hStereoMdct->sw_uncorr || hStereoClassif->xtalk_decision ) )
#endif
        {
            hStereoClassif->lrtd_mode = 1;
            element_mode = IVAS_CPE_TD;
@@ -145,17 +155,16 @@ int16_t select_stereo_mode(
    }
    else if ( element_mode < IVAS_CPE_MDCT )
    {
#ifdef DEBUGGING
        if ( stereo_switching_flag == 0 )
        {
#ifdef DEBUGGING
            if ( hCPE->stereo_mode_cmdl > 1 )
            {
                element_mode = hCPE->stereo_mode_cmdl;
            }
        }
        else
#endif
            if ( element_mode == IVAS_CPE_TD )
        }
        else if ( element_mode == IVAS_CPE_TD )
        {
            if ( hCPE->hStereoTD->prev_fr_LRTD_TD_dec > 0 && is_speech )
            {
@@ -192,6 +201,7 @@ int16_t select_stereo_mode(
        if ( hCPE->last_element_mode != IVAS_CPE_DFT && hCPE->last_element_mode != IVAS_CPE_TD )
        {
            int16_t lrtd_mode = hStereoClassif->lrtd_mode;

            /* reset stereo classifier when switching from MDCT stereo to Unified stereo */
            stereo_classifier_init( hCPE->hStereoClassif );