Loading lib_enc/ivas_cpe_enc_fx.c +32 −16 Original line number Diff line number Diff line Loading @@ -130,7 +130,10 @@ ivas_error ivas_cpe_enc_fx( Word16 NFFT_inner; move16(); move16(); Word16 q_com, shift, q_min, gb; #ifdef FIX_2320_OOB_SCE_SWITCHING Word16 input_frame_2; #endif Word16 i, j, q_com, shift, q_min, gb; error = IVAS_ERR_OK; move32(); Loading @@ -156,6 +159,9 @@ ivas_error ivas_cpe_enc_fx( * Initialization - general *-----------------------------------------------------------------*/ #ifdef FIX_2320_OOB_SCE_SWITCHING input_frame_2 = shl( input_frame, 1 ); #endif set16_fx( q_re_im_buf, 0, CPE_CHANNELS ); tdm_SM_or_LRTD_Pri = 0; Loading @@ -178,7 +184,7 @@ ivas_error ivas_cpe_enc_fx( set16_fx( voicing_fr_fx[0], 0, NB_SUBFR ); set16_fx( voicing_fr_fx[1], 0, NB_SUBFR ); FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) FOR( i = 0; i < CPE_CHANNELS; i++ ) { set16_zero_fx( fft_buff_fx[i], 2 * L_FFT ); set16_zero_fx( old_inp_16k_16fx[i], L_INP ); Loading Loading @@ -252,9 +258,9 @@ ivas_error ivas_cpe_enc_fx( move16(); } FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) FOR( i = 0; i < CPE_CHANNELS; i++ ) { FOR( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ ) FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { set_zero_fx( realBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX ); set_zero_fx( imagBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX ); Loading Loading @@ -408,8 +414,13 @@ ivas_error ivas_cpe_enc_fx( IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { gb = find_guarded_bits_fx( sts[0]->encoderLookahead_FB ); #ifdef FIX_2320_OOB_SCE_SWITCHING shift = L_norm_arr( sts[1]->old_input_signal32_fx, input_frame_2 ); shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, input_frame_2 ) ); #else shift = L_norm_arr( sts[1]->old_input_signal32_fx, shl( input_frame, 1 ) ); shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, shl( input_frame, 1 ) ) ); #endif IF( LT_16( shift, gb ) ) { Loading @@ -436,10 +447,10 @@ ivas_error ivas_cpe_enc_fx( *----------------------------------------------------------------*/ #ifdef FIX_2320_OOB_SCE_SWITCHING shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, shl( input_frame, 1 ) ), L_norm_arr( sts[1]->input_buff32_fx, shl( input_frame, 1 ) ) ); shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, input_frame_2 ), L_norm_arr( sts[1]->input_buff32_fx, input_frame_2 ) ); q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); scale_sig32( sts[1]->input_buff32_fx, shl( input_frame, 1 ), sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ scale_sig32( sts[0]->input_buff32_fx, shl( input_frame, 1 ), sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ scale_sig32( sts[1]->input_buff32_fx, input_frame_2, sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ scale_sig32( sts[0]->input_buff32_fx, input_frame_2, sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ #else shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ); q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); Loading @@ -455,10 +466,10 @@ ivas_error ivas_cpe_enc_fx( stereo_tca_enc_fx( hCPE, input_frame ); #ifdef FIX_2320_OOB_SCE_SWITCHING shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, shl( input_frame, 1 ) ), sts[0]->q_inp32 ), 16 ); shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, shl( input_frame, 1 ) ), sts[1]->q_inp32 ), 16 ) ); Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, shl( input_frame, 1 ), sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, shl( input_frame, 1 ), sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, input_frame_2 ), sts[0]->q_inp32 ), 16 ); shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, input_frame_2 ), sts[1]->q_inp32 ), 16 ) ); Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, input_frame_2, sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, input_frame_2, sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift #else shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 ); shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[1]->q_inp32 ), 16 ) ); Loading Loading @@ -728,12 +739,9 @@ ivas_error ivas_cpe_enc_fx( move16(); /* Determine the energy ratio between the 2 channels */ tdm_ratio_idx = stereo_tdm_ener_analysis_fx( ivas_format, hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Q0 */ tdm_ratio_idx = stereo_tdm_ener_analysis_fx( ivas_format, hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Q0 */ /* Compute the downmix signal based on the ratio index */ Word16 tdm_SM_flag; IF( hCPE->hStereoTD->tdm_LRTD_flag == 0 ) { Loading Loading @@ -855,11 +863,19 @@ ivas_error ivas_cpe_enc_fx( // Normalise the input buffer from Q15 Word16 input_norm, q_inp; //, common_q, fir_delay_len; #ifdef FIX_2320_OOB_SCE_SWITCHING input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, input_frame_2 ); #else input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, shl( input_frame, 1 ) ); #endif q_inp = sub( add( Q15, input_norm ), 16 ); // Rescale the old input, input and FIR delay section of input buffer #ifdef FIX_2320_OOB_SCE_SWITCHING Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, input_frame_2, sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp #else Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, shl( input_frame, 1 ), sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp #endif // Update the Q-factors sts[0]->q_inp = q_inp; Loading Loading @@ -1207,7 +1223,7 @@ ivas_error ivas_cpe_enc_fx( } } FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) FOR( i = 0; i < CPE_CHANNELS; i++ ) { Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 ); // Q(-1) -> Q15 } Loading Loading
lib_enc/ivas_cpe_enc_fx.c +32 −16 Original line number Diff line number Diff line Loading @@ -130,7 +130,10 @@ ivas_error ivas_cpe_enc_fx( Word16 NFFT_inner; move16(); move16(); Word16 q_com, shift, q_min, gb; #ifdef FIX_2320_OOB_SCE_SWITCHING Word16 input_frame_2; #endif Word16 i, j, q_com, shift, q_min, gb; error = IVAS_ERR_OK; move32(); Loading @@ -156,6 +159,9 @@ ivas_error ivas_cpe_enc_fx( * Initialization - general *-----------------------------------------------------------------*/ #ifdef FIX_2320_OOB_SCE_SWITCHING input_frame_2 = shl( input_frame, 1 ); #endif set16_fx( q_re_im_buf, 0, CPE_CHANNELS ); tdm_SM_or_LRTD_Pri = 0; Loading @@ -178,7 +184,7 @@ ivas_error ivas_cpe_enc_fx( set16_fx( voicing_fr_fx[0], 0, NB_SUBFR ); set16_fx( voicing_fr_fx[1], 0, NB_SUBFR ); FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) FOR( i = 0; i < CPE_CHANNELS; i++ ) { set16_zero_fx( fft_buff_fx[i], 2 * L_FFT ); set16_zero_fx( old_inp_16k_16fx[i], L_INP ); Loading Loading @@ -252,9 +258,9 @@ ivas_error ivas_cpe_enc_fx( move16(); } FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) FOR( i = 0; i < CPE_CHANNELS; i++ ) { FOR( Word16 j = 0; j < CLDFB_NO_COL_MAX; j++ ) FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { set_zero_fx( realBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX ); set_zero_fx( imagBuffer_fx[i][j], CLDFB_NO_CHANNELS_MAX ); Loading Loading @@ -408,8 +414,13 @@ ivas_error ivas_cpe_enc_fx( IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_DFT ) ) { gb = find_guarded_bits_fx( sts[0]->encoderLookahead_FB ); #ifdef FIX_2320_OOB_SCE_SWITCHING shift = L_norm_arr( sts[1]->old_input_signal32_fx, input_frame_2 ); shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, input_frame_2 ) ); #else shift = L_norm_arr( sts[1]->old_input_signal32_fx, shl( input_frame, 1 ) ); shift = s_min( shift, L_norm_arr( sts[0]->old_input_signal32_fx, shl( input_frame, 1 ) ) ); #endif IF( LT_16( shift, gb ) ) { Loading @@ -436,10 +447,10 @@ ivas_error ivas_cpe_enc_fx( *----------------------------------------------------------------*/ #ifdef FIX_2320_OOB_SCE_SWITCHING shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, shl( input_frame, 1 ) ), L_norm_arr( sts[1]->input_buff32_fx, shl( input_frame, 1 ) ) ); shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, input_frame_2 ), L_norm_arr( sts[1]->input_buff32_fx, input_frame_2 ) ); q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); scale_sig32( sts[1]->input_buff32_fx, shl( input_frame, 1 ), sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ scale_sig32( sts[0]->input_buff32_fx, shl( input_frame, 1 ), sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ scale_sig32( sts[1]->input_buff32_fx, input_frame_2, sub( q_min, sts[1]->q_inp32 ) ); /* q_min */ scale_sig32( sts[0]->input_buff32_fx, input_frame_2, sub( q_min, sts[0]->q_inp32 ) ); /* q_min */ #else shift = s_min( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ) ); q_min = add( sts[0]->q_inp32, sub( shift, find_guarded_bits_fx( input_frame ) ) ); Loading @@ -455,10 +466,10 @@ ivas_error ivas_cpe_enc_fx( stereo_tca_enc_fx( hCPE, input_frame ); #ifdef FIX_2320_OOB_SCE_SWITCHING shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, shl( input_frame, 1 ) ), sts[0]->q_inp32 ), 16 ); shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, shl( input_frame, 1 ) ), sts[1]->q_inp32 ), 16 ) ); Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, shl( input_frame, 1 ), sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, shl( input_frame, 1 ), sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, input_frame_2 ), sts[0]->q_inp32 ), 16 ); shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, input_frame_2 ), sts[1]->q_inp32 ), 16 ) ); Copy_Scale_sig32_16( sts[0]->input_buff32_fx, sts[0]->input_buff_fx, input_frame_2, sub( add( Q16, shift ), sts[0]->q_inp32 ) ); // shift Copy_Scale_sig32_16( sts[1]->input_buff32_fx, sts[1]->input_buff_fx, input_frame_2, sub( add( Q16, shift ), sts[1]->q_inp32 ) ); // shift #else shift = sub( add( L_norm_arr( sts[0]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[0]->q_inp32 ), 16 ); shift = s_min( shift, sub( add( L_norm_arr( sts[1]->input_buff32_fx, L_FRAME48k + L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) ), sts[1]->q_inp32 ), 16 ) ); Loading Loading @@ -728,12 +739,9 @@ ivas_error ivas_cpe_enc_fx( move16(); /* Determine the energy ratio between the 2 channels */ tdm_ratio_idx = stereo_tdm_ener_analysis_fx( ivas_format, hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Q0 */ tdm_ratio_idx = stereo_tdm_ener_analysis_fx( ivas_format, hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM ); /* Q0 */ /* Compute the downmix signal based on the ratio index */ Word16 tdm_SM_flag; IF( hCPE->hStereoTD->tdm_LRTD_flag == 0 ) { Loading Loading @@ -855,11 +863,19 @@ ivas_error ivas_cpe_enc_fx( // Normalise the input buffer from Q15 Word16 input_norm, q_inp; //, common_q, fir_delay_len; #ifdef FIX_2320_OOB_SCE_SWITCHING input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, input_frame_2 ); #else input_norm = L_norm_arr( sts[0]->input32_fx - input_frame, shl( input_frame, 1 ) ); #endif q_inp = sub( add( Q15, input_norm ), 16 ); // Rescale the old input, input and FIR delay section of input buffer #ifdef FIX_2320_OOB_SCE_SWITCHING Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, input_frame_2, sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp #else Copy_Scale_sig32_16( sts[0]->input32_fx - input_frame, sts[0]->input_fx - input_frame, shl( input_frame, 1 ), sub( add( Q16, q_inp ), Q15 ) ); // Q15 -> q_inp #endif // Update the Q-factors sts[0]->q_inp = q_inp; Loading Loading @@ -1207,7 +1223,7 @@ ivas_error ivas_cpe_enc_fx( } } FOR( Word16 i = 0; i < CPE_CHANNELS; i++ ) FOR( i = 0; i < CPE_CHANNELS; i++ ) { Copy_Scale_sig_16_32_no_sat( old_inp_12k8_16fx[i], old_inp_12k8_fx[i], L_INP_12k8, Q16 ); // Q(-1) -> Q15 } Loading