Commit ebfa1fa8 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'ivas_cldfb_dec_reconfig_fxd' into 'main'

Conversions related to ivas_cldfb_dec_reconfig

See merge request !137
parents 207a173c a73d7b2c
Loading
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1702,12 +1702,13 @@ ivas_error openCldfb_ivas_fx(
        move16();
    }

    IF ( ( hs->cldfb_state_fx = (Word16 *) malloc( buf_len * sizeof( Word16 ) ) ) == NULL )
    IF ( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }

    set_s(hs->cldfb_state_fx, 0, buf_len);
    hs->cldfb_state_length = buf_len; // Temporarily added to store the length of buffer
    set32_fx(hs->cldfb_state_fx, 0, buf_len);

    /* TODO: remove the floating point dependency */

+6 −6
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
#include <stdint.h>
#include "options.h"
#include "prot.h"
Word32 floatToFixed(const float f, Word16 Q)
Word32 floatToFixed(float f, Word16 Q)
{
	if (f == 1.0f && Q == Q15)
		return MAX16B;
@@ -15,35 +15,35 @@ Word32 floatToFixed(const float f, Word16 Q)
		return (Word32)(f * (float)((unsigned int)1 << Q) + (f >= 0 ? 0.5 : -0.5));
}

float fixedToFloat(const Word32 i, Word16 Q)
float fixedToFloat(Word32 i, Word16 Q)
{
	if (Q < 0)
		return (i * (float)(((unsigned)1) << (-Q)));
	else
		return (float)(i) / (float)((unsigned int)1 << Q);
}
void floatToFixed_arrL(const float *f, Word32 *i, Word16 Q, Word16 l)
void floatToFixed_arrL(float *f, Word32 *i, Word16 Q, Word16 l)
{
	for (int j = 0; j < l; j++)
	{
		i[j] = floatToFixed(f[j], Q);
	}
}
void floatToFixed_arr(const float *f, Word16 *i, Word16 Q, Word16 l)
void floatToFixed_arr(float *f, Word16 *i, Word16 Q, Word16 l)
{
	for (int j = 0; j < l; j++)
	{
		i[j] = (Word16)floatToFixed(f[j], Q);
	}
}
void fixedToFloat_arrL(const Word32 *i, float *f, Word16 Q, Word16 l)
void fixedToFloat_arrL(Word32 *i, float *f, Word16 Q, Word16 l)
{
	for (int j = 0; j < l; j++)
	{
		f[j] = fixedToFloat(i[j], Q);
	}
}
void fixedToFloat_arr(const Word16 *i, float *f, Word16 Q, Word16 l)
void fixedToFloat_arr(Word16 *i, float *f, Word16 Q, Word16 l)
{
	for (int j = 0; j < l; j++)
	{
+15 −0
Original line number Diff line number Diff line
@@ -3620,6 +3620,15 @@ void ivas_init_dec_get_num_cldfb_instances(
    int16_t *numCldfbAnalyses,                                  /* o  : number of CLDFB analysis instances      */
    int16_t *numCldfbSyntheses                                  /* o  : number of CLDFB synthesis instances     */
);
#ifdef IVAS_FLOAT_FIXED
ivas_error ivas_cldfb_dec_reconfig_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                */
    const Word16 nchan_transport_old,                          /* i  : number of TCs in previous frame                       */
    Word16 numCldfbAnalyses_old,                               /* i  : number of CLDFB analysis instances in previous frame  */
    const Word16 numCldfbSyntheses_old,                         /* i  : number of CLDFB synthesis instances in previous frame */
    const Word16 Q_cldfbSynDec
);
#endif // IVAS_FLOAT_FIXED

ivas_error ivas_cldfb_dec_reconfig(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                */
@@ -4502,6 +4511,12 @@ void ivas_itda(
    const int16_t length 
);

void ivas_spar_get_cldfb_gains_fx(
    SPAR_DEC_HANDLE hSpar,
    HANDLE_CLDFB_FILTER_BANK cldfbAnaDec0,
    HANDLE_CLDFB_FILTER_BANK cldfbSynDec0,
    const DECODER_CONFIG_HANDLE hDecoderConfig
);
void ivas_spar_get_cldfb_gains(
    SPAR_DEC_HANDLE hSpar,
    HANDLE_CLDFB_FILTER_BANK cldfbAnaDec0,
+4 −0
Original line number Diff line number Diff line
@@ -800,6 +800,10 @@ typedef struct ivas_fb_mixer_state_structure
    int16_t prior_input_length;
    int16_t windowed_fr_offset;
    float cldfb_cross_fade[CLDFB_NO_COL_MAX];
#ifdef IVAS_FLOAT_FIXED
    const Word16 *pFilterbank_cross_fade_fx;
    Word16 cldfb_cross_fade_fx[CLDFB_NO_COL_MAX];
#endif // IVAS_FLOAT_FIXED
    int16_t cldfb_cross_fade_start;
    int16_t cldfb_cross_fade_end;

+6 −6
Original line number Diff line number Diff line
@@ -71,17 +71,17 @@ Word16 float_to_fix16( float number, Word16 Q );
// Word16 to Float
float fix16_to_float( Word16 number, Word16 Q );

void floatToFixed_arrL(const float * f, Word32* i, Word16 Q, Word16 l);
void floatToFixed_arr(const float * f, Word16* i, Word16 Q, Word16 l);
void fixedToFloat_arrL(const Word32 *i, float * f, Word16 Q, Word16 l);
void fixedToFloat_arr(const Word16 *i, float * f, Word16 Q, Word16 l);
void floatToFixed_arrL( float * f, Word32* i, Word16 Q, Word16 l);
void floatToFixed_arr( float * f, Word16* i, Word16 Q, Word16 l);
void fixedToFloat_arrL( Word32 *i, float * f, Word16 Q, Word16 l);
void fixedToFloat_arr( Word16 *i, float * f, Word16 Q, Word16 l);
Word16 Q_factor(float x);
Word16 Q_factor_L(float x);
Word16 Q_factor_arr(float* x, Word16 l);
Word16 Q_factor_arrL(float* x, Word16 l);
//Handles the cases where Q is negative
Word32 floatToFixed(const float f, Word16 Q);
float fixedToFloat(const Word32 i, Word16 Q);
Word32 floatToFixed( float f, Word16 Q);
float fixedToFloat( Word32 i, Word16 Q);

// Float to 32-bit Mantissa and Exponent using frexp
void f2me(float n, Word32 *mantissa, Word16 *expo);
Loading