Commit 41570121 authored by fotopoulou's avatar fotopoulou
Browse files

Merge branch '221-use-of-uninitialized-value-in-stereo-br-switching' of...

Merge branch '221-use-of-uninitialized-value-in-stereo-br-switching' of forge.3gpp.org:ivas-codec-pc/ivas-codec into 221-use-of-uninitialized-value-in-stereo-br-switching
parents 49381384 d0c500d3
Loading
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -1424,7 +1424,6 @@ void stereo_switching_dec(

            sts[0]->tilt_code = 0.0f;
            sts[0]->gc_threshold = 0.0f;
            /*init_gp_clip( sts[1]->clip_var );*/

            set_f( sts[0]->mem_syn1, 0, M );
            set_f( sts[0]->mem_syn2, 0, M );
@@ -1454,7 +1453,6 @@ void stereo_switching_dec(

        sts[1]->tilt_code = 0.0f;
        sts[1]->gc_threshold = 0.0f;
        /*init_gp_clip( sts[1]->clip_var );*/

        set_f( sts[1]->mem_syn1, 0, M );
        set_f( sts[1]->mem_syn2, 0, M );
@@ -1471,20 +1469,24 @@ void stereo_switching_dec(
        {
            sts[1]->last_core = sts[0]->last_core;
            sts[1]->last_coder_type = sts[0]->last_coder_type;
#ifndef FIX_221_BR_SWITCH_STEREO
            sts[1]->hTcxCfg->last_aldo = sts[0]->hTcxCfg->last_aldo;
            sts[1]->hTcxCfg->tcx_curr_overlap_mode = sts[0]->hTcxCfg->tcx_curr_overlap_mode;
#endif

            mvr2r( sts[0]->hHQ_core->old_out, sts[1]->hHQ_core->old_out, L_FRAME48k );
            mvr2r( sts[0]->delay_buf_out, sts[1]->delay_buf_out, HQ_DELTA_MAX * HQ_DELAY_COMP );
            mvr2r( sts[0]->hTcxDec->old_syn_Overl, sts[1]->hTcxDec->old_syn_Overl, 256 );
            /* Todo: apply panning to buffers instead of simply using dmx in left and right channel */

#ifndef FIX_221_BR_SWITCH_STEREO
            sts[1]->fscale = sts[0]->fscale;
            sts[1]->hTcxCfg->tcx_mdct_window_length = sts[0]->hTcxCfg->tcx_mdct_window_length;
            sts[1]->pit_res_max = sts[0]->pit_res_max;
            sts[1]->pit_res_max_past = sts[0]->pit_res_max_past;
            sts[1]->hTcxDec->L_frameTCX = sts[0]->hTcxDec->L_frameTCX;
            sts[1]->hTcxDec->conceal_eof_gain = sts[0]->hTcxDec->conceal_eof_gain;
#endif
        }
    }
    else if ( hCPE->element_mode == IVAS_CPE_TD && hCPE->last_element_mode == IVAS_CPE_MDCT )
@@ -1492,8 +1494,10 @@ void stereo_switching_dec(
        set_f( sts[0]->old_exc, 0.0f, L_EXC_MEM_DEC );
        set_f( sts[1]->old_exc, 0.0f, L_EXC_MEM_DEC );
    }

#ifdef FIX_221_BR_SWITCH_STEREO
    else if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->last_element_mode == IVAS_CPE_TD )
    /* TD/DFT -> MDCT stereo switching (there is no TCX in the TD stereo secondary channel, or DFT stereo) */
    if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->last_element_mode != IVAS_CPE_MDCT )
    {
        sts[1]->hTcxCfg->last_aldo = sts[0]->hTcxCfg->last_aldo;
        sts[1]->hTcxCfg->tcx_curr_overlap_mode = sts[0]->hTcxCfg->tcx_curr_overlap_mode;
+7 −5
Original line number Diff line number Diff line
@@ -758,11 +758,8 @@ void stereo_switching_enc(

        /* no secondary channel in the previous frame -> memory resets */
        set_zero( sts[1]->old_inp_12k8, L_INP_MEM );
        /*set_zero( sts[1]->old_inp_16k, L_INP_MEM );*/
        set_zero( sts[1]->mem_decim, 2 * L_FILT_MAX );
        /*set_zero( sts[1]->mem_decim16k, 2*L_FILT_MAX );*/
        sts[1]->mem_preemph = 0;
        /*sts[1]->mem_preemph16k = 0;*/

        set_zero( sts[1]->buf_speech_enc, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k );
        set_zero( sts[1]->buf_speech_enc_pe, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k );
@@ -812,14 +809,16 @@ void stereo_switching_enc(
                sts[1]->input[-sts[0]->encoderLookahead_FB + i] = ( ( sts[0]->encoderLookahead_FB - i ) * sts[0]->input[-sts[0]->encoderLookahead_FB + i] + i * sts[1]->input[-sts[0]->encoderLookahead_FB + i] ) * tmpF;
                sts[0]->input[-sts[0]->encoderLookahead_FB + i] = ( ( sts[0]->encoderLookahead_FB - i ) * sts[0]->input[-sts[0]->encoderLookahead_FB + i] + i * sts[1]->input[-2 * sts[0]->encoderLookahead_FB + i] ) * tmpF;
            }
            /* restore continous signal in right channel (part of old_output was used to store original left channel) */
            /* restore continuous signal in right channel (part of old_output was used to store original left channel) */
            mvr2r( sts[0]->input - sts[0]->hTcxEnc->L_frameTCX, sts[1]->input - sts[0]->hTcxEnc->L_frameTCX, sts[0]->hTcxEnc->L_frameTCX - sts[0]->encoderLookahead_FB );

            sts[1]->last_core = sts[0]->last_core;
            sts[1]->last_coder_type = sts[0]->last_coder_type;
            sts[1]->last_bwidth = sts[0]->last_bwidth;
#ifndef FIX_221_BR_SWITCH_STEREO
            sts[1]->hTcxCfg->last_aldo = sts[0]->hTcxCfg->last_aldo;
            sts[1]->hTcxCfg->tcx_curr_overlap_mode = sts[0]->hTcxCfg->tcx_curr_overlap_mode;
#endif
        }
    }
    else if ( hCPE->element_mode == IVAS_CPE_TD && hCPE->last_element_mode == IVAS_CPE_MDCT )
@@ -827,12 +826,15 @@ void stereo_switching_enc(
        set_f( sts[0]->hLPDmem->old_exc, 0.0f, L_EXC_MEM );
        set_f( sts[1]->hLPDmem->old_exc, 0.0f, L_EXC_MEM );
    }

#ifdef FIX_221_BR_SWITCH_STEREO
    else if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->last_element_mode == IVAS_CPE_TD )
    /* TD/DFT -> MDCT stereo switching (there is no TCX in the TD stereo secondary channel, or DFT stereo) */
    if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->last_element_mode != IVAS_CPE_MDCT )
    {
        sts[1]->hTcxCfg->last_aldo = sts[0]->hTcxCfg->last_aldo;
        sts[1]->hTcxCfg->tcx_curr_overlap_mode = sts[0]->hTcxCfg->tcx_curr_overlap_mode;
    }
#endif

    return;
}