Commit eba75150 authored by multrus's avatar multrus
Browse files

port float MR1575 to BASOP main

parent 494a65f4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3426,7 +3426,11 @@ void mctStereoIGF_enc_fx(
    Encoder_State **sts,                                 /* i/o: encoder state structure                    */
    Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2],       /* i  : MDCT spectrum for ITF                      */
    Word16 q_origSpec,                                   /* i  : Q for MDCT spectrum                        */
#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC
    Word32 *powerSpec[MCT_MAX_CHANNELS],                 /* i/o: MDCT^2 + MDST^2 spectrum,or estimate       */
#else
    Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k],   /* i/o: MDCT^2 + MDST^2 spectrum,or estimate       */
#endif
    Word16 q_powerSpec[MCT_MAX_CHANNELS],                /* i  : Q for powSpec_fx                           */
    Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i  : same as powerSpec_fx but for inverse spect.*/
    Word16 *q_powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV],  /* i  : Q for powSpecMsInv_fx                      */
+1 −0
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@
#define FIX_1138_SBA_EXT_ERROR_PRINTOUT                 /* VA: issue 1138: Fix SBA EXT output call of audioCfg2channels() */
#define NONBE_FIX_981_PARAMBIN_DEFAULT_EARLY_PART             /* Nokia: Set default early part energy correction to unity for BINAURAL_ROOM_REVERB */
#define NONBE_FIX_1174_MCMASA_LBR_LOOP_ERROR            /* Nokia: Fix issue 1174 by removing the unnecessary inner loop causing problems. */
#define NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC      /* FhG: fix out-of-bound errors when switching from SID frame to active frame*/

/* #################### End BASOP porting switches ############################ */

+77 −0
Original line number Diff line number Diff line
@@ -233,19 +233,39 @@ void ivas_mct_core_enc_fx(
    Word16 i, cpe_id, n, nAvailBits;
    Word16 nCPE;
    Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2]; /* Pointers to MDCT output for a short block (L/R) */
#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC
    Word32 powerSpecMsInv_long_cpe0_fx[CPE_CHANNELS][L_FRAME_PLUS];
    Word32 inv_spectrum_long_cpe0_fx[CPE_CHANNELS][L_FRAME_PLUS];
    Word32 powerSpec_long_cpe0_fx[CPE_CHANNELS][L_FRAME_PLUS];
    Word32 powerSpec_long_fx[MCT_MAX_CHANNELS - CPE_CHANNELS][L_FRAME48k];
    Word32 inv_spectrum_long_fx[MCT_MAX_CHANNELS - CPE_CHANNELS][L_FRAME48k];   /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */
    Word32 powerSpecMsInv_long_fx[MCT_MAX_CHANNELS - CPE_CHANNELS][L_FRAME48k]; /* MS inv power spectrum, also inverse MDST spectrum */
#else
    Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k];
#endif
    Word16 exp_powerSpec[MCT_MAX_CHANNELS][N_MAX + L_MDCT_OVLP_MAX];
    Word32 mdst_fx;
#ifndef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC
    Word32 powerSpecMsInv_long_fx[MCT_MAX_CHANNELS][L_FRAME48k]; /* MS inv power spectrum, also inverse MDST spectrum */
#endif
#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC
    Word32 *powerSpec_fx[MCT_MAX_CHANNELS];
#endif
    Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][2];
    Word32 *inv_mdst_spectrum_fx[MCT_MAX_CHANNELS][2];
    Word32 *inv_spectrum_fx[MCT_MAX_CHANNELS][2];
    Word32 *mdst_spectrum_fx[MCT_MAX_CHANNELS][2] = { { NULL } };
#ifndef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC
    Word32 inv_spectrum_long_fx[MCT_MAX_CHANNELS][L_FRAME48k]; /* quantized MDCT spectrum, inv ms mask mdst spectrum, scratch for MS spectra in the MS decision */
#endif
    Word16 total_side_bits;
    Word16 chBitRatios[MCT_MAX_CHANNELS];
    Word16 q_powSpec[MCT_MAX_CHANNELS], q_spec, q_origSpec, tmp_s;
#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC
    Word16 tmp_q_powSpec[L_FRAME_PLUS], tmp_q_powSpecInv[MCT_MAX_CHANNELS][L_FRAME_PLUS], *tmp_q_psi[MCT_MAX_CHANNELS][2];
#else
    Word16 tmp_q_powSpec[L_FRAME48k], tmp_q_powSpecInv[MCT_MAX_CHANNELS][L_FRAME48k], *tmp_q_psi[MCT_MAX_CHANNELS][2];
#endif
    Word64 W_tmp;
    Encoder_State *sts[MCT_MAX_CHANNELS];
    Encoder_State *st;
@@ -270,6 +290,62 @@ void ivas_mct_core_enc_fx(
        nCPE = add( nCPE, 1 );
    }

