Commit 39972794 authored by kinuthia's avatar kinuthia
Browse files

fix ASAN errors: backport fixes 1033, 976

parent bfb495d3
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -61,6 +61,8 @@
#define NON_BE_FIX_1048_THRESHOLD_COH_BASOP             /* Nokia: Fix 1048 replace comparison with 0 with comparison to threshold, to align with BASOP*/
#define NONBE_FIX_1054_NEGATIVE_LVQ_INDEX               /* Nokia: issue 1054: Input to decode_comb in deindex_lvq_SHB should be positive */
#define NONBE_FIX_738_QUATERNION_SLERP_PRECISION        /* Philips: issue 738: Quaternion spherical linear interpolation precision handling issues */
#define FIX_1033_MEMORY_LEAK_OMASA                      /* Nokia / Orange: issue #1033: Memory leak in OMASA to BINAURAL with HRTF with bitrate switching */
#define FIX_976_USAN_PVQ_ENC_DEC_EVS_CR                 /* Ericsson:  premature cast to unsigned detected by USAN corrected  */
/* #################### End FIXES switches ############################ */

#define BASOP_NOGLOB                                    /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */
+9 −2
Original line number Diff line number Diff line
@@ -1140,8 +1140,15 @@ static ivas_error ivas_mc_dec_reconfig(

            if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) )
            {
#ifdef FIX_1033_MEMORY_LEAK_OMASA
                if ( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE )
                {
#endif
                    ivas_td_binaural_close( &st_ivas->hBinRendererTd );
                    st_ivas->hHrtfTD = NULL;
#ifdef FIX_1033_MEMORY_LEAK_OMASA
                }
#endif
            }

            if ( st_ivas->hDiracDecBin != NULL )
+19 −4
Original line number Diff line number Diff line
@@ -310,10 +310,17 @@ ivas_error ivas_omasa_dec_config(
            if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
            {
                /* Allocate TD renderer for the objects in DISC mode */
#ifdef FIX_1033_MEMORY_LEAK_OMASA
                if ( st_ivas->hBinRendererTd == NULL )
                {
#endif
                    if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }
#ifdef FIX_1033_MEMORY_LEAK_OMASA
                }
#endif

                /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
                if ( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ) != IVAS_ERR_OK )
@@ -324,8 +331,16 @@ ivas_error ivas_omasa_dec_config(
            else
            {
                /* TD renderer handle */
#ifdef FIX_1033_MEMORY_LEAK_OMASA
                if ( st_ivas->hBinRendererTd != NULL && st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE )
                {
#endif
                    /* TD renderer handle */
                    ivas_td_binaural_close( &st_ivas->hBinRendererTd );
                    st_ivas->hHrtfTD = NULL;
#ifdef FIX_1033_MEMORY_LEAK_OMASA
                }
#endif

                /* ISM renderer handle + ISM data handle */
                ivas_omasa_separate_object_renderer_close( st_ivas );
+18 −1
Original line number Diff line number Diff line
@@ -109,8 +109,17 @@ static void pvq_decode_band(

    for ( j = 0; j < Np; j++ )
    {
        g_part[j] = -( (float) g_part_s[j] ) / 32768;
#ifdef FIX_976_USAN_PVQ_ENC_DEC_EVS_CR
        /* note: here  g_part   needs to be become exactly  1.0(float) thus in BASOP  Word16 g_part_s is in the negative Q15 domain */
#endif


#ifdef FIX_976_USAN_PVQ_ENC_DEC_EVS_CR
        /* aligned to BASOP to avoid USAN undefined negation warning for -(-32768) */
        g_part_s[j] = negate( g_part_s[j] );
#else
        g_part_s[j] = -g_part_s[j];
#endif
    }

    srt_vec_ind( g_part_s, sg_part, idx_sort, Np );
@@ -416,7 +425,11 @@ static void densitySymbolIndexDecode(
    {
        tot = res * ( res + 1 ) + 1;
        dec_freq = rc_decode( &st->BER_detect, hPVQ, tot );
#ifdef FIX_976_USAN_PVQ_ENC_DEC_EVS_CR
        alpha = (int16_t) floor_sqrt_exact( (uint32_t) ( ( res + 1 ) * ( res + 1 ) - dec_freq ) ) + res + 1;
#else
        alpha = (int16_t) floor_sqrt_exact( (uint32_t) ( res + 1 ) * ( res + 1 ) - dec_freq ) + res + 1;
#endif
        sym_freq = 2 * ( res - alpha ) + 1;
        cum_freq = alpha * ( 2 * ( res + 1 ) - alpha );
    }
@@ -434,7 +447,11 @@ static void densitySymbolIndexDecode(
        dec_freq = rc_decode( &st->BER_detect, hPVQ, tot );
        if ( dec_freq < tot - ( res + 1 ) - ( res - ( c + 1 ) ) * ( res - c ) * c + c + 1 )
        {
#ifdef FIX_976_USAN_PVQ_ENC_DEC_EVS_CR
            alpha = ( res_c - 1 + (int16_t) floor_sqrt_exact( (uint32_t) ( res_c * ( res_c + 4 * dec_freq - 2 ) + 1 ) ) ) / ( 2 * res_c );
#else
            alpha = ( res_c - 1 + (int16_t) floor_sqrt_exact( (uint32_t) res_c * ( res_c + 4 * dec_freq - 2 ) + 1 ) ) / ( 2 * res_c );
#endif
            sym_freq = 2 * alpha * res_c + 1;
            cum_freq = alpha * ( ( alpha - 1 ) * res_c + 1 );
        }
+5 −0
Original line number Diff line number Diff line
@@ -121,7 +121,12 @@ static void pvq_encode_band(
    for ( j = 0; j < Np; j++ )
    {
        g_part[j] = -( (float) g_part_s[j] ) / 32768;
#ifdef FIX_976_USAN_PVQ_ENC_DEC_EVS_CR
        /* aligned to BASOP to avoid USAN undefined negation warning with -(-32768) */
        g_part_s[j] = negate( g_part_s[j] );
#else
        g_part_s[j] = -g_part_s[j];
#endif
    }

    srt_vec_ind( g_part_s, sg_part, idx_sort, Np );