Commit 713d7615 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'mode_switch_decoder_LPD' into 'main'

Subfunctions for mode_switch_decoder_LPD converted to fixed point.

See merge request !33
parents e9df5ed3 2683d182
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@
    <ClCompile Include="..\lib_com\findpulse.c" />
    <ClCompile Include="..\lib_com\fine_gain_bits.c" />
    <ClCompile Include="..\lib_com\fine_gain_bits_fx.c" />
    <ClCompile Include="..\lib_com\float_to_fix_ops.c" />
    <ClCompile Include="..\lib_com\frame_ener.c" />
    <ClCompile Include="..\lib_com\gain_inov_fx.c" />
    <ClCompile Include="..\lib_com\get_gain.c" />
+1 −0
Original line number Diff line number Diff line
@@ -805,6 +805,7 @@
    <ClCompile Include="..\lib_com\ivas_sns_com_fx.c">
      <Filter>common_ivas_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_com\float_to_fix_ops.c" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_com\basop32.h" />
+28 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"

#include "prot_fx2.h"
#if __STDC_VERSION__ >= 199901L
#if defined __ICL
#define restrict __restrict
@@ -723,6 +723,12 @@ ivas_error openCldfb_ivas(
    {
        buf_len = hs->p_filter_length;
    }
#ifdef IVAS_FLOAT_FIXED
    if ( ( hs->cldfb_state_fx = (Word16 *) malloc( buf_len * sizeof( Word16 ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }
#endif // IVAS_FLOAT_FIXED

    if ( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL )
    {
@@ -1230,3 +1236,24 @@ void cldfb_reset_memory_ivas(

    return;
}
void cldfb_reset_memory_fx(
	HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */,
	Word16* memory_length
)
{
	UWord16 offset = sub(hs->p_filter_length, hs->no_channels);

	IF (hs->type == CLDFB_ANALYSIS)
	{
		*memory_length = offset;
	}
	ELSE
	{
		*memory_length = hs->p_filter_length;
	}

		/* save the memory */
	set16_fx(hs->cldfb_state_fx, 0, *memory_length);

	return;
}
 No newline at end of file
+606 −86

File changed.

Preview size limit exceeded, changes collapsed.

+76 −0
Original line number Diff line number Diff line
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "options.h"
#include "prot.h"
Word32 floatToFixed(const float f, Word16 Q)
{
	if (Q < 0)
		return (Word32)((float)(f) / (float)(1 << (-Q)) + (f >= 0 ? 0.5 : -0.5));
	else
		return (Word32)(f * (float)(1 << Q) + (f >= 0 ? 0.5 : -0.5));
}

float fixedToFloat(const Word32 i, Word16 Q)
{
	if (Q < 0)
		return (i * (float)(1 << (-Q)));
	else
		return (float)(i) / (float)(1 << Q);
}
void floatToFixed_arrL(const 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)
{
	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)
{
	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)
{
	for (int j = 0; j < l; j++)
	{
		f[j] = fixedToFloat(i[j], Q);
	}
}
Word16 Q_factor(Word16 x)
{
	return norm_s(x);
}
Word16 Q_factor_L(Word32 x)
{
	return norm_l(x);
}
Word16 Q_factor_arr(float *x, Word16 l)
{
	Word16 Q = 15;
	for (int i = 0; i < l; i++)
	{
		if (x[i] >= 1 || x[i] <= -1)
			Q = s_min(Q, norm_s((Word16)x[i]));
	}
	return Q;
}
Word16 Q_factor_arrL(float *x, Word16 l)
{
	Word16 Q = 31;
	for (int i = 0; i < l; i++)
	{
		if (x[i] >= 1 || x[i] <= -1)
			Q = s_min(Q, norm_l((Word32)x[i]));
	}
	return Q;
}
Loading