Commit a4a26f8c authored by sekine's avatar sekine
Browse files

Enhanced accuracy by renormalization in the frequency domain. 

Added WMOPS counter #estimate_itd_wnd_fft_fx,#calc_poc_fx,#find_poc_peak_fx,#estimate_itd_fx,#weighted_ave_fx,#calc_energy_fx,#adapt_gain_fx,#create_M_signal_fx,#stereo_dmx_evs_enc_fx.
parent a9c5c8b0
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -53,12 +53,12 @@

#define SUPPORT_JBM_TRACEFILE                   /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */

/*#define WMOPS*/                                   /* Activate complexity and memory counters */
#define WMOPS                                   /* Activate complexity and memory counters */
#ifdef WMOPS
/*#define WMOPS_PER_FRAME*/                     /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */
/*#define WMOPS_DETAIL*/                        /* Output detailed complexity printout for every function. Increases runtime overhead */
/*#define WMOPS_WC_FRAME_ANALYSIS*/             /* Output detailed complexity analysis for the worst-case frame */
/*#define MEM_COUNT_DETAILS*/                   /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */
#define WMOPS_PER_FRAME                   /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */
#define WMOPS_DETAIL                       /* Output detailed complexity printout for every function. Increases runtime overhead */
#define WMOPS_WC_FRAME_ANALYSIS             /* Output detailed complexity analysis for the worst-case frame */
/*define MEM_COUNT_DETAILS*/                   /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */
#endif

/* #################### End DEBUGGING switches ############################ */
@@ -94,6 +94,8 @@
#define FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2       /*FhG: reduces WMOPS*/
#define FIX_1481_HARDCODE_DIV                          /* FhG: hardcode division results in stereo_dmx_evs_init_encoder_fx() */
#define FIX_1486_IND_SHB_RES                   /* VA: Fix for issue 1486: align the usage of IND_SHB_RES_GS indices with float code */
#define FIX_1511_RENORM
#define FIX_1511_WMOPS

#define TEST_HR
#define REMOVE_EVS_DUPLICATES                   /* remove core-coder duplicated functions, ACELP low-band decoder */
+147 −0
Original line number Diff line number Diff line
@@ -223,6 +223,10 @@ void estimate_itd_wnd_fft_fx(
    Word16 step, bias;
    Word16 rshift;

#ifdef FIX_1511_WMOPS
	push_wmops("estimate_itd_wnd_fft_fx");
#endif

    n0 = shr( input_frame, 1 );
    IF( EQ_16( input_frame, L_FRAME16k ) )
    {
@@ -269,6 +273,10 @@ void estimate_itd_wnd_fft_fx(
    speci[n0] = 0;
    move32();

#ifdef FIX_1511_WMOPS
	pop_wmops();
#endif

    return;
}

@@ -322,6 +330,10 @@ static void calc_poc_fx(
    Word64 W_tmp;
    Word16 W_tmp_q;

#ifdef FIX_1511_WMOPS
	push_wmops("calc_poc_fx");
#endif

    /* Initialization */
    // iN = 1.0f / (float) input_frame;
    s = hPOC->sin_fx;
@@ -412,6 +424,23 @@ static void calc_poc_fx(
            Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) );
            Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) );

#ifdef FIX_1511_RENORM
			{
				Word32 TH1 = 65536 * 512;
				Word16 SHIFT1 = 4;
				IF((LT_32(L_abs(Lr), TH1)) &&
					(LT_32(L_abs(Li), TH1)) &&
					(LT_32(L_abs(Rr), TH1)) &&
					(LT_32(L_abs(Ri), TH1)))
				{
					Lr = L_shl(Lr, SHIFT1);
					Li = L_shl(Li, SHIFT1);
					Rr = L_shl(Rr, SHIFT1);
					Ri = L_shl(Ri, SHIFT1);
				}
			}
#endif 

            specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e
            move32();
            specPOi[i] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e
@@ -424,6 +453,23 @@ static void calc_poc_fx(
                Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) );
                Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) );

