Commit ad936ef6 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'Q_info_updates_basop_instrumentation_enc_1' into 'main'

Q info updates, basop instrumentation updates for lib_enc

See merge request !894
parents e6f72668 4809aa10
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3818,7 +3818,7 @@ detect_transient_fx.c
Word16 detect_transient_fx(
    const Word16 *in_fx, /*Q_new */
    const Word16 L,
    const Word16 L,      /*Q0*/
    Word16 Q_new,
    Encoder_State *st_fx );
+4 −4
Original line number Diff line number Diff line
@@ -1046,7 +1046,7 @@ static void ivas_find_enr1(

            // *ptE *= norm_val;                 /* normalization - corresponds to FFT normalization by 2/L_FFT */
            Ltmp = Mpy_32_32( Ltmp, norm_val );                                                                     // 2 * Qfft + te_exp - 32
            *ptE = L_shl( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2
            *ptE = L_shl_sat( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2
            move32();

            *Bin_E++ = *ptE; // Q_new + QSCALE - 2
@@ -1095,7 +1095,7 @@ static void ivas_find_enr1(

                // *Bin_E *= norm_val;
                Ltmp = Mpy_32_32( Ltmp, norm_val );                                                                       // 2 * Qfft + te_exp - 32
                *Bin_E = L_shl( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2
                *Bin_E = L_shl_sat( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2
                move32();

                band[i] = L_add_sat( band[i], *Bin_E++ ); // Q_new + QSCALE - 2
+1 −1
Original line number Diff line number Diff line
@@ -353,7 +353,7 @@ void core_encode_openloop_fx(
        IF( EQ_16( st->mdct_sw, MODE1 ) )
        {
            /* Account for core signaling bits difference: bandwidth and ACELP/TCX signaling bit are replaced */
            target_bits = add( target_bits, sub( add( FrameSizeConfig[st->frame_size_index].bandwidth_bits, 1 ), signalling_mode1_tcx20_enc( st, 0 ) ) );
            target_bits = add( target_bits, sub( add( FrameSizeConfig[st->frame_size_index].bandwidth_bits, 1 ), signalling_mode1_tcx20_enc_fx( st, 0 ) ) );
        }
        ELSE if ( EQ_16( st->mdct_sw_enable, MODE2 ) )
        {
+40 −38
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@

void core_switching_pre_enc_fx(
    Encoder_State *st_fx,          /* i/o: encoder state structure           */
    const Word16 *old_inp_12k8,    /* i  : old input signal @12.8kHz         */
    const Word16 *old_inp_16k,     /* i  : old input signal @16kHz           */
    const Word16 active_cnt,       /* i  : active frame counter              */
    const Word16 last_element_mode /* i  : last_element_mode                 */
    const Word16 *old_inp_12k8,    /* i  : old input signal @12.8kHz         Qx*/
    const Word16 *old_inp_16k,     /* i  : old input signal @16kHz           Qx*/
    const Word16 active_cnt,       /* i  : active frame counter              Q0*/
    const Word16 last_element_mode /* i  : last_element_mode                 Q0*/
)
{
    Word16 Sample_Delay_HP, Sample_Delay_LP;
@@ -46,7 +46,7 @@ void core_switching_pre_enc_fx(
        {
            st_fx->mem_deemph_fx = hLPDmem->syn[M];
            move16();
            Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M );
            Copy( hLPDmem->mem_syn2, hLPDmem->mem_syn1_fx, M ); /*hLPDmem->q_mem_syn*/
        }

        if ( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) )
@@ -102,9 +102,9 @@ void core_switching_pre_enc_fx(
        test();
        IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) && ( EQ_16( st_fx->last_L_frame, L_FRAME ) ) )
        {
            Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M );
            Copy( st_fx->lsp_old_fx, st_fx->lsp_old16k_fx, M ); /*Q15*/

            st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 );
            st_fx->rate_switching_reset_16kHz = lsp_convert_poly_fx( st_fx->lsp_old16k_fx, st_fx->L_frame, 0 ); /*Q0*/
        }

        st_fx->use_acelp_preq = 0;
@@ -141,7 +141,7 @@ void core_switching_pre_enc_fx(
        hHQ_core->prev_stab_hfe2 = 0;
        move16();

        if ( hTcxEnc != NULL )
        IF( hTcxEnc != NULL )
        {
            set16_fx( hTcxEnc->old_out_fx, 0, L_FRAME32k );
        }
@@ -151,7 +151,7 @@ void core_switching_pre_enc_fx(
       within ACELP_CORE if switching from another bitarate to vbr, last_ppp and last_nelp is always updated in the previous frame */
    test();
    test();
    IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) )
    IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) ) )
    {
        IF( hSC_VBR != NULL )
        {
@@ -167,7 +167,7 @@ void core_switching_pre_enc_fx(
    test();
    test();
    test();
    IF( EQ_16( st_fx->core, ACELP_CORE ) && ( NE_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) )
    IF( ( st_fx->core == ACELP_CORE ) && ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->last_codec_mode, MODE2 ) || LE_32( st_fx->last_total_brate, PPP_NELP_2k80 ) ) )
    {
        st_fx->act_count = 3;
        move16();
@@ -177,17 +177,17 @@ void core_switching_pre_enc_fx(

    test();
    test();
    IF( ( ( EQ_16( st_fx->core, ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) ||
    IF( ( ( ( st_fx->core == ACELP_CORE ) || EQ_16( st_fx->core, AMR_WB_CORE ) ) && EQ_16( st_fx->last_core, HQ_CORE ) ) ||
        ( ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) || EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( last_element_mode, IVAS_CPE_DFT ) ) ) && EQ_16( active_cnt, 1 ) ) )
    {
        IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
        {
            Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */
            Copy( TRWB2_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP Qlog2(2.56)*/
            lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_16k );
        }
        ELSE
        {
            Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP */
            Copy( TRWB_Ave_fx, st_fx->lsf_old_fx, M ); /* init of LSP Qlog2(2.56)*/
            lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, INT_FS_FX );
        }

@@ -217,7 +217,7 @@ void core_switching_pre_enc_fx(
        move16();

        set16_fx( st_fx->mem_MA_fx, 0, M );
        Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M );
        Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); /*Qlog2(2.56)*/
        init_gp_clip_fx( st_fx->clip_var_fx );
        st_fx->last_coder_type = GENERIC;
        move16();
@@ -231,7 +231,7 @@ void core_switching_pre_enc_fx(
            move16();
        }

        Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 );
        Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/
        set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 );

        /* Reset old ACELP buffers */
@@ -280,7 +280,7 @@ void core_switching_pre_enc_fx(
        move16();

        tmp16 = shr( st_fx->L_frame, 6 );
        Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 );
        Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/
        set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 );

        /* Reset old TD BWE buffers */
@@ -337,7 +337,7 @@ void core_switching_pre_enc_fx(
                }
                Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) );
            }
            Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP );
            Copy( old_inp_12k8 + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/
        }
        ELSE
        {
@@ -352,11 +352,11 @@ void core_switching_pre_enc_fx(
                Sample_Delay_HP = sub( Sample_Delay_HP, NS2SA( 16000, DELAY_FIR_RESAMPL_NS ) );
            }

            Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP );
            Copy( old_inp_16k + sub( L_INP_MEM + L_FRAME, Sample_Delay_LP ), hBWE_FD->old_input_lp_fx, Sample_Delay_LP ); /*Qx*/
        }

        tmp = sub( L_LOOK_16k + L_SUBFR16k, Sample_Delay_HP );
        Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP );
        Copy( &hBWE_TD->old_speech_shb_fx[tmp], hBWE_FD->new_input_hp_fx, Sample_Delay_HP ); /*Q(Q_shb_spch)*/
        add( 0, 0 );

        IF( NE_16( st_fx->last_extl, WB_BWE ) )
