Commit eb225adf authored by vaillancour's avatar vaillancour
Browse files

more fixes concerning -rf encoder command line

parent 6b2abebf
Loading
Loading
Loading
Loading
+44 −3
Original line number Diff line number Diff line
@@ -1038,21 +1038,34 @@ void GenShapedWBExcitation_fx(
            n1 = norm_s( max_val );
            FOR ( i = 0; i < L_FRAME16k / 4; i++ )
            {
#ifdef BASOP_NOGLOB
                excTmp2_frac[i] = shl_o( excTmp2[i], n1, &Overflow );
#else
                excTmp2_frac[i] = shl( excTmp2[i], n1 );
#endif
                move16(); /* Q14 */
            }
            n1 = sub( sub( 14, n1 ), Q_bwe_exc );
            pow1 = 1;
            FOR ( i = 0;  i < L_FRAME16k / 4; i++ )
            {
#ifdef BASOP_NOGLOB
                L_tmp = L_mult_o( excTmp2_frac[i], excTmp2_frac[i], &Overflow); /* Q29 */
                pow1 = L_add_o( pow1, L_shr( L_tmp, 7 ), &Overflow); /* Q22 */
#else
                L_tmp = L_mult( excTmp2_frac[i], excTmp2_frac[i] ); /* Q29 */
                pow1 = L_add( pow1, L_shr( L_tmp, 7 ) ); /* Q22 */
#endif
            }
        }

        FOR ( i = 0; i < L_FRAME16k / 4; i++ )
        {
#ifdef BASOP_NOGLOB
            excNoisyEnv[i] = L_add_o( *mem_csfilt, L_mult_o( csfilt_num2[0], excTmp2[i], &Overflow ), &Overflow);
#else
            excNoisyEnv[i] = L_add( *mem_csfilt, L_mult( csfilt_num2[0], excTmp2[i] ) );
#endif
            move32();  /* Q_bwe_exc+16  */
            *mem_csfilt = Mult_32_16( excNoisyEnv[i], neg_csfilt_den2[1] );
            move32();  /* Q_bwe_exc+16 */
@@ -1082,14 +1095,23 @@ void GenShapedWBExcitation_fx(
            n2 = norm_l( Lmax );
            FOR ( i = 0; i < L_FRAME16k / 4; i++ )
            {
#ifdef BASOP_NOGLOB
                exc4k_frac[i] = extract_h( L_shl_o( exc4k_32[i], n2, &Overflow ) ); /* Q(14-n2) */
#else
                exc4k_frac[i] = extract_h( L_shl( exc4k_32[i], n2 ) ); /* Q(14-n2) */
#endif
            }
            n2 = 30 - n2 - ( Q_bwe_exc + 6 );
            pow22 = 1;
            FOR ( i = 0;  i < L_FRAME16k / 4; i++ )
            {
#ifdef BASOP_NOGLOB
                L_tmp = L_mult_o( exc4k_frac[i], exc4k_frac[i], &Overflow); /* Q29 */
                pow22 = L_add_o( pow22, L_shr( L_tmp, 7 ), &Overflow); /* Q22     */
#else
                L_tmp = L_mult( exc4k_frac[i], exc4k_frac[i] ); /* Q29 */
                pow22 = L_add( pow22, L_shr( L_tmp, 7 ) ); /* Q22     */
#endif
            }
        }

@@ -1098,12 +1120,19 @@ void GenShapedWBExcitation_fx(
        IF( EQ_16(coder_type, UNVOICED)||(igf_flag!=0&&LT_16(avg_voice_fac,6654)))
        {
            L_tmp = root_a_over_b_fx( pow1, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp );
#ifdef BASOP_NOGLOB
            scale = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow); /*Q15 */
#else
            scale = round_fx( L_shl( L_tmp, exp ) ); /*Q15 */

#endif
            sc = sub( add( n2, Q_bwe_exc ), 14 );
            FOR ( i = 0; i < L_FRAME16k / 4; i++ )
            {
#ifdef BASOP_NOGLOB
                exc4kWhtnd[i] = round_fx_o( L_shl_o( L_mult_o( exc4k_frac[i], scale, &Overflow), sc, &Overflow), &Overflow); /*  Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */
#else
                exc4kWhtnd[i] = round_fx( L_shl( L_mult( exc4k_frac[i], scale ), sc ) ); /*  Q_bwe_exc+n2-10+16+ Q_bwe_exc + n2 -14 -16 = //Q_bwe_exc */
#endif
            }
        }
        ELSE
@@ -1133,17 +1162,29 @@ void GenShapedWBExcitation_fx(
                }

                Ltemp1 = root_a_fx( L_deposit_h( tmp_vfac ), 31, &exp );
#ifdef BASOP_NOGLOB
                temp1 = round_fx_o( L_shl_o( Ltemp1, exp, &Overflow ), &Overflow ); /* Q15 */
#else
                temp1 = round_fx( L_shl( Ltemp1, exp ) ); /* Q15 */

#endif
                L_tmp = Mult_32_16( pow1, sub( 32767, tmp_vfac ) ); /* Q22*/
                Ltemp2 = root_a_over_b_fx( L_tmp, sub( 22, shl( n1, 1 ) ), pow22, sub( 22, shl( n2, 1 ) ), &exp );
#ifdef BASOP_NOGLOB
                temp2 = round_fx_o( L_shl_o( Ltemp2, exp, &Overflow ), &Overflow ); /* Q15 */
#else
                temp2 = round_fx( L_shl( Ltemp2, exp ) ); /* Q15 */

#endif
                FOR ( j = 0; j < L_FRAME16k / 16; j++ )
                {
#ifdef BASOP_NOGLOB
                    L_tmp = L_mult_o( temp1, exc4kWhtnd[k], &Overflow );/* Q(16+Q_bwe_exc) */
                    L_tmp = L_add_o( L_tmp, L_shl_o( L_mult_o( temp2, exc4k_frac[k], &Overflow), sc, &Overflow), &Overflow); /* Q(16+Q_bwe_exc) */
                    exc4kWhtnd[k] = round_fx_o( L_tmp, &Overflow); /* Q_bwe_exc */
#else
                    L_tmp = L_mult( temp1, exc4kWhtnd[k] );/* Q(16+Q_bwe_exc) */
                    L_tmp = L_add( L_tmp, L_shl( L_mult( temp2, exc4k_frac[k] ), sc ) ); /* Q(16+Q_bwe_exc) */
                    exc4kWhtnd[k] = round_fx( L_tmp ); /* Q_bwe_exc */
#endif
                    k++;
                }
            }