#ifdef FIX_1511_RENORM
				{
					Word32 TH1 = 65536 * 512;
					Word16 SHIFT1 = 4;
					IF((LT_32(L_abs(Lr), TH1)) &&
						(LT_32(L_abs(Li), TH1)) &&
						(LT_32(L_abs(Rr), TH1)) &&
						(LT_32(L_abs(Ri), TH1)))
					{
						Lr = L_shl(Lr, SHIFT1);
						Li = L_shl(Li, SHIFT1);
						Rr = L_shl(Rr, SHIFT1);
						Ri = L_shl(Ri, SHIFT1);
					}
				}
#endif 

                specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e
                move32();
                specPOi[j] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e
@@ -444,6 +490,24 @@ static void calc_poc_fx(
            Li = L_add( L_sub( specLi[i], Mpy_32_32_r( specRr[i], eps_sin ) ), Mpy_32_32_r( specRi[i], eps_cos ) );
            Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) );
            Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) );

#ifdef FIX_1511_RENORM
			{
				Word32 TH1 = 65536 * 512;
				Word16 SHIFT1 = 4;
				IF((LT_32(L_abs(Lr), TH1)) &&
					(LT_32(L_abs(Li), TH1)) &&
					(LT_32(L_abs(Rr), TH1)) &&
					(LT_32(L_abs(Ri), TH1)))
				{
					Lr = L_shl(Lr, SHIFT1);
					Li = L_shl(Li, SHIFT1);
					Rr = L_shl(Rr, SHIFT1);
					Ri = L_shl(Ri, SHIFT1);
				}
			}
#endif 

            specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e
            move32();
            specPOi[i] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e
@@ -454,6 +518,24 @@ static void calc_poc_fx(
            Li = L_sub( L_sub( specLi[j], Mpy_32_32_r( specRr[j], eps_sin ) ), Mpy_32_32_r( specRi[j], eps_cos ) );
            Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) );
            Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) );

#ifdef FIX_1511_RENORM
			{
				Word32 TH1 = 65536 * 512;
				Word16 SHIFT1 = 4;
				IF((LT_32(L_abs(Lr), TH1)) &&
					(LT_32(L_abs(Li), TH1)) &&
					(LT_32(L_abs(Rr), TH1)) &&
					(LT_32(L_abs(Ri), TH1)))
				{
					Lr = L_shl(Lr, SHIFT1);
					Li = L_shl(Li, SHIFT1);
					Rr = L_shl(Rr, SHIFT1);
					Ri = L_shl(Ri, SHIFT1);
				}
			}
#endif 

            specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e
            move32();
            specPOi[j] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e
@@ -1125,6 +1207,10 @@ static void calc_poc_fx(
        }
    }

#ifdef FIX_1511_WMOPS
	pop_wmops();
#endif

    return;
}

