diff --git a/lib_com/options.h b/lib_com/options.h index e8a44d873d9aaa3d8cc9b9db02792a309469fbec..5ed2aa912363340d6e3c275e3b6744f3d859765a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -1,87 +1,90 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ - -#ifndef OPTIONS_H -#define OPTIONS_H - -/* clang-format off */ - -/* ################### Start DEBUGGING switches ######################## */ - -/*#define DEBUGGING*/ /* Allows debugging message to be printed out during runtime */ -#ifdef DEBUGGING -#define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ -#define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */ -#define DEBUG_FORCE_MDCT_STEREO_MODE /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */ -/*#define DEBUG_FORCE_DIR*/ /* Force modes/parameters by reading from external binary files */ -/*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ -#define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */ -#endif - -#define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ - -/*#define WMOPS*/ /* Activate complexity and memory counters */ -#ifdef WMOPS -/*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ -/*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */ -/*#define WMOPS_WC_FRAME_ANALYSIS*/ /* Output detailed complexity analysis for the worst-case frame */ -/*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ -#endif - -/* #################### End DEBUGGING switches ############################ */ - -#ifndef BASOP_NOGLOB_DEV_USE_GLOBALS -#define BASOP_NOGLOB_DECLARE_LOCAL -#endif - -#define FIX_867_CLDFB_NRG_SCALE - -#define FIX_1378_ACELP_OUT_OF_BOUNDS - -/* Note: each compile switch (FIX_1101_...) is independent from the other ones */ -//#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ -#define OPT_AVOID_STATE_BUF_RESCALE /* Optimization made to avoid rescale of synth state buffer */ -#define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/ -#define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot /*FhG: WMOPS tuning, nonbe*/ -/* Both following 2 macros (IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST*) are independent from each other, they refer to different code blocks */ -#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE /* FhG: reduces WMOPS of param_mc_prm_est, bit-exact to previous version */ -//#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE /* FhG: reduces WMOPS of param_mc_prm_est, not bit-exact to previous version. Obsoleted by MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE. */ -#define HARM_PUSH_BIT -#define HARM_ENC_INIT -//#define HARM_SCE_INIT -#define DIV32_OPT_NEWTON /* FhG: faster 32 by 32 bit division */ -#define MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of Cy calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Obsoletes IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE. */ -#endif +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +/*==================================================================================== + EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 + ====================================================================================*/ + +#ifndef OPTIONS_H +#define OPTIONS_H + +/* clang-format off */ + +/* ################### Start DEBUGGING switches ######################## */ + +/*#define DEBUGGING*/ /* Allows debugging message to be printed out during runtime */ +#ifdef DEBUGGING +#define DEBUG_MODE_INFO /* Define to output most important parameters to the subdirectory "res/" */ +#define DEBUG_MODE_INFO_TWEAK /* Enable command line switch to specify subdirectory for debug info output inside "./res/" */ +#define DEBUG_FORCE_MDCT_STEREO_MODE /* Force stereo mode decision for MDCT stereo: -stereo 3 1 forces L/R coding and -stereo 3 2 forces full M/S coding */ +/*#define DEBUG_FORCE_DIR*/ /* Force modes/parameters by reading from external binary files */ +/*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ +#define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */ +#endif + +#define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ + +/*#define WMOPS*/ /* Activate complexity and memory counters */ +#ifdef WMOPS +/*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ +/*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */ +/*#define WMOPS_WC_FRAME_ANALYSIS*/ /* Output detailed complexity analysis for the worst-case frame */ +/*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ +#endif + +/* #################### End DEBUGGING switches ############################ */ + +#ifndef BASOP_NOGLOB_DEV_USE_GLOBALS +#define BASOP_NOGLOB_DECLARE_LOCAL +#endif + +#define FIX_867_CLDFB_NRG_SCALE + +#define FIX_1378_ACELP_OUT_OF_BOUNDS + +/* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +//#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ +#define OPT_AVOID_STATE_BUF_RESCALE /* Optimization made to avoid rescale of synth state buffer */ +#define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/ +#define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot /*FhG: WMOPS tuning, nonbe*/ +/* Both following 2 macros (IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST*) are independent from each other, they refer to different code blocks */ +#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE /* FhG: reduces WMOPS of param_mc_prm_est, bit-exact to previous version */ +//#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE /* FhG: reduces WMOPS of param_mc_prm_est, not bit-exact to previous version. Obsoleted by MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE. */ +#define HARM_PUSH_BIT +#define HARM_ENC_INIT +//#define HARM_SCE_INIT +#define DIV32_OPT_NEWTON /* FhG: faster 32 by 32 bit division */ +#define MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of Cy calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Obsoletes IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE. */ + +#define TEST_HR + +#endif diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 22af9097ddb2a538140f180f0c87660a2b0d6971..e694b60c23b57ff6780c49020375890592655164 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -518,7 +518,12 @@ void encod_gen_voic_ivas_fx( set16_fx( code_preQ_fx, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); - +#ifdef TEST_HR + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) + { + shift_wsp = sub( shift_wsp, 1 ); + } +#endif /* set and write harmonicity flag */ harm_flag_acelp = 0; move16(); @@ -621,18 +626,33 @@ void encod_gen_voic_ivas_fx( IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) { +#ifdef TEST_HR + gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, + &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR ); +#else gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, sub( shift_wsp, 1 ), y2_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR ); +#endif } ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) ) { +#ifdef TEST_HR + gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx, + &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp ); +#else gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, sub( shift_wsp, 1 ) ); +#endif } ELSE { +#ifdef TEST_HR + gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, Es_pred_fx, + &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx ); +#else gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, sub( shift_wsp, 1 ), y2_fx, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx ); +#endif } IF( st_fx->Opt_SC_VBR ) { diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index d6935dd0ce0cbbf841fc6f7917dba300dfd34f33..8e4f13116e030f44bea24b521666c95538462796 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -520,7 +520,12 @@ Word16 encod_tran_ivas_fx( move16(); set16_fx( code_preQ, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); - +#ifdef TEST_HR + if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) + { + shift_wsp = sub( shift_wsp, 1 ); + } +#endif /*----------------------------------------------------------------* * ACELP subframe loop *----------------------------------------------------------------*/ @@ -540,8 +545,11 @@ Word16 encod_tran_ivas_fx( q_h1 = sub( 14, norm_s( h1[0] ) ); Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ +#ifdef TEST_HR + Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); +#else Scale_sig( h1, L_SUBFR, sub( 13, q_h1 ) ); - +#endif /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_SUBFR, shift ); @@ -559,7 +567,9 @@ Word16 encod_tran_ivas_fx( IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { +#ifndef TEST_HR Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ +#endif transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift ); } @@ -587,22 +597,37 @@ Word16 encod_tran_ivas_fx( IF( Jopt_flag == 0 ) { /* SQ gain_code */ +#ifdef TEST_HR + gain_enc_tc_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y2, code, Es_pred_fx, + &gain_pit, &gain_code, &gain_inov, &norm_gain_code, shift_wsp ); +#else gain_enc_tc_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y2, code, Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, sub( shift_wsp, 1 ) ); +#endif } ELSE { IF( GT_32( st_fx->core_brate, ACELP_32k ) ) { /* SQ gain_pit and gain_code */ +#ifdef TEST_HR + gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y1, y2, code, Es_pred_fx, + &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, shift_wsp ); +#else gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y1, y2, code, Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, sub( shift_wsp, 1 ) ); +#endif } ELSE { /* VQ gain_pit and gain_code */ +#ifdef TEST_HR + gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame_fx, i_subfr, tc_subfr, xn, y1, shift_wsp, y2, code, Es_pred_fx, + &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); +#else gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame_fx, i_subfr, tc_subfr, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); +#endif } } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 6718552c50c293060c7af36aa7625249778aeb3b..9f630da6613efe31400cd71440e9f12823a9f672 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -1423,7 +1423,11 @@ void transition_enc_ivas_fx( *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, ( Q_new + shift - 1 ) ); move16(); +#ifdef TEST_HR + Copy( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ) ); +#else Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 ); +#endif lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15, xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); @@ -1660,7 +1664,11 @@ void transition_enc_ivas_fx( *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, Q_new ); move16(); +#ifdef TEST_HR + Copy( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ) ); +#else Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 ); +#endif lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15, xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) @@ -2082,7 +2090,11 @@ static void tc_enc_ivas_fx( /*--------------------------------------------------------------* * compute glottal-shape codebook excitation *--------------------------------------------------------------*/ +#ifdef TEST_HR + Copy( h1, h1_fx, L_SUBFR + ( M + 1 ) ); +#else Copy_Scale_sig( h1, h1_fx, L_SUBFR + ( M + 1 ), 1 ); +#endif /* create filtered glottal codebook contribution */ conv_fx( &exc_fx[i_subfr], h1_fx, yy1_fx, L_SUBFR );