Commit 6d538ee3 authored by vaclav's avatar vaclav
Browse files

Merge branch '1926-basop-PortFlpMr2050' into 'main'

Port MR2050 from float to BASOP

Closes #1926

See merge request !2114
parents f491056a 1c82e02a
Loading
Loading
Loading
Loading
Loading
+48 −49
Original line number Diff line number Diff line
@@ -6198,7 +6198,7 @@ ivas_error ivas_core_enc_fx(
    const Word16 n_CoreChannels,                                /* i  : number of core channels to be coded     Q0*/
    Word16 old_inp_12k8_fx[][L_INP_12k8],                       /* i  : buffer of old input signal              Q_new-1*/
    Word16 old_inp_16k_fx[][L_INP],                             /* i  : buffer of old input signal              Q_new-1*/
    Word16 Q_new[],
    Word16 Q_new[],                                             /* i  : Q factor of speech buffers              */
    Word32 ener_fx[],                                           /* i  : residual energy from Levinson-Durbin	epsP_fx_q*/
    Word16 A_fx[][NB_SUBFR16k * ( M + 1 )],                     /* i  : A(z) unquantized for the 4 subframes    Q12*/
    Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )],                    /* i  : weighted A(z) unquantized for subframes Q12*/
@@ -6210,9 +6210,9 @@ ivas_error ivas_core_enc_fx(
    Word16 attack_flag[],                                       /* i  : attack flag (GSC or TC)                 Q0*/
    Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer                        q_re_im_buf*/
    Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer                        q_re_im_buf*/
    Word16 *q_re_im_buf,
    Word16 *q_re_im_buf,                                        /* i  : Q factor of re/in CLDFB buffers         */
    Word16 old_wsp_fx[][L_WSP],                                 /* i  : weighted input signal buffer            e_old_wsp*/
    Word16 e_old_wsp[],
    Word16 e_old_wsp[],                                         /* i  : Q factor of old_wsp buffer              */
    const Word16 loc_harm[],                                    /* i  : harmonicity flag						Q0*/
    const Word16 cor_map_sum_fx[],                              /* i  : speech/music clasif. parameter			Q8*/
    const Word16 vad_flag_dtx[],                                /* i  : HE-SAD flag with additional DTX HO		Q0*/
@@ -6308,12 +6308,11 @@ ivas_error ivas_ism_metadata_enc_create_fx(
    Word32 element_brate_tmp[]                                  /* o  : element bitrate per object                  */
);


/*----------------------------------------------------------------------------------*
 * Parametric ISM prototypes
 *----------------------------------------------------------------------------------*/

/*! r: ISM format mode */

ivas_error ivas_param_ism_enc_open_fx(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder structure                      */
);
@@ -6328,11 +6327,11 @@ void ivas_ism_metadata_close(
    const Word16 first_idx                                      /* i  : index of first handle to deallocate         */
);


ivas_error ivas_ism_enc_config(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder structure                      */
);


/*----------------------------------------------------------------------------------*
 * ISM DTX prototypes
 *----------------------------------------------------------------------------------*/
+1 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@
#define NONBE_1240_FIX_CORE_SELECTION_ISM_SW            /* VA: issue 1240: Remove the forcing of the TCX core in ISM when switching from a high bitarte to a low one */
#define FIX_1101_CLEANING_JBM_CALL                      /* VA: issue 1101: remove obsolete call of ivas_jbm_dec_tc_buffer_open() */
#define FIX_VOIP_FUNCTIONS                              /* VA: fix data type mismatch in IVAS_DEC_VoIP_SetScale() + add sanity checks to API functions */
#define FIX_1298_MEMORY_OPT_IVAS_CORE_ENC               /* VA: issue 1298: Memory saving in ivas_core_enc() */
#define NONBE_FIX_1337_MISSING_DIRECTIVITY_DISTATT_EXTREND /* Eri: issue 1337: Missing directivity setting and distance attenuation in external renderer IVAS_rend */
#define NONBE_1214_PLC_LSF_MEMORY                       /* VA: issue 1224: reset ACELP PLC FEC memory in case of switching from MDCT stereo to TD/DFT stereo */
#define NONBE_1293_SR_HRTF                              /* VA: issue 1293: add support of external HRTFs in split rendering */
+57 −36
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@
 *
 * Principal IVAS core coder routine, where number of core channels is 1 or 2
 *-------------------------------------------------------------------*/

ivas_error ivas_core_enc_fx(
    SCE_ENC_HANDLE hSCE,                                             /* i/o: SCE encoder structure                              */
    CPE_ENC_HANDLE hCPE,                                             /* i/o: CPE encoder structure                              */
@@ -58,7 +59,7 @@ ivas_error ivas_core_enc_fx(
    const Word16 n_CoreChannels,                                     /* i  : number of core channels to be coded              Q0*/
    Word16 old_inp_12k8_fx[][L_INP_12k8],                            /* i  : buffer of old input signal                  Q_new-1*/
    Word16 old_inp_16k_fx[][L_INP],                                  /* i  : buffer of old input signal                  Q_new-1*/
    Word16 Q_new[],
    Word16 Q_new[],                                                  /* i  : Q factor of speech buffers                         */
    Word32 ener_fx[],                                                /* i  : residual energy from Levinson-Durbin	   epsP_fx_q*/
    Word16 A_fx[][NB_SUBFR16k * ( M + 1 )],                          /* i  : A(z) unquantized for the 4 subframes            Q12*/
    Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )],                         /* i  : weighted A(z) unquantized for subframes         Q12*/
@@ -70,9 +71,9 @@ ivas_error ivas_core_enc_fx(
    Word16 attack_flag[],                                            /* i  : attack flag (GSC or TC)                          Q0*/
    Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer                             q_re_im_buf*/
    Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer                             q_re_im_buf*/
    Word16 *q_re_im_buf,
    Word16 *q_re_im_buf,                                             /* i  : Q factor of re/im CLDFB buffers                    */
    Word16 old_wsp_fx[][L_WSP],                                      /* i  : weighted input signal buffer              e_old_wsp*/
    Word16 e_old_wsp[],
    Word16 e_old_wsp[],                                              /* i  : Q factor of old_wsp buffer                         */
    const Word16 loc_harm[],                                         /* i  : harmonicity flag							      Q0*/
    const Word16 cor_map_sum_fx[],                                   /* i  : speech/music clasif. parameter			          Q8*/
    const Word16 vad_flag_dtx[],                                     /* i  : HE-SAD flag with additional DTX HO		          Q0*/
@@ -89,17 +90,23 @@ ivas_error ivas_core_enc_fx(
    Encoder_State **sts, *st;
    STEREO_ICBWE_ENC_HANDLE hStereoICBWE;
    STEREO_TD_ENC_DATA_HANDLE hStereoTD;
    move16();
    move16();
    Word16 voice_factors_fx[CPE_CHANNELS][NB_SUBFR16k]; /* Q15 */
    Word32 shb_speech_fx32[L_FRAME16k];
    Word32 *new_swb_speech_fx;
    Word16 *inp_fx[CPE_CHANNELS];
#ifdef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC
    Word16 *shb_speech_fx;
#else
    Word16 shb_speech_fx[L_FRAME16k]; // Q_shb_spch
#endif
    Word16 Q_shb_spch;
    Word32 new_swb_speech_buffer_fx[L_FRAME48k + STEREO_DFT_OVL_MAX];
    Word16 new_inp_resamp16k_fx[CPE_CHANNELS][L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
#ifdef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC
    Word16 *hb_speech_fx;
#else
    Word16 hb_speech_fx[L_FRAME16k / 4];
#endif
    Word32 bwe_exc_extended_fx[CPE_CHANNELS][L_FRAME32k + NL_BUFF_OFFSET]; /* 2 * Q_new */
    Word16 old_syn_12k8_16k_fx[CPE_CHANNELS][L_FRAME16k];                  /* ACELP core synthesis at 12.8kHz or 16kHz to be used by the SWB BWE */
    Word16 *new_swb_speech_fx_16;
@@ -120,14 +127,18 @@ ivas_error ivas_core_enc_fx(
    Word16 i, shift, Q_min;

    set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX );
#ifndef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC
    set16_fx( new_swb_speech_buffer_fx_16, 0, L_FRAME48k + STEREO_DFT_OVL_MAX );
#endif

    FOR( i = 0; i < CPE_CHANNELS; i++ )
    {
        set_zero_fx( bwe_exc_extended_fx[i], L_FRAME32k + NL_BUFF_OFFSET );
        set16_fx( old_syn_12k8_16k_fx[i], 0, L_FRAME16k );
    }
#ifndef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC
    set16_fx( shb_speech_fx, 0, L_FRAME16k );
#endif

    push_wmops( "ivas_core_enc" );

@@ -205,7 +216,6 @@ ivas_error ivas_core_enc_fx(
         * Initializiation per core-coder channel
         *-----------------------------------------------------------------*/


        st->extl = -1;
        move16();
        unbits[n] = 0;
@@ -217,6 +227,7 @@ ivas_error ivas_core_enc_fx(
        /*---------------------------------------------------------------------*
         * Pre-processing, incl. Decision matrix
         *---------------------------------------------------------------------*/

        IF( st->cldfbAnaEnc )
        {
            Word16 tmp_shift = L_norm_arr( enerBuffer_fx[n], st->cldfbAnaEnc->no_channels );
@@ -231,7 +242,6 @@ ivas_error ivas_core_enc_fx(

        Scale_sig( fft_buff_fx[n], ( 2 * L_FFT ), -1 ); // To create 1 headroom for addition of magnitude square spectrum
                                                        // fft_buff_fx_exp = add(fft_buff_fx_exp,1);

        FOR( i = 0; i < st->nb_subfr; i++ )
        {
            Scale_sig( &A_fx[n][i * ( M + 1 )], M + 1, sub( norm_s( A_fx[n][i * ( M + 1 )] ), 2 ) );   // scaling to Q12
@@ -317,6 +327,7 @@ ivas_error ivas_core_enc_fx(
        /*---------------------------------------------------------------------*
         * Preprocessing (preparing) for ACELP/HQ core switching
         *---------------------------------------------------------------------*/

        core_switching_pre_enc_ivas_fx( st, old_inp_12k8_fx[n], sub( Q_new[n], 1 ), old_inp_16k_fx[n], sub( Q_new[n], 1 ), sts[0]->active_cnt, last_element_mode );

        /*---------------------------------------------------------------------*
@@ -356,6 +367,7 @@ ivas_error ivas_core_enc_fx(
            move16();
            Q_spec_old = hTcxEnc->spectrum_long_e;
            move16();

            /* TCX core encoder */
            stereo_tcx_core_enc( st, old_inp_12k8_fx[n] + L_INP_MEM, old_inp_16k_fx[n] + L_INP_MEM, Aw_fx[n], lsp_new_fx[n], lsp_mid_fx[n], pitch_buf_fx[n], last_element_mode, vad_hover_flag[0], 0 );

@@ -664,6 +676,7 @@ ivas_error ivas_core_enc_fx(
        /*---------------------------------------------------------------------*
         * Postprocessing for ACELP/HQ core switching
         *---------------------------------------------------------------------*/

        core_switching_post_enc_ivas_fx( st, old_inp_12k8_fx[n], old_inp_16k_fx[n], A_fx[n], Q_new[n] );

        /*---------------------------------------------------------------------*
@@ -671,6 +684,10 @@ ivas_error ivas_core_enc_fx(
         * WB BWE encoding
         *---------------------------------------------------------------------*/

#ifdef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC
        hb_speech_fx = new_swb_speech_buffer_fx_16; /* reuse existing buffer: hb_speech[L_FRAME16k/4]; */
#endif

        test();
        test();
        IF( GE_32( input_Fs, 16000 ) && LT_16( st->bwidth, SWB ) && st->hBWE_TD != NULL )
@@ -692,7 +709,6 @@ ivas_error ivas_core_enc_fx(
            wb_bwe_enc_ivas_fx( st, new_inp_resamp16k_fx[n] );
        }


        /*---------------------------------------------------------------------*
         * SWB(FB) TBE encoding
         * SWB(FB) BWE encoding
@@ -700,6 +716,10 @@ ivas_error ivas_core_enc_fx(

        new_swb_speech_fx = new_swb_speech_buffer_fx + STEREO_DFT_OVL_MAX;
        new_swb_speech_fx_16 = new_swb_speech_buffer_fx_16 + STEREO_DFT_OVL_MAX;
#ifdef FIX_1298_MEMORY_OPT_IVAS_CORE_ENC
        set16_fx( new_swb_speech_buffer_fx_16, 0, L_FRAME48k + STEREO_DFT_OVL_MAX );
        shb_speech_fx = new_inp_resamp16k_fx[n]; /* reuse existing buffer: shb_speech[L_FRAME16k] */
#endif

        test();
        test();
@@ -736,7 +756,6 @@ ivas_error ivas_core_enc_fx(
            Scale_sig( st->hBWE_FD->L_old_wtda_swb_fx, L_FRAME48k, shift ); // st->Q_old_wtda
        }


        /* SWB TBE encoder */
        test();
        test();
@@ -769,6 +788,7 @@ ivas_error ivas_core_enc_fx(
        /*---------------------------------------------------------------------*
         * SWB DTX/CNG encoding
         *---------------------------------------------------------------------*/

        test();
        test();
        test();
@@ -847,6 +867,7 @@ ivas_error ivas_core_enc_fx(
    /*------------------------------------------------------------------*
     * Write potentially unused bits in combined format coding
     *-----------------------------------------------------------------*/

    test();
    test();
    IF( hCPE != NULL && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->brate_surplus > 0 )