Commit aff41673 authored by vaclav's avatar vaclav
Browse files

editorial improvements

parent aaf24683
Loading
Loading
Loading
Loading
+83 −20
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
/*-----------------------------------------------------------------*
 * Local Constants
 *-----------------------------------------------------------------*/

#define PIT_MIN2   20 /* pit_min for pitch tracking                                                  */
#define PIT_MIN_1  44 /* for second pitch track */
#define PIT_MIN2_1 24
@@ -57,14 +58,18 @@ static Word16 pitch_coherence_fx( Word16 pitch0, Word16 pitch1, Word16 fac_max,
static Word32 Dot_product12_OL( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 );

static Word32 Dot_product12_OL_back( Word16 *sum1, const Word16 x[], const Word16 y[], const Word16 lg, const Word16 lg2, Word16 *exp, Word16 *exp2 );

#ifdef FIX_2403_COMBINE_PITCH_OL
static void pitch_ol_resolve_fx( Word16 pitch[3], Word16 voicing[3], Word16 *old_pitch, Word16 *old_corr, Word16 *old_thres, Word16 *delta_pit, const Word16 element_mode, const Word16 corr_shift, const Word16 relE, const Word16 Opt_SC_VBR, Word16 pitchX[NHFR][2 * NSECT], Word16 corX[NHFR][2 * NSECT], Word16 scaledX[NHFR][2 * NSECT], const Word16 sect0, const Word16 *pit_max, const Word16 pit_min_coding );
#endif


/*-----------------------------------------------------------------*
 * pitch_ol_init()
 *
 * Open loop pitch variable initialization
 *-----------------------------------------------------------------*/

void pitch_ol_init_fx(
    Word16 *old_thres, /* o  : threshold for reinforcement of past pitch influence */
    Word16 *old_pitch, /* o  : pitch  of the 2nd half-frame of previous frame      */
@@ -80,8 +85,17 @@ void pitch_ol_init_fx(
    move16();
    *old_corr = 0;
    move16();

    return;
}

#ifdef FIX_2403_COMBINE_PITCH_OL
/*-----------------------------------------------------------------*
 * pitch_ol_resolve_fx()
 *
 *
 *-----------------------------------------------------------------*/

static void pitch_ol_resolve_fx(
    Word16 pitch[3],                 /* o  : open loop pitch lag for each half-frame Q0                     */
    Word16 voicing[3],               /* o  : maximum normalized correlation for each half-frame Q15         */
@@ -113,6 +127,7 @@ static void pitch_ol_resolve_fx(
    Word16 cor_tmp[2 * NHFR];
    Word16 thres1[2 * NHFR];
    Word16 tmp_buf[NHFR + 1];

    /*-----------------------------------------------------------------*
     * Favor a smaller delay if it happens that it has its multiple
     * in the longer-delay sections  (harmonics check)
@@ -149,6 +164,7 @@ static void pitch_ol_resolve_fx(
    {
        find_mult_fx( &fac, pitchX[i][0], pitchX[i][1], pit_max[3], &scaledX[i][0], old_pitch, old_corr, DELTA0, STEP ); /* Multiples in 2nd section */
    }

    fac = THRES0;
    move16();
    find_mult_fx( &fac, pitchX[i][NSECT + 2], pitchX[i][NSECT + 3], pit_max[7], &scaledX[i][NSECT + 2], old_pitch, old_corr, 2, 2 );         /* Multiples in 3rd section */
@@ -165,6 +181,7 @@ static void pitch_ol_resolve_fx(
     * Compute the maximum scaling for the neighbour correlation
     * reinforcement
     *-----------------------------------------------------------------*/

    add_sect0 = add( NSECT, sect0 );
    sub_sect0 = sub( NSECT, sect0 );
    FOR( i = 0; i < NHFR; i++ )
@@ -197,13 +214,15 @@ static void pitch_ol_resolve_fx(
        thres1[i + NHFR] = mult( THRES1, cor_tmp[i + NHFR] );
        move16();
    }
    /*-----------------------------------------------------------------*
    /*----
    -------------------------------------------------------------*
     * Take into account previous and next pitch values of the present
     * frame and look-ahead. Choose the pitch lags and normalize
     * correlations for each half-frame & look-ahead
     *-----------------------------------------------------------------*/

    pitch_neighbour_fx( sect0, pitch_tmp, pitchX, cor_tmp, scaledX, thres1, ind_tmp );

    FOR( i = 0; i < NHFR; i++ )
    {
        ind = add( maximum_fx( scaledX[i] + sect0, sub_sect0, &ftmp ), sect0 );
@@ -311,6 +330,7 @@ static void pitch_ol_resolve_fx(
     * in the next frame and is then used when the normalized
     * correlation is reinforced by the past estimate
     *-----------------------------------------------------------------*/

    tmp_buf[0] = *old_pitch;
    move16();
    FOR( i = 0; i < NHFR; i++ )
@@ -375,6 +395,8 @@ static void pitch_ol_resolve_fx(
        pitch[i] = i_mult2( pitch[i], OPL_DECIM );
        move16();
    }

    return;
}

#endif
@@ -610,6 +632,7 @@ void pitch_ol_fx(
    /*-----------------------------------------------------------------------------*
     * Estimate the new pitch by extrapolating the old pitch value for 2 half-frames
     *-----------------------------------------------------------------------------*/

    old_tmp = add( *old_pitch, *delta_pit );
    old_tmp = s_min( old_tmp, PIT_MAX / OPL_DECIM );
    old_tmp = s_max( old_tmp, pit_min );
@@ -620,6 +643,7 @@ void pitch_ol_fx(
    /*-----------------------------------------------------------------*
     * Loop for all three half-frames (current frame + look-ahead)
     *-----------------------------------------------------------------*/

    pt_cor0 = scaled_buf + DELTA_COH - 1;

    pt_cor2 = pt_cor0 - pit_min + old_tmp;
@@ -690,6 +714,7 @@ void pitch_ol_fx(
            /*----------------------------------------------------------*
             * Find correlation for the non-overlapping pitch lag values
             *----------------------------------------------------------*/

            exp_sect[subsect0] = 0;
            move16();
            pt_cor5 = pt_cor1;
@@ -725,6 +750,7 @@ void pitch_ol_fx(
            /*----------------------------------------------------------*
             * For each subsection, find the correlation
             *----------------------------------------------------------*/

            FOR( j = subsect0; j < NSUBSECT; j++ )
            {
                len_temp = sublen[j];
@@ -837,6 +863,7 @@ void pitch_ol_fx(
            /*-----------------------------------------------------------------*
             * Find correlation for the non-overlapping pitch lag values
             *-----------------------------------------------------------------*/

            exp_sect[subsect0] = 0;
            move16();
            pt_cor5 = pt_cor1;
@@ -985,6 +1012,7 @@ void pitch_ol_fx(
         * Scale correlation function in the neighbourhood of
         * the extrapolated pitch
         *-----------------------------------------------------------------*/

        pt_cor1 = pt_cor2 - ( DELTA_COH - 1 );
        pt_cor3 = pt_cor4 - ( DELTA_COH - 1 );
        pt2 = scale1;
@@ -1113,6 +1141,7 @@ void pitch_ol_fx(

        } /* FOR j < NSECT */
    }     /* FOR i < NHFR */

#ifdef FIX_2403_COMBINE_PITCH_OL
    pitch_ol_resolve_fx( pitch, voicing, old_pitch, old_corr, old_thres, delta_pit, EVS_MONO, corr_shift, relE, Opt_SC_VBR, pitchX, corX, scaledX, sect0, pit_max, pit_min_coding );
#else
@@ -1365,9 +1394,11 @@ void pitch_ol_fx(
        move16();
    }
#endif

    return;
}


void pitch_ol_ivas_fx(
    Word16 pitch[3],         /* o  : open loop pitch lag for each half-frame in range [29,231]      Q0  */
    Word16 voicing[3],       /* o  : maximum normalized correlation for each half-frame in [0,1.0[  Q15 */
@@ -1496,6 +1527,7 @@ void pitch_ol_ivas_fx(
     * Extend the decimation of wsp to the end of the speech buffer
     * Update wsp memory
     *--------------------------------------------------------------*/

    Copy( st_old_wsp2, old_wsp2, ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM );
    wsp2 = old_wsp2 + ( ( L_WSP_MEM - L_INTERPOL ) / OPL_DECIM );

@@ -1545,6 +1577,7 @@ void pitch_ol_ivas_fx(
    /*-----------------------------------------------------------------------------*
     * Estimate the new pitch by extrapolating the old pitch value for 2 half-frames
     *-----------------------------------------------------------------------------*/

    old_tmp = add( *old_pitch, *delta_pit );
    old_tmp = s_min( old_tmp, PIT_MAX / OPL_DECIM );
    old_tmp = s_max( old_tmp, pit_min );
@@ -1555,6 +1588,7 @@ void pitch_ol_ivas_fx(
    /*-----------------------------------------------------------------*
     * Loop for all three half-frames (current frame + look-ahead)
     *-----------------------------------------------------------------*/

    pt_cor0 = scaled_buf + DELTA_COH - 1;
    pt_cor0_exp = scaled_buf_exp + DELTA_COH - 1;

@@ -1674,6 +1708,7 @@ void pitch_ol_ivas_fx(
            /*----------------------------------------------------------*
             * For each subsection, find the correlation
             *----------------------------------------------------------*/

            FOR( j = subsect0; j < NSUBSECT; j++ )
            {
                len_temp = sublen[j];
@@ -1759,6 +1794,7 @@ void pitch_ol_ivas_fx(
            /*-----------------------------------------------------------------*
             * For each section in both sets, find fixed vector energy
             *-----------------------------------------------------------------*/

            FOR( j = sect0; j < NSECT; j++ ) /* loop for each section */
            {
                /* 1st set */
@@ -1939,6 +1975,7 @@ void pitch_ol_ivas_fx(
         * Scale correlation function in the neighbourhood of
         * the extrapolated pitch
         *-----------------------------------------------------------------*/

        pt_cor1 = pt_cor2 - ( DELTA_COH - 1 );
        pt_cor1_exp = pt_cor2_exp - ( DELTA_COH - 1 );
        pt_cor3 = pt_cor4 - ( DELTA_COH - 1 );
@@ -2090,6 +2127,7 @@ void pitch_ol_ivas_fx(

        } /* FOR j < NSECT */
    }     /* FOR i < NHFR */

#ifdef FIX_2403_COMBINE_PITCH_OL
    pitch_ol_resolve_fx( pitch, voicing, old_pitch, old_corr, old_thres, delta_pit, IVAS_SCE, corr_shift, relE, Opt_SC_VBR, pitchX, corX, scaledX, sect0, pit_max, pit_min_coding ); /* any element mode other than EVS_MONO is OK here */
#else
@@ -2353,6 +2391,7 @@ void pitch_ol_ivas_fx(
 * Verifies whether max pitch delays in higher sections have multiples
 * in lower sections
 *-----------------------------------------------------------------*/

static void find_mult_fx(
    Word16 *fac,       /* i/o: correlation scaling factor Q12              */
    Word16 pitch0,     /* i  : pitch of max correlation in the c section   */
@@ -2389,6 +2428,8 @@ static void find_mult_fx(
        pit_min = add( pit_min, pitch0 ); /* next multiple */
        delta = add( delta, step );       /* the incertitude to the allowed range */
    }

    return;
}

/*---------------------------------------------------------------------------*
@@ -2397,6 +2438,7 @@ static void find_mult_fx(
 * Verifies if the maximum correlation pitch lag is coherent with neighbour
 * values
 *---------------------------------------------------------------------------*/

static void pitch_neighbour_fx(
    Word16 sect0,               /* i  : indicates whether section 0 (below PIT_MIN) is used       */
    Word16 pitch_tmp[],         /* i  : estimated pitch values for each half-frame & look-ahead   */
@@ -2510,13 +2552,17 @@ static void pitch_neighbour_fx(
            }
        }
    }

    return;
}


/*-----------------------------------------------------------------*
 * pitch_coherence_fx
 *
 * Verify if pitch evolution is smooth
 *-----------------------------------------------------------------*/

static Word16 pitch_coherence_fx(
    Word16 pitch0,  /* i  : first pitch to compare        */
    Word16 pitch1,  /* i  : 2nd pitch to compare          */
@@ -2543,11 +2589,13 @@ static Word16 pitch_coherence_fx(
    return pc;
}


/*-----------------------------------------------------------------*
 * LP_Decim2_Copy:
 *
 * Decimate a vector by 2 with 2nd order fir filter.
 *-----------------------------------------------------------------*/

static void LP_Decim2_Copy(
    const Word16 x[], /* i:   signal to process */
    Word16 y[],       /* o:   signal to process */
@@ -2597,13 +2645,19 @@ static void LP_Decim2_Copy(
        y[j++] = round_fx( L_tmp );
        move16();
    }

    return;
}


/*---------------------------------------------------------------------*
 * Dot_product12_OL
 *
 * two different length dot products of x and y
 *---------------------------------------------------------------------*/
static Word32 Dot_product12_OL(                   /* o  : Q31: normalized result (1 < val <= -1) */

/* o  : Q31: normalized result (1 < val <= -1) */
static Word32 Dot_product12_OL(
    Word16 *sum1,     /* o  : Q31: normalized result 2 */
    const Word16 x[], /* i  : 12bits: x vector */
    const Word16 y[], /* i  : 12bits: y vector */
@@ -2662,12 +2716,15 @@ static Word32 Dot_product12_OL( /* o : Q31: normalized result
    return L_sum;
}


/*---------------------------------------------------------------------*
 * Dot_product12_OL_back()
 *
 * two different length dot products of x and y, computed backward
 *---------------------------------------------------------------------*/
static Word32 Dot_product12_OL_back(                   /* o  : Q31: normalized result (1 < val <= -1) */

/* o  : Q31: normalized result (1 < val <= -1) */
static Word32 Dot_product12_OL_back(
    Word16 *sum1,     /* o  : Q31: normalized result 2 */
    const Word16 x[], /* i  : 12bits: x vector */
    const Word16 y[], /* i  : 12bits: y vector */
@@ -2726,6 +2783,13 @@ static Word32 Dot_product12_OL_back( /* o : Q31: normalized r
    return L_sum;
}


/*---------------------------------------------------------------------*
 * pitchDoubling_det_fx()
 *
 *
 *---------------------------------------------------------------------*/

void pitchDoubling_det_fx(
    Word16 *wspeech,
    Word16 *pitch_ol,
@@ -2737,7 +2801,6 @@ void pitchDoubling_det_fx(
    Word16 new_Top[2];
    Word16 m, T;


    /*save initial values*/

    new_Top[0] = pitch_ol[0];
@@ -2747,7 +2810,6 @@ void pitchDoubling_det_fx(

    FOR( m = 2; m < 5; m++ )
    {

        /* T= pitch_ol[0]/m; */
        T = mult( pitch_ol[0], One_div_fx[m - 1] );

@@ -2800,4 +2862,5 @@ void pitchDoubling_det_fx(
    pitch_ol[1] = new_Top[1];
    move16();

} /*end of pitch doubling detection*/
    return;
}
+1 −1

File changed.

Contains only whitespace changes.