diff --git a/lib_com/bits_alloc.c b/lib_com/bits_alloc.c index 67840f93e605ed1664f20b82b30ba54b64b1b9c2..c99851d58db839a8e0cb3577db425cede40bfebb 100644 --- a/lib_com/bits_alloc.c +++ b/lib_com/bits_alloc.c @@ -42,15 +42,14 @@ #include "ivas_rom_com.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * Local function prototypes *--------------------------------------------------------------------*/ static int16_t BITS_ALLOC_adjust_acelp_fixed_cdk( const int16_t bits_frame, int16_t *fixed_cdk_index, const int16_t nb_subfr ); -#ifndef IVAS_FLOAT_FIXED static int16_t allocate_unused( const int32_t core_brate, const int16_t coder_type, const int16_t unused_bits, const int16_t nb_prm, const int16_t subfr, const int16_t prm_type, int16_t *prm_bit_mode ); -#endif typedef enum { @@ -358,7 +357,6 @@ static int16_t BITS_ALLOC_adjust_acelp_fixed_cdk( * Selection of fixed innovation codebook bitbudget table *--------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static int16_t fcb_table( const int16_t n, const int16_t L_subfr ) @@ -373,7 +371,6 @@ static int16_t fcb_table( return ( out ); } -#endif /*-------------------------------------------------------------------* * acelp_FCB_allocator() @@ -381,7 +378,6 @@ static int16_t fcb_table( * Routine to allocate fixed innovation codebook bit-budget *--------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static ivas_error acelp_FCB_allocator( int16_t *nBits, /* i/o: available bit-budget */ int16_t fixed_cdk_index[], /* o : codebook index */ @@ -512,7 +508,6 @@ static ivas_error acelp_FCB_allocator( return error; } -#endif /*-------------------------------------------------------------------* @@ -523,7 +518,6 @@ static ivas_error acelp_FCB_allocator( * - per channel bitrate minimum is 13250 kbps for ACELP@16kHz *--------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED ivas_error config_acelp1_IVAS( const int16_t enc_dec, /* i : encoder/decoder flag */ const int32_t total_brate, /* i : total bitrate */ @@ -1341,7 +1335,6 @@ ivas_error config_acelp1_IVAS( return error; } -#endif /*-------------------------------------------------------------------* * allocate_unused() @@ -1349,7 +1342,6 @@ ivas_error config_acelp1_IVAS( * Allocate unused bits *--------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static int16_t allocate_unused( const int32_t core_brate, const int16_t coder_type, @@ -1426,7 +1418,6 @@ static int16_t allocate_unused( return bit_added + max_bit_per_pos; } -#endif /*-------------------------------------------------------------------* @@ -1436,8 +1427,6 @@ static int16_t allocate_unused( *--------------------------------------------------------------------*/ /*! r: ACELP16k flag */ - -#ifndef IVAS_FLOAT_FIXED int16_t set_ACELP_flag_IVAS( const int16_t element_mode, /* i : element mode */ const int32_t element_brate, /* i : element bitrate */ diff --git a/lib_com/cng_exc.c b/lib_com/cng_exc.c index d1e24e065df58147930e9cc4b4c45e6a83cffb91..716750db83f3b14ac11c7c41d8468b8b7da25a12 100644 --- a/lib_com/cng_exc.c +++ b/lib_com/cng_exc.c @@ -478,7 +478,7 @@ void cng_params_postupd( * * update CNG parameters *-------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void cng_params_upd( const float lsp_new[], /* i : LSP parameters */ const float exc2[], /* i : current enhanced excitation */ @@ -581,6 +581,7 @@ void cng_params_upd( return; } +#endif /*---------------------------------------------------------------------* diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index c3506838f6c0118e087a034043510fd2250b9b56..4682759623ef0ad80ca8c4bd3ea268250dbf6efe 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -22,141 +22,141 @@ static Word16 get_edxt_factor( Word16 length ) /* Returns value of sqrtf(2.f/len move16(); IF( EQ_16( length, 512 ) ) { - factor = 2048; + factor = 2048; /*0.0625 in Q15*/ move16(); } ELSE IF( EQ_16( length, 256 ) ) { - factor = 2896; + factor = 2896; /*0.0883 in Q15*/ move16(); } ELSE IF( EQ_16( length, 128 ) ) { - factor = 4096; + factor = 4096; /*0.125 in Q15*/ move16(); } ELSE IF( EQ_16( length, 640 ) ) { - factor = 1832; + factor = 1832; /*0.0559 in Q15*/ move16(); } ELSE IF( EQ_16( length, 320 ) ) { - factor = 2590; + factor = 2590; /*0.079 in Q15*/ move16(); } ELSE IF( EQ_16( length, 160 ) ) { - factor = 3663; + factor = 3663; /*0.1117 in Q15*/ move16(); } ELSE IF( EQ_16( length, 80 ) ) { - factor = 5181; + factor = 5181; /*0.1581 in Q15*/ move16(); } ELSE IF( EQ_16( length, 40 ) ) { - factor = 7327; + factor = 7327; /*0.223 in Q15*/ move16(); } ELSE IF( EQ_16( length, 960 ) ) { - factor = 1496; + factor = 1496; /*0.0456 in Q15*/ move16(); } ELSE IF( EQ_16( length, 480 ) ) { - factor = 2115; + factor = 2115; /*0.0645 in Q15*/ move16(); } ELSE IF( EQ_16( length, 240 ) ) { - factor = 2991; + factor = 2991; /*0.0912 in Q15*/ move16(); } ELSE IF( EQ_16( length, 120 ) ) { - factor = 4230; + factor = 4230; /*0.1290 in Q15*/ move16(); } ELSE IF( EQ_16( length, 1200 ) ) { - factor = 1338; + factor = 1338; /*0.040 in Q15*/ move16(); } ELSE IF( EQ_16( length, 800 ) ) { - factor = 1638; + factor = 1638; /*0.05 in Q15*/ move16(); } ELSE IF( EQ_16( length, 400 ) ) { - factor = 2317; + factor = 2317; /*0.070 in Q15*/ move16(); } ELSE IF( EQ_16( length, 200 ) ) { - factor = 3277; + factor = 3277; /*0.1 in Q15*/ move16(); } - return factor; + return factor; /*Q15*/ } -static Word16 const *get_edct_table( Word16 length, Word16 *q ) +static Word16 const *get_edct_table( Word16 length /*Q0*/, Word16 *q ) { Word16 const *edct_table; edct_table = NULL; SWITCH( length ) { case 1200: - edct_table = edct_table_600_fx; + edct_table = edct_table_600_fx; /*Q17*/ *q = add( *q, 2 ); move16(); BREAK; case 960: - edct_table = edct_table_480_fx; + edct_table = edct_table_480_fx; /*Q16*/ BREAK; case 640: - edct_table = edct_table_320_fx; + edct_table = edct_table_320_fx; /*Q16*/ BREAK; case 320: - edct_table = edct_table_160_fx; + edct_table = edct_table_160_fx; /*Q16*/ BREAK; case 256: - edct_table = edct_table_128_fx; + edct_table = edct_table_128_fx; /*Q16*/ BREAK; case 240: - edct_table = edct_table_120_fx; + edct_table = edct_table_120_fx; /*Q16*/ BREAK; case 200: - edct_table = edct_table_100_fx; + edct_table = edct_table_100_fx; /*Q16*/ BREAK; case 160: - edct_table = edct_table_80_fx; + edct_table = edct_table_80_fx; /*Q16*/ BREAK; case 40: - edct_table = edct_table_20_fx; + edct_table = edct_table_20_fx; /*Q16*/ BREAK; case 800: - edct_table = edct_table_400_fx; + edct_table = edct_table_400_fx; /*Q17*/ *q = add( *q, 2 ); move16(); BREAK; case 512: - edct_table = edct_table_256_fx; + edct_table = edct_table_256_fx; /*Q16*/ BREAK; case 480: - edct_table = edct_table_240_fx; + edct_table = edct_table_240_fx; /*Q16*/ BREAK; case 400: - edct_table = edct_table_200_fx; + edct_table = edct_table_200_fx; /*Q16*/ BREAK; case 128: - edct_table = edct_table_64_fx; + edct_table = edct_table_64_fx; /*Q16*/ BREAK; case 80: - edct_table = edct_table_40_fx; + edct_table = edct_table_40_fx; /*Q16*/ BREAK; default: BREAK; @@ -180,7 +180,7 @@ static Word16 const *get_edct_table( Word16 length, Word16 *q ) void edct_fx( const Word32 *x, /* i : input signal Qq */ Word32 *y, /* o : output transform Qq */ - Word16 length, /* i : length */ + Word16 length, /* i : length Q0*/ Word16 *q /* i : Q value of input signal */ ) { @@ -193,18 +193,18 @@ void edct_fx( Word16 tmp; Word16 len1; - edct_table = get_edct_table( length, q ); - len1 = shr( length, 1 ); + edct_table = get_edct_table( length, q ); /*q*/ + len1 = shr( length, 1 ); /*Q0*/ /* Twiddling and Pre-rotate */ FOR( i = 0; i < len1; i++ ) { - L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Q(q+1) */ - complex_buf[2 * i] = Madd_32_16( L_tmp, x[sub( length, add( 1, shl( i, 1 ) ) )], edct_table[sub( len1, add( 1, i ) )] ); /*Q(q+1) */ + L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Q(q+1) */ + complex_buf[2 * i] = Madd_32_16( L_tmp, x[( length - ( 1 + ( i * 2 ) ) )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */ move32(); - L_tmp = Mult_32_16( x[sub( length, add( 1, shl( i, 1 ) ) )], edct_table[i] ); /*Q(q+1) */ + L_tmp = Mult_32_16( x[( length - ( 1 + ( i * 2 ) ) )], edct_table[i] ); /*Q(q+1) */ - complex_buf[add( shl( i, 1 ), 1 )] = Msub_32_16( L_tmp, x[shl( i, 1 )], edct_table[sub( len1, add( 1, i ) )] ); /*Q(q+1) */ + complex_buf[( ( i * 2 ) + 1 )] = Msub_32_16( L_tmp, x[( i * 2 )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */ move32(); } @@ -212,15 +212,15 @@ void edct_fx( move16(); BASOP_cfft( (cmplx *) complex_buf, len1, q, y ); - tmp = div_s( 1, length ); /*Q15 */ - tmp = round_fx( L_shl( L_mult( tmp, 19302 ), 2 ) ); /*Q15 */ + tmp = div_s( 1, length ); /*Q15 */ + tmp = round_fx( L_shl( L_mult( tmp, 19302 /*0.75f * EVS_PI in Q13*/ ), 2 ) ); /*Q15 */ FOR( i = 0; i < len1; i++ ) { - re = Msub_32_16( complex_buf[2 * i], complex_buf[add( shl( i, 1 ), 1 )], tmp ); - im = Madd_32_16( complex_buf[add( shl( i, 1 ), 1 )], complex_buf[2 * i], tmp ); - y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[sub( len1, add( 1, i ) )] ) ); + re = Msub_32_16( complex_buf[2 * i], complex_buf[( ( i * 2 ) + 1 )], tmp ); /*Q(q+1) */ + im = Madd_32_16( complex_buf[( ( i * 2 ) + 1 )], complex_buf[2 * i], tmp ); /*Q(q+1) */ + y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[( len1 - ( 1 + i ) )] ) ); /*Q(q+2)*/ move32(); - y[sub( length, add( 1, shl( i, 1 ) ) )] = L_sub( Mult_32_16( re, edct_table[sub( len1, add( 1, i ) )] ), Mult_32_16( im, edct_table[i] ) ); + y[( length - ( 1 + ( i * 2 ) ) )] = L_sub( Mult_32_16( re, edct_table[( len1 - ( 1 + i ) )] ), Mult_32_16( im, edct_table[i] ) ); /*Q(q+2)*/ move32(); } /*Q(q-2) */ @@ -258,17 +258,17 @@ void edst_fx( Word16 tmp; Word16 len1; - edct_table = get_edct_table( length, q ); - len1 = shr( length, 1 ); + edct_table = get_edct_table( length, q ); /*q*/ + len1 = shr( length, 1 ); /*Q0*/ /* Twiddling and Pre-rotate */ FOR( i = 0; i < len1; i++ ) { - L_tmp = Mult_32_16( x[sub( length, add( 1, shl( i, 1 ) ) )], edct_table[i] ); - complex_buf[2 * i] = Madd_32_16( L_tmp, x[2 * i], edct_table[sub( len1, add( 1, i ) )] ); + L_tmp = Mult_32_16( x[( length - ( 1 + ( i * 2 ) ) )], edct_table[i] ); /*Qq+1*/ + complex_buf[2 * i] = Madd_32_16( L_tmp, x[2 * i], edct_table[( len1 - ( 1 + i ) )] ); /*Qq+1*/ move32(); - L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); - complex_buf[add( shl( i, 1 ), 1 )] = Msub_32_16( L_tmp, x[sub( length, add( 1, shl( i, 1 ) ) )], edct_table[sub( len1, add( 1, i ) )] ); + L_tmp = Mult_32_16( x[2 * i], edct_table[i] ); /*Qq+1*/ + complex_buf[( ( i * 2 ) + 1 )] = Msub_32_16( L_tmp, x[( length - ( 1 + ( i * 2 ) ) )], edct_table[( len1 - ( 1 + i ) )] ); /*Qq+1*/ move32(); } @@ -276,15 +276,15 @@ void edst_fx( move16(); BASOP_cfft( (cmplx *) complex_buf, len1, q, y ); - tmp = div_s( 1, length ); /*Q15 */ - tmp = round_fx( L_shl( L_mult( tmp, 19302 ), 2 ) ); /*Q15 */ + tmp = div_s( 1, length ); /*Q15 */ + tmp = round_fx( L_shl( L_mult( tmp, 19302 /*0.75f * EVS_PI in Q13*/ ), 2 ) ); /*Q15 */ FOR( i = 0; i < len1; i++ ) { - re = Msub_32_16( complex_buf[2 * i], complex_buf[add( shl( i, 1 ), 1 )], tmp ); - im = Madd_32_16( complex_buf[add( shl( i, 1 ), 1 )], complex_buf[2 * i], tmp ); - y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[sub( len1, add( 1, i ) )] ) ); + re = Msub_32_16( complex_buf[2 * i], complex_buf[( ( i * 2 ) + 1 )], tmp ); /*Qq+1*/ + im = Madd_32_16( complex_buf[( ( i * 2 ) + 1 )], complex_buf[2 * i], tmp ); /*Qq+1*/ + y[2 * i] = L_add( Mult_32_16( re, edct_table[i] ), Mult_32_16( im, edct_table[( len1 - ( 1 + i ) )] ) ); /*Qq+2*/ move32(); - y[sub( length, add( 1, shl( i, 1 ) ) )] = L_sub( Mult_32_16( im, edct_table[i] ), Mult_32_16( re, edct_table[sub( len1, add( 1, i ) )] ) ); + y[( length - ( 1 + ( i * 2 ) ) )] = L_sub( Mult_32_16( im, edct_table[i] ), Mult_32_16( re, edct_table[( len1 - ( 1 + i ) )] ) ); /*Qq+2*/ move32(); } /*Q(q) */ @@ -347,15 +347,15 @@ void edct_16fx( IF( EQ_16( length, L_FRAME32k ) ) { - edct_table = &edct_table_320_16fx[0]; + edct_table = &edct_table_320_16fx[0]; /*Q15*/ } ELSE IF( EQ_16( length, L_FRAME ) ) { - edct_table = &edct_table_128_16fx[0]; + edct_table = &edct_table_128_16fx[0]; /*Q15*/ } ELSE IF( EQ_16( length, L_FRAME16k ) ) { - edct_table = &edct_table_160_16fx[0]; + edct_table = &edct_table_160_16fx[0]; /*Q15*/ } ELSE { @@ -364,8 +364,8 @@ void edct_16fx( /* Twiddling and Pre-rotate */ Lmax = L_deposit_l( 0 ); Len2 = shr( length, 1 ); - px = x + sub( length, 1 ); - pt = edct_table + sub( Len2, 1 ); + px = x + sub( length, 1 ); /*Qx*/ + pt = edct_table + sub( Len2, 1 ); /*Q16*/ FOR( i = 0; i < Len2; i++ ) { i2 = shl( i, 1 ); @@ -391,8 +391,8 @@ void edct_16fx( } Q_edct = sub( tmp, bh ); /*creating a bit-headroom */ - px = x + sub( length, 1 ); - pt = edct_table + sub( Len2, 1 ); + px = x + sub( length, 1 ); /*Qx*/ + pt = edct_table + sub( Len2, 1 ); /*Q15*/ FOR( i = 0; i < Len2; i++ ) { i2 = shl( i, 1 ); @@ -458,8 +458,8 @@ void edct_16fx( } /* Post-rotate and obtain the output data */ - py = y + sub( length, 1 ); - pt = edct_table + sub( Len2, 1 ); + py = y + sub( length, 1 ); /*Qx*/ + pt = edct_table + sub( Len2, 1 ); /*Q15*/ FOR( i = 0; i < Len2; i++ ) { i2 = shl( i, 1 ); @@ -497,10 +497,10 @@ void edct_16fx( *-----------------------------------------------------------------*/ void iedct_short_fx( - const Word32 *in, /* i : input vector */ + const Word32 *in, /* i : input vector Q*/ Word16 *Q, /* i/o: Q value of input */ - Word32 *out, /* o : output vector */ - const Word16 segment_length /* i : length */ + Word32 *out, /* o : output vector Q*/ + const Word16 segment_length /* i : length Q0*/ ) { Word32 alias[MAX_SEGMENT_LENGTH]; @@ -512,8 +512,8 @@ void iedct_short_fx( move16(); tmp = 0; move16(); - seg_len_div2 = shr( segment_length, 1 ); - seg_len_div4 = shr( segment_length, 2 ); + seg_len_div2 = shr( segment_length, 1 ); /*Q0*/ + seg_len_div4 = shr( segment_length, 2 ); /*Q0*/ seg_len_3mul_div4 = add( seg_len_div2, seg_len_div4 ); edct_fx( in, alias, seg_len_div2, Q ); @@ -533,13 +533,13 @@ void iedct_short_fx( } FOR( i = 0; i < seg_len_div4; i++ ) { - out[i] = alias[add( seg_len_div4, i )]; + out[i] = alias[( seg_len_div4 + i )]; /*Q*/ move32(); - out[add( seg_len_div4, i )] = L_negate( alias[sub( sub( seg_len_div2, 1 ), i )] ); + out[( seg_len_div4 + i )] = L_negate( alias[( ( seg_len_div2 - 1 ) - i )] ); /*Q*/ move32(); - out[add( seg_len_div2, i )] = L_negate( alias[sub( sub( seg_len_div4, 1 ), i )] ); + out[( seg_len_div2 + i )] = L_negate( alias[( ( seg_len_div4 - 1 ) - i )] ); /*Q*/ move32(); - out[add( seg_len_3mul_div4, i )] = L_negate( alias[i] ); + out[( seg_len_3mul_div4 + i )] = L_negate( alias[i] ); /*Q*/ move32(); } @@ -554,11 +554,11 @@ void iedct_short_fx( *-------------------------------------------------------------------------*/ void edxt_fx( - const Word32 *x, /* i : input signal */ - Word32 *y, /* o : output transform */ - const Word16 length, /* i : length */ - const UWord16 kernelType, /* i : kernel type (0 - 3) */ - const UWord16 synthesis /* i : nonzero for inverse */ + const Word32 *x, /* i : input signal Qx*/ + Word32 *y, /* o : output transform Qx*/ + const Word16 length, /* i : length Q0*/ + const UWord16 kernelType, /* i : kernel type (0 - 3) Q0*/ + const UWord16 synthesis /* i : nonzero for inverse Q0*/ ) { Word16 k, m, fac; @@ -570,113 +570,113 @@ void edxt_fx( sinPtr = NULL; IF( EQ_16( length, 512 ) ) { - cosPtr = cos_scale_tbl_512; - sinPtr = sin_scale_tbl_512; + cosPtr = cos_scale_tbl_512; /*Q15*/ + sinPtr = sin_scale_tbl_512; /*Q15*/ n = 1; move16(); } ELSE IF( EQ_16( length, 256 ) ) { - cosPtr = cos_scale_tbl_512; - sinPtr = sin_scale_tbl_512; + cosPtr = cos_scale_tbl_512; /*Q15*/ + sinPtr = sin_scale_tbl_512; /*Q15*/ n = 2; move16(); } ELSE IF( EQ_16( length, 128 ) ) { - cosPtr = cos_scale_tbl_512; - sinPtr = sin_scale_tbl_512; + cosPtr = cos_scale_tbl_512; /*Q15*/ + sinPtr = sin_scale_tbl_512; /*Q15*/ n = 4; move16(); } ELSE IF( EQ_16( length, 640 ) ) { - cosPtr = cos_scale_tbl_640; - sinPtr = sin_scale_tbl_640; + cosPtr = cos_scale_tbl_640; /*Q15*/ + sinPtr = sin_scale_tbl_640; /*Q15*/ n = 1; move16(); } ELSE IF( EQ_16( length, 320 ) ) { - cosPtr = cos_scale_tbl_640; - sinPtr = sin_scale_tbl_640; + cosPtr = cos_scale_tbl_640; /*Q15*/ + sinPtr = sin_scale_tbl_640; /*Q15*/ n = 2; move16(); } ELSE IF( EQ_16( length, 160 ) ) { - cosPtr = cos_scale_tbl_640; - sinPtr = sin_scale_tbl_640; + cosPtr = cos_scale_tbl_640; /*Q15*/ + sinPtr = sin_scale_tbl_640; /*Q15*/ n = 4; move16(); } ELSE IF( EQ_16( length, 80 ) ) { - cosPtr = cos_scale_tbl_640; - sinPtr = sin_scale_tbl_640; + cosPtr = cos_scale_tbl_640; /*Q15*/ + sinPtr = sin_scale_tbl_640; /*Q15*/ n = 8; move16(); } ELSE IF( EQ_16( length, 40 ) ) { - cosPtr = cos_scale_tbl_640; - sinPtr = sin_scale_tbl_640; + cosPtr = cos_scale_tbl_640; /*Q15*/ + sinPtr = sin_scale_tbl_640; /*Q15*/ n = 16; move16(); } ELSE IF( EQ_16( length, 960 ) ) { - cosPtr = cos_scale_tbl_960; - sinPtr = sin_scale_tbl_960; + cosPtr = cos_scale_tbl_960; /*Q15*/ + sinPtr = sin_scale_tbl_960; /*Q15*/ n = 1; move16(); } ELSE IF( EQ_16( length, 480 ) ) { - cosPtr = cos_scale_tbl_960; - sinPtr = sin_scale_tbl_960; + cosPtr = cos_scale_tbl_960; /*Q15*/ + sinPtr = sin_scale_tbl_960; /*Q15*/ n = 2; move16(); } ELSE IF( EQ_16( length, 240 ) ) { - cosPtr = cos_scale_tbl_960; - sinPtr = sin_scale_tbl_960; + cosPtr = cos_scale_tbl_960; /*Q15*/ + sinPtr = sin_scale_tbl_960; /*Q15*/ n = 4; move16(); } ELSE IF( EQ_16( length, 120 ) ) { - cosPtr = cos_scale_tbl_960; - sinPtr = sin_scale_tbl_960; + cosPtr = cos_scale_tbl_960; /*Q15*/ + sinPtr = sin_scale_tbl_960; /*Q15*/ n = 8; move16(); } ELSE IF( EQ_16( length, 1200 ) ) { - cosPtr = cos_scale_tbl_1200; - sinPtr = sin_scale_tbl_1200; + cosPtr = cos_scale_tbl_1200; /*Q15*/ + sinPtr = sin_scale_tbl_1200; /*Q15*/ n = 1; move16(); } ELSE IF( EQ_16( length, 800 ) ) { - cosPtr = cos_scale_tbl_800; - sinPtr = sin_scale_tbl_800; + cosPtr = cos_scale_tbl_800; /*Q15*/ + sinPtr = sin_scale_tbl_800; /*Q15*/ n = 1; move16(); } ELSE IF( EQ_16( length, 400 ) ) { - cosPtr = cos_scale_tbl_800; - sinPtr = sin_scale_tbl_800; + cosPtr = cos_scale_tbl_800; /*Q15*/ + sinPtr = sin_scale_tbl_800; /*Q15*/ n = 2; move16(); } ELSE IF( EQ_16( length, 200 ) ) { - cosPtr = cos_scale_tbl_800; - sinPtr = sin_scale_tbl_800; + cosPtr = cos_scale_tbl_800; /*Q15*/ + sinPtr = sin_scale_tbl_800; /*Q15*/ n = 4; move16(); } @@ -686,17 +686,17 @@ void edxt_fx( IF( EQ_16( kernelType, MDST_II ) || EQ_16( kernelType, MDCT_II ) ) { const Word16 Nm1 = sub( length, 1 ); - const Word16 xSign = sub( imult1616( 2, shr( kernelType, 1 ) ), 1 ); + const Word16 xSign = sub( imult1616( 2, shr( kernelType, 1 ) ), 1 ); /*Q0*/ Word32 re[L_FRAME_PLUS]; Word32 im[L_FRAME_PLUS]; IF( !synthesis ) { - FOR( k = shr( Nm1, 1 ); k >= 0; k-- ) /* pre-modulation of audio input */ + FOR( k = ( Nm1 / 2 ); k >= 0; k-- ) /* pre-modulation of audio input */ { - re[k] = x[2 * k]; - re[sub( Nm1, k )] = Mpy_32_16_1( x[add( shl( k, 1 ), 1 )], shl_sat( xSign, 15 ) ); - im[k] = im[sub( Nm1, k )] = 0; + re[k] = x[2 * k]; /*Qx*/ + re[( Nm1 - k )] = Mpy_32_16_1( x[( ( k * 2 ) + 1 )], shl_sat( xSign, 15 ) ); /*Qx*/ + im[k] = im[( Nm1 - k )] = 0; move32(); move32(); move32(); @@ -713,87 +713,87 @@ void edxt_fx( IF( shr( kernelType, 1 ) ) { - FOR( k = shr( Nm1, 1 ); k > 0; k-- ) + FOR( k = ( Nm1 / 2 ); k > 0; k-- ) { // const float wRe = cosf( scale * k ); // const float wIm = sinf( scale * k ); - const Word16 wRe = cosPtr[imult1616( k, n )]; - const Word16 wIm = sinPtr[imult1616( k, n )]; + const Word16 wRe = cosPtr[( k * n )]; /*Q15*/ + const Word16 wIm = sinPtr[( k * n )]; /*Q15*/ - y[k] /*pt 1*/ = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) ); - y[sub( length, k )] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) ); + y[k] /*pt 1*/ = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) ); /*Qx*/ + y[( length - k )] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) ); /*Qx*/ move32(); move32(); } - y[shr( length, 1 )] = Mpy_32_16_1( re[shr( length, 1 )], INV_SQRT_2_Q15 ); + y[( length / 2 )] = Mpy_32_16_1( re[( length / 2 )], INV_SQRT_2_Q15 ); /*Qx*/ move32(); } ELSE /* forw. DST-II */ { - FOR( k = shr( Nm1, 1 ); k > 0; k-- ) + FOR( k = ( Nm1 / 2 ); k > 0; k-- ) { // const float wRe = cosf( scale * k ); // const float wIm = sinf( scale * k ); - const Word16 wRe = cosPtr[imult1616( k, n )]; - const Word16 wIm = sinPtr[imult1616( k, n )]; + const Word16 wRe = cosPtr[( k * n )]; /*Q15*/ + const Word16 wIm = sinPtr[( k * n )]; /*Q15*/ - y[sub( Nm1, k )] = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) ); - y[k - 1] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) ); + y[( Nm1 - k )] = L_add( Mpy_32_16_1( re[k], wRe ), Mpy_32_16_1( im[k], wIm ) ); /*Qx*/ + y[k - 1] = L_sub( Mpy_32_16_1( re[k], wIm ), Mpy_32_16_1( im[k], wRe ) ); /*Qx*/ move32(); move32(); } - y[shr( Nm1, 1 )] = Mpy_32_16_1( re[shr( length, 1 )], INV_SQRT_2_Q15 ); + y[( Nm1 / 2 )] = Mpy_32_16_1( re[( length / 2 )], INV_SQRT_2_Q15 ); /*Qx*/ move32(); } - y[sub( Nm1, imult1616( Nm1, shr( kernelType, 1 ) ) )] = L_shr( re[0], 1 ); + y[( Nm1 - ( Nm1 * ( kernelType / 2 ) ) )] = L_shr( re[0], 1 ); /*Qx*/ move32(); } ELSE /* inverse II = III */ { IF( shr( kernelType, 1 ) ) { - FOR( k = shr( Nm1, 1 ); k > 0; k-- ) + FOR( k = ( Nm1 / 2 ); k > 0; k-- ) { // const float wRe = cosf( scale * k ) * 0.5f; // const float wIm = sinf( scale * k ) * 0.5f; const Word16 wRe = shr( cosPtr[imult1616( k, n )], 1 ); const Word16 wIm = shr( sinPtr[imult1616( k, n )], 1 ); - re[k] = L_add( Mpy_32_16_1( x[k], wRe ), Mpy_32_16_1( x[sub( length, k )], wIm ) ); - im[k] = L_sub( Mpy_32_16_1( x[sub( length, k )], wRe ), Mpy_32_16_1( x[k], wIm ) ); + re[k] = L_add( Mpy_32_16_1( x[k], wRe ), Mpy_32_16_1( x[( length - k )], wIm ) ); /*Qx*/ + im[k] = L_sub( Mpy_32_16_1( x[( length - k )], wRe ), Mpy_32_16_1( x[k], wIm ) ); /*Qx*/ move32(); move32(); } - re[shr( length, 1 )] = Mpy_32_16_1( x[shr( length, 1 )], INV_SQRT_2_Q15 ); + re[( length / 2 )] = Mpy_32_16_1( x[( length / 2 )], INV_SQRT_2_Q15 ); /*Qx*/ move32(); } ELSE /* DST type III */ { - FOR( k = shr( Nm1, 1 ); k > 0; k-- ) + FOR( k = ( Nm1 / 2 ); k > 0; k-- ) { // const float wRe = cosf( scale * k ) * 0.5f; // const float wIm = sinf( scale * k ) * 0.5f; - const Word16 wRe = shr( cosPtr[imult1616( k, n )], 1 ); - const Word16 wIm = shr( sinPtr[imult1616( k, n )], 1 ); + const Word16 wRe = shr( cosPtr[( k * n )], 1 ); /*Q15*/ + const Word16 wIm = shr( sinPtr[( k * n )], 1 ); /*Q15*/ - re[k] = L_add( Mpy_32_16_1( x[sub( Nm1, k )], wRe ), Mpy_32_16_1( x[sub( k, 1 )], wIm ) ); - im[k] = L_sub( Mpy_32_16_1( x[sub( k, 1 )], wRe ), Mpy_32_16_1( x[sub( Nm1, k )], wIm ) ); + re[k] = L_add( Mpy_32_16_1( x[( Nm1 - k )], wRe ), Mpy_32_16_1( x[( k - 1 )], wIm ) ); /*Qx*/ + im[k] = L_sub( Mpy_32_16_1( x[( k - 1 )], wRe ), Mpy_32_16_1( x[( Nm1 - k )], wIm ) ); /*Qx*/ move32(); move32(); } - re[shr( length, 1 )] = Mpy_32_16_1( x[shr( Nm1, 1 )], INV_SQRT_2_Q15 ); + re[( length / 2 )] = Mpy_32_16_1( x[( Nm1 / 2 )], INV_SQRT_2_Q15 ); /*Qx*/ move32(); } - re[0] = x[sub( Nm1, imult1616( Nm1, shr( kernelType, 1 ) ) )]; - im[0] = im[shr( length, 1 )] = 0; + re[0] = x[( Nm1 - ( Nm1 * ( kernelType / 2 ) ) )]; /*Qx*/ + im[0] = im[( length / 2 )] = 0; move32(); move32(); - FOR( k = shr( Nm1, 1 ); k > 0; k-- ) + FOR( k = ( Nm1 / 2 ); k > 0; k-- ) { - re[sub( length, k )] = re[k]; - im[sub( length, k )] = L_negate( im[k] ); + re[( length - k )] = re[k]; /*Qx*/ + im[( length - k )] = L_negate( im[k] ); /*Qx*/ move32(); move32(); } @@ -807,17 +807,17 @@ void edxt_fx( fft_fx( re, im, length, 1 ); } - FOR( k = shr( Nm1, 1 ); k >= 0; k-- ) /* post-modulation of FFT output */ + FOR( k = ( Nm1 / 2 ); k >= 0; k-- ) /* post-modulation of FFT output */ { - y[2 * k] = re[k]; + y[2 * k] = re[k]; /*Qx*/ move32(); IF( xSign != 0 ) { - y[add( shl( k, 1 ), 1 )] = Mpy_32_16_1( re[sub( Nm1, k )], shl_sat( xSign, 15 ) ); + y[( ( k * 2 ) + 1 )] = Mpy_32_16_1( re[( Nm1 - k )], shl_sat( xSign, 15 ) ); /*Qx*/ } ELSE { - y[add( shl( k, 1 ), 1 )] = 0; + y[( ( k * 2 ) + 1 )] = 0; /*Qx*/ } move32(); } @@ -873,7 +873,7 @@ void edxt_fx( FOR( m = 0; m < length; m++ ) { - y[m] = Mpy_32_16_1( y[m], fac ); + y[m] = Mpy_32_16_1( y[m], fac ); /*Qx*/ move32(); } return; diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index 350391c26b92b89457e41f707d8a19ed28ded48a..91750b486303de20d195fb9a06c576ef660fdf64 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -117,7 +117,11 @@ void initFdCngCom_flt( hFdCngCom->active_frame_counter = 0; hFdCngCom->frame_type_previous = ACTIVE_FRAME; hFdCngCom->flag_noisy_speech = 0; +#ifndef IVAS_FLOAT_FIXED hFdCngCom->likelihood_noisy_speech_flt = 0.f; +#else + hFdCngCom->likelihood_noisy_speech = 0; +#endif hFdCngCom->numCoreBands = 0; hFdCngCom->stopBand = 0; hFdCngCom->startBand = 0; diff --git a/lib_com/igf_base.c b/lib_com/igf_base.c index adad4c47c2b29b458c4a2d889a1020cc66f6d82d..5aa8e8c3fd28751c47bfeef3ef62a0138381974f 100644 --- a/lib_com/igf_base.c +++ b/lib_com/igf_base.c @@ -41,6 +41,7 @@ #include "rom_com.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * IGF_ApplyTransFac_flt() * @@ -63,6 +64,7 @@ int16_t IGF_ApplyTransFac_flt( return ret; } +#endif /*---------------------------------------------------------------------* @@ -357,6 +359,7 @@ int16_t IGF_MapBitRateToIndex_flt( return bitRateIndex; } +#ifndef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * IGF_gridSetUp_flt() * @@ -567,6 +570,7 @@ int16_t IGFCommonFuncsIGFConfiguration_flt( return retValue; } +#endif /*---------------------------------------------------------------------* diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index d871ebe6d5581bfe51aab0d9a7ad906106201802..f170bada1045f2b7fddc7c96410fd94f7599ffe6 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -1070,6 +1070,7 @@ float ism_dequant_meta( * * ---------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_param_ism_config( PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i/o: IVAS Param ISM Config Structure */ const int16_t nchan_obj /* i : number of ISM channels */ @@ -1098,8 +1099,7 @@ void ivas_param_ism_config( return; } - -#ifdef IVAS_FLOAT_FIXED +#else 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 */ @@ -1129,15 +1129,11 @@ void ivas_param_ism_config_fx( move16(); } - hParamIsm->last_dmx_gain_fx = (Word16) 16384; // Q15-last_dmx_gain_e + hParamIsm->last_dmx_gain_fx = (Word16) 16384; // 15-1 = Q14 move16(); hParamIsm->last_dmx_gain_e = 1; move16(); - set16_fx( hParamIsm->last_cardioid_left_fx, (Word16) 16384, MAX_NUM_OBJECTS ); -#if 1 // TODO: To be removed later - hParamIsm->last_dmx_gain = 1.0f; - set_f( hParamIsm->last_cardioid_left, 1.0f, MAX_NUM_OBJECTS ); -#endif + set16_fx( hParamIsm->last_cardioid_left_fx, (Word16) 16384, MAX_NUM_OBJECTS ); // Q14 return; } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6dc3b8f552d224148ae362539e28d7c688f8938a..d845d877857febf75ffb09eb677b328a7c96a584 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1218,12 +1218,12 @@ void ivas_param_ism_stereo_dmx( float *data[MAX_NUM_OBJECTS], /* i/o: input signal/stereo dmx */ const int16_t input_frame /* i : Length of input frame */ ); -#endif void ivas_param_ism_config( PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i/o: IVAS Param ISM Config Structure */ const int16_t nchan_ism /* i : number of ISM channels */ ); +#endif ivas_error ivas_ism_enc_config( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ @@ -1343,23 +1343,27 @@ void ivas_ism_metadata_sid_dec( int16_t nb_bits_metadata[] /* o : number of metadata bits */ ); +#ifndef IVAS_FLOAT_FIXED void ivas_ism_get_sce_id_dtx( ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */ const int16_t nchan_transport, /* i : number of transport channels */ const int16_t input_frame /* i : input frame length per channel */ ); +#endif void ivas_param_ism_compute_noisy_speech_flag( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); +#ifndef IVAS_FLOAT_FIXED void ivas_ism_coh_estim_dtx_enc( ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */ const int16_t nchan_transport, /* i : number of transport channels */ const int16_t input_frame /* i : input frame length */ ); +#endif void update_last_metadata( const int16_t nchan_ism, /* i : number of objects */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 348fc2ebe15bc27471f411aba0baf900189eb8af..5d1a5137aecce5fa83f88949e65e6b2290164184 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2872,6 +2872,10 @@ Word16 quantize_sns_fx( Word16 *zero_side_flag, /* Q0 */ Word16 *sns_stereo_mode ); /* Q0 */ +void stereo_enc_cng_init_fx( + STEREO_CNG_ENC_HANDLE hStereoCng /* i/o: stereo CNG encoder structure */ +); + void stereo_cng_upd_counters_fx( STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ const Word32 element_mode, /* i : element mode */ @@ -5447,6 +5451,10 @@ void ivas_cov_smooth_process_fx( const Word16 transient_det[2], Word16 *q_cov[IVAS_SPAR_MAX_CH] ); +void ivas_pca_enc_init_fx( + PCA_ENC_STATE *hPCA /* i/o: PCA encoder structure */ +); + void ivas_pca_enc_fx( const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ PCA_ENC_STATE *hPCA, /* i : PCA encoder structure */ diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index d6dd690fbca436e822398090c17810976f5791bc..d306ed04c175c099f42410096f51e8ef08db11b0 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -349,22 +349,23 @@ typedef struct ivas_huff_coeffs_t /* AGC structures */ typedef struct ivas_agc_chan_data_t { - int16_t absGainExp; - int16_t absGainExpCurr; + Word16 absGainExp; + Word16 absGainExpCurr; } ivas_agc_chan_data_t; typedef struct ivas_agc_com_state_t { +#ifndef IVAS_FLOAT_FIXED float *winFunc; -#ifdef IVAS_FLOAT_FIXED - Word16 *winFunc_fx; -#endif // IVAS_FLOAT_FIXED - int16_t in_delay; /* TODO: JBM check if this needs to be adjusted in the dec */ - uint16_t absEmin; - uint16_t betaE; - uint16_t maxAttExp; - uint16_t num_coeff; +#else + Word16 *winFunc_fx; /* Q15 */ +#endif + Word16 in_delay; /* TODO: JBM check if this needs to be adjusted in the dec */ + UWord16 absEmin; + UWord16 betaE; + UWord16 maxAttExp; + UWord16 num_coeff; } ivas_agc_com_state_t; @@ -841,7 +842,7 @@ typedef struct ivas_fb_bin_to_band_data_t typedef struct ivas_filterbank_t { - int16_t filterbank_num_bands; + Word16 filterbank_num_bands; ivas_fb_consts_t fb_consts; ivas_fb_bin_to_band_data_t fb_bin_to_band; @@ -851,7 +852,7 @@ typedef struct ivas_fb_mixer_state_structure { IVAS_FB_CFG *fb_cfg; - int16_t num_diff_bands; + Word16 num_diff_bands; ivas_filterbank_t *pFb; #ifndef IVAS_FLOAT_FIXED float *ppFilterbank_inFR_re[IVAS_MAX_FB_MIXER_IN_CH]; @@ -871,14 +872,14 @@ typedef struct ivas_fb_mixer_state_structure #endif /* store sin part in const table (no need to store 1s and 0s, no need to do windowing for 1's and 0's as well) */ - int16_t cross_fade_start_offset; - int16_t cross_fade_end_offset; + Word16 cross_fade_start_offset; + Word16 cross_fade_end_offset; const float *pFilterbank_cross_fade; - int16_t ana_window_offset; + Word16 ana_window_offset; const float *pAna_window; - int16_t prior_input_length; - int16_t windowed_fr_offset; + Word16 prior_input_length; + Word16 windowed_fr_offset; #ifdef IVAS_FLOAT_FIXED const Word16 *pFilterbank_cross_fade_fx; Word16 cldfb_cross_fade_fx[CLDFB_NO_COL_MAX]; @@ -887,10 +888,10 @@ typedef struct ivas_fb_mixer_state_structure #else float cldfb_cross_fade[CLDFB_NO_COL_MAX]; #endif // IVAS_FLOAT_FIXED - int16_t cldfb_cross_fade_start; - int16_t cldfb_cross_fade_end; + Word16 cldfb_cross_fade_start; + Word16 cldfb_cross_fade_end; - int16_t first_frame[IVAS_SPAR_MAX_CH]; + Word16 first_frame[IVAS_SPAR_MAX_CH]; } IVAS_FB_MIXER_DATA, *IVAS_FB_MIXER_HANDLE; @@ -903,27 +904,29 @@ typedef struct ivas_param_ism_data_structure { IVAS_FB_MIXER_HANDLE hFbMixer; - int16_t nbands; - int16_t nblocks[MAX_PARAM_ISM_NBANDS]; - int16_t band_grouping[MAX_PARAM_ISM_NBANDS + 1]; + Word16 nbands; + Word16 nblocks[MAX_PARAM_ISM_NBANDS]; + Word16 band_grouping[MAX_PARAM_ISM_NBANDS + 1]; - int16_t azi_index[MAX_NUM_OBJECTS]; - int16_t ele_index[MAX_NUM_OBJECTS]; + Word16 azi_index[MAX_NUM_OBJECTS]; + Word16 ele_index[MAX_NUM_OBJECTS]; - int16_t obj_indices[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE]; - int16_t power_ratios_idx[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS]; + Word16 obj_indices[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS][MAX_PARAM_ISM_WAVE]; + Word16 power_ratios_idx[MAX_PARAM_ISM_NBANDS][MAX_PARAM_ISM_NBLOCKS]; - int16_t last_az_sgn[MAX_NUM_OBJECTS]; - int16_t last_az_diff[MAX_NUM_OBJECTS]; - int16_t last_el_sgn[MAX_NUM_OBJECTS]; - int16_t last_el_diff[MAX_NUM_OBJECTS]; + Word16 last_az_sgn[MAX_NUM_OBJECTS]; + Word16 last_az_diff[MAX_NUM_OBJECTS]; + Word16 last_el_sgn[MAX_NUM_OBJECTS]; + Word16 last_el_diff[MAX_NUM_OBJECTS]; - int16_t flag_noisy_speech; - int16_t noisy_speech_buffer[PARAM_ISM_HYS_BUF_SIZE]; - int16_t flag_equal_energy; + Word16 flag_noisy_speech; + Word16 noisy_speech_buffer[PARAM_ISM_HYS_BUF_SIZE]; + Word16 flag_equal_energy; +#ifndef IVAS_FLOAT_FIXED float last_dmx_gain; float last_cardioid_left[MAX_NUM_OBJECTS]; +#endif Word16 last_dmx_gain_fx; Word16 last_dmx_gain_e; diff --git a/lib_com/ivas_stereo_mdct_bands_com.c b/lib_com/ivas_stereo_mdct_bands_com.c index ab2357d24b1cc7173e90b7e42ed08a9674f8404d..903f7adee311901e167b2542f6ebae10f22cb208 100644 --- a/lib_com/ivas_stereo_mdct_bands_com.c +++ b/lib_com/ivas_stereo_mdct_bands_com.c @@ -67,13 +67,13 @@ typedef union #ifdef IVAS_FLOAT_FIXED void stereo_mdct_init_bands_fx( - const Word16 L_frame, /* i : frame length */ - const Word16 tmp_tcx_mode, /* i : tcx mode (TCX10, TCX 20), -1 if transition frame */ - const Word32 element_brate, /* i : element bitrate */ - const Word16 igf, /* i : flag indicating if IGF is used */ + const Word16 L_frame, /* i : frame length Q0*/ + const Word16 tmp_tcx_mode, /* i : tcx mode (TCX10, TCX 20), -1 if transition frame Q0*/ + const Word32 element_brate, /* i : element bitrate Q0*/ + const Word16 igf, /* i : flag indicating if IGF is used Q0*/ const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */ - Word16 *sfbOffset, /* o : sfb offset table */ - Word16 *sfbCnt /* o : number of sfbs */ + Word16 *sfbOffset, /* o : sfb offset table Q0*/ + Word16 *sfbCnt /* o : number of sfbs Q0*/ ) { SBPARAMS sfbParam; @@ -82,24 +82,24 @@ void stereo_mdct_init_bands_fx( IF( tmp_tcx_mode > 0 ) { - tcx_mode = tmp_tcx_mode; + tcx_mode = tmp_tcx_mode; /*Q0*/ move16(); IF( EQ_16( tcx_mode, TCX_20_CORE ) ) { - L_frameTCX = L_frame; + L_frameTCX = L_frame; /*Q0*/ move16(); } ELSE { - L_frameTCX = shr( L_frame, 1 ); + L_frameTCX = shr( L_frame, 1 ); /*Q0*/ move16(); } } ELSE { /*transition frame*/ - L_frameTCX = add( L_frame, shr( L_frame, 2 ) ); + L_frameTCX = add( L_frame, shr( L_frame, 2 ) ); /*Q0*/ tcx_mode = TCX_20_CORE; move16(); } @@ -111,23 +111,23 @@ void stereo_mdct_init_bands_fx( IF( EQ_16( tcx_mode, TCX_20_CORE ) ) { - cnt = sfbParam.steBands->bdnCnt_TCX20[0]; + cnt = sfbParam.steBands->bdnCnt_TCX20[0]; /*Q0*/ move16(); } ELSE { - cnt = sfbParam.steBands->bndCnt_TCX10[0]; + cnt = sfbParam.steBands->bndCnt_TCX10[0]; /*Q0*/ move16(); } IF( EQ_16( tcx_mode, TCX_20_CORE ) ) { - sfbWidths = sfbParam.steBands->bandLengthsTCX20; + sfbWidths = sfbParam.steBands->bandLengthsTCX20; /*Q0*/ move16(); } ELSE { - sfbWidths = sfbParam.steBands->bandLengthsTCX10; + sfbWidths = sfbParam.steBands->bandLengthsTCX10; /*Q0*/ move16(); } } @@ -142,36 +142,36 @@ void stereo_mdct_init_bands_fx( case L_FRAME32k: IF( EQ_16( tcx_mode, TCX_20_CORE ) ) { - cnt = sfbParam.steBands->bdnCnt_TCX20[1]; + cnt = sfbParam.steBands->bdnCnt_TCX20[1]; /*Q0*/ move16(); } ELSE { - cnt = sfbParam.steBands->bndCnt_TCX10[1]; + cnt = sfbParam.steBands->bndCnt_TCX10[1]; /*Q0*/ move16(); } BREAK; case L_FRAME25_6k: IF( EQ_16( tcx_mode, TCX_20_CORE ) ) { - cnt = sfbParam.steBands->bdnCnt_TCX20[2]; + cnt = sfbParam.steBands->bdnCnt_TCX20[2]; /*Q0*/ move16(); } ELSE { - cnt = sfbParam.steBands->bndCnt_TCX10[2]; + cnt = sfbParam.steBands->bndCnt_TCX10[2]; /*Q0*/ move16(); } BREAK; case L_FRAME16k: IF( EQ_16( tcx_mode, TCX_20_CORE ) ) { - cnt = sfbParam.steBands->bdnCnt_TCX20[3]; + cnt = sfbParam.steBands->bdnCnt_TCX20[3]; /*Q0*/ move16(); } ELSE { - cnt = sfbParam.steBands->bndCnt_TCX10[3]; + cnt = sfbParam.steBands->bndCnt_TCX10[3]; /*Q0*/ move16(); } move16(); @@ -183,12 +183,12 @@ void stereo_mdct_init_bands_fx( IF( EQ_16( tcx_mode, TCX_20_CORE ) ) { - sfbWidths = sfbParam.steBands->bandLengthsTCX20; + sfbWidths = sfbParam.steBands->bandLengthsTCX20; /*Q0*/ move16(); } ELSE { - sfbWidths = sfbParam.steBands->bandLengthsTCX10; + sfbWidths = sfbParam.steBands->bandLengthsTCX10; /*Q0*/ move16(); } } @@ -213,12 +213,12 @@ void stereo_mdct_init_bands_fx( IF( EQ_16( tcx_mode, TCX_20_CORE ) ) { - sfbWidths = sfbParam.lpcBndsParam->bandLengthsTCX20; + sfbWidths = sfbParam.lpcBndsParam->bandLengthsTCX20; /*Q0*/ move16(); } ELSE { - sfbWidths = sfbParam.lpcBndsParam->bandLengthsTCX10; + sfbWidths = sfbParam.lpcBndsParam->bandLengthsTCX10; /*Q0*/ move16(); } cnt = 64; @@ -232,9 +232,9 @@ void stereo_mdct_init_bands_fx( FOR( i = 0; i < cnt; i++ ) { - sfbOffset[i] = s_min( specStartOffset, L_frameTCX ); + sfbOffset[i] = s_min( specStartOffset, L_frameTCX ); /*Q0*/ move16(); - specStartOffset = add( specStartOffset, sfbWidths[i] ); + specStartOffset = add( specStartOffset, sfbWidths[i] ); /*Q0*/ IF( GE_16( sfbOffset[i], L_frameTCX ) ) { @@ -244,7 +244,7 @@ void stereo_mdct_init_bands_fx( *sfbCnt = i; move16(); - sfbOffset[*sfbCnt] = s_min( specStartOffset, L_frameTCX ); + sfbOffset[*sfbCnt] = s_min( specStartOffset, L_frameTCX ); /*Q0*/ move16(); IF( igf ) @@ -274,7 +274,7 @@ void stereo_mdct_init_bands_fx( IF( GE_16( sfbOffset[i], hIgfGrid->startLine ) ) { /* set band border to igf start line */ - sfbOffset[i] = hIgfGrid->startLine; + sfbOffset[i] = hIgfGrid->startLine; /*Q0*/ move16(); *sfbCnt = i; move16(); @@ -284,15 +284,15 @@ void stereo_mdct_init_bands_fx( /* change bands above the igf start line to match igf bands */ FOR( ( i = 1, k = igfSfbStep ); i < hIgfGrid->swb_offset_len; ( i++, k += igfSfbStep ) ) { - sfbOffset[add( *sfbCnt, i )] = hIgfGrid->swb_offset[k]; + sfbOffset[( *sfbCnt + i )] = hIgfGrid->swb_offset[k]; /*Q0*/ move16(); } - *sfbCnt = add( *sfbCnt, sub( hIgfGrid->swb_offset_len, 1 ) ); + *sfbCnt = add( *sfbCnt, sub( hIgfGrid->swb_offset_len, 1 ) ); /*Q0*/ move16(); /* better save than sorry, overwrite anything that is left above */ - FOR( i = add( *sfbCnt, 1 ); i < add( sfbOldCnt, 1 ); i++ ) + FOR( i = ( *sfbCnt + 1 ); i < ( sfbOldCnt + 1 ); i++ ) { sfbOffset[i] = 0; move16(); @@ -302,13 +302,13 @@ void stereo_mdct_init_bands_fx( { IF( LT_16( sfbOffset[*sfbCnt], L_frameTCX ) ) { - Word16 nMissingBins = sub( L_frameTCX, sfbOffset[*sfbCnt] ); + Word16 nMissingBins = sub( L_frameTCX, sfbOffset[*sfbCnt] ); /*Q0*/ IF( LT_16( shr( sfbWidths[i], 1 ), nMissingBins ) ) { *sfbCnt = add( *sfbCnt, 1 ); move16(); } - sfbOffset[*sfbCnt] = L_frameTCX; + sfbOffset[*sfbCnt] = L_frameTCX; /*Q0*/ move16(); } } @@ -474,17 +474,17 @@ void stereo_mdct_init_bands( #ifdef IVAS_FLOAT_FIXED void stereo_mdct_init_igf_start_band_fx( STEREO_MDCT_BAND_PARAMETERS *stbParams, /* i/o: stereo frequency band parameters */ - const Word16 transFac, /* i : transform factor */ - const Word16 bwidth, /* i : audio bandwidth */ - const Word32 element_brate /* i : element bitrate */ + const Word16 transFac, /* i : transform factor Q14*/ + const Word16 bwidth, /* i : audio bandwidth Q0*/ + const Word32 element_brate /* i : element bitrate Q0*/ ) { Word16 i, bitRateIndex, igfStartLine; const Word16 *swb_offset; - bitRateIndex = IGF_MapBitRateToIndex( element_brate, bwidth, IVAS_CPE_MDCT, 0 ); + bitRateIndex = IGF_MapBitRateToIndex( element_brate, bwidth, IVAS_CPE_MDCT, 0 ); /*Q0*/ swb_offset = &swb_offset_LB_new[bitRateIndex][1]; - igfStartLine = IGF_ApplyTransFac( swb_offset[0], transFac ); + igfStartLine = IGF_ApplyTransFac( swb_offset[0], transFac ); /*Q0*/ FOR( i = 0; i < stbParams->sfbCnt; i++ ) { @@ -496,7 +496,7 @@ void stereo_mdct_init_igf_start_band_fx( } } - stbParams->nBandsStereoCore = stbParams->sfbIgfStart; + stbParams->nBandsStereoCore = stbParams->sfbIgfStart; /*Q0*/ move16(); diff --git a/lib_com/ivas_stereo_mdct_stereo_com.c b/lib_com/ivas_stereo_mdct_stereo_com.c index f28c69b2242ed7775b9755bac96c22786618f093..7f8f1b55b70eed1467f731ba673da8cd1c891d4b 100644 --- a/lib_com/ivas_stereo_mdct_stereo_com.c +++ b/lib_com/ivas_stereo_mdct_stereo_com.c @@ -49,26 +49,26 @@ #ifdef IVAS_FLOAT_FIXED void splitAvailableBits_fx( - const Word16 total_bits, /* i : total available bits for TCX coding */ - const Word16 split_ratio, /* i : split ratio */ - const Word16 isSBAStereoMode, /* i : signal core coding for SBA */ - Word16 *bits_ch0, /* o : bits for channel 0 */ - Word16 *bits_ch1 /* o : bits for channel 1 */ + const Word16 total_bits, /* i : total available bits for TCX coding Q0*/ + const Word16 split_ratio, /* i : split ratio Q0*/ + const Word16 isSBAStereoMode, /* i : signal core coding for SBA Q0*/ + Word16 *bits_ch0, /* o : bits for channel 0 Q0*/ + Word16 *bits_ch1 /* o : bits for channel 1 Q0*/ ) { assert( split_ratio >= 1 && LT_16( split_ratio, SMDCT_BITRATE_RATIO_RANGE ) ); /* *bits_ch0 = split_ratio * total_bits / SMDCT_BITRATE_RATIO_RANGE; */ - *bits_ch0 = extract_l( L_shr( L_mult0( split_ratio, total_bits ), 3 ) ); + *bits_ch0 = extract_l( L_shr( L_mult0( split_ratio, total_bits ), 3 ) ); /*Q0*/ move16(); /* for SBA mode bias the distribution towards the W channel */ test(); IF( LT_16( split_ratio, 7 ) && isSBAStereoMode ) { - *bits_ch0 = add( *bits_ch0, extract_l( Mpy_32_16_1( 6554 /* 0.2 in Q15 */, *bits_ch0 ) ) ); + *bits_ch0 = add( *bits_ch0, extract_l( Mpy_32_16_1( 6554 /* 0.2 in Q15 */, *bits_ch0 ) ) ); /*Q0*/ move16(); } - *bits_ch1 = sub( total_bits, *bits_ch0 ); + *bits_ch1 = sub( total_bits, *bits_ch0 ); /*Q0*/ move16(); return; diff --git a/lib_com/ivas_stereo_psychlpc_com.c b/lib_com/ivas_stereo_psychlpc_com.c index 8ca07965dfe28560c29e708771dd97daea314d4f..1acadee3183c5c346f4d99b6fe7ea0c2114a7b7a 100644 --- a/lib_com/ivas_stereo_psychlpc_com.c +++ b/lib_com/ivas_stereo_psychlpc_com.c @@ -52,16 +52,16 @@ #ifdef IVAS_FLOAT_FIXED static void SpectrumWeighting_Init_fx( SpectrumWarping const *pSpectrumWarping, - const Word16 isTCX20, + const Word16 isTCX20, /*Q0*/ PsychoacousticParameters *pPsychParams ) { IF( isTCX20 ) { - pPsychParams->bandLengths = pSpectrumWarping->bandLengthsTCX20; + pPsychParams->bandLengths = pSpectrumWarping->bandLengthsTCX20; /*Q0*/ } ELSE { - pPsychParams->bandLengths = pSpectrumWarping->bandLengthsTCX10; + pPsychParams->bandLengths = pSpectrumWarping->bandLengthsTCX10; /*Q0*/ } return; @@ -94,10 +94,10 @@ static void SpectrumWeighting_Init( #ifdef IVAS_FLOAT_FIXED ivas_error PsychoacousticParameters_Init_fx( - const Word32 sr_core, /* i : sampling rate of core-coder */ - const Word16 nBins, /* i : Number of bins (spectral lines) */ - const Word8 nBands, /* i : Number of spectrum subbands */ - const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ + const Word32 sr_core, /* i : sampling rate of core-coder Q0*/ + const Word16 nBins, /* i : Number of bins (spectral lines) Q0*/ + const Word8 nBands, /* i : Number of spectrum subbands Q0*/ + const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 Q0*/ const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ PsychoacousticParameters *pPsychParams ) { @@ -107,8 +107,8 @@ ivas_error PsychoacousticParameters_Init_fx( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "PsychParams handle is NULL" ); } - pPsychParams->nBins = nBins; - pPsychParams->nBands = nBands; + pPsychParams->nBins = nBins; /*Q0*/ + pPsychParams->nBands = nBands; /*Q0*/ move16(); move16(); @@ -191,12 +191,12 @@ ivas_error PsychoacousticParameters_Init( #ifdef IVAS_FLOAT_FIXED void InitPsychLPC_fx( - const Word32 sr_core, /* i : sampling rate of core-coder */ - const Word16 L_frame, /* i : frame length */ + const Word32 sr_core, /* i : sampling rate of core-coder Q0*/ + const Word16 L_frame, /* i : frame length Q0*/ const TCX_CONFIG_HANDLE hTcxCfg /* i : TCX configuration handle */ ) { - Word16 L_frame_ext = add( L_frame, shr( L_frame, 2 ) ); + Word16 L_frame_ext = add( L_frame, shr( L_frame, 2 ) ); /*Q0*/ hTcxCfg->psychParamsCurrent = NULL; @@ -252,8 +252,8 @@ void SetCurrentPsychParams( } #else void SetCurrentPsychParams( - const Word16 core, - const Word16 last_frame_was_concealed_cng, + const Word16 core, /*Q0*/ + const Word16 last_frame_was_concealed_cng, /*Q0*/ TCX_CONFIG_HANDLE hTcxCfg ) { test(); diff --git a/lib_com/ivas_stereo_td_bit_alloc.c b/lib_com/ivas_stereo_td_bit_alloc.c index 4d8f90e9d6f58cc8dd60af07648a3dc3df9f9c9d..2168a6755c54c450af8fc3c42c4741b6d826f8ae 100644 --- a/lib_com/ivas_stereo_td_bit_alloc.c +++ b/lib_com/ivas_stereo_td_bit_alloc.c @@ -438,29 +438,29 @@ void tdm_bit_alloc( #else void tdm_bit_alloc( - const Word16 ivas_format, /* i : IVAS format */ - const Word16 ism_mode, /* i : ISM mode in combined format */ - const Word32 element_brate_wo_meta, /* i : element bitrate without metadata */ - const Word16 tdm_lp_reuse_flag, /* i : LPC reusage flag */ - Word32 *total_brate_pri, /* o : Allocated primary channel bitrate */ - Word32 *total_brate_sec, /* o : Allocated secondary channel bitrate */ - Word16 *tdm_low_rate_mode, /* o : secondary channel low rate mode flag*/ - const Word16 coder_type, /* i : secondary channel coder type */ - const Word16 ener_ratio_idx, /* i : correlation ratio indexe */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 bwidth_pri, /* i : bandwidth of the primary channel */ - const Word16 bwidth_sec, /* i : bandwidth of the secondary channel */ - const Word16 flag_ACELP16k_pri, /* i : ACELP@16kHz core flag, primary chan.*/ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word16 coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */ - const Word16 tdm_inst_ratio_idx_ref /* i : instantaneous correlation ratio idx */ + const Word16 ivas_format, /* i : IVAS format Q0*/ + const Word16 ism_mode, /* i : ISM mode in combined format Q0*/ + const Word32 element_brate_wo_meta, /* i : element bitrate without metadata Q0*/ + const Word16 tdm_lp_reuse_flag, /* i : LPC reusage flag Q0*/ + Word32 *total_brate_pri, /* o : Allocated primary channel bitrate Q0*/ + Word32 *total_brate_sec, /* o : Allocated secondary channel bitrate Q0*/ + Word16 *tdm_low_rate_mode, /* o : secondary channel low rate mode flag Q0*/ + const Word16 coder_type, /* i : secondary channel coder type Q0*/ + const Word16 ener_ratio_idx, /* i : correlation ratio indexe Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 bwidth_pri, /* i : bandwidth of the primary channel Q0*/ + const Word16 bwidth_sec, /* i : bandwidth of the secondary channel Q0*/ + const Word16 flag_ACELP16k_pri, /* i : ACELP@16kHz core flag, primary chan. Q0*/ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag Q0*/ + const Word16 coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) Q0*/ + const Word16 tdm_inst_ratio_idx_ref /* i : instantaneous correlation ratio idx Q0*/ ) { Word16 idx, four_subfr_fcb, two_subfr_fcb; Word32 bit_rate_diff_fx; Word32 BWE_brate; Word16 tmp_bits; - Word16 tdm_inst_ratio_idx = tdm_inst_ratio_idx_ref; + Word16 tdm_inst_ratio_idx = tdm_inst_ratio_idx_ref; /*Q0*/ move16(); if ( EQ_16( tdm_inst_ratio_idx, TDM_NQ ) ) { @@ -511,7 +511,7 @@ void tdm_bit_alloc( } /* Secondary channel based bitrate allocation */ - *total_brate_sec = tdm_bit_allc_tbl[idx][coder_type]; + *total_brate_sec = tdm_bit_allc_tbl[idx][coder_type]; /*Q0*/ move16(); test(); @@ -523,7 +523,7 @@ void tdm_bit_alloc( /* secondary channel bitrate allocation based on the energy scaling ratio */ IF( ( ( NE_16( ivas_format, MASA_ISM_FORMAT ) || ism_mode == ISM_MODE_NONE ) && ( ( NE_16( coder_type, UNVOICED ) ) || EQ_16( tdm_LRTD_flag, 1 ) ) ) || ( EQ_16( ivas_format, MASA_ISM_FORMAT ) && ism_mode != ISM_MODE_NONE && GT_16( coder_type, UNVOICED ) ) ) { - bit_rate_diff_fx = L_sub( element_brate_wo_meta, L_shl( *total_brate_sec, 1 ) ); + bit_rate_diff_fx = L_sub( element_brate_wo_meta, L_shl( *total_brate_sec, 1 ) ); /*Q0*/ IF( EQ_16( tdm_LRTD_flag, 1 ) ) /* > element_brate > STEREO_22k or CT0 not used */ { @@ -532,31 +532,31 @@ void tdm_bit_alloc( { Word32 res_fix = 0; move32(); - res_fix = Mpy_32_32( 644245095, L_sub( element_brate_wo_meta, 500 ) ); - res_fix = imult3216( Mpy_32_32( L_abs( res_fix ), 21474837 ), 100 ); + res_fix = Mpy_32_32( 644245095 /*0.3f in Q31*/, L_sub( element_brate_wo_meta, 500 ) ); /*Q0*/ + res_fix = imult3216( Mpy_32_32( L_abs( res_fix ), 21474837 /*0.01 in Q31*/ ), 100 ); /*Q0*/ if ( res_fix < 0 ) { res_fix = L_negate( res_fix ); } - *total_brate_sec = L_max( *total_brate_sec, res_fix ); + *total_brate_sec = L_max( *total_brate_sec, res_fix ); /*Q0*/ move32(); - tmp_bits = imult1616( negate( abs_s( sub( tdm_inst_ratio_idx, 16 ) ) ), imult1616( idx, 200 ) ); + tmp_bits = imult1616( negate( abs_s( sub( tdm_inst_ratio_idx, 16 ) ) ), imult1616( idx, 200 ) ); /*Q0*/ } ELSE { Word32 res_fix = 0; move32(); - res_fix = Mpy_32_32( 1073741824, L_sub( element_brate_wo_meta, 500 ) ); - res_fix = imult3216( Mpy_32_32( L_abs( res_fix ), 21474837 ), 100 ); + res_fix = Mpy_32_32( 1073741824 /*0.5f in Q31*/, L_sub( element_brate_wo_meta, 500 ) ); /*Q0*/ + res_fix = imult3216( Mpy_32_32( L_abs( res_fix ), 21474837 /*0.01 in Q31*/ ), 100 ); /*Q0*/ if ( res_fix < 0 ) { res_fix = L_negate( res_fix ); } - *total_brate_sec = L_max( *total_brate_sec, res_fix ); + *total_brate_sec = L_max( *total_brate_sec, res_fix ); /*Q0*/ move32(); - tmp_bits = imult1616( negate( abs_s( sub( tdm_inst_ratio_idx, 16 ) ) ), imult1616( 100, idx ) ); + tmp_bits = imult1616( negate( abs_s( sub( tdm_inst_ratio_idx, 16 ) ) ), imult1616( 100, idx ) ); /*Q0*/ } /* tmp_bits should be subtract from the secondary channel bitrate */ @@ -576,9 +576,9 @@ void tdm_bit_alloc( IF( LT_16( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) ) { - bit_rate_diff_fx = imult3216( bit_rate_diff_fx, sub( LRTD_STEREO_MID_IS_PRIM, ener_ratio_idx ) ); - bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 ); - bit_rate_diff_fx = Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 3277 ); + bit_rate_diff_fx = imult3216( bit_rate_diff_fx, sub( LRTD_STEREO_MID_IS_PRIM, ener_ratio_idx ) ); /*Q0*/ + bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 ); /*Q0*/ + bit_rate_diff_fx = Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 3277 /*0.1f in Q15*/ ); /*Q0*/ if ( bit_rate_diff_fx < 0 ) { bit_rate_diff_fx = L_negate( bit_rate_diff_fx ); @@ -586,9 +586,9 @@ void tdm_bit_alloc( } ELSE { - bit_rate_diff_fx = imult3216( bit_rate_diff_fx, sub( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) ); - bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 ); - bit_rate_diff_fx = Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 3277 ); + bit_rate_diff_fx = imult3216( bit_rate_diff_fx, sub( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) ); /*Q0*/ + bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 ); /*Q0*/ + bit_rate_diff_fx = Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 3277 /*0.1f in Q15*/ ); /*Q0*/ if ( bit_rate_diff_fx < 0 ) { bit_rate_diff_fx = L_negate( bit_rate_diff_fx ); @@ -596,21 +596,21 @@ void tdm_bit_alloc( } } /*bit_rate_diff2 = ((Word16)(10.f*(-0.5f*ener_ratio_LR+0.5f)*bit_rate_diff)/100)*100;*/ - Word32 temp = imult3216( Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 328 ), 100 ); + Word32 temp = imult3216( Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 328 /*0.01f in Q15*/ ), 100 ); /*Q0*/ if ( bit_rate_diff_fx < 0 ) { temp = L_negate( temp ); } - *total_brate_sec = L_add( *total_brate_sec, temp ); + *total_brate_sec = L_add( *total_brate_sec, temp ); /*Q0*/ move32(); - *total_brate_sec = L_max( *total_brate_sec, tdm_bit_allc_tbl[idx][coder_type] ); + *total_brate_sec = L_max( *total_brate_sec, tdm_bit_allc_tbl[idx][coder_type] ); /*Q0*/ move32(); test(); IF( ( coder_type == INACTIVE ) && tdm_LRTD_flag == 0 ) { - *total_brate_sec = L_min( *total_brate_sec, MIN_BRATE_SWB_BWE ); + *total_brate_sec = L_min( *total_brate_sec, MIN_BRATE_SWB_BWE ); /*Q0*/ move32(); } @@ -623,11 +623,11 @@ void tdm_bit_alloc( IF( GT_16( bwidth_pri, WB ) ) { - delta_brate = 600; /* To slightly compensate for SWB BWE instead of WB BWE */ + delta_brate = 600; /* To slightly compensate for SWB BWE instead of WB BWE Q0*/ move16(); if ( LE_32( element_brate_wo_meta, IVAS_16k4 ) ) { - delta_brate = 1250; /* To compensate for SWB BWE instead of WB BWE */ + delta_brate = 1250; /* To compensate for SWB BWE instead of WB BWE Q0*/ move16(); } } @@ -639,41 +639,41 @@ void tdm_bit_alloc( } ELSE IF( LE_32( element_brate_wo_meta, IVAS_16k4 ) ) { - *total_brate_sec = L_max( *total_brate_sec, add( 6500, delta_brate ) ); /* ~40-43 % of the total bitrate */ + *total_brate_sec = L_max( *total_brate_sec, add( 6500, delta_brate ) ); /* ~40-43 % of the total bitrate Q0*/ move32(); } ELSE IF( LE_32( element_brate_wo_meta, IVAS_24k4 ) ) { - *total_brate_sec = L_max( *total_brate_sec, add( 9000, delta_brate ) ); /* ~37-39 % of the total bitrate */ + *total_brate_sec = L_max( *total_brate_sec, add( 9000, delta_brate ) ); /* ~37-39 % of the total bitrate Q0*/ move32(); } ELSE { - *total_brate_sec = L_max( *total_brate_sec, add( 9600, delta_brate ) ); /* ~30-32% of the total bitrate */ + *total_brate_sec = L_max( *total_brate_sec, add( 9600, delta_brate ) ); /* ~30-32% of the total bitrate Q0*/ move32(); } } ELSE { - *total_brate_sec = L_min( *total_brate_sec, Mpy_32_32( 9663677, element_brate_wo_meta ) * 100 ); + *total_brate_sec = L_min( *total_brate_sec, Mpy_32_32( 9663677 /*0.0045f in Q31*/, element_brate_wo_meta ) * 100 ); /*Q0*/ move32(); } - *total_brate_sec = L_min( *total_brate_sec, 18000 ); + *total_brate_sec = L_min( *total_brate_sec, 18000 ); /*Q0*/ move32(); } ELSE IF( EQ_16( coder_type, UNVOICED ) ) { IF( tdm_lp_reuse_flag == 0 ) { - *total_brate_sec = L_add( *total_brate_sec, imult3216( FRAMES_PER_SEC, 36 ) ); + *total_brate_sec = L_add( *total_brate_sec, imult3216( FRAMES_PER_SEC, 36 ) ); /*Q0*/ move32(); } } IF( LE_16( coder_type, UNVOICED ) ) { - *total_brate_sec = L_min( *total_brate_sec, MAX_TDM_UC_BRATE ); + *total_brate_sec = L_min( *total_brate_sec, MAX_TDM_UC_BRATE ); /*Q0*/ move32(); test(); @@ -693,7 +693,7 @@ void tdm_bit_alloc( } ELSE IF( ( tdm_lp_reuse_flag == 0 && LT_32( *total_brate_sec, TDM_UC_NORMAL_MODE_MINBR_LP_R ) && EQ_16( coder_type, UNVOICED ) ) || ( tdm_lp_reuse_flag == 0 && LE_32( *total_brate_sec, L_deposit_l( add( tdm_bit_allc_tbl[idx][0], MID_LP_BRATE ) ) ) ) ) { - *total_brate_sec = L_add( *total_brate_sec, MID_LP_BRATE ); + *total_brate_sec = L_add( *total_brate_sec, MID_LP_BRATE ); /*Q0*/ move32(); } } @@ -730,7 +730,7 @@ void tdm_bit_alloc( IF( LT_32( ( L_sub( ( L_sub( element_brate_wo_meta, *total_brate_sec ) ), BWE_brate ) ), 14000 ) ) { - *total_brate_sec = L_sub( element_brate_wo_meta, L_add( 14000, BWE_brate ) ); + *total_brate_sec = L_sub( element_brate_wo_meta, L_add( 14000, BWE_brate ) ); /*Q0*/ move32(); } } @@ -744,12 +744,12 @@ void tdm_bit_alloc( move32(); if ( tdm_LRTD_flag == 0 ) { - BWE_brate = L_add( BWE_brate, 250 ); /* ICA Brate */ + BWE_brate = L_add( BWE_brate, 250 ); /* ICA Brate Q0*/ } } ELSE IF( tdm_LRTD_flag == 0 ) { - BWE_brate = L_add( BWE_brate, 350 ); /* ICA Brate */ + BWE_brate = L_add( BWE_brate, 350 ); /* ICA Brate Q0*/ } } @@ -757,29 +757,29 @@ void tdm_bit_alloc( { IF( GT_32( element_brate_wo_meta, IVAS_13k2 ) ) { - *total_brate_sec = L_min( *total_brate_sec, L_sub( element_brate_wo_meta, L_add( ACELP_8k00, BWE_brate ) ) ); + *total_brate_sec = L_min( *total_brate_sec, L_sub( element_brate_wo_meta, L_add( ACELP_8k00, BWE_brate ) ) ); /*Q0*/ move32(); } ELSE { - *total_brate_sec = L_min( *total_brate_sec, L_sub( element_brate_wo_meta, L_add( ACELP_7k20, BWE_brate ) ) ); + *total_brate_sec = L_min( *total_brate_sec, L_sub( element_brate_wo_meta, L_add( ACELP_7k20, BWE_brate ) ) ); /*Q0*/ move32(); } } ELSE { - *total_brate_sec = L_min( *total_brate_sec, L_sub( element_brate_wo_meta, L_add( 5900, BWE_brate ) ) ); + *total_brate_sec = L_min( *total_brate_sec, L_sub( element_brate_wo_meta, L_add( 5900, BWE_brate ) ) ); /*Q0*/ move32(); } IF( coder_type == INACTIVE ) { - *total_brate_sec = L_max( *total_brate_sec, tdm_bit_allc_tbl[0][0] ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */ + *total_brate_sec = L_max( *total_brate_sec, tdm_bit_allc_tbl[0][0] ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs Q0*/ move32(); } ELSE { - *total_brate_sec = L_max( *total_brate_sec, 3500 ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs */ + *total_brate_sec = L_max( *total_brate_sec, 3500 ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs Q0*/ move32(); } @@ -796,51 +796,51 @@ void tdm_bit_alloc( /* Pitch is transmitted as well, further increase the bitrate */ IF( tdm_Pitch_reuse_flag == 0 ) { - *total_brate_sec = L_max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SEC_LPC_RATE + MIN_SIGN_RATE ); + *total_brate_sec = L_max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SEC_LPC_RATE + MIN_SIGN_RATE ); /*Q0*/ move32(); test(); IF( EQ_16( tdm_LRTD_flag, 1 ) && EQ_16( bwidth_sec, SWB ) ) { /* ensure that there are enough bits to code SWB TBE_1k10 as well */ - *total_brate_sec = L_max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SEC_LPC_RATE + MIN_SIGN_RATE + SWB_TBE_1k10 ); + *total_brate_sec = L_max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SEC_LPC_RATE + MIN_SIGN_RATE + SWB_TBE_1k10 ); /*Q0*/ move32(); } } ELSE /* only LPC is tranmitted -> IF ( *total_brate_sec < MIN_SEC_BRATE+MIN_SEC_LPC_RATE ) */ { - *total_brate_sec = L_max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_LPC_RATE + MIN_SIGN_RATE ); + *total_brate_sec = L_max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_LPC_RATE + MIN_SIGN_RATE ); /*Q0*/ move32(); } } ELSE IF( /*tdm_lp_reuse_flag == 1*/ tdm_Pitch_reuse_flag == 0 ) { - *total_brate_sec = L_max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SIGN_RATE ); + *total_brate_sec = L_max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SIGN_RATE ); /*Q0*/ move32(); } /* Choose between 2 and 4 subfr, depending of the bitrate available and prevent the gap between the 2 atlernative */ IF( EQ_16( tdm_LRTD_flag, 1 ) ) { - four_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 4 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) ); - two_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) ); + four_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 4 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) ); /*Q0*/ + two_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) ); /*Q0*/ } ELSE { - four_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 4 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) ); - two_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) ); + four_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 4 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) ); /*Q0*/ + two_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) ); /*Q0*/ } IF( tdm_lp_reuse_flag == 0 ) { - four_subfr_fcb = sub( four_subfr_fcb, MIN_SEC_LPC_RATE ); - two_subfr_fcb = sub( two_subfr_fcb, MIN_SEC_LPC_RATE ); + four_subfr_fcb = sub( four_subfr_fcb, MIN_SEC_LPC_RATE ); /*Q0*/ + two_subfr_fcb = sub( two_subfr_fcb, MIN_SEC_LPC_RATE ); /*Q0*/ } IF( tdm_Pitch_reuse_flag == 0 ) { - four_subfr_fcb = sub( four_subfr_fcb, ( MIN_SEC_ACB_RATE + 10 * FRAMES_PER_SEC ) ); - two_subfr_fcb = sub( two_subfr_fcb, MIN_SEC_ACB_RATE ); + four_subfr_fcb = sub( four_subfr_fcb, ( MIN_SEC_ACB_RATE + 10 * FRAMES_PER_SEC ) ); /*Q0*/ + two_subfr_fcb = sub( two_subfr_fcb, MIN_SEC_ACB_RATE ); /*Q0*/ } /* Too much bits for the 2 subfr model but not enough for the the 4 subfr model -> slightly reduce the 2nd channel bitrate */ @@ -849,24 +849,24 @@ void tdm_bit_alloc( { IF( EQ_16( tdm_LRTD_flag, 1 ) ) { - *total_brate_sec = 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC + ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC; + *total_brate_sec = 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC + ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC; /*Q0*/ move32(); } ELSE { - *total_brate_sec = 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC + ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC; + *total_brate_sec = 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC + ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC; /*Q0*/ move32(); } IF( tdm_lp_reuse_flag == 0 ) { - *total_brate_sec = L_add( *total_brate_sec, MIN_SEC_LPC_RATE ); + *total_brate_sec = L_add( *total_brate_sec, MIN_SEC_LPC_RATE ); /*Q0*/ move32(); } IF( tdm_Pitch_reuse_flag == 0 ) { - *total_brate_sec = L_add( *total_brate_sec, MIN_SEC_ACB_RATE ); + *total_brate_sec = L_add( *total_brate_sec, MIN_SEC_ACB_RATE ); /*Q0*/ move32(); } } @@ -878,7 +878,7 @@ void tdm_bit_alloc( ELSE /* Possible slight increase of secondary channel bit budget to compensate for FCB limited flexibility */ { Word16 tmp_rate, i; - tmp_rate = two_subfr_fcb; + tmp_rate = two_subfr_fcb; /*Q0*/ move16(); idx = sub( NB_RATE_POSS, 2 ); @@ -889,13 +889,13 @@ void tdm_bit_alloc( BREAK; } } - *total_brate_sec = L_add( *total_brate_sec, sub( fast_FCB_rates_2sfr[idx], tmp_rate ) ); + *total_brate_sec = L_add( *total_brate_sec, sub( fast_FCB_rates_2sfr[idx], tmp_rate ) ); /*Q0*/ move32(); } /* To prevent 13.2 kb/s for primary channel as some bitstream issues arrise with it */ IF( EQ_32( L_sub( element_brate_wo_meta, *total_brate_sec ), ACELP_13k20 ) ) { - *total_brate_sec = L_add( *total_brate_sec, 100 ); + *total_brate_sec = L_add( *total_brate_sec, 100 ); /*Q0*/ move32(); } } @@ -903,11 +903,11 @@ IF( EQ_32( L_sub( element_brate_wo_meta, *total_brate_sec ), ACELP_13k20 ) ) test(); IF( EQ_32( *total_brate_sec, PPP_NELP_2k80 ) || EQ_32( *total_brate_sec, SID_2k40 ) ) { - *total_brate_sec = L_sub( *total_brate_sec, 100 ); + *total_brate_sec = L_sub( *total_brate_sec, 100 ); /*Q0*/ move32(); } -*total_brate_pri = L_sub( element_brate_wo_meta, *total_brate_sec ); +*total_brate_pri = L_sub( element_brate_wo_meta, *total_brate_sec ); /*Q0*/ move32(); return; @@ -974,8 +974,8 @@ void td_stereo_param_updt_fx( Word16 tdm_lspQ_PCh_fx[], /* o : Q LSPs for primary channel Q15 */ Word16 tdm_lsfQ_PCh_fx[], /* o : Q LSFs for primary channel Qlog2(2.56) */ Word16 tdm_Pri_pitch_buf_fx[], /* o : pitch values for primary channel Q6 */ - const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag */ - const Word16 tdm_use_IAWB_Ave_lpc /* i : flag to indicate the usage of mean inactive LP coefficients */ + const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag Q0*/ + const Word16 tdm_use_IAWB_Ave_lpc /* i : flag to indicate the usage of mean inactive LP coefficients Q0*/ #ifndef FIX_798_WRONG_CPY_OF_PITCH , Word16 Q_var @@ -987,19 +987,19 @@ void td_stereo_param_updt_fx( IF( EQ_16( tdm_use_IAWB_Ave_lpc, 1 ) ) { /*not being assert*/ - Copy( IAWB_Ave_fx, tdm_lsfQ_PCh_fx, M ); + Copy( IAWB_Ave_fx, tdm_lsfQ_PCh_fx, M ); /*Qlog2(2.56)*/ lsf2lsp_fx( tdm_lsfQ_PCh_fx, tdm_lspQ_PCh_fx, M, INT_FS_12k8 ); } ELSE IF( EQ_16( flag_ACELP16k, 1 ) ) { - Copy( lsp_old_PCh_fx, tdm_lspQ_PCh_fx, M ); + Copy( lsp_old_PCh_fx, tdm_lspQ_PCh_fx, M ); /*Q15*/ lsp_convert_poly_fx( tdm_lspQ_PCh_fx, L_FRAME, 0 ); lsp2lsf_fx( tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, M, INT_FS_12k8 ); } ELSE { - Copy( lsp_old_PCh_fx, tdm_lspQ_PCh_fx, M ); - Copy( lsf_old_PCh_fx, tdm_lsfQ_PCh_fx, M ); + Copy( lsp_old_PCh_fx, tdm_lspQ_PCh_fx, M ); /*Q15*/ + Copy( lsf_old_PCh_fx, tdm_lsfQ_PCh_fx, M ); /*Qlog2(2.56)*/ } #ifdef FIX_798_WRONG_CPY_OF_PITCH IF( EQ_16( flag_ACELP16k, 1 ) ) @@ -1009,14 +1009,14 @@ void td_stereo_param_updt_fx( move16(); FOR( i = 0; i < NB_SUBFR; i++ ) { - tmp16 = mult_r( pitch_buf_PCh_fx[i], mult_factor ); /* Convert 16kHz to 12.8 kHz pitch values */ - tdm_Pri_pitch_buf_fx[i] = s_max( tmp16, PIT_MIN << 6 ); /* pitch is represented in Q6*/ + tmp16 = mult_r( pitch_buf_PCh_fx[i], mult_factor ); /* Convert 16kHz to 12.8 kHz pitch values Q6*/ + tdm_Pri_pitch_buf_fx[i] = s_max( tmp16, shl( PIT_MIN, 6 ) ); /* pitch is represented in Q6*/ move16(); } } ELSE { - Copy( pitch_buf_PCh_fx, tdm_Pri_pitch_buf_fx, NB_SUBFR ); + Copy( pitch_buf_PCh_fx, tdm_Pri_pitch_buf_fx, NB_SUBFR ); /*Q6*/ } #else @@ -1058,17 +1058,17 @@ void td_stereo_param_updt_fx( *-------------------------------------------------------------------*/ static void tdm_SCh_LSF_intra_pred_zero_bits_fx( - const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs */ - Word16 *pred_lsf_SCh_fx, /* o : predicted secondary channel LSFs */ - const Word16 *lsf_mean_fx, /* i : secondary channel mean LSFs */ - const Word16 beta_fx /* i : pull to average beta factor */ + const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs x2.56*/ + Word16 *pred_lsf_SCh_fx, /* o : predicted secondary channel LSFs x2.56*/ + const Word16 *lsf_mean_fx, /* i : secondary channel mean LSFs x2.56*/ + const Word16 beta_fx /* i : pull to average beta factor Q15*/ ) { Word16 i; /* pulling the LSFs closer to the average */ FOR( i = 0; i < M; i++ ) { - pred_lsf_SCh_fx[i] = add( mult_r( beta_fx, tdm_lsfQ_PCh_fx[i] ), mult_r( sub( 32767, beta_fx ), lsf_mean_fx[i] ) ); + pred_lsf_SCh_fx[i] = add( mult_r( beta_fx, tdm_lsfQ_PCh_fx[i] ), mult_r( sub( 32767 /*1.0f in Q15*/, beta_fx ), lsf_mean_fx[i] ) ); move16(); } @@ -1107,10 +1107,10 @@ static void tdm_SCh_LSF_intra_pred_zero_bits( *-------------------------------------------------------------------*/ static void tdm_SCh_LSF_intra_pred_tri_diag_mat_fx( - Word16 *lsf_SCh_fx, /* i/o: secondary channel LSFs */ - const Word16 *lsf_mean_in_fx, /* i : secondary channel mean LSFs (in) */ - const Word16 *lsf_mean_out_fx, /* i : secondary channel mean LSFs (out) */ - const Word16 *prd_diag_3_fx /* i : secondary channel mean LSFs */ + Word16 *lsf_SCh_fx, /* i/o: secondary channel LSFs x2.56*/ + const Word16 *lsf_mean_in_fx, /* i : secondary channel mean LSFs (in) x2.56*/ + const Word16 *lsf_mean_out_fx, /* i : secondary channel mean LSFs (out) x2.56*/ + const Word16 *prd_diag_3_fx /* i : secondary channel mean LSFs Q15*/ ) { Word16 i; @@ -1120,16 +1120,16 @@ static void tdm_SCh_LSF_intra_pred_tri_diag_mat_fx( Word16 *lsf_tmp_ptr2_fx; Word16 *lsf_SCh_ptr_fx; - prd_ptr_fx = prd_diag_3_fx; + prd_ptr_fx = prd_diag_3_fx; /*Q15*/ v_sub_16( lsf_SCh_fx, lsf_mean_in_fx, lsf_tmp_fx, M ); - lsf_tmp_ptr1_fx = lsf_tmp_fx; + lsf_tmp_ptr1_fx = lsf_tmp_fx; /*x2.56*/ - lsf_SCh_ptr_fx = lsf_SCh_fx; + lsf_SCh_ptr_fx = lsf_SCh_fx; /*x2.56*/ - lsf_tmp_ptr2_fx = lsf_tmp_ptr1_fx; + lsf_tmp_ptr2_fx = lsf_tmp_ptr1_fx; /*x2.56*/ *lsf_SCh_ptr_fx = mult_r( *lsf_tmp_ptr1_fx++, *prd_ptr_fx++ ); // Q2.56 + 15 -15 move16(); @@ -1142,23 +1142,23 @@ static void tdm_SCh_LSF_intra_pred_tri_diag_mat_fx( lsf_tmp_ptr1_fx = lsf_tmp_ptr2_fx; // Q2.56 *lsf_SCh_ptr_fx = mult_r( *lsf_tmp_ptr1_fx++, *prd_ptr_fx++ ); // Q2.56 + 15 -15 move16(); - lsf_tmp_ptr2_fx = lsf_tmp_ptr1_fx; - *lsf_SCh_ptr_fx = add( *lsf_SCh_ptr_fx, mult_r( ( *lsf_tmp_ptr1_fx++ ), ( *prd_ptr_fx++ ) ) ); + lsf_tmp_ptr2_fx = lsf_tmp_ptr1_fx; /*x2.56*/ + *lsf_SCh_ptr_fx = add( *lsf_SCh_ptr_fx, mult_r( ( *lsf_tmp_ptr1_fx++ ), ( *prd_ptr_fx++ ) ) ); /*x2.56*/ move16(); - ( *lsf_SCh_ptr_fx ) = add( *lsf_SCh_ptr_fx, mult_r( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx++ ) ) ); + ( *lsf_SCh_ptr_fx ) = add( *lsf_SCh_ptr_fx, mult_r( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx++ ) ) ); /*x2.56*/ move16(); lsf_SCh_ptr_fx++; } - lsf_tmp_ptr1_fx = lsf_tmp_ptr2_fx; - *lsf_SCh_ptr_fx = mult_r( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx ) ); + lsf_tmp_ptr1_fx = lsf_tmp_ptr2_fx; /*x2.56*/ + *lsf_SCh_ptr_fx = mult_r( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx ) ); /*x2.56*/ move16(); lsf_tmp_ptr1_fx++; prd_ptr_fx++; - *lsf_SCh_ptr_fx = add( mult_r( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx ) ), *lsf_SCh_ptr_fx ); + *lsf_SCh_ptr_fx = add( mult_r( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx ) ), *lsf_SCh_ptr_fx ); /*x2.56*/ move16(); - v_add_16( lsf_SCh_fx, lsf_mean_out_fx, lsf_SCh_fx, M ); + v_add_16( lsf_SCh_fx, lsf_mean_out_fx, lsf_SCh_fx, M ); /*x2.56*/ return; } @@ -1220,9 +1220,9 @@ static void tdm_SCh_LSF_intra_pred_tri_diag_mat( *-------------------------------------------------------------------*/ void tdm_SCh_LSF_intra_pred_fx( - const Word32 element_brate, /* i : element bitrate */ - const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs */ - Word16 *pred_lsf_SCh_fx /* o : predicted secondary channel LSFs */ + const Word32 element_brate, /* i : element bitrate Q0*/ + const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs x2.56*/ + Word16 *pred_lsf_SCh_fx /* o : predicted secondary channel LSFs x2.56*/ ) { Word16 fixed_beta; @@ -1311,11 +1311,11 @@ void tdm_SCh_LSF_intra_pred( *-------------------------------------------------------------------*/ static void tdm_SCh_LSF_intra_pred_one_bit_dec_fx( - const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs */ - Word16 *pred_lsf_SCh_fx, /* o : predicted secondary channel LSFs */ - const Word16 *lsf_mean_fx, /* i : secondary channel mean LSFs */ - const Word16 *Beta_Q_x_fx, /* i : beta quantization values */ - const Word16 beta_index_fx /* i : the quantization bits for beta (-1 if beta fixed)*/ + const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs x2.56*/ + Word16 *pred_lsf_SCh_fx, /* o : predicted secondary channel LSFs x2.56*/ + const Word16 *lsf_mean_fx, /* i : secondary channel mean LSFs x2.56*/ + const Word16 *Beta_Q_x_fx, /* i : beta quantization values Q15*/ + const Word16 beta_index_fx /* i : the quantization bits for beta (-1 if beta fixed) Q0*/ ) { Word16 i; @@ -1327,7 +1327,7 @@ static void tdm_SCh_LSF_intra_pred_one_bit_dec_fx( /* pulling the LSFs closer to the avergae */ FOR( i = 0; i < M; i++ ) { - pred_lsf_SCh_fx[i] = add( mult_r( beta_fx, tdm_lsfQ_PCh_fx[i] ), mult_r( sub( 32767, beta_fx ), lsf_mean_fx[i] ) ); + pred_lsf_SCh_fx[i] = add( mult_r( beta_fx, tdm_lsfQ_PCh_fx[i] ), mult_r( sub( 32767 /*1.0f in Q15*/, beta_fx ), lsf_mean_fx[i] ) ); /*x2.56*/ move16(); } @@ -1371,13 +1371,13 @@ static void tdm_SCh_LSF_intra_pred_one_bit_dec( *-------------------------------------------------------------------*/ static void tdm_SCh_LSF_intra_pred_one_bit_enc_fx( - const Word16 *lsf_SCh_fx, /* i : secondary channel LSFs */ - const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs */ - Word16 *pred_lsf_SCh_fx, /* o : predicted secondary channel LSFs */ - const Word16 *lsf_mean_fx, /* i : secondary channel mean LSFs */ - const Word16 *lsf_wgts_new_fx, /* i : Improved wgts for LSFs */ - const Word16 *Beta_Q_x_fx, /* i : beta quantization values */ - Word16 *beta_index /* o : the quantization bits for beta (-1 if beta fixed) */ + const Word16 *lsf_SCh_fx, /* i : secondary channel LSFs x2.56*/ + const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs x2.56*/ + Word16 *pred_lsf_SCh_fx, /* o : predicted secondary channel LSFs x2.56*/ + const Word16 *lsf_mean_fx, /* i : secondary channel mean LSFs x2.56*/ + const Word16 *lsf_wgts_new_fx, /* i : Improved wgts for LSFs Q8*/ + const Word16 *Beta_Q_x_fx, /* i : beta quantization values Q15*/ + Word16 *beta_index /* o : the quantization bits for beta (-1 if beta fixed) Q0*/ ) { Word16 i; @@ -1390,23 +1390,23 @@ static void tdm_SCh_LSF_intra_pred_one_bit_enc_fx( FOR( i = 0; i < M; i++ ) { - A_temp_fx[i] = sub( lsf_SCh_fx[i], lsf_mean_fx[i] ); + A_temp_fx[i] = sub( lsf_SCh_fx[i], lsf_mean_fx[i] ); /*x2.56*/ move16(); - B_temp_fx[i] = sub( lsf_mean_fx[i], tdm_lsfQ_PCh_fx[i] ); + B_temp_fx[i] = sub( lsf_mean_fx[i], tdm_lsfQ_PCh_fx[i] ); /*x2.56*/ move16(); } FOR( i = 0; i < M; i++ ) { - Word32 wgt_A_temp = Mpy_32_16_1( L_mult( A_temp_fx[i], A_temp_fx[i] ), lsf_wgts_new_fx[i] ); // - Word32 wgt_B_temp = Mpy_32_16_1( L_mult( B_temp_fx[i], B_temp_fx[i] ), lsf_wgts_new_fx[i] ); - Word32 wgt_AB_temp = Mpy_32_16_1( L_mult( A_temp_fx[i], B_temp_fx[i] ), lsf_wgts_new_fx[i] ); - Word32 Beta_Q_x0 = L_mult( Beta_Q_x_fx[0], Beta_Q_x_fx[0] ); // Q31 - Word32 Beta_Q_x1 = L_mult( Beta_Q_x_fx[1], Beta_Q_x_fx[1] ); // Q31 + Word32 wgt_A_temp = Mpy_32_16_1( L_mult( A_temp_fx[i], A_temp_fx[i] ), lsf_wgts_new_fx[i] ); /*2*(x2.56)-7*/ + Word32 wgt_B_temp = Mpy_32_16_1( L_mult( B_temp_fx[i], B_temp_fx[i] ), lsf_wgts_new_fx[i] ); /*2*(x2.56)-7*/ + Word32 wgt_AB_temp = Mpy_32_16_1( L_mult( A_temp_fx[i], B_temp_fx[i] ), lsf_wgts_new_fx[i] ); /*2*(x2.56)-7*/ + Word32 Beta_Q_x0 = L_mult( Beta_Q_x_fx[0], Beta_Q_x_fx[0] ); // Q31 + Word32 Beta_Q_x1 = L_mult( Beta_Q_x_fx[1], Beta_Q_x_fx[1] ); // Q31 - WD_fx[0] = L_add( WD_fx[0], L_add( L_add( wgt_A_temp, Mpy_32_16_1( L_shl( wgt_AB_temp, 1 ), Beta_Q_x_fx[0] ) ), Mpy_32_32( wgt_B_temp, Beta_Q_x0 ) ) ); + WD_fx[0] = L_add( WD_fx[0], L_add( L_add( wgt_A_temp, Mpy_32_16_1( L_shl( wgt_AB_temp, 1 ), Beta_Q_x_fx[0] ) ), Mpy_32_32( wgt_B_temp, Beta_Q_x0 ) ) ); /*2*(x2.56)-7*/ move32(); - WD_fx[1] = L_add( WD_fx[1], L_add( L_add( wgt_A_temp, Mpy_32_16_1( L_shl( wgt_AB_temp, 1 ), Beta_Q_x_fx[1] ) ), Mpy_32_32( wgt_B_temp, Beta_Q_x1 ) ) ); + WD_fx[1] = L_add( WD_fx[1], L_add( L_add( wgt_A_temp, Mpy_32_16_1( L_shl( wgt_AB_temp, 1 ), Beta_Q_x_fx[1] ) ), Mpy_32_32( wgt_B_temp, Beta_Q_x1 ) ) ); /*2*(x2.56)-7*/ move32(); } @@ -1484,32 +1484,32 @@ static void tdm_SCh_LSF_intra_pred_one_bit_enc( *-------------------------------------------------------------------*/ void tdm_SCh_lsf_reuse_fx( - const Word16 enc_dec, /* i : encoder/decoder flag */ - const Word32 element_brate, /* i : element bitrate */ - Word16 lsf_new_fx[M], /* i/o: LSFs at the end of the frame */ - Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */ - const Word16 tdm_lsfQ_PCh_fx[M], /* i : primary channel LSFs */ - const Word16 lsf_wgts_fx[M], /* i : LSF weights */ - Word16 *beta_index /* i/o: quantization index */ + const Word16 enc_dec, /* i : encoder/decoder flag Q0*/ + const Word32 element_brate, /* i : element bitrate Q0*/ + Word16 lsf_new_fx[M], /* i/o: LSFs at the end of the frame x2.56*/ + Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ + const Word16 tdm_lsfQ_PCh_fx[M], /* i : primary channel LSFs x2.56*/ + const Word16 lsf_wgts_fx[M], /* i : LSF weights Q8*/ + Word16 *beta_index /* i/o: quantization index Q0*/ ) { const Word16 *Beta_Q1bit_re_use_fx; IF( LE_32( element_brate, IVAS_13k2 ) ) { - Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_13k2_fx; + Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_13k2_fx; /*Q15*/ } ELSE IF( LE_32( element_brate, IVAS_16k4 ) ) { - Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_16k4_fx; + Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_16k4_fx; /*Q15*/ } ELSE IF( LE_32( element_brate, IVAS_32k ) ) { - Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_24k4_32k_fx; + Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_24k4_32k_fx; /*Q15*/ } ELSE { - Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_48k_fx; + Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_48k_fx; /*Q15*/ } IF( enc_dec == ENC ) diff --git a/lib_com/prot.h b/lib_com/prot.h index 93b3f3a909626e2ed98df0e68c2117be76f65ce5..7564cdc488d992560d3f5c8f0c39d4d25e466928 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -965,6 +965,7 @@ void CNG_exc( const int16_t element_mode /* i : IVAS Element mode */ ); +#ifndef IVAS_FLOAT_FIXED void cng_params_upd( const float lsp_new[], /* i : LSP aprameters */ const float exc2[], /* i : current enhanced excitation */ @@ -982,6 +983,7 @@ void cng_params_upd( const int16_t element_mode, /* i : Element mode */ const int16_t bwidth /* i : audio bandwidth */ ); +#endif void cng_params_postupd( const int16_t ho_circ_ptr, /* i : pointer for CNG averaging buffers */ @@ -4011,6 +4013,7 @@ void dtx_hangover_control( const float lsp_new[M] /* i : current frame LSPs */ ); +#ifndef IVAS_FLOAT_FIXED void updt_enc( Encoder_State *st, /* i/o: state structure */ const float *old_exc, /* i : buffer of excitation */ @@ -4021,6 +4024,7 @@ void updt_enc( const float *lsp_new, /* i : current frame LSP vector */ const float *old_bwe_exc /* o : buffer of excitation for SWB TBE */ ); +#endif void updt_enc_common( Encoder_State *st /* i/o: encoder state structure */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 1fac038c880b175c8c4ed2d58b26359db125b835..1fa1b354963284e3435f4ed70c1bf761ba9d46c4 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3157,102 +3157,108 @@ Word16 get_tbe_bits_fx( // pvq_com_fx UWord32 intLimCDivPos_fx( - UWord32 NUM, - Word16 DEN ); + UWord32 NUM, /* Qx */ + Word16 DEN /* Q0 */ +); Word16 shrtCDivSignedApprox( - const Word16 num, - const Word16 den ); + const Word16 num, /* Q0 */ + const Word16 den /* Q0 */ +); void obtainEnergyQuantizerDensity_fx( - const Word16 L, - const Word16 R, - Word16 *Density ); + const Word16 L, /* i : left vector energy Q0*/ + const Word16 R, /* i : right vector energy Q0*/ + Word16 *Density /* o : quantizer density Q0*/ +); void dsDirac2Dirac_fx( - const Word16 dsDiracIndex, - Word16 *diracs ); + const Word16 dsDiracIndex, /* Q0 */ + Word16 *diracs /* Q0 */ +); void dsDiracPerQuanta_fx( - const Word16 td, - const Word16 t_quanta, - const Word16 dsm, - const unsigned char *const *frQuanta, - Word16 *DsIdx ); + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ + const Word16 dsm, /* i : Conservative rounding flag Q0*/ + const unsigned char *const *frQuanta, /* i : Quanta lookup table */ + Word16 *DsIdx /* o : Lookup table index Q0*/ +); void QuantaPerDsDirac_fx( - const Word16 td, /* i : Length of vector segment */ - const Word16 dsDiracIndex, /* i : Quanta table index */ - const unsigned char *const *dimFrQuanta, /* i : Quanta lookup table */ - Word16 *Quanta /* i : Quanta */ + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 dsDiracIndex, /* i : Quanta table index Q0*/ + const unsigned char *const *dimFrQuanta, /* i : Quanta lookup table */ + Word16 *Quanta /* i : Quanta Q0*/ ); void conservativeL1Norm_fx( - const Word16 L, /* i : Length of vector segment */ - const Word16 Qvec, /* i : Assigned number of quanta */ - const Word16 Fcons, /* i : Conservative rounding flag */ - const Word16 Qavail, /* i : Input quanta remaining */ - const Word16 Qreserv, /* i : Input quanta in reservoir */ - const Word16 Dspec, /* i : assigned diracs from bitalloc */ - Word16 *Dvec, /* o : actual number of diracs */ - Word16 *Qspare, /* o : Output quanta remaining */ - Word16 *Qreservplus, /* o : Output quanta in reservoir */ - Word16 *Dspecplus /* o : Output number of diracs */ + const Word16 L, /* i : Length of vector segment Q0*/ + const Word16 Qvec, /* i : Assigned number of quanta Q0*/ + const Word16 Fcons, /* i : Conservative rounding flag Q0*/ + const Word16 Qavail, /* i : Input quanta remaining Q0*/ + const Word16 Qreserv, /* i : Input quanta in reservoir Q0*/ + const Word16 Dspec, /* i : assigned diracs from bitalloc Q0*/ + Word16 *Dvec, /* o : actual number of diracs Q0*/ + Word16 *Qspare, /* o : Output quanta remaining Q0*/ + Word16 *Qreservplus, /* o : Output quanta in reservoir Q0*/ + Word16 *Dspecplus /* o : Output number of diracs Q0*/ ); void bandBitsAdjustment_fx( - const Word16 Brc, /* i : Current number of read quanta in range coder */ - const UWord32 INTrc, /* i : Range coder state */ - const Word16 Bavail, /* i : Available number of quanta */ - const Word16 Nbands, /* i : Number of bands */ - const Word16 D, /* i : Remaining number of bands to encode */ - const Word16 L, /* i : Size of current band */ - const Word16 Bband, /* i : Quanta allocation for current band */ - const Word16 Breserv, /* i : Quanta reservoir */ - Word16 *Bband_adj, /* o : Actual used number of quanta */ - Word16 *Brem, /* o : Quanta remaining */ - Word16 *Breservplus /* o : Quanta pool size */ + const Word16 Brc, /* i : Current number of read quanta in range coder Q0*/ + const UWord32 INTrc, /* i : Range coder state Q0*/ + const Word16 Bavail, /* i : Available number of quanta Q3*/ + const Word16 Nbands, /* i : Number of bands Q0*/ + const Word16 D, /* i : Remaining number of bands to encode Q0*/ + const Word16 L, /* i : Size of current band Q0*/ + const Word16 Bband, /* i : Quanta allocation for current band Q0*/ + const Word16 Breserv, /* i : Quanta reservoir Q0*/ + Word16 *Bband_adj, /* o : Actual used number of quanta Q0*/ + Word16 *Brem, /* o : Quanta remaining Q0*/ + Word16 *Breservplus /* o : Quanta pool size Q0*/ ); void densityAngle2RmsProjDec_fx( - const Word16 D, /* i : density */ - const Word16 indexphi, /* i : decoded index from AR dec */ - Word16 *oppQ15, /* o : opposite */ - Word16 *nearQ15, /* o : near */ - Word16 *oppRatioQ3 /* o : ratio */ + const Word16 D, /* i : density Q0*/ + const Word16 indexphi, /* i : decoded index from AR dec Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ ); void densityAngle2RmsProjEnc_fx( - const Word16 D, /* i : density */ - const Word16 phiQ14uq, /* i : angle */ - Word16 *indexphi, /* o : index */ - Word16 *oppQ15, /* o : opposite */ - Word16 *nearQ15, /* o : near */ - Word16 *oppRatioQ3 /* o : ratio */ + const Word16 D, /* i : density Q0*/ + const Word16 phiQ14uq, /* i : angle Q14*/ + Word16 *indexphi, /* o : index Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ ); void NearOppSplitAdjustment_fx( - const Word16 qband, - const Word16 qzero, - const Word16 Qac, - const UWord32 INTac, - const Word16 qglobal, - const Word16 FlagCons, - const Word16 Np, - const Word16 Nhead, - const Word16 Ntail, - const Word16 Nnear, - const Word16 Nopp, - Word16 oppRQ3, - Word16 *qnear, - Word16 *qopp, - Word16 *qglobalupd ); + const Word16 qband, /* i : quanta for current band Q0*/ + const Word16 qzero, /* i : range coder finalization quanta Q0*/ + const Word16 Qac, /* i : range coder current quanta Q0*/ + const UWord32 INTac, /* i : range coder state Q0*/ + const Word16 qglobal, /* i : quanta input Q0*/ + const Word16 FlagCons, /* i : conservative rounding flag Q0*/ + const Word16 Np, /* i : number of parts Q0*/ + const Word16 Nhead, /* i : first part Q0*/ + const Word16 Ntail, /* i : remaining parts Q0*/ + const Word16 Nnear, /* i : length of near component Q0*/ + const Word16 Nopp, /* i : length of opposite component Q0*/ + Word16 oppRQ3, /* i : ratio Q0*/ + Word16 *qnear, /* o : quantized near Q0*/ + Word16 *qopp, /* o : quantized opposite Q0*/ + Word16 *qglobalupd /* o : quanta remaining Q0*/ +); void apply_gain_fx( - const Word16 *ord, /* i : Indices for energy order */ - const Word16 *band_start, /* i : Sub band start indices */ - const Word16 *band_end, /* i : Sub band end indices */ - const Word16 num_sfm, /* i : Number of bands */ + 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 Q12 */ Word16 *xq /* i/o: Float synthesis / Gain adjusted synth Q15/Q12 */ ); @@ -3267,25 +3273,27 @@ void fine_gain_quant_fx( ); void srt_vec_ind16_fx( - const Word16 *linear, /* linear i */ - Word16 *srt, /* sorted output*/ - Word16 *I, /* index for sorted output */ - Word16 length ); + const Word16 *linear, /* linear input Q3*/ + Word16 *srt, /* sorted output Q3*/ + Word16 *I, /* index for sorted output Q0*/ + Word16 length /* Q0 */ +); -Word16 atan2_fx( - const Word32, - const Word32 ); +Word16 atan2_fx( /* o: Angle between 0 and PI/2 radian (Q14) */ + const Word32 y, /* i : near side (Argument must be positive) (Q15) */ + const Word32 x /* i : opposite side (Q15) */ +); // rang_com_fx.c -Word16 rc_get_bits2_fx( /* o: Number of bits needed */ - const Word16 N, /* i: Number of bits currently used */ - const UWord32 range /* i: Range of range coder */ +Word16 rc_get_bits2_fx( /* o: Number of bits needed Q0*/ + const Word16 N, /* i: Number of bits currently used Q0*/ + const UWord32 range /* i: Range of range coder Q0*/ ); void rangeCoderFinalizationFBits_fx( - Word16 Brc, /* i : Current number of decoded bits */ - UWord32 INTrc, /* i : Range coder state */ - Word16 *FBits /* i : Fractional finalization bits */ + Word16 Brc, /* i : Current number of decoded bits Q0*/ + UWord32 INTrc, /* i : Range coder state Q0*/ + Word16 *FBits /* i : Fractional finalization bits Q0*/ ); // wi_fx.c @@ -4848,19 +4856,19 @@ void fine_gain_pred_fx( ); void fine_gain_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order */ - const Word16 num_sfm, /* i : Number of bands */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ const Word16 *gopt /* i : Optimal gains Q12 */ ); #ifdef IVAS_FLOAT_FIXED void fine_gain_quant_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order */ - const Word16 num_sfm, /* i : Number of bands */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ const Word16 *gopt /* i : Optimal gains Q12 */ ); @@ -5286,10 +5294,10 @@ void Inverse_Transform( // recovernorm void recovernorm_fx( - const Word16 *idxbuf, /* i : reordered quantization indices */ - Word16 *ynrm, /* o : recovered quantization indices */ - Word16 *normqlg2, /* o : recovered quantized norms */ - const Word16 nb_sfm /* i : number of SFMs */ + const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ + Word16 *ynrm, /* o : recovered quantization indices Q0*/ + Word16 *normqlg2, /* o : recovered quantized norms Q0*/ + const Word16 nb_sfm /* i : number of SFMs Q0*/ ); // tcq_poition_qeith.c @@ -6897,23 +6905,23 @@ void re8_decode_base_index_fx( const Word16 n, UWord16 I, Word16 *x ); // re8_utils_fx.c void re8_k2y_fx( - const Word16 *k, /* i : Voronoi index k[0..7] */ - const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) */ - Word16 *y /* o : 8-dimensional point y[0..7] in RE8 */ + const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ + const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ + Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ ); void re8_vor_fx( - const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) */ - Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) */ - Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4*/ - Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c */ - Word16 *ka /* o : identifier of absolute leader (to index c) */ + const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ + Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ + Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ + Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ + Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ ); // re8_PPV_fx.c void re8_PPV_fx( - const Word32 x[], /* i : point in R^8Q15 */ - Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */ + const Word32 x[], /* i : point in R^8 Q15 */ + Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ ); // dec_pit_exc_fx.c diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c index dc353b95c641e567b43f09b4296fe7fc9f3e1da8..4f3f61e998b36684053550eda860f02b7250df43 100644 --- a/lib_com/pvq_com_fx.c +++ b/lib_com/pvq_com_fx.c @@ -10,22 +10,24 @@ /*! r: Approximate integer division for positive input using lookup table */ UWord32 intLimCDivPos_fx( - UWord32 NUM, - Word16 DEN ) + UWord32 NUM, /* Qx */ + Word16 DEN /* Q0 */ +) { UWord32 UL_ru, UL_rl; - Mpy_32_32_uu( UL_lshl( NUM, 1 ), intLimCDivInvDQ31[DEN], &UL_ru, &UL_rl ); + Mpy_32_32_uu( UL_lshl( NUM, 1 ), intLimCDivInvDQ31[DEN], &UL_ru, &UL_rl ); /* Qx */ return UL_ru; } /*! r: Approximate integer division for signed input using lookup table */ static Word32 intLimCDivSigned_fx( - Word32 NUM, - Word16 DEN ) + Word32 NUM, /* Qx */ + Word16 DEN /* Q0 */ +) { Word32 L_tmp; - L_tmp = intLimCDivPos_fx( L_abs( NUM ), DEN ); + L_tmp = intLimCDivPos_fx( L_abs( NUM ), DEN ); /* Qx */ if ( NUM < 0 ) { L_tmp = L_negate( L_tmp ); /* one op */ @@ -35,12 +37,13 @@ static Word32 intLimCDivSigned_fx( /*! r: Approximate integer division for negative input */ Word16 shrtCDivSignedApprox( - const Word16 num, - const Word16 den ) + const Word16 num, /* Q0 */ + const Word16 den /* Q0 */ +) { Word16 pool_part; - pool_part = extract_h( L_mult( negate( abs_s( num ) ), lim_neg_inv_tbl_fx[den] ) ); + pool_part = extract_h( L_mult( negate( abs_s( num ) ), lim_neg_inv_tbl_fx[den] ) ); /* Q0 */ /* neg_in always, positive out always, so that positive truncation(rounding) is used */ if ( num < 0 ) { @@ -50,11 +53,11 @@ Word16 shrtCDivSignedApprox( } static void nearProjQ15_fx( - const Word16 x, /* i : input coefficient */ - Word16 *result /* o : projection */ + const Word16 x, /* i : input coefficient Q15*/ + Word16 *result /* o : projection Q15*/ ) { - const Word16 a[4] = { 14967, -25518, 3415, 32351 }; + const Word16 a[4] = { 14967, -25518, 3415, 32351 }; /* Q15 */ move16(); move16(); move16(); @@ -63,12 +66,12 @@ static void nearProjQ15_fx( UWord16 lsb; b = L_deposit_l( a[0] ); - b = L_shl( L_deposit_l( add( a[1], extract_h( L_mult0( extract_l( b ), x ) ) ) ), 1 ); - Mpy_32_16_ss( b, x, &b, &lsb ); - b = L_add( L_deposit_l( a[2] ), b ); - Mpy_32_16_ss( b, x, &b, &lsb ); - b = L_add( L_deposit_l( a[3] ), b ); - *result = extract_l( b ); + b = L_shl( L_deposit_l( add( a[1], extract_h( L_mult0( extract_l( b ), x ) ) ) ), 1 ); /* Q15 */ + Mpy_32_16_ss( b, x, &b, &lsb ); /* Q15 */ + b = L_add( L_deposit_l( a[2] ), b ); /* Q15 */ + Mpy_32_16_ss( b, x, &b, &lsb ); /* Q15 */ + b = L_add( L_deposit_l( a[3] ), b ); /* Q15 */ + *result = extract_l( b ); /* Q15 */ move16(); return; } @@ -79,9 +82,9 @@ static void nearProjQ15_fx( * *-------------------------------------------------------------------*/ void obtainEnergyQuantizerDensity_fx( - const Word16 L, /* i : left vector energy */ - const Word16 R, /* i : right vector energy */ - Word16 *Density /* o : quantizer density */ + const Word16 L, /* i : left vector energy Q0*/ + const Word16 R, /* i : right vector energy Q0*/ + Word16 *Density /* o : quantizer density Q0*/ ) { Word16 Rnrg, den, n; @@ -89,21 +92,21 @@ void obtainEnergyQuantizerDensity_fx( den = sub( shl( L, 1 ), 1 ); IF( LE_16( den, 67 ) ) { - Rnrg = extract_l( intLimCDivPos_fx( L_deposit_l( R ), den ) ); + Rnrg = extract_l( intLimCDivPos_fx( L_deposit_l( R ), den ) ); /* Q0 */ } ELSE { n = norm_s( den ); move16(); - Rnrg = shr( div_s( R, shl( den, n ) ), sub( 15, n ) ); + Rnrg = shr( div_s( R, shl( den, n ) ), sub( 15, n ) ); /* n */ } - Rnrg = add( Rnrg, 28 ); + Rnrg = add( Rnrg, 28 ); /* Q0 */ - Rnrg = s_min( Rnrg, 56 ); - Rnrg = s_min( Rnrg, sub( R, 96 ) ); + Rnrg = s_min( Rnrg, 56 ); /* Q0 */ + Rnrg = s_min( Rnrg, sub( R, 96 ) ); /* Q0 */ Rnrg = s_max( Rnrg, 3 ); - *Density = obtainEnergyQuantizerDensity_f[Rnrg]; + *Density = obtainEnergyQuantizerDensity_f[Rnrg]; /* Q0 */ move16(); return; } @@ -115,21 +118,21 @@ void obtainEnergyQuantizerDensity_fx( * *-------------------------------------------------------------------*/ void dsDirac2Dirac_fx( - const Word16 dsDiracIndex, /* i : input index */ - Word16 *diracs /* o : number of diracs */ + const Word16 dsDiracIndex, /* i : input index Q0*/ + Word16 *diracs /* o : number of diracs Q0*/ ) { - *diracs = dsDiracsTab[dsDiracIndex]; + *diracs = dsDiracsTab[dsDiracIndex]; /* Q0 */ move16(); return; } void dsDiracPerQuanta_fx( - const Word16 td, /* i : Length of vector segment */ - const Word16 t_quanta, /* i : Assigned number of quanta */ - const Word16 dsm, /* i : Conservative rounding flag */ - const unsigned char *const *frQuanta, /* i : Quanta lookup table */ - Word16 *DsIdx /* o : Lookup table index */ + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 t_quanta, /* i : Assigned number of quanta Q0*/ + const Word16 dsm, /* i : Conservative rounding flag Q0*/ + const unsigned char *const *frQuanta, /* i : Quanta lookup table */ + Word16 *DsIdx /* o : Lookup table index Q0*/ ) { const unsigned char *sv; @@ -138,55 +141,55 @@ void dsDiracPerQuanta_fx( Word16 dsIndex; Word16 i; - sv = frQuanta[td]; + sv = frQuanta[td]; /* Q0 */ nsv = sv[0]; move16(); - t_quanta_o = sub( t_quanta, QUANTAQ3OFFSET ); + t_quanta_o = sub( t_quanta, QUANTAQ3OFFSET ); /* Q0 */ IF( GE_16( t_quanta_o, sv[nsv] ) ) { - *DsIdx = nsv; + *DsIdx = nsv; /* Q0 */ move16(); return; } IF( LE_16( t_quanta_o, sv[1] ) ) { - *DsIdx = 1; + *DsIdx = 1; /* Q0 */ move16(); return; } - dsIndex = shl( 1, frQuanta[0][td] ); - IF( GT_16( t_quanta_o, sv[shr( nsv, 1 )] ) ) + dsIndex = shl( 1, frQuanta[0][td] ); /* Q0 */ + IF( GT_16( t_quanta_o, sv[nsv >> 1] ) ) { - dsIndex = sub( nsv, dsIndex ); + dsIndex = sub( nsv, dsIndex ); /* Q0 */ } FOR( i = frQuanta[0][td] - 1; i >= 0; i-- ) { - dsIndex = add( dsIndex, shl( sub( shl( lshr( sub( sv[dsIndex], t_quanta_o ), 15 ), 1 ), 1 ), i ) ); + dsIndex = add( dsIndex, shl( sub( shl( lshr( sub( sv[dsIndex], t_quanta_o ), 15 ), 1 ), 1 ), i ) ); /* Q0 */ } - dsIndex = add( dsIndex, lshr( sub( sv[dsIndex], t_quanta_o ), 15 ) ); - dsIndex = sub( dsIndex, lshr( sub( 1, dsIndex ), 15 ) ); + dsIndex = add( dsIndex, lshr( sub( sv[dsIndex], t_quanta_o ), 15 ) ); /* Q0 */ + dsIndex = sub( dsIndex, lshr( sub( 1, dsIndex ), 15 ) ); /* Q0 */ if ( EQ_16( dsm, PVQ_CONS ) ) { - *DsIdx = dsIndex; + *DsIdx = dsIndex; /* Q0 */ move16(); return; } - *DsIdx = add( dsIndex, lshr( sub( add( sv[add( dsIndex, 1 )], sv[dsIndex] ), shl( t_quanta_o, 1 ) ), 15 ) ); + *DsIdx = add( dsIndex, lshr( sub( add( sv[dsIndex + 1], sv[dsIndex] ), shl( t_quanta_o, 1 ) ), 15 ) ); /* Q0 */ move16(); return; } void QuantaPerDsDirac_fx( - const Word16 td, /* i : Length of vector segment */ - const Word16 dsDiracIndex, /* i : Quanta table index */ - const unsigned char *const *dimFrQuanta, /* i : Quanta lookup table */ - Word16 *Quanta /* i : Quanta */ + const Word16 td, /* i : Length of vector segment Q0*/ + const Word16 dsDiracIndex, /* i : Quanta table index Q0*/ + const unsigned char *const *dimFrQuanta, /* i : Quanta lookup table */ + Word16 *Quanta /* i : Quanta Q0*/ ) { *Quanta = dimFrQuanta[td][dsDiracIndex]; @@ -196,22 +199,22 @@ void QuantaPerDsDirac_fx( *Quanta = -1; /* single op */ move16(); } - *Quanta = add( *Quanta, QUANTAQ3OFFSET ); + *Quanta = add( *Quanta, QUANTAQ3OFFSET ); /* Q0 */ move16(); return; } void conservativeL1Norm_fx( - const Word16 L, /* i : Length of vector segment */ - const Word16 Qvec, /* i : Assigned number of quanta */ - const Word16 Fcons, /* i : Conservative rounding flag */ - const Word16 Qavail, /* i : Input quanta remaining */ - const Word16 Qreserv, /* i : Input quanta in reservoir */ - const Word16 Dspec, /* i : assigned diracs from bitalloc */ - Word16 *Dvec, /* o : actual number of diracs */ - Word16 *Qspare, /* o : Output quanta remaining */ - Word16 *Qreservplus, /* o : Output quanta in reservoir */ - Word16 *Dspecplus /* o : Output number of diracs */ + const Word16 L, /* i : Length of vector segment Q0*/ + const Word16 Qvec, /* i : Assigned number of quanta Q0*/ + const Word16 Fcons, /* i : Conservative rounding flag Q0*/ + const Word16 Qavail, /* i : Input quanta remaining Q0*/ + const Word16 Qreserv, /* i : Input quanta in reservoir Q0*/ + const Word16 Dspec, /* i : assigned diracs from bitalloc Q0*/ + Word16 *Dvec, /* o : actual number of diracs Q0*/ + Word16 *Qspare, /* o : Output quanta remaining Q0*/ + Word16 *Qreservplus, /* o : Output quanta in reservoir Q0*/ + Word16 *Dspecplus /* o : Output number of diracs Q0*/ ) { @@ -221,7 +224,7 @@ void conservativeL1Norm_fx( frQuantaL = hBitsN[L]; - *Qreservplus = add( Qreserv, sub( Qvec, QUANTAQ3OFFSET ) ); + *Qreservplus = add( Qreserv, sub( Qvec, QUANTAQ3OFFSET ) ); /* Q0 */ move16(); dsDiracPerQuanta_fx( L, Qvec, Fcons, hBitsN, &Minit ); @@ -229,26 +232,26 @@ void conservativeL1Norm_fx( move16(); DO { - Qtestminus = (short) frQuantaL[Mprime]; + Qtestminus = (Word16) frQuantaL[Mprime]; move16(); - *Qspare = sub( Qavail, Qtestminus ); + *Qspare = sub( Qavail, Qtestminus ); /* Q0 */ move16(); - Mprime = sub( Mprime, 1 ); + Mprime = sub( Mprime, 1 ); /* Q0 */ } WHILE( ( Mprime >= 0 ) && LT_16( *Qspare, QUANTAQ3OFFSET ) ); if ( Mprime < 0 ) { - *Qspare = add( Qavail, QUANTAQ3OFFSET ); /* single op */ + *Qspare = add( Qavail, QUANTAQ3OFFSET ); /* single op Q0*/ move16(); } dsDirac2Dirac_fx( add( Mprime, 1 ), Dvec ); - *Dspecplus = add( Dspec, *Dvec ); + *Dspecplus = add( Dspec, *Dvec ); /* Q0 */ move16(); - *Qreservplus = sub( *Qreservplus, (short) frQuantaL[Minit] ); + *Qreservplus = sub( *Qreservplus, (Word16) frQuantaL[Minit] ); /* Q0 */ move16(); - *Qspare = sub( *Qspare, QUANTAQ3OFFSET ); + *Qspare = sub( *Qspare, QUANTAQ3OFFSET ); /* Q0 */ move16(); return; @@ -256,17 +259,17 @@ void conservativeL1Norm_fx( void bandBitsAdjustment_fx( - const Word16 Brc, /* i : Current number of read quanta in range coder */ - const UWord32 INTrc, /* i : Range coder state */ - const Word16 Bavail, /* i : Available number of quanta */ - const Word16 Nbands, /* i : Number of bands */ - const Word16 D, /* i : Remaining number of bands to encode */ - const Word16 L, /* i : Size of current band */ - const Word16 Bband, /* i : Quanta allocation for current band */ - const Word16 Breserv, /* i : Quanta reservoir */ - Word16 *Bband_adj, /* o : Actual used number of quanta */ - Word16 *Brem, /* o : Quanta remaining */ - Word16 *Breservplus /* o : Quanta pool size */ + const Word16 Brc, /* i : Current number of read quanta in range coder Q0*/ + const UWord32 INTrc, /* i : Range coder state Q0*/ + const Word16 Bavail, /* i : Available number of quanta Q3*/ + const Word16 Nbands, /* i : Number of bands Q0*/ + const Word16 D, /* i : Remaining number of bands to encode Q0*/ + const Word16 L, /* i : Size of current band Q0*/ + const Word16 Bband, /* i : Quanta allocation for current band Q0*/ + const Word16 Breserv, /* i : Quanta reservoir Q0*/ + Word16 *Bband_adj, /* o : Actual used number of quanta Q0*/ + Word16 *Brem, /* o : Quanta remaining Q0*/ + Word16 *Breservplus /* o : Quanta pool size Q0*/ ) { Word16 Btemp; @@ -277,25 +280,25 @@ void bandBitsAdjustment_fx( IF( LT_16( D, Nbands ) ) { - L_tmp = L_deposit_l( sub( Breserv, Bff ) ); - Btemp = extract_l( intLimCDivSigned_fx( L_tmp, s_min( D, 3 ) ) ); /* result always fits in Word16 */ - *Breservplus = add( Bband, Breserv ); + L_tmp = L_deposit_l( sub( Breserv, Bff ) ); /* Q0 */ + Btemp = extract_l( intLimCDivSigned_fx( L_tmp, s_min( D, 3 ) ) ); /* result always fits in Word16 Q0*/ + *Breservplus = add( Bband, Breserv ); /* Q0 */ move16(); } ELSE { Btemp = 0; move16(); - *Breservplus = add( Bband, Bff ); + *Breservplus = add( Bband, Bff ); /* Q0 */ move16(); } - *Bband_adj = s_min( extract_l( L_mult( L, 40 ) ), Bband ); + *Bband_adj = s_min( extract_l( L_mult( L, 40 ) ), Bband ); /* Q3 */ move16(); - *Brem = sub( Bavail, Bff ); + *Brem = sub( Bavail, Bff ); /* Q0 */ move16(); - *Bband_adj = s_min( *Brem, add( *Bband_adj, Btemp ) ); + *Bband_adj = s_min( *Brem, add( *Bband_adj, Btemp ) ); /* Q0 */ move16(); - *Bband_adj = s_max( 0, *Bband_adj ); + *Bband_adj = s_max( 0, *Bband_adj ); /* Q0 */ move16(); return; } @@ -321,38 +324,38 @@ static Word16 Ratio_base2Q11_fx( /* o : Q11 */ d = sub( ms, mc ); /* d in Q15 */ z = mult_r( z, d ); /* z in Q11 */ - result = add( z, shl( sub( nc, ns ), 11 ) ); + result = add( z, shl( sub( nc, ns ), 11 ) ); /* Q11 */ return result; } static void Ratio_rQ3_fx( - Word16 opp, /* i : opposite */ - Word16 near, /* i : near */ - Word16 *result /* o : ratio */ + Word16 opp, /* i : opposite Q15*/ + Word16 near, /* i : near Q15*/ + Word16 *result /* o : ratio Q3*/ ) { Word16 tmp; - tmp = add( 1 << 7, Ratio_base2Q11_fx( opp, near ) ); - *result = shr( tmp, 8 ); + tmp = add( 1 << 7, Ratio_base2Q11_fx( opp, near ) ); /* Q11 */ + *result = shr( tmp, 8 ); /* Q3 */ move16(); return; } void densityAngle2RmsProjDec_fx( - const Word16 D, /* i : density */ - const Word16 indexphi, /* i : decoded index from AR dec */ - Word16 *oppQ15, /* o : opposite */ - Word16 *nearQ15, /* o : near */ - Word16 *oppRatioQ3 /* o : ratio */ + const Word16 D, /* i : density Q0*/ + const Word16 indexphi, /* i : decoded index from AR dec Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ ) { Word16 phiQ14q; Word16 oppTail, nearTail; - phiQ14q = (Word16) intLimCDivPos_fx( (UWord32) L_shl( L_deposit_l( indexphi ), 13 ), shr( D, 1 ) ); + phiQ14q = (Word16) intLimCDivPos_fx( (UWord32) L_shl( L_deposit_l( indexphi ), 13 ), shr( D, 1 ) ); /* Q14 */ move16(); if ( indexphi < 0 ) { @@ -365,11 +368,11 @@ void densityAngle2RmsProjDec_fx( IF( s_or( oppTail, nearTail ) < 0 ) { - *oppQ15 = s_and( oppTail, ( 1 << 15 ) - 1 ); + *oppQ15 = s_and( oppTail, ( 1 << 15 ) - 1 ); /* Q15 */ move16(); - *nearQ15 = s_and( nearTail, ( 1 << 15 ) - 1 ); + *nearQ15 = s_and( nearTail, ( 1 << 15 ) - 1 ); /* Q15 */ move16(); - *oppRatioQ3 = shl( add( 1, shl( nearTail, 1 ) ), 14 ); + *oppRatioQ3 = shl( add( 1, shl( nearTail, 1 ) ), 14 ); /* Q3 */ move16(); } ELSE @@ -383,15 +386,15 @@ void densityAngle2RmsProjDec_fx( } void densityAngle2RmsProjEnc_fx( - const Word16 D, /* i : density */ - const Word16 phiQ14uq, /* i : angle */ - Word16 *indexphi, /* o : index */ - Word16 *oppQ15, /* o : opposite */ - Word16 *nearQ15, /* o : near */ - Word16 *oppRatioQ3 /* o : ratio */ + const Word16 D, /* i : density Q0*/ + const Word16 phiQ14uq, /* i : angle Q14*/ + Word16 *indexphi, /* o : index Q0*/ + Word16 *oppQ15, /* o : opposite Q15*/ + Word16 *nearQ15, /* o : near Q15*/ + Word16 *oppRatioQ3 /* o : ratio Q3*/ ) { - *indexphi = mult_r( shl( D, 1 ), phiQ14uq ); + *indexphi = mult_r( shl( D, 1 ), phiQ14uq ); /* Q0 */ move16(); if ( s_and( D, 1 ) > 0 ) { @@ -404,21 +407,21 @@ void densityAngle2RmsProjEnc_fx( } void NearOppSplitAdjustment_fx( - const Word16 qband, /* i : quanta for current band */ - const Word16 qzero, /* i : range coder finalization quanta */ - const Word16 Qac, /* i : range coder current quanta */ - const UWord32 INTac, /* i : range coder state */ - const Word16 qglobal, /* i : quanta input */ - const Word16 FlagCons, /* i : conservative rounding flag */ - const Word16 Np, /* i : number of parts */ - const Word16 Nhead, /* i : first part */ - const Word16 Ntail, /* i : remaining parts */ - const Word16 Nnear, /* i : length of near component */ - const Word16 Nopp, /* i : length of opposite component */ - Word16 oppRQ3, /* i : ratio */ - Word16 *qnear, /* o : quantized near */ - Word16 *qopp, /* o : quantized opposite */ - Word16 *qglobalupd /* o : quanta remaining */ + const Word16 qband, /* i : quanta for current band Q0*/ + const Word16 qzero, /* i : range coder finalization quanta Q0*/ + const Word16 Qac, /* i : range coder current quanta Q0*/ + const UWord32 INTac, /* i : range coder state Q0*/ + const Word16 qglobal, /* i : quanta input Q0*/ + const Word16 FlagCons, /* i : conservative rounding flag Q0*/ + const Word16 Np, /* i : number of parts Q0*/ + const Word16 Nhead, /* i : first part Q0*/ + const Word16 Ntail, /* i : remaining parts Q0*/ + const Word16 Nnear, /* i : length of near component Q0*/ + const Word16 Nopp, /* i : length of opposite component Q0*/ + Word16 oppRQ3, /* i : ratio Q0*/ + Word16 *qnear, /* o : quantized near Q0*/ + Word16 *qopp, /* o : quantized opposite Q0*/ + Word16 *qglobalupd /* o : quanta remaining Q0*/ ) { @@ -427,45 +430,46 @@ void NearOppSplitAdjustment_fx( Word16 QIb, QIa; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move32(); #endif rangeCoderFinalizationFBits_fx( Qac, INTac, &qac ); - qboth = sub( qband, sub( qac, qzero ) ); + qboth = sub( qband, sub( qac, qzero ) ); /* Q0 */ /* skew calc code */ qskew = 0; move16(); IF( GT_16( Nhead, 1 ) ) { - qavg = extract_h( L_shl( intLimCDivSigned_fx( L_deposit_l( qboth ), Np ), 16 ) ); /* qboth may be negative */ + qavg = extract_h( L_shl( intLimCDivSigned_fx( L_deposit_l( qboth ), Np ), 16 ) ); /* qboth may be negative Q0*/ dsDiracPerQuanta_fx( Ntail, qavg, FlagCons, hBitsN, &Midx ); QuantaPerDsDirac_fx( Nhead, Midx, hBitsN, &qmin ); - qskew = sub( qavg, qmin ); - qskew = s_max( 0, qskew ); - } /* end of skew calc code*/ + qskew = sub( qavg, qmin ); /* Q0 */ + qskew = s_max( 0, qskew ); /* Q0 */ + } /* end of skew calc code*/ - QIa = add( extract_l( intLimCDivPos_fx( (UWord32) L_deposit_l( Nopp ), Nnear ) ), 1 ); /* always positive Word16 out */ - L_qnum = L_sub( L_deposit_l( sub( sub( add( qband, qzero ), qac ), qskew ) ), L_mult0( Nopp, oppRQ3 ) ); + QIa = add( extract_l( intLimCDivPos_fx( (UWord32) L_deposit_l( Nopp ), Nnear ) ), 1 ); /* always positive Word16 out Q0*/ + L_qnum = L_sub( L_deposit_l( sub( sub( add( qband, qzero ), qac ), qskew ) ), L_mult0( Nopp, oppRQ3 ) ); /* Q0 */ L_QIb = L_deposit_l( 0 ); IF( L_qnum > 0 ) { - L_QIb = (Word32) intLimCDivPos_fx( L_qnum, QIa ); + L_QIb = (Word32) intLimCDivPos_fx( L_qnum, QIa ); /* Q0 */ } - *qnear = qboth; + *qnear = qboth; /* Q3 */ move16(); #ifdef BASOP_NOGLOB - QIb = extract_h( L_shl_o( L_QIb, 16, &Overflow ) ); /* may saturate */ + QIb = extract_h( L_shl_o( L_QIb, 16, &Overflow ) ); /* may saturate Q0*/ #else QIb = extract_h( L_shl( L_QIb, 16 ) ); /* may saturate */ #endif if ( LE_16( QIb, qboth ) ) { - *qnear = QIb; + *qnear = QIb; /* Q0 */ move16(); } - *qopp = sub( qboth, *qnear ); + *qopp = sub( qboth, *qnear ); /* Q0 */ move16(); - *qglobalupd = sub( qglobal, sub( qac, qzero ) ); + *qglobalupd = sub( qglobal, sub( qac, qzero ) ); /* Q0 */ move16(); return; @@ -479,10 +483,10 @@ void NearOppSplitAdjustment_fx( *--------------------------------------------------------------------------*/ void apply_gain_fx( - const Word16 *ord, /* i : Indices for energy order */ - const Word16 *band_start, /* i : Sub band start indices */ - const Word16 *band_end, /* i : Sub band end indices */ - const Word16 num_sfm, /* i : Number of bands */ + 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 Q12 */ Word16 *xq /* i/o: Float synthesis / Gain adjusted synth Q15/Q12 */ ) @@ -512,10 +516,10 @@ void apply_gain_fx( *--------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED void fine_gain_quant_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order */ - const Word16 num_sfm, /* i : Number of bands */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ const Word16 *gopt /* i : Optimal gains Q12 */ ) @@ -536,7 +540,7 @@ void fine_gain_quant_ivas_fx( FOR( band = 0; band < num_sfm; band++ ) { - gbits = gain_bits[ord[band]]; + gbits = gain_bits[ord[band]]; /* Q0 */ move16(); test(); IF( fg_pred[band] != 0 && gbits > 0 ) @@ -545,9 +549,9 @@ void fine_gain_quant_ivas_fx( exp1 = sub( exp1, 1 ); tmp1 = shl( gopt[band], exp1 ); exp2 = norm_s( fg_pred[band] ); - tmp2 = shl( fg_pred[band], exp2 ); + tmp2 = shl( fg_pred[band], exp2 ); /* Q12 + exp2 */ exp1 = add( 15, sub( exp1, exp2 ) ); - err = div_s( tmp1, tmp2 ); + err = div_s( tmp1, tmp2 ); /* Q15 */ tmp1 = norm_s( err ); exp2 = Log2_norm_lc( L_deposit_h( shl( err, tmp1 ) ) ); tmp1 = sub( 14, tmp1 ); @@ -555,16 +559,16 @@ void fine_gain_quant_ivas_fx( L_tmp = L_Comp( tmp1, exp2 ); Mpy_32_16_ss( L_tmp, 24660, &L_tmp, &lsb ); /* 24660 = 20*log10(2) in Q12 */ /*16+12-15=13 */ #ifdef BASOP_NOGLOB - gain_db = round_fx_sat( L_shl_o( L_tmp, 17, &Overflow ) ); -#else /* BASOP_NOGLOB */ + gain_db = round_fx_sat( L_shl_o( L_tmp, 17, &Overflow ) ); /* Q14 */ +#else /* BASOP_NOGLOB */ gain_db = round_fx( L_shl( L_tmp, 17 ) ); #endif - idx = squant_fx( gain_db, &gain_dbq, finegain_fx[gbits - 1], gain_cb_size[gbits - 1] ); + idx = squant_fx( gain_db, &gain_dbq, finegain_fx[gbits - 1], gain_cb_size[gbits - 1] ); /* Q0 */ push_indice( hBstr, IND_PVQ_FINE_GAIN, idx, gbits ); L_tmp = L_mult0( gain_dbq, 21771 ); /* 21771=0.05*log2(10) */ /* 14+17=31 */ - L_tmp = L_shr( L_tmp, 15 ); + L_tmp = L_shr( L_tmp, 15 ); /* Q16 */ tmp1 = L_Extract_lc( L_tmp, &exp1 ); tmp1 = abs_s( tmp1 ); tmp1 = extract_l( Pow2( 14, tmp1 ) ); @@ -580,10 +584,10 @@ void fine_gain_quant_ivas_fx( } #endif void fine_gain_quant_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 *ord, /* i : Indices for energy order */ - const Word16 num_sfm, /* i : Number of bands */ - const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 *ord, /* i : Indices for energy order Q0 */ + const Word16 num_sfm, /* i : Number of bands Q0 */ + const Word16 *gain_bits, /* i : Gain adjustment bits per sub band Q0 */ Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */ const Word16 *gopt /* i : Optimal gains Q12 */ ) @@ -604,7 +608,7 @@ void fine_gain_quant_fx( FOR( band = 0; band < num_sfm; band++ ) { - gbits = gain_bits[ord[band]]; + gbits = gain_bits[ord[band]]; /* Q0 */ move16(); test(); IF( fg_pred[band] != 0 && gbits > 0 ) @@ -613,9 +617,9 @@ void fine_gain_quant_fx( exp1 = sub( exp1, 1 ); tmp1 = shl( gopt[band], exp1 ); exp2 = norm_s( fg_pred[band] ); - tmp2 = shl( fg_pred[band], exp2 ); + tmp2 = shl( fg_pred[band], exp2 ); /* Q12 + exp2 */ exp1 = add( 15, sub( exp1, exp2 ) ); - err = div_s( tmp1, tmp2 ); + err = div_s( tmp1, tmp2 ); /* Q15 */ tmp1 = norm_s( err ); exp2 = Log2_norm_lc( L_deposit_h( shl( err, tmp1 ) ) ); tmp1 = sub( 14, tmp1 ); @@ -632,7 +636,7 @@ void fine_gain_quant_fx( push_indice_fx( hBstr, IND_PVQ_FINE_GAIN, idx, gbits ); L_tmp = L_mult0( gain_dbq, 21771 ); /* 21771=0.05*log2(10) */ /* 14+17=31 */ - L_tmp = L_shr( L_tmp, 15 ); + L_tmp = L_shr( L_tmp, 15 ); /* Q16 */ tmp1 = L_Extract_lc( L_tmp, &exp1 ); tmp1 = abs_s( tmp1 ); tmp1 = extract_l( Pow2( 14, tmp1 ) ); @@ -654,10 +658,11 @@ void fine_gain_quant_fx( *-------------------------------------------------------------------*/ void srt_vec_ind16_fx( - const Word16 *linear, /* linear input */ - Word16 *srt, /* sorted output*/ - Word16 *I, /* index for sorted output */ - Word16 length ) + const Word16 *linear, /* linear input Q3*/ + Word16 *srt, /* sorted output Q3*/ + Word16 *I, /* index for sorted output Q0*/ + Word16 length /* Q0 */ +) { Word16 pos, npos; Word16 idxMem; @@ -666,11 +671,11 @@ void srt_vec_ind16_fx( /*initilize */ FOR( pos = 0; pos < length; pos++ ) { - I[pos] = pos; + I[pos] = pos; /* Q0 */ move16(); } - Copy( linear, srt, length ); + Copy( linear, srt, length ); /* Q3 */ /* now iterate */ FOR( pos = 0; pos < ( length - 1 ); pos++ ) @@ -679,18 +684,18 @@ void srt_vec_ind16_fx( { IF( LT_16( srt[npos], srt[pos] ) ) { - idxMem = I[pos]; + idxMem = I[pos]; /* Q0 */ move16(); - I[pos] = I[npos]; + I[pos] = I[npos]; /* Q0 */ move16(); - I[npos] = idxMem; + I[npos] = idxMem; /* Q0 */ move16(); - valMem = srt[pos]; + valMem = srt[pos]; /* Q0 */ move16(); - srt[pos] = srt[npos]; + srt[pos] = srt[npos]; /* Q0 */ move16(); - srt[npos] = valMem; + srt[npos] = valMem; /* Q0 */ move16(); } } diff --git a/lib_com/range_com_fx.c b/lib_com/range_com_fx.c index 3eebfa3c961015db21670913d26108ab5d6ea110..b84ec6c26756c7fa5aa080d2300971f81f3475e4 100644 --- a/lib_com/range_com_fx.c +++ b/lib_com/range_com_fx.c @@ -13,9 +13,9 @@ * Get number of bits needed to finalize range coder *-------------------------------------------------------------------*/ -Word16 rc_get_bits2_fx( /* o: Number of bits needed */ - const Word16 N, /* i: Number of bits currently used */ - const UWord32 range /* i: Range of range coder */ +Word16 rc_get_bits2_fx( /* o: Number of bits needed Q0*/ + const Word16 N, /* i: Number of bits currently used Q0*/ + const UWord32 range /* i: Range of range coder Q0*/ ) { return add( add( N, 2 ), norm_ul( range ) ); @@ -28,24 +28,24 @@ Word16 rc_get_bits2_fx( /* o: Number of bits needed *-------------------------------------------------------------------*/ void rangeCoderFinalizationFBits_fx( - Word16 Brc, /* i : Current number of decoded bits */ - UWord32 INTrc, /* i : Range coder state */ - Word16 *FBits /* i : Fractional finalization bits */ + Word16 Brc, /* i : Current number of decoded bits Q0*/ + UWord32 INTrc, /* i : Range coder state Q0*/ + Word16 *FBits /* i : Fractional finalization bits Q0*/ ) { Word32 L_Bq15; UWord32 h, UL_tmp; UWord16 Bq15ui16, l; Word16 B, E, x, k; - *FBits = shl( add( Brc, 32 ), 3 ); + *FBits = shl( add( Brc, 32 ), 3 ); /* Q0 */ - B = sub( 30, norm_ul( INTrc ) ); - x = sub( B, RCF_INIT_SHIFT ); + B = sub( 30, norm_ul( INTrc ) ); /* Q0 */ + x = sub( B, RCF_INIT_SHIFT ); /* Q0 */ L_Bq15 = 0; move16(); if ( x >= 0 ) { - L_Bq15 = (Word32) UL_lshr( INTrc, x ); + L_Bq15 = (Word32) UL_lshr( INTrc, x ); /* Q0 */ move32(); } @@ -53,16 +53,16 @@ void rangeCoderFinalizationFBits_fx( move16(); FOR( k = 1; k < 4; k++ ) { - Bq15ui16 = u_extract_l( L_shr( L_Bq15, s_and( E, 1 ) ) ); - UL_tmp = UL_lshl( UL_deposit_l( Bq15ui16 ), 1 ); - Mpy_32_16_uu( UL_tmp, Bq15ui16, &h, &l ); + Bq15ui16 = u_extract_l( L_shr( L_Bq15, s_and( E, 1 ) ) ); /* Q0 */ + UL_tmp = UL_lshl( UL_deposit_l( Bq15ui16 ), 1 ); /* Q0 */ + Mpy_32_16_uu( UL_tmp, Bq15ui16, &h, &l ); /* Q0 */ L_Bq15 = (Word32) h; move32(); - E = add( shl( B, 1 ), extract_l( L_lshr( L_sub( ( ( 1L << 16 ) - 1L ), L_Bq15 ), 31 ) ) ); + E = add( shl( B, 1 ), extract_l( L_lshr( L_sub( ( ( 1L << 16 ) - 1L ), L_Bq15 ), 31 ) ) ); /* Q0 */ B = E; move16(); } - *FBits = sub( *FBits, B ); + *FBits = sub( *FBits, B ); /* Q0 */ move16(); return; } diff --git a/lib_com/re8_ppv_fx.c b/lib_com/re8_ppv_fx.c index f330f22c2070006ab76240ea118b83e868c1ce10..c643bf1ea21c69568e61b3a6b8e0b939d1a609ff 100644 --- a/lib_com/re8_ppv_fx.c +++ b/lib_com/re8_ppv_fx.c @@ -24,8 +24,8 @@ static Word32 compute_error_2D8_fx( const Word32 x[], const Word16 y[] ); * --------------------------------------------------------------*/ void re8_PPV_fx( - const Word32 x[], /* i : point in R^8Q15 */ - Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */ + const Word32 x[], /* i : point in R^8 Q15 */ + Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0*/ ) { Word16 i, y0[8]; @@ -42,14 +42,14 @@ void re8_PPV_fx( FOR( i = 0; i < 8; i++ ) { - x1[i] = L_sub( x[i], QR ); + x1[i] = L_sub( x[i], QR ); /* Q15 */ move32(); } nearest_neighbor_2D8_fx( x1, y ); FOR( i = 0; i < 8; i++ ) { - y[i] = add( y[i], 1 ); + y[i] = add( y[i], 1 ); /* Q0 */ move16(); } @@ -66,7 +66,7 @@ void re8_PPV_fx( *--------------------------------------------------------------*/ IF( LT_32( e0, e1 ) ) { - Copy( y0, y, 8 ); + Copy( y0, y, 8 ); /* Q0 */ } return; @@ -83,8 +83,8 @@ void re8_PPV_fx( --------------------------------------------------------------*/ static void nearest_neighbor_2D8_fx( - const Word32 x[], /* i : point in R^8 */ - Word16 y[] /* o : point in 2D8 (8-dimensional integer vector) */ + const Word32 x[], /* i : point in R^8 Q15*/ + Word16 y[] /* o : point in 2D8 (8-dimensional integer vector) Q0*/ ) { Word16 i, j; @@ -103,10 +103,10 @@ static void nearest_neighbor_2D8_fx( { /* round to ..., -2, 0, 2, ... ([-1..1[ --> 0) */ tmp16 = round_fx( L_add( x[i], L_shr( x[i], 31 ) ) ); - y[i] = shl( tmp16, 1 ); + y[i] = shl( tmp16, 1 ); /* Q0 */ move16(); /* sum += y[i] */ - sum = add( sum, y[i] ); + sum = add( sum, y[i] ); /* Q0 */ } /*--------------------------------------------------------------* @@ -126,7 +126,7 @@ static void nearest_neighbor_2D8_fx( { /* compute ei = xi-yi */ /* e[i]=x[i]-y[i] */ - e = L_msu( x[i], y[i], QR / 2 ); + e = L_msu( x[i], y[i], QR / 2 ); /* Q15 */ /* compute |ei| = | xi-yi | */ s = L_abs( e ); @@ -137,19 +137,19 @@ static void nearest_neighbor_2D8_fx( j = i; move16(); } - em = L_max( s, em ); + em = L_max( s, em ); /* Q15 */ } /* round xj in the "wrong way" */ - e = L_msu( x[j], y[j], QR / 2 ); + e = L_msu( x[j], y[j], QR / 2 ); /* Q15 */ tmp16 = extract_h( e ); - tmp16b = add( y[j], 2 ); + tmp16b = add( y[j], 2 ); /* Q0 */ if ( tmp16 < 0 ) { - tmp16b = sub( tmp16b, 2 + 2 ); + tmp16b = sub( tmp16b, 2 + 2 ); /* Q0 */ } - y[j] = tmp16b; + y[j] = tmp16b; /* Q0 */ move16(); } @@ -164,9 +164,9 @@ static void nearest_neighbor_2D8_fx( * (quantized) point in 2D8. --------------------------------------------------------------*/ -static Word32 compute_error_2D8_fx( /* o : mean squared error */ - const Word32 x[], /* i : input vector */ - const Word16 y[] /* i : point in 2D8 (8-dimensional integer vector) */ +static Word32 compute_error_2D8_fx( /* o : mean squared error Q15*/ + const Word32 x[], /* i : input vector Q15*/ + const Word16 y[] /* i : point in 2D8 (8-dimensional integer vector) Q0*/ ) { Word16 i, hi, lo; @@ -176,17 +176,17 @@ static Word32 compute_error_2D8_fx( /* o : mean squared error FOR( i = 0; i < 8; i++ ) { /*tmp = x[i]-y[i];*/ - Ltmp = L_msu( x[i], y[i], 16384 ); - hi = extract_h( L_shl( Ltmp, 1 ) ); - lo = extract_l( L_msu( Ltmp, hi, 16384 ) ); + Ltmp = L_msu( x[i], y[i], 16384 ); /* Q15 */ + hi = extract_h( L_shl( Ltmp, 1 ) ); /* Q0 */ + lo = extract_l( L_msu( Ltmp, hi, 16384 ) ); /* Q15 */ - Ltmp = L_mult( hi, hi ); - Ltmp = L_shl( Ltmp, 14 ); - Ltmp = L_mac( Ltmp, hi, lo ); - Ltmp = L_mac0( Ltmp, mult( lo, lo ), 1 ); + Ltmp = L_mult( hi, hi ); /* Q1 */ + Ltmp = L_shl( Ltmp, 14 ); /* Q15 */ + Ltmp = L_mac( Ltmp, hi, lo ); /* Q15 */ + Ltmp = L_mac0( Ltmp, mult( lo, lo ), 1 ); /* Q15 */ /* err+=tmp*tmp */ - err = L_add( Ltmp, err ); + err = L_add( Ltmp, err ); /* Q15 */ } return ( err ); diff --git a/lib_com/re8_util_fx.c b/lib_com/re8_util_fx.c index 00909e2f5b6a48602dc439213ba30568fb7b4a19..746b7152ba401e6ac47dc6c51966b9cd9dbbc99a 100644 --- a/lib_com/re8_util_fx.c +++ b/lib_com/re8_util_fx.c @@ -23,11 +23,11 @@ static void re8_coord_fx( const Word16 *y, Word16 *k ); * MULTI-RATE RE8 INDEXING BY VORONOI EXTENSION *----------------------------------------------------------------*/ void re8_vor_fx( - const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) */ - Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) */ - Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4*/ - Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c */ - Word16 *ka /* o : identifier of absolute leader (to index c) */ + const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) Q0*/ + Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) Q0*/ + Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4 Q0*/ + Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c Q0*/ + Word16 *ka /* o : identifier of absolute leader (to index c) Q0*/ ) { Word16 i, r, iter, ka_tmp, n_tmp, mask; @@ -45,14 +45,14 @@ void re8_vor_fx( * the absolute leader is identified by ka * - a translation table maps ka to the codebook number n) *----------------------------------------------------------------*/ - *ka = re8_identify_absolute_leader_fx( y ); + *ka = re8_identify_absolute_leader_fx( y ); /* Q0 */ move16(); /*----------------------------------------------------------------* * compute codebook number n of Qn (by table look-up) * at this stage, n=0,2,3,4 or out=100 *----------------------------------------------------------------*/ - *n = Da_nq[*ka]; + *n = Da_nq[*ka]; /* Q0 */ move16(); /*----------------------------------------------------------------* @@ -70,17 +70,17 @@ void re8_vor_fx( IF( LE_16( *n, 4 ) ) { - Copy( y, c, 8 ); + Copy( y, c, 8 ); /* Q0 */ } ELSE { /*------------------------------------------------------------* * initialize r and m=2^r based on || y ||^2/8 *------------------------------------------------------------*/ - Ltmp = L_mult( y[0], y[0] ); + Ltmp = L_mult( y[0], y[0] ); /* Q1 */ FOR( i = 1; i < 8; i++ ) { - Ltmp = L_mac( Ltmp, y[i], y[i] ); + Ltmp = L_mac( Ltmp, y[i], y[i] ); /* Q1 */ } Lsphere = L_shr( Ltmp, 5 + 1 ); /* *0.125*0.25 / 2 to remove L_mac effect */ @@ -99,7 +99,7 @@ void re8_vor_fx( /*------------------------------------------------------------* * compute m and the mask needed for modulo m (for Voronoi coding) *------------------------------------------------------------*/ - mask = sub( shl( 1, r ), 1 ); /* 0x0..011...1 */ + mask = sub( shl( 1, r ), 1 ); /* 0x0..011...1 Q0*/ /*------------------------------------------------------------* * find the minimal value of r (or equivalently of m) in 2 iterations @@ -112,7 +112,7 @@ void re8_vor_fx( *--------------------------------------------------------*/ FOR( i = 0; i < 8; i++ ) { - k_tmp[i] = s_and( k_mod[i], mask ); + k_tmp[i] = s_and( k_mod[i], mask ); /* Q0 */ move16(); } @@ -125,19 +125,19 @@ void re8_vor_fx( FOR( i = 0; i < 8; i++ ) { - c_tmp[i] = shr( sub( y[i], v[i] ), r ); + c_tmp[i] = shr( sub( y[i], v[i] ), r ); /* Q0 */ move16(); } /*--------------------------------------------------------* * verify if c_tmp is in Q2, Q3 or Q4 *--------------------------------------------------------*/ - ka_tmp = re8_identify_absolute_leader_fx( c_tmp ); + ka_tmp = re8_identify_absolute_leader_fx( c_tmp ); /* Q0 */ /*--------------------------------------------------------* * at this stage, n_tmp=2,3,4 or out = 100 -- n=0 is not possible *--------------------------------------------------------*/ - n_tmp = Da_nq[ka_tmp]; + n_tmp = Da_nq[ka_tmp]; /* Q0 */ move16(); IF( GT_16( n_tmp, 4 ) ) @@ -145,7 +145,7 @@ void re8_vor_fx( /*--------------------------------------------------------* * if c is not in Q2, Q3, or Q4 (i.e. n_tmp>4), use m = 2^(r+1) instead of 2^r *--------------------------------------------------------*/ - r = add( r, 1 ); + r = add( r, 1 ); /* Q0 */ mask = add( shl( mask, 1 ), 1 ); /* mask = m-1 <- this is less complex */ } ELSE @@ -156,23 +156,23 @@ void re8_vor_fx( * since Q2 is a subset of Q3, indicate n=3 instead of n=2 (this is because * for n>4, n=n'+2r with n'=3 or 4, so n'=2 is not valid) *--------------------------------------------------------*/ - n_tmp = s_max( n_tmp, 3 ); + n_tmp = s_max( n_tmp, 3 ); /* Q0 */ /*--------------------------------------------------------* * save current values into ka, n, k and c *--------------------------------------------------------*/ - *ka = ka_tmp; + *ka = ka_tmp; /* Q0 */ move16(); - *n = add( n_tmp, shl( r, 1 ) ); + *n = add( n_tmp, shl( r, 1 ) ); /* Q0 */ move16(); - Copy( k_tmp, k, 8 ); - Copy( c_tmp, c, 8 ); + Copy( k_tmp, k, 8 ); /* Q0 */ + Copy( c_tmp, c, 8 ); /* Q0 */ /*--------------------------------------------------------* * try m = 2^(r-1) instead of 2^r to be sure that m is minimal *--------------------------------------------------------*/ - r = sub( r, 1 ); - mask = shr( mask, 1 ); + r = sub( r, 1 ); /* Q0 */ + mask = shr( mask, 1 ); /* Q0 */ } } } @@ -187,9 +187,9 @@ void re8_vor_fx( * VORONOI INDEXING (INDEX DECODING) k -> y -------------------------------------------------------------------------*/ void re8_k2y_fx( - const Word16 *k, /* i : Voronoi index k[0..7] */ - const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) */ - Word16 *y /* o : 8-dimensional point y[0..7] in RE8 */ + const Word16 *k, /* i : Voronoi index k[0..7] Q0*/ + const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) Q0*/ + Word16 *y /* o : 8-dimensional point y[0..7] in RE8 Q0*/ ) { Word16 i, v[8], *ptr1, *ptr2, m_tmp, mm; @@ -204,29 +204,29 @@ void re8_k2y_fx( * [1 1 _ 1 1] * a=(2,0,...,0) *---------------------------------------------------------------*/ - m_tmp = sub( 15, m ); + m_tmp = sub( 15, m ); /* Q0 */ - Lsum = L_deposit_l( k[7] ); + Lsum = L_deposit_l( k[7] ); /* Q0 */ ytp[7] = Lsum; move32(); - z[7] = L_shl( Lsum, m_tmp ); - move32(); /* (int)(floor(y[7]*QR+0.5))>>m */ + z[7] = L_shl( Lsum, m_tmp ); /* m_tmp */ + move32(); /* (int)(floor(y[7]*QR+0.5))>>m */ FOR( i = 6; i >= 1; i-- ) { - Ltmp = L_deposit_l( shl( k[i], 1 ) ); - Lsum = L_add( Lsum, Ltmp ); - ytp[i] = L_add( ytp[7], Ltmp ); + Ltmp = L_deposit_l( shl( k[i], 1 ) ); /* Q0 */ + Lsum = L_add( Lsum, Ltmp ); /* Q0 */ + ytp[i] = L_add( ytp[7], Ltmp ); /* Q0 */ move32(); - z[i] = L_shl( ytp[i], m_tmp ); - move32(); /* (int)(floor(y[7]*QR+0.5))>>m */ + z[i] = L_shl( ytp[i], m_tmp ); /* m_tmp */ + move32(); /* (int)(floor(y[7]*QR+0.5))>>m */ } - Lsum = L_add( Lsum, L_deposit_l( shl( k[0], 2 ) ) ); + Lsum = L_add( Lsum, L_deposit_l( shl( k[0], 2 ) ) ); /* Q0 */ ytp[0] = Lsum; move32(); - z[0] = L_shl( L_sub( Lsum, 2 ), m_tmp ); - move32(); /* (int)(floor(y[7]*QR+0.5))>>m */ + z[0] = L_shl( L_sub( Lsum, 2 ), m_tmp ); /* m_tmp */ + move32(); /* (int)(floor(y[7]*QR+0.5))>>m */ /*---------------------------------------------------------------* * find nearest neighbor v of z in infinite RE8 @@ -236,15 +236,15 @@ void re8_k2y_fx( /*---------------------------------------------------------------* * compute y -= m v *---------------------------------------------------------------*/ - ptr1 = y; - ptr2 = v; + ptr1 = y; /* Q0 */ + ptr2 = v; /* Q0 */ mm = shr( shl( 1, m ), 1 ); /* shr to remove effect of L_mult in L_msu */ FOR( i = 0; i < 8; i++ ) { - Ltmp = L_msu( ytp[i], *ptr2++, mm ); - *ptr1++ = extract_l( Ltmp ); + Ltmp = L_msu( ytp[i], *ptr2++, mm ); /* Q0 */ + *ptr1++ = extract_l( Ltmp ); /* Q0 */ } return; @@ -258,8 +258,8 @@ void re8_k2y_fx( * SPECIFIES THE CODEBOOKS Q0, Q2, Q3 and Q4 -----------------------------------------------------------------------*/ -static Word16 re8_identify_absolute_leader_fx( /* o : integer indicating if y if in Q0, Q2, Q3 or Q4 (or if y is an outlier) */ - const Word16 y[] /* i : point in RE8 (8-dimensional integer vector) */ +static Word16 re8_identify_absolute_leader_fx( /* o : integer indicating if y if in Q0, Q2, Q3 or Q4 (or if y is an outlier) Q0*/ + const Word16 y[] /* i : point in RE8 (8-dimensional integer vector) Q0*/ ) { Word16 i, s, id, nb, pos, ka, tmp16; @@ -270,10 +270,10 @@ static Word16 re8_identify_absolute_leader_fx( /* o : integer i /*-----------------------------------------------------------------------* * compute the RE8 shell number s = (y1^2+...+y8^2)/8 and C=(y1^2, ..., y8^2) *-----------------------------------------------------------------------*/ - Ls = L_mult( y[0], y[0] ); + Ls = L_mult( y[0], y[0] ); /* Q1 */ FOR( i = 1; i < 8; i++ ) { - Ls = L_mac( Ls, y[i], y[i] ); + Ls = L_mac( Ls, y[i], y[i] ); /* Q1 */ } #ifdef BASOP_NOGLOB s = extract_h( L_shl_sat( Ls, 16 - ( 3 + 1 ) ) ); /* s can saturate here */ @@ -304,14 +304,14 @@ static Word16 re8_identify_absolute_leader_fx( /* o : integer i * compute the unique identifier id of the absolute leader related to y: * s = (y1^4 + ... + y8^4)/8 *---------------------------------------------------------------*/ - C = L_mult( y[0], y[0] ); - tmp16 = extract_h( L_shl( C, 16 - 1 ) ); - Ltmp = L_mult( tmp16, tmp16 ); + C = L_mult( y[0], y[0] ); /* Q1 */ + tmp16 = extract_h( L_shl( C, 16 - 1 ) ); /* Q0 */ + Ltmp = L_mult( tmp16, tmp16 ); /* Q1 */ FOR( i = 1; i < 8; i++ ) { - C = L_mult( y[i], y[i] ); - tmp16 = extract_h( L_shl( C, 16 - 1 ) ); - Ltmp = L_mac( Ltmp, tmp16, tmp16 ); + C = L_mult( y[i], y[i] ); /* Q1 */ + tmp16 = extract_h( L_shl( C, 16 - 1 ) ); /* Q0 */ + Ltmp = L_mac( Ltmp, tmp16, tmp16 ); /* Q1 */ } id = extract_h( L_shl( Ltmp, 16 - ( 3 + 1 ) ) ); /* id can saturate to 8192 */ @@ -322,12 +322,12 @@ static Word16 re8_identify_absolute_leader_fx( /* o : integer i * only the id's related to the shell of number s are checked *---------------------------------------------------------------*/ - nb = Da_nb[s - 1]; /* get the number of absolute leaders used on the shell of number s */ - pos = Da_pos[s - 1]; /* get the position of the first absolute leader of shell s in Da_id */ + nb = Da_nb[s - 1]; /* get the number of absolute leaders used on the shell of number s Q0*/ + pos = Da_pos[s - 1]; /* get the position of the first absolute leader of shell s in Da_id Q0*/ move16(); move16(); - ptr = &Da_id[pos]; + ptr = &Da_id[pos]; /* Q0 */ move16(); FOR( i = 0; i < nb; i++ ) { @@ -338,7 +338,7 @@ static Word16 re8_identify_absolute_leader_fx( /* o : integer i BREAK; } ptr++; - pos = add( pos, 1 ); + pos = add( pos, 1 ); /* Q0 */ } } } @@ -354,8 +354,8 @@ static Word16 re8_identify_absolute_leader_fx( /* o : integer i -----------------------------------------------------------------------*/ static void re8_coord_fx( - const Word16 *y, /* i : 8-dimensional point y[0..7] in RE8 */ - Word16 *k /* o : coordinates k[0..7] */ + const Word16 *y, /* i : 8-dimensional point y[0..7] in RE8 Q0*/ + Word16 *k /* o : coordinates k[0..7] Q0*/ ) { Word16 i, tmp, sum; @@ -369,21 +369,21 @@ static void re8_coord_fx( * [ 5 -2 _ -2 4] * *---------------------------------------------------------------*/ - k[7] = y[7]; + k[7] = y[7]; /* Q0 */ move16(); - tmp = y[7]; + tmp = y[7]; /* Q0 */ move16(); - sum = add( y[7], shl( y[7], 2 ) ); + sum = add( y[7], shl( y[7], 2 ) ); /* Q0 */ FOR( i = 6; i >= 1; i-- ) { /* apply factor 2/4 from M^-1 */ - k[i] = shr( sub( y[i], tmp ), 1 ); + k[i] = shr( sub( y[i], tmp ), 1 ); /* Q0 */ move16(); - sum = sub( sum, y[i] ); + sum = sub( sum, y[i] ); /* Q0 */ } /* apply factor 1/4 from M^-1 */ - k[0] = shr( add( y[0], sum ), 2 ); + k[0] = shr( add( y[0], sum ), 2 ); /* Q0 */ move16(); return; diff --git a/lib_com/recovernorm_fx.c b/lib_com/recovernorm_fx.c index a61e1f1839391144f9e9611ab813593c6c953260..2f98597583c50159430e9798c37b86d42a4abde9 100644 --- a/lib_com/recovernorm_fx.c +++ b/lib_com/recovernorm_fx.c @@ -14,10 +14,10 @@ *--------------------------------------------------------------------------*/ void recovernorm_fx( - const Word16 *idxbuf, /* i : reordered quantization indices */ - Word16 *ynrm, /* o : recovered quantization indices */ - Word16 *normqlg2, /* o : recovered quantized norms */ - const Word16 nb_sfm /* i : number of SFMs */ + const Word16 *idxbuf, /* i : reordered quantization indices Q0*/ + Word16 *ynrm, /* o : recovered quantization indices Q0*/ + Word16 *normqlg2, /* o : recovered quantized norms Q0*/ + const Word16 nb_sfm /* i : number of SFMs Q0*/ ) { Word16 i, j, k; @@ -27,32 +27,32 @@ void recovernorm_fx( SWITCH( nb_sfm ) { case NB_SFM: - order = norm_order_48; + order = norm_order_48; /* Q0 */ move16(); BREAK; case SFM_N_SWB: - order = norm_order_32; + order = norm_order_32; /* Q0 */ move16(); BREAK; case SFM_N_WB: - order = norm_order_16; + order = norm_order_16; /* Q0 */ move16(); BREAK; default: - order = norm_order_48; + order = norm_order_48; /* Q0 */ move16(); BREAK; } FOR( i = 0; i < nb_sfm; i++ ) { - j = order[i]; + j = order[i]; /* Q0 */ move16(); - k = idxbuf[i]; + k = idxbuf[i]; /* Q0 */ move16(); - ynrm[j] = k; + ynrm[j] = k; /* Q0 */ move16(); - normqlg2[j] = dicnlg2[k]; + normqlg2[j] = dicnlg2[k]; /* Q0 */ move16(); } diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index e8143222dd1ce7e5f012d568b7a458de28f4d687..7430b18e608764fe4add30bcd6bcd80e4db8313f 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -35673,19 +35673,19 @@ const TCX_LTP_FILTER tcxLtpFilters[12] = const SCALE_TCX_SETUP scaleTcxTable[SIZE_SCALE_TABLE_TCX] = { - { 0, 0, 8000, 0.67f , 21955/*0.67f Q15*/ }, - { 0, 8000, 9600, 0.70f , 22938/*0.70f Q15*/ }, - { 0, 9600, 13200, 0.76f , 24904/*0.76f Q15*/ }, - { 0, 13200, 16400, 0.86f , 28180/*0.86f Q15*/ }, - { 0, 16400, 24400, 0.90f , 29491/*0.90f Q15*/ }, - { 0, 24400, 64000, 0.96f , 31457/*0.96f Q15*/ }, - { 1, 0, 8000, 1.f , 32767/*1.f Q15*/ }, - { 1, 8000, 9600, 1.f , 32767/*1.f Q15*/ }, - { 1, 9600, 13200, 1.f , 32767/*1.f Q15*/ }, - { 1, 13200, 16400, 0.85f /*0.85f*/, 27853/*0.85f Q15*/ }, - { 1, 16400, 24400, 0.88f /*0.90*/ , 28836/*0.88f Q15*/ }, - { 1, 24400, 32000, 0.90f /*0.90*/ , 29491/*0.90f Q15*/ }, - { 1, 32000, 32400, 0.95f /*0.91f*/, 31130/*0.95f Q15*/ }, + { 0, 0, 8000, /* 0.67f ,*/ 21955/*0.67f Q15*/ }, + { 0, 8000, 9600, /* 0.70f ,*/ 22938/*0.70f Q15*/ }, + { 0, 9600, 13200, /* 0.76f ,*/ 24904/*0.76f Q15*/ }, + { 0, 13200, 16400, /* 0.86f ,*/ 28180/*0.86f Q15*/ }, + { 0, 16400, 24400, /* 0.90f ,*/ 29491/*0.90f Q15*/ }, + { 0, 24400, 64000, /* 0.96f ,*/ 31457/*0.96f Q15*/ }, + { 1, 0, 8000, /* 1.f ,*/ 32767/*1.f Q15*/ }, + { 1, 8000, 9600, /* 1.f ,*/ 32767/*1.f Q15*/ }, + { 1, 9600, 13200, /* 1.f ,*/ 32767/*1.f Q15*/ }, + { 1, 13200, 16400, /* 0.85f ,*/ 27853/*0.85f Q15*/ }, + { 1, 16400, 24400, /* 0.88f ,*/ 28836/*0.88f Q15*/ }, + { 1, 24400, 32000, /* 0.90f ,*/ 29491/*0.90f Q15*/ }, + { 1, 32000, 32400, /* 0.95f ,*/ 31130/*0.95f Q15*/ }, }; diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 4cfcb8caf0f1547fd96e2ed17ba6e1510e15ac0f..53a29ca93a0069158642d366f3c88638045633c5 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -134,10 +134,13 @@ typedef struct int16_t voice_tilt; /*Flag for triggering new voice factor tilt*/ +#ifndef IVAS_FLOAT_FIXED float formant_enh_num_flt; float formant_enh_den_flt; - Word16 formant_enh_num; /* Q15 */ - Word16 formant_enh_den; /* Q15 */ +#else + Word16 formant_enh_num; /* Q15 */ + Word16 formant_enh_den; /* Q15 */ +#endif int16_t bpf_mode; @@ -527,17 +530,20 @@ typedef struct Word32 exc_cng_32fx[L_FRAME16k]; #endif - int32_t CngBitrate; - int16_t CngBandwidth; + Word32 CngBitrate; + Word16 CngBandwidth; - int16_t flag_noisy_speech; + Word16 flag_noisy_speech; +#ifndef IVAS_FLOAT_FIXED float likelihood_noisy_speech_flt; - Word16 likelihood_noisy_speech; // Q15 +#else + Word16 likelihood_noisy_speech; /* Q15 */ +#endif #ifndef IVAS_FLOAT_FIXED float coherence_flt; /* inter-channel coherence of noise */ #else - Word16 coherence_fx; /* inter-channel coherence of noise Q15 */ + Word16 coherence_fx; /* inter-channel coherence of noise Q15 */ #endif int16_t no_side_flag; /* indicates whether the side noise shape should be zeroed-out or not */ @@ -694,8 +700,11 @@ typedef struct int32_t bitrateFrom; int32_t bitrateTo; +#ifndef IVAS_FLOAT_FIXED float scale_flt; - Word16 scale; /* Q15 */ +#else + Word16 scale; /* Q15 */ +#endif } SCALE_TCX_SETUP; @@ -884,14 +893,17 @@ typedef struct igf_grid_struct int16_t infoIsRefined; int16_t infoGranuleLen; Word16 infoTransFac; +#ifndef IVAS_FLOAT_FIXED float whiteningThreshold_flt[2][IGF_MAX_TILES]; - Word16 whiteningThreshold[2][IGF_MAX_TILES]; /* 2Q13 */ float gFactor_flt; float fFactor_flt; float lFactor_flt; - Word16 gFactor; /* 1Q14 */ - Word16 fFactor; /* 1Q14 */ - Word16 lFactor; /* 1Q14 */ +#else + Word16 whiteningThreshold[2][IGF_MAX_TILES]; /* 2Q13 */ + Word16 gFactor; /* 1Q14 */ + Word16 fFactor; /* 1Q14 */ + Word16 lFactor; /* 1Q14 */ +#endif } IGF_GRID, *H_IGF_GRID; diff --git a/lib_com/window_fx.c b/lib_com/window_fx.c index 2efbe562231f15f2fd2a7064d92ffba9d71048ac..2b3c50ac6749ca1a74fed4bd80ad51a09e5f3d76 100644 --- a/lib_com/window_fx.c +++ b/lib_com/window_fx.c @@ -89,7 +89,7 @@ void ham_cos_window_ivas( const Word16 n2 /* i: */ ) { - Word16 cc_fx; + Word16 cc_fx; // Q15 Word16 i; // cte = PI2 / (float) ( 2 * n1 - 1 ); @@ -98,7 +98,7 @@ void ham_cos_window_ivas( move16(); FOR( i = 0; i < n1; i++ ) { - *fh++ = sub( 17694, mult( getCosWord16R2( cc_fx ), 15073 ) ); + *fh++ = sub( 17694 /*0.54.Q15*/, mult( getCosWord16R2( cc_fx ), 15073 /*0.46.Q15*/ ) ); move16(); cc_fx = div_s( add( i, 1 ), sub( shl( n1, 1 ), 1 ) ); // add(cc_fx, cte_fx); } diff --git a/lib_com/window_ola_fx.c b/lib_com/window_ola_fx.c index 7dd0f2a79164d6a5f60be97f2b1c80aedc14a436..40763be995bdd9a8d5664f33fcc19c2409891084 100644 --- a/lib_com/window_ola_fx.c +++ b/lib_com/window_ola_fx.c @@ -44,8 +44,8 @@ void sinq_fx( IF( GT_16( abs_s( tmp ), 3 ) ) { /*A=(x[2]+x[0])/x[1]=2*cos(tmp); here approximated by 2*(1-tmp^2/2!) */ - A32 = L_mult0( tmp, tmp ); /*Q30 */ - A32 = L_add( L_sub( 1073741824, A32 ), 1073741824 ); /*Q30 */ + A32 = L_mult0( tmp, tmp ); /*Q30 */ + A32 = L_add( L_sub( 1073741824 /*1.Q30*/, A32 ), 1073741824 /*1.Q30*/ ); /*Q30 */ } ELSE { @@ -216,8 +216,8 @@ void window_ola_fx( temp = sub( L, n ); - tmp2 = div_s( 1, temp ); /*Q15 */ - tmp2 = round_fx( L_shl( L_mult( tmp2, 25736 ), 2 ) ); /*Q15 */ + tmp2 = div_s( 1, temp ); /*Q15 */ + tmp2 = round_fx( L_shl( L_mult( tmp2, 25736 /*(pi/2).Q14*/ ), 2 ) ); /*Q15 */ sinq_fx( shr( tmp2, 1 ), shr( tmp2, 2 ), temp, SS2 ); @@ -532,17 +532,42 @@ void window_ola_fx( *-------------------------------------------------------------------*/ void window_ola_ext_fx( - const Word32 *ImdstOut, /* i : input */ - Word32 *auOut, /* o : output audio */ - Word32 *OldauOut, /* i/o: audio from previous frame */ + const Word32 *ImdstOut, /* i : input Qx */ + Word32 *auOut, /* o : output audio Qx */ + Word32 *OldauOut, /* i/o: audio from previous frame Qx */ const Word16 L, /* i : length */ const Word16 right_mode, const Word16 left_mode, /* i : window overlap of current frame (0: full, 2: none, or 3: half) */ const UWord16 kernel_type /* i : transform kernel type */ ) { - const Word16 sign_left = ( kernel_type & 1 ? MAX_16 : negate( MAX_16 ) ); - const Word16 sign_right = ( kernel_type >= MDCT_II ? negate( MAX_16 ) : MAX_16 ); + Word16 temp; + IF( s_and( kernel_type, 1 ) ) + { + temp = MAX_16; + } + ELSE + { + temp = MIN_16; + } + move16(); + + const Word16 sign_left = temp; + move16(); + + IF( GE_16( kernel_type, MDCT_II ) ) + { + temp = MIN_16; + } + ELSE + { + temp = MAX_16; + } + move16(); + + const Word16 sign_right = temp; + move16(); + Word16 i, decimate, decay; Word16 n, n16, windecay48, windecay16; Word16 win_right[R2_48]; @@ -551,7 +576,7 @@ void window_ola_ext_fx( Word16 win_int_right[R2_16]; Word32 *paout; - n = shr( mult( shl( L, Q5 ), N_ZERO_BY_FS ), Q5 ); + n = shr( mult( shl( L, Q5 ), N_ZERO_BY_FS ), Q5 ); // Q0 n16 = N16_CORE_SW; move16(); windecay48 = WINDECAY48; @@ -600,93 +625,93 @@ void window_ola_ext_fx( move16(); } - paout = auOut - n; + paout = auOut - n; // Qx IF( EQ_16( L, L_FRAME32k ) ) { - FOR( i = n; i < shr( L, 1 ); i += 2 ) + FOR( i = n; i < ( L >> 1 ); i += 2 ) { - paout[i] = L_add_sat( Mpy_32_16_1( Mpy_32_16_1( ImdstOut[add( shr( L, 1 ), i )], sign_right ), win_right[sub( sub( sub( i_mult( ( sub( 2 * L_FRAME16k, add( n16, shr( sub( i, n ), 1 ) ) ) ), decimate ), 1 ), decay ), windecay48 )] ), OldauOut[i] ); + paout[i] = L_add_sat( Mpy_32_16_1( Mpy_32_16_1( ImdstOut[( ( L >> 1 ) + i )], sign_right ), win_right[( ( ( ( ( ( 2 * L_FRAME16k - ( n16 + ( ( i - n ) >> 1 ) ) ) ) * decimate ) - 1 ) - decay ) - windecay48 )] ), OldauOut[i] ); move32(); - paout[i + 1] = L_add_sat( Mpy_32_16_1( Mpy_32_16_1( ImdstOut[add( add( shr( L, 1 ), i ), 1 )], sign_right ), win_int_right[sub( sub( sub( 2 * L_FRAME16k, add( n16, shr( sub( i, n ), 1 ) ) ), 1 ), windecay16 )] ), OldauOut[i + 1] ); + paout[i + 1] = L_add_sat( Mpy_32_16_1( Mpy_32_16_1( ImdstOut[( ( ( L >> 1 ) + i ) + 1 )], sign_right ), win_int_right[( ( ( 2 * L_FRAME16k - ( n16 + ( ( i - n ) >> 1 ) ) ) - 1 ) - windecay16 )] ), OldauOut[i + 1] ); move32(); } - FOR( i = 0; i < shr( L, 1 ) - n; i += 2 ) + FOR( i = 0; i < ( L >> 1 ) - n; i += 2 ) { - paout[add( add( shr( L, 1 ), i ), 1 )] = L_add_sat( Mpy_32_16_1( L_negate( ImdstOut[sub( sub( L, 1 ), add( i, 1 ) )] ), win_right[sub( add( i_mult( ( sub( 3 * L_FRAME16k / 2 - 1, shr( i, 1 ) ) ), decimate ), decay ), windecay48 )] ), OldauOut[add( add( i, shr( L, 1 ) ), 1 )] ); + paout[( ( ( L >> 1 ) + i ) + 1 )] = L_add_sat( Mpy_32_16_1( L_negate( ImdstOut[( ( L - 1 ) - ( i + 1 ) )] ), win_right[( ( ( ( ( 3 * L_FRAME16k / 2 - 1 - ( i >> 1 ) ) ) * decimate ) + decay ) - windecay48 )] ), OldauOut[( ( i + ( L >> 1 ) ) + 1 )] ); move32(); - paout[add( shr( L, 1 ), i )] = L_add_sat( Mpy_32_16_1( L_negate( ImdstOut[sub( sub( L, 1 ), i )] ), win_int_right[sub( sub( 3 * L_FRAME16k / 2 - 1, shr( i, 1 ) ), windecay16 )] ), OldauOut[add( i, shr( L, 1 ) )] ); + paout[( ( L >> 1 ) + i )] = L_add_sat( Mpy_32_16_1( L_negate( ImdstOut[( ( L - 1 ) - i )] ), win_int_right[( ( 3 * L_FRAME16k / 2 - 1 - ( i >> 1 ) ) - windecay16 )] ), OldauOut[( i + ( L >> 1 ) )] ); move32(); } - FOR( i = sub( shr( L, 1 ), n ); i < shr( L, 1 ); i += 2 ) + FOR( i = ( ( L >> 1 ) - n ); i < ( L >> 1 ); i += 2 ) { - paout[add( add( shr( L, 1 ), i ), 1 )] = L_add_sat( L_negate( ImdstOut[sub( sub( L, 1 ), add( i, 1 ) )] ), OldauOut[add( add( i, shr( L, 1 ) ), 1 )] ); + paout[( ( ( L >> 1 ) + i ) + 1 )] = L_add_sat( L_negate( ImdstOut[( ( L - 1 ) - ( i + 1 ) )] ), OldauOut[( ( i + ( L >> 1 ) ) + 1 )] ); move32(); - paout[add( shr( L, 1 ), i )] = L_add_sat( L_negate( ImdstOut[sub( L, add( 1, i ) )] ), OldauOut[add( i, shr( L, 1 ) )] ); + paout[( ( L >> 1 ) + i )] = L_add_sat( L_negate( ImdstOut[( L - ( 1 + i ) )] ), OldauOut[( i + ( L >> 1 ) )] ); move32(); } - FOR( i = 0; i < shr( L, 1 ); i += 2 ) + FOR( i = 0; i < ( L >> 1 ); i += 2 ) { - OldauOut[add( add( shr( L, 1 ), i ), 1 )] = Mpy_32_16_1( Mpy_32_16_1( ImdstOut[i + 1], sign_left ), win_left[add( i_mult( sub( L_FRAME16k / 2 - 1, shr( i, 1 ) ), decimate ), decay )] ); + OldauOut[( ( ( L >> 1 ) + i ) + 1 )] = Mpy_32_16_1( Mpy_32_16_1( ImdstOut[i + 1], sign_left ), win_left[( ( ( L_FRAME16k / 2 - 1 - ( i >> 1 ) ) * decimate ) + decay )] ); move32(); - OldauOut[add( shr( L, 1 ), i )] = Mpy_32_16_1( Mpy_32_16_1( ImdstOut[i], sign_left ), win_int_left[sub( L_FRAME16k / 2 - 1, shr( i, 1 ) )] ); + OldauOut[( ( L >> 1 ) + i )] = Mpy_32_16_1( Mpy_32_16_1( ImdstOut[i], sign_left ), win_int_left[( L_FRAME16k / 2 - 1 - ( i >> 1 ) )] ); move32(); } - FOR( i = n; i < shr( L, 1 ); i += 2 ) + FOR( i = n; i < ( L >> 1 ); i += 2 ) { - OldauOut[i] = Mpy_32_16_1( L_negate( ImdstOut[sub( sub( shr( L, 1 ), 1 ), i )] ), win_left[sub( sub( i_mult( sub( L_FRAME16k, shr( i, 1 ) ), decimate ), decay ), 1 )] ); + OldauOut[i] = Mpy_32_16_1( L_negate( ImdstOut[( ( ( L >> 1 ) - 1 ) - i )] ), win_left[( ( ( ( L_FRAME16k - ( i >> 1 ) ) * decimate ) - decay ) - 1 )] ); move32(); - OldauOut[i + 1] = Mpy_32_16_1( L_negate( ImdstOut[sub( sub( shr( L, 1 ), 1 ), add( i, 1 ) )] ), win_int_left[sub( L_FRAME16k - 1, shr( i, 1 ) )] ); + OldauOut[i + 1] = Mpy_32_16_1( L_negate( ImdstOut[( ( ( L >> 1 ) - 1 ) - ( i + 1 ) )] ), win_int_left[( L_FRAME16k - 1 - ( i >> 1 ) )] ); move32(); } } ELSE { - FOR( i = n; i < shr( L, 1 ); i++ ) + FOR( i = n; i < ( L >> 1 ); i++ ) { - paout[i] = L_add_sat( Mpy_32_16_1( Mpy_32_16_1( ImdstOut[add( shr( L, 1 ), i )], sign_right ), win_right[sub( sub( sub( i_mult( ( sub( shl( L, 1 ), i ) ), decimate ), 1 ), decay ), windecay48 )] ), OldauOut[i] ); + paout[i] = L_add_sat( Mpy_32_16_1( Mpy_32_16_1( ImdstOut[( ( L >> 1 ) + i )], sign_right ), win_right[( ( ( ( ( ( ( L << 1 ) - i ) ) * decimate ) - 1 ) - decay ) - windecay48 )] ), OldauOut[i] ); move32(); } - FOR( i = 0; i < shr( L, 1 ) - n; i++ ) + FOR( i = 0; i < ( L >> 1 ) - n; i++ ) { - paout[add( shr( L, 1 ), i )] = L_add_sat( Mpy_32_16_1( L_negate( ImdstOut[sub( L, add( 1, i ) )] ), win_right[sub( add( i_mult( ( sub( sub( i_mult( 3, shr( L, 1 ) ), 1 ), i ) ), decimate ), decay ), windecay48 )] ), OldauOut[add( i, shr( L, 1 ) )] ); + paout[( ( L >> 1 ) + i )] = L_add_sat( Mpy_32_16_1( L_negate( ImdstOut[( L - ( 1 + i ) )] ), win_right[( ( ( ( ( ( ( 3 * ( L >> 1 ) ) - 1 ) - i ) ) * decimate ) + decay ) - windecay48 )] ), OldauOut[( i + ( L >> 1 ) )] ); move32(); } - FOR( i = sub( shr( L, 1 ), n ); i < shr( L, 1 ); i++ ) + FOR( i = ( ( L >> 1 ) - n ); i < ( L >> 1 ); i++ ) { - paout[add( shr( L, 1 ), i )] = L_add_sat( L_negate( ImdstOut[sub( L, add( 1, i ) )] ), OldauOut[add( i, shr( L, 1 ) )] ); + paout[( ( L >> 1 ) + i )] = L_add_sat( L_negate( ImdstOut[( L - ( 1 + i ) )] ), OldauOut[( i + ( L >> 1 ) )] ); move32(); } - FOR( i = 0; i < shr( L, 1 ); i++ ) + FOR( i = 0; i < ( L >> 1 ); i++ ) { - OldauOut[add( shr( L, 1 ), i )] = Mpy_32_16_1( Mpy_32_16_1( ImdstOut[i], sign_left ), win_left[add( i_mult( ( sub( shr( L, 1 ), add( i, 1 ) ) ), decimate ), decay )] ); + OldauOut[( ( L >> 1 ) + i )] = Mpy_32_16_1( Mpy_32_16_1( ImdstOut[i], sign_left ), win_left[( ( ( ( ( L >> 1 ) - ( i + 1 ) ) ) * decimate ) + decay )] ); move32(); } - FOR( i = n; i < shr( L, 1 ); i++ ) + FOR( i = n; i < ( L >> 1 ); i++ ) { - OldauOut[i] = Mpy_32_16_1( L_negate( ImdstOut[sub( shr( L, 1 ), add( 1, i ) )] ), win_left[sub( sub( i_mult( sub( L, i ), decimate ), decay ), 1 )] ); + OldauOut[i] = Mpy_32_16_1( L_negate( ImdstOut[( ( L >> 1 ) - ( 1 + i ) )] ), win_left[( ( ( ( L - i ) * decimate ) - decay ) - 1 )] ); move32(); } } FOR( i = 0; i < n; i++ ) { - OldauOut[i] = L_negate( ImdstOut[sub( shr( L, 1 ), add( 1, i ) )] ); + OldauOut[i] = L_negate( ImdstOut[( ( L >> 1 ) - ( 1 + i ) )] ); move32(); } FOR( i = 0; i < n; i++ ) { - paout[add( L, i )] = OldauOut[i]; + paout[( L + i )] = OldauOut[i]; move32(); } @@ -731,14 +756,14 @@ void core_switching_OLA_fx( *Qsynth = tmp; move16(); Scale_sig( synth_subfr_out, SWITCH_MAX_GAP, sub( tmp, *Qsubfr ) ); - Scale_sig( mem_over_hp, NS2SA( 16000, DELAY_CLDFB_NS ) + 2, sub( tmp, *Qsubfr ) ); /* reScale mem over HP at Qsynth */ + Scale_sig( mem_over_hp, NS2SA_FX2( 16000, DELAY_CLDFB_NS ) + 2, sub( tmp, *Qsubfr ) ); /* reScale mem over HP at Qsynth */ *Qsubfr = tmp; move16(); /* win = window_48kHz_fx;*/ /* win_int = window_8_16_32kHz_fx;*/ - on_win = one_on_win_48k_fx; - on_win_int = one_on_win_8k_16k_48k_fx; + on_win = one_on_win_48k_fx; // Q14 + on_win_int = one_on_win_8k_16k_48k_fx; // Q14 SWITCH( output_frame ) @@ -792,7 +817,7 @@ void core_switching_OLA_fx( /* resample filter memory */ IF( EQ_16( output_frame, L_FRAME8k ) ) { - Copy( synth_subfr_out + SWITCH_GAP_LENGTH_8k, tmp_buf_switch + SWITCH_GAP_LENGTH_8k, NS2SA( output_Fs, DELAY_CLDFB_NS ) ); /* copy subframe to tmp buffer */ + Copy( synth_subfr_out + SWITCH_GAP_LENGTH_8k, tmp_buf_switch + SWITCH_GAP_LENGTH_8k, NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ) ); /* copy subframe to tmp buffer */ } ELSE { @@ -800,7 +825,7 @@ void core_switching_OLA_fx( move16(); out_filt_length = 0; move16(); - out_filt_length = modify_Fs_intcub3m_sup_fx( mem_over_hp + 2, NS2SA( 12800, DELAY_CLDFB_NS ), 12800, tmp_buf_switch2, output_Fs, &filt_delay ); + out_filt_length = modify_Fs_intcub3m_sup_fx( mem_over_hp + 2, NS2SA_FX2( 12800, DELAY_CLDFB_NS ), 12800, tmp_buf_switch2, output_Fs, &filt_delay ); pt = tmp_buf_switch2 + sub( out_filt_length, filt_delay ); pt2 = pt - 1; FOR( i = 0; i < filt_delay; i++ ) @@ -902,7 +927,7 @@ void core_switching_OLA_fx( pt2 = pt + 1; pt5 = on_win + 210 - 1; pt4 = on_win_int + 70 - 1; - temp_len = i_mult2( shr( R2_16, 2 ), delta ); + temp_len = i_mult2( ( R2_16 >> 2 ), delta ); FOR( i = 0; i < temp_len; i += 2 ) { #ifdef BASOP_NOGLOB @@ -926,7 +951,7 @@ void core_switching_OLA_fx( pt = synth + tmp; pt5 = on_win + 210 - 1; - temp_len = i_mult2( shr( R2_16, 2 ), delta ); + temp_len = i_mult2( ( R2_16 >> 2 ), delta ); FOR( i = 0; i < temp_len; i++ ) { #ifdef BASOP_NOGLOB @@ -944,7 +969,7 @@ void core_switching_OLA_fx( pt = synth + tmp; move16(); /*Q15 */ - pt2 = synth_subfr_bwe + tmp - NS2SA( output_Fs, DELAY_CLDFB_NS ); + pt2 = synth_subfr_bwe + tmp - NS2SA_FX2( output_Fs, DELAY_CLDFB_NS ); move16(); /*Q15 */ pt3 = tmp_buf_switch + tmp; move16(); /*Q15 */ diff --git a/lib_com/wtda.c b/lib_com/wtda.c index eed61a240778fb7867926794b02c2501ffbff432..3a9494e4273d9902681b3e2bb99b37ff4b7ed4d5 100644 --- a/lib_com/wtda.c +++ b/lib_com/wtda.c @@ -377,9 +377,9 @@ void wtda_fx32( move16(); decay = 0; move16(); - windecay48 = (Word16) WINDECAY48; // (int16_t)(2 * ((float)L_FRAME48k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_48 - move16(); + windecay48 = extract_l( WINDECAY48 ); // (int16_t)(2 * ((float)L_FRAME48k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_48 + test(); IF( EQ_16( L, L_FRAME32k ) || EQ_16( L, L_FRAME16k ) ) { decimate = 3; @@ -415,7 +415,7 @@ void wtda_fx32( BREAK; } - windecay16 = (Word16) WINDECAY16; // (int16_t)(2 * ((float)L_FRAME16k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_16; + windecay16 = extract_l( WINDECAY16 ); // (int16_t)(2 * ((float)L_FRAME16k * N_ZERO_MDCT_NS / FRAME_SIZE_NS)) + R1_16; /* algorithmic delay reduction */ i = 0; @@ -434,7 +434,7 @@ void wtda_fx32( IF( EQ_16( L, L_FRAME32k ) ) { - FOR( i = 0; i < sub( L / 2, n ); i += 2 ) + FOR( i = 0; i < ( L / 2 - n ); i += 2 ) { idx1 = sub( sub( shr( L, 1 ), i ), 1 ); idx2 = sub( sub( 3 * L_FRAME16k / 2 - 1, shr( i, 1 ) ), windecay16 ); @@ -453,16 +453,16 @@ void wtda_fx32( FOR( i = L / 2 - n; i < L / 2; i += 2 ) { - wtda_audio[i] = L_negate( allsig_r[sub( sub( shr( L, 1 ), i ), 1 )] ); + wtda_audio[i] = L_negate( allsig_r[( ( ( L >> 1 ) - i ) - 1 )] ); move32(); - wtda_audio[i + 1] = L_negate( allsig_r[sub( sub( shr( L, 1 ), add( i, 1 ) ), 1 )] ); + wtda_audio[i + 1] = L_negate( allsig_r[( ( ( L >> 1 ) - ( i + 1 ) ) - 1 )] ); move32(); } FOR( i = 0; i < n; i += 2 ) { - wtda_audio[add( i, shr( L, 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[add( i_mult( shr( i, 1 ), decimate ), decay )] ), new_audio[sub( sub( n, i ), 1 )] ); + wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[( ( ( i >> 1 ) * decimate ) + decay )] ), new_audio[( ( n - i ) - 1 )] ); move32(); - wtda_audio[add( add( i, shr( L, 1 ) ), 1 )] = L_sub_sat( Mpy_32_16_1( allsig_l[i + 1], win_int_left[i / 2] ), new_audio[sub( sub( n, add( i, 1 ) ), 1 )] ); + wtda_audio[( ( i + ( L >> 1 ) ) + 1 )] = L_sub_sat( Mpy_32_16_1( allsig_l[i + 1], win_int_left[i / 2] ), new_audio[( ( n - ( i + 1 ) ) - 1 )] ); move32(); } @@ -473,14 +473,14 @@ void wtda_fx32( idx2 = add( i_mult( shr( i, 1 ), decimate ), decay ); idx3 = sub( sub( L, i ), 1 ); idx4 = sub( sub( i_mult( sub( shr( L, 1 ), shr( i, 1 ) ), decimate ), 1 ), decay ); - wtda_audio[add( i, shr( L, 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) ); + wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) ); move32(); idx1 = add( i, 1 ); idx2 = shr( i, 1 ); idx3 = sub( sub( L, add( i, 1 ) ), 1 ); idx4 = sub( sub( shr( L, 1 ), shr( i, 1 ) ), 1 ); - wtda_audio[add( add( i, shr( L, 1 ) ), 1 )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_int_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_int_left[idx4] ) ); + wtda_audio[( ( i + ( L >> 1 ) ) + 1 )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_int_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_int_left[idx4] ) ); move32(); } } @@ -498,13 +498,13 @@ void wtda_fx32( FOR( i = L / 2 - n; i < L / 2; i++ ) { - wtda_audio[i] = L_negate( allsig_r[sub( sub( shr( L, 1 ), i ), 1 )] ); + wtda_audio[i] = L_negate( allsig_r[( ( ( L >> 1 ) - i ) - 1 )] ); move32(); } FOR( i = 0; i < n; i++ ) { - wtda_audio[add( i, shr( L, 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[add( i_mult( i, decimate ), decay )] ), new_audio[sub( sub( n, i ), 1 )] ); + wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[i], win_left[( ( i * decimate ) + decay )] ), new_audio[( ( n - i ) - 1 )] ); move32(); } @@ -515,7 +515,7 @@ void wtda_fx32( idx2 = add( i_mult( i, decimate ), decay ); idx3 = sub( sub( L, i ), 1 ); idx4 = sub( sub( sub( i_mult( L, decimate ), i_mult( i, decimate ) ), 1 ), decay ); - wtda_audio[add( i, shr( L, 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) ); + wtda_audio[( i + ( L >> 1 ) )] = L_sub_sat( Mpy_32_16_1( allsig_l[idx1], win_left[idx2] ), Mpy_32_16_1( allsig_l[idx3], win_left[idx4] ) ); move32(); } } diff --git a/lib_com/wtda_fx.c b/lib_com/wtda_fx.c index e94789a6a8cbb08eba68d35fd04d2758a86aa042..1806638bbcc027e60964fda0a0152f858348d814 100644 --- a/lib_com/wtda_fx.c +++ b/lib_com/wtda_fx.c @@ -59,7 +59,7 @@ static void mvs2s_dec( *--------------------------------------------------------------------------*/ static void copy_win( - Word16 *out_win, /* o : output window buffer */ + Word16 *out_win, /* o : output window buffer Q15*/ const Word16 nb_zero, /* i : length of zero padding */ const Word16 *in_win, /* i : input window */ const Word16 win_lenght, /* i : length */ @@ -69,7 +69,7 @@ static void copy_win( { IF( decimate < 0 ) { - set16_fx( out_win, 32767, nb_one ); + set16_fx( out_win, 32767, nb_one ); // Q15 mvs2s_inv( in_win, out_win + nb_one, win_lenght, negate( decimate ) ); set16_fx( out_win + add( win_lenght, nb_one ), 0, nb_zero ); } @@ -77,7 +77,7 @@ static void copy_win( { set16_fx( out_win, 0, nb_zero ); mvs2s_dec( in_win, out_win + nb_zero, win_lenght, decimate ); - set16_fx( out_win + add( nb_zero, win_lenght ), 32767, nb_one ); + set16_fx( out_win + add( nb_zero, win_lenght ), 32767, nb_one ); // Q15 } } /*--------------------------------------------------------------------------* @@ -102,12 +102,12 @@ void tcx_get_windows_mode1( test(); IF( EQ_16( L, 256 ) || EQ_16( L, 512 ) ) { - copy_win( left_win, R1_25 - 4 * R2_25 / 7, small_overlap_25, R2_25 / 7, 3 * R2_25 / 7, 1 ); + copy_win( left_win, R1_25 - 4 * R2_25 / 7, small_overlap_25, R2_25 / 7, 3 * R2_25 / 7, 1 ); // Q15 } ELSE { - copy_win( left_win, R1_48 - 4 * R2_48 / 7, small_overlap_48, R2_48 / 7, 3 * R2_48 / 7, 1 ); - copy_win( left_win_int, R1_16 - 4 * R2_16 / 7, small_overlap_int, R2_16 / 7, 3 * R2_16 / 7, 1 ); + copy_win( left_win, R1_48 - 4 * R2_48 / 7, small_overlap_48, R2_48 / 7, 3 * R2_48 / 7, 1 ); // Q15 + copy_win( left_win_int, R1_16 - 4 * R2_16 / 7, small_overlap_int, R2_16 / 7, 3 * R2_16 / 7, 1 ); // Q15 } } ELSE IF( EQ_16( left_mode, HALF_OVERLAP ) ) @@ -115,12 +115,12 @@ void tcx_get_windows_mode1( test(); IF( EQ_16( L, 256 ) || EQ_16( L, 512 ) ) { - copy_win( left_win, R1_25 - 5 * R2_25 / 7, half_overlap_25, 3 * R2_25 / 7, 2 * R2_25 / 7, 1 ); + copy_win( left_win, R1_25 - 5 * R2_25 / 7, half_overlap_25, 3 * R2_25 / 7, 2 * R2_25 / 7, 1 ); // Q15 } ELSE { - copy_win( left_win, R1_48 - 5 * R2_48 / 7, half_overlap_48, 3 * R2_48 / 7, 2 * R2_48 / 7, 1 ); - copy_win( left_win_int, R1_16 - 5 * R2_16 / 7, half_overlap_int, 3 * R2_16 / 7, 2 * R2_16 / 7, 1 ); + copy_win( left_win, R1_48 - 5 * R2_48 / 7, half_overlap_48, 3 * R2_48 / 7, 2 * R2_48 / 7, 1 ); // Q15 + copy_win( left_win_int, R1_16 - 5 * R2_16 / 7, half_overlap_int, 3 * R2_16 / 7, 2 * R2_16 / 7, 1 ); // Q15 } } ELSE IF( EQ_16( left_mode, ALDO_WINDOW ) ) /* ALDO */ @@ -128,12 +128,12 @@ void tcx_get_windows_mode1( test(); IF( EQ_16( L, 256 ) || EQ_16( L, 512 ) ) { - Copy( window_256kHz, left_win, R1_25 ); + Copy( window_256kHz, left_win, R1_25 ); // Q15 } ELSE { - Copy( window_48kHz_fx, left_win, R1_48 ); - Copy( window_8_16_32kHz_fx, left_win_int, R1_16 ); + Copy( window_48kHz_fx, left_win, R1_48 ); // Q15 + Copy( window_8_16_32kHz_fx, left_win_int, R1_16 ); // Q15 } } ELSE @@ -148,13 +148,13 @@ void tcx_get_windows_mode1( test(); IF( EQ_16( L, 256 ) || EQ_16( L, 512 ) ) { - copy_win( right_win, 3 * R2_25 / 7, small_overlap_25, R2_25 / 7, 3 * R2_25 / 7, -1 ); + copy_win( right_win, 3 * R2_25 / 7, small_overlap_25, R2_25 / 7, 3 * R2_25 / 7, -1 ); // Q15 } ELSE { - copy_win( right_win, 3 * R2_48 / 7, small_overlap_48, R2_48 / 7, 3 * R2_48 / 7, -1 ); - copy_win( right_win_int, 3 * R2_16 / 7, small_overlap_int, R2_16 / 7, 3 * R2_16 / 7, -1 ); + copy_win( right_win, 3 * R2_48 / 7, small_overlap_48, R2_48 / 7, 3 * R2_48 / 7, -1 ); // Q15 + copy_win( right_win_int, 3 * R2_16 / 7, small_overlap_int, R2_16 / 7, 3 * R2_16 / 7, -1 ); // Q15 } } ELSE IF( EQ_16( right_mode, HALF_OVERLAP ) ) @@ -162,12 +162,12 @@ void tcx_get_windows_mode1( test(); IF( EQ_16( L, 256 ) || EQ_16( L, 512 ) ) { - copy_win( right_win, 2 * R2_25 / 7, half_overlap_25, 3 * R2_25 / 7, 2 * R2_25 / 7, -1 ); + copy_win( right_win, 2 * R2_25 / 7, half_overlap_25, 3 * R2_25 / 7, 2 * R2_25 / 7, -1 ); // Q15 } ELSE { - copy_win( right_win, 2 * R2_48 / 7, half_overlap_48, 3 * R2_48 / 7, 2 * R2_48 / 7, -1 ); - copy_win( right_win_int, 2 * R2_16 / 7, half_overlap_int, 3 * R2_16 / 7, 2 * R2_16 / 7, -1 ); + copy_win( right_win, 2 * R2_48 / 7, half_overlap_48, 3 * R2_48 / 7, 2 * R2_48 / 7, -1 ); // Q15 + copy_win( right_win_int, 2 * R2_16 / 7, half_overlap_int, 3 * R2_16 / 7, 2 * R2_16 / 7, -1 ); // Q15 } } ELSE IF( EQ_16( right_mode, ALDO_WINDOW ) ) @@ -175,12 +175,12 @@ void tcx_get_windows_mode1( test(); IF( EQ_16( L, 256 ) || EQ_16( L, 512 ) ) { - Copy( window_256kHz + R1_25, right_win, R2_25 ); + Copy( window_256kHz + R1_25, right_win, R2_25 ); // Q15 } ELSE { - Copy( window_48kHz_fx + R1_48, right_win, R2_48 ); - Copy( window_8_16_32kHz_fx + R1_16, right_win_int, R2_16 ); + Copy( window_48kHz_fx + R1_48, right_win, R2_48 ); // Q15 + Copy( window_8_16_32kHz_fx + R1_16, right_win_int, R2_16 ); // Q15 } } ELSE diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index d2a43ac55d656ad89c0fd738ed9d2cbc0bcf8310..eef3bcbd272b0b1a6ae31176ee6370c16968e459 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -1390,8 +1390,6 @@ ivas_error acelp_core_enc( *-----------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - - // Word16 pitch_buf_fx[NB_SUBFR16k]; floatToFixed_arr( pitch_buf, pitch_buf_fx, Q6, NB_SUBFR16k ); // Saturation Conversion used as last values have garbage values even in float floatToFixed_arr16( st->old_pitch_buf, st->old_pitch_buf_fx, Q6, 2 * NB_SUBFR16k ); @@ -1408,11 +1406,11 @@ ivas_error acelp_core_enc( floatToFixed_arr16( old_exc_flt, old_exc_fx, q_old_exc, L_EXC ); st->hLPDmem->e_old_exc = sub( 15, q_old_exc ); - Word16 q_old_bwe_exc; + Word16 q_old_bwe_exc = 0; IF( st->hBWE_TD != NULL ) { - q_old_bwe_exc = Q_factor_arr( old_bwe_exc, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ); - floatToFixed_arr16( old_bwe_exc, old_bwe_exc_fx, q_old_bwe_exc, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ); + q_old_bwe_exc = Q_factor_arr( &old_bwe_exc[L_FRAME32k], PIT16k_MAX * 2 ); + floatToFixed_arr16( &old_bwe_exc[L_FRAME32k], &old_bwe_exc_fx[L_FRAME32k], q_old_bwe_exc, PIT16k_MAX * 2 ); st->Q_exc = q_old_bwe_exc; } @@ -1421,20 +1419,43 @@ ivas_error acelp_core_enc( st->hGSCEnc->mid_dyn_fx = float_to_fix16( st->hGSCEnc->mid_dyn, Q7 ); } + if ( st->L_frame == L_FRAME ) + { + floatToFixed_arr( st->lsp_old, st->lsp_old_fx, Q15, M ); + } #endif // IVAS_FLOAT_FIXED_CONVERSIONS updt_enc_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, old_bwe_exc_fx ); -#endif // IVAS_FLOAT_FIXED - +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + fixedToFloat_arr( st->hLPDmem->old_exc, st->hLPDmem->old_exc_flt, q_old_exc, L_EXC_MEM ); + IF( !st->Opt_AMR_WB && st->hBWE_TD != NULL ) + { + fixedToFloat_arr( st->hBWE_TD->old_bwe_exc_fx, st->hBWE_TD->old_bwe_exc, q_old_bwe_exc, PIT16k_MAX * 2 ); + } + fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, Q15, M ); + for ( i = 0; i < M; i++ ) + { + st->lsf_old[i] = (float) ( st->lsf_old_fx[i] / 2.56f ); + } + st->hGSCEnc->mid_dyn = fixedToFloat( st->hGSCEnc->mid_dyn_fx, Q7 ); + IF( EQ_16( st->L_frame, L_FRAME ) ) + { + fixedToFloat_arr( st->lsp_old16k_fx, st->lsp_old16k, Q15, M ); + } + fixedToFloat_arr( st->old_pitch_buf_fx, st->old_pitch_buf, Q6, shl( shr( st->L_frame, 6 ), 1 ) ); // Q6 + fixedToFloat_arr( st->old_Aq_12_8_fx, st->old_Aq_12_8, Q12, M + 1 ); // Q12 + st->old_Es_pred = fixedToFloat( st->old_Es_pred_fx, Q8 ); +#endif +#else updt_enc( st, old_exc_flt, pitch_buf, Es_pred, Aq, lsf_new, lsp_new, old_bwe_exc ); +#endif // IVAS_FLOAT_FIXED if ( st->hTdCngEnc != NULL && st->Opt_DTX_ON && st->core_brate > SID_2k40 ) { /* update CNG parameters in active frames */ #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 q_exc = Q_factor_arr( exc, L_EXC - L_EXC_MEM ); q_exc = min( q_exc, Q_factor_arr( st->hTdCngEnc->cng_exc2_buf_flt, HO_HIST_SIZE * L_FFT ) ); floatToFixed_arr16( exc, exc_fx, q_exc, L_EXC - L_EXC_MEM ); @@ -1442,21 +1463,17 @@ ivas_error acelp_core_enc( floatToFixed_arr32( st->hTdCngEnc->ho_env_circ, st->hTdCngEnc->ho_env_circ_fx, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); floatToFixed_arr16( st->hTdCngEnc->ho_lsp_circ, st->hTdCngEnc->ho_lsp_circ_fx, Q15, HO_HIST_SIZE * M ); - - // Backup - Word16 ho_circ_ptr = st->hTdCngEnc->ho_circ_ptr; - Word16 ho_circ_size = st->hTdCngEnc->ho_circ_size; - Word16 cng_buf_cnt = st->hTdCngEnc->cng_buf_cnt; - Word32 cng_brate_buf[HO_HIST_SIZE]; - for ( int j = 0; j < HO_HIST_SIZE; j++ ) - { - cng_brate_buf[j] = st->hTdCngEnc->cng_brate_buf[j]; - } - #endif // IVAS_FLOAT_FIXED_CONVERSIONS - - cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); - + cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ_fx, + &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ_fx, q_exc, ENC, st->hTdCngEnc->ho_env_circ_fx, &st->hTdCngEnc->cng_buf_cnt, + st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_Qexc_buf, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, + st->hFdCngEnc->hFdCngCom->CngBandwidth ); +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + fixedToFloat_arr( st->hTdCngEnc->ho_lsp_circ_fx, st->hTdCngEnc->ho_lsp_circ, Q15, HO_HIST_SIZE * M ); + fixedToFloat_arrL( st->hTdCngEnc->ho_env_circ_fx, st->hTdCngEnc->ho_env_circ, Q6, HO_HIST_SIZE * NUM_ENV_CNG ); + fixedToFloat_arr( st->hTdCngEnc->cng_exc2_buf, st->hTdCngEnc->cng_exc2_buf_flt, Q6, HO_HIST_SIZE * L_FFT ); +#endif +#else #ifdef IVAS_FLOAT_FIXED_CONVERSIONS // Restore st->hTdCngEnc->ho_circ_ptr = ho_circ_ptr; @@ -1467,9 +1484,9 @@ ivas_error acelp_core_enc( st->hTdCngEnc->cng_brate_buf[j] = cng_brate_buf[j]; } #endif // IVAS_FLOAT_FIXED_CONVERSIONS -#endif // IVAS_FLOAT_FIXED cng_params_upd( lsp_new, exc, st->L_frame, &st->hTdCngEnc->ho_circ_ptr, st->hTdCngEnc->ho_ener_circ, &st->hTdCngEnc->ho_circ_size, st->hTdCngEnc->ho_lsp_circ, ENC, st->hTdCngEnc->ho_env_circ, &st->hTdCngEnc->cng_buf_cnt, st->hTdCngEnc->cng_exc2_buf_flt, st->hTdCngEnc->cng_brate_buf, st->hDtxEnc->last_active_brate, st->element_mode, st->hFdCngEnc->hFdCngCom->CngBandwidth ); +#endif // IVAS_FLOAT_FIXED #ifndef IVAS_FLOAT_FIXED if ( st->L_frame == L_FRAME ) diff --git a/lib_enc/core_enc_reconf.c b/lib_enc/core_enc_reconf.c index b02d0c4385529931ec45dc8d93cf38047302913f..08278149f2e344c8a89600e706bce752108163c4 100644 --- a/lib_enc/core_enc_reconf.c +++ b/lib_enc/core_enc_reconf.c @@ -56,7 +56,11 @@ void core_coder_reconfig( int16_t bwidth, i, index; /*Configuration of ACELP*/ +#ifndef IVAS_FLOAT_FIXED BITS_ALLOC_init_config_acelp_IVAS( st->total_brate, st->narrowBand, st->nb_subfr, &( st->acelp_cfg ) ); +#else + BITS_ALLOC_init_config_acelp( st->total_brate, st->narrowBand, st->nb_subfr, &( st->acelp_cfg ) ); +#endif /*Configuration of partial copy*/ if ( st->Opt_RF_ON ) @@ -68,8 +72,13 @@ void core_coder_reconfig( st->hRF->acelp_cfg_rf.formant_enh = 1; st->hRF->acelp_cfg_rf.formant_tilt = 1; st->hRF->acelp_cfg_rf.voice_tilt = 1; +#ifndef IVAS_FLOAT_FIXED st->hRF->acelp_cfg_rf.formant_enh_num_flt = FORMANT_SHARPENING_G1_FLT; st->hRF->acelp_cfg_rf.formant_enh_den_flt = FORMANT_SHARPENING_G2_FLT; +#else + st->hRF->acelp_cfg_rf.formant_enh_num = FORMANT_SHARPENING_G1; + st->hRF->acelp_cfg_rf.formant_enh_den = FORMANT_SHARPENING_G2; +#endif } if ( st->element_mode == IVAS_CPE_MDCT ) diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index bc926b32d8b40ddb01a92f2c27c08afb37eff199..a78e88139c33d75d42d6cd4994cda921fd784b58 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -3827,7 +3827,11 @@ void IGFEncSetMode( set_f( hPrivateData->SFM_sb, 0.f, IGF_MAX_SFB ); set_f( hPrivateData->SFM_tb, 0.f, IGF_MAX_SFB ); +#ifndef IVAS_FLOAT_FIXED if ( IGFCommonFuncsIGFConfiguration_flt( total_brate, bwidth, element_mode, &hPrivateData->igfInfo, rf_mode ) ) +#else + IF( IGFCommonFuncsIGFConfiguration_ivas_fx( total_brate, bwidth, element_mode, &hPrivateData->igfInfo, rf_mode ) ) +#endif { IGFSCFEncoderOpen( &hPrivateData->hIGFSCFArithEnc, &hPrivateData->igfInfo, total_brate, bwidth, element_mode, rf_mode ); diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index cd20bc222863af811fb1abcec8b2477a9c382e6a..51ddc90803cdd39b0f5684fc25e6e62887efffef 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -430,6 +430,7 @@ ivas_error ivas_spar_agc_enc_open_fx( * Deallocate SPAR AGC encoder handle *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_spar_agc_enc_close( ivas_agc_enc_state_t **hAgcEnc /* i/o: SPAR AGC encoder handle */ ) @@ -457,8 +458,7 @@ void ivas_spar_agc_enc_close( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void ivas_spar_agc_enc_close_fx( ivas_agc_enc_state_t **hAgcEnc /* i/o: SPAR AGC encoder handle */ ) @@ -495,6 +495,7 @@ void ivas_spar_agc_enc_close_fx( * AGC encoder *-----------------------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_agc_enc_process( ivas_agc_enc_state_t *hAgcEnc, /* i/o: AGC encoder handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ @@ -725,8 +726,7 @@ void ivas_agc_enc_process( return; } - -#ifdef IVAS_FLOAT_FIXED +#else void ivas_agc_enc_process_fx( ivas_agc_enc_state_t *hAgcEnc, /* i/o: AGC encoder handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 2b8930a55ad52fa5db99bdb12ea41403de84bcd8..ec599c5fc044c1b27bfa1608eee61c73901dfa11 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -1144,14 +1144,19 @@ ivas_error ivas_cpe_enc( Etot_last_fx[1] = float_to_fix16( Etot_last[1], Q8 ); #endif tdm_configure_enc_fx( ivas_format, st_ivas->ism_mode, hCPE, Etot_last_fx, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata ); + + IF( hEncoderConfig->Opt_DTX_ON ) + { + stereo_cng_upd_counters_fx( hCPE->hStereoCng, hCPE->element_mode, -1, NULL, sts[0]->hTdCngEnc->burst_ho_cnt, NULL ); + } #else tdm_configure_enc( ivas_format, st_ivas->ism_mode, hCPE, Etot_last, tdm_SM_or_LRTD_Pri, tdm_ratio_idx, tdm_ratio_idx_SM, attack_flag[0], nb_bits_metadata ); -#endif if ( hEncoderConfig->Opt_DTX_ON ) { stereo_cng_upd_counters( hCPE->hStereoCng, hCPE->element_mode, -1, NULL, sts[0]->hTdCngEnc->burst_ho_cnt, NULL ); } +#endif } /* modify the coder_type depending on the total_brate per channel */ @@ -2344,7 +2349,11 @@ ivas_error create_cpe_enc( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Stereo Cng for Unified/TD \n" ) ); } +#ifndef IVAS_FLOAT_FIXED stereo_enc_cng_init( hCPE->hStereoCng ); +#else + stereo_enc_cng_init_fx( hCPE->hStereoCng ); +#endif } } else @@ -2634,7 +2643,7 @@ ivas_error create_cpe_enc_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Stereo Cng for Unified/TD \n" ) ); } - stereo_enc_cng_init( hCPE->hStereoCng ); + stereo_enc_cng_init_fx( hCPE->hStereoCng ); } } ELSE diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index d2e4487b326fa24ff7631d34906273dd6c07fc15..9c114e061a2a7cf92a5a3deb3ddd8890e1b4e742 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -801,10 +801,7 @@ ivas_error ivas_enc( for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) { floatToFixed_arr32( st_ivas->hParamIsm->hFbMixer->ppFilterbank_prior_input[i], st_ivas->hParamIsm->hFbMixer->ppFilterbank_prior_input_fx[i], Q14, st_ivas->hParamIsm->hFbMixer->fb_cfg->prior_input_length ); - st_ivas->hParamIsm->last_cardioid_left_fx[i] = float_to_fix16( st_ivas->hParamIsm->last_cardioid_left[i], Q14 ); } - st_ivas->hParamIsm->last_dmx_gain_e = 15 - norm_s( (Word16) st_ivas->hParamIsm->last_dmx_gain ); - st_ivas->hParamIsm->last_dmx_gain_fx = float_to_fix16( st_ivas->hParamIsm->last_dmx_gain, 15 - st_ivas->hParamIsm->last_dmx_gain_e ); #endif ivas_param_ism_enc_fx( st_ivas, data_fx, input_frame, Q14 ); @@ -820,10 +817,7 @@ ivas_error ivas_enc( for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) { fixedToFloat_arrL32( st_ivas->hParamIsm->hFbMixer->ppFilterbank_prior_input_fx[i], st_ivas->hParamIsm->hFbMixer->ppFilterbank_prior_input[i], Q14, st_ivas->hParamIsm->hFbMixer->fb_cfg->prior_input_length ); - st_ivas->hParamIsm->last_cardioid_left[i] = fixedToFloat_16( st_ivas->hParamIsm->last_cardioid_left_fx[i], Q14 ); } - - st_ivas->hParamIsm->last_dmx_gain = fixedToFloat_16( st_ivas->hParamIsm->last_dmx_gain_fx, 15 - st_ivas->hParamIsm->last_dmx_gain_e ); #endif #else ivas_param_ism_enc( st_ivas, data_f, input_frame ); diff --git a/lib_enc/ivas_ism_dtx_enc.c b/lib_enc/ivas_ism_dtx_enc.c index 5b90cb9f84926993ac6982ea403b223b81b0717b..a0f76b78fa6ab306572175af911c50814a456846 100644 --- a/lib_enc/ivas_ism_dtx_enc.c +++ b/lib_enc/ivas_ism_dtx_enc.c @@ -635,8 +635,7 @@ void ivas_ism_get_sce_id_dtx_fx( return; } -#endif // IVAS_FLOAT_FIXED - +#else void ivas_ism_get_sce_id_dtx( ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */ @@ -682,7 +681,7 @@ void ivas_ism_get_sce_id_dtx( return; } - +#endif // IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * ivas_ism_coh_estim_dtx_enc() @@ -775,8 +774,7 @@ void ivas_ism_coh_estim_dtx_enc_fx( return; } -#endif // IVAS_FLOAT_FIXED - +#else void ivas_ism_coh_estim_dtx_enc( ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */ @@ -831,3 +829,4 @@ void ivas_ism_coh_estim_dtx_enc( return; } +#endif // IVAS_FLOAT_FIXED diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 78eb1974d9b479b025605be095b7e8d089cd9177..47423d868c6154c6f7067551501bd4d0a1fd6667 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -617,20 +617,12 @@ ivas_error ivas_ism_enc( *-----------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - if ( st_ivas->hISMDTX ) - { - floatToFixed_arr16( st_ivas->hISMDTX->coh, st_ivas->hISMDTX->coh_fx, Q15, st_ivas->nchan_transport ); - } - /* compute the dominant sce_id using long term energy */ for ( int j = 0; j < st_ivas->nchan_transport; j++ ) { IF( st_ivas->hSCE[j] && st_ivas->hSCE[j]->hCoreCoder[0] ) floatToFixed_arrL( st_ivas->hSCE[j]->hCoreCoder[0]->input, st_ivas->hSCE[j]->hCoreCoder[0]->input32_fx, Q11, input_frame ); /*Q0*/ } - IF( st_ivas->hISMDTX ) - f2me_buf( &st_ivas->hISMDTX->long_term_energy_stereo_dmx_enc[0][0], &st_ivas->hISMDTX->long_term_energy_stereo_dmx_enc_fx[0][0], &st_ivas->hISMDTX->long_term_energy_stereo_dmx_enc_e, st_ivas->nchan_transport * PARAM_ISM_HYS_BUF_SIZE ); - FOR( sce_id = 0; sce_id < nchan_transport_ism; sce_id++ ) { relE_fx[sce_id][0] = float_to_fix16( relE[sce_id][0], Q8 ); @@ -833,14 +825,6 @@ ivas_error ivas_ism_enc( pop_wmops(); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - IF( st_ivas->hISMDTX ) - { - me2f_buf( &st_ivas->hISMDTX->long_term_energy_stereo_dmx_enc_fx[0][0], st_ivas->hISMDTX->long_term_energy_stereo_dmx_enc_e, &st_ivas->hISMDTX->long_term_energy_stereo_dmx_enc[0][0], st_ivas->nchan_transport * PARAM_ISM_HYS_BUF_SIZE ); - fixedToFloat_arr( st_ivas->hISMDTX->coh_fx, st_ivas->hISMDTX->coh, Q15, st_ivas->nchan_transport ); - } -#endif - return error; } #endif diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 4c27158a0f76f2297d9ad2b3fba28d7ece3431a5..baebbcee57092dfdc9967813abde871fd97c9861 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -8703,7 +8703,7 @@ static void ivas_encode_masaism_metadata_fx( } ELSE { - hOmasaData->masa_to_total_energy_ratio_fx[sf][band] = MAX_32; + hOmasaData->masa_to_total_energy_ratio_fx[sf][band] = ONE_IN_Q30; move32(); } } diff --git a/lib_enc/ivas_pca_enc.c b/lib_enc/ivas_pca_enc.c index 17cd24ba34b7bcf6648612be3b93b2dfcbac02a7..aff3a54e9170966c50109667c2c4dbe827a5dd6f 100644 --- a/lib_enc/ivas_pca_enc.c +++ b/lib_enc/ivas_pca_enc.c @@ -113,26 +113,11 @@ static void pca_enc_reset( return; } #else -static void pca_enc_reset( +static void pca_enc_reset_fx( PCA_ENC_STATE *hPCA ) { Word16 i; -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - /* reset states for interpolation and multiplexing */ - eye_matrix( hPCA->prev_eigVec, FOA_CHANNELS, 1.0f ); - set_zero( hPCA->prev_ql, IVAS_PCA_INTERP ); - hPCA->prev_ql[0] = 1.0f; - set_zero( hPCA->prev_qr, IVAS_PCA_INTERP ); - hPCA->prev_qr[0] = 1.0f; - FOR( i = 0; i < FOA_CHANNELS; i++ ) - { - hPCA->prev_D[i] = 0.25f; - } - eye_matrix( hPCA->mem_eigVec_interp, FOA_CHANNELS, 1.0f ); - set_zero( hPCA->old_r_sm, FOA_CHANNELS * FOA_CHANNELS ); -#endif - eye_matrix_fx( hPCA->prev_eigVec_fx, FOA_CHANNELS, MAX_WORD16 ); set16_fx( hPCA->prev_ql_fx, 0, IVAS_PCA_INTERP ); hPCA->prev_ql_fx[0] = MAX_WORD16; @@ -142,7 +127,7 @@ static void pca_enc_reset( move16(); FOR( i = 0; i < FOA_CHANNELS; i++ ) { - hPCA->prev_D_fx[i] = shr( MAX_WORD16, 2 ); // 0.25 in Q15 + hPCA->prev_D_fx[i] = ONE_IN_Q13; // 0.25 in Q15 move16(); } eye_matrix_fx( hPCA->mem_eigVec_interp_fx, FOA_CHANNELS, MAX_WORD16 ); @@ -154,6 +139,7 @@ static void pca_enc_reset( } #endif +#ifndef IVAS_FLOAT_FIXED static void pca_transform_sub( float *eigVec, float *transformed_data[8], /* i : input/transformed audio channels */ @@ -183,8 +169,7 @@ static void pca_transform_sub( return; } - -#ifdef IVAS_FLOAT_FIXED +#else static void pca_transform_sub_fx( Word16 *eigVec, Word32 *transformed_data[8], /* i : input/transformed audio channels Q11 */ @@ -219,9 +204,9 @@ static void pca_transform_sub_fx( return; } - #endif +#ifndef IVAS_FLOAT_FIXED static void pca_enc_transform( PCA_ENC_STATE *hPCA, float *ql, @@ -250,9 +235,7 @@ static void pca_enc_transform( return; } - - -#ifdef IVAS_FLOAT_FIXED +#else static void pca_enc_transform_fx( PCA_ENC_STATE *hPCA, Word16 *ql_fx, // Q15 @@ -282,6 +265,7 @@ static void pca_enc_transform_fx( } #endif +#ifndef IVAS_FLOAT_FIXED static void pca_update_state( PCA_ENC_STATE *hPCA, float *ql, @@ -295,9 +279,7 @@ static void pca_update_state( return; } - - -#ifdef IVAS_FLOAT_FIXED +#else static void pca_update_state_fx( PCA_ENC_STATE *hPCA, Word16 *ql, // Q15 @@ -313,6 +295,7 @@ static void pca_update_state_fx( } #endif +#ifndef IVAS_FLOAT_FIXED static void swap_eigvec( float *eigVec, const int16_t i, @@ -336,8 +319,7 @@ static void swap_eigvec( return; } - -#ifdef IVAS_FLOAT_FIXED +#else static void swap_eigvec_fx( Word32 *eigVec, // Q31 const Word32 i, @@ -366,6 +348,7 @@ static void swap_eigvec_fx( } #endif +#ifndef IVAS_FLOAT_FIXED static void sort4_D_eigVec( float *D, float *eigVec ) @@ -408,8 +391,7 @@ static void sort4_D_eigVec( return; } - -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS +#else static void sort4_D_eigVec_fx( Word32 *D, // Q Word32 *eigVec // Q31 @@ -460,14 +442,15 @@ static void sort4_D_eigVec_fx( * * Initialize PCA encoder *------------------------------------------------------------------------*/ + #ifdef IVAS_FLOAT_FIXED -void ivas_pca_enc_init( +void ivas_pca_enc_init_fx( PCA_ENC_STATE *hPCA /* i/o: PCA encoder structure */ ) { hPCA->prev_bypass_decision = PCA_MODE_INACTIVE; move32(); - pca_enc_reset( hPCA ); + pca_enc_reset_fx( hPCA ); return; } @@ -489,6 +472,7 @@ void ivas_pca_enc_init( * PCA encoder *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ivas_pca_enc( const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ PCA_ENC_STATE *hPCA, /* i : PCA encoder structure */ @@ -824,7 +808,7 @@ void ivas_pca_enc( return; } - +#else void ivas_pca_enc_fx( const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ PCA_ENC_STATE *hPCA, /* i : PCA encoder structure */ @@ -878,7 +862,7 @@ void ivas_pca_enc_fx( /* handle bitrate switching */ IF( NE_32( ivas_total_brate, PCA_BRATE ) ) { - pca_enc_reset( hPCA ); + pca_enc_reset_fx( hPCA ); IF( NE_32( hEncoderConfig->last_ivas_total_brate, PCA_BRATE ) ) { @@ -1270,3 +1254,4 @@ void ivas_pca_enc_fx( pca_update_state_fx( hPCA, ql_fx, qr_fx, eigVec_fx16, n_channels ); return; } +#endif diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 9ffd91825e77a8775d5e7196b7a280fd0531af39..af582936591d6f9fa25c2a294ff5b049a379cc8c 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -213,7 +213,11 @@ ivas_error ivas_spar_enc_open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR PCA encoder" ); } +#ifndef IVAS_FLOAT_FIXED ivas_pca_enc_init( hSpar->hPCA ); +#else + ivas_pca_enc_init_fx( hSpar->hPCA ); +#endif } /* initialization */ @@ -407,7 +411,7 @@ ivas_error ivas_spar_enc_open_fx( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR PCA encoder" ); } - ivas_pca_enc_init( hSpar->hPCA ); + ivas_pca_enc_init_fx( hSpar->hPCA ); } /* initialization */ @@ -1459,13 +1463,6 @@ static ivas_error ivas_spar_enc_process( p_pcm_tmp[i][j] = fix_to_float( p_pcm_tmp_fx[i][j], q_pcm_fx[i] ); } } - fixedToFloat_arr( hSpar->hPCA->prev_qr_fx, hSpar->hPCA->prev_qr, Q15, IVAS_PCA_INTERP ); - fixedToFloat_arr( hSpar->hPCA->prev_ql_fx, hSpar->hPCA->prev_ql, Q15, IVAS_PCA_INTERP ); - fixedToFloat_arr( hSpar->hPCA->prev_eigVec_fx, hSpar->hPCA->prev_eigVec, Q15, FOA_CHANNELS * FOA_CHANNELS ); - FOR( Word16 k = 0; k < 16; k++ ) - { - hSpar->hPCA->old_r_sm[k] = fixedToFloat( hSpar->hPCA->old_r_sm_fx[k], hSpar->hPCA->old_r_sm_q ); - } #else ivas_pca_enc( hEncoderConfig, hSpar->hPCA, hMetaData, p_pcm_tmp, input_frame, FOA_CHANNELS ); #endif diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 1b07f61a6d343a04d2328f6e5325510048f0e781..11c2007a114d46d0dbd0601df373d1099051a785 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -457,7 +457,7 @@ ivas_error ivas_spar_md_enc_init( } } } - hMdEnc->q_mixer_mat_fx = Q31; + hMdEnc->q_mixer_mat_fx = Q30; move16(); #endif diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index eae4255072df2702f022b00915f0e471eba7026b..84b5fa9cb54acc7b82599d1ff911dbdf9618e48b 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -313,7 +313,9 @@ typedef struct stereo_dft_enc_data_struct int16_t res_pred_flag_1; int16_t res_pred_flag_2; int16_t res_pred_counter; +#ifndef IVAS_FLOAT_FIXED float res_pred_gain_f[STEREO_DFT_BAND_MAX]; +#endif int16_t res_pred_index_EC[STEREO_DFT_BAND_MAX]; int16_t res_pred_index_ECDiff[STEREO_DFT_BAND_MAX]; int16_t res_pred_index_ECprevious[STEREO_DFT_BAND_MAX]; @@ -331,7 +333,9 @@ typedef struct stereo_dft_enc_data_struct float res_cod_NRG_M[STEREO_DFT_BAND_MAX]; float res_cod_NRG_S[STEREO_DFT_BAND_MAX]; float res_cod_SNR_M[STEREO_DFT_BAND_MAX]; +#ifndef IVAS_FLOAT_FIXED float old_snr; +#endif int16_t first_frm_flag; /* ADAP first frame flag */ /* flags and data for adaptive wideband residual coding */ @@ -884,13 +888,15 @@ typedef struct Word16 long_term_energy_stereo_dmx_enc_e; Word16 coh_fx[MAX_NUM_OBJECTS]; #endif // IVAS_FLOAT_FIXED - int16_t dtx_flag; - int16_t sce_id_dtx; + Word16 dtx_flag; + Word16 sce_id_dtx; - int16_t cnt_SID_ISM; + Word16 cnt_SID_ISM; +#ifndef IVAS_FLOAT_FIXED float long_term_energy_stereo_dmx_enc[MAX_NUM_OBJECTS][PARAM_ISM_HYS_BUF_SIZE]; float coh[MAX_NUM_OBJECTS]; +#endif } ISM_DTX_DATA, *ISM_DTX_HANDLE; /*----------------------------------------------------------------------------------* @@ -1002,33 +1008,38 @@ typedef struct ivas_dirac_enc_data_structure /* AGC structures */ typedef struct ivas_agc_enc_chan_state_t { - int16_t lastExp; - int16_t prevExp; + Word16 lastExp; + Word16 prevExp; +#ifndef IVAS_FLOAT_FIXED float lastGain; float lastMaxAbs; - int16_t gainExpVal; - float MaxAbsVal_del; - int16_t MaxAbsValIdx_del; -#ifdef IVAS_FLOAT_FIXED - Word32 lastGain_fx; - Word32 lastMaxAbs_fx; - Word32 MaxAbsVal_del_fx; +#else + Word32 lastGain_fx; /* Q(q_lastGain_fx) */ Word16 q_lastGain_fx; + Word32 lastMaxAbs_fx; /* Q(q_lastMaxAbs_fx) */ Word16 q_lastMaxAbs_fx; +#endif + Word16 gainExpVal; +#ifndef IVAS_FLOAT_FIXED + float MaxAbsVal_del; +#else + Word32 MaxAbsVal_del_fx; /* Q(q_MaxAbsVal_del_fx) */ Word16 q_MaxAbsVal_del_fx; #endif + Word16 MaxAbsValIdx_del; } ivas_agc_enc_chan_state_t; typedef struct ivas_agc_enc_state_t { ivas_agc_com_state_t agc_com; -#ifdef IVAS_FLOAT_FIXED - Word32 minDelta_fx; - Word32 smFact_fx; -#endif +#ifndef IVAS_FLOAT_FIXED float minDelta; float smFact; +#else + Word32 minDelta_fx; /* Q31 */ + Word32 smFact_fx; /* Q31 */ +#endif ivas_agc_enc_chan_state_t *gain_state; ivas_agc_chan_data_t *gain_data; @@ -1073,15 +1084,15 @@ typedef struct ivas_spar_md_enc_state_t /* PCA structure */ typedef struct { - int16_t prev_bypass_decision; + Word16 prev_bypass_decision; +#ifndef IVAS_FLOAT_FIXED float prev_eigVec[FOA_CHANNELS * FOA_CHANNELS]; float prev_ql[IVAS_PCA_INTERP]; float prev_qr[IVAS_PCA_INTERP]; float prev_D[IVAS_PCA_INTERP]; float mem_eigVec_interp[FOA_CHANNELS * FOA_CHANNELS]; float old_r_sm[FOA_CHANNELS * FOA_CHANNELS]; - -#ifdef IVAS_FLOAT_FIXED +#else Word16 prev_eigVec_fx[FOA_CHANNELS * FOA_CHANNELS]; // Q15 Word16 prev_ql_fx[IVAS_PCA_INTERP]; // Q15 Word16 prev_qr_fx[IVAS_PCA_INTERP]; // Q15 @@ -1129,24 +1140,28 @@ typedef struct ivas_spar_enc_lib_t typedef struct ivas_param_mc_enc_data_structure { IVAS_FB_MIXER_HANDLE hFbMixer; - int16_t transient_detector_delay; + Word16 transient_detector_delay; +#ifndef IVAS_FLOAT_FIXED const float *dmx_factors; - - const Word32 *dmx_factors_fx; +#else + const Word32 *dmx_factors_fx; /* Q31 */ +#endif /* Multichannel Specific Parameters */ IVAS_PARAM_MC_METADATA hMetadataPMC; - int16_t band_grouping[PARAM_MC_MAX_PARAMETER_BANDS + 1]; - int16_t lfe_index; - int16_t icc_map_index[PARAM_MC_PARAMETER_FRAMES][PARAM_MC_SZ_ICC_MAP]; - int16_t max_param_band_abs_cov; + Word16 band_grouping[PARAM_MC_MAX_PARAMETER_BANDS + 1]; + Word16 lfe_index; + Word16 icc_map_index[PARAM_MC_PARAMETER_FRAMES][PARAM_MC_SZ_ICC_MAP]; + Word16 max_param_band_abs_cov; +#ifndef IVAS_FLOAT_FIXED float prev_ilds[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_SZ_ILD_MAP]; - Word32 prev_ilds_fx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_SZ_ILD_MAP]; /*Q21*/ - float ener_fac[PARAM_MC_MAX_PARAMETER_BANDS]; +#else + Word32 prev_ilds_fx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_SZ_ILD_MAP]; /*Q21*/ Word32 ener_fac_fx[PARAM_MC_MAX_PARAMETER_BANDS]; /*Q21*/ +#endif } PARAM_MC_ENC_DATA, *PARAM_MC_ENC_HANDLE; @@ -1487,23 +1502,24 @@ typedef struct ivas_osba_enc_data_structure typedef struct stereo_cng_enc { - Word16 prev_sg_average_counter; /* Counter for sidegain averaging */ - Word16 sg_active_cnt; /* Counter for sidegain averaging */ - Word16 sg_average_counter; /* Counter for sidegain averaging */ - float sg_average[STEREO_DFT_ERB4_BANDS]; /* Sidegain average */ -#ifndef IVAS_FLOAT_FIXED - float prev_sg_average[STEREO_DFT_ERB4_BANDS]; /* Previous sidegain average */ -#endif - float mem_cohBand[STEREO_DFT_BAND_MAX / 2]; /* Coherence memory */ - float prev_cohBand[2 * ( STEREO_DFT_BAND_MAX / 2 )]; /* Previous coherence */ - Word16 cng_counter; /* Counter for cng period length */ - Word16 td_active; /* TD-stereo indication */ - Word16 first_SID_after_TD; /* Set if first SID frame after TD stereo */ - Word16 first_SID; /* Set if first SID frame since codec start */ + Word16 prev_sg_average_counter; /* Counter for sidegain averaging */ + Word16 sg_active_cnt; /* Counter for sidegain averaging */ + Word16 sg_average_counter; /* Counter for sidegain averaging */ +#ifndef IVAS_FLOAT_FIXED + float sg_average[STEREO_DFT_ERB4_BANDS]; /* Sidegain average */ + float prev_sg_average[STEREO_DFT_ERB4_BANDS]; /* Previous sidegain average */ + float mem_cohBand[STEREO_DFT_BAND_MAX / 2]; /* Coherence memory */ + float prev_cohBand[2 * ( STEREO_DFT_BAND_MAX / 2 )]; /* Previous coherence */ +#else Word32 sg_average_fx[STEREO_DFT_ERB4_BANDS]; /* Sidegain average Q26 */ - Word32 prev_sg_average_fx[STEREO_DFT_ERB4_BANDS]; /* Previous sidegain average Q26 */ - Word32 mem_cohBand_fx[STEREO_DFT_BAND_MAX / 2]; /* Coherence memory */ - Word32 prev_cohBand_fx[2 * ( STEREO_DFT_BAND_MAX / 2 )]; /* Previous coherence */ + Word32 prev_sg_average_fx[STEREO_DFT_ERB4_BANDS]; /* Previous sidegain average Q26 */ + Word32 mem_cohBand_fx[STEREO_DFT_BAND_MAX / 2]; /* Coherence memory Q31 */ + Word32 prev_cohBand_fx[2 * ( STEREO_DFT_BAND_MAX / 2 )]; /* Previous coherence Q31 */ +#endif + Word16 cng_counter; /* Counter for cng period length */ + Word16 td_active; /* TD-stereo indication */ + Word16 first_SID_after_TD; /* Set if first SID frame after TD stereo */ + Word16 first_SID; /* Set if first SID frame since codec start */ } STEREO_CNG_ENC, *STEREO_CNG_ENC_HANDLE; diff --git a/lib_enc/ivas_stereo_cng_enc.c b/lib_enc/ivas_stereo_cng_enc.c index a9dc30e44ba35a3a5cedb55ed6a0d4f0a718dcc7..7fd2e47665b977f5af2ccc08196fac7f964d28eb 100644 --- a/lib_enc/ivas_stereo_cng_enc.c +++ b/lib_enc/ivas_stereo_cng_enc.c @@ -1011,35 +1011,52 @@ void stereo_dft_cng_side_gain( * Initializes counters and averages * ---------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void stereo_enc_cng_init_fx( + STEREO_CNG_ENC_HANDLE hStereoCng /* i/o: stereo CNG encoder structure */ +) +{ + hStereoCng->sg_average_counter = 0; + move16(); + set32_fx( hStereoCng->sg_average_fx, 0, STEREO_DFT_BAND_MAX ); + hStereoCng->prev_sg_average_counter = 0; + move16(); + set32_fx( hStereoCng->prev_sg_average_fx, 0, STEREO_DFT_BAND_MAX ); + hStereoCng->sg_active_cnt = 0; + move16(); + hStereoCng->first_SID = 1; + move16(); + set32_fx( hStereoCng->mem_cohBand_fx, ONE_IN_Q30, STEREO_DFT_BAND_MAX / 2 ); + set32_fx( hStereoCng->prev_cohBand_fx, 0, 2 * ( STEREO_DFT_BAND_MAX / 2 ) ); + hStereoCng->td_active = 0; + move16(); + hStereoCng->first_SID_after_TD = 1; + move16(); + hStereoCng->cng_counter = 0; + move16(); + + return; +} +#else void stereo_enc_cng_init( STEREO_CNG_ENC_HANDLE hStereoCng /* i/o: stereo CNG encoder structure */ ) { hStereoCng->sg_average_counter = 0; set_zero( hStereoCng->sg_average, STEREO_DFT_BAND_MAX ); -#ifdef IVAS_FLOAT_FIXED - set32_fx( hStereoCng->sg_average_fx, 0, STEREO_DFT_BAND_MAX ); -#endif hStereoCng->prev_sg_average_counter = 0; -#ifndef IVAS_FLOAT_FIXED set_zero( hStereoCng->prev_sg_average, STEREO_DFT_BAND_MAX ); -#else - set32_fx( hStereoCng->prev_sg_average_fx, 0, STEREO_DFT_BAND_MAX ); -#endif hStereoCng->sg_active_cnt = 0; hStereoCng->first_SID = 1; set_f( hStereoCng->mem_cohBand, 0.5f, STEREO_DFT_BAND_MAX / 2 ); /*Q31*/ set_zero( hStereoCng->prev_cohBand, 2 * ( STEREO_DFT_BAND_MAX / 2 ) ); -#ifdef IVAS_FLOAT_FIXED - set32_fx( hStereoCng->mem_cohBand_fx, ONE_IN_Q30, STEREO_DFT_BAND_MAX / 2 ); - set32_fx( hStereoCng->prev_cohBand_fx, 0, 2 * ( STEREO_DFT_BAND_MAX / 2 ) ); -#endif hStereoCng->td_active = 0; hStereoCng->first_SID_after_TD = 1; hStereoCng->cng_counter = 0; return; } +#endif /*------------------------------------------------------------------------- @@ -1098,7 +1115,7 @@ void stereo_cng_upd_counters_fx( } return; } -#endif +#else void stereo_cng_upd_counters( STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ const int32_t element_mode, /* i : element mode */ @@ -1140,3 +1157,4 @@ void stereo_cng_upd_counters( } return; } +#endif diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index f4afc47ab1b9145e03dbbcb33ae6d06b4bd0855a..bf03b282537d794ed29aacf05b54eddf9d83597f 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -1027,7 +1027,9 @@ void stereo_dft_enc_reset( hStereoDft->res_cod_NRG_M[i] = 0; hStereoDft->res_cod_NRG_S[i] = 0; } +#ifndef IVAS_FLOAT_FIXED hStereoDft->old_snr = 0.f; +#endif hStereoDft->reverb_flag = 0; @@ -1036,8 +1038,8 @@ void stereo_dft_enc_reset( hStereoDft->diff_l_h_sm = 0.0f; hStereoDft->diff_r_h_sm = 0.0f; hStereoDft->prev_fac2 = 1.0f; -#endif set_zero( hStereoDft->res_pred_gain_f, STEREO_DFT_BAND_MAX ); +#endif /*misc*/ hStereoDft->no_ipd_flag = 1; /* Initialization of the no IPD variables */ diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index e57aadf5d7d14f04c53efaa7fd1e8532bf573878..6854716ae7f91a422b316126b59a72a7a5849e12 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -1414,7 +1414,6 @@ void stereo_mdct_core_enc( { st->hIGFEnc->tns_predictionGain = float_to_fix16( st->hIGFEnc->tns_predictionGain_flt, Q23 ); } - // floatToFixed_arr16( &hPrivateData->igfInfo.grid[igfGridIdx].whiteningThreshold_flt[0][0], &hPrivateData->igfInfo.grid[igfGridIdx].whiteningThreshold[0][0], Q13, 2 * IGF_MAX_TILES ); #endif ProcessIGF_ivas_fx( st, st->hTcxEnc->spectrum_fx[n], orig_spectrum_fx[ch][n], &q_spectrum, &powerSpec_fx[ch][n * L_subframeTCX], &q_powerSpec, st->core == TCX_20_CORE, n, hCPE->hCoreCoder[0]->sp_aud_decision0, 0 ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 96dab941ca4572b7c3f26f76ee2b69078f3d075b..5cb71c096a3d2abc42dbb6d300a90a92949081ea 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -543,7 +543,7 @@ ivas_error stereo_memory_enc_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Stereo Cng for Unified/TD\n" ) ); } - stereo_enc_cng_init( hCPE->hStereoCng ); + stereo_enc_cng_init_fx( hCPE->hStereoCng ); } } diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index 926a1930d8599c38c0781a395e49d0a4ebea7bad..8a73b6616120a4edfa152fe3eb83f6198b783511 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -1625,7 +1625,7 @@ Word16 ivas_acelp_tcx20_switching_fx( move16(); } - basop_E_LPC_f_lsp_a_conversion( lsp_mid, A_q_tcx_fx, M ); + E_LPC_f_lsp_a_conversion( lsp_mid, A_q_tcx_fx, M ); Q_A_q_tcx = sub( 14, norm_s( A_q_tcx_fx[0] ) ); scale_A = sub( Q12, Q_A_q_tcx ); Copy_Scale_sig( A_q_tcx_fx, A_q_tcx_fx, M + 1, scale_A ); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index ce072891d4b853256a7a845aaca9ef9c6a084b5b..a8130236d47ebc79b61b46e1d03170adda284f9c 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -2844,8 +2844,14 @@ static ivas_error sanitizeBandwidth_fx( } ELSE { + Word32 quo = 0, rem; + move32(); + IF( EQ_16( hEncoderConfig->ivas_format, ISM_FORMAT ) ) + { + iDiv_and_mod_32( hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism, &quo, &rem, 0 ); + } IF( EQ_16( max_bwidth_tmp, FB ) && ( ( NE_16( hEncoderConfig->ivas_format, ISM_FORMAT ) && LT_32( hEncoderConfig->ivas_total_brate, MIN_BRATE_FB_STEREO ) ) || - ( EQ_16( hEncoderConfig->ivas_format, ISM_FORMAT ) && LT_32( div_l( hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ), MIN_BRATE_FB_ISM ) ) ) ) + ( EQ_16( hEncoderConfig->ivas_format, ISM_FORMAT ) && LT_32( quo, MIN_BRATE_FB_ISM ) ) ) ) { max_bwidth_tmp = SWB; } diff --git a/lib_enc/updt_enc.c b/lib_enc/updt_enc.c index b6178439a89398c13bdbd413d1bf3a895a6a742a..9c48b93a5246ce5b3a81c346e4a62881bf5e2049 100644 --- a/lib_enc/updt_enc.c +++ b/lib_enc/updt_enc.c @@ -52,6 +52,7 @@ * Common updates (all frame types) *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void updt_enc( Encoder_State *st, /* i/o: state structure */ const float *old_exc, /* i : buffer of excitation */ @@ -151,7 +152,6 @@ void updt_enc( return; } -#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * updt_IO_switch() *