diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index 458e473aaf848d7093a359a2f0f54cb6e8a2c926..583051b2321b59f4ea863bf7af2953523899fa8e 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -811,15 +811,8 @@ void ivas_ism_reset_metadata_enc( move32(); hIsmMeta->pitch_fx = 0; move32(); - hIsmMeta->radius_fx = 1 << 9; + hIsmMeta->radius_fx = 1 << 9; // Q9 move16(); -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - hIsmMeta->azimuth = 0.0f; - hIsmMeta->elevation = 0.0f; - hIsmMeta->yaw = 0.0f; - hIsmMeta->pitch = 0.0f; - hIsmMeta->radius = 1.0f; -#endif hIsmMeta->ism_metadata_flag = 0; move16(); hIsmMeta->non_diegetic_flag = 0; diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index f0181aa9e4a87ffb3e40c51d7e28e76ec6509652..5ffc7f4f343229040aeec57faaf3c835acd830a1 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -6506,7 +6506,7 @@ void ivas_enc_cov_handler_process_fx( ivas_enc_cov_handler_state_t *hCovEnc, /* i/o: SPAR Covar. encoder handle */ Word32 **ppIn_FR_real, Word32 **ppIn_FR_imag, - Word16 *q_ppIn_FR, + Word16 q_ppIn_FR, Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], Word16 *q_cov_real[IVAS_SPAR_MAX_CH], Word32 *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index 17bc88128034bd1c9230c16afcad756fedc89647..fb5cb5792e8109bbb3b6f253499bc91fe117f0b9 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -3814,7 +3814,7 @@ void ivas_get_spar_md_from_dirac_fx( } ELSE { - cov_real_dirac_fx[i][j][band] = L_shl_sat( Mpy_32_32( Mpy_32_32( en_ratio_fac_fx, response_avg_fx[i] ), response_avg_fx[j] ), 1 ); + cov_real_dirac_fx[i][j][band] = L_shl( Mpy_32_32( Mpy_32_32( en_ratio_fac_fx, response_avg_fx[i] ), response_avg_fx[j] ), 1 ); move32(); } } diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 4cb4168dfadba8ecdc1acd48731c606530ab473f..5fdcf2bc18371b84902a94e27f30e6cef6dcf82a 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -65,12 +65,13 @@ typedef struct Word16 radius_fx; /* radius value read from the input metadata file */ /* Q9 */ Word32 yaw_fx; /* yaw value read from the input metadata file */ /* Q22 */ Word32 pitch_fx; /* pitch value read from the input metadata file */ /* Q22 */ +#else + float azimuth; /* azimuth value read from the input metadata file */ + float elevation; /* elevation value read from the input metadata file */ + float radius; /* radius value read from the input metadata file */ + float yaw; /* yaw value read from the input metadata file */ + float pitch; /* pitch value read from the input metadata file */ #endif - float azimuth; /* azimuth value read from the input metadata file */ - float elevation; /* elevation value read from the input metadata file */ - float radius; /* radius value read from the input metadata file */ - float yaw; /* yaw value read from the input metadata file */ - float pitch; /* pitch value read from the input metadata file */ int16_t non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */ @@ -79,11 +80,12 @@ typedef struct int16_t last_radius_idx; /* last frame index of coded radius */ int16_t radius_diff_cnt; /* FEC counter of consecutive differentially radius coded frames */ +#ifndef IVAS_FLOAT_FIXED float last_azimuth; /* MD smoothing in DTX- last Q azimuth value */ float last_elevation; /* MD smoothing in DTX - last Q elevation value */ float last_true_azimuth; /* MD smoothing in DTX- last true Q azimuth value */ float last_true_elevation; /* MD smoothing in DTX- last true Q elevation value */ -#ifdef IVAS_FLOAT_FIXED +#else Word32 last_azimuth_fx; /* MD smoothing in DTX- last Q azimuth value */ /* Q22 */ Word32 last_elevation_fx; /* MD smoothing in DTX - last Q elevation value */ /* Q22 */ Word32 last_true_azimuth_fx; /* MD smoothing in DTX- last true Q azimuth value */ /* Q22 */ @@ -92,9 +94,10 @@ typedef struct int16_t ism_md_fec_cnt_enc; /* counter of continuous frames where MD are not transmitted */ int16_t ism_md_inc_diff_cnt; /* counter of continuous frames where MD are transmitted in inactive segments when MD significantly changes */ - float last_true_radius; /* last true Q radius value */ -#ifdef IVAS_FLOAT_FIXED - Word16 last_true_radius_fx; /* last true Q radius value */ +#ifndef IVAS_FLOAT_FIXED + float last_true_radius; /* last true Q radius value */ +#else + Word16 last_true_radius_fx; /* last true Q radius value */ #endif int16_t ism_imp; /* ISM importance flag */ @@ -103,9 +106,10 @@ typedef struct #ifdef IVAS_FLOAT_FIXED Word32 q_azimuth_old_fx; Word32 q_elevation_old_fx; -#endif +#else float q_azimuth_old; float q_elevation_old; +#endif } ISM_METADATA_FRAME, *ISM_METADATA_HANDLE; @@ -453,15 +457,16 @@ typedef struct ivas_masa_descriptive_meta_struct typedef struct ivas_masa_directional_spatial_meta_struct { +#ifndef IVAS_FLOAT_FIXED float azimuth[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float elevation[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float spread_coherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; -#ifdef IVAS_FLOAT_FIXED - Word32 azimuth_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q22 */ - Word32 elevation_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q22 */ - Word32 energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q30 */ - Word16 spread_coherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q15 */ +#else + Word32 azimuth_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q22 */ + Word32 elevation_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q22 */ + Word32 energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q30 */ + Word16 spread_coherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Q15 */ #endif uint16_t spherical_index[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; @@ -469,14 +474,15 @@ typedef struct ivas_masa_directional_spatial_meta_struct typedef struct ivas_masa_common_spatial_meta_struct { +#ifndef IVAS_FLOAT_FIXED float diffuse_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float surround_coherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; -#ifdef IVAS_FLOAT_FIXED + float remainder_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; +#else Word32 diffuse_to_total_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q30 - Word16 surround_coherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q14 + Word16 surround_coherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q15 Word32 remainder_to_total_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; // Q30 #endif - float remainder_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; } MASA_COMMON_SPATIAL_META; @@ -611,7 +617,7 @@ typedef struct ivas_masa_qmetadata_frame_struct #ifndef IVAS_FLOAT_FIXED float dir_comp_ratio; #else - Word16 dir_comp_ratio_fx; /* Q15 */ + Word16 dir_comp_ratio_fx; /* Q15 */ #endif uint8_t is_masa_ivas_format; diff --git a/lib_com/prot.h b/lib_com/prot.h index c430c9c3dee77e62aa0071b14a547fac4768ab1d..d0fc8d2ff457fef60d1bf1d5fb0f2b7240750027 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -9345,6 +9345,7 @@ void FEC_clas_estim( const int16_t FEC_mode /* i : ACELP FEC mode */ ); +#ifndef IVAS_FLOAT_FIXED void InitTransientDetection( const int16_t nFrameLength, const int16_t nTCXDelay, @@ -9367,6 +9368,7 @@ float GetTCXMaxenergyChange( const int16_t isTCX10, const int16_t nCurrentSubblocks, const int16_t nPrevSubblocks ); +#endif void SetTCXModeInfo( Encoder_State *st, /* i/o: encoder state structure */ diff --git a/lib_dec/ACcontextMapping_dec.c b/lib_dec/ACcontextMapping_dec.c index 952303ce872c0a8dc0e816c18bb8238bcc536d4f..470e11e64bbbe940415e30fd4d2ebb2f2a8e2afc 100644 --- a/lib_dec/ACcontextMapping_dec.c +++ b/lib_dec/ACcontextMapping_dec.c @@ -44,6 +44,7 @@ #include "ivas_prot.h" /* Range coder header file */ #include +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * ACcontextMapping_decode2_no_mem_s17_LC_ivas() * @@ -51,7 +52,6 @@ *-------------------------------------------------------------------*/ /*! r: resQBits */ -#ifndef IVAS_FLOAT_FIXED int16_t ACcontextMapping_decode2_no_mem_s17_LC_ivas( Decoder_State *st, /* i/o: decoder state */ int16_t *x, /* o : decoded spectrum */ @@ -319,7 +319,7 @@ int16_t ACcontextMapping_decode2_no_mem_s17_LC_ivas( return resQBits; } -#endif + /*-------------------------------------------------------------------* * RCcontextMapping_decode2_no_mem_s17_LCS() @@ -328,7 +328,7 @@ int16_t ACcontextMapping_decode2_no_mem_s17_LC_ivas( *-------------------------------------------------------------------*/ /*! r: resQBits */ -#ifndef IVAS_FLOAT_FIXED + int16_t RCcontextMapping_decode2_no_mem_s17_LCS( Decoder_State *st, /* i/o: decoder state */ int16_t *x, /* o : decoded spectrum */ diff --git a/lib_dec/FEC.c b/lib_dec/FEC.c index 3f19f35eb7712783a6ea6e7ae50ca90a3d4d5e70..dc36007289920ef9bfaf557139f16ed2f0eb789f 100644 --- a/lib_dec/FEC.c +++ b/lib_dec/FEC.c @@ -43,24 +43,20 @@ #include "prot.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void gain_dec_bfi( float *past_qua_en ); -#endif - -#ifndef IVAS_FLOAT_FIXED static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word16 new_pit, Word16 Tc, Word16 L_frame ); -#endif /*-------------------------------------------------------------------* * FEC_exc_estim() * * Calculation of excitation signal *-------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED + void FEC_exc_estim( Decoder_State *st, /* i/o: Decoder static memory */ const int16_t L_frame, /* i : length of the frame */ @@ -482,7 +478,6 @@ void FEC_exc_estim( return; } -#endif /*-------------------------------------------------------------------* @@ -492,7 +487,7 @@ void FEC_exc_estim( * next frame *-------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED + static void gain_dec_bfi( float *past_qua_en /* i/o: gain quantization memory (4 words) */ ) @@ -522,9 +517,13 @@ static void gain_dec_bfi( return; } -#endif +/*-------------------------------------------------------------------* + * Local function prototypes + *-------------------------------------------------------------------*/ +#endif + #define WMC_TOOL_SKIP /*-------------------------------------------------------------------* * pulseRes_preCalc() diff --git a/lib_dec/FEC_HQ_core.c b/lib_dec/FEC_HQ_core.c index 17fe13469f79f9f2b974cf23dc4365c003f8b7ee..e9695a9efc0c2fa649b8c03af983f748d5a659ce 100644 --- a/lib_dec/FEC_HQ_core.c +++ b/lib_dec/FEC_HQ_core.c @@ -1550,17 +1550,15 @@ void save_synthesis_hq_fec_fx( { case EVS_MONO: post_hq_delay = NS2SA_FX2( st->output_Fs, POST_HQ_DELAY_NS ); - move16(); BREAK; case IVAS_SCE: post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); - move16(); BREAK; case IVAS_CPE_DFT: + test(); IF( EQ_16( hCPE->nchan_out, 1 ) && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) { post_hq_delay = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); - move16(); } ELSE { @@ -1579,13 +1577,13 @@ void save_synthesis_hq_fec_fx( test(); test(); test(); - IF( ( EQ_16( st->codec_mode, MODE1 ) && st->hTcxDec != NULL ) && ( ( EQ_16( st->core, ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) ) + IF( ( EQ_16( st->codec_mode, MODE1 ) && st->hTcxDec != NULL ) && ( ( ( st->core == ACELP_CORE ) && !( EQ_16( st->bfi, 1 ) && EQ_16( st->con_tcx, 1 ) ) ) || EQ_16( st->core, HQ_CORE ) ) ) { Copy( st->hTcxDec->synth_history_fx + output_frame, st->hTcxDec->synth_history_fx, add( sub( output_frame, post_hq_delay ), NS2SA_FX2( st->output_Fs, PH_ECU_MEM_NS ) ) ); FOR( Word16 i = 0; i < output_frame; i++ ) { #ifdef FIX_856_EXTRACT_L - st->hTcxDec->old_synthFB_fx[sub( add( i, output_frame ), post_hq_delay )] = extract_h( L_shl_sat( output_fx[i], 16 ) ); + st->hTcxDec->old_synthFB_fx[( ( i + output_frame ) - post_hq_delay )] = extract_h( L_shl_sat( output_fx[i], 16 ) ); // Q16 #else st->hTcxDec->old_synthFB_fx[sub( add( i, output_frame ), post_hq_delay )] = extract_l( output_fx[i] ); #endif diff --git a/lib_dec/FEC_HQ_phase_ecu.c b/lib_dec/FEC_HQ_phase_ecu.c index 3ab4ca0ef1219d61f6cb5c8505df8faa9f3ece0c..7a46d308bb0d8a16a11cc81c1ffec0305246bb8f 100644 --- a/lib_dec/FEC_HQ_phase_ecu.c +++ b/lib_dec/FEC_HQ_phase_ecu.c @@ -43,6 +43,7 @@ #include "prot.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * Local constants *---------------------------------------------------------------------*/ @@ -98,10 +99,8 @@ * Local functions *---------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static int16_t rand_phase( const int16_t seed, float *sin_F, float *cos_F ); static float imax2_jacobsen_mag( const float *y_re, const float *y_im ); -#endif /*-------------------------------------------------------------------* * mult_rev2() @@ -109,7 +108,7 @@ static float imax2_jacobsen_mag( const float *y_re, const float *y_im ); * Multiplication of two vectors second vector is multiplied in reverse order *-------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED + static void mult_rev2( const float x1[], /* i : Input vector 1 */ const float x2[], /* i : Input vector 2 */ @@ -126,7 +125,6 @@ static void mult_rev2( return; } -#endif /*-------------------------------------------------------------------* @@ -135,7 +133,6 @@ static void mult_rev2( * Square magnitude of fft spectrum *-------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void fft_spec2( float x[], /* i/o: Input vector: complex spectrum -> square magnitude spectrum */ const int16_t N /* i : Vector length */ @@ -153,7 +150,7 @@ static void fft_spec2( return; } -#endif + /*------------------------------------------------------------------* * rand_phase() @@ -161,7 +158,6 @@ static void fft_spec2( * randomized phase in form of sin and cos components *------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED /*! r: Updated seed from RNG */ static int16_t rand_phase( const int16_t seed, /* i : RNG seed */ @@ -193,7 +189,7 @@ static int16_t rand_phase( return seed2; } -#endif + /*----------------------------------------------------------------------------- * imax2_jacobsen_mag() @@ -262,7 +258,6 @@ float imax2_jacobsen_mag( return posi; } -#endif /*------------------------------------------------------------------* @@ -271,7 +266,7 @@ float imax2_jacobsen_mag( * Transient analysis *------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED + static void trans_ana( const float *xfp, /* i : Input signal */ float *mag_chg, /* i/o: Magnitude modification */ @@ -453,7 +448,6 @@ static void trans_ana( return; } -#endif /*------------------------------------------------------------------* @@ -462,7 +456,6 @@ static void trans_ana( * Peak-picking algorithm *------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED void peakfinder( const float *x0, /* i : vector from which the maxima will be found */ const int16_t len0, /* i : length of input vector */ @@ -659,7 +652,7 @@ void peakfinder( return; } -#endif + /*-------------------------------------------------------------------* * imax_pos() @@ -668,7 +661,6 @@ void peakfinder( *-------------------------------------------------------------------*/ /*! r: interpolated maximum position */ -#ifndef IVAS_FLOAT_FIXED float imax_pos( const float *y /* i : Input vector for peak interpolation */ ) @@ -710,7 +702,7 @@ float imax_pos( return posi + 1.0f; } -#endif + /*-------------------------------------------------------------------* * spec_ana() @@ -718,7 +710,6 @@ float imax_pos( * Spectral analysis *-------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void spec_ana( const float *prevsynth, /* i : Input signal */ int16_t *plocs, /* o : The indicies of the identified peaks */ @@ -956,7 +947,7 @@ static void spec_ana( return; } -#endif + /*-------------------------------------------------------------------* * subst_spec() @@ -964,7 +955,6 @@ static void spec_ana( * Substitution spectrum calculation *-------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void subst_spec( const int16_t *plocs, /* i : The indicies of the identified peaks */ const float *plocsi, /* i : Interpolated positions of the identified peaks */ @@ -1278,7 +1268,7 @@ static void subst_spec( return; } -#endif + /*-------------------------------------------------------------------------- * rec_wtda() @@ -1286,7 +1276,6 @@ static void subst_spec( * Windowing and TDA of reconstructed frame *--------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void rec_wtda( float *X, /* i/o: ECU frame / unwindowed ECU frame */ float *ecu_rec, /* o : Reconstructed frame in tda domain */ @@ -1395,7 +1384,6 @@ static void rec_wtda( return; } -#endif /*-------------------------------------------------------------------------- @@ -1404,7 +1392,6 @@ static void rec_wtda( * Frame reconstruction *--------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void rec_frame( float *X, /* i/o: FFT spectrum / IFFT of spectrum */ float *ecu_rec, /* o : Reconstructed frame in tda domain */ @@ -1446,7 +1433,6 @@ static void rec_frame( return; } -#endif /*-------------------------------------------------------------------------- @@ -1455,7 +1441,6 @@ static void rec_frame( * FIR downsampling filter *--------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void fir_dwn( const float x[], /* i : input vector */ const float h[], /* i : impulse response of the FIR filter */ @@ -1508,7 +1493,6 @@ static void fir_dwn( return; } -#endif /*-------------------------------------------------------------------------- @@ -1517,7 +1501,6 @@ static void fir_dwn( * Pitch/correlation analysis and adaptive analysis frame length calculation *--------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void fec_ecu_pitch( const float *prevsynth, /* i : previous synthesis */ float *prevsynth_LP, /* o : down-sampled synthesis */ @@ -1643,7 +1626,6 @@ static void fec_ecu_pitch( return; } -#endif /*-------------------------------------------------------------------------- @@ -1653,7 +1635,6 @@ static void fec_ecu_pitch( * next power of 2 using linear interpolation. *--------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void fec_ecu_dft( const float *prevsynth_LP, /* i : Downsampled past synthesis (2*160 samples) */ const int16_t N, /* i : Analysis frame length in 8 kHz (corr. max) */ @@ -1719,7 +1700,6 @@ static void fec_ecu_dft( * fast cosinus generator Amp*cos(2*pi*freq+phi) *--------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void singenerator( const int16_t L, /* i : size of output */ const float cosfreq, /* i : cosine of 1-sample dephasing at the given frequency */ @@ -1769,7 +1749,6 @@ static void singenerator( return; } -#endif /*-------------------------------------------------------------------------- @@ -1778,7 +1757,6 @@ static void singenerator( * ECU frame sinusoid generation *--------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void sinusoidal_synthesis( const float *Tfr, /* i : DFT coefficients, real part */ const float *Tfi, /* i : DFT coefficients, imag part */ @@ -1902,7 +1880,6 @@ static void sinusoidal_synthesis( return; } -#endif /*-------------------------------------------------------------------------- * fec_noise_filling() @@ -1915,7 +1892,6 @@ static void sinusoidal_synthesis( * it to be inserted into wtda *--------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void fec_noise_filling( const float *prevsynth, /* i : Past synthesis buffer (length 2*L) */ float *synthesis, /* i/o: Sinusoidal ECU / Sinusoidal ECU + noise */ @@ -2031,7 +2007,6 @@ static void fec_noise_filling( return; } -#endif /*-------------------------------------------------------------------------- * fec_alg() @@ -2040,7 +2015,6 @@ static void fec_noise_filling( * length *--------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void fec_alg( const float *prevsynth, /* i : previous synthesis */ const float *prevsynth_LP, /* i : down-sampled synthesis */ @@ -2074,7 +2048,6 @@ static void fec_alg( return; } -#endif /*-------------------------------------------------------------------------- @@ -2083,7 +2056,6 @@ static void fec_alg( * Main routine for HQ phase ECU *--------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void hq_phase_ecu( const float *prevsynth, /* i : buffer of previously synthesized signal */ float *ecu_rec, /* o : reconstructed frame in tda domain */ @@ -2175,9 +2147,7 @@ static void hq_phase_ecu( return; } -#endif -#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------------- * hq_ecu() * diff --git a/lib_dec/LD_music_post_filter.c b/lib_dec/LD_music_post_filter.c index e3817e69f4bb687b3bce4daca2a813c84d789f8d..dfdd586b44ec5714a2c7c3c0f0b1401282d9a28c 100644 --- a/lib_dec/LD_music_post_filter.c +++ b/lib_dec/LD_music_post_filter.c @@ -43,6 +43,7 @@ #include "prot_fx.h" #include "wmc_auto.h" +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ @@ -65,14 +66,11 @@ * Local function prototypes *-------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void spectrum_mod_dct( float data[], const float lf_E[], float lf_EO[], const float noiseE[], const float minGain, float lp_gbin[], const int16_t music_flag, int16_t min_band, const float MAX_GN, const int16_t max_band ); static void analy_sp_dct( const float dct_in[], float dct_buf[], float *fr_bands, float *lf_E, float *etot ); static void find_enr_dct( const float data[], float band[], float *ptE, float *Etot, const int16_t min_band, const int16_t max_band, float *Bin_E, const float bin_freq ); -#endif -#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------* * LD_music_post_filter() * @@ -360,7 +358,6 @@ void LD_music_post_filter( /* reconstruction of the enhanced synthesis */ mvr2r( DCT_buf, dtc_out, DCT_L_POST ); } -#endif /*---------------------------------------------------------------------------* * spectrum_mod_dct() @@ -368,7 +365,6 @@ void LD_music_post_filter( * spectrum enhancement according to the output of signal_type_clas() *---------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void spectrum_mod_dct( float data[], /* i/o: DCT spectrum */ const float lf_E[], /* i : per bin E for first 46 bins (without DC) */ @@ -523,7 +519,6 @@ static void spectrum_mod_dct( return; } -#endif /*----------------------------------------------------------------------------------* * analy_sp_dct() @@ -531,7 +526,6 @@ static void spectrum_mod_dct( * Spectral analysis of the current synthesized frame *----------------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED static void analy_sp_dct( const float dct_in[], /* i : input DCT spectrum */ float dct_buf[], /* i : output DCT spectrum */ @@ -558,7 +552,6 @@ static void analy_sp_dct( return; } -#endif /*------------------------------------------------------------------------* * find_enr_dct) @@ -567,7 +560,6 @@ static void analy_sp_dct( * The energy is normalized by the number of frequency bins in a channel *------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED void find_enr_dct( const float data[], /* i : fft result, for the format see fft_rel.c */ float band[], /* o : per band energy */ @@ -630,7 +622,6 @@ void find_enr_dct( return; } -#endif /*------------------------------------------------------------------------* * Prep_music_postP() @@ -638,7 +629,6 @@ void find_enr_dct( * Performs the steps needed to do the music post processing *------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED void Prep_music_postP( float exc_buffer_in[], /* i/o: excitation buffer */ float dct_buffer_out[], /* o : DCT output buffer */ @@ -701,7 +691,6 @@ void Prep_music_postP( return; } -#endif /*------------------------------------------------------------------------* * Post_music_postP() @@ -710,7 +699,6 @@ void Prep_music_postP( * to retreive the aligned excitation and redo the synthesis *------------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED void Post_music_postP( float dct_buffer_in[], /* i/o: excitation buffer */ float exc_buffer_out[], /* o : DCT output buffer */ @@ -731,7 +719,6 @@ void Post_music_postP( return; } -#endif /*-------------------------------------------------------------------* @@ -739,7 +726,7 @@ void Post_music_postP( * * Initialize LD music postfilter state structure *-------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED + void music_postfilt_init_flt( MUSIC_POSTFILT_HANDLE hMusicPF /* i/o: LD music postfilter handle */ ) diff --git a/lib_dec/acelp_core_switch_dec.c b/lib_dec/acelp_core_switch_dec.c index a982d8bb4556172171ec9c5c051632aee7896d28..a7a2eb75b78b80f7d625069b83bbc21c503fcadb 100644 --- a/lib_dec/acelp_core_switch_dec.c +++ b/lib_dec/acelp_core_switch_dec.c @@ -40,22 +40,18 @@ #include "rom_com.h" #include "prot.h" #include "wmc_auto.h" - +#ifndef IVAS_FLOAT_FIXED /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ - -#ifndef IVAS_FLOAT_FIXED static void decod_gen_voic_core_switch( Decoder_State *st, const int16_t L_frame, const int16_t sharpFlag, const float *Aq, float *exc, const int32_t core_brate ); -#endif - /*-------------------------------------------------------------------* * acelp_core_switch_dec() * * ACELP core decoder in the first ACELP->HQ switching frame *-------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED + ivas_error acelp_core_switch_dec( Decoder_State *st, /* i/o: decoder state structure */ float *synth_subfr_out, /* o : synthesized ACELP subframe */ diff --git a/lib_dec/ari_dec.c b/lib_dec/ari_dec.c index 7d63c3b342f0b7cd331828d23da8317718552fd2..2102356fa1350f155380b7c68958305a3934ee6f 100644 --- a/lib_dec/ari_dec.c +++ b/lib_dec/ari_dec.c @@ -113,15 +113,15 @@ Word16 ari_start_decoding_14bits_prm_ivas_fx( Word16 i; const Word16 *p; - val = L_deposit_l( 0 ); - + val = 0; + move32(); p = ptr + bp; FOR( i = 0; i < cbitsnew; i++ ) { val = L_or( L_shl( val, 1 ), *( p + i ) ); } - s->low = L_deposit_l( 0 ); + s->low = 0; move32(); s->high = ari_q4new; move32(); @@ -189,8 +189,7 @@ Word16 ari_decode_14bits_pow_ivas( move16(); k = sub( k, 1 ); symbol = (UWord16) L_shl( 1, k ); - move16(); - break; + BREAK; } } assert( k < 12 ); /* maximum 2^10-1*/ @@ -220,7 +219,6 @@ Word16 ari_decode_14bits_pow_ivas( highlim = 16384; move16(); move16(); - move16(); } @@ -238,7 +236,6 @@ Word16 ari_decode_14bits_pow_ivas( value = (UWord32) W_sub( value, ari_q2new ); low = L_sub( low, ari_q2new ); high = L_sub( high, ari_q2new ); - move32(); } ELSE { @@ -248,7 +245,6 @@ Word16 ari_decode_14bits_pow_ivas( value = (UWord32) W_sub( value, ari_q1new ); low = L_sub( low, ari_q1new ); high = L_sub( high, ari_q1new ); - move32(); } ELSE { @@ -262,7 +258,6 @@ Word16 ari_decode_14bits_pow_ivas( assert( abs( ptr[bp] ) <= 1 && "AC expects reading binary values!!!" ); value = (UWord32) ( W_shl( value, 1 ) | ptr[bp++] ); - move32(); } test(); @@ -340,6 +335,7 @@ Word16 ari_decode_14bits_sign_ivas( } ELSE { + test(); IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) ) { value = (UWord32) W_sub( value, ari_q1new ); @@ -348,7 +344,7 @@ Word16 ari_decode_14bits_sign_ivas( } ELSE { - break; + BREAK; } } } diff --git a/lib_dec/arith_coder_dec.c b/lib_dec/arith_coder_dec.c index a4f4d7409304ba16f7b6b1efc5e80f2746b454b4..f41f4f5909cd8a4b6011b0134b2c4597b8303c62 100644 --- a/lib_dec/arith_coder_dec.c +++ b/lib_dec/arith_coder_dec.c @@ -120,11 +120,11 @@ static int16_t tcx_arith_decode( #ifdef IVAS_FLOAT_FIXED static Word16 tcx_arith_decode_ivas_fx( const Word16 L_frame, /* i : number of spectral lines */ - const Word16 envelope[], /* i : scaled envelope (Q15-e) */ + const Word16 envelope[], /* i : scaled envelope (Q15-envelope_e) */ Word16 envelope_e, /* i : scaled envelope exponent (Q0) */ const Word16 target_bits, /* i : target bit budget */ Word16 prm[], /* i : bitstream parameters */ - Word32 q_spectrum[], /* o : scalar quantized spectrum */ + Word32 q_spectrum[], /* o : scalar quantized spectrum (Q31-q_spectrum_e) */ Word16 *q_spectrum_e /* o : spectrum exponent */ ) { @@ -159,13 +159,13 @@ static Word16 tcx_arith_decode_ivas_fx( bp = ari_decode_14bits_sign_ivas( prm, bp, target_bits, &s, &as ); q_spectrum[k] = L_mult( q, sub( 3, shl( s, 1 ) ) ); move32(); - q_spectrum[k] = L_shl( q_spectrum[k], 30 - SPEC_EXP_DEC ); + q_spectrum[k] = L_shl( q_spectrum[k], 30 - SPEC_EXP_DEC ); // Q(31-20) move32(); } ELSE { /* line is zero, no sign needed */ - q_spectrum[k] = L_deposit_l( 0 ); + q_spectrum[k] = 0; move32(); } @@ -297,7 +297,7 @@ void tcx_arith_decode_envelope( #ifdef IVAS_FLOAT_FIXED void tcx_arith_decode_envelope_ivas_fx( Decoder_State *st, /* i/o: coder state */ - Word32 q_spectrum[], /* o : quantised MDCT coefficients */ + Word32 q_spectrum[], /* o : quantised MDCT coefficients Q(31-q_spectrum_e) */ Word16 *q_spectrum_e, /* o : MDCT exponent */ const Word16 L_frame, /* i : frame or MDCT length */ Word16 L_spec, /* i : length w/o BW limitation */ @@ -328,7 +328,7 @@ void tcx_arith_decode_envelope_ivas_fx( test(); test(); test(); - IF( GT_16( L_spec, N_MAX_ARI ) || ( EQ_16( st->element_mode, EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) || + IF( GT_16( L_spec, N_MAX_ARI ) || ( ( st->element_mode == EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) || ( EQ_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE / FRAMES_PER_SEC ) ) ) ) || ( GT_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE_CPE / FRAMES_PER_SEC ) ) ) ) || ( target_bits <= 0 ) ) diff --git a/lib_dec/avq_dec.c b/lib_dec/avq_dec.c index b0eef6b2fa04367a1be566bc834d3a98ca510339..8fc098d2d98e9b3b5d99e253b15f66bf1cf1d839 100644 --- a/lib_dec/avq_dec.c +++ b/lib_dec/avq_dec.c @@ -41,12 +41,12 @@ #include "wmc_auto.h" #include +#ifndef IVAS_FLOAT_FIXED /*-------------------------------------------------------------------* * Local prototypes *-------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED + static void read_cv( Decoder_State *st, uint16_t *I, int16_t *kv, int16_t nq, int16_t *nbits ); -#endif /*-----------------------------------------------------------------* * AVQ_demuxdec() @@ -55,7 +55,6 @@ static void read_cv( Decoder_State *st, uint16_t *I, int16_t *kv, int16_t nq, in * split algebraic vector dequantizer based on RE8 latice. *-----------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED void AVQ_demuxdec( Decoder_State *st, /* i/o: decoder state structure */ int16_t xriq[], /* o : decoded subvectors [0..8*Nsv-1]*/ diff --git a/lib_dec/bass_psfilter.c b/lib_dec/bass_psfilter.c index 47ca645bc800f7b3e21c4bc64d4b06c7f365dd7c..9d148712562bfc1ab35be32f8bc92bf3a7db6103 100644 --- a/lib_dec/bass_psfilter.c +++ b/lib_dec/bass_psfilter.c @@ -725,8 +725,8 @@ Word16 res_bpf_adapt_ivas_fx( W_tmp = W_add_nosat( W_tmp, W_mult0_32_32( res_buf[i], res_buf[i] ) ); } - res_hb_nrg = (Word32) W_shr( W_tmp, shl( q_res, 1 ) ); // Q0 - res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv ); + res_hb_nrg = W_extract_l( W_shr( W_tmp, shl( q_res, 1 ) ) ); // Q0 + res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv ); // Q0 res_hb_nrg = L_add( Mpy_32_16_1( res_hb_nrg, STEREO_DFT_BPF_ADAPT_ALPHA_FX ), Mpy_32_16_1( hStereoDft->res_hb_nrg_mem_fx, sub( MAX_16, STEREO_DFT_BPF_ADAPT_ALPHA_FX ) ) ); hStereoDft->res_hb_nrg_mem_fx = res_hb_nrg; move32(); @@ -738,7 +738,7 @@ Word16 res_bpf_adapt_ivas_fx( { tmp = L_sub( bpf_error_signal_8k[i], hStereoDft->bpf_error_signal_last_fx ); error_nrg = Madd_32_32( error_nrg, tmp, tmp ); - hStereoDft->bpf_error_signal_last_fx = bpf_error_signal_8k[add( i, ( STEREO_DFT_L_SUBFR_8k - 1 ) )]; + hStereoDft->bpf_error_signal_last_fx = bpf_error_signal_8k[( i + ( STEREO_DFT_L_SUBFR_8k - 1 ) )]; move32(); } error_nrg = L_shl( error_nrg, 1 ); // Q0 @@ -810,7 +810,7 @@ void bpf_pitch_coherence( #ifdef IVAS_FLOAT_FIXED void bpf_pitch_coherence_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ - const Word32 pitch_buf[] /* i : pitch for every subfr [0,1,2,3] */ + const Word32 pitch_buf[] /* i : pitch for every subfr [0,1,2,3] Q20 */ ) { Word16 nb_subfr; @@ -820,31 +820,31 @@ void bpf_pitch_coherence_ivas_fx( SWITCH( st->L_frame ) { case 80: - scaled_inv_L_frame = 26843545; + scaled_inv_L_frame = 26843545; // 1/80 in Q31 move32(); BREAK; case 160: - scaled_inv_L_frame = 13421773; + scaled_inv_L_frame = 13421773; // 1/160 in Q31 move32(); BREAK; case 256: - scaled_inv_L_frame = 8388608; + scaled_inv_L_frame = 8388608; // 1/256 in Q31 move32(); BREAK; case 320: - scaled_inv_L_frame = 6710886; + scaled_inv_L_frame = 6710886; // 1/320 in Q31 move32(); BREAK; case 512: - scaled_inv_L_frame = 4194304; + scaled_inv_L_frame = 4194304; // 1/512 in Q31 move32(); BREAK; case 640: - scaled_inv_L_frame = 3355443; + scaled_inv_L_frame = 3355443; // 1/640 in Q31 move32(); BREAK; case 960: - scaled_inv_L_frame = 2236962; + scaled_inv_L_frame = 2236962; // 1/80 in Q31 move32(); BREAK; default: @@ -854,27 +854,27 @@ void bpf_pitch_coherence_ivas_fx( nb_subfr = shr( st->L_frame, 6 ); test(); - IF( GT_16( st->clas_dec, UNVOICED_CLAS ) && NE_16( st->element_mode, EVS_MONO ) ) + IF( GT_16( st->clas_dec, UNVOICED_CLAS ) && ( st->element_mode != EVS_MONO ) ) { pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( st->old_pitch_buf_fx[nb_subfr], st->old_pitch_buf_fx[nb_subfr + 1] ) ) ); pc = Mpy_32_32( pc, scaled_inv_L_frame ); pcn1 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); - pcn1 = L_max( L_min( pcn1, 4096 ), 0 ); + pcn1 = L_max( L_min( pcn1, 4096 ), 0 ); // 4096 = 1 in Q12 pc = L_abs( L_sub( L_add( pitch_buf[nb_subfr - 1], pitch_buf[nb_subfr - 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) ); pc = Mpy_32_32( pc, scaled_inv_L_frame ); pcn2 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); - pcn2 = L_max( L_min( pcn2, 4096 ), 0 ); + pcn2 = L_max( L_min( pcn2, 4096 ), 0 ); // 4096 = 1 in Q12 pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) ); pc = Mpy_32_32( pc, scaled_inv_L_frame ); pcn3 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); - pcn3 = L_max( L_min( pcn3, 4096 ), 0 ); + pcn3 = L_max( L_min( pcn3, 4096 ), 0 ); // 4096 = 1 in Q12 - IF( LT_32( L_add( pcn1, L_add( pcn2, pcn3 ) ), 10240 ) ) + IF( LT_32( L_add( pcn1, L_add( pcn2, pcn3 ) ), 10240 /*2.5f in Q12*/ ) ) { - st->hBPF->psf_att_fx = 13107; - move16(); /*Q15*/ + st->hBPF->psf_att_fx = 13107; //.4 in Q15 + move16(); /*Q15*/ set16_fx( &st->hBPF->Track_on_hist[L_TRACK_HIST - nb_subfr], 1, nb_subfr ); } } diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index 3e95cbc5353a2100683feb7c9862c997df330088..8816f03ffc3806f26dd71622fab3f41dc94b1a5b 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -202,7 +202,7 @@ void ivas_mct_side_bits_fx( } /*read MCT data and calculate frame bits per channel */ - FOR( ch = 0; ch < shr( hMCT->nchan_out_woLFE, 1 ); ch++ ) + FOR( ch = 0; ch < hMCT->nchan_out_woLFE / 2; ch++ ) { initMdctStereoDecData_fx( hMCT->hBlockData[ch]->hStereoMdct, st0->igf, st0->hIGFDec->igfData.igfInfo.grid, hCPE[0]->element_brate, st0->bwidth ); } @@ -292,7 +292,7 @@ void ivas_mct_core_dec( MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE decoder structure */ const Word16 nCPE, /* i : number of CPEs */ - Word32 *signal_out_fx[], + Word32 *signal_out_fx[], // q_x Word16 q_x[MCT_MAX_CHANNELS] ) { Word16 i, k, ch, cpe_id, nChannels; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index f3221106d3f1dc8df20142aa059183ac44ccefe0..197c9f2a99c38b354653f4f52dfc7686c9b639db 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -292,7 +292,7 @@ ivas_error ivas_mct_dec( #else ivas_error ivas_mct_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Word32 *output_fx[], /* o : output synthesis signal */ + Word32 *output_fx[], /* o : output synthesis signal Q11*/ const Word16 output_frame, /* i : output frame length per channel */ const Word16 nb_bits_metadata /* i : number of metadata bits */ ) @@ -306,18 +306,18 @@ ivas_error ivas_mct_dec_fx( Word16 nTnsBitsTCX10[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV]; Word16 fUseTns[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV]; STnsData tnsData[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV]; - Word16 Aq_fx[MCT_MAX_BLOCKS][CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )]; + Word16 Aq_fx[MCT_MAX_BLOCKS][CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )]; // Q12 Word32 output_lfe_ch_fx[L_FRAME48k]; Word16 q_output = 11; Word16 n, k, i; - Word32 *x_fx[CPE_CHANNELS][NB_DIV]; + Word32 *x_fx[CPE_CHANNELS][NB_DIV]; //(Q(31 - x_e) Word16 x_e[MAX_CICP_CHANNELS][NB_DIV]; Word16 x_len[CPE_CHANNELS][NB_DIV]; set16_fx( x_len[0], 0, NB_DIV ); set16_fx( x_len[1], 0, NB_DIV ); Decoder_State **sts; - Word16 synth_fx[CPE_CHANNELS][L_FRAME_PLUS]; + Word16 synth_fx[CPE_CHANNELS][L_FRAME_PLUS]; //(Q_synth) Word32 ivas_total_brate; ivas_error error; Word16 e_sig[CPE_CHANNELS] = { 15, 15 }; @@ -342,7 +342,7 @@ ivas_error ivas_mct_dec_fx( IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && ( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) ) { /* save LFE channel */ - Copy32( output_fx[LFE_CHANNEL], output_lfe_ch_fx, output_frame ); + Copy32( output_fx[LFE_CHANNEL], output_lfe_ch_fx, output_frame ); // Q11 } IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) && ( st_ivas->bfi == 0 ) ) @@ -406,11 +406,11 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - x_fx[n][0] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )]; + x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11 x_e[n][0] = 20; move16(); move16(); - x_fx[n][1] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )] + ( L_FRAME48k / 2 ); + x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11 x_e[n][1] = 20; move16(); move16(); @@ -436,7 +436,7 @@ ivas_error ivas_mct_dec_fx( move16(); FOR( k = 0; k < subFrames; ++k ) { - Scale_sig32( x_fx[ch][k], shr( L_FRAME48k, sub( subFrames, 1 ) ), sub( x_e[ch][k], 20 ) ); + Scale_sig32( x_fx[ch][k], shr( L_FRAME48k, sub( subFrames, 1 ) ), sub( x_e[ch][k], 20 ) ); // Scaling back to Q11 } } @@ -453,13 +453,13 @@ ivas_error ivas_mct_dec_fx( // Scaling output buffer to q_x FOR( i = 0; i < hMCT->nchan_out_woLFE; ++i ) { - Scale_sig32( output_fx[i], L_FRAME48k, sub( q_x[i], Q11 ) ); + Scale_sig32( output_fx[i], L_FRAME48k, sub( q_x[i], Q11 ) ); // Q11 -> Q12 } ivas_mct_core_dec( hMCT, st_ivas->hCPE, nCPE, output_fx, q_x ); // Scaling output buffer back to Q11 FOR( i = 0; i < hMCT->nchan_out_woLFE; ++i ) { - Scale_sig32( output_fx[i], L_FRAME48k, sub( Q11, q_x[i] ) ); + Scale_sig32( output_fx[i], L_FRAME48k, sub( Q11, q_x[i] ) ); // Q12 -> Q11 } @@ -485,9 +485,9 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - Copy_Scale_sig_16_32( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); - x_fx[n][0] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )]; - x_fx[n][1] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )] + ( L_FRAME48k / 2 ); + Copy_Scale_sig_16_32( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); // Q16 + x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11 + x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11 x_e[n][0] = 20; move16(); move16(); @@ -510,10 +510,10 @@ ivas_error ivas_mct_dec_fx( nSubFrames = NB_DIV; } move16(); - Scale_sig32( x_fx[ind][0], shr( L_FRAME48k, sub( nSubFrames, 1 ) ), sub( x_e[ind][0], 20 ) ); + Scale_sig32( x_fx[ind][0], shr( L_FRAME48k, sub( nSubFrames, 1 ) ), sub( x_e[ind][0], 20 ) ); // Q11 IF( EQ_16( nSubFrames, 2 ) ) { - Scale_sig32( x_fx[ind][1], shr( L_FRAME48k, 1 ), sub( x_e[ind][1], 20 ) ); + Scale_sig32( x_fx[ind][1], shr( L_FRAME48k, 1 ), sub( x_e[ind][1], 20 ) ); // Q11 } } } @@ -533,16 +533,16 @@ ivas_error ivas_mct_dec_fx( { set16_fx( x_all_e[i], 0, NB_DIV ); } - Word32 *x_all_fx[MAX_CICP_CHANNELS][NB_DIV]; + Word32 *x_all_fx[MAX_CICP_CHANNELS][NB_DIV]; //(Q(31 - x_all_e) FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - x_all_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][0] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )]; - x_all_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][1] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )] + ( L_FRAME48k / 2 ); - x_all_e[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][1] = 20; + x_all_fx[n + ( cpe_id * CPE_CHANNELS )][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11 + x_all_fx[n + ( cpe_id * CPE_CHANNELS )][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11 + x_all_e[n + ( cpe_id * CPE_CHANNELS )][1] = 20; move16(); - x_all_e[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][0] = 20; + x_all_e[n + ( cpe_id * CPE_CHANNELS )][0] = 20; move16(); } } @@ -553,8 +553,8 @@ ivas_error ivas_mct_dec_fx( { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - Scale_sig32( x_all_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][0], ( L_FRAME48k / 2 ), sub( x_all_e[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][0], 20 ) ); - Scale_sig32( x_all_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][1], ( L_FRAME48k / 2 ), sub( x_all_e[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )][1], 20 ) ); + Scale_sig32( x_all_fx[n + ( cpe_id * CPE_CHANNELS )][0], ( L_FRAME48k / 2 ), sub( x_all_e[n + ( cpe_id * CPE_CHANNELS )][0], 20 ) ); // Q11 + Scale_sig32( x_all_fx[n + ( cpe_id * CPE_CHANNELS )][1], ( L_FRAME48k / 2 ), sub( x_all_e[n + ( cpe_id * CPE_CHANNELS )][1], 20 ) ); // Q11 } } } @@ -566,8 +566,8 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { - x_fx[n][0] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )]; - x_fx[n][1] = output_fx[add( n, shl( cpe_id, 1 /* * CPE_CHANNELS*/ ) )] + ( L_FRAME48k / 2 ); + x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11 + x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11 } Copy_Scale_sig_16_32( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ); @@ -616,11 +616,11 @@ ivas_error ivas_mct_dec_fx( IF( ( st_ivas->sba_dirac_stereo_flag != 0 ) && ( NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) || GE_16( cpe_id, sub( nCPE, 2 ) ) ) ) { - Copy_Scale_sig_16_32( synth_fx[n], synth_fx_32[n], L_FRAME48k, Q11 - 0 ); + Copy_Scale_sig_16_32( synth_fx[n], synth_fx_32[n], L_FRAME48k, Q11 - 0 ); // Q11 Copy_Scale_sig_16_32( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, hCPE->hCoreCoder[n]->hHQ_core->oldOut_fx, output_frame, sub( Q11, hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda ) ); ivas_post_proc_fx( NULL, hCPE, n, synth_fx_32[n], NULL, output_frame, 1, Q11 ); #ifdef MSAN_FIX - Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], output_frame, 0 - Q11 ); + Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], output_frame, 0 - Q11 ); // Q0 #else Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], L_FRAME48k, 0 - Q11 ); #endif @@ -650,25 +650,25 @@ ivas_error ivas_mct_dec_fx( { dirac_stereo_flag = 0; } - IF( NE_32( ( error = core_switching_post_dec_ivas_fx( sts[n], synth_fx[n], output_fx[add( shl( cpe_id, 1 /* * CPE_CHANNELS*/ ), n )], output_mem_fx, st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = core_switching_post_dec_ivas_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) ) { return error; } - Copy_Scale_sig_16_32( synth_fx[n], output_fx[add( shl( cpe_id, 1 /* * CPE_CHANNELS*/ ), n )], output_frame, sub( Q11, Q_synth ) ); + Copy_Scale_sig_16_32( synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_frame, sub( Q11, Q_synth ) ); // Q11 /* Save synthesis for HQ FEC */ Word32 output_fx_[L_FRAME48k]; - Copy32( output_fx[add( shl( cpe_id, 1 /* * CPE_CHANNELS*/ ), n )], output_fx_, L_FRAME48k ); - Scale_sig32( output_fx_, L_FRAME48k, Q16 - Q11 ); - Copy_Scale_sig32_16( sts[n]->prev_synth_buffer32_fx, sts[n]->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); + Copy32( output_fx[( cpe_id * CPE_CHANNELS ) + n], output_fx_, L_FRAME48k ); // Q11 + Scale_sig32( output_fx_, L_FRAME48k, Q16 - Q11 ); // Q11 -> Q16 + Copy_Scale_sig32_16( sts[n]->prev_synth_buffer32_fx, sts[n]->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -11 ); // Q11 -> Q0 sts[n]->q_prev_synth_buffer_fx = 0; move16(); save_synthesis_hq_fec_fx( sts[n], output_fx_, output_frame, hCPE ); /* CoreCoder common updates */ - ivas_updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, output_fx[add( shl( cpe_id, 1 /* * CPE_CHANNELS*/ ), n )], 11 ); + ivas_updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, output_fx[( cpe_id * CPE_CHANNELS ) + n], 11 ); } /* n_channels loop */ @@ -676,7 +676,7 @@ ivas_error ivas_mct_dec_fx( { IF( hCPE->hCoreCoder[n] ) { - Copy_Scale_sig_16_32( hCPE->hCoreCoder[n]->delay_buf_out_fx, hCPE->hCoreCoder[n]->delay_buf_out32_fx, HQ_DELTA_MAX * HQ_DELAY_COMP, Q11 ); + Copy_Scale_sig_16_32( hCPE->hCoreCoder[n]->delay_buf_out_fx, hCPE->hCoreCoder[n]->delay_buf_out32_fx, HQ_DELTA_MAX * HQ_DELAY_COMP, Q11 ); // Q0 -> Q11 } } @@ -697,16 +697,16 @@ ivas_error ivas_mct_dec_fx( Word32 tmp[L_FRAME48k]; /*save center channel output*/ - Copy32( output_fx[sub( hMCT->nchan_out_woLFE, 1 )], tmp, output_frame ); + Copy32( output_fx[hMCT->nchan_out_woLFE - 1], tmp, output_frame ); // Q11 - FOR( n = sub( hMCT->nchan_out_woLFE, 1 ); n >= LFE_CHANNEL; n-- ) + FOR( n = hMCT->nchan_out_woLFE - 1; n >= LFE_CHANNEL; n-- ) { - Copy32( output_fx[sub( n, 1 )], output_fx[add( n, 1 )], output_frame ); + Copy32( output_fx[n - 1], output_fx[n + 1], output_frame ); // Q11 } - Copy32( tmp, output_fx[sub( LFE_CHANNEL, 1 )], output_frame ); + Copy32( tmp, output_fx[LFE_CHANNEL - 1], output_frame ); // Q11 /* save LFE channel */ - Copy32( output_lfe_ch_fx, output_fx[LFE_CHANNEL], output_frame ); + Copy32( output_lfe_ch_fx, output_fx[LFE_CHANNEL], output_frame ); // Q11 } pop_wmops(); @@ -794,7 +794,7 @@ ivas_error create_mct_dec_fx( /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ if ( hMCT->nchan_out_woLFE % 2 ) { - st_ivas->hCPE[sub( st_ivas->nCPE, 1 )]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; + st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; move32(); } @@ -827,7 +827,7 @@ ivas_error create_mct_dec_fx( hMCT->hBlockData[n]->hStereoMdct->reverse_dmx = 0; move16(); move16(); - hMCT->hBlockData[n]->hStereoMdct->smooth_ratio_fx = ONE_IN_Q26; + hMCT->hBlockData[n]->hStereoMdct->smooth_ratio_fx = ONE_IN_Q26; // Q26 move32(); } FOR( ; n < MCT_MAX_BLOCKS; n++ ) @@ -1442,7 +1442,7 @@ ivas_error ivas_mc_dec_config_fx( { FOR( Word16 i = 0; i < 4; i++ ) { - st_ivas->hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 2 )] = shl_sat( st_ivas->hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 2 )], 9 ); + st_ivas->hRenderConfig->directivity_fx[( i * 3 ) + 2] = shl_sat( st_ivas->hRenderConfig->directivity_fx[( i * 3 ) + 2], 9 ); // Q15 move16(); } } @@ -1454,7 +1454,7 @@ ivas_error ivas_mc_dec_config_fx( { FOR( Word16 i = 0; i < 4; i++ ) { - st_ivas->hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 2 )] = shr( st_ivas->hRenderConfig->directivity_fx[add( imult1616( i, 3 ), 2 )], 9 ); + st_ivas->hRenderConfig->directivity_fx[( i * 3 ) + 2] = shr( st_ivas->hRenderConfig->directivity_fx[( i * 3 ) + 2], 9 ); // Q15 move16(); } } diff --git a/lib_dec/ivas_mct_dec_mct_fx.c b/lib_dec/ivas_mct_dec_mct_fx.c index d6e5b686582b0a9899e0b6faf964b0be72470225..0f9bd98cc2be47af3e46055590cf978cb67d7c52 100644 --- a/lib_dec/ivas_mct_dec_mct_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx.c @@ -239,7 +239,7 @@ void apply_MCT_dec_fx( Word16 pair; MCT_DEC_BLOCK_DATA_HANDLE hBlock; - FOR( pair = sub( hMCT->currBlockDataCnt, 1 ); pair >= 0; pair-- ) + FOR( pair = hMCT->currBlockDataCnt - 1; pair >= 0; pair-- ) { hBlock = hMCT->hBlockData[pair]; @@ -260,7 +260,7 @@ void apply_MCT_dec_fx( void mctStereoIGF_dec_fx( MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ Decoder_State **stm, /* i/o: decoder state structure */ - Word32 *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequantized spectrum*/ + Word32 *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequantized spectrum i:Q12*/ const Word16 bfi /* i : bad frame flag */ ) { @@ -272,7 +272,7 @@ void mctStereoIGF_dec_fx( Word16 L_spec[CPE_CHANNELS]; Word16 L_frame[CPE_CHANNELS]; Word16 L_frameTCX[CPE_CHANNELS]; - Word32 *p_x[CPE_CHANNELS][NB_DIV]; + Word32 *p_x[CPE_CHANNELS][NB_DIV]; // Q(31 - p_x_e) Word16 p_x_e[CPE_CHANNELS][NB_DIV]; Word16 p_x_len[CPE_CHANNELS][NB_DIV]; Word16 singleChEle[MCT_MAX_CHANNELS]; @@ -305,13 +305,13 @@ void mctStereoIGF_dec_fx( move16(); // Using input Q-factor as 12 - set16_fx( p_x_e[0], 31 - Q12, CPE_CHANNELS ); - set16_fx( p_x_e[1], 31 - Q12, CPE_CHANNELS ); + set16_fx( p_x_e[0], 31 - Q12, CPE_CHANNELS ); // Q12 + set16_fx( p_x_e[1], 31 - Q12, CPE_CHANNELS ); // Q12 FOR( k = 0; k < nSubframes; k++ ) { - p_x[0][k] = x[ch1][k]; - p_x[1][k] = x[ch2][k]; + p_x[0][k] = x[ch1][k]; // Q12 + p_x[1][k] = x[ch2][k]; // Q12 test(); IF( NE_16( hMCT->hBlockData[b]->hStereoMdct->IGFStereoMode[k], SMDCT_DUAL_MONO ) || NE_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[k], SMDCT_DUAL_MONO ) ) diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 777d18f5c1fb0bfbd26dca003c03b5df1256939f..90cb85cc3b23d894503f6ba1b5b113912acc8afb 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -722,7 +722,7 @@ void ivas_mdct_dec_side_bits_frame_channel_fx( FOR( Word16 n = 0; n < nSubframes; ++n ) { - const Word16 is_side = (Word16) L_and( EQ_16( ch, 1 ), EQ_16( param_lpc[0][n], SNS_STEREO_MODE_MS ) ); + const Word16 is_side = extract_l( L_and( EQ_16( ch, 1 ), EQ_16( param_lpc[0][n], SNS_STEREO_MODE_MS ) ) ); const Word16 *bits; Word16 nStages; IF( EQ_16( nSubframes, 1 ) ) @@ -736,6 +736,7 @@ void ivas_mdct_dec_side_bits_frame_channel_fx( nStages = SNS_MSVQ_NSTAGES_TCX10; } move16(); + move16(); IF( is_side ) { /* check for zero-side flag */ @@ -753,6 +754,7 @@ void ivas_mdct_dec_side_bits_frame_channel_fx( { bits = ivas_sns_cdbks_side_tcx10_bits; } + move16(); } FOR( Word16 j = 0; j < nStages; ++j ) @@ -1029,7 +1031,7 @@ void ivas_mdct_core_invQ_fx( Word32 *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ Word16 x_e[CPE_CHANNELS][NB_DIV], Word16 x_len[CPE_CHANNELS][NB_DIV], - Word16 Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients */ + Word16 Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients Q12*/ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */ const Word16 MCT_flag /* i : hMCT handle allocated (1) or not (0) */ ) @@ -1044,7 +1046,7 @@ void ivas_mdct_core_invQ_fx( Word16 Aind[CPE_CHANNELS][M + 1]; Word32 sns[CPE_CHANNELS][NB_DIV][M]; /* TCX */ - Word16 xn_buf[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; + Word16 xn_buf[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; // Q14 Word16 tcx_offset[CPE_CHANNELS]; Word16 tcx_offsetFB[CPE_CHANNELS]; Word16 left_rect[CPE_CHANNELS]; @@ -1142,8 +1144,8 @@ void ivas_mdct_core_invQ_fx( stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0[1], &spectralData_tmp[0], &spectralData_tmp[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1, &q_r, &q_l ); #ifdef MSAN_FIX - Copy_Scale_sig_32_16( spectralData_tmp[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0], -15 ); - Copy_Scale_sig_32_16( spectralData_tmp[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[1], -15 ); + Copy_Scale_sig_32_16( spectralData_tmp[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0], -15 ); // q_l - 15 + Copy_Scale_sig_32_16( spectralData_tmp[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[1], -15 ); // q_r - 15 #else Copy_Scale_sig_32_16( spectralData_tmp[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_FRAME_MAX, -15 ); Copy_Scale_sig_32_16( spectralData_tmp[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_FRAME_MAX, -15 ); @@ -1298,8 +1300,8 @@ void ivas_mdct_core_invQ_fx( } } - Copy( tmp_ms_sig[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0] ); - Copy( tmp_ms_sig[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0] ); + Copy( tmp_ms_sig[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0] ); // Q(15 - tmp_ms_sig_e) + Copy( tmp_ms_sig[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0] ); // Q(15 - tmp_ms_sig_e) sts[0]->hTonalMDCTConc->lastBlockData.spectralData_exp = tmp_ms_sig_e[0]; move16(); sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp = tmp_ms_sig_e[1]; @@ -1990,14 +1992,14 @@ void ivas_mdct_core_reconstruct_fx( Word16 q_win = -2; move16(); /* TCX */ - Word16 xn_buf_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; + Word16 xn_buf_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; // Q(-2) Word16 tcx_offset[CPE_CHANNELS]; Word16 tcx_offsetFB[CPE_CHANNELS]; Word16 left_rect[CPE_CHANNELS]; Word16 L_spec[CPE_CHANNELS]; Word16 pitch[CPE_CHANNELS][NB_SUBFR16k]; - Word16 pit_gain_fx[CPE_CHANNELS][NB_SUBFR16k]; + Word16 pit_gain_fx[CPE_CHANNELS][NB_SUBFR16k]; // Q14 Word16 skip_decoding, sf; set16_fx( xn_buf_fx, 0, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); @@ -2052,21 +2054,21 @@ void ivas_mdct_core_reconstruct_fx( set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M ); IF( st->core != ACELP_CORE ) { - Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDACFB ) ); - Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); - Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, sub( -1, st->Q_syn ) ) ); - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); - Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); + Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // st->hTcxDec->Q_syn_Overl_TDACFB -> q_win + Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win + Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, sub( -1, st->Q_syn ) ) ); // Q(-1 - st->Q_syn) -> q_win + Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win + Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win #ifdef MSAN_FIX - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); - Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win + Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win #else Scale_sig( synth_buf_fx, 3136, sub( q_win, q_syn ) ); Scale_sig( synth_bufFB_fx, 3136, sub( q_win, q_syn ) ); #endif - Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); + Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win FOR( k = 0; k < nSubframes[ch]; k++ ) { init_tcx_info_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], k, bfi, &tcx_offset[ch], @@ -2079,18 +2081,18 @@ void ivas_mdct_core_reconstruct_fx( IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, q_win, - MDCT_IV, fUseTns[ch][k], &synth_fx[L_mult0( k, L_frame[ch] )], &synthFB_fx[L_mult0( k, L_frameTCX[ch] )], bfi, k, 0 ); + MDCT_IV, fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); } ELSE { decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, q_win, - st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[L_mult0( k, L_frame[ch] )], &synthFB_fx[L_mult0( k, L_frameTCX[ch] )], bfi, k, 0 ); + st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); } } ELSE { - set16_fx( &synth_fx[L_mult0( k, L_frame[ch] )], 0, L_frame[ch] ); - set16_fx( &synthFB_fx[L_mult0( k, L_frame[ch] )], 0, L_frameTCX[ch] ); + set16_fx( &synth_fx[k * L_frame[ch]], 0, L_frame[ch] ); + set16_fx( &synthFB_fx[k * L_frame[ch]], 0, L_frameTCX[ch] ); } } @@ -2115,25 +2117,26 @@ void ivas_mdct_core_reconstruct_fx( { st->Q_syn = add( q_win, sf ); } - Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( sub( -1, st->Q_syn ), q_win ) ); + + Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( sub( -1, st->Q_syn ), q_win ) ); // q_win -> Q(-1 - st->Q_syn) st->hTcxDec->Q_syn_Overl_TDACFB = sub( -1, st->Q_syn ); move16(); - Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), q_win ) ); + Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), q_win ) ); // q_win -> Q(-1 - st->Q_syn) st->hTcxDec->Q_syn_Overl_TDAC = sub( -1, st->Q_syn ); move16(); - Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), q_win ) ); + Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), q_win ) ); // q_win -> Q(-1 - st->Q_syn) #ifdef MSAN_FIX - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); - Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn + Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn #else Scale_sig( synth_buf_fx, 3136, sub( q_syn, q_win ) ); Scale_sig( synth_bufFB_fx, 3136, sub( q_syn, q_win ) ); #endif Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); - Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, q_win ) ); - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) ); + Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn + Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn st->hHQ_core->Q_old_wtda = st->Q_syn; move16(); st->hHQ_core->Q_old_wtda_LB = st->Q_syn; @@ -2142,15 +2145,15 @@ void ivas_mdct_core_reconstruct_fx( ELSE /*ACELP core for ACELP-PLC */ { assert( EQ_16( st->bfi, 1 ) ); - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), negate( q_syn ) ); - Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), negate( q_syn ) ); + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), negate( q_syn ) ); // Q0 + Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), negate( q_syn ) ); // Q0 q_syn = 0; move16(); move16(); /* PLC: [TCX: TD PLC] */ IF( MCT_flag != 0 ) { - con_tcx_ivas_fx( st, &synthFB_fx[0], -16384, NULL, 0, NULL ); + con_tcx_ivas_fx( st, &synthFB_fx[0], -16384, NULL, 0, NULL ); //-1.Q14 = -16384 } ELSE { @@ -2164,14 +2167,14 @@ void ivas_mdct_core_reconstruct_fx( } } - Scale_sig( synthFB_fx, st->hTcxDec->L_frameTCX, q_syn ); + Scale_sig( synthFB_fx, st->hTcxDec->L_frameTCX, q_syn ); // q_syn IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) ) { - Scale_sig( synthFB_fx - add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), sub( q_syn, sub( st->Q_exc, 1 ) ) ); + Scale_sig( synthFB_fx - add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), add( add( shr( st->hTcxDec->L_frameTCX, 1 ), st->hTcxDec->pit_max_TCX ), 2 * M ), sub( q_syn, sub( st->Q_exc, 1 ) ) ); // 2 * q_syn - (st->Q_exc - 1) } ELSE { - Scale_sig( synthFB_fx - st->hTcxDec->L_frameTCX, st->hTcxDec->L_frameTCX, sub( q_syn, sub( st->Q_exc, 1 ) ) ); + Scale_sig( synthFB_fx - st->hTcxDec->L_frameTCX, st->hTcxDec->L_frameTCX, sub( q_syn, sub( st->Q_exc, 1 ) ) ); // 2 * q_syn - (st->Q_exc - 1) } lerp( synthFB_fx, synth_fx, st->L_frame, st->hTcxDec->L_frameTCX ); @@ -2217,7 +2220,7 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->q_synth_history_fx = st->hTcxDec->q_old_synth; move16(); move16(); - Scale_sig( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->Q_syn, q_syn ) ); + Scale_sig( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->Q_syn, q_syn ) ); // st->Q_syn IF( st->hHQ_core != NULL ) { Copy( st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hTcxDec->old_synthFB_fx + st->hTcxDec->old_synth_lenFB, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); @@ -2232,14 +2235,14 @@ void ivas_mdct_core_reconstruct_fx( Word16 x_fx_16[1200]; IF( st->p_bpf_noise_buf_32 ) { - Copy_Scale_sig_32_16( st->p_bpf_noise_buf_32, st->p_bpf_noise_buf, st->L_frame, -Q11 ); + Copy_Scale_sig_32_16( st->p_bpf_noise_buf_32, st->p_bpf_noise_buf, st->L_frame, -Q11 ); // Q11 -> Q0 } post_decoder_ivas_fx( st, synth_buf_fx, pit_gain_fx[ch], pitch[ch], x_fx_16, st->p_bpf_noise_buf ); IF( st->p_bpf_noise_buf_32 ) { - Copy_Scale_sig_16_32_no_sat( st->p_bpf_noise_buf, st->p_bpf_noise_buf_32, st->L_frame, Q11 ); + Copy_Scale_sig_16_32_no_sat( st->p_bpf_noise_buf, st->p_bpf_noise_buf_32, st->L_frame, Q11 ); // Q0 -> Q11 } IF( signal_outFB_fx[ch] != NULL ) { @@ -2254,7 +2257,7 @@ void ivas_mdct_core_reconstruct_fx( st->last_coder_type = st->coder_type; move16(); - Copy_Scale_sig_16_32( x_fx_16, x_fx[ch][0], st->L_frame, sub( q_x, q_syn ) ); + Copy_Scale_sig_16_32( x_fx_16, x_fx[ch][0], st->L_frame, sub( q_x, q_syn ) ); // q_syn -> Q_x } IF( GT_16( e_sig[0], e_sig[1] ) ) @@ -2311,9 +2314,9 @@ void ivas_mdct_core_reconstruct_fx( L_tmp = Mpy_32_32( W_extract_h( nrgL_fx ), W_extract_h( nrgR_fx ) ); e_tmp = add( e_nrgL, e_nrgR ); L_tmp = ISqrt32( L_tmp, &e_tmp ); - hCPE->hStereoMdct->lastCoh_fx = extract_l( L_shr( Mpy_32_32( L_abs( W_extract_h( xcorr_fx ) ), L_tmp ), sub( 17, add( e_xcorr, e_tmp ) ) ) ); + hCPE->hStereoMdct->lastCoh_fx = extract_l( L_shr( Mpy_32_32( L_abs( W_extract_h( xcorr_fx ) ), L_tmp ), sub( 17, add( e_xcorr, e_tmp ) ) ) ); // Q14 move16(); - hCPE->hStereoMdct->lastCoh_fx = s_min( hCPE->hStereoMdct->lastCoh_fx, 16384 ); + hCPE->hStereoMdct->lastCoh_fx = s_min( hCPE->hStereoMdct->lastCoh_fx, 16384 ); // 1.Q14 = 16384 move16(); } @@ -2452,8 +2455,8 @@ void ivas_mdct_core_tns_ns_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : two entries for each channel in TCX10 */ STnsData tnsData[CPE_CHANNELS][NB_DIV], /* o : TNS parameter */ - Word32 *x_fx[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */ - Word32 Aq_fx[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients */ + Word32 *x_fx[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS Q(31 - x_e)*/ + Word32 Aq_fx[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients Q16*/ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ Word16 x_e[CPE_CHANNELS][NB_DIV] ) { @@ -2531,11 +2534,13 @@ void ivas_mdct_core_tns_ns_fx( q_x = sub( 31, x_e[ch][k] ); IF( bfi == 0 ) { - sns_interpolate_scalefactors_fx( sns_int_scf_fx, &Aq_fx[ch][k * M], DEC ); + sns_interpolate_scalefactors_fx( sns_int_scf_fx, &Aq_fx[ch][k * M], DEC ); // Q16 + test(); + test(); IF( ( MCT_flag != 0 ) && st->hTonalMDCTConc != NULL && EQ_16( add( k, 1 ), nSubframes[ch] ) ) { - Word16 scf_fx[FDNS_NPTS], scf_e[FDNS_NPTS]; + Word16 scf_fx[FDNS_NPTS] /*(16 - scf_e)*/, scf_e[FDNS_NPTS]; Word16 q_shift; FOR( Word16 ind = 0; ind < st->hTonalMDCTConc->nScaleFactors; ind++ ) { @@ -2552,7 +2557,8 @@ void ivas_mdct_core_tns_ns_fx( { IF( st->hTonalMDCTConc != NULL ) { - IF( ( MCT_flag == 0 ) && LT_16( st->hTcxDec->cummulative_damping_tcx, 32440 ) ) + test(); + IF( ( MCT_flag == 0 ) && LT_16( st->hTcxDec->cummulative_damping_tcx, 32440 ) ) // 0.99.Q15 = 32440 { Word16 *scf_last_m, *scf_last_e; Word32 *scf_bg; @@ -2571,7 +2577,7 @@ void ivas_mdct_core_tns_ns_fx( FOR( Word16 i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ ) { - sns_int_scf_fx[i] = Madd_32_16( Mpy_32_16_1( L_shl( scf_last_m[i], add( 1, scf_last_e[i] ) ), fade_out ), scf_bg[i], fade_in ); + sns_int_scf_fx[i] = Madd_32_16( Mpy_32_16_1( L_shl( scf_last_m[i], add( 1, scf_last_e[i] ) ), fade_out ), scf_bg[i], fade_in ); // Q16 move32(); } } @@ -2581,7 +2587,7 @@ void ivas_mdct_core_tns_ns_fx( move16(); FOR( Word16 i = 0; i < st->hTonalMDCTConc->nScaleFactors; i++ ) { - sns_int_scf_fx[i] = L_shl( st->hTonalMDCTConc->lastBlockData.scaleFactors[i], add( 1, st->hTonalMDCTConc->lastBlockData.scaleFactors_exp[i] ) ); + sns_int_scf_fx[i] = L_shl( st->hTonalMDCTConc->lastBlockData.scaleFactors[i], add( 1, st->hTonalMDCTConc->lastBlockData.scaleFactors_exp[i] ) ); // Q16 move32(); } } @@ -2615,7 +2621,7 @@ void ivas_mdct_core_tns_ns_fx( // q_sns_int_scf -= 1; FOR( Word16 c = 0; c < FDNS_NPTS; c++ ) { - sns_int_scf_fx[c] = L_shl( sns_int_scf_fx[c], sub( q_sns_int_scf, 16 ) ); + sns_int_scf_fx[c] = L_shl( sns_int_scf_fx[c], sub( q_sns_int_scf, 16 ) ); // Q16 -> q_sns_int_scf move32(); } q_2 = q_x; diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index f38068570436aa6a0b928c8675e9288c1d1f6247..19058c9c9fc2e0ab00858fd872cb75cb698fc647 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -52,10 +52,10 @@ ivas_error ivas_sce_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 sce_id, /* i : SCE # identifier */ - Word32 *output[1], /* o : output synthesis signal */ - const Word16 output_frame, /* i : output frame length per channel */ - const Word16 nb_bits_metadata /* i : number of metadata bits */ + const Word16 sce_id, /* i : SCE # identifier Q0*/ + Word32 *output[1], /* o : output synthesis signal Q11*/ + const Word16 output_frame, /* i : output frame length per channel Q0*/ + const Word16 nb_bits_metadata /* i : number of metadata bits Q0*/ ) { Word32 outputHB[1][L_FRAME48k]; /*Word32 buffer for output HB synthesis, one channel */ @@ -75,9 +75,9 @@ ivas_error ivas_sce_dec_fx( st->BER_detect = s_or( st->BER_detect, st_ivas->BER_detect ); move16(); - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; /*Q0*/ move32(); - last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; + last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; /*Q0*/ move32(); IF( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) ) @@ -97,7 +97,7 @@ ivas_error ivas_sce_dec_fx( test(); IF( !st_ivas->bfi && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) { - st->total_brate = L_sub( ivas_total_brate, L_shr( L_mult( nb_bits_metadata, FRAMES_PER_SEC ), 1 ) ); + st->total_brate = L_sub( ivas_total_brate, L_mult0( nb_bits_metadata, FRAMES_PER_SEC ) ); /*Q0*/ move16(); test(); assert( EQ_32( st->total_brate, SID_2k40 ) && "SCE SID must be 2.4kbps!" ); @@ -116,7 +116,7 @@ ivas_error ivas_sce_dec_fx( } ELSE IF( !st_ivas->bfi && NE_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && LE_32( last_ivas_total_brate, IVAS_SID_5k2 ) ) { - st->total_brate = L_sub( hSCE->element_brate, L_shr( L_mult( nb_bits_metadata, FRAMES_PER_SEC ), 1 ) ); + st->total_brate = L_sub( hSCE->element_brate, L_mult0( nb_bits_metadata, FRAMES_PER_SEC ) ); /*Q0*/ move32(); } @@ -147,13 +147,13 @@ ivas_error ivas_sce_dec_fx( ( LT_32( hSCE->element_brate, MIN_BRATE_FB_ISM ) && st->is_ism_format ) ) { /* WB and SWB are supported */ - st->bwidth = add( get_next_indice_fx( st, 1 ), WB ); + st->bwidth = add( get_next_indice_fx( st, 1 ), WB ); /*Q0*/ move16(); } ELSE { /* WB, SWB and FB are supported */ - st->bwidth = get_next_indice_fx( st, NBITS_BWIDTH ); + st->bwidth = get_next_indice_fx( st, NBITS_BWIDTH ); /*Q0*/ move16(); } } @@ -182,33 +182,33 @@ ivas_error ivas_sce_dec_fx( test(); IF( EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { - st->bits_frame_nominal = extract_l( L_sub( Mpy_32_16_1( hSCE->element_brate, INV_FRAME_PER_SEC_Q15 ), ISM_NB_BITS_METADATA_NOMINAL ) ); + st->bits_frame_nominal = extract_l( L_sub( Mpy_32_16_1( hSCE->element_brate, INV_FRAME_PER_SEC_Q15 ), ISM_NB_BITS_METADATA_NOMINAL ) ); /*Q0*/ move16(); } ELSE IF( ( EQ_16( (Word16) st_ivas->mc_mode, MC_MODE_MCMASA ) && GE_32( ivas_total_brate, MCMASA_SEPARATE_BRATE ) ) || ( EQ_16( (Word16) st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) ) { - st->bits_frame_nominal = extract_l( Mpy_32_16_1( hSCE->element_brate, INV_FRAME_PER_SEC_Q15 ) ); + st->bits_frame_nominal = extract_l( Mpy_32_16_1( hSCE->element_brate, INV_FRAME_PER_SEC_Q15 ) ); /*Q0*/ move16(); } ELSE IF( EQ_16( (Word16) st_ivas->ism_mode, ISM_MODE_NONE ) && EQ_16( (Word16) st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - st->bits_frame_nominal = extract_l( Mpy_32_16_1( st_ivas->hSpar->core_nominal_brate, INV_FRAME_PER_SEC_Q15 ) ); + st->bits_frame_nominal = extract_l( Mpy_32_16_1( st_ivas->hSpar->core_nominal_brate, INV_FRAME_PER_SEC_Q15 ) ); /*Q0*/ move16(); } ELSE { - st->bits_frame_nominal = st_ivas->hQMetaData->bits_frame_nominal; + st->bits_frame_nominal = st_ivas->hQMetaData->bits_frame_nominal; /*Q0*/ move16(); } } ELSE IF( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) ) { - st->bits_frame_nominal = extract_l( Mpy_32_16_1( st_ivas->hSpar->core_nominal_brate, INV_FRAME_PER_SEC_Q15 ) ); + st->bits_frame_nominal = extract_l( Mpy_32_16_1( st_ivas->hSpar->core_nominal_brate, INV_FRAME_PER_SEC_Q15 ) ); /*Q0*/ move16(); } ELSE { - st->bits_frame_nominal = extract_l( L_sub( Mpy_32_16_1( hSCE->element_brate, INV_FRAME_PER_SEC_Q15 ), ISM_NB_BITS_METADATA_NOMINAL ) ); + st->bits_frame_nominal = extract_l( L_sub( Mpy_32_16_1( hSCE->element_brate, INV_FRAME_PER_SEC_Q15 ), ISM_NB_BITS_METADATA_NOMINAL ) ); /*Q0*/ move16(); } @@ -220,7 +220,7 @@ ivas_error ivas_sce_dec_fx( test(); IF( !st_ivas->bfi && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) ) { - st->total_brate = L_sub( ivas_total_brate, L_shr( L_mult( nb_bits_metadata, FRAMES_PER_SEC ), 1 ) ); + st->total_brate = L_sub( ivas_total_brate, L_mult0( nb_bits_metadata, FRAMES_PER_SEC ) ); /*Q0*/ if ( EQ_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && NE_16( st_ivas->hISMDTX.sce_id_dtx, sce_id ) ) { @@ -230,12 +230,12 @@ ivas_error ivas_sce_dec_fx( } ELSE IF( !st_ivas->bfi && EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) { - st->total_brate = ivas_total_brate; + st->total_brate = ivas_total_brate; /*Q0*/ move32(); } ELSE IF( !st_ivas->bfi && NE_16( (Word16) st_ivas->ivas_format, ISM_FORMAT ) && NE_16( (Word16) st_ivas->ivas_format, MASA_ISM_FORMAT ) ) /* note: in ISMs, total_brate[] is set in ivas_ism_config() */ { - st->total_brate = L_sub( hSCE->element_brate, L_shr( L_mult( nb_bits_metadata, FRAMES_PER_SEC ), 1 ) ); + st->total_brate = L_sub( hSCE->element_brate, L_mult0( nb_bits_metadata, FRAMES_PER_SEC ) ); /*Q0*/ move32(); } @@ -257,7 +257,7 @@ ivas_error ivas_sce_dec_fx( } ELSE { - st->flag_ACELP16k = set_ACELP_flag_IVAS( IVAS_SCE, hSCE->element_brate, st->total_brate, 0, 0, -1, -1 ); + st->flag_ACELP16k = set_ACELP_flag_IVAS( IVAS_SCE, hSCE->element_brate, st->total_brate, 0, 0, -1, -1 ); /*Q0*/ move16(); } @@ -306,7 +306,7 @@ ivas_error ivas_sce_dec_fx( IF( st_ivas->sba_dirac_stereo_flag && ( GT_32( st->core_brate, SID_2k40 ) || EQ_16( st->cng_type, LP_CNG ) ) ) { /* skip addition of ACELP BWE for now, will be done after upmix */ - Copy32( outputHB[0], hSCE->save_hb_synth_fx, output_frame ); + Copy32( outputHB[0], hSCE->save_hb_synth_fx, output_frame ); /*Q11*/ hSCE->q_save_hb_synth_fx = Q11; move16(); } @@ -314,7 +314,7 @@ ivas_error ivas_sce_dec_fx( { Word32 output_Fs; - output_Fs = st_ivas->hDecoderConfig->output_Fs; + output_Fs = st_ivas->hDecoderConfig->output_Fs; /*Q0*/ move32(); /*----------------------------------------------------------------* @@ -333,17 +333,17 @@ ivas_error ivas_sce_dec_fx( * output LB and HB mix *----------------------------------------------------------------*/ - v_add_fx( output[0], outputHB[0], output[0], output_frame ); + v_add_fx( output[0], outputHB[0], output[0], output_frame ); /*Q11*/ } /*----------------------------------------------------------------* * Common updates *----------------------------------------------------------------*/ - hSCE->last_element_brate = hSCE->element_brate; + hSCE->last_element_brate = hSCE->element_brate; /*Q0*/ move32(); - st_ivas->BER_detect = s_or( st_ivas->BER_detect, st->BER_detect ); + st_ivas->BER_detect = s_or( st_ivas->BER_detect, st->BER_detect ); /*Q0*/ move16(); @@ -360,8 +360,8 @@ ivas_error ivas_sce_dec_fx( ivas_error create_sce_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 sce_id, /* i : SCE # identifier */ - const Word32 element_brate /* i : element bitrate */ + const Word16 sce_id, /* i : SCE # identifier Q0*/ + const Word32 element_brate /* i : element bitrate Q0*/ ) { SCE_DEC_HANDLE hSCE; @@ -371,7 +371,7 @@ ivas_error create_sce_dec( error = IVAS_ERR_OK; move16(); - output_frame = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); + output_frame = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); /*Q0*/ /*-----------------------------------------------------------------* * Allocate SCE handle @@ -386,9 +386,9 @@ ivas_error create_sce_dec( * Initialization - general parameters *-----------------------------------------------------------------*/ - hSCE->sce_id = sce_id; + hSCE->sce_id = sce_id; /*Q0*/ move16(); - hSCE->element_brate = element_brate; + hSCE->element_brate = element_brate; /*Q0*/ move32(); set32_fx( hSCE->prev_hb_synth_fx, 0, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) ); diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index d33eb08b7abf3fc441e6aee4c8484567e417ecc4..1863e11ae088df0c76dcd31b009fd382bb68f3de 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -53,7 +53,7 @@ static void sns_1st_dec_fx( const Word16 index, /* i : codebook index */ const Word16 core, const Word16 L_frame, - Word32 *snsq_fx /* i/o: i:prediction o:quantized sns */ + Word32 *snsq_fx /* i/o: i:prediction o:quantized sns Q16*/ ) { Word16 i; @@ -68,20 +68,20 @@ static void sns_1st_dec_fx( SWITCH( L_frame ) { case L_FRAME16k: - means = &sns_1st_means_16k[core - 1][0]; + means = &sns_1st_means_16k[core - 1][0]; /*Q0*/ BREAK; case L_FRAME25_6k: - means = &sns_1st_means_25k6[core - 1][0]; + means = &sns_1st_means_25k6[core - 1][0]; /*Q0*/ BREAK; case L_FRAME32k: - means = &sns_1st_means_32k[core - 1][0]; + means = &sns_1st_means_32k[core - 1][0]; /*Q0*/ BREAK; default: assert( !"illegal frame length in sns_1st_cod" ); } - p_dico = &sns_1st_cdbk[0][core - 1][0] + i_mult( index % 32, ( M / 2 ) ); + p_dico = &sns_1st_cdbk[0][core - 1][0] + i_mult( index % 32, ( M / 2 ) ); /*Q0*/ FOR( i = 0; i < M / 2; i++ ) { @@ -89,11 +89,11 @@ static void sns_1st_dec_fx( move32(); } - p_dico = &sns_1st_cdbk[1][sub( core, 1 )][0] + i_mult( shr( index, 5 ), ( M / 2 ) ); + p_dico = &sns_1st_cdbk[1][sub( core, 1 )][0] + i_mult( shr( index, 5 ), ( M / 2 ) ); /*Q0*/ FOR( i = M / 2; i < M; i++ ) { - snsq_fx[i] = L_add( L_mult( ( *p_dico++ ), cdbk_fix ), L_mult( means[i], means_fix ) ); + snsq_fx[i] = L_add( L_mult( ( *p_dico++ ), cdbk_fix ), L_mult( means[i], means_fix ) ); /*Q16*/ move32(); } @@ -106,14 +106,14 @@ static void sns_1st_dec_fx( *-------------------------------------------------------------------*/ static void sns_2st_dec_fx( - Word32 *snsq_fx, /* i/o: i:1st stage o:1st+2nd stage */ + Word32 *snsq_fx, /* i/o: i:1st stage o:1st+2nd stage q_snsq*/ Word16 *q_snsq, - Word16 *indx /* i : index[] (4 bits per words) */ + Word16 *indx /* i : index[] (4 bits per words) Q0*/ ) { Word16 i; Word16 xq_fx[M]; - Word16 scale_fx = 13107; + Word16 scale_fx = 13107; /*1.0/2.5f in Q15*/ move16(); /* quantize */ AVQ_dec_lpc( indx, xq_fx, 2 ); @@ -129,8 +129,8 @@ static void sns_2st_dec_fx( IF( GE_16( *q_snsq, 16 ) ) { snsq_dIFf = sub( *q_snsq, 16 ); - tmp1 = L_shr( snsq_fx[i], snsq_dIFf ); - snsq_fx[i] = L_add( tmp1, tmp ); + tmp1 = L_shr( snsq_fx[i], snsq_dIFf ); /*Q16*/ + snsq_fx[i] = L_add( tmp1, tmp ); /*Q16*/ move32(); *q_snsq = 16; move16(); @@ -138,8 +138,8 @@ static void sns_2st_dec_fx( ELSE { snsq_dIFf = sub( 16, *q_snsq ); - tmp1 = L_shr( tmp, snsq_dIFf ); - snsq_fx[i] = L_add( snsq_fx[i], tmp1 ); + tmp1 = L_shr( tmp, snsq_dIFf ); /*q_snsq*/ + snsq_fx[i] = L_add( snsq_fx[i], tmp1 ); /*q_snsq*/ move32(); } } @@ -152,18 +152,18 @@ static void sns_2st_dec_fx( *-------------------------------------------------------------------*/ void sns_avq_dec_fx( - Word16 *index, /* i : Quantization indices */ - Word32 SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */ + Word16 *index, /* i : Quantization indices Q0*/ + Word32 SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors q_snsq*/ Word16 *q_snsq, - const Word16 L_frame, /* i : frame length */ - const Word16 numlpc /* i : Number of sets of lpc */ + const Word16 L_frame, /* i : frame length Q0*/ + const Word16 numlpc /* i : Number of sets of lpc Q0*/ ) { Word16 i, nbi, last; Word16 q_type; /* go from one-based indexing to zero-based indexing */ - last = sub( numlpc, 1 ); + last = sub( numlpc, 1 ); /*Q0*/ index++; @@ -173,13 +173,13 @@ void sns_avq_dec_fx( move16(); sns_2st_dec_fx( SNS_Q[last], q_snsq, index ); - nbi = add( add( 2, index[0] ), index[1] ); + nbi = add( add( 2, index[0] ), index[1] ); /*Q0*/ index += nbi; /* Decode intermediate LPC (512 framing) */ IF( EQ_16( numlpc, 2 ) ) { - q_type = *index++; + q_type = *index++; /*Q0*/ move16(); IF( q_type == 0 ) @@ -193,7 +193,7 @@ void sns_avq_dec_fx( { FOR( i = 0; i < M; i++ ) { - SNS_Q[0][i] = SNS_Q[1][i]; + SNS_Q[0][i] = SNS_Q[1][i]; /*q_snsq*/ move32(); } sns_2st_dec_fx( SNS_Q[0], q_snsq, index ); @@ -210,18 +210,18 @@ void sns_avq_dec_fx( *-------------------------------------------------------------------*/ void sns_avq_dec_stereo_fx( - Word16 *indexl, /* i : Quantization indices (left channel) */ - Word16 *indexr, /* i : Quantization indices (right channe) */ - const Word16 L_frame, /* i : frame length */ - Word32 *SNS_Ql, /* o : Quantized SNS vectors (left channel) */ + Word16 *indexl, /* i : Quantization indices (left channel) Q0*/ + Word16 *indexr, /* i : Quantization indices (right channe) Q0*/ + const Word16 L_frame, /* i : frame length Q0*/ + Word32 *SNS_Ql, /* o : Quantized SNS vectors (left channel) q_l*/ Word16 *q_l, - Word32 *SNS_Qr, /* o : Quantized SNS vectors (right channe) */ + Word32 *SNS_Qr, /* o : Quantized SNS vectors (right channe) q_r*/ Word16 *q_r ) { Word16 i, stereo_mode; Word32 mid_q_fx[M], side_q_fx[M]; - stereo_mode = *indexl++; + stereo_mode = *indexl++; /*Q0*/ move16(); indexr++; @@ -236,7 +236,7 @@ void sns_avq_dec_stereo_fx( IF( EQ_16( stereo_mode, 2 ) ) { /* MS coding */ - tmp1 = *indexl++; + tmp1 = *indexl++; /*Q0*/ move16(); sns_1st_dec_fx( tmp1, TCX_20_CORE, L_frame, mid_q_fx ); q_mid = 16; @@ -291,9 +291,9 @@ void sns_avq_dec_stereo_fx( ELSE { /* LR decoding */ - tmp1 = *indexl++; + tmp1 = *indexl++; /*Q0*/ move16(); - tmp2 = *indexr++; + tmp2 = *indexr++; /*Q0*/ move16(); sns_1st_dec_fx( tmp1, TCX_20_CORE, L_frame, SNS_Ql ); *q_l = 16; @@ -316,8 +316,8 @@ void sns_avq_dec_stereo_fx( *-------------------------------------------------------------------*/ void dequantize_sns_fx( - Word16 indices[CPE_CHANNELS][NPRM_LPC_NEW], - Word32 snsQ_out_fx[CPE_CHANNELS][NB_DIV][M], + Word16 indices[CPE_CHANNELS][NPRM_LPC_NEW], /*Q0*/ + Word32 snsQ_out_fx[CPE_CHANNELS][NB_DIV][M], /*Q16*/ Decoder_State **sts ) { Word16 nSubframes, k, ch; @@ -325,13 +325,13 @@ void dequantize_sns_fx( Word16 zero_side_flag[NB_DIV]; Decoder_State *st; - sns_stereo_mode[0] = indices[0][0]; + sns_stereo_mode[0] = indices[0][0]; /*Q0*/ move16(); - sns_stereo_mode[1] = indices[0][1]; + sns_stereo_mode[1] = indices[0][1]; /*Q0*/ move16(); - zero_side_flag[0] = indices[0][2]; + zero_side_flag[0] = indices[0][2]; /*Q0*/ move16(); - zero_side_flag[1] = indices[0][3]; + zero_side_flag[1] = indices[0][3]; /*Q0*/ move16(); FOR( ch = 0; ch < CPE_CHANNELS; ++ch ) @@ -365,7 +365,7 @@ void dequantize_sns_fx( move16(); } - Word32 *snsQ_fx = snsQ_out_fx[ch][k]; + Word32 *snsQ_fx = snsQ_out_fx[ch][k]; /*Q16*/ IF( is_side ) { @@ -379,13 +379,13 @@ void dequantize_sns_fx( nStages = SNS_MSVQ_NSTAGES_SIDE; move16(); - msvq_dec_fx( side_cdbks_fx, NULL, NULL, nStages, M, M, &indices[ch][add( idxIndices, SNS_STEREO_MODE_OFFSET_INDICES )], 0, NULL, snsQ_fx, NULL, 15 ); // always 15 + msvq_dec_fx( side_cdbks_fx, NULL, NULL, nStages, M, M, &indices[ch][( idxIndices + SNS_STEREO_MODE_OFFSET_INDICES )], 0, NULL, snsQ_fx, NULL, 15 ); // always 15 } ELSE { - msvq_dec_fx( cdbks_fx, NULL, NULL, nStages, M, M, &indices[ch][add( idxIndices, SNS_STEREO_MODE_OFFSET_INDICES )], 0, NULL, snsQ_fx, NULL, 12 ); + msvq_dec_fx( cdbks_fx, NULL, NULL, nStages, M, M, &indices[ch][( idxIndices + SNS_STEREO_MODE_OFFSET_INDICES )], 0, NULL, snsQ_fx, NULL, 12 ); } - idxIndices = add( idxIndices, nStages ); + idxIndices = add( idxIndices, nStages ); /*Q0*/ } } @@ -402,7 +402,7 @@ void dequantize_sns_fx( { IF( EQ_16( sns_stereo_mode[k], SNS_STEREO_MODE_MS ) ) { - inverseMS_fx( M, snsQ_out_fx[0][k], snsQ_out_fx[1][k], ONE_IN_Q31 ); + inverseMS_fx( M, snsQ_out_fx[0][k], snsQ_out_fx[1][k], ONE_IN_Q31 ); /*Q16*/ } } } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index b8b1e0545e6196a0ba47a18f8c0a585878495be8..6089012bc1831d43d66fcb5887793fd2806e1f09 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -278,7 +278,7 @@ ivas_error ivas_spar_dec_open( #else ivas_error ivas_spar_dec_open_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */ + const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag Q0*/ ) { SPAR_DEC_HANDLE hSpar; @@ -292,10 +292,10 @@ ivas_error ivas_spar_dec_open_fx( error = IVAS_ERR_OK; move32(); - sba_order_internal = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); + sba_order_internal = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); /*Q0*/ move16(); - num_channels_internal = ivas_sba_get_nchan_metadata_fx( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate ); + num_channels_internal = ivas_sba_get_nchan_metadata_fx( sba_order_internal, st_ivas->hDecoderConfig->ivas_total_brate ); /*Q0*/ hSpar = st_ivas->hSpar; @@ -308,16 +308,16 @@ ivas_error ivas_spar_dec_open_fx( } } - output_Fs = st_ivas->hDecoderConfig->output_Fs; + output_Fs = st_ivas->hDecoderConfig->output_Fs; /*Q0*/ move32(); IF( GT_16( num_channels_internal, ( SBA_HOA2_ORDER + 1 ) * ( SBA_HOA2_ORDER + 1 ) ) ) { - num_decor_chs = IVAS_HBR_MAX_DECOR_CHS; + num_decor_chs = IVAS_HBR_MAX_DECOR_CHS; /*Q0*/ move16(); } ELSE { - num_decor_chs = sub( num_channels_internal, 1 ); + num_decor_chs = sub( num_channels_internal, 1 ); /*Q0*/ } /* TD decorr. */ @@ -346,7 +346,7 @@ ivas_error ivas_spar_dec_open_fx( move16(); if ( hSpar->hTdDecorr ) { - hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[hSpar->hMdDec->table_idx].td_ducking; + hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[hSpar->hMdDec->table_idx].td_ducking; /*Q0*/ move16(); } @@ -357,9 +357,9 @@ ivas_error ivas_spar_dec_open_fx( { return error; } - fb_cfg->pcm_offset = NS2SA_FX2( output_Fs, DELAY_FB_1_NS + IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ); + fb_cfg->pcm_offset = NS2SA_FX2( output_Fs, DELAY_FB_1_NS + IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ); /*Q0*/ move16(); - fb_cfg->remix_order = remix_order_set[hSpar->hMdDec->spar_md_cfg.remix_unmix_order]; + fb_cfg->remix_order = remix_order_set[hSpar->hMdDec->spar_md_cfg.remix_unmix_order]; /*Q0*/ move16(); /* FB mixer handle */ @@ -440,21 +440,21 @@ ivas_error ivas_spar_dec_open_fx( ivas_output_init( &( st_ivas->hTransSetup ), st_ivas->transport_config ); set16_fx( hSpar->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); - set16_fx( hSpar->subframe_nbslots, JBM_CLDFB_SLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS ); - hSpar->nb_subframes = DEFAULT_JBM_SUBFRAMES_5MS; + set16_fx( hSpar->subframe_nbslots, JBM_CLDFB_SLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS ); /*Q0*/ + hSpar->nb_subframes = DEFAULT_JBM_SUBFRAMES_5MS; /*Q0*/ move16(); hSpar->subframes_rendered = 0; move16(); hSpar->slots_rendered = 0; move16(); - hSpar->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; + hSpar->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; /*Q0*/ move16(); /* init render timeslot mapping */ set16_fx( hSpar->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); FOR( map_idx = 0; map_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; map_idx++ ) { - hSpar->render_to_md_map[map_idx] = map_idx; + hSpar->render_to_md_map[map_idx] = map_idx; /*Q0*/ move16(); } @@ -468,17 +468,17 @@ ivas_error ivas_spar_dec_open_fx( buffer_mode = TC_BUFFER_MODE_RENDERER; move32(); - nchan_tc = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); - nchan_to_allocate = num_channels_internal; + nchan_tc = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); /*Q0*/ + nchan_to_allocate = num_channels_internal; /*Q0*/ move16(); test(); if ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - nchan_to_allocate = add( nchan_to_allocate, st_ivas->nchan_ism ); + nchan_to_allocate = add( nchan_to_allocate, st_ivas->nchan_ism ); /*Q0*/ } - granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /*Q0*/ move16(); test(); @@ -490,17 +490,17 @@ ivas_error ivas_spar_dec_open_fx( test(); IF( ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) { - nchan_tc = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); - nchan_to_allocate = nchan_tc; + nchan_tc = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); /*Q0*/ + nchan_to_allocate = nchan_tc; /*Q0*/ move16(); } ELSE { buffer_mode = TC_BUFFER_MODE_BUFFER; move32(); - nchan_tc = st_ivas->hDecoderConfig->nchan_out; + nchan_tc = st_ivas->hDecoderConfig->nchan_out; /*Q0*/ move16(); - nchan_to_allocate = nchan_tc; + nchan_to_allocate = nchan_tc; /*Q0*/ move16(); } } @@ -518,7 +518,7 @@ ivas_error ivas_spar_dec_open_fx( /* get correct granularity in case of binaural rendering of the discrete objects with the td obj renderer */ Word32 quo, rem; iDiv_and_mod_32( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &quo, &rem, 0 ); - granularity = extract_l( quo ); + granularity = extract_l( quo ); /*Q0*/ } IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, buffer_mode, nchan_tc, nchan_to_allocate, nchan_to_allocate, granularity ) ), IVAS_ERR_OK ) ) @@ -582,8 +582,8 @@ void ivas_spar_dec_close( #else void ivas_spar_dec_close_fx( SPAR_DEC_HANDLE *hSpar, /* i/o: SPAR decoder handle */ - const Word32 output_Fs, /* i : output sampling rate */ - const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag */ + const Word32 output_Fs, /* i : output sampling rate Q0*/ + const Word16 spar_reconfig_flag /* i : SPAR reconfiguration flag Q0*/ ) { test(); @@ -631,7 +631,7 @@ void ivas_spar_dec_close_fx( #ifdef IVAS_FLOAT_FIXED ivas_error ivas_spar_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - Word16 *nb_bits_read /* o : number of MD bits read */ + Word16 *nb_bits_read /* o : number of MD bits read Q0*/ ) { DECODER_CONFIG_HANDLE hDecoderConfig; @@ -657,14 +657,14 @@ ivas_error ivas_spar_dec_fx( st0 = st_ivas->hCPE[0]->hCoreCoder[0]; } - bit_stream_orig = st0->bit_stream; - next_bit_pos_orig = st0->next_bit_pos; + bit_stream_orig = st0->bit_stream; /*Q0*/ + next_bit_pos_orig = st0->next_bit_pos; /*Q0*/ move16(); IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { iDiv_and_mod_32( hDecoderConfig->ivas_total_brate, FRAMES_PER_SEC, &quo, &rem, 0 ); - last_bit_pos = sub( extract_l( L_sub( quo, 1 ) ), nb_bits_read[1] ); + last_bit_pos = sub( extract_l( L_sub( quo, 1 ) ), nb_bits_read[1] ); /*Q0*/ } ELSE { @@ -683,38 +683,38 @@ ivas_error ivas_spar_dec_fx( IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { iDiv_and_mod_32( hDecoderConfig->ivas_total_brate, FRAMES_PER_SEC, &quo, &rem, 0 ); - last_bit_pos = sub( extract_l( L_sub( quo, 1 ) ), nb_bits_read[1] ); + last_bit_pos = sub( extract_l( L_sub( quo, 1 ) ), nb_bits_read[1] ); /*Q0*/ } ELSE { iDiv_and_mod_32( hDecoderConfig->ivas_total_brate, FRAMES_PER_SEC, &quo, &rem, 0 ); - last_bit_pos = extract_l( L_sub( quo, 1 ) ); + last_bit_pos = extract_l( L_sub( quo, 1 ) ); /*Q0*/ } test(); if ( !st0->bfi && EQ_32( hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) { - last_bit_pos = sub( last_bit_pos, SID_FORMAT_NBITS ); + last_bit_pos = sub( last_bit_pos, SID_FORMAT_NBITS ); /*Q0*/ } - nb_bits_read_orig = *nb_bits_read; + nb_bits_read_orig = *nb_bits_read; /*Q0*/ move16(); - last_bit_pos = sub( last_bit_pos, nb_bits_read_orig ); + last_bit_pos = sub( last_bit_pos, nb_bits_read_orig ); /*Q0*/ /* reverse the bitstream for easier reading of indices */ FOR( i = 0; i < s_min( MAX_BITS_METADATA, last_bit_pos ); i++ ) { - bstr_meta[i] = st_ivas->bit_stream[sub( last_bit_pos, i )]; + bstr_meta[i] = st_ivas->bit_stream[( last_bit_pos - i )]; /*Q0*/ move16(); } - st0->bit_stream = bstr_meta; + st0->bit_stream = bstr_meta; /*Q0*/ st0->next_bit_pos = 0; move16(); - st0->bits_frame = s_min( MAX_BITS_METADATA, add( last_bit_pos, 1 ) ); + st0->bits_frame = s_min( MAX_BITS_METADATA, add( last_bit_pos, 1 ) ); /*Q0*/ move16(); if ( !st0->bfi ) { - st0->total_brate = hDecoderConfig->ivas_total_brate; /* to avoid BER detect */ + st0->total_brate = hDecoderConfig->ivas_total_brate; /* to avoid BER detect */ /*Q0*/ move32(); } @@ -727,21 +727,21 @@ ivas_error ivas_spar_dec_fx( return error; } - *nb_bits_read = add( st0->next_bit_pos, nb_bits_read_orig ); + *nb_bits_read = add( st0->next_bit_pos, nb_bits_read_orig ); /*Q0*/ move16(); - st0->bit_stream = bit_stream_orig; - st0->next_bit_pos = next_bit_pos_orig; + st0->bit_stream = bit_stream_orig; /*Q0*/ + st0->next_bit_pos = next_bit_pos_orig; /*Q0*/ move16(); test(); IF( !st0->bfi && EQ_32( hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) ) { Word16 zero_pad_bits; - *nb_bits_read = add( *nb_bits_read, SID_FORMAT_NBITS ); + *nb_bits_read = add( *nb_bits_read, SID_FORMAT_NBITS ); /*Q0*/ move16(); - zero_pad_bits = sub( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC, *nb_bits_read ); + zero_pad_bits = sub( ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC, *nb_bits_read ); /*Q0*/ assert( zero_pad_bits <= 1 ); - *nb_bits_read = add( *nb_bits_read, zero_pad_bits ); + *nb_bits_read = add( *nb_bits_read, zero_pad_bits ); /*Q0*/ move16(); } @@ -853,10 +853,10 @@ ivas_error ivas_spar_dec( #ifdef IVAS_FLOAT_FIXED static Word16 ivas_get_spar_table_idx_from_coded_idx( - const Word32 ivas_total_brate, /* i : IVAS total bitrate */ - const Word16 sba_order, /* i : Ambisonic (SBA) order */ + const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ + const Word16 sba_order, /* i : Ambisonic (SBA) order Q0*/ Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - Word16 *bitlen /* o : number of bits */ + Word16 *bitlen /* o : number of bits Q0*/ ) { Word16 table_idx, ind1[IVAS_SPAR_BR_TABLE_LEN]; @@ -878,12 +878,12 @@ static Word16 ivas_get_spar_table_idx_from_coded_idx( } assert( j > 0 ); - *bitlen = ivas_get_bits_to_encode( sub( j, 1 ) ); + *bitlen = ivas_get_bits_to_encode( sub( j, 1 ) ); /*Q0*/ move16(); - ind2 = get_next_indice_fx( st0, *bitlen ); + ind2 = get_next_indice_fx( st0, *bitlen ); /*Q0*/ - table_idx = ind1[ind2]; + table_idx = ind1[ind2]; /*Q0*/ move16(); return table_idx; @@ -929,17 +929,17 @@ static int16_t ivas_get_spar_table_idx_from_coded_idx( #ifdef IVAS_FLOAT_FIXED static Word16 ivas_parse_spar_header( - const Word32 ivas_total_brate, /* i : IVAS total bitrate */ - const Word16 sba_order, /* i : Ambisonic (SBA) order */ + const Word32 ivas_total_brate, /* i : IVAS total bitrate Q0*/ + const Word16 sba_order, /* i : Ambisonic (SBA) order Q0*/ Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - Word16 *table_idx ) + Word16 *table_idx /*Q0*/ ) { Word16 bitlen, bwidth; - *table_idx = ivas_get_spar_table_idx_from_coded_idx( ivas_total_brate, sba_order, st0, &bitlen ); + *table_idx = ivas_get_spar_table_idx_from_coded_idx( ivas_total_brate, sba_order, st0, &bitlen ); /*Q0*/ move16(); - bwidth = ivas_spar_br_table_consts[( *table_idx )].bwidth; + bwidth = ivas_spar_br_table_consts[( *table_idx )].bwidth; /*Q0*/ move16(); return bwidth; @@ -966,7 +966,7 @@ static int16_t ivas_parse_spar_header( static Word16 get_random_number_fx( Word16 *seed ) { - return Random( seed ); + return Random( seed ); /*Q15*/ } #else static float get_random_number( @@ -981,12 +981,13 @@ static float get_random_number( #ifdef IVAS_FLOAT_FIXED static Word32 matrix_det_fx( - const Word32 a00, - const Word32 a01, - const Word32 a10, - const Word32 a11 ) + const Word32 a00, /*Q27*/ + const Word32 a01, /*Q27*/ + const Word32 a10, /*Q27*/ + const Word32 a11 /*Q27*/ +) { - return L_sub( Mpy_32_32( a00, a11 ), Mpy_32_32( a01, a10 ) ); + return L_sub( Mpy_32_32( a00, a11 ), Mpy_32_32( a01, a10 ) ); /*Q23*/ } #else static float matrix_det( @@ -1002,8 +1003,8 @@ static float matrix_det( #ifdef IVAS_FLOAT_FIXED static void matrix_inverse_fx( - Word32 in[3][3], - Word32 out[3][3], + Word32 in[3][3], /*Q27*/ + Word32 out[3][3], /*out_q*/ const Word16 size, Word16 *out_q ) { @@ -1016,9 +1017,9 @@ static void matrix_inverse_fx( IF( EQ_16( size, 1 ) ) { - tmp_32 = BASOP_Util_Divide3232_Scale( ONE_IN_Q27, L_max( in[0][0], eps_fx ), &tmp_e ); + tmp_32 = BASOP_Util_Divide3232_Scale( ONE_IN_Q27, L_max( in[0][0], eps_fx ), &tmp_e ); /*Q: 15 - tmp_e*/ shift = norm_l( tmp_32 ); - out[0][0] = L_shl( tmp_32, shift ); + out[0][0] = L_shl( tmp_32, shift ); /*out_q*/ move32(); *out_q = add( shift, sub( Q15, tmp_e ) ); move16(); @@ -1027,20 +1028,20 @@ static void matrix_inverse_fx( } ELSE IF( EQ_16( size, 2 ) ) { - det = matrix_det_fx( in[0][1], in[0][1], in[1][0], in[1][1] ); - tmp_32 = BASOP_Util_Divide3232_Scale( ONE_IN_Q23, L_max( det, eps_fx ), &tmp_e ); + det = matrix_det_fx( in[0][1], in[0][1], in[1][0], in[1][1] ); /*Q23*/ + tmp_32 = BASOP_Util_Divide3232_Scale( ONE_IN_Q23, L_max( det, eps_fx ), &tmp_e ); /*Q: 15 - tmp_e*/ shift = norm_l( tmp_32 ); - fac = L_shl( tmp_32, shift ); + fac = L_shl( tmp_32, shift ); /*q_fac*/ q_fac = add( shift, sub( Q15, tmp_e ) ); - out[0][0] = Mpy_32_32( in[1][1], fac ); + out[0][0] = Mpy_32_32( in[1][1], fac ); /*q_fac - 4*/ move32(); - out[1][0] = Mpy_32_32( in[1][0], L_negate( fac ) ); + out[1][0] = Mpy_32_32( in[1][0], L_negate( fac ) ); /*q_fac - 4*/ move32(); - out[0][1] = Mpy_32_32( in[0][1], L_negate( fac ) ); + out[0][1] = Mpy_32_32( in[0][1], L_negate( fac ) ); /*q_fac - 4*/ move32(); - out[1][1] = Mpy_32_32( in[0][0], fac ); + out[1][1] = Mpy_32_32( in[0][0], fac ); /*q_fac - 4*/ move32(); *out_q = add( Q27, sub( q_fac, 31 ) ); @@ -1049,31 +1050,31 @@ static void matrix_inverse_fx( return; } - det = L_add( L_sub( Mpy_32_32( in[0][0], matrix_det_fx( in[1][1], in[1][2], in[2][1], in[2][2] ) ), Mpy_32_32( in[1][0], matrix_det_fx( in[0][1], in[0][2], in[2][1], in[2][2] ) ) ), Mpy_32_32( in[2][0], matrix_det_fx( in[0][1], in[0][2], in[1][1], in[1][2] ) ) ); - tmp_32 = BASOP_Util_Divide3232_Scale( ONE_IN_Q19, L_max( det, eps_fx ), &tmp_e ); + det = L_add( L_sub( Mpy_32_32( in[0][0], matrix_det_fx( in[1][1], in[1][2], in[2][1], in[2][2] ) ), Mpy_32_32( in[1][0], matrix_det_fx( in[0][1], in[0][2], in[2][1], in[2][2] ) ) ), Mpy_32_32( in[2][0], matrix_det_fx( in[0][1], in[0][2], in[1][1], in[1][2] ) ) ); /*Q19*/ + tmp_32 = BASOP_Util_Divide3232_Scale( ONE_IN_Q19, L_max( det, eps_fx ), &tmp_e ); /*Q: 31 - tmp_e*/ shift = norm_l( tmp_32 ); - fac = L_shl( tmp_32, shift ); + fac = L_shl( tmp_32, shift ); /*q_fac*/ q_fac = add( shift, sub( Q15, tmp_e ) ); - out[0][0] = Mpy_32_32( matrix_det_fx( in[1][1], in[1][2], in[2][1], in[2][2] ), fac ); + out[0][0] = Mpy_32_32( matrix_det_fx( in[1][1], in[1][2], in[2][1], in[2][2] ), fac ); /*q_fac-8*/ move32(); - out[1][0] = Mpy_32_32( matrix_det_fx( in[1][0], in[1][2], in[2][0], in[2][2] ), L_negate( fac ) ); + out[1][0] = Mpy_32_32( matrix_det_fx( in[1][0], in[1][2], in[2][0], in[2][2] ), L_negate( fac ) ); /*q_fac-8*/ move32(); - out[2][0] = Mpy_32_32( matrix_det_fx( in[1][0], in[1][1], in[2][0], in[2][1] ), fac ); + out[2][0] = Mpy_32_32( matrix_det_fx( in[1][0], in[1][1], in[2][0], in[2][1] ), fac ); /*q_fac-8*/ move32(); - out[0][1] = Mpy_32_32( matrix_det_fx( in[0][1], in[0][2], in[2][1], in[2][2] ), L_negate( fac ) ); + out[0][1] = Mpy_32_32( matrix_det_fx( in[0][1], in[0][2], in[2][1], in[2][2] ), L_negate( fac ) ); /*q_fac-8*/ move32(); - out[1][1] = Mpy_32_32( matrix_det_fx( in[0][0], in[0][2], in[2][0], in[2][2] ), fac ); + out[1][1] = Mpy_32_32( matrix_det_fx( in[0][0], in[0][2], in[2][0], in[2][2] ), fac ); /*q_fac-8*/ move32(); - out[2][1] = Mpy_32_32( matrix_det_fx( in[0][0], in[0][1], in[2][0], in[2][1] ), L_negate( fac ) ); + out[2][1] = Mpy_32_32( matrix_det_fx( in[0][0], in[0][1], in[2][0], in[2][1] ), L_negate( fac ) ); /*q_fac-8*/ move32(); - out[0][2] = Mpy_32_32( matrix_det_fx( in[0][1], in[0][2], in[1][1], in[1][2] ), fac ); + out[0][2] = Mpy_32_32( matrix_det_fx( in[0][1], in[0][2], in[1][1], in[1][2] ), fac ); /*q_fac-8*/ move32(); - out[1][2] = Mpy_32_32( matrix_det_fx( in[0][0], in[0][2], in[1][0], in[1][2] ), L_negate( fac ) ); + out[1][2] = Mpy_32_32( matrix_det_fx( in[0][0], in[0][2], in[1][0], in[1][2] ), L_negate( fac ) ); /*q_fac-8*/ move32(); - out[2][2] = Mpy_32_32( matrix_det_fx( in[0][0], in[0][1], in[1][0], in[1][1] ), fac ); + out[2][2] = Mpy_32_32( matrix_det_fx( in[0][0], in[0][1], in[1][0], in[1][1] ), fac ); /*q_fac-8*/ move32(); *out_q = add( Q23, sub( q_fac, 31 ) ); @@ -1164,45 +1165,45 @@ void ivas_spar_get_cldfb_gains_fx( Word16 Q_cf_len_s; Word16 Q_weights; - pt_len = cldfbAnaDec0->p_filter_length; + pt_len = cldfbAnaDec0->p_filter_length; /*Q0*/ move16(); - num_cldfb_bands = cldfbAnaDec0->no_channels; + num_cldfb_bands = cldfbAnaDec0->no_channels; /*Q0*/ move16(); - stride = NS2SA_FX2( output_Fs_fx, DELAY_CLDFB_NS ); - encfb_delay = NS2SA_FX2( output_Fs_fx, IVAS_FB_ENC_DELAY_NS ); - decfb_delay = NS2SA_FX2( output_Fs_fx, IVAS_FB_DEC_DELAY_NS ); + stride = NS2SA_FX2( output_Fs_fx, DELAY_CLDFB_NS ); /*Q0*/ + encfb_delay = NS2SA_FX2( output_Fs_fx, IVAS_FB_ENC_DELAY_NS ); /*Q0*/ + decfb_delay = NS2SA_FX2( output_Fs_fx, IVAS_FB_DEC_DELAY_NS ); /*Q0*/ - cf_start = add( sub( hSpar->hFbMixer->cross_fade_start_offset, encfb_delay ), decfb_delay ); /* time domain after CLDFB synthesis*/ - cf_end = add( sub( hSpar->hFbMixer->cross_fade_end_offset, encfb_delay ), decfb_delay ); + cf_start = add( sub( hSpar->hFbMixer->cross_fade_start_offset, encfb_delay ), decfb_delay ); /* time domain after CLDFB synthesis*/ /*Q0*/ + cf_end = add( sub( hSpar->hFbMixer->cross_fade_end_offset, encfb_delay ), decfb_delay ); /*Q0*/ cf_len = sub( cf_end, cf_start ); - weights_fx = hSpar->hFbMixer->cldfb_cross_fade_fx; - cf_cldfb_start = shr( extract_l( ceil_fixed( sub( divide1616( sub( cf_start, shr( decfb_delay, 1 ) ), shl( stride, 9 ) ), 32 ), 6 ) ), 6 ); - cf_cldfb_end = shr( divide1616( add( sub( cf_start, shr( decfb_delay, 1 ) ), cf_len ), shl( stride, 9 ) ), 6 ); /*q-factor of stride is 9(as max value is 60)*/ - num_cf_slots = add( sub( cf_cldfb_end, cf_cldfb_start ), 1 ); - num_samples = add( imult1616( num_cf_slots, stride ), sub( pt_len, stride ) ); + weights_fx = hSpar->hFbMixer->cldfb_cross_fade_fx; /*hSpar->hFbMixer->cldfb_cross_fade_q*/ + cf_cldfb_start = shr( extract_l( ceil_fixed( sub( divide1616( sub( cf_start, shr( decfb_delay, 1 ) ), shl( stride, 9 ) ), 32 ), 6 ) ), 6 ); /*Q0*/ + cf_cldfb_end = shr( divide1616( add( sub( cf_start, shr( decfb_delay, 1 ) ), cf_len ), shl( stride, 9 ) ), 6 ); /*q-factor of stride is 9(as max value is 60)*/ /*Q0*/ + num_cf_slots = add( sub( cf_cldfb_end, cf_cldfb_start ), 1 ); /*Q0*/ + num_samples = add( imult1616( num_cf_slots, stride ), sub( pt_len, stride ) ); /*Q0*/ seed = RANDOM_INITSEED; move16(); split_band = SPAR_DIRAC_SPLIT_START_BAND; move16(); - pp_ts_im_fx[0] = ts_im_fx; - pp_ts_re_fx[0] = ts_re_fx; + pp_ts_im_fx[0] = ts_im_fx; /*Q22*/ + pp_ts_re_fx[0] = ts_re_fx; /*Q22*/ set32_fx( tgt_fx, 0, ( 3 - 1 ) * CLDFB_NO_CHANNELS_MAX + 10 * CLDFB_NO_CHANNELS_MAX ); - cf_start_s_fx = divide3232( ( sub( cf_start, shr( decfb_delay, 1 ) ) ), output_Fs_fx ); - cf_len_s_fx = divide3232( sub( hSpar->hFbMixer->cross_fade_end_offset, hSpar->hFbMixer->cross_fade_start_offset ), output_Fs_fx ); + cf_start_s_fx = divide3232( ( sub( cf_start, shr( decfb_delay, 1 ) ) ), output_Fs_fx ); /*Q_cf_start_s*/ + cf_len_s_fx = divide3232( sub( hSpar->hFbMixer->cross_fade_end_offset, hSpar->hFbMixer->cross_fade_start_offset ), output_Fs_fx ); /*Q_cf_len_s*/ Q_cf_start_s = sub( norm_s( cf_start_s_fx ), 1 ); Q_cf_len_s = norm_s( cf_len_s_fx ); Q_weights = add( 15, sub( Q_cf_start_s, Q_cf_len_s ) ); FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) { - weights_fx[ts] = divide1616( shl( sub( divide3232( L_mult0( add( shl( ts, 1 ), 1 ), shr( stride, 1 ) ), output_Fs_fx ), cf_start_s_fx ), Q_cf_start_s ), shl( cf_len_s_fx, Q_cf_len_s ) ); + weights_fx[ts] = divide1616( shl( sub( divide3232( L_mult0( add( shl( ts, 1 ), 1 ), shr( stride, 1 ) ), output_Fs_fx ), cf_start_s_fx ), Q_cf_start_s ), shl( cf_len_s_fx, Q_cf_len_s ) ); /*Q_weights*/ move16(); - weights_fx[ts] = s_max( s_min( weights_fx[ts], shl( 1, Q_weights ) ), 0 ); + weights_fx[ts] = s_max( s_min( weights_fx[ts], shl( 1, Q_weights ) ), 0 ); /*Q_weights*/ move16(); } - hSpar->hFbMixer->cldfb_cross_fade_start = cf_cldfb_start; + hSpar->hFbMixer->cldfb_cross_fade_start = cf_cldfb_start; /*Q0*/ move16(); - hSpar->hFbMixer->cldfb_cross_fade_end = cf_cldfb_end; + hSpar->hFbMixer->cldfb_cross_fade_end = cf_cldfb_end; /*Q0*/ move16(); test(); @@ -1215,10 +1216,10 @@ void ivas_spar_get_cldfb_gains_fx( /* optimization*/ /* compute time-domain cross-fade for considered time slots*/ - tmp_idx = sub( cf_start, imult1616( cf_cldfb_start, stride ) ); + tmp_idx = sub( cf_start, imult1616( cf_cldfb_start, stride ) ); /*Q0*/ FOR( sample = 0; sample < cf_len; sample++ ) { - tgt_fx[tmp_idx] = L_deposit_h( hSpar->hFbMixer->pFilterbank_cross_fade_fx[sample] ); + tgt_fx[tmp_idx] = L_deposit_h( hSpar->hFbMixer->pFilterbank_cross_fade_fx[sample] ); /*Q31*/ move32(); tmp_idx = add( tmp_idx, 1 ); /* increasing window function */ @@ -1226,7 +1227,7 @@ void ivas_spar_get_cldfb_gains_fx( FOR( ; tmp_idx < num_samples; tmp_idx++ ) { /* fill up with ones*/ - tgt_fx[tmp_idx] = MAX_32; + tgt_fx[tmp_idx] = MAX_32; /*Q31*/ move32(); } FOR( sample = 0; sample < num_samples; sample++ ) @@ -1241,8 +1242,8 @@ void ivas_spar_get_cldfb_gains_fx( FOR( sample = 0; sample < sub( pt_len, stride ); sample++ ) { /* fill internal CLDFB analysis time buffer with data*/ - Word16 x_fx = get_random_number_fx( &seed ); - cldfbAnaDec0->cldfb_state_fx[sample] = L_shl( x_fx, 12 ); + Word16 x_fx = get_random_number_fx( &seed ); /*Q15*/ + cldfbAnaDec0->cldfb_state_fx[sample] = L_shl( x_fx, 12 ); /*Q27*/ move32(); } Word16 q_cldfb = 27; @@ -1253,8 +1254,8 @@ void ivas_spar_get_cldfb_gains_fx( { FOR( sample = 0; sample < stride; sample++ ) { - Word16 x_fx = get_random_number_fx( &seed ); - ts_inout_fx[sample] = L_shl( x_fx, 12 ); /*Q-27*/ + Word16 x_fx = get_random_number_fx( &seed ); /*Q15*/ + ts_inout_fx[sample] = L_shl( x_fx, 12 ); /*Q27*/ move32(); } @@ -1264,15 +1265,15 @@ void ivas_spar_get_cldfb_gains_fx( FOR( sample = 0; sample < stride; sample++ ) { - T_fx[add( imult1616( slot, stride ), sample )][slot] = ts_inout_fx[sample]; + T_fx[( ( slot * stride ) + sample )][slot] = ts_inout_fx[sample]; /*Q21*/ move32(); } - tmp_idx = sub( pt_len, 1 ); + tmp_idx = sub( pt_len, 1 ); /*Q0*/ FOR( sample = stride; sample < pt_len; sample++ ) { - T_fx[add( imult1616( slot, stride ), sample )][slot] = cldfbSynDec0->cldfb_state_fx[tmp_idx]; + T_fx[( ( slot * stride ) + sample )][slot] = cldfbSynDec0->cldfb_state_fx[tmp_idx]; /*Q21*/ move32(); - tmp_idx = sub( tmp_idx, 1 ); + tmp_idx = sub( tmp_idx, 1 ); /*Q0*/ } } @@ -1297,11 +1298,11 @@ void ivas_spar_get_cldfb_gains_fx( } } - Tt_T_fx[1][0] = Tt_T_fx[0][1]; + Tt_T_fx[1][0] = Tt_T_fx[0][1]; /*Q27*/ move32(); - Tt_T_fx[2][0] = Tt_T_fx[0][2]; + Tt_T_fx[2][0] = Tt_T_fx[0][2]; /*Q27*/ move32(); - Tt_T_fx[2][1] = Tt_T_fx[1][2]; + Tt_T_fx[2][1] = Tt_T_fx[1][2]; /*Q27*/ move32(); FOR( slot_row = 0; slot_row < num_cf_slots; slot_row++ ) { @@ -1309,7 +1310,7 @@ void ivas_spar_get_cldfb_gains_fx( move32(); FOR( sample = 0; sample < num_samples; sample++ ) { - Tt_tgt_fx[slot_row] = L_add( Tt_tgt_fx[slot_row], Mpy_32_32( T_fx[sample][slot_row], tgt_fx[sample] ) ); + Tt_tgt_fx[slot_row] = L_add( Tt_tgt_fx[slot_row], Mpy_32_32( T_fx[sample][slot_row], tgt_fx[sample] ) ); /*Q21*/ move32(); } } @@ -1323,9 +1324,9 @@ void ivas_spar_get_cldfb_gains_fx( move32(); FOR( slot_col = 0; slot_col < num_cf_slots; slot_col++ ) { - tmp = L_add( tmp, Mpy_32_32( Tt_T_inv_fx[slot_row][slot_col], Tt_tgt_fx[slot_col] ) ); + tmp = L_add( tmp, Mpy_32_32( Tt_T_inv_fx[slot_row][slot_col], Tt_tgt_fx[slot_col] ) ); /*output_q-10*/ } - weights_fx[add( cf_cldfb_start, slot_row )] = extract_l( L_shr( L_max( L_min( tmp, L_shl( 1, sub( output_q, 10 ) ) ), 0 ), sub( sub( output_q, 10 ), Q_weights ) ) ); /*Q_weights*/ + weights_fx[( cf_cldfb_start + slot_row )] = extract_l( L_shr( L_max( L_min( tmp, L_shl( 1, sub( output_q, 10 ) ) ), 0 ), sub( sub( output_q, 10 ), Q_weights ) ) ); /*Q_weights*/ move16(); } hSpar->hFbMixer->cldfb_cross_fade_q = Q_weights; @@ -1337,8 +1338,8 @@ void ivas_spar_get_cldfb_gains_fx( return; } Word16 ivas_is_res_channel( - const Word16 ch, /* i : ch index in WYZX ordering */ - const Word16 nchan_transport /* i : number of transport channels (1-4) */ + const Word16 ch, /* i : ch index in WYZX ordering Q0*/ + const Word16 nchan_transport /* i : number of transport channels (1-4) Q0*/ ) { const Word16 rc_map[FOA_CHANNELS][FOA_CHANNELS] = { @@ -1355,7 +1356,7 @@ Word16 ivas_is_res_channel( } assert( nchan_transport <= FOA_CHANNELS ); - return ( rc_map[nchan_transport - 1][ch] ); + return ( rc_map[nchan_transport - 1][ch] ); /*Q0*/ } #else void ivas_spar_get_cldfb_gains( @@ -1596,15 +1597,15 @@ static ivas_error ivas_spar_dec_MD_fx( * Initialization *---------------------------------------------------------------------*/ - sba_order = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); - bfi = st_ivas->bfi; + sba_order = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); /*Q0*/ + bfi = st_ivas->bfi; /*Q0*/ move16(); - ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; /*Q0*/ move32(); - num_channels = ivas_sba_get_nchan_metadata_fx( sba_order, ivas_total_brate ); - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + num_channels = ivas_sba_get_nchan_metadata_fx( sba_order, ivas_total_brate ); /*Q0*/ + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); /*Q0*/ - num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; /*Q0*/ move16(); test(); @@ -1621,17 +1622,17 @@ static ivas_error ivas_spar_dec_MD_fx( } ELSE { - hSpar->hMdDec->spar_md.num_bands = s_min( SPAR_DIRAC_SPLIT_START_BAND, IVAS_MAX_NUM_BANDS ); + hSpar->hMdDec->spar_md.num_bands = s_min( SPAR_DIRAC_SPLIT_START_BAND, IVAS_MAX_NUM_BANDS ); /*Q0*/ move16(); } IF( NE_16( hSpar->hMdDec->table_idx, table_idx ) ) { - hSpar->hMdDec->table_idx = table_idx; + hSpar->hMdDec->table_idx = table_idx; /*Q0*/ move16(); if ( hSpar->hTdDecorr ) { - hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking; + hSpar->hTdDecorr->ducking_flag = ivas_spar_br_table_consts[table_idx].td_ducking; /*Q0*/ move16(); } @@ -1828,10 +1829,11 @@ static ivas_error ivas_spar_dec_MD( static Word16 ivas_spar_get_cldfb_slot_gain_fx( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const Word16 time_slot_idx, - Word16 *time_slot_idx0, - Word16 *time_slot_idx1, - Word16 *weight_lowfreq_fx ) + const Word16 time_slot_idx, /*Q0*/ + Word16 *time_slot_idx0, /*Q0*/ + Word16 *time_slot_idx1, /*Q0*/ + Word16 *weight_lowfreq_fx /*Q15*/ +) { Word16 weight_fx; Word32 encfb_delay_fx, decfb_delay_fx; @@ -1840,40 +1842,40 @@ static Word16 ivas_spar_get_cldfb_slot_gain_fx( Word16 i_hist; Word16 split_band; - *weight_lowfreq_fx = hSpar->hFbMixer->cldfb_cross_fade_fx[time_slot_idx]; + *weight_lowfreq_fx = hSpar->hFbMixer->cldfb_cross_fade_fx[time_slot_idx]; /*Q15*/ move16(); encfb_delay_fx = IVAS_FB_ENC_DELAY_NS; move32(); decfb_delay_fx = IVAS_FB_DEC_DELAY_NS; move32(); - Word32 one_by_outfs = 0; // q15 + Word32 one_by_outfs = 0; // Q15 move32(); SWITCH( hDecoderConfig->output_Fs ) { case 16000: - one_by_outfs = 2048000000; + one_by_outfs = 2048000000; /* 1000000000.0f/(output_Fs) in Q15 */ move32(); BREAK; case 32000: - one_by_outfs = 1024000000; + one_by_outfs = 1024000000; /* 1000000000.0f/(output_Fs) in Q15 */ move32(); BREAK; case 48000: - one_by_outfs = 682666688; + one_by_outfs = 682666688; /* 1000000000.0f/(output_Fs) in Q15 */ move32(); BREAK; default: assert( 0 ); } - Word64 fade_start = W_mult0_32_32( one_by_outfs, hSpar->hFbMixer->cross_fade_start_offset ); + Word64 fade_start = W_mult0_32_32( one_by_outfs, hSpar->hFbMixer->cross_fade_start_offset ); /*Q15*/ move64(); - fade_start = W_shr( fade_start, 15 ); - xfade_start_ns_fx = L_add( L_sub( W_extract_l( fade_start ), encfb_delay_fx ), L_shr( decfb_delay_fx, 1 ) ); - xfade_delay_subframes = extract_l( Mpy_32_32( xfade_start_ns_fx, 429 /* 1 / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 -> 429 */ ) ); + fade_start = W_shr( fade_start, 15 ); /*Q0*/ + xfade_start_ns_fx = L_add( L_sub( W_extract_l( fade_start ), encfb_delay_fx ), L_shr( decfb_delay_fx, 1 ) ); /*Q0*/ + xfade_delay_subframes = extract_l( Mpy_32_32( xfade_start_ns_fx, 429 /* 1 / ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 -> 429 */ ) ); /*Q0*/ - i_hist = sub( 4, xfade_delay_subframes ); + i_hist = sub( 4, xfade_delay_subframes ); /*Q0*/ split_band = SPAR_DIRAC_SPLIT_START_BAND; move16(); @@ -1890,15 +1892,15 @@ static Word16 ivas_spar_get_cldfb_slot_gain_fx( move16(); BREAK; case 1: - weight_fx = 8191; + weight_fx = 8191; /*0.25f in Q15*/ move16(); BREAK; case 2: - weight_fx = 16383; + weight_fx = 16383; /*0.5f in Q15*/ move16(); BREAK; case 3: - weight_fx = 24575; + weight_fx = 24575; /*0.75f in Q15*/ move16(); BREAK; default: @@ -1912,23 +1914,23 @@ static Word16 ivas_spar_get_cldfb_slot_gain_fx( weight_fx = 0; move16(); } - *time_slot_idx0 = i_hist; + *time_slot_idx0 = i_hist; /*Q0*/ move16(); - *time_slot_idx1 = add( i_hist, 1 ); + *time_slot_idx1 = add( i_hist, 1 ); /*Q0*/ move16(); } ELSE { /* determine cross-fade gain for current frame Parameters*/ - *time_slot_idx0 = hSpar->hFbMixer->cldfb_cross_fade_start; + *time_slot_idx0 = hSpar->hFbMixer->cldfb_cross_fade_start; /*Q0*/ move16(); - *time_slot_idx1 = hSpar->hFbMixer->cldfb_cross_fade_end; + *time_slot_idx1 = hSpar->hFbMixer->cldfb_cross_fade_end; /*Q0*/ move16(); - weight_fx = *weight_lowfreq_fx; + weight_fx = *weight_lowfreq_fx; /*Q15*/ move16(); } - return weight_fx; + return weight_fx; /*Q15*/ } #else @@ -1992,20 +1994,21 @@ static float ivas_spar_get_cldfb_slot_gain( #ifdef IVAS_FLOAT_FIXED void ivas_spar_get_parameters_fx( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const Word16 ts, - const Word16 num_ch_out, - const Word16 num_ch_in, - const Word16 num_spar_bands, - Word32 par_mat_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] ) + SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ + const Word16 ts, /*Q0*/ + const Word16 num_ch_out, /*Q0*/ + const Word16 num_ch_in, /*Q0*/ + const Word16 num_spar_bands, /*Q0*/ + Word32 par_mat_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] /*hSpar->hMdDec->Q_mixer_mat*/ +) { Word16 spar_band, out_ch, in_ch; Word16 weight_fx, weight_20ms_fx; Word16 ts0, ts1, split_band; // weight = ivas_spar_get_cldfb_slot_gain(hSpar, hDecoderConfig, ts, &ts0, &ts1, &weight_20ms); - weight_fx = ivas_spar_get_cldfb_slot_gain_fx( hSpar, hDecoderConfig, ts, &ts0, &ts1, &weight_20ms_fx ); + weight_fx = ivas_spar_get_cldfb_slot_gain_fx( hSpar, hDecoderConfig, ts, &ts0, &ts1, &weight_20ms_fx ); /*Q15*/ split_band = SPAR_DIRAC_SPLIT_START_BAND; move16(); @@ -2025,12 +2028,12 @@ void ivas_spar_get_parameters_fx( { par_mat_fx[out_ch][in_ch][spar_band] = L_add_sat( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[ts0][out_ch][in_ch][spar_band], sub( MAX_WORD16, weight_fx ) ), - Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[ts1][out_ch][in_ch][spar_band], weight_fx ) ); + Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[ts1][out_ch][in_ch][spar_band], weight_fx ) ); /*hSpar->hMdDec->Q_mixer_mat*/ move32(); } ELSE { - par_mat_fx[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band]; + par_mat_fx[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band]; /*hSpar->hMdDec->Q_mixer_mat*/ move32(); } } @@ -2042,7 +2045,7 @@ void ivas_spar_get_parameters_fx( /* 20ms Transport channel reconstruction with matching encoder/decoder processing */ Word16 prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ move16(); - par_mat_fx[out_ch][in_ch][spar_band] = L_add_sat( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[prev_idx][out_ch][in_ch][spar_band], sub( MAX_WORD16, weight_20ms_fx ) ), Mpy_32_16_1( hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band], weight_20ms_fx ) ); + par_mat_fx[out_ch][in_ch][spar_band] = L_add_sat( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[prev_idx][out_ch][in_ch][spar_band], sub( MAX_WORD16, weight_20ms_fx ) ), Mpy_32_16_1( hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band], weight_20ms_fx ) ); /*hSpar->hMdDec->Q_mixer_mat*/ move32(); } } @@ -2177,12 +2180,13 @@ static void ivas_spar_get_skip_mat( #else static void ivas_spar_get_skip_mat_fx( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - const Word16 num_ch_out, - const Word16 num_ch_in, - const Word16 num_spar_bands, - Word16 skip_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], - const Word16 num_md_sub_frames ) + SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ + const Word16 num_ch_out, /*Q0*/ + const Word16 num_ch_in, /*Q0*/ + const Word16 num_spar_bands, /*Q0*/ + Word16 skip_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /*Q0*/ + const Word16 num_md_sub_frames /*Q0*/ +) { Word16 spar_band, out_ch, in_ch; Word16 i_ts, skip_flag; @@ -2221,7 +2225,7 @@ static void ivas_spar_get_skip_mat_fx( { FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) { - IF( hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][add( spar_band, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )] != 0 ) + IF( hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][( spar_band + ( i_ts * IVAS_MAX_NUM_BANDS ) )] != 0 ) { skip_flag = 0; move16(); @@ -2247,15 +2251,15 @@ static void ivas_spar_get_skip_mat_fx( #ifdef IVAS_FLOAT_FIXED static void ivas_spar_calc_smooth_facs_fx( - Word32 *cldfb_in_ts_re_fx[CLDFB_NO_COL_MAX], // i - Word32 *cldfb_in_ts_im_fx[CLDFB_NO_COL_MAX], // i + Word32 *cldfb_in_ts_re_fx[CLDFB_NO_COL_MAX], // i q_cldfb + Word32 *cldfb_in_ts_im_fx[CLDFB_NO_COL_MAX], // i q_cldfb Word16 q_cldfb, - Word16 nbands_spar, - const Word16 nSlots, - const Word16 isFirstSubframe, + Word16 nbands_spar, /*Q0*/ + const Word16 nSlots, /*Q0*/ + const Word16 isFirstSubframe, /*Q0*/ ivas_fb_bin_to_band_data_t *bin2band, - Word16 *smooth_fac_fx, // o - Word32 smooth_buf_fx[IVAS_MAX_NUM_BANDS][2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1] ) // o + Word16 *smooth_fac_fx, // o Q15 + Word32 smooth_buf_fx[IVAS_MAX_NUM_BANDS][2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1] ) // o Q0 { Word16 b, bin, i, ts; Word32 subframe_band_nrg_fx[IVAS_MAX_NUM_BANDS]; @@ -2370,7 +2374,7 @@ static void ivas_spar_calc_smooth_facs_fx( } /* apply upper bounds depending on band */ - smooth_fac_fx[b] = s_max( min_smooth_gains1_fx[b], s_min( max_smooth_gains2_fx[b], smooth_fac_fx[b] ) ); + smooth_fac_fx[b] = s_max( min_smooth_gains1_fx[b], s_min( max_smooth_gains2_fx[b], smooth_fac_fx[b] ) ); /*Q15*/ move16(); } @@ -2382,7 +2386,7 @@ static void ivas_spar_calc_smooth_facs_fx( { FOR( i = 2 * SBA_DIRAC_NRG_SMOOTH_LONG; i > 0; i-- ) { - smooth_buf_fx[b][i] = smooth_buf_fx[b][i - 1]; + smooth_buf_fx[b][i] = smooth_buf_fx[b][i - 1]; /*Q0*/ move32(); } } @@ -2549,8 +2553,8 @@ void ivas_spar_dec_agc_pca( #else void ivas_spar_dec_agc_pca_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - Word32 *output[], /* i/o: input/output audio channels */ - const Word16 output_frame /* i : output frame length */ + Word32 *output[], /* i/o: input/output audio channels Q14*/ + const Word16 output_frame /* i : output frame length Q0*/ ) { Word16 nchan_transport; @@ -2562,7 +2566,7 @@ void ivas_spar_dec_agc_pca_fx( hSpar = st_ivas->hSpar; hDecoderConfig = st_ivas->hDecoderConfig; - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; /*Q0*/ move16(); IF( GE_16( st_ivas->nchan_transport, 3 ) ) @@ -2572,22 +2576,22 @@ void ivas_spar_dec_agc_pca_fx( /*convert WYZX downmix to WYXZ*/ FOR( i = 0; i < output_frame; i++ ) { - temp = output[2][i]; + temp = output[2][i]; /*Q14*/ move32(); - output[2][i] = output[3][i]; + output[2][i] = output[3][i]; /*Q14*/ move32(); - output[3][i] = temp; + output[3][i] = temp; /*Q14*/ move32(); } } IF( hSpar->hMdDec->td_decorr_flag ) { - num_in_ingest = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + num_in_ingest = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); /*Q0*/ } ELSE { - num_in_ingest = nchan_transport; + num_in_ingest = nchan_transport; /*Q0*/ move16(); } @@ -2647,7 +2651,7 @@ void ivas_spar_dec_set_render_map( #else void ivas_spar_dec_set_render_map_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 nCldfbTs /* i : number of CLDFB time slots */ + const Word16 nCldfbTs /* i : number of CLDFB time slots Q0*/ ) { SPAR_DEC_HANDLE hSpar; @@ -2655,7 +2659,7 @@ void ivas_spar_dec_set_render_map_fx( hSpar = st_ivas->hSpar; /* adapt subframes */ - hSpar->num_slots = nCldfbTs; + hSpar->num_slots = nCldfbTs; /*Q0*/ move16(); hSpar->slots_rendered = 0; move16(); @@ -2670,9 +2674,9 @@ void ivas_spar_dec_set_render_map_fx( test(); IF( !( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) ) { - st_ivas->hTcBuffer->nb_subframes = hSpar->nb_subframes; + st_ivas->hTcBuffer->nb_subframes = hSpar->nb_subframes; /*Q0*/ move16(); - Copy( hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hSpar->nb_subframes ); + Copy( hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hSpar->nb_subframes ); /*Q0*/ } ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, 1, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hSpar->render_to_md_map ); @@ -2710,7 +2714,7 @@ void ivas_spar_dec_set_render_params( #else void ivas_spar_dec_set_render_params_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const Word16 n_cldfb_slots /* i : number of cldfb slots in this frame */ + const Word16 n_cldfb_slots /* i : number of cldfb slots in this frame Q0*/ ) { SPAR_DEC_HANDLE hSpar; @@ -2718,9 +2722,9 @@ void ivas_spar_dec_set_render_params_fx( Word16 num_bands_out; hSpar = st_ivas->hSpar; - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; /*Q0*/ move16(); - num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; /*Q0*/ move16(); ivas_spar_dec_gen_umx_mat_fx( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); @@ -2819,9 +2823,9 @@ void ivas_spar_dec_digest_tc( #else void ivas_spar_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const Word16 nchan_transport, /* i : number of transport channels */ - const Word16 nCldfbSlots, /* i : number of CLDFB slots */ - const Word16 nSamplesForRendering /* i : number of samples provided */ + const Word16 nchan_transport, /* i : number of transport channels Q0*/ + const Word16 nCldfbSlots, /* i : number of CLDFB slots Q0*/ + const Word16 nSamplesForRendering /* i : number of samples provided Q0*/ ) { SPAR_DEC_HANDLE hSpar; @@ -2846,7 +2850,7 @@ void ivas_spar_dec_digest_tc_fx( { if ( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - ch_sba_idx = st_ivas->nchan_ism; + ch_sba_idx = st_ivas->nchan_ism; /*Q0*/ move16(); } } @@ -2854,20 +2858,20 @@ void ivas_spar_dec_digest_tc_fx( /* TD decorrelator */ Word32 quo, rem; iDiv_and_mod_32( st_ivas->hDecoderConfig->output_Fs, FRAMES_PER_SEC, &quo, &rem, 0 ); - default_frame = extract_l( quo ); - nSamplesLeftForTD = nSamplesForRendering; + default_frame = extract_l( quo ); /*Q0*/ + nSamplesLeftForTD = nSamplesForRendering; /*Q0*/ move16(); - nchan_internal = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + nchan_internal = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); /*Q0*/ FOR( ch = 0; ch < nchan_internal; ch++ ) { - pPcm_tmp[ch] = Pcm_tmp[ch]; - p_tc[ch] = st_ivas->hTcBuffer->tc_fx[add( ch, ch_sba_idx )]; + pPcm_tmp[ch] = Pcm_tmp[ch]; /*Q11*/ + p_tc[ch] = st_ivas->hTcBuffer->tc_fx[( ch + ch_sba_idx )]; /*Q11*/ } WHILE( nSamplesLeftForTD ) { - Word16 nSamplesToDecorr = s_min( nSamplesLeftForTD, default_frame ); + Word16 nSamplesToDecorr = s_min( nSamplesLeftForTD, default_frame ); /*Q0*/ IF( hSpar->hTdDecorr ) { @@ -2879,27 +2883,27 @@ void ivas_spar_dec_digest_tc_fx( { FOR( ch = 0; ch < sub( nchan_internal, nchan_transport ); ch++ ) { - Copy32( pPcm_tmp[sub( sub( hSpar->hTdDecorr->num_apd_outputs, 1 ), ch )], p_tc[sub( sub( nchan_internal, 1 ), ch )], nSamplesToDecorr ); + Copy32( pPcm_tmp[( ( hSpar->hTdDecorr->num_apd_outputs - 1 ) - ch )], p_tc[( ( nchan_internal - 1 ) - ch )], nSamplesToDecorr ); /*Q11*/ } } ELSE { FOR( ch = 0; ch < sub( nchan_internal, nchan_transport ); ch++ ) { - set32_fx( p_tc[sub( sub( nchan_internal, 1 ), ch )], 0, nSamplesToDecorr ); + set32_fx( p_tc[( ( nchan_internal - 1 ) - ch )], 0, nSamplesToDecorr ); } FOR( ch = 0; ch < hSpar->hTdDecorr->num_apd_outputs; ch++ ) { - Copy32( pPcm_tmp[sub( sub( hSpar->hTdDecorr->num_apd_outputs, 1 ), ch )], p_tc[sub( sub( nchan_internal, 1 ), ch )], nSamplesToDecorr ); + Copy32( pPcm_tmp[( ( hSpar->hTdDecorr->num_apd_outputs - 1 ) - ch )], p_tc[( ( nchan_internal - 1 ) - ch )], nSamplesToDecorr ); /*Q11*/ } } } FOR( ch = 0; ch < nchan_internal; ch++ ) { - p_tc[ch] = p_tc[ch] + nSamplesToDecorr; + p_tc[ch] = p_tc[ch] + nSamplesToDecorr; /*Q11*/ } - nSamplesLeftForTD = sub( nSamplesLeftForTD, nSamplesToDecorr ); + nSamplesLeftForTD = sub( nSamplesLeftForTD, nSamplesToDecorr ); /*Q0*/ } } @@ -3047,8 +3051,8 @@ void ivas_spar_dec_upmixer( #ifdef IVAS_FLOAT_FIXED void ivas_spar_dec_upmixer_sf_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - Word32 *output_fx[], /* o : output audio channels */ - const Word16 nchan_internal, /* i : number of internal channels */ + Word32 *output_fx[], /* o : output audio channels Q11*/ + const Word16 nchan_internal, /* i : number of internal channels Q0*/ Word16 out_len ) { Word16 cldfb_band, num_cldfb_bands, numch_in, numch_out; @@ -3072,19 +3076,19 @@ void ivas_spar_dec_upmixer_sf_fx( push_wmops( "ivas_spar_dec_upmixer_sf" ); hSpar = st_ivas->hSpar; hDecoderConfig = st_ivas->hDecoderConfig; - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; /*Q0*/ move16(); - num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands; + num_cldfb_bands = hSpar->hFbMixer->pFb->fb_bin_to_band.num_cldfb_bands; /*Q0*/ move16(); - numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; + numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; /*Q0*/ move16(); - numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; + numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; /*Q0*/ move16(); - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); /*Q0*/ + slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /*Q0*/ move16(); - slot_idx_start = hSpar->slots_rendered; + slot_idx_start = hSpar->slots_rendered; /*Q0*/ move16(); test(); @@ -3097,7 +3101,7 @@ void ivas_spar_dec_upmixer_sf_fx( FOR( i = 0; i < nchan_internal; i++ ) { - p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[add( i, nchan_ism )] + i_mult( slot_idx_start, slot_size ); + p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[( i + nchan_ism )] + i_mult( slot_idx_start, slot_size ); /*Q11*/ } test(); @@ -3106,7 +3110,7 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( i = 0; i < nchan_ism; i++ ) { - p_tc_fx[add( i, nchan_internal )] = st_ivas->hTcBuffer->tc_fx[i] + i_mult( slot_idx_start, slot_size ); + p_tc_fx[( i + nchan_internal )] = st_ivas->hTcBuffer->tc_fx[i] + i_mult( slot_idx_start, slot_size ); /*Q11*/ } } } @@ -3114,7 +3118,7 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( i = 0; i < nchan_internal; i++ ) { - p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[i] + i_mult( slot_idx_start, slot_size ); + p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[i] + i_mult( slot_idx_start, slot_size ); /*Q11*/ } } @@ -3125,12 +3129,12 @@ void ivas_spar_dec_upmixer_sf_fx( IF( hSpar->hMdDec->td_decorr_flag ) { - num_in_ingest = nchan_internal; + num_in_ingest = nchan_internal; /*Q0*/ move16(); } ELSE { - num_in_ingest = nchan_transport; + num_in_ingest = nchan_transport; /*Q0*/ move16(); } @@ -3138,7 +3142,7 @@ void ivas_spar_dec_upmixer_sf_fx( * PCA decoder *---------------------------------------------------------------------*/ - hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest; + hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest; /*Q0*/ move16(); @@ -3157,8 +3161,8 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { - cldfb_in_ts_re_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][i_mult( ts, num_cldfb_bands )]; - cldfb_in_ts_im_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][add( i_mult( ts, num_cldfb_bands ), ( 4 * num_cldfb_bands ) )]; + cldfb_in_ts_re_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][( ts * num_cldfb_bands )]; /*Q11*/ + cldfb_in_ts_im_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][( ( ts * num_cldfb_bands ) + ( 4 * num_cldfb_bands ) )]; /*Q11*/ } } } @@ -3168,8 +3172,8 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) { - cldfb_in_ts_re_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][i_mult( ts, num_cldfb_bands )]; - cldfb_in_ts_im_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][add( i_mult( ts, num_cldfb_bands ), ( 4 * num_cldfb_bands ) )]; + cldfb_in_ts_re_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][( ts * num_cldfb_bands )]; /*Q11*/ + cldfb_in_ts_im_fx[in_ch][ts] = &Pcm_tmp_fx[in_ch][( ( ts * num_cldfb_bands ) + ( 4 * num_cldfb_bands ) )]; /*Q11*/ } } } @@ -3178,7 +3182,7 @@ void ivas_spar_dec_upmixer_sf_fx( * CLDFB Processing and Synthesis *---------------------------------------------------------------------*/ - num_spar_bands = hSpar->hFbMixer->pFb->filterbank_num_bands; + num_spar_bands = hSpar->hFbMixer->pFb->filterbank_num_bands; /*Q0*/ move16(); /* apply parameters */ @@ -3196,7 +3200,7 @@ void ivas_spar_dec_upmixer_sf_fx( { Word16 q_cldfb = 11; move16(); - cldfbAnalysis_ts_fx_fixed_q( &p_tc_fx[in_ch][i_mult( ts, num_cldfb_bands )], cldfb_in_ts_re_fx[in_ch][ts], cldfb_in_ts_im_fx[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch], &q_cldfb ); + cldfbAnalysis_ts_fx_fixed_q( &p_tc_fx[in_ch][( ts * num_cldfb_bands )], cldfb_in_ts_re_fx[in_ch][ts], cldfb_in_ts_im_fx[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch], &q_cldfb ); } } @@ -3204,13 +3208,13 @@ void ivas_spar_dec_upmixer_sf_fx( test(); IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - FOR( ; in_ch < add( st_ivas->nchan_ism, numch_in ); in_ch++ ) + FOR( ; in_ch < ( st_ivas->nchan_ism + numch_in ); in_ch++ ) { FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { Word16 q_cldfb = 11; move16(); - cldfbAnalysis_ts_fx_fixed_q( &p_tc_fx[in_ch][i_mult( ts, num_cldfb_bands )], cldfb_in_ts_re_fx[in_ch][ts], cldfb_in_ts_im_fx[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch], &q_cldfb ); + cldfbAnalysis_ts_fx_fixed_q( &p_tc_fx[in_ch][( ts * num_cldfb_bands )], cldfb_in_ts_re_fx[in_ch][ts], cldfb_in_ts_im_fx[in_ch][ts], num_cldfb_bands, st_ivas->cldfbAnaDec[in_ch], &q_cldfb ); } } } @@ -3226,9 +3230,9 @@ void ivas_spar_dec_upmixer_sf_fx( } FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { - md_idx = hSpar->render_to_md_map[add( ts, slot_idx_start )]; + md_idx = hSpar->render_to_md_map[( ts + slot_idx_start )]; /*Q0*/ move16(); - Scale_sig( hSpar->hFbMixer->cldfb_cross_fade_fx, CLDFB_NO_COL_MAX, Q15 - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q ); + Scale_sig( hSpar->hFbMixer->cldfb_cross_fade_fx, CLDFB_NO_COL_MAX, Q15 - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q ); /*Q15*/ st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q15; move16(); ivas_spar_get_parameters_fx( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat_fx ); @@ -3245,7 +3249,7 @@ void ivas_spar_dec_upmixer_sf_fx( { mixer_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( mixer_mat_fx[out_ch][in_ch][spar_band], sub( 32767, hSpar->hMdDec->smooth_fac_fx[spar_band] ) ), hSpar->hMdDec->mixer_mat_prev2_fx[out_ch][in_ch][spar_band], hSpar->hMdDec->smooth_fac_fx[spar_band] ); /*q1*/ move32(); - hSpar->hMdDec->mixer_mat_prev2_fx[out_ch][in_ch][spar_band] = mixer_mat_fx[out_ch][in_ch][spar_band]; + hSpar->hMdDec->mixer_mat_prev2_fx[out_ch][in_ch][spar_band] = mixer_mat_fx[out_ch][in_ch][spar_band]; /*q1*/ move32(); } } @@ -3271,9 +3275,9 @@ void ivas_spar_dec_upmixer_sf_fx( { IF( LT_16( cldfb_band, CLDFB_PAR_WEIGHT_START_BAND ) ) /* tuning parameter, depends on how much SPAR Filters overlap for the CLDFB bands */ { - spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band]; + spar_band = bin2band->p_cldfb_map_to_spar_band[cldfb_band]; /*Q0*/ move16(); - cldfb_par_fx = mixer_mat_fx[out_ch][in_ch][spar_band]; + cldfb_par_fx = mixer_mat_fx[out_ch][in_ch][spar_band]; /*q1*/ move32(); } ELSE @@ -3283,8 +3287,8 @@ void ivas_spar_dec_upmixer_sf_fx( FOR( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ ) { /* accumulate contributions from all SPAR bands */ - Word16 tmp = extract_l( L_shr( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 7 ) ); - cldfb_par_fx = L_add_sat( cldfb_par_fx, Mpy_32_16_1( mixer_mat_fx[out_ch][in_ch][spar_band], tmp ) ); /*q1*/ + Word16 tmp = extract_l( L_shr( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 7 ) ); /*Q15*/ + cldfb_par_fx = L_add_sat( cldfb_par_fx, Mpy_32_16_1( mixer_mat_fx[out_ch][in_ch][spar_band], tmp ) ); /*q1*/ } } @@ -3307,10 +3311,10 @@ void ivas_spar_dec_upmixer_sf_fx( } test(); - IF( ( EQ_16( ( add( add( slot_idx_start, ts ), 1 ) ), hSpar->num_slots ) ) || ( NE_16( ( shr( md_idx, 2 ) /* md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME */ ), ( hSpar->render_to_md_map[add( add( slot_idx_start, ts ), 1 )] / JBM_CLDFB_SLOTS_IN_SUBFRAME /*It's value is 4*/ ) ) ) ) + IF( ( EQ_16( ( add( add( slot_idx_start, ts ), 1 ) ), hSpar->num_slots ) ) || ( NE_16( ( shr( md_idx, 2 ) /* md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME */ ), ( hSpar->render_to_md_map[( ( slot_idx_start + ts ) + 1 )] / JBM_CLDFB_SLOTS_IN_SUBFRAME /*It's value is 4*/ ) ) ) ) { /* we have crossed an unadapted parameter sf border, update previous mixing matrices */ - Word16 md_sf = shr( md_idx, 2 ) /* md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME */; + Word16 md_sf = shr( md_idx, 2 ) /* md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME */; /*Q0*/ split_band = SPAR_DIRAC_SPLIT_START_BAND; move16(); if ( NE_16( num_md_sub_frames, MAX_PARAM_SPATIAL_SUBFRAMES ) ) @@ -3320,10 +3324,10 @@ void ivas_spar_dec_upmixer_sf_fx( } IF( LT_16( split_band, IVAS_MAX_NUM_BANDS ) ) { - Copy32( hSpar->hMdDec->mixer_mat_prev_fx[1][0][0], hSpar->hMdDec->mixer_mat_prev_fx[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - Copy32( hSpar->hMdDec->mixer_mat_prev_fx[2][0][0], hSpar->hMdDec->mixer_mat_prev_fx[1][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - Copy32( hSpar->hMdDec->mixer_mat_prev_fx[3][0][0], hSpar->hMdDec->mixer_mat_prev_fx[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - Copy32( hSpar->hMdDec->mixer_mat_prev_fx[4][0][0], hSpar->hMdDec->mixer_mat_prev_fx[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); + Copy32( hSpar->hMdDec->mixer_mat_prev_fx[1][0][0], hSpar->hMdDec->mixer_mat_prev_fx[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); /*hSpar->hMdDec->Q_mixer_mat*/ + Copy32( hSpar->hMdDec->mixer_mat_prev_fx[2][0][0], hSpar->hMdDec->mixer_mat_prev_fx[1][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); /*hSpar->hMdDec->Q_mixer_mat*/ + Copy32( hSpar->hMdDec->mixer_mat_prev_fx[3][0][0], hSpar->hMdDec->mixer_mat_prev_fx[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); /*hSpar->hMdDec->Q_mixer_mat*/ + Copy32( hSpar->hMdDec->mixer_mat_prev_fx[4][0][0], hSpar->hMdDec->mixer_mat_prev_fx[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); /*hSpar->hMdDec->Q_mixer_mat*/ FOR( out_ch = 0; out_ch < numch_out; out_ch++ ) { @@ -3331,14 +3335,14 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( b = 0; b < num_spar_bands; b++ ) { - hSpar->hMdDec->mixer_mat_prev_fx[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][add( b, i_mult( md_sf, IVAS_MAX_NUM_BANDS ) )]; + hSpar->hMdDec->mixer_mat_prev_fx[4][out_ch][in_ch][b] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][( b + ( md_sf * IVAS_MAX_NUM_BANDS ) )]; /*hSpar->hMdDec->Q_mixer_mat*/ move32(); } } } - hSpar->i_subframe = add( hSpar->i_subframe, 1 ); + hSpar->i_subframe = add( hSpar->i_subframe, 1 ); /*Q0*/ move16(); - hSpar->i_subframe = s_min( hSpar->i_subframe, MAX_PARAM_SPATIAL_SUBFRAMES ); + hSpar->i_subframe = s_min( hSpar->i_subframe, MAX_PARAM_SPATIAL_SUBFRAMES ); /*Q0*/ move16(); } } @@ -3359,7 +3363,7 @@ void ivas_spar_dec_upmixer_sf_fx( idx_lfe = 0; move16(); - outchannels = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); + outchannels = add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ); /*Q0*/ FOR( ch = 0; ch < outchannels; ch++ ) { @@ -3383,16 +3387,16 @@ void ivas_spar_dec_upmixer_sf_fx( IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || !( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) && !( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { - Scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, -6 ); + Scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, -6 ); /*st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state-6*/ st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = sub( st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, 6 ); move16(); - Scale_sig32( output_fx[ch], out_len, -6 ); + Scale_sig32( output_fx[ch], out_len, -6 ); /*Q5*/ FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, st_ivas->cldfbSynDec[idx_in] ); } - Scale_sig32( output_fx[ch], out_len, 6 ); - Scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, 6 ); + Scale_sig32( output_fx[ch], out_len, 6 ); /*Q11*/ + Scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, 6 ); /*st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state+6*/ st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = add( st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state, 6 ); move16(); } @@ -3406,24 +3410,24 @@ void ivas_spar_dec_upmixer_sf_fx( /* CLDFB to time synthesis (overwrite mixer output) */ FOR( out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { - Scale_sig32( st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx, st_ivas->cldfbSynDec[out_ch]->p_filter_length, -6 ); + Scale_sig32( st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx, st_ivas->cldfbSynDec[out_ch]->p_filter_length, -6 ); /*st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state-6*/ st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state = sub( st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state, 6 ); move16(); - Scale_sig32( output_fx[out_ch], out_len, -6 ); + Scale_sig32( output_fx[out_ch], out_len, -6 ); /*Q5*/ FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, st_ivas->cldfbSynDec[out_ch] ); } - Scale_sig32( output_fx[out_ch], out_len, 6 ); - Scale_sig32( st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx, st_ivas->cldfbSynDec[out_ch]->p_filter_length, 6 ); + Scale_sig32( output_fx[out_ch], out_len, 6 ); /*Q11*/ + Scale_sig32( st_ivas->cldfbSynDec[out_ch]->cldfb_state_fx, st_ivas->cldfbSynDec[out_ch]->p_filter_length, 6 ); /*st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state+6*/ st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state = add( st_ivas->cldfbSynDec[out_ch]->Q_cldfb_state, 6 ); move16(); } } - hSpar->slots_rendered = add( hSpar->slots_rendered, hSpar->subframe_nbslots[hSpar->subframes_rendered] ); + hSpar->slots_rendered = add( hSpar->slots_rendered, hSpar->subframe_nbslots[hSpar->subframes_rendered] ); /*Q0*/ move16(); - hSpar->subframes_rendered = add( hSpar->subframes_rendered, 1 ); + hSpar->subframes_rendered = add( hSpar->subframes_rendered, 1 ); /*Q0*/ move16(); pop_wmops(); diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index 32c52ba3b29b3e04d2e6b2385acabd14b7c7e453..44d6abe4ba1c9eea19e2651b904d9769824e6924 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -240,7 +240,7 @@ ivas_error JB4_Create( move32(); /* internal configuration values - do not change!!! */ h->timeScale = 0; - move32(); + move16(); h->frameDuration = 0; move32(); @@ -789,7 +789,7 @@ static Word16 JB4_adaptPlayout( *maxScaling = 0; move32(); stretchTime = false; - + move16(); /* switch type of current playout (first one, active, DTX) */ IF( !h->firstDataUnitPopped ) { diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index efa0e0d4c06c5213554cb068d28dd8850da8e43b..262d8d42450121b684c6518631aad5ca1e5c35a7 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -98,7 +98,12 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * /* Configure ACELP */ + +#ifndef MSAN_FIX hLPDmem->nbits = BITS_ALLOC_config_acelp( target_bits, st->coder_type, acelp_cfg, st->narrowBand, st->nb_subfr ); +#else + BITS_ALLOC_config_acelp( target_bits, st->coder_type, acelp_cfg, st->narrowBand, st->nb_subfr ); +#endif /* Init Framing parameters */ move16(); diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index e449b2420f5dbaef56632161f91ecc9af430191e..86be7be4ec749b98b8959d677bc4c6542a3cf76b 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -4394,7 +4394,9 @@ void coder_tcx_fx( Word16 winMDST[N_MAX + L_MDCT_OVLP_MAX]; Word16 *pWinMDST; Word16 left_overlap_mode, right_overlap_mode; +#ifndef MSAN_FIX LPD_state_HANDLE hLPDmem = st->hLPDmem; +#endif TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; left_overlap = right_overlap = -1; @@ -4560,7 +4562,9 @@ void coder_tcx_fx( st, hm_cfg ); +#ifndef MSAN_FIX hLPDmem->nbits = add( hLPDmem->nbits, add( tnsBits, ltpBits ) ); +#endif } diff --git a/lib_enc/core_enc_init.c b/lib_enc/core_enc_init.c index 8c01fae3ba09d4fa482e53cc958000473d655948..fc2bef83c9ef14538877ac9b9dcb0713fdf86174 100644 --- a/lib_enc/core_enc_init.c +++ b/lib_enc/core_enc_init.c @@ -722,12 +722,19 @@ static void init_tcx( hTcxEnc->spectrum[0] = hTcxEnc->spectrum_long; hTcxEnc->spectrum[1] = hTcxEnc->spectrum_long + N_TCX10_MAX; + #ifdef IVAS_FLOAT_FIXED hTcxEnc->spectrum_fx[0] = hTcxEnc->spectrum_long_fx; hTcxEnc->spectrum_fx[1] = hTcxEnc->spectrum_long_fx + N_TCX10_MAX; st->preemph_fac_flt = fix16_to_float( st->preemph_fac, Q15 ); #endif +#ifdef MSAN_FIX + set_zero( hTcxEnc->spectrum[0], N_TCX10_MAX ); + set_zero( hTcxEnc->spectrum[1], N_TCX10_MAX ); + set_zero_fx( hTcxEnc->spectrum_fx[0], N_TCX10_MAX ); + set_zero_fx( hTcxEnc->spectrum_fx[1], N_TCX10_MAX ); +#endif init_tcx_cfg( st->hTcxCfg, total_brate, st->sr_core, st->input_Fs, st->L_frame, st->bwidth, hTcxEnc->L_frameTCX, st->fscale, st->encoderLookahead_enc, st->encoderLookahead_FB, st->preemph_fac_flt, st->tcxonly, st->rf_mode, st->igf, diff --git a/lib_enc/ext_sig_ana.c b/lib_enc/ext_sig_ana.c index 2d1a7c3d6d7fe4502440f3e7d981a3576f3a070f..33c3201b0aff379e049862561df6aaf387dc51da 100644 --- a/lib_enc/ext_sig_ana.c +++ b/lib_enc/ext_sig_ana.c @@ -133,7 +133,6 @@ void core_signal_analysis_high_bitrate( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS if ( st->element_mode == IVAS_CPE_DFT ) { - floatToFixed_arr( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange_flt, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange, Q7, NSUBBLOCKS + MAX_TD_DELAY ); hTcxEnc->tcxltp_norm_corr_past = float_to_fix16( hTcxEnc->tcxltp_norm_corr_past_flt, Q15 ); q_fac = Q_factor_arr( st->buf_wspeech_enc_flt, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); floatToFixed_arr( st->buf_wspeech_enc_flt, buf_wspeech_enc_fx, q_fac, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); @@ -149,7 +148,6 @@ void core_signal_analysis_high_bitrate( } else if ( st->element_mode != IVAS_CPE_MDCT ) { - floatToFixed_arr( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange_flt, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange, Q7, NSUBBLOCKS + MAX_TD_DELAY ); hTcxEnc->tcxltp_norm_corr_past = float_to_fix16( hTcxEnc->tcxltp_norm_corr_past_flt, Q15 ); q_fac = Q_factor_arr( st->buf_speech_enc_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); floatToFixed_arr( st->buf_speech_enc_flt, buf_speech_enc_fx, q_fac, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); @@ -479,12 +477,6 @@ void core_signal_analysis_high_bitrate( // -1 = -32768 , Q=15 , ltp_gain // spectrum_fx[]=fixed( (float)spectrum[]) , Q=q_factor_spectrum floatToFixed_arrL( hTcxEnc->spectrum_long, hTcxEnc->spectrum_long_fx, q_factor_spectrum, N_MAX ); - - // subblockNrg=(fix)((float)subblockNrg_flt) - floatToFixed_arrL( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrg_flt, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrg, 7, 24 ); - - // subblockNrgChange=(fix)((float)subblockNrgChange_flt) - floatToFixed_arr( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange_flt, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange, 7, 24 ); #endif test(); TNSAnalysis_ivas_fx( st->hTcxCfg, L_frameTCX, st->hTcxCfg->tcx_coded_lines, transform_type[frameno], ( frameno == 0 ) && ( st->last_core == ACELP_CORE ), hTcxEnc->spectrum_fx[frameno], st->hTranDet, -32768, &hTcxEnc->tnsData[frameno], &hTcxEnc->fUseTns[frameno], NULL ); @@ -493,12 +485,6 @@ void core_signal_analysis_high_bitrate( { // conv params to float // spectrum[]=float( (fix)spectrum_fx[]) , Q=q_factor_spectrum fixedToFloat_arrL( hTcxEnc->spectrum_long_fx, hTcxEnc->spectrum_long, q_factor_spectrum, N_MAX ); - - // subblockNrg_flt=(float)((fixed)subblockNrg) - fixedToFloat_arrL( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrg, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrg_flt, 7, 24 ); - - // subblockNrgChange_flt=(float)((fixed)subblockNrgChange) - fixedToFloat_arr( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange_flt, 7, 24 ); } #endif #endif diff --git a/lib_enc/init_enc.c b/lib_enc/init_enc.c index 5c23fee656b6aa5ef6ab41054bd7b2400e2fee2e..cb326efb278d52bc1085446479edd50066fe9d12 100644 --- a/lib_enc/init_enc.c +++ b/lib_enc/init_enc.c @@ -890,6 +890,7 @@ ivas_error init_encoder( } #ifdef MSAN_FIX set_f( st->hTcxEnc->spectrum_long, 0, N_MAX ); + set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX ); #endif // MSAN_FIX /* Share the memories for 2xTCX10/4xTCX5 and for TCX20 */ @@ -1057,6 +1058,16 @@ ivas_error init_encoder( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); } +#ifdef IVAS_FLOAT_FIXED + IF( GT_16( st->element_mode, EVS_MONO ) ) + { + InitTransientDetection_ivas_fx( shl( div_l( st->input_Fs, FRAMES_PER_SEC ), 1 ), 0, st->hTranDet, 1 ); + } + ELSE + { + InitTransientDetection_ivas_fx( shl( div_l( st->input_Fs, FRAMES_PER_SEC ), 1 ), NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); + } +#else if ( st->element_mode > EVS_MONO ) { @@ -1066,6 +1077,7 @@ ivas_error init_encoder( { InitTransientDetection( (int16_t) ( st->input_Fs / FRAMES_PER_SEC ), NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); } +#endif /*-----------------------------------------------------------------* * IVAS parameters @@ -2329,16 +2341,16 @@ ivas_error init_encoder_ivas_fx( Word16 frame_length = BASOP_Util_Divide3232_Scale( st->input_Fs, FRAMES_PER_SEC, &temp ); frame_length = shr( frame_length, sub( 15, temp ) ); +#ifdef IVAS_FLOAT_FIXED IF( GT_16( st->element_mode, EVS_MONO ) ) { InitTransientDetection_ivas_fx( frame_length, 0, st->hTranDet, 1 ); } ELSE { - InitTransientDetection_ivas_fx( frame_length, NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); + InitTransientDetection_ivas_fx( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); } - -#if 1 +#else if ( GT_16( st->element_mode, EVS_MONO ) ) { InitTransientDetection( frame_length, 0, st->hTranDet, 1 ); diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index 75f550d91b28e54839a87cba43bd032bbcaa4a56..6effecd944ddd47af21ce0770e743f4dba86d1ba 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -237,11 +237,6 @@ ivas_error ivas_core_enc( st->hTcxEnc->tcxltp_norm_corr_past = (Word16) floatToFixed( st->hTcxEnc->tcxltp_norm_corr_past_flt, Q15 ); } - IF( st->hTranDet ) - { - floatToFixed_arr( st->hTranDet->subblockEnergies.subblockNrgChange_flt, st->hTranDet->subblockEnergies.subblockNrgChange, Q15 - NRG_CHANGE_E, NSUBBLOCKS + MAX_TD_DELAY ); - } - f2me( cor_map_sum[n], &cor_map_sum_fx, &exp_cor_map_sum ); q_fft_buff = Q_factor_arrL( fft_buff[n], ( 2 * L_FFT ) ); @@ -322,11 +317,6 @@ ivas_error ivas_core_enc( st->hTcxEnc->tfm_mem = fixedToFloat_32( st->hTcxEnc->tfm_mem_fx, Q31 ); st->hTcxEnc->tcxltp_norm_corr_past_flt = fixedToFloat_16( st->hTcxEnc->tcxltp_norm_corr_past, Q15 ); } - - IF( st->hTranDet ) - { - fixedToFloat_arr( st->hTranDet->subblockEnergies.subblockNrgChange, st->hTranDet->subblockEnergies.subblockNrgChange_flt, Q15 - NRG_CHANGE_E, NSUBBLOCKS + MAX_TD_DELAY ); - } #endif if ( st->element_mode == IVAS_CPE_MDCT || st->element_mode == IVAS_SCE ) diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index f7659715c5075cb100ff2a0818fa196a9afad38c..917c185cdcc2b9e879dfa23806528da9e01d00af 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -2922,30 +2922,29 @@ ivas_error pre_proc_front_ivas_fx( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS IF( EQ_16( element_mode, IVAS_SCE ) ) { - Word16 q1 = Q_factor_arr( st->hTranDet->subblockEnergies.subblockNrg_flt, NSUBBLOCKS + MAX_TD_DELAY ); - Word16 q2 = Q_factor_arr( st->hTranDet->subblockEnergies.accSubblockNrg_flt, NSUBBLOCKS + MAX_TD_DELAY + 1 ); - - st->hTranDet->transientDetector.pSubblockEnergies->facAccSubblockNrg = float_to_fix16( st->hTranDet->transientDetector.pSubblockEnergies->facAccSubblockNrg_flt, Q15 ); - floatToFixed_arrL( st->hTranDet->subblockEnergies.subblockNrg_flt, st->hTranDet->subblockEnergies.subblockNrg, q1, NSUBBLOCKS + MAX_TD_DELAY ); - floatToFixed_arrL( st->hTranDet->subblockEnergies.accSubblockNrg_flt, st->hTranDet->subblockEnergies.accSubblockNrg, q2, NSUBBLOCKS + MAX_TD_DELAY + 1 ); - st->hTranDet->subblockEnergies.subblockNrg_e = 31 - q1; - st->hTranDet->subblockEnergies.accSubblockNrg_e = 31 - q2; + Word16 q1 = Q7; + Word16 q2 = Q7; + st->hTranDet->subblockEnergies.subblockNrg_e = sub( 31, q1 ); + st->hTranDet->subblockEnergies.accSubblockNrg_e = sub( 31, q2 ); + move16(); + move16(); + move16(); + move16(); } ELSE IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) { FOR( i = 0; i < CPE_CHANNELS; i++ ) { - Word16 q1 = Q_factor_arr( hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.subblockNrg_flt, NSUBBLOCKS + MAX_TD_DELAY ); - Word16 q2 = Q_factor_arr( hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.accSubblockNrg_flt, NSUBBLOCKS + MAX_TD_DELAY + 1 ); - - hCPE->hCoreCoder[i]->hTranDet->transientDetector.pSubblockEnergies->facAccSubblockNrg = float_to_fix16( hCPE->hCoreCoder[i]->hTranDet->transientDetector.pSubblockEnergies->facAccSubblockNrg_flt, Q15 ); - floatToFixed_arrL( hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.subblockNrg_flt, hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.subblockNrg, q1, NSUBBLOCKS + MAX_TD_DELAY ); - floatToFixed_arrL( hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.accSubblockNrg_flt, hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.accSubblockNrg, q2, NSUBBLOCKS + MAX_TD_DELAY + 1 ); - hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.subblockNrg_e = 31 - q1; - hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.accSubblockNrg_e = 31 - q2; + Word16 q1 = Q7; + Word16 q2 = Q7; + hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.subblockNrg_e = sub( 31, q1 ); + hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.accSubblockNrg_e = sub( 31, q2 ); + move16(); + move16(); + move16(); + move16(); } } - #endif IF( EQ_16( element_mode, IVAS_SCE ) ) { @@ -2967,24 +2966,6 @@ ivas_error pre_proc_front_ivas_fx( } } } - -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - IF( EQ_16( element_mode, IVAS_SCE ) ) - { - fixedToFloat_arrL( st->hTranDet->subblockEnergies.subblockNrg, st->hTranDet->subblockEnergies.subblockNrg_flt, ( 31 - st->hTranDet->subblockEnergies.subblockNrg_e ), NSUBBLOCKS + MAX_TD_DELAY ); - fixedToFloat_arrL( st->hTranDet->subblockEnergies.accSubblockNrg, st->hTranDet->subblockEnergies.accSubblockNrg_flt, ( 31 - st->hTranDet->subblockEnergies.accSubblockNrg_e ), NSUBBLOCKS + MAX_TD_DELAY + 1 ); - st->hTranDet->transientDetector.pSubblockEnergies->facAccSubblockNrg_flt = fix16_to_float( st->hTranDet->transientDetector.pSubblockEnergies->facAccSubblockNrg, Q15 ); - } - ELSE IF( EQ_16( element_mode, IVAS_CPE_DFT ) ) - { - FOR( i = 0; i < CPE_CHANNELS; i++ ) - { - fixedToFloat_arrL( hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.subblockNrg, hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.subblockNrg_flt, ( 31 - hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.subblockNrg_e ), NSUBBLOCKS + MAX_TD_DELAY ); - fixedToFloat_arrL( hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.accSubblockNrg, hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.accSubblockNrg_flt, ( 31 - hCPE->hCoreCoder[i]->hTranDet->subblockEnergies.accSubblockNrg_e ), NSUBBLOCKS + MAX_TD_DELAY + 1 ); - hCPE->hCoreCoder[i]->hTranDet->transientDetector.pSubblockEnergies->facAccSubblockNrg_flt = fix16_to_float( hCPE->hCoreCoder[i]->hTranDet->transientDetector.pSubblockEnergies->facAccSubblockNrg, Q15 ); - } - } -#endif #else if ( element_mode == IVAS_SCE ) { diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 8ba98f4fda362c670fa243d8e15a9e4463bf4c7c..62fb9ae7052e2897e6277541325f54957ea93ecd 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -471,57 +471,13 @@ ivas_error ivas_cpe_enc( { #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - sts[n]->hTranDet->subblockEnergies.firState1 = (Word16) floatToFixed( sts[n]->hTranDet->subblockEnergies.firState1_flt, -1 ); - sts[n]->hTranDet->subblockEnergies.firState2 = (Word16) floatToFixed( sts[n]->hTranDet->subblockEnergies.firState2_flt, -1 ); - - FOR( Word16 i = 0; i < NSUBBLOCKS + MAX_TD_DELAY + 1; i++ ) - { - sts[n]->hTranDet->subblockEnergies.accSubblockNrg[i] = floatToFixed( sts[n]->hTranDet->subblockEnergies.accSubblockNrg_flt[i], 7 ); - } - - FOR( Word16 i = 0; i < NSUBBLOCKS + MAX_TD_DELAY; i++ ) - { - sts[n]->hTranDet->subblockEnergies.subblockNrg[i] = floatToFixed( sts[n]->hTranDet->subblockEnergies.subblockNrg_flt[i], 7 ); - sts[n]->hTranDet->subblockEnergies.subblockNrgChange[i] = (Word16) floatToFixed( sts[n]->hTranDet->subblockEnergies.subblockNrgChange_flt[i], 7 ); - } - - - FOR( Word16 i = 0; i < L_FRAME_MAX / NSUBBLOCKS; i++ ) - { - sts[n]->hTranDet->delayBuffer.buffer[i] = (Word16) floatToFixed( sts[n]->hTranDet->delayBuffer.buffer_flt[i], -1 ); - } - - sts[n]->hTranDet->transientDetector.attackRatioThreshold = (Word16) floatToFixed( sts[n]->hTranDet->transientDetector.attackRatioThreshold_flt, 11 ); - floatToFixed_arr16( sts[n]->input, sts[n]->input_fx, -1, input_frame ); - - sts[n]->hTranDet->subblockEnergies.facAccSubblockNrg = float_to_fix16( sts[n]->hTranDet->subblockEnergies.facAccSubblockNrg_flt, 15 ); - #endif - RunTransientDetection_ivas_fx( sts[n]->input_fx, input_frame, sts[n]->hTranDet ); - -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - - sts[n]->hTranDet->subblockEnergies.firState1_flt = fixedToFloat( (Word32) sts[n]->hTranDet->subblockEnergies.firState1, -1 ); - sts[n]->hTranDet->subblockEnergies.firState2_flt = fixedToFloat( (Word32) sts[n]->hTranDet->subblockEnergies.firState2, -1 ); - - FOR( Word16 i = 0; i < NSUBBLOCKS + MAX_TD_DELAY; i++ ) - { - sts[n]->hTranDet->subblockEnergies.subblockNrg_flt[i] = fixedToFloat( sts[n]->hTranDet->subblockEnergies.subblockNrg[i], 7 ); - sts[n]->hTranDet->subblockEnergies.subblockNrgChange_flt[i] = fixedToFloat( (Word32) sts[n]->hTranDet->subblockEnergies.subblockNrgChange[i], 7 ); - } - - FOR( Word16 i = 0; i < NSUBBLOCKS + MAX_TD_DELAY + 1; i++ ) - { - sts[n]->hTranDet->subblockEnergies.accSubblockNrg_flt[i] = fixedToFloat( sts[n]->hTranDet->subblockEnergies.accSubblockNrg[i], 7 ); - } - - FOR( Word16 i = 0; i < L_FRAME_MAX / NSUBBLOCKS; i++ ) - { - sts[n]->hTranDet->delayBuffer.buffer_flt[i] = fixedToFloat( (Word32) sts[n]->hTranDet->delayBuffer.buffer[i], -1 ); - } -#endif + sts[n]->hTranDet->subblockEnergies.subblockNrg_e = 31 - Q7; + sts[n]->hTranDet->subblockEnergies.accSubblockNrg_e = 31 - Q7; + move16(); + move16(); #else RunTransientDetection( sts[n]->input, input_frame, sts[n]->hTranDet ); #endif @@ -529,9 +485,6 @@ ivas_error ivas_cpe_enc( #ifndef IVAS_FLOAT_FIXED currFlatness[n] = GetTCXAvgTemporalFlatnessMeasure( sts[n]->hTranDet, NSUBBLOCKS, 0 ); #else -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - floatToFixed_arr( sts[n]->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange_flt, sts[n]->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange, 7, NSUBBLOCKS + MAX_TD_DELAY ); -#endif currFlatness_fx[n] = GetTCXAvgTemporalFlatnessMeasure_ivas_fx( sts[n]->hTranDet, NSUBBLOCKS, 0 ); move16(); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 1738910de7056978e46077276f04e4d1f0303543..7891a753ba88a66aaa0e04121ab00c2beed8fa21 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -498,7 +498,7 @@ ivas_error ivas_dirac_enc( int16_t orig_dirac_bands; float dir[3], avg_dir[3]; #ifdef IVAS_FLOAT_FIXED - Word32 dir_fx[3] /*, avg_dir_fx[3]*/; + Word32 dir_fx[3], avg_dir_fx[3]; #endif float energySum, vecLen; int16_t i, j, b, i_ts; @@ -601,7 +601,7 @@ ivas_error ivas_dirac_enc( energySum += hDirAC->buffer_energy[i * orig_dirac_bands + j]; } -#ifdef IVAS_FLOAT_FIXED_ +#ifdef IVAS_FLOAT_FIXED /*==========================================flt-2-fix======================================================*/ Word16 q_dir_e = 0; f2me_buf( avg_dir, avg_dir_fx, &q_dir_e, 3 ); diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 281bd0ff5f375d7b6f9a5a814e3585a7436309c2..978bb371fca64fc92fb19dd3626f7d9739e684e9 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -803,8 +803,6 @@ ivas_error ivas_enc( } for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) { - st_ivas->hIsmMetaData[i]->azimuth_fx = floatToFixed( st_ivas->hIsmMetaData[i]->azimuth, Q22 ); - st_ivas->hIsmMetaData[i]->elevation_fx = floatToFixed( st_ivas->hIsmMetaData[i]->elevation, Q22 ); 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 ); } @@ -824,7 +822,6 @@ ivas_error ivas_enc( } for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) { - st_ivas->hIsmMetaData[i]->azimuth_fx = floatToFixed( st_ivas->hIsmMetaData[i]->azimuth, Q22 ); 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 ); } @@ -870,31 +867,11 @@ ivas_error ivas_enc( #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - MASA_METADATA_HANDLE current_meta = &( st_ivas->hMasa->masaMetadata ); - MASA_METADATA_HANDLE previous_meta = &( st_ivas->hMasa->data.sync_state.previous_metadata ); - fixedToFloat_arrL( st_ivas->hMasa->data.importanceWeight_fx, st_ivas->hMasa->data.importanceWeight, 30, 24 ); for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( current_meta->directional_meta[k].azimuth[i][j], Q22 ); - current_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( current_meta->directional_meta[k].elevation[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( current_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( current_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - previous_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].azimuth[i][j], Q22 ); - previous_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].elevation[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - } f2me( st_ivas->hMasa->data.energy[i][j], &st_ivas->hMasa->data.energy_fx[i][j], &st_ivas->hMasa->data.energy_e[i][j] ); - current_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( current_meta->common_meta.surround_coherence[i][j], Q15 ) ); - current_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( current_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( current_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->common_meta.surround_coherence[i][j], Q15 ) ); - previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); } } @@ -904,29 +881,6 @@ ivas_error ivas_enc( return error; } #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( current_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - current_meta->directional_meta[k].elevation[i][j] = fixedToFloat( current_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( current_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( current_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - previous_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( previous_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - previous_meta->directional_meta[k].elevation[i][j] = fixedToFloat( previous_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( previous_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( previous_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - } - current_meta->common_meta.surround_coherence[i][j] = fixedToFloat( current_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - current_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.surround_coherence[i][j] = fixedToFloat( previous_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - previous_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - } - } if ( st_ivas->hQMetaData->q_direction ) { for ( int band = 0; band < st_ivas->hMasa->config.numCodingBands; band++ ) @@ -942,7 +896,6 @@ ivas_error ivas_enc( } } } - fixedToFloat_arrL( st_ivas->hMasa->data.importanceWeight_fx, st_ivas->hMasa->data.importanceWeight, 30, 24 ); #endif // IVAS_FLOAT_FIXED_CONVERSIONS #else if ( ( error = ivas_masa_enc_config( st_ivas ) ) != IVAS_ERR_OK ) @@ -1016,31 +969,11 @@ ivas_error ivas_enc( #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - MASA_METADATA_HANDLE current_meta = &( st_ivas->hMasa->masaMetadata ); - MASA_METADATA_HANDLE previous_meta = &( st_ivas->hMasa->data.sync_state.previous_metadata ); - fixedToFloat_arrL( st_ivas->hMasa->data.importanceWeight_fx, st_ivas->hMasa->data.importanceWeight, 30, 24 ); for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( current_meta->directional_meta[k].azimuth[i][j], Q22 ); - current_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( current_meta->directional_meta[k].elevation[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( current_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( current_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - previous_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].azimuth[i][j], Q22 ); - previous_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].elevation[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - } f2me( st_ivas->hMasa->data.energy[i][j], &st_ivas->hMasa->data.energy_fx[i][j], &st_ivas->hMasa->data.energy_e[i][j] ); - current_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( current_meta->common_meta.surround_coherence[i][j], Q15 ) ); - current_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( current_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( current_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->common_meta.surround_coherence[i][j], Q15 ) ); - previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); } } #endif // IVAS_FLOAT_FIXED_CONVERSIONS @@ -1049,29 +982,6 @@ ivas_error ivas_enc( return error; } #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( current_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - current_meta->directional_meta[k].elevation[i][j] = fixedToFloat( current_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( current_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( current_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - previous_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( previous_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - previous_meta->directional_meta[k].elevation[i][j] = fixedToFloat( previous_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( previous_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( previous_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - } - current_meta->common_meta.surround_coherence[i][j] = fixedToFloat( current_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - current_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.surround_coherence[i][j] = fixedToFloat( previous_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - previous_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - } - } if ( st_ivas->hQMetaData->q_direction ) { for ( int band = 0; band < st_ivas->hMasa->config.numCodingBands; band++ ) @@ -1087,7 +997,6 @@ ivas_error ivas_enc( } } } - fixedToFloat_arrL( st_ivas->hMasa->data.importanceWeight_fx, st_ivas->hMasa->data.importanceWeight, 30, 24 ); #endif // IVAS_FLOAT_FIXED_CONVERSIONS #else if ( ( error = ivas_omasa_enc_config( st_ivas ) ) != IVAS_ERR_OK ) @@ -1112,19 +1021,6 @@ ivas_error ivas_enc( int16_t j; int16_t nchan_transport = st_ivas->nchan_transport; int16_t nchan_ism = hEncoderConfig->nchan_ism; - Word16 block_m_idx, band_m_idx; - for ( block_m_idx = 0; block_m_idx < hOMasa->nSubframes; block_m_idx++ ) - { - for ( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ ) - { - hMasa->data.hOmasaData->energy_ism_fx[block_m_idx][band_m_idx] = floatToFixed( hMasa->data.hOmasaData->energy_ism[block_m_idx][band_m_idx], 31 - hMasa->data.hOmasaData->energy_ism_fx_e[block_m_idx][band_m_idx] ); - } - } - for ( i = 0; i < nchan_ism; i++ ) - { - st_ivas->hIsmMetaData[i]->azimuth_fx = float_to_fix( st_ivas->hIsmMetaData[i]->azimuth, Q22 ); - st_ivas->hIsmMetaData[i]->elevation_fx = float_to_fix( st_ivas->hIsmMetaData[i]->elevation, Q22 ); - } int16_t norm_data_in = MAX16B; for ( j = 0; j < nchan_ism + nchan_transport; j++ ) { @@ -1144,76 +1040,31 @@ ivas_error ivas_enc( { floatToFixed_arrL( hOMasa->cldfbAnaEnc[i]->cldfb_state, hOMasa->cldfbAnaEnc[i]->cldfb_state_fx, st_ivas->q_data_fx, hOMasa->cldfbAnaEnc[i]->cldfb_state_length ); } - // int16_t numSf = hMasa->config.joinedSubframes == TRUE ? 1 : 4; for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { for ( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) { f2me( hMasa->data.energy[i][j], &hMasa->data.energy_fx[i][j], &hMasa->data.energy_e[i][j] ); - for ( int k = 0; k < hMasa->config.numberOfDirections; k++ ) - { - hMasa->masaMetadata.directional_meta[k].energy_ratio_fx[i][j] = float_to_fix( hMasa->masaMetadata.directional_meta[k].energy_ratio[i][j], 30 ); - hMasa->masaMetadata.directional_meta[k].azimuth_fx[i][j] = float_to_fix( hMasa->masaMetadata.directional_meta[k].azimuth[i][j], 22 ); - hMasa->masaMetadata.directional_meta[k].elevation_fx[i][j] = float_to_fix( hMasa->masaMetadata.directional_meta[k].elevation[i][j], 22 ); - hMasa->masaMetadata.directional_meta[k].spread_coherence_fx[i][j] = float_to_fix16( hMasa->masaMetadata.directional_meta[k].spread_coherence[i][j], 15 ); - } - hMasa->masaMetadata.common_meta.surround_coherence_fx[i][j] = float_to_fix16( hMasa->masaMetadata.common_meta.surround_coherence[i][j], 15 ); - hMasa->masaMetadata.common_meta.diffuse_to_total_ratio_fx[i][j] = float_to_fix( hMasa->masaMetadata.common_meta.diffuse_to_total_ratio[i][j], 30 ); } } - for ( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) - { - hMasa->data.importanceWeight_fx[i] = floatToFixed( hMasa->data.importanceWeight[i], Q30 ); - } #endif ivas_omasa_enc_fx( st_ivas->hOMasa, st_ivas->hMasa, st_ivas->hIsmMetaData, data_fx, st_ivas->q_data_fx, input_frame, st_ivas->nchan_transport, hEncoderConfig->nchan_ism, st_ivas->ism_mode, data_separated_object_fx, &idx_separated_object ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( block_m_idx = 0; block_m_idx < hOMasa->nSubframes; block_m_idx++ ) - { - for ( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ ) - { - hMasa->data.hOmasaData->energy_ism[block_m_idx][band_m_idx] = me2f( hMasa->data.hOmasaData->energy_ism_fx[block_m_idx][band_m_idx], hMasa->data.hOmasaData->energy_ism_fx_e[block_m_idx][band_m_idx] ); - } - } for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { for ( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) { hMasa->data.energy[i][j] = me2f( hMasa->data.energy_fx[i][j], hMasa->data.energy_e[i][j] ); - for ( int k = 0; k < hMasa->config.numberOfDirections; k++ ) - { - hMasa->masaMetadata.directional_meta[k].energy_ratio[i][j] = fix_to_float( hMasa->masaMetadata.directional_meta[k].energy_ratio_fx[i][j], 30 ); - hMasa->masaMetadata.directional_meta[k].azimuth[i][j] = fix_to_float( hMasa->masaMetadata.directional_meta[k].azimuth_fx[i][j], 22 ); - hMasa->masaMetadata.directional_meta[k].elevation[i][j] = fix_to_float( hMasa->masaMetadata.directional_meta[k].elevation_fx[i][j], 22 ); - hMasa->masaMetadata.directional_meta[k].spread_coherence[i][j] = fix_to_float( hMasa->masaMetadata.directional_meta[k].spread_coherence_fx[i][j], 15 ); - } - hMasa->masaMetadata.common_meta.surround_coherence[i][j] = fix_to_float( hMasa->masaMetadata.common_meta.surround_coherence_fx[i][j], 15 ); - hMasa->masaMetadata.common_meta.diffuse_to_total_ratio[i][j] = fix_to_float( hMasa->masaMetadata.common_meta.diffuse_to_total_ratio_fx[i][j], 30 ); } } for ( i = 0; i < nchan_ism; i++ ) { fixedToFloat_arrL( hOMasa->cldfbAnaEnc[i]->cldfb_state_fx, hOMasa->cldfbAnaEnc[i]->cldfb_state, st_ivas->q_data_fx, hOMasa->cldfbAnaEnc[i]->cldfb_state_length ); } - for ( block_m_idx = 0; block_m_idx < hOMasa->nSubframes; block_m_idx++ ) - { - for ( i = 0; i < hOMasa->nbands; i++ ) - { - for ( int k = 0; k < nchan_ism; k++ ) - { - hMasa->data.hOmasaData->energy_ratio_ism[block_m_idx][i][k] = me2f( hMasa->data.hOmasaData->energy_ratio_ism_fx[block_m_idx][i][k], 1 ); - } - } - } for ( i = 0; i < nchan_ism + nchan_transport; i++ ) { fixedToFloat_arrL( data_fx[i], data_f[i], st_ivas->q_data_fx, input_frame ); } - for ( i = 0; i < nchan_ism; i++ ) - { - st_ivas->hIsmMetaData[i]->azimuth = fixedToFloat( st_ivas->hIsmMetaData[i]->azimuth_fx, Q22 ); - st_ivas->hIsmMetaData[i]->elevation = fixedToFloat( st_ivas->hIsmMetaData[i]->elevation_fx, Q22 ); - } fixedToFloat_arrL( data_separated_object_fx, data_separated_object, st_ivas->q_data_fx, input_frame ); #endif // IVAS_FLOAT_FIXED_CONVERSIONS } @@ -1517,10 +1368,6 @@ ivas_error ivas_enc( #endif ivas_mcmasa_enc_fx( st_ivas->hMcMasa, st_ivas->hQMetaData, st_ivas->hMasa, data_fx, input_frame, st_ivas->nchan_transport, nchan_inp, q_data ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - st_ivas->hMasa->data.lfeToTotalEnergyRatio[i] = st_ivas->hMasa->data.lfeToTotalEnergyRatio_fx[i] / (float) ( 1 << ( Q15 - st_ivas->hMasa->data.lfeToTotalEnergyRatio_e[i] ) ); - } for ( i = 0; i < nchan_inp; i++ ) { fixedToFloat_arrL( data_fx[i], data_f[i], q_data, input_frame ); diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index f2ee3a9d6c0cb2cf2df99b8c5f3d29d50c67478e..7c5223b42ecd3b3b8b4fe7f5c363f81436abe0a3 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -60,7 +60,7 @@ *------------------------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED -static void ivas_band_cov_fx( Word32 **ppIn_FR_real, Word32 **ppIn_FR_imag, Word16 *q_In_FR, const Word16 num_chans, const Word16 num_bins, Word16 stride, Word32 **pFb_bin_to_band, const Word16 *pFb_start_bin_per_band, const Word16 *pFb_active_bins_per_band, const Word16 start_band, const Word16 end_band, Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], Word16 *q_cov_real[IVAS_SPAR_MAX_CH], const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] ); +static void ivas_band_cov_fx( Word32 **ppIn_FR_real, Word32 **ppIn_FR_imag, Word16 q_In_FR, const Word16 num_chans, const Word16 num_bins, Word16 stride, Word32 **pFb_bin_to_band, const Word16 *pFb_start_bin_per_band, const Word16 *pFb_active_bins_per_band, const Word16 start_band, const Word16 end_band, Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], Word16 *q_cov_real[IVAS_SPAR_MAX_CH], const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] ); #else static void ivas_band_cov( float **ppIn_FR_real, float **ppIn_FR_imag, const int16_t num_chans, const int16_t num_bins, int16_t stride, float **pFb_bin_to_band, const int16_t *pFb_start_bin_per_band, const int16_t *pFb_active_bins_per_band, const int16_t start_band, const int16_t end_band, float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] ); #endif @@ -547,7 +547,7 @@ void ivas_enc_cov_handler_process_fx( ivas_enc_cov_handler_state_t *hCovEnc, /* i/o: SPAR Covar. encoder handle */ Word32 **ppIn_FR_real, Word32 **ppIn_FR_imag, - Word16 *q_ppIn_FR, + Word16 q_ppIn_FR, Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], Word16 *q_cov_real[IVAS_SPAR_MAX_CH], Word32 *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], @@ -819,7 +819,7 @@ void ivas_enc_cov_handler_process( static void ivas_band_cov_fx( Word32 **ppIn_FR_real, Word32 **ppIn_FR_imag, - Word16 *q_In_FR, + Word16 q_In_FR, const Word16 num_chans, const Word16 num_bins, Word16 stride, @@ -905,7 +905,7 @@ static void ivas_band_cov_fx( cov_real_64bit[i][j][k] = temp * (Word64) ( num_blocks ); // (q_In_FR[i1] + q_In_FR[j1] + (q_shift - 10) - guard_bits move64(); } - q_cov_real[i][j] = add( add( q_In_FR[i1], q_In_FR[j1] ), sub( q_shift, Q10 ) ); + q_cov_real[i][j] = add( add( q_In_FR, q_In_FR ), sub( q_shift, Q10 ) ); move16(); } } diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 4d6376af1ec4a9c4b2ffe439396c5f8420255fd8..1d77e746c35ef95e9226376c983ed824d7fd01d1 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -1204,31 +1204,11 @@ ivas_error ivas_init_encoder( } #else #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - MASA_METADATA_HANDLE current_meta = &( st_ivas->hMasa->masaMetadata ); - MASA_METADATA_HANDLE previous_meta = &( st_ivas->hMasa->data.sync_state.previous_metadata ); - fixedToFloat_arrL( st_ivas->hMasa->data.importanceWeight_fx, st_ivas->hMasa->data.importanceWeight, 30, 24 ); for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( current_meta->directional_meta[k].azimuth[i][j], Q22 ); - current_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( current_meta->directional_meta[k].elevation[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( current_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( current_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - previous_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].azimuth[i][j], Q22 ); - previous_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].elevation[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - } f2me( st_ivas->hMasa->data.energy[i][j], &st_ivas->hMasa->data.energy_fx[i][j], &st_ivas->hMasa->data.energy_e[i][j] ); - current_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( current_meta->common_meta.surround_coherence[i][j], Q15 ) ); - current_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( current_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( current_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->common_meta.surround_coherence[i][j], Q15 ) ); - previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); } } #endif // IVAS_FLOAT_FIXED_CONVERSIONS @@ -1238,29 +1218,6 @@ ivas_error ivas_init_encoder( } #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( current_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - current_meta->directional_meta[k].elevation[i][j] = fixedToFloat( current_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( current_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( current_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - previous_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( previous_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - previous_meta->directional_meta[k].elevation[i][j] = fixedToFloat( previous_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( previous_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( previous_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - } - current_meta->common_meta.surround_coherence[i][j] = fixedToFloat( current_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - current_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.surround_coherence[i][j] = fixedToFloat( previous_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - previous_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - } - } if ( st_ivas->hQMetaData->q_direction != NULL ) { for ( int band = 0; band < st_ivas->hMasa->config.numCodingBands; band++ ) @@ -1276,7 +1233,6 @@ ivas_error ivas_init_encoder( } } } - fixedToFloat_arrL( st_ivas->hMasa->data.importanceWeight_fx, st_ivas->hMasa->data.importanceWeight, 30, 24 ); #endif #endif // IVAS_FLOAT_FIXED_CONVERSIONS @@ -1923,31 +1879,11 @@ ivas_error ivas_init_encoder_fx( } #else #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - MASA_METADATA_HANDLE current_meta = &( st_ivas->hMasa->masaMetadata ); - MASA_METADATA_HANDLE previous_meta = &( st_ivas->hMasa->data.sync_state.previous_metadata ); - fixedToFloat_arrL( st_ivas->hMasa->data.importanceWeight_fx, st_ivas->hMasa->data.importanceWeight, 30, 24 ); for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( current_meta->directional_meta[k].azimuth[i][j], Q22 ); - current_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( current_meta->directional_meta[k].elevation[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( current_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( current_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - previous_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].azimuth[i][j], Q22 ); - previous_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].elevation[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - } f2me( st_ivas->hMasa->data.energy[i][j], &st_ivas->hMasa->data.energy_fx[i][j], &st_ivas->hMasa->data.energy_e[i][j] ); - current_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( current_meta->common_meta.surround_coherence[i][j], Q15 ) ); - current_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( current_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( current_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->common_meta.surround_coherence[i][j], Q15 ) ); - previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); } } #endif // IVAS_FLOAT_FIXED_CONVERSIONS @@ -1957,29 +1893,6 @@ ivas_error ivas_init_encoder_fx( } #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( current_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - current_meta->directional_meta[k].elevation[i][j] = fixedToFloat( current_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( current_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( current_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - previous_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( previous_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - previous_meta->directional_meta[k].elevation[i][j] = fixedToFloat( previous_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( previous_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( previous_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - } - current_meta->common_meta.surround_coherence[i][j] = fixedToFloat( current_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - current_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.surround_coherence[i][j] = fixedToFloat( previous_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - previous_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - } - } if ( st_ivas->hQMetaData->q_direction != NULL ) { for ( int band = 0; band < st_ivas->hMasa->config.numCodingBands; band++ ) @@ -1995,7 +1908,6 @@ ivas_error ivas_init_encoder_fx( } } } - fixedToFloat_arrL( st_ivas->hMasa->data.importanceWeight_fx, st_ivas->hMasa->data.importanceWeight, 30, 24 ); #endif #endif // IVAS_FLOAT_FIXED_CONVERSIONS diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 9d8612ff074dfd7e77d4aaad50be67a55796c204..78eb1974d9b479b025605be095b7e8d089cd9177 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -557,68 +557,21 @@ ivas_error ivas_ism_enc( #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - st->hTranDet->subblockEnergies.firState1 = (Word16) floatToFixed( st->hTranDet->subblockEnergies.firState1_flt, -1 ); - st->hTranDet->subblockEnergies.firState2 = (Word16) floatToFixed( st->hTranDet->subblockEnergies.firState2_flt, -1 ); - - FOR( i = 0; i < NSUBBLOCKS + MAX_TD_DELAY + 1; i++ ) - { - st->hTranDet->subblockEnergies.accSubblockNrg[i] = floatToFixed( st->hTranDet->subblockEnergies.accSubblockNrg_flt[i], 7 ); - } - - FOR( i = 0; i < NSUBBLOCKS + MAX_TD_DELAY; i++ ) - { - st->hTranDet->subblockEnergies.subblockNrg[i] = floatToFixed( st->hTranDet->subblockEnergies.subblockNrg_flt[i], 7 ); - st->hTranDet->subblockEnergies.subblockNrgChange[i] = (Word16) floatToFixed( st->hTranDet->subblockEnergies.subblockNrgChange_flt[i], 7 ); - } - - - FOR( i = 0; i < L_FRAME_MAX / NSUBBLOCKS; i++ ) - { - st->hTranDet->delayBuffer.buffer[i] = (Word16) floatToFixed( st->hTranDet->delayBuffer.buffer_flt[i], 7 ); - } - - st->hTranDet->transientDetector.attackRatioThreshold = (Word16) floatToFixed( st->hTranDet->transientDetector.attackRatioThreshold_flt, 11 ); - floatToFixed_arr16( st->input, st->input_fx, -1, input_frame ); - st->hTranDet->subblockEnergies.facAccSubblockNrg = float_to_fix16( st->hTranDet->subblockEnergies.facAccSubblockNrg_flt, 15 ); - #endif - RunTransientDetection_ivas_fx( st->input_fx, input_frame, st->hTranDet ); - -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - - st->hTranDet->subblockEnergies.firState1_flt = fixedToFloat( (Word32) st->hTranDet->subblockEnergies.firState1, -1 ); - st->hTranDet->subblockEnergies.firState2_flt = fixedToFloat( (Word32) st->hTranDet->subblockEnergies.firState2, -1 ); - - FOR( i = 0; i < NSUBBLOCKS + MAX_TD_DELAY; i++ ) - { - st->hTranDet->subblockEnergies.subblockNrg_flt[i] = fixedToFloat( st->hTranDet->subblockEnergies.subblockNrg[i], 7 ); - st->hTranDet->subblockEnergies.subblockNrgChange_flt[i] = fixedToFloat( (Word32) st->hTranDet->subblockEnergies.subblockNrgChange[i], 7 ); - } - - FOR( i = 0; i < NSUBBLOCKS + MAX_TD_DELAY + 1; i++ ) - { - st->hTranDet->subblockEnergies.accSubblockNrg_flt[i] = fixedToFloat( st->hTranDet->subblockEnergies.accSubblockNrg[i], 7 ); - } - - FOR( i = 0; i < L_FRAME_MAX / NSUBBLOCKS; i++ ) - { - st->hTranDet->delayBuffer.buffer_flt[i] = fixedToFloat( (Word32) st->hTranDet->delayBuffer.buffer[i], -1 ); - } -#endif + st->hTranDet->subblockEnergies.subblockNrg_e = 31 - Q7; + st->hTranDet->subblockEnergies.accSubblockNrg_e = 31 - Q7; + move16(); + move16(); #else RunTransientDetection( st->input, input_frame, st->hTranDet ); #endif #ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 e_tmp; - f2me_buf_16( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange_flt, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange, &e_tmp, 24 ); -#endif currFlatness_fx[0] = GetTCXAvgTemporalFlatnessMeasure_fx( (const TransientDetection *) st->hTranDet, NSUBBLOCKS, 0 ); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - currFlatness[0] = me2f_16( currFlatness_fx[0], e_tmp ); + currFlatness[0] = me2f_16( currFlatness_fx[0], 15 - Q7 ); #endif #else currFlatness[0] = GetTCXAvgTemporalFlatnessMeasure( st->hTranDet, NSUBBLOCKS, 0 ); @@ -664,20 +617,6 @@ ivas_error ivas_ism_enc( *-----------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - IF( st_ivas->hIsmMetaData != NULL ) - { - FOR( int ch = 0; ch < st_ivas->hEncoderConfig->nchan_ism; ch++ ) - { - st_ivas->hIsmMetaData[ch]->azimuth_fx = floatToFixed( st_ivas->hIsmMetaData[ch]->azimuth, Q22 ); - st_ivas->hIsmMetaData[ch]->elevation_fx = floatToFixed( st_ivas->hIsmMetaData[ch]->elevation, Q22 ); - st_ivas->hIsmMetaData[ch]->yaw_fx = floatToFixed( st_ivas->hIsmMetaData[ch]->yaw, Q22 ); - st_ivas->hIsmMetaData[ch]->pitch_fx = floatToFixed( st_ivas->hIsmMetaData[ch]->pitch, Q22 ); - st_ivas->hIsmMetaData[ch]->radius_fx = float_to_fix16( st_ivas->hIsmMetaData[ch]->radius, Q9 ); - st_ivas->hIsmMetaData[ch]->last_true_azimuth_fx = float_to_fix( st_ivas->hIsmMetaData[ch]->last_true_azimuth, Q22 ); - st_ivas->hIsmMetaData[ch]->last_true_elevation_fx = float_to_fix( st_ivas->hIsmMetaData[ch]->last_true_elevation, Q22 ); - st_ivas->hIsmMetaData[ch]->last_true_radius_fx = float_to_fix16( st_ivas->hIsmMetaData[ch]->last_true_radius, Q9 ); - } - } if ( st_ivas->hISMDTX ) { floatToFixed_arr16( st_ivas->hISMDTX->coh, st_ivas->hISMDTX->coh_fx, Q15, st_ivas->nchan_transport ); @@ -895,17 +834,6 @@ ivas_error ivas_ism_enc( pop_wmops(); #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - IF( st_ivas->hIsmMetaData != NULL ) - { - FOR( int ch = 0; ch < st_ivas->hEncoderConfig->nchan_ism; ch++ ) - { - st_ivas->hIsmMetaData[ch]->last_true_azimuth = fix_to_float( st_ivas->hIsmMetaData[ch]->last_true_azimuth_fx, Q22 ); - st_ivas->hIsmMetaData[ch]->last_true_elevation = fix_to_float( st_ivas->hIsmMetaData[ch]->last_true_elevation_fx, Q22 ); - st_ivas->hIsmMetaData[ch]->last_true_radius = fix16_to_float( st_ivas->hIsmMetaData[ch]->last_true_radius_fx, Q9 ); - st_ivas->hIsmMetaData[ch]->last_azimuth = fix_to_float( st_ivas->hIsmMetaData[ch]->last_azimuth_fx, Q22 ); - st_ivas->hIsmMetaData[ch]->last_elevation = fix_to_float( st_ivas->hIsmMetaData[ch]->last_elevation_fx, Q22 ); - } - } 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 ); diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index d383d7b327b84f56f842091f8fa770e21fb31cb3..982b355503449e91162491a6dde37d1701ee910a 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -1622,11 +1622,6 @@ ivas_error ivas_ism_metadata_enc_create( move16(); st_ivas->hIsmMetaData[ch]->q_elevation_old_fx = 0; move16(); - /*===============fix-to-flt====================*/ - st_ivas->hIsmMetaData[ch]->q_azimuth_old = fix_to_float( st_ivas->hIsmMetaData[ch]->q_azimuth_old_fx, Q22 ); - st_ivas->hIsmMetaData[ch]->q_elevation_old = fix_to_float( st_ivas->hIsmMetaData[ch]->q_elevation_old_fx, Q22 ); - /*===============fix-to-flt====================*/ - #ifdef IVAS_FLOAT_FIXED ivas_ism_reset_metadata_enc( st_ivas->hIsmMetaData[ch] ); @@ -1644,15 +1639,6 @@ ivas_error ivas_ism_metadata_enc_create( st_ivas->hIsmMetaData[ch]->ism_md_fec_cnt_enc = 0; st_ivas->hIsmMetaData[ch]->ism_md_inc_diff_cnt = ISM_MD_INC_DIFF_CNT_MAX; st_ivas->hIsmMetaData[ch]->last_true_radius_fx = ONE_IN_Q9; - - /*===============fix-to-flt====================*/ - st_ivas->hIsmMetaData[ch]->last_azimuth = fix_to_float( st_ivas->hIsmMetaData[ch]->last_azimuth_fx, Q22 ); - st_ivas->hIsmMetaData[ch]->last_elevation = fix_to_float( st_ivas->hIsmMetaData[ch]->last_elevation_fx, Q22 ); - - st_ivas->hIsmMetaData[ch]->last_true_azimuth = fix_to_float( st_ivas->hIsmMetaData[ch]->last_true_azimuth_fx, Q22 ); - st_ivas->hIsmMetaData[ch]->last_true_elevation = fix_to_float( st_ivas->hIsmMetaData[ch]->last_true_elevation_fx, Q22 ); - st_ivas->hIsmMetaData[ch]->last_true_radius = fix16_to_float( st_ivas->hIsmMetaData[ch]->last_true_radius_fx, Q9 ); - /*===============fix-to-flt====================*/ } IF( EQ_16( st_ivas->hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 3525a8ab00e27f568a111943f2378f827f77a48a..97101e41252a74590fe51568af25a0ab75871a15 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -250,10 +250,15 @@ ivas_error ivas_masa_enc_open( hMasa->data.onset_detector_2 = 0.0f; #endif - set_zero( hMasa->data.lfeToTotalEnergyRatio, MAX_PARAM_SPATIAL_SUBFRAMES ); +#ifdef IVAS_FLOAT_FIXED set32_fx( hMasa->data.lfeToTotalEnergyRatio_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); set16_fx( hMasa->data.lfeToTotalEnergyRatio_e, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); + hMasa->data.prevq_lfeToTotalEnergyRatio_fx = 0; + move32(); +#else + set_zero( hMasa->data.lfeToTotalEnergyRatio, MAX_PARAM_SPATIAL_SUBFRAMES ); hMasa->data.prevq_lfeToTotalEnergyRatio = 0.0f; +#endif hMasa->data.prevq_lfeIndex = 0; hMasa->data.sync_state.prev_sim_stop = 0; @@ -280,10 +285,17 @@ ivas_error ivas_masa_enc_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA data encoder\n" ) ); } +#ifdef IVAS_FLOAT_FIXED + FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + set32_fx( hOmasaData->masa_to_total_energy_ratio_fx[i], 0, MASA_FREQUENCY_BANDS ); + } +#else for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { set_f( hOmasaData->masa_to_total_energy_ratio[i], 0, MASA_FREQUENCY_BANDS ); } +#endif #ifndef IVAS_FLOAT_FIXED hOmasaData->lp_noise_CPE = -1; #else @@ -291,12 +303,16 @@ ivas_error ivas_masa_enc_open( #endif hOmasaData->omasa_stereo_sw_cnt = OMASA_STEREO_SW_CNT_MAX; #ifdef IVAS_FLOAT_FIXED - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { - set_zero( hOmasaData->energy_ism[i], MASA_FREQUENCY_BANDS ); set_zero_fx( hOmasaData->energy_ism_fx[i], MASA_FREQUENCY_BANDS ); set16_fx( hOmasaData->energy_ism_fx_e[i], 0, MASA_FREQUENCY_BANDS ); } +#else + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + set_zero( hOmasaData->energy_ism[i], MASA_FREQUENCY_BANDS ); + } #endif hMasa->data.hOmasaData = hOmasaData; @@ -358,483 +374,344 @@ ivas_error ivas_masa_encode( MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder structure */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ - int16_t *nb_bits_metadata, /* o : number of metadata bits written */ - const int16_t nchan_transport, /* i : number of MASA input/transport channels */ + Word16 *nb_bits_metadata, /* o : number of metadata bits written */ + const Word16 nchan_transport, /* i : number of MASA input/transport channels */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t Opt_DTX_ON, /* i : DTX on flag */ - const int16_t element_mode, /* i : element mode */ + const Word32 ivas_total_brate, /* i : IVAS total bitrate */ + const Word16 Opt_DTX_ON, /* i : DTX on flag */ + const Word16 element_mode, /* i : element mode */ const ISM_MODE ism_mode, /* i : ISM format mode */ - const int16_t nchan_ism, /* i : number of ISM channels */ + const Word16 nchan_ism, /* i : number of ISM channels */ ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS], /* i : ISM metadata handle */ - const int16_t idx_separated_object, /* i : index of the separated object */ + const Word16 idx_separated_object, /* i : index of the separated object */ OMASA_ENC_HANDLE hOMasa, /* i : OMASA encoder handle */ - const int16_t ism_imp, /* i : importance of separated object */ - const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ + const Word16 ism_imp, /* i : importance of separated object */ + const Word16 flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ ) { MASA_DIRECTIONAL_SPATIAL_META *h_orig_metadata; - int16_t i, j; - int16_t masa_sid_descriptor; - int16_t low_bitrate_mode; - int32_t masa_total_brate; + Word16 i, j, s; + Word16 masa_sid_descriptor; + Word16 low_bitrate_mode; + Word32 masa_total_brate; ivas_error error; - Word16 guard_bits; + Word16 guard_bits, tmp; + +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + for ( i = 0; i < hQMetaData->no_directions; i++ ) + { + for ( j = hQMetaData->q_direction[i].cfg.start_band; j < hQMetaData->q_direction[i].cfg.nbands; ++j ) + { + floatToFixed_arrL( hQMetaData->q_direction[i].band_data[j].energy_ratio, hQMetaData->q_direction[i].band_data[j].energy_ratio_fx, Q30, MAX_PARAM_SPATIAL_SUBFRAMES ); + floatToFixed_arrL( hQMetaData->q_direction[i].band_data[j].azimuth, hQMetaData->q_direction[i].band_data[j].azimuth_fx, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + floatToFixed_arrL( hQMetaData->q_direction[i].band_data[j].elevation, hQMetaData->q_direction[i].band_data[j].elevation_fx, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + floatToFixed_arrL( hQMetaData->q_direction[i].band_data[j].q_azimuth, hQMetaData->q_direction[i].band_data[j].q_azimuth_fx, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + floatToFixed_arrL( hQMetaData->q_direction[i].band_data[j].q_elevation, hQMetaData->q_direction[i].band_data[j].q_elevation_fx, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + } + } + hMasa->data.q_energy = Q31; + // guard_bits = find_guarded_bits_fx( 9 ); + guard_bits = find_guarded_bits_fx( 24 ); + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + hMasa->data.q_energy = s_min( hMasa->data.q_energy, L_get_q_buf1( hMasa->data.energy[i], MASA_FREQUENCY_BANDS ) ); + } + hMasa->data.q_energy -= guard_bits; + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + for ( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) + { + hMasa->data.energy_e[i][j] = 31 - hMasa->data.q_energy; + } + } + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + floatToFixed_arrL32( hMasa->data.energy[i], hMasa->data.energy_fx[i], hMasa->data.q_energy, MASA_FREQUENCY_BANDS ); + } +#endif masa_sid_descriptor = -1; h_orig_metadata = NULL; low_bitrate_mode = 0; + move16(); + move16(); - if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) + test(); + IF( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) ) { /* Create the MASA SID descriptor for the metadata and CPE mode, in order to have the SID frame self-contained. */ - if ( Opt_DTX_ON && hQMetaData != NULL ) + test(); + IF( Opt_DTX_ON && hQMetaData != NULL ) { - if ( nchan_transport == 2 ) /* this is MASA format in CPE only */ + IF( EQ_16( nchan_transport, 2 ) ) /* this is MASA format in CPE only */ { masa_sid_descriptor = 0; /* for IVAS_CPE_DFT */ - if ( element_mode == IVAS_CPE_MDCT ) + move16(); + if ( EQ_16( element_mode, IVAS_CPE_MDCT ) ) { masa_sid_descriptor = 1; + move16(); } } } /* Validate and compensate ratios as necessary */ -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 sf, dir; - MASA_METADATA_HANDLE hMeta = &( hMasa->masaMetadata ); - Word16 numDirs = hMeta->descriptive_meta.numberOfDirections + 1; - FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) - { - floatToFixed_arrL32( hMeta->common_meta.remainder_to_total_ratio[sf], hMeta->common_meta.remainder_to_total_ratio_fx[sf], Q30, MASA_FREQUENCY_BANDS ); - FOR( dir = 0; dir < numDirs; dir++ ) - { - floatToFixed_arrL32( hMeta->directional_meta[dir].energy_ratio[sf], hMeta->directional_meta[dir].energy_ratio_fx[sf], Q30, MASA_FREQUENCY_BANDS ); - } - floatToFixed_arrL32( hMeta->common_meta.diffuse_to_total_ratio[sf], hMeta->common_meta.diffuse_to_total_ratio_fx[sf], Q30, MASA_FREQUENCY_BANDS ); - } -#endif compensate_energy_ratios_fx( hMasa ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) - { - FOR( dir = 0; dir < numDirs; dir++ ) - { - fixedToFloat_arrL32( hMeta->directional_meta[dir].energy_ratio_fx[sf], hMeta->directional_meta[dir].energy_ratio[sf], Q30, MASA_FREQUENCY_BANDS ); - } - fixedToFloat_arrL32( hMeta->common_meta.diffuse_to_total_ratio_fx[sf], hMeta->common_meta.diffuse_to_total_ratio[sf], Q30, MASA_FREQUENCY_BANDS ); - } -#endif -#else - compensate_energy_ratios( hMasa ); -#endif - if ( Opt_DTX_ON ) + IF( Opt_DTX_ON ) { - if ( ( h_orig_metadata = (MASA_DIRECTIONAL_SPATIAL_META *) malloc( MASA_MAXIMUM_DIRECTIONS * sizeof( MASA_DIRECTIONAL_SPATIAL_META ) ) ) == NULL ) + IF( ( h_orig_metadata = (MASA_DIRECTIONAL_SPATIAL_META *) malloc( MASA_MAXIMUM_DIRECTIONS * sizeof( MASA_DIRECTIONAL_SPATIAL_META ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA encoder\n" ) ); } - for ( i = 0; i < MASA_MAXIMUM_DIRECTIONS; i++ ) + FOR( i = 0; i < MASA_MAXIMUM_DIRECTIONS; i++ ) { - for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - mvr2r( hMasa->masaMetadata.directional_meta[i].azimuth[j], h_orig_metadata[i].azimuth[j], MASA_FREQUENCY_BANDS ); - mvr2r( hMasa->masaMetadata.directional_meta[i].elevation[j], h_orig_metadata[i].elevation[j], MASA_FREQUENCY_BANDS ); - mvr2r( hMasa->masaMetadata.directional_meta[i].energy_ratio[j], h_orig_metadata[i].energy_ratio[j], MASA_FREQUENCY_BANDS ); - mvs2s( (int16_t *) ( hMasa->masaMetadata.directional_meta[i].spherical_index[j] ), (int16_t *) ( h_orig_metadata[i].spherical_index[j] ), MASA_FREQUENCY_BANDS ); + Copy32( hMasa->masaMetadata.directional_meta[i].azimuth_fx[j], h_orig_metadata[i].azimuth_fx[j], MASA_FREQUENCY_BANDS ); + Copy32( hMasa->masaMetadata.directional_meta[i].elevation_fx[j], h_orig_metadata[i].elevation_fx[j], MASA_FREQUENCY_BANDS ); + Copy32( hMasa->masaMetadata.directional_meta[i].energy_ratio_fx[j], h_orig_metadata[i].energy_ratio_fx[j], MASA_FREQUENCY_BANDS ); + Copy( (Word16 *) ( hMasa->masaMetadata.directional_meta[i].spherical_index[j] ), (Word16 *) ( h_orig_metadata[i].spherical_index[j] ), MASA_FREQUENCY_BANDS ); } } } - if ( ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) && ivas_total_brate >= IVAS_384k ) + test(); + test(); + if ( ( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) ) && GE_32( ivas_total_brate, IVAS_384k ) ) { hMasa->config.mergeRatiosOverSubframes = 0; + move16(); } /* Combine frequency bands and sub-frames */ -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 numSf = hMasa->config.joinedSubframes == TRUE ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES; - for ( i = 0; i < 4; i++ ) - { - for ( j = 0; j < 24; j++ ) - { - f2me( hMasa->data.energy[i][j], &hMasa->data.energy_fx[i][j], &hMasa->data.energy_e[i][j] ); - } - } - if ( hMasa->config.numCodingBands <= MAX_REDUCED_NBANDS ) - { - for ( i = 0; i < hMasa->config.numberOfDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - floatToFixed_arrL32( hMeta->directional_meta[i].azimuth[j], hMeta->directional_meta[i].azimuth_fx[j], Q22, MASA_FREQUENCY_BANDS ); - floatToFixed_arrL32( hMeta->directional_meta[i].elevation[j], hMeta->directional_meta[i].elevation_fx[j], Q22, MASA_FREQUENCY_BANDS ); - floatToFixed_arrL32( hMeta->directional_meta[i].energy_ratio[j], hMeta->directional_meta[i].energy_ratio_fx[j], Q30, MASA_FREQUENCY_BANDS ); - } - } - if ( hMasa->config.useCoherence && hMasa->config.coherencePresent ) - { - for ( i = 0; i < hMasa->config.numberOfDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - floatToFixed_arr( hMeta->directional_meta[i].spread_coherence[j], hMeta->directional_meta[i].spread_coherence_fx[j], Q15, MASA_FREQUENCY_BANDS ); - if ( i == 0 ) - { - floatToFixed_arr( hMeta->common_meta.surround_coherence[j], hMeta->common_meta.surround_coherence_fx[j], Q15, MASA_FREQUENCY_BANDS ); - } - } - } - } - } - if ( hMasa->config.mergeRatiosOverSubframes ) - { - if ( hMasa->config.useCoherence && hMasa->config.coherencePresent ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - floatToFixed_arr( hMeta->common_meta.surround_coherence[j], hMeta->common_meta.surround_coherence_fx[j], Q15, MASA_FREQUENCY_BANDS ); - } - } - for ( i = 0; i < hMasa->config.numberOfDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - floatToFixed_arrL32( hMeta->directional_meta[i].energy_ratio[j], hMeta->directional_meta[i].energy_ratio_fx[j], Q30, MASA_FREQUENCY_BANDS ); - } - } - } -#endif combine_freqbands_and_subframes_fx( hMasa ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < 4; i++ ) - { - for ( j = 0; j < 24; j++ ) - { - hMasa->data.energy[i][j] = me2f( hMasa->data.energy_fx[i][j], hMasa->data.energy_e[i][j] ); - } - } - if ( hMasa->config.numCodingBands <= MAX_REDUCED_NBANDS ) + + /* aligning the exponents */ + s = 0; + move16(); + FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { - for ( i = 0; i < hMasa->config.numberOfDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - fixedToFloat_arrL32( hMeta->directional_meta[i].azimuth_fx[j], hMeta->directional_meta[i].azimuth[j], Q22, MASA_FREQUENCY_BANDS ); - fixedToFloat_arrL32( hMeta->directional_meta[i].elevation_fx[j], hMeta->directional_meta[i].elevation[j], Q22, MASA_FREQUENCY_BANDS ); - fixedToFloat_arrL32( hMeta->directional_meta[i].energy_ratio_fx[j], hMeta->directional_meta[i].energy_ratio[j], Q30, MASA_FREQUENCY_BANDS ); - } - } - if ( hMasa->config.useCoherence && hMasa->config.coherencePresent ) - { - for ( i = 0; i < hMasa->config.numberOfDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - fixedToFloat_arr( hMeta->directional_meta[i].spread_coherence_fx[j], hMeta->directional_meta[i].spread_coherence[j], Q15, MASA_FREQUENCY_BANDS ); - if ( i == 0 ) - { - fixedToFloat_arr( hMeta->common_meta.surround_coherence_fx[j], hMeta->common_meta.surround_coherence[j], Q15, MASA_FREQUENCY_BANDS ); - } - } - } - } + maximum_s( hMasa->data.energy_e[i], MASA_FREQUENCY_BANDS, &tmp ); + s = s_max( s, tmp ); } - if ( hMasa->config.mergeRatiosOverSubframes ) + FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { - if ( hMasa->config.useCoherence && hMasa->config.coherencePresent ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - fixedToFloat_arr( hMeta->common_meta.surround_coherence_fx[j], hMeta->common_meta.surround_coherence[j], Q15, MASA_FREQUENCY_BANDS ); - } - } - for ( i = 0; i < hMasa->config.numberOfDirections; i++ ) + FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - fixedToFloat_arrL32( hMeta->directional_meta[i].energy_ratio_fx[j], hMeta->directional_meta[i].energy_ratio[j], Q30, MASA_FREQUENCY_BANDS ); - } + hMasa->data.energy_fx[i][j] = L_shr( hMasa->data.energy_fx[i][j], sub( s, hMasa->data.energy_e[i][j] ) ); + hMasa->data.energy_e[i][j] = s; + move32(); + move16(); } } -#endif -#else - combine_freqbands_and_subframes( hMasa ); -#endif + hMasa->data.q_energy = sub( 31, s ); + move16(); } - if ( hMasa->config.numberOfDirections == 2 && hMasa->config.numTwoDirBands < hMasa->config.numCodingBands && ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) ) + test(); + test(); + test(); + IF( EQ_16( hMasa->config.numberOfDirections, 2 ) && LT_16( hMasa->config.numTwoDirBands, hMasa->config.numCodingBands ) && ( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) ) ) { - if ( ( ivas_format == MASA_ISM_FORMAT && ism_mode != ISM_MODE_NONE && ism_mode != ISM_MASA_MODE_MASA_ONE_OBJ ) || ( ivas_format != MASA_ISM_FORMAT ) ) + test(); + test(); + test(); + IF( ( EQ_32( ivas_format, MASA_ISM_FORMAT ) && NE_32( ism_mode, ISM_MODE_NONE ) && NE_32( ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) || NE_32( ivas_format, MASA_ISM_FORMAT ) ) { /* Combine directions */ -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 numCodingBands = hMasa->config.numCodingBands; - Word16 numDirections = hMasa->config.numberOfDirections; - Word16 numSf = hMasa->config.joinedSubframes == TRUE ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES; - Word16 computeCoherence = hMasa->config.useCoherence && hMasa->config.coherencePresent; - MASA_METADATA_HANDLE hMeta; - hMeta = &( hMasa->masaMetadata ); - for ( i = 0; i < numDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) - { - for ( int k = 0; k < hMasa->config.numCodingBands; k++ ) - { - hMeta->directional_meta[i].energy_ratio_fx[j][k] = floatToFixed( hMeta->directional_meta[i].energy_ratio[j][k], Q30 ); - hMeta->directional_meta[i].azimuth_fx[j][k] = floatToFixed( hMeta->directional_meta[i].azimuth[j][k], Q22 ); - hMeta->directional_meta[i].elevation_fx[j][k] = floatToFixed( hMeta->directional_meta[i].elevation[j][k], Q22 ); - } - } - } - /* Combine directions on the remaining bands */ - for ( i = 0; i < hMasa->config.numCodingBands; i++ ) - { - for ( j = 0; j < numSf; j++ ) - { - hMeta->directional_meta[0].spread_coherence_fx[j][i] = (Word16) floatToFixed( hMeta->directional_meta[0].spread_coherence[j][i], Q15 ); - hMeta->directional_meta[1].spread_coherence_fx[j][i] = (Word16) floatToFixed( hMeta->directional_meta[1].spread_coherence[j][i], Q15 ); - hMeta->common_meta.surround_coherence_fx[j][i] = (Word16) floatToFixed( hMeta->common_meta.surround_coherence[j][i], Q15 ); - } - } - - /* Estimate the importance of having two directions instead of one */ - for ( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) - { - hMasa->data.importanceWeight_fx[i] = floatToFixed( hMasa->data.importanceWeight[i], Q30 ); - } -#endif - ivas_masa_combine_directions_fx( hMasa ); - -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < numCodingBands; i++ ) - { - if ( hMasa->data.twoDirBands[i] == 0 ) - { - for ( j = 0; j < numSf; j++ ) - { - hMeta->directional_meta[0].azimuth[j][i] = fixedToFloat( hMeta->directional_meta[0].azimuth_fx[j][i], Q22 ); - hMeta->directional_meta[0].elevation[j][i] = fixedToFloat( hMeta->directional_meta[0].elevation_fx[j][i], Q22 ); - if ( computeCoherence ) - { - hMeta->directional_meta[0].spread_coherence[j][i] = fixedToFloat( hMeta->directional_meta[0].spread_coherence_fx[j][i], Q15 ); - hMeta->common_meta.surround_coherence[j][i] = fixedToFloat( hMeta->common_meta.surround_coherence_fx[j][i], Q15 ); - } - hMeta->directional_meta[0].energy_ratio[j][i] = fixedToFloat( hMeta->directional_meta[0].energy_ratio_fx[j][i], Q30 ); - hMeta->directional_meta[1].energy_ratio[j][i] = fixedToFloat( hMeta->directional_meta[1].energy_ratio_fx[j][i], Q30 ); - } - } - } -#endif -#else - ivas_masa_combine_directions( hMasa ); -#endif } /* If we joined all bands, then metadata is now one directional. */ - if ( hMasa->config.numTwoDirBands == 0 ) + IF( hMasa->config.numTwoDirBands == 0 ) { hMasa->config.numberOfDirections = 1; hMasa->masaMetadata.descriptive_meta.numberOfDirections = 0; hQMetaData->no_directions = 1; + move16(); + move16(); + move16(); } } /* Reset qmetadata bit budget */ hQMetaData->metadata_max_bits = hMasa->config.max_metadata_bits; - if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) + move16(); + test(); + IF( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) ) { - if ( ivas_format == MASA_ISM_FORMAT && ism_mode != ISM_MODE_NONE ) + test(); + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && NE_32( ism_mode, ISM_MODE_NONE ) ) { /* write the number of objects in ISM_MASA format*/ - push_next_indice( hMetaData, nchan_ism - 1, NO_BITS_MASA_ISM_NO_OBJ ); - hQMetaData->metadata_max_bits -= NO_BITS_MASA_ISM_NO_OBJ; + push_next_indice( hMetaData, sub( nchan_ism, 1 ), NO_BITS_MASA_ISM_NO_OBJ ); + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, NO_BITS_MASA_ISM_NO_OBJ ); + move16(); /* write index of separated object if needed */ - if ( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && nchan_ism > 1 ) + test(); + IF( EQ_32( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) && GT_16( nchan_ism, 1 ) ) { push_next_indice( hMetaData, idx_separated_object, NO_BITS_MASA_ISM_NO_OBJ ); - hQMetaData->metadata_max_bits -= NO_BITS_MASA_ISM_NO_OBJ; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, NO_BITS_MASA_ISM_NO_OBJ ); + move16(); } /* write ISM importance flag (one per object) */ - if ( ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + IF( EQ_32( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { push_next_indice( hMetaData, hIsmMetaData[0]->ism_imp, ISM_METADATA_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_FLAG_BITS ); + move16(); } - else if ( ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) + ELSE IF( EQ_32( ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { - if ( hIsmMetaData[0]->ism_md_null_flag ) + IF( hIsmMetaData[0]->ism_md_null_flag ) { /* signal NULL metadata frame */ push_next_indice( hMetaData, 1, ISM_METADATA_MD_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_MD_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_MD_FLAG_BITS ); + move16(); /* write the ISM class to ISM_NO_META and again the true ISM class */ push_next_indice( hMetaData, ISM_NO_META, ISM_METADATA_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_FLAG_BITS ); + move16(); push_next_indice( hMetaData, hIsmMetaData[0]->ism_imp, ISM_METADATA_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_FLAG_BITS ); + move16(); } - else + ELSE { push_next_indice( hMetaData, hIsmMetaData[0]->ism_imp, ISM_METADATA_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_FLAG_BITS ); + move16(); - if ( hIsmMetaData[0]->ism_imp == ISM_NO_META ) + IF( EQ_16( hIsmMetaData[0]->ism_imp, ISM_NO_META ) ) { /* signal low-rate ISM_NO_META frame */ push_next_indice( hMetaData, 0, ISM_METADATA_MD_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_MD_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_MD_FLAG_BITS ); + move16(); /* signal presence of MD in low-rate ISM_NO_META frame */ push_next_indice( hMetaData, hIsmMetaData[0]->ism_md_lowrate_flag, ISM_METADATA_INACTIVE_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_INACTIVE_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_INACTIVE_FLAG_BITS ); + move16(); } } } - else if ( ism_mode == ISM_MASA_MODE_DISC ) + ELSE IF( EQ_32( ism_mode, ISM_MASA_MODE_DISC ) ) { - for ( i = 0; i < nchan_ism; i++ ) + FOR( i = 0; i < nchan_ism; i++ ) { - if ( hIsmMetaData[i]->ism_md_null_flag ) + IF( hIsmMetaData[i]->ism_md_null_flag ) { /* signal NULL metadata frame */ push_next_indice( hMetaData, 1, ISM_METADATA_MD_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_MD_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_MD_FLAG_BITS ); + move16(); /* write the ISM class to ISM_NO_META and again the true ISM class */ push_next_indice( hMetaData, ISM_NO_META, ISM_METADATA_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_FLAG_BITS ); + move16(); push_next_indice( hMetaData, hIsmMetaData[i]->ism_imp, ISM_METADATA_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_FLAG_BITS ); + move16(); } - else + ELSE { push_next_indice( hMetaData, hIsmMetaData[i]->ism_imp, ISM_METADATA_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_FLAG_BITS ); + move16(); - if ( hIsmMetaData[i]->ism_imp == ISM_NO_META ) + IF( EQ_16( hIsmMetaData[i]->ism_imp, ISM_NO_META ) ) { /* signal low-rate ISM_NO_META frame */ push_next_indice( hMetaData, 0, ISM_METADATA_MD_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_MD_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_MD_FLAG_BITS ); + move16(); /* signal presence of MD in low-rate ISM_NO_META frame */ push_next_indice( hMetaData, hIsmMetaData[i]->ism_md_lowrate_flag, ISM_METADATA_INACTIVE_FLAG_BITS ); - hQMetaData->metadata_max_bits -= ISM_METADATA_INACTIVE_FLAG_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, ISM_METADATA_INACTIVE_FLAG_BITS ); + move16(); } } } - - if ( ivas_total_brate == IVAS_128k && nchan_ism >= 3 ) + test(); + IF( EQ_32( ivas_total_brate, IVAS_128k ) && GE_16( nchan_ism, 3 ) ) { push_next_indice( hMetaData, flag_omasa_ener_brate, 1 ); - hQMetaData->metadata_max_bits -= 1; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, 1 ); + move16(); } } } - else + ELSE { /* write the number of MASA transport channels */ - push_next_indice( hMetaData, nchan_transport - 1, MASA_TRANSP_BITS ); - hQMetaData->metadata_max_bits -= MASA_TRANSP_BITS; + push_next_indice( hMetaData, sub( nchan_transport, 1 ), MASA_TRANSP_BITS ); + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_TRANSP_BITS ); + move16(); } - if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MODE_NONE ) + test(); + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MODE_NONE ) ) { /* signal MASA_ISM_FORMAT to decoder */ push_next_indice( hMetaData, 1, 1 ); /* write reserved bit */ push_next_indice( hMetaData, 0, MASA_HEADER_BITS - 1 ); - hQMetaData->metadata_max_bits -= MASA_HEADER_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_HEADER_BITS ); + move16(); } - else + ELSE { /* the MASA_ISM_FORMAT is not signalled here */ /* write reserved bits */ push_next_indice( hMetaData, 0, MASA_HEADER_BITS ); - hQMetaData->metadata_max_bits -= MASA_HEADER_BITS; + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_HEADER_BITS ); + move16(); } /* write number of directions */ - push_next_indice( hMetaData, hQMetaData->no_directions - 1, 1 ); - hQMetaData->metadata_max_bits -= 1; + push_next_indice( hMetaData, sub( hQMetaData->no_directions, 1 ), 1 ); + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, 1 ); + move16(); /* write subframe mode */ - push_next_indice( hMetaData, hQMetaData->q_direction[0].cfg.nblocks == 1 ? 1 : 0, MASA_SUBFRAME_BITS ); - hQMetaData->metadata_max_bits -= MASA_SUBFRAME_BITS; - } - - if ( ivas_format == MC_FORMAT ) - { - int16_t lfeBitsWritten; -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + IF( EQ_16( hQMetaData->q_direction[0].cfg.nblocks, 1 ) ) { - f2me( hMasa->data.lfeToTotalEnergyRatio[i], &hMasa->data.lfeToTotalEnergyRatio_fx[i], &hMasa->data.lfeToTotalEnergyRatio_e[i] ); + push_next_indice( hMetaData, 1, MASA_SUBFRAME_BITS ); } - hMasa->data.prevq_lfeToTotalEnergyRatio_fx = floatToFixed( hMasa->data.prevq_lfeToTotalEnergyRatio, Q31 ); -#endif - lfeBitsWritten = encode_lfe_to_total_energy_ratio_fx( hMasa, hMetaData, ivas_total_brate ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - hMasa->data.prevq_lfeToTotalEnergyRatio = fixedToFloat( hMasa->data.prevq_lfeToTotalEnergyRatio_fx, Q31 ); -#endif -#else - lfeBitsWritten = encode_lfe_to_total_energy_ratio( hMasa, hMetaData, ivas_total_brate ); -#endif - hQMetaData->metadata_max_bits -= lfeBitsWritten; + ELSE + { + push_next_indice( hMetaData, 0, MASA_SUBFRAME_BITS ); + } + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_SUBFRAME_BITS ); + move16(); } -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - // Word16 numSf = hMasa->config.joinedSubframes == TRUE ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES; - hMasa->data.q_energy = Q31; - guard_bits = find_guarded_bits_fx( 24 ); - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - hMasa->data.q_energy = s_min( hMasa->data.q_energy, L_get_q_buf1( hMasa->data.energy[i], MASA_FREQUENCY_BANDS ) ); - } - hMasa->data.q_energy -= guard_bits; - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - floatToFixed_arrL32( hMasa->data.energy[i], hMasa->data.energy_fx[i], hMasa->data.q_energy, MASA_FREQUENCY_BANDS ); - } - for ( int16_t d = 0; d < hQMetaData->no_directions; d++ ) + + IF( EQ_32( ivas_format, MC_FORMAT ) ) { - for ( i = hQMetaData->q_direction[d].cfg.start_band; i < hQMetaData->q_direction[d].cfg.nbands; i++ ) - { - for ( j = 0; j < hQMetaData->q_direction[d].cfg.nblocks; j++ ) - { - hQMetaData->q_direction[d].band_data[i].elevation_fx[j] = float_to_fix( hQMetaData->q_direction[d].band_data[i].elevation[j], Q22 ); - hQMetaData->q_direction[d].band_data[i].azimuth_fx[j] = float_to_fix( hQMetaData->q_direction[d].band_data[i].azimuth[j], Q22 ); - hQMetaData->q_direction[d].band_data[i].energy_ratio_fx[j] = floatToFixed( hQMetaData->q_direction[d].band_data[i].energy_ratio[j], Q30 ); - } - } + Word16 lfeBitsWritten; + + lfeBitsWritten = encode_lfe_to_total_energy_ratio_fx( hMasa, hMetaData, ivas_total_brate ); + + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, lfeBitsWritten ); + move16(); } -#endif + /* Move data from encoder to qmetadata */ test(); IF( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) ) { move_metadata_to_qmetadata_fx( hMasa, hQMetaData ); } -#else - /* Move data from encoder to qmetadata */ - if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT ) - { - move_metadata_to_qmetadata( hMasa, hQMetaData ); - } -#endif -#ifdef IVAS_FLOAT_FIXED test(); IF( LT_16( hMasa->config.max_metadata_bits, MINIMUM_BIT_BUDGET_NORMAL_META ) && !hMasa->config.joinedSubframes ) @@ -844,41 +721,17 @@ ivas_error ivas_masa_encode( low_bitrate_mode = (Word16) LE_32( ivas_total_brate, 32000 ); /* Write low bitrate mode. 1 signals that we have merged through time, 0 signals merge through frequency. */ - push_next_indice( hMetaData, hQMetaData->q_direction[0].cfg.nblocks == 1 ? 1 : 0, MASA_LOWBITRATE_MODE_BITS ); - hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_LOWBITRATE_MODE_BITS ); - } -#else - if ( hMasa->config.max_metadata_bits < MINIMUM_BIT_BUDGET_NORMAL_META && !hMasa->config.joinedSubframes ) - { - reduce_metadata_further( hMasa, hQMetaData, ivas_format ); - - low_bitrate_mode = ( ivas_total_brate <= 32000 ); - - /* Write low bitrate mode. 1 signals that we have merged through time, 0 signals merge through frequency. */ - push_next_indice( hMetaData, hQMetaData->q_direction[0].cfg.nblocks == 1 ? 1 : 0, MASA_LOWBITRATE_MODE_BITS ); - hQMetaData->metadata_max_bits -= MASA_LOWBITRATE_MODE_BITS; - } -#endif -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - if ( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) - { - for ( int sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; ++sf ) + IF( EQ_16( hQMetaData->q_direction[0].cfg.nblocks, 1 ) ) { - for ( int band = 0; band < MASA_FREQUENCY_BANDS; ++band ) - { - hMasa->data.hOmasaData->masa_to_total_energy_ratio_fx[sf][band] = floatToFixed_32( hMasa->data.hOmasaData->masa_to_total_energy_ratio[sf][band], Q30 ); - } + push_next_indice( hMetaData, 1, MASA_LOWBITRATE_MODE_BITS ); } + ELSE + { + push_next_indice( hMetaData, 0, MASA_LOWBITRATE_MODE_BITS ); + } + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_LOWBITRATE_MODE_BITS ); + move16(); } - for ( int obj = 0; obj < nchan_ism; obj++ ) - { - hIsmMetaData[obj]->elevation_fx = floatToFixed( hIsmMetaData[obj]->elevation, Q22 ); - hIsmMetaData[obj]->azimuth_fx = floatToFixed( hIsmMetaData[obj]->azimuth, Q22 ); - hIsmMetaData[obj]->q_elevation_old_fx = floatToFixed( hIsmMetaData[obj]->q_elevation_old, Q22 ); - hIsmMetaData[obj]->q_azimuth_old_fx = floatToFixed( hIsmMetaData[obj]->q_azimuth_old, Q22 ); - } -#endif /* Encode MASA+ISM metadata */ test(); @@ -896,110 +749,17 @@ ivas_error ivas_masa_encode( } } -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - fixedToFloat_arrL32( hMasa->data.energy_fx[i], hMasa->data.energy[i], hMasa->data.q_energy, MASA_FREQUENCY_BANDS ); - } - for ( int16_t d = 0; d < hQMetaData->no_directions; d++ ) - { - for ( i = hQMetaData->q_direction[d].cfg.start_band; i < hQMetaData->q_direction[d].cfg.nbands; i++ ) - { - for ( j = 0; j < hQMetaData->q_direction[d].cfg.nblocks; j++ ) - { - hQMetaData->q_direction[d].band_data[i].elevation[j] = fix_to_float( hQMetaData->q_direction[d].band_data[i].elevation_fx[j], Q22 ); - hQMetaData->q_direction[d].band_data[i].azimuth[j] = fix_to_float( hQMetaData->q_direction[d].band_data[i].azimuth_fx[j], Q22 ); - hQMetaData->q_direction[d].band_data[i].energy_ratio[j] = fixedToFloat( hQMetaData->q_direction[d].band_data[i].energy_ratio_fx[j], Q30 ); - } - } - } - if ( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) - { - for ( int sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; ++sf ) - { - for ( int band = 0; band < MASA_FREQUENCY_BANDS; ++band ) - { - fixedToFloat_arrL( hMasa->data.hOmasaData->q_energy_ratio_ism_fx[sf][band], hMasa->data.hOmasaData->q_energy_ratio_ism[sf][band], Q30, nchan_ism ); - } - } - for ( int block_m_idx = 0; block_m_idx < hOMasa->nSubframes; block_m_idx++ ) - { - for ( i = 0; i < hOMasa->nbands; i++ ) - { - for ( int k = 0; k < nchan_ism; k++ ) - { - hMasa->data.hOmasaData->energy_ratio_ism[block_m_idx][i][k] = fixedToFloat( hMasa->data.hOmasaData->energy_ratio_ism_fx[block_m_idx][i][k], Q30 ); - } - } - } - } - if ( EQ_32( ivas_format, MASA_ISM_FORMAT ) ) - { - for ( int sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; ++sf ) - { - for ( int band = 0; band < MASA_FREQUENCY_BANDS; ++band ) - { - fixedToFloat_arrL( hMasa->data.hOmasaData->q_energy_ratio_ism_fx[sf][band], hMasa->data.hOmasaData->q_energy_ratio_ism[sf][band], Q30, nchan_ism ); - hMasa->data.hOmasaData->masa_to_total_energy_ratio[sf][band] = fixedToFloat_32( hMasa->data.hOmasaData->masa_to_total_energy_ratio_fx[sf][band], Q30 ); - } - } - } - for ( int obj = 0; obj < nchan_ism; obj++ ) - { - hIsmMetaData[obj]->elevation = fixedToFloat( hIsmMetaData[obj]->elevation_fx, Q22 ); - hIsmMetaData[obj]->azimuth = fixedToFloat( hIsmMetaData[obj]->azimuth_fx, Q22 ); - hIsmMetaData[obj]->q_elevation_old = fixedToFloat( hIsmMetaData[obj]->q_elevation_old_fx, Q22 ); - hIsmMetaData[obj]->q_azimuth_old = fixedToFloat( hIsmMetaData[obj]->q_azimuth_old_fx, Q22 ); - } -#endif -#else - /* Encode MASA+ISM metadata */ - if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) - { - /* encode MASA/ISM energy ratios */ - ivas_encode_masaism_metadata( hMasa, hQMetaData, hMetaData, hIsmMetaData, nchan_ism, low_bitrate_mode, hOMasa->nCodingBands, hOMasa->nSubframes, idx_separated_object, ism_imp ); - } - else - { - if ( ivas_format == MASA_ISM_FORMAT ) - { - hMasa->data.hOmasaData->masa_to_total_energy_ratio[0][0] = -1; /* signals NOT to adjust the energy ratios */ - } - } -#endif - /* Encode metadata */ masa_total_brate = ivas_total_brate; -#ifndef IVAS_FLOAT_FIXED - if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_DISC ) - { - masa_total_brate = calculate_cpe_brate_MASA_ISM( ism_mode, ivas_total_brate, nchan_ism ); - } -#else + move32(); test(); IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MASA_MODE_DISC ) ) { masa_total_brate = calculate_cpe_brate_MASA_ISM_fx( ism_mode, ivas_total_brate, nchan_ism ); } -#endif IF( GE_32( masa_total_brate, IVAS_384k ) ) { -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( int16_t d = 0; d < hQMetaData->no_directions; d++ ) - { - for ( i = hQMetaData->q_direction[d].cfg.start_band; i < hQMetaData->q_direction[d].cfg.nbands; i++ ) - { - for ( j = 0; j < hQMetaData->q_direction[d].cfg.nblocks; j++ ) - { - hQMetaData->q_direction[d].band_data[i].elevation_fx[j] = float_to_fix( hQMetaData->q_direction[d].band_data[i].elevation[j], Q22 ); - hQMetaData->q_direction[d].band_data[i].azimuth_fx[j] = float_to_fix( hQMetaData->q_direction[d].band_data[i].azimuth[j], Q22 ); - hQMetaData->q_direction[d].band_data[i].energy_ratio_fx[j] = floatToFixed( hQMetaData->q_direction[d].band_data[i].energy_ratio[j], Q30 ); - } - } - } -#endif // IVAS_FLOAT_FIXED_CONVERSIONS IF( GE_32( masa_total_brate, IVAS_512k ) ) { IF( NE_32( ( error = ivas_qmetadata_enc_encode_hr_384_512_fx( hMetaData, hQMetaData, 16, 4 ) ), IVAS_ERR_OK ) ) @@ -1014,113 +774,13 @@ ivas_error ivas_masa_encode( return error; } } - -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( int16_t d = 0; d < hQMetaData->no_directions; d++ ) - { - for ( i = hQMetaData->q_direction[d].cfg.start_band; i < hQMetaData->q_direction[d].cfg.nbands; i++ ) - { - for ( j = 0; j < hQMetaData->q_direction[d].cfg.nblocks; j++ ) - { - hQMetaData->q_direction[d].band_data[i].elevation[j] = fix_to_float( hQMetaData->q_direction[d].band_data[i].elevation_fx[j], Q22 ); - hQMetaData->q_direction[d].band_data[i].azimuth[j] = fix_to_float( hQMetaData->q_direction[d].band_data[i].azimuth_fx[j], Q22 ); - hQMetaData->q_direction[d].band_data[i].energy_ratio[j] = fixedToFloat( hQMetaData->q_direction[d].band_data[i].energy_ratio_fx[j], Q30 ); - } - } - } - if ( masa_total_brate >= IVAS_512k ) - { - for ( int16_t d = 0; d < hQMetaData->no_directions; d++ ) - { - for ( i = hQMetaData->q_direction[d].cfg.start_band; i < hQMetaData->q_direction[d].cfg.nbands; i++ ) - { - for ( j = 0; j < hQMetaData->q_direction[d].cfg.nblocks; j++ ) - { - hQMetaData->q_direction[d].band_data[i].q_elevation[j] = fix_to_float( hQMetaData->q_direction[d].band_data[i].q_elevation_fx[j], Q22 ); - hQMetaData->q_direction[d].band_data[i].q_azimuth[j] = fix_to_float( hQMetaData->q_direction[d].band_data[i].q_azimuth_fx[j], Q22 ); - } - } - } - } -#endif // IVAS_FLOAT_FIXED_CONVERSIONS - -#else - if ( masa_total_brate >= IVAS_512k ) - { - if ( ( error = ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 16, 4 ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else - { - if ( ( error = ivas_qmetadata_enc_encode_hr_384_512( hMetaData, hQMetaData, 11, 3 ) ) != IVAS_ERR_OK ) - { - return error; - } - } -#endif } - else + ELSE { -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < hQMetaData->no_directions; i++ ) - { - for ( j = hQMetaData->q_direction[0].cfg.start_band; j < hQMetaData->q_direction[0].cfg.nbands; ++j ) - { - floatToFixed_arrL( hQMetaData->q_direction[i].band_data[j].energy_ratio, hQMetaData->q_direction[i].band_data[j].energy_ratio_fx, Q30, MAX_PARAM_SPATIAL_SUBFRAMES ); - floatToFixed_arrL( hQMetaData->q_direction[i].band_data[j].azimuth, hQMetaData->q_direction[i].band_data[j].azimuth_fx, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); - floatToFixed_arrL( hQMetaData->q_direction[i].band_data[j].elevation, hQMetaData->q_direction[i].band_data[j].elevation_fx, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); - -#ifndef MSAN_FIX - floatToFixed_arrL( hQMetaData->q_direction[i].band_data[j].q_azimuth, hQMetaData->q_direction[i].band_data[j].q_azimuth_fx, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); - floatToFixed_arrL( hQMetaData->q_direction[i].band_data[j].q_elevation, hQMetaData->q_direction[i].band_data[j].q_elevation_fx, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); -#endif - } - } -#endif - if ( ( error = ivas_qmetadata_enc_encode_fx( hMetaData, hQMetaData, 0 ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_qmetadata_enc_encode_fx( hMetaData, hQMetaData, 0 ) ), IVAS_ERR_OK ) ) { return error; } -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < hQMetaData->no_directions; i++ ) - { - for ( j = hQMetaData->q_direction[0].cfg.start_band; j < hQMetaData->q_direction[0].cfg.nbands; ++j ) - { - fixedToFloat_arrL( hQMetaData->q_direction[i].band_data[j].energy_ratio_fx, hQMetaData->q_direction[i].band_data[j].energy_ratio, Q30, MAX_PARAM_SPATIAL_SUBFRAMES ); - /*fixedToFloat_arrL( hQMetaData->q_direction[i].band_data[j].azimuth_fx, hQMetaData->q_direction[i].band_data[j].azimuth, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); - fixedToFloat_arrL( hQMetaData->q_direction[i].band_data[j].elevation_fx, hQMetaData->q_direction[i].band_data[j].elevation, Q22, MAX_PARAM_SPATIAL_SUBFRAMES );*/ - fixedToFloat_arrL( hQMetaData->q_direction[i].band_data[j].q_azimuth_fx, hQMetaData->q_direction[i].band_data[j].q_azimuth, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); - fixedToFloat_arrL( hQMetaData->q_direction[i].band_data[j].q_elevation_fx, hQMetaData->q_direction[i].band_data[j].q_elevation, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); - } - } -#endif - } - -#ifndef IVAS_FLOAT_FIXED - if ( ivas_format == MASA_ISM_FORMAT && ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) - { - /* Modify spatial metadata based on the MASA-to-total energy ratios */ - ivas_omasa_modify_masa_energy_ratios( hQMetaData, hMasa->data.hOmasaData->masa_to_total_energy_ratio ); - } -#else - Word16 b, d; - - IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) - { - for ( b = 0; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) - { - for ( d = 0; d < hQMetaData->no_directions; d++ ) - { - floatToFixed_arr32( hQMetaData->q_direction[d].band_data[b].energy_ratio, hQMetaData->q_direction[d].band_data[b].energy_ratio_fx, Q30, MAX_PARAM_SPATIAL_SUBFRAMES ); - } - } - - for ( b = 0; b < MAX_PARAM_SPATIAL_SUBFRAMES; ++b ) - { - floatToFixed_arr32( hMasa->data.hOmasaData->masa_to_total_energy_ratio[b], hMasa->data.hOmasaData->masa_to_total_energy_ratio_fx[b], Q30, MASA_MAXIMUM_CODING_SUBBANDS ); - } } test(); @@ -1130,292 +790,80 @@ ivas_error ivas_masa_encode( ivas_omasa_modify_masa_energy_ratios_fx( hQMetaData, hMasa->data.hOmasaData->masa_to_total_energy_ratio_fx ); } - IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) - { - for ( b = 0; b < hQMetaData->q_direction[0].cfg.nbands; b++ ) - { - for ( d = 0; d < hQMetaData->no_directions; d++ ) - { - fixedToFloat_arrL( hQMetaData->q_direction[d].band_data[b].energy_ratio_fx, hQMetaData->q_direction[d].band_data[b].energy_ratio, Q30, MAX_PARAM_SPATIAL_SUBFRAMES ); - } - } - } -#endif - *nb_bits_metadata = hMetaData->nb_bits_tot; + move16(); - if ( ivas_format == MASA_FORMAT && Opt_DTX_ON ) + test(); + IF( EQ_32( ivas_format, MASA_FORMAT ) && Opt_DTX_ON ) { /* save old values */ - uint8_t numCodingBands = hMasa->config.numCodingBands; - uint8_t numTwoDirBands = hMasa->config.numTwoDirBands; - int16_t nbands = hQMetaData->q_direction[0].cfg.nbands; - uint8_t numberOfDirections = hMasa->config.numberOfDirections; - uint8_t numberOfDirectionsMeta = hMasa->masaMetadata.descriptive_meta.numberOfDirections; - uint16_t numberOfDirectionsQMetaData = hQMetaData->no_directions; + UWord8 numCodingBands = hMasa->config.numCodingBands; + UWord8 numTwoDirBands = hMasa->config.numTwoDirBands; + Word16 nbands = hQMetaData->q_direction[0].cfg.nbands; + UWord8 numberOfDirections = hMasa->config.numberOfDirections; + UWord8 numberOfDirectionsMeta = hMasa->masaMetadata.descriptive_meta.numberOfDirections; + UWord16 numberOfDirectionsQMetaData = hQMetaData->no_directions; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); - if ( !( hMasa->config.numberOfDirections == 1 && hQMetaData->q_direction->cfg.nbands == 5 ) ) + test(); + IF( !( EQ_16( hMasa->config.numberOfDirections, 1 ) && EQ_16( hQMetaData->q_direction->cfg.nbands, 5 ) ) ) { - for ( i = 0; i < MASA_MAXIMUM_DIRECTIONS; i++ ) + FOR( i = 0; i < MASA_MAXIMUM_DIRECTIONS; i++ ) { - for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - mvr2r( h_orig_metadata[i].azimuth[j], hMasa->masaMetadata.directional_meta[i].azimuth[j], MASA_FREQUENCY_BANDS ); - mvr2r( h_orig_metadata[i].elevation[j], hMasa->masaMetadata.directional_meta[i].elevation[j], MASA_FREQUENCY_BANDS ); - mvr2r( h_orig_metadata[i].energy_ratio[j], hMasa->masaMetadata.directional_meta[i].energy_ratio[j], MASA_FREQUENCY_BANDS ); + Copy32( h_orig_metadata[i].azimuth_fx[j], hMasa->masaMetadata.directional_meta[i].azimuth_fx[j], MASA_FREQUENCY_BANDS ); + Copy32( h_orig_metadata[i].elevation_fx[j], hMasa->masaMetadata.directional_meta[i].elevation_fx[j], MASA_FREQUENCY_BANDS ); + Copy32( h_orig_metadata[i].energy_ratio_fx[j], hMasa->masaMetadata.directional_meta[i].energy_ratio_fx[j], MASA_FREQUENCY_BANDS ); } } /* Force to have 5 bands and 1 direction */ hMasa->config.numCodingBands = 5; hMasa->config.numTwoDirBands = 0; -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - MASA_METADATA_HANDLE hMeta = &( hMasa->masaMetadata ); - Word16 numSf = hMasa->config.joinedSubframes == TRUE ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES; - for ( i = 0; i < 4; i++ ) - { - for ( j = 0; j < 24; j++ ) - { - f2me( hMasa->data.energy[i][j], &hMasa->data.energy_fx[i][j], &hMasa->data.energy_e[i][j] ); - } - } - if ( hMasa->config.numCodingBands <= MAX_REDUCED_NBANDS ) - { - for ( i = 0; i < hMasa->config.numberOfDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - floatToFixed_arrL32( hMeta->directional_meta[i].azimuth[j], hMeta->directional_meta[i].azimuth_fx[j], Q22, MASA_FREQUENCY_BANDS ); - floatToFixed_arrL32( hMeta->directional_meta[i].elevation[j], hMeta->directional_meta[i].elevation_fx[j], Q22, MASA_FREQUENCY_BANDS ); - floatToFixed_arrL32( hMeta->directional_meta[i].energy_ratio[j], hMeta->directional_meta[i].energy_ratio_fx[j], Q30, MASA_FREQUENCY_BANDS ); - } - } - if ( hMasa->config.useCoherence && hMasa->config.coherencePresent ) - { - for ( i = 0; i < hMasa->config.numberOfDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - floatToFixed_arr( hMeta->directional_meta[i].spread_coherence[j], hMeta->directional_meta[i].spread_coherence_fx[j], Q15, MASA_FREQUENCY_BANDS ); - if ( i == 0 ) - { - floatToFixed_arr( hMeta->common_meta.surround_coherence[j], hMeta->common_meta.surround_coherence_fx[j], Q15, MASA_FREQUENCY_BANDS ); - } - } - } - } - } - if ( hMasa->config.mergeRatiosOverSubframes ) - { - if ( hMasa->config.useCoherence && hMasa->config.coherencePresent ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - floatToFixed_arr( hMeta->common_meta.surround_coherence[j], hMeta->common_meta.surround_coherence_fx[j], Q15, MASA_FREQUENCY_BANDS ); - } - } - for ( i = 0; i < hMasa->config.numberOfDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - floatToFixed_arrL32( hMeta->directional_meta[i].energy_ratio[j], hMeta->directional_meta[i].energy_ratio_fx[j], Q30, MASA_FREQUENCY_BANDS ); - } - } - } -#endif + move16(); + move16(); + combine_freqbands_and_subframes_fx( hMasa ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < 4; i++ ) - { - for ( j = 0; j < 24; j++ ) - { - hMasa->data.energy[i][j] = me2f( hMasa->data.energy_fx[i][j], hMasa->data.energy_e[i][j] ); - } - } - if ( hMasa->config.numCodingBands <= MAX_REDUCED_NBANDS ) - { - for ( i = 0; i < hMasa->config.numberOfDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - fixedToFloat_arrL32( hMeta->directional_meta[i].azimuth_fx[j], hMeta->directional_meta[i].azimuth[j], Q22, MASA_FREQUENCY_BANDS ); - fixedToFloat_arrL32( hMeta->directional_meta[i].elevation_fx[j], hMeta->directional_meta[i].elevation[j], Q22, MASA_FREQUENCY_BANDS ); - fixedToFloat_arrL32( hMeta->directional_meta[i].energy_ratio_fx[j], hMeta->directional_meta[i].energy_ratio[j], Q30, MASA_FREQUENCY_BANDS ); - } - } - if ( hMasa->config.useCoherence && hMasa->config.coherencePresent ) - { - for ( i = 0; i < hMasa->config.numberOfDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - fixedToFloat_arr( hMeta->directional_meta[i].spread_coherence_fx[j], hMeta->directional_meta[i].spread_coherence[j], Q15, MASA_FREQUENCY_BANDS ); - if ( i == 0 ) - { - fixedToFloat_arr( hMeta->common_meta.surround_coherence_fx[j], hMeta->common_meta.surround_coherence[j], Q15, MASA_FREQUENCY_BANDS ); - } - } - } - } - } - if ( hMasa->config.mergeRatiosOverSubframes ) - { - if ( hMasa->config.useCoherence && hMasa->config.coherencePresent ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - fixedToFloat_arr( hMeta->common_meta.surround_coherence_fx[j], hMeta->common_meta.surround_coherence[j], Q15, MASA_FREQUENCY_BANDS ); - } - } - for ( i = 0; i < hMasa->config.numberOfDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) /* NB: for numSf==1, operates only on first sub-frame */ - { - fixedToFloat_arrL32( hMeta->directional_meta[i].energy_ratio_fx[j], hMeta->directional_meta[i].energy_ratio[j], Q30, MASA_FREQUENCY_BANDS ); - } - } - } -#endif -#else - combine_freqbands_and_subframes( hMasa ); -#endif + hQMetaData->q_direction[0].cfg.nbands = 5; + move16(); - if ( hMasa->config.numberOfDirections == 2 && hMasa->config.numTwoDirBands < hMasa->config.numCodingBands ) + test(); + IF( EQ_16( hMasa->config.numberOfDirections, 2 ) && LT_16( hMasa->config.numTwoDirBands, hMasa->config.numCodingBands ) ) { /* Combine directions */ -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - numCodingBands = hMasa->config.numCodingBands; - Word16 numDirections = hMasa->config.numberOfDirections; - numSf = hMasa->config.joinedSubframes == TRUE ? 1 : MAX_PARAM_SPATIAL_SUBFRAMES; - Word16 computeCoherence = hMasa->config.useCoherence && hMasa->config.coherencePresent; - hMeta = &( hMasa->masaMetadata ); - for ( i = 0; i < numDirections; i++ ) - { - for ( j = 0; j < numSf; j++ ) - { - for ( int k = 0; k < hMasa->config.numCodingBands; k++ ) - { - hMeta->directional_meta[i].energy_ratio_fx[j][k] = floatToFixed( hMeta->directional_meta[i].energy_ratio[j][k], Q30 ); - hMeta->directional_meta[i].azimuth_fx[j][k] = floatToFixed( hMeta->directional_meta[i].azimuth[j][k], Q22 ); - hMeta->directional_meta[i].elevation_fx[j][k] = floatToFixed( hMeta->directional_meta[i].elevation[j][k], Q22 ); - } - } - } - /* Combine directions on the remaining bands */ - for ( i = 0; i < hMasa->config.numCodingBands; i++ ) - { - for ( j = 0; j < numSf; j++ ) - { - hMeta->directional_meta[0].spread_coherence_fx[j][i] = (Word16) floatToFixed( hMeta->directional_meta[0].spread_coherence[j][i], Q15 ); - hMeta->directional_meta[1].spread_coherence_fx[j][i] = (Word16) floatToFixed( hMeta->directional_meta[1].spread_coherence[j][i], Q15 ); - hMeta->common_meta.surround_coherence_fx[j][i] = (Word16) floatToFixed( hMeta->common_meta.surround_coherence[j][i], Q15 ); - } - } - - /* Estimate the importance of having two directions instead of one */ - for ( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) - { - hMasa->data.importanceWeight_fx[i] = floatToFixed( hMasa->data.importanceWeight[i], Q30 ); - } -#endif ivas_masa_combine_directions_fx( hMasa ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < numCodingBands; i++ ) - { - if ( hMasa->data.twoDirBands[i] == 0 ) - { - for ( j = 0; j < numSf; j++ ) - { - hMeta->directional_meta[0].azimuth[j][i] = fixedToFloat( hMeta->directional_meta[0].azimuth_fx[j][i], Q22 ); - hMeta->directional_meta[0].elevation[j][i] = fixedToFloat( hMeta->directional_meta[0].elevation_fx[j][i], Q22 ); - if ( computeCoherence ) - { - hMeta->directional_meta[0].spread_coherence[j][i] = fixedToFloat( hMeta->directional_meta[0].spread_coherence_fx[j][i], Q15 ); - hMeta->common_meta.surround_coherence[j][i] = fixedToFloat( hMeta->common_meta.surround_coherence_fx[j][i], Q15 ); - } - hMeta->directional_meta[0].energy_ratio[j][i] = fixedToFloat( hMeta->directional_meta[0].energy_ratio_fx[j][i], Q30 ); - hMeta->directional_meta[1].energy_ratio[j][i] = fixedToFloat( hMeta->directional_meta[1].energy_ratio_fx[j][i], Q30 ); - } - } - } -#endif -#else - ivas_masa_combine_directions( hMasa ); -#endif - /* If we joined all bands, then metadata is now one directional. */ - if ( hMasa->config.numTwoDirBands == 0 ) + IF( hMasa->config.numTwoDirBands == 0 ) { hMasa->config.numberOfDirections = 1; hMasa->masaMetadata.descriptive_meta.numberOfDirections = 0; hQMetaData->no_directions = 1; + move16(); + move16(); + move16(); } } -#ifdef IVAS_FLOAT_FIXED move_metadata_to_qmetadata_fx( hMasa, hQMetaData ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( d = 0; d < hQMetaData->no_directions; d++ ) - { - for ( i = hQMetaData->q_direction[d].cfg.start_band; i < hQMetaData->q_direction[d].cfg.nbands; i++ ) - { - for ( j = 0; j < hQMetaData->q_direction[d].cfg.nblocks; j++ ) - { - hQMetaData->q_direction[d].band_data[i].elevation[j] = fix_to_float( hQMetaData->q_direction[d].band_data[i].elevation_fx[j], Q22 ); - hQMetaData->q_direction[d].band_data[i].azimuth[j] = fix_to_float( hQMetaData->q_direction[d].band_data[i].azimuth_fx[j], Q22 ); - hQMetaData->q_direction[d].band_data[i].energy_ratio[j] = fixedToFloat( hQMetaData->q_direction[d].band_data[i].energy_ratio_fx[j], Q30 ); - } - } - } -#endif -#else - move_metadata_to_qmetadata( hMasa, hQMetaData ); -#endif - FOR( j = hQMetaData->q_direction[0].cfg.start_band; j < hQMetaData->q_direction[0].cfg.nbands; ++j ) { -#ifdef IVAS_FLOAT_FIXED - /*=====================================flt-2-fix============================================*/ - hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[0] = floatToFixed( hQMetaData->q_direction[0].band_data[j].energy_ratio[0], Q30 ); - /*=====================================flt-2-fix============================================*/ - hQMetaData->q_direction[0].band_data[j].energy_ratio_index[0] = masa_sq_fx( L_sub( ONE_IN_Q30, hQMetaData->q_direction[0].band_data[j].energy_ratio_fx[0] ), diffuseness_thresholds_fx, DIRAC_DIFFUSE_LEVELS ); -#else - hQMetaData->q_direction[0].band_data[j].energy_ratio_index[0] = masa_sq( 1.0f - hQMetaData->q_direction[0].band_data[j].energy_ratio[0], diffuseness_thresholds, DIRAC_DIFFUSE_LEVELS ); -#endif + move32(); } } free( h_orig_metadata ); -#ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - IVAS_QDIRECTION *q_direction; - q_direction = &( hQMetaData->q_direction[0] ); - FOR( b = 0; b < q_direction->cfg.nbands; b++ ) - { - FOR( int m = 0; m < q_direction->cfg.nblocks; m++ ) - { - q_direction->band_data[b].azimuth_fx[m] = floatToFixed( q_direction->band_data[b].azimuth[m], Q22 ); - q_direction->band_data[b].elevation_fx[m] = floatToFixed( q_direction->band_data[b].elevation[m], Q22 ); - } - } -#endif + ivas_qmetadata_enc_sid_encode_fx( hMetaData, hQMetaData, masa_sid_descriptor, ivas_format ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - FOR( b = 0; b < q_direction->cfg.nbands; b++ ) - { - q_direction->band_data[b].q_azimuth[0] = fixedToFloat( q_direction->band_data[b].q_azimuth_fx[0], Q22 ); - q_direction->band_data[b].q_elevation[0] = fixedToFloat( q_direction->band_data[b].q_elevation_fx[0], Q22 ); - } -#endif -#else - ivas_qmetadata_enc_sid_encode( hMetaData, hQMetaData, masa_sid_descriptor, ivas_format ); -#endif /* restore old values */ hMasa->config.numCodingBands = numCodingBands; @@ -1424,7 +872,31 @@ ivas_error ivas_masa_encode( hMasa->config.numberOfDirections = numberOfDirections; hMasa->masaMetadata.descriptive_meta.numberOfDirections = numberOfDirectionsMeta; hQMetaData->no_directions = numberOfDirectionsQMetaData; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + } + +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) + { + fixedToFloat_arrL32( hMasa->data.energy_fx[i], hMasa->data.energy[i], hMasa->data.q_energy, MASA_FREQUENCY_BANDS ); + } + for ( i = 0; i < hQMetaData->no_directions; i++ ) + { + for ( j = hQMetaData->q_direction[0].cfg.start_band; j < hQMetaData->q_direction[0].cfg.nbands; ++j ) + { + fixedToFloat_arrL( hQMetaData->q_direction[i].band_data[j].energy_ratio_fx, hQMetaData->q_direction[i].band_data[j].energy_ratio, Q30, MAX_PARAM_SPATIAL_SUBFRAMES ); + fixedToFloat_arrL( hQMetaData->q_direction[i].band_data[j].azimuth_fx, hQMetaData->q_direction[i].band_data[j].azimuth, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + fixedToFloat_arrL( hQMetaData->q_direction[i].band_data[j].elevation_fx, hQMetaData->q_direction[i].band_data[j].elevation, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + fixedToFloat_arrL( hQMetaData->q_direction[i].band_data[j].q_azimuth_fx, hQMetaData->q_direction[i].band_data[j].q_azimuth, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + fixedToFloat_arrL( hQMetaData->q_direction[i].band_data[j].q_elevation_fx, hQMetaData->q_direction[i].band_data[j].q_elevation, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); + } } +#endif return IVAS_ERR_OK; } @@ -2243,20 +1715,6 @@ ivas_error ivas_masa_enc_config( floatToFixed_arr32( hMasa->data.dir_align_state.previous_ele_dir2, hMasa->data.dir_align_state.previous_ele_dir2_fx, Q22, MASA_FREQUENCY_BANDS ); floatToFixed_arr32( hMasa->data.dir_align_state.previous_azi_dir1, hMasa->data.dir_align_state.previous_azi_dir1_fx, Q22, MASA_FREQUENCY_BANDS ); floatToFixed_arr32( hMasa->data.dir_align_state.previous_azi_dir2, hMasa->data.dir_align_state.previous_azi_dir2_fx, Q22, MASA_FREQUENCY_BANDS ); - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - hMasa->masaMetadata.directional_meta[0].azimuth_fx[i][j] = float_to_fix( hMasa->masaMetadata.directional_meta[0].azimuth[i][j], Q22 ); - hMasa->masaMetadata.directional_meta[0].elevation_fx[i][j] = float_to_fix( hMasa->masaMetadata.directional_meta[0].elevation[i][j], Q22 ); - hMasa->masaMetadata.directional_meta[0].energy_ratio_fx[i][j] = float_to_fix( hMasa->masaMetadata.directional_meta[0].energy_ratio[i][j], Q30 ); - hMasa->masaMetadata.directional_meta[0].spread_coherence_fx[i][j] = float_to_fix16( hMasa->masaMetadata.directional_meta[0].spread_coherence[i][j], Q15 ); - hMasa->masaMetadata.directional_meta[1].azimuth_fx[i][j] = float_to_fix( hMasa->masaMetadata.directional_meta[1].azimuth[i][j], Q22 ); - hMasa->masaMetadata.directional_meta[1].elevation_fx[i][j] = float_to_fix( hMasa->masaMetadata.directional_meta[1].elevation[i][j], Q22 ); - hMasa->masaMetadata.directional_meta[1].energy_ratio_fx[i][j] = float_to_fix( hMasa->masaMetadata.directional_meta[1].energy_ratio[i][j], Q30 ); - hMasa->masaMetadata.directional_meta[1].spread_coherence_fx[i][j] = float_to_fix16( hMasa->masaMetadata.directional_meta[1].spread_coherence[i][j], Q15 ); - } - } #endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED masa_metadata_direction_alignment_fx( hMasa ); #ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED @@ -2264,46 +1722,13 @@ ivas_error ivas_masa_enc_config( fixedToFloat_arrL( hMasa->data.dir_align_state.previous_ele_dir2_fx, hMasa->data.dir_align_state.previous_ele_dir2, Q22, MASA_FREQUENCY_BANDS ); fixedToFloat_arrL( hMasa->data.dir_align_state.previous_azi_dir1_fx, hMasa->data.dir_align_state.previous_azi_dir1, Q22, MASA_FREQUENCY_BANDS ); fixedToFloat_arrL( hMasa->data.dir_align_state.previous_azi_dir2_fx, hMasa->data.dir_align_state.previous_ele_dir2, Q22, MASA_FREQUENCY_BANDS ); - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - hMasa->masaMetadata.directional_meta[0].azimuth[i][j] = fixedToFloat( hMasa->masaMetadata.directional_meta[0].azimuth_fx[i][j], Q22 ); - hMasa->masaMetadata.directional_meta[0].elevation[i][j] = fixedToFloat( hMasa->masaMetadata.directional_meta[0].elevation_fx[i][j], Q22 ); - hMasa->masaMetadata.directional_meta[0].energy_ratio[i][j] = fixedToFloat( hMasa->masaMetadata.directional_meta[0].energy_ratio_fx[i][j], Q30 ); - hMasa->masaMetadata.directional_meta[0].spread_coherence[i][j] = fixedToFloat( hMasa->masaMetadata.directional_meta[0].spread_coherence_fx[i][j], Q15 ); - hMasa->masaMetadata.directional_meta[1].azimuth[i][j] = fixedToFloat( hMasa->masaMetadata.directional_meta[1].azimuth_fx[i][j], Q22 ); - hMasa->masaMetadata.directional_meta[1].elevation[i][j] = fixedToFloat( hMasa->masaMetadata.directional_meta[1].elevation_fx[i][j], Q22 ); - hMasa->masaMetadata.directional_meta[1].energy_ratio[i][j] = fixedToFloat( hMasa->masaMetadata.directional_meta[1].energy_ratio_fx[i][j], Q30 ); - hMasa->masaMetadata.directional_meta[1].spread_coherence[i][j] = fixedToFloat( hMasa->masaMetadata.directional_meta[1].spread_coherence_fx[i][j], Q15 ); - } - } #endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - MASA_METADATA_HANDLE current_meta = &( hMasa->masaMetadata ); - MASA_METADATA_HANDLE previous_meta = &( hMasa->data.sync_state.previous_metadata ); for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth_fx[i][j] = float_to_fix( current_meta->directional_meta[k].azimuth[i][j], Q22 ); - current_meta->directional_meta[k].elevation_fx[i][j] = float_to_fix( current_meta->directional_meta[k].elevation[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio_fx[i][j] = float_to_fix( current_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence_fx[i][j] = float_to_fix16( current_meta->directional_meta[k].spread_coherence[i][j], Q15 ); - previous_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].azimuth[i][j], Q22 ); - previous_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].elevation[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - } f2me( hMasa->data.energy[i][j], &hMasa->data.energy_fx[i][j], &hMasa->data.energy_e[i][j] ); - current_meta->common_meta.surround_coherence_fx[i][j] = float_to_fix16( current_meta->common_meta.surround_coherence[i][j], Q15 ); - current_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = float_to_fix( current_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio_fx[i][j] = float_to_fix( current_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->common_meta.surround_coherence[i][j], Q15 ) ); - previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); } } #endif // IVAS_FLOAT_FIXED_CONVERSIONS @@ -2317,31 +1742,7 @@ ivas_error ivas_masa_enc_config( /* Inspect metadata for parameter changes that affect coding. */ detect_metadata_composition_fx( hMasa, &joinedSubframes, &coherencePresent, &isActualTwoDir ); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( current_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - current_meta->directional_meta[k].elevation[i][j] = fixedToFloat( current_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( current_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( current_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - previous_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( previous_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - previous_meta->directional_meta[k].elevation[i][j] = fixedToFloat( previous_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( previous_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( previous_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - } - current_meta->common_meta.surround_coherence[i][j] = fixedToFloat( current_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - current_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.surround_coherence[i][j] = fixedToFloat( previous_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - previous_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - } - } -#endif // IVAS_FLOAT_FIXED_CONVERSIONS + hMasa->config.joinedSubframes = joinedSubframes; hMasa->config.coherencePresent = coherencePresent; hMasa->config.numberOfDirections = ( hMasa->masaMetadata.descriptive_meta.numberOfDirections + 1 ) == 2 && isActualTwoDir ? 2 : 1; @@ -2372,7 +1773,69 @@ ivas_error ivas_masa_enc_config( ivas_masa_set_coding_config_fx( &( hMasa->config ), hMasa->data.band_mapping, ivas_total_brate, st_ivas->nchan_transport, ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) ); } #endif +#ifdef IVAS_FLOAT_FIXED + /* Setup importance weights for two-direction band selection. */ + IF( EQ_16( hMasa->config.numberOfDirections, 2 ) ) + { + set32_fx( hMasa->data.importanceWeight_fx, ONE_IN_Q30, hMasa->config.numCodingBands ); + + IF( EQ_16( hMasa->config.numCodingBands, 5 ) ) + { + hMasa->data.importanceWeight_fx[4] = 751619277; // 0.7f in Q30 + move32(); + } + ELSE IF( EQ_16( hMasa->config.numCodingBands, 8 ) ) + { + hMasa->data.importanceWeight_fx[7] = 751619277; // 0.7f in Q30 + move32(); + } + ELSE IF( EQ_16( hMasa->config.numCodingBands, 10 ) ) + { + hMasa->data.importanceWeight_fx[8] = 751619277; // 0.7f in Q30 + hMasa->data.importanceWeight_fx[9] = 107374182; // 0.1f in Q30 + move32(); + move32(); + } + ELSE IF( EQ_16( hMasa->config.numCodingBands, 12 ) ) + { + hMasa->data.importanceWeight_fx[10] = 751619277; // 0.7f in Q30 + hMasa->data.importanceWeight_fx[11] = 107374182; // 0.1f in Q30 + move32(); + move32(); + } + ELSE IF( EQ_16( hMasa->config.numCodingBands, 18 ) ) + { + hMasa->data.importanceWeight_fx[14] = 858993459; // 0.8f in Q30 + hMasa->data.importanceWeight_fx[15] = 536870912; // 0.5f in Q30 + hMasa->data.importanceWeight_fx[16] = 214748365; // 0.2f in Q30 + hMasa->data.importanceWeight_fx[17] = 0; + move32(); + move32(); + move32(); + move32(); + } + ELSE IF( EQ_16( hMasa->config.numCodingBands, 24 ) ) + { + hMasa->data.importanceWeight_fx[20] = 858993459; // 0.8f in Q30 + hMasa->data.importanceWeight_fx[21] = 536870912; // 0.5f in Q30 + hMasa->data.importanceWeight_fx[22] = 214748365; // 0.2f in Q30 + hMasa->data.importanceWeight_fx[23] = 0; + move32(); + move32(); + move32(); + move32(); + } + IF( EQ_16( hMasa->config.numTwoDirBands, hMasa->config.numCodingBands ) ) + { + set8_fx( (Word8 *) hMasa->data.twoDirBands, 1, hMasa->config.numCodingBands ); + } + } + ELSE + { + set8_fx( (Word8 *) hMasa->data.twoDirBands, 0, hMasa->config.numCodingBands ); + } +#else /* Setup importance weights for two-direction band selection. */ if ( hMasa->config.numberOfDirections == 2 ) { @@ -2420,6 +1883,7 @@ ivas_error ivas_masa_enc_config( { set_c( (int8_t *) hMasa->data.twoDirBands, 0, hMasa->config.numCodingBands ); } +#endif /* Set qmeta to correct values */ if ( ( error = ivas_qmetadata_allocate_memory( hQMetaData, hMasa->config.numCodingBands, hMasa->config.numberOfDirections == 2 && hMasa->config.numTwoDirBands != 0 ? 2 : 1, hMasa->config.useCoherence ) ) != IVAS_ERR_OK ) @@ -2569,7 +2033,7 @@ ivas_error ivas_masa_enc_config( return error; } #endif // IVAS_FLOAT_FIXED - +#ifdef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------------* * ivas_masa_surrcoh_signicant() * @@ -2644,7 +2108,7 @@ UWord8 ivas_masa_surrcoh_signicant_fx( return 0; } - +#else /*-----------------------------------------------------------------------* * ivas_masa_surrcoh_signicant() * @@ -2688,7 +2152,7 @@ uint8_t ivas_masa_surrcoh_signicant( return 0; /* Surrounding coherence was not significant in any subframe */ } - +#endif /*-----------------------------------------------------------------------* * Local functions @@ -6836,7 +6300,7 @@ void ivas_merge_masa_metadata_fx( return; } -#endif // IVAS_FLOAT_FIXED +#else void ivas_merge_masa_metadata( MASA_ENCODER_HANDLE hMasa, /* i/o: MASA enc handle. source for MASA metadata and combined metadata will be here */ @@ -6953,7 +6417,7 @@ void ivas_merge_masa_metadata( return; } - +#endif #ifdef IVAS_FLOAT_FIXED static void quantize_ratio_ism_vector_ivas_fx( const Word16 *ratio_ism, /* ratio_ism_e */ @@ -8981,7 +8445,7 @@ static void ivas_encode_masaism_metadata_fx( { FOR( obj = 0; obj < nchan_ism; obj++ ) { - assert( ( hOmasaData->energy_ratio_ism[sf][band][obj] >= 0 ) && ( hOmasaData->energy_ratio_ism[sf][band][obj] <= 1 ) ); + assert( ( hOmasaData->energy_ratio_ism_fx[sf][band][obj] >= 0 ) && ( hOmasaData->energy_ratio_ism_fx[sf][band][obj] <= ONE_IN_Q30 ) ); ratio_ism_fx[band][obj] = extract_h( hOmasaData->energy_ratio_ism_fx[sf][band][obj] ); // Q14 move16(); } @@ -9165,7 +8629,7 @@ void ivas_merge_masa_transports_fx( return; } -#endif // IVAS_FLOAT_FIXED +#else void ivas_merge_masa_transports( float data_in_f1[][L_FRAME48k], @@ -9186,3 +8650,4 @@ void ivas_merge_masa_transports( return; } +#endif diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c index a6316ea3dbea53badcb67496eebc8ff63961a099..f74174689c0debe8ea908682f37345ae19c98884 100644 --- a/lib_enc/ivas_mc_param_enc.c +++ b/lib_enc/ivas_mc_param_enc.c @@ -829,31 +829,11 @@ void ivas_param_mc_enc_fx( #ifdef IVAS_FLOAT_FIXED_CONVERSIONS for ( ch = 0; ch < st_ivas->nchan_transport; ch++ ) { - Word16 cpe_idx = ch / 2; - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.firState1 = (Word16) floatToFixed( st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.firState1_flt, -1 ); - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.firState2 = (Word16) floatToFixed( st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.firState2_flt, -1 ); - - for ( i = 0; i < NSUBBLOCKS + MAX_TD_DELAY + 1; i++ ) - { - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.accSubblockNrg[i] = floatToFixed( st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.accSubblockNrg_flt[i], 7 ); - } - - for ( i = 0; i < NSUBBLOCKS + MAX_TD_DELAY; i++ ) - { - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.subblockNrg[i] = floatToFixed( st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.subblockNrg_flt[i], 7 ); - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.subblockNrgChange[i] = (Word16) floatToFixed( st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.subblockNrgChange_flt[i], 7 ); - } - - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.subblockNrg_e = 31 - 7; - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.accSubblockNrg_e = 31 - 7; - - for ( i = 0; i < L_FRAME_MAX / NSUBBLOCKS; i++ ) - { - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->delayBuffer.buffer[i] = (Word16) floatToFixed( st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->delayBuffer.buffer_flt[i], 7 ); - } - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->transientDetector.attackRatioThreshold = float_to_fix16( st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->transientDetector.attackRatioThreshold_flt, Q15 - ATTACKTHRESHOLD_E ); - - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.facAccSubblockNrg = float_to_fix16( st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.facAccSubblockNrg_flt, 15 ); + Word16 cpe_idx = shr( ch, 1 ); + st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.subblockNrg_e = 31 - Q7; + st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.accSubblockNrg_e = 31 - Q7; + move16(); + move16(); } #endif @@ -1014,35 +994,26 @@ void ivas_param_mc_enc_fx( hParamMC->hMetadataPMC.last_coded_bwidth = hParamMC->hMetadataPMC.coded_bwidth; move16(); -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( ch = 0; ch < st_ivas->nchan_transport; ch++ ) + FOR( ch = 0; ch < st_ivas->nchan_transport; ch++ ) { - Word16 cpe_idx = ch / 2; - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.firState1_flt = fixedToFloat( (Word32) st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.firState1, -1 ); - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.firState2_flt = fixedToFloat( (Word32) st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.firState2, -1 ); - - for ( i = 0; i < NSUBBLOCKS + MAX_TD_DELAY; i++ ) - { - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.subblockNrg_flt[i] = fixedToFloat( st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.subblockNrg[i], 7 ); - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.subblockNrgChange_flt[i] = fixedToFloat( (Word32) st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.subblockNrgChange[i], 7 ); - } - - for ( i = 0; i < NSUBBLOCKS + MAX_TD_DELAY + 1; i++ ) + Word16 cpe_idx = shr( ch, 1 ); + FOR( i = 0; i < NSUBBLOCKS + MAX_TD_DELAY; i++ ) { - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.accSubblockNrg_flt[i] = fixedToFloat( st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.accSubblockNrg[i], 7 ); + st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.subblockNrg_e = 31 - Q7; + move16(); } - - for ( i = 0; i < L_FRAME_MAX / NSUBBLOCKS; i++ ) + FOR( i = 0; i < NSUBBLOCKS + MAX_TD_DELAY + 1; i++ ) { - st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->delayBuffer.buffer_flt[i] = fixedToFloat( (Word32) st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->delayBuffer.buffer[i], -1 ); + st_ivas->hCPE[cpe_idx]->hCoreCoder[ch - cpe_idx * CPE_CHANNELS]->hTranDet->subblockEnergies.accSubblockNrg_e = 31 - Q7; + move16(); } } +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS for ( i = 0; i < hParamMC->hFbMixer->fb_cfg->num_in_chans; i++ ) { fixedToFloat_arrL( hParamMC->hFbMixer->ppFilterbank_prior_input_fx[i], hParamMC->hFbMixer->ppFilterbank_prior_input[i], Q11, input_frame / PARAM_MC_MDFT_NO_SLOTS ); } - #endif pop_wmops(); diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index ddb275e08e089e79849f0721ecbbf10564846071..7e4902855613a5683f132c32d5b963c7f8276011 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -1442,7 +1442,7 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx( Word16 *q_cov_real[IVAS_SPAR_MAX_CH]; Word16 *q_cov_dtx_real[IVAS_SPAR_MAX_CH]; Word32 *pp_in_fr_real_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH], *pp_in_fr_imag_fx[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH]; - Word16 q_ppIn_FR[MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH]; + Word16 q_ppIn_FR; Word32 rxy_fx, ryy_fx; Word32 rxx_fx; @@ -1588,7 +1588,7 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx( set_s( q_cov_dtx_real[i], Q31, MC_PARAMUPMIX_NCH ); } - set_s( q_ppIn_FR, sub( Q14, gb ), MC_PARAMUPMIX_COMBINATIONS * MC_PARAMUPMIX_NCH ); + q_ppIn_FR = sub( Q14, gb ); ivas_enc_cov_handler_process_fx( hMCParamUpmix->hCovEnc[b], pp_in_fr_real_fx, pp_in_fr_imag_fx, q_ppIn_FR, cov_real_fx, q_cov_real, cov_dtx_real_fx, q_cov_dtx_real, hMCParamUpmix->hFbMixer->pFb, 0, hMCParamUpmix->hFbMixer->pFb->filterbank_num_bands, MC_PARAMUPMIX_NCH, 0 /*dtx_vad*/, transient_det[b], HOA_md_ind, NULL, NULL, NULL, 0, 0 ); FOR( i = 0; i < MC_PARAMUPMIX_NCH; i++ ) diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 59ea11b012f608f69c6eabbbdd516d77de29f883..f326b1a32bde73183c91b2a1f5ee1f8f75a78343 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -42,6 +42,7 @@ #ifdef IVAS_FLOAT_FIXED #include "prot_fx.h" #include "ivas_prot_fx.h" +#include "prot_fx_enc.h" #include "rom_com.h" #endif @@ -438,6 +439,7 @@ ivas_error ivas_mct_enc( hMCT->p_orig_spectrum_long[cpe_id][n] = orig_spectrum_long[cpe_id][n]; #ifdef MSAN_FIX set_zero( mdst_spectrum_long[cpe_id][n], L_FRAME48k ); + set_zero( orig_spectrum_long[cpe_id][n], L_FRAME48k ); #endif #endif set32_fx( orig_spectrum_long_fx[cpe_id][n], 0, L_FRAME48k ); @@ -1770,31 +1772,11 @@ static ivas_error ivas_mc_enc_reconfig( } #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - MASA_METADATA_HANDLE current_meta = &( st_ivas->hMasa->masaMetadata ); - MASA_METADATA_HANDLE previous_meta = &( st_ivas->hMasa->data.sync_state.previous_metadata ); - fixedToFloat_arrL( st_ivas->hMasa->data.importanceWeight_fx, st_ivas->hMasa->data.importanceWeight, 30, 24 ); for ( int i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( current_meta->directional_meta[k].azimuth[i][j], Q22 ); - current_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( current_meta->directional_meta[k].elevation[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( current_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( current_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - previous_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].azimuth[i][j], Q22 ); - previous_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].elevation[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - } f2me( st_ivas->hMasa->data.energy[i][j], &st_ivas->hMasa->data.energy_fx[i][j], &st_ivas->hMasa->data.energy_e[i][j] ); - current_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( current_meta->common_meta.surround_coherence[i][j], Q15 ) ); - current_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( current_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( current_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->common_meta.surround_coherence[i][j], Q15 ) ); - previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); } } #endif // IVAS_FLOAT_FIXED_CONVERSIONS @@ -1803,29 +1785,6 @@ static ivas_error ivas_mc_enc_reconfig( return error; } #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( int i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( current_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - current_meta->directional_meta[k].elevation[i][j] = fixedToFloat( current_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( current_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( current_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - previous_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( previous_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - previous_meta->directional_meta[k].elevation[i][j] = fixedToFloat( previous_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( previous_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( previous_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - } - current_meta->common_meta.surround_coherence[i][j] = fixedToFloat( current_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - current_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.surround_coherence[i][j] = fixedToFloat( previous_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - previous_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - } - } if ( st_ivas->hQMetaData->q_direction != NULL ) { for ( int band = 0; band < st_ivas->hMasa->config.numCodingBands; band++ ) @@ -1841,7 +1800,6 @@ static ivas_error ivas_mc_enc_reconfig( } } } - fixedToFloat_arrL( st_ivas->hMasa->data.importanceWeight_fx, st_ivas->hMasa->data.importanceWeight, 30, 24 ); #endif // IVAS_FLOAT_FIXED_CONVERSIONS #else if ( ( error = ivas_mcmasa_enc_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -1855,31 +1813,11 @@ static ivas_error ivas_mc_enc_reconfig( /* reconfigure McMASA instance */ #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - MASA_METADATA_HANDLE current_meta = &( st_ivas->hMasa->masaMetadata ); - MASA_METADATA_HANDLE previous_meta = &( st_ivas->hMasa->data.sync_state.previous_metadata ); - fixedToFloat_arrL( st_ivas->hMasa->data.importanceWeight_fx, st_ivas->hMasa->data.importanceWeight, 30, 24 ); for ( int i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( current_meta->directional_meta[k].azimuth[i][j], Q22 ); - current_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( current_meta->directional_meta[k].elevation[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( current_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( current_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - previous_meta->directional_meta[k].azimuth_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].azimuth[i][j], Q22 ); - previous_meta->directional_meta[k].elevation_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].elevation[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio_fx[i][j] = floatToFixed( previous_meta->directional_meta[k].energy_ratio[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->directional_meta[k].spread_coherence[i][j], Q15 ) ); - } f2me( st_ivas->hMasa->data.energy[i][j], &st_ivas->hMasa->data.energy_fx[i][j], &st_ivas->hMasa->data.energy_e[i][j] ); - current_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( current_meta->common_meta.surround_coherence[i][j], Q15 ) ); - current_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( current_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( current_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.surround_coherence_fx[i][j] = (Word16) min( 32767, floatToFixed( previous_meta->common_meta.surround_coherence[i][j], Q15 ) ); - previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.diffuse_to_total_ratio[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio_fx[i][j] = floatToFixed( previous_meta->common_meta.remainder_to_total_ratio[i][j], Q30 ); } } #endif // IVAS_FLOAT_FIXED_CONVERSIONS @@ -1888,29 +1826,6 @@ static ivas_error ivas_mc_enc_reconfig( return error; } #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( int i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - for ( int j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - for ( int k = 0; k < MASA_MAXIMUM_DIRECTIONS; k++ ) - { - current_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( current_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - current_meta->directional_meta[k].elevation[i][j] = fixedToFloat( current_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - current_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( current_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - current_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( current_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - previous_meta->directional_meta[k].azimuth[i][j] = fixedToFloat( previous_meta->directional_meta[k].azimuth_fx[i][j], Q22 ); - previous_meta->directional_meta[k].elevation[i][j] = fixedToFloat( previous_meta->directional_meta[k].elevation_fx[i][j], Q22 ); - previous_meta->directional_meta[k].energy_ratio[i][j] = fixedToFloat( previous_meta->directional_meta[k].energy_ratio_fx[i][j], Q30 ); - previous_meta->directional_meta[k].spread_coherence[i][j] = fixedToFloat( previous_meta->directional_meta[k].spread_coherence_fx[i][j], Q15 ); - } - current_meta->common_meta.surround_coherence[i][j] = fixedToFloat( current_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - current_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - current_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( current_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.surround_coherence[i][j] = fixedToFloat( previous_meta->common_meta.surround_coherence_fx[i][j], Q15 ); - previous_meta->common_meta.diffuse_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.diffuse_to_total_ratio_fx[i][j], Q30 ); - previous_meta->common_meta.remainder_to_total_ratio[i][j] = fixedToFloat( previous_meta->common_meta.remainder_to_total_ratio_fx[i][j], Q30 ); - } - } if ( st_ivas->hQMetaData->q_direction != NULL ) { for ( int band = 0; band < st_ivas->hMasa->config.numCodingBands; band++ ) @@ -1926,7 +1841,6 @@ static ivas_error ivas_mc_enc_reconfig( } } } - fixedToFloat_arrL( st_ivas->hMasa->data.importanceWeight_fx, st_ivas->hMasa->data.importanceWeight, 30, 24 ); #endif // IVAS_FLOAT_FIXED_CONVERSIONS #else if ( ( error = ivas_mcmasa_enc_reconfig( st_ivas ) ) != IVAS_ERR_OK ) @@ -1999,7 +1913,11 @@ static ivas_error ivas_mc_enc_reconfig( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) ); } +#ifdef IVAS_FLOAT_FIXED + InitTransientDetection_ivas_fx( shl( div_l( st->input_Fs, FRAMES_PER_SEC ), 1 ), NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); +#else InitTransientDetection( (int16_t) ( st->input_Fs / FRAMES_PER_SEC ), NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); +#endif } if ( st->hIGFEnc == NULL ) diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 57ff78f079b03a3967ba4b465831978c9d1e57be..aecf4c9a9919fe2196e3409cb1c5deabd47a2f84 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -1743,10 +1743,6 @@ void ivas_mdct_core_whitening_enc( st->prevEnergyHF_fx = floatToFixed_32( st->prevEnergyHF, q_com ); st->currEnergyHF_fx = floatToFixed_32( st->currEnergyHF, q_com ); st->currEnergyHF_e_fx = sub( Q31, q_com ); - IF( st->hTranDet ) - { - floatToFixed_arr( st->hTranDet->subblockEnergies.subblockNrgChange_flt, st->hTranDet->subblockEnergies.subblockNrgChange, Q15 - NRG_CHANGE_E, NSUBBLOCKS + MAX_TD_DELAY ); - } IF( st->hTcxEnc ) { st->hTcxEnc->tfm_mem_fx = floatToFixed_32( st->hTcxEnc->tfm_mem, Q31 ); @@ -1787,7 +1783,6 @@ void ivas_mdct_core_whitening_enc( #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; - floatToFixed_arr( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange_flt, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange, 7, NSUBBLOCKS + MAX_TD_DELAY ); hTcxEnc->tcxltp_norm_corr_past = float_to_fix16( hTcxEnc->tcxltp_norm_corr_past_flt, Q15 ); q_fac = Q_factor_arr( old_wsp[ch], L_WSP ); floatToFixed_arr( old_wsp[ch], old_wsp_fx[ch], q_fac, L_WSP ); @@ -1921,7 +1916,6 @@ void ivas_mdct_core_whitening_enc( if ( st->element_mode == IVAS_CPE_DFT ) { - floatToFixed_arr( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange_flt, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange, Q7, NSUBBLOCKS + MAX_TD_DELAY ); hTcxEnc->tcxltp_norm_corr_past = float_to_fix16( hTcxEnc->tcxltp_norm_corr_past_flt, Q15 ); q_fac = Q_factor_arr( st->buf_wspeech_enc_flt, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); floatToFixed_arr( st->buf_wspeech_enc_flt, st->buf_wspeech_enc, q_fac, L_FRAME16k + L_SUBFR + L_FRAME16k + L_NEXT_MAX_16k + 320 ); @@ -1929,7 +1923,6 @@ void ivas_mdct_core_whitening_enc( } else if ( st->element_mode != IVAS_CPE_MDCT ) { - floatToFixed_arr( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange_flt, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange, Q7, NSUBBLOCKS + MAX_TD_DELAY ); hTcxEnc->tcxltp_norm_corr_past = float_to_fix16( hTcxEnc->tcxltp_norm_corr_past_flt, Q15 ); q_fac = Q_factor_arr( st->buf_speech_enc_flt, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); floatToFixed_arr( st->buf_speech_enc_flt, st->buf_speech_enc, q_fac, L_PAST_MAX_32k + L_FRAME32k + L_NEXT_MAX_32k ); @@ -1938,9 +1931,6 @@ void ivas_mdct_core_whitening_enc( st->hTcxEnc->exp_buf_speech_ltp = 15 - q_fac; } - floatToFixed_arrL( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrg_flt, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrg, 7, 24 ); - floatToFixed_arr( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange_flt, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange, 7, 24 ); - IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) && st->igf ) { if ( st->hIGFEnc ) @@ -2059,15 +2049,9 @@ void ivas_mdct_core_whitening_enc( IF( st->hTcxEnc->fUseTns[0] || st->hTcxEnc->fUseTns[1] ) { if ( st->hTcxCfg->fIsTNSAllowed ) - { // conv params to float - // spectrum[]=float( (fix)spectrum_fx[]) , Q=q_factor_spectrum - // fixedToFloat_arrL( hTcxEnc->spectrum_long_fx, hTcxEnc->spectrum_long, q_factor_spectrum, N_MAX ); - - // subblockNrg_flt=(float)((fixed)subblockNrg) - fixedToFloat_arrL( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrg, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrg_flt, 7, 24 ); - - // subblockNrgChange_flt=(float)((fixed)subblockNrgChange) - fixedToFloat_arr( st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange, st->hTranDet->transientDetector.pSubblockEnergies->subblockNrgChange_flt, 7, 24 ); + { + st->hTranDet->transientDetector.pSubblockEnergies->subblockNrg_e = 31 - Q7; + move16(); } } } diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index 48b1a7a444d2738d4cf58013ae8d0328ff511a6c..79a32e4a4480cbd3c97bb8be60f345e24977bc28 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -355,7 +355,6 @@ ivas_error ivas_qmetadata_enc_encode_fx( Word16 nbands, nblocks, start_band; Word16 ndirections, d; Word32 azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES]; - float azimuth_orig_flt[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], elevation_orig_flt[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES]; Word16 all_coherence_zero; Word16 bit_pos_0, total_bits_1dir, bits_no_dirs_coh; Word16 bits_signaling[QMETADATA_MAX_NO_DIRECTIONS]; @@ -442,7 +441,7 @@ ivas_error ivas_qmetadata_enc_encode_fx( bits_diff_sum = 0; move16(); - // TODO + bits_diff[0] = ivas_qmetadata_entropy_encode_diffuseness_fx( hMetaData, &( hQMetaData->q_direction[0] ), &diffuseness_index_max_ec_frame_pre[0] ); move16(); bits_diff_sum = add( bits_diff_sum, bits_diff[0] ); @@ -591,7 +590,6 @@ ivas_error ivas_qmetadata_enc_encode_fx( q_direction->not_in_2D = 0; move16(); /* Quantize directions*/ - // TODO : Remove azimuth_orig_flt and elevation_orig_flt once full fixed point quantize_direction_frame2D_fx( q_direction, azimuth_orig, elevation_orig ); } ELSE @@ -715,19 +713,6 @@ ivas_error ivas_qmetadata_enc_encode_fx( extra_bits = sub( hQMetaData->metadata_max_bits, sub( hMetaData->nb_bits_tot, bit_pos_0 ) ); } -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( int j = hQMetaData->q_direction[0].cfg.start_band; j < hQMetaData->q_direction[0].cfg.nbands; ++j ) - { - fixedToFloat_arrL( hQMetaData->q_direction[d].band_data[j].azimuth_fx, hQMetaData->q_direction[d].band_data[j].azimuth, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); - fixedToFloat_arrL( hQMetaData->q_direction[d].band_data[j].elevation_fx, hQMetaData->q_direction[d].band_data[j].elevation, Q22, MAX_PARAM_SPATIAL_SUBFRAMES ); - } - for ( i = start_band; i < nbands; i++ ) - { - fixedToFloat_arrL( azimuth_orig[i], azimuth_orig_flt[i], Q22, nblocks ); - fixedToFloat_arrL( elevation_orig[i], elevation_orig_flt[i], Q22, nblocks ); - } -#endif - /* Requantized directions */ IF( LE_16( add( total_bits_1dir, bits_surround_coh ), hQMetaData->qmetadata_max_bit_req ) && GT_16( add( add( add( bits_dir[d], bits_diff[d] ), bits_coherence[d] ), bits_signaling[d] ), total_bits_1dir ) ) { @@ -753,59 +738,48 @@ ivas_error ivas_qmetadata_enc_encode_fx( IF( hQMetaData->is_masa_ivas_format == 0 ) { - reduce_bits = bits_dir_raw - ( total_bits_1dir - bits_diff[d] - bits_coherence[d] - bits_signaling[d] ); + reduce_bits = sub( bits_dir_raw, sub( sub( sub( total_bits_1dir, bits_diff[d] ), bits_coherence[d] ), bits_signaling[d] ) ); ind_order[0] = -1; + move16(); } ELSE { ind_order[0] = 0; - reduce_bits = min( nbands * nblocks + MASA_BIT_REDUCT_PARAM, bits_dir_raw - ( total_bits_1dir - bits_diff[d] - bits_coherence[d] - bits_signaling[d] ) ); + move16(); + reduce_bits = s_min( add( imult1616( nbands, nblocks ), MASA_BIT_REDUCT_PARAM ), sub( bits_dir_raw, sub( sub( sub( total_bits_1dir, bits_diff[d] ), bits_coherence[d] ), bits_signaling[d] ) ) ); - IF( GT_16( reduce_bits, ( bits_dir_raw - nbands * nblocks ) ) ) + IF( GT_16( reduce_bits, sub( bits_dir_raw, imult1616( nbands, nblocks ) ) ) ) { - reduce_bits = bits_dir_raw - nbands * nblocks; + reduce_bits = sub( bits_dir_raw, imult1616( nbands, nblocks ) ); } } only_reduce_bits_direction_fx( &extra_bits, q_direction, reduce_bits, nbands, nblocks, ind_order ); bits_dir[d] = hMetaData->nb_bits_tot; -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - - for ( int j = 0; j < MASA_MAXIMUM_CODING_SUBBANDS; j++ ) - { - floatToFixed_arrL32( elevation_orig_flt[j], elevation_orig[j], Q22, 4 ); - floatToFixed_arrL32( azimuth_orig_flt[j], azimuth_orig[j], Q22, 4 ); - } + move16(); - for ( int k = q_direction->cfg.start_band; k < q_direction->cfg.nbands; k++ ) - { - floatToFixed_arrL32( q_direction->band_data[k].elevation, q_direction->band_data[k].elevation_fx, Q22, 4 ); - floatToFixed_arrL32( q_direction->band_data[k].azimuth, q_direction->band_data[k].azimuth_fx, Q22, 4 ); - } -#endif // IVAS_FLOAT_FIXED_CONVERSIONS requantize_direction_EC_3_fx( &extra_bits, q_direction, nbands, hMetaData, elevation_orig, azimuth_orig, ind_order ); - bits_dir[d] = hMetaData->nb_bits_tot - bits_dir[d]; -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( int k = q_direction->cfg.start_band; k < q_direction->cfg.nbands; k++ ) - { - fixedToFloat_arrL32( q_direction->band_data[k].elevation_fx, q_direction->band_data[k].elevation, Q22, 4 ); - fixedToFloat_arrL32( q_direction->band_data[k].azimuth_fx, q_direction->band_data[k].azimuth, Q22, 4 ); - } -#endif // IVAS_FLOAT_FIXED_CONVERSIONS + bits_dir[d] = sub( hMetaData->nb_bits_tot, bits_dir[d] ); + move16(); } /* finalize writing coherence */ + test(); + test(); IF( GT_16( bits_coherence[d], 0 ) && EQ_16( all_coherence_zero, 0 ) && GT_16( nblocks, 1 ) ) { bit_pos_start = hMetaData->nb_bits_tot; hMetaData->nb_bits_tot = bit_pos_start_coh; ivas_qmetadata_quantize_coherence_fx( hQMetaData, d, all_coherence_zero, hMetaData, 1, &indice_coherence, 0 ); hMetaData->nb_bits_tot = bit_pos_start; + move16(); + move16(); + move16(); } - IF( EQ_16( d, 0 ) ) + IF( d == 0 ) { - total_bits_1dir = hQMetaData->metadata_max_bits - ( hMetaData->nb_bits_tot - bit_pos_0 ); + total_bits_1dir = sub( hQMetaData->metadata_max_bits, sub( hMetaData->nb_bits_tot, bit_pos_0 ) ); } /* Save quantized DOAs */ @@ -816,13 +790,6 @@ ivas_error ivas_qmetadata_enc_encode_fx( } /* Copy original DOAs back to q_direction*/ -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( i = start_band; i < nbands; i++ ) - { - floatToFixed_arrL( azimuth_orig_flt[i], azimuth_orig[i], Q22, nblocks ); - floatToFixed_arrL( elevation_orig_flt[i], elevation_orig[i], Q22, nblocks ); - } -#endif FOR( i = start_band; i < nbands; i++ ) { Copy32( azimuth_orig[i], q_direction->band_data[i].azimuth_fx, nblocks ); @@ -1227,7 +1194,7 @@ ivas_error ivas_qmetadata_enc_encode( * * Main function for quantizing and coding Spatial Metadata at HRs *-----------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_qmetadata_enc_encode_hr_384_512( BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ IVAS_QMETADATA *hQMetaData, /* i/o: metadata handle */ @@ -1466,7 +1433,7 @@ ivas_error ivas_qmetadata_enc_encode_hr_384_512( return error; } -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_qmetadata_enc_encode_hr_384_512_fx( BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ IVAS_QMETADATA *hQMetaData, /* i/o: metadata handle */ diff --git a/lib_enc/ivas_qspherical_enc.c b/lib_enc/ivas_qspherical_enc.c index ee3d4a1e119c971baec083f4a2cbab140e18619d..74a787b2cbce12632b35c9d9bfc7febaa34d48e4 100644 --- a/lib_enc/ivas_qspherical_enc.c +++ b/lib_enc/ivas_qspherical_enc.c @@ -66,7 +66,7 @@ static Word16 direction_distance_cp_fx( Word32 theta, Word32 theta_hat, Word32 t * * *----------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void quantize_direction_frame( IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], @@ -166,7 +166,7 @@ void quantize_direction_frame( return; } -#ifdef IVAS_FLOAT_FIXED +#else void quantize_direction_frame_fx( IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ Word32 azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* o : Q22 */ diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index e27f432be931b17d289e7f15a470936e471a7476..b6e5fbaf6798e7fb550a4341cb0fc6d11dc9a5b9 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -146,62 +146,24 @@ ivas_error ivas_sce_enc( { #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - st->hTranDet->subblockEnergies.firState1 = (Word16) floatToFixed( st->hTranDet->subblockEnergies.firState1_flt, -1 ); - st->hTranDet->subblockEnergies.firState2 = (Word16) floatToFixed( st->hTranDet->subblockEnergies.firState2_flt, -1 ); - - FOR( Word16 i = 0; i < NSUBBLOCKS + MAX_TD_DELAY + 1; i++ ) - { - st->hTranDet->subblockEnergies.accSubblockNrg[i] = floatToFixed( st->hTranDet->subblockEnergies.accSubblockNrg_flt[i], 7 ); - } - - FOR( Word16 i = 0; i < NSUBBLOCKS + MAX_TD_DELAY; i++ ) - { - st->hTranDet->subblockEnergies.subblockNrg[i] = floatToFixed( st->hTranDet->subblockEnergies.subblockNrg_flt[i], 7 ); - st->hTranDet->subblockEnergies.subblockNrgChange[i] = (Word16) floatToFixed( st->hTranDet->subblockEnergies.subblockNrgChange_flt[i], 7 ); - } - - - FOR( Word16 i = 0; i < L_FRAME_MAX / NSUBBLOCKS; i++ ) - { - st->hTranDet->delayBuffer.buffer[i] = (Word16) floatToFixed( st->hTranDet->delayBuffer.buffer_flt[i], -1 ); - } - - st->hTranDet->transientDetector.attackRatioThreshold = (Word16) floatToFixed( st->hTranDet->transientDetector.attackRatioThreshold_flt, 11 ); - floatToFixed_arr16( st->input, st->input_fx, -1, input_frame ); - - st->hTranDet->subblockEnergies.facAccSubblockNrg = float_to_fix16( st->hTranDet->subblockEnergies.facAccSubblockNrg_flt, 15 ); - #endif - RunTransientDetection_ivas_fx( st->input_fx, input_frame, st->hTranDet ); - -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - - st->hTranDet->subblockEnergies.firState1_flt = fixedToFloat( (Word32) st->hTranDet->subblockEnergies.firState1, -1 ); - st->hTranDet->subblockEnergies.firState2_flt = fixedToFloat( (Word32) st->hTranDet->subblockEnergies.firState2, -1 ); - FOR( Word16 i = 0; i < NSUBBLOCKS + MAX_TD_DELAY; i++ ) - { - st->hTranDet->subblockEnergies.subblockNrg_flt[i] = fixedToFloat( st->hTranDet->subblockEnergies.subblockNrg[i], 7 ); - st->hTranDet->subblockEnergies.subblockNrgChange_flt[i] = fixedToFloat( (Word32) st->hTranDet->subblockEnergies.subblockNrgChange[i], 7 ); - } - - FOR( Word16 i = 0; i < NSUBBLOCKS + MAX_TD_DELAY + 1; i++ ) - { - st->hTranDet->subblockEnergies.accSubblockNrg_flt[i] = fixedToFloat( st->hTranDet->subblockEnergies.accSubblockNrg[i], 7 ); - } - - FOR( Word16 i = 0; i < L_FRAME_MAX / NSUBBLOCKS; i++ ) - { - st->hTranDet->delayBuffer.buffer_flt[i] = fixedToFloat( (Word32) st->hTranDet->delayBuffer.buffer[i], -1 ); - } -#endif + st->hTranDet->subblockEnergies.subblockNrg_e = 31 - Q7; + st->hTranDet->subblockEnergies.accSubblockNrg_e = 31 - Q7; + move16(); + move16(); #else RunTransientDetection( st->input, input_frame, st->hTranDet ); #endif } +#ifdef IVAS_FLOAT_FIXED + Word16 tmp = GetTCXAvgTemporalFlatnessMeasure_fx( (const TransientDetection *) st->hTranDet, NSUBBLOCKS, 0 ); + currFlatness[0] = me2f_16( tmp, 15 - Q7 ); +#else currFlatness[0] = GetTCXAvgTemporalFlatnessMeasure( st->hTranDet, NSUBBLOCKS, 0 ); +#endif /*----------------------------------------------------------------* * Configuration of core encoder diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 68b457c3ccff9e49f8874939fc4611af3a750031..582595208c332a41711ee488a476066ce0fad372 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -644,17 +644,18 @@ static ivas_error ivas_spar_cov_md_process( SPAR_ENC_HANDLE hSpar, const IVAS_QMETADATA_HANDLE hQMetaData, BSTR_ENC_HANDLE hMetaData, - const int16_t nchan_inp, - const int16_t sba_order, - float *ppIn_FR_real[IVAS_SPAR_MAX_CH], - float *ppIn_FR_imag[IVAS_SPAR_MAX_CH], - const int16_t transient_det[2], - const int16_t dtx_vad, - const int16_t nchan_transport, - int16_t *dyn_active_w_flag ) + const Word16 nchan_inp, + const Word16 sba_order, + Word32 *ppIn_FR_real_fx[IVAS_SPAR_MAX_CH], + Word32 *ppIn_FR_imag_fx[IVAS_SPAR_MAX_CH], + const Word16 transient_det[2], + const Word16 dtx_vad, + const Word16 nchan_transport, + Word16 *dyn_active_w_flag, + Word16 q_ppIn_FR ) { - int16_t i, j, i_ts, b, table_idx; - int16_t active_w_vlbr; + Word16 i, j, i_ts, b, table_idx; + Word16 active_w_vlbr; /* note: the actual dimensions of matrixes correspond to num_channels = ivas_sba_get_nchan_metadata( sba_order, ivas_total_brate ); */ float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; @@ -667,34 +668,42 @@ static ivas_error ivas_spar_cov_md_process( Word16 *q_cov_dtx_real[IVAS_SPAR_MAX_CH]; Word32 cov_real_buf_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; Word32 cov_dtx_real_buf_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; - Word32 *ppIn_FR_real_fx[IVAS_SPAR_MAX_CH], *ppIn_FR_imag_fx[IVAS_SPAR_MAX_CH]; - Word16 q_ppIn_FR[IVAS_SPAR_MAX_CH]; - Word16 input_frame; - Word16 nchan_fb_in; #endif ivas_error error; error = IVAS_ERR_OK; + move32(); - active_w_vlbr = ( hEncoderConfig->ivas_total_brate < IVAS_24k4 ) ? 1 : 0; + IF( LT_32( hEncoderConfig->ivas_total_brate, IVAS_24k4 ) ) + { + active_w_vlbr = 1; + move16(); + } + ELSE + { + active_w_vlbr = 0; + move16(); + } /*-----------------------------------------------------------------------------------------* * Set SPAR bitrates *-----------------------------------------------------------------------------------------*/ - table_idx = ivas_get_spar_table_idx( hEncoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL ); + table_idx = ivas_get_spar_table_idx_fx( hEncoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL ); - if ( hSpar->hMdEnc->table_idx != table_idx ) + IF( NE_16( hSpar->hMdEnc->table_idx, table_idx ) ) { hSpar->hMdEnc->table_idx = table_idx; - if ( hEncoderConfig->ivas_total_brate != hEncoderConfig->last_ivas_total_brate && !hSpar->spar_reconfig_flag ) + move16(); + test(); + IF( NE_32( hEncoderConfig->ivas_total_brate, hEncoderConfig->last_ivas_total_brate ) && !hSpar->spar_reconfig_flag ) { - if ( ( error = ivas_spar_md_enc_init( hSpar->hMdEnc, hEncoderConfig, sba_order ) ) != IVAS_ERR_OK ) + IF( NE_32( ( error = ivas_spar_md_enc_init( hSpar->hMdEnc, hEncoderConfig, sba_order ) ), IVAS_ERR_OK ) ) { return error; } } - else + ELSE { ivas_spar_set_bitrate_config( &hSpar->hMdEnc->spar_md_cfg, table_idx, ( hSpar->hMdEnc->spar_hoa_md_flag ) ? IVAS_MAX_NUM_BANDS : SPAR_DIRAC_SPLIT_START_BAND, hSpar->hMdEnc->spar_hoa_dirac2spar_md_flag, 1, hEncoderConfig->Opt_PCA_ON, hSpar->AGC_Enable ); } @@ -746,44 +755,10 @@ static ivas_error ivas_spar_cov_md_process( } #endif -#ifdef IVAS_FLOAT_FIXED - input_frame = extract_l( Mpy_32_32( hEncoderConfig->input_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - nchan_fb_in = hSpar->hFbMixer->fb_cfg->nchan_fb_in; - move16(); - - FOR( i = 0; i < nchan_fb_in; i++ ) - { - IF( ( ppIn_FR_real_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * input_frame ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR encoder Fixed" ); - } - set_zero_fx( ppIn_FR_real_fx[i], input_frame ); - IF( ( ppIn_FR_imag_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * input_frame ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR encoder Fixed" ); - } - set_zero_fx( ppIn_FR_imag_fx[i], input_frame ); - } - set_s( q_ppIn_FR, Q31, nchan_fb_in ); - - FOR( i = 0; i < nchan_fb_in; i++ ) - { - q_ppIn_FR[i] = L_get_q_buf1( ppIn_FR_real[i], input_frame ); - q_ppIn_FR[i] = min( q_ppIn_FR[i], L_get_q_buf1( ppIn_FR_imag[i], input_frame ) ); - floatToFixed_arrL( ppIn_FR_real[i], ppIn_FR_real_fx[i], q_ppIn_FR[i], input_frame ); - floatToFixed_arrL( ppIn_FR_imag[i], ppIn_FR_imag_fx[i], q_ppIn_FR[i], input_frame ); - } -#endif - -#ifdef IVAS_FLOAT_FIXED ivas_enc_cov_handler_process_fx( hSpar->hCovEnc, ppIn_FR_real_fx, ppIn_FR_imag_fx, q_ppIn_FR, cov_real_fx, q_cov_real, cov_dtx_real_fx, q_cov_dtx_real, hSpar->hFbMixer->pFb, 0, hSpar->hFbMixer->pFb->filterbank_num_bands, nchan_inp, dtx_vad, transient_det, hSpar->hMdEnc->HOA_md_ind, &hSpar->hMdEnc->spar_md.res_ind, remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order], dyn_active_w_flag, nchan_transport, 1 ); -#else - ivas_enc_cov_handler_process( hSpar->hCovEnc, ppIn_FR_real, ppIn_FR_imag, cov_real, cov_dtx_real, hSpar->hFbMixer->pFb, 0, hSpar->hFbMixer->pFb->filterbank_num_bands, nchan_inp, dtx_vad, transient_det, hSpar->hMdEnc->HOA_md_ind, - &hSpar->hMdEnc->spar_md.res_ind, remix_order_set[hSpar->hMdEnc->spar_md_cfg.remix_unmix_order], dyn_active_w_flag, nchan_transport, 1 ); -#endif -#ifdef IVAS_FLOAT_FIXED +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS FOR( i = 0; i < nchan_inp; i++ ) { FOR( j = 0; j < nchan_inp; j++ ) @@ -800,29 +775,30 @@ static ivas_error ivas_spar_cov_md_process( free( q_cov_dtx_real[i] ); q_cov_dtx_real[i] = NULL; } - // Note: No need to convert ppIn_FR_real_fx and ppIn_FR_imag_fx back to float as they are not used after ivas_spar_cov_md_process() - - FOR( i = 0; i < nchan_fb_in; i++ ) - { - free( ppIn_FR_real_fx[i] ); - ppIn_FR_real_fx[i] = NULL; - free( ppIn_FR_imag_fx[i] ); - ppIn_FR_imag_fx[i] = NULL; - } #endif - - if ( nchan_transport > 1 && nchan_transport <= ( FOA_CHANNELS - 1 ) ) + test(); + IF( GT_16( nchan_transport, 1 ) && LE_16( nchan_transport, ( FOA_CHANNELS - 1 ) ) ) { push_next_indice( hMetaData, *dyn_active_w_flag, 1 ); - if ( ( *dyn_active_w_flag == 1 ) && ( nchan_transport == 2 ) ) + test(); + IF( EQ_16( *dyn_active_w_flag, 1 ) && EQ_16( nchan_transport, 2 ) ) { - push_next_indice( hMetaData, hSpar->hMdEnc->spar_md.res_ind - nchan_transport, 1 ); + push_next_indice( hMetaData, sub( hSpar->hMdEnc->spar_md.res_ind, nchan_transport ), 1 ); + } + IF( EQ_16( *dyn_active_w_flag, 1 ) ) + { + hSpar->front_vad_flag = 1; + move16(); + } + ELSE + { + hSpar->front_vad_flag = hSpar->front_vad_flag; + move16(); } - hSpar->front_vad_flag = ( *dyn_active_w_flag == 1 ) ? 1 : hSpar->front_vad_flag; } - else + ELSE { - if ( nchan_transport == FOA_CHANNELS ) + IF( EQ_16( nchan_transport, FOA_CHANNELS ) ) { push_next_indice( hMetaData, 0, 1 ); } @@ -832,83 +808,83 @@ static ivas_error ivas_spar_cov_md_process( * MetaData encoder *-----------------------------------------------------------------------------------------*/ - if ( hSpar->hMdEnc->spar_hoa_md_flag == 0 ) + IF( hSpar->hMdEnc->spar_hoa_md_flag == 0 ) { -#ifdef IVAS_FLOAT_FIXED - if ( ( error = ivas_spar_md_enc_process_fx( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, cov_real_fx, hSpar->hCovEnc->pCov_state->q_cov_real_per_band, cov_dtx_real_fx, hSpar->hCovEnc->pCov_dtx_state->q_cov_real_per_band, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag ) ) != IVAS_ERR_OK ) -#endif + IF( NE_32( ( error = ivas_spar_md_enc_process_fx( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, cov_real_fx, hSpar->hCovEnc->pCov_state->q_cov_real_per_band, cov_dtx_real_fx, hSpar->hCovEnc->pCov_dtx_state->q_cov_real_per_band, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag ) ), IVAS_ERR_OK ) ) { return error; } } - if ( hSpar->hMdEnc->spar_hoa_dirac2spar_md_flag ) + IF( hSpar->hMdEnc->spar_hoa_dirac2spar_md_flag ) { - float azi_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES]; - float ele_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES]; - float diffuseness[IVAS_MAX_NUM_BANDS]; - float Wscale_d[IVAS_MAX_NUM_BANDS]; -#ifdef IVAS_FLOAT_FIXED Word16 order; Word32 azi_dirac_fx[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES]; Word32 ele_dirac_fx[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES]; Word32 diffuseness_fx[IVAS_MAX_NUM_BANDS]; Word32 Wscale_d_fx[IVAS_MAX_NUM_BANDS]; -#endif - int16_t d_start_band, d_end_band; - int16_t dirac_band_idx; + Word16 d_start_band, d_end_band; + Word16 dirac_band_idx; d_start_band = hSpar->enc_param_start_band; + move16(); d_end_band = IVAS_MAX_NUM_BANDS; + move16(); - for ( b = d_start_band; b < d_end_band; b++ ) + FOR( b = d_start_band; b < d_end_band; b++ ) { - dirac_band_idx = hSpar->dirac_to_spar_md_bands[b] - d_start_band; - for ( i_ts = 0; i_ts < hQMetaData->q_direction->cfg.nblocks; i_ts++ ) + dirac_band_idx = sub( hSpar->dirac_to_spar_md_bands[b], d_start_band ); + FOR( i_ts = 0; i_ts < hQMetaData->q_direction->cfg.nblocks; i_ts++ ) { - azi_dirac[b][i_ts] = hQMetaData->q_direction->band_data[dirac_band_idx].azimuth[i_ts]; - ele_dirac[b][i_ts] = hQMetaData->q_direction->band_data[dirac_band_idx].elevation[i_ts]; + azi_dirac_fx[b][i_ts] = hQMetaData->q_direction->band_data[dirac_band_idx].azimuth_fx[i_ts]; + move32(); + ele_dirac_fx[b][i_ts] = hQMetaData->q_direction->band_data[dirac_band_idx].elevation_fx[i_ts]; + move32(); } - diffuseness[b] = 1.0f - hQMetaData->q_direction->band_data[dirac_band_idx].energy_ratio[0]; + diffuseness_fx[b] = L_sub( ONE_IN_Q30, hQMetaData->q_direction->band_data[dirac_band_idx].energy_ratio_fx[0] ); + move32(); } - - if ( d_start_band >= 6 && dtx_vad == 1 ) + test(); + IF( GE_16( d_start_band, 6 ) && EQ_16( dtx_vad, 1 ) ) { +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS mvr2r( hSpar->hMdEnc->spar_md.band_coeffs[d_start_band - 1].P_quant_re, hSpar->hMdEnc->spar_md.band_coeffs[d_start_band - 1].P_re, IVAS_SPAR_MAX_CH - 1 ); +#endif + Copy32( hSpar->hMdEnc->spar_md.band_coeffs[d_start_band - 1].P_quant_re_fx, hSpar->hMdEnc->spar_md.band_coeffs[d_start_band - 1].P_re_fx, IVAS_SPAR_MAX_CH - 1 ); } - for ( b = d_start_band; b < d_end_band; b++ ) + FOR( b = d_start_band; b < d_end_band; b++ ) { - Wscale_d[b] = 1.0f; - for ( i = 1; i < nchan_inp; i++ ) + Word16 tmp_e, Wscale_d_e = 0; + move16(); + Wscale_d_fx[b] = ONE_IN_Q31; + move32(); + FOR( i = 1; i < nchan_inp; i++ ) { - Wscale_d[b] += cov_real[i][i][b] / max( EPSILON, cov_real[0][0][b] ); + Word32 tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( cov_real_fx[i][i][b], cov_real_fx[0][0][b], &tmp_e ) ); + tmp_e = add( tmp_e, sub( sub( Q31, hSpar->hCovEnc->pCov_state->q_cov_real_per_band[i][i][b] ), sub( Q31, hSpar->hCovEnc->pCov_state->q_cov_real_per_band[0][0][b] ) ) ); + Wscale_d_fx[b] = BASOP_Util_Add_Mant32Exp( tmp, tmp_e, Wscale_d_fx[b], Wscale_d_e, &Wscale_d_e ); + move32(); } - Wscale_d[b] = Wscale_d[b] / ( 1.0f + (float) sba_order ); /*DirAC normalized signal variance sums to 1 + order*/ - Wscale_d[b] = sqrtf( Wscale_d[b] ); - Wscale_d[b] = min( 2.0f, max( Wscale_d[b], 1.0f ) ); + Wscale_d_fx[b] = L_deposit_h( BASOP_Util_Divide3232_Scale( Wscale_d_fx[b], L_add( 1, sba_order ), &tmp_e ) ); + move32(); + tmp_e = add( tmp_e, sub( Wscale_d_e, Q31 ) ); + Wscale_d_fx[b] = Sqrt32( Wscale_d_fx[b], &tmp_e ); + move32(); + Wscale_d_fx[b] = L_shl_sat( Wscale_d_fx[b], sub( tmp_e, Q2 ) ); // saturating to Q29, as final value is limited to 2 below + move32(); + Wscale_d_fx[b] = L_min( ONE_IN_Q30, L_max( Wscale_d_fx[b], ONE_IN_Q29 ) ); // Q29 + move32(); } #ifdef IVAS_FLOAT_FIXED #ifdef IVAS_FLOAT_FIXED_CONVERSIONS - for ( b = d_start_band; b < d_end_band; b++ ) - { - for ( i_ts = 0; i_ts < hQMetaData->q_direction->cfg.nblocks; i_ts++ ) - { - azi_dirac_fx[b][i_ts] = float_to_fix( azi_dirac[b][i_ts], Q22 ); - ele_dirac_fx[b][i_ts] = float_to_fix( ele_dirac[b][i_ts], Q22 ); - } - diffuseness_fx[b] = float_to_fix( diffuseness[b], Q30 ); - Wscale_d_fx[b] = float_to_fix( Wscale_d[b], Q29 ); - } for ( b = 0; b < IVAS_MAX_NUM_BANDS; b++ ) { for ( i = 0; i < IVAS_SPAR_MAX_CH - 1; i++ ) { - hSpar->hMdEnc->spar_md.band_coeffs[b].P_re_fx[i] = float_to_fix( hSpar->hMdEnc->spar_md.band_coeffs[b].P_re[i], Q22 ); - hSpar->hMdEnc->spar_md.band_coeffs[b].pred_re_fx[i] = float_to_fix( hSpar->hMdEnc->spar_md.band_coeffs[b].pred_re[i], Q22 ); + hSpar->hMdEnc->spar_md.band_coeffs[b].P_re_fx[i] = L_shr( hSpar->hMdEnc->spar_md.band_coeffs[b].P_re_fx[i], Q6 ); + hSpar->hMdEnc->spar_md.band_coeffs[b].pred_re_fx[i] = L_shr( hSpar->hMdEnc->spar_md.band_coeffs[b].pred_re_fx[i], Q6 ); } hSpar->hMdEnc->spar_md.band_coeffs[b].q_P_re_fx = Q22; hSpar->hMdEnc->spar_md.band_coeffs[b].q_pred_re_fx = Q22; @@ -974,13 +950,9 @@ static ivas_error ivas_spar_cov_md_process( #endif } - if ( hSpar->hMdEnc->spar_hoa_md_flag ) + IF( hSpar->hMdEnc->spar_hoa_md_flag ) { -#ifdef IVAS_FLOAT_FIXED error = ivas_spar_md_enc_process_fx( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, cov_real_fx, hSpar->hCovEnc->pCov_state->q_cov_real_per_band, cov_dtx_real_fx, hSpar->hCovEnc->pCov_dtx_state->q_cov_real_per_band, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag ); -#else - error = ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, cov_real, cov_dtx_real, hMetaData, dtx_vad, nchan_inp, sba_order, hSpar->hFbMixer->prior_mixer, *dyn_active_w_flag, hQMetaData->dirac_mono_flag ); -#endif } return error; @@ -1271,6 +1243,12 @@ static ivas_error ivas_spar_enc_process( ppIn_FR_imag[i] = pcm_tmp[i] + input_frame; p_pcm_tmp[i] = pcm_tmp[i]; } + FOR( i = 0; i < nchan_fb_in; i++ ) + { + ppIn_FR_real_fx[i] = pcm_tmp_fx[i]; + ppIn_FR_imag_fx[i] = pcm_tmp_fx[i] + input_frame; + p_pcm_tmp_fx[i] = pcm_tmp_fx[i]; + } dtx_vad = ( hEncoderConfig->Opt_DTX_ON == 1 ) ? front_vad_flag : 1; @@ -1304,8 +1282,28 @@ static ivas_error ivas_spar_enc_process( /*-----------------------------------------------------------------------------------------* * Covariance and MD processing *-----------------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - if ( ( error = ivas_spar_cov_md_process( hEncoderConfig, st_ivas->hSpar, st_ivas->hQMetaData, hMetaData, nchan_inp, sba_order, ppIn_FR_real, ppIn_FR_imag, transient_det, dtx_vad, nchan_transport, &dyn_active_w_flag ) ) != IVAS_ERR_OK ) + for ( b = hSpar->enc_param_start_band; b < IVAS_MAX_NUM_BANDS; b++ ) + { + Word16 dirac_band_idx = hSpar->dirac_to_spar_md_bands[b] - hSpar->enc_param_start_band; + for ( i_ts = 0; i_ts < hQMetaData->q_direction->cfg.nblocks; i_ts++ ) + { + hQMetaData->q_direction->band_data[dirac_band_idx].azimuth_fx[i_ts] = float_to_fix( hQMetaData->q_direction->band_data[dirac_band_idx].azimuth[i_ts], Q22 ); + hQMetaData->q_direction->band_data[dirac_band_idx].elevation_fx[i_ts] = float_to_fix( hQMetaData->q_direction->band_data[dirac_band_idx].elevation[i_ts], Q22 ); + } + hQMetaData->q_direction->band_data[dirac_band_idx].energy_ratio_fx[0] = float_to_fix( hQMetaData->q_direction->band_data[dirac_band_idx].energy_ratio[0], Q30 ); + } +#ifdef IVAS_FLOAT_FIXED_CONVERSIONS + for ( int ch_idx = 0; ch_idx < nchan_fb_in; ch_idx++ ) + { + floatToFixed_arrL32( ppIn_FR_real[ch_idx], ppIn_FR_real_fx[ch_idx], Q14 - gb, input_frame ); + floatToFixed_arrL32( ppIn_FR_imag[ch_idx], ppIn_FR_imag_fx[ch_idx], Q14 - gb, input_frame ); + } +#endif +#endif + + if ( ( error = ivas_spar_cov_md_process( hEncoderConfig, st_ivas->hSpar, st_ivas->hQMetaData, hMetaData, nchan_inp, sba_order, ppIn_FR_real_fx, ppIn_FR_imag_fx, transient_det, dtx_vad, nchan_transport, &dyn_active_w_flag, Q14 - gb ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index d61ed4bd6ba546106856576cbac8b736b1611665..4e8a5ba3f669d1583bad97f859a380b54b3cec9a 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -415,6 +415,20 @@ ivas_error ivas_spar_md_enc_init( } } +#ifdef MSAN_FIX + FOR( i = 0; i < num_channels; i++ ) + { + FOR( j = 0; j < num_channels; j++ ) + { + FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) + { + hMdEnc->mixer_mat_fx[i][j][k] = 0; + move32(); + } + } + } +#endif + ivas_clear_band_coeffs( hMdEnc->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); ivas_clear_band_coeff_idx( hMdEnc->spar_md.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); ivas_clear_band_coeff_idx( hMdEnc->spar_md_prior.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 67ff327e246779a95b875737585e0e05ba904034..746d5712ac257123367cdd4690b065ff9bb1f26c 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1235,11 +1235,12 @@ typedef struct ivas_omasa_enc_state_structure typedef struct ivas_omasa_encoder_one_data_struct { +#ifndef IVAS_FLOAT_FIXED float energy_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; float energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; -#ifdef IVAS_FLOAT_FIXED +#else Word32 energy_ism_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word16 energy_ism_fx_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word32 energy_ratio_ism_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; /*q30*/ @@ -1249,10 +1250,10 @@ typedef struct ivas_omasa_encoder_one_data_struct #ifndef IVAS_FLOAT_FIXED float lp_noise_CPE; /* LP filtered total noise estimation */ #else - Word16 lp_noise_CPE_fx; /* LP filtered total noise estimation Q8 */ + Word16 lp_noise_CPE_fx; /* LP filtered total noise estimation Q8 */ #endif - int16_t omasa_stereo_sw_cnt; + Word16 omasa_stereo_sw_cnt; } OMASA_ENCODER_DATA_STATE, *OMASA_ENCODER_DATA_HANDLE; @@ -1302,16 +1303,17 @@ typedef struct ivas_masa_encoder_data_struct HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc[MAX_NUM_ENC_CLDFB_INSTANCES]; int16_t band_mapping[MASA_FREQUENCY_BANDS + 1]; uint8_t twoDirBands[MASA_FREQUENCY_BANDS]; - float importanceWeight[MASA_FREQUENCY_BANDS]; SPHERICAL_GRID_DATA Sph_Grid16; - float lfeToTotalEnergyRatio[MAX_PARAM_SPATIAL_SUBFRAMES]; #ifdef IVAS_FLOAT_FIXED Word32 importanceWeight_fx[MASA_FREQUENCY_BANDS]; /*q30*/ Word32 lfeToTotalEnergyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; Word16 lfeToTotalEnergyRatio_e[MAX_PARAM_SPATIAL_SUBFRAMES]; #endif +#ifndef IVAS_FLOAT_FIXED + float importanceWeight[MASA_FREQUENCY_BANDS]; + float lfeToTotalEnergyRatio[MAX_PARAM_SPATIAL_SUBFRAMES]; float prevq_lfeToTotalEnergyRatio; -#ifdef IVAS_FLOAT_FIXED +#else Word32 prevq_lfeToTotalEnergyRatio_fx; // Q31 #endif int16_t prevq_lfeIndex; diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index 3b8f329cc60145c6e84cea65a0b23a0b265ee86a..e57aadf5d7d14f04c53efaa7fd1e8532bf573878 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -626,10 +626,6 @@ void stereo_mdct_core_enc( st->prevEnergyHF_fx = floatToFixed_32( st->prevEnergyHF, q_com ); st->currEnergyHF_fx = floatToFixed_32( st->currEnergyHF, q_com ); st->currEnergyHF_e_fx = sub( Q31, q_com ); - IF( st->hTranDet ) - { - floatToFixed_arr( st->hTranDet->subblockEnergies.subblockNrgChange_flt, st->hTranDet->subblockEnergies.subblockNrgChange, Q15 - NRG_CHANGE_E, NSUBBLOCKS + MAX_TD_DELAY ); - } IF( st->hTcxEnc ) { st->hTcxEnc->tfm_mem_fx = floatToFixed_32( st->hTcxEnc->tfm_mem, Q31 ); @@ -663,23 +659,12 @@ void stereo_mdct_core_enc( #endif /* adaptively sync tcx modes*/ #ifdef IVAS_FLOAT_FIXED -#ifdef IVAS_FLOAT_FIXED_CONVERSIONS - Word16 temp_q = Q_factor_arrL( sts[0]->hTranDet->subblockEnergies.accSubblockNrg_flt, NSUBBLOCKS + MAX_TD_DELAY + 1 ); - temp_q = s_min( temp_q, Q_factor_arrL( sts[1]->hTranDet->subblockEnergies.accSubblockNrg_flt, NSUBBLOCKS + MAX_TD_DELAY + 1 ) ); - for ( ch = 0; ch < CPE_CHANNELS; ch++ ) - { - st = sts[ch]; - floatToFixed_arrL32( st->hTranDet->subblockEnergies.accSubblockNrg_flt, st->hTranDet->subblockEnergies.accSubblockNrg, temp_q, NSUBBLOCKS + MAX_TD_DELAY + 1 ); - } -#endif - IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) && ( GT_16( abs_s( sub( sts[0]->hTcxCfg->tcx_last_overlap_mode, sts[1]->hTcxCfg->tcx_last_overlap_mode ) ), extract_l( 2 ) ) || EQ_16( sts[0]->hTcxCfg->tcx_last_overlap_mode, sts[1]->hTcxCfg->tcx_last_overlap_mode ) || EQ_16( add( sts[0]->hTcxCfg->tcx_last_overlap_mode, sts[1]->hTcxCfg->tcx_last_overlap_mode ), extract_l( 5 ) ) ) ) /* disable syncing for stereo switching or large diff in last frame overlap */ { sync_tcx_mode( sts ); } - #else if ( ( hCPE->last_element_mode == IVAS_CPE_MDCT ) && ( abs( sts[0]->hTcxCfg->tcx_last_overlap_mode - sts[1]->hTcxCfg->tcx_last_overlap_mode ) > 2 || sts[0]->hTcxCfg->tcx_last_overlap_mode == sts[1]->hTcxCfg->tcx_last_overlap_mode || diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index fdb85842b33c831a36ad6359aeea3ddc5b278b07..4ba0f3444b7c78167119e8248bd2b2a500c492b1 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -479,14 +479,6 @@ ivas_error IVAS_ENC_FeedObjectMetadata( Word32 yaw_fx = float_to_fix( metadata.yaw, Q22 ); /* Q22 */ Word32 pitch_fx = float_to_fix( metadata.pitch, Q22 ); /* Q22 */ error = ivas_set_ism_metadata_fx( hIvasEnc->st_ivas->hIsmMetaData[ismIndex], azimuth_fx, elevation_fx, radius_fx, yaw_fx, pitch_fx, metadata.non_diegetic_flag ); - - /*================fix-to-flt====================*/ - hIvasEnc->st_ivas->hIsmMetaData[ismIndex]->azimuth = fix_to_float( azimuth_fx, Q22 ); - hIvasEnc->st_ivas->hIsmMetaData[ismIndex]->elevation = fix_to_float( elevation_fx, Q22 ); - hIvasEnc->st_ivas->hIsmMetaData[ismIndex]->radius = fix_to_float( radius_fx, Q9 ); - hIvasEnc->st_ivas->hIsmMetaData[ismIndex]->yaw = fix_to_float( yaw_fx, Q22 ); - hIvasEnc->st_ivas->hIsmMetaData[ismIndex]->pitch = fix_to_float( pitch_fx, Q22 ); - /*================fix-to-flt====================*/ #else error = ivas_set_ism_metadata( hIvasEnc->st_ivas->hIsmMetaData[ismIndex], metadata.azimuth, metadata.elevation, metadata.radius, metadata.yaw, metadata.pitch, metadata.non_diegetic_flag ); #endif diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index b1a97be46b9f32badb36964d04f61772a13d2159..500dd1307ee3b1f573a0c5360591a9df90d2b7dc 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -139,8 +139,10 @@ typedef struct signal_buffers_enc_data_structure /* Delay buffer: Used to buffer input samples and to define the subblock size of a transient detector. */ typedef struct { - int16_t nSubblockSize; /* Subblock size of a transient detector that uses this delay buffer. */ + int16_t nSubblockSize; /* Subblock size of a transient detector that uses this delay buffer. */ +#ifndef IVAS_FLOAT_FIXED float buffer_flt[L_FRAME_MAX / NSUBBLOCKS]; /* Delay buffer */ +#endif Word16 buffer[L_FRAME48k / NSUBBLOCKS]; int16_t nDelay; /* Size of the delay buffer in use. Maximum delay from all users of this buffer. */ @@ -149,27 +151,37 @@ typedef struct /* Subblock energies: Holds subblock energies and recursively accumulated energies. Also buffers the energies. */ typedef struct { - DelayBuffer *pDelayBuffer; /* Delay buffer. */ + DelayBuffer *pDelayBuffer; /* Delay buffer. */ +#ifndef IVAS_FLOAT_FIXED float subblockNrg_flt[NSUBBLOCKS + MAX_TD_DELAY]; /* Subblock energies with a delay buffering. */ +#endif Word32 subblockNrg[NSUBBLOCKS + MAX_TD_DELAY]; Word16 subblockNrg_e; +#ifndef IVAS_FLOAT_FIXED float accSubblockNrg_flt[NSUBBLOCKS + MAX_TD_DELAY + 1]; /* Recursively accumulated subblock energies with a delay buffering. At index i the value corresponds to the accumulated subblock energy up to i-1, including block i-1 and without block i. */ +#endif Word32 accSubblockNrg[NSUBBLOCKS + MAX_TD_DELAY + 1]; Word16 accSubblockNrg_e; +#ifndef IVAS_FLOAT_FIXED float subblockNrgChange_flt[NSUBBLOCKS + MAX_TD_DELAY]; /* subblockNrgChange[i] = max(subblockNrg[i]/subblockNrg[i-1], subblockNrg[i-1]/subblockNrg[i]) */ - Word16 subblockNrgChange[NSUBBLOCKS + MAX_TD_DELAY]; /* Q7(15 - SUBBLOCK_NRG_CHANGE_E) */ - int16_t nDelay; /* Size of the delay buffer in use, as number of subblocks. Maximum delay from all users of this buffer. */ - int16_t nPartialDelay; /* Delay of the input (modulo pDelayBuffer->nSubblockSize), nPartialDelay <= pDelayBuffer->nDelay. */ +#endif + Word16 subblockNrgChange[NSUBBLOCKS + MAX_TD_DELAY]; /* Q7(15 - SUBBLOCK_NRG_CHANGE_E) */ + int16_t nDelay; /* Size of the delay buffer in use, as number of subblocks. Maximum delay from all users of this buffer. */ + int16_t nPartialDelay; /* Delay of the input (modulo pDelayBuffer->nSubblockSize), nPartialDelay <= pDelayBuffer->nDelay. */ /* Decay factor for the recursive accumulation */ +#ifndef IVAS_FLOAT_FIXED float facAccSubblockNrg_flt; +#endif Word16 facAccSubblockNrg; /* High-pass filter states (delay line) */ +#ifndef IVAS_FLOAT_FIXED float firState1_flt; float firState2_flt; +#endif Word16 firState1; Word16 firState2; @@ -190,11 +202,13 @@ typedef struct TransientDetector int16_t nSubblocksToCheck; /* Number of subblocks to check for transients. */ TCheckSubblocksForAttack CheckSubblocksForAttack; /* Function for checking a presence of an attack. */ TCheckSubblocksForAttack_fx CheckSubblocksForAttack_fx; /* Function for checking a presence of an attack. */ - float attackRatioThreshold_flt; /* Attack ratio threshold */ - Word16 attackRatioThreshold; /* Attack ratio threshold Q11 */ - int16_t bIsAttackPresent; /* True when an attack was detected. */ - int16_t prev_bIsAttackPresent; /* True if an attack was detected in the previous frame. */ - int16_t attackIndex; /* The index of an attack. */ +#ifndef IVAS_FLOAT_FIXED + float attackRatioThreshold_flt; /* Attack ratio threshold */ +#endif + Word16 attackRatioThreshold; /* Attack ratio threshold Q11 */ + int16_t bIsAttackPresent; /* True when an attack was detected. */ + int16_t prev_bIsAttackPresent; /* True if an attack was detected in the previous frame. */ + int16_t attackIndex; /* The index of an attack. */ } TransientDetector; /* Transient detection: Holds all transient detectors and buffers used by them. */ @@ -1106,7 +1120,10 @@ typedef struct sp_mus_clas_structure typedef struct lpd_state_structure { + +#ifndef MSAN_FIX Word16 nbits; /* number of bits used by ACELP or TCX */ +#endif /* signal memory */ float syn_flt[1 + M]; /* Synthesis memory (non-pe) */ diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index d3e56a079a50715e772235e8c98709c1d1024735..ba1fe063ffe54d2e5e0fc47f44d4fbafe68ed7a5 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -4084,7 +4084,11 @@ void fd_bwe_enc_init_fx( set16_fx( hBWE_FD->new_input_hp_fx, 0, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS - DELAY_CLDFB_NS ) ); set16_fx( hBWE_FD->old_input_fx, 0, NS2SA( 48000, DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) ); set16_fx( hBWE_FD->old_input_wb_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_12k8_NS ) ); +#ifndef MSAN_FIX set16_fx( hBWE_FD->old_input_lp_fx, 0, NS2SA( 16000, ACELP_LOOK_NS + DELAY_SWB_TBE_16k_NS ) ); +#else + set16_fx( hBWE_FD->old_input_lp_fx, 0, NS2SA( 16000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_NS ) ); +#endif set16_fx( hBWE_FD->old_syn_12k8_16k_fx, 0, NS2SA( 16000, DELAY_FD_BWE_ENC_NS ) ); hBWE_FD->prev_mode = NORMAL; move16(); diff --git a/lib_enc/transient_detection.c b/lib_enc/transient_detection.c index fc757ed493706bfb338443709b802d6c9f91e846..b88d296fb83c56bfef3c3218c73595bce4ec48c9 100644 --- a/lib_enc/transient_detection.c +++ b/lib_enc/transient_detection.c @@ -63,17 +63,17 @@ * Local function prototypes *---------------------------------------------------------------*/ -static void InitDelayBuffer( const int16_t nFrameLength, const int16_t nDelay, DelayBuffer *pDelayBuffer ); -static void InitSubblockEnergies( const int16_t nFrameLength, const int16_t nDelay, DelayBuffer *pDelayBuffer, SubblockEnergies *pSubblockEnergies ); -static void InitTransientDetector( SubblockEnergies *pSubblockEnergies, const int16_t nDelay, const int16_t nSubblocksToCheck, TCheckSubblocksForAttack pCheckSubblocksForAttack, const float attackRatioThreshold, TransientDetector *pTransientDetector ); #ifndef IVAS_FLOAT_FIXED static void UpdateDelayBuffer( const float *inputconst, const int16_t nSamplesAvailable, DelayBuffer *pDelayBuffer ); static void HighPassFilter( const float *input, const int16_t length, float *pFirState1, float *pFirState2, float *output ); static void UpdateSubblockEnergies( const float *input, const int16_t nSamplesAvailable, SubblockEnergies *pSubblockEnergies ); static void CalculateSubblockEnergies( const float *input, const int16_t nSamplesAvailable, SubblockEnergies *pSubblockEnergies ); static void RunTransientDetector( TransientDetector *pTransientDetector ); -#endif +static void InitTransientDetector( SubblockEnergies *pSubblockEnergies, const int16_t nDelay, const int16_t nSubblocksToCheck, TCheckSubblocksForAttack pCheckSubblocksForAttack, const float attackRatioThreshold, TransientDetector *pTransientDetector ); +static void InitSubblockEnergies( const int16_t nFrameLength, const int16_t nDelay, DelayBuffer *pDelayBuffer, SubblockEnergies *pSubblockEnergies ); +static void InitDelayBuffer( const int16_t nFrameLength, const int16_t nDelay, DelayBuffer *pDelayBuffer ); static void GetAttackForTCXDecision( const float *pSubblockNrg, const float *pAccSubblockNrg, const int16_t nSubblocks, const int16_t nPastSubblocks, const float attackRatioThreshold, int16_t *pbIsAttackPresent, int16_t *pAttackIndex ); +#endif /*-------------------------------------------------------------------* * InitTransientDetection() @@ -81,6 +81,7 @@ static void GetAttackForTCXDecision( const float *pSubblockNrg, const float *pAc * *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void InitTransientDetection( const int16_t nFrameLength, const int16_t nTCXDelay, @@ -109,7 +110,7 @@ void InitTransientDetection( return; } - +#endif /*-------------------------------------------------------------------* * GetTCXAvgTemporalFlatnessMeasure() @@ -117,6 +118,7 @@ void InitTransientDetection( * *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED float GetTCXAvgTemporalFlatnessMeasure( TRAN_DET_HANDLE hTranDet, const int16_t nCurrentSubblocks, @@ -136,7 +138,9 @@ float GetTCXAvgTemporalFlatnessMeasure( sumTempFlatness = 0.0f; assert( ( nPrevSubblocks <= nRelativeDelay ) && ( nCurrentSubblocks <= NSUBBLOCKS + nDelay ) ); + pSubblockNrgChange = &pSubblockEnergies->subblockNrgChange_flt[nRelativeDelay - nPrevSubblocks]; + for ( i = 0; i < nTotBlocks; i++ ) { sumTempFlatness += pSubblockNrgChange[i]; @@ -144,14 +148,14 @@ float GetTCXAvgTemporalFlatnessMeasure( return sumTempFlatness / (float) nTotBlocks; } - +#endif /*-------------------------------------------------------------------* * GetTCXMaxenergyChange() * * *-------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED float GetTCXMaxenergyChange( TRAN_DET_HANDLE hTranDet, const int16_t isTCX10, @@ -208,6 +212,7 @@ float GetTCXMaxenergyChange( return maxEnergyChange; } +#endif #ifndef IVAS_FLOAT_FIXED @@ -415,6 +420,7 @@ void SetTCXModeInfo( * See TCheckSubblocksForAttack for definition of parameters. * It is assumed that the delay of MDCT overlap was not taken into account, so that the last subblock corresponds to the newest input subblock. */ +#ifndef IVAS_FLOAT_FIXED static void GetAttackForTCXDecision( const float *pSubblockNrg, const float *pAccSubblockNrg, @@ -506,8 +512,10 @@ static void InitDelayBuffer( return; } +#endif +#ifndef IVAS_FLOAT_FIXED static void InitSubblockEnergies( const int16_t nFrameLength, const int16_t nDelay, @@ -518,21 +526,22 @@ static void InitSubblockEnergies( assert( ( pDelayBuffer != NULL ) && ( pSubblockEnergies != NULL ) && ( pDelayBuffer->nSubblockSize * NSUBBLOCKS == nFrameLength ) && ( pDelayBuffer->nSubblockSize > 0 ) ); - set_f( pSubblockEnergies->subblockNrg_flt, MIN_BLOCK_ENERGY, nMaxBuffSize ); - set_f( pSubblockEnergies->accSubblockNrg_flt, MIN_BLOCK_ENERGY, nMaxBuffSize + 1 ); - set_f( pSubblockEnergies->subblockNrgChange_flt, 1.0f, nMaxBuffSize ); pSubblockEnergies->nDelay = nDelay / pDelayBuffer->nSubblockSize; assert( pSubblockEnergies->nDelay < nMaxBuffSize ); pSubblockEnergies->nPartialDelay = nDelay % pDelayBuffer->nSubblockSize; - pSubblockEnergies->facAccSubblockNrg_flt = 0.8125f; /* Energy accumulation factor */ + set_f( pSubblockEnergies->accSubblockNrg_flt, MIN_BLOCK_ENERGY, nMaxBuffSize + 1 ); + set_f( pSubblockEnergies->subblockNrg_flt, MIN_BLOCK_ENERGY, nMaxBuffSize ); + set_f( pSubblockEnergies->subblockNrgChange_flt, 1.0f, nMaxBuffSize ); pSubblockEnergies->firState1_flt = 0.0f; pSubblockEnergies->firState2_flt = 0.0f; + pSubblockEnergies->facAccSubblockNrg_flt = 0.8125f; /* Energy accumulation factor */ pSubblockEnergies->pDelayBuffer = pDelayBuffer; pDelayBuffer->nDelay = max( pDelayBuffer->nDelay, pSubblockEnergies->nPartialDelay ); return; } +#endif /** Init transient detector. @@ -545,6 +554,7 @@ static void InitSubblockEnergies( * @param attackRatioThreshold Attack ratio threshold. * @param pTransientDetector Structure to be initialized. */ +#ifndef IVAS_FLOAT_FIXED static void InitTransientDetector( SubblockEnergies *pSubblockEnergies, const int16_t nDelay, @@ -572,6 +582,7 @@ static void InitTransientDetector( return; } +#endif #ifndef IVAS_FLOAT_FIXED diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index 1300d421f370366101acbb437bc166aa73a757fc..4c9907b2846451300ecbbacbc882f6df07d5edec 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -44,6 +44,7 @@ static void InitDelayBuffer( Word16 nFrameLength, Word16 nDelay, DelayBuffer *pDelayBuffer ); static void InitSubblockEnergies( Word16 nFrameLength, Word16 nDelay, DelayBuffer *pDelayBuffer, SubblockEnergies *pSubblockEnergies ); +static void InitSubblockEnergies_ivas_fx( Word16 nFrameLength, Word16 nDelay, DelayBuffer *pDelayBuffer, SubblockEnergies *pSubblockEnergies ); static void InitTransientDetector_fx( SubblockEnergies *pSubblockEnergies, Word16 nDelay, Word16 nSubblocksToCheck, TCheckSubblocksForAttack_fx pCheckSubblocksForAttack, Word16 attackRatioThreshold, TransientDetector *pTransientDetector ); static void UpdateDelayBuffer( Word16 const *input, Word16 nSamplesAvailable, DelayBuffer *pDelayBuffer ); static void HighPassFilter( Word16 const *input, Word16 length, Word16 *pFirState1, Word16 *pFirState2, Word16 *output ); @@ -255,7 +256,7 @@ void InitTransientDetection_ivas_fx( Word16 nFrameLength, /* Init the delay buffer. */ InitDelayBuffer( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer ); /* Init a subblock energies buffer used for the TCX Short/Long decision. */ - InitSubblockEnergies( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer, &pTransientDetection->subblockEnergies ); + InitSubblockEnergies_ivas_fx( nFrameLength, nTCXDelay, &pTransientDetection->delayBuffer, &pTransientDetection->subblockEnergies ); /* Init the TCX Short/Long transient detector. */ InitTCXTransientDetector( nTCXDelay, &pTransientDetection->subblockEnergies, &pTransientDetection->transientDetector ); /* We need two past subblocks for the TCX TD and NSUBBLOCKS+1 for the temporal flatness measure FOR the TCX LTP. */ @@ -956,6 +957,28 @@ static void InitSubblockEnergies( Word16 nFrameLength, Word16 nDelay, DelayBuffe pDelayBuffer->nDelay = s_max( pDelayBuffer->nDelay, pSubblockEnergies->nPartialDelay ); } +static void InitSubblockEnergies_ivas_fx( Word16 nFrameLength, Word16 nDelay, DelayBuffer *pDelayBuffer, SubblockEnergies *pSubblockEnergies ) +{ + Word16 const nMaxBuffSize = sizeof( pSubblockEnergies->subblockNrg ) / sizeof( pSubblockEnergies->subblockNrg[0] ); + (void) nFrameLength; + + + assert( ( pDelayBuffer != NULL ) && ( pSubblockEnergies != NULL ) && ( pDelayBuffer->nSubblockSize * NSUBBLOCKS == nFrameLength ) && ( pDelayBuffer->nSubblockSize > 0 ) ); + + set32_fx( pSubblockEnergies->subblockNrg, 13743, nMaxBuffSize ); + set32_fx( pSubblockEnergies->accSubblockNrg, 13743, nMaxBuffSize + 1 ); + set16_fx( pSubblockEnergies->subblockNrgChange, ONE_IN_Q7, nMaxBuffSize ); + pSubblockEnergies->nDelay = nDelay / pDelayBuffer->nSubblockSize; + assert( pSubblockEnergies->nDelay < nMaxBuffSize ); + pSubblockEnergies->nPartialDelay = nDelay % pDelayBuffer->nSubblockSize; + pSubblockEnergies->facAccSubblockNrg = 26624 /*0.8125f Q15*/; /* Energy accumulation factor */ + pSubblockEnergies->firState1 = 0; + pSubblockEnergies->firState2 = 0; + + pSubblockEnergies->pDelayBuffer = pDelayBuffer; + pDelayBuffer->nDelay = s_max( pDelayBuffer->nDelay, pSubblockEnergies->nPartialDelay ); +} + /** Init transient detector. * Fills TransientDetector structure with sensible content and enable it. * @param pSubblockEnergies Subblock energies used in this transient detector. diff --git a/lib_rend/ivas_reverb_iir_filter.c b/lib_rend/ivas_reverb_iir_filter.c index 85245aadcccfb44dc15fde8aa3d2d928662de202..5ec718a3fdd2aaa20249f817e60f10f5fdcbc444 100644 --- a/lib_rend/ivas_reverb_iir_filter.c +++ b/lib_rend/ivas_reverb_iir_filter.c @@ -63,9 +63,9 @@ void ivas_reverb_iir_filt_init( FOR( UWord16 i = 0; i < maxTaps; i++ ) { - iirFilter->CoefA_fx[i] = 0; + iirFilter->CoefA_fx[i] = 0; /*Q30*/ move32(); - iirFilter->CoefB_fx[i] = 0; + iirFilter->CoefB_fx[i] = 0; /*Q30*/ move32(); } @@ -111,8 +111,8 @@ void ivas_reverb_iir_filt_init( void ivas_reverb_iir_filt_set( ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ UWord16 nr_taps, /* i : number of IIR filter taps */ - const Word16 *coefA, /* i : A filter coefficients to set */ - const Word16 *coefB /* i : the B filter coefficients to set */ + const Word16 *coefA, /* i : A filter coefficients to set Q14*/ + const Word16 *coefB /* i : the B filter coefficients to set Q14*/ ) { UWord16 i; @@ -132,7 +132,7 @@ void ivas_reverb_iir_filt_set( { FOR( i = 0; i < iirFilter->nr_taps; i++ ) { - iirFilter->CoefB_fx[i] = L_shl( coefB[i], 16 ); /*Q30*/ + iirFilter->CoefB_fx[i] = L_shl( coefB[i] /*Q14*/, 16 ); /*Q30*/ move32(); } } @@ -140,9 +140,9 @@ void ivas_reverb_iir_filt_set( { FOR( i = 0; i < iirFilter->nr_taps; i++ ) { - iirFilter->CoefA_fx[i] = L_shl( coefA[i], 16 ); /*Q30*/ + iirFilter->CoefA_fx[i] = L_shl( coefA[i] /*Q14*/, 16 ); /*Q30*/ move32(); - iirFilter->CoefB_fx[i] = L_shl( coefB[i], 16 ); /*Q30*/ + iirFilter->CoefB_fx[i] = L_shl( coefB[i] /*Q14*/, 16 ); /*Q30*/ move32(); } } @@ -202,35 +202,35 @@ void ivas_reverb_iir_filt_set( void ivas_reverb_iir_filt_2taps_feed_blk_fx( ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ const UWord16 blk_size, /* i : size */ - const Word32 *input, /* i : input buffer */ - Word32 *output /* i : output buffer */ + const Word32 *input, /* i : input buffer Q30 */ + Word32 *output /* i/o : output buffer Q30 */ ) { UWord16 i; Word32 flt_output_fx = 0; move32(); - Word32 flt_CoefB_0_fx = iirFilter->CoefB_fx[0]; + Word32 flt_CoefB_0_fx = iirFilter->CoefB_fx[0]; /*Q30*/ move32(); - Word32 flt_CoefB_1_fx = iirFilter->CoefB_fx[1]; + Word32 flt_CoefB_1_fx = iirFilter->CoefB_fx[1]; /*Q30*/ move32(); - Word32 flt_CoefA_1_fx = iirFilter->CoefA_fx[1]; + Word32 flt_CoefA_1_fx = iirFilter->CoefA_fx[1]; /*Q30*/ move32(); - Word32 flt_pBuffer_0_fx = iirFilter->pBuffer_fx[0]; + Word32 flt_pBuffer_0_fx = iirFilter->pBuffer_fx[0]; /*Q30*/ move32(); - Word32 flt_pBuffer_1_fx = iirFilter->pBuffer_fx[1]; + Word32 flt_pBuffer_1_fx = iirFilter->pBuffer_fx[1]; /*Q30*/ move32(); FOR( i = 0; i < blk_size; i++ ) { - flt_output_fx = L_add( L_shl( Mpy_32_32( input[i], flt_CoefB_0_fx ), 1 ), flt_pBuffer_0_fx ); - flt_pBuffer_0_fx = L_sub( L_add( flt_pBuffer_1_fx, L_shl( Mpy_32_32( input[i], flt_CoefB_1_fx ), 1 ) ), L_shl( Mpy_32_32( flt_output_fx, flt_CoefA_1_fx ), 1 ) ); - output[i] = flt_output_fx; + flt_output_fx = L_add( L_shl( Mpy_32_32( input[i], flt_CoefB_0_fx ), 1 ), flt_pBuffer_0_fx ); // Q30 + flt_pBuffer_0_fx = L_sub( L_add( flt_pBuffer_1_fx /*Q30*/, L_shl( Mpy_32_32( input[i] /*Q30*/, flt_CoefB_1_fx /*Q30*/ ) /*Q29*/, 1 ) /*Q30*/ ), L_shl( Mpy_32_32( flt_output_fx /*Q30*/, flt_CoefA_1_fx /*Q30*/ ), 1 /*Q30*/ ) ); /*Q30*/ + output[i] = flt_output_fx; /*Q30*/ move32(); } - iirFilter->pBuffer_fx[0] = flt_pBuffer_0_fx; + iirFilter->pBuffer_fx[0] = flt_pBuffer_0_fx; /*Q30*/ move32(); - iirFilter->pBuffer_fx[1] = flt_pBuffer_1_fx; + iirFilter->pBuffer_fx[1] = flt_pBuffer_1_fx; /*Q30*/ move32(); - iirFilter->Output_fx = flt_output_fx; + iirFilter->Output_fx = flt_output_fx; // Q30 move32(); return; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 4ddf64c89d5e9754273c6bb19877872372851bbc..a178953bad28b53c1d8b3b0d8ece6767ca112d91 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -12149,9 +12149,9 @@ static void copyMasaMetadataToDiracRenderer_fx( { FOR( bin = MASA_band_grouping_24[band]; bin < MASA_band_grouping_24[band + 1] && bin < maxBin; bin++ ) { - hSpatParamRendCom->azimuth[meta_write_index][bin] = (Word16) meta->directional_meta[0].azimuth[sf][band]; + hSpatParamRendCom->azimuth[meta_write_index][bin] = extract_l( L_shr( meta->directional_meta[0].azimuth_fx[sf][band], Q22 ) ); // Q22 -> Q0 move16(); - hSpatParamRendCom->elevation[meta_write_index][bin] = (Word16) meta->directional_meta[0].elevation[sf][band]; + hSpatParamRendCom->elevation[meta_write_index][bin] = extract_l( L_shr( meta->directional_meta[0].elevation_fx[sf][band], Q22 ) ); // Q22 -> Q0 move16(); hSpatParamRendCom->energy_ratio1_fx[meta_write_index][bin] = meta->directional_meta[0].energy_ratio_fx[sf][band]; move32(); @@ -12164,9 +12164,9 @@ static void copyMasaMetadataToDiracRenderer_fx( IF( EQ_16( hSpatParamRendCom->numSimultaneousDirections, 2 ) ) { - hSpatParamRendCom->azimuth2[meta_write_index][bin] = (Word16) meta->directional_meta[1].azimuth[sf][band]; + hSpatParamRendCom->azimuth2[meta_write_index][bin] = extract_l( L_shr( meta->directional_meta[1].azimuth_fx[sf][band], Q22 ) ); // Q22 -> Q0 move16(); - hSpatParamRendCom->elevation2[meta_write_index][bin] = (Word16) meta->directional_meta[1].elevation[sf][band]; + hSpatParamRendCom->elevation2[meta_write_index][bin] = extract_l( L_shr( meta->directional_meta[1].elevation_fx[sf][band], Q22 ) ); // Q22 -> Q0 move16(); hSpatParamRendCom->energy_ratio2_fx[meta_write_index][bin] = meta->directional_meta[1].energy_ratio_fx[sf][band]; move32(); diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 11178d54c378ed1e88ec3a3185e61cc704ea9924..59d7b632c35ae4198e67e9633fc6d5387430313d 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -190,8 +190,9 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { +#ifndef IVAS_FLOAT_FIXED deindex_sph_idx( readIndex[b], &self->sph_grid16, &( hMeta->directional_meta[i].elevation[j][b] ), &( hMeta->directional_meta[i].azimuth[j][b] ) ); -#ifdef IVAS_FLOAT_FIXED +#else deindex_sph_idx_fx( readIndex[b], &self->sph_grid16, &( hMeta->directional_meta[i].elevation_fx[j][b] ), &( hMeta->directional_meta[i].azimuth_fx[j][b] ) ); #endif hMeta->directional_meta[i].spherical_index[j][b] = readIndex[b]; @@ -205,9 +206,10 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { +#ifndef IVAS_FLOAT_FIXED hMeta->directional_meta[i].energy_ratio[j][b] = ( (float) readOther[b] ) / UINT8_MAX; -#ifdef IVAS_FLOAT_FIXED - hMeta->directional_meta[i].energy_ratio_fx[j][b] = (Word32) ( readOther[b] * ONE_IN_Q22 ); // Q30 +#else + hMeta->directional_meta[i].energy_ratio_fx[j][b] = (Word32) ( readOther[b] * ONE_IN_Q22 ); // Q30 #endif } @@ -220,8 +222,9 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { +#ifndef IVAS_FLOAT_FIXED hMeta->directional_meta[i].spread_coherence[j][b] = ( (float) readOther[b] ) / UINT8_MAX; -#ifdef IVAS_FLOAT_FIXED +#else hMeta->directional_meta[i].spread_coherence_fx[j][b] = (Word16) ( readOther[b] * ONE_IN_Q7 ); // Q15 #endif @@ -237,9 +240,10 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { +#ifndef IVAS_FLOAT_FIXED hMeta->common_meta.diffuse_to_total_ratio[j][b] = ( (float) readOther[b] ) / UINT8_MAX; -#ifdef IVAS_FLOAT_FIXED - hMeta->common_meta.diffuse_to_total_ratio_fx[j][b] = (Word32) ( readOther[b] * ONE_IN_Q22 ); // Q30 +#else + hMeta->common_meta.diffuse_to_total_ratio_fx[j][b] = (Word32) ( readOther[b] * ONE_IN_Q22 ); // Q30 #endif } @@ -252,9 +256,10 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { +#ifndef IVAS_FLOAT_FIXED hMeta->common_meta.surround_coherence[j][b] = ( (float) readOther[b] ) / UINT8_MAX; -#ifdef IVAS_FLOAT_FIXED - hMeta->common_meta.surround_coherence_fx[j][b] = shl( (Word16) readOther[b], 7 ); // Q8->Q15 +#else + hMeta->common_meta.surround_coherence_fx[j][b] = shl( (Word16) readOther[b], 7 ); // Q8->Q15 move16(); #endif } @@ -267,7 +272,12 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { +#ifndef IVAS_FLOAT_FIXED hMeta->common_meta.remainder_to_total_ratio[j][b] = ( (float) readOther[b] ) / UINT8_MAX; +#else + hMeta->common_meta.remainder_to_total_ratio_fx[j][b] = L_shl( (Word32) readOther[b], Q22 ); // Q8 -> Q30 + move32(); +#endif } }