Loading lib_com/cnst.h +2 −3 Original line number Diff line number Diff line Loading @@ -1979,11 +1979,10 @@ typedef enum _DCTTYPE #define INV_PREECHO_SMOOTH_LENP1 ( 1 / ( PREECHO_SMOOTH_LEN + 1.0 ) ); #define EPSILON 0.000000000000001f #define EPSILON_FX 0 #define EPSILON_FX_SMALL 1 #ifdef IVAS_FLOAT_FIXED #define EPSILON_FIX (1) #endif #define EPSILON_FX (Word32)1 #define MAX_SEGMENT_LENGTH 480 #define NUM_TIME_SWITCHING_BLOCKS 4 Loading lib_com/ivas_cnst.h +2 −2 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ #ifdef IVAS_FLOAT_FIXED #define INV_SQRT2_FX_Q15 23170 /* 1/sqrt(2) Q15*/ #define INV_SQRT3_FX 18918 /* 1/sqrt(3) Q15*/ #endif #define LOG_10 2.30258509299f Loading lib_com/ivas_prot.h +33 −0 Original line number Diff line number Diff line Loading @@ -3042,6 +3042,25 @@ void mvr2r_inc( const int16_t n /* i : vector size */ ); #ifdef IVAS_FLOAT_FIXED void mvr2r_inc_fixed_one( const Word32 x_fx[], /* i : input vector */ const Word16 x_inc, /* i : increment for vector x[] */ Word32 y_fx[], /* o : output vector */ const Word16 y_inc, /* i : increment for vector y[] */ const Word16 n /* i : vector size */ ); void mvr2r_inc_fixed( const float x[], /* i : input vector */ const Word32 x_fx[], /* i : input vector */ const int16_t x_inc, /* i : increment for vector x[] */ float y[], /* o : output vector */ Word32 y_fx[], /* o : output vector */ const int16_t y_inc, /* i : increment for vector y[] */ const int16_t n /* i : vector size */ ); #endif void v_add_inc( const float x1[], /* i : Input vector 1 */ const int16_t x_inc, /* i : Increment for input vector 1 */ Loading Loading @@ -3085,6 +3104,13 @@ void v_addc_fx( const Word16 N /* i : Vector length */ ); #endif void v_addc_fixed( const Word32 x[], /* i : Input vector */ const Word32 c, /* i : Constant */ Word32 y[], /* o : Output vector that contains c*x */ const Word16 N /* i : Vector length */ ); void v_addc( const float x[], /* i : Input vector */ const float c, /* i : Constant */ Loading Loading @@ -4162,6 +4188,13 @@ void ivas_dirac_dec_get_response_fixed( const Word16 elevation, Word32 *response, const Word16 ambisonics_order ); void ivas_dirac_dec_get_response_fixed_Q( const Word16 azimuth, const Word16 elevation, Word32 *response, const Word16 ambisonics_order, Word16 Q); #endif void calculate_hodirac_sector_parameters( Loading lib_com/ivas_spar_com.c +117 −0 Original line number Diff line number Diff line Loading @@ -1998,6 +1998,123 @@ void ivas_dirac_dec_get_response_fixed( return; } void ivas_dirac_dec_get_response_fixed_Q( const Word16 azimuth, const Word16 elevation, Word32 *response, const Word16 ambisonics_order, Word16 Q_out) { Word16 index_azimuth, index_elevation; Word16 el, e, az; Word32 cos_1, cos_2, sin_1, cos_az[3]; Word32 sin_az[3]; Word32 f, c; Word16 l, m; Word16 b, b1, b_2, b1_2, a; index_azimuth = (azimuth + 180) % 360; index_elevation = elevation + 90; e = index_elevation > 90 ? -1 : 1; el = index_elevation > 90 ? 180 - index_elevation : index_elevation; az = index_azimuth > 180 ? 360 - index_azimuth : index_azimuth; f = index_azimuth > 180 ? -(1 << Q29) : (1 << Q29); cos_1 = dirac_gains_trg_term_int[az][0] >> 1; // Q29 cos_2 = Mpy_32_32(cos_1, cos_1); // Q27 sin_1 = Mpy_32_32(f, dirac_gains_trg_term_int[az][1] >> 1); // Q27 cos_az[0] = cos_1; // Q29 cos_az[1] = L_sub(Mpy_32_32((1 << Q30), cos_2), (1 << Q25)) << 4; // Q29 cos_az[2] = L_sub(Mpy_32_32(Mpy_32_32((1 << Q30), cos_1), cos_az[1]) << 4, cos_az[0]); // Q29 sin_az[0] = sin_1 << 2; // Q29 sin_az[1] = Mpy_32_32(Mpy_32_32(sin_1, (1 << Q30)), cos_1) << 6; // Q29 sin_az[2] = Mpy_32_32(sin_1, L_sub(L_shl_sat(Mpy_32_32((1 << Q30), cos_2), 5), (1 << 29))) << 4; response[0] = L_shl(1, Q_out); /* Un-optimized code - for reference */ /* for( l = 1; l<= ambisonics_order; l++ ) */ /* { */ /* int16_t b, b1, a; */ /* float c; */ /* for( m = 0; m < l; m++ ) */ /* { */ /* b = l*l+m; */ /* a = dirac_gains_P_idx[b]; */ /* c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */ /* if( m%2 == 1 ) */ /* { */ /* c = c*e; */ /* } */ /* response[b] = c * sin_az[l-m-1]; */ /* b1 = l*l+2*l-m; */ /* response[b1] = c * cos_az[l-m-1]; */ /* } */ /* b = l*l+l; */ /* a = dirac_gains_P_idx[b]; */ /* c = dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */ /* if( l%2 == 1) */ /* { */ /* c = c*e; */ /* } */ /* response[b] = c; */ /* } */ FOR(l = 1; l <= ambisonics_order; l++) { b_2 = l * l; b1_2 = l * l + 2 * l; FOR(m = 0; m < l; m += 2) { b = b_2 + m; a = dirac_gains_P_idx[b]; c = Mpy_32_32(Mpy_32_32(SQRT2_FIXED, dirac_gains_norm_term_int[a]), dirac_gains_Pnm_int[el][a]); // Q25 response[b] = L_shl(Mpy_32_32(c, sin_az[l - m - 1]), Q_out - Q23); // Q_out b1 = b1_2 - m; response[b1] = L_shl(Mpy_32_32(c, cos_az[l - m - 1]), Q_out - Q23); // Q_out } FOR(m = 1; m < l; m += 2) { b = b_2 + m; a = dirac_gains_P_idx[b]; c = Mpy_32_32(Mpy_32_32(SQRT2_FIXED, dirac_gains_norm_term_int[a]), dirac_gains_Pnm_int[el][a]); // Q25 IF(e == -1) { c = -c; } response[b] = L_shl(Mpy_32_32(c, sin_az[l - m - 1]), Q_out - Q23); // Q29 b1 = b1_2 - m; response[b1] = L_shl(Mpy_32_32(c, cos_az[l - m - 1]), Q_out - Q23); // Q29 } b = b_2 + l; a = dirac_gains_P_idx[b]; c = Mpy_32_32(dirac_gains_norm_term_int[a], dirac_gains_Pnm_int[el][a]); //Q26 IF(l % 2 == 1) { IF(e == -1) { c = -c; } } response[b] = L_shl(c, Q_out - Q26); // Q29 } return; } #endif /*-----------------------------------------------------------------------------------------* Loading lib_com/ivas_tools.c +116 −1 Original line number Diff line number Diff line Loading @@ -187,6 +187,103 @@ void ivas_syn_output_f( * * *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED void mvr2r_inc_fixed_one( const Word32 x_fx[], /* i : input vector */ const Word16 x_inc, /* i : increment for vector x[] */ Word32 y_fx[], /* o : output vector */ const Word16 y_inc, /* i : increment for vector y[] */ const Word16 n /* i : vector size */ ) { Word16 i; Word16 ix; Word16 iy; IF(n <= 0) { /* cannot transfer vectors with size 0 */ return; } IF(y_fx < x_fx) { ix = 0; iy = 0; FOR(i = 0; i < n; i++) { y_fx[iy] = x_fx[ix]; ix += x_inc; iy += y_inc; } } ELSE { ix = (n - 1) * x_inc; iy = (n - 1) * y_inc; FOR(i = n - 1; i >= 0; i--) { y_fx[iy] = x_fx[ix]; ix -= x_inc; iy -= y_inc; } } return; } void mvr2r_inc_fixed( const float x[], /* i : input vector */ const Word32 x_fx[], /* i : input vector */ const Word16 x_inc, /* i : increment for vector x[] */ float y[], /* o : output vector */ Word32 y_fx[], /* o : output vector */ const Word16 y_inc, /* i : increment for vector y[] */ const Word16 n /* i : vector size */ ) { Word16 i; Word16 ix; Word16 iy; IF (n <= 0) { /* cannot transfer vectors with size 0 */ return; } IF (y_fx < x_fx) { ix = 0; iy = 0; FOR (i = 0; i < n; i++) { y_fx[iy] = x_fx[ix]; y[iy] = x[ix]; ix += x_inc; iy += y_inc; } } ELSE { ix = (n - 1) * x_inc; iy = (n - 1) * y_inc; FOR (i = n - 1; i >= 0; i--) { y_fx[iy] = x_fx[ix]; y[iy] = x[ix]; ix -= x_inc; iy -= y_inc; } } return; } #endif void mvr2r_inc( const float x[], /* i : input vector */ Loading Loading @@ -402,6 +499,24 @@ void v_addc_fx( * * Addition of constant to vector *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED void v_addc_fixed( const Word32 x[], /* i : Input vector */ const Word32 c, /* i : Constant */ Word32 y[], /* o : Output vector that contains c*x */ const Word16 N /* i : Vector length */ ) { Word16 i; FOR(i = 0; i < N; i++) { y[i] = L_add(c, x[i]); } return; } #endif void v_addc( const float x[], /* i : Input vector */ Loading Loading
lib_com/cnst.h +2 −3 Original line number Diff line number Diff line Loading @@ -1979,11 +1979,10 @@ typedef enum _DCTTYPE #define INV_PREECHO_SMOOTH_LENP1 ( 1 / ( PREECHO_SMOOTH_LEN + 1.0 ) ); #define EPSILON 0.000000000000001f #define EPSILON_FX 0 #define EPSILON_FX_SMALL 1 #ifdef IVAS_FLOAT_FIXED #define EPSILON_FIX (1) #endif #define EPSILON_FX (Word32)1 #define MAX_SEGMENT_LENGTH 480 #define NUM_TIME_SWITCHING_BLOCKS 4 Loading
lib_com/ivas_cnst.h +2 −2 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ #ifdef IVAS_FLOAT_FIXED #define INV_SQRT2_FX_Q15 23170 /* 1/sqrt(2) Q15*/ #define INV_SQRT3_FX 18918 /* 1/sqrt(3) Q15*/ #endif #define LOG_10 2.30258509299f Loading
lib_com/ivas_prot.h +33 −0 Original line number Diff line number Diff line Loading @@ -3042,6 +3042,25 @@ void mvr2r_inc( const int16_t n /* i : vector size */ ); #ifdef IVAS_FLOAT_FIXED void mvr2r_inc_fixed_one( const Word32 x_fx[], /* i : input vector */ const Word16 x_inc, /* i : increment for vector x[] */ Word32 y_fx[], /* o : output vector */ const Word16 y_inc, /* i : increment for vector y[] */ const Word16 n /* i : vector size */ ); void mvr2r_inc_fixed( const float x[], /* i : input vector */ const Word32 x_fx[], /* i : input vector */ const int16_t x_inc, /* i : increment for vector x[] */ float y[], /* o : output vector */ Word32 y_fx[], /* o : output vector */ const int16_t y_inc, /* i : increment for vector y[] */ const int16_t n /* i : vector size */ ); #endif void v_add_inc( const float x1[], /* i : Input vector 1 */ const int16_t x_inc, /* i : Increment for input vector 1 */ Loading Loading @@ -3085,6 +3104,13 @@ void v_addc_fx( const Word16 N /* i : Vector length */ ); #endif void v_addc_fixed( const Word32 x[], /* i : Input vector */ const Word32 c, /* i : Constant */ Word32 y[], /* o : Output vector that contains c*x */ const Word16 N /* i : Vector length */ ); void v_addc( const float x[], /* i : Input vector */ const float c, /* i : Constant */ Loading Loading @@ -4162,6 +4188,13 @@ void ivas_dirac_dec_get_response_fixed( const Word16 elevation, Word32 *response, const Word16 ambisonics_order ); void ivas_dirac_dec_get_response_fixed_Q( const Word16 azimuth, const Word16 elevation, Word32 *response, const Word16 ambisonics_order, Word16 Q); #endif void calculate_hodirac_sector_parameters( Loading
lib_com/ivas_spar_com.c +117 −0 Original line number Diff line number Diff line Loading @@ -1998,6 +1998,123 @@ void ivas_dirac_dec_get_response_fixed( return; } void ivas_dirac_dec_get_response_fixed_Q( const Word16 azimuth, const Word16 elevation, Word32 *response, const Word16 ambisonics_order, Word16 Q_out) { Word16 index_azimuth, index_elevation; Word16 el, e, az; Word32 cos_1, cos_2, sin_1, cos_az[3]; Word32 sin_az[3]; Word32 f, c; Word16 l, m; Word16 b, b1, b_2, b1_2, a; index_azimuth = (azimuth + 180) % 360; index_elevation = elevation + 90; e = index_elevation > 90 ? -1 : 1; el = index_elevation > 90 ? 180 - index_elevation : index_elevation; az = index_azimuth > 180 ? 360 - index_azimuth : index_azimuth; f = index_azimuth > 180 ? -(1 << Q29) : (1 << Q29); cos_1 = dirac_gains_trg_term_int[az][0] >> 1; // Q29 cos_2 = Mpy_32_32(cos_1, cos_1); // Q27 sin_1 = Mpy_32_32(f, dirac_gains_trg_term_int[az][1] >> 1); // Q27 cos_az[0] = cos_1; // Q29 cos_az[1] = L_sub(Mpy_32_32((1 << Q30), cos_2), (1 << Q25)) << 4; // Q29 cos_az[2] = L_sub(Mpy_32_32(Mpy_32_32((1 << Q30), cos_1), cos_az[1]) << 4, cos_az[0]); // Q29 sin_az[0] = sin_1 << 2; // Q29 sin_az[1] = Mpy_32_32(Mpy_32_32(sin_1, (1 << Q30)), cos_1) << 6; // Q29 sin_az[2] = Mpy_32_32(sin_1, L_sub(L_shl_sat(Mpy_32_32((1 << Q30), cos_2), 5), (1 << 29))) << 4; response[0] = L_shl(1, Q_out); /* Un-optimized code - for reference */ /* for( l = 1; l<= ambisonics_order; l++ ) */ /* { */ /* int16_t b, b1, a; */ /* float c; */ /* for( m = 0; m < l; m++ ) */ /* { */ /* b = l*l+m; */ /* a = dirac_gains_P_idx[b]; */ /* c = SQRT2 * dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */ /* if( m%2 == 1 ) */ /* { */ /* c = c*e; */ /* } */ /* response[b] = c * sin_az[l-m-1]; */ /* b1 = l*l+2*l-m; */ /* response[b1] = c * cos_az[l-m-1]; */ /* } */ /* b = l*l+l; */ /* a = dirac_gains_P_idx[b]; */ /* c = dirac_gains_norm_term[a] * dirac_gains_Pnm[el][a]; */ /* if( l%2 == 1) */ /* { */ /* c = c*e; */ /* } */ /* response[b] = c; */ /* } */ FOR(l = 1; l <= ambisonics_order; l++) { b_2 = l * l; b1_2 = l * l + 2 * l; FOR(m = 0; m < l; m += 2) { b = b_2 + m; a = dirac_gains_P_idx[b]; c = Mpy_32_32(Mpy_32_32(SQRT2_FIXED, dirac_gains_norm_term_int[a]), dirac_gains_Pnm_int[el][a]); // Q25 response[b] = L_shl(Mpy_32_32(c, sin_az[l - m - 1]), Q_out - Q23); // Q_out b1 = b1_2 - m; response[b1] = L_shl(Mpy_32_32(c, cos_az[l - m - 1]), Q_out - Q23); // Q_out } FOR(m = 1; m < l; m += 2) { b = b_2 + m; a = dirac_gains_P_idx[b]; c = Mpy_32_32(Mpy_32_32(SQRT2_FIXED, dirac_gains_norm_term_int[a]), dirac_gains_Pnm_int[el][a]); // Q25 IF(e == -1) { c = -c; } response[b] = L_shl(Mpy_32_32(c, sin_az[l - m - 1]), Q_out - Q23); // Q29 b1 = b1_2 - m; response[b1] = L_shl(Mpy_32_32(c, cos_az[l - m - 1]), Q_out - Q23); // Q29 } b = b_2 + l; a = dirac_gains_P_idx[b]; c = Mpy_32_32(dirac_gains_norm_term_int[a], dirac_gains_Pnm_int[el][a]); //Q26 IF(l % 2 == 1) { IF(e == -1) { c = -c; } } response[b] = L_shl(c, Q_out - Q26); // Q29 } return; } #endif /*-----------------------------------------------------------------------------------------* Loading
lib_com/ivas_tools.c +116 −1 Original line number Diff line number Diff line Loading @@ -187,6 +187,103 @@ void ivas_syn_output_f( * * *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED void mvr2r_inc_fixed_one( const Word32 x_fx[], /* i : input vector */ const Word16 x_inc, /* i : increment for vector x[] */ Word32 y_fx[], /* o : output vector */ const Word16 y_inc, /* i : increment for vector y[] */ const Word16 n /* i : vector size */ ) { Word16 i; Word16 ix; Word16 iy; IF(n <= 0) { /* cannot transfer vectors with size 0 */ return; } IF(y_fx < x_fx) { ix = 0; iy = 0; FOR(i = 0; i < n; i++) { y_fx[iy] = x_fx[ix]; ix += x_inc; iy += y_inc; } } ELSE { ix = (n - 1) * x_inc; iy = (n - 1) * y_inc; FOR(i = n - 1; i >= 0; i--) { y_fx[iy] = x_fx[ix]; ix -= x_inc; iy -= y_inc; } } return; } void mvr2r_inc_fixed( const float x[], /* i : input vector */ const Word32 x_fx[], /* i : input vector */ const Word16 x_inc, /* i : increment for vector x[] */ float y[], /* o : output vector */ Word32 y_fx[], /* o : output vector */ const Word16 y_inc, /* i : increment for vector y[] */ const Word16 n /* i : vector size */ ) { Word16 i; Word16 ix; Word16 iy; IF (n <= 0) { /* cannot transfer vectors with size 0 */ return; } IF (y_fx < x_fx) { ix = 0; iy = 0; FOR (i = 0; i < n; i++) { y_fx[iy] = x_fx[ix]; y[iy] = x[ix]; ix += x_inc; iy += y_inc; } } ELSE { ix = (n - 1) * x_inc; iy = (n - 1) * y_inc; FOR (i = n - 1; i >= 0; i--) { y_fx[iy] = x_fx[ix]; y[iy] = x[ix]; ix -= x_inc; iy -= y_inc; } } return; } #endif void mvr2r_inc( const float x[], /* i : input vector */ Loading Loading @@ -402,6 +499,24 @@ void v_addc_fx( * * Addition of constant to vector *-------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED void v_addc_fixed( const Word32 x[], /* i : Input vector */ const Word32 c, /* i : Constant */ Word32 y[], /* o : Output vector that contains c*x */ const Word16 N /* i : Vector length */ ) { Word16 i; FOR(i = 0; i < N; i++) { y[i] = L_add(c, x[i]); } return; } #endif void v_addc( const float x[], /* i : Input vector */ Loading