Commit be401931 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

Merge branch 'main' of ssh://forge.3gpp.org:29419/sa4/audio/ivas-basop into...

Merge branch 'main' of ssh://forge.3gpp.org:29419/sa4/audio/ivas-basop into 2247-accelerate-basop_util_addmant32exp
parents d3c8861d 1c5efba7
Loading
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2960,3 +2960,14 @@ cmplx CL_mult_32x16( cmplx input, cmplx_s coeff )
#endif
    return result;
}

Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 )
{
    Word32 var1_l;
    Word64 var_out;
    var1_l = W_extract_l( W_var1 );
    var_out = W_mult0_32_32( L_and( var1_l, 1 ), L_var2 );
    var_out = W_mac_32_32( var_out, L_lshr( var1_l, 1 ), L_var2 );
    var_out = W_mac_32_32( W_shr( var_out, 31 ), W_extract_h( W_var1 ), L_var2 );
    return var_out;
}
+20 −0
Original line number Diff line number Diff line
@@ -956,4 +956,24 @@ cmplx CL_scale_t( cmplx x, Word16 y );
cmplx CL_dscale_t( cmplx x, Word16 y1, Word16 y2 );
cmplx CL_mult_32x16( cmplx input, cmplx_s coeff );


/*!
   \brief   64-bit/32-bit multiplication with shift

     This multiplication is similar to Mpy_32_32 except for the fact that the first argument
     and the return type are Word64. The function performs the following operation:

       z = ((int128_t)x   (int128_t)y) >> 31

     where:
      - x is a 64-bit signed integer
      - y is a 32-bit signed integer
      - z is a 64-bit signed integer

   \param W_var1 64-bit signed integer argument
   \param L_var2 32-bit signed integer argument
   \return 64-bit signed integer representing the result of the multiplication with shift
*/
Word64 Mpy_64_32( Word64 W_var1, Word32 L_var2 );

#endif /* __BASOP_UTIL_H__ */
+32 −0
Original line number Diff line number Diff line
@@ -98,6 +98,38 @@
#define Q29                                29
#define Q30                                30
#define Q31                                31
#define Q32                                32
#define Q33                                33
#define Q34                                34
#define Q35                                35
#define Q36                                36
#define Q37                                37
#define Q38                                38
#define Q39                                39
#define Q40                                40
#define Q41                                41
#define Q42                                42
#define Q43                                43
#define Q44                                44
#define Q45                                45
#define Q46                                46
#define Q47                                47
#define Q48                                48
#define Q49                                49
#define Q50                                50
#define Q51                                51
#define Q52                                52
#define Q53                                53
#define Q54                                54
#define Q55                                55
#define Q56                                56
#define Q57                                57
#define Q58                                58
#define Q59                                59
#define Q60                                60
#define Q61                                61
#define Q62                                62
#define Q63                                63

/*----------------------------------------------------------------------------------*
 * one in Q
+198 −36
Original line number Diff line number Diff line
@@ -38,13 +38,6 @@
#include "ivas_rom_com.h"
#include "ivas_prot_fx.h"

/*------------------------------------------------------------------------------------------*
 * Local functions declaration
 *------------------------------------------------------------------------------------------*/

static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e );


