Commit 33b110c9 authored by Arash Azizi's avatar Arash Azizi
Browse files

issue: 2479 changes required to harmonize function pair tcx_ltp_pitch_search_fx()

parent 398d808c
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@
#define FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC            /* Nokia: Fix to convert non-converted binary operations */
#define FIX_2455_HARMONIZE_generate_comfort_noise_enc /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */
#define FIX_2455_HARMONIZE_configureFdCngEnc          /* FhG: harmonize generate_comfort_noise_enc and generate_comfort_noise_enc_ivas */
#define FIX_2479_HARM_PITCH_GAIN                        /* FhG: basop issue 2479: Harmonize tcx_ltp_pitch_search_*(), tcx_ltp_find_gain_*fx() */

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

+91 −13
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ static Word32 interpolate_corr(

    return s;
}

#ifndef FIX_2479_HARM_PITCH_GAIN
static void tcx_ltp_pitch_search(
    Word16 pitch_ol,
    Word16 *pitch_int,
@@ -278,6 +278,9 @@ static void tcx_ltp_pitch_search(
    }
}


#endif // !FIX_2479_HARM_PITCH_GAIN
#ifndef FIX_2479_HARM_PITCH_GAIN
static void tcx_ltp_pitch_search_ivas_fx(
    const Word16 pitch_ol,
    Word16 *pitch_int,
@@ -293,6 +296,24 @@ static void tcx_ltp_pitch_search_ivas_fx(
    const Word16 pitres,
    const Word16 check_border_case,
    Word16 *border_case )
#else
static void tcx_ltp_pitch_search_fx(
    const Word16 pitch_ol,
    Word16* pitch_int,
    Word16* pitch_fr,
    Word16* index,
    Word16* norm_corr,
    const Word16 len,
    const Word16* wsp, // Qx
    const Word16 pitmin,
    const Word16 pitfr1,
    const Word16 pitfr2,
    const Word16 pitmax,
    const Word16 pitres,
    const Word16 check_border_case,
    Word16* border_case,
    Word16 element_mode)
#endif // !FIX_2479_HARM_PITCH_GAIN
{
    Word16 i, t, t0, t1, step, fraction, t0_min, t0_max, t_min, t_max, delta, temp_m, temp_e, s, s_wsp;
    Word16 cor_idx_ini, cor_idx;
@@ -328,6 +349,12 @@ static void tcx_ltp_pitch_search_ivas_fx(
    t_max = add( t0_max, L_INTERPOL1 );

    /* normalize wsp */
#ifdef FIX_2479_HARM_PITCH_GAIN
    IF(EQ_16(element_mode, EVS_MONO)) {
        assert(len + t_max <= L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1);
    }
#endif // FIX_2479_HARM_PITCH_GAIN

    s_wsp = getScaleFactor16( wsp - t_max, add( len, t_max ) );
    s_wsp = sub( s_wsp, 4 );
    FOR( t = negate( t_max ); t < len; t++ )
@@ -336,9 +363,14 @@ static void tcx_ltp_pitch_search_ivas_fx(
        move16();
    }
    wsp = wsp2 + t_max;
#ifdef FIX_2479_HARM_PITCH_GAIN
    move16();
#endif // FIX_2479_HARM_PITCH_GAIN

    pt_cor = cor;

#ifdef FIX_2479_HARM_PITCH_GAIN
    move32();
#endif // FIX_2479_HARM_PITCH_GAIN
    FOR( t = t_min; t <= t_max; t++ )
    {
        *pt_cor = dot( wsp, wsp - t, len ); // 2*(x + s_wsp)
@@ -350,6 +382,10 @@ static void tcx_ltp_pitch_search_ivas_fx(
    cor_max = L_add( *pt_cor++, 0 );
    t1 = t0_min;
    move16();
#ifdef FIX_2479_HARM_PITCH_GAIN
    move32();
#endif // FIX_2479_HARM_PITCH_GAIN


    FOR( t = t0_min + 1; t <= t0_max; t++ )
    {
@@ -385,7 +421,7 @@ static void tcx_ltp_pitch_search_ivas_fx(
    temp_e = sub( negate( s ), temp_e );

    *norm_corr = shl_sat( temp_m, temp_e );

#ifndef FIX_2479_HARM_PITCH_GAIN
    test();
    IF(check_border_case&& EQ_16(t1, t0_min))
    {
@@ -401,6 +437,26 @@ static void tcx_ltp_pitch_search_ivas_fx(
            }
        }
    }
#else
    IF(NE_16(element_mode, EVS_MONO)) {
        test();
        IF(check_border_case && EQ_16(t1, t0_min))
        {
            Word32 tmpCor;
            FOR(t = t1 - L_INTERPOL1; t < t1; t++)
            {
                tmpCor = dot(wsp, wsp - t, len);
                IF(GT_32(tmpCor, cor_max))
                {
                    *border_case = 1;
                    move16();
                    BREAK;
                }
            }
        }
    }
#endif // !FIX_2479_HARM_PITCH_GAIN


    IF( GE_16( t1, pitfr1 ) )
    {
@@ -630,7 +686,11 @@ void tcx_ltp_encode_fx(
    Word16 buf_zir[M + L_SUBFR], *zir;
    Word16 Aest[M + 1];
    Word16 alpha, step;

#ifdef FIX_2479_HARM_PITCH_GAIN
    Word16 leg_flag;
    leg_flag = 1;
    Word16 border_case;
#endif // FIX_2479_HARM_PITCH_GAIN
    norm_corr = 0;
    move16();

@@ -662,7 +722,12 @@ void tcx_ltp_encode_fx(
        }

        /* Find pitch lag */
#ifndef FIX_2479_HARM_PITCH_GAIN
        tcx_ltp_pitch_search(Top, pitch_int, pitch_fr, &ltp_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres);
#else
        tcx_ltp_pitch_search_fx(Top, pitch_int, pitch_fr, &ltp_param[1], &norm_corr, L_frame, wsp, pitmin, pitfr1, pitfr2, pitmax, pitres, 1, &border_case, leg_flag);
#endif // !FIX_2479_HARM_PITCH_GAIN

        
        nPrevSubblocks = extract_h( L_mac( 0x17fff, NSUBBLOCKS, div_s( *pitch_int, L_frame ) ) );
        nPrevSubblocks = add( s_min( nPrevSubblocks, NSUBBLOCKS ), 1 );
@@ -957,7 +1022,11 @@ void tcx_ltp_encode_ivas_fx(
            IF( LT_16( abs_s( sub( Top[0], Top[1] ) ), shr( delta, 1 ) ) )
            {
                /* estimates are close enough and stable, take the artihmetic mean as estimate */
#ifndef FIX_2479_HARM_PITCH_GAIN
                tcx_ltp_pitch_search_ivas_fx(shr(add(Top[0], Top[1]), 1), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, &ltp_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case);
#else
               tcx_ltp_pitch_search_fx(shr(add(Top[0], Top[1]), 1), &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, &ltp_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case, element_mode);
#endif // !FIX_2479_HARM_PITCH_GAIN
            }
            ELSE
            {
@@ -969,7 +1038,12 @@ void tcx_ltp_encode_ivas_fx(

                FOR( i = 0; i < 2; i++ )
                {
#ifndef FIX_2479_HARM_PITCH_GAIN
                    tcx_ltp_pitch_search_ivas_fx(Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case);
#else
                    tcx_ltp_pitch_search_fx(Top[i], &pitch_int_2[i], &pitch_fr_2[i], &pit_param_2[i], &norm_corr_2_fx[i], L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, 1, &border_case, element_mode);
#endif // !FIX_2479_HARM_PITCH_GAIN

                                    }

                IF( GT_16( norm_corr_2_fx[1], norm_corr_2_fx[0] ) )
@@ -1004,7 +1078,11 @@ void tcx_ltp_encode_ivas_fx(
                tmp = 0;
            }
            move16();
#ifndef FIX_2479_HARM_PITCH_GAIN
            tcx_ltp_pitch_search_ivas_fx(Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, &ltp_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, tmp, &border_case);
#else
            tcx_ltp_pitch_search_fx(Top[1], &hTcxEnc->tcxltp_pitch_int, &hTcxEnc->tcxltp_pitch_fr, &ltp_param[1], &norm_corr_fx, L_frame, wsp_fx, st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max, tmp, &border_case, element_mode);
#endif // !FIX_2479_HARM_PITCH_GAIN
        }

        if ( border_case )