Commit 1d96c426 authored by kulgod's avatar kulgod
Browse files

basops + trying dyn q for enc_pit_exc

parent 8e6c4d1b
Loading
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -570,6 +570,7 @@ static void encod_gen_voic_core_switch_ivas_fx(
    Word16 h2[L_SUBFR + ( M + 1 )];
    Word16 dummyF[NB_SUBFR16k];
    Word16 lp_select, lp_flag;
    Word16 q_h1;
    LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */
    BSTR_ENC_HANDLE hBstr;

@@ -633,15 +634,9 @@ static void encod_gen_voic_core_switch_ivas_fx(
        weight_a_fx( A, Ap, GAMMA1, M ); /* Bandwidth expansion of A(z) filter coefficients */
        find_targets_ivas_fx( inp, hLPDmem->mem_syn, 0, &( hLPDmem->mem_w0 ), Aq, res, L_SUBFR, Ap, TILT_FAC_FX, xn, cn, h1 );
    }
#if 1
    Word16 q_h1 = 14 - norm_s( h1[0] );
    Copy_Scale_sig( h1, h2, L_SUBFR, 11 - q_h1 ); /*Q11*/
    //Scale_sig( h1, L_SUBFR, 14 - q_h1 );                /* set h1[] in Q14 with scaling for convolution Q14+shift*/
#else
    /*Scale_sig(h1, L_SUBFR, shift);  */ /*Q14-shift */
    Copy_Scale_sig( h1, h2, L_SUBFR, -2 );
    Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
#endif

    q_h1 = sub( 14, norm_s( h1[0] ) );
    Copy_Scale_sig( h1, h2, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/

    /* scaling of xn[] to limit dynamic at 12 bits */
    Scale_sig( xn, L_SUBFR, shift ); /* Q_new */
@@ -651,10 +646,9 @@ static void encod_gen_voic_core_switch_ivas_fx(
     * Adaptive exc. construction
     *----------------------------------------------------------------*/
    set16_fx( dummyF, -1, NB_SUBFR16k ); /* hack to signal ACELP->HQ switching frame */
    //scale_sig(h2, L_SUBFR, 2); //Q13

    pitch = pit_encode_ivas_fx( hBstr,
                                st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/, Q_new ); /* Q6 */
    //scale_sig(h2, L_SUBFR, -2); //Q11

    /*-----------------------------------------------------------------*
     * Find adaptive exitation
@@ -673,7 +667,7 @@ static void encod_gen_voic_core_switch_ivas_fx(
     * LP filtering of the adaptive excitation, codebook target computation
     *-----------------------------------------------------------------*/
    lp_flag = st_fx->acelp_cfg.ltf_mode;                                                                                                      /* Q0 */
    Scale_sig( h1, L_SUBFR, 14 - q_h1 );                                                                                                      /* set h1[] in Q14 with scaling for convolution Q14+shift*/
    Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) );                                                                                                /* set h1[] in Q14 with scaling for convolution Q14+shift*/
    lp_select = lp_filt_exc_enc_ivas_fx( MODE1, GENERIC, 0, exc, h1, xn, y1, xn2, L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */

    IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
+7 −17
Original line number Diff line number Diff line
@@ -465,13 +465,13 @@ void encod_gen_voic_ivas_fx(
    Word16 shift_wsp;
    Word16 harm_flag_acelp;
    Word16 lp_select, lp_flag, L_frame;
    Word16 q_h1;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
    SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
    BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
    SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
    LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;

    /*------------------------------------------------------------------*
@@ -553,23 +553,17 @@ void encod_gen_voic_ivas_fx(

        find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
                              res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
#if 1
        Word16 q_h1 = 14 - norm_s( h1_fx[0] );
        Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, 11 - q_h1 );  /*Q11*/
        //Scale_sig( h1_fx, L_SUBFR, 14 - q_h1 );                       /* set h1[] in Q14 with scaling for convolution Q14+shift*/
#else
        Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 );  /*Q11*/
        Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q14+shift*/
#endif

        q_h1 = sub( 14, norm_s( h1_fx[0] ) );
        Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/

        /* scaling of xn[] to limit dynamic at 12 bits */
        Scale_sig( xn_fx, L_SUBFR, shift );

        //Scale_sig( h2_fx, L_SUBFR, 2 ); // Q13
        *pt_pitch_fx = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx,
                                           L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new ); /* Q6 */
        //scale_sig( h2_fx, L_SUBFR, -2 );                                                                                                                                       // Q11
        move16();

        // tbe_celp_exc(L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx);
        tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag );

        /*-----------------------------------------------------------------*
@@ -594,7 +588,7 @@ void encod_gen_voic_ivas_fx(
        /*-----------------------------------------------------------------*
         * LP filtering of the adaptive excitation, codebook target computation
         *-----------------------------------------------------------------*/
        Scale_sig( h1_fx, L_SUBFR, 14 - q_h1 );
        Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/
        lp_select = lp_filt_exc_enc_ivas_fx( MODE1, st_fx->coder_type, i_subfr_fx, exc_fx, h1_fx,
                                             xn_fx, y1_fx, xn2_fx, L_SUBFR, L_frame, g_corr_fx, clip_gain_fx, &gain_pit_fx, &lp_flag );

@@ -603,10 +597,6 @@ void encod_gen_voic_ivas_fx(
            push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 );
        }

        /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/
        hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /* Q14 */
        move16();

        /*-----------------------------------------------------------------*
         * Transform domain contribution encoding - active frames
         *-----------------------------------------------------------------*/