/*-----------------------------------------------------------------------------------------*
 * Function ivas_filters_init()
 *
@@ -71,27 +64,43 @@ void ivas_filters_init_fx(
        FOR( i = 0; i < IVAS_BIQUAD_FILT_LEN; i++ )
        {
            filter_state->num_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i];
            filter_state->num_e[IVAS_FILTER_STAGE_0][i] = 1;
            filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN];
            filter_state->den_e[IVAS_FILTER_STAGE_0][i] = 1;
            move32();
            move32();
#ifdef OPT_2239_IVAS_FILTER_PROCESS
            filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31;
            filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = Q30 - Q31;
            move16();
            move16();
#else
            filter_state->num_e[IVAS_FILTER_STAGE_0][i] = 1;
            filter_state->den_e[IVAS_FILTER_STAGE_0][i] = 1;
            move16();
            move16();
#endif
        }

        filter_state->state_fx[0][0] = 0;
        filter_state->state_e[0][0] = 0;
        filter_state->state_fx[0][1] = 0;
        filter_state->state_e[0][1] = 0;
        filter_state->state_fx[0][2] = 0;
        filter_state->state_e[0][2] = 0;
#ifdef OPT_2239_IVAS_FILTER_PROCESS
        filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0;
        move64();
        move64();
        move64();
#else
        filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0;
        move32();
        move32();
        move32();
        filter_state->state_e[0][0] = 0;
        filter_state->state_e[0][1] = 0;
        filter_state->state_e[0][2] = 0;
        move16();
        move16();
        move16();
#endif
    }
    ELSE
    {
@@ -100,54 +109,208 @@ void ivas_filters_init_fx(

        FOR( i = 0; i < IVAS_BIQUAD_FILT_LEN; i++ )
        {

            filter_state->num_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i];
            filter_state->num_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i];
            filter_state->den_fx[IVAS_FILTER_STAGE_0][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN];
            filter_state->den_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN];
            filter_state->num_fx[IVAS_FILTER_STAGE_1][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN * 2];
            filter_state->num_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 2];
            filter_state->den_fx[IVAS_FILTER_STAGE_1][i] = filt_coeff_fx[i + IVAS_BIQUAD_FILT_LEN * 3];
            filter_state->den_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 3];
            move32();
            move32();
            move32();
            move32();
#ifdef OPT_2239_IVAS_FILTER_PROCESS
            filter_state->num_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 0 * IVAS_BIQUAD_FILT_LEN] ), Q31 );
            filter_state->den_shr[IVAS_FILTER_STAGE_0][i] = sub( sub( 31, filt_coeff_e[i + 1 * IVAS_BIQUAD_FILT_LEN] ), Q31 );
            filter_state->num_shr[IVAS_FILTER_STAGE_1][i] = sub( sub( 31, filt_coeff_e[i + 2 * IVAS_BIQUAD_FILT_LEN] ), Q31 );
            filter_state->den_shr[IVAS_FILTER_STAGE_1][i] = sub( sub( 31, filt_coeff_e[i + 3 * IVAS_BIQUAD_FILT_LEN] ), Q31 );
            move16();
            move16();
            move16();
            move16();
#else
            filter_state->num_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i];
            filter_state->den_e[IVAS_FILTER_STAGE_0][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN];
            filter_state->num_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 2];
            filter_state->den_e[IVAS_FILTER_STAGE_1][i] = filt_coeff_e[i + IVAS_BIQUAD_FILT_LEN * 3];
            move16();
            move16();
            move16();
            move16();
#endif
        }

        filter_state->state_fx[0][0] = 0;
        filter_state->state_e[0][0] = 0;
        filter_state->state_fx[0][1] = 0;
        filter_state->state_e[0][1] = 0;
        filter_state->state_fx[0][2] = 0;
        filter_state->state_e[0][2] = 0;
        filter_state->state_fx[1][0] = 0;
        filter_state->state_e[1][0] = 0;
        filter_state->state_fx[1][1] = 0;
        filter_state->state_e[1][1] = 0;
        filter_state->state_fx[1][2] = 0;
        filter_state->state_e[1][2] = 0;
#ifdef OPT_2239_IVAS_FILTER_PROCESS
        filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_1][0] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_1][1] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_1][2] = 0;
        move64();
        move64();
        move64();
        move64();
        move64();
        move64();
#else
        filter_state->state_fx[IVAS_FILTER_STAGE_0][0] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][1] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_0][2] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_1][0] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_1][1] = 0;
        filter_state->state_fx[IVAS_FILTER_STAGE_1][2] = 0;
        move32();
        move32();
        move32();
        move32();
        move32();
        move32();
        filter_state->state_e[0][0] = 0;
        filter_state->state_e[0][1] = 0;
        filter_state->state_e[0][2] = 0;
        filter_state->state_e[1][0] = 0;
        filter_state->state_e[1][1] = 0;
        filter_state->state_e[1][2] = 0;
        move16();
        move16();
        move16();
        move16();
        move16();
        move16();
#endif
    }

    return;
}

#ifdef OPT_2239_IVAS_FILTER_PROCESS
static Word64 ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, const Word16 stage, const Word64 in );

/*-----------------------------------------------------------------------------------------*
 * Function ivas_iir_2_filter_fx()
 *
 * Process call for filtering a sample
 *-----------------------------------------------------------------------------------------*/

