Commit 1d29f81d authored by vaillancour's avatar vaillancour
Browse files

harmonized find_uv

parent 8f2faed9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@
#define FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA              /* Nokia: Fix float issue 1501, uninitialized value in ivas_masa_combine_directions for OMASA */
#define FIX_BASOP_2323_DIRAC_ENC_WRONG_INIT             /* Nokia/FhG: basop issue 2323: Use correct init size */
#define FIX_BASOP_2324_MISSING_SET_TO_ZERO              /* Nokia: basop issue 2324: Fix issue by setting the exponent to zero where it should be */
#define FIX_2349_HARM_FIND_UV                           /* VA: basop issue 2349 : harmonizing find_uv function */

/* #################### End BE switches ################################## */

+48 −13
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum
 *
 * Decision about coder type
 *-------------------------------------------------------------------*/

#ifndef FIX_2349_HARM_FIND_UV
Word16 find_uv_fx(                           /* o  : coding type                                                    */
                   Encoder_State *st_fx,     /* i/o: encoder state structure                                        */
                   const Word16 *T_op_fr,    /* i  : pointer to adjusted fractional pitch (4 val.)                  Q6*/
@@ -573,6 +573,9 @@ Word16 find_uv_fx( /* o : coding type
 * Decision about coder type
 *-------------------------------------------------------------------*/
Word16 find_uv_ivas_fx(                                       /* o  : coding type                                                   */
#else
Word16 find_uv_fx( /* o  : coding type                                                   */
#endif
                        Encoder_State *st_fx,                 /* i/o: encoder state structure                                       */
                        const Word16 *T_op_fr,                /* i  : pointer to adjusted fractional pitch (4 val.)                 Q6*/
                        const Word16 *voicing_fr,             /* i  : refined correlation for each subframes                        Q15*/
@@ -587,6 +590,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
                        const Word16 last_core_orig,          /* i  : original last core                                            Q0*/
                        STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure                                   */
                        const Word16 Q_new,
                        const Word16 shift,
                        const Word16 q_hp_E )
{
    Word16 coder_type, i;
@@ -607,7 +611,16 @@ Word16 find_uv_ivas_fx( /* o : coding typ
    SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
    Word16 Last_Resort;
    Word16 vadnoise;
#ifdef FIX_2349_HARM_FIND_UV
    Word16 Q_in, loc_lp_noise;
    
    Q_in = Q_new;
    move16();
    if( st_fx->element_mode == EVS_MONO )
    {
        Q_in = sub( Q_new, 1 );
    }
#endif
    IF( hSC_VBR != NULL )
    {
        Last_Resort = hSC_VBR->Last_Resort; /* Q0 */
@@ -637,7 +650,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
    pt_enr_ssf = enr_ssf + 2 * NB_SSF;
    FOR( i = 0; i < 2 * ( NB_SSF + 1 ); i++ )
    {
        emaximum_fx( Q_new, pt_speech, SSF, pt_enr_ssf );
        emaximum_fx( Q_in, pt_speech, SSF, pt_enr_ssf );
        pt_speech += ( SSF / 2 );
        pt_enr_ssf++;
    }
@@ -675,7 +688,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
        pt_enr_ssf1++;
    }

    IF( hStereoClassif != NULL )
    IF( hStereoClassif != NULL ) /* IVAS only */
    {
        IF( st_fx->idchan == 0 )
        {
@@ -717,7 +730,12 @@ Word16 find_uv_ivas_fx( /* o : coding typ
     *-----------------------------------------------------------------*/

    dE3 = sub( Etot, extract_h( hNoiseEst->Etot_last_32fx ) ); /*Q8*/

#ifdef FIX_2349_HARM_FIND_UV
    if ( st_fx->element_mode == EVS_MONO ) /* Overwrite DE3 in case of EVS */
    {
        dE3 = sub( Etot, hNoiseEst->Etot_last_fx ); /*Q8*/
    }
#endif
    /*-----------------------------------------------------------------*
     * Energy decrease after spike (dE2)
     *-----------------------------------------------------------------*/
@@ -806,7 +824,12 @@ Word16 find_uv_ivas_fx( /* o : coding typ
    }

    E_min_th = L_shl( E_MIN_IVAS_FX_Q31, sub( q_hp_E, Q31 ) );

#ifdef FIX_2349_HARM_FIND_UV
    if ( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */
    {
        E_min_th = L_shl( E_MIN_FX, Q_new );
    }
#endif
    test();
    test();
    test();
@@ -836,16 +859,22 @@ Word16 find_uv_ivas_fx( /* o : coding typ
    {
        ee1_th = 544; /*8.5f Q6*/
        move16();

        loc_lp_noise = extract_h( st_fx->lp_noise_32fx );
#ifdef FIX_2349_HARM_FIND_UV
        if ( st_fx->element_mode == EVS_MONO ) /* Overwrite E_min_th in case of EVS */
        {
            loc_lp_noise = st_fx->lp_noise_fx;
        }
#endif
        /* SC-VBR - determine the threshold on relative energy as a function of lp_noise */
        IF( st_fx->input_bwidth != NB )
        {
            /*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */
            L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24
            L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, loc_lp_noise ); // Q24
            IF( Last_Resort == 0 )
            {
                /*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/
                L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24
                L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, loc_lp_noise ); // Q24
            }
            relE_thres = round_fx( L_tmp );
        }
@@ -853,7 +882,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
        {

            /*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/
            L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24
            L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, loc_lp_noise ); // Q24
            relE_thres = round_fx( L_tmp );
        }
        relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */
@@ -889,7 +918,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ
        test();
        test();
        test();
        IF( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low  */
        if( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22282 /* 0.68 in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low  */
              ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 /* 0.79 in Q15 */ ) ) &&               /* normalized correlation low on look-ahead - onset detection */
              ( LT_32( ee[0], 640 /* 10.0f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) &&                     /* energy concentrated in high frequencies provided that some energy is present in HF...  */
              ( LT_32( ee[1], ee1_th ) ) && ( GT_32( hp_E[1], E_min_th ) ) &&                                    /* ... biased towards look-ahead to detect onsets  */
@@ -917,7 +946,9 @@ Word16 find_uv_ivas_fx( /* o : coding typ
        test();
        test();
        if ( ( ( LT_16( add_sat( mean_voi3, corr_shift ), add( 22774 /* 0.695f in Q15 */, mean_voi3_offset ) ) ) && /* normalized correlation low  */
               /*( LT_16( add_o( st_fx->voicing_fx[2], corr_shift, &Overflow ), 25887 ) ) && */                     /* normalized correlation low on look-ahead - onset detection */
#ifdef FIX_2349_HARM_FIND_UV
               ( LT_16( add_sat( st_fx->voicing_fx[2], corr_shift ), 25887 ) && st_fx->element_mode == EVS_MONO ) && /* normalized correlation low on look-ahead - onset detection */
#endif
               ( LT_32( ee[0], 397 /* 6.2f in Q6 */ ) ) && ( GT_32( hp_E[0], E_min_th ) ) &&                        /* energy concentrated in high frequencies provided that some energy is present in HF...  */
               ( LT_32( ee[1], 397 /* 6.2f in Q16 */ ) ) && ( GT_32( hp_E[1], E_min_th ) ) &&                       /* ... biased towards look-ahead to detect onsets  */
               ( tmp_offset_flag == 0 ) &&                                                                          /* Take care of voiced offsets */
@@ -1037,9 +1068,13 @@ Word16 find_uv_ivas_fx( /* o : coding typ
            move16();
            /* Current frame cannot be compressed to pack the partial redundancy;*/

            IF( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) )
            IF( NE_16( st_fx->rf_mode, st_fx->Opt_RF_ON ) ) /* can happen only for EVS-BE modes*/
            {
#ifdef FIX_2349_HARM_FIND_UV
                core_coder_mode_switch_fx( st_fx, st_fx->last_total_brate, 0, shift );
#else
                core_coder_mode_switch_ivas_fx( st_fx, st_fx->last_total_brate, 0 );
#endif
            }
        }
    }
+5 −1
Original line number Diff line number Diff line
@@ -1292,9 +1292,13 @@ ivas_error pre_proc_front_ivas_fx(

    find_tilt_ivas_fx( fr_bands_fx, fr_bands_fx_q, bckr_temp, scale, ee_fx, st->pitch, st->voicing_fx, lf_E_fx, q_lf_E_fx,
                       corr_shift_fx, st->input_bwidth, st->max_band, hp_E_fx, MODE1, &( st->bckr_tilt_lt ), st->Opt_SC_VBR );

#ifdef FIX_2349_HARM_FIND_UV
    st->coder_type = find_uv_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx,
                                      &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, shift, fr_bands_fx_q ); // Q0
#else
    st->coder_type = find_uv_ivas_fx( st, pitch_fr_fx, voicing_fr_fx, inp_12k8_fx, ee_fx, &dE1X_fx, corr_shift_fx, *relE_fx, extract_h( Etot_fx ), hp_E_fx,
                                      &flag_spitch, last_core_orig, hStereoClassif, *Q_new /*q_inp_12k8*/, fr_bands_fx_q ); // Q0
#endif
    Copy_Scale_sig_16_32_no_sat( st->lgBin_E_fx, st->Bin_E_fx, L_FFT / 2, sub( st->q_Bin_E, Q7 ) );

    /*-----------------------------------------------------------------*
+5 −1
Original line number Diff line number Diff line
@@ -520,9 +520,13 @@ void pre_proc_fx(
    find_tilt_fx( fr_bands, hNoiseEst->bckr_fx, ee, st->pitch, st->voicing_fx, lf_E, corr_shift, st->input_bwidth,
                  st->max_band, hp_E, st->codec_mode, *Q_new, &( st->bckr_tilt_lt ), st->Opt_SC_VBR );

#ifdef FIX_2349_HARM_FIND_UV
    st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee, NULL, corr_shift, relE, *Etot, hp_E,
                                 &flag_spitch, last_core_orig, NULL, *Q_new, *shift, NULL ); // Q0
#else
    st->coder_type = find_uv_fx( st, pitch_fr, voicing_fr, inp_12k8, ee,
                                 corr_shift, relE, *Etot, hp_E, *Q_new, &flag_spitch, *shift, last_core_orig );

#endif
    /*-----------------------------------------------------------------*
     * channel aware mode configuration                                *
     *-----------------------------------------------------------------*/