@@ -367,8 +367,8 @@ void core_switching_pre_enc_fx(
            move16();
        }
        hBWE_FD->EnergyLF_fx = L_deposit_l( 0 );
        hBWE_FD->prev_L_swb_norm1 = 8;
        move16(); /*8.0 in Q0 */
        hBWE_FD->prev_L_swb_norm1 = 8; /*8.0 in Q0 */
        move16();
        st_fx->EnergyLT_fx_exp = 30;
        move16(); /* Set to a High Exponent so it is 1^-30 */
    }
@@ -428,7 +428,7 @@ void core_switching_post_enc_fx(

        test();
        test();
        IF( ( EQ_16( st_fx->last_core, ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) && EQ_16( st_fx->element_mode, EVS_MONO ) ) /* core switching ==> CELP subframe encoding */
        IF( ( ( st_fx->last_core == ACELP_CORE ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) && EQ_16( st_fx->element_mode, EVS_MONO ) ) /* core switching ==> CELP subframe encoding */
        {
            acelp_core_switch_enc_fx( st_fx, old_inp_12k8 + L_INP_MEM - NS2SA_FX2( INT_FS_FX, ACELP_LOOK_NS ),
                                      old_inp_16k + L_INP_MEM - NS2SA_FX2( INT_FS_16k, ACELP_LOOK_NS ), A, Qshift, Q_new );
@@ -513,8 +513,8 @@ void core_switching_post_enc_fx(
            set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD );
            set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER );
            set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER );
            hBWE_TD->gain_prec_swb_fx = 16384;
            move16(); /*Q14 = 1 */
            hBWE_TD->gain_prec_swb_fx = 16384; /*Q14 = 1 */
            move16();
        }
        ELSE IF( EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) )
        {
@@ -522,6 +522,8 @@ void core_switching_post_enc_fx(
        }
        test();
        test();
        test();
        test();
        IF( EQ_16( st_fx->extl, FB_TBE ) && ( ( NE_16( st_fx->last_extl, FB_TBE ) && NE_16( st_fx->last_core, TCX_20_CORE ) && NE_16( st_fx->last_core, TCX_10_CORE ) ) || NE_16( st_fx->L_frame, st_fx->last_L_frame ) ) )
        {
            set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER );
@@ -551,10 +553,10 @@ void core_switching_post_enc_fx(

void core_switching_hq_prepare_enc_fx(
    Encoder_State *st_fx,     /* i/o: encoder state structure */
    Word16 *num_bits,         /* i/o: bit budget update       */
    const Word16 input_frame, /* i  : frame length            */
    Word16 *num_bits,         /* i/o: bit budget update       Q0*/
    const Word16 input_frame, /* i  : frame length            Q0*/
    Word32 *wtda_audio,       /* shall be q_audio + 15, audio allready scalled in wtda function  */
    const Word16 *audio )
    const Word16 *audio /*q_audio*/ )
{
    Word16 delta, Loverlapp, i;
    Word16 tmp16;
@@ -568,22 +570,22 @@ void core_switching_hq_prepare_enc_fx(
        case L_FRAME8k:
            delta = 1;
            move16();
            pt_cos = sin_switch_8;
            pt_cos = sin_switch_8; /*Q15*/
            BREAK;
        case L_FRAME16k:
            delta = 2;
            move16();
            pt_cos = sin_switch_16;
            pt_cos = sin_switch_16; /*Q15*/
            BREAK;
        case L_FRAME32k:
            delta = 4;
            move16();
            pt_cos = sin_switch_32;
            pt_cos = sin_switch_32; /*Q15*/
            BREAK;
        default:
            delta = 6;
            move16();
            pt_cos = sin_switch_48;
            pt_cos = sin_switch_48; /*Q15*/
            BREAK;
    }

@@ -642,25 +644,25 @@ void core_switching_hq_prepare_enc_fx(
    }

    /* Transition window at the encoder */
    n = i_mult2( N_ZERO_8, delta );
    Loverlapp = i_mult2( SWITCH_OVERLAP_8k, delta );
    n = i_mult2( N_ZERO_8, delta );                  /*Q0*/
    Loverlapp = i_mult2( SWITCH_OVERLAP_8k, delta ); /*Q0*/
    /*Overflow=0; */

    pt_32 = wtda_audio + shr( input_frame, 1 );
    pt_16 = audio + sub( n, 1 );
    pt_32 = wtda_audio + shr( input_frame, 1 ); /*q_audio+15*/
    pt_16 = audio + sub( n, 1 );                /*q_audio*/
    tmp16 = sub( shr( input_frame, 1 ), Loverlapp );

    FOR( i = 0; i < tmp16; i++ )
    {
        /* wtda_audio[i+input_frame/2] = - audio[n-i-1]; */
        *pt_32++ = L_negate( L_shr( L_deposit_h( *pt_16-- ), 1 ) ); /*   Q +16 -1  */
        *pt_32++ = L_negate( L_shr( L_deposit_h( *pt_16-- ), 1 ) ); /*q_audio+15*/
    }

    pt_cos = pt_cos + Loverlapp - 1;
    pt_cos = pt_cos + Loverlapp - 1; /*Q15*/
    FOR( i = tmp16; i < shr( input_frame, 1 ); i++ )
    {
        /* *pt_32++ =  - audio[n-i-1] *(float)cos((i+1-input_frame/2+Loverlapp)*EVS_PI/(2*(Loverlapp+1)));   win=cos() */
        *pt_32++ = L_negate( L_mult0( *pt_16--, *pt_cos-- ) );
        *pt_32++ = L_negate( L_mult0( *pt_16--, *pt_cos-- ) ); /*q_audio+15*/
    }

    IF( hTcxEnc != NULL )
+17 −17
Original line number Diff line number Diff line
@@ -24,9 +24,9 @@
 *   y[i]=sum(j=i,l-1) x[j]*h[j-i], i=0,l-1
 *-------------------------------------------------------------------*/
void corr_xh_fx(
    const Word16 x[], /* i  : target signal                                   */
    Word16 dn[],      /* o  : correlation between x[] and h[]                 */
    const Word16 h[]  /* i  : impulse response (of weighted synthesis filter) */
    const Word16 x[], /* i  : target signal                                   Qx*/
    Word16 dn[],      /* o  : correlation between x[] and h[]                 Qdn = Qx+j-1*/
    const Word16 h[]  /* i  : impulse response (of weighted synthesis filter) Q14*/
)
{
    Word16 i, j, k;
@@ -44,20 +44,20 @@ void corr_xh_fx(
        L_maxloc = L_deposit_l( 0 );
        FOR( i = k; i < L_SUBFR; i += STEP )
        {
            L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] */
            L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] Qx+15*/
            FOR( j = i; j < L_SUBFR - 1; j++ )
            {
#ifdef BASOP_NOGLOB
                L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow );
                L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/
#else
                L_tmp = L_mac( L_tmp, x[j + 1], h[j + 1 - i] );
#endif
            }

            y32[i] = L_tmp;
            y32[i] = L_tmp; /*Qx+15*/
            move32();
            L_tmp = L_abs( L_tmp );
            L_maxloc = L_max( L_tmp, L_maxloc );
            L_maxloc = L_max( L_tmp, L_maxloc ); /*Qx+15*/
        }
        /* tot += 3*max / 8 */
        L_maxloc = L_shr( L_maxloc, 2 );
@@ -77,7 +77,7 @@ void corr_xh_fx(

    FOR( i = 0; i < L_SUBFR; i++ )
    {
        dn[i] = round_fx( L_shl( y32[i], j ) );
        dn[i] = round_fx( L_shl( y32[i], j ) ); /*Qx+15+j-16*/
    }
    return;
}
@@ -86,7 +86,7 @@ void corr_hh_ivas_fx(
    const Word16 *h, /* i  : target signal                                  e(norm_s(h1[0])+1) */
    Word16 *y,       /* o  : correlation between x[] and h[]                Q_new + 1 */
    Word16 *Qy,
    const Word16 L_subfr /* i  : length of the subframe                          */
    const Word16 L_subfr /* i  : length of the subframe                          Q0*/
)
{
    Word16 i, j, k;
@@ -114,10 +114,10 @@ void corr_hh_ivas_fx(
#endif
            }

            y32[i] = L_tmp;
            y32[i] = L_tmp; // 2*(15 - norm_s(h[0]) -3) - 1
            move32();
            L_tmp = L_abs( L_tmp );
            L_maxloc = L_max( L_tmp, L_maxloc );
            L_maxloc = L_max( L_tmp, L_maxloc ); // 2*(15 - norm_s(h[0]) -3) - 1
        }
        /* tot += 3*max / 8 */
        L_maxloc = L_shr( L_maxloc, 2 );
@@ -147,12 +147,12 @@ void corr_hh_ivas_fx(
}

void corr_xh_ivas_fx(
    const Word16 x[], /* i  : target signal                                   */
    const Word16 x[], /* i  : target signal                                   Qx*/
    const Word16 Qx,
    Word16 dn[], /* o  : correlation between x[] and h[]                 */
    Word16 dn[], /* o  : correlation between x[] and h[]                 Qdn*/
    Word16 *Qdn,
    const Word16 h[],    /* i  : impulse response (of weighted synthesis filter) */
    const Word16 L_subfr /* i  : length of the subframe                          */
    const Word16 h[],    /* i  : impulse response (of weighted synthesis filter) (Q15 - norm_s(h[0]))*/
    const Word16 L_subfr /* i  : length of the subframe                          Q0*/
)
{
    Word16 i, j, k;
@@ -180,10 +180,10 @@ void corr_xh_ivas_fx(
#endif
            }

            y32[i] = L_tmp;
            y32[i] = L_tmp; // Qx+(15 - norm_s(h[0]))
            move32();
            L_tmp = L_abs( L_tmp );
            L_maxloc = L_max( L_tmp, L_maxloc );
            L_maxloc = L_max( L_tmp, L_maxloc ); // Qx+(15 - norm_s(h[0]))
        }
        /* tot += 3*max / 8 */
        L_maxloc = L_shr( L_maxloc, 2 );
Loading