Commit 2e93c4ea authored by Sandesh Venkatesh's avatar Sandesh Venkatesh Committed by Manuel Jander
Browse files

Removed the dependency of common exp for mdst_spectrum_fx and spectrum_fx,...

Removed the dependency of common exp for mdst_spectrum_fx and spectrum_fx, fb_tbe_enc exponent correction
parent 03fbde15
Loading
Loading
Loading
Loading
+6 −38
Original line number Diff line number Diff line
@@ -2665,12 +2665,6 @@ void ms_inv_mask_processing_fx(
    const Word32 x_1_fx[],                   /* i  : spectrum 2                              */
    Word32 x_inv_0_fx[],                     /* o  : inverse spectrum 1                      */
    Word32 x_inv_1_fx[],                     /* o  : inverse spectrum 2                      */
#ifdef FIX_1464_NO_SINGLE_SPEC_Q
    Word16 *x_0_e,
    Word16 *x_1_e,
    Word16 *x_inv_0_e,
    Word16 *x_inv_1_e,
#endif
    Word16 maxSfb                            /* i  : number of stereo frequency bands        */
);

@@ -2681,10 +2675,6 @@ void ms_processing_fx(
    const Word16 iSubframe,                  /* i  : subframe number                 */
    Word32 x_0_fx[],                         /* i/o: spectrum 1                      */
    Word32 x_1_fx[],                         /* i/o: spectrum 1                      */
#ifdef FIX_1464_NO_SINGLE_SPEC_Q
    Word16 *x_0_e,
    Word16 *x_1_e,
#endif
    Word16 maxSfb                            /* i  : number of stereo frequency bands*/
);

@@ -2692,10 +2682,6 @@ void convertToMS_fx(
    const Word16 L_frame, /* i  : frame length                    */
    Word32 x0[],          /* i/o: mid/left channel coefficients   */
    Word32 x1[],          /* i/o: side/right channel coefficients */
#ifdef FIX_1464_NO_SINGLE_SPEC_Q
    Word16 *x0_e,
    Word16 *x1_e,
#endif
    const Word32 norm_fac /* i  : normalization factor            */
);

@@ -2709,12 +2695,7 @@ void IGFEncStereoEncoder_fx(
    const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i  : IGF handle                              */
    const Word32 *mdctSpectrumL_fx,        /* i  : left spectrum                           */
    const Word32 *mdctSpectrumR_fx,        /* i  : right spectrum                          */
#ifdef FIX_1464_NO_SINGLE_SPEC_Q
    const Word16 mdctSpectrumL_e,
    const Word16 mdctSpectrumR_e,
#else
    Word16 q_mdctSpectrum,
#endif
    Word16 *msMask,                /* i/o: MS mask                                 */
    Word16 *igfStereoMode,         /* o  : IGF stereo mode                         */
    const Word16 mdct_stereo_mode, /* i  : MDCT stereo mode                        */
@@ -2730,13 +2711,8 @@ void stereo_coder_tcx_fx(
    Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV],      /* i/o: inverse spectrum                */
    Word32 *inv_mdst_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum           */
    const Word16 mct_on,                                /* i  : flag mct block (1) or stereo (0)  */
#ifdef FIX_1464_NO_SINGLE_SPEC_Q
    Word16 mdst_spectrum_e[CPE_CHANNELS][NB_DIV],
    Word16 inv_spectrum_e[CPE_CHANNELS][NB_DIV],
    Word16 inv_mdst_spectrum_e[CPE_CHANNELS][NB_DIV] );
#else
    Word16 q_spec );
#endif
    Word16 exp_spec,
    Word16 exp_mdst_spec );

// bw_detect_fx.c
Word16 set_bw_mct_fx(
@@ -2765,11 +2741,6 @@ void apply_MCT_enc_fx(
    Word32 *mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV],     /* i/o: MDST spectrum                       */
    Word32 *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV],      /* i/o: inverse spectrum                    */
    Word32 *inv_mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum               */