static Word64 ivas_iir_2_filter_fx(
    ivas_filters_process_state_t *filter_state,
    const Word16 stage,
    const Word64 in )
{
    Word64 tmp_prod, tmp, out;
    Word16 j;

    tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][0] ), filter_state->num_shr[stage][0] );
    out = W_add( filter_state->state_fx[stage][0], tmp_prod );

    FOR( j = 1; j < filter_state->filt_len; j++ )
    {
        tmp_prod = W_shr( Mpy_64_32( in, filter_state->num_fx[stage][j] ), filter_state->num_shr[stage][j] );
        tmp = W_add( filter_state->state_fx[stage][j], tmp_prod );
        tmp_prod = W_shr( Mpy_64_32( out, filter_state->den_fx[stage][j] ), filter_state->den_shr[stage][j] );
        filter_state->state_fx[stage][j - 1] = W_sub( tmp, tmp_prod );
        move64();
    }

    return out;
}

/*-----------------------------------------------------------------------------------------*
 * Function ivas_filter_process_fx32()
 *
 * Process call for filtering a signal
 *-----------------------------------------------------------------------------------------*/

void ivas_filter_process_fx32(
    ivas_filters_process_state_t *filter_state, /* i/o: filter state handle             */
    Word32 *pIn_Out_fx,                         /* i/o: signal subject to filtering     */
    const Word16 length )                       /* i  : number of samples to filter     */
{
    Word64 in, out;
    Word16 i;

    SWITCH( filter_state->order )
    {
        case IVAS_FILTER_ORDER_1:
            FOR( i = 0; i < length; i++ )
            {
                in = W_deposit32_h( pIn_Out_fx[i] );

                out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_0, in );

                pIn_Out_fx[i] = W_extract_h( out );
                move32();
            }
            BREAK;
        case IVAS_FILTER_ORDER_4:
            FOR( i = 0; i < length; i++ )
            {
                in = W_deposit32_h( pIn_Out_fx[i] );

                out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_0, in );
                out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_1, out );

                pIn_Out_fx[i] = W_extract_h( out );
                move32();
            }
            BREAK;
        default:
            BREAK;
    }

    return;
}

/*-----------------------------------------------------------------------------------------*
 * Function ivas_filter_process_fx64()
 *
 * Process call for filtering a signal
 *-----------------------------------------------------------------------------------------*/

void ivas_filter_process_fx64(
    ivas_filters_process_state_t *filter_state, /* i/o: filter state handle             */
    Word64 *pIn_Out_fx,                         /* i/o: signal subject to filtering     */
    const Word16 length )                       /* i  : number of samples to filter     */

{
    Word64 in, out;
    Word16 i;

    SWITCH( filter_state->order )
    {
        case IVAS_FILTER_ORDER_1:
            FOR( i = 0; i < length; i++ )
            {
                in = pIn_Out_fx[i];
                move64();

                out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_0, in );

                pIn_Out_fx[i] = out;
                move64();
            }
            BREAK;
        case IVAS_FILTER_ORDER_4:
            FOR( i = 0; i < length; i++ )
            {
                in = pIn_Out_fx[i];
                move64();

                out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_0, in );
                out = ivas_iir_2_filter_fx( filter_state, IVAS_FILTER_STAGE_1, out );

                pIn_Out_fx[i] = out;
                move64();
            }
            BREAK;
        default:
            BREAK;
    }

    return;
}

