Commit ad0a24c3 authored by vaillancour's avatar vaillancour
Browse files

more comments inside stereo_tdm_ener_analysis()

parent 8a69cf17
Loading
Loading
Loading
Loading
+35 −4
Original line number Diff line number Diff line
@@ -194,8 +194,11 @@ int16_t stereo_tdm_ener_analysis(
    hStereoTD->prev_fr_LRTD_TD_dec = hCPE->hStereoClassif->lrtd_mode;

    /*----------------------------------------------------------------*
     * When the energies of channels are low enough, compute the ratio
     * of L and R needed to create new mono/side signals
     * If the ivas format is MASA_ISM and the signal is classified 
     * as having a low correlation (interfering talker or uncorrelated content)
     * and the bitrate available is lower than 15 kbps.
     * then, then next frame will be encoded using the normal TD, which allows 
     * for a lower total bitrate
     *----------------------------------------------------------------*/

    if ( ivas_format == MASA_ISM_FORMAT )
@@ -206,6 +209,19 @@ int16_t stereo_tdm_ener_analysis(
            hStereoTD->prev_fr_LRTD_TD_dec = 0;
        }
    }
    /*----------------------------------------------------------------*
     * An rms energy threshold is set and will be use later to decide when 
     * it is the right time to change the mixing level or to change primary 
     * and secondary channel.
     * 
     * If the signal is classified as having a low correlation 
     * (interfering talker or uncorrelated content), 
     * then, the rms threshold is lowered and further more if the long 
     * term rms energy of at least one of the channel is <= 75. On the other hand, 
     * if the lt term rms of both channel is above that threshold but the 
     * coding mode of both channel is considered as inactive, then the 
     * rms threshold is increased.
     *----------------------------------------------------------------*/

    rms_thd = RMS_MIN;
    if ( hCPE->hStereoClassif->lrtd_mode == 1 )
@@ -219,8 +235,23 @@ int16_t stereo_tdm_ener_analysis(
        {
            rms_thd /= .2f;
        }

        /* Overwrite the LR decision flag in case the signals is already considered as S/M or when the signal is very similar between left and right channel */
       /*----------------------------------------------------------------*
        * Overwrite the LRTD decision flag and use the normal TD for the 
        * following cases:
        *1- The signals is already considered as S/M 
        *2- The LRTD flag is set to 1 and the last switching frame 
        *   happened more than 10 frames ago and both channel are considered 
        *   as inactive or the uncorrelated decision flag is 0 (not completely uncorrelated) 
        *   and the interfering talker score and the weighted interfering score 
        *   are low or the uncorrelated decision flag is 1 (likely uncorrelated) and 
        *   both channel are classified as unvoiced and the uncorrelated score is low
        *3- The LRTD flag is set to 0 and both channel are considered 
        *   as inactive or the uncorrelated decision flag is 0 (not completely uncorrelated) 
        *   and the interfering talker score and the weighted interfering score 
        *   are low or the uncorrelated decision flag is 1 (likely uncorrelated) and 
        *   both channel are classified as unvoiced and the uncorrelated score is low
        * the conditions 2 and 3 vary slightly to ensure an hysteresis effect
        *----------------------------------------------------------------*/
        if ( tdm_SM_flag_loc == 1 )
        {
            hStereoTD->prev_fr_LRTD_TD_dec = 0;