Commit 743f12ea authored by Sandesh Venkatesh's avatar Sandesh Venkatesh Committed by Fabian Bauer
Browse files

pitch_ol precision improvements, LTV crash fix for +10dB enc stream

parent 76bda7b2
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -10052,6 +10052,12 @@ Word16 maximum_fx( /* o : index of the maximum value in t
                   Word16 *max_fx        /* o  : maximum value in the input vector              */
);
Word16 maximum_exp_fx(                        /* o  : index of the maximum value in the input vector */
                       const Word16 *vec_fx,  /* i  : input vector                                   */
                       const Word16 *exp_vec, /* i  : exponents of input vector                      */
                       const Word16 lvec_fx   /* i  : length of input vector                         */
);
Word16 maximum_abs_16_fx(                    /* o  : index of the maximum abs value in the input vector */
                          const Word16 *vec, /* i  : input vector                                   */
                          const Word16 lvec, /* i  : length of input vector                         */
+36 −1
Original line number Diff line number Diff line
@@ -1021,10 +1021,14 @@ void Scale_sig(
    }
}

/*-------------------------------------------------------------------*
 * scale_sig
 * Up/down scale a 16 bits vector
 *-------------------------------------------------------------------*/
void scale_sig(
    Word16 x[],       /* i/o: signal to scale                 Qx        */
    const Word16 lg,  /* i  : size of x[]                     Q0        */
    const Word16 exp0 /* i  : exponent: x = round(x << exp)   Qx ?exp  */
    const Word16 exp0 /* i  : exponent: x = round(x << exp)   Qx   exp  */
)
{
    Word16 i;
@@ -1230,6 +1234,37 @@ Word16 maximum_fx( /* o : index of the maximum value in t
    return ind;
}

Word16 maximum_exp_fx(                        /* o  : index of the maximum value in the input vector */
                       const Word16 *vec_fx,  /* i  : input vector                                   */
                       const Word16 *exp_vec, /* i  : exponents of input vector                      */
                       const Word16 lvec_fx   /* i  : length of input vector                         */
)
{
    Word16 j, ind;
    Word16 tmp, exp;
    ind = 0;
    move16();
    tmp = vec_fx[0];
    move16();
    exp = exp_vec[0];
    move16();

    FOR( j = 1; j < lvec_fx; j++ )
    {
        IF( LT_16( tmp, shr_sat( vec_fx[j], sub( exp, exp_vec[j] ) ) ) )
        {
            ind = j;
            move16();
            tmp = vec_fx[j];
            move16();
            exp = exp_vec[j];
            move16();
        }
    }

    return ind;
}

/*---------------------------------------------------------------------*
 * maximum_abs_16_fx()
 *
+1 −1
Original line number Diff line number Diff line
@@ -1260,7 +1260,7 @@ ivas_error pre_proc_front_ivas_fx(
    move16();

    pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx,
                      &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, *relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR );
                      &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, *relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q_wsp );
    /* Updates for adaptive lag window memory */
    st->old_pitch_la = st->pitch[2];
    move16();
+8 −8
Original line number Diff line number Diff line
@@ -73,9 +73,9 @@ ivas_error ivas_cpe_enc_fx(
    CPE_ENC_HANDLE hCPE;
    Encoder_State **sts;
    Word16 n, n_CoreChannels;
    Word32 old_inp_12k8_fx[CPE_CHANNELS][L_INP_12k8];   /* buffer of input signal @ 12k8        Q16 */
    Word32 old_inp_12k8_fx[CPE_CHANNELS][L_INP_12k8];   /* buffer of input signal @ 12k8        Q15 */
    Word16 old_inp_12k8_16fx[CPE_CHANNELS][L_INP_12k8]; /* buffer of input signal @ 12k8    Q_new-1 */
    Word32 old_inp_16k_fx[CPE_CHANNELS][L_INP];         /* buffer of input signal @ 16kHz       Q16 */
    Word32 old_inp_16k_fx[CPE_CHANNELS][L_INP];         /* buffer of input signal @ 16kHz       Q15 */
    Word16 old_inp_16k_16fx[CPE_CHANNELS][L_INP];       /* buffer of input signal @ 16kHz   Q_new-1 */
    Word16 Q_new[CPE_CHANNELS] = { 0 };
    Word16 fft_buff_fx[CPE_CHANNELS][2 * L_FFT]; /* FFT buffer                               */
@@ -759,24 +759,24 @@ ivas_error ivas_cpe_enc_fx(
        test();
        IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
        {
            Copy_Scale_sig_16_32_no_sat( sts[1]->old_inp_12k8_fx, old_inp_12k8_fx[1], L_INP_MEM, 16 - 0 );
            Copy_Scale_sig_16_32_no_sat( sts[1]->old_inp_12k8_fx, old_inp_12k8_fx[1], L_INP_MEM, 15 - 0 ); // Q15
            stereo_dft_enc_synthesize_fx( hCPE->hStereoDft, old_inp_12k8_fx[1] + L_INP_MEM, &out_12k8_start_ind[1], &out_12k8_end_ind[1], 1, input_Fs, 8000, 0, NULL );

            /* update old input signal buffer */
            Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_FRAME8k, sts[1]->old_inp_12k8_fx, L_INP_MEM, 0 - 16 );
            Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_FRAME8k, sts[1]->old_inp_12k8_fx, L_INP_MEM, 0 - 15 ); // Q0
        }
        Copy_Scale_sig32_16( sts[0]->input32_fx + out_start_ind, sts[0]->input_fx + out_start_ind, sub( out_end_ind, out_start_ind ), sub( add( Q16, sts[0]->q_inp ), Q16 ) );
        Copy_Scale_sig32_16( sts[0]->input32_fx + out_start_ind, sts[0]->input_fx + out_start_ind, sub( out_end_ind, out_start_ind ), sub( add( Q16, sts[0]->q_inp ), Q15 ) ); // Q15

        Copy_Scale_sig32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, -1 ); // Q16->Q-1
        Copy_Scale_sig32_16( old_inp_16k_fx[0], old_inp_16k_16fx[0], L_INP, 0 ); // Q15->Q-1