#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC
    /* point first CPE channels to longer buffers where switching from ACELP to TCX may occur in SBA with DTX (total memory saving)*/
    FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
    {
        set32_fx( inv_spectrum_long_cpe0_fx[ch], 0, L_FRAME_PLUS );
        set32_fx( powerSpec_long_cpe0_fx[ch], 0, L_FRAME_PLUS );      // tmp_q_powSpec
        set32_fx( powerSpecMsInv_long_cpe0_fx[ch], 0, L_FRAME_PLUS ); // tmp_q_powSpecInv

        inv_mdst_spectrum_fx[ch][0] = powerSpecMsInv_fx[ch][0] = powerSpecMsInv_long_cpe0_fx[ch];
        inv_mdst_spectrum_fx[ch][1] = powerSpecMsInv_fx[ch][1] = powerSpecMsInv_long_cpe0_fx[ch] + N_TCX10_MAX;

        set16_fx( tmp_q_powSpecInv[ch], 63, L_FRAME_PLUS );

        tmp_q_psi[ch][0] = tmp_q_powSpecInv[ch];
        tmp_q_psi[ch][1] = &tmp_q_powSpecInv[ch][N_TCX10_MAX];

        inv_spectrum_fx[ch][0] = inv_spectrum_long_cpe0_fx[ch];
        inv_spectrum_fx[ch][1] = inv_spectrum_long_cpe0_fx[ch] + N_TCX10_MAX;
        powerSpec_fx[ch] = powerSpec_long_cpe0_fx[ch];
    }
    FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
    {
        q_powSpec[ch] = 0;
        move16();
        set16_fx( exp_powerSpec[ch], 0, N_MAX + L_MDCT_OVLP_MAX );
    }

    FOR( ch = CPE_CHANNELS; ch < nChannels; ch++ )
    {
        set32_fx( inv_spectrum_long_fx[ch - CPE_CHANNELS], 0, L_FRAME48k );
        set32_fx( powerSpec_long_fx[ch - CPE_CHANNELS], 0, L_FRAME48k );      // tmp_q_powSpec
        set32_fx( powerSpecMsInv_long_fx[ch - CPE_CHANNELS], 0, L_FRAME48k ); // tmp_q_powSpecInv

        inv_mdst_spectrum_fx[ch][0] = powerSpecMsInv_fx[ch][0] = powerSpecMsInv_long_fx[ch - CPE_CHANNELS];
        inv_mdst_spectrum_fx[ch][1] = powerSpecMsInv_fx[ch][1] = powerSpecMsInv_long_fx[ch - CPE_CHANNELS] + N_TCX10_MAX;

        set16_fx( tmp_q_powSpecInv[ch], 63, L_FRAME48k );

        tmp_q_psi[ch][0] = tmp_q_powSpecInv[ch];
        tmp_q_psi[ch][1] = &tmp_q_powSpecInv[ch][N_TCX10_MAX];

        inv_spectrum_fx[ch][0] = inv_spectrum_long_fx[ch - CPE_CHANNELS];
        inv_spectrum_fx[ch][1] = inv_spectrum_long_fx[ch - CPE_CHANNELS] + N_TCX10_MAX;
        powerSpec_fx[ch] = powerSpec_long_fx[ch - CPE_CHANNELS];
    }

    FOR( ch = CPE_CHANNELS; ch < MCT_MAX_CHANNELS; ch++ )
    {
        set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k );
        q_powSpec[ch] = 0;
        move16();
        set16_fx( exp_powerSpec[ch], 0, N_MAX + L_MDCT_OVLP_MAX );
    }

    set16_fx( tmp_q_powSpec, 63, L_FRAME_PLUS );
#else
    FOR( ch = 0; ch < MCT_MAX_CHANNELS; ch++ )
    {
        set32_fx( powerSpecMsInv_long_fx[ch], 0, L_FRAME48k );
@@ -295,6 +371,7 @@ void ivas_mct_core_enc_fx(
    }

    set16_fx( tmp_q_powSpec, 63, L_FRAME48k );
#endif

    FOR( ( cpe_id = 0, i = 0 ); cpe_id < nCPE; cpe_id++ )
    {
+9 −5
Original line number Diff line number Diff line
@@ -983,7 +983,11 @@ void mctStereoIGF_enc_fx(
    Encoder_State **sts,                           /* i/o: encoder state structure                    */
    Word32 *orig_spectrum_fx[MCT_MAX_CHANNELS][2], /* i  : MDCT spectrum for ITF                      */
    Word16 q_origSpec,                             /* i  : Q for MDCT spectrum                        */
#ifdef NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC
    Word32 *powerSpec_fx[MCT_MAX_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate       */
#else
    Word32 powerSpec_fx[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate       */
#endif
    Word16 q_powerSpec[MCT_MAX_CHANNELS],                /* i  : Q for powSpec_fx                           */
    Word32 *powerSpecMsInv_fx[MCT_MAX_CHANNELS][NB_DIV], /* i  : same as powerSpec_fx but for inverse spect.*/
    Word16 *q_powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV],  /* i  : Q for powSpecMsInv_fx                      */