From 1e7ee47fc869b903dfe212e3ecea76c7f49e36dd Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 27 Aug 2025 11:09:02 +0200 Subject: [PATCH] maintenance --- apps/decoder.c | 4 +- lib_com/bitalloc_fx.c | 13 +- lib_com/cng_exc_fx.c | 35 +- lib_com/common_api_types.h | 40 +- lib_com/disclaimer.c | 2 +- lib_com/edct_fx.c | 43 +- lib_com/fd_cng_com_fx.c | 12 +- lib_com/ivas_cnst.h | 414 ++-- lib_com/ivas_dirac_com_fx.c | 23 +- lib_com/ivas_filters_fx.c | 27 +- lib_com/ivas_prot_fx.h | 1256 +++++++------ lib_com/ivas_rom_com.c | 1 + lib_com/ivas_rom_com_fx.c | 1 - lib_com/ivas_rotation_com.c | 33 +- lib_com/ivas_tools_fx.c | 7 + lib_com/lpc_tools_fx.c | 6 +- lib_com/lsf_tools_fx.c | 2 +- lib_com/prot_fx.h | 1672 ++++++++++------- lib_com/swb_tbe_com_fx.c | 4 +- lib_com/tcx_utils_fx.c | 24 +- lib_com/tools.c | 4 +- lib_dec/FEC_adapt_codebook_fx.c | 14 +- lib_dec/FEC_pitch_estim_fx.c | 7 +- lib_dec/LD_music_post_filter_fx.c | 7 +- lib_dec/arith_coder_dec_fx.c | 7 +- lib_dec/dec_tcx_fx.c | 9 +- lib_dec/dlpc_avq_fx.c | 7 +- lib_dec/fd_cng_dec_fx.c | 14 +- lib_dec/gs_dec_amr_wb_fx.c | 3 +- lib_dec/hq_env_dec_fx.c | 18 +- lib_dec/ivas_binRenderer_internal_fx.c | 51 +- lib_dec/ivas_dirac_dec_fx.c | 115 +- lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 9 +- lib_dec/ivas_init_dec_fx.c | 88 +- lib_dec/ivas_ism_dec_fx.c | 12 +- lib_dec/ivas_ism_dtx_dec_fx.c | 4 +- lib_dec/ivas_ism_param_dec_fx.c | 2 +- lib_dec/ivas_ism_renderer_fx.c | 8 +- lib_dec/ivas_jbm_dec_fx.c | 2 + lib_dec/ivas_lfe_dec_fx.c | 4 +- lib_dec/ivas_masa_dec_fx.c | 13 +- lib_dec/ivas_mc_paramupmix_dec_fx.c | 2 +- lib_dec/ivas_mct_dec_fx.c | 22 +- lib_dec/ivas_mct_dec_mct_fx_fx.c | 2 +- lib_dec/ivas_mdct_core_dec_fx.c | 2 +- lib_dec/ivas_mono_dmx_renderer_fx.c | 4 +- lib_dec/ivas_objectRenderer_internal_fx.c | 1 + lib_dec/ivas_omasa_dec_fx.c | 2 +- lib_dec/ivas_osba_dec_fx.c | 17 +- lib_dec/ivas_qmetadata_dec_fx.c | 2 +- lib_dec/ivas_rom_dec_fx.c | 6 - lib_dec/ivas_sba_dec_fx.c | 10 +- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 2 + lib_dec/ivas_stereo_cng_dec_fx.c | 4 +- lib_dec/ivas_stereo_dft_plc_fx.c | 4 +- lib_dec/ivas_stereo_icbwe_dec_fx.c | 5 +- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 10 +- lib_dec/ivas_stereo_switching_dec_fx.c | 2 - lib_dec/lib_dec.h | 14 +- lib_dec/lib_dec_fx.c | 10 +- lib_dec/lsf_dec_fx.c | 5 +- lib_dec/pit_dec_fx.c | 10 +- lib_dec/pitch_extr_fx.c | 6 +- lib_dec/rom_dec_fx.c | 49 +- lib_enc/acelp_core_switch_enc_fx.c | 3 + lib_enc/avq_cod_fx.c | 30 +- lib_enc/cod2t32_fx.c | 14 +- lib_enc/cod4t64_fx.c | 143 +- lib_enc/enc_acelp_fx.c | 56 +- lib_enc/enc_acelpx_fx.c | 26 +- lib_enc/enc_gen_voic_fx.c | 1 + lib_enc/enc_higher_acelp_fx.c | 37 +- lib_enc/enc_pit_exc_fx.c | 26 +- lib_enc/enc_tran_fx.c | 13 + lib_enc/enc_uv_fx.c | 28 +- lib_enc/ext_sig_ana_fx.c | 30 +- lib_enc/find_tilt_fx.c | 5 +- lib_enc/gain_enc_fx.c | 52 +- lib_enc/hq_core_enc_fx.c | 4 +- lib_enc/hq_lr_enc_fx.c | 34 +- lib_enc/init_enc_fx.c | 6 +- lib_enc/inov_enc_fx.c | 7 +- lib_enc/ivas_dirac_enc_fx.c | 4 +- lib_enc/ivas_enc_fx.c | 2 +- lib_enc/ivas_front_vad_fx.c | 2 +- lib_enc/ivas_init_enc_fx.c | 29 +- lib_enc/ivas_ism_enc_fx.c | 1 - lib_enc/ivas_mcmasa_enc_fx.c | 22 +- lib_enc/ivas_mct_enc_mct_fx.c | 8 +- lib_enc/ivas_mdct_core_enc_fx.c | 10 +- lib_enc/ivas_omasa_enc_fx.c | 15 +- lib_enc/ivas_osba_enc_fx.c | 9 +- lib_enc/ivas_pca_enc_fx.c | 4 +- lib_enc/ivas_qmetadata_enc_fx.c | 4 +- lib_enc/ivas_spar_encoder_fx.c | 7 +- lib_enc/ivas_stereo_dft_enc_fx.c | 2 +- lib_enc/ivas_stereo_ica_enc_fx.c | 42 +- lib_enc/ivas_stereo_icbwe_enc_fx.c | 4 +- lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 18 +- lib_enc/ivas_stereo_switching_enc_fx.c | 2 +- lib_enc/ivas_td_low_rate_enc_fx.c | 3 + lib_enc/lp_exc_e_fx.c | 45 +- lib_enc/lsf_enc_fx.c | 36 +- lib_enc/pit_enc_fx.c | 109 +- lib_enc/prot_fx_enc.h | 1465 ++++++++------- lib_enc/pvq_encode_fx.c | 2 +- lib_enc/stat_enc.h | 2 - lib_enc/swb_tbe_enc_fx.c | 83 +- lib_enc/vad_param_updt_fx.c | 3 +- lib_isar/isar_splitRendererPLC.c | 4 +- lib_isar/lib_isar_post_rend.c | 8 +- lib_isar/lib_isar_pre_rend.c | 6 +- lib_rend/ivas_crend_fx.c | 5 +- lib_rend/ivas_dirac_ana_fx.c | 6 +- .../ivas_dirac_dec_binaural_functions_fx.c | 38 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 80 +- lib_rend/ivas_dirac_rend_fx.c | 2 +- lib_rend/ivas_efap_fx.c | 15 +- lib_rend/ivas_mcmasa_ana_fx.c | 29 +- lib_rend/ivas_objectRenderer_fx.c | 14 +- lib_rend/ivas_objectRenderer_sources_fx.c | 82 +- lib_rend/ivas_omasa_ana_fx.c | 23 +- lib_rend/ivas_output_init_fx.c | 2 +- lib_rend/ivas_prot_rend_fx.h | 274 +-- lib_rend/ivas_reverb_fx.c | 19 +- lib_rend/ivas_reverb_iir_filter_fx.c | 4 +- lib_rend/ivas_rom_rend.h | 8 +- lib_rend/ivas_rom_rend_fx.c | 8 +- lib_rend/ivas_stat_rend.h | 69 +- lib_rend/ivas_td_decorr_fx.c | 2 +- lib_rend/lib_rend.h | 2 +- lib_rend/lib_rend_fx.c | 30 +- 132 files changed, 3968 insertions(+), 3418 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 320b30909..8a8ec02af 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -87,8 +87,8 @@ typedef struct uint16_t count; uint16_t selected; uint16_t frameCounter; -} AcousticEnvironmentSequence; +} AcousticEnvironmentSequence; typedef struct { @@ -481,6 +481,7 @@ int main( fprintf( stderr, "Failed to get Distance Attenuation \n\n" ); goto cleanup; } + if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { if ( asked_frame_size != IVAS_RENDER_FRAMESIZE_20MS && @@ -2476,7 +2477,6 @@ static ivas_error decodeG192( cleanup: RenderConfigReader_close( &renderConfigReader ); - split_rend_reader_writer_close( &splitRendWriter ); AudioFileWriter_close( &afWriter ); MasaFileWriter_close( &masaWriter ); diff --git a/lib_com/bitalloc_fx.c b/lib_com/bitalloc_fx.c index 2b630cf21..6d6c44842 100644 --- a/lib_com/bitalloc_fx.c +++ b/lib_com/bitalloc_fx.c @@ -230,13 +230,12 @@ void bitalloc_fx( *-------------------------------------------------------------------*/ Word16 BitAllocF_fx( - Word16 *y, /* i : norm of sub-vectors :Q0 */ - Word32 bit_rate, /* i : bitrate :Q0 */ - Word16 B, /* i : number of available bits :Q0 */ - Word16 N, /* i : number of sub-vectors :Q0 */ - Word16 *R, /* o : bit-allocation indicator :Q0 */ - Word16 *Rsubband_fx /* o : sub-band bit-allocation vector :Q3 */ - , + Word16 *y, /* i : norm of sub-vectors :Q0 */ + Word32 bit_rate, /* i : bitrate :Q0 */ + Word16 B, /* i : number of available bits :Q0 */ + Word16 N, /* i : number of sub-vectors :Q0 */ + Word16 *R, /* o : bit-allocation indicator :Q0 */ + Word16 *Rsubband_fx, /* o : sub-band bit-allocation vector :Q3 */ const Word16 hqswb_clas, /* i : hq swb class :Q0 */ const Word16 num_env_bands /* i : Number sub bands to be encoded for HF GNERIC :Q0 */ ) diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index 6296b406c..d884abb94 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -1046,24 +1046,23 @@ void cng_params_upd_fx( } void cng_params_upd_ivas_fx( - const Word16 lsp_new[], /* i : LSP aprameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer Q(6+shift) */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate /* i : Last active bit rate Q0 */ - , - const Word16 element_mode, /* i : Element mode */ - const Word16 bwidth /* i : Audio bandwidth */ + const Word16 lsp_new[], /* i : LSP aprameters Q15 */ + const Word16 exc2[], /* i : current enhanced excitation Q_exc */ + const Word16 L_frame, /* i : frame length Q0 */ + Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ + Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ + Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ + Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ + const Word16 Q_exc, /* i : Q value of excitation */ + const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ + Word32 ho_env_circ[], /* i/o: Envelope buffer Q(6+shift) */ + Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ + Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ + Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ + Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ + const Word32 last_active_brate, /* i : Last active bit rate Q0 */ + const Word16 element_mode, /* i : Element mode */ + const Word16 bwidth /* i : Audio bandwidth */ ) { Word32 L_ener, L_tmp; diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 66f2c2d74..a9b34314f 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -222,7 +222,7 @@ typedef struct _IVAS_JBM_TRACE_DATA *----------------------------------------------------------------------------------*/ #define ISAR_MAX_SPLIT_REND_BITRATE 768000 -#define ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (int32_t) ISAR_MAX_SPLIT_REND_BITRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) +#define ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES ( ( ( (Word32) ISAR_MAX_SPLIT_REND_BITRATE / IVAS_NUM_FRAMES_PER_SEC ) + 7 ) >> 3 ) #define ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ 1 #define SPLIT_REND_BITS_BUFF_SIZE ( ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES + ISAR_SPLIT_REND_ADDITIONAL_BYTES_TO_READ ) @@ -266,36 +266,36 @@ typedef enum typedef struct _ISAR_SPLIT_REND_BITS_DATA { - uint8_t *bits_buf; - int32_t buf_len; /*size of bits_buf in bytes. This field should be set by allocator of bits_buf*/ - int32_t bits_written; - int32_t bits_read; - int16_t codec_frame_size_ms; + UWord8 *bits_buf; + Word32 buf_len; /*size of bits_buf in bytes. This field should be set by allocator of bits_buf*/ + Word32 bits_written; + Word32 bits_read; + Word16 codec_frame_size_ms; ISAR_SPLIT_REND_CODEC codec; ISAR_SPLIT_REND_POSE_CORRECTION_MODE pose_correction; - int16_t isar_frame_size_ms; - int16_t lc3plus_highres; + Word16 isar_frame_size_ms; + Word16 lc3plus_highres; } ISAR_SPLIT_REND_BITS_DATA, *ISAR_SPLIT_REND_BITS_HANDLE; typedef struct _ISAR_SPLIT_REND_CONFIG { - int32_t splitRendBitRate; /*Bit rate for split rendering mode, if "pcm_out" is set then "splitRendBitRate" is used as a limit for MD bitrate */ - int16_t hq_mode; /*High quality 3DOF mode with additional side information. Requires more pre-renditions. */ - int16_t dof; /*flag to specify if pose correction is needed for 1, 2 or 3 degree of freedoms*/ - /*The axis can be set dynamically per frame based on a file input */ - /*possible values: + Word32 splitRendBitRate; /*Bit rate for split rendering mode, if "pcm_out" is set then "splitRendBitRate" is used as a limit for MD bitrate */ + Word16 hq_mode; /*High quality 3DOF mode with additional side information. Requires more pre-renditions. */ + Word16 dof; /*flag to specify if pose correction is needed for 1, 2 or 3 degree of freedoms*/ + /*The axis can be set dynamically per frame based on a file input */ + /*possible values: 1 - (1dof correction. By default YAW correction) 2 - (2dof correction. By default YAW and PITCH correction) 3 - (3dof correction. By default YAW, PITCH and ROLL correction) */ - int16_t codec_delay_ms; /* look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/ - int16_t isar_frame_size_ms; /* ISAR bit stream frame size in milliseconds */ - int16_t codec_frame_size_ms; /* Codec frame size in milliseconds, only relevant with LC3plus */ + Word16 codec_delay_ms; /* look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/ + Word16 isar_frame_size_ms; /* ISAR bit stream frame size in milliseconds */ + Word16 codec_frame_size_ms; /* Codec frame size in milliseconds, only relevant with LC3plus */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode; ISAR_SPLIT_REND_CODEC codec; ISAR_SPLIT_REND_RENDERER_SELECTION rendererSelection; - int16_t lc3plus_highres; + Word16 lc3plus_highres; } ISAR_SPLIT_REND_CONFIG_DATA, *ISAR_SPLIT_REND_CONFIG_HANDLE; @@ -348,9 +348,9 @@ typedef struct _IVAS_RENDER_CONFIG typedef struct { - int16_t numSamplesPerChannel; - int16_t numChannels; - int16_t is_cldfb; + Word16 numSamplesPerChannel; + Word16 numChannels; + Word16 is_cldfb; } IVAS_REND_AudioBufferConfig; diff --git a/lib_com/disclaimer.c b/lib_com/disclaimer.c index 0f4c3ef65..80b25ce45 100644 --- a/lib_com/disclaimer.c +++ b/lib_com/disclaimer.c @@ -40,7 +40,7 @@ #define WMC_TOOL_SKIP -int16_t print_disclaimer( FILE *fPtr ) +Word16 print_disclaimer( FILE *fPtr ) { fprintf( fPtr, "\n==================================================================================================\n" ); diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index 244d69381..ad5f6a78b 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -603,7 +603,7 @@ void iedct_short_fx( return; } -#define FAST_EDXT /* optimized FFT-based DCT/DST algorithm */ + /*-------------------------------------------------------------------------* * edxt_fx() * @@ -739,7 +739,6 @@ void edxt_fx( move16(); } -#ifdef FAST_EDXT test(); IF( EQ_16( kernelType, MDST_II ) || EQ_16( kernelType, MDCT_II ) ) { @@ -913,47 +912,7 @@ void edxt_fx( } } } -#endif -#ifdef IVAS_FLOAT_FIXED_TO_BE_DONE - ELSE - /* TODO: below IF and ELSE blocks are unreachable, verified on code coverage report */ - IF( s_and( kernelType, 1 ) ) /* DST */ - { - const float offK = ( kernelType == MDST_II && synthesis ? 0.5f : 1.0f - 0.5f * ( kernelType >> 1 ) ); - const float offM = ( kernelType == MDST_II && synthesis ? 1.0f : 0.5f ); - - FOR( k = 0; k < length; k++ ) - { - y[k] = 0.f; - FOR( m = 0; m < length; m++ ) - { - y[k] += x[m] * sinf( pi_len * ( m + offM ) * ( k + offK ) ); - } - } - IF( offK == 1.f ) - { - y[length - 1] *= 0.5f; /* scale Nyquist sample */ - } - } - ELSE /* kernelType 0, 2: DCT */ - { - const float offK = ( EQ_16( kernelType, MDCT_II ) && synthesis ? 0.5f : 0.5f - shr( shr( kernelType, 1 ), 1 ) ); - const float offM = ( EQ_16( kernelType, MDCT_II ) && synthesis ? 0.0f : 0.5f ); - FOR( k = 0; k < length; k++ ) - { - y[k] = 0.f; - FOR( m = 0; m < length; m++ ) - { - y[k] += x[m] * cosf( pi_len * ( m + offM ) * ( k + offK ) ); - } - } - IF( offK == 0.f ) - { - y[0] *= 0.5f; /* scale lowest (i.e. DC) sample */ - } - } -#endif // IVAS_FLOAT_FIXED_TO_BE_DONE /*v_multc(y, (kernelType == MDCT_II ? -1.f : 1.f) * sqrtf(2.f / length), y, length);*/ fac = get_edxt_factor( length ); /* Q15 */ if ( EQ_16( kernelType, MDCT_II ) ) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 6666f9091..878a591a8 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -3355,8 +3355,8 @@ void SynthesisSTFT_fx( } /* Get time-domain signal */ // v_multc(olapBuffer + hFdCngCom->frameSize / 4, (float)(hFdCngCom->fftlen / 2), timeDomainOutput, hFdCngCom->frameSize); - v_multc_fixed( olapBuffer + hFdCngCom->frameSize / 4, fftScale, timeDomainOutput, hFdCngCom->frameSize ); // Q_in - 9 - /* Get excitation */ + v_multc_fx( olapBuffer + hFdCngCom->frameSize / 4, fftScale, timeDomainOutput, hFdCngCom->frameSize ); // Q_in - 9 + /* Get excitation */ test(); test(); IF( ( EQ_16( element_mode, IVAS_CPE_TD ) || EQ_16( element_mode, IVAS_CPE_DFT ) ) && EQ_16( nchan_out, 2 ) ) @@ -3367,12 +3367,12 @@ void SynthesisSTFT_fx( move32(); } // v_multc(buf, (float)(hFdCngCom->fftlen / 2), buf, M + 1 + hFdCngCom->frameSize); - v_multc_fixed( buf_fx, fftScale, buf_fx, add( M + 1, hFdCngCom->frameSize ) ); + v_multc_fx( buf_fx, fftScale, buf_fx, add( M + 1, hFdCngCom->frameSize ) ); } ELSE { // v_multc(olapBuffer + hFdCngCom->frameSize / 4 - (M + 1), (float)(hFdCngCom->fftlen / 2), buf, M + 1 + hFdCngCom->frameSize); - v_multc_fixed( olapBuffer + sub( shr( hFdCngCom->frameSize, 2 ), ( M + 1 ) ), fftScale, buf_fx, add( M + 1, hFdCngCom->frameSize ) ); + v_multc_fx( olapBuffer + sub( shr( hFdCngCom->frameSize, 2 ), ( M + 1 ) ), fftScale, buf_fx, add( M + 1, hFdCngCom->frameSize ) ); } tmp_fx = buf_fx[0]; @@ -3447,10 +3447,10 @@ void SynthesisSTFT_dirac_fx( } /* Get time-domain signal */ - v_multc_fixed( olapBuffer + shr( hFdCngCom->frameSize, 2 ), fftScale, timeDomainOutput, samples_out ); // Q_in - 9 + v_multc_fx( olapBuffer + shr( hFdCngCom->frameSize, 2 ), fftScale, timeDomainOutput, samples_out ); // Q_in - 9 /* Get excitation */ - v_multc_fixed( olapBuffer + sub( shr( hFdCngCom->frameSize, 2 ), ( M + 1 ) ), fftScale, buf, add( M + 1, hFdCngCom->frameSize ) ); + v_multc_fx( olapBuffer + sub( shr( hFdCngCom->frameSize, 2 ), ( M + 1 ) ), fftScale, buf, add( M + 1, hFdCngCom->frameSize ) ); tmp = buf[0]; move32(); preemph_ivas_fx( buf + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp ); diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 86bf5d28d..668fd6682 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -44,45 +44,31 @@ * mathematical constants *----------------------------------------------------------------------------------*/ -#define PI_OVER_2 ( EVS_PI / 2.0f ) -#define PI_OVER_180 ( EVS_PI / 180.0f ) #define ONE_BY_PI_OVER_180_Q25 ( 1922527360 ) // Q25 -#define PI_OVER_180_Q22 ( 73204 ) // Q22 -#define _180_OVER_PI ( 180.0f / EVS_PI ) -#define _180_OVER_PI_Q25 ( 1922527338 ) // Q25 -#define PI_OVER_180_Q25 ( 585635 ) // Q25 +#define PI_OVER_180_Q22 ( 73204 ) // ( EVS_PI / 180.0f ) in Q22 +#define _180_OVER_PI_Q25 ( 1922527338 ) // ( 180.0f / EVS_PI ) in Q25 +#define PI_OVER_180_Q25 ( 585635 ) // ( EVS_PI / 180.0f ) in Q25 #define _180_IN_Q22 ( 754974720 ) // Q22 #define _360_IN_Q22 ( 1509949440 ) // Q22 -#define _180_OVER_PI_FX ( 58670 ) // Q10 -#define PI_OVER_180_Q15 ( 572 ) // Q15 -#define _180_OVER_PI_Q9 ( 29335 ) // Q9 +#define _180_OVER_PI_FX ( 58670 ) // ( 180.0f / EVS_PI ) in Q10 +#define PI_OVER_180_Q15 ( 572 ) // ( EVS_PI / 180.0f ) in Q15 +#define _180_OVER_PI_Q9 ( 29335 ) // ( 180.0f / EVS_PI ) in Q9 #define PI_OVER_4_Q29 ( 421657440 ) // Q29 -#define _180_OVER_PI_Q9 ( 29335 ) // Q9 #define PI_OVER_Q29 ( 1686629760 ) // Q29 #define Q31_0_99 ( 2126008811 ) // Q31 #define Q31_0_01 ( 21474836 ) // Q31 #define PI_OVER_180_FX ( 37480660 ) // Q31 #define PI_OVER_4_Q29 ( 421657440 ) // Q29 -#define PI_OVER_Q29 ( 1686629760 ) // Q29 #define PI2_C_ADP_RATE_Q31 ( 449767936 ) // Q31 (2.0f * EVS_PI * pOTR->centerAdaptationRate) #define PI2_C_Q28 ( 1686629760 ) // Q28 #define OFF_C_ADP_RATE_Q31 ( 268435456 ) // Q31 #define C_ADP_RATE_Q31 ( 71582792 ) // Q31 - -#define SQRT2 1.414213562373095f -#define SQRT2_FIXED 1518500250 // Q30 -#define SQRT2_OVER_2 (SQRT2 / 2.0f) -#define SQRT2_OVER_2_FIXED 1518500250 // Q31 - -#define INV_SQRT2 7.071067811865475e-1f /* 1/sqrt(2) */ -#define INV_SQRT3 0.577350269189626f /* 1/sqrt(3) */ -#define INV_SQRT2_FX ( 1518500224 ) /* 1/sqrt(2) in Q31 */ - -#define INV_SQRT2_FX_Q15 ( 23170 ) /* 1/sqrt(2) Q15 */ -#define INV_SQRT3_FX ( 18918 ) /* 1/sqrt(3) Q15 */ - -#define LOG_10 2.30258509299f +#define SQRT2_FIXED 1518500250 /* 1.414213562373095f in Q30 */ +#define SQRT2_OVER_2_FIXED 1518500250 /* (SQRT2 / 2.0f) in Q31 */ +#define INV_SQRT2_FX 1518500224 /* 1/sqrt(2) in Q31 */ +#define INV_SQRT2_FX_Q15 23170 /* 1/sqrt(2) Q15 */ +#define INV_SQRT3_FX 18918 /* 1/sqrt(3) Q15 */ /*----------------------------------------------------------------------------------* @@ -341,36 +327,24 @@ typedef enum #define ADJUST_ISM_BRATE_POS 8000 #define ISM_AZIMUTH_NBITS 7 -#define ISM_AZIMUTH_MIN -180.0f -#define ISM_AZIMUTH_MAX 180.0f -#define ISM_AZIMUTH_MIN_FX ( -754974720 ) // Q22 -#define ISM_AZIMUTH_MAX_FX ( 754974720 ) // Q22 -#define ISM_AZIMUTH_LOW_BORDER -140.0f -#define ISM_AZIMUTH_HIGH_BORDER 135.0f -#define ISM_AZIMUTH_LOW_BORDER_FX ( -587202560 ) // Q22 -#define ISM_AZIMUTH_HIGH_BORDER_FX ( 566231040 ) // Q22 +#define ISM_AZIMUTH_MIN_FX -754974720 /* -180.0f in Q22 */ +#define ISM_AZIMUTH_MAX_FX 754974720 /* 180.0f in Q22 */ +#define ISM_AZIMUTH_LOW_BORDER_FX -587202560 /* -140.0f in Q22 */ +#define ISM_AZIMUTH_HIGH_BORDER_FX 566231040 /* 135.0f in Q22 */ #define ISM_ELEVATION_NBITS 6 -#define ISM_ELEVATION_MIN -90.0f -#define ISM_ELEVATION_MAX 90.0f -#define ISM_ELEVATION_MIN_FX ( -377487360 ) // Q22 -#define ISM_ELEVATION_MAX_FX ( 377487360 ) // Q22 -#define ISM_ELEVATION_LOW_BORDER -70.0f -#define ISM_ELEVATION_HIGH_BORDER 65.0f -#define ISM_ELEVATION_LOW_BORDER_FX ( -293601280 ) // Q22 -#define ISM_ELEVATION_HIGH_BORDER_FX ( 272629760 ) // Q22 -#define ISM_Q_STEP 2.5f -#define ISM_Q_STEP_FX ( 10485760 ) // Q22 -#define ISM_Q_STEP_BORDER 5.0f -#define ISM_Q_STEP_BORDER_FX ( 20971520 ) // Q22 +#define ISM_ELEVATION_MIN_FX -377487360 /* -90.0f in Q22 */ +#define ISM_ELEVATION_MAX_FX 377487360 /* 90.0f in Q22 */ +#define ISM_ELEVATION_LOW_BORDER_FX -293601280 /* -70.0f in Q22 */ +#define ISM_ELEVATION_HIGH_BORDER_FX 272629760 /* 65.0f in Q22 */ +#define ISM_Q_STEP_FX 10485760 /* 2.5f in Q22 */ +#define ISM_Q_STEP_BORDER_FX 20971520 /* 5.0f in Q22 */ #define ISM_FEC_MAX 10 #define ISM_RADIUS_NBITS 6 -#define ISM_RADIUS_MIN 0.0f -#define ISM_RADIUS_MIN_Q9 0 -#define ISM_RADIUS_DELTA 0.25f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */ -#define ISM_RADIUS_DELTA_Q8 64 // Q8 +#define ISM_RADIUS_MIN_Q9 0 /* 0.0f in Q9 */ +#define ISM_RADIUS_DELTA_Q8 64 /* 0.25f in Q8 */ #define ISM_EXTENDED_METADATA_BRATE IVAS_64k #define ISM_METADATA_IS_NDP_BITS 1 #define ISM_EXTENDED_METADATA_BITS 1 @@ -389,24 +363,24 @@ typedef enum #define PARAM_ISM_MAX_CHAN 16 #define PARAM_ISM_HYS_BUF_SIZE 10 -#define STEP_PARAM_ISM_POW_RATIO_NBITS_Q31 (306783378) /* 1.0f / (float)((1 << PARAM_ISM_POW_RATIO_NBITS) - 1) */ +#define STEP_PARAM_ISM_POW_RATIO_NBITS_Q31 306783378 /* 1.0f / (float)((1 << PARAM_ISM_POW_RATIO_NBITS) - 1) */ /* ISM DTX */ -#define ISM_Q_STEP_FX ( 10485760 ) // Q22 -#define ISM_Q_STEP_BORDER_FX ( 20971520 ) // Q22 +#define ISM_Q_STEP_FX 10485760 /* Q22 */ +#define ISM_Q_STEP_BORDER_FX 20971520 /* Q22 */ #define ISM_DTX_COH_SCA_BITS 4 #define ISM_DTX_AZI_BITS_HIGH 8 #define ISM_DTX_ELE_BITS_HIGH 7 #define ISM_Q_STEP_HIGH (ISM_Q_STEP / 2) #define ISM_Q_STEP_BORDER_HIGH (ISM_Q_STEP_BORDER / 2) -#define ISM_Q_STEP_HIGH_FX ( 5 * ( 1 << ( 22 - 2 ) ) ) // Q22 -#define ISM_Q_STEP_BORDER_HIGH_FX ( 5 * ( 1 << ( 22 - 1 ) ) ) // Q22 +#define ISM_Q_STEP_HIGH_FX ( 5 * ( 1 << ( 22 - 2 ) ) ) /* Q22 */ +#define ISM_Q_STEP_BORDER_HIGH_FX ( 5 * ( 1 << ( 22 - 1 ) ) ) /* Q22 */ #define ISM_DTX_AZI_BITS_LOW 6 #define ISM_DTX_ELE_BITS_LOW 5 #define ISM_Q_STEP_LOW (ISM_Q_STEP * 2) #define ISM_Q_STEP_BORDER_LOW (ISM_Q_STEP_BORDER * 2) -#define ISM_Q_STEP_LOW_FX ( 5 * (1 << 22) ) // Q22 -#define ISM_Q_STEP_BORDER_LOW_FX ( 10 * (1 << 22) ) // Q22 +#define ISM_Q_STEP_LOW_FX ( 5 * (1 << 22) ) /* Q22 */ +#define ISM_Q_STEP_BORDER_LOW_FX ( 10 * (1 << 22) ) /* Q22 */ /* ISM modes */ typedef enum @@ -555,9 +529,6 @@ enum #define STEREO_DFT_ENC_DFT_NB ( STEREO_DFT_OFFSET + 1 ) /*frame + lookahead*/ #define STEREO_DFT_DEC_DFT_NB ( STEREO_DFT_NBDIV + STEREO_DFT_OFFSET ) /*frame + lookahead*/ -#define STEREO_CNA_LR_CORR_LT_FILT 0.95f /* long-term averaging factor for L/R correlation estimation */ -#define STEREO_CNA_ILD_LT_FILT 0.9f /* long-term averaging factor for ILD estimation */ - typedef enum { DFT_STEREO_DEC_ANA_NOCORE = -1, /*-1: signal read from file (DEBUG mode)*/ @@ -570,17 +541,15 @@ typedef enum } DFT_STEREO_DEC_ANA_TYPE; /*Stereo parameters*/ - #define STEREO_DFT_ERB4_BANDS 14 #define STEREO_DFT_ERB8_BANDS 8 #define STEREO_DFT_BAND_MAX ( STEREO_DFT_ERB4_BANDS - 1 ) /*Maximum number of parameter bands*/ #define STEREO_DFT_BUF_MAX STEREO_DFT32MS_N_MAX * STEREO_DFT_NBDIV - #define STEREO_DFT_NRG_PAST_LEN 3 /*ITD*/ #define STEREO_DFT_ITD_FS 32000 -#define STEREO_DFT_ITD_MAX 160 /*samples @ 32000*/ +#define STEREO_DFT_ITD_MAX 160 /*samples @ 32000*/ #define STEREO_DFT_ITD_MAX_ANA 200 #define STEREO_DFT_ITD_MIN max( STEREO_DFT_ITD_MAX - 256 + 1, 1 ) /*STEREO_DFT_ITD_MAX-pow(2,STEREO_DFT_ITD_NBITS-1)+1*/ #define STEREO_DFT_ITD_NBITS 9 /* 1 bit for sign, the rest for the absolute value*/ @@ -592,11 +561,10 @@ typedef enum #define STEREO_DFT_FLAG_BITS 1 #define STEREO_DFT_SIDEGAIN_NBITS 5 #define STEREO_DFT_FEC_THRESHOLD 10 -#define STEREO_DFT_FEC_THRESHOLD_PLUS_1_INV_Q31 ( 195225786 ) // Q31 -#define STEREO_DFT_BITDIFF_LP_FAC_Q31 ( 128849019 ) // Q31 /* Low-pass filter coefficient for filtering bit difference between absolute and differential coding */ -#define STEREO_DFT_BITDIFF_ABS_SELECT_Q31 ( 1717986918 ) // Q31 /* Constant to set tendency for selecting absolute coding mode */ -#define STEREO_DFT_BITDIFF_INIT (12.0f) /* Init value for low-pass bit difference */ -#define STEREO_DFT_BITDIFF_INIT_FX (12288) // Q10 /* Init value for low-pass bit difference in Q10*/ +#define STEREO_DFT_FEC_THRESHOLD_PLUS_1_INV_Q31 195225786 /* Q31 */ +#define STEREO_DFT_BITDIFF_LP_FAC_Q31 128849019 /* Low-pass filter coefficient for filtering bit difference between absolute and differential coding, Q31 */ +#define STEREO_DFT_BITDIFF_ABS_SELECT_Q31 1717986918 /* Constant to set tendency for selecting absolute coding mode, Q31 */ +#define STEREO_DFT_BITDIFF_INIT_FX 12288 /* Init value for low-pass bit difference, 12.0f in Q10*/ #define STEREO_DFT_SIDE_GAIN_NBITS 5 #define STEREO_DFT_IPD_NBITS 3 @@ -617,9 +585,8 @@ typedef enum #define STEREO_DFT_SG_ACT_CNT_MAX 1500 #define STEREO_DFT_COH_MAXBAND 6 #define STEREO_DFT_SID_GIPD_NBITS 2 -#define STEREO_DFT_FD_FILT 0.9f -#define STEREO_DFT_FD_FILT_Q31 1932735283 // Q31 -#define STEREO_DFT_FD_FILT_COMP_Q31 214748364 // Q31 /* 1.0 - STEREO_DFT_FD_FILT */ +#define STEREO_DFT_FD_FILT_Q31 1932735283 /* 0.9f in Q31 */ +#define STEREO_DFT_FD_FILT_COMP_Q31 214748364 /* 1.0 - STEREO_DFT_FD_FILT in Q31 */ #define STEREO_DFT_CNG_ITD_CNT 8 @@ -645,17 +612,15 @@ typedef enum #define STEREO_DFT_RES_GAINS_BITS 3 #define STEREO_DFT_RES_COD_SNR_MIN 10 -#define STEREO_DFT_RES_COD_SNR_MIN_Q25 335544320 // Q25 +#define STEREO_DFT_RES_COD_SNR_MIN_Q25 335544320 /* Q25 */ #define STEREO_DFT_RES_COD_SNR_MAX 40 -#define STEREO_DFT_RES_COD_SNR_MAX_Q25 1342177280 // Q25 +#define STEREO_DFT_RES_COD_SNR_MAX_Q25 1342177280 /* Q25 */ #define STEREO_DFT_L_SUBFR_8k 32 #define STEREO_DFT_NBPSF_PIT_MAX_8k NBPSF_PIT_MAX / 2 /* Residual coding BPF */ -#define STEREO_DFT_BPF_ADAPT_ALPHA (0.61f) -#define STEREO_DFT_BPF_ADAPT_BETA (0.68f) -#define STEREO_DFT_BPF_ADAPT_ALPHA_FX (19988) /* STEREO_DFT_BPF_ADAPT_ALPHA in Q15 */ -#define STEREO_DFT_BPF_ADAPT_BETA_FX (22281) /* STEREO_DFT_BPF_ADAPT_BETA in Q15 */ +#define STEREO_DFT_BPF_ADAPT_ALPHA_FX 19988 /* 0.61f in Q15 */ +#define STEREO_DFT_BPF_ADAPT_BETA_FX 22281 /* 0.68f in Q15 */ /* Golomb-Rice encoding */ #define NO_SYMB_GR_SIDE_G 31 @@ -729,10 +694,8 @@ enum #define ECSQ_VECTOR_SIZE_MAX 256 #define ECSQ_GLOBAL_GAIN_INDEX_ALL_ZERO 127 /* indicates that all values in the vector are zero */ -#define ECLVQ_GLOBAL_GAIN_FACTOR ( 20.0f * 127.0f / 90.0f ) -#define ECLVQ_GLOBAL_GAIN_FACTOR_Q26 1893961218 // Q26 -#define ECLVQ_INV_GLOBAL_GAIN_FACTOR ( 1.0f / ( 20.0f * 127.0f / 90.0f ) ) -#define ECLVQ_INV_GLOBAL_GAIN_FACTOR_Q24 594468 // Q24 +#define ECLVQ_GLOBAL_GAIN_FACTOR_Q26 1893961218 /* ( 20.0f * 127.0f / 90.0f ) in Q26 */ +#define ECLVQ_INV_GLOBAL_GAIN_FACTOR_Q24 594468 /* ( 1.0f / ( 20.0f * 127.0f / 90.0f ) ) in Q24 */ /* the currently defined configuration indexes are: 0: un-optimized using uniform 4 bit parameters (reserved) @@ -825,12 +788,10 @@ enum fea_names #define STEREO_BITS_TCA_CHAN 1 /* ref/target channel index */ #define STEREO_BITS_TCA_CORRSTATS 5 /* target corrStats */ #define STEREO_BITS_TCA_GD 5 /* target gain */ -#define STEREO_TCA_GDMIN -1.0f -#define STEREO_TCA_GDMIN_FX -32768 // Q15 -#define STEREO_TCA_GDSTEP 0.05f -#define STEREO_TCA_GDSTEP_FX 819 // Q14 -#define STEREO_TCA_GDMIN_FX_Q14 (-16384) // Q14 -#define STEREO_TCA_GDSTEP_FX_Q13 (410) // Q13 +#define STEREO_TCA_GDMIN_FX -32768 /* -1.0f in Q15 */ +#define STEREO_TCA_GDSTEP_FX 819 /* 0.05f in Q14 */ +#define STEREO_TCA_GDMIN_FX_Q14 -16384 /* -1.0fin Q14 */ +#define STEREO_TCA_GDSTEP_FX_Q13 410 /* 0.05f in Q13 */ #define STEREO_BITS_TCA ( STEREO_BITS_TCA_CHAN + STEREO_BITS_TCA_CORRSTATS + STEREO_BITS_TCA_GD ) #define STEREO_ICBWE_MSFLAG_BITS 1 /* BWE Multi Source flag */ @@ -846,14 +807,14 @@ enum fea_names #define MAX_DELAYREGLEN 12 /* max regression length */ #define INV_MAX_DELAYREGLEN 0.083333333333333f /* (1/MAX_DELAYREGLEN) */ -#define INV_MAX_DELAYREGLEN_FX_Q15 2731 // Q15 /* (1/MAX_DELAYREGLEN) */ +#define INV_MAX_DELAYREGLEN_FX_Q15 2731 /* (1/MAX_DELAYREGLEN) in Q15 */ #define MAX_INTERPOLATE 11 #define ADDED_MEM_DS 40 #define STEREO_L_TCA_OVLP_NS 5000000L /* overlap length of the ICA gain scaling */ +#define STEREO_DMX_GAIN_Q13 29066 /* Q13, calculated this -->"powf( 10, ( ( 1 << STEREO_BITS_TCA_GD ) - 1 ) * STEREO_TCA_GDSTEP + STEREO_TCA_GDMIN )"*/ -#define STEREO_DMX_GAIN_Q13 29066 // Q13 /* calculated this -->"powf( 10, ( ( 1 << STEREO_BITS_TCA_GD ) - 1 ) * STEREO_TCA_GDSTEP + STEREO_TCA_GDMIN )"*/ /*----------------------------------------------------------------------------------* * TD Stereo Constants *----------------------------------------------------------------------------------*/ @@ -914,8 +875,7 @@ enum fea_names #define SNS_CDBKS_BITS_4_FRAC 12 #define SNS_MEANS_BITS_4_FRAC 14 -#define MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG 0.001f -#define MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG_Q31 2147483 // Q31 +#define MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG_Q31 2147483 /* 0.001f in Q31 */ #define MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME 2 * FRAMES_PER_SEC #define MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN 20 #define MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE 3 @@ -1013,47 +973,36 @@ typedef enum #define DIRAC_DIFF_NUM_AMBI_COMP 4 #define DIRAC_HOA_RENDERING_NUM_VIRT_DECORR_LS 8 -#define DIRAC_GAIN_LIMIT 31.622776601683793f /* 30db gain limitiation */ -#define DIRAC_GAIN_LIMIT_Q26 ( 2122168614 ) // Q26 /* 30db gain limitiation */ +#define DIRAC_GAIN_LIMIT_Q26 2122168614 /* 30db gain limitiation, 31.622776601683793f in Q26 */ #define DIRAC_MAX_NUM_DECORR_FILTERS 22 #define DIRAC_MAX_DECORR_FILTER_LEN 20 #define DIRAC_DECORR_NUM_SPLIT_BANDS 3 #define DIRAC_DECORR_FILTER_LEN_1 15 #define DIRAC_DECORR_FILTER_LEN_2 6 #define DIRAC_DECORR_FILTER_LEN_3 3 -#define DIRAC_ONSET_ALPHA 0.95f -#define DIRAC_ONSET_BETA 0.995f -#define DIRAC_ONSET_GAIN 4.0f -#define DIRAC_ONSET_ALPHA_FX 31129 // Q15 -#define DIRAC_ONSET_BETA_FX 32604 // Q15 -#define ONE_DIRAC_ONSET_BETA_FX 163 // Q15 -#define DIRAC_ONSET_GAIN_FX 16384 // Q12 +#define DIRAC_ONSET_ALPHA_FX 31129 /* 0.95f in Q15 */ +#define DIRAC_ONSET_BETA_FX 32604 /* 0.995f in Q15 */ +#define ONE_DIRAC_ONSET_BETA_FX 163 /* Q15 */ +#define DIRAC_ONSET_GAIN_FX 16384 /* 0.995f in Q12 */ #define DELAY_DIRAC_ENC_CMP_NS 9500000L /* Delay to be compensated on DirAC encoder */ -#define DELAY_DIRAC_SPAR_ENC_CMP_NS 500000L /* here we may set the 24 samples (at 48 kHz) additional delay to something else, leave as is for now*/ +#define DELAY_DIRAC_SPAR_ENC_CMP_NS 500000L /* here we may set the 24 samples (at 48 kHz) additional delay to something else, leave as is for now*/ #define DELAY_DIRAC_PARAM_DEC_SFR 2 /* Delay to be compensation for DirAC parameters in the decoder (subframes) */ #define DELAY_MASA_PARAM_DEC_SFR 2 /* Delay to be compensation for MASA parameters in the decoder (subframes) */ -#define SPH_IDX_FRONT ( MASA_NO_POINTS_EQUATOR / 2 ) /* Spherical index corresponding to front direction for setting as default value */ +#define SPH_IDX_FRONT ( MASA_NO_POINTS_EQUATOR / 2 ) /* Spherical index corresponding to front direction for setting as default value */ #define DIRAC_SLOT_NS 1250000L /* time duration of a time slot, 1.25ms (==DELAY_RENERER_NS/MAX_PARAM_SPATIAL_SUBFRAMES) */ #define DIRAC_SLOT_ENC_NS 5000000L -#define DIRAC_MONO_THRESH_SILENCE 3e4f -#define DIRAC_MONO_NORM_FACTOR 1e13f -#define DIRAC_MONO_ONE_ON_NORM_FACTOR (1.f / 1e13f) -#define DIRAC_MONO_MAX_THRESH 1e6f -#define DIRAC_MONO_MIN_THRESH 1e2f -#define DIRAC_MONO_FRAME_THRESH 15 /* 30ms */ - - -#define DIRAC_MONO_THRESH_SILENCE_FX (Word32)3e4 -#define DIRAC_MONO_NORM_FACTOR_FX (Word64)1e13 -#define DIRAC_MONO_ONE_ON_NORM_FACTOR_FX (Word64)1/1e13 -#define DIRAC_MONO_MAX_THRESH_FX (Word32)1e6 -#define DIRAC_MONO_MIN_THRESH_FX (Word32)1e2 -#define DIRAC_MONO_NORM_FACTOR_M 1220703104 -#define DIRAC_MONO_NORM_FACTOR_E 44 +#define DIRAC_MONO_FRAME_THRESH 15 /* 30ms */ +#define DIRAC_MONO_THRESH_SILENCE_FX (Word32)3e4 +#define DIRAC_MONO_NORM_FACTOR_FX (Word64)1e13 +#define DIRAC_MONO_ONE_ON_NORM_FACTOR_FX (Word64)1/1e13 +#define DIRAC_MONO_MAX_THRESH_FX (Word32)1e6 +#define DIRAC_MONO_MIN_THRESH_FX (Word32)1e2 +#define DIRAC_MONO_NORM_FACTOR_M 1220703104 +#define DIRAC_MONO_NORM_FACTOR_E 44 typedef enum { @@ -1088,18 +1037,13 @@ typedef enum #define IVAS_SPAR_ARITH_OVERSHOOT_BITS 16 /* Common SPAR metadata constants */ -#define IVAS_ACTIVEW_DM_F_SCALE 0.5f -#define IVAS_ACTIVEW_DM_F_SCALE_FX (1073741824) /* 0.5f in Q31 */ -#define IVAS_ACTIVEW_DM_F_SCALE_DTX 0.25f -#define IVAS_ACTIVEW_DM_F_SCALE_DTX_FX (536870912) /* 0.25f in Q31 */ -#define IVAS_ACTIVEW_DM_F_SCALE_VLBR 0.25f -#define IVAS_ACTIVEW_DM_F_SCALE_VLBR_FX (536870912) /* 0.25f in Q31 */ +#define IVAS_ACTIVEW_DM_F_SCALE_FX 1073741824 /* 0.5f in Q31 */ +#define IVAS_ACTIVEW_DM_F_SCALE_DTX_FX 536870912 /* 0.25f in Q31 */ +#define IVAS_ACTIVEW_DM_F_SCALE_VLBR_FX 536870912 /* 0.25f in Q31 */ #define IVAS_SPAR_FOA_DFLT_FREQ_PER_CHAN 24000 -#define IVAS_SPAR_DYN_ACTIVEW_THRESH (0.0039f) -#define IVAS_SPAR_DYN_ACTIVEW_THRESH_FX (8375186) /* 0.0039f in Q31 */ -#define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH (32.0f) -#define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH_Q0 (32) +#define IVAS_SPAR_DYN_ACTIVEW_THRESH_FX 8375186 /* 0.0039f in Q31 */ +#define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH_Q0 32 #define MAX_QUANT_STRATS 3 #define MAX_CODING_STRATS 3 @@ -1154,13 +1098,10 @@ enum #define IVAS_APD_8_SECT 8 #define IVAS_APD_16_SECT 16 -#define IVAS_DECORR_PARM_LOOKAHEAD_TAU 2e-3f -#define IVAS_DECORR_PARM_APD_TAU 42949673 // Q31 +#define IVAS_DECORR_PARM_APD_TAU 42949673 /* Q31 */ /* IVAS SBA PCA */ -#define IVAS_PCA_NB_SUBR 20 /* 80 -> 0.25 ms, 40 -> 0.5 ms... */ -#define IVAS_PCA_COV_THRES 3e-5f -#define IVAS_PCA_QUAT_EPS 1e-7f +#define IVAS_PCA_NB_SUBR 20 /* 80 -> 0.25 ms, 40 -> 0.5 ms... */ #define IVAS_PCA_QBITS 19 #define IVAS_PCA_N1 91 #define IVAS_PCA_N1_EQ ( (IVAS_PCA_N1-1)/2 ) @@ -1170,15 +1111,10 @@ enum #define IVAS_PCA_LEN_INTERP_Q ( IVAS_PCA_INTERP * IVAS_PCA_N_SLOTS ) #define IVAS_PCA_DELAY_CMP 24 #define IVAS_PCA_LEN_INTERP_EIG_DEC ( (IVAS_PCA_N_SLOTS+IVAS_PCA_DELAY_CMP)*16) -#define IVAS_PCA_THRES_MIN_DOT 0.8f -#define IVAS_PCA_THRES_MIN_DOT2 0.0f -#define IVAS_PCA_THRES_DIST_ALT 6.0f - -#define IVAS_PCA_QUAT_EPS_FX 215 // Q31 -#define IVAS_PCA_THRES_MIN_DOT_FX 1717986918 // 0.8 in Q31 +#define IVAS_PCA_QUAT_EPS_FX 215 /* 1e-7f in Q31 */ +#define IVAS_PCA_THRES_MIN_DOT_FX 1717986918 /* 0.8 in Q31 */ #define IVAS_PCA_THRES_MIN_DOT2_FX 0 -#define IVAS_PCA_THRES_DIST_ALT_FX 1610612736 // 6 in Q28 - +#define IVAS_PCA_THRES_DIST_ALT_FX 1610612736 /* 6 in Q28 */ typedef enum { @@ -1220,6 +1156,7 @@ enum TOTAL_DECD_QUANT_STRATS }; + /*----------------------------------------------------------------------------------* * MASA constants *----------------------------------------------------------------------------------*/ @@ -1240,13 +1177,12 @@ enum #define MASA_TRANSP_BITS 1 #define NO_BITS_MASA_ISM_NO_OBJ 2 -#define MASA2TOTAL_THR_Q30 1052266987 // 0.98f in Q30 +#define MASA2TOTAL_THR_Q30 1052266987 /* 0.98f in Q30 */ //Maximum error in float to fixed conversion : 0.005% //Assuming the accuracy of 99.995% //New value = 99.995 / 100 * 0.98 = 0.979951 #define BITS_MASA2TOTTAL_DCT0 6 -#define STEP_M2T 0.1f -#define STEP_M2T_FX 214748365 // Q31 +#define STEP_M2T_FX 214748365 /* 0.1f in Q31 */ #define MASA_HEADER_BITS 2 #define MASA_SUBFRAME_BITS 1 #define MASA_LOWBITRATE_MODE_BITS 1 @@ -1286,16 +1222,11 @@ enum #define LIMIT_ER_SIMPLE_ENC 6 #define LIMIT_USE_COMMON 3 -#define MASA_COHERENCE_TOLERANCE 0.1f -#define MASA_COHERENCE_THRESHOLD 0.1f -#define MASA_COHERENCE_TOLERANCE_FX 3277/*0.1 Q15*/ -#define MASA_COHERENCE_THRESHOLD_FX 214748365 // 0.1 in Q31 -#define MASA_RATIO_TOLERANCE 0.1f -#define MASA_RATIO_THRESHOLD 0.1f -#define MASA_ANGLE_TOLERANCE 0.5f -#define MASA_RATIO_THRESHOLD_FX 32212255 // 0.015 in Q31 -#define MASA_RATIO_TOLERANCE_FX 107374182 // 0.1 in Q30 -#define MASA_ANGLE_TOLERANCE_FX ONE_IN_Q21 // 0.5 in Q22 +#define MASA_COHERENCE_TOLERANCE_FX 3277 /* 0.1 Q15 */ +#define MASA_COHERENCE_THRESHOLD_FX 214748365 /* 0.1 in Q31 */ +#define MASA_RATIO_THRESHOLD_FX 32212255 /* 0.015 in Q31 */ +#define MASA_RATIO_TOLERANCE_FX 107374182 /* 0.1 in Q30 */ +#define MASA_ANGLE_TOLERANCE_FX ONE_IN_Q21 /* 0.5 in Q22 */ #define MASA_LIMIT_NO_BANDS_SUR_COH 8 #define MINIMUM_BIT_BUDGET_NORMAL_META 100 #define DIFF_DFRATIO_2BIT_LIMIT_IDX_HODIRAC 4 @@ -1309,16 +1240,11 @@ enum #define MASA_NO_POINTS_EQUATOR 430 #define MASA_NO_CIRCLES 121 -#define MASA_NO_CIRCLES_Q23 ( 1015021568 ) // Q23 -#define MASA_ASIN_OFFSET 0.0064471690266724975f -#define MASA_ASIN_OFFSET_Q15 ( 211 ) // Q15 -#define MASA_NTOT2_FAC 32768.00566947353f -#define MASA_NTOT2_FAC_Q15 ( 1073741952 ) // Q15 -#define MASA_ANGLE_AT_EQUATOR 0.012894427382667f -#define MASA_ANGLE_AT_EQUATOR_Q31 ( 27690572 ) // Q31 -#define MASA_ANGLE_AT_EQUATOR_DEG 0.738796268264740f -#define MASA_ANGLE_AT_EQUATOR_DEG_Q31 ( 1586552905l ) // Q31 -#define MASA_INV_ANGLE_AT_EQUATOR_DEG 1.353553128183453f +#define MASA_NO_CIRCLES_Q23 1015021568 /* Q23 */ +#define MASA_ASIN_OFFSET_Q15 211 /* 0.0064471690266724975f in Q15 */ +#define MASA_NTOT2_FAC_Q15 1073741952 /* 32768.00566947353f in Q15 */ +#define MASA_ANGLE_AT_EQUATOR_Q31 27690572 /* 0.012894427382667f in Q31 */ +#define MASA_ANGLE_AT_EQUATOR_DEG_Q31 1586552905l /* 0.738796268264740f in Q31 */ #define MASA_STEREO_MIN_BITRATE IVAS_24k4 #define MAXIMUM_OMASA_FREQ_BANDS 8 /* Corresponds to maximum number of coding bands at 32 kbps */ #define OMASA_STEREO_SW_CNT_MAX 100 @@ -1327,12 +1253,12 @@ enum #define NBITS_HR_COH 4 #define OMASA_TDREND_MATCHING_GAIN_FX 26026 -#define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30 (1453366656l) +#define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30 1453366656l /* 1.353553128183453f in Q30 */ #define MASA_JBM_RINGBUFFER_FRAMES 3 -#define TOLERANCE_360_Q22 1510033326 /* 360 in Q22 + 0.02 in Q22*/ -#define MINUS_TOLERANCE_360_Q22 -1510033326 /* - (360 in Q22 + 0.02 in Q22) */ +#define TOLERANCE_360_Q22 1510033326 /* 360 in Q22 + 0.02 in Q22*/ +#define MINUS_TOLERANCE_360_Q22 -1510033326 /* - (360 in Q22 + 0.02 in Q22) */ typedef enum { MASA_STEREO_NOT_DEFINED, @@ -1381,40 +1307,33 @@ typedef enum #define MCMASA_SEPARATE_BRATE IVAS_64k /* minimum bitrate from which separated channel coding is supported */ #define MCMASA_MAX_ANA_CHANS 11 /* Maximum number of channels currently used in analysis of multichannel formats */ -#define MCMASA_MONOBITRATIO_64k_Q31 ( 536870912 ) // Q31 -#define MCMASA_MONOBITRATIO_Q31 ( 644245095 ) // Q31 +#define MCMASA_MONOBITRATIO_64k_Q31 536870912 /* Q31 */ +#define MCMASA_MONOBITRATIO_Q31 644245095 /* Q31 */ #define MC_MASA_THR_ELEVATION 40 -#define MCMASA_LFE_QLOW -6.5f -#define MCMASA_LFE_DELTA 1.0f -#define MCMASA_LFE_1BIT_THRES 0.03f -#define MCMASA_LFE_ALPHA 0.67f -#define MCMASA_LFE_BETA 0.09f -#define MCMASA_LFE_1BIT_THRES_Q30 32212255 /* 0.03f in Q30 */ -#define MCMASA_LFE_ALPHA_Q30 719407022 /* 0.67f in Q30 */ -#define MCMASA_LFE_BETA_Q30 96636764 /* 0.09f in Q30 */ -#define MCMASA_LFE_THETA 1.3f -#define MCMASA_LFE_SYNTH_ALPHA 0.95f /* Smoothing coefficient for LFE synthesis */ -#define MCMASA_LFE_SYNTH_ALPHA_Q15 (31129) // Q15 -#define MCMASA_LFE_ALPHA_Q15 (21954) // Q15 -#define MCMASA_LFE_BETA_Q15 (2949) // Q15 -#define MCMASA_LFE_BETA_Q14 (1474) // Q14 -#define MCMASA_LFE_THETA_Q14 (21299) // Q14 -#define MCMASA_LFE_QLOW_Q12 (-26624) // Q12 -#define MCMASA_LFE_DELTA_Q11 (2048) // Q11 -#define MCMASA_LFE_QLOW_Q11 (-13312) // Q11 -#define MCMASA_LFE_DELTA_Q10 (1024) // Q10 +#define MCMASA_LFE_1BIT_THRES_Q30 32212255 /* 0.03f in Q30 */ +#define MCMASA_LFE_ALPHA_Q30 719407022 /* 0.67f in Q30 */ +#define MCMASA_LFE_BETA_Q30 96636764 /* 0.09f in Q30 */ +#define MCMASA_LFE_SYNTH_ALPHA_Q15 31129 /* 0.95f in Q15 */ +#define MCMASA_LFE_ALPHA_Q15 21954 /* 0.67f in Q15 */ +#define MCMASA_LFE_BETA_Q15 2949 /* 0.09f in Q15 */ +#define MCMASA_LFE_BETA_Q14 1474 /* 0.09f in Q14 */ +#define MCMASA_LFE_THETA_Q14 21299 /* 1.3f in Q14 */ +#define MCMASA_LFE_QLOW_Q12 -26624 /* -6.5f in Q12 */ +#define MCMASA_LFE_DELTA_Q11 2048 /* 1.0f in Q11 */ +#define MCMASA_LFE_QLOW_Q11 -13312 /* -6.5f in Q11 */ +#define MCMASA_LFE_DELTA_Q10 1024 /* 1.0f in Q10 */ #define NUM_ELEVATED_SPEAKERS 4 #define MCMASA_MIN_SPEAKERS_SEPARATE_CENTER 4 + /*----------------------------------------------------------------------------------* * MCT constants *----------------------------------------------------------------------------------*/ #define LFE_CHANNEL 3 -#define MIN_LFE_NRG 0.5f #define MCT_MAX_CHANNELS MAX_TRANSPORT_CHANNELS #define MCT_MAX_BLOCKS ( MCT_MAX_CHANNELS / CPE_CHANNELS ) /* max. number of channel pairs (MCT_MAX_CHANNELS/2) within MCT*/ @@ -1425,23 +1344,17 @@ typedef enum #define MCT_NUM_BLOCK_DATA_BITS 4 -/*typedef enum -{ - MCT_CHAN_MODE_REGULAR, - MCT_CHAN_MODE_IGNORE -} MCT_CHAN_MODE;*/ - /*----------------------------------------------------------------------------------* * MC Param-Upmix Mode Constants *----------------------------------------------------------------------------------*/ -#define MC_PARAMUPMIX_MAX_TRANSPORT_CHANS 8 -#define MC_PARAMUPMIX_MAX_INPUT_CHANS 12 -#define MC_PARAMUPMIX_MAX_BITS 1024 /* Maximum number of bits for the MC Param-Upmix metadata */ -#define MC_PARAMUPMIX_COMBINATIONS 4 /* number of sets of 2 channels combined */ -#define MC_PARAMUPMIX_NCH 2 /* number of channels to combine into 1 */ -#define MC_PARAMUPMIX_MIN_CLDFB 8 +#define MC_PARAMUPMIX_MAX_TRANSPORT_CHANS 8 +#define MC_PARAMUPMIX_MAX_INPUT_CHANS 12 +#define MC_PARAMUPMIX_MAX_BITS 1024 /* Maximum number of bits for the MC Param-Upmix metadata */ +#define MC_PARAMUPMIX_COMBINATIONS 4 /* number of sets of 2 channels combined */ +#define MC_PARAMUPMIX_NCH 2 /* number of channels to combine into 1 */ +#define MC_PARAMUPMIX_MIN_CLDFB 8 typedef enum _COV_SMOOTHING_TYPE { @@ -1493,11 +1406,8 @@ typedef enum PARAM_MC_SYNTH_MONO_STEREO /* synthesis to mono or stereo */ } PARAM_MC_SYNTHESIS_CONF; -#define PARAM_MC_REG_SX_FX (429496729) // Q31 /* Regularization factor for mixing matrix calculation */ -#define PARAM_MC_REG_GHAT_FX (2147483) // Q31 /* Regularization factor for mixing matrix calculation */ - -#define PARAM_MC_REG_SX (0.2f) /* Regularization factor for mixing matrix calculation */ -#define PARAM_MC_REG_GHAT (0.001f) /* Regularization factor for mixing matrix calculation */ +#define PARAM_MC_REG_SX_FX 429496729 /* Regularization factor for mixing matrix calculation, (0.2f) in Q31 */ +#define PARAM_MC_REG_GHAT_FX 2147483 /* Regularization factor for mixing matrix calculation, (0.001f) in Q31 */ #define PARAM_MC_MAX_PARAMETER_BANDS 20 /* Maximum number of parameter bands */ #define PARAM_MC_MAX_PARAMETER_BANDS_RES 14 /* Maximum number of parameter bands with decorrelation */ #define PARAM_MC_MAX_NSLOTS MAX_JBM_CLDFB_TIMESLOTS /* Maximum number of CLDFB slots in a frame */ @@ -1505,7 +1415,6 @@ typedef enum #define PARAM_MC_NSUBFRAMES_DEC 4 /* Number of subframes for the synthesis in the decoder */ #define PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND 30 /* Maximum number of CLDFB frequency bands within a parameter band */ #define PARAM_MC_PARAMETER_FRAMES 2 /* Number of frames a parameter set for a parameter band is used*/ -#define PARAM_MC_ICC_ERROR_BIAS_FAC (1.15f) /* factor for favouring past ICC maps in the adaptive ICC map decision */ #define PARAM_MC_TRANSIENT_BAND_STEP 2 /* Number of parameter bands combined in case of a transient frame*/ #define PARAM_MC_MAX_DECORR_CLDFB_BANDS 20 /* Maximum number of CLDFB bands with decorrelation */ #define PARAM_MC_MAX_TRANSPORT_CHANS 3 /* Number of down mix channels */ @@ -1520,27 +1429,23 @@ typedef enum #define PARAM_MC_NUM_BITS_ICC_SCALAR_QUANT 3 /* Number of bits for ICC uniform coding */ #define PARAM_MC_SZ_ILD_QUANTIZER_4BITS 16 /* Length of the ILD quantizer for Parametric MC */ #define PARAM_MC_NUM_BITS_ILD_SCALAR_QUANT 4 /* Number of bits for ILD uniform coding */ -#define PARAM_MC_DEFAULT_MIN_ILD (-92.0f) /* Default relative channel level for untransmitted channel energies */ -#define PARAM_MC_DEFAULT_MIN_ILD_FX (-23552) // Q8 /* Default relative channel level for untransmitted channel energies */ +#define PARAM_MC_DEFAULT_MIN_ILD_FX (-23552) /* Default relative channel level for untransmitted channel energies, (-92.0f) in Q8 */ #define PARAM_MC_MAX_BITS 1024 /* Maximum number of bits for the Parametric MC metadata */ #define PARAM_MC_MAX_BAND_ABS_COV_ENC 10 #define PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC 10 #define PARAM_MC_MAX_BAND_ABS_COV_DEC 10 -#define PARAM_MC_ENER_LIMIT_INTRAFRAME (1.5f) -#define PARAM_MC_ENER_LIMIT_INTRAFRAME_FX_Q21 3145728 -#define PARAM_MC_ENER_LIMIT_INTERFRAME (2.0f) -#define PARAM_MC_ENER_LIMIT_INTERFRAME_FX_Q21 4194304 -#define PARAM_MC_ENER_LIMIT_MAX_DELTA_FAC (15.0f) -#define PARAM_MC_ENER_LIMIT_MAX_DELTA_FAC_FX_Q21 31457280 -#define PARAM_MC_NUM_ATTACK_ILD_THRESH (3) -#define PARAM_MC_LFE_ON_THRESH (8000.0f) -#define PARAM_MC_LFE_ON_THRESH_FX 8000 // Q0 +#define PARAM_MC_ENER_LIMIT_INTRAFRAME_FX_Q21 3145728 /* (1.5f) in Q21 */ +#define PARAM_MC_ENER_LIMIT_INTERFRAME_FX_Q21 4194304 /* (2.0f) in Q21 */ +#define PARAM_MC_ENER_LIMIT_MAX_DELTA_FAC_FX_Q21 31457280 /* (15.0f) in Q21 */ +#define PARAM_MC_NUM_ATTACK_ILD_THRESH 3 +#define PARAM_MC_LFE_ON_THRESH_FX 8000 /* Q0 */ #define PARAM_MC_BAND_TO_MDCT_BAND_RATIO 16 /* Ratio of resolution of CLDFB Bands to MDCT Bands */ #define PARAM_MC_SLOT_ENC_NS 2500000L #define PARAM_MC_MDFT_NO_SLOTS 8 -#define INV_PARAM_MC_MDFT_NO_SLOTS_FX 4096 // Q15 +#define INV_PARAM_MC_MDFT_NO_SLOTS_FX 4096 /* Q15 */ #define PARAM_MC_CLDFB_TO_MDFT_FAC 2 + /*----------------------------------------------------------------------------------* * LFE Coding Constants *----------------------------------------------------------------------------------*/ @@ -1570,20 +1475,14 @@ typedef enum #define IVAS_LFE_NUM_COEFFS_IN_SUBGRP 2 #define IVAS_LFE_MAX_NUM_DCT_PASS_BINS 8 #define IVAS_LFE_MAX_NUM_DCT_COEFFS (IVAS_LFE_MAX_NUM_DCT_PASS_BINS * IVAS_LFE_NUM_COEFFS_IN_SUBGRP) -#define IVAS_LFE_FADE_NS 8000000L /* 8.0 ms */ -#define IVAS_LFE_FADE_S_Q15 263 /* 8.0 ms in Q15 */ +#define IVAS_LFE_FADE_NS 8000000L /* 8.0 ms */ +#define IVAS_LFE_FADE_S_Q15 263 /* 8.0 ms in Q15 */ #define IVAS_MAX_NUM_QUANT_STRATS 2 #define IVAS_MAX_NUM_DCT_COEF_GROUPS 4 #define IVAS_LFE_SHIFT_BITS 5 #define IVAS_LFE_BITRATE_5000 5000 -#define IVAS_LFE_ABS_SUM_FLT_THR (0.000001f) - -#define IVAS_LFE_ABS_SUM_FLT_THR_Q42 4398047 - - -#define IVAS_ZERO_PAD_LEN_MULT_FAC (0.5f) - -#define IVAS_ZERO_PAD_LEN_MULT_FAC_fx 16384 // 0.5 in Q15 +#define IVAS_LFE_ABS_SUM_FLT_THR_Q42 4398047 /* 0.000001f in Q42 */ +#define IVAS_ZERO_PAD_LEN_MULT_FAC_fx 16384 /* 0.5 in Q15 */ /* LFE PLC */ #define LFE_PLC_BUFLEN 240 @@ -1592,13 +1491,16 @@ typedef enum #define LFE_PLC_LENANA LFE_PLC_BUFLEN #define LFE_PLC_FDEL 300 + /*----------------------------------------------------------------------------------* * HO Dirac Constants *----------------------------------------------------------------------------------*/ -#define HODIRAC_BETA (214748368) /* 0.2f in Q30 */ -#define HODIRAC_FAC1 (951579008) /* 1.772454f in Q29 */ -#define HODIRAC_FAC2 (549393984) /* 1.023326f in Q29 */ -#define HODIRAC_FAC3 (317192992) /* 0.590818f in Q29 */ + +#define HODIRAC_BETA 214748368 /* 0.2f in Q30 */ +#define HODIRAC_FAC1 951579008 /* 1.772454f in Q29 */ +#define HODIRAC_FAC2 549393984 /* 1.023326f in Q29 */ +#define HODIRAC_FAC3 317192992 /* 0.590818f in Q29 */ + /*----------------------------------------------------------------------------------* * Amplitude Panning (EFAP, VBAP) constants @@ -1617,7 +1519,6 @@ typedef enum EFAP_DMX_INTENSITY } EFAP_VTX_DMX_TYPE; - #define VBAP_NUM_SEARCH_SECTORS 4 @@ -1629,8 +1530,8 @@ typedef enum #define BINAURAL_MAXBANDS_Q25 2013265920 /* Max number of bands in Q25 */ #define ONE_BY_48000_Q31 44740 #define BINAURAL_CONVBANDS 50 /* Bands upto which convolution is performed */ -#define BINAURAL_NTAPS 3 -#define BINAURAL_NTAPS_SBA BINAURAL_NTAPS +#define BINAURAL_NTAPS 3 +#define BINAURAL_NTAPS_SBA BINAURAL_NTAPS #define BINAURAL_NTAPS_MAX 96 @@ -1639,9 +1540,8 @@ typedef enum #define HRTF_LS_CHANNELS 15 #define HRTF_NUM_BINS 60 #define REVERB_PREDELAY_MAX 20 /* Max input delay for reverb module */ -#define GAIN_LFE 1.88364911f /* Gain applied to LFE during renderering */ -#define GAIN_LFE_WORD32 2022552831 // Q30 /* Gain applied to LFE during renderering */ -#define GAIN_LFE_FX 30862 // Q14 /* Gain applied to LFE during renderering */ +#define GAIN_LFE_WORD32 2022552831 /* Gain applied to LFE during renderering, 1.88364911f in Q30 */ +#define GAIN_LFE_FX 30862 /* Gain applied to LFE during renderering, 1.88364911f in Q14 */ #define LOW_BIT_RATE_BINAURAL_EQ_BINS 17 /* Number of bins in an EQ applied at low bit rates in binauralization */ #define LOW_BIT_RATE_BINAURAL_EQ_OFFSET 14 /* Offset of bins where the low-bit-rate EQ starts*/ @@ -1663,8 +1563,6 @@ typedef enum #define HEADROT_SHMAT_DIM2 ( HEADROT_SHMAT_DIM * HEADROT_SHMAT_DIM ) - - /*----------------------------------------------------------------------------------* * TD Binaural Object renderer *----------------------------------------------------------------------------------*/ @@ -1683,17 +1581,14 @@ typedef enum #define SFX_SPAT_BIN_NUM_SUBSAMPLES 64 #define ITD_MEM_LEN (MAX_ITD + SFX_SPAT_BIN_SINC_M) #define L_SUBFRAME5MS_48k (L_FRAME48k/4) -#define MAX_ANGULAR_STEP (0.01f) -#define MAX_ANGULAR_STEP_INV ( 1.0f / MAX_ANGULAR_STEP ) #define MAX_INTERPOLATION_STEPS 12 - -#define DEG_360_IN_Q22 ( 360 << Q22 ) // Q22 -#define DEG_180_IN_Q22 ( 180 << Q22 ) // Q22 -#define DEG_90_IN_Q22 ( 90 << Q22 ) // Q22 -#define ONE_BY_360_Q31 ( 5965232 ) // Q31 -#define ONE_BY_360_Q15 ( 91 ) // Q15 -#define ONE_BY_180_Q31 ( 11930465 ) // Q31 +#define DEG_360_IN_Q22 ( 360 << Q22 ) /* Q22 */ +#define DEG_180_IN_Q22 ( 180 << Q22 ) /* Q22 */ +#define DEG_90_IN_Q22 ( 90 << Q22 ) /* Q22 */ +#define ONE_BY_360_Q31 ( 5965232 ) /* Q31 */ +#define ONE_BY_360_Q15 ( 91 ) /* Q15 */ +#define ONE_BY_180_Q31 ( 11930465 ) /* Q31 */ /* ----- Enums - TD Renderer ----- */ @@ -1735,7 +1630,6 @@ typedef enum } SFX_OpMode_t; - /*----------------------------------------------------------------------------------* * Reverberator constants *----------------------------------------------------------------------------------*/ @@ -1753,6 +1647,7 @@ typedef enum #define LR_IAC_LENGTH_NR_FC ( RV_LENGTH_NR_FC ) #define LR_IAC_LENGTH_NR_FC_16KHZ ( RV_LENGTH_NR_FC_16KHZ ) + /*----------------------------------------------------------------------------------* * FB mixer constants *----------------------------------------------------------------------------------*/ @@ -1883,22 +1778,19 @@ typedef enum *----------------------------------------------------------------------------------*/ #define IVAS_LIMITER_THRESHOLD 32729 /* -0.01 dBFS */ -#define IVAS_LIMITER_ATTACK_SECONDS 0.005f /*----------------------------------------------------------------------------------* * Early Reflection constants *----------------------------------------------------------------------------------*/ -#define ER_RADIUS (1.0f) -#define ER_LIST_ORIGIN_X (0.0f) -#define ER_LIST_ORIGIN_Y (0.0f) -#define ER_LIST_HEIGHT (1.6f) -#define ER_RADIUS_FX (1* ONE_IN_Q30) //Q2.30 -#define ER_LIST_ORIGIN_X_FX (0) -#define ER_LIST_ORIGIN_Y_FX (0) -#define ER_LIST_HEIGHT_FX (6710886) /* 1.6 in Q.22 */ - +#define ER_LIST_ORIGIN_X 0.0f +#define ER_LIST_ORIGIN_Y 0.0f +#define ER_LIST_HEIGHT 1.6f +#define ER_RADIUS_FX (1* ONE_IN_Q30) /*Q2.30 */ +#define ER_LIST_ORIGIN_X_FX 0 +#define ER_LIST_ORIGIN_Y_FX 0 +#define ER_LIST_HEIGHT_FX 6710886 /* 1.6f in Q.22 */ /*----------------------------------------------------------------------------------* @@ -1915,8 +1807,8 @@ typedef enum #define STEREO_DMX_EVS_SUBBAND_SIZE 2 #define STEREO_DMX_EVS_NB_SUBBAND_MAX (L_FRAME48k / (2 * STEREO_DMX_EVS_SUBBAND_SIZE)) -#define STEREO_DMX_EVS_PHA_LEN_MAX 96 /* Max of PHA_LEN */ -#define STEREO_DMX_EVS_FAD_LEN_MAX 480 /* Max of FAD_LEN */ +#define STEREO_DMX_EVS_PHA_LEN_MAX 96 /* Max of PHA_LEN */ +#define STEREO_DMX_EVS_FAD_LEN_MAX 480 /* Max of FAD_LEN */ #define STEREO_DMX_EVS_DATA_LEN_MAX (STEREO_DMX_EVS_PHA_LEN_MAX + L_FRAME48k) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 26d58936f..ac21c48b9 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -503,13 +503,13 @@ void ivas_get_dirac_sba_max_md_bits_fx( * * DirAC Configuration function for SBA *------------------------------------------------------------------------*/ + ivas_error ivas_dirac_sba_config_fx( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ Word16 *element_mode, /* i/o: element mode of the core coder */ Word32 sba_total_brate, /* i : SBA total bitrate */ const Word16 sba_order, /* i : Ambisonic (SBA) order */ - const Word16 nbands /* i : number of frequency bands */ - , + const Word16 nbands, /* i : number of frequency bands */ IVAS_FORMAT ivas_format ) { Word16 nbands_coded; @@ -784,7 +784,8 @@ void computeDirectionVectors_fx( * * *------------------------------------------------------------------------*/ -void computeDiffuseness_fixed( + +void computeDiffuseness_fx( Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], // i: Q(q_factor_intensity) const Word32 *buffer_energy, // i: Q(q_factor_energy) const Word16 num_freq_bands, @@ -808,7 +809,6 @@ void computeDiffuseness_fixed( Word16 q_ene, q_intensity; /* Compute Intensity slow and energy slow buffer_intensity and buffer_energy */ - set_zero_fx( intensity_slow, i_mult( DIRAC_NUM_DIMS, CLDFB_NO_CHANNELS_MAX ) ); set_zero_fx( intensity_slow_abs, CLDFB_NO_CHANNELS_MAX ); set_zero_fx( energy_slow, CLDFB_NO_CHANNELS_MAX ); @@ -967,17 +967,20 @@ void computeDiffuseness_fixed( return; } -Word32 deindex_azimuth_fx( /* o : output Q22 */ - Word16 id_phi, /* i : index */ - const Word16 no_bits, /* i : number of bits for the spherical grid */ - const Word16 id_th, /* i : elevation index */ - const Word16 remap, /* i : remapping flag */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ + +/* o : output Q22 */ +Word32 deindex_azimuth_fx( + Word16 id_phi, /* i : index */ + const Word16 no_bits, /* i : number of bits for the spherical grid */ + const Word16 id_th, /* i : elevation index */ + const Word16 remap, /* i : remapping flag */ + const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ ) { Word16 flag_delta; Word32 dd_fx, delta_phi_fx; Word32 phi_hat_fx; + test(); IF( NE_32( mc_format, MC_LS_SETUP_INVALID ) && EQ_16( no_bits, 2 ) ) { diff --git a/lib_com/ivas_filters_fx.c b/lib_com/ivas_filters_fx.c index eca54cc55..02e7b272a 100644 --- a/lib_com/ivas_filters_fx.c +++ b/lib_com/ivas_filters_fx.c @@ -41,28 +41,27 @@ /*------------------------------------------------------------------------------------------* * Local functions declaration *------------------------------------------------------------------------------------------*/ -static void ivas_iir_2_filter_fx( - ivas_filters_process_state_t *filter_state, - Word32 *pIn_Out_fx, // Q(31-*pIn_Out_e) - const Word16 length, - const Word16 stage, - Word16 *pIn_Out_e ); + +static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, const Word16 length, const Word16 stage, Word16 *pIn_Out_e ); + + /*-----------------------------------------------------------------------------------------* * Function ivas_filters_init() * * Initialisation call for filtering a signal *-----------------------------------------------------------------------------------------*/ + void ivas_filters_init_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - const Word32 *filt_coeff_fx, /* i : filter coefficients Q31- *filt_coeff_e */ - const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */ - const Word16 order ) /* i : filter order */ + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + const Word32 *filt_coeff_fx, /* i : filter coefficients Q31- *filt_coeff_e */ + const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */ + const Word16 order ) /* i : filter order */ { Word16 i; + filter_state->order = order; move16(); - test(); IF( EQ_16( order, IVAS_FILTER_ORDER_1 ) ) { @@ -155,6 +154,7 @@ void ivas_filters_init_fx( * * Process call for selecting the type filter *-----------------------------------------------------------------------------------------*/ + void ivas_filter_process_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ @@ -163,6 +163,7 @@ void ivas_filter_process_fx( { Word16 pIn_Out_e[L_FRAME_MAX]; Word16 i; + SWITCH( filter_state->order ) { case IVAS_FILTER_ORDER_1: @@ -195,6 +196,7 @@ void ivas_filter_process_fx( return; } + void ivas_filter_process_exp_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ @@ -227,6 +229,7 @@ void ivas_filter_process_exp_fx( * * Process call for filtering a signal *-----------------------------------------------------------------------------------------*/ + static void ivas_iir_2_filter_fx( ivas_filters_process_state_t *filter_state, Word32 *pIn_Out_fx, // Q(31-*pIn_Out_e) @@ -279,4 +282,6 @@ static void ivas_iir_2_filter_fx( } } } + + return; } diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index b5d06d4b2..df7713905 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -180,7 +180,6 @@ void ivas_omasa_render_objects_from_mix_fx( Word16 *output_q /* i/o: output Q value */ ); - ivas_error ivas_omasa_ism_metadata_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word32 ism_total_brate, /* i : ISM total bitrate */ @@ -231,27 +230,32 @@ void ivas_dct_windowing_fx( const Word16 frame_len, /*Q0*/ Word32 *pOut_buf, // Q10 Word32 *pBuffer_prev, // Q10 - Word32 *pTemp_lfe ); + Word32 *pTemp_lfe +); void ivas_get_twid_factors_fx1( const Word16 length, // Q0 const Word16 **pTwid_re, // Q15 - const Word16 **pTwid_im ); + const Word16 **pTwid_im +); Word32 ivas_get_mdct_scaling_gain_fx( - const Word16 dct_len_by_2 ); + const Word16 dct_len_by_2 +); void ivas_imdct_fx( const Word32 *pIn, // Q24 Word32 *pOut, // q_out Q9 const Word16 length /*Q0*/, - Word16 *q_out ); + Word16 *q_out +); void ivas_mdct_fx( const Word32 *pIn, // q_out Word32 *pOut, // q_out const Word16 length, // Q0 - Word16 *q_out ); + Word16 *q_out +); void ivas_itda_fx( const Word32 *re, /* i : time alised signal after IDCT Q24 */ @@ -265,7 +269,6 @@ void ivas_tda_fx( const Word16 length /* i : length of time alised signal buffer Q0*/ ); -// ivas_agc_dec_fx.c ivas_error ivas_spar_agc_dec_open_fx( ivas_agc_dec_state_t **hAgcDec, /* i/o: SPAR AGC decoder handle */ const Word32 output_Fs /* i : output sampling rate */ @@ -290,16 +293,17 @@ void ivas_agc_read_bits_fx( const Word16 AGC_flag /* i : AGC on/off flag */ ); -// ivas_agc_com_fx.c void ivas_agc_initWindowFunc_fx( Word16 *pWinFunc, // o: Q15 - const Word16 length ); + const Word16 length +); void ivas_agc_calcGainParams_fx( UWord16 *absEmin, // o: Q0 UWord16 *betaE, // o: Q0 UWord16 *maxAttExp, // o: Q0 - const Word16 numCoeffs ); + const Word16 numCoeffs +); void ivas_transient_det_process_fx( ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ @@ -314,28 +318,28 @@ void ivas_td_decorr_get_ducking_gains_fx( Word32 *pIn_duck_gains, Word32 *pOut_duck_gains, const Word16 frame_len, - const Word16 tdet_flag ); + const Word16 tdet_flag +); -// ivas_stereo_eclvq_dec.c void ECSQ_decode( ECSQ_instance *ecsq_inst, const Word16 N, - Word16 *output ); + Word16 *output +); -// bass_psfilter.c Word16 res_bpf_adapt_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo decoder handle */ const Word32 *bpf_error_signal_8k, /* i : BPF modification signal */ Word32 res_buf[STEREO_DFT_N_8k] /* i : residual buffer */ ); -// ivas_sns_com_fx.c void sns_compute_scf_fx( Word32 spectrum[], /* i : Spectrum (Q_in) */ const PsychoacousticParameters *pPsychParams, const Word16 L_frame, Word32 *scf, /* o : Scalefactors (Q16)*/ - Word16 q ); + Word16 q +); void sns_interpolate_scalefactors_fx( Word32 *scf_int, /* o : interpolated scalefactors for spectrum shaping q16*/ @@ -352,7 +356,6 @@ void sns_shape_spectrum_fx( const Word16 L_frame, /* i : frame length */ Word16 *length ); -// ivas_stereo_eclvq_com_fx.c Word32 ECSQ_dequantize_gain_fx( const Word16 index ); @@ -365,12 +368,14 @@ void ECSQ_dequantize_vector_fx( const Word16 *input, /*qx*/ const Word32 global_gain, /*q15*/ const Word16 N, - Word32 *output /*qx*/ ); + Word32 *output /*qx*/ +); void ECSQ_init_instance_fx( ECSQ_instance *ecsq_inst, const Word16 config_index, - void *ac_handle ); + void *ac_handle +); void decoder_tcx_invQ_fx( Decoder_State *st, /* i/o: coder memory state */ @@ -491,6 +496,7 @@ void stereo_dft_dec_update_fx( const Word16 output_frame, /* i : output frame length */ const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ); + void stereo_dft_res_ecu_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ Word32 *pDFT_RES, /* i/o: residual signal */ @@ -504,6 +510,7 @@ void stereo_dft_res_ecu_fx( Word32 *plocsi, /* i/o: Peak locations (fractional) */ Word32 *input_mem /* o : Residual DFT buffer input mem */ ); + void stereo_dft_res_subst_spec_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ Word32 *pDFT_RES, /* i/o: residual signal */ @@ -517,6 +524,7 @@ void stereo_dft_res_subst_spec_fx( Word32 *plocsi, /* i/o: Peak locations (fractional) */ const Word16 analysis_flag /* i : Flag for running peak analysis */ ); + void stereo_dft_res_ecu_burst_att_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ Word32 *pDFT_RES, /* i/o: residual signal /att. residual */ @@ -548,26 +556,30 @@ void stereo_dft_dec_analyze_fx( const Word16 k_offset, /* i : offset of DFT */ const Word16 delay, /* i : delay in samples for input signal */ Word16 *q, - Word16 *q_out_DFT ); + Word16 *q_out_DFT +); void init_basic_allpass_fx( basic_allpass_t *ap, const Word32 *gains_fx, - const Word16 *delays ); + const Word16 *delays +); void filter_with_allpass_fx( const Word32 *sig, /* i : allpass input signal */ Word32 *out, /* o : filtered output */ const Word16 len, /* i : length of input */ basic_allpass_t *ap, /* i/o: basic allpass structure */ - Word16 q_shift ); + Word16 q_shift +); Word32 stereo_dft_dmx_swb_nrg_fx( const Word32 *dmx_k0, /* i : first subframe spectrum */ const Word32 *dmx_k1, /* i : second subframe spectrum */ const Word16 frame_length, /* i : frame lanegth */ const Word16 q0, - const Word16 q1 ); + const Word16 q1 +); void stereo_dft_dec_core_switching_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ @@ -579,7 +591,8 @@ void stereo_dft_dec_core_switching_fx( const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB FOR DFT Stereo */ const Word16 sba_dirac_stereo_dtx_flag, /* i : DTX indicator FOR SBA DirAC stereo */ Word16 *q, - Word16 *q_DFT ); + Word16 *q_DFT +); Word16 ivas_get_hodirac_flag_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ @@ -729,7 +742,8 @@ void ivas_compute_spar_params_enc_fx( Word32 *pWscale, /*q_Wscale*/ Word16 *q_Wscale, const Word16 from_dirac, - const Word16 dyn_active_w_flag ); + const Word16 dyn_active_w_flag +); void ivas_compute_spar_params_fx( Word32 *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], /*q_cov_real*/ @@ -751,7 +765,8 @@ void ivas_compute_spar_params_fx( Word32 *pWscale_fx, /*q_pWscale*/ Word16 *q_pWscale, const Word16 from_dirac, - const Word16 dyn_active_w_flag ); + const Word16 dyn_active_w_flag +); ivas_error ivas_ism_metadata_dec_fx( const Word32 ism_total_brate, /* i : ISM total bitrate */ @@ -792,7 +807,6 @@ void ivas_ism_metadata_sid_dec_fx( Word16 nb_bits_metadata[] /* o : number of metadata bits */ ); -// ivas_sce_dec_fx.c ivas_error create_sce_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 cpe_id, /* i : SCE # identifier */ @@ -819,7 +833,6 @@ ivas_error ivas_sce_dec_fx( const Word16 nb_bits_metadata /* i : number of metadata bits */ ); -// ivas_cpe_dec_fx.c ivas_error create_cpe_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 cpe_id, /* i : CPE # identifier */ @@ -846,12 +859,7 @@ void ivas_post_proc_fx( Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ const Word16 output_frame, /* i : output frame length */ const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - Word16 output_q ); - -// ivas_lfe_dec_fx.c - -void ivas_lfe_dec_close_fx( - LFE_DEC_HANDLE *hLFE /* i/o: LFE encoder handle */ + Word16 output_q ); ivas_error ivas_create_lfe_dec_fx( @@ -894,7 +902,6 @@ void updt_enc_common_ivas_fx( const Word16 Q_new /* i : CUrrent frame scaling */ ); - void updateBuffersForDmxMdctStereo_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ const Word16 output_frame, /* i : output frame length */ @@ -982,7 +989,8 @@ void stereo_dft_enc_analyze_fx( Word32 DFT[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC], /* o : DFT buffers */ Word16 DFT_e[CPE_CHANNELS], /* o : DFT buffers */ Word16 *input_mem[CPE_CHANNELS], /* i/o: input buffer memory */ - Word16 *q_input_mem ); + Word16 *q_input_mem +); Word16 IGF_MapBitRateToIndex( const Word32 brate, /* i : bitrate */ @@ -1022,7 +1030,8 @@ void stereo_td_itd_fx( Encoder_State **sts, /* i/o: Encoder state structure */ const Word16 input_frame, /* i : input frame length */ Word16 *input_mem[CPE_CHANNELS], /* i/o: input buffer memory */ - Word16 *q_input_mem ); + Word16 *q_input_mem +); void stereo_dft_unify_dmx_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder stereo handle */ @@ -1045,7 +1054,8 @@ void stereo_dft_enc_compute_itd_fx( Word32 *bin_nrgL, Word16 *bin_nrgL_e, Word32 *bin_nrgR, - Word16 *bin_nrgR_e ); + Word16 *bin_nrgR_e +); Word16 stereo_dft_band_config_fx( Word16 *band_limits, /* o : DFT band limits */ @@ -1054,7 +1064,6 @@ Word16 stereo_dft_band_config_fx( const Word16 enc_dec /* i : flag to indicate enc vs dec */ ); -// ivas_ls_custom_dec.c void ivas_ls_custom_setup_fx( IVAS_OUTPUT_SETUP_HANDLE hOutSetup, /* o : IVAS output setup handle */ const LSSETUP_CUSTOM_STRUCT *hLsSetupCustom /* i : Custom loudspeaker setup handle */ @@ -1096,7 +1105,8 @@ void ivas_omasa_separate_object_render_jbm_fx( void get_panning_gain_fx( const Word16 sinAngleMapped, - Word16 *panningGains ); + Word16 *panningGains +); void ivas_ism_get_stereo_gains_fx( const Word16 aziDeg, /* i : object azimuth */ @@ -1105,7 +1115,6 @@ void ivas_ism_get_stereo_gains_fx( Word16 *right_gain_fx /* o : right channel gain */ ); -// ivas_mct_dec_mct_fx.c void ivas_mct_dec_mct_fx( MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ Decoder_State **sts, /* i/o: decoder state structure */ @@ -1125,7 +1134,6 @@ void mctStereoIGF_dec_fx( const Word16 bfi /* i : bad frame flag */ ); -// ivas_stereo_mdct_stereo_dec.c void parse_stereo_from_bitstream( STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo decoder structure */ Decoder_State **sts, /* i/o: decoder state structure */ @@ -1159,6 +1167,7 @@ void v_multc_acc_32_16( Word32 y[], /* o : Output vector that contains y + c*x */ const Word16 N /* i : Vector length */ ); + void v_multc_acc_32_32( const Word32 x[], /* i : Input vector */ const Word32 c, /* i : Constant */ @@ -1184,6 +1193,7 @@ void ivas_ism_mono_dmx_fx( Word32 *output_f_fx[], /* i/o: synthesized core-coder transport channels/mono output */ const Word16 output_frame /* i : output frame length */ ); + void ivas_sba_dirac_stereo_smooth_parameters_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */ @@ -1229,7 +1239,6 @@ void stereo_dft_dec_fx( const Word16 num_md_sub_frames /* i : number of MD subframes */ ); -// ivas_stereo_dft_enc.c Word32 stereo_dft_enc_synthesize_fx( STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder stereo handle */ Word32 *output_fx, /* o : output synthesis Q16 */ @@ -1239,7 +1248,8 @@ Word32 stereo_dft_enc_synthesize_fx( const Word32 input_Fs, /* i : input sampling rate */ const Word32 output_sampling_rate, /* i : output sampling rate */ const Word16 L_frame, /* i : frame length at internal Fs */ - Word16 *nrg_out_fx_e ); + Word16 *nrg_out_fx_e +); void ivas_ls_setup_conversion_fx( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ @@ -1298,7 +1308,8 @@ void extend_dctN_input_fx( void ivas_dirac_dec_get_frequency_axis_fx( Word16 *frequency_axis, /* Q0 */ const Word32 output_Fs, - const Word16 num_freq_bands ); + const Word16 num_freq_bands +); void ivas_decision_matrix_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ @@ -1316,7 +1327,8 @@ void cmplx_matrix_square_fx( Word32 *realZ, /* o : real part of the resulting matrix */ Word32 *imagZ, /* o : imaginary part of the resulting matrix */ Word16 input_exp, - Word16 *output_exp ); + Word16 *output_exp +); Word16 matrix_diag_product_fx( const Word32 *X, /* i : left hand matrix */ @@ -1328,7 +1340,8 @@ Word16 matrix_diag_product_fx( Word16 Y_e, const Word16 entriesY, /* i : number of entries in the diagonal */ Word32 *Z, /* o : resulting matrix after the matrix multiplication */ - Word16 *Z_e ); + Word16 *Z_e +); Word16 matrix_diag_product_fx_2( const Word32 *X, /* i : left hand matrix Q31 - X_e*/ @@ -1340,7 +1353,8 @@ Word16 matrix_diag_product_fx_2( const Word16 *Y_e, const Word16 entriesY, /* i : number of entries in the diagonal Q0*/ Word32 *Z, /* o : resulting matrix after the matrix multiplication Q31 - Z_e*/ - Word16 *Z_e ); + Word16 *Z_e +); Word16 matrix_diag_product_fx_1( const Word32 *X, /* i : left hand matrix */ @@ -1352,7 +1366,8 @@ Word16 matrix_diag_product_fx_1( const Word16 *Y_e, const Word16 entriesY, /* i : number of entries in the diagonal */ Word32 *Z, /* o : resulting matrix after the matrix multiplication */ - Word16 *Z_e ); + Word16 *Z_e +); Word16 diag_matrix_product_fx( const Word32 *Y, /* i : left hand diagonal matrix as vector containing the diagonal elements */ @@ -1364,7 +1379,8 @@ Word16 diag_matrix_product_fx( const Word16 colsX, /* i : number of columns of the right hand matrix */ const Word16 transpX, /* i : flag indicating the transposition of the right hand matrix prior to the multiplication */ Word32 *Z, /* o : resulting matrix after the matrix multiplication */ - Word16 *Z_e ); + Word16 *Z_e +); Word16 matrix_product_diag_fx( const Word32 *X, /* i : left hand matrix */ @@ -1473,10 +1489,11 @@ void mdct_read_IGF_bits_fx( Decoder_State *st0 /* i : pointer to handle where bitstream is read */ ); -void IGFDecReadData_ivas_fx( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ - Decoder_State *st, /**< in: | decoder state */ - const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ +void IGFDecReadData_ivas_fx( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ ); void stereo_tca_init_dec_fx( @@ -1514,16 +1531,17 @@ void ivas_get_dirac_sba_max_md_bits_fx( Word16 *metadata_max_bits, Word16 *qmetadata_max_bit_req, const Word16 nbands, - IVAS_FORMAT ivas_format ); + IVAS_FORMAT ivas_format +); ivas_error ivas_dirac_sba_config_fx( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ Word16 *element_mode, /* i/o: element mode of the core coder */ Word32 sba_total_brate, /* i : SBA total bitrate */ const Word16 sba_order, /* i : Ambisonic (SBA) order */ - const Word16 nbands /* i : number of frequency bands */ - , - IVAS_FORMAT ivas_format ); + const Word16 nbands, /* i : number of frequency bands */ + IVAS_FORMAT ivas_format +); ivas_error ivas_dirac_config_fx( void *st_ivas, /* i/o: IVAS encoder/decoder state structure */ @@ -1532,7 +1550,8 @@ ivas_error ivas_dirac_config_fx( void dtx_read_padding_bits_fx( DEC_CORE_HANDLE st, - const Word16 num_bits ); + const Word16 num_bits +); void FdCngEncodeMDCTStereoSID_fx( CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ @@ -1554,7 +1573,8 @@ void FdCngDecodeDiracMDCTStereoSID_fx( void TonalMdctConceal_whiten_noise_shape_ivas_fx( Decoder_State *st, const Word16 L_frame, - const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE whitening_mode ); + const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE whitening_mode +); void stereo_icBWE_dec_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ @@ -1579,7 +1599,8 @@ void decoder_tcx_tns_fx( const Word16 bfi, /* i : Bad frame indicator */ const Word16 frame_cnt, /* i : frame counter in the super frame */ const Word16 whitenedDomain, - Word16 *length ); + Word16 *length +); void ivas_mdct_core_tns_ns_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ @@ -1638,7 +1659,8 @@ void ivas_hq_core_dec_fx( const Word16 hq_core_type, /* i : HQ core type */ const Word16 core_switching_flag, /* i : ACELP->HQ switching frame flag */ Word16 output[], - Word16 *Q_output ); + Word16 *Q_output +); void ivas_HQ_FEC_Mem_update_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -1653,14 +1675,16 @@ void ivas_HQ_FEC_Mem_update_fx( Word16 num_Sb, Word16 *mean_en_high_fx, /*Q5*/ Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */ - Word16 output_frame ); + Word16 output_frame +); -Word16 ivas_hq_classifier_dec_fx( /* o : Consumed bits Q0 */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : Core bit rate Q0 */ - const Word16 length, /* i : Frame length Q0 */ - Word16 *is_transient, /* o : Transient flag Q0 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ +/* o : Consumed bits Q0 */ +Word16 ivas_hq_classifier_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : Core bit rate Q0 */ + const Word16 length, /* i : Frame length Q0 */ + Word16 *is_transient, /* o : Transient flag Q0 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ ); void ivas_hq_hr_dec_fx( @@ -1706,13 +1730,14 @@ void ivas_hq_bit_allocation_fx( const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_GEN Q0 */ ); -Word16 ivas_assign_gain_bits_fx( /* o : Number of assigned gain bits */ - const Word16 core, /* i : HQ core */ - const Word16 BANDS, /* i : Number of bands */ - const Word16 *band_width, /* i : Sub band bandwidth */ - Word16 *Rk, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ - Word16 *gain_bits_array, /* o : Assigned gain bits */ - Word16 *Rcalc /* o : Bit budget for shape quantizer Q3 */ +/* o : Number of assigned gain bits */ +Word16 ivas_assign_gain_bits_fx( + const Word16 core, /* i : HQ core */ + const Word16 BANDS, /* i : Number of bands */ + const Word16 *band_width, /* i : Sub band bandwidth */ + Word16 *Rk, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */ + Word16 *gain_bits_array, /* o : Assigned gain bits */ + Word16 *Rcalc /* o : Bit budget for shape quantizer Q3 */ ); void ivas_fine_gain_pred_fx( @@ -1743,7 +1768,8 @@ Word16 ivas_pvq_core_dec_fx( Word16 *Rs, Word16 *npulses, Word16 *maxpulse, - const Word16 core ); + const Word16 core +); void ivas_hq_ecu_fx( const Word16 *prevsynth, /* i : buffer of previously synthesized signal */ @@ -1805,7 +1831,8 @@ void ivas_fill_spectrum_fx( const Word16 num_sfm, /* i : Total number of bands Q0 */ Word16 *prev_env_Q, const Word16 num_env_bands, - const Word16 element_mode ); + const Word16 element_mode +); void ivas_de_interleave_spectrum_fx( Word32 *coefs, /* i/o: input and output coefficients Q12 */ @@ -1843,9 +1870,9 @@ void synchro_synthesis_fx( Word32 *output_fx[CPE_CHANNELS], /* i/o: output synthesis signal */ const Word16 output_frame, /* i : Number of samples */ const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - Word16 output_fx_q ); + Word16 output_fx_q +); -// ivas_dirac_output_synthesis_cov void ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( Word32 *RealBuffer_fx, /* i : input channel filter bank samples (real part) */ Word16 RealBuffer_e, /* i : exponent input channel filter bank samples (real part)*/ @@ -1866,7 +1893,8 @@ void configureFdCngDec_ivas_fx( const Word32 total_brate, const Word16 L_frame, const Word16 last_L_frame, - const Word16 element_mode ); + const Word16 element_mode +); void synchonize_channels_mdct_sid_fx( Decoder_State *sts[CPE_CHANNELS], /* i/o: decoder state structure */ @@ -1874,12 +1902,10 @@ void synchonize_channels_mdct_sid_fx( ); void ivas_interpolate_3_over_1_allpass_fx( - const Word16 *input_fx, - /* i : input signal */ /* Q_input */ - const Word16 len, /* i : number of input samples */ - Word16 *out_fx, - /* o : output signal */ /* Q_input */ - Word16 *mem_fx /* i/o: memory */ /* Q_input */ + const Word16 *input_fx, /* i : input signal Q_input */ + const Word16 len, /* i : number of input samples */ + Word16 *out_fx, /* o : output signal Q_input */ + Word16 *mem_fx /* i/o: memory Q_input */ ); void tdm_configure_enc_fx( @@ -1898,7 +1924,8 @@ void stereoFdCngCoherence_fx( Encoder_State **sts, /* i/o: core encoder structures */ const Word16 last_element_mode, /* i : last element mode */ Word16 fft_buff[CPE_CHANNELS][2 * L_FFT], /* i : fft buffers for L and R channels fft_exp*/ - Word16 fft_exp ); + Word16 fft_exp +); void ivas_wb_tbe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -1907,7 +1934,8 @@ void ivas_wb_tbe_dec_fx( const Word16 Q_exc, const Word16 voice_factors[], /* i : voicing factors */ Word16 *synth, /* o : WB synthesis/final synthesis */ - Word16 *Q_synth ); + Word16 *Q_synth +); void GenShapedWBExcitation_ivas_fx( Word16 *excSHB, /* o : synthesized shaped shb exctiation Q_bwe_exc*/ @@ -1924,18 +1952,20 @@ void GenShapedWBExcitation_ivas_fx( Word16 bwe_seed[], /* i/o : random number generator seed */ const Word16 voice_factors[], /* i : voicing factor Q15*/ const Word16 uv_flag, /* i : unvoiced flag */ - const Word16 igf_flag ); - -Word16 ivas_wb_bwe_dec_fx( /* o : Q_syn_hb*/ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 output[], /* i : suntehsis @ internal Fs Q_input */ - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const Word16 output_frame, /* i : frame length */ - Word16 *voice_factors_fx, /* i : voicing factors Q15 */ - const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ - Word16 *Qpost ); + const Word16 igf_flag +); + +/* o : Q_syn_hb*/ +Word16 ivas_wb_bwe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 output[], /* i : suntehsis @ internal Fs Q_input */ + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + const Word16 output_frame, /* i : frame length */ + Word16 *voice_factors_fx, /* i : voicing factors Q15 */ + const Word16 pitch_buf_fx[], /* i : pitch buffer Q6 */ + Word16 *Qpost ); void ivas_param_ism_config_fx( PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i/o: IVAS Param ISM Config Structure */ @@ -1971,7 +2001,8 @@ void TonalMDCTConceal_Detect_ivas_fx( const Word32 pitchLag, Word16 *numIndices, const PsychoacousticParameters *psychParamsCurrent, - Word16 element_mode ); + Word16 element_mode +); Word16 GetPLCModeDecision_ivas_fx( Decoder_State *st /* i/o: decoder memory state pointer */ @@ -1995,7 +2026,8 @@ void ivas_DetectTonalComponents_fx( const Word16 nSamplesCore, Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ const PsychoacousticParameters *psychParamsCurrent, - Word16 element_mode ); + Word16 element_mode +); ivas_error stereo_dft_dec_create_fx( STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ @@ -2024,7 +2056,9 @@ void initFdCngDec_ivas_fx( DEC_CORE_HANDLE st, /* i/o: decoder state structure */ Word16 scale ); -void ivas_initFdCngCom_fx( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale ); +void ivas_initFdCngCom_fx( + HANDLE_FD_CNG_COM hFdCngCom, Word16 scale +); Word16 set_ACELP_flag_IVAS( const Word16 element_mode, /* i : element mode */ @@ -2048,7 +2082,8 @@ void ivas_calc_c_p_coeffs_enc_fx( const Word16 band_idx, const Word16 dtx_vad, const Word16 compute_p_flag, - const Word16 dyn_active_w_flag ); + const Word16 dyn_active_w_flag +); void ivas_calc_c_p_coeffs_fx( ivas_spar_md_t *pSparMd, @@ -2148,7 +2183,8 @@ void small_reduction_direction_fx( IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ UWord16 bits_dir[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], const Word16 raw_flag[MASA_MAXIMUM_CODING_SUBBANDS], - Word16 *diff ); + Word16 *diff +); void sort_desc_ind_32_fx( Word32 *s, /* i/o: vector to be sorted Qx*/ @@ -2162,7 +2198,8 @@ ivas_error only_reduce_bits_direction_fx( Word16 reduce_bits, const Word16 coding_subbands, const Word16 no_subframes, - Word16 *ind_order ); + Word16 *ind_order +); void ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( const Word32 az, /* i : azimuth Q22 */ @@ -2215,7 +2252,8 @@ ivas_error TDREND_MIX_LIST_SetOrient_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const Word32 *FrontVec_p_fx, /* i : Listener's orientation front vector */ const Word32 *UpVec_p_fx, /* i : Listener's orientation up vector */ - const Word16 orient_q ); + const Word16 orient_q +); void TDREND_MIX_LIST_SetPos_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ @@ -2276,7 +2314,6 @@ void stereo_dtf_cng_fx( Word16 q_dft /* i : Q factor of the DFT data */ ); - void ivas_spar_update_md_hist_fx( ivas_spar_md_dec_state_t *hMdDec /* i/o: SPAR MD decoder handle */ ); @@ -2305,7 +2342,8 @@ void ivas_dirac_dec_render_sf_fx( Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */ const Word16 nchan_transport, /* i : number of transport channels */ Word32 *pppQMfFrame_ts_re_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], - Word32 *pppQMfFrame_ts_im_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] ); + Word32 *pppQMfFrame_ts_im_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] +); void ivas_dirac_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ @@ -2437,7 +2475,8 @@ ivas_error PsychoacousticParameters_Init_fx( const Word8 nBands, /* i : Number of spectrum subbands */ const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ - PsychoacousticParameters *pPsychParams ); + PsychoacousticParameters *pPsychParams +); ivas_error ivas_FB_mixer_open_fx( IVAS_FB_MIXER_HANDLE *hFbMixer_out, /* i/o: FB mixer handle */ @@ -2464,9 +2503,9 @@ void ivas_fb_mixer_cross_fading_fx( Word32 *pMdft_out_new_fx, const Word16 ch, const Word16 frame_len, - const Word16 cf_offset ); + const Word16 cf_offset +); -// ivas_omasa_dec.c ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of samples requested */ @@ -2494,13 +2533,15 @@ Word16 ivas_sba_spar_sid_bitlen_fx( void ivas_sba_get_spar_hoa_ch_ind_fx( const Word16 num_md_chs, /* i : number of MD channels */ const Word32 ivas_total_brate, /* i : IVAS total bitrate */ - Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] ); + Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] +); void ivas_sba_get_spar_hoa_md_flag_fx( const Word16 sba_order, /* i : Ambisonic (SBA) order */ const Word32 ivas_total_brate, /* i : IVAS total bitrate */ Word16 *spar_hoa_md_flag, - Word16 *spar_hoa_dirac2spar_md_flag ); + Word16 *spar_hoa_dirac2spar_md_flag +); void ivas_omasa_dirac_rend_jbm_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ @@ -2551,34 +2592,41 @@ void ivas_wrap_arround_fx( Word16 *pArr, const Word16 min_val, const Word16 max_val, - const Word16 length ); + const Word16 length +); void ivas_get_cum_freq_model_fx( const Word16 *pFreq_model, const Word16 length, - Word16 *pCum_freq_model ); + Word16 *pCum_freq_model +); Word16 ivas_map_num_pred_r_to_idx_fx( const Word16 num_quant_points_pred_r, - const Word16 active_w_flag ); + const Word16 active_w_flag +); Word16 ivas_map_num_drct_r_to_idx_fx( - const Word16 num_quant_points_drct_r ); + const Word16 num_quant_points_drct_r +); Word16 ivas_map_num_decd_r_to_idx_fx( - const Word16 num_quant_points_decd_r ); + const Word16 num_quant_points_decd_r +); void ivas_spar_arith_coeffs_com_init_fx( ivas_arith_coeffs_t *pArith_coeffs, ivas_spar_md_com_cfg *pSpar_cfg, const Word16 table_idx, - const Word16 enc_dec ); + const Word16 enc_dec +); void ivas_spar_huff_coeffs_com_init_fx( ivas_huff_coeffs_t *pHuff_coeffs, ivas_spar_md_com_cfg *pSpar_cfg, const Word16 table_idx, - const Word16 enc_dec ); + const Word16 enc_dec +); ISM_MODE ivas_omasa_ism_mode_select_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ @@ -2623,6 +2671,7 @@ Word16 calculate_brate_limit_flag_fx( const Word16 ism_imp[], /* i : ISM importance flags */ const Word16 nchan_ism /* i : number of objects */ ); + Word16 ism_quant_meta_fx( const Word32 val, /* i : scalar value to quantize Q22 */ Word32 *valQ, /* o : quantized value Q22 */ @@ -2637,28 +2686,11 @@ Word16 getNumChanAnalysis_fx( Encoder_Struct *st_ivas /* i : IVAS encoder structure */ ); + /*----------------------------------------------------------------------------------* * Limiter prototypes *----------------------------------------------------------------------------------*/ - -ivas_error ivas_limiter_open( - IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ - const int16_t num_channels, /* i : number of I/O channels */ - const int32_t sampling_rate /* i : sampling rate for processing */ -); - -void ivas_limiter_close( - IVAS_LIMITER_HANDLE *phLimiter /* i/o: pointer to limiter handle, can be NULL */ -); - -void ivas_limiter_dec( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ - const int16_t num_channels, /* i : number of channels to be processed */ - const int16_t output_frame, /* i : number of samples per channel in the buffer */ - const int16_t BER_detect /* i : BER detect flag */ -); void ivas_limiter_dec_fx( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ @@ -2667,13 +2699,7 @@ void ivas_limiter_dec_fx( const Word16 BER_detect, /* i : BER detect flag */ Word16 q_factor /* i : Q factor of the output samples */ ); -void limiter_process( - IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ - const int16_t output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ - const float threshold, /* i : signal amplitude above which limiting starts to be applied */ - const int16_t BER_detect, /* i : BER detect flag */ - int16_t *strong_saturation_cnt /* i/o: counter of strong saturations (can be NULL) */ -); + void limiter_process_fx( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ const Word16 output_frame, /* i : number of samples to be processed per channel in the I/O buffer */ @@ -2719,16 +2745,17 @@ void ivas_lfe_lpf_enc_apply_fx( const Word16 input_frame /* i : input frame length per channel */ ); -// ivas_arith.c void ivas_ari_done_encoding_14bits_fx( BSTR_ENC_HANDLE hBstr, - Tastat *s ); + Tastat *s +); void ivas_ari_encode_14bits_ext_fx( BSTR_ENC_HANDLE hBstr, Tastat *s, Word32 symbol, - const UWord16 *cum_freq ); + const UWord16 *cum_freq +); void ms_inv_mask_processing_fx( STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */ @@ -2786,16 +2813,14 @@ void stereo_coder_tcx_fx( Word32 *inv_mdst_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */ const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */ Word16 exp_spec, - Word16 exp_mdst_spec ); + Word16 exp_mdst_spec +); -// bw_detect_fx.c Word16 set_bw_mct_fx( CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE encoder structures */ const Word16 nCPE /* i : number of CPEs */ ); - -// ivas_mct_enc_mct.c void write_mct_bitstream_fx( Encoder_State **sts, /* i/o: encoder state structure */ MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ @@ -2839,6 +2864,7 @@ void ivas_spar_bitrate_dist_fx( const Word16 sba_order, /* i : Ambisonic (SBA) order */ const Word16 bwidth /* i : audio bandwidth */ ); + ivas_error ivas_corecoder_enc_reconfig_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const Word16 nSCE_old, /* i : number of SCEs in previous frame */ @@ -2855,6 +2881,7 @@ void ivas_sba_zero_vert_comp_fx( const Word16 sba_planar, /* i : SBA planar flag */ const Word16 input_frame /* i : frame length */ ); + void tdm_configure_dec_fx( const Word16 ivas_format, /* i : IVAS format */ const Word16 ism_mode, /* i : ISM mode in combined format */ @@ -2877,6 +2904,7 @@ Word16 mdct_classifier_ivas_fx( const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ); + /*----------------------------------------------------------------------------------* * Range Coder prototypes *----------------------------------------------------------------------------------*/ @@ -2980,7 +3008,8 @@ void stereo_dft_enc_res_fx( const Word32 *input_8k, /* i : input buffer sampled at 8kHz Q15 */ BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ Word16 *nb_bits, /* o : number of bits written */ - const Word16 max_bits ); + const Word16 max_bits +); Word32 ECSQ_encode_target_SNR_fx( ECSQ_instance *ecsq_inst, @@ -2990,20 +3019,23 @@ Word32 ECSQ_encode_target_SNR_fx( const Word32 target_SNR, // Q25 const Word16 max_bits, Word32 *output, - Word16 *global_gain_index_output ); + Word16 *global_gain_index_output +); void ECSQ_quantize_vector_fx( const Word32 *input, const Word16 input_e, const Word32 global_gain, // Q15 const Word16 N, - Word16 *output ); + Word16 *output +); Word32 ECSQ_compute_optimal_gain_fx( // Q15 const Word32 *input, const Word16 input_e, const Word16 N, - const Word16 *output ); + const Word16 *output +); void spectral_balancer_fx16( Word16 *signal, /* i/o : signal Qx */ @@ -3067,7 +3099,8 @@ void encod_gen_2sbfr( const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[], /* i : pitch values for primary channel */ Word16 Q_new, - Word16 shift ); + Word16 shift +); void acelp_fast_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -3234,8 +3267,8 @@ Word16 quantize_direction2D_fx( void restore_metadata_buffer_fx( BSTR_ENC_HANDLE hMetaData, const Word16 next_ind_start, - const Word16 bit_pos_start ); - + const Word16 bit_pos_start +); void small_requantize_direction_frame_fx( IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ @@ -3243,7 +3276,8 @@ void small_requantize_direction_frame_fx( Word32 elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], // Q22 const Word16 raw_flag[MASA_MAXIMUM_CODING_SUBBANDS], Word16 bits_dir_bands[MASA_MAXIMUM_CODING_SUBBANDS], - Word16 *diff ); + Word16 *diff +); void ivas_param_ism_stereo_dmx_fx( Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ @@ -3316,8 +3350,8 @@ void computeDirectionVectors_fixed( Word32 *direction_vector_y, /*Q30*/ Word32 *direction_vector_z, /*Q30*/ Word16 i_e, /*Exponent of all the intensity buffers*/ - Word16 *i_e_band ); - + Word16 *i_e_band +); UWord8 ivas_masa_surrcoh_signicant_fx( Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Surround coherence Q31 */ @@ -3326,6 +3360,7 @@ UWord8 ivas_masa_surrcoh_signicant_fx( const Word16 nBands /* i : Number of frequency bands */ ); + /*----------------------------------------------------------------------------------* * McMASA prototypes *----------------------------------------------------------------------------------*/ @@ -3353,6 +3388,7 @@ void ivas_mcmasa_enc_fx( const Word16 nchan_inp, /* i : Number of input channels */ const Word16 q_inp /* i : Input data q-format */ ); + void ivas_mcmasa_param_est_enc_fx( MCMASA_ENC_HANDLE hMcMasa, /* i : McMASA encoder structure */ MASA_ENCODER_HANDLE hMasa, /* i : MASA encoder structure */ @@ -3378,7 +3414,8 @@ void computeReferencePower_enc_fx( Word16 ref_power_w, /* i : use 0 if hodirac is enabled */ const Word16 nchan_ana, /* i : number of analysis channels */ Word16 inp_q, /* i : q of cld buffers */ - Word16 q_reference_power[DIRAC_NO_FB_BANDS_MAX] ); + Word16 q_reference_power[DIRAC_NO_FB_BANDS_MAX] +); void computeReferencePower_enc_fx_dirac( const Word16 *band_grouping, /* i : Band grouping for estimation */ @@ -3434,7 +3471,6 @@ void ivas_mct_core_enc_fx( const Word16 sba_order /* i : Ambisonic (SBA) order */ ); - ivas_error mct_enc_reconfigure_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const UWord16 b_nchan_change /* i : flag indicating different channel count */ @@ -3472,6 +3508,7 @@ Word16 quantize_direction2D_fx( UWord16 *index_phi, /* o : quantized azimuth index */ const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ ); + void quantize_direction_frame_fx( IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ Word32 azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* o : Q22 */ @@ -3505,6 +3542,7 @@ void ivas_qmetadata_enc_sid_encode_fx( const Word16 nchan_transport, /* i : number of transport channels */ const Word16 ivas_format /* i : ivas format */ ); + void ivas_param_mc_enc_fx( Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ @@ -3572,6 +3610,7 @@ void ivas_omasa_encode_masa_to_total_fx( ivas_error ivas_masa_enc_config_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); + ivas_error ivas_omasa_enc_config_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -3579,6 +3618,7 @@ ivas_error ivas_omasa_enc_config_fx( void ivas_omasa_enc_close_fx( OMASA_ENC_HANDLE *hOMasa /* i/o: encoder OMASA handle */ ); + ivas_error ivas_omasa_enc_open_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); @@ -3645,7 +3685,8 @@ void ivas_quantise_real_values_fx( const Word32 max_value_fx, Word16 *index, Word32 *quant_fx, - const Word16 dim ); + const Word16 dim +); void ivas_quantise_real_values_enc_fx( const Word32 *values_fx, // Q28 @@ -3654,7 +3695,8 @@ void ivas_quantise_real_values_enc_fx( const Word32 max_value_fx, // Q28 Word16 *index, Word32 *quant_fx, // Q28 - const Word16 dim ); + const Word16 dim +); void ivas_quantise_real_values_enc_fx_varq( const Word32 *values_fx, @@ -3664,32 +3706,38 @@ void ivas_quantise_real_values_enc_fx_varq( Word16 *index, Word32 *quant_fx, const Word16 dim, - Word16 inp_q ); + Word16 inp_q +); void ivas_spar_quant_dtx_init_fx( ivas_spar_md_t *spar_md, - Word32 *min_max ); + Word32 *min_max +); void ivas_spar_quant_dtx_init_fx( ivas_spar_md_t *spar_md, - Word32 *min_max ); + Word32 *min_max +); void ivas_copy_band_coeffs_idx_to_arr( ivas_band_coeffs_ind_t *pBands_idx, const Word16 nB, Word16 *pSymbol_re, ivas_cell_dim_t *pCell_dims, - const ivas_coeffs_type_t coeff_type ); + const ivas_coeffs_type_t coeff_type +); void ivas_clear_band_coeffs_fx( ivas_band_coeffs_t *pband_coeffs, - const UWord16 num_bands ); + const UWord16 num_bands +); Word16 ivas_qmetadata_DecodeExtendedGR( UWord16 *bitstream, Word16 *index, const Word16 alph_size, - const Word16 gr_param ); + const Word16 gr_param +); void ivas_masa_combine_directions_fx( MASA_ENCODER_HANDLE hMasa /* i/o: MASA encoder handle */ @@ -3708,7 +3756,8 @@ Word16 ivas_get_df_ratio_bits_fx( void invdct4_transform_fx( Word32 *v_fx, /* i : input vector */ UWord8 *invdct_v, /* o : transformed vector */ - Word16 q ); + Word16 q +); void ivas_spar_param_to_masa_param_mapping_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ @@ -3833,13 +3882,15 @@ void ivas_filter_process_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i : signal subject to filtering */ const Word16 length, /* i : filter order */ - Word16 q_factor ); + Word16 q_factor +); void ivas_filter_process_exp_fx( ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ Word32 *pIn_Out_fx, /* i/o: signal subject to filtering (exp[i] : pIn_out_e[i]) */ const Word16 length, /* i : filter order */ - Word16 *pIn_Out_e ); + Word16 *pIn_Out_e +); ivas_error ivas_osba_enc_open_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ @@ -3859,11 +3910,13 @@ void ivas_osba_enc_fx( const Word16 sba_analysis_order, /* i : SBA order evaluated in DirAC/SPAR encoder */ const Word32 input_Fs, /* i : input sampling rate */ const Word16 sba_planar, /* i : planar SBA flag */ - Word16 *q_data ); + Word16 *q_data +); ivas_error ivas_osba_data_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); + ivas_error ivas_osba_dirac_td_binaural_jbm_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ @@ -3920,15 +3973,16 @@ void ivas_omasa_preProcessStereoTransportsForMovedObjects_fx( Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*cldfb_buf_q*/ Word16 *cldfb_buf_q, const Word16 nBins, - const Word16 subframe ); - + const Word16 subframe +); void ivas_omasa_decode_masa_to_total_fx( UWord16 *bit_stream, Word16 *index, Word32 masa_to_total_energy_ratio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], const Word16 nbands, - const Word16 nblocks ); + const Word16 nblocks +); /*----------------------------------------------------------------------------------* @@ -3965,7 +4019,8 @@ void ivas_fb_mixer_pcm_ingest_fx( const Word16 frame_len, /* i : frame length */ const Word16 HOA_md_ind[IVAS_SPAR_MAX_CH], Word16 q_data_fix, - Word16 *q_ppOut_pcm ); + Word16 *q_ppOut_pcm +); void ivas_fb_mixer_process_fx( IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ @@ -4129,7 +4184,6 @@ void smooth_dft2td_transition_fx( const Word16 output_frame /* i : output frame lenght Q0*/ ); - Word16 is_IVAS_bitrate_fx( const Word32 ivas_total_brate /* i : IVAS total bitrate */ ); @@ -4267,7 +4321,8 @@ ivas_error ivas_ism_metadata_enc_fx( const Word16 lp_noise_CPE, /* i : LP filtered total noise estimation */ const Word16 flag_omasa_ener_brate, /* i : less bitrate for objects in OMASA flag */ Word16 *omasa_stereo_sw_cnt, - const Word16 ini_frame ); + const Word16 ini_frame +); ivas_error ivas_ism_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -4294,14 +4349,16 @@ void ivas_param_ism_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ Word32 *transport_channels[], /* i : synthesized core-coder transport channels/DirAC output */ - Word16 q_tc_in ); + Word16 q_tc_in +); void ivas_param_ism_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - Word32 *output_f_fx[] ); + Word32 *output_f_fx[] +); void ivas_param_ism_params_to_masa_param_mapping_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ @@ -4342,8 +4399,8 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ const Word16 sce_id_dtx, /* i : SCE DTX ID */ const Word16 nchan_transport, /* i : number of transport channels */ - Word16 *Q_cngNoiseLevel ); - + Word16 *Q_cngNoiseLevel +); ivas_error stereo_dft_enc_create_fx( STEREO_DFT_ENC_DATA_HANDLE *hStereoDft, /* o : encoder DFT stereo handle */ @@ -4374,7 +4431,8 @@ void stereo_dft_quantize_res_gains_fx( Word32 *gq, // Q31 Word32 *rq, // Q31 Word16 *ig, - Word16 *ir ); + Word16 *ir +); void stereo_dft_dequantize_itd_fx( Word16 *ind, /* Q0 */ @@ -4503,7 +4561,8 @@ void stereo_td_init_enc_fx( ivas_error stereo_set_tdm_fx( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ const Word16 input_frame, /* i : input frame length per channel */ - Word16 input_q ); + Word16 input_q +); void stereo_tdm_prep_dwnmx_fx( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ @@ -4545,7 +4604,8 @@ Word16 tdm_lp_comparison_fx( const Word16 *isp_SCh_fx, /* i : secondary channel LSPs Q15 */ const Word16 L_frame, /* i : frame length */ const Word32 element_brate_wo_meta, /* i : element bitrate without metadata*/ - Word16 Q_speech ); + Word16 Q_speech +); ivas_error signaling_enc_secondary_fx( Encoder_State *st, /* i/o: Encoder structure */ @@ -4554,26 +4614,19 @@ ivas_error signaling_enc_secondary_fx( ); void tdm_low_rate_enc( - Encoder_State *st, /* i/o: State structure */ - const Word16 Aq[], /* i : 12k8 Lp coefficient */ - const Word16 *res, - /* i : residual signal */ // Q_new - Word16 *synth, - /* i/o: core synthesis */ // Q_new - Word16 *exc_fx, - /* i/o: current non-enhanced excitation */ // Q_new - Word16 *pitch_buf, - /* i/o: floating pitch values for each subframe */ // Q6 - Word16 *voice_factors, - /* o : voicing factors */ // Q15 - Word16 *bwe_exc_fx, - /* o : excitation for SWB TBE */ // Q_new + Encoder_State *st, /* i/o: State structure */ + const Word16 Aq[], /* i : 12k8 Lp coefficient */ + const Word16 *res, /* i : residual signal // Q_new*/ + Word16 *synth, /* i/o: core synthesis // Q_new*/ + Word16 *exc_fx, /* i/o: current non-enhanced excitation // Q_new*/ + Word16 *pitch_buf, /* i/o: floating pitch values for each subframe // Q6*/ + Word16 *voice_factors, /* o : voicing factors // Q15*/ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE // Q_new*/ const Word16 attack_flag, /* i : attck flag */ - const Word16 *lsf_new, - /* i : current frame ISF vector */ // x2.56 - Word16 *tmp_noise, - /* o : long-term noise energy */ // Q8 - Word16 Q_new ); + const Word16 *lsf_new, /* i : current frame ISF vector */ // x2.56 + Word16 *tmp_noise, /* o : long-term noise energy */ // Q8 + Word16 Q_new +); void tdm_low_rate_dec_fx( Decoder_State *st, /* i/o: decoder static memory */ @@ -4630,12 +4683,14 @@ void init_tcx_enc_info_fx( Encoder_State *st, /* i/o: coder memory state */ Word16 *L_frame, Word16 *L_frameTCX, - Word16 *L_spec ); + Word16 *L_spec +); void SetCurrentPsychParams( const Word16 core, const Word16 last_frame_was_concealed_cng, - TCX_CONFIG_HANDLE hTcxCfg ); + TCX_CONFIG_HANDLE hTcxCfg +); void sns_avq_cod_fx( const Word32 *sns_fx, /* i : Input sns vectors */ @@ -4704,7 +4759,8 @@ ivas_error front_vad_fx( Word16 Q_inp, Word16 *Q_buffer, Word16 Q_add, - Word16 *front_create_flag ); + Word16 *front_create_flag +); void stereo_cna_update_params_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ @@ -4751,11 +4807,13 @@ void v_add_inc_fx( const Word16 y_inc, /* i : increment for vector y[] */ const Word16 N /* i : Vector length */ ); + Word32 logsumexp_fx( const Word32 x[], /* i : input array x */ const Word16 x_e, const Word16 N /* i : number of elements in array x */ ); + Word32 lin_interp32_fx( const Word32 x, /* i : the value to be mapped */ const Word32 x1, /* i : source range interval: low end */ @@ -4833,13 +4891,15 @@ void v_mult_mat_fx( const Word16 N, /* i : number of rows */ const Word16 C /* i : number of columns */ ); + void v_mult_mat_fixed( Word32 *y, /* o : the product x*A */ const Word32 *x, /* i : vector x */ const Word32 *A, /* i : matrix A */ const Word16 Nr, /* i : number of rows */ const Word16 Nc, /* i : number of columns */ - Word16 guardbits ); + Word16 guardbits +); Word32 check_bounds_l( const Word32 value, /* i : Input value */ @@ -4896,7 +4956,8 @@ void ivas_mct_core_dec( CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE decoder structure */ const Word16 nCPE, /* i : number of CPEs */ Word32 *signal_out_fx[], - Word16 q_x[MCT_MAX_CHANNELS] ); + Word16 q_x[MCT_MAX_CHANNELS] +); void ivas_qmetadata_to_dirac_fx( const IVAS_QMETADATA_HANDLE hQMetaData, /* i : frame of MASA q_metadata */ @@ -4950,6 +5011,7 @@ Word32 deindex_azimuth_fx( const Word16 remap, /* i : remapping flag */ const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ ); + void deindex_spherical_component_fx( const UWord16 sph_idx, /* i : spherical index */ Word32 *az_fx, /* o : decoded azimuth value */ @@ -4974,7 +5036,8 @@ void ivas_dirac_param_est_enc_fx( const Word16 nchan_fb_in, Word16 *mono_frame_count, Word16 *dirac_mono_flag, - const Word16 shift ); + const Word16 shift +); ivas_error ivas_cldfb_dec_reconfig_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -4986,23 +5049,6 @@ ivas_error ivas_cldfb_dec_reconfig_fx( ivas_error ivas_sba_enc_reconfigure_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); -/*! r: Ambisonic (SBA) order used for analysis and coding */ -Word16 ivas_sba_get_analysis_order( - const Word32 ivas_total_brate, /* i : IVAS total bitrate */ - const Word16 sba_order /* i : Ambisonic (SBA) order */ -); - -Word16 ivas_sba_get_nchan_metadata( - const Word16 sba_order, /* i : Ambisonic (SBA) order */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); - -/*! r: flag indicating to code SPAR HOA MD for all bands */ -void ivas_sba_get_spar_hoa_md_flag( - const Word16 sba_order, /* i : Ambisonic (SBA) order */ - const Word32 ivas_total_brate, /* i : IVAS total bitrate */ - Word16 *spar_hoa_md_flag, - Word16 *spar_hoa_dirac2spar_md_flag ); Word16 ivas_sba_remapTCs_fx( Word32 *sba_data[], /* i/o: SBA signals */ @@ -5028,10 +5074,12 @@ void ivas_dirac_config_bands_fx( const Word8 useLowerBandRes, /* i : flag indicating lower band resolution for DirAC */ const Word16 enc_param_start_band, /* i : band index of first DirAC parameter band */ IVAS_FB_MIXER_HANDLE hFbMdft, - const Word8 BandGroupLowRes ); + const Word8 BandGroupLowRes +); void ivas_dirac_dec_close_fx( - DIRAC_DEC_HANDLE *hDirAC_out ); + DIRAC_DEC_HANDLE *hDirAC_out +); void generate_masking_noise_lb_dirac_fx( HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ @@ -5042,11 +5090,7 @@ void generate_masking_noise_lb_dirac_fx( ); void ivas_dirac_dec_close_fx( - DIRAC_DEC_HANDLE *hDirAC_out ); - -void ivas_dirac_dec_set_md_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 nCldfbTs /* i : number of CLDFB time slots */ + DIRAC_DEC_HANDLE *hDirAC_out ); void computeDirectionVectors_fx( @@ -5058,30 +5102,34 @@ void computeDirectionVectors_fx( Word32 *direction_vector_x, Word32 *direction_vector_y, Word32 *direction_vector_z, - Word16 *q_factor ); + Word16 *q_factor +); -void computeDiffuseness_fixed( +void computeDiffuseness_fx( Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], const Word32 *buffer_energy, const Word16 num_freq_bands, Word32 *diffuseness, Word16 *q_factor_intensity, Word16 *q_factor_energy, - Word16 *q_diffuseness ); + Word16 *q_diffuseness +); void ivas_dirac_dec_get_response_fx( const Word16 azimuth, const Word16 elevation, Word32 *response_fx, /*Q_out*/ const Word16 ambisonics_order, - Word16 Q_out ); + Word16 Q_out +); /*This is a derivate to ivas_dirac_dec_get_response_fx with fixed Q_out=29*/ void ivas_dirac_dec_get_response_fx_29( const Word16 azimuth, const Word16 elevation, Word32 *response_fx, /*Q_out=29*/ - const Word16 ambisonics_order ); + const Word16 ambisonics_order +); void calculate_hodirac_sector_parameters_fx( DIRAC_ENC_HANDLE hDirAC, /* i : DirAC handle */ @@ -5137,7 +5185,8 @@ void ivas_param_mc_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ Word32 *transport_channels_f_fx[], - Word16 transport_f_e ); + Word16 transport_f_e +); void ivas_param_mc_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ @@ -5145,7 +5194,8 @@ void ivas_param_mc_dec_render_fx( UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ Word32 *output_f_fx[], /* o : rendered time signal */ - Word16 channel_active_fx[MAX_OUTPUT_CHANNELS] ); + Word16 channel_active_fx[MAX_OUTPUT_CHANNELS] +); Word16 matrix_product_mant_exp_fx( const Word32 *X_fx, /* i : left hand matrix */ @@ -5233,7 +5283,8 @@ Word16 computeMixingMatrices_fx( Word32 *mixing_matrix_fx, /* o : resulting mixing matrix */ Word16 *mixing_matrix_out_e, Word32 *Cr_fx, /* o : residual covariance matrix */ - Word16 *Cr_e ); + Word16 *Cr_e +); Word16 computeMixingMatricesResidual_fx( const Word32 num_outputs, /* i : number of output channels */ @@ -5246,7 +5297,8 @@ Word16 computeMixingMatricesResidual_fx( const Word32 reg_ghat_fx, /* i : regularization factor for the normalization matrix */ const Word16 reg_ghat_e, Word32 *mixing_matrix_fx, /* o : resulting residual mixing matrix */ - Word16 *mixing_matrix_ret_e ); + Word16 *mixing_matrix_ret_e +); Word16 svd_fx( Word32 InputMatrix[][MAX_OUTPUT_CHANNELS], /* i : matrix to be decomposed (M) InputMatrix_e*/ @@ -5317,7 +5369,8 @@ Word16 computeMixingMatricesISM_fx( const Word32 reg_Sx_fx, const Word32 reg_ghat_fx, Word32 *mixing_matrix_fx, - Word16 *mixing_matrix_e ); + Word16 *mixing_matrix_e +); ivas_error ivas_spar_enc_open_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder handle */ @@ -5421,6 +5474,7 @@ void ivas_sba_dec_digest_tc_fx( const Word16 nCldfbSlots, /* i : number of CLDFB slots */ const Word16 nSamplesForRendering /* i : number of samples provided */ ); + ivas_error ivas_sba_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ @@ -5456,7 +5510,8 @@ void ivas_create_fullr_dmx_mat_fx( const Word16 start_band, const Word16 end_band, const Word16 active_w, - ivas_spar_md_com_cfg *hMdCfg ); + ivas_spar_md_com_cfg *hMdCfg +); void ivas_get_spar_md_from_dirac_enc_fx( Word32 azi_dirac_fx[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES], // Q22 @@ -5474,7 +5529,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( Word32 Wscale_d[IVAS_MAX_NUM_BANDS], // Q29 const UWord8 useLowerRes, const Word16 active_w_vlbr, - const Word16 dyn_active_w_flag ); + const Word16 dyn_active_w_flag +); void ivas_get_spar_md_from_dirac_fx( Word32 azi_dirac_fx[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES], // Q22 @@ -5492,7 +5548,8 @@ void ivas_get_spar_md_from_dirac_fx( Word32 Wscale_d[IVAS_MAX_NUM_BANDS], // Q29 const UWord8 useLowerRes, const Word16 active_w_vlbr, - const Word16 dyn_active_w_flag ); + const Word16 dyn_active_w_flag +); ivas_error ivas_spar_md_enc_process_fx( ivas_spar_md_enc_state_t *hMdEnc, /* i/o: SPAR MD encoder handle */ @@ -5509,7 +5566,8 @@ ivas_error ivas_spar_md_enc_process_fx( Word16 *q_prior_mixer, /* i/o : q for prior mixer_matrix */ const Word16 dyn_active_w_flag, /* i : flag to indicate dynamic active W */ const Word16 dirac_mono_flag, /* i : flag to indicate mono only mode in SBA */ - const Word16 nchan_out ); + const Word16 nchan_out +); Word16 ivas_get_spar_dec_md_num_subframes( const Word16 sba_order, /* i : Ambisonic (SBA) order */ @@ -5541,7 +5599,8 @@ void ivas_spar_dec_gen_umx_mat_fx( const Word16 nchan_transport, /* i : number of transport channels */ const Word16 num_bands_out, /* i : number of output bands */ const Word16 bfi, /* i : bad frame indicator */ - const Word16 num_md_sub_frames ); + const Word16 num_md_sub_frames +); ivas_error ivas_spar_covar_enc_open_fx( ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */ @@ -5577,7 +5636,8 @@ void ivas_enc_cov_handler_process_fx( const Word16 *remix_order, Word16 *dyn_active_w_flag, const Word16 nchan_transport, - const Word16 is_sba ); + const Word16 is_sba +); ivas_error ivas_spar_covar_smooth_enc_open_fx( ivas_cov_smooth_state_t **hCovState, /* i/o: SPAR Covar. smoothing handle */ @@ -5601,7 +5661,8 @@ void ivas_cov_smooth_process_fx( const Word16 end_band, const Word16 num_ch, const Word16 transient_det[2], - Word16 *q_cov[IVAS_SPAR_MAX_CH] ); + Word16 *q_cov[IVAS_SPAR_MAX_CH] +); void ivas_pca_enc_init_fx( PCA_ENC_STATE *hPCA /* i/o: PCA encoder structure */ @@ -5620,7 +5681,8 @@ void cov_subfr_fx( Word32 **ptr_sig_fx, // Q11 Word64 *r_fx_64, // Q11 const Word16 n_channels, - const Word16 len ); + const Word16 len +); void ivas_pca_read_bits_fx( Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ @@ -5657,12 +5719,14 @@ void eig_qr_fx( const Word16 num_iter, Word32 *EV_fx, // Q31 Word32 *Vals_fx, // A_q - const Word16 n ); + const Word16 n +); void exhst_4x4_fx( Word16 *cost_mtx, // Q Word16 *path, - const Word16 maximize ); + const Word16 maximize +); Word16 mat_det4_fx( const Word16 *m // Q15 @@ -5677,13 +5741,15 @@ void mat2dquat_fx( void dquat2mat_fx( const Word16 *ql, const Word16 *qr, - Word16 *m ); + Word16 *m +); void quat_shortestpath_fx( const Word16 *q00, Word16 *q01, const Word16 *q10, - Word16 *q11 ); + Word16 *q11 +); void pca_interp_preproc_fx( const Word16 *prev_ql, @@ -5692,110 +5758,119 @@ void pca_interp_preproc_fx( const Word16 *qr, const Word16 len, Word16 *ql_interp, - Word16 *qr_interp ); + Word16 *qr_interp +); void pca_dec_s3_fx( const Word32 index, - Word16 *q ); + Word16 *q +); void ivas_spar_huff_coeffs_com_init( ivas_huff_coeffs_t *pHuff_coeffs, ivas_spar_md_com_cfg *pSpar_cfg, const Word16 table_idx, - const Word16 enc_dec ); + const Word16 enc_dec +); void ivas_spar_arith_coeffs_com_init( ivas_arith_coeffs_t *pArith_coeffs, ivas_spar_md_com_cfg *pSpar_cfg, const Word16 table_idx, - const Word16 enc_dec ); + const Word16 enc_dec +); void ivas_ari_start_decoding_14bits_ext_1_lfe( Decoder_State *st, Tastat *s, - Word16 *extra_bits_read ); + Word16 *extra_bits_read +); UWord16 ivas_ari_decode_14bits_bit_ext_1_lfe( Decoder_State *st, Tastat *s, const UWord16 *cum_freq, - Word16 *extra_bits_read ); + Word16 *extra_bits_read +); void ivas_ari_done_decoding_14bits_ext_1_lfe( Decoder_State *st, - const Word16 extra_bits_read ); + const Word16 extra_bits_read +); Word16 quantize_phi_fx( - Word32 phi, /* i : azimuth value */ - const Word16 flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ - Word32 *phi_hat, /* o : quantized azimuth */ - const Word16 n /* i : azimuth codebook size */ + Word32 phi, /* i : azimuth value */ + const Word16 flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ + Word32 *phi_hat, /* o : quantized azimuth */ + const Word16 n /* i : azimuth codebook size */ ); Word16 quantize_phi_enc_fx( - Word32 phi, /* i : azimuth value */ - const Word16 flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ - Word32 *phi_hat, /* o : quantized azimuth */ - const Word16 n /* i : azimuth codebook size */ + Word32 phi, /* i : azimuth value */ + const Word16 flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ + Word32 *phi_hat, /* o : quantized azimuth */ + const Word16 n /* i : azimuth codebook size */ ); Word16 ivas_spar_chk_zero_coefs_fx( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); void pca_enc_s3_fx( Word16 *q, // Q15 - Word32 *index ); + Word32 *index +); void ivas_spar_get_uniform_quant_strat_fx( ivas_spar_md_com_cfg *pSpar_md_com_cfg, - const Word16 table_idx ); + const Word16 table_idx +); void ivas_lfe_lpf_select_filt_coeff_fx( - const Word32 sampling_rate, /* i : sampling rate */ - const Word16 order, /* i : filter order */ - const Word32 **ppFilt_coeff_fx, /* o : filter coefficients */ - const Word16 **ppFilt_coeff_e /* o : exponents of filter coefficients */ + const Word32 sampling_rate, /* i : sampling rate */ + const Word16 order, /* i : filter order */ + const Word32 **ppFilt_coeff_fx, /* o : filter coefficients */ + const Word16 **ppFilt_coeff_e /* o : exponents of filter coefficients */ ); void ivas_filters_init_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - const Word32 *filt_coeff, /* i : filter coefficients */ - const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */ - const Word16 order /* i : filter order */ + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + const Word32 *filt_coeff, /* i : filter coefficients */ + const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */ + const Word16 order /* i : filter order */ ); void ivas_decision_matrix_enc_fx( - Encoder_State *st, /* i : encoder state structure */ - const Word32 element_brate, /* i : element bitrate */ - const Word16 fft_buff[], /* i : FFT buffer */ - const Word32 enerBuffer[], /* i : energy buffer */ + Encoder_State *st, /* i : encoder state structure */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 fft_buff[], /* i : FFT buffer */ + const Word32 enerBuffer[], /* i : energy buffer */ Word16 enerBuffer_exp, - const Word16 last_element_mode /* i : last element mode */ + const Word16 last_element_mode /* i : last element mode */ ); void stereo_dft_dec_sid_coh_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 nbands, /* i : number of DFT stereo bands Q0*/ - Word16 *coh, /* i/o: coherence Q15*/ - Word16 *nb_bits /* i/o: number of bits read Q0*/ + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 nbands, /* i : number of DFT stereo bands Q0*/ + Word16 *coh, /* i/o: coherence Q15*/ + Word16 *nb_bits /* i/o: number of bits read Q0*/ ); void stereo_tca_init_enc_fx( - STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo ICA handle */ - const Word32 input_Fs /* i : input sampling frequency */ + STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo ICA handle */ + const Word32 input_Fs /* i : input sampling frequency */ ); void stereo_tca_dec_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *synth[CPE_CHANNELS], /* i/o: output synth qsynth*/ - const Word16 output_frame /* i : length of a frame per channel Q0*/ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *synth[CPE_CHANNELS], /* i/o: output synth qsynth*/ + const Word16 output_frame /* i : length of a frame per channel Q0*/ ); void stereo_tca_scale_R_channel_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *output_fx, /* i/o: output synthesis, R channel q_out*/ - const Word16 output_frame /* i : frame length Q0*/ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *output_fx, /* i/o: output synthesis, R channel q_out*/ + const Word16 output_frame /* i : frame length Q0*/ ); void adjustTargetSignal_fx( @@ -5803,215 +5878,215 @@ void adjustTargetSignal_fx( const Word16 prevShift, const Word16 currShift, const Word16 L_shift_adapt, - const Word16 method ); + const Word16 method +); void stereo_icBWE_init_enc_fx( - STEREO_ICBWE_ENC_HANDLE hStereoICBWE /* i/o: Stereo inter-channel BWE handle */ + STEREO_ICBWE_ENC_HANDLE hStereoICBWE /* i/o: Stereo inter-channel BWE handle */ ); void stereo_classifier_init_fx( - STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier structure */ + STEREO_CLASSIF_HANDLE hStereoClassif /* i/o: stereo classifier structure */ ); void stereo_td_init_dec_fx( - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const Word16 last_element_mode /* i : last element mode Q0*/ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ + const Word16 last_element_mode /* i : last element mode Q0*/ ); void initMdctStereoEncData_fx( - STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 element_mode, /* i : element mode */ - const Word32 element_brate, /* i : element bitrate */ - const Word16 bwidth, /* i : bandwidth */ - const Word16 igf, /* i : flag indicating IGF activity */ - const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */ - const Word16 mem_init /* i : initialize memory after malloc */ + STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word16 element_mode, /* i : element mode */ + const Word32 element_brate, /* i : element bitrate */ + const Word16 bwidth, /* i : bandwidth */ + const Word16 igf, /* i : flag indicating IGF activity */ + const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */ + const Word16 mem_init /* i : initialize memory after malloc */ ); void deindex_sph_idx_fx( - const UWord16 sphIndex, /* i : Spherical index */ - const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ - Word32 *theta_fx, /* o : Elevation */ - Word32 *phi_fx /* o : Azimuth */ + const UWord16 sphIndex, /* i : Spherical index */ + const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ + Word32 *theta_fx, /* o : Elevation */ + Word32 *phi_fx /* o : Azimuth */ ); ivas_error ivas_dirac_enc_open_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); void ivas_dirac_enc_close_fx( - DIRAC_ENC_HANDLE *hDirAC, /* i/o: encoder DirAC handle */ - const Word32 input_Fs /* i : input sampling_rate */ + DIRAC_ENC_HANDLE *hDirAC, /* i/o: encoder DirAC handle */ + const Word32 input_Fs /* i : input sampling_rate */ ); ivas_error ivas_dirac_enc_fx( - DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ - Word32 *data_f[], /* i/o: SBA channels */ - Word32 **ppIn_FR_real, /* o : real freq domain values */ - Word32 **ppIn_FR_imag, /* o : imag freq domain values */ + DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ + BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ + Word32 *data_f[], /* i/o: SBA channels */ + Word32 **ppIn_FR_real, /* o : real freq domain values */ + Word32 **ppIn_FR_imag, /* o : imag freq domain values */ Word16 pp_fr_q, - const Word16 input_frame, /* i : input frame length */ - const Word16 dtx_vad, /* i : DTX vad flag */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const Word16 nchan_transport, /* i : number of transport channels */ - const Word16 hodirac_flag, /* i : hodirac flag */ + const Word16 input_frame, /* i : input frame length */ + const Word16 dtx_vad, /* i : DTX vad flag */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const Word16 nchan_transport, /* i : number of transport channels */ + const Word16 hodirac_flag, /* i : hodirac flag */ const Word16 shift ); ivas_error ivas_spar_md_enc_init_fx( - ivas_spar_md_enc_state_t *hMdEnc, /* o : MD encoder handle */ - const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ - const Word16 sba_order /* i : Ambisonic (SBA) order */ + ivas_spar_md_enc_state_t *hMdEnc, /* o : MD encoder handle */ + const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ + const Word16 sba_order /* i : Ambisonic (SBA) order */ ); void ivas_spar_get_cldfb_gains_fx( SPAR_DEC_HANDLE hSpar, HANDLE_CLDFB_FILTER_BANK cldfbAnaDec0, HANDLE_CLDFB_FILTER_BANK cldfbSynDec0, - const DECODER_CONFIG_HANDLE hDecoderConfig ); + const DECODER_CONFIG_HANDLE hDecoderConfig +); void ivas_sba_getTCs_fx( - Word32 *sba_data[], /* i : SBA signals Q11 */ - Encoder_Struct *st_ivas, /* i/o: Encoder struct */ - const Word16 input_frame /* i : frame length */ + Word32 *sba_data[], /* i : SBA signals Q11 */ + Encoder_Struct *st_ivas, /* i/o: Encoder struct */ + const Word16 input_frame /* i : frame length */ ); ivas_error front_vad_spar_fx( - SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */ - const Word32 *omni_in, /* i : omnidirectional input signal Q11 */ - ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */ - const Word16 input_frame /* i : input frame length */ + SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */ + const Word32 *omni_in, /* i : omnidirectional input signal Q11 */ + ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */ + const Word16 input_frame /* i : input frame length */ ); ivas_error ivas_spar_enc_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - Word32 *data_fx[], /* i/o: input/transport audio channel Q11 */ - const Word16 input_frame, /* i : input frame length */ - Word16 *nb_bits_metadata, /* i : number of MD bits written */ - BSTR_ENC_HANDLE hMetaData /* o : MetaData handle */ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + Word32 *data_fx[], /* i/o: input/transport audio channel Q11 */ + const Word16 input_frame, /* i : input frame length */ + Word16 *nb_bits_metadata, /* i : number of MD bits written */ + BSTR_ENC_HANDLE hMetaData /* o : MetaData handle */ ); ivas_error ivas_ism_enc_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - Word32 *data[], /* i : input signal [channels][samples] Q(q_data) */ - Word16 q_data, /* i : Q-factor of input signal */ - const Word16 input_frame, /* i : input frame length per channel */ - Word16 *nb_bits_metadata, /* i : number of metadata bits */ - const Word16 flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + Word32 *data[], /* i : input signal [channels][samples] Q(q_data) */ + Word16 q_data, /* i : Q-factor of input signal */ + const Word16 input_frame, /* i : input frame length per channel */ + Word16 *nb_bits_metadata, /* i : number of metadata bits */ + const Word16 flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ ); ivas_error ivas_sce_enc_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const Word16 sce_id, /* i : SCE # identifier */ - const Word32 data_fx[], /* i : input signal for single channel Q(q_data_fx) */ - const Word16 q_data_fx, /* i : Q-factor of input signal for single channel */ - const Word16 input_frame, /* i : input frame length per channel */ - const Word16 nb_bits_metadata /* i : number of metadata bits */ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + const Word16 sce_id, /* i : SCE # identifier */ + const Word32 data_fx[], /* i : input signal for single channel Q(q_data_fx) */ + const Word16 q_data_fx, /* i : Q-factor of input signal for single channel */ + const Word16 input_frame, /* i : input frame length per channel */ + const Word16 nb_bits_metadata /* i : number of metadata bits */ ); ivas_error ivas_cpe_enc_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const Word16 cpe_id, /* i : CPE # identifier */ - Word32 data_fx_ch0[], /* i : input signal for channel 0 Q(q_data_fx) */ - Word32 data_fx_ch1[], /* i : input signal for channel 1 Q(q_data_fx) */ - Word16 q_data_fx, /* i : Q-factor of input signal for both channels */ - const Word16 input_frame, /* i : input frame length per channel */ - const Word16 nb_bits_metadata, /* i : number of metadata bits */ - Word16 Q_new_out[] ); + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + const Word16 cpe_id, /* i : CPE # identifier */ + Word32 data_fx_ch0[], /* i : input signal for channel 0 Q(q_data_fx) */ + Word32 data_fx_ch1[], /* i : input signal for channel 1 Q(q_data_fx) */ + Word16 q_data_fx, /* i : Q-factor of input signal for both channels */ + const Word16 input_frame, /* i : input frame length per channel */ + const Word16 nb_bits_metadata, /* i : number of metadata bits */ + Word16 Q_new_out[] +); ivas_error ivas_mct_enc_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - Word32 *data_fx[MCT_MAX_CHANNELS], /* i : input signal buffers Q(q_data_fx) */ - Word16 q_data_fx, /* i : Q-factor of input signal */ - const Word16 input_frame, /* i : input frame length per channel */ - const Word16 nb_bits_metadata /* i : number of metadata bits */ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + Word32 *data_fx[MCT_MAX_CHANNELS], /* i : input signal buffers Q(q_data_fx) */ + Word16 q_data_fx, /* i : Q-factor of input signal */ + const Word16 input_frame, /* i : input frame length per channel */ + const Word16 nb_bits_metadata /* i : number of metadata bits */ ); ivas_error ivas_compute_core_buffers_fx( - Encoder_State *st, /* i/o: encoder state structure */ - Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame */ - Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz */ - Word16 new_inp_resamp16k_out_fx[], /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ - const Word16 input_frame, /* i : frame length */ - const Word16 last_element_mode, /* i : last element mode */ - const Word32 sr_core, /* i : core-coder sampling rate */ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r */ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */ - Word32 epsP[M + 1], /* i/o: LP prediction errors */ - Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */ - Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ + Encoder_State *st, /* i/o: encoder state structure */ + Word16 **inp16k_out_fx, /* o : ptr. to inp. signal in the current frame */ + Word16 *old_inp_16k_fx, /* i/o: buffer of old input signal @ 16kHz */ + Word16 new_inp_resamp16k_out_fx[], /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */ + const Word16 input_frame, /* i : frame length */ + const Word16 last_element_mode, /* i : last element mode */ + const Word32 sr_core, /* i : core-coder sampling rate */ + Word32 *ener_fx, /* o : residual energy from Levinson-Durbin Q_r */ + Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes */ + Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes */ + Word32 epsP[M + 1], /* i/o: LP prediction errors */ + Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame */ + Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame */ Word16 Q_old_inp_16k, Word16 Q_r[2], - Word16 *Q_new ); + Word16 *Q_new +); ivas_error ivas_enc_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const Word16 *data, /* i : input signal Q0 */ - const Word16 n_samples /* i : number of input samples */ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ + const Word16 *data, /* i : input signal Q0 */ + const Word16 n_samples /* i : number of input samples */ ); void reset_metadata_spatial_fx( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ - const Word32 element_brate, /* i : element bitrate */ - Word32 *total_brate, /* o : total bitrate */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 nb_bits_metadata /* i : number of meatdata bits */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ + const Word32 element_brate, /* i : element bitrate */ + Word32 *total_brate, /* o : total bitrate */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 nb_bits_metadata /* i : number of meatdata bits */ ); void Euler2Quat_fx( - const Word32 yaw, /* i : yaw (x) Q22 */ - const Word32 pitch, /* i : pitch (y) Q22 */ - const Word32 roll, /* i : roll (z) Q22 */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ + const Word32 yaw, /* i : yaw (x) Q22 */ + const Word32 pitch, /* i : pitch (y) Q22 */ + const Word32 roll, /* i : roll (z) Q22 */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ ); -float deg2rad( - float degrees ); Word32 deg2rad_fx( - Word32 degrees ); + Word32 degrees +); void Quat2EulerDegree_fx( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - Word32 *yaw_fx, /* o : yaw */ - Word32 *pitch_fx, /* o : pitch */ - Word32 *roll_fx /* o : roll */ + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + Word32 *yaw_fx, /* o : yaw */ + Word32 *pitch_fx, /* o : pitch */ + Word32 *roll_fx /* o : roll */ ); void Copy_Quat_fx( - const IVAS_QUATERNION *in_quat, /* i : quaternion describing the rotation */ - IVAS_QUATERNION *out_quat /* i : quaternion describing the rotation */ + const IVAS_QUATERNION *in_quat, /* i : quaternion describing the rotation */ + IVAS_QUATERNION *out_quat /* o : quaternion describing the rotation */ ); void modify_Quat_q_fx( - const IVAS_QUATERNION *in_quat, /* i : quaternion describing the rotation */ - IVAS_QUATERNION *out_quat, /* i : quaternion describing the rotation */ - Word16 q_new /* i : quaternion describing the rotation */ + const IVAS_QUATERNION *in_quat, /* i : quaternion describing the rotation */ + IVAS_QUATERNION *out_quat, /* i : quaternion describing the rotation */ + Word16 q_new /* o : quaternion describing the rotation */ ); void modify_Rmat_q_fx( - Word32 Rmat_in[3][3], /* i : real-space rotation matrix for this rotation */ - Word32 Rmat_out[3][3], /* o : real-space rotation matrix for this rotation*/ - Word16 q_cur, /* i : current q factor for rotation matrix */ - Word16 q_new /* i : target q factor for rotation matrix */ + Word32 Rmat_in[3][3], /* i : real-space rotation matrix for this rotation */ + Word32 Rmat_out[3][3], /* o : real-space rotation matrix for this rotation */ + Word16 q_cur, /* i : current q factor for rotation matrix */ + Word16 q_new /* i : target q factor for rotation matrix */ ); -/*=============================================================================================*/ -/* clang-format off */ + /*----------------------------------------------------------------------------------* * General IVAS prototypes *----------------------------------------------------------------------------------*/ -/*! r: number of channels to be analysed */ - void copy_encoder_config_ivas_fx( Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ Encoder_State *st, /* o : encoder state structure */ - const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ + const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ ); ivas_error create_mct_enc_fx( @@ -6027,96 +6102,97 @@ void ivas_mct_enc_close_fx( ); ivas_error pre_proc_front_ivas_fx( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ - const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - const Word16 n, /* i : channel number Q0*/ - Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/ - Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 *relE_fx, /* o : frame relative energy Q8*/ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/ - Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/ + SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ + const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + const Word16 n, /* i : channel number Q0*/ + Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/ + Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/ + Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ + Word16 *relE_fx, /* o : frame relative energy Q8*/ + Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/ + Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/ Word16 *epsP_fx_q, - Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/ - Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/ - Word16 *attack_flag, /* o : flag signaling attack Q0*/ + Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/ + Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/ + Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/ + Word16 *attack_flag, /* o : flag signaling attack Q0*/ Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/ Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/ - Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */ - Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/ + Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */ + Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/ Word16 *q_old_wsp, - Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/ - Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/ - Word16 *loc_harm, /* o : harmonicity flag Q0*/ - Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/ - Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/ - Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ - Word16 *enerBuffer_fx_exp, /* o : energy buffer */ - Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/ - Word16 *fft_buff_fx_q, /* o : FFT buffer */ - const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/ - const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/ - const Word32 currFlatness_fx, /* i : flatness parameter Q21*/ - const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/ - Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/ + Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/ + Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/ + Word16 *loc_harm, /* o : harmonicity flag Q0*/ + Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/ + Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/ + Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ + Word16 *enerBuffer_fx_exp, /* o : energy buffer */ + Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/ + Word16 *fft_buff_fx_q, /* o : FFT buffer */ + const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/ + const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/ + const Word32 currFlatness_fx, /* i : flatness parameter Q21*/ + const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/ + Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/ Word16 fr_bands_LR_fx_q[CPE_CHANNELS], - const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/ - Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/ + const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/ + Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/ Word16 lf_E_LR_fx_q, - const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ - Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/ + const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ + Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/ Word16 band_energies_LR_fx_q, - const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ - const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ - const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ - const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ - const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ + const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ + const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ + const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ + const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ + const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ Word16 *Q_new #ifdef DEBUG_MODE_INFO , const Word16 ch_idx #endif ); + ivas_error pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 last_element_mode, /* i : last element mode Q0*/ - const Word32 element_brate, /* i : element bitrate Q0*/ - const Word32 last_element_brate, /* i : last element bitrate Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */ - Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */ - Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/ - Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/ - Word16 *epsP_fx_q, /* i : LP prediction errors */ - Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ - Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/ - Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/ - Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/ + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 last_element_mode, /* i : last element mode Q0*/ + const Word32 element_brate, /* i : element bitrate Q0*/ + const Word32 last_element_brate, /* i : last element bitrate Q0*/ + const Word16 input_frame, /* i : frame length Q0*/ + Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */ + Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */ + Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/ + Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ + Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/ + Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/ + Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/ + Word16 *epsP_fx_q, /* i : LP prediction errors */ + Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ + Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ + Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/ + Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/ + Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/ Word16 e_old_wsp, - const Word16 loc_harm, /* i : harmonicity flag Q0*/ - const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ - Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */ + const Word16 loc_harm, /* i : harmonicity flag Q0*/ + const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ + const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ + const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ + Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */ Word16 e_enerBuffer, - Word16 fft_buff_fx[2 * L_FFT], /* Qx */ - Word16 cor_map_sum_fx, /* Q8 */ + Word16 fft_buff_fx[2 * L_FFT], /* Qx */ + Word16 cor_map_sum_fx, /* Q8 */ Word16 *Q_new ); -/*! r: number of clipped samples */ + void ivas_initialize_handles_enc_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -6142,13 +6218,10 @@ ivas_error ivas_init_decoder_front( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); - void ivas_mct_dec_close( MCT_DEC_HANDLE *hMCT /* i/o: MCT decoder structure */ ); -/*! r: number of channels to be synthesised */ - void copy_decoder_config( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ Decoder_State *st /* o : decoder state structure */ @@ -6204,8 +6277,8 @@ Word16 is_IVAS_bitrate_fx( const Word32 ivas_total_brate /* i : IVAS total bitrate */ ); -int16_t is_DTXrate( - const int32_t ivas_total_brate /* i : IVAS total bitrate */ +Word16 is_DTXrate( + const Word32 ivas_total_brate /* i : IVAS total bitrate */ ); @@ -6255,6 +6328,7 @@ void ivas_ism_reset_metadata( void ivas_ism_reset_metadata_enc( ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */ ); + void ivas_ism_reset_metadata_API( ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ ); @@ -6320,12 +6394,11 @@ void ivas_ism_metadata_sid_enc_fx( Word16 nb_bits_metadata[] /* o : number of metadata bits */ ); - - void ivas_param_ism_compute_noisy_speech_flag_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); + /*----------------------------------------------------------------------------------* * DFT Stereo prototypes *----------------------------------------------------------------------------------*/ @@ -6346,14 +6419,14 @@ UWord16 rc_uni_dec_read_bit( /*! r: Read bit */ UWord16 rc_uni_dec_read_bit_prob_fast( RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ - const Word16 freq0, /* i : Frequency for symbol 0 */ - const UWord16 tot_shift /* i : Total frequency as a power of 2 */ + const Word16 freq0, /* i : Frequency for symbol 0 */ + const UWord16 tot_shift /* i : Total frequency as a power of 2 */ ); /*! r: Read bits */ UWord16 rc_uni_dec_read_bits( RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ - const Word16 bits /* i : Number of bits */ + const Word16 bits /* i : Number of bits */ ); @@ -6380,10 +6453,9 @@ void tdm_bit_alloc( const Word16 tdm_inst_ratio_idx /* i : instantaneous correlation ratio index */ ); - /*! r: value of the indice */ -uint16_t get_indice_st( - Decoder_State *st, /* i/o: decoder state structure */ +UWord16 get_indice_st( + Decoder_State *st, /* i/o: decoder state structure */ const Word32 element_brate, /* i : element bitrate */ const Word16 pos, /* i : absolute position in the bitstream */ const Word16 nb_bits /* i : number of bits to quantize the indice */ @@ -6395,26 +6467,27 @@ uint16_t get_indice_st( void stereo_mdct_core_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/ - Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ - Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ + Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/ + Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ + Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ ); Word16 write_stereo_to_bitstream_fx ( STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */ Encoder_State **sts, /* i/o: Encoder state structure */ - Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/ - const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ + Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/ + const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ ); /*----------------------------------------------------------------------------------* * Stereo CNG prototypes *----------------------------------------------------------------------------------*/ + void stereo_cng_dec_update( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ + const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ ); @@ -6423,9 +6496,9 @@ void stereo_cng_dec_update( *----------------------------------------------------------------------------------*/ void mvc2c( - const uint8_t x[], /* i : input vector */ - uint8_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ + const UWord8 x[], /* i : input vector */ + UWord8 y[], /* o : output vector */ + const Word16 n /* i : vector size */ ); void stereo_switching_dec( @@ -6434,28 +6507,25 @@ void stereo_switching_dec( ); -/*! r: number of bits written */ - - - /*----------------------------------------------------------------------------------* * MCT prototypes *----------------------------------------------------------------------------------*/ + void ivas_mdct_core_whitening_enc_fx( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples */ - Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ - Word16 pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */ - Word32 *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */ - Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* o : buffer TNS bits */ - Word32 *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening */ - Word16 tnsSize[CPE_CHANNELS][NB_DIV], /* o : size of TNS */ - Word16 p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to parameter array */ + Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples */ + Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ + Word16 pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */ + Word32 *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */ + Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* o : buffer TNS bits */ + Word32 *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening */ + Word16 tnsSize[CPE_CHANNELS][NB_DIV], /* o : size of TNS */ + Word16 p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to parameter array */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */ + const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */ const Word16 nChannels, /* i : total number of coded channels */ -Word16 mdst_spectrum_e[CPE_CHANNELS][NB_DIV], -Word16 orig_spectrum_e[CPE_CHANNELS][NB_DIV] + Word16 mdst_spectrum_e[CPE_CHANNELS][NB_DIV], + Word16 orig_spectrum_e[CPE_CHANNELS][NB_DIV] ); void splitAvailableBitsMCT_fx( @@ -6471,24 +6541,24 @@ void enc_prm_igf_mdct( BSTR_ENC_HANDLE hBstr /* i/o: Bitstream handle */ ); + /*----------------------------------------------------------------------------------* * Q Metadata prototypes for DirAC and MASA *----------------------------------------------------------------------------------*/ -/*! r: number of bits written */ /*! r: number of bits read */ Word16 ivas_qmetadata_dec_decode( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - UWord16 *bitstream, /* i : bitstream */ - Word16 *index, /* i/o: bitstream position */ - const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */ + UWord16 *bitstream, /* i : bitstream */ + Word16 *index, /* i/o: bitstream position */ + const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */ ); /*! r: number of bits read */ Word16 ivas_qmetadata_dec_decode_hr_384_512( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */ - UWord16 *bitstream, /* i : bitstream */ - Word16 *index, /* i/o: bitstream position */ + UWord16 *bitstream, /* i : bitstream */ + Word16 *index, /* i/o: bitstream position */ const SPHERICAL_GRID_DATA *sph_grid16, /* i : spherical grid for deindexing */ const Word16 bits_sph_idx, const Word16 bits_sp_coh, @@ -6498,14 +6568,13 @@ Word16 ivas_qmetadata_dec_decode_hr_384_512( /*! r: number of bits read */ Word16 ivas_qmetadata_dec_sid_decode( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - UWord16 *bitstream, /* i : bitstream */ - Word16 *index, /* i/o: bitstream position */ - const Word16 nchan_transport, /* i : number of transport channels */ - Word16 *element_mode, /* o : element mode */ - const Word16 ivas_format /* i : IVAS format */ + UWord16 *bitstream, /* i : bitstream */ + Word16 *index, /* i/o: bitstream position */ + const Word16 nchan_transport, /* i : number of transport channels */ + Word16 *element_mode, /* o : element mode */ + const Word16 ivas_format /* i : IVAS format */ ); - UWord16 ivas_qmetadata_reorder_generic_fx( const Word16 signed_value ); @@ -6530,7 +6599,6 @@ Word16 ivas_get_sba_dirac_stereo_flag( * DirAC prototypes *----------------------------------------------------------------------------------*/ - ivas_error ivas_dirac_enc_reconfigure( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); @@ -6541,7 +6609,7 @@ ivas_error ivas_mc_paramupmix_enc_open_fx( void ivas_mc_paramupmix_enc_close_fx( MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ - const int32_t input_Fs /* i : input sampling rate */ + const Word32 input_Fs /* i : input sampling rate */ ); ivas_error ivas_mc_paramupmix_dec_open( @@ -6556,13 +6624,13 @@ void ivas_mc_paramupmix_dec_read_BS( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Decoder_State *st, /* i/o: decoder state structure */ MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */ - Word16 *nb_bits /* o : number of bits written */ + Word16 *nb_bits /* o : number of bits written */ ); void ivas_mc_paramupmix_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - const Word16 nSamplesForRendering /* i : number of samples provided */ + const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + const Word16 nSamplesForRendering /* i : number of samples provided */ ); void ivas_param_mc_set_coded_bands_fx( @@ -6570,10 +6638,11 @@ void ivas_param_mc_set_coded_bands_fx( ); UWord16 ivas_param_mc_get_configuration_index_fx( - const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ + const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ + const Word32 ivas_total_brate /* i : IVAS total bitrate */ ); + /*----------------------------------------------------------------------------------* * SPAR prototypes *----------------------------------------------------------------------------------*/ @@ -6584,10 +6653,10 @@ UWord16 ivas_param_mc_get_configuration_index_fx( ivas_error ivas_spar_md_dec_open( ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const Word16 num_channels, /* i : number of internal channels */ - const Word16 sba_order, /* i : SBA order */ - const Word16 sid_format, /* i : SID format */ - const Word32 last_active_ivas_total_brate /* i : IVAS last active bitrate */ + const Word16 num_channels, /* i : number of internal channels */ + const Word16 sba_order, /* i : SBA order */ + const Word16 sid_format, /* i : SID format */ + const Word32 last_active_ivas_total_brate /* i : IVAS last active bitrate */ ); void ivas_spar_md_dec_close( @@ -6597,14 +6666,14 @@ void ivas_spar_md_dec_close( ivas_error ivas_spar_md_dec_init( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const Word16 num_channels, /* i : number of internal channels */ - const Word16 sba_order /* i : SBA order */ + const Word16 num_channels, /* i : number of internal channels */ + const Word16 sba_order /* i : SBA order */ ); /* Transient detector module */ ivas_error ivas_transient_det_open_fx( ivas_trans_det_state_t **hTranDet, /* i/o: Transient detector handle */ - const Word32 sampling_rate /* i : sampling rate */ + const Word32 sampling_rate /* i : sampling rate */ ); void ivas_transient_det_close_fx( @@ -6650,6 +6719,7 @@ void ivas_clear_band_coeff_idx( /*----------------------------------------------------------------------------------* * MASA prototypes *----------------------------------------------------------------------------------*/ + ivas_error ivas_masa_enc_open_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); @@ -6658,17 +6728,18 @@ void ivas_masa_enc_close_fx( MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */ ); -int16_t ivas_qmetadata_encode_extended_gr_length_fx( +Word16 ivas_qmetadata_encode_extended_gr_length_fx( const UWord16 value, const UWord16 alphabet_size, - const Word16 gr_param); + const Word16 gr_param +); void ivas_qmetadata_encode_extended_gr_fx( - BSTR_ENC_HANDLE hMetaData, /* i/o: q_metadata handle */ - const UWord16 value, /* i : value to be encoded */ - const UWord16 alphabet_size, /* i : alphabet size */ - const Word16 gr_param); /* i : GR order */ - + BSTR_ENC_HANDLE hMetaData, /* i/o: q_metadata handle */ + const UWord16 value, /* i : value to be encoded */ + const UWord16 alphabet_size, /* i : alphabet size */ + const Word16 gr_param /* i : GR order */ +); void ivas_set_qmetadata_maxbit_req_fx( IVAS_QMETADATA_HANDLE hQMetaData, /* o : qmetadata structure where the requirement value is set */ @@ -6680,7 +6751,6 @@ void ivas_set_qmetadata_maxbit_req_fx( * Binaural FastConv Renderer Prototypes *-----------------------------------------------------------------------------------*/ - void ivas_binaural_hrtf_close( HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */ ); @@ -6710,24 +6780,22 @@ void panning_wrap_angles( * McMASA prototypes *----------------------------------------------------------------------------------*/ - ivas_error ivas_mcmasa_dec_reconfig( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); void ivas_mcmasa_dmx_modify_fx( - const Word16 n_samples, /* i : input frame length in samples */ - Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/ - Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/ - const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */ - const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/ + const Word16 n_samples, /* i : input frame length in samples */ + Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/ + Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/ + const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */ + const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/ ); ivas_error ivas_mono_dmx_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); - void ivas_mono_dmx_renderer_close( MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ ); @@ -6748,7 +6816,7 @@ void ivas_lfe_lpf_enc_close_fx( ivas_error ivas_create_lfe_enc_fx( LFE_ENC_HANDLE *hLFE, /* o : IVAS LFE encoder structure */ - const Word32 input_Fs /* i : input sampling rate */ + const Word32 input_Fs /* i : input sampling rate */ ); void ivas_lfe_enc_close_fx( @@ -6756,20 +6824,23 @@ void ivas_lfe_enc_close_fx( ); void ivas_filters_init_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - const Word32 *filt_coeff_fx, /* i : filter coefficients Q31- *filt_coeff_e */ - const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */ - const Word16 order ) ; + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + const Word32 *filt_coeff_fx, /* i : filter coefficients Q31- *filt_coeff_e */ + const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */ + const Word16 order +); void ivas_filter_process_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ - const Word16 length, /* i : filter order */ - Word16 q_factor ); + ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ + Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ + const Word16 length, /* i : filter order */ + Word16 q_factor +); /*----------------------------------------------------------------------------------* * OSBA prototypes *----------------------------------------------------------------------------------*/ + ivas_error ivas_osba_enc_reconfig( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -6784,7 +6855,7 @@ void ivas_set_surplus_brate_enc( void ivas_set_surplus_brate_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int32_t *ism_total_brate /* i : ISM total bitrate */ + Word32 *ism_total_brate /* i : ISM total bitrate */ ); ivas_error ivas_omasa_separate_object_renderer_open( @@ -6795,21 +6866,20 @@ void ivas_omasa_separate_object_renderer_close( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); + /*----------------------------------------------------------------------------------* * Filter-bank (FB) Mixer *----------------------------------------------------------------------------------*/ ivas_error ivas_fb_set_cfg( IVAS_FB_CFG **pFb_cfg_out, /* o : FB config. handle */ - const Word16 ivas_format, /* i : IVAS format */ - const Word16 num_in_chans, /* i : number of FB input channels */ - const Word16 num_out_chans, /* i : number of FB output channels */ - const Word16 active_w_mixing, /* i : active_w_mixing flag */ - const Word32 sampling_Fs, /* i : sampling rate */ - const Word16 nachan_dirac_ana /* i : number of DirAR analysis channels */ + const Word16 ivas_format, /* i : IVAS format */ + const Word16 num_in_chans, /* i : number of FB input channels */ + const Word16 num_out_chans, /* i : number of FB output channels */ + const Word16 active_w_mixing, /* i : active_w_mixing flag */ + const Word32 sampling_Fs, /* i : sampling rate */ + const Word16 nachan_dirac_ana /* i : number of DirAR analysis channels */ ); -/*=============================================================================================*/ - #endif diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 64fe2ba37..653968a4f 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -2583,6 +2583,7 @@ const Word16 ivas_lfe_num_dct_pass_bins_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP] = { 8 const Word16 ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP] = { 1, 0 }; const Word16 ivas_lfe_lpf_delay_Q15[2] = { 57, 114 }; + const Word32 ivas_lfe_lpf_delay_ns[2] = { 1750000, 3500000 }; const Word16 dirac_gains_P_idx[16] = diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index 58c8444f8..bc27d4878 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -1807,7 +1807,6 @@ const Word16 ivas_lpf_4_butter_48k_sos_e[IVAS_BIQUAD_FILT_LEN << 2] = { -27, -26, -27, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - const Word32 ivas_lfe_window_coeff_48k_fx[IVAS_LFE_FADE_LEN_48K] = { // Q31 0x0003a373, 0x000608f6, 0x000888a7, 0x000b3e1b, 0x000e34f1, 0x001174a2, 0x00150328, 0x0018e5e1, 0x001d21eb, 0x0021bc4d, 0x0026ba09, 0x002c202f, 0x0031f3dc, 0x00383a43, 0x003ef8ad, 0x0046347b, 0x004df325, 0x00563a3f, 0x005f0f74, 0x00687888, 0x00727b59, 0x007d1ddb, 0x0088661c, 0x00945a41, 0x00a10087, 0x00ae5f3d, 0x00bc7ccd, 0x00cb5fb3, 0x00db0e7d, 0x00eb8fd0, 0x00fcea61, 0x010f24f8, 0x0122466a, 0x013655a0, 0x014b598e, 0x01615936, 0x01785ba8, 0x01906800, 0x01a9855e, 0x01c3baf0, 0x01df0fee, 0x01fb8b90, 0x02193514, 0x023813c4, 0x02582ee4, 0x02798db8, 0x029c378c, 0x02c033a4, 0x02e58944, 0x030c3fa8, 0x03345e0c, 0x035deba0, 0x0388ef8c, 0x03b570f0, 0x03e376dc, 0x04130858, 0x04442c58, 0x0476e9b8, 0x04ab4760, 0x04e14c00, 0x0518fe48, 0x055264c8, 0x058d8600, 0x05ca6850, 0x06091200, 0x06498930, 0x068bd3f0, 0x06cff830, 0x0715fba8, 0x075de408, 0x07a7b6c8, 0x07f37940, 0x084130a0, 0x0890e200, 0x08e29220, 0x093645c0, 0x098c0150, 0x09e3c940, 0x0a3da180, 0x0a998e30, 0x0af792e0, 0x0b57b320, 0x0bb9f240, 0x0c1e5360, 0x0c84d940, 0x0ced8690, 0x0d585dc0, 0x0dc560f0, 0x0e349200, 0x0ea5f2b0, 0x0f198450, 0x0f8f4820, 0x10073f00, 0x10816980, 0x10fdc840, 0x117c5b00, 0x11fd21e0, 0x12801c60, 0x130549a0, 0x138ca8c0, 0x14163880, 0x14a1f740, 0x152fe320, 0x15bffa00, 0x16523980, 0x16e69ee0, 0x177d2700, 0x1815cec0, 0x18b09260, 0x194d6e00, 0x19ec5d60, 0x1a8d5c20, 0x1b306580, 0x1bd57440, 0x1c7c8300, 0x1d258c40, 0x1dd08a00, 0x1e7d7600, 0x1f2c49a0, 0x1fdcfe20, 0x208f8c40, 0x2143ed00, 0x21fa1840, 0x22b20680, 0x236baf40, 0x24270a00, 0x24e40e00, 0x25a2b280, 0x2662ee00, 0x2724b700, 0x27e80400, 0x28acca80, 0x297300c0, 0x2a3a9c00, 0x2b039180, 0x2bcdd680, 0x2c995fc0, 0x2d6621c0, 0x2e341140, 0x2f032240, 0x2fd34900, 0x30a47900, 0x3176a640, 0x3249c440, 0x331dc600, 0x33f29f40, 0x34c842c0, 0x359ea340, 0x3675b3c0, 0x374d66c0, 0x3825af00, 0x38fe7ec0, 0x39d7c880, 0x3ab17e40, 0x3b8b9240, 0x3c65f6c0, 0x3d409d80, 0x3e1b7880, 0x3ef679c0, 0x3fd19340, 0x40acb680, 0x4187d580, 0x4262e280, 0x433dce80, 0x44188c00, 0x44f30c80, 0x45cd4180, 0x46a71e00, 0x47809300, 0x48599300, 0x49320f80, 0x4a09fb80, 0x4ae14880, 0x4bb7e900, 0x4c8dcf80, 0x4d62ee80, 0x4e373880, 0x4f0aa080, 0x4fdd1900, 0x50ae9600, 0x517f0980, 0x524e6780, 0x531ca380, 0x53e9b100, 0x54b58400, 0x55801080, 0x56494b00, 0x57112800, 0x57d79c00, 0x589c9c00, 0x59601d00, 0x5a221480, 0x5ae27880, 0x5ba13e00, 0x5c5e5c00, 0x5d19c880, 0x5dd37a80, 0x5e8b6800, 0x5f418980, 0x5ff5d580, 0x60a84480, 0x6158ce00, 0x62076a80, 0x62b41280, 0x635ebf80, 0x64076a80, 0x64ae0d00, 0x6552a100, 0x65f52080, 0x66958680, 0x6733cd00, 0x67cff000, 0x6869ea80, 0x6901b880, 0x69975600, 0x6a2abf80, 0x6abbf200, 0x6b4aea80, 0x6bd7a680, 0x6c622300, 0x6cea5f80, 0x6d705900, 0x6df40f00, 0x6e758080, 0x6ef4ac80, 0x6f719300, 0x6fec3380, 0x70648f00, 0x70daa580, 0x714e7880, 0x71c00880, 0x722f5780, 0x729c6700, 0x73073980, 0x736fd100, 0x73d62f80, 0x743a5900, 0x749c5080, 0x74fc1880, 0x7559b600, 0x75b52b80, 0x760e7e80, 0x7665b280, 0x76bacc80, 0x770dd180, 0x775ec600, 0x77adb000, 0x77fa9480, 0x78457900, 0x788e6400, 0x78d55b80, 0x791a6500, 0x795d8780, 0x799ec900, 0x79de3100, 0x7a1bc580, 0x7a578d80, 0x7a919100, 0x7ac9d600, 0x7b006500, 0x7b354400, 0x7b687b80, 0x7b9a1300, 0x7bca1180, 0x7bf87f80, 0x7c256400, 0x7c50c780, 0x7c7ab180, 0x7ca32a00, 0x7cca3900, 0x7cefe600, 0x7d143900, 0x7d373a80, 0x7d58f280, 0x7d796800, 0x7d98a380, 0x7db6ad00, 0x7dd38c80, 0x7def4900, 0x7e09eb00, 0x7e237a00, 0x7e3bfd80, 0x7e537d80, 0x7e6a0180, 0x7e7f9080, 0x7e943200, 0x7ea7ed80, 0x7ebaca00, 0x7ecccf00, 0x7ede0300, 0x7eee6d00, 0x7efe1400, 0x7f0cfe80, 0x7f1b3380, 0x7f28b900, 0x7f359500, 0x7f41ce80, 0x7f4d6b80, 0x7f587180, 0x7f62e680, 0x7f6cd000, 0x7f763400, 0x7f7f1780, 0x7f878080, 0x7f8f7380, 0x7f96f580, 0x7f9e0b80, 0x7fa4bb00, 0x7fab0780, 0x7fb0f600, 0x7fb68b00, 0x7fbbca00, 0x7fc0b800, 0x7fc55880, 0x7fc9af80, 0x7fcdc080, 0x7fd18f00, 0x7fd51e80, 0x7fd87280, 0x7fdb8d80, 0x7fde7380, 0x7fe12700, 0x7fe3aa80, 0x7fe60100, 0x7fe82d00, 0x7fea3180, 0x7fec1000, 0x7fedcb00, 0x7fef6500, 0x7ff0e000, 0x7ff23e00, 0x7ff38080, 0x7ff4a980, 0x7ff5ba80, 0x7ff6b580, 0x7ff79c00, 0x7ff86e80, 0x7ff92f80, 0x7ff9e000, 0x7ffa8100, 0x7ffb1380, 0x7ffb9880, 0x7ffc1180, 0x7ffc7f80, 0x7ffce300, 0x7ffd3c80, 0x7ffd8d80, 0x7ffdd680, 0x7ffe1880, 0x7ffe5300, 0x7ffe8800, 0x7ffeb700, 0x7ffee100, 0x7fff0600, 0x7fff2700, 0x7fff4480, 0x7fff5e80, 0x7fff7500, 0x7fff8900, 0x7fff9a80, 0x7fffaa00, 0x7fffb780, 0x7fffc300, 0x7fffcd00, 0x7fffd580, 0x7fffdc80, 0x7fffe300, 0x7fffe880, 0x7fffec80, 0x7ffff080, 0x7ffff380, 0x7ffff680, 0x7ffff880, 0x7ffffa00, 0x7ffffb80, 0x7ffffc80, 0x7ffffd80, 0x7ffffe80, 0x7fffff00, 0x7fffff00, 0x7fffff80, 0x7fffff80, 0x7fffffff, 0x7fffffff }; diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index 78a0837ab..1e55cf068 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -83,9 +83,10 @@ void Euler2Quat_fx( * * Quaternion q factor modification *------------------------------------------------------------------------*/ + void Copy_Quat_fx( const IVAS_QUATERNION *in_quat, /* i : quaternion describing the rotation */ - IVAS_QUATERNION *out_quat /* i : quaternion describing the rotation */ + IVAS_QUATERNION *out_quat /* o : quaternion describing the rotation */ ) { out_quat->q_fact = in_quat->q_fact; @@ -102,14 +103,16 @@ void Copy_Quat_fx( return; } + /*------------------------------------------------------------------------- * Scale_Quat_fx() * * Quaternion q factor modification *------------------------------------------------------------------------*/ + void modify_Quat_q_fx( const IVAS_QUATERNION *in_quat, /* i : quaternion describing the rotation */ - IVAS_QUATERNION *out_quat, /* i : quaternion describing the rotation */ + IVAS_QUATERNION *out_quat, /* o : quaternion describing the rotation */ Word16 q_new /* i : quaternion describing the rotation */ ) { @@ -121,16 +124,18 @@ void modify_Quat_q_fx( return; } + /*------------------------------------------------------------------------- * modify_Rmat_q_fx() * * Rotation matrix q factor modification *------------------------------------------------------------------------*/ + void modify_Rmat_q_fx( - Word32 Rmat_in[3][3], /* i : real-space rotation matrix for this rotation */ - Word32 Rmat_out[3][3], /* o : real-space rotation matrix for this rotation*/ + Word32 Rmat_in[3][3], /* i : real-space rotation matrix for this rotation */ + Word32 Rmat_out[3][3], /* o : real-space rotation matrix for this rotation */ Word16 q_cur, /* i : current q factor for rotation matrix */ - Word16 q_new /* i : target q factor for rotation matrix */ + Word16 q_new /* i : target q factor for rotation matrix */ ) { Word16 j, k; @@ -146,11 +151,13 @@ void modify_Rmat_q_fx( return; } + /*------------------------------------------------------------------------- * Quat2EulerDegree() * * Quaternion handling: calculate corresponding Euler angles in degrees *------------------------------------------------------------------------*/ + void Quat2EulerDegree_fx( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ Word32 *yaw_fx, /* o : yaw */ @@ -238,6 +245,7 @@ void Quat2EulerDegree_fx( * * Converts degrees to normalized radians *------------------------------------------------------------------------*/ + Word32 deg2rad_fx( Word32 degrees // Q22 ) @@ -253,18 +261,3 @@ Word32 deg2rad_fx( return Mpy_32_32( PI_OVER_180_FX, degrees ); // Q22 } - -float deg2rad( - float degrees ) -{ - while ( degrees >= 180.0f ) - { - degrees = degrees - 360.0f; - } - while ( degrees <= -180.0f ) - { - degrees = degrees + 360.0f; - } - - return PI_OVER_180 * degrees; -} diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 9001276bf..2aa66792f 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -2124,6 +2124,7 @@ static float wrap_azi( return azi; } + /* helper function for panning_wrap_angles */ static Word32 wrap_azi_fx( const Word32 azi_deg /* Q22 */ ) @@ -2144,6 +2145,8 @@ static Word32 wrap_azi_fx( return azi; /*Q22*/ } + + /*-------------------------------------------------------------------* * panning_wrap_angles() * @@ -2152,6 +2155,7 @@ static Word32 wrap_azi_fx( * elevation = [-90, 90] * Considers direction changes from large elevation values *-------------------------------------------------------------------*/ + void panning_wrap_angles( const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ @@ -2211,6 +2215,8 @@ void panning_wrap_angles( return; } } + + /*-------------------------------------------------------------------* * panning_wrap_angles_fx() * @@ -2219,6 +2225,7 @@ void panning_wrap_angles( * elevation = [-90, 90] * Considers direction changes from large elevation values *-------------------------------------------------------------------*/ + void panning_wrap_angles_fx( const Word32 azi_deg, /* i : azimuth in degrees for panning direction (positive left) Q22 */ const Word32 ele_deg, /* i : elevation in degrees for panning direction (positive up) Q22 */ diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c index c8cc09e73..607d6787f 100644 --- a/lib_com/lpc_tools_fx.c +++ b/lib_com/lpc_tools_fx.c @@ -584,7 +584,7 @@ Word16 E_LPC_lev_dur_stab( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /*QR /*------------------------------------------* * Compute new LPC coeff. -> An[i] - * An[j]= A[j] + K*A[i-j] , j=1 to i-1 + * An[j]= A[j] + K*A[i-j], j=1 to i-1 * An[i]= K *------------------------------------------*/ @@ -801,7 +801,7 @@ Word16 E_LPC_lev_dur_stab_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 /*------------------------------------------* * Compute new LPC coeff. -> An[i] - * An[j]= A[j] + K*A[i-j] , j=1 to i-1 + * An[j]= A[j] + K*A[i-j], j=1 to i-1 * An[i]= K *------------------------------------------*/ @@ -1019,7 +1019,7 @@ Word16 E_LPC_lev_dur_stab_fx( const Word16 Rh[] /*QR -16*/, const Word16 Rl[] /* /*------------------------------------------* * Compute new LPC coeff. -> An[i] - * An[j]= A[j] + K*A[i-j] , j=1 to i-1 + * An[j]= A[j] + K*A[i-j], j=1 to i-1 * An[i]= K *------------------------------------------*/ diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 80e597e1a..7c6406879 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -4147,7 +4147,7 @@ void dec_FDCNG_MSVQ_stage1_fx( { dct_vec[col] = shl( cbpW8[col], dct_col_shift_tab[col] ); // Q0 move32(); - /* LOGIC( 1 ) , SHIFT( 1 ); + /* LOGIC( 1 ), SHIFT( 1 ); in BASOP: s_and(for W8->W16), shl() */ } diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index ddd0bfdcc..4aa6e2ea0 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -32,6 +32,7 @@ #ifndef PROT_FX2_H #define PROT_FX2_H + /*----------------------------------------------------------------------------------* * Prototypes of RAM counting tool macros *----------------------------------------------------------------------------------*/ @@ -166,6 +167,7 @@ Word16 L_get_q_buf1( float *ptr_flt, Word16 length ); /*================================================================================*/ /* conversion functions: */ /*================================================================================*/ + Word32 sum_l_fx( const Word32 *vec, /* i : input vector */ const Word16 lvec /* i : length of input vector */ @@ -212,8 +214,9 @@ void set32_fx( ); // tools.c -Word16 Random( /* o : output random value */ - Word16 *seed /* i/o: random seed */ +/* o : output random value */ +Word16 Random( + Word16 *seed /* i/o: random seed */ ); // tools.c @@ -255,14 +258,16 @@ void scale_sig( ); // tools.c -Word32 sum2_fx( /* o : sum of all squared vector elements Q(2x+1)*/ - const Word16 *vec, /* i : i vector Qx*/ - const Word16 lvec /* i : length of i vector */ +/* o : sum of all squared vector elements Q(2x+1)*/ +Word32 sum2_fx( + const Word16 *vec, /* i : i vector Qx*/ + const Word16 lvec /* i : length of i vector */ ); -Word64 sum2_fx_no_sat( /* o : sum of all squared vector elements Q(2x)*/ - const Word16 *vec, /* i : i vector Qx*/ - const Word16 lvec /* i : length of i vector */ +/* o : sum of all squared vector elements Q(2x)*/ +Word64 sum2_fx_no_sat( + const Word16 *vec, /* i : i vector Qx*/ + const Word16 lvec /* i : length of i vector */ ); Word16 sign_fx( @@ -272,6 +277,7 @@ Word16 sign_fx( Word16 sign16_fx( const Word16 x /* i : input value of x */ ); + /*========================================================================================================/ mslvq_com_fx.c /========================================================================================================*/ @@ -293,7 +299,9 @@ void deindex_lvq_SHB_fx( const Word16 nbits, const Word16 mode ); -Word32 encode_comb_fx( Word16 *cv, Word16 idx_lead ); +Word32 encode_comb_fx( + Word16 *cv, + Word16 idx_lead ); Word32 mslvq_ivas_16( Word16 *pTmp_fx, /* i : M-dimensional input vector */ @@ -366,7 +374,6 @@ void calc_normal_length_fx_32( Word16 *prev_L_swb_norm /*i/o : last normalize length : Q0 */ ); - void hq_generic_decoding_fx( const Word16 HQ_mode, /* i : HQ mode */ Word32 *coeff_out1_fx, /* i/o: BWE i & temporary buffer */ @@ -391,10 +398,11 @@ Word16 WB_BWE_gain_pred_fx( Word16 last_extl_fx, Word16 tilt_wb_fx ); -Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 */ - const Word16 *sp0, /* i : i signal */ - const Word16 exp, /* i : Exp of inp signal */ - const Word16 N /* i : signal length */ +/* o : Tilt in Q24 */ +Word32 calc_tilt_bwe_fx( + const Word16 *sp0, /* i : i signal */ + const Word16 exp, /* i : Exp of inp signal */ + const Word16 N /* i : signal length */ ); void calc_norm_envelop_fx( @@ -528,6 +536,7 @@ void calc_norm_fx( const Word16 *band_len, /* i : Length of bands Q0 */ const Word16 *band_start /* i : Start of bands Q0 */ ); + void calc_norm_ivas_fx( const Word32 *x_fx, /* i : Input vector.(Qin) */ Word16 *norm, /* o : Quantization indices for norms Q0 */ @@ -537,6 +546,7 @@ void calc_norm_ivas_fx( const Word16 *band_len, /* i : Length of bands */ const Word16 *band_start /* i : Start of bands */ ); + void logqnorm_ivas_fx( const Word32 *x_fx, /* i : coefficient vector Qq*/ const Word16 q, /* i : q of coefficient vector */ @@ -545,6 +555,7 @@ void logqnorm_ivas_fx( const Word16 N, /* i : sub-vector size */ const Word32 *thre_fxn /* i : quantization thresholds Q14*/ ); + /*========================================================================================================/ hq_tools_fx.c /========================================================================================================*/ @@ -556,16 +567,17 @@ void hq_swb_harmonic_calc_norm_envelop_fx( const Word16 SWB_flength /* i : length of i signal */ ); -Word16 build_nf_codebook_fx( /* o : Number of coefficients in nf codebook */ - const Word16 flag_32K_env_ho, /* i : Envelope attenuation hangover flag */ - const Word16 *coeff, /* i : Coded spectral coefficients */ - const Word16 *sfm_start, /* i : Subband start indices */ - const Word16 *sfmsize, /* i : Subband widths */ - const Word16 *sfm_end, /* i : Subband end indices */ - const Word16 last_sfm, /* i : Last coded band */ - const Word16 *R, /* i : Per-band bit allocation */ - Word16 *CodeBook, /* o : Noise-fill codebook */ - Word16 *CodeBook_mod /* o : Densified noise-fill codebook */ +/* o : Number of coefficients in nf codebook */ +Word16 build_nf_codebook_fx( + const Word16 flag_32K_env_ho, /* i : Envelope attenuation hangover flag */ + const Word16 *coeff, /* i : Coded spectral coefficients */ + const Word16 *sfm_start, /* i : Subband start indices */ + const Word16 *sfmsize, /* i : Subband widths */ + const Word16 *sfm_end, /* i : Subband end indices */ + const Word16 last_sfm, /* i : Last coded band */ + const Word16 *R, /* i : Per-band bit allocation */ + Word16 *CodeBook, /* o : Noise-fill codebook */ + Word16 *CodeBook_mod /* o : Densified noise-fill codebook */ ); void limit_band_noise_level_calc_fx( @@ -734,6 +746,7 @@ Word16 calc_nor_delta_hf_fx( const Word16 *sfm_start, /* i : Start index of bands */ const Word16 core_sfm /* i : index of the end band for core */ ); + Word16 calc_nor_delta_hf_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word32 *t_audio, /* i : transform-domain coefficients Qx*/ @@ -799,6 +812,7 @@ void enforce_zero_for_min_envelope_fx( const Word16 *sfm_start, /* i : Sub band start indices Q0 */ const Word16 *sfm_end /* i : Sub band end indices Q0 */ ); + void apply_envelope_enc_ivas_fx( const Word16 *coeff, /* i/o: Coded/noisefilled normalized spectrum Q12 */ const Word16 *norm, /* i : Envelope Q0 */ @@ -807,6 +821,7 @@ void apply_envelope_enc_ivas_fx( const Word16 *sfm_end, /* i : Sub band end indices Q0 */ Word32 *coeff_out /* o : coded/noisefilled spectrum Q12 */ ); + void apply_envelope_fx( const Word16 *coeff, /* i : Coded/noisefilled normalized spectrum Q12 */ const Word16 *norm, /* i : Envelope */ @@ -827,7 +842,10 @@ void apply_envelope_fx( lsf_tools_fx.c /========================================================================================================*/ -void compute_poly_product_fx( Word16 *coef, Word32 *p, Word16 order ); +void compute_poly_product_fx( + Word16 *coef, + Word32 *p, + Word16 order ); Word16 xsp_to_xsf( Word16 lsp ); @@ -836,8 +854,14 @@ Word16 xsf_to_xsp( Word16 lsf /* Q2.56 */ ); -void lsp_convolve_fx( Word32 x, Word32 *p1, Word32 *p2, Word16 len ); -Word32 poscos_fx( Word16 w ); +void lsp_convolve_fx( + Word32 x, + Word32 *p1, + Word32 *p2, + Word16 len ); + +Word32 poscos_fx( + Word16 w ); Word32 sub_lsp2lsf_fx( const Word16 lsp_i /* i : lsp[m] (range: -1<=val<1) Q15*/ @@ -848,22 +872,39 @@ void E_LPC_lsp_lsf_conversion( Word16 lsf[], /* output : lsf[m] normalized (range: 0<=val<=6400) */ const Word16 m /* i : LPC order */ ); + void E_LPC_lsf_lsp_conversion( const Word16 lsf[], /* i : lsf[m] normalized (range: 0<=val<=6400) */ Word16 lsp[], /* o : lsp[m] (range: -1<=val<1) */ const Word16 m /* i : LPC order */ ); -void E_LPC_f_lsp_a_conversion( const Word16 *lsp, Word16 *a, const Word16 m ); +void E_LPC_f_lsp_a_conversion( + const Word16 *lsp, + Word16 *a, + const Word16 m ); + void E_LPC_a_isp_conversion( const Word16 *a, /* i : LP filter coefficients */ Word16 *isp, /* o : Line spectral pairs (in the cosine domain) */ const Word16 *old_isp, /* i : LSP vector from past frame */ const Word16 m /* i : LPC order */ ); -void E_LPC_isp_isf_conversion( const Word16 isp[], Word16 isf[], const Word16 m ); -void E_LPC_isf_isp_conversion( const Word16 isf[], Word16 isp[], const Word16 m ); -void E_LPC_f_isp_a_conversion( const Word16 *isp, Word16 *a, const Word16 m ); + +void E_LPC_isp_isf_conversion( + const Word16 isp[], + Word16 isf[], + const Word16 m ); + +void E_LPC_isf_isp_conversion( + const Word16 isf[], + Word16 isp[], + const Word16 m ); + +void E_LPC_f_isp_a_conversion( + const Word16 *isp, + Word16 *a, + const Word16 m ); void E_LPC_a_lsp_conversion( const Word16 *a, /* i : LP filter coefficients */ @@ -897,14 +938,21 @@ void E_LPC_a_lsp_conversion( const Word16 m /* i : LPC order */ ); -void v_sort( Word16 *r, const Word16 lo, const Word16 up ); +void v_sort( + Word16 *r, + const Word16 lo, + const Word16 up ); -void compute_poly_product_fx( Word16 *coef, Word32 *p, Word16 order ); +void compute_poly_product_fx( + Word16 *coef, + Word32 *p, + Word16 order ); void dec_prm_hm_fx( Decoder_State *st, Word16 *prm_hm, /* Q0 */ const Word16 L_frame ); + void msvq_dec( const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) (0Q15) */ const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ @@ -926,23 +974,22 @@ void lsf_syn_mem_restore_fx( Word32 gc_threshold_fx, /* i: Q16 */ Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ Word16 next_force_sf_bck_fx, /* i: */ - - Word16 *lsp_new, /* o: LSP vector to quantize Q15 */ - Word16 *lsf_new, /* o: quantized LSF vector Q15 */ - Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */ - Word16 clip_var, /* i: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* i: quantizer memory for AR model Q15 */ - Word16 *mem_MA, /* i: quantizer memory for MA model Q15 */ - Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */ - Word16 *lsf_new_bck, /* i: quantized LSF vector - backup Q15 */ - Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */ - Word16 mCb1, /* i: counter for stationary frame after a transition frame */ - Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* i: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 mem_w0_bck, /* i: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 streaklimit, /* i:LSF quantizer Q15 */ - Word16 pstreaklen /* i:LSF quantizer */ + Word16 *lsp_new, /* o: LSP vector to quantize Q15 */ + Word16 *lsf_new, /* o: quantized LSF vector Q15 */ + Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */ + Word16 clip_var, /* i: pitch clipping state var Q(2.56) */ + Word16 *mem_AR, /* i: quantizer memory for AR model Q15 */ + Word16 *mem_MA, /* i: quantizer memory for MA model Q15 */ + Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */ + Word16 *lsf_new_bck, /* i: quantized LSF vector - backup Q15 */ + Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */ + Word16 mCb1, /* i: counter for stationary frame after a transition frame */ + Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ + Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ + Word16 *mem_syn_bck, /* i: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 mem_w0_bck, /* i: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 streaklimit, /* i:LSF quantizer Q15 */ + Word16 pstreaklen /* i:LSF quantizer */ ); void lsf_syn_mem_restore_ivas_fx( @@ -1049,25 +1096,28 @@ void lsp2isp_fx( const Word16 m /* i : order of LP analysis */ ); -Word16 lsf_stab_fx( /* o : LP filter stability Q15*/ - const Word16 *lsf, /* i : LSF vector Q(x2.56)*/ - const Word16 *lsfold, /* i : old LSF vector Q(x2.56)*/ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame /* i : frame length */ +/* o : LP filter stability Q15*/ +Word16 lsf_stab_fx( + const Word16 *lsf, /* i : LSF vector Q(x2.56)*/ + const Word16 *lsfold, /* i : old LSF vector Q(x2.56)*/ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame /* i : frame length */ ); -Word16 lsf_stab_ivas_fx( /* o : LP filter stability Q15*/ - const Word16 *lsf, /* i : LSF vector Q(x2.56)*/ - const Word16 *lsfold, /* i : old LSF vector Q(x2.56)*/ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame /* i : frame length */ +/* o : LP filter stability Q15*/ +Word16 lsf_stab_ivas_fx( + const Word16 *lsf, /* i : LSF vector Q(x2.56)*/ + const Word16 *lsfold, /* i : old LSF vector Q(x2.56)*/ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame /* i : frame length */ ); -Word16 lsf_stab_ivas_fx( /* o : LP filter stability Q15*/ - const Word16 *lsf, /* i : LSF vector Q(x2.56)*/ - const Word16 *lsfold, /* i : old LSF vector Q(x2.56)*/ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame /* i : frame length */ +/* o : LP filter stability Q15*/ +Word16 lsf_stab_ivas_fx( + const Word16 *lsf, /* i : LSF vector Q(x2.56)*/ + const Word16 *lsfold, /* i : old LSF vector Q(x2.56)*/ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame /* i : frame length */ ); void reorder_isf_fx( @@ -1123,7 +1173,11 @@ Word16 vq_dec_lvq_ivas_fx( Word16 mode, /* (i): mode_lvq, or mode_lvq_p */ Word16 no_bits /* (i): no. bits for lattice */ ); -void a2rc_fx( const Word16 *a, Word16 *refl, Word16 lpcorder ); + +void a2rc_fx( + const Word16 *a, + Word16 *refl, + Word16 lpcorder ); Word16 vq_dec_lvq_ivas_fx( Word16 sf_flag, /* i : safety net flag */ @@ -1135,7 +1189,10 @@ Word16 vq_dec_lvq_ivas_fx( Word16 no_bits /* (i): no. bits for lattice */ ); -void a2rc_fx( const Word16 *a, Word16 *refl, Word16 lpcorder ); +void a2rc_fx( + const Word16 *a, + Word16 *refl, + Word16 lpcorder ); void lsp_weights_fx( Word16 lsp_nq_fx[], @@ -1202,14 +1259,56 @@ void autocorr_fx_32( const Word16 sym_flag /* i : symmetric window flag */ ); -Word16 E_LPC_lev_dur( const Word16 Rh[], const Word16 Rl[], Word16 A[], Word32 epsP[], const Word16 order, Word16 *parcorr ); -Word16 E_LPC_lev_dur_stab( const Word16 Rh[], const Word16 Rl[], Word16 A[], Word32 epsP[], const Word16 order, Word16 *parcorr, Word16 k_max ); - -Word16 E_LPC_lev_dur_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 A[], Word32 epsP[], const Word16 order, Word16 *parcorr ); -Word16 E_LPC_lev_dur_stab_ivas_fx( const Word16 Rh[], const Word16 Rl[], Word16 A[], Word32 epsP[], const Word16 order, Word16 *parcorr, Word16 k_max ); - -Word16 E_LPC_lev_dur_fx( const Word16 Rh[], const Word16 Rl[], Word32 A[], Word32 epsP[], const Word16 order, Word32 *mem ); -Word16 E_LPC_lev_dur_stab_fx( const Word16 Rh[], const Word16 Rl[], Word32 A[], Word32 epsP[], const Word16 order, Word32 *mem, Word16 k_max ); +Word16 E_LPC_lev_dur( + const Word16 Rh[], + const Word16 Rl[], + Word16 A[], + Word32 epsP[], + const Word16 order, + Word16 *parcorr ); + +Word16 E_LPC_lev_dur_stab( + const Word16 Rh[], + const Word16 Rl[], + Word16 A[], + Word32 epsP[], + const Word16 order, + Word16 *parcorr, + Word16 k_max ); + +Word16 E_LPC_lev_dur_ivas_fx( + const Word16 Rh[], + const Word16 Rl[], + Word16 A[], + Word32 epsP[], + const Word16 order, + Word16 *parcorr ); + +Word16 E_LPC_lev_dur_stab_ivas_fx( + const Word16 Rh[], + const Word16 Rl[], + Word16 A[], + Word32 epsP[], + const Word16 order, + Word16 *parcorr, + Word16 k_max ); + +Word16 E_LPC_lev_dur_fx( + const Word16 Rh[], + const Word16 Rl[], + Word32 A[], + Word32 epsP[], + const Word16 order, + Word32 *mem ); + +Word16 E_LPC_lev_dur_stab_fx( + const Word16 Rh[], + const Word16 Rl[], + Word32 A[], + Word32 epsP[], + const Word16 order, + Word32 *mem, + Word16 k_max ); Word16 lev_dur_fx( Word32 *a_fx, /* o : LP coefficients (a[0] = 1.0) Q(q_a)*/ @@ -1219,10 +1318,16 @@ Word16 lev_dur_fx( Word16 q_a, Word16 q_r ); -void E_LPC_a_add_tilt( const Word16 *a /*Qa*/, Word16 *ap /*Qa*/, Word16 gamma /*Q15*/, Word16 m ); -void E_LPC_int_lpc_tcx( const Word16 lsp_old[], /* i : LSPs from past frame (1Q14) */ - const Word16 lsp_new[], /* i : LSPs from present frame (1Q14) */ - Word16 a[] /* o : interpolated LP coefficients (4Q11) */ +void E_LPC_a_add_tilt( + const Word16 *a /*Qa*/, + Word16 *ap /*Qa*/, + Word16 gamma /*Q15*/, + Word16 m ); + +void E_LPC_int_lpc_tcx( + const Word16 lsp_old[], /* i : LSPs from past frame (1Q14) */ + const Word16 lsp_new[], /* i : LSPs from present frame (1Q14) */ + Word16 a[] /* o : interpolated LP coefficients (4Q11) */ ); Word16 E_LPC_lsp_unweight( @@ -1233,9 +1338,23 @@ Word16 E_LPC_lsp_unweight( Word16 lpcorder /* (I): prediction order Q0 */ ); -Word32 E_LPC_schur( Word32 r[] /*Qr*/, Word16 reflCoeff[] /*Q15*/, Word32 epsP[] /*Qr*/, const Word16 m ); -Word32 E_LPC_schur_ivas( Word32 r[] /*Qr*/, Word16 reflCoeff[] /*Q15*/, const Word16 m ); -void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs /*Qx*/, Word16 *lsf /*15Q16*/, const Word16 *old_lsf /*15Q16*/, Word16 lpcOrder, Word8 lpcRep /*Q0*/ ); +Word32 E_LPC_schur( + Word32 r[] /*Qr*/, + Word16 reflCoeff[] /*Q15*/, + Word32 epsP[] /*Qr*/, + const Word16 m ); + +Word32 E_LPC_schur_ivas( + Word32 r[] /*Qr*/, + Word16 reflCoeff[] /*Q15*/, + const Word16 m ); + +void E_LPC_a_lsf_isf_conversion( + Word16 *lpcCoeffs /*Qx*/, + Word16 *lsf /*15Q16*/, + const Word16 *old_lsf /*15Q16*/, + Word16 lpcOrder, + Word8 lpcRep /*Q0*/ ); /*========================================================================================================/ @@ -1377,6 +1496,7 @@ void scale_sig32_r( const Word16 lg, /* i : size of x[] Q0 */ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx exp */ ); + Word16 rescale_mem( const Word16 *Q_exc, /* i : current excitation scaling (>=0) */ Word16 *prev_Q_syn, /* i/o : scaling factor of previous frame */ @@ -1419,36 +1539,42 @@ void hq_configure_evs_fx( ); // hp50.c -void hp20( Word16 signal[], /* i/o: signal to filter any */ - const Word16 stride, /* i : stride to be applied accessing signal */ - const Word16 lg, /* i : length of signal (integer) Q0 */ - Word32 mem[5], /* i/o: static filter memory with this layout: */ - /* mem[0]: y[-2] (32-bit) */ - /* mem[1]; y[-1] (32-bit) */ - /* mem[2]: x[-2] << 16 */ - /* mem[3]: x[-1] << 16 */ - /* Note: mem[0..3] need to be scaled per frame */ - /* mem[4]: states scale */ - const Word32 sFreq ); +/* i/o: signal to filter any */ +void hp20( + Word16 signal[], + const Word16 stride, /* i : stride to be applied accessing signal */ + const Word16 lg, /* i : length of signal (integer) Q0 */ + Word32 mem[5], /* i/o: static filter memory with this layout: */ + /* mem[0]: y[-2] (32-bit) */ + /* mem[1]; y[-1] (32-bit) */ + /* mem[2]: x[-2] << 16 */ + /* mem[3]: x[-1] << 16 */ + /* Note: mem[0..3] need to be scaled per frame */ + /* mem[4]: states scale */ + const Word32 sFreq ); // get_gain.c -Word32 get_gain( /* encoder side; enc = 0 -> decoder side */ - Word16 *sign /* i/o: sign of the maximum */ + +/* o : pulse position */ +Word16 findpulse_fx( + const Word16 L_frame, /* i : length of the frame */ + const Word16 res[], /* i : Residual signal <12 bits */ + const Word16 T0, /* i : Pitch estimation Q0 */ + const Word16 enc, /* i : enc = 1 -> encoder side; enc = 0 -> decoder side */ + Word16 *sign /* i/o: sign of the maximum */ ); // env_stab_trans.c @@ -1657,7 +1788,6 @@ void env_stab_transient_detect_fx( const Word16 Qcoeff /* i : Q of coded spectral coefficients */ ); - // env_adj.c void env_adj_fx( const Word16 *pulses, /* i : number of pulses per band Q0 */ @@ -1668,32 +1798,35 @@ void env_adj_fx( const Word16 *sfmsize /* i : subband sizes Q0 */ ); - // env_stab.c - -Word16 env_stability_fx( /* in Q15 */ - const Word16 *ynrm, /*i: Norm vector for current frame */ - const Word16 nb_sfm, /*i: Number of sub-bands */ - Word16 *mem_norm, /*i/o: Norm vector memory from past frame */ - Word16 *mem_env_delta, /*i/o: Envelope stability memory for smoothing in Q11 */ - const Word16 core_switching_flag /* i : Core switching flag */ +/* in Q15 */ +Word16 env_stability_fx( + const Word16 *ynrm, /*i: Norm vector for current frame */ + const Word16 nb_sfm, /*i: Number of sub-bands */ + Word16 *mem_norm, /*i/o: Norm vector memory from past frame */ + Word16 *mem_env_delta, /*i/o: Envelope stability memory for smoothing in Q11 */ + const Word16 core_switching_flag /* i : Core switching flag */ ); -Word16 env_stab_smo_fx( /* Q0 */ - Word16 env_stab, /*i : env_stab value Q15 */ - Word16 *env_stab_state_p, /*i/o: env_stab state probabilities Q15 */ - Word16 *ho_cnt /*i/o: hangover counter for speech state */ +/* Q0 */ +Word16 env_stab_smo_fx( + Word16 env_stab, /*i : env_stab value Q15 */ + Word16 *env_stab_state_p, /*i/o: env_stab state probabilities Q15 */ + Word16 *ho_cnt /*i/o: hangover counter for speech state */ ); // enr_1_az.c -Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 */ - const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ - const Word16 len /* i : impulse response length Q0 */ +/* o : impulse response energy Q3 */ +Word16 Enr_1_Az_fx( + const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ + const Word16 len /* i : impulse response length Q0 */ ); -Word16 Enr_1_Az_fx_o( /* o : impulse response energy Q3 */ - const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ - const Word16 len, /* i : impulse response length Q0 */ - Flag *Overflow_out /* o : propagating the Overflow flag to upper level */ + +/* o : impulse response energy Q3 */ +Word16 Enr_1_Az_fx_o( + const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */ + const Word16 len, /* i : impulse response length Q0 */ + Flag *Overflow_out /* o : propagating the Overflow flag to upper level */ ); // gs_gains_fx.c @@ -1703,6 +1836,7 @@ void Ener_per_band_comp_fx( const Word16 Q_exc_diff, const Word16 Mband, /* i : Max band */ const Word16 Eflag ); + void Ener_per_band_comp_ivas_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ @@ -1738,7 +1872,6 @@ void pre_echo_att_fx( const Word16 Q_new, const Word16 last_coder_type, /* i : Last coding mode Q0*/ const Word16 L_frame /* i : Frame length Q0*/ - ); void pre_echo_att_ivas_fx( @@ -1899,9 +2032,10 @@ void sqrt_32n_16_fx( Word16 *Qout /* o : Q value for out_fx */ ); -Word16 div_s_ss( /* o: result of division (Word16 Q0) */ - const Word16 n, /* i: numerator (Word16 Q0 */ - const Word16 d /* i: denominator (Word16 Q0) */ +/* o: result of division (Word16 Q0) */ +Word16 div_s_ss( + const Word16 n, /* i: numerator (Word16 Q0 */ + const Word16 d /* i: denominator (Word16 Q0) */ ); void noiseinj_hf_fx( @@ -1952,16 +2086,17 @@ void return_bits_normal2_fx( const Word16 bits_lagIndices_fx[] /* i : bits for lagIndices */ ); -Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_min */ - Word32 L_spectra[], /* i : Qs core coder */ - /*Word16 Qs,*/ /* i : Q0 Q value for spectra, spectra_ni */ - const Word32 L_spectra_ni[], /* i : Qs core coder with sparse filling */ - Word16 sspectra_fx[], /* o : Qss Smoothed tonal information from core coder */ - Word16 sspectra_diff_fx[], /* o : Qss non tonal infomration for gap filling */ - Word16 sspectra_ni_fx[], /* o : Qss smoothed core coder */ - Word16 *Qss, /* o : Q0 Q value for sspectra* */ - const Word16 fLenLow_fx, /* i : Q0 low frequency boundaries */ - Word16 *ni_seed_fx /* io : Q0 random seed */ +/* o : Qss ss_min */ +Word16 spectrumsmooth_noiseton_fx( + Word32 L_spectra[], /* i : Qs core coder */ + /*Word16 Qs,*/ /* i : Q0 Q value for spectra, spectra_ni */ + const Word32 L_spectra_ni[], /* i : Qs core coder with sparse filling */ + Word16 sspectra_fx[], /* o : Qss Smoothed tonal information from core coder */ + Word16 sspectra_diff_fx[], /* o : Qss non tonal infomration for gap filling */ + Word16 sspectra_ni_fx[], /* o : Qss smoothed core coder */ + Word16 *Qss, /* o : Q0 Q value for sspectra* */ + const Word16 fLenLow_fx, /* i : Q0 low frequency boundaries */ + Word16 *ni_seed_fx /* io : Q0 random seed */ ); void ton_ene_est_fx( @@ -2376,9 +2511,25 @@ void syn_filt_fx32( const Word16 update_m /* i : update memory flag Q0 : 0 --> no memory update */ ); -void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], Word16 y[], const Word16 lg, Word16 mem[], const Word16 update, const Word16 m ); +void E_UTIL_synthesis( + const Word16 shift, + const Word16 a[], + const Word16 x[], + Word16 y[], + const Word16 lg, + Word16 mem[], + const Word16 update, + const Word16 m ); -void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[], Word32 y[], const Word16 lg, Word32 mem[], const Word16 update, const Word16 m ); +void E_UTIL_synthesis_fx( + const Word16 shift, + const Word32 a[], + const Word32 x[], + Word32 y[], + const Word16 lg, + Word32 mem[], + const Word16 update, + const Word16 m ); void synth_mem_updt2( const Word16 L_frame, /* i : frame length */ @@ -2389,6 +2540,7 @@ void synth_mem_updt2( Word16 mem_syn[], /* o : synthesis filter memory for find_target */ const Word16 dec /* i : flag for decoder indication */ ); + void ivas_synth_mem_updt2_fx( const Word16 L_frame, /* i : frame length */ const Word16 last_L_frame, /* i : frame length */ @@ -2398,30 +2550,48 @@ void ivas_synth_mem_updt2_fx( Word16 mem_syn[], /* o : synthesis filter memory for find_target */ const Word16 dec ); - // lerp.c -void lerp( const Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize ); - -void L_lerp_fx_q11( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 bufferOldSize ); - -void L_lerp_fx( Word32 *f, Word32 *f_out, Word16 bufferNewSize, Word16 bufferOldSize, Word16 *q ); +void lerp( + const Word16 *f, + Word16 *f_out, + Word16 bufferNewSize, + Word16 bufferOldSize ); + +void L_lerp_fx_q11( + Word32 *f, + Word32 *f_out, + Word16 bufferNewSize, + Word16 bufferOldSize ); + +void L_lerp_fx( + Word32 *f, + Word32 *f_out, + Word16 bufferNewSize, + Word16 bufferOldSize, + Word16 *q ); // index_pvq_opt.c -PvqEntry mpvq_encode_vec_fx( /* o : leading_sign_index, index, size, k_val */ - const Word16 *vec_in, /* i : signed pulse train */ - Word16 dim_in, /* i : dimension */ - Word16 k_val_local /* i : nb unit pulses */ +/* o : leading_sign_index, index, size, k_val */ +PvqEntry mpvq_encode_vec_fx( + const Word16 *vec_in, /* i : signed pulse train */ + Word16 dim_in, /* i : dimension */ + Word16 k_val_local /* i : nb unit pulses */ ); -PvqEntry get_size_mpvq_calc_offset_fx( /* o : size, dim, k_val */ - Word16 dim_in, /* i : dimension */ - Word16 k_val_in, /* i : nb unit pulses */ - UWord32 *h_mem /* o : offsets */ + +/* o : size, dim, k_val */ +PvqEntry get_size_mpvq_calc_offset_fx( + Word16 dim_in, /* i : dimension */ + Word16 k_val_in, /* i : nb unit pulses */ + UWord32 *h_mem /* o : offsets */ ); -void mpvq_decode_vec_fx( /* o : void */ - const PvqEntry *entry, /* i : sign_ind, index, dim, k_val */ - UWord32 *h_mem, /* i : A/U offsets */ - Word16 *vec_out /* o : pulse train */ + +/* o : void */ +void mpvq_decode_vec_fx( + const PvqEntry *entry, /* i : sign_ind, index, dim, k_val */ + UWord32 *h_mem, /* i : A/U offsets */ + Word16 *vec_out /* o : pulse train */ ); + // weight_a_fx.c void weight_a_subfr_fx( const Word16 nb_subfr, /* i : number of subframes Q0 */ @@ -2444,6 +2614,7 @@ void weight_a_fx( const Word16 gamma, /* i: weighting factor Q15 */ const Word16 m /* i: order of LP filter Q0 */ ); + void E_LPC_a_weight_inv( const Word16 *a, /* Q12 */ Word16 *ap, /* Q12 */ @@ -2482,26 +2653,30 @@ void calc_residu_fx( Word16 *res, /* o : residual signal Qx+1*/ const Word16 *p_Aq /* i : quantized LP filter coefficients Q12*/ ); + // inerpol_lc.c -Word32 Interpol_lc_fx( /* o : interpolated value Q15 */ - const Word16 *x, /* i : input vector Q0 */ - const Word16 *win, /* i : interpolation window Q14 */ - const Word16 frac, /* i : fraction (0..up_samp) Q0 */ - const Word16 up_samp, /* i : upsampling factor Q0 */ - const Word16 nb_coef /* i : number of coefficients Q0 */ -); - -Word16 modify_Fs_ivas_fx( /* o : length of output Q0 */ - const Word16 sigIn_fx[], /* i : signal to decimate Q0 */ - Word16 lg, /* i : length of input Q0 */ - const Word32 fin, /* i : frequency of input Q0 */ - Word16 sigOut_fx[], /* o : decimated signal Q0 */ - const Word32 fout, /* i : frequency of output Q0 */ - Word16 mem_fx[], /* i/o: filter memory Q0 */ - const Word16 nblp, /* i : flag indicating if NB low-pass is applied */ - Word16 *Q_new_inp, /*scaling added on sigOut_fx */ - Word16 *mem_decim_size /*i: size modified for mem_fx*/ +/* o : interpolated value Q15 */ +Word32 Interpol_lc_fx( + const Word16 *x, /* i : input vector Q0 */ + const Word16 *win, /* i : interpolation window Q14 */ + const Word16 frac, /* i : fraction (0..up_samp) Q0 */ + const Word16 up_samp, /* i : upsampling factor Q0 */ + const Word16 nb_coef /* i : number of coefficients Q0 */ +); + +/* o : length of output Q0 */ +Word16 modify_Fs_ivas_fx( + const Word16 sigIn_fx[], /* i : signal to decimate Q0 */ + Word16 lg, /* i : length of input Q0 */ + const Word32 fin, /* i : frequency of input Q0 */ + Word16 sigOut_fx[], /* o : decimated signal Q0 */ + const Word32 fout, /* i : frequency of output Q0 */ + Word16 mem_fx[], /* i/o: filter memory Q0 */ + const Word16 nblp, /* i : flag indicating if NB low-pass is applied */ + Word16 *Q_new_inp, /*scaling added on sigOut_fx */ + Word16 *mem_decim_size /*i: size modified for mem_fx*/ ); + // modif_fs_fx.c Word16 modify_Fs_fx( /* o : length of output Q0 */ const Word16 sigIn_fx[], /* i : signal to decimate Q0 */ @@ -2513,13 +2688,14 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ const Word16 nblp /* i : flag indicating if NB low-pass is applied */ ); -Word16 modify_Fs_intcub3m_sup_fx( /* o : length of output */ - const Word16 sigIn[], /* i : signal to decimate with memory of 2 samples (indexes -2 & -1) */ - const Word16 lg, /* i : length of input (suppose that lg is such that lg_out is integer, ex multiple of 5 in case of 16kHz to 12.8 kHz) */ - const Word32 fin, /* i : frequency of input */ - Word16 sigOut[], /* o : decimated signal */ - const Word32 fout, /* i : frequency of output */ - Word16 *delayout /* o : delay of output */ +/* o : length of output */ +Word16 modify_Fs_intcub3m_sup_fx( + const Word16 sigIn[], /* i : signal to decimate with memory of 2 samples (indexes -2 & -1) */ + const Word16 lg, /* i : length of input (suppose that lg is such that lg_out is integer, ex multiple of 5 in case of 16kHz to 12.8 kHz) */ + const Word32 fin, /* i : frequency of input */ + Word16 sigOut[], /* o : decimated signal */ + const Word32 fout, /* i : frequency of output */ + Word16 *delayout /* o : delay of output */ ); void Decimate_allpass_steep_fx( @@ -2658,6 +2834,7 @@ Word16 E_UTIL_f_preemph3( Word16 *mem, /* Qx */ Word16 bits /* Q0 */ ); + Word16 E_UTIL_f_preemph3_ivas_fx( Word16 *signal, /* Qx */ const Word16 mu, /* Q15 */ @@ -2665,6 +2842,7 @@ Word16 E_UTIL_f_preemph3_ivas_fx( Word16 *mem, /* Qx */ Word16 bits /* Q0 */ ); + // swb_bwe_com_fx.c Word16 WB_BWE_gain_pred_fx( Word16 *WB_fenv, /* o : WB frequency envelopes */ @@ -2689,10 +2867,11 @@ void calc_normal_length_fx( Word16 *prev_L_swb_norm, /*i/o : last normalize length */ Word16 Q_syn ); -Word16 ivas_calc_tilt_bwe_fx( /* o : Tilt in Q24 */ - const Word32 *sp, /* i : i signal */ - const Word16 exp_sp, /* i : Exp of inp signal */ - const Word16 N /* i : signal length */ +/* o : Tilt in Q24 */ +Word16 ivas_calc_tilt_bwe_fx( + const Word32 *sp, /* i : i signal */ + const Word16 exp_sp, /* i : Exp of inp signal */ + const Word16 N /* i : signal length */ ); void calc_norm_envelop_fx( @@ -3108,14 +3287,10 @@ void ScaleShapedWB_fx( const Word16 *win, /* i : window */ const Word16 *subwin, /* i : subframes window */ const Word16 Q_bwe_exc, - Word16 L_frame /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ - , - Word16 dynQ /* i : indicate whether output is dynamic Q, or Q0 */ - , - Word16 *Qx /* o : newly computed Q factor for synSHB */ - , - Word16 prev_Qx /* i : prev_Qx for memory scaling */ - , + Word16 L_frame, /* i : Frame length - determines whether 12.8 or 16kHz core in-use */ + Word16 dynQ, /* i : indicate whether output is dynamic Q, or Q0 */ + Word16 *Qx, /* o : newly computed Q factor for synSHB */ + Word16 prev_Qx, /* i : prev_Qx for memory scaling */ Word32 *Hilbert_Mem /* i : Hilbert memory used for computing Qx */ ); @@ -3990,25 +4165,25 @@ void cng_params_upd_fx( ); void cng_params_upd_ivas_fx( - const Word16 lsp_new[], /* i : LSP aprameters Q15 */ - const Word16 exc2[], /* i : current enhanced excitation Q_exc */ - const Word16 L_frame, /* i : frame length Q0 */ - Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ - Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ - Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ - Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ - const Word16 Q_exc, /* i : Q value of excitation */ - const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ - Word32 ho_env_circ[], /* i/o: Envelope buffer */ - Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ - Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ - Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ - Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ - const Word32 last_active_brate /* i : Last active bit rate Q0 */ - , - const Word16 element_mode, /* i : Element mode */ - const Word16 bwidth /* i : Audio bandwidth */ + const Word16 lsp_new[], /* i : LSP aprameters Q15 */ + const Word16 exc2[], /* i : current enhanced excitation Q_exc */ + const Word16 L_frame, /* i : frame length Q0 */ + Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */ + Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */ + Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */ + Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */ + const Word16 Q_exc, /* i : Q value of excitation */ + const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */ + Word32 ho_env_circ[], /* i/o: Envelope buffer */ + Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */ + Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */ + Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */ + Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */ + const Word32 last_active_brate, /* i : Last active bit rate Q0 */ + const Word16 element_mode, /* i : Element mode */ + const Word16 bwidth /* i : Audio bandwidth */ ); + Word16 get_cng_mode( const Word32 last_active_brate /* i : last active bitrate */ ); @@ -4285,28 +4460,25 @@ void InitTnsConfigs_ivas_fx( const Word16 element_mode, const Word16 is_mct ); -#define IVAS_CODE_TCX_UTIL -#ifdef IVAS_CODE_TCX_UTIL void SetAllowTnsOnWhite( STnsConfig tnsConfig[2][2], const Word8 allowTnsOnWhite ); -#endif -#undef IVAS_CODE_TCX_UTIL void SetTnsConfig( TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ const Word16 isTCX20, const Word16 isAfterACELP ); -void tcx_get_gain( Word32 *x, /* i: spectrum 1 */ - Word16 x_e, /* i: spectrum 1 exponent */ - Word32 *y, /* i: spectrum 2 */ - Word16 y_e, /* i: spectrum 2 exponent */ - Word16 n, /* i: length */ - Word16 *gain, /* o: gain */ - Word16 *gain_e, /* o: gain exponent */ - Word32 *en_y, /* o: energy of y (optional) */ - Word16 *en_y_e /* o: energy of y exponent (optional) */ +void tcx_get_gain( + Word32 *x, /* i: spectrum 1 */ + Word16 x_e, /* i: spectrum 1 exponent */ + Word32 *y, /* i: spectrum 2 */ + Word16 y_e, /* i: spectrum 2 exponent */ + Word16 n, /* i: length */ + Word16 *gain, /* o: gain */ + Word16 *gain_e, /* o: gain exponent */ + Word32 *en_y, /* o: energy of y (optional) */ + Word16 *en_y_e /* o: energy of y exponent (optional) */ ); void init_TCX_config( @@ -4320,7 +4492,6 @@ void init_TCX_config( void resetTecDec_Fx( TEC_DEC_HANDLE hTecDec ); - void resetTecEnc_Fx( TEC_ENC_HANDLE hTECEnc, Word16 flag ); @@ -4371,7 +4542,10 @@ void tecEnc_TBE_fx( const Word16 *voicing, const Word16 coder_type ); -void set_TEC_TFA_code_fx( const Word16 corrFlag, Word16 *tec_flag, Word16 *tfa_flag ); +void set_TEC_TFA_code_fx( + const Word16 corrFlag, + Word16 *tec_flag, + Word16 *tfa_flag ); // tcx_mdct_fx.c void TCX_MDCT( @@ -4424,7 +4598,6 @@ void TCX_MDXT_Inverse_fx( ); // edct_fx.c -#define EDCT_FACTOR_SCALE 2 void edct_fx( const Word32 *x, /* i : i signal Qq */ Word32 *y, /* o : output transform Qq */ @@ -5916,7 +6089,7 @@ Word16 minimum_l( Word32 *min_val /* o : minimum value in the input vector */ ); -void v_multc_fixed( +void v_multc_fx( const Word32 x[], /* i : Input vector */ const Word32 c, /* i : Constant */ Word32 y[], /* o : Output vector that contains c*x */ @@ -6046,8 +6219,8 @@ void lsf_end_dec_fx( Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ Word16 *lpc_param, /* i : LPC parameters Q0*/ Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *nb_indices /* o : number of indices Q0*/ - , + Word16 *nb_indices, /* o : number of indices Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ ); @@ -6943,9 +7116,8 @@ void pit_Q_dec_fx( Word16 *T0, /* o : integer pitch lag */ Word16 *T0_frac, /* o : pitch fraction */ Word16 *T0_min, /* i/o: delta search min */ - Word16 *T0_max /* i/o: delta search max */ - , - Word16 *BER_detect /* o : BER detect flag */ + Word16 *T0_max, /* i/o: delta search max */ + Word16 *BER_detect /* o : BER detect flag */ ); void pit16k_Q_dec_fx( @@ -6955,9 +7127,8 @@ void pit16k_Q_dec_fx( Word16 *T0, /* o : integer pitch lag */ Word16 *T0_frac, /* o : pitch fraction */ Word16 *T0_min, /* i/o: delta search min */ - Word16 *T0_max /* i/o: delta search max */ - , - Word16 *BER_detect /* o : BER detect flag */ + Word16 *T0_max, /* i/o: delta search max */ + Word16 *BER_detect /* o : BER detect flag */ ); void abs_pit_dec_fx( @@ -7046,7 +7217,12 @@ void D_ACELP_indexing_fx( Word16 index[], Word16 *BER_detect ); -void fcb_pulse_track_joint_decode_fx( UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word16 *pulse_num, Word16 track_num ); +void fcb_pulse_track_joint_decode_fx( + UWord16 *idxs, + Word16 wordcnt, + UWord32 *index_n, + Word16 *pulse_num, + Word16 track_num ); // dec2t32_fx.c void dec_acelp_2t32_fx( @@ -7056,9 +7232,8 @@ void dec_acelp_2t32_fx( void dec_acelp_1t64_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 code[] /* o: algebraic (fixed) codebook excitation Q12*/ - , - const Word16 L_subfr /* i : sub frame lenght*/ + Word16 code[], /* o: algebraic (fixed) codebook excitation Q12*/ + const Word16 L_subfr /* i : sub frame lenght*/ ); // acelp_core_switch)dec_fx.c @@ -7243,8 +7418,7 @@ void decod_nelp_fx( Word16 *voice_factors, /* o : Voice factor */ Word16 *bwe_exc, Word16 *Q_exc, - Word16 bfi /* i : frame error rate */ - , + Word16 bfi, /* i : frame error rate */ Word16 *gain_buf /*Q14*/ ); @@ -7267,16 +7441,17 @@ void FEC_lsf2lsp_interp( Word16 *lsp /* o : estimated LSP vector */ ); - // fd_cng_dec_fx.c -ivas_error createFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec ); +ivas_error createFdCngDec_fx( + HANDLE_FD_CNG_DEC *hFdCngDec ); void initFdCngDec_fx( DEC_CORE_HANDLE st, /* i/o: decoder state structure */ Word16 scale ); /* Delete the instance of type FD_CNG */ -void deleteFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec ); +void deleteFdCngDec_fx( + HANDLE_FD_CNG_DEC *hFdCngDec ); /* Configure CLDFB-CNG */ void configureFdCngDec_fx( @@ -7321,8 +7496,9 @@ void perform_noise_estimation_dec_ivas_fx( ); /* Decode the CLDFB-CNG bitstream */ -void FdCng_decodeSID_fx( HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ - Decoder_State *corest ); /* i/o: decoder state structure */ +void FdCng_decodeSID_fx( + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Decoder_State *corest ); /* i/o: decoder state structure */ void noisy_speech_detection_fx( HANDLE_FD_CNG_DEC hFdCngDec, /* i/o: FD_CNG structure */ @@ -7350,10 +7526,11 @@ void generate_comfort_noise_dec_ivas_fx( const Word16 nchan_out /* i : number of output channels */ ); -void generate_comfort_noise_dec_hf_fx( Word32 **bufferReal, /* o : matrix to real part of i bands */ - Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ - Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ - Decoder_State *stdec ); +void generate_comfort_noise_dec_hf_fx( + Word32 **bufferReal, /* o : matrix to real part of i bands */ + Word32 **bufferImag, /* o : matrix to imaginary part of i bands */ + Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of i bands */ + Decoder_State *stdec ); void generate_comfort_noise_dec_hf_ivas_fx( Word32 **bufferReal, /* o : matrix to real part of input bands */ @@ -7364,26 +7541,27 @@ void generate_comfort_noise_dec_hf_ivas_fx( ); /* Generate the comfort noise based on the target noise level */ -void generate_masking_noise_fx( Word16 *timeDomainBuffer, /* i/o: time-domain signal */ - Word16 Q, - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ - , - Word16 length, - Word16 core ); +void generate_masking_noise_fx( + Word16 *timeDomainBuffer, /* i/o: time-domain signal */ + Word16 Q, + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Word16 length, + Word16 core ); void generate_masking_noise_update_seed_fx( HANDLE_FD_CNG_COM st /* i/o : pointer to FD_CNG_COM structure */ ); -void generate_masking_noise_mdct_fx( Word32 *mdctBuffer, /* i/o: time-domain signal */ - Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ - , - Word16 L_frame ); +void generate_masking_noise_mdct_fx( + Word32 *mdctBuffer, /* i/o: time-domain signal */ + Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ + HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */ + Word16 L_frame ); -void generate_masking_noise_mdct_ivas_fx( Word32 *mdctBuffer, /* i/o: time-domain signal */ - Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ - HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ ); +void generate_masking_noise_mdct_ivas_fx( + Word32 *mdctBuffer, /* i/o: time-domain signal */ + Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ + HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */ ); // init_dec_fx.c ivas_error init_decoder_fx( @@ -7424,21 +7602,23 @@ Word16 wb_bwe_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ Word16 *Qpost ); -Word16 swb_bwe_gain_deq_fx( /* o : BWE class */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 core, /* i : core */ - Word16 *SWB_tenv, /* o : Q0, time-domain BWE envelope */ - Word16 *SWB_fenv, /* o : Q1, frequency-domain BWE envelope */ - const Word16 hr_flag, /* i : high rate flag */ - const Word16 hqswb_clas /* i : HQ BWE class */ -); - -Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ - Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ - const Word16 output_frame, /* i : frame length */ - Word16 *Qpost ); +/* o : BWE class */ +Word16 swb_bwe_gain_deq_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 core, /* i : core */ + Word16 *SWB_tenv, /* o : Q0, time-domain BWE envelope */ + Word16 *SWB_fenv, /* o : Q1, frequency-domain BWE envelope */ + const Word16 hr_flag, /* i : high rate flag */ + const Word16 hqswb_clas /* i : HQ BWE class */ +); + +/*o :Q_syn_hb*/ +Word16 swb_bwe_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis (might be rescaled inside wtda() ) Q0/Qpost */ + Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis Q_syn_hb */ + const Word16 output_frame, /* i : frame length */ + Word16 *Qpost ); void fd_bwe_dec_init( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -7466,11 +7646,19 @@ void hq_core_dec_fx( void HQ_core_dec_init_fx( HQ_DEC_HANDLE hHQ_core /* i/o: HQ core data handle */ ); + void HQ_nbfec_init_fx( HQ_NBFEC_HANDLE hHQ_nbfec /* i/o: HQ NB FEC data handle */ ); -void GetAttackForTCXDecision_fx( Word32 const *pSubblockNrg, Word32 const *pAccSubblockNrg, Word16 nSubblocks, Word16 nPastSubblocks, Word16 attackRatioThreshold, Word16 *pbIsAttackPresent, Word16 *pAttackIndex ); +void GetAttackForTCXDecision_fx( + Word32 const *pSubblockNrg, + Word32 const *pAccSubblockNrg, + Word16 nSubblocks, + Word16 nPastSubblocks, + Word16 attackRatioThreshold, + Word16 *pbIsAttackPresent, + Word16 *pAttackIndex ); // FEC_HQ_phase_ecu_fx.c void hq_ecu_fx( @@ -7496,7 +7684,6 @@ void hq_ecu_fx( Decoder_State *st_fx /* i/o: decoder state structure */ ); - // hq_lr_dec_fx.c void hq_lr_dec_fx( Decoder_State *st_fx, /* i/o: : decoder state structure */ @@ -7507,15 +7694,15 @@ void hq_lr_dec_fx( ); // gq_env_dec_fx.c -Word16 decode_envelope_indices_fx( /* o : Number of bits Q0*/ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 start_norm, /* i : starting band index Q0*/ - const Word16 num_sfm, /* i : Number of subbands Q0*/ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0*/ - Word16 *difidx, /* o : Diff indices/encoded diff indices Q0*/ - const Word16 flag_HQ2 /* i : indicator of HQ2 core Q0*/ - , - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0*/ +/* o : Number of bits Q0*/ +Word16 decode_envelope_indices_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 start_norm, /* i : starting band index Q0*/ + const Word16 num_sfm, /* i : Number of subbands Q0*/ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0*/ + Word16 *difidx, /* o : Diff indices/encoded diff indices Q0*/ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0*/ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0*/ ); void dequantize_norms_fx( @@ -7533,7 +7720,6 @@ void hdecnrm_fx( const Word16 numNorms, /* (i) number of norms Q0*/ Word16 *index ); /* (o) indices of quantized norms Q0*/ - Word16 decode_huff_context_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *hufftab, @@ -7648,12 +7834,13 @@ void hq_hr_dec_fx( ); // hq_classifier_dec_fx.c -Word16 hq_classifier_dec_fx( /* o : Consumed bits Q0 */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : Core bit rate Q0 */ - const Word16 length, /* i : Frame length Q0 */ - Word16 *is_transient, /* o : Transient flag Q0 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ +/* o : Consumed bits Q0 */ +Word16 hq_classifier_dec_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : Core bit rate Q0 */ + const Word16 length, /* i : Frame length Q0 */ + Word16 *is_transient, /* o : Transient flag Q0 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ ); // peak_vq_dec_fx.c @@ -7761,9 +7948,8 @@ void updt_dec_fx( const Word16 *lsf_new_fx, /* i : current frame LSF vector */ const Word16 *lsp_new_fx, /* i : current frame LSP vector */ const Word16 voice_factors[], /* i : voicing factors */ - const Word16 *old_bwe_exc_fx /* i : buffer of excitation */ - , - const Word16 *gain_buf /*Q14*/ + const Word16 *old_bwe_exc_fx, /* i : buffer of excitation */ + const Word16 *gain_buf /*Q14*/ ); void updt_IO_switch_dec_fx( @@ -7793,43 +7979,30 @@ void update_decoder_LPD_cng( // FEC_clas_estim_fx void FEC_clas_estim_fx( - Decoder_State *st_fx, /* i/o: decoder state handle */ - const Word16 Opt_AMR_WB, - /* i : flag indicating AMR-WB IO mode */ /*A*/ - const Word16 L_frame, /* i : length of the frame */ - Word16 *clas, /* i/o: frame classification */ - const Word16 coder_type, /* i : coder type */ - const Word16 *pitch, /* i : pitch values for each subframe (Q6) */ - Word16 *syn, /* i : synthesis buffer */ - Word16 *lp_speech, /* i/o: long term active speech energy average Q8 */ - Word16 *decision_hyst, - /* i/o: hysteresis of the music/speech decision */ /*A*/ - Word16 *UV_cnt, - /* i/o: number of consecutives frames classified as UV */ /*A*/ - Word16 *LT_UV_cnt, - /* i/o: long term consecutives frames classified as UV */ /*A*/ - Word16 *Last_ener, - /* i/o: last_energy frame */ /*A*/ - Word16 *locattack, - /* i/o: detection of attack (mainly to localized speech burst) */ /*A*/ - Word16 *lt_diff_etot, - /* i/o: long-term total energy variation */ /*A*/ - Word16 *amr_io_class, - /* i/o: classification for AMR-WB IO mode */ /*A*/ - Word16 Q_syn, /* i : Synthesis scaling */ - Word16 *class_para, - /* o : classification para. fmerit1 */ /*A*/ - Word16 *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */ - Word16 *Q_mem_syn, - /*i/o : exponent for memory of synthesis signal for frame class estimation */ /*B*/ - Word16 LTP_Gain, - /* i : LTP gain is 0..0.6 or negative Q15*/ /*B*/ - Word16 mode, - /* i : signal classifier mode */ /*B*/ - Word16 bfi, - /* i : bad frame indicator */ /*B*/ - Word32 last_core_brate, /* i : bitrate of previous frame */ - const Word16 FEC_mode /* i : ACELP FEC mode */ + Decoder_State *st_fx, /* i/o: decoder state handle */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode A*/ + const Word16 L_frame, /* i : length of the frame */ + Word16 *clas, /* i/o: frame classification */ + const Word16 coder_type, /* i : coder type */ + const Word16 *pitch, /* i : pitch values for each subframe (Q6) */ + Word16 *syn, /* i : synthesis buffer */ + Word16 *lp_speech, /* i/o: long term active speech energy average Q8 */ + Word16 *decision_hyst, /* i/o: hysteresis of the music/speech decision A*/ + Word16 *UV_cnt, /* i/o: number of consecutives frames classified as UV A*/ + Word16 *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV A*/ + Word16 *Last_ener, /* i/o: last_energy frame A*/ + Word16 *locattack, /* i/o: detection of attack (mainly to localized speech burst) A*/ + Word16 *lt_diff_etot, /* i/o: long-term total energy variation A*/ + Word16 *amr_io_class, /* i/o: classification for AMR-WB IO mode A*/ + Word16 Q_syn, /* i : Synthesis scaling */ + Word16 *class_para, /* o : classification para. fmerit1 A*/ + Word16 *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */ + Word16 *Q_mem_syn, /* i/o : exponent for memory of synthesis signal for frame class estimation B*/ + Word16 LTP_Gain, /* i : LTP gain is 0..0.6 or negative Q15B*/ + Word16 mode, /* i : signal classifier mode B*/ + Word16 bfi, /* i : bad frame indicator B*/ + Word32 last_core_brate, /* i : bitrate of previous frame */ + const Word16 FEC_mode /* i : ACELP FEC mode */ ); Word16 FEC_pos_dec_fx( @@ -8011,6 +8184,7 @@ ivas_error ppp_voiced_decoder_fx( Word16 *pitch, /* o : floating pitch values for each subframe */ Word16 bfi /* i : Frame error rate */ ); + void sc_vbr_dec_init( SC_VBR_DEC_HANDLE hSC_VBR /* i/o: SC-VBR decoder handle */ ); @@ -8034,6 +8208,7 @@ void open_decoder_LPD_fx( const Word32 total_brate, /* Q0 */ const Word16 bwidth /* Q0 */ ); + void open_decoder_LPD_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ const Word32 total_brate, /* i : total bitrate Q0*/ @@ -8054,11 +8229,13 @@ void open_decoder_LPD_ivas_fx( void reset_tcx_overl_buf_fx( TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ ); + void acelp_plc_mdct_transition_fx( Decoder_State *st /* i/o: Decoder state */ ); void cldfb_reset_memory_fx( HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ ); + void tcxltp_dec_init_fx( TCX_LTP_DEC_HANDLE hTcxLtpDec, /* Q0 */ const Word16 ini_frame, /* Q0 */ @@ -8066,16 +8243,17 @@ void tcxltp_dec_init_fx( const Word16 element_mode, /* Q0 */ const Word16 pit_max, /* Q0 */ const Word32 sr_core ); /* Q0 */ -// swb_bwe_dec_hr_fx.c -Word16 swb_bwe_dec_hr_fx( /* o : Exponent of SHB synthesis */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz : Q(15 - exp) */ - const Word16 exp, /* i : Exponent of core synthesis */ - Word16 *hb_synth_fx, /* o : SHB synthesis : Q(15 - hb_synth_fx_exp)*/ - const Word16 output_frame, /* i : frame length */ - const Word16 unbits, /* i : number of core unused bits */ - const Word16 pitch_buf[] /* i : pitch buffer : Q6 */ +// swb_bwe_dec_hr_fx.c +/* o : Exponent of SHB synthesis */ +Word16 swb_bwe_dec_hr_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz : Q(15 - exp) */ + const Word16 exp, /* i : Exponent of core synthesis */ + Word16 *hb_synth_fx, /* o : SHB synthesis : Q(15 - hb_synth_fx_exp)*/ + const Word16 output_frame, /* i : frame length */ + const Word16 unbits, /* i : number of core unused bits */ + const Word16 pitch_buf[] /* i : pitch buffer : Q6 */ ); void hr_bwe_dec_init( @@ -8154,13 +8332,12 @@ void stat_noise_uv_mod_ivas_fx( // FEC_adao_codebook_fx.c Word16 FEC_SinOnset_fx( - Word16 *exc, /* i/o : exc vector to modify */ - Word16 puls_pos, /* i : last pulse position desired */ - const Word16 T0, /* i : Pitch information of the 1 subfr */ - Word32 enr_q, /* i : energy provide by the encoder */ - Word16 *Aq, /* i : A(z) filter Q12 */ - const Word16 L_frame /* i : frame length */ - , + Word16 *exc, /* i/o : exc vector to modify */ + Word16 puls_pos, /* i : last pulse position desired */ + const Word16 T0, /* i : Pitch information of the 1 subfr */ + Word32 enr_q, /* i : energy provide by the encoder */ + Word16 *Aq, /* i : A(z) filter Q12 */ + const Word16 L_frame, /* i : frame length */ const Word16 Qold ); Word16 FEC_enhACB_fx( @@ -8280,20 +8457,18 @@ void transition_dec_fx( Word16 tc_classif_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 L_frame /* i : length of the frame */ + const Word16 L_frame /* i : length of the frame */ ); // dec_ppp_fx.c ivas_error decod_ppp_fx( - Decoder_State *st_fx, /* i/o: state structure */ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ - Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */ - Word16 *exc_fx, /* i/o: current non-enhanced excitation */ - Word16 *exc2_fx, /* i/o: current enhanced excitation */ - Word16 bfi /* i : bad frame indicator */ - , - Word16 *gain_buf /*Q14*/ - , + Decoder_State *st_fx, /* i/o: state structure */ + const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ + Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */ + Word16 *exc_fx, /* i/o: current non-enhanced excitation */ + Word16 *exc2_fx, /* i/o: current enhanced excitation */ + Word16 bfi, /* i : bad frame indicator */ + Word16 *gain_buf, /*Q14*/ Word16 *voice_factors, /* o : voicing factors */ Word16 *bwe_exc_fx /* o : excitation for SWB TBE */ ); @@ -8380,8 +8555,8 @@ Word16 DecodeIndex( Decoder_State *st, const Word16 Bandwidth, /* o : NB, 1: (S)WB */ Word16 *PeriodicityIndex ); -Word16 -DecodeIndex_fx( + +Word16 DecodeIndex_fx( Decoder_State *st, const Word16 Bandwidth, Word16 *PeriodicityIndex ); @@ -8406,6 +8581,7 @@ Word16 lsf_bctcvq_decprm( Word16 *param_lpc /* Q0 */ ); + Word16 D_lsf_tcxlpc( const Word16 indices[], /* i : VQ indices Q0*/ Word16 lsf_q[], /* o : quantized LSF Q1*/ @@ -8439,7 +8615,6 @@ Word16 lsf_ind_is_active( const Word16 narrowband, const Word16 cdk ); - // IGFSCFDecoder.c void IGFSCFDecoderOpen( IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i : handle to public data */ @@ -8469,7 +8644,10 @@ void ari_start_decoding_14bits_fx( Decoder_State *st, Tastat *s ); -Word16 ari_start_decoding_14bits_prm_fx( const Word16 *ptr, Word16 bp, Tastat *s ); +Word16 ari_start_decoding_14bits_prm_fx( + const Word16 *ptr, + Word16 bp, + Tastat *s ); Word16 ari_decode_14bits_s17_ext_fx( Decoder_State *st, @@ -8485,9 +8663,20 @@ Word16 ari_decode_14bits_bit_ext_fx( Decoder_State *st, Tastat *s ); -Word16 ari_decode_14bits_pow_fx( Word16 *ptr, Word16 bp, Word16 bits, Word16 *res, Tastat *s, Word16 base ); +Word16 ari_decode_14bits_pow_fx( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s, + Word16 base ); -Word16 ari_decode_14bits_sign_fx( Word16 *ptr, Word16 bp, Word16 bits, Word16 *res, Tastat *s ); +Word16 ari_decode_14bits_sign_fx( + Word16 *ptr, + Word16 bp, + Word16 bits, + Word16 *res, + Tastat *s ); // dec_prm_fx.c void getTCXparam_fx( @@ -8501,6 +8690,7 @@ void getTCXparam_fx( 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 */ @@ -8558,22 +8748,25 @@ void tcx_hm_modify_envelope( // tns_base_dec_fx.c Word16 -ReadTnsData( STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - -void ReadTnsData_ivas_fx( STnsConfig const *pTnsConfig, - Decoder_State *st, - Word16 *pnBits, - Word16 *stream, - Word16 *pnSize ); - -Word16 DecodeTnsData( STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - STnsData *pTnsData ); +ReadTnsData( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + +void ReadTnsData_ivas_fx( + STnsConfig const *pTnsConfig, + Decoder_State *st, + Word16 *pnBits, + Word16 *stream, + Word16 *pnSize ); + +Word16 DecodeTnsData( + STnsConfig const *pTnsConfig, + Word16 const *stream, + Word16 *pnSize, + STnsData *pTnsData ); Word16 DecodeTnsData_ivas_fx( STnsConfig const *pTnsConfig, @@ -8641,25 +8834,28 @@ void ReadFromBitstream_fx( Decoder_State *st, Word16 **pStream, Word16 *pnSize ); + // igf_dec_fx.c -void IGFDecReadData( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ - Decoder_State *st, /**< in: | decoder state */ - const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ +void IGFDecReadData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ ); -void IGFDecReadLevel( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ - Decoder_State *st, /**< in: | decoder state */ - const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ - const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ +void IGFDecReadLevel( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */ + Decoder_State *st, /**< in: | decoder state */ + const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */ + const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */ ); -void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - Word32 *spectrum, /**< in/out: | MDCT spectrum */ - Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ - const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ - Word16 bfi /**< in: | frame loss == 1, frame good == 0 */ - +void IGFDecApplyMono( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + Word32 *spectrum, /**< in/out: | MDCT spectrum */ + Word16 *spectrum_e, /**< in/out: | exponent of spectrum */ + const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */ + Word16 bfi /**< in: | frame loss == 1, frame good == 0 */ ); void IGFDecApplyMono_ivas( @@ -8703,8 +8899,9 @@ void IGFDecSetMode_ivas_fx( const Word16 rf_mode /* i : flag to signal the RF mode */ ); -void IGFDecUpdateInfo( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 igfGridIdx /**< in: | IGF grid index */ +void IGFDecUpdateInfo( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 igfGridIdx /**< in: | IGF grid index */ ); void IGFDecUpdateInfo_ivas_fx( @@ -8713,10 +8910,11 @@ void IGFDecUpdateInfo_ivas_fx( const Word16 igfGridIdx /* i : IGF grid index */ ); -void IGFDecCopyLPCFlatSpectrum( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ - const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ - const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ +void IGFDecCopyLPCFlatSpectrum( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */ + const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */ + const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ ); void IGFDecCopyLPCFlatSpectrum_fx( @@ -8726,12 +8924,14 @@ void IGFDecCopyLPCFlatSpectrum_fx( const Word16 igfGridIdx /**< in: Q0 | IGF grid index */ ); -void IGFDecStoreTCX10SubFrameData( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 subFrameIdx /**< in: Q0 | index of subframe */ +void IGFDecStoreTCX10SubFrameData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 subFrameIdx /**< in: Q0 | index of subframe */ ); -void IGFDecRestoreTCX10SubFrameData( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ - const Word16 subFrameIdx /**< in: Q0 | index of subframe */ +void IGFDecRestoreTCX10SubFrameData( + const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ + const Word16 subFrameIdx /**< in: Q0 | index of subframe */ ); void IGFDecRestoreTCX10SubFrameData_fx( @@ -8739,7 +8939,6 @@ void IGFDecRestoreTCX10SubFrameData_fx( const Word16 subFrameIdx /* i : index of subframe */ ); - void init_igf_dec( IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: IGF decoder handle */ ); @@ -8750,6 +8949,7 @@ Word16 dlpc_avq_fx( Word16 *LSF_Q, /* (o) Quantized LSF vectors */ Word16 numlpc, /* (i) Number of sets of lpc */ Word32 sr_core ); + Word16 decode_lpc_avq_fx( Decoder_State *st, /* i/o: decoder state structure */ const Word16 numlpc, /* i : Number of sets of lpc */ @@ -8757,20 +8957,19 @@ Word16 decode_lpc_avq_fx( ); Word16 decode_lpc_avq_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc /* o : lpc parameters */ - , + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 numlpc, /* i : Number of sets of lpc */ + Word16 *param_lpc, /* o : lpc parameters */ const Word16 ch, /* i : channel */ const Word16 element_mode, /* i : element mode */ const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ ); + // vlpc_1st_dec_fx.c void vlpc_1st_dec( Word16 index, /* i : codebook index */ Word16 *lsfq ); /* i/o: i:prediction o:quantized lsf */ - // vlpc_2st_dec_fx.c void vlpc_2st_dec( Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ @@ -8779,9 +8978,10 @@ void vlpc_2st_dec( Word32 sr_core ); // vlpc_2st_com_fx.c -void lsf_weight_2st( const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ - Word16 *w, /* output: weighting function (0Q15*1.28) */ - const Word16 mode /* input: operational mode Q0 */ +void lsf_weight_2st( + const Word16 *lsfq, /* input: quantized lsf coefficients (14Q1*1.28) */ + Word16 *w, /* output: weighting function (0Q15*1.28) */ + const Word16 mode /* input: operational mode Q0 */ ); // ACcontextMapping_fx.c @@ -8812,7 +9012,6 @@ Word32 update_mixed_context_ivas_fx( Word16 a /* Q0 */ ); - // ACcontextMapping_dec_fx.c typedef Word16 ( *get_next_coeff_function )( @@ -8830,6 +9029,7 @@ Word16 ACcontextMapping_decode2_no_mem_s17_LC( Word16 resQMaxBits, /* i: residual coding maximum bits*/ CONTEXT_HM_CONFIG *hm_cfg /* i: context-based harmonic model configuration */ ); + Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( Decoder_State *st, /* i/o: decoder state */ Word16 *x, /* o : decoded spectrum */ @@ -8847,6 +9047,7 @@ void reconfig_decoder_LPD_fx( Word32 total_brate, /* i : total bitrate Q0*/ Word16 L_frame_old /* i : frame length Q0*/ ); + void reconfig_decoder_LPD_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ const Word16 bits_frame, /* i : bit budget Q0*/ @@ -8856,33 +9057,28 @@ void reconfig_decoder_LPD_ivas_fx( ); // er_utils_fx.c -void minimumStatistics_fx( Word16 *noiseLevelMemory, /* Q15, internal state */ - Word16 *noiseLevelIndex, /* Q0, internal state */ - Word16 *currLevelIndex, /* Q0, internal state (circular buffer) */ - Word16 *noiseEstimate, /* Q15, previous estimate of background noise */ - Word16 *lastFrameLevel, /* Q15, level of the last frame */ - Word16 currentFrameLevel, /* Q15, level of the current frame */ - Word16 *noiseLevelMemory_e, /* scaling factor for noiseLevelMemory */ - Word16 const noiseEstimate_e, /* exponent of noiseEstimate */ - Word16 *new_noiseEstimate_e, /* new exponent of noise Estimate*/ - Word16 *const lastFrameLevel_e, /* exponent of lastFrameLevel */ - Word16 currentFrameLevel_e ); /* exponent of currentFrameLevel */ - - -Word16 getLevelSynDeemph_fx( /*10Q5*/ - Word16 h1Init[], - /* i: i value or vector to be processed */ /* Q15 */ - Word16 const A[], - /* i: LPC coefficients */ /* Qx */ - Word16 const lpcorder, - /* i: LPC order */ /* Q0 */ - Word16 const lenLpcExc, - /* i: length of the LPC excitation buffer */ /* Q0 */ - Word16 const preemph_fac, - /* i: preemphasis factor */ /* Q15 */ - Word16 const numLoops, - /* i: number of loops */ /* Q0 */ - Word16 *Exp /* o: exponent of return value Q15 */ +void minimumStatistics_fx( + Word16 *noiseLevelMemory, /* Q15, internal state */ + Word16 *noiseLevelIndex, /* Q0, internal state */ + Word16 *currLevelIndex, /* Q0, internal state (circular buffer) */ + Word16 *noiseEstimate, /* Q15, previous estimate of background noise */ + Word16 *lastFrameLevel, /* Q15, level of the last frame */ + Word16 currentFrameLevel, /* Q15, level of the current frame */ + Word16 *noiseLevelMemory_e, /* scaling factor for noiseLevelMemory */ + Word16 const noiseEstimate_e, /* exponent of noiseEstimate */ + Word16 *new_noiseEstimate_e, /* new exponent of noise Estimate*/ + Word16 *const lastFrameLevel_e, /* exponent of lastFrameLevel */ + Word16 currentFrameLevel_e ); /* exponent of currentFrameLevel */ + +/*10Q5*/ +Word16 getLevelSynDeemph_fx( + Word16 h1Init[], /* i: i value or vector to be processed Q15 */ + Word16 const A[], /* i: LPC coefficients Qx */ + Word16 const lpcorder, /* i: LPC order Q0 */ + Word16 const lenLpcExc, /* i: length of the LPC excitation buffer Q0 */ + Word16 const preemph_fac, /* i: preemphasis factor Q15 */ + Word16 const numLoops, /* i: number of loops Q0 */ + Word16 *Exp /* o: exponent of return value Q15 */ ); void genPlcFiltBWAdap_fx( @@ -8900,7 +9096,8 @@ void highPassFiltering_fx( const Word16 l_fir_fer ); /* i: high pass filter length */ -Word16 GetPLCModeDecision_fx( Decoder_State *st ); +Word16 GetPLCModeDecision_fx( + Decoder_State *st ); // dlpc_stoch_fx.c void lpc_unquantize_fx( @@ -8942,10 +9139,12 @@ void getLookAheadResSig( const Word16 L_frame, /* Q0 */ const Word16 numSubFrame /* Q0 */ ); + void updateLSFForConcealment( PLC_ENC_EVS_HANDLE decState, Word16 *lsf_14Q1 /* 14Q1 */ ); + void getConcealedLP( PLC_ENC_EVS_HANDLE memDecState, Word16 *AqCon, /* 14Q1 */ @@ -8953,6 +9152,7 @@ void getConcealedLP( const Word16 last_good, /* Q0 */ const Word16 L_frame /* Q0 */ ); + void getConcealedLSF( PLC_ENC_EVS_HANDLE memDecState, const Word16 lsfBase[], /* Q1 * 1.28 */ @@ -8982,15 +9182,14 @@ void con_tcx_fx( ); // er_scale_sync.c -Word16 Damping_fact_fx( /* o : damping factor */ /*Q14*/ - const Word16 coder_type, /* i : coding type in last good received frame */ - const Word16 nbLostCmpt, /* i : counter of consecutive bfi frames */ - const Word16 last_good, /* i : last good frame class */ - const Word16 stab_fac, - /* i : ISF stability factor */ /*Q15*/ - Word32 *lp_gainp, - /*i/o: damped pitch gain */ /*Q16 Word32!*/ - const Word16 core /* i : current coding mode */ +/* o : damping factor */ /*Q14*/ +Word16 Damping_fact_fx( + const Word16 coder_type, /* i : coding type in last good received frame */ + const Word16 nbLostCmpt, /* i : counter of consecutive bfi frames */ + const Word16 last_good, /* i : last good frame class */ + const Word16 stab_fac, /* i : ISF stability factor Q15*/ + Word32 *lp_gainp, /*i/o: damped pitch gain Q16 Word32!*/ + const Word16 core /* i : current coding mode */ ); // dec_tcx_fx.c @@ -9022,11 +9221,12 @@ void decoder_tcx_ivas_fx( const Word16 frame_cnt, const Word16 sba_dirac_stereo_flag ); -void decoder_tcx_post_fx( Decoder_State *st_fx, - Word16 *synth, - Word16 *synthFB, - Word16 *A, - Word16 bfi ); +void decoder_tcx_post_fx( + Decoder_State *st_fx, + Word16 *synth, + Word16 *synthFB, + Word16 *A, + Word16 bfi ); // arith_coder_dec_fx.c void tcx_arith_decode_envelope_fx( @@ -9043,9 +9243,8 @@ void tcx_arith_decode_envelope_fx( Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a*/ Word16 *arith_bits, /* o: bits used for ari. coding */ Word16 *signaling_bits, /* o: bits used for signaling */ - Word16 *nf_seed /* o: noise filling seed Q0 */ - , - Word16 low_complexity /* i: low-complexity flag Q0 */ + Word16 *nf_seed, /* o: noise filling seed Q0 */ + Word16 low_complexity /* i: low-complexity flag Q0 */ ); @@ -9096,8 +9295,7 @@ void con_acelp_fx( const Word16 stab_fac, /*mem_syn >rescaling done */ - , + Word16 *Qf_mem_syn, /*mem_syn >rescaling done */ Word16 *pitch_buffer, Word16 *voice_factors, Word16 *bwe_exc ); @@ -9216,7 +9414,9 @@ void cldfbAnalysis_ts_fx( const Word16 samplesToProcess, /* i : samples to process */ HANDLE_CLDFB_FILTER_BANK h_cldfb, Word16 *q_cldfb ); -Word16 floor_log_2( Word32 num ); + +Word16 floor_log_2( + Word32 num ); void cldfbAnalysis_ts_fx_var_q( const Word32 *timeIn_fx, @@ -9230,20 +9430,18 @@ void cldfbAnalysis_ts_fx_var_q( Word16 *q_cldfb ); void cldfbAnalysis_ts_fx_fixed_q( - const Word32 *timeIn_fx, - /* i : time buffer */ // q - Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], - /* o : real value buffer */ // q - 5 - Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], - /* o : imag value buffer */ // q - 5 - const Word16 samplesToProcess, /* i : samples to process */ - HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ + const Word32 *timeIn_fx, /* i : time buffer q */ + Word32 realBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : real value buffer q - 5 */ + Word32 imagBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : imag value buffer q - 5 */ + const Word16 samplesToProcess, /* i : samples to process */ + HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i : filterbank state */ Word16 *q_cldfb ); void configureCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ const Word32 sampling_rate /* i : sampling rate */ ); + // dec4t64.c void dec_acelp_fast_fx( Decoder_State *st, /* i/o: decoder state structure */ @@ -9251,6 +9449,7 @@ void dec_acelp_fast_fx( Word16 code[], /* o : algebraic (fixed) codebook excitation */ const Word16 L_subfr /* i : subframe length */ ); + // codec_tcx_common.c void tcx5SpectrumInterleaving_fx( const Word16 tcx5Size, @@ -9371,7 +9570,35 @@ void generate_masking_noise_dirac_ivas_fx( Word16 *q_cldfb ); // modif_fs/c -void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_TDAC, Word16 *xn_buf, const Word16 *tcx_aldo_window_1, const PWord16 *tcx_aldo_window_1_trunc, const PWord16 *tcx_aldo_window_2, const PWord16 *tcx_mdct_window_half, const PWord16 *tcx_mdct_window_minimum, const PWord16 *tcx_mdct_window_trans, Word16 tcx_mdct_window_half_length, Word16 tcx_mdct_window_min_length, Word16 index, Word16 left_rect, Word16 tcx_offset, Word16 overlap, Word16 L_frame, Word16 L_frameTCX, Word16 L_spec_TCX5, Word16 L_frame_glob, Word16 frame_cnt, Word16 bfi, Word16 *old_out, Word16 *Q_old_wtda, Decoder_State *st, Word16 fullbandScale, Word16 *acelp_zir ); +void IMDCT_fx( + Word32 *x, + Word16 x_e, + Word16 *old_syn_overl, + Word16 *syn_Overl_TDAC, + Word16 *xn_buf, + const Word16 *tcx_aldo_window_1, + const PWord16 *tcx_aldo_window_1_trunc, + const PWord16 *tcx_aldo_window_2, + const PWord16 *tcx_mdct_window_half, + const PWord16 *tcx_mdct_window_minimum, + const PWord16 *tcx_mdct_window_trans, + Word16 tcx_mdct_window_half_length, + Word16 tcx_mdct_window_min_length, + Word16 index, + Word16 left_rect, + Word16 tcx_offset, + Word16 overlap, + Word16 L_frame, + Word16 L_frameTCX, + Word16 L_spec_TCX5, + Word16 L_frame_glob, + Word16 frame_cnt, + Word16 bfi, + Word16 *old_out, + Word16 *Q_old_wtda, + Decoder_State *st, + Word16 fullbandScale, + Word16 *acelp_zir ); void IMDCT_ivas_fx( Word32 *x_fx, @@ -9425,11 +9652,11 @@ void configureFdCngDec_fx( const Word16 last_L_frame, const Word16 element_mode ); - Word32 sum2_f_16_fx( const Word16 *vec, /* i : input vector */ const Word16 lvec /* i : length of input vector */ ); + Word32 sum2_f_16_gb_fx( const Word16 *vec, /* i : input vector */ const Word16 lvec, /* i : length of input vector */ @@ -9458,7 +9685,6 @@ Word16 deindex_lvq_ivas_fx( Word16 no_bits /* i : number of bits for lattice */ ); - void deleteCldfb_ivas_fx( HANDLE_CLDFB_FILTER_BANK *h_cldfb /* i/o: filter bank handle */ ); @@ -9488,13 +9714,14 @@ UWord32 mvl2s_r( const Word16 n /* i : vector size */ ); -void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, - Word16 *synth, - Word16 *synthFB, - Word16 Q_syn, - Word16 *A, - Word16 bfi, - Word16 MCT_flag ); +void decoder_tcx_post_ivas_fx( + Decoder_State *st_fx, + Word16 *synth, + Word16 *synthFB, + Word16 Q_syn, + Word16 *A, + Word16 bfi, + Word16 MCT_flag ); void con_tcx_ivas_fx( Decoder_State *st, /* i/o: coder memory state */ @@ -9507,13 +9734,11 @@ void con_tcx_ivas_fx( ); void ivas_mdct_core_reconstruct_fx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - Word32 *x_fx[][NB_DIV], - /* i/o: synthesis @internal_FS */ // Q(q_x) - Word16 signal_outFB_fx[CPE_CHANNELS][L_FRAME_PLUS], - /* o : synthesis @output_FS */ // e_sig - Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ + Word32 *x_fx[][NB_DIV], /* i/o: synthesis @internal_FS Q(q_x) */ + Word16 signal_outFB_fx[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS e_sig */ + Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ Word16 q_x, Word16 e_sig[CPE_CHANNELS] ); @@ -9542,42 +9767,48 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( CONTEXT_HM_CONFIG *hm_cfg /* context-based harmonic model configuration */ ); -Word16 usdequant_fx( /* Qx*/ - const Word16 idx, /* i: quantizer index Q0*/ - const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word16 delta /* i: quantization step Qy*/ +/* Qx*/ +Word16 usdequant_fx( + const Word16 idx, /* i: quantizer index Q0*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta /* i: quantization step Qy*/ ); -Word32 usdequant32_fx( /* Qx*/ - const Word16 idx, /* i: quantizer index Q0*/ - const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word32 delta /* i: quantization step Qy*/ +/* Qx*/ +Word32 usdequant32_fx( + const Word16 idx, /* i: quantizer index Q0*/ + const Word32 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word32 delta /* i: quantization step Qy*/ ); -Word16 usquant_fx( /* o: index of the winning codeword */ - const Word16 x, /* i: scalar value to quantize Qx*/ - Word16 *xq, /* o: quantized value Qx*/ - const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ - const Word16 delta, /* i: quantization step Qx-1*/ - const Word16 cbsize /* i: codebook size */ +/* o: index of the winning codeword */ +Word16 usquant_fx( + const Word16 x, /* i: scalar value to quantize Qx*/ + Word16 *xq, /* o: quantized value Qx*/ + const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/ + const Word16 delta, /* i: quantization step Qx-1*/ + const Word16 cbsize /* i: codebook size */ ); -Word32 Dot_product( /* o : Sum */ - const Word16 x[], /* i : 12bits: x vector */ - const Word16 y[], /* i : 12bits: y vector */ - const Word16 lg /* i : vector length */ +/* o : Sum */ +Word32 Dot_product( + const Word16 x[], /* i : 12bits: x vector */ + const Word16 y[], /* i : 12bits: y vector */ + const Word16 lg /* i : vector length */ ); -Word32 dotp_fx( /* o : dot product of x[] and y[] */ - const Word16 x[], /* i : vector x[] */ - const Word16 y[], /* i : vector y[] */ - const Word16 n, /* i : vector length */ - Word16 *exp /* (o) : exponent of result (0..+30) */ +/* o : dot product of x[] and y[] */ +Word32 dotp_fx( + const Word16 x[], /* i : vector x[] */ + const Word16 y[], /* i : vector y[] */ + const Word16 n, /* i : vector length */ + Word16 *exp /* (o) : exponent of result (0..+30) */ ); -Word32 sum2_fx_mod( /* o : sum of all squared vector elements Q(2x+1)*/ - const Word16 *vec, /* i : i vector Qx*/ - const Word16 lvec /* i : length of i vector */ +/* o : sum of all squared vector elements Q(2x+1)*/ +Word32 sum2_fx_mod( + const Word16 *vec, /* i : i vector Qx*/ + const Word16 lvec /* i : length of i vector */ ); void Copy_Scale_sig( @@ -9621,19 +9852,23 @@ void Random_Fill( Word16 scaling /* i : scaling of values */ ); -Word16 mean_fx( /* o : mean of vector */ - const Word16 *vec_fx, /* i : i vector */ - const Word16 lvec_fx /* i : length of i vector */ +/* o : mean of vector */ +Word16 mean_fx( + const Word16 *vec_fx, /* i : i vector */ + const Word16 lvec_fx /* i : length of i vector */ ); -Word16 mean_no_sat_fx( /* o : mean of vector Qx */ - const Word16 *vec_fx, /* i : input vector Qx */ - const Word16 lvec_fx /* i : length of input vector */ +/* o : mean of vector Qx */ +Word16 mean_no_sat_fx( + const Word16 *vec_fx, /* i : input vector Qx */ + const Word16 lvec_fx /* i : length of input vector */ ); -Word32 mean_no_sat_Word32_fx( /* o : mean of vector Qx */ - const Word32 *vec_fx, /* i : input vector Qx */ - const Word16 lvec_fx, /* i : length of input vector */ - const Word16 gb ); + +/* o : mean of vector Qx */ +Word32 mean_no_sat_Word32_fx( + const Word32 *vec_fx, /* i : input vector Qx */ + const Word16 lvec_fx, /* i : length of input vector */ + const Word16 gb ); void sort( UWord16 *x, /* i/o: Vector to be sorted */ UWord16 len /* i/o: vector length */ @@ -9651,52 +9886,60 @@ void sort_32_fx( const Word16 up /* I : High limit of sorting range */ ); -Word16 minimum_fx( /* o : index of the minimum value in the input vector */ - const Word16 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word16 *min_fx /* o : minimum value in the input vector */ +/* o : index of the minimum value in the input vector */ +Word16 minimum_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *min_fx /* o : minimum value in the input vector */ ); -Word16 maximum_fx( /* o : index of the maximum value in the input vector */ - const Word16 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word16 *max_fx /* o : maximum value in the input vector */ +/* o : index of the maximum value in the input vector */ +Word16 maximum_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word16 *max_fx /* o : maximum value in the input vector */ ); -Word16 maximum_exp_fx( /* o : index of the maximum value in the input vector */ - const Word16 *vec_fx, /* i : input vector */ - const Word16 *exp_vec, /* i : exponents of input vector */ - const Word16 lvec_fx /* i : length of input vector */ +/* o : index of the maximum value in the input vector */ +Word16 maximum_exp_fx( + const Word16 *vec_fx, /* i : input vector */ + const Word16 *exp_vec, /* i : exponents of input vector */ + const Word16 lvec_fx /* i : length of input vector */ ); -Word16 maximum_abs_16_fx( /* o : index of the maximum abs value in the input vector */ - const Word16 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word16 *max_val /* o : maximum value in the input vector */ +/* o : index of the maximum abs value in the input vector */ +Word16 maximum_abs_16_fx( + const Word16 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word16 *max_val /* o : maximum value in the input vector */ ); -Word16 minimum_abs32_fx( /* o : index of the minimum value in the input vector */ - const Word32 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word32 *min_fx /* o : minimum value in the input vector */ +/* o : index of the minimum value in the input vector */ +Word16 minimum_abs32_fx( + const Word32 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word32 *min_fx /* o : minimum value in the input vector */ ); -Word16 minimum_32_fx( /* o : index of the minimum value in the input vector */ - const Word32 *vec_fx, /* i : input vector */ - const Word16 lvec_fx, /* i : length of input vector */ - Word32 *min_fx /* o : minimum value in the input vector */ +/* o : index of the minimum value in the input vector */ +Word16 minimum_32_fx( + const Word32 *vec_fx, /* i : input vector */ + const Word16 lvec_fx, /* i : length of input vector */ + Word32 *min_fx /* o : minimum value in the input vector */ ); -Word16 maximum_32_fx( /* o : index of the maximum value in the input vector */ - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ +/* o : index of the maximum value in the input vector */ +Word16 maximum_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ ); -Word16 maximum_abs_32_fx( /* o : index of the maximum value in the input vector */ - const Word32 *vec, /* i : input vector */ - const Word16 lvec, /* i : length of input vector */ - Word32 *max_val /* o : maximum value in the input vector */ +/* o : index of the maximum value in the input vector */ +Word16 maximum_abs_32_fx( + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ + Word32 *max_val /* o : maximum value in the input vector */ ); /*! r: index of the maximum value in the input vector */ @@ -9723,42 +9966,50 @@ Word16 Exp32Array( const Word32 *sx /* (i): Data array */ ); -Word32 sum16_32_fx( /* o : sum of all vector elements Qx*/ - const Word16 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ +/* o : sum of all vector elements Qx*/ +Word32 sum16_32_fx( + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ ); -Word32 sum32_sat( /* o : sum of all vector elements Qx*/ - const Word32 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ +/* o : sum of all vector elements Qx*/ +Word32 sum32_sat( + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ ); -Word32 var_fx_32( /* o: variance of vector Qx+16*/ - const Word16 *x, /* i: input vector Qx*/ - const Word16 Qx, - const Word16 len /* i: length of inputvector */ -); -Word32 var_fx_32in_32out( /* o: variance of vector Qx+16*/ - const Word32 *x, /* i: input vector Qx*/ - Word16 *Qx, - const Word16 len, /* i: length of inputvector */ - const Word16 gb ); -Word16 var_fx( /* o: variance of vector Qx*/ - const Word16 *x, /* i: input vector Qx*/ - const Word16 Qx, - const Word16 len /* i: length of inputvector */ +/* o: variance of vector Qx+16*/ +Word32 var_fx_32( + const Word16 *x, /* i: input vector Qx*/ + const Word16 Qx, + const Word16 len /* i: length of inputvector */ ); -Word16 std_fx( /* o: standard deviation */ - const Word16 x[], /* i: input vector */ - const Word16 len /* i: length of the input vector */ +/* o: variance of vector Qx+16*/ +Word32 var_fx_32in_32out( + const Word32 *x, /* i: input vector Qx*/ + Word16 *Qx, + const Word16 len, /* i: length of inputvector */ + const Word16 gb ); + +/* o: variance of vector Qx*/ +Word16 var_fx( + const Word16 *x, /* i: input vector Qx*/ + const Word16 Qx, + const Word16 len /* i: length of inputvector */ ); -Word32 dot_product_mat_fx( /* o : the dot product x'*A*x */ - const Word16 *x, /* i : vector x Q15 */ - const Word32 *A, /* i : matrix A Q0*/ - const Word16 m /* i : vector & matrix size */ +/* o: standard deviation */ +Word16 std_fx( + const Word16 x[], /* i: input vector */ + const Word16 len /* i: length of the input vector */ +); +/* o : the dot product x'*A*x */ +Word32 dot_product_mat_fx( + const Word16 *x, /* i : vector x Q15 */ + const Word32 *A, /* i : matrix A Q0*/ + const Word16 m /* i : vector & matrix size */ ); void Vr_subt( @@ -9768,22 +10019,24 @@ void Vr_subt( Word16 N /* i : Vector lenght */ ); -Word16 vquant_ivas_fx( /* o: index of the winning codevector */ - Word32 x[], /* i: vector to quantize Q25 */ - const Word32 x_mean[], /* i: vector mean to subtract (0 if none) Q25 */ - Word32 xq[], /* o: quantized vector Q25 */ - const Word32 cb[], /* i: codebook Q25 */ - const Word16 dim, /* i: dimension of codebook vectors */ - const Word16 cbsize /* i: codebook size */ +/* o: index of the winning codevector */ +Word16 vquant_ivas_fx( + Word32 x[], /* i: vector to quantize Q25 */ + const Word32 x_mean[], /* i: vector mean to subtract (0 if none) Q25 */ + Word32 xq[], /* o: quantized vector Q25 */ + const Word32 cb[], /* i: codebook Q25 */ + const Word16 dim, /* i: dimension of codebook vectors */ + const Word16 cbsize /* i: codebook size */ ); -Word16 vquant_fx( /* o: index of the winning codevector */ - Word16 x[], /* i: vector to quantize Q13 */ - const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/ - Word16 xq[], /* o: quantized vector Q13 */ - const Word16 cb[], /* i: codebook Q13 */ - const Word16 dim, /* i: dimension of codebook vectors */ - const Word16 cbsize /* i: codebook size */ +/* o: index of the winning codevector */ +Word16 vquant_fx( + Word16 x[], /* i: vector to quantize Q13 */ + const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/ + Word16 xq[], /* o: quantized vector Q13 */ + const Word16 cb[], /* i: codebook Q13 */ + const Word16 dim, /* i: dimension of codebook vectors */ + const Word16 cbsize /* i: codebook size */ ); Word16 w_vquant_fx( @@ -9796,36 +10049,42 @@ Word16 w_vquant_fx( const Word16 rev_vect /* i: reverse codebook vectors */ ); -Word16 emaximum_fx( /* o : return index with max energy value in vector Q0 */ - const Word16 Qvec, /* i : Q of input vector Q0 */ - const Word16 *vec, /* i : input vector Qx */ - const Word16 lvec, /* i : length of input vector Q0 */ - Word32 *ener_max /* o : maximum energy value Q0 */ +/* o : return index with max energy value in vector Q0 */ +Word16 emaximum_fx( + const Word16 Qvec, /* i : Q of input vector Q0 */ + const Word16 *vec, /* i : input vector Qx */ + const Word16 lvec, /* i : length of input vector Q0 */ + Word32 *ener_max /* o : maximum energy value Q0 */ ); -Word16 emaximum_32fx( /* o : return index with max energy value in vector Q0 */ - const Word16 Qvec, /* i : Q of input vector Q0 */ - const Word32 *vec, /* i : input vector Qx */ - const Word16 lvec, /* i : length of input vector Q0 */ - Word32 *ener_max /* o : maximum energy value Q0 */ +/* o : return index with max energy value in vector Q0 */ +Word16 emaximum_32fx( + const Word16 Qvec, /* i : Q of input vector Q0 */ + const Word32 *vec, /* i : input vector Qx */ + const Word16 lvec, /* i : length of input vector Q0 */ + Word32 *ener_max /* o : maximum energy value Q0 */ ); -Word32 Mean32( /* o : mean of the elements of the vector */ - const Word32 in[], /* i : input vector */ - const Word16 L /* i : length of input vector */ +/* o : mean of the elements of the vector */ +Word32 Mean32( + const Word32 in[], /* i : input vector */ + const Word16 L /* i : length of input vector */ ); -Word32 sum32_fx( /* o : sum of all vector elements Qx*/ - const Word32 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ +/* o : sum of all vector elements Qx*/ +Word32 sum32_fx( + const Word32 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ ); -Word16 sum16_fx( /* o : sum of all vector elements Qx*/ - const Word16 *vec, /* i : input vector Qx*/ - const Word16 lvec /* i : length of input vector */ +/* o : sum of all vector elements Qx*/ +Word16 sum16_fx( + const Word16 *vec, /* i : input vector Qx*/ + const Word16 lvec /* i : length of input vector */ ); -Word16 own_random2_fx( Word16 seed ); +Word16 own_random2_fx( + Word16 seed ); void iDiv_and_mod_32( const Word32 Numer, /* i : 32 bits numerator */ @@ -9865,16 +10124,17 @@ Word32 root_a_over_b_ivas_fx( Word16 Q_b, Word16 *exp_out ); -void fir_fx( const Word16 x[], /* i : input vector Qx*/ - const Word16 h[], /* i : impulse response of the FIR filter Q12*/ - Word16 y[], /* o : output vector (result of filtering) Qx*/ - Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/ - const Word16 L, /* i : input vector size */ - const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */ - const Word16 upd /* i : 1 = update the memory, 0 = not */ - , - Word16 shift /* i : difference between Q15 and scaling of h[] */ +void fir_fx( + const Word16 x[], /* i : input vector Qx*/ + const Word16 h[], /* i : impulse response of the FIR filter Q12*/ + Word16 y[], /* o : output vector (result of filtering) Qx*/ + Word16 mem[], /* i/o: memory of the input signal (L samples) Qx*/ + const Word16 L, /* i : input vector size */ + const Word16 K, /* i : order of the FIR filter (K+1 coefs.) */ + const Word16 upd, /* i : 1 = update the memory, 0 = not */ + Word16 shift /* i : difference between Q15 and scaling of h[] */ ); + void v_add_32( const Word32 x1[], /* i : Input vector 1 */ const Word32 x2[], /* i : Input vector 2 */ @@ -9896,7 +10156,6 @@ void v_sub_32( const Word16 N /* i : Vector length */ ); - void v_add_16( const Word16 x1[], /* i : Input vector 1 */ const Word16 x2[], /* i : Input vector 2 */ @@ -9911,12 +10170,12 @@ void v_sub_16( const Word16 N /* i : Vector length */ ); - -Word16 squant_fx( /* o: index of the winning codeword */ - const Word16 x, /* i: scalar value to quantize */ - Word16 *xq, /* o: quantized value */ - const Word16 cb[], /* i: codebook */ - const Word16 cbsize /* i: codebook size */ +/* o: index of the winning codeword */ +Word16 squant_fx( + const Word16 x, /* i: scalar value to quantize */ + Word16 *xq, /* o: quantized value */ + const Word16 cb[], /* i: codebook */ + const Word16 cbsize /* i: codebook size */ ); Word16 squant_int_fx( @@ -9988,60 +10247,83 @@ void add_vec_fx( const Word16 N /* i : Vector lenght */ ); -Word32 Add_flt32_flt32( /* o: Result (Normalized) */ - Word32 a, /* i: 1st Value */ - Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ - Word32 b, /* i: 2nd Value */ - Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ - Word16 *exp_out /* o: Exponent of Result */ +/* o: Result (Normalized) */ +Word32 Add_flt32_flt32( + Word32 a, /* i: 1st Value */ + Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ + Word32 b, /* i: 2nd Value */ + Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o: Exponent of Result */ ); -Word32 Mul_flt32_Q15( /* o: Result (Normalized) */ - Word32 value, /* i: Pseudo_float Value */ - Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */ - Word16 frac /* i: Q15 value */ +/* o: Result (Normalized) */ +Word32 Mul_flt32_Q15( + Word32 value, /* i: Pseudo_float Value */ + Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */ + Word16 frac /* i: Q15 value */ ); -Word32 Div_flt32_flt32( /* o: Result (Normalized) */ - Word32 a, /* i: 1st Value */ - Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ - Word32 b, /* i: 2nd Value */ - Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ - Word16 *exp_out /* o: Exponent of Result */ +/* o: Result (Normalized) */ +Word32 Div_flt32_flt32( + Word32 a, /* i: 1st Value */ + Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */ + Word32 b, /* i: 2nd Value */ + Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */ + Word16 *exp_out /* o: Exponent of Result */ ); -Word32 Calc_Energy_Autoscaled( /* o: Result (Energy) */ - const Word16 *signal, /* i: Signal */ - Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */ - Word16 len, /* i: Frame Length */ - Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */ +/* o: Result (Energy) */ +Word32 Calc_Energy_Autoscaled( + const Word16 *signal, /* i: Signal */ + Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */ + Word16 len, /* i: Frame Length */ + Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */ ); -Word16 Find_Max_Norm16( const Word16 *src, Word16 len ); - -Word16 Find_Max_Norm32( const Word32 *src, Word16 len ); +Word16 Find_Max_Norm16( + const Word16 *src, + Word16 len ); -Word32 Sqrt_Ratio32( /* o: Result in Q31 */ - Word32 L_val1, /* i: Mantisa of Val1 */ - Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ - Word32 L_val2, /* i: Mantisa of Val2 */ - Word16 exp2, /* i: Exp of Val2 (same as exp1) */ - Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ +Word16 Find_Max_Norm32( + const Word32 *src, + Word16 len ); +/* o: Result in Q31 */ +Word32 Sqrt_Ratio32( + Word32 L_val1, /* i: Mantisa of Val1 */ + Word16 exp1, /* i: Exp of Val1 (>0: Val was Left Shifted, <0:Right Shifted) */ + Word32 L_val2, /* i: Mantisa of Val2 */ + Word16 exp2, /* i: Exp of Val2 (same as exp1) */ + Word16 *exp /* o: Exp of Result (# of 'L_shl' Req to get to Final Value) */ ); -Word16 Invert16( /* result in Q'15 + 'exp' */ - Word16 val, - Word16 *exp ); +/* result in Q'15 + 'exp' */ +Word16 Invert16( + Word16 val, + Word16 *exp ); -Word16 find_rem( Word16 n, Word16 m, Word16 *r ); +Word16 find_rem( + Word16 n, + Word16 m, + Word16 *r ); -Word32 find_remd( Word32 n, Word32 m, Word32 *r ); +Word32 find_remd( + Word32 n, + Word32 m, + Word32 *r ); Word16 rint_new_fx( Word32 x /*Q16 */ ); -Word16 erb_diff_search_fx( Word16 *prev_erb, const Word16 *curr_erb, Word16 *dif_erb, Word16 *pow_spec, const Word16 *cb_fx, Word16 cb_size, Word16 cb_dim, Word16 offset ); +Word16 erb_diff_search_fx( + Word16 *prev_erb, + const Word16 *curr_erb, + Word16 *dif_erb, + Word16 *pow_spec, + const Word16 *cb_fx, + Word16 cb_size, + Word16 cb_dim, + Word16 offset ); void Acelp_dec_total_exc( Word16 *exc_fx, /* i/o: adapt. excitation exc */ @@ -10053,11 +10335,18 @@ void Acelp_dec_total_exc( const Word16 L_subfr /* i : Subframne lenght */ ); -UWord32 UL_inverse( const UWord32 UL_val, Word16 *exp ); +UWord32 UL_inverse( + const UWord32 UL_val, + Word16 *exp ); -UWord32 UL_div( const UWord32 UL_num, const UWord32 UL_den ); +UWord32 UL_div( + const UWord32 UL_num, + const UWord32 UL_den ); -Word16 ratio( const Word32 numer, const Word32 denom, Word16 *expo ); +Word16 ratio( + const Word32 numer, + const Word32 denom, + Word16 *expo ); void hp400_12k8_fx( Word16 signal[], /* i/o: input signal / output is divided by 16 */ @@ -10071,9 +10360,19 @@ void hp400_12k8_ivas_fx( Word16 mem[] /* i/o: filter memory [6] */ ); -Word16 dot_prod_satcontr( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len ); +Word16 dot_prod_satcontr( + const Word16 *x, + const Word16 *y, + Word16 qx, + Word16 qy, + Word16 *qo, + Word16 len ); -void E_UTIL_f_convolve( const Word16 x[], const Word16 h[], Word16 y[], const Word16 size ); +void E_UTIL_f_convolve( + const Word16 x[], + const Word16 h[], + Word16 y[], + const Word16 size ); void floating_point_add( Word32 *mx, /* io: mantissa of the addend Q31 */ @@ -10114,7 +10413,8 @@ Word16 lin_interp_fx( const Word16 flag_sat /* i : flag to indicate whether to apply saturation */ ); -Word16 ceil_log_2( UWord64 val ); +Word16 ceil_log_2( + UWord64 val ); Word32 imax_pos_fx( const Word32 *y /* i : Input vector for peak interpolation Qx*/ diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 48322cb71..3a1f7bd8e 100755 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6543,7 +6543,7 @@ void wb_tbe_extras_reset_synth_fx( *-------------------------------------------------------------------*/ void elliptic_bpf_48k_generic_fx( - const int16_t element_mode, + const Word16 element_mode, Word16 IsUpsampled3, Word16 input_fx[], /* i : input signal Q_input_fx*/ Word16 *Q_input_fx, @@ -6861,7 +6861,7 @@ void synthesise_fb_high_band_fx( Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ Word16 bpf_memory_Q[], Word16 Qout, - int16_t element_mode ) + Word16 element_mode ) { Word16 i, j; Word16 excitation_in_interp3_buffer[L_FRAME48k + 4]; diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index fa0f7a9df..62175a658 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -681,10 +681,6 @@ void lpc2mdct( const PWord16 *ptwiddle; Word32 workBuffer[2 * BASOP_CFFT_MAX_LENGTH]; -#ifndef IVAS_CODE_TCX_UTIL - (void) noInverse; -#endif - assert( length <= FDNS_NPTS ); sizeN = shl( length, 1 ); /*Q0*/ @@ -709,23 +705,11 @@ void lpc2mdct( move32(); } - move16(); -#ifdef IVAS_CODE_TCX_UTIL if ( noInverse ) { - /* half length FFT */ - scale = add( norm_s( lpcCoeffs[0] ), 1 ); - BASOP_cfft( (cmplx *) ComplexData, FDNS_NPTS, &scale, workBuffer ); // tbv -> In float the fft type changes as well - /*Get amplitude*/ - j = sub( length, 1 ); - k = 0; - for ( i = 0; i < length; i++ ) - { - mdct_gains[i] = (float) ( sqrt( RealData[i] * RealData[i] + ImagData[i] * ImagData[i] ) ); - } + /* not used */ } else -#endif { /* half length FFT */ scale = add( norm_s( lpcCoeffs[0] ), 1 ); @@ -2045,7 +2029,6 @@ void InitTnsConfigs_ivas_fx( InitTnsConfiguration_ivas_fx( bwidth, add( L_frame, shr( L_frame, 2 ) ), &tnsConfig[1][1], igfStopFreq, total_brate, element_mode, MCT_flag ); } - void SetTnsConfig( TCX_CONFIG_HANDLE hTcxCfg, /* i : configuration of TCX */ const Word16 isTCX20, /*Q0*/ @@ -2055,8 +2038,7 @@ void SetTnsConfig( hTcxCfg->pCurrentTnsConfig = &hTcxCfg->tnsConfig[isTCX20][isAfterACELP]; assert( hTcxCfg->pCurrentTnsConfig != NULL ); } -#define IVAS_CODE_TCX_UTIL -#ifdef IVAS_CODE_TCX_UTIL + /*-------------------------------------------------------------------* * SetAllowTnsOnWhite * @@ -2078,8 +2060,6 @@ void SetAllowTnsOnWhite( move16(); return; } -#endif -#undef IVAS_CODE_TCX_UTIL void tcx_get_gain( Word32 *x, /* i: spectrum 1 Q31 - x_e*/ diff --git a/lib_com/tools.c b/lib_com/tools.c index 909460c5d..ddf1e31c2 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -795,12 +795,12 @@ void v_sub_fixed_no_hdrm( } /*-------------------------------------------------------------------* - * v_multc_fixed() + * v_multc_fx() * * Multiplication of vector by constant *-------------------------------------------------------------------*/ -void v_multc_fixed( +void v_multc_fx( const Word32 x[], /* i : Input vector */ const Word32 c, /* i : Constant */ Word32 y[], /* o : Output vector that contains c*x */ diff --git a/lib_dec/FEC_adapt_codebook_fx.c b/lib_dec/FEC_adapt_codebook_fx.c index fae55ab5b..24ddc6463 100644 --- a/lib_dec/FEC_adapt_codebook_fx.c +++ b/lib_dec/FEC_adapt_codebook_fx.c @@ -15,14 +15,12 @@ * Create an artificial onset when it is lost *---------------------------------------------------------------------*/ Word16 FEC_SinOnset_fx( - Word16 *exc, - /* i/o : exc vector to modify */ // Qin = Qold, Qout = Q_exc - Word16 puls_pos, /* i : last pulse position desired */ - const Word16 T0, /* i : Pitch information of the 1 subfr */ - Word32 enr_q, /* i : energy provide by the encoder */ - Word16 *Aq, /* i : A(z) filter Q12 */ - const Word16 L_frame /* i : frame length */ - , + Word16 *exc, /* i/o : exc vector to modify Qin = Qold, Qout = Q_exc */ + Word16 puls_pos, /* i : last pulse position desired */ + const Word16 T0, /* i : Pitch information of the 1 subfr */ + Word32 enr_q, /* i : energy provide by the encoder */ + Word16 *Aq, /* i : A(z) filter Q12 */ + const Word16 L_frame, /* i : frame length */ const Word16 Qold ) { Word16 P0, onset_len, sign, i, len, L_subfr, L_subfr2; diff --git a/lib_dec/FEC_pitch_estim_fx.c b/lib_dec/FEC_pitch_estim_fx.c index b7ad94f89..4ea25cd85 100644 --- a/lib_dec/FEC_pitch_estim_fx.c +++ b/lib_dec/FEC_pitch_estim_fx.c @@ -44,10 +44,9 @@ void FEC_pitch_estim_fx( const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */ Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC Q6*/ Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */ - Word16 *upd_cnt /* i/o: update counter */ - , - const Word16 coder_type, /* i : coder_type */ - Word16 element_mode /* i : element mode */ + Word16 *upd_cnt, /* i/o: update counter */ + const Word16 coder_type, /* i : coder_type */ + Word16 element_mode /* i : element mode */ ) { Word16 tmp, tmp1, tmp2, tmp3; diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index f07feac96..d1ec20b0b 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -941,11 +941,10 @@ void Post_music_postP_fx( Word16 *mem_deemph, /* i/o: speech deemph filter memory Q_syn*/ Word16 *st_pst_old_syn_fx, /* i/o: psfiler Q_syn*/ Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler Q_syn*/ - Word16 *mem_agc, /*Q_syn*/ + Word16 *mem_agc, /* Q_syn */ PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */ - const Word16 *tmp_buffer /* tmp_buffer in Q-1 */ - , - Word16 *mem_tmp2 /* Temporary memory used with scale_syn Q_syn*/ + const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */ + Word16 *mem_tmp2 /* Temporary memory used with scale_syn Q_syn*/ ) { Word16 exc16[DCT_L_POST]; diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index 60a59c4da..051c74edf 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -35,7 +35,6 @@ static Word16 tcx_arith_decode_fx( move32(); #endif - bp = ari_start_decoding_14bits_prm_fx( prm, 0, &as ); tmp = sub( envelope_e, 1 + 15 ); @@ -108,9 +107,8 @@ void tcx_arith_decode_envelope_fx( Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a Q0*/ Word16 *arith_bits, /* o: bits used for ari. coding Q0 */ Word16 *signaling_bits, /* o: bits used for signaling Q0 */ - Word16 *nf_seed /* o: noise filling seed Q0 */ - , - Word16 low_complexity /* i: low-complexity flag Q0 */ + Word16 *nf_seed, /* o: noise filling seed Q0 */ + Word16 low_complexity /* i: low-complexity flag Q0 */ ) { Word32 env[N_MAX_ARI]; /* unscaled envelope */ @@ -148,7 +146,6 @@ void tcx_arith_decode_envelope_fx( return; } - *signaling_bits = 0; move16(); assert( st->hTcxDec->enableTcxLpc ); diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index b861b8aba..5dcd4ca4a 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -620,14 +620,11 @@ void decoder_tcx_fx( test(); IF( ( bfi == 0 ) && ( hTcxCfg->resq != 0 ) ) { - IF( hTcxDec->tcx_lpc_shaped_ari != 0 ) /* new arithmetic coder */ { - Word16 *prm_resq; - prm_resq = prm_sqQ + sub( *prm_target /* = targetBits */ - , + prm_resq = prm_sqQ + sub( *prm_target, /* = targetBits */ hTcxDec->resQBits[frame_cnt] ); i = tcx_ari_res_invQ_spec( x, x_e, L_spec, @@ -661,7 +658,6 @@ void decoder_tcx_fx( } /* for FAC */ - test(); IF( bfi == 0 && st->tcxonly == 0 ) { @@ -731,7 +727,6 @@ void decoder_tcx_fx( } } - IF( hTcxDec->tcx_lpc_shaped_ari == 0 ) /* old arithmetic coder */ { /* noise filling seed */ @@ -3321,7 +3316,7 @@ void IMDCT_ivas_fx( move32(); } q_tmp_fx_32 = sub( q_xn_buf_fx_32, res_e ); - // v_multc_fixed( xn_buf_fx_32 + overlap / 2 + nz, (float) sqrt( (float) L_frame / NORM_MDCT_FACTOR ), tmp_fx_32, L_frame ); + // v_multc_fx( xn_buf_fx_32 + overlap / 2 + nz, (float) sqrt( (float) L_frame / NORM_MDCT_FACTOR ), tmp_fx_32, L_frame ); if ( allow_qwin_change ) { diff --git a/lib_dec/dlpc_avq_fx.c b/lib_dec/dlpc_avq_fx.c index 07f1ea6f2..4be63062f 100644 --- a/lib_dec/dlpc_avq_fx.c +++ b/lib_dec/dlpc_avq_fx.c @@ -285,10 +285,9 @@ Word16 decode_lpc_avq_fx( } Word16 decode_lpc_avq_ivas_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const Word16 numlpc, /* i : Number of sets of lpc */ - Word16 *param_lpc /* o : lpc parameters */ - , + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 numlpc, /* i : Number of sets of lpc */ + Word16 *param_lpc, /* o : lpc parameters */ const Word16 ch, /* i : channel */ const Word16 element_mode, /* i : element mode */ const Word16 sns_low_br_mode /* i : SNS low-bitrate mode */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 47724c6e6..6ed60bf46 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -3641,9 +3641,8 @@ void generate_comfort_noise_dec_hf_ivas_fx( void generate_masking_noise_fx( Word16 *timeDomainBuffer, /* i/o : pointer to time domain output buffer 15Q0 */ Word16 Q, - HANDLE_FD_CNG_COM hFdCngCom /* i/o : pointer to FD_CNG_COM structure */ - , - Word16 length, /*Q0*/ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o : pointer to FD_CNG_COM structure */ + Word16 length, /*Q0*/ Word16 core /*Q0*/ ) { Word16 i, s, s1, s2, sq, cnt, startBand2, stopFFTbin2; @@ -3855,10 +3854,9 @@ void generate_masking_noise_update_seed_fx( * Generate additional comfort noise (kind of noise filling) * ************************************************************/ void generate_masking_noise_mdct_fx( - Word32 *mdctBuffer, /* i/o: time-domain signal Q31 - mdctBuffer_e*/ - Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ - HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */ - , + Word32 *mdctBuffer, /* i/o: time-domain signal Q31 - mdctBuffer_e*/ + Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ Word16 L_frame ) { Word16 i, s, s1, s2, sq, cnt; @@ -4112,7 +4110,7 @@ void generate_masking_noise_mdct_ivas_fx( } /*re-normalization of energy level: M/sqrt(2)*/ - v_multc_fixed( maskingNoise, SQRT_NORM_MDCT_FACTOR_Q27, maskingNoise, hFdCngCom->stopFFTbin ); // Q11 + v_multc_fx( maskingNoise, SQRT_NORM_MDCT_FACTOR_Q27, maskingNoise, hFdCngCom->stopFFTbin ); // Q11 scale_sig32( maskingNoise, hFdCngCom->stopFFTbin, sub( 20, *mdctBuffer_e ) ); // exp = *mdctBuffer_e diff --git a/lib_dec/gs_dec_amr_wb_fx.c b/lib_dec/gs_dec_amr_wb_fx.c index eea37431a..4a0bf352f 100644 --- a/lib_dec/gs_dec_amr_wb_fx.c +++ b/lib_dec/gs_dec_amr_wb_fx.c @@ -122,8 +122,7 @@ static void Ener_per_band_fx( static void Apply_gain_fx( 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*/ - , + Word32 L_Ener_per_bd_yQ[], /* i : Ener per band for norm vector Qx*/ const Word16 Q_out ) { Word16 i_band; diff --git a/lib_dec/hq_env_dec_fx.c b/lib_dec/hq_env_dec_fx.c index 7c5af1b2a..5011dcf86 100644 --- a/lib_dec/hq_env_dec_fx.c +++ b/lib_dec/hq_env_dec_fx.c @@ -13,15 +13,15 @@ * Decode envelope indices *------------------------------------------------------------------------*/ -Word16 decode_envelope_indices_fx( /* o : Number of bits Q0*/ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 start_norm, /* i : starting band index Q0*/ - const Word16 num_sfm, /* i : Number of subbands Q0*/ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0*/ - Word16 *difidx, /* o : Diff indices/encoded diff indices Q0*/ - const Word16 flag_HQ2 /* i : indicator of HQ2 core Q0*/ - , - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0*/ +/* o : Number of bits Q0*/ +Word16 decode_envelope_indices_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word16 start_norm, /* i : starting band index Q0*/ + const Word16 num_sfm, /* i : Number of subbands Q0*/ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0*/ + Word16 *difidx, /* o : Diff indices/encoded diff indices Q0*/ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0*/ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0*/ ) { Word16 hcode_l; diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index a36209423..c6b98c2c1 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -45,28 +45,33 @@ #include "ivas_prot_fx.h" #include "ivas_rom_com_fx.h" #include "debug.h" -#define NUM_TAPS_F0_6 ( Word16 )( 58 ) // (Word16) ceil( 0.6f * hBinRenConvModule->numTaps ) -#define NUM_TAPS_F0_5 ( Word16 )( 48 ) // (Word16) ceil( 0.5f * hBinRenConvModule->numTaps ) -#define NUM_TAPS_F0_4 ( Word16 )( 39 ) // (Word16) ceil( 0.4f * hBinRenConvModule->numTaps ) -#define NUM_TAPS_F0_3 ( Word16 )( 29 ) // (Word16) ceil( 0.3f * hBinRenConvModule->numTaps ) + /*----------------------------------------------------------------------------------* * Local constants *----------------------------------------------------------------------------------*/ #define REVERB_INPUT_DOWNMIX_CHANNELS ( 11 ) + +#define NUM_TAPS_F0_6 ( Word16 )( 58 ) // (Word16) ceil( 0.6f * hBinRenConvModule->numTaps ) +#define NUM_TAPS_F0_5 ( Word16 )( 48 ) // (Word16) ceil( 0.5f * hBinRenConvModule->numTaps ) +#define NUM_TAPS_F0_4 ( Word16 )( 39 ) // (Word16) ceil( 0.4f * hBinRenConvModule->numTaps ) +#define NUM_TAPS_F0_3 ( Word16 )( 29 ) // (Word16) ceil( 0.3f * hBinRenConvModule->numTaps ) + /* Downmix table for sparse frequency domain reverberator*/ -const Word32 dmxmtx_table_fx[BINAURAL_CHANNELS][REVERB_INPUT_DOWNMIX_CHANNELS] = { +static const Word32 dmxmtx_table_fx[BINAURAL_CHANNELS][REVERB_INPUT_DOWNMIX_CHANNELS] = { // Q31 { 0x7fffffff, 0, 1518485623, 0x7fffffff, 0, 0x7fffffff, 0, 0x7fffffff, 0, 0x7fffffff, 0 }, { 0, 0x7fffffff, 1518485623, 0, 0x7fffffff, 0, 0x7fffffff, 0, 0x7fffffff, 0, 0x7fffffff }, }; + /*------------------------------------------------------------------------- * ivas_binRenderer_filterModule_fx() * * *-------------------------------------------------------------------------*/ + static void ivas_binRenderer_filterModule_fx( Word32 out_Conv_CLDFB_real[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : real part of Binaural signals Q6 */ Word32 out_Conv_CLDFB_imag[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : imag part of Binaural signals Q6 */ @@ -166,11 +171,13 @@ static void ivas_binRenderer_filterModule_fx( return; } + /*------------------------------------------------------------------------- * ivas_binRenderer_convModuleOpen() * * Open convolution module handle of fastconv binaural renderer *-------------------------------------------------------------------------*/ + static ivas_error ivas_binRenderer_convModuleOpen( BINAURAL_RENDERER_HANDLE hBinRenderer, const Word16 renderer_type, @@ -333,7 +340,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { IF( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) @@ -495,11 +501,13 @@ static ivas_error ivas_binRenderer_convModuleOpen( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------------* * ivas_init_binaural_hrtf() * * initialize memory for HrtfFastConv structure elements *-------------------------------------------------------------------------*/ + void ivas_init_binaural_hrtf_fx( HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ ) @@ -555,11 +563,13 @@ void ivas_init_binaural_hrtf_fx( return; } + /*-------------------------------------------------------------------------* * ivas_alloc_pppMem() * * Allocate memory for tripple pointer elements *-------------------------------------------------------------------------*/ + static ivas_error ivas_alloc_pppMem_fx( Word32 ****pppMem, /*Qx*/ const Word16 dim1, @@ -596,11 +606,13 @@ IF( allocate_init_flag == 0 ) return IVAS_ERR_OK; } + /*-------------------------------------------------------------------------* * ivas_allocate_binaural_hrtf() * * Allocate memory for HrtfFastConv structure elements *-------------------------------------------------------------------------*/ + ivas_error ivas_allocate_binaural_hrtf_fx( HRTFS_FASTCONV *HrtfFastConv, /* i/o: FASTCONV HRTF structure */ const AUDIO_CONFIG input_config, /* i : input audio configuration */ @@ -767,11 +779,13 @@ ivas_error ivas_allocate_binaural_hrtf_fx( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------------* * ivas_binaural_HRTF_open() * * *-------------------------------------------------------------------------*/ + static ivas_error ivas_binaural_hrtf_open_fx( HRTFS_FASTCONV_HANDLE *hHrtfFastConv, /* i : fastconv HRTF handle */ const AUDIO_CONFIG input_config, /* i : output configuration */ @@ -895,11 +909,14 @@ static ivas_error ivas_binaural_hrtf_open_fx( return IVAS_ERR_OK; } + + /*-------------------------------------------------------------------------* * ivas_binaural_obtain_DMX_fx() * * *-------------------------------------------------------------------------*/ + static void ivas_binaural_obtain_DMX_fx( const Word16 numTimeSlots, BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ @@ -1062,6 +1079,7 @@ static void ivas_binaural_obtain_DMX_fx( } } } + IF( NE_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) ) { *Q_in_out = sub( *Q_in_out, 1 ); @@ -1175,11 +1193,13 @@ ivas_error ivas_rend_openCldfbRend( return error; } + /*------------------------------------------------------------------------- * ivas_binRenderer_open() * * Open fastconv binaural renderer handle *-------------------------------------------------------------------------*/ + ivas_error ivas_binRenderer_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -1352,12 +1372,11 @@ ivas_error ivas_binRenderer_open_fx( { pRoomAcoustics = &( st_ivas->hRenderConfig->roomAcoustics ); } + IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, pRoomAcoustics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx, NULL ) ), IVAS_ERR_OK ) ) { return error; } - - /* initialize the dmx matrix */ } ELSE { @@ -1396,11 +1415,13 @@ ivas_error ivas_binRenderer_open_fx( return error; } + /*------------------------------------------------------------------------- * ivas_binRenderer_convModuleClose() * * Close convolution module handle of fastconv binaural renderer *------------------------------------------------------------------------*/ + static void ivas_binRenderer_convModuleClose_fx( BINAURAL_RENDERER_HANDLE *hBinRenderer, /* i/o: fastconv binaural renderer handle */ const Word16 num_poses /* i : number of poses */ @@ -1485,11 +1506,13 @@ static void ivas_binRenderer_convModuleClose_fx( return; } + /*------------------------------------------------------------------------- * ivas_binRenderer_close() * * Close fastconv binaural renderer memories *------------------------------------------------------------------------*/ + void ivas_binRenderer_close_fx( BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ ) @@ -1516,11 +1539,13 @@ void ivas_binRenderer_close_fx( return; } + /*------------------------------------------------------------------------- * ivas_free_pppHrtfMem() * * Free fastconv binaural renderer hrtf memories *------------------------------------------------------------------------*/ + static void ivas_free_pppHrtfMem_fx( Word32 ****ppppHRIR, /*Qx*/ const Word16 dim, @@ -1550,11 +1575,13 @@ static void ivas_free_pppHrtfMem_fx( return; } + /*------------------------------------------------------------------------- * ivas_binaural_hrtf_close() * * Close fastconv binaural renderer hrtf memories *------------------------------------------------------------------------*/ + void ivas_binaural_hrtf_close( HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i : fastconv HRTF handle */ ) @@ -1598,11 +1625,13 @@ void ivas_binaural_hrtf_close( return; } + /*-------------------------------------------------------------------------* * ivas_binaural_add_LFE() * * The functions adds the LFE to the left and right channels after binaural rendering *-------------------------------------------------------------------------*/ + void ivas_binaural_add_LFE_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word16 output_frame, /* i : length of input frame */ @@ -1665,6 +1694,7 @@ void ivas_binaural_add_LFE_fx( return; } + /*------------------------------------------------------------------------- * ivas_binRenderer_fx() * @@ -1883,6 +1913,7 @@ void ivas_binRenderer_fx( return; } + /*------------------------------------------------------------------------- * ivas_rend_CldfbMultiBinRendProcess() * @@ -1902,8 +1933,8 @@ void ivas_rend_CldfbMultiBinRendProcess( const Word16 Q_in /* i : LS signals exp */ ) { - int16_t slot_idx, ch_idx, idx, pose_idx, i, j; - int16_t sf_idx; + Word16 slot_idx, ch_idx, idx, pose_idx, i, j; + Word16 sf_idx; Word32 Cldfb_RealBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_sfIn[MAX_INPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 211b004b8..4f24be6c4 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -48,6 +48,7 @@ /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ + static ivas_error ivas_dirac_dec_config_internal_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const DIRAC_CONFIG_FLAG flag_config_inp /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ @@ -959,11 +960,14 @@ static ivas_error ivas_dirac_rend_config_fx( return error; } + + /*------------------------------------------------------------------------- * ivas_dirac_dec_config() * * Open or reconfigure decoder DirAC/MASA handle *-------------------------------------------------------------------------*/ + ivas_error ivas_dirac_dec_config_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const DIRAC_CONFIG_FLAG flag_config_inp /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ @@ -1194,15 +1198,16 @@ ivas_error ivas_dirac_dec_config_fx( } } - return error; } + /*------------------------------------------------------------------------- * ivas_dirac_dec_close() * * Close DirAC memories *------------------------------------------------------------------------*/ + void ivas_dirac_dec_close_fx( DIRAC_DEC_HANDLE *hDirAC_out ) { @@ -1228,11 +1233,14 @@ void ivas_dirac_dec_close_fx( return; } + + /*------------------------------------------------------------------------- * ivas_dirac_dec_read_BS_fx() * * Read DirAC parameters from the bitstream *------------------------------------------------------------------------*/ + void ivas_dirac_dec_read_BS_fx( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ Decoder_State *st, /* i/o: decoder state structure */ @@ -1289,6 +1297,7 @@ void ivas_dirac_dec_read_BS_fx( *nb_bits = add( *nb_bits, ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), nchan_transport, NULL, SBA_FORMAT ) ); move16(); + FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[1].azimuth_fx[0]; @@ -1416,11 +1425,14 @@ void ivas_dirac_dec_read_BS_fx( return; } + + /*-----------------------------------------------------------------------* * ivas_qmetadata_to_dirac() * * Copy qmetedata to DirAC parameters for rendering *-----------------------------------------------------------------------*/ + void ivas_qmetadata_to_dirac_fx( const IVAS_QMETADATA_HANDLE hQMetaData, /* i : frame of MASA q_metadata */ DIRAC_DEC_HANDLE hDirAC, /* i : DirAC decoder structure */ @@ -1848,7 +1860,6 @@ void ivas_qmetadata_to_dirac_fx( move16(); } - hSpatParamRendCom->energy_ratio1_fx[tmp_write_idx_band][b] = q_direction->band_data[qBand_idx].energy_ratio_fx[0]; move32(); hSpatParamRendCom->diffuseness_vector_fx[tmp_write_idx_band][b] = diffuseness_fx; @@ -1925,97 +1936,16 @@ void ivas_qmetadata_to_dirac_fx( /* update buffer write index */ hSpatParamRendCom->dirac_bs_md_write_idx = add( hSpatParamRendCom->dirac_bs_md_write_idx, MAX_PARAM_SPATIAL_SUBFRAMES ) % hSpatParamRendCom->dirac_md_buffer_length; move16(); + return; } + + /*------------------------------------------------------------------------- * ivas_dirac_dec_set_md_map() * * Set metadata index mapping for DirAC *------------------------------------------------------------------------*/ -void ivas_dirac_dec_set_md_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 nCldfbTs /* i : number of CLDFB time slots */ -) -{ - Word16 num_slots_in_subfr; - DIRAC_DEC_HANDLE hDirAC; - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - - hDirAC = st_ivas->hDirAC; - hSpatParamRendCom = st_ivas->hSpatParamRendCom; - - /* adapt subframes */ - hSpatParamRendCom->num_slots = nCldfbTs; - move16(); - hSpatParamRendCom->slots_rendered = 0; - move16(); - num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; - move16(); - hSpatParamRendCom->subframes_rendered = 0; - move16(); - - ivas_jbm_dec_get_adapted_subframes( nCldfbTs, hSpatParamRendCom->subframe_nbslots, &hSpatParamRendCom->nb_subframes ); - - /* copy also to tc buffer */ - /* only for non-combined formats and combinded formats w/o discrete objects */ - test(); - test(); - test(); - IF( ( NE_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) || NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) && !( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) ) - { - st_ivas->hTcBuffer->nb_subframes = hSpatParamRendCom->nb_subframes; - move16(); - Copy( hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, hSpatParamRendCom->nb_subframes ); - } - - /* set mapping according to dirac_read_idx */ - - set16_fx( hSpatParamRendCom->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); - - test(); - test(); - IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) - { - ivas_jbm_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); - } - ELSE IF( hDirAC == NULL || hDirAC->hConfig == NULL || hDirAC->hConfig->dec_param_estim == 0 ) - { - ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, 0, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); - } - ELSE - { - ivas_jbm_dec_get_md_map( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbTs, num_slots_in_subfr, hSpatParamRendCom->dirac_read_idx, hSpatParamRendCom->dirac_md_buffer_length, hSpatParamRendCom->render_to_md_map ); - } - - test(); - test(); - IF( hDirAC == NULL || hDirAC->hConfig == NULL || hDirAC->hConfig->dec_param_estim == 0 ) - { - Word64 tmp_fx; - Word16 sf_idx, slot_idx, slot_idx_abs; - Word32 quo, rem; - - slot_idx_abs = 0; - move16(); - FOR( sf_idx = 0; sf_idx < hSpatParamRendCom->nb_subframes; sf_idx++ ) - { - tmp_fx = 0; - move64(); - FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[sf_idx]; slot_idx++ ) - { - tmp_fx = W_add_nosat( tmp_fx, W_deposit32_l( L_deposit_l( hSpatParamRendCom->render_to_md_map[slot_idx_abs] ) ) ); - slot_idx_abs = add( slot_idx_abs, 1 ); - } - iDiv_and_mod_32( W_shl_sat_l( tmp_fx, 16 ), hSpatParamRendCom->subframe_nbslots[sf_idx], &quo, &rem, 0 ); - hSpatParamRendCom->render_to_md_map[sf_idx] = add( round_fx( quo ), hSpatParamRendCom->dirac_read_idx ) % hSpatParamRendCom->dirac_md_buffer_length; - move16(); - } - - set16_fx( &hSpatParamRendCom->render_to_md_map[hSpatParamRendCom->nb_subframes], 0, sub( MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME, hSpatParamRendCom->nb_subframes ) ); - } - - return; -} void ivas_dirac_dec_set_md_map_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -2054,7 +1984,6 @@ void ivas_dirac_dec_set_md_map_fx( } /* set mapping according to dirac_read_idx */ - set16_fx( hSpatParamRendCom->render_to_md_map, 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME ); test(); @@ -2126,6 +2055,8 @@ void ivas_dirac_dec_set_md_map_fx( return; } + + /*------------------------------------------------------------------------- * ivas_dirac_dec_render_fx() * @@ -2306,7 +2237,6 @@ void ivas_dirac_dec_render_sf_fx( } } - hDirAC = st_ivas->hDirAC; hDirACRend = st_ivas->hDirACRend; hSpatParamRendCom = st_ivas->hSpatParamRendCom; @@ -2401,7 +2331,6 @@ void ivas_dirac_dec_render_sf_fx( move16(); } - test(); test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) @@ -3051,12 +2980,13 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q[0]; move16(); - computeDiffuseness_fixed( hDirACRend->buffer_intensity_real_fx, hDirACRend->buffer_energy_fx, num_freq_bands, hSpatParamRendCom->diffuseness_vector_fx[md_idx], hDirACRend->q_buffer_intensity_real, hDirACRend->q_buffer_energy, &hSpatParamRendCom->q_diffuseness_vector ); + computeDiffuseness_fx( hDirACRend->buffer_intensity_real_fx, hDirACRend->buffer_energy_fx, num_freq_bands, hSpatParamRendCom->diffuseness_vector_fx[md_idx], hDirACRend->q_buffer_intensity_real, hDirACRend->q_buffer_energy, &hSpatParamRendCom->q_diffuseness_vector ); } /*-----------------------------------------------------------------* * frequency domain decorrelation *-----------------------------------------------------------------*/ + IF( EQ_16( hDirACRend->proto_signal_decorr_on, 1 ) ) { /* decorrelate prototype frame */ @@ -3077,7 +3007,7 @@ void ivas_dirac_dec_render_sf_fx( hDirACRend->h_freq_domain_decorr_ap_params, hDirACRend->h_freq_domain_decorr_ap_state ); - v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); + v_multc_fx( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); v_add_fixed_no_hdrm( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ p_onset_filter_fx = onset_filter_subframe_fx; @@ -3133,6 +3063,7 @@ void ivas_dirac_dec_render_sf_fx( /*-----------------------------------------------------------------* * output synthesis *-----------------------------------------------------------------*/ + test(); IF( ( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) || EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) ) { @@ -3954,7 +3885,6 @@ void ivas_dirac_dec_render_sf_fx( { FOR( ch = 0; ch < outchannels; ch++ ) { - test(); test(); IF( ( hDirACRend->hOutSetup.num_lfe > 0 && ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) ) @@ -4061,7 +3991,6 @@ void ivas_dirac_dec_render_sf_fx( hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 ); move16(); - IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev; diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index 954dd5f72..0f6ea7f1e 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ - #include "basop_util.h" #include "enh32.h" #include @@ -552,11 +551,11 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( move16(); } - v_multc_fixed( mixing_matrix_fx[param_band_idx], L_deposit_h( hParamMC->h_output_synthesis_params.interpolator_fx[slot_idx_tot] ), mixing_matrix_smooth_fx, imult1616( nY, nX ) ); + v_multc_fx( mixing_matrix_fx[param_band_idx], L_deposit_h( hParamMC->h_output_synthesis_params.interpolator_fx[slot_idx_tot] ), mixing_matrix_smooth_fx, imult1616( nY, nX ) ); mixing_matrix_smooth_e = mixing_matrix_e[param_band_idx]; // interpolator is W16 move16(); - v_multc_fixed( h_synthesis_state.mixing_matrix_old_fx[param_band_idx], L_sub( ONE_IN_Q31, L_deposit_h( hParamMC->h_output_synthesis_params.interpolator_fx[slot_idx_tot] ) ), mixing_matrix_buffer_fx, imult1616( nY, nX ) ); + v_multc_fx( h_synthesis_state.mixing_matrix_old_fx[param_band_idx], L_sub( ONE_IN_Q31, L_deposit_h( hParamMC->h_output_synthesis_params.interpolator_fx[slot_idx_tot] ) ), mixing_matrix_buffer_fx, imult1616( nY, nX ) ); mixing_matrix_buffer_e = h_synthesis_state.mixing_matrix_old_exp[param_band_idx]; // interpolator is W16 move16(); @@ -566,12 +565,12 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( { /* residual mixing matrix interpolation*/ - v_multc_fixed( mixing_matrix_res_fx[param_band_idx], L_deposit_h( hParamMC->h_output_synthesis_params.interpolator_fx[slot_idx_tot] ), mixing_matrix_res_smooth_fx, imult1616( nY, nY ) ); + v_multc_fx( mixing_matrix_res_fx[param_band_idx], L_deposit_h( hParamMC->h_output_synthesis_params.interpolator_fx[slot_idx_tot] ), mixing_matrix_res_smooth_fx, imult1616( nY, nY ) ); mixing_matrix_res_smooth_e = mixing_matrix_res_e[param_band_idx]; // interpolator is W16 move16(); set_zero_fx( mixing_matrix_buffer_fx, imult1616( nY, nY ) ); - v_multc_fixed( h_synthesis_state.mixing_matrix_res_old_fx[param_band_idx], L_sub( ONE_IN_Q31, L_deposit_h( hParamMC->h_output_synthesis_params.interpolator_fx[slot_idx_tot] ) ), mixing_matrix_buffer_fx, imult1616( nY, nY ) ); + v_multc_fx( h_synthesis_state.mixing_matrix_res_old_fx[param_band_idx], L_sub( ONE_IN_Q31, L_deposit_h( hParamMC->h_output_synthesis_params.interpolator_fx[slot_idx_tot] ) ), mixing_matrix_buffer_fx, imult1616( nY, nY ) ); mixing_matrix_buffer_e = h_synthesis_state.mixing_matrix_res_old_exp[param_band_idx]; // interpolator is W16 move16(); diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 5a87800f7..3c925d35a 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -387,7 +387,7 @@ ivas_error ivas_dec_get_format_fx( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "wrong MC configuration signalled!" ); } - st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), st_ivas->hDecoderConfig->ivas_total_brate ); + st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), ivas_total_brate ); st_ivas->transport_config = signaled_config; move16(); } @@ -649,6 +649,7 @@ ivas_error ivas_dec_setup( st_ivas->nchan_transport = 1; move16(); } + /* this should be non-zero if original input format was MASA_ISM_FORMAT */ st_ivas->nchan_ism = add( st_ivas->bit_stream[L_sub( res_dec, 3 )], shl( st_ivas->bit_stream[L_sub( res_dec, 2 )], 1 ) ); @@ -789,9 +790,7 @@ ivas_error ivas_dec_setup( test(); IF( st_ivas->ini_frame > 0 && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - Word16 n; - - n = add( st_ivas->nchan_transport, st_ivas->nchan_ism ); + Word16 n = add( st_ivas->nchan_transport, st_ivas->nchan_ism ); st_ivas->nCPE = shr_r( n, 1 ); } } @@ -1269,7 +1268,6 @@ static ivas_error ivas_read_format( *-------------------------------------------------------------------*/ /*! r: number of channels to be synthesised */ - Word16 getNumChanSynthesis( Decoder_Struct *st_ivas /* i : IVAS decoder structure */ ) @@ -1305,6 +1303,7 @@ Word16 getNumChanSynthesis( return n; } + /*-------------------------------------------------------------------* * copy_decoder_config() * @@ -1404,12 +1403,13 @@ ivas_error ivas_init_decoder_front( { return error; } - error = ivas_orient_trk_SetTrackingType_fx( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking ); - IF( NE_32( ( error ), IVAS_ERR_OK ) ) + + IF( NE_32( ( error = ivas_orient_trk_SetTrackingType_fx( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking ) ), IVAS_ERR_OK ) ) { return error; } } + /*-------------------------------------------------------------------* * Allocate and initialize external orientation handle *--------------------------------------------------------------------*/ @@ -1425,6 +1425,7 @@ ivas_error ivas_init_decoder_front( /*-------------------------------------------------------------------* * Allocate and initialize combined orientation handle *--------------------------------------------------------------------*/ + test(); IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) { @@ -1469,6 +1470,7 @@ ivas_error ivas_init_decoder_front( /*-------------------------------------------------------------------* * Allocate and initialize Binaural Renderer configuration handle *--------------------------------------------------------------------*/ + test(); test(); IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || @@ -1494,6 +1496,7 @@ ivas_error ivas_init_decoder_front( * * Initialize IVAS decoder state structure *-------------------------------------------------------------------*/ + ivas_error ivas_init_decoder_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -1832,7 +1835,7 @@ ivas_error ivas_init_decoder_fx( test(); test(); test(); - IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && !( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) ) ) + IF( NE_32( output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_MONO ) && !( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) ) ) { IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) ) { @@ -1857,7 +1860,7 @@ ivas_error ivas_init_decoder_fx( move16(); } - ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ), + ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, extract_l( Mpy_32_32_r( output_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); @@ -1985,6 +1988,7 @@ ivas_error ivas_init_decoder_fx( st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); move16(); + IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) ) { return error; @@ -2013,7 +2017,7 @@ ivas_error ivas_init_decoder_fx( test(); test(); - IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) ) + IF( NE_32( output_config, IVAS_AUDIO_CONFIG_FOA ) && NE_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_MONO ) ) { IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) ) { @@ -2029,6 +2033,7 @@ ivas_error ivas_init_decoder_fx( st_ivas->hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); move16(); + IF( ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) ) { st_ivas->hSpar->enc_param_start_band = 0; @@ -2038,7 +2043,7 @@ ivas_error ivas_init_decoder_fx( move16(); } - ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ), + ivas_dirac_config_bands_fx( band_grouping, IVAS_MAX_NUM_BANDS, extract_l( Mpy_32_32_r( output_Fs, INV_CLDFB_BANDWIDTH_Q31 ) ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 ); } @@ -2059,9 +2064,7 @@ ivas_error ivas_init_decoder_fx( st_ivas->nCPE_old = st_ivas->nCPE; move16(); { - Word16 n_all; - - n_all = add( st_ivas->nchan_transport, st_ivas->nchan_ism ); + Word16 n_all = add( st_ivas->nchan_transport, st_ivas->nchan_ism ); st_ivas->nCPE = shr( add( n_all, 1 ), 1 ); } st_ivas->element_mode_init = IVAS_CPE_MDCT; @@ -2301,6 +2304,7 @@ ivas_error ivas_init_decoder_fx( st_ivas->element_mode_init = IVAS_CPE_MDCT; move16(); + FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { Word32 res_dec, res_frac; @@ -2374,13 +2378,13 @@ ivas_error ivas_init_decoder_fx( } IF( NE_32( ( error = ivas_masa_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) - { return error; } st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); move16(); + test(); IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) ) { @@ -2389,6 +2393,7 @@ ivas_error ivas_init_decoder_fx( return error; } } + test(); test(); IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.separateChannelEnabled && !st_ivas->hLsSetupCustom->separate_ch_found ) @@ -2422,7 +2427,6 @@ ivas_error ivas_init_decoder_fx( } } - ivas_mcmasa_split_brate_fx( st_ivas->hOutSetup.separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) @@ -2439,6 +2443,7 @@ ivas_error ivas_init_decoder_fx( { st_ivas->element_mode_init = IVAS_CPE_MDCT; /* element_mode_init was IVAS_SCE for SCE initialization */ move16(); + IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, brate_cpe ) ), IVAS_ERR_OK ) ) { return error; @@ -2508,6 +2513,7 @@ ivas_error ivas_init_decoder_fx( /*-------------------------------------------------------------------* * Allocate and initialize rendering handles *--------------------------------------------------------------------*/ + test(); test(); test(); @@ -2567,17 +2573,15 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - if ( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) + if ( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, output_Fs ) ), IVAS_ERR_OK ) ) { return error; } } - granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); - + granularity = NS2SA_FX2( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ), IVAS_ERR_OK ) ) { return error; @@ -2602,7 +2606,7 @@ ivas_error ivas_init_decoder_fx( test(); test(); test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && EQ_32( st_ivas->ivas_format, MC_FORMAT ) && ( hDecoderConfig->Opt_Headrotation || hDecoderConfig->Opt_ExternalOrientation ) ) { IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), st_ivas->hIntSetup.ls_azimuth_fx, st_ivas->hIntSetup.ls_elevation_fx, st_ivas->hIntSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) { @@ -2610,9 +2614,15 @@ ivas_error ivas_init_decoder_fx( } } - IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), - IVAS_ERR_OK ) ) + Word16 num_poses = 1; + move16(); + if ( st_ivas->hSplitBinRend != NULL ) + { + num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; + move16(); + } + + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, output_Fs, num_poses ) ), IVAS_ERR_OK ) ) { return error; } @@ -2633,7 +2643,7 @@ ivas_error ivas_init_decoder_fx( } ELSE { - granularity = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); + granularity = NS2SA_FX2( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); @@ -2680,7 +2690,7 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, output_Fs ) ), IVAS_ERR_OK ) ) { return error; } @@ -2799,7 +2809,7 @@ ivas_error ivas_init_decoder_fx( } IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { - IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, output_Fs ) ), IVAS_ERR_OK ) ) { return error; } @@ -2841,7 +2851,7 @@ ivas_error ivas_init_decoder_fx( test(); test(); test(); - IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !st_ivas->sba_dirac_stereo_flag && NE_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) + IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !st_ivas->sba_dirac_stereo_flag && NE_16( hDecoderConfig->nchan_out, 1 ) ) { Word16 Q_cldfbSynDec = Q11; move16(); @@ -2883,7 +2893,7 @@ ivas_error ivas_init_decoder_fx( { IF( st_ivas->hBinRenderer->render_lfe ) { - IF( NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + IF( NE_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { /* Account for filterbank delay */ delay_ns = L_add( delay_ns, IVAS_FB_DEC_DELAY_NS ); @@ -2930,7 +2940,7 @@ ivas_error ivas_init_decoder_fx( /* no module has yet open the TC buffer, open a default one */ n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); - IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ) ) ), IVAS_ERR_OK ) ) { return error; } @@ -2940,7 +2950,7 @@ ivas_error ivas_init_decoder_fx( test(); IF( ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && st_ivas->hDecoderConfig->Opt_tsm ) { - IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { IF( NE_32( ( error = ivas_jbm_dec_metadata_open( st_ivas ) ), IVAS_ERR_OK ) ) { @@ -2950,15 +2960,15 @@ ivas_error ivas_init_decoder_fx( } /*-----------------------------------------------------------------* - * Allocate floating-point output audio buffers + * Allocate output audio buffers *-----------------------------------------------------------------*/ - FOR( n = 0; n < ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) + FOR( n = 0; n < ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); n++ ) { /* note: these are intra-frame heap memories */ IF( ( st_ivas->p_output_fx[n] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output audio buffer!\n" ) ); } set32_fx( st_ivas->p_output_fx[n], 0, 48000 / FRAMES_PER_SEC ); } @@ -3119,6 +3129,7 @@ void destroy_core_dec_fx( return; } + /*------------------------------------------------------------------------- * ivas_initialize_handles_dec() * @@ -3214,7 +3225,7 @@ void ivas_initialize_handles_dec( st_ivas->hTcBuffer = NULL; st_ivas->hJbmMetadata = NULL; - /* floating-point output audio buffers */ + /* output audio buffers */ FOR( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { st_ivas->p_output_fx[i] = NULL; @@ -3367,8 +3378,8 @@ void ivas_destroy_dec_fx( ivas_reverb_close( &st_ivas->hReverb ); /* LS config converter handle */ - ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); + /* Custom LS configuration handle */ IF( st_ivas->hLsSetupCustom != NULL ) { @@ -3440,10 +3451,9 @@ void ivas_destroy_dec_fx( st_ivas->hJbmMetadata = NULL; } - /* floating-point output audio buffers */ + /* output audio buffers */ FOR( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { - IF( st_ivas->p_output_fx[i] != NULL ) { free( st_ivas->p_output_fx[i] ); @@ -3472,6 +3482,7 @@ void ivas_init_dec_get_num_cldfb_instances_fx( ) { IVAS_FORMAT ivas_format; + *numCldfbAnalyses = st_ivas->nchan_transport; move16(); *numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out; @@ -3761,6 +3772,7 @@ static ivas_error doSanityChecks_IVAS( move32(); output_config = st_ivas->hDecoderConfig->output_config; move32(); + /*-----------------------------------------------------------------* * Sanity checks *-----------------------------------------------------------------*/ diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 79275105a..925dbd0e7 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -308,16 +308,14 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } /*-----------------------------------------------------------------* - * floating-point output audio buffers + * output audio buffers *-----------------------------------------------------------------*/ - { - nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); + nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); - IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) - { - return error; - } + IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) + { + return error; } /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index d5943a90c..8774fb947 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -195,8 +195,8 @@ void ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( } exp = sub( 31, Q_temp ); fac_fx = Sqrt32( temp, &exp ); - v_multc_fixed( hFdCngCom->cngNoiseLevel, fac_fx, hFdCngCom->cngNoiseLevel, cng_noise_level_len ); /*Resultant Q of cngNoiseLevel is Q_cngNoiseLevel for ch*/ - scale_sig32( hFdCngCom->cngNoiseLevel, cng_noise_level_len, exp ); /*Restoring Q of hFdCngCom->cngNoiseLevel to Q_cngNoiseLevel */ + v_multc_fx( hFdCngCom->cngNoiseLevel, fac_fx, hFdCngCom->cngNoiseLevel, cng_noise_level_len ); /*Resultant Q of cngNoiseLevel is Q_cngNoiseLevel for ch*/ + scale_sig32( hFdCngCom->cngNoiseLevel, cng_noise_level_len, exp ); /*Restoring Q of hFdCngCom->cngNoiseLevel to Q_cngNoiseLevel */ } } } diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 1b7435305..fbfa7f9aa 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -926,7 +926,7 @@ void ivas_ism_dec_digest_tc_fx( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_STEREO ) || ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) ) { - int16_t i; + Word16 i; Word32 azimuth_fx, elevation_fx; /* we have a full frame interpolator, adapt it */ diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index a0fa5a3d5..ffe7a2cd8 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -72,7 +72,7 @@ ivas_error ivas_ism_renderer_open_fx( test(); test(); IF( st_ivas->hIntSetup.is_loudspeaker_setup && - st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && + NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hIntSetup.ls_azimuth_fx != NULL && st_ivas->hIntSetup.ls_elevation_fx != NULL && st_ivas->hEFAPdata == NULL ) { @@ -132,6 +132,7 @@ ivas_error ivas_ism_renderer_open_fx( * * Close struct for object rendering. *-------------------------------------------------------------------------*/ + void ivas_ism_renderer_close( ISM_RENDERER_HANDLE *hIsmRendererData /* i/o: ISM renderer handle */ ) @@ -160,6 +161,7 @@ void ivas_ism_renderer_close( * * Object rendering process *-------------------------------------------------------------------------*/ + void ivas_ism_render_sf_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const RENDERER_TYPE renderer_type, /* i : active renderer type */ @@ -241,10 +243,9 @@ void ivas_ism_render_sf_fx( set32_fx( output_fx[i], 0, n_samples_to_render ); } - FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { - int16_t n_samples_in_subframe; + Word16 n_samples_in_subframe; n_samples_in_subframe = st_ivas->hTcBuffer->n_samples_granularity * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]; test(); @@ -407,6 +408,7 @@ void ivas_ism_get_stereo_gains_fx( return; } + /*-------------------------------------------------------------------------* * ivas_omasa_separate_object_renderer_open() * diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index b8b234d8a..ab7562342 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2790,6 +2790,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { return error; } + IF( NE_32( ( error = getAudioConfigNumChannels( st_ivas->hOutSetup.output_config, &nchan_out ) ), IVAS_ERR_OK ) ) { return error; @@ -2812,6 +2813,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( { return error; } + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc_fx, p_output_fx ); } ELSE diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 29a64da58..74d8de662 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -315,6 +315,7 @@ static void ivas_create_lfe_lpf_dec_fx( return; } + /*-----------------------------------------------------------------------------------------* * Function ivas_lfe_dec_fx() * @@ -401,6 +402,7 @@ void ivas_lfe_dec_fx( j = add( j, shr( output_frame, 5 ) ); } q_out = Q9; + move16(); } IF( hLFE->filter_state.order > 0 ) @@ -488,7 +490,7 @@ ivas_error ivas_create_lfe_dec_fx( low_pass_delay_dec_out = 0; // Q15 move16(); - if ( delay_ns > ivas_lfe_lpf_delay_ns[IVAS_FILTER_ORDER_4 - 3] ) + IF( GT_32( delay_ns, ivas_lfe_lpf_delay_ns[IVAS_FILTER_ORDER_4 - 3] ) ) { filt_order = 4; low_pass_delay_dec_out = ivas_lfe_lpf_delay_Q15[IVAS_FILTER_ORDER_4 - 3]; diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 087ff9ae6..a81b7d73b 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -185,11 +185,13 @@ ivas_error ivas_masa_decode_fx( IF( NE_32( ivas_format, MC_FORMAT ) || NE_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { Word16 bits_per_frame = extract_l( Mpy_32_32( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + IF( EQ_32( ivas_format, MASA_FORMAT ) ) { /* re-read the number of objects, needed in case of bad frame */ st_ivas->nchan_ism = sub( 5, add( st_ivas->bit_stream[bits_per_frame - 3], shl( st_ivas->bit_stream[bits_per_frame - 2], 1 ) ) ); } + test(); IF( EQ_32( ivas_format, MASA_FORMAT ) && NE_16( st_ivas->nchan_ism, 5 ) ) { @@ -213,6 +215,7 @@ ivas_error ivas_masa_decode_fx( move16(); move16(); *nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS ); + /* read number of directions */ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); @@ -314,6 +317,7 @@ ivas_error ivas_masa_decode_fx( move16(); st_ivas->hIsmMetaData[0]->ism_md_lowrate_flag = 0; move16(); + IF( EQ_16( st_ivas->hIsmMetaData[0]->ism_imp, ISM_NO_META ) ) { /* read flags */ @@ -349,6 +353,7 @@ ivas_error ivas_masa_decode_fx( move16(); st_ivas->hIsmMetaData[ch]->ism_md_lowrate_flag = 0; move16(); + IF( EQ_16( st_ivas->hIsmMetaData[ch]->ism_imp, ISM_NO_META ) ) { /* read flags */ @@ -362,8 +367,10 @@ ivas_error ivas_masa_decode_fx( move16(); } } + st_ivas->flag_omasa_brate = 0; move16(); + test(); IF( GE_16( st_ivas->nchan_ism, 3 ) && EQ_32( ivas_total_brate, IVAS_128k ) ) { @@ -374,7 +381,6 @@ ivas_error ivas_masa_decode_fx( } } } - byteBuffer = st->bit_stream[st->next_bit_pos]; move16(); st->next_bit_pos = sub( st->next_bit_pos, 1 ); @@ -828,6 +834,7 @@ ivas_error ivas_masa_dec_open_fx( /* these are not needed -> clean. EXT metafile writer in OMASA needs only the number of ISMs and writes default null-data */ ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); } + test(); test(); test(); @@ -1177,8 +1184,8 @@ void ivas_masa_prerender_fx( test(); IF( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) || EQ_32( st_ivas->renderer_type, RENDERER_DISABLE ) ) { - v_multc_fixed( output_fx[0], SQRT2_FIXED, output_fx[0], output_frame ); /* q + 30 - 31 = q - 1*/ /* Gain transport signal when transmitting mono with cpe in order to match loudness */ - *q_shift = -1; /* Q has decreased by 1. */ + v_multc_fx( output_fx[0], SQRT2_FIXED, output_fx[0], output_frame ); /* q + 30 - 31 = q - 1*/ /* Gain transport signal when transmitting mono with cpe in order to match loudness */ + *q_shift = -1; /* Q has decreased by 1. */ move16(); } } diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 48b6b8c75..98bf0f1f6 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -734,7 +734,7 @@ static void ivas_mc_paramupmix_dec_sf( Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - int16_t slot_index_start; + Word16 slot_index_start; hMCParamUpmix = st_ivas->hMCParamUpmix; assert( hMCParamUpmix ); diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 4a06299a9..7edb39868 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -199,12 +199,9 @@ ivas_error ivas_mct_dec_fx( move16(); } - /* MCT core decoder */ Word16 q_x[MAX_TRANSPORT_CHANNELS]; ivas_mct_core_dec( hMCT, st_ivas->hCPE, nCPE, output_fx, q_x ); - // Scaling output buffer back to Q11 - /* for sba to stereo output disable any further processing for TCs > 2 as it is not needed*/ test(); @@ -238,7 +235,6 @@ ivas_error ivas_mct_dec_fx( ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, 20 ); } - test(); test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_MC ) ) @@ -330,7 +326,6 @@ ivas_error ivas_mct_dec_fx( } } - /*----------------------------------------------------------------* * CoreCoder Post-processing and updates *----------------------------------------------------------------*/ @@ -376,6 +371,7 @@ ivas_error ivas_mct_dec_fx( return error; } Copy_Scale_sig_16_32_no_sat( synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_frame, sub( Q11, Q_synth ) ); // Q11 + /* Save synthesis for HQ FEC */ Word32 output_fx_[L_FRAME48k]; Copy32( output_fx[( cpe_id * CPE_CHANNELS ) + n], output_fx_, L_FRAME48k ); // Q11 @@ -438,6 +434,7 @@ ivas_error ivas_mct_dec_fx( * * Create, allocate and initialize IVAS decoder MCT handle *-------------------------------------------------------------------------*/ + ivas_error create_mct_dec_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -530,6 +527,7 @@ ivas_error create_mct_dec_fx( hMCT->hBlockData[n]->ch2 = 0; move16(); move16(); + /*-----------------------------------------------------------------* * MDCT stereo initialization *-----------------------------------------------------------------*/ @@ -571,6 +569,7 @@ ivas_error create_mct_dec_fx( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * mct_dec_reconfigure() * @@ -819,7 +818,7 @@ ivas_error ivas_mc_dec_config_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 idx, /* i : LS config. index */ UWord16 *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ - Word16 *data /* o : output synthesis signal */ + Word16 *data /* o : output synthesis signal */ ) { AUDIO_CONFIG signaled_config; @@ -889,7 +888,7 @@ ivas_error ivas_mc_dec_config_fx( *-------------------------------------------------------------------------*/ static ivas_error ivas_mc_dec_reconfig_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ UWord16 *nSamplesRendered, /* o : number of samples flushed from the last frame (JBM) */ Word16 *data /* o : output synthesis signal */ ) @@ -965,7 +964,6 @@ static ivas_error ivas_mc_dec_reconfig_fx( ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); /* transfer subframe info from DirAC or ParamMC to central tc buffer */ - if ( st_ivas->hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER ) { test(); @@ -1324,6 +1322,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( /*-----------------------------------------------------------------* * re-configure HP20 memories *-----------------------------------------------------------------*/ + IF( NE_32( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ), IVAS_ERR_OK ) ) { return error; @@ -1390,6 +1389,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( IF( st_ivas->hBinRenderer != NULL && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { ivas_binRenderer_close_fx( &st_ivas->hBinRenderer ); + test(); IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) { @@ -1478,6 +1478,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( } } } + /*-----------------------------------------------------------------* * CLDFB instances *-----------------------------------------------------------------*/ @@ -1490,6 +1491,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( /*-----------------------------------------------------------------* * Allocate the LFE handle that is coded separately after the allocation of the core coders *-----------------------------------------------------------------*/ + test(); IF( ( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) ) { @@ -1638,9 +1640,8 @@ static ivas_error ivas_mc_dec_reconfig_fx( } } - /*-----------------------------------------------------------------* - * floating-point output audio buffers + * output audio buffers *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); @@ -1649,5 +1650,6 @@ static ivas_error ivas_mc_dec_reconfig_fx( { return error; } + return error; } diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c index 299a09a93..c5e884f46 100644 --- a/lib_dec/ivas_mct_dec_mct_fx_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c @@ -205,7 +205,7 @@ static void applyGlobalILD_fx( qratio = L_shl( qratio, q_qratio ); FOR( k = 0; k < nSubframes; k++ ) { - v_multc_fixed( x[ch][k], qratio, x[ch][k], L_subframeTCX ); // Qx - 5 + q_qratio + v_multc_fx( x[ch][k], qratio, x[ch][k], L_subframeTCX ); // Qx - 5 + q_qratio scale_sig32( x[ch][k], L_subframeTCX, sub( 5, q_qratio ) ); } } diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 4e080bb2f..11359685a 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1678,7 +1678,7 @@ void ivas_mdct_core_tns_ns_fx( q_x = add( q_x, 1 ); } - v_multc_fixed( x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf_fx[FDNS_NPTS - 1], x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sub( L_spec[ch], st->hTcxCfg->psychParamsCurrent->nBins ) ); + v_multc_fx( x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf_fx[FDNS_NPTS - 1], x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sub( L_spec[ch], st->hTcxCfg->psychParamsCurrent->nBins ) ); q_2 = sub( add( q_x, q_sns_int_scf ), 31 ); Scale_sig32( &x_fx[ch][k][0], st->hTcxCfg->psychParamsCurrent->nBins, sub( q_2, q_x ) ); diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 848f457eb..b9391ba3f 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -329,8 +329,8 @@ void ivas_apply_non_diegetic_panning_fx( pan_left_fx = add( mult( non_diegetic_pan_gain_fx, 16384 ), 16384 ); // 0.5.Q15 = 16384 pan_right_fx = sub( 32767, pan_left_fx ); - v_multc_fixed( input_f_fx, L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame ); - v_multc_fixed( input_f_fx, L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame ); + v_multc_fx( input_f_fx, L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame ); + v_multc_fx( input_f_fx, L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame ); return; } diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 914dde94e..c5e87587e 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -333,6 +333,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( { continue; } + IF( ( error = ivas_td_binaural_open_unwrap_fx( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, st_ivas->nchan_transport, diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 439958731..0ec1f4be0 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -821,7 +821,7 @@ ivas_error ivas_omasa_dec_config_fx( } /*-----------------------------------------------------------------* - * floating-point output audio buffers + * output audio buffers *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 3aae05179..efad2c471 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -228,6 +228,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( } } } + return IVAS_ERR_OK; } @@ -292,7 +293,7 @@ ivas_error ivas_osba_render_sf_fx( if ( !st_ivas->hDecoderConfig->Opt_tsm ) { - int16_t tc_offset; + Word16 tc_offset; tc_offset = st_ivas->hTcBuffer->n_samples_rendered; for ( n = 0; n < st_ivas->nchan_ism; n++ ) { @@ -339,10 +340,6 @@ void ivas_osba_stereo_add_channels_fx( { Word16 n; -#if 0 - IF ( ism_mode == ISM_SBA_MODE_DISC ) - { -#endif IF( NE_16( gain, ONE_IN_Q11 ) ) { assert( 0 && "Object editing is not implemented in the BASOP code!" ); @@ -354,16 +351,6 @@ void ivas_osba_stereo_add_channels_fx( v_add_fixed_no_hdrm( output_fx[n], tc_fx[n + nchan_ism], output_fx[n], n_samples_to_render ); } } -#if 0 - } - ELSE - { - FOR( n = 0; n < nchan_out; n++ ) - { - v_add_fixed_no_hdrm( output_fx[n], tc_fx[n + nchan_ism], output_fx[n], n_samples_to_render ); - } - } -#endif return; } diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index 40da176d8..4bbcc9b0a 100644 --- a/lib_dec/ivas_qmetadata_dec_fx.c +++ b/lib_dec/ivas_qmetadata_dec_fx.c @@ -1190,7 +1190,7 @@ Word16 ivas_qmetadata_dec_sid_decode( IF( EQ_16( ivas_format, SBA_FORMAT ) ) { sba_spar_bitlen = ivas_sba_spar_sid_bitlen_fx( nchan_transport ); - metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS - SBA_ORDER_BITS - SBA_PLANAR_BITS - 1; /* -1 for inactive mode header bit*/ + metadata_sid_bits = (Word16) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS - SBA_ORDER_BITS - SBA_PLANAR_BITS - 1; /* -1 for inactive mode header bit*/ metadata_sid_bits = sub( metadata_sid_bits, sba_spar_bitlen ); } ELSE diff --git a/lib_dec/ivas_rom_dec_fx.c b/lib_dec/ivas_rom_dec_fx.c index 8b2a2d27e..ae0ccf31c 100644 --- a/lib_dec/ivas_rom_dec_fx.c +++ b/lib_dec/ivas_rom_dec_fx.c @@ -357,8 +357,6 @@ const UWord16 * const sym_freq_ECSQ_tab_abs_lsbs[1 + 4] = * DirAC ROM tables *----------------------------------------------------------------------------------*/ - - /*Q10*/ const Word16 dirac_dithering_azi_scale_fx[DIRAC_DIFFUSE_LEVELS] = { @@ -369,10 +367,6 @@ const Word16 dirac_dithering_ele_scale_fx[DIRAC_DIFFUSE_LEVELS] = { 1375 ,2072 ,3680 ,5743 ,9468 ,15979 ,21410 ,28252 }; -/*----------------------------------------------------------------------------------* - * FASTCONV and PARAMETRIC binaural renderer ROM tables - *----------------------------------------------------------------------------------*/ - /*----------------------------------------------------------------------* diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index c5df63529..069c821d6 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -583,6 +583,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( { return error; } + nchan_transport = add( nchan_transport, st_ivas->nchan_ism ); st_ivas->nCPE = shr_r( nchan_transport, 1 ); move16(); @@ -599,6 +600,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( { ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); } + nchan_transport = st_ivas->nchan_transport; move16(); nchan_transport_old = add( nchan_transport_old, st_ivas->nchan_ism ); /*Q0*/ @@ -753,7 +755,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( } /*-----------------------------------------------------------------* - * floating-point output audio buffers + * output audio buffers *-----------------------------------------------------------------*/ nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); /*Q0*/ @@ -767,6 +769,12 @@ ivas_error ivas_sba_dec_reconfigure_fx( } +/*-------------------------------------------------------------------* + * ivas_sba_dec_digest_tc_fx() + * + * + *-------------------------------------------------------------------*/ + void ivas_sba_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const Word16 nCldfbSlots, /* i : number of CLDFB slots Q0*/ diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 377543f60..3ab1022fe 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -622,6 +622,7 @@ static void map_params_dirac_to_stereo( move32(); } } + /* Clamp values here. [-1, 1] is the allowed range, but due to precision issues they can be slightly off which can cause problems later. */ /* In Q31, this clamping happens implicitly */ q_sqrt = 0; @@ -642,6 +643,7 @@ static void map_params_dirac_to_stereo( q_sqrt = 0; move16(); } + /* for residual prediction gain, allowed range is [0, 1]*/ res_pred_gain[b] = L_max( Mpy_32_16_1( diffuseness[b], sub( MAX_16, surrCoh[b] ) ), 0 ); /*Q31*/ move32(); diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index a481d9ccb..c9614733c 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -59,8 +59,8 @@ #define CM_INIT 50 #define CORR_INIT 8 #define SID_INIT 6 -#define STEREO_CNA_LR_CORR_LT_FILT_FX 2040109440 /* long-term averaging factor for L/R correlation estimation in stereo CNA */ -#define STEREO_CNA_ILD_LT_FILT_FX 1932735283 /* long-term averaging factor for ILD estimation in stereo CNA */ +#define STEREO_CNA_LR_CORR_LT_FILT_FX 2040109440 /* long-term averaging factor for L/R correlation estimation in stereo CNA, == 0.95f */ +#define STEREO_CNA_ILD_LT_FILT_FX 1932735283 /* long-term averaging factor for ILD estimation in stereo CNA, == 0.9f */ /*------------------------------------------------------------------- * stereo_dft_dec_sid_coh() diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index c29e1e4b5..75c7631bc 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -145,7 +145,7 @@ void stereo_dft_res_ecu_fx( v_shr_32( res_buf, res_buf, L_FRAME8k, negate( q_shift ) ); /* hStereoDft->q_dft */ - v_multc_fixed( res_buf, fac, res_buf, L_FRAME8k ); /* hStereoDft->q_dft */ + v_multc_fx( res_buf, fac, res_buf, L_FRAME8k ); /* hStereoDft->q_dft */ /* Cross-fade memory */ fac = 0; @@ -756,7 +756,7 @@ void stereo_dft_res_ecu_burst_att_fx( fac = L_sub( MAX_32, L_deposit_h( BASOP_Util_Divide3232_Scale( L_sub( hStereoDft->time_offs, L_ana ), L_add( hStereoDft->time_offs, L_ana ), &q_fac ) ) ); /* Q0 */ } - v_multc_fixed( pDFT_RES, fac, pDFT_RES, shl( L_res, 1 ) ); + v_multc_fx( pDFT_RES, fac, pDFT_RES, shl( L_res, 1 ) ); return; } diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index af31aea40..acad47eb4 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -122,9 +122,8 @@ void stereo_icBWE_dec_fx( const Word16 *fb_synth_ref_fx, /* i : ref. high-band synthesis 16-20 kHz Q_white_exc*/ const Word16 *voice_factors_fx, /* i : voicing factors Q15 */ const Word16 output_frame, /* i : frame length Q0 */ - Word16 *Q_syn /* i : Q of synth and synthRef buffers */ - , - const Word16 Q_white_exc /* i : Q of fb_synth_ref_fx */ + Word16 *Q_syn, /* i : Q of synth and synthRef buffers */ + const Word16 Q_white_exc /* i : Q of fb_synth_ref_fx */ ) { Word16 i, j, k, nbSubFr; diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index c34fd8624..60f2bbb24 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -463,16 +463,16 @@ void stereo_decoder_tcx_fx( IF( ( GT_32( nrgRatio, ONE_IN_Q26 ) ) && ( LT_16( k, tmp1 ) ) ) { shift = norm_l( nrgRatio ); - nrgRatio = L_shl( nrgRatio, shift ); /* Q26 + shift */ - v_multc_fixed( spec_r[k], nrgRatio, spec_r[k], L_frameTCX_r ); /* spec_r will be in Qx + shift - Q5 */ - Scale_sig32( spec_r[k], L_frameTCX_r, sub( 5, shift ) ); /* Qx */ + nrgRatio = L_shl( nrgRatio, shift ); /* Q26 + shift */ + v_multc_fx( spec_r[k], nrgRatio, spec_r[k], L_frameTCX_r ); /* spec_r will be in Qx + shift - Q5 */ + Scale_sig32( spec_r[k], L_frameTCX_r, sub( 5, shift ) ); /* Qx */ } ELSE IF( ( LT_32( nrgRatio, ONE_IN_Q26 ) ) && ( LT_16( k, tmp2 ) ) ) { inv_nrgRatio = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q26, nrgRatio, &tmp_e ); shift = sub( 5, tmp_e ); - v_multc_fixed( spec_l[k], inv_nrgRatio, spec_l[k], L_frameTCX_l ); /* spec_r will be in Qx - tmp_e */ - Scale_sig32( spec_l[k], L_frameTCX_l, sub( 5, shift ) ); /* Qx */ + v_multc_fx( spec_l[k], inv_nrgRatio, spec_l[k], L_frameTCX_l ); /* spec_r will be in Qx - tmp_e */ + Scale_sig32( spec_l[k], L_frameTCX_l, sub( 5, shift ) ); /* Qx */ } } } /* for k */ diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index ef4cd013a..a75d2ec91 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -2141,12 +2141,10 @@ void stereo_td2dft_update_fx( } ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) && hCPE->input_mem_fx[0] != NULL ) { - /* update DFT stereo OLA memories */ /*set_zero( hCPE->input_mem_LB[n], STEREO_DFT32MS_OVL_16k );*/ L_lerp_fx_q11( output_fx + sub( sts[n]->L_frame, ovl ), hCPE->input_mem_LB_fx[n], STEREO_DFT32MS_OVL_16k, ovl ); - /* TCX synthesis (it was already delayed in TD stereo in core_switching_post_dec()) */ IF( sts[n]->hTcxDec != NULL ) { diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 458b44124..4f6153e40 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -171,14 +171,14 @@ ivas_error IVAS_DEC_GetCldfbSamples( Word16 *nOutSamples /* o : number of samples per channel written to output buffer */ ); -int16_t IVAS_DEC_is_split_rendering_enabled( +Word16 IVAS_DEC_is_split_rendering_enabled( IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ - int16_t *isSplitRend /* o : flag to indicate if split rendering is enabled */ + Word16 *isSplitRend /* o : flag to indicate if split rendering is enabled */ ); -int16_t IVAS_DEC_is_split_rendering_coded_out( +Word16 IVAS_DEC_is_split_rendering_coded_out( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *isSplitCoded /* o : flag to indicate if split rendering is enabled */ + Word16 *isSplitCoded /* o : flag to indicate if split rendering is enabled */ ); /*! r: error code */ @@ -191,9 +191,9 @@ ivas_error IVAS_DEC_GetObjectMetadata( /*! r: error code */ ivas_error IVAS_DEC_GetMasaMetadata( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ - const UWord8 getFromJbmBuffer /* i : get metadata from a JBM buffer */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_MASA_DECODER_EXT_OUT_META_HANDLE *hMasaExtOutMeta, /* o : pointer to handle, which will be set to point to metadata from the most recently decoded frame */ + const UWord8 getFromJbmBuffer /* i : get metadata from a JBM buffer */ ); /*! r: error code */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index c1cc0bd04..adefcd340 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1540,7 +1540,7 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_limiter_dec_fx( st_ivas->hLimiter, pOutput, st_ivas->hDecoderConfig->nchan_out, numSamplesPerChannelToDecode, st_ivas->BER_detect, Q11 ); } - ivas_syn_output_fx( pOutput, Q11, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); + ivas_syn_output_fx( pOutput, Q11, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (Word16 *) pcmBuf_out ); } free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); @@ -2840,6 +2840,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( IF( hIvasDec->st_ivas->hDiracDecBin[0] != NULL && hIvasDec->st_ivas->hDiracDecBin[0]->hReverb != NULL ) { ivas_binaural_reverb_close_fx( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ) ); + IF( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hDiracDecBin[0]->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL, NULL ) ) != IVAS_ERR_OK ) { return error; @@ -2851,6 +2852,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( IF( hIvasDec->st_ivas->hBinRenderer != NULL && hIvasDec->st_ivas->hBinRenderer->hReverb != NULL ) { ivas_binaural_reverb_close_fx( &( hIvasDec->st_ivas->hBinRenderer->hReverb ) ); + IF( ( error = ivas_binaural_reverb_init( &( hIvasDec->st_ivas->hBinRenderer->hReverb ), hIvasDec->st_ivas->hHrtfStatistics, hIvasDec->st_ivas->hBinRenderer->conv_band, hIvasDec->st_ivas->hBinRenderer->timeSlots, &( hRenderConfig->roomAcoustics ), hIvasDec->st_ivas->hDecoderConfig->output_Fs, NULL, NULL, NULL ) ) != IVAS_ERR_OK ) { return error; @@ -4314,7 +4316,7 @@ ivas_error IVAS_DEC_GetCldfbSamples( IF( hSplitBinRend->hCldfbDataOut->config != IVAS_AUDIO_CONFIG_INVALID ) { num_chs = audioCfg2channels( hSplitBinRend->hCldfbDataOut->config ); - maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 ); + maxBand = (Word16) ( ( CLDFB_NO_CHANNELS_MAX * hIvasDec->st_ivas->hDecoderConfig->output_Fs ) / 48000 ); FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX; slot_idx++ ) { @@ -4404,7 +4406,7 @@ static void ivas_destroy_handle_isar( * *---------------------------------------------------------------------*/ -int16_t IVAS_DEC_is_split_rendering_enabled( +Word16 IVAS_DEC_is_split_rendering_enabled( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ Word16 *isSplitRend /* o : flag to indicate if split rendering is enabled */ ) @@ -4635,7 +4637,7 @@ static ivas_error ivas_dec_init_split_rend( Word16 IVAS_DEC_is_split_rendering_coded_out( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *isSplitCoded /* o : flag to indicate if split rendering is enabled */ + Word16 *isSplitCoded /* o : flag to indicate if split rendering is enabled */ ) { Decoder_Struct *st_ivas; diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index 913543db8..ec45dbae9 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -370,9 +370,8 @@ void lsf_end_dec_fx( Word16 *qlsf, /* o : quantized LSFs in the cosine domain Qx2.56*/ Word16 *lpc_param, /* i : LPC parameters Q0*/ Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *nb_indices /* o : number of indices Q0*/ - , - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ + Word16 *nb_indices, /* o : number of indices Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ ) { Word16 pred0[M]; /* Prediction for the safety-net quantizer (usually mean)*/ diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c index 38ec41cb2..d490dce4a 100644 --- a/lib_dec/pit_dec_fx.c +++ b/lib_dec/pit_dec_fx.c @@ -591,9 +591,8 @@ void pit_Q_dec_fx( Word16 *T0, /* o : integer pitch lag */ Word16 *T0_frac, /* o : pitch fraction */ Word16 *T0_min, /* i/o: delta search min */ - Word16 *T0_max /* i/o: delta search max */ - , - Word16 *BER_detect /* o : BER detect flag */ + Word16 *T0_max, /* i/o: delta search max */ + Word16 *BER_detect /* o : BER detect flag */ ) { IF( EQ_16( nBits, 10 ) ) /* absolute decoding with 10 bits */ @@ -702,9 +701,8 @@ void pit16k_Q_dec_fx( Word16 *T0, /* o : integer pitch lag */ Word16 *T0_frac, /* o : pitch fraction */ Word16 *T0_min, /* i/o: delta search min */ - Word16 *T0_max /* i/o: delta search max */ - , - Word16 *BER_detect /* o : BER detect flag */ + Word16 *T0_max, /* i/o: delta search max */ + Word16 *BER_detect /* o : BER detect flag */ ) { Word16 index; diff --git a/lib_dec/pitch_extr_fx.c b/lib_dec/pitch_extr_fx.c index 5cabc98b1..5d6e397b0 100644 --- a/lib_dec/pitch_extr_fx.c +++ b/lib_dec/pitch_extr_fx.c @@ -220,8 +220,7 @@ void pitch_pred_linear_fit( a2 = mac_r( L_mac( L_mult( mult_r( 2 * 2048, pg[1] ) /*Q8*/, pg[2] ) /*Q5+16*/, mult_r( 2 * 2048, pg[1] ) /*Q8*/, pg[3] ) /*Q5+16*/, mult_r( -4 * 2048, pg[0] ) /*Q8*/, pg[1] /*Q12*/ ) /*Q5*/; a1 = mac_r( L_mac( L_mult( mult_r( 3 * 2048, pg[0] ) /*Q8*/, pg[1] ) /*Q5+16*/, mult_r( 4 * 2048, pg[0] ) /*Q8*/, pg[2] /*Q12*/ ) /*Q5+16*/, mult_r( 3 * 2048, pg[0] ) /*Q8*/, pg[3] /*Q12*/ ) /*Q5*/; - a = L_mac( L_mac( L_mac( L_mac( L_mult( a1, round_fx( L_shl( ml[0], 4 ) ) ) /*Q4*/ - , + a = L_mac( L_mac( L_mac( L_mac( L_mult( a1, round_fx( L_shl( ml[0], 4 ) ) ) /*Q4*/, round_fx( L_shl( ml[1], 4 ) ) /*Q4*/, a2 ), round_fx( L_shl( ml[2], 4 ) ) /*Q4*/, a3 ), round_fx( L_shl( ml[3], 4 ) ) /*Q4*/, a4 ), @@ -258,8 +257,7 @@ void pitch_pred_linear_fit( b4 = mac_r( L_mac( L_mac( L_mult( mult_r( -3 * 8192, pg[0] ), pg[3] ), mult_r( -2 * 8192, pg[1] ), pg[3] ), mult_r( -32768 / 2, pg[3] ), mult_r( 32768 / 2, pg[2] ) ), mult_r( 32768 / 2, pg[4] ), mult_r( 32768 / 2, pg[3] ) ); /*Q7*/ b5 = mac_r( L_mac( L_mac( L_mult( mult_r( -32768 /*(-4*8192)*/, pg[0] ), pg[4] ), mult_r( -3 * 8192, pg[1] ), pg[4] ), mult_r( -2 * 8192, pg[2] ), pg[4] ), mult_r( -32768 / 2, pg[4] ), mult_r( 32768 / 2, pg[3] ) ) /*Q7*/; - b = L_mac( L_mac( L_mac( L_mac( L_mult( b1, round_fx( L_shl( ml[0], 4 ) ) ) /*Q4*/ - , + b = L_mac( L_mac( L_mac( L_mac( L_mult( b1, round_fx( L_shl( ml[0], 4 ) ) ) /*Q4*/, round_fx( L_shl( ml[1], 4 ) ) /*Q4*/, b2 ), round_fx( L_shl( ml[2], 4 ) ) /*Q4*/, b3 ), round_fx( L_shl( ml[3], 4 ) ) /*Q4*/, b4 ), diff --git a/lib_dec/rom_dec_fx.c b/lib_dec/rom_dec_fx.c index 3f5243286..8857a0f00 100644 --- a/lib_dec/rom_dec_fx.c +++ b/lib_dec/rom_dec_fx.c @@ -51,6 +51,7 @@ const Word16 h_low_fx[5] = /* Q15 */ { -410, 3572, 25602, 3572, -410 }; + const Word16 inv_sqi[15] = /* Q15 */ { 8192, /* 1/4 */ @@ -69,9 +70,11 @@ const Word16 inv_sqi[15] = /* Q15 */ 146, /* 1/225 */ 128 /* 1/256 */ }; + /*-------------------------------------------------------------------* * index square used in fec_adapt_codebook *-------------------------------------------------------------------*/ + const Word16 sqi[15] = /* Q0 */ { 4, /* 2 */ @@ -90,8 +93,10 @@ const Word16 sqi[15] = /* Q0 */ 225, /* 15 */ 256 /* 16 */ }; + /* RE8 related tables */ const Word16 mult_avq_tab[7] = {1,1,1,342,1,1,171}; + const Word16 shift_avq_tab[7] = {0,0,1, 10,2,0, 10}; const Word16 hntable[55]= @@ -132,15 +137,18 @@ const Word16 POW_ATT_TABLE0[OFF_FRAMES_LIMIT + 1] = /* Q15 */ 20675, 19745, 18856, 18007, 17197, 16423, 8211, 4106, 2053, 1026, 513, 257, 128, 64, 32, 16, 8, 4, 2, 1, 0 }; + const Word16 POW_ATT_TABLE1[OFF_FRAMES_LIMIT + 1] = /* Q15 */ { 32767, 31656, 30581, 29543, 28540, 27571, 26635, 25731, 24857, 24013, 23198, 22410, 21650, 20915, 20205, 19519, 9759, 4880, 2440, 1220, 610, 305, 152, 76, 38, 19, 10, 5, 2, 1, 0 }; + /* frequency group start bins for transient analysis */ /* 125 375 750 1250 2000 4000 8000 16000 24000 */ const Word16 gw[LGW_MAX] = { 1, 3, 6, 10, 16, 32, 64, 128, 192 }; + const Word16 gw_fx[LGW_MAX] = { 1, 3, 6, 10, 16, 32, 64, 128, 192 }; /* Q0 frequency group start bins for transient analysis */ const Word16 gw_len_inv_fx[LGW_MAX - 1] = /* Q15 */ @@ -148,14 +156,15 @@ const Word16 gw_len_inv_fx[LGW_MAX - 1] = /* Q15 */ 16384, 10923, 8192, 5461, 2048, 1024, 512, 512, }; + const Word16 GR_POW_HEADROOM[LGW_MAX] = /* in Q0-- Number of bits down-shifting to prevent from saturation in group power accumulation.*/ { 0, 0, 1, 2, 2, 3, 4, 4, 4 }; + /* 31.25 343.75 718.75 1218.75 1968.75 4000 8000 16000 24000 */ const Word16 ivas_gwlpr[LGW_MAX] = { 1, 3*QUOT_LPR_LTR-1, 6*QUOT_LPR_LTR-1, 10*QUOT_LPR_LTR-1, 16*QUOT_LPR_LTR-1, 32*QUOT_LPR_LTR, 64*QUOT_LPR_LTR, 128*QUOT_LPR_LTR, 192*QUOT_LPR_LTR }; - const Word16 w_hamm48k_2_fx[L_TRANA48k / 2] = /* Q15 */ { 2621, 2623, 2630, 2640, 2654, 2672, 2694, 2721, @@ -215,6 +224,7 @@ const Word16 w_hamm16k_2_fx[L_TRANA16k / 2] = /* Q15 */ 28549, 29053, 29529, 29976, 30393, 30780, 31134, 31455, 31742, 31995, 32213, 32396, 32543, 32653, 32727, 32763 }; + const Word16 w_hamm_sana48k_2_fx[288] = /* Q15 */ { 2621, 2622, 2625, 2630, 2636, 2644, 2654, 2666, @@ -254,6 +264,7 @@ const Word16 w_hamm_sana48k_2_fx[288] = /* Q15 */ 32552, 32579, 32604, 32628, 32649, 32669, 32687, 32703, 32717, 32730, 32741, 32750, 32757, 32762, 32766, 32767 }; + const Word16 w_hamm_sana32k_2_fx[L_PROT_HAMM_LEN2_32k] = /* Q15 */ { 2621, 2623, 2630, 2640, 2654, 2672, 2694, 2721, @@ -281,6 +292,7 @@ const Word16 w_hamm_sana32k_2_fx[L_PROT_HAMM_LEN2_32k] = /* Q15 */ 32283, 32344, 32400, 32452, 32501, 32545, 32585, 32622, 32654, 32682, 32707, 32727, 32743, 32755, 32763, 32767 }; + const Word16 w_hamm_sana16k_2_fx[L_PROT_HAMM_LEN2_16k] = /* Q15 */ { 2621, 2630, 2654, 2695, 2752, 2825, 2914, 3019, @@ -305,30 +317,30 @@ const Word16 swb_hr_inv_frm_len[4] = /* in Q19 */ 4369 /* 1/(960/8) */ }; -const Word16 inv_tbl_2n_minus1[] = { -1, -1, /* Bits = 0 and 1 are not used */ - 21845/*Q16*/, - 18725/*Q17*/, - 17476/*Q18*/, - 16913/*Q19*/, - 16644/*Q20*/, - 16513/*Q21*/ +const Word16 inv_tbl_2n_minus1[] = { + -1, -1, /* Bits = 0 and 1 are not used */ + 21845/*Q16*/, + 18725/*Q17*/, + 17476/*Q18*/, + 16913/*Q19*/, + 16644/*Q20*/, + 16513/*Q21*/ }; /* in Qx */ - /* er_dec_tcx.c */ const Word16 h_high3_32[L_FIR_FER2] = { -1694/*-0.0517f Q15*/, -1923/*-0.0587f Q15*/, -2687/*-0.0820f Q15*/, -3355/*-0.1024f Q15*/, -3814/*-0.1164f Q15*/, 28790/*0.8786f Q15*/, -3814/*-0.1164f Q15*/, -3355/*-0.1024f Q15*/, -2687/*-0.0820f Q15*/, -1923/*-0.0587f Q15*/, -1694/*-0.0517f Q15*/ }; + const Word16 h_high3_16[L_FIR_FER2] = { 0/* 0.f Q15*/, -672/*-0.0205f Q15*/, -2133/*-0.0651f Q15*/, -4116/*-0.1256f Q15*/, -5872/*-0.1792f Q15*/, 26306/*0.8028f Q15*/, -5872/*-0.1792f Q15*/, -4116/*-0.1256f Q15*/, -2133/*-0.0651f Q15*/, -672/*-0.0205f Q15*/, 0/* 0.f Q15*/ }; -const Word16 T_256DIV_L_Frame[] = + +const Word16 T_256DIV_L_Frame[6] = { - 6554 /*L_Frame 640*/ - ,8192 /*L_Frame 512*/ - ,8738 /*L_Frame 480*/ - ,13107/*L_Frame 320*/ - ,16384 /*L_Frame 256*/ - ,26214 /*L_Frame 160*/ + 6554, /*L_Frame 640*/ + 8192, /*L_Frame 512*/ + 8738, /*L_Frame 480*/ + 13107, /*L_Frame 320*/ + 16384, /*L_Frame 256*/ + 26214 /*L_Frame 160*/ }; -/* clang-format on */ - /* Word16 (Q15) Hann window ranging from 0 to 32767/32768 (~0.999969) */ const Word16 pcmdsp_window_hann_960[960] = { @@ -444,3 +456,4 @@ const Word16 pcmdsp_window_hann_640[640] = { 490, 452, 415, 380, 346, 314, 283, 254, 227, 201, 176, 154, 132, 113, 94, 78, 63, 50, 38, 27, 19, 12, 6, 2, 0 }; +/* clang-format on */ diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 7ab5492f7..82253fa51 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -400,6 +400,7 @@ static void encod_gen_voic_core_switch_fx( * Close-loop pitch search and quantization * Adaptive exc. construction *----------------------------------------------------------------*/ + set16_fx( dummyF, -1, NB_SUBFR16k ); /* hack to signal ACELP->HQ switching frame */ pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ @@ -612,6 +613,7 @@ static void encod_gen_voic_core_switch_ivas_fx( * Close-loop pitch search and quantization * Adaptive exc. construction *----------------------------------------------------------------*/ + set16_fx( dummyF, -1, NB_SUBFR16k ); /* hack to signal ACELP->HQ switching frame */ pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, core_bitrate, 0, L_frame, GENERIC, &pitch_limit_flag, 0, exc, L_SUBFR, T_op, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, 0 /*hStereoTD->tdm_Pitch_reuse_flag*/, dummyF /*hStereoTD->tdm_Pri_pitch_buf*/ @@ -620,6 +622,7 @@ static void encod_gen_voic_core_switch_ivas_fx( st_fx->element_mode, Q_new #endif ); /* Q6 */ + /*-----------------------------------------------------------------* * Find adaptive exitation *-----------------------------------------------------------------*/ diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index 31de69328..d831d61b6 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -1,6 +1,7 @@ /*==================================================================================== EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ + #include #include #include "options.h" /* Compilation switches */ @@ -13,19 +14,23 @@ /*-------------------------------------------------------------------* * Local prototypes *-------------------------------------------------------------------*/ + static void wrte_cv( BSTR_ENC_HANDLE hBstr, const Word16 nq, const Word16 i_ind, const Word16 kv_ind, UWord16 I, Word16 kv[], Word16 *bits ); + + /*-------------------------------------------------------------------* * Function AVQ_cod() * * * * Split algevraic vector quantizer (AVQ) base on RE8 latice * *-------------------------------------------------------------------*/ -void AVQ_cod_fx( /* o: comfort noise gain factor */ - const Word16 xri[], /* i: vector to quantize Qx*/ - Word16 xriq[], /* o: quantized normalized vector (assuming the bit budget is enough) */ - const Word16 NB_BITS, /* i: number of allocated bits */ - const Word16 Nsv, /* i: number of subvectors (lg=Nsv*8) */ - const Word16 Q_in_ref /* i: Scaling input */ +/* o: comfort noise gain factor */ +void AVQ_cod_fx( + const Word16 xri[], /* i : vector to quantize Qx*/ + Word16 xriq[], /* o : quantized normalized vector (assuming the bit budget is enough) */ + const Word16 NB_BITS, /* i : number of allocated bits */ + const Word16 Nsv, /* i : number of subvectors (lg=Nsv*8) */ + const Word16 Q_in_ref /* i : Scaling input */ ) { Word16 i, l, iter, c[8]; @@ -159,13 +164,13 @@ void AVQ_cod_fx( /* o: comfort noise gain factor * * Encode subvectors and write indexes into the bitstream *-----------------------------------------------------------------*/ + void AVQ_encmux_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 extl, /* i : extension layer */ - Word16 xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed - by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */ + Word16 xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */ Word16 *nb_bits, /* i/o: number of allocated bits */ - const Word16 Nsv, /* i: number of subvectors */ + const Word16 Nsv, /* i : number of subvectors */ Word16 nq_out[], /* o : AVQ nq index */ Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution */ Word16 trgtSvPos /* i : target SV for AVQ bit savings */ @@ -181,6 +186,7 @@ void AVQ_encmux_fx( Word16 unusedbitsFlag; Word16 svOrder[NSV_MAX], k, nullVec, dummy_bits; Word16 tmp; + test(); IF( EQ_16( extl, SWB_BWE_HIGHRATE ) || EQ_16( extl, FB_BWE_HIGHRATE ) ) { @@ -583,8 +589,10 @@ void AVQ_encmux_fx( return; } + + /*-------------------------------------------------------------------* - * Function AVQ_cod_lpc_fx() * + * Function AVQ_cod_lpc_fx() * * * * Split algebraic vector quantizer (AVQ) for LPC quantization * *-------------------------------------------------------------------*/ diff --git a/lib_enc/cod2t32_fx.c b/lib_enc/cod2t32_fx.c index 5c3684429..f697c4d74 100644 --- a/lib_enc/cod2t32_fx.c +++ b/lib_enc/cod2t32_fx.c @@ -296,6 +296,8 @@ void acelp_2t32_fx( } return; } + + /*---------------------------------------------------------------------------------- * Function acelp_1t64() * @@ -306,19 +308,21 @@ void acelp_2t32_fx( *----------------------------------------------------------------------------------*/ void acelp_1t64_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 dn[], /* i : corr. between target and h[]. Qx*/ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 dn[], /* i : corr. between target and h[]. Qx*/ const Word16 h[], /* i : impulse response of weighted synthesis filter Q12 */ - Word16 code[], /* o : algebraic (fixed) codebook excitation Q9 */ - Word16 y[], /* o : filtered fixed codebook excitation Q9 */ - const Word16 L_subfr /* i : subframe length */ + Word16 code[], /* o : algebraic (fixed) codebook excitation Q9 */ + Word16 y[], /* o : filtered fixed codebook excitation Q9 */ + const Word16 L_subfr /* i : subframe length */ ) { Word16 i, pos, sgn, index; Word32 L_tmp; + /*-------------------------------------------------------------------* * Find position and sign of maximum impulse. *-------------------------------------------------------------------*/ + pos = emaximum_fx( 0, dn, L_subfr, &L_tmp ); IF( dn[pos] < 0 ) diff --git a/lib_enc/cod4t64_fx.c b/lib_enc/cod4t64_fx.c index 8c480b779..964139640 100644 --- a/lib_enc/cod4t64_fx.c +++ b/lib_enc/cod4t64_fx.c @@ -65,11 +65,9 @@ Word16 acelp_4t64_fx( Word16 y[], /* o : filtered fixed codebook excitation Q9*/ Word16 nbbits, /* i : number of bits per codebook */ const Word16 cmpl_flag, /* i : complexity reduction flag */ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ - , + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ const Word16 element_mode ) { - Word16 i, k, index, track; Word32 L_index; Word16 ind[NPMAXPT * NB_TRACK_FCB_4T + 32]; /* VE3: why +32 ???*/ @@ -467,14 +465,16 @@ Word16 acelp_4t64_fx( return saved_bits; } + /*---------------------------------------------------------------------* *encode class for 3p 4p 5p 6p/track * *---------------------------------------------------------------------*/ -static Word32 fcb_encode_cl_fx( /* o: class index of the pulse on a track */ - const Word32 buffer[], /* i: pulses on a track */ - const Word32 pulse_num, /* i: pulses number on a track */ - const Word32 pos_num /* i: number of the position which have pulse */ +/* o: comfort noise gain factor */ +static Word32 fcb_encode_cl_fx( + const Word32 buffer[], /* i : pulses on a track */ + const Word32 pulse_num, /* i : pulses number on a track */ + const Word32 pos_num /* i : number of the position which have pulse */ ) { Word32 i, k; @@ -499,9 +499,11 @@ static Word32 fcb_encode_cl_fx( /* o: class index of t /*---------------------------------------------------------------------* *encode fcb pulse index * *---------------------------------------------------------------------*/ -static Word32 fcb_encode_PI_fx( /* o: return index of the pulse on a track */ - const Word16 v[], /* i: pulse on a track Q9 */ - const Word32 pulse_num /* i: number of the pulse on a track */ + +/* o: return index of the pulse on a track */ +static Word32 fcb_encode_PI_fx( + const Word16 v[], /* i : pulse on a track Q9 */ + const Word32 pulse_num /* i : number of the pulse on a track */ ) { Word16 sector_p[7]; @@ -527,10 +529,12 @@ static Word32 fcb_encode_PI_fx( /* o: return index of t /*---------------------------------------------------------------------* *encode the class and compute class offset * *---------------------------------------------------------------------*/ -static Word32 fcb_encode_class_fx( /* o: class offset */ - const Word32 sector_6p_num[], /* i: position which have pulse on a track */ - const Word32 pulse_num, /* i: pulse number on a track */ - const Word32 pulse_pos_num /* i: number of position which have pulse on a track */ + +/* o: class offset */ +static Word32 fcb_encode_class_fx( + const Word32 sector_6p_num[], /* i : position which have pulse on a track */ + const Word32 pulse_num, /* i : pulse number on a track */ + const Word32 pulse_pos_num /* i : number of position which have pulse on a track */ ) { Word32 i, j, k; @@ -560,14 +564,18 @@ static Word32 fcb_encode_class_fx( /* o: class o } return mn9_offet; } + + /*---------------------------------------------------------------------* *encode the position * *---------------------------------------------------------------------*/ -static Word32 fcb_encode_position_fx( /* o: return index of the positions which have pulse*/ - const Word16 pos_vector[], /* i: position of the pulse on a track */ - Word32 n, - const Word32 pos_num, /* i: the number of position which have pulse */ - const Word32 flag ) + +/* o: return index of the positions which have pulse*/ +static Word32 fcb_encode_position_fx( + const Word16 pos_vector[], /* i: position of the pulse on a track */ + Word32 n, + const Word32 pos_num, /* i: the number of position which have pulse */ + const Word32 flag ) { Word32 i; Word32 mmm1; @@ -599,20 +607,17 @@ static Word32 fcb_encode_position_fx( /* o: return return mmm1; } -/*-------------------------------------------------------------------* - * search_ixiy - * - * Find the best positions of 2 pulses in a subframe - *-------------------------------------------------------------------*/ /*------------------------------------------------------------* * quant_1p_N1 * * Quantization of 1 pulse with N+1 bits: *-------------------------------------------------------------*/ -static Word16 quant_1p_N1_fx( /* o : return N+1 bits */ - const Word16 pos, /* i : position of the pulse */ - const Word16 N /* i : number of bits FOR position */ + +/* o : return N+1 bits */ +static Word16 quant_1p_N1_fx( + const Word16 pos, /* i : position of the pulse */ + const Word16 N /* i : number of bits FOR position */ ) { Word16 mask; @@ -626,6 +631,7 @@ static Word16 quant_1p_N1_fx( /* o : return N+1 bits { index = add( index, shl( 1, N ) ); /* index += 1 << N */ } + return index; } @@ -634,11 +640,15 @@ static Word16 quant_1p_N1_fx( /* o : return N+1 bits * quant_2p_2N1_fx * * Quantization of 2 pulses with 2*N+1 bits: + + *-------------------------------------------------------------*/ -Word16 quant_2p_2N1_fx( /* o: return (2*N)+1 bits */ - const Word16 pos1, /* i: position of the pulse 1 */ - const Word16 pos2, /* i: position of the pulse 2 */ - const Word16 N /* i: number of bits FOR position */ + +/* o: return (2*N)+1 bits */ +Word16 quant_2p_2N1_fx( + const Word16 pos1, /* i : position of the pulse 1 */ + const Word16 pos2, /* i : position of the pulse 2 */ + const Word16 N /* i : number of bits FOR position */ ) { Word16 mask, tmp; @@ -700,23 +710,29 @@ Word16 quant_2p_2N1_fx( /* o: return (2*N)+1 bits */ return index; } + + /*---------------------------------------------------------------------* * Quantization of 3 pulses with 3*N+1 bits: * *---------------------------------------------------------------------*/ -static Word16 quant_3p_3N1_fx( /* o : return (3*N)+1 bits */ - const Word16 pos1, /* i : position of the pulse 1 */ - const Word16 pos2, /* i : position of the pulse 2 */ - const Word16 pos3, /* i : position of the pulse 3 */ - const Word16 N /* i : number of bits for position */ + +/* o : return (3*N)+1 bits */ +static Word16 quant_3p_3N1_fx( + const Word16 pos1, /* i : position of the pulse 1 */ + const Word16 pos2, /* i : position of the pulse 2 */ + const Word16 pos3, /* i : position of the pulse 3 */ + const Word16 N /* i : number of bits for position */ ) { Word16 nb_pos; Word16 index; nb_pos = shl( 1, sub( N, 1 ) ); /* nb_pos = (1<<(N-1)); */ + /*-------------------------------------------------------* * Quantization of 3 pulses with 3*N+1 bits: * *-------------------------------------------------------*/ + logic16(); logic16(); logic16(); @@ -751,24 +767,30 @@ static Word16 quant_3p_3N1_fx( /* o : return (3*N)+1 bits } return ( index ); } + + /*---------------------------------------------------------------------* * Quantization of 4 pulses with 4*N+1 bits: * *---------------------------------------------------------------------*/ -static Word32 quant_4p_4N1_fx( /* o : return (4*N)+1 bits */ - const Word16 pos1, /* i : position of the pulse 1 */ - const Word16 pos2, /* i : position of the pulse 2 */ - const Word16 pos3, /* i : position of the pulse 3 */ - const Word16 pos4, /* i : position of the pulse 4 */ - const Word16 N /* i : number of bits for position */ + +/* o : return (4*N)+1 bits */ +static Word32 quant_4p_4N1_fx( + const Word16 pos1, /* i : position of the pulse 1 */ + const Word16 pos2, /* i : position of the pulse 2 */ + const Word16 pos3, /* i : position of the pulse 3 */ + const Word16 pos4, /* i : position of the pulse 4 */ + const Word16 N /* i : number of bits for position */ ) { Word16 nb_pos; Word32 index; nb_pos = shl( 1, sub( N, 1 ) ); /* nb_pos = (1<<(N-1)); */ + /*-------------------------------------------------------* * Quantization of 4 pulses with 4*N+1 bits: * *-------------------------------------------------------*/ + logic16(); logic16(); logic16(); @@ -800,15 +822,19 @@ static Word32 quant_4p_4N1_fx( /* o : return (4*N)+1 bits /* index += quant_2p_2N1_fx(pos1, pos4, N) << (2*N); */ index = L_add( index, L_shl( quant_2p_2N1_fx( pos1, pos4, N ), shl( N, 1 ) ) ); } + return ( index ); } + + /*---------------------------------------------------------------------* * Quantization of 4 pulses with 4*N bits: * *---------------------------------------------------------------------*/ -static Word32 quant_4p_4N_fx( /* o : return 4*N bits */ - const Word16 pos[], /* i : position of the pulse 1..4 */ - const Word16 N /* i : number of bits for position */ +/* o : return 4*N bits */ +static Word32 quant_4p_4N_fx( + const Word16 pos[], /* i : position of the pulse 1..4 */ + const Word16 N /* i : number of bits for position */ ) { Word16 i, j, k, nb_pos, n_1, tmp; @@ -880,9 +906,10 @@ static Word32 quant_4p_4N_fx( /* o : return 4*N bits } -static Word32 quant_5p_5N_fx( /* o : return 5*N bits */ - const Word16 pos[], /* i : position of the pulse 1..5 */ - const Word16 N ) /* i : number of bits for position */ +/* o : return 5*N bits */ +static Word32 quant_5p_5N_fx( + const Word16 pos[], /* i : position of the pulse 1..5 */ + const Word16 N ) /* i : number of bits for position */ { Word16 i, j, k, nb_pos, n_1, tmp; Word16 posA[5], posB[5]; @@ -960,9 +987,11 @@ static Word32 quant_5p_5N_fx( /* o : return 5*N bits return ( index ); } -static Word32 quant_6p_6N_2_fx( /* o : return (6*N)-2 bits */ - const Word16 pos[], /* i : position of the pulse 1..6 */ - const Word16 N ) /* i : number of bits for position */ + +/* o : return (6*N)-2 bits */ +static Word32 quant_6p_6N_2_fx( + const Word16 pos[], /* i : position of the pulse 1..6 */ + const Word16 N ) /* i : number of bits for position */ { Word16 i, j, k, nb_pos, n_1; Word16 posA[6], posB[6]; @@ -1046,11 +1075,13 @@ static Word32 quant_6p_6N_2_fx( /* o : return (6*N)-2 bits /*---------------------------------------------------------------------* *order the pulse position * *---------------------------------------------------------------------*/ -static Word32 pre_process_fx( /* o: return sign value of pulse on a track */ - const Word16 v[], /* i: the pulse vector Q9 */ - Word16 pos_vector[], /* o: position of the pulse on a track */ - Word32 pos_vector_num[], /* o: the pulse number on the position which have pulse Q0 */ - Word32 *pulse_pos_num /* i: the number of position which have pulse */ + +/* o: return sign value of pulse on a track */ +static Word32 pre_process_fx( + const Word16 v[], /* i : the pulse vector Q9 */ + Word16 pos_vector[], /* o : position of the pulse on a track */ + Word32 pos_vector_num[], /* o : the pulse number on the position which have pulse Q0 */ + Word32 *pulse_pos_num /* i : the number of position which have pulse */ ) { Word16 j, k; diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index f1c87722b..995286120 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1067,7 +1067,15 @@ void E_ACELP_corrmatrix_fx( Word16 h[] /*Q12*/, Word16 sign[] /*Q0*/, Word16 vec return; } -void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/, const Word16 element_mode ) +void E_ACELP_4tsearch_fx( + Word16 dn[] /*Qdn*/, + const Word16 cn[] /*Q_xn*/, + const Word16 H[] /*Q12*/, + Word16 code[] /*Q9*/, + const PulseConfig *config, + Word16 ind[] /*Q0*/, + Word16 y[] /*Qy*/, + const Word16 element_mode ) { Word16 sign[L_SUBFR], vec[L_SUBFR]; Word16 cor_x[16], cor_y[16], h_buf[4 * L_SUBFR]; @@ -1091,7 +1099,6 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const move32(); #endif - alp = config->alp; /* Q13 */ /* initial value for energy of all fixed pulses */ move16(); nb_pulse = config->nb_pulse; @@ -1153,13 +1160,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const E_ACELP_vec_neg_fx( h, h_inv, L_SUBFR ); - /* * Compute correlation matrices needed for the codebook search. */ E_ACELP_corrmatrix_fx( h, sign, vec, rrixix, rrixiy ); - /* * Deep first search: * ------------------ @@ -1366,7 +1371,6 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const } assert( check ); /* debug code not instrumented */ - /* * Build the codeword, the filtered codeword and index of codevector, as well as store weighted correlations. */ @@ -1391,6 +1395,8 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const } return; } + + /* * E_ACELP_4t_fx * @@ -1425,6 +1431,7 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const * Returns: * void */ + void E_ACELP_4t_fx( Word16 dn[], /*Qdn*/ Word16 cn[] /* Q_xn */, @@ -1438,9 +1445,8 @@ void E_ACELP_4t_fx( const Word16 last_L_frame, /*Q0*/ const Word32 total_brate, /*Q0*/ const Word16 i_subfr, /*Q0*/ - const Word16 cmpl_flag /*Q0*/ - , - const Word16 element_mode /*Q0*/ + const Word16 cmpl_flag, /*Q0*/ + const Word16 element_mode /*Q0*/ ) { PulseConfig config; @@ -1490,6 +1496,8 @@ void E_ACELP_4t_fx( E_ACELP_indexing_fx( code, &config, NB_TRACK_FCB_4T, _index ); return; } + + static void E_ACELP_indexing_shift( Word16 wordcnt, /* i: 16-bit word count including the newly shifted-in bits Q0*/ Word16 shift_bits, /* i: number of bits to shift in from the lsb Q0*/ @@ -1511,9 +1519,11 @@ static void E_ACELP_indexing_shift( } dst[i] = s_or( lshl( src[i], shift_bits ), lsb_bits ); /*Q(shift_bits)*/ move16(); + return; } + #define MAX_IDX_LEN 9 Word16 E_ACELP_indexing_fx( @@ -1638,11 +1648,13 @@ Word16 E_ACELP_indexing_fx( return saved_bits; } + /*--------------------------------------------------------------------------* * E_ACELP_adaptive_codebook * * Find adaptive codebook. *--------------------------------------------------------------------------*/ + void E_ACELP_adaptive_codebook( Word16 *exc, /* i/o: pointer to the excitation frame Q_new */ Word16 T0, /* i : integer pitch lag Q0 */ @@ -1660,13 +1672,10 @@ void E_ACELP_adaptive_codebook( ACELP_CbkCorr *g_corr, /* o : ACELP correlation values */ Word16 **pt_indice, /* i/o: quantization indices pointer */ Word16 *pitch_gain, /* o : adaptive codebook gain 1Q14 */ - Word16 exp_xn /* i : exponent of xn (Q_xn-15) */ - , + Word16 exp_xn, /* i : exponent of xn (Q_xn-15) */ Word16 rf_mode, Word16 rf_coder_type, - Word16 *lp_select - -) + Word16 *lp_select ) { Word16 y2[L_SUBFR], xn2[L_SUBFR], code[L_SUBFR]; ACELP_CbkCorr g_corr2; @@ -1749,6 +1758,7 @@ void E_ACELP_adaptive_codebook( * - find filtered pitch exc. y2[]=exc[] convolved with h1[]) * * - compute pitch gain2 * *-----------------------------------------------------------------*/ + test(); IF( EQ_16( mode, NORMAL_OPERATION ) || EQ_16( mode, LOW_PASS ) ) { @@ -1788,6 +1798,7 @@ void E_ACELP_adaptive_codebook( /*-----------------------------------------------------------------* * use the best prediction (minimise quadratic error). * *-----------------------------------------------------------------*/ + test(); IF( EQ_16( mode, LOW_PASS ) || LT_32( L_tmp, L_ener ) ) { @@ -1841,6 +1852,7 @@ void E_ACELP_adaptive_codebook( * * Find innovative codebook. *--------------------------------------------------------------------------*/ + void E_ACELP_innovative_codebook_fx( Word16 *exc, /* i : pointer to the excitation frame Q_new */ Word16 T0, /* i : integer pitch lag Q0 */ @@ -1869,7 +1881,6 @@ void E_ACELP_innovative_codebook_fx( Word16 Rw2[L_SUBFR]; Word16 pitch, idx; - pitch = T0; move16(); idx = shr( i_subfr, 6 ); @@ -1939,7 +1950,12 @@ void E_ACELP_innovative_codebook_fx( * n - (output) range of possible states (0...n-1) * p - (output) number of pulses found *--------------------------------------------------------------------------*/ -static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, UWord32 *ps /*Q0*/, Word16 *p /*Q0*/ ) + +static void E_ACELP_codearithp_fx( + const Word16 v[] /*Q9*/, + UWord32 *n /*Q0*/, + UWord32 *ps /*Q0*/, + Word16 *p /*Q0*/ ) { Word16 k, nb_pulse, i, t, pos[NPMAXPT], posno; Word16 sign, m; @@ -2024,10 +2040,17 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U *p = nb_pulse; /*Q0*/ move16(); + return; } -void fcb_pulse_track_joint_fx( UWord16 *idxs /*Q0*/, Word16 wordcnt /*Q0*/, UWord32 *index_n /*Q0*/, Word16 *pulse_num /*Q0*/, Word16 track_num /*Q0*/ ) + +void fcb_pulse_track_joint_fx( + UWord16 *idxs /*Q0*/, + Word16 wordcnt /*Q0*/, + UWord32 *index_n /*Q0*/, + Word16 *pulse_num /*Q0*/, + Word16 track_num /*Q0*/ ) { Word16 hi_to_low[10]; UWord32 index, index_mask; @@ -2142,5 +2165,6 @@ void fcb_pulse_track_joint_fx( UWord16 *idxs /*Q0*/, Word16 wordcnt /*Q0*/, UWor idxs[track] = extract_l( index ); index = L_lshr( index, 16 ); } + return; } diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 3d0959341..97447082b 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -4,21 +4,24 @@ #include #include "options.h" -//#include "prot_fx.h" #include "basop_util.h" #include "options.h" #include "rom_enc.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ + /*--------------------------------------------------------------------------------------* * Local constant *--------------------------------------------------------------------------------------*/ #define _1_Q11 ( 2048 /*1.0f Q11*/ ) /* 1.0f in 4Q11 */ + + /*--------------------------------------------------------------------------------------* * E_ACELP_update_cor *--------------------------------------------------------------------------------------*/ + static void E_ACELP_update_cor_fx( const Word16 pos[], /* i Q0*/ Word16 nb_pulse, /* i Q0*/ @@ -111,11 +114,16 @@ static void E_ACELP_update_cor_fx( { assert( !"Number of pulses not supported" ); } + + return; } + + /*--------------------------------------------------------------------------------------* * E_ACELP_2pulse_searchx * Iterations: nb_pos_ix*16 *--------------------------------------------------------------------------------------*/ + static void E_ACELP_2pulse_searchx_fx( const Word16 nb_pos_ix, /*Q0*/ const Word16 track_x, /*Q0*/ @@ -221,7 +229,6 @@ static void E_ACELP_2pulse_searchx_fx( sqk[1 - ik] = sq; /* Q9 */ move16(); - /*s = (alpk * sq) - (sqk * alp2); MULT(1);MAC(1);*/ s = L_msu_o( L_mult( alpk[ik], sq ), sqk[ik], alp2_16, &Overflow ); /* Q_sq = Q_sqk, Q_alpk = Q_alp */ if ( s > 0 ) @@ -256,11 +263,15 @@ static void E_ACELP_2pulse_searchx_fx( move16(); assert( ( ( pos[0] & 3 ) == track_x ) && ( ( pos[1] & 3 ) == track_y ) ); /* sanity check */ + + return; } + /*--------------------------------------------------------------------------------------* * E_ACELP_1pulse_searchx *--------------------------------------------------------------------------------------*/ + static void E_ACELP_1pulse_searchx_fx( UWord8 tracks[2], /*Q0*/ Word16 *R, /*Q9+scale*/ @@ -354,21 +365,24 @@ static void E_ACELP_1pulse_searchx_fx( move16(); *ix = x_save; /* Q0 */ move16(); + + return; } + /*--------------------------------------------------------------------------------------* * E_ACELP_4tsearchx_fx * Autocorrelation method for searching pulse positions effectively * Algorithm is identical to traditional covariance method *--------------------------------------------------------------------------------------*/ + void E_ACELP_4tsearchx_fx( Word16 dn[], /*Qdn*/ const Word16 cn[], /*Q_new*/ Word16 Rw[], /*Q9*/ Word16 code[], /*Q9*/ const PulseConfig *config, - Word16 ind[] /*Q0*/ - , + Word16 ind[], /*Q0*/ const Word16 element_mode ) { Word16 sign[L_SUBFR], vec[L_SUBFR]; @@ -394,7 +408,6 @@ void E_ACELP_4tsearchx_fx( ps = 0; /* to avoid compilation warnings */ move16(); - alp = config->alp; /* Q13 */ move16(); nb_pulse = config->nb_pulse; @@ -598,7 +611,6 @@ void E_ACELP_4tsearchx_fx( } } - /* * Store weighted energy of code, build the codeword and index of codevector. */ @@ -646,4 +658,6 @@ void E_ACELP_4tsearchx_fx( move16(); } } + + return; } diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index dba711330..cb9bba638 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -250,6 +250,7 @@ void encod_gen_voic_fx( st_fx->element_mode, Q_new #endif ); /* Q6 */ + tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); /*-----------------------------------------------------------------* diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index 2a0b0e7b1..8fe9fb0b6 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -1,6 +1,7 @@ /*==================================================================================== EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ + #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ @@ -9,14 +10,18 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx_enc.h" + /*---------------------------------------------------------------------* * Local function prototype *---------------------------------------------------------------------*/ + static void find_cn_fx( const Word16 xn[], const Word16 Ap[], const Word16 *p_Aq, Word16 cn[] ); + /*-----------------------------------------------------------------* * Transform domain contribution encoding *-----------------------------------------------------------------*/ + #define Q_MINUS 4 void transf_cdbk_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ @@ -83,6 +88,7 @@ void transf_cdbk_enc_fx( * For inactive frame, find target in residual domain * Deemphasis *--------------------------------------------------------------*/ + IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { gcode16 = round_fx_o( L_shl_o( gain_code, Q_new, &Overflow ), &Overflow ); @@ -132,12 +138,14 @@ void transf_cdbk_enc_fx( /*--------------------------------------------------------------* * Split algebraic vector quantizer based on RE8 lattice *--------------------------------------------------------------*/ + AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, 0 ); /*--------------------------------------------------------------* * Find prequantizer excitation gain * Quantize the gain *--------------------------------------------------------------*/ + L_corr = L_deposit_l( 0 ); L_ener = L_deposit_l( 0 ); FOR( i = 0; i < Nsv * 8; i++ ) @@ -247,6 +255,7 @@ void transf_cdbk_enc_fx( /*--------------------------------------------------------------* * Encode and multiplex subvectors into bit-stream *--------------------------------------------------------------*/ + trgtSvPos = Nsv - 1; move16(); test(); @@ -312,6 +321,7 @@ void transf_cdbk_enc_fx( /*--------------------------------------------------------------* * Preemphasise *--------------------------------------------------------------*/ + /* in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */ test(); if ( ( nq[7] != 0 ) && ( GT_16( sub( st_fx->last_nq_preQ, nq[0] ), 7 ) ) ) @@ -368,6 +378,8 @@ void transf_cdbk_enc_fx( return; } + + void transf_cdbk_enc_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP Q0*/ @@ -433,6 +445,7 @@ void transf_cdbk_enc_ivas_fx( * For inactive frame, find target in residual domain * Deemphasis *--------------------------------------------------------------*/ + IF( EQ_16( st_fx->coder_type, INACTIVE ) ) { gcode16 = round_fx_o( L_shl_o( gain_code, Q_new, &Overflow ), &Overflow ); @@ -481,12 +494,14 @@ void transf_cdbk_enc_ivas_fx( /*--------------------------------------------------------------* * Split algebraic vector quantizer based on RE8 lattice *--------------------------------------------------------------*/ + AVQ_cod_fx( x_tran, x_norm, nBits, Nsv, 0 ); /*--------------------------------------------------------------* * Find prequantizer excitation gain * Quantize the gain *--------------------------------------------------------------*/ + L_corr = L_deposit_l( 0 ); L_ener = L_deposit_l( 0 ); FOR( i = 0; i < Nsv * 8; i++ ) @@ -598,6 +613,7 @@ void transf_cdbk_enc_ivas_fx( /*--------------------------------------------------------------* * Encode and multiplex subvectors into bit-stream *--------------------------------------------------------------*/ + trgtSvPos = sub( Nsv, 1 ); move16(); test(); @@ -612,7 +628,9 @@ void transf_cdbk_enc_ivas_fx( move16(); move16(); } + AVQ_encmux_fx( st_fx->hBstr, -1, x_norm, &nBits, Nsv, nq, avq_bit_sFlag, trgtSvPos ); + /* save # of AVQ unused bits for next subframe */ *unbits = nBits; move16(); @@ -662,6 +680,7 @@ void transf_cdbk_enc_ivas_fx( /*--------------------------------------------------------------* * Preemphasise *--------------------------------------------------------------*/ + /* in extreme cases at subframe boundaries, lower the preemphasis memory to avoid a saturation */ test(); if ( ( nq[7] != 0 ) && ( GT_16( sub( st_fx->last_nq_preQ, nq[0] ), 7 ) ) ) @@ -742,6 +761,8 @@ void transf_cdbk_enc_ivas_fx( return; } + + /*-------------------------------------------------------------------* * Find target in residual domain - cn[] *-------------------------------------------------------------------*/ @@ -770,13 +791,15 @@ static void find_cn_fx( /*-----------------------------------------------------------------* * Transform domain contribution encoding *-----------------------------------------------------------------*/ -Word16 gain_quant_fx( /* o: quantization index Q0*/ - Word32 *gain, /* i: quantized gain Q16*/ - Word16 *gain16, /* o: quantized gain expg*/ - const Word16 c_min, /* i: log10 of lower limit in Q14*/ - const Word16 c_max, /* i: log10 of upper limit in Q13*/ - const Word16 bits, /* i: number of bits to quantize Q0*/ - Word16 *expg /* o: output exponent of gain16 */ + +/* o: quantization index Q0*/ +Word16 gain_quant_fx( + Word32 *gain, /* i : quantized gain Q16*/ + Word16 *gain16, /* o : quantized gain expg*/ + const Word16 c_min, /* i : log10 of lower limit in Q14*/ + const Word16 c_max, /* i : log10 of upper limit in Q13*/ + const Word16 bits, /* i : number of bits to quantize Q0*/ + Word16 *expg /* o : output exponent of gain16 */ ) { Word16 index, levels; diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index b44592307..0c607ff28 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -262,6 +262,7 @@ void enc_pit_exc_fx( * Close-loop pitch search and quantization * Adaptive exc. construction *----------------------------------------------------------------*/ + *pt_pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc, L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf #if !defined REUSE_EVS_ACELP_PITCH_NORM_CORR @@ -269,11 +270,13 @@ void enc_pit_exc_fx( st_fx->element_mode, Q_new #endif ); /* Q6 */ + /*-----------------------------------------------------------------* * Find adaptive exitation *-----------------------------------------------------------------*/ pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure * or in case of floating point encoder & fixed p. decoder @@ -344,12 +347,15 @@ void enc_pit_exc_fx( inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); + /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ + gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_FRAME, i_subfr, -1, xn, y1, shift_wsp, y2, code, Es_pred, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); } + gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ @@ -364,9 +370,11 @@ void enc_pit_exc_fx( hLPDmem->tilt_code = 0; move16(); } + /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ + IF( use_fcb != 0 ) { Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ @@ -391,6 +399,7 @@ void enc_pit_exc_fx( * Construct adaptive part of the excitation * Save the non-enhanced excitation for FEC_exc *-----------------------------------------------------------------*/ + IF( use_fcb != 0 ) { FOR( i = 0; i < L_subfr; i++ ) @@ -525,8 +534,11 @@ void enc_pit_exc_fx( cum_gpit = shl_sat( cum_gpit, 1 ); /*Q15*/ *gpit = round_fx( L_mac( L_mult( 3277, *gpit ), 29491, cum_gpit ) ); /*Q15*/ + + return; } + void enc_pit_exc_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 *speech, /* i : Input speech Q_new-1*/ @@ -638,7 +650,6 @@ void enc_pit_exc_ivas_fx( } ELSE { - Local_BR = ACELP_7k20; move32(); Pitch_BR = st_fx->core_brate; @@ -710,6 +721,7 @@ void enc_pit_exc_ivas_fx( /*------------------------------------------------------------------* * ACELP subframe loop *------------------------------------------------------------------*/ + p_Aw = Aw; p_Aq = Aq; @@ -724,6 +736,7 @@ void enc_pit_exc_ivas_fx( * target in residual domain "cn" * Compute impulse response, h1[], of weighted synthesis filter *----------------------------------------------------------------*/ + Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */ /* condition on target (compared to float) has been put outside the loop */ @@ -740,6 +753,7 @@ void enc_pit_exc_ivas_fx( * Close-loop pitch search and quantization * Adaptive exc. construction *----------------------------------------------------------------*/ + *pt_pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc, L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf #if !defined REUSE_EVS_ACELP_PITCH_NORM_CORR @@ -754,6 +768,7 @@ void enc_pit_exc_ivas_fx( *-----------------------------------------------------------------*/ pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure * or in case of floating point encoder & fixed p. decoder @@ -765,8 +780,10 @@ void enc_pit_exc_ivas_fx( * Codebook target computation * (No LP filtering of the adaptive excitation) *-----------------------------------------------------------------*/ + lp_select = lp_filt_exc_enc_fx( MODE1, AUDIO, i_subfr, exc, h1, xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */ + IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 ); @@ -824,9 +841,11 @@ void enc_pit_exc_ivas_fx( /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ + gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, st_fx->L_frame, i_subfr, -1, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); } + gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/ @@ -841,9 +860,11 @@ void enc_pit_exc_ivas_fx( hLPDmem->tilt_code = 0; move16(); } + /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ + IF( use_fcb != 0 ) { Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); @@ -866,6 +887,7 @@ void enc_pit_exc_ivas_fx( * Construct adaptive part of the excitation * Save the non-enhanced excitation for FEC_exc *-----------------------------------------------------------------*/ + IF( use_fcb != 0 ) { FOR( i = 0; i < L_subfr; i++ ) @@ -1001,4 +1023,6 @@ void enc_pit_exc_ivas_fx( cum_gpit = shl_sat( cum_gpit, 1 ); /*Q15*/ *gpit = round_fx( L_mac( L_mult( 3277, *gpit ), 29491, cum_gpit ) ); /*Q15*/ + + return; } diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 3e1571370..084084663 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -1,6 +1,7 @@ /*==================================================================================== EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ + #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Compilation switches */ @@ -10,6 +11,7 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ + /*=================================================================================*/ /* FUNCTION : void encod_tran_fx () */ /*---------------------------------------------------------------------------------*/ @@ -103,9 +105,11 @@ Word16 encod_tran_fx( L_frame_fx = st_fx->L_frame; move16(); + /*------------------------------------------------------------------* * Initializations *------------------------------------------------------------------*/ + gain_pit = 0; move16(); gain_code = L_deposit_l( 0 ); @@ -200,11 +204,13 @@ Word16 encod_tran_fx( Jopt_flag = 1; move16(); } + /*-----------------------------------------------------------------* * Quantize the gains * Test quantized gain of pitch for pitch clipping algorithm * Update tilt of code: 0.0 (unvoiced) to 0.5 (voiced) *-----------------------------------------------------------------*/ + IF( Jopt_flag == 0 ) { /* SQ gain_code */ @@ -231,6 +237,7 @@ Word16 encod_tran_fx( Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ + /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ @@ -417,6 +424,7 @@ Word16 encod_tran_fx( return tc_subfr; } + Word16 encod_tran_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Q0*/ @@ -582,11 +590,13 @@ Word16 encod_tran_ivas_fx( Jopt_flag = 1; move16(); } + /*-----------------------------------------------------------------* * Quantize the gains * Test quantized gain of pitch for pitch clipping algorithm * Update tilt of code: 0.0 (unvoiced) to 0.5 (voiced) *-----------------------------------------------------------------*/ + IF( Jopt_flag == 0 ) { /* SQ gain_code */ @@ -613,6 +623,7 @@ Word16 encod_tran_ivas_fx( Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/ gcode16 = round_fx_o( Lgcode, &Overflow ); hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 + /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ @@ -625,6 +636,7 @@ Word16 encod_tran_ivas_fx( L_tmp = L_msu( L_tmp, y1[L_SUBFR - 1], gain_pit ); // Q_new-1+15+shift L_tmp = L_shl_sat( L_tmp, sub( 1, shift ) ); // Q_new+15 hLPDmem->mem_w0 = round_fx_sat( L_tmp ); /*Q_new-1*/ + /*-----------------------------------------------------------------* * Construct adaptive part of the excitation * Save the non-enhanced excitation for FEC_exc @@ -656,6 +668,7 @@ Word16 encod_tran_ivas_fx( * Construct adaptive part of the excitation * Save the non-enhanced excitation for FEC_exc *-----------------------------------------------------------------*/ + FOR( i = 0; i < L_SUBFR; i++ ) { /* code in Q9, gain_pit in Q14 */ diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index 28c79a968..1a531b8be 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -1,6 +1,7 @@ /*==================================================================================== EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ + #include #include #include "options.h" /* Compilation switches */ @@ -9,12 +10,13 @@ #include "rom_com.h" #include "prot_fx_enc.h" /* Function prototypes */ + /*-------------------------------------------------------------------* * encod_unvoiced() * * Encode unvoiced (UC) frames *-------------------------------------------------------------------*/ -/*fixed point implementation of unvoiced_encoder*/ + void encod_unvoiced_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : Input speech Q_new*/ @@ -81,7 +83,6 @@ void encod_unvoiced_fx( Q_xn = add( sub( Q_new, 1 ), shift ); Q_new_p5 = add( Q_new, 5 ); - FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) { /*----------------------------------------------------------------* @@ -89,6 +90,7 @@ void encod_unvoiced_fx( * Find the excitation search target "xn" and innovation target in residual domain "cn" * Compute impulse response, h1[], of weighted synthesis filter *----------------------------------------------------------------*/ + i_subfr_idx = shr( i_subfr, 6 ); Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ @@ -100,9 +102,11 @@ void encod_unvoiced_fx( /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); + /*----------------------------------------------------------------* * Unvoiced subframe processing *----------------------------------------------------------------*/ + IF( !uc_two_stage_flag ) { *pt_pitch_fx = gaus_encode_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx, @@ -123,9 +127,11 @@ void encod_unvoiced_fx( * Gain clipping test to avoid unstable synthesis on frame erasure * or in case of floating point encoder & fixed p. decoder *-----------------------------------------------------------------*/ + Mode2_gp_clip_fx( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn ); *pt_pitch_fx = L_SUBFR; move16(); + /*----------------------------------------------------------------------* * Encode the algebraic innovation * *----------------------------------------------------------------------*/ @@ -165,15 +171,18 @@ void encod_unvoiced_fx( /*----------------------------------------------------------* * - voice factor (for pitch enhancement) * *----------------------------------------------------------*/ + E_UTIL_voice_factor( exc_fx, i_subfr, code_fx, gain_pit_fx, L_gain_code_fx, &voice_fac_fx, &( hLPDmem->tilt_code ), L_SUBFR, acelp_cfg->voice_tilt, Q_new, shift ); IF( st_fx->Opt_RF_ON ) { st_fx->hRF->rf_tilt_buf[i_subfr_idx] = hLPDmem->tilt_code; } + /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ + /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ Ltmp = Mpy_32_16_1( L_gain_code_fx, y2_fx[L_SUBFR - 1] ); /* Q10 */ Ltmp = L_shl( Ltmp, add( 5, Q_xn ) ); /* Q15 + Q_xn */ @@ -222,6 +231,7 @@ void encod_unvoiced_fx( * Synthesize speech to update mem_syn[]. * Update A(z) filters *-----------------------------------------------------------------*/ + Syn_filt_s( 1, p_Aq_fx, M, &exc_fx[i_subfr], &syn_fx[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); p_Aw_fx += ( M + 1 ); @@ -238,6 +248,7 @@ void encod_unvoiced_fx( return; } + void encod_unvoiced_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 *speech_fx, /* i : Input speech Q_new*/ @@ -287,6 +298,7 @@ void encod_unvoiced_ivas_fx( /*------------------------------------------------------------------* * Initializations *------------------------------------------------------------------*/ + gain_pit_fx = 0; move16(); @@ -306,7 +318,6 @@ void encod_unvoiced_ivas_fx( Q_xn = add( sub( Q_new, 1 ), shift ); Q_new_p5 = add( Q_new, 5 ); - FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR ) { /*----------------------------------------------------------------* @@ -314,6 +325,7 @@ void encod_unvoiced_ivas_fx( * Find the excitation search target "xn" and innovation target in residual domain "cn" * Compute impulse response, h1[], of weighted synthesis filter *----------------------------------------------------------------*/ + i_subfr_idx = shr( i_subfr, 6 ); Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ @@ -326,9 +338,11 @@ void encod_unvoiced_ivas_fx( /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); // Q_new - 1 + shift + /*----------------------------------------------------------------* * Unvoiced subframe processing *----------------------------------------------------------------*/ + IF( !uc_two_stage_flag ) { *pt_pitch_fx = gaus_encode_fx( st_fx, i_subfr, h1_fx, xn_fx, exc_fx, &hLPDmem->mem_w0, st_fx->clip_var_fx, @@ -341,22 +355,25 @@ void encod_unvoiced_ivas_fx( /*----------------------------------------------------------------* * Unvoiced subframe processing in two stages *----------------------------------------------------------------*/ + // PMT("The code below needs validation, never been tested") /* No adaptive codebook (UC) */ set16_fx( y1, 0, L_SUBFR ); set16_fx( exc_fx + i_subfr, 0, L_SUBFR ); + /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure * or in case of floating point encoder & fixed p. decoder *-----------------------------------------------------------------*/ + Mode2_gp_clip_fx( st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, L_SUBFR, Q_xn ); *pt_pitch_fx = L_SUBFR << 6; move16(); + /*----------------------------------------------------------------------* * Encode the algebraic innovation * *----------------------------------------------------------------------*/ - // E_ACELP_innovative_codebook_fx( exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8) st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate, st_fx->element_mode ); inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); @@ -398,6 +415,7 @@ void encod_unvoiced_ivas_fx( /*----------------------------------------------------------* * - voice factor (for pitch enhancement) * *----------------------------------------------------------*/ + E_UTIL_voice_factor( exc_fx, i_subfr, code_fx, gain_pit_fx, L_gain_code_fx, &voice_fac_fx, &( hLPDmem->tilt_code ), L_SUBFR, acelp_cfg->voice_tilt, Q_new, shift ); if ( st_fx->Opt_RF_ON ) @@ -408,6 +426,7 @@ void encod_unvoiced_ivas_fx( /*-----------------------------------------------------------------* * Update memory of the weighting filter *-----------------------------------------------------------------*/ + /* st_fx->mem_w0 = xn[L_SUBFR-1] - (gain_pit*y1[L_SUBFR-1]) - (gain_code*y2[L_SUBFR-1]); */ Ltmp = Mpy_32_16_1( L_gain_code_fx, y2_fx[L_SUBFR - 1] ); /* Q10 */ Ltmp = L_shl( Ltmp, add( 5, Q_xn ) ); // Qxn+15 @@ -462,6 +481,7 @@ void encod_unvoiced_ivas_fx( * Synthesize speech to update mem_syn[]. * Update A(z) filters *-----------------------------------------------------------------*/ + Syn_filt_s( 1, p_Aq_fx, M, &exc_fx[i_subfr], &syn_fx[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 ); p_Aw_fx += ( M + 1 ); diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 87fa6a451..e9028b8b6 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -914,10 +914,10 @@ void core_signal_analysis_high_bitrate_ivas_fx( tmp = BASOP_Util_Divide1616_Scale( st->bwidth_sw_cnt, BWS_TRAN_PERIOD, &exp_diff ); factor = L_shl( L_deposit_h( tmp ), exp_diff ); // Q31 - v_multc_fixed( hTcxEnc->spectrum_fx[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), - factor, - hTcxEnc->spectrum_fx[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), - L_subframe - L_FRAME16k / ( 2 * nSubframes ) ); + v_multc_fx( hTcxEnc->spectrum_fx[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), + factor, + hTcxEnc->spectrum_fx[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), + L_subframe - L_FRAME16k / ( 2 * nSubframes ) ); } } hTcxEnc->spectrum_e[frameno] = s_max( exp[0], exp[1] ); @@ -954,7 +954,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( tmp = Sqrt16( tmp, &exp_diff ); factor = L_shl( L_deposit_h( tmp ), exp_diff ); // Q31 - v_multc_fixed( hTcxEnc->spectrum_fx[frameno], factor, hTcxEnc->spectrum_fx[frameno], L_subframe ); + v_multc_fx( hTcxEnc->spectrum_fx[frameno], factor, hTcxEnc->spectrum_fx[frameno], L_subframe ); } ELSE { @@ -996,10 +996,10 @@ void core_signal_analysis_high_bitrate_ivas_fx( tmp = BASOP_Util_Divide1616_Scale( st->bwidth_sw_cnt, BWS_TRAN_PERIOD, &exp_diff ); factor = L_shl( L_deposit_h( tmp ), exp_diff ); // Q31 - v_multc_fixed( hTcxEnc->spectrum_fx[frameno] + L_FRAME16k / nSubframes, - factor, - hTcxEnc->spectrum_fx[frameno] + L_FRAME16k / nSubframes, - L_subframe - L_FRAME16k / nSubframes ); + v_multc_fx( hTcxEnc->spectrum_fx[frameno] + L_FRAME16k / nSubframes, + factor, + hTcxEnc->spectrum_fx[frameno] + L_FRAME16k / nSubframes, + L_subframe - L_FRAME16k / nSubframes ); } IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) @@ -1121,10 +1121,10 @@ void core_signal_analysis_high_bitrate_ivas_fx( tmp = BASOP_Util_Divide1616_Scale( st->bwidth_sw_cnt, BWS_TRAN_PERIOD, &exp_diff ); factor = L_shl( L_deposit_h( tmp ), exp_diff ); // Q31 - v_multc_fixed( spectrum[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), - factor, - spectrum[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), - L_subframe - L_FRAME16k / ( 2 * nSubframes ) ); + v_multc_fx( spectrum[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), + factor, + spectrum[frameno] + i * tcx5SizeFB + L_FRAME16k / ( 2 * nSubframes ), + L_subframe - L_FRAME16k / ( 2 * nSubframes ) ); } } } @@ -1149,7 +1149,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( tmp = Sqrt16( tmp, &exp_diff ); factor = L_shl( L_deposit_h( tmp ), exp_diff ); // Q31 - v_multc_fixed( spectrum[frameno], factor, spectrum[frameno], L_subframe ); + v_multc_fx( spectrum[frameno], factor, spectrum[frameno], L_subframe ); } ELSE { @@ -1191,7 +1191,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( tmp = BASOP_Util_Divide1616_Scale( st->bwidth_sw_cnt, BWS_TRAN_PERIOD, &exp_diff ); factor = L_shl( L_deposit_h( tmp ), exp_diff ); // Q31 - v_multc_fixed( spectrum[frameno] + L_FRAME16k / nSubframes, factor, spectrum[frameno] + L_FRAME16k / nSubframes, L_subframe - L_FRAME16k / nSubframes ); + v_multc_fx( spectrum[frameno] + L_FRAME16k / nSubframes, factor, spectrum[frameno] + L_FRAME16k / nSubframes, L_subframe - L_FRAME16k / nSubframes ); } } } diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index c5fb6d2e1..c951e9c3b 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -28,9 +28,8 @@ void find_tilt_fx( Word32 hp_E[], /* o : energy in HF Q_new + Q_SCALE*/ const Word16 codec_mode, /* i : MODE1 or MODE2 Q0*/ const Word16 Q_new, /* i : scaling factor */ - Word32 *bckr_tilt_lt /* i/o: lf/hf E ratio of background noise Q16*/ - , - Word16 Opt_vbr_mode /* Q0 */ + Word32 *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise Q16*/ + Word16 Opt_vbr_mode /* Q0 */ ) { Word32 lp_bckr = 0, hp_bckr = 0, lp_E, Ltmp; diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 9468fff60..fbfcc2c18 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -533,6 +533,8 @@ void gain_enc_mless_fx( return; } + + /*---------------------------------------------------------------------* * gain_enc_SQ() * @@ -817,17 +819,21 @@ void gain_enc_SQ_fx( return; } + + /*-------------------------------------------------------------------* * gain_enc_gaus() * * Quantization of gain for Gaussian codebook *-------------------------------------------------------------------*/ -Word16 gain_enc_gaus_fx( /* o : Return index of quantization */ - Word32 *gain, /* i/o: Code gain to quantize Q16*/ - const Word16 bits, /* i : number of bits to quantize Q0*/ - const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ - const Word16 stepSize, /* i : Step size choice Q14*/ - const Word16 inv_stepSize /* i : Step size choice Q15*/ + +/* o : Return index of quantization */ +Word16 gain_enc_gaus_fx( + Word32 *gain, /* i/o: Code gain to quantize Q16*/ + const Word16 bits, /* i : number of bits to quantize Q0*/ + const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ + const Word16 stepSize, /* i : Step size choice Q14*/ + const Word16 inv_stepSize /* i : Step size choice Q15*/ ) { Word16 index, exp_gain, frac_gain, wtmp; @@ -872,6 +878,8 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant return index; } + + /*-----------------------------------------------------------------* * gain_enc_tc() * @@ -881,6 +889,7 @@ Word16 gain_enc_gaus_fx( /* o : Return index of quant * - gain_pit = 0 * - gain_code - scalar quantization (no prediciton history used) *-----------------------------------------------------------------*/ + void gain_enc_tc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -909,6 +918,7 @@ void gain_enc_tc_fx( /*----------------------------------------------------------------* * get number of bits for gain quantization *----------------------------------------------------------------*/ + nBits = gains_mode[shr( i_subfr, 6 )]; /*----------------------------------------------------------------* @@ -934,6 +944,7 @@ void gain_enc_tc_fx( /*----------------------------------------------------------------* * compute gain = xy/yy *----------------------------------------------------------------*/ + g_code_fx = div_s( num, den ); i = sub( exp_num, exp_den ); /* Gain_trans in Q7 */ @@ -1023,9 +1034,11 @@ void gain_enc_tc_fx( BREAK; } } + /*----------------------------------------------------------------* * 3-bit -> 2-bit encoding *----------------------------------------------------------------*/ + IF( EQ_16( nBits, 2 ) ) { /* 2-bit -> 3-bit decoding */ @@ -1053,6 +1066,7 @@ void gain_enc_tc_fx( /*-----------------------------------------------------------------* * decode normalized codebook gain *-----------------------------------------------------------------*/ + /**norm_gain_code = *gain_code / *gain_inov;*/ expg = sub( norm_s( *gain_inov_fx ), 1 ); expg = s_max( expg, 0 ); @@ -1060,13 +1074,17 @@ void gain_enc_tc_fx( tmp_fx = div_s( shr( 8192, expg ), *gain_inov_fx ); *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) ); // Q16 move32(); + return; } + + /*-----------------------------------------------------------------* * Find_Opt_gainQ_fx() * * Find the best quantizer *-----------------------------------------------------------------*/ + static Word16 Find_Opt_gainQ_fx( Word16 *coeff, /* exp(exp_coeff) */ Word16 *exp_coeff, @@ -1091,7 +1109,6 @@ static Word16 Find_Opt_gainQ_fx( move32(); #endif - /*----------------------------------------------------------------* * Find the best quantizer * ~~~~~~~~~~~~~~~~~~~~~~~ @@ -1205,8 +1222,11 @@ static Word16 Find_Opt_gainQ_fx( L_tmp = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16 */ *gain_code = L_tmp; /* gain of code in Q16 */ move16(); + return index; } + + /*---------------------------------------------------------------------* * gain_enc_lbr() * @@ -1238,12 +1258,10 @@ void gain_enc_lbr_fx( Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - const Word16 L_subfr /* i : subframe length Q0*/ - , - const Word16 element_mode /* i : mode element Q0*/ + const Word16 L_subfr, /* i : subframe length Q0*/ + const Word16 element_mode /* i : mode element Q0*/ ) { - Word16 index = 0, size, nBits, n_pred, ctype; const Word16 *b, *cdbk = 0; Word16 gcode0, aux[10]; @@ -1260,6 +1278,7 @@ void gain_enc_lbr_fx( L_subfr_sf = 7; move16(); } + /*-----------------------------------------------------------------* * calculate the rest of the correlation coefficients * c2 = , c3 = -2, c4 = 2, c5* = @@ -1309,7 +1328,6 @@ void gain_enc_lbr_fx( *gain_inov = extract_h( L_shl_sat( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */ move16(); - /*-----------------------------------------------------------------* * select the codebook, size and number of bits * set the gains searching range @@ -1325,6 +1343,7 @@ void gain_enc_lbr_fx( * calculate prediction of gcode * search for the best codeword *-----------------------------------------------------------------*/ + test(); IF( i_subfr == 0 ) { @@ -1634,7 +1653,6 @@ void gain_enc_lbr_fx( aux[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ move16(); - /*aux[4] = (float)log10(gc_mem[2]); = log2(gc_mem[2])*log10(2);*/ exp = norm_l( gc_mem[2] ); @@ -1677,9 +1695,11 @@ void gain_enc_lbr_fx( { push_indice( hBstr, IND_GAIN, index, nBits ); } + return; } + /*-------------------------------------------------------------------* * gain_enc_amr_wb() * @@ -1691,7 +1711,6 @@ void gain_enc_lbr_fx( * mean-squared weighted error criterion is used in the quantizer search. *-------------------------------------------------------------------*/ - void gain_enc_amr_wb_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *xn, /* i : target vector Q_xn*/ @@ -1726,6 +1745,7 @@ void gain_enc_amr_wb_fx( * Find the initial quantization pitch index * Set gains search range *----------------------------------------------------------------*/ + IF( GE_32( core_brate, ACELP_12k65 ) ) { t_qua_gain = t_qua_gain7b_fx; // Q14 @@ -1771,6 +1791,7 @@ void gain_enc_amr_wb_fx( } nBits = 6; } + /*----------------------------------------------------------------* * Compute coefficients needed for the quantization. * @@ -1783,6 +1804,7 @@ void gain_enc_amr_wb_fx( * Product and have been computed in Adpt_enr() and * are in vector g_coeff[]. *----------------------------------------------------------------*/ + coeff[0] = g_coeff[0]; move16(); exp_coeff[0] = g_coeff[1]; @@ -1816,6 +1838,7 @@ void gain_enc_amr_wb_fx( * L_tmp = MEAN_ENER - 10log10(energy of code/ L_subfr) * = MEAN_ENER - 3.0103*log2(energy of code/ L_subfr) *----------------------------------------------------------------*/ + L_tmp = Dot_product12( code, code, L_SUBFR, &exp_code ); L_inov = L_add( L_tmp, 0 ); /* exp_code: -18 (code in Q9), -6 (/L_subfr), -31 (L_tmp Q31->Q0) */ @@ -1835,6 +1858,7 @@ void gain_enc_amr_wb_fx( /*----------------------------------------------------------------* * predicted codebook gain *----------------------------------------------------------------*/ + L_tmp = L_shl( L_tmp, 10 ); /* From Q14 to Q24 */ L_tmp = L_mac0( L_tmp, pred_gain_fx[0], past_qua_en[0] ); /* Q14*Q10 -> Q24 */ L_tmp = L_mac0( L_tmp, pred_gain_fx[1], past_qua_en[1] ); /* Q14*Q10 -> Q24 */ diff --git a/lib_enc/hq_core_enc_fx.c b/lib_enc/hq_core_enc_fx.c index b5e1abbca..fd8398590 100644 --- a/lib_enc/hq_core_enc_fx.c +++ b/lib_enc/hq_core_enc_fx.c @@ -467,12 +467,12 @@ void hq_core_enc_ivas_fx( { FOR( i = 0; i < NUM_TIME_SWITCHING_BLOCKS; i++ ) { - v_multc_fixed( t_audio_fx + add( i_mult2( i, shr( inner_frame, 2 ) ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ), L_tmp, t_audio_fx + add( i_mult2( i, shr( inner_frame, 2 ) ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ), sub( shr( inner_frame, 2 ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ) ); // Q_audio + Q31 - Q31 -> Q_audio + v_multc_fx( t_audio_fx + add( i_mult2( i, shr( inner_frame, 2 ) ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ), L_tmp, t_audio_fx + add( i_mult2( i, shr( inner_frame, 2 ) ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ), sub( shr( inner_frame, 2 ), L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS ) ); // Q_audio + Q31 - Q31 -> Q_audio } } ELSE { - v_multc_fixed( t_audio_fx + L_FRAME16k, L_tmp, t_audio_fx + L_FRAME16k, L_spec - L_FRAME16k ); // Q_audio + Q31 - Q31 -> Q_audio + v_multc_fx( t_audio_fx + L_FRAME16k, L_tmp, t_audio_fx + L_FRAME16k, L_spec - L_FRAME16k ); // Q_audio + Q31 - Q31 -> Q_audio } } diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index af2780682..2cc5639a3 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -2151,14 +2151,14 @@ static Word16 small_symbol_enc_tran_ivas_fx( /* o : bit * if flag_pack = 0, estimatng else packing bits *--------------------------------------------------------------------------*/ -static Word16 small_symbol_enc_fx( /* o : bits */ - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ - const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode, /* i/o: LC mode info Q0*/ - const Word16 flag_pack /* i : indicator of packing or estimating bits Q0*/ - , - const Word16 is_transient /* Q0 */ ) +/* o : bits */ +static Word16 small_symbol_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ + const Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ + const Word16 BANDS, /* i : number of bands Q0*/ + Word16 *hLCmode, /* i/o: LC mode info Q0*/ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0*/ + const Word16 is_transient /* Q0 */ ) { Word16 i, bits; Word16 difidx[BANDS_MAX], LSB[BANDS_MAX]; @@ -2289,12 +2289,13 @@ static Word16 small_symbol_enc_ivas_fx( } -static Word16 large_symbol_enc_fx( /* o : bits Q0*/ - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ - Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ - const Word16 BANDS, /* i : number of bands Q0*/ - Word16 *hLCmode0, /* i/o: LC mode info Q0*/ - const Word16 flag_pack /* i : indicator of packing or estimating bits Q0*/ +/* o : bits Q0 */ +static Word16 large_symbol_enc_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream */ + Word16 *qbidx, /* i : input of dequantized differential energy Q0*/ + const Word16 BANDS, /* i : number of bands Q0*/ + Word16 *hLCmode0, /* i/o: LC mode info Q0*/ + const Word16 flag_pack /* i : indicator of packing or estimating bits Q0*/ ) { Word16 i, bits, tmp; @@ -3165,7 +3166,7 @@ static Word16 band_energy_quant_fx( static Word16 band_energy_quant_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word32 *L_t_audio, /* i : Q12 : input MDCT signal (Qs) */ const Word16 band_start[], /* i : Q0 : band start table */ const Word16 band_end[], /* i : Q0 : band end table */ @@ -3173,7 +3174,8 @@ static Word16 band_energy_quant_ivas_fx( const Word16 bands, /* i : Q0 : number of bands */ const Word32 L_qint, /* i : Q29 */ const Word16 eref_fx, /* i : Q10 */ - const Word16 is_transient /* i : Q0 : indicator for HQ_TRANSIENT */ ) + const Word16 is_transient /* i : Q0 : indicator for HQ_TRANSIENT */ +) { Word16 i, k; Word16 ebits; diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 0ee479a7c..f07331c9e 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -22,9 +22,9 @@ *-----------------------------------------------------------------------*/ ivas_error init_encoder_fx( - Encoder_State *st_fx, /* i/o: Encoder static variables structure */ - const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ - const int16_t interval_SID /* i : interval for SID update */ + Encoder_State *st_fx, /* i/o: Encoder static variables structure */ + const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ + const Word16 interval_SID /* i : interval for SID update */ ) { Word16 i; diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index b7358df5f..761a894f1 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -1,10 +1,10 @@ /*==================================================================================== EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ + #include #include "options.h" /* Compilation switches */ #include "cnst.h" /* Common constants */ -//#include "prot_fx.h" /* Function prototypes */ #include "basop_util.h" #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ @@ -14,7 +14,7 @@ /*==============================================================================*/ -/* FUNCTION : inov_encode_fx() */ +/* FUNCTION : inov_encode_fx() */ /*------------------------------------------------------------------------------*/ /* PURPOSE : Encode the algebraic innovation */ /*------------------------------------------------------------------------------*/ @@ -334,7 +334,6 @@ Word16 inov_encode_fx( } } - /*----------------------------------------------------------------* * Pitch sharpening *----------------------------------------------------------------*/ @@ -344,6 +343,7 @@ Word16 inov_encode_fx( return stack_pulses; } + Word16 inov_encode_ivas_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -744,7 +744,6 @@ Word16 inov_encode_ivas_fx( } } - /*----------------------------------------------------------------* * Pitch sharpening *----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 455128296..030671b8d 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -1456,14 +1456,14 @@ void ivas_dirac_param_est_enc_fx( * * *------------------------------------------------------------------------*/ + static void computeIntensityVector_enc_fx( const DIRAC_ENC_HANDLE hDirAC, Word32 Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* q_cldfb */ Word32 Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* q_cldfb */ const Word16 enc_param_start_band, /* i : first band to process Q0*/ const Word16 num_frequency_bands, /* Q0 */ - Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS] /* q_intensity_real */ - , + Word32 intensity_real[DIRAC_NUM_DIMS][DIRAC_MAX_NBANDS], /* q_intensity_real */ Word16 q_cldfb, Word16 q_intensity_real[DIRAC_MAX_NBANDS] ) { diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index 11368cec8..742f04197 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -311,7 +311,7 @@ ivas_error ivas_enc_fx( /* Stereo transport is used also with monoMASA, duplicate mono if monoMASA */ IF( EQ_16( sub( st_ivas->hEncoderConfig->nchan_inp, hEncoderConfig->nchan_ism ), 1 ) ) { - v_multc_fixed( data_fx[hEncoderConfig->nchan_ism], L_deposit_h( INV_SQRT2_FX_Q15 ) /* Q31 */, data_fx[hEncoderConfig->nchan_ism], input_frame ); + v_multc_fx( data_fx[hEncoderConfig->nchan_ism], L_deposit_h( INV_SQRT2_FX_Q15 ) /* Q31 */, data_fx[hEncoderConfig->nchan_ism], input_frame ); Copy32( data_fx[hEncoderConfig->nchan_ism], data_fx[hEncoderConfig->nchan_ism + 1], input_frame ); /* st_ivas->q_data_fx */ } diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index ce09abdbc..99da0175f 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -304,7 +304,7 @@ ivas_error front_vad_fx( IF( EQ_16( n_chan, CPE_CHANNELS ) ) { /* get average channel energies, adding up was already done, so only need to scale by number of channels */ - v_multc_fixed( &band_energies_LR_fx[0], ONE_IN_Q30 /* 0.5f in Q31 */, &band_energies_LR_fx[0], 2 * NB_BANDS ); + v_multc_fx( &band_energies_LR_fx[0], ONE_IN_Q30 /* 0.5f in Q31 */, &band_energies_LR_fx[0], 2 * NB_BANDS ); /* Logical OR between L and R decisions */ test(); diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 5a3592ad2..33a1dcc41 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -279,6 +279,8 @@ Word16 getNumChanAnalysis_fx( return n; } + + /*-------------------------------------------------------------------* * copy_encoder_config_fx() * @@ -421,6 +423,7 @@ void ivas_initialize_handles_enc_fx( * * Initialize IVAS encoder state structure *-------------------------------------------------------------------*/ + ivas_error ivas_init_encoder_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) @@ -463,7 +466,7 @@ ivas_error ivas_init_encoder_fx( move16(); /*-----------------------------------------------------------------* - * Allocate floating-point input audio buffers + * Allocate input audio buffers *-----------------------------------------------------------------*/ nchan_inp_buff = hEncoderConfig->nchan_inp; /* Q0 */ @@ -488,7 +491,7 @@ ivas_error ivas_init_encoder_fx( /* note: these are intra-frame heap memories */ IF( ( st_ivas->p_data_fx[n] = (Word32 *) malloc( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) * sizeof( Word32 ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for input audio buffer!\n" ) ); } set32_fx( st_ivas->p_data_fx[n], 0, extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) ) ); } @@ -773,9 +776,6 @@ ivas_error ivas_init_encoder_fx( } ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) ) { - st_ivas->ism_mode = ISM_MODE_NONE; - move16(); - st_ivas->ism_mode = ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->hEncoderConfig->nchan_ism ); IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) @@ -833,12 +833,8 @@ ivas_error ivas_init_encoder_fx( ELSE { /* allocate and initialize MCT core coder */ - { - int16_t n_all; - - n_all = add( st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_ism ); - st_ivas->nCPE = shr_r( n_all, 1 ); - } + Word16 n_all = add( st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_ism ); + st_ivas->nCPE = shr_r( n_all, 1 ); FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { @@ -865,7 +861,7 @@ ivas_error ivas_init_encoder_fx( st_ivas->mc_mode = ivas_mc_mode_select_fx( hEncoderConfig->mc_input_setup, ivas_total_brate ); /* Q0 */ move32(); - IF( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, input_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -979,6 +975,7 @@ ivas_error ivas_init_encoder_fx( { return error; } + ivas_mcmasa_split_brate_fx( st_ivas->hMcMasa->separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) @@ -1034,6 +1031,8 @@ ivas_error ivas_init_encoder_fx( return error; } + + /*------------------------------------------------------------------------- * destroy_core_enc() * @@ -1192,6 +1191,7 @@ void destroy_core_enc_fx( return; } + void destroy_evs_core_enc_fx( ENC_CORE_HANDLE hCoreCoder /* i/o: core encoder structure */ ) @@ -1350,11 +1350,13 @@ void destroy_evs_core_enc_fx( * * Close IVAS encoder handles *-------------------------------------------------------------------------*/ + void ivas_destroy_enc_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) { Word16 i, n, nchan_inp; + nchan_inp = st_ivas->hEncoderConfig->nchan_inp; move16(); @@ -1462,7 +1464,7 @@ void ivas_destroy_enc_fx( free( st_ivas->ind_list_metadata ); } - /* floating-point input audio buffers */ + /* input audio buffers */ FOR( n = 0; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { IF( st_ivas->p_data_fx[n] != NULL ) @@ -1478,6 +1480,7 @@ void ivas_destroy_enc_fx( return; } + /*------------------------------------------------------------------------- * ivas_initialize_MD_bstr_enc_fx() * diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index dc41c784d..e25bf9ea0 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -520,7 +520,6 @@ ivas_error ivas_ism_enc_fx( dbgwrite( &tmpF, sizeof( float ), 1, input_frame, fname( debug_dir, "element_brate", 0, id, ENC ) ); } #endif - pop_wmops(); return error; diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 1a208d0cc..4482a40d4 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -287,7 +287,7 @@ ivas_error ivas_mcmasa_enc_open_fx( bufferSize = (Word16) ( ( input_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES ); FOR( i = 0; i < 2; i++ ) { - IF( ( hMcMasa->lfeAnaRingBuffer[i] = (Word32 *) malloc( bufferSize * sizeof( float ) ) ) == NULL ) + IF( ( hMcMasa->lfeAnaRingBuffer[i] = (Word32 *) malloc( bufferSize * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for McMasa\n" ) ); } @@ -1109,8 +1109,8 @@ void ivas_mcmasa_param_est_enc_fx( } /* Y */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins ); // inp_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins ); // inp_q + v_multc_fx( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins ); // inp_q + v_multc_fx( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins ); // inp_q FOR( i = 1; i < numAnalysisChannels; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[1][i], Foa_RealBuffer_fx[1], num_freq_bins ); // inp_q @@ -1126,8 +1126,8 @@ void ivas_mcmasa_param_est_enc_fx( } ELSE { - v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins ); // inp_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins ); // inp_q + v_multc_fx( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins ); // inp_q + v_multc_fx( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins ); // inp_q FOR( i = 1; i < numAnalysisChannels; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[2][i], Foa_RealBuffer_fx[2], num_freq_bins ); // inp_q @@ -1136,8 +1136,8 @@ void ivas_mcmasa_param_est_enc_fx( } /* X */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins ); // inp_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins ); // inp_q + v_multc_fx( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins ); // inp_q + v_multc_fx( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins ); // inp_q FOR( i = 1; i < numAnalysisChannels; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[3][i], Foa_RealBuffer_fx[3], num_freq_bins ); // inp_q @@ -1150,8 +1150,8 @@ void ivas_mcmasa_param_est_enc_fx( Copy32( Foa_ImagBuffer_fx[0], FoaEven_ImagBuffer_fx[0], num_freq_bins ); // inp_q /* Y */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_RealBuffer_fx[1], num_freq_bins ); // inp_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_ImagBuffer_fx[1], num_freq_bins ); // inp_q + v_multc_fx( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_RealBuffer_fx[1], num_freq_bins ); // inp_q + v_multc_fx( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_ImagBuffer_fx[1], num_freq_bins ); // inp_q FOR( i = 1; i < numAnalysisChannels; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[1][i], FoaEven_RealBuffer_fx[1], num_freq_bins ); // inp_q @@ -1163,8 +1163,8 @@ void ivas_mcmasa_param_est_enc_fx( set_zero_fx( FoaEven_ImagBuffer_fx[2], num_freq_bins ); // inp_q /* X */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_RealBuffer_fx[3], num_freq_bins ); // inp_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_ImagBuffer_fx[3], num_freq_bins ); // inp_q + v_multc_fx( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_RealBuffer_fx[3], num_freq_bins ); // inp_q + v_multc_fx( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_ImagBuffer_fx[3], num_freq_bins ); // inp_q FOR( i = 1; i < numAnalysisChannels; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[3][i], FoaEven_RealBuffer_fx[3], num_freq_bins ); // inp_q diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 0918c51d2..52df4c8cb 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -607,8 +607,8 @@ static void getGlobalILD_fx( FOR( k = 0; k < nSubframes; k++ ) { - v_multc_fixed( sts[ch]->hTcxEnc->spectrum_fx[k], L_deposit_h( qratio ), sts[ch]->hTcxEnc->spectrum_fx[k], L_subframe ); // sts[ch]->hTcxEnc->spectrum_e - v_multc_fixed( mdst_spectrum[ch][k], L_deposit_h( qratio ), mdst_spectrum[ch][k], L_subframe ); // sts[ch]->hTcxEnc->spectrum_e + v_multc_fx( sts[ch]->hTcxEnc->spectrum_fx[k], L_deposit_h( qratio ), sts[ch]->hTcxEnc->spectrum_fx[k], L_subframe ); // sts[ch]->hTcxEnc->spectrum_e + v_multc_fx( mdst_spectrum[ch][k], L_deposit_h( qratio ), mdst_spectrum[ch][k], L_subframe ); // sts[ch]->hTcxEnc->spectrum_e } } } @@ -874,8 +874,8 @@ void apply_MCT_enc_fx( FOR( k = 0; k < nSubframes; k++ ) { - v_multc_fixed( sts[ch]->hTcxEnc->spectrum_fx[k], L_deposit_h( qratio ), sts[ch]->hTcxEnc->spectrum_fx[k], L_subframeTCX ); - v_multc_fixed( mdst_spectrum[ch][k], L_deposit_h( qratio ), mdst_spectrum[ch][k], L_subframeTCX ); + v_multc_fx( sts[ch]->hTcxEnc->spectrum_fx[k], L_deposit_h( qratio ), sts[ch]->hTcxEnc->spectrum_fx[k], L_subframeTCX ); + v_multc_fx( mdst_spectrum[ch][k], L_deposit_h( qratio ), mdst_spectrum[ch][k], L_subframeTCX ); set32_fx( inv_spectrum[ch][k], 0, L_subframeTCX ); } sts[ch]->hTcxEnc->spectrum_e[1] = add( sts[ch]->hTcxEnc->spectrum_e[0], exp ); diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index 86ea8ebe9..b4eba6201 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -362,8 +362,8 @@ static void kernel_switch_trafo_fx( tmp = BASOP_Util_Divide1616_Scale( NORM_MDCT_FACTOR, add( shr( l, 1 ), add( m, shr( r, 1 ) ) ), &exp_tmp ); tmp = Sqrt16( tmp, &exp_tmp ); - factor = L_shl( L_deposit_h( tmp ), sub( exp_tmp, 1 ) ); // Q30 - v_multc_fixed( y, factor, y, add( shr( l, 1 ), add( m, shr( r, 1 ) ) ) ); // (Q_in, Q30) -> Q_in - 1 + factor = L_shl( L_deposit_h( tmp ), sub( exp_tmp, 1 ) ); // Q30 + v_multc_fx( y, factor, y, add( shr( l, 1 ), add( m, shr( r, 1 ) ) ) ); // (Q_in, Q30) -> Q_in - 1 return; } @@ -440,7 +440,7 @@ static void kernel_switch_update_transforms_fx( tmp = BASOP_Util_Divide1616_Scale( NORM_MDCT_FACTOR, s, &exp_tmp ); tmp = Sqrt16( tmp, &exp_tmp ); factor = L_shl( L_deposit_h( tmp ), sub( exp_tmp, Q1 ) ); // Q30 - v_multc_fixed( sigR, factor, sigR, s ); // (Q6, Q30) -> Q5 + v_multc_fx( sigR, factor, sigR, s ); // (Q6, Q30) -> Q5 q_com = L_norm_arr( sigR, s ); q_com = s_min( add( q_com, Q5 ), *q_sig ); @@ -591,8 +591,8 @@ static void kernel_switch_update_transforms_fx( Word16 tmp, exp_tmp; Word32 factor; tmp = BASOP_Util_Divide1616_Scale( bwidthSwCnt, BWS_TRAN_PERIOD, &exp_tmp ); - factor = L_shl( L_deposit_h( tmp ), exp_tmp ); // Q31 - v_multc_fixed( sigR + L_FRAME16k / nSubframes, factor, sigR + L_FRAME16k / nSubframes, sub( s, idiv1616( L_FRAME16k, nSubframes ) ) ); // *q_sig + factor = L_shl( L_deposit_h( tmp ), exp_tmp ); // Q31 + v_multc_fx( sigR + L_FRAME16k / nSubframes, factor, sigR + L_FRAME16k / nSubframes, sub( s, idiv1616( L_FRAME16k, nSubframes ) ) ); // *q_sig } return; diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 26485b29f..fdca506b4 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -961,7 +961,6 @@ void ivas_set_surplus_brate_enc( dbgwrite( &tmpF, 4, 1, input_frame, "res/brate_MASA_MD" ); /* == MASA MD bitrate */ } #endif - return; } @@ -1222,8 +1221,8 @@ static void ivas_omasa_param_est_enc_fx( } /* Y */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins ); /*q*/ - v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins ); /*q*/ + v_multc_fx( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins ); /*q*/ + v_multc_fx( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins ); /*q*/ FOR( i = 1; i < nchan_ism; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[1][i], Foa_RealBuffer_fx[1], num_freq_bins ); /*q*/ @@ -1231,8 +1230,8 @@ static void ivas_omasa_param_est_enc_fx( } /* Z */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins ); /*q*/ - v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins ); /*q*/ + v_multc_fx( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins ); /*q*/ + v_multc_fx( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins ); /*q*/ FOR( i = 1; i < nchan_ism; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[2][i], Foa_RealBuffer_fx[2], num_freq_bins ); /*q*/ @@ -1241,8 +1240,8 @@ static void ivas_omasa_param_est_enc_fx( /* X */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins ); /*q*/ - v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins ); /*q*/ + v_multc_fx( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins ); /*q*/ + v_multc_fx( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins ); /*q*/ FOR( i = 1; i < nchan_ism; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_RealBuffer_fx[3], num_freq_bins ); /*q*/ @@ -1293,7 +1292,7 @@ static void ivas_omasa_param_est_enc_fx( Copy32( reference_power_fx[ts], &( hOMasa->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands ); hOMasa->buffer_energy_q[( index - 1 )] = sub( 31, ref_exp ); move16(); - computeDiffuseness_fixed( hOMasa->buffer_intensity_real_fx, hOMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hOMasa->buffer_intensity_real_q, hOMasa->buffer_energy_q, &q_diffuseness_vector ); + computeDiffuseness_fx( hOMasa->buffer_intensity_real_fx, hOMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hOMasa->buffer_intensity_real_q, hOMasa->buffer_energy_q, &q_diffuseness_vector ); FOR( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ ) { diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 5ab29f617..e537b32f4 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -353,21 +353,19 @@ ivas_error ivas_osba_enc_reconfig( /*-----------------------------------------------------------------* * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ + nchan_transport = st_ivas->nchan_transport; test(); test(); IF( old_ism_mode == ISM_MODE_NONE && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - { - nchan_transport = add( st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_ism ); - st_ivas->nCPE = shr_r( nchan_transport, 1 ); - } + nchan_transport = add( st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_ism ); + st_ivas->nCPE = shr_r( nchan_transport, 1 ); } ELSE IF( EQ_32( old_ism_mode, ISM_SBA_MODE_DISC ) && st_ivas->ism_mode == ISM_MODE_NONE ) { nchan_transport_old = add( nchan_transport_old, st_ivas->hEncoderConfig->nchan_ism ); - nchan_transport = st_ivas->nchan_transport; } ELSE IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) @@ -376,6 +374,7 @@ ivas_error ivas_osba_enc_reconfig( nchan_transport = add( st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_ism ); st_ivas->nCPE = shr_r( nchan_transport, 1 ); } + Word16 tmp_e; Word32 bitrate_per_chan = L_deposit_h( BASOP_Util_Divide3216_Scale( ivas_total_brate, st_ivas->nchan_transport, &tmp_e ) ); bitrate_per_chan = L_shr( bitrate_per_chan, sub( 15, tmp_e ) ); diff --git a/lib_enc/ivas_pca_enc_fx.c b/lib_enc/ivas_pca_enc_fx.c index 2cb347a02..7eb4f18e7 100644 --- a/lib_enc/ivas_pca_enc_fx.c +++ b/lib_enc/ivas_pca_enc_fx.c @@ -415,9 +415,9 @@ void ivas_pca_enc_fx( { temp_fx32 = r_sm_fx[k * FOA_CHANNELS + k]; // min_q move32(); - IF( LT_32( temp_fx32, L_shr( 64424, sub( 31, hPCA->old_r_sm_q ) ) ) ) // IVAS_PCA_COV_THRES in Q31 + IF( LT_32( temp_fx32, L_shr( 64424, sub( 31, hPCA->old_r_sm_q ) ) ) ) // IVAS_PCA_COV_THRES=3e-5f in Q31 { - temp_fx32 = L_shr( 64424, sub( 31, hPCA->old_r_sm_q ) ); // IVAS_PCA_COV_THRES in Q31 /*hPCA->old_r_sm_q */ + temp_fx32 = L_shr( 64424, sub( 31, hPCA->old_r_sm_q ) ); // IVAS_PCA_COV_THRES=3e-5f in Q31 /*hPCA->old_r_sm_q */ } r_sm_fx[k * FOA_CHANNELS + k] = temp_fx32; /* pointer reuse */ // hPCA->old_r_sm_q move32(); diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 6b56b36a3..c510f2e0a 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -885,9 +885,8 @@ void ivas_qmetadata_enc_sid_encode_fx( IF( EQ_16( ivas_format, SBA_FORMAT ) ) { - sba_spar_bitlen = ivas_sba_spar_sid_bitlen_fx( nchan_transport ); - metadata_sid_bits = (int16_t) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS - SBA_ORDER_BITS - SBA_PLANAR_BITS - 1; /* -1 for inactive mode header bit*/ + metadata_sid_bits = (Word16) ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS - SBA_ORDER_BITS - SBA_PLANAR_BITS - 1; /* -1 for inactive mode header bit*/ metadata_sid_bits = sub( metadata_sid_bits, sba_spar_bitlen ); } ELSE @@ -896,7 +895,6 @@ void ivas_qmetadata_enc_sid_encode_fx( move16(); } - /* Save initial position in bitstream */ bit_pos_start = hMetaData->nb_bits_tot; move16(); diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index 04b4049a7..5c8abb83a 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -732,9 +732,11 @@ static ivas_error ivas_spar_enc_process_fx( { Copy32( data_fx[HOA_keep_ind[i]], data_fx[i], input_frame ); } + /*-----------------------------------------------------------------------------------------* * Transient detector *-----------------------------------------------------------------------------------------*/ + ivas_transient_det_process_fx( hSpar->hTranDet, data_fx[0], input_frame, transient_det ); #ifdef DEBUGGING @@ -745,7 +747,6 @@ static ivas_error ivas_spar_enc_process_fx( dbgwrite_txt( a, 2, "fixed.txt", NULL ); } #endif - if ( LT_32( ivas_total_brate, IVAS_24k4 ) ) { transient_det[1] = 0; @@ -892,12 +893,14 @@ static ivas_error ivas_spar_enc_process_fx( /*-----------------------------------------------------------------------------------------* * Covariance and MD processing *-----------------------------------------------------------------------------------------*/ + IF( NE_32( ( error = ivas_spar_cov_md_process_fx( hEncoderConfig, st_ivas->hSpar, st_ivas->hQMetaData, hMetaData, nchan_inp, sba_order, ppIn_FR_real_fx, ppIn_FR_imag_fx, transient_det, dtx_vad, nchan_transport, &dyn_active_w_flag, pp_fr_q ) ), IVAS_ERR_OK ) ) { return error; } set16_fx( q_p_pcm_tmp_fx, pp_fr_q, nchan_fb_in ); + /*-----------------------------------------------------------------------------------------* * FB mixer *-----------------------------------------------------------------------------------------*/ @@ -974,6 +977,7 @@ static ivas_error ivas_spar_enc_process_fx( v_add_fx( data_fx[idx], p_pcm_tmp_fx[i] + num_del_samples, p_pcm_tmp_fx[i] + num_del_samples, sub( input_frame, num_del_samples ) ); } } + /*-----------------------------------------------------------------------------------------* * PCA encoder *-----------------------------------------------------------------------------------------*/ @@ -992,7 +996,6 @@ static ivas_error ivas_spar_enc_process_fx( } } - /*-----------------------------------------------------------------------------------------* * AGC *-----------------------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index 80c4b5a21..297cd9fe6 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -52,7 +52,7 @@ #define STEREO_DFT_NRG_PAST_MAX_BAND 9 #define STEREO_DFT_NRG_PAST_MAX_BAND_LB 4 -#define STEREO_DFT_DMX_CROSSOVER ( int16_t )( 132 * ( (float) ( STEREO_DFT_N_NS_ENC ) / STEREO_DFT_N_NS ) + 0.5f ) /* crossover bin between binwise and bandwise DMX */ +#define STEREO_DFT_DMX_CROSSOVER ( Word16 )( 132 * ( (float) ( STEREO_DFT_N_NS_ENC ) / STEREO_DFT_N_NS ) + 0.5f ) /* crossover bin between binwise and bandwise DMX */ #define ITD_VAD_E_BAND_N_INIT 200000 #define ITD_SID_PREV_FRAMES 5 diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index d0252a1f1..dd6f52ca0 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -703,7 +703,7 @@ static void utilCrossCorr_fx( *corrEst_e = max_e; move16(); - v_multc_fixed( corrEst, scale, corrEst, j ); + v_multc_fx( corrEst, scale, corrEst, j ); *corrEst_e = add( *corrEst_e, temp2_e ); move16(); @@ -1036,15 +1036,15 @@ static void corrStatsEst_fx( IF( LT_32( hStereoTCA->prevTargetGain_fx, 429496730 /*0.8f in Q29*/ ) && vad_flag1 ) { /* ch 2 is prev reference channel */ - v_multc_fixed( corrEst_fx, 644245095 /*1.2f in Q29*/, corrEst_fx, L_NCSHIFT_DS + 1 ); /* Q31-corrEst_exp */ - v_multc_fixed( corrEst_fx + L_NCSHIFT_DS + 1, 447213470 /* 0.833 in Q29*/, corrEst_fx + L_NCSHIFT_DS + 1, L_NCSHIFT_DS ); /* Q31-corrEst_exp */ + v_multc_fx( corrEst_fx, 644245095 /*1.2f in Q29*/, corrEst_fx, L_NCSHIFT_DS + 1 ); /* Q31-corrEst_exp */ + v_multc_fx( corrEst_fx + L_NCSHIFT_DS + 1, 447213470 /* 0.833 in Q29*/, corrEst_fx + L_NCSHIFT_DS + 1, L_NCSHIFT_DS ); /* Q31-corrEst_exp */ corrEst_exp = add( corrEst_exp, 2 ); } ELSE IF( GT_32( hStereoTCA->prevTargetGain_fx, 644245094 /*1.2f in Q29*/ ) && vad_flag1 ) { /* ch 1 is prev reference channel */ - v_multc_fixed( corrEst_fx, 447213470 /* 0.833 f in Q29*/, corrEst_fx, L_NCSHIFT_DS ); /* Q31-corrEst_exp */ - v_multc_fixed( corrEst_fx + L_NCSHIFT_DS, 644245095 /*1.2f in Q29*/, corrEst_fx + L_NCSHIFT_DS, L_NCSHIFT_DS + 1 ); /* Q31-corrEst_exp */ + v_multc_fx( corrEst_fx, 447213470 /* 0.833 f in Q29*/, corrEst_fx, L_NCSHIFT_DS ); /* Q31-corrEst_exp */ + v_multc_fx( corrEst_fx + L_NCSHIFT_DS, 644245095 /*1.2f in Q29*/, corrEst_fx + L_NCSHIFT_DS, L_NCSHIFT_DS + 1 ); /* Q31-corrEst_exp */ corrEst_exp = add( corrEst_exp, 2 ); } test(); @@ -1054,9 +1054,9 @@ static void corrStatsEst_fx( j = s_min( 2 * L_NCSHIFT_DS, add( hStereoTCA->prevCorrLagStats[0], 1 + L_NCSHIFT_DS ) ); k = add( sub( j, i ), 1 ); - v_multc_fixed( corrEst_fx, ONE_IN_Q29 /*1.0f in Q29*/, corrEst_fx, i ); // to allign in same exp (Q31-corrEst_exp) - v_multc_fixed( corrEst_fx + i, 644245095 /*1.2f in Q29*/, corrEst_fx + i, k ); /* Q31-corrEst_exp */ - v_multc_fixed( corrEst_fx + i + k, ONE_IN_Q29 /*1.0f in Q29*/, corrEst_fx + i + k, sub( 2 * L_NCSHIFT_DS + 1, i + k ) ); // to allign in same exp (Q31-corrEst_exp) + v_multc_fx( corrEst_fx, ONE_IN_Q29 /*1.0f in Q29*/, corrEst_fx, i ); // to allign in same exp (Q31-corrEst_exp) + v_multc_fx( corrEst_fx + i, 644245095 /*1.2f in Q29*/, corrEst_fx + i, k ); /* Q31-corrEst_exp */ + v_multc_fx( corrEst_fx + i + k, ONE_IN_Q29 /*1.0f in Q29*/, corrEst_fx + i + k, sub( 2 * L_NCSHIFT_DS + 1, i + k ) ); // to allign in same exp (Q31-corrEst_exp) corrEst_exp = add( corrEst_exp, 2 ); } @@ -1875,17 +1875,17 @@ void stereo_tca_enc_fx( IF( EQ_16( hStereoTCA->prevRefChanIndx, L_CH_INDX ) ) { - v_multc_fixed( bufChanL_fx, ONE_IN_Q29, bufChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q - 2*/ - Copy32( ptrChanL_fx - add( lMemRecalc, lMemRecalc_SCh ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q - 2 - v_multc_fixed( ptrChanR_fx + sub( prevNCShift, add( lMemRecalc, lMemRecalc_SCh ) ), hStereoTCA->prevTargetGain_fx, input_mem_loc_fx[1], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q-2 - v_multc_fixed( bufChanR_fx, ONE_IN_Q29, bufChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/ + v_multc_fx( bufChanL_fx, ONE_IN_Q29, bufChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q - 2*/ + Copy32( ptrChanL_fx - add( lMemRecalc, lMemRecalc_SCh ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q - 2 + v_multc_fx( ptrChanR_fx + sub( prevNCShift, add( lMemRecalc, lMemRecalc_SCh ) ), hStereoTCA->prevTargetGain_fx, input_mem_loc_fx[1], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q-2 + v_multc_fx( bufChanR_fx, ONE_IN_Q29, bufChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/ } ELSE { - v_multc_fixed( bufChanL_fx, ONE_IN_Q29, bufChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/ - Copy32( ptrChanL_fx + sub( prevNCShift, add( lMemRecalc, lMemRecalc_SCh ) ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2 - v_multc_fixed( ptrChanR_fx - add( lMemRecalc, lMemRecalc_SCh ), hStereoTCA->prevTargetGain_fx, input_mem_loc_fx[1], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2 - v_multc_fixed( bufChanR_fx, ONE_IN_Q29, bufChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/ + v_multc_fx( bufChanL_fx, ONE_IN_Q29, bufChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/ + Copy32( ptrChanL_fx + sub( prevNCShift, add( lMemRecalc, lMemRecalc_SCh ) ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2 + v_multc_fx( ptrChanR_fx - add( lMemRecalc, lMemRecalc_SCh ), hStereoTCA->prevTargetGain_fx, input_mem_loc_fx[1], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2 + v_multc_fx( bufChanR_fx, ONE_IN_Q29, bufChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/ } bufChan_q = sub( bufChan_q, 2 ); q_com = bufChan_q; @@ -1936,7 +1936,7 @@ void stereo_tca_enc_fx( } ELSE { - v_multc_fixed( target_fx - tempS, hStereoTCA->prevTargetGain_fx, &( input_mem_loc_fx[target_idx][lMemRecalc + lMemRecalc_SCh - tempS - currentNCShift] ), add( currentNCShift, tempS ) ); /* bufChan_q - 2 */ + v_multc_fx( target_fx - tempS, hStereoTCA->prevTargetGain_fx, &( input_mem_loc_fx[target_idx][lMemRecalc + lMemRecalc_SCh - tempS - currentNCShift] ), add( currentNCShift, tempS ) ); /* bufChan_q - 2 */ scale_sig32( input_mem_loc_fx[target_idx], sub( sub( add( lMemRecalc, lMemRecalc_SCh ), tempS ), currentNCShift ), -2 ); scale_sig32( &input_mem_loc_fx[target_idx][lMemRecalc + lMemRecalc_SCh], sub( NS2SA( 48000, L_MEM_RECALC_NS + L_MEM_RECALC_SCH_NS ), add( lMemRecalc, lMemRecalc_SCh ) ), -2 ); scale_sig32( input_mem_loc_fx[0], NS2SA( 48000, L_MEM_RECALC_NS + L_MEM_RECALC_SCH_NS ), -2 ); @@ -1988,12 +1988,12 @@ void stereo_tca_enc_fx( target_idx = L_CH_INDX; /* only to avoid compilation warning */ move16(); - v_multc_fixed( bufChanL_fx, ONE_IN_Q29, bufChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/ + v_multc_fx( bufChanL_fx, ONE_IN_Q29, bufChanL_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2*/ - Copy32( ptrChanL_fx - add( lMemRecalc, lMemRecalc_SCh ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2 - v_multc_fixed( ptrChanR_fx - add( lMemRecalc, lMemRecalc_SCh ), hStereoTCA->prevTargetGain_fx, input_mem_loc_fx[1], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2 + Copy32( ptrChanL_fx - add( lMemRecalc, lMemRecalc_SCh ), input_mem_loc_fx[0], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2 + v_multc_fx( ptrChanR_fx - add( lMemRecalc, lMemRecalc_SCh ), hStereoTCA->prevTargetGain_fx, input_mem_loc_fx[1], add( lMemRecalc, lMemRecalc_SCh ) ); // bufChan_q -2 - v_multc_fixed( bufChanR_fx, ONE_IN_Q29, bufChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2 */ + v_multc_fx( bufChanR_fx, ONE_IN_Q29, bufChanR_fx, L_MEM_RECALC_48K + L_MEM_RECALC_48k_SCH + L_FRAME48k + L_NCSHIFTMAX ); /* TO make in common Q bufChan_q -2 */ bufChan_q = sub( bufChan_q, 2 ); q_com = bufChan_q; move16(); diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 67ba071a0..025908f9d 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -735,7 +735,7 @@ void stereo_icBWE_enc_ivas_fx( test(); IF( LT_32( gTarget_fx, 268435456 ) || GT_32( gTarget_fx, 1073741824 ) ) // 0.5 in Q29 or 2.0 in Q29 { - v_multc_fixed( voice_factors_fx, 1073741824, nlMixFac_fx, NB_SUBFR16k ); // Q31, 0.5 in Q31 -> 1073741824 + v_multc_fx( voice_factors_fx, 1073741824, nlMixFac_fx, NB_SUBFR16k ); // Q31, 0.5 in Q31 -> 1073741824 } Word16 L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR; @@ -948,7 +948,7 @@ void stereo_icBWE_enc_ivas_fx( test(); IF( LT_32( gTarget_fx, 268435456 ) || GT_32( gTarget_fx, 1073741824 ) ) // 0.5 in Q29 & 2.0 in Q29 { - v_multc_fixed( voice_factors_fx, 1073741824 /*0.5 in Q31*/, nlMixFac_fx, NB_SUBFR16k ); /* Q31 */ + v_multc_fx( voice_factors_fx, 1073741824 /*0.5 in Q31*/, nlMixFac_fx, NB_SUBFR16k ); /* Q31 */ } Word16 L_FRAME16k_by_nbSubFr = L_FRAME16k / NB_SUBFR; diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index 23094eb22..55447fabb 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -429,15 +429,15 @@ void stereo_coder_tcx_fx( move32(); - v_multc_fixed( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[0], &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* exp: exp_spec+1 */ - v_multc_fixed( &mdst_spectrum_fx[0][k][startLine], nrgRatio_fx[0], &mdst_spectrum_fx[0][k][startLine], sfbWidth ); /* exp: exp_mdct_spec+1 */ - scale_sig32( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // exp: exp_spec - scale_sig32( &mdst_spectrum_fx[0][k][startLine], sfbWidth, Q1 ); // exp: exp_mdct_spec - - v_multc_fixed( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[1], &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* exp: exp_spec+1 */ - v_multc_fixed( &mdst_spectrum_fx[1][k][startLine], nrgRatio_fx[1], &mdst_spectrum_fx[1][k][startLine], sfbWidth ); /* exp: exp_mdct_spec+1 */ - scale_sig32( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // exp: exp_spec - scale_sig32( &mdst_spectrum_fx[1][k][startLine], sfbWidth, Q1 ); // exp: exp_mdct_spec + v_multc_fx( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[0], &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* exp: exp_spec+1 */ + v_multc_fx( &mdst_spectrum_fx[0][k][startLine], nrgRatio_fx[0], &mdst_spectrum_fx[0][k][startLine], sfbWidth ); /* exp: exp_mdct_spec+1 */ + scale_sig32( &sts[0]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // exp: exp_spec + scale_sig32( &mdst_spectrum_fx[0][k][startLine], sfbWidth, Q1 ); // exp: exp_mdct_spec + + v_multc_fx( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], nrgRatio_fx[1], &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth ); /* exp: exp_spec+1 */ + v_multc_fx( &mdst_spectrum_fx[1][k][startLine], nrgRatio_fx[1], &mdst_spectrum_fx[1][k][startLine], sfbWidth ); /* exp: exp_mdct_spec+1 */ + scale_sig32( &sts[1]->hTcxEnc->spectrum_fx[k][startLine], sfbWidth, Q1 ); // exp: exp_spec + scale_sig32( &mdst_spectrum_fx[1][k][startLine], sfbWidth, Q1 ); // exp: exp_mdct_spec } } } diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 469bf211a..1fb0f73dd 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -821,7 +821,7 @@ void stereo_switching_enc_fx( test(); IF( hCPE->hStereoTD != NULL && EQ_16( hCPE->hStereoTD->tdm_last_ratio_idx, LRTD_STEREO_LEFT_IS_PRIM ) ) { - v_multc_fixed( hCPE->hCoreCoder[1]->old_input_signal32_fx + sub( input_frame, add( offset, NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) ) ), -MAX_32, sts[1]->cldfbAnaEnc->cldfb_state_fx, offset ); /* Q16+q_inp */ + v_multc_fx( hCPE->hCoreCoder[1]->old_input_signal32_fx + sub( input_frame, add( offset, NS2SA_FX2( L_mult0( input_frame, FRAMES_PER_SEC ), L_MEM_RECALC_TBE_NS ) ) ), -MAX_32, sts[1]->cldfbAnaEnc->cldfb_state_fx, offset ); /* Q16+q_inp */ sts[1]->cldfbAnaEnc->Q_cldfb_state = q_inp; move16(); } diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 71b31130a..6e0fe1b27 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -274,6 +274,7 @@ void encod_gen_2sbfr( * Close-loop pitch search on the 1st and 3rd subfr only and quantization * Adaptive exc. construction *------------------------------------------------------------------------*/ + *pt_pitch = pit_encode_fx( st->hBstr, st->acelp_cfg.pitch_bits, st->core_brate, 0, L_frame, coder_type, &pitch_limit_flag, i_subfr, exc, 2 * L_SUBFR, st->pitch, &T0_min, &T0_max, &T0, &T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf #if !defined REUSE_EVS_ACELP_PITCH_NORM_CORR , @@ -303,6 +304,7 @@ void encod_gen_2sbfr( Scale_sig( h1, 2 * L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ lp_filt_exc_enc_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode ); + /* update long-term pitch gain for speech/music classifier */ st->hSpMusClas->lowrate_pitchGain = add( mult( 29491, st->hSpMusClas->lowrate_pitchGain ), mult( 3277 /*Q15*/, gain_pit ) ); // Q14 move16(); @@ -319,6 +321,7 @@ void encod_gen_2sbfr( gain_enc_lbr_fx( st->hBstr, st->acelp_cfg.gains_mode, coder_type, i_subfr, xn, y1, add( sub( Q_new, 1 ), shift ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, st->element_mode ); + IF( st->Opt_SC_VBR ) { if ( EQ_16( st->hSC_VBR->last_ppp_mode, 1 ) ) diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index 3b77bf3cd..6edc9304e 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -173,6 +173,7 @@ Word16 lp_filt_exc_enc_fx( return select; } + /*-------------------------------------------------------------------* * adpt_enr_fx() * @@ -180,20 +181,20 @@ Word16 lp_filt_exc_enc_fx( * This serves to decide about the filtering of the adaptive excitation *-------------------------------------------------------------------*/ -static Word16 adpt_enr_fx( /* o : adaptive excitation energy mant */ - const Word16 codec_mode, /* i : MODE1 or MODE2 */ - const Word16 *exc, /* i : excitation vector Q_new */ - const Word16 *h1, /* i : impuls response Q15 */ - Word16 *y1, /* o : zero-memory filtered adpt. excitation 12 bits */ - const Word16 L_subfr, /* i : vector length */ - Word16 *gain, /* o : subframe adaptive gain Q14 */ - Word16 *g_corr, /* o : correlations for adptive gain mant/exp*/ - const Word16 clip_gain, /* i : adaptive gain clipping flag Q0 */ - const Word16 *xn, /* i : adaptive codebook target 12 bits Q_new-1+shift*/ - Word16 *xn2, /* o : algebraic codebook target 12 bits Q_new-1+shift*/ - Word16 *exp_ener /* o : adaptive excitation energy exp */ - , - Word16 use_prev_sf_pit_gain /* i : flag to use prev sf pitch gain or not */ +/* o : adaptive excitation energy mant */ +static Word16 adpt_enr_fx( + const Word16 codec_mode, /* i : MODE1 or MODE2 */ + const Word16 *exc, /* i : excitation vector Q_new */ + const Word16 *h1, /* i : impuls response Q15 */ + Word16 *y1, /* o : zero-memory filtered adpt. excitation 12 bits */ + const Word16 L_subfr, /* i : vector length */ + Word16 *gain, /* o : subframe adaptive gain Q14 */ + Word16 *g_corr, /* o : correlations for adptive gain mant/exp*/ + const Word16 clip_gain, /* i : adaptive gain clipping flag Q0 */ + const Word16 *xn, /* i : adaptive codebook target 12 bits Q_new-1+shift*/ + Word16 *xn2, /* o : algebraic codebook target 12 bits Q_new-1+shift*/ + Word16 *exp_ener, /* o : adaptive excitation energy exp */ + Word16 use_prev_sf_pit_gain /* i : flag to use prev sf pitch gain or not */ ) { Word16 ener, i; @@ -274,14 +275,14 @@ static Word16 adpt_enr_fx( /* o : adaptive excitation * codebook excitation y1[]. ( and -2 ) *-------------------------------------------------------------------*/ -Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) */ - const Word16 xn_1[], /* i : target signal Q_new*/ - const Word16 y1_1[], /* i : filtered adaptive codebook excitation 12 bits*/ - Word16 g_corr[], /* o : correlations and -2 mant/exp*/ - const Word16 L_subfr, /* i : vector length */ - const Word16 norm_flag /* i : flag for constraining pitch contribution */ - , - Flag *Overflow_out /* o : propagating the Overflow flag to upper level */ +/* o : pitch gain (0..GAIN_PIT_MAX) */ +Word16 corr_xy1_fx( + const Word16 xn_1[], /* i : target signal Q_new*/ + const Word16 y1_1[], /* i : filtered adaptive codebook excitation 12 bits*/ + Word16 g_corr[], /* o : correlations and -2 mant/exp*/ + const Word16 L_subfr, /* i : vector length */ + const Word16 norm_flag, /* i : flag for constraining pitch contribution */ + Flag *Overflow_out /* o : propagating the Overflow flag to upper level */ ) { Word16 i; diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 505114459..4f407895e 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -1352,9 +1352,11 @@ void lsf_end_enc_fx( /* Update AR-predictor memories */ Copy( qlsf, st->mem_AR_fx, M ); + return; } + void lsf_end_enc_ivas_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 *lsf, /* i : LSF in the frequency domain (0..6400) x2.56*/ @@ -1366,8 +1368,7 @@ void lsf_end_enc_ivas_fx( Word16 *lpc_param, Word16 *no_indices, Word16 *bits_param_lpc, - Word16 coder_type_raw /* i : Coder type (LSF coder_type have some special cases)*/ - , + Word16 coder_type_raw, /* i : Coder type (LSF coder_type have some special cases)*/ const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ) { @@ -1438,10 +1439,11 @@ void lsf_end_enc_ivas_fx( move16(); } - /*----------------------------------------------------------------------------------- -* + /*------------------------------------------------------------------------------------* * Calculate the number of stages and levels for each stage based on allowed bit budget * Set absolute threshold for codebook-type decision logic depending on signal bandwidth - *------------------------------------------------------------------------------------ -*/ + *-------------------------------------------------------------------------------------*/ + IF( st->bwidth == NB ) { abs_threshold = SFNETLOWLIMIT_NB / 2; @@ -1458,6 +1460,7 @@ void lsf_end_enc_ivas_fx( /*--------------------------------------------------------------------------------* * LSF quantization of SID frames *--------------------------------------------------------------------------------*/ + IF( EQ_32( st->core_brate, SID_2k40 ) ) { lsfq_CNG_ivas_fx( hBstr, lsf, wghts, qlsf ); @@ -1473,8 +1476,8 @@ void lsf_end_enc_ivas_fx( * Calculate number of stages and levels for each stage based on the allowed bit allocation * (subtract one bit for LSF predictor selection) *----------------------------------------------------------------*/ - lsf_allocate_fx( sub( nBits, shr( predmode, 1 ) ), mode_lvq, mode_lvq_p, &stages0, &stages1, levels0, levels1, bits0, bits1 ); + lsf_allocate_fx( sub( nBits, shr( predmode, 1 ) ), mode_lvq, mode_lvq_p, &stages0, &stages1, levels0, levels1, bits0, bits1 ); /*--------------------------------------------------------------------------------* * LSF quantization of all other frames but SID frames @@ -1540,6 +1543,7 @@ void lsf_end_enc_ivas_fx( pred2[i] = add( pred0[i], mult( Predictors_fx[mode_lvq_p][i], sub( st->mem_AR_fx[i], pred0[i] ) ) ); Tmp2[i] = sub( lsf[i], pred2[i] ); } + /* Adaptive scaling factor (multiplier) is updated in order to reduce the amount of consecutive predictive frames in case of possible frame erasure. AR-predictive usage for VOICED mode is allowed to be higher than other modes. */ test(); @@ -1686,6 +1690,7 @@ void lsf_end_enc_ivas_fx( } } } + /*--------------------------------------------------------------------------* * Write indices to array *--------------------------------------------------------------------------*/ @@ -1871,7 +1876,6 @@ void lsf_end_enc_ivas_fx( } } - /*--------------------------------------------------------------------------* * De-quantize encoded LSF vector *--------------------------------------------------------------------------*/ @@ -1938,9 +1942,11 @@ void lsf_end_enc_ivas_fx( /* Update AR-predictor memories */ Copy( qlsf, st->mem_AR_fx, M ); + return; } + /*-------------------------------------------------------------------* * first_VQstages() * @@ -2113,6 +2119,7 @@ static void first_VQstages( /*------------------------------------------------------------* * Compute error vectors for each node *------------------------------------------------------------*/ + cs = 0; move16(); FOR( c = 0; c < maxC; c++ ) @@ -2137,6 +2144,7 @@ static void first_VQstages( return; } + static void first_VQstages_ivas_fx( const Word16 *const *cb, Word16 u[], /* i : vector to be encoded (prediction and mean removed) */ @@ -2303,6 +2311,7 @@ static void first_VQstages_ivas_fx( /*------------------------------------------------------------* * Compute error vectors for each node *------------------------------------------------------------*/ + cs = 0; move16(); FOR( c = 0; c < maxC; c++ ) @@ -2326,6 +2335,8 @@ static void first_VQstages_ivas_fx( return; } + + /*--------------------------------------------------------------------------- * vq_enc_lsf_lvq() * @@ -2386,7 +2397,6 @@ static Word32 vq_lvq_lsf_enc( first_VQstages( cb, u, levels, stagesVQ, w, M, MSVQ_MAXCNT, indices_firstVQ ); } - FOR( i = 0; i < maxC; i++ ) { Copy( pred, cand[i], M ); @@ -2446,6 +2456,7 @@ static Word32 vq_lvq_lsf_enc( return e[c2]; } + static Word32 vq_lvq_lsf_enc_ivas_fx( Word16 pred_flag, Word16 mode, @@ -2506,7 +2517,6 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( first_VQstages_ivas_fx( cb, u, levels, stagesVQ, w, M, MSVQ_MAXCNT, indices_firstVQ ); } - FOR( i = 0; i < maxC; i++ ) { Copy( pred, cand[i], M ); @@ -2564,6 +2574,8 @@ static Word32 vq_lvq_lsf_enc_ivas_fx( return e[c2]; } + + static void BcTcvq_1st_fx( Word16 x_fx[][2], /*x2.56*/ const Word16 CB_fx[][128][2], /*x2.56*/ @@ -2714,7 +2726,6 @@ static void BcTcvq_SubBlock_fx( Word16 stage1, stage2, state, prev_state, branch; Word16 index, bestCode, brCode[N_DIM]; Word16 temp16_fx; - Word32 dist_fx, minDist_fx, brDist_fx[N_DIM]; Word16 pred_fx[N_DIM], target_fx[N_DIM], brQuant_fx[N_DIM][N_DIM]; @@ -2723,7 +2734,6 @@ static void BcTcvq_SubBlock_fx( FOR( state = 0; state < NUM_STATE; state++ ) { - /* 1st branch search */ prev_state = NTRANS[0][state]; move16(); @@ -2921,8 +2931,11 @@ static Word32 BcTcvq_FixSearch_fx( move16(); minDist_fx = L_shr( minDist_fx, 2 ); /*2.56*2.56*Q(-5 - 2)*/ + return minDist_fx; } + + static Word16 optimalPath_fx( Word32 cDist_fx[][16], /*2.56*2.56*Q(-5 - 2)*/ Word32 blockDist_fx[], /*2.56*2.56*Q(-5 - 2)*/ @@ -3062,7 +3075,6 @@ static void buildCode_fx( set16_fx( BrIndex, 0, ( N_STAGE_VQ - 4 ) ); - FOR( stage = N_STAGE_VQ - 4; stage >= 1; stage-- ) { if ( GT_16( s[stage], 7 ) ) @@ -3101,6 +3113,8 @@ static void buildCode_fx( return; } + + static void BcTcvq_fx( Word16 snFlag, const Word16 *x_fx, // x2.65 diff --git a/lib_enc/pit_enc_fx.c b/lib_enc/pit_enc_fx.c index c62959799..de5c8379c 100644 --- a/lib_enc/pit_enc_fx.c +++ b/lib_enc/pit_enc_fx.c @@ -1,6 +1,7 @@ /*==================================================================================== EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 ====================================================================================*/ + #include #include #include "options.h" /* Compilation switches */ @@ -8,7 +9,6 @@ #include "rom_enc.h" /* Encoder static table prototypes */ #include "rom_com_fx.h" /* Static table prototypes */ #include "rom_com.h" /* Static table prototypes */ -//#include "prot_fx.h" /* Function prototypes */ #include "rom_basop_util.h" #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ @@ -54,30 +54,31 @@ static void limit_T0_voiced2( Word16 res, const Word16 *T_op, Word16 *T0_min, Wo /* _ None */ /*==============================================================================*/ -Word16 pit_encode_fx( /* o : Fractional pitch for each subframe */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 pitch_bits[], /* i : pitch bits */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *exc, /* i/o: pointer to excitation signal frame */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 *pitch, /* i : open loop pitch estimates in current frame */ - Word16 *T0_min, /* i/o: lower limit for close-loop search */ - Word16 *T0_max, /* i/o: higher limit for close-loop search */ - Word16 *T0, /* i/o: close loop integer pitch */ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch */ - const Word16 *h1, /* i : weighted filter input response */ - const Word16 *xn, /* i : target vector */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ +/* o : Fractional pitch for each subframe */ +Word16 pit_encode_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 pitch_bits[], /* i : pitch bits */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *exc, /* i/o: pointer to excitation signal frame */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 *pitch, /* i : open loop pitch estimates in current frame */ + Word16 *T0_min, /* i/o: lower limit for close-loop search */ + Word16 *T0_max, /* i/o: higher limit for close-loop search */ + Word16 *T0, /* i/o: close loop integer pitch */ + Word16 *T0_frac, /* i/o: close loop fractional part of the pitch */ + const Word16 *h1, /* i : weighted filter input response */ + const Word16 *xn, /* i : target vector */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ #if !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , - const Word16 element_mode, /* i : mode element */ - const Word16 Q_new /* i : scaling factor */ + , + const Word16 element_mode, /* i : mode element */ + const Word16 Q_new /* i : scaling factor */ #endif ) { @@ -235,6 +236,7 @@ Word16 pit_encode_fx( /* o : Fractional pitc #endif ); move16(); + pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max ); } ELSE IF( EQ_16( coder_type, VOICED ) ) @@ -566,6 +568,8 @@ Word16 pit_encode_fx( /* o : Fractional pitc return pitch_cl; } + + /*-------------------------------------------------------------------* * abs_pit_enc() * @@ -575,11 +579,12 @@ Word16 pit_encode_fx( /* o : Fractional pitc * fr_step = 4: pitch range encoded with 8 bits *-------------------------------------------------------------------*/ -Word16 abs_pit_enc_fx( /* o : pitch index */ - const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - const Word16 T0, /* i : integer pitch lag */ - const Word16 T0_frac /* i : pitch fraction */ +/* o : pitch index */ +Word16 abs_pit_enc_fx( + const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + const Word16 T0, /* i : integer pitch lag */ + const Word16 T0_frac /* i : pitch fraction */ ) { Word16 pitch_index = 0; @@ -764,11 +769,12 @@ Word16 abs_pit_enc_fx( /* o : pitch index * fr_step = 4: resolution 1/4 (frac = 0, 1, 2, or 3) *-------------------------------------------------------------------*/ -Word16 delta_pit_enc_fx( /* o : pitch index */ - const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/ - const Word16 T0, /* i : integer pitch lag */ - const Word16 T0_frac, /* i : pitch fraction */ - const Word16 T0_min /* i : delta search min */ +/* o : pitch index */ +Word16 delta_pit_enc_fx( + const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/ + const Word16 T0, /* i : integer pitch lag */ + const Word16 T0_frac, /* i : pitch fraction */ + const Word16 T0_min /* i : delta search min */ ) { Word16 pitch_index = 0; @@ -792,29 +798,31 @@ Word16 delta_pit_enc_fx( /* o : pitch index return pitch_index; } + /*-------------------------------------------------------------------* * pitch_fr4() * * Find the closed loop pitch period with 1/4 subsample resolution. *-------------------------------------------------------------------*/ -Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ - const Word16 exc[], /* i : excitation buffer Q_new*/ - const Word16 xn[], /* i : target signal Q_new-1+shift*/ - const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/ - const Word16 t0_min, /* i : minimum value in the searched range. Q0*/ - const Word16 t0_max, /* i : maximum value in the searched range. Q0*/ - Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */ - const Word16 i_subfr, /* i : flag to first subframe */ - const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */ - const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */ - const Word16 t0_fr1, /* i : minimum value for resolution 1 */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 L_subfr /* i : size of subframe */ +/* o : chosen integer pitch lag */ +Word16 pitch_fr4_fx( + const Word16 exc[], /* i : excitation buffer Q_new*/ + const Word16 xn[], /* i : target signal Q_new-1+shift*/ + const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/ + const Word16 t0_min, /* i : minimum value in the searched range. Q0*/ + const Word16 t0_max, /* i : maximum value in the searched range. Q0*/ + Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */ + const Word16 i_subfr, /* i : flag to first subframe */ + const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */ + const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */ + const Word16 t0_fr1, /* i : minimum value for resolution 1 */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 L_subfr /* i : size of subframe */ #if !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , - const Word16 element_mode, /* i : mode element */ - const Word16 Q_new /* i : scaling factor */ + , + const Word16 element_mode, /* i : mode element */ + const Word16 Q_new /* i : scaling factor */ #endif ) { @@ -880,6 +888,7 @@ Word16 pitch_fr4_fx( /* o : chosen integer pitch lag { norm_corr_fx( exc, xn, h, t_min, t_max, corr, L_subfr ); } + /*-----------------------------------------------------------------* * Find integer pitch *-----------------------------------------------------------------*/ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 5e2e14447..17646a27b 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -62,9 +62,7 @@ ivas_error acelp_core_enc_fx( Word16 *unbits_fx, /* o : number of unused bits Q0*/ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ const Word16 Q_new, - const Word16 shift - -); + const Word16 shift ); void analy_lp_fx( const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ @@ -106,6 +104,7 @@ void AVQ_encmux_fx( Word16 avq_bit_sFlag, /* i : flag for AVQ bit saving solution */ Word16 trgtSvPos /* i : target SV for AVQ bit savings */ ); + void bw_detect_fx( Encoder_State *st, /* i/o: Encoder State */ const Word16 signal_in[], /* i : input signal */ @@ -165,6 +164,7 @@ Word16 dtx_hangover_addition_fx( VAD_HANDLE hVAD, /* i/o: VAD data handle */ NOISE_EST_HANDLE hNoiseEst /* i : Noise estimation handle */ ); + Word16 ivas_dtx_hangover_addition_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 vad_flag, /* i Q0 */ @@ -174,6 +174,7 @@ Word16 ivas_dtx_hangover_addition_fx( VAD_HANDLE hVAD, /* i/o: VAD data handle */ NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ Word16 *rem_dtx_ho ); + void fb_tbe_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 new_input[], /* i : i speech at 48 kHz sample rate */ @@ -197,6 +198,7 @@ Word16 ffr_getSfWord32( const Word32 *vector, /*!< Pointer to i vector */ const Word16 len /*!< Length of i vector */ ); + void find_tilt_ivas_fx( const Word32 fr_bands[], /* i : energy in frequency bands q_fr_bands*/ const Word16 q_fr_bands, /* i : Q of fr_bands Q0*/ @@ -228,42 +230,43 @@ void find_tilt_fx( Word32 hp_E[], /* o : energy in HF Q_new + Q_SCALE*/ const Word16 codec_mode, /* i : MODE1 or MODE2 Q0*/ const Word16 Q_new, /* i : scaling factor */ - Word32 *bckr_tilt_lt /* i/o: lf/hf E ratio of background noise Q16*/ - , - Word16 Opt_vbr_mode /* Q0 */ -); - -Word16 find_uv_ivas_fx( /* o : coding type */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ - const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ - const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ - Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/ - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF q_hp_E*/ - Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ - const Word16 last_core_orig, /* i : original last core Q0*/ - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - const Word16 Q_new, - const Word16 q_hp_E ); - -Word16 find_uv_fx( /* o : coding type */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ - const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ - const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ - const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ - const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ - const Word16 relE, /* i : relative frame energy Q8*/ - const Word16 Etot, /* i : total energy Q8*/ - const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/ - const Word16 Q_new, - Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ - const Word16 shift, - const Word16 last_core_orig /* i : original last core Q0*/ + Word32 *bckr_tilt_lt, /* i/o: lf/hf E ratio of background noise Q16*/ + Word16 Opt_vbr_mode /* Q0 */ +); + +/* o : coding type */ +Word16 find_uv_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ + const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ + const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ + const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ + Word32 *dE1X, /* o : sudden energy increase for S/M classifier Q13*/ + const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ + const Word16 relE, /* i : relative frame energy Q8*/ + const Word16 Etot, /* i : total energy Q8*/ + const Word32 hp_E[], /* i : energy in HF q_hp_E*/ + Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ + const Word16 last_core_orig, /* i : original last core Q0*/ + STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ + const Word16 Q_new, + const Word16 q_hp_E ); + +/* o : coding type */ +Word16 find_uv_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6*/ + const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15*/ + const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/ + const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6*/ + const Word16 corr_shift, /* i : normalized correlation correction in noise Q15*/ + const Word16 relE, /* i : relative frame energy Q8*/ + const Word16 Etot, /* i : total energy Q8*/ + const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE*/ + const Word16 Q_new, + Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation Q0*/ + const Word16 shift, + const Word16 last_core_orig /* i : original last core Q0*/ ); void fine_gain_quant_fx( @@ -289,6 +292,7 @@ void long_enr_fx( const Word16 Etot, /* i : total channel E (see lib_enc\analy_sp.c) */ const Word16 localVAD_HE_SAD, /* i : HE-SAD flag without hangover */ Word16 high_lpn_flag ); + void ivas_long_enr_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word32 Etot, /* i : total channel E (see lib_enc\analy_sp.c) Q=24*/ @@ -300,12 +304,14 @@ void ivas_long_enr_fx( const Word16 Etot_LR[] /* i : total channel energy LR channels Q=8*/ ); -Word16 mdct_classifier_fx( /* o: MDCT A/B decision */ - const Word16 *Y, /* i: re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ - Encoder_State *st_fx, /* i/o: Encoder state variable */ - Word32 *cldfbBuf_Ener, - Word16 enerBuffer_exp, - const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ + +/* o: MDCT A/B decision */ +Word16 mdct_classifier_fx( + const Word16 *Y, /* i: re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */ + Encoder_State *st_fx, /* i/o: Encoder state variable */ + Word32 *cldfbBuf_Ener, + Word16 enerBuffer_exp, + const Word32 brate /* i : current brate, IVAS: nominal bitrate, EVS: st->total_brate */ ); void noise_est_down_fx( @@ -369,6 +375,7 @@ void noise_est_fx( Word16 S_map[], /* o : short-term correlation map Q7 */ const Word16 ini_frame /* i : Frame number (init) */ ); + void noise_est_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 old_pitch1, /* i : previous frame OL pitch[1] */ @@ -401,6 +408,7 @@ void noise_est_ivas_fx( FRONT_VAD_ENC_HANDLE hFrontVad, /* i/o: front-VAD handle */ const Word16 ini_frame /* i : Frame number (init) */ ); + void noise_est_pre_fx( const Word16 Etot, /* i : Energy of current frame */ const Word16 ini_frame_fx, /* i : Frame number (init) */ @@ -418,21 +426,17 @@ void noise_est_pre_32fx( const Word16 idchan, /* i : channel ID */ const Word16 element_mode, /* i : element mode */ const Word16 last_element_mode /* i : last element mode */ - ); void pitch_ol2_fx( - const Word16 pit_min, /* i : minimum pitch value (20 or 29) */ - const Word16 pitch_ol, /* i : pitch to be improved */ - Word16 *pitch_fr_fx, - /* o : adjusted 1/4 fractional pitch */ /*Q7*/ - Word16 *voicing_fr_fx, - /* o : adjusted 1/4 fractional voicing */ /*Q15*/ - const Word16 pos, /* i : position in frame where to calculate the improv. */ - const Word16 *wsp_fx, - /* i : weighted speech for current frame and look-ahead */ /*Q_new-1+shift*/ - const Word16 delta, /* i : delta for pitch search (2 or 7) */ - const Word16 element_mode /* i : EVS or IVAS */ + const Word16 pit_min, /* i : minimum pitch value (20 or 29) */ + const Word16 pitch_ol, /* i : pitch to be improved */ + Word16 *pitch_fr_fx, /* o : adjusted 1/4 fractional pitch Q7*/ + Word16 *voicing_fr_fx, /* o : adjusted 1/4 fractional voicing Q15*/ + const Word16 pos, /* i : position in frame where to calculate the improv. */ + const Word16 *wsp_fx, /* i : weighted speech for current frame and look-ahead Q_new-1+shift*/ + const Word16 delta, /* i : delta for pitch search (2 or 7) */ + const Word16 element_mode /* i : EVS or IVAS */ ); void pitch_ol_ivas_fx( @@ -503,19 +507,20 @@ void Scale_mem_enc( Word16 *last_exc_dct_in, Word16 *old_input_lp ); -Word32 Scale_mem_pre_proc( /* o : Min energy scaled */ - Word16 ini_frame_fx, /* i : Frame number Q0*/ - Word16 Q_exp, /* i : Diff scaling factor */ - Word16 *Q_new, /* i/o: Absolute scaling factor */ - Word16 *old_speech, /* i/o: Speech memory */ - Word16 *mem_wsp, /* i/o: wsp vector memory st->mem_wsp_q*/ - Word32 *enrO, /* i/o: Enr mem q_enrO*/ - Word32 *bckr, /* i/o: Back ground_fx ener mem q_bckr*/ - Word32 *ave_enr, /* i/o: Ave_enr mem Q_new + QSCALE*/ - Word32 *ave_enr2, /* i/o: Ave_enr2 mem Q_new + QSCALE*/ - Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame Q_new + QSCALE*/ - Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago Q_new + QSCALE*/ - Word32 *st_Bin_E_old ); +/* o : Min energy scaled */ +Word32 Scale_mem_pre_proc( + Word16 ini_frame_fx, /* i : Frame number Q0*/ + Word16 Q_exp, /* i : Diff scaling factor */ + Word16 *Q_new, /* i/o: Absolute scaling factor */ + Word16 *old_speech, /* i/o: Speech memory */ + Word16 *mem_wsp, /* i/o: wsp vector memory st->mem_wsp_q*/ + Word32 *enrO, /* i/o: Enr mem q_enrO*/ + Word32 *bckr, /* i/o: Back ground_fx ener mem q_bckr*/ + Word32 *ave_enr, /* i/o: Ave_enr mem Q_new + QSCALE*/ + Word32 *ave_enr2, /* i/o: Ave_enr2 mem Q_new + QSCALE*/ + Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame Q_new + QSCALE*/ + Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago Q_new + QSCALE*/ + Word32 *st_Bin_E_old ); void Scale_wsp( Word16 *wsp, /* i : Weigthed speech */ @@ -529,22 +534,24 @@ void Scale_wsp( const Word16 Len_p_look /* i : L_frame + look ahead Q0*/ ); -Word16 signal_clas_fx( /* o : classification for current frames */ - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *speech, /* i : pointer to speech signal for E computation */ - const Word32 *ee, /* i : lf/hf E ration for 2 half-frames */ - const Word16 relE, /* i : frame relative E to the long term average */ - const Word16 L_look, /* i : look-ahead */ - Word16 *uc_clas /* o : temporary classification used in music/speech class*/ +/* o : classification for current frames */ +Word16 signal_clas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *speech, /* i : pointer to speech signal for E computation */ + const Word32 *ee, /* i : lf/hf E ration for 2 half-frames */ + const Word16 relE, /* i : frame relative E to the long term average */ + const Word16 L_look, /* i : look-ahead */ + Word16 *uc_clas /* o : temporary classification used in music/speech class*/ ); -Word16 signal_clas_ivas_fx( /* o : classification for current frames */ - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 *speech, /* i : pointer to speech signal for E computation */ - const Word32 *ee, /* i : lf/hf E ration for 2 half-frames */ - const Word16 relE, /* i : frame relative E to the long term average */ - const Word16 L_look, /* i : look-ahead */ - Word16 *uc_clas /* o : temporary classification used in music/speech class*/ +/* o : classification for current frames */ +Word16 signal_clas_ivas_fx( + Encoder_State *st, /* i/o: encoder state structure */ + const Word16 *speech, /* i : pointer to speech signal for E computation */ + const Word32 *ee, /* i : lf/hf E ration for 2 half-frames */ + const Word16 relE, /* i : frame relative E to the long term average */ + const Word16 L_look, /* i : look-ahead */ + Word16 *uc_clas /* o : temporary classification used in music/speech class*/ ); void speech_music_classif_fx( @@ -634,17 +641,14 @@ void swb_CNG_enc_ivas_fx( ); void swb_pre_proc_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 *input_fx, /* i : original i signal */ - Word16 *new_swb_speech_fx, /* o : original i signal at 32kHz */ - Word16 *shb_speech_fx, /* o : SHB target signal (6-14kHz) at 16kHz */ - Word16 *Q_shb_spch /* o : shb target signal Q factor */ - , - Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* i : real buffer */ - , - Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* i : imag buffer */ - , - const CLDFB_SCALE_FACTOR *cldfbScale /* i : scale data of real and imag CLDFB buffers */ + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 *input_fx, /* i : original i signal */ + Word16 *new_swb_speech_fx, /* o : original i signal at 32kHz */ + Word16 *shb_speech_fx, /* o : SHB target signal (6-14kHz) at 16kHz */ + Word16 *Q_shb_spch, /* o : shb target signal Q factor */ + Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : real buffer */ + Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : imag buffer */ + const CLDFB_SCALE_FACTOR *cldfbScale /* i : scale data of real and imag CLDFB buffers */ ); void InitSWBencBufferStates_fx( @@ -691,20 +695,23 @@ Word16 tfaEnc_TBE_fx( const Word16 *pitch_buf, /* Q6 */ const Word16 Q_enr ); -Word32 VAD_Log2( Word32 i_s32Val, - Word16 i_s16Q ); +Word32 VAD_Log2( + Word32 i_s32Val, + Word16 i_s16Q ); -Word32 VAD_L_ADD( Word32 s32Mantissa1, - Word16 i_tExp1, - Word32 s32Mantissa2, - Word16 i_tExp2, - Word16 *s16Exp ); +Word32 VAD_L_ADD( + Word32 s32Mantissa1, + Word16 i_tExp1, + Word32 s32Mantissa2, + Word16 i_tExp2, + Word16 *s16Exp ); -Word32 VAD_L_div( Word32 L_var1, - Word32 L_var2, - Word16 Q_L_var1, - Word16 Q_L_var2, - Word16 *Q_OUT ); +Word32 VAD_L_div( + Word32 L_var1, + Word32 L_var2, + Word16 Q_L_var1, + Word16 Q_L_var2, + Word16 *Q_OUT ); void vad_param_updt_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -760,7 +767,6 @@ void wb_tbe_enc_ivas_fx( const Word16 pitch_buf[] /* i : pitch for each subframe Q6 */ ); - Word16 wb_vad_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 fr_bands[], /* i : per band i energy (contains 2 vectors) Q_new+QSCALE*/ @@ -793,14 +799,15 @@ Word16 wb_vad_ivas_fx( Word16 lp_noise /* i : long term noise energy */ ); -Word32 construct_snr_thresh_fx( Word16 sp_center[], /*(i) spectral center Q10*/ - Word32 snr_flux, /*(i) snr flux Q25*/ - Word32 lt_snr, /*(i) long time time domain snr Q25*/ - Word32 l_snr, /*(i) long time frequency domain snr Q25*/ - Word32 continuous_speech_num, /*(i) amount of continuous speech frames Q0*/ - Word16 continuous_noise_num, /*(i) amount of continuous noise frames Q0*/ - Word32 fg_energy_est_start, /*(i) whether if estimated energy Q0*/ - Word16 bw_index /*(i) band width index Q0*/ +Word32 construct_snr_thresh_fx( + Word16 sp_center[], /*(i) spectral center Q10*/ + Word32 snr_flux, /*(i) snr flux Q25*/ + Word32 lt_snr, /*(i) long time time domain snr Q25*/ + Word32 l_snr, /*(i) long time frequency domain snr Q25*/ + Word32 continuous_speech_num, /*(i) amount of continuous speech frames Q0*/ + Word16 continuous_noise_num, /*(i) amount of continuous noise frames Q0*/ + Word32 fg_energy_est_start, /*(i) whether if estimated energy Q0*/ + Word16 bw_index /*(i) band width index Q0*/ ); void sc_vbr_enc_init_fx( @@ -813,28 +820,42 @@ void updt_enc_common_fx( const Word16 Q_new /* i : CUrrent frame scaling */ ); -void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ); - -Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) */ - const Word16 xn_1[], /* i : target signal */ - const Word16 y1_1[], /* i : filtered adaptive codebook excitation */ - Word16 g_corr[], /* o : correlations and -2 */ - const Word16 L_subfr, /* i : vector length */ - const Word16 norm_flag /* i : flag for constraining pitch contribution */ - , - Flag *Overflow_out /* o : propagating the Overflow flag to upper level */ -); - -Word16 E_ACELP_indexing_fx( const Word16 code[] /*Q9*/, const PulseConfig *config, Word16 num_tracks /*Q0*/, Word16 prm[] /*Q(shift_bits)*/ ); -void fcb_pulse_track_joint_fx( UWord16 *idxs /*Q0*/, Word16 wordcnt /*Q0*/, UWord32 *index_n /*Q0*/, Word16 *pulse_num /*Q0*/, Word16 track_num /*Q0*/ ); +void attenuateNbSpectrum_fx( + Word16 L_frame, + Word32 *spectrum ); + +/* o : pitch gain (0..GAIN_PIT_MAX) */ +Word16 corr_xy1_fx( + const Word16 xn_1[], /* i : target signal */ + const Word16 y1_1[], /* i : filtered adaptive codebook excitation */ + Word16 g_corr[], /* o : correlations and -2 */ + const Word16 L_subfr, /* i : vector length */ + const Word16 norm_flag, /* i : flag for constraining pitch contribution */ + Flag *Overflow_out /* o : propagating the Overflow flag to upper level */ +); + +Word16 E_ACELP_indexing_fx( + const Word16 code[] /*Q9*/, + const PulseConfig *config, + Word16 num_tracks /*Q0*/, + Word16 prm[] /*Q(shift_bits)*/ ); + +void fcb_pulse_track_joint_fx( + UWord16 *idxs /*Q0*/, + Word16 wordcnt /*Q0*/, + UWord32 *index_n /*Q0*/, + Word16 *pulse_num /*Q0*/, + Word16 track_num /*Q0*/ ); + +/* o: quantization index */ +Word16 gain_quant_fx( + Word32 *gain, /* i/o: quantized gain */ + Word16 *gain16, + const Word16 c_min, /* i: log10 of lower limit in Q14 */ + const Word16 c_max, /* i: log10 of upper limit in Q13 */ + const Word16 bits, /* i: number of bits to quantize */ + Word16 *expg ); -Word16 gain_quant_fx( /* o: quantization index */ - Word32 *gain, /* i/o: quantized gain */ - Word16 *gain16, - const Word16 c_min, /* i: log10 of lower limit in Q14 */ - const Word16 c_max, /* i: log10 of upper limit in Q13 */ - const Word16 bits, /* i: number of bits to quantize */ - Word16 *expg ); void gsc_enc_fx( Encoder_State *st_fx, /* i/o: State structure */ Word16 res_dct_in[], /* i : dct of residual signal */ @@ -942,6 +963,7 @@ Word16 peak_avrg_ratio_fx( Word16 *mode_count, /* i/o: HQ_HARMONIC mode count Q0*/ Word16 *mode_count1, /* i/o: HQ_NORMAL mode count Q0*/ Word16 Q_coeff ); + Word16 peak_avrg_ratio_ivas_fx( const Word32 total_brate, /* Q0 */ const Word32 *input_hi_fx, /* i : i signal Q_coeff*/ @@ -949,6 +971,7 @@ Word16 peak_avrg_ratio_ivas_fx( Word16 *mode_count, /* i/o: HQ_HARMONIC mode count Q0*/ Word16 *mode_count1, /* i/o: HQ_NORMAL mode count Q0*/ Word16 Q_coeff ); + void hvq_classifier_ivas_fx( const Word32 *input, /* i : input signal Q12 */ Word16 *prev_Npeaks, /* i/o: Peak number memory Q0 */ @@ -962,8 +985,9 @@ void hvq_classifier_ivas_fx( Word16 *hvq_hangover, /* i/o: Mode-switch hangover Q0 */ Word32 *L_pe_gains /* o : peak gains Q12 */ ); + void pit16k_Q_enc_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 nBits, /* i : # of Q bits */ const Word16 limit_flag, /* i : restrained(0) or extended(1) Q limits */ const Word16 T0, /* i : integer pitch lag */ @@ -971,25 +995,28 @@ void pit16k_Q_enc_fx( Word16 *T0_min, /* i/o: delta search min */ Word16 *T0_max /* o : delta search max */ ); -Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */ - const Word16 exc[], /* i : excitation buffer Q_new*/ - const Word16 xn[], /* i : target signal Q_new-1+shift*/ - const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/ - const Word16 t0_min, /* i : minimum value in the searched range. Q0*/ - const Word16 t0_max, /* i : maximum value in the searched range. Q0*/ - Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */ - const Word16 i_subfr, /* i : flag to first subframe */ - const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */ - const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */ - const Word16 t0_fr1, /* i : minimum value for resolution 1 */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 L_subfr /* i : size of subframe */ + +/* o : chosen integer pitch lag */ +Word16 pitch_fr4_fx( + const Word16 exc[], /* i : excitation buffer Q_new*/ + const Word16 xn[], /* i : target signal Q_new-1+shift*/ + const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/ + const Word16 t0_min, /* i : minimum value in the searched range. Q0*/ + const Word16 t0_max, /* i : maximum value in the searched range. Q0*/ + Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */ + const Word16 i_subfr, /* i : flag to first subframe */ + const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */ + const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */ + const Word16 t0_fr1, /* i : minimum value for resolution 1 */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 L_subfr /* i : size of subframe */ #if !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , - const Word16 element_mode, /* i : mode element */ - const Word16 Q_new /* i : scaling factor */ + , + const Word16 element_mode, /* i : mode element */ + const Word16 Q_new /* i : scaling factor */ #endif ); + void pit_Q_enc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -1002,9 +1029,12 @@ void pit_Q_enc_fx( Word16 *T0_min, /* i/o: delta search min */ Word16 *T0_max /* o : delta search max */ ); -void PsychAdaptLowFreqEmph_fx( Word32 x[], - const Word16 lpcGains[], - const Word16 lpcGains_e[] ); + +void PsychAdaptLowFreqEmph_fx( + Word32 x[], + const Word16 lpcGains[], + const Word16 lpcGains_e[] ); + void set_bw_fx( const Word16 element_mode, /* i : element mode */ const Word32 element_brate, /* i : element bitrate */ @@ -1016,25 +1046,27 @@ void set_bw_stereo_fx( CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structures */ ); -Word16 WB_BWE_encoding_fx( /* o : classification of wb signal */ - const Word16 coder_type, /* i : coder type */ - const Word16 *yos_fx, /* i : MDCT coefficients of weighted original */ - Word16 *WB_fenv_fx, /* i/o: energy of WB envelope */ - Encoder_State *st_fx, /* i/o: Encoder structure */ - Word16 Q_synth, - Word16 Q_synth_lf ); +/* o : classification of wb signal */ +Word16 WB_BWE_encoding_fx( + const Word16 coder_type, /* i : coder type */ + const Word16 *yos_fx, /* i : MDCT coefficients of weighted original */ + Word16 *WB_fenv_fx, /* i/o: energy of WB envelope */ + Encoder_State *st_fx, /* i/o: Encoder structure */ + Word16 Q_synth, + Word16 Q_synth_lf ); -Word16 WB_BWE_encoding_ivas_fx( /* o : classification of wb signal */ - Encoder_State *st_fx, /* i/o: Encoder structure */ - const Word32 *yos_fx, /* i : MDCT coefficients of weighted original */ - Word16 *WB_fenv_fx, /* i/o: energy of WB envelope */ - Word16 Q_synth, - Word16 Q_synth_lf ); +/* o : classification of wb signal */ +Word16 WB_BWE_encoding_ivas_fx( + Encoder_State *st_fx, /* i/o: Encoder structure */ + const Word32 *yos_fx, /* i : MDCT coefficients of weighted original */ + Word16 *WB_fenv_fx, /* i/o: energy of WB envelope */ + Word16 Q_synth, + Word16 Q_synth_lf ); void calculate_hangover_attenuation_gain_fx( Encoder_State *st, /* i : encoder state structure */ Word16 *att, /* o : attenuation factor */ - const Word16 vad_hover_flag /* i : VAD hangover flag */ + const Word16 vad_hover_flag /* i : VAD hangover flag */ ); /*transient_detection.h*/ @@ -1045,14 +1077,16 @@ void calculate_hangover_attenuation_gain_fx( * Don't include the delay of the MDCT overlap. * @param pTransientDetection Structure to be initialized. It contains all transient detectors to be used. */ -void InitTransientDetection_fx( Word16 nFrameLength, - Word16 nTCXDelay, - struct TransientDetection *pTransientDetection ); +void InitTransientDetection_fx( + Word16 nFrameLength, + Word16 nTCXDelay, + struct TransientDetection *pTransientDetection ); -void InitTransientDetection_ivas_fx( Word16 nFrameLength, - Word16 nTCXDelay, - TRAN_DET_HANDLE pTransientDetection, - const Word16 ext_mem_flag ); +void InitTransientDetection_ivas_fx( + Word16 nFrameLength, + Word16 nTCXDelay, + TRAN_DET_HANDLE pTransientDetection, + const Word16 ext_mem_flag ); /** Runs transient detection. * Runs all transient detectors defined in pTransientDetection @@ -1061,8 +1095,10 @@ void InitTransientDetection_ivas_fx( Word16 nFrameLength, * @param nSamplesAvailable Number of new i samples available. * @param pTransientDetection Structure that contains transient detectors to be run. */ -void RunTransientDetection_fx( Word16 const *i, Word16 nSamplesAvailable, struct TransientDetection *pTransientDetection ); - +void RunTransientDetection_fx( + Word16 const *i, + Word16 nSamplesAvailable, + struct TransientDetection *pTransientDetection ); void RunTransientDetection_ivas_fx( Word16 *input_fx, /* i : input signal Q: q_input */ @@ -1088,16 +1124,18 @@ Word32 GetTCXAvgTemporalFlatnessMeasure_ivas_fx( struct TransientDetection const * @param nPrevSubblocks Number of subblocks from the previous frames to use for the calculation. * @param maximum energy change with exponent NRG_CHANGE_E */ -Word16 GetTCXMaxenergyChange_fx( struct TransientDetection const *pTransientDetection, - const Word8 isTCX10, - const Word16 nCurrentSubblocks, - const Word16 nPrevSubblocks ); +Word16 GetTCXMaxenergyChange_fx( + struct TransientDetection const *pTransientDetection, + const Word8 isTCX10, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ); -Word16 GetTCXMaxenergyChange_ivas_fx( TRAN_DET_HANDLE hTranDet, - const Word8 isTCX10, - const Word16 nCurrentSubblocks, - const Word16 nPrevSubblocks ); +Word16 GetTCXMaxenergyChange_ivas_fx( + TRAN_DET_HANDLE hTranDet, + const Word8 isTCX10, + const Word16 nCurrentSubblocks, + const Word16 nPrevSubblocks ); /** Set TCX window length and overlap configuration * @param prevEnergyHF previous HF energy. Exponent must be the same as for currEnergyHF. @@ -1113,9 +1151,10 @@ void SetTCXModeInfo_ivas_fx( * @param prevEnergyHF previous HF energy. Exponent must be the same as for currEnergyHF. * @param currEnergyHF current HF energy. Exponent must be the same as for prevEnergyHF. */ -void SetTCXModeInfo_fx( Encoder_State *st, - struct TransientDetection const *pTransientDetection, - Word16 *tcxModeOverlap ); +void SetTCXModeInfo_fx( + Encoder_State *st, + struct TransientDetection const *pTransientDetection, + Word16 *tcxModeOverlap ); void GSC_enc_init_fx( GSC_ENC_HANDLE hGSCEnc /* i/o: GSC data handle */ @@ -1208,6 +1247,7 @@ void ProcessIGF_fx( Word16 isTransition, /**< in: flag indicating if the i is the transition from from ACELP to TCX20/TCX10 */ Word16 frameno /**< in: flag indicating index of current subframe */ ); + void AnalyzePowerSpectrum_fx( Encoder_State *st, /* i/o: encoder states */ Word16 L_frame, /* i : frame length */ @@ -1233,35 +1273,43 @@ void AnalyzePowerSpectrum_ivas_fx( Word32 powerSpec[], /* o : Power spectrum. Can point to signal */ Word16 powerSpec_e[] ); -void AdaptLowFreqEmph_fx( Word32 x[], - Word16 x_e, - Word16 xq[], - Word16 invGain, - Word16 invGain_e, - Word16 tcx_lpc_shaped_ari, - Word16 lpcGains[], - Word16 lpcGains_e[], - const Word16 lg ); -Word16 SQ_gain_fx( /* o : SQ gain */ - Word32 x[], /* i : vector to quantize */ - Word16 x_e, /* i : exponent */ - Word16 nbitsSQ, /* i : number of bits targeted */ - Word16 lg, /* i : vector size (2048 max) */ - Word16 *gain_e ); /* o : SQ gain exponent */ - -Word16 SQ_gain_ivas_fx( /* o : SQ gain */ - Word32 x[], /* i : vector to quantize */ - Word16 x_e, /* i : exponent */ - Word16 nbitsSQ, /* i : number of bits targeted */ - Word16 lg, /* i : vector size (2048 max) */ - Word16 *gain_e ); /* o : SQ gain exponent */ - -Word16 SQ_gain_estimate_fx( /* o : SQ gain */ - Word32 x[], /* i : vector to quantize */ - Word16 x_e, /* i : exponent */ - Word16 nbitsSQ, /* i : number of bits targeted */ - Word16 lg, /* i : vector size (2048 max) */ - Word16 *gain_e ); /* o : SQ gain exponent */ +void AdaptLowFreqEmph_fx( + Word32 x[], + Word16 x_e, + Word16 xq[], + Word16 invGain, + Word16 invGain_e, + Word16 tcx_lpc_shaped_ari, + Word16 lpcGains[], + Word16 lpcGains_e[], + const Word16 lg ); + +/* o : SQ gain */ +Word16 SQ_gain_fx( + Word32 x[], /* i : vector to quantize */ + Word16 x_e, /* i : exponent */ + Word16 nbitsSQ, /* i : number of bits targeted */ + Word16 lg, /* i : vector size (2048 max) */ + Word16 *gain_e /* o : SQ gain exponent */ +); + +/* o : SQ gain */ +Word16 SQ_gain_ivas_fx( + Word32 x[], /* i : vector to quantize */ + Word16 x_e, /* i : exponent */ + Word16 nbitsSQ, /* i : number of bits targeted */ + Word16 lg, /* i : vector size (2048 max) */ + Word16 *gain_e /* o : SQ gain exponent */ +); + +/* o : SQ gain */ +Word16 SQ_gain_estimate_fx( + Word32 x[], /* i : vector to quantize */ + Word16 x_e, /* i : exponent */ + Word16 nbitsSQ, /* i : number of bits targeted */ + Word16 lg, /* i : vector size (2048 max) */ + Word16 *gain_e /* o : SQ gain exponent */ +); void tcx_scalar_quantization_fx( Word32 *x, /* i: i coefficients */ @@ -1370,6 +1418,7 @@ void tcx_encoder_memory_update_fx( Word16 *synthout, /* o: synthesis signal */ Word16 Q_new, Word16 shift ); + Word16 tcx_ari_res_Q_spec_fx( const Word32 x_orig[], /* i: original spectrum Q31-e */ Word16 x_orig_e, /* i: original spectrum exponent Q0 */ @@ -1439,19 +1488,21 @@ Word16 tcx_res_Q_spec_ivas_fx( const Word16 lf_deemph_factors[] ); /* compute noise-measure flags for spectrum filling and quantization (0: tonal, 1: noise-like) */ -void ComputeSpectrumNoiseMeasure_fx( const Word32 *powerSpec, - Word16 L_frame, - Word16 startLine, - Word8 resetMemory, - Word8 *noiseFlags, - Word16 lowpassLine ); +void ComputeSpectrumNoiseMeasure_fx( + const Word32 *powerSpec, + Word16 L_frame, + Word16 startLine, + Word8 resetMemory, + Word8 *noiseFlags, + Word16 lowpassLine ); -void ComputeSpectrumNoiseMeasure_ivas_fx( Word64 *powerSpec, /* Qx */ - Word16 L_frame, /* Q0 */ - Word16 startLine, /* Q0 */ - Word8 resetMemory, /* Q0 */ - Word8 *noiseFlags, /* Q0 */ - Word16 lowpassLine /* Q0 */ +void ComputeSpectrumNoiseMeasure_ivas_fx( + Word64 *powerSpec, /* Qx */ + Word16 L_frame, /* Q0 */ + Word16 startLine, /* Q0 */ + Word8 resetMemory, /* Q0 */ + Word8 *noiseFlags, /* Q0 */ + Word16 lowpassLine /* Q0 */ ); void lpc_quantization_fx( @@ -1507,7 +1558,17 @@ void Mode2_pit_encode_fx( Word16 pit_fr2, Word16 pit_max, Word16 pit_res_max ); -void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const Word16 H[] /*Q12*/, Word16 code[] /*Q9*/, const PulseConfig *config, Word16 ind[] /*Q0*/, Word16 y[] /*Qy*/, const Word16 element_mode ); + +void E_ACELP_4tsearch_fx( + Word16 dn[] /*Qdn*/, + const Word16 cn[] /*Q_xn*/, + const Word16 H[] /*Q12*/, + Word16 code[] /*Q9*/, + const PulseConfig *config, + Word16 ind[] /*Q0*/, + Word16 y[] /*Qy*/, + const Word16 element_mode ); + void E_ACELP_4t_fx( Word16 dn[], /* Qdn */ Word16 cn[] /* Q_xn */, @@ -1579,13 +1640,14 @@ TNS is tested on the spectrum defined by pSpectrum. * @param pTnsData TNS data is filled with sensible information. * @return Returns 1 if Tns should be used, otherwise 0. */ -Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ - Word32 const pSpectrum[], /* i : MDCT spectrum Q=Qx */ - STnsData *pTnsData, /* o : TNS data struct */ - TRAN_DET_HANDLE hTranDet, /* i : transient detection handle */ - Word8 isTCX10, /* i : TCX10 or TCX20? */ - Word16 ltp_gain, /* i : LTP gain Q=15 */ - Word16 *predictionGain /* o : TNS prediction gain Q=7 */ +Word16 DetectTnsFilt_ivas_fx( + STnsConfig const *pTnsConfig, /* i : TNS Configuration struct */ + Word32 const pSpectrum[], /* i : MDCT spectrum Q=Qx */ + STnsData *pTnsData, /* o : TNS data struct */ + TRAN_DET_HANDLE hTranDet, /* i : transient detection handle */ + Word8 isTCX10, /* i : TCX10 or TCX20? */ + Word16 ltp_gain, /* i : LTP gain Q=15 */ + Word16 *predictionGain /* o : TNS prediction gain Q=7 */ ); @@ -1598,11 +1660,12 @@ Word16 DetectTnsFilt_ivas_fx( STnsConfig const *pTnsConfig, /* i : TNS Configur * @param pnBits Set to the number of required. * @return 0 on success, otherwise 1. */ -Word16 EncodeTnsData_fx( STnsConfig const *pTnsConfig, - STnsData const *pTnsData, - Word16 *stream, - Word16 *pnSize, - Word16 *pnBits ); +Word16 EncodeTnsData_fx( + STnsConfig const *pTnsConfig, + STnsData const *pTnsData, + Word16 *stream, + Word16 *pnSize, + Word16 *pnBits ); /** Write TNS data into a bitstream. * Writes TNS data into a bitstream. @@ -1613,17 +1676,19 @@ Word16 EncodeTnsData_fx( STnsConfig const *pTnsConfig, * @param pnBits Set to the number of bits written. * @return 0 on success, otherwise 1. */ -Word16 WriteTnsData_fx( STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - Encoder_State *st, - Word16 *pnBits ); - -Word16 WriteTnsData_ivas_fx( STnsConfig const *pTnsConfig, - Word16 const *stream, - Word16 *pnSize, - BSTR_ENC_HANDLE hBstr, - Word16 *pnBits ); +Word16 WriteTnsData_fx( + STnsConfig const *pTnsConfig, + Word16 const *stream, + Word16 *pnSize, + Encoder_State *st, + Word16 *pnBits ); + +Word16 WriteTnsData_ivas_fx( + STnsConfig const *pTnsConfig, + Word16 const *stream, + Word16 *pnSize, + BSTR_ENC_HANDLE hBstr, + Word16 *pnBits ); void subband_FFT_fx( Word32 **Sr, /*(i) real part of the CLDFB*/ @@ -1632,6 +1697,7 @@ void subband_FFT_fx( Word32 Offset, /*(i) offset of the CLDFB*/ Word16 *fftoQ /*(o) the Scaling */ ); + Word16 E_ACELP_toeplitz_mul_fx( const Word16 R[], /* Q9 */ const Word16 c[], /* Qx */ @@ -1639,7 +1705,13 @@ Word16 E_ACELP_toeplitz_mul_fx( const Word16 L_subfr, /* Q0 */ const Word16 highrate /* Q0 */ ); -Word16 E_ACELP_code43bit_fx( const Word16 code[], UWord32 *ps, Word16 *p, UWord16 idxs[] ); + +Word16 E_ACELP_code43bit_fx( + const Word16 code[], + UWord32 *ps, + Word16 *p, + UWord16 idxs[] ); + void tc_classif_enc_fx( const Word16 Q_new, /* i : scaling factor */ const Word16 L_frame, /* i : length of the frame */ @@ -1664,6 +1736,7 @@ Word16 gain_enc_uv_fx( Word16 *gain_inov, /*0=rel */ - const Word32 sr_core /* i : internal sampling rate */ +/* o : number of allocated bits */ +Word16 vlpc_2st_cod_fx( + const Word16 *lsf, /* i : normalized vector to quantize */ + Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */ + Word16 *indx, /* o : index[] (4 bits per words) */ + const Word16 mode, /* i : 0=abs, >0=rel */ + const Word32 sr_core /* i : internal sampling rate */ ); Word16 update_decision_fx( @@ -3165,9 +3317,10 @@ void spec_center_fx( const Word16 Q_sb_p /* i : the Scaling of sb_power*/ ); -void spec_flatness_fx( Word32 *spec_amp, /*(i) spectral amplitude*/ - Word32 smooth_spec_amp[], /*(i) smoothed spectral amplitude*/ - Word16 sSFM[SFM_NUM] /*(o) spectral flatness rate*/ +void spec_flatness_fx( + Word32 *spec_amp, /*(i) spectral amplitude*/ + Word32 smooth_spec_amp[], /*(i) smoothed spectral amplitude*/ + Word16 sSFM[SFM_NUM] /*(o) spectral flatness rate*/ ); void SetModeIndex_fx( @@ -3188,6 +3341,7 @@ void MDCT_selector_fx( void MDCT_selector_reset_fx( TCX_ENC_HANDLE hTcxEnc ); + void MDCT_classifier_reset_fx( TCX_ENC_HANDLE hTcxEnc /* i/o: TCX Encoder Handle */ ); @@ -3199,6 +3353,7 @@ void ltd_stable_fx( const Word16 frameloop, /* i : amount of frames*/ const Word16 Q_frames_power /* i : the Scaling of frames_power*/ ); + /* IGFSCFEncoder.c */ void IGFSCFEncoderOpen_fx( IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data */ @@ -3264,22 +3419,23 @@ void background_update_fx( ); /* enc_gain.c */ -Word16 E_GAIN_closed_loop_search_fx( Word16 exc[], /*Q_new*/ - Word16 xn[], /*Q_xn*/ - Word16 h[], /* Q14+shift */ - Word16 t0_min, - Word16 t0_min_frac, - Word16 t0_max, - Word16 t0_max_frac, - Word16 t0_min_max_res, - Word16 *pit_frac, - Word16 *pit_res, - Word16 pit_res_max, - Word16 i_subfr, - Word16 pit_min, - Word16 pit_fr2, - Word16 pit_fr1, - Word16 L_subfr ); +Word16 E_GAIN_closed_loop_search_fx( + Word16 exc[], /*Q_new*/ + Word16 xn[], /*Q_xn*/ + Word16 h[], /* Q14+shift */ + Word16 t0_min, + Word16 t0_min_frac, + Word16 t0_max, + Word16 t0_max_frac, + Word16 t0_min_max_res, + Word16 *pit_frac, + Word16 *pit_res, + Word16 pit_res_max, + Word16 i_subfr, + Word16 pit_min, + Word16 pit_fr2, + Word16 pit_fr1, + Word16 L_subfr ); void core_acelp_tcx20_switching_fx( Encoder_State *st, /* i/o: encoder state structure */ @@ -3305,6 +3461,7 @@ Word16 comvad_decision_fx( const Word16 frame_energy_Q, /*(i) the Scaling of current frame energy*/ Word16 *cldfb_addition, /*(o) adjust the harmonized hangover */ const Word16 vada_flag ); + void amr_wb_enc_init_fx( AMRWB_IO_ENC_HANDLE hAmrwb_IO /* i/o: AMR-WB IO encoder handle */ ); @@ -3317,6 +3474,7 @@ void snr_calc( const Word32 frame_energy, /* i : current frame energy sacle_sbpower*/ const Word32 bwidth /* i : audio band width Q0*/ ); + void FEC_encode_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP */ @@ -3352,30 +3510,32 @@ void update_average_rate_fx( SC_VBR_ENC_HANDLE hSC_VBR, /* i/o: SC-VBR state structure */ const Word32 core_brate_fx /* i : core bitrate */ ); -Word16 pit_encode_fx( /* o : Fractional pitch for each subframe */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const Word16 pitch_bits[], /* i : pitch bits */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - const Word16 i_subfr, /* i : subframe index */ - Word16 *exc, /* i/o: pointer to excitation signal frame */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 *T_op, /* i : open loop pitch estimates in current frame */ - Word16 *T0_min, /* i/o: lower limit for close-loop search */ - Word16 *T0_max, /* i/o: higher limit for close-loop search */ - Word16 *T0, /* i/o: close loop integer pitch */ - Word16 *T0_frac, /* i/o: close loop fractional part of the pitch */ - const Word16 *h1, /* i : weighted filter i response */ - const Word16 *xn, /* i : target vector */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ + +/* o : Fractional pitch for each subframe */ +Word16 pit_encode_fx( + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 pitch_bits[], /* i : pitch bits */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + const Word16 i_subfr, /* i : subframe index */ + Word16 *exc, /* i/o: pointer to excitation signal frame */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 *T_op, /* i : open loop pitch estimates in current frame */ + Word16 *T0_min, /* i/o: lower limit for close-loop search */ + Word16 *T0_max, /* i/o: higher limit for close-loop search */ + Word16 *T0, /* i/o: close loop integer pitch */ + Word16 *T0_frac, /* i/o: close loop fractional part of the pitch */ + const Word16 *h1, /* i : weighted filter i response */ + const Word16 *xn, /* i : target vector */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ #if !defined REUSE_EVS_ACELP_PITCH_NORM_CORR - , - const Word16 element_mode, /* i : mode element */ - const Word16 Q_new /* i : scaling factor */ + , + const Word16 element_mode, /* i : mode element */ + const Word16 Q_new /* i : scaling factor */ #endif ); @@ -3395,6 +3555,7 @@ Word16 lp_filt_exc_enc_fx( Word16 *gain_pit, /* o : adaptive excitation gain Q14 */ Word16 *lp_flag /* i/o: mode selection Q0 */ ); + Word16 inov_encode_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word32 core_brate, /* i : core bitrate */ @@ -3466,6 +3627,7 @@ void gain_enc_mless_fx( Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 Qx*/ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) Q0*/ ); + void updt_IO_switch_enc_fx( Encoder_State *st, /* i/o: state structure */ const Word16 input_frame /* i : i frame length */ @@ -3553,7 +3715,6 @@ void gain_enc_amr_wb_fx( Word16 *past_qua_en /* i/o: gain quantization memory (4 words) Q10*/ ); - void hf_cod_fx( const Word32 core_brate_fx, /* i : core bitrate */ const Word16 *speech16k_fx, /* i : original speech at 16 kHz */ @@ -3639,10 +3800,10 @@ void gain_enc_lbr_fx( Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ - const Word16 L_subfr /* i : subframe length Q0*/ - , - const Word16 element_mode /* i : mode element Q0*/ + const Word16 L_subfr, /* i : subframe length Q0*/ + const Word16 element_mode /* i : mode element Q0*/ ); + void gain_enc_SQ_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 gains_mode[], /* i : gain bits Q0*/ @@ -3660,6 +3821,7 @@ void gain_enc_SQ_fx( const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) Q0*/ const Word16 Q_xn /* i : xn and y1 scaling */ ); + void updt_tar_fx( const Word16 *x, /* i : old target (for pitch search) */ Word16 *x2, /* o : new target (for codebook search) */ @@ -3667,6 +3829,7 @@ void updt_tar_fx( const Word16 gain, /* i : adaptive codebook gain */ const Word16 L /* i : subframe size */ ); + void updt_tar_HR_fx( const Word16 *x, /* i : old target (for pitch search) */ Word16 *x2, /* o : new target (for codebook search) */ @@ -3726,7 +3889,6 @@ void transition_enc_fx( Word16 *unbits_ACELP, /* i/o: unused bits */ Word16 Q_new, /* i : Current scaling */ Word16 shift /* i : downscaling needs for 12 bits convolutions */ - ); void transition_enc_ivas_fx( @@ -3753,7 +3915,6 @@ void transition_enc_ivas_fx( Word16 *unbits_ACELP, /* i/o: unused bits */ Word16 Q_new, /* i : Current scaling */ Word16 shift /* i : downscaling needs for 12 bits convolutions */ - ); void gain_enc_tc_fx( @@ -3866,13 +4027,15 @@ void swb_bwe_enc_hr_fx( const Word16 unbits /* i : number of core unused bits */ ); -Word16 gain_enc_gaus_fx( /* o : Return index of quantization */ - Word32 *gain, /* i/o: Code gain to quantize Q16*/ - const Word16 bits, /* i : number of bits to quantize Q0*/ - const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ - const Word16 stepSize, /* i : Step size choice Q14*/ - const Word16 inv_stepSize /* i : Step size choice Q15*/ +/* o : Return index of quantization */ +Word16 gain_enc_gaus_fx( + Word32 *gain, /* i/o: Code gain to quantize Q16*/ + const Word16 bits, /* i : number of bits to quantize Q0*/ + const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8*/ + const Word16 stepSize, /* i : Step size choice Q14*/ + const Word16 inv_stepSize /* i : Step size choice Q15*/ ); + void enc_pit_exc_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 *speech, /* i : Input speech Q_new-1*/ @@ -3913,23 +4076,25 @@ void enc_pit_exc_ivas_fx( Word16 Q_new, Word16 shift ); -Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is significant */ - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *dct_res, /* i : DCT of residual Qnew*/ - Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ - Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ - Word16 Qnew ); - -Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin where pitch contribution is significant */ - Encoder_State *st_fx, /* i/o: state structure */ - const Word16 *dct_res, /* i : DCT of residual Qnew*/ - Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ - Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ - Word16 Qnew ); +/* o : bin where pitch contribution is significant */ +Word16 Pit_exc_contribution_len_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 *dct_res, /* i : DCT of residual Qnew*/ + Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ + Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ + Word16 Qnew ); + +/* o : bin where pitch contribution is significant */ +Word16 Pit_exc_contribution_len_ivas_fx( + Encoder_State *st_fx, /* i/o: state structure */ + const Word16 *dct_res, /* i : DCT of residual Qnew*/ + Word16 *dct_pitex, /* i/o: DCT of pitch contribution Qnew*/ + Word16 *pitch_buf, /* i/o: Pitch per subframe Q6*/ + const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ + Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ + Word16 Qnew ); Word16 pvq_core_enc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -3947,6 +4112,7 @@ Word16 pvq_core_enc_fx( Word16 *maxpulse, /* i : maximum pulse per band */ const Word16 core /* i : number of bands */ ); + Word16 pvq_core_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ @@ -3986,7 +4152,6 @@ void hq_lr_enc_ivas_fx( const Word16 is_transient_fx /* i : Q0 : transient flag */ ); - void hq_hr_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure fx */ Word32 *t_audio, /* i/o: transform-domain coefficients Q12 */ @@ -4019,28 +4184,32 @@ void diffcod_fx( Word16 *difidx /* (o) differential code Q0*/ ); -Word16 hq_classifier_enc_fx( /* o : Consumed bits Q0 */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 length, /* i : Frame length Q0 */ - const Word32 *coefs, /* i : Spectral coefficients Q12 */ - const Word16 is_transient, /* i : Transient flag Q0 */ - Word16 *Npeaks, /* o : Number of identified peaks Q0 */ - Word16 *peaks, /* o : Peak indices Q0 */ - Word32 *pe_gains, /* o : Peak gains Q12 */ - Word32 *nf_gains, /* o : Noise-fill gains Q12 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ -); -Word16 hq_classifier_enc_ivas_fx( /* o : Consumed bits Q0 */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 length, /* i : Frame length Q0 */ - const Word32 *coefs, /* i : Spectral coefficients Q12 */ - const Word16 is_transient, /* i : Transient flag Q0 */ - Word16 *Npeaks, /* o : Number of identified peaks Q0 */ - Word16 *peaks, /* o : Peak indices Q0 */ - Word32 *pe_gains, /* o : Peak gains Q12 */ - Word32 *nf_gains, /* o : Noise-fill gains Q12 */ - Word16 *hqswb_clas /* o : HQ class Q0 */ +/* o : Consumed bits Q0 */ +Word16 hq_classifier_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 length, /* i : Frame length Q0 */ + const Word32 *coefs, /* i : Spectral coefficients Q12 */ + const Word16 is_transient, /* i : Transient flag Q0 */ + Word16 *Npeaks, /* o : Number of identified peaks Q0 */ + Word16 *peaks, /* o : Peak indices Q0 */ + Word32 *pe_gains, /* o : Peak gains Q12 */ + Word32 *nf_gains, /* o : Noise-fill gains Q12 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ +); + +/* o : Consumed bits Q0 */ +Word16 hq_classifier_enc_ivas_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 length, /* i : Frame length Q0 */ + const Word32 *coefs, /* i : Spectral coefficients Q12 */ + const Word16 is_transient, /* i : Transient flag Q0 */ + Word16 *Npeaks, /* o : Number of identified peaks Q0 */ + Word16 *peaks, /* o : Peak indices Q0 */ + Word32 *pe_gains, /* o : Peak gains Q12 */ + Word32 *nf_gains, /* o : Noise-fill gains Q12 */ + Word16 *hqswb_clas /* o : HQ class Q0 */ ); + void diff_envelope_coding_fx( const Word16 is_transient, /* i : transient indicator Q0 */ const Word16 num_env_bands, /* i : number of envelope bands to code Q0 */ @@ -4050,16 +4219,16 @@ void diff_envelope_coding_fx( Word16 *difidx /* o : differential code Q0 */ ); -Word16 encode_envelope_indices_ivas_fx( /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ - const Word16 num_sfm, /* i : Number of subbands Q0 */ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ - Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ - Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ - const Word16 flag_HQ2 /* i : indicator of HQ2 core Q0 */ - , - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ +/* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ +Word16 encode_envelope_indices_ivas_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ + const Word16 num_sfm, /* i : Number of subbands Q0 */ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ + Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ + Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ ); void hq_generic_encoding_fx( @@ -4079,34 +4248,38 @@ void normalizecoefs_fx( Word16 *coefs_norm /* o : Normalized output vector (Q12) */ ); -Word16 hvq_enc_fx( /* o : Consumed bits */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word32 brate, /* i : Total bit rate */ - const Word16 hvq_bits, /* i : HVQ bit budget */ - const Word16 Npeaks, /* i : Number of peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ - Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */ - Word16 *noise_level, /* o : Quantized noise level */ - const Word32 *pe_gains, /* i : Peak gains */ - const Word32 *coefs, /* i : spectrum coefficients in Q14 */ - Word32 *coefs_out /* o : encoded spectrum coefficients in Q14 */ -); -Word16 hvq_enc_ivas_fx( /*o : Consumed bits */ - Encoder_State *st_fx, /*i/o: encoder state structure */ - const Word32 core_brate, /*i : Total bit rate */ - const Word16 hvq_bits, /*i : HVQ bit budget */ - const Word16 Npeaks, /*i : Number of peaks */ - const Word16 *ynrm, /* i : Envelope coefficients */ - Word16 *R, /* i/o: Bit allocation/updated bit allocation */ - Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ - Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains Q12 */ - Word16 *noise_level, /* o : Quantized noise level Q15 */ - const Word32 *pe_gains, /* i : Peak gains */ - const Word32 *coefs, /* i : spectrum coefficients in Q12 */ - Word32 *coefs_out /* o : encoded spectrum coefficients in Q12 */ +/* o : Consumed bits */ +Word16 hvq_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word32 brate, /* i : Total bit rate */ + const Word16 hvq_bits, /* i : HVQ bit budget */ + const Word16 Npeaks, /* i : Number of peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ + Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */ + Word16 *noise_level, /* o : Quantized noise level */ + const Word32 *pe_gains, /* i : Peak gains */ + const Word32 *coefs, /* i : spectrum coefficients in Q14 */ + Word32 *coefs_out /* o : encoded spectrum coefficients in Q14 */ +); + +/*o : Consumed bits */ +Word16 hvq_enc_ivas_fx( + Encoder_State *st_fx, /*i/o: encoder state structure */ + const Word32 core_brate, /*i : Total bit rate */ + const Word16 hvq_bits, /*i : HVQ bit budget */ + const Word16 Npeaks, /*i : Number of peaks */ + const Word16 *ynrm, /* i : Envelope coefficients */ + Word16 *R, /* i/o: Bit allocation/updated bit allocation */ + Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */ + Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains Q12 */ + Word16 *noise_level, /* o : Quantized noise level Q15 */ + const Word32 *pe_gains, /* i : Peak gains */ + const Word32 *coefs, /* i : spectrum coefficients in Q12 */ + Word32 *coefs_out /* o : encoded spectrum coefficients in Q12 */ ); + Word16 pvq_core_enc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ @@ -4124,14 +4297,16 @@ Word16 pvq_core_enc_fx( const Word16 core /* i : number of bands */ ); -Word16 noise_adjust_fx( /* o : index of noise attenuation Q0 */ - const Word16 *coeffs_norm, /* i : normalized coefficients Qx */ - const Word16 qx, /* i : Q value of coeffs_norm */ - const Word16 *bitalloc, /* i : bit allocation Q0 */ - const Word16 *sfm_start, /* i : band start Q0 */ - const Word16 *sfm_end, /* i : band end Q0 */ - const Word16 core_sfm /* i : index of the end band for core Q0 */ +/* o : index of noise attenuation Q0 */ +Word16 noise_adjust_fx( + const Word16 *coeffs_norm, /* i : normalized coefficients Qx */ + const Word16 qx, /* i : Q value of coeffs_norm */ + const Word16 *bitalloc, /* i : bit allocation Q0 */ + const Word16 *sfm_start, /* i : band start Q0 */ + const Word16 *sfm_end, /* i : band end Q0 */ + const Word16 core_sfm /* i : index of the end band for core Q0 */ ); + ivas_error tcq_core_LR_enc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 inp_vector_fx[], /* x5 */ @@ -4152,7 +4327,6 @@ ivas_error tcq_core_LR_enc_fx( const Word16 adjustFlag, const Word16 is_transient ); - ivas_error tcq_core_LR_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word32 inp_vector[], @@ -4173,17 +4347,18 @@ ivas_error tcq_core_LR_enc_ivas_fx( const Word16 adjustFlag, const Word16 is_transient ); -Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ - BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ - const Word16 num_sfm, /* i : Number of subbands Q0 */ - const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ - Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ - Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ - const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ - const Word16 flag_HQ2 /* i : indicator of HQ2 core Q0 */ - , - const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ +/* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */ +Word16 encode_envelope_indices_fx( + BSTR_ENC_HANDLE hBstr, /* i : handle to the bitstream Q0 */ + const Word16 num_sfm, /* i : Number of subbands Q0 */ + const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */ + Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */ + Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */ + const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */ + const Word16 flag_HQ2, /* i : indicator of HQ2 core Q0 */ + const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */ ); + void diffcod_lrmdct_fx( const Word16 N, /* i : number of sub-vectors Q0*/ const Word16 be_ref, /* i : band energy reference Q0*/ @@ -4191,6 +4366,7 @@ void diffcod_lrmdct_fx( Word16 *difidx, /* o : differential code Q0*/ const Word16 is_transient /* i : transient flag Q0*/ ); + Word16 peak_vq_enc_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 bwidth, /* i : audio bandwidth */ @@ -4204,6 +4380,7 @@ Word16 peak_vq_enc_ivas_fx( Word16 *vq_peak_idx, /* i : Peak index vector */ Word32 *nf_gains /* i : Estimated noise floor gains Q12 */ ); + Word16 peak_vq_enc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 bwidth, /* i : audio bandwidth */ @@ -4241,7 +4418,12 @@ void InitSWBencBuffer_ivas_fx( void ResetSHBbuffer_Enc_fx( Encoder_State *st_fx /* i/o: SHB encoder structure */ ); -Word16 E_ACELP_hh_corr( Word16 *x /*Q11*/, Word16 *y /*Qy*/, Word16 L_subfr /*Q0*/, Word16 bits /*Q0*/ ); + +Word16 E_ACELP_hh_corr( + Word16 *x /*Q11*/, + Word16 *y /*Qy*/, + Word16 L_subfr /*Q0*/, + Word16 bits /*Q0*/ ); void acelp_1t64_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -4251,6 +4433,7 @@ void acelp_1t64_fx( Word16 y[], /* o : filtered fixed codebook excitation */ const Word16 L_subfr /* i : subframe length */ ); + void acelp_2t32_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 dn[], /* i : corr. between target and h[]. */ @@ -4258,6 +4441,7 @@ void acelp_2t32_fx( Word16 code[], /* o : algebraic (fixed) codebook excitation */ Word16 y[] /* o : filtered fixed codebook excitation */ ); + Word16 acelp_4t64_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 dn[], /* i : corr. between target and h[]. */ @@ -4269,9 +4453,9 @@ Word16 acelp_4t64_fx( Word16 y[], /* o : filtered fixed codebook excitation Q9*/ Word16 nbbits, /* i : number of bits per codebook */ const Word16 cmpl_flag, /* i : coomplexity reduction flag */ - const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */ - , + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ const Word16 element_mode ); + ivas_error evs_enc_fx( Encoder_State *st, /* i/o: encoder state structure */ const Word16 *data, /* i : input signal Q0*/ @@ -4280,16 +4464,18 @@ ivas_error evs_enc_fx( ); /* y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx) */ -Word16 noise_est_AR1_Qx( /* o: Qx y(n) */ - Word16 x, /* i : Qx x(n) */ - Word16 y, /* i : Qx y(n-1) */ - Word16 alpha /*i : Q15 scaling of driving x(n) */ +/* o: Qx y(n) */ +Word16 noise_est_AR1_Qx( + Word16 x, /* i : Qx x(n) */ + Word16 y, /* i : Qx y(n-1) */ + Word16 alpha /*i : Q15 scaling of driving x(n) */ ); -Word32 noise_est_AR1_Qx_32( /* o: Qx y(n) */ - Word32 x, /* i : Qx x(n) */ - Word32 y, /* i : Qx y(n-1) */ - Word32 alpha /*i : Q15 scaling of driving x(n) */ +/* o: Qx y(n) */ +Word32 noise_est_AR1_Qx_32( + Word32 x, /* i : Qx x(n) */ + Word32 y, /* i : Qx y(n-1) */ + Word32 alpha /*i : Q15 scaling of driving x(n) */ ); void FEC_lsf_estim_enc_fx( @@ -4349,35 +4535,36 @@ Word32 mslvq_fx( Word16 pred_flag, /* i : prediction flag (0: safety net, 1 - predictive )*/ Word16 no_scales[][2] ); - -Word16 multi_harm_fx( /* o : frame multi-harmonicity (1-harmonic, 0-not) */ - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : i signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ -); - -Word16 multi_harm_ivas_fx( /* o : frame multi-harmonicity (1-harmonic, 0-not) */ - const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ - Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ - Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ - Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ - const Word32 total_brate, /* i : total bitrate Q0 */ - const Word16 bwidth, /* i : i signal bandwidth Q0 */ - Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ - Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ - Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ - Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ - Word16 *sp_floor, /* o: noise floor estimate Q7 */ - Word16 S_map[] /* o : short-term correlation map Q7 */ +/* o : frame multi-harmonicity (1-harmonic, 0-not) */ +Word16 multi_harm_fx( + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 bwidth, /* i : i signal bandwidth Q0 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *sp_floor, /* o: noise floor estimate Q7 */ + Word16 S_map[] /* o : short-term correlation map Q7 */ +); + +/* o : frame multi-harmonicity (1-harmonic, 0-not) */ +Word16 multi_harm_ivas_fx( + const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */ + Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */ + Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */ + Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */ + const Word32 total_brate, /* i : total bitrate Q0 */ + const Word16 bwidth, /* i : i signal bandwidth Q0 */ + Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */ + Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */ + Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */ + Word16 *cor_map_sum, /* i : sum of correlation map Q8 */ + Word16 *sp_floor, /* o: noise floor estimate Q7 */ + Word16 S_map[] /* o : short-term correlation map Q7 */ ); void pvq_encode_frame_fx( @@ -4396,6 +4583,7 @@ void pvq_encode_frame_fx( const Word16 pvq_bits, /* i : number of bits avaiable */ const Word16 core /* i : core */ ); + void pvq_encode_frame_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 *coefs_norm, /* i : normalized coefficients to encode */ @@ -4412,9 +4600,11 @@ void pvq_encode_frame_ivas_fx( const Word16 pvq_bits, /* i : number of bits avaiable */ const Word16 core /* i : core */ ); -Word16 Interpol_4( /*Qx o : interpolated value */ - Word16 *x, /*Qx i : i vector */ - Word16 frac /* i : fraction (-4..+3) */ + +/*Qx o : interpolated value */ +Word16 Interpol_4( + Word16 *x, /*Qx i : i vector */ + Word16 frac /* i : fraction (-4..+3) */ ); void set_ppp_mode_fx( @@ -4441,6 +4631,7 @@ void pvq_encode_fx( const Word16 dim, /* i: Length of vector */ const Word16 neg_gain /* i: - Gain use - negative gain in Q15 0 ..1 */ ); + void pvq_encode_ivas_fx( BSTR_ENC_HANDLE hBstr, PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ @@ -4461,11 +4652,13 @@ void rc_enc_finish_fx( BSTR_ENC_HANDLE hBstr, /* i/o: Encoder state */ PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ ); + void rc_enc_finish_ivas_fx( BSTR_ENC_HANDLE hBstr, PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle */ ); + void rc_encode_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ @@ -4473,6 +4666,7 @@ void rc_encode_fx( UWord32 sym_freq, /* i : Symbol probability Q0*/ UWord32 tot /* i : Total cumulative frequency Q0*/ ); + void rc_encode_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ @@ -4480,12 +4674,14 @@ void rc_encode_ivas_fx( UWord32 sym_freq, /* i : Symbol probability Q0*/ UWord32 tot /* i : Total cumulative frequency Q0*/ ); + void rc_enc_uniform_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ UWord32 value, /* i : Value to encode Q0*/ UWord32 tot /* i : Maximum value Q0*/ ); + void rc_enc_uniform_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ @@ -4499,12 +4695,14 @@ void rc_enc_bits_fx( UWord32 value, /* i : Value to encode Q0*/ Word16 bits /* i : Number of bits used Q0*/ ); + void rc_enc_bits_ivas_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ PVQ_ENC_HANDLE hPVQ, /* i/o: PVQ encoder handle */ UWord32 value, /* i : Value to encode Q0*/ Word16 bits /* i : Number of bits used Q0*/ ); + void re8_compute_base_index_fx( const Word16 *x, /* i : Elemen of Q2, Q3 or Q4 */ const Word16 ka, /* i : Identifier of the absolute leader related to x */ @@ -4515,11 +4713,12 @@ void tfaCalcEnv_fx( const Word16 *shb_speech, Word32 *enr ); -Word16 delta_pit_enc_fx( /* o : pitch index */ - const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/ - const Word16 T0, /* i : integer pitch lag */ - const Word16 T0_frac, /* i : pitch fraction */ - const Word16 T0_min /* i : delta search min */ +/* o : pitch index */ +Word16 delta_pit_enc_fx( + const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/ + const Word16 T0, /* i : integer pitch lag */ + const Word16 T0_frac, /* i : pitch fraction */ + const Word16 T0_min /* i : delta search min */ ); void set_impulse_fx( @@ -4533,11 +4732,12 @@ void set_impulse_fx( Word16 Q_new /* i : Current scaling */ ); -Word16 abs_pit_enc_fx( /* o : pitch index */ - const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/ - const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ - const Word16 T0, /* i : integer pitch lag */ - const Word16 T0_frac /* i : pitch fraction */ +/* o : pitch index */ +Word16 abs_pit_enc_fx( + const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/ + const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */ + const Word16 T0, /* i : integer pitch lag */ + const Word16 T0_frac /* i : pitch fraction */ ); ivas_error ppp_quarter_encoder_fx( @@ -4575,9 +4775,9 @@ void index_lvq_ivas_fx( const Word16 prediction_flag ); ivas_error init_encoder_fx( - Encoder_State *st_fx, /* i/o: Encoder static variables structure */ - const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ - const int16_t interval_SID /* i : interval for SID update */ + Encoder_State *st_fx, /* i/o: Encoder static variables structure */ + const Word16 var_SID_rate_flag, /* i : flag for variable SID update rate */ + const Word16 interval_SID /* i : interval for SID update */ ); void copy_encoder_config_fx( @@ -4615,9 +4815,10 @@ Word16 cng_energy_ivas_fx( const Word16 Q_new /* i : Input scaling */ ); -void generate_comfort_noise_enc_ivas_fx( Encoder_State *stcod, - Word16 Q_new, - Word16 gen_exc ); +void generate_comfort_noise_enc_ivas_fx( + Encoder_State *stcod, + Word16 Q_new, + Word16 gen_exc ); void SynthesisSTFT_enc_ivas_fx( Word32 *fftBuffer, /* i : pointer to FFT bins */ diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index e98906704..c87a081fa 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -68,7 +68,7 @@ static Word16 one_pulse_search( en_tmp = en_dn_shift; /* dummy assignment to avoid compiler warning for unused parameter */ /* maximize correlation precision, prior to every unit pulse addition in the vector */ - corr_up_shift = norm_l( L_mac( *L_xy_ptr, 1, max_xabs ) ); /* pre analyze worst case L_xy update in the dim loop , 2 ops */ + corr_up_shift = norm_l( L_mac( *L_xy_ptr, 1, max_xabs ) ); /* pre analyze worst case L_xy update in the dim loop, 2 ops */ imax = -1; /* not needed for search, only added to avoid compiler warning */ /* clean BE code, with split out low/high precision loops */ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index c1e2924b3..83ed5460a 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -1677,7 +1677,6 @@ typedef struct enc_core_structure Word16 prevTempFlatness_fx; /* exponent is AVG_FLAT_E Q7 in EVS */ /* Q4 in IVAS */ Word32 prevTempFlatness_32fx; /* Q21 in IVAS */ - // float currEnergyLookAhead; Word32 currEnergyLookAhead_fx; // Q31 Word32 prevEnergyHF_fx; Word32 currEnergyHF_fx; @@ -1696,7 +1695,6 @@ typedef struct enc_core_structure Word16 encoderLookahead_FB; /* pitch_ol for adaptive lag window */ - Word16 old_pitch_la; /* past open loop pitch lag from look-ahead before very short stable pitch detection */ Word16 old_voicing_la; /* past open loop pitch gain from look-ahead */ diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index d5c546c35..675121cef 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -24,16 +24,11 @@ /*-----------------------------------------------------------------* * Local functions *-----------------------------------------------------------------*/ -static void return_M_Least_fx_GainFrame( const Word32 *inp, - const Word32 *codebook, - const Word16 num_grp, - const Word16 interNum, - Word16 *least ); +static void return_M_Least_fx_GainFrame( const Word32 *inp, const Word32 *codebook, const Word16 num_grp, const Word16 interNum, Word16 *least ); static void singlevectortest_gain_fx( const Word32 *inp, const Word16 dimen, const Word16 cb_size, Word16 *index, Word32 *recon, const Word32 *codebook ); - static void determine_gain_weights_fx( const Word32 *gain, Word16 *weights, const Word16 dims ); static void QuantizeSHBsubgains_fx( Encoder_State *st_fx, Word16 *subgains, const Word16 extl ); @@ -48,53 +43,28 @@ static Word16 closest_centroid_fx( const Word16 *data, const Word16 *weights, co static Word16 closest_centroid_lc_fx( const Word16 *data, const Word16 *quantizer, const Word16 centroids ); -static void EstimateSHBFrameGain_fx( const Word16 length, - const Word16 *oriSHB, - const Word16 Q_oriSHB, - const Word16 *synSHB, - const Word16 Q_synSHB, - Word16 *subgain, - Word32 *GainFrame, - const Word16 *win_shb, - const Word16 *subwin_shb, - const Word16 n_subfr_saturation ); - -static void EstimateSHBFrameGain_ivas_fx( const Word16 length, - const Word16 *oriSHB, - const Word16 Q_oriSHB, - const Word16 *synSHB, - const Word16 Q_synSHB, - Word16 *subgain, - Word32 *GainFrame, - const Word16 *win_shb, - const Word16 *subwin_shb, - const Word16 n_subfr_saturation ); - -static void EstimateSHBGainShape_fx( const Word16 length, - const Word16 *oriSHB, - const Word16 Q_oriSHB, - const Word16 *synSHB, - const Word16 Q_synSHB, - Word16 *subgain, - const Word16 *subwin, - Word16 *n_subfr_saturation, - const Flag limit_min_gain ); +static void EstimateSHBFrameGain_fx( const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, Word32 *GainFrame, const Word16 *win_shb, const Word16 *subwin_shb, const Word16 n_subfr_saturation ); + +static void EstimateSHBFrameGain_ivas_fx( const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, Word32 *GainFrame, const Word16 *win_shb, const Word16 *subwin_shb, const Word16 n_subfr_saturation ); +static void EstimateSHBGainShape_fx( const Word16 length, const Word16 *oriSHB, const Word16 Q_oriSHB, const Word16 *synSHB, const Word16 Q_synSHB, Word16 *subgain, const Word16 *subwin, Word16 *n_subfr_saturation, const Flag limit_min_gain ); static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ); static Word32 pow_off_pk_corrected_fx( Word16 a[], Word16 len, Word16 step ); static void find_max_mem_enc( Encoder_State *st_fx, Word16 *n_mem, Word16 *n_mem2 ); + static void rescale_genSHB_mem_enc( Encoder_State *st_fx, Word16 sf ); + static void find_max_mem_wb_enc( Encoder_State *st_fx, Word16 *n_mem ); + static void rescale_genWB_mem_enc( Encoder_State *st_fx, Word16 sf ); -static void Quant_lower_LSF_fx( const Word16 lsf[], - Word16 lsf_q[], - Word16 lsf_idx[] ); +static void Quant_lower_LSF_fx( const Word16 lsf[], Word16 lsf_q[], Word16 lsf_idx[] ); static Word16 Quant_mirror_point_fx( const Word16 lsf[], const Word16 lsf_q[], Word16 *m ); + static Word16 Find_LSF_grid_fx( const Word16 lsf[], Word16 lsf_q[], const Word16 m ); static void Quant_BWE_LSF_fx( Encoder_State *st_fx, const Word16 lsp_shb[], Word16 Q_lsfs[] ); @@ -109,21 +79,9 @@ static void Quant_shb_res_gshape_fx( Encoder_State *st_fx, Word16 *shb_res_gshap static void Quant_shb_res_gshape_ivas_fx( Encoder_State *st, Word16 shb_res_gshape_fx[] ); -static void gainFrSmooth_En_fx( Encoder_State *st_fx, - Word16 *shb_frame_fx, - const Word16 *lpc_shb_fx, - const Word16 *lsp_shb_fx, - Word16 *MA_lsp_shb_spacing, - Word16 *frGainAttenuate, - Word16 *frGainSmoothEn ); +static void gainFrSmooth_En_fx( Encoder_State *st_fx, Word16 *shb_frame_fx, const Word16 *lpc_shb_fx, const Word16 *lsp_shb_fx, Word16 *MA_lsp_shb_spacing, Word16 *frGainAttenuate, Word16 *frGainSmoothEn ); -static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx, - Word16 *shb_frame_fx /* Q_in */, - const Word16 *lpc_shb_fx /* Q12 */, - const Word16 *lsp_shb_fx /* Q15 */, - Word16 *MA_lsp_shb_spacing /* Q15 */, - Word16 *frGainAttenuate /* Q0 */, - Word16 *frGainSmoothEn /* Q0 */ ); +static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx, Word16 *shb_frame_fx /* Q_in */, const Word16 *lpc_shb_fx /* Q12 */, const Word16 *lsp_shb_fx /* Q15 */, Word16 *MA_lsp_shb_spacing /* Q15 */, Word16 *frGainAttenuate /* Q0 */, Word16 *frGainSmoothEn /* Q0 */ ); /*-------------------------------------------------------------------* @@ -131,6 +89,7 @@ static void gainFrSmooth_En_ivas_fx( Encoder_State *st_fx, * * Find norm and max in TBE memories and past buffers *-------------------------------------------------------------------*/ + void find_max_mem_enc( Encoder_State *st_fx, Word16 *n_mem, @@ -236,6 +195,8 @@ void find_max_mem_enc( tempQ15 = sub( s_min( *n_mem, n_mem_32 ), 1 ); *n_mem = s_max( tempQ15, 0 ); move16(); + + return; } @@ -244,7 +205,10 @@ void find_max_mem_enc( * * Rescale genSHB memories *-------------------------------------------------------------------*/ -void rescale_genSHB_mem_enc( Encoder_State *st_fx, Word16 sf ) + +void rescale_genSHB_mem_enc( + Encoder_State *st_fx, + Word16 sf ) { Word16 i; TD_BWE_ENC_HANDLE hBWE_TD = st_fx->hBWE_TD; @@ -5663,6 +5627,7 @@ static void Quant_shb_ener_sf_fx( { push_indice( st_fx->hBstr, IND_SHB_ENER_SF, idxSubEner_fx, NUM_BITS_SHB_ENER_SF ); } + return; } @@ -5717,6 +5682,7 @@ static void Quant_shb_ener_sf_ivas_fx( { push_indice( st_fx->hBstr, IND_SHB_ENER_SF, idxSubEner_fx, NUM_BITS_SHB_ENER_SF ); } + return; } @@ -5751,6 +5717,8 @@ static void Quant_shb_res_gshape_fx( push_indice( st_fx->hBstr, IND_SHB_RES_GS + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS ); } } + + return; } @@ -5787,6 +5755,8 @@ static void Quant_shb_res_gshape_ivas_fx( push_indice( st->hBstr, IND_SHB_RES_GS + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS ); } } + + return; } @@ -5814,8 +5784,7 @@ static void QuantizeSHBframegain_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ Word32 *GainFrame, /* i/o: Gain Q18 */ const Word16 extl, /* i : extension layer */ - Word32 extl_brate /* i : extension layer bitrate */ - , + Word32 extl_brate, /* i : extension layer bitrate */ Word16 *rf_gainFrame_ind ) { Word16 idxFrameGain; diff --git a/lib_enc/vad_param_updt_fx.c b/lib_enc/vad_param_updt_fx.c index 464903a03..5c2ca3fd4 100644 --- a/lib_enc/vad_param_updt_fx.c +++ b/lib_enc/vad_param_updt_fx.c @@ -62,8 +62,7 @@ void vad_param_updt_fx( } IF( !st_fx->Opt_AMR_WB ) { - /* fix explanation - , after function dtx_fx, the "vad_flag" parameter can not be used for SID scheduling purposes any longer + /* fix explanation, after function dtx_fx, the "vad_flag" parameter can not be used for SID scheduling purposes any longer as dtx_fx can schedules active frames even if the initial analyzed vad_flag is 0 ) in the worst case without the fix an active frame could be classified as SID frame, quite/very unlikley though */ diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index 60eeff746..d807a26e6 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -1277,8 +1277,8 @@ void isar_splitBinRendPLC( { FOR( k = 0; k < iNumCols; k++ ) { - v_multc_fixed( &Cldfb_RealBuffer_Binaural_fx[n][k][0], fade_fac_fx, &Cldfb_RealBuffer_Binaural_fx[n][k][0], (Word16) CLDFB_NO_CHANNELS_MAX ); - v_multc_fixed( &Cldfb_ImagBuffer_Binaural_fx[n][k][0], fade_fac_fx, &Cldfb_ImagBuffer_Binaural_fx[n][k][0], (Word16) CLDFB_NO_CHANNELS_MAX ); + v_multc_fx( &Cldfb_RealBuffer_Binaural_fx[n][k][0], fade_fac_fx, &Cldfb_RealBuffer_Binaural_fx[n][k][0], (Word16) CLDFB_NO_CHANNELS_MAX ); + v_multc_fx( &Cldfb_ImagBuffer_Binaural_fx[n][k][0], fade_fac_fx, &Cldfb_ImagBuffer_Binaural_fx[n][k][0], (Word16) CLDFB_NO_CHANNELS_MAX ); } } } diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index d610a4a08..6ae2e2715 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1615,10 +1615,10 @@ static ivas_error renderInputSplitBin( splitBinInput->base.numNewSamplesPerChannel = 0; /* Apply input gain to new audio */ - v_multc_fixed( inAudio.data_fx, - splitBinInput->base.gain_fx, - inAudio.data_fx, - inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); + v_multc_fx( inAudio.data_fx, + splitBinInput->base.gain_fx, + inAudio.data_fx, + inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); SWITCH( outConfig ) { diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index da4f6542f..1ba5cafc4 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -119,8 +119,8 @@ ivas_error ISAR_PRE_REND_open( FOR( ch = 0; ch < num_ch; ch++ ) { - if ( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), - CLDFB_ANALYSIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) + IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), + CLDFB_ANALYSIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) { return error; } @@ -152,7 +152,7 @@ ivas_error ISAR_PRE_REND_open( { IF( EQ_16( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) ) { - if ( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, ivas_frame_size ) ) != IVAS_ERR_OK ) + IF( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, ivas_frame_size ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index aa9869b61..c56007c23 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1417,7 +1417,7 @@ static ivas_error ivas_er_init_handle( ivas_error ivas_rend_initCrendWrapper( CREND_WRAPPER_HANDLE *pCrend, - const int16_t num_poses ) + const Word16 num_poses ) { Word16 i; CREND_HANDLE hCrend; @@ -2104,8 +2104,7 @@ ivas_error ivas_rend_crendProcessSubframe( Word32 *input_f[], /* i : transport channels Qx */ Word32 *output[], /* i/o: input/output audio channels Qx */ const Word16 n_samples_to_render, /* i : output frame length per channel */ - const Word32 output_Fs /* i : output sampling rate */ - , + const Word32 output_Fs, /* i : output sampling rate */ const Word16 pos_idx ) { Word16 subframe_idx, subframe_len; diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 4e00b9623..733f80bde 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -446,7 +446,7 @@ static void ivas_dirac_param_est_ana_fx( Copy32( reference_power_fx[ts], &( hDirAC->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands ); hDirAC->buffer_energy_q[index - 1] = reference_power_q; move16(); - computeDiffuseness_fixed( hDirAC->buffer_intensity_real_fx, hDirAC->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hDirAC->buffer_intensity_real_q, hDirAC->buffer_energy_q, &diffuseness_q ); + computeDiffuseness_fx( hDirAC->buffer_intensity_real_fx, hDirAC->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hDirAC->buffer_intensity_real_q, hDirAC->buffer_energy_q, &diffuseness_q ); FOR( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ ) { @@ -537,10 +537,10 @@ static void ivas_dirac_dmx_fx( IF( EQ_16( nchan_transport, 2 ) ) { v_add_fx( data_in_fx[0], data_in_fx[1], data_out_fx[0], input_frame ); - v_multc_fixed( data_out_fx[0], ONE_IN_Q30, data_out_fx[0], input_frame ); // ONE_IN_Q30 = 0.5* ONE_IN_Q31 + v_multc_fx( data_out_fx[0], ONE_IN_Q30, data_out_fx[0], input_frame ); // ONE_IN_Q30 = 0.5* ONE_IN_Q31 v_sub_fixed_no_hdrm( data_in_fx[0], data_in_fx[1], data_out_fx[1], input_frame ); - v_multc_fixed( data_out_fx[1], ONE_IN_Q30, data_out_fx[1], input_frame ); + v_multc_fx( data_out_fx[1], ONE_IN_Q30, data_out_fx[1], input_frame ); FOR( i = 0; i < nchan_transport; i++ ) { diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index f81fa0d3d..bcd69a51a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -130,18 +130,7 @@ static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx /*q_Ein*/, Word32 Ein2_f static void matrixMul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); -static void matrixTransp2Mul_fx( - Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, - Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, - Word16 *q_A, - Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, - Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, - Word16 *q_B, - Word32 Ascale, - Word32 Bscale, - Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, - Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, - Word16 *q_out ); +static void matrixTransp2Mul_fx( Word32 Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word32 Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_A*/, Word16 *q_A, Word32 Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word32 Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_B*/, Word16 *q_B, Word32 Ascale, Word32 Bscale, Word32 outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word32 outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_out*/, Word16 *q_out ); /*------------------------------------------------------------------------- @@ -297,6 +286,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( } hDiracDecBin->q_earlyPartEneCorrection = Q28; move16(); + /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ test(); test(); @@ -308,7 +298,6 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( IF( hDiracDecBin->hReverb == NULL && EQ_16( pos_idx, 0 ) ) /* open reverb only for the main direction */ { - IF( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, pRoomAcoustics, output_Fs, ( *phHrtfParambin )->parametricReverberationTimes_fx, ( *phHrtfParambin )->parametricReverberationEneCorrections_fx, hDiracDecBin->earlyPartEneCorrection_fx ) ), IVAS_ERR_OK ) ) { return error; @@ -342,7 +331,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( ivas_dirac_dec_decorr_close_fx( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); } - if ( pos_idx == 0 ) /* open decorrelator only for the main direction */ + IF( pos_idx == 0 ) /* open decorrelator only for the main direction */ { IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hDiracDecBin->hTdDecorr ), &( hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) { @@ -354,6 +343,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( IF( !hDiracDecBin->useTdDecorr && !( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) ) { Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; + ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, output_Fs, nBins ); IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( hDiracDecBin->h_freq_domain_decorr_ap_params ), @@ -410,6 +400,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( return error; } } + return IVAS_ERR_OK; } @@ -418,11 +409,13 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( * * Close parametric binaural renderer *------------------------------------------------------------------------*/ + void ivas_dirac_dec_close_binaural_data( DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */ ) { - int16_t pos_idx; + Word16 pos_idx; + test(); IF( hBinaural == NULL || *hBinaural == NULL ) { @@ -4815,7 +4808,6 @@ static void getDirectPartGains_fx( const Word16 isHeadtracked, HRTFS_PARAMBIN_HANDLE hHrtfParambin ) { - // float aziRad, eleRad; Word32 y, mappedX; Word16 aziRadMapped, A, A2, A3; const Word16 LsAngleRad = 17157; // Q15 @@ -4964,6 +4956,7 @@ static void getDirectPartGains_fx( return; } + static void hrtfShGetHrtf_fx( const Word16 bin, const Word16 aziDeg, @@ -4979,6 +4972,7 @@ static void hrtfShGetHrtf_fx( Word16 k; Word16( *hrtfShCoeffsReInt_fx )[16][60]; Word16( *hrtfShCoeffsImInt_fx )[16][60]; + hrtfShCoeffsReInt_fx = hHrtfParambin->hrtfShCoeffsRe_fx; hrtfShCoeffsImInt_fx = hHrtfParambin->hrtfShCoeffsIm_fx; @@ -5012,11 +5006,7 @@ static void hrtfShGetHrtf_fx( { Word32 shVec[HRTF_SH_CHANNELS]; - ivas_dirac_dec_get_response_fx( aziDeg, - eleDeg, - shVec, - HRTF_SH_ORDER, - Q29 ); + ivas_dirac_dec_get_response_fx( aziDeg, eleDeg, shVec, HRTF_SH_ORDER, Q29 ); FOR( k = 0; k < HRTF_SH_CHANNELS; k++ ) { @@ -5476,7 +5466,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( Word16 i, j; Word16 nchan_transport; Word16 q_mat; - int16_t pos_idx; + Word16 pos_idx; const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; Word32 tmp_Cldfb_out_re[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 tmp_Cldfb_out_im[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; @@ -5587,8 +5577,8 @@ static void ivas_masa_ext_rend_parambin_internal_fx( { /* At mono input duplicate the channel to dual-mono, and apply gain correction to ensure same overall level as in stereo mode */ - v_multc_fixed( Cldfb_RealBuffer_in_fx[0][slot], 1518500224 /* INV_SQRT_2 in Q31 */, Cldfb_RealBuffer_in_fx[0][slot], nBins ); - v_multc_fixed( Cldfb_ImagBuffer_in_fx[0][slot], 1518500224 /* INV_SQRT_2 in Q31 */, Cldfb_ImagBuffer_in_fx[0][slot], nBins ); + v_multc_fx( Cldfb_RealBuffer_in_fx[0][slot], 1518500224 /* INV_SQRT_2 in Q31 */, Cldfb_RealBuffer_in_fx[0][slot], nBins ); + v_multc_fx( Cldfb_ImagBuffer_in_fx[0][slot], 1518500224 /* INV_SQRT_2 in Q31 */, Cldfb_ImagBuffer_in_fx[0][slot], nBins ); Copy32( Cldfb_RealBuffer_in_fx[0][slot], Cldfb_RealBuffer_in_fx[1][slot], nBins ); Copy32( Cldfb_ImagBuffer_in_fx[0][slot], Cldfb_ImagBuffer_in_fx[1][slot], nBins ); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 541e4d5a8..20db014e3 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -724,8 +724,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { - v_multc_fixed( hSpatParamRendCom->energy_ratio1_fx[md_idx], -MAX_32 /*-1 Q31*/, aux_buf, num_freq_bands ); /* 30 + 31 - 31 -> 30 */ - v_addc_fixed( aux_buf, ONE_IN_Q30 /*1 Q30*/, aux_buf, num_freq_bands ); /*30*/ + v_multc_fx( hSpatParamRendCom->energy_ratio1_fx[md_idx], -MAX_32 /*-1 Q31*/, aux_buf, num_freq_bands ); /* 30 + 31 - 31 -> 30 */ + v_addc_fx( aux_buf, ONE_IN_Q30 /*1 Q30*/, aux_buf, num_freq_bands ); /*30*/ Copy32( hSpatParamRendCom->energy_ratio1_fx[md_idx], h_dirac_output_synthesis_state->direct_power_factor_fx, num_freq_bands ); /*Q30*/ @@ -733,8 +733,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->diffuse_power_factor_fx, num_freq_bands ); /*Q30*/ - v_multc_fixed( hSpatParamRendCom->energy_ratio2_fx[md_idx], -MAX_32 /*-1 Q31*/, aux_buf, num_freq_bands ); /*30+31-31->30*/ - v_addc_fixed( aux_buf, ONE_IN_Q30 /*1 Q30*/, aux_buf, num_freq_bands ); /*30*/ + v_multc_fx( hSpatParamRendCom->energy_ratio2_fx[md_idx], -MAX_32 /*-1 Q31*/, aux_buf, num_freq_bands ); /*30+31-31->30*/ + v_addc_fx( aux_buf, ONE_IN_Q30 /*1 Q30*/, aux_buf, num_freq_bands ); /*30*/ Copy32( hSpatParamRendCom->energy_ratio2_fx[md_idx], &h_dirac_output_synthesis_state->direct_power_factor_fx[hSpatParamRendCom->num_freq_bands], num_freq_bands ); /*Q30*/ @@ -799,16 +799,15 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->direct_power_factor_q = sub( 31, h_dirac_output_synthesis_state->direct_power_factor_q ); h_dirac_output_synthesis_state->diffuse_power_factor_q = sub( 31, h_dirac_output_synthesis_state->diffuse_power_factor_q ); - v_multc_fixed( h_dirac_output_synthesis_state->direct_power_factor_fx, - ONE_IN_Q29 /*0.25f Q31*/, - h_dirac_output_synthesis_state->direct_power_factor_fx, - num_freq_bands ); /*h_dirac_output_synthesis_state->direct_power_factor_q+Q31-Q31->h_dirac_output_synthesis_state->direct_power_factor_q*/ - v_multc_fixed( h_dirac_output_synthesis_state->diffuse_power_factor_fx, - ONE_IN_Q29 /*0.25f Q31*/, - h_dirac_output_synthesis_state->diffuse_power_factor_fx, - num_freq_bands ); /*h_dirac_output_synthesis_state->diffuse_power_factor_q+Q31-Q31->h_dirac_output_synthesis_state->diffuse_power_factor_q*/ + v_multc_fx( h_dirac_output_synthesis_state->direct_power_factor_fx, + ONE_IN_Q29 /*0.25f Q31*/, + h_dirac_output_synthesis_state->direct_power_factor_fx, + num_freq_bands ); /*h_dirac_output_synthesis_state->direct_power_factor_q+Q31-Q31->h_dirac_output_synthesis_state->direct_power_factor_q*/ + v_multc_fx( h_dirac_output_synthesis_state->diffuse_power_factor_fx, + ONE_IN_Q29 /*0.25f Q31*/, + h_dirac_output_synthesis_state->diffuse_power_factor_fx, + num_freq_bands ); /*h_dirac_output_synthesis_state->diffuse_power_factor_q+Q31-Q31->h_dirac_output_synthesis_state->diffuse_power_factor_q*/ /*Direct gain*/ - Word16 *exp_temp_cy_cross_dir_smooth_fx = (Word16 *) malloc( num_freq_bands * num_channels_dir * sizeof( Word16 ) ); Word16 cy_cross_dir_smooth_e = sub( 31, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); @@ -1254,14 +1253,14 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( /*Direct gain*/ FOR( ch_idx = 0; ch_idx < nchan_transport_foa; ch_idx++ ) { - v_multc_fixed( diffuseness, // Q30 - ONE_IN_Q31, // Q31 - &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q30 - num_freq_bands ); - v_multc_fixed( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q30 - L_sub( h_dirac_output_synthesis_params.diffuse_compensation_factor_fx, ONE_IN_Q27 ), // Q27 - &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q26 - num_freq_bands ); + v_multc_fx( diffuseness, // Q30 + ONE_IN_Q31, // Q31 + &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q30 + num_freq_bands ); + v_multc_fx( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q30 + L_sub( h_dirac_output_synthesis_params.diffuse_compensation_factor_fx, ONE_IN_Q27 ), // Q27 + &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q26 + num_freq_bands ); FOR( l = 0; l < num_freq_bands; l++ ) { @@ -1360,14 +1359,14 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( h_dirac_output_synthesis_state.diffuse_power_factor_fx, // Q31 &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q31 num_freq_bands ); - v_multc_fixed( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q31 - L_sub( L_shr( h_dirac_output_synthesis_params.diffuse_compensation_factor_decorr_fx, Q3 ), ONE_IN_Q26 ), // Q26 - &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q26 - num_freq_bands_diff ); - v_multc_fixed( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + num_freq_bands_diff], // Q31 - L_sub( L_shr( h_dirac_output_synthesis_params.diffuse_compensation_factor_fx, Q1 ), ONE_IN_Q26 ), // Q26 - &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + num_freq_bands_diff], // Q26 - num_freq_bands - num_freq_bands_diff ); + v_multc_fx( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q31 + L_sub( L_shr( h_dirac_output_synthesis_params.diffuse_compensation_factor_decorr_fx, Q3 ), ONE_IN_Q26 ), // Q26 + &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands], // Q26 + num_freq_bands_diff ); + v_multc_fx( &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + num_freq_bands_diff], // Q31 + L_sub( L_shr( h_dirac_output_synthesis_params.diffuse_compensation_factor_fx, Q1 ), ONE_IN_Q26 ), // Q26 + &h_dirac_output_synthesis_state.cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + num_freq_bands_diff], // Q26 + num_freq_bands - num_freq_bands_diff ); FOR( l = 0; l < num_freq_bands; l++ ) { @@ -3364,9 +3363,9 @@ void ivas_dirac_dec_compute_power_factors_fx( { Word16 i; - v_multc_fixed( diffuseness_fx, L_negate( ( ONE_IN_Q31 ) ), direct_power_factor, num_freq_bands ); // Q30 + v_multc_fx( diffuseness_fx, L_negate( ( ONE_IN_Q31 ) ), direct_power_factor, num_freq_bands ); // Q30 - v_addc_fixed( direct_power_factor, ONE_IN_Q30, direct_power_factor, num_freq_bands ); // Q30 + v_addc_fx( direct_power_factor, ONE_IN_Q30, direct_power_factor, num_freq_bands ); // Q30 Copy32( diffuseness_fx, diffuse_power_factor, num_freq_bands ); // Q30 @@ -3374,7 +3373,6 @@ void ivas_dirac_dec_compute_power_factors_fx( v_mult_fixed( &diffuse_power_factor[max_band_decorr], &diffuse_power_factor[max_band_decorr], &diffuse_power_factor[max_band_decorr], num_freq_bands - max_band_decorr ); // Q29 - FOR( i = 0; i < max_band_decorr; i++ ) { direct_power_factor[i] = L_shr( direct_power_factor[i], 1 ); // Q29 @@ -3382,6 +3380,7 @@ void ivas_dirac_dec_compute_power_factors_fx( diffuse_power_factor[i] = L_shr( diffuse_power_factor[i], 1 ); // Q29 move32(); } + return; } @@ -3391,6 +3390,7 @@ void ivas_dirac_dec_compute_power_factors_fx( * * *------------------------------------------------------------------------*/ + void ivas_lfe_synth_with_filters_fx( MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, /* i/o: LFE synthesis structure for McMASA */ Word32 *data_fx[], /* o : output signals (Q11) */ @@ -3715,7 +3715,7 @@ static void computeTargetPSDs_diffuse_fx( { cur_idx = imult1616( ch_idx, num_freq_bands ); - v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], aux_buffer_res, sub( num_freq_bands, start_band ) ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ + v_multc_fx( &diffuse_power[start_band], diffuse_responses_square[ch_idx], aux_buffer_res, sub( num_freq_bands, start_band ) ); /* Q31 + Q(q_reference_power) - Q31 = Q(q_reference_power) */ scale_sig32( aux_buffer_res, s_min( sub( num_freq_bands, start_band ), CLDFB_NO_CHANNELS_HALF ), sub( common_q, q_reference_power[0] ) ); /* Q(common_q) */ scale_sig32( aux_buffer_res + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( sub( num_freq_bands, start_band ), CLDFB_NO_CHANNELS_HALF ) ), sub( common_q, q_reference_power[1] ) ); /* Q(common_q) */ scale_sig32( &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ), sub( common_q, *q_cy_auto_diff_smooth ) ); /* Q(common_q) */ @@ -3767,7 +3767,7 @@ static void computeTargetPSDs_diffuse_subframe_fx( { Scale_sig32( &cy_auto_diff_smooth[cur_idx], start_band, sub( q_diffuse_power, *q_cy_auto_diff_smooth ) ); } - v_multc_fixed( &diffuse_power[start_band], diffuse_responses_square[ch_idx], &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ) ); // (q_reference_power, Q31) -> q_reference_power + v_multc_fx( &diffuse_power[start_band], diffuse_responses_square[ch_idx], &cy_auto_diff_smooth[cur_idx + start_band], sub( num_freq_bands, start_band ) ); // (q_reference_power, Q31) -> q_reference_power } *q_cy_auto_diff_smooth = q_cy_auto_diff_smooth_new; @@ -3813,12 +3813,12 @@ static void computeTargetPSDs_diffuse_with_onsets_fx( cur_idx = imult1616( ch_idx, num_freq_bands ); diff_idx = imult1616( proto_frame_diff_index[ch_idx], num_freq_bands ); - v_multc_fixed( &onset_filter[diff_idx], diffuse_responses_square[ch_idx], aux_buffer_res1, num_decorr_freq_bands ); // (Q31, Q31) -> Q31 - v_multc_fixed( &onset_filter[diff_idx], INT_MIN, aux_buffer_res, num_decorr_freq_bands ); // (Q31, Q31) -> Q31 - v_addc_fixed( aux_buffer_res, ONE_IN_Q31, aux_buffer_res, num_decorr_freq_bands ); // Q31 - v_multc_fixed( aux_buffer_res, diffuse_response_p4, aux_buffer_res, num_decorr_freq_bands ); // (Q31, Q31) -> Q31 - v_add_fixed( aux_buffer_res1, aux_buffer_res, aux_buffer_res, num_decorr_freq_bands, Q1 ); // Q30 - v_mult_fixed( aux_buffer_res, diffuse_power, aux_buffer_res, num_decorr_freq_bands ); // (Q30, q_reference_power) -> q_reference_power - Q1 + v_multc_fx( &onset_filter[diff_idx], diffuse_responses_square[ch_idx], aux_buffer_res1, num_decorr_freq_bands ); // (Q31, Q31) -> Q31 + v_multc_fx( &onset_filter[diff_idx], INT_MIN, aux_buffer_res, num_decorr_freq_bands ); // (Q31, Q31) -> Q31 + v_addc_fx( aux_buffer_res, ONE_IN_Q31, aux_buffer_res, num_decorr_freq_bands ); // Q31 + v_multc_fx( aux_buffer_res, diffuse_response_p4, aux_buffer_res, num_decorr_freq_bands ); // (Q31, Q31) -> Q31 + v_add_fixed( aux_buffer_res1, aux_buffer_res, aux_buffer_res, num_decorr_freq_bands, Q1 ); // Q30 + v_mult_fixed( aux_buffer_res, diffuse_power, aux_buffer_res, num_decorr_freq_bands ); // (Q30, q_reference_power) -> q_reference_power - Q1 IF( NE_16( q_common, q_reference_power_min_one[0] ) ) { diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 38ffe53d1..0e73246df 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -4018,7 +4018,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( hDirACRend->h_freq_domain_decorr_ap_params, hDirACRend->h_freq_domain_decorr_ap_state ); - v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ + v_multc_fx( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ v_add_fixed_no_hdrm( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ p_onset_filter_fx = onset_filter_subframe_fx; /*q31*/ } diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 68908cfaa..ef2d7b752 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -175,6 +175,7 @@ ivas_error efap_init_data_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for EFAP bufferS\n" ) ); } + /* get upper bound of number of polygons required */ polyset_size = efap_poly_limit[num_speaker_nodes - 1]; @@ -1612,8 +1613,8 @@ static Word32 get_tri_gain_fx( move16(); Word32 inv_tmpDot2 = L_shl( tmpDot1, norm_l( tmpDot1 ) ); exp = sub( exp, norm_l( tmpDot1 ) ); - Word16 inv_tmpDot1 = Inv16( extract_h( inv_tmpDot2 ), &exp ); // 15-exp - v_multc_fixed( tmpN, L_shl( inv_tmpDot1, add( Q16, exp ) ), N, 2 ); // 22+31-31->22 + Word16 inv_tmpDot1 = Inv16( extract_h( inv_tmpDot2 ), &exp ); // 15-exp + v_multc_fx( tmpN, L_shl( inv_tmpDot1, add( Q16, exp ) ), N, 2 ); // 22+31-31->22 tmpDot2 = dotp_fixed( P_minus_A, N, 2 ); // 22+22-31->13 @@ -1849,7 +1850,7 @@ static Word32 point_plane_distance_fx( // returns output in Q28 move16(); tmpNorm = ISqrt32( tmpNorm, &exp ); // Q29 v_sub_fixed( X, P1, tmpDot1, 3, 1 ); // Q30 - v_multc_fixed( resultCross, tmpNorm, tmpDot2, 3 ); // Q29 - exp + v_multc_fx( resultCross, tmpNorm, tmpDot2, 3 ); // Q29 - exp dist = L_shl( dotp_fixed( tmpDot1, tmpDot2, 3 ), exp ); // Q28 return dist; } @@ -2251,11 +2252,11 @@ static void sort_channels_vertex_fx( move16(); normU = ISqrt32( dotp_fixed( tmpU, tmpU, 3 ) /*q29*/, &exp1 ); /*q=31-exp1*/ // normU = L_shl_sat( normU, exp ); //normU Q31 - v_multc_fixed( tmpU, normU, U, 3 ); // U Q30 - exp1 + v_multc_fx( tmpU, normU, U, 3 ); // U Q30 - exp1 /* Second Base Vector */ - v_sub_fixed( P3, P2, tmpV1, 3, 1 ); // tmpV1 Q30 - v_multc_fixed( U, dotp_fixed( U, tmpV1, 3 ), tmpV2, 3 ); // tmpV2 Q28 - 2*exp1 + v_sub_fixed( P3, P2, tmpV1, 3, 1 ); // tmpV1 Q30 + v_multc_fx( U, dotp_fixed( U, tmpV1, 3 ), tmpV2, 3 ); // tmpV2 Q28 - 2*exp1 FOR( i = 0; i < 3; i++ ) { @@ -2268,7 +2269,7 @@ static void sort_channels_vertex_fx( move16(); normV = ISqrt32( dotp_fixed( tmpV3, tmpV3, 3 ) /*q29*/, &exp2 ); // q=31-exp2 - v_multc_fixed( tmpV3, normV, V, 3 ); // V Q30 - exp2 + v_multc_fx( tmpV3, normV, V, 3 ); // V Q30 - exp2 /* Center of the first Triangle */ FOR( i = 0; i < 3; ++i ) diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 1ce8dc77f..336a1b3bb 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -60,13 +60,12 @@ /* Structure for covariance matrix */ typedef struct { - float xr[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS]; - float xi[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS]; Word32 xr_fx[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS]; Word32 xi_fx[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS]; Word16 xr_e[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS]; /*Stores exponent for xr_fx*/ Word16 xi_e[MCMASA_MAX_ANA_CHANS][MCMASA_MAX_ANA_CHANS]; /*Stores exponent for xi_fx*/ } CovarianceMatrix; + void ivas_mcmasa_param_est_ana_fx( MCMASA_ANA_HANDLE hMcMasa, /* i : McMASA analyzer structure */ Word32 data_fx[][L_FRAME48k], /* i : Audio frame in MC-format */ @@ -80,7 +79,6 @@ void ivas_mcmasa_param_est_ana_fx( const Word16 nchan_inp /* i : Number of input channels */ ); - static void computeVerticalDiffuseness_fx( Word32 **buffer_intensity, /* i : Intensity vectors */ const Word32 *buffer_energy, /* i : Energy */ @@ -88,6 +86,7 @@ static void computeVerticalDiffuseness_fx( Word32 *diffuseness, /* o : Estimated diffuseness Q31 */ Word16 *buffer_intensity_q, Word16 *buffer_energy_q ); + static void compute_cov_mtx_fx( Word32 sr[MCMASA_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX], /* i : Input matrix, real, s[ch][freq] */ Word32 si[MCMASA_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX], /* i : Input matrix, imag, s[ch][freq] */ @@ -96,6 +95,7 @@ static void compute_cov_mtx_fx( CovarianceMatrix *COVls, /* o : Output matrix, contains upper part of cov mtx */ Word16 inp_exp /* i : Stores exponent for sr and si */ ); + static void computeEvenLayout_fx( const Word32 *ls_azimuth, /* i: Q22 */ Word32 *ls_azimuth_even, /* o: Q22 */ @@ -715,8 +715,8 @@ void ivas_mcmasa_param_est_ana_fx( } /* Y */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins ); /*inp_q*/ - v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins ); /*inp_q*/ + v_multc_fx( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins ); /*inp_q*/ + v_multc_fx( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins ); /*inp_q*/ FOR( i = 1; i < numAnalysisChannels; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[1][i], Foa_RealBuffer_fx[1], num_freq_bins ); /*inp_q*/ @@ -731,8 +731,8 @@ void ivas_mcmasa_param_est_ana_fx( } ELSE { - v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins ); /*inp_q*/ - v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins ); /*inp_q*/ + v_multc_fx( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins ); /*inp_q*/ + v_multc_fx( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins ); /*inp_q*/ FOR( i = 1; i < numAnalysisChannels; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[2][i], Foa_RealBuffer_fx[2], num_freq_bins ); /*inp_q*/ @@ -740,8 +740,8 @@ void ivas_mcmasa_param_est_ana_fx( } } /* X */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins ); /*inp_q*/ - v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins ); /*inp_q*/ + v_multc_fx( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins ); /*inp_q*/ + v_multc_fx( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins ); /*inp_q*/ FOR( i = 1; i < numAnalysisChannels; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaMtx_fx[3][i], Foa_RealBuffer_fx[3], num_freq_bins ); /*inp_q*/ @@ -754,8 +754,8 @@ void ivas_mcmasa_param_est_ana_fx( Copy32( Foa_ImagBuffer_fx[0], FoaEven_ImagBuffer_fx[0], num_freq_bins ); /*inp_q*/ /* Y */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_RealBuffer_fx[1], num_freq_bins ); /*inp_q*/ - v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_ImagBuffer_fx[1], num_freq_bins ); /*inp_q*/ + v_multc_fx( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_RealBuffer_fx[1], num_freq_bins ); /*inp_q*/ + v_multc_fx( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[1][0], FoaEven_ImagBuffer_fx[1], num_freq_bins ); /*inp_q*/ FOR( i = 1; i < numAnalysisChannels; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[1][i], FoaEven_RealBuffer_fx[1], num_freq_bins ); /*inp_q*/ @@ -767,8 +767,8 @@ void ivas_mcmasa_param_est_ana_fx( set_zero_fx( FoaEven_ImagBuffer_fx[2], num_freq_bins ); /* X */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_RealBuffer_fx[3], num_freq_bins ); /*inp_q*/ - v_multc_fixed( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_ImagBuffer_fx[3], num_freq_bins ); /*inp_q*/ + v_multc_fx( Chnl_RealBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_RealBuffer_fx[3], num_freq_bins ); /*inp_q*/ + v_multc_fx( Chnl_ImagBuffer_fx[0], hMcMasa->chnlToFoaEvenMtx_fx[3][0], FoaEven_ImagBuffer_fx[3], num_freq_bins ); /*inp_q*/ FOR( i = 1; i < numAnalysisChannels; i++ ) { v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hMcMasa->chnlToFoaEvenMtx_fx[3][i], FoaEven_RealBuffer_fx[3], num_freq_bins ); /*inp_q*/ @@ -824,7 +824,8 @@ void ivas_mcmasa_param_est_ana_fx( Copy32( reference_power_fx[ts], &( hMcMasa->buffer_energy_fx[i_mult( index - 1, num_freq_bands )] ), num_freq_bands ); hMcMasa->buffer_energy_q[index - 1] = reference_power_q; move16(); - computeDiffuseness_fixed( hMcMasa->buffer_intensity_real_fx, hMcMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hMcMasa->buffer_intensity_real_q, hMcMasa->buffer_energy_q, out_exp ); // out_exp = Q30 + computeDiffuseness_fx( hMcMasa->buffer_intensity_real_fx, hMcMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hMcMasa->buffer_intensity_real_q, hMcMasa->buffer_energy_q, out_exp ); // out_exp = Q30 + /* Compute vertical diffuseness, and tune original diffuseness if needed */ IF( !hMcMasa->isHorizontalSetup ) { diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 850debb72..073790e44 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -237,6 +237,7 @@ ivas_error ivas_td_binaural_open_unwrap_fx( } } } + test(); test(); IF( EQ_16( ivas_format, ISM_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) || EQ_16( ivas_format, SBA_ISM_FORMAT ) ) @@ -260,7 +261,8 @@ ivas_error ivas_td_binaural_open_unwrap_fx( move32(); move32(); move32(); - if ( NULL == distAtt ) + + IF( NULL == distAtt ) { DistAtten.DistAttenModel = TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED; // Q0 move16(); @@ -271,13 +273,18 @@ ivas_error ivas_td_binaural_open_unwrap_fx( DistAtten.RollOffFactor_fx = ONE_IN_Q30; // Q30 move32(); } - else + ELSE { DistAtten.DistAttenModel = TDREND_DIST_ATTEN_MODEL_INV_DIST_CLAMPED; // Q0 + move16(); DistAtten.MaxDist_fx = distAtt[0]; + move32(); DistAtten.RefDist_fx = distAtt[1]; + move32(); DistAtten.RollOffFactor_fx = distAtt[2]; + move32(); } + IF( NE_32( ( error = TDREND_MIX_SRC_SetDirAtten_fx( pBinRendTd, nS, DirAtten_p ) ), IVAS_ERR_OK ) ) { return error; @@ -451,13 +458,11 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( } /* Render subframe */ - IF( NE_32( ( error = TDREND_GetMix_fx( hBinRendererTd, output_fx, subframe_length, subframe_idx ) ), IVAS_ERR_OK ) ) { return error; } - /* Advance subframe pointer */ c_indx = 0; move16(); @@ -507,7 +512,6 @@ ivas_error TDREND_GetMix_fx( Word32 hrf_left_delta[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; Word32 hrf_right_delta[SFX_SPAT_BIN_MAX_FILTER_LENGTH]; Word16 intp_count; - Word16 hrf_left_delta_e = 0, hrf_right_delta_e = 0; move16(); move16(); diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 4c30f23de..7b27384ec 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -135,6 +135,7 @@ ivas_error TDREND_MIX_SRC_SetDir_fx( * * Set directional attenuation for the mixer. --------------------------------------------------------------------*/ + ivas_error TDREND_MIX_SRC_SetDirAtten_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const Word16 SrcInd, /* i : Source index Q0 */ @@ -168,6 +169,7 @@ ivas_error TDREND_MIX_SRC_SetDistAtten( ) { TDREND_SRC_SPATIAL_t *SrcSpatial_p; + IF( GT_16( SrcInd, hBinRendererTd->MaxSrcInd ) ) { return ( IVAS_ERROR( IVAS_ERR_INVALID_INDEX, "Index exceeds max index\n" ) ); @@ -270,6 +272,7 @@ static void TDREND_SRC_REND_Init_fx( return; } + /*-------------------------------------------------------------------* * TDREND_SRC_REND_UpdateFiltersFromSpatialParams() * @@ -280,31 +283,19 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ - Word32 *hrf_left_prev, - /* i/o: Left filter */ // exp(hrf_left_prev_e) - Word16 *hrf_left_prev_e, - /* i/o: Left filter exponent */ // Q0 - Word32 *hrf_right_prev, - /* i/o: Right filter */ // exp(hrf_right_prev_e) - Word16 *hrf_right_prev_e, - /* i/o: Right filter exponent */ // Q0 - Word32 *hrf_left_delta, - /* o : Left filter interpolation delta */ // exp(hrf_left_delta_e) - Word16 *hrf_left_delta_e, - /* o : Left filter interpolation delta exponent */ // Q0 - Word32 *hrf_right_delta, - /* o : Right filter interpolation delta */ // exp(hrf_right_delta_e) - Word16 *hrf_right_delta_e, - /* o : Right filter interpolation delta exponent */ // Q0 - Word16 *intp_count, - /* o : Interpolation count */ // Q0 - Word16 *filterlength, - /* o : Length of filters */ // Q0 - Word16 *itd, - /* o : ITD value */ // Q0 - Word32 *Gain, - /* o : Gain value */ // Q30 - TDREND_SRC_t *Src_p /* i/o: Source pointer */ + Word32 *hrf_left_prev, /* i/o: Left filter exp(hrf_left_prev_e) */ + Word16 *hrf_left_prev_e, /* i/o: Left filter exponent Q0 */ + Word32 *hrf_right_prev, /* i/o: Right filter exp(hrf_right_prev_e) */ + Word16 *hrf_right_prev_e, /* i/o: Right filter exponent Q0 */ + Word32 *hrf_left_delta, /* o : Left filter interpolation delta exp(hrf_left_delta_e) */ + Word16 *hrf_left_delta_e, /* o : Left filter interpolation delta exponent Q0 */ + Word32 *hrf_right_delta, /* o : Right filter interpolation delta exp(hrf_right_delta_e) */ + Word16 *hrf_right_delta_e, /* o : Right filter interpolation delta exponent Q0 */ + Word16 *intp_count, /* o : Interpolation count Q0 */ + Word16 *filterlength, /* o : Length of filters Q0 */ + Word16 *itd, /* o : ITD value Q0 */ + Word32 *Gain, /* o : Gain value Q30 */ + TDREND_SRC_t *Src_p /* i/o: Source pointer */ ) { TDREND_MIX_Listener_t *Listener_p; @@ -393,11 +384,11 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( move32(); } - /* Update total gains */ *Gain = L_shl( Mpy_32_32( L_shl( L_mult( *SrcRend_p->SrcGain_p_fx, *SrcRend_p->DirGain_p_fx ), 1 ), L_shl( L_mult( *SrcRend_p->DistGain_p_fx, hBinRendererTd->Gain_fx ), 1 ) ), 1 ); // Q30 move32(); - /* Delta for interpolation, in case the angular step exceeds MAX_ANGULAR_STEP */ + + /* Delta for interpolation, in case the angular step exceeds MAX_ANGULAR_STEP=0.01f */ Word32 ele_tmp = Src_p->elev_prev_fx; // Q22 move32(); IF( GT_32( ele_tmp, DEG_180_IN_Q22 ) ) @@ -464,8 +455,6 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( move16(); } - test(); - IF( ( *intp_count > 0 ) ) { /* Set deltas for interpolation */ @@ -486,8 +475,8 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( *hrf_left_delta_e = tmp_e; move16(); - Word32 fac = L_deposit_h( div_s( 1, *intp_count ) ); // Q15 - v_multc_fixed( hrf_left_delta, fac, hrf_left_delta, *filterlength ); // exp(hrf_left_delta_e) + Word32 fac = L_deposit_h( div_s( 1, *intp_count ) ); // Q15 + v_multc_fx( hrf_left_delta, fac, hrf_left_delta, *filterlength ); // exp(hrf_left_delta_e) tmp_e = s_max( *hrf_right_prev_e, hrf_right_e ); FOR( Word16 i = 0; i < *filterlength; i++ ) @@ -505,7 +494,7 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( *hrf_right_delta_e = tmp_e; move16(); - v_multc_fixed( hrf_right_delta, fac, hrf_right_delta, *filterlength ); // exp(hrf_right_delta_e) + v_multc_fx( hrf_right_delta, fac, hrf_right_delta, *filterlength ); // exp(hrf_right_delta_e) } ELSE { @@ -527,6 +516,7 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( return; } + /*-------------------------------------------------------------------* * TDREND_SRC_SPATIAL_Alloc() * @@ -652,6 +642,7 @@ static void TDREND_SRC_SPATIAL_SetDirAtten_fx( return; } + /*-------------------------------------------------------------------* * TDREND_SRC_SPATIAL_SetDistAtten() * @@ -676,6 +667,7 @@ static void TDREND_SRC_SPATIAL_SetDistAtten( return; } + /*-------------------------------------------------------------------* * TDREND_SRC_SPATIAL_GetDirGain() * @@ -683,11 +675,11 @@ static void TDREND_SRC_SPATIAL_SetDistAtten( --------------------------------------------------------------------*/ /*! r: Gain value */ -static Word16 TDREND_SRC_SPATIAL_GetDirGain_fx( /* o : Directional Gain Output Q14 */ - const TDREND_DirAtten_t *DirAtten_p, /* i : Directional attenuation specification */ - const Word32 *Front_p_fx, /* i : Front-pointing vector Q30 */ - const Word32 *RelPos_p_fx, /* i : Relative position */ - const Word16 RelPos_p_e /* i : Relative position exp RelPos_p_e */ +static Word16 TDREND_SRC_SPATIAL_GetDirGain_fx( + const TDREND_DirAtten_t *DirAtten_p, /* i : Directional attenuation specification */ + const Word32 *Front_p_fx, /* i : Front-pointing vector Q30 */ + const Word32 *RelPos_p_fx, /* i : Relative position */ + const Word16 RelPos_p_e /* i : Relative position exp RelPos_p_e */ ) { Word16 DirGain_fx; // Q14 @@ -768,10 +760,10 @@ static Word16 TDREND_SRC_SPATIAL_GetDirGain_fx( --------------------------------------------------------------------*/ /*! r: Gain value */ -static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx( /* o : Distance gain Q14 */ - const TDREND_DistAtten_t *DistAtten_p, /* i : Distance attenuation parameters */ - const Word32 Dist_fx, /* i : Distance value Dist_e */ - const Word16 Dist_e /* i : Distance value exp */ +static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx( + const TDREND_DistAtten_t *DistAtten_p, /* i : Distance attenuation parameters */ + const Word32 Dist_fx, /* i : Distance value Dist_e */ + const Word16 Dist_e /* i : Distance value exp */ ) { Word16 DistGain_fx; // Q14 @@ -841,11 +833,13 @@ static Word16 TDREND_SRC_SPATIAL_GetDistGain_fx( return DistGain_fx; } + /*-------------------------------------------------------------------* * TDREND_SRC_Alloc() * * Allocate a source. --------------------------------------------------------------------*/ + ivas_error TDREND_SRC_Alloc( TDREND_SRC_t **Src_pp /* i/o: Source */ ) @@ -880,6 +874,7 @@ ivas_error TDREND_SRC_Alloc( return error; } + /*-------------------------------------------------------------------* * TDREND_SRC_Dealloc() * @@ -901,13 +896,17 @@ void TDREND_SRC_Dealloc( /* Free the Src_p variable */ free( Src_p ); Src_p = NULL; + return; } + + /*-------------------------------------------------------------------* * TDREND_SRC_Init() * * Initializes a source. --------------------------------------------------------------------*/ + void TDREND_SRC_Init_fx( TDREND_SRC_t *Src_p, /* i/o: Source to initialize */ const TDREND_PosType_t PosType /* i : Position type specifier */ @@ -951,5 +950,6 @@ void TDREND_SRC_Init_fx( move32(); Src_p->prevGain_fx = ONE_IN_Q30; // Q30 move32(); + return; } diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 67e72e84c..a2c1539e7 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -496,8 +496,8 @@ static void ivas_omasa_param_est_ana_fx( /* Y */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins ); // Q: Chnl_RealBuffer_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins ); // Q: Chnl_ImagBuffer_q + v_multc_fx( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins ); // Q: Chnl_RealBuffer_q + v_multc_fx( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins ); // Q: Chnl_ImagBuffer_q FOR( i = 1; i < nchan_ism; i++ ) { @@ -507,8 +507,8 @@ static void ivas_omasa_param_est_ana_fx( /* Z */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q + v_multc_fx( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q + v_multc_fx( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q FOR( i = 1; i < nchan_ism; i++ ) { @@ -516,8 +516,8 @@ static void ivas_omasa_param_est_ana_fx( v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[2][i], Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q } - v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins ); // Q: Chnl_RealBuffer_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins ); // Q: Chnl_ImagBuffer_q + v_multc_fx( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins ); // Q: Chnl_RealBuffer_q + v_multc_fx( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins ); // Q: Chnl_ImagBuffer_q FOR( i = 1; i < nchan_ism; i++ ) { @@ -563,7 +563,7 @@ static void ivas_omasa_param_est_ana_fx( hOMasa->buffer_energy_q[index - 1] = reference_power_q; move16(); - computeDiffuseness_fixed( hOMasa->buffer_intensity_real_fx, hOMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hOMasa->buffer_intensity_real_q, hOMasa->buffer_energy_q, &diffuseness_q ); // diffuseness_q=Q30 + computeDiffuseness_fx( hOMasa->buffer_intensity_real_fx, hOMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hOMasa->buffer_intensity_real_q, hOMasa->buffer_energy_q, &diffuseness_q ); // diffuseness_q=Q30 FOR( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ ) { @@ -654,7 +654,6 @@ static void ivas_omasa_dmx_fx( const Word16 interpolator_fx[L_FRAME48k] ) { Word16 i, j, k, l, tmp1, tmp2; - Word16 azimuth_fx, elevation_fx; Word16 gains_fx[MASA_MAX_TRANSPORT_CHANNELS]; Word16 g1_fx, g2_fx, scale; @@ -686,7 +685,6 @@ static void ivas_omasa_dmx_fx( { FOR( k = 0; k < input_frame; k++ ) { - g1_fx = interpolator_fx[k]; // Q15 move16(); scale = BASOP_Util_Add_MantExp( 16384, 1, negate( g1_fx ), 0, &g2_fx ); @@ -761,8 +759,6 @@ static void ivas_omasa_dmx_fx( return; } -/* Compute downmix */ - /*--------------------------------------------------------------------------* * computeIntensityVector_ana() @@ -850,11 +846,6 @@ void computeIntensityVector_ana_fx( return; } -/*--------------------------------------------------------------------------* - * computeIntensityVector_ana() - * - * - *--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------* diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index ebd1f3f27..61ff57882 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -500,7 +500,7 @@ ivas_error ivas_output_buff_dec_fx( /* note: these are intra-frame heap memories */ IF( ( p_output_f[ch] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output audio buffer!\n" ) ); } } } diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 84af7ab1c..59a1645ed 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -108,24 +108,30 @@ void limiter_process_fx( Word16 *strong_saturation_cnt, /* i/o: counter of strong saturations (can be NULL) */ Word16 q_factor /* i : Q factor of output samples */ ); + + /*----------------------------------------------------------------------------------* * TD decorr. function prototypes *----------------------------------------------------------------------------------*/ + ivas_error ivas_td_decorr_dec_open_fx( ivas_td_decorr_state_t **hTdDecorr, /* i/o: TD decorrelator handle */ const Word32 output_Fs, /* i : output sampling rate */ const Word16 nchan_internal, /* i : number of internal channels */ const Word16 ducking_flag /* i : ducking flag */ ); + void ivas_td_decorr_dec_close( ivas_td_decorr_state_t **hTdDecorr /* i/o: TD decorrelator handle */ ); + void ivas_td_decorr_process_fx( ivas_td_decorr_state_t *hTdDecorr, /* i/o: TD decoderrelator handle */ Word32 *pcm_in[], /* i : input audio channels */ Word32 **ppOut_pcm, /* o : output audio channels */ const Word16 output_frame /* i : output frame length */ ); + ivas_error ivas_td_decorr_reconfig_dec( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const Word32 ivas_total_brate, /* i : total IVAS bitrate */ @@ -141,6 +147,8 @@ void ivas_td_decorr_APD_iir_filter_fx( const Word16 num_APD_sections, /* i : numbef of APD sections */ const Word16 output_frame /* i : output frame length */ ); + + /*----------------------------------------------------------------------------------* * Amplitude Panning EFAP prototypes *----------------------------------------------------------------------------------*/ @@ -696,10 +704,10 @@ void ivas_td_binaural_close_fx( ); ivas_error TDREND_GetMix_fx( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - Word32 *output[], /* i/o: ISM object synth / rendered output in 0,1 */ - const Word16 subframe_length, /* i/o: subframe length Q11 */ -const Word16 subframe_idx /* i : Subframe index to 5 ms subframe */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + Word32 *output[], /* i/o: ISM object synth / rendered output in 0,1 */ + const Word16 subframe_length, /* i/o: subframe length Q11 */ + const Word16 subframe_idx /* i : Subframe index to 5 ms subframe */ ); void BSplineModelEvalDealloc_fx( @@ -770,22 +778,22 @@ ivas_error TDREND_MIX_SRC_SetPlayState( ); void TDREND_SRC_REND_UpdateFiltersFromSpatialParams_fx( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ - TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ - Word32 *hrf_left_prev, /* i/o: Left filter */ - Word16 *hrf_left_prev_e, /* i/o: Left filter exponent */ - Word32 *hrf_right_prev, /* i/o: Right filter */ - Word16 *hrf_right_prev_e, /* i/o: Right filter exponent */ - Word32 *hrf_left_delta, /* o : Left filter interpolation delta */ - Word16 *hrf_left_delta_e, /* o : Left filter interpolation delta exponent */ - Word32 *hrf_right_delta, /* o : Right filter interpolation delta */ - Word16 *hrf_right_delta_e, /* o : Right filter interpolation delta exponent */ - Word16 *intp_count, /* o : Interpolation count */ - Word16 *filterlength, /* o : Length of filters */ - Word16 *itd, /* o : ITD value */ - Word32 *Gain, /* o : Gain value Q30 */ - TDREND_SRC_t *Src_p /* i/o: Source pointer */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ + TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ + Word32 *hrf_left_prev, /* i/o: Left filter */ + Word16 *hrf_left_prev_e, /* i/o: Left filter exponent */ + Word32 *hrf_right_prev, /* i/o: Right filter */ + Word16 *hrf_right_prev_e, /* i/o: Right filter exponent */ + Word32 *hrf_left_delta, /* o : Left filter interpolation delta */ + Word16 *hrf_left_delta_e, /* o : Left filter interpolation delta exponent */ + Word32 *hrf_right_delta, /* o : Right filter interpolation delta */ + Word16 *hrf_right_delta_e, /* o : Right filter interpolation delta exponent */ + Word16 *intp_count, /* o : Interpolation count */ + Word16 *filterlength, /* o : Length of filters */ + Word16 *itd, /* o : ITD value */ + Word32 *Gain, /* o : Gain value Q30 */ + TDREND_SRC_t *Src_p /* i/o: Source pointer */ ); ivas_error TDREND_SRC_Alloc( @@ -801,36 +809,31 @@ void TDREND_SRC_Init_fx( const TDREND_PosType_t PosType /* i : Position type specifier */ ); -/* ----- Object renderer - vec ----- */ void TDREND_SPATIAL_VecInit_fx( - Word32 *Pos_p, /* o : Output vector */ - const Word32 PosX, /* i : X value */ - const Word32 PosY, /* i : Y value */ - const Word32 PosZ /* i : Z value */ + Word32 *Pos_p, /* o : Output vector */ + const Word32 PosX, /* i : X value */ + const Word32 PosY, /* i : Y value */ + const Word32 PosZ /* i : Z value */ ); -/*! r: Euclidian norm value */ - void TDREND_SPATIAL_VecNormalize_fx( - const Word32 *Vec_p_fx, /* i : Input vector Qx */ - Word16 q, /* i : Input vector Q-factor */ - Word32 *VecNorm_p_fx /* o : Normalised output vector Q30 */ + const Word32 *Vec_p_fx, /* i : Input vector Qx */ + Word16 q, /* i : Input vector Q-factor */ + Word32 *VecNorm_p_fx /* o : Normalised output vector Q30 */ ); Word16 TDREND_SPATIAL_EvalOrthonormOrient_fx( - Word32 *FrontVecON_p_fx, /* i/o: Normalized front vector Q30 */ - Word32 *UpVecON_p_fx, /* i/o: Normalized up vector Q30 */ - Word32 *RightVecON_p_fx, /* i/o: Normalized right vector Q30 */ - const Word32 *FrontVec_p_fx, /* i : Input front vector Qx */ - const Word32 *UpVec_p_fx, /* i : Input up vector orient_q */ - const Word16 orient_q /* i : Input up Q-factor */ + Word32 *FrontVecON_p_fx, /* i/o: Normalized front vector Q30 */ + Word32 *UpVecON_p_fx, /* i/o: Normalized up vector Q30 */ + Word32 *RightVecON_p_fx, /* i/o: Normalized right vector Q30 */ + const Word32 *FrontVec_p_fx, /* i : Input front vector Qx */ + const Word32 *UpVec_p_fx, /* i : Input up vector orient_q */ + const Word16 orient_q /* i : Input up Q-factor */ ); -/* ----- Object renderer - mix ----- */ - ivas_error TDREND_MIX_AddSrc_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - Word16 *SrcInd, /* o : Source index */ + Word16 *SrcInd, /* o : Source index */ const TDREND_PosType_t PosType /* i : Position type (absolute/relative) */ ); @@ -847,32 +850,30 @@ ivas_error TDREND_MIX_Init_fx( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HRTF data (initialized in case of NULL) */ const TDREND_MixSpatSpec_t *MixSpatSpec_p, /* i : Mixer spatial specification */ - const Word32 output_Fs /* i : Output sampling rate */ + const Word32 output_Fs /* i : Output sampling rate */ ); - /* ----- Object renderer - sfx ----- */ - void TDREND_Apply_ITD_fx( - Word32 *input_fx, /* i : Input subframe to be time adjusted Qx */ - Word32 *out_left_fx, /* o : Output left channel with ITD applied Qx */ - Word32 *out_right_fx, /* o : Output right channel with ITD applied Qx */ - Word16 *previtd, /* i/o: Previous ITD value */ - const Word16 itd, /* i : Current subframe ITD value */ - Word32 *mem_itd_fx, /* i/o: ITD buffer memory Qx */ - const Word16 length /* i : Subframe length */ + Word32 *input_fx, /* i : Input subframe to be time adjusted Qx */ + Word32 *out_left_fx, /* o : Output left channel with ITD applied Qx */ + Word32 *out_right_fx, /* o : Output right channel with ITD applied Qx */ + Word16 *previtd, /* i/o: Previous ITD value */ + const Word16 itd, /* i : Current subframe ITD value */ + Word32 *mem_itd_fx, /* i/o: ITD buffer memory Qx */ + const Word16 length /* i : Subframe length */ ); void TDREND_firfilt_fx( - Word32 *signal_fx, /* i/o: Input signal / Filtered signal Qx */ - Word32 *filter_fx, /* i/o: FIR filter Qy */ - const Word16 filter_e, /* i : FIR filter exp */ - const Word32 *filter_delta_fx, /* i : FIR filter delta Qy */ - const Word16 intp_count, /* i : interpolation count */ - Word32 *mem_fx, /* i/o: filter memory Qx */ - const Word16 subframe_length, /* i : Length of signal */ - const Word16 filterlength, /* i : Filter length */ - const Word32 Gain_fx, /* i : Gain Q30 */ - const Word32 prevGain_fx /* i : Previous gain Q30 */ + Word32 *signal_fx, /* i/o: Input signal / Filtered signal Qx */ + Word32 *filter_fx, /* i/o: FIR filter Qy */ + const Word16 filter_e, /* i : FIR filter exp */ + const Word32 *filter_delta_fx, /* i : FIR filter delta Qy */ + const Word16 intp_count, /* i : interpolation count */ + Word32 *mem_fx, /* i/o: filter memory Qx */ + const Word16 subframe_length, /* i : Length of signal */ + const Word16 filterlength, /* i : Filter length */ + const Word32 Gain_fx, /* i : Gain Q30 */ + const Word32 prevGain_fx /* i : Previous gain Q30 */ ); @@ -897,7 +898,7 @@ void ivas_rend_closeCrend( ); ivas_error ivas_hrtf_init( - HRTFS_DATA *hHrtf /* i/o: HRTF handle */ + HRTFS_DATA *hHrtf /* i/o: HRTF handle */ ); ivas_error ivas_rend_initCrendWrapper( @@ -914,10 +915,10 @@ ivas_error ivas_rend_crendProcessSubframe( const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ - Word32 *input_f[], /* i : transport channels */ - Word32 *output[], /* i/o: input/output audio channels */ - const Word16 n_samples_to_render, /* i : output frame length per channel */ - const Word32 output_Fs, /* i : output sampling rate */ + Word32 *input_f[], /* i : transport channels */ + Word32 *output[], /* i/o: input/output audio channels */ + const Word16 n_samples_to_render, /* i : output frame length per channel */ + const Word32 output_Fs, /* i : output sampling rate */ const Word16 pos_idx ); @@ -927,16 +928,15 @@ ivas_error ivas_rend_crendProcessSubframe( *----------------------------------------------------------------------------------*/ ivas_error ivas_binaural_reverb_init( - REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ + REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ - const Word16 numBins, /* i : number of CLDFB bins */ - const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ + const Word16 numBins, /* i : number of CLDFB bins */ + const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const Word32 sampling_rate, /* i : sampling rate */ - const Word32 *defaultTimes, /* i : default reverberation times */ - const Word32 *defaultEne /* i : default reverberation energies */ - , - Word32 *earlyEne /* i/o: Early part energies to be modified */ + const Word32 sampling_rate, /* i : sampling rate */ + const Word32 *defaultTimes, /* i : default reverberation times */ + const Word32 *defaultEne, /* i : default reverberation energies */ + Word32 *earlyEne /* i/o: Early part energies to be modified */ ); void ivas_binaural_reverb_close_fx( @@ -944,83 +944,85 @@ void ivas_binaural_reverb_close_fx( ); void ivas_binaural_reverb_processSubframe_fx( - REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ - const Word16 numInChannels, /* i : num inputs to be processed */ - const Word16 numSlots, /* i : number of slots to be processed */ - Word32 inReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real, Comment: This change swaps two first dimensions as first dimension is not constant. */ - Word32 inImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */ - Word32 outReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* o : output CLDFB data real */ - Word32 outImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* o : output CLDFB data imag */ + REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ + const Word16 numInChannels, /* i : num inputs to be processed */ + const Word16 numSlots, /* i : number of slots to be processed */ + Word32 inReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data real, Comment: This change swaps two first dimensions as first dimension is not constant. */ + Word32 inImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : input CLDFB data imag */ + Word32 outReal[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX],/* o : output CLDFB data real */ + Word32 outImag[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /* o : output CLDFB data imag */ ); ivas_error ivas_reverb_open_fx( - REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ - const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ - RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ - const Word32 output_Fs /* i : output sampling rate */ + REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ + RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ + const Word32 output_Fs /* i : output sampling rate */ ); void ivas_reverb_close( - REVERB_HANDLE *hReverb /* i/o: Reverberator handle */ + REVERB_HANDLE *hReverb /* i/o: Reverberator handle */ ); ivas_error ivas_reverb_process_fx( - const REVERB_HANDLE hReverb, /* i : Reverberator handle */ - const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ - const Word16 mix_signals, /* i : add reverb to output signal */ - Word32 *pcm_in[], /* i (Q11): the PCM audio to apply reverb on */ - Word32 *pcm_out[], /* o : the PCM audio with reverb applied */ - const Word16 i_ts /* i : (Q0) subframe index */ + const REVERB_HANDLE hReverb, /* i : Reverberator handle */ + const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ + const Word16 mix_signals, /* i : add reverb to output signal */ + Word32 *pcm_in[], /* i (Q11): the PCM audio to apply reverb on */ + Word32 *pcm_out[], /* o : the PCM audio with reverb applied */ + const Word16 i_ts /* i : (Q0) subframe index */ ); 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 Q11 */ - 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 */ ); /*! r: sample gotten out of delay line, and amplified by set gain */ Word32 ivas_rev_delay_line_get_sample_fx( /* Q11 */ - ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ + 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 Q11 */ + 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( 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 */ + 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 */ ); 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 Q11 */ + 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 */ ); void ivas_reverb_iir_filt_init( ivas_rev_iir_filter_t *iirFilter, /* o : IIR filter */ - const UWord16 maxTaps /* i : maximum number of filter taps */ + const UWord16 maxTaps /* i : maximum number of filter taps */ ); void ivas_reverb_iir_filt_set( ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ - UWord16 nr_taps, /* i : number of IIR filter taps */ - const Word16 *coefA, /* i : A filter coefficients to set */ - const Word16 *coefB /* i : the B filter coefficients to set */ + UWord16 nr_taps, /* i : number of IIR filter taps */ + const Word16 *coefA, /* i : A filter coefficients to set */ + const Word16 *coefB /* i : the B filter coefficients to set */ ); + void ivas_reverb_iir_filt_2taps_feed_blk_fx( ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ - const UWord16 blk_size, /* i : size */ - const Word32 *input, /* i : input buffer */ - Word32 *output /* i : output buffer */ + const UWord16 blk_size, /* i : size */ + const Word32 *input, /* i : input buffer */ + Word32 *output /* o : output buffer */ ); UWord16 int_log2( UWord32 powerOf2 ); + Word16 ivas_reverb_t2f_f2t_init( ivas_reverb_t2f_f2t_t *t2f_f2t, const Word16 fft_size, @@ -1387,10 +1389,10 @@ ivas_error ivas_orient_trk_GetTrackedRotation_fx( ); ivas_error ivas_orient_trk_Process_fx( - ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ - IVAS_QUATERNION absRot, /* i : absolute head rotation */ - Word32 updateRate_fx, /* i : rotation update rate [Hz] */ - IVAS_QUATERNION *pTrkRot /* o : tracked rotation */ + ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ + IVAS_QUATERNION absRot, /* i : absolute head rotation */ + Word32 updateRate_fx, /* i : rotation update rate [Hz] */ + IVAS_QUATERNION *pTrkRot /* o : tracked rotation */ ); @@ -1401,16 +1403,16 @@ ivas_error ivas_orient_trk_Process_fx( ivas_error ivas_mcmasa_ana_open( MCMASA_ANA_HANDLE *hMcMasaPtr, /* i/o: McMASA data handle pointer */ const AUDIO_CONFIG inConfig, /* i : Input config */ - Word32 input_Fs /* i : Sampling frequency */ + Word32 input_Fs /* i : Sampling frequency */ ); void ivas_mcmasa_ana_fx( - MCMASA_ANA_HANDLE hMcMasa, /* i/o: McMASA encoder handle */ - Word32 data[][L_FRAME48k], /* i/o: Input / transport audio signals */ + MCMASA_ANA_HANDLE hMcMasa, /* i/o: McMASA encoder handle */ + Word32 data[][L_FRAME48k], /* i/o: Input / transport audio signals */ Word16 q_data, - const Word16 input_frame, /* i : Input frame size */ - const Word16 nchan_transport, /* i : Number of transport channels */ - const Word16 nchan_inp /* i : Number of input channels */ + const Word16 input_frame, /* i : Input frame size */ + const Word16 nchan_transport, /* i : Number of transport channels */ + const Word16 nchan_inp /* i : Number of input channels */ ); void ivas_mcmasa_ana_close( @@ -1419,28 +1421,28 @@ void ivas_mcmasa_ana_close( ivas_error ivas_omasa_ana_open( OMASA_ANA_HANDLE *hOMasaPtr, /* i/o: OMASA data handle pointer */ - Word32 input_Fs, /* i : Sampling frequency */ - UWord16 total_num_objects /* i : Number of objects */ + Word32 input_Fs, /* i : Sampling frequency */ + UWord16 total_num_objects /* i : Number of objects */ ); void ivas_omasa_ana_fx( OMASA_ANA_HANDLE hOMasa, /* i/o: OMASA analysis handle */ - Word32 data_in_f_fx[][L_FRAME48k], /* i/o: Input / transport audio signals */ + Word32 data_in_f_fx[][L_FRAME48k], /* i/o: Input / transport audio signals */ Word16 *q, - const Word16 input_frame, /* i : Input frame size */ - const Word16 nchan_transport, /* i : Number of transport channels */ - const Word16 nchan_ism /* i : Number of objects for parameter analysis*/ + const Word16 input_frame, /* i : Input frame size */ + const Word16 nchan_transport, /* i : Number of transport channels */ + const Word16 nchan_ism /* i : Number of objects for parameter analysis*/ ); void ivas_omasa_ana_close( OMASA_ANA_HANDLE *hOMasa /* i/o: analysis OMASA handle */ ); void computeIntensityVector_ana_fx( - const Word16 *band_grouping, /* i : Band grouping for estimation */ - Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal Qx */ - Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input sig Qx */ - const Word16 num_frequency_bands, /* i : Number of frequency bands */ - Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /* o : Intensity */ + const Word16 *band_grouping, /* i : Band grouping for estimation */ + Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal Qx */ + Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input sig Qx */ + const Word16 num_frequency_bands, /* i : Number of frequency bands */ + Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /* o : Intensity */ Word16 q_intensity_real[MASA_FREQUENCY_BANDS], Word16 inp_q ); @@ -1474,11 +1476,11 @@ ivas_error ivas_dirac_ana_open_fx( ); void ivas_dirac_ana_fx( - DIRAC_ANA_HANDLE hDirAC, /* i/o: DIRAC analysis handle */ - Word32 data_in_fx[][L_FRAME48k], /* i/o: Input / transport audio signals */ - const Word16 input_frame, /* i : Input frame size */ + DIRAC_ANA_HANDLE hDirAC, /* i/o: DIRAC analysis handle */ + Word32 data_in_fx[][L_FRAME48k], /* i/o: Input / transport audio signals */ + const Word16 input_frame, /* i : Input frame size */ const Word16 nchan_transport, /* i : Number of transport channels */ - const Word16 data_q /*i : Q of data_in_fx*/ + const Word16 data_q /* i : Q of data_in_fx */ ); void ivas_dirac_ana_close_fx( @@ -1499,8 +1501,8 @@ void ivas_prerend_merge_masa_metadata_fx( ivas_error masaPrerendOpen_fx( MASA_PREREND_HANDLE *hMasaPrerendPtr, /* o : handle to the opened prerenderer */ - Word16 numTransports, /* i : number of transport channels */ - Word32 input_Fs /* i : signal sampling rate */ + Word16 numTransports, /* i : number of transport channels */ + Word32 input_Fs /* i : signal sampling rate */ ); void masaPrerendClose_fx( diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index a1ae8152d..28c421cfd 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1432,11 +1432,13 @@ static ivas_error setup_FDN_branches_fx( return error; } + /*------------------------------------------------------------------------- * ivas_reverb_open_fx() * * Allocate and initialize FDN reverberation handle *------------------------------------------------------------------------*/ + ivas_error ivas_reverb_open_fx( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ @@ -1554,6 +1556,7 @@ ivas_error ivas_reverb_open_fx( { return error; } + /* Compute target levels (gains) for the coloration filters */ Word32 *pHrtf_avg_pwr_response_l_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 * ) ); Word32 *pHrtf_avg_pwr_response_r_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 * ) ); @@ -1683,13 +1686,13 @@ ivas_error ivas_reverb_open_fx( return error; } - if ( *hReverb == NULL ) + IF( *hReverb == NULL ) { /* init predelay */ ivas_rev_delay_line_init( &( pState->predelay_line ), pState->pPredelay_buffer_fx, params.pre_delay, predelay_bf_len ); /* set up feedback delay network */ - if ( ( error = setup_FDN_branches_fx( pState, ¶ms ) ) != IVAS_ERR_OK ) + IF( ( error = setup_FDN_branches_fx( pState, ¶ms ) ) != IVAS_ERR_OK ) { return error; } @@ -2149,8 +2152,8 @@ void ivas_binaural_reverb_processSubframe_fx( /* Add the data from the end of the loop to the beginning, with an attenuation factor * according to RT60. This procedure generates an IIR decaying response. The response * is decorrelated later on. */ - v_multc_fixed( hReverb->loopBufReal_fx[bin] + hReverb->loopBufLength[bin], hReverb->loopAttenuationFactor_fx[bin], hReverb->loopBufReal_fx[bin], numSlots ); - v_multc_fixed( hReverb->loopBufImag_fx[bin] + hReverb->loopBufLength[bin], hReverb->loopAttenuationFactor_fx[bin], hReverb->loopBufImag_fx[bin], numSlots ); + v_multc_fx( hReverb->loopBufReal_fx[bin] + hReverb->loopBufLength[bin], hReverb->loopAttenuationFactor_fx[bin], hReverb->loopBufReal_fx[bin], numSlots ); + v_multc_fx( hReverb->loopBufImag_fx[bin] + hReverb->loopBufLength[bin], hReverb->loopAttenuationFactor_fx[bin], hReverb->loopBufImag_fx[bin], numSlots ); } /* 2) Apply the determined pre-delay to the input audio, and add the delayed audio to the loop. */ @@ -2434,9 +2437,8 @@ ivas_error ivas_binaural_reverb_init( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ const Word32 sampling_rate, /* i : sampling rate */ const Word32 *defaultTimes, /* i : default reverberation times */ - const Word32 *defaultEne /* i : default reverberation energies */ - , - Word32 *earlyEne /* i/o: Early part energies to be modified */ + const Word32 *defaultEne, /* i : default reverberation energies */ + Word32 *earlyEne /* i/o: Early part energies to be modified */ ) { ivas_error error; @@ -2449,7 +2451,6 @@ ivas_error ivas_binaural_reverb_init( IF( roomAcoustics != NULL ) { - IF( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, revTimes, revEne ) ) != IVAS_ERR_OK ) { return error; @@ -2525,6 +2526,8 @@ ivas_error ivas_binaural_reverb_init( return error; } + + /*------------------------------------------------------------------------- * ivas_binaural_reverb_close_fx() * diff --git a/lib_rend/ivas_reverb_iir_filter_fx.c b/lib_rend/ivas_reverb_iir_filter_fx.c index e09ec7005..981a40466 100644 --- a/lib_rend/ivas_reverb_iir_filter_fx.c +++ b/lib_rend/ivas_reverb_iir_filter_fx.c @@ -116,6 +116,8 @@ void ivas_reverb_iir_filt_set( return; } + + /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_iir_filt_2taps_feed_blk() * @@ -126,7 +128,7 @@ void ivas_reverb_iir_filt_2taps_feed_blk_fx( ivas_rev_iir_filter_t *iirFilter, /* i/o: IIR filter */ const UWord16 blk_size, /* i : size */ const Word32 *input, /* i : input buffer Q30 */ - Word32 *output /* i/o : output buffer Q30 */ + Word32 *output /* i/o: output buffer Q30 */ ) { UWord16 i; diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index f98fc83df..5b0f33864 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -84,7 +84,6 @@ extern const Word32 diffuseFieldCoherenceDifferenceX_fx[BINAURAL_COHERENCE_DIFFE extern const Word32 diffuseFieldCoherenceDifferenceY_fx[BINAURAL_COHERENCE_DIFFERENCE_BINS]; /*Q-31*/ extern const Word32 diffuseFieldCoherenceDifferenceZ_fx[BINAURAL_COHERENCE_DIFFERENCE_BINS]; /*Q-31*/ - /*----------------------------------------------------------------------------------* * TD ISM Object renderer *----------------------------------------------------------------------------------*/ @@ -96,12 +95,14 @@ extern const Word32 SincTable_fx[321]; /*----------------------------------------------------------------------------------* * t-design and SN3D normalization table *----------------------------------------------------------------------------------*/ + /* SN3D norm (Fixed) */ extern const Word32 norm_sn3d_hoa3_int[16]; /*Q-29*/ /* Order 11 t-design (Fixed) */ extern const Word32 t_design_11_azimuth_int[70]; /*Q-22*/ extern const Word32 t_design_11_elevation_int[70]; /*Q-22*/ + /*----------------------------------------------------------------------* * Reverberator ROM tables *-----------------------------------------------------------------------*/ @@ -110,17 +111,12 @@ extern const Word32 ivas_reverb_default_fc_fx[]; /*Q-16*/ extern const Word32 ivas_reverb_default_RT60_fx[]; /*Q-26*/ extern const Word32 ivas_reverb_default_DSR_fx[]; /*Q-30*/ -/*----------------------------------------------------------------------------------* - * Renderer SBA & MC enc/dec matrices - *----------------------------------------------------------------------------------*/ - /*----------------------------------------------------------------------------------* * EFAP ROM tables *----------------------------------------------------------------------------------*/ extern const Word8 efap_poly_limit[MAX_OUTPUT_CHANNELS]; - /*----------------------------------------------------------------------------------* * LS Configuration Converter ROM tables *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c index 6b27d9f17..467061cdd 100644 --- a/lib_rend/ivas_rom_rend_fx.c +++ b/lib_rend/ivas_rom_rend_fx.c @@ -282,15 +282,13 @@ const Word32 ivas_reverb_default_DSR_fx[IVAS_REVERB_DEFAULT_N_BANDS] /*Q30*/ = 66, 30, 28 }; -/*----------------------------------------------------------------------------------* - * Renderer SBA & MC enc/dec matrices - *----------------------------------------------------------------------------------*/ - /*----------------------------------------------------------------------------------* * EFAP ROM tables *----------------------------------------------------------------------------------*/ -const Word8 efap_poly_limit[MAX_OUTPUT_CHANNELS] = {22, 22, 22, 26, 30, 34, 36, 42, 42, 44, 47, 51, 52, 54, 54, 54}; +const Word8 efap_poly_limit[MAX_OUTPUT_CHANNELS] = { + 22, 22, 22, 26, 30, 34, 36, 42, 42, 44, 47, 51, 52, 54, 54, 54 +}; /*----------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index db6cc1d6e..c63013191 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -262,17 +262,6 @@ typedef struct dirac_output_synthesis_state_structure /* only pointer to local buffers */ Word32 *diffuse_responses_square_fx; /* squared diffuse responses. Size: num_channels. */ /* Q31 */ - /* only pointer to local buffers */ - - - /* only pointer to local buffers */ - - /* Output gain memories */ - - /* only pointer to local buffers */ - - /* PSD memories */ - const Word32 *onset_filter_fx; /* Q31 */ /* Temporal smoothing memories */ @@ -518,7 +507,6 @@ typedef struct triplet_search_structure } VBAP_SEARCH_STRUCT; - /* VBAP data structure. Contains the formed virtual surface arrangement * and supporting data. */ typedef struct vbap_data_structure { @@ -535,6 +523,7 @@ typedef struct vbap_data_structure Word16 *object_mode_bottom_virtual_speaker_node_division_gains_fx; /* Q16 */ Word16 *object_mode_top_virtual_speaker_node_division_gains_fx; /* Q16 */ Word16 *object_mode_back_virtual_speaker_node_division_gains_fx; /* Q16 */ + } VBAP_DATA, *VBAP_HANDLE; @@ -574,7 +563,6 @@ typedef struct ivas_binaural_reverb_struct UWord32 binRend_RandNext; Word16 highestBinauralCoherenceBin; - Word32 dmxmtx_fx[BINAURAL_CHANNELS][MAX_OUTPUT_CHANNELS]; Word32 foa_enc_fx[MAX_OUTPUT_CHANNELS][FOA_CHANNELS]; @@ -674,6 +662,7 @@ typedef struct ivas_dirac_dec_binaural_data_structure HANDLE_DIRAC_DECORR_STATE h_freq_domain_decorr_ap_state; } DIRAC_DEC_BIN_DATA, *DIRAC_DEC_BIN_HANDLE; + typedef struct ivas_binaural_rendering_conv_module_struct_fx { Word32 ***filterTapsLeftReal_fx; @@ -689,6 +678,7 @@ typedef struct ivas_binaural_rendering_conv_module_struct_fx } BINRENDERER_CONV_MODULE_FX, *BINRENDERER_CONV_MODULE_HANDLE_FX; + /*----------------------------------------------------------------------------------* * EFAP structures *----------------------------------------------------------------------------------*/ @@ -711,6 +701,7 @@ typedef struct EFAP_VERTEX_DATA Word16 *vtxOrder; /* Array that indicates the order of the vertex ranked by increasing azimuth */ } EFAP_VERTEX_DATA; + typedef struct EFAP_POLYSET { Word16 chan[EFAP_MAX_CHAN_NUM]; /* An array indicating the loudspeaker index of the polygon vertices */ @@ -720,6 +711,7 @@ typedef struct EFAP_POLYSET Word32 polyEle[EFAP_MAX_CHAN_NUM]; /* An array (same length as "chan"), with the elevation of the channels */ /* Q22 */ } EFAP_POLYSET; + typedef struct EFAP_LS_TRIANGLE { Word16 LS[3]; /* Array indicating the loudspeaker index of the triangle vertices */ @@ -749,6 +741,7 @@ typedef struct EFAP } EFAP, *EFAP_HANDLE; + /*----------------------------------------------------------------------------------* * Orientation tracking structure *----------------------------------------------------------------------------------*/ @@ -768,6 +761,7 @@ typedef struct ivas_orient_trk_state_t } ivas_orient_trk_state_t; + /*----------------------------------------------------------------------------------* * Head rotation data structure *----------------------------------------------------------------------------------*/ @@ -801,11 +795,14 @@ typedef struct ivas_binaural_head_track_struct ivas_orient_trk_state_t *OrientationTracker; ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; + } HEAD_TRACK_DATA, *HEAD_TRACK_DATA_HANDLE; + /*----------------------------------------------------------------------------------* * External orientation data structure *----------------------------------------------------------------------------------*/ + typedef struct ivas_external_orientation_struct { Word8 enableHeadRotation[MAX_PARAM_SPATIAL_SUBFRAMES]; /* 0 - disable, 1 - enable, 2 - freeze to previous rotation */ @@ -816,9 +813,12 @@ typedef struct ivas_external_orientation_struct Word16 num_subframes; } EXTERNAL_ORIENTATION_DATA, *EXTERNAL_ORIENTATION_HANDLE; + + /*----------------------------------------------------------------------------------* * Combined orientation data structure for the external orienations and head orientation *----------------------------------------------------------------------------------*/ + typedef struct ivas_combined_orientation_struct { Word16 enableCombinedOrientation[MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -853,8 +853,10 @@ typedef struct ivas_combined_orientation_struct Word16 cur_subframe_samples_rendered; Word16 subframe_idx_start; Word16 cur_subframe_samples_rendered_start; + } COMBINED_ORIENTATION_DATA, *COMBINED_ORIENTATION_HANDLE; + /*----------------------------------------------------------------------------------* * Reverberator structure *----------------------------------------------------------------------------------*/ @@ -869,6 +871,7 @@ typedef struct ivas_rev_delay_line_t Word16 Delay; UWord16 BufferPos; Word16 Gain_fx; // Q14 + } ivas_rev_delay_line_t; typedef struct ivas_rev_iir_filter_t @@ -883,8 +886,8 @@ typedef struct ivas_rev_iir_filter_t } ivas_rev_iir_filter_t; -typedef float rv_fftwf_type_complex[2]; /* complex type of fftwf library */ typedef Word32 rv_fftwf_type_complex_fx[2]; /* complex type of fftwf library */ + /* Convertion block for FFT filter: from time domain to frequency domain (with OLS) and back */ typedef struct ivas_reverb_t2f_f2t_t { @@ -892,13 +895,12 @@ typedef struct ivas_reverb_t2f_f2t_t Word16 log2_fft_size; Word16 block_size; Word16 hist_size; /* rv_fft_size - rv_block_size */ - // float fft_history_L[RV_FILTER_MAX_HISTORY]; Word32 fft_history_L_fx[RV_FILTER_MAX_HISTORY]; - // float fft_history_R[RV_FILTER_MAX_HISTORY]; Word32 fft_history_R_fx[RV_FILTER_MAX_HISTORY]; Word16 prev_shift; } ivas_reverb_t2f_f2t_t; + /* FFT filter with its frequency response coefficients */ typedef struct ivas_reverb_fft_filter_t { @@ -937,6 +939,7 @@ typedef struct ivas_reverb_state_t } REVERB_DATA, *REVERB_HANDLE; + /*----------------------------------------------------------------------------------* * Shoebox structure *----------------------------------------------------------------------------------*/ @@ -1019,7 +1022,6 @@ typedef struct er_struct_t Word32 user_origin_fx[3]; // is not needed Word32 *circ_buffers; - UWord16 *closest_ch_idx; shoebox_output_t shoebox_data; shoebox_obj_t shoebox_lib; @@ -1185,6 +1187,7 @@ typedef struct TDREND_HRFILT_FiltSet_struct ModelParamsITD_t ModelParamsITD; TDREND_HRFILT_Method_t FilterMethod; /* HR filtering method */ Word32 latency_s_fx; /* Q31 */ + } TDREND_HRFILT_FiltSet_t; /* Distance attenuation */ @@ -1291,12 +1294,14 @@ typedef struct Word32 binaural_latency_ns; BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd; TDREND_HRFILT_FiltSet_t **hHrtfTD; + } TDREND_WRAPPER, *TDREND_WRAPPER_HANDLE; /*------------------------------------------------------------------------------------------* * Crend structures *------------------------------------------------------------------------------------------*/ + typedef struct ivas_hrtfs_structure { Word32 *pOut_to_bin_re_fx[MAX_INTERN_CHANNELS][BINAURAL_CHANNELS]; // Q29 @@ -1316,6 +1321,7 @@ typedef struct ivas_hrtfs_structure Word16 init_from_rom; Word16 gain_lfe_fx; // Q14 } HRTFS_DATA, *HRTFS_HANDLE; + /* Main Crend structure */ typedef struct ivas_crend_state_t { @@ -1346,7 +1352,6 @@ typedef struct ivas_binaural_crend_wrapper_struct Word16 io_qfactor; } CREND_WRAPPER, *CREND_WRAPPER_HANDLE; - /* Fastconv binaural data structure */ typedef struct ivas_binaural_rendering_struct { @@ -1373,6 +1378,7 @@ typedef struct ivas_binaural_rendering_struct } BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; + /*------------------------------------------------------------------------------------------* * HRTF structures - hrtfs from binary files *------------------------------------------------------------------------------------------*/ @@ -1437,7 +1443,8 @@ typedef struct ivas_hrtfs_statistics_struct Word32 *average_energy_l_dyn; Word32 *average_energy_r_dyn; Word32 *inter_aural_coherence_dyn; - int16_t fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ + Word16 fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ + } HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; @@ -1447,7 +1454,7 @@ typedef struct ivas_hrtfs_statistics_struct typedef struct { - int32_t binaural_latency_ns; + Word32 binaural_latency_ns; BINAURAL_RENDERER_HANDLE hCldfbRend; HRTFS_FASTCONV_HANDLE hHrtfFastConv; @@ -1457,6 +1464,7 @@ typedef struct /*----------------------------------------------------------------------------------* * Limiter structure *----------------------------------------------------------------------------------*/ + typedef struct { Word16 max_num_channels; @@ -1471,9 +1479,9 @@ typedef struct int32_t cnt_frames_limited; /* counter of frames in which the limiter is applied */ #endif - } IVAS_LIMITER, *IVAS_LIMITER_HANDLE; + /*----------------------------------------------------------------------------------* * Loudspeaker Configuration Conversion structure *----------------------------------------------------------------------------------*/ @@ -1490,11 +1498,11 @@ typedef struct ivas_LS_setupconversion_struct } LSSETUP_CONVERSION_STRUCT, *LSSETUP_CONVERSION_HANDLE; - typedef struct ivas_LS_setupconversion_matrix_fx { Word16 index; Word32 value; + } LS_CONVERSION_MATRIX_FX; typedef struct ivas_LS_setupconversion_mapping_fx @@ -1502,7 +1510,9 @@ typedef struct ivas_LS_setupconversion_mapping_fx AUDIO_CONFIG input_config; AUDIO_CONFIG output_config; const LS_CONVERSION_MATRIX_FX *conversion_matrix_fx; + } LS_CONVERSION_MAPPING_FX; + typedef struct ivas_mono_downmix_renderer_struct { Word32 inputEnergy_fx; @@ -1516,6 +1526,7 @@ typedef struct ivas_mono_downmix_renderer_struct /*----------------------------------------------------------------------------------* * Custom Loudspeaker configuration structure *----------------------------------------------------------------------------------*/ + typedef struct ivas_LS_setup_custom { Word16 is_planar_setup; /* flag to indicate if setup is planar or not */ @@ -1527,8 +1538,8 @@ typedef struct ivas_LS_setup_custom Word16 separate_ch_found; /* flag to indicate if a center channel was found */ Word16 separate_ch_gains_fx[MAX_OUTPUT_CHANNELS]; /* gains to pan McMASA separateChannel in case no center channel is present */ -} LSSETUP_CUSTOM_STRUCT, *LSSETUP_CUSTOM_HANDLE; +} LSSETUP_CUSTOM_STRUCT, *LSSETUP_CUSTOM_HANDLE; /* Channel types in a channel-based config */ typedef enum @@ -1539,6 +1550,7 @@ typedef enum } ChannelType; + /*----------------------------------------------------------------------------------* * MASA external renderer structure *----------------------------------------------------------------------------------*/ @@ -1561,6 +1573,7 @@ typedef struct ivas_masa_external_rendering_struct HANDLE_CLDFB_FILTER_BANK cldfbSynRend[MAX_OUTPUT_CHANNELS]; } MASA_EXT_REND_DATA, *MASA_EXT_REND_HANDLE; + /*----------------------------------------------------------------------------------* * Multichannel MASA (McMASA) analysis structure *----------------------------------------------------------------------------------*/ @@ -1607,7 +1620,6 @@ typedef struct ivas_mcmasa_ana_data_structure Word16 numHorizontalChannels; UWord8 isHorizontalSetup; - MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; @@ -1616,6 +1628,7 @@ typedef struct ivas_mcmasa_ana_data_structure } MCMASA_ANA_DATA, *MCMASA_ANA_HANDLE; + /*----------------------------------------------------------------------------------* * Object MASA (OMASA) analysis structure *----------------------------------------------------------------------------------*/ @@ -1629,15 +1642,12 @@ typedef struct ivas_omasa_ana_data_structure HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc[MAX_NUM_OBJECTS]; /* DirAC parameter estimation */ - - Word16 band_grouping[MASA_FREQUENCY_BANDS + 1]; Word16 block_grouping[5]; /* diffuseness */ Word16 index_buffer_intensity; - MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; @@ -1657,12 +1667,13 @@ typedef struct ivas_omasa_ana_data_structure Word16 buffer_energy_q[DIRAC_NO_COL_AVG_DIFF]; Word32 chnlToFoaMtx_fx[FOA_CHANNELS][MCMASA_MAX_ANA_CHANS]; // Q15 - } OMASA_ANA_DATA, *OMASA_ANA_HANDLE; + /*----------------------------------------------------------------------------------* * DirAC analysis structure *----------------------------------------------------------------------------------*/ + typedef struct ivas_dirac_ana_data_structure { Word16 nbands; @@ -1690,6 +1701,8 @@ typedef struct ivas_dirac_ana_data_structure Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; } DIRAC_ANA_DATA, *DIRAC_ANA_HANDLE; + + /*----------------------------------------------------------------------------------* * MASA prerend structure *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_td_decorr_fx.c b/lib_rend/ivas_td_decorr_fx.c index 14795da41..7d0d2e5e2 100644 --- a/lib_rend/ivas_td_decorr_fx.c +++ b/lib_rend/ivas_td_decorr_fx.c @@ -203,7 +203,7 @@ ivas_error ivas_td_decorr_dec_open_fx( ivas_td_decorr_state_t *hTdDecorr_loc; ivas_error error; - buf_len = extract_l( Mpy_32_32( output_Fs, 4294968 ) ); // IVAS_DECORR_PARM_LOOKAHEAD_TAU * 2 ^ 31 -> 4294968 + buf_len = extract_l( Mpy_32_32( output_Fs, 4294968 ) ); // IVAS_DECORR_PARM_LOOKAHEAD_TAU=2e-3f * 2 ^ 31 -> 4294968 num_out_chans = sub( nchan_internal, 1 ); diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 05b78f670..30f44a7a7 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -415,7 +415,7 @@ void IVAS_REND_cldfbSynthesis_wrapper( Word32 **realBuffer, /* i : real values */ Word32 **imagBuffer, /* i : imag values */ Word32 *timeOut, /* o : output time domain samples */ - const int16_t samplesToProcess, /* i : number of processed samples */ + const Word16 samplesToProcess, /* i : number of processed samples */ IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb, /* i : filter bank state */ Word16 Q_cldfb, Word16 *Q_out diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index c74d77bf9..b3a9d7dfc 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -63,15 +63,11 @@ * Local types *-------------------------------------------------------------------*/ -typedef float pan_vector[MAX_OUTPUT_CHANNELS]; -typedef float pan_matrix[MAX_INPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; -typedef float rotation_gains[MAX_INPUT_CHANNELS][MAX_INPUT_CHANNELS]; typedef Word32 pan_vector_fx[MAX_OUTPUT_CHANNELS]; typedef Word32 pan_matrix_fx[MAX_INPUT_CHANNELS][MAX_OUTPUT_CHANNELS]; typedef Word16 rotation_gains_fx[MAX_INPUT_CHANNELS][MAX_INPUT_CHANNELS]; typedef Word32 rotation_gains_Word32[MAX_INPUT_CHANNELS][MAX_INPUT_CHANNELS]; typedef Word32 rotation_matrix_fx[3][3]; -typedef float rotation_matrix[3][3]; /* EFAP wrapper to simplify writing panning gains to a vector that includes LFE channels */ typedef struct @@ -123,7 +119,6 @@ typedef struct rotation_matrix_fx rot_mat_prev; pan_vector_fx prev_pan_gains_fx; rotation_matrix_fx rot_mat_prev_fx; - pan_vector prev_pan_gains; Word8 firstFrameRendered; TDREND_WRAPPER splitTdRendWrappers[MAX_HEAD_ROT_POSES - 1]; /* Additional TD Rend instances used for split rendering */ Word32 *bufferData_fx; @@ -138,13 +133,9 @@ typedef struct { Word16 numLfeChannels; bool pan_lfe; - // float lfeInputGain; Word32 lfeInputGain_fx; /* Q31 */ - // float lfeOutputAzimuth; Word16 lfeOutputAzimuth_fx; - // float lfeOutputElevation; Word16 lfeOutputElevation_fx; - // IVAS_REND_LfePanMtx lfePanMtx; IVAS_REND_LfePanMtx_fx lfePanMtx_fx; /* Q31 */ } lfe_routing; @@ -175,7 +166,6 @@ typedef struct typedef struct { input_base base; - // pan_matrix hoaDecMtx; pan_matrix_fx hoaDecMtx_fx; CLDFB_REND_WRAPPER cldfbRendWrapper; CREND_WRAPPER_HANDLE crendWrapper; @@ -2115,7 +2105,7 @@ static ivas_error updateLfePanGainsForMcOut( } /* linear input gain */ - v_multc_fixed( inputMc->lfeRouting.lfePanMtx_fx[i], inputMc->lfeRouting.lfeInputGain_fx, inputMc->lfeRouting.lfePanMtx_fx[i], numOutChannels ); /* Q31 */ + v_multc_fx( inputMc->lfeRouting.lfePanMtx_fx[i], inputMc->lfeRouting.lfeInputGain_fx, inputMc->lfeRouting.lfePanMtx_fx[i], numOutChannels ); /* Q31 */ } return error; @@ -2149,7 +2139,7 @@ static ivas_error updateLfePanGainsForAmbiOut( ivas_dirac_dec_get_response_fx( inputMc->lfeRouting.lfeOutputAzimuth_fx, inputMc->lfeRouting.lfeOutputElevation_fx, inputMc->lfeRouting.lfePanMtx_fx[i], outAmbiOrder, Q29 ); /* linear input gain */ - v_multc_fixed( inputMc->lfeRouting.lfePanMtx_fx[i], inputMc->lfeRouting.lfeInputGain_fx, inputMc->lfeRouting.lfePanMtx_fx[i], IVAS_MAX_OUTPUT_CHANNELS ); /* Q31 */ + v_multc_fx( inputMc->lfeRouting.lfePanMtx_fx[i], inputMc->lfeRouting.lfeInputGain_fx, inputMc->lfeRouting.lfePanMtx_fx[i], IVAS_MAX_OUTPUT_CHANNELS ); /* Q31 */ } return error; @@ -3985,7 +3975,7 @@ static ivas_error ivas_pre_rend_init( move16(); move32(); - IF( ( pSplitRendEncBuffer->data_fx = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( float ) ) ) == NULL ) + IF( ( pSplitRendEncBuffer->data_fx = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( Word32 ) ) ) == NULL ) { return IVAS_ERR_FAILED_ALLOC; } @@ -4950,6 +4940,7 @@ Word16 IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend->hDiracDecBin[0] != NULL && pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb != NULL ) { ivas_binaural_reverb_close_fx( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb ); + IF( NE_32( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hDiracDecBin[0]->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), *pMasaInput->base.ctx.pOutSampleRate, NULL, NULL, NULL ) ), IVAS_ERR_OK ) ) { return error; @@ -4958,6 +4949,7 @@ Word16 IVAS_REND_FeedRenderConfig( if ( pMasaInput->hMasaExtRend->hReverb != NULL ) { ivas_binaural_reverb_close_fx( &pMasaInput->hMasaExtRend->hReverb ); + IF( NE_32( ( error = ivas_binaural_reverb_init( &pMasaInput->hMasaExtRend->hReverb, hIvasRend->hHrtfs.hHrtfStatistics, pMasaInput->hMasaExtRend->hSpatParamRendCom->num_freq_bands, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRenderConfig->roomAcoustics ), *pMasaInput->base.ctx.pOutSampleRate, NULL, NULL, NULL ) ), IVAS_ERR_OK ) ) { return error; @@ -6573,7 +6565,7 @@ static ivas_error renderInputIsm( move32(); /* Apply input gain to new audio */ - v_multc_fixed( inAudio.data_fx, ismInput->base.gain_fx, inAudio.data_fx, imult1616( inAudio.config.numSamplesPerChannel, inAudio.config.numChannels ) ); + v_multc_fx( inAudio.data_fx, ismInput->base.gain_fx, inAudio.data_fx, imult1616( inAudio.config.numSamplesPerChannel, inAudio.config.numChannels ) ); *outAudio.pq_fact = sub( *outAudio.pq_fact, Q1 ); move16(); exp = *outAudio.pq_fact; @@ -6718,10 +6710,10 @@ static ivas_error renderLfeToBinaural_fx( assert( mcInput->binauralDelaySmp < frame_size ); /* Get delayed LFE signal from previous frame, apply gain and save in tmp buffer */ - v_multc_fixed( mcInput->lfeDelayBuffer_fx, gain_fx, tmpLfeBuffer, num_cpy_smpl_prev_frame ); /* Qx - 1 */ + v_multc_fx( mcInput->lfeDelayBuffer_fx, gain_fx, tmpLfeBuffer, num_cpy_smpl_prev_frame ); /* Qx - 1 */ /* Continue filling tmp buffer, now with LFE signal from current frame */ - v_multc_fixed( lfeInput, gain_fx, tmpLfeBuffer + num_cpy_smpl_prev_frame, num_cpy_smpl_cur_frame ); /* Qx - 1 */ + v_multc_fx( lfeInput, gain_fx, tmpLfeBuffer + num_cpy_smpl_prev_frame, num_cpy_smpl_cur_frame ); /* Qx - 1 */ /* Save remaining LFE samples of current frame for next frame */ MVR2R_WORD32( lfeInput + num_cpy_smpl_cur_frame, mcInput->lfeDelayBuffer_fx, num_cpy_smpl_prev_frame ); @@ -7395,7 +7387,7 @@ static ivas_error renderInputMc( } mcInput->base.numNewSamplesPerChannel = 0; move32(); - v_multc_fixed( inAudio.data_fx, mcInput->base.gain_fx, inAudio.data_fx, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); + v_multc_fx( inAudio.data_fx, mcInput->base.gain_fx, inAudio.data_fx, inAudio.config.numSamplesPerChannel * inAudio.config.numChannels ); *outAudio.pq_fact = sub( *outAudio.pq_fact, Q1 ); // reducing the Q by 1 compensating for the v_mult_fixed done move16(); /* set combined orientation subframe info to start info */ @@ -7950,7 +7942,7 @@ static ivas_error renderInputSba( *outAudio.pq_fact = outAudio.q_factor; move16(); /* Apply input gain to new audio */ - v_multc_fixed( inAudio.data_fx, sbaInput->base.gain_fx, inAudio.data_fx, i_mult( inAudio.config.numSamplesPerChannel, inAudio.config.numChannels ) ); + v_multc_fx( inAudio.data_fx, sbaInput->base.gain_fx, inAudio.data_fx, i_mult( inAudio.config.numSamplesPerChannel, inAudio.config.numChannels ) ); *outAudio.pq_fact = sub( *outAudio.pq_fact, 1 ); // to compensate for the qfactor reduction in gain multiplication. move16(); @@ -8319,7 +8311,7 @@ static ivas_error renderInputMasa( *outAudio.pq_fact = outAudio.q_factor; move16(); /* Apply input gain to new audio */ - v_multc_fixed( inAudio.data_fx, masaInput->base.gain_fx, inAudio.data_fx, i_mult( inAudio.config.numSamplesPerChannel, inAudio.config.numChannels ) ); + v_multc_fx( inAudio.data_fx, masaInput->base.gain_fx, inAudio.data_fx, i_mult( inAudio.config.numSamplesPerChannel, inAudio.config.numChannels ) ); *outAudio.pq_fact = sub( *outAudio.pq_fact, 1 ); // to compensate for the qfactor reduction in gain multiplication. move16(); -- GitLab