#else
static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e );

/*-----------------------------------------------------------------------------------------*
 * Function ivas_filter_process()
@@ -158,7 +321,7 @@ void ivas_filters_init_fx(
void ivas_filter_process_fx(
    ivas_filters_process_state_t *filter_state, /* i/o: filter state handle             */
    Word32 *pIn_Out_fx,                         /* i/o: signal subject to filtering Q(q_factor)   */
    const Word16 length,                        /* i  : filter order                    */
    const Word16 length,                        /* i  : number of samples to filter     */
    Word16 q_factor )
{
    Word16 pIn_Out_e[L_FRAME_MAX];
@@ -196,11 +359,10 @@ void ivas_filter_process_fx(
    return;
}


void ivas_filter_process_exp_fx(
    ivas_filters_process_state_t *filter_state, /* i/o: filter state handle             */
    Word32 *pIn_Out_fx,                         /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i])   */
    const Word16 length,                        /* i  : filter order                    */
    const Word16 length,                        /* i  : number of samples to filter     */
    Word16 *pIn_Out_e )
{
    SWITCH( filter_state->order )
@@ -223,7 +385,6 @@ void ivas_filter_process_exp_fx(
    return;
}


/*-----------------------------------------------------------------------------------------*
 * Function ivas_iir_2_filter()
 *
@@ -285,3 +446,4 @@ static void ivas_iir_2_filter_fx(

    return;
}
#endif
+16 −10
Original line number Diff line number Diff line
@@ -3802,20 +3802,33 @@ void ivas_lfe_enc_fx(
    BSTR_ENC_HANDLE hBstr                                       /* i/o: bitstream handle                                */
);

#ifdef OPT_2239_IVAS_FILTER_PROCESS
void ivas_filter_process_fx32(
    ivas_filters_process_state_t *filter_state,                 /* i/o: filter state handle                             */
    Word32 *pIn_Out_fx,                                         /* i  : signal subject to filtering                     */
    const Word16 length                                         /* i  : number of samples to filter                     */
);

void ivas_filter_process_fx64(
    ivas_filters_process_state_t *filter_state,                 /* i/o: filter state handle                             */
    Word64 *pIn_Out_fx,                                         /* i  : signal subject to filtering                     */
    const Word16 length                                         /* i  : number of samples to filter                     */
);
#else
void ivas_filter_process_fx(
    ivas_filters_process_state_t *filter_state,                 /* i/o: filter state handle                             */
    Word32 *pIn_Out_fx,                                         /* i  : signal subject to filtering                     */
    const Word16 length,                                        /* i  : filter order                                    */
    const Word16 length,                                        /* i  : number of samples to filter                     */
    Word16 q_factor 
);

void ivas_filter_process_exp_fx(
    ivas_filters_process_state_t *filter_state,                 /* i/o: filter state handle                             */
    Word32 *pIn_Out_fx,                                         /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i])   */
    const Word16 length,                                        /* i  : filter order                                    */
    const Word16 length,                                        /* i  : number of samples to filter                     */
    Word16 *pIn_Out_e 
);

#endif
ivas_error ivas_osba_enc_open_fx(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder handle                             */
);
@@ -6804,13 +6817,6 @@ void ivas_filters_init_fx(
    const Word16 order 
);

void ivas_filter_process_fx(
    ivas_filters_process_state_t *filter_state,                 /* i/o: filter state handle                     */
    Word32 *pIn_Out_fx,                                         /* i/o: signal subject to filtering Q(q_factor) */
    const Word16 length,                                        /* i  : filter order                            */
    Word16 q_factor 
);

/*----------------------------------------------------------------------------------*
 * OSBA prototypes
 *----------------------------------------------------------------------------------*/
Loading