#ifdef IVAS_FLOAT_FIXED_CONVERSIONS
        /*local fix2flt*/
        /*fix2flt: dft_synthesize*/
        Copy_Scale_sig_32_16( old_inp_12k8_fx[0] + L_INP_MEM + out_12k8_start_ind[0], old_inp_12k8_16fx[0] + L_INP_MEM + out_12k8_start_ind[0], out_12k8_end_ind[0] - out_12k8_start_ind[0], -Q17 );
        Copy_Scale_sig_32_16( old_inp_12k8_fx[0] + L_INP_MEM + out_12k8_start_ind[0], old_inp_12k8_16fx[0] + L_INP_MEM + out_12k8_start_ind[0], out_12k8_end_ind[0] - out_12k8_start_ind[0], -Q16 ); // Q-1
        if ( hCPE->element_mode == IVAS_CPE_DFT && hCPE->hStereoDft->res_cod_mode[STEREO_DFT_OFFSET] )
        {
            sts[1]->exp_old_inp_12k8 = Q15;
            move16();
            Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_INP_MEM + out_12k8_start_ind[1], old_inp_12k8_16fx[1] + L_INP_MEM + out_12k8_start_ind[1], out_12k8_end_ind[1] - out_12k8_start_ind[1], -Q17 ); // Q-1
            Copy_Scale_sig_32_16( old_inp_12k8_fx[1] + L_INP_MEM + out_12k8_start_ind[1], old_inp_12k8_16fx[1] + L_INP_MEM + out_12k8_start_ind[1], out_12k8_end_ind[1] - out_12k8_start_ind[1], -Q16 ); // Q-1
        }
        /*fix2flt end*/
#endif
+1 −1
Original line number Diff line number Diff line
@@ -713,7 +713,7 @@ ivas_error front_vad_spar_fx(
        old_pitch = st->pitch[1];
        move16();
        Scale_sig( wsp_fx, 368, sub( Q8, Q_inp_12k8 ) );
        pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR );
        pitch_ol_ivas_fx( st->pitch, st->voicing_fx, &st->old_pitch, &st->old_corr_fx, corr_shift_fx, &st->old_thres_fx, &st->delta_pit, st->old_wsp2_fx, wsp_fx, st->mem_decim2_fx, relE_fx, st->clas, st->input_bwidth, st->Opt_SC_VBR, Q8 );
        /* Updates for adaptive lag window memory */
        st->old_pitch_la = st->pitch[2];
        move16();
Loading