+8 −16
Original line number Diff line number Diff line
@@ -580,7 +580,7 @@ void enc_pit_exc_ivas_fx(
    Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */
    Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes*/
    Word16 h1_q15[PIT_EXC_L_SUBFR + ( M + 1 )];
    SP_MUS_CLAS_HANDLE hSpMusClas = st_fx->hSpMusClas;
    Word16 q_h1;
    BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
    GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc;
    LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
@@ -739,14 +739,10 @@ void enc_pit_exc_ivas_fx(

        find_targets_ivas_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq,
                              res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
#if 1
        Word16 q_h1 = 14 - norm_s( h1[0] );
        Copy_Scale_sig( h1, h2, L_subfr, 11 - q_h1 ); /*Q11*/
        Scale_sig( h1, L_subfr, 14 - q_h1 );          /* set h1[] in Q14 with scaling for convolution Q14+shift*/
#else
        Copy_Scale_sig( h1, h2, L_subfr, -2 );     /* Q13 */
        Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
#endif

        q_h1 = sub( 14, norm_s( h1[0] ) );
        Copy_Scale_sig( h1, h2, L_subfr, sub( 11, q_h1 ) ); /*Q11*/

        /* scaling of xn[] to limit dynamic at 12 bits */
        Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */

@@ -754,11 +750,12 @@ void enc_pit_exc_ivas_fx(
         * Close-loop pitch search and quantization
         * Adaptive exc. construction
         *----------------------------------------------------------------*/
        //scale_sig(h2, L_subfr, 2); // Q13

        *pt_pitch = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc,
                                        L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new ); /* Q6 */
        move16();
        //scale_sig(h2, L_subfr, -2); // Q11
        Scale_sig( h1, L_subfr, sub( 14, q_h1 ) );          /* set h1[] in Q14 with scaling for convolution Q14*/

        /*-----------------------------------------------------------------*
         * Find adaptive exitation
         *-----------------------------------------------------------------*/
@@ -775,8 +772,6 @@ void enc_pit_exc_ivas_fx(
         * Codebook target computation
         * (No LP filtering of the adaptive excitation)
         *-----------------------------------------------------------------*/
        //Scale_sig( h1, L_subfr, 14 - q_h1 ); /* set h1[] in Q14 with scaling for convolution Q14+shift*/

        Copy_Scale_sig( h1, h1_q15, L_subfr, 1 ); // Q14 -> Q15

        lp_select = lp_filt_exc_enc_ivas_fx( MODE1, AUDIO, i_subfr, exc, h1_q15,
@@ -787,9 +782,6 @@ void enc_pit_exc_ivas_fx(
            push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 );
        }

        /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/
        hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/

        gpit_tmp = gain_pit;
        move16(); /*Q14*/
        test();
+6 −9
Original line number Diff line number Diff line
@@ -467,6 +467,7 @@ Word16 encod_tran_ivas_fx(
    Word16 L_frame_fx;
    Word16 shift_wsp;
    Word32 L_tmp;
    Word16 q_h1;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
@@ -539,14 +540,11 @@ Word16 encod_tran_ivas_fx(

        find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
                              res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
#if 1
        Word16 q_h1 = 14 - norm_s( h1[0] );
        Copy_Scale_sig( h1, h2_fx, L_SUBFR, 11 - q_h1 ); /*Q11*/
        //Scale_sig( h1, L_subfr, 14 - q_h1 );          /* set h1[] in Q14 with scaling for convolution Q14+shift*/
        Scale_sig( h1, L_SUBFR, 13 - q_h1 );          /* set h1[] in Q14 with scaling for convolution Q14+shift*/
#else
        Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 );
#endif

        q_h1 = sub( 14, norm_s( h1[0] ) );
        Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/
        Scale_sig( h1, L_SUBFR, sub( 13, q_h1 ) );

        /* scaling of xn[] to limit dynamic at 12 bits */
        Scale_sig( xn, L_SUBFR, shift );

@@ -564,7 +562,6 @@ Word16 encod_tran_ivas_fx(

        IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
        {
            //Scale_sig( h1, L_SUBFR, 14 - q_h1 ); /* set h1[] in Q14 with scaling for convolution */
            Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
            transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx,
                                     &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift );
+6 −9
Original line number Diff line number Diff line
@@ -279,6 +279,7 @@ void encod_unvoiced_ivas_fx(
    Word16 i_subfr, Q_xn, Q_new_p5, tmp2, j, i;
    Word16 index, i_subfr_idx;
    Word16 unbits_PI;
    Word16 q_h1;
    acelp_cfg = &( st_fx->acelp_cfg );
    SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
    LPD_state_HANDLE hLPDmem = st_fx->hLPDmem;
@@ -318,14 +319,10 @@ void encod_unvoiced_ivas_fx(

        find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx,
                              res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
#if 1
        Word16 q_h1 = 14 - norm_s( h1_fx[0] );
        Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, 11 - q_h1 );
        Scale_sig( h1_fx, L_SUBFR, 14 - q_h1 );
#else
        Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 );
        Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
#endif

        q_h1 = sub( 14, norm_s( h1_fx[0] ) );
        Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) );
        Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) );

        /* scaling of xn[] to limit dynamic at 12 bits */
        Scale_sig( xn_fx, L_SUBFR, shift ); // Q_new - 1 + shift
Loading