Commit 30efc029 authored by vaclav's avatar vaclav
Browse files

Merge branch '1384-msan-clang-18-use-of-uninitialized-value-in-stereo_tcx_core_enc' into 'main'

Fix [MSAN Clang 18] use-of-uninitialized-value in stereo_tcx_core_enc

See merge request !2248
parents f1805395 3a7ed8a3
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@
#define FIX_1377_HANDLE_ERROR_CODE                      /* Eri: Add missing error code handling from IVAS_REND_SetObjectIDs */
#define FIX_HRTF_LEFTOVERS                              /* VA: HRTF updates - bring float main in line with BASOP main */
#define FIX_1384_MSAN_ivas_spar_dec_open                /* VA: issue 1386: fix use-of-uninitialized value in ivas_spar_dec_open() */
#define FIX_1384_MSAN_stereo_tcx_core_enc               /* VA: issue 1384: fix use-of-uninitialized value in stereo_tcx_core_enc() */

/* #################### End BE switches ################################## */

+31 −2
Original line number Diff line number Diff line
@@ -277,7 +277,7 @@ void stereo_tcx_core_dec(
    }

    /*--------------------------------------------------------------------------------*
     * LPC PARAMETERS
     * LPC envelope decoding
     *--------------------------------------------------------------------------------*/

    st->acelp_cfg.midLpc = 0;
@@ -288,6 +288,9 @@ void stereo_tcx_core_dec(
        {
            int16_t tcx_lpc_cdk;

#ifdef FIX_1384_MSAN_stereo_tcx_core_enc
            tcx_lpc_cdk = tcxlpc_get_cdk( st->coder_type );
#else
            if ( bfi && st->use_partial_copy && st->rf_frame_type == RF_TCXFD )
            {
                tcx_lpc_cdk = tcxlpc_get_cdk( GENERIC );
@@ -296,6 +299,7 @@ void stereo_tcx_core_dec(
            {
                tcx_lpc_cdk = tcxlpc_get_cdk( st->coder_type );
            }
#endif

            mvr2r( st->lsf_old, &lsf[0], M );
            mvr2r( st->lsp_old, &lsp[0], M );
@@ -394,10 +398,12 @@ void stereo_tcx_core_dec(
        lsp2a_stab( st->lsp_old, st->old_Aq_12_8, M );
    }

#ifndef FIX_1384_MSAN_stereo_tcx_core_enc
    if ( st->enablePlcWaveadjust && bfi )
    {
        st->hPlcInfo->nbLostCmpt++;
    }
#endif

    /*--------------------------------------------------------------------------------*
     * TD-TCX concealment
@@ -532,6 +538,7 @@ void stereo_tcx_core_dec(

    if ( st->core == TCX_10_CORE || st->core == TCX_20_CORE )
    {
#ifndef FIX_1384_MSAN_stereo_tcx_core_enc
        if ( st->enablePlcWaveadjust ||          /* bfi      */
             ( st->last_total_brate >= HQ_48k && /* recovery */
               st->last_codec_mode == MODE2 ) )
@@ -549,6 +556,7 @@ void stereo_tcx_core_dec(
                }
            }
        }
#endif

        if ( !bfi && st->hTonalMDCTConc != NULL )
        {
@@ -673,10 +681,12 @@ void stereo_tcx_core_dec(

    if ( !bfi )
    {
#ifndef FIX_1384_MSAN_stereo_tcx_core_enc
        if ( st->enablePlcWaveadjust )
        {
            st->hPlcInfo->nbLostCmpt = 0;
        }
#endif

        if ( param[1 + NOISE_FILL_RANGES] != 0 )
        {
@@ -834,7 +844,11 @@ static void dec_prm_tcx(
    getTCXMode( st, st, 0 /* <- MCT_flag */ );

    /* last_core for error concealment */
#ifdef FIX_1384_MSAN_stereo_tcx_core_enc
    if ( st->element_mode != IVAS_CPE_MDCT )
#else
    if ( !st->use_partial_copy && st->element_mode != IVAS_CPE_MDCT )
#endif
    {
        st->last_core_from_bs = get_next_indice( st, 1 ); /* Store decoder memory of last_core */
        if ( st->last_core == ACELP_CORE && st->last_core_from_bs != ACELP_CORE )
@@ -860,8 +874,10 @@ static void dec_prm_tcx(
        }
    }

#ifndef FIX_1384_MSAN_stereo_tcx_core_enc
    if ( !st->use_partial_copy )
    {
#endif
        if ( st->element_mode != IVAS_CPE_MDCT )
        {
            getTCXWindowing( st->core, st->last_core, st->element_mode, st->hTcxCfg, st );
@@ -872,8 +888,9 @@ static void dec_prm_tcx(
        {
            st->dec_glr_idx = -1;
        }
#ifndef FIX_1384_MSAN_stereo_tcx_core_enc
    }

#endif
#ifdef DEBUG_MODE_TCX
    fprintf( pF, "\t TCX Header: %d bits: %d %d %d %d\n", st->next_bit_pos - start_bit_pos, st->tcxonly, st->core, st->tcxonly ? st->clas_dec : st->hTcxCfg->coder_type, st->hTcxCfg->tcx_curr_overlap_mode );
    nbits_tcx = st->next_bit_pos;
@@ -895,6 +912,17 @@ static void dec_prm_tcx(
     * TCX20/10 parameters
     *--------------------------------------------------------------------------------*/

#ifdef FIX_1384_MSAN_stereo_tcx_core_enc
    getTCXparam( st, st, hm_cfg, param, bits_common, start_bit_pos, NULL, NULL, NULL, -1 );

    if ( *total_nbbits - bitsRead[0] < ( st->next_bit_pos - start_bit_pos ) )
    {
        st->BER_detect = 1;
        st->next_bit_pos = start_bit_pos + *total_nbbits - bitsRead[0];
    }

    bitsRead[0] = st->next_bit_pos - start_bit_pos;
#else
    if ( st->use_partial_copy == 0 )
    {
        getTCXparam( st, st, hm_cfg, param, bits_common, start_bit_pos, NULL, NULL, NULL, -1 );
@@ -910,6 +938,7 @@ static void dec_prm_tcx(

        bitsRead[0] = st->next_bit_pos - start_bit_pos;
    }
#endif

    return;
}
+4 −1
Original line number Diff line number Diff line
@@ -310,7 +310,7 @@ void stereo_tcx_core_enc(
    }

    /*--------------------------------------------------------------*
     * Envelope Quantization and FDNS
     * LPC Envelope Quantization and FDNS
     *---------------------------------------------------------------*/

    if ( !st->enableTcxLpc )
@@ -336,6 +336,9 @@ void stereo_tcx_core_enc(
        }
    }

#ifdef FIX_1384_MSAN_stereo_tcx_core_enc
    st->acelp_cfg.midLpc = 0;
#endif
    last_core_orig = st->last_core;
    for ( n = 0; n < n_subframes; n++ )
    {