@@ -1144,6 +1230,11 @@ static Word32 find_poc_peak_fx(
    Word16 itd_cand[CPE_CHANNELS], i, n, cnt[CPE_CHANNELS], Lh, peak_range, *on, *itdLR, prev_off[CPE_CHANNELS], eps_fx;
    Word32 Q_fx[CPE_CHANNELS], aQ_fx[CPE_CHANNELS], cQ_fx[CPE_CHANNELS], width_fx, *peak_width_fx, *peakQ_fx, cconfidence_fx, *P_fx, tmpf_fx, eps2_fx;
    Word16 tmpf_e = 0, eps2_e = 0, Q_e[CPE_CHANNELS], eps_e = 15, peakQ_e[CPE_CHANNELS];

#ifdef FIX_1511_WMOPS
	push_wmops("find_poc_peak_fx");
#endif

    move16();
    move16();
    move16();
@@ -1434,6 +1525,10 @@ static Word32 find_poc_peak_fx(
    hPOC->confidence_fx = L_add( cconfidence_var1, L_shl( cconfidence_var2, 1 ) );                                                                                      // Q31
    move32();

#ifdef FIX_1511_WMOPS
	pop_wmops();
#endif

    return hPOC->confidence_fx;
}

@@ -1459,6 +1554,10 @@ static ivas_error estimate_itd_fx(
    Word16 rfft_coef_step;
    ivas_error error;

#ifdef FIX_1511_WMOPS
	push_wmops("estimate_itd_fx");
#endif

    error = IVAS_ERR_OK;
    move32();

@@ -1515,6 +1614,10 @@ static ivas_error estimate_itd_fx(
    *corr = round_fx( find_poc_peak_fx( hPOC, itd, input_frame, STEREO_DMX_EVS_POC_W_FORGETTING_FX ) );
    move16();

#ifdef FIX_1511_WMOPS
	pop_wmops();
#endif

    return error;
}

@@ -1535,6 +1638,11 @@ static void weighted_ave_fx(
{
    Word16 i, len;
    Word32 gain_tmp_fx = 0, gain_sub_fx;

#ifdef FIX_1511_WMOPS
	push_wmops("weighted_ave_fx");
#endif

    move32();
    len = shr( input_frame, 4 );
    gain_sub_fx = L_sub( gain_fx, old_gain_fx );
@@ -1550,6 +1658,10 @@ static void weighted_ave_fx(
        move32();
    }

#ifdef FIX_1511_WMOPS
	pop_wmops();
#endif

    return;
}
/*-------------------------------------------------------------------*
@@ -1569,6 +1681,11 @@ static void calc_energy_fx(
    Word32 E_32_fx, wnd_fx, wnd_diff_fx;
    Word16 i, adaptlen;
    Word64 E_fx;

#ifdef FIX_1511_WMOPS
	push_wmops("calc_energy_fx");
#endif

    /* Initialization */
    E_fx = 0;
    move32();
@@ -1630,6 +1747,11 @@ static void calc_energy_fx(
    // *energy = *energy * ratio_float + ( E / (float) input_frame ) * ( 1.0f - ratio_float );
    *energy_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( *energy_fx, ratio_float_fx ), *energy_fx_e, Mpy_32_32( temp32, L_sub( MAX_32, ratio_float_fx ) ), sub( 31, q_temp32 ), energy_fx_e );
    move32();

#ifdef FIX_1511_WMOPS
	pop_wmops();
#endif

    return;
}

@@ -1650,6 +1772,10 @@ static void adapt_gain_fx(
    Word16 i, len;
    Word32 gain_tmp_fx, gain_sub_fx;

#ifdef FIX_1511_WMOPS
	push_wmops("adapt_gain_fx");
#endif

    len = shr( input_frame, 4 );
    //  gain_sub = gain - old_gain;
    gain_sub_fx = L_sub( gain_fx, old_gain_fx ); // Q31
@@ -1668,6 +1794,10 @@ static void adapt_gain_fx(
        move32();
    }

#ifdef FIX_1511_WMOPS
	pop_wmops();
#endif

    return;
}

@@ -1696,6 +1826,11 @@ static void create_M_signal_fx(
    Word32 temp32_1, temp32_2;
    Word16 temp_e;
    Word16 temp_e_1, temp_e_2;

#ifdef FIX_1511_WMOPS
	push_wmops("create_M_signal_fx");
#endif

    /* Initialization */
    eps_fx = 1024; // 1024.0f in Q0
    move32();
@@ -1761,6 +1896,10 @@ static void create_M_signal_fx(
    w_prev_fx[2] = amp_mod_fx[1];
    move32();

#ifdef FIX_1511_WMOPS
	pop_wmops();
#endif

    return;
}

@@ -1799,6 +1938,10 @@ void stereo_dmx_evs_enc_fx(
    Word64 W_tmp;
    Word16 W_tmp_q;

#ifdef FIX_1511_WMOPS
	push_wmops("stereo_dmx_evs_enc_fx");
#endif

    if ( is_binaural )
    {
        /* use of is_binaural flag is to be considered */
@@ -2150,6 +2293,10 @@ void stereo_dmx_evs_enc_fx(

    Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q26->Q15

#ifdef FIX_1511_WMOPS
	pop_wmops();
#endif

    return;
}