+8 −1
Original line number Diff line number Diff line
@@ -534,12 +534,19 @@ Word16 E_ACELP_xy1_corr(Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16
    L_off = L_shr(10737418l/*0.01f/2.0f Q31*/, s_min(add(exp_xn,exp_xn), 31));
    L_off = L_max(1,L_off); /* ensure at least a '1' */

#ifdef BASOP_NOGLOB
    /* Compute scalar product t1: <y1[] * y1[]> */
    yy = round_fx_o(Dot_product15_offs(y1, y1, L_subfr, &exp_yy, L_off), &Overflow);

    /* Compute scalar product t0: <xn[] * y1[]> */
    xy = round_fx_o(Dot_product12_offs(xn, y1, L_subfr, &exp_xy, L_off), &Overflow);
#else
    /* Compute scalar product t1: <y1[] * y1[]> */
    yy = round_fx(Dot_product15_offs(y1, y1, L_subfr, &exp_yy, L_off));

    /* Compute scalar product t0: <xn[] * y1[]> */
    xy = round_fx(Dot_product12_offs(xn, y1, L_subfr, &exp_xy, L_off));

#endif
    /* Compute doubled format out of the exponent */
    Q_xn = shl(sub(15,exp_xn),1);
    g_corr->y1y1   = yy;
+30 −2
Original line number Diff line number Diff line
@@ -165,6 +165,10 @@ void coder_acelp_rf(
    Word16 prev_gain_pit;
    Word16 rf_coder_type;
    Word16 lp_select;
#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif /* BASOP_NOGLOB */

    RF_ENC_HANDLE hRF = st->hRF;

    /* to avoid compilation warnings */
@@ -420,10 +424,22 @@ void coder_acelp_rf(
                 *-----------------------------------------------------------------*/
                /* st_fx->_rf_mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */
                Ltmp = Mpy_32_16_1(gain_code, y2[L_SUBFR-1]);
#ifdef BASOP_NOGLOB
                Ltmp = L_shl_o(Ltmp, add(5,Q_xn), &Overflow);
                Ltmp = L_mac_o(Ltmp, y1[L_SUBFR-1], gain_pit, &Overflow);
#else
                Ltmp = L_shl(Ltmp, add(5,Q_xn));
                Ltmp = L_mac(Ltmp, y1[L_SUBFR-1], gain_pit);
#endif
                /* Add Gaussian contribution*/
                Ltmp2 = Mpy_32_16_1(gain_code2, y22[L_SUBFR-1]);
#ifdef BASOP_NOGLOB
                Ltmp2 = L_shl_o(Ltmp2, add(5,Q_xn), &Overflow);
                Ltmp = L_add_o(Ltmp, Ltmp2, &Overflow);
                hRF->rf_mem_w0 =sub_o(xn[L_SUBFR-1], round_fx_o(L_shl_o(Ltmp, 1, &Overflow), &Overflow), &Overflow);
                move16();
                hRF->rf_mem_w0 =shr_o(hRF->rf_mem_w0, shift, &Overflow); /*Qnew-1*/
#else
                Ltmp2 = L_shl(Ltmp2, add(5,Q_xn));
                Ltmp = L_add(Ltmp, Ltmp2);
                hRF->rf_mem_w0 =sub(xn[L_SUBFR-1], round_fx(L_shl(Ltmp, 1)));
@@ -431,7 +447,7 @@ void coder_acelp_rf(
                BASOP_SATURATE_WARNING_OFF;
                hRF->rf_mem_w0 =shr(hRF->rf_mem_w0, shift); /*Qnew-1*/
                BASOP_SATURATE_WARNING_ON;

#endif


                /*-------------------------------------------------------*
@@ -445,19 +461,31 @@ void coder_acelp_rf(
                    {
                        /* code in Q9, gain_pit in Q14; exc Q_new */
                        Ltmp = Mpy_32_16_1(gain_code2, code2[i]);
#ifdef BASOP_NOGLOB
                        Ltmp = L_shl_o(Ltmp, Q_new_p5, &Overflow);
                        Ltmp = L_mac_o(Ltmp, gain_pit, exc_rf[i+i_subfr], &Overflow);
                        exc2[i] = round_fx_o(L_shl_o(Ltmp, 1, &Overflow), &Overflow);
#else
                        Ltmp = L_shl(Ltmp, Q_new_p5);
                        Ltmp = L_mac(Ltmp, gain_pit, exc_rf[i+i_subfr]);
                        BASOP_SATURATE_WARNING_OFF
                        exc2[i] = round_fx(L_shl(Ltmp, 1));
                        BASOP_SATURATE_WARNING_ON

#endif
                        Ltmp2 = Mpy_32_16_1(gain_code_vect[j], code[i]);
#ifdef BASOP_NOGLOB
                        Ltmp2 = L_shl_o(Ltmp2, Q_new_p5, &Overflow);
                        Ltmp = L_add_o(Ltmp, Ltmp2, &Overflow);
                        Ltmp = L_shl_o(Ltmp, 1, &Overflow);       /* saturation can occur here */
                        exc_rf[i + i_subfr] = round_fx_o(Ltmp, &Overflow);
#else
                        Ltmp2 = L_shl(Ltmp2, Q_new_p5);
                        Ltmp = L_add(Ltmp, Ltmp2);
                        BASOP_SATURATE_WARNING_OFF
                        Ltmp = L_shl(Ltmp, 1);       /* saturation can occur here */
                        BASOP_SATURATE_WARNING_ON
                        exc_rf[i + i_subfr] = round_fx(Ltmp);
#endif
                    }
                    tmp2 = L_SUBFR;
                }
+8 −2
Original line number Diff line number Diff line
@@ -387,15 +387,21 @@ Word16 gain_enc( /* o : quantization pitch index

    L_tmp = L_mult(g_code, gcode0);            /* Q11*Q15 -> Q27 */
    exp_gcode0 = add(exp_gcode0,-11);
#ifdef BASOP_NOGLOB
    L_tmp = L_shl_o(L_tmp, exp_gcode0, &Overflow);       /*   Q27 -> Q16 */
#else
    L_tmp = L_shl(L_tmp, exp_gcode0);       /*   Q27 -> Q16 */

#endif

    *gain_code = L_tmp;
    move32();
    /* Q16/Q12 => Q5 */
    L_tmp = L_deposit_h(BASOP_Util_Divide3216_Scale(L_tmp,*gain_inov,&i));
#ifdef BASOP_NOGLOB
    *past_gcode = L_shl_o(L_tmp,sub(i,15-12), &Overflow);
#else
    *past_gcode = L_shl(L_tmp,sub(i,15-12));

#endif

    return index;
}
+13 −2
Original line number Diff line number Diff line
@@ -115,12 +115,21 @@ void set_impulse_fx(
            /* nominator & DEnominator row <0> */
            FOR (i=0; i < L_SUBFR; i++)
            {
#ifdef BASOP_NOGLOB
                Lrr = L_mac_o(Lrr, gh_fx[i], gh_fx[i], &Overflow);
                Ldd = L_mac_o(Ldd, gh_fx[i], xn_fx[i], &Overflow);
#else
                Lrr = L_mac(Lrr, gh_fx[i], gh_fx[i]);
                Ldd = L_mac(Ldd, gh_fx[i], xn_fx[i]);
#endif
            }
            rr_fx[start1] = Lrr;
            move32();
#ifdef BASOP_NOGLOB
            dd_fx[start1] = round_fx_o(Ldd, &Overflow);
#else
            dd_fx[start1] = round_fx(Ldd);
#endif
            rr_fx[start1] = L_max(rr_fx[start1], 1);

            FOR (i=add(start1, 1); i<L_IMPULSE2; i++)
@@ -136,20 +145,22 @@ void set_impulse_fx(
                    move16();
#ifdef BASOP_NOGLOB
                    Lrr = L_mac_o(Lrr, gh_fx[j], gh_fx[j], &Overflow);
                    Ldd = L_mac_o(Ldd, gh_fx[j], xn_fx[j], &Overflow);
#else /* BASOP_NOGLOB */
                    Lrr = L_mac(Lrr, gh_fx[j], gh_fx[j]);
#endif /* BASOP_NOGLOB */
                    Ldd = L_mac(Ldd, gh_fx[j], xn_fx[j]);
#endif /* BASOP_NOGLOB */
                }

                gh_fx[0]  = mult_r(Glottal_cdbk_fx[m*L_IMPULSE+L_IMPULSE2-i],h_orig_fx[0]);
                move16();
#ifdef BASOP_NOGLOB
                Lrr = L_mac_o(Lrr, gh_fx[0], gh_fx[0], &Overflow);
                Ldd = L_mac_o(Ldd, gh_fx[0], xn_fx[0], &Overflow);
#else /* BASOP_NOGLOB */
                Lrr = L_mac(Lrr, gh_fx[0], gh_fx[0]);
#endif /* BASOP_NOGLOB */
                Ldd = L_mac(Ldd, gh_fx[0], xn_fx[0]);
#endif /* BASOP_NOGLOB */
                dd_fx[i] = round_fx(Ldd);
                rr_fx[i] = L_max(Lrr, 1);
                move32();