Commit da9755c9 authored by vaillancour's avatar vaillancour
Browse files

comment function stereo_smooth_LR_transition()

parent bec84e72
Loading
Loading
Loading
Loading
+40 −5
Original line number Diff line number Diff line
@@ -629,7 +629,7 @@ static int16_t Get_dt_lt_ener(
    }

    /*----------------------------------------------------------------*
     * Compute the 1st order energy difference difference
     * Compute the 1st order energy difference 
     *----------------------------------------------------------------*/

    *ener_R_dt = *tdm_lt_rms_R - *tdm_last_ener_lt_R;
@@ -1362,7 +1362,9 @@ static void Get_corr_n(
    ener_side = 1e-6f;

    /*----------------------------------------------------------------*
     * Find the normalized correlation between: left/mono and right/mono based
     * Find the normalized correlation between: left/mono and right/mono 
     * Find the energy difference between side and mono, this info is later 
     * used to help determine the out of phase signal
     *----------------------------------------------------------------*/

    if ( tdm_SM_calc_flag )
@@ -1406,9 +1408,9 @@ static void Get_corr_n(

/*! r: smoothed position */
static int16_t stereo_smooth_LR_transition(
    int16_t *tdm_prev_stable_idx,           /* i/o: Previous Transmitted ratio index                */
    int16_t *tdm_prev_stable_idx,           /* i/o: Last energy ratio index considered stable       */
    int16_t *tdm_ratio_transition_mov_flag, /* i/o: Flag that indicates that L-R energy is changing */
    int16_t tdm_last_ratio_idx,             /* i  : last TDM ratio index                            */
    int16_t tdm_last_ratio_idx,             /* i  : last transmitted TDM ratio index                */
    int16_t *tdm_prev_desired_idx,          /* i/o: Previous Transmitted ratio index                */
    int16_t *tdm_ratio_transition_cnt,      /* i/o: Counter                                         */
    const int16_t tdm_SM_flag,              /* i  : channel combination scheme flag for current frame */
@@ -1417,15 +1419,48 @@ static int16_t stereo_smooth_LR_transition(
{
    int16_t idx;

    /*-------------------------------------------------------------------*
     * if the signal is considered as out of phase, 
     * energy ratio desired index is forced to mid-range (15)
     *-------------------------------------------------------------------*/
    if ( tdm_SM_flag == 1 )
    {
        desired_idx = 15;
    }

    /*-------------------------------------------------------------------*
     * if the energy ratio desired index is different than the previous 
     * stable energy index, it indicates that the energy is moving from 
     * its last stable position
     *-------------------------------------------------------------------*/
    if ( desired_idx != *tdm_prev_stable_idx )
    {
        *tdm_ratio_transition_mov_flag = 1;
    }
    /*-------------------------------------------------------------------*
     * When the moving energy flag is set to 1, 
     *   if the current energy ratio index is different from the previous 
     *   one
     *    then, 
     *      update the previous stable energy index with the last transmitted one 
     *      reset transition energy counter
     *   increment the transition energy counter by 4 
     *   
     * if the current energy ratio index + 2 is smaller than the last stable 
     * energy index
     *   then,
     *      the quantized energy index will be equal to the last stable index 
     *      minus the transition counter
     * else if the current energy ratio index - 2 is larger than the last 
     * stable energy index
     *   then,
     *      the quantized energy index will be equal to the last stable index 
     *      plus the transition counter
     * else 
     *      the quantized energy index is equal to the current energy index
     * 
     * this allows for a smoother transition from one stable energy index to 
     * another one when the energy gap is relatively big
     *-------------------------------------------------------------------*/

    if ( *tdm_ratio_transition_mov_flag == 1 )
    {