diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj
index ee67280d0dd1f64ad9424857fd969cdaebef2b63..702c6c1adf8b6c0a92e6a183f0c284961f2d7fd6 100644
--- a/Workspace_msvc/lib_com.vcxproj
+++ b/Workspace_msvc/lib_com.vcxproj
@@ -161,7 +161,6 @@
-
diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters
index e8bbb17e9b0e6ab35342975185aa9d5a4fdfdeb8..37a179045ca136dbbd540c08d247454837167c5b 100644
--- a/Workspace_msvc/lib_com.vcxproj.filters
+++ b/Workspace_msvc/lib_com.vcxproj.filters
@@ -256,9 +256,6 @@
common_all_c
-
- common_all_c
-
common_all_c
diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj
index 72dac3925a10692041d19680f8b65089e26f455d..bfbfa8d4cfcb5cde0cfbb9ee005bd22b7c228761 100644
--- a/Workspace_msvc/lib_util.vcxproj
+++ b/Workspace_msvc/lib_util.vcxproj
@@ -109,6 +109,7 @@
+
@@ -141,6 +142,7 @@
+
@@ -176,4 +178,4 @@
-
+
\ No newline at end of file
diff --git a/apps/decoder.c b/apps/decoder.c
index 458c164ac83cb6f9ea949206acf5468a341e8213..7b02e26b4d16f550b669b01e04535c1158f4b054 100644
--- a/apps/decoder.c
+++ b/apps/decoder.c
@@ -31,6 +31,7 @@
*******************************************************************************************************/
#include "lib_dec.h"
+#include "options.h"
#include
#include "cmdl_tools.h"
#include "audio_file_writer.h"
@@ -50,7 +51,6 @@
#include "obj_edit_file_reader.h"
#include "vector3_pair_file_reader.h"
#include "wmc_auto.h"
-#include "options.h"
#include "stl.h"
#ifdef IVAS_RTPDUMP
#include "ivas_rtp_file.h"
@@ -1787,12 +1787,11 @@ static void usage_dec( void )
fprintf( stdout, " ID and duration pairs, where duration is specified in frames\n" );
fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration.\n" );
fprintf( stdout, "-obj_edit File : Object editing instructions file or NULL for built-in example\n" );
-
fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" );
fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" );
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
fprintf( stdout, "-room_size (S|M|L) : Selects default reverb based on a room size (S - small | M - medium | L - large)\n" );
- fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration,\n" );
+ fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration\n" );
#endif
fprintf( stdout, "-q : Quiet mode, no frame counter\n" );
fprintf( stdout, " default is deactivated\n" );
diff --git a/lib_com/basop_proto_func.h b/lib_com/basop_proto_func.h
index 0e2fc5ad757ee775ed1de3a0ebe9cf2b2dfdbeb0..55c15f29107dbeb67291ed4b950b7569a6ca8b75 100644
--- a/lib_com/basop_proto_func.h
+++ b/lib_com/basop_proto_func.h
@@ -43,10 +43,6 @@
#include "basop_util.h"
-/* tcx_lpc_cdk.h */
-#define LSF_GAP_VAL( x ) ( Word16 )( (x) *2.0f * 1.28f )
-#define LSFM( x ) FL2WORD16_SCALE( x * 1.28, 15 - 1 ) /* 14Q1*1.28 */
-
/* cnst.h */
#define GAMMA1_INV 17809 /* weighting factor (numerator) default:0.92 (1Q14format) */
#define GAMMA16k_INV 17430 /* weighting factor (numerator) default:0.94 (1Q14format) */
diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c
index 363113f2147234d21b1f7b3542d50be23f86e324..390afbd005b0c3590004d65cbe454a1ee08fb35d 100644
--- a/lib_com/fd_cng_com_fx.c
+++ b/lib_com/fd_cng_com_fx.c
@@ -27,7 +27,7 @@
* Local function prototypes
*-------------------------------------------------------------------*/
static void getmidbands( const Word16 *part, const Word16 npart, Word16 *midband, Word16 *psize, Word16 *psize_norm, Word16 *psize_norm_exp, Word16 *psize_inv );
-
+static void mhvals( const Word16 d, Word16 *m );
/*-------------------------------------------------------------------
* createFdCngCom()
@@ -2823,7 +2823,8 @@ void SynthesisSTFT_ivas_fx(
/**************************************************************************************
* Compute some values used in the bias correction of the minimum statistics algorithm *
**************************************************************************************/
-void mhvals(
+
+static void mhvals(
const Word16 d,
Word16 *m /*, Word16 * h*/
)
diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c
deleted file mode 100644
index 8b69e05e8811edbc273a3cd78e735d1bc0f99375..0000000000000000000000000000000000000000
--- a/lib_com/float_to_fix_ops.c
+++ /dev/null
@@ -1,297 +0,0 @@
-#include
-#include
-#include
-#include
-#include "options.h"
-#include "prot_fx.h"
-#define WMC_TOOL_SKIP
-
-Word32 floatToFixed( float f, Word16 Q )
-{
- Word64 result_32;
- if ( f == 1.0f && Q == Q15 )
- return MAX16B;
- if ( f == 1.0f && Q == Q31 )
- return MAXVAL_WORD32;
- if ( Q < 0 )
- result_32 = (Word64) ( (float) ( f ) / (double) ( (unsigned Word64) 1 << ( -Q ) ) + ( f >= 0 ? 0.5 : -0.5 ) );
- else
- result_32 = (Word64) ( f * (double) ( (unsigned Word64) 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 )
-{
- if ( Q < 0 )
- return ( i * (float) ( ( 1LL ) << ( -Q ) ) );
- else
- return (float) ( i ) / (float) ( 1LL << Q );
-}
-void floatToFixed_arrL( float *f, Word32 *i, Word16 Q, Word16 l )
-{
- for ( int j = 0; j < l; j++ )
- {
- Word64 i64_val = floatToFixed( f[j], Q );
- IF( i64_val > MAX_32 )
- {
- i64_val = MAX_32;
- }
- ELSE IF( i64_val < MIN_32 )
- {
- i64_val = MIN_32;
- }
- i[j] = (Word32) i64_val;
- }
-}
-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 );
- }
-}
-
-float fixedToFloat_16( Word16 i, Word16 Q )
-{
- if ( Q < 0 )
- return ( i * (float) ( ( (unsigned) 1 ) << ( -Q ) ) );
- else
- return (float) ( i ) / (float) ( (unsigned int) 1 << Q );
-}
-float fixedToFloat_32( Word32 number, Word16 Q )
-{
- float val = 0.0f;
- assert( abs_s( Q ) <= 63 );
- if ( abs_s( Q ) > 31 )
- {
- if ( Q > 0 )
- {
- val = ( ( (float) number / ( 1 << ( Q - 31 ) ) ) / ( (unsigned int) MAX_32 + 1 ) );
- }
- else
- {
- val = ( (float) number * ( 1 << ( -Q - 31 ) ) * (unsigned int) MIN_32 );
- }
- }
- else
- {
- val = fixedToFloat( number, Q );
- }
- return val;
-}
-
-Word32 floatToFixed_32( float number, Word16 Q )
-{
- float val = 0.0f;
- assert( abs_s( Q ) <= 63 );
- if ( abs_s( Q ) > 31 )
- {
- if ( Q > 0 )
- {
- val = ( number * ( (unsigned int) MAX_32 + 1 ) ) * ( 1 << ( Q - 31 ) );
- }
- else
- {
- val = ( number / ( 1 << ( -Q - 31 ) ) ) / (unsigned int) MIN_32;
- }
- if ( val >= 0.0f )
- {
- assert( (Word32) val <= MAX_32 );
- }
- else
- {
- assert( (Word32) val >= MIN_32 );
- }
- }
- else
- {
- return floatToFixed( number, Q );
- }
-
- return (Word32) val;
-}
-
-void floatToFixed_arrL32( float *f, Word32 *i, Word16 Q, Word16 l )
-{
- for ( int j = 0; j < l; j++ )
- {
- i[j] = floatToFixed_32( f[j], Q );
- }
-}
-
-void fixedToFloat_arrL32( Word32 *i, float *f, Word16 Q, Word16 l )
-{
- for ( int j = 0; j < l; j++ )
- {
- f[j] = fixedToFloat_32( i[j], Q );
- }
-}
-
-void floatToFixed_arr( float *f, Word16 *i, Word16 Q, Word16 l )
-{
- for ( int j = 0; j < l; j++ )
- {
- Word32 i32_val = floatToFixed( f[j], Q );
- IF( i32_val > MAX_16 )
- {
- i32_val = MAX_16;
- }
- ELSE IF( i32_val < MIN_16 )
- {
- i32_val = MIN_16;
- }
- i[j] = (Word16) i32_val;
- }
-}
-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( Word16 *i, float *f, Word16 Q, Word16 l )
-{
- for ( int j = 0; j < l; j++ )
- {
- f[j] = fixedToFloat( i[j], Q );
- }
-}
-Word16 Q_factor( float x )
-{
- Word16 Q = 15;
- if ( x >= 1 || x <= -1 )
- Q = norm_s( (Word16) L_abs( (Word32) x ) );
- return Q;
-}
-Word16 Q_factor_L( float x )
-{
- Word16 Q = 31;
- if ( x >= 1 || x <= -1 )
- Q = norm_l( L_abs( (Word32) x ) );
- return Q;
-}
-Word16 Q_factor_L_32( Word32 x )
-{
- Word16 Q = 31;
- if ( x >= 1 || x <= -1 )
- Q = norm_l( L_abs( (Word32) x ) );
- return Q;
-}
-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) L_abs( (Word32) 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) L_abs( (Word32) x[i] ) ) );
- }
- return Q;
-}
-
-Word16 L_get_q( float f )
-{
- if ( fabsf( f ) > (float) INT_MAX )
- {
- return sub( sub( W_norm( (Word64) f ), 32 ), 0 );
- }
- else
- {
- return sub( norm_l( (Word32) f ), 0 );
- }
-}
-
-Word16 L_get_q_buf( float *ptr_flt, Word16 length )
-{
- Word16 k;
- float ftemp = 0.0;
-
- for ( k = 0; k < length; k++ )
- {
- if ( fabsf( ptr_flt[k] ) > ftemp )
- ftemp = fabsf( ptr_flt[k] );
- }
-
- if ( ftemp > (float) INT_MAX )
- {
- return sub( sub( W_norm( (Word64) ftemp ), 32 ), 0 );
- }
- else
- {
- return sub( norm_l( (Word32) ftemp ), 0 );
- }
-}
-
-Word16 L_get_q1( float f )
-{
- if ( fabsf( f ) >= 0.f && fabsf( f ) < 1.f )
- {
- return Q31;
- }
- else if ( fabsf( f ) > (float) INT_MAX )
- {
- return sub( sub( W_norm( (Word64) f ), 32 ), 0 );
- }
- else
- {
- return sub( norm_l( (Word32) f ), 0 );
- }
-}
-
-Word16 L_get_q_buf1( float *ptr_flt, Word16 length )
-{
- Word16 k;
- float ftemp = 0.0;
-
- for ( k = 0; k < length; k++ )
- {
- if ( fabsf( ptr_flt[k] ) > ftemp )
- ftemp = fabsf( ptr_flt[k] );
- }
-
- if ( ftemp >= 0.f && ftemp < 1.f )
- {
- return Q31;
- }
- else if ( ftemp > (float) INT_MAX )
- {
- return sub( sub( W_norm( (Word64) ftemp ), 32 ), 0 );
- }
- else
- {
- return sub( norm_l( (Word32) ftemp ), 0 );
- }
-}
-#undef WMC_TOOL_SKIP
diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h
index 0cb0174d691783bc653a12359861190a292acb61..db13b368bcdad53b0a58feec8190799320ba7f06 100644
--- a/lib_com/ivas_prot_fx.h
+++ b/lib_com/ivas_prot_fx.h
@@ -3720,8 +3720,8 @@ void ivas_init_binaural_hrtf_fx(
ivas_error ivas_allocate_binaural_hrtf_fx(
HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */
- const int16_t n_channels, /* i : number of input channels */
- const int16_t allocate_init_flag /* i : Memory allocation flag */
+ const Word16 n_channels, /* i : number of input channels */
+ const Word16 allocate_init_flag /* i : Memory allocation flag */
);
void ivas_binRenderer_fx(
@@ -6776,18 +6776,6 @@ void ivas_ism_renderer_close(
);
-/*----------------------------------------------------------------------------------*
- * Amplitude Panning VBAP prototypes
- *----------------------------------------------------------------------------------*/
-
-void panning_wrap_angles(
- const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */
- const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */
- float *azi_wrapped, /* o : wrapped azimuth component */
- float *ele_wrapped /* o : wrapped elevation component */
-);
-
-
/*----------------------------------------------------------------------------------*
* McMASA prototypes
*----------------------------------------------------------------------------------*/
diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c
index 515a10cdb1195b2259ad19591e195199e13ba508..973837ac0afa15a9f554639079b0c04044a3f653 100644
--- a/lib_com/ivas_tools_fx.c
+++ b/lib_com/ivas_tools_fx.c
@@ -117,8 +117,8 @@ void mvc2c(
/*! r: number of clipped samples */
UWord32 ivas_syn_output_fx(
- Word32 *synth[], /* i/o: float synthesis signal q_synth*/
- const Word16 q_synth,
+ Word32 *synth[], /* i/o: synthesis signal q_synth*/
+ const Word16 q_synth, /* i : Q factor */
const Word16 output_frame, /* i : output frame length (one channel) Q0*/
const Word16 n_channels, /* i : number of output channels Q0*/
Word16 *synth_out /* o : integer 16 bits synthesis signal Q0*/
@@ -131,7 +131,7 @@ UWord32 ivas_syn_output_fx(
move32();
/*-----------------------------------------------------------------*
- * float to integer conversion with saturation control
+ * Word32 to Word16 conversion with saturation control
*-----------------------------------------------------------------*/
FOR( n = 0; n < n_channels; n++ )
@@ -1992,26 +1992,6 @@ void lls_interp_n_fx(
}
-/* helper function for panning_wrap_angles */
-static float wrap_azi(
- const float azi_deg )
-{
- float azi = azi_deg;
-
- /* Wrap azimuth value */
- while ( azi > 180 )
- {
- azi -= 360.0f;
- }
-
- while ( azi <= -180 )
- {
- azi += 360;
- }
-
- return azi;
-}
-
/* helper function for panning_wrap_angles */
static Word32 wrap_azi_fx(
const Word32 azi_deg /* Q22 */ )
@@ -2034,76 +2014,6 @@ static Word32 wrap_azi_fx(
}
-/*-------------------------------------------------------------------*
- * panning_wrap_angles()
- *
- * Wrap angles for amplitude panning to the range:
- * azimuth = (-180, 180]
- * elevation = [-90, 90]
- * Considers direction changes from large elevation values
- *-------------------------------------------------------------------*/
-
-void panning_wrap_angles(
- const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */
- const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */
- float *azi_wrapped, /* o : wrapped azimuth component */
- float *ele_wrapped /* o : wrapped elevation component */
-)
-{
- float azi, ele;
-
- azi = azi_deg;
- ele = ele_deg;
-
- if ( fabsf( ele ) < 90 )
- {
- *ele_wrapped = ele;
- *azi_wrapped = wrap_azi( azi );
- return;
- }
- else
- {
- /* Special case when elevation is a multiple of 90; azimuth is irrelevant */
- if ( ( fmodf( ele, 90 ) == 0 ) && ( fmodf( ele, 180 ) != 0 ) )
- {
- *azi_wrapped = 0;
- while ( ele > 90 )
- {
- ele -= 360;
- }
- while ( ele < -90 )
- {
- ele += 360;
- }
- *ele_wrapped = ele;
- }
- else
- {
- /* Wrap elevation and adjust azimuth accordingly */
- while ( fabsf( ele ) > 90 )
- {
- /* Flip to other hemisphere */
- azi += 180;
-
- /* Compensate elevation accordingly */
- if ( ele > 90 )
- {
- ele = 180 - ele;
- }
- else if ( ele < -90 )
- {
- ele = -180 - ele;
- }
- }
- *azi_wrapped = wrap_azi( azi );
- *ele_wrapped = ele;
- }
-
- return;
- }
-}
-
-
/*-------------------------------------------------------------------*
* panning_wrap_angles_fx()
*
@@ -2184,7 +2094,7 @@ void panning_wrap_angles_fx(
/*-------------------------------------------------------------------------*
* v_sort_ind_fixed()
*
- * Sort a float array
+ * Sort a Word32 array
* (modified version of v_sort() to return an index array)
*-------------------------------------------------------------------------*/
diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h
index 8f4b53c5ec07d43f06022ef563ff1ca0be86fb0c..28601b9cac139d9a70e1fff7beff5216d48d7d9c 100644
--- a/lib_com/prot_fx.h
+++ b/lib_com/prot_fx.h
@@ -102,80 +102,16 @@
}
#endif
-/*================================================================================*/
-/* conversion functions: */
-/*================================================================================*/
-
-// Float to Word32
-Word32 float_to_fix( float number, Word32 Q );
-// Word32 to Float
-float fix_to_float( Word32 number, Word32 Q );
-// Float to Word16
-Word16 float_to_fix16( float number, Word16 Q );
-// Word16 to Float
-float fix16_to_float( Word16 number, Word16 Q );
-
-Word16 float_to_fix16_thrld( float number, Word16 Q );
-
-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 );
-void floatToFixed_arrL32( float *f, Word32 *i, Word16 Q, Word16 l );
-void fixedToFloat_arrL32( Word32 *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 );
-Word16 Q_factor_L_32( Word32 x );
-// Handles the cases where Q is negative
-Word32 floatToFixed( float f, Word16 Q );
-float fixedToFloat( Word32 i, Word16 Q );
-Word32 floatToFixed_32( float f, Word16 Q );
-float fixedToFloat_32( Word32 i, Word16 Q );
-float fixedToFloat_16( Word16 i, Word16 Q );
-
-void floatToFixed_arr16( float *f, Word16 *i, Word16 Q, Word16 l );
-void floatToFixed_arr32( float *f, Word32 *i, Word16 Q, Word16 l );
-// Float to 32-bit Mantissa and Exponent using frexp
-void f2me( float n, Word32 *mantissa, Word16 *expo );
-// 32-bit Mantissa and Exponent to Float using ldexp
-float me2f( Word32 m, Word16 expo );
-// Float to 32-bit Mantissa Array and Exponent
-void f2me_buf( const float *x, Word32 *m, Word16 *e, const Word32 n );
-// 32-bit Mantissa Array and Exponent to Float
-void me2f_buf( const Word32 *m, const Word16 e, float *out, const Word32 n );
-// Float to 16-bit Mantissa and Exponent using frexp
-void f2me_16( float n, Word16 *mantissa, Word16 *expo );
-// 16-bit Mantissa and Exponent to Float using ldexp
-float me2f_16( Word16 m, Word16 expo );
-// Float to 16-bit Mantissa Array and Exponent
-void f2me_buf_16( const float *x, Word16 *m, Word16 *e, const Word32 n );
-// 16-bit Mantissa Array and Exponent to Float
-void me2f_buf_16( const Word16 *m, const Word16 e, float *out, const Word32 n );
-
-void f2fix_16( float *var_flt, Word16 *var_fix, Word32 expo );
-void fix2f_16( Word16 *var_fix, float *var_flt, Word32 expo );
-void f2fix( float *var_flt, Word32 *var_fix, Word32 expo );
-void fix2f( Word32 *var_fix, float *var_flt, Word32 expo );
-
-// Get max Q factor for a float value before sat in 32-bit
-Word16 L_get_q( float f );
-Word16 L_get_q1( float f );
-// Get max Q factor for a float buffer before sat in 32-bit
-Word16 L_get_q_buf( float *ptr_flt, Word16 length );
-Word16 L_get_q_buf1( float *ptr_flt, Word16 length );
-
-/*================================================================================*/
-/* conversion functions: */
-/*================================================================================*/
+
+/*----------------------------------------------------------------------------------*
+ * Prototypes of tools
+ *----------------------------------------------------------------------------------*/
Word32 sum_l_fx(
const Word32 *vec, /* i : input vector */
const Word16 lvec /* i : length of input vector */
);
-
Word32 Mult_32_16(
Word32 a,
Word16 b );
@@ -215,13 +151,11 @@ void set32_fx(
const Word16 N /* i : Lenght of the vector */
);
-// tools.c
/* o : output random value */
Word16 Random(
Word16 *seed /* i/o: random seed */
);
-// tools.c
void Copy(
const Word16 x[], /* i : i vector */
Word16 y[], /* o : output vector */
@@ -3467,7 +3401,7 @@ void apply_gain_fx(
const Word16 *band_end, /* i : Sub band end indices Q0 */
const Word16 num_sfm, /* i : Number of bands Q0 */
const Word16 *gains, /* i : Band gain vector Q12 */
- Word16 *xq /* i/o: Float synthesis / Gain adjusted synth Q15/Q12 */
+ Word16 *xq /* i/o: synthesis / Gain adjusted synth Q15/Q12 */
);
void fine_gain_quant_fx(
@@ -5410,11 +5344,6 @@ void SynthesisSTFT_ivas_fx(
const Word16 nchan_out /* i : number of output channels */
);
-void mhvals(
- const Word16 d,
- Word16 *m /*, float * h*/
-);
-
Word32 sign_l(
const Word32 x /* i : input value of x */
);
@@ -7886,8 +7815,8 @@ void updt_IO_switch_dec_fx(
);
void updt_bw_switching_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 *synth, /* i : float synthesis signal */
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ const Word16 *synth, /* i : synthesis signal Qpost */
const Word16 Qpost );
void updt_dec_common_fx(
@@ -10980,9 +10909,6 @@ Word16 own_random(
Word16 *seed /* i/o: random seed */
);
-Word16 norm_ul_float(
- UWord32 UL_var1 );
-
/*! r: sum of all vector elements */
Word16 sum_s(
const Word16 *vec, /* i : input vector */
@@ -11022,17 +10948,6 @@ void set16_zero_fx(
const Word16 lvec /* i : length of the vector */
);
-void set_zero(
- float *vec, /* o : input vector */
- const Word16 lvec /* i : length of the vector */
-);
-
-void mvr2r(
- const float x[], /* i : input vector */
- float y[], /* o : output vector */
- const Word16 n /* i : vector size */
-);
-
void mvs2s(
const Word16 x[], /* i : input vector */
Word16 y[], /* o : output vector */
@@ -11058,18 +10973,6 @@ Word16 minimum_s(
Word16 *min_val /* o : minimum value in the input vector */
);
-/*! r: dequanzited gain */
-float usdequant(
- const Word16 idx, /* i : quantizer index */
- const float qlow, /* i : lowest codebook entry (index 0) */
- const float delta /* i : quantization step */
-);
-
-void sort(
- UWord16 *x, /* i/o: Vector to be sorted */
- UWord16 len /* i/o: vector length */
-);
-
void sort_l(
Word32 *x, /* i/o: Vector to be sorted */
Word16 len /* i/o: vector length */
diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c
index 98ca8c4ab1dce71ba25c07df33b3cc7238dbd829..73276fda31f53439626d7d279febb014a36652fa 100644
--- a/lib_com/pvq_com_fx.c
+++ b/lib_com/pvq_com_fx.c
@@ -474,12 +474,12 @@ void NearOppSplitAdjustment_fx(
*--------------------------------------------------------------------------*/
void apply_gain_fx(
- const Word16 *ord, /* i : Indices for energy order Q0 */
- const Word16 *band_start, /* i : Sub band start indices Q0 */
- const Word16 *band_end, /* i : Sub band end indices Q0 */
- const Word16 num_sfm, /* i : Number of bands Q0 */
- const Word16 *gains, /* i : Band gain vector Qx */
- Word16 *xq /* i/o: Float synthesis / Gain adjusted synth Q15/Qx */
+ const Word16 *ord, /* i : Indices for energy order Q0 */
+ const Word16 *band_start, /* i : Sub band start indices Q0 */
+ const Word16 *band_end, /* i : Sub band end indices Q0 */
+ const Word16 num_sfm, /* i : Number of bands Q0 */
+ const Word16 *gains, /* i : Band gain vector Qx */
+ Word16 *xq /* i/o: synthesis / Gain adjusted synth Q15/Qx */
)
{
Word16 band, i;
diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c
index 38b39f36e2501d17e2c15433853f10ae1346deb4..69968d5dba82b6f0371ef67363c7c06599e18169 100644
--- a/lib_com/tools_fx.c
+++ b/lib_com/tools_fx.c
@@ -72,31 +72,6 @@ Word16 own_random(
return ( *seed );
}
-/*---------------------------------------------------------------------
- * norm_ul_float()
- *
- *---------------------------------------------------------------------*/
-
-Word16 norm_ul_float( UWord32 UL_var1 )
-{
- Word16 var_out;
-
- if ( UL_var1 == 0 )
- {
- var_out = 0;
- }
- else
- {
- for ( var_out = 0; UL_var1 < (UWord32) 0x80000000U; var_out++ )
- {
- UL_var1 <<= 1;
- }
- }
- BASOP_CHECK();
-
- return ( var_out );
-}
-
/*---------------------------------------------------------------------
* sum_s()
@@ -359,68 +334,6 @@ void set_l(
return;
}
-/*---------------------------------------------------------------------*
- * set_zero()
- *
- * Set a vector vec[] of dimension lvec to zero
- *---------------------------------------------------------------------*/
-
-void set_zero(
- float *vec, /* o : input vector */
- const Word16 lvec /* i : length of the vector */
-)
-{
- Word16 i;
-
- for ( i = 0; i < lvec; i++ )
- {
- *vec++ = 0.0f;
- }
-
- return;
-}
-
-
-/*---------------------------------------------------------------------*
- * mvr2r()
- * mvs2s()
- * mvr2d()
- * mvd2r()
- *
- * Transfer the contents of vector x[] to vector y[]
- *---------------------------------------------------------------------*/
-
-void mvr2r(
- const float x[], /* i : input vector */
- float y[], /* o : output vector */
- const Word16 n /* i : vector size */
-)
-{
- Word16 i;
-
- if ( n <= 0 )
- {
- /* cannot transfer vectors with size 0 */
- return;
- }
-
- if ( y < x )
- {
- for ( i = 0; i < n; i++ )
- {
- y[i] = x[i];
- }
- }
- else
- {
- for ( i = n - 1; i >= 0; i-- )
- {
- y[i] = x[i];
- }
- }
-
- return;
-}
void mvs2s(
const Word16 x[], /* i : input vector */
@@ -879,26 +792,6 @@ void v_multc_fx_16_16(
return;
}
-/*-------------------------------------------------------------------*
- * usdequant()
- *
- * Uniform scalar de-quantizer routine
- *
- * Applies de-quantization based on scale and round operations.
- *-------------------------------------------------------------------*/
-
-float usdequant(
- const Word16 idx, /* i : quantizer index */
- const float qlow, /* i : lowest codebook entry (index 0) */
- const float delta /* i : quantization step */
-)
-{
- float g;
-
- g = idx * delta + qlow;
-
- return ( g );
-}
void sort(
UWord16 *x, /* i/o: Vector to be sorted */
@@ -925,192 +818,6 @@ void sort(
return;
}
-#define WMC_TOOL_SKIP
-
-// conversion functions:
-Word32 float_to_fix( float number, Word32 Q )
-{
- assert( Q >= 0 );
- if ( number == 1.0f && Q == Q31 )
- {
- return ONE_IN_Q31;
- }
- if ( isnan( number ) )
- {
- number = 0;
- }
- assert( fabs( number ) < pow( 2, 31 - Q ) );
- Word32 ret = (Word32) ( number * ( (UWord32) 1 << Q ) );
- return ret;
-}
-
-float fix_to_float(
- Word32 number,
- Word32 Q )
-{
- assert( Q >= 0 );
- float ret = (float) number / ( (UWord32) 1 << Q );
- return ret;
-}
-
-Word16 float_to_fix16(
- float number,
- Word16 Q )
-{
- assert( Q >= 0 );
- IF( isnan( number ) )
- return 0;
- if ( number == 1.0f && Q == Q15 )
- return MAX16B;
- if ( number == -1.0f && Q == Q15 )
- return MIN16B;
- assert( fabs( number ) < pow( 2, 15 - Q ) );
- Word16 ret = (Word16) ( number * ( (UWord16) 1 << Q ) );
- return ret;
-}
-
-Word16 float_to_fix16_thrld( float number, Word16 Q )
-{
- assert( Q >= 0 );
- if ( number == 1.0f && Q == Q15 )
- return MAX16B;
- float limit = (float) pow( 2, 15 - Q );
- /*Add threshold*/
- if ( number > MAX16B_FLT )
- {
- number = MAX16B_FLT;
- }
- else if ( number < MIN16B_FLT )
- {
- number = MIN16B_FLT;
- }
- assert( number <= limit && number >= -limit );
- Word16 ret = (Word16) ( number * ( (UWord16) 1 << Q ) );
- return ret;
-}
-
-float fix16_to_float( Word16 number, Word16 Q )
-{
- assert( Q >= 0 );
- float ret = (float) number / ( (UWord16) 1 << Q );
- return ret;
-}
-
-// Float to 32-bit Mantissa and Exponent
-void f2me( float n, Word32 *mantissa, Word16 *expo )
-{
- Word32 e;
- float mf = (float) frexp( n, &e );
- *expo = (Word16) e;
- *mantissa = float_to_fix( mf, Q31 );
-}
-
-// 32-bit Mantissa and Exponent to Float
-float me2f( Word32 m, Word16 expo )
-{
- float mf = fix_to_float( m, Q31 );
- return (float) ldexp( mf, expo );
-}
-
-// Float buffer to 32-bit mantissa buffer and common exponent.
-void f2me_buf( const float *x, Word32 *m, Word16 *e, const Word32 n )
-{
- Word16 max_e = -32, tmp_e;
- Word32 i;
-
- for ( i = 0; i < n; i++ )
- {
- f2me( x[i], &m[i], &tmp_e );
- max_e = ( max_e > tmp_e ) ? max_e : tmp_e;
- }
-
- for ( i = 0; i < n; i++ )
- {
- f2me( x[i], &m[i], &tmp_e );
- m[i] = L_shr( m[i], max_e - tmp_e );
- }
-
- *e = max_e;
-}
-
-// 32-bit Mantissa buffer and exponent into float buffer.
-void me2f_buf( const Word32 *m, const Word16 e, float *out, const Word32 n )
-{
- for ( int i = 0; i < n; i++ )
- {
- out[i] = me2f( m[i], e );
- }
-}
-
-// Float to 16-bit Mantissa and Exponent
-void f2me_16( float n, Word16 *mantissa, Word16 *expo )
-{
- Word32 e;
- float mf = (float) frexp( n, &e );
- *expo = (Word16) e;
- *mantissa = float_to_fix16( mf, 15 );
-}
-
-// 16-bit Mantissa and Exponent to Float
-float me2f_16( Word16 m, Word16 expo )
-{
- float mf = fix16_to_float( m, 15 );
- return (float) ldexp( mf, expo );
-}
-
-// Float buffer to 16-bit mantissa buffer and common exponent.
-void f2me_buf_16( const float *x, Word16 *m, Word16 *e, const Word32 n )
-{
- Word16 max_e = -16, tmp_e;
- Word32 i;
-
- for ( i = 0; i < n; i++ )
- {
- f2me_16( x[i], &m[i], &tmp_e );
- max_e = ( max_e > tmp_e ) ? max_e : tmp_e;
- }
-
- for ( i = 0; i < n; i++ )
- {
- f2me_16( x[i], &m[i], &tmp_e );
- m[i] = shr( m[i], max_e - tmp_e );
- }
-
- *e = max_e;
-}
-
-// 16-bit Mantissa buffer and exponent into float buffer.
-void me2f_buf_16( const Word16 *m, const Word16 e, float *out, const Word32 n )
-{
- for ( int i = 0; i < n; i++ )
- {
- out[i] = me2f_16( m[i], e );
- }
-}
-void f2fix( float *var_flt, Word32 *var_fix, Word32 expo )
-{
- *var_fix = (Word32) ( *var_flt * pow( 2, 31 - expo ) );
-}
-
-void fix2f( Word32 *var_fix, float *var_flt, Word32 expo )
-{
- float mf = fix_to_float( *var_fix, 31 );
- *var_flt = (float) ldexp( mf, expo );
-}
-
-void f2fix_16( float *var_flt, Word16 *var_fix, Word32 expo )
-{
- *var_fix = (Word16) ( *var_flt * pow( 2, 15 - expo ) );
-}
-
-void fix2f_16( Word16 *var_fix, float *var_flt, Word32 expo )
-{
- float mf = fix16_to_float( *var_fix, 15 );
- *var_flt = (float) ldexp( mf, expo );
-}
-
-#undef WMC_TOOL_SKIP
-
/*-------------------------------------------------------------------*
* usdequant_fx()
diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c
index 36471b15614d2e0c11bb22b7dbd92802f93c5be5..5d4a6d9645d7e4bb5d16cd973d8f3dbc20b37740 100644
--- a/lib_dec/ivas_binRenderer_internal_fx.c
+++ b/lib_dec/ivas_binRenderer_internal_fx.c
@@ -543,7 +543,7 @@ return IVAS_ERR_OK;
ivas_error ivas_allocate_binaural_hrtf_fx(
HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */
- const int16_t n_channels, /* i : number of input channels */
+ const Word16 n_channels, /* i : number of input channels */
const Word16 allocate_init_flag /* i : Memory allocation flag */
)
{
diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c
index 1f2f7779166df5d66c2a309a1bbab186f693dc22..853ea9aac4ac3084a90f523194358fb9bc21df2a 100644
--- a/lib_dec/ivas_jbm_dec_fx.c
+++ b/lib_dec/ivas_jbm_dec_fx.c
@@ -2710,7 +2710,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
}
ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
{
- /*TODO :To be tested : no stream entering---------------------------------------*/
/* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */
set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, hTcBuffer->n_samples_granularity ); // 32767=1.0f in Q15
@@ -2755,7 +2754,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
test();
IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
{
- /*TODO :To be tested : no stream entering*/
st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor;
IF( NE_32( ( error = getAudioConfigNumChannels( intern_config_old, &nchan_in ) ), IVAS_ERR_OK ) )
{
diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c
index 30f307731929f1f28f8c7ad8f9ff2fad660f5219..7df8ddfef39e13e8ed3f750d3526919d7c30fba8 100644
--- a/lib_dec/ivas_omasa_dec_fx.c
+++ b/lib_dec/ivas_omasa_dec_fx.c
@@ -681,7 +681,7 @@ ivas_error ivas_omasa_dec_config_fx(
{
set_s( hMasaIsmData->azimuth_ism_fx[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR );
set_s( hMasaIsmData->elevation_ism_fx[obj_idx], 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR );
- FOR( int16_t sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ )
+ FOR( Word16 sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR; sf++ )
{
set_l( hMasaIsmData->energy_ratio_ism_fx[obj_idx][sf], 0, CLDFB_NO_CHANNELS_MAX );
}
diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c
index 246fd4e297ff23a12bd73c3161dee26f8ccf30cc..82d52ca009e6be00a69456dae46b16417982ca4f 100644
--- a/lib_dec/lib_dec_fx.c
+++ b/lib_dec/lib_dec_fx.c
@@ -43,6 +43,9 @@
#include "jbm_pcmdsp_fifo.h"
#include
#include
+#ifdef DEBUGGING
+#include "float_to_fix_ops.h"
+#endif
#include "wmc_auto.h"
@@ -1454,7 +1457,6 @@ static ivas_error isar_generate_metadata_and_bitstream(
{
/*TD input*/
/*if CLDFB handles have been allocated then assume valid multi binaural input in out[][] buffer and perform CLDFB analysis*/
- /* local float2fix, to be removed */
num_poses = hSplitBinRend->splitrend.multiBinPoseData.num_poses;
move16();
@@ -3467,7 +3469,11 @@ static ivas_error IVAS_DEC_FeedAcousticEnvPI(
move32();
move32();
- mvr2r( hAcoustEnvPI.absorbCoeffs, hRenderConfig->roomAcoustics.AbsCoeff, IVAS_ROOM_ABS_COEFF );
+ FOR( Word16 i = 0; i < IVAS_ROOM_ABS_COEFF; i++ )
+ {
+ hRenderConfig->roomAcoustics.AbsCoeff[i] = hAcoustEnvPI.absorbCoeffs[i];
+ move16();
+ }
}
IF( ( error = IVAS_DEC_AddAcousticEnvironment( hIvasDec, acEnv ) ) != IVAS_ERR_OK )
@@ -5890,7 +5896,7 @@ static ivas_error printConfigInfo_dec(
IF( st_ivas->hDecoderConfig->Opt_non_diegetic_pan )
{
fprintf( stdout, "Output configuration: mono EVS bit-exact decoding to stereo\n" );
- float non_diegetic_pan_gain = fixedToFloat( st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, 15 );
+ float non_diegetic_pan_gain = (float) ( st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx ) / (float) ( 1LL << Q15 );
fprintf( stdout, "Non-diegetic panning: %.2f\n", non_diegetic_pan_gain * 90.f );
}
ELSE
@@ -6011,7 +6017,7 @@ static ivas_error printConfigInfo_dec(
IF( st_ivas->hDecoderConfig->Opt_non_diegetic_pan )
{
- float non_diegetic_pan_gain = fixedToFloat( st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, 15 );
+ float non_diegetic_pan_gain = (float) ( st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx ) / (float) ( 1LL << Q15 );
fprintf( stdout, "Non-diegetic panning: %.2f\n", non_diegetic_pan_gain * 90.f );
}
diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c
index 8704c2e078953ece7244675baad1c1e9af417161..7d389a0e23d4ced23f1d1b7ec7b29931ca8d78f1 100644
--- a/lib_dec/updt_dec_fx.c
+++ b/lib_dec/updt_dec_fx.c
@@ -394,8 +394,8 @@ void updt_IO_switch_dec_fx(
*-------------------------------------------------------------------*/
void updt_bw_switching_fx(
- Decoder_State *st_fx, /* i/o: decoder state structure */
- const Word16 *synth, /* i : fixed point synthesis signal Qpost */
+ Decoder_State *st_fx, /* i/o: decoder state structure */
+ const Word16 *synth, /* i : synthesis signal Qpost */
const Word16 Qpost )
{
test();
@@ -786,7 +786,7 @@ static void ivas_updt_bw_switching_fx(
move16();
}
}
- st_fx->prev_bws_cnt = st_fx->bws_cnt; // TODO: Duplicate variables
+ st_fx->prev_bws_cnt = st_fx->bws_cnt;
move16();
return;
}
diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c
index b7cdbc99472340e7ebac0a1cdf2b67eed6018c02..c390ab78b94f7129a690eb44722328636d19be0f 100644
--- a/lib_enc/core_switching_enc_fx.c
+++ b/lib_enc/core_switching_enc_fx.c
@@ -298,7 +298,7 @@ void core_switching_pre_enc_fx(
/* reset BWE memories */
IF( hBWE_FD != NULL )
{
- set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); /* TODO : this might not be needed */
+ set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
}
}
test();
@@ -915,7 +915,7 @@ void core_switching_pre_enc_ivas_fx(
/* reset BWE memories */
IF( hBWE_FD != NULL )
{
- set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); /* TODO : this might not be needed */
+ set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) );
}
}
test();
diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c
index 32582f2db10e8e7dedae16d3796559b0727d65ce..e685566645353a7d5f81aa4b460be74ecaf11502 100644
--- a/lib_enc/ivas_ism_metadata_enc_fx.c
+++ b/lib_enc/ivas_ism_metadata_enc_fx.c
@@ -505,7 +505,6 @@ ivas_error ivas_ism_metadata_enc_fx(
{
idx_angle1_abs = ism_quant_meta_fx( hIsmMetaData->azimuth_fx, &valQ_fx, ism_azimuth_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, 1 << ISM_AZIMUTH_NBITS );
idx_angle2_abs = ism_quant_meta_fx( hIsmMetaData->elevation_fx, &valQ_fx, ism_elevation_borders_fx, ISM_Q_STEP_FX, ISM_Q_STEP_BORDER_FX, 1 << ISM_ELEVATION_NBITS );
- // valQ = fixedToFloat( valQ_fx, Q22 );
}
ELSE /* ISM_MODE_PARAM */
{
@@ -527,7 +526,6 @@ ivas_error ivas_ism_metadata_enc_fx(
Word16 valQ_fx_tmp = extract_h( valQ_fx ); // 22 - 16 = 6
idx_radius_abs = usquant_fx( hIsmMetaData->radius_fx, &valQ_fx_tmp, ISM_RADIUS_MIN_Q9, ISM_RADIUS_DELTA_Q8, 1 << ISM_RADIUS_NBITS );
valQ_fx = L_shr( L_deposit_h( valQ_fx_tmp ), 3 ); // Q22
- // valQ = fixedToFloat( valQ_fx, Q22 );
encode_angle_indices_fx( hBstr, &( hIsmMetaData->orientation_angle ), hIsmMetaData->last_ism_metadata_flag, ini_frame, idx_angle1_abs, idx_angle2_abs, &flag_abs_yaw[ch], &flag_abs_pitch[ch] );
encode_radius_fx( hBstr, &hIsmMetaData->last_radius_idx, &hIsmMetaData->radius_diff_cnt, hIsmMetaData->last_ism_metadata_flag, idx_radius_abs, &flag_abs_radius[ch] );
}
diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c
index c10705e5db5192984f0279374dce3288edab1870..7c5972545795c6dcbde28290bf971053b5b1ceaf 100644
--- a/lib_enc/ivas_tcx_core_enc_fx.c
+++ b/lib_enc/ivas_tcx_core_enc_fx.c
@@ -370,7 +370,6 @@ void stereo_tcx_core_enc(
* Core Signal Analysis: MDCT, TNS, LPC analysis
*---------------------------------------------------------------*/
- /* TODO: integrate this. */
st->prev_Q_new = 0;
st->Q_old = 0;
diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h
index 5e995061569a99f74793eab34d724391f119862e..e4b29eb08b2f7cab50d5f303e4fb2c0dd24cf930 100644
--- a/lib_enc/prot_fx_enc.h
+++ b/lib_enc/prot_fx_enc.h
@@ -3625,7 +3625,7 @@ void re8_cod_fx(
void TBEreset_enc_fx(
TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
- const int16_t last_core, /* i : last core */
+ const Word16 last_core, /* i : last core */
Word16 bandwidth /* i : bandwidth mode */
);
diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c
index c6c7135fc32ea5b70fea2299389bc759af671b01..9aeaf5f2c75a6fbdcc5e0d3abcd93bd8a148ad6f 100644
--- a/lib_enc/swb_tbe_enc_fx.c
+++ b/lib_enc/swb_tbe_enc_fx.c
@@ -7637,7 +7637,7 @@ void tbe_write_bitstream_fx(
void TBEreset_enc_fx(
TD_BWE_ENC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */
- const int16_t last_core, /* i : last core */
+ const Word16 last_core, /* i : last core */
Word16 bandwidth /* i : bandwidth mode */
)
{
diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c
index 445540715ad5519ac42edd6b55b6cc002207f39a..37ebdf27852cc52bf1e1edabb73b721c576b3e44 100644
--- a/lib_isar/isar_splitRendererPre.c
+++ b/lib_isar/isar_splitRendererPre.c
@@ -48,6 +48,9 @@
#ifdef DBG_WAV_WRITER
#include "string.h"
#endif
+#ifdef DEBUG_QUANT_CODE_OUT
+#include "float_to_fix_ops.h"
+#endif
#include "basop_util.h"
/*---------------------------------------------------------------------*
diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c
index 8bc3c037980dc68ea0f0efb65cd69a47a63d27bc..dee0fe052a902bb55841b54c10646c6ff79fcce7 100644
--- a/lib_rend/ivas_hrtf_fx.c
+++ b/lib_rend/ivas_hrtf_fx.c
@@ -55,7 +55,7 @@ ivas_error ivas_HRTF_binary_open_fx(
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF binary!" );
}
- set_c( (int8_t *) ( *hHrtfTD ), 0, (int32_t) sizeof( TDREND_HRFILT_FiltSet_t ) );
+ set_c( (Word8 *) ( *hHrtfTD ), 0, (Word32) sizeof( TDREND_HRFILT_FiltSet_t ) );
return IVAS_ERR_OK;
}
@@ -246,7 +246,7 @@ ivas_error ivas_HRTF_parambin_binary_open_fx(
return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for parametric binauralizer HRTF tables!" );
}
- set_c( (int8_t *) ( *hHrtfParambin ), 0, (int32_t) sizeof( HRTFS_PARAMBIN ) );
+ set_c( (Word8 *) ( *hHrtfParambin ), 0, (Word32) sizeof( HRTFS_PARAMBIN ) );
return IVAS_ERR_OK;
}
diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h
index 9dce43a9751d6b8c12b41f8a5e7257a100a5cb04..e257ccd126ca3de2fc931e00fd99463a3e21c82b 100644
--- a/lib_rend/ivas_prot_rend_fx.h
+++ b/lib_rend/ivas_prot_rend_fx.h
@@ -608,7 +608,7 @@ ivas_error ivas_HRTF_CRend_binary_open_fx(
);
ivas_error ivas_HRTF_CRend_binary_open_buffers_int16(
- int16_t **buffer, /* o : buffer to allocate */
+ Word16 **buffer, /* o : buffer to allocate */
const uint32_t mem_size /* i : size of buffer */
);
@@ -618,7 +618,7 @@ void ivas_HRTF_CRend_binary_close_fx(
ivas_error ivas_HRTF_statistics_init_fx(
HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */
- const int32_t sampleRate /* i : Sample rate */
+ const Word32 sampleRate /* i : Sample rate */
);
void ivas_HRTF_statistics_close_fx(
@@ -891,7 +891,7 @@ ivas_error ivas_rend_openCrend_fx(
HRTFS_CREND_HANDLE hHrtfCrend,
HRTFS_STATISTICS_HANDLE hHrtfStatistics,
const Word32 output_Fs,
- const int16_t ext_rend_flag,
+ const Word16 ext_rend_flag,
const Word16 num_poses
);
diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c
index 09720d202d72eaceaa847453fc8af51939d97b97..b7f890ec39673d50daea8655d5a4bad9462be7e3 100644
--- a/lib_rend/ivas_reverb_fft_filter_fx.c
+++ b/lib_rend/ivas_reverb_fft_filter_fx.c
@@ -37,15 +37,17 @@
#include
#include "wmc_auto.h"
#include "debug.h"
-#define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) )
-#define fix_to_float( n, factor ) ( (float) n / ( 1 << factor ) )
+
/*------------------------------------------------------------------------------------------*
* Static functions declarations
*------------------------------------------------------------------------------------------*/
+
static void fft_wrapper_2ch_fx( Word32 *buffer_L, Word32 *buffer_R, const Word16 fft_size );
static void ifft_wrapper_2ch_fx( Word32 *buffer_L, Word32 *buffer_R, const Word16 fft_size );
+
+
/*-----------------------------------------------------------------------------------------*
* Function int_log2()
*
diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c
index b9762f72c2c4d3c3947d5ec68f179b08bd09b179..d45002320996d82c9a193755235dbb70fff6740f 100644
--- a/lib_rend/ivas_rotation_fx.c
+++ b/lib_rend/ivas_rotation_fx.c
@@ -98,6 +98,26 @@ static void external_target_interpolation_fx( EXTERNAL_ORIENTATION_HANDLE hExtOr
static bool are_orientations_same_fx( const IVAS_QUATERNION *orientation1, const IVAS_QUATERNION *orientation2 );
+/*-----------------------------------------------------------------------*
+ * function Q_factor_L_32()
+ *
+ *
+ *-----------------------------------------------------------------------*/
+
+static Word16 Q_factor_L_32(
+ const Word32 x )
+{
+ Word16 Q = 31;
+
+ if ( x >= 1 || x <= -1 )
+ {
+ Q = norm_l( L_abs( (Word32) x ) );
+ }
+
+ return Q;
+}
+
+
/*-----------------------------------------------------------------------*
* ivas_headTrack_open()
*
diff --git a/lib_util/float_to_fix_ops.c b/lib_util/float_to_fix_ops.c
new file mode 100644
index 0000000000000000000000000000000000000000..4bab0a6b1d9a7b8012257c039f374a6757ab5314
--- /dev/null
+++ b/lib_util/float_to_fix_ops.c
@@ -0,0 +1,129 @@
+
+#include "common_api_types.h"
+#include "float_to_fix_ops.h"
+#include
+#include
+
+
+#define Q15 15
+#define Q31 31
+#define ONE_IN_Q31 0x7fffffff
+#define MAX16B 32767
+#define MIN16B ( -32768 )
+#define MAXVAL_WORD32 ( (int32_t) 0x7FFFFFFF )
+
+
+Word32 float_to_fix(
+ float number,
+ const Word32 Q )
+{
+ assert( Q >= 0 );
+ if ( number == 1.0f && Q == Q31 )
+ {
+ return ONE_IN_Q31;
+ }
+ if ( isnan( number ) )
+ {
+ number = 0;
+ }
+ assert( fabs( number ) < pow( 2, 31 - Q ) );
+ Word32 ret = (Word32) ( number * ( (UWord32) 1 << Q ) );
+
+ return ret;
+}
+
+
+Word16 float_to_fix16(
+ const float number,
+ const Word16 Q )
+{
+ assert( Q >= 0 );
+ if ( isnan( number ) )
+ return 0;
+ if ( number == 1.0f && Q == Q15 )
+ return MAX16B;
+ if ( number == -1.0f && Q == Q15 )
+ return MIN16B;
+ assert( fabs( number ) < pow( 2, 15 - Q ) );
+ Word16 ret = (Word16) ( number * ( (UWord16) 1 << Q ) );
+
+ return ret;
+}
+
+
+Word32 floatToFixed(
+ const float f,
+ const Word16 Q )
+{
+ Word64 result_32;
+
+ if ( f == 1.0f && Q == Q15 )
+ return MAX16B;
+ if ( f == 1.0f && Q == Q31 )
+ return MAXVAL_WORD32;
+ if ( Q < 0 )
+ result_32 = (Word64) ( (float) ( f ) / (double) ( (unsigned Word64) 1 << ( -Q ) ) + ( f >= 0 ? 0.5 : -0.5 ) );
+ else
+ result_32 = (Word64) ( f * (double) ( (unsigned Word64) 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(
+ const Word32 i,
+ const Word16 Q )
+{
+ if ( Q < 0 )
+ return ( i * (float) ( ( 1LL ) << ( -Q ) ) );
+ else
+ return (float) ( i ) / (float) ( 1LL << Q );
+}
+
+
+float fix16_to_float(
+ const Word16 number,
+ const Word16 Q )
+{
+ assert( Q >= 0 );
+ float ret = (float) number / ( (UWord16) 1 << Q );
+
+ return ret;
+}
+
+
+Word32 floatToFixed_32(
+ const float number,
+ const Word16 Q )
+{
+ float val = 0.0f;
+ assert( abs_s( Q ) <= 63 );
+ if ( abs_s( Q ) > 31 )
+ {
+ if ( Q > 0 )
+ {
+ val = ( number * ( (unsigned int) MAX_32 + 1 ) ) * ( 1 << ( Q - 31 ) );
+ }
+ else
+ {
+ val = ( number / ( 1 << ( -Q - 31 ) ) ) / (unsigned int) MIN_32;
+ }
+ if ( val >= 0.0f )
+ {
+ assert( (Word32) val <= MAX_32 );
+ }
+ else
+ {
+ assert( (Word32) val >= MIN_32 );
+ }
+ }
+ else
+ {
+ return floatToFixed( number, Q );
+ }
+
+ return (Word32) val;
+}
diff --git a/lib_util/float_to_fix_ops.h b/lib_util/float_to_fix_ops.h
new file mode 100644
index 0000000000000000000000000000000000000000..0cd23cbc687c24b8026a754c0acbd320a466c14f
--- /dev/null
+++ b/lib_util/float_to_fix_ops.h
@@ -0,0 +1,19 @@
+
+#include "common_api_types.h"
+
+#ifndef FLOAT_TO_FIX_OPS_H
+#define FLOAT_TO_FIX_OPS_H
+
+Word32 float_to_fix( float number, const Word32 Q );
+
+Word16 float_to_fix16( const float number, const Word16 Q );
+
+Word32 floatToFixed( const float f, const Word16 Q );
+
+Word32 floatToFixed_32( const float number, const Word16 Q );
+
+float fixedToFloat( const Word32 i, const Word16 Q );
+
+float fix16_to_float( const Word16 number, const Word16 Q );
+
+#endif /* FLOAT_TO_FIX_OPS_H */
diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c
index aa9c62661687a10033b358f3f9eaaaa44743cb3c..2cced2665ac1f26de63f8b41716d85eb7de77b1d 100644
--- a/lib_util/ism_file_reader.c
+++ b/lib_util/ism_file_reader.c
@@ -34,12 +34,19 @@
#include "cmdl_tools.h"
#include
#include
-#include "prot_fx.h"
+#include "float_to_fix_ops.h"
+
#define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */
#define NUM_ISM_METADATA_PER_LINE 8 /* Number of ISM metadata per line in a metadata file */
#define NUM_MIN_ISM_METADATA 1 /* Minimum number of metadata parameters (azimuth) */
+#define Q9 9
+#define Q22 22
+#define Q31 31
+#define DEG_360_IN_Q22 ( 360 << Q22 ) /* Q22 */
+#define DEG_180_IN_Q22 ( 180 << Q22 ) /* Q22 */
+#define DEG_90_IN_Q22 ( 90 << Q22 ) /* Q22 */
struct IsmFileReader
{
@@ -175,7 +182,7 @@ ivas_error IsmFileReader_readNextFrame(
}
#ifdef FIX_2084_FLOATING_POINT_LEFTOVERS
- if ( GT_32( ismMetadata->azimuth_fx, DEG_180_IN_Q22 ) || LT_32( ismMetadata->azimuth_fx, -DEG_180_IN_Q22 ) )
+ if ( ( ismMetadata->azimuth_fx > DEG_180_IN_Q22 ) || ( ismMetadata->azimuth_fx < -DEG_180_IN_Q22 ) )
#else
if ( ismMetadata->azimuth > 180 || ismMetadata->azimuth < -180 )
#endif
@@ -183,7 +190,7 @@ ivas_error IsmFileReader_readNextFrame(
return IVAS_ERR_ISM_INVALID_METADATA_VALUE;
}
#ifdef FIX_2084_FLOATING_POINT_LEFTOVERS
- if ( GT_32( ismMetadata->elevation_fx, DEG_90_IN_Q22 ) || LT_32( ismMetadata->elevation_fx, -DEG_90_IN_Q22 ) )
+ if ( ( ismMetadata->elevation_fx > DEG_90_IN_Q22 ) || ( ismMetadata->elevation_fx < -DEG_90_IN_Q22 ) )
#else
if ( ismMetadata->elevation > 90 || ismMetadata->elevation < -90 )
#endif
@@ -191,7 +198,7 @@ ivas_error IsmFileReader_readNextFrame(
return IVAS_ERR_ISM_INVALID_METADATA_VALUE;
}
#ifdef FIX_2084_FLOATING_POINT_LEFTOVERS
- if ( LT_32( ismMetadata->radius_fx, 0 ) ) /* Negative radius not supported. Max quantized radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */
+ if ( ismMetadata->radius_fx < 0 ) /* Negative radius not supported. Max quantized radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */
#else
if ( ismMetadata->radius < 0 ) /* Negative radius not supported. Max quantized radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */
#endif
@@ -199,7 +206,7 @@ ivas_error IsmFileReader_readNextFrame(
return IVAS_ERR_ISM_INVALID_METADATA_VALUE;
}
#ifdef FIX_2084_FLOATING_POINT_LEFTOVERS
- if ( GT_32( ismMetadata->spread_fx, DEG_360_IN_Q22 ) || LT_32( ismMetadata->spread_fx, 0 ) )
+ if ( ( ismMetadata->spread_fx > DEG_360_IN_Q22 ) || ( ismMetadata->spread_fx < 0 ) )
#else
if ( ismMetadata->spread > 360 || ismMetadata->spread < 0 )
#endif
@@ -207,7 +214,7 @@ ivas_error IsmFileReader_readNextFrame(
return IVAS_ERR_ISM_INVALID_METADATA_VALUE;
}
#ifdef FIX_2084_FLOATING_POINT_LEFTOVERS
- if ( /*GT_32( ismMetadata->gainFactor_fx, ONE_IN_Q31 ) ||*/ LT_32( ismMetadata->gainFactor_fx, 0 ) )
+ if ( /*( ismMetadata->gainFactor_fx > ONE_IN_Q31 ) ||*/ ( ismMetadata->gainFactor_fx < 0 ) )
#else
if ( ismMetadata->gainFactor > 1 || ismMetadata->gainFactor < 0 )
#endif
@@ -215,7 +222,7 @@ ivas_error IsmFileReader_readNextFrame(
return IVAS_ERR_ISM_INVALID_METADATA_VALUE;
}
#ifdef FIX_2084_FLOATING_POINT_LEFTOVERS
- if ( GT_32( ismMetadata->yaw_fx, DEG_180_IN_Q22 ) || LT_32( ismMetadata->yaw_fx, -DEG_180_IN_Q22 ) )
+ if ( ( ismMetadata->yaw_fx > DEG_180_IN_Q22 ) || ( ismMetadata->yaw_fx < -DEG_180_IN_Q22 ) )
#else
if ( ismMetadata->yaw > 180 || ismMetadata->yaw < -180 )
#endif
@@ -223,7 +230,7 @@ ivas_error IsmFileReader_readNextFrame(
return IVAS_ERR_ISM_INVALID_METADATA_VALUE;
}
#ifdef FIX_2084_FLOATING_POINT_LEFTOVERS
- if ( GT_32( ismMetadata->pitch_fx, DEG_90_IN_Q22 ) || LT_32( ismMetadata->pitch_fx, -DEG_90_IN_Q22 ) )
+ if ( ( ismMetadata->pitch_fx > DEG_90_IN_Q22 ) || ( ismMetadata->pitch_fx < -DEG_90_IN_Q22 ) )
#else
if ( ismMetadata->pitch > 90 || ismMetadata->pitch < -90 )
#endif
diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c
index 8e55187c87caa7089da8f103533f738fdf6d601c..ba53566af0fa8142cfd23ec853d55c20bdd15eae 100644
--- a/lib_util/ism_file_writer.c
+++ b/lib_util/ism_file_writer.c
@@ -33,11 +33,14 @@
#include "ism_file_writer.h"
#include
#include
+#include "float_to_fix_ops.h"
-#include "prot_fx.h"
#define META_LINE_LENGTH 200 /* max number of characters at one line of metadata input/output file */
+#define Q9 9
+#define Q22 22
+#define Q31 31
struct IsmFileWriter
{
diff --git a/lib_util/ivas_rtp_file.c b/lib_util/ivas_rtp_file.c
index 4ef3578f6d276ac1e6723cf808ae486a09859f83..dd4d235ef8dfd1d8976b69c65ef4341b8b648c78 100644
--- a/lib_util/ivas_rtp_file.c
+++ b/lib_util/ivas_rtp_file.c
@@ -29,11 +29,16 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
+
+#include
#include
#include
#include "ivas_rtp_file.h"
#include "ivas_error_utils.h"
-#include "prot_fx.h"
+#include "float_to_fix_ops.h"
+
+
+#define Q15 15
struct IVAS_RTP_FILE
{
diff --git a/lib_util/ls_custom_file_reader.c b/lib_util/ls_custom_file_reader.c
index 37784a6305c237882477fd37292abdf89e78c79d..5c1ac6ae041709cb0c7f84642afab48efc2a8c7f 100644
--- a/lib_util/ls_custom_file_reader.c
+++ b/lib_util/ls_custom_file_reader.c
@@ -33,7 +33,7 @@
#include "ls_custom_file_reader.h"
#include
#include
-#include "ivas_prot_fx.h"
+#include
struct LsCustomFileReader
@@ -105,6 +105,96 @@ void CustomLsReader_close(
}
+/*-------------------------------------------------------------------*
+ * panning_wrap_angles()
+ *
+ * Wrap angles for amplitude panning to the range:
+ * azimuth = (-180, 180]
+ * elevation = [-90, 90]
+ * Considers direction changes from large elevation values
+ *-------------------------------------------------------------------*/
+
+/* helper function for panning_wrap_angles */
+static float wrap_azi(
+ const float azi_deg )
+{
+ float azi = azi_deg;
+
+ /* Wrap azimuth value */
+ while ( azi > 180 )
+ {
+ azi -= 360.0f;
+ }
+
+ while ( azi <= -180 )
+ {
+ azi += 360;
+ }
+
+ return azi;
+}
+
+static void panning_wrap_angles(
+ const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */
+ const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */
+ float *azi_wrapped, /* o : wrapped azimuth component */
+ float *ele_wrapped /* o : wrapped elevation component */
+)
+{
+ float azi, ele;
+
+ azi = azi_deg;
+ ele = ele_deg;
+
+ if ( fabsf( ele ) < 90 )
+ {
+ *ele_wrapped = ele;
+ *azi_wrapped = wrap_azi( azi );
+ return;
+ }
+ else
+ {
+ /* Special case when elevation is a multiple of 90; azimuth is irrelevant */
+ if ( ( fmodf( ele, 90 ) == 0 ) && ( fmodf( ele, 180 ) != 0 ) )
+ {
+ *azi_wrapped = 0;
+ while ( ele > 90 )
+ {
+ ele -= 360;
+ }
+ while ( ele < -90 )
+ {
+ ele += 360;
+ }
+ *ele_wrapped = ele;
+ }
+ else
+ {
+ /* Wrap elevation and adjust azimuth accordingly */
+ while ( fabsf( ele ) > 90 )
+ {
+ /* Flip to other hemisphere */
+ azi += 180;
+
+ /* Compensate elevation accordingly */
+ if ( ele > 90 )
+ {
+ ele = 180 - ele;
+ }
+ else if ( ele < -90 )
+ {
+ ele = -180 - ele;
+ }
+ }
+ *azi_wrapped = wrap_azi( azi );
+ *ele_wrapped = ele;
+ }
+
+ return;
+ }
+}
+
+
/*-------------------------------------------------------------------------*
* CustomLoudspeakerLayout_validate()
*
diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c
index 2f32ea858de8a066ba9e09cd6968e626599d6f08..9746c69ac41e10f01edcfd7d708fae77acfadea4 100644
--- a/lib_util/rotation_file_reader.c
+++ b/lib_util/rotation_file_reader.c
@@ -33,10 +33,14 @@
#include "rotation_file_reader.h"
#include
#include
-#include
-#include "prot_fx.h"
+#include "float_to_fix_ops.h"
+#define Q22 22
+#define Q25 25
+#define Q29 29
+#define Q31 31
+
struct RotFileReader
{
FILE *trajFile;
@@ -206,10 +210,7 @@ ivas_error ExternalOrientationFileReading(
pQuaternion->x_fx = float_to_fix( x, Q29 );
pQuaternion->y_fx = float_to_fix( y, Q29 );
pQuaternion->z_fx = float_to_fix( z, Q29 );
- move32();
- move32();
- move32();
- move32();
+
*enableHeadRotation = (int8_t) headRotFlag;
*enableExternalOrientation = (int8_t) extOrientationFlag;
*enableRotationInterpolation = (int8_t) rotInterpolationFlag;
diff --git a/lib_util/vector3_pair_file_reader.c b/lib_util/vector3_pair_file_reader.c
index a4b8cc450bdb26b6f204a3cce6935cf906a19c33..737ef91af135e8ad834d85a2d66a1a8dea0c3e8b 100644
--- a/lib_util/vector3_pair_file_reader.c
+++ b/lib_util/vector3_pair_file_reader.c
@@ -33,8 +33,7 @@
#include "vector3_pair_file_reader.h"
#include
#include
-#include "prot_fx.h" // needed for floatToFixed_32
-//#include "ivas_prot_fx.h" // needed for floatToFixed_32
+#include "float_to_fix_ops.h" // needed for floatToFixed_32
struct Vector3PairFileReader
@@ -115,8 +114,8 @@ ivas_error Vector3PairFileReader_read(
pSecond->y = y2;
pSecond->z = z2;
- pFirst->q_fact = Q29;
- pSecond->q_fact = Q29;
+ pFirst->q_fact = 29; // Q29
+ pSecond->q_fact = 29; // Q29
pFirst->x_fx = floatToFixed_32( pFirst->x, pFirst->q_fact );
pFirst->y_fx = floatToFixed_32( pFirst->y, pFirst->q_fact );
pFirst->z_fx = floatToFixed_32( pFirst->z, pFirst->q_fact );