Commit 83f352f2 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch '798-instability-in-right-channel-of-td-stereo-at-24-4kbps' into 'main'

798 Fix proposal, modifications under FIX_798_LSF_SECONDARY_CH_MISSING_CODE...

See merge request !386
parents 82ff6a30 c310371e
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -823,7 +823,7 @@ ivas_error config_acelp1(

            bits -= acelp_cfg->mid_lsf_bits;
        }
#ifdef LSF_RE_USE_SECONDARY_CHANNEL
#if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE
        else if ( tdm_lp_reuse_flag == 1 && idchan == 1 && active_cnt != 1 )
        {
            bits -= TDM_IC_LSF_PRED_BITS;
@@ -1384,7 +1384,7 @@ ivas_error config_acelp1(
        {
            if ( idchan > 0 && element_mode == IVAS_CPE_TD )
            {
#ifdef LSF_RE_USE_SECONDARY_CHANNEL
#if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE
                if ( !tdm_lp_reuse_flag )
                {
                    acelp_cfg->lsf_bits += bits; /* increase LSF Q bits */
+13 −9
Original line number Diff line number Diff line
@@ -835,8 +835,12 @@ void td_stereo_param_updt_fx(
    Word16 tdm_lsfQ_PCh[],            /* o  : Q LSFs for primary channel              */
    Word16 tdm_Pri_pitch_buf[],       /* o  : pitch values for primary channel        */
    const Word16 flag_ACELP16k,       /* i  : ACELP@16kHz flag                        */
    const Word16 tdm_use_IAWB_Ave_lpc, /* i  : flag to indicate the usage of mean inactive LP coefficients */
    Word16 Q_var );
    const Word16 tdm_use_IAWB_Ave_lpc /* i  : flag to indicate the usage of mean inactive LP coefficients */
#ifndef FIX_798_WRONG_CPY_OF_PITCH
    ,
    Word16 Q_var
#endif
);

void updateBuffersForDmxMdctStereo_fx(
    CPE_DEC_HANDLE hCPE,                      /* i/o: CPE handle                              */
+31 −10
Original line number Diff line number Diff line
@@ -871,8 +871,12 @@ void td_stereo_param_updt_fx(
    Word16 tdm_lsfQ_PCh_fx[],         /* o  : Q LSFs for primary channel    Qx2.56*/
    Word16 tdm_Pri_pitch_buf_fx[],    /* o  : pitch values for primary channel    Q_var */
    const Word16 flag_ACELP16k,       /* i  : ACELP@16kHz flag                    */
    const Word16 tdm_use_IAWB_Ave_lpc, /* i  : flag to indicate the usage of mean inactive LP coefficients */
    Word16 Q_var )
    const Word16 tdm_use_IAWB_Ave_lpc /* i  : flag to indicate the usage of mean inactive LP coefficients */
#ifndef FIX_798_WRONG_CPY_OF_PITCH
    ,
    Word16 Q_var
#endif
)
{
    Word16 i;
    /* Copy some primary channel information into the secondary channel structure for later usage */
@@ -893,7 +897,24 @@ void td_stereo_param_updt_fx(
        Copy( lsp_old_PCh_fx, tdm_lspQ_PCh_fx, M );
        Copy( lsf_old_PCh_fx, tdm_lsfQ_PCh_fx, M );
    }
#ifdef FIX_798_WRONG_CPY_OF_PITCH
    IF( EQ_16( flag_ACELP16k, 1 ) )
    {
        Word16 tmp16;
        Word16 mult_factor = 26214 /*0.8f in Q15*/;
        FOR( i = 0; i < NB_SUBFR; i++ )
        {
            tmp16 = mult_r( pitch_buf_PCh_fx[i], mult_factor );     /* Convert 16kHz to 12.8 kHz pitch values */
            tdm_Pri_pitch_buf_fx[i] = s_max( tmp16, PIT_MIN << 6 ); /* pitch is represented in Q6*/
            move16();
        }
    }
    ELSE
    {
        Copy( pitch_buf_PCh_fx, tdm_Pri_pitch_buf_fx, NB_SUBFR );
    }

#else
    /* This is only to keep the buffer up-to-date */
    Word16 mult_factor = 26214 /*0.8f in Q15*/;
    Word16 min_tdm_Pri_pitch_buf_fx = 0;
@@ -919,7 +940,7 @@ void td_stereo_param_updt_fx(
    {
        Copy( pitch_buf_PCh_fx, tdm_Pri_pitch_buf_fx, NB_SUBFR );
    }

#endif
    return;
}
#endif
+2 −0
Original line number Diff line number Diff line
@@ -146,6 +146,8 @@
#define FIX_778_STEREO_BRATE_SWITCHING
#define FIX_774_ENERGY_BURST                    /* Fix 0 bit BWE */
#define FIX_729_MISSING_RESCALING
#define FIX_798_LSF_SECONDARY_CH_MISSING_CODE  /* Adding the missing code to properly render the secondary channel of TD stereo*/
#define FIX_798_WRONG_CPY_OF_PITCH             /* The copy of the pitch from primary to secondary channel was wrong AND safety check was really wrong */
/* ################## End DEVELOPMENT switches ######################### */

/* clang-format on */
+3 −3
Original line number Diff line number Diff line
@@ -5501,7 +5501,7 @@ void lsf_dec_fx(
    Word16 *lsp_new,               /* o  : de-quantized LSP vector                     */
    Word16 *lsp_mid,               /* o  : de-quantized mid-frame LSP vector    */
    const Word16 tdm_low_rate_mode /* i  : secondary channel low rate mode flag */
#ifdef LSF_RE_USE_SECONDARY_CHANNEL
#if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE
    ,
    const Word16 tdm_lsfQ_PCh[M] /* i  : Q LSFs for primary channel          */
#endif
@@ -5615,9 +5615,9 @@ void lsf_end_dec_fx(
    Word16 *lpc_param,
    Word16 *LSF_Q_prediction, /* o  : LSF prediction mode                     */
    Word16 *nb_indices
#ifdef LSF_RE_USE_SECONDARY_CHANNEL
#if defined LSF_RE_USE_SECONDARY_CHANNEL || defined FIX_798_LSF_SECONDARY_CH_MISSING_CODE
    ,
    const float tdm_lsfQ_PCh[M]
    const Word16 tdm_lsfQ_PCh[M]
#endif
);

Loading