Commit 9d736830 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'core_sw_pre_dec_fxd' into 'main'

Add conversion changes for core_switching_pre_dec, ism-funcs

See merge request !212
parents 4f379a1e 6d3e7f82
Loading
Loading
Loading
Loading
Loading
+79 −0
Original line number Diff line number Diff line
@@ -2295,6 +2295,45 @@ static void cldfb_init_proto_and_twiddles(
 *
 * Save the memory of filter; to be restored with cldfb_restore_memory_ivas()
 *--------------------------------------------------------------------*/
#ifdef IVAS_FLOAT_FIXED
ivas_error cldfb_save_memory_ivas_fx(
    HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
)
{
    UWord16 offset = sub(hs->p_filter_length , hs->no_channels);

    IF ( hs->memory_flt != NULL || NE_16(hs->memory_length , 0) )
    {
        /* memory already stored; Free memory first */
        return IVAS_ERR_OK;
    }

    IF ( EQ_16(hs->type , CLDFB_ANALYSIS) )
    {
        hs->memory_length = offset;
        move16();
    }
    ELSE
    {
        hs->memory_length = hs->p_filter_length;
        move16();
    }
#if 1/*Floating point memory allocation: To be removed later*/
    IF ( ( hs->memory_flt = (float *) malloc( hs->memory_length * sizeof( float ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" );
    }
#endif
    IF ( ( hs->memory32 = (Word32 *) malloc( hs->memory_length * sizeof(Word32) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CLDFB\n" );
    }
    /* save the memory */
    Copy32( hs->cldfb_state_fx, hs->memory32, hs->memory_length );

    return IVAS_ERR_OK;
}
#endif // IVAS_FLOAT_FIXED

ivas_error cldfb_save_memory_ivas(
    HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
@@ -2334,6 +2373,46 @@ ivas_error cldfb_save_memory_ivas(
 *
 * Restores the memory of filter; memory to be save by cldfb_save_memory_ivas()
 *--------------------------------------------------------------------*/
#ifdef IVAS_FLOAT_FIXED
void cldfb_restore_memory_ivas_fx(
    HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
)
{
    UWord16 offset = sub(hs->p_filter_length , hs->no_channels);
    UWord16 size;
    IF ( hs->memory_flt == NULL || EQ_16(hs->memory_length , 0) )
    {
        /* memory not allocated */
        return;
    }

    IF ( EQ_16(hs->type , CLDFB_ANALYSIS) )
    {
        size = offset;
        move16();
    }
    ELSE
    {
        size = hs->p_filter_length;
        move16();
    }

    /* read the memory */
    Copy32( hs->memory32, hs->cldfb_state_fx, hs->memory_length );

    /* adjust sample rate if it was changed in the meanwhile */
    IF ( NE_16(hs->memory_length , size) )
    {
        L_lerp_fx_q11( hs->cldfb_state_fx, hs->cldfb_state_fx, size, hs->memory_length);
    }
    hs->cldfb_state_length = size;
    hs->memory_length = 0;
    free( hs->memory32 );
    hs->memory32 = NULL;

    return;
}
#endif // IVAS_FLOAT_FIXED

void cldfb_restore_memory_ivas(
    HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */
+5 −0
Original line number Diff line number Diff line
@@ -2081,6 +2081,11 @@ typedef enum _DCTTYPE
#define ENV_STAB_EST1                       2.93f                   /* env_stab estimation coefficient 1 */
#define ENV_STAB_EST2                       (-2.20f)                /* env_stab estimation coefficient 2 */
#define ENV_STAB_EST3                       0.741f                  /* env_stab estimation coefficient 3 */
#ifdef IVAS_FLOAT_FIXED
#define ENV_STAB_EST1_FX                    12001                  /* env_stab estimation coefficient 1 *//*Q-12*/
#define ENV_STAB_EST2_FX                    (-9011)                /* env_stab estimation coefficient 2 *//*Q-12*/
#define ENV_STAB_EST3_FX                    3035                   /* env_stab estimation coefficient 3 *//*Q-12*/
#endif // IVAS_FLOAT_FIXED
#define STAB_FAC_EST1                       1.093f                  /* stab_fac HQ estimation coefficient 1 */
#define STAB_FAC_EST2                       (-5.84e-05f)            /* stab_fac HQ estimation coefficient 2, including Q12 scaling */
#define STAB_FAC_EST3                       0.125f                  /* stab_fac HQ estimation coefficient 3 */
+38 −5
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
#include <stdint.h>
#include "options.h"
#include "prot.h"
#include "prot_fx2.h"
Word32 floatToFixed(float f, Word16 Q)
{
	if (f == 1.0f && Q == Q15)
@@ -12,7 +13,15 @@ Word32 floatToFixed(float f, Word16 Q)
	if (Q < 0)
		return (Word32)((float)(f) / (float)(((unsigned)1) << (-Q)) + (f >= 0 ? 0.5 : -0.5));
	else
		return (Word32)(f * (float)((unsigned int)1 << Q) + (f >= 0 ? 0.5 : -0.5));
	{
		Word64 result_32;
		result_32=(Word64)(f * (float)((unsigned int)1 << Q) + (f >= 0 ? 0.5 : -0.5));
		if (result_32 > MAX_32)
			return MAX_32;
		if (result_32 < MIN_32)
			return MIN_32;
		return (Word32)result_32;
	}
}

float fixedToFloat(Word32 i, Word16 Q)
@@ -42,6 +51,30 @@ void floatToFixed_arrL(float *f, Word32 *i, Word16 Q, Word16 l)
#endif
	}
}
void floatToFixed_arr16( float *f, Word16 *i, Word16 Q, Word16 l )
{
    if ( Q <= 0 )
    {
        floatToFixed_arr( f, i, Q, l );
        return;
    }
    for ( int j = 0; j < l; j++ )
    {
        i[j] = float_to_fix16( f[j], Q );
    }
}
void floatToFixed_arr32( float *f, Word32 *i, Word16 Q, Word16 l )
{
    if ( Q <= 0 )
    {
        floatToFixed_arrL( f, i, Q, l );
        return;
    }
    for ( int j = 0; j < l; j++ )
    {
        i[j] = float_to_fix( f[j], Q );
    }
}
void floatToFixed_arr(float *f, Word16 *i, Word16 Q, Word16 l)
{
	for (int j = 0; j < l; j++)
@@ -80,14 +113,14 @@ Word16 Q_factor(float x)
{
    Word16 Q = 15;
    if ( x >= 1 || x <= -1 )
        Q = norm_s((Word16)x);
        Q = norm_s((Word16)abs(x));
    return Q;
}
Word16 Q_factor_L(float x)
{
    Word16 Q = 31;
    if ( x >= 1 || x <= -1 )
        Q = norm_l((Word32)x);
        Q = norm_l((Word32)abs(x));
    return Q;
}
Word16 Q_factor_arr(float *x, Word16 l)
@@ -96,7 +129,7 @@ Word16 Q_factor_arr(float *x, Word16 l)
	for (int i = 0; i < l; i++)
	{
		if (x[i] >= 1 || x[i] <= -1)
			Q = s_min(Q, norm_s((Word16)x[i]));
			Q = s_min(Q, norm_s((Word16)abs(x[i])));
	}
	return Q;
}
@@ -106,7 +139,7 @@ Word16 Q_factor_arrL(float *x, Word16 l)
	for (int i = 0; i < l; i++)
	{
		if (x[i] >= 1 || x[i] <= -1)
			Q = s_min(Q, norm_l((Word32)x[i]));
			Q = s_min(Q, norm_l((Word32)abs(x[i])));
	}
	return Q;
}
+1 −1
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ void fer_energy_fx(
        *enr = W_extract_h( W_tmp );   // Q = q_synth * 2 + shift - 32

        enr_tmp = BASOP_Util_Divide3216_Scale( *enr, shr( L_frame, 1 ) /*Q0*/, &exp );
        *enr = L_shl( L_deposit_l( enr_tmp ), 5 );
        *enr = L_shr( L_deposit_l( enr_tmp ), (shift-32-exp-1));
    }
    return;
}
+38 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
#include "ivas_rom_com.h"
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
#include "prot_fx1.h"


/*-----------------------------------------------------------------------*
@@ -934,6 +935,43 @@ void ivas_param_ism_config(
    return;
}

#ifdef IVAS_FLOAT_FIXED
void ivas_param_ism_config_fx(
    PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i/o: IVAS Param ISM Config Structure      */
    const Word16 nchan_obj            /* i  : number of ISM channels               */
)
{
    Word16 i;

    hParamIsm->nbands = MAX_PARAM_ISM_NBANDS;
    move16();

    FOR ( i = 0; i < hParamIsm->nbands; i++ )
    {
        hParamIsm->nblocks[i] = MAX_PARAM_ISM_NBLOCKS;
        move16();
    }

    /* for elevation zero compute the max azi quantization indices */
    FOR ( i = 0; i < nchan_obj; i++ )
    {
        hParamIsm->last_az_diff[i] = 0;
        move16();
        hParamIsm->last_az_sgn[i] = 1;
        move16();
        hParamIsm->last_el_diff[i] = 0;
        move16();
        hParamIsm->last_el_sgn[i] = 1;
        move16();
    }

    hParamIsm->last_dmx_gain_fx = (Word16) 16384;
    move16();
    set16_fx( hParamIsm->last_cardioid_left_fx, (Word16) 16384, MAX_NUM_OBJECTS );

    return;
}
#endif

/*---------------------------------------------------------------
 * ivas_ism_mode_select()
Loading