From 9fce618c817ee978d9e9986f002d324f0a412994 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 23 Oct 2024 10:53:01 +0530 Subject: [PATCH] Q info addition for decoder and renderer files - 1 --- lib_com/prot_fx.h | 183 ++++---- lib_dec/dec_pit_exc_fx.c | 25 +- lib_dec/dec_post_fx.c | 278 ++++++------ lib_dec/dec_ppp_fx.c | 2 +- lib_dec/dec_prm_fx.c | 579 +++++++++++++----------- lib_dec/dec_tcx_fx.c | 187 ++++---- lib_dec/decision_matrix_dec_fx.c | 93 ++-- lib_dec/gs_dec_amr_wb_fx.c | 184 ++++---- lib_dec/gs_dec_fx.c | 398 ++++++++-------- lib_dec/hdecnrm_fx.c | 162 +++---- lib_dec/ivas_stereo_dft_dec_fx.c | 4 +- lib_dec/stat_dec.h | 2 +- lib_rend/ivas_prot_rend.h | 56 +-- lib_rend/ivas_reverb_delay_line.c | 60 +-- lib_rend/ivas_reverb_fft_filter.c | 117 ++--- lib_rend/ivas_rom_binaural_crend_head.c | 4 +- lib_rend/ivas_rom_rend.c | 10 +- 17 files changed, 1207 insertions(+), 1137 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 20a851b29..1a1b8a81a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -827,7 +827,7 @@ void compute_poly_product_fx( Word16 *coef, Word32 *p, Word16 order ); void dec_prm_hm_fx( Decoder_State *st, - Word16 *prm_hm, + Word16 *prm_hm, /* Q0 */ const Word16 L_frame ); void msvq_dec( const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) (0Q15) */ @@ -6358,9 +6358,9 @@ void TonalMDCTConceal_SaveTimeSignal( // decision_matrix_dec_fx.c void decision_matrix_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ - Word16 *sharpFlag, /* o : formant sharpening flag */ - Word16 *hq_core_type, /* o : HQ core type */ - Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag */ + Word16 *sharpFlag, /* o : formant sharpening flag Q0 */ + Word16 *hq_core_type, /* o : HQ core type Q0 */ + Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag Q0 */ ); // hf_synth_fx.c @@ -6627,60 +6627,60 @@ void PulseResynchronization_fx( // gs_dec_fx.c void decod_audio_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain */ - const Word16 *Aq, /* i : LP filter coefficient */ - Word16 *pitch_buf, /* o : floating pitch values for each subframe */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *exc, /* i/o: adapt. excitation exc */ - Word16 *exc2, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ - Word16 *lsf_new /* i : ISFs at the end of the frame */ + Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ + const Word16 *Aq, /* i : LP filter coefficient Q12*/ + Word16 *pitch_buf, /* o : floating pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ + Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ + Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/ , Word16 *gain_buf /*Q14*/ ); void decod_audio_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain */ - const Word16 *Aq, /* i : LP filter coefficient */ - Word16 *pitch_buf, /* o : floating pitch values for each subframe */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *exc, /* i/o: adapt. excitation exc */ - Word16 *exc2, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ - Word16 *lsf_new /* i : ISFs at the end of the frame */ + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ + const Word16 *Aq, /* i : LP filter coefficient Q12*/ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ + Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ + Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/ , Word16 *gain_buf, /*Q14*/ - const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ + const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ ); void gsc_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation */ - const Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - const Word16 nb_subfr, /* i : Number of subframe considered */ - const Word16 coder_type, /* i : coding type */ - Word16 *last_bin, /* i : last bin of bit allocation */ - const Word16 *lsf_new, /* i : ISFs at the end of the frame */ - Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill */ + Decoder_State *st_fx, /* i/o: State structure */ + Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ + const Word16 pit_band_idx, /* i : bin position of the cut-off frequency Q0*/ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + Word16 *last_bin, /* i : last bin of bit allocation Q0*/ + const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 Q_exc ); void gsc_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ - Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation */ - const Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - const Word16 nb_subfr, /* i : Number of subframe considered */ - const Word16 coder_type, /* i : coding type */ - Word16 *last_bin, /* i : last bin of bit allocation */ - const Word16 *lsf_new, /* i : ISFs at the end of the frame */ - Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill */ + Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ + const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + Word16 *last_bin, /* i : last bin of bit allocation Q0*/ + const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 *Q_exc ); void GSC_dec_init( @@ -7647,8 +7647,8 @@ void dequantize_norms_fx( // hdecnrm_fx.c void hdecnrm_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 numNorms, /* (i) number of norms */ - Word16 *index ); /* (o) indices of quantized norms */ + const Word16 numNorms, /* (i) number of norms Q0*/ + Word16 *index ); /* (o) indices of quantized norms Q0*/ Word16 decode_huff_context_fx( @@ -7658,31 +7658,32 @@ Word16 decode_huff_context_fx( void hdecnrm_context_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, - Word16 *index, - Word16 *n_length ); + const Word16 N, /* Q0 */ + Word16 *index, /* Q0 */ + Word16 *n_length /* Q0 */ +); void hdecnrm_resize_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* (i) number of SFMs */ - Word16 *index /* (o) norm quantization index vector */ + const Word16 N, /* (i) number of SFMs Q0*/ + Word16 *index /* (o) norm quantization index vector Q0*/ ); void huff_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : Number of codewords to decode */ - const Word16 buffer_len, /* i : Number of bits to read */ - const Word16 num_lengths, /* i : Number of different huffman codeword lengths */ - const Word16 *thres, /* i : Threshold of first codeword of each length */ - const Word16 *offset, /* i : Offset for first codeword */ - const Word16 *huff_tab, /* i : Huffman table order by codeword lengths */ - Word16 *index /* o : Decoded index */ + const Word16 N, /* i : Number of codewords to decode Q0*/ + const Word16 buffer_len, /* i : Number of bits to read Q0*/ + const Word16 num_lengths, /* i : Number of different huffman codeword lengths Q0*/ + const Word16 *thres, /* i : Threshold of first codeword of each length Q0*/ + const Word16 *offset, /* i : Offset for first codeword Q0*/ + const Word16 *huff_tab, /* i : Huffman table order by codeword lengths Q0*/ + Word16 *index /* o : Decoded index Q0*/ ); void hdecnrm_tran_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : number of norms */ - Word16 *index /* o : indices of quantized norms */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* i : number of norms Q0*/ + Word16 *index /* o : indices of quantized norms Q0*/ ); #endif @@ -8129,24 +8130,24 @@ void music_postfilt_init( // gs_dec_amr_wb.c void improv_amr_wb_gs_fx( - const Word16 clas, /* i : signal frame class */ - const Word16 coder_type, /* i : coder type */ - const Word32 core_brate, /* i : bitrate allocated to the core */ - Word16 *seed_tcx, /* i/o: Seed used for noise generation */ - Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient */ - Word16 *mem_syn2_fx, /* i/o: synthesis memory */ - const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q15 */ - const Word16 locattack, /* i : Flag for a detected attack */ - Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient */ - Word16 *exc2_fx, /* i/o: Decoded complete excitation */ - const Word16 Q_exc2, /* i : Exponent of Exc2 */ - Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory */ - Word16 *syn_fx, /* o: Decoded synthesis to be updated */ - const Word16 Q_syn, /* i : Synthesis scaling Q0 */ - const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer */ - const Word16 Last_ener_fx, /* i : Last energy (Q8) */ - const Word16 rate_switching_reset, /* i : rate switching reset flag */ - const Word16 last_coder_type /* i : Last coder_type */ + const Word16 clas, /* i : signal frame class Q0*/ + const Word16 coder_type, /* i : coder type Q0*/ + const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ + Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ + Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ + Word16 *mem_syn2_fx, /* i/o: synthesis memory Q_syn*/ + const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ + const Word16 locattack, /* i : Flag for a detected attack Q0*/ + Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient q_Aq*/ + Word16 *exc2_fx, /* i/o: Decoded complete excitation Q_exc2*/ + const Word16 Q_exc2, /* i : Exponent of Exc2 */ + Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ + Word16 *syn_fx, /* o: Decoded synthesis to be updated Q_syn*/ + const Word16 Q_syn, /* i : Synthesis scaling */ + const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ + const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ + const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ + const Word16 last_coder_type /* i : Last coder_type Q0*/ #ifdef ADD_IVAS_GS_DEC_IMPR , const Word16 VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */ @@ -8715,13 +8716,13 @@ void getTCXparam_fx( Decoder_State *st, /* i/o: Decoder State handle */ Decoder_State *st0, /* i : bitstream */ CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */ - Word16 param[], /* o : decoded parameters */ - const Word16 bits_common, /* i : number of common bits */ - const Word16 start_bit_pos, /* i : position of the start bit */ - const Word16 *no_param_tns, /* i : number of TNS parameters per subframe */ - Word16 p_param[2], /* o : pointer to parameters for next round of bs reading*/ - Word16 nTnsBitsTCX10[2], - const Word16 pre_past_flag ); + Word16 param[], /* o : decoded parameters Q0 */ + const Word16 bits_common, /* i : number of common bits Q0 */ + const Word16 start_bit_pos, /* i : position of the start bit Q0 */ + const Word16 *no_param_tns, /* i : number of TNS parameters per subframe Q0 */ + Word16 p_param[2], /* o : pointer to parameters for next round of bs reading Q0 */ + Word16 nTnsBitsTCX10[2], /*Q0*/ + const Word16 pre_past_flag /*Q0*/ ); void dec_prm_fx( Word16 *coder_type, Word16 param[], /* (o) : decoded parameters */ @@ -8732,11 +8733,11 @@ void dec_prm_fx( Word16 *bitsRead ); void getLPCparam_fx( - Decoder_State *st, /* i/o: decoder memory state */ - Word16 param_lpc[], /* o : LTP parameters */ - Decoder_State *st0, /* i : bitstream */ - const Word16 ch, /* i : channel */ - const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ + Decoder_State *st, /* i/o: decoder memory state */ + Word16 param_lpc[], /* o : LTP parameters Q0 */ + Decoder_State *st0, /* i : bitstream */ + const Word16 ch, /* i : channel Q0 */ + const Word16 sns_low_br_mode /* i : SNS low-bitrate mode Q0 */ ); // ari_hm_fx.c diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index 3328839ea..d04dc1b30 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -21,7 +21,7 @@ /*--------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ /* _ (Word16*) pitch_buf_fx : floating pitch values for each subframe Q6 */ -/* _ (Word16*) code_fx : innovation */ +/* _ (Word16*) code_fx : innovation Q12 */ /*--------------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ /* Decoder_State_fx *st_fx : decoder state structure */ @@ -80,6 +80,7 @@ void dec_pit_exc_fx( Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */ #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; + move16(); #endif use_fcb = 0; @@ -269,7 +270,7 @@ void dec_pit_exc_fx( * Find the total excitation *----------------------------------------------------------------------*/ - Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[shr( imult1616( i_subfr_fx, 2 * HIBND_ACB_L_FAC ), 1 )], hGSCDec->last_exc_dct_in_fx, + Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[( i_subfr_fx * ( 2 * HIBND_ACB_L_FAC ) ) / 2], hGSCDec->last_exc_dct_in_fx, L_subfr_fx, shr( imult1616( L_subfr_fx, 2 * HIBND_ACB_L_FAC ), 1 ), gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, i_subfr_fx, coder_type ); gain_code16 = round_fx( L_shl( gain_code_fx, st_fx->Q_exc ) ); /*Q_exc*/ @@ -285,8 +286,8 @@ void dec_pit_exc_fx( FOR( i = 0; i < L_subfr_fx; i++ ) { #ifdef BASOP_NOGLOB - L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[add( i, i_subfr_fx )] ), 1 ); /*Q16+Q_exc*/ - exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/ + L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /*Q16+Q_exc*/ + exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/ #else L_tmp = L_shl( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /*Q16+Q_exc*/ exc_fx[i + i_subfr_fx] = round_fx( L_tmp ); /*Q_exc*/ @@ -300,7 +301,7 @@ void dec_pit_exc_fx( FOR( i = 0; i < L_subfr_fx; i++ ) { - L_tmp = L_mult( gain_pitx2, exc_fx[add( i, i_subfr_fx )] ); /*Q16+Q_exc*/ + L_tmp = L_mult( gain_pitx2, exc_fx[i + i_subfr_fx] ); /*Q16+Q_exc*/ #ifdef BASOP_NOGLOB exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/ #else @@ -695,7 +696,7 @@ void dec_pit_exc_ivas_fx( move16(); } #ifdef BASOP_NOGLOB - gain_code_fx = L_mult0( s_max( sub( 32767, shl_o( gain_pit_fx, 1, &Overflow ) ), 16384 ), st_fx->lp_gainc_fx ); /* Use gain pitch and past gain code as an indicator to help finding the best scaling value. gain_code_fx used a temp var*/ + gain_code_fx = L_mult0( s_max( sub( 32767, shl_o( gain_pit_fx, 1, &Overflow ) ), 16384 /*0.5.Q15*/ ), st_fx->lp_gainc_fx ); /* Use gain pitch and past gain code as an indicator to help finding the best scaling value. gain_code_fx used a temp var*/ #else gain_code_fx = L_mult0( s_max( sub( 32767, shl( gain_pit_fx, 1 ) ), 16384 ), st_fx->lp_gainc_fx ); /* Use gain pitch and past gain code as an indicator to help finding the best scaling value. gain_code_fx used a temp var*/ #endif @@ -704,7 +705,7 @@ void dec_pit_exc_ivas_fx( /*----------------------------------------------------------------------* * Find the total excitation *----------------------------------------------------------------------*/ - Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[shr( imult1616( i_subfr_fx, 2 * HIBND_ACB_L_FAC ), 1 )], hGSCDec->last_exc_dct_in_fx, + Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[( i_subfr_fx * ( 2 * HIBND_ACB_L_FAC ) ) / 2], hGSCDec->last_exc_dct_in_fx, L_subfr_fx, shr( imult1616( L_subfr_fx, 2 * HIBND_ACB_L_FAC ), 1 ), gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, i_subfr_fx, coder_type ); gain_code16 = round_fx( L_shl( gain_code_fx, st_fx->Q_exc ) ); /*Q_exc*/ @@ -726,8 +727,8 @@ void dec_pit_exc_ivas_fx( { FOR( i = 0; i < L_subfr_fx; i++ ) { - L_tmp = L_shl( L_mult( gain_pit_fx, exc_fx[add( i, i_subfr_fx )] ), 1 ); /*Q16+Q_exc*/ - exc_fx[add( i, i_subfr_fx )] = round_fx( L_tmp ); /*Q_exc*/ + L_tmp = L_shl( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /*Q16+Q_exc*/ + exc_fx[i + i_subfr_fx] = round_fx( L_tmp ); /*Q_exc*/ move16(); } } @@ -737,8 +738,8 @@ void dec_pit_exc_ivas_fx( FOR( i = 0; i < L_subfr_fx; i++ ) { - L_tmp = L_mult( gain_pitx2, exc_fx[add( i, i_subfr_fx )] ); /*Q16+Q_exc*/ - exc_fx[add( i, i_subfr_fx )] = round_fx( L_tmp ); /*Q_exc*/ + L_tmp = L_mult( gain_pitx2, exc_fx[i + i_subfr_fx] ); /*Q16+Q_exc*/ + exc_fx[i + i_subfr_fx] = round_fx( L_tmp ); /*Q_exc*/ move16(); } } @@ -859,7 +860,7 @@ void dec_pit_exc_ivas_fx( p_Aq_fx += 4 * ( M + 1 ); /* update gains for FEC - equivalent to lp_gain_updt() */ - st_fx->lp_gainp_fx = gain_pit_fx; + st_fx->lp_gainp_fx = gain_pit_fx; // Q14 move16(); st_fx->lp_gainc_fx = 0; move16(); diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index 977146b34..296b5cef7 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -103,7 +103,7 @@ void nb_post_filt_fx( /* update long-term background noise energy during inactive frames */ IF( EQ_16( coder_type, INACTIVE ) ) { - *psf_lp_noise = round_fx( L_mac( L_mult( 31130, *psf_lp_noise ), 26214 /*0.05 Q19*/, shl( tmp_noise, 4 ) ) ); /*Q8*Q15 + Q19*Q4 -> Q8 */ + *psf_lp_noise = round_fx( L_mac( L_mult( 31130 /*0.95.Q15*/, *psf_lp_noise ), 26214 /*0.05 Q19*/, shl( tmp_noise, 4 ) ) ); /*Q8*Q15 + Q19*Q4 -> Q8 */ } } @@ -112,17 +112,17 @@ void nb_post_filt_fx( IF( hPFstat->reset ) { set16_fx( hPFstat->mem_res2, 0, DECMEM_RES2 ); - Copy( &Synth[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); + Copy( &Synth[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); // Qsyn Copy( &Synth[L_frame - L_SYN_MEM], hPFstat->mem_stp, L_SYN_MEM ); - hPFstat->gain_prec = 16384; + hPFstat->gain_prec = 16384; // 1.Q14 move16(); hPFstat->reset = 0; move16(); return; } Pf_in = &pf_in_buffer[M]; - Copy( hPFstat->mem_pf_in + L_SYN_MEM - M, &Pf_in[-M], M ); - Copy( Synth, Pf_in, L_frame ); + Copy( hPFstat->mem_pf_in + L_SYN_MEM - M, &Pf_in[-M], M ); // Qsyn + Copy( Synth, Pf_in, L_frame ); // Qsyn Copy( &Synth[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); /* deactivation of the post filter in case of AUDIO because it causes problems to singing sequences */ IF( EQ_16( coder_type, AUDIO ) ) @@ -137,13 +137,13 @@ void nb_post_filt_fx( /* run the post filter */ - p_Aq = Aq; + p_Aq = Aq; // Q12 move16(); j = 0; move16(); FOR( i = 0; i < L_frame; i += L_SUBFR ) { - T0_first = Pitch_buf[j]; + T0_first = Pitch_buf[j]; // Q6 move16(); Dec_postfilt_fx( hPFstat, T0_first, &Pf_in[i], p_Aq, &Synth[i], Post_G1, Post_G2, Gain_factor, disable_hpf ); @@ -180,26 +180,26 @@ void nb_post_filt_fx( *----------------------------------------------------------------------------*/ static void Dec_postfilt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - const Word16 t0, /* i : pitch delay given by coder */ - const Word16 *signal_ptr, /* i : input signal (pointer to current subframe */ - const Word16 *coeff, /* i : LPC coefficients for current subframe */ - Word16 *sig_out, /* o : postfiltered output */ - const Word16 gamma1, /* i : short term postfilt. den. weighting factor */ - const Word16 gamma2, /* i : short term postfilt. num. weighting factor */ + const Word16 t0, /* i : pitch delay given by coder Q6 */ + const Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q0 */ + const Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */ + Word16 *sig_out, /* o : postfiltered output Q15*/ + const Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/ + const Word16 gamma2, /* i : short term postfilt. num. weighting factor Q15*/ const Word16 Gain_factor, /* i : Gain Factor (Q15) */ const Word16 disable_hpf ) { /* Local variables and arrays */ - Word16 apond1[M + 1]; /* s.t. denominator coeff. */ - Word16 apond2[LONG_H_ST]; + Word16 apond1[M + 1]; /* s.t. denominator coeff. Q12*/ + Word16 apond2[LONG_H_ST]; // Q12 Word16 sig_ltp[L_SUBFR + 1]; /* H0 output signal */ - Word16 res2[SIZ_RES2]; + Word16 res2[SIZ_RES2]; // Q0 Word16 *sig_ltp_ptr; Word16 *res2_ptr; Word16 *ptr_mem_stp; - Word16 parcor0; + Word16 parcor0; // Q15 /* Init pointers and restore memories */ @@ -259,7 +259,7 @@ static void Dec_postfilt_fx( void formant_post_filt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ - Word16 *Aq, /* i : LP filter coefficient */ + Word16 *Aq, /* i : LP filter coefficient Q12 */ Word16 *synth_out, /* i/o: input signal */ Word16 L_frame, Word32 lp_noise, /* (i) : background noise energy (15Q16) */ @@ -269,7 +269,7 @@ void formant_post_filt_fx( { Word16 i_subfr; Word16 *p_Aq; - Word16 post_G1, post_G2; + Word16 post_G1, post_G2; // Q15 /*default parameter for noisy speech and high bit-rates*/ @@ -351,7 +351,7 @@ void formant_post_filt_fx( } /* Reset post filter */ - if ( hPFstat->reset != 0 ) + IF( hPFstat->reset != 0 ) { post_G1 = MAX16B; move16(); @@ -361,7 +361,7 @@ void formant_post_filt_fx( move16(); Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_stp, L_SYN_MEM ); - hPFstat->gain_prec = 16384; + hPFstat->gain_prec = 16384; // 1.Q14 move16(); Copy( synth_in, synth_out, L_frame ); @@ -373,7 +373,7 @@ void formant_post_filt_fx( Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); move16(); - p_Aq = Aq; + p_Aq = Aq; // Q12 FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) { Dec_formant_postfilt_fx( hPFstat, &synth_in[i_subfr], p_Aq, &synth_out[i_subfr], post_G1, post_G2 ); @@ -385,7 +385,7 @@ void formant_post_filt_fx( void formant_post_filt_ivas_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ - Word16 *Aq, /* i : LP filter coefficient */ + Word16 *Aq, /* i : LP filter coefficient Q12 */ Word16 *synth_out, /* i/o: input signal */ Word16 L_frame, Word32 lp_noise, /* (i) : background noise energy (15Q16) */ @@ -477,7 +477,7 @@ void formant_post_filt_ivas_fx( } /* Reset post filter */ - if ( hPFstat->reset != 0 ) + IF( hPFstat->reset != 0 ) { post_G1 = MAX16B; move16(); @@ -487,7 +487,7 @@ void formant_post_filt_ivas_fx( move16(); Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_stp, L_SYN_MEM ); - hPFstat->gain_prec = 16384; + hPFstat->gain_prec = 16384; // 1.Q14 move16(); Copy( synth_in, synth_out, L_frame ); @@ -499,7 +499,7 @@ void formant_post_filt_ivas_fx( Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); move16(); - p_Aq = Aq; + p_Aq = Aq; // Q12 FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) { Dec_formant_postfilt_ivas_fx( hPFstat, &synth_in[i_subfr], p_Aq, &synth_out[i_subfr], post_G1, post_G2 ); @@ -524,19 +524,19 @@ void formant_post_filt_ivas_fx( *----------------------------------------------------------------------------*/ static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *signal_ptr, /* i : input signal (pointer to current subframe */ - Word16 *coeff, /* i : LPC coefficients for current subframe */ + Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/ + Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */ Word16 *sig_out, /* o : postfiltered output */ - Word16 gamma1, /* i : short term postfilt. den. weighting factor*/ - Word16 gamma2 /* i : short term postfilt. num. weighting factor*/ + Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/ + Word16 gamma2 /* i : short term postfilt. num. weighting factor Q15*/ ) { /* Local variables and arrays */ - Word16 apond1[M + 1]; /* s.t. denominator coeff. */ - Word16 apond2[LONG_H_ST]; - Word16 res2[L_SUBFR]; - Word16 resynth[L_SUBFR + 1]; - Word16 parcor0; + Word16 apond1[M + 1]; /* s.t. denominator coeff. Q12*/ + Word16 apond2[LONG_H_ST]; // Q12 + Word16 res2[L_SUBFR]; // Q14 + Word16 resynth[L_SUBFR + 1]; // Qy + Word16 parcor0; // Q15 Word16 i, max; Word16 scale_down; @@ -545,14 +545,14 @@ static void Dec_formant_postfilt_fx( weight_a_fx( coeff, apond2, gamma2, M ); set16_fx( &apond2[M + 1], 0, LONG_H_ST - ( M + 1 ) ); - max = abs_s( signal_ptr[0] ); + max = abs_s( signal_ptr[0] ); // Q14 FOR( i = 1; i < L_SUBFR; i++ ) { max = s_max( max, abs_s( signal_ptr[i] ) ); } scale_down = 0; move16(); - if ( GT_16( max, 16384 ) ) + if ( GT_16( max, 16384 /*1.Q14*/ ) ) { scale_down = 1; move16(); @@ -604,19 +604,19 @@ static void Dec_formant_postfilt_fx( #ifdef IVAS_FLOAT_FIXED static void Dec_formant_postfilt_ivas_fx( PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *signal_ptr, /* i : input signal (pointer to current subframe */ - Word16 *coeff, /* i : LPC coefficients for current subframe */ + Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/ + Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */ Word16 *sig_out, /* o : postfiltered output */ - Word16 gamma1, /* i : short term postfilt. den. weighting factor*/ - Word16 gamma2 /* i : short term postfilt. num. weighting factor*/ + Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/ + Word16 gamma2 /* i : short term postfilt. num. weighting factor Q15*/ ) { /* Local variables and arrays */ - Word16 apond1[M + 1]; /* s.t. denominator coeff. */ - Word16 apond2[LONG_H_ST]; - Word16 res2[L_SUBFR]; - Word16 resynth[L_SUBFR + 1]; - Word16 parcor0; + Word16 apond1[M + 1]; /* s.t. denominator coeff. Q12*/ + Word16 apond2[LONG_H_ST]; // Q12 + Word16 res2[L_SUBFR]; // Q14 + Word16 resynth[L_SUBFR + 1]; // Qy + Word16 parcor0; // Q15 Word16 i, max; Word16 scale_down; @@ -625,14 +625,14 @@ static void Dec_formant_postfilt_ivas_fx( weight_a_fx( coeff, apond2, gamma2, M ); set16_fx( &apond2[M + 1], 0, LONG_H_ST - ( M + 1 ) ); - max = abs_s( signal_ptr[0] ); + max = abs_s( signal_ptr[0] ); // Q14 FOR( i = 1; i < L_SUBFR; i++ ) { max = s_max( max, abs_s( signal_ptr[i] ) ); } scale_down = 0; move16(); - if ( GT_16( max, 16384 ) ) + if ( GT_16( max, 16384 /*1.Q14*/ ) ) { scale_down = 1; move16(); @@ -693,7 +693,7 @@ static void modify_pst_param_fx( Word16 *g1, /* o : Gamma1 used in post filter Q15 */ Word16 *g2, /* o : Gamma1 used in post filter Q15 */ const Word16 coder_type, /* i : Vad information decoded in UV frame */ - Word16 *gain_factor /* o : Gain factor applied in post filtering */ + Word16 *gain_factor /* o : Gain factor applied in post filtering Q15 */ ) { Word16 tmp; @@ -758,9 +758,9 @@ static void modify_pst_param_fx( * Perform harmonic postfilter *----------------------------------------------------------------------------*/ static void pst_ltp_fx( - Word16 t0, /* i : pitch delay given by coder */ - Word16 *ptr_sig_in, /* i : postfilter i filter (residu2) */ - Word16 *ptr_sig_pst0, /* o : harmonic postfilter o */ + Word16 t0, /* i : pitch delay given by coder Q6 */ + Word16 *ptr_sig_in, /* i : postfilter i filter (residu2) Qx */ + Word16 *ptr_sig_pst0, /* o : harmonic postfilter o Qx */ Word16 gain_factor /* i : Gain Factor (Q15) */ ) { @@ -790,8 +790,8 @@ static void pst_ltp_fx( /* i signal justified on 13 bits */ - ptr_sig = ptr_sig_in - DECMEM_RES2; - nb_sh_sig = getScaleFactor16( ptr_sig, add( DECMEM_RES2, L_SUBFR ) ); + ptr_sig = ptr_sig_in - DECMEM_RES2; // Qx + nb_sh_sig = getScaleFactor16( ptr_sig, DECMEM_RES2 + L_SUBFR ); nb_sh_sig = sub( 3, nb_sh_sig ); FOR( i = 0; i < DECMEM_RES2 + L_SUBFR; i++ ) @@ -814,7 +814,7 @@ static void pst_ltp_fx( { IF( phase == 0 ) { - ptr_y_up = ptr_sig_in - ltpdel; + ptr_y_up = ptr_sig_in - ltpdel; // Qx } ELSE { @@ -890,7 +890,7 @@ static void pst_ltp_fx( /* gain_plt += (1.0f-gain_plt) * gain_factor */ /* gain_plt = gain_plt + gain_factor - gain_plt*gain_factor */ #ifdef BASOP_NOGLOB - gain_plt = msu_ro( L_msu( L_deposit_h( gain_plt ), gain_plt, gain_factor ), -32768, gain_factor, &Overflow ); + gain_plt = msu_ro( L_msu( L_deposit_h( gain_plt ), gain_plt, gain_factor ), -32768, gain_factor, &Overflow ); // Q15 #else gain_plt = msu_r( L_msu( L_deposit_h( gain_plt ), gain_plt, gain_factor ), -32768, gain_factor ); #endif @@ -906,12 +906,12 @@ static void pst_ltp_fx( * Computes best (shortest) integer LTP delay + fine search *---------------------------------------------------------------------------*/ static void search_del_fx( - Word16 t0, /* i : pitch delay given by coder */ + Word16 t0, /* i : pitch delay given by coder Q0 */ Word16 *ptr_sig_in, /* i : i signal (with delay line) */ Word16 *ltpdel, /* o : delay = *ltpdel - *phase / f_up */ Word16 *phase, /* o : phase */ - Word16 *num_gltp, /* o : 16 bits numerator of LTP gain */ - Word16 *den_gltp, /* o : 16 bits denominator of LTP gain */ + Word16 *num_gltp, /* o : 16 bits numerator of LTP gain Q(sh_num_gltp) */ + Word16 *den_gltp, /* o : 16 bits denominator of LTP gain Q(sh_den_gltp) */ Word16 *sh_num_gltp, /* o : justification for num_gltp */ Word16 *sh_den_gltp, /* o : justification for den_gltp */ Word16 *y_up, /* o : LT delayed signal if fract. delay */ @@ -933,10 +933,10 @@ static void search_del_fx( Word16 *ptr1, *ptr_y_up; Word16 i, n; - Word16 num, den0, den1; + Word16 num /*Q(sh_num)*/, den0 /*Q(sh_den)*/, den1 /*Q(sh_den)*/; Word16 den_max, num_max; Word32 L_numsq_max; - Word16 ener; + Word16 ener; // Q(sh_ener) Word16 sh_num, sh_den, sh_ener; Word16 i_max, lambda, phi, phi_max, ioff; Word16 temp; @@ -1320,7 +1320,7 @@ static void search_del_fx( } ELSE { - if ( temp > 0 ) + IF( temp > 0 ) { L_temp1 = L_shr( L_temp1, temp ); } @@ -1365,10 +1365,10 @@ static void search_del_fx( * Perform long term postfilter *----------------------------------------------------------------------------*/ static void filt_plt_fx( - Word16 *s_in, /* i : i signal with past */ - Word16 *s_ltp, /* i : filtered signal with gain 1 */ - Word16 *s_out, /* o : signal */ - Word16 gain_plt /* i : filter gain */ + Word16 *s_in, /* i : i signal with past Qx */ + Word16 *s_ltp, /* i : filtered signal with gain 1 Qx*/ + Word16 *s_out, /* o : signal Qx */ + Word16 gain_plt /* i : filter gain Q15 */ ) { @@ -1379,15 +1379,15 @@ static void filt_plt_fx( Word16 gain_plt_1; - gain_plt_1 = sub( 32767, gain_plt ); - gain_plt_1 = add( gain_plt_1, 1 ); /* 2**15 (1 - g) */ + gain_plt_1 = sub( 32767, gain_plt ); // Q15 + gain_plt_1 = add( gain_plt_1, 1 ); /* 2**15 (1 - g) */ FOR( n = 0; n < L_SUBFR; n++ ) { /* s_out(n) = gain_plt x s_in(n) + gain_plt_1 x s_ltp(n) */ - L_acc = L_mult( gain_plt, s_in[n] ); - s_out[n] = mac_r( L_acc, gain_plt_1, s_ltp[n] ); - move16(); /* no overflow */ + L_acc = L_mult( gain_plt, s_in[n] ); // Qx + Q15 + 1 + s_out[n] = mac_r( L_acc, gain_plt_1, s_ltp[n] ); // Qx + move16(); /* no overflow */ } @@ -1406,8 +1406,8 @@ static void compute_ltp_l_fx( Word16 ltpdel, /* i : delay factor */ Word16 phase, /* i : phase factor */ Word16 *y_up, /* i : delayed signal */ - Word16 *num, /* i : numerator of LTP gain */ - Word16 *den, /* i : denominator of LTP gain */ + Word16 *num, /* i : numerator of LTP gain Q(sh_num) */ + Word16 *den, /* i : denominator of LTP gain Q(sh_den) */ Word16 *sh_num, /* i : justification factor of num */ Word16 *sh_den /* i : justification factor of den */ ) @@ -1420,7 +1420,7 @@ static void compute_ltp_l_fx( temp = sub( phase, 1 ); temp = shl( temp, L2_LH2_L ); - ptr_h = tab_hup_l_fx + temp; /* tab_hup_l_fx + LH2_L * (phase-1) */ + ptr_h = tab_hup_l_fx + temp; /* tab_hup_l_fx + LH2_L * (phase-1) */ // Q15 temp = sub( LH_UP_L, ltpdel ); ptr2 = s_in + temp; @@ -1459,6 +1459,7 @@ static void compute_ltp_l_fx( *num = extract_l( L_acc ); *sh_num = temp; move16(); + move16(); } /* Compute den */ @@ -1477,6 +1478,7 @@ static void compute_ltp_l_fx( *den = extract_l( L_acc ); *sh_den = temp; move16(); + move16(); return; @@ -1490,12 +1492,12 @@ static void compute_ltp_l_fx( * and gain2 = num2 * 2** sh_num2 / den2 * 2** sh_den2 *----------------------------------------------------------------------------*/ static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain */ - Word16 num1, /* i : numerator of gain1 */ - Word16 den1, /* i : denominator of gain1 */ + Word16 num1, /* i : numerator of gain1 Q(sh_num1) */ + Word16 den1, /* i : denominator of gain1 Q(sh_den1) */ Word16 sh_num1, /* i : just. factor for num1 */ Word16 sh_den1, /* i : just. factor for den1 */ - Word16 num2, /* i : numerator of gain2 */ - Word16 den2, /* i : denominator of gain2 */ + Word16 num2, /* i : numerator of gain2 Q(sh_num2) */ + Word16 den2, /* i : denominator of gain2 Q(sh_den2) */ Word16 sh_num2, /* i : just. factor for num2 */ Word16 sh_den2 /* i : just. factor for den2 */ ) @@ -1506,7 +1508,7 @@ static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain Word16 temp1, temp2; - if ( den2 == 0 ) + IF( den2 == 0 ) { return 1; } @@ -1526,11 +1528,11 @@ static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain temp2 = add( temp2, sh_den1 ); temp2 = sub( temp2, temp1 ); - if ( temp2 > 0 ) + IF( temp2 > 0 ) { L_temp1 = L_shr( L_temp1, temp2 ); /* temp2 > 0 */ } - if ( temp2 < 0 ) + IF( temp2 < 0 ) { L_temp2 = L_shl( L_temp2, temp2 ); /* temp2 < 0 */ } @@ -1555,10 +1557,10 @@ static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain * SUMn (abs (h[n])) and computes parcor0 *---------------------------------------------------------------------------- */ static void calc_st_filt_local_fx( - Word16 *apond2, /* i : coefficients of numerator */ - Word16 *apond1, /* i : coefficients of denominator */ - Word16 *parcor0, /* o : 1st parcor calcul. on composed filter */ - Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 */ + Word16 *apond2, /* i : coefficients of numerator Q12 */ + Word16 *apond1, /* i : coefficients of denominator Q12 */ + Word16 *parcor0, /* o : 1st parcor calcul. on composed filter Q15*/ + Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 Qx */ Word16 *mem_zero /* i : All zero memory */ ) { @@ -1579,20 +1581,20 @@ static void calc_st_filt_local_fx( Calc_rc0_h( h, parcor0 ); /* compute g0 */ - L_g0 = L_mult0( 1, abs_s( h[0] ) ); + L_g0 = L_mult0( 1, abs_s( h[0] ) ); // Q12 FOR( i = 1; i < LONG_H_ST; i++ ) { - L_g0 = L_mac0( L_g0, 1, abs_s( h[i] ) ); + L_g0 = L_mac0( L_g0, 1, abs_s( h[i] ) ); // Q12 } - g0 = extract_h( L_shl( L_g0, 14 ) ); + g0 = extract_h( L_shl( L_g0, 14 ) ); // Q10 /* Scale signal i of 1/A(gamma1) */ - IF( GT_16( g0, 1024 ) ) + IF( GT_16( g0, 1024 ) ) /*1024 = 1.Q10*/ { - temp = div_s( 1024, g0 ); /* temp = 2**15 / gain0 */ + temp = div_s( 1024, g0 ); /* temp => Q15 / gain0 */ /*1024 = 1.Q10*/ FOR( i = 0; i < L_SUBFR; i++ ) { - sig_ltp_ptr[i] = mult_r( sig_ltp_ptr[i], temp ); + sig_ltp_ptr[i] = mult_r( sig_ltp_ptr[i], temp ); // Qx move16(); } } @@ -1603,17 +1605,17 @@ static void calc_st_filt_local_fx( #ifdef IVAS_FLOAT_FIXED static void calc_st_filt_ivas_fx( - Word16 *apond2, /* i : coefficients of numerator */ - Word16 *apond1, /* i : coefficients of denominator */ - Word16 *parcor0, /* o : 1st parcor calcul. on composed filter */ - Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 */ + Word16 *apond2, /* i : coefficients of numerator Q12 */ + Word16 *apond1, /* i : coefficients of denominator Q12 */ + Word16 *parcor0, /* o : 1st parcor calcul. on composed filter Q15 */ + Word16 *sig_ltp_ptr, /* i/o: i of 1/A(gamma1) : scaled by 1/g0 Qx*/ Word16 *mem_zero, /* i : All zero memory */ const Word16 extl /* i : extension layer info */ ) { Word32 L_g0; - Word16 h[LONG_H_ST]; + Word16 h[LONG_H_ST]; // Q12 Word16 g0, temp; Word16 i; @@ -1635,20 +1637,20 @@ static void calc_st_filt_ivas_fx( Calc_rc0_h( h, parcor0 ); /* compute g0 */ - L_g0 = L_mult0( 1, abs_s( h[0] ) ); + L_g0 = L_mult0( 1, abs_s( h[0] ) ); // Q12 FOR( i = 1; i < LONG_H_ST; i++ ) { - L_g0 = L_mac0( L_g0, 1, abs_s( h[i] ) ); + L_g0 = L_mac0( L_g0, 1, abs_s( h[i] ) ); // Q12 } - g0 = extract_h( L_shl( L_g0, 14 ) ); + g0 = extract_h( L_shl( L_g0, 14 ) ); // Q10 /* Scale signal i of 1/A(gamma1) */ - IF( GT_16( g0, 1024 ) ) + IF( GT_16( g0, 1024 ) ) /*1024 = 1.Q10*/ { - temp = div_s( 1024, g0 ); /* temp = 2**15 / gain0 */ + temp = div_s( 1024, g0 ); /* temp => Q15 / gain0 */ /*1024 = 1.Q10*/ FOR( i = 0; i < L_SUBFR; i++ ) { - sig_ltp_ptr[i] = mult_r( sig_ltp_ptr[i], temp ); + sig_ltp_ptr[i] = mult_r( sig_ltp_ptr[i], temp ); // Qx move16(); } } @@ -1685,34 +1687,34 @@ void Filt_mu_fx( IF( parcor0 > 0 ) { - mu = mult_r( parcor0, GAMMA3_PLUS_FX ); + mu = mult_r( parcor0, GAMMA3_PLUS_FX ); // Q15 /* GAMMA3_PLUS_FX < 0.5 */ sh_fact = 14; move16(); /* sh_fact */ fact = (Word16) 0x4000; - move16(); /* 2**sh_fact */ + move16(); /* Q(sh_fact) */ L_fact = (Word32) L_deposit_l( 0x2000 ); /* fact >> 1 */ } ELSE { - mu = mult_r( parcor0, GAMMA3_MINUS_FX ); + mu = mult_r( parcor0, GAMMA3_MINUS_FX ); // Q15 /* GAMMA3_MINUS_FX < 0.9375 */ sh_fact = 11; move16(); /* sh_fact */ fact = (Word16) 0x0800; - move16(); /* 2**sh_fact */ + move16(); /* Q(sh_fact) */ L_fact = (Word32) L_deposit_l( 0x0400 ); /* fact >> 1 */ } temp = sub( 1, abs_s( mu ) ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB - mu2 = add_o( 32767, temp, &Overflow ); /* 2**15 (1 - |mu|) */ + mu2 = add_o( 32767, temp, &Overflow ); /* Q15 (1 - |mu|) */ #else mu2 = add( 32767, temp ); /* 2**15 (1 - |mu|) */ #endif BASOP_SATURATE_WARNING_ON_EVS; - ga = div_s( fact, mu2 ); /* 2**sh_fact / (1 - |mu|) */ + ga = div_s( fact, mu2 ); /* Q(sh_fact) / (1 - |mu|) */ ptrs = sig_in; /* points on sig_in(-1) */ @@ -1748,7 +1750,7 @@ void Filt_mu_fx( void Filt_mu_ivas_fx( Word16 *sig_in, /* i : signal (beginning at sample -1) */ Word16 *sig_out, /* o : signal with tilt */ - Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) */ + Word16 parcor0, /* i : parcor0 (mu = parcor0 * gamma3) Q15 */ Word16 L_subfr, /* i : the length of subframe */ const Word16 extl ) { @@ -1768,58 +1770,58 @@ void Filt_mu_ivas_fx( { IF( parcor0 > 0 ) { - mu = mult_r( parcor0, GAMMA3_PLUS_WB_FX ); + mu = mult_r( parcor0, GAMMA3_PLUS_WB_FX ); // Q15 /* GAMMA3_PLUS_FX < 0.5 */ sh_fact = 14; move16(); /* sh_fact */ fact = (Word16) 0x4000; - move16(); /* 2**sh_fact */ - L_fact = (Word32) L_deposit_l( 0x2000 ); /* fact >> 1 */ + move16(); /* Q(sh_fact) */ + L_fact = L_deposit_l( 0x2000 ); /* fact >> 1 */ } ELSE { - mu = mult_r( parcor0, GAMMA3_MINUS_WB_FX ); + mu = mult_r( parcor0, GAMMA3_MINUS_WB_FX ); // Q15 /* GAMMA3_MINUS_FX < 0.9375 */ sh_fact = 11; move16(); /* sh_fact */ fact = (Word16) 0x0800; - move16(); /* 2**sh_fact */ - L_fact = (Word32) L_deposit_l( 0x0400 ); /* fact >> 1 */ + move16(); /* Q(sh_fact) */ + L_fact = L_deposit_l( 0x0400 ); /* fact >> 1 */ } } ELSE { IF( parcor0 > 0 ) { - mu = mult_r( parcor0, GAMMA3_PLUS_FX ); + mu = mult_r( parcor0, GAMMA3_PLUS_FX ); // Q15 /* GAMMA3_PLUS_FX < 0.5 */ sh_fact = 14; move16(); /* sh_fact */ fact = (Word16) 0x4000; - move16(); /* 2**sh_fact */ - L_fact = (Word32) L_deposit_l( 0x2000 ); /* fact >> 1 */ + move16(); /* Q(sh_fact) */ + L_fact = L_deposit_l( 0x2000 ); /* fact >> 1 */ } ELSE { - mu = mult_r( parcor0, GAMMA3_MINUS_FX ); + mu = mult_r( parcor0, GAMMA3_MINUS_FX ); // Q15 /* GAMMA3_MINUS_FX < 0.9375 */ sh_fact = 11; move16(); /* sh_fact */ fact = (Word16) 0x0800; - move16(); /* 2**sh_fact */ - L_fact = (Word32) L_deposit_l( 0x0400 ); /* fact >> 1 */ + move16(); /* Q(sh_fact) */ + L_fact = L_deposit_l( 0x0400 ); /* fact >> 1 */ } } temp = sub( 1, abs_s( mu ) ); BASOP_SATURATE_WARNING_OFF_EVS; #ifdef BASOP_NOGLOB - mu2 = add_o( 32767, temp, &Overflow ); /* 2**15 (1 - |mu|) */ + mu2 = add_o( 32767, temp, &Overflow ); /* Q15 (1 - |mu|) */ #else mu2 = add( 32767, temp ); /* 2**15 (1 - |mu|) */ #endif BASOP_SATURATE_WARNING_ON_EVS; - ga = div_s( fact, mu2 ); /* 2**sh_fact / (1 - |mu|) */ + ga = div_s( fact, mu2 ); /* Q(sh_fact) / (1 - |mu|) */ ptrs = sig_in; /* points on sig_in(-1) */ @@ -1854,9 +1856,9 @@ void Filt_mu_ivas_fx( * gain[n] = AGC_FAC_FX * gain[n-1] + (1 - AGC_FAC_FX) g_in/g_out *---------------------------------------------------------------------------*/ void scale_st_fx( - const Word16 *sig_in, /* i : postfilter i signal */ - Word16 *sig_out, /* i/o: postfilter o signal */ - Word16 *gain_prec, /* i/o: last value of gain for subframe */ + const Word16 *sig_in, /* i : postfilter i signal Qx */ + Word16 *sig_out, /* i/o: postfilter o signal Qx */ + Word16 *gain_prec, /* i/o: last value of gain for subframe Q14*/ Word16 L_subfr ) { Word32 L_acc, L_temp; @@ -1871,11 +1873,11 @@ void scale_st_fx( L_acc = L_deposit_l( 0 ); FOR( i = 0; i < L_subfr; i++ ) { - if ( sig_in[i] > 0 ) + IF( sig_in[i] > 0 ) { L_acc = L_mac0( L_acc, 1, sig_in[i] ); } - if ( sig_in[i] < 0 ) + IF( sig_in[i] < 0 ) { L_acc = L_msu0( L_acc, 1, sig_in[i] ); } @@ -1948,6 +1950,7 @@ void scale_st_fx( L_temp = L_shl( L_temp, 1 ); sig_out[i] = round_fx( L_temp ); #endif + move16(); } *gain_prec = gain; move16(); @@ -1963,26 +1966,26 @@ void scale_st_fx( *---------------------------------------------------------------------------*/ void blend_subfr2_fx( - Word16 *sigIn1, - Word16 *sigIn2, - Word16 *sigOut ) + Word16 *sigIn1, // Qx + Word16 *sigIn2, // Qx + Word16 *sigOut // Qx +) { - Word16 fac1 = 32768 - 512; - Word16 fac2 = 0 + 512; - Word16 step = 1024; + Word16 fac1 = 32768 - 512; // 1.Q15 - ( 1.Q15 / L_SUBFR ); + Word16 fac2 = 0 + 512; // 0.Q15 + ( 1.Q15 / L_SUBFR ); + Word16 step = 1024; // 1.Q15 / ( L_SUBFR / 2 ); Word16 i; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; -#endif move16(); +#endif move16(); move16(); move16(); FOR( i = 0; i < L_SUBFR / 2; i++ ) { #ifdef BASOP_NOGLOB - sigOut[i] = mac_ro( L_mult_o( fac1, sigIn1[i], &Overflow ), fac2, sigIn2[i], &Overflow ); - move16(); + sigOut[i] = mac_ro( L_mult_o( fac1, sigIn1[i], &Overflow ), fac2, sigIn2[i], &Overflow ); // Qx fac1 = sub_o( fac1, step, &Overflow ); fac2 = add_o( fac2, step, &Overflow ); #else @@ -1990,6 +1993,7 @@ void blend_subfr2_fx( fac1 = sub( fac1, step ); fac2 = add( fac2, step ); #endif + move16(); } return; diff --git a/lib_dec/dec_ppp_fx.c b/lib_dec/dec_ppp_fx.c index d37efa4c7..189ecc2b7 100644 --- a/lib_dec/dec_ppp_fx.c +++ b/lib_dec/dec_ppp_fx.c @@ -70,7 +70,7 @@ ivas_error decod_ppp_fx( /* call voiced decoder at this point */ FOR( k = 0; k < M; k++ ) { - p_Aq_curr_fx[k] = Aq_fx[add( k, ( 3 * ( M + 1 ) ) + 1 )]; + p_Aq_curr_fx[k] = Aq_fx[( k + ( 3 * ( M + 1 ) ) + 1 )]; move16(); /*Q12 */ } diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 7b923ab72..194e6bba6 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -20,10 +20,10 @@ void getLPCparam_fx( Decoder_State *st, /* i/o: decoder memory state */ - Word16 param_lpc[], /* o : LTP parameters */ + Word16 param_lpc[], /* o : LTP parameters Q0 */ Decoder_State *st0, /* i : bitstream */ - const Word16 ch, /* i : channel */ - const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ + const Word16 ch, /* i : channel Q0 */ + const Word16 sns_low_br_mode /* i : SNS low-bitrate mode Q0 */ ) { IF( st->use_partial_copy == 0 ) @@ -59,9 +59,9 @@ void getLPCparam_fx( { test(); test(); - IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->coder_type, VOICED ) && EQ_16( st->core, ACELP_CORE ) ) + IF( EQ_32( st->sr_core, INT_FS_16k ) && EQ_16( st->coder_type, VOICED ) && ( st->core == ACELP_CORE ) ) { - assert( EQ_16( st->element_mode, EVS_MONO ) ); + assert( st->element_mode == EVS_MONO ); lsf_bctcvq_decprm( st0, param_lpc ); } ELSE @@ -82,21 +82,21 @@ void getLPCparam_fx( test(); IF( EQ_16( st->rf_frame_type, RF_TCXFD ) ) { - param_lpc[0] = 0; + param_lpc[0] = 0; // Q0 move16(); - param_lpc[1] = get_next_indice_fx( st0, lsf_numbits[0] ); /* VQ 1 */ + param_lpc[1] = get_next_indice_fx( st0, lsf_numbits[0] ); /* VQ 1 */ // Q0 move16(); - param_lpc[2] = get_next_indice_fx( st0, lsf_numbits[1] ); /* VQ 2 */ + param_lpc[2] = get_next_indice_fx( st0, lsf_numbits[1] ); /* VQ 2 */ // Q0 move16(); - param_lpc[3] = get_next_indice_fx( st0, lsf_numbits[2] ); /* VQ 3 */ + param_lpc[3] = get_next_indice_fx( st0, lsf_numbits[2] ); /* VQ 3 */ // Q0 move16(); } ELSE IF( GE_16( st->rf_frame_type, RF_ALLPRED ) && LE_16( st->rf_frame_type, RF_NELP ) ) { /* LSF indices */ - param_lpc[0] = get_next_indice_fx( st0, 8 ); /* VQ 1 */ + param_lpc[0] = get_next_indice_fx( st0, 8 ); /* VQ 1 */ // Q0 move16(); - param_lpc[1] = get_next_indice_fx( st0, 8 ); /* VQ 2 */ + param_lpc[1] = get_next_indice_fx( st0, 8 ); /* VQ 2 */ // Q0 move16(); } } @@ -106,7 +106,7 @@ void getLPCparam_fx( void dec_prm_hm_fx( Decoder_State *st, - Word16 *prm_hm, + Word16 *prm_hm, /* Q0 */ const Word16 L_frame ) { Word16 tmp; @@ -127,7 +127,7 @@ void dec_prm_hm_fx( move16(); /* Flag */ - prm_hm[0] = get_next_indice_fx( st, 1 ); + prm_hm[0] = get_next_indice_fx( st, 1 ); // Q0 move16(); IF( prm_hm[0] != 0 ) @@ -161,13 +161,13 @@ void getTCXparam_fx( Decoder_State *st, /* i/o: Decoder State handle */ Decoder_State *st0, /* i : bitstream */ CONTEXT_HM_CONFIG hm_cfg, /* i/o: HM config */ - Word16 param[], /* o : decoded parameters */ - const Word16 bits_common, /* i : number of common bits */ - const Word16 start_bit_pos, /* i : position of the start bit */ - const Word16 *no_param_tns, /* i : number of TNS parameters per subframe */ - Word16 p_param[2], /* o : pointer to parameters for next round of bs reading*/ - Word16 nTnsBitsTCX10[2], - const Word16 pre_past_flag ) + Word16 param[], /* o : decoded parameters Q0 */ + const Word16 bits_common, /* i : number of common bits Q0 */ + const Word16 start_bit_pos, /* i : position of the start bit Q0 */ + const Word16 *no_param_tns, /* i : number of TNS parameters per subframe Q0 */ + Word16 p_param[2], /* o : pointer to parameters for next round of bs reading Q0 */ + Word16 nTnsBitsTCX10[2], /*Q0*/ + const Word16 pre_past_flag /*Q0*/ ) { Word16 ix, j, k, core, last_core, nSubframes; Word16 lg, lgFB, flag_ctx_hm, hm_size; @@ -243,7 +243,7 @@ void getTCXparam_fx( IGFDecReadData( st->hIGFDec, st0, IGF_GRID_LB_SHORT, 1 - k ); IGFDecStoreTCX10SubFrameData( st->hIGFDec, k ); - nbits_igf = add( nbits_igf, sub( st0->next_bit_pos, ix ) ); + nbits_igf = add( nbits_igf, sub( st0->next_bit_pos, ix ) ); // Q0 } } /* loop over subframes */ @@ -251,35 +251,35 @@ void getTCXparam_fx( { flag_ctx_hm = 0; move16(); - prm = param + imult1616( k, DEC_NPRM_DIV ); + prm = param + k * DEC_NPRM_DIV; j = 0; move16(); - nbits_tcx = sub( st0->next_bit_pos, start_bit_pos ); + nbits_tcx = sub( st0->next_bit_pos, start_bit_pos ); // Q0 test(); test(); - IF( pre_part && st->enablePlcWaveadjust && EQ_16( k, ( nSubframes - 1 ) ) ) + IF( pre_part && st->enablePlcWaveadjust && EQ_16( k, sub( nSubframes, 1 ) ) ) { - st->tonality_flag = get_next_indice_fx( st0, 1 ); + st->tonality_flag = get_next_indice_fx( st0, 1 ); // Q0 move16(); } IF( post_part ) { /* TCX Gain */ - prm[j] = get_next_indice_fx( st0, NBITS_TCX_GAIN ); - j = add( j, 1 ); + prm[j] = get_next_indice_fx( st0, NBITS_TCX_GAIN ); // Q0 + j = add( j, 1 ); // Q0 move16(); /* TCX Noise Filling = NBITS_NOISE_FILL_LEVEL bits */ - prm[j] = get_next_indice_fx( st0, NBITS_NOISE_FILL_LEVEL ); - j = add( j, 1 ); + prm[j] = get_next_indice_fx( st0, NBITS_NOISE_FILL_LEVEL ); // Q0 + j = add( j, 1 ); // Q0 move16(); } ELSE { - j = add( j, 1 + NOISE_FILL_RANGES ); + j = add( j, 1 + NOISE_FILL_RANGES ); // Q0 } /* LTP data */ @@ -289,24 +289,24 @@ void getTCXparam_fx( test(); IF( ( k == 0 ) && ( hTcxLtpDec->tcxltp || GT_32( st->sr_core, 25600 ) ) ) /* PLC pitch info for HB */ { - prm[j] = get_next_indice_fx( st0, 1 ); + prm[j] = get_next_indice_fx( st0, 1 ); // Q0 move16(); IF( prm[j] ) { - prm[add( j, 1 )] = get_next_indice_fx( st0, 9 ); + prm[add( j, 1 )] = get_next_indice_fx( st0, 9 ); // Q0 move16(); - prm[add( j, 2 )] = get_next_indice_fx( st0, 2 ); + prm[add( j, 2 )] = get_next_indice_fx( st0, 2 ); // Q0 move16(); - tcxltp_prm_0 = prm[j]; + tcxltp_prm_0 = prm[j]; // Q0 move16(); - tcxltp_prm_1 = prm[j + 1]; + tcxltp_prm_1 = prm[j + 1]; // Q0 move16(); - tcxltp_prm_2 = prm[j + 2]; + tcxltp_prm_2 = prm[j + 2]; // Q0 move16(); } - st->BER_detect = st->BER_detect | tcx_ltp_decode_params( &prm[j], &( hTcxLtpDec->tcxltp_pitch_int ), &( hTcxLtpDec->tcxltp_pitch_fr ), &( hTcxLtpDec->tcxltp_gain ), st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max ); + st->BER_detect = s_or( st->BER_detect, tcx_ltp_decode_params( &prm[j], &( hTcxLtpDec->tcxltp_pitch_int ), &( hTcxLtpDec->tcxltp_pitch_fr ), &( hTcxLtpDec->tcxltp_gain ), st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max ) ); // Q0 move16(); - hTcxDec->tcxltp_last_gain_unmodified = hTcxLtpDec->tcxltp_gain; + hTcxDec->tcxltp_last_gain_unmodified = hTcxLtpDec->tcxltp_gain; // Q15 move16(); test(); @@ -316,45 +316,45 @@ void getTCXparam_fx( // To be done at the end Word32 tmp32 = L_shl( L_mult0( st->L_frame, st->pit_res_max ), 1 + kLtpHmFractionalResolution + 1 ); Word16 tmp1 = add( imult1616( hTcxLtpDec->tcxltp_pitch_int, st->pit_res_max ), hTcxLtpDec->tcxltp_pitch_fr ); - hTcxDec->tcx_hm_LtpPitchLag = div_l( tmp32, tmp1 ); + hTcxDec->tcx_hm_LtpPitchLag = div_l( tmp32, tmp1 ); // Q15 move16(); } ELSE { - hTcxDec->tcx_hm_LtpPitchLag = -1; + hTcxDec->tcx_hm_LtpPitchLag = -1; // Q15 move16(); } - j = add( j, 3 ); + j = add( j, 3 ); // Q0 } ELSE { - prm[j] = tcxltp_prm_0; - j = add( j, 1 ); + prm[j] = tcxltp_prm_0; // Q0 + j = add( j, 1 ); // Q0 move16(); - prm[j] = tcxltp_prm_1; - j = add( j, 1 ); + prm[j] = tcxltp_prm_1; // Q0 + j = add( j, 1 ); // Q0 move16(); - prm[j] = tcxltp_prm_2; - j = add( j, 1 ); + prm[j] = tcxltp_prm_2; // Q0 + j = add( j, 1 ); // Q0 move16(); } } /* TCX spectral data */ - lg = shr( st->L_frame, sub( nSubframes, 1 ) ); - lgFB = shr( st->hTcxCfg->tcx_coded_lines, sub( nSubframes, 1 ) ); + lg = shr( st->L_frame, sub( nSubframes, 1 ) ); // Q0 + lgFB = shr( st->hTcxCfg->tcx_coded_lines, sub( nSubframes, 1 ) ); // Q0 test(); test(); IF( post_part && ( k == 0 ) && EQ_16( st->last_core_from_bs, ACELP_CORE ) ) { /* ACE->TCX transition */ - lg = add( lg, st->hTcxCfg->tcx_offset ); - lgFB = add( lgFB, shr( lgFB, sub( 3, nSubframes ) ) ); + lg = add( lg, st->hTcxCfg->tcx_offset ); // Q0 + lgFB = add( lgFB, shr( lgFB, sub( 3, nSubframes ) ) ); // Q0 - if ( st->hTcxCfg->lfacNext < 0 ) + IF( st->hTcxCfg->lfacNext < 0 ) { - lg = sub( lg, st->hTcxCfg->lfacNext ); + lg = sub( lg, st->hTcxCfg->lfacNext ); // Q0 } } @@ -384,33 +384,41 @@ void getTCXparam_fx( move16(); IF( no_param_tns ) { - ix = get_next_indice_fx( st0, 1 ); /* common_tns_data[] for subframe k */ + ix = get_next_indice_fx( st0, 1 ); /* common_tns_data[] for subframe k */ // Q0 } IF( ix ) { - prm[j] = imult1616( no_param_tns[k], -1 ); /* - signals common TNS and its size */ + prm[j] = imult1616( no_param_tns[k], -1 ); /* - signals common TNS and its size */ // Q0 move16(); - nTnsParams = no_param_tns[k]; + nTnsParams = no_param_tns[k]; // Q0 move16(); } ELSE { ReadTnsData_ivas_fx( st->hTcxCfg->pCurrentTnsConfig, st0, &nTnsBits, prm + j, &nTnsParams ); } - hTcxDec->tnsActive[k] = 0; + hTcxDec->tnsActive[k] = 0; // Q0 move16(); if ( prm[j] != 0 ) { - hTcxDec->tnsActive[k] = nTnsParams; + hTcxDec->tnsActive[k] = nTnsParams; // Q0 move16(); } - if ( nTnsBitsTCX10 != NULL ) + IF( nTnsBitsTCX10 != NULL ) { - nTnsBitsTCX10[k] = add( nTnsBits, ( no_param_tns ? 1 : 0 ) ); - move16(); + IF( no_param_tns ) + { + nTnsBitsTCX10[k] = add( nTnsBits, 1 ); // Q0 + move16(); + } + ELSE + { + nTnsBitsTCX10[k] = add( nTnsBits, 0 ); // Q0 + move16(); + } } - j = add( j, nTnsParams ); + j = add( j, nTnsParams ); // Q0 } IF( post_part ) @@ -418,46 +426,46 @@ void getTCXparam_fx( IF( EQ_16( core, TCX_20_CORE ) ) { // Q-factor of TcxBandwidth is 15 : derived from getTcxBandwidth function - hm_size = mult( st->TcxBandwidth, shl( lg, 1 ) ); + hm_size = mult( st->TcxBandwidth, shl( lg, 1 ) ); // Q0 test(); - IF( hTcxDec->tcx_lpc_shaped_ari && NE_16( st->last_core_from_bs, ACELP_CORE ) ) + IF( hTcxDec->tcx_lpc_shaped_ari && ( st->last_core_from_bs != ACELP_CORE ) ) { dec_prm_hm_fx( st0, &prm[j], hm_size ); } - nbits_tcx = sub( st->bits_frame_core, sub( st0->next_bit_pos, start_bit_pos ) ); + nbits_tcx = sub( st->bits_frame_core, sub( st0->next_bit_pos, start_bit_pos ) ); // Q0 } ELSE { - hm_size = mult( st->TcxBandwidth, shl( lgFB, 1 ) ); - nbits_tcx = sub( shr( sub( add( sub( sub( st->bits_frame_core, bits_common ), nbits_igf ), 1 ), k ), 1 ), sub( sub( st0->next_bit_pos, start_bit_pos ), nbits_tcx ) ); + hm_size = mult( st->TcxBandwidth, shl( lgFB, 1 ) ); // Q0 + nbits_tcx = sub( shr( sub( add( sub( sub( st->bits_frame_core, bits_common ), nbits_igf ), 1 ), k ), 1 ), sub( sub( st0->next_bit_pos, start_bit_pos ), nbits_tcx ) ); // Q0 } /*Context HM flag*/ test(); test(); - IF( st->hTcxCfg->ctx_hm && !( EQ_16( st->last_core_from_bs, ACELP_CORE ) && ( k == 0 ) ) ) + IF( st->hTcxCfg->ctx_hm && !( ( st->last_core_from_bs == ACELP_CORE ) && ( k == 0 ) ) ) { - useHarmonicModel = get_next_indice_fx( st0, 1 ); - prm[j] = useHarmonicModel; + useHarmonicModel = get_next_indice_fx( st0, 1 ); // Q0 + prm[j] = useHarmonicModel; // Q0 move16(); - nbits_tcx = sub( nbits_tcx, 1 ); + nbits_tcx = sub( nbits_tcx, 1 ); // Q0 IF( useHarmonicModel ) { ix = DecodeIndex_fx( st0, (Word16) GE_16( hm_size, 256 ), prm + add( j, 1 ) ); - flag_ctx_hm = 1; + flag_ctx_hm = 1; // Q0 move16(); PeriodicityIndex = *( prm + add( j, 1 ) ); - IF( EQ_16( st->element_mode, EVS_MONO ) ) + IF( st->element_mode == EVS_MONO ) { ConfigureContextHm( lgFB, nbits_tcx, PeriodicityIndex, hTcxDec->tcx_hm_LtpPitchLag, &hm_cfg ); } - nbits_tcx = sub( nbits_tcx, ix ); + nbits_tcx = sub( nbits_tcx, ix ); // Q0 } } } - j = add( j, NPRM_CTX_HM ); + j = add( j, NPRM_CTX_HM ); // Q0 /* read IGF payload */ test(); @@ -465,31 +473,39 @@ void getTCXparam_fx( { IF( st->igf ) { - ix = st->next_bit_pos; + ix = st->next_bit_pos; // Q0 move16(); - IGFDecReadLevel( st->hIGFDec, st0, ( EQ_16( st->last_core_from_bs, ACELP_CORE ) ) ? IGF_GRID_LB_TRAN : IGF_GRID_LB_NORM, 1 ); - IGFDecReadData( st->hIGFDec, st0, ( EQ_16( st->last_core_from_bs, ACELP_CORE ) ) ? IGF_GRID_LB_TRAN : IGF_GRID_LB_NORM, 1 ); + IF( st->last_core_from_bs == ACELP_CORE ) + { + IGFDecReadLevel( st->hIGFDec, st0, IGF_GRID_LB_TRAN, 1 ); + IGFDecReadData( st->hIGFDec, st0, IGF_GRID_LB_TRAN, 1 ); + } + ELSE + { + IGFDecReadLevel( st->hIGFDec, st0, IGF_GRID_LB_NORM, 1 ); + IGFDecReadData( st->hIGFDec, st0, IGF_GRID_LB_NORM, 1 ); + } - nbits_tcx = sub( nbits_tcx, sub( st0->next_bit_pos, ix ) ); + nbits_tcx = sub( nbits_tcx, sub( st0->next_bit_pos, ix ) ); // Q0 } - nbits_tcx = sub( st->bits_frame_core, sub( st0->next_bit_pos, start_bit_pos ) ); + nbits_tcx = sub( st->bits_frame_core, sub( st0->next_bit_pos, start_bit_pos ) ); // Q0 } ELSE IF( p_param != NULL ) { - p_param[k] = j; + p_param[k] = j; // Q0 move16(); } } ELSE { - j = p_param[k]; + j = p_param[k]; // Q0 move16(); - nbits_tcx = st->bits_frame_channel; + nbits_tcx = st->bits_frame_channel; // Q0 move16(); if ( EQ_16( st->core, TCX_10_CORE ) ) { - nbits_tcx = sub( nTnsBitsTCX10[k], NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ); + nbits_tcx = sub( nTnsBitsTCX10[k], NBITS_TCX_GAIN + NOISE_FILL_RANGES * NBITS_NOISE_FILL_LEVEL ); // Q0 } } @@ -498,36 +514,52 @@ void getTCXparam_fx( test(); IF( hTcxDec->tcx_lpc_shaped_ari && EQ_16( core, TCX_20_CORE ) ) { - prm[j] = nbits_tcx; /* store length of buffer */ - j = add( j, 1 ); + prm[j] = nbits_tcx; /* store length of buffer */ // Q0 + j = add( j, 1 ); // Q0 move16(); prms = &prm[j]; FOR( ix = 0; ix < nbits_tcx; ix++ ) { - prms[ix] = get_next_indice_1_fx( st0 ); + prms[ix] = get_next_indice_1_fx( st0 ); // Q0 } FOR( ix = 0; ix < 32; ix++ ) { - prms[add( ix, nbits_tcx )] = 1; + prms[ix + nbits_tcx] = 1; // Q0 + move16(); } - move16(); - j = add( j, nbits_tcx ); + j = add( j, nbits_tcx ); // Q0 } ELSE { - IF( GT_16( st->element_mode, EVS_MONO ) ) + IF( st->element_mode > EVS_MONO ) { IF( useHarmonicModel ) { ConfigureContextHm( lgFB, nbits_tcx, PeriodicityIndex, hTcxDec->tcx_hm_LtpPitchLag, &hm_cfg ); } - hTcxDec->resQBits[k] = RCcontextMapping_decode2_no_mem_s17_LCS_fx( st0, prm + j, lgFB, nbits_tcx, imult1616( NPRM_RESQ, st->hTcxCfg->resq ), flag_ctx_hm ? &hm_cfg : NULL ); - move16(); + IF( flag_ctx_hm ) + { + hTcxDec->resQBits[k] = RCcontextMapping_decode2_no_mem_s17_LCS_fx( st0, prm + j, lgFB, nbits_tcx, imult1616( NPRM_RESQ, st->hTcxCfg->resq ), &hm_cfg ); // Q0 + move16(); + } + ELSE + { + hTcxDec->resQBits[k] = RCcontextMapping_decode2_no_mem_s17_LCS_fx( st0, prm + j, lgFB, nbits_tcx, imult1616( NPRM_RESQ, st->hTcxCfg->resq ), NULL ); // Q0 + move16(); + } } ELSE { - hTcxDec->resQBits[k] = ACcontextMapping_decode2_no_mem_s17_LC( st0, prm + j, lgFB, nbits_tcx, imult1616( NPRM_RESQ, st->hTcxCfg->resq ), flag_ctx_hm ? &hm_cfg : NULL ); - move16(); + IF( flag_ctx_hm ) + { + hTcxDec->resQBits[k] = ACcontextMapping_decode2_no_mem_s17_LC( st0, prm + j, lgFB, nbits_tcx, imult1616( NPRM_RESQ, st->hTcxCfg->resq ), &hm_cfg ); // Q0 + move16(); + } + ELSE + { + hTcxDec->resQBits[k] = ACcontextMapping_decode2_no_mem_s17_LC( st0, prm + j, lgFB, nbits_tcx, imult1616( NPRM_RESQ, st->hTcxCfg->resq ), NULL ); // Q0 + move16(); + } } } } @@ -545,9 +577,9 @@ void getTCXparam_fx( *-----------------------------------------------------------------*/ void dec_prm_fx( Word16 *coder_type, - Word16 param[], /* (o) : decoded parameters */ - Word16 param_lpc[], /* (o) : LPC parameters */ - Word16 *total_nbbits, /* i/o : number of bits / decoded bits */ + Word16 param[], /* (o) : decoded parameters Q0 */ + Word16 param_lpc[], /* (o) : LPC parameters Q0 */ + Word16 *total_nbbits, /* i/o : number of bits / decoded bits Q0 */ Decoder_State *st, Word16 L_frame, Word16 *bitsRead ) @@ -613,17 +645,17 @@ void dec_prm_fx( IF( EQ_16( st->rf_flag, 1 ) ) { /*Inherent adjustment to accommodate the compact packing used in the RF mode*/ - start_bit_pos = sub( st->next_bit_pos, 2 ); + start_bit_pos = sub( st->next_bit_pos, 2 ); // Q0 } ELSE { - start_bit_pos = st->next_bit_pos; + start_bit_pos = st->next_bit_pos; // Q0 move16(); } } /* Framing parameters */ - nb_subfr = st->nb_subfr; + nb_subfr = st->nb_subfr; // Q0 move16(); /* Initialize pointers */ @@ -646,12 +678,12 @@ void dec_prm_fx( /* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */ IF( st->tcxonly ) { - st->core = add( get_next_indice_fx( st, 1 ), 1 ); + st->core = add( get_next_indice_fx( st, 1 ), 1 ); // Q0 move16(); - ind = get_next_indice_fx( st, 2 ); + ind = get_next_indice_fx( st, 2 ); // Q0 st->clas_dec = ONSET; move16(); - if ( ind == 0 ) + IF( ind == 0 ) { st->clas_dec = UNVOICED_CLAS; move16(); @@ -683,7 +715,7 @@ void dec_prm_fx( /* 2 bits instead of 3 as TCX is already signaled */ st->core = TCX_20_CORE; move16(); - st->hTcxCfg->coder_type = get_next_indice_fx( st, 2 ); + st->hTcxCfg->coder_type = get_next_indice_fx( st, 2 ); // Q0 move16(); *coder_type = st->hTcxCfg->coder_type; move16(); @@ -694,7 +726,7 @@ void dec_prm_fx( { IF( get_next_indice_1_fx( st ) != 0 ) /* TCX */ { - tmp = get_next_indice_fx( st, 3 ); + tmp = get_next_indice_fx( st, 3 ); // Q0 assert( !( tmp & 4 ) || !"HQ_CORE encountered in dec_prm_fx" ); st->core = TCX_20_CORE; move16(); @@ -707,7 +739,7 @@ void dec_prm_fx( { st->core = ACELP_CORE; move16(); - *coder_type = get_next_indice_fx( st, 2 ); + *coder_type = get_next_indice_fx( st, 2 ); // Q0 move16(); } } @@ -736,7 +768,7 @@ void dec_prm_fx( { st->core = ACELP_CORE; move16(); - *coder_type = get_next_indice_fx( st, 3 ); + *coder_type = get_next_indice_fx( st, 3 ); // Q0 move16(); IF( GE_16( *coder_type, ACELP_MODE_MAX ) ) { @@ -752,22 +784,22 @@ void dec_prm_fx( } test(); - if ( ( st->igf != 0 ) && EQ_16( st->core, ACELP_CORE ) ) + IF( ( st->igf != 0 ) && ( st->core == ACELP_CORE ) ) { - st->bits_frame_core = sub( st->bits_frame_core, get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_flag ) ); + st->bits_frame_core = sub( st->bits_frame_core, get_tbe_bits_fx( st->total_brate, st->bwidth, st->rf_flag ) ); // Q0 move16(); } - if ( EQ_16( st->rf_flag, 1 ) ) + IF( EQ_16( st->rf_flag, 1 ) ) { - st->bits_frame_core = sub( st->bits_frame_core, add( st->rf_target_bits, 1 ) ); /* +1 as flag-bit not considered in rf_target_bits */ + st->bits_frame_core = sub( st->bits_frame_core, add( st->rf_target_bits, 1 ) ); /* +1 as flag-bit not considered in rf_target_bits */ // Q0 move16(); } /* Inactive frame detection on non-DTX mode */ st->VAD = 1; move16(); - if ( EQ_16( *coder_type, INACTIVE ) ) + if ( *coder_type == INACTIVE ) { st->VAD = 0; move16(); @@ -778,7 +810,7 @@ void dec_prm_fx( st->core_ext_mode = *coder_type; move16(); - if ( EQ_16( *coder_type, INACTIVE ) ) + if ( *coder_type == INACTIVE ) { st->core_ext_mode = UNVOICED; move16(); @@ -789,7 +821,7 @@ void dec_prm_fx( move16(); test(); test(); - IF( ( NE_16( st->core, ACELP_CORE ) || st->hTcxCfg->lfacNext > 0 ) && st->use_partial_copy == 0 ) + IF( ( ( st->core != ACELP_CORE ) || st->hTcxCfg->lfacNext > 0 ) && st->use_partial_copy == 0 ) { st->last_core_from_bs = get_next_indice_fx( st, 1 ); move16(); @@ -812,8 +844,8 @@ void dec_prm_fx( IF( EQ_16( st->core, TCX_10_CORE ) ) { st->last_core = TCX_20_CORE; - st->last_core_from_bs = TCX_20_CORE; move16(); + st->last_core_from_bs = TCX_20_CORE; move16(); } } @@ -828,14 +860,14 @@ void dec_prm_fx( Mpy_32_16_ss( st->total_brate, 5243, &L_tmp, &lsb ); /* 5243 is 1/50 in Q18. (0+18-15=3) */ num_bits = extract_l( L_shr( L_tmp, 3 ) ); /* Q0 */ - get_next_indice_tmp_fx( st, sub( sub( sub( add( start_bit_pos, num_bits ), st->rf_target_bits ), 3 ), st->next_bit_pos ) ); + get_next_indice_tmp_fx( st, sub( sub( sub( add( start_bit_pos, num_bits ), st->rf_target_bits ), 3 ), st->next_bit_pos ) ); // Q0 } IF( st->use_partial_copy == 0 ) { /* Set the last overlap mode based on the previous and current frame type and coded overlap mode */ test(); - IF( ( EQ_16( st->last_core, ACELP_CORE ) ) || ( EQ_16( st->last_core, AMR_WB_CORE ) ) ) + IF( ( st->last_core == ACELP_CORE ) || ( EQ_16( st->last_core, AMR_WB_CORE ) ) ) { st->hTcxCfg->tcx_last_overlap_mode = TRANSITION_OVERLAP; move16(); @@ -853,7 +885,7 @@ void dec_prm_fx( st->hTcxCfg->tcx_last_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode; move16(); test(); - if ( ( NE_16( st->core, TCX_10_CORE ) ) && ( EQ_16( st->hTcxCfg->tcx_curr_overlap_mode, FULL_OVERLAP ) ) ) + if ( ( NE_16( st->core, TCX_10_CORE ) ) && ( st->hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) ) { st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; move16(); @@ -864,12 +896,12 @@ void dec_prm_fx( st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; move16(); - IF( NE_16( st->core, ACELP_CORE ) ) + IF( st->core != ACELP_CORE ) { tmp = 0; move16(); /* if current TCX mode is not 0 (full overlap), read another bit */ - if ( get_next_indice_fx( st, 1 ) ) + IF( get_next_indice_fx( st, 1 ) ) { tmp = add( 2, get_next_indice_fx( st, 1 ) ); } @@ -880,7 +912,7 @@ void dec_prm_fx( test(); test(); test(); - if ( ( EQ_16( st->core, TCX_20_CORE ) ) && ( tmp == 0 ) && ( NE_16( st->last_core, ACELP_CORE ) ) && ( NE_16( st->last_core, AMR_WB_CORE ) ) ) + if ( ( EQ_16( st->core, TCX_20_CORE ) ) && ( tmp == 0 ) && ( st->last_core != ACELP_CORE ) && ( NE_16( st->last_core, AMR_WB_CORE ) ) ) { st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; move16(); @@ -897,28 +929,28 @@ void dec_prm_fx( search_range = 8; move16(); - st->flagGuidedAcelp = get_next_indice_fx( st, 1 ); + st->flagGuidedAcelp = get_next_indice_fx( st, 1 ); // Q0 move16(); pitchDiff = 0; move16(); IF( st->flagGuidedAcelp ) { - pitchDiff = get_next_indice_fx( st, bits_per_subfr ); + pitchDiff = get_next_indice_fx( st, bits_per_subfr ); // Q0 move16(); - st->guidedT0 = sub( pitchDiff, search_range ); + st->guidedT0 = sub( pitchDiff, search_range ); // Q0 move16(); } test(); if ( ( pitchDiff == 0 ) && st->flagGuidedAcelp ) { - st->flagGuidedAcelp = 0; + st->flagGuidedAcelp = 0; // Q0 move16(); } } ELSE { - st->flagGuidedAcelp = 0; + st->flagGuidedAcelp = 0; // Q0 move16(); } @@ -926,9 +958,9 @@ void dec_prm_fx( { move16(); st->dec_glr_idx = -1; - if ( EQ_16( st->core, ACELP_CORE ) ) + IF( st->core == ACELP_CORE ) { - st->dec_glr_idx = get_next_indice_fx( st, G_LPC_RECOVERY_BITS ); + st->dec_glr_idx = get_next_indice_fx( st, G_LPC_RECOVERY_BITS ); // Q0 move16(); } } @@ -962,7 +994,7 @@ void dec_prm_fx( /* Decode LPC parameters */ test(); - IF( hTcxDec->enableTcxLpc && NE_16( st->core, ACELP_CORE ) ) + IF( hTcxDec->enableTcxLpc && ( st->core != ACELP_CORE ) ) { Word16 tcx_lpc_cdk; tcx_lpc_cdk = tcxlpc_get_cdk( *coder_type ); @@ -984,7 +1016,7 @@ void dec_prm_fx( { test(); test(); - IF( EQ_32( st->sr_core, 16000 ) && EQ_16( *coder_type, VOICED ) && EQ_16( st->core, ACELP_CORE ) ) + IF( EQ_32( st->sr_core, 16000 ) && EQ_16( *coder_type, VOICED ) && ( st->core == ACELP_CORE ) ) { lsf_bctcvq_decprm( st, param_lpc ); } @@ -1007,26 +1039,26 @@ void dec_prm_fx( test(); IF( EQ_16( st->rf_frame_type, RF_TCXFD ) ) { - param_lpc[0] = 0; + param_lpc[0] = 0; // Q0 move16(); - param_lpc[1] = get_next_indice_fx( st, lsf_numbits[0] ); /* VQ 1 */ + param_lpc[1] = get_next_indice_fx( st, lsf_numbits[0] ); /* VQ 1 */ // Q0 move16(); - param_lpc[2] = get_next_indice_fx( st, lsf_numbits[1] ); /* VQ 2 */ + param_lpc[2] = get_next_indice_fx( st, lsf_numbits[1] ); /* VQ 2 */ // Q0 move16(); - param_lpc[3] = get_next_indice_fx( st, lsf_numbits[2] ); /* VQ 3 */ + param_lpc[3] = get_next_indice_fx( st, lsf_numbits[2] ); /* VQ 3 */ // Q0 move16(); } ELSE IF( GE_16( st->rf_frame_type, RF_ALLPRED ) && LE_16( st->rf_frame_type, RF_NELP ) ) { /* LSF indices */ - param_lpc[0] = get_next_indice_fx( st, 8 ); /* VQ 1 */ + param_lpc[0] = get_next_indice_fx( st, 8 ); /* VQ 1 */ // Q0 move16(); - param_lpc[1] = get_next_indice_fx( st, 8 ); /* VQ 2 */ + param_lpc[1] = get_next_indice_fx( st, 8 ); /* VQ 2 */ // Q0 move16(); } } - st->bits_common = sub( st->next_bit_pos, start_bit_pos ); + st->bits_common = sub( st->next_bit_pos, start_bit_pos ); // Q0 move16(); @@ -1035,7 +1067,7 @@ void dec_prm_fx( *--------------------------------------------------------------------------------*/ test(); test(); - IF( EQ_16( st->core, ACELP_CORE ) && ( st->use_partial_copy == 0 ) ) + IF( ( st->core == ACELP_CORE ) && ( st->use_partial_copy == 0 ) ) { /* Target Bits */ acelp_target_bits = sub( st->bits_frame_core, st->bits_common ); @@ -1053,23 +1085,23 @@ void dec_prm_fx( } /* Adaptive BPF (2 bits)*/ - n = ACELP_BPF_BITS[st->acelp_cfg.bpf_mode]; + n = ACELP_BPF_BITS[st->acelp_cfg.bpf_mode]; // Q0 move16(); - st->bpf_gain_param = shl( st->acelp_cfg.bpf_mode, 1 ); - if ( n != 0 ) + st->bpf_gain_param = shl( st->acelp_cfg.bpf_mode, 1 ); // Q0 + IF( n != 0 ) { - st->bpf_gain_param = get_next_indice_fx( st, n ); + st->bpf_gain_param = get_next_indice_fx( st, n ); // Q0 move16(); } /* Mean energy (2 or 3 bits) */ - n = ACELP_NRG_BITS[st->acelp_cfg.nrg_mode]; + n = ACELP_NRG_BITS[st->acelp_cfg.nrg_mode]; // Q0 move16(); - if ( n != 0 ) + IF( n != 0 ) { - prm[j] = get_next_indice_fx( st, n ); - j = add( j, 1 ); + prm[j] = get_next_indice_fx( st, n ); // Q0 + j = add( j, 1 ); // Q0 move16(); } @@ -1077,63 +1109,63 @@ void dec_prm_fx( FOR( sfr = 0; sfr < nb_subfr; sfr++ ) { /* Pitch lag (4, 5, 6, 8 or 9 bits) */ - n = ACELP_LTP_BITS_SFR[st->acelp_cfg.ltp_mode][sfr]; + n = ACELP_LTP_BITS_SFR[st->acelp_cfg.ltp_mode][sfr]; // Q0 move16(); IF( n != 0 ) { - prm[j] = get_next_indice_fx( st, n ); - j = add( j, 1 ); + prm[j] = get_next_indice_fx( st, n ); // Q0 + j = add( j, 1 ); // Q0 move16(); } /* Adaptive codebook filtering (1 bit) */ IF( EQ_16( st->acelp_cfg.ltf_mode, 2 ) ) { - prm[j] = get_next_indice_fx( st, 1 ); - j = add( j, 1 ); + prm[j] = get_next_indice_fx( st, 1 ); // Q0 + j = add( j, 1 ); // Q0 move16(); } /* Innovative codebook */ { /* Decode pulse positions. */ - j_old = j; + j_old = j; // Q0 move16(); - wordcnt = shr( ACELP_FIXED_CDK_BITS( st->acelp_cfg.fixed_cdk_index[sfr] ), 4 ); - bitcnt = s_and( ACELP_FIXED_CDK_BITS( st->acelp_cfg.fixed_cdk_index[sfr] ), 0xF ); + wordcnt = shr( ACELP_FIXED_CDK_BITS( st->acelp_cfg.fixed_cdk_index[sfr] ), 4 ); // Q0 + bitcnt = s_and( ACELP_FIXED_CDK_BITS( st->acelp_cfg.fixed_cdk_index[sfr] ), 0xF ); // Q0 /* sanity check for testing - not instrumented */ test(); IF( GE_16( st->acelp_cfg.fixed_cdk_index[sfr], ACELP_FIXED_CDK_NB ) || ( st->acelp_cfg.fixed_cdk_index[sfr] < 0 ) ) { - st->acelp_cfg.fixed_cdk_index[sfr] = 0; + st->acelp_cfg.fixed_cdk_index[sfr] = 0; // Q0 move16(); - st->BER_detect = 1; + st->BER_detect = 1; // Q0 move16(); } FOR( ix = 0; ix < wordcnt; ix++ ) { - prm[j] = (Word16) get_next_indice_fx( st, 16 ); - j = add( j, 1 ); + prm[j] = (Word16) get_next_indice_fx( st, 16 ); // Q0 + j = add( j, 1 ); // Q0 move16(); } - if ( bitcnt ) + IF( bitcnt ) { - prm[j] = get_next_indice_fx( st, bitcnt ); + prm[j] = get_next_indice_fx( st, bitcnt ); // Q0 move16(); } - j = add( j_old, 8 ); + j = add( j_old, 8 ); // Q0 } /* Gains (5b, 6b or 7b / subfr) */ - n = ACELP_GAINS_BITS[st->acelp_cfg.gains_mode[sfr]]; + n = ACELP_GAINS_BITS[st->acelp_cfg.gains_mode[sfr]]; // Q0 move16(); - prm[j] = get_next_indice_fx( st, n ); - j = add( j, 1 ); + prm[j] = get_next_indice_fx( st, n ); // Q0 + j = add( j, 1 ); // Q0 move16(); } /*end of subfr loop*/ } @@ -1157,43 +1189,44 @@ void dec_prm_fx( IF( EQ_16( st->rf_frame_type, RF_NELP ) ) { /* NELP gain indices */ - st->rf_indx_nelp_iG1 = get_next_indice_fx( st, 5 ); - st->rf_indx_nelp_iG2[0] = get_next_indice_fx( st, 6 ); + st->rf_indx_nelp_iG1 = get_next_indice_fx( st, 5 ); // Q0 move16(); - st->rf_indx_nelp_iG2[1] = get_next_indice_fx( st, 6 ); + st->rf_indx_nelp_iG2[0] = get_next_indice_fx( st, 6 ); // Q0 + move16(); + st->rf_indx_nelp_iG2[1] = get_next_indice_fx( st, 6 ); // Q0 move16(); /* NELP filter selection index */ - st->rf_indx_nelp_fid = get_next_indice_fx( st, 2 ); + st->rf_indx_nelp_fid = get_next_indice_fx( st, 2 ); // Q0 move16(); /* tbe gainFr */ - st->rf_indx_tbeGainFr = get_next_indice_fx( st, 5 ); + st->rf_indx_tbeGainFr = get_next_indice_fx( st, 5 ); // Q0 move16(); } ELSE { /* rf_frame_type ALL_PRED: 4, NO_PRED: 5, GEN_PRED: 6*/ /* ES pred */ - prm[j] = get_next_indice_fx( st, 3 ); + prm[j] = get_next_indice_fx( st, 3 ); // Q0 move16(); - j = add( j, 1 ); + j = add( j, 1 ); // Q0 - ltp_mode = ACELP_LTP_MODE[1][1][st->rf_frame_type]; + ltp_mode = ACELP_LTP_MODE[1][1][st->rf_frame_type]; // Q0 move16(); - gains_mode = ACELP_GAINS_MODE[1][1][st->rf_frame_type]; + gains_mode = ACELP_GAINS_MODE[1][1][st->rf_frame_type]; // Q0 move16(); /* Subframe parameters */ FOR( sfr = 0; sfr < nb_subfr; sfr++ ) { /* Pitch lag (5, or 8 bits) */ - n = ACELP_LTP_BITS_SFR[ltp_mode][sfr]; + n = ACELP_LTP_BITS_SFR[ltp_mode][sfr]; // Q0 move16(); IF( n != 0 ) { - prm[j] = get_next_indice_fx( st, n ); - j = add( j, 1 ); + prm[j] = get_next_indice_fx( st, n ); // Q0 + j = add( j, 1 ); // Q0 move16(); } @@ -1205,24 +1238,24 @@ void dec_prm_fx( { /* NOTE: FCB actual bits need to be backed up as well */ /*n = ACELP_FIXED_CDK_BITS(st->rf_indx_fcb[fec_offset][sfr]) & 15;*/ - prm[j] = get_next_indice_fx( st, 7 ); + prm[j] = get_next_indice_fx( st, 7 ); // Q0 move16(); - j = add( j, 8 ); + j = add( j, 8 ); // Q0 } /* Gains (5b, 6b or 7b / subfr) */ test(); IF( sfr == 0 || EQ_16( sfr, 2 ) ) { - n = ACELP_GAINS_BITS[gains_mode]; + n = ACELP_GAINS_BITS[gains_mode]; // Q0 move16(); - prm[j] = get_next_indice_fx( st, n ); - j = add( j, 1 ); + prm[j] = get_next_indice_fx( st, n ); // Q0 + j = add( j, 1 ); // Q0 move16(); } } - st->rf_indx_tbeGainFr = get_next_indice_fx( st, 2 ); + st->rf_indx_tbeGainFr = get_next_indice_fx( st, 2 ); // Q0 move16(); } } @@ -1238,18 +1271,18 @@ void dec_prm_fx( if ( st->enablePlcWaveadjust ) { - st->tonality_flag = get_next_indice_fx( st, 1 ); + st->tonality_flag = get_next_indice_fx( st, 1 ); // Q0 move16(); } /* TCX Gain = 7 bits */ - prm[j] = get_next_indice_fx( st, 7 ); - j = add( j, 1 ); + prm[j] = get_next_indice_fx( st, 7 ); // Q0 + j = add( j, 1 ); // Q0 move16(); /* TCX Noise Filling = NBITS_NOISE_FILL_LEVEL bits */ - prm[j] = get_next_indice_fx( st, NBITS_NOISE_FILL_LEVEL ); - j = add( j, 1 ); + prm[j] = get_next_indice_fx( st, NBITS_NOISE_FILL_LEVEL ); // Q0 + j = add( j, 1 ); // Q0 move16(); /* LTP data */ @@ -1258,31 +1291,31 @@ void dec_prm_fx( IF( hTcxLtpDec->tcxltp != 0 || GT_32( st->sr_core, 25600 ) ) { - prm[j] = get_next_indice_fx( st, 1 ); + prm[j] = get_next_indice_fx( st, 1 ); // Q0 move16(); IF( prm[j] ) { - prm[j + 1] = get_next_indice_fx( st, 9 ); + prm[j + 1] = get_next_indice_fx( st, 9 ); // Q0 move16(); - prm[j + 2] = get_next_indice_fx( st, 2 ); + prm[j + 2] = get_next_indice_fx( st, 2 ); // Q0 move16(); } - st->BER_detect = st->BER_detect | - tcx_ltp_decode_params( &prm[j], - &( hTcxLtpDec->tcxltp_pitch_int ), - &( hTcxLtpDec->tcxltp_pitch_fr ), - &( hTcxLtpDec->tcxltp_gain ), - st->pit_min, - st->pit_fr1, - st->pit_fr2, - st->pit_max, - st->pit_res_max ); + st->BER_detect = s_or( st->BER_detect, + tcx_ltp_decode_params( &prm[j], + &( hTcxLtpDec->tcxltp_pitch_int ), + &( hTcxLtpDec->tcxltp_pitch_fr ), + &( hTcxLtpDec->tcxltp_gain ), + st->pit_min, + st->pit_fr1, + st->pit_fr2, + st->pit_max, + st->pit_res_max ) ); - hTcxDec->tcx_hm_LtpPitchLag = -1; + hTcxDec->tcx_hm_LtpPitchLag = -1; // Q15 move16(); - hTcxDec->tcxltp_last_gain_unmodified = hTcxLtpDec->tcxltp_gain; + hTcxDec->tcxltp_last_gain_unmodified = hTcxLtpDec->tcxltp_gain; // Q15 move16(); test(); @@ -1290,12 +1323,12 @@ void dec_prm_fx( { Word32 tmp32 = L_shl( L_mult0( st->L_frame, st->pit_res_max ), 1 + kLtpHmFractionalResolution + 1 ); Word16 tmp1 = add( imult1616( hTcxLtpDec->tcxltp_pitch_int, st->pit_res_max ), hTcxLtpDec->tcxltp_pitch_fr ); - hTcxDec->tcx_hm_LtpPitchLag = div_l( tmp32, tmp1 ); + hTcxDec->tcx_hm_LtpPitchLag = div_l( tmp32, tmp1 ); // Q15 move16(); } } - j = add( j, 3 ); + j = add( j, 3 ); // Q0 /* TCX spectral data */ lg = L_frame; @@ -1303,16 +1336,16 @@ void dec_prm_fx( lgFB = st->hTcxCfg->tcx_coded_lines; move16(); - IF( EQ_16( st->last_core_from_bs, ACELP_CORE ) ) + IF( st->last_core_from_bs == ACELP_CORE ) { /* ACE->TCX transition */ - lg = add( lg, st->hTcxCfg->tcx_offset ); + lg = add( lg, st->hTcxCfg->tcx_offset ); // Q0 if ( st->hTcxCfg->lfacNext < 0 ) { - lg = sub( lg, st->hTcxCfg->lfacNext ); + lg = sub( lg, st->hTcxCfg->lfacNext ); // Q0 } - lgFB = add( lgFB, shr( lgFB, 2 ) ); + lgFB = add( lgFB, shr( lgFB, 2 ) ); // Q0 } /* TNS data */ @@ -1326,7 +1359,7 @@ void dec_prm_fx( SetTnsConfig( st->hTcxCfg, 1, (Word16) EQ_16( st->last_core_from_bs, ACELP_CORE ) ); ReadTnsData( st->hTcxCfg->pCurrentTnsConfig, st, &nTnsBits, prm + j, &nTnsParams ); - j = add( j, nTnsParams ); + j = add( j, nTnsParams ); // Q0 } hm_size = shl( mult( st->TcxBandwidth, lg ), 1 ); @@ -1337,18 +1370,18 @@ void dec_prm_fx( } nbits_tcx = sub( st->bits_frame_core, sub( st->next_bit_pos, start_bit_pos ) ); - if ( st->enableGplc != 0 ) + IF( st->enableGplc != 0 ) { - nbits_tcx = sub( nbits_tcx, 7 ); + nbits_tcx = sub( nbits_tcx, 7 ); // Q0 } /*Context HM flag*/ test(); - IF( st->hTcxCfg->ctx_hm && NE_16( st->last_core_from_bs, ACELP_CORE ) ) + IF( st->hTcxCfg->ctx_hm && ( st->last_core_from_bs != ACELP_CORE ) ) { - prm[j] = get_next_indice_fx( st, 1 ); + prm[j] = get_next_indice_fx( st, 1 ); // Q0 move16(); - nbits_tcx = sub( nbits_tcx, 1 ); + nbits_tcx = sub( nbits_tcx, 1 ); // Q0 IF( prm[j] ) { @@ -1375,10 +1408,10 @@ void dec_prm_fx( hTcxDec->tcx_hm_LtpPitchLag, &hm_cfg ); - nbits_tcx = sub( nbits_tcx, NumIndexBits ); + nbits_tcx = sub( nbits_tcx, NumIndexBits ); // Q0 } } - j = add( j, NPRM_CTX_HM ); + j = add( j, NPRM_CTX_HM ); // Q0 /* read IGF payload */ IF( st->igf ) @@ -1386,7 +1419,7 @@ void dec_prm_fx( n = st->next_bit_pos; move16(); - IF( EQ_16( st->last_core_from_bs, ACELP_CORE ) ) + IF( st->last_core_from_bs == ACELP_CORE ) { IGFDecReadLevel( st->hIGFDec, st, IGF_GRID_LB_TRAN, 1 ); IGFDecReadData( st->hIGFDec, st, IGF_GRID_LB_TRAN, 1 ); @@ -1397,22 +1430,22 @@ void dec_prm_fx( IGFDecReadData( st->hIGFDec, st, IGF_GRID_LB_NORM, 1 ); } - nbits_tcx = sub( nbits_tcx, sub( st->next_bit_pos, n ) ); + nbits_tcx = sub( nbits_tcx, sub( st->next_bit_pos, n ) ); // Q0 } - nbits_tcx = sub( st->bits_frame_core, sub( st->next_bit_pos, start_bit_pos ) ); + nbits_tcx = sub( st->bits_frame_core, sub( st->next_bit_pos, start_bit_pos ) ); // Q0 IF( hTcxDec->tcx_lpc_shaped_ari != 0 ) { - prm[j] = nbits_tcx; /* store length of buffer */ - j = add( j, 1 ); + prm[j] = nbits_tcx; /* store length of buffer */ // Q0 + j = add( j, 1 ); // Q0 move16(); prms = &prm[j]; FOR( ix = 0; ix < nbits_tcx; ix++ ) { - prms[ix] = get_next_indice_1_fx( st ); + prms[ix] = get_next_indice_1_fx( st ); // Q0 move16(); } set16_fx( prms + nbits_tcx, 1, 32 ); - j = add( j, nbits_tcx ); + j = add( j, nbits_tcx ); // Q0 } ELSE { @@ -1423,9 +1456,9 @@ void dec_prm_fx( phm_cfg = &hm_cfg; move16(); } - hTcxDec->resQBits[0] = ACcontextMapping_decode2_no_mem_s17_LC( st, prm + j, lgFB, nbits_tcx, NPRM_RESQ * st->hTcxCfg->resq, phm_cfg ); + hTcxDec->resQBits[0] = ACcontextMapping_decode2_no_mem_s17_LC( st, prm + j, lgFB, nbits_tcx, imult1616( NPRM_RESQ, st->hTcxCfg->resq ), phm_cfg ); // Q0 move16(); - j = add( j, lg ); + j = add( j, lg ); // Q0 } } @@ -1434,7 +1467,7 @@ void dec_prm_fx( IF( GE_16( st->rf_frame_type, RF_TCXFD ) && LE_16( st->rf_frame_type, RF_TCXTD2 ) && EQ_16( st->use_partial_copy, 1 ) ) { /* classification */ - ind = get_next_indice_fx( st, 2 ); + ind = get_next_indice_fx( st, 2 ); // Q0 st->clas_dec = ONSET; move16(); @@ -1465,7 +1498,7 @@ void dec_prm_fx( IF( EQ_16( st->rf_frame_type, RF_TCXFD ) ) { /* TCX Gain = 7 bits */ - hTcxDec->old_gaintcx_bfi = get_next_indice_fx( st, 7 ); + hTcxDec->old_gaintcx_bfi = get_next_indice_fx( st, 7 ); // Q0 move16(); } ELSE @@ -1476,19 +1509,19 @@ void dec_prm_fx( test(); IF( EQ_16( st->rf_frame_type, RF_TCXTD2 ) || EQ_16( st->rf_frame_type, RF_TCXTD1 ) ) { - prm_ltp[0] = 1; - move16(); /* LTP active*/ - prm_ltp[1] = get_next_indice_fx( st, 9 ); - prm_ltp[2] = 3; - move16(); /* max ampl. quantizer output (2bits), anyway not used later*/ + prm_ltp[0] = 1; // Q0 + move16(); /* LTP active*/ + prm_ltp[1] = get_next_indice_fx( st, 9 ); // Q0 + prm_ltp[2] = 3; // Q0 + move16(); /* max ampl. quantizer output (2bits), anyway not used later*/ IF( st->prev_bfi == 0 ) { - st->BER_detect = st->BER_detect | - tcx_ltp_decode_params( &prm_ltp[0], &( hTcxLtpDec->tcxltp_pitch_int ), &( hTcxLtpDec->tcxltp_pitch_fr ), &( hTcxLtpDec->tcxltp_gain ), - st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max ); + st->BER_detect = s_or( st->BER_detect, + tcx_ltp_decode_params( &prm_ltp[0], &( hTcxLtpDec->tcxltp_pitch_int ), &( hTcxLtpDec->tcxltp_pitch_fr ), &( hTcxLtpDec->tcxltp_gain ), + st->pit_min, st->pit_fr1, st->pit_fr2, st->pit_max, st->pit_res_max ) ); move16(); - hTcxDec->tcxltp_last_gain_unmodified = hTcxLtpDec->tcxltp_gain; + hTcxDec->tcxltp_last_gain_unmodified = hTcxLtpDec->tcxltp_gain; // Q15 move16(); } } @@ -1536,22 +1569,22 @@ void dec_prm_fx( j = 0; move16(); - nbits_tcx = sub( st->next_bit_pos, start_bit_pos ); + nbits_tcx = sub( st->next_bit_pos, start_bit_pos ); // Q0 test(); - if ( st->enablePlcWaveadjust && k ) + IF( st->enablePlcWaveadjust && k ) { - st->tonality_flag = get_next_indice_fx( st, 1 ); + st->tonality_flag = get_next_indice_fx( st, 1 ); // Q0 move16(); } /* TCX Gain = 7 bits */ - prm[j] = get_next_indice_fx( st, 7 ); - j = add( j, 1 ); + prm[j] = get_next_indice_fx( st, 7 ); // Q0 + j = add( j, 1 ); // Q0 move16(); /* TCX Noise Filling = NBITS_NOISE_FILL_LEVEL bits */ - prm[j] = get_next_indice_fx( st, NBITS_NOISE_FILL_LEVEL ); - j = add( j, 1 ); + prm[j] = get_next_indice_fx( st, NBITS_NOISE_FILL_LEVEL ); // Q0 + j = add( j, 1 ); // Q0 move16(); /* LTP data */ @@ -1559,22 +1592,22 @@ void dec_prm_fx( test(); IF( ( k == 0 ) && ( ( hTcxLtpDec->tcxltp != 0 ) || ( GT_32( st->sr_core, 25600 ) ) ) ) { - prm[j] = get_next_indice_fx( st, 1 ); + prm[j] = get_next_indice_fx( st, 1 ); // Q0 move16(); IF( prm[j] ) { - prm[j + 1] = get_next_indice_fx( st, 9 ); + prm[j + 1] = get_next_indice_fx( st, 9 ); // Q0 move16(); - prm[j + 2] = get_next_indice_fx( st, 2 ); + prm[j + 2] = get_next_indice_fx( st, 2 ); // Q0 move16(); - tcxltp_prm_0 = prm[j]; + tcxltp_prm_0 = prm[j]; // Q0 move16(); - tcxltp_prm_1 = prm[j + 1]; + tcxltp_prm_1 = prm[j + 1]; // Q0 move16(); - tcxltp_prm_2 = prm[j + 2]; + tcxltp_prm_2 = prm[j + 2]; // Q0 move16(); } @@ -1590,32 +1623,32 @@ void dec_prm_fx( st->pit_res_max ) ); move16(); - hTcxDec->tcxltp_last_gain_unmodified = hTcxLtpDec->tcxltp_gain; + hTcxDec->tcxltp_last_gain_unmodified = hTcxLtpDec->tcxltp_gain; // Q15 move16(); - hTcxDec->tcx_hm_LtpPitchLag = -1; + hTcxDec->tcx_hm_LtpPitchLag = -1; // Q15 move16(); - j = add( j, 3 ); + j = add( j, 3 ); // Q0 } ELSE { - prm[j] = tcxltp_prm_0; - j = add( j, 1 ); + prm[j] = tcxltp_prm_0; // Q0 + j = add( j, 1 ); // Q0 move16(); - prm[j] = tcxltp_prm_1; - j = add( j, 1 ); + prm[j] = tcxltp_prm_1; // Q0 + j = add( j, 1 ); // Q0 move16(); - prm[j] = tcxltp_prm_2; - j = add( j, 1 ); + prm[j] = tcxltp_prm_2; // Q0 + j = add( j, 1 ); // Q0 move16(); } /* TCX spectral data */ - lg = shr( L_frame, 1 ); - lgFB = shr( st->hTcxCfg->tcx_coded_lines, 1 ); + lg = shr( L_frame, 1 ); // Q0 + lgFB = shr( st->hTcxCfg->tcx_coded_lines, 1 ); // Q0 test(); - IF( k == 0 && EQ_16( st->last_core_from_bs, ACELP_CORE ) ) + IF( k == 0 && ( st->last_core_from_bs == ACELP_CORE ) ) { /* ACE->TCX transition */ lg = add( lg, st->hTcxCfg->tcx_offset ); @@ -1656,31 +1689,31 @@ void dec_prm_fx( hm_size = shl( mult( st->TcxBandwidth, lgFB ), 1 ); /*compute target bits*/ - nbits_tcx = sub( shr( sub( add( sub( sub( st->bits_frame_core, st->bits_common ), nbits_igf ), 1 ), k ), 1 ), sub( sub( st->next_bit_pos, start_bit_pos ), nbits_tcx ) ); + nbits_tcx = sub( shr( sub( add( sub( sub( st->bits_frame_core, st->bits_common ), nbits_igf ), 1 ), k ), 1 ), sub( sub( st->next_bit_pos, start_bit_pos ), nbits_tcx ) ); // Q0 /*Context HM flag*/ test(); test(); - IF( st->hTcxCfg->ctx_hm && !( EQ_16( st->last_core_from_bs, ACELP_CORE ) && ( k == 0 ) ) ) + IF( st->hTcxCfg->ctx_hm && !( ( st->last_core_from_bs == ACELP_CORE ) && ( k == 0 ) ) ) { - prm[j] = get_next_indice_fx( st, 1 ); + prm[j] = get_next_indice_fx( st, 1 ); // Q0 move16(); - nbits_tcx = sub( nbits_tcx, 1 ); + nbits_tcx = sub( nbits_tcx, 1 ); // Q0 move16(); IF( prm[j] ) /* Read PeriodicityIndex */ { - Word16 NumIndexBits = DecodeIndex_fx( st, (Word16) GE_16( hm_size, 256 ), prm + j + 1 ); + Word16 NumIndexBits = DecodeIndex_fx( st, (Word16) GE_16( hm_size, 256 ), prm + j + 1 ); // Q0 flag_ctx_hm = 1; move16(); ConfigureContextHm( lgFB, nbits_tcx, *( prm + j + 1 ), -1, &hm_cfg ); - nbits_tcx = sub( nbits_tcx, NumIndexBits ); + nbits_tcx = sub( nbits_tcx, NumIndexBits ); // Q0 } } - j = add( j, NPRM_CTX_HM ); + j = add( j, NPRM_CTX_HM ); // Q0 phm_cfg = NULL; move16(); if ( flag_ctx_hm ) @@ -1688,9 +1721,9 @@ void dec_prm_fx( phm_cfg = &hm_cfg; move16(); } - hTcxDec->resQBits[k] = ACcontextMapping_decode2_no_mem_s17_LC( st, prm + j, lgFB, nbits_tcx, NPRM_RESQ * st->hTcxCfg->resq, phm_cfg ); + hTcxDec->resQBits[k] = ACcontextMapping_decode2_no_mem_s17_LC( st, prm + j, lgFB, nbits_tcx, imult1616( NPRM_RESQ, st->hTcxCfg->resq ), phm_cfg ); // Q0 move16(); - j = add( j, lgFB ); + j = add( j, lgFB ); // Q0 } /* k, window index */ } @@ -1701,10 +1734,10 @@ void dec_prm_fx( { st->BER_detect = 1; move16(); - st->next_bit_pos = add( start_bit_pos, sub( *total_nbbits, bitsRead[0] ) ); + st->next_bit_pos = add( start_bit_pos, sub( *total_nbbits, bitsRead[0] ) ); // Q0 move16(); } - bitsRead[0] = sub( st->next_bit_pos, start_bit_pos ); + bitsRead[0] = sub( st->next_bit_pos, start_bit_pos ); // Q0 move16(); } diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 53b688e72..35a417a6c 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -1613,9 +1613,9 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, #ifdef IVAS_FLOAT_FIXED void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, - Word16 *synth, - Word16 *synthFB, - Word16 *A, + Word16 *synth, // Qx + Word16 *synthFB, // Qx + Word16 *A, // Q: 14 - norm_s(A[0]) Word16 bfi, Word16 MCT_flag ) { @@ -1684,7 +1684,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, { tmp32 = L_shl( tmp32_1 /*Q28*/, -( 28 - 15 ) ); /*16Q15*/ #ifdef BASOP_NOGLOB - synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp32, synthFB[i] ), 16 ) ); + synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp32, synthFB[i] ), 16 ) ); // Qx #else synthFB[i] = round_fx( L_shl( Mpy_32_16_1( tmp32, synthFB[i] ), 16 ) ); #endif @@ -1696,8 +1696,8 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, tmp32_2 /*stepCompensate*/ = L_shl_r( L_deposit_h( hTcxDec->stepCompensate ), sub( hTcxDec->stepCompensate_e, 31 - 28 ) ); /*Q28*/ FOR( i = 0; i < st_fx->L_frame; i++ ) { - tmp32 = L_shl( tmp32_1 /*Q28*/, -( 28 - 15 ) ); /*16Q15*/ - xn_buf[i] = extract_l( Mpy_32_16_1( tmp32, xn_buf[i] ) ); + tmp32 = L_shl( tmp32_1 /*Q28*/, -( 28 - 15 ) ); /*16Q15*/ + xn_buf[i] = extract_l( Mpy_32_16_1( tmp32, xn_buf[i] ) ); // Qx move16(); tmp32_1 = L_sub( tmp32_1, tmp32_2 ); } @@ -1843,7 +1843,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, } } - if ( ( EQ_16( st_fx->nbLostCmpt, 1 ) ) ) + IF( ( EQ_16( st_fx->nbLostCmpt, 1 ) ) ) { hTcxDec->conceal_eof_gain32 = ONE_IN_Q30 /*1.0f Q30*/; move32(); @@ -1878,14 +1878,14 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, FOR( i = 0; i < hTcxDec->L_frameTCX; i++ ) { tmp_shift = conceal_eof_gainFB_e; - synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( conceal_eof_gainFB, synthFB[i] ), tmp_shift ) ); + synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( conceal_eof_gainFB, synthFB[i] ), tmp_shift ) ); // Qx move16(); - conceal_eof_gainFB = BASOP_Util_Add_Mant32Exp( conceal_eof_gainFB, conceal_eof_gainFB_e, L_negate( stepFB ), stepFB_e, &conceal_eof_gainFB_e ); + conceal_eof_gainFB = BASOP_Util_Add_Mant32Exp( conceal_eof_gainFB, conceal_eof_gainFB_e, L_negate( stepFB ), stepFB_e, &conceal_eof_gainFB_e ); // Q: 31 - conceal_eof_gainFB_e } } FOR( i = 0; i < st_fx->L_frame; i++ ) { - xn_buf[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( hTcxDec->conceal_eof_gain32, xn_buf[i] ), hTcxDec->conceal_eof_gain_e ) ); + xn_buf[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( hTcxDec->conceal_eof_gain32, xn_buf[i] ), hTcxDec->conceal_eof_gain_e ) ); // Qx move16(); hTcxDec->conceal_eof_gain32 = BASOP_Util_Add_Mant32Exp( hTcxDec->conceal_eof_gain32, hTcxDec->conceal_eof_gain_e, L_negate( step ), step_e, &hTcxDec->conceal_eof_gain_e ); move32(); @@ -1956,16 +1956,16 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, st_fx->bfi_pitch_frame = st_fx->L_frame; move16(); - st_fx->mem_pitch_gain[add( shl( st_fx->nb_subfr, 1 ), 1 )] = st_fx->mem_pitch_gain[st_fx->nb_subfr + 1]; + st_fx->mem_pitch_gain[st_fx->nb_subfr * 2 + 1] = st_fx->mem_pitch_gain[st_fx->nb_subfr + 1]; // Q14 move16(); - st_fx->mem_pitch_gain[shl( st_fx->nb_subfr, 1 )] = st_fx->mem_pitch_gain[st_fx->nb_subfr]; + st_fx->mem_pitch_gain[st_fx->nb_subfr * 2] = st_fx->mem_pitch_gain[st_fx->nb_subfr]; // Q14 move16(); FOR( i = 0; i < st_fx->nb_subfr; i++ ) { - st_fx->mem_pitch_gain[sub( sub( shl( st_fx->nb_subfr, 1 ), 1 ), i )] = st_fx->mem_pitch_gain[sub( sub( st_fx->nb_subfr, 1 ), i )]; + st_fx->mem_pitch_gain[( st_fx->nb_subfr * 2 - 1 ) - i] = st_fx->mem_pitch_gain[st_fx->nb_subfr - 1 - i]; // Q14 move16(); - st_fx->mem_pitch_gain[sub( sub( st_fx->nb_subfr, 1 ), i )] = shr( hTcxDec->tcxltp_last_gain_unmodified, 1 ); /* Q14 */ + st_fx->mem_pitch_gain[st_fx->nb_subfr - 1 - i] = shr( hTcxDec->tcxltp_last_gain_unmodified, 1 ); /* Q14 */ move16(); } } @@ -2049,7 +2049,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T /* number of zero for ALDO windows*/ tmp32 = L_add( st->sr_core, 0 ); - if ( fullbandScale != 0 ) + IF( fullbandScale != 0 ) { tmp32 = L_add( st->output_Fs, 0 ); } @@ -2057,7 +2057,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T tmp_offset = 0; move16(); - if ( tcx_offset < 0 ) + IF( tcx_offset < 0 ) { tmp_offset = negate( tcx_offset ); } @@ -2258,9 +2258,9 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T L_win ); /* extra folding-out on left side of win, for perfect reconstruction */ - FOR( w = shr( overlap, 1 ); w < overlap; w++ ) + FOR( w = ( overlap / 2 ); w < overlap; w++ ) { - xn_buf[sub( sub( overlap, 1 ), w )] = negate( xn_buf[w] ); + xn_buf[( ( overlap - 1 ) - w )] = negate( xn_buf[w] ); move16(); } @@ -2745,8 +2745,8 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T FOR( ; i < tcx_mdct_window_half_length; i++ ) { #ifdef BASOP_NOGLOB - xn_buf[i + tmp1] = mult_r_sat( xn_buf[i + tmp1], tcx_mdct_window_half[sub( sub( tcx_mdct_window_half_length, 1 ), i )].v.re ); - xn_buf[i + tmp1] = add_sat( xn_buf[i + tmp1], mult_r_sat( hTcxDec->syn_OverlFB[i], mult_r_sat( tcx_mdct_window_half[sub( sub( tcx_mdct_window_half_length, 1 ), i )].v.im, tcx_mdct_window_half[sub( sub( tcx_mdct_window_half_length, 1 ), i )].v.im ) ) ); + xn_buf[i + tmp1] = mult_r_sat( xn_buf[i + tmp1], tcx_mdct_window_half[( ( tcx_mdct_window_half_length - 1 ) - i )].v.re ); + xn_buf[i + tmp1] = add_sat( xn_buf[i + tmp1], mult_r_sat( hTcxDec->syn_OverlFB[i], mult_r_sat( tcx_mdct_window_half[( ( tcx_mdct_window_half_length - 1 ) - i )].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im ) ) ); #else xn_buf[i + tmp1] = mult_r( xn_buf[i + tmp1], tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.re ); xn_buf[i + tmp1] = add( xn_buf[i + tmp1], mult_r( hTcxDec->syn_OverlFB[i], mult_r( tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im ) ) ); @@ -2774,8 +2774,8 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T FOR( ; i < tcx_mdct_window_half_length; i++ ) { #ifdef BASOP_NOGLOB - xn_buf[i + tmp1] = mult_r_sat( xn_buf[i + tmp1], tcx_mdct_window_half[sub( sub( tcx_mdct_window_half_length, 1 ), i )].v.re ); - xn_buf[i + tmp1] = add_sat( xn_buf[i + tmp1], mult_r_sat( hTcxDec->syn_Overl[i], mult_r_sat( tcx_mdct_window_half[sub( sub( tcx_mdct_window_half_length, 1 ), i )].v.im, tcx_mdct_window_half[sub( sub( tcx_mdct_window_half_length, 1 ), i )].v.im ) ) ); + xn_buf[i + tmp1] = mult_r_sat( xn_buf[i + tmp1], tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.re ); + xn_buf[i + tmp1] = add_sat( xn_buf[i + tmp1], mult_r_sat( hTcxDec->syn_Overl[i], mult_r_sat( tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im ) ) ); #else xn_buf[i + tmp1] = mult_r( xn_buf[i + tmp1], tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.re ); xn_buf[i + tmp1] = add( xn_buf[i + tmp1], mult_r( hTcxDec->syn_Overl[i], mult_r( tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im, tcx_mdct_window_half[tcx_mdct_window_half_length - 1 - i].v.im ) ) ); @@ -2836,7 +2836,7 @@ void IMDCT_ivas_fx( exp = 0; move16(); nz = BASOP_Util_Divide3216_Scale( c, L_frameTCX, &exp ); - exp = exp + ( 31 - 15 ); + exp = add( exp, ( 31 - 15 ) ); nz = shr( nz, sub( 15, exp ) ); // Q0 test(); @@ -2852,7 +2852,7 @@ void IMDCT_ivas_fx( fac = Mpy_32_16_1( hTcxDec->conceal_eof_gain32, st->last_concealed_gain_syn_deemph ); // q = 31 - hTcxDec->conceal_eof_gain_e FOR( Word16 ind = 0; ind < overlap; ind++ ) { - old_syn_overl_fx[ind] = extract_l( L_shl_sat( Mpy_32_32( old_syn_overl_fx[ind], fac ), hTcxDec->conceal_eof_gain_e ) ); + old_syn_overl_fx[ind] = extract_l( L_shl_sat( Mpy_32_32( old_syn_overl_fx[ind], fac ), hTcxDec->conceal_eof_gain_e ) ); // Q(-2) move16(); } } @@ -2998,17 +2998,17 @@ void IMDCT_ivas_fx( /* extra folding-out on left side of win, for perfect reconstruction */ IF( GE_16( kernel_type, MDCT_II ) ) { - FOR( w = shr( overlap, 1 ); w < overlap; w++ ) + FOR( w = overlap / 2; w < overlap; w++ ) { - xn_buf_fx[sub( sub( overlap, 1 ), w )] = xn_buf_fx[w]; + xn_buf_fx[overlap - 1 - w] = xn_buf_fx[w]; move16(); } } ELSE { - FOR( w = shr( overlap, 1 ); w < overlap; w++ ) + FOR( w = overlap / 2; w < overlap; w++ ) { - xn_buf_fx[sub( sub( overlap, 1 ), w )] = negate( xn_buf_fx[w] ); + xn_buf_fx[overlap - 1 - w] = negate( xn_buf_fx[w] ); move16(); } } @@ -3068,7 +3068,7 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { - tmp_fx_32[ind] = L_shl( Mpy_32_16_1( xn_buf_fx_32[shr( overlap, 1 ) + nz + ind], res_m ), res_e ); + tmp_fx_32[ind] = L_shl( Mpy_32_16_1( xn_buf_fx_32[( overlap / 2 ) + nz + ind], res_m ), res_e ); move32(); } q_tmp_fx_32 = q_xn_buf_fx_32; @@ -3103,7 +3103,7 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { - tmp_fx_32[ind] = Mpy_32_16_1( xn_buf_fx_32[shr( overlap, 1 ) + nz + ind], res_m ); + tmp_fx_32[ind] = Mpy_32_16_1( xn_buf_fx_32[( overlap / 2 ) + nz + ind], res_m ); move32(); } q_tmp_fx_32 = sub( q_xn_buf_fx_32, res_e ); @@ -3111,7 +3111,7 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { - xn_buf_fx[add( add( ind, shr( overlap, 1 ) ), nz )] = (Word16) L_shr( xn_buf_fx_32[add( add( ind, shr( overlap, 1 ) ), nz )], sub( q_xn_buf_fx_32, q_win ) ); + xn_buf_fx[( ind + ( overlap / 2 ) ) + nz] = (Word16) L_shr( xn_buf_fx_32[( ind + ( overlap / 2 ) ) + nz], sub( q_xn_buf_fx_32, q_win ) ); move16(); } @@ -3135,13 +3135,13 @@ void IMDCT_ivas_fx( IF( tcx_offset < 0 ) { - acelp_mem_len = -tcx_offset; + acelp_mem_len = negate( tcx_offset ); } ELSE { acelp_mem_len = 0; + move16(); } - move16(); IF( EQ_16( kernel_type, MDST_IV ) ) { @@ -3183,7 +3183,7 @@ void IMDCT_ivas_fx( lev_dur_fx( &st->old_Aq_12_8_fx_32[0], &r_fx[0], M, NULL, 28 /*Q(st->q_old_Aq_12_8_fx_32)*/, add( add( shl( q_buf, 1 ), q_r ), 1 ) ); FOR( Word16 ind = 0; ind <= M; ind++ ) { - st->old_Aq_12_8_fx[ind] = (Word16) L_shr( st->old_Aq_12_8_fx_32[ind], 16 ); + st->old_Aq_12_8_fx[ind] = (Word16) L_shr( st->old_Aq_12_8_fx_32[ind], 16 ); // Q28 -> Q12 move16(); } } @@ -3215,9 +3215,9 @@ void IMDCT_ivas_fx( FOR( i = 0; i < sub( overlap, tcx_mdct_window_min_length ); i++ ) { #ifdef BASOP_NOGLOB - xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )] = add_sat( xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )], old_out_fx[add( i, nz )] ); + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); // Q(-2) #else - xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )] = add( xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )], old_out_fx[add( i, nz )] ); + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); #endif move16(); } @@ -3232,49 +3232,49 @@ void IMDCT_ivas_fx( FOR( ; i < overlap; i++ ) /* perfectly reconstructing ALDO shortening */ { #ifdef BASOP_NOGLOB - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], old_out_fx[add( i, nz )] ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // Q(-2) #else - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], old_out_fx[add( i, nz )] ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // Q(-2) #endif move16(); } - FOR( i = 0; i < shr( tcx_mdct_window_min_length, 1 ); i++ ) + FOR( i = 0; i < ( tcx_mdct_window_min_length / 2 ); i++ ) { #ifdef BASOP_NOGLOB - xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )] = add_sat( xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )], mult_r( old_out_fx[add( add( i, nz ), overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); // Q(-2) #else - xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )] = add( xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )], mult_r( old_out_fx[add( add( i, nz ), overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); #endif move16(); } FOR( ; i < tcx_mdct_window_min_length; i++ ) { #ifdef BASOP_NOGLOB - xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )] = add_sat( xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )], mult_r( old_out_fx[add( add( i, nz ), overlap )], tcx_mdct_window_minimum_fx[sub( tcx_mdct_window_min_length, add( 1, i ) )].v.im ) ); + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // Q(-2) #else - xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )] = add( xn_buf_fx[add( sub( add( i, shr( overlap, 1 ) ), tcx_offset ), overlap )], mult_r( old_out_fx[add( add( i, nz ), overlap )], tcx_mdct_window_minimum_fx[sub( tcx_mdct_window_min_length, add( 1, i ) )].v.im ) ); + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); #endif move16(); } } ELSE { - FOR( ; i < sub( overlap, shr( tcx_mdct_window_min_length, 1 ) ); i++ ) + FOR( ; i < ( overlap - ( tcx_mdct_window_min_length / 2 ) ); i++ ) { #ifdef BASOP_NOGLOB - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_out_fx[add( i, nz )], tcx_mdct_window_minimum_fx[add( sub( tcx_mdct_window_min_length, overlap ), i )].v.re ) ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) #else - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_out_fx[add( i, nz )], tcx_mdct_window_minimum_fx[add( sub( tcx_mdct_window_min_length, overlap ), i )].v.re ) ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); #endif move16(); } FOR( ; i < overlap; i++ ) { #ifdef BASOP_NOGLOB - xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_out_fx[add( i, nz )], tcx_mdct_window_minimum_fx[sub( overlap, add( 1, i ) )].v.im ) ); + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) #else - xn_buf_fx[add( i, sub( shr( overlap, 1 ), tcx_offset ) )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_out_fx[add( i, nz )], tcx_mdct_window_minimum_fx[sub( overlap, add( 1, i ) )].v.im ) ); + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); #endif move16(); } @@ -3286,12 +3286,12 @@ void IMDCT_ivas_fx( IF( bfi != 0 ) { - FOR( i = 0; i < shr( tcx_mdct_window_half_length, 1 ); i++ ) + FOR( i = 0; i < ( tcx_mdct_window_half_length / 2 ); i++ ) { #ifdef BASOP_NOGLOB - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[i].v.re ) ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[i].v.re ) ); // Q(-2) #else - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[i].v.re ) ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[i].v.re ) ); #endif move16(); @@ -3299,9 +3299,9 @@ void IMDCT_ivas_fx( FOR( ; i < tcx_mdct_window_half_length; i++ ) { #ifdef BASOP_NOGLOB - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); // Q(-2) #else - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_syn_overl_fx[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); #endif move16(); } @@ -3310,7 +3310,7 @@ void IMDCT_ivas_fx( { FOR( i = 0; i < overlap; i++ ) { - xn_buf_fx[i] = add_sat( xn_buf_fx[i], old_syn_overl_fx[i] ); + xn_buf_fx[i] = add_sat( xn_buf_fx[i], old_syn_overl_fx[i] ); // Q(-2) move16(); } } @@ -3319,9 +3319,9 @@ void IMDCT_ivas_fx( FOR( i = 0; i < overlap; i++ ) { #ifdef BASOP_NOGLOB - xn_buf_fx[add( i, shr( overlap, 1 ) )] = add_sat( xn_buf_fx[add( i, shr( overlap, 1 ) )], old_syn_overl_fx[i] ); + xn_buf_fx[( i + ( overlap / 2 ) )] = add_sat( xn_buf_fx[( i + ( overlap / 2 ) )], old_syn_overl_fx[i] ); // Q(-2) #else - xn_buf_fx[add( i, shr( overlap, 1 ) )] = add( xn_buf_fx[add( i, shr( overlap, 1 ) )], old_syn_overl_fx[i] ); + xn_buf_fx[( i + ( overlap / 2 ) )] = add( xn_buf_fx[( i + ( overlap / 2 ) )], old_syn_overl_fx[i] ); #endif move16(); } @@ -3347,7 +3347,7 @@ void IMDCT_ivas_fx( { FOR( i = 0; i < nz; i++ ) { - old_out_fx[add( add( nz, overlap ), i )] = negate( mult_r( xn_buf_fx[sub( L_frame, add( 1, i ) )], tcx_aldo_window_1_fx[sub( nz, add( 1, i ) )] ) ); + old_out_fx[( ( nz + overlap ) + i )] = negate( mult_r( xn_buf_fx[( L_frame - ( 1 + i ) )], tcx_aldo_window_1_fx[( nz - ( 1 + i ) )] ) ); // Q(-2) move16(); } } @@ -3355,7 +3355,7 @@ void IMDCT_ivas_fx( { FOR( i = 0; i < nz; i++ ) { - old_out_fx[add( add( nz, overlap ), i )] = mult_r( xn_buf_fx[sub( L_frame, add( 1, i ) )], tcx_aldo_window_1_fx[sub( nz, add( 1, i ) )] ); + old_out_fx[( ( nz + overlap ) + i )] = mult_r( xn_buf_fx[( L_frame - ( 1 + i ) )], tcx_aldo_window_1_fx[( nz - ( 1 + i ) )] ); // Q(-2) move16(); } } @@ -3378,41 +3378,41 @@ void IMDCT_ivas_fx( { IF( FB_flag != 0 ) { - FOR( i = 0; i < shr( tcx_mdct_window_half_length, 1 ); i++ ) + FOR( i = 0; i < ( tcx_mdct_window_half_length / 2 ); i++ ) { - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = mult_r( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], tcx_mdct_window_half_fx[i].v.im ); - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_OverlFB[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[i].v.im ); // Q(-2) + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_OverlFB[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); // Q(-2) move16(); move16(); } FOR( ; i < tcx_mdct_window_half_length; i++ ) { - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = mult_r( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.re ); - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_OverlFB[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ), tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.re ); // Q(-2) + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_OverlFB[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ), tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); // Q(-2) move16(); move16(); } } ELSE { - FOR( i = 0; i < shr( tcx_mdct_window_half_length, 1 ); i++ ) + FOR( i = 0; i < ( tcx_mdct_window_half_length / 2 ); i++ ) { - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = mult_r( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], tcx_mdct_window_half_fx[i].v.im ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[i].v.im ); #ifdef BASOP_NOGLOB - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); // Q(-2) #else - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[i].v.re ), tcx_mdct_window_half_fx[i].v.re ) ); #endif move16(); move16(); } FOR( ; i < tcx_mdct_window_half_length; i++ ) { - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = mult_r( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.re ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = mult_r( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.re ); #ifdef BASOP_NOGLOB - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add_sat( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ), tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ), tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); // Q(-2) #else - xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )] = add( xn_buf_fx[sub( add( i, shr( overlap, 1 ) ), tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ), tcx_mdct_window_half_fx[sub( tcx_mdct_window_half_length, add( 1, i ) )].v.im ) ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( mult_r( hTcxDec->syn_Overl[i], tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ), tcx_mdct_window_half_fx[( tcx_mdct_window_half_length - ( 1 + i ) )].v.im ) ); #endif move16(); move16(); @@ -3536,7 +3536,16 @@ void init_tcx_info_fx( } ELSE { - IGFDecUpdateInfo_ivas_fx( st->hIGFDec, frame_cnt, ( st->last_core == ACELP_CORE || ( *left_rect && st->bfi ) ) ? IGF_GRID_LB_TRAN : IGF_GRID_LB_NORM ); + test(); + test(); + IF( st->last_core == ACELP_CORE || ( *left_rect && st->bfi ) ) + { + IGFDecUpdateInfo_ivas_fx( st->hIGFDec, frame_cnt, IGF_GRID_LB_TRAN ); + } + ELSE + { + IGFDecUpdateInfo_ivas_fx( st->hIGFDec, frame_cnt, IGF_GRID_LB_NORM ); + } } } } @@ -3593,6 +3602,7 @@ void decoder_tcx_IGF_mono_fx( test(); IF( NE_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly ) { + test(); test(); IF( EQ_16( st->last_core, ACELP_CORE ) || ( left_rect && bfi ) ) { @@ -3664,7 +3674,7 @@ void decoder_tcx_IGF_stereo_fx( FOR( sfb = 0; sfb < sfbConf->sfbCnt; sfb++ ) { - set16_fx( &coreMsMask[sfbConf->sfbOffset[sfb]], ms_mask[k][sfb], sfbConf->sfbOffset[sfb + 1] - sfbConf->sfbOffset[sfb] ); + set16_fx( &coreMsMask[sfbConf->sfbOffset[sfb]], ms_mask[k][sfb], sub( sfbConf->sfbOffset[sfb + 1], sfbConf->sfbOffset[sfb] ) ); } test(); @@ -3756,10 +3766,10 @@ void decoder_tcx_IGF_stereo_fx( void decoder_tcx_ivas_fx( Decoder_State *st, Word16 prm[], - Word16 A_fx[], - Word16 Aind[], - Word16 synth_fx[], - Word16 synthFB_fx[], + Word16 A_fx[], // Q: 14 - norm_s(A_fx[0]) + Word16 Aind[], // Q: 14 - norm_s(Aind[0]) + Word16 synth_fx[], // Q_syn + Word16 synthFB_fx[], // Q_syn const Word16 bfi, const Word16 frame_cnt, const Word16 sba_dirac_stereo_flag ) @@ -4038,9 +4048,16 @@ void decoder_tcx_invQ_fx( prm_sqQ = prm_target + 1; move16(); - tcx_arith_decode_envelope_ivas_fx( st, x, x_e, L_frame, L_spec, Aind, *prm_target, prm_sqQ, (Word16) NE_16( st->last_core_from_bs, ACELP_CORE ), prm_hm, /* HM parameter area */ hTcxDec->tcx_hm_LtpPitchLag, &arith_bits, &signaling_bits, ( st->bwidth > WB ) ? 1 : 0 ); + IF( GT_32( st->bwidth, WB ) ) + { + tcx_arith_decode_envelope_ivas_fx( st, x, x_e, L_frame, L_spec, Aind, *prm_target, prm_sqQ, (Word16) NE_16( st->last_core_from_bs, ACELP_CORE ), prm_hm, /* HM parameter area */ hTcxDec->tcx_hm_LtpPitchLag, &arith_bits, &signaling_bits, 1 ); + } + ELSE + { + tcx_arith_decode_envelope_ivas_fx( st, x, x_e, L_frame, L_spec, Aind, *prm_target, prm_sqQ, (Word16) NE_16( st->last_core_from_bs, ACELP_CORE ), prm_hm, /* HM parameter area */ hTcxDec->tcx_hm_LtpPitchLag, &arith_bits, &signaling_bits, 0 ); + } - hTcxDec->resQBits[frame_cnt] = *prm_target - arith_bits; + hTcxDec->resQBits[frame_cnt] = sub( *prm_target, arith_bits ); move16(); /* Noise filling seed */ @@ -4098,7 +4115,7 @@ void decoder_tcx_invQ_fx( move16(); } - FOR( i = start_zeroing; i < max( L_frame, L_frameTCX ); i++ ) + FOR( i = start_zeroing; i < s_max( L_frame, L_frameTCX ); i++ ) { x[i] = 0; move32(); @@ -4171,7 +4188,7 @@ void decoder_tcx_invQ_fx( hTcxDec->old_gaintcx_bfi_e = *gain_tcx_e; move16(); - hTcxDec->cummulative_damping_tcx = MAX16B; + hTcxDec->cummulative_damping_tcx = MAX16B; // 1 in Q15 move16(); } ELSE /* bfi = 1 */ @@ -4211,7 +4228,7 @@ void decoder_tcx_invQ_fx( move16(); } - hTcxDec->damping = ONE_IN_Q14; + hTcxDec->damping = ONE_IN_Q14; // Q14 move16(); } ELSE @@ -4257,7 +4274,7 @@ void decoder_tcx_invQ_fx( gamma = add( mult_r( hTcxDec->cummulative_damping_tcx, sub( gamma1, MAX16B ) ), MAX16B ); } - IF( st->element_mode != IVAS_CPE_MDCT ) + IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { weight_a_fx( A, Ap, gamma, M ); lpc2mdct_2( Ap, M, NULL, NULL, gainlpc2, gainlpc2_e, FDNS_NPTS ); @@ -4295,7 +4312,7 @@ void decoder_tcx_invQ_fx( move16(); tmp32 = Sqrt32( tmp32, &st->last_gain_syn_deemph_e ); #ifdef BASOP_NOGLOB - st->last_gain_syn_deemph = round_fx_o( tmp32, &Overflow ); + st->last_gain_syn_deemph = round_fx_o( tmp32, &Overflow ); // Q15 #else last_gain_syn_deemph_fx = round_fx( tmp32 ); #endif @@ -4689,7 +4706,7 @@ void decoder_tcx_noisefilling_fx( } /* get the starting location of the subframe in the frame */ - if ( EQ_16( st->core, TCX_10_CORE ) ) + IF( EQ_16( st->core, TCX_10_CORE ) ) { st->hPlcInfo->subframe = extract_l( L_mult0( frame_cnt, L_frameTCX_glob ) ); move16(); @@ -4904,7 +4921,7 @@ void decoder_tcx_noisefilling_fx( } } - if ( st->igf ) + IF( st->igf ) { *st->hIGFDec->igfData.igfInfo.nfSeed = extract_l( L_add( L_mult0( nf_seed, 31821 ), 13849 ) ); move16(); diff --git a/lib_dec/decision_matrix_dec_fx.c b/lib_dec/decision_matrix_dec_fx.c index 66c7440b1..5d9beccff 100644 --- a/lib_dec/decision_matrix_dec_fx.c +++ b/lib_dec/decision_matrix_dec_fx.c @@ -20,9 +20,9 @@ #ifdef IVAS_FLOAT_FIXED void decision_matrix_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ - Word16 *sharpFlag, /* o : formant sharpening flag */ - Word16 *hq_core_type, /* o : HQ core type */ - Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag */ + Word16 *sharpFlag, /* o : formant sharpening flag Q0 */ + Word16 *hq_core_type, /* o : HQ core type Q0 */ + Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag Q0 */ ) { Word16 start_idx; @@ -60,24 +60,24 @@ void decision_matrix_dec_fx( ELSE { test(); - IF( EQ_32( st->total_brate, FRAME_NO_DATA ) || EQ_32( st->total_brate, SID_2k40 ) ) + IF( ( st->total_brate == FRAME_NO_DATA ) || EQ_32( st->total_brate, SID_2k40 ) ) { st->core = ACELP_CORE; move16(); st->core_brate = st->total_brate; move32(); - IF( NE_32( st->total_brate, FRAME_NO_DATA ) ) + IF( st->total_brate != FRAME_NO_DATA ) { - st->cng_type = get_next_indice_fx( st, 1 ); + st->cng_type = get_next_indice_fx( st, 1 ); // Q0 - IF( EQ_16( st->cng_type, LP_CNG ) ) + IF( st->cng_type == LP_CNG ) { st->L_frame = L_FRAME; move16(); - tmp16 = get_next_indice_fx( st, 1 ); - IF( EQ_16( tmp16, 1 ) ) + tmp16 = get_next_indice_fx( st, 1 ); // Q0 + if ( EQ_16( tmp16, 1 ) ) { st->L_frame = L_FRAME16k; move16(); @@ -85,14 +85,14 @@ void decision_matrix_dec_fx( } ELSE { - st->bwidth = get_next_indice_fx( st, 2 ); + st->bwidth = get_next_indice_fx( st, 2 ); // Q0 - tmp16 = get_next_indice_fx( st, 1 ); + tmp16 = get_next_indice_fx( st, 1 ); // Q0 move16(); st->L_frame = L_FRAME16k; move16(); - IF( tmp16 == 0 ) + if ( tmp16 == 0 ) { st->L_frame = L_FRAME; move16(); @@ -101,7 +101,7 @@ void decision_matrix_dec_fx( } test(); - IF( GE_32( st->output_Fs, 32000 ) && GE_16( st->bwidth, SWB ) ) + if ( GE_32( st->output_Fs, 32000 ) && GE_16( st->bwidth, SWB ) ) { st->extl = SWB_CNG; move16(); @@ -110,7 +110,7 @@ void decision_matrix_dec_fx( test(); test(); test(); - IF( EQ_32( st->total_brate, FRAME_NO_DATA ) && st->prev_bfi && !st->bfi && GT_16( st->L_frame, L_FRAME16k ) ) + if ( ( st->total_brate == FRAME_NO_DATA ) && st->prev_bfi && !st->bfi && GT_16( st->L_frame, L_FRAME16k ) ) { st->L_frame = st->last_CNG_L_frame; move16(); @@ -128,23 +128,27 @@ void decision_matrix_dec_fx( move32(); st->L_frame = L_FRAME; move16(); - st->fscale = sr2fscale_fx( INT_FS_FX ); + st->fscale = sr2fscale_fx( INT_FS_FX ); // Q0 move16(); IF( st->ini_frame == 0 ) { /* avoid switching of internal ACELP Fs in the very first frame */ st->last_L_frame = st->L_frame; + move16(); st->last_core = st->core; + move16(); st->last_core_brate = st->core_brate; + move32(); st->last_extl = st->extl; + move16(); } st->vbr_hw_BWE_disable_dec = 1; move16(); - get_next_indice_fx( st, 1 ); + get_next_indice_fx( st, 1 ); // Q0 - ppp_nelp_mode = get_next_indice_fx( st, 2 ); + ppp_nelp_mode = get_next_indice_fx( st, 2 ); // Q0 /* 0 - PPP_NB, 1 - PPP_WB, 2 - NELP_NB, 3 - NELP_WB */ IF( ppp_nelp_mode == 0 ) @@ -201,11 +205,11 @@ void decision_matrix_dec_fx( ELSE IF( GE_32( st->total_brate, ACELP_24k40 ) && LE_32( st->total_brate, ACELP_64k ) ) { /* read the ACELP/HQ core selection bit */ - temp_core = get_next_indice_fx( st, 1 ); + temp_core = get_next_indice_fx( st, 1 ); // Q0 st->core = HQ_CORE; move16(); - IF( temp_core == 0 ) + if ( temp_core == 0 ) { st->core = ACELP_CORE; move16(); @@ -217,7 +221,7 @@ void decision_matrix_dec_fx( * Read ACELP signaling bits from the bitstream *-----------------------------------------------------------------*/ - IF( EQ_16( st->core, ACELP_CORE ) ) + IF( st->core == ACELP_CORE ) { /* find the section in the ACELP signaling table corresponding to bitrate */ start_idx = 0; @@ -231,7 +235,7 @@ void decision_matrix_dec_fx( move16(); start_idx = 0; move16(); - break; + BREAK; } } @@ -242,7 +246,7 @@ void decision_matrix_dec_fx( nBits = extract_l( acelp_sig_tbl[start_idx] ); start_idx = add( start_idx, 1 ); - start_idx = add( start_idx, get_next_indice_fx( st, nBits ) ); + start_idx = add( start_idx, get_next_indice_fx( st, nBits ) ); // Q0 IF( GE_16( start_idx, MAX_ACELP_SIG ) ) { ind = 0; @@ -257,17 +261,19 @@ void decision_matrix_dec_fx( move32(); /* convert signaling indice into signaling information */ - st->coder_type = extract_l( L_and( ind, 0x7L ) ); + st->coder_type = extract_l( L_and( ind, 0x7L ) ); // Q0 IF( EQ_16( st->coder_type, LR_MDCT ) ) { st->core = HQ_CORE; move16(); - st->bwidth = extract_l( L_and( L_shr( ind, 3 ), 0x7L ) ); + st->bwidth = extract_l( L_and( L_shr( ind, 3 ), 0x7L ) ); // Q0 + move16(); } ELSE { - st->bwidth = extract_l( L_and( L_shr( ind, 3 ), 0x7L ) ); - *sharpFlag = extract_l( L_and( L_shr( ind, 6 ), 0x1L ) ); + st->bwidth = extract_l( L_and( L_shr( ind, 3 ), 0x7L ) ); // Q0 + move16(); + *sharpFlag = extract_l( L_and( L_shr( ind, 6 ), 0x1L ) ); // Q0 move16(); } } @@ -292,11 +298,11 @@ void decision_matrix_dec_fx( IF( ( st->BER_detect ) || ( GE_32( ind, 1 << 7 ) ) || ( LE_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->bwidth, FB ) ) || - ( GE_32( st->total_brate, ACELP_32k ) && EQ_16( st->bwidth, NB ) ) || - ( GE_32( st->total_brate, ACELP_32k ) && !( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, TRANSITION ) || EQ_16( st->coder_type, INACTIVE ) ) ) || - ( LT_32( st->total_brate, ACELP_13k20 ) && NE_16( st->bwidth, NB ) && EQ_16( st->coder_type, LR_MDCT ) ) || + ( GE_32( st->total_brate, ACELP_32k ) && ( st->bwidth == NB ) ) || + ( GE_32( st->total_brate, ACELP_32k ) && !( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, TRANSITION ) || ( st->coder_type == INACTIVE ) ) ) || + ( LT_32( st->total_brate, ACELP_13k20 ) && ( st->bwidth != NB ) && EQ_16( st->coder_type, LR_MDCT ) ) || ( GE_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->coder_type, UNVOICED ) ) || - ( GE_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->coder_type, AUDIO ) && EQ_16( st->bwidth, NB ) ) ) + ( GE_32( st->total_brate, ACELP_13k20 ) && EQ_16( st->coder_type, AUDIO ) && ( st->bwidth == NB ) ) ) { st->BER_detect = 0; move16(); @@ -413,7 +419,7 @@ void decision_matrix_dec_fx( test(); IF( EQ_16( st->core, ACELP_CORE ) && EQ_16( st->bwidth, WB ) && LT_32( st->total_brate, ACELP_9k60 ) ) { - IF( st->vbr_hw_BWE_disable_dec == 0 ) + if ( st->vbr_hw_BWE_disable_dec == 0 ) { st->extl = WB_BWE; move16(); @@ -422,7 +428,7 @@ void decision_matrix_dec_fx( ELSE IF( EQ_16( st->core, ACELP_CORE ) && EQ_16( st->bwidth, WB ) && GE_32( st->total_brate, ACELP_9k60 ) && LE_32( st->total_brate, ACELP_16k40 ) ) { /* read the WB TBE/BWE selection bit */ - tmp16 = get_next_indice_fx( st, 1 ); + tmp16 = get_next_indice_fx( st, 1 ); // Q0 IF( EQ_16( tmp16, 1 ) ) { st->extl = WB_BWE; @@ -444,7 +450,7 @@ void decision_matrix_dec_fx( { st->extl = SWB_BWE_HIGHRATE; move16(); - IF( EQ_16( st->bwidth, FB ) ) + if ( EQ_16( st->bwidth, FB ) ) { st->extl = FB_BWE_HIGHRATE; move16(); @@ -471,7 +477,7 @@ void decision_matrix_dec_fx( move16(); st->extl_brate = SWB_TBE_1k6; move32(); - IF( GE_32( st->total_brate, ACELP_24k40 ) ) + if ( GE_32( st->total_brate, ACELP_24k40 ) ) { st->extl_brate = SWB_TBE_2k8; move32(); @@ -504,6 +510,7 @@ void decision_matrix_dec_fx( /* set core bitrate */ st->core_brate = L_sub( st->total_brate, st->extl_brate ); + move32(); /*-----------------------------------------------------------------* * Read HQ signaling bits from the bitstream @@ -516,11 +523,11 @@ void decision_matrix_dec_fx( IF( NE_16( st->mdct_sw, MODE2 ) ) { /* skip the HQ/TCX core switching flag */ - get_next_indice_tmp_fx( st, 1 ); + get_next_indice_tmp_fx( st, 1 ); // Q0 } /* read ACELP->HQ core switching flag */ - *core_switching_flag = get_next_indice_fx( st, 1 ); + *core_switching_flag = get_next_indice_fx( st, 1 ); // Q0 IF( EQ_16( *core_switching_flag, 1 ) ) { @@ -530,8 +537,8 @@ void decision_matrix_dec_fx( /* read ACELP L_frame info */ st->last_L_frame = L_FRAME16k; move16(); - tmp16 = get_next_indice_fx( st, 1 ); - IF( tmp16 == 0 ) + tmp16 = get_next_indice_fx( st, 1 ); // Q0 + if ( tmp16 == 0 ) { st->last_L_frame = L_FRAME; move16(); @@ -544,7 +551,7 @@ void decision_matrix_dec_fx( /* read/set band-width (needed for different I/O sampling rate support) */ IF( GT_32( st->total_brate, ACELP_16k40 ) ) { - tmp16 = get_next_indice_fx( st, 2 ); + tmp16 = get_next_indice_fx( st, 2 ); // Q0 IF( tmp16 == 0 ) { @@ -574,7 +581,7 @@ void decision_matrix_dec_fx( test(); test(); test(); - IF( ( GE_32( st->total_brate, ACELP_24k40 ) && EQ_16( st->bwidth, NB ) ) || + IF( ( GE_32( st->total_brate, ACELP_24k40 ) && ( st->bwidth == NB ) ) || ( EQ_16( st->core, HQ_CORE ) && LE_32( st->total_brate, LRMDCT_CROSSOVER_POINT ) && EQ_16( st->bwidth, FB ) ) ) { st->bfi = 1; @@ -644,7 +651,7 @@ void decision_matrix_dec_fx( test(); test(); test(); - IF( EQ_32( st->core_brate, FRAME_NO_DATA ) ) + IF( st->core_brate == FRAME_NO_DATA ) { /* prevent "L_frame" changes in CNG segments */ st->L_frame = st->last_L_frame; @@ -670,14 +677,16 @@ void decision_matrix_dec_fx( st->nb_subfr = NB_SUBFR; move16(); - IF( EQ_16( st->L_frame, L_FRAME16k ) ) + if ( EQ_16( st->L_frame, L_FRAME16k ) ) { st->nb_subfr = NB_SUBFR16k; move16(); } #if 1 // def ADD_IVAS_BWE 0> NEEDED for IO with conf_acelp1 st->extl_orig = st->extl; + move16(); st->extl_brate_orig = st->extl_brate; + move32(); #endif test(); IF( EQ_32( st->output_Fs, 8000 ) ) diff --git a/lib_dec/gs_dec_amr_wb_fx.c b/lib_dec/gs_dec_amr_wb_fx.c index d57411ff4..9778acec0 100644 --- a/lib_dec/gs_dec_amr_wb_fx.c +++ b/lib_dec/gs_dec_amr_wb_fx.c @@ -49,9 +49,9 @@ static void gs_dec_amr_wb_fx( const long core_brate, Word16 *seed_tcx, const Wor *-------------------------------------------------------------------*/ static void NoiseFill_fx( - Word16 *exc_diffQ_fx, /* i/o: Noise per band */ - Word16 *seed_tcx, /* i : Seed for noise */ - const Word16 Mbands_gn, /* i : number of bands */ + Word16 *exc_diffQ_fx, /* i/o: Noise per band Q_out*/ + Word16 *seed_tcx, /* i : Seed for noise Q0*/ + const Word16 Mbands_gn, /* i : number of bands Q0*/ const Word16 Q_out /* i : Q of exc_diffQ_fx[] */ ) { @@ -60,16 +60,16 @@ static void NoiseFill_fx( Word16 fact; CurBin = 0; move16(); - fact = shr( 24576 /*0.75f*/, sub( 15, Q_out ) ); + fact = shr( 24576 /*0.75f in Q15*/, sub( 15, Q_out ) ); /* Q_out */ FOR( i_band = 0; i_band < Mbands_gn; i_band++ ) { EndBin = add( CurBin, crit_bins[i_band] ); FOR( ; CurBin < EndBin; CurBin++ ) { - L_temp = L_mult( Random( seed_tcx ), fact ); - L_temp = L_msu( L_temp, exc_diffQ_fx[CurBin], -32768 ); - exc_diffQ_fx[CurBin] = round_fx( L_temp ); + L_temp = L_mult( Random( seed_tcx ), fact ); /* Q15 + Q_out + 1 */ + L_temp = L_msu( L_temp, exc_diffQ_fx[CurBin], -32768 ); /* Q15 + Q_out + 1*/ + exc_diffQ_fx[CurBin] = round_fx( L_temp ); /* Q_out */ move16(); } } @@ -84,9 +84,9 @@ static void NoiseFill_fx( *-------------------------------------------------------------------*/ static void Ener_per_band_fx( - const Word16 exc_diff_fx[], /* i : target signal */ - const Word16 exc_diff_exp, /* i : Exponent of exc_diff_fx */ - Word32 y_gain4_fx[] /* o : Energy per band to quantize Q16 */ + const Word16 exc_diff_fx[], /* i : target signal exp(exc_diff_exp)*/ + const Word16 exc_diff_exp, /* i : Exponent of exc_diff_fx */ + Word32 y_gain4_fx[] /* o : Energy per band to quantize Q16*/ ) { const Word16 *ptr16; @@ -96,29 +96,29 @@ static void Ener_per_band_fx( exp = shl( exc_diff_exp, 1 ); /* To Get 0.01f in Q of (exc_diff_exp-1)^2 */ - L_epsilon = L_shr( 42949673L, sub( 32 + ENER_FX_Q_GUARD * 2, exp ) ); + L_epsilon = L_shr( 42949673L, sub( 32 + ENER_FX_Q_GUARD * 2, exp ) ); /* Q16 */ ptr16 = exc_diff_fx; FOR( j = 0; j < CRIT_NOIS_BAND; j++ ) { - temp = shr( *ptr16++, ENER_FX_Q_GUARD ); - L_temp = L_mac0( L_epsilon, temp, temp ); + temp = shr( *ptr16++, ENER_FX_Q_GUARD ); /* Q15 - exc_diff_exp + Q1 */ + L_temp = L_mac0( L_epsilon, temp, temp ); /* Q16 */ FOR( i = 1; i < crit_bins[j]; i++ ) { - temp = shr( *ptr16++, ENER_FX_Q_GUARD ); - L_temp = L_mac0( L_temp, temp, temp ); + temp = shr( *ptr16++, ENER_FX_Q_GUARD ); /* Q15 - exc_diff_exp + Q1 */ + L_temp = L_mac0( L_temp, temp, temp ); /* Q16 */ } L_temp2 = L_mult0( 1, 6554 ); /* sqrt of 0.01f in Q16*/ IF( L_temp != 0 ) /* avoid executing sqrt of 0 (because a div_s is used to invert and then call inv_sqrt) */ { L_temp2 = Sqrt_Ratio32( L_temp, exp, 1, 0, &i ); #ifdef BASOP_NOGLOB - L_temp2 = L_shr_sat( L_temp2, sub( 15 - ENER_FX_Q_GUARD, i ) ); + L_temp2 = L_shr_sat( L_temp2, sub( 15 - ENER_FX_Q_GUARD, i ) ); /* Q16 */ #else L_temp2 = L_shr( L_temp2, sub( 15 - ENER_FX_Q_GUARD, i ) ); #endif } - y_gain4_fx[j] = L_temp2; + y_gain4_fx[j] = L_temp2; /* Q16 */ move32(); } @@ -133,9 +133,9 @@ static void Ener_per_band_fx( *-------------------------------------------------------------------*/ static void Apply_gain_fx( - Word16 exc_diffQ_fx[], /* i/o: Quantized excitation */ - Word32 L_Ener_per_bd_iQ[], /* i : Target ener per band */ - Word32 L_Ener_per_bd_yQ[] /* i : Ener per band for norm vector */ + Word16 exc_diffQ_fx[], /* i/o: Quantized excitation Qx*/ + Word32 L_Ener_per_bd_iQ[], /* i : Target ener per band Q16*/ + Word32 L_Ener_per_bd_yQ[] /* i : Ener per band for norm vector Qx*/ , const Word16 Q_out ) { @@ -154,11 +154,11 @@ static void Apply_gain_fx( move16(); FOR( i_band = 0; i_band < CRIT_NOIS_BAND; i_band++ ) { - EndBin = add( CurBin, crit_bins[i_band] ); + EndBin = add( CurBin, crit_bins[i_band] ); /* Q0 */ y_gain_exp = norm_l( L_Ener_per_bd_yQ[i_band] ); exp3 = norm_l( L_Ener_per_bd_iQ[i_band] ); /* use 'exp3' as temporary exponent of 'L_Ener_per_bd_iQ[]' */ #ifdef BASOP_NOGLOB - y_gain_fx = round_fx_sat( Div_flt32_flt32( L_shl_sat( L_Ener_per_bd_iQ[i_band], exp3 ), exp3, L_shl_sat( L_Ener_per_bd_yQ[i_band], y_gain_exp ), y_gain_exp, &y_gain_exp ) ); + y_gain_fx = round_fx_sat( Div_flt32_flt32( L_shl_sat( L_Ener_per_bd_iQ[i_band], exp3 ), exp3, L_shl_sat( L_Ener_per_bd_yQ[i_band], y_gain_exp ), y_gain_exp, &y_gain_exp ) ); /* y_gain_exp - 31 + Q_out */ #else y_gain_fx = round_fx( Div_flt32_flt32( L_shl( L_Ener_per_bd_iQ[i_band], exp3 ), exp3, L_shl( L_Ener_per_bd_yQ[i_band], y_gain_exp ), y_gain_exp, &y_gain_exp ) ); #endif @@ -172,9 +172,9 @@ static void Apply_gain_fx( { FOR( ; CurBin < EndBin; CurBin++ ) { - L_temp = L_mult( exc_diffQ_fx[CurBin], y_gain_fx ); - L_temp = L_shr( L_temp, y_gain_exp ); - exc_diffQ_fx[CurBin] = round_fx( L_temp ); + L_temp = L_mult( exc_diffQ_fx[CurBin], y_gain_fx ); /* Q16 + Q_out + y_gain_exp */ + L_temp = L_shr( L_temp, y_gain_exp ); /* Q_out + 16 */ + exc_diffQ_fx[CurBin] = round_fx( L_temp ); /* Q_out */ move16(); } } @@ -190,29 +190,29 @@ static void Apply_gain_fx( *-------------------------------------------------------------------*/ static void normalize_spec_fx( - Word16 fac_up_fx, /* i : Core bitrate (Q8) */ - Word16 fy_norm_fx[], /* i/o: Frequency quantized parameter (Q8) */ - const Word16 L_frame, /* i : Section lenght */ - const Word16 Q_out /* i : Q of fy_norm_fx[] */ + Word16 fac_up_fx, /* i : Core bitrate (Q8)*/ + Word16 fy_norm_fx[], /* i/o: Frequency quantized parameter (Q8)*/ + const Word16 L_frame, /* i : Section lenght Q0*/ + const Word16 Q_out /* i : Q of fy_norm_fx[] */ ) { Word16 idx, j; Word32 L_temp; Word16 temp, exp; - idx = emaximum_fx( 0 /* Exponent is not Important */, fy_norm_fx, L_frame, &L_temp ); + idx = emaximum_fx( 0 /* Exponent is not Important */, fy_norm_fx, L_frame, &L_temp ); /* Q0 */ exp = sub( Q_out, 8 /*Q8 of Fac Up/down*/ ); - temp = Invert16( abs_s( fy_norm_fx[idx] ), &exp ); - L_temp = L_mult( temp, fac_up_fx ); + temp = Invert16( abs_s( fy_norm_fx[idx] ), &exp ); /* Q15 + exp */ + L_temp = L_mult( temp, fac_up_fx ); /* Q15 + exp + Q8 + 1 */ exp = sub( 15, exp ); #ifdef BASOP_NOGLOB - L_temp = L_shl_sat( L_temp, exp ); + L_temp = L_shl_sat( L_temp, exp ); /* Q24 + Q_out */ #else L_temp = L_shl( L_temp, exp ); #endif FOR( j = 0; j < L_frame; j++ ) { - fy_norm_fx[j] = round_fx( Mult_32_16( L_temp, fy_norm_fx[j] ) ); + fy_norm_fx[j] = round_fx( Mult_32_16( L_temp, fy_norm_fx[j] ) ); /* Q_out */ move16(); } @@ -226,16 +226,16 @@ static void normalize_spec_fx( *-------------------------------------------------------------------*/ static void gs_dec_amr_wb_fx( - const long core_brate, /* i : bitrate allocated to the core */ - Word16 *seed_tcx, /* i/o: seed used for noise generation */ - const Word16 dct_in_fx[], /* i : cdt of residual signal */ + const long core_brate, /* i : bitrate allocated to the core Q0*/ + Word16 *seed_tcx, /* i/o: seed used for noise generation Q0*/ + const Word16 dct_in_fx[], /* i : cdt of residual signal Q_dct_in*/ const Word16 Q_dct_in, /* i : Exponent of dct_in_fx */ - Word16 dct_out_fx[], /* o : dct of pitch only excitation */ + Word16 dct_out_fx[], /* o : dct of pitch only excitation Q_dct_out*/ Word16 Q_dct_out, /* o : Exponent of dct_out_fx */ - const Word16 pitch_fx[], /* i : pitch buffer */ - const Word16 voice_fac, /* i : gain pitch Q15 */ - const Word16 clas, /* i : signal frame class */ - const Word16 coder_type /* i : coder type */ + const Word16 pitch_fx[], /* i : pitch buffer Q6*/ + const Word16 voice_fac, /* i : gain pitch Q15*/ + const Word16 clas, /* i : signal frame class Q0*/ + const Word16 coder_type /* i : coder type Q0*/ #ifdef ADD_IVAS_GS_DEC_IMPR , const Word16 VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */ @@ -266,7 +266,7 @@ static void gs_dec_amr_wb_fx( FOR( i = 0; i < CRIT_NOIS_BAND; i++ ) { #ifdef BASOP_NOGLOB - temp = s_max( round_fx_sat( Ener_per_bd_iQ_fx[i] ), temp ); + temp = s_max( round_fx_sat( Ener_per_bd_iQ_fx[i] ), temp ); /* Q0 */ #else temp = s_max( round_fx( Ener_per_bd_iQ_fx[i] ), temp ); #endif @@ -278,7 +278,7 @@ static void gs_dec_amr_wb_fx( { FOR( i = 0; i < CRIT_NOIS_BAND; i++ ) { - Ener_per_bd_iQ_fx[i] = Mult_32_16( Ener_per_bd_iQ_fx[i], crit_bins_corr_fx[i] ); + Ener_per_bd_iQ_fx[i] = Mult_32_16( Ener_per_bd_iQ_fx[i], crit_bins_corr_fx[i] ); /* Q16 */ move32(); } } @@ -287,16 +287,16 @@ static void gs_dec_amr_wb_fx( /*--------------------------------------------------------------------------------------* * Find the lenght of the temporal contribution, with a minimum contribution of 1.2kHz *--------------------------------------------------------------------------------------*/ - temp = s_min( pitch_fx[0], pitch_fx[1] ); - temp = s_min( temp, pitch_fx[2] ); - temp = s_min( temp, pitch_fx[3] ); + temp = s_min( pitch_fx[0], pitch_fx[1] ); /* Q6 */ + temp = s_min( temp, pitch_fx[2] ); /* Q6 */ + temp = s_min( temp, pitch_fx[3] ); /* Q6 */ /* etmp14 = 12800.0f/(temp/16.0f)*8.0f */ exp = 6; /* Pitch in Q6*/ move16(); - temp = Invert16( temp, &exp ); - L_temp = L_mult( temp, 12800 ); - L_temp = L_shl( L_temp, sub( 3, exp ) ); /* *8.0f */ + temp = Invert16( temp, &exp ); /* Q15 */ + L_temp = L_mult( temp, 12800 ); /* Q15 */ + L_temp = L_shl( L_temp, sub( 3, exp ) ); /* *8.0f */ /* Q15 */ #ifdef ADD_IVAS_GS_DEC_IMPR test(); test(); @@ -305,27 +305,27 @@ static void gs_dec_amr_wb_fx( if ( GE_32( core_brate, ACELP_12k65 ) ) #endif { - L_temp = L_shl( L_temp, 1 ); + L_temp = L_shl( L_temp, 1 ); /* Q16 */ } /* (Word16)(etmp14+0.5f) */ - mDiff_len = round_fx( L_temp ); + mDiff_len = round_fx( L_temp ); /* Q0 */ temp = 32767; move16(); L_temp = L_deposit_l( 0 ); FOR( i = 0; i < CRIT_NOIS_BAND; i++ ) { - temp2 = sub( crit_bands_loc_fx[i], mDiff_len ); - temp2 = abs_s( temp2 ); + temp2 = sub( crit_bands_loc_fx[i], mDiff_len ); /* Q0 */ + temp2 = abs_s( temp2 ); /* Q0 */ if ( GT_16( temp, temp2 ) ) { - L_temp = L_msu( L_temp, crit_bins[i], -32768 ); + L_temp = L_msu( L_temp, crit_bins[i], -32768 ); /* Q16 */ } - temp = s_min( temp, temp2 ); + temp = s_min( temp, temp2 ); /* Q0 */ } - mDiff_len = s_max( round_fx( L_temp ), BIN_1k2 ); + mDiff_len = s_max( round_fx( L_temp ), BIN_1k2 ); /* Q0 */ #ifdef ADD_IVAS_GS_DEC_IMPR @@ -334,12 +334,12 @@ static void gs_dec_amr_wb_fx( Copy( dct_in_fx, exc_diffQ, L_FRAME ); /* normalization of the spectrum and noise fill */ - normalize_spec_fx( 1 * 256, exc_diffQ + mDiff_len, L_FRAME - mDiff_len, NORMALIZE_SPECS_Q_OUT ); + normalize_spec_fx( 1 * 256, exc_diffQ + mDiff_len, sub( L_FRAME, mDiff_len ), NORMALIZE_SPECS_Q_OUT ); } ELSE #endif { - Copy( dct_in_fx, exc_diffQ_fx, mDiff_len ); + Copy( dct_in_fx, exc_diffQ_fx, mDiff_len ); /* Q_dct_in */ set16_fx( exc_diffQ_fx + mDiff_len, 0, sub( L_FRAME, mDiff_len ) ); /* normalization of the spectrum and noise fill*/ @@ -356,7 +356,7 @@ static void gs_dec_amr_wb_fx( * Compute tilt factor and amplify HF accordingly *--------------------------------------------------------------------------------------*/ - temp = mult_r( sub( 32767, voice_fac ), 16384 ); /* Q15 */ + temp = mult_r( sub( 32767 /* 1.0 in Q15 */, voice_fac ), 16384 /* 0.5 in Q15 */ ); /* Q15 */ FOR( i = 240; i < L_FRAME; i++ ) { temp2 = msu_r( -7680 * 65536, -17564, shl( i, 6 ) ); /*-15 in Q9; -0.067 in Q18 and i in Q6= Q9 */ @@ -374,7 +374,7 @@ static void gs_dec_amr_wb_fx( * Copy to the output vector *--------------------------------------------------------------------------------------*/ - Copy( exc_diffQ_fx, dct_out_fx, L_FRAME ); + Copy( exc_diffQ_fx, dct_out_fx, L_FRAME ); /* Q_dct_out */ return; } @@ -386,24 +386,24 @@ static void gs_dec_amr_wb_fx( * unvoiced and audio signals (used only in AMR-WB IO mode) *-------------------------------------------------------------------*/ void improv_amr_wb_gs_fx( - const Word16 clas, /* i : signal frame class */ - const Word16 coder_type, /* i : coder type */ - const Word32 core_brate, /* i : bitrate allocated to the core */ - Word16 *seed_tcx, /* i/o: Seed used for noise generation */ - Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient */ - Word16 *mem_syn2_fx, /* i/o: synthesis memory */ - const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14 */ - const Word16 locattack, /* i : Flag for a detected attack */ - Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient */ - Word16 *exc2_fx, /* i/o: Decoded complete excitation */ - const Word16 Q_exc2, /* i : Exponent of Exc2 */ - Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory */ - Word16 *syn_fx, /* o: Decoded synthesis to be updated */ - const Word16 Q_syn, /* i : Synthesis scaling Q0 */ - const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6 */ - const Word16 Last_ener_fx, /* i : Last energy (Q8) */ - const Word16 rate_switching_reset, /* i : rate switching reset flag */ - const Word16 last_coder_type /* i : Last coder_type */ + const Word16 clas, /* i : signal frame class Q0*/ + const Word16 coder_type, /* i : coder type Q0*/ + const Word32 core_brate, /* i : bitrate allocated to the core Q0*/ + Word16 *seed_tcx, /* i/o: Seed used for noise generation Q0*/ + Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient q_old_Aq*/ + Word16 *mem_syn2_fx, /* i/o: synthesis memory Q_syn*/ + const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q14*/ + const Word16 locattack, /* i : Flag for a detected attack Q0*/ + Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient q_Aq*/ + Word16 *exc2_fx, /* i/o: Decoded complete excitation Q_exc2*/ + const Word16 Q_exc2, /* i : Exponent of Exc2 */ + Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory Q_syn*/ + Word16 *syn_fx, /* o: Decoded synthesis to be updated Q_syn*/ + const Word16 Q_syn, /* i : Synthesis scaling */ + const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer Q6*/ + const Word16 Last_ener_fx, /* i : Last energy (Q8) Q0*/ + const Word16 rate_switching_reset, /* i : rate switching reset flag Q0*/ + const Word16 last_coder_type /* i : Last coder_type Q0*/ #ifdef ADD_IVAS_GS_DEC_IMPR , const Word16 VeryLowRateSTflag /* i : Enable the noise enhancement for very low rate stereo generic mode */ @@ -449,7 +449,7 @@ void improv_amr_wb_gs_fx( * generic audio sound * LP filter smoothing for inactive parts *------------------------------------------------------------*/ - *seed_tcx = extract_l( L_mult0( pitch_buf_fx[0], pitch_buf_fx[3] ) ); + *seed_tcx = extract_l( L_mult0( pitch_buf_fx[0], pitch_buf_fx[3] ) ); /* Q0 */ move16(); /* last_coder_type == UNVOICED should be understand as INACTIVE, but it is forced to UNVOICED in update_dec */ test(); @@ -460,36 +460,36 @@ void improv_amr_wb_gs_fx( FOR( i = 0; i < NB_SUBFR; i++ ) { - Copy( Aq_fx, Aq_orig, NB_SUBFR * ( M + 1 ) ); + Copy( Aq_fx, Aq_orig, NB_SUBFR * ( M + 1 ) ); /* q_Aq */ - exp_a = norm_s( Aq_fx[imult1616( i, ( M + 1 ) )] ); - exp_b = norm_s( old_Aq_fx[imult1616( i, ( M + 1 ) )] ); + exp_a = norm_s( Aq_fx[i * ( M + 1 )] ); + exp_b = norm_s( old_Aq_fx[i * ( M + 1 )] ); exp_diff = sub( exp_a, exp_b ); IF( exp_diff > 0 ) { - Scale_sig( &old_Aq_fx[imult1616( i, ( M + 1 ) )], ( M + 1 ), negate( exp_diff ) ); + Scale_sig( &old_Aq_fx[i * ( M + 1 )], ( M + 1 ), negate( exp_diff ) ); /* exp_b */ } ELSE { - Scale_sig( &Aq_fx[imult1616( i, ( M + 1 ) )], ( M + 1 ), exp_diff ); + Scale_sig( &Aq_fx[i * ( M + 1 )], ( M + 1 ), exp_diff ); /* exp_a */ } - FOR( j = imult1616( i, ( M + 1 ) ); j < imult1616( add( i, 1 ), ( M + 1 ) ); j++ ) + FOR( j = i * ( M + 1 ); j < ( i + 1 ) * ( M + 1 ); j++ ) { - Aq_fx[j] = round_fx( L_mac( L_mult( ALP_FX, old_Aq_fx[j] ), MALP_FX, Aq_fx[j] ) ); + Aq_fx[j] = round_fx( L_mac( L_mult( ALP_FX, old_Aq_fx[j] ), MALP_FX, Aq_fx[j] ) ); /* q_Aq */ move16(); } } /* check the smoothed LP filter stability */ - enr_LP_old = Enr_1_Az_fx( old_Aq_fx, L_SUBFR ); + enr_LP_old = Enr_1_Az_fx( old_Aq_fx, L_SUBFR ); /* Q3 */ Overflow = 0; move16(); FOR( i = 0; i < NB_SUBFR; i++ ) { #ifdef BASOP_NOGLOB - enr_LP_new = Enr_1_Az_fx_o( Aq_fx + imult1616( i, ( M + 1 ) ), L_SUBFR, &Overflow ); + enr_LP_new = Enr_1_Az_fx_o( Aq_fx + imult1616( i, ( M + 1 ) ), L_SUBFR, &Overflow ); /* Q3 */ #else enr_LP_new = Enr_1_Az_fx( Aq_fx + i * ( M + 1 ), L_SUBFR ); #endif @@ -497,14 +497,14 @@ void improv_amr_wb_gs_fx( IF( GT_16( shr( enr_LP_new, 7 ), enr_LP_old ) || Overflow ) { /* filter is unstable, do not modify the excitation */ - Copy( Aq_orig, Aq_fx, NB_SUBFR * ( M + 1 ) ); + Copy( Aq_orig, Aq_fx, NB_SUBFR * ( M + 1 ) ); /* q_Aq */ Overflow = 0; move16(); return; } - enr_LP_old = enr_LP_new; + enr_LP_old = enr_LP_new; /* Q3 */ move16(); } } @@ -527,7 +527,7 @@ void improv_amr_wb_gs_fx( * Redo core synthesis at 12k8 Hz with the modified excitation *------------------------------------------------------------*/ - Copy( mem_tmp_fx, mem_syn2_fx, M ); + Copy( mem_tmp_fx, mem_syn2_fx, M ); /* Q_syn */ syn_12k8_fx( L_FRAME, Aq_fx, exc2_fx, syn_fx, mem_syn2_fx, 1, Q_exc2, Q_syn ); } diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 9a10f0862..7af4b5c40 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -34,14 +34,14 @@ /*==========================================================================*/ void decod_audio_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain */ - const Word16 *Aq, /* i : LP filter coefficient */ - Word16 *pitch_buf, /* o : floating pitch values for each subframe */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *exc, /* i/o: adapt. excitation exc */ - Word16 *exc2, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ - Word16 *lsf_new /* i : ISFs at the end of the frame */ + Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ + const Word16 *Aq, /* i : LP filter coefficient Q12*/ + Word16 *pitch_buf, /* o : floating pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ + Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ + Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/ , Word16 *gain_buf /*Q14*/ ) @@ -71,7 +71,7 @@ void decod_audio_fx( move16(); /* decode GSC attack flag (used to reduce possible pre-echo) */ - gsc_attack_flag = (Word16) get_next_indice_fx( st_fx, 1 ); + gsc_attack_flag = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */ move16(); /* decode GSC SWB speech flag */ @@ -83,7 +83,7 @@ void decod_audio_fx( ( st_fx->element_mode > EVS_MONO && st_fx->total_brate > MIN_BRATE_GSC_NOISY_FLAG && st_fx->bwidth >= SWB && !st_fx->flag_ACELP16k ) ) ) ) #endif { - st_fx->GSC_noisy_speech = (Word16) get_next_indice_fx( st_fx, 1 ); + st_fx->GSC_noisy_speech = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */ move16(); } @@ -92,9 +92,9 @@ void decod_audio_fx( test(); IF( st_fx->GSC_noisy_speech && LT_16( st_fx->bwidth, SWB ) && st_fx->GSC_IVAS_mode == 0 ) { - st_fx->BER_detect = 1; + st_fx->BER_detect = 1; /* Q0 */ move16(); - st_fx->GSC_noisy_speech = 0; + st_fx->GSC_noisy_speech = 0; /* Q0 */ move16(); } /* set bit-allocation */ @@ -114,11 +114,11 @@ void decod_audio_fx( IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) ) #endif { - nb_subfr = NB_SUBFR; + nb_subfr = NB_SUBFR; /* Q0 */ move16(); hGSCDec->cor_strong_limit = 0; move16(); - hGSCDec->noise_lev = NOISE_LEVEL_SP3; + hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */ move16(); #ifdef ADD_LRTD if ( st_fx->GSC_IVAS_mode >= 1 ) @@ -144,12 +144,12 @@ void decod_audio_fx( { IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) { - hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 2 ), NOISE_LEVEL_SP2 ); + hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 2 ), NOISE_LEVEL_SP2 ); /* Q0 */ move16(); } ELSE { - hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 3 ), NOISE_LEVEL_SP0 ); + hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 3 ), NOISE_LEVEL_SP0 ); /* Q0 */ move16(); } @@ -165,7 +165,7 @@ void decod_audio_fx( else #endif { - hGSCDec->cor_strong_limit = 1; + hGSCDec->cor_strong_limit = 1; /* Q0 */ move16(); nb_subfr = SWNB_SUBFR; move16(); @@ -180,12 +180,12 @@ void decod_audio_fx( nbits = 2; } #endif - nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); + nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */ move16(); IF( s_and( nb_frame_flg, 0x1 ) == 0 ) { - nb_subfr = 2 * SWNB_SUBFR; + nb_subfr = 2 * SWNB_SUBFR; /* Q0 */ move16(); hGSCDec->cor_strong_limit = 0; move16(); @@ -216,29 +216,29 @@ void decod_audio_fx( IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) ) { - nbits = 3; + nbits = 3; /* Q0 */ move16(); test(); if ( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type == INACTIVE ) { - nbits = 1; + nbits = 1; /* Q0 */ move16(); } } ELSE { - nbits = 4; + nbits = 4; /* Q0 */ move16(); } test(); IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type != INACTIVE ) { - pit_band_idx = 1; + pit_band_idx = 1; /* Q0 */ move16(); } ELSE { - pit_band_idx = (Word16) get_next_indice_fx( st_fx, nbits ); + pit_band_idx = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */ move16(); } @@ -246,26 +246,26 @@ void decod_audio_fx( { IF( LT_32( st_fx->core_brate, ACELP_9k60 ) ) { - pit_band_idx = 7 + BAND1k2; - move16(); /* At low rate, if pitch model is chosen, then for to be use on extented and constant frequency range */ + pit_band_idx = 7 + BAND1k2; /* Q0 */ + move16(); /* At low rate, if pitch model is chosen, then for to be use on extented and constant frequency range */ } ELSE { - pit_band_idx = add( pit_band_idx, BAND1k2 ); + pit_band_idx = add( pit_band_idx, BAND1k2 ); /* Q0 */ } /* detect bit errors in the bitstream */ IF( GT_16( pit_band_idx, 13 ) ) /* The maximum decodable index is 10 + BAND1k2 (3) = 13 */ { - pit_band_idx = 13; + pit_band_idx = 13; /* Q0 */ move16(); - st_fx->BER_detect = 1; + st_fx->BER_detect = 1; /* Q0 */ move16(); } - Diff_len = mfreq_loc_div_25[pit_band_idx]; + Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */ move16(); } - hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; + hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */ move16(); @@ -288,7 +288,7 @@ void decod_audio_fx( #endif { Word16 indice; - nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; + nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; /* Q0 */ move16(); if ( st_fx->element_mode > EVS_MONO ) { @@ -296,7 +296,7 @@ void decod_audio_fx( move16(); } - indice = get_next_indice_fx( st_fx, nbits ); + indice = get_next_indice_fx( st_fx, nbits ); /* Q0 */ Es_pred_dec_fx( &Es_pred, indice, nbits, 0 ); } @@ -312,28 +312,28 @@ void decod_audio_fx( IF( LT_16( low_pit, 64 ) ) { - pit_band_idx = 9 + BAND1k2; + pit_band_idx = 9 + BAND1k2; /* Q0 */ move16(); if ( st_fx->bwidth == NB ) { - pit_band_idx = 7 + BAND1k2; + pit_band_idx = 7 + BAND1k2; /* Q0 */ move16(); } } ELSE IF( LT_16( low_pit, 128 ) ) { - pit_band_idx = 5 + BAND1k2; + pit_band_idx = 5 + BAND1k2; /* Q0 */ move16(); } ELSE { - pit_band_idx = 3 + BAND1k2; + pit_band_idx = 3 + BAND1k2; /* Q0 */ move16(); } - Diff_len = mfreq_loc_div_25[pit_band_idx]; + Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */ move16(); - hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; + hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */ move16(); } @@ -346,18 +346,18 @@ void decod_audio_fx( * Reset unvaluable part of the adaptive (pitch) excitation contribution *---------------------------------------------------------------*/ - max_len = sub( st_fx->L_frame, Diff_len ); + max_len = sub( st_fx->L_frame, Diff_len ); /* Q0 */ if ( st_fx->bwidth == NB ) { - max_len = sub( 160, Diff_len ); + max_len = sub( 160, Diff_len ); /* Q0 */ } Len = 80; move16(); if ( LT_16( max_len, 80 ) ) { - Len = max_len; + Len = max_len; /* Q0 */ move16(); } @@ -366,7 +366,7 @@ void decod_audio_fx( { FOR( i = 0; i < max_len; i++ ) { - dct_epit[add( i, Diff_len )] = 0; + dct_epit[i + Diff_len] = 0; move16(); } } @@ -374,47 +374,47 @@ void decod_audio_fx( { FOR( i = 0; i < Len; i++ ) { - dct_epit[add( i, Diff_len )] = mult_r( dct_epit[add( i, Diff_len )], sm_table_fx[i] ); + dct_epit[i + Diff_len] = mult_r( dct_epit[i + Diff_len], sm_table_fx[i] ); /* Qx */ move16(); } FOR( ; i < max_len; i++ ) { - dct_epit[add( i, Diff_len )] = 0; + dct_epit[i + Diff_len] = 0; move16(); } } // PMT("in the rare case of 4 subfr, bfi_pitch_fx might be wrong") - st_fx->bfi_pitch_fx = mean_fx( pitch_buf, nb_subfr ); + st_fx->bfi_pitch_fx = mean_fx( pitch_buf, nb_subfr ); /* Q6 */ move16(); - st_fx->bfi_pitch_frame = st_fx->L_frame; + st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */ move16(); - Diff_len = add( Diff_len, 1 ); + Diff_len = add( Diff_len, 1 ); /* Q0 */ st_fx->bpf_off = 0; move16(); } ELSE { /* No adaptive (pitch) excitation contribution */ - st_fx->bpf_off = 1; + st_fx->bpf_off = 1; /* Q0 */ move16(); set16_fx( dct_epit, 0, st_fx->L_frame ); IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { - set16_fx( pitch_buf, shl( L_SUBFR16k, 6 ), NB_SUBFR16k ); + set16_fx( pitch_buf, L_SUBFR16k * 64, NB_SUBFR16k ); } ELSE { - set16_fx( pitch_buf, shl( L_SUBFR, 6 ), NB_SUBFR ); + set16_fx( pitch_buf, L_SUBFR * 64, NB_SUBFR ); } set16_fx( gain_buf, 0, NB_SUBFR16k ); - st_fx->bfi_pitch_fx = shl( L_SUBFR, 6 ); + st_fx->bfi_pitch_fx = L_SUBFR * 64; move16(); - st_fx->bfi_pitch_frame = st_fx->L_frame; + st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */ move16(); st_fx->lp_gainp_fx = 0; move16(); @@ -434,7 +434,7 @@ void decod_audio_fx( /* find the current total number of bits used */ - tmp_nb_bits_tot = st_fx->next_bit_pos; + tmp_nb_bits_tot = st_fx->next_bit_pos; /* Q0 */ move16(); #ifdef IVAS_CODE if ( st_fx->extl_brate_fx_orig > 0 ) @@ -443,7 +443,7 @@ void decod_audio_fx( #endif { /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */ - tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); + tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */ } @@ -456,7 +456,7 @@ void decod_audio_fx( if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) ) #endif { - tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); + tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); /* Q0 */ } #ifdef ADD_LRTD @@ -502,8 +502,8 @@ void decod_audio_fx( * Updates *--------------------------------------------------------------------------------------*/ - Copy( exc, exc2, st_fx->L_frame ); - Copy( exc_wo_nf, exc, st_fx->L_frame ); + Copy( exc, exc2, st_fx->L_frame ); /* Q_exc */ + Copy( exc_wo_nf, exc, st_fx->L_frame ); /* Q_exc */ /*--------------------------------------------------------------------------------------* * Channel aware mode parameters @@ -537,21 +537,21 @@ void decod_audio_fx( /* _ None */ /*==========================================================================*/ void decod_audio_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain */ - const Word16 *Aq, /* i : LP filter coefficient */ - Word16 *pitch_buf, /* o : Word16 pitch values for each subframe */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 *exc, /* i/o: adapt. excitation exc */ - Word16 *exc2, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc, /* o : excitation for SWB TBE */ - Word16 *lsf_new /* i : ISFs at the end of the frame */ + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ + const Word16 *Aq, /* i : LP filter coefficient Q12*/ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ + Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ + Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/ , Word16 *gain_buf, /*Q14*/ - const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ + const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ ) { Word16 tmp_nb_bits_tot, pit_band_idx; @@ -579,7 +579,7 @@ void decod_audio_ivas_fx( move16(); /* decode GSC attack flag (used to reduce possible pre-echo) */ - gsc_attack_flag = (Word16) get_next_indice_fx( st_fx, 1 ); + gsc_attack_flag = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */ move16(); /* decode GSC SWB speech flag */ @@ -597,7 +597,7 @@ void decod_audio_ivas_fx( ( st_fx->element_mode > EVS_MONO && GT_32( st_fx->total_brate, MIN_BRATE_GSC_NOISY_FLAG ) && GE_16( st_fx->bwidth, SWB ) && !st_fx->flag_ACELP16k ) ) ) ) #endif { - st_fx->GSC_noisy_speech = (Word16) get_next_indice_fx( st_fx, 1 ); + st_fx->GSC_noisy_speech = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */ move16(); } @@ -606,7 +606,7 @@ void decod_audio_ivas_fx( test(); IF( st_fx->GSC_noisy_speech && LT_16( st_fx->bwidth, SWB ) && st_fx->GSC_IVAS_mode == 0 ) { - st_fx->BER_detect = 1; + st_fx->BER_detect = 1; /* Q0 */ move16(); st_fx->GSC_noisy_speech = 0; move16(); @@ -628,11 +628,11 @@ void decod_audio_ivas_fx( IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) ) #endif { - nb_subfr = NB_SUBFR; + nb_subfr = NB_SUBFR; /* Q0 */ move16(); hGSCDec->cor_strong_limit = 0; move16(); - hGSCDec->noise_lev = NOISE_LEVEL_SP3; + hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */ move16(); #if 1 // def ADD_LRTD IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) ) @@ -640,20 +640,20 @@ void decod_audio_ivas_fx( test(); if ( LT_32( st_fx->core_brate, GSC_L_RATE_STG ) && LT_32( st_fx->GSC_IVAS_mode, 3 ) ) { - nb_subfr = 2; + nb_subfr = 2; /* Q0 */ move16(); } - hGSCDec->noise_lev = NOISE_LEVEL_SP2; + hGSCDec->noise_lev = NOISE_LEVEL_SP2; /* Q0 */ move16(); IF( EQ_16( st_fx->GSC_IVAS_mode, 3 ) ) /* Music like */ { - hGSCDec->noise_lev = NOISE_LEVEL_SP0; + hGSCDec->noise_lev = NOISE_LEVEL_SP0; /* Q0 */ move16(); } ELSE IF( st_fx->GSC_noisy_speech == 0 ) /* speech like but not noisy */ { - hGSCDec->noise_lev = NOISE_LEVEL_SP3; + hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */ move16(); } } @@ -663,12 +663,12 @@ void decod_audio_ivas_fx( { IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) { - hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 2 ), NOISE_LEVEL_SP2 ); + hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 2 ), NOISE_LEVEL_SP2 ); /* Q0 */ move16(); } ELSE { - hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 3 ), NOISE_LEVEL_SP0 ); + hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 3 ), NOISE_LEVEL_SP0 ); /* Q0 */ move16(); } @@ -682,30 +682,30 @@ void decod_audio_ivas_fx( { hGSCDec->cor_strong_limit = 0; move16(); - nb_subfr = 1; + nb_subfr = 1; /* Q0 */ move16(); } ELSE #endif { - hGSCDec->cor_strong_limit = 1; + hGSCDec->cor_strong_limit = 1; /* Q0 */ move16(); - nb_subfr = SWNB_SUBFR; + nb_subfr = SWNB_SUBFR; /* Q0 */ move16(); IF( GE_32( st_fx->core_brate, ACELP_9k60 ) ) { - nbits = 1; + nbits = 1; /* Q0 */ move16(); #if 1 // def ADD_LRTD test(); if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) ) { - nbits = 2; + nbits = 2; /* Q0 */ move16(); } #endif - nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); + nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */ move16(); test(); @@ -725,7 +725,7 @@ void decod_audio_ivas_fx( if ( EQ_16( shr( nb_frame_flg, 1 ), 1 ) ) { - nb_subfr = shl( nb_subfr, 1 ); + nb_subfr = shl( nb_subfr, 1 ); /* Q0 */ } #endif } @@ -735,7 +735,7 @@ void decod_audio_ivas_fx( test(); if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( nb_subfr, NB_SUBFR ) ) { - nb_subfr = NB_SUBFR16k; + nb_subfr = NB_SUBFR16k; /* Q0 */ move16(); } #endif @@ -745,29 +745,29 @@ void decod_audio_ivas_fx( IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) ) { - nbits = 3; + nbits = 3; /* Q0 */ move16(); test(); if ( LT_32( st_fx->core_brate, ACELP_9k60 ) && ( st_fx->coder_type == INACTIVE ) ) { - nbits = 1; + nbits = 1; /* Q0 */ move16(); } } ELSE { - nbits = 4; + nbits = 4; /* Q0 */ move16(); } test(); IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type != INACTIVE ) { - pit_band_idx = 1; + pit_band_idx = 1; /* Q0 */ move16(); } ELSE { - pit_band_idx = (Word16) get_next_indice_fx( st_fx, nbits ); + pit_band_idx = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */ move16(); } @@ -775,26 +775,26 @@ void decod_audio_ivas_fx( { IF( LT_32( st_fx->core_brate, ACELP_9k60 ) ) { - pit_band_idx = 7 + BAND1k2; - move16(); /* At low rate, if pitch model is chosen, then for to be use on extented and constant frequency range */ + pit_band_idx = 7 + BAND1k2; /* Q0 */ + move16(); /* At low rate, if pitch model is chosen, then for to be use on extented and constant frequency range */ } ELSE { - pit_band_idx = add( pit_band_idx, BAND1k2 ); + pit_band_idx = add( pit_band_idx, BAND1k2 ); /* Q0 */ } /* detect bit errors in the bitstream */ IF( GT_16( pit_band_idx, 13 ) ) /* The maximum decodable index is 10 + BAND1k2 (3) = 13 */ { - pit_band_idx = 13; + pit_band_idx = 13; /* Q0 */ move16(); - st_fx->BER_detect = 1; + st_fx->BER_detect = 1; /* Q0 */ move16(); } - Diff_len = mfreq_loc_div_25[pit_band_idx]; + Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */ move16(); } - hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; + hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */ move16(); @@ -824,15 +824,15 @@ void decod_audio_ivas_fx( #endif { Word16 indice; - nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; + nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; /* Q0 */ move16(); if ( st_fx->element_mode > EVS_MONO ) { - nbits = 5; + nbits = 5; /* Q0 */ move16(); } - indice = get_next_indice_fx( st_fx, nbits ); + indice = get_next_indice_fx( st_fx, nbits ); /* Q0 */ Es_pred_dec_fx( &Es_pred, indice, nbits, 0 ); } @@ -848,28 +848,28 @@ void decod_audio_ivas_fx( IF( LT_16( low_pit, 64 ) ) { - pit_band_idx = 9 + BAND1k2; + pit_band_idx = 9 + BAND1k2; /* Q0 */ move16(); if ( st_fx->bwidth == NB ) { - pit_band_idx = 7 + BAND1k2; + pit_band_idx = 7 + BAND1k2; /* Q0 */ move16(); } } ELSE IF( LT_16( low_pit, 128 ) ) { - pit_band_idx = 5 + BAND1k2; + pit_band_idx = 5 + BAND1k2; /* Q0 */ move16(); } ELSE { - pit_band_idx = 3 + BAND1k2; + pit_band_idx = 3 + BAND1k2; /* Q0 */ move16(); } - Diff_len = mfreq_loc_div_25[pit_band_idx]; + Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */ move16(); - hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; + hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */ move16(); } @@ -882,18 +882,18 @@ void decod_audio_ivas_fx( * Reset unvaluable part of the adaptive (pitch) excitation contribution *---------------------------------------------------------------*/ - max_len = sub( st_fx->L_frame, Diff_len ); + max_len = sub( st_fx->L_frame, Diff_len ); /* Q0 */ if ( st_fx->bwidth == NB ) { - max_len = sub( 160, Diff_len ); + max_len = sub( 160, Diff_len ); /* Q0 */ } Len = 80; move16(); if ( LT_16( max_len, 80 ) ) { - Len = max_len; + Len = max_len; /* Q0 */ move16(); } @@ -902,7 +902,7 @@ void decod_audio_ivas_fx( { FOR( i = 0; i < max_len; i++ ) { - dct_epit[add( i, Diff_len )] = 0; + dct_epit[i + Diff_len] = 0; move16(); } } @@ -910,23 +910,23 @@ void decod_audio_ivas_fx( { FOR( i = 0; i < Len; i++ ) { - dct_epit[add( i, Diff_len )] = mult_r( dct_epit[add( i, Diff_len )], sm_table_fx[i] ); + dct_epit[i + Diff_len] = mult_r( dct_epit[i + Diff_len], sm_table_fx[i] ); /* Qx */ move16(); } FOR( ; i < max_len; i++ ) { - dct_epit[add( i, Diff_len )] = 0; + dct_epit[i + Diff_len] = 0; move16(); } } // PMT("in the rare case of 4 subfr, bfi_pitch_fx might be wrong") - st_fx->bfi_pitch_fx = mean_fx( pitch_buf, nb_subfr ); + st_fx->bfi_pitch_fx = mean_fx( pitch_buf, nb_subfr ); /* Q6 */ move16(); - st_fx->bfi_pitch_frame = st_fx->L_frame; + st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */ move16(); - Diff_len = add( Diff_len, 1 ); + Diff_len = add( Diff_len, 1 ); /* Q0 */ st_fx->bpf_off = 0; move16(); } @@ -939,18 +939,18 @@ void decod_audio_ivas_fx( IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { - set16_fx( pitch_buf, shl( L_SUBFR16k, 6 ), NB_SUBFR16k ); + set16_fx( pitch_buf, ( L_SUBFR16k * 64 ), NB_SUBFR16k ); } ELSE { - set16_fx( pitch_buf, shl( L_SUBFR, 6 ), NB_SUBFR ); + set16_fx( pitch_buf, L_SUBFR * 64, NB_SUBFR ); } set16_fx( gain_buf, 0, NB_SUBFR16k ); - st_fx->bfi_pitch_fx = shl( L_SUBFR, 6 ); + st_fx->bfi_pitch_fx = L_SUBFR * 64; move16(); - st_fx->bfi_pitch_frame = st_fx->L_frame; + st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */ move16(); st_fx->lp_gainp_fx = 0; move16(); @@ -970,7 +970,7 @@ void decod_audio_ivas_fx( /* find the current total number of bits used */ - tmp_nb_bits_tot = st_fx->next_bit_pos; + tmp_nb_bits_tot = st_fx->next_bit_pos; /* Q0 */ move16(); #if 1 // def IVAS_CODE if ( st_fx->extl_brate_orig > 0 ) @@ -979,7 +979,7 @@ void decod_audio_ivas_fx( #endif { /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */ - tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); + tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */ } @@ -991,16 +991,16 @@ void decod_audio_ivas_fx( if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) ) #endif { - tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); + tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); /* Q0 */ } #if 1 // ydef ADD_LRTD IF( EQ_16( st_fx->idchan, 1 ) ) { - tmp_nb_bits_tot = add( tmp_nb_bits_tot, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ); + tmp_nb_bits_tot = add( tmp_nb_bits_tot, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ); /* Q0 */ if ( EQ_16( st_fx->tdm_LRTD_flag, 1 ) ) { - tmp_nb_bits_tot = sub( tmp_nb_bits_tot, STEREO_BITS_TCA ); + tmp_nb_bits_tot = sub( tmp_nb_bits_tot, STEREO_BITS_TCA ); /* Q0 */ } } #endif @@ -1012,11 +1012,11 @@ void decod_audio_ivas_fx( Q_exc_old = sub( Q_exc_old, st_fx->Q_exc ); IF( st_fx->hGSCDec ) { - Scale_sig( st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME16k, Q_exc_old ); + Scale_sig( st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME16k, Q_exc_old ); /* Q_exc_old */ } IF( bwe_exc ) { - Scale_sig( bwe_exc - PIT16k_MAX * 2, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2, Q_exc_old ); + Scale_sig( bwe_exc - PIT16k_MAX * 2, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2, Q_exc_old ); /* Q_exc_old */ } } /*--------------------------------------------------------------------------------------* @@ -1051,8 +1051,8 @@ void decod_audio_ivas_fx( * Updates *--------------------------------------------------------------------------------------*/ - Copy( exc, exc2, st_fx->L_frame ); - Copy( exc_wo_nf, exc, st_fx->L_frame ); + Copy( exc, exc2, st_fx->L_frame ); /* Q_exc */ + Copy( exc_wo_nf, exc, st_fx->L_frame ); /* Q_exc */ /*--------------------------------------------------------------------------------------* * Channel aware mode parameters @@ -1088,15 +1088,15 @@ void decod_audio_ivas_fx( /*==========================================================================*/ void gsc_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ - Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation */ - const Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - const Word16 nb_subfr, /* i : Number of subframe considered */ - const Word16 coder_type, /* i : coding type */ - Word16 *last_bin, /* i : last bin of bit allocation */ - const Word16 *lsf_new, /* i : ISFs at the end of the frame */ - Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill */ + Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ + const Word16 pit_band_idx, /* i : bin position of the cut-off frequency Q0*/ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + Word16 *last_bin, /* i : last bin of bit allocation Q0*/ + const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 Q_exc ) { Word16 i, j, bit, nb_subbands, pvq_len; @@ -1127,6 +1127,8 @@ void gsc_dec_fx( Word16 seed_init; GSC_DEC_HANDLE hGSCDec; hGSCDec = st_fx->hGSCDec; + move16(); + move16(); move16(); // for Mbands_gn move16(); // for Qexc_diffQ @@ -1164,8 +1166,8 @@ void gsc_dec_fx( IF( st_fx->bfi || st_fx->BER_detect ) { /* copy old gain */ - Copy( hGSCDec->old_y_gain_fx, Ener_per_bd_iQ, Mbands_gn ); - mean_gain = mult_r( st_fx->lp_gainc_fx, 3277 ); /*Q3*/ + Copy( hGSCDec->old_y_gain_fx, Ener_per_bd_iQ, Mbands_gn ); /* Q_old_gain */ + mean_gain = mult_r( st_fx->lp_gainc_fx, 3277 ); /*Q3*/ FOR( i = 0; i < Mbands_gn; i++ ) { Ener_per_bd_iQ[i] = add( Ener_per_bd_iQ[i], shl( mean_gain, 9 ) ); /*Q12*/ @@ -1202,7 +1204,7 @@ void gsc_dec_fx( mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); #else - mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); + mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q12 */ #endif st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ move16(); @@ -1239,13 +1241,13 @@ void gsc_dec_fx( FOR( i = 0; i < st_fx->L_frame; i++ ) { L_tmp = L_shr( L_mult( Random( &hGSCDec->seed_tcx ), 26214 ), 5 ); /*Q10*/ - L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); - hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp ); /*Q10*/ + L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); /* Q10 */ + hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp ); /*Q10*/ move16(); } } - Copy( hGSCDec->Last_GSC_spectrum_fx, exc_diffQ, st_fx->L_frame ); + Copy( hGSCDec->Last_GSC_spectrum_fx, exc_diffQ, st_fx->L_frame ); /* Q10 */ FOR( i = 0; i < st_fx->L_frame; i++ ) { @@ -1271,7 +1273,7 @@ void gsc_dec_fx( #endif { pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); - Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); + Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ } seed_init = 0; move16(); @@ -1290,34 +1292,34 @@ void gsc_dec_fx( /* Reorder Q bands */ FOR( j = 0; j < nb_subbands; j++ ) { - Copy( concat_out + j * 16, exc_diffQ + max_ener_band[j] * 16, 16 ); + Copy( concat_out + shl( j, 4 ), exc_diffQ + shl( max_ener_band[j], 4 ), 16 ); /* Q_PVQ_OUT */ - *last_bin = s_max( *last_bin, max_ener_band[j] ); + *last_bin = s_max( *last_bin, max_ener_band[j] ); /* Q0 */ move16(); - bitallocation_band[max_ener_band[j]] = 1; + bitallocation_band[max_ener_band[j]] = 1; /* Q0 */ move16(); - seed_init = add( seed_init, inpulses_fx[j] ); + seed_init = add( seed_init, inpulses_fx[j] ); /* Q0 */ } test(); IF( NE_16( st_fx->last_coder_type, AUDIO ) /* First audio frame */ && NE_16( st_fx->last_coder_type, UNVOICED ) ) /* last_coder_type == INACTIVE is overwritten in update_dec to UNVOICED */ { - FOR( j = 0; j < shl( nb_subbands, 4 ); j++ ) + FOR( j = 0; j < nb_subbands * 16; j++ ) { IF( concat_out[j] > 0 ) { - seed_init = extract_l( L_shl( seed_init, 3 ) ); + seed_init = extract_l( L_shl( seed_init, 3 ) ); /* Q0 */ } if ( concat_out[j] < 0 ) { - seed_init = add( seed_init, 3 ); + seed_init = add( seed_init, 3 ); /* Q0 */ move16(); } } - hGSCDec->seed_tcx = seed_init; + hGSCDec->seed_tcx = seed_init; /* Q0 */ move16(); } test(); @@ -1325,18 +1327,18 @@ void gsc_dec_fx( { if ( exc_diffQ[L_FRAME8k - 2] != 0 ) { - bitallocation_exc[0] = 1; + bitallocation_exc[0] = 1; /* Q0 */ move16(); } if ( exc_diffQ[L_FRAME8k - 1] != 0 ) { - bitallocation_exc[1] = 1; + bitallocation_exc[1] = 1; /* Q0 */ move16(); } } - Copy( exc_diffQ, hGSCDec->Last_GSC_spectrum_fx, st_fx->L_frame ); + Copy( exc_diffQ, hGSCDec->Last_GSC_spectrum_fx, st_fx->L_frame ); /* Q_PVQ_OUT */ /*--------------------------------------------------------------------------------------* * Skip adaptive (pitch) contribution frequency band (no noise added over the time contribution) @@ -1413,15 +1415,15 @@ void gsc_dec_fx( /*==========================================================================*/ void gsc_dec_ivas_fx( Decoder_State *st_fx, /* i/o: State structure */ - Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation */ - const Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q */ - const Word16 nb_subfr, /* i : Number of subframe considered */ - const Word16 coder_type, /* i : coding type */ - Word16 *last_bin, /* i : last bin of bit allocation */ - const Word16 *lsf_new, /* i : ISFs at the end of the frame */ - Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill */ + Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ + const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ + const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ + const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + const Word16 coder_type, /* i : coding type Q0*/ + Word16 *last_bin, /* i : last bin of bit allocation Q0*/ + const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 *Q_exc ) { Word16 i, j, bit, nb_subbands, pvq_len; @@ -1470,12 +1472,12 @@ void gsc_dec_ivas_fx( test(); if ( coder_type == INACTIVE && ( EQ_16( st_fx->tdm_LRTD_flag, 1 ) || EQ_16( st_fx->element_mode, IVAS_SCE ) ) && LE_32( st_fx->core_brate, GSC_LRES_GAINQ_LIMIT ) ) { - bit = add( bit, GSC_LRES_NB_NITS ); + bit = add( bit, GSC_LRES_NB_NITS ); /* Q0 */ } if ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { - Mbands_gn = MBANDS_GN16k; + Mbands_gn = MBANDS_GN16k; /* Q0 */ move16(); } #endif @@ -1489,8 +1491,8 @@ void gsc_dec_ivas_fx( IF( st_fx->bfi || st_fx->BER_detect ) { /* copy old gain */ - Copy( hGSCDec->old_y_gain_fx, Ener_per_bd_iQ, Mbands_gn ); - mean_gain = mult_r( st_fx->lp_gainc_fx, 3277 ); /*Q3*/ + Copy( hGSCDec->old_y_gain_fx, Ener_per_bd_iQ, Mbands_gn ); /* Q_old_gain */ + mean_gain = mult_r( st_fx->lp_gainc_fx, 3277 ); /*Q3*/ FOR( i = 0; i < Mbands_gn; i++ ) { Ener_per_bd_iQ[i] = add( Ener_per_bd_iQ[i], shl( mean_gain, 9 ) ); /*Q12*/ @@ -1512,7 +1514,7 @@ void gsc_dec_ivas_fx( { break; } - i = add( i, 1 ); + i++; } test(); @@ -1521,9 +1523,9 @@ void gsc_dec_ivas_fx( if ( st_fx->element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) && LE_32( st_fx->core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation is mapped to 8 kb/s instead of 9.6 kb/s in this case */ { - i = sub( i, 1 ); + i--; } - mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); + mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ #else mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); @@ -1563,13 +1565,13 @@ void gsc_dec_ivas_fx( FOR( i = 0; i < st_fx->L_frame; i++ ) { L_tmp = L_shr( L_mult( Random( &hGSCDec->seed_tcx ), 26214 ), 5 ); /*Q10*/ - L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); - hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp ); /*Q10*/ + L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); /* Q10 */ + hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp ); /*Q10*/ move16(); } } - Copy( hGSCDec->Last_GSC_spectrum_fx, exc_diffQ, st_fx->L_frame ); + Copy( hGSCDec->Last_GSC_spectrum_fx, exc_diffQ, st_fx->L_frame ); /* Q10 */ FOR( i = 0; i < st_fx->L_frame; i++ ) { @@ -1595,7 +1597,7 @@ void gsc_dec_ivas_fx( #endif { pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); - Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); + Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ } seed_init = 0; move16(); @@ -1603,7 +1605,7 @@ void gsc_dec_ivas_fx( #if 1 // def ADD_LRTD max_eq = 0; move16(); - max_eq_val = 32767; + max_eq_val = 32767; /* 1.0f in Q15 */ move16(); test(); @@ -1616,7 +1618,7 @@ void gsc_dec_ivas_fx( Word16 temp_max_eq = add( abs_s( concat_out[j] ), 10 ) /*0.01f in Q10*/; if ( LE_16( temp_max_eq, ONE_IN_Q10 ) ) { - max_eq = max_eq_val; + max_eq = max_eq_val; /* Q15 */ move16(); } ELSE @@ -1624,22 +1626,22 @@ void gsc_dec_ivas_fx( Word16 exp = 5; move16(); max_eq = Inv16( temp_max_eq, &exp ); - max_eq = shl( max_eq, exp ); + max_eq = shl( max_eq, exp ); /* Q15 */ } } #endif /* Reorder Q bands */ FOR( j = 0; j < nb_subbands; j++ ) { - Copy( concat_out + imult1616( j, 16 ), exc_diffQ + imult1616( max_ener_band[j], 16 ), 16 ); + Copy( concat_out + imult1616( j, 16 ), exc_diffQ + imult1616( max_ener_band[j], 16 ), 16 ); /* Q_PVQ_OUT */ - *last_bin = s_max( *last_bin, max_ener_band[j] ); + *last_bin = s_max( *last_bin, max_ener_band[j] ); /* Q0 */ move16(); - bitallocation_band[max_ener_band[j]] = 1; + bitallocation_band[max_ener_band[j]] = 1; /* Q0 */ move16(); - seed_init = add( seed_init, inpulses_fx[j] ); + seed_init = add( seed_init, inpulses_fx[j] ); /* Q0 */ } test(); IF( NE_16( st_fx->last_coder_type, AUDIO ) /* First audio frame */ @@ -1649,19 +1651,19 @@ void gsc_dec_ivas_fx( { IF( concat_out[j] > 0 ) { - seed_init = extract_l( L_shl( seed_init, 3 ) ); + seed_init = extract_l( L_shl( seed_init, 3 ) ); /* Q0 */ } if ( concat_out[j] < 0 ) { #ifdef BASOP_NOGLOB_TMP_715 - seed_init = add_sat( seed_init, 3 ); + seed_init = add_sat( seed_init, 3 ); /* Q0 */ #else seed_init = add( seed_init, 3 ); #endif } } - hGSCDec->seed_tcx = seed_init; + hGSCDec->seed_tcx = seed_init; /* Q0 */ move16(); } test(); @@ -1669,18 +1671,18 @@ void gsc_dec_ivas_fx( { if ( exc_diffQ[L_FRAME8k - 2] != 0 ) { - bitallocation_exc[0] = 1; + bitallocation_exc[0] = 1; /* Q0 */ move16(); } if ( exc_diffQ[L_FRAME8k - 1] != 0 ) { - bitallocation_exc[1] = 1; + bitallocation_exc[1] = 1; /* Q0 */ move16(); } } - Copy( exc_diffQ, hGSCDec->Last_GSC_spectrum_fx, st_fx->L_frame ); + Copy( exc_diffQ, hGSCDec->Last_GSC_spectrum_fx, st_fx->L_frame ); /* Q_PVQ_OUT */ /*--------------------------------------------------------------------------------------* * Skip adaptive (pitch) contribution frequency band (no noise added over the time contribution) @@ -1698,7 +1700,7 @@ void gsc_dec_ivas_fx( { // PMT("GSC FIX point to be done here") // exc_diffQ[i] *= max_eq; - exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq ); + exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq ); /* Q_PVQ_OUT */ move16(); } } @@ -1708,7 +1710,7 @@ void gsc_dec_ivas_fx( { // PMT("GSC FIX point to be done here") // exc_diffQ[i] *= max_eq; - exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq ); + exc_diffQ[i] = mult_r( exc_diffQ[i], max_eq ); /* Q_PVQ_OUT */ move16(); } } @@ -1744,12 +1746,12 @@ void GSC_dec_init( GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ ) { - hGSCDec->seed_tcx = 15687; + hGSCDec->seed_tcx = 15687; /* Q0 */ hGSCDec->cor_strong_limit = 1; move16(); move16(); - hGSCDec->noise_lev = NOISE_LEVEL_SP0; + hGSCDec->noise_lev = NOISE_LEVEL_SP0; /* Q0 */ hGSCDec->Last_GSC_pit_band_idx = 0; move16(); move16(); @@ -1778,7 +1780,7 @@ void GSC_dec_init_ivas_fx( GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ ) { - hGSCDec->seed_tcx = 15687; + hGSCDec->seed_tcx = 15687; /* Q0 */ move16(); hGSCDec->cor_strong_limit = 1; move16(); diff --git a/lib_dec/hdecnrm_fx.c b/lib_dec/hdecnrm_fx.c index 9c8b6fa01..291aa87fb 100644 --- a/lib_dec/hdecnrm_fx.c +++ b/lib_dec/hdecnrm_fx.c @@ -13,18 +13,18 @@ /* Huffman decoding for indices of quantized norms */ /*--------------------------------------------------------------------------*/ void hdecnrm_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 numNorms, /* i : number of norms */ - Word16 *index ) /* o : indices of quantized norms */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 numNorms, /* i : number of norms Q0*/ + Word16 *index ) /* o : indices of quantized norms Q0*/ { Word16 i, j, k, n, m; Word16 temp; Word16 *pidx; - pidx = index; + pidx = index; /* Q0 */ - m = sub( numNorms, 1 ); + m = sub( numNorms, 1 ); /* Q0 */ FOR( i = 0; i < m; i++ ) { j = (Word16) 0; @@ -34,51 +34,51 @@ void hdecnrm_fx( if ( get_next_indice_1_fx( st_fx ) != 0 ) { - j = (Word16) 1; + j = (Word16) 1; /* Q0 */ move16(); } if ( get_next_indice_1_fx( st_fx ) != 0 ) { - k = (Word16) 1; + k = (Word16) 1; /* Q0 */ move16(); } - n = add( shl( j, 1 ), k ); - j = shl( j, 2 ); - temp = sub( add( 16, n ), j ); + n = add( shl( j, 1 ), k ); /* Q0 */ + j = shl( j, 2 ); /* Q0 */ + temp = sub( add( 16, n ), j ); /* Q0 */ IF( get_next_indice_1_fx( st_fx ) != 0 ) { - temp = add( add( 12, n ), j ); + temp = add( add( 12, n ), j ); /* Q0 */ IF( get_next_indice_1_fx( st_fx ) != 0 ) { j = (Word16) 0; move16(); if ( get_next_indice_1_fx( st_fx ) != 0 ) { - j = 1; + j = 1; /* Q0 */ move16(); } - temp = add( 8, n ); + temp = add( 8, n ); /* Q0 */ if ( j != 0 ) { - temp = add( temp, 12 ); + temp = add( temp, 12 ); /* Q0 */ } IF( get_next_indice_1_fx( st_fx ) != 0 ) { - temp = n; + temp = n; /* Q0 */ move16(); if ( get_next_indice_1_fx( st_fx ) != 0 ) { - temp = add( 4, n ); + temp = add( 4, n ); /* Q0 */ } if ( j != 0 ) { - temp = add( temp, 24 ); + temp = add( temp, 24 ); /* Q0 */ } } } } - *pidx++ = temp; + *pidx++ = temp; /* Q0 */ move16(); } @@ -96,9 +96,10 @@ void hdecnrm_fx( /*--------------------------------------------------------------------------*/ Word16 decode_huff_context_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *hufftab, - Word16 *rbits ) + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *hufftab, /* Q0 */ + Word16 *rbits /* Q0 */ +) { Word16 tmp_l, tmp_h; Word32 hufftab_idx; @@ -106,11 +107,11 @@ Word16 decode_huff_context_fx( hufftab_idx = L_deposit_l( 0 ); WHILE( hufftab[hufftab_idx] > 0 ) { - tmp_h = shr( hufftab[hufftab_idx], 4 ); - tmp_l = sub( hufftab[hufftab_idx], shl( tmp_h, 4 ) ); - *rbits = add( *rbits, tmp_l ); + tmp_h = shr( hufftab[hufftab_idx], 4 ); /* Q0 */ + tmp_l = sub( hufftab[hufftab_idx], shl( tmp_h, 4 ) ); /* Q0 */ + *rbits = add( *rbits, tmp_l ); /* Q0 */ move16(); - hufftab_idx = L_add( hufftab_idx, L_add( L_deposit_l( tmp_h ), get_next_indice_fx( st_fx, tmp_l ) ) ); + hufftab_idx = L_add( hufftab_idx, L_add( L_deposit_l( tmp_h ), get_next_indice_fx( st_fx, tmp_l ) ) ); /* Q0 */ } return negate( hufftab[hufftab_idx] ); } @@ -129,20 +130,21 @@ Word16 decode_huff_context_fx( void hdecnrm_context_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, - Word16 *index, - Word16 *n_length ) + const Word16 N, /* Q0 */ + Word16 *index, /* Q0 */ + Word16 *n_length /* Q0 */ +) { Word16 i, prevj, tmp; - prevj = add( index[0], OFFSET_NORM ); + prevj = add( index[0], OFFSET_NORM ); /* Q0 */ FOR( i = 1; i < N; i++ ) { IF( GT_16( prevj, HTH_NORM ) ) { /* above */ - tmp = decode_huff_context_fx( st_fx, hntable, n_length ); - index[i] = sub( 31, tmp ); + tmp = decode_huff_context_fx( st_fx, hntable, n_length ); /* Q0 */ + index[i] = sub( 31, tmp ); /* Q0 */ move16(); } ELSE @@ -150,17 +152,17 @@ void hdecnrm_context_fx( IF( LT_16( prevj, LTH_NORM ) ) { /* less */ - index[i] = decode_huff_context_fx( st_fx, hntable, n_length ); + index[i] = decode_huff_context_fx( st_fx, hntable, n_length ); /* Q0 */ move16(); } ELSE { /* equal */ - index[i] = decode_huff_context_fx( st_fx, hetable, n_length ); + index[i] = decode_huff_context_fx( st_fx, hetable, n_length ); /* Q0 */ move16(); } } - prevj = index[i]; + prevj = index[i]; /* Q0 */ move16(); } return; @@ -168,17 +170,17 @@ void hdecnrm_context_fx( void hdecnrm_resize_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* (i) number of SFMs */ - Word16 *index /* (o) norm quantization index vector */ + const Word16 N, /* (i) number of SFMs Q0*/ + Word16 *index /* (o) norm quantization index vector Q0*/ ) { Word16 i, j, k, m; Word16 temp; Word16 *pidx; - pidx = index; + pidx = index; /* Q0 */ - m = sub( N, 1 ); + m = sub( N, 1 ); /* Q0 */ move16(); FOR( i = 0; i < m; i++ ) { @@ -191,7 +193,7 @@ void hdecnrm_resize_fx( { IF( get_next_indice_1_fx( st_fx ) != 0 ) { - k = add( k, 1 ); + k = add( k, 1 ); /* Q0 */ move16(); } ELSE @@ -202,31 +204,31 @@ void hdecnrm_resize_fx( IF( EQ_16( k, 11 ) ) { - temp = 25; + temp = 25; /* Q0 */ move16(); } ELSE IF( EQ_16( k, 10 ) ) { - temp = 5; + temp = 5; /* Q0 */ move16(); } ELSE IF( EQ_16( k, 9 ) ) { - temp = 6; + temp = 6; /* Q0 */ move16(); } ELSE{ IF( get_next_indice_1_fx( st_fx ) != 0 ){ - temp = add( 16, k ); + temp = add( 16, k ); /* Q0 */ } ELSE { - temp = sub( 15, k ); + temp = sub( 15, k ); /* Q0 */ move16(); } } -*pidx++ = temp; +*pidx++ = temp; /* Q0 */ move16(); } @@ -241,20 +243,20 @@ return; void huff_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : Number of codewords to decode */ - const Word16 buffer_len, /* i : Number of bits to read */ - const Word16 num_lengths, /* i : Number of different huffman codeword lengths */ - const Word16 *thres, /* i : Threshold of first codeword of each length */ - const Word16 *offset, /* i : Offset for first codeword */ - const Word16 *huff_tab, /* i : Huffman table order by codeword lengths */ - Word16 *index /* o : Decoded index */ + const Word16 N, /* i : Number of codewords to decode Q0*/ + const Word16 buffer_len, /* i : Number of bits to read Q0*/ + const Word16 num_lengths, /* i : Number of different huffman codeword lengths Q0*/ + const Word16 *thres, /* i : Threshold of first codeword of each length Q0*/ + const Word16 *offset, /* i : Offset for first codeword Q0*/ + const Word16 *huff_tab, /* i : Huffman table order by codeword lengths Q0*/ + Word16 *index /* o : Decoded index Q0*/ ) { Word16 i, j, k; UWord16 val; Word16 last_bits; - last_bits = buffer_len; + last_bits = buffer_len; /* Q0 */ move16(); val = 0; @@ -263,24 +265,24 @@ void huff_dec_fx( move16(); FOR( i = 0; i < N; i++ ) { - last_bits = sub( buffer_len, j ); - val = (UWord16) L_shl( val, last_bits ); - val = (UWord16) L_and( val, sub( lshl( 1, buffer_len ), 1 ) ); - val = (UWord16) L_or( val, get_next_indice_fx( st_fx, last_bits ) ); + last_bits = sub( buffer_len, j ); /* Q0 */ + val = (UWord16) L_shl( val, last_bits ); /* Q0 */ + val = (UWord16) L_and( val, sub( lshl( 1, buffer_len ), 1 ) ); /* Q0 */ + val = (UWord16) L_or( val, get_next_indice_fx( st_fx, last_bits ) ); /* Q0 */ /* Find codeword length */ - j = sub( num_lengths, 1 ); + j = sub( num_lengths, 1 ); /* Q0 */ WHILE( LT_16( val, thres[j] ) ) { - j = sub( j, 1 ); + j = sub( j, 1 ); /* Q0 */ } - k = lshr( sub( val, thres[j] ), j ); - *index++ = huff_tab[add( offset[j], k )]; + k = lshr( sub( val, thres[j] ), j ); /* Q0 */ + *index++ = huff_tab[offset[j] + k]; /* Q0 */ move16(); } /* Put back unused bits */ - st_fx->next_bit_pos = sub( st_fx->next_bit_pos, j ); + st_fx->next_bit_pos = sub( st_fx->next_bit_pos, j ); /* Q0 */ move16(); return; @@ -293,9 +295,9 @@ void huff_dec_fx( *--------------------------------------------------------------------------*/ void hdecnrm_tran_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 N, /* i : number of norms */ - Word16 *index /* o : indices of quantized norms */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 N, /* i : number of norms Q0*/ + Word16 *index /* o : indices of quantized norms Q0*/ ) { Word16 i, j, k, n, m; @@ -303,9 +305,9 @@ void hdecnrm_tran_fx( Word16 *pidx; Word16 l; - pidx = index; + pidx = index; /* Q0 */ - m = sub( N, 1 ); + m = sub( N, 1 ); /* Q0 */ FOR( i = 0; i < m; i++ ) { j = 0; @@ -314,20 +316,20 @@ void hdecnrm_tran_fx( move16(); if ( get_next_indice_1_fx( st_fx ) != 0 ) { - j = 1; + j = 1; /* Q0 */ move16(); } if ( get_next_indice_1_fx( st_fx ) != 0 ) { - k = 1; + k = 1; /* Q0 */ move16(); } /*n = k * 2 + j; */ - n = add( shl( k, 1 ), j ); + n = add( shl( k, 1 ), j ); /* Q0 */ /*l = k * 4; */ - l = shl( k, 2 ); + l = shl( k, 2 ); /* Q0 */ test(); test(); test(); @@ -335,22 +337,22 @@ void hdecnrm_tran_fx( test(); IF( ( j == 0 && k == 0 ) || ( EQ_16( j, 1 ) && k == 0 ) || ( EQ_16( j, 1 ) && EQ_16( k, 1 ) ) ) { - temp = sub( add( 15, l ), n ); + temp = sub( add( 15, l ), n ); /* Q0 */ } ELSE{ IF( get_next_indice_1_fx( st_fx ) != 0 ){ - temp = sub( add( 15, n ), l ); + temp = sub( add( 15, n ), l ); /* Q0 */ } ELSE { - temp = sub( add( 15, l ), n ); + temp = sub( add( 15, l ), n ); /* Q0 */ IF( get_next_indice_1_fx( st_fx ) != 0 ) { FOR( k = 0; k < 3; ) { IF( get_next_indice_1_fx( st_fx ) != 0 ) { - k = add( k, 1 ); + k++; /* Q0 */ } ELSE { @@ -364,22 +366,22 @@ void hdecnrm_tran_fx( temp = sub( temp, 5 ); if ( EQ_16( k, 3 ) ) { - temp = sub( temp, 1 ); + temp = sub( temp, 1 ); /* Q0 */ } } ELSE IF( EQ_16( k, 1 ) ) { - temp = add( temp, 1 ); + temp = add( temp, 1 ); /* Q0 */ } ELSE { - temp = add( temp, 2 ); + temp = add( temp, 2 ); /* Q0 */ IF( get_next_indice_1_fx( st_fx ) != 0 ) { temp = add( temp, 1 ); if ( get_next_indice_1_fx( st_fx ) != 0 ) { - temp = add( temp, 1 ); + temp = add( temp, 1 ); /* Q0 */ } } } @@ -387,7 +389,7 @@ void hdecnrm_tran_fx( } } -*pidx++ = temp; +*pidx++ = temp; /* Q0 */ move16(); } diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 1c5a15e28..71aaec7df 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -3127,14 +3127,14 @@ void stereo_dft_generate_res_pred_fx( move32(); FOR( i = max( hStereoDft->band_limits[b], bin0 ); i < min( hStereoDft->band_limits[b + 1], STEREO_DFT32MS_N_32k / 2 ); i++ ) { - dmx_nrg = L_add( dmx_nrg, Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) ); /* 2 * q_dft - 31 */ + dmx_nrg = L_add( dmx_nrg, L_shr( Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ), 1 ) ); /* 2 * q_dft - 31 - 1 */ DFT_PRED_RES[2 * i] = L_add( L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i], g_short ), q_shift0 ), L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_long_ind][2 * i], g_long ), q_shift1 ) ); /* q_dft */ move32(); DFT_PRED_RES[2 * i + 1] = L_add( L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_short_ind][2 * i + 1], g_short ), q_shift0 ), L_shl( Mpy_32_16_1( hStereoDft->DFT_past_DMX_fx[d_long_ind][2 * i + 1], g_long ), q_shift1 ) ); /* q_dft */ move32(); - past_dmx_nrg = L_add( past_dmx_nrg, Madd_32_32( Mpy_32_32( DFT_PRED_RES[2 * i], DFT_PRED_RES[2 * i] ), DFT_PRED_RES[2 * i + 1], DFT_PRED_RES[2 * i + 1] ) ); /* 2 * q_dft - 31 */ + past_dmx_nrg = L_add( past_dmx_nrg, L_shr( Madd_32_32( Mpy_32_32( DFT_PRED_RES[2 * i], DFT_PRED_RES[2 * i] ), DFT_PRED_RES[2 * i + 1], DFT_PRED_RES[2 * i + 1] ), 1 ) ); /* 2 * q_dft - 31 -1 */ } op1 = L_deposit_h( BASOP_Util_Divide3232_Scale( ( EPSILON_FIX + dmx_nrg ), ( EPSILON_FIX + past_dmx_nrg ), &q_div ) ); /* q_div + 16 */ q_norm_fac = q_div; diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 9304dc325..cc6f7c5be 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -778,7 +778,7 @@ typedef struct tcx_dec_structure #ifndef IVAS_FLOAT_FIXED float cummulative_damping_tcx_float; #endif - Word16 cummulative_damping_tcx; + Word16 cummulative_damping_tcx; // Q15 } TCX_DEC_DATA, *TCX_DEC_HANDLE; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index a3c6d0e1b..033086191 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -1872,10 +1872,10 @@ ivas_error ivas_reverb_process( ); #ifdef IVAS_FLOAT_FIXED void ivas_rev_delay_line_init( - ivas_rev_delay_line_t *pDelay, /* o : the delay line to initialize */ - Word32 *memory_buffer, /* i : the memory buffer to use for the delay line */ - const UWord16 delay, /* i : the delay */ - const UWord16 maxdelay /* i : maximum delay to be supported */ + ivas_rev_delay_line_t *pDelay, /* o : the delay line to initialize */ + Word32 *memory_buffer, /* i : the memory buffer to use for the delay line Q11 */ + const UWord16 delay, /* i : the delay */ + const UWord16 maxdelay /* i : maximum delay to be supported */ ); #else void ivas_rev_delay_line_init( @@ -1887,13 +1887,13 @@ void ivas_rev_delay_line_init( #endif #ifdef IVAS_FLOAT_FIXED /*! r: sample gotten out of delay line, and amplified by set gain */ -Word32 ivas_rev_delay_line_get_sample_fx( - ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ +Word32 ivas_rev_delay_line_get_sample_fx( /* Q11 */ + ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ ); void ivas_rev_delay_line_feed_sample_fx( - ivas_rev_delay_line_t *pDelay, /* i : the delay line */ - Word32 input /* i : the sample to feed */ + ivas_rev_delay_line_t *pDelay, /* i : the delay line */ + Word32 input /* i : the sample to feed Q11 */ ); void ivas_rev_delay_line_get_sample_blk_fx( @@ -1903,9 +1903,9 @@ void ivas_rev_delay_line_get_sample_blk_fx( ); void ivas_rev_delay_line_feed_sample_blk_fx( - ivas_rev_delay_line_t *pDelay, /* i/o: the delay line */ - const UWord16 blk_size, /* i : number of samples in the input data block */ - Word32 *input /* i : the samples to feed */ + ivas_rev_delay_line_t *pDelay, /* i/o: the delay line */ + const UWord16 blk_size, /* i : number of samples in the input data block */ + Word32 *input /* i : the samples to feed Q11 */ ); #else /*! r: sample gotten out of delay line, and amplified by set gain */ @@ -1987,20 +1987,20 @@ void ivas_reverb_t2f_f2t_ClearHistory( ivas_reverb_t2f_f2t_t *t2f_f2t ); #ifdef IVAS_FLOAT_FIXED -void ivas_reverb_t2f_f2t_in_fx( - ivas_reverb_t2f_f2t_t *t2f_f2t, - Word32 *input_L, - Word32 *input_R, - Word32 *buffer_L, - Word32 *buffer_R +void ivas_reverb_t2f_f2t_in_fx( + ivas_reverb_t2f_f2t_t *t2f_f2t, + Word32 *input_L, // i: Qx + Word32 *input_R, // i: Qx + Word32 *buffer_L, // o: Qx + 1 + Word32 *buffer_R // o: Qx + 1 ); void ivas_reverb_t2f_f2t_out_fx( ivas_reverb_t2f_f2t_t *t2f_f2t, - Word32 *buffer_L, - Word32 *buffer_R, - Word32 *output_L, - Word32 *output_R + Word32 *buffer_L, // i/o: Qx + Word32 *buffer_R, // i/o: Qx + Word32 *output_L, // i/o: Qx + Word32 *output_R // i/o: Qx ); #else void ivas_reverb_t2f_f2t_in( @@ -2025,12 +2025,12 @@ Word16 ivas_reverb_fft_filter_init( ); void ivas_reverb_fft_filter_ComplexMul_fx( - ivas_reverb_fft_filter_t *fft_filter, - Word32 *buffer + ivas_reverb_fft_filter_t *fft_filter, /* i */ + Word32 *buffer /* i/o: Qx */ ); void ivas_reverb_fft_filter_CrossMix_fx( - Word32 *buffer0, - Word32 *buffer1, + Word32 *buffer0, // i/o: Qx + Word32 *buffer1, // i/o: Qx const Word16 fft_size ); #else @@ -2057,9 +2057,9 @@ void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( ); #ifdef IVAS_FLOAT_FIXED void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR_fx( - rv_fftwf_type_complex_fx *spectrum, - Word32 *fft_real, - const Word16 fft_size); + rv_fftwf_type_complex_fx *spectrum, // i: Qx + Word32 *fft_real, // o: Qx + const Word16 fft_size); void ivas_reverb_define_window_fft_fx( Word32 *pWindow, //output in Q31 const Word16 transitionStart, diff --git a/lib_rend/ivas_reverb_delay_line.c b/lib_rend/ivas_reverb_delay_line.c index 32599fd27..9025b1597 100644 --- a/lib_rend/ivas_reverb_delay_line.c +++ b/lib_rend/ivas_reverb_delay_line.c @@ -48,10 +48,10 @@ *-----------------------------------------------------------------------------------------*/ void ivas_rev_delay_line_init( - ivas_rev_delay_line_t *pDelay, /* o : the delay line to initialize */ - Word32 *memory_buffer, /* i : the memory buffer to use for the delay line */ - const UWord16 delay, /* i : the delay */ - const UWord16 maxdelay /* i : maximum delay to be supported */ + ivas_rev_delay_line_t *pDelay, /* o : the delay line to initialize */ + Word32 *memory_buffer, /* i : the memory buffer to use for the delay line Q11 */ + const UWord16 delay, /* i : the delay */ + const UWord16 maxdelay /* i : maximum delay to be supported */ ) { pDelay->MaxDelay = maxdelay; @@ -85,11 +85,11 @@ void ivas_rev_delay_line_init( *-----------------------------------------------------------------------------------------*/ void ivas_rev_delay_line_feed_sample_fx( - ivas_rev_delay_line_t *pDelay, /* i : the delay line */ - Word32 input /* i : the sample to feed */ + ivas_rev_delay_line_t *pDelay, /* i : the delay line */ + Word32 input /* i : the sample to feed Q11 */ ) { - pDelay->pBuffer_fx[pDelay->BufferPos] = input; + pDelay->pBuffer_fx[pDelay->BufferPos] = input; // Q11 pDelay->BufferPos = u_extract_l( UL_addNsD( pDelay->BufferPos, 1 ) ); move16(); @@ -223,9 +223,9 @@ void ivas_rev_delay_line_feed_sample_blk( *-----------------------------------------------------------------------------------------*/ void ivas_rev_delay_line_feed_sample_blk_fx( - ivas_rev_delay_line_t *pDelay, /* i/o: the delay line */ - const UWord16 blk_size, /* i : number of samples in the input data block */ - Word32 *input /* i : the samples to feed */ + ivas_rev_delay_line_t *pDelay, /* i/o: the delay line */ + const UWord16 blk_size, /* i : number of samples in the input data block */ + Word32 *input /* i : the samples to feed Q11 */ ) { Word32 *pDst, *pSrc; @@ -246,14 +246,14 @@ void ivas_rev_delay_line_feed_sample_blk_fx( pDst = &pDelay->pBuffer_fx[pos]; FOR( i = 0; i < blk_size_1; i++ ) { - pDst[i] = input[i]; + pDst[i] = input[i]; // Q11 move32(); } - pDst = &pDelay->pBuffer_fx[0]; - pSrc = &input[blk_size_1]; + pDst = &pDelay->pBuffer_fx[0]; // Q11 + pSrc = &input[blk_size_1]; // Q11 FOR( i = 0; i < blk_size_2; i++ ) { - pDst[i] = pSrc[i]; + pDst[i] = pSrc[i]; // Q11 move32(); } pos = blk_size_2; @@ -261,10 +261,10 @@ void ivas_rev_delay_line_feed_sample_blk_fx( } ELSE /* copy only 1 data block directly if it fits in the buffer */ { - pDst = &pDelay->pBuffer_fx[pos]; + pDst = &pDelay->pBuffer_fx[pos]; // Q11 FOR( i = 0; i < blk_size; i++ ) { - pDst[i] = input[i]; + pDst[i] = input[i]; // Q11 move32(); } pos = (UWord16) L_add( pos, blk_size ); @@ -289,8 +289,8 @@ void ivas_rev_delay_line_feed_sample_blk_fx( *-----------------------------------------------------------------------------------------*/ /*! r: sample gotten out of delay line, and amplified by set gain */ -Word32 ivas_rev_delay_line_get_sample_fx( - ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ +Word32 ivas_rev_delay_line_get_sample_fx( /* Q11 */ + ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ ) { IF( EQ_16( pDelay->Gain_fx, ONE_IN_Q14 ) ) @@ -301,7 +301,7 @@ Word32 ivas_rev_delay_line_get_sample_fx( ELSE { - return ( L_shl( Mpy_32_16_r( pDelay->pBuffer_fx[pDelay->BufferPos], pDelay->Gain_fx ), 1 ) ); + return ( L_shl( Mpy_32_16_r( pDelay->pBuffer_fx[pDelay->BufferPos], pDelay->Gain_fx ), 1 ) ); // Q11 + Q14 - 15 + 1 = Q11 } } /*-----------------------------------------------------------------------------------------* @@ -311,9 +311,9 @@ Word32 ivas_rev_delay_line_get_sample_fx( *-----------------------------------------------------------------------------------------*/ void ivas_rev_delay_line_get_sample_blk_fx( - ivas_rev_delay_line_t *pDelay, /* i : the delay line */ - const UWord16 blk_size, /* i : number of samples in the data block */ - Word32 *output /* i/o: amples gotten out of delay line, and amplified by set gainin */ + ivas_rev_delay_line_t *pDelay, /* i : the delay line */ + const UWord16 blk_size, /* i : number of samples in the data block */ + Word32 *output /* i/o: amples gotten out of delay line, and amplified by set gainin Q11 */ ) { Word32 *pDst, *pSrc; @@ -334,16 +334,16 @@ void ivas_rev_delay_line_get_sample_blk_fx( move16(); blk_size_2 = (UWord16) L_sub( blk_size, blk_size_1 ); move16(); - pSrc = &pDelay->pBuffer_fx[pos]; + pSrc = &pDelay->pBuffer_fx[pos]; // Q11 IF( EQ_16( gain, ONE_IN_Q14 ) ) { FOR( i = 0; i < blk_size_1; i++ ) { - output[i] = pSrc[i]; + output[i] = pSrc[i]; // Q11 move32(); } - pSrc = &pDelay->pBuffer_fx[0]; - pDst = &output[blk_size_1]; + pSrc = &pDelay->pBuffer_fx[0]; // Q11 + pDst = &output[blk_size_1]; // Q11 FOR( i = 0; i < blk_size_2; i++ ) { pDst[i] = pSrc[i]; @@ -354,14 +354,14 @@ void ivas_rev_delay_line_get_sample_blk_fx( { FOR( i = 0; i < blk_size_1; i++ ) { - output[i] = L_shl( Mpy_32_16_r( pSrc[i], gain ), 1 ); + output[i] = L_shl( Mpy_32_16_r( pSrc[i], gain ), 1 ); // Q11 + Q14 - 15 + 1 = Q11 move32(); } pSrc = &pDelay->pBuffer_fx[0]; pDst = &output[blk_size_1]; FOR( i = 0; i < blk_size_2; i++ ) { - pDst[i] = L_shl( Mpy_32_16_r( pSrc[i], gain ), 1 ); + pDst[i] = L_shl( Mpy_32_16_r( pSrc[i], gain ), 1 ); // Q11 + Q14 - 15 + 1 = Q11 move32(); } } @@ -374,7 +374,7 @@ void ivas_rev_delay_line_get_sample_blk_fx( { FOR( i = 0; i < blk_size; i++ ) { - output[i] = pSrc[i]; + output[i] = pSrc[i]; // Q11 move32(); } } @@ -382,7 +382,7 @@ void ivas_rev_delay_line_get_sample_blk_fx( { FOR( i = 0; i < blk_size; i++ ) { - output[i] = L_shl( Mpy_32_16_r( pSrc[i], gain ), 1 ); + output[i] = L_shl( Mpy_32_16_r( pSrc[i], gain ), 1 ); // Q11 + Q14 - 15 + 1 = Q11 move32(); } } diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter.c index 2e9ce6cda..bae4d3f36 100644 --- a/lib_rend/ivas_reverb_fft_filter.c +++ b/lib_rend/ivas_reverb_fft_filter.c @@ -139,8 +139,8 @@ uint16_t int_log2( *-----------------------------------------------------------------------------------------*/ static void fft_wrapper_2ch_fx( - Word32 *buffer_L_fx, - Word32 *buffer_R_fx, + Word32 *buffer_L_fx, // input Q: Qx -> output Q: (Qx + 1) + Word32 *buffer_R_fx, // input Q: Qx -> output Q: (Qx + 1) const Word16 fft_size ) { const Word16 half_sz = shr( fft_size, 1 ); @@ -149,27 +149,27 @@ static void fft_wrapper_2ch_fx( DoRTFTn_fx_ivas( buffer_L_fx, buffer_R_fx, fft_size ); /* separating left and right channel spectra */ - buffer_L_fx[0] = L_shl( buffer_L_fx[0], 1 ); + buffer_L_fx[0] = L_shl( buffer_L_fx[0], 1 ); // Qx + 1 move32(); - buffer_R_fx[0] = L_shl( buffer_R_fx[0], 1 ); + buffer_R_fx[0] = L_shl( buffer_R_fx[0], 1 ); // Qx + 1 move32(); FOR( k = 1; k < half_sz; k++ ) { mirror_k = sub( fft_size, k ); - left_re_fx = ( L_add( buffer_L_fx[k], buffer_L_fx[mirror_k] ) ); - left_im_fx = ( L_sub( buffer_R_fx[k], buffer_R_fx[mirror_k] ) ); + left_re_fx = ( L_add( buffer_L_fx[k], buffer_L_fx[mirror_k] ) ); // Qx + 1 + left_im_fx = ( L_sub( buffer_R_fx[k], buffer_R_fx[mirror_k] ) ); // Qx + 1 - right_re_fx = ( L_add( buffer_R_fx[k], buffer_R_fx[mirror_k] ) ); - right_im_fx = L_negate( ( L_sub( buffer_L_fx[k], buffer_L_fx[mirror_k] ) ) ); + right_re_fx = ( L_add( buffer_R_fx[k], buffer_R_fx[mirror_k] ) ); // Qx + 1 + right_im_fx = L_negate( ( L_sub( buffer_L_fx[k], buffer_L_fx[mirror_k] ) ) ); // Qx + 1 - buffer_L_fx[k] = left_re_fx; + buffer_L_fx[k] = left_re_fx; // Qx + 1 move32(); - buffer_R_fx[k] = right_re_fx; + buffer_R_fx[k] = right_re_fx; // Qx + 1 move32(); - buffer_L_fx[mirror_k] = left_im_fx; + buffer_L_fx[mirror_k] = left_im_fx; // Qx + 1 move32(); - buffer_R_fx[mirror_k] = right_im_fx; + buffer_R_fx[mirror_k] = right_im_fx; // Qx + 1 move32(); } @@ -221,8 +221,8 @@ static void fft_wrapper_2ch( *-----------------------------------------------------------------------------------------*/ static void ifft_wrapper_2ch_fx( - Word32 *buffer_L, - Word32 *buffer_R, + Word32 *buffer_L, // i/o: Qx + Word32 *buffer_R, // i/o: Qx const Word16 fft_size ) { Word32 buffer_L_re, buffer_L_im, buffer_R_re, buffer_R_im; @@ -234,22 +234,22 @@ static void ifft_wrapper_2ch_fx( { mirror_k = sub( fft_size, k ); - buffer_L_re = buffer_L[k]; + buffer_L_re = buffer_L[k]; // Qx move32(); - buffer_L_im = buffer_L[mirror_k]; + buffer_L_im = buffer_L[mirror_k]; // Qx move32(); - buffer_R_re = buffer_R[k]; + buffer_R_re = buffer_R[k]; // Qx move32(); - buffer_R_im = buffer_R[mirror_k]; + buffer_R_im = buffer_R[mirror_k]; // Qx move32(); - buffer_L[k] = L_add( buffer_L_re, buffer_R_im ); + buffer_L[k] = L_add( buffer_L_re, buffer_R_im ); // Qx move32(); - buffer_L[mirror_k] = L_sub( buffer_L_re, buffer_R_im ); + buffer_L[mirror_k] = L_sub( buffer_L_re, buffer_R_im ); // Qx move32(); - buffer_R[k] = L_sub( buffer_R_re, buffer_L_im ); + buffer_R[k] = L_sub( buffer_R_re, buffer_L_im ); // Qx move32(); - buffer_R[mirror_k] = L_add( buffer_R_re, buffer_L_im ); + buffer_R[mirror_k] = L_add( buffer_R_re, buffer_L_im ); // Qx move32(); } @@ -441,26 +441,26 @@ void ivas_reverb_t2f_f2t_ClearHistory( void ivas_reverb_t2f_f2t_in_fx( ivas_reverb_t2f_f2t_t *t2f_f2t, - Word32 *input_L, - Word32 *input_R, - Word32 *buffer_L, - Word32 *buffer_R ) + Word32 *input_L, // i: Qx + Word32 *input_R, // i: Qx + Word32 *buffer_L, // o: Qx + 1 + Word32 *buffer_R ) // o: Qx + 1 { Word16 i; Word16 hlen = t2f_f2t->hist_size; move16(); Word16 bsiz = t2f_f2t->block_size; move16(); - Word32 *hist_L = t2f_f2t->fft_history_L_fx; - Word32 *hist_R = t2f_f2t->fft_history_R_fx; + Word32 *hist_L = t2f_f2t->fft_history_L_fx; // Qx + Word32 *hist_R = t2f_f2t->fft_history_R_fx; // Qx Word32 *pL, *pR; /* copy history to buffer */ FOR( i = 0; i < hlen; i++ ) { - buffer_L[i] = hist_L[i]; + buffer_L[i] = hist_L[i]; // Qx move16(); - buffer_R[i] = hist_R[i]; + buffer_R[i] = hist_R[i]; // Qx move16(); } @@ -469,9 +469,9 @@ void ivas_reverb_t2f_f2t_in_fx( pR = &buffer_R[hlen]; FOR( i = 0; i < bsiz; i++ ) { - pL[i] = input_L[i]; + pL[i] = input_L[i]; // Qx move32(); - pR[i] = input_R[i]; + pR[i] = input_R[i]; // Qx move32(); } @@ -480,14 +480,14 @@ void ivas_reverb_t2f_f2t_in_fx( pR = &buffer_R[bsiz]; FOR( i = 0; i < hlen; i++ ) { - hist_L[i] = pL[i]; + hist_L[i] = pL[i]; // Qx move32(); - hist_R[i] = pR[i]; + hist_R[i] = pR[i]; // Qx move32(); } /* do FFT */ - fft_wrapper_2ch_fx( buffer_L, buffer_R, t2f_f2t->fft_size ); + fft_wrapper_2ch_fx( buffer_L, buffer_R, t2f_f2t->fft_size ); // Qx -> Qx + 1 return; } @@ -552,10 +552,10 @@ void ivas_reverb_t2f_f2t_in( void ivas_reverb_t2f_f2t_out_fx( ivas_reverb_t2f_f2t_t *t2f_f2t, - Word32 *buffer_L, - Word32 *buffer_R, - Word32 *output_L, - Word32 *output_R ) + Word32 *buffer_L, // i/o: Qx + Word32 *buffer_R, // i/o: Qx + Word32 *output_L, // i/o: Qx + Word32 *output_R ) // i/o: Qx { Word16 i; Word32 *pL = &buffer_L[t2f_f2t->hist_size]; @@ -565,9 +565,9 @@ void ivas_reverb_t2f_f2t_out_fx( FOR( i = 0; i < t2f_f2t->block_size; i++ ) { - output_L[i] = pL[i]; + output_L[i] = pL[i]; // Qx move32(); - output_R[i] = pR[i]; + output_R[i] = pR[i]; // Qx move32(); } @@ -654,8 +654,9 @@ int16_t ivas_reverb_fft_filter_init( *-----------------------------------------------------------------------------------------*/ void ivas_reverb_fft_filter_ComplexMul_fx( - ivas_reverb_fft_filter_t *fft_filter, - Word32 *buffer ) + ivas_reverb_fft_filter_t *fft_filter, /* i */ + Word32 *buffer /* i/o: Qx */ +) { Word16 f_spec, h, i, j; Word32 *spec; @@ -665,18 +666,18 @@ void ivas_reverb_fft_filter_ComplexMul_fx( h = shr( f_spec, 1 ); spec = fft_filter->fft_spectrum_fx; - buffer[0] = Mpy_32_32( spec[0], buffer[0] ); /* real multiply f0 DC */ + buffer[0] = Mpy_32_32( spec[0], buffer[0] ); /* real multiply f0 DC */ // Q31 + Qx - 31 = Qx move32(); - buffer[h] = Mpy_32_32( spec[h], buffer[h] ); /* real multiply f_spec Nyquist */ + buffer[h] = Mpy_32_32( spec[h], buffer[h] ); /* real multiply f_spec Nyquist */ // Q31 + Qx - 31 = Qx move32(); j = sub( f_spec, 1 ); FOR( i = 1; i < h; i++ ) /*actual complex multiply in loop */ { t = buffer[i]; move32(); - buffer[i] = L_sub( Mpy_32_32( t, spec[i] ), Mpy_32_32( buffer[j], spec[j] ) ); + buffer[i] = L_sub( Mpy_32_32( t, spec[i] ), Mpy_32_32( buffer[j], spec[j] ) ); // Qx + Q31 - 31 = Qx move32(); - buffer[j] = L_add( Mpy_32_32( t, spec[j] ), Mpy_32_32( buffer[j], spec[i] ) ); + buffer[j] = L_add( Mpy_32_32( t, spec[j] ), Mpy_32_32( buffer[j], spec[i] ) ); // Qx + Q31 - 31 = Qx move32(); j = sub( j, 1 ); } @@ -723,22 +724,22 @@ void ivas_reverb_fft_filter_ComplexMul( *-----------------------------------------------------------------------------------------*/ #ifdef IVAS_FLOAT_FIXED void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR_fx( - rv_fftwf_type_complex_fx *spectrum, - Word32 *fft_real, + rv_fftwf_type_complex_fx *spectrum, // i: Qx + Word32 *fft_real, // o: Qx const Word16 fft_size ) { Word16 i, h; h = shr( fft_size, 1 ); - fft_real[0] = spectrum[0][0]; + fft_real[0] = spectrum[0][0]; // Qx move32(); - fft_real[h] = spectrum[h][0]; + fft_real[h] = spectrum[h][0]; // Qx move32(); FOR( i = 1; i < h; i++ ) { - fft_real[i] = spectrum[i][0]; + fft_real[i] = spectrum[i][0]; // Qx move32(); - fft_real[sub( fft_size, i )] = spectrum[i][1]; + fft_real[fft_size - i] = spectrum[i][1]; // Qx move32(); } @@ -775,8 +776,8 @@ void ivas_reverb_fft_filter_ConvertFFTWF_2_FFTR( *-----------------------------------------------------------------------------------------*/ void ivas_reverb_fft_filter_CrossMix_fx( - Word32 *buffer0, - Word32 *buffer1, + Word32 *buffer0, // i/o: Qx + Word32 *buffer1, // i/o: Qx const Word16 fft_size ) { Word32 t; @@ -784,11 +785,11 @@ void ivas_reverb_fft_filter_CrossMix_fx( FOR( i = 0; i < fft_size; i++ ) { - t = buffer0[i]; + t = buffer0[i]; // Qx move32(); - buffer0[i] = L_add( t, buffer1[i] ); + buffer0[i] = L_add( t, buffer1[i] ); // Qx move32(); - buffer1[i] = L_sub( t, buffer1[i] ); + buffer1[i] = L_sub( t, buffer1[i] ); // Qx move32(); } diff --git a/lib_rend/ivas_rom_binaural_crend_head.c b/lib_rend/ivas_rom_binaural_crend_head.c index a34162e49..d688ccded 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.c +++ b/lib_rend/ivas_rom_binaural_crend_head.c @@ -678,7 +678,7 @@ const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS #ifndef IVAS_FLOAT_FIXED const float CRendBin_FOA_HRIR_latency_s = 0.000020834f; #else -const Word32 CRendBin_FOA_HRIR_latency_s_fx = 44741; +const Word32 CRendBin_FOA_HRIR_latency_s_fx = 44741; // Q31 #endif // IVAS_FLOAT_FIXED /* Sample Rate = 48000 */ @@ -904,7 +904,7 @@ const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NU #ifndef IVAS_FLOAT_FIXED const float CRendBin_HOA2_HRIR_latency_s = 0.000020834f; #else -const Word32 CRendBin_HOA2_HRIR_latency_s_fx = 44741; +const Word32 CRendBin_HOA2_HRIR_latency_s_fx = 44741; // Q31 #endif // IVAS_FLOAT_FIXED /* Sample Rate = 48000 */ diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index 3012dad11..ae3482a4f 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -204,9 +204,9 @@ const float * const ap_lattice_coeffs[DIRAC_DECORR_NUM_SPLIT_BANDS] = }; #else -const Word16 ap_lattice_coeffs_1_fx[330] = { 26061, 16472, 6699, 13650, 15061, 8862, -6617, 917, 2222, -1724, -1270, -1880, 671, 12048, -19454, 17487, 6635, -63, 6392, -6044, -7663, 7474, -10790, -11098, -2611, 1716, -310, 5859, 6253, -15691, 1442, 25837, 4375, -5690, 17871, 22329, 10907, 9656, 10658, 1560, 5157, 3810, 7175, -6201, -10400, -24696, 25309, -16625, 9076, -22700, 7612, -11624, -511, -7309, 10174, -1147, 2810, -16383, 7053, 6599, -16238, -9884, 6439, 10687, -19476, 10319, 21911, 2511, 1497, -4089, -6660, -9738, 4122, -5881, -6611, 5279, 12977, 8745, 11684, 15995, -1843, 4563, -9712, -3697, 1225, -12039, -7087, -9088, 12760, 3772, -7879, -8880, 13982, -362, 4974, 8306, 7397, 16341, -4468, 14516, -9994, -1025, -352, 5581, 16268, -4583, -7929, -3435, 9645, -2219, -16128, -15978, 1192, 3584, 12981, -11562, -6747, -2719, -15172, -10135, 848, -3029, -4100, -5115, -160, 5847, 2935, 1468, 7805, -10227, -12802, -5850, 14890, 12681, -12742, -6481, 1164, 14922, -1782, 12452, 9534, 1599, 2576, 7265, -7128, 3974, -12998, -7159, -4170, -8831, -11279, -15238, -13808, -852, 7259, 11861, -11411, 9666, 11998, 2315, -2819, 8261, 5113, -2057, 13401, 7944, -9888, -2167, 12735, -15146, -5206, 7562, -3053, 1542, 2405, -10977, 751, 11619, 2372, 638, 11039, -15746, 5579, 8508, -12896, -11422, -3570, 9137, 12631, 11870, -10444, 11872, 9467, 9542, -9110, -14722, -9453, -13565, -13280, -9671, -8031, 82, 9433, 11410, -5844, -6767, 11504, -15800, 699, -16128, 1593, 14853, 3576, 7621, -15524, 4603, 11551, -3231, 4822, -1828, 3530, -7570, 11708, 11404, 7615, -10642, 5324, 1888, -1990, -319, -7346, -9252, -2144, 2119, 9187, -9335, -15417, 638, -14493, 12360, 14659, -9519, 11322, 12130, -10260, 3918, 9830, 13336, -9106, 14648, 6383, 5167, -7320, -4822, 12421, -7089, 4520, -13014, 2421, -8949, -14517, -5515, 11346, 1230, 2142, 5370, -4014, 11975, -10365, 3842, -9872, 5558, -11025, 8844, -13767, -10855, 16335, -12878, -15144, -10587, 15432, -11778, 8661, 7104, 16167, 4963, -10539, 15217, -11654, 13775, 6039, -9900, 4474, -8285, 6353, 9790, 7825, -12658, -5963, -2533, 4090, -8630, 12766, 147, 11134, 13605, 12378, 13114, 11548, -124, -6046, 14199, -7784, 4839, 13343, 2215, -8169, -11600, 10516, 13959, 10144, -6215, -6863, 5209, -2684, 12675, 5851, -13341, 7280, -4885, }; -const Word16 ap_lattice_coeffs_2_fx[132] = { 20764, 22321, -1619, 9395, 4784, 4436, -13439, -6775, -21527, -3334, 14296, 11135, -4305, -25354, -9883, 10733, 10886, 6745, 23514, -18100, -4919, 1787, 7848, -21249, -23653, 6205, 2234, 203, 2523, 1267, 13874, -3560, 14157, -13586, 9104, 13712, 2549, -9275, -11698, 151, -14504, -12200, 13216, 7963, 10301, 14565, 11387, 16254, 3552, 15380, -5579, 10692, 5641, 14428, 1914, 11130, -6388, 16096, -9217, -1412, -15810, -10977, -11015, 6437, -5394, 14499, -4429, -11612, 14815, -10198, -11391, 16329, -9469, 12334, -5830, 6407, 10940, -5003, 1744, 15000, 14499, 7708, -11310, -9374, 5093, 13283, 7113, -3537, 350, 12090, -16330, -16246, -7060, -3075, 10494, -453, 16036, 15427, -2157, 11366, 893, 4918, 15860, -16298, 5531, -16182, -5686, 10966, 8658, -13914, -10319, 8293, 13021, -16107, -14867, -15183, -626, 11, 10336, 15477, 3117, 9285, -7375, -3924, -15626, 1229, 11041, 16204, -2051, 5821, 15200, 16032, }; -const Word16 ap_lattice_coeffs_3_fx[66] = { 621, -6953, 13851, -13128, -3502, -805, 4587, 9161, 1060, 20726, 18957, -24071, 563, 433, -908, -11578, -15799, -16097, 14975, 5410, 15391, -6412, 14421, -15642, 11802, -16074, 15880, -5694, 247, 9115, 14234, 1977, -6347, -1104, 16260, 96, -15756, -3589, -760, 10639, -9570, -11670, -12012, 12481, -9887, 3614, 12575, 9960, -16373, -11455, 10969, -662, -14092, -5069, -12161, 10947, 11367, -5465, -7506, 3865, 11183, 16071, 16176, -12049, 13976, -1499, }; +const Word16 ap_lattice_coeffs_1_fx[330] /* Q15 */ = { 26061, 16472, 6699, 13650, 15061, 8862, -6617, 917, 2222, -1724, -1270, -1880, 671, 12048, -19454, 17487, 6635, -63, 6392, -6044, -7663, 7474, -10790, -11098, -2611, 1716, -310, 5859, 6253, -15691, 1442, 25837, 4375, -5690, 17871, 22329, 10907, 9656, 10658, 1560, 5157, 3810, 7175, -6201, -10400, -24696, 25309, -16625, 9076, -22700, 7612, -11624, -511, -7309, 10174, -1147, 2810, -16383, 7053, 6599, -16238, -9884, 6439, 10687, -19476, 10319, 21911, 2511, 1497, -4089, -6660, -9738, 4122, -5881, -6611, 5279, 12977, 8745, 11684, 15995, -1843, 4563, -9712, -3697, 1225, -12039, -7087, -9088, 12760, 3772, -7879, -8880, 13982, -362, 4974, 8306, 7397, 16341, -4468, 14516, -9994, -1025, -352, 5581, 16268, -4583, -7929, -3435, 9645, -2219, -16128, -15978, 1192, 3584, 12981, -11562, -6747, -2719, -15172, -10135, 848, -3029, -4100, -5115, -160, 5847, 2935, 1468, 7805, -10227, -12802, -5850, 14890, 12681, -12742, -6481, 1164, 14922, -1782, 12452, 9534, 1599, 2576, 7265, -7128, 3974, -12998, -7159, -4170, -8831, -11279, -15238, -13808, -852, 7259, 11861, -11411, 9666, 11998, 2315, -2819, 8261, 5113, -2057, 13401, 7944, -9888, -2167, 12735, -15146, -5206, 7562, -3053, 1542, 2405, -10977, 751, 11619, 2372, 638, 11039, -15746, 5579, 8508, -12896, -11422, -3570, 9137, 12631, 11870, -10444, 11872, 9467, 9542, -9110, -14722, -9453, -13565, -13280, -9671, -8031, 82, 9433, 11410, -5844, -6767, 11504, -15800, 699, -16128, 1593, 14853, 3576, 7621, -15524, 4603, 11551, -3231, 4822, -1828, 3530, -7570, 11708, 11404, 7615, -10642, 5324, 1888, -1990, -319, -7346, -9252, -2144, 2119, 9187, -9335, -15417, 638, -14493, 12360, 14659, -9519, 11322, 12130, -10260, 3918, 9830, 13336, -9106, 14648, 6383, 5167, -7320, -4822, 12421, -7089, 4520, -13014, 2421, -8949, -14517, -5515, 11346, 1230, 2142, 5370, -4014, 11975, -10365, 3842, -9872, 5558, -11025, 8844, -13767, -10855, 16335, -12878, -15144, -10587, 15432, -11778, 8661, 7104, 16167, 4963, -10539, 15217, -11654, 13775, 6039, -9900, 4474, -8285, 6353, 9790, 7825, -12658, -5963, -2533, 4090, -8630, 12766, 147, 11134, 13605, 12378, 13114, 11548, -124, -6046, 14199, -7784, 4839, 13343, 2215, -8169, -11600, 10516, 13959, 10144, -6215, -6863, 5209, -2684, 12675, 5851, -13341, 7280, -4885, }; +const Word16 ap_lattice_coeffs_2_fx[132] /* Q15 */ = { 20764, 22321, -1619, 9395, 4784, 4436, -13439, -6775, -21527, -3334, 14296, 11135, -4305, -25354, -9883, 10733, 10886, 6745, 23514, -18100, -4919, 1787, 7848, -21249, -23653, 6205, 2234, 203, 2523, 1267, 13874, -3560, 14157, -13586, 9104, 13712, 2549, -9275, -11698, 151, -14504, -12200, 13216, 7963, 10301, 14565, 11387, 16254, 3552, 15380, -5579, 10692, 5641, 14428, 1914, 11130, -6388, 16096, -9217, -1412, -15810, -10977, -11015, 6437, -5394, 14499, -4429, -11612, 14815, -10198, -11391, 16329, -9469, 12334, -5830, 6407, 10940, -5003, 1744, 15000, 14499, 7708, -11310, -9374, 5093, 13283, 7113, -3537, 350, 12090, -16330, -16246, -7060, -3075, 10494, -453, 16036, 15427, -2157, 11366, 893, 4918, 15860, -16298, 5531, -16182, -5686, 10966, 8658, -13914, -10319, 8293, 13021, -16107, -14867, -15183, -626, 11, 10336, 15477, 3117, 9285, -7375, -3924, -15626, 1229, 11041, 16204, -2051, 5821, 15200, 16032, }; +const Word16 ap_lattice_coeffs_3_fx[66] /* Q15 */ = { 621, -6953, 13851, -13128, -3502, -805, 4587, 9161, 1060, 20726, 18957, -24071, 563, 433, -908, -11578, -15799, -16097, 14975, 5410, 15391, -6412, 14421, -15642, 11802, -16074, 15880, -5694, 247, 9115, 14234, 1977, -6347, -1104, 16260, 96, -15756, -3589, -760, 10639, -9570, -11670, -12012, 12481, -9887, 3614, 12575, 9960, -16373, -11455, 10969, -662, -14092, -5069, -12161, 10947, 11367, -5465, -7506, 3865, 11183, 16071, 16176, -12049, 13976, -1499, }; const Word16 * const ap_lattice_coeffs_fx[DIRAC_DECORR_NUM_SPLIT_BANDS] = { @@ -269,7 +269,7 @@ const float surCohEne[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = 3.0903f, 2.0053f, 1.0860f, 0.8072f, 0.7079f }; #else -const Word16 surCohEne_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] = +const Word16 surCohEne_fx[MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS] /* Q13 */ = { 25315, 16427, 8896, 6612, 5799 }; @@ -302,7 +302,7 @@ const float lowBitRateBinauralEQ[LOW_BIT_RATE_BINAURAL_EQ_BINS] = 0.979f, 0.893f, 0.762f, 0.615f, 0.52f, 0.48f, 0.477f, 0.477f, 0.48f, 0.501f, 0.546f, 0.602f, 0.652f, 0.664f, 0.652f, 0.639f, 0.635f }; #else -const Word32 lowBitRateBinauralEQ_fx[LOW_BIT_RATE_BINAURAL_EQ_BINS] = +const Word32 lowBitRateBinauralEQ_fx[LOW_BIT_RATE_BINAURAL_EQ_BINS] /* Q31 */ = { 2102386432, 1917702912, 1636382592, 1320702464, 1116691456, 1030792128, 1024349696, 1024349696, 1030792128, 1075889280, 1172526080, 1292785152, 1400159360, 1425929088, 1400159360, 1372242048, 1363652096 -- GitLab