static int kalman_smoothen(WMAVoiceContext *s, int pitch,

                           const float *in, float *out, int size)

{

    int n;

    float optimal_gain = 0, dot;

    const float *ptr = &in[-FFMAX(s->min_pitch_val, pitch - 3)],

                *end = &in[-FFMIN(s->max_pitch_val, pitch + 3)],

                *best_hist_ptr;



    /* find best fitting point in history */

    do {

        dot = ff_scalarproduct_float_c(in, ptr, size);

        if (dot > optimal_gain) {

            optimal_gain  = dot;

            best_hist_ptr = ptr;

        }

    } while (--ptr >= end);



    if (optimal_gain <= 0)

        return -1;

    dot = ff_scalarproduct_float_c(best_hist_ptr, best_hist_ptr, size);

    if (dot <= 0) // would be 1.0

        return -1;



    if (optimal_gain <= dot) {

        dot = dot / (dot + 0.6 * optimal_gain); // 0.625-1.000

    } else

        dot = 0.625;



    /* actual smoothing */

    for (n = 0; n < size; n++)

        out[n] = best_hist_ptr[n] + dot * (in[n] - best_hist_ptr[n]);



    return 0;

}

static int kalman_smoothen(WMAVoiceContext *s, int pitch,

                           const float *in, float *out, int size)

{

    int n;

    float optimal_gain = 0, dot;

    const float *ptr = &in[-FFMAX(s->min_pitch_val, pitch - 3)],

                *end = &in[-FFMIN(s->max_pitch_val, pitch + 3)],

                *best_hist_ptr;



    

    do {

        dot = ff_scalarproduct_float_c(in, ptr, size);

        if (dot > optimal_gain) {

            optimal_gain  = dot;

            best_hist_ptr = ptr;

        }

    } while (--ptr >= end);



    if (optimal_gain <= 0)

        return -1;

    dot = ff_scalarproduct_float_c(best_hist_ptr, best_hist_ptr, size);

    if (dot <= 0) 

        return -1;



    if (optimal_gain <= dot) {

        dot = dot / (dot + 0.6 * optimal_gain); 

    } else

        dot = 0.625;



    

    for (n = 0; n < size; n++)

        out[n] = best_hist_ptr[n] + dot * (in[n] - best_hist_ptr[n]);



    return 0;

}

                *best_hist_ptr;
static int FUNC_0(WMAVoiceContext *VAR_0, int VAR_1,

                           const float *VAR_2, float *VAR_3, int VAR_4)

{

    int VAR_5;

    float VAR_6 = 0, VAR_7;

    const float *VAR_8 = &VAR_2[-FFMAX(VAR_0->min_pitch_val, VAR_1 - 3)],

                *VAR_9 = &VAR_2[-FFMIN(VAR_0->max_pitch_val, VAR_1 + 3)],

                *VAR_10;



    

    do {

        VAR_7 = ff_scalarproduct_float_c(VAR_2, VAR_8, VAR_4);

        if (VAR_7 > VAR_6) {

            VAR_6  = VAR_7;

            VAR_10 = VAR_8;

        }

    } while (--VAR_8 >= VAR_9);



    if (VAR_6 <= 0)

        return -1;

    VAR_7 = ff_scalarproduct_float_c(VAR_10, VAR_10, VAR_4);

    if (VAR_7 <= 0) 

        return -1;



    if (VAR_6 <= VAR_7) {

        VAR_7 = VAR_7 / (VAR_7 + 0.6 * VAR_6); 

    } else

        VAR_7 = 0.625;



    

    for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++)

        VAR_3[VAR_5] = VAR_10[VAR_5] + VAR_7 * (VAR_2[VAR_5] - VAR_10[VAR_5]);



    return 0;

}

static int FUNC_0(WMAVoiceContext *VAR_0, int VAR_1,
const float *VAR_2, float *VAR_3, int VAR_4)
{ int VAR_5; float VAR_6 = 0, VAR_7; const float *VAR_8 = &VAR_2[-FFMAX(VAR_0->min_pitch_val, VAR_1 - 3)],
*VAR_9 = &VAR_2[-FFMIN(VAR_0->max_pitch_val, VAR_1 + 3)],
*VAR_10; do { VAR_7 = ff_scalarproduct_float_c(VAR_2, VAR_8, VAR_4); if (VAR_7 > VAR_6) { VAR_6  = VAR_7; VAR_10 = VAR_8; } } while (--VAR_8 >= VAR_9); if (VAR_6 <= 0)
return -1; VAR_7 = ff_scalarproduct_float_c(VAR_10, VAR_10, VAR_4); if (VAR_7 <= 0)
return -1; if (VAR_6 <= VAR_7) { VAR_7 = VAR_7 / (VAR_7 + 0.6 * VAR_6); } else VAR_7 = 0.625; for (VAR_5 = 0; VAR_5 < VAR_4; VAR_5++) VAR_3[VAR_5] = VAR_10[VAR_5] + VAR_7 * (VAR_2[VAR_5] - VAR_10[VAR_5]); return 0; }