#ifdef FIX_1464_NO_SINGLE_SPEC_Q
    Word16 mdst_spectrum_e[MCT_MAX_CHANNELS][NB_DIV],     /* i/o: MDST spectrum exponent             Q0*/
    Word16 inv_spectrum_e[MCT_MAX_CHANNELS][NB_DIV],      /* i/o: inv spectrum exponent             Q0*/
    Word16 inv_mdst_spectrum_e[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum exponent     Q0*/
#endif
    const Word16 nchan                                   /* i  : number of channels                  */
);

@@ -3372,9 +3343,6 @@ void mctStereoIGF_enc_fx(
    Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i  : same as powerSpec_fx but for inverse spect.*/
    Word16 q_powerSpecMsInv[MCT_MAX_CHANNELS],           /* i  : Q for powSpecMsInv_fx                      */
    Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][NB_DIV],   /* i  : inverse spectrum                           */
#ifdef FIX_1464_NO_SINGLE_SPEC_Q
    Word16 q_inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i  : Q for inv_spectrum_fx                      */
#endif
    const Word16 sp_aud_decision0[MCT_MAX_CHANNELS]      /* i  : speech audio decision                      */
);

+32 −53
Original line number Diff line number Diff line
@@ -359,13 +359,7 @@ static void getBlockValues_fx(
    Word32 *mdst_spectrum[MCT_MAX_CHANNELS][2],     /* i/o: MDST spectrum, Q = q_spec                     */
    Word32 *inv_spectrum[MCT_MAX_CHANNELS][2],      /* i/o: inverse spectrum, Q = q_spec                  */
    Word32 *inv_mdst_spectrum[MCT_MAX_CHANNELS][2], /* i/o: invers MDST spectrum, Q = q_spec              */
#ifdef FIX_1464_NO_SINGLE_SPEC_Q
    Word16 mdst_spectrum_e[MCT_MAX_CHANNELS][2],
    Word16 inv_spectrum_e[MCT_MAX_CHANNELS][2],
    Word16 inv_mdst_spectrum_e[MCT_MAX_CHANNELS][2]
#else
    Word16 q_spec                                   /* i  : common Q factor of the above spectrum buffers */
#endif
)
{
    Word16 n;
@@ -391,11 +385,7 @@ static void getBlockValues_fx(
    p_st[0] = sts[ch1];
    p_st[1] = sts[ch2];

#ifdef FIX_1464_NO_SINGLE_SPEC_Q
    stereo_coder_tcx_fx( hBlock->hStereoMdct, p_st, hBlock->mask, p_mdst_spectrum, p_inv_spectrum, p_inv_mdst_spectrum, 1, mdst_spectrum_e, inv_spectrum_e, inv_mdst_spectrum_e );
#else
    stereo_coder_tcx_fx( hBlock->hStereoMdct, p_st, hBlock->mask, p_mdst_spectrum, p_inv_spectrum, p_inv_mdst_spectrum, 1, sub( 31, q_spec ), sub( 31, q_spec ) );
#endif

    test();
    test();
@@ -639,11 +629,6 @@ void apply_MCT_enc_fx(
    Word32 *mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV],     /* i/o: MDST spectrum                       Qx*/
    Word32 *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV],      /* i/o: inverse spectrum                    Qx*/
    Word32 *inv_mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum               Qx*/
#ifdef FIX_1464_NO_SINGLE_SPEC_Q
    Word16 mdst_spectrum_e[MCT_MAX_CHANNELS][NB_DIV],     /* i/o: MDST spectrum exponent             Q0*/
    Word16 inv_spectrum_e[MCT_MAX_CHANNELS][NB_DIV],      /* i/o: inv spectrum exponent             Q0*/
    Word16 inv_mdst_spectrum_e[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum exponent     Q0*/
#endif
    const Word16 nchan                                   /* i  : number of channels                  */
)
{
@@ -818,11 +803,7 @@ void apply_MCT_enc_fx(
                /* calculate all related values: */
                assert( sts[ch1]->mct_chan_mode != MCT_CHAN_MODE_IGNORE && sts[ch2]->mct_chan_mode != MCT_CHAN_MODE_IGNORE );

#ifdef FIX_1464_NO_SINGLE_SPEC_Q
                getBlockValues_fx( sts, ch1, ch2, hMCT->hBlockData[currBlockDataCnt], mdst_spectrum, inv_spectrum, inv_mdst_spectrum, mdst_spectrum_e, inv_spectrum_e, inv_mdst_spectrum_e );
#else
                getBlockValues_fx( sts, ch1, ch2, hMCT->hBlockData[currBlockDataCnt], mdst_spectrum, inv_spectrum, inv_mdst_spectrum, sub( 31, sts[0]->hTcxEnc->spectrum_e[0] ) );
#endif

                IF( hMCT->hBlockData[currBlockDataCnt]->isActive == 0 )
                {
@@ -1007,9 +988,6 @@ void mctStereoIGF_enc_fx(
    Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i  : same as powerSpec_fx but for inverse spect.*/
    Word16 q_powerSpecMsInv[MCT_MAX_CHANNELS],           /* i  : Q for powSpecMsInv_fx                      */
    Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][NB_DIV],   /* i  : inverse spectrum                           */
#ifdef FIX_1464_NO_SINGLE_SPEC_Q
    Word16 q_inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i  : Q for inv_spectrum_fx                      */
#endif
    const Word16 sp_aud_decision0[MCT_MAX_CHANNELS]      /* i  : speech audio decision                      */
)
{
@@ -1019,11 +997,7 @@ void mctStereoIGF_enc_fx(
    Word32 *p_powerSpec_fx[NB_DIV];

    Word16 b, nSubframes, L_subframeTCX;
#ifdef FIX_1464_NO_SINGLE_SPEC_Q
    Word16 p_ch[2], n, ch, ch1, ch2;
#else
    Word16 p_ch[2], n, ch, ch1, ch2, s = 31;
#endif
    Word16 q_pSI_ch[2];
    Word16 q_pS_ch[2];
    Encoder_State *p_st[NB_DIV];
@@ -1098,34 +1072,39 @@ void mctStereoIGF_enc_fx(
            IF( NE_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[n], hMCT->hBlockData[b]->hStereoMdct->IGFStereoMode[n] ) ||
                EQ_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[n], SMDCT_BW_MS ) )
            {
#ifdef FIX_1464_NO_SINGLE_SPEC_Q
                Word16 exp_SI_ch[CPE_CHANNELS], exp_pS_ch[CPE_CHANNELS], exp_pSI_ch[CPE_CHANNELS];
                exp_SI_ch[0] = sub( 31, q_inv_spectrum[ch1][n] );
                exp_SI_ch[1] = sub( 31, q_inv_spectrum[ch2][n] );
                exp_pSI_ch[0] = sub( 31, q_pSI_ch[0] );
                exp_pSI_ch[1] = sub( 31, q_pSI_ch[1] );
                exp_pS_ch[0] = sub( 31, q_pS_ch[0] );
                exp_pS_ch[1] = sub( 31, q_pS_ch[1] );

                ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask,
                                     p_orig_spectrum_fx, q_origSpec, q_origSpec,
                                     p_powerSpec_fx, exp_pS_ch, p_powerSpecMsInv_fx, exp_pSI_ch, p_inv_spectrum_fx, exp_SI_ch, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 );
#else
                Word16 exp_powerSpec_fx[CPE_CHANNELS], exp_powerSpecMsInv_fx[CPE_CHANNELS], exp_inv_spectrum_fx[CPE_CHANNELS];

                Word16 exp_powerSpec_tmp[CPE_CHANNELS];
                Word16 exp_p_inv_spectrum[CPE_CHANNELS];
                FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
                {
                    s = s_min( s, sub( 31, p_st[ch]->hTcxEnc->spectrum_e[n] ) );
                    s = s_min( s, q_pS_ch[ch] );
                    s = s_min( s, q_pSI_ch[ch] );
                }
                FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
                {
                    exp_powerSpec_fx[ch] = sub( Q31, q_pS_ch[ch] );
                    exp_powerSpecMsInv_fx[ch] = sub( Q31, q_pSI_ch[ch] );
                    exp_inv_spectrum_fx[ch] = p_st[ch]->hTcxEnc->spectrum_e[n];
                    scale_sig32( p_st[ch]->hTcxEnc->spectrum_fx[0], N_MAX, sub( s, sub( 31, p_st[ch]->hTcxEnc->spectrum_e[0] ) ) );
                    scale_sig32( p_inv_spectrum_fx[ch][0], L_FRAME48k, sub( s, sub( 31, p_st[ch]->hTcxEnc->spectrum_e[0] ) ) );
                    p_st[ch]->hTcxEnc->spectrum_e[0] = sub( 31, s );
                    p_st[ch]->hTcxEnc->spectrum_e[1] = sub( 31, s );
                    move16();
                    move16();

                    scale_sig32( p_powerSpecMsInv_fx[ch][0], L_FRAME48k, sub( s, q_pSI_ch[ch] ) );
                    scale_sig32( &p_powerSpec_fx[ch][0], sts[ch]->hTcxEnc->L_frameTCX, sub( s, q_pS_ch[ch] ) );
                    q_powerSpec[ch1] = s;
                    q_powerSpec[ch2] = s;
                    move16();
                    move16();
                }

                ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask, p_orig_spectrum_fx, q_origSpec, q_origSpec, p_powerSpec_fx, exp_powerSpec_fx,
                                     p_powerSpecMsInv_fx, exp_powerSpecMsInv_fx, p_inv_spectrum_fx, exp_inv_spectrum_fx, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 );
#endif
                exp_powerSpec_tmp[0] = p_st[0]->hTcxEnc->spectrum_e[0];
                exp_powerSpec_tmp[1] = p_st[1]->hTcxEnc->spectrum_e[0];
                exp_p_inv_spectrum[0] = exp_p_inv_spectrum[1] = p_st[0]->hTcxEnc->spectrum_e[0];
                move16();
                move16();
                move16();
                move16();
                ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask, p_orig_spectrum_fx, q_origSpec, q_origSpec, p_powerSpec_fx, exp_powerSpec_tmp,
                                     p_powerSpecMsInv_fx, exp_powerSpec_tmp, p_inv_spectrum_fx, exp_p_inv_spectrum, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 );
            }
            ELSE
            {
@@ -1143,7 +1122,7 @@ void mctStereoIGF_enc_fx(
                    q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] );

                    set16_fx( exp_powerSpec[p_ch[ch]], sub( Q31, q_powerSpec[p_ch[ch]] ), N_MAX + L_MDCT_OVLP_MAX );
                    ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], &q_spectrum, orig_spectrum_fx[p_ch[ch]][n], q_origSpec, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &exp_powerSpec[p_ch[ch]][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
                    ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[p_ch[ch]][n], &q_spectrum, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &exp_powerSpec[p_ch[ch]][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );

                    st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum );
                    move16();
@@ -1184,7 +1163,7 @@ void mctStereoIGF_enc_fx(
                    q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] );

                    set16_fx( exp_powerSpec[ch], sub( Q31, q_powerSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX );
                    ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], &q_spectrum, orig_spectrum_fx[ch][n], q_origSpec, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );
                    ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 );

                    st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum );
                    move16();
+8 −261

File changed.

Preview size limit exceeded, changes collapsed.

+26 −321

File changed.

Preview size limit exceeded, changes collapsed.

+4 −3
Original line number Diff line number Diff line
@@ -7429,9 +7429,10 @@ void fb_tbe_enc_fx(

void fb_tbe_enc_ivas_fx(
    Encoder_State *st,        /* i/o: encoder state structure                 */
    const Word16 new_input[], /* i  : input speech at 48 kHz sample rate     Q0 */
    const Word16 new_input[], /* i  : input speech at 48 kHz sample rate     Q_new_input */
    const Word16 fb_exc[],    /* i  : FB excitation from the SWB part        Q_fb_exc */
    Word16 Q_fb_exc )
    Word16 Q_fb_exc,
    Word16 Q_new_input )
{
    Word16 ratio;
    Word16 tmp_vec[L_FRAME48k];
@@ -7465,7 +7466,7 @@ void fb_tbe_enc_ivas_fx(
    }

    Copy_Scale_sig( new_input - NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), input_fhb_new, L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), exp_temp );

    exp_temp = add( exp_temp, Q_new_input );
    IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) )
    {
#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic