Commit 02723cad authored by vaillancour's avatar vaillancour
Browse files

as tested in the short AB test

parent 59cf37d1
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1766,9 +1766,6 @@ int16_t select_stereo_mode(
    CPE_ENC_HANDLE hCPE,                                        /* i/o: CPE encoder structure                           */
    const IVAS_FORMAT ivas_format,                              /* i  : IVAS format                                     */
    const int32_t ivas_total_brate                              /* i  : IVAS total brate                                */
#ifdef OMASA_TUNING
    ,const int16_t isOmasa                                      /* i  : Flag to indicate that Omasa is present          */        
#endif
);

void stereo_classifier_init(
@@ -1833,6 +1830,9 @@ int16_t stereo_tdm_ener_analysis(
    const int16_t input_frame,                                  /* i  : Number of samples                       */
    int16_t *tdm_SM_or_LRTD_Pri,                                /* o  : channel combination scheme flag in TD stereo OR LRTD primary channel */
    int16_t *tdm_ratio_idx_SM                                   /* o  : TDM ratio index for SM mode             */
#ifdef OMASA_TUNING
   ,const int16_t isOmasa                                       /* i  : Flag to indicate that Omasa is present          */
#endif
);

void stereo_tdm_downmix(
+7 −11
Original line number Diff line number Diff line
@@ -140,7 +140,8 @@ void tdm_bit_alloc(

    /* secondary channel bitrate allocation based on the energy scaling ratio */
#ifdef OMASA_TUNING
    if ( (IsOmasa == 0 && ( ( coder_type != UNVOICED ) || tdm_LRTD_flag == 1 ) ) ||  
    if ( (IsOmasa == 0 && ( ( coder_type != UNVOICED ) || tdm_LRTD_flag == 1 ) ) 
        ||  
        ( IsOmasa == 1 && coder_type > UNVOICED ) )
#else
    if ( ( coder_type != UNVOICED ) || tdm_LRTD_flag == 1 )
@@ -412,11 +413,11 @@ void tdm_bit_alloc(
            }
            *total_brate_sec += ( fast_FCB_rates_2sfr[idx] - tmp_rate );
        }
        ///* prevent 2.4 kb/s and 2.8 kb/s as they are reserved bitrates for DTX and VBR */
        //if ( *total_brate_sec == PPP_NELP_2k80 || *total_brate_sec == SID_2k40 )
        //{
        //    *total_brate_sec += 100;
        //}
        /* prevent 2.4 kb/s and 2.8 kb/s as they are reserved bitrates for DTX and VBR */
        if ( *total_brate_sec == PPP_NELP_2k80 || *total_brate_sec == SID_2k40 )
        {
            *total_brate_sec += 100;
        }

        /* To prevent 13.2 kb/s for primary channel as some bitstream issues arrise with it */
        if ( element_brate_wo_meta - *total_brate_sec == ACELP_13k20 )
@@ -424,11 +425,6 @@ void tdm_bit_alloc(
            *total_brate_sec += 100;
        }
    }
    /* prevent 2.4 kb/s and 2.8 kb/s as they are reserved bitrates for DTX and VBR */
    if ( *total_brate_sec == PPP_NELP_2k80 || *total_brate_sec == SID_2k40 )
    {
        *total_brate_sec += 100;
    }
    *total_brate_pri = element_brate_wo_meta - *total_brate_sec;

    return;
+7 −11
Original line number Diff line number Diff line
@@ -169,20 +169,12 @@ ivas_error ivas_cpe_enc(
#ifdef OMASA_UPDATES
        if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM && ivas_total_brate == IVAS_48k )
        {
            hCPE->element_mode = select_stereo_mode( hCPE, ivas_format, IVAS_32k 
#ifdef OMASA_TUNING
                                                     ,st_ivas->hOMasa!=NULL
#endif 
            );
            hCPE->element_mode = select_stereo_mode( hCPE, ivas_format, IVAS_32k );
        }
        else
        {
#endif
            hCPE->element_mode = select_stereo_mode( hCPE, ivas_format, ivas_total_brate
#ifdef OMASA_TUNING
                                                     ,st_ivas->hOMasa!=NULL
#endif 
            );
            hCPE->element_mode = select_stereo_mode( hCPE, ivas_format, ivas_total_brate );
#ifdef OMASA_UPDATES
        }
#endif
@@ -421,7 +413,11 @@ ivas_error ivas_cpe_enc(
    else if ( hCPE->element_mode == IVAS_CPE_TD )
    {
        /* Determine the energy ratio between the 2 channels */
        tdm_ratio_idx = stereo_tdm_ener_analysis( hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM );
        tdm_ratio_idx = stereo_tdm_ener_analysis( hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM
#ifdef OMASA_TUNING
                                                  , st_ivas->hOMasa != NULL
#endif
        );

        /* Compute the downmix signal based on the ratio index */
        stereo_tdm_downmix( hCPE->hStereoTD, sts[0]->input, sts[1]->input, input_frame, tdm_ratio_idx, ( ( hCPE->hStereoTD->tdm_LRTD_flag == 0 ) ? tdm_SM_or_LRTD_Pri : 0 ), tdm_ratio_idx_SM );
+0 −14
Original line number Diff line number Diff line
@@ -90,9 +90,6 @@ int16_t select_stereo_mode(
    CPE_ENC_HANDLE hCPE,           /* i/o: CPE encoder structure       */
    const IVAS_FORMAT ivas_format, /* i  : IVAS format                 */
    const int32_t ivas_total_brate /* i  : IVAS total brate            */
#ifdef OMASA_TUNING
   ,const int16_t isOmasa /* i  : Flag to indicate that Omasa is present          */
#endif
)
{
    int16_t element_mode;
@@ -212,17 +209,6 @@ int16_t select_stereo_mode(
            set_f( hStereoClassif->xtalk_fv, -1.0f, SSC_MAX_NFEA );
        }
    }
#ifdef OMASA_TUNING
    else if ( element_mode == IVAS_CPE_TD && isOmasa )
    {
        if ( ( hStereoClassif->lrtd_mode == 1 || hCPE->hStereoTD->prev_fr_LRTD_TD_dec == 1 ) && ( hCPE->element_brate - 50 * FRAMES_PER_SEC + hCPE->brate_surplus + hCPE->brate_surplus < 15000 ) )
        {
            hStereoClassif->lrtd_mode = 0;
            hStereoClassif->prev_lrtd_mode = 0;
        }
    }
#endif


#ifdef DEBUG_MODE_TD
    dbgwrite( &hStereoClassif->unclr_decision, sizeof( int16_t ), 1, L_FRAME16k, "res/unclr_decision.enc" );
+13 −11
Original line number Diff line number Diff line
@@ -115,6 +115,9 @@ int16_t stereo_tdm_ener_analysis(
    const int16_t input_frame,   /* i  : Number of samples                   */
    int16_t *tdm_SM_or_LRTD_Pri, /* o  : channel combination scheme flag in TD stereo OR LRTD primary channel */
    int16_t *tdm_ratio_idx_SM    /* o  : TDM ratio index for SM mode         */
#ifdef OMASA_TUNING
   ,const int16_t isOmasa /* i  : Flag to indicate that Omasa is present          */
#endif
)
{
    float rms_R, rms_L;
@@ -194,7 +197,16 @@ int16_t stereo_tdm_ener_analysis(
     * When the energies of channels are low enough, compute the ratio
     * of L and R needed to create new mono/side signals
     *----------------------------------------------------------------*/
#ifdef OMASA_TUNING
    if (  isOmasa )
    {

        if ( ( hCPE->hStereoClassif->lrtd_mode == 1 || hCPE->hStereoTD->prev_fr_LRTD_TD_dec == 1 ) && ( hCPE->element_brate - 50 * FRAMES_PER_SEC + hCPE->brate_surplus + hCPE->brate_surplus < 15000 ) )
        {
            hStereoTD->prev_fr_LRTD_TD_dec = 0;
        }
    }
#endif
    rms_thd = RMS_MIN;
    if ( hCPE->hStereoClassif->lrtd_mode == 1 )
    {
@@ -229,17 +241,7 @@ int16_t stereo_tdm_ener_analysis(
            hStereoTD->prev_fr_LRTD_TD_dec = 0;
        }
    }
    //if ( hCPE->hStereoTD != NULL )
    //{

    //    if ( /*hStereoClassif->lrtd_mode == 1*/ hCPE->hStereoTD->prev_fr_LRTD_TD_dec == 1 && hCPE->element_brate - 50 * FRAMES_PER_SEC + hCPE->brate_surplus < 12600 )
    //    {
    //        //hStereoClassif->xtalk_decision = 0;
    //        //hStereoClassif->lrtd_mode = 0;
    //        hCPE->hStereoTD->prev_fr_LRTD_TD_dec = 0;
    //        //hCPE->hStereoClassif->lrtd_mode = 0;
    //    }
    //}
    side_can_change = 0;

    /* update LRTD->DFT stereo hangover